diff --git a/.gitignore b/.gitignore index ff947966a2b9c7814a8ca64228810130cabe96f6..b2913b82aead866c8a72dbbe6bfbf16f7c2c0e78 100644 --- a/.gitignore +++ b/.gitignore @@ -18,3 +18,8 @@ GPATH GRTAGS GTAGS tags + +# others +nfapi_nr_interface_scf +*.log +*.out diff --git a/.vscode/launch.json b/.vscode/launch.json index 4b563febdea2f01db7f95405d5bc5ffb1803f586..8be69157639e9efa5c6bffc1a1ffd770d2d7d6ff 100644 --- a/.vscode/launch.json +++ b/.vscode/launch.json @@ -8,14 +8,17 @@ "name": "(gdb) Launch", "type": "cppdbg", "request": "launch", - "program": "enter program name, for example ${workspaceFolder}/a.exe", - "args": [], + "program": "${workspaceFolder}/cmake_targets/ran_build/build/lte-softmodem", + "args": [ + "-O", "../ci-scripts/conf_files/rcc.band7.tm1.nfapi.conf", + "--noS1" + ], "stopAtEntry": false, - "cwd": "${workspaceFolder}", + "cwd": "${workspaceFolder}/cmake_targets", "environment": [], "externalConsole": false, "MIMode": "gdb", - "miDebuggerPath": "/path/to/gdb", + "miDebuggerPath": "${workspaceFolder}/cmake_targets/sudo-gdb", "setupCommands": [ { "description": "Enable pretty-printing for gdb", diff --git a/README.md b/README.md index 62f8576e81547cf7769ff966ec0b524629a40ea3..4f38f77e4e9d37d8fdc54ff6b867bc84db818d72 100644 --- a/README.md +++ b/README.md @@ -21,16 +21,28 @@ # OpenAirInterface License # -OpenAirInterface is under OpenAirInterface Software Alliance license. +### Included Fixes: ### +- Ease of use of gprof and address sanitizer for debugging purposes +- Updated json files to allow for GDB, real-time debugging capabilities +- Updated logging features to minimally log only key connection milestones. This imroves scalability of multiple UEs. +- Updated logging to include time stamp for timing analysis +- Updated memory allocation procedures to correct size requirements +- Added debugging features to handle signal terminations +- nfapi.c pullarray8 fix invalid pointer math +- Overlapping destination and source memory in memcpy, so updated to memmove to check for this bug +- Advanced error checking mechanisms in critical pack and unpack functions +- Created option for CPU assignment to UE to improve scalability +- Added EPC integration to allow multiple individual UE entities to each have their USIM information parced by the executables +- Updated random value seeds to minimize probability of error in generation of random values +- Enables capability round robin scheduler if desired +- Enables capability real time scheduler if desired +- Added new standalone functions to the UE phy-layer (phy_stub_ue.c) to incorporate individual UE entities +- Updated sending and packing functions in UE (lte_ue.c) to incorporate new standalone changes +- Incorporated semaphores to control timing of incoming downlink packets +- Implemented new queuing system to handle message exchange from UE to eNB and vice versa +- Updated global value in nFAPI for size of subframe +- Updated global value to increase scalability in system - * [OAI License Model](http://www.openairinterface.org/?page_id=101) - * [OAI License v1.1 on our website](http://www.openairinterface.org/?page_id=698) - -It is distributed under **OAI Public License V1.1**. - -The license information is distributed under [LICENSE](LICENSE) file in the same directory. - -Please see [NOTICE](NOTICE.md) file for third party software that is included in the sources. # Where to Start # diff --git a/ci-scripts/Jenkinsfile-GitLab-Container b/ci-scripts/Jenkinsfile-GitLab-Container index 654ad23230bfaf745d3b0d6953a972c44493888e..f5852bace54c2773d4fbe3eda0bb7be2f9cff3f0 100644 --- a/ci-scripts/Jenkinsfile-GitLab-Container +++ b/ci-scripts/Jenkinsfile-GitLab-Container @@ -198,17 +198,37 @@ pipeline { } } } - stage ("RF Simulators") { + stage ("4G RF Simulators") { when { expression {doMandatoryTests} } steps { script { - triggerSlaveJob ('RAN-RF-Sim-Test', 'Test-RF-Sim-Container') + triggerSlaveJob ('RAN-RF-Sim-Test-4G', 'Test-RF-Sim-Container-4G') } } post { always { script { - finalizeSlaveJob('RAN-RF-Sim-Test') + finalizeSlaveJob('RAN-RF-Sim-Test-4G') + } + } + failure { + script { + currentBuild.result = 'FAILURE' + } + } + } + } + stage ("5G RF Simulators") { + when { expression {doMandatoryTests} } + steps { + script { + triggerSlaveJob ('RAN-RF-Sim-Test-5G', 'Test-RF-Sim-Container-4G') + } + } + post { + always { + script { + finalizeSlaveJob('RAN-RF-Sim-Test-5G') } } failure { @@ -238,6 +258,26 @@ pipeline { } } } + stage ("Test OAI NR UE - OAI gNB - TDD - Band 78 - N300") { + when { expression {doMandatoryTests} } + steps { + script { + triggerSlaveJob ('RAN-gNB-nrUE-MONO-TDD-Band78-N300', 'Test-TDD-Band78-gNB-NR-UE') + } + } + post { + always { + script { + finalizeSlaveJob('RAN-gNB-nrUE-MONO-TDD-Band78-N300') + } + } + failure { + script { + currentBuild.result = 'FAILURE' + } + } + } + } } } stage ("Images Push to Registries") { diff --git a/ci-scripts/Jenkinsfile-gitlab b/ci-scripts/Jenkinsfile-gitlab index a0284edb71cc6a645128f192c2deda78a850ad96..3042ada815afe4ad4a60c7efb4a096ee432f3187 100644 --- a/ci-scripts/Jenkinsfile-gitlab +++ b/ci-scripts/Jenkinsfile-gitlab @@ -404,26 +404,6 @@ pipeline { } } } - stage ("Test L2 simulator") { - when { - expression {doFullTestsuite} - } - steps { - lock (vmResource) { - script { - timeout (time: 30, unit: 'MINUTES') { - try { - gitlabCommitStatus(name: "Test L2-sim") { - sh "./ci-scripts/oai-ci-vm-tool test --workspace $WORKSPACE --variant l2-sim --job-name ${JOB_NAME} --build-id ${BUILD_ID}" - } - } catch (Exception e) { - currentBuild.result = 'FAILURE' - } - } - } - } - } - } stage ("Destroy all Virtual Machines") { when { expression {doMandatoryTests} @@ -549,74 +529,6 @@ pipeline { } } } - stage ("Test MONOLITHIC - FDD - Band 13 - B210") { - when { - expression {doFullTestsuite} - } - steps { - script { - sh "sleep 60" - triggerSlaveJob ('eNB-CI-MONO-FDD-Band13-B210', 'Test-Mono-FDD-Band13-LTE-M') - } - } - post { - always { - script { - finalizeSlaveJob('eNB-CI-MONO-FDD-Band13-B210') - } - } - failure { - script { - currentBuild.result = 'FAILURE' - } - } - } - } - stage ("Test X2 Handover - FDD - Band 13 - B210") { - when { - expression {doFullTestsuite} - } - steps { - script { - sh "sleep 60" - triggerSlaveJob ('eNB-CI-MONO-FDD-Band13-X2HO-B210', 'Test-Mono-FDD-Band13-X2-HO') - } - } - post { - always { - script { - finalizeSlaveJob('eNB-CI-MONO-FDD-Band13-X2HO-B210') - } - } - failure { - script { - currentBuild.result = 'FAILURE' - } - } - } - } - stage ("Test IF4p5 - TDD - Band 38 - B210 - MultiRRU") { - when { - expression {doFullTestsuite} - } - steps { - script { - triggerSlaveJob ('eNB-CI-IF4p5-TDD-Band38-MultiRRU-B210', 'Test-IF4p5-TDD-Band38-Multi-RRU') - } - } - post { - always { - script { - finalizeSlaveJob('eNB-CI-IF4p5-TDD-Band38-MultiRRU-B210') - } - } - failure { - script { - currentBuild.result = 'FAILURE' - } - } - } - } stage ("Test OAI UE - FDD - Band 20 - B200") { when { expression {doFullTestsuite} @@ -663,50 +575,6 @@ pipeline { } } } - stage ("Test OAI NR UE - OAI gNB - TDD - Band 78 - N300") { - when { - expression {doMandatoryTests} - } - steps { - script { - triggerSlaveJob ('gNB-nrUE-MONO-TDD-Band78-N300', 'Test-TDD-Band78-gNB-NR-UE') - } - } - post { - always { - script { - finalizeSlaveJob('gNB-nrUE-MONO-TDD-Band78-N300') - } - } - failure { - script { - currentBuild.result = 'FAILURE' - } - } - } - } - stage ("Test OAI OCP-eNB - FDD - Band 7 - B210") { - when { - expression {doFullTestsuite} - } - steps { - script { - triggerSlaveJob ('OCPeNB-FDD-Band7-B210', 'Test-OCP-FDD-Band7') - } - } - post { - always { - script { - finalizeSlaveJob('OCPeNB-FDD-Band7-B210') - } - } - failure { - script { - currentBuild.result = 'FAILURE' - } - } - } - } } post { always { diff --git a/ci-scripts/Jenkinsfile-tmp-multi-enb-nsa b/ci-scripts/Jenkinsfile-tmp-multi-enb-nsa index dd9fbbd03c81e54d9dd8306adb5d9ea8461ab88e..6e987a5e38547155cd37ff4d52d27e40dc2f0a60 100644 --- a/ci-scripts/Jenkinsfile-tmp-multi-enb-nsa +++ b/ci-scripts/Jenkinsfile-tmp-multi-enb-nsa @@ -37,6 +37,7 @@ def testStageName = params.pipelineTestStageName // Name of the phone/server resource def ciSmartPhonesResource1 = params.SmartPhonesResource1 def ciSmartPhonesResource2 = params.SmartPhonesResource2 +def ciSmartPhonesResource3 = params.SmartPhonesResource3 // Global Parameters. Normally they should be populated when the master job // triggers the slave job with parameters @@ -55,7 +56,7 @@ pipeline { options { disableConcurrentBuilds() ansiColor('xterm') - lock(extra: [[resource: ciSmartPhonesResource2]], resource: ciSmartPhonesResource1) + lock(extra: [[resource: ciSmartPhonesResource2],[resource: ciSmartPhonesResource1]],resource: ciSmartPhonesResource3) } stages { stage("Build Init") { @@ -87,6 +88,9 @@ pipeline { if (params.SmartPhonesResource2 == null) { allParametersPresent = false } + if (params.SmartPhonesResource3 == null) { + allParametersPresent = false + } // 1st eNB parameters if (params.eNB_IPAddress == null) { allParametersPresent = false @@ -117,6 +121,15 @@ pipeline { if (params.eNB2_Credentials == null) { allParametersPresent = false } + if (params.UE_IPAddress == null) { + allParametersPresent = false + } + if (params.UE_SourceCodePath == null) { + allParametersPresent = false + } + if (params.UE_Credentials == null) { + 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) { @@ -213,21 +226,22 @@ pipeline { [$class: 'UsernamePasswordMultiBinding', credentialsId: "${params.eNB1_Credentials}", usernameVariable: 'eNB1_Username', passwordVariable: 'eNB1_Password'], [$class: 'UsernamePasswordMultiBinding', credentialsId: "${params.eNB2_Credentials}", usernameVariable: 'eNB2_Username', passwordVariable: 'eNB2_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.ADB_Credentials}", usernameVariable: 'ADB_Username', passwordVariable: 'ADB_Password'], + [$class: 'UsernamePasswordMultiBinding', credentialsId: "${params.UE_Credentials}", usernameVariable: 'UE_Username', passwordVariable: 'UE_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}" String[] myXmlTestSuite = testXMLFile.split("\\r?\\n") for (xmlFile in myXmlTestSuite) { if (fileExists(xmlFile)) { try { - sh "python3 main.py --mode=TesteNB --ranRepository=${eNB_Repository} --ranBranch=${eNB_Branch} --ranCommitID=${eNB_CommitID} --ranAllowMerge=${eNB_AllowMergeRequestProcess} --ranTargetBranch=${eNB_TargetBranch} --eNBIPAddress=${params.eNB_IPAddress} --eNBUserName=${eNB_Username} --eNBPassword=${eNB_Password} --eNBSourceCodePath=${params.eNB_SourceCodePath} --eNB1IPAddress=${params.eNB1_IPAddress} --eNB1UserName=${eNB1_Username} --eNB1Password=${eNB1_Password} --eNB1SourceCodePath=${params.eNB1_SourceCodePath} --eNB2IPAddress=${params.eNB2_IPAddress} --eNB2UserName=${eNB2_Username} --eNB2Password=${eNB2_Password} --eNB2SourceCodePath=${params.eNB2_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}" + sh "python3 main.py --mode=TesteNB --ranRepository=${eNB_Repository} --ranBranch=${eNB_Branch} --ranCommitID=${eNB_CommitID} --ranAllowMerge=${eNB_AllowMergeRequestProcess} --ranTargetBranch=${eNB_TargetBranch} --eNBIPAddress=${params.eNB_IPAddress} --eNBUserName=${eNB_Username} --eNBPassword=${eNB_Password} --eNBSourceCodePath=${params.eNB_SourceCodePath} --eNB1IPAddress=${params.eNB1_IPAddress} --eNB1UserName=${eNB1_Username} --eNB1Password=${eNB1_Password} --eNB1SourceCodePath=${params.eNB1_SourceCodePath} --eNB2IPAddress=${params.eNB2_IPAddress} --eNB2UserName=${eNB2_Username} --eNB2Password=${eNB2_Password} --eNB2SourceCodePath=${params.eNB2_SourceCodePath} --UEIPAddress=${params.UE_IPAddress} --UEUserName=${UE_Username} --UEPassword=${UE_Password} --UESourceCodePath=${params.UE_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}" } 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}" + sh "python3 main.py --mode=FinalizeHtml --finalStatus=${buildStageStatus} --eNBIPAddress=${params.eNB_IPAddress} --eNBUserName=${eNB_Username} --eNBPassword=${eNB_Password} --UEIPAddress=${params.UE_IPAddress} --UEUserName=${UE_Username} --UEPassword=${UE_Password}" } } } @@ -253,6 +267,24 @@ pipeline { } } } + stage('Log Collection (OAI UE - Build)') { + steps { + echo '\u2705 \u001B[32mLog Collection (OAI UE - Build)\u001B[0m' + withCredentials([ + [$class: 'UsernamePasswordMultiBinding', credentialsId: "${params.UE_Credentials}", usernameVariable: 'UE_Username', passwordVariable: 'UE_Password'] + ]) { + sh "python3 ci-scripts/main.py --mode=LogCollectBuild --UEIPAddress=${params.UE_IPAddress} --UEUserName=${UE_Username} --UEPassword=${UE_Password} --UESourceCodePath=${params.UE_SourceCodePath}" + + echo '\u2705 \u001B[32mLog Transfer (UE - Build)\u001B[0m' + sh "sshpass -p \'${UE_Password}\' scp -o 'StrictHostKeyChecking no' -o 'ConnectTimeout 10' ${UE_Username}@${params.UE_IPAddress}:${UE_SourceCodePath}/cmake_targets/build.log.zip ./build.log.${env.BUILD_ID}.zip || true" + } + script { + if(fileExists("build.log.${env.BUILD_ID}.zip")) { + archiveArtifacts "build.log.${env.BUILD_ID}.zip" + } + } + } + } stage('Log Collection (eNB - Run)') { steps { withCredentials([ @@ -271,6 +303,24 @@ pipeline { } } } + stage('Log Collection (OAI UE - Run)') { + steps { + withCredentials([ + [$class: 'UsernamePasswordMultiBinding', credentialsId: "${params.UE_Credentials}", usernameVariable: 'UE_Username', passwordVariable: 'UE_Password'] + ]) { + echo '\u2705 \u001B[32mLog Collection (OAI UE - Run)\u001B[0m' + sh "python3 ci-scripts/main.py --mode=LogCollectOAIUE --UEIPAddress=${params.UE_IPAddress} --UEUserName=${UE_Username} --UEPassword=${UE_Password} --UESourceCodePath=${params.UE_SourceCodePath}" + + echo '\u2705 \u001B[32mLog Transfer (OAI UE - Run)\u001B[0m' + sh "sshpass -p \'${UE_Password}\' scp -o 'StrictHostKeyChecking no' -o 'ConnectTimeout 10' ${UE_Username}@${params.UE_IPAddress}:${UE_SourceCodePath}/cmake_targets/ue.log.zip ./ue.log.${env.BUILD_ID}.zip || true" + } + script { + if(fileExists("ue.log.${env.BUILD_ID}.zip")) { + archiveArtifacts "ue.log.${env.BUILD_ID}.zip" + } + } + } + } stage('Log Collection (CN)') { // Bypassing this stage if EPC server is not defined when { @@ -332,6 +382,19 @@ pipeline { } } } + stage ("Result Update"){ + when { + expression { params.DataBaseHost != "none" } + } + agent {label DataBaseHost} + steps { + script { + dir ('ci-scripts/ran_dashboard') { + sh "python3 Hdashboard.py testevent ${params.eNB_MR} " + } + } + } + } } } } diff --git a/ci-scripts/Jenkinsfile-trig-nsa b/ci-scripts/Jenkinsfile-trig-nsa index 27e27c842613188822a4ef29ce1c0e16e432d015..772b34231aba9fdb97803ec7f016e4a3b388e5a9 100644 --- a/ci-scripts/Jenkinsfile-trig-nsa +++ b/ci-scripts/Jenkinsfile-trig-nsa @@ -27,6 +27,8 @@ def pythonExecutor = params.pythonExecutor def TARGET_BRANCH = "develop" def ALLOW_MERGE = true +def GitPostArgs = '' +def jobStatus pipeline { agent { @@ -47,39 +49,89 @@ pipeline { COMMIT_ID=sh returnStdout: true, script: """curl --silent "https://gitlab.eurecom.fr/api/v4/projects/oai%2Fopenairinterface5g/merge_requests/${MR}" | jq ".sha" || true """ COMMIT_ID=COMMIT_ID.trim() echo "Testing NSA on : ${MR} ${SRC_BRANCH} ${COMMIT_ID}" + commit = COMMIT_ID.replace("\"","") + GitPostArgs = MR + ' ' + commit + ' ' + echo GitPostArgs + + //calling LTE 2x2 + jobName = "RAN-LTE-2x2-Module-OAIEPC" + jobStatus = build job: jobName, wait : true, propagate : false, parameters: [ + string(name: 'eNB_MR', value: String.valueOf(MR)), + string(name: 'eNB_Branch', value: String.valueOf(SRC_BRANCH)), + string(name: 'eNB_CommitID', value: String.valueOf(COMMIT_ID)), + string(name: 'eNB_TargetBranch', value: String.valueOf(TARGET_BRANCH)), + booleanParam(name: 'eNB_mergeRequest', value: Boolean.valueOf(ALLOW_MERGE)) + ] + jobResult = jobStatus.getResult() + build_url = jobStatus.getAbsoluteUrl() + build_id = jobStatus.getNumber().toString() + GitPostArgs += jobName + ' ' + build_url + ' ' + build_id + ' ' + jobResult + ' ' + echo GitPostArgs + //calling NSA B200 - build job: "RAN-NSA-B200-Module-LTEBOX", wait : true, propagate : false, parameters: [ - string(name: 'eNB_MR', value: String.valueOf(MR)), + jobName = "RAN-NSA-B200-Module-LTEBOX" + jobStatus = build job: jobName, wait : true, propagate : false, parameters: [ + string(name: 'eNB_MR', value: String.valueOf(MR)), string(name: 'eNB_Branch', value: String.valueOf(SRC_BRANCH)), string(name: 'eNB_CommitID', value: String.valueOf(COMMIT_ID)), string(name: 'eNB_TargetBranch', value: String.valueOf(TARGET_BRANCH)), booleanParam(name: 'eNB_mergeRequest', value: Boolean.valueOf(ALLOW_MERGE)) ] + jobResult = jobStatus.getResult() + build_url = jobStatus.getAbsoluteUrl() + build_id = jobStatus.getNumber().toString() + GitPostArgs += jobName + ' ' + build_url + ' ' + build_id + ' ' + jobResult + ' ' + echo GitPostArgs + //calling NSA 2x2 - build job: "RAN-NSA-2x2-Module-OAIEPC", wait : true, propagate : false, parameters: [ + jobName = "RAN-NSA-2x2-Module-OAIEPC" + jobStatus = build job: jobName, wait : true, propagate : false, parameters: [ string(name: 'eNB_MR', value: String.valueOf(MR)), string(name: 'eNB_Branch', value: String.valueOf(SRC_BRANCH)), string(name: 'eNB_CommitID', value: String.valueOf(COMMIT_ID)), string(name: 'eNB_TargetBranch', value: String.valueOf(TARGET_BRANCH)), booleanParam(name: 'eNB_mergeRequest', value: Boolean.valueOf(ALLOW_MERGE)) ] - //calling LTE 2x2 - build job: "RAN-LTE-2x2-Module-OAIEPC", wait : true, propagate : false, parameters: [ + jobResult = jobStatus.getResult() + build_url = jobStatus.getAbsoluteUrl() + build_id = jobStatus.getNumber().toString() + GitPostArgs += jobName + ' ' + build_url + ' ' + build_id + ' ' + jobResult + ' ' + echo GitPostArgs + + //calling SA + jobName = "RAN-SA-Module-CN5G" + jobStatus = build job: jobName, wait : true, propagate : false, parameters: [ string(name: 'eNB_MR', value: String.valueOf(MR)), string(name: 'eNB_Branch', value: String.valueOf(SRC_BRANCH)), string(name: 'eNB_CommitID', value: String.valueOf(COMMIT_ID)), string(name: 'eNB_TargetBranch', value: String.valueOf(TARGET_BRANCH)), booleanParam(name: 'eNB_mergeRequest', value: Boolean.valueOf(ALLOW_MERGE)) ] - //calling SA - build job: "RAN-SA-Module-CN5G", wait : true, propagate : false, parameters: [ + jobResult = jobStatus.getResult() + build_url = jobStatus.getAbsoluteUrl() + build_id = jobStatus.getNumber().toString() + GitPostArgs += jobName + ' ' + build_url + ' ' + build_id + ' ' + jobResult + ' ' + echo GitPostArgs + + //calling OAIUE N310-X300 + jobName = "RAN-SA-OAIUE-N310-X300-CN5G" + jobStatus = build job: jobName, wait : true, propagate : false, parameters: [ string(name: 'eNB_MR', value: String.valueOf(MR)), string(name: 'eNB_Branch', value: String.valueOf(SRC_BRANCH)), string(name: 'eNB_CommitID', value: String.valueOf(COMMIT_ID)), string(name: 'eNB_TargetBranch', value: String.valueOf(TARGET_BRANCH)), booleanParam(name: 'eNB_mergeRequest', value: Boolean.valueOf(ALLOW_MERGE)) ] + jobResult = jobStatus.getResult() + build_url = jobStatus.getAbsoluteUrl() + build_id = jobStatus.getNumber().toString() + GitPostArgs += jobName + ' ' + build_url + ' ' + build_id + ' ' + jobResult + ' ' + echo GitPostArgs + //git report the test results in 1 block, at the end of the test sequence of one MR + dir ('ci-scripts/ran_dashboard') { + sh "python3 Hdashboard.py gitpost ${GitPostArgs}" + } } } } diff --git a/ci-scripts/checkCodingFormattingRules.sh b/ci-scripts/checkCodingFormattingRules.sh index 45cf08aa9afeec3a78b761b2ee5f075810601476..a805f765dfb9b4ca7c6e3cf481a9f0784c08d722 100755 --- a/ci-scripts/checkCodingFormattingRules.sh +++ b/ci-scripts/checkCodingFormattingRules.sh @@ -77,7 +77,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" || 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` if [ $IS_OAI_LICENCE_PRESENT -eq 0 ] && [ $IS_BSD_LICENCE_PRESENT -eq 0 ] then if [ $IS_NFAPI -eq 0 ] && [ $IS_EXCEPTION -eq 0 ] @@ -198,7 +198,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" || 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` if [ $IS_OAI_LICENCE_PRESENT -eq 0 ] && [ $IS_BSD_LICENCE_PRESENT -eq 0 ] then if [ $IS_NFAPI -eq 0 ] && [ $IS_EXCEPTION -eq 0 ] diff --git a/ci-scripts/cls_containerize.py b/ci-scripts/cls_containerize.py index 8ee611362864a1a10ca4a860717148f4f7fd5efa..e60651393513bab12e18fafe7b9174f89dbecd29 100644 --- a/ci-scripts/cls_containerize.py +++ b/ci-scripts/cls_containerize.py @@ -93,6 +93,7 @@ class Containerize(): self.allImagesSize = {} self.collectInfo = {} + self.tsharkStarted = False self.pingContName = '' self.pingOptions = '' self.pingLossThreshold = '' @@ -177,7 +178,8 @@ class Containerize(): self.dockerfileprefix = '.rhel8.2' self.cliBuildOptions = '--no-cache --disable-compression' - imageNames = [] + # we always build the ran-build image with all targets + imageNames = [('ran-build', 'build')] result = re.search('eNB', self.imageKind) # Creating a tupple with the imageName and the DockerFile prefix pattern on obelix if result is not None: @@ -197,8 +199,6 @@ class Containerize(): imageNames.append(('oai-physim', 'phySim')) if self.host == 'Ubuntu': imageNames.append(('oai-lte-ru', 'lteRU')) - if len(imageNames) == 0: - imageNames.append(('oai-enb', 'eNB')) # Workaround for some servers, we need to erase completely the workspace if self.forcedWorkspaceCleanup: @@ -210,42 +210,41 @@ class Containerize(): # if asterix, copy the entitlement and subscription manager configurations if self.host == 'Red Hat': - mySSH.command('mkdir -p tmp/ca/', '\$', 5) - mySSH.command('mkdir -p tmp/entitlement/', '\$', 5) + 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) - sharedimage = 'ran-build' - sharedTag = 'develop' - forceSharedImageBuild = False + baseImage = 'ran-base' + baseTag = 'develop' + forceBaseImageBuild = False imageTag = 'develop' if (self.ranAllowMerge): imageTag = 'ci-temp' if self.ranTargetBranch == 'develop': - mySSH.command('git diff HEAD..origin/develop -- docker/Dockerfile.ran' + self.dockerfileprefix + ' | grep --colour=never -i INDEX', '\$', 5) + mySSH.command('git diff HEAD..origin/develop -- cmake_targets/build_oai cmake_targets/tools/build_helper docker/Dockerfile.base' + self.dockerfileprefix + ' | grep --colour=never -i INDEX', '\$', 5) result = re.search('index', mySSH.getBefore()) if result is not None: - forceSharedImageBuild = True - sharedTag = 'ci-temp' + forceBaseImageBuild = True + baseTag = 'ci-temp' else: - forceSharedImageBuild = True + forceBaseImageBuild = True # Let's remove any previous run artifacts if still there mySSH.command(self.cli + ' image prune --force', '\$', 30) - if forceSharedImageBuild: - mySSH.command(self.cli + ' image rm ' + sharedimage + ':' + sharedTag + ' || true', '\$', 30) + if forceBaseImageBuild: + mySSH.command(self.cli + ' image rm ' + baseImage + ':' + baseTag + ' || true', '\$', 30) for image,pattern in imageNames: mySSH.command(self.cli + ' image rm ' + image + ':' + imageTag + ' || true', '\$', 30) - # Build the shared image only on Push Events (not on Merge Requests) - # On when the shared image docker file is being modified. - if forceSharedImageBuild: - mySSH.command(self.cli + ' build ' + self.cliBuildOptions + ' --target ' + sharedimage + ' --tag ' + sharedimage + ':' + sharedTag + ' --file docker/Dockerfile.ran' + self.dockerfileprefix + ' --build-arg NEEDED_GIT_PROXY="http://proxy.eurecom.fr:8080" . > cmake_targets/log/ran-build.log 2>&1', '\$', 1600) - # First verify if the shared image was properly created. + # Build the base image only on Push Events (not on Merge Requests) + # On when the base image docker file is being modified. + if forceBaseImageBuild: + mySSH.command(self.cli + ' build ' + self.cliBuildOptions + ' --target ' + baseImage + ' --tag ' + baseImage + ':' + baseTag + ' --file docker/Dockerfile.base' + self.dockerfileprefix + ' --build-arg NEEDED_GIT_PROXY="http://proxy.eurecom.fr:8080" . > 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\' ' + sharedimage + ':' + sharedTag, '\$', 5) + mySSH.command(self.cli + ' image inspect --format=\'Size = {{.Size}} bytes\' ' + baseImage + ':' + baseTag, '\$', 5) if mySSH.getBefore().count('o such image') != 0: - logging.error('\u001B[1m Could not build properly ran-build\u001B[0m') + logging.error('\u001B[1m Could not build properly ran-base\u001B[0m') status = False else: result = re.search('Size *= *(?P<size>[0-9\-]+) *bytes', mySSH.getBefore()) @@ -253,20 +252,20 @@ class Containerize(): imageSize = float(result.group('size')) imageSize = imageSize / 1000 if imageSize < 1000: - logging.debug('\u001B[1m ran-build size is ' + ('%.0f' % imageSize) + ' kbytes\u001B[0m') - self.allImagesSize['ran-build'] = str(round(imageSize,1)) + ' kbytes' + 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-build size is ' + ('%.0f' % imageSize) + ' Mbytes\u001B[0m') - self.allImagesSize['ran-build'] = str(round(imageSize,1)) + ' Mbytes' + 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-build size is ' + ('%.3f' % imageSize) + ' Gbytes\u001B[0m') - self.allImagesSize['ran-build'] = str(round(imageSize,1)) + ' Gbytes' + 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-build size is unknown') - # If the shared image failed, no need to continue + 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) @@ -278,16 +277,18 @@ class Containerize(): sys.exit(1) else: # Recover build logs, for the moment only possible when build is successful - mySSH.command(self.cli + ' create --name test ' + sharedimage + ':' + sharedTag, '\$', 5) - mySSH.command('mkdir -p cmake_targets/log/ran-build', '\$', 5) - mySSH.command(self.cli + ' cp test:/oai-ran/cmake_targets/log/. cmake_targets/log/ran-build', '\$', 5) + 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) for image,pattern in imageNames: - # the archived Dockerfiles have "ran-build:latest" as base 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#' + sharedimage + ':latest#' + sharedimage + ':' + sharedTag + '#" docker/Dockerfile.' + pattern + self.dockerfileprefix, '\$', 5) + mySSH.command('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) # split the log mySSH.command('mkdir -p cmake_targets/log/' + image, '\$', 5) @@ -318,7 +319,7 @@ class Containerize(): logging.debug('\u001B[1m ' + image + ' size is ' + ('%.3f' % imageSize) + ' Gbytes\u001B[0m') self.allImagesSize[image] = str(round(imageSize,1)) + ' Gbytes' else: - logging.debug('ran-build size is unknown') + logging.debug('ran-base size is unknown') self.allImagesSize[image] = 'unknown' # Now pruning dangling images in between target builds mySSH.command(self.cli + ' image prune --force', '\$', 30) @@ -337,13 +338,19 @@ class Containerize(): 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 + 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('.') #Trying to identify the errors and warnings for each built images imageNames1 = imageNames - shared = ('ran-build','ran') - imageNames1.insert(0, shared) + 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')] @@ -499,6 +506,7 @@ class Containerize(): # mySSH.command('sed -i -e "s/FLEXRAN_ENABLED:.*$/FLEXRAN_ENABLED: \'no\'/" ci-docker-compose.yml', '\$', 2) # mySSH.command('sed -i -e "s/CI_FLEXRAN_CTL_IP_ADDR/127.0.0.1/" ci-docker-compose.yml', '\$', 2) # Currently support only one + mySSH.command('echo ' + lPassWord + ' | sudo -S b2xx_fx3_utils --reset-device', '\$', 15) mySSH.command('docker-compose --file ci-docker-compose.yml config --services | sed -e "s@^@service=@" 2>&1', '\$', 10) result = re.search('service=(?P<svc_name>[a-zA-Z0-9\_]+)', mySSH.getBefore()) if result is not None: @@ -579,33 +587,53 @@ class Containerize(): mySSH.command('cd ' + lSourcePath + '/' + self.yamlPath[self.eNB_instance], '\$', 5) # Currently support only one mySSH.command('docker-compose --file ci-docker-compose.yml config', '\$', 5) + containerName = '' + containerToKill = False result = re.search('container_name: (?P<container_name>[a-zA-Z0-9\-\_]+)', mySSH.getBefore()) if self.eNB_logFile[self.eNB_instance] == '': self.eNB_logFile[self.eNB_instance] = 'enb_' + HTML.testCase_id + '.log' if result is not None: containerName = result.group('container_name') + containerToKill = True + if containerToKill: + mySSH.command('docker inspect ' + containerName, '\$', 30) + result = re.search('Error: No such object: ' + containerName, mySSH.getBefore()) + if result is not None: + containerToKill = False + if containerToKill: mySSH.command('docker kill --signal INT ' + containerName, '\$', 30) time.sleep(5) mySSH.command('docker logs ' + containerName + ' > ' + lSourcePath + '/cmake_targets/' + self.eNB_logFile[self.eNB_instance], '\$', 30) mySSH.command('docker rm -f ' + containerName, '\$', 30) # Forcing the down now to remove the networks and any artifacts mySSH.command('docker-compose --file ci-docker-compose.yml down', '\$', 5) + # Cleaning any created tmp volume + mySSH.command('docker volume prune --force || true', '\$', 20) mySSH.close() # Analyzing log file! - copyin_res = mySSH.copyin(lIpAddr, lUserName, lPassWord, lSourcePath + '/cmake_targets/' + self.eNB_logFile[self.eNB_instance], '.') + if containerToKill: + copyin_res = mySSH.copyin(lIpAddr, lUserName, lPassWord, lSourcePath + '/cmake_targets/' + self.eNB_logFile[self.eNB_instance], '.') + else: + copyin_res = 0 nodeB_prefix = 'e' if (copyin_res == -1): HTML.htmleNBFailureMsg='Could not copy ' + nodeB_prefix + 'NB logfile to analyze it!' HTML.CreateHtmlTestRow('N/A', 'KO', CONST.ENB_PROCESS_NOLOGFILE_TO_ANALYZE) else: - logging.debug('\u001B[1m Analyzing ' + nodeB_prefix + 'NB logfile \u001B[0m ' + self.eNB_logFile[self.eNB_instance]) - logStatus = RAN.AnalyzeLogFile_eNB(self.eNB_logFile[self.eNB_instance], HTML) + if containerToKill: + logging.debug('\u001B[1m Analyzing ' + nodeB_prefix + 'NB logfile \u001B[0m ' + self.eNB_logFile[self.eNB_instance]) + logStatus = RAN.AnalyzeLogFile_eNB(self.eNB_logFile[self.eNB_instance], HTML) + else: + logStatus = 0 if (logStatus < 0): HTML.CreateHtmlTestRow(RAN.runtime_stats, 'KO', logStatus) else: HTML.CreateHtmlTestRow(RAN.runtime_stats, 'OK', CONST.ALL_PROCESSES_OK) + # all the xNB run logs shall be on the server 0 for logCollecting + if containerToKill and self.eNB_serverId[self.eNB_instance] != '0': + mySSH.copyout(self.eNBIPAddress, self.eNBUserName, self.eNBPassword, './' + self.eNB_logFile[self.eNB_instance], self.eNBSourceCodePath + '/cmake_targets/') logging.info('\u001B[1m Undeploying OAI Object Pass\u001B[0m') def DeployGenObject(self, HTML): @@ -638,7 +666,7 @@ class Containerize(): cmd = 'cd ' + self.yamlPath[0] + ' && docker-compose -f docker-compose-ci.yml up -d ' + self.services[0] logging.debug(cmd) try: - deployStatus = subprocess.check_output(cmd, shell=True, stderr=subprocess.STDOUT, universal_newlines=True, timeout=30) + deployStatus = subprocess.check_output(cmd, shell=True, stderr=subprocess.STDOUT, universal_newlines=True, timeout=100) except Exception as e: self.exitStatus = 1 logging.error('Could not deploy') @@ -651,7 +679,7 @@ class Containerize(): healthy = 0 while (count < 10): count += 1 - deployStatus = subprocess.check_output(cmd, shell=True, stderr=subprocess.STDOUT, universal_newlines=True, timeout=10) + deployStatus = subprocess.check_output(cmd, shell=True, stderr=subprocess.STDOUT, universal_newlines=True, timeout=30) healthy = 0 for state in deployStatus.split('\n'): res = re.search('Up \(healthy\)', state) @@ -663,6 +691,10 @@ class Containerize(): time.sleep(10) if count == 100 and healthy == self.nb_healthy[0]: + if self.tsharkStarted == False: + logging.debug('Starting tshark on public network') + self.CaptureOnDockerNetworks() + self.tsharkStarted = True HTML.CreateHtmlTestRow('n/a', 'OK', CONST.ALL_PROCESSES_OK) logging.info('\u001B[1m Deploying OAI Object(s) PASS\u001B[0m') else: @@ -670,8 +702,24 @@ class Containerize(): HTML.CreateHtmlTestRow('Could not deploy in time', 'KO', CONST.ALL_PROCESSES_OK) logging.error('\u001B[1m Deploying OAI Object(s) FAILED\u001B[0m') - def UndeployGenObject(self, HTML): + def CaptureOnDockerNetworks(self): + cmd = 'cd ' + self.yamlPath[0] + ' && docker-compose -f docker-compose-ci.yml config | grep com.docker.network.bridge.name | sed -e "s@^.*name: @@"' + networkNames = subprocess.check_output(cmd, shell=True, stderr=subprocess.STDOUT, universal_newlines=True, timeout=10) + cmd = 'sudo nohup tshark -f "not tcp and not arp and not port 53 and not host archive.ubuntu.com and not host security.ubuntu.com and not port 2152"' + for name in networkNames.split('\n'): + res = re.search('rfsim', name) + if res is not None: + cmd += ' -i ' + name + cmd += ' -w /tmp/capture_' + ymlPath = self.yamlPath[0].split('/') + cmd += ymlPath[1] + '.pcap > /tmp/tshark.log 2>&1 &' + logging.debug(cmd) + networkNames = subprocess.check_output(cmd, shell=True, stderr=subprocess.STDOUT, universal_newlines=True, timeout=10) + + def UndeployGenObject(self, HTML, RAN, UE): self.exitStatus = 0 + ymlPath = self.yamlPath[0].split('/') + logPath = '../cmake_targets/log/' + ymlPath[1] if (self.ranAllowMerge): cmd = 'cd ' + self.yamlPath[0] + ' && sed -e "s@develop@ci-temp@" docker-compose.y*ml > docker-compose-ci.yml' @@ -683,7 +731,7 @@ class Containerize(): # if the containers are running, recover the logs! cmd = 'cd ' + self.yamlPath[0] + ' && docker-compose -f docker-compose-ci.yml ps --all' logging.debug(cmd) - deployStatus = subprocess.check_output(cmd, shell=True, stderr=subprocess.STDOUT, universal_newlines=True, timeout=10) + deployStatus = subprocess.check_output(cmd, shell=True, stderr=subprocess.STDOUT, universal_newlines=True, timeout=30) anyLogs = False for state in deployStatus.split('\n'): res = re.search('Name|----------', state) @@ -697,12 +745,74 @@ class Containerize(): cName = res.group('container_name') cmd = 'cd ' + self.yamlPath[0] + ' && docker logs ' + cName + ' > ' + cName + '.log 2>&1' logging.debug(cmd) - deployStatus = subprocess.check_output(cmd, shell=True, stderr=subprocess.STDOUT, universal_newlines=True, timeout=10) + deployStatus = subprocess.check_output(cmd, shell=True, stderr=subprocess.STDOUT, universal_newlines=True, timeout=30) + fullStatus = True if anyLogs: - cmd = 'mkdir -p ../cmake_targets/log && mv ' + self.yamlPath[0] + '/*.log ../cmake_targets/log' + cmd = 'mkdir -p '+ logPath + ' && cp ' + self.yamlPath[0] + '/*.log ' + logPath logging.debug(cmd) deployStatus = subprocess.check_output(cmd, shell=True, stderr=subprocess.STDOUT, universal_newlines=True, timeout=10) + # Analyzing log file(s)! + listOfPossibleRanContainers = ['enb', 'gnb', 'cu', 'du'] + for container in listOfPossibleRanContainers: + filename = self.yamlPath[0] + '/rfsim?g-oai-' + container + '.log' + cmd = 'ls ' + filename + containerStatus = True + try: + lsStatus = subprocess.check_output(cmd, shell=True, stderr=subprocess.STDOUT, universal_newlines=True, timeout=10) + filename = str(lsStatus).strip() + except: + containerStatus = False + if not containerStatus: + continue + + logging.debug('\u001B[1m Analyzing xNB logfile ' + filename + ' \u001B[0m') + logStatus = RAN.AnalyzeLogFile_eNB(filename, HTML) + if (logStatus < 0): + fullStatus = False + HTML.CreateHtmlTestRow(RAN.runtime_stats, 'KO', logStatus) + else: + HTML.CreateHtmlTestRow(RAN.runtime_stats, 'OK', CONST.ALL_PROCESSES_OK) + + listOfPossibleUeContainers = ['lte-ue*', 'nr-ue*'] + for container in listOfPossibleUeContainers: + filename = self.yamlPath[0] + '/rfsim?g-oai-' + container + '.log' + cmd = 'ls ' + filename + containerStatus = True + try: + lsStatus = subprocess.check_output(cmd, shell=True, stderr=subprocess.STDOUT, universal_newlines=True, timeout=10) + filename = str(lsStatus).strip() + except: + containerStatus = False + if not containerStatus: + continue + + logging.debug('\u001B[1m Analyzing UE logfile ' + filename + ' \u001B[0m') + logStatus = UE.AnalyzeLogFile_UE(filename, HTML, RAN) + if (logStatus < 0): + fullStatus = False + HTML.CreateHtmlTestRow('UE log Analysis', 'KO', logStatus) + else: + HTML.CreateHtmlTestRow('UE log Analysis', 'OK', CONST.ALL_PROCESSES_OK) + + cmd = 'rm ' + self.yamlPath[0] + '/*.log' + logging.debug(cmd) + deployStatus = subprocess.check_output(cmd, shell=True, stderr=subprocess.STDOUT, universal_newlines=True, timeout=10) + if self.tsharkStarted: + self.tsharkStarted = True + ymlPath = self.yamlPath[0].split('/') + cmd = 'sudo chmod 666 /tmp/capture_' + ymlPath[1] + '.pcap' + logging.debug(cmd) + copyStatus = subprocess.check_output(cmd, shell=True, stderr=subprocess.STDOUT, universal_newlines=True, timeout=10) + cmd = 'cp /tmp/capture_' + ymlPath[1] + '.pcap ' + logPath + logging.debug(cmd) + copyStatus = subprocess.check_output(cmd, shell=True, stderr=subprocess.STDOUT, universal_newlines=True, timeout=10) + cmd = 'sudo rm /tmp/capture_' + ymlPath[1] + '.pcap' + logging.debug(cmd) + copyStatus = subprocess.check_output(cmd, shell=True, stderr=subprocess.STDOUT, universal_newlines=True, timeout=10) + self.tsharkStarted = False + + logging.debug('\u001B[1m Undeploying \u001B[0m') cmd = 'cd ' + self.yamlPath[0] + ' && docker-compose -f docker-compose-ci.yml down' logging.debug(cmd) try: @@ -714,31 +824,43 @@ class Containerize(): logging.error('\u001B[1m Undeploying OAI Object(s) FAILED\u001B[0m') return - HTML.CreateHtmlTestRow('n/a', 'OK', CONST.ALL_PROCESSES_OK) - logging.info('\u001B[1m Undeploying OAI Object(s) PASS\u001B[0m') + # Cleaning any created tmp volume + cmd = 'docker volume prune --force || true' + logging.debug(cmd) + deployStatus = subprocess.check_output(cmd, shell=True, stderr=subprocess.STDOUT, universal_newlines=True, timeout=100) + + if fullStatus: + HTML.CreateHtmlTestRow('n/a', 'OK', CONST.ALL_PROCESSES_OK) + logging.info('\u001B[1m Undeploying OAI Object(s) PASS\u001B[0m') + else: + HTML.CreateHtmlTestRow('n/a', 'KO', CONST.ALL_PROCESSES_OK) + logging.info('\u001B[1m Undeploying OAI Object(s) FAIL\u001B[0m') - def PingFromContainer(self, HTML): + def PingFromContainer(self, HTML, RAN, UE): self.exitStatus = 0 - cmd = 'mkdir -p ../cmake_targets/log' + ymlPath = self.yamlPath[0].split('/') + logPath = '../cmake_targets/log/' + ymlPath[1] + cmd = 'mkdir -p ' + logPath deployStatus = subprocess.check_output(cmd, shell=True, stderr=subprocess.STDOUT, universal_newlines=True, timeout=10) - cmd = 'docker exec ' + self.pingContName + ' /bin/bash -c "ping ' + self.pingOptions + '" 2>&1 | tee ../cmake_targets/log/ping_' + HTML.testCase_id + '.log || true' + cmd = 'docker exec ' + self.pingContName + ' /bin/bash -c "ping ' + self.pingOptions + '" 2>&1 | tee ' + logPath + '/ping_' + HTML.testCase_id + '.log || true' + logging.debug(cmd) deployStatus = subprocess.check_output(cmd, shell=True, stderr=subprocess.STDOUT, universal_newlines=True, timeout=100) result = re.search(', (?P<packetloss>[0-9\.]+)% packet loss, time [0-9\.]+ms', deployStatus) if result is None: - self.PingExit(HTML, False, 'Packet Loss Not Found') + self.PingExit(HTML, RAN, UE, False, 'Packet Loss Not Found') return packetloss = result.group('packetloss') if float(packetloss) == 100: - self.PingExit(HTML, False, 'Packet Loss is 100%') + self.PingExit(HTML, RAN, UE, False, 'Packet Loss is 100%') return result = re.search('rtt min\/avg\/max\/mdev = (?P<rtt_min>[0-9\.]+)\/(?P<rtt_avg>[0-9\.]+)\/(?P<rtt_max>[0-9\.]+)\/[0-9\.]+ ms', deployStatus) if result is None: - self.PingExit(HTML, False, 'Ping RTT_Min RTT_Avg RTT_Max Not Found!') + self.PingExit(HTML, RAN, UE, False, 'Ping RTT_Min RTT_Avg RTT_Max Not Found!') return rtt_min = result.group('rtt_min') @@ -760,7 +882,7 @@ class Containerize(): packetLossOK = False elif float(packetloss) > 0: message += '\nPacket Loss is not 0%' - self.PingExit(HTML, packetLossOK, message) + self.PingExit(HTML, RAN, UE, packetLossOK, message) if packetLossOK: logging.debug('\u001B[1;37;44m ping result \u001B[0m') @@ -770,21 +892,30 @@ class Containerize(): logging.debug('\u001B[1;34m ' + max_msg + '\u001B[0m') logging.info('\u001B[1m Ping Test PASS\u001B[0m') - def PingExit(self, HTML, status, message): + def PingExit(self, HTML, RAN, UE, status, message): html_queue = SimpleQueue() html_cell = '<pre style="background-color:white">UE\n' + message + '</pre>' html_queue.put(html_cell) if status: HTML.CreateHtmlTestRowQueue(self.pingOptions, 'OK', 1, html_queue) else: - self.exitStatus = 1 - logging.error('\u001B[1;37;41m ' + message + ' \u001B[0m') + logging.error('\u001B[1;37;41m ping test FAIL -- ' + message + ' \u001B[0m') HTML.CreateHtmlTestRowQueue(self.pingOptions, 'KO', 1, html_queue) + # Automatic undeployment + logging.debug('----------------------------------------') + logging.debug('\u001B[1m Starting Automatic undeployment \u001B[0m') + logging.debug('----------------------------------------') + HTML.testCase_id = 'AUTO-UNDEPLOY' + HTML.desc = 'Automatic Un-Deployment' + self.UndeployGenObject(HTML, RAN, UE) + self.exitStatus = 1 - def IperfFromContainer(self, HTML): + def IperfFromContainer(self, HTML, RAN): self.exitStatus = 0 - cmd = 'mkdir -p ../cmake_targets/log' + ymlPath = self.yamlPath[0].split('/') + logPath = '../cmake_targets/log/' + ymlPath[1] + cmd = 'mkdir -p ' + logPath logStatus = subprocess.check_output(cmd, shell=True, stderr=subprocess.STDOUT, universal_newlines=True, timeout=10) # Start the server process @@ -794,7 +925,8 @@ class Containerize(): time.sleep(5) # Start the client process - cmd = 'docker exec ' + self.cliContName + ' /bin/bash -c "iperf ' + self.cliOptions + '" 2>&1 | tee ../cmake_targets/log/iperf_client_' + HTML.testCase_id + '.log || true' + + cmd = 'docker exec ' + self.cliContName + ' /bin/bash -c "iperf ' + self.cliOptions + '" 2>&1 | tee '+ logPath + '/iperf_client_' + HTML.testCase_id + '.log || true' logging.debug(cmd) clientStatus = subprocess.check_output(cmd, shell=True, stderr=subprocess.STDOUT, universal_newlines=True, timeout=100) @@ -803,9 +935,9 @@ class Containerize(): logging.debug(cmd) serverStatus = subprocess.check_output(cmd, shell=True, stderr=subprocess.STDOUT, universal_newlines=True, timeout=10) time.sleep(5) - cmd = 'docker cp ' + self.svrContName + ':/tmp/iperf_server.log ../cmake_targets/log/iperf_server_' + HTML.testCase_id + '.log' + cmd = 'docker cp ' + self.svrContName + ':/tmp/iperf_server.log '+ logPath + '/iperf_server_' + HTML.testCase_id + '.log' logging.debug(cmd) - serverStatus = subprocess.check_output(cmd, shell=True, stderr=subprocess.STDOUT, universal_newlines=True, timeout=10) + serverStatus = subprocess.check_output(cmd, shell=True, stderr=subprocess.STDOUT, universal_newlines=True, timeout=30) # Analyze client output result = re.search('Server Report:', clientStatus) @@ -899,9 +1031,10 @@ class Containerize(): if status: HTML.CreateHtmlTestRowQueue(self.cliOptions, 'OK', 1, html_queue) else: - self.exitStatus = 1 + logging.error('\u001B[1m Iperf Test FAIL -- ' + message + ' \u001B[0m') HTML.CreateHtmlTestRowQueue(self.cliOptions, 'KO', 1, html_queue) + def CheckAndAddRoute(self, svrName, ipAddr, userName, password): logging.debug('Checking IP routing on ' + svrName) mySSH = SSH.SSHConnection() @@ -1012,3 +1145,4 @@ class Containerize(): if result is None: mySSH.command('echo ' + password + ' | sudo -S iptables -P FORWARD ACCEPT', '\$', 10) mySSH.close() + diff --git a/ci-scripts/cls_oaicitest.py b/ci-scripts/cls_oaicitest.py index cc6e235ab3c3d8da93f389d25ad9701df66722f0..05bac18900cc67d6b528f02f916052b36cec7480 100644 --- a/ci-scripts/cls_oaicitest.py +++ b/ci-scripts/cls_oaicitest.py @@ -57,12 +57,15 @@ import sshconnection import cls_module_ue import cls_ci_ueinfra #class defining the multi Ue infrastrucure +logging.getLogger("matplotlib").setLevel(logging.WARNING) +import matplotlib.pyplot as plt +import numpy as np #----------------------------------------------------------- # Utility functions #----------------------------------------------------------- -def GetPingTimeAnalysis(ping_log_file): +def GetPingTimeAnalysis(RAN,ping_log_file,ping_rttavg_threshold): #ping time values read from file t_ping=[] #ping stats (dictionary) to be returned by the function @@ -86,17 +89,46 @@ def GetPingTimeAnalysis(ping_log_file): max_loc=t_ping.index(max(t_ping)) ping_stat['max_loc']=max_loc #remove it - t_ping.pop(max_loc) + t_ping_post=t_ping.copy() + t_ping_post.pop(max_loc) #new stats after removing max value - ping_stat['min_1']=min(t_ping) - ping_stat['mean_1']=stat.mean(t_ping) - ping_stat['median_1']=stat.median(t_ping) - ping_stat['max_1']=max(t_ping) + ping_stat['min_1']=min(t_ping_post) + ping_stat['mean_1']=stat.mean(t_ping_post) + ping_stat['median_1']=stat.median(t_ping_post) + ping_stat['max_1']=max(t_ping_post) + + #plot ping over time and save png for artifacts + ticks = np.arange(0, len(t_ping), 1) + figure, axis = plt.subplots(figsize=(10, 10)) + axis.plot(ticks,t_ping,marker='o') + axis.set_xlabel('Ping Events') + axis.set_ylabel("Ping RTT (in ms)") + axis.set_title(ping_log_file) + axis.set_xticks(ticks) + axis.set_xticklabels([]) + YMAX=20 #base scale + if max(t_ping) > YMAX: + y_max=max(t_ping)+1 + else: + y_max=YMAX+1 + plt.ylim(0,y_max) + if ping_rttavg_threshold != '': + th_label="AVG Ping Fail Threshold="+ping_rttavg_threshold + plt.axhline(y=float(ping_rttavg_threshold), color='r', linestyle='-',label=th_label) + axis.legend() + plt.savefig(ping_log_file+'.png') + + #copy the png file already to enb to move it move it later into the artifacts + try: + mySSH = sshconnection.SSHConnection() + mySSH.copyout(RAN.eNBIPAddress, RAN.eNBUserName, RAN.eNBPassword, ping_log_file+'.png', RAN.eNBSourceCodePath + '/cmake_targets/') + except: + logging.debug('\u001B[1;37;41m Ping PNG SCP to eNB FAILED\u001B[0m') return ping_stat else: - logging.error("Ping log file does not exist") + logging.error("GetPingTimeAnalysis : Ping log file does not exist") return -1 @@ -126,8 +158,10 @@ class OaiCiTest(): self.desc = '' self.ping_args = '' self.ping_packetloss_threshold = '' + self.ping_rttavg_threshold ='' self.iperf_args = '' self.iperf_packetloss_threshold = '' + self.iperf_bitrate_threshold = '' self.iperf_profile = '' self.iperf_options = '' self.iperf_direction = '' @@ -1530,7 +1564,7 @@ class OaiCiTest(): statusQueue.put(message) lock.release() - def Ping_common(self, lock, UE_IPAddress, device_id, statusQueue,EPC, Module_UE): + def Ping_common(self, lock, UE_IPAddress, device_id, statusQueue,EPC, Module_UE,RAN): try: SSH = sshconnection.SSHConnection() # Launch ping on the EPC side (true for ltebox and old open-air-cn) @@ -1552,12 +1586,13 @@ class OaiCiTest(): SSH.command('cd scripts', '\$', 5) # In case of a docker-based deployment, we need to ping from the trf-gen container launchFromTrfContainer = False - if re.match('OAI-Rel14-Docker', EPC.Type, re.IGNORECASE): + if (re.match('OAI-Rel14-Docker', EPC.Type, re.IGNORECASE)) or (re.match('OAICN5G', EPC.Type, re.IGNORECASE)): launchFromTrfContainer = True if launchFromTrfContainer: ping_status = SSH.command('docker exec -it prod-trf-gen /bin/bash -c "ping ' + self.ping_args + ' ' + UE_IPAddress + '" 2>&1 | tee ping_' + self.testCase_id + '_' + device_id + '.log', '\$', int(ping_time[0])*1.5) else: ping_status = SSH.command('stdbuf -o0 ping ' + self.ping_args + ' ' + UE_IPAddress + ' 2>&1 | stdbuf -o0 tee ping_' + self.testCase_id + '_' + device_id + '.log', '\$', int(ping_time[0])*1.5) + ping_log_file='ping_' + self.testCase_id + '_' + device_id + '.log' #copy the ping log file to have it locally for analysis (ping stats) SSH.copyin(EPC.IPAddress, EPC.UserName, EPC.Password, EPC.SourceCodePath + '/scripts/ping_' + self.testCase_id + '_' + device_id + '.log', '.') else: @@ -1577,6 +1612,7 @@ class OaiCiTest(): SSH.open(EPC.IPAddress, EPC.UserName, EPC.Password) #cat is executed on EPC SSH.command('cat ' + EPC.SourceCodePath + '/scripts/ping_' + self.testCase_id + '_' + device_id + '.log', '\$', 5) + ping_log_file='/scripts/ping_' + self.testCase_id + '_' + device_id + '.log' else: #launch from Module SSH.open(Module_UE.HostIPAddress, Module_UE.HostUsername, Module_UE.HostPassword) #target address is different depending on EPC type @@ -1594,6 +1630,7 @@ class OaiCiTest(): #cat is executed locally SSH.command('cat ping_' + self.testCase_id + '_' + self.ue_id + '.log', '\$', 5) + ping_log_file='ping_' + self.testCase_id + '_' + self.ue_id + '.log' ping_status=0 # TIMEOUT CASE @@ -1632,6 +1669,7 @@ class OaiCiTest(): min_msg = 'RTT(Min) : ' + rtt_min + ' ms' avg_msg = 'RTT(Avg) : ' + rtt_avg + ' ms' max_msg = 'RTT(Max) : ' + rtt_max + ' ms' + lock.acquire() logging.debug('\u001B[1;37;44m ping result (' + UE_IPAddress + ') \u001B[0m') logging.debug('\u001B[1;34m ' + pal_msg + '\u001B[0m') @@ -1640,9 +1678,9 @@ class OaiCiTest(): logging.debug('\u001B[1;34m ' + max_msg + '\u001B[0m') #adding extra ping stats from local file - ping_log_file='ping_' + self.testCase_id + '_' + device_id + '.log' + #ping_log_file variable is defined above in this function, depending on device/ue logging.debug('Analyzing Ping log file : ' + os.getcwd() + '/' + ping_log_file) - ping_stat=GetPingTimeAnalysis(ping_log_file) + ping_stat=GetPingTimeAnalysis(RAN,ping_log_file,self.ping_rttavg_threshold) ping_stat_msg='' if (ping_stat!=-1) and (len(ping_stat)!=0): ping_stat_msg+='Ping stats before removing largest value : \n' @@ -1658,17 +1696,29 @@ class OaiCiTest(): ping_stat_msg+='RTT(Max) : ' + str("{:.2f}".format(ping_stat['max_1'])) + 'ms \n' #building html message - qMsg = pal_msg + '\n' + min_msg + '\n' + avg_msg + '\n' + max_msg + '\n' + ping_stat_msg + qMsg = pal_msg + '\n' + min_msg + '\n' + avg_msg + '\n' + max_msg + '\n' + ping_stat_msg + + #checking packet loss compliance packetLossOK = True if packetloss is not None: if float(packetloss) > float(self.ping_packetloss_threshold): qMsg += '\nPacket Loss too high' - logging.debug('\u001B[1;37;41m Packet Loss too high \u001B[0m') + logging.debug('\u001B[1;37;41m Packet Loss too high; Target: '+ self.ping_packetloss_threshold + '%\u001B[0m') packetLossOK = False elif float(packetloss) > 0: qMsg += '\nPacket Loss is not 0%' logging.debug('\u001B[1;30;43m Packet Loss is not 0% \u001B[0m') - if (packetLossOK): + + #checking RTT avg compliance + rttavgOK = True + if self.ping_rttavg_threshold != '': + if float(rtt_avg)>float(self.ping_rttavg_threshold): + ping_rttavg_error_msg = 'RTT(Avg) too high: ' + rtt_avg + ' ms; Target: '+ self.ping_rttavg_threshold+ ' ms' + qMsg += '\n'+ping_rttavg_error_msg + logging.debug('\u001B[1;37;41m'+ ping_rttavg_error_msg +' \u001B[0m') + rttavgOK = False + + if packetLossOK and rttavgOK: statusQueue.put(0) else: statusQueue.put(-1) @@ -1820,7 +1870,7 @@ class OaiCiTest(): device_id = self.UEDevices[i] else: device_id = Module_UE.ID + "-" + Module_UE.Kind - p = Process(target = self.Ping_common, args = (lock,UE_IPAddress,device_id,status_queue,EPC,Module_UE,)) + p = Process(target = self.Ping_common, args = (lock,UE_IPAddress,device_id,status_queue,EPC,Module_UE,RAN,)) p.daemon = True p.start() multi_jobs.append(p) @@ -1995,6 +2045,35 @@ class OaiCiTest(): else: return -2 + + def Iperf_analyzeV2BIDIR(self, lock, UE_IPAddress, device_id, statusQueue,server_filename,client_filename): + #server file is unused for the moment + if (not os.path.isfile(client_filename)): + self.ping_iperf_wrong_exit(lock, UE_IPAddress, device_id, statusQueue, 'Bidir TCP : Could not analyze from client log') + return + report=[] + report_msg='Client Report:\n' + with open(client_filename, 'r') as f_client: + for line in f_client.readlines(): + result = re.search(rf'^\[\s+\d+\](?P<direction>\[.+\]).*\s+(?P<bitrate>[0-9\.]+ [KMG]bits\/sec).*\s+(?P<role>\bsender|receiver\b)', str(line)) + if result is not None: + report.append(str(line)) + report_msg+=result.group('role') + ' ' + result.group('direction')+ '\t = ' +result.group('bitrate')+'\n' + + if len(report)>0: + lock.acquire() + statusQueue.put(0) + statusQueue.put(device_id) + statusQueue.put(UE_IPAddress) + statusQueue.put(report_msg) + logging.debug('\u001B[1;37;45m TCP Bidir Iperf Result (' + UE_IPAddress + ') \u001B[0m') + logging.debug('\u001B[1;35m ' + report_msg + '\u001B[0m') + lock.release() + else: + self.ping_iperf_wrong_exit(lock, UE_IPAddress, device_id, statusQueue, 'Bidir TCP : Could not analyze from client log') + + + def Iperf_analyzeV2Server(self, lock, UE_IPAddress, device_id, statusQueue, iperf_real_options, filename,type): if (not os.path.isfile(filename)): self.ping_iperf_wrong_exit(lock, UE_IPAddress, device_id, statusQueue, 'Could not analyze from server log') @@ -2071,12 +2150,20 @@ class OaiCiTest(): pl = float(100 * pl_sum / ps_sum) packetloss = '%2.1f ' % (pl) packetloss += '%' + #checking packet loss compliance if float(pl) > float(self.iperf_packetloss_threshold): - pal_too_high_msg = 'Packet Loss too high : actual = '+packetloss+', target = '+self.iperf_packetloss_threshold+'%\n' + pal_too_high_msg = 'Packet Loss too high : tested = '+packetloss+', target = '+self.iperf_packetloss_threshold+'%' + else: + pal_too_high_msg='Packet Loss value is within acceptance range' + #checking bitrate perf compliance + if float(br_loss) < float(self.iperf_bitrate_threshold): + bit_too_low_msg = 'Bitrate too low : tested = '+bitperf+', target = '+self.iperf_bitrate_threshold+'%' else: - pal_too_high_msg='' + bit_too_low_msg='Bitrate perf value is within acceptance range' lock.acquire() - if (br_loss < 90) or (float(pl) > float(self.iperf_packetloss_threshold)): + if (float(br_loss) < float(self.iperf_bitrate_threshold)) and (float(pl) > float(self.iperf_packetloss_threshold)): + statusQueue.put(-1) + elif (float(br_loss) < float(self.iperf_bitrate_threshold)) or (float(pl) > float(self.iperf_packetloss_threshold)): statusQueue.put(1) else: statusQueue.put(0) @@ -2087,7 +2174,7 @@ class OaiCiTest(): brl_msg = 'Bitrate Perf: ' + bitperf jit_msg = 'Jitter : ' + jitter pal_msg = 'Packet Loss : ' + packetloss - statusQueue.put(req_msg + '\n' + bir_msg + '\n' + brl_msg + '\n' + jit_msg + '\n' + pal_msg + '\n' + pal_too_high_msg + '\n') + statusQueue.put(req_msg + '\n' + bir_msg + '\n' + brl_msg + '\n' + jit_msg + '\n' + pal_msg + '\n' + pal_too_high_msg + '\n' + bit_too_low_msg + '\n') logging.debug('\u001B[1;37;45m iperf result (' + UE_IPAddress + ') \u001B[0m') logging.debug('\u001B[1;35m ' + req_msg + '\u001B[0m') logging.debug('\u001B[1;35m ' + bir_msg + '\u001B[0m') @@ -2095,6 +2182,7 @@ class OaiCiTest(): logging.debug('\u001B[1;35m ' + jit_msg + '\u001B[0m') logging.debug('\u001B[1;35m ' + pal_msg + '\u001B[0m') logging.debug('\u001B[1;35m ' + pal_too_high_msg + '\u001B[0m') + logging.debug('\u001B[1;35m ' + bit_too_low_msg + '\u001B[0m') lock.release() else: self.ping_iperf_wrong_exit(lock, UE_IPAddress, device_id, statusQueue, 'Could not analyze from server log') @@ -2283,14 +2371,19 @@ class OaiCiTest(): result = re.search('TRF_IP_ADDR = (?P<trf_ip_addr>[0-9\.]+)', SSH.getBefore()) if result is not None: trf_gen_IP = result.group('trf_ip_addr') + #kill iperf processes on EPC side + SSH.command('docker exec -it prod-trf-gen /bin/bash -c "killall --signal SIGKILL iperf"', '\$', 5) + SSH.command('docker exec -it prod-trf-gen /bin/bash -c "killall --signal SIGKILL iperf3"', '\$', 5) SSH.close() #kill iperf processes on UE side before (in case there are still some remaining) SSH.open(Module_UE.HostIPAddress, Module_UE.HostUsername, Module_UE.HostPassword) cmd = 'killall --signal=SIGKILL iperf' SSH.command(cmd,'\$',5) + cmd = 'killall --signal=SIGKILL iperf3' + SSH.command(cmd,'\$',5) SSH.close() - iperf_time = self.Iperf_ComputeTime() + iperf_time = self.Iperf_ComputeTime() if self.iperf_direction=="DL": logging.debug("Iperf for Module in DL mode detected") #server side UE @@ -2304,7 +2397,7 @@ class OaiCiTest(): #client side EPC SSH.open(EPC.IPAddress, EPC.UserName, EPC.Password) client_filename = 'iperf_client_' + self.testCase_id + '_' + self.ue_id + '.log' - SSH.command('docker exec -it prod-trf-gen /bin/bash -c "killall --signal SIGKILL iperf"', '\$', 5) + iperf_cmd = 'bin/iperf -c ' + UE_IPAddress + ' ' + self.iperf_args + ' 2>&1 > ' + client_filename cmd = 'docker exec -it prod-trf-gen /bin/bash -c \"' + iperf_cmd + '\"' SSH.command(cmd,'\$',int(iperf_time)*5.0) @@ -2323,7 +2416,7 @@ class OaiCiTest(): #server side EPC SSH.open(EPC.IPAddress, EPC.UserName, EPC.Password) server_filename = 'iperf_server_' + self.testCase_id + '_' + self.ue_id + '.log' - SSH.command('docker exec -it prod-trf-gen /bin/bash -c "killall --signal SIGKILL iperf"', '\$', 5) + iperf_cmd = 'echo $USER; nohup bin/iperf -s -u 2>&1 > ' + server_filename cmd = 'docker exec -d prod-trf-gen /bin/bash -c \"' + iperf_cmd + '\"' SSH.command(cmd,'\$',5) @@ -2348,6 +2441,38 @@ class OaiCiTest(): SSH.copyin(EPC.IPAddress, EPC.UserName, EPC.Password, server_filename, '.') #send for analysis self.Iperf_analyzeV2Server(lock, UE_IPAddress, device_id, statusQueue, self.iperf_args,server_filename,1) + + elif self.iperf_direction=="BIDIR": + logging.debug("Iperf for Module in BIDIR mode detected") + #server side EPC + SSH.open(EPC.IPAddress, EPC.UserName, EPC.Password) + server_filename = 'iperf_server_' + self.testCase_id + '_' + self.ue_id + '.log' + + iperf_cmd = 'echo $USER; nohup /usr/local/bin/iperf3 -s 2>&1 > ' + server_filename + cmd = 'docker exec -d prod-trf-gen /bin/bash -c \"' + iperf_cmd + '\"' + SSH.command(cmd,'\$',5) + SSH.close() + + #client side UE + SSH.open(Module_UE.HostIPAddress, Module_UE.HostUsername, Module_UE.HostPassword) + client_filename = 'iperf_client_' + self.testCase_id + '_' + self.ue_id + '.log' + cmd = 'rm '+ client_filename + SSH.command(cmd,'\$',5) + SSH.command('iperf3 -B ' + UE_IPAddress + ' -c ' + trf_gen_IP + ' ' + self.iperf_args + ' 2>&1 > ' + client_filename, '\$', int(iperf_time)*5.0) + SSH.close() + + #once client is done, retrieve the server file from container to EPC Host + SSH.open(EPC.IPAddress, EPC.UserName, EPC.Password) + SSH.command('docker cp prod-trf-gen:/iperf-2.0.13/' + server_filename + ' ' + EPC.SourceCodePath, '\$', 5) + SSH.copyin(EPC.IPAddress, EPC.UserName, EPC.Password, EPC.SourceCodePath + '/' + server_filename, '.') + SSH.close() + + #copy the 2 resulting files locally + SSH.copyin(Module_UE.HostIPAddress, Module_UE.HostUsername, Module_UE.HostPassword, client_filename, '.') + SSH.copyin(EPC.IPAddress, EPC.UserName, EPC.Password, server_filename, '.') + #send for analysis + self.Iperf_analyzeV2BIDIR(lock, UE_IPAddress, device_id, statusQueue, server_filename, client_filename) + else : logging.debug("Incorrect or missing IPERF direction in XML") @@ -2413,6 +2538,30 @@ class OaiCiTest(): #send for analysis filename='iperf_server_' + self.testCase_id + '_' + self.ue_id + '.log' self.Iperf_analyzeV2Server(lock, UE_IPAddress, device_id, statusQueue, self.iperf_args,filename,1) + elif self.iperf_direction=="BIDIR": + logging.debug("Iperf for Module in BIDIR mode detected") + #server side EPC + SSH.open(EPC.IPAddress, EPC.UserName, EPC.Password) + server_filename = 'iperf_server_' + self.testCase_id + '_' + self.ue_id + '.log' + cmd = 'rm ' + server_filename + SSH.command(cmd,'\$',5) + cmd = 'echo $USER; nohup iperf3 -s 2>&1 > '+server_filename+' &' + SSH.command(cmd,'\$',5) + SSH.close() + + #client side UE + SSH.open(Module_UE.HostIPAddress, Module_UE.HostUsername, Module_UE.HostPassword) + client_filename = 'iperf_client_' + self.testCase_id + '_' + self.ue_id + '.log' + cmd = 'rm ' + client_filename + SSH.command(cmd,'\$',5) + SSH.command('iperf3 -c 192.172.0.1 ' + self.iperf_args + ' 2>&1 > '+client_filename, '\$', int(iperf_time)*5.0) + SSH.close() + + #copy the 2 resulting files locally + SSH.copyin(Module_UE.HostIPAddress, Module_UE.HostUsername, Module_UE.HostPassword, client_filename, '.') + SSH.copyin(EPC.IPAddress, EPC.UserName, EPC.Password, server_filename, '.') + #send for analysis + self.Iperf_analyzeV2BIDIR(lock, UE_IPAddress, device_id, statusQueue, server_filename, client_filename) else : logging.debug("Incorrect or missing IPERF direction in XML") @@ -2998,9 +3147,6 @@ class OaiCiTest(): if result is not None and not exitSignalReceived: foundSegFault = True result = re.search('[Cc]ore [dD]ump', str(line)) - if result is not None and not exitSignalReceived: - foundSegFault = True - result = re.search('./lte-uesoftmodem', str(line)) if result is not None and not exitSignalReceived: foundSegFault = True result = re.search('[Aa]ssertion', str(line)) @@ -3348,7 +3494,7 @@ class OaiCiTest(): self.desc = 'Automatic Termination of OAI-UE' HTML.desc = self.desc self.ShowTestID() - self.TerminateOAIUE(HTML,RAN,COTS_UE,EPC,InfraUE) + self.TerminateOAIUE(HTML,RAN,COTS_UE,EPC,InfraUE,CONTAINERS) if (RAN.Initialize_eNB_args != ''): self.testCase_id = 'AUTO-KILL-RAN' HTML.testCase_id = self.testCase_id @@ -3380,6 +3526,41 @@ class OaiCiTest(): CONTAINERS.UndeployObject(HTML,RAN) RAN.prematureExit=True + #this function is called only if eNB/gNB fails to start + #RH to be re-factored + def AutoTerminateeNB(self,HTML,RAN,EPC,CONTAINERS): + if (RAN.Initialize_eNB_args != ''): + self.testCase_id = 'AUTO-KILL-RAN' + HTML.testCase_id = self.testCase_id + self.desc = 'Automatic Termination of all RAN nodes' + HTML.desc = self.desc + self.ShowTestID() + #terminate all RAN nodes eNB/gNB/OCP + for instance in range(0, len(RAN.air_interface)): + if RAN.air_interface[instance]!='': + logging.debug('Auto Termination of Instance ' + str(instance) + ' : ' + RAN.air_interface[instance]) + RAN.eNB_instance=instance + RAN.TerminateeNB(HTML,EPC) + if RAN.flexranCtrlInstalled and RAN.flexranCtrlStarted: + self.testCase_id = 'AUTO-KILL-flexran-ctl' + HTML.testCase_id = self.testCase_id + self.desc = 'Automatic Termination of FlexRan CTL' + HTML.desc = self.desc + self.ShowTestID() + self.TerminateFlexranCtrl(HTML,RAN,EPC) + if CONTAINERS.yamlPath[0] != '': + self.testCase_id = 'AUTO-KILL-CONTAINERS' + HTML.testCase_id = self.testCase_id + self.desc = 'Automatic Termination of all RAN containers' + HTML.desc = self.desc + self.ShowTestID() + for instance in range(0, len(CONTAINERS.yamlPath)): + if CONTAINERS.yamlPath[instance]!='': + CONTAINERS.eNB_instance=instance + CONTAINERS.UndeployObject(HTML,RAN) + RAN.prematureExit=True + + def IdleSleep(self,HTML): time.sleep(self.idle_sleep_time) HTML.CreateHtmlTestRow(str(self.idle_sleep_time) + ' sec', 'OK', CONST.ALL_PROCESSES_OK) diff --git a/ci-scripts/cls_physim.py b/ci-scripts/cls_physim.py index e825b2f7bd694b3abdeb3d7c7c69024ebf65ada5..33792f6ca4cb2c57f6179c1460ef43f3d2b0d183 100644 --- a/ci-scripts/cls_physim.py +++ b/ci-scripts/cls_physim.py @@ -183,7 +183,7 @@ class PhySim: mySSH.open(self.eNBIpAddr, self.eNBUserName, self.eNBPassWord) mySSH.command('cd '+self.__workSpacePath,'\$',5) #run and redirect the results to a log file - mySSH.command(self.__workSpacePath+'phy_simulators/build/ldpctest ' + self.runargs + ' >> '+self.__runLogFile, '\$', 30) + mySSH.command(self.__workSpacePath+'ran_build/build/ldpctest ' + self.runargs + ' >> '+self.__runLogFile, '\$', 30) mySSH.close() #return updated HTML to main lHTML = html.HTMLManagement() diff --git a/ci-scripts/cls_static_code_analysis.py b/ci-scripts/cls_static_code_analysis.py index 1680f3e560340c8cbe9a7946e77f04269b3ef9ff..c899a9aabd678d8a0e107197a2e6f49e070ceb34 100644 --- a/ci-scripts/cls_static_code_analysis.py +++ b/ci-scripts/cls_static_code_analysis.py @@ -121,7 +121,7 @@ class StaticCodeAnalysis(): mySSH.command('docker build --tag oai-cppcheck:xenial --file ci-scripts/docker/Dockerfile.cppcheck.xenial . > cmake_targets/log/cppcheck-xenial.txt 2>&1', '\$', 600) mySSH.command('sed -e "s@xenial@bionic@" ci-scripts/docker/Dockerfile.cppcheck.xenial > ci-scripts/docker/Dockerfile.cppcheck.bionic', '\$', 6) mySSH.command('docker build --tag oai-cppcheck:bionic --file ci-scripts/docker/Dockerfile.cppcheck.bionic . > cmake_targets/log/cppcheck-bionic.txt 2>&1', '\$', 600) - mySSH.command('docker image rm oai-cppcheck:bionic oai-cppcheck:xenial || true', '\$', 60) + mySSH.command('docker image rm oai-cppcheck:bionic oai-cppcheck:xenial || true', '\$', 30) # Analyzing the logs mySSH.command('cd ' + lSourcePath + '/cmake_targets', '\$', 5) diff --git a/ci-scripts/conf_files/benetel-5g.conf b/ci-scripts/conf_files/benetel-5g.conf index 47898aad155b77a35fc1e692688430bda0ec980a..dc86567c1fe70b6ecc18965dc466cd5c1b0ef986 100644 --- a/ci-scripts/conf_files/benetel-5g.conf +++ b/ci-scripts/conf_files/benetel-5g.conf @@ -54,15 +54,6 @@ gNBs = #pdcch-ConfigCommon initialDLBWPcontrolResourceSetZero = 0; initialDLBWPsearchSpaceZero = 0; - #pdsch-ConfigCommon - #pdschTimeDomainAllocationList (up to 16 entries) - initialDLBWPk0_0 = 0; #for DL slot - initialDLBWPmappingType_0 = 0; #0=typeA,1=typeB - initialDLBWPstartSymbolAndLength_0 = 40; #this is SS=1,L=13 - - initialDLBWPk0_1 = 0; #for mixed slot - initialDLBWPmappingType_1 = 0; - initialDLBWPstartSymbolAndLength_1 = 57; #this is SS=1,L=5 #uplinkConfigCommon #frequencyInfoUL @@ -119,19 +110,6 @@ gNBs = # restrictedSetConfig # 0=unrestricted, 1=restricted type A, 2=restricted type B restrictedSetConfig = 0, - # pusch-ConfigCommon (up to 16 elements) - initialULBWPk2_0 = 2; # used for UL slot - initialULBWPmappingType_0 = 1 - initialULBWPstartSymbolAndLength_0 = 55; # this is SS=0 L=12 - - initialULBWPk2_1 = 2; # used for mixed slot - initialULBWPmappingType_1 = 1; - initialULBWPstartSymbolAndLength_1 = 69; # this is SS=10 L=2 - - initialULBWPk2_2 = 7; # used for Msg.3 during RA - initialULBWPmappingType_2 = 1; - initialULBWPstartSymbolAndLength_2 = 52; # this is SS=10 L=4 - msg3_DeltaPreamble = 1; #p0_NominalWithGrant =-90; @@ -237,11 +215,11 @@ MACRLCs = ( ); L1s = ( - { - num_cc = 1; - tr_n_preference = "local_mac"; - pusch_proc_threads = 8; - } +{ + num_cc = 1; + tr_n_preference = "local_mac"; + thread_pool_size = 8; +} ); RUs = ( diff --git a/ci-scripts/conf_files/enb.band38.lte_2x2_tm2.100PRB.usrpn310.conf b/ci-scripts/conf_files/enb.band38.lte_2x2_tm2.100PRB.usrpn310.conf new file mode 100644 index 0000000000000000000000000000000000000000..f116c3708d4dd07544b6effbf8f1f6ca941dbc57 --- /dev/null +++ b/ci-scripts/conf_files/enb.band38.lte_2x2_tm2.100PRB.usrpn310.conf @@ -0,0 +1,281 @@ +Active_eNBs = ( "eNB-Eurecom-B38"); +# Asn1_verbosity, choice in: none, info, annoying +Asn1_verbosity = "none"; + +eNBs = +( + { + ////////// Identification parameters: + eNB_ID = 0xe02; + + cell_type = "CELL_MACRO_ENB"; + + eNB_name = "eNB-Eurecom-B38"; + + // Tracking area code, 0x0000 and 0xfffe are reserved values + tracking_area_code = 1; + plmn_list = ( { mcc = 208; mnc = 97; mnc_length = 2; } ); + + tr_s_preference = "local_mac" + + ////////// Physical parameters: + + component_carriers = ( + { + node_function = "3GPP_eNODEB"; + node_timing = "synch_to_ext_device"; + node_synch_ref = 0; + frame_type = "TDD"; + tdd_config = 1; + tdd_config_s = 0; + prefix_type = "NORMAL"; + eutra_band = 38; + downlink_frequency = 2605000000L; + nr_scg_ssb_freq = 624608; + uplink_frequency_offset = 0; + Nid_cell = 0; + N_RB_DL = 100; + Nid_cell_mbsfn = 0; + nb_antenna_ports = 2; + nb_antennas_tx = 2; + nb_antennas_rx = 2; + tx_gain = 90; + rx_gain = 125; + pbch_repetition = "FALSE"; + prach_root = 0; + prach_config_index = 0; + prach_high_speed = "DISABLE"; + prach_zero_correlation = 1; + prach_freq_offset = 2; + pucch_delta_shift = 1; + pucch_nRB_CQI = 0; + pucch_nCS_AN = 0; + pucch_n1_AN = 0; + pdsch_referenceSignalPower = -29; + pdsch_p_b = 0; + pusch_n_SB = 1; + pusch_enable64QAM = "DISABLE"; + pusch_hoppingMode = "interSubFrame"; + pusch_hoppingOffset = 0; + pusch_groupHoppingEnabled = "ENABLE"; + pusch_groupAssignment = 0; + pusch_sequenceHoppingEnabled = "DISABLE"; + pusch_nDMRS1 = 1; + phich_duration = "NORMAL"; + phich_resource = "ONESIXTH"; + srs_enable = "DISABLE"; + /* srs_BandwidthConfig =; + srs_SubframeConfig =; + srs_ackNackST =; + srs_MaxUpPts =;*/ + + pusch_p0_Nominal = -96; + pusch_alpha = "AL1"; + pucch_p0_Nominal = -104; + msg3_delta_Preamble = 6; + pucch_deltaF_Format1 = "deltaF2"; + pucch_deltaF_Format1b = "deltaF3"; + pucch_deltaF_Format2 = "deltaF0"; + pucch_deltaF_Format2a = "deltaF0"; + pucch_deltaF_Format2b = "deltaF0"; + + rach_numberOfRA_Preambles = 64; + rach_preamblesGroupAConfig = "DISABLE"; + /* + rach_sizeOfRA_PreamblesGroupA = ; + rach_messageSizeGroupA = ; + rach_messagePowerOffsetGroupB = ; + */ + rach_powerRampingStep = 4; + rach_preambleInitialReceivedTargetPower = -108; + rach_preambleTransMax = 10; + rach_raResponseWindowSize = 10; + rach_macContentionResolutionTimer = 48; + rach_maxHARQ_Msg3Tx = 4; + + pcch_default_PagingCycle = 128; + pcch_nB = "oneT"; + bcch_modificationPeriodCoeff = 2; + ue_TimersAndConstants_t300 = 1000; + ue_TimersAndConstants_t301 = 1000; + ue_TimersAndConstants_t310 = 1000; + ue_TimersAndConstants_t311 = 10000; + ue_TimersAndConstants_n310 = 20; + ue_TimersAndConstants_n311 = 1; + ue_TransmissionMode = 2; + + //Parameters for SIB18 + rxPool_sc_CP_Len = "normal"; + rxPool_sc_Period = "sf40"; + rxPool_data_CP_Len = "normal"; + rxPool_ResourceConfig_prb_Num = 20; + rxPool_ResourceConfig_prb_Start = 5; + rxPool_ResourceConfig_prb_End = 44; + rxPool_ResourceConfig_offsetIndicator_present = "prSmall"; + rxPool_ResourceConfig_offsetIndicator_choice = 0; + rxPool_ResourceConfig_subframeBitmap_present = "prBs40"; + rxPool_ResourceConfig_subframeBitmap_choice_bs_buf = "00000000000000000000"; + rxPool_ResourceConfig_subframeBitmap_choice_bs_size = 5; + rxPool_ResourceConfig_subframeBitmap_choice_bs_bits_unused = 0; +/* rxPool_dataHoppingConfig_hoppingParameter = 0; + rxPool_dataHoppingConfig_numSubbands = "ns1"; + rxPool_dataHoppingConfig_rbOffset = 0; + rxPool_commTxResourceUC-ReqAllowed = "TRUE"; +*/ + // Parameters for SIB19 + discRxPool_cp_Len = "normal" + discRxPool_discPeriod = "rf32" + discRxPool_numRetx = 1; + discRxPool_numRepetition = 2; + discRxPool_ResourceConfig_prb_Num = 5; + discRxPool_ResourceConfig_prb_Start = 3; + discRxPool_ResourceConfig_prb_End = 21; + discRxPool_ResourceConfig_offsetIndicator_present = "prSmall"; + discRxPool_ResourceConfig_offsetIndicator_choice = 0; + discRxPool_ResourceConfig_subframeBitmap_present = "prBs40"; + discRxPool_ResourceConfig_subframeBitmap_choice_bs_buf = "f0ffffffff"; + discRxPool_ResourceConfig_subframeBitmap_choice_bs_size = 5; + discRxPool_ResourceConfig_subframeBitmap_choice_bs_bits_unused = 0; + + } + ); + + + srb1_parameters : + { + # timer_poll_retransmit = (ms) [5, 10, 15, 20,... 250, 300, 350, ... 500] + timer_poll_retransmit = 80; + + # timer_reordering = (ms) [0,5, ... 100, 110, 120, ... ,200] + timer_reordering = 35; + + # timer_reordering = (ms) [0,5, ... 250, 300, 350, ... ,500] + timer_status_prohibit = 0; + + # poll_pdu = [4, 8, 16, 32 , 64, 128, 256, infinity(>10000)] + poll_pdu = 4; + + # poll_byte = (kB) [25,50,75,100,125,250,375,500,750,1000,1250,1500,2000,3000,infinity(>10000)] + poll_byte = 99999; + + # max_retx_threshold = [1, 2, 3, 4 , 6, 8, 16, 32] + max_retx_threshold = 4; + } + + # ------- SCTP definitions + SCTP : + { + # Number of streams to use in input/output + SCTP_INSTREAMS = 2; + SCTP_OUTSTREAMS = 2; + }; + + + ////////// MME parameters: + mme_ip_address = ( { ipv4 = "CI_MME_IP_ADDR"; + ipv6 = "192:168:30::17"; + active = "yes"; + preference = "ipv4"; + } + ); + + enable_measurement_reports = "no"; + + ///X2 + enable_x2 = "yes"; + t_reloc_prep = 1000; /* unit: millisecond */ + tx2_reloc_overall = 2000; /* unit: millisecond */ + t_dc_prep = 1000; /* unit: millisecond */ + t_dc_overall = 2000; /* unit: millisecond */ + + NETWORK_INTERFACES : + { + ENB_INTERFACE_NAME_FOR_S1_MME = "eno1"; + ENB_IPV4_ADDRESS_FOR_S1_MME = "CI_ENB_IP_ADDR"; + ENB_INTERFACE_NAME_FOR_S1U = "eno1"; + ENB_IPV4_ADDRESS_FOR_S1U = "CI_ENB_IP_ADDR"; + ENB_PORT_FOR_S1U = 2152; # Spec 2152 + ENB_IPV4_ADDRESS_FOR_X2C = "CI_ENB_IP_ADDR"; + ENB_PORT_FOR_X2C = 36422; # Spec 36422 + }; + } +); + +MACRLCs = ( + { + num_cc = 1; + tr_s_preference = "local_L1"; + tr_n_preference = "local_RRC"; + phy_test_mode = 0; + scheduler_mode = "fairRR"; + bler_target_upper = 20.0; + bler_target_lower = 10.0; + max_ul_rb_index = 27; + puSch10xSnr = 200; + puCch10xSnr = 150; + } +); + +L1s = ( + { + num_cc = 1; + tr_n_preference = "local_mac"; + prach_dtx_threshold = 200; + pucch1_dtx_threshold = 5 + pucch1ab_dtx_threshold =0; + } +); + +RUs = ( + { + local_rf = "yes" + nb_tx = 2 + nb_rx = 2 + att_tx = 0 + att_rx = 0; + bands = [38]; + max_pdschReferenceSignalPower = -27; + max_rxgain = 75; + eNB_instances = [0]; + sdr_addrs = "mgmt_addr=192.168.18.241,addr=192.168.20.2,second_addr=192.168.10.2"; + + } +); + +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"; + } +); + +NETWORK_CONTROLLER : +{ + FLEXRAN_ENABLED = "no"; + FLEXRAN_INTERFACE_NAME = "lo"; + FLEXRAN_IPV4_ADDRESS = "127.0.0.1"; + FLEXRAN_PORT = 2210; + FLEXRAN_CACHE = "/mnt/oai_agent_cache"; + FLEXRAN_AWAIT_RECONF = "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"; + }; + 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 new file mode 100644 index 0000000000000000000000000000000000000000..682fb376cfd95e6a741bbd3d95fee731a55b7dbe --- /dev/null +++ b/ci-scripts/conf_files/episci/episci_gnb.band78.sa.fr1.106PRB.usrpn310.conf @@ -0,0 +1,325 @@ +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 = 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 + } + ); + + }); + + nr_cellid = 12345678L; + + ////////// Physical parameters: + + ssb_SubcarrierOffset = 0; + pdsch_AntennaPorts = 1; + pusch_AntennaPorts = 1; + ul_prbblacklist = "51,52,53,54" + min_rxtxtime = 6; + pdcch_ConfigSIB1 = ( + { + controlResourceSetZero = 12; + searchSpaceZero = 0; + } + ); + + servingCellConfigCommon = ( + { + #spCellConfigCommon + + physCellId = 0; + +# downlinkConfigCommon + #frequencyInfoDL + # this is 3600 MHz + 43 PRBs@30kHz SCS (same as initial BWP) + absoluteFrequencySSB = 641280; + dl_frequencyBand = 78; + # this is 3600 MHz + dl_absoluteFrequencyPointA = 640008; + #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=27,L=48 (275*(L-1))+RBstart + initialDLBWPlocationAndBandwidth = 12952; # 6366 12925 12956 28875 12952 +# subcarrierSpacing +# 0=kHz15, 1=kHz30, 2=kHz60, 3=kHz120 + initialDLBWPsubcarrierSpacing = 1; + #pdcch-ConfigCommon + initialDLBWPcontrolResourceSetZero = 12; + initialDLBWPsearchSpaceZero = 0; + #pdsch-ConfigCommon + #pdschTimeDomainAllocationList (up to 16 entries) + initialDLBWPk0_0 = 0; #for DL slot + initialDLBWPmappingType_0 = 0; #0=typeA,1=typeB + initialDLBWPstartSymbolAndLength_0 = 40; #this is SS=1,L=13 + + initialDLBWPk0_1 = 0; #for mixed slot + initialDLBWPmappingType_1 = 0; + initialDLBWPstartSymbolAndLength_1 = 57; #this is SS=1,L=5 + + #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 = 12952; +# 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 = -96; +#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 = 14; +#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; # used for UL slot + initialULBWPmappingType_0 = 1 + initialULBWPstartSymbolAndLength_0 = 41; # this is SS=0 L=13 + + initialULBWPk2_1 = 6; # used for mixed slot + initialULBWPmappingType_1 = 1; + initialULBWPstartSymbolAndLength_1 = 52; # this is SS=10 L=4 + + initialULBWPk2_2 = 7; # used for Msg.3 during RA + initialULBWPmappingType_2 = 1; + initialULBWPstartSymbolAndLength_2 = 52; # this is SS=10 L=4 + + 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 = "ctrl0"; + GNB_IPV4_ADDRESS_FOR_NG_AMF = "172.16.0.1"; + GNB_INTERFACE_NAME_FOR_NGU = "ctrl0"; + GNB_IPV4_ADDRESS_FOR_NGU = "172.16.0.1"; + GNB_PORT_FOR_NGU = 2152; # Spec 2152 + }; + + } +); + +MACRLCs = ( + { + num_cc = 1; + local_s_if_name = "lo:"; + remote_s_address = "127.0.0.1"; // pnf addr [!] + local_s_address = "127.0.0.2"; // vnf addr + local_s_portc = 50601; // vnf p5 port + remote_s_portc = 50600; // pnf p5 port [!] + local_s_portd = 50611; // vnf p7 port [!] + remote_s_portd = 50610; // pnf p7 port [!] + tr_s_preference = "nfapi"; + tr_n_preference = "local_RRC"; + } +); + +L1s = ( +{ + num_cc = 1; + tr_n_preference = "local_mac"; + thread_pool_size = 8; + prach_dtx_threshold = 120; + pucch0_dtx_threshold = 150; +} +); + +RUs = ( + { + local_rf = "yes" + nb_tx = 1 + nb_rx = 1 + att_tx = 0 + att_rx = 0; + bands = [78]; + max_pdschReferenceSignalPower = -27; + max_rxgain = 75; + eNB_instances = [0]; + #beamforming 1x4 matrix: + bf_weights = [0x00007fff, 0x0000, 0x0000, 0x0000]; + #clock_src = "external"; + sdr_addrs = "mgmt_addr=192.168.18.240,addr=192.168.10.2,second_addr=192.168.20.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"; + 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"; + ngap_log_level ="debug"; + ngap_log_verbosity ="medium"; + }; + diff --git a/ci-scripts/conf_files/episci/episci_nr-ue.nfapi.conf b/ci-scripts/conf_files/episci/episci_nr-ue.nfapi.conf new file mode 100644 index 0000000000000000000000000000000000000000..f5563ecc026c9e162bebc99afc3232f8080c44b1 --- /dev/null +++ b/ci-scripts/conf_files/episci/episci_nr-ue.nfapi.conf @@ -0,0 +1,52 @@ +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 ="medium"; + rlc_log_level ="info"; + rlc_log_verbosity ="medium"; + pdcp_log_level ="info"; + pdcp_log_verbosity ="medium"; + rrc_log_level ="info"; + rrc_log_verbosity ="full"; +}; + +uicc0 = { +imsi = "208950000000031"; +key = "0c0a34601d4f07677303652c0462535b"; +opc= "63bfa50ee6523365ff14c1f45f88737d"; +dnn= "oai"; +nssai_sst=222; +nssai_sd=123; +} + +L1s = ( + { + num_cc = 1; + tr_n_preference = "nfapi"; + local_n_if_name = "ens3"; + remote_n_address = "127.0.0.1"; //Proxy IP + local_n_address = "127.0.0.1"; + local_n_portc = 50600; + remote_n_portc = 50601; + local_n_portd = 50610; + remote_n_portd = 50611; + } +); + +RUs = ( + { + local_rf = "yes" + nb_tx = 1 + nb_rx = 1 + att_tx = 90 + att_rx = 0; + bands = [7,38,42,43]; + max_pdschReferenceSignalPower = -27; + max_rxgain = 125; + } +); diff --git a/ci-scripts/conf_files/episci/episci_nr-ue0.nfapi.conf b/ci-scripts/conf_files/episci/episci_nr-ue0.nfapi.conf new file mode 100644 index 0000000000000000000000000000000000000000..f5563ecc026c9e162bebc99afc3232f8080c44b1 --- /dev/null +++ b/ci-scripts/conf_files/episci/episci_nr-ue0.nfapi.conf @@ -0,0 +1,52 @@ +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 ="medium"; + rlc_log_level ="info"; + rlc_log_verbosity ="medium"; + pdcp_log_level ="info"; + pdcp_log_verbosity ="medium"; + rrc_log_level ="info"; + rrc_log_verbosity ="full"; +}; + +uicc0 = { +imsi = "208950000000031"; +key = "0c0a34601d4f07677303652c0462535b"; +opc= "63bfa50ee6523365ff14c1f45f88737d"; +dnn= "oai"; +nssai_sst=222; +nssai_sd=123; +} + +L1s = ( + { + num_cc = 1; + tr_n_preference = "nfapi"; + local_n_if_name = "ens3"; + remote_n_address = "127.0.0.1"; //Proxy IP + local_n_address = "127.0.0.1"; + local_n_portc = 50600; + remote_n_portc = 50601; + local_n_portd = 50610; + remote_n_portd = 50611; + } +); + +RUs = ( + { + local_rf = "yes" + nb_tx = 1 + nb_rx = 1 + att_tx = 90 + att_rx = 0; + bands = [7,38,42,43]; + max_pdschReferenceSignalPower = -27; + max_rxgain = 125; + } +); diff --git a/ci-scripts/conf_files/episci/episci_nr-ue1.nfapi.conf b/ci-scripts/conf_files/episci/episci_nr-ue1.nfapi.conf new file mode 100644 index 0000000000000000000000000000000000000000..5df3ccf6cc15686af1b3cca34543468a0fb59d56 --- /dev/null +++ b/ci-scripts/conf_files/episci/episci_nr-ue1.nfapi.conf @@ -0,0 +1,52 @@ +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 ="medium"; + rlc_log_level ="info"; + rlc_log_verbosity ="medium"; + pdcp_log_level ="info"; + pdcp_log_verbosity ="medium"; + rrc_log_level ="info"; + rrc_log_verbosity ="full"; +}; + +uicc0 = { +imsi = "208950000000032"; +key = "0c0a34601d4f07677303652c0462535b"; +opc= "63bfa50ee6523365ff14c1f45f88737d"; +dnn= "oai"; +nssai_sst=222; +nssai_sd=123; +} + +L1s = ( + { + num_cc = 1; + tr_n_preference = "nfapi"; + local_n_if_name = "ens3"; + remote_n_address = "127.0.0.1"; //Proxy IP + local_n_address = "127.0.0.1"; + local_n_portc = 50600; + remote_n_portc = 50601; + local_n_portd = 50610; + remote_n_portd = 50611; + } +); + +RUs = ( + { + local_rf = "yes" + nb_tx = 1 + nb_rx = 1 + att_tx = 90 + att_rx = 0; + bands = [7,38,42,43]; + max_pdschReferenceSignalPower = -27; + max_rxgain = 125; + } +); diff --git a/ci-scripts/conf_files/episci/episci_nr-ue2.nfapi.conf b/ci-scripts/conf_files/episci/episci_nr-ue2.nfapi.conf new file mode 100644 index 0000000000000000000000000000000000000000..b1ce5fee8d0ee856ce483658eba66f37149ea46c --- /dev/null +++ b/ci-scripts/conf_files/episci/episci_nr-ue2.nfapi.conf @@ -0,0 +1,52 @@ +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 ="medium"; + rlc_log_level ="info"; + rlc_log_verbosity ="medium"; + pdcp_log_level ="info"; + pdcp_log_verbosity ="medium"; + rrc_log_level ="info"; + rrc_log_verbosity ="full"; +}; + +uicc0 = { +imsi = "208950000000033"; +key = "0c0a34601d4f07677303652c0462535b"; +opc= "63bfa50ee6523365ff14c1f45f88737d"; +dnn= "oai"; +nssai_sst=222; +nssai_sd=123; +} + +L1s = ( + { + num_cc = 1; + tr_n_preference = "nfapi"; + local_n_if_name = "ens3"; + remote_n_address = "127.0.0.1"; //Proxy IP + local_n_address = "127.0.0.1"; + local_n_portc = 50600; + remote_n_portc = 50601; + local_n_portd = 50610; + remote_n_portd = 50611; + } +); + +RUs = ( + { + local_rf = "yes" + nb_tx = 1 + nb_rx = 1 + att_tx = 90 + att_rx = 0; + bands = [7,38,42,43]; + max_pdschReferenceSignalPower = -27; + max_rxgain = 125; + } +); diff --git a/ci-scripts/conf_files/episci/episci_nr-ue3.nfapi.conf b/ci-scripts/conf_files/episci/episci_nr-ue3.nfapi.conf new file mode 100644 index 0000000000000000000000000000000000000000..aea5104f1c6f42356495e15b7910bc0dd659da74 --- /dev/null +++ b/ci-scripts/conf_files/episci/episci_nr-ue3.nfapi.conf @@ -0,0 +1,52 @@ +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 ="medium"; + rlc_log_level ="info"; + rlc_log_verbosity ="medium"; + pdcp_log_level ="info"; + pdcp_log_verbosity ="medium"; + rrc_log_level ="info"; + rrc_log_verbosity ="full"; +}; + +uicc0 = { +imsi = "208950000000034"; +key = "0c0a34601d4f07677303652c0462535b"; +opc= "63bfa50ee6523365ff14c1f45f88737d"; +dnn= "oai"; +nssai_sst=222; +nssai_sd=123; +} + +L1s = ( + { + num_cc = 1; + tr_n_preference = "nfapi"; + local_n_if_name = "ens3"; + remote_n_address = "127.0.0.1"; //Proxy IP + local_n_address = "127.0.0.1"; + local_n_portc = 50600; + remote_n_portc = 50601; + local_n_portd = 50610; + remote_n_portd = 50611; + } +); + +RUs = ( + { + local_rf = "yes" + nb_tx = 1 + nb_rx = 1 + att_tx = 90 + att_rx = 0; + bands = [7,38,42,43]; + max_pdschReferenceSignalPower = -27; + max_rxgain = 125; + } +); diff --git a/ci-scripts/conf_files/episci/episci_rcc.band7.tm1.nfapi.conf b/ci-scripts/conf_files/episci/episci_rcc.band7.tm1.nfapi.conf new file mode 100644 index 0000000000000000000000000000000000000000..4e596f81b59b1e72fca2ba3786ccf39479985ac7 --- /dev/null +++ b/ci-scripts/conf_files/episci/episci_rcc.band7.tm1.nfapi.conf @@ -0,0 +1,247 @@ +Active_eNBs = ( "eNB-Eurecom-LTEBox"); +# Asn1_verbosity, choice in: none, info, annoying +Asn1_verbosity = "none"; + +eNBs = +( + { + ////////// Identification parameters: + eNB_ID = 0xe00; + + cell_type = "CELL_MACRO_ENB"; + + eNB_name = "eNB-Eurecom-LTEBox"; + + // Tracking area code, 0x0000 and 0xfffe are reserved values + tracking_area_code = 5; + + plmn_list = ( { mcc = 320; mnc = 230; mnc_length = 3; } ); + + tr_s_preference = "local_mac" + + ////////// Physical parameters: + + component_carriers = ( + { + node_function = "3GPP_eNODEB"; + node_timing = "synch_to_ext_device"; + node_synch_ref = 0; + frame_type = "FDD"; + tdd_config = 3; + tdd_config_s = 0; + prefix_type = "NORMAL"; + eutra_band = 7; + downlink_frequency = 2685000000L; + uplink_frequency_offset = -120000000; + Nid_cell = 0; + N_RB_DL = 50; + Nid_cell_mbsfn = 0; + nb_antenna_ports = 1; + nb_antennas_tx = 1; + nb_antennas_rx = 1; + tx_gain = 90; + rx_gain = 125; + pbch_repetition = "FALSE"; + prach_root = 0; + prach_config_index = 0; + prach_high_speed = "DISABLE"; + prach_zero_correlation = 1; + prach_freq_offset = 2; + pucch_delta_shift = 1; + pucch_nRB_CQI = 0; + pucch_nCS_AN = 0; + pucch_n1_AN = 0; + pdsch_referenceSignalPower = -27; + pdsch_p_b = 0; + pusch_n_SB = 1; + pusch_enable64QAM = "DISABLE"; + pusch_hoppingMode = "interSubFrame"; + pusch_hoppingOffset = 0; + pusch_groupHoppingEnabled = "ENABLE"; + pusch_groupAssignment = 0; + pusch_sequenceHoppingEnabled = "DISABLE"; + pusch_nDMRS1 = 1; + phich_duration = "NORMAL"; + phich_resource = "ONESIXTH"; + srs_enable = "DISABLE"; + /* srs_BandwidthConfig =; + srs_SubframeConfig =; + srs_ackNackST =; + srs_MaxUpPts =;*/ + + pusch_p0_Nominal = -96; + pusch_alpha = "AL1"; + pucch_p0_Nominal = -104; + msg3_delta_Preamble = 6; + pucch_deltaF_Format1 = "deltaF2"; + pucch_deltaF_Format1b = "deltaF3"; + pucch_deltaF_Format2 = "deltaF0"; + pucch_deltaF_Format2a = "deltaF0"; + pucch_deltaF_Format2b = "deltaF0"; + + rach_numberOfRA_Preambles = 64; + rach_preamblesGroupAConfig = "DISABLE"; + /* + rach_sizeOfRA_PreamblesGroupA = ; + rach_messageSizeGroupA = ; + rach_messagePowerOffsetGroupB = ; + */ + rach_powerRampingStep = 4; + rach_preambleInitialReceivedTargetPower = -108; + rach_preambleTransMax = 10; + rach_raResponseWindowSize = 10; + rach_macContentionResolutionTimer = 48; + rach_maxHARQ_Msg3Tx = 4; + + pcch_default_PagingCycle = 128; + pcch_nB = "oneT"; + bcch_modificationPeriodCoeff = 2; + ue_TimersAndConstants_t300 = 1000; + ue_TimersAndConstants_t301 = 1000; + ue_TimersAndConstants_t310 = 1000; + ue_TimersAndConstants_t311 = 10000; + ue_TimersAndConstants_n310 = 20; + ue_TimersAndConstants_n311 = 1; + ue_TransmissionMode = 1; + + //Parameters for SIB18 + rxPool_sc_CP_Len = "normal"; + rxPool_sc_Period = "sf40"; + rxPool_data_CP_Len = "normal"; + rxPool_ResourceConfig_prb_Num = 20; + rxPool_ResourceConfig_prb_Start = 5; + rxPool_ResourceConfig_prb_End = 44; + rxPool_ResourceConfig_offsetIndicator_present = "prSmall"; + rxPool_ResourceConfig_offsetIndicator_choice = 0; + rxPool_ResourceConfig_subframeBitmap_present = "prBs40"; + rxPool_ResourceConfig_subframeBitmap_choice_bs_buf = "00000000000000000000"; + rxPool_ResourceConfig_subframeBitmap_choice_bs_size = 5; + rxPool_ResourceConfig_subframeBitmap_choice_bs_bits_unused = 0; +/* rxPool_dataHoppingConfig_hoppingParameter = 0; + rxPool_dataHoppingConfig_numSubbands = "ns1"; + rxPool_dataHoppingConfig_rbOffset = 0; + rxPool_commTxResourceUC-ReqAllowed = "TRUE"; +*/ + // Parameters for SIB19 + discRxPool_cp_Len = "normal" + discRxPool_discPeriod = "rf32" + discRxPool_numRetx = 1; + discRxPool_numRepetition = 2; + discRxPool_ResourceConfig_prb_Num = 5; + discRxPool_ResourceConfig_prb_Start = 3; + discRxPool_ResourceConfig_prb_End = 21; + discRxPool_ResourceConfig_offsetIndicator_present = "prSmall"; + discRxPool_ResourceConfig_offsetIndicator_choice = 0; + discRxPool_ResourceConfig_subframeBitmap_present = "prBs40"; + discRxPool_ResourceConfig_subframeBitmap_choice_bs_buf = "f0ffffffff"; + discRxPool_ResourceConfig_subframeBitmap_choice_bs_size = 5; + discRxPool_ResourceConfig_subframeBitmap_choice_bs_bits_unused = 0; + + } + ); + + + srb1_parameters : + { + # timer_poll_retransmit = (ms) [5, 10, 15, 20,... 250, 300, 350, ... 500] + timer_poll_retransmit = 80; + + # timer_reordering = (ms) [0,5, ... 100, 110, 120, ... ,200] + timer_reordering = 35; + + # timer_reordering = (ms) [0,5, ... 250, 300, 350, ... ,500] + timer_status_prohibit = 0; + + # poll_pdu = [4, 8, 16, 32 , 64, 128, 256, infinity(>10000)] + poll_pdu = 4; + + # poll_byte = (kB) [25,50,75,100,125,250,375,500,750,1000,1250,1500,2000,3000,infinity(>10000)] + poll_byte = 99999; + + # max_retx_threshold = [1, 2, 3, 4 , 6, 8, 16, 32] + max_retx_threshold = 4; + } + + # ------- 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.61.195"; + ipv6 = "192:168:30::17"; + port = 36412 ; + active = "yes"; + preference = "ipv4"; + } + ); + + enable_measurement_reports = "yes"; + + ///X2 + enable_x2 = "yes"; + t_reloc_prep = 1000; /* unit: millisecond */ + tx2_reloc_overall = 2000; /* unit: millisecond */ + t_dc_prep = 1000; /* unit: millisecond */ + t_dc_overall = 2000; /* unit: millisecond */ + + NETWORK_INTERFACES : + { + ENB_INTERFACE_NAME_FOR_S1_MME = "ctrl0"; + ENB_IPV4_ADDRESS_FOR_S1_MME = "172.16.0.1"; + ENB_INTERFACE_NAME_FOR_S1U = "ctrl0"; + ENB_IPV4_ADDRESS_FOR_S1U = "172.16.0.1"; + ENB_PORT_FOR_S1U = 2152; # Spec 2152 + ENB_IPV4_ADDRESS_FOR_X2C = "172.16.0.1"; + ENB_PORT_FOR_X2C = 36422; # Spec 36422 + + }; + } +); + +MACRLCs = ( + { + num_cc = 1; + local_s_if_name = "lo"; + remote_s_address = "127.0.0.1"; + local_s_address = "127.0.0.1"; + local_s_portc = 50001; + remote_s_portc = 50000; + local_s_portd = 50011; + remote_s_portd = 50010; + tr_s_preference = "nfapi"; + tr_n_preference = "local_RRC"; + scheduler_mode = "fairRR"; + } +); + +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"; + } +); + +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"; + }; diff --git a/ci-scripts/conf_files/episci/episci_rcc.band78.tm1.106PRB.nfapi.conf b/ci-scripts/conf_files/episci/episci_rcc.band78.tm1.106PRB.nfapi.conf new file mode 100644 index 0000000000000000000000000000000000000000..b64b88ddeabbac5332093567592ef8018520950b --- /dev/null +++ b/ci-scripts/conf_files/episci/episci_rcc.band78.tm1.106PRB.nfapi.conf @@ -0,0 +1,265 @@ +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 = 5; + + plmn_list = ({mcc = 320; mnc = 230; mnc_length = 3;}); + + tr_s_preference = "local_mac" + + ////////// Physical parameters: + + ssb_SubcarrierOffset = 31; //0; + pdsch_AntennaPorts = 1; + pusch_AntennaPorts = 1; + + servingCellConfigCommon = ( + { + #spCellConfigCommon + + physCellId = 0; + +# downlinkConfigCommon + #frequencyInfoDL + # this is 3600 MHz + 84 PRBs@30kHz SCS (same as initial BWP) + absoluteFrequencySSB = 641272; //641032; #641968; 641968=start of ssb at 3600MHz + 82 RBs 641032=center of SSB at center of cell + dl_frequencyBand = 78; + # this is 3600 MHz + dl_absoluteFrequencyPointA = 640000; + #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=84,L=13 (275*(L-1))+RBstart + initialDLBWPlocationAndBandwidth = 6368; +# subcarrierSpacing +# 0=kHz15, 1=kHz30, 2=kHz60, 3=kHz120 + initialDLBWPsubcarrierSpacing = 1; + #pdcch-ConfigCommon + initialDLBWPcontrolResourceSetZero = 0; + initialDLBWPsearchSpaceZero = 0; + #pdsch-ConfigCommon + #pdschTimeDomainAllocationList (up to 16 entries) + initialDLBWPk0_0 = 0; #for DL slot + initialDLBWPmappingType_0 = 0; #0=typeA,1=typeB + initialDLBWPstartSymbolAndLength_0 = 40; #this is SS=1,L=13 + + initialDLBWPk0_1 = 0; #for mixed slot + initialDLBWPmappingType_1 = 0; + initialDLBWPstartSymbolAndLength_1 = 57; #this is SS=1,L=5 + + #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 = 6368; +# 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 = -100; +#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 = 5; +#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 = 14; //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; # used for UL slot + initialULBWPmappingType_0 = 1 + initialULBWPstartSymbolAndLength_0 = 41; # this is SS=0 L=13 + + initialULBWPk2_1 = 6; # used for mixed slot + initialULBWPmappingType_1 = 1; + initialULBWPstartSymbolAndLength_1 = 52; # this is SS=10 L=4 + + initialULBWPk2_2 = 7; # used for Msg.3 during RA + initialULBWPmappingType_2 = 1; + initialULBWPstartSymbolAndLength_2 = 52; # this is SS=10 L=4 + + 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; #0x80; + +# 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; //8; //7; + nrofDownlinkSymbols = 6; //0; //6; + nrofUplinkSlots = 2; + nrofUplinkSymbols = 4; //0; //4; + + 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.61.195"; + ipv6 = "192:168:30::17"; + active = "yes"; + preference = "ipv4"; + } + ); + ///X2 + enable_x2 = "yes"; + t_reloc_prep = 1000; /* unit: millisecond */ + tx2_reloc_overall = 2000; /* unit: millisecond */ + t_dc_prep = 1000; /* unit: millisecond */ + t_dc_overall = 2000; /* unit: millisecond */ + target_enb_x2_ip_address = ( + { ipv4 = "172.16.0.1"; # rrc.band7.tm1.nfapi.conf:line 201 + ipv6 = "192:168:30::17"; + preference = "ipv4"; + } + ); + + NETWORK_INTERFACES : + { # All of these have to be IP addr of gNB + # if in CORE container, make it 172.16.0.X + # if not launched in CORE, can set to lo (127.0.0.2) + GNB_INTERFACE_NAME_FOR_S1_MME = "ctrl0"; + GNB_IPV4_ADDRESS_FOR_S1_MME = "172.16.0.2"; + GNB_INTERFACE_NAME_FOR_S1U = "ctrl0"; + GNB_IPV4_ADDRESS_FOR_S1U = "172.16.0.2"; + GNB_PORT_FOR_S1U = 2152; # Spec 2152 + GNB_IPV4_ADDRESS_FOR_X2C = "172.16.0.2"; + GNB_PORT_FOR_X2C = 36422; # Spec 36422 + }; + } +); + + +MACRLCs = ( + { + num_cc = 1; + local_s_if_name = "lo:"; + remote_s_address = "127.0.0.1"; // pnf addr [!] + local_s_address = "127.0.0.2"; // vnf addr + local_s_portc = 50601; // vnf p5 port + remote_s_portc = 50600; // pnf p5 port [!] + local_s_portd = 50611; // vnf p7 port [!] + remote_s_portd = 50610; // pnf p7 port [!] + tr_s_preference = "nfapi"; + tr_n_preference = "local_RRC"; + } +) + + +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"; + } +); + +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"; + }; + diff --git a/ci-scripts/conf_files/episci/episci_ue.nfapi.conf b/ci-scripts/conf_files/episci/episci_ue.nfapi.conf new file mode 100644 index 0000000000000000000000000000000000000000..0170a466552424119c05fa5ae8c6c40cdb45a471 --- /dev/null +++ b/ci-scripts/conf_files/episci/episci_ue.nfapi.conf @@ -0,0 +1,44 @@ +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 ="medium"; + rlc_log_level ="info"; + rlc_log_verbosity ="medium"; + pdcp_log_level ="info"; + pdcp_log_verbosity ="medium"; + rrc_log_level ="info"; + rrc_log_verbosity ="full"; +}; + + +L1s = ( + { + num_cc = 1; + tr_n_preference = "nfapi"; + local_n_if_name = "ens3"; + remote_n_address = "127.0.0.1"; //Proxy IP + local_n_address = "127.0.0.1"; + local_n_portc = 50000; + remote_n_portc = 50001; + local_n_portd = 50010; + remote_n_portd = 50011; + } +); + +RUs = ( + { + local_rf = "yes" + nb_tx = 1 + nb_rx = 1 + att_tx = 90 + att_rx = 0; + bands = [7,38,42,43]; + max_pdschReferenceSignalPower = -27; + max_rxgain = 125; + } +); diff --git a/ci-scripts/conf_files/episci/episci_ue_test_sfr.conf b/ci-scripts/conf_files/episci/episci_ue_test_sfr.conf new file mode 100644 index 0000000000000000000000000000000000000000..e98e1b92f1fdd19cb427ee46db6dddc584d917d5 --- /dev/null +++ b/ci-scripts/conf_files/episci/episci_ue_test_sfr.conf @@ -0,0 +1,786 @@ +# List of known PLMNS +PLMN: { + PLMN0: { + FULLNAME="Test network"; + SHORTNAME="OAI4G"; + MNC="01"; + MCC="001"; + + }; + PLMN1: { + FULLNAME="SFR France"; + SHORTNAME="SFR"; + MNC="10"; + MCC="208"; + + }; + PLMN2: { + FULLNAME="SFR France"; + SHORTNAME="SFR"; + MNC="11"; + MCC="208"; + }; + PLMN3: { + FULLNAME="SFR France"; + SHORTNAME="SFR"; + MNC="13"; + MCC="208"; + }; + PLMN4: { + FULLNAME="OAI LTEBOX"; + SHORTNAME="OAIALU"; + MNC="95"; + MCC="208"; + }; + PLMN5: { + FULLNAME="T-Mobile USA"; + SHORTNAME="T-Mobile"; + MNC="280"; + MCC="310"; + }; + PLMN6: { + FULLNAME="FICTITIOUS USA"; + SHORTNAME="FICTITIO"; + MNC="028"; + MCC="310"; + }; + PLMN7: { + FULLNAME="Vodafone Italia"; + SHORTNAME="VODAFONE"; + MNC="10"; + MCC="222"; + }; + PLMN8: { + FULLNAME="Vodafone Spain"; + SHORTNAME="VODAFONE"; + MNC="01"; + MCC="214"; + }; + PLMN9: { + FULLNAME="Vodafone Spain"; + SHORTNAME="VODAFONE"; + MNC="06"; + MCC="214"; + }; + PLMN10: { + FULLNAME="Vodafone Germ"; + SHORTNAME="VODAFONE"; + MNC="02"; + MCC="262"; + }; + PLMN11: { + FULLNAME="Vodafone Germ"; + SHORTNAME="VODAFONE"; + MNC="04"; + MCC="262"; + }; + PLMN12: { + FULLNAME="Vodafone Germ"; + SHORTNAME="VODAFONE"; + MNC="230"; + MCC="320"; + }; +}; + +UE0: +{ + USER: { + IMEI="356113022094148"; + MANUFACTURER="EURECOM"; + MODEL="LTE Android PC"; + PIN="0000"; + }; + + SIM: { + MSIN="100000025"; + USIM_API_K="0c0a34601d4f07677303652c0462535b"; + OPC="ba05688178e398bedc100674071002cb"; + MSISDN="1011234561024"; + }; + + # Home PLMN Selector with Access Technology + HPLMN= "320230"; + + # User controlled PLMN Selector with Access Technology + UCPLMN_LIST = (); + + # Operator PLMN List + OPLMN_LIST = ("00101", "20810", "20811", "20813", "20895", "310280", "310028", "320230"); + + # Operator controlled PLMN Selector with Access Technology + OCPLMN_LIST = ("22210", "21401", "21406", "26202", "26204"); + + # Forbidden plmns + FPLMN_LIST = (); + + # List of Equivalent HPLMNs +#TODO: UE does not connect if set, to be fixed in the UE +# EHPLMN_LIST= ("20811", "20813"); + EHPLMN_LIST= (); +}; + +UE1: +{ + USER: { + IMEI="356113022094149"; + MANUFACTURER="EURECOM"; + MODEL="LTE Android PC"; + PIN="0000"; + }; + + SIM: { + MSIN="100000166"; + USIM_API_K="0c0a34601d4f07677303652c0462535b"; + OPC="ba05688178e398bedc100674071002cb"; + MSISDN="1011234561165"; + }; + + # Home PLMN Selector with Access Technology + HPLMN= "320230"; + + # User controlled PLMN Selector with Access Technology + UCPLMN_LIST = (); + + # Operator PLMN List + OPLMN_LIST = ("00101", "20810", "20811", "20813", "20895", "310280", "310028", "320230"); + + # Operator controlled PLMN Selector with Access Technology + OCPLMN_LIST = ("22210", "21401", "21406", "26202", "26204"); + + # Forbidden plmns + FPLMN_LIST = (); + + # List of Equivalent HPLMNs +#TODO: UE does not connect if set, to be fixed in the UE +# EHPLMN_LIST= ("20811", "20813"); + EHPLMN_LIST= (); +}; + +UE2: +{ + USER: { + IMEI="356113022094150"; + MANUFACTURER="EURECOM"; + MODEL="LTE Android PC"; + PIN="0000"; + }; + + SIM: { + MSIN="100000012"; + USIM_API_K="0c0a34601d4f07677303652c0462535b"; + OPC="ba05688178e398bedc100674071002cb"; + MSISDN="1011234561011"; + }; + + # Home PLMN Selector with Access Technology + HPLMN= "320230"; + + # User controlled PLMN Selector with Access Technology + UCPLMN_LIST = (); + + # Operator PLMN List + OPLMN_LIST = ("00101", "20810", "20811", "20813", "20895", "310280", "310028", "320230"); + + # Operator controlled PLMN Selector with Access Technology + OCPLMN_LIST = ("22210", "21401", "21406", "26202", "26204"); + + # Forbidden plmns + FPLMN_LIST = (); + + # List of Equivalent HPLMNs +#TODO: UE does not connect if set, to be fixed in the UE +# EHPLMN_LIST= ("20811", "20813"); + EHPLMN_LIST= (); +}; + +UE3: +{ + USER: { + IMEI="356113022094151"; + MANUFACTURER="EURECOM"; + MODEL="LTE Android PC"; + PIN="0000"; + }; + + SIM: { + MSIN="100000064"; + USIM_API_K="0c0a34601d4f07677303652c0462535b"; + OPC="ba05688178e398bedc100674071002cb"; + MSISDN="1011234561063"; + }; + + # Home PLMN Selector with Access Technology + HPLMN= "320230"; + + # User controlled PLMN Selector with Access Technology + UCPLMN_LIST = (); + + # Operator PLMN List + OPLMN_LIST = ("00101", "20810", "20811", "20813", "20895", "310280", "310028", "320230"); + + # Operator controlled PLMN Selector with Access Technology + OCPLMN_LIST = ("22210", "21401", "21406", "26202", "26204"); + + # Forbidden plmns + FPLMN_LIST = (); + + # List of Equivalent HPLMNs +#TODO: UE does not connect if set, to be fixed in the UE +# EHPLMN_LIST= ("20811", "20813"); + EHPLMN_LIST= (); +}; + +UE4: +{ + USER: { + IMEI="356113022094152"; + MANUFACTURER="EURECOM"; + MODEL="LTE Android PC"; + PIN="0000"; + }; + + SIM: { + MSIN="100000082"; + USIM_API_K="0c0a34601d4f07677303652c0462535b"; + OPC="ba05688178e398bedc100674071002cb"; + MSISDN="1011234561081"; + }; + + # Home PLMN Selector with Access Technology + HPLMN= "320230"; + + # User controlled PLMN Selector with Access Technology + UCPLMN_LIST = (); + + # Operator PLMN List + OPLMN_LIST = ("00101", "20810", "20811", "20813", "20895", "310280", "310028", "320230"); + + # Operator controlled PLMN Selector with Access Technology + OCPLMN_LIST = ("22210", "21401", "21406", "26202", "26204"); + + # Forbidden plmns + FPLMN_LIST = (); + + # List of Equivalent HPLMNs +#TODO: UE does not connect if set, to be fixed in the UE +# EHPLMN_LIST= ("20811", "20813"); + EHPLMN_LIST= (); +}; + +UE5: +{ + USER: { + IMEI="356113022094153"; + MANUFACTURER="EURECOM"; + MODEL="LTE Android PC"; + PIN="0000"; + }; + + SIM: { + MSIN="100000011"; + USIM_API_K="0c0a34601d4f07677303652c0462535b"; + OPC="ba05688178e398bedc100674071002cb"; + MSISDN="1011234561010"; + }; + + # Home PLMN Selector with Access Technology + HPLMN= "320230"; + + # User controlled PLMN Selector with Access Technology + UCPLMN_LIST = (); + + # Operator PLMN List + OPLMN_LIST = ("00101", "20810", "20811", "20813", "20895", "310280", "310028", "320230"); + + # Operator controlled PLMN Selector with Access Technology + OCPLMN_LIST = ("22210", "21401", "21406", "26202", "26204"); + + # Forbidden plmns + FPLMN_LIST = (); + + # List of Equivalent HPLMNs +#TODO: UE does not connect if set, to be fixed in the UE +# EHPLMN_LIST= ("20811", "20813"); + EHPLMN_LIST= (); +}; + +UE6: +{ + USER: { + IMEI="356113022094154"; + MANUFACTURER="EURECOM"; + MODEL="LTE Android PC"; + PIN="0000"; + }; + + SIM: { + MSIN="100000093"; + USIM_API_K="0c0a34601d4f07677303652c0462535b"; + OPC="ba05688178e398bedc100674071002cb"; + MSISDN="1011234561092"; + }; + + # Home PLMN Selector with Access Technology + HPLMN= "320230"; + + # User controlled PLMN Selector with Access Technology + UCPLMN_LIST = (); + + # Operator PLMN List + OPLMN_LIST = ("00101", "20810", "20811", "20813", "20895", "310280", "310028", "320230"); + + # Operator controlled PLMN Selector with Access Technology + OCPLMN_LIST = ("22210", "21401", "21406", "26202", "26204"); + + # Forbidden plmns + FPLMN_LIST = (); + + # List of Equivalent HPLMNs +#TODO: UE does not connect if set, to be fixed in the UE +# EHPLMN_LIST= ("20811", "20813"); + EHPLMN_LIST= (); +}; + +UE7: +{ + USER: { + IMEI="356113022094155"; + MANUFACTURER="EURECOM"; + MODEL="LTE Android PC"; + PIN="0000"; + }; + + SIM: { + MSIN="100000188"; + USIM_API_K="0c0a34601d4f07677303652c0462535b"; + OPC="ba05688178e398bedc100674071002cb"; + MSISDN="1011234561187"; + }; + + # Home PLMN Selector with Access Technology + HPLMN= "320230"; + + # User controlled PLMN Selector with Access Technology + UCPLMN_LIST = (); + + # Operator PLMN List + OPLMN_LIST = ("00101", "20810", "20811", "20813", "20895", "310280", "310028", "320230"); + + # Operator controlled PLMN Selector with Access Technology + OCPLMN_LIST = ("22210", "21401", "21406", "26202", "26204"); + + # Forbidden plmns + FPLMN_LIST = (); + + # List of Equivalent HPLMNs +#TODO: UE does not connect if set, to be fixed in the UE +# EHPLMN_LIST= ("20811", "20813"); + EHPLMN_LIST= (); +}; + +UE8: +{ + USER: { + IMEI="356113022094158"; + MANUFACTURER="EURECOM"; + MODEL="LTE Android PC"; + PIN="0000"; + }; + + SIM: { + MSIN="100000017"; + USIM_API_K="0c0a34601d4f07677303652c0462535b"; + OPC="ba05688178e398bedc100674071002cb"; + MSISDN="1011234561016"; + }; + + # Home PLMN Selector with Access Technology + HPLMN= "320230"; + + # User controlled PLMN Selector with Access Technology + UCPLMN_LIST = (); + + # Operator PLMN List + OPLMN_LIST = ("00101", "20810", "20811", "20813", "20895", "310280", "310028", "320230"); + + # Operator controlled PLMN Selector with Access Technology + OCPLMN_LIST = ("22210", "21401", "21406", "26202", "26204"); + + # Forbidden plmns + FPLMN_LIST = (); + + # List of Equivalent HPLMNs +#TODO: UE does not connect if set, to be fixed in the UE +# EHPLMN_LIST= ("20811", "20813"); + EHPLMN_LIST= (); +}; + +UE9: +{ + USER: { + IMEI="356113022094159"; + MANUFACTURER="EURECOM"; + MODEL="LTE Android PC"; + PIN="0000"; + }; + + SIM: { + MSIN="100000071"; + USIM_API_K="0c0a34601d4f07677303652c0462535b"; + OPC="ba05688178e398bedc100674071002cb"; + MSISDN="1011234561070"; + }; + + # Home PLMN Selector with Access Technology + HPLMN= "320230"; + + # User controlled PLMN Selector with Access Technology + UCPLMN_LIST = (); + + # Operator PLMN List + OPLMN_LIST = ("00101", "20810", "20811", "20813", "20895", "310280", "310028", "320230"); + + # Operator controlled PLMN Selector with Access Technology + OCPLMN_LIST = ("22210", "21401", "21406", "26202", "26204"); + + # Forbidden plmns + FPLMN_LIST = (); + + # List of Equivalent HPLMNs +#TODO: UE does not connect if set, to be fixed in the UE +# EHPLMN_LIST= ("20811", "20813"); + EHPLMN_LIST= (); +}; + +UE10: +{ + USER: { + IMEI="356113022094110"; + MANUFACTURER="EURECOM"; + MODEL="LTE Android PC"; + PIN="0000"; + }; + + SIM: { + MSIN="100000125"; + USIM_API_K="0c0a34601d4f07677303652c0462535b"; + OPC="ba05688178e398bedc100674071002cb"; + MSISDN="1011234561124"; + }; + + # Home PLMN Selector with Access Technology + HPLMN= "320230"; + + # User controlled PLMN Selector with Access Technology + UCPLMN_LIST = (); + + # Operator PLMN List + OPLMN_LIST = ("00101", "20810", "20811", "20813", "20895", "310280", "310028", "320230"); + + # Operator controlled PLMN Selector with Access Technology + OCPLMN_LIST = ("22210", "21401", "21406", "26202", "26204"); + + # Forbidden plmns + FPLMN_LIST = (); + + # List of Equivalent HPLMNs +#TODO: UE does not connect if set, to be fixed in the UE +# EHPLMN_LIST= ("20811", "20813"); + EHPLMN_LIST= (); +}; + +UE11: +{ + USER: { + IMEI="356113022094111"; + MANUFACTURER="EURECOM"; + MODEL="LTE Android PC"; + PIN="0000"; + }; + + SIM: { + MSIN="100000067"; + USIM_API_K="0c0a34601d4f07677303652c0462535b"; + OPC="ba05688178e398bedc100674071002cb"; + MSISDN="1011234561066"; + }; + + # Home PLMN Selector with Access Technology + HPLMN= "320230"; + + # User controlled PLMN Selector with Access Technology + UCPLMN_LIST = (); + + # Operator PLMN List + OPLMN_LIST = ("00101", "20810", "20811", "20813", "20895", "310280", "310028", "320230"); + + # Operator controlled PLMN Selector with Access Technology + OCPLMN_LIST = ("22210", "21401", "21406", "26202", "26204"); + + # Forbidden plmns + FPLMN_LIST = (); + + # List of Equivalent HPLMNs +#TODO: UE does not connect if set, to be fixed in the UE +# EHPLMN_LIST= ("20811", "20813"); + EHPLMN_LIST= (); +}; + +UE12: +{ + USER: { + IMEI="356113022094112"; + MANUFACTURER="EURECOM"; + MODEL="LTE Android PC"; + PIN="0000"; + }; + + SIM: { + MSIN="100000152"; + USIM_API_K="0c0a34601d4f07677303652c0462535b"; + OPC="ba05688178e398bedc100674071002cb"; + MSISDN="1011234561151"; + }; + + # Home PLMN Selector with Access Technology + HPLMN= "320230"; + + # User controlled PLMN Selector with Access Technology + UCPLMN_LIST = (); + + # Operator PLMN List + OPLMN_LIST = ("00101", "20810", "20811", "20813", "20895", "310280", "310028", "320230"); + + # Operator controlled PLMN Selector with Access Technology + OCPLMN_LIST = ("22210", "21401", "21406", "26202", "26204"); + + # Forbidden plmns + FPLMN_LIST = (); + + # List of Equivalent HPLMNs +#TODO: UE does not connect if set, to be fixed in the UE +# EHPLMN_LIST= ("20811", "20813"); + EHPLMN_LIST= (); +}; + +UE13: +{ + USER: { + IMEI="356113022094113"; + MANUFACTURER="EURECOM"; + MODEL="LTE Android PC"; + PIN="0000"; + }; + + SIM: { + MSIN="100000083"; + USIM_API_K="0c0a34601d4f07677303652c0462535b"; + OPC="ba05688178e398bedc100674071002cb"; + MSISDN="1011234561082"; + }; + + # Home PLMN Selector with Access Technology + HPLMN= "320230"; + + # User controlled PLMN Selector with Access Technology + UCPLMN_LIST = (); + + # Operator PLMN List + OPLMN_LIST = ("00101", "20810", "20811", "20813", "20895", "310280", "310028", "320230"); + + # Operator controlled PLMN Selector with Access Technology + OCPLMN_LIST = ("22210", "21401", "21406", "26202", "26204"); + + # Forbidden plmns + FPLMN_LIST = (); + + # List of Equivalent HPLMNs +#TODO: UE does not connect if set, to be fixed in the UE +# EHPLMN_LIST= ("20811", "20813"); + EHPLMN_LIST= (); +}; + +UE14: +{ + USER: { + IMEI="356113022094114"; + MANUFACTURER="EURECOM"; + MODEL="LTE Android PC"; + PIN="0000"; + }; + + SIM: { + MSIN="100000086"; + USIM_API_K="0c0a34601d4f07677303652c0462535b"; + OPC="ba05688178e398bedc100674071002cb"; + MSISDN="1011234561085"; + }; + + # Home PLMN Selector with Access Technology + HPLMN= "320230"; + + # User controlled PLMN Selector with Access Technology + UCPLMN_LIST = (); + + # Operator PLMN List + OPLMN_LIST = ("00101", "20810", "20811", "20813", "20895", "310280", "310028", "320230"); + + # Operator controlled PLMN Selector with Access Technology + OCPLMN_LIST = ("22210", "21401", "21406", "26202", "26204"); + + # Forbidden plmns + FPLMN_LIST = (); + + # List of Equivalent HPLMNs +#TODO: UE does not connect if set, to be fixed in the UE +# EHPLMN_LIST= ("20811", "20813"); + EHPLMN_LIST= (); +}; + +UE15: +{ + USER: { + IMEI="356113022094115"; + MANUFACTURER="EURECOM"; + MODEL="LTE Android PC"; + PIN="0000"; + }; + + SIM: { + MSIN="100000026"; + USIM_API_K="0c0a34601d4f07677303652c0462535b"; + OPC="ba05688178e398bedc100674071002cb"; + MSISDN="1011234561025"; + }; + + # Home PLMN Selector with Access Technology + HPLMN= "320230"; + + # User controlled PLMN Selector with Access Technology + UCPLMN_LIST = (); + + # Operator PLMN List + OPLMN_LIST = ("00101", "20810", "20811", "20813", "20895", "310280", "310028", "320230"); + + # Operator controlled PLMN Selector with Access Technology + OCPLMN_LIST = ("22210", "21401", "21406", "26202", "26204"); + + # Forbidden plmns + FPLMN_LIST = (); + + # List of Equivalent HPLMNs +#TODO: UE does not connect if set, to be fixed in the UE +# EHPLMN_LIST= ("20811", "20813"); + EHPLMN_LIST= (); +}; + +UE16: +{ + USER: { + IMEI="356113022094116"; + MANUFACTURER="EURECOM"; + MODEL="LTE Android PC"; + PIN="0000"; + }; + + SIM: { + MSIN="100000114"; + USIM_API_K="0c0a34601d4f07677303652c0462535b"; + OPC="ba05688178e398bedc100674071002cb"; + MSISDN="1011234561113"; + }; + + # Home PLMN Selector with Access Technology + HPLMN= "320230"; + + # User controlled PLMN Selector with Access Technology + UCPLMN_LIST = (); + + # Operator PLMN List + OPLMN_LIST = ("00101", "20810", "20811", "20813", "20895", "310280", "310028", "320230"); + + # Operator controlled PLMN Selector with Access Technology + OCPLMN_LIST = ("22210", "21401", "21406", "26202", "26204"); + + # Forbidden plmns + FPLMN_LIST = (); + + # List of Equivalent HPLMNs +#TODO: UE does not connect if set, to be fixed in the UE +# EHPLMN_LIST= ("20811", "20813"); + EHPLMN_LIST= (); +}; + +UE17: +{ + USER: { + IMEI="356113022094117"; + MANUFACTURER="EURECOM"; + MODEL="LTE Android PC"; + PIN="0000"; + }; + + SIM: { + MSIN="100000159"; + USIM_API_K="0c0a34601d4f07677303652c0462535b"; + OPC="ba05688178e398bedc100674071002cb"; + MSISDN="1011234561158"; + }; + + # Home PLMN Selector with Access Technology + HPLMN= "320230"; + + # User controlled PLMN Selector with Access Technology + UCPLMN_LIST = (); + + # Operator PLMN List + OPLMN_LIST = ("00101", "20810", "20811", "20813", "20895", "310280", "310028", "320230"); + + # Operator controlled PLMN Selector with Access Technology + OCPLMN_LIST = ("22210", "21401", "21406", "26202", "26204"); + + # Forbidden plmns + FPLMN_LIST = (); + + # List of Equivalent HPLMNs +#TODO: UE does not connect if set, to be fixed in the UE +# EHPLMN_LIST= ("20811", "20813"); + EHPLMN_LIST= (); +}; + +UE18: +{ + USER: { + IMEI="356113022094118"; + MANUFACTURER="EURECOM"; + MODEL="LTE Android PC"; + PIN="0000"; + }; + + SIM: { + MSIN="100000113"; + USIM_API_K="0c0a34601d4f07677303652c0462535b"; + OPC="ba05688178e398bedc100674071002cb"; + MSISDN="1011234561112"; + }; + + # Home PLMN Selector with Access Technology + HPLMN= "320230"; + + # User controlled PLMN Selector with Access Technology + UCPLMN_LIST = (); + + # Operator PLMN List + OPLMN_LIST = ("00101", "20810", "20811", "20813", "20895", "310280", "310028", "320230"); + + # Operator controlled PLMN Selector with Access Technology + OCPLMN_LIST = ("22210", "21401", "21406", "26202", "26204"); + + # Forbidden plmns + FPLMN_LIST = (); + + # List of Equivalent HPLMNs +#TODO: UE does not connect if set, to be fixed in the UE +# EHPLMN_LIST= ("20811", "20813"); + EHPLMN_LIST= (); +}; \ No newline at end of file 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 new file mode 100644 index 0000000000000000000000000000000000000000..c0d4c6d4c95aa128ab45389e2f55fe021ff4ef30 --- /dev/null +++ b/ci-scripts/conf_files/episci/proxy_gnb.band78.sa.fr1.106PRB.usrpn310.conf @@ -0,0 +1,326 @@ +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; + sd = 0x1; // 0 false, else true + }, + { + sst = 1; + sd = 0x112233; // 0 false, else true + } + ); + + }); + + nr_cellid = 12345678L; + + ////////// Physical parameters: + + ssb_SubcarrierOffset = 0; + pdsch_AntennaPorts = 1; + pusch_AntennaPorts = 1; + ul_prbblacklist = "51,52,53,54" + min_rxtxtime = 6; + + pdcch_ConfigSIB1 = ( + { + controlResourceSetZero = 12; + searchSpaceZero = 0; + } + ); + + servingCellConfigCommon = ( + { + #spCellConfigCommon + + physCellId = 0; + +# downlinkConfigCommon + #frequencyInfoDL + # this is 3600 MHz + 43 PRBs@30kHz SCS (same as initial BWP) + absoluteFrequencySSB = 641280; + dl_frequencyBand = 78; + # this is 3600 MHz + dl_absoluteFrequencyPointA = 640008; + #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=27,L=48 (275*(L-1))+RBstart + initialDLBWPlocationAndBandwidth = 12952; # 6366 12925 12956 28875 12952 +# subcarrierSpacing +# 0=kHz15, 1=kHz30, 2=kHz60, 3=kHz120 + initialDLBWPsubcarrierSpacing = 1; + #pdcch-ConfigCommon + initialDLBWPcontrolResourceSetZero = 12; + initialDLBWPsearchSpaceZero = 0; + #pdsch-ConfigCommon + #pdschTimeDomainAllocationList (up to 16 entries) + initialDLBWPk0_0 = 0; #for DL slot + initialDLBWPmappingType_0 = 0; #0=typeA,1=typeB + initialDLBWPstartSymbolAndLength_0 = 40; #this is SS=1,L=13 + + initialDLBWPk0_1 = 0; #for mixed slot + initialDLBWPmappingType_1 = 0; + initialDLBWPstartSymbolAndLength_1 = 57; #this is SS=1,L=5 + + #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 = 12952; +# 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 = -96; +#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 = 14; +#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; # used for UL slot + initialULBWPmappingType_0 = 1 + initialULBWPstartSymbolAndLength_0 = 41; # this is SS=0 L=13 + + initialULBWPk2_1 = 6; # used for mixed slot + initialULBWPmappingType_1 = 1; + initialULBWPstartSymbolAndLength_1 = 52; # this is SS=10 L=4 + + initialULBWPk2_2 = 7; # used for Msg.3 during RA + initialULBWPmappingType_2 = 1; + initialULBWPstartSymbolAndLength_2 = 52; # this is SS=10 L=4 + + 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.61.195"; + ipv6 = "192:168:30::17"; + active = "yes"; + preference = "ipv4"; + } + ); + + + NETWORK_INTERFACES : + { + GNB_INTERFACE_NAME_FOR_NG_AMF = "lo:"; + GNB_IPV4_ADDRESS_FOR_NG_AMF = "127.0.0.2"; + GNB_INTERFACE_NAME_FOR_NGU = "lo:"; + GNB_IPV4_ADDRESS_FOR_NGU = "127.0.0.2"; + GNB_PORT_FOR_NGU = 2152; # Spec 2152 + }; + + } +); + +MACRLCs = ( + { + num_cc = 1; + local_s_if_name = "lo:"; + remote_s_address = "127.0.0.1"; // pnf addr [!] + local_s_address = "127.0.0.2"; // vnf addr + local_s_portc = 50601; // vnf p5 port + remote_s_portc = 50600; // pnf p5 port [!] + local_s_portd = 50611; // vnf p7 port [!] + remote_s_portd = 50610; // pnf p7 port [!] + tr_s_preference = "nfapi"; + tr_n_preference = "local_RRC"; + } +); + +L1s = ( +{ + num_cc = 1; + tr_n_preference = "local_mac"; + thread_pool_size = 8; + prach_dtx_threshold = 120; + pucch0_dtx_threshold = 150; +} +); + +RUs = ( + { + local_rf = "yes" + nb_tx = 1 + nb_rx = 1 + att_tx = 0 + att_rx = 0; + bands = [78]; + max_pdschReferenceSignalPower = -27; + max_rxgain = 75; + eNB_instances = [0]; + #beamforming 1x4 matrix: + bf_weights = [0x00007fff, 0x0000, 0x0000, 0x0000]; + #clock_src = "external"; + sdr_addrs = "mgmt_addr=192.168.18.240,addr=192.168.10.2,second_addr=192.168.20.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"; + 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"; + ngap_log_level ="debug"; + ngap_log_verbosity ="medium"; + }; + diff --git a/ci-scripts/conf_files/episci/proxy_nr-ue.nfapi.conf b/ci-scripts/conf_files/episci/proxy_nr-ue.nfapi.conf new file mode 100644 index 0000000000000000000000000000000000000000..8411ed8fc6d0a2552e109ccfa3040a1a8b523803 --- /dev/null +++ b/ci-scripts/conf_files/episci/proxy_nr-ue.nfapi.conf @@ -0,0 +1,52 @@ +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 ="medium"; + rlc_log_level ="info"; + rlc_log_verbosity ="medium"; + pdcp_log_level ="info"; + pdcp_log_verbosity ="medium"; + rrc_log_level ="info"; + rrc_log_verbosity ="full"; +}; + +uicc0 = { +imsi = "2089900007487"; +key = "fec86ba6eb707ed08905757b1bb44b8f"; +opc= "C42449363BBAD02B66D16BC975D77CC1"; +dnn= "oai"; +nssai_sst=1; +nssai_sd=1; +} + +L1s = ( + { + num_cc = 1; + tr_n_preference = "nfapi"; + local_n_if_name = "lo:"; + remote_n_address = "127.0.0.1"; //Proxy IP + local_n_address = "127.0.0.1"; + local_n_portc = 50600; + remote_n_portc = 50601; + local_n_portd = 50610; + remote_n_portd = 50611; + } +); + +RUs = ( + { + local_rf = "yes" + nb_tx = 1 + nb_rx = 1 + att_tx = 90 + att_rx = 0; + bands = [7,38,42,43]; + max_pdschReferenceSignalPower = -27; + max_rxgain = 125; + } +); diff --git a/ci-scripts/conf_files/episci/proxy_rcc.band7.tm1.nfapi.conf b/ci-scripts/conf_files/episci/proxy_rcc.band7.tm1.nfapi.conf new file mode 100644 index 0000000000000000000000000000000000000000..d4c72d6c1411433ac8fca598def78739009e1236 --- /dev/null +++ b/ci-scripts/conf_files/episci/proxy_rcc.band7.tm1.nfapi.conf @@ -0,0 +1,247 @@ +Active_eNBs = ( "eNB-Eurecom-LTEBox"); +# Asn1_verbosity, choice in: none, info, annoying +Asn1_verbosity = "none"; + +eNBs = +( + { + ////////// Identification parameters: + eNB_ID = 0xe00; + + cell_type = "CELL_MACRO_ENB"; + + eNB_name = "eNB-Eurecom-LTEBox"; + + // Tracking area code, 0x0000 and 0xfffe are reserved values + tracking_area_code = 5; + + plmn_list = ( { mcc = 320; mnc = 230; mnc_length = 3; } ); + + tr_s_preference = "local_mac" + + ////////// Physical parameters: + + component_carriers = ( + { + node_function = "3GPP_eNODEB"; + node_timing = "synch_to_ext_device"; + node_synch_ref = 0; + frame_type = "FDD"; + tdd_config = 3; + tdd_config_s = 0; + prefix_type = "NORMAL"; + eutra_band = 7; + downlink_frequency = 2685000000L; + uplink_frequency_offset = -120000000; + Nid_cell = 0; + N_RB_DL = 50; + Nid_cell_mbsfn = 0; + nb_antenna_ports = 1; + nb_antennas_tx = 1; + nb_antennas_rx = 1; + tx_gain = 90; + rx_gain = 125; + pbch_repetition = "FALSE"; + prach_root = 0; + prach_config_index = 0; + prach_high_speed = "DISABLE"; + prach_zero_correlation = 1; + prach_freq_offset = 2; + pucch_delta_shift = 1; + pucch_nRB_CQI = 0; + pucch_nCS_AN = 0; + pucch_n1_AN = 0; + pdsch_referenceSignalPower = -27; + pdsch_p_b = 0; + pusch_n_SB = 1; + pusch_enable64QAM = "DISABLE"; + pusch_hoppingMode = "interSubFrame"; + pusch_hoppingOffset = 0; + pusch_groupHoppingEnabled = "ENABLE"; + pusch_groupAssignment = 0; + pusch_sequenceHoppingEnabled = "DISABLE"; + pusch_nDMRS1 = 1; + phich_duration = "NORMAL"; + phich_resource = "ONESIXTH"; + srs_enable = "DISABLE"; + /* srs_BandwidthConfig =; + srs_SubframeConfig =; + srs_ackNackST =; + srs_MaxUpPts =;*/ + + pusch_p0_Nominal = -96; + pusch_alpha = "AL1"; + pucch_p0_Nominal = -104; + msg3_delta_Preamble = 6; + pucch_deltaF_Format1 = "deltaF2"; + pucch_deltaF_Format1b = "deltaF3"; + pucch_deltaF_Format2 = "deltaF0"; + pucch_deltaF_Format2a = "deltaF0"; + pucch_deltaF_Format2b = "deltaF0"; + + rach_numberOfRA_Preambles = 64; + rach_preamblesGroupAConfig = "DISABLE"; + /* + rach_sizeOfRA_PreamblesGroupA = ; + rach_messageSizeGroupA = ; + rach_messagePowerOffsetGroupB = ; + */ + rach_powerRampingStep = 4; + rach_preambleInitialReceivedTargetPower = -108; + rach_preambleTransMax = 10; + rach_raResponseWindowSize = 10; + rach_macContentionResolutionTimer = 48; + rach_maxHARQ_Msg3Tx = 4; + + pcch_default_PagingCycle = 128; + pcch_nB = "oneT"; + bcch_modificationPeriodCoeff = 2; + ue_TimersAndConstants_t300 = 1000; + ue_TimersAndConstants_t301 = 1000; + ue_TimersAndConstants_t310 = 1000; + ue_TimersAndConstants_t311 = 10000; + ue_TimersAndConstants_n310 = 20; + ue_TimersAndConstants_n311 = 1; + ue_TransmissionMode = 1; + + //Parameters for SIB18 + rxPool_sc_CP_Len = "normal"; + rxPool_sc_Period = "sf40"; + rxPool_data_CP_Len = "normal"; + rxPool_ResourceConfig_prb_Num = 20; + rxPool_ResourceConfig_prb_Start = 5; + rxPool_ResourceConfig_prb_End = 44; + rxPool_ResourceConfig_offsetIndicator_present = "prSmall"; + rxPool_ResourceConfig_offsetIndicator_choice = 0; + rxPool_ResourceConfig_subframeBitmap_present = "prBs40"; + rxPool_ResourceConfig_subframeBitmap_choice_bs_buf = "00000000000000000000"; + rxPool_ResourceConfig_subframeBitmap_choice_bs_size = 5; + rxPool_ResourceConfig_subframeBitmap_choice_bs_bits_unused = 0; +/* rxPool_dataHoppingConfig_hoppingParameter = 0; + rxPool_dataHoppingConfig_numSubbands = "ns1"; + rxPool_dataHoppingConfig_rbOffset = 0; + rxPool_commTxResourceUC-ReqAllowed = "TRUE"; +*/ + // Parameters for SIB19 + discRxPool_cp_Len = "normal" + discRxPool_discPeriod = "rf32" + discRxPool_numRetx = 1; + discRxPool_numRepetition = 2; + discRxPool_ResourceConfig_prb_Num = 5; + discRxPool_ResourceConfig_prb_Start = 3; + discRxPool_ResourceConfig_prb_End = 21; + discRxPool_ResourceConfig_offsetIndicator_present = "prSmall"; + discRxPool_ResourceConfig_offsetIndicator_choice = 0; + discRxPool_ResourceConfig_subframeBitmap_present = "prBs40"; + discRxPool_ResourceConfig_subframeBitmap_choice_bs_buf = "f0ffffffff"; + discRxPool_ResourceConfig_subframeBitmap_choice_bs_size = 5; + discRxPool_ResourceConfig_subframeBitmap_choice_bs_bits_unused = 0; + + } + ); + + + srb1_parameters : + { + # timer_poll_retransmit = (ms) [5, 10, 15, 20,... 250, 300, 350, ... 500] + timer_poll_retransmit = 80; + + # timer_reordering = (ms) [0,5, ... 100, 110, 120, ... ,200] + timer_reordering = 35; + + # timer_reordering = (ms) [0,5, ... 250, 300, 350, ... ,500] + timer_status_prohibit = 0; + + # poll_pdu = [4, 8, 16, 32 , 64, 128, 256, infinity(>10000)] + poll_pdu = 4; + + # poll_byte = (kB) [25,50,75,100,125,250,375,500,750,1000,1250,1500,2000,3000,infinity(>10000)] + poll_byte = 99999; + + # max_retx_threshold = [1, 2, 3, 4 , 6, 8, 16, 32] + max_retx_threshold = 4; + } + + # ------- 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.61.3"; + ipv6 = "192:168:30::17"; + port = 36412 ; + active = "yes"; + preference = "ipv4"; + } + ); + + enable_measurement_reports = "no"; + + ///X2 + enable_x2 = "yes"; + t_reloc_prep = 1000; /* unit: millisecond */ + tx2_reloc_overall = 2000; /* unit: millisecond */ + t_dc_prep = 1000; /* unit: millisecond */ + t_dc_overall = 2000; /* unit: millisecond */ + + NETWORK_INTERFACES : + { + ENB_INTERFACE_NAME_FOR_S1_MME = "lo"; + ENB_IPV4_ADDRESS_FOR_S1_MME = "127.0.0.1"; + ENB_INTERFACE_NAME_FOR_S1U = "lo"; + ENB_IPV4_ADDRESS_FOR_S1U = "127.0.0.1"; + ENB_PORT_FOR_S1U = 2152; # Spec 2152 + ENB_IPV4_ADDRESS_FOR_X2C = "127.0.0.1"; + ENB_PORT_FOR_X2C = 36422; # Spec 36422 + + }; + } +); + +MACRLCs = ( + { + num_cc = 1; + local_s_if_name = "lo"; + remote_s_address = "127.0.0.1"; + local_s_address = "127.0.0.1"; + local_s_portc = 50001; + remote_s_portc = 50000; + local_s_portd = 50011; + remote_s_portd = 50010; + tr_s_preference = "nfapi"; + tr_n_preference = "local_RRC"; + scheduler_mode = "fairRR"; + } +); + +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"; + } +); + +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"; + }; diff --git a/ci-scripts/conf_files/episci/proxy_rcc.band78.tm1.106PRB.nfapi.conf b/ci-scripts/conf_files/episci/proxy_rcc.band78.tm1.106PRB.nfapi.conf new file mode 100644 index 0000000000000000000000000000000000000000..0ef317d63e8c5d13c0c5d607582d442ddbaa3fda --- /dev/null +++ b/ci-scripts/conf_files/episci/proxy_rcc.band78.tm1.106PRB.nfapi.conf @@ -0,0 +1,305 @@ +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 = 5; + + plmn_list = ({mcc = 320; mnc = 230; mnc_length = 3;}); + + tr_s_preference = "local_mac" + + ////////// Physical parameters: + + ssb_SubcarrierOffset = 0; + pdsch_AntennaPorts = 1; + + servingCellConfigCommon = ( + { + #spCellConfigCommon + + physCellId = 0; + +# downlinkConfigCommon + #frequencyInfoDL + # this is 3600 MHz + 43 PRBs@30kHz SCS (same as initial BWP) + absoluteFrequencySSB = 641032; + dl_frequencyBand = 78; + # this is 3600 MHz + dl_absoluteFrequencyPointA = 640000; + #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=41,L=24 (275*(L-1))+RBstart + initialDLBWPlocationAndBandwidth = 6366; +# subcarrierSpacing +# 0=kHz15, 1=kHz30, 2=kHz60, 3=kHz120 + initialDLBWPsubcarrierSpacing = 1; + #pdcch-ConfigCommon + initialDLBWPcontrolResourceSetZero = 12; + 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=2,L=12 + initialDLBWPstartSymbolAndLength_1 = 53; + + initialDLBWPk0_2 = 0; + initialDLBWPmappingType_2 = 0; + #this is SS=1,L=12 + initialDLBWPstartSymbolAndLength_2 = 54; + + initialDLBWPk0_3 = 0; + initialDLBWPmappingType_3 = 0; + #this is SS=1,L=5 + initialDLBWPstartSymbolAndLength_3 = 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 = 6366; +# 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, + + # pusch-ConfigCommon (up to 16 elements) + initialULBWPk2_0 = 6; + initialULBWPmappingType_0 = 1 + # this is SS=0 L=11 + initialULBWPstartSymbolAndLength_0 = 55; + + initialULBWPk2_1 = 6; + initialULBWPmappingType_1 = 1; + # this is SS=0 L=12 + initialULBWPstartSymbolAndLength_1 = 69; + + 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 = 10; + } + + + ); + + + + srb1_parameters : + { + # timer_poll_retransmit = (ms) [5, 10, 15, 20,... 250, 300, 350, ... 500] + timer_poll_retransmit = 80; + + # timer_reordering = (ms) [0,5, ... 100, 110, 120, ... ,200] + timer_reordering = 35; + + # timer_reordering = (ms) [0,5, ... 250, 300, 350, ... ,500] + timer_status_prohibit = 0; + + # poll_pdu = [4, 8, 16, 32 , 64, 128, 256, infinity(>10000)] + poll_pdu = 4; + + # poll_byte = (kB) [25,50,75,100,125,250,375,500,750,1000,1250,1500,2000,3000,infinity(>10000)] + poll_byte = 99999; + + # max_retx_threshold = [1, 2, 3, 4 , 6, 8, 16, 32] + max_retx_threshold = 4; + } + + # ------- 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.61.3"; + ipv6 = "192:168:30::17"; + active = "yes"; + preference = "ipv4"; + } + ); + ///X2 + enable_x2 = "yes"; + t_reloc_prep = 1000; /* unit: millisecond */ + tx2_reloc_overall = 2000; /* unit: millisecond */ + t_dc_prep = 1000; /* unit: millisecond */ + t_dc_overall = 2000; /* unit: millisecond */ + target_enb_x2_ip_address = ( + { ipv4 = "127.0.0.1"; # rrc.band7.tm1.nfapi.conf:line 201 + ipv6 = "192:168:30::17"; + preference = "ipv4"; + } + ); + + NETWORK_INTERFACES : + { # All of these have to be IP addr of gNB + # if in CORE container, make it 172.16.0.X + # if not launched in CORE, can set to lo (127.0.0.2) + GNB_INTERFACE_NAME_FOR_S1_MME = "lo:"; + GNB_IPV4_ADDRESS_FOR_S1_MME = "127.0.0.2"; + GNB_INTERFACE_NAME_FOR_S1U = "lo:"; + GNB_IPV4_ADDRESS_FOR_S1U = "127.0.0.2"; + GNB_PORT_FOR_S1U = 2152; # Spec 2152 + GNB_IPV4_ADDRESS_FOR_X2C = "127.0.0.2"; + GNB_PORT_FOR_X2C = 36422; # Spec 36422 + }; + } +); + + +MACRLCs = ( + { + num_cc = 1; + local_s_if_name = "lo:"; + remote_s_address = "127.0.0.1"; // pnf addr [!] + local_s_address = "127.0.0.2"; // vnf addr + local_s_portc = 50601; // vnf p5 port + remote_s_portc = 50600; // pnf p5 port [!] + local_s_portd = 50611; // vnf p7 port [!] + remote_s_portd = 50610; // pnf p7 port [!] + tr_s_preference = "nfapi"; + tr_n_preference = "local_RRC"; + } +) + + +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"; + } +); + +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"; + }; + diff --git a/ci-scripts/conf_files/episci/proxy_ue.nfapi.conf b/ci-scripts/conf_files/episci/proxy_ue.nfapi.conf new file mode 100644 index 0000000000000000000000000000000000000000..3f227d573ce08d877303567177ace3a1fb3611b0 --- /dev/null +++ b/ci-scripts/conf_files/episci/proxy_ue.nfapi.conf @@ -0,0 +1,44 @@ +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 ="medium"; + rlc_log_level ="info"; + rlc_log_verbosity ="medium"; + pdcp_log_level ="info"; + pdcp_log_verbosity ="medium"; + rrc_log_level ="info"; + rrc_log_verbosity ="full"; +}; + + +L1s = ( + { + num_cc = 1; + tr_n_preference = "nfapi"; + local_n_if_name = "lo"; + remote_n_address = "127.0.0.1"; + local_n_address = "127.0.0.1"; + local_n_portc = 50000; + remote_n_portc = 50001; + local_n_portd = 50010; + remote_n_portd = 50011; + } +); + +RUs = ( + { + local_rf = "yes" + nb_tx = 1 + nb_rx = 1 + att_tx = 90 + att_rx = 0; + bands = [7,38,42,43]; + max_pdschReferenceSignalPower = -27; + max_rxgain = 125; + } +); diff --git a/ci-scripts/conf_files/gNB_SA_CU.conf b/ci-scripts/conf_files/gNB_SA_CU.conf new file mode 100644 index 0000000000000000000000000000000000000000..d3cfbfc97368a942bc634a824cc593e37784c214 --- /dev/null +++ b/ci-scripts/conf_files/gNB_SA_CU.conf @@ -0,0 +1,275 @@ +Active_gNBs = ( "gNB-Eurecom-CU"); +# Asn1_verbosity, choice in: none, info, annoying +Asn1_verbosity = "none"; +Num_Threads_PUSCH = 8; + +gNBs = +( + { + ////////// Identification parameters: + gNB_CU_ID = 0xe00; + +# cell_type = "CELL_MACRO_GNB"; + + gNB_name = "gNB-Eurecom-CU"; + + // 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 = "f1"; + + local_s_if_name = "lo"; + local_s_address = "127.0.0.4"; + remote_s_address = "127.0.0.3"; + local_s_portc = 501; + local_s_portd = 2152; + remote_s_portc = 500; + remote_s_portd = 2152; + ssb_SubcarrierOffset = 0; + pdsch_AntennaPorts = 1; + pusch_AntennaPorts = 1; + min_rxtxtime = 6; + sib1_tda = 0; + + pdcch_ConfigSIB1 = ( + { + controlResourceSetZero = 12; + searchSpaceZero = 0; + } + ); + + servingCellConfigCommon = ( + { + #spCellConfigCommon + + physCellId = 0; + +# downlinkConfigCommon + #frequencyInfoDL + # this is 3600 MHz + 43 PRBs@30kHz SCS (same as initial BWP) + absoluteFrequencySSB = 641280; + dl_frequencyBand = 78; + # this is 3600 MHz + dl_absoluteFrequencyPointA = 640008; + #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=27,L=48 (275*(L-1))+RBstart + initialDLBWPlocationAndBandwidth = 28875; # 6366 12925 12956 28875 12952 +# subcarrierSpacing +# 0=kHz15, 1=kHz30, 2=kHz60, 3=kHz120 + initialDLBWPsubcarrierSpacing = 1; + #pdcch-ConfigCommon + initialDLBWPcontrolResourceSetZero = 12; + initialDLBWPsearchSpaceZero = 0; + #pdsch-ConfigCommon + #pdschTimeDomainAllocationList (up to 16 entries) + initialDLBWPk0_0 = 0; #for DL slot + initialDLBWPmappingType_0 = 0; #0=typeA,1=typeB + initialDLBWPstartSymbolAndLength_0 = 40; #this is SS=1,L=13 + + initialDLBWPk0_1 = 0; #for mixed slot + initialDLBWPmappingType_1 = 0; + initialDLBWPstartSymbolAndLength_1 = 57; #this is SS=1,L=5 + + #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 = 13; + preambleReceivedTargetPower = -96; +#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 = 14; +#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; # used for UL slot + initialULBWPmappingType_0 = 1 + initialULBWPstartSymbolAndLength_0 = 41; # this is SS=0 L=13 + + initialULBWPk2_1 = 6; # used for mixed slot + initialULBWPmappingType_1 = 1; + initialULBWPstartSymbolAndLength_1 = 52; # this is SS=10 L=4 + + initialULBWPk2_2 = 7; # used for Msg.3 during RA + initialULBWPmappingType_2 = 1; + initialULBWPstartSymbolAndLength_2 = 52; # this is SS=10 L=4 + + 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.5.233"; + ipv6 = "192:168:30::17"; + active = "yes"; + preference = "ipv4"; + } + ); + + NETWORK_INTERFACES : + { + + GNB_INTERFACE_NAME_FOR_NG_AMF = "eth0"; + GNB_IPV4_ADDRESS_FOR_NG_AMF = "CI_GNB_IP_ADDR"; + GNB_INTERFACE_NAME_FOR_NGU = "eth0"; + GNB_IPV4_ADDRESS_FOR_NGU = "CI_GNB_IP_ADDR"; + GNB_PORT_FOR_S1U = 2152; # Spec 2152 + }; + } +); + +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 ="debug"; + 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"; + ngap_log_level ="debug"; + ngap_log_verbosity ="medium"; + }; + diff --git a/ci-scripts/conf_files/gNB_SA_DU.conf b/ci-scripts/conf_files/gNB_SA_DU.conf new file mode 100644 index 0000000000000000000000000000000000000000..adcbcd45d0ce1fd0a75420a2d60ea8c7f92ac785 --- /dev/null +++ b/ci-scripts/conf_files/gNB_SA_DU.conf @@ -0,0 +1,294 @@ +Active_gNBs = ( "gNB-Eurecom-DU"); +# 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-Eurecom-DU"; + + // 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; + + ////////// Physical parameters: + + ssb_SubcarrierOffset = 0; + pdsch_AntennaPorts = 1; + pusch_AntennaPorts = 1; + min_rxtxtime = 6; + sib1_tda = 0; + + pdcch_ConfigSIB1 = ( + { + controlResourceSetZero = 12; + searchSpaceZero = 0; + } + ); + + servingCellConfigCommon = ( + { + #spCellConfigCommon + + physCellId = 0; + +# downlinkConfigCommon + #frequencyInfoDL + # this is 3600 MHz + 43 PRBs@30kHz SCS (same as initial BWP) + absoluteFrequencySSB = 641280; + dl_frequencyBand = 78; + # this is 3600 MHz + dl_absoluteFrequencyPointA = 640008; + #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=27,L=48 (275*(L-1))+RBstart + initialDLBWPlocationAndBandwidth = 28875; # 6366 12925 12956 28875 12952 +# subcarrierSpacing +# 0=kHz15, 1=kHz30, 2=kHz60, 3=kHz120 + initialDLBWPsubcarrierSpacing = 1; + #pdcch-ConfigCommon + initialDLBWPcontrolResourceSetZero = 12; + initialDLBWPsearchSpaceZero = 0; + #pdsch-ConfigCommon + #pdschTimeDomainAllocationList (up to 16 entries) + initialDLBWPk0_0 = 0; #for DL slot + initialDLBWPmappingType_0 = 0; #0=typeA,1=typeB + initialDLBWPstartSymbolAndLength_0 = 40; #this is SS=1,L=13 + + initialDLBWPk0_1 = 0; #for mixed slot + initialDLBWPmappingType_1 = 0; + initialDLBWPstartSymbolAndLength_1 = 57; #this is SS=1,L=5 + + #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 = 13; + preambleReceivedTargetPower = -96; +#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 = 14; +#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; # used for UL slot + initialULBWPmappingType_0 = 1 + initialULBWPstartSymbolAndLength_0 = 41; # this is SS=0 L=13 + + initialULBWPk2_1 = 6; # used for mixed slot + initialULBWPmappingType_1 = 1; + initialULBWPstartSymbolAndLength_1 = 52; # this is SS=10 L=4 + + initialULBWPk2_2 = 7; # used for Msg.3 during RA + initialULBWPmappingType_2 = 1; + initialULBWPstartSymbolAndLength_2 = 52; # this is SS=10 L=4 + + 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; + }; + } +); + +MACRLCs = ( + { + num_cc = 1; + tr_s_preference = "local_L1"; + tr_n_preference = "f1"; + local_n_if_name = "lo"; + local_n_address = "127.0.0.3"; + remote_n_address = "127.0.0.4"; + local_n_portc = 500; + local_n_portd = 2152; + remote_n_portc = 501; + remote_n_portd = 2152; + + } +); + +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 +} +); + +RUs = ( + { + local_rf = "yes" + nb_tx = 1 + nb_rx = 1 + att_tx = 0 + att_rx = 0; + bands = [78]; + max_pdschReferenceSignalPower = -27; + max_rxgain = 114; + eNB_instances = [0]; + #beamforming 1x4 matrix: + bf_weights = [0x00007fff, 0x0000, 0x0000, 0x0000]; + clock_src = "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" +} + + 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 ="debug"; + 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"; + ngap_log_level ="debug"; + ngap_log_verbosity ="medium"; + }; + 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 9bf313669046d84af390cb961f2508fd9c5b9379..e3bdde8469350298c09e416bc32316a0990176cb 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 @@ -89,19 +89,6 @@ gNBs = #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 @@ -156,22 +143,6 @@ gNBs = # 0=unrestricted, 1=restricted type A, 2=restricted type B restrictedSetConfig = 0, - # pusch-ConfigCommon (up to 16 elements) - initialULBWPk2_0 = 2; - initialULBWPmappingType_0 = 1 - # this is SS=2 L=13 - initialULBWPstartSymbolAndLength_0 = 41; - - initialULBWPk2_1 = 2; - 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; @@ -258,13 +229,13 @@ MACRLCs = ( ); L1s = ( - { - num_cc = 1; - tr_n_preference = "local_mac"; - pusch_proc_threads = 2; - prach_dtx_threshold = 120; - pucch0_dtx_threshold = 150; - } +{ + num_cc = 1; + tr_n_preference = "local_mac"; + thread_pool_size = 8; + prach_dtx_threshold = 120; + pucch0_dtx_threshold = 150; +} ); RUs = ( 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 dfbbdf659dd71442f285c0ef0554bf210a62e7c6..3955b1542ecf28e6f708754fab817900ad49b784 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 @@ -86,19 +86,6 @@ gNBs = #pdcch-ConfigCommon initialDLBWPcontrolResourceSetZero = 10; 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 @@ -153,22 +140,6 @@ gNBs = # 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; @@ -255,12 +226,12 @@ MACRLCs = ( ); L1s = ( - { - num_cc = 1; - tr_n_preference = "local_mac"; - pusch_proc_threads = 2; - prach_dtx_threshold = 120; - } +{ + num_cc = 1; + tr_n_preference = "local_mac"; + thread_pool_size = 8; + prach_dtx_threshold = 120; +} ); RUs = ( 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 1c6288240634296fdf3be4915e171931ac5e6b86..dd9c210c0ddc61e105a0c87a9a4659cb961bebfb 100644 --- a/ci-scripts/conf_files/gnb.band261.tm1.32PRB.usrpn300.conf +++ b/ci-scripts/conf_files/gnb.band261.tm1.32PRB.usrpn300.conf @@ -24,6 +24,7 @@ gNBs = ssb_SubcarrierOffset = 0; pdsch_AntennaPorts = 1; pusch_AntennaPorts = 1; + min_rxtxtime = 6; servingCellConfigCommon = ( { @@ -54,15 +55,6 @@ gNBs = #pdcch-ConfigCommon initialDLBWPcontrolResourceSetZero = 12; initialDLBWPsearchSpaceZero = 0; - #pdsch-ConfigCommon - #pdschTimeDomainAllocationList (up to 16 entries) - initialDLBWPk0_0 = 0; #for DL slot - initialDLBWPmappingType_0 = 0; #0=typeA,1=typeB - initialDLBWPstartSymbolAndLength_0 = 40; #this is SS=1,L=13 - - initialDLBWPk0_3 = 0; #for mixed slot - initialDLBWPmappingType_3 = 0; - initialDLBWPstartSymbolAndLength_3 = 57; #this is SS=1,L=5 #uplinkConfigCommon #frequencyInfoUL @@ -117,21 +109,6 @@ gNBs = # 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=0 L=11 - initialULBWPstartSymbolAndLength_0 = 41; - - initialULBWPk2_1 = 6; - initialULBWPmappingType_1 = 1; - # this is SS=0 L=12 - initialULBWPstartSymbolAndLength_1 = 69; - - initialULBWPk2_2 = 14; - initialULBWPmappingType_2 = 1; - # this is SS=10 L=4 - initialULBWPstartSymbolAndLength_2 = 52; msg3_DeltaPreamble = 1; p0_NominalWithGrant =-90; @@ -234,12 +211,12 @@ MACRLCs = ( ); L1s = ( - { +{ num_cc = 1; tr_n_preference = "local_mac"; - pusch_proc_threads = 8; + thread_pool_size = 8; ofdm_offset_divisor = 8; #set this to UINT_MAX for offset 0 - } +} ); RUs = ( 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 850cf9a60ca883ec58fc58cbc6f0971d9ba7846e..2400136f9f93645addf19345da24d54556fa12c1 100644 --- a/ci-scripts/conf_files/gnb.band66.tm1.106PRB.usrpn300.conf +++ b/ci-scripts/conf_files/gnb.band66.tm1.106PRB.usrpn300.conf @@ -24,6 +24,7 @@ gNBs = ssb_SubcarrierOffset = 0; pdsch_AntennaPorts = 1; pusch_AntennaPorts = 1; + min_rxtxtime = 6; servingCellConfigCommon = ( { @@ -54,15 +55,6 @@ gNBs = #pdcch-ConfigCommon initialDLBWPcontrolResourceSetZero = 12; initialDLBWPsearchSpaceZero = 0; - #pdsch-ConfigCommon - #pdschTimeDomainAllocationList (up to 16 entries) - initialDLBWPk0_0 = 0; #for DL slot - initialDLBWPmappingType_0 = 0; #0=typeA,1=typeB - initialDLBWPstartSymbolAndLength_0 = 40; #this is SS=1,L=13 - - initialDLBWPk0_3 = 0; #for mixed slot - initialDLBWPmappingType_3 = 0; - initialDLBWPstartSymbolAndLength_3 = 57; #this is SS=1,L=5 #uplinkConfigCommon #frequencyInfoUL @@ -118,18 +110,6 @@ gNBs = # restrictedSetConfig # 0=unrestricted, 1=restricted type A, 2=restricted type B restrictedSetConfig = 0, - # pusch-ConfigCommon (up to 16 elements) - initialULBWPk2_0 = 6; # used for UL slot - initialULBWPmappingType_0 = 1 - initialULBWPstartSymbolAndLength_0 = 41; # this is SS=0 L=13 - - initialULBWPk2_1 = 6; # used for mixed slot - initialULBWPmappingType_1 = 1; - initialULBWPstartSymbolAndLength_1 = 69; # this is SS=10 L=2 - - initialULBWPk2_2 = 7; # used for Msg.3 during RA - initialULBWPmappingType_2 = 1; - initialULBWPstartSymbolAndLength_2 = 52; # this is SS=10 L=4 msg3_DeltaPreamble = 1; p0_NominalWithGrant =-90; @@ -215,12 +195,12 @@ MACRLCs = ( ); L1s = ( - { +{ num_cc = 1; tr_n_preference = "local_mac"; - pusch_proc_threads = 8; + thread_pool_size = 8; ofdm_offset_divisor = 8; #set this to UINT_MAX for offset 0 - } +} ); RUs = ( 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 c8dc1477b080a89fee03dc2eaa1f586843cbc106..adb79ceb8db7513bd2b5c86506be98431c70e0d1 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 @@ -55,15 +55,6 @@ gNBs = #pdcch-ConfigCommon initialDLBWPcontrolResourceSetZero = 0; initialDLBWPsearchSpaceZero = 0; - #pdsch-ConfigCommon - #pdschTimeDomainAllocationList (up to 16 entries) - initialDLBWPk0_0 = 0; #for DL slot - initialDLBWPmappingType_0 = 0; #0=typeA,1=typeB - initialDLBWPstartSymbolAndLength_0 = 40; #this is SS=1,L=13 - - initialDLBWPk0_1 = 0; #for mixed slot - initialDLBWPmappingType_1 = 0; - initialDLBWPstartSymbolAndLength_1 = 57; #this is SS=1,L=5 #uplinkConfigCommon #frequencyInfoUL @@ -118,18 +109,6 @@ gNBs = # restrictedSetConfig # 0=unrestricted, 1=restricted type A, 2=restricted type B restrictedSetConfig = 0, - # pusch-ConfigCommon (up to 16 elements) - initialULBWPk2_0 = 2; # used for UL slot - initialULBWPmappingType_0 = 1 - initialULBWPstartSymbolAndLength_0 = 41; # this is SS=0 L=13 - - initialULBWPk2_1 = 2; # used for mixed slot - initialULBWPmappingType_1 = 1; - initialULBWPstartSymbolAndLength_1 = 24; # this is SS=10 L=2 - - initialULBWPk2_2 = 7; # used for Msg.3 during RA - initialULBWPmappingType_2 = 1; - initialULBWPstartSymbolAndLength_2 = 52; # this is SS=10 L=4 msg3_DeltaPreamble = 1; p0_NominalWithGrant =-90; @@ -231,12 +210,12 @@ MACRLCs = ( ); L1s = ( - { - num_cc = 1; - tr_n_preference = "local_mac"; - pusch_proc_threads = 8; - prach_dtx_threshold = 120; - } +{ + num_cc = 1; + tr_n_preference = "local_mac"; + thread_pool_size = 8; + prach_dtx_threshold = 120; +} ); RUs = ( 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 0f73f7cd0bc6461afb8d552b3c0ae394ac2ccf82..b71bd3acd9e932a023a31882689f0238c46457e5 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 @@ -41,6 +41,7 @@ gNBs = pdsch_AntennaPorts = 1; pusch_AntennaPorts = 2; ul_prbblacklist = "51,52,53,54" + do_SRS = 1; pdcch_ConfigSIB1 = ( { @@ -90,19 +91,6 @@ gNBs = #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 @@ -157,22 +145,6 @@ gNBs = # 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; @@ -260,13 +232,12 @@ MACRLCs = ( ); L1s = ( - { - num_cc = 1; - tr_n_preference = "local_mac"; - pusch_proc_threads = 4; - prach_dtx_threshold = 120; -# pucch0_dtx_threshold = 150; - } +{ + num_cc = 1; + tr_n_preference = "local_mac"; + prach_dtx_threshold = 120; +# pucch0_dtx_threshold = 150; +} ); RUs = ( 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 a5d35d450e1fc33d7b396d611bde7e950db669f0..32a40fe9516eb60ac3651f4c8428995673fed0c6 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 @@ -6,43 +6,52 @@ gNBs = ( { ////////// Identification parameters: - gNB_ID = 0xe00; + 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 = 97; mnc_length = 2; snssaiList = ( - { - sst = 1; - sd = 0x1; // 0 false, else true - }, - { - sst = 1; - sd = 0x112233; // 0 false, else true - } - ); + { + sst = 1; + sd = 0x010203; // 0 false, else true + }, + { + sst = 1; + sd = 0x112233; // 0 false, else true + } + ); + }); - }); + nr_cellid = 12345678L - nr_cellid = 12345678L; +# tr_s_preference = "local_mac" ////////// Physical parameters: ssb_SubcarrierOffset = 0; pdsch_AntennaPorts = 1; pusch_AntennaPorts = 1; + #pusch_TargetSNRx10 = 200; + #pucch_TargetSNRx10 = 200; ul_prbblacklist = "51,52,53,54" + min_rxtxtime = 6; + do_SRS = 1; - pdcch_ConfigSIB1 = ( + pdcch_ConfigSIB1 = ( { - controlResourceSetZero = 12; + controlResourceSetZero = 11; searchSpaceZero = 0; } - ); + ); servingCellConfigCommon = ( { @@ -52,11 +61,23 @@ gNBs = # downlinkConfigCommon #frequencyInfoDL - # this is 3600 MHz + 43 PRBs@30kHz SCS (same as initial BWP) - absoluteFrequencySSB = 641280; - dl_frequencyBand = 78; - # this is 3600 MHz - dl_absoluteFrequencyPointA = 640008; + # 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 @@ -65,40 +86,33 @@ gNBs = dl_carrierBandwidth = 106; #initialDownlinkBWP #genericParameters - # this is RBstart=27,L=48 (275*(L-1))+RBstart - initialDLBWPlocationAndBandwidth = 12952; # 6366 12925 12956 28875 12952 + # this is RBstart=0,L=106 (275*(L-1))+RBstart + initialDLBWPlocationAndBandwidth = 28875; # subcarrierSpacing # 0=kHz15, 1=kHz30, 2=kHz60, 3=kHz120 - initialDLBWPsubcarrierSpacing = 1; + initialDLBWPsubcarrierSpacing = 1; #pdcch-ConfigCommon - initialDLBWPcontrolResourceSetZero = 12; - initialDLBWPsearchSpaceZero = 0; - #pdsch-ConfigCommon - #pdschTimeDomainAllocationList (up to 16 entries) - initialDLBWPk0_0 = 0; #for DL slot - initialDLBWPmappingType_0 = 0; #0=typeA,1=typeB - initialDLBWPstartSymbolAndLength_0 = 40; #this is SS=1,L=13 - - initialDLBWPk0_1 = 0; #for mixed slot - initialDLBWPmappingType_1 = 0; - initialDLBWPstartSymbolAndLength_1 = 57; #this is SS=1,L=5 + initialDLBWPcontrolResourceSetZero = 11; + initialDLBWPsearchSpaceZero = 0; + + #uplinkConfigCommon #frequencyInfoUL - ul_frequencyBand = 78; + ul_frequencyBand = 78; #scs-SpecificCarrierList - ul_offstToCarrier = 0; + ul_offstToCarrier = 0; # subcarrierSpacing # 0=kHz15, 1=kHz30, 2=kHz60, 3=kHz120 - ul_subcarrierSpacing = 1; - ul_carrierBandwidth = 106; + ul_subcarrierSpacing = 1; + ul_carrierBandwidth = 106; pMax = 20; #initialUplinkBWP #genericParameters - initialULBWPlocationAndBandwidth = 12952; + initialULBWPlocationAndBandwidth = 28875; # subcarrierSpacing # 0=kHz15, 1=kHz30, 2=kHz60, 3=kHz120 - initialULBWPsubcarrierSpacing = 1; + initialULBWPsubcarrierSpacing = 1; #rach-ConfigCommon #rach-ConfigGeneric prach_ConfigurationIndex = 98; @@ -106,8 +120,8 @@ gNBs = #0 = one, 1=two, 2=four, 3=eight prach_msg1_FDM = 0; prach_msg1_FrequencyStart = 0; - zeroCorrelationZoneConfig = 13; - preambleReceivedTargetPower = -96; + zeroCorrelationZoneConfig = 12; + preambleReceivedTargetPower = -104; #preamblTransMax (0...10) = (3,4,5,6,7,8,10,20,50,100,200) preambleTransMax = 6; #powerRampingStep @@ -118,9 +132,9 @@ 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 = 4; + ssb_perRACH_OccasionAndCB_PreamblesPerSSB_PR = 3; #oneHalf (0..15) 4,8,12,16,...60,64 - ssb_perRACH_OccasionAndCB_PreamblesPerSSB = 14; + ssb_perRACH_OccasionAndCB_PreamblesPerSSB = 15; #ra_ContentionResolutionTimer #(0..7) 8,16,24,32,40,48,56,64 ra_ContentionResolutionTimer = 7; @@ -136,19 +150,6 @@ gNBs = # 0=unrestricted, 1=restricted type A, 2=restricted type B restrictedSetConfig = 0, - # pusch-ConfigCommon (up to 16 elements) - initialULBWPk2_0 = 6; # used for UL slot - initialULBWPmappingType_0 = 1 - initialULBWPstartSymbolAndLength_0 = 41; # this is SS=0 L=13 - - initialULBWPk2_1 = 6; # used for mixed slot - initialULBWPmappingType_1 = 1; - initialULBWPstartSymbolAndLength_1 = 52; # this is SS=10 L=4 - - initialULBWPk2_2 = 7; # used for Msg.3 during RA - initialULBWPmappingType_2 = 1; - initialULBWPstartSymbolAndLength_2 = 52; # this is SS=10 L=4 - msg3_DeltaPreamble = 1; p0_NominalWithGrant =-90; @@ -189,7 +190,7 @@ gNBs = nrofUplinkSlots = 2; nrofUplinkSymbols = 4; - ssPBCH_BlockPower = -25; + ssPBCH_BlockPower = -25; } ); @@ -203,46 +204,45 @@ gNBs = SCTP_OUTSTREAMS = 2; }; - ////////// AMF parameters: - amf_ip_address = ( { ipv4 = "CI_MME_IP_ADDR"; - ipv6 = "192:168:30::17"; - active = "yes"; - preference = "ipv4"; - } - ); - - - NETWORK_INTERFACES : - { - GNB_INTERFACE_NAME_FOR_NG_AMF = "eth0"; - GNB_IPV4_ADDRESS_FOR_NG_AMF = "CI_GNB_IP_ADDR"; - GNB_INTERFACE_NAME_FOR_NGU = "eth0"; - GNB_IPV4_ADDRESS_FOR_NGU = "CI_GNB_IP_ADDR"; - GNB_PORT_FOR_NGU = 2152; # Spec 2152 - }; + amf_ip_address = ( { ipv4 = "CI_MME_IP_ADDR"; + ipv6 = "192:168:30::17"; + active = "yes"; + preference = "ipv4"; + } + ); + + NETWORK_INTERFACES : + { + + GNB_INTERFACE_NAME_FOR_NG_AMF = "em1"; + GNB_IPV4_ADDRESS_FOR_NG_AMF = "CI_GNB_IP_ADDR"; + GNB_INTERFACE_NAME_FOR_NGU = "em1"; + GNB_IPV4_ADDRESS_FOR_NGU = "CI_GNB_IP_ADDR"; + 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; - } + { + 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"; - pusch_proc_threads = 8; - prach_dtx_threshold = 120; - pucch0_dtx_threshold = 150; - } +{ + num_cc = 1; + tr_n_preference = "local_mac"; + prach_dtx_threshold = 120; +# pucch0_dtx_threshold = 150; +} ); RUs = ( @@ -256,9 +256,15 @@ RUs = ( max_pdschReferenceSignalPower = -27; max_rxgain = 75; eNB_instances = [0]; - #beamforming 1x4 matrix: - bf_weights = [0x00007fff, 0x0000, 0x0000, 0x0000]; - #clock_src = "external"; + ##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 = "mgmt_addr=192.168.18.240,addr=192.168.10.2,second_addr=192.168.20.2,clock_source=internal,time_source=internal" } ); @@ -272,15 +278,6 @@ THREAD_STRUCT = ( } ); -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 @@ -314,7 +311,6 @@ security = { pdcp_log_verbosity ="medium"; rrc_log_level ="info"; rrc_log_verbosity ="medium"; - ngap_log_level ="debug"; - ngap_log_verbosity ="medium"; + f1ap_log_level ="debug"; + f1ap_log_verbosity ="medium"; }; - 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 new file mode 100644 index 0000000000000000000000000000000000000000..f28c3167b6b6c7fb2b1feeb1ff4375b92163a3ff --- /dev/null +++ b/ci-scripts/conf_files/gnb.band78.sa.fr1.162PRB.2x2.usrpn310.conf @@ -0,0 +1,315 @@ +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 = 97; + 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 = 1; + #pusch_TargetSNRx10 = 200; + #pucch_TargetSNRx10 = 200; + ul_prbblacklist = "51,52,53,54" + 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 = 31889; +# 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 = 31889; +# 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 = "CI_MME_IP_ADDR"; + ipv6 = "192:168:30::17"; + active = "yes"; + preference = "ipv4"; + } + ); + + NETWORK_INTERFACES : + { + + GNB_INTERFACE_NAME_FOR_NG_AMF = "em1"; + GNB_IPV4_ADDRESS_FOR_NG_AMF = "CI_GNB_IP_ADDR"; + GNB_INTERFACE_NAME_FOR_NGU = "em1"; + GNB_IPV4_ADDRESS_FOR_NGU = "CI_GNB_IP_ADDR"; + 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; +# pucch0_dtx_threshold = 150; +} +); + +RUs = ( + { + local_rf = "yes" + nb_tx = 1 + nb_rx = 1 + 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 = "mgmt_addr=192.168.18.240,addr=192.168.10.2,second_addr=192.168.20.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"; + } +); + +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/ci-scripts/conf_files/gnb.band78.tm1.106PRB.usrpn300.conf b/ci-scripts/conf_files/gnb.band78.tm1.106PRB.usrpn300.conf index 4f0f7c6b2e154471f9e9296243ea6335fa20a84b..9cc8f554e812d517316e977f0ee93a97066511f9 100644 --- a/ci-scripts/conf_files/gnb.band78.tm1.106PRB.usrpn300.conf +++ b/ci-scripts/conf_files/gnb.band78.tm1.106PRB.usrpn300.conf @@ -21,9 +21,10 @@ gNBs = ////////// Physical parameters: - ssb_SubcarrierOffset = 0; - pdsch_AntennaPorts = 1; - pusch_AntennaPorts = 1; + ssb_SubcarrierOffset = 0; + pdsch_AntennaPorts = 1; + pusch_AntennaPorts = 1; + min_rxtxtime = 6; servingCellConfigCommon = ( { @@ -54,15 +55,6 @@ gNBs = #pdcch-ConfigCommon initialDLBWPcontrolResourceSetZero = 12; initialDLBWPsearchSpaceZero = 0; - #pdsch-ConfigCommon - #pdschTimeDomainAllocationList (up to 16 entries) - initialDLBWPk0_0 = 0; #for DL slot - initialDLBWPmappingType_0 = 0; #0=typeA,1=typeB - initialDLBWPstartSymbolAndLength_0 = 40; #this is SS=1,L=13 - - initialDLBWPk0_1 = 0; #for mixed slot - initialDLBWPmappingType_1 = 0; - initialDLBWPstartSymbolAndLength_1 = 57; #this is SS=1,L=5 #uplinkConfigCommon #frequencyInfoUL @@ -117,19 +109,6 @@ gNBs = # 0=unrestricted, 1=restricted type A, 2=restricted type B restrictedSetConfig = 0, - # pusch-ConfigCommon (up to 16 elements) - initialULBWPk2_0 = 6; # used for UL slot - initialULBWPmappingType_0 = 1 - initialULBWPstartSymbolAndLength_0 = 41; # this is SS=0 L=13 - - initialULBWPk2_1 = 6; # used for mixed slot - initialULBWPmappingType_1 = 1; - initialULBWPstartSymbolAndLength_1 = 69; # this is SS=10 L=2 - - initialULBWPk2_2 = 7; # used for Msg.3 during RA - initialULBWPmappingType_2 = 1; - initialULBWPstartSymbolAndLength_2 = 52; # this is SS=10 L=4 - msg3_DeltaPreamble = 1; p0_NominalWithGrant =-90; @@ -215,11 +194,11 @@ MACRLCs = ( ); L1s = ( - { - num_cc = 1; - tr_n_preference = "local_mac"; - pusch_proc_threads = 8; - } +{ + num_cc = 1; + tr_n_preference = "local_mac"; + thread_pool_size = 8; +} ); RUs = ( 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 015d9ee0d0ac50f8489940c4851da7ef4a81ac01..249b7e45270bdf61e6ff1b909e1e3806effdd08a 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 @@ -52,15 +52,6 @@ gNBs = #pdcch-ConfigCommon initialDLBWPcontrolResourceSetZero = 0; initialDLBWPsearchSpaceZero = 0; - #pdsch-ConfigCommon - #pdschTimeDomainAllocationList (up to 16 entries) - initialDLBWPk0_0 = 0; #for DL slot - initialDLBWPmappingType_0 = 0; #0=typeA,1=typeB - initialDLBWPstartSymbolAndLength_0 = 40; #this is SS=1,L=13 - - initialDLBWPk0_1 = 0; #for mixed slot - initialDLBWPmappingType_1 = 0; - initialDLBWPstartSymbolAndLength_1 = 57; #this is SS=1,L=5 #uplinkConfigCommon #frequencyInfoUL @@ -115,18 +106,6 @@ gNBs = # restrictedSetConfig # 0=unrestricted, 1=restricted type A, 2=restricted type B restrictedSetConfig = 0, - # pusch-ConfigCommon (up to 16 elements) - initialULBWPk2_0 = 6; # used for UL slot - initialULBWPmappingType_0 = 1 - initialULBWPstartSymbolAndLength_0 = 41; # this is SS=0 L=13 - - initialULBWPk2_1 = 6; # used for mixed slot - initialULBWPmappingType_1 = 1; - initialULBWPstartSymbolAndLength_1 = 52; # this is SS=10 L=4 - - initialULBWPk2_2 = 7; # used for Msg.3 during RA - initialULBWPmappingType_2 = 1; - initialULBWPstartSymbolAndLength_2 = 52; # this is SS=10 L=4 msg3_DeltaPreamble = 1; p0_NominalWithGrant =-90; @@ -231,12 +210,12 @@ MACRLCs = ( ); L1s = ( - { - num_cc = 1; - tr_n_preference = "local_mac"; - pusch_proc_threads = 6; - ofdm_offset_divisor = 8; #set this to UINT_MAX for offset 0 - } +{ + num_cc = 1; + tr_n_preference = "local_mac"; + thread_pool_size = 6; + ofdm_offset_divisor = 8; #set this to UINT_MAX for offset 0 +} ); RUs = ( 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 e6bbbf2d411334d968e97df6ce25bdb85eb5a4ce..f232106d561bb233a9c7be736f7800af1cadd574 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 @@ -23,6 +23,7 @@ gNBs = ssb_SubcarrierOffset = 31; //0; pdsch_AntennaPorts = 1; pusch_AntennaPorts = 1; + min_rxtxtime = 6; servingCellConfigCommon = ( { @@ -53,19 +54,6 @@ gNBs = #pdcch-ConfigCommon initialDLBWPcontrolResourceSetZero = 0; initialDLBWPsearchSpaceZero = 0; - #pdsch-ConfigCommon - #pdschTimeDomainAllocationList (up to 16 entries) - initialDLBWPk0_0 = 0; - #initialULBWPmappingType - #0=typeA,1=typeB - initialDLBWPmappingType_0 = 0;#for DL slot - #this is SS=1,L=13 - initialDLBWPstartSymbolAndLength_0 = 40; - - initialDLBWPk0_1 = 0;#for mixed slot - initialDLBWPmappingType_1 = 0; - #this is SS=1,L=5 - initialDLBWPstartSymbolAndLength_1 = 57; #uplinkConfigCommon #frequencyInfoUL @@ -120,21 +108,6 @@ gNBs = # restrictedSetConfig # 0=unrestricted, 1=restricted type A, 2=restricted type B restrictedSetConfig = 0, - # pusch-ConfigCommon (up to 16 elements) - initialULBWPk2_0 = 2; - initialULBWPmappingType_0 = 1 - # this is SS=0 L=11 - initialULBWPstartSymbolAndLength_0 = 41; - - initialULBWPk2_1 = 2; - initialULBWPmappingType_1 = 1; - # this is SS=0 L=12 - initialULBWPstartSymbolAndLength_1 = 69; - - initialULBWPk2_2 = 7; - initialULBWPmappingType_2 = 1; - # this is SS=10 L=4 - initialULBWPstartSymbolAndLength_2 = 52; msg3_DeltaPreamble = 1; p0_NominalWithGrant =-90; @@ -238,11 +211,11 @@ MACRLCs = ( ); L1s = ( - { +{ num_cc = 1; tr_n_preference = "local_mac"; - pusch_proc_threads = 6; - } + thread_pool_size = 6; +} ); RUs = ( diff --git a/ci-scripts/conf_files/nr-ue.nfapi.conf b/ci-scripts/conf_files/nr-ue.nfapi.conf new file mode 100644 index 0000000000000000000000000000000000000000..b12e0c8d05beee6edaa4de41334f8beace656c19 --- /dev/null +++ b/ci-scripts/conf_files/nr-ue.nfapi.conf @@ -0,0 +1,44 @@ +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 ="medium"; + rlc_log_level ="info"; + rlc_log_verbosity ="medium"; + pdcp_log_level ="info"; + pdcp_log_verbosity ="medium"; + rrc_log_level ="info"; + rrc_log_verbosity ="full"; +}; + + +L1s = ( + { + num_cc = 1; + tr_n_preference = "nfapi"; + local_n_if_name = "ens3"; + remote_n_address = "127.0.0.1"; //Proxy IP + local_n_address = "127.0.0.1"; + local_n_portc = 50600; + remote_n_portc = 50601; + local_n_portd = 50610; + remote_n_portd = 50611; + } +); + +RUs = ( + { + local_rf = "yes" + nb_tx = 1 + nb_rx = 1 + att_tx = 90 + att_rx = 0; + bands = [7,38,42,43]; + max_pdschReferenceSignalPower = -27; + max_rxgain = 125; + } +); diff --git a/ci-scripts/conf_files/ue.sa.conf b/ci-scripts/conf_files/ue.sa.conf new file mode 100644 index 0000000000000000000000000000000000000000..3e6f78f7093cc64100e7c54ff442c13595bfd87d --- /dev/null +++ b/ci-scripts/conf_files/ue.sa.conf @@ -0,0 +1,8 @@ +uicc0 = { + imsi = "208970100001127"; + key = "fec86ba6eb707ed08905757b1bb44b8f"; + opc= "c42449363bbad02b66d16bc975d77cc1"; + dnn= "oai"; + nssai_sst=1; + nssai_sd=66051; +} diff --git a/ci-scripts/constants.py b/ci-scripts/constants.py index bb110bc0e87b149cc999222bfa2d0567b0b305c4..3c056759283a973543e16d61f6a57d984dd2ac8c 100644 --- a/ci-scripts/constants.py +++ b/ci-scripts/constants.py @@ -44,6 +44,7 @@ ENB_PROCESS_ASSERTION = -12 ENB_PROCESS_REALTIME_ISSUE = -13 ENB_PROCESS_NOLOGFILE_TO_ANALYZE = -14 ENB_PROCESS_SLAVE_RRU_NOT_SYNCED = -15 +ENB_REAL_TIME_PROCESSING_ISSUE = -16 HSS_PROCESS_FAILED = -2 HSS_PROCESS_OK = +2 MME_PROCESS_FAILED = -3 diff --git a/ci-scripts/datalog_rt_stats.2x2.yaml b/ci-scripts/datalog_rt_stats.2x2.yaml new file mode 100644 index 0000000000000000000000000000000000000000..9e2b66862d6ab4cd53137c67695fe82fd4771a78 --- /dev/null +++ b/ci-scripts/datalog_rt_stats.2x2.yaml @@ -0,0 +1,35 @@ +#this is a configuration file +#used to build real time processing statistics +#for 5G NR phy test (gNB terminate) +Title : Processing Time (us) +ColNames : + - Metric + - Average + - Max + - Average vs Reference Deviation (Reference Value ; Acceptability Threshold) +Ref : + feprx : 120.0 + feptx_prec : 8.0 + feptx_ofdm : 50.0 + feptx_total : 75.0 + L1 Tx processing thread 0 : 300.0 + L1 Tx processing thread 1 : 300.0 + DLSCH encoding : 230.0 + L1 Rx processing : 175.0 + PUSCH inner-receiver : 100.0 + PUSCH decoding : 180.0 + DL & UL scheduling timing stats : 37.0 + UL Indication : 38.0 +Threshold : + feprx : 1.25 + feptx_prec : 1.25 + feptx_ofdm : 1.25 + feptx_total : 1.25 + L1 Tx processing thread 0 : 1.25 + L1 Tx processing thread 1 : 1.25 + DLSCH encoding : 1.25 + L1 Rx processing : 1.25 + PUSCH inner-receiver : 1.25 + PUSCH decoding : 1.25 + DL & UL scheduling timing stats : 1.25 + UL Indication : 1.25 diff --git a/ci-scripts/datalog_rt_stats.yaml b/ci-scripts/datalog_rt_stats.default.yaml similarity index 97% rename from ci-scripts/datalog_rt_stats.yaml rename to ci-scripts/datalog_rt_stats.default.yaml index 507ea5d182f2f2c849fd8ae497a7ada7cf0c395b..a2d4768752250e35101d020598fd4d0da097e141 100644 --- a/ci-scripts/datalog_rt_stats.yaml +++ b/ci-scripts/datalog_rt_stats.default.yaml @@ -17,7 +17,7 @@ Ref : DLSCH encoding : 230.0 L1 Rx processing : 175.0 PUSCH inner-receiver : 100.0 - PUSCH decoding : 140.0 + PUSCH decoding : 180.0 DL & UL scheduling timing stats : 37.0 UL Indication : 38.0 Threshold : diff --git a/ci-scripts/epc.py b/ci-scripts/epc.py index 0ae636e4f8766e4264459ec20cb612635617ce25..9ed9f06d8e9701e96b64a3343a6f5dde5ccbdd73 100644 --- a/ci-scripts/epc.py +++ b/ci-scripts/epc.py @@ -133,7 +133,7 @@ class EPCManagement(): mySSH.open(self.IPAddress, self.UserName, self.Password) if re.match('OAI-Rel14-Docker', self.Type, re.IGNORECASE): logging.debug('Using the OAI EPC Release 14 MME in Docker') - mySSH.command('docker exec -d ' + self.containerPrefix + '-oai-mme /bin/bash -c "nohup tshark -i eth0 -i lo:s10 -w /tmp/mme_check_run.pcap 2>&1 > /dev/null"', '\$', 5) + mySSH.command('docker exec -d ' + self.containerPrefix + '-oai-mme /bin/bash -c "nohup tshark -i eth0 -i lo:s10 -f "not port 2152" -w /tmp/mme_check_run.pcap 2>&1 > /dev/null"', '\$', 5) time.sleep(5) mySSH.command('docker exec -d ' + self.containerPrefix + '-oai-mme /bin/bash -c "nohup ./bin/oai_mme -c ./etc/' + self.mmeConfFile + ' > mme_check_run.log 2>&1"', '\$', 5) elif re.match('OAI-Rel14-CUPS', self.Type, re.IGNORECASE): @@ -198,8 +198,8 @@ class EPCManagement(): mySSH.open(self.IPAddress, self.UserName, self.Password) if re.match('OAI-Rel14-Docker', self.Type, re.IGNORECASE): logging.debug('Using the OAI EPC Release 14 SPGW-CUPS in Docker') - mySSH.command('docker exec -d ' + self.containerPrefix + '-oai-spgwc /bin/bash -c "nohup tshark -i eth0 -i lo:p5c -i lo:s5c -w /tmp/spgwc_check_run.pcap 2>&1 > /dev/null"', '\$', 5) - mySSH.command('docker exec -d ' + self.containerPrefix + '-oai-spgwu-tiny /bin/bash -c "nohup tshark -i eth0 -w /tmp/spgwu_check_run.pcap 2>&1 > /dev/null"', '\$', 5) + mySSH.command('docker exec -d ' + self.containerPrefix + '-oai-spgwc /bin/bash -c "nohup tshark -i eth0 -i lo:p5c -i lo:s5c -f "not port 2152" -w /tmp/spgwc_check_run.pcap 2>&1 > /dev/null"', '\$', 5) + mySSH.command('docker exec -d ' + self.containerPrefix + '-oai-spgwu-tiny /bin/bash -c "nohup tshark -i eth0 -f "not port 2152" -w /tmp/spgwu_check_run.pcap 2>&1 > /dev/null"', '\$', 5) time.sleep(5) mySSH.command('docker exec -d ' + self.containerPrefix + '-oai-spgwc /bin/bash -c "nohup ./bin/oai_spgwc -o -c ./etc/spgw_c.conf > spgwc_check_run.log 2>&1"', '\$', 5) time.sleep(5) @@ -532,6 +532,7 @@ class EPCManagement(): logging.debug('Terminating OAI CN5G') mySSH.command('cd /opt/oai-cn5g-fed/docker-compose', '\$', 5) mySSH.command('./core-network.sh stop nrf spgwu', '\$', 60) + mySSH.command('docker volume prune --force || true', '\$', 60) time.sleep(2) mySSH.command('tshark -r /tmp/oai-cn5g.pcap | egrep --colour=never "Tracking area update" ','\$', 30) result = re.search('Tracking area update request', mySSH.getBefore()) @@ -760,6 +761,7 @@ class EPCManagement(): nbContainers += 1 mySSH.command('docker-compose down', '\$', 60) + mySSH.command('docker volume prune --force || true', '\$', 60) mySSH.command('docker inspect --format=\'{{.State.Health.Status}}\' ' + listOfContainers, '\$', 10) noMoreContainerNb = mySSH.getBefore().count('No such object') mySSH.command('docker inspect --format=\'{{.Name}}\' prod-oai-public-net prod-oai-private-net', '\$', 10) @@ -773,7 +775,7 @@ class EPCManagement(): HTML.CreateHtmlTestRowQueue(self.Type, 'OK', 1, html_queue) else: logging.debug('Undeployment went wrong') - HTML.CreateHtmlTestRowQueu(self.Type, 'KO', 1, html_queue) + HTML.CreateHtmlTestRowQueue(self.Type, 'KO', 1, html_queue) def LogCollectHSS(self): mySSH = SSH.SSHConnection() diff --git a/ci-scripts/main.py b/ci-scripts/main.py index e9acdc9152fc9892ce7ddf4c7df1fe2a89aef62a..43772fb655f3b65bce5a8abd2b115d7e64077272 100644 --- a/ci-scripts/main.py +++ b/ci-scripts/main.py @@ -155,6 +155,11 @@ def GetParametersFromXML(action): elif action == 'Initialize_eNB': RAN.eNB_Trace=test.findtext('eNB_Trace') RAN.eNB_Stats=test.findtext('eNB_Stats') + datalog_rt_stats_file=test.findtext('rt_stats_cfg') + if datalog_rt_stats_file is None: + RAN.datalog_rt_stats_file='datalog_rt_stats.default.yaml' + else: + RAN.datalog_rt_stats_file=datalog_rt_stats_file RAN.Initialize_eNB_args=test.findtext('Initialize_eNB_args') eNB_instance=test.findtext('eNB_instance') USRPIPAddress=test.findtext('USRP_IPAddress') @@ -295,6 +300,11 @@ def GetParametersFromXML(action): CiTestObj.ue_id = "" else: CiTestObj.ue_id = ue_id + ping_rttavg_threshold = test.findtext('ping_rttavg_threshold') + if (ping_rttavg_threshold is None): + CiTestObj.ping_rttavg_threshold = "" + else: + CiTestObj.ping_rttavg_threshold = ping_rttavg_threshold elif action == 'Iperf': CiTestObj.iperf_args = test.findtext('iperf_args') @@ -303,8 +313,15 @@ def GetParametersFromXML(action): CiTestObj.ue_id = "" else: CiTestObj.ue_id = ue_id - CiTestObj.iperf_direction = test.findtext('direction')#used for modules only + CiTestObj.iperf_direction = test.findtext('direction')#used for modules only CiTestObj.iperf_packetloss_threshold = test.findtext('iperf_packetloss_threshold') + iperf_bitrate_threshold = test.findtext('iperf_bitrate_threshold') + if (iperf_bitrate_threshold is None): + CiTestObj.iperf_bitrate_threshold = "90" #if no threshold is specified, default will be 90% + else: + CiTestObj.iperf_bitrate_threshold = iperf_bitrate_threshold + + CiTestObj.iperf_profile = test.findtext('iperf_profile') if (CiTestObj.iperf_profile is None): CiTestObj.iperf_profile = 'balanced' @@ -806,6 +823,8 @@ elif re.match('^TesteNB$', mode, re.IGNORECASE) or re.match('^TestUE$', mode, re check_OAI_UE = False RAN.pStatus=CiTestObj.CheckProcessExist(check_eNB, check_OAI_UE,RAN,EPC) RAN.InitializeeNB(HTML, EPC) + if RAN.prematureExit: + CiTestObj.AutoTerminateeNB(HTML,RAN,EPC,CONTAINERS) elif action == 'Terminate_eNB': RAN.TerminateeNB(HTML, EPC) elif action == 'Initialize_UE': @@ -895,15 +914,15 @@ elif re.match('^TesteNB$', mode, re.IGNORECASE) or re.match('^TestUE$', mode, re if CONTAINERS.exitStatus==1: RAN.prematureExit = True elif action == 'UndeployGenObject': - CONTAINERS.UndeployGenObject(HTML) + CONTAINERS.UndeployGenObject(HTML, RAN, CiTestObj) if CONTAINERS.exitStatus==1: RAN.prematureExit = True elif action == 'PingFromContainer': - CONTAINERS.PingFromContainer(HTML) + CONTAINERS.PingFromContainer(HTML, RAN, CiTestObj) if CONTAINERS.exitStatus==1: RAN.prematureExit = True elif action == 'IperfFromContainer': - CONTAINERS.IperfFromContainer(HTML) + CONTAINERS.IperfFromContainer(HTML, RAN) if CONTAINERS.exitStatus==1: RAN.prematureExit = True else: diff --git a/ci-scripts/ran.py b/ci-scripts/ran.py index 90fece4381310445a5e0ec314a96e0ade6dbc35e..ad360d217979d30bcf982b7279a12f0b30f09938 100644 --- a/ci-scripts/ran.py +++ b/ci-scripts/ran.py @@ -92,6 +92,7 @@ class RANManagement(): self.epcPcapFile = '' self.runtime_stats= '' self.datalog_rt_stats={} + self.datalog_rt_stats_file='datalog_rt_stats.default.yaml' self.eNB_Trace = '' #if 'yes', Tshark will be launched at initialization self.eNB_Stats = '' #if 'yes', Statistics Monitor will be launched at initialization self.USRPIPAddress = '' @@ -159,6 +160,7 @@ class RANManagement(): # Raphael: here add a check if git clone or git fetch went smoothly mySSH.command('git config user.email "jenkins@openairinterface.org"', '\$', 5) mySSH.command('git config user.name "OAI Jenkins"', '\$', 5) + mySSH.command('git advice.detachedHead false', '\$', 5) # Checking the BUILD INFO file if not self.backgroundBuild: mySSH.command('ls *.txt', '\$', 5) @@ -203,6 +205,7 @@ class RANManagement(): else: logging.debug('Merging with the target branch: ' + self.ranTargetBranch) mySSH.command('git merge --ff origin/' + self.ranTargetBranch + ' -m "Temporary merge for CI"', '\$', 5) + logging.debug(mySSH.getBefore()) # print what git said when merging/checking out mySSH.command('source oaienv', '\$', 5) mySSH.command('cd cmake_targets', '\$', 5) mySSH.command('mkdir -p log', '\$', 5) @@ -212,6 +215,7 @@ class RANManagement(): mySSH.command('echo "./build_oai ' + self.Build_eNB_args + '" > ./my-lte-softmodem-build.sh', '\$', 5) mySSH.command('chmod 775 ./my-lte-softmodem-build.sh', '\$', 5) mySSH.command('echo ' + lPassWord + ' | sudo -S ls', '\$', 5) + logging.debug(mySSH.getBefore()) # print current directory contents for verification mySSH.command('echo $USER; nohup sudo -E ./my-lte-softmodem-build.sh' + ' > ' + lSourcePath + '/cmake_targets/compile_oai_enb.log ' + ' 2>&1 &', lUserName, 5) mySSH.close() HTML.CreateHtmlTestRow(self.Build_eNB_args, 'OK', CONST.ALL_PROCESSES_OK) @@ -346,7 +350,7 @@ class RANManagement(): #reboot USRP if requested in xml if self.USRPIPAddress!='': - logging.debug('USRP '+ self.USRPIPAddress +'reboot request') + logging.debug('USRP '+ self.USRPIPAddress +': reboot request') mySSH.open(lIpAddr, lUserName, lPassWord) cmd2usrp='ssh root@'+self.USRPIPAddress+' reboot' mySSH.command2(cmd2usrp,1) @@ -371,10 +375,11 @@ class RANManagement(): result = re.search('interfaceToUse=(?P<eth_interface>[a-zA-Z0-9\-\_]+)done', mySSH.getBefore()) if result is not None: eth_interface = result.group('eth_interface') - logging.debug('\u001B[1m Launching tshark on interface ' + eth_interface + '\u001B[0m') + fltr = 'port 38412 or port 36412 or port 36422' # NGAP, S1AP, X2AP + logging.debug('\u001B[1m Launching tshark on interface ' + eth_interface + ' with filter "' + fltr + '"\u001B[0m') pcapfile = pcapfile_prefix + self.testCase_id + '_log.pcap' mySSH.command('echo ' + lPassWord + ' | sudo -S rm -f /tmp/' + pcapfile , '\$', 5) - mySSH.command('echo $USER; nohup sudo -E tshark -i ' + eth_interface + ' -w /tmp/' + pcapfile + ' > /dev/null 2>&1 &','\$', 5) + mySSH.command('echo $USER; nohup sudo -E tshark -i ' + eth_interface + ' -f "' + fltr + '" -w /tmp/' + pcapfile + ' > /dev/null 2>&1 &','\$', 5) mySSH.close() @@ -390,10 +395,11 @@ class RANManagement(): result = re.search('interfaceToUse=(?P<eth_interface>[a-zA-Z0-9\-\_]+)done', mySSH.getBefore()) if result is not None: eth_interface = result.group('eth_interface') - logging.debug('\u001B[1m Launching tshark on interface ' + eth_interface + '\u001B[0m') + fltr = 'port 38412 or port 36412 or port 36422' # NGAP, S1AP, X2AP + logging.debug('\u001B[1m Launching tshark on interface ' + eth_interface + ' with filter "' + fltr + '"\u001B[0m') self.epcPcapFile = 'enb_' + self.testCase_id + '_s1log.pcap' mySSH.command('echo ' + localEpcPassword + ' | sudo -S rm -f /tmp/' + self.epcPcapFile , '\$', 5) - mySSH.command('echo $USER; nohup sudo tshark -f "host ' + lIpAddr +'" -i ' + eth_interface + ' -w /tmp/' + self.epcPcapFile + ' > /tmp/tshark.log 2>&1 &', localEpcUserName, 5) + mySSH.command('echo $USER; nohup sudo tshark -f "host ' + lIpAddr +'" -i ' + eth_interface + ' -f "' + fltr + '" -w /tmp/' + self.epcPcapFile + ' > /tmp/tshark.log 2>&1 &', localEpcUserName, 5) mySSH.close() mySSH.open(lIpAddr, lUserName, lPassWord) mySSH.command('cd ' + lSourcePath, '\$', 5) @@ -474,7 +480,7 @@ class RANManagement(): mySSH.command('echo ' + lPassWord + ' | echo "ulimit -c unlimited && sudo UHD_RFNOC_DIR=/usr/local/share/uhd/rfnoc ./ran_build/build/' + self.air_interface[self.eNB_instance] + ' -O ' + lSourcePath + '/' + ci_full_config_file + extra_options + '" > ./my-lte-softmodem-run' + str(self.eNB_instance) + '.sh', '\$', 5) #otherwise the regular command is ok else: - mySSH.command('echo "ulimit -c unlimited && ./ran_build/build/' + self.air_interface[self.eNB_instance] + ' -O ' + lSourcePath + '/' + ci_full_config_file + extra_options + '" > ./my-lte-softmodem-run' + str(self.eNB_instance) + '.sh', '\$', 5) + mySSH.command('echo "ulimit -c unlimited && catchsegv ./ran_build/build/' + self.air_interface[self.eNB_instance] + ' -O ' + lSourcePath + '/' + ci_full_config_file + extra_options + '" > ./my-lte-softmodem-run' + str(self.eNB_instance) + '.sh', '\$', 5) mySSH.command('chmod 775 ./my-lte-softmodem-run' + str(self.eNB_instance) + '.sh', '\$', 5) mySSH.command('echo ' + lPassWord + ' | sudo -S rm -Rf enb_' + self.testCase_id + '.log', '\$', 5) @@ -487,9 +493,9 @@ class RANManagement(): conf_file='../ci-scripts/stats_monitor_conf.yaml' if self.eNB_Stats=='yes': if (self.air_interface[self.eNB_instance] == 'lte-softmodem') or (self.air_interface[self.eNB_instance] == 'ocp-enb'): - mySSH.command('echo $USER; nohup python3 ' + monitor_file + ' ' + conf_file + ' enb 2>&1 > enb_stats_monitor_execution.log &', '\$', 5) + mySSH.command('echo $USER; nohup python3 ' + monitor_file + ' ' + conf_file + ' ' + self.testCase_id + ' enb 2>&1 > enb_stats_monitor_execution.log &', '\$', 5) else: - mySSH.command('echo $USER; nohup python3 ' + monitor_file + ' ' + conf_file + ' gnb 2>&1 > gnb_stats_monitor_execution.log &', '\$', 5) + mySSH.command('echo $USER; nohup python3 ' + monitor_file + ' ' + conf_file + ' ' + self.testCase_id + ' gnb 2>&1 > gnb_stats_monitor_execution.log &', '\$', 5) @@ -665,10 +671,14 @@ class RANManagement(): mySSH.command('echo ' + localEpcPassword + ' | sudo -S chmod 666 /tmp/' + self.epcPcapFile, '\$', 5) mySSH.copyin(localEpcIpAddr, localEpcUserName, localEpcPassword, '/tmp/' + self.epcPcapFile, '.') mySSH.copyout(lIpAddr, lUserName, lPassWord, self.epcPcapFile, lSourcePath + '/cmake_targets/.') + mySSH.command('killall --signal SIGKILL record', '\$', 5) mySSH.close() + # if T tracer was run with option 0 (no logs), analyze logs + # from textlog, otherwise do normal analysis (e.g., option 2) + result = re.search('T_stdout 0', str(self.Initialize_eNB_args)) + if (result is not None): logging.debug('\u001B[1m Replaying RAW record file\u001B[0m') mySSH.open(lIpAddr, lUserName, lPassWord) - mySSH.command('killall --signal SIGKILL record', '\$', 5) mySSH.command('cd ' + lSourcePath + '/common/utils/T/tracer/', '\$', 5) enbLogFile = self.eNBLogFiles[int(self.eNB_instance)] raw_record_file = enbLogFile.replace('.log', '_record.raw') @@ -717,6 +727,9 @@ class RANManagement(): logStatus = self.AnalyzeLogFile_eNB(fileToAnalyze, HTML) if (logStatus < 0): HTML.CreateHtmlTestRow('N/A', 'KO', logStatus) + #display rt stats for gNB only + if len(self.datalog_rt_stats)!=0 and nodeB_prefix == 'g': + HTML.CreateHtmlDataLogTable(self.datalog_rt_stats) self.prematureExit = True self.eNBmbmsEnables[int(self.eNB_instance)] = False return @@ -738,8 +751,11 @@ class RANManagement(): mySSH.command('echo ' + self.eNBPassword + ' | sudo -S mv /tmp/enb_*.pcap .','\$',20) mySSH.command('echo ' + self.eNBPassword + ' | sudo -S mv /tmp/gnb_*.pcap .','\$',20) mySSH.command('echo ' + self.eNBPassword + ' | sudo -S rm -f enb.log.zip', '\$', 5) - mySSH.command('echo ' + self.eNBPassword + ' | sudo -S zip enb.log.zip enb*.log core* enb_*record.raw enb_*.pcap gnb_*.pcap enb_*txt physim_*.log *stats.log *monitor.pickle *monitor*.png log/*/*.log log/*/*.pcap', '\$', 60) - mySSH.command('echo ' + self.eNBPassword + ' | sudo -S rm enb*.log core* enb_*record.raw enb_*.pcap gnb_*.pcap enb_*txt physim_*.log *stats.log *monitor.pickle *monitor*.png log/*/*.log log/*/*.pcap', '\$', 15) + mySSH.command('echo ' + self.eNBPassword + ' | sudo -S zip enb.log.zip enb*.log enb_*record.raw enb_*.pcap gnb_*.pcap enb_*txt physim_*.log *stats.log *monitor.pickle *monitor*.png ping*.log.png log/*/*.log log/*/*.pcap', '\$', 60) + result = re.search('core.\d+', mySSH.getBefore()) + if result is not None: + mySSH.command('echo ' + self.eNBPassword + ' | sudo -S zip enb.log.zip core* ran_build/build/{lte,nr}-softmodem', '\$', 60) # add core and executable to zip + mySSH.command('echo ' + self.eNBPassword + ' | sudo -S rm enb*.log core* enb_*record.raw enb_*.pcap gnb_*.pcap enb_*txt physim_*.log *stats.log *monitor.pickle *monitor*.png ping*.log.png log/*/*.log log/*/*.pcap', '\$', 15) mySSH.close() def AnalyzeLogFile_eNB(self, eNBlogFile, HTML): @@ -752,6 +768,7 @@ class RANManagement(): msgLine = 0 foundSegFault = False foundRealTimeIssue = False + foundRealTimeIssue_cnt = 0 rrcSetupComplete = 0 rrcReleaseRequest = 0 rrcReconfigRequest = 0 @@ -801,6 +818,7 @@ class RANManagement(): #NSA specific log markers nsa_markers ={'SgNBReleaseRequestAcknowledge': [],'FAILURE': [], 'scgFailureInformationNR-r15': [], 'SgNBReleaseRequest': []} nodeB_prefix_found = False + RealTimeProcessingIssue = False line_cnt=0 #log file line counter for line in enb_log_file.readlines(): @@ -879,9 +897,6 @@ class RANManagement(): if result is not None and not exitSignalReceived: foundSegFault = True result = re.search('[Cc]ore [dD]ump', str(line)) - if result is not None and not exitSignalReceived: - foundSegFault = True - result = re.search('./ran_build/build/lte-softmodem', str(line)) if result is not None and not exitSignalReceived: foundSegFault = True result = re.search('[Aa]ssertion', str(line)) @@ -890,6 +905,7 @@ class RANManagement(): result = re.search('LLL', str(line)) if result is not None and not exitSignalReceived: foundRealTimeIssue = True + foundRealTimeIssue_cnt += 1 if foundAssertion and (msgLine < 3): msgLine += 1 msgAssertion += str(line) @@ -965,7 +981,7 @@ class RANManagement(): if result is not None: mbmsRequestMsg += 1 #FR1 NSA test : add new markers to make sure gNB is used - result = re.search('\[gNB [0-9]+\]\[RAPROC\] PUSCH with TC_RNTI [0-9a-fA-F]+ received correctly, adding UE MAC Context UE_id [0-9]+\/RNTI [0-9a-fA-F]+', str(line)) + result = re.search('\[gNB [0-9]+\]\[RAPROC\] PUSCH with TC_RNTI 0x[0-9a-fA-F]+ received correctly, adding UE MAC Context UE_id [0-9]+\/RNTI 0x[0-9a-fA-F]+', str(line)) if result is not None: NSA_RAPROC_PUSCH_check = 1 #dlsch and ulsch statistics @@ -1004,7 +1020,7 @@ class RANManagement(): #the following part takes the *_stats.log files as source (not the stdout log file) #the datalog config file has to be loaded - datalog_rt_stats_file='datalog_rt_stats.yaml' + datalog_rt_stats_file=self.datalog_rt_stats_file if (os.path.isfile(datalog_rt_stats_file)): yaml_file=datalog_rt_stats_file elif (os.path.isfile('ci-scripts/'+datalog_rt_stats_file)): @@ -1017,12 +1033,9 @@ class RANManagement(): datalog_rt_stats = yaml.load(f,Loader=yaml.FullLoader) rt_keys = datalog_rt_stats['Ref'] #we use the keys from the Ref field - if (os.path.isfile('./nrL1_stats.log')) and (os.path.isfile('./nrL1_stats.log')): - stat_files_present=True - else: - stat_files_present=False - logging.debug("NR Stats files for RT analysis not found") - if stat_files_present: + if os.path.isfile('./nrL1_stats.log') and os.path.isfile('./nrMAC_stats.log'): + # don't use CI-nrL1_stats.log, as this will increase the processing time for + # no reason, we just need the last occurence nrL1_stats = open('./nrL1_stats.log', 'r') nrMAC_stats = open('./nrMAC_stats.log', 'r') for line in nrL1_stats.readlines(): @@ -1043,6 +1056,8 @@ class RANManagement(): real_time_stats[k]=tmp.group(1) nrL1_stats.close() nrMAC_stats.close() + else: + logging.debug("NR Stats files for RT analysis not found") #stdout log file and stat log files analysis completed logging.debug(' File analysis (stdout, stats) completed') @@ -1121,8 +1136,7 @@ class RANManagement(): #check if there is a fail => will render the test as failed for k in datalog_rt_stats['Data']: if float(datalog_rt_stats['Data'][k][2])> datalog_rt_stats['Threshold'][k]: #condition for fail : avg/ref is greater than the fixed threshold - #setting prematureExit is ok although not the best option - self.prematureExit=False #temp for debug : do not stop the test if RT stats are excedeed + RealTimeProcessingIssue = True else: statMsg = 'No real time stats found in the log file\n' logging.debug('No real time stats found in the log file') @@ -1156,7 +1170,10 @@ class RANManagement(): logging.debug(statMsg) htmleNBFailureMsg += htmlMsg - + if RealTimeProcessingIssue: + logging.debug('\u001B[1;37;41m ' + nodeB_prefix + 'NB ended with real time processing issue! \u001B[0m') + htmleNBFailureMsg += 'Fail due to real time processing issue\n' + global_status = CONST.ENB_REAL_TIME_PROCESSING_ISSUE if uciStatMsgCount > 0: statMsg = nodeB_prefix + 'NB showed ' + str(uciStatMsgCount) + ' "uci->stat" message(s)' logging.debug('\u001B[1;30;43m ' + statMsg + ' \u001B[0m') @@ -1258,7 +1275,7 @@ class RANManagement(): global_status = CONST.ENB_PROCESS_ASSERTION if foundRealTimeIssue: logging.debug('\u001B[1;37;41m ' + nodeB_prefix + 'NB faced real time issues! \u001B[0m') - htmleNBFailureMsg += nodeB_prefix + 'NB faced real time issues!\n' + htmleNBFailureMsg += nodeB_prefix + 'NB faced real time issues! COUNT = '+ str(foundRealTimeIssue_cnt) +' lines\n' if rlcDiscardBuffer > 0: rlcMsg = nodeB_prefix + 'NB RLC discarded ' + str(rlcDiscardBuffer) + ' buffer(s)' logging.debug('\u001B[1;37;41m ' + rlcMsg + ' \u001B[0m') diff --git a/ci-scripts/ran_dashboard/Hdashboard.py b/ci-scripts/ran_dashboard/Hdashboard.py index 5e34ae50bf3777f1c7032b2608facd0ef16f6666..1b65c7af4f0b78d2b8b2c1680857bf9ef7362e0f 100644 --- a/ci-scripts/ran_dashboard/Hdashboard.py +++ b/ci-scripts/ran_dashboard/Hdashboard.py @@ -43,7 +43,7 @@ import gitlab import yaml import os import time - +import sys from sqlconnect import SQLConnect @@ -61,7 +61,9 @@ class Dashboard: self.git = self.__getGitData(cmd) #git data from Gitlab self.tests = self.__loadCfg('ran_dashboard_cfg.yaml') #tests table setup from yaml self.db = self.__loadFromDB() #test results from database - + self.mr_list=[] #mr list in string format + for x in range(len(self.git)): + self.mr_list.append(str(self.git[x]['iid'])) def __loadCfg(self,yaml_file): with open(yaml_file,'r') as f: @@ -86,6 +88,29 @@ class Dashboard: mydb.close_connection() return mydb.data + def singleMR_initHTML(self, date): + self.f_html.write('<!DOCTYPE html>\n') + self.f_html.write('<head>\n') + self.f_html.write('<link rel="stylesheet" href="../test_styles.css">\n') + self.f_html.write('<title>Test Dashboard</title>\n') + self.f_html.write('</head>\n') + self.f_html.write('<br>\n') + self.f_html.write('<br>\n') + self.f_html.write('<table>\n') + self.f_html.write('<tr>\n') + self.f_html.write('<td class="Main">OAI RAN TEST Status Dashboard</td>\n') + self.f_html.write('</td>\n') + self.f_html.write('<tr>\n') + self.f_html.write('<tr></tr>\n') + self.f_html.write('<tr>\n') + self.f_html.write('<td class="Date">Update : '+date+'</td>\n') + self.f_html.write('</td>\n') + self.f_html.write('</tr>\n') + self.f_html.write('</table>\n') + self.f_html.write('<br>\n') + self.f_html.write('<br>\n') + + def Test_initHTML(self, date): self.f_html.write('<!DOCTYPE html>\n') self.f_html.write('<head>\n') @@ -197,11 +222,13 @@ class Dashboard: self.f_html.write('</tr>\n') - def Build(self, type, htmlfilename): + def Build(self, type, mr, htmlfilename): if type=='MR': self.Build_MR_Table(htmlfilename) elif type=='Tests': self.Build_Test_Table(htmlfilename) + elif type=='singleMR': + self.Build_singleMR_Table(mr,htmlfilename) else : print("Undefined Dashboard Type, options : MR or Tests") @@ -291,6 +318,93 @@ class Dashboard: self.Test_terminateHTML() + def Build_singleMR_Table(self,singlemr,htmlfilename): + print("Building single MR Tests Results...") + + self.f_html=open(htmlfilename,'w') + + ###update date/time, format dd/mm/YY H:M:S + now = datetime.now() + dt_string = now.strftime("%d/%m/%Y %H:%M") + #HTML table header + self.singleMR_initHTML(dt_string) + + + #1 table per MR if test results exist => 1 table for matching mr + for x in range(len(self.git)): + mr=str(self.git[x]['iid']) + if mr==singlemr: + #if 'PASS' not in self.db[mr]: + self.f_html.write('<h3><a href="https://gitlab.eurecom.fr/oai/openairinterface5g/-/merge_requests/'+mr+'">'+mr+'</a>'+' '+self.git[x]['title'] + '</h3>\n') + self.f_html.write('<table class="Test_Table">\n') + self.f_html.write('<tr>\n') + self.f_html.write('<th class="Test_Name">Test Name</th>\n') + self.f_html.write('<th class="Test_Descr">Bench</th> \n') + self.f_html.write('<th class="Test_Descr">Test</th> \n') + self.f_html.write('<th class="Pass"># Pass</th>\n') + self.f_html.write('<th class="Fail"># Fail</th>\n') + self.f_html.write('<th class="Last_Pass">Last Pass</th>\n') + self.f_html.write('<th class="Last_Fail">Last Fail</th>\n') + self.f_html.write('</tr>\n') + + #parsing the tests + for t in self.tests: + + row=[] + short_name= t + hyperlink= self.tests[t]['link'] + job=self.tests[t]['job'] + + + if job in self.db[mr]: + if 'PASS' in self.db[mr][job]: + row.append(self.db[mr][job]['PASS']) + else: + row.append('') + if 'FAIL' in self.db[mr][job]: + row.append(self.db[mr][job]['FAIL']) + else: + row.append('') + #2 columns for last_pass and last_fail links + if 'last_pass' in self.db[mr][job]: + lastpasshyperlink= self.db[mr][job]['last_pass'][1] + lastpasstext= self.db[mr][job]['last_pass'][0] + else: + lastpasshyperlink='' + lastpasstext='' + + if 'last_fail' in self.db[mr][job]: + lastfailhyperlink= self.db[mr][job]['last_fail'][1] + lastfailtext= self.db[mr][job]['last_fail'][0] + else: + lastfailhyperlink='' + lastfailtext='' + + + + self.f_html.write('<tr>\n') + self.f_html.write('<td><a href='+hyperlink+'>'+short_name+'</a></td>\n') + self.f_html.write('<td>'+self.tests[t]['bench']+'</td>\n') + self.f_html.write('<td>'+self.tests[t]['test']+'</td>\n') + if row[0]!='': + self.f_html.write('<td style="background-color: rgb(58, 236, 58);">'+str(row[0])+'</td>\n') + else: + self.f_html.write('<td></td>\n') + if row[1]!='': + self.f_html.write('<td style="background-color: red;">'+str(row[1])+'</td>\n') + else: + self.f_html.write('<td></td>\n') + self.f_html.write('<td><a href='+lastpasshyperlink+'>'+lastpasstext+'</a></td>\n') + self.f_html.write('<td><a href='+lastfailhyperlink+'>'+lastfailtext+'</a></td>\n') + self.f_html.write('</tr>\n') + + self.f_html.write('</table>\n') + + #terminate HTML table and close file + self.Test_terminateHTML() + + + def Build_MR_Table(self,htmlfilename): print("Building Merge Requests Dashboard...") @@ -379,6 +493,7 @@ class Dashboard: #terminate HTML table and close file self.MR_terminateHTML() + def CopyToS3(self,htmlfilename,bucket,key): print("Uploading to S3 bucket") #Creating Session With Boto3. @@ -387,15 +502,127 @@ class Dashboard: #Creating S3 Resource From the Session. result = s3.upload_file(htmlfilename, bucket,key, ExtraArgs={'ACL':'public-read','ContentType': 'text/html'}) + #unused + def CopyCSS(self,path): + s3 = boto3.resource('s3') + copy_source = {'Bucket': 'oaitestdashboard','Key':'test_styles.css'} + s3.meta.client.copy(copy_source, 'oaitestdashboard', path+'/'+ 'test_styles.css') + + + def PostGitNote(self,mr,commit,args): + #current date and time to be posted with test results + #now = datetime.now() + #dt_string = now.strftime("%d/%m/%Y %H:%M") + + if len(args)%4 != 0: + print("Wrong Number of Arguments") + return + else : + n_tests=len(args)//4 + + gl = gitlab.Gitlab.from_config('OAI') + project_id = 223 + project = gl.projects.get(project_id) + + #retrieve all the notes from the MR + editable_mr = project.mergerequests.get(int(mr)) + mr_notes = editable_mr.notes.list(all=True) + + body = '<a href="https://oaitestdashboard.s3.eu-west-1.amazonaws.com/MR'+mr+'/index.html">Consolidated Test Results</a><br>'+\ + 'Tested CommitID: ' + commit + '<br>' + + for i in range(0,n_tests): + jobname = args[4*i] + buildurl = args[4*i+1] + buildid = args[4*i+2] + status = args[4*i+3] + body += jobname+', status is <b>'+status+'</b>, (<a href="'+buildurl+'">'+buildid+'</a>)<br>' + + #create new note + mr_note = editable_mr.notes.create({ + 'body': body + }) + editable_mr.save() + + def AWSCleanup(self,mode): + #first build MR list from aws S3 bucket + if mode != 'report' and mode !='delete': + print("incorrect mode for awsclean") + return + aws_mr_list=[] + s3 = boto3.resource('s3') + my_bucket = s3.Bucket('oaitestdashboard') + for my_bucket_object in my_bucket.objects.all(): + #MR objects are like MR1407/index.html + res=re.search(r'^MR([0-9]+)',my_bucket_object.key) + if res!=None: + aws_mr_list.append(res.group(1))#store MR number as a string + #open MR list from GIt already exists as an attribute of this class self.mr_list + #parse aws MR list and delete those MR that are no longer open + for aws_mr in aws_mr_list: + if aws_mr not in self.mr_list: + if mode=="report": + print(aws_mr+' can be deleted from AWS S3') + else : + awspath="MR"+aws_mr+"/" + print('deleting ' + aws_mr) + my_bucket.objects.filter(Prefix=awspath).delete() + + + + def main(): - htmlDash=Dashboard() - htmlDash.Build('MR','/tmp/MR_index.html') - htmlDash.CopyToS3('/tmp/MR_index.html','oairandashboard','index.html') - htmlDash.Build('Tests','/tmp/Tests_index.html') - htmlDash.CopyToS3('/tmp/Tests_index.html','oaitestdashboard','index.html') + #call from slave Jenkinsfile : sh "python3 Hdashboard.py testevent ${params.eNB_MR} " + #call from master Jenkinsfile : sh "python3 Hdashboard.py gitpost ${GitPostArgs}" + + + if len(sys.argv)>1: + + #individual MR test results + test dashboard, event based (end of slave jenkins pipeline) + if sys.argv[1]=="testevent" : + mr=sys.argv[2] + htmlDash=Dashboard() + if mr in htmlDash.mr_list: + #single MR test results + htmlDash.Build('singleMR',mr,'/tmp/MR'+mr+'_index.html') + htmlDash.CopyToS3('/tmp/MR'+mr+'_index.html','oaitestdashboard','MR'+mr+'/index.html') + #all MR test results + htmlDash.Build('Tests','0000','/tmp/Tests_index.html') + htmlDash.CopyToS3('/tmp/Tests_index.html','oaitestdashboard','index.html') + + #git post with MR test results, event based (end of master jenkins pipeline) + elif sys.argv[1]=="gitpost": + mr=sys.argv[2] + commit=sys.argv[3] + args=[] + for i in range (4, len(sys.argv)): #jobname, url, id , result + args.append(sys.argv[i]) + htmlDash=Dashboard() + if mr in htmlDash.mr_list: + htmlDash.PostGitNote(mr,commit, args) + else: + print("Not a Merge Request => this build is for testing/debug purpose, no report to git") + elif sys.argv[1]=="awsclean": + mode=sys.argv[2]#report or delete + htmlDash=Dashboard() + htmlDash.AWSCleanup(mode) + else: + print("Wrong argument at position 1") + + + #test and MR status dashboards, cron based + else: + htmlDash=Dashboard() + #all MR status dashboard + htmlDash.Build('MR','0000','/tmp/MR_index.html') + htmlDash.CopyToS3('/tmp/MR_index.html','oairandashboard','index.html') + #all MR test results + htmlDash.Build('Tests','0000','/tmp/Tests_index.html') + htmlDash.CopyToS3('/tmp/Tests_index.html','oaitestdashboard','index.html') + + - if __name__ == "__main__": # execute only if run as a script main() diff --git a/ci-scripts/ran_dashboard/ran_dashboard_cfg.yaml b/ci-scripts/ran_dashboard/ran_dashboard_cfg.yaml index 071b9e2e6747fca041d361623a57c3cea08c3063..8b311cf6ac09050bebbdd530ed4e15585347e0b5 100644 --- a/ci-scripts/ran_dashboard/ran_dashboard_cfg.yaml +++ b/ci-scripts/ran_dashboard/ran_dashboard_cfg.yaml @@ -2,7 +2,7 @@ LTE-2x2 : #short name used in the dashboard job : 'RAN-LTE-2x2-Module-OAIEPC' #job name from Jenkins, used in the database link : 'https://jenkins-oai.eurecom.fr/view/RAN/job/RAN-LTE-2x2-Module-OAIEPC' bench : 'Obelix-N310-OAIEPC-Quectel(nrmodule2)' - test : 'TDD, 40MHz, MCS9, 26Mb DL, 7Mb UL' + test : 'TM1 + TM2, TDD, 40MHz, MCS9, 26Mb DL, 7Mb UL' NSA-B200 : job : 'RAN-NSA-B200-Module-LTEBOX' link : 'https://jenkins-oai.eurecom.fr/view/RAN/job/RAN-NSA-B200-Module-LTEBOX' @@ -18,4 +18,9 @@ SA-N310 : link : 'https://jenkins-oai.eurecom.fr/view/RAN/job/RAN-SA-Module-CN5G' bench : 'Asterix-N310-OAICN5G-Quectel(nrmodule2)' test : 'TDD, 40MHz, 60Mb DL, 3Mb UL' +SA-OAIUE-N310-X300 : + job : 'RAN-SA-OAIUE-N310-X300-CN5G' + link : 'https://jenkins-oai.eurecom.fr/view/RAN/job/RAN-SA-OAIUE-N310-X300-CN5G/' + bench : 'Asterix-N310-OAICN5G-OAIUE-N310' + test : 'TDD, 40MHz, Ping, (to be implemented : iperf)' diff --git a/ci-scripts/reportTestLocally.sh b/ci-scripts/reportTestLocally.sh index 19fac7fd781827e8d83b5bf470772eb03bcbaa9f..6ef6b2e254e80f55a60b0706e5555b7f61708f54 100755 --- a/ci-scripts/reportTestLocally.sh +++ b/ci-scripts/reportTestLocally.sh @@ -1033,116 +1033,6 @@ function report_test { echo " </div>" >> ./test_simulator_results.html fi - ARCHIVES_LOC=archives/l2_sim/test - if [ -d $ARCHIVES_LOC ] - then - echo " <h3>4G LTE L2-NFAPI Simulator Check</h3>" >> ./test_simulator_results.html - - if [ -f $ARCHIVES_LOC/test_final_status.log ] - then - if [ `grep -c TEST_OK $ARCHIVES_LOC/test_final_status.log` -eq 1 ] - then - echo " <div class=\"alert alert-success\">" >> ./test_simulator_results.html - echo " <strong>TEST was SUCCESSFUL <span class=\"glyphicon glyphicon-ok-circle\"></span></strong>" >> ./test_simulator_results.html - echo " </div>" >> ./test_simulator_results.html - else - echo " <div class=\"alert alert-danger\">" >> ./test_simulator_results.html - echo " <strong>TEST was a FAILURE! <span class=\"glyphicon glyphicon-ban-circle\"></span></strong>" >> ./test_simulator_results.html - echo " </div>" >> ./test_simulator_results.html - fi - else - echo " <div class=\"alert alert-danger\">" >> ./test_simulator_results.html - echo " <strong>COULD NOT DETERMINE TEST FINAL STATUS! <span class=\"glyphicon glyphicon-ban-circle\"></span></strong>" >> ./test_simulator_results.html - echo " </div>" >> ./test_simulator_results.html - fi - - echo " <button data-toggle=\"collapse\" data-target=\"#oai-l2-sim-test-details\">More details on L2-NFAPI Simulator test results</button>" >> ./test_simulator_results.html - echo " <div id=\"oai-l2-sim-test-details\" class=\"collapse\">" >> ./test_simulator_results.html - echo " <table border = \"1\">" >> ./test_simulator_results.html - echo " <tr bgcolor = \"#33CCFF\" >" >> ./test_simulator_results.html - echo " <th>Log File Name</th>" >> ./test_simulator_results.html - echo " <th>Command</th>" >> ./test_simulator_results.html - echo " <th>Status</th>" >> ./test_simulator_results.html - echo " <th>Statistics</th>" >> ./test_simulator_results.html - echo " </tr>" >> ./test_simulator_results.html - - EPC_CONFIGS=("wS1" "noS1") - TRANS_MODES=("fdd") - BW_CASES=(05) - NB_USERS=(01 04) - for CN_CONFIG in ${EPC_CONFIGS[@]} - do - for TMODE in ${TRANS_MODES[@]} - do - for BW in ${BW_CASES[@]} - do - for UES in ${NB_USERS[@]} - do - echo " <tr bgcolor = \"#8FBC8F\" >" >> ./test_simulator_results.html - if [[ $CN_CONFIG =~ .*wS1.* ]] - then - echo " <td align = \"center\" colspan = 4 >Test with EPC (aka withS1): ${TMODE} -- ${BW}MHz -- ${UES} user(s)</td>" >> ./test_simulator_results.html - else - echo " <td align = \"center\" colspan = 4 >Test without EPC (aka noS1): ${TMODE} -- ${BW}MHz -- ${UES} user(s)</td>" >> ./test_simulator_results.html - fi - echo " </tr>" >> ./test_simulator_results.html - ENB_LOG=$ARCHIVES_LOC/${TMODE}_${BW}MHz_${UES}users_${CN_CONFIG}_enb.log - UE_LOG=`echo $ENB_LOG | sed -e "s#enb#ue#"` - if [ -f $ENB_LOG ] && [ -f $UE_LOG ] - then - NAME_ENB=`echo $ENB_LOG | sed -e "s#$ARCHIVES_LOC/##"` - NAME_UE=`echo $UE_LOG | sed -e "s#$ARCHIVES_LOC/##"` - echo " <tr>" >> ./test_simulator_results.html - echo " <td>$NAME_ENB --- $NAME_UE</td>" >> ./test_simulator_results.html - echo " <td>N/A</td>" >> ./test_simulator_results.html - NB_ENB_GOT_SYNC=`egrep -c "got sync" $ENB_LOG` - NB_UE_GOT_SYNC=`egrep -c "got sync" $UE_LOG` - NB_ENB_SYNCED_WITH_UE=`egrep -c "Sending NFAPI_START_RESPONSE" $UE_LOG` - if [ $NB_ENB_GOT_SYNC -gt 0 ] && [ $NB_UE_GOT_SYNC -gt 2 ] && [ $NB_ENB_SYNCED_WITH_UE -gt 0 ] - then - echo " <td bgcolor = \"green\" >OK</td>" >> ./test_simulator_results.html - else - echo " <td bgcolor = \"red\" >KO</td>" >> ./test_simulator_results.html - fi - echo " <td><pre>" >> ./test_simulator_results.html - if [ $NB_ENB_GOT_SYNC -gt 0 ] - then - echo "<font color = \"blue\">- eNB --> got sync</font>" >> ./test_simulator_results.html - else - echo "<font color = \"red\"><b>- eNB NEVER got sync</b></font>" >> ./test_simulator_results.html - fi - if [ $NB_UE_GOT_SYNC -gt 2 ] - then - echo "<font color = \"blue\">- UE --> got sync</font>" >> ./test_simulator_results.html - else - echo "<font color = \"red\"><b>- UE NEVER got sync</b></font>" >> ./test_simulator_results.html - fi - if [ $NB_ENB_SYNCED_WITH_UE -gt 0 ] - then - echo "<font color = \"blue\">- UE attached to eNB</font>" >> ./test_simulator_results.html - else - echo "<font color = \"red\"><b>- UE NEVER attached to eNB</b></font>" >> ./test_simulator_results.html - fi - echo " </pre></td>" >> ./test_simulator_results.html - echo " </tr>" >> ./test_simulator_results.html - fi - PING_LOGS=`ls $ARCHIVES_LOC/${TMODE}_${BW}MHz_${UES}users_${CN_CONFIG}_ping*.log 2> /dev/null` - analyzePingFiles - - IPERF_TESTS=`ls $ARCHIVES_LOC/${TMODE}_${BW}MHz_${UES}users_${CN_CONFIG}_iperf_dl*client*txt 2> /dev/null` - analyzeIperfFiles - - IPERF_TESTS=`ls $ARCHIVES_LOC/${TMODE}_${BW}MHz_${UES}users_${CN_CONFIG}_iperf_ul*client*txt 2> /dev/null` - analyzeIperfFiles - done - done - done - done - - echo " </table>" >> ./test_simulator_results.html - echo " </div>" >> ./test_simulator_results.html - fi - ARCHIVES_LOC=archives/phy_sim/test if [ -d $ARCHIVES_LOC ] then diff --git a/ci-scripts/runTestOnVM.sh b/ci-scripts/runTestOnVM.sh index de696cdc64b77cb03be90a6d91080fd05e5f837e..8be4a47bfa13219686b8bce3c105363f81f44b32 100755 --- a/ci-scripts/runTestOnVM.sh +++ b/ci-scripts/runTestOnVM.sh @@ -65,7 +65,7 @@ function start_basic_sim_enb { echo "sudo chmod 777 /home/ubuntu/tmp/cmake_targets/ran_build/" >> $1 echo "sudo chmod 777 /home/ubuntu/tmp/cmake_targets/ran_build/build/" >> $1 echo "cd /home/ubuntu/tmp/cmake_targets/ran_build/build/" >> $1 - echo "echo \"ulimit -c unlimited && ./lte-softmodem -O /home/ubuntu/tmp/ci-scripts/conf_files/ci-$LOC_CONF_FILE --log_config.global_log_options level,nocolor --basicsim\" > ./my-lte-softmodem-run.sh " >> $1 + echo "echo \"ulimit -c unlimited && ./lte-softmodem -O /home/ubuntu/tmp/ci-scripts/conf_files/ci-$LOC_CONF_FILE --log_config.global_log_options level,nocolor,time --basicsim\" > ./my-lte-softmodem-run.sh " >> $1 echo "chmod 775 ./my-lte-softmodem-run.sh" >> $1 echo "cat ./my-lte-softmodem-run.sh" >> $1 echo "if [ -e /home/ubuntu/tmp/cmake_targets/log/$LOC_LOG_FILE ]; then sudo sudo rm -f /home/ubuntu/tmp/cmake_targets/log/$LOC_LOG_FILE; fi" >> $1 @@ -110,7 +110,7 @@ function start_basic_sim_ue { echo "echo \"cd /home/ubuntu/tmp/cmake_targets/ran_build/build/\"" > $1 echo "sudo chmod 777 /home/ubuntu/tmp/cmake_targets/ran_build/build/" >> $1 echo "cd /home/ubuntu/tmp/cmake_targets/ran_build/build" >> $1 - echo "echo \"./lte-uesoftmodem -C ${LOC_FREQUENCY}000000 -r $LOC_NB_RBS --log_config.global_log_options nocolor,level --basicsim\" > ./my-lte-uesoftmodem-run.sh" >> $1 + echo "echo \"./lte-uesoftmodem -C ${LOC_FREQUENCY}000000 -r $LOC_NB_RBS --log_config.global_log_options nocolor,line_num,level --basicsim\" > ./my-lte-uesoftmodem-run.sh" >> $1 echo "chmod 775 ./my-lte-uesoftmodem-run.sh" >> $1 echo "cat ./my-lte-uesoftmodem-run.sh" >> $1 echo "if [ -e /home/ubuntu/tmp/cmake_targets/log/$LOC_UE_LOG_FILE ]; then sudo sudo rm -f /home/ubuntu/tmp/cmake_targets/log/$LOC_UE_LOG_FILE; fi" >> $1 @@ -818,9 +818,9 @@ function start_l2_sim_enb { echo "cd /home/ubuntu/tmp/cmake_targets/ran_build/build/" >> $1 if [ $LOC_S1_CONFIGURATION -eq 0 ] then - echo "echo \"ulimit -c unlimited && ./lte-softmodem -O /home/ubuntu/tmp/ci-scripts/conf_files/ci-$LOC_CONF_FILE --log_config.global_log_options level,nocolor --noS1\" > ./my-lte-softmodem-run.sh " >> $1 + echo "echo \"ulimit -c unlimited && ./lte-softmodem -O /home/ubuntu/tmp/ci-scripts/conf_files/ci-$LOC_CONF_FILE --log_config.global_log_options level,nocolor,time --noS1\" > ./my-lte-softmodem-run.sh " >> $1 else - echo "echo \"ulimit -c unlimited && ./lte-softmodem -O /home/ubuntu/tmp/ci-scripts/conf_files/ci-$LOC_CONF_FILE --log_config.global_log_options level,nocolor \" > ./my-lte-softmodem-run.sh " >> $1 + echo "echo \"ulimit -c unlimited && ./lte-softmodem -O /home/ubuntu/tmp/ci-scripts/conf_files/ci-$LOC_CONF_FILE --log_config.global_log_options level,nocolor,time \" > ./my-lte-softmodem-run.sh " >> $1 fi echo "chmod 775 ./my-lte-softmodem-run.sh" >> $1 echo "cat ./my-lte-softmodem-run.sh" >> $1 @@ -929,9 +929,9 @@ function start_l2_sim_ue { echo "cd /home/ubuntu/tmp/cmake_targets/ran_build/build/" >> $1 if [ $LOC_S1_CONFIGURATION -eq 0 ] then - echo "echo \"ulimit -c unlimited && ./lte-uesoftmodem -O /home/ubuntu/tmp/ci-scripts/conf_files/ci-$LOC_CONF_FILE --L2-emul 3 --num-ues $LOC_NB_UES --nums_ue_thread 1 --nokrnmod 1 --log_config.global_log_options level,nocolor --noS1\" > ./my-lte-softmodem-run.sh " >> $1 + echo "echo \"ulimit -c unlimited && ./lte-uesoftmodem -O /home/ubuntu/tmp/ci-scripts/conf_files/ci-$LOC_CONF_FILE --L2-emul 3 --num-ues $LOC_NB_UES --nums_ue_thread 1 --nokrnmod 1 --log_config.global_log_options level,nocolor,time --noS1\" > ./my-lte-softmodem-run.sh " >> $1 else - echo "echo \"ulimit -c unlimited && ./lte-uesoftmodem -O /home/ubuntu/tmp/ci-scripts/conf_files/ci-$LOC_CONF_FILE --L2-emul 3 --num-ues $LOC_NB_UES --nums_ue_thread 1 --nokrnmod 1 --log_config.global_log_options level,nocolor\" > ./my-lte-softmodem-run.sh " >> $1 + echo "echo \"ulimit -c unlimited && ./lte-uesoftmodem -O /home/ubuntu/tmp/ci-scripts/conf_files/ci-$LOC_CONF_FILE --L2-emul 3 --num-ues $LOC_NB_UES --nums_ue_thread 1 --nokrnmod 1 --log_config.global_log_options level,nocolor,time\" > ./my-lte-softmodem-run.sh " >> $1 fi echo "chmod 775 ./my-lte-softmodem-run.sh" >> $1 echo "cat ./my-lte-softmodem-run.sh" >> $1 @@ -1051,9 +1051,9 @@ function start_rf_sim_enb { echo "cd /home/ubuntu/tmp/cmake_targets/ran_build/build/" >> $1 if [ $LOC_S1_CONFIGURATION -eq 0 ] then - echo "echo \"ulimit -c unlimited && ./lte-softmodem -O /home/ubuntu/tmp/ci-scripts/conf_files/ci-$LOC_CONF_FILE --rfsim --log_config.global_log_options level,nocolor --noS1 --eNBs.[0].rrc_inactivity_threshold 0\" > ./my-lte-softmodem-run.sh " >> $1 + echo "echo \"ulimit -c unlimited && ./lte-softmodem -O /home/ubuntu/tmp/ci-scripts/conf_files/ci-$LOC_CONF_FILE --rfsim --log_config.global_log_options level,nocolor,time --noS1 --eNBs.[0].rrc_inactivity_threshold 0\" > ./my-lte-softmodem-run.sh " >> $1 else - echo "echo \"ulimit -c unlimited && ./lte-softmodem -O /home/ubuntu/tmp/ci-scripts/conf_files/ci-$LOC_CONF_FILE --rfsim --log_config.global_log_options level,nocolor --eNBs.[0].rrc_inactivity_threshold 0 --eNBs.[0].plmn_list.[0].mnc 93\" > ./my-lte-softmodem-run.sh " >> $1 + echo "echo \"ulimit -c unlimited && ./lte-softmodem -O /home/ubuntu/tmp/ci-scripts/conf_files/ci-$LOC_CONF_FILE --rfsim --log_config.global_log_options level,nocolor,time --eNBs.[0].rrc_inactivity_threshold 0 --eNBs.[0].plmn_list.[0].mnc 93\" > ./my-lte-softmodem-run.sh " >> $1 fi echo "chmod 775 ./my-lte-softmodem-run.sh" >> $1 echo "cat ./my-lte-softmodem-run.sh" >> $1 @@ -1159,9 +1159,9 @@ function start_rf_sim_ue { echo "cd /home/ubuntu/tmp/cmake_targets/ran_build/build/" >> $1 if [ $LOC_S1_CONFIGURATION -eq 0 ] then - echo "echo \"ulimit -c unlimited && ./lte-uesoftmodem -C ${LOC_FREQUENCY}000000 -r $LOC_PRB --ue-rxgain 140 --ue-txgain 120 --nokrnmod 1 --rfsim --log_config.global_log_options level,nocolor --noS1\" > ./my-lte-softmodem-run.sh " >> $1 + echo "echo \"ulimit -c unlimited && ./lte-uesoftmodem -C ${LOC_FREQUENCY}000000 -r $LOC_PRB --ue-rxgain 140 --ue-txgain 120 --nokrnmod 1 --rfsim --log_config.global_log_options level,nocolor,time --noS1\" > ./my-lte-softmodem-run.sh " >> $1 else - echo "echo \"ulimit -c unlimited && ./lte-uesoftmodem -C ${LOC_FREQUENCY}000000 -r $LOC_PRB --ue-rxgain 140 --ue-txgain 120 --nokrnmod 1 --rfsim --log_config.global_log_options level,nocolor\" > ./my-lte-softmodem-run.sh " >> $1 + echo "echo \"ulimit -c unlimited && ./lte-uesoftmodem -C ${LOC_FREQUENCY}000000 -r $LOC_PRB --ue-rxgain 140 --ue-txgain 120 --nokrnmod 1 --rfsim --log_config.global_log_options level,nocolor,time\" > ./my-lte-softmodem-run.sh " >> $1 fi echo "chmod 775 ./my-lte-softmodem-run.sh" >> $1 echo "cat ./my-lte-softmodem-run.sh" >> $1 @@ -1281,12 +1281,12 @@ function start_rf_sim_gnb { then if [ $LOC_RA_SA_TEST -eq 0 ] #no RA test => use --phy-test option then - echo "echo \"./nr-softmodem -O /home/ubuntu/tmp/ci-scripts/conf_files/ci-$LOC_CONF_FILE --log_config.global_log_options level,nocolor --parallel-config PARALLEL_SINGLE_THREAD --noS1 --nokrnmod 1 --rfsim --phy-test --lowmem --noS1\" > ./my-nr-softmodem-run.sh " >> $1 + echo "echo \"./nr-softmodem -O /home/ubuntu/tmp/ci-scripts/conf_files/ci-$LOC_CONF_FILE --log_config.global_log_options level,nocolor,time --parallel-config PARALLEL_SINGLE_THREAD --noS1 --nokrnmod 1 --rfsim --phy-test --lowmem --noS1\" > ./my-nr-softmodem-run.sh " >> $1 elif [ $LOC_RA_SA_TEST -eq 1 ] #RA test => use --do-ra option then - echo "echo \"./nr-softmodem -O /home/ubuntu/tmp/ci-scripts/conf_files/ci-$LOC_CONF_FILE --log_config.global_log_options level,nocolor --parallel-config PARALLEL_SINGLE_THREAD --rfsim --do-ra --lowmem --noS1\" > ./my-nr-softmodem-run.sh " >> $1 + echo "echo \"./nr-softmodem -O /home/ubuntu/tmp/ci-scripts/conf_files/ci-$LOC_CONF_FILE --log_config.global_log_options level,nocolor,time --parallel-config PARALLEL_SINGLE_THREAD --rfsim --do-ra --lowmem --noS1\" > ./my-nr-softmodem-run.sh " >> $1 else #SA test => use --sa option - echo "echo \"./nr-softmodem -O /home/ubuntu/tmp/ci-scripts/conf_files/ci-$LOC_CONF_FILE --log_config.global_log_options level,nocolor --parallel-config PARALLEL_SINGLE_THREAD --rfsim --sa --lowmem \" > ./my-nr-softmodem-run.sh " >> $1 + echo "echo \"./nr-softmodem -O /home/ubuntu/tmp/ci-scripts/conf_files/ci-$LOC_CONF_FILE --log_config.global_log_options level,nocolor,time --parallel-config PARALLEL_SINGLE_THREAD --rfsim --sa --lowmem \" > ./my-nr-softmodem-run.sh " >> $1 fi fi echo "chmod 775 ./my-nr-softmodem-run.sh" >> $1 @@ -1397,12 +1397,12 @@ function start_rf_sim_nr_ue { then if [ $LOC_RA_SA_TEST -eq 0 ] #no RA test => use --phy-test option then - echo "echo \"./nr-uesoftmodem --nokrnmod 1 --rfsim --phy-test --rrc_config_path /home/ubuntu/tmp/cmake_targets/ran_build/build/ --log_config.global_log_options level,nocolor --noS1\" > ./my-nr-softmodem-run.sh " >> $1 + echo "echo \"./nr-uesoftmodem --nokrnmod 1 --rfsim --phy-test --rrc_config_path /home/ubuntu/tmp/cmake_targets/ran_build/build/ --log_config.global_log_options level,nocolor,time --noS1\" > ./my-nr-softmodem-run.sh " >> $1 elif [ $LOC_RA_SA_TEST -eq 1 ] #RA test => use --do-ra option then - echo "echo \"./nr-uesoftmodem --rfsim --do-ra --log_config.global_log_options level,nocolor --rrc_config_path /home/ubuntu/tmp/cmake_targets/ran_build/build/\" > ./my-nr-softmodem-run.sh " >> $1 + echo "echo \"./nr-uesoftmodem --rfsim --do-ra --log_config.global_log_options level,nocolor,time --rrc_config_path /home/ubuntu/tmp/cmake_targets/ran_build/build/\" > ./my-nr-softmodem-run.sh " >> $1 else #SA test => use --sa option - echo "echo \"./nr-uesoftmodem -r 106 --numerology 1 --band 78 -C 3619200000 --rfsim --sa --log_config.global_log_options level,nocolor\" > ./my-nr-softmodem-run.sh " >> $1 + echo "echo \"./nr-uesoftmodem -r 106 --numerology 1 --band 78 -C 3619200000 --rfsim --sa --log_config.global_log_options level,nocolor,time\" > ./my-nr-softmodem-run.sh " >> $1 fi fi echo "chmod 775 ./my-nr-softmodem-run.sh" >> $1 @@ -1472,13 +1472,18 @@ function run_test_on_vm { echo "############################################################" echo "OAI CI VM script" echo "############################################################" - if [[ (( "$RUN_OPTIONS" == "complex" ) && ( $VM_NAME =~ .*-l2-sim.* )) ]] || [[ (( "$RUN_OPTIONS" == "complex" ) && ( $VM_NAME =~ .*-rf-sim.* )) ]] + if [[ (( "$RUN_OPTIONS" == "complex" ) && ( $VM_NAME =~ .*-l2-sim.* )) ]] then - ENB_VM_NAME=`echo $VM_NAME | sed -e "s#l2-sim#enb-ethernet#" -e "s#rf-sim#enb-ethernet#"` + echo "This VM test type is no longer supported in the pipeline framework" + return + fi + if [[ (( "$RUN_OPTIONS" == "complex" ) && ( $VM_NAME =~ .*-rf-sim.* )) ]] + then + ENB_VM_NAME=`echo $VM_NAME | sed -e "s#rf-sim#enb-ethernet#"` ENB_VM_CMDS=${ENB_VM_NAME}_cmds.txt echo "ENB_VM_NAME = $ENB_VM_NAME" echo "ENB_VM_CMD_FILE = $ENB_VM_CMDS" - UE_VM_NAME=`echo $VM_NAME | sed -e "s#l2-sim#ue-ethernet#" -e "s#rf-sim#ue-ethernet#"` + UE_VM_NAME=`echo $VM_NAME | sed -e "s#rf-sim#ue-ethernet#"` UE_VM_CMDS=${UE_VM_NAME}_cmds.txt echo "UE_VM_NAME = $UE_VM_NAME" echo "UE_VM_CMD_FILE = $UE_VM_CMDS" @@ -1499,7 +1504,7 @@ function run_test_on_vm { echo "JENKINS_WKSP = $JENKINS_WKSP" echo "ARCHIVES_LOC = $ARCHIVES_LOC" - if [[ (( "$RUN_OPTIONS" == "complex" ) && ( $VM_NAME =~ .*-l2-sim.* )) ]] || [[ (( "$RUN_OPTIONS" == "complex" ) && ( $VM_NAME =~ .*-rf-sim.* )) ]] + if [[ (( "$RUN_OPTIONS" == "complex" ) && ( $VM_NAME =~ .*-rf-sim.* )) ]] then echo "############################################################" echo "Waiting for ENB VM to be started" diff --git a/ci-scripts/sshconnection.py b/ci-scripts/sshconnection.py index 67e0b832e66210e359690ff0a388c5013c3d1c5c..d5b4a4c83e459ce8825977420949b2fe6588152f 100644 --- a/ci-scripts/sshconnection.py +++ b/ci-scripts/sshconnection.py @@ -157,22 +157,24 @@ class SSHConnection(): if not silent: logging.debug(commandline) self.cmd2Results = '' + noHistoryCmd = 'unset HISTFILE; ' + commandline myHost = self.username + '@' + self.ipaddress # CAUTION: THIS METHOD IMPLIES THAT THERE ARE VALID SSH KEYS # BETWEEN THE PYTHON EXECUTOR NODE AND THE REMOTE HOST # OTHERWISE IT WON'T WORK - lSsh = subprocess.Popen(["ssh", "%s" % myHost, commandline],shell=False,stdout=subprocess.PIPE,stderr=subprocess.PIPE) + lSsh = subprocess.Popen(["ssh", "%s" % myHost, noHistoryCmd],shell=False,stdout=subprocess.PIPE,stderr=subprocess.PIPE) self.cmd2Results = str(lSsh.stdout.readlines()) def command3(self, commandline, timeout, silent=False): if not silent: logging.debug(commandline) self.cmd2Results = '' + noHistoryCmd = 'unset HISTFILE; ' + commandline myHost = self.username + '@' + self.ipaddress # CAUTION: THIS METHOD IMPLIES THAT THERE ARE VALID SSH KEYS # BETWEEN THE PYTHON EXECUTOR NODE AND THE REMOTE HOST # OTHERWISE IT WON'T WORK - lSsh = subprocess.Popen(["ssh", "%s" % myHost, commandline],shell=False,stdout=subprocess.PIPE,stderr=subprocess.PIPE) + lSsh = subprocess.Popen(["ssh", "%s" % myHost, noHistoryCmd],shell=False,stdout=subprocess.PIPE,stderr=subprocess.PIPE) return lSsh.stdout.readlines() diff --git a/ci-scripts/stats_monitor.py b/ci-scripts/stats_monitor.py index 933bf13203c7fe577d68f52b7438f7087683beb0..d7cad7ae554b7aa427030c569b3bf3ac31db79af 100755 --- a/ci-scripts/stats_monitor.py +++ b/ci-scripts/stats_monitor.py @@ -11,6 +11,7 @@ import pickle import matplotlib.pyplot as plt import numpy as np import yaml +import os class StatMonitor(): @@ -59,11 +60,21 @@ class StatMonitor(): self.d[node_type]['mcs'].append(int(result.group(4))) - def collect(self,node_type): + def collect(self,testcase_id,node_type): if node_type=='enb': - cmd='cat L1_stats.log MAC_stats.log PDCP_stats.log RRC_stats.log' + files = ["L1_stats.log", "MAC_stats.log", "PDCP_stats.log", "RRC_stats.log"] else: #'gnb' - cmd='cat nrL1_stats.log nrMAC_stats.log nrPDCP_stats.log nrRRC_stats.log' + files = ["nrL1_stats.log", "nrMAC_stats.log", "nrPDCP_stats.log", "nrRRC_stats.log"] + #append each file's contents to another file (prepended with CI-) for debug + for f in files: + if os.path.isfile(f): + cmd = 'cat '+ f + ' >> CI-'+testcase_id+'-'+f + subprocess.Popen(cmd,shell=True) + #join the files for further processing + cmd='cat ' + for f in files: + if os.path.isfile(f): + cmd += f+' ' process=subprocess.Popen(shlex.split(cmd), stdout=subprocess.PIPE) output = process.stdout.readlines() if node_type=='enb': @@ -72,7 +83,7 @@ class StatMonitor(): self.process_gnb(node_type,output) - def graph(self,node_type): + def graph(self,testcase_id, node_type): for page in self.d[node_type]['graph']:#work out a set a graphs per page col = 1 figure, axis = plt.subplots(len(self.d[node_type]['graph'][page]), col ,figsize=(10, 10)) @@ -103,13 +114,14 @@ class StatMonitor(): plt.tight_layout() #save as png - plt.savefig(node_type+'_stats_monitor_'+page+'.png') + plt.savefig(node_type+'_stats_monitor_'+testcase_id+'_'+page+'.png') if __name__ == "__main__": cfg_filename = sys.argv[1] #yaml file as metrics config - node = sys.argv[2]#enb or gnb + testcase_id = sys.argv[2] #test case id to name files accordingly, especially if we have several tests in a sequence + node = sys.argv[3]#enb or gnb mon=StatMonitor(cfg_filename) #collecting stats when modem process is stopped @@ -117,11 +129,11 @@ if __name__ == "__main__": process=subprocess.Popen(CMD, shell=True, stdout=subprocess.PIPE) output = process.stdout.readlines() while len(output)!=0 : - mon.collect(node) + mon.collect(testcase_id,node) process=subprocess.Popen(CMD, shell=True, stdout=subprocess.PIPE) output = process.stdout.readlines() time.sleep(1) print('Process stopped') with open(node+'_stats_monitor.pickle', 'wb') as handle: pickle.dump(mon.d, handle, protocol=pickle.HIGHEST_PROTOCOL) - mon.graph(node) + mon.graph(testcase_id, node) diff --git a/ci-scripts/stats_monitor.py.old b/ci-scripts/stats_monitor.py.old deleted file mode 100755 index ae9b39bfa632c5b85d24d494464b2ae001040cb3..0000000000000000000000000000000000000000 --- a/ci-scripts/stats_monitor.py.old +++ /dev/null @@ -1,94 +0,0 @@ -import subprocess -import time -import shlex -import re -import sys -import matplotlib.pyplot as plt -import pickle -import numpy as np -import os - -def collect(d, node_type): - if node_type=='enb': - cmd='cat L1_stats.log MAC_stats.log PDCP_stats.log RRC_stats.log' - else: #'gnb' - cmd='cat nrL1_stats.log nrMAC_stats.log nrPDCP_stats.log nrRRC_stats.log' - process=subprocess.Popen(shlex.split(cmd), stdout=subprocess.PIPE) - output = process.stdout.readlines() - for l in output: - tmp=l.decode("utf-8") - result=re.match(rf'^.*\bPHR\b ([0-9]+).+\bbler\b ([0-9]+\.[0-9]+).+\bmcsoff\b ([0-9]+).+\bmcs\b ([0-9]+)',tmp) - if result is not None: - d['PHR'].append(int(result.group(1))) - d['bler'].append(float(result.group(2))) - d['mcsoff'].append(int(result.group(3))) - d['mcs'].append(int(result.group(4))) - - -def graph(d, node_type): - - - figure, axis = plt.subplots(4, 1,figsize=(10, 10)) - - major_ticks = np.arange(0, len(d['PHR'])+1, 1) - axis[0].set_xticks(major_ticks) - axis[0].set_xticklabels([]) - axis[0].plot(d['PHR'],marker='o') - axis[0].set_xlabel('time') - axis[0].set_ylabel('PHR') - axis[0].set_title("PHR") - - major_ticks = np.arange(0, len(d['bler'])+1, 1) - axis[1].set_xticks(major_ticks) - axis[1].set_xticklabels([]) - axis[1].plot(d['bler'],marker='o') - axis[1].set_xlabel('time') - axis[1].set_ylabel('bler') - axis[1].set_title("bler") - - major_ticks = np.arange(0, len(d['mcsoff'])+1, 1) - axis[2].set_xticks(major_ticks) - axis[2].set_xticklabels([]) - axis[2].plot(d['mcsoff'],marker='o') - axis[2].set_xlabel('time') - axis[2].set_ylabel('mcsoff') - axis[2].set_title("mcsoff") - - major_ticks = np.arange(0, len(d['mcs'])+1, 1) - axis[3].set_xticks(major_ticks) - axis[3].set_xticklabels([]) - axis[3].plot(d['mcs'],marker='o') - axis[3].set_xlabel('time') - axis[3].set_ylabel('mcs') - axis[3].set_title("mcs") - - plt.tight_layout() - # Combine all the operations and display - plt.savefig(node_type+'_stats_monitor.png') - plt.show() - -if __name__ == "__main__": - - node_type = sys.argv[1]#enb or gnb - - d={} - d['PHR']=[] - d['bler']=[] - d['mcsoff']=[] - d['mcs']=[] - - - cmd='ps aux | grep modem | grep -v grep' - process=subprocess.Popen(cmd, shell=True, stdout=subprocess.PIPE) - output = process.stdout.readlines() - while len(output)!=0 : - collect(d, node_type) - process=subprocess.Popen(cmd, shell=True, stdout=subprocess.PIPE) - output = process.stdout.readlines() - time.sleep(1) - print('process stopped') - with open(node_type+'_stats_monitor.pickle', 'wb') as handle: - pickle.dump(d, handle, protocol=pickle.HIGHEST_PROTOCOL) - graph(d, node_type) - - diff --git a/ci-scripts/stats_monitor_dev.py b/ci-scripts/stats_monitor_dev.py deleted file mode 100755 index 83de20f5d25480f92d59698319231439b2c41231..0000000000000000000000000000000000000000 --- a/ci-scripts/stats_monitor_dev.py +++ /dev/null @@ -1,101 +0,0 @@ -""" -To create graphs and pickle from runtime statistics in L1,MAC,RRC,PDCP files -""" - -import subprocess -import time -import shlex -import re -import sys -import pickle -import matplotlib.pyplot as plt -import numpy as np -import yaml - - -class StatMonitor(): - def __init__(self,): - with open('stats_monitor_conf.yaml','r') as file: - self.d = yaml.load(file) - for node in self.d: - for metric in self.d[node]: - self.d[node][metric]=[] - - - def process_gnb (self,node_type,output): - for line in output: - tmp=line.decode("utf-8") - result=re.match(r'^.*\bdlsch_rounds\b ([0-9]+)\/([0-9]+).*\bdlsch_errors\b ([0-9]+)',tmp) - if result is not None: - self.d[node_type]['dlsch_err'].append(int(result.group(3))) - percentage=float(result.group(2))/float(result.group(1)) - self.d[node_type]['dlsch_err_perc_round_1'].append(percentage) - result=re.match(r'^.*\bulsch_rounds\b ([0-9]+)\/([0-9]+).*\bulsch_errors\b ([0-9]+)',tmp) - if result is not None: - self.d[node_type]['ulsch_err'].append(int(result.group(3))) - percentage=float(result.group(2))/float(result.group(1)) - self.d[node_type]['ulsch_err_perc_round_1'].append(percentage) - - - def process_enb (self,node_type,output): - for line in output: - tmp=line.decode("utf-8") - result=re.match(r'^.*\bPHR\b ([0-9]+).+\bbler\b ([0-9]+\.[0-9]+).+\bmcsoff\b ([0-9]+).+\bmcs\b ([0-9]+)',tmp) - if result is not None: - self.d[node_type]['PHR'].append(int(result.group(1))) - self.d[node_type]['bler'].append(float(result.group(2))) - self.d[node_type]['mcsoff'].append(int(result.group(3))) - self.d[node_type]['mcs'].append(int(result.group(4))) - - - def collect(self,node_type): - if node_type=='enb': - cmd='cat L1_stats.log MAC_stats.log PDCP_stats.log RRC_stats.log' - else: #'gnb' - cmd='cat nrL1_stats.log nrMAC_stats.log nrPDCP_stats.log nrRRC_stats.log' - process=subprocess.Popen(shlex.split(cmd), stdout=subprocess.PIPE) - output = process.stdout.readlines() - if node_type=='enb': - self.process_enb(node_type,output) - else: #'gnb' - self.process_gnb(node_type,output) - - - def graph(self,node_type): - col = 1 - figure, axis = plt.subplots(len(self.d[node_type]), col ,figsize=(10, 10)) - i=0 - for metric in self.d[node_type]: - major_ticks = np.arange(0, len(self.d[node_type][metric])+1, 1) - axis[i].set_xticks(major_ticks) - axis[i].set_xticklabels([]) - axis[i].plot(self.d[node_type][metric],marker='o') - axis[i].set_xlabel('time') - axis[i].set_ylabel(metric) - axis[i].set_title(metric) - i+=1 - - plt.tight_layout() - # Combine all the operations and display - plt.savefig(node_type+'_stats_monitor.png') - plt.show() - - -if __name__ == "__main__": - - node = sys.argv[1]#enb or gnb - mon=StatMonitor() - - #collecting stats when modem process is stopped - CMD='ps aux | grep mode | grep -v grep' - process=subprocess.Popen(CMD, shell=True, stdout=subprocess.PIPE) - output = process.stdout.readlines() - while len(output)!=0 : - mon.collect(node) - process=subprocess.Popen(CMD, shell=True, stdout=subprocess.PIPE) - output = process.stdout.readlines() - time.sleep(1) - print('Process stopped') - with open(node+'_stats_monitor.pickle', 'wb') as handle: - pickle.dump(mon.d, handle, protocol=pickle.HIGHEST_PROTOCOL) - mon.graph(node) diff --git a/ci-scripts/xml_files/benetel_nsa_quectel.xml b/ci-scripts/xml_files/benetel_nsa_quectel.xml index ed93f59e81cefff0d0b410c38f0636c5cd939452..8c284b6673bd5750fb163c41a838ce896c1ba6df 100644 --- a/ci-scripts/xml_files/benetel_nsa_quectel.xml +++ b/ci-scripts/xml_files/benetel_nsa_quectel.xml @@ -61,7 +61,7 @@ <testCase id="030000"> <class>Initialize_eNB</class> <desc>Initialize eNB</desc> - <Initialize_eNB_args>-O ci-scripts/conf_files/benetel-4g.conf</Initialize_eNB_args> + <Initialize_eNB_args>-O ci-scripts/conf_files/benetel-4g.conf --log_config.global_log_options level,nocolor,time,line_num,function</Initialize_eNB_args> <eNB_instance>0</eNB_instance> <eNB_serverId>0</eNB_serverId> <air_interface>lte</air_interface> @@ -71,7 +71,7 @@ <testCase id="040000"> <class>Initialize_eNB</class> <desc>Initialize gNB</desc> - <Initialize_eNB_args>-O ci-scripts/conf_files/benetel-5g.conf -q</Initialize_eNB_args> + <Initialize_eNB_args>-O ci-scripts/conf_files/benetel-5g.conf -q --log_config.global_log_options level,nocolor,time,line_num,function</Initialize_eNB_args> <eNB_instance>1</eNB_instance> <eNB_serverId>1</eNB_serverId> <air_interface>nr</air_interface> diff --git a/ci-scripts/xml_files/benetel_nsa_quectel_longrun.xml b/ci-scripts/xml_files/benetel_nsa_quectel_longrun.xml index 93c0c5a00a209659092d47b39787086b48dc30da..2e4494c81995985dff095b803f8e47984e4ec185 100644 --- a/ci-scripts/xml_files/benetel_nsa_quectel_longrun.xml +++ b/ci-scripts/xml_files/benetel_nsa_quectel_longrun.xml @@ -63,7 +63,7 @@ <testCase id="030000"> <class>Initialize_eNB</class> <desc>Initialize eNB</desc> - <Initialize_eNB_args>-O ci-scripts/conf_files/benetel-4g.conf</Initialize_eNB_args> + <Initialize_eNB_args>-O ci-scripts/conf_files/benetel-4g.conf --log_config.global_log_options level,nocolor,time,line_num,function</Initialize_eNB_args> <eNB_instance>0</eNB_instance> <eNB_serverId>0</eNB_serverId> <air_interface>lte</air_interface> @@ -73,7 +73,7 @@ <testCase id="040000"> <class>Initialize_eNB</class> <desc>Initialize gNB</desc> - <Initialize_eNB_args>-O ci-scripts/conf_files/benetel-5g.conf -q</Initialize_eNB_args> + <Initialize_eNB_args>-O ci-scripts/conf_files/benetel-5g.conf -q --log_config.global_log_options level,nocolor,time,line_num,function</Initialize_eNB_args> <eNB_instance>1</eNB_instance> <eNB_serverId>1</eNB_serverId> <air_interface>nr</air_interface> diff --git a/ci-scripts/xml_files/container_4g_rfsim.xml b/ci-scripts/xml_files/container_4g_rfsim_fdd_05MHz.xml similarity index 87% rename from ci-scripts/xml_files/container_4g_rfsim.xml rename to ci-scripts/xml_files/container_4g_rfsim_fdd_05MHz.xml index 7f13d599b8945efae275790a161b55b4f2595ed7..fd254f185677c81ee189f636dbef00b7eb3bbf21 100644 --- a/ci-scripts/xml_files/container_4g_rfsim.xml +++ b/ci-scripts/xml_files/container_4g_rfsim_fdd_05MHz.xml @@ -21,10 +21,9 @@ --> <testCaseList> - <htmlTabRef>rfsim-4glte</htmlTabRef> - <htmlTabName>Testing 4G LTE RF sim in containers</htmlTabName> + <htmlTabRef>rfsim-4glte-fdd05mhz</htmlTabRef> + <htmlTabName>Monolithic eNB - FDD 05MHz</htmlTabName> <htmlTabIcon>wrench</htmlTabIcon> - <repeatCount>2</repeatCount> <TestCaseRequestedList> 100011 000011 @@ -46,7 +45,7 @@ <testCase id="000011"> <class>DeployGenObject</class> <desc>Deploy Cassandra Database</desc> - <yaml_path>yaml_files/4g_rfsimulator</yaml_path> + <yaml_path>yaml_files/4g_rfsimulator_fdd_05MHz</yaml_path> <services>cassandra db_init</services> <nb_healthy>1</nb_healthy> </testCase> @@ -66,23 +65,23 @@ <testCase id="000012"> <class>DeployGenObject</class> <desc>Deploy OAI 4G CoreNetwork</desc> - <yaml_path>yaml_files/4g_rfsimulator</yaml_path> + <yaml_path>yaml_files/4g_rfsimulator_fdd_05MHz</yaml_path> <services>oai_hss oai_mme oai_spgwc oai_spgwu trf_gen</services> <nb_healthy>6</nb_healthy> </testCase> <testCase id="000013"> <class>DeployGenObject</class> - <desc>Deploy OAI 4G eNB RF sim</desc> - <yaml_path>yaml_files/4g_rfsimulator</yaml_path> + <desc>Deploy OAI 4G eNB RF sim (FDD 05MHz)</desc> + <yaml_path>yaml_files/4g_rfsimulator_fdd_05MHz</yaml_path> <services>enb</services> <nb_healthy>7</nb_healthy> </testCase> <testCase id="000014"> <class>DeployGenObject</class> - <desc>Deploy OAI 4G NR-UE RF sim</desc> - <yaml_path>yaml_files/4g_rfsimulator</yaml_path> + <desc>Deploy OAI 4G NR-UE RF sim (FDD 05MHz)</desc> + <yaml_path>yaml_files/4g_rfsimulator_fdd_05MHz</yaml_path> <services>oai_ue0</services> <nb_healthy>8</nb_healthy> </testCase> @@ -124,7 +123,7 @@ <testCase id="100011"> <class>UndeployGenObject</class> <desc>Undeploy all OAI 4G stack</desc> - <yaml_path>yaml_files/4g_rfsimulator</yaml_path> + <yaml_path>yaml_files/4g_rfsimulator_fdd_05MHz</yaml_path> </testCase> </testCaseList> diff --git a/ci-scripts/xml_files/container_4g_rfsim_down.xml b/ci-scripts/xml_files/container_4g_rfsim_fdd_05MHz_down.xml similarity index 90% rename from ci-scripts/xml_files/container_4g_rfsim_down.xml rename to ci-scripts/xml_files/container_4g_rfsim_fdd_05MHz_down.xml index dee516d9248e1ea3dd2141dca5fa7f5e2987f3d2..1c3b1d5a7c3b37cd901258d110cae313c14069a4 100644 --- a/ci-scripts/xml_files/container_4g_rfsim_down.xml +++ b/ci-scripts/xml_files/container_4g_rfsim_fdd_05MHz_down.xml @@ -21,7 +21,7 @@ --> <testCaseList> - <htmlTabRef>rfsim-4glte-down</htmlTabRef> + <htmlTabRef>rfsim-4glte-fdd05mhz-down</htmlTabRef> <htmlTabName>CleanUp 4G RF</htmlTabName> <htmlTabIcon>trash</htmlTabIcon> <TestCaseRequestedList> @@ -32,7 +32,7 @@ <testCase id="100011"> <class>UndeployGenObject</class> <desc>Undeploy all OAI 4G stack</desc> - <yaml_path>yaml_files/4g_rfsimulator</yaml_path> + <yaml_path>yaml_files/4g_rfsimulator_fdd_05MHz</yaml_path> </testCase> </testCaseList> diff --git a/ci-scripts/xml_files/container_4g_rfsim_fdd_05MHz_noS1.xml b/ci-scripts/xml_files/container_4g_rfsim_fdd_05MHz_noS1.xml new file mode 100644 index 0000000000000000000000000000000000000000..2ff9461b9361d490d8574d0a89034444449db4c0 --- /dev/null +++ b/ci-scripts/xml_files/container_4g_rfsim_fdd_05MHz_noS1.xml @@ -0,0 +1,109 @@ +<!-- + + 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 + +--> +<testCaseList> + <htmlTabRef>rfsim-4glte-fdd05mhz-noS1</htmlTabRef> + <htmlTabName>Monolithic eNB - FDD 05MHz - noS1</htmlTabName> + <htmlTabIcon>wrench</htmlTabIcon> + <TestCaseRequestedList> + 100011 + 000013 + 000001 + 000014 + 000002 + 020011 + 020012 + 030011 + 030012 + 100011 + </TestCaseRequestedList> + <TestCaseExclusionList></TestCaseExclusionList> + + <testCase id="000001"> + <class>IdleSleep</class> + <desc>Sleep</desc> + <idle_sleep_time_in_sec>30</idle_sleep_time_in_sec> + </testCase> + + <testCase id="000002"> + <class>IdleSleep</class> + <desc>Sleep</desc> + <idle_sleep_time_in_sec>10</idle_sleep_time_in_sec> + </testCase> + + <testCase id="000013"> + <class>DeployGenObject</class> + <desc>Deploy OAI 4G eNB RF sim (FDD 05MHz)</desc> + <yaml_path>yaml_files/4g_rfsimulator_fdd_05MHz_noS1</yaml_path> + <services>enb</services> + <nb_healthy>1</nb_healthy> + </testCase> + + <testCase id="000014"> + <class>DeployGenObject</class> + <desc>Deploy OAI 4G NR-UE RF sim (FDD 05MHz)</desc> + <yaml_path>yaml_files/4g_rfsimulator_fdd_05MHz_noS1</yaml_path> + <services>oai_ue0</services> + <nb_healthy>2</nb_healthy> + </testCase> + + <testCase id="020011"> + <class>PingFromContainer</class> + <desc>Ping Traffic-Gen from LTE-UE</desc> + <container_name>rfsim4g-oai-lte-ue0</container_name> + <options>-I oaitun_ue1 -c 20 10.0.1.1</options> + <loss_threshold>5</loss_threshold> + </testCase> + + <testCase id="020012"> + <class>PingFromContainer</class> + <desc>Ping LTE-UE from eNB</desc> + <container_name>rfsim4g-oai-enb</container_name> + <options>-I oaitun_enb1 -c 20 10.0.1.2</options> + <loss_threshold>5</loss_threshold> + </testCase> + + <testCase id="030011"> + <class>IperfFromContainer</class> + <desc>Iperf UDP Downlink</desc> + <server_container_name>rfsim4g-oai-lte-ue0</server_container_name> + <client_container_name>rfsim4g-oai-enb</client_container_name> + <server_options>-B 10.0.1.2 -u -i 1 -s</server_options> + <client_options>-B 10.0.1.1 -c 10.0.1.2 -u -i 1 -t 30 -b 2M</client_options> + </testCase> + + <testCase id="030012"> + <class>IperfFromContainer</class> + <desc>Iperf UDP Uplink</desc> + <server_container_name>rfsim4g-oai-enb</server_container_name> + <client_container_name>rfsim4g-oai-lte-ue0</client_container_name> + <server_options>-B 10.0.1.1 -u -i 1 -s</server_options> + <client_options>-B 10.0.1.2 -c 10.0.1.1 -u -i 1 -t 30 -b 1M</client_options> + </testCase> + + <testCase id="100011"> + <class>UndeployGenObject</class> + <desc>Undeploy all OAI 4G stack</desc> + <yaml_path>yaml_files/4g_rfsimulator_fdd_05MHz_noS1</yaml_path> + </testCase> + +</testCaseList> diff --git a/ci-scripts/xml_files/container_4g_rfsim_fdd_05MHz_noS1_down.xml b/ci-scripts/xml_files/container_4g_rfsim_fdd_05MHz_noS1_down.xml new file mode 100644 index 0000000000000000000000000000000000000000..6db1dfd9de73d167e0c58424c650cdf7dd867fc4 --- /dev/null +++ b/ci-scripts/xml_files/container_4g_rfsim_fdd_05MHz_noS1_down.xml @@ -0,0 +1,38 @@ +<!-- + + 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 + +--> +<testCaseList> + <htmlTabRef>rfsim-4glte-fdd05mhz-nos1-down</htmlTabRef> + <htmlTabName>CleanUp 4G RF</htmlTabName> + <htmlTabIcon>trash</htmlTabIcon> + <TestCaseRequestedList> + 100011 + </TestCaseRequestedList> + <TestCaseExclusionList></TestCaseExclusionList> + + <testCase id="100011"> + <class>UndeployGenObject</class> + <desc>Undeploy all OAI 4G stack</desc> + <yaml_path>yaml_files/4g_rfsimulator_fdd_05MHz_noS1</yaml_path> + </testCase> + +</testCaseList> diff --git a/ci-scripts/xml_files/container_4g_rfsim_fdd_10MHz.xml b/ci-scripts/xml_files/container_4g_rfsim_fdd_10MHz.xml new file mode 100644 index 0000000000000000000000000000000000000000..f00e277c36f3bb7e91ad96f4737c895017323967 --- /dev/null +++ b/ci-scripts/xml_files/container_4g_rfsim_fdd_10MHz.xml @@ -0,0 +1,129 @@ +<!-- + + 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 + +--> +<testCaseList> + <htmlTabRef>rfsim-4glte-fdd10mhz</htmlTabRef> + <htmlTabName>Monolithic eNB - FDD 10MHz</htmlTabName> + <htmlTabIcon>wrench</htmlTabIcon> + <TestCaseRequestedList> + 100011 + 000011 + 000001 + 000012 + 000002 + 000013 + 000001 + 000014 + 000002 + 020011 + 020012 + 030011 + 030012 + 100011 + </TestCaseRequestedList> + <TestCaseExclusionList></TestCaseExclusionList> + + <testCase id="000011"> + <class>DeployGenObject</class> + <desc>Deploy Cassandra Database</desc> + <yaml_path>yaml_files/4g_rfsimulator_fdd_10MHz</yaml_path> + <services>cassandra db_init</services> + <nb_healthy>1</nb_healthy> + </testCase> + + <testCase id="000001"> + <class>IdleSleep</class> + <desc>Sleep</desc> + <idle_sleep_time_in_sec>30</idle_sleep_time_in_sec> + </testCase> + + <testCase id="000002"> + <class>IdleSleep</class> + <desc>Sleep</desc> + <idle_sleep_time_in_sec>10</idle_sleep_time_in_sec> + </testCase> + + <testCase id="000012"> + <class>DeployGenObject</class> + <desc>Deploy OAI 4G CoreNetwork</desc> + <yaml_path>yaml_files/4g_rfsimulator_fdd_10MHz</yaml_path> + <services>oai_hss oai_mme oai_spgwc oai_spgwu trf_gen</services> + <nb_healthy>6</nb_healthy> + </testCase> + + <testCase id="000013"> + <class>DeployGenObject</class> + <desc>Deploy OAI 4G eNB RF sim (FDD 10MHz)</desc> + <yaml_path>yaml_files/4g_rfsimulator_fdd_10MHz</yaml_path> + <services>enb</services> + <nb_healthy>7</nb_healthy> + </testCase> + + <testCase id="000014"> + <class>DeployGenObject</class> + <desc>Deploy OAI 4G NR-UE RF sim (FDD 10MHz)</desc> + <yaml_path>yaml_files/4g_rfsimulator_fdd_10MHz</yaml_path> + <services>oai_ue0</services> + <nb_healthy>8</nb_healthy> + </testCase> + + <testCase id="020011"> + <class>PingFromContainer</class> + <desc>Ping Traffic-Gen from LTE-UE</desc> + <container_name>rfsim4g-oai-lte-ue0</container_name> + <options>-I oaitun_ue1 -c 20 192.168.61.11</options> + <loss_threshold>5</loss_threshold> + </testCase> + + <testCase id="020012"> + <class>PingFromContainer</class> + <desc>Ping LTE-UE from Traffic-Gen</desc> + <container_name>rfsim4g-trf-gen</container_name> + <options>-c 20 12.0.0.2</options> + <loss_threshold>5</loss_threshold> + </testCase> + + <testCase id="030011"> + <class>IperfFromContainer</class> + <desc>Iperf UDP Downlink</desc> + <server_container_name>rfsim4g-oai-lte-ue0</server_container_name> + <client_container_name>rfsim4g-trf-gen</client_container_name> + <server_options>-B 12.0.0.2 -u -i 1 -s</server_options> + <client_options>-c 12.0.0.2 -u -i 1 -t 30 -b 2M</client_options> + </testCase> + + <testCase id="030012"> + <class>IperfFromContainer</class> + <desc>Iperf UDP Uplink</desc> + <server_container_name>rfsim4g-trf-gen</server_container_name> + <client_container_name>rfsim4g-oai-lte-ue0</client_container_name> + <server_options>-u -i 1 -s</server_options> + <client_options>-B 12.0.0.2 -c 192.168.61.11 -u -i 1 -t 30 -b 1M</client_options> + </testCase> + + <testCase id="100011"> + <class>UndeployGenObject</class> + <desc>Undeploy all OAI 4G stack</desc> + <yaml_path>yaml_files/4g_rfsimulator_fdd_10MHz</yaml_path> + </testCase> + +</testCaseList> diff --git a/ci-scripts/xml_files/container_4g_rfsim_fdd_10MHz_down.xml b/ci-scripts/xml_files/container_4g_rfsim_fdd_10MHz_down.xml new file mode 100644 index 0000000000000000000000000000000000000000..7d03d56ff4ce72c2031c96fc6781ba8118ecaa32 --- /dev/null +++ b/ci-scripts/xml_files/container_4g_rfsim_fdd_10MHz_down.xml @@ -0,0 +1,38 @@ +<!-- + + 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 + +--> +<testCaseList> + <htmlTabRef>rfsim-4glte-fdd10mhz-down</htmlTabRef> + <htmlTabName>CleanUp 4G RF</htmlTabName> + <htmlTabIcon>trash</htmlTabIcon> + <TestCaseRequestedList> + 100011 + </TestCaseRequestedList> + <TestCaseExclusionList></TestCaseExclusionList> + + <testCase id="100011"> + <class>UndeployGenObject</class> + <desc>Undeploy all OAI 4G stack</desc> + <yaml_path>yaml_files/4g_rfsimulator_fdd_10MHz</yaml_path> + </testCase> + +</testCaseList> diff --git a/ci-scripts/xml_files/container_4g_rfsim_fdd_20MHz.xml b/ci-scripts/xml_files/container_4g_rfsim_fdd_20MHz.xml new file mode 100644 index 0000000000000000000000000000000000000000..52e1ac7de18ee874300c685e2c0ae62282556e81 --- /dev/null +++ b/ci-scripts/xml_files/container_4g_rfsim_fdd_20MHz.xml @@ -0,0 +1,129 @@ +<!-- + + 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 + +--> +<testCaseList> + <htmlTabRef>rfsim-4glte-fdd20mhz</htmlTabRef> + <htmlTabName>Monolithic eNB - FDD 20MHz</htmlTabName> + <htmlTabIcon>wrench</htmlTabIcon> + <TestCaseRequestedList> + 100011 + 000011 + 000001 + 000012 + 000002 + 000013 + 000001 + 000014 + 000002 + 020011 + 020012 + 030011 + 030012 + 100011 + </TestCaseRequestedList> + <TestCaseExclusionList></TestCaseExclusionList> + + <testCase id="000011"> + <class>DeployGenObject</class> + <desc>Deploy Cassandra Database</desc> + <yaml_path>yaml_files/4g_rfsimulator_fdd_20MHz</yaml_path> + <services>cassandra db_init</services> + <nb_healthy>1</nb_healthy> + </testCase> + + <testCase id="000001"> + <class>IdleSleep</class> + <desc>Sleep</desc> + <idle_sleep_time_in_sec>30</idle_sleep_time_in_sec> + </testCase> + + <testCase id="000002"> + <class>IdleSleep</class> + <desc>Sleep</desc> + <idle_sleep_time_in_sec>10</idle_sleep_time_in_sec> + </testCase> + + <testCase id="000012"> + <class>DeployGenObject</class> + <desc>Deploy OAI 4G CoreNetwork</desc> + <yaml_path>yaml_files/4g_rfsimulator_fdd_20MHz</yaml_path> + <services>oai_hss oai_mme oai_spgwc oai_spgwu trf_gen</services> + <nb_healthy>6</nb_healthy> + </testCase> + + <testCase id="000013"> + <class>DeployGenObject</class> + <desc>Deploy OAI 4G eNB RF sim (FDD 20MHz)</desc> + <yaml_path>yaml_files/4g_rfsimulator_fdd_20MHz</yaml_path> + <services>enb</services> + <nb_healthy>7</nb_healthy> + </testCase> + + <testCase id="000014"> + <class>DeployGenObject</class> + <desc>Deploy OAI 4G NR-UE RF sim (FDD 20MHz)</desc> + <yaml_path>yaml_files/4g_rfsimulator_fdd_20MHz</yaml_path> + <services>oai_ue0</services> + <nb_healthy>8</nb_healthy> + </testCase> + + <testCase id="020011"> + <class>PingFromContainer</class> + <desc>Ping Traffic-Gen from LTE-UE</desc> + <container_name>rfsim4g-oai-lte-ue0</container_name> + <options>-I oaitun_ue1 -c 20 192.168.61.11</options> + <loss_threshold>5</loss_threshold> + </testCase> + + <testCase id="020012"> + <class>PingFromContainer</class> + <desc>Ping LTE-UE from Traffic-Gen</desc> + <container_name>rfsim4g-trf-gen</container_name> + <options>-c 20 12.0.0.2</options> + <loss_threshold>5</loss_threshold> + </testCase> + + <testCase id="030011"> + <class>IperfFromContainer</class> + <desc>Iperf UDP Downlink</desc> + <server_container_name>rfsim4g-oai-lte-ue0</server_container_name> + <client_container_name>rfsim4g-trf-gen</client_container_name> + <server_options>-B 12.0.0.2 -u -i 1 -s</server_options> + <client_options>-c 12.0.0.2 -u -i 1 -t 30 -b 2M</client_options> + </testCase> + + <testCase id="030012"> + <class>IperfFromContainer</class> + <desc>Iperf UDP Uplink</desc> + <server_container_name>rfsim4g-trf-gen</server_container_name> + <client_container_name>rfsim4g-oai-lte-ue0</client_container_name> + <server_options>-u -i 1 -s</server_options> + <client_options>-B 12.0.0.2 -c 192.168.61.11 -u -i 1 -t 30 -b 1M</client_options> + </testCase> + + <testCase id="100011"> + <class>UndeployGenObject</class> + <desc>Undeploy all OAI 4G stack</desc> + <yaml_path>yaml_files/4g_rfsimulator_fdd_20MHz</yaml_path> + </testCase> + +</testCaseList> diff --git a/ci-scripts/xml_files/container_4g_rfsim_fdd_20MHz_down.xml b/ci-scripts/xml_files/container_4g_rfsim_fdd_20MHz_down.xml new file mode 100644 index 0000000000000000000000000000000000000000..0a721c5091697d0e2eba6daeed239b34f4dfc9bf --- /dev/null +++ b/ci-scripts/xml_files/container_4g_rfsim_fdd_20MHz_down.xml @@ -0,0 +1,38 @@ +<!-- + + 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 + +--> +<testCaseList> + <htmlTabRef>rfsim-4glte-fdd20mhz-down</htmlTabRef> + <htmlTabName>CleanUp 4G RF</htmlTabName> + <htmlTabIcon>trash</htmlTabIcon> + <TestCaseRequestedList> + 100011 + </TestCaseRequestedList> + <TestCaseExclusionList></TestCaseExclusionList> + + <testCase id="100011"> + <class>UndeployGenObject</class> + <desc>Undeploy all OAI 4G stack</desc> + <yaml_path>yaml_files/4g_rfsimulator_fdd_20MHz</yaml_path> + </testCase> + +</testCaseList> diff --git a/ci-scripts/xml_files/container_4g_rfsim_tdd_05MHz.xml b/ci-scripts/xml_files/container_4g_rfsim_tdd_05MHz.xml new file mode 100644 index 0000000000000000000000000000000000000000..cdaee430efc3c092a5cfd60cb95e94d10c0c7975 --- /dev/null +++ b/ci-scripts/xml_files/container_4g_rfsim_tdd_05MHz.xml @@ -0,0 +1,130 @@ +<!-- + + 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 + +--> +<testCaseList> + <htmlTabRef>rfsim-4glte-tdd05mhz</htmlTabRef> + <htmlTabName>Monolithic eNB - TDD 05MHz</htmlTabName> + <htmlTabIcon>wrench</htmlTabIcon> + <repeatCount>2</repeatCount> + <TestCaseRequestedList> + 100011 + 000011 + 000001 + 000012 + 000002 + 000013 + 000001 + 000014 + 000002 + 020011 + 020012 + 030011 + 030012 + 100011 + </TestCaseRequestedList> + <TestCaseExclusionList></TestCaseExclusionList> + + <testCase id="000011"> + <class>DeployGenObject</class> + <desc>Deploy Cassandra Database</desc> + <yaml_path>yaml_files/4g_rfsimulator_tdd_05MHz</yaml_path> + <services>cassandra db_init</services> + <nb_healthy>1</nb_healthy> + </testCase> + + <testCase id="000001"> + <class>IdleSleep</class> + <desc>Sleep</desc> + <idle_sleep_time_in_sec>30</idle_sleep_time_in_sec> + </testCase> + + <testCase id="000002"> + <class>IdleSleep</class> + <desc>Sleep</desc> + <idle_sleep_time_in_sec>10</idle_sleep_time_in_sec> + </testCase> + + <testCase id="000012"> + <class>DeployGenObject</class> + <desc>Deploy OAI 4G CoreNetwork</desc> + <yaml_path>yaml_files/4g_rfsimulator_tdd_05MHz</yaml_path> + <services>oai_hss oai_mme oai_spgwc oai_spgwu trf_gen</services> + <nb_healthy>6</nb_healthy> + </testCase> + + <testCase id="000013"> + <class>DeployGenObject</class> + <desc>Deploy OAI 4G eNB RF sim (TDD 05MHz)</desc> + <yaml_path>yaml_files/4g_rfsimulator_tdd_05MHz</yaml_path> + <services>enb</services> + <nb_healthy>7</nb_healthy> + </testCase> + + <testCase id="000014"> + <class>DeployGenObject</class> + <desc>Deploy OAI 4G NR-UE RF sim (TDD 05MHz)</desc> + <yaml_path>yaml_files/4g_rfsimulator_tdd_05MHz</yaml_path> + <services>oai_ue0</services> + <nb_healthy>8</nb_healthy> + </testCase> + + <testCase id="020011"> + <class>PingFromContainer</class> + <desc>Ping Traffic-Gen from LTE-UE</desc> + <container_name>rfsim4g-oai-lte-ue0</container_name> + <options>-I oaitun_ue1 -c 20 192.168.61.11</options> + <loss_threshold>5</loss_threshold> + </testCase> + + <testCase id="020012"> + <class>PingFromContainer</class> + <desc>Ping LTE-UE from Traffic-Gen</desc> + <container_name>rfsim4g-trf-gen</container_name> + <options>-c 20 12.0.0.2</options> + <loss_threshold>5</loss_threshold> + </testCase> + + <testCase id="030011"> + <class>IperfFromContainer</class> + <desc>Iperf UDP Downlink</desc> + <server_container_name>rfsim4g-oai-lte-ue0</server_container_name> + <client_container_name>rfsim4g-trf-gen</client_container_name> + <server_options>-B 12.0.0.2 -u -i 1 -s</server_options> + <client_options>-c 12.0.0.2 -u -i 1 -t 30 -b 2M</client_options> + </testCase> + + <testCase id="030012"> + <class>IperfFromContainer</class> + <desc>Iperf UDP Uplink</desc> + <server_container_name>rfsim4g-trf-gen</server_container_name> + <client_container_name>rfsim4g-oai-lte-ue0</client_container_name> + <server_options>-u -i 1 -s</server_options> + <client_options>-B 12.0.0.2 -c 192.168.61.11 -u -i 1 -t 30 -b 1M</client_options> + </testCase> + + <testCase id="100011"> + <class>UndeployGenObject</class> + <desc>Undeploy all OAI 4G stack</desc> + <yaml_path>yaml_files/4g_rfsimulator_tdd_05MHz</yaml_path> + </testCase> + +</testCaseList> diff --git a/ci-scripts/xml_files/container_4g_rfsim_tdd_05MHz_down.xml b/ci-scripts/xml_files/container_4g_rfsim_tdd_05MHz_down.xml new file mode 100644 index 0000000000000000000000000000000000000000..7e27bac73c4200339e1cf94e06a568150a5c130c --- /dev/null +++ b/ci-scripts/xml_files/container_4g_rfsim_tdd_05MHz_down.xml @@ -0,0 +1,38 @@ +<!-- + + 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 + +--> +<testCaseList> + <htmlTabRef>rfsim-4glte-tdd05mhz-down</htmlTabRef> + <htmlTabName>CleanUp 4G RF</htmlTabName> + <htmlTabIcon>trash</htmlTabIcon> + <TestCaseRequestedList> + 100011 + </TestCaseRequestedList> + <TestCaseExclusionList></TestCaseExclusionList> + + <testCase id="100011"> + <class>UndeployGenObject</class> + <desc>Undeploy all OAI 4G stack</desc> + <yaml_path>yaml_files/4g_rfsimulator_tdd_05MHz</yaml_path> + </testCase> + +</testCaseList> diff --git a/ci-scripts/xml_files/container_5g_f1_rfsim.xml b/ci-scripts/xml_files/container_5g_f1_rfsim.xml new file mode 100644 index 0000000000000000000000000000000000000000..501f2fe46ff6043468c0b3e7e940bfb8ee36932e --- /dev/null +++ b/ci-scripts/xml_files/container_5g_f1_rfsim.xml @@ -0,0 +1,121 @@ +<!-- + + 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 + +--> +<testCaseList> + <htmlTabRef>rfsim-5gnr-f1</htmlTabRef> + <htmlTabName>Testing 5G NR RF sim in containers - CU-DU F1 split</htmlTabName> + <htmlTabIcon>wrench</htmlTabIcon> + <TestCaseRequestedList> + 100021 + 000020 + 000021 + 000022 + 000023 + 000024 + 020021 + 020022 + 030021 + 100021 + </TestCaseRequestedList> + <TestCaseExclusionList></TestCaseExclusionList> + + <testCase id="000020"> + <class>DeployGenObject</class> + <desc>Deploy MySql Database</desc> + <yaml_path>yaml_files/5g_f1_rfsimulator</yaml_path> + <services>mysql</services> + <nb_healthy>1</nb_healthy> + </testCase> + + <testCase id="000021"> + <class>DeployGenObject</class> + <desc>Deploy OAI 5G CoreNetwork</desc> + <yaml_path>yaml_files/5g_f1_rfsimulator</yaml_path> + <services>oai-nrf oai-amf oai-smf oai-spgwu oai-ext-dn</services> + <nb_healthy>6</nb_healthy> + </testCase> + + <testCase id="000022"> + <class>DeployGenObject</class> + <desc>Deploy OAI 5G CU RF sim SA</desc> + <yaml_path>yaml_files/5g_f1_rfsimulator</yaml_path> + <services>oai-cu</services> + <nb_healthy>7</nb_healthy> + </testCase> + + <testCase id="000023"> + <class>DeployGenObject</class> + <desc>Deploy OAI 5G DU RF sim SA</desc> + <yaml_path>yaml_files/5g_f1_rfsimulator</yaml_path> + <services>oai-du</services> + <nb_healthy>8</nb_healthy> + </testCase> + + <testCase id="000024"> + <class>DeployGenObject</class> + <desc>Deploy OAI 5G NR-UE RF sim SA</desc> + <yaml_path>yaml_files/5g_f1_rfsimulator</yaml_path> + <services>oai-nr-ue</services> + <nb_healthy>9</nb_healthy> + </testCase> + + <testCase id="020021"> + <class>PingFromContainer</class> + <desc>Ping ext-dn from NR-UE</desc> + <container_name>rfsim5g-oai-nr-ue</container_name> + <options>-I oaitun_ue1 -c 20 192.168.72.135</options> + <loss_threshold>5</loss_threshold> + </testCase> + + <testCase id="020022"> + <class>PingFromContainer</class> + <desc>Ping NR-UE from ext-dn</desc> + <container_name>rfsim5g-oai-ext-dn</container_name> + <options>-c 20 12.1.1.2</options> + <loss_threshold>5</loss_threshold> + </testCase> + + <testCase id="030021"> + <class>IperfFromContainer</class> + <desc>Iperf UDP Downlink</desc> + <server_container_name>rfsim5g-oai-nr-ue</server_container_name> + <client_container_name>rfsim5g-oai-ext-dn</client_container_name> + <server_options>-B 12.1.1.2 -u -i 1 -s</server_options> + <client_options>-c 12.1.1.2 -u -i 1 -t 30 -b 200K</client_options> + </testCase> + + <testCase id="030022"> + <class>IperfFromContainer</class> + <desc>Iperf UDP Uplink</desc> + <server_container_name>rfsim5g-oai-ext-dn</server_container_name> + <client_container_name>rfsim5g-oai-nr-ue</client_container_name> + <server_options>-u -i 1 -s</server_options> + <client_options>-B 12.1.1.2 -c 192.168.72.135 -u -i 1 -t 30 -b 5K</client_options> + </testCase> + + <testCase id="100021"> + <class>UndeployGenObject</class> + <desc>Undeploy all OAI 5G stack</desc> + <yaml_path>yaml_files/5g_f1_rfsimulator</yaml_path> + </testCase> + +</testCaseList> diff --git a/ci-scripts/xml_files/container_5g_f1_rfsim_down.xml b/ci-scripts/xml_files/container_5g_f1_rfsim_down.xml new file mode 100644 index 0000000000000000000000000000000000000000..ac3f7347bae311790ef413c98660ef4a446877eb --- /dev/null +++ b/ci-scripts/xml_files/container_5g_f1_rfsim_down.xml @@ -0,0 +1,38 @@ +<!-- + + 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 + +--> +<testCaseList> + <htmlTabRef>rfsim-5gnr-down-f1</htmlTabRef> + <htmlTabName>CleanUp 5G RF - CU-DU F1 split</htmlTabName> + <htmlTabIcon>trash</htmlTabIcon> + <TestCaseRequestedList> + 100022 + </TestCaseRequestedList> + <TestCaseExclusionList></TestCaseExclusionList> + + <testCase id="100022"> + <class>UndeployGenObject</class> + <desc>Undeploy all OAI 5G stack</desc> + <yaml_path>yaml_files/5g_f1_rfsimulator</yaml_path> + </testCase> + +</testCaseList> diff --git a/ci-scripts/xml_files/container_5g_rfsim.xml b/ci-scripts/xml_files/container_5g_rfsim.xml index 11f85688ecea2b2e26211169be214413190c49e0..d1114616a85e6815a53d3bae280a2914a6973662 100644 --- a/ci-scripts/xml_files/container_5g_rfsim.xml +++ b/ci-scripts/xml_files/container_5g_rfsim.xml @@ -22,11 +22,12 @@ --> <testCaseList> <htmlTabRef>rfsim-5gnr</htmlTabRef> - <htmlTabName>Testing 5G NR RF sim in containers</htmlTabName> + <htmlTabName>Testing 5G NR RF sim - Monolithic gNB</htmlTabName> <htmlTabIcon>wrench</htmlTabIcon> <repeatCount>4</repeatCount> <TestCaseRequestedList> 100001 + 000000 000001 000002 000003 @@ -38,11 +39,19 @@ </TestCaseRequestedList> <TestCaseExclusionList></TestCaseExclusionList> + <testCase id="000000"> + <class>DeployGenObject</class> + <desc>Deploy MySql Database</desc> + <yaml_path>yaml_files/5g_rfsimulator</yaml_path> + <services>mysql</services> + <nb_healthy>1</nb_healthy> + </testCase> + <testCase id="000001"> <class>DeployGenObject</class> <desc>Deploy OAI 5G CoreNetwork</desc> <yaml_path>yaml_files/5g_rfsimulator</yaml_path> - <services>mysql oai-nrf oai-amf oai-smf oai-spgwu oai-ext-dn</services> + <services>oai-nrf oai-amf oai-smf oai-spgwu oai-ext-dn</services> <nb_healthy>6</nb_healthy> </testCase> @@ -84,7 +93,7 @@ <server_container_name>rfsim5g-oai-nr-ue</server_container_name> <client_container_name>rfsim5g-oai-ext-dn</client_container_name> <server_options>-B 12.1.1.2 -u -i 1 -s</server_options> - <client_options>-c 12.1.1.2 -u -i 1 -t 30 -b 400K</client_options> + <client_options>-c 12.1.1.2 -u -i 1 -t 30 -b 3M</client_options> </testCase> <testCase id="030002"> @@ -93,7 +102,7 @@ <server_container_name>rfsim5g-oai-ext-dn</server_container_name> <client_container_name>rfsim5g-oai-nr-ue</client_container_name> <server_options>-u -i 1 -s</server_options> - <client_options>-B 12.1.1.2 -c 192.168.72.135 -u -i 1 -t 30 -b 20K</client_options> + <client_options>-B 12.1.1.2 -c 192.168.72.135 -u -i 1 -t 30 -b 1M</client_options> </testCase> <testCase id="100001"> diff --git a/ci-scripts/xml_files/container_5g_rfsim_down.xml b/ci-scripts/xml_files/container_5g_rfsim_down.xml index 57b0f67a214c297fe86648559e29aaf04012c1f7..9acc3f85a1b8b2dce671ccf468e62900af1d5b20 100644 --- a/ci-scripts/xml_files/container_5g_rfsim_down.xml +++ b/ci-scripts/xml_files/container_5g_rfsim_down.xml @@ -22,7 +22,7 @@ --> <testCaseList> <htmlTabRef>rfsim-5gnr-down</htmlTabRef> - <htmlTabName>CleanUp 5G RF</htmlTabName> + <htmlTabName>CleanUp 5G RF - Monolithic gNB</htmlTabName> <htmlTabIcon>trash</htmlTabIcon> <TestCaseRequestedList> 100002 diff --git a/ci-scripts/xml_files/container_nsa_b200_quectel.xml b/ci-scripts/xml_files/container_nsa_b200_quectel.xml index cc8312d7a39751e8dd39c21ab034cfc57edcc2b2..55f8b8638df8c67791e0641fe7f5ad5a90b13d58 100644 --- a/ci-scripts/xml_files/container_nsa_b200_quectel.xml +++ b/ci-scripts/xml_files/container_nsa_b200_quectel.xml @@ -37,8 +37,10 @@ 000001 050000 050001 - 070000 070001 + 070000 + 050000 + 050001 010002 000001 030202 @@ -103,6 +105,7 @@ <id>idefix</id> <ping_args>-c 20</ping_args> <ping_packetloss_threshold>1</ping_packetloss_threshold> + <ping_rttavg_threshold>15</ping_rttavg_threshold> </testCase> <testCase id="050001"> @@ -111,6 +114,7 @@ <id>idefix</id> <ping_args>-c 100 -i 0.2</ping_args> <ping_packetloss_threshold>1</ping_packetloss_threshold> + <ping_rttavg_threshold>15</ping_rttavg_threshold> </testCase> <testCase id="070000"> @@ -119,17 +123,19 @@ <iperf_args>-u -b 40M -t 60</iperf_args> <direction>DL</direction> <id>idefix</id> - <iperf_packetloss_threshold>3</iperf_packetloss_threshold> + <iperf_packetloss_threshold>20</iperf_packetloss_threshold> + <iperf_bitrate_threshold>85</iperf_bitrate_threshold> <iperf_profile>single-ue</iperf_profile> </testCase> <testCase id="070001"> <class>Iperf</class> - <desc>iperf (UL/2Mbps/UDP)(60 sec)(single-ue profile)</desc> - <iperf_args>-u -b 2M -t 60</iperf_args> + <desc>iperf (UL/3Mbps/UDP)(60 sec)(single-ue profile)</desc> + <iperf_args>-u -b 3M -t 60</iperf_args> <direction>UL</direction> <id>idefix</id> <iperf_packetloss_threshold>1</iperf_packetloss_threshold> + <iperf_bitrate_threshold>95</iperf_bitrate_threshold> <iperf_profile>single-ue</iperf_profile> </testCase> 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 a4caa77075979939cdbe7530caa1f8a399129e57..d330d826bfc6c310ffd434178784a6b08040a7fd 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 @@ -35,7 +35,7 @@ <testCase id="030101"> <class>Initialize_eNB</class> <desc>Initialize OCP-eNB (FDD/Band7/5MHz)</desc> - <Initialize_eNB_args>-O ci-scripts/conf_files/enb.band7.tm1.25PRB.usrpb210.conf</Initialize_eNB_args> + <Initialize_eNB_args>-O ci-scripts/conf_files/enb.band7.tm1.25PRB.usrpb210.conf --log_config.global_log_options level,nocolor,time</Initialize_eNB_args> <air_interface>ocp</air_interface> </testCase> 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 581858e44e1287128d29cebf66ff741b0fb5bd4c..48ce2f298f779c544600d97bb4e40490d0adb15f 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 @@ -52,7 +52,7 @@ <testCase id="030101"> <class>Initialize_eNB</class> <desc>Initialize eNB (FDD/Band7/5MHz)</desc> - <Initialize_eNB_args>-O ci-scripts/conf_files/enb.band7.tm1.25PRB.usrpb210.conf --noS1 --eNBs.[0].rrc_inactivity_threshold 0</Initialize_eNB_args> + <Initialize_eNB_args>-O ci-scripts/conf_files/enb.band7.tm1.25PRB.usrpb210.conf --noS1 --eNBs.[0].rrc_inactivity_threshold 0 --log_config.global_log_options level,nocolor,time</Initialize_eNB_args> </testCase> <testCase id="030201"> @@ -63,7 +63,7 @@ <testCase id="090101"> <class>Initialize_OAI_UE</class> <desc>Initialize OAI UE (FDD/Band7/5MHz)</desc> - <Initialize_OAI_UE_args>-C 2680000000 -r 25 --ue-rxgain 120 --ue-txgain 0 --ue-max-power 0 --ue-scan-carrier --nokrnmod 1 --noS1</Initialize_OAI_UE_args> + <Initialize_OAI_UE_args>-C 2680000000 -r 25 --ue-rxgain 120 --ue-txgain 0 --ue-max-power 0 --ue-scan-carrier --nokrnmod 1 --noS1 --log_config.global_log_options level,nocolor,time</Initialize_OAI_UE_args> </testCase> <testCase id="090109"> 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 775ef2e023257733c55b1cf5a822773caa3f808d..fb66ce0c6684b3605feb1bcd9a918ef71a018d14 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 @@ -52,7 +52,7 @@ <testCase id="030104"> <class>Initialize_eNB</class> <desc>Initialize eNB (FDD/Band7/5MHz/MBMS)</desc> - <Initialize_eNB_args>-O ci-scripts/conf_files/enb.band17.tm1.mbms.25PRB.usrpb210.conf --noS1 --eNBs.[0].rrc_inactivity_threshold 0 --nokrnmod 1 --eNBs.[0].component_carriers.[0].eutra_band 7 --eNBs.[0].component_carriers.[0].downlink_frequency 2680000000 --eNBs.[0].component_carriers.[0].uplink_frequency_offset -120000000 --eNBs.[0].component_carriers.[0].mbms_dedicated_serving_cell ENABLE --MCEs.[0].mbms_sched_info.mbms_area_config_list.[0].pmch_config_list.[0].allocated_sf_end 512</Initialize_eNB_args> + <Initialize_eNB_args>-O ci-scripts/conf_files/enb.band17.tm1.mbms.25PRB.usrpb210.conf --noS1 --eNBs.[0].rrc_inactivity_threshold 0 --nokrnmod 1 --eNBs.[0].component_carriers.[0].eutra_band 7 --eNBs.[0].component_carriers.[0].downlink_frequency 2680000000 --eNBs.[0].component_carriers.[0].uplink_frequency_offset -120000000 --eNBs.[0].component_carriers.[0].mbms_dedicated_serving_cell ENABLE --MCEs.[0].mbms_sched_info.mbms_area_config_list.[0].pmch_config_list.[0].allocated_sf_end 512 --log_config.global_log_options level,nocolor,time</Initialize_eNB_args> </testCase> <testCase id="030201"> @@ -63,7 +63,7 @@ <testCase id="090104"> <class>Initialize_OAI_UE</class> <desc>Initialize OAI UE (FDD/Band7/5MHz/MBMS)</desc> - <Initialize_OAI_UE_args>-C 2680000000 -r 25 --ue-rxgain 120 --ue-txgain 0 --ue-max-power 0 --ue-scan-carrier --nokrnmod 1 --noS1</Initialize_OAI_UE_args> + <Initialize_OAI_UE_args>-C 2680000000 -r 25 --ue-rxgain 120 --ue-txgain 0 --ue-max-power 0 --ue-scan-carrier --nokrnmod 1 --noS1 --log_config.global_log_options level,nocolor,time</Initialize_OAI_UE_args> </testCase> <testCase id="090109"> 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 b841d3bab4b5eea7c60e0492904e8ca78094a4be..234f6639ce1eb69067f572b67b0dc80dc2a51ea9 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 @@ -52,7 +52,7 @@ <testCase id="030103"> <class>Initialize_eNB</class> <desc>Initialize eNB (FDD/Band7/5MHz/MBMS)</desc> - <Initialize_eNB_args>-O ci-scripts/conf_files/enb.band17.tm1.mbms.25PRB.usrpb210.conf --noS1 --eNBs.[0].rrc_inactivity_threshold 0 --nokrnmod 1 --eNBs.[0].component_carriers.[0].eutra_band 7 --eNBs.[0].component_carriers.[0].downlink_frequency 2680000000 --eNBs.[0].component_carriers.[0].uplink_frequency_offset -120000000</Initialize_eNB_args> + <Initialize_eNB_args>-O ci-scripts/conf_files/enb.band17.tm1.mbms.25PRB.usrpb210.conf --noS1 --eNBs.[0].rrc_inactivity_threshold 0 --nokrnmod 1 --eNBs.[0].component_carriers.[0].eutra_band 7 --eNBs.[0].component_carriers.[0].downlink_frequency 2680000000 --eNBs.[0].component_carriers.[0].uplink_frequency_offset -120000000 --log_config.global_log_options level,nocolor,time</Initialize_eNB_args> </testCase> <testCase id="030201"> @@ -63,7 +63,7 @@ <testCase id="090103"> <class>Initialize_OAI_UE</class> <desc>Initialize OAI UE (FDD/Band7/5MHz/MBMS)</desc> - <Initialize_OAI_UE_args>-C 2680000000 -r 25 --ue-rxgain 120 --ue-txgain 0 --ue-max-power 0 --ue-scan-carrier --nokrnmod 1 --noS1</Initialize_OAI_UE_args> + <Initialize_OAI_UE_args>-C 2680000000 -r 25 --ue-rxgain 120 --ue-txgain 0 --ue-max-power 0 --ue-scan-carrier --nokrnmod 1 --noS1 --log_config.global_log_options level,nocolor,time</Initialize_OAI_UE_args> </testCase> <testCase id="090109"> 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 2336f8e614456fa17c0a566536f9c24c2c097bbc..791d32eec05480e6d914dc9f1ec0acb675a1dc74 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 @@ -46,7 +46,7 @@ <testCase id="030102"> <class>Initialize_eNB</class> <desc>Initialize eNB (FDD/Band7/5MHz)</desc> - <Initialize_eNB_args>-O ci-scripts/conf_files/enb.band7.tm1.25PRB.usrpb210.conf --eNBs.[0].rrc_inactivity_threshold 0</Initialize_eNB_args> + <Initialize_eNB_args>-O ci-scripts/conf_files/enb.band7.tm1.25PRB.usrpb210.conf --eNBs.[0].rrc_inactivity_threshold 0 --log_config.global_log_options level,nocolor,time</Initialize_eNB_args> </testCase> <testCase id="030201"> @@ -57,7 +57,7 @@ <testCase id="090102"> <class>Initialize_OAI_UE</class> <desc>Initialize OAI UE (FDD/Band7/5MHz)</desc> - <Initialize_OAI_UE_args>-C 2680000000 -r 25 --ue-rxgain 120 --ue-txgain 0 --ue-max-power 0 --ue-scan-carrier --nokrnmod 1</Initialize_OAI_UE_args> + <Initialize_OAI_UE_args>-C 2680000000 -r 25 --ue-rxgain 120 --ue-txgain 0 --ue-max-power 0 --ue-scan-carrier --nokrnmod 1 --log_config.global_log_options level,nocolor,time</Initialize_OAI_UE_args> </testCase> <testCase id="090109"> diff --git a/ci-scripts/xml_files/enb_usrp210_band13_test_10mhz_tm1.xml b/ci-scripts/xml_files/enb_usrp210_band13_test_10mhz_tm1.xml index cdba0723dff81e5dc8bf6f6a24b08117bc4c8501..c050b38b121c10d191e5ad84b9044305dc4682a7 100644 --- a/ci-scripts/xml_files/enb_usrp210_band13_test_10mhz_tm1.xml +++ b/ci-scripts/xml_files/enb_usrp210_band13_test_10mhz_tm1.xml @@ -43,7 +43,7 @@ <testCase id="030121"> <class>Initialize_eNB</class> <desc>Initialize eNB (FDD/Band13/10MHz)</desc> - <Initialize_eNB_args>-O ci-scripts/conf_files/enb.band13.tm1.50PRB.emtc.conf</Initialize_eNB_args> + <Initialize_eNB_args>-O ci-scripts/conf_files/enb.band13.tm1.50PRB.emtc.conf --log_config.global_log_options level,nocolor,time</Initialize_eNB_args> </testCase> <testCase id="030201"> diff --git a/ci-scripts/xml_files/enb_usrp210_band40_test_05mhz_tm1.xml b/ci-scripts/xml_files/enb_usrp210_band40_test_05mhz_tm1.xml index 6cf5634fcf0a72be9f73184d7d395872f337461d..f1a2ad2ea32537cb221422754db19271c3aa3df6 100644 --- a/ci-scripts/xml_files/enb_usrp210_band40_test_05mhz_tm1.xml +++ b/ci-scripts/xml_files/enb_usrp210_band40_test_05mhz_tm1.xml @@ -34,7 +34,7 @@ <testCase id="030104"> <class>Initialize_eNB</class> <desc>Initialize eNB (TDD/Band40/5MHz)</desc> - <Initialize_eNB_args>-O ci-scripts/conf_files/enb.band40.tm1.25PRB.FairScheduler.usrpb210.conf</Initialize_eNB_args> + <Initialize_eNB_args>-O ci-scripts/conf_files/enb.band40.tm1.25PRB.FairScheduler.usrpb210.conf --log_config.global_log_options level,nocolor,time</Initialize_eNB_args> </testCase> <testCase id="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 5ece10d37e2cdd22605f19c5b8067fb5d465feb3..2e7da714b05557fd9ec79786b8f13d078cd0e79a 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 @@ -38,7 +38,7 @@ <testCase id="030105"> <class>Initialize_eNB</class> <desc>Initialize eNB (TDD/Band40/5MHz)</desc> - <Initialize_eNB_args>-O ci-scripts/conf_files/enb.band40.tm2.25PRB.FairScheduler.usrpb210.conf --MACRLCs.[0].scheduler_mode default</Initialize_eNB_args> + <Initialize_eNB_args>-O ci-scripts/conf_files/enb.band40.tm2.25PRB.FairScheduler.usrpb210.conf --MACRLCs.[0].scheduler_mode default --log_config.global_log_options level,nocolor,time</Initialize_eNB_args> </testCase> <testCase id="030201"> diff --git a/ci-scripts/xml_files/enb_usrp210_band40_test_10mhz_tm1.xml b/ci-scripts/xml_files/enb_usrp210_band40_test_10mhz_tm1.xml index b1d87e598e7ef7cc7bda596ea7aebc34bf15b185..d2877fc01ee1431f87eff50984accdddf03c8821 100644 --- a/ci-scripts/xml_files/enb_usrp210_band40_test_10mhz_tm1.xml +++ b/ci-scripts/xml_files/enb_usrp210_band40_test_10mhz_tm1.xml @@ -36,7 +36,7 @@ <testCase id="030114"> <class>Initialize_eNB</class> <desc>Initialize eNB (TDD/Band40/10MHz/info)</desc> - <Initialize_eNB_args>-O ci-scripts/conf_files/enb.band40.tm1.50PRB.FairScheduler.usrpb210.conf</Initialize_eNB_args> + <Initialize_eNB_args>-O ci-scripts/conf_files/enb.band40.tm1.50PRB.FairScheduler.usrpb210.conf --log_config.global_log_options level,nocolor,time</Initialize_eNB_args> </testCase> <testCase id="030201"> 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 d75704acebc026b5f449c68a7f4a196eb44f1cac..ef9fee0dca2262fa82b3d0aa3f8710ac688b449d 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 @@ -37,7 +37,7 @@ <testCase id="030124"> <class>Initialize_eNB</class> <desc>Initialize eNB (TDD/Band40/20MHz/info)</desc> - <Initialize_eNB_args>-O ci-scripts/conf_files/enb.band40.tm1.100PRB.FairScheduler.usrpb210.conf</Initialize_eNB_args> + <Initialize_eNB_args>-O ci-scripts/conf_files/enb.band40.tm1.100PRB.FairScheduler.usrpb210.conf --log_config.global_log_options level,nocolor,time</Initialize_eNB_args> </testCase> <testCase id="030201"> diff --git a/ci-scripts/xml_files/enb_usrp210_band40_test_20mhz_tm1_default_scheduler.xml b/ci-scripts/xml_files/enb_usrp210_band40_test_20mhz_tm1_default_scheduler.xml index a6530a920ccc824d85aa659026ebf585c954ca5c..adf03d802a194b36d3bf929011ea5e7cd8801277 100644 --- a/ci-scripts/xml_files/enb_usrp210_band40_test_20mhz_tm1_default_scheduler.xml +++ b/ci-scripts/xml_files/enb_usrp210_band40_test_20mhz_tm1_default_scheduler.xml @@ -36,7 +36,7 @@ <testCase id="030125"> <class>Initialize_eNB</class> <desc>Initialize eNB (TDD/Band40/20MHz/info)</desc> - <Initialize_eNB_args>-O ci-scripts/conf_files/enb.band40.tm1.100PRB.FairScheduler.usrpb210.conf --MACRLCs.[0].scheduler_mode default</Initialize_eNB_args> + <Initialize_eNB_args>-O ci-scripts/conf_files/enb.band40.tm1.100PRB.FairScheduler.usrpb210.conf --MACRLCs.[0].scheduler_mode default --log_config.global_log_options level,nocolor,time</Initialize_eNB_args> </testCase> <testCase id="030201"> diff --git a/ci-scripts/xml_files/enb_usrp210_band40_tracer.xml b/ci-scripts/xml_files/enb_usrp210_band40_tracer.xml index 08cef07c8cad6e861cd705ed2181d5fc12303be3..d8793b63e6198740b585aeed3b12f0336222aac6 100644 --- a/ci-scripts/xml_files/enb_usrp210_band40_tracer.xml +++ b/ci-scripts/xml_files/enb_usrp210_band40_tracer.xml @@ -33,7 +33,7 @@ <testCase id="030100"> <class>Initialize_eNB</class> <desc>Initialize eNB (TDD/Band40/5MHz) with T Tracer on</desc> - <Initialize_eNB_args>-O ci-scripts/conf_files/enb.band40.tm1.25PRB.FairScheduler.usrpb210.conf --T_stdout 0</Initialize_eNB_args> + <Initialize_eNB_args>-O ci-scripts/conf_files/enb.band40.tm1.25PRB.FairScheduler.usrpb210.conf --T_stdout 0 --log_config.global_log_options level,nocolor,time</Initialize_eNB_args> </testCase> <testCase id="030201"> diff --git a/ci-scripts/xml_files/enb_usrp210_band7_test_05mhz_tm1.xml b/ci-scripts/xml_files/enb_usrp210_band7_test_05mhz_tm1.xml index ec6090c00c7004de47fad48539f6f3dd5bd46573..2fe0e17611dabaa2faa1760d748aa2f379e7f02a 100644 --- a/ci-scripts/xml_files/enb_usrp210_band7_test_05mhz_tm1.xml +++ b/ci-scripts/xml_files/enb_usrp210_band7_test_05mhz_tm1.xml @@ -34,7 +34,7 @@ <testCase id="030101"> <class>Initialize_eNB</class> <desc>Initialize eNB (FDD/Band7/5MHz)</desc> - <Initialize_eNB_args>-O ci-scripts/conf_files/enb.band7.tm1.25PRB.usrpb210.conf</Initialize_eNB_args> + <Initialize_eNB_args>-O ci-scripts/conf_files/enb.band7.tm1.25PRB.usrpb210.conf --log_config.global_log_options level,nocolor,time</Initialize_eNB_args> </testCase> <testCase id="030201"> 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 73d12161994923f717c3c330c2d725710b58200b..aedd980c34756ba9da5b12a5a9b6c15a529b6be5 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 @@ -71,7 +71,7 @@ <testCase id="030102"> <class>Initialize_eNB</class> <desc>Initialize eNB (FDD/Band7/5MHz) for RRC Inactivity Timer testing -- no FlexRan Ctl</desc> - <Initialize_eNB_args>-O ci-scripts/conf_files/enb.band7.tm1.25PRB.usrpb210.conf</Initialize_eNB_args> + <Initialize_eNB_args>-O ci-scripts/conf_files/enb.band7.tm1.25PRB.usrpb210.conf --log_config.global_log_options level,nocolor,time</Initialize_eNB_args> </testCase> <testCase id="030201"> 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 6ee9247ef34c5ae8366693105c6bbd51c6801412..b4886374838dc95607d1ac4932bad6daf7b05a92 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 @@ -83,7 +83,7 @@ <testCase id="030103"> <class>Initialize_eNB</class> <desc>Initialize eNB (FDD/Band7/5MHz) for RRC Inactivity Timer testing -- with FlexRan Ctl</desc> - <Initialize_eNB_args>-O ci-scripts/conf_files/enb.band7.tm1.25PRB.usrpb210.conf</Initialize_eNB_args> + <Initialize_eNB_args>-O ci-scripts/conf_files/enb.band7.tm1.25PRB.usrpb210.conf --log_config.global_log_options level,nocolor,time</Initialize_eNB_args> </testCase> <testCase id="030201"> diff --git a/ci-scripts/xml_files/enb_usrp210_band7_test_10mhz_tm1.xml b/ci-scripts/xml_files/enb_usrp210_band7_test_10mhz_tm1.xml index 1ee223d1c7cceca179be0f1bafc5a29519dafca1..5b3a23dbfb12e02d069be600ec91ea0a67357962 100644 --- a/ci-scripts/xml_files/enb_usrp210_band7_test_10mhz_tm1.xml +++ b/ci-scripts/xml_files/enb_usrp210_band7_test_10mhz_tm1.xml @@ -34,7 +34,7 @@ <testCase id="030111"> <class>Initialize_eNB</class> <desc>Initialize eNB (FDD/Band7/10MHz)</desc> - <Initialize_eNB_args>-O ci-scripts/conf_files/enb.band7.tm1.50PRB.usrpb210.conf --eNBs.[0].component_carriers.[0].drx_Config_present prRelease</Initialize_eNB_args> + <Initialize_eNB_args>-O ci-scripts/conf_files/enb.band7.tm1.50PRB.usrpb210.conf --eNBs.[0].component_carriers.[0].drx_Config_present prRelease --log_config.global_log_options level,nocolor,time</Initialize_eNB_args> </testCase> <testCase id="030201"> 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 a76f188bc48d19dfe1db5f13e022aa9d3b9dcf82..82e0a32f6a85a04a0f075aad0af84c7c11c2a3fe 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 @@ -35,7 +35,7 @@ <testCase id="030112"> <class>Initialize_eNB</class> <desc>Initialize eNB (FDD/Band7/10MHz) with CDRX</desc> - <Initialize_eNB_args>-O ci-scripts/conf_files/enb.band7.tm1.50PRB.usrpb210.conf --eNBs.[0].component_carriers.[0].drx_Config_present prSetup</Initialize_eNB_args> + <Initialize_eNB_args>-O ci-scripts/conf_files/enb.band7.tm1.50PRB.usrpb210.conf --eNBs.[0].component_carriers.[0].drx_Config_present prSetup --log_config.global_log_options level,nocolor,time</Initialize_eNB_args> </testCase> <testCase id="030201"> diff --git a/ci-scripts/xml_files/enb_usrp210_band7_test_20mhz_tm1.xml b/ci-scripts/xml_files/enb_usrp210_band7_test_20mhz_tm1.xml index adde118128c5d61d11f2e20dd386e59939749f16..b25f75d2d377615c69a793bad272e14de6a4d875 100644 --- a/ci-scripts/xml_files/enb_usrp210_band7_test_20mhz_tm1.xml +++ b/ci-scripts/xml_files/enb_usrp210_band7_test_20mhz_tm1.xml @@ -34,7 +34,7 @@ <testCase id="030121"> <class>Initialize_eNB</class> <desc>Initialize eNB (FDD/Band7/20MHz)</desc> - <Initialize_eNB_args>-O ci-scripts/conf_files/enb.band7.tm1.100PRB.usrpb210.conf</Initialize_eNB_args> + <Initialize_eNB_args>-O ci-scripts/conf_files/enb.band7.tm1.100PRB.usrpb210.conf --log_config.global_log_options level,nocolor,time</Initialize_eNB_args> </testCase> <testCase id="030201"> diff --git a/ci-scripts/xml_files/f1_usrp210_band7_test_05mhz.xml b/ci-scripts/xml_files/f1_usrp210_band7_test_05mhz.xml index c2a48037baf5c2e6b151059d3806d15e4d07e2f9..68aca3a26dc4f8edd4418e16192f928c4fd564df 100644 --- a/ci-scripts/xml_files/f1_usrp210_band7_test_05mhz.xml +++ b/ci-scripts/xml_files/f1_usrp210_band7_test_05mhz.xml @@ -42,14 +42,14 @@ <testCase id="030141"> <class>Initialize_eNB</class> <desc>Initialize DU (FDD/Band7/5MHz)</desc> - <Initialize_eNB_args>-O ci-scripts/conf_files/du.band7.tm1.25PRB.usrpb210.conf</Initialize_eNB_args> + <Initialize_eNB_args>-O ci-scripts/conf_files/du.band7.tm1.25PRB.usrpb210.conf --log_config.global_log_options level,nocolor,time</Initialize_eNB_args> <eNB_instance>1</eNB_instance> </testCase> <testCase id="030142"> <class>Initialize_eNB</class> <desc>Initialize CU (FDD/Band7/5MHz)</desc> - <Initialize_eNB_args>-O ci-scripts/conf_files/cu.band7.tm1.25PRB.conf</Initialize_eNB_args> + <Initialize_eNB_args>-O ci-scripts/conf_files/cu.band7.tm1.25PRB.conf --log_config.global_log_options level,nocolor,time</Initialize_eNB_args> <eNB_instance>0</eNB_instance> </testCase> diff --git a/ci-scripts/xml_files/f1_usrp210_band7_test_10mhz.xml b/ci-scripts/xml_files/f1_usrp210_band7_test_10mhz.xml index 8d028df433a9d0ec2a972f2b16f6c64e36441ce9..4e8fe45c36b8e62d2a98c17346f6d244d17ec14e 100644 --- a/ci-scripts/xml_files/f1_usrp210_band7_test_10mhz.xml +++ b/ci-scripts/xml_files/f1_usrp210_band7_test_10mhz.xml @@ -42,14 +42,14 @@ <testCase id="030151"> <class>Initialize_eNB</class> <desc>Initialize DU (FDD/Band7/10MHz)</desc> - <Initialize_eNB_args>-O ci-scripts/conf_files/du.band7.tm1.50PRB.usrpb210.conf</Initialize_eNB_args> + <Initialize_eNB_args>-O ci-scripts/conf_files/du.band7.tm1.50PRB.usrpb210.conf --log_config.global_log_options level,nocolor,time</Initialize_eNB_args> <eNB_instance>1</eNB_instance> </testCase> <testCase id="030152"> <class>Initialize_eNB</class> <desc>Initialize CU (FDD/Band7/10MHz)</desc> - <Initialize_eNB_args>-O ci-scripts/conf_files/cu.band7.tm1.50PRB.conf</Initialize_eNB_args> + <Initialize_eNB_args>-O ci-scripts/conf_files/cu.band7.tm1.50PRB.conf --log_config.global_log_options level,nocolor,time</Initialize_eNB_args> <eNB_instance>0</eNB_instance> </testCase> diff --git a/ci-scripts/xml_files/f1_usrp210_band7_test_20mhz.xml b/ci-scripts/xml_files/f1_usrp210_band7_test_20mhz.xml index 061b87294bfe6e328d3433faf420436d508c55f8..22e2aed34c3bafdae10932016391462fc9a2a3f3 100644 --- a/ci-scripts/xml_files/f1_usrp210_band7_test_20mhz.xml +++ b/ci-scripts/xml_files/f1_usrp210_band7_test_20mhz.xml @@ -42,14 +42,14 @@ <testCase id="030161"> <class>Initialize_eNB</class> <desc>Initialize DU (FDD/Band7/20MHz)</desc> - <Initialize_eNB_args>-O ci-scripts/conf_files/du.band7.tm1.100PRB.usrpb210.conf</Initialize_eNB_args> + <Initialize_eNB_args>-O ci-scripts/conf_files/du.band7.tm1.100PRB.usrpb210.conf --log_config.global_log_options level,nocolor,time</Initialize_eNB_args> <eNB_instance>1</eNB_instance> </testCase> <testCase id="030162"> <class>Initialize_eNB</class> <desc>Initialize CU (FDD/Band7/20MHz)</desc> - <Initialize_eNB_args>-O ci-scripts/conf_files/cu.band7.tm1.100PRB.conf</Initialize_eNB_args> + <Initialize_eNB_args>-O ci-scripts/conf_files/cu.band7.tm1.100PRB.conf --log_config.global_log_options level,nocolor,time</Initialize_eNB_args> <eNB_instance>0</eNB_instance> </testCase> diff --git a/ci-scripts/xml_files/fr1_gnb_build.xml b/ci-scripts/xml_files/fr1_gnb_build.xml index 43cff756209972bbbf605397c37f8c439d472c53..13d85fccc4e6648af968dc8cff092ebd0d78eb41 100644 --- a/ci-scripts/xml_files/fr1_gnb_build.xml +++ b/ci-scripts/xml_files/fr1_gnb_build.xml @@ -38,11 +38,4 @@ <forced_workspace_cleanup>True</forced_workspace_cleanup> </testCase> - <testCase id="000002"> - <class>WaitEndBuild_eNB</class> - <desc>Wait for end of Build gNB</desc> - <eNB_instance>0</eNB_instance> - <eNB_serverId>0</eNB_serverId> - </testCase> - </testCaseList> diff --git a/ci-scripts/xml_files/fr1_nsa_2x2_quectel.xml b/ci-scripts/xml_files/fr1_nsa_2x2_quectel.xml index bdca76379d02cf670c50930b4ae0bf3cc761b944..5c53bf5eed4de0b43ae07e18fb3f89cfd4821a2c 100644 --- a/ci-scripts/xml_files/fr1_nsa_2x2_quectel.xml +++ b/ci-scripts/xml_files/fr1_nsa_2x2_quectel.xml @@ -24,7 +24,7 @@ <htmlTabRef>TEST-NSA-FR1-TM2-Tab1</htmlTabRef> <htmlTabName>NSA 2x2 Ping DL UL with QUECTEL</htmlTabName> <htmlTabIcon>tasks</htmlTabIcon> - <repeatCount>5</repeatCount> + <repeatCount>1</repeatCount> <TestCaseRequestedList> 030000 040000 @@ -61,7 +61,7 @@ <testCase id="030000"> <class>Initialize_eNB</class> <desc>Initialize eNB</desc> - <Initialize_eNB_args>-O ci-scripts/conf_files/enb.band38.nsa_2x2.100PRB.usrpn310.conf --usrp-tx-thread-config 1 --thread-pool 0,2,4,6</Initialize_eNB_args> + <Initialize_eNB_args>-O ci-scripts/conf_files/enb.band38.nsa_2x2.100PRB.usrpn310.conf --usrp-tx-thread-config 1 --thread-pool 0,2,4,6 --log_config.global_log_options level,nocolor,time,line_num,function</Initialize_eNB_args> <eNB_instance>0</eNB_instance> <eNB_serverId>0</eNB_serverId> <air_interface>lte</air_interface> @@ -74,11 +74,12 @@ <testCase id="040000"> <class>Initialize_eNB</class> <desc>Initialize gNB</desc> - <Initialize_eNB_args>-O ci-scripts/conf_files/gnb.band78.nsa_2x2.106PRB.usrpn310.conf -q --usrp-tx-thread-config 1 --thread-pool 0,2,4,6</Initialize_eNB_args> + <Initialize_eNB_args>-O ci-scripts/conf_files/gnb.band78.nsa_2x2.106PRB.usrpn310.conf -q --usrp-tx-thread-config 1 --log_config.global_log_options level,nocolor,time,line_num,function</Initialize_eNB_args> <eNB_instance>1</eNB_instance> <eNB_serverId>1</eNB_serverId> <air_interface>nr</air_interface> <eNB_Stats>yes</eNB_Stats> + <rt_stats_cfg>datalog_rt_stats.2x2.yaml</rt_stats_cfg> <USRP_IPAddress>192.168.18.240</USRP_IPAddress> </testCase> diff --git a/ci-scripts/xml_files/fr1_nsa_2x2_quectel_attach_detach.xml b/ci-scripts/xml_files/fr1_nsa_2x2_quectel_attach_detach.xml index ebb5c880d5b3af1eb5bc2891cdf622b791acd4fe..02544f273baae039405add42c5d89ef67c07cf8c 100644 --- a/ci-scripts/xml_files/fr1_nsa_2x2_quectel_attach_detach.xml +++ b/ci-scripts/xml_files/fr1_nsa_2x2_quectel_attach_detach.xml @@ -24,7 +24,7 @@ <htmlTabRef>TEST-NSA-FR1-TM2-Tab2</htmlTabRef> <htmlTabName>NSA 2x2 Attach-Detach with QUECTEL</htmlTabName> <htmlTabIcon>tasks</htmlTabIcon> - <repeatCount>5</repeatCount> + <repeatCount>1</repeatCount> <TestCaseRequestedList> 031000 041000 @@ -81,7 +81,7 @@ <testCase id="031000"> <class>Initialize_eNB</class> <desc>Initialize eNB</desc> - <Initialize_eNB_args>-O ci-scripts/conf_files/enb.band38.nsa_2x2.100PRB.usrpn310.conf --usrp-tx-thread-config 1 --thread-pool 0,2,4,6</Initialize_eNB_args> + <Initialize_eNB_args>-O ci-scripts/conf_files/enb.band38.nsa_2x2.100PRB.usrpn310.conf --usrp-tx-thread-config 1 --thread-pool 0,2,4,6 --log_config.global_log_options level,nocolor,time,line_num,function</Initialize_eNB_args> <eNB_instance>0</eNB_instance> <eNB_serverId>0</eNB_serverId> <air_interface>lte</air_interface> @@ -94,11 +94,12 @@ <testCase id="041000"> <class>Initialize_eNB</class> <desc>Initialize gNB</desc> - <Initialize_eNB_args>-O ci-scripts/conf_files/gnb.band78.nsa_2x2.106PRB.usrpn310.conf -q --usrp-tx-thread-config 1 --thread-pool 0,2,4,6</Initialize_eNB_args> + <Initialize_eNB_args>-O ci-scripts/conf_files/gnb.band78.nsa_2x2.106PRB.usrpn310.conf -q --usrp-tx-thread-config 1 --log_config.global_log_options level,nocolor,time,line_num,function</Initialize_eNB_args> <eNB_instance>1</eNB_instance> <eNB_serverId>1</eNB_serverId> <air_interface>nr</air_interface> <eNB_Stats>yes</eNB_Stats> + <rt_stats_cfg>datalog_rt_stats.2x2.yaml</rt_stats_cfg> <USRP_IPAddress>192.168.18.240</USRP_IPAddress> </testCase> diff --git a/ci-scripts/xml_files/fr1_nsa_base.xml b/ci-scripts/xml_files/fr1_nsa_base.xml index 96bdc79f0f9138e2d43597237575014f28700c04..dec24f7d93046a0dd46412df7d037ce6d7856eb0 100644 --- a/ci-scripts/xml_files/fr1_nsa_base.xml +++ b/ci-scripts/xml_files/fr1_nsa_base.xml @@ -70,7 +70,7 @@ <testCase id="030000"> <class>Initialize_eNB</class> <desc>Initialize eNB</desc> - <Initialize_eNB_args>-O ci-scripts/conf_files/enb.band7.tm1.fr1.25PRB.usrpb210.conf</Initialize_eNB_args> + <Initialize_eNB_args>-O ci-scripts/conf_files/enb.band7.tm1.fr1.25PRB.usrpb210.conf --log_config.global_log_options level,nocolor,time,line_num,function</Initialize_eNB_args> <eNB_instance>0</eNB_instance> <eNB_serverId>0</eNB_serverId> <air_interface>lte</air_interface> @@ -80,7 +80,7 @@ <testCase id="040000"> <class>Initialize_eNB</class> <desc>Initialize gNB</desc> - <Initialize_eNB_args>-O ci-scripts/conf_files/gnb.band78.tm1.fr1.106PRB.usrpb210.conf -E</Initialize_eNB_args> + <Initialize_eNB_args>-O ci-scripts/conf_files/gnb.band78.tm1.fr1.106PRB.usrpb210.conf -E --log_config.global_log_options level,nocolor,time,line_num,function</Initialize_eNB_args> <eNB_instance>1</eNB_instance> <eNB_serverId>1</eNB_serverId> <air_interface>nr</air_interface> diff --git a/ci-scripts/xml_files/fr1_nsa_quectel.xml b/ci-scripts/xml_files/fr1_nsa_quectel.xml index 2b64b9bbe5e08d7a72929b423ce37b7d42eac0f5..574286fbc26e7fc068f2f10a3cd66329331063d0 100644 --- a/ci-scripts/xml_files/fr1_nsa_quectel.xml +++ b/ci-scripts/xml_files/fr1_nsa_quectel.xml @@ -34,10 +34,13 @@ 050000 050001 000001 - 070000 + 070003 + 070002 000001 - 070001 + 070002 000001 + 050000 + 050001 010002 080001 080000 @@ -62,7 +65,7 @@ <testCase id="030000"> <class>Initialize_eNB</class> <desc>Initialize eNB</desc> - <Initialize_eNB_args>-O ci-scripts/conf_files/enb.band7.tm1.fr1.25PRB.usrpb210.conf</Initialize_eNB_args> + <Initialize_eNB_args>-O ci-scripts/conf_files/enb.band7.tm1.fr1.25PRB.usrpb210.conf --log_config.global_log_options level,nocolor,time,line_num,function</Initialize_eNB_args> <eNB_instance>0</eNB_instance> <eNB_serverId>0</eNB_serverId> <air_interface>lte</air_interface> @@ -73,7 +76,7 @@ <testCase id="040000"> <class>Initialize_eNB</class> <desc>Initialize gNB</desc> - <Initialize_eNB_args>-O ci-scripts/conf_files/gnb.band78.tm1.fr1.106PRB.usrpb210.conf -E -q --RUs.[0].sdr_addrs "serial=30C51D4"</Initialize_eNB_args> + <Initialize_eNB_args>-O ci-scripts/conf_files/gnb.band78.tm1.fr1.106PRB.usrpb210.conf -E -q --RUs.[0].sdr_addrs "serial=30C51D4" --log_config.global_log_options level,nocolor,time,line_num,function</Initialize_eNB_args> <eNB_instance>1</eNB_instance> <eNB_serverId>1</eNB_serverId> <air_interface>nr</air_interface> @@ -98,6 +101,7 @@ <id>idefix</id> <ping_args>-c 20</ping_args> <ping_packetloss_threshold>1</ping_packetloss_threshold> + <ping_rttavg_threshold>15</ping_rttavg_threshold> </testCase> <testCase id="050001"> @@ -106,28 +110,61 @@ <id>idefix</id> <ping_args>-c 100 -i 0.2</ping_args> <ping_packetloss_threshold>1</ping_packetloss_threshold> + <ping_rttavg_threshold>15</ping_rttavg_threshold> </testCase> <testCase id="070000"> + <class>Iperf</class> + <desc>iperf (DL/30Mbps/UDP)(30 sec)(single-ue profile)</desc> + <iperf_args>-u -b 30M -t 30</iperf_args> + <direction>DL</direction> + <id>idefix</id> + <iperf_packetloss_threshold>5</iperf_packetloss_threshold> + <iperf_bitrate_threshold>95</iperf_bitrate_threshold> + <iperf_profile>single-ue</iperf_profile> + </testCase> + + <testCase id="070001"> + <class>Iperf</class> + <desc>iperf (DL/40Mbps/UDP)(30 sec)(single-ue profile)</desc> + <iperf_args>-u -b 40M -t 30</iperf_args> + <direction>DL</direction> + <id>idefix</id> + <iperf_packetloss_threshold>5</iperf_packetloss_threshold> + <iperf_bitrate_threshold>95</iperf_bitrate_threshold> + <iperf_profile>single-ue</iperf_profile> + </testCase> + + <testCase id="070002"> <class>Iperf</class> <desc>iperf (DL/60Mbps/UDP)(60 sec)(single-ue profile)</desc> <iperf_args>-u -b 60M -t 60</iperf_args> <direction>DL</direction> <id>idefix</id> - <iperf_packetloss_threshold>3</iperf_packetloss_threshold> + <iperf_packetloss_threshold>5</iperf_packetloss_threshold> + <iperf_bitrate_threshold>95</iperf_bitrate_threshold> <iperf_profile>single-ue</iperf_profile> </testCase> - <testCase id="070001"> + <testCase id="070003"> <class>Iperf</class> <desc>iperf (UL/3Mbps/UDP)(60 sec)(single-ue profile)</desc> <iperf_args>-u -b 3M -t 60</iperf_args> <direction>UL</direction> <id>idefix</id> <iperf_packetloss_threshold>1</iperf_packetloss_threshold> + <iperf_bitrate_threshold>95</iperf_bitrate_threshold> <iperf_profile>single-ue</iperf_profile> </testCase> + <testCase id="070002"> + <class>Iperf</class> + <desc>iperf (BIDIR TCP)(10 sec)(single-ue profile)</desc> + <iperf_args>-t 10 --bidir</iperf_args> + <direction>BIDIR</direction> + <id>idefix</id> + <iperf_profile>single-ue</iperf_profile> + </testCase> <testCase id="080000"> <class>Terminate_eNB</class> diff --git a/ci-scripts/xml_files/fr1_nsa_quectel_attach_detach.xml b/ci-scripts/xml_files/fr1_nsa_quectel_attach_detach.xml index 2263f731c582219bda3c234f8c6246499f8f8269..68d2f94af920beb5fcd1c8e07b534d6a74f8687e 100644 --- a/ci-scripts/xml_files/fr1_nsa_quectel_attach_detach.xml +++ b/ci-scripts/xml_files/fr1_nsa_quectel_attach_detach.xml @@ -81,7 +81,7 @@ <testCase id="030000"> <class>Initialize_eNB</class> <desc>Initialize eNB</desc> - <Initialize_eNB_args>-O ci-scripts/conf_files/enb.band7.tm1.fr1.25PRB.usrpb210.conf</Initialize_eNB_args> + <Initialize_eNB_args>-O ci-scripts/conf_files/enb.band7.tm1.fr1.25PRB.usrpb210.conf --log_config.global_log_options level,nocolor,time,line_num,function</Initialize_eNB_args> <eNB_instance>0</eNB_instance> <eNB_serverId>0</eNB_serverId> <air_interface>lte</air_interface> @@ -92,7 +92,7 @@ <testCase id="040000"> <class>Initialize_eNB</class> <desc>Initialize gNB</desc> - <Initialize_eNB_args>-O ci-scripts/conf_files/gnb.band78.tm1.fr1.106PRB.usrpb210.conf -E -q</Initialize_eNB_args> + <Initialize_eNB_args>-O ci-scripts/conf_files/gnb.band78.tm1.fr1.106PRB.usrpb210.conf -E -q --log_config.global_log_options level,nocolor,time,line_num,function</Initialize_eNB_args> <eNB_instance>1</eNB_instance> <eNB_serverId>1</eNB_serverId> <air_interface>nr</air_interface> diff --git a/ci-scripts/xml_files/fr1_nsa_quectel_long.xml b/ci-scripts/xml_files/fr1_nsa_quectel_long.xml index 21ff7a63c5b3dfbc4712dd036233b6fdb66f61e1..c3801068a9354160bcd94a1c8f5e2be439eb5013 100644 --- a/ci-scripts/xml_files/fr1_nsa_quectel_long.xml +++ b/ci-scripts/xml_files/fr1_nsa_quectel_long.xml @@ -61,7 +61,7 @@ <testCase id="030000"> <class>Initialize_eNB</class> <desc>Initialize eNB</desc> - <Initialize_eNB_args>-O ci-scripts/conf_files/enb.band7.tm1.fr1.25PRB.usrpb210.conf</Initialize_eNB_args> + <Initialize_eNB_args>-O ci-scripts/conf_files/enb.band7.tm1.fr1.25PRB.usrpb210.conf --log_config.global_log_options level,nocolor,time,line_num,function</Initialize_eNB_args> <eNB_instance>0</eNB_instance> <eNB_serverId>0</eNB_serverId> <air_interface>lte</air_interface> @@ -72,7 +72,7 @@ <testCase id="040000"> <class>Initialize_eNB</class> <desc>Initialize gNB</desc> - <Initialize_eNB_args>-O ci-scripts/conf_files/gnb.band78.tm1.fr1.106PRB.usrpb210.conf -E -q</Initialize_eNB_args> + <Initialize_eNB_args>-O ci-scripts/conf_files/gnb.band78.tm1.fr1.106PRB.usrpb210.conf -E -q --log_config.global_log_options level,nocolor,time,line_num,function</Initialize_eNB_args> <eNB_instance>1</eNB_instance> <eNB_serverId>1</eNB_serverId> <air_interface>nr</air_interface> diff --git a/ci-scripts/xml_files/fr1_sa_oaiue_b200.xml b/ci-scripts/xml_files/fr1_sa_oaiue_b200.xml new file mode 100644 index 0000000000000000000000000000000000000000..774d5751c5949fc468cb660dbbbd6fb530555827 --- /dev/null +++ b/ci-scripts/xml_files/fr1_sa_oaiue_b200.xml @@ -0,0 +1,123 @@ +<!-- + + 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 + +--> +<testCaseList> + <htmlTabRef>TEST-SA-FR1-Tab1</htmlTabRef> + <htmlTabName>SA Ping DL UL with OAI NR UE</htmlTabName> + <htmlTabIcon>tasks</htmlTabIcon> + <repeatCount>1</repeatCount> + <TestCaseRequestedList> + 040000 + 000002 + 010000 + 000002 + 050000 + 050001 + 000001 + 010002 + 080000 + </TestCaseRequestedList> + <TestCaseExclusionList></TestCaseExclusionList> + + <testCase id="010000"> + <class>Initialize_OAI_UE</class> + <desc>Initialize OAI UE</desc> + <air_interface>nr</air_interface> + <Initialize_OAI_UE_args>--sa -O ../../../ci-scripts/conf_files/ue.sa.conf --usrp-args "serial=30C51D1" --numerology 1 -r 106 --band 78 -C 3319680000 --nokrnmod 1 --ue-txgain 0 -E --log_config.global_log_options level,nocolor,time</Initialize_OAI_UE_args> + </testCase> + + <testCase id="010002"> + <class>Terminate_OAI_UE</class> + <desc>Terminate OAI UE</desc> + </testCase> + + + <testCase id="040000"> + <class>Initialize_eNB</class> + <desc>Initialize gNB</desc> + <Initialize_eNB_args>-O ci-scripts/conf_files/gnb.band78.sa.fr1.106PRB.usrpn310.conf --sa -q --usrp-tx-thread-config 1 --log_config.global_log_options level,nocolor,time</Initialize_eNB_args> + <eNB_instance>0</eNB_instance> + <eNB_serverId>0</eNB_serverId> + <air_interface>nr</air_interface> + <eNB_Trace>yes</eNB_Trace> + <eNB_Stats>yes</eNB_Stats> + <USRP_IPAddress>192.168.18.240</USRP_IPAddress> + </testCase> + + <testCase id="000001"> + <class>IdleSleep</class> + <desc>Sleep</desc> + <idle_sleep_time_in_sec>5</idle_sleep_time_in_sec> + </testCase> + + <testCase id="000002"> + <class>IdleSleep</class> + <desc>Sleep</desc> + <idle_sleep_time_in_sec>20</idle_sleep_time_in_sec> + </testCase> + + + <testCase id="050000"> + <class>Ping</class> + <desc>Ping from CN to UE: 20pings in 20sec</desc> + <ping_args>-c 20</ping_args> + <ping_packetloss_threshold>5</ping_packetloss_threshold> + </testCase> + + <testCase id="050001"> + <class>Ping</class> + <desc>Ping from CN to UE: 100pings in 20sec</desc> + <ping_args>-c 100 -i 0.2</ping_args> + <ping_packetloss_threshold>5</ping_packetloss_threshold> + </testCase> + + <testCase id="070000"> + <class>Iperf</class> + <desc>iperf (DL/60Mbps/UDP)(60 sec)(single-ue profile)</desc> + <iperf_args>-u -b 60M -t 60</iperf_args> + <direction>DL</direction> + <id>nrmodule2_quectel</id> + <iperf_packetloss_threshold>5</iperf_packetloss_threshold> + <iperf_profile>single-ue</iperf_profile> + </testCase> + + <testCase id="070001"> + <class>Iperf</class> + <desc>iperf (UL/3Mbps/UDP)(60 sec)(single-ue profile)</desc> + <iperf_args>-u -b 3M -t 60</iperf_args> + <direction>UL</direction> + <id>nrmodule2_quectel</id> + <iperf_packetloss_threshold>5</iperf_packetloss_threshold> + <iperf_profile>single-ue</iperf_profile> + </testCase> + + + <testCase id="080000"> + <class>Terminate_eNB</class> + <desc>Terminate gNB</desc> + <eNB_instance>0</eNB_instance> + <eNB_serverId>0</eNB_serverId> + <air_interface>nr</air_interface> + </testCase> + +</testCaseList> + diff --git a/ci-scripts/xml_files/fr1_sa_oaiue_n310.xml b/ci-scripts/xml_files/fr1_sa_oaiue_n310.xml new file mode 100644 index 0000000000000000000000000000000000000000..55852ad79be335cb9a06f6f328490a09e4b3684b --- /dev/null +++ b/ci-scripts/xml_files/fr1_sa_oaiue_n310.xml @@ -0,0 +1,123 @@ +<!-- + + 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 + +--> +<testCaseList> + <htmlTabRef>TEST-SA-FR1-Tab1</htmlTabRef> + <htmlTabName>SA Ping DL UL with OAI NR UE (N310)</htmlTabName> + <htmlTabIcon>tasks</htmlTabIcon> + <repeatCount>1</repeatCount> + <TestCaseRequestedList> + 040000 + 000002 + 010000 + 000002 + 050000 + 050001 + 000001 + 010002 + 080000 + </TestCaseRequestedList> + <TestCaseExclusionList></TestCaseExclusionList> + + <testCase id="010000"> + <class>Initialize_OAI_UE</class> + <desc>Initialize OAI UE (N310)</desc> + <air_interface>nr</air_interface> + <Initialize_OAI_UE_args>--sa -O ../../../ci-scripts/conf_files/ue.sa.conf --usrp-args "mgmt_addr=192.168.18.241,second_addr=192.168.10.2" --numerology 1 -r 106 --band 78 -C 3319680000 --nokrnmod 1 --ue-txgain 0 --ue-rxgain 70 --ue-fo-compensation --log_config.global_log_options level,nocolor,time</Initialize_OAI_UE_args> + </testCase> + + <testCase id="010002"> + <class>Terminate_OAI_UE</class> + <desc>Terminate OAI UE</desc> + </testCase> + + + <testCase id="040000"> + <class>Initialize_eNB</class> + <desc>Initialize gNB</desc> + <Initialize_eNB_args>-O ci-scripts/conf_files/gnb.band78.sa.fr1.106PRB.usrpn310.conf --sa --usrp-tx-thread-config 1 --log_config.global_log_options level,nocolor,time</Initialize_eNB_args> + <eNB_instance>0</eNB_instance> + <eNB_serverId>0</eNB_serverId> + <air_interface>nr</air_interface> + <eNB_Trace>yes</eNB_Trace> + <eNB_Stats>yes</eNB_Stats> + <USRP_IPAddress>192.168.18.240</USRP_IPAddress> + </testCase> + + <testCase id="000001"> + <class>IdleSleep</class> + <desc>Sleep</desc> + <idle_sleep_time_in_sec>5</idle_sleep_time_in_sec> + </testCase> + + <testCase id="000002"> + <class>IdleSleep</class> + <desc>Sleep</desc> + <idle_sleep_time_in_sec>20</idle_sleep_time_in_sec> + </testCase> + + + <testCase id="050000"> + <class>Ping</class> + <desc>Ping from CN to UE: 20pings in 20sec</desc> + <ping_args>-c 20</ping_args> + <ping_packetloss_threshold>5</ping_packetloss_threshold> + </testCase> + + <testCase id="050001"> + <class>Ping</class> + <desc>Ping from CN to UE: 100pings in 20sec</desc> + <ping_args>-c 100 -i 0.2</ping_args> + <ping_packetloss_threshold>5</ping_packetloss_threshold> + </testCase> + + <testCase id="070000"> + <class>Iperf</class> + <desc>iperf (DL/60Mbps/UDP)(60 sec)(single-ue profile)</desc> + <iperf_args>-u -b 60M -t 60</iperf_args> + <direction>DL</direction> + <id>nrmodule2_quectel</id> + <iperf_packetloss_threshold>5</iperf_packetloss_threshold> + <iperf_profile>single-ue</iperf_profile> + </testCase> + + <testCase id="070001"> + <class>Iperf</class> + <desc>iperf (UL/3Mbps/UDP)(60 sec)(single-ue profile)</desc> + <iperf_args>-u -b 3M -t 60</iperf_args> + <direction>UL</direction> + <id>nrmodule2_quectel</id> + <iperf_packetloss_threshold>5</iperf_packetloss_threshold> + <iperf_profile>single-ue</iperf_profile> + </testCase> + + + <testCase id="080000"> + <class>Terminate_eNB</class> + <desc>Terminate gNB</desc> + <eNB_instance>0</eNB_instance> + <eNB_serverId>0</eNB_serverId> + <air_interface>nr</air_interface> + </testCase> + +</testCaseList> + diff --git a/ci-scripts/xml_files/fr1_sa_oaiue_x300.xml b/ci-scripts/xml_files/fr1_sa_oaiue_x300.xml new file mode 100644 index 0000000000000000000000000000000000000000..c43bdd2a7c932197bf6a91e4a7a4e6b2105281f2 --- /dev/null +++ b/ci-scripts/xml_files/fr1_sa_oaiue_x300.xml @@ -0,0 +1,123 @@ +<!-- + + 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 + +--> +<testCaseList> + <htmlTabRef>TEST-SA-FR1-Tab2</htmlTabRef> + <htmlTabName>SA Ping DL UL with OAI NR UE (X300)</htmlTabName> + <htmlTabIcon>tasks</htmlTabIcon> + <repeatCount>1</repeatCount> + <TestCaseRequestedList> + 041000 + 000002 + 011000 + 000002 + 051000 + 051001 + 000001 + 010002 + 080000 + </TestCaseRequestedList> + <TestCaseExclusionList></TestCaseExclusionList> + + <testCase id="011000"> + <class>Initialize_OAI_UE</class> + <desc>Initialize OAI UE (X300)</desc> + <air_interface>nr</air_interface> + <Initialize_OAI_UE_args>--sa -O ../../../ci-scripts/conf_files/ue.sa.conf --usrp-args "addr=192.168.60.2" --numerology 1 -r 106 --band 78 -C 3319680000 --nokrnmod 1 --ue-txgain 0 --ue-rxgain 70 --ue-fo-compensation --log_config.global_log_options level,nocolor,time</Initialize_OAI_UE_args> + </testCase> + + <testCase id="010002"> + <class>Terminate_OAI_UE</class> + <desc>Terminate OAI UE</desc> + </testCase> + + + <testCase id="041000"> + <class>Initialize_eNB</class> + <desc>Initialize gNB</desc> + <Initialize_eNB_args>-O ci-scripts/conf_files/gnb.band78.sa.fr1.106PRB.usrpn310.conf --sa --usrp-tx-thread-config 1 --log_config.global_log_options level,nocolor,time</Initialize_eNB_args> + <eNB_instance>0</eNB_instance> + <eNB_serverId>0</eNB_serverId> + <air_interface>nr</air_interface> + <eNB_Trace>yes</eNB_Trace> + <eNB_Stats>yes</eNB_Stats> + <USRP_IPAddress>192.168.18.240</USRP_IPAddress> + </testCase> + + <testCase id="000001"> + <class>IdleSleep</class> + <desc>Sleep</desc> + <idle_sleep_time_in_sec>5</idle_sleep_time_in_sec> + </testCase> + + <testCase id="000002"> + <class>IdleSleep</class> + <desc>Sleep</desc> + <idle_sleep_time_in_sec>20</idle_sleep_time_in_sec> + </testCase> + + + <testCase id="051000"> + <class>Ping</class> + <desc>Ping from CN to UE: 20pings in 20sec</desc> + <ping_args>-c 20</ping_args> + <ping_packetloss_threshold>5</ping_packetloss_threshold> + </testCase> + + <testCase id="051001"> + <class>Ping</class> + <desc>Ping from CN to UE: 100pings in 20sec</desc> + <ping_args>-c 100 -i 0.2</ping_args> + <ping_packetloss_threshold>5</ping_packetloss_threshold> + </testCase> + + <testCase id="070000"> + <class>Iperf</class> + <desc>iperf (DL/60Mbps/UDP)(60 sec)(single-ue profile)</desc> + <iperf_args>-u -b 60M -t 60</iperf_args> + <direction>DL</direction> + <id>nrmodule2_quectel</id> + <iperf_packetloss_threshold>5</iperf_packetloss_threshold> + <iperf_profile>single-ue</iperf_profile> + </testCase> + + <testCase id="070001"> + <class>Iperf</class> + <desc>iperf (UL/3Mbps/UDP)(60 sec)(single-ue profile)</desc> + <iperf_args>-u -b 3M -t 60</iperf_args> + <direction>UL</direction> + <id>nrmodule2_quectel</id> + <iperf_packetloss_threshold>5</iperf_packetloss_threshold> + <iperf_profile>single-ue</iperf_profile> + </testCase> + + + <testCase id="080000"> + <class>Terminate_eNB</class> + <desc>Terminate gNB</desc> + <eNB_instance>0</eNB_instance> + <eNB_serverId>0</eNB_serverId> + <air_interface>nr</air_interface> + </testCase> + +</testCaseList> + diff --git a/ci-scripts/xml_files/fr1_sa_quectel.xml b/ci-scripts/xml_files/fr1_sa_quectel.xml index ff877287aa64bac1891cb0bd359250f5c2393ea8..8d15015c0747e4c84d46dcc7322421f7c0d2b080 100644 --- a/ci-scripts/xml_files/fr1_sa_quectel.xml +++ b/ci-scripts/xml_files/fr1_sa_quectel.xml @@ -31,10 +31,15 @@ 010000 000001 050000 + 000001 050001 + 000001 070000 + 000001 070001 000001 + 070002 + 000001 010002 080000 </TestCaseRequestedList> @@ -58,12 +63,13 @@ <testCase id="040000"> <class>Initialize_eNB</class> <desc>Initialize gNB</desc> - <Initialize_eNB_args>-O ci-scripts/conf_files/gnb.band78.sa.fr1.106PRB.2x2.usrpn310.conf --sa -q --usrp-tx-thread-config 1 --thread-pool 0,2,4,6</Initialize_eNB_args> + <Initialize_eNB_args>-O ci-scripts/conf_files/gnb.band78.sa.fr1.106PRB.2x2.usrpn310.conf --sa -q --usrp-tx-thread-config 1 --T_stdout 2 --log_config.global_log_options level,nocolor,time</Initialize_eNB_args> <eNB_instance>0</eNB_instance> <eNB_serverId>0</eNB_serverId> <air_interface>nr</air_interface> <eNB_Trace>yes</eNB_Trace> <eNB_Stats>yes</eNB_Stats> + <rt_stats_cfg>datalog_rt_stats.2x2.yaml</rt_stats_cfg> <USRP_IPAddress>192.168.18.240</USRP_IPAddress> </testCase> @@ -82,10 +88,11 @@ <testCase id="050000"> <class>Ping</class> - <desc>Ping: 20pings in 20sec</desc> + <desc>Ping: 40pings in 40sec</desc> <id>nrmodule2_quectel</id> - <ping_args>-c 20</ping_args> - <ping_packetloss_threshold>5</ping_packetloss_threshold> + <ping_args>-c 40</ping_args> + <ping_packetloss_threshold>1</ping_packetloss_threshold> + <ping_rttavg_threshold>20</ping_rttavg_threshold> </testCase> <testCase id="050001"> @@ -93,7 +100,8 @@ <desc>Ping: 100pings in 20sec</desc> <id>nrmodule2_quectel</id> <ping_args>-c 100 -i 0,2</ping_args> - <ping_packetloss_threshold>5</ping_packetloss_threshold> + <ping_packetloss_threshold>1</ping_packetloss_threshold> + <ping_rttavg_threshold>20</ping_rttavg_threshold> </testCase> <testCase id="070000"> @@ -103,6 +111,7 @@ <direction>DL</direction> <id>nrmodule2_quectel</id> <iperf_packetloss_threshold>5</iperf_packetloss_threshold> + <iperf_bitrate_threshold>95</iperf_bitrate_threshold> <iperf_profile>single-ue</iperf_profile> </testCase> @@ -113,6 +122,16 @@ <direction>UL</direction> <id>nrmodule2_quectel</id> <iperf_packetloss_threshold>5</iperf_packetloss_threshold> + <iperf_bitrate_threshold>95</iperf_bitrate_threshold> + <iperf_profile>single-ue</iperf_profile> + </testCase> + + <testCase id="070002"> + <class>Iperf</class> + <desc>iperf (BIDIR TCP)(10 sec)(single-ue profile)</desc> + <iperf_args>-t 10 --bidir</iperf_args> + <direction>BIDIR</direction> + <id>nrmodule2_quectel</id> <iperf_profile>single-ue</iperf_profile> </testCase> diff --git a/ci-scripts/xml_files/fr1_sa_quectel_162prb.xml b/ci-scripts/xml_files/fr1_sa_quectel_162prb.xml new file mode 100644 index 0000000000000000000000000000000000000000..23cc6d25b8415bb7937007f197bc9d842e5b5b38 --- /dev/null +++ b/ci-scripts/xml_files/fr1_sa_quectel_162prb.xml @@ -0,0 +1,138 @@ +<!-- + + 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 + +--> +<testCaseList> + <htmlTabRef>TEST-SA-FR1-Tab3</htmlTabRef> + <htmlTabName>SA 162PRB</htmlTabName> + <htmlTabIcon>tasks</htmlTabIcon> + <repeatCount>1</repeatCount> + <TestCaseRequestedList> + 042000 + 000002 + 010000 + 000001 + 052000 + 000001 + 072000 + 000001 + 072001 + 000001 + 072002 + 000001 + 010002 + 080000 + </TestCaseRequestedList> + <TestCaseExclusionList></TestCaseExclusionList> + + <testCase id="010000"> + <class>Initialize_UE</class> + <desc>Initialize Quectel</desc> + <id>nrmodule2_quectel</id> + <UE_Trace>yes</UE_Trace> + </testCase> + + + <testCase id="010002"> + <class>Terminate_UE</class> + <desc>Terminate Quectel</desc> + <id>nrmodule2_quectel</id> + </testCase> + + + <testCase id="042000"> + <class>Initialize_eNB</class> + <desc>Initialize gNB</desc> + <Initialize_eNB_args>-O ci-scripts/conf_files/gnb.band78.sa.fr1.162PRB.2x2.usrpn310.conf --sa -q --usrp-tx-thread-config 1 --log_config.global_log_options level,nocolor,time</Initialize_eNB_args> + <eNB_instance>0</eNB_instance> + <eNB_serverId>0</eNB_serverId> + <air_interface>nr</air_interface> + <eNB_Trace>yes</eNB_Trace> + <eNB_Stats>yes</eNB_Stats> + <rt_stats_cfg>datalog_rt_stats.2x2.yaml</rt_stats_cfg> + <USRP_IPAddress>192.168.18.240</USRP_IPAddress> + </testCase> + + <testCase id="000001"> + <class>IdleSleep</class> + <desc>Sleep</desc> + <idle_sleep_time_in_sec>5</idle_sleep_time_in_sec> + </testCase> + + <testCase id="000002"> + <class>IdleSleep</class> + <desc>Sleep</desc> + <idle_sleep_time_in_sec>20</idle_sleep_time_in_sec> + </testCase> + + + <testCase id="052000"> + <class>Ping</class> + <desc>Ping: 40pings in 40sec</desc> + <id>nrmodule2_quectel</id> + <ping_args>-c 40</ping_args> + <ping_packetloss_threshold>1</ping_packetloss_threshold> + <ping_rttavg_threshold>20</ping_rttavg_threshold> + </testCase> + + + <testCase id="072000"> + <class>Iperf</class> + <desc>iperf (DL/140Mbps/UDP)(60 sec)(single-ue profile)</desc> + <iperf_args>-u -b 140M -t 60</iperf_args> + <direction>DL</direction> + <id>nrmodule2_quectel</id> + <iperf_packetloss_threshold>50</iperf_packetloss_threshold> + <iperf_bitrate_threshold>50</iperf_bitrate_threshold> + <iperf_profile>single-ue</iperf_profile> + </testCase> + + <testCase id="072001"> + <class>Iperf</class> + <desc>iperf (UL/3Mbps/UDP)(60 sec)(single-ue profile)</desc> + <iperf_args>-u -b 3M -t 60</iperf_args> + <direction>UL</direction> + <id>nrmodule2_quectel</id> + <iperf_packetloss_threshold>5</iperf_packetloss_threshold> + <iperf_bitrate_threshold>95</iperf_bitrate_threshold> + <iperf_profile>single-ue</iperf_profile> + </testCase> + + <testCase id="072002"> + <class>Iperf</class> + <desc>iperf (BIDIR TCP)(10 sec)(single-ue profile)</desc> + <iperf_args>-t 10 --bidir</iperf_args> + <direction>BIDIR</direction> + <id>nrmodule2_quectel</id> + <iperf_profile>single-ue</iperf_profile> + </testCase> + + + <testCase id="080000"> + <class>Terminate_eNB</class> + <desc>Terminate gNB</desc> + <eNB_instance>0</eNB_instance> + <eNB_serverId>0</eNB_serverId> + <air_interface>nr</air_interface> + </testCase> + +</testCaseList> + diff --git a/ci-scripts/xml_files/fr1_sa_quectel_stages.xml b/ci-scripts/xml_files/fr1_sa_quectel_stages.xml index b2236dd5276251358939a14be7674880ff81a3ac..3e497ede13caa63b094799b4d44a63406819cf92 100644 --- a/ci-scripts/xml_files/fr1_sa_quectel_stages.xml +++ b/ci-scripts/xml_files/fr1_sa_quectel_stages.xml @@ -26,28 +26,28 @@ <htmlTabIcon>tasks</htmlTabIcon> <repeatCount>1</repeatCount> <TestCaseRequestedList> - 040000 + 041000 000002 - 010000 + 011000 000001 - 050000 + 051000 000001 - 070000 + 071000 000001 - 070001 + 071001 000001 - 070002 + 071002 000001 - 070003 + 071003 000001 - 070004 + 071004 000001 - 010002 - 080000 + 011002 + 081000 </TestCaseRequestedList> <TestCaseExclusionList></TestCaseExclusionList> - <testCase id="010000"> + <testCase id="011000"> <class>Initialize_UE</class> <desc>Initialize Quectel</desc> <id>nrmodule2_quectel</id> @@ -55,22 +55,23 @@ </testCase> - <testCase id="010002"> + <testCase id="011002"> <class>Terminate_UE</class> <desc>Terminate Quectel</desc> <id>nrmodule2_quectel</id> </testCase> - <testCase id="040000"> + <testCase id="041000"> <class>Initialize_eNB</class> <desc>Initialize gNB</desc> - <Initialize_eNB_args>-O ci-scripts/conf_files/gnb.band78.sa.fr1.106PRB.2x2.usrpn310.conf --sa -q --usrp-tx-thread-config 1 --thread-pool 0,2,4,6</Initialize_eNB_args> + <Initialize_eNB_args>-O ci-scripts/conf_files/gnb.band78.sa.fr1.106PRB.2x2.usrpn310.conf --sa -q --usrp-tx-thread-config 1 --log_config.global_log_options level,nocolor,time</Initialize_eNB_args> <eNB_instance>0</eNB_instance> <eNB_serverId>0</eNB_serverId> <air_interface>nr</air_interface> <eNB_Trace>yes</eNB_Trace> <eNB_Stats>yes</eNB_Stats> + <rt_stats_cfg>datalog_rt_stats.2x2.yaml</rt_stats_cfg> <USRP_IPAddress>192.168.18.240</USRP_IPAddress> </testCase> @@ -87,64 +88,70 @@ </testCase> - <testCase id="050000"> + <testCase id="051000"> <class>Ping</class> - <desc>Ping: 20pings in 20sec</desc> + <desc>Ping: 40pings in 40sec</desc> <id>nrmodule2_quectel</id> - <ping_args>-c 20</ping_args> - <ping_packetloss_threshold>5</ping_packetloss_threshold> + <ping_args>-c 40</ping_args> + <ping_packetloss_threshold>1</ping_packetloss_threshold> + <ping_rttavg_threshold>20</ping_rttavg_threshold> </testCase> - <testCase id="070000"> + <testCase id="071000"> <class>Iperf</class> <desc>iperf (DL/10Mbps/UDP)(30 sec)(single-ue profile)</desc> <iperf_args>-u -b 10M -t 30</iperf_args> <direction>DL</direction> <id>nrmodule2_quectel</id> <iperf_packetloss_threshold>5</iperf_packetloss_threshold> + <iperf_bitrate_threshold>95</iperf_bitrate_threshold> <iperf_profile>single-ue</iperf_profile> </testCase> - <testCase id="070001"> + <testCase id="071001"> <class>Iperf</class> <desc>iperf (DL/20Mbps/UDP)(30 sec)(single-ue profile)</desc> <iperf_args>-u -b 20M -t 30</iperf_args> <direction>DL</direction> <id>nrmodule2_quectel</id> <iperf_packetloss_threshold>5</iperf_packetloss_threshold> + <iperf_bitrate_threshold>95</iperf_bitrate_threshold> <iperf_profile>single-ue</iperf_profile> </testCase> - <testCase id="070002"> + <testCase id="071002"> <class>Iperf</class> <desc>iperf (DL/40Mbps/UDP)(30 sec)(single-ue profile)</desc> <iperf_args>-u -b 40M -t 30</iperf_args> <direction>DL</direction> <id>nrmodule2_quectel</id> <iperf_packetloss_threshold>5</iperf_packetloss_threshold> + <iperf_bitrate_threshold>95</iperf_bitrate_threshold> <iperf_profile>single-ue</iperf_profile> </testCase> - <testCase id="070003"> + <testCase id="071003"> <class>Iperf</class> <desc>iperf (DL/60Mbps/UDP)(30 sec)(single-ue profile)</desc> <iperf_args>-u -b 60M -t 30</iperf_args> <direction>DL</direction> <id>nrmodule2_quectel</id> <iperf_packetloss_threshold>5</iperf_packetloss_threshold> + <iperf_bitrate_threshold>95</iperf_bitrate_threshold> <iperf_profile>single-ue</iperf_profile> </testCase> - <testCase id="070004"> + <testCase id="071004"> <class>Iperf</class> <desc>iperf (DL/90Mbps/UDP)(30 sec)(single-ue profile)</desc> <iperf_args>-u -b 90M -t 30</iperf_args> <direction>DL</direction> <id>nrmodule2_quectel</id> - <iperf_packetloss_threshold>5</iperf_packetloss_threshold> + <iperf_packetloss_threshold>10</iperf_packetloss_threshold> + <iperf_bitrate_threshold>90</iperf_bitrate_threshold> <iperf_profile>single-ue</iperf_profile> </testCase> - <testCase id="080000"> + <testCase id="081000"> <class>Terminate_eNB</class> <desc>Terminate gNB</desc> <eNB_instance>0</eNB_instance> diff --git a/ci-scripts/xml_files/fr1_sa_quectel_stages_162prb.xml b/ci-scripts/xml_files/fr1_sa_quectel_stages_162prb.xml new file mode 100644 index 0000000000000000000000000000000000000000..5feed7558657b039d75c1d16ca8b3f9ffce85d40 --- /dev/null +++ b/ci-scripts/xml_files/fr1_sa_quectel_stages_162prb.xml @@ -0,0 +1,167 @@ +<!-- + + 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 + +--> +<testCaseList> + <htmlTabRef>TEST-SA-FR1-Tab4</htmlTabRef> + <htmlTabName>SA Staged DL with QUECTEL</htmlTabName> + <htmlTabIcon>tasks</htmlTabIcon> + <repeatCount>1</repeatCount> + <TestCaseRequestedList> + 040000 + 000002 + 010000 + 000001 + 050000 + 000001 + 070000 + 000001 + 070001 + 000001 + 070002 + 000001 + 070003 + 000001 + 070004 + 000001 + 070005 + 000001 + 010002 + 080000 + </TestCaseRequestedList> + <TestCaseExclusionList></TestCaseExclusionList> + + <testCase id="010000"> + <class>Initialize_UE</class> + <desc>Initialize Quectel</desc> + <id>nrmodule2_quectel</id> + <UE_Trace>yes</UE_Trace> + </testCase> + + + <testCase id="010002"> + <class>Terminate_UE</class> + <desc>Terminate Quectel</desc> + <id>nrmodule2_quectel</id> + </testCase> + + + <testCase id="040000"> + <class>Initialize_eNB</class> + <desc>Initialize gNB</desc> + <Initialize_eNB_args>-O ci-scripts/conf_files/gnb.band78.sa.fr1.162PRB.2x2.usrpn310.conf --sa -q --usrp-tx-thread-config 1 --log_config.global_log_options level,nocolor,time</Initialize_eNB_args> + <eNB_instance>0</eNB_instance> + <eNB_serverId>0</eNB_serverId> + <air_interface>nr</air_interface> + <eNB_Trace>yes</eNB_Trace> + <eNB_Stats>yes</eNB_Stats> + <rt_stats_cfg>datalog_rt_stats.2x2.yaml</rt_stats_cfg> + <USRP_IPAddress>192.168.18.240</USRP_IPAddress> + </testCase> + + <testCase id="000001"> + <class>IdleSleep</class> + <desc>Sleep</desc> + <idle_sleep_time_in_sec>5</idle_sleep_time_in_sec> + </testCase> + + <testCase id="000002"> + <class>IdleSleep</class> + <desc>Sleep</desc> + <idle_sleep_time_in_sec>20</idle_sleep_time_in_sec> + </testCase> + + + <testCase id="050000"> + <class>Ping</class> + <desc>Ping: 20pings in 20sec</desc> + <id>nrmodule2_quectel</id> + <ping_args>-c 20</ping_args> + <ping_packetloss_threshold>5</ping_packetloss_threshold> + </testCase> + + + <testCase id="070000"> + <class>Iperf</class> + <desc>iperf (DL/10Mbps/UDP)(30 sec)(single-ue profile)</desc> + <iperf_args>-u -b 10M -t 30</iperf_args> + <direction>DL</direction> + <id>nrmodule2_quectel</id> + <iperf_packetloss_threshold>5</iperf_packetloss_threshold> + <iperf_profile>single-ue</iperf_profile> + </testCase> + <testCase id="070001"> + <class>Iperf</class> + <desc>iperf (DL/20Mbps/UDP)(30 sec)(single-ue profile)</desc> + <iperf_args>-u -b 20M -t 30</iperf_args> + <direction>DL</direction> + <id>nrmodule2_quectel</id> + <iperf_packetloss_threshold>5</iperf_packetloss_threshold> + <iperf_profile>single-ue</iperf_profile> + </testCase> + <testCase id="070002"> + <class>Iperf</class> + <desc>iperf (DL/40Mbps/UDP)(30 sec)(single-ue profile)</desc> + <iperf_args>-u -b 40M -t 30</iperf_args> + <direction>DL</direction> + <id>nrmodule2_quectel</id> + <iperf_packetloss_threshold>5</iperf_packetloss_threshold> + <iperf_profile>single-ue</iperf_profile> + </testCase> + <testCase id="070003"> + <class>Iperf</class> + <desc>iperf (DL/60Mbps/UDP)(30 sec)(single-ue profile)</desc> + <iperf_args>-u -b 60M -t 30</iperf_args> + <direction>DL</direction> + <id>nrmodule2_quectel</id> + <iperf_packetloss_threshold>5</iperf_packetloss_threshold> + <iperf_profile>single-ue</iperf_profile> + </testCase> + <testCase id="070004"> + <class>Iperf</class> + <desc>iperf (DL/90Mbps/UDP)(30 sec)(single-ue profile)</desc> + <iperf_args>-u -b 90M -t 30</iperf_args> + <direction>DL</direction> + <id>nrmodule2_quectel</id> + <iperf_packetloss_threshold>5</iperf_packetloss_threshold> + <iperf_profile>single-ue</iperf_profile> + </testCase> + <testCase id="070005"> + <class>Iperf</class> + <desc>iperf (DL/140Mbps/UDP)(30 sec)(single-ue profile)</desc> + <iperf_args>-u -b 140M -t 30</iperf_args> + <direction>DL</direction> + <id>nrmodule2_quectel</id> + <iperf_packetloss_threshold>5</iperf_packetloss_threshold> + <iperf_profile>single-ue</iperf_profile> + </testCase> + + + <testCase id="080000"> + <class>Terminate_eNB</class> + <desc>Terminate gNB</desc> + <eNB_instance>0</eNB_instance> + <eNB_serverId>0</eNB_serverId> + <air_interface>nr</air_interface> + </testCase> + +</testCaseList> + diff --git a/ci-scripts/xml_files/fr1_usrp210_band7_test_05mhz_tm1.xml b/ci-scripts/xml_files/fr1_usrp210_band7_test_05mhz_tm1.xml index ea25d5b6946fedb72fee0a2965c182413fd540a1..4d78b5b0a9cefd70050a6d7845960226fb39f0e3 100644 --- a/ci-scripts/xml_files/fr1_usrp210_band7_test_05mhz_tm1.xml +++ b/ci-scripts/xml_files/fr1_usrp210_band7_test_05mhz_tm1.xml @@ -41,7 +41,7 @@ <testCase id="030101"> <class>Initialize_eNB</class> <desc>Initialize eNB (FDD/Band7/5MHz)</desc> - <Initialize_eNB_args>-O ci-scripts/conf_files/enb.band7.tm1.25PRB.usrpb210.conf --eNBs.[0].plmn_list.[0].mcc 311 --eNBs.[0].plmn_list.[0].mnc 480 --eNBs.[0].plmn_list.[0].mnc_length 3 --eNBs.[0].component_carriers.[0].Nid_cell 10</Initialize_eNB_args> + <Initialize_eNB_args>-O ci-scripts/conf_files/enb.band7.tm1.25PRB.usrpb210.conf --eNBs.[0].plmn_list.[0].mcc 311 --eNBs.[0].plmn_list.[0].mnc 480 --eNBs.[0].plmn_list.[0].mnc_length 3 --eNBs.[0].component_carriers.[0].Nid_cell 10 --log_config.global_log_options level,nocolor,time</Initialize_eNB_args> </testCase> <testCase id="030201"> 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 b1e9697be2f0e9cba104a7d15ceef8041ec4df8c..a74dd26137a4045dee965376df1223555e0073f0 100644 --- a/ci-scripts/xml_files/gnb_nr_ue_usrp_run.xml +++ b/ci-scripts/xml_files/gnb_nr_ue_usrp_run.xml @@ -33,7 +33,7 @@ <testCase id="090101"> <class>Initialize_eNB</class> <desc>Initialize gNB USRP</desc> - <Initialize_eNB_args>-O ci-scripts/conf_files/gnb.band78.tm1.106PRB.usrpn300.conf --phy-test</Initialize_eNB_args> + <Initialize_eNB_args>-O ci-scripts/conf_files/gnb.band78.tm1.106PRB.usrpn300.conf --phy-test --log_config.global_log_options level,nocolor,time</Initialize_eNB_args> <air_interface>NR</air_interface> </testCase> @@ -52,7 +52,7 @@ <testCase id="090102"> <class>Initialize_OAI_UE</class> <desc>Initialize NR UE USRP</desc> - <Initialize_OAI_UE_args>--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 </Initialize_OAI_UE_args> + <Initialize_OAI_UE_args>--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</Initialize_OAI_UE_args> <air_interface>NR</air_interface> </testCase> 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 2c44ead8ea7fda1befae4319f178f471e9ac8e8d..f91077aacfda89af28d5dee9190554b18e5a2add 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 @@ -33,7 +33,7 @@ <testCase id="090103"> <class>Initialize_eNB</class> <desc>Initialize gNB USRP (Tx-Write-Threading enabled)</desc> - <Initialize_eNB_args>-O ci-scripts/conf_files/gnb.band78.tm1.106PRB.usrpn300.conf --phy-test --usrp-tx-thread-config 1</Initialize_eNB_args> + <Initialize_eNB_args>-O ci-scripts/conf_files/gnb.band78.tm1.106PRB.usrpn300.conf --phy-test --usrp-tx-thread-config 1 --log_config.global_log_options level,nocolor,time</Initialize_eNB_args> <air_interface>NR</air_interface> </testCase> @@ -52,7 +52,7 @@ <testCase id="090104"> <class>Initialize_OAI_UE</class> <desc>Initialize NR UE USRP</desc> - <Initialize_OAI_UE_args>--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 </Initialize_OAI_UE_args> + <Initialize_OAI_UE_args>--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</Initialize_OAI_UE_args> <air_interface>NR</air_interface> </testCase> diff --git a/ci-scripts/xml_files/gnb_phytest_usrp_run.xml b/ci-scripts/xml_files/gnb_phytest_usrp_run.xml index 9e798afdc488ca4d13b4c88d7cd4d1976fbbdfb7..f1185c08c96dd711b547299b36cbe41cc79e6ef0 100644 --- a/ci-scripts/xml_files/gnb_phytest_usrp_run.xml +++ b/ci-scripts/xml_files/gnb_phytest_usrp_run.xml @@ -21,21 +21,22 @@ --> <testCaseList> - <htmlTabRef>gNB-PHY-Test</htmlTabRef> - <htmlTabName>Run-gNB-PHY-Test</htmlTabName> - <htmlTabIcon>tasks</htmlTabIcon> + <htmlTabRef>gNB-PHY-Test</htmlTabRef> + <htmlTabName>Run-gNB-PHY-Test</htmlTabName> + <htmlTabIcon>tasks</htmlTabIcon> <repeatCount>3</repeatCount> <TestCaseRequestedList> 090101 000001 090109 </TestCaseRequestedList> <TestCaseExclusionList></TestCaseExclusionList> - - <testCase id="090101"> - <class>Initialize_eNB</class> - <desc>Initialize gNB USRP</desc> - <Initialize_eNB_args>-O ci-scripts/conf_files/gnb.band78.tm1.106PRB.usrpn300.conf --phy-test -q -U 787200 -T 106 -t 28 -D 130175 -m 28 -M 106</Initialize_eNB_args> + + <testCase id="090101"> + <class>Initialize_eNB</class> + <desc>Initialize gNB USRP</desc> + <Initialize_eNB_args>-O ci-scripts/conf_files/gnb.band78.tm1.106PRB.usrpn300.conf --phy-test -q -U 787200 -T 106 -t 28 -D 130175 -m 28 -M 106 --log_config.global_log_options level,nocolor,time</Initialize_eNB_args> <air_interface>NR</air_interface> - </testCase> + <USRP_IPAddress>192.168.30.2</USRP_IPAddress> + </testCase> <testCase id="000001"> <class>IdleSleep</class> @@ -44,10 +45,10 @@ </testCase> - <testCase id="090109"> - <class>Terminate_eNB</class> - <desc>Terminate gNB</desc> + <testCase id="090109"> + <class>Terminate_eNB</class> + <desc>Terminate gNB</desc> <air_interface>NR</air_interface> - </testCase> + </testCase> </testCaseList> diff --git a/ci-scripts/xml_files/if4p5_usrp210_band40_test_05mhz.xml b/ci-scripts/xml_files/if4p5_usrp210_band40_test_05mhz.xml index 06763aa99531e47b968fdaafbe76589a61b2b8d3..715dc0e3153e540eefd882fff711f9d5a366fa9b 100644 --- a/ci-scripts/xml_files/if4p5_usrp210_band40_test_05mhz.xml +++ b/ci-scripts/xml_files/if4p5_usrp210_band40_test_05mhz.xml @@ -35,14 +35,14 @@ <testCase id="030104"> <class>Initialize_eNB</class> <desc>Initialize RRU (TDD/Band40)</desc> - <Initialize_eNB_args>-O ci-scripts/conf_files/rru.tdd.band40.conf --RUs.[0].max_rxgain 125</Initialize_eNB_args> + <Initialize_eNB_args>-O ci-scripts/conf_files/rru.tdd.band40.conf --RUs.[0].max_rxgain 125 --log_config.global_log_options level,nocolor,time</Initialize_eNB_args> <eNB_instance>0</eNB_instance> </testCase> <testCase id="030105"> <class>Initialize_eNB</class> <desc>Initialize RCC (TDD/Band40/5MHz)</desc> - <Initialize_eNB_args>-O ci-scripts/conf_files/rcc.band40.tm1.25PRB.FairScheduler.usrpb210.conf</Initialize_eNB_args> + <Initialize_eNB_args>-O ci-scripts/conf_files/rcc.band40.tm1.25PRB.FairScheduler.usrpb210.conf --log_config.global_log_options level,nocolor,time</Initialize_eNB_args> <eNB_instance>1</eNB_instance> </testCase> 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 9224c67fe7ba02b3f0388b12063bec6cd66bcf6c..f755a7ec96cc547e7cae4333dcad22cfc825001f 100644 --- a/ci-scripts/xml_files/if4p5_usrp210_band40_test_10mhz.xml +++ b/ci-scripts/xml_files/if4p5_usrp210_band40_test_10mhz.xml @@ -38,14 +38,14 @@ <testCase id="030114"> <class>Initialize_eNB</class> <desc>Initialize RRU (TDD/Band40)</desc> - <Initialize_eNB_args>-O ci-scripts/conf_files/rru.tdd.band40.conf --RUs.[0].max_rxgain 120</Initialize_eNB_args> + <Initialize_eNB_args>-O ci-scripts/conf_files/rru.tdd.band40.conf --RUs.[0].max_rxgain 120 --log_config.global_log_options level,nocolor,time</Initialize_eNB_args> <eNB_instance>0</eNB_instance> </testCase> <testCase id="030115"> <class>Initialize_eNB</class> <desc>Initialize RCC (TDD/Band40/10MHz/info)</desc> - <Initialize_eNB_args>-O ci-scripts/conf_files/rcc.band40.tm1.50PRB.FairScheduler.usrpb210.conf</Initialize_eNB_args> + <Initialize_eNB_args>-O ci-scripts/conf_files/rcc.band40.tm1.50PRB.FairScheduler.usrpb210.conf --log_config.global_log_options level,nocolor,time</Initialize_eNB_args> <eNB_instance>1</eNB_instance> </testCase> 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 cb54ba31eeed23f203777d4f7451af63d86a1c4c..4e84c47faf324caffa467cc114a292cd19dba111 100644 --- a/ci-scripts/xml_files/if4p5_usrp210_band40_test_20mhz.xml +++ b/ci-scripts/xml_files/if4p5_usrp210_band40_test_20mhz.xml @@ -36,14 +36,14 @@ <testCase id="030124"> <class>Initialize_eNB</class> <desc>Initialize RRU (TDD/Band40)</desc> - <Initialize_eNB_args>-O ci-scripts/conf_files/rru.tdd.band40.conf</Initialize_eNB_args> + <Initialize_eNB_args>-O ci-scripts/conf_files/rru.tdd.band40.conf --log_config.global_log_options level,nocolor,time</Initialize_eNB_args> <eNB_instance>0</eNB_instance> </testCase> <testCase id="030125"> <class>Initialize_eNB</class> <desc>Initialize RCC (TDD/Band40/20MHz/info)</desc> - <Initialize_eNB_args>-O ci-scripts/conf_files/rcc.band40.tm1.100PRB.FairScheduler.usrpb210.conf --MACRLCs.[0].scheduler_mode default</Initialize_eNB_args> + <Initialize_eNB_args>-O ci-scripts/conf_files/rcc.band40.tm1.100PRB.FairScheduler.usrpb210.conf --MACRLCs.[0].scheduler_mode default --log_config.global_log_options level,nocolor,time</Initialize_eNB_args> <eNB_instance>1</eNB_instance> </testCase> diff --git a/ci-scripts/xml_files/if4p5_usrp210_band7_test_05mhz.xml b/ci-scripts/xml_files/if4p5_usrp210_band7_test_05mhz.xml index d72633159df638556f0429d4a35d8f6d114a4bfd..fc3fe29992e1705dbb4ba59936bbf3516dc7ce6c 100644 --- a/ci-scripts/xml_files/if4p5_usrp210_band7_test_05mhz.xml +++ b/ci-scripts/xml_files/if4p5_usrp210_band7_test_05mhz.xml @@ -35,14 +35,14 @@ <testCase id="030101"> <class>Initialize_eNB</class> <desc>Initialize RRU (FDD/Band7)</desc> - <Initialize_eNB_args>-O ci-scripts/conf_files/rru.fdd.band7.conf --RUs.[0].max_rxgain 125</Initialize_eNB_args> + <Initialize_eNB_args>-O ci-scripts/conf_files/rru.fdd.band7.conf --RUs.[0].max_rxgain 125 --log_config.global_log_options level,nocolor,time</Initialize_eNB_args> <eNB_instance>1</eNB_instance> </testCase> <testCase id="030102"> <class>Initialize_eNB</class> <desc>Initialize RCC (FDD/Band7/5MHz)</desc> - <Initialize_eNB_args>-O ci-scripts/conf_files/rcc.band7.tm1.if4p5.lo.25PRB.usrpb210.conf</Initialize_eNB_args> + <Initialize_eNB_args>-O ci-scripts/conf_files/rcc.band7.tm1.if4p5.lo.25PRB.usrpb210.conf --log_config.global_log_options level,nocolor,time</Initialize_eNB_args> <eNB_instance>0</eNB_instance> </testCase> diff --git a/ci-scripts/xml_files/if4p5_usrp210_band7_test_10mhz.xml b/ci-scripts/xml_files/if4p5_usrp210_band7_test_10mhz.xml index 98e1aed575352562e5a7c311641328f9ea746700..8aa07a1c439db47638e7d9b4b29372ac93e0e9c2 100644 --- a/ci-scripts/xml_files/if4p5_usrp210_band7_test_10mhz.xml +++ b/ci-scripts/xml_files/if4p5_usrp210_band7_test_10mhz.xml @@ -35,14 +35,14 @@ <testCase id="030111"> <class>Initialize_eNB</class> <desc>Initialize RRU (FDD/Band7)</desc> - <Initialize_eNB_args>-O ci-scripts/conf_files/rru.fdd.band7.conf --RUs.[0].max_rxgain 120</Initialize_eNB_args> + <Initialize_eNB_args>-O ci-scripts/conf_files/rru.fdd.band7.conf --RUs.[0].max_rxgain 120 --log_config.global_log_options level,nocolor,time</Initialize_eNB_args> <eNB_instance>1</eNB_instance> </testCase> <testCase id="030112"> <class>Initialize_eNB</class> <desc>Initialize RCC (FDD/Band7/10MHz)</desc> - <Initialize_eNB_args>-O ci-scripts/conf_files/rcc.band7.tm1.if4p5.lo.50PRB.usrpb210.conf</Initialize_eNB_args> + <Initialize_eNB_args>-O ci-scripts/conf_files/rcc.band7.tm1.if4p5.lo.50PRB.usrpb210.conf --log_config.global_log_options level,nocolor,time</Initialize_eNB_args> <eNB_instance>0</eNB_instance> </testCase> diff --git a/ci-scripts/xml_files/if4p5_usrp210_band7_test_20mhz.xml b/ci-scripts/xml_files/if4p5_usrp210_band7_test_20mhz.xml index 2cf4e0fbf5310febc64e7b7b56c7954680aad6a9..01f26bdf0fbbdaae38bb62e2b7ee06904fbe6da0 100644 --- a/ci-scripts/xml_files/if4p5_usrp210_band7_test_20mhz.xml +++ b/ci-scripts/xml_files/if4p5_usrp210_band7_test_20mhz.xml @@ -35,14 +35,14 @@ <testCase id="030121"> <class>Initialize_eNB</class> <desc>Initialize RRU (FDD/Band7)</desc> - <Initialize_eNB_args>-O ci-scripts/conf_files/rru.fdd.band7.conf</Initialize_eNB_args> + <Initialize_eNB_args>-O ci-scripts/conf_files/rru.fdd.band7.conf --log_config.global_log_options level,nocolor,time</Initialize_eNB_args> <eNB_instance>1</eNB_instance> </testCase> <testCase id="030122"> <class>Initialize_eNB</class> <desc>Initialize RCC (FDD/Band7/20MHz)</desc> - <Initialize_eNB_args>-O ci-scripts/conf_files/rcc.band7.tm1.if4p5.lo.100PRB.usrpb210.conf</Initialize_eNB_args> + <Initialize_eNB_args>-O ci-scripts/conf_files/rcc.band7.tm1.if4p5.lo.100PRB.usrpb210.conf --log_config.global_log_options level,nocolor,time</Initialize_eNB_args> <eNB_instance>0</eNB_instance> </testCase> 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 ae348b6b259d94f44ac379d682079ccf8e355878..c2fb2e8e2e11f9212e2d64f1d285a5e22253310b 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 @@ -46,7 +46,7 @@ <testCase id="030102"> <class>Initialize_eNB</class> <desc>Initialize eNB (FDD/Band7/5MHz)</desc> - <Initialize_eNB_args>-O ci-scripts/conf_files/enb.band7.tm1.25PRB.usrpb210.conf --eNBs.[0].rrc_inactivity_threshold 0 --RUs.[0].max_rxgain 120 --eNBs.[0].component_carriers.[0].pusch_p0_Nominal -90 --eNBs.[0].component_carriers.[0].pucch_p0_Nominal -96 --eNBs.[0].tracking_area_code 600 --eNBs.[0].plmn_list.[0].mnc 95</Initialize_eNB_args> + <Initialize_eNB_args>-O ci-scripts/conf_files/enb.band7.tm1.25PRB.usrpb210.conf --eNBs.[0].rrc_inactivity_threshold 0 --RUs.[0].max_rxgain 120 --eNBs.[0].component_carriers.[0].pusch_p0_Nominal -90 --eNBs.[0].component_carriers.[0].pucch_p0_Nominal -96 --eNBs.[0].tracking_area_code 600 --eNBs.[0].plmn_list.[0].mnc 95 --log_config.global_log_options level,nocolor,time</Initialize_eNB_args> </testCase> <testCase id="030201"> @@ -57,7 +57,7 @@ <testCase id="090102"> <class>Initialize_OAI_UE</class> <desc>Initialize OAI UE (FDD/Band7/5MHz)</desc> - <Initialize_OAI_UE_args>-C 2680000000 -r 25 --ue-rxgain 130 --ue-txgain 1 --ue-max-power -6 --ue-scan-carrier --nokrnmod 1</Initialize_OAI_UE_args> + <Initialize_OAI_UE_args>-C 2680000000 -r 25 --ue-rxgain 130 --ue-txgain 1 --ue-max-power -6 --ue-scan-carrier --nokrnmod 1 --log_config.global_log_options level,nocolor,time</Initialize_OAI_UE_args> </testCase> <testCase id="090109"> 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 b77c6273e6873a9f37cf3427b4a76bd998cdc49d..d5bdc5a42d68f26dcca9cc71824b6f5e46157210 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 @@ -52,7 +52,7 @@ <testCase id="030101"> <class>Initialize_eNB</class> <desc>Initialize eNB (FDD/Band7/5MHz)</desc> - <Initialize_eNB_args>-O ci-scripts/conf_files/enb.band7.tm1.25PRB.usrpb210.conf --noS1 --eNBs.[0].rrc_inactivity_threshold 0 --RUs.[0].max_rxgain 120 --eNBs.[0].component_carriers.[0].pusch_p0_Nominal -90 --eNBs.[0].component_carriers.[0].pucch_p0_Nominal -96 --eNBs.[0].tracking_area_code 600 --eNBs.[0].plmn_list.[0].mnc 95</Initialize_eNB_args> + <Initialize_eNB_args>-O ci-scripts/conf_files/enb.band7.tm1.25PRB.usrpb210.conf --noS1 --eNBs.[0].rrc_inactivity_threshold 0 --RUs.[0].max_rxgain 120 --eNBs.[0].component_carriers.[0].pusch_p0_Nominal -90 --eNBs.[0].component_carriers.[0].pucch_p0_Nominal -96 --eNBs.[0].tracking_area_code 600 --eNBs.[0].plmn_list.[0].mnc 95 --log_config.global_log_options level,nocolor,time</Initialize_eNB_args> </testCase> <testCase id="030201"> @@ -63,7 +63,7 @@ <testCase id="090101"> <class>Initialize_OAI_UE</class> <desc>Initialize OAI UE (FDD/Band7/5MHz)</desc> - <Initialize_OAI_UE_args>-C 2680000000 -r 25 --ue-rxgain 130 --ue-txgain 1 --ue-max-power -6 --ue-scan-carrier --nokrnmod 1 --noS1</Initialize_OAI_UE_args> + <Initialize_OAI_UE_args>-C 2680000000 -r 25 --ue-rxgain 130 --ue-txgain 1 --ue-max-power -6 --ue-scan-carrier --nokrnmod 1 --noS1 --log_config.global_log_options level,nocolor,time</Initialize_OAI_UE_args> </testCase> <testCase id="090109"> diff --git a/ci-scripts/xml_files/inria/enb_usrp210_band7_test_05mhz_tm1.xml b/ci-scripts/xml_files/inria/enb_usrp210_band7_test_05mhz_tm1.xml index df41385f83899c751ba1e492a45fff139680c2e8..d0f94dc56029dc7bf8c34806630bb0ff91b5dac1 100644 --- a/ci-scripts/xml_files/inria/enb_usrp210_band7_test_05mhz_tm1.xml +++ b/ci-scripts/xml_files/inria/enb_usrp210_band7_test_05mhz_tm1.xml @@ -93,7 +93,7 @@ <testCase id="030103"> <class>Initialize_eNB</class> <desc>Initialize eNB (FDD/Band7/5MHz)</desc> - <Initialize_eNB_args>-O ci-scripts/conf_files/enb.band7.tm1.25PRB.usrpb210.conf --eNBs.[0].rrc_inactivity_threshold 0 --RUs.[0].max_rxgain 120 --eNBs.[0].component_carriers.[0].pusch_p0_Nominal -90 --eNBs.[0].component_carriers.[0].pucch_p0_Nominal -96 --eNBs.[0].tracking_area_code 600 --eNBs.[0].plmn_list.[0].mnc 95</Initialize_eNB_args> + <Initialize_eNB_args>-O ci-scripts/conf_files/enb.band7.tm1.25PRB.usrpb210.conf --eNBs.[0].rrc_inactivity_threshold 0 --RUs.[0].max_rxgain 120 --eNBs.[0].component_carriers.[0].pusch_p0_Nominal -90 --eNBs.[0].component_carriers.[0].pucch_p0_Nominal -96 --eNBs.[0].tracking_area_code 600 --eNBs.[0].plmn_list.[0].mnc 95 --log_config.global_log_options level,nocolor,time</Initialize_eNB_args> </testCase> <testCase id="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 852f48c370e2b2a7455857d6c07250cada0030af..b4b20c12390258c6f99bac9269b028338520244a 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 @@ -64,7 +64,7 @@ <testCase id="030104"> <class>Initialize_eNB</class> <desc>Initialize eNB #0 (FDD/Band7/5MHz)</desc> - <Initialize_eNB_args>-O ci-scripts/conf_files/enb.band7.tm1.25PRB.usrpb210.conf --eNBs.[0].rrc_inactivity_threshold 0 --RUs.[0].max_rxgain 120 --eNBs.[0].component_carriers.[0].pusch_p0_Nominal -90 --eNBs.[0].component_carriers.[0].pucch_p0_Nominal -96 --eNBs.[0].tracking_area_code 600 --eNBs.[0].plmn_list.[0].mnc 95 --eNBs.[0].enable_measurement_reports yes --eNBs.[0].enable_x2 yes --eNBs.[0].nr_cellid 123456</Initialize_eNB_args> + <Initialize_eNB_args>-O ci-scripts/conf_files/enb.band7.tm1.25PRB.usrpb210.conf --eNBs.[0].rrc_inactivity_threshold 0 --RUs.[0].max_rxgain 120 --eNBs.[0].component_carriers.[0].pusch_p0_Nominal -90 --eNBs.[0].component_carriers.[0].pucch_p0_Nominal -96 --eNBs.[0].tracking_area_code 600 --eNBs.[0].plmn_list.[0].mnc 95 --eNBs.[0].enable_measurement_reports yes --eNBs.[0].enable_x2 yes --eNBs.[0].nr_cellid 123456 --log_config.global_log_options level,nocolor,time</Initialize_eNB_args> <eNB_instance>0</eNB_instance> <eNB_serverId>0</eNB_serverId> </testCase> @@ -72,7 +72,7 @@ <testCase id="030105"> <class>Initialize_eNB</class> <desc>Initialize eNB #1 (FDD/Band7/5MHz)</desc> - <Initialize_eNB_args>-O ci-scripts/conf_files/enb.band7.tm1.25PRB.slave.usrpb210.conf --eNBs.[0].rrc_inactivity_threshold 0 --RUs.[0].max_rxgain 120 --eNBs.[0].component_carriers.[0].pusch_p0_Nominal -90 --eNBs.[0].component_carriers.[0].pucch_p0_Nominal -96 --eNBs.[0].tracking_area_code 600 --eNBs.[0].plmn_list.[0].mnc 95 --eNBs.[0].enable_measurement_reports yes --eNBs.[0].enable_x2 yes --eNBs.[0].nr_cellid 98765</Initialize_eNB_args> + <Initialize_eNB_args>-O ci-scripts/conf_files/enb.band7.tm1.25PRB.slave.usrpb210.conf --eNBs.[0].rrc_inactivity_threshold 0 --RUs.[0].max_rxgain 120 --eNBs.[0].component_carriers.[0].pusch_p0_Nominal -90 --eNBs.[0].component_carriers.[0].pucch_p0_Nominal -96 --eNBs.[0].tracking_area_code 600 --eNBs.[0].plmn_list.[0].mnc 95 --eNBs.[0].enable_measurement_reports yes --eNBs.[0].enable_x2 yes --eNBs.[0].nr_cellid 98765 --log_config.global_log_options level,nocolor,time</Initialize_eNB_args> <eNB_instance>1</eNB_instance> <eNB_serverId>1</eNB_serverId> </testCase> diff --git a/ci-scripts/xml_files/fr1_lte_2x2_quectel.xml b/ci-scripts/xml_files/lte_2x2_tm1_quectel.xml similarity index 87% rename from ci-scripts/xml_files/fr1_lte_2x2_quectel.xml rename to ci-scripts/xml_files/lte_2x2_tm1_quectel.xml index 03d474aef04b79a763e58d76e7044740b4d20125..6cb7b2883b0a10fbc492188d48c907a61b7b3f9f 100644 --- a/ci-scripts/xml_files/fr1_lte_2x2_quectel.xml +++ b/ci-scripts/xml_files/lte_2x2_tm1_quectel.xml @@ -21,8 +21,8 @@ --> <testCaseList> - <htmlTabRef>TEST-LTE-TM2</htmlTabRef> - <htmlTabName>LTE 2x2 Ping DL UL with QUECTEL</htmlTabName> + <htmlTabRef>TEST-LTE-TM1-Tab1</htmlTabRef> + <htmlTabName>LTE 2x2 TM1 Ping DL UL with QUECTEL</htmlTabName> <htmlTabIcon>tasks</htmlTabIcon> <repeatCount>1</repeatCount> <TestCaseRequestedList> @@ -59,7 +59,7 @@ <testCase id="030000"> <class>Initialize_eNB</class> <desc>Initialize eNB</desc> - <Initialize_eNB_args>-O ci-scripts/conf_files/enb.band38.lte_2x2.100PRB.usrpn310.conf --usrp-tx-thread-config 1 --thread-pool 0,2,4,6</Initialize_eNB_args> + <Initialize_eNB_args>-O ci-scripts/conf_files/enb.band38.lte_2x2.100PRB.usrpn310.conf --usrp-tx-thread-config 1 --thread-pool 0,2,4,6 --log_config.global_log_options level,nocolor,time</Initialize_eNB_args> <eNB_instance>0</eNB_instance> <eNB_serverId>0</eNB_serverId> <air_interface>lte</air_interface> @@ -87,14 +87,16 @@ <desc>Ping: 20 pings</desc> <id>nrmodule2_quectel</id> <ping_args>-c 20</ping_args> - <ping_packetloss_threshold>5</ping_packetloss_threshold> + <ping_packetloss_threshold>1</ping_packetloss_threshold> + <ping_rttavg_threshold>40</ping_rttavg_threshold> </testCase> <testCase id="050001"> <class>Ping</class> <desc>Ping: 100 pings, size 1024</desc> <id>nrmodule2_quectel</id> <ping_args>-c 100 -s 1024 -i 0,2</ping_args> - <ping_packetloss_threshold>5</ping_packetloss_threshold> + <ping_packetloss_threshold>1</ping_packetloss_threshold> + <ping_rttavg_threshold>30</ping_rttavg_threshold> </testCase> @@ -105,6 +107,7 @@ <direction>DL</direction> <id>nrmodule2_quectel</id> <iperf_packetloss_threshold>5</iperf_packetloss_threshold> + <iperf_bitrate_threshold>95</iperf_bitrate_threshold> <iperf_profile>single-ue</iperf_profile> </testCase> @@ -115,6 +118,7 @@ <direction>UL</direction> <id>nrmodule2_quectel</id> <iperf_packetloss_threshold>5</iperf_packetloss_threshold> + <iperf_bitrate_threshold>95</iperf_bitrate_threshold> <iperf_profile>single-ue</iperf_profile> </testCase> diff --git a/ci-scripts/xml_files/lte_2x2_tm2_quectel.xml b/ci-scripts/xml_files/lte_2x2_tm2_quectel.xml new file mode 100644 index 0000000000000000000000000000000000000000..e6520fc5fcd4b7e73099de64ad8d62da744bec47 --- /dev/null +++ b/ci-scripts/xml_files/lte_2x2_tm2_quectel.xml @@ -0,0 +1,145 @@ +<!-- + + 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 + +--> +<testCaseList> + <htmlTabRef>TEST-LTE-TM2-Tab2</htmlTabRef> + <htmlTabName>LTE 2x2 TM2 Ping DL UL with QUECTEL</htmlTabName> + <htmlTabIcon>tasks</htmlTabIcon> + <repeatCount>1</repeatCount> + <TestCaseRequestedList> + 030001 + 000002 + 010000 + 000001 + 050002 + 050003 + 000002 + 070002 + 070003 + 000001 + 010002 + 080000 + </TestCaseRequestedList> + <TestCaseExclusionList></TestCaseExclusionList> + + <testCase id="010000"> + <class>Initialize_UE</class> + <desc>Initialize Quectel</desc> + <id>nrmodule2_quectel</id> + <UE_Trace>yes</UE_Trace> + </testCase> + + + <testCase id="010002"> + <class>Terminate_UE</class> + <desc>Terminate Quectel</desc> + <id>nrmodule2_quectel</id> + </testCase> + + + <testCase id="030001"> + <class>Initialize_eNB</class> + <desc>Initialize eNB</desc> + <Initialize_eNB_args>-O ci-scripts/conf_files/enb.band38.lte_2x2_tm2.100PRB.usrpn310.conf --usrp-tx-thread-config 1 --thread-pool 0,2,4,6 --log_config.global_log_options level,nocolor,time</Initialize_eNB_args> + <eNB_instance>0</eNB_instance> + <eNB_serverId>0</eNB_serverId> + <air_interface>lte</air_interface> + <eNB_Trace>yes</eNB_Trace> + <eNB_Stats>yes</eNB_Stats> + <USRP_IPAddress>192.168.18.241</USRP_IPAddress> + </testCase> + + + <testCase id="000001"> + <class>IdleSleep</class> + <desc>Sleep</desc> + <idle_sleep_time_in_sec>5</idle_sleep_time_in_sec> + </testCase> + + <testCase id="000002"> + <class>IdleSleep</class> + <desc>Sleep</desc> + <idle_sleep_time_in_sec>20</idle_sleep_time_in_sec> + </testCase> + + + <testCase id="050002"> + <class>Ping</class> + <desc>Ping: 20 pings</desc> + <id>nrmodule2_quectel</id> + <ping_args>-c 20</ping_args> + <ping_packetloss_threshold>1</ping_packetloss_threshold> + <ping_rttavg_threshold>40</ping_rttavg_threshold> + </testCase> + <testCase id="050003"> + <class>Ping</class> + <desc>Ping: 100 pings, size 1024</desc> + <id>nrmodule2_quectel</id> + <ping_args>-c 100 -s 1024 -i 0,2</ping_args> + <ping_packetloss_threshold>1</ping_packetloss_threshold> + <ping_rttavg_threshold>30</ping_rttavg_threshold> + </testCase> + + + <testCase id="070002"> + <class>Iperf</class> + <desc>iperf (DL/1Mbps/UDP)(60 sec)(single-ue profile)</desc> + <iperf_args>-u -b 1M -t 60</iperf_args> + <direction>DL</direction> + <id>nrmodule2_quectel</id> + <iperf_packetloss_threshold>5</iperf_packetloss_threshold> + <iperf_bitrate_threshold>95</iperf_bitrate_threshold> + <iperf_profile>single-ue</iperf_profile> + </testCase> + + <testCase id="070003"> + <class>Iperf</class> + <desc>iperf (UL/7Mbps/UDP)(60 sec)(single-ue profile)</desc> + <iperf_args>-u -b 7M -t 60</iperf_args> + <direction>UL</direction> + <id>nrmodule2_quectel</id> + <iperf_packetloss_threshold>5</iperf_packetloss_threshold> + <iperf_bitrate_threshold>95</iperf_bitrate_threshold> + <iperf_profile>single-ue</iperf_profile> + </testCase> + + + + + <testCase id="080000"> + <class>Terminate_eNB</class> + <desc>Terminate eNB</desc> + <eNB_instance>0</eNB_instance> + <eNB_serverId>0</eNB_serverId> + <air_interface>lte</air_interface> + </testCase> + + <testCase id="080001"> + <class>Terminate_eNB</class> + <desc>Terminate gNB</desc> + <eNB_instance>1</eNB_instance> + <eNB_serverId>1</eNB_serverId> + <air_interface>nr</air_interface> + </testCase> + +</testCaseList> + 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 cca14c0696253f1f87b5c3c88a8f6ffe4c3ff1b0..3875a3df0347d4b91e1e4f3644de83a6bd999ec5 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 @@ -42,7 +42,7 @@ <testCase id="030111"> <class>Initialize_eNB</class> <desc>Initialize RCC (TDD/Band38/10MHz)</desc> - <Initialize_eNB_args>-O ci-scripts/conf_files/rcc.band38.tm1.50PRB.multi.rru.conf --noS1</Initialize_eNB_args> + <Initialize_eNB_args>-O ci-scripts/conf_files/rcc.band38.tm1.50PRB.multi.rru.conf --noS1 --log_config.global_log_options level,nocolor,time</Initialize_eNB_args> <eNB_instance>0</eNB_instance> <eNB_serverId>0</eNB_serverId> </testCase> @@ -50,7 +50,7 @@ <testCase id="030112"> <class>Initialize_eNB</class> <desc>Initialize Master RRU (TDD/Band38/10MHz)</desc> - <Initialize_eNB_args>-O ci-scripts/conf_files/rru.band38.tm1.master.conf --noS1</Initialize_eNB_args> + <Initialize_eNB_args>-O ci-scripts/conf_files/rru.band38.tm1.master.conf --noS1 --log_config.global_log_options level,nocolor,time</Initialize_eNB_args> <eNB_instance>1</eNB_instance> <eNB_serverId>1</eNB_serverId> </testCase> @@ -58,7 +58,7 @@ <testCase id="030113"> <class>Initialize_eNB</class> <desc>Initialize Slave RRU (TDD/Band38/10MHz)</desc> - <Initialize_eNB_args>-O ci-scripts/conf_files/rru.band38.tm1.slave.conf --noS1</Initialize_eNB_args> + <Initialize_eNB_args>-O ci-scripts/conf_files/rru.band38.tm1.slave.conf --noS1 --log_config.global_log_options level,nocolor,time</Initialize_eNB_args> <eNB_instance>2</eNB_instance> <eNB_serverId>2</eNB_serverId> </testCase> diff --git a/ci-scripts/xml_files/simple_dummy_build.xml b/ci-scripts/xml_files/simple_dummy_build.xml index 75e5f6339a00e0e69053042792615f992eaef4da..a3649c210c984048f8725472cfe22c77b9d47487 100644 --- a/ci-scripts/xml_files/simple_dummy_build.xml +++ b/ci-scripts/xml_files/simple_dummy_build.xml @@ -25,7 +25,7 @@ <htmlTabName>Build</htmlTabName> <htmlTabIcon>wrench</htmlTabIcon> <TestCaseRequestedList> - 010101 + 000001 </TestCaseRequestedList> <TestCaseExclusionList> </TestCaseExclusionList> @@ -38,4 +38,10 @@ <eNB_serverId>0</eNB_serverId> </testCase> + <testCase id="000001"> + <class>IdleSleep</class> + <desc>Sleep</desc> + <idle_sleep_time_in_sec>5</idle_sleep_time_in_sec> + </testCase> + </testCaseList> diff --git a/ci-scripts/xml_files/test_case_list_template.xml b/ci-scripts/xml_files/test_case_list_template.xml index 69024805beeb58d8d10a99f468697734974cfa8e..1a8871c0370f8c7fa2a7e8aff9de5195a9e8820e 100644 --- a/ci-scripts/xml_files/test_case_list_template.xml +++ b/ci-scripts/xml_files/test_case_list_template.xml @@ -42,37 +42,37 @@ <testCase id="030101"> <class>Initialize_eNB</class> <desc>Initialize eNB (FDD/Band1/5MHz/info)</desc> - <Initialize_eNB_args>-O enb.band7.tm1.50PRB.usrpb210.conf</Initialize_eNB_args> + <Initialize_eNB_args>-O enb.band7.tm1.50PRB.usrpb210.conf --log_config.global_log_options level,nocolor,time</Initialize_eNB_args> </testCase> <testCase id="030102"> <class>Initialize_eNB</class> <desc>Initialize eNB (FDD/Band1/10MHz/info)</desc> - <Initialize_eNB_args>-O 10M.band1.FDD.info.conf</Initialize_eNB_args> + <Initialize_eNB_args>-O 10M.band1.FDD.info.conf --log_config.global_log_options level,nocolor,time</Initialize_eNB_args> </testCase> <testCase id="030103"> <class>Initialize_eNB</class> <desc>Initialize eNB (FDD/Band1/20MHz/info)</desc> - <Initialize_eNB_args>-O 20M.band1.FDD.info.conf</Initialize_eNB_args> + <Initialize_eNB_args>-O 20M.band1.FDD.info.conf --log_config.global_log_options level,nocolor,time</Initialize_eNB_args> </testCase> <testCase id="030104"> <class>Initialize_eNB</class> <desc>Initialize eNB (TDD/Band38/5MHz/info)</desc> - <Initialize_eNB_args>-O 5M.band38.TDD.info.conf</Initialize_eNB_args> + <Initialize_eNB_args>-O 5M.band38.TDD.info.conf --log_config.global_log_options level,nocolor,time</Initialize_eNB_args> </testCase> <testCase id="030105"> <class>Initialize_eNB</class> <desc>Initialize eNB (TDD/Band38/10MHz/info)</desc> - <Initialize_eNB_args>-O 10M.band38.TDD.info.conf</Initialize_eNB_args> + <Initialize_eNB_args>-O 10M.band38.TDD.info.conf --log_config.global_log_options level,nocolor,time</Initialize_eNB_args> </testCase> <testCase id="030106"> <class>Initialize_eNB</class> <desc>Initialize eNB (TDD/Band38/20MHz/info)</desc> - <Initialize_eNB_args>-O 20M.band38.TDD.info.conf</Initialize_eNB_args> + <Initialize_eNB_args>-O 20M.band38.TDD.info.conf --log_config.global_log_options level,nocolor,time</Initialize_eNB_args> </testCase> <testCase id="030201"> 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 d3e36f603eb10deac64f57a72f26d93f13bad480..49ccfbca1433cc5a8cffdd50d36f206ac2ea1c22 100644 --- a/ci-scripts/xml_files/ue_band20_test_10mhz_orange.xml +++ b/ci-scripts/xml_files/ue_band20_test_10mhz_orange.xml @@ -34,7 +34,7 @@ <testCase id="090110"> <class>Initialize_OAI_UE</class> <desc>Initialize OAI UE -- sniffing Orange frequency</desc> - <Initialize_OAI_UE_args>-C 816000000 -r 50 --ue-rxgain 135 --ue-scan-carrier --no-L2-connect --nokrnmod 1</Initialize_OAI_UE_args> + <Initialize_OAI_UE_args>-C 816000000 -r 50 --ue-rxgain 135 --ue-scan-carrier --no-L2-connect --nokrnmod 1 --log_config.global_log_options level,nocolor,time</Initialize_OAI_UE_args> </testCase> <testCase id="000001"> 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 3f6441e06ea8de2379e808f1ee35743379038413..fdc70a9bdd84c0baab9800d84492a5b5b128c771 100644 --- a/ci-scripts/xml_files/ue_band20_test_10mhz_sfr.xml +++ b/ci-scripts/xml_files/ue_band20_test_10mhz_sfr.xml @@ -34,7 +34,7 @@ <testCase id="090111"> <class>Initialize_OAI_UE</class> <desc>Initialize OAI UE -- sniffing SFR frequency</desc> - <Initialize_OAI_UE_args>-C 806000000 -r 50 --ue-rxgain 130 --ue-scan-carrier --no-L2-connect --nokrnmod 1</Initialize_OAI_UE_args> + <Initialize_OAI_UE_args>-C 806000000 -r 50 --ue-rxgain 130 --ue-scan-carrier --no-L2-connect --nokrnmod 1 --log_config.global_log_options level,nocolor,time</Initialize_OAI_UE_args> </testCase> <testCase id="000001"> 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 7256c985c584d02126109b0b41764531294d0d8d..14872c9f8f5ce3b52fb3406e1b894608ec747602 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 @@ -61,7 +61,7 @@ <testCase id="030101"> <class>Initialize_eNB</class> <desc>Initialize Master eNB (FDD/Band7/5MHz)</desc> - <Initialize_eNB_args>-O ci-scripts/conf_files/enb.band13.tm1.25PRB.usrpb210.conf</Initialize_eNB_args> + <Initialize_eNB_args>-O ci-scripts/conf_files/enb.band13.tm1.25PRB.usrpb210.conf --log_config.global_log_options level,nocolor,time</Initialize_eNB_args> <eNB_instance>0</eNB_instance> <eNB_serverId>0</eNB_serverId> </testCase> @@ -69,7 +69,7 @@ <testCase id="030102"> <class>Initialize_eNB</class> <desc>Initialize Slave eNB (FDD/Band7/5MHz)</desc> - <Initialize_eNB_args>-O ci-scripts/conf_files/enb.slave.band13.tm1.25PRB.usrpb210.conf</Initialize_eNB_args> + <Initialize_eNB_args>-O ci-scripts/conf_files/enb.slave.band13.tm1.25PRB.usrpb210.conf --log_config.global_log_options level,nocolor,time</Initialize_eNB_args> <eNB_instance>1</eNB_instance> <eNB_serverId>1</eNB_serverId> </testCase> diff --git a/ci-scripts/yaml_files/4g_rfsimulator/README.md b/ci-scripts/yaml_files/4g_rfsimulator_fdd_05MHz/README.md similarity index 100% rename from ci-scripts/yaml_files/4g_rfsimulator/README.md rename to ci-scripts/yaml_files/4g_rfsimulator_fdd_05MHz/README.md diff --git a/ci-scripts/yaml_files/4g_rfsimulator/docker-compose.yml b/ci-scripts/yaml_files/4g_rfsimulator_fdd_05MHz/docker-compose.yml similarity index 97% rename from ci-scripts/yaml_files/4g_rfsimulator/docker-compose.yml rename to ci-scripts/yaml_files/4g_rfsimulator_fdd_05MHz/docker-compose.yml index 32e4bd41e8146f4b6e52a16324948d2b18f66e9c..e852643ab9227564e8cbc2c3dca1721a473c8e23 100644 --- a/ci-scripts/yaml_files/4g_rfsimulator/docker-compose.yml +++ b/ci-scripts/yaml_files/4g_rfsimulator_fdd_05MHz/docker-compose.yml @@ -221,7 +221,7 @@ services: FLEXRAN_ENABLED: 'no' FLEXRAN_INTERFACE_NAME: eth0 FLEXRAN_IPV4_ADDRESS: 192.168.61.10 - USE_ADDITIONAL_OPTIONS: --rfsim + USE_ADDITIONAL_OPTIONS: --rfsim --log_config.global_log_options level,nocolor,time healthcheck: test: /bin/bash -c "pgrep lte-softmodem" interval: 10s @@ -248,7 +248,7 @@ services: OPC: 'c42449363bbad02b66d16bc975d77cc1' MSISDN: '001011234561010' HPLMN: 20896 - USE_ADDITIONAL_OPTIONS: --rfsim -C 2680000000 -r 25 --ue-rxgain 140 --ue-txgain 120 --nokrnmod 1 + USE_ADDITIONAL_OPTIONS: --rfsim -C 2680000000 -r 25 --ue-rxgain 140 --ue-txgain 120 --nokrnmod 1 --log_config.global_log_options level,nocolor,time healthcheck: test: /bin/bash -c "pgrep lte-uesoftmodem" interval: 10s diff --git a/ci-scripts/yaml_files/4g_rfsimulator/oai_db.cql b/ci-scripts/yaml_files/4g_rfsimulator_fdd_05MHz/oai_db.cql similarity index 100% rename from ci-scripts/yaml_files/4g_rfsimulator/oai_db.cql rename to ci-scripts/yaml_files/4g_rfsimulator_fdd_05MHz/oai_db.cql diff --git a/ci-scripts/yaml_files/4g_rfsimulator_fdd_05MHz_noS1/docker-compose.yml b/ci-scripts/yaml_files/4g_rfsimulator_fdd_05MHz_noS1/docker-compose.yml new file mode 100644 index 0000000000000000000000000000000000000000..6e3916b8ca71af1828a977282d5457c14441472b --- /dev/null +++ b/ci-scripts/yaml_files/4g_rfsimulator_fdd_05MHz_noS1/docker-compose.yml @@ -0,0 +1,75 @@ +version: '3.8' + +services: + enb: + image: oai-enb:develop + privileged: true + container_name: rfsim4g-oai-enb + networks: + public_net: + ipv4_address: 192.168.61.20 + environment: + TZ: Europe/Paris + USE_FDD_MONO: 'yes' + RFSIMULATOR: enb + ENB_NAME: eNB-rf-sim + MCC: '208' + MNC: '96' + MNC_LENGTH: 2 + TAC: 1 + UTRA_BAND_ID: 7 + DL_FREQUENCY_IN_MHZ: 2680 + UL_FREQUENCY_OFFSET_IN_MHZ: 120 + NID_CELL: 10 + NB_PRB: 25 + MME_S1C_IP_ADDRESS: 192.168.61.3 + ENB_S1C_IF_NAME: eth0 + ENB_S1C_IP_ADDRESS: 192.168.61.20 + ENB_S1U_IF_NAME: eth0 + ENB_S1U_IP_ADDRESS: 192.168.61.20 + ENB_X2_IP_ADDRESS: 192.168.61.20 + FLEXRAN_ENABLED: 'no' + FLEXRAN_INTERFACE_NAME: eth0 + FLEXRAN_IPV4_ADDRESS: 192.168.61.10 + USE_ADDITIONAL_OPTIONS: --rfsim --log_config.global_log_options level,nocolor,time --noS1 + healthcheck: + test: /bin/bash -c "pgrep lte-softmodem" + interval: 10s + timeout: 5s + retries: 5 + + oai_ue0: + image: oai-lte-ue:develop + privileged: true + container_name: rfsim4g-oai-lte-ue0 + networks: + public_net: + ipv4_address: 192.168.61.30 + expose: + - "10000" + environment: + TZ: Europe/Paris + HOSTNAME: oai_ue0 + RFSIMULATOR: 192.168.61.20 + MCC: '208' + MNC: '96' + SHORT_IMSI: '0100000001' + LTE_KEY: 'fec86ba6eb707ed08905757b1bb44b8f' + OPC: 'c42449363bbad02b66d16bc975d77cc1' + MSISDN: '001011234561010' + HPLMN: 20896 + USE_ADDITIONAL_OPTIONS: --rfsim -C 2680000000 -r 25 --ue-rxgain 140 --ue-txgain 120 --nokrnmod 1 --log_config.global_log_options level,nocolor,time --noS1 + healthcheck: + test: /bin/bash -c "pgrep lte-uesoftmodem" + interval: 10s + timeout: 5s + retries: 5 + +networks: + public_net: + name: rfsim4g-oai-public-net + ipam: + config: + - subnet: 192.168.61.0/26 + driver_opts: + com.docker.network.bridge.name: "rfsim4g-public" diff --git a/ci-scripts/yaml_files/4g_rfsimulator_fdd_10MHz/docker-compose.yml b/ci-scripts/yaml_files/4g_rfsimulator_fdd_10MHz/docker-compose.yml new file mode 100644 index 0000000000000000000000000000000000000000..4c1ceb424a09e08d3d5d5a316500fb7efda90f9e --- /dev/null +++ b/ci-scripts/yaml_files/4g_rfsimulator_fdd_10MHz/docker-compose.yml @@ -0,0 +1,272 @@ +version: '3.8' + +services: + cassandra: + image: cassandra:2.1 + container_name: rfsim4g-cassandra + networks: + private_net: + ipv4_address: 192.168.68.2 + environment: + CASSANDRA_CLUSTER_NAME: "OAI HSS Cluster" + CASSANDRA_ENDPOINT_SNITCH: GossipingPropertyFileSnitch + healthcheck: + test: /bin/bash -c "nodetool status" + interval: 10s + timeout: 5s + retries: 5 + + db_init: + image: cassandra:2.1 + container_name: rfsim4g-db-init + depends_on: [cassandra] + deploy: + restart_policy: + condition: on-failure + max_attempts: 10 + networks: + private_net: + ipv4_address: 192.168.68.4 + volumes: + - ../4g_rfsimulator_fdd_05MHz/oai_db.cql:/home/oai_db.cql + entrypoint: /bin/bash -c "cqlsh --file /home/oai_db.cql 192.168.68.2 && echo 'OK'" + + oai_hss: + image: oai-hss:latest + container_name: rfsim4g-oai-hss + privileged: true + depends_on: [cassandra] + networks: + private_net: + ipv4_address: 192.168.68.3 + public_net: + ipv4_address: 192.168.61.2 + environment: + REALM: openairinterface.org + HSS_FQDN: hss.openairinterface.org + PREFIX: /openair-hss/etc + cassandra_Server_IP: 192.168.68.2 + OP_KEY: 1006020f0a478bf6b699f15c062e42b3 + LTE_K: fec86ba6eb707ed08905757b1bb44b8f + APN1: oai.ipv4 + APN2: internet + FIRST_IMSI: 208960100000001 + NB_USERS: 10 + healthcheck: + test: /bin/bash -c "pgrep oai_hss" + interval: 10s + timeout: 5s + retries: 5 + + oai_mme: + image: oai-mme:latest + container_name: rfsim4g-oai-mme + privileged: true + depends_on: [oai_hss] + networks: + public_net: + ipv4_address: 192.168.61.3 + environment: + REALM: openairinterface.org + PREFIX: /openair-mme/etc + INSTANCE: 1 + PID_DIRECTORY: /var/run + HSS_IP_ADDR: 192.168.61.2 + HSS_HOSTNAME: hss + HSS_FQDN: hss.openairinterface.org + HSS_REALM: openairinterface.org + MCC: '208' + MNC: '96' + MME_GID: 32768 + MME_CODE: 3 + TAC_0: 1 + TAC_1: 2 + TAC_2: 3 + MME_FQDN: mme.openairinterface.org + MME_S6A_IP_ADDR: 192.168.61.3 + MME_INTERFACE_NAME_FOR_S1_MME: eth0 + MME_IPV4_ADDRESS_FOR_S1_MME: 192.168.61.3 + MME_INTERFACE_NAME_FOR_S11: eth0 + MME_IPV4_ADDRESS_FOR_S11: 192.168.61.3 + MME_INTERFACE_NAME_FOR_S10: lo + MME_IPV4_ADDRESS_FOR_S10: 127.0.0.10 + OUTPUT: CONSOLE + SGW_IPV4_ADDRESS_FOR_S11_0: 192.168.61.4 + PEER_MME_IPV4_ADDRESS_FOR_S10_0: 0.0.0.0 + PEER_MME_IPV4_ADDRESS_FOR_S10_1: 0.0.0.0 + MCC_SGW_0: '208' + MNC3_SGW_0: '096' + TAC_LB_SGW_0: '01' + TAC_HB_SGW_0: '00' + MCC_MME_0: '208' + MNC3_MME_0: '096' + TAC_LB_MME_0: '02' + TAC_HB_MME_0: '00' + MCC_MME_1: '208' + MNC3_MME_1: '096' + TAC_LB_MME_1: '03' + TAC_HB_MME_1: '00' + TAC_LB_SGW_TEST_0: '03' + TAC_HB_SGW_TEST_0: '00' + SGW_IPV4_ADDRESS_FOR_S11_TEST_0: 0.0.0.0 + healthcheck: + test: /bin/bash -c "pgrep oai_mme" + interval: 10s + timeout: 5s + retries: 5 + + oai_spgwc: + image: oai-spgwc:latest + privileged: true + depends_on: [oai_mme] + container_name: rfsim4g-oai-spgwc + networks: + public_net: + ipv4_address: 192.168.61.4 + environment: + TZ: Europe/Paris + SGW_INTERFACE_NAME_FOR_S11: eth0 + PGW_INTERFACE_NAME_FOR_SX: eth0 + DEFAULT_DNS_IPV4_ADDRESS: 192.168.18.129 + DEFAULT_DNS_SEC_IPV4_ADDRESS: 8.8.4.4 + PUSH_PROTOCOL_OPTION: 'true' + APN_NI_1: oai.ipv4 + APN_NI_2: oai.ipv4_2 + DEFAULT_APN_NI_1: oai.ipv4 + UE_IP_ADDRESS_POOL_1: '12.0.0.2 - 12.0.0.254' + UE_IP_ADDRESS_POOL_2: '12.1.1.2 - 12.1.1.254' + MCC: '208' + MNC: '96' + MNC03: '096' + TAC: 1 + GW_ID: 1 + REALM: openairinterface.org + healthcheck: + test: /bin/bash -c "pgrep oai_spgwc" + interval: 10s + timeout: 5s + retries: 5 + + oai_spgwu: + image: oai-spgwu-tiny:latest + privileged: true + container_name: rfsim4g-oai-spgwu-tiny + depends_on: [oai_spgwc] + networks: + public_net: + ipv4_address: 192.168.61.5 + environment: + TZ: Europe/Paris + PID_DIRECTORY: /var/run + INSTANCE: 1 + SGW_INTERFACE_NAME_FOR_S1U_S12_S4_UP: eth0 + PGW_INTERFACE_NAME_FOR_SGI: eth0 + SGW_INTERFACE_NAME_FOR_SX: eth0 + SPGWC0_IP_ADDRESS: 192.168.61.4 + NETWORK_UE_IP: '12.0.0.0/24' + NETWORK_UE_NAT_OPTION: 'yes' + MCC: '208' + MNC: '96' + MNC03: '096' + TAC: 1 + GW_ID: 1 + REALM: openairinterface.org + healthcheck: + test: /bin/bash -c "pgrep oai_spgwu" + interval: 10s + timeout: 5s + retries: 5 + + trf_gen: + image: trf-gen:production + privileged: true + container_name: rfsim4g-trf-gen + networks: + public_net: + ipv4_address: 192.168.61.11 + entrypoint: /bin/bash -c "ip route add 12.0.0.0/24 via 192.168.61.5 dev eth0; sleep infinity" + healthcheck: + test: /bin/bash -c "ping -c 2 192.168.61.5" + interval: 10s + timeout: 5s + retries: 5 + + enb: + image: oai-enb:develop + privileged: true + container_name: rfsim4g-oai-enb + networks: + public_net: + ipv4_address: 192.168.61.20 + environment: + TZ: Europe/Paris + USE_FDD_MONO: 'yes' + RFSIMULATOR: enb + ENB_NAME: eNB-rf-sim + MCC: '208' + MNC: '96' + MNC_LENGTH: 2 + TAC: 1 + UTRA_BAND_ID: 7 + DL_FREQUENCY_IN_MHZ: 2680 + UL_FREQUENCY_OFFSET_IN_MHZ: 120 + NID_CELL: 10 + NB_PRB: 50 + MME_S1C_IP_ADDRESS: 192.168.61.3 + ENB_S1C_IF_NAME: eth0 + ENB_S1C_IP_ADDRESS: 192.168.61.20 + ENB_S1U_IF_NAME: eth0 + ENB_S1U_IP_ADDRESS: 192.168.61.20 + ENB_X2_IP_ADDRESS: 192.168.61.20 + FLEXRAN_ENABLED: 'no' + FLEXRAN_INTERFACE_NAME: eth0 + FLEXRAN_IPV4_ADDRESS: 192.168.61.10 + USE_ADDITIONAL_OPTIONS: --rfsim --log_config.global_log_options level,nocolor,time + healthcheck: + test: /bin/bash -c "pgrep lte-softmodem" + interval: 10s + timeout: 5s + retries: 5 + + oai_ue0: + image: oai-lte-ue:develop + privileged: true + container_name: rfsim4g-oai-lte-ue0 + networks: + public_net: + ipv4_address: 192.168.61.30 + expose: + - "10000" + environment: + TZ: Europe/Paris + HOSTNAME: oai_ue0 + RFSIMULATOR: 192.168.61.20 + MCC: '208' + MNC: '96' + SHORT_IMSI: '0100000001' + LTE_KEY: 'fec86ba6eb707ed08905757b1bb44b8f' + OPC: 'c42449363bbad02b66d16bc975d77cc1' + MSISDN: '001011234561010' + HPLMN: 20896 + USE_ADDITIONAL_OPTIONS: --rfsim -C 2680000000 -r 50 --ue-rxgain 140 --ue-txgain 120 --nokrnmod 1 --log_config.global_log_options level,nocolor,time + healthcheck: + test: /bin/bash -c "pgrep lte-uesoftmodem" + interval: 10s + timeout: 5s + retries: 5 + +networks: + private_net: + name: rfsim4g-oai-private-net + ipam: + config: + - subnet: 192.168.68.0/26 + driver_opts: + com.docker.network.bridge.name: "rfsim4g-private" + public_net: + name: rfsim4g-oai-public-net + ipam: + config: + - subnet: 192.168.61.0/26 + driver_opts: + com.docker.network.bridge.name: "rfsim4g-public" diff --git a/ci-scripts/yaml_files/4g_rfsimulator_fdd_20MHz/docker-compose.yml b/ci-scripts/yaml_files/4g_rfsimulator_fdd_20MHz/docker-compose.yml new file mode 100644 index 0000000000000000000000000000000000000000..4a61181afbb620fa64d839e3b82fac5291eddfc5 --- /dev/null +++ b/ci-scripts/yaml_files/4g_rfsimulator_fdd_20MHz/docker-compose.yml @@ -0,0 +1,272 @@ +version: '3.8' + +services: + cassandra: + image: cassandra:2.1 + container_name: rfsim4g-cassandra + networks: + private_net: + ipv4_address: 192.168.68.2 + environment: + CASSANDRA_CLUSTER_NAME: "OAI HSS Cluster" + CASSANDRA_ENDPOINT_SNITCH: GossipingPropertyFileSnitch + healthcheck: + test: /bin/bash -c "nodetool status" + interval: 10s + timeout: 5s + retries: 5 + + db_init: + image: cassandra:2.1 + container_name: rfsim4g-db-init + depends_on: [cassandra] + deploy: + restart_policy: + condition: on-failure + max_attempts: 10 + networks: + private_net: + ipv4_address: 192.168.68.4 + volumes: + - ../4g_rfsimulator_fdd_05MHz/oai_db.cql:/home/oai_db.cql + entrypoint: /bin/bash -c "cqlsh --file /home/oai_db.cql 192.168.68.2 && echo 'OK'" + + oai_hss: + image: oai-hss:latest + container_name: rfsim4g-oai-hss + privileged: true + depends_on: [cassandra] + networks: + private_net: + ipv4_address: 192.168.68.3 + public_net: + ipv4_address: 192.168.61.2 + environment: + REALM: openairinterface.org + HSS_FQDN: hss.openairinterface.org + PREFIX: /openair-hss/etc + cassandra_Server_IP: 192.168.68.2 + OP_KEY: 1006020f0a478bf6b699f15c062e42b3 + LTE_K: fec86ba6eb707ed08905757b1bb44b8f + APN1: oai.ipv4 + APN2: internet + FIRST_IMSI: 208960100000001 + NB_USERS: 10 + healthcheck: + test: /bin/bash -c "pgrep oai_hss" + interval: 10s + timeout: 5s + retries: 5 + + oai_mme: + image: oai-mme:latest + container_name: rfsim4g-oai-mme + privileged: true + depends_on: [oai_hss] + networks: + public_net: + ipv4_address: 192.168.61.3 + environment: + REALM: openairinterface.org + PREFIX: /openair-mme/etc + INSTANCE: 1 + PID_DIRECTORY: /var/run + HSS_IP_ADDR: 192.168.61.2 + HSS_HOSTNAME: hss + HSS_FQDN: hss.openairinterface.org + HSS_REALM: openairinterface.org + MCC: '208' + MNC: '96' + MME_GID: 32768 + MME_CODE: 3 + TAC_0: 1 + TAC_1: 2 + TAC_2: 3 + MME_FQDN: mme.openairinterface.org + MME_S6A_IP_ADDR: 192.168.61.3 + MME_INTERFACE_NAME_FOR_S1_MME: eth0 + MME_IPV4_ADDRESS_FOR_S1_MME: 192.168.61.3 + MME_INTERFACE_NAME_FOR_S11: eth0 + MME_IPV4_ADDRESS_FOR_S11: 192.168.61.3 + MME_INTERFACE_NAME_FOR_S10: lo + MME_IPV4_ADDRESS_FOR_S10: 127.0.0.10 + OUTPUT: CONSOLE + SGW_IPV4_ADDRESS_FOR_S11_0: 192.168.61.4 + PEER_MME_IPV4_ADDRESS_FOR_S10_0: 0.0.0.0 + PEER_MME_IPV4_ADDRESS_FOR_S10_1: 0.0.0.0 + MCC_SGW_0: '208' + MNC3_SGW_0: '096' + TAC_LB_SGW_0: '01' + TAC_HB_SGW_0: '00' + MCC_MME_0: '208' + MNC3_MME_0: '096' + TAC_LB_MME_0: '02' + TAC_HB_MME_0: '00' + MCC_MME_1: '208' + MNC3_MME_1: '096' + TAC_LB_MME_1: '03' + TAC_HB_MME_1: '00' + TAC_LB_SGW_TEST_0: '03' + TAC_HB_SGW_TEST_0: '00' + SGW_IPV4_ADDRESS_FOR_S11_TEST_0: 0.0.0.0 + healthcheck: + test: /bin/bash -c "pgrep oai_mme" + interval: 10s + timeout: 5s + retries: 5 + + oai_spgwc: + image: oai-spgwc:latest + privileged: true + depends_on: [oai_mme] + container_name: rfsim4g-oai-spgwc + networks: + public_net: + ipv4_address: 192.168.61.4 + environment: + TZ: Europe/Paris + SGW_INTERFACE_NAME_FOR_S11: eth0 + PGW_INTERFACE_NAME_FOR_SX: eth0 + DEFAULT_DNS_IPV4_ADDRESS: 192.168.18.129 + DEFAULT_DNS_SEC_IPV4_ADDRESS: 8.8.4.4 + PUSH_PROTOCOL_OPTION: 'true' + APN_NI_1: oai.ipv4 + APN_NI_2: oai.ipv4_2 + DEFAULT_APN_NI_1: oai.ipv4 + UE_IP_ADDRESS_POOL_1: '12.0.0.2 - 12.0.0.254' + UE_IP_ADDRESS_POOL_2: '12.1.1.2 - 12.1.1.254' + MCC: '208' + MNC: '96' + MNC03: '096' + TAC: 1 + GW_ID: 1 + REALM: openairinterface.org + healthcheck: + test: /bin/bash -c "pgrep oai_spgwc" + interval: 10s + timeout: 5s + retries: 5 + + oai_spgwu: + image: oai-spgwu-tiny:latest + privileged: true + container_name: rfsim4g-oai-spgwu-tiny + depends_on: [oai_spgwc] + networks: + public_net: + ipv4_address: 192.168.61.5 + environment: + TZ: Europe/Paris + PID_DIRECTORY: /var/run + INSTANCE: 1 + SGW_INTERFACE_NAME_FOR_S1U_S12_S4_UP: eth0 + PGW_INTERFACE_NAME_FOR_SGI: eth0 + SGW_INTERFACE_NAME_FOR_SX: eth0 + SPGWC0_IP_ADDRESS: 192.168.61.4 + NETWORK_UE_IP: '12.0.0.0/24' + NETWORK_UE_NAT_OPTION: 'yes' + MCC: '208' + MNC: '96' + MNC03: '096' + TAC: 1 + GW_ID: 1 + REALM: openairinterface.org + healthcheck: + test: /bin/bash -c "pgrep oai_spgwu" + interval: 10s + timeout: 5s + retries: 5 + + trf_gen: + image: trf-gen:production + privileged: true + container_name: rfsim4g-trf-gen + networks: + public_net: + ipv4_address: 192.168.61.11 + entrypoint: /bin/bash -c "ip route add 12.0.0.0/24 via 192.168.61.5 dev eth0; sleep infinity" + healthcheck: + test: /bin/bash -c "ping -c 2 192.168.61.5" + interval: 10s + timeout: 5s + retries: 5 + + enb: + image: oai-enb:develop + privileged: true + container_name: rfsim4g-oai-enb + networks: + public_net: + ipv4_address: 192.168.61.20 + environment: + TZ: Europe/Paris + USE_FDD_MONO: 'yes' + RFSIMULATOR: enb + ENB_NAME: eNB-rf-sim + MCC: '208' + MNC: '96' + MNC_LENGTH: 2 + TAC: 1 + UTRA_BAND_ID: 7 + DL_FREQUENCY_IN_MHZ: 2680 + UL_FREQUENCY_OFFSET_IN_MHZ: 120 + NID_CELL: 10 + NB_PRB: 100 + MME_S1C_IP_ADDRESS: 192.168.61.3 + ENB_S1C_IF_NAME: eth0 + ENB_S1C_IP_ADDRESS: 192.168.61.20 + ENB_S1U_IF_NAME: eth0 + ENB_S1U_IP_ADDRESS: 192.168.61.20 + ENB_X2_IP_ADDRESS: 192.168.61.20 + FLEXRAN_ENABLED: 'no' + FLEXRAN_INTERFACE_NAME: eth0 + FLEXRAN_IPV4_ADDRESS: 192.168.61.10 + USE_ADDITIONAL_OPTIONS: --rfsim --log_config.global_log_options level,nocolor,time + healthcheck: + test: /bin/bash -c "pgrep lte-softmodem" + interval: 10s + timeout: 5s + retries: 5 + + oai_ue0: + image: oai-lte-ue:develop + privileged: true + container_name: rfsim4g-oai-lte-ue0 + networks: + public_net: + ipv4_address: 192.168.61.30 + expose: + - "10000" + environment: + TZ: Europe/Paris + HOSTNAME: oai_ue0 + RFSIMULATOR: 192.168.61.20 + MCC: '208' + MNC: '96' + SHORT_IMSI: '0100000001' + LTE_KEY: 'fec86ba6eb707ed08905757b1bb44b8f' + OPC: 'c42449363bbad02b66d16bc975d77cc1' + MSISDN: '001011234561010' + HPLMN: 20896 + USE_ADDITIONAL_OPTIONS: --rfsim -C 2680000000 -r 100 --ue-rxgain 140 --ue-txgain 120 --nokrnmod 1 --log_config.global_log_options level,nocolor,time + healthcheck: + test: /bin/bash -c "pgrep lte-uesoftmodem" + interval: 10s + timeout: 5s + retries: 5 + +networks: + private_net: + name: rfsim4g-oai-private-net + ipam: + config: + - subnet: 192.168.68.0/26 + driver_opts: + com.docker.network.bridge.name: "rfsim4g-private" + public_net: + name: rfsim4g-oai-public-net + ipam: + config: + - subnet: 192.168.61.0/26 + driver_opts: + com.docker.network.bridge.name: "rfsim4g-public" diff --git a/ci-scripts/yaml_files/4g_rfsimulator_tdd_05MHz/docker-compose.yml b/ci-scripts/yaml_files/4g_rfsimulator_tdd_05MHz/docker-compose.yml new file mode 100644 index 0000000000000000000000000000000000000000..3424780791e5b1efaf468781bb99b698fade02e0 --- /dev/null +++ b/ci-scripts/yaml_files/4g_rfsimulator_tdd_05MHz/docker-compose.yml @@ -0,0 +1,271 @@ +version: '3.8' + +services: + cassandra: + image: cassandra:2.1 + container_name: rfsim4g-cassandra + networks: + private_net: + ipv4_address: 192.168.68.2 + environment: + CASSANDRA_CLUSTER_NAME: "OAI HSS Cluster" + CASSANDRA_ENDPOINT_SNITCH: GossipingPropertyFileSnitch + healthcheck: + test: /bin/bash -c "nodetool status" + interval: 10s + timeout: 5s + retries: 5 + + db_init: + image: cassandra:2.1 + container_name: rfsim4g-db-init + depends_on: [cassandra] + deploy: + restart_policy: + condition: on-failure + max_attempts: 10 + networks: + private_net: + ipv4_address: 192.168.68.4 + volumes: + - ../4g_rfsimulator_fdd_05MHz/oai_db.cql:/home/oai_db.cql + entrypoint: /bin/bash -c "cqlsh --file /home/oai_db.cql 192.168.68.2 && echo 'OK'" + + oai_hss: + image: oai-hss:latest + container_name: rfsim4g-oai-hss + privileged: true + depends_on: [cassandra] + networks: + private_net: + ipv4_address: 192.168.68.3 + public_net: + ipv4_address: 192.168.61.2 + environment: + REALM: openairinterface.org + HSS_FQDN: hss.openairinterface.org + PREFIX: /openair-hss/etc + cassandra_Server_IP: 192.168.68.2 + OP_KEY: 1006020f0a478bf6b699f15c062e42b3 + LTE_K: fec86ba6eb707ed08905757b1bb44b8f + APN1: oai.ipv4 + APN2: internet + FIRST_IMSI: 208960100000001 + NB_USERS: 10 + healthcheck: + test: /bin/bash -c "pgrep oai_hss" + interval: 10s + timeout: 5s + retries: 5 + + oai_mme: + image: oai-mme:latest + container_name: rfsim4g-oai-mme + privileged: true + depends_on: [oai_hss] + networks: + public_net: + ipv4_address: 192.168.61.3 + environment: + REALM: openairinterface.org + PREFIX: /openair-mme/etc + INSTANCE: 1 + PID_DIRECTORY: /var/run + HSS_IP_ADDR: 192.168.61.2 + HSS_HOSTNAME: hss + HSS_FQDN: hss.openairinterface.org + HSS_REALM: openairinterface.org + MCC: '208' + MNC: '96' + MME_GID: 32768 + MME_CODE: 3 + TAC_0: 1 + TAC_1: 2 + TAC_2: 3 + MME_FQDN: mme.openairinterface.org + MME_S6A_IP_ADDR: 192.168.61.3 + MME_INTERFACE_NAME_FOR_S1_MME: eth0 + MME_IPV4_ADDRESS_FOR_S1_MME: 192.168.61.3 + MME_INTERFACE_NAME_FOR_S11: eth0 + MME_IPV4_ADDRESS_FOR_S11: 192.168.61.3 + MME_INTERFACE_NAME_FOR_S10: lo + MME_IPV4_ADDRESS_FOR_S10: 127.0.0.10 + OUTPUT: CONSOLE + SGW_IPV4_ADDRESS_FOR_S11_0: 192.168.61.4 + PEER_MME_IPV4_ADDRESS_FOR_S10_0: 0.0.0.0 + PEER_MME_IPV4_ADDRESS_FOR_S10_1: 0.0.0.0 + MCC_SGW_0: '208' + MNC3_SGW_0: '096' + TAC_LB_SGW_0: '01' + TAC_HB_SGW_0: '00' + MCC_MME_0: '208' + MNC3_MME_0: '096' + TAC_LB_MME_0: '02' + TAC_HB_MME_0: '00' + MCC_MME_1: '208' + MNC3_MME_1: '096' + TAC_LB_MME_1: '03' + TAC_HB_MME_1: '00' + TAC_LB_SGW_TEST_0: '03' + TAC_HB_SGW_TEST_0: '00' + SGW_IPV4_ADDRESS_FOR_S11_TEST_0: 0.0.0.0 + healthcheck: + test: /bin/bash -c "pgrep oai_mme" + interval: 10s + timeout: 5s + retries: 5 + + oai_spgwc: + image: oai-spgwc:latest + privileged: true + depends_on: [oai_mme] + container_name: rfsim4g-oai-spgwc + networks: + public_net: + ipv4_address: 192.168.61.4 + environment: + TZ: Europe/Paris + SGW_INTERFACE_NAME_FOR_S11: eth0 + PGW_INTERFACE_NAME_FOR_SX: eth0 + DEFAULT_DNS_IPV4_ADDRESS: 192.168.18.129 + DEFAULT_DNS_SEC_IPV4_ADDRESS: 8.8.4.4 + PUSH_PROTOCOL_OPTION: 'true' + APN_NI_1: oai.ipv4 + APN_NI_2: oai.ipv4_2 + DEFAULT_APN_NI_1: oai.ipv4 + UE_IP_ADDRESS_POOL_1: '12.0.0.2 - 12.0.0.254' + UE_IP_ADDRESS_POOL_2: '12.1.1.2 - 12.1.1.254' + MCC: '208' + MNC: '96' + MNC03: '096' + TAC: 1 + GW_ID: 1 + REALM: openairinterface.org + healthcheck: + test: /bin/bash -c "pgrep oai_spgwc" + interval: 10s + timeout: 5s + retries: 5 + + oai_spgwu: + image: oai-spgwu-tiny:latest + privileged: true + container_name: rfsim4g-oai-spgwu-tiny + depends_on: [oai_spgwc] + networks: + public_net: + ipv4_address: 192.168.61.5 + environment: + TZ: Europe/Paris + PID_DIRECTORY: /var/run + INSTANCE: 1 + SGW_INTERFACE_NAME_FOR_S1U_S12_S4_UP: eth0 + PGW_INTERFACE_NAME_FOR_SGI: eth0 + SGW_INTERFACE_NAME_FOR_SX: eth0 + SPGWC0_IP_ADDRESS: 192.168.61.4 + NETWORK_UE_IP: '12.0.0.0/24' + NETWORK_UE_NAT_OPTION: 'yes' + MCC: '208' + MNC: '96' + MNC03: '096' + TAC: 1 + GW_ID: 1 + REALM: openairinterface.org + healthcheck: + test: /bin/bash -c "pgrep oai_spgwu" + interval: 10s + timeout: 5s + retries: 5 + + trf_gen: + image: trf-gen:production + privileged: true + container_name: rfsim4g-trf-gen + networks: + public_net: + ipv4_address: 192.168.61.11 + entrypoint: /bin/bash -c "ip route add 12.0.0.0/24 via 192.168.61.5 dev eth0; sleep infinity" + healthcheck: + test: /bin/bash -c "ping -c 2 192.168.61.5" + interval: 10s + timeout: 5s + retries: 5 + + enb: + image: oai-enb:develop + privileged: true + container_name: rfsim4g-oai-enb + networks: + public_net: + ipv4_address: 192.168.61.20 + environment: + TZ: Europe/Paris + USE_TDD_MONO: 'yes' + RFSIMULATOR: enb + ENB_NAME: eNB-rf-sim + MCC: '208' + MNC: '96' + MNC_LENGTH: 2 + TAC: 1 + UTRA_BAND_ID: 38 + DL_FREQUENCY_IN_MHZ: 2605 + UL_FREQUENCY_OFFSET_IN_MHZ: 0 + NID_CELL: 10 + NB_PRB: 25 + MME_S1C_IP_ADDRESS: 192.168.61.3 + S1C_IF_NAME: eth0 + F1_CU_IP_ADDRESS: 192.168.61.20 + S1U_IF_NAME: eth0 + F1_CU_IP_ADDRESS: 192.168.61.20 + FLEXRAN_ENABLED: 'no' + FLEXRAN_INTERFACE_NAME: eth0 + FLEXRAN_IPV4_ADDRESS: 192.168.61.10 + USE_ADDITIONAL_OPTIONS: --rfsim --log_config.global_log_options level,nocolor,time + healthcheck: + test: /bin/bash -c "pgrep lte-softmodem" + interval: 10s + timeout: 5s + retries: 5 + + oai_ue0: + image: oai-lte-ue:develop + privileged: true + container_name: rfsim4g-oai-lte-ue0 + networks: + public_net: + ipv4_address: 192.168.61.30 + expose: + - "10000" + environment: + TZ: Europe/Paris + HOSTNAME: oai_ue0 + RFSIMULATOR: 192.168.61.20 + MCC: '208' + MNC: '96' + SHORT_IMSI: '0100000001' + LTE_KEY: 'fec86ba6eb707ed08905757b1bb44b8f' + OPC: 'c42449363bbad02b66d16bc975d77cc1' + MSISDN: '001011234561010' + HPLMN: 20896 + USE_ADDITIONAL_OPTIONS: --rfsim -T -C 2605000000 -r 25 --ue-rxgain 140 --ue-txgain 120 --nokrnmod 1 --log_config.global_log_options level,nocolor,time + healthcheck: + test: /bin/bash -c "pgrep lte-uesoftmodem" + interval: 10s + timeout: 5s + retries: 5 + +networks: + private_net: + name: rfsim4g-oai-private-net + ipam: + config: + - subnet: 192.168.68.0/26 + driver_opts: + com.docker.network.bridge.name: "rfsim4g-private" + public_net: + name: rfsim4g-oai-public-net + ipam: + config: + - subnet: 192.168.61.0/26 + driver_opts: + com.docker.network.bridge.name: "rfsim4g-public" diff --git a/ci-scripts/yaml_files/5g_f1_rfsimulator/amf-healthcheck.sh b/ci-scripts/yaml_files/5g_f1_rfsimulator/amf-healthcheck.sh new file mode 100755 index 0000000000000000000000000000000000000000..8bfdee2aac6150b50240f7af4fa15a5eb105e9bc --- /dev/null +++ b/ci-scripts/yaml_files/5g_f1_rfsimulator/amf-healthcheck.sh @@ -0,0 +1,57 @@ +#!/bin/bash +set -eo pipefail + +STATUS=0 +AMF_PORT_FOR_NGAP=38412 +AMF_PORT_FOR_N11_HTTP=80 +AMF_IP_NGAP_INTERFACE=$(ifconfig $AMF_INTERFACE_NAME_FOR_NGAP | grep inet | awk {'print $2'}) +AMF_IP_N11_INTERFACE=$(ifconfig $AMF_INTERFACE_NAME_FOR_N11 | grep inet | awk {'print $2'}) +N2_PORT_STATUS=$(netstat -Snpl | grep -o "$AMF_IP_NGAP_INTERFACE:$AMF_PORT_FOR_NGAP") +N11_PORT_STATUS=$(netstat -tnpl | grep -o "$AMF_IP_N11_INTERFACE:$AMF_PORT_FOR_N11_HTTP") +#Check if entrypoint properly configured the conf file and no parameter is unset (optional) +NB_UNREPLACED_AT=`cat /openair-amf/etc/*.conf | grep -v contact@openairinterface.org | grep -c @ || true` + +if [ $NB_UNREPLACED_AT -ne 0 ]; then + STATUS=1 + echo "Healthcheck error: configuration file is not configured properly" +fi + +if [[ -z $N2_PORT_STATUS ]]; then + STATUS=1 + echo "Healthcheck error: N2 SCTP port $AMF_PORT_FOR_NGAP is not listening" +fi + +if [[ -z $N11_PORT_STATUS ]]; then + STATUS=1 + echo "Healthcheck error: N11/SBI TCP/HTTP port $AMF_PORT_FOR_N11_HTTP is not listening" +fi + +#host="${MYSQL_SERVER}" +#user="${MYSQL_USER:-root}" +#export MYSQL_PWD="${MYSQL_PASS}" + +#args=( +# -h"$host" +# -u"$user" +# --silent +#) + +#if ! command -v mysql &> /dev/null; then +# echo "Installing mysql command" +# apt update +# apt-get -y install mysql-client +#else +# if select="$(echo 'SELECT 1' | mysql "${args[@]}")" && [ "$select" = '1' ]; then +# database_check=$(mysql -h$host -u$user -D oai_db --silent -e "SELECT * FROM users;") +# if [[ -z $database_check ]]; then +# echo "Healthcheck error: oai_db not populated" +# STATUS=1 +# fi +# STATUS=0 +# else +# echo "Healthcheck error: Mysql port inactive" +# STATUS=1 +# fi +#fi + +exit $STATUS diff --git a/ci-scripts/yaml_files/5g_f1_rfsimulator/docker-compose.yaml b/ci-scripts/yaml_files/5g_f1_rfsimulator/docker-compose.yaml new file mode 100644 index 0000000000000000000000000000000000000000..6a39f2147ea7719ba7337db9b0ffc6713240f0d8 --- /dev/null +++ b/ci-scripts/yaml_files/5g_f1_rfsimulator/docker-compose.yaml @@ -0,0 +1,339 @@ +version: '3.8' +services: + oai-nrf: + container_name: "rfsim5g-oai-nrf" + image: oai-nrf:latest + environment: + - NRF_INTERFACE_NAME_FOR_SBI=eth0 + - NRF_INTERFACE_PORT_FOR_SBI=80 + - NRF_INTERFACE_HTTP2_PORT_FOR_SBI=9090 + - NRF_API_VERSION=v1 + - INSTANCE=0 + - PID_DIRECTORY=/var/run + networks: + public_net: + ipv4_address: 192.168.71.130 + volumes: + - ./nrf-healthcheck.sh:/openair-nrf/bin/nrf-healthcheck.sh + healthcheck: + test: /bin/bash -c "/openair-nrf/bin/nrf-healthcheck.sh" + interval: 10s + timeout: 5s + retries: 5 + mysql: + container_name: "rfsim5g-mysql" + image: mysql:5.7 + volumes: + - ./oai_db.sql:/docker-entrypoint-initdb.d/oai_db.sql + - ./mysql-healthcheck.sh:/tmp/mysql-healthcheck.sh + environment: + - TZ=Europe/Paris + - MYSQL_DATABASE=oai_db + - MYSQL_USER=test + - MYSQL_PASSWORD=test + - MYSQL_ROOT_PASSWORD=linux + healthcheck: + test: /bin/bash -c "/tmp/mysql-healthcheck.sh" + interval: 10s + timeout: 5s + retries: 5 + networks: + public_net: + ipv4_address: 192.168.71.131 + oai-amf: + container_name: "rfsim5g-oai-amf" + image: oai-amf:latest + environment: + - TZ=Europe/paris + - INSTANCE=0 + - PID_DIRECTORY=/var/run + - MCC=208 + - MNC=99 + - REGION_ID=128 + - AMF_SET_ID=1 + - SERVED_GUAMI_MCC_0=208 + - SERVED_GUAMI_MNC_0=99 + - SERVED_GUAMI_REGION_ID_0=128 + - SERVED_GUAMI_AMF_SET_ID_0=1 + - SERVED_GUAMI_MCC_1=460 + - SERVED_GUAMI_MNC_1=11 + - SERVED_GUAMI_REGION_ID_1=10 + - SERVED_GUAMI_AMF_SET_ID_1=1 + - PLMN_SUPPORT_MCC=208 + - PLMN_SUPPORT_MNC=99 + - PLMN_SUPPORT_TAC=0x0001 + - SST_0=1 + - SD_0=1 + - SST_1=1 + - SD_1=12 + - AMF_INTERFACE_NAME_FOR_NGAP=eth0 + - AMF_INTERFACE_NAME_FOR_N11=eth0 + - SMF_INSTANCE_ID_0=1 + - SMF_FQDN_0=oai-smf + - SMF_IPV4_ADDR_0=0.0.0.0 + - SMF_HTTP_VERSION_0=v1 + - SELECTED_0=true + - SMF_INSTANCE_ID_1=2 + - SMF_FQDN_1=oai-smf + - SMF_IPV4_ADDR_1=0.0.0.0 + - SMF_HTTP_VERSION_1=v1 + - SELECTED_1=false + - MYSQL_SERVER=192.168.71.131 + - MYSQL_USER=root + - MYSQL_PASS=linux + - MYSQL_DB=oai_db + - OPERATOR_KEY=c42449363bbad02b66d16bc975d77cc1 + - NRF_IPV4_ADDRESS=192.168.71.130 + - NRF_PORT=80 + - NF_REGISTRATION=yes + - SMF_SELECTION=yes + - USE_FQDN_DNS=yes + - NRF_API_VERSION=v1 + - NRF_FQDN=oai-nrf + - EXTERNAL_AUSF=no + - AUSF_IPV4_ADDRESS=0.0.0.0 + - AUSF_PORT=80 + - AUSF_API_VERSION=v1 + - AUSF_FQDN=localhost + depends_on: + - oai-nrf + - mysql + volumes: + - ./amf-healthcheck.sh:/openair-amf/bin/amf-healthcheck.sh + healthcheck: + test: /bin/bash -c "/openair-amf/bin/amf-healthcheck.sh" + interval: 10s + timeout: 15s + retries: 5 + networks: + public_net: + ipv4_address: 192.168.71.132 + oai-smf: + container_name: "rfsim5g-oai-smf" + image: oai-smf:latest + environment: + - TZ=Europe/Paris + - INSTANCE=0 + - PID_DIRECTORY=/var/run + - SMF_INTERFACE_NAME_FOR_N4=eth0 + - SMF_INTERFACE_NAME_FOR_SBI=eth0 + - SMF_INTERFACE_PORT_FOR_SBI=80 + - SMF_INTERFACE_HTTP2_PORT_FOR_SBI=9090 + - SMF_API_VERSION=v1 + - DEFAULT_DNS_IPV4_ADDRESS=192.168.18.129 + - DEFAULT_DNS_SEC_IPV4_ADDRESS=4.4.4.4 + - AMF_IPV4_ADDRESS=0.0.0.0 + - AMF_PORT=80 + - AMF_API_VERSION=v1 + - AMF_FQDN=oai-amf + - UDM_IPV4_ADDRESS=127.0.0.1 + - UDM_PORT=80 + - UDM_API_VERSION=v1 + - UDM_FQDN=localhost + - UPF_IPV4_ADDRESS=192.168.71.134 + - UPF_FQDN_0=oai-spgwu + - NRF_IPV4_ADDRESS=192.168.71.130 + - NRF_PORT=80 + - NRF_API_VERSION=v1 + - NRF_FQDN=oai-nrf + - REGISTER_NRF=yes + - DISCOVER_UPF=yes + - USE_FQDN_DNS=yes + - DNN_NI0=oai + - DNN_NI2=oai.ipv4 + depends_on: + - oai-nrf + - oai-amf + volumes: + - ./smf-healthcheck.sh:/openair-smf/bin/smf-healthcheck.sh + healthcheck: + test: /bin/bash -c "/openair-smf/bin/smf-healthcheck.sh" + interval: 10s + timeout: 5s + retries: 5 + networks: + public_net: + ipv4_address: 192.168.71.133 + oai-spgwu: + container_name: "rfsim5g-oai-spgwu" + image: oai-spgwu-tiny:latest + environment: + - TZ=Europe/Paris + - PID_DIRECTORY=/var/run + - SGW_INTERFACE_NAME_FOR_S1U_S12_S4_UP=eth0 + - SGW_INTERFACE_NAME_FOR_SX=eth0 + - PGW_INTERFACE_NAME_FOR_SGI=eth0 + - NETWORK_UE_NAT_OPTION=yes + - NETWORK_UE_IP=12.1.1.0/24 + - SPGWC0_IP_ADDRESS=192.168.71.133 + - BYPASS_UL_PFCP_RULES=no + - MCC=208 + - MNC=99 + - MNC03=099 + - TAC=1 + - GTP_EXTENSION_HEADER_PRESENT=yes + - GW_ID=1 + - REALM=openairinterface.org + - ENABLE_5G_FEATURES=yes + - REGISTER_NRF=yes + - USE_FQDN_NRF=yes + - UPF_FQDN_5G=oai-spgwu + - NRF_IPV4_ADDRESS=192.168.71.130 + - NRF_PORT=80 + - NRF_API_VERSION=v1 + - NRF_FQDN=oai-nrf + - NSSAI_SST_0=1 + - NSSAI_SD_0=1 + - DNN_0=oai + depends_on: + - oai-nrf + - oai-smf + cap_add: + - NET_ADMIN + - SYS_ADMIN + cap_drop: + - ALL + privileged: true + volumes: + - ./spgwu-healthcheck.sh:/openair-spgwu-tiny/bin/spgwu-healthcheck.sh + healthcheck: + test: /bin/bash -c "/openair-spgwu-tiny/bin/spgwu-healthcheck.sh" + interval: 10s + timeout: 5s + retries: 5 + networks: + public_net: + ipv4_address: 192.168.71.134 + traffic_net: + ipv4_address: 192.168.72.134 + oai-ext-dn: + image: ubuntu:bionic + privileged: true + container_name: rfsim5g-oai-ext-dn + entrypoint: /bin/bash -c \ + "apt update; apt install -y procps iptables iproute2 iperf iputils-ping;"\ + "iptables -t nat -A POSTROUTING -o eth0 -j MASQUERADE;"\ + "ip route add 12.1.1.0/24 via 192.168.72.134 dev eth0; sleep infinity" + depends_on: + - oai-spgwu + networks: + traffic_net: + ipv4_address: 192.168.72.135 + healthcheck: + test: /bin/bash -c "ping -c 2 192.168.72.134" + interval: 10s + timeout: 5s + retries: 5 + oai-cu: + image: oai-gnb:develop + privileged: true + container_name: rfsim5g-oai-cu + environment: + RFSIMULATOR: server + USE_SA_CU: 'yes' + GNB_NAME: cu-rfsim + TAC: 1 + MCC: '208' + 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.136 + GNB_NGU_IF_NAME: eth0 + GNB_NGU_IP_ADDRESS: 192.168.71.136 + F1_IF_NAME: eth0 + F1_CU_IP_ADDRESS: 192.168.71.136 + F1_DU_IP_ADDRESS: 192.168.71.138 + F1_CU_D_PORT: 2153 + F1_DU_D_PORT: 2153 + USE_ADDITIONAL_OPTIONS: --sa --rfsim --log_config.global_log_options level,nocolor,time + depends_on: + - oai-ext-dn + networks: + public_net: + ipv4_address: 192.168.71.136 + healthcheck: + test: /bin/bash -c "pgrep nr-softmodem" + interval: 10s + timeout: 5s + retries: 5 + oai-du: + image: oai-gnb:develop + privileged: true + container_name: rfsim5g-oai-du + environment: + RFSIMULATOR: server + USE_SA_TDD_CU: 'yes' + GNB_NAME: du-rfsim + TAC: 1 + MCC: '208' + 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.138 + GNB_NGU_IF_NAME: eth0 + GNB_NGU_IP_ADDRESS: 192.168.71.138 + F1_IF_NAME: eth0 + F1_CU_IP_ADDRESS: 192.168.71.136 + F1_DU_IP_ADDRESS: 192.168.71.138 + F1_CU_D_PORT: 2153 + F1_DU_D_PORT: 2153 + USE_ADDITIONAL_OPTIONS: --sa --rfsim --log_config.global_log_options level,nocolor,time + depends_on: + - oai-cu + networks: + public_net: + ipv4_address: 192.168.71.138 + healthcheck: + test: /bin/bash -c "pgrep nr-softmodem" + interval: 10s + timeout: 5s + retries: 5 + oai-nr-ue: + image: oai-nr-ue:develop + privileged: true + container_name: rfsim5g-oai-nr-ue + environment: + RFSIMULATOR: 192.168.71.138 + FULL_IMSI: '208990100001100' + FULL_KEY: 'fec86ba6eb707ed08905757b1bb44b8f' + 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 + networks: + public_net: + ipv4_address: 192.168.71.137 + healthcheck: + test: /bin/bash -c "pgrep nr-uesoftmodem" + interval: 10s + timeout: 5s + retries: 5 + +networks: + public_net: + driver: bridge + name: rfsim5g-oai-public-net + ipam: + config: + - subnet: 192.168.71.128/26 + driver_opts: + com.docker.network.bridge.name: "rfsim5g-public" + traffic_net: + driver: bridge + name: rfsim5g-oai-traffic_net-net + ipam: + config: + - subnet: 192.168.72.128/26 + driver_opts: + com.docker.network.bridge.name: "rfsim5g-traffic" diff --git a/ci-scripts/yaml_files/5g_f1_rfsimulator/mysql-healthcheck.sh b/ci-scripts/yaml_files/5g_f1_rfsimulator/mysql-healthcheck.sh new file mode 100755 index 0000000000000000000000000000000000000000..c92efb9f00a1f69e36dbc8bd410c163bb5d37a97 --- /dev/null +++ b/ci-scripts/yaml_files/5g_f1_rfsimulator/mysql-healthcheck.sh @@ -0,0 +1,46 @@ +#!/bin/bash +set -eo pipefail + +if [ "$MYSQL_ROOT_PASSWORD" ] && [ -z "$MYSQL_USER" ] && [ -z "$MYSQL_PASSWORD" ]; then + echo >&2 'Healthcheck error: cannot determine root password (and MYSQL_USER and MYSQL_PASSWORD were not set)' + exit 0 +fi + +host="$(hostname --ip-address || echo '127.0.0.1')" +user="${MYSQL_USER:-root}" +export MYSQL_PWD="${MYSQL_PASSWORD:-$MYSQL_ROOT_PASSWORD}" + +args=( + # force mysql to not use the local "mysqld.sock" (test "external" connectivity) + -h"$host" + -u"$user" + --silent +) + +STATUS=0 +if command -v mysqladmin &> /dev/null; then + if mysqladmin "${args[@]}" ping > /dev/null; then + database_check=$(mysql -u$user -D oai_db --silent -e "SELECT * FROM users;") + if [[ -z $database_check ]]; then + echo "Healthcheck error: oai_db not populated" + STATUS=1 + fi + STATUS=0 + else + echo "Healthcheck error: Mysql port inactive" + STATUS=1 + fi +else + if select="$(echo 'SELECT 1' | mysql "${args[@]}")" && [ "$select" = '1' ]; then + database_check=$(mysql -u$user -D oai_db --silent -e "SELECT * FROM users;") + if [[ -z $database_check ]]; then + echo "Healthcheck error: oai_db not populated" + STATUS=1 + fi + STATUS=0 + else + echo "Healthcheck error: Mysql port inactive" + STATUS=1 + fi +fi +exit $STATUS diff --git a/ci-scripts/yaml_files/5g_f1_rfsimulator/nrf-healthcheck.sh b/ci-scripts/yaml_files/5g_f1_rfsimulator/nrf-healthcheck.sh new file mode 100755 index 0000000000000000000000000000000000000000..3479c092e8805bf45007d1a4635ee43149786401 --- /dev/null +++ b/ci-scripts/yaml_files/5g_f1_rfsimulator/nrf-healthcheck.sh @@ -0,0 +1,20 @@ +#!/bin/bash +set -eo pipefail + +STATUS=0 +NRF_IP_SBI_INTERFACE=$(ifconfig $NRF_INTERFACE_NAME_FOR_SBI | grep inet | awk {'print $2'}) +NRF_SBI_PORT_STATUS=$(netstat -tnpl | grep -o "$NRF_IP_SBI_INTERFACE:$NRF_INTERFACE_PORT_FOR_SBI") +#Check if entrypoint properly configured the conf file and no parameter is unset(optional) +NB_UNREPLACED_AT=`cat /openair-nrf/etc/*.conf | grep -v contact@openairinterface.org | grep -c @ || true` + +if [ $NB_UNREPLACED_AT -ne 0 ]; then + STATUS=1 + echo "Healthcheck error: UNHEALTHY configuration file is not configured properly" +fi + +if [[ -z $NRF_SBI_PORT_STATUS ]]; then + STATUS=1 + echo "Healthcheck error: UNHEALTHY SBI TCP/HTTP port $NRF_INTERFACE_PORT_FOR_SBI is not listening." +fi + +exit $STATUS \ No newline at end of file diff --git a/ci-scripts/yaml_files/5g_f1_rfsimulator/oai_db.sql b/ci-scripts/yaml_files/5g_f1_rfsimulator/oai_db.sql new file mode 100755 index 0000000000000000000000000000000000000000..fbd7907a71edd41cc32016f91176b270b8b5bd11 --- /dev/null +++ b/ci-scripts/yaml_files/5g_f1_rfsimulator/oai_db.sql @@ -0,0 +1,217 @@ +-- MySQL dump 10.13 Distrib 5.5.46, for debian-linux-gnu (x86_64) +-- +-- Host: localhost Database: oai_db +-- ------------------------------------------------------ +-- Server version 5.5.46-0ubuntu0.14.04.2 + +/*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */; +/*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */; +/*!40101 SET @OLD_COLLATION_CONNECTION=@@COLLATION_CONNECTION */; +/*!40101 SET NAMES utf8 */; +/*!40103 SET @OLD_TIME_ZONE=@@TIME_ZONE */; +/*!40103 SET TIME_ZONE='+00:00' */; +/*!40014 SET @OLD_UNIQUE_CHECKS=@@UNIQUE_CHECKS, UNIQUE_CHECKS=0 */; +/*!40014 SET @OLD_FOREIGN_KEY_CHECKS=@@FOREIGN_KEY_CHECKS, FOREIGN_KEY_CHECKS=0 */; +/*!40101 SET @OLD_SQL_MODE=@@SQL_MODE, SQL_MODE='NO_AUTO_VALUE_ON_ZERO' */; +/*!40111 SET @OLD_SQL_NOTES=@@SQL_NOTES, SQL_NOTES=0 */; + +-- +-- Table structure for table `apn` +-- + +DROP TABLE IF EXISTS `apn`; +/*!40101 SET @saved_cs_client = @@character_set_client */; +/*!40101 SET character_set_client = utf8 */; +CREATE TABLE `apn` ( + `id` int(11) NOT NULL AUTO_INCREMENT, + `apn-name` varchar(60) NOT NULL, + `pdn-type` enum('IPv4','IPv6','IPv4v6','IPv4_or_IPv6') NOT NULL, + PRIMARY KEY (`id`), + UNIQUE KEY `apn-name` (`apn-name`) +) ENGINE=InnoDB DEFAULT CHARSET=latin1; +/*!40101 SET character_set_client = @saved_cs_client */; + +-- +-- Dumping data for table `apn` +-- + +LOCK TABLES `apn` WRITE; +/*!40000 ALTER TABLE `apn` DISABLE KEYS */; +/*!40000 ALTER TABLE `apn` ENABLE KEYS */; +UNLOCK TABLES; + +-- +-- Table structure for table `mmeidentity` +-- + +DROP TABLE IF EXISTS `mmeidentity`; +/*!40101 SET @saved_cs_client = @@character_set_client */; +/*!40101 SET character_set_client = utf8 */; +CREATE TABLE `mmeidentity` ( + `idmmeidentity` int(11) NOT NULL AUTO_INCREMENT, + `mmehost` varchar(255) DEFAULT NULL, + `mmerealm` varchar(200) DEFAULT NULL, + `UE-Reachability` tinyint(1) NOT NULL COMMENT 'Indicates whether the MME supports UE Reachability Notifcation', + PRIMARY KEY (`idmmeidentity`) +) ENGINE=MyISAM AUTO_INCREMENT=46 DEFAULT CHARSET=latin1; +/*!40101 SET character_set_client = @saved_cs_client */; + +-- +-- Dumping data for table `mmeidentity` +-- + +LOCK TABLES `mmeidentity` WRITE; +/*!40000 ALTER TABLE `mmeidentity` DISABLE KEYS */; +INSERT INTO `mmeidentity` VALUES (2,'mme2.openair4G.eur','openair4G.eur',0),(1,'nano.openair4G.eur','openair4G.eur',0),(5,'abeille.openair4G.eur','openair4G.eur',0),(4,'yang.openair4G.eur','openair4G.eur',0),(3,'mme3.openair4G.eur','openair4G.eur',0),(6,'calisson.openair4G.eur','openair4G.eur',0); +/*!40000 ALTER TABLE `mmeidentity` ENABLE KEYS */; +UNLOCK TABLES; + +-- +-- Table structure for table `pdn` +-- + +DROP TABLE IF EXISTS `pdn`; +/*!40101 SET @saved_cs_client = @@character_set_client */; +/*!40101 SET character_set_client = utf8 */; +CREATE TABLE `pdn` ( + `id` int(11) NOT NULL AUTO_INCREMENT, + `apn` varchar(60) NOT NULL, + `pdn_type` enum('IPv4','IPv6','IPv4v6','IPv4_or_IPv6') NOT NULL DEFAULT 'IPv4', + `pdn_ipv4` varchar(15) DEFAULT '0.0.0.0', + `pdn_ipv6` varchar(45) CHARACTER SET latin1 COLLATE latin1_general_ci DEFAULT '0:0:0:0:0:0:0:0', + `aggregate_ambr_ul` int(10) unsigned DEFAULT '50000000', + `aggregate_ambr_dl` int(10) unsigned DEFAULT '100000000', + `pgw_id` int(11) NOT NULL, + `users_imsi` varchar(15) NOT NULL, + `qci` tinyint(3) unsigned NOT NULL DEFAULT '9', + `priority_level` tinyint(3) unsigned NOT NULL DEFAULT '15', + `pre_emp_cap` enum('ENABLED','DISABLED') DEFAULT 'DISABLED', + `pre_emp_vul` enum('ENABLED','DISABLED') DEFAULT 'DISABLED', + `LIPA-Permissions` enum('LIPA-prohibited','LIPA-only','LIPA-conditional') NOT NULL DEFAULT 'LIPA-only', + PRIMARY KEY (`id`,`pgw_id`,`users_imsi`), + KEY `fk_pdn_pgw1_idx` (`pgw_id`), + KEY `fk_pdn_users1_idx` (`users_imsi`) +) ENGINE=MyISAM AUTO_INCREMENT=60 DEFAULT CHARSET=latin1; +/*!40101 SET character_set_client = @saved_cs_client */; + +-- +-- Dumping data for table `pdn` +-- + +LOCK TABLES `pdn` WRITE; +/*!40000 ALTER TABLE `pdn` DISABLE KEYS */; +INSERT INTO `pdn` VALUES (1,'oai.ipv4','IPv4','0.0.0.0','0:0:0:0:0:0:0:0',50000000,100000000,3,'208930000000001',9,15,'DISABLED','ENABLED','LIPA-only'),(41,'oai.ipv4','IPv4','0.0.0.0','0:0:0:0:0:0:0:0',50000000,100000000,3,'20834123456789',9,15,'DISABLED','ENABLED','LIPA-only'),(40,'oai.ipv4','IPv4','0.0.0.0','0:0:0:0:0:0:0:0',50000000,100000000,3,'20810000001234',9,15,'DISABLED','ENABLED','LIPA-only'),(42,'oai.ipv4','IPv4','0.0.0.0','0:0:0:0:0:0:0:0',50000000,100000000,3,'31002890832150',9,15,'DISABLED','ENABLED','LIPA-only'),(16,'oai.ipv4','IPv4','0.0.0.0','0:0:0:0:0:0:0:0',50000000,100000000,3,'208950000000002',9,15,'DISABLED','ENABLED','LIPA-only'),(43,'oai.ipv4','IPv4','0.0.0.0','0:0:0:0:0:0:0:0',50000000,100000000,3,'001010123456789',9,15,'DISABLED','ENABLED','LIPA-only'),(2,'oai.ipv4','IPv4','0.0.0.0','0:0:0:0:0:0:0:0',50000000,100000000,3,'208930000000002',9,15,'DISABLED','ENABLED','LIPA-only'),(3,'oai.ipv4','IPv4','0.0.0.0','0:0:0:0:0:0:0:0',50000000,100000000,3,'208930000000003',9,15,'DISABLED','ENABLED','LIPA-only'),(4,'oai.ipv4','IPv4','0.0.0.0','0:0:0:0:0:0:0:0',50000000,100000000,3,'208930000000004',9,15,'DISABLED','ENABLED','LIPA-only'),(5,'oai.ipv4','IPv4','0.0.0.0','0:0:0:0:0:0:0:0',50000000,100000000,3,'208930000000005',9,15,'DISABLED','ENABLED','LIPA-only'),(6,'oai.ipv4','IPv4','0.0.0.0','0:0:0:0:0:0:0:0',50000000,100000000,3,'208930000000006',9,15,'DISABLED','ENABLED','LIPA-only'),(7,'oai.ipv4','IPv4','0.0.0.0','0:0:0:0:0:0:0:0',50000000,100000000,3,'208930000000007',9,15,'DISABLED','ENABLED','LIPA-only'),(8,'oai.ipv4','IPv4','0.0.0.0','0:0:0:0:0:0:0:0',50000000,100000000,3,'208940000000001',9,15,'DISABLED','ENABLED','LIPA-only'),(9,'oai.ipv4','IPv4','0.0.0.0','0:0:0:0:0:0:0:0',50000000,100000000,3,'208940000000002',9,15,'DISABLED','ENABLED','LIPA-only'),(10,'oai.ipv4','IPv4','0.0.0.0','0:0:0:0:0:0:0:0',50000000,100000000,3,'208940000000003',9,15,'DISABLED','ENABLED','LIPA-only'),(11,'oai.ipv4','IPv4','0.0.0.0','0:0:0:0:0:0:0:0',50000000,100000000,3,'208940000000004',9,15,'DISABLED','ENABLED','LIPA-only'),(12,'oai.ipv4','IPv4','0.0.0.0','0:0:0:0:0:0:0:0',50000000,100000000,3,'208940000000005',9,15,'DISABLED','ENABLED','LIPA-only'),(13,'oai.ipv4','IPv4','0.0.0.0','0:0:0:0:0:0:0:0',50000000,100000000,3,'208940000000006',9,15,'DISABLED','ENABLED','LIPA-only'),(14,'oai.ipv4','IPv4','0.0.0.0','0:0:0:0:0:0:0:0',50000000,100000000,3,'208940000000007',9,15,'DISABLED','ENABLED','LIPA-only'),(15,'oai.ipv4','IPv4','0.0.0.0','0:0:0:0:0:0:0:0',50000000,100000000,3,'208950000000001',9,15,'DISABLED','ENABLED','LIPA-only'),(17,'oai.ipv4','IPv4','0.0.0.0','0:0:0:0:0:0:0:0',50000000,100000000,3,'208950000000003',9,15,'DISABLED','ENABLED','LIPA-only'),(18,'oai.ipv4','IPv4','0.0.0.0','0:0:0:0:0:0:0:0',50000000,100000000,3,'208950000000004',9,15,'DISABLED','ENABLED','LIPA-only'),(19,'oai.ipv4','IPv4','0.0.0.0','0:0:0:0:0:0:0:0',50000000,100000000,3,'208950000000005',9,15,'DISABLED','ENABLED','LIPA-only'),(20,'oai.ipv4','IPv4','0.0.0.0','0:0:0:0:0:0:0:0',50000000,100000000,3,'208950000000006',9,15,'DISABLED','ENABLED','LIPA-only'),(21,'oai.ipv4','IPv4','0.0.0.0','0:0:0:0:0:0:0:0',50000000,100000000,3,'208950000000007',9,15,'DISABLED','ENABLED','LIPA-only'),(22,'oai.ipv4','IPv4','0.0.0.0','0:0:0:0:0:0:0:0',50000000,100000000,3,'208920100001100',9,15,'DISABLED','ENABLED','LIPA-only'),(23,'oai.ipv4','IPv4','0.0.0.0','0:0:0:0:0:0:0:0',50000000,100000000,3,'208920100001101',9,15,'DISABLED','ENABLED','LIPA-only'),(24,'oai.ipv4','IPv4','0.0.0.0','0:0:0:0:0:0:0:0',50000000,100000000,3,'208920100001102',9,15,'DISABLED','ENABLED','LIPA-only'),(25,'oai.ipv4','IPv4','0.0.0.0','0:0:0:0:0:0:0:0',50000000,100000000,3,'208920100001103',9,15,'DISABLED','ENABLED','LIPA-only'),(26,'oai.ipv4','IPv4','0.0.0.0','0:0:0:0:0:0:0:0',50000000,100000000,3,'208920100001104',9,15,'DISABLED','ENABLED','LIPA-only'),(27,'oai.ipv4','IPv4','0.0.0.0','0:0:0:0:0:0:0:0',50000000,100000000,3,'208920100001105',9,15,'DISABLED','ENABLED','LIPA-only'),(28,'oai.ipv4','IPv4','0.0.0.0','0:0:0:0:0:0:0:0',50000000,100000000,3,'208920100001106',9,15,'DISABLED','ENABLED','LIPA-only'),(29,'oai.ipv4','IPv4','0.0.0.0','0:0:0:0:0:0:0:0',50000000,100000000,3,'208920100001107',9,15,'DISABLED','ENABLED','LIPA-only'),(30,'oai.ipv4','IPv4','0.0.0.0','0:0:0:0:0:0:0:0',50000000,100000000,3,'208920100001108',9,15,'DISABLED','ENABLED','LIPA-only'),(31,'oai.ipv4','IPv4','0.0.0.0','0:0:0:0:0:0:0:0',50000000,100000000,3,'208920100001109',9,15,'DISABLED','ENABLED','LIPA-only'),(32,'oai.ipv4','IPv4','0.0.0.0','0:0:0:0:0:0:0:0',50000000,100000000,3,'208920100001110',9,15,'DISABLED','ENABLED','LIPA-only'),(33,'oai.ipv4','IPv4','0.0.0.0','0:0:0:0:0:0:0:0',50000000,100000000,3,'208930100001111',9,15,'DISABLED','ENABLED','LIPA-only'),(34,'oai.ipv4','IPv4','0.0.0.0','0:0:0:0:0:0:0:0',50000000,100000000,3,'208930100001112',9,15,'DISABLED','ENABLED','LIPA-only'),(35,'oai.ipv4','IPv4','0.0.0.0','0:0:0:0:0:0:0:0',50000000,100000000,3,'208930100001113',9,15,'DISABLED','ENABLED','LIPA-only'),(44,'operator','IPv4','0.0.0.0','0:0:0:0:0:0:0:0',50000000,100000000,3,'208930100001113',9,15,'DISABLED','ENABLED','LIPA-only'),(45,'operator','IPv4','0.0.0.0','0:0:0:0:0:0:0:0',50000000,100000000,3,'208930100001112',9,15,'DISABLED','ENABLED','LIPA-only'),(46,'operator','IPv4','0.0.0.0','0:0:0:0:0:0:0:0',50000000,100000000,3,'208930100001111',9,15,'DISABLED','ENABLED','LIPA-only'),(47,'operator','IPv4','0.0.0.0','0:0:0:0:0:0:0:0',50000000,100000000,3,'208950000000002',9,15,'DISABLED','ENABLED','LIPA-only'),(48,'oai.ipv4','IPv4','0.0.0.0','0:0:0:0:0:0:0:0',50000000,100000000,3,'208950000000008',9,15,'DISABLED','ENABLED','LIPA-only'),(49,'oai.ipv4','IPv4','0.0.0.0','0:0:0:0:0:0:0:0',50000000,100000000,3,'208950000000009',9,15,'DISABLED','ENABLED','LIPA-only'),(50,'oai.ipv4','IPv4','0.0.0.0','0:0:0:0:0:0:0:0',50000000,100000000,3,'208950000000010',9,15,'DISABLED','ENABLED','LIPA-only'),(51,'oai.ipv4','IPv4','0.0.0.0','0:0:0:0:0:0:0:0',50000000,100000000,3,'208950000000011',9,15,'DISABLED','ENABLED','LIPA-only'),(52,'oai.ipv4','IPv4','0.0.0.0','0:0:0:0:0:0:0:0',50000000,100000000,3,'208950000000012',9,15,'DISABLED','ENABLED','LIPA-only'),(53,'oai.ipv4','IPv4','0.0.0.0','0:0:0:0:0:0:0:0',50000000,100000000,3,'208950000000013',9,15,'DISABLED','ENABLED','LIPA-only'),(54,'oai.ipv4','IPv4','0.0.0.0','0:0:0:0:0:0:0:0',50000000,100000000,3,'208950000000014',9,15,'DISABLED','ENABLED','LIPA-only'),(55,'oai.ipv4','IPv4','0.0.0.0','0:0:0:0:0:0:0:0',50000000,100000000,3,'208950000000015',9,15,'DISABLED','ENABLED','LIPA-only'),(56,'oai.ipv4','IPv4','0.0.0.0','0:0:0:0:0:0:0:0',50000000,100000000,3,'208920100001118',9,15,'DISABLED','ENABLED','LIPA-only'),(57,'oai.ipv4','IPv4','0.0.0.0','0:0:0:0:0:0:0:0',50000000,100000000,3,'208920100001121',9,15,'DISABLED','ENABLED','LIPA-only'),(58,'oai.ipv4','IPv4','0.0.0.0','0:0:0:0:0:0:0:0',50000000,100000000,3,'208920100001120',9,15,'DISABLED','ENABLED','LIPA-only'),(59,'oai.ipv4','IPv4','0.0.0.0','0:0:0:0:0:0:0:0',50000000,100000000,3,'208920100001119',9,15,'DISABLED','ENABLED','LIPA-only'); +/*!40000 ALTER TABLE `pdn` ENABLE KEYS */; +UNLOCK TABLES; + +-- +-- Table structure for table `pgw` +-- + +DROP TABLE IF EXISTS `pgw`; +/*!40101 SET @saved_cs_client = @@character_set_client */; +/*!40101 SET character_set_client = utf8 */; +CREATE TABLE `pgw` ( + `id` int(11) NOT NULL AUTO_INCREMENT, + `ipv4` varchar(15) NOT NULL, + `ipv6` varchar(39) NOT NULL, + PRIMARY KEY (`id`), + UNIQUE KEY `ipv4` (`ipv4`), + UNIQUE KEY `ipv6` (`ipv6`) +) ENGINE=MyISAM AUTO_INCREMENT=4 DEFAULT CHARSET=latin1; +/*!40101 SET character_set_client = @saved_cs_client */; + +-- +-- Dumping data for table `pgw` +-- + +LOCK TABLES `pgw` WRITE; +/*!40000 ALTER TABLE `pgw` DISABLE KEYS */; +INSERT INTO `pgw` VALUES (1,'127.0.0.1','0:0:0:0:0:0:0:1'),(2,'192.168.56.101',''),(3,'10.0.0.2','0'); +/*!40000 ALTER TABLE `pgw` ENABLE KEYS */; +UNLOCK TABLES; + +-- +-- Table structure for table `terminal-info` +-- + +DROP TABLE IF EXISTS `terminal-info`; +/*!40101 SET @saved_cs_client = @@character_set_client */; +/*!40101 SET character_set_client = utf8 */; +CREATE TABLE `terminal-info` ( + `imei` varchar(15) NOT NULL, + `sv` varchar(2) NOT NULL, + UNIQUE KEY `imei` (`imei`) +) ENGINE=InnoDB DEFAULT CHARSET=latin1; +/*!40101 SET character_set_client = @saved_cs_client */; + +-- +-- Dumping data for table `terminal-info` +-- + +LOCK TABLES `terminal-info` WRITE; +/*!40000 ALTER TABLE `terminal-info` DISABLE KEYS */; +/*!40000 ALTER TABLE `terminal-info` ENABLE KEYS */; +UNLOCK TABLES; + +-- +-- Table structure for table `users` +-- + +DROP TABLE IF EXISTS `users`; +/*!40101 SET @saved_cs_client = @@character_set_client */; +/*!40101 SET character_set_client = utf8 */; +CREATE TABLE `users` ( + `imsi` varchar(15) NOT NULL COMMENT 'IMSI is the main reference key.', + `msisdn` varchar(46) DEFAULT NULL COMMENT 'The basic MSISDN of the UE (Presence of MSISDN is optional).', + `imei` varchar(15) DEFAULT NULL COMMENT 'International Mobile Equipment Identity', + `imei_sv` varchar(2) DEFAULT NULL COMMENT 'International Mobile Equipment Identity Software Version Number', + `ms_ps_status` enum('PURGED','NOT_PURGED') DEFAULT 'PURGED' COMMENT 'Indicates that ESM and EMM status are purged from MME', + `rau_tau_timer` int(10) unsigned DEFAULT '120', + `ue_ambr_ul` bigint(20) unsigned DEFAULT '50000000' COMMENT 'The Maximum Aggregated uplink MBRs to be shared across all Non-GBR bearers according to the subscription of the user.', + `ue_ambr_dl` bigint(20) unsigned DEFAULT '100000000' COMMENT 'The Maximum Aggregated downlink MBRs to be shared across all Non-GBR bearers according to the subscription of the user.', + `access_restriction` int(10) unsigned DEFAULT '60' COMMENT 'Indicates the access restriction subscription information. 3GPP TS.29272 #7.3.31', + `mme_cap` int(10) unsigned zerofill DEFAULT NULL COMMENT 'Indicates the capabilities of the MME with respect to core functionality e.g. regional access restrictions.', + `mmeidentity_idmmeidentity` int(11) NOT NULL DEFAULT '0', + `key` varbinary(16) NOT NULL DEFAULT '0' COMMENT 'UE security key', + `RFSP-Index` smallint(5) unsigned NOT NULL DEFAULT '1' COMMENT 'An index to specific RRM configuration in the E-UTRAN. Possible values from 1 to 256', + `urrp_mme` tinyint(1) NOT NULL DEFAULT '0' COMMENT 'UE Reachability Request Parameter indicating that UE activity notification from MME has been requested by the HSS.', + `sqn` bigint(20) unsigned zerofill NOT NULL, + `rand` varbinary(16) NOT NULL, + `OPc` varbinary(16) DEFAULT NULL COMMENT 'Can be computed by HSS', + PRIMARY KEY (`imsi`,`mmeidentity_idmmeidentity`), + KEY `fk_users_mmeidentity_idx1` (`mmeidentity_idmmeidentity`) +) ENGINE=MyISAM DEFAULT CHARSET=latin1; +/*!40101 SET character_set_client = @saved_cs_client */; + +-- +-- Dumping data for table `users` +-- + +LOCK TABLES `users` WRITE; +/*!40000 ALTER TABLE `users` DISABLE KEYS */; +INSERT INTO `users` VALUES ('20834123456789','380561234567','35609204079300',NULL,'PURGED',50,40000000,100000000,47,0000000000,1,'+�E��ų\0�,IH��H',0,0,00000000000000000096,'Px�X \Z1��x��','^��K�����FeU���'),('20810000001234','33611123456','35609204079299',NULL,'PURGED',120,40000000,100000000,47,0000000000,1,'��G?/����� |hb',1,0,00000281454575616225,'\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0','�4�s@���z��~�'),('31002890832150','33638060059','35611302209414',NULL,'PURGED',120,40000000,100000000,47,0000000000,1,'��G?/����� |hb',1,0,00000000000000012416,'`�F�݆��D��ϛ���','�4�s@���z��~�'),('001010123456789','33600101789','35609204079298',NULL,'PURGED',120,50000000,100000000,47,0000000000,1,'\0 \n\r',1,0,00000000000000000351,'\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0','L�*\\�����^��]� '),('208930000000001','33638030001','35609204079301',NULL,'PURGED',120,50000000,100000000,47,0000000000,1,'��G?/����� |hb',1,0,00000000000000006103,'��wq��gzW�Ð��Z]','�4�s@���z��~�'),('208950000000002','33638050002','35609204079502',NULL,'PURGED',120,50000000,100000000,47,0000000000,1,'��G?/����� |hb',1,0,00000000000000020471,'\0 \n\r','�4�s@���z��~�'),('208950000000003','33638050003','35609204079503',NULL,'PURGED',120,50000000,100000000,47,0000000000,1,'��G?/����� |hb',1,0,00000000000000012343,'\0 \n\r','�4�s@���z��~�'),('208950000000004','33638050004','35609204079504',NULL,'PURGED',120,50000000,100000000,47,0000000000,1,'��G?/����� |hb',1,0,00000000000000012215,'56f0261d9d051063','�4�s@���z��~�'),('208950000000005','33638050005','35609204079505',NULL,'PURGED',120,50000000,100000000,47,0000000000,1,'��G?/����� |hb',1,0,00000000000000012215,'56f0261d9d051063','�4�s@���z��~�'),('208950000000001','33638050001','35609204079501',NULL,'PURGED',120,50000000,100000000,47,0000000000,1,'��G?/����� |hb',1,0,00000000000000006103,'��wq��gzW�Ð��Z]','�4�s@���z��~�'),('208950000000006','33638050006','35609204079506',NULL,'PURGED',120,50000000,100000000,47,0000000000,1,'��G?/����� |hb',1,0,00000000000000012215,'56f0261d9d051063','�4�s@���z��~�'),('208950000000007','33638050007','35609204079507',NULL,'PURGED',120,50000000,100000000,47,0000000000,1,'��G?/����� |hb',1,0,00000000000000012215,'56f0261d9d051063','�4�s@���z��~�'),('208930000000002','33638030002','35609204079302',NULL,'PURGED',120,50000000,100000000,47,0000000000,1,'��G?/����� |hb',1,0,00000000000000006103,'��wq��gzW�Ð��Z]','�4�s@���z��~�'),('208930000000003','33638030003','35609204079303',NULL,'PURGED',120,50000000,100000000,47,0000000000,1,'��G?/����� |hb',1,0,00000000000000006103,'��wq��gzW�Ð��Z]','�4�s@���z��~�'),('208930000000004','33638030004','35609204079304',NULL,'PURGED',120,50000000,100000000,47,0000000000,1,'��G?/����� |hb',1,0,00000000000000006103,'��wq��gzW�Ð��Z]','�4�s@���z��~�'),('208930000000005','33638030005','35609204079305',NULL,'PURGED',120,50000000,100000000,47,0000000000,1,'��G?/����� |hb',1,0,00000000000000006103,'��wq��gzW�Ð��Z]','�4�s@���z��~�'),('208930000000006','33638030006','35609204079306',NULL,'PURGED',120,50000000,100000000,47,0000000000,1,'��G?/����� |hb',1,0,00000000000000006103,'��wq��gzW�Ð��Z]','�4�s@���z��~�'),('208930000000007','33638030007','35609204079307',NULL,'PURGED',120,50000000,100000000,47,0000000000,1,'��G?/����� |hb',1,0,00000000000000006103,'��wq��gzW�Ð��Z]','�4�s@���z��~�'),('208940000000007','33638040007','35609204079407',NULL,'PURGED',120,50000000,100000000,47,0000000000,1,'��G?/����� |hb',1,0,00000000000000006103,'��wq��gzW�Ð��Z]','�4�s@���z��~�'),('208940000000006','33638040006','35609204079406',NULL,'PURGED',120,50000000,100000000,47,0000000000,1,'��G?/����� |hb',1,0,00000000000000006103,'��wq��gzW�Ð��Z]','�4�s@���z��~�'),('208940000000005','33638040005','35609204079405',NULL,'PURGED',120,50000000,100000000,47,0000000000,1,'��G?/����� |hb',1,0,00000000000000006103,'��wq��gzW�Ð��Z]','�4�s@���z��~�'),('208940000000004','33638040004','35609204079404',NULL,'PURGED',120,50000000,100000000,47,0000000000,1,'��G?/����� |hb',1,0,00000000000000006103,'��wq��gzW�Ð��Z]','�4�s@���z��~�'),('208940000000003','33638040003','35609204079403',NULL,'PURGED',120,50000000,100000000,47,0000000000,1,'��G?/����� |hb',1,0,00000000000000006103,'��wq��gzW�Ð��Z]','�4�s@���z��~�'),('208940000000002','33638040002','35609204079402',NULL,'PURGED',120,50000000,100000000,47,0000000000,1,'��G?/����� |hb',1,0,00000000000000006103,'��wq��gzW�Ð��Z]','�4�s@���z��~�'),('208940000000001','33638040001','35609204079401',NULL,'PURGED',120,50000000,100000000,47,0000000000,1,'��G?/����� |hb',1,0,00000000000000006103,'��wq��gzW�Ð��Z]','�4�s@���z��~�'),('208920100001100','33638020001','35609204079201',NULL,'PURGED',120,50000000,100000000,47,0000000000,1,'��G?/����� |hb',1,0,00000000000000006103,'ebd07771ace8677a','�4�s@���z��~�'),('208920100001101','33638020001','35609204079201',NULL,'NOT_PURGED',120,50000000,100000000,47,0000000000,1,'��k��p~Љu{�K�',1,0,00000281044204937234,'\0 \n\r','�$I6;��+f�k�u�|�'),('208920100001102','33638020002','35609204079202',NULL,'PURGED',120,50000000,100000000,47,0000000000,1,'��G?/����� |hb',1,0,00000000000000006103,'ebd07771ace8677a','�4�s@���z��~�'),('208920100001103','33638020003','35609204079203',NULL,'PURGED',120,50000000,100000000,47,0000000000,1,'��G?/����� |hb',1,0,00000000000000006103,'ebd07771ace8677a','�4�s@���z��~�'),('208920100001104','33638020004','35609204079204',NULL,'PURGED',120,50000000,100000000,47,0000000000,1,'��G?/����� |hb',1,0,00000000000000006103,'ebd07771ace8677a','�4�s@���z��~�'),('208920100001105','33638020005','35609204079205',NULL,'PURGED',120,50000000,100000000,47,0000000000,1,'��G?/����� |hb',1,0,00000000000000006103,'ebd07771ace8677a','�4�s@���z��~�'),('208920100001106','33638020006','35609204079206',NULL,'PURGED',120,50000000,100000000,47,0000000000,1,'��k��p~Љu{�K�',1,0,00000000000000006103,'ebd07771ace8677a','�$I6;��+f�k�u�|�'),('208920100001107','33638020007','35609204079207',NULL,'PURGED',120,50000000,100000000,47,0000000000,1,'��G?/����� |hb',1,0,00000000000000006103,'ebd07771ace8677a','�4�s@���z��~�'),('208920100001108','33638020008','35609204079208',NULL,'PURGED',120,50000000,100000000,47,0000000000,1,'��G?/����� |hb',1,0,00000000000000006103,'ebd07771ace8677a','�4�s@���z��~�'),('208920100001109','33638020009','35609204079209',NULL,'PURGED',120,50000000,100000000,47,0000000000,1,'��G?/����� |hb',1,0,00000000000000006103,'ebd07771ace8677a','�4�s@���z��~�'),('208920100001110','33638020010','35609204079210',NULL,'PURGED',120,50000000,100000000,47,0000000000,1,'��G?/����� |hb',1,0,00000000000000006103,'ebd07771ace8677a','�4�s@���z��~�'),('208930100001111','33638030011','35609304079211',NULL,'PURGED',120,50000000,100000000,47,0000000000,1,'��G?/����� |hb',1,0,00000000000000006103,'ebd07771ace8677a','�4�s@���z��~�'),('208930100001112','33638030012','35609304079212',NULL,'PURGED',120,50000000,100000000,47,0000000000,1,'��G?/����� |hb',1,0,00000000000000006103,'ebd07771ace8677a','�4�s@���z��~�'),('208930100001113','33638030013','35609304079213',NULL,'PURGED',120,50000000,100000000,47,0000000000,1,'��G?/����� |hb',1,0,00000000000000006263,'�SNܒ�Iv��e�6','�4�s@���z��~�'),('208950000000008','33638050008','35609204079508',NULL,'PURGED',120,50000000,100000000,47,0000000000,1,'��G?/����� |hb',1,0,00000000000000012215,'56f0261d9d051063','�4�s@���z��~�'),('208950000000009','33638050009','35609204079509',NULL,'PURGED',120,50000000,100000000,47,0000000000,1,'��G?/����� |hb',1,0,00000000000000012215,'56f0261d9d051063','�4�s@���z��~�'),('208950000000010','33638050010','35609204079510',NULL,'PURGED',120,50000000,100000000,47,0000000000,1,'��G?/����� |hb',1,0,00000000000000012215,'56f0261d9d051063','�4�s@���z��~�'),('208950000000011','33638050011','35609204079511',NULL,'PURGED',120,50000000,100000000,47,0000000000,1,'��G?/����� |hb',1,0,00000000000000012215,'56f0261d9d051063','�4�s@���z��~�'),('208950000000012','33638050012','35609204079512',NULL,'PURGED',120,50000000,100000000,47,0000000000,1,'��G?/����� |hb',1,0,00000000000000012215,'56f0261d9d051063','�4�s@���z��~�'),('208950000000013','33638050013','35609204079513',NULL,'PURGED',120,50000000,100000000,47,0000000000,1,'��G?/����� |hb',1,0,00000000000000012215,'56f0261d9d051063','�4�s@���z��~�'),('208950000000014','33638050014','35609204079514',NULL,'PURGED',120,50000000,100000000,47,0000000000,1,'��G?/����� |hb',1,0,00000000000000012215,'56f0261d9d051063','�4�s@���z��~�'),('208950000000015','33638050015','35609204079515',NULL,'PURGED',120,50000000,100000000,47,0000000000,1,'��G?/����� |hb',1,0,00000000000000000000,'3536663032363164','�4�s@���z��~�'),('208920100001118','33638020010','35609204079210',NULL,'NOT_PURGED',120,50000000,100000000,47,0000000000,1,'��k��p~Љu{�K�',1,0,00000281044204934762,'~?03�u-%�ey�y�','�$I6;��+f�k�u�|�'),('208920100001121','33638020010','35609204079210',NULL,'NOT_PURGED',120,50000000,100000000,47,0000000000,1,'��k��p~Љu{�K�',1,0,00000281044204935293,'&��@xg�]���\n��Vp','�$I6;��+f�k�u�|�'),('208920100001119','33638020010','35609204079210',NULL,'NOT_PURGED',120,50000000,100000000,47,0000000000,1,'��k��p~Љu{�K�',1,0,00000281044204935293,'269482407867805d','�$I6;��+f�k�u�|�'),('208920100001120','33638020010','35609204079210',NULL,'NOT_PURGED',120,50000000,100000000,47,0000000000,1,'��k��p~Љu{�K�',1,0,00000281044204935293,'3236393438323430','�$I6;��+f�k�u�|�'); +INSERT INTO `users` VALUES ('208990100001100','1','55000000000000',NULL,'PURGED',50,40000000,100000000,47,0000000000,1,0xfec86ba6eb707ed08905757b1bb44b8f,0,0,0x40,'ebd07771ace8677a',0xc42449363bbad02b66d16bc975d77cc1); +INSERT INTO `users` VALUES ('208950000000031','380561234567','55000000000001',NULL,'PURGED',50,40000000,100000000,47,0000000000,1,0x0C0A34601D4F07677303652C0462535B,0,0,0x40,'ebd07771ace8677a',0x63bfa50ee6523365ff14c1f45f88737d); +INSERT INTO `users` VALUES ('208950000000032','380561234567','55000000000001',NULL,'PURGED',50,40000000,100000000,47,0000000000,1,0x0C0A34601D4F07677303652C0462535B,0,0,0x40,'ebd07771ace8677a',0x63bfa50ee6523365ff14c1f45f88737d); +INSERT INTO `users` VALUES ('208950000000033','380561234567','55000000000001',NULL,'PURGED',50,40000000,100000000,47,0000000000,1,0x0C0A34601D4F07677303652C0462535B,0,0,0x40,'ebd07771ace8677a',0x63bfa50ee6523365ff14c1f45f88737d); +INSERT INTO `users` VALUES ('208950000000034','380561234567','55000000000001',NULL,'PURGED',50,40000000,100000000,47,0000000000,1,0x0C0A34601D4F07677303652C0462535B,0,0,0x40,'ebd07771ace8677a',0x63bfa50ee6523365ff14c1f45f88737d); +INSERT INTO `users` VALUES ('208950000000035','380561234567','55000000000001',NULL,'PURGED',50,40000000,100000000,47,0000000000,1,0x0C0A34601D4F07677303652C0462535B,0,0,0x40,'ebd07771ace8677a',0x63bfa50ee6523365ff14c1f45f88737d); +INSERT INTO `users` VALUES ('208950000000036','380561234567','55000000000001',NULL,'PURGED',50,40000000,100000000,47,0000000000,1,0x0C0A34601D4F07677303652C0462535B,0,0,0x40,'ebd07771ace8677a',0x63bfa50ee6523365ff14c1f45f88737d); +INSERT INTO `users` VALUES ('208950000000037','380561234567','55000000000001',NULL,'PURGED',50,40000000,100000000,47,0000000000,1,0x0C0A34601D4F07677303652C0462535B,0,0,0x40,'ebd07771ace8677a',0x63bfa50ee6523365ff14c1f45f88737d); +INSERT INTO `users` VALUES ('208950000000038','380561234567','55000000000001',NULL,'PURGED',50,40000000,100000000,47,0000000000,1,0x0C0A34601D4F07677303652C0462535B,0,0,0x40,'ebd07771ace8677a',0x63bfa50ee6523365ff14c1f45f88737d); +INSERT INTO `users` VALUES ('208950000000039','380561234567','55000000000001',NULL,'PURGED',50,40000000,100000000,47,0000000000,1,0x0C0A34601D4F07677303652C0462535B,0,0,0x40,'ebd07771ace8677a',0x63bfa50ee6523365ff14c1f45f88737d); +INSERT INTO `users` VALUES ('208950000000040','380561234567','55000000000001',NULL,'PURGED',50,40000000,100000000,47,0000000000,1,0x0C0A34601D4F07677303652C0462535B,0,0,0x40,'ebd07771ace8677a',0x63bfa50ee6523365ff14c1f45f88737d); +/*!40000 ALTER TABLE `users` ENABLE KEYS */; +UNLOCK TABLES; +/*!40103 SET TIME_ZONE=@OLD_TIME_ZONE */; + +/*!40101 SET SQL_MODE=@OLD_SQL_MODE */; +/*!40014 SET FOREIGN_KEY_CHECKS=@OLD_FOREIGN_KEY_CHECKS */; +/*!40014 SET UNIQUE_CHECKS=@OLD_UNIQUE_CHECKS */; +/*!40101 SET CHARACTER_SET_CLIENT=@OLD_CHARACTER_SET_CLIENT */; +/*!40101 SET CHARACTER_SET_RESULTS=@OLD_CHARACTER_SET_RESULTS */; +/*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */; +/*!40111 SET SQL_NOTES=@OLD_SQL_NOTES */; + +-- Dump completed on 2016-06-28 11:41:40 diff --git a/ci-scripts/yaml_files/5g_f1_rfsimulator/smf-healthcheck.sh b/ci-scripts/yaml_files/5g_f1_rfsimulator/smf-healthcheck.sh new file mode 100755 index 0000000000000000000000000000000000000000..d9ff7608e80d8ec5e840e94bcf074d27759c702d --- /dev/null +++ b/ci-scripts/yaml_files/5g_f1_rfsimulator/smf-healthcheck.sh @@ -0,0 +1,21 @@ +#!/bin/bash +set -eo pipefail + +STATUS=0 +SMF_IP_SBI_INTERFACE=$(ifconfig $SMF_INTERFACE_NAME_FOR_SBI | grep inet | awk {'print $2'}) +SMF_SBI_PORT_STATUS=$(netstat -tnpl | grep -o "$SMF_IP_SBI_INTERFACE:$SMF_INTERFACE_PORT_FOR_SBI") + +#Check if entrypoint properly configured the conf file and no parameter is unset(optional) +#NB_UNREPLACED_AT=`cat /openair-smf/etc/*.conf | grep -v contact@openairinterface.org | grep -c @ || true` + +#if [ $NB_UNREPLACED_AT -ne 0 ]; then +# STATUS=-1 +# echo "Healthcheck error: UNHEALTHY configuration file is not configured properly" +#fi +# +if [[ -z $SMF_SBI_PORT_STATUS ]]; then + STATUS=-1 + echo "Healthcheck error: UNHEALTHY SBI TCP/HTTP port $SMF_INTERFACE_PORT_FOR_SBI is not listening." +fi + +exit $STATUS diff --git a/ci-scripts/yaml_files/5g_f1_rfsimulator/spgwu-healthcheck.sh b/ci-scripts/yaml_files/5g_f1_rfsimulator/spgwu-healthcheck.sh new file mode 100755 index 0000000000000000000000000000000000000000..0e3b67ee7e5653a19552ceae70abd36b04a223a7 --- /dev/null +++ b/ci-scripts/yaml_files/5g_f1_rfsimulator/spgwu-healthcheck.sh @@ -0,0 +1,28 @@ +#!/bin/bash +set -eo pipefail + +STATUS=0 +SGW_PORT_FOR_S1U_S12_S4_UP=2152 +SGW_PORT_FOR_SX=8805 +SGW_IP_S1U_INTERFACE=$(ifconfig $SGW_INTERFACE_NAME_FOR_S1U_S12_S4_UP | grep inet | awk {'print $2'}) +SGW_IP_SX_INTERFACE=$(ifconfig $SGW_INTERFACE_NAME_FOR_SX | grep inet | awk {'print $2'}) +S1U_S12_S4_UP_PORT_STATUS=$(netstat -unpl | grep -o "$SGW_IP_S1U_INTERFACE:$SGW_PORT_FOR_S1U_S12_S4_UP") +SX_PORT_STATUS=$(netstat -unpl | grep -o "$SGW_IP_SX_INTERFACE:$SGW_PORT_FOR_SX") +#Check if entrypoint properly configured the conf file and no parameter is unset (optional) +NB_UNREPLACED_AT=`cat /openair-spgwu/etc/*.conf | grep -v contact@openairinterface.org | grep -c @ || true` +if [ $NB_UNREPLACED_AT -ne 0 ]; then + STATUS=1 + echo "Healthcheck error: UNHEALTHY configuration file is not configured properly" +fi + +if [[ -z $S1U_S12_S4_UP_PORT_STATUS ]]; then + STATUS=1 + echo "Healthcheck error: UNHEALTHY S1U port $SGW_PORT_FOR_S1U_S12_S4_UP is not listening." +fi + +if [[ -z $SX_PORT_STATUS ]]; then + STATUS=1 + echo "Healthcheck error: UNHEALTHY SX port $SGW_PORT_FOR_SX is not listening." +fi + +exit $STATUS \ No newline at end of file diff --git a/ci-scripts/yaml_files/5g_rfsimulator/README.md b/ci-scripts/yaml_files/5g_rfsimulator/README.md index 915b71296fa1ecada3beecdfd634f320667d7337..fc562dd1eb97521aef7471435d04c1daef2ccc70 100644 --- a/ci-scripts/yaml_files/5g_rfsimulator/README.md +++ b/ci-scripts/yaml_files/5g_rfsimulator/README.md @@ -14,7 +14,7 @@ This page is only valid for an `Ubuntu18` host. -**NOTE: this version (2021-10-05) is valid for the `v1.1.0` and `v1.2.0` versions of the `OAI 5G CN`.** +**NOTE: this version (2022-01-27) has been updated for the `v1.3.0` version of the `OAI 5G CN`.** **TABLE OF CONTENTS** @@ -76,9 +76,9 @@ $ docker image tag rdefosseoai/oai-nr-ue:develop oai-nr-ue:develop $ docker logout ``` -**CAUTION: 2021/10/05 with the release `v1.2.0` of the `CN5G`, the previous version was not compatible any-more.** +**CAUTION: 2022/01/27 with the release `v1.3.0` of the `CN5G`, the previous version was not compatible any-more.** -**This new version is working for both the `v1.1.0` and `v1.2.0` of the `CN5G`.** +**This new version is working only with the `v1.3.0` of the `CN5G`.** # 2. Deploy containers # @@ -88,7 +88,9 @@ $ docker logout **Just `docker-compose up -d` WILL NOT WORK!** -All the following commands **SHALL** be run from the `ci-scripts/yaml_files/5g_rfsimulator` folder. +All the following commands **SHALL** be run from the `ci-scripts/yaml_files/5g_rfsimulator` folder for a deployment with monolithic gNB. + +For a deployment with the gNB split in CU and DU components, the following commands **SHALL** be run from the `ci-scripts/yaml_files/5g_f1_rfsimulator` folder. ## 2.1. Deploy OAI 5G Core Network ## @@ -148,6 +150,9 @@ rfsim5g-traffic: flags=4163<UP,BROADCAST,RUNNING,MULTICAST> mtu 1500 **CAUTION: To execute this 2nd step, the whole `CN5G` SHALL be in `healthy` state (especially the `mysql` container).** +The gNB can be deployed either in monolithic mode, or in CU/DU split mode. +- For a deployment with a monolithic gNB: + ```bash $ docker-compose up -d oai-gnb rfsim5g-oai-nrf is up-to-date @@ -155,7 +160,16 @@ rfsim5g-oai-spgwu is up-to-date rfsim5g-oai-ext-dn is up-to-date Creating rfsim5g-oai-gnb ... done ``` +- For a deployment with the gNB split in CU and DU components: +```bash +#Deployment of the CU +$ docker-compose up -d oai-cu +``` +```bash +#Deployment of the DU +$ docker-compose up -d oai-du +``` Wait for a bit. ```bash diff --git a/ci-scripts/yaml_files/5g_rfsimulator/docker-compose.yaml b/ci-scripts/yaml_files/5g_rfsimulator/docker-compose.yaml index 31d64f35dc8dc06e866ff88c7aa308c7dd41972a..f0476b0a1efd0ed1932c16ca927e7c9dac926bc0 100644 --- a/ci-scripts/yaml_files/5g_rfsimulator/docker-compose.yaml +++ b/ci-scripts/yaml_files/5g_rfsimulator/docker-compose.yaml @@ -111,7 +111,6 @@ services: oai-smf: container_name: "rfsim5g-oai-smf" image: oai-smf:latest - entrypoint: /bin/bash -c "/openair-smf/bin/oai_smf -c /openair-smf/bin/oai-smf.conf -o" environment: - TZ=Europe/Paris - INSTANCE=0 @@ -140,12 +139,13 @@ services: - REGISTER_NRF=yes - DISCOVER_UPF=yes - USE_FQDN_DNS=yes + - DNN_NI0=oai + - DNN_NI2=oai.ipv4 depends_on: - oai-nrf - oai-amf volumes: - ./smf-healthcheck.sh:/openair-smf/bin/smf-healthcheck.sh - - ./oai-smf.conf:/openair-smf/bin/oai-smf.conf healthcheck: test: /bin/bash -c "/openair-smf/bin/smf-healthcheck.sh" interval: 10s @@ -244,7 +244,7 @@ services: GNB_NGA_IP_ADDRESS: 192.168.71.136 GNB_NGU_IF_NAME: eth0 GNB_NGU_IP_ADDRESS: 192.168.71.136 - USE_ADDITIONAL_OPTIONS: --sa -E --rfsim + USE_ADDITIONAL_OPTIONS: --sa -E --rfsim --log_config.global_log_options level,nocolor,time depends_on: - oai-ext-dn networks: @@ -267,7 +267,7 @@ services: DNN: oai NSSAI_SST: 1 NSSAI_SD: 1 - USE_ADDITIONAL_OPTIONS: -E --sa --rfsim -r 106 --numerology 1 -C 3619200000 --nokrnmod + 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 networks: diff --git a/ci-scripts/yaml_files/5g_rfsimulator/oai-smf.conf b/ci-scripts/yaml_files/5g_rfsimulator/oai-smf.conf deleted file mode 100644 index 0c83ab8be937cee03a6b1dc0931473e162c952df..0000000000000000000000000000000000000000 --- a/ci-scripts/yaml_files/5g_rfsimulator/oai-smf.conf +++ /dev/null @@ -1,133 +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 -################################################################################ - -SMF = -{ - FQDN = "oai-smf-svc"; - INSTANCE = 0; # 0 is the default - PID_DIRECTORY = "/var/run"; # /var/run is the default - - INTERFACES : - { - N4 : - { - # SMF binded interface for N4 communication (UPF) - INTERFACE_NAME = "eth0"; # YOUR NETWORK CONFIG HERE - IPV4_ADDRESS = "read"; - }; - - SBI : - { - # SMF binded interface for SBI interface (e.g., communication with AMF, UDM) - INTERFACE_NAME = "eth0"; # YOUR NETWORK CONFIG HERE - IPV4_ADDRESS = "read"; - PORT = 80; # YOUR NETWORK CONFIG HERE (default: 80) - HTTP2_PORT = 9090; # YOUR NETWORK CONFIG HERE - API_VERSION = "v1"; # YOUR SMF API VERSION CONFIG HERE - }; - - }; - - - # Pool of UE assigned IP addresses - # Do not make IP pools overlap - # first IPv4 address X.Y.Z.1 is reserved for GTP network device on UPF - IP_ADDRESS_POOL : - { - IPV4_LIST = ( - {RANGE = "12.1.1.2 - 12.1.1.128";}, # STRING, IPv4 RANGE IP_start - IP_end, YOUR NETWORK CONFIG HERE. - {RANGE = "12.1.1.129 - 12.1.1.224";}, # STRING, IPv4 RANGE IP_start - IP_end, YOUR NETWORK CONFIG HERE. - {RANGE = "10.10.10.2 - 10.10.10.253";} # STRING, IPv4 RANGE IP_start - IP_end, YOUR NETWORK CONFIG HERE. - - ); - IPV6_LIST = ( - {PREFIX = "2001:1:2::/64";}, # STRING, IPv6 prefix, YOUR NETWORK CONFIG HERE. - {PREFIX = "3001:1:2::/64";}, # STRING, IPv6 prefix, YOUR NETWORK CONFIG HERE. - {PREFIX = "4001:1:2::/64";} # STRING, IPv6 prefix, YOUR NETWORK CONFIG HERE. - ); - }; - - DNN_LIST = ( - # IPV4_POOL, IPV6_POOL are index in IPV4_LIST, IPV6_LIST, PDU_SESSION_TYPE choice in {IPv4, IPv6, IPv4v6} - {DNN_NI = "default"; PDU_SESSION_TYPE = "IPv4"; IPV4_POOL = 2; IPV6_POOL = -1}, - {DNN_NI = "carrier.com"; PDU_SESSION_TYPE = "IPv4"; IPV4_POOL = 1; IPV6_POOL = -1}, - {DNN_NI = "oai"; PDU_SESSION_TYPE = "IPv4"; IPV4_POOL = 0; IPV6_POOL = -1} - ); - - # DNS address communicated to UEs - DEFAULT_DNS_IPV4_ADDRESS = "192.168.18.129"; # YOUR DNS CONFIG HERE - DEFAULT_DNS_SEC_IPV4_ADDRESS = "192.168.18.129"; # YOUR DNS CONFIG HERE - DEFAULT_DNS_IPV6_ADDRESS = "2001:4860:4860::8888"; # YOUR DNS CONFIG HERE - DEFAULT_DNS_SEC_IPV6_ADDRESS = "2001:4860:4860::8844"; # YOUR DNS CONFIG HERE - - SUPPORT_FEATURES: - { - # STRING, {"yes", "no"}, - REGISTER_NRF = "yes"; # Set to yes if SMF resgisters to an NRF - DISCOVER_UPF = "yes"; # Set to yes to enable UPF discovery and selection - FORCE_PUSH_PROTOCOL_CONFIGURATION_OPTIONS = "no"; # Non standard feature, normally should be set to "no", - # but you may need to set to yes for UE that do not explicitly request a PDN address through NAS signalling - USE_LOCAL_SUBSCRIPTION_INFO = "yes"; # Set to yes if SMF uses local subscription information instead of from an UDM - USE_FQDN_DNS = "yes"; # Set to yes if AMF/UDM/NRF/UPF will relying on a DNS to resolve FQDN - } - - AMF : - { - IPV4_ADDRESS = "0.0.0.0"; # YOUR AMF CONFIG HERE - PORT = 80; # YOUR AMF CONFIG HERE (default: 80) - API_VERSION = "v1"; # YOUR AMF API VERSION FOR SBI CONFIG HERE - FQDN = "oai-amf" # YOUR AMF FQDN CONFIG HERE - }; - - UDM : - { - IPV4_ADDRESS = "127.0.0.1"; # YOUR UDM CONFIG HERE - PORT = 80; # YOUR UDM CONFIG HERE (default: 80) - API_VERSION = "v1"; # YOUR UDM API VERSION FOR SBI CONFIG HERE - FQDN = "localhost" # YOUR UDM FQDN CONFIG HERE - }; - - NRF : - { - IPV4_ADDRESS = "192.168.71.130"; # YOUR NRF CONFIG HERE - PORT = 80; # YOUR NRF CONFIG HERE (default: 80) - API_VERSION = "v1"; # YOUR NRF API VERSION FOR SBI CONFIG HERE - FQDN = "oai-nrf" # YOUR NRF FQDN CONFIG HERE - }; - - UPF_LIST = ( - {IPV4_ADDRESS = "192.168.71.134" ; FQDN = "oai-spgwu"} # YOUR UPF CONFIG HERE - ); - - LOCAL_CONFIGURATION : - { - SESSION_MANAGEMENT_SUBSCRIPTION_LIST = ( - { NSSAI_SST = 222, NSSAI_SD = "123", DNN = "default", DEFAULT_SESSION_TYPE = "IPV4", DEFAULT_SSC_MODE = 1, - QOS_PROFILE_5QI = 7, QOS_PROFILE_PRIORITY_LEVEL = 1, QOS_PROFILE_ARP_PRIORITY_LEVEL = 1, QOS_PROFILE_ARP_PREEMPTCAP = "NOT_PREEMPT", - QOS_PROFILE_ARP_PREEMPTVULN = "NOT_PREEMPTABLE", SESSION_AMBR_UL = "20Mbps", SESSION_AMBR_DL = "22Mbps"}, - { NSSAI_SST = 1; NSSAI_SD = "1", DNN = "oai", DEFAULT_SESSION_TYPE = "IPV4", DEFAULT_SSC_MODE = 1, - QOS_PROFILE_5QI = 6, QOS_PROFILE_PRIORITY_LEVEL = 1, QOS_PROFILE_ARP_PRIORITY_LEVEL = 1, QOS_PROFILE_ARP_PREEMPTCAP = "NOT_PREEMPT", - QOS_PROFILE_ARP_PREEMPTVULN = "NOT_PREEMPTABLE", SESSION_AMBR_UL = "20Mbps", SESSION_AMBR_DL = "22Mbps"} - ); - }; - -}; - diff --git a/ci-scripts/yaml_files/fr1_enb_mono_fdd_tim/docker-compose.yml b/ci-scripts/yaml_files/fr1_enb_mono_fdd_tim/docker-compose.yml index 2df277d78baa8c43a6cdb15cbda2735e7d2eb9e5..b7dd3d0296194a4ccf8837db1979656b6d0d19ce 100644 --- a/ci-scripts/yaml_files/fr1_enb_mono_fdd_tim/docker-compose.yml +++ b/ci-scripts/yaml_files/fr1_enb_mono_fdd_tim/docker-compose.yml @@ -27,7 +27,7 @@ services: FLEXRAN_ENABLED: 'no' FLEXRAN_INTERFACE_NAME: eth0 FLEXRAN_IPV4_ADDRESS: CI_FLEXRAN_CTL_IP_ADDR - USE_ADDITIONAL_OPTIONS: '--RUs.[0].max_rxgain 115 --RUs.[0].max_pdschReferenceSignalPower -27 --eNBs.[0].component_carriers.[0].pucch_p0_Nominal -96' + USE_ADDITIONAL_OPTIONS: --RUs.[0].max_rxgain 115 --RUs.[0].max_pdschReferenceSignalPower -27 --eNBs.[0].component_carriers.[0].pucch_p0_Nominal -96 --log_config.global_log_options level,nocolor,time volumes: - /dev:/dev networks: diff --git a/ci-scripts/yaml_files/nsa_b200_enb/docker-compose.yml b/ci-scripts/yaml_files/nsa_b200_enb/docker-compose.yml index 9bd08aeabca231990a90be98401ed3b619435da1..92ccdf8a0ac3fe0e2251ad62e23177f2e060c533 100644 --- a/ci-scripts/yaml_files/nsa_b200_enb/docker-compose.yml +++ b/ci-scripts/yaml_files/nsa_b200_enb/docker-compose.yml @@ -31,6 +31,7 @@ services: FLEXRAN_INTERFACE_NAME: eth0 FLEXRAN_IPV4_ADDRESS: 192.168.18.210 THREAD_PARALLEL_CONFIG: PARALLEL_SINGLE_THREAD + USE_ADDITIONAL_OPTIONS: --log_config.global_log_options level,nocolor,time,line_num,function volumes: - /dev:/dev networks: diff --git a/ci-scripts/yaml_files/nsa_b200_gnb/docker-compose.yml b/ci-scripts/yaml_files/nsa_b200_gnb/docker-compose.yml index 4ae51158ac2a0783c7627b6769f16788e6169f1e..c6096956a87ec2105ea7b341ae130fef0233d686 100644 --- a/ci-scripts/yaml_files/nsa_b200_gnb/docker-compose.yml +++ b/ci-scripts/yaml_files/nsa_b200_gnb/docker-compose.yml @@ -26,7 +26,7 @@ services: FLEXRAN_INTERFACE_NAME: eth0 FLEXRAN_IPV4_ADDRESS: 192.168.18.210 THREAD_PARALLEL_CONFIG: PARALLEL_RU_L1_TRX_SPLIT - USE_ADDITIONAL_OPTIONS: -E -q --RUs.[0].sdr_addrs serial=30C51D4 + USE_ADDITIONAL_OPTIONS: -E -q --RUs.[0].sdr_addrs serial=30C51D4 --log_config.global_log_options level,nocolor,time,line_num,function volumes: - /dev:/dev networks: diff --git a/cmake_targets/.gitignore b/cmake_targets/.gitignore new file mode 100644 index 0000000000000000000000000000000000000000..6d6cdd29a6a82c09fa1a646f36852a5a2af35dcf --- /dev/null +++ b/cmake_targets/.gitignore @@ -0,0 +1,3 @@ +.usim.* +.ue_emm.nvram* +.ue.nvram* diff --git a/cmake_targets/CMakeLists.txt b/cmake_targets/CMakeLists.txt index e48241fcddc098857b63da16898645e1764c90cd..b7b365741cb90c9c9a3ec1f196c42ed9bd1ccbf9 100644 --- a/cmake_targets/CMakeLists.txt +++ b/cmake_targets/CMakeLists.txt @@ -69,8 +69,6 @@ elseif (${RF_BOARD} STREQUAL "OAI_AW2SORI") endif (${RF_BOARD} STREQUAL "OAI_USRP") -message("RU=${RU}") - pkg_search_module(OPENPGM openpgm-5.1 openpgm-5.2) if(NOT ${OPENPGM_FOUND}) message("PACKAGE openpgm-5.1 is required by binaries such as oaisim: will fail later if this target is built") @@ -270,6 +268,22 @@ function(make_version VERSION_VALUE) endforeach() set(${VERSION_VALUE} "${RESULT}" PARENT_SCOPE) endfunction() + +macro(compile_asn1 asn1Source asn1cCmd ResultFlag) + # Warning: if you modify ASN.1 source file to generate new C files, cmake should be re-run instead of make + execute_process(COMMAND ${asn1cCmd} ${asn1Source} RESULT_VARIABLE ret) + + if (NOT ${ret} STREQUAL 0) + message(FATAL_ERROR "${ret}: error") + endif (NOT ${ret} STREQUAL 0) + + add_custom_target ( + ${ResultFlag} ALL + ${asn1cCmd} ${asn1Source} + DEPENDS ${asn1Source} + ) +endmacro(compile_asn1) + #################################################### # compilation flags ############################################# @@ -294,7 +308,7 @@ else (CMAKE_SYSTEM_PROCESSOR STREQUAL "armv7l") set(COMPILATION_AVX2 "False") endif() if (CPUINFO MATCHES "sse4_1") - set(C_FLAGS_PROCESSOR "${C_FLAGS_PROCESSOR} -msse4.1") + set(C_FLAGS_PROCESSOR "${C_FLAGS_PROCESSOR} -msse4.1 -mpclmul") endif() if (CPUINFO MATCHES "ssse3") set(C_FLAGS_PROCESSOR "${C_FLAGS_PROCESSOR} -mssse3") @@ -322,15 +336,15 @@ add_definitions("-DSTDC_HEADERS=1 -DHAVE_SYS_TYPES_H=1 -DHAVE_SYS_STAT_H=1 -DHAV set(commonOpts "-pipe -Wno-packed-bitfield-compat -fPIC -Wall -fno-strict-aliasing -rdynamic") set(CMAKE_C_FLAGS - "${CMAKE_C_FLAGS} ${C_FLAGS_PROCESSOR} ${commonOpts} -std=gnu99 -funroll-loops -mpclmul") + "${CMAKE_C_FLAGS} ${C_FLAGS_PROCESSOR} ${commonOpts} -std=gnu99 -funroll-loops") set(CMAKE_CXX_FLAGS - "${CMAKE_CXX_FLAGS} ${C_FLAGS_PROCESSOR} ${commonOpts} -std=c++11 -mpclmul") + "${CMAKE_CXX_FLAGS} ${C_FLAGS_PROCESSOR} ${commonOpts} -std=c++11") if (SANITIZE_ADDRESS) - set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fsanitize=address -fno-common") - set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fsanitize=address -fno-common") + set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fsanitize=address -fno-omit-frame-pointer -static-libasan -fno-common") + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fsanitize=address -fno-omit-frame-pointer -static-libasan -fno-common") endif () add_definitions("-DASN_DISABLE_OER_SUPPORT") @@ -345,6 +359,10 @@ set(CMAKE_C_FLAGS_DEBUG "${debugOpt} -O0") set(CMAKE_C_FLAGS_RELWITHDEBINFO "${debugOpt} -O2") set(CMAKE_C_FLAGS_RELEASE "-O3") +# Enable assert() for RelWithDebInfo builds +string(REPLACE "-DNDEBUG" "" CMAKE_C_FLAGS_RELWITHDEBINFO "${CMAKE_C_FLAGS_RELWITHDEBINFO}") +string(REPLACE "-DNDEBUG" "" CMAKE_CXX_FLAGS_RELWITHDEBINFO "${CMAKE_CXX_FLAGS_RELWITHDEBINFO}") + set(GIT_BRANCH "UNKNOWN") set(GIT_COMMIT_HASH "UNKNOWN") set(GIT_COMMIT_DATE "UNKNOWN") @@ -382,14 +400,13 @@ set (FIRMWARE_VERSION "No svn information") add_definitions("-DFIRMWARE_VERSION=\"${FIRMWARE_VERSION}\"") add_definitions("-DPACKAGE_VERSION=\"Branch: ${GIT_BRANCH} Abrev. Hash: ${GIT_COMMIT_HASH} Date: ${GIT_COMMIT_DATE}\"") add_definitions("-DPACKAGE_BUGREPORT=\"openair4g-devel@lists.eurecom.fr\"") -#add_definitions("-DEMIT_ASN_DEBUG=1") # Debug related options ######################################### -add_boolean_option(ASN_DEBUG False "ASN1 coder/decoder Debug") -add_boolean_option(EMIT_ASN_DEBUG False "ASN1 coder/decoder Debug") -add_boolean_option(MSG_PRINT False "print debug messages") +add_boolean_option(ASN_EMIT_DEBUG False "ASN1 coder/decoder Debug") +add_boolean_option(ASN_THREAD_SAFE True "ASN1 coder/decoder Debug") +add_boolean_option(MSG_PRINT True "print debug messages") add_boolean_option(DISABLE_XER_PRINT False "print XER Format") add_boolean_option(XER_PRINT False "print XER Format") add_boolean_option(RRC_MSG_PRINT False "print RRC messages") @@ -434,23 +451,11 @@ set (RRC_GRAMMAR ${OPENAIR2_DIR}/RRC/LTE/MESSAGES/asn1c/ASN1_files/lte-rrc-15.6. add_definitions(-DLTE_RRC_VERSION=${LTE_RRC_VERSION}) set (RRC_FULL_DIR ${asn1_generated_dir}/RRC_${RRC_ASN1_VERSION}) -# Warning: if you modify ASN.1 source file to generate new C files, cmake should be re-run instead of make -if (${RU} STREQUAL 0) - execute_process(COMMAND ${OPENAIR_CMAKE}/tools/make_asn1c_includes.sh "LTE_" " " "${RRC_FULL_DIR}" "${RRC_GRAMMAR}" - RESULT_VARIABLE ret) -endif (${RU} STREQUAL 0) - -if (NOT ${ret} STREQUAL 0) - message(FATAL_ERROR "${ret}: error") -endif (NOT ${ret} STREQUAL 0) -file(GLOB rrc_source ${RRC_FULL_DIR}/*.c) -add_custom_target ( - rrc_flag ALL - ${OPENAIR_CMAKE}/tools/make_asn1c_includes.sh "LTE_" " " "${RRC_FULL_DIR}" "${RRC_GRAMMAR}" - DEPENDS ${RRC_GRAMMAR} - ) +set(rrc_cmd ${OPENAIR_CMAKE}/tools/make_asn1c_includes.sh "LTE_" " " "${RRC_FULL_DIR}") -set_source_files_properties(${rrc_source} PROPERTIES COMPILE_FLAGS -w) # suppress warnings from generated code +compile_asn1("${RRC_GRAMMAR}" "${rrc_cmd}" rrc_flag) + +file(GLOB rrc_source ${RRC_FULL_DIR}/*.c) add_library(RRC_LIB ${rrc_source} ${OPENAIR2_DIR}/RRC/LTE/MESSAGES/asn1_msg.c ${OPENAIR2_DIR}/RRC/LTE/MESSAGES/asn1_msg_NB_IoT.c) @@ -467,21 +472,12 @@ add_definitions(-DNR_RRC_VERSION=${NR_RRC_VERSION}) set (NR_RRC_FULL_DIR ${asn1_generated_dir}/RRC_${NR_RRC_ASN1_VERSION}) # Warning: if you modify ASN.1 source file to generate new C files, cmake should be re-run instead of make - execute_process( - COMMAND ${OPENAIR_CMAKE}/tools/make_asn1c_includes.sh "NR_" "-findirect-choice" "${NR_RRC_FULL_DIR}" "${NR_RRC_GRAMMAR}" - RESULT_VARIABLE ret) -if (NOT ${ret} STREQUAL 0) - message(FATAL_ERROR "${ret}: error") -endif () -file(GLOB nr_rrc_source ${NR_RRC_FULL_DIR}/*.c) -file(GLOB nr_rrc_h ${NR_RRC_FULL_DIR}/*.h) +set(nr_rrc_cmd ${OPENAIR_CMAKE}/tools/make_asn1c_includes.sh "NR_" "-findirect-choice" "${NR_RRC_FULL_DIR}") -add_custom_target ( - nr_rrc_flag ALL - ${OPENAIR_CMAKE}/tools/make_asn1c_includes.sh "NR_" "-findirect-choice" "${NR_RRC_FULL_DIR}" "${NR_RRC_GRAMMAR}" - DEPENDS ${NR_RRC_GRAMMAR} - ) +compile_asn1("${NR_RRC_GRAMMAR}" "${nr_rrc_cmd}" nr_rrc_flag) +file(GLOB nr_rrc_source ${NR_RRC_FULL_DIR}/*.c) +file(GLOB nr_rrc_h ${NR_RRC_FULL_DIR}/*.h) add_library(NR_RRC_LIB ${nr_rrc_h} ${nr_rrc_source} ${OPENAIR2_DIR}/RRC/NR/MESSAGES/asn1_msg.c ) @@ -503,22 +499,11 @@ set(S1AP_ASN_DIR ${S1AP_DIR}/MESSAGES/ASN1/${S1AP_RELEASE}) set(S1AP_C_DIR ${asn1_generated_dir}/S1AP_${S1AP_RELEASE}) # Warning: if you modify ASN.1 source file to generate new C files, cmake should be re-run instead of make -if (${RU} STREQUAL 0) - execute_process( - COMMAND ${OPENAIR_CMAKE}/tools/make_asn1c_includes.sh "S1AP_" -fno-include-deps "${S1AP_C_DIR}" "${S1AP_ASN_DIR}/${S1AP_ASN_FILES}" - RESULT_VARIABLE ret) - if (NOT ${ret} STREQUAL 0) - message(FATAL_ERROR "${ret}: error") - endif (NOT ${ret} STREQUAL 0) - file(GLOB S1AP_source ${S1AP_C_DIR}/*.c) -endif (${RU} STREQUAL 0) +set(s1ap_cmd ${OPENAIR_CMAKE}/tools/make_asn1c_includes.sh "S1AP_" -fno-include-deps "${S1AP_C_DIR}") - add_custom_target ( - s1ap_flag ALL - ${OPENAIR_CMAKE}/tools/make_asn1c_includes.sh "S1AP_" -fno-include-deps "${S1AP_C_DIR}" "${S1AP_ASN_DIR}/${S1AP_ASN_FILES}" - DEPENDS "${S1AP_ASN_DIR}/${S1AP_ASN_FILES}" - ) +compile_asn1("${S1AP_ASN_DIR}/${S1AP_ASN_FILES}" "${s1ap_cmd}" s1ap_flag) +file(GLOB S1AP_source ${S1AP_C_DIR}/*.c) add_library(S1AP_LIB ${S1AP_source} ${S1AP_DIR}/s1ap_common.c @@ -560,20 +545,11 @@ set(NGAP_ASN_DIR ${NGAP_DIR}/MESSAGES/ASN1/ASN1_files) set(NGAP_C_DIR ${asn1_generated_dir}/NGAP_${NGAP_RELEASE}) # Warning: if you modify ASN.1 source file to generate new C files, cmake should be re-run instead of make -execute_process( - COMMAND ${OPENAIR_CMAKE}/tools/make_asn1c_includes.sh "NGAP_" "-fno-include-deps -findirect-choice" "${NGAP_C_DIR}" "${NGAP_ASN_DIR}/${NGAP_ASN_FILES}" - RESULT_VARIABLE ret) -if (NOT ${ret} STREQUAL 0) - message(FATAL_ERROR "${ret}: error") -endif (NOT ${ret} STREQUAL 0) -file(GLOB NGAP_source ${NGAP_C_DIR}/*.c) +set (ngap_cmd ${OPENAIR_CMAKE}/tools/make_asn1c_includes.sh "NGAP_" "-fno-include-deps -findirect-choice" "${NGAP_C_DIR}") -add_custom_target ( - ngap_flag ALL - ${OPENAIR_CMAKE}/tools/make_asn1c_includes.sh "NGAP_" "-fno-include-deps -findirect-choice" "${NGAP_C_DIR}" "${NGAP_ASN_DIR}/${NGAP_ASN_FILES}" - DEPENDS "${NGAP_ASN_DIR}/${NGAP_ASN_FILES}" -) +compile_asn1("${NGAP_ASN_DIR}/${NGAP_ASN_FILES}" "${ngap_cmd}" ngap_flag) +file(GLOB NGAP_source ${NGAP_C_DIR}/*.c) add_library(NGAP_LIB ${NGAP_source} # ${NGAP_DIR}/ngap_common.c @@ -627,22 +603,12 @@ set(M2AP_ASN_DIR ${M2AP_DIR}/MESSAGES/ASN1/${M2AP_RELEASE}) set(M2AP_C_DIR ${asn1_generated_dir}/M2AP_${M2AP_RELEASE}) # Warning: if you modify ASN.1 source file to generate new C files, cmake should be re-run instead of make -if (${RU} STREQUAL 0) - execute_process( - COMMAND ${OPENAIR_CMAKE}/tools/make_asn1c_includes.sh "M2AP_" "-fno-include-deps -DEMIT_ASN_DEBUG=1" "${M2AP_C_DIR}" "${M2AP_ASN_DIR}/${M2AP_ASN_FILES}" - RESULT_VARIABLE ret) - if (NOT ${ret} STREQUAL 0) - message(FATAL_ERROR "${ret}: error") - endif (NOT ${ret} STREQUAL 0) -endif (${RU} STREQUAL 0) -file(GLOB M2AP_source ${M2AP_C_DIR}/*.c) +set(m2ap_cmd ${OPENAIR_CMAKE}/tools/make_asn1c_includes.sh "M2AP_" "-fno-include-deps -DEMIT_ASN_DEBUG=1" "${M2AP_C_DIR}") -add_custom_target ( - m2_flag ALL - COMMAND ${OPENAIR_CMAKE}/tools/make_asn1c_includes.sh "M2AP_" "-fno-include-deps -DEMIT_ASN_DEBUG=1" "${M2AP_C_DIR}" "${M2AP_ASN_DIR}/${M2AP_ASN_FILES}" - DEPENDS ${M2AP_ASN_DIR}/${M2AP_ASN_FILES} - ) + +compile_asn1("${M2AP_ASN_DIR}/${M2AP_ASN_FILES}" "${m2ap_cmd}" m2_flag) +file(GLOB M2AP_source ${M2AP_C_DIR}/*.c) add_library(M2AP_LIB ${M2AP_source} @@ -700,22 +666,11 @@ set(M3AP_ASN_DIR ${M3AP_DIR}/MESSAGES/ASN1/${M3AP_RELEASE}) set(M3AP_C_DIR ${asn1_generated_dir}/M3AP_${M3AP_RELEASE}) # Warning: if you modify ASN.1 source file to generate new C files, cmake should be re-run instead of make -if (${RU} STREQUAL 0) - execute_process( - COMMAND ${OPENAIR_CMAKE}/tools/make_asn1c_includes.sh "M3AP_" -fno-include-deps "${M3AP_C_DIR}" "${M3AP_ASN_DIR}/${M3AP_ASN_FILES}" - RESULT_VARIABLE ret) - if (NOT ${ret} STREQUAL 0) - message(FATAL_ERROR "${ret}: error") - endif (NOT ${ret} STREQUAL 0) -endif (${RU} STREQUAL 0) +set(m3_cmd ${OPENAIR_CMAKE}/tools/make_asn1c_includes.sh "M3AP_" -fno-include-deps "${M3AP_C_DIR}") -file(GLOB M3AP_source ${M3AP_C_DIR}/*.c) +compile_asn1("${M3AP_ASN_DIR}/${M3AP_ASN_FILES}" "${m3_cmd}" m3_flag) -add_custom_target ( - m3_flag ALL - COMMAND ${OPENAIR_CMAKE}/tools/make_asn1c_includes.sh "M3AP_" -fno-include-deps "${M3AP_C_DIR}" "${M3AP_ASN_DIR}/${M3AP_ASN_FILES}" - DEPENDS ${M3AP_ASN_DIR}/${M3AP_ASN_FILES} - ) +file(GLOB M3AP_source ${M3AP_C_DIR}/*.c) add_library(M3AP_LIB ${M3AP_source} @@ -757,22 +712,11 @@ add_definitions(-DX2AP_VERSION=${X2AP_VERSION}) set(X2AP_ASN_DIR ${X2AP_DIR}/MESSAGES/ASN1/${X2AP_RELEASE}) set(X2AP_C_DIR ${asn1_generated_dir}/X2AP_${X2AP_RELEASE}) # Warning: if you modify ASN.1 source file to generate new C files, cmake should be re-run instead of make -if (${RU} STREQUAL 0) - execute_process( - COMMAND ${OPENAIR_CMAKE}/tools/make_asn1c_includes.sh "X2AP_" -fno-include-deps "${X2AP_C_DIR}" "${X2AP_ASN_DIR}/${X2AP_ASN_FILES}" - RESULT_VARIABLE ret) - if (NOT ${ret} STREQUAL 0) - message(FATAL_ERROR "${ret}: error") - endif (NOT ${ret} STREQUAL 0) -endif (${RU} STREQUAL 0) +set(x2_cmd ${OPENAIR_CMAKE}/tools/make_asn1c_includes.sh "X2AP_" -fno-include-deps "${X2AP_C_DIR}") -file(GLOB X2AP_source ${X2AP_C_DIR}/*.c) +compile_asn1("${X2AP_ASN_DIR}/${X2AP_ASN_FILES}" "${x2_cmd}" x2_flag) -add_custom_target ( - x2_flag ALL - COMMAND ${OPENAIR_CMAKE}/tools/make_asn1c_includes.sh "X2AP_" -fno-include-deps "${X2AP_C_DIR}" "${X2AP_ASN_DIR}/${X2AP_ASN_FILES}" - DEPENDS ${X2AP_ASN_DIR}/${X2AP_ASN_FILES} - ) +file(GLOB X2AP_source ${X2AP_C_DIR}/*.c) add_library(X2AP_LIB ${X2AP_source} @@ -817,36 +761,25 @@ set(F1AP_ASN_FILES ${F1AP_ASN_DIR}/F1AP-Containers.asn ) -if (${RU} STREQUAL 0) - set(F1AP_ASN_GENERATED_C_DIR ${asn1_generated_dir}/F1AP_${ASN1RELDIR}) - message("calling ASN1C_PREFIX=F1AP_ asn1c -gen-PER -no-gen-OER -fcompound-names -no-gen-example -findirect-choice -fno-include-deps -D ${F1AP_ASN_GENERATED_C_DIR} ${F1AP_ASN_FILES}") - execute_process( - COMMAND ${OPENAIR_CMAKE}/tools/make_asn1c_includes.sh "F1AP_" "-findirect-choice -fno-include-deps" ${F1AP_ASN_GENERATED_C_DIR} ${F1AP_ASN_FILES} - RESULT_VARIABLE ret - ) - - if (NOT ${ret} STREQUAL 0) - message(FATAL_ERROR "asn1c: error") - endif (NOT ${ret} STREQUAL 0) - - add_custom_target ( - f1_flag ALL - COMMAND ${OPENAIR_CMAKE}/tools/make_asn1c_includes.sh "F1AP_" "-findirect-choice -fno-include-deps" ${F1AP_ASN_GENERATED_C_DIR} ${F1AP_ASN_FILES} - DEPENDS ${F1AP_ASN_FILES} - ) - file(GLOB F1AP_ASN_GENERATED_C_FILES ${F1AP_ASN_GENERATED_C_DIR}/*.c) - add_library(F1AP_LIB - ${F1AP_ASN_GENERATED_C_FILES} - ) - add_dependencies (F1AP_LIB f1_flag) - - include_directories ("${F1AP_ASN_GENERATED_C_DIR}") - include_directories ("${F1AP_DIR}") - - file(GLOB F1AP_C_FILES ${F1AP_DIR}/*.c) - add_library(F1AP ${F1AP_C_FILES} ) - -endif (${RU} STREQUAL 0) + +set(F1AP_ASN_GENERATED_C_DIR ${asn1_generated_dir}/F1AP_${ASN1RELDIR}) + +set(f1_cmd ${OPENAIR_CMAKE}/tools/make_asn1c_includes.sh "F1AP_" "-findirect-choice -fno-include-deps" "${F1AP_ASN_GENERATED_C_DIR}") + +compile_asn1("${F1AP_ASN_FILES}" "${f1_cmd}" f1_flag) + +file(GLOB F1AP_ASN_GENERATED_C_FILES ${F1AP_ASN_GENERATED_C_DIR}/*.c) +add_library(F1AP_LIB + ${F1AP_ASN_GENERATED_C_FILES} + ) +add_dependencies (F1AP_LIB f1_flag) + +include_directories ("${F1AP_ASN_GENERATED_C_DIR}") +include_directories ("${F1AP_DIR}") + +file(GLOB F1AP_C_FILES ${F1AP_DIR}/*.c) +add_library(F1AP ${F1AP_C_FILES} ) + # Hardware dependant options ################################### @@ -964,7 +897,7 @@ set(HWLIB_BENETEL_4G_SOURCE ) add_library(benetel_4g MODULE ${HWLIB_BENETEL_4G_SOURCE} ) -set_target_properties(benetel_4g PROPERTIES COMPILE_FLAGS "-fvisibility=hidden -march=native -I$ENV{RTE_SDK}/$ENV{RTE_TARGET}/include") +set_target_properties(benetel_4g PROPERTIES COMPILE_FLAGS "-fvisibility=hidden -I$ENV{RTE_SDK}/$ENV{RTE_TARGET}/include") SET(DPDK_LIBS "-Wl,-rpath,$ENV{RTE_SDK}/$ENV{RTE_TARGET}/lib -Wl,--whole-archive -L$ENV{RTE_SDK}/$ENV{RTE_TARGET}/lib -ldpdk -Wl,--no-whole-archive") TARGET_LINK_LIBRARIES(benetel_4g ${DPDK_LIBS}) @@ -982,7 +915,7 @@ set(HWLIB_BENETEL_5G_SOURCE ) add_library(benetel_5g MODULE ${HWLIB_BENETEL_5G_SOURCE} ) -set_target_properties(benetel_5g PROPERTIES COMPILE_FLAGS "-fvisibility=hidden -march=native -I$ENV{RTE_SDK}/$ENV{RTE_TARGET}/include") +set_target_properties(benetel_5g PROPERTIES COMPILE_FLAGS "-fvisibility=hidden -I$ENV{RTE_SDK}/$ENV{RTE_TARGET}/include") SET(DPDK_LIBS "-Wl,-rpath,$ENV{RTE_SDK}/$ENV{RTE_TARGET}/lib -Wl,--whole-archive -L$ENV{RTE_SDK}/$ENV{RTE_TARGET}/lib -ldpdk -Wl,--no-whole-archive") TARGET_LINK_LIBRARIES(benetel_5g ${DPDK_LIBS}) @@ -1036,7 +969,6 @@ add_boolean_option(DRIVER2013 True "only relevant for EXMIMO") add_boolean_option(EXMIMO_IOT True "????") add_boolean_option(LOCALIZATION False "???") add_integer_option(MAX_NUM_CCs 1 "????") -add_boolean_option(PHYSIM False "for L1 simulators (dlsim, ulsim, ...)") add_boolean_option(SMBV False "Rohde&Schwarz SMBV100A vector signal generator") add_boolean_option(DEBUG_PHY False "Enable PHY layer debugging options") add_boolean_option(DEBUG_PHY_PROC False "Enable debugging of PHY layer procedures") @@ -1069,7 +1001,6 @@ add_boolean_option(TRACE_RLC_AM_HOLE False "TRACE for RLC AM, TO BE CHANGE add_boolean_option(TRACE_RLC_AM_PDU False "TRACE for RLC AM, TO BE CHANGED IN A MORE GENERAL FLAG") add_boolean_option(TRACE_RLC_AM_RESEGMENT False "TRACE for RLC AM, TO BE CHANGED IN A MORE GENERAL FLAG") add_boolean_option(TRACE_RLC_AM_RX False "TRACE for RLC AM, TO BE CHANGED IN A MORE GENERAL FLAG") -add_boolean_option(TRACE_RLC_AM_RX_DECODE False "TRACE for RLC AM, TO BE CHANGED IN A MORE GENERAL FLAG") add_boolean_option(TRACE_RLC_AM_TX False "TRACE for RLC AM, TO BE CHANGED IN A MORE GENERAL FLAG") add_boolean_option(TRACE_RLC_AM_TX_STATUS False "TRACE for RLC AM, TO BE CHANGED IN A MORE GENERAL FLAG") add_boolean_option(TRACE_RLC_AM_STATUS_CREATION False "TRACE for RLC AM, TO BE CHANGED IN A MORE GENERAL FLAG") @@ -1088,6 +1019,7 @@ add_boolean_option(TRACE_RLC_UM_TX_STATUS False "TRACE for RLC UM, TO BE CHANGE ########################## #add_boolean_option(LINK_ENB_PDCP_TO_IP_DRIVER False "For eNB, PDCP communicate with a IP driver") #add_boolean_option(LINK_ENB_PDCP_TO_GTPV1U True "For eNB, PDCP communicate with GTP-U protocol (eNB<->S-GW)") +add_definitions(-DNEW_GTPU=1) ########################## # RRC LAYER OPTIONS @@ -1544,6 +1476,7 @@ set(NFAPI_USER_SRC ${NFAPI_USER_DIR}/nfapi.c ${NFAPI_USER_DIR}/nfapi_pnf.c ${NFAPI_USER_DIR}/nfapi_vnf.c + ${NFAPI_USER_DIR}/gnb_ind_vars.c ) add_library(NFAPI_USER_LIB ${NFAPI_USER_SRC}) add_dependencies(NFAPI_USER_LIB rrc_flag) @@ -1608,6 +1541,10 @@ set(PHY_LDPC_CL_SRC ${OPENAIR1_DIR}/PHY/CODING/nrLDPC_decoder/nrLDPC_decoder_CL.c ${OPENAIR1_DIR}/PHY/CODING/nrLDPC_encoder/ldpc_encoder_optim8segmulti.c ) +add_custom_target( nrLDPC_decoder_kernels_CL + COMMAND gcc ${OPENAIR1_DIR}/PHY/CODING/nrLDPC_decoder/nrLDPC_decoder_CL.c -dD -DNRLDPC_KERNEL_SOURCE -E -o ${CMAKE_CURRENT_BINARY_DIR}/nrLDPC_decoder_kernels_CL.clc + SOURCES ${OPENAIR1_DIR}/PHY/CODING/nrLDPC_decoder/nrLDPC_decoder_CL.c +) set(PHY_NR_CODINGIF ${OPENAIR1_DIR}/PHY/CODING/nrLDPC_load.c; @@ -1618,6 +1555,7 @@ add_library(ldpc_optim MODULE ${PHY_LDPC_OPTIM_SRC} ) add_library(ldpc_optim8seg MODULE ${PHY_LDPC_OPTIM8SEG_SRC} ) add_library(ldpc_cl MODULE ${PHY_LDPC_CL_SRC} ) target_link_libraries(ldpc_cl OpenCL) +add_dependencies(ldpc_cl nrLDPC_decoder_kernels_CL) if (CUDA_FOUND) cuda_add_library(ldpc_cuda MODULE ${PHY_LDPC_CUDA_SRC} ) @@ -1648,7 +1586,6 @@ set(PHY_SRC_COMMON ${OPENAIR1_DIR}/PHY/LTE_TRANSPORT/prach_common.c ${OPENAIR1_DIR}/PHY/LTE_TRANSPORT/pucch_common.c ${OPENAIR1_DIR}/PHY/LTE_TRANSPORT/dlsch_scrambling.c - ${OPENAIR1_DIR}/PHY/LTE_TRANSPORT/lte_gold_generic.c ${OPENAIR1_DIR}/PHY/LTE_UE_TRANSPORT/srs_modulation.c ${OPENAIR1_DIR}/PHY/MODULATION/ofdm_mod.c ${OPENAIR1_DIR}/PHY/LTE_ESTIMATION/lte_sync_time.c @@ -1773,6 +1710,9 @@ set(PHY_SRC_UE set(PHY_NR_SRC_COMMON ${OPENAIR1_DIR}/PHY/NR_TRANSPORT/nr_prach_common.c + ${OPENAIR1_DIR}/PHY/NR_UE_TRANSPORT/srs_modulation_nr.c + ${OPENAIR1_DIR}/PHY/NR_TRANSPORT/nr_scrambling.c + ${OPENAIR1_DIR}/PHY/NR_REFSIG/scrambling_luts.c ) set(PHY_NR_SRC @@ -1798,7 +1738,6 @@ set(PHY_SRC_UE ${OPENAIR1_DIR}/PHY/NR_REFSIG/nr_dmrs_rx.c ${OPENAIR1_DIR}/PHY/NR_TRANSPORT/nr_csi_rs.c ${OPENAIR1_DIR}/PHY/NR_REFSIG/nr_gold.c - ${OPENAIR1_DIR}/PHY/NR_REFSIG/scrambling_luts.c ${OPENAIR1_DIR}/PHY/NR_REFSIG/nr_gen_mod_table.c ${OPENAIR1_DIR}/PHY/NR_REFSIG/dmrs_nr.c ${OPENAIR1_DIR}/PHY/NR_REFSIG/ptrs_nr.c @@ -1821,6 +1760,7 @@ set(PHY_SRC_UE ${PHY_SMALLBLOCKSRC} ${PHY_NR_CODINGIF} ${OPENAIR1_DIR}/PHY/NR_TRANSPORT/pucch_rx.c + ${OPENAIR1_DIR}/PHY/NR_TRANSPORT/srs_rx.c ${OPENAIR1_DIR}/PHY/NR_TRANSPORT/nr_uci_tools_common.c ) set(PHY_NR_UE_SRC @@ -1842,7 +1782,6 @@ set(PHY_SRC_UE ${OPENAIR1_DIR}/PHY/NR_TRANSPORT/nr_sch_dmrs.c ${OPENAIR1_DIR}/PHY/NR_UE_TRANSPORT/ ${OPENAIR1_DIR}/PHY/NR_UE_TRANSPORT/nr_prach.c - ${OPENAIR1_DIR}/PHY/NR_UE_TRANSPORT/srs_modulation_nr.c ${OPENAIR1_DIR}/PHY/NR_UE_TRANSPORT/dci_nr.c ${OPENAIR1_DIR}/PHY/NR_UE_TRANSPORT/dci_tools_nr.c ${OPENAIR1_DIR}/PHY/NR_UE_TRANSPORT/pucch_nr.c @@ -2098,6 +2037,7 @@ set(NR_L2_SRC_UE ${NR_UE_RRC_DIR}/L2_interface_ue.c ${NR_UE_RRC_DIR}/main_ue.c ${NR_UE_RRC_DIR}/rrc_UE.c + ${NR_UE_RRC_DIR}/rrc_nsa.c ) set (MAC_SRC @@ -2136,12 +2076,14 @@ set (MAC_NR_SRC ${NR_GNB_MAC_DIR}/gNB_scheduler_primitives.c ${NR_GNB_MAC_DIR}/gNB_scheduler_phytest.c ${NR_GNB_MAC_DIR}/gNB_scheduler_uci.c + ${NR_GNB_MAC_DIR}/gNB_scheduler_srs.c ${NR_GNB_MAC_DIR}/gNB_scheduler_RA.c ) set (MAC_SRC_UE ${PHY_INTERFACE_DIR}/phy_stub_UE.c + ${PHY_INTERFACE_DIR}/queue_t.c ${MAC_DIR}/main_ue.c ${MAC_DIR}/ue_procedures.c ${MAC_DIR}/ra_procedures.c @@ -2833,7 +2775,6 @@ target_link_libraries (test5Gnas LIB_5GNAS_GNB CONFIG_LIB minimal_lib ) ################################################### add_executable(lte-softmodem - ${OPENAIR_TARGETS}/RT/USER/rt_wrapper.c ${OPENAIR_TARGETS}/RT/USER/lte-enb.c ${OPENAIR_TARGETS}/RT/USER/lte-ru.c ${OPENAIR_TARGETS}/RT/USER/ru_control.c @@ -2855,6 +2796,7 @@ add_executable(lte-softmodem ${OPENAIR3_DIR}/NAS/UE/nas_ue_task.c ${OPENAIR_DIR}/common/utils/utils.c ${OPENAIR_DIR}/common/utils/system.c + ${PHY_INTERFACE_DIR}/queue_t.c ${OPENAIR_DIR}/common/utils/lte/ue_power.c ${OPENAIR_DIR}/common/utils/lte/prach_utils.c ${XFORMSINTERFACE_SOURCE} @@ -2866,7 +2808,7 @@ add_dependencies(lte-softmodem rrc_flag s1ap_flag x2_flag oai_iqplayer) target_link_libraries (lte-softmodem -Wl,--start-group - RRC_LIB NR_RRC_LIB S1AP_LIB S1AP_ENB F1AP_LIB F1AP M2AP_LIB M2AP_ENB X2AP_LIB X2AP_ENB M3AP_LIB M3AP_ENB NR_GTPV1U SECU_CN SECU_OSA UTIL HASHTABLE SCTP_CLIENT MME_APP UDP SCHED_LIB SCHED_RU_LIB + RRC_LIB NR_RRC_LIB S1AP_LIB S1AP_ENB M2AP_LIB M2AP_ENB X2AP_LIB X2AP_ENB M3AP_LIB M3AP_ENB GTPV1U_OCP F1AP_LIB F1AP SECU_CN SECU_OSA UTIL HASHTABLE SCTP_CLIENT MME_APP UDP SCHED_LIB SCHED_RU_LIB PHY_COMMON PHY PHY_RU LFDS L2 L2_LTE NFAPI_COMMON_LIB NFAPI_LIB NFAPI_VNF_LIB NFAPI_PNF_LIB NFAPI_USER_LIB MISC_NFAPI_LTE_LIB LFDS7 ${MSC_LIB} ${RAL_LIB} ${NAS_UE_LIB} ITTI ${FLPT_MSG_LIB} ${ASYNC_IF_LIB} ${FLEXRAN_AGENT_LIB} ${FSPT_MSG_LIB} ${PROTO_AGENT_LIB} -Wl,--end-group z dl) @@ -2899,6 +2841,7 @@ add_executable(ocp-enb ${OPENAIR_DIR}/common/utils/system.c ${OPENAIR_DIR}/common/utils/lte/ue_power.c ${OPENAIR_DIR}/common/utils/lte/prach_utils.c + ${PHY_INTERFACE_DIR}/queue_t.c ${XFORMSINTERFACE_SOURCE} ${T_SOURCE} ${CONFIG_SOURCES} @@ -2909,7 +2852,7 @@ add_dependencies(ocp-enb rrc_flag s1ap_flag x2_flag oai_iqplayer coding params_l target_link_libraries (ocp-enb -Wl,--start-group - RRC_LIB NR_RRC_LIB S1AP_LIB S1AP_ENB F1AP_LIB F1AP M2AP_LIB M2AP_ENB X2AP_LIB X2AP_ENB M3AP_LIB M3AP_ENB NR_GTPV1U SECU_CN SECU_OSA UTIL HASHTABLE SCTP_CLIENT MME_APP UDP SCHED_LIB SCHED_RU_LIB + RRC_LIB NR_RRC_LIB S1AP_LIB S1AP_ENB F1AP_LIB F1AP M2AP_LIB M2AP_ENB X2AP_LIB X2AP_ENB M3AP_LIB M3AP_ENB GTPV1U_OCP SECU_CN SECU_OSA UTIL HASHTABLE SCTP_CLIENT MME_APP UDP SCHED_LIB SCHED_RU_LIB PHY_COMMON PHY PHY_RU LFDS L2 L2_LTE NFAPI_COMMON_LIB NFAPI_LIB MISC_NFAPI_LTE_LIB NFAPI_VNF_LIB NFAPI_PNF_LIB NFAPI_USER_LIB LFDS7 SIMU_COMMON ${MSC_LIB} ${RAL_LIB} ${NAS_UE_LIB} ITTI ${FLPT_MSG_LIB} ${ASYNC_IF_LIB} ${FLEXRAN_AGENT_LIB} ${FSPT_MSG_LIB} ${PROTO_AGENT_LIB} -Wl,--end-group z dl) @@ -2946,7 +2889,6 @@ target_link_libraries(du_test add_executable(oairu ${OPENAIR_TARGETS}/RT/USER/lte-ru.c ${OPENAIR_TARGETS}/RT/USER/ru_control.c - ${OPENAIR_TARGETS}/RT/USER/rt_wrapper.c ${OPENAIR_TARGETS}/ARCH/COMMON/common_lib.c ${OPENAIR_TARGETS}/ARCH/COMMON/record_player.c ${OPENAIR_DIR}/executables/softmodem-common.c @@ -2974,7 +2916,6 @@ target_link_libraries (oairu pthread m ${CONFIG_LIB} rt ${CMAKE_DL_LIBS} ${T_LIB ####################################### add_executable(lte-uesoftmodem - ${OPENAIR_TARGETS}/RT/USER/rt_wrapper.c ${OPENAIR_TARGETS}/RT/USER/lte-ue.c ${OPENAIR_TARGETS}/RT/USER/lte-uesoftmodem.c ${OPENAIR_DIR}/executables/softmodem-common.c @@ -3004,9 +2945,8 @@ if (NOT ${NOS1}) endif() target_link_libraries (lte-uesoftmodem -Wl,--start-group - RRC_LIB NR_RRC_LIB S1AP_LIB S1AP_ENB X2AP_LIB X2AP_ENB M2AP_LIB M2AP_ENB M3AP_LIB M3AP_ENB F1AP F1AP_LIB - - NR_GTPV1U SECU_CN SECU_OSA UTIL HASHTABLE SCTP_CLIENT MME_APP UDP SCHED_RU_LIB SCHED_UE_LIB PHY_COMMON + RRC_LIB NR_RRC_LIB S1AP_LIB S1AP_ENB X2AP_LIB X2AP_ENB M2AP_LIB M2AP_ENB M3AP_LIB M3AP_ENB + SECU_CN SECU_OSA UTIL HASHTABLE SCTP_CLIENT MME_APP UDP SCHED_RU_LIB SCHED_UE_LIB PHY_COMMON PHY_UE PHY_RU LFDS L2_UE L2_LTE LFDS7 SIMU_COMMON SIMU NFAPI_COMMON_LIB NFAPI_LIB NFAPI_PNF_LIB NFAPI_USER_LIB MISC_NFAPI_LTE_LIB ${MSC_LIB} ${RAL_LIB} ${NAS_UE_LIB} ITTI ${FLPT_MSG_LIB} ${ASYNC_IF_LIB} ${ATLAS_LIBRARIES} -Wl,--end-group z dl) @@ -3040,6 +2980,7 @@ add_executable(nr-softmodem ${OPENAIR_DIR}/common/utils/lte/ue_power.c ${OPENAIR_DIR}/common/utils/lte/prach_utils.c ${OPENAIR_DIR}/common/utils/nr/nr_common.c + ${PHY_INTERFACE_DIR}/queue_t.c ${XFORMSINTERFACE_SOURCE} ${T_SOURCE} ${CONFIG_SOURCES} @@ -3080,6 +3021,7 @@ add_executable(ocp-gnb ${OPENAIR_DIR}/common/utils/nr/nr_common.c ${OPENAIR_DIR}/common/utils/utils.c ${OPENAIR_DIR}/common/utils/system.c + ${PHY_INTERFACE_DIR}/queue_t.c ${XFORMS_SOURCE_NR} ${T_SOURCE} ${CONFIG_SOURCES} @@ -3283,14 +3225,16 @@ add_executable(nr_dlsim ${OPENAIR_DIR}/executables/softmodem-common.c ${OPENAIR2_DIR}/RRC/NAS/nas_config.c ${OPENAIR1_DIR}/SIMULATION/ETH_TRANSPORT/netlink_init.c + ${NR_UE_RRC_DIR}/rrc_nsa.c ${NFAPI_USER_DIR}/nfapi.c ${OPENAIR_DIR}/common/utils/threadPool/thread-pool.c + ${PHY_INTERFACE_DIR}/queue_t.c ${UTIL_SRC} ${T_SOURCE} ${SHLIB_LOADER_SOURCES} ) target_link_libraries(nr_dlsim - -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 -Wl,--end-group + -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 ) target_compile_definitions(nr_dlsim PUBLIC -DPHYSICAL_SIMULATOR) @@ -3303,13 +3247,15 @@ add_executable(nr_prachsim ${OPENAIR1_DIR}/SCHED_NR/phy_procedures_nr_common.c ${OPENAIR2_DIR}/RRC/NAS/nas_config.c ${OPENAIR1_DIR}/SIMULATION/ETH_TRANSPORT/netlink_init.c + ${NR_UE_RRC_DIR}/rrc_nsa.c ${NFAPI_USER_DIR}/nfapi.c ${OPENAIR_DIR}/common/utils/threadPool/thread-pool.c + ${PHY_INTERFACE_DIR}/queue_t.c ${UTIL_SRC} ${T_SOURCE} ${SHLIB_LOADER_SOURCES}) target_link_libraries(nr_prachsim - -Wl,--start-group UTIL SIMU_COMMON SIMU PHY_COMMON PHY_NR_COMMON PHY_NR PHY_RU PHY_NR_UE MAC_NR_COMMON 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 -Wl,--end-group + -Wl,--start-group UTIL SIMU_COMMON SIMU PHY_COMMON PHY_NR_COMMON PHY_NR PHY_RU PHY_NR_UE MAC_NR_COMMON 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) add_executable(nr_ulschsim @@ -3318,6 +3264,7 @@ add_executable(nr_ulschsim ${OPENAIR_DIR}/common/utils/utils.c ${OPENAIR_DIR}/common/utils/system.c ${OPENAIR_DIR}/common/utils/nr/nr_common.c + ${PHY_INTERFACE_DIR}/queue_t.c ${UTIL_SRC} ${T_SOURCE} ${SHLIB_LOADER_SOURCES} @@ -3336,13 +3283,15 @@ add_executable(nr_ulsim ${OPENAIR_DIR}/executables/softmodem-common.c ${OPENAIR2_DIR}/RRC/NAS/nas_config.c ${OPENAIR1_DIR}/SIMULATION/ETH_TRANSPORT/netlink_init.c + ${NR_UE_RRC_DIR}/rrc_nsa.c ${NFAPI_USER_DIR}/nfapi.c + ${PHY_INTERFACE_DIR}/queue_t.c ${UTIL_SRC} ${T_SOURCE} ${SHLIB_LOADER_SOURCES} ) 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 -Wl,--end-group + -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 ) target_compile_definitions(nr_ulsim PUBLIC -DPHYSICAL_SIMULATOR) @@ -3380,7 +3329,7 @@ add_executable(test_epc_generate_scenario ${OPENAIR3_DIR}/S1AP/s1ap_eNB_defs.h ) target_link_libraries (test_epc_generate_scenario - -Wl,--start-group RRC_LIB S1AP_LIB S1AP_ENB X2AP_LIB X2AP_ENB M2AP_LIB M2AP_ENB M3AP_LIB M3AP_ENB F1AP_LIB F1AP NR_GTPV1U LIB_NAS_UE SECU_CN UTIL HASHTABLE SCTP_CLIENT MME_APP UDP SCHED_LIB PHY LFDS ITTI ${MSC_LIB} L2 -Wl,--end-group pthread m rt crypt sctp ${LIBXML2_LIBRARIES} ${LIBXSLT_LIBRARIES} ${CRYPTO_LIBRARIES} ${OPENSSL_LIBRARIES} ${CONFIG_LIB} + -Wl,--start-group RRC_LIB S1AP_LIB S1AP_ENB X2AP_LIB X2AP_ENB M2AP_LIB M2AP_ENB M3AP_LIB M3AP_ENB F1AP_LIB F1AP GTPV1U_OCP LIB_NAS_UE SECU_CN UTIL HASHTABLE SCTP_CLIENT MME_APP UDP SCHED_LIB PHY LFDS ITTI ${MSC_LIB} L2 -Wl,--end-group pthread m rt crypt sctp ${LIBXML2_LIBRARIES} ${LIBXSLT_LIBRARIES} ${CRYPTO_LIBRARIES} ${OPENSSL_LIBRARIES} ${CONFIG_LIB} ) add_executable(test_epc_play_scenario @@ -3399,7 +3348,7 @@ add_executable(test_epc_play_scenario ) target_include_directories(test_epc_play_scenario PUBLIC /usr/local/share/asn1c) target_link_libraries (test_epc_play_scenario - -Wl,--start-group RRC_LIB S1AP_LIB X2AP_LIB X2AP_ENB M3AP_LIB M3AP_ENB F1AP_LIB F1AP NR_GTPV1U LIB_NAS_UE SECU_CN UTIL HASHTABLE SCTP_CLIENT MME_APP UDP SCHED_LIB PHY_NR_COMMON PHY_COMMON PHY PHY_UE LFDS ITTI ${MSC_LIB} -Wl,--end-group pthread m rt crypt sctp ${LIBXML2_LIBRARIES} ${LIBXSLT_LIBRARIES} ${CRYPTO_LIBRARIES} ${OPENSSL_LIBRARIES} ${CONFIG_LIB} + -Wl,--start-group RRC_LIB S1AP_LIB X2AP_LIB X2AP_ENB M3AP_LIB M3AP_ENB F1AP_LIB F1AP GTPV1U_OCP LIB_NAS_UE SECU_CN UTIL HASHTABLE SCTP_CLIENT MME_APP UDP SCHED_LIB PHY_NR_COMMON PHY_COMMON PHY PHY_UE LFDS ITTI ${MSC_LIB} -Wl,--end-group pthread m rt crypt sctp ${LIBXML2_LIBRARIES} ${LIBXSLT_LIBRARIES} ${CRYPTO_LIBRARIES} ${OPENSSL_LIBRARIES} ${CONFIG_LIB} ) @@ -3445,7 +3394,7 @@ if (${T_TRACER}) NFAPI_COMMON_LIB NFAPI_LIB NFAPI_PNF_LIB NFAPI_VNF_LIB NFAPI_USER_LIB PHY_COMMON PHY PHY_UE PHY_NR PHY_NR_COMMON PHY_NR_UE PHY_RU PHY_MEX L2 L2_LTE L2_NR L2_LTE_NR L2_UE NR_L2_UE L2_UE_LTE_NR MAC_NR_COMMON MAC_NR MAC_UE_NR NGAP_GNB - CN_UTILS NR_GTPV1U GTPV1U_OCP SCTP_CLIENT MME_APP UDP LIB_NAS_UE NB_IoT LFDS LFDS7 SIMU_COMMON SIMU SIMU_ETH OPENAIR0_LIB + CN_UTILS GTPV1U_OCP GTPV1U_OCP SCTP_CLIENT MME_APP UDP LIB_NAS_UE NB_IoT LFDS LFDS7 SIMU_COMMON SIMU SIMU_ETH OPENAIR0_LIB ldpc_orig ldpc_optim ldpc_optim8seg ldpc PROTO_AGENT dfts) if (TARGET ${i}) add_dependencies(${i} generate_T) diff --git a/cmake_targets/build_oai b/cmake_targets/build_oai index 5c833c502a9c03e4a2dd2ccd09e4f45f06982e0d..92bcfd88e2e577e27b3d481321e770e1b6d8ed8b 100755 --- a/cmake_targets/build_oai +++ b/cmake_targets/build_oai @@ -27,9 +27,8 @@ set -e # Include helper functions -ORIGIN_PATH=$PWD -THIS_SCRIPT_PATH=$(dirname $(readlink -f $0)) -source $THIS_SCRIPT_PATH/tools/build_helper +THIS_SCRIPT_PATH=$(dirname $(readlink -f "$0")) +source "$THIS_SCRIPT_PATH"/tools/build_helper # Set environment variables (OPENAIR_HOME, ...) set_openair_env @@ -38,7 +37,6 @@ set_openair_env gen_nvram_path=$OPENAIR_DIR/targets/bin conf_nvram_path=$OPENAIR_DIR/openair3/NAS/TOOLS/ue_eurecom_test_sfr.conf -MSC_GEN=0 XFORMS="True" SKIP_SHARED_LIB_FLAG="False" UE_EXPANSION="False" @@ -59,7 +57,7 @@ BUILD_DOXYGEN=0 BUILD_COVERITY_SCAN=0 T_TRACER="True" DISABLE_HARDWARE_DEPENDENCY="False" -CMAKE_BUILD_TYPE="" +CMAKE_BUILD_TYPE="RelWithDebInfo" CMAKE_CMD="$CMAKE" UE_AUTOTEST_TRACE="False" UE_DEBUG_TRACE="False" @@ -101,25 +99,23 @@ Options Makes the LTE softmodem --eNBocp Makes the OCP LTE softmodem --gNB +--gNB Makes the NR softmodem ---nrUE - Makes the NR UE softmodem --RU - Makes the OAI RRU (without full stack) + Makes the OAI RRU --UE Makes the UE specific parts (ue_ip, usim, nvram) from the given configuration file +--nrUE + Makes the NR UE softmodem --UE-conf-nvram [configuration file] Specify conf_nvram_path (default \"$conf_nvram_path\") --UE-gen-nvram [output path] Specify gen_nvram_path (default \"$gen_nvram_path\") ---HWLAT - Makes test program for haw latency tests --a | --agent - Enables agent for software-defined control of the eNB -w | --hardware EXMIMO, USRP, BLADERF, LMSSDR, IRIS, ADRV9371_ZC706, SIMU, AW2SORI, None (Default) Adds this RF board support (in external packages installation and in compilation) +-t | --transport + Selects the transport protocol type, options: None, Ethernet, benetel4g, benetel5g -P | --phy_simulators Makes the unitary tests Layer 1 simulators -S | --core_simulators @@ -130,6 +126,14 @@ Options runs only specified test cases specified here. This flag is only valid with -s -V | --vcd Adds a debgging facility to the binary files: GUI with major internal synchronization events +-x | --xforms + Will compile with software oscilloscope features +--HWLAT + Makes test program for haw latency tests +--HWLAT_TEST + Compiles a hw latency test program +--verbose-ci + Compile with verbose instructions in CI Docker env --verbose-compile Shows detailed compilation instructions in makefile --cflags_processor @@ -165,6 +169,10 @@ Options Build for I/Q record-playback modes -k | --skip-shared-libraries Skip build for shared libraries to reduce compilation time when building frequently for debugging purposes +--ninja + Tell cmake to use the Ninja build system. Without, will generate make files +--sanitize-address | -fsanitize=address + Enable the address sanitizer on all targets --ittiSIM Makes the itti simulator -h | --help @@ -208,28 +216,24 @@ function main() { -g | --run-with-gdb) case "$2" in "Release") - GDB=0 CMAKE_BUILD_TYPE="Release" echo_info "Will Compile without gdb symbols and with compiler optimization" CMAKE_CMD="$CMAKE_CMD -DCMAKE_BUILD_TYPE=Release" shift ;; "RelWithDebInfo") - GDB=0 CMAKE_BUILD_TYPE="RelWithDebInfo" echo_info "Will Compile with gdb symbols" CMAKE_CMD="$CMAKE_CMD -DCMAKE_BUILD_TYPE=RelWithDebInfo -DCMAKE_EXPORT_COMPILE_COMMANDS=1" shift ;; "MinSizeRel") - GDB=0 CMAKE_BUILD_TYPE="MinSizeRel" echo_info "Will Compile for minimal exec size" CMAKE_CMD="$CMAKE_CMD -DCMAKE_BUILD_TYPE=MinSizeRel" shift ;; "Debug" | *) - GDB=1 CMAKE_BUILD_TYPE="Debug" echo_info "Will Compile with gdb symbols and disable compiler optimization" CMAKE_CMD="$CMAKE_CMD -DCMAKE_BUILD_TYPE=Debug" @@ -244,37 +248,30 @@ function main() { shift;; --eNB) eNB=1 - RU=0 echo_info "Will compile eNB" shift;; --eNBocp) eNBocp=1 - RU=0 echo_info "Will compile OCP eNB" shift;; --gNB) gNB=1 - RU=0 - NR="True" echo_info "Will compile gNB" shift;; --RU) - RU=1 + RU=1 echo_info "Will compile RRU" shift;; -a | --agent) echo_info "FlexRAN support is always compiled into the eNB" shift;; --UE) - RU=0 UE=1 echo_info "Will compile UE" shift;; --nrUE) - RU=0 nrUE=1 rfsimNas=1 - NR="True" echo_info "Will compile NR UE" shift;; --mu) @@ -282,10 +279,10 @@ function main() { echo_info "Will compile with UE_EXPANSION" shift;; --UE-conf-nvram) - conf_nvram_path=$(readlink -f $2) + conf_nvram_path=$(readlink -f "$2") shift 2;; --UE-gen-nvram) - gen_nvram_path=$(readlink -f $2) + gen_nvram_path=$(readlink -f "$2") shift 2;; -w | --hardware) # Use OAI_USRP as the key word USRP is used inside UHD driver @@ -309,7 +306,6 @@ function main() { shift 2;; -P | --phy_simulators) SIMUS_PHY=1 - RU=0 echo_info "Will compile dlsim, ulsim, ..." shift;; -S | --core_simulators) @@ -344,11 +340,11 @@ function main() { echo_info "Will compile hw latency test program" shift;; --verbose-ci) - VERBOSE_CI=1 + VERBOSE_CI=1 echo_info "Will compile with verbose instructions in CI Docker env" shift;; --verbose-compile) - VERBOSE_COMPILE=1 + VERBOSE_COMPILE=1 echo_info "Will compile with verbose instructions" shift;; --cflags_processor) @@ -478,7 +474,7 @@ function main() { ######################################################## # to be discussed - if [ "$eNB" = "1" -o "$eNBocp" = "1" -o "$gNB" = "1" -o "$RU" = "1" ] ; then + if [ "$eNB" = "1" -o "$eNBocp" = "1" -o "$gNB" = "1" ] ; then if [ "$HW" = "None" -a "$TP" = "None" ] ; then echo_info "No local radio head and no transport protocol selected" fi @@ -589,15 +585,12 @@ function main() { echo_info "3. building the compilation directives ..." DIR=$OPENAIR_DIR/cmake_targets - if [ "$SIMUS_PHY" = "1" -o "$SIMUS_CORE" = "1" ] ; then - build_dir=phy_simulators - else - if [ "$T_TRACER" = "False" ] ; then + if [ "$T_TRACER" = "False" ] ; then build_dir=ran_build_noLOG - else + else build_dir=ran_build - fi fi + [ "$CLEAN" = "1" ] && rm -rf $DIR/$build_dir/build mkdir -p $DIR/$build_dir/build @@ -605,89 +598,81 @@ function main() { config_libconfig_shlib=params_libconfig # first generate the CMakefile in the right directory - if [ "$eNB" = "1" -o "$eNBocp" = "1" -o "$UE" = "1" -o "$gNB" = "1" -o "$RU" = "1" -o "$nrUE" = "1" -o "$HW" = "EXMIMO" -o "$ittiSIM" = "1" -o "$rfsimNas" = "1" ] ; then - - # softmodem compilation - - cmake_file=$DIR/$build_dir/CMakeLists.txt - echo "cmake_minimum_required(VERSION 2.8)" > $cmake_file - echo "project (OpenAirInterface)" >> $cmake_file - echo "set ( CMAKE_BUILD_TYPE $CMAKE_BUILD_TYPE )" >> $cmake_file - echo "set ( CFLAGS_PROCESSOR_USER \"$CFLAGS_PROCESSOR_USER\" )" >> $cmake_file - echo "set ( UE_EXPANSION $UE_EXPANSION )" >> $cmake_file -# echo "set ( PHY_TX_THREAD $UE_EXPANSION )" >> $cmake_file - echo "set ( PRE_SCD_THREAD $UE_EXPANSION )" >> $cmake_file - echo "set ( ENABLE_VCD_FIFO $VCD_TIMING )" >> $cmake_file - echo "set ( RF_BOARD \"${HW}\")" >> $cmake_file - echo "set ( TRANSP_PRO \"${TP}\")" >> $cmake_file - echo "set ( PACKAGE_NAME \"${exec}\")" >> $cmake_file - echo "set ( DEADLINE_SCHEDULER \"${DEADLINE_SCHEDULER_FLAG_USER}\" )" >> $cmake_file - echo "set ( CPU_AFFINITY \"${CPU_AFFINITY_FLAG_USER}\" )" >> $cmake_file - echo "set ( T_TRACER $T_TRACER )" >> $cmake_file - echo "set ( UE_AUTOTEST_TRACE $UE_AUTOTEST_TRACE )" >> $cmake_file - echo "set ( UE_DEBUG_TRACE $UE_DEBUG_TRACE )" >> $cmake_file - echo "set ( UE_TIMING_TRACE $UE_TIMING_TRACE )" >> $cmake_file - echo "set ( USRP_REC_PLAY $USRP_REC_PLAY )" >> $cmake_file - echo "set ( SKIP_SHARED_LIB_FLAG $SKIP_SHARED_LIB_FLAG )" >> $cmake_file - echo "set ( RU $RU )" >> $cmake_file - echo "set ( ITTI_SIM $ITTI_SIM )" >> $cmake_file - echo "set ( SANITIZE_ADDRESS $SANITIZE_ADDRESS )" >> $cmake_file - echo 'include(${CMAKE_CURRENT_SOURCE_DIR}/../CMakeLists.txt)' >> $cmake_file - cd $DIR/$build_dir/build - eval $CMAKE_CMD - - execlist="" - if [ "$eNB" = "1" ] ; then + # softmodem compilation + + cmake_file=$DIR/$build_dir/CMakeLists.txt + echo "cmake_minimum_required(VERSION 2.8)" > $cmake_file + echo "project (OpenAirInterface)" >> $cmake_file + echo "set ( CMAKE_BUILD_TYPE $CMAKE_BUILD_TYPE )" >> $cmake_file + echo "set ( CFLAGS_PROCESSOR_USER \"$CFLAGS_PROCESSOR_USER\" )" >> $cmake_file + echo "set ( UE_EXPANSION $UE_EXPANSION )" >> $cmake_file + # echo "set ( PHY_TX_THREAD $UE_EXPANSION )" >> $cmake_file + echo "set ( PRE_SCD_THREAD $UE_EXPANSION )" >> $cmake_file + echo "set ( ENABLE_VCD_FIFO $VCD_TIMING )" >> $cmake_file + echo "set ( RF_BOARD \"${HW}\")" >> $cmake_file + echo "set ( TRANSP_PRO \"${TP}\")" >> $cmake_file + echo "set ( PACKAGE_NAME \"${exec}\")" >> $cmake_file + echo "set ( DEADLINE_SCHEDULER \"${DEADLINE_SCHEDULER_FLAG_USER}\" )" >> $cmake_file + echo "set ( CPU_AFFINITY \"${CPU_AFFINITY_FLAG_USER}\" )" >> $cmake_file + echo "set ( T_TRACER $T_TRACER )" >> $cmake_file + echo "set ( UE_AUTOTEST_TRACE $UE_AUTOTEST_TRACE )" >> $cmake_file + echo "set ( UE_DEBUG_TRACE $UE_DEBUG_TRACE )" >> $cmake_file + echo "set ( UE_TIMING_TRACE $UE_TIMING_TRACE )" >> $cmake_file + echo "set ( USRP_REC_PLAY $USRP_REC_PLAY )" >> $cmake_file + echo "set ( SKIP_SHARED_LIB_FLAG $SKIP_SHARED_LIB_FLAG )" >> $cmake_file + echo "set ( ITTI_SIM $ITTI_SIM )" >> $cmake_file + echo "set ( SANITIZE_ADDRESS $SANITIZE_ADDRESS )" >> $cmake_file + echo 'include(${CMAKE_CURRENT_SOURCE_DIR}/../CMakeLists.txt)' >> $cmake_file + cd $DIR/$build_dir/build + eval $CMAKE_CMD + + execlist="" + if [ "$eNB" = "1" ] ; then execlist="$execlist lte-softmodem" - fi - if [ "$eNBocp" = "1" ] ; then + fi + if [ "$eNBocp" = "1" ] ; then execlist="$execlist ocp-enb" - fi - if [ "$gNB" = "1" ] ; then + fi + if [ "$gNB" = "1" ] ; then execlist="$execlist nr-softmodem" - fi - if [ "$RU" = "1" ] ; then + fi + if [ "$RU" = "1" ] ; then execlist="$execlist oairu" - fi - if [ "$UE" = 1 ] ; then + fi + if [ "$UE" = 1 ] ; then execlist="$execlist lte-uesoftmodem" - fi - if [ "$nrUE" = 1 ] ; then + fi + if [ "$nrUE" = 1 ] ; then execlist="$execlist nr-uesoftmodem" - fi - - if [ "$ittiSIM" = "1" ] ; then + fi + + if [ "$ittiSIM" = "1" ] ; then execlist="$execlist nr-ittisim" - fi - - for f in $execlist ; do + fi + + for f in $execlist ; do echo_info "Compiling $f..." compilations \ - $build_dir $f \ - $f $dbin/$f.$REL - done - - -# mandatory shared libraries common to UE and (e/g)NB - - if [ "$SKIP_SHARED_LIB_FLAG" = "False" ]; then + $build_dir $f \ + $f $dbin/$f.$REL + done + + + # mandatory shared libraries common to UE and (e/g)NB + + if [ "$SKIP_SHARED_LIB_FLAG" = "False" ]; then echo_info "Building shared libraries common to UE and gNB" - + + compilations \ + $build_dir $config_libconfig_shlib \ + lib$config_libconfig_shlib.so $dbin/lib$config_libconfig_shlib.so + compilations \ - $build_dir $config_libconfig_shlib \ - lib$config_libconfig_shlib.so $dbin/lib$config_libconfig_shlib.so - - if [ "$RU" = "0" ] ; then - - compilations \ $build_dir coding \ libcoding.so $dbin/libcoding.so - - - fi - fi + fi - + if [ "$UE" = 1 ] ; then echo_info "Compiling UE specific part" @@ -726,7 +711,7 @@ function main() { # generate USIM data if [ -f $dbin/conf2uedata ]; then - install_nas_tools $conf_nvram_path $gen_nvram_path + install_nas_tools $conf_nvram_path $gen_nvram_path "$dlog/conf2uedata.txt" echo_info "Copying UE specific part to $DIR/$build_dir/build" cp -Rvf $dbin/.ue_emm.nvram0 $DIR/$build_dir/build cp -Rvf $dbin/.ue.nvram0 $DIR/$build_dir/build @@ -736,11 +721,8 @@ function main() { fi fi - if [ "$SIMUS_PHY" = "1" -o "$SIMUS_CORE" = "1" ] ; then - cd $DIR/$build_dir/build - eval $CMAKE_CMD - fi - + cd $DIR/$build_dir/build + ################## # PHY simulators # ################## @@ -751,11 +733,11 @@ function main() { # simlist="ldpctest" for f in $simlist ; do compilations \ - phy_simulators $f \ + ran_build $f \ $f $dbin/$f.$REL done compilations \ - phy_simulators coding \ + ran_build coding \ libcoding.so $dbin/libcoding.so # compilations \ # lte-simulators $config_libconfig_shlib \ @@ -770,7 +752,7 @@ function main() { simlist="secu_knas_encrypt_eia1 secu_kenb aes128_ctr_encrypt aes128_ctr_decrypt secu_knas_encrypt_eea2 secu_knas secu_knas_encrypt_eea1 kdf aes128_cmac_encrypt secu_knas_encrypt_eia2" for f in $simlist ; do compilations \ - phy_simulators test_$f \ + ran_build test_$f \ test_$f $dbin/test_$f.$REL done fi diff --git a/cmake_targets/install_external_packages.ubuntu20 b/cmake_targets/install_external_packages.ubuntu20 index f0314ca575eb32faf6776aa3027b58b8f2f2e6fd..e58f5c9bb16ec52c5ede52a01a0eda26f402fe72 100755 --- a/cmake_targets/install_external_packages.ubuntu20 +++ b/cmake_targets/install_external_packages.ubuntu20 @@ -24,6 +24,7 @@ # authors Laurent Thomas # ####################################### + if [ ! -f /etc/os-release ]; then echo "No /etc/os-release file found. You're likely on an unsupported distro." exit 1 @@ -134,7 +135,6 @@ clean_all_files() { rm -rf "$dir"/ran_build/build rm -rf "$dir"/ran_build_noLOG/build rm -rf "$dir"/lte-simulators/build - rm -rf "$dir"/phy_simulators/build rm -rf "$dir"/nas_sim_tools/build rm -rf "$dir"/oaisim_build_oai/build rm -rf "$dir"/oaisim_build_oai/CMakeLists.txt @@ -452,17 +452,6 @@ install_asn1c_from_source(){ ) > "$asn1_install_log" 2>&1 } -################################################# -# 2. compile -################################################ - -install_nas_tools() { - echo_success "generate .ue_emm.nvram .ue.nvram" - ./nvram --gen -c "$1" -o "$2" - ./usim --gen -c "$1" -o "$2" -} - - ################################ # set_openair_env ############################### @@ -483,7 +472,7 @@ if ! check_supported_distribution; then echo_error "Your distribution $(get_distribution_release) is not supported by oai !" exit 1 fi - +set_openair_env echo_info "Installing packages" check_install_ubuntu_packages diff --git a/cmake_targets/nas_sim_tools/CMakeLists.txt b/cmake_targets/nas_sim_tools/CMakeLists.txt index 308c71be4c2d3112234d6066191d6d6779aa4610..739e55a33efbadba951af67da2af96f9666815cd 100755 --- a/cmake_targets/nas_sim_tools/CMakeLists.txt +++ b/cmake_targets/nas_sim_tools/CMakeLists.txt @@ -15,6 +15,7 @@ set(CMAKE_C_FLAGS set(OPENAIR_DIR $ENV{OPENAIR_DIR}) set(OPENAIR3_DIR $ENV{OPENAIR_DIR}/openair3) include_directories (${OPENAIR_DIR}/openair2/COMMON) +include_directories (${OPENAIR_DIR}) set(CONF2UEDATA_LIB_SRC ${OPENAIR_DIR}/openair3/NAS/TOOLS/conf_emm.c diff --git a/cmake_targets/phy_simulators b/cmake_targets/phy_simulators new file mode 120000 index 0000000000000000000000000000000000000000..2a12e92f3e9e3938cd869184ab1b8d3f78aa1240 --- /dev/null +++ b/cmake_targets/phy_simulators @@ -0,0 +1 @@ +ran_build/ \ No newline at end of file diff --git a/cmake_targets/phy_simulators/CMakeLists.txt b/cmake_targets/phy_simulators/CMakeLists.txt deleted file mode 100755 index f8c659959f36a6558a2cf76f3c8a6ac1676a9be0..0000000000000000000000000000000000000000 --- a/cmake_targets/phy_simulators/CMakeLists.txt +++ /dev/null @@ -1,21 +0,0 @@ -cmake_minimum_required(VERSION 2.8) -project (OpenAirInterface) -set ( CMAKE_BUILD_TYPE ) -set ( CFLAGS_PROCESSOR_USER "" ) -set ( UE_EXPANSION False ) -set ( PRE_SCD_THREAD False ) -set ( ENABLE_VCD_FIFO False ) -set ( RF_BOARD "None") -set ( TRANSP_PRO "None") -set ( PACKAGE_NAME "") -set ( DEADLINE_SCHEDULER "False" ) -set ( CPU_AFFINITY "False" ) -set ( T_TRACER True ) -set ( UE_AUTOTEST_TRACE False ) -set ( UE_DEBUG_TRACE False ) -set ( UE_TIMING_TRACE False ) -set ( USRP_REC_PLAY False ) -set ( SKIP_SHARED_LIB_FLAG False ) -set ( PHYSIM True) -set ( RU 0) -include(${CMAKE_CURRENT_SOURCE_DIR}/../CMakeLists.txt) diff --git a/cmake_targets/tools/build_helper b/cmake_targets/tools/build_helper index 06f32183b7feb3a9b9d1da3c56d78a3100354a92..ec5de6a0d1b4272afafefd37d1a177338e81b95c 100755 --- a/cmake_targets/tools/build_helper +++ b/cmake_targets/tools/build_helper @@ -168,7 +168,7 @@ clean_all_files() { rm -rf $dir/log $OPENAIR_DIR/targets/bin/* rm -rf $dir/ran_build $dir/ran_build_noLOG rm -rf $dir/lte-simulators/build - rm -rf $dir/phy_simulators/build $dir/nas_sim_tools/build + rm -rf $dir/nas_sim_tools/build rm -rf $dir/oaisim_build_oai/build $dir/oaisim_build_oai/CMakeLists.txt rm -rf $dir/autotests/bin $dir/autotests/log $dir/autotests/*/build } @@ -756,6 +756,7 @@ check_install_oai_software() { libidn11-dev \ libmysqlclient-dev \ libpython2.7-dev \ + libreadline-dev \ libsctp1 \ libsctp-dev \ libssl-dev \ @@ -842,6 +843,7 @@ check_install_oai_software() { patch \ psmisc \ python \ + readline-devel \ subversion \ xmlstarlet \ python-pip \ @@ -892,20 +894,10 @@ install_asn1c_from_source(){ ################################################ install_nas_tools() { - if [ ! -f .ue.nvram0 ]; then - echo_success "generate .ue_emm.nvram .ue.nvram" - ./nvram --gen -c $1 -o $2 - else - [ ./nvram -nt .ue.nvram0 -o ./nvram -nt .ue_emm.nvram0 ] && ./nvram --gen -c $1 -o $2 - fi - - if [ ! -f .usim.nvram0 ]; then - echo_success "generate .usim.nvram" - ./usim --gen -c $1 -o $2 - else - [ ./usim -nt .usim.nvram0 ] && ./usim --gen -c $1 -o $2 - fi - + echo_success "generate .ue_emm.nvram .ue.nvram" + ./nvram --gen -c $1 -o $2 > "$3" + echo_success "generate .usim.nvram" + ./usim --gen -c $1 -o $2 >> "$3" } diff --git a/common/config/config_load_configmodule.c b/common/config/config_load_configmodule.c index 740c6e240bc77c61c99fbc08982d83ec30ba3fcd..773692a82a05b53f1419b1418dffdb9acf54f04f 100644 --- a/common/config/config_load_configmodule.c +++ b/common/config/config_load_configmodule.c @@ -182,8 +182,8 @@ int config_cmdlineonly_get(paramdef_t *cfgoptions,int numoptions, char *prefix ) } configmodule_interface_t *load_configmodule(int argc, - char **argv, - uint32_t initflags) + char **argv, + uint32_t initflags) { char *cfgparam=NULL; char *modeparams=NULL; @@ -194,6 +194,11 @@ configmodule_interface_t *load_configmodule(int argc, int i; int OoptIdx=-1; + printf("CMDLINE: "); + for (int i=0; i<argc; i++) + printf("\"%s\" ", argv[i]); + printf("\n"); + /* first parse the command line to look for the -O option */ for (i = 0; i<argc; i++) { if (strlen(argv[i]) < 2) @@ -219,11 +224,9 @@ configmodule_interface_t *load_configmodule(int argc, cfgparam = getenv("OAI_CONFIGMODULE"); } - /* default different for UE and softmodem because UE doesn't use config file*/ + /* default different for UE and softmodem because UE may run without config file */ /* and -O option is not mandatory for UE */ /* phy simulators behave as UE */ - /* test of exec name would better be replaced by a parameter to the l */ - /* oad_configmodule function */ if (cfgparam == NULL) { tmpflags = tmpflags | CONFIG_NOOOPT; @@ -249,9 +252,14 @@ configmodule_interface_t *load_configmodule(int argc, } cfgptr = calloc(sizeof(configmodule_interface_t),1); - cfgptr->argv_info = calloc(sizeof(int32_t), argc); + /* argv_info is used to memorize command line options which have been recognized */ + /* and to detect unrecognized command line options which might have been specified */ + cfgptr->argv_info = calloc(sizeof(int32_t), argc+10); + /* argv[0] is the exec name, always Ok */ cfgptr->argv_info[0] |= CONFIG_CMDLINEOPT_PROCESSED; + /* when OoptIdx is >0, -O option has been detected at position OoptIdx + * we must memorize arv[OoptIdx is Ok */ if (OoptIdx >= 0) { cfgptr->argv_info[OoptIdx] |= CONFIG_CMDLINEOPT_PROCESSED; cfgptr->argv_info[OoptIdx+1] |= CONFIG_CMDLINEOPT_PROCESSED; diff --git a/common/config/libconfig/config_libconfig.c b/common/config/libconfig/config_libconfig.c index 17266246f0c24e9b9178ebb62171ed5ff3dd0fc6..48893fb5bed3d313413e43959eceb4f3f3c82ba7 100644 --- a/common/config/libconfig/config_libconfig.c +++ b/common/config/libconfig/config_libconfig.c @@ -122,7 +122,7 @@ int config_libconfig_get(paramdef_t *cfgoptions,int numoptions, char *prefix ) { switch(cfgoptions[i].type) { case TYPE_STRING: - if ( config_lookup_string(&(libconfig_privdata.cfg),cfgpath, (const char **)&str)) { + if ( config_lookup_string(&(libconfig_privdata.cfg), cfgpath, (const char**)&str)) { if ( cfgoptions[i].numelt > 0 && str != NULL && strlen(str) >= cfgoptions[i].numelt ) { fprintf(stderr,"[LIBCONFIG] %s: %s exceeds maximum length of %i bytes, value truncated\n", cfgpath,str,cfgoptions[i].numelt); diff --git a/common/utils/LOG/DOC/addconsoletrace.md b/common/utils/LOG/DOC/addconsoletrace.md index 9ab90cf12009e8de2bc2a5885f34dd67c4708295..d5ede8c57de08b0c5eb8f61a2110601f6c5de886 100644 --- a/common/utils/LOG/DOC/addconsoletrace.md +++ b/common/utils/LOG/DOC/addconsoletrace.md @@ -3,6 +3,7 @@ ```C LOG_E(<component>,<format>,<argument>,...) LOG_W(<component>,<format>,<argument>,...) +LOG_A(<component>,<format>,<argument>,...) LOG_I(<component>,<format>,<argument>,...) LOG_D(<component>,<format>,<argument>,...) LOG_T(<component>,<format>,<argument>,...) @@ -14,9 +15,10 @@ these macros are used in place of the printf C function. The additionnal ***comp |:---------|:---------------|:---------------|----------------:| | LOG_E | E | 0 | error | | LOG_W | W | 1 | warning | -| LOG_I | I | 2 | informational | -| LOG_D | D | 3 | debug | -| LOG_T | T | 4 | trace | +| LOG_A | A | 2 | analysis | +| LOG_I | I | 3 | informational | +| LOG_D | D | 4 | debug | +| LOG_T | T | 5 | trace | component list is defined as an `enum` in [log.h](https://gitlab.eurecom.fr/oai/openairinterface5g/blob/develop/common/utils/LOG/log.h). A new component can be defined by adding an item in this type, it must also be defined in the T tracer [T_messages.txt ](https://gitlab.eurecom.fr/oai/openairinterface5g/blob/develop/common/utils/T/T_messages.txt). diff --git a/common/utils/LOG/DOC/log.md b/common/utils/LOG/DOC/log.md index 4b3e5981e1da3b4205bdc7f126fd92773d65730f..4d97e3845d77f533033512ec4a13660392d3ca69 100644 --- a/common/utils/LOG/DOC/log.md +++ b/common/utils/LOG/DOC/log.md @@ -8,7 +8,7 @@ By default, this facility is included at build-time and activated at run-time. T ```bash /build_oai --disable-T-Tracer ``` -- To use the the T-Tracer instead of the console logging facility, use the command line option *T_stdout*. *T_stdout* is a boolean option, which, when set to 0 (false) disable the console logging facility. All stdout messages are then sent to the T-Tracer. +- To use the the T-Tracer, use the command line option *T_stdout*. When set to 0, it disables the console logging facility. All stdout messages are then sent to the T-Tracer. When set to 1 (the default), the logs are output to the linux console and no T trace is generated. When set to 2 both console logging and T traces are activated. ## Documentation diff --git a/common/utils/LOG/DOC/rtusage.md b/common/utils/LOG/DOC/rtusage.md index 445f335725c57fcc3675b9df0a608b8e2f3cab90..041c29e688ecea97e84b99e97b27e6e018bb76d2 100644 --- a/common/utils/LOG/DOC/rtusage.md +++ b/common/utils/LOG/DOC/rtusage.md @@ -7,9 +7,9 @@ All logging facility parameters are defined in the log_config section. Some para | name | type | default | description | |:---:|:---:|:---:|:----| -| `global_log_level` | `pre-defined string of char` | `info` | Allows printing of messages up to the specified level. Available levels, from lower to higher are `error`,`warn`,`info`,`debug`,`trace` | +| `global_log_level` | `pre-defined string of char` | `info` | Allows printing of messages up to the specified level. Available levels, from lower to higher are `error`,`warn`,`analysis`,`info`,`debug`,`trace` | | `global_log_online` | `boolean` | 1 (=true) | If false, all console messages are discarded, whatever their level | -| `global_log_options` | `list of pre-defined string of char` | | 3 options can be specified to trigger the information added in the header of the message: `nocolor`, disable color usage in log messages, usefull when redirecting logs to a file, where escape sequences used for color selection can be annoying, `level`, add a one letter level id in the message header (T,D,I,W,E for trace, debug, info, warning, error),`thread`, add the thread name in the message header| +| `global_log_options` | `list of pre-defined string of char` | | 5 options can be specified to trigger the information added in the header of the message: `nocolor`, disable color usage in log messages, usefull when redirecting logs to a file, where escape sequences used for color selection can be annoying, `level`, add a one letter level id in the message header (T,D,I,A,W,E for trace, debug, info, analysis, warning, error),`thread`, add the thread name in the message header, `thread_id`, adds the thread ID in the message header, `function`, adds the function name, `line_num`, adds the line number, `time` adds the time since process starts| ### Component specific parameters | name | type | default | description | diff --git a/common/utils/LOG/log.c b/common/utils/LOG/log.c index d0a53a755b27ca807f5df975aa0f9f5c597446a0..29e4f718c699e90998225159b1c0a1a4890e8114 100644 --- a/common/utils/LOG/log.c +++ b/common/utils/LOG/log.c @@ -43,6 +43,8 @@ #include <string.h> #include <linux/prctl.h> #include "common/config/config_userapi.h" +#include <time.h> +#include <sys/time.h> // main log variables @@ -63,6 +65,7 @@ char logmem_filename[1024] = {0}; mapping log_level_names[] = { {"error", OAILOG_ERR}, {"warn", OAILOG_WARNING}, + {"analysis", OAILOG_ANALYSIS}, {"info", OAILOG_INFO}, {"debug", OAILOG_DEBUG}, {"trace", OAILOG_TRACE}, @@ -73,14 +76,19 @@ mapping log_options[] = { {"nocolor", FLAG_NOCOLOR }, {"level", FLAG_LEVEL }, {"thread", FLAG_THREAD }, + {"line_num", FLAG_FILE_LINE }, + {"function", FLAG_FUNCT}, + {"time", FLAG_TIME}, + {"thread_id", FLAG_THREAD_ID}, {NULL,-1} }; mapping log_maskmap[] = LOG_MASKMAP_INIT; -char *log_level_highlight_start[] = {LOG_RED, LOG_ORANGE, "", LOG_BLUE, LOG_CYBL}; /*!< \brief Optional start-format strings for highlighting */ -char *log_level_highlight_end[] = {LOG_RESET,LOG_RESET,LOG_RESET, LOG_RESET,LOG_RESET}; /*!< \brief Optional end-format strings for highlighting */ +char *log_level_highlight_start[] = {LOG_RED, LOG_ORANGE, LOG_GREEN, "", LOG_BLUE, LOG_CYBL}; /*!< \brief Optional start-format strings for highlighting */ +char *log_level_highlight_end[] = {LOG_RESET, LOG_RESET, LOG_RESET, LOG_RESET, LOG_RESET, LOG_RESET}; /*!< \brief Optional end-format strings for highlighting */ +static void log_output_memory(log_component_t *c, const char *file, const char *func, int line, int comp, int level, const char* format,va_list args); int write_file_matlab(const char *fname, @@ -476,6 +484,8 @@ int logInit (void) register_log_component("NR_MAC","log",NR_MAC); register_log_component("NR_PHY","log",NR_PHY); register_log_component("NGAP","",NGAP); + register_log_component("ITTI","log",ITTI); + register_log_component("UTIL","log",UTIL); for (int i=0 ; log_level_names[i].name != NULL ; i++) g_log->level2string[i] = toupper(log_level_names[i].name[0]); // uppercased first letter of level name @@ -493,84 +503,105 @@ int logInit (void) return 0; } - -char *log_getthreadname(char *threadname, - int bufsize) +#include <sys/syscall.h> +static inline int log_header(log_component_t *c, + char *log_buffer, + int buffsize, + const char *file, + const char *func, + int line, + int level) { - int rt = pthread_getname_np(pthread_self(), threadname,bufsize) ; + int flag= g_log->flag | c->flag; + + char threadname[64]; + if (flag & FLAG_THREAD ) { + threadname[0]='{'; + if (pthread_getname_np(pthread_self(), threadname + 1, sizeof(threadname) - 3) != 0) + strcpy(threadname+1, "?thread?"); + strcat(threadname,"} "); + } else { + threadname[0]=0; + } - if (rt == 0) { - return threadname; + char l[32]; + if (flag & FLAG_FILE_LINE && flag & FLAG_FUNCT ) + snprintf(l, sizeof l, "(%s:%d) ", func, line); + else if (flag & FLAG_FILE_LINE) + snprintf(l, sizeof l, "(%d) ", line); + else if (flag & FLAG_FUNCT) + snprintf(l, sizeof l, "(%s) ", func); + else + l[0] = 0; + + char timeString[32]; + if ( flag & FLAG_TIME ) { + struct timespec t; + if (clock_gettime(CLOCK_MONOTONIC, &t) == -1) + abort(); + snprintf(timeString, sizeof(timeString), "%lu.%06lu ", + t.tv_sec, + t.tv_nsec / 1000); } else { - return "thread?"; + timeString[0] = 0; } -} -static int log_header(char *log_buffer, - int buffsize, - int comp, - int level, - const char *format) -{ - char threadname[PR_SET_NAME]; - return snprintf(log_buffer, buffsize, "%s%s[%s]%c %s %s%s", - log_level_highlight_end[level], - ( (g_log->flag & FLAG_NOCOLOR)?"":log_level_highlight_start[level]), - g_log->log_component[comp].name, - ( (g_log->flag & FLAG_LEVEL)?g_log->level2string[level]:' '), - ( (g_log->flag & FLAG_THREAD)?log_getthreadname(threadname,PR_SET_NAME+1):""), - format, - log_level_highlight_end[level]); + char threadIdString[32]; + if (flag & FLAG_THREAD_ID) { + snprintf(threadIdString, sizeof(threadIdString), "%08lx ", syscall(__NR_gettid)); + } else { + threadIdString[0] = 0; + } + return snprintf(log_buffer, buffsize, "%s%s%s[%s] %c %s%s", + flag & FLAG_NOCOLOR ? "" : log_level_highlight_start[level], + timeString, + threadIdString, + c->name, + flag & FLAG_LEVEL ? g_log->level2string[level] : ' ', + l, + threadname + ); } void logRecord_mt(const char *file, - const char *func, - int line, - int comp, - int level, - const char *format, - ... ) + const char *func, + int line, + int comp, + int level, + const char *format, + ... ) { - char log_buffer[MAX_LOG_TOTAL]= {0}; + log_component_t *c = &g_log->log_component[comp]; va_list args; va_start(args,format); - if (log_mem_flag == 1) { - log_output_memory(file,func,line,comp,level,format,args); - } else { - log_header(log_buffer,MAX_LOG_TOTAL,comp,level,format); - g_log->log_component[comp].vprint(g_log->log_component[comp].stream,log_buffer,args); - fflush(g_log->log_component[comp].stream); - } + log_output_memory(c, file,func,line,comp,level,format,args); va_end(args); } void vlogRecord_mt(const char *file, - const char *func, - int line, - int comp, - int level, - const char *format, - va_list args ) + const char *func, + int line, + int comp, + int level, + const char *format, + va_list args ) { - char log_buffer[MAX_LOG_TOTAL]; - if (log_mem_flag == 1) { - log_output_memory(file,func,line,comp,level, format,args); - } else { - log_header(log_buffer,MAX_LOG_TOTAL,comp, level,format); - g_log->log_component[comp].vprint(g_log->log_component[comp].stream,log_buffer, args); - } + log_component_t *c = &g_log->log_component[comp]; + log_output_memory(c, file,func,line,comp,level, format,args); } void log_dump(int component, - void *buffer, - int buffsize, - int datatype, - const char *format, - ... ) + void *buffer, + int buffsize, + int datatype, + const char *format, + ... ) { va_list args; char *wbuf; - + log_component_t *c = &g_log->log_component[component]; + int flag= g_log->flag | c->flag; + switch(datatype) { case LOG_DUMP_DOUBLE: wbuf=malloc((buffsize * 10) + 64 + MAX_LOG_TOTAL); @@ -584,9 +615,8 @@ void log_dump(int component, if (wbuf != NULL) { va_start(args, format); - int pos=log_header(wbuf,MAX_LOG_TOTAL,component, OAILOG_INFO,""); - int pos2=vsprintf(wbuf+pos,format, args); - pos=pos+pos2; + int pos=log_header(c, wbuf,MAX_LOG_TOTAL,"noFile","noFunc",0, OAILOG_INFO); + pos+=vsprintf(wbuf+pos,format, args); va_end(args); for (int i=0; i<buffsize; i++) { @@ -601,9 +631,11 @@ void log_dump(int component, break; } } - - sprintf(wbuf+pos,"\n"); - g_log->log_component[component].print(g_log->log_component[component].stream,wbuf); + if ( flag & FLAG_NOCOLOR ) + sprintf(wbuf+pos,"\n"); + else + sprintf(wbuf+pos,"%s\n",log_level_highlight_end[OAILOG_INFO]); + c->print(c->stream,wbuf); free(wbuf); } } @@ -801,15 +833,19 @@ void flush_mem_to_file(void) } } -char logmem_log_level[NUM_LOG_LEVEL]={'E','W','I','D','T'}; +const char logmem_log_level[NUM_LOG_LEVEL] = { + [OAILOG_ERR] = 'E', + [OAILOG_WARNING] = 'W', + [OAILOG_ANALYSIS] = 'A', + [OAILOG_INFO] = 'I', + [OAILOG_DEBUG] = 'D', + [OAILOG_TRACE] = 'T', +}; -void log_output_memory(const char *file, const char *func, int line, int comp, int level, const char* format,va_list args) +static void log_output_memory(log_component_t *c, const char *file, const char *func, int line, int comp, int level, const char* format,va_list args) { //logRecord_mt(file,func,line, pthread_self(), comp, level, format, ##args) int len = 0; - log_component_t *c; - char *log_start; - char *log_end; /* The main difference with the version above is the use of this local log_buffer. * The other difference is the return value of snprintf which was not used * correctly. It was not a big problem because in practice MAX_LOG_TOTAL is @@ -817,92 +853,37 @@ void log_output_memory(const char *file, const char *func, int line, int comp, i */ char log_buffer[MAX_LOG_TOTAL]; - /* for no gcc warnings */ - (void)log_start; - (void)log_end; - - - c = &g_log->log_component[comp]; - - //VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_LOG_RECORD, VCD_FUNCTION_IN); - // make sure that for log trace the extra info is only printed once, reset when the level changes - if (level == OAILOG_TRACE) { - log_start = log_buffer; - len = vsnprintf(log_buffer, MAX_LOG_TOTAL, format, args); - if (len > MAX_LOG_TOTAL) len = MAX_LOG_TOTAL; - log_end = log_buffer + len; - } else { - if ( (g_log->flag & 0x001) || (c->flag & 0x001) ) { - len += snprintf(&log_buffer[len], MAX_LOG_TOTAL - len, "%s", - log_level_highlight_start[level]); - if (len > MAX_LOG_TOTAL) len = MAX_LOG_TOTAL; - } - - log_start = log_buffer + len; - -// if ( (g_log->flag & 0x004) || (c->flag & 0x004) ) { - len += snprintf(&log_buffer[len], MAX_LOG_TOTAL - len, "[%s]", - g_log->log_component[comp].name); - if (len > MAX_LOG_TOTAL) len = MAX_LOG_TOTAL; -// } - - if ( (level >= OAILOG_ERR) && (level <= OAILOG_TRACE) ) { - len += snprintf(&log_buffer[len], MAX_LOG_TOTAL - len, "[%c]", - logmem_log_level[level]); - if (len > MAX_LOG_TOTAL) len = MAX_LOG_TOTAL; - } - - if ( (g_log->flag & FLAG_THREAD) || (c->flag & FLAG_THREAD) ) { -# define THREAD_NAME_LEN 128 - char threadname[THREAD_NAME_LEN]; - if (pthread_getname_np(pthread_self(), threadname, THREAD_NAME_LEN) != 0) - { - perror("pthread_getname_np : "); - } else { - len += snprintf(&log_buffer[len], MAX_LOG_TOTAL - len, "[%s]", threadname); - if (len > MAX_LOG_TOTAL) len = MAX_LOG_TOTAL; + if (level < OAILOG_TRACE) { + int n = log_header(c, log_buffer+len, MAX_LOG_TOTAL, file, func, line, level); + if (n > 0) { + len += n; + if (len > MAX_LOG_TOTAL) { + len = MAX_LOG_TOTAL; } -# undef THREAD_NAME_LEN } - - if ( (g_log->flag & FLAG_FUNCT) || (c->flag & FLAG_FUNCT) ) { - len += snprintf(&log_buffer[len], MAX_LOG_TOTAL - len, "[%s] ", - func); - if (len > MAX_LOG_TOTAL) len = MAX_LOG_TOTAL; - } - - if ( (g_log->flag & FLAG_FILE_LINE) || (c->flag & FLAG_FILE_LINE) ) { - len += snprintf(&log_buffer[len], MAX_LOG_TOTAL - len, "[%s:%d]", - file, line); - if (len > MAX_LOG_TOTAL) len = MAX_LOG_TOTAL; + } + int n = vsnprintf(log_buffer+len, MAX_LOG_TOTAL-len, format, args); + if (n > 0) { + len += n; + if (len > MAX_LOG_TOTAL) { + len = MAX_LOG_TOTAL; } - -/* len += snprintf(&log_buffer[len], MAX_LOG_TOTAL - len, "[%08lx]", thread_id); - if (len > MAX_LOG_TOTAL) len = MAX_LOG_TOTAL; - - struct timeval gettime; - gettimeofday(&gettime,NULL); - len += snprintf(&log_buffer[len], MAX_LOG_TOTAL - len, "[%ld.%06ld]", gettime.tv_sec, gettime.tv_usec); - if (len > MAX_LOG_TOTAL) len = MAX_LOG_TOTAL; -*/ - if ( (g_log->flag & FLAG_NOCOLOR) || (c->flag & FLAG_NOCOLOR) ) { - len += snprintf(&log_buffer[len], MAX_LOG_TOTAL - len, "%s", - log_level_highlight_end[level]); - if (len > MAX_LOG_TOTAL) len = MAX_LOG_TOTAL; + } + if ( !((g_log->flag | c->flag) & FLAG_NOCOLOR) ) { + int n = snprintf(log_buffer+len, MAX_LOG_TOTAL-len, "%s", log_level_highlight_end[level]); + if (n > 0) { + len += n; + if (len > MAX_LOG_TOTAL) { + len = MAX_LOG_TOTAL; + } } - - len += vsnprintf(&log_buffer[len], MAX_LOG_TOTAL - len, format, args); - if (len > MAX_LOG_TOTAL) len = MAX_LOG_TOTAL; - log_end = log_buffer + len; } - //va_end(args); - // OAI printf compatibility - if(log_mem_flag==1){ - if(log_mem_d[log_mem_side].enable_flag==1){ - int temp_index; + if(log_mem_flag==1){ + if(log_mem_d[log_mem_side].enable_flag==1){ + int temp_index; temp_index=log_mem_d[log_mem_side].buf_index; if(temp_index+len+1 < LOG_MEM_SIZE){ log_mem_d[log_mem_side].buf_index+=len; @@ -933,9 +914,10 @@ void log_output_memory(const char *file, const char *func, int line, int comp, i } } } - }else{ - fwrite(log_buffer, len, 1, stdout); - } + }else{ + AssertFatal(len >= 0 && len <= MAX_LOG_TOTAL, "Bad len %d\n", len); + if (write(fileno(c->stream), log_buffer, len)) {}; + } } int logInit_log_mem (void) diff --git a/common/utils/LOG/log.h b/common/utils/LOG/log.h index fa95d5a6fee9436755a6c42207cf1a598985742b..46c73427c183910010233a1c18fbc8590cefe4cf 100644 --- a/common/utils/LOG/log.h +++ b/common/utils/LOG/log.h @@ -54,6 +54,12 @@ #include "T.h" #include <common/utils/utils.h> /*----------------------------------------------------------------------------*/ +#include <assert.h> +#ifdef NDEBUG +#warning assert is disabled +#endif +#define NUM_ELEMENTS(ARRAY) (sizeof(ARRAY) / sizeof(ARRAY[0])) +#define CHECK_INDEX(ARRAY, INDEX) assert((INDEX) < NUM_ELEMENTS(ARRAY)) #ifdef __cplusplus extern "C" { @@ -84,11 +90,12 @@ extern "C" { # define OAILOG_DISABLE -1 /*!< \brief disable all LOG messages, cannot be used in LOG macros, use only in LOG module */ # define OAILOG_ERR 0 /*!< \brief critical error conditions, impact on "must have" functionalities */ # define OAILOG_WARNING 1 /*!< \brief warning conditions, shouldn't happen but doesn't impact "must have" functionalities */ -# define OAILOG_INFO 2 /*!< \brief informational messages most people don't need, shouldn't impact real-time behavior */ -# define OAILOG_DEBUG 3 /*!< \brief first level debug-level messages, for developers, may impact real-time behavior */ -# define OAILOG_TRACE 4 /*!< \brief second level debug-level messages, for developers, likely impact real-time behavior*/ +# define OAILOG_ANALYSIS 2 /*!< \brief informational messages most people don't need, shouldn't impact real-time behavior */ +# define OAILOG_INFO 3 /*!< \brief informational messages most people don't need, shouldn't impact real-time behavior */ +# define OAILOG_DEBUG 4 /*!< \brief first level debug-level messages, for developers, may impact real-time behavior */ +# define OAILOG_TRACE 5 /*!< \brief second level debug-level messages, for developers, likely impact real-time behavior*/ -#define NUM_LOG_LEVEL 5 /*!< \brief the number of message levels users have with LOG (OAILOG_DISABLE is not available to user as a level, so it is not included)*/ +#define NUM_LOG_LEVEL 6 /*!< \brief the number of message levels users have with LOG (OAILOG_DISABLE is not available to user as a level, so it is not included)*/ /* @}*/ @@ -121,6 +128,7 @@ extern "C" { #define FLAG_FUNCT 0x0020 #define FLAG_FILE_LINE 0x0040 #define FLAG_TIME 0x0100 +#define FLAG_THREAD_ID 0x0200 #define FLAG_INITIALIZED 0x8000 #define SET_LOG_OPTION(O) g_log->flag = (g_log->flag | O) @@ -237,6 +245,8 @@ typedef enum { ASN, NFAPI_VNF, NFAPI_PNF, + ITTI, + UTIL, MAX_LOG_PREDEF_COMPONENTS, } comp_name_t; @@ -315,7 +325,6 @@ int register_log_component(char *name, char *fext, int compidx); #define LOG_MEM_SIZE 100*1024*1024 #define LOG_MEM_FILE "./logmem.log" void flush_mem_to_file(void); -void log_output_memory(const char *file, const char *func, int line, int comp, int level, const char* format,va_list args); int logInit_log_mem(void); void close_log_mem(void); @@ -383,7 +392,7 @@ int32_t write_file_matlab(const char *fname, const char *vname, void *data, int /* optname help paramflags XXXptr defXXXval type numelt */ /*-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------*/ #define LOG_GLOBALPARAMS_DESC { \ - {LOG_CONFIG_STRING_GLOBAL_LOG_LEVEL, "Default log level for all componemts\n", 0, strptr:(char **)&gloglevel, defstrval:log_level_names[2].name, TYPE_STRING, 0}, \ + {LOG_CONFIG_STRING_GLOBAL_LOG_LEVEL, "Default log level for all componemts\n", 0, strptr:(char **)&gloglevel, defstrval:log_level_names[3].name, TYPE_STRING, 0}, \ {LOG_CONFIG_STRING_GLOBAL_LOG_ONLINE, "Default console output option, for all components\n", 0, iptr:&(consolelog), defintval:1, TYPE_INT, 0}, \ {LOG_CONFIG_STRING_GLOBAL_LOG_OPTIONS, LOG_CONFIG_HELP_OPTIONS, 0, strlistptr:NULL, defstrlistval:NULL, TYPE_STRINGLIST, 0} \ } @@ -400,10 +409,12 @@ int32_t write_file_matlab(const char *fname, const char *vname, void *data, int #define LOG_DUMP_DOUBLE 1 // debugging macros #define LOG_F LOG_I /* because LOG_F was originaly to dump a message or buffer but is also used as a regular level...., to dump use LOG_DUMPMSG */ + # if T_TRACER /* per component, level dependent macros */ # define LOG_E(c, x...) do { if (T_stdout) { if( g_log->log_component[c].level >= OAILOG_ERR ) logRecord_mt(__FILE__, __FUNCTION__, __LINE__,c, OAILOG_ERR, x) ;} else { T(T_LEGACY_ ## c ## _ERROR, T_PRINTF(x)) ;}} while (0) # define LOG_W(c, x...) do { if (T_stdout) { if( g_log->log_component[c].level >= OAILOG_WARNING) logRecord_mt(__FILE__, __FUNCTION__, __LINE__,c, OAILOG_WARNING, x) ;} else { T(T_LEGACY_ ## c ## _WARNING, T_PRINTF(x)) ;}} while (0) +# define LOG_A(c, x...) do { if (T_stdout) { if( g_log->log_component[c].level >= OAILOG_ANALYSIS) logRecord_mt(__FILE__, __FUNCTION__, __LINE__,c, OAILOG_ANALYSIS, x) ;} else { T(T_LEGACY_ ## c ## _INFO, T_PRINTF(x)) ;}} while (0) # define LOG_I(c, x...) do { if (T_stdout) { if( g_log->log_component[c].level >= OAILOG_INFO ) logRecord_mt(__FILE__, __FUNCTION__, __LINE__,c, OAILOG_INFO, x) ;} else { T(T_LEGACY_ ## c ## _INFO, T_PRINTF(x)) ;}} while (0) # define LOG_D(c, x...) do { if (T_stdout) { if( g_log->log_component[c].level >= OAILOG_DEBUG ) logRecord_mt(__FILE__, __FUNCTION__, __LINE__,c, OAILOG_DEBUG, x) ;} else { T(T_LEGACY_ ## c ## _DEBUG, T_PRINTF(x)) ;}} while (0) # define LOG_T(c, x...) do { if (T_stdout) { if( g_log->log_component[c].level >= OAILOG_TRACE ) logRecord_mt(__FILE__, __FUNCTION__, __LINE__,c, OAILOG_TRACE, x) ;} else { T(T_LEGACY_ ## c ## _TRACE, T_PRINTF(x)) ;}} while (0) @@ -422,6 +433,7 @@ int32_t write_file_matlab(const char *fname, const char *vname, void *data, int # define LOG_E(c, x...) do { if( g_log->log_component[c].level >= OAILOG_ERR ) logRecord_mt(__FILE__, __FUNCTION__, __LINE__,c, OAILOG_ERR, x) ;} while (0) # define LOG_W(c, x...) do { if( g_log->log_component[c].level >= OAILOG_WARNING) logRecord_mt(__FILE__, __FUNCTION__, __LINE__,c, OAILOG_WARNING, x) ;} while (0) +# define LOG_A(c, x...) do { if( g_log->log_component[c].level >= OAILOG_ANALYSIS) logRecord_mt(__FILE__, __FUNCTION__, __LINE__,c, OAILOG_ANALYSIS, x);} while (0) # define LOG_I(c, x...) do { if( g_log->log_component[c].level >= OAILOG_INFO ) logRecord_mt(__FILE__, __FUNCTION__, __LINE__,c, OAILOG_INFO, x) ;} while (0) # define LOG_D(c, x...) do { if( g_log->log_component[c].level >= OAILOG_DEBUG ) logRecord_mt(__FILE__, __FUNCTION__, __LINE__,c, OAILOG_DEBUG, x) ;} while (0) # define LOG_T(c, x...) do { if( g_log->log_component[c].level >= OAILOG_TRACE ) logRecord_mt(__FILE__, __FUNCTION__, __LINE__,c, OAILOG_TRACE, x) ;} while (0) @@ -436,6 +448,7 @@ int32_t write_file_matlab(const char *fname, const char *vname, void *data, int # define LOG_VAR(A,B) A B # define T_ACTIVE(a) (0) # endif /* T_TRACER */ + /* avoid warnings for variables only used in LOG macro's but set outside debug section */ #define GCC_NOTUSED __attribute__((unused)) #define LOG_USEDINLOG_VAR(A,B) GCC_NOTUSED A B diff --git a/common/utils/T/T.c b/common/utils/T/T.c index 8ee359b77f491518e4aa934851f087bc040175c7..49742bf600795016afb6f168003bcfd2d31137a2 100644 --- a/common/utils/T/T.c +++ b/common/utils/T/T.c @@ -217,6 +217,11 @@ void T_Config_Init(void) { sizeof(ttraceparams) / sizeof(paramdef_t), NULL); - if (T_stdout == 0) + if (T_stdout < 0 || T_stdout > 2) { + printf("fatal error: T_stdout = %d but only values 0, 1, or 2 are allowed\n", T_stdout); + exit(1); + } + + if (T_stdout == 0 || T_stdout == 2) T_init(T_port, 1-T_nowait, T_dont_fork); } diff --git a/common/utils/T/T.h b/common/utils/T/T.h index 626dbafd2586840657e515ca66a6f5ab8776080b..014294505454bd8640fa55525812e6c0dccf543e 100644 --- a/common/utils/T/T.h +++ b/common/utils/T/T.h @@ -100,7 +100,7 @@ extern int T_stdout; 20,19,18,17,16,15,14,13,12,11,10,9,8,7,6,5,4,3,2,1,0)(__VA_ARGS__) #define TN_N(n0,n1,n2,n3,n4,n5,n6,n7,n8,n9,n10,n11,n12,n13,n14,n15,n16,n17,\ n18,n19,n20,n21,n22,n23,n24,n25,n26,n27,n28,n29,n30,n31,n32,n,...) T##n -#define T(...) do { if (T_stdout == 0) TN(__VA_ARGS__); } while (0) +#define T(...) do { if (T_stdout == 0 || T_stdout == 2) TN(__VA_ARGS__); } while (0) /* type used to send arbitrary buffer data */ typedef struct { @@ -607,7 +607,7 @@ extern int *T_active; {"T_port", CONFIG_HLP_TPORT, 0, iptr:&T_port, defintval:TTRACER_DEFAULT_PORTNUM, TYPE_INT, 0},\ {"T_nowait", CONFIG_HLP_NOTWAIT, PARAMFLAG_BOOL, iptr:&T_nowait, defintval:0, TYPE_INT, 0},\ {"T_dont_fork", CONFIG_HLP_TNOFORK, PARAMFLAG_BOOL, iptr:&T_dont_fork, defintval:0, TYPE_INT, 0},\ - {"T_stdout", CONFIG_HLP_STDOUT, PARAMFLAG_BOOL, iptr:&T_stdout, defintval:1, TYPE_INT, 0},\ + {"T_stdout", CONFIG_HLP_STDOUT, 0, iptr:&T_stdout, defintval:1, TYPE_INT, 0},\ } diff --git a/common/utils/T/T_messages.txt b/common/utils/T/T_messages.txt index 192bf8cc371ff0da11ddbfe3304d8ebf1407320a..a8b919e5252459e007c696744515a42ef7ac7e9c 100644 --- a/common/utils/T/T_messages.txt +++ b/common/utils/T/T_messages.txt @@ -93,6 +93,14 @@ ID = GNB_PHY_PUCCH_PUSCH_IQ DESC = gNodeB input data in the frequency domain for a slot where some PUCCH or PUSCH detection was done GROUP = ALL:PHY:GRAPHIC:HEAVY:GNB FORMAT = int,frame : int,slot : buffer,rxdataF +ID = GNB_PHY_UL_FREQ_CHANNEL_ESTIMATE + DESC = gNodeB channel estimation in the frequency domain + GROUP = ALL:PHY:GRAPHIC:HEAVY:GNB + FORMAT = int,gNB_ID : int,rnti : int,frame : int,subframe : int,antenna : buffer,chest_t +ID = GNB_PHY_UL_TIME_CHANNEL_ESTIMATE + DESC = gNodeB channel estimation in the time domain + GROUP = ALL:PHY:GRAPHIC:HEAVY:GNB + FORMAT = int,gNB_ID : int,rnti : int,frame : int,subframe : int,antenna : buffer,chest_t ID = GNB_PHY_PRACH_INPUT_SIGNAL DESC = gNodeB input data in the time domain for slots with PRACH detection GROUP = ALL:PHY:GRAPHIC:HEAVY:GNB @@ -1061,6 +1069,48 @@ ID = LEGACY_NFAPI_PNF_TRACE DESC = NFAPI_PNF legacy logs - trace level GROUP = ALL:LEGACY_NFAPI_PNF:LEGACY_GROUP_TRACE:LEGACY FORMAT = string,log + +ID = LEGACY_ITTI_INFO + DESC = ITTI legacy logs - info level + GROUP = ALL:LEGACY_ITTI:LEGACY_GROUP_INFO:LEGACY + FORMAT = string,log +ID = LEGACY_ITTI_ERROR + DESC = ITTI legacy logs - error level + GROUP = ALL:LEGACY_ITTI:LEGACY_GROUP_ERROR:LEGACY + FORMAT = string,log +ID = LEGACY_ITTI_WARNING + DESC = ITTI legacy logs - warning level + GROUP = ALL:LEGACY_ITTI:LEGACY_GROUP_WARNING:LEGACY + FORMAT = string,log +ID = LEGACY_ITTI_DEBUG + DESC = ITTI legacy logs - debug level + GROUP = ALL:LEGACY_ITTI:LEGACY_GROUP_DEBUG:LEGACY + FORMAT = string,log +ID = LEGACY_ITTI_TRACE + DESC = ITTI legacy logs - trace level + GROUP = ALL:LEGACY_ITTI:LEGACY_GROUP_TRACE:LEGACY + FORMAT = string,log + +ID = LEGACY_UTIL_INFO + DESC = UTIL legacy logs - info level + GROUP = ALL:LEGACY_UTIL:LEGACY_GROUP_INFO:LEGACY + FORMAT = string,log +ID = LEGACY_UTIL_ERROR + DESC = UTIL legacy logs - error level + GROUP = ALL:LEGACY_UTIL:LEGACY_GROUP_ERROR:LEGACY + FORMAT = string,log +ID = LEGACY_UTIL_WARNING + DESC = UTIL legacy logs - warning level + GROUP = ALL:LEGACY_UTIL:LEGACY_GROUP_WARNING:LEGACY + FORMAT = string,log +ID = LEGACY_UTIL_DEBUG + DESC = UTIL legacy logs - debug level + GROUP = ALL:LEGACY_UTIL:LEGACY_GROUP_DEBUG:LEGACY + FORMAT = string,log +ID = LEGACY_UTIL_TRACE + DESC = UTIL legacy logs - trace level + GROUP = ALL:LEGACY_UTIL:LEGACY_GROUP_TRACE:LEGACY + FORMAT = string,log # this is a bad hack but I won't fix (function util_print_hex_octets # in openairinterface5g/openair2/LAYER2/PDCP_v10.1.0/pdcp_util.c # does funky things with the LOG_x macros but we work on the C pre-processor diff --git a/common/utils/T/tracer/gnb.c b/common/utils/T/tracer/gnb.c index 4aaa4898a1fcc7902c189d8732f3a481c9562634..6629a1efd6e39ee26acd0551ef8cb6e53acc0b0b 100644 --- a/common/utils/T/tracer/gnb.c +++ b/common/utils/T/tracer/gnb.c @@ -4,15 +4,28 @@ #include <pthread.h> #include <unistd.h> #include "database.h" +#include "event.h" #include "handler.h" #include "config.h" #include "logger/logger.h" -#include "view/view.h" #include "gui/gui.h" +#include "utils.h" +#include "openair_logo.h" + +int ue_id[65536]; +int next_ue_id; typedef struct { widget *pucch_pusch_iq_plot; + widget *ul_freq_estimate_ue_xy_plot; + widget *ul_time_estimate_ue_xy_plot; + widget *current_ue_label; + widget *current_ue_button; + widget *prev_ue_button; + widget *next_ue_button; logger *pucch_pusch_iq_logger; + logger *ul_freq_estimate_ue_logger; + logger *ul_time_estimate_ue_logger; } gnb_gui; typedef struct { @@ -21,6 +34,7 @@ typedef struct { int nevents; pthread_mutex_t lock; gnb_gui *e; + int ue; /* what UE is displayed in the UE specific views */ void *database; } gnb_data; @@ -69,34 +83,133 @@ static void *gui_thread(void *_g) return NULL; } -static void gnb_main_gui(gnb_gui *e, gui *g, event_handler *h, void *database, - gnb_data *ed) +static void set_current_ue(gui *g, gnb_data *e, int ue) +{ + char s[256]; + + sprintf(s, "[UE %d] ", ue); + label_set_text(g, e->e->current_ue_label, s); + + sprintf(s, "GNB_PHY_PUCCH_PUSCH_IQ [UE %d]", ue); + xy_plot_set_title(g, e->e->pucch_pusch_iq_plot, s); + + sprintf(s, "UL channel estimation in frequency domain [UE %d]", ue); + xy_plot_set_title(g, e->e->ul_freq_estimate_ue_xy_plot, s); + + sprintf(s, "UL channel estimation in time domain [UE %d]", ue); + xy_plot_set_title(g, e->e->ul_time_estimate_ue_xy_plot, s); +} + +void reset_ue_ids(void) +{ + int i; + printf("resetting known UEs\n"); + for (i = 0; i < 65536; i++) ue_id[i] = -1; + ue_id[65535] = 0; + ue_id[65534] = 1; /* HACK: to be removed */ + ue_id[2] = 2; /* this supposes RA RNTI = 2, very openair specific */ + next_ue_id = 0; +} + +static void click(void *private, gui *g, char *notification, widget *w, void *notification_data) +{ + int *d = notification_data; + int button = d[0]; + gnb_data *ed = private; + gnb_gui *e = ed->e; + int ue = ed->ue; + int do_reset = 0; + + if (button != 1) return; + if (w == e->prev_ue_button) { ue--; if (ue < 0) ue = 0; } + if (w == e->next_ue_button) ue++; + if (w == e->current_ue_button) do_reset = 1; + + if (pthread_mutex_lock(&ed->lock)) abort(); + if (do_reset) reset_ue_ids(); + if (ue != ed->ue) { + set_current_ue(g, ed, ue); + ed->ue = ue; + } + if (pthread_mutex_unlock(&ed->lock)) abort(); +} + +static void gnb_main_gui(gnb_gui *e, gui *g, event_handler *h, void *database, gnb_data *ed) { widget *main_window; widget *top_container; widget *line; + widget *col; + widget *logo; widget *w; + widget *w2; logger *l; view *v; - main_window = new_toplevel_window(g, 500, 300, "gNB tracer"); - + main_window = new_toplevel_window(g, 1500, 230, "gNB tracer"); top_container = new_container(g, VERTICAL); widget_add_child(g, main_window, top_container, -1); line = new_container(g, HORIZONTAL); widget_add_child(g, top_container, line, -1); + logo = new_image(g, openair_logo_png, openair_logo_png_len); + + /* logo + prev/next UE buttons */ + col = new_container(g, VERTICAL); + widget_add_child(g, col, logo, -1); + w = new_container(g, HORIZONTAL); + widget_add_child(g, col, w, -1); + w2 = new_label(g, ""); + widget_add_child(g, w, w2, -1); + label_set_clickable(g, w2, 1); + e->current_ue_button = w2; + e->current_ue_label = w2; + w2 = new_label(g, " [prev UE] "); + widget_add_child(g, w, w2, -1); + label_set_clickable(g, w2, 1); + e->prev_ue_button = w2; + w2 = new_label(g, " [next UE] "); + widget_add_child(g, w, w2, -1); + label_set_clickable(g, w2, 1); + e->next_ue_button = w2; + widget_add_child(g, line, col, -1); /* PUCCH/PUSCH IQ data */ - w = new_xy_plot(g, 55, 55, "", 50); + w = new_xy_plot(g, 200, 200, "", 10); e->pucch_pusch_iq_plot = w; widget_add_child(g, line, w, -1); xy_plot_set_range(g, w, -1000, 1000, -1000, 1000); - xy_plot_set_title(g, w, "rxdataF"); l = new_iqlog_full(h, database, "GNB_PHY_PUCCH_PUSCH_IQ", "rxdataF"); v = new_view_xy(300*12*14,10,g,w,new_color(g,"#000"),XY_FORCED_MODE); logger_add_view(l, v); e->pucch_pusch_iq_logger = l; + + /* UL channel estimation in frequency domain */ + w = new_xy_plot(g, 490, 200, "", 50); + e->ul_freq_estimate_ue_xy_plot = w; + widget_add_child(g, line, w, -1); + xy_plot_set_range(g, w, 0, 2048, -10, 80); + l = new_framelog(h, database, "GNB_PHY_UL_FREQ_CHANNEL_ESTIMATE", "subframe", "chest_t"); + framelog_set_update_only_at_sf9(l, 0); + v = new_view_xy(2048, 10, g, w, new_color(g, "#0c0c72"), XY_LOOP_MODE); + logger_add_view(l, v); + e->ul_freq_estimate_ue_logger = l; + + /* UL channel estimation in time domain */ + w = new_xy_plot(g, 490, 200, "", 50); + e->ul_time_estimate_ue_xy_plot = w; + widget_add_child(g, line, w, -1); + xy_plot_set_range(g, w, 0, 2048, -10, 80); + l = new_framelog(h, database, "GNB_PHY_UL_TIME_CHANNEL_ESTIMATE", "subframe", "chest_t"); + framelog_set_update_only_at_sf9(l, 0); + v = new_view_xy(2048, 10, g, w, new_color(g, "#0c0c72"), XY_LOOP_MODE); + logger_add_view(l, v); + e->ul_time_estimate_ue_logger = l; + + set_current_ue(g, ed, ed->ue); + register_notifier(g, "click", e->current_ue_button, click, ed); + register_notifier(g, "click", e->prev_ue_button, click, ed); + register_notifier(g, "click", e->next_ue_button, click, ed); } int main(int n, char **v) @@ -136,7 +249,11 @@ int main(int n, char **v) h = new_handler(database); on_off(database, "GNB_PHY_PUCCH_PUSCH_IQ", is_on, 1); + on_off(database, "GNB_PHY_UL_FREQ_CHANNEL_ESTIMATE", is_on, 1); + on_off(database, "GNB_PHY_UL_TIME_CHANNEL_ESTIMATE", is_on, 1); + gnb_data.ue = 0; + gnb_data.e = ⪚ gnb_data.database = database; gnb_data.socket = -1; gnb_data.is_on = is_on; diff --git a/common/utils/assertions.h b/common/utils/assertions.h index 06d43bdbfa05c26dc08ac292aae9af8dd15a6364..d85dab79a0c744f7d8cda566caa66638a2e9f34b 100644 --- a/common/utils/assertions.h +++ b/common/utils/assertions.h @@ -26,17 +26,10 @@ #include <stdlib.h> #include <inttypes.h> #include <platform_types.h> +#include "backtrace.h" -#if defined(ENB_MODE) -# define display_backtrace() -#else -# include "backtrace.h" -#endif - -void output_log_mem(void); #define _Assert_Exit_ \ fprintf(stderr, "\nExiting execution\n"); \ - display_backtrace(); \ fflush(stdout); \ fflush(stderr); \ abort(); diff --git a/common/utils/backtrace.c b/common/utils/backtrace.c index f61cf0349ac5d9a64fcad36a6b235e9c8071768d..634bb3a834dd381ef708d8acc74a274d1f0a6897 100644 --- a/common/utils/backtrace.c +++ b/common/utils/backtrace.c @@ -28,7 +28,7 @@ #include <signal.h> #include <execinfo.h> -#include "backtrace.h" +#include <common/utils/backtrace.h> /* Obtain a backtrace and print it to stdout. */ void display_backtrace(void) { @@ -49,8 +49,3 @@ void display_backtrace(void) { free(strings); } - -void backtrace_handle_signal(siginfo_t *info) { - display_backtrace(); - //exit(EXIT_FAILURE); -} diff --git a/common/utils/backtrace.h b/common/utils/backtrace.h index 3977d0321c68c6f007edb2e451479f736c00e05c..9aaf7184530d0b8072ce5a34a6553f2bf2056716 100644 --- a/common/utils/backtrace.h +++ b/common/utils/backtrace.h @@ -26,10 +26,7 @@ #ifdef __cplusplus extern "C" { #endif - void display_backtrace(void); - -void backtrace_handle_signal(siginfo_t *info); #ifdef __cplusplus } #endif diff --git a/common/utils/nr/nr_common.c b/common/utils/nr/nr_common.c index a704a66c767ace9d3b6dc0011bf8f6574b149e02..d823fcc1c45ed0e8e413c3f2400e65cd3bcecf6d 100644 --- a/common/utils/nr/nr_common.c +++ b/common/utils/nr/nr_common.c @@ -42,7 +42,7 @@ const char *duplex_mode[]={"FDD","TDD"}; // - N_OFFs for bands from 80 to 89 and band 95 is referred to UL // - Frequencies are expressed in KHz // - col: NR_band ul_min ul_max dl_min dl_max step N_OFFs_DL deltaf_raster -nr_bandentry_t nr_bandtable[] = { +const nr_bandentry_t nr_bandtable[] = { {1, 1920000, 1980000, 2110000, 2170000, 20, 422000, 100}, {2, 1850000, 1910000, 1930000, 1990000, 20, 386000, 100}, {3, 1710000, 1785000, 1805000, 1880000, 20, 361000, 100}, @@ -117,7 +117,7 @@ uint16_t get_band(uint64_t downlink_frequency, int32_t delta_duplex) uint64_t center_freq_diff_khz = 999999999999999999; // 2^64 uint16_t current_band = 0; - for (int ind = 0; ind < nr_bandtable_size; ind++) { + for (int ind = 0; ind < sizeofArray(nr_bandtable); ind++) { if (dl_freq_khz < nr_bandtable[ind].dl_min || dl_freq_khz > nr_bandtable[ind].dl_max) continue; @@ -143,8 +143,6 @@ uint16_t get_band(uint64_t downlink_frequency, int32_t delta_duplex) return current_band; } -const size_t nr_bandtable_size = sizeof(nr_bandtable) / sizeof(nr_bandentry_t); - int NRRIV2BW(int locationAndBandwidth,int N_RB) { int tmp = locationAndBandwidth/N_RB; int tmp2 = locationAndBandwidth%N_RB; @@ -257,6 +255,48 @@ void get_coreset_rballoc(uint8_t *FreqDomainResource,int *n_rb,int *rb_offset) { *n_rb = 6*count; } +int get_nb_periods_per_frame(uint8_t tdd_period) { + + int nb_periods_per_frame; + switch(tdd_period) { + case 0: + nb_periods_per_frame = 20; // 10ms/0p5ms + break; + + case 1: + nb_periods_per_frame = 16; // 10ms/0p625ms + break; + + case 2: + nb_periods_per_frame = 10; // 10ms/1ms + break; + + case 3: + nb_periods_per_frame = 8; // 10ms/1p25ms + break; + + case 4: + nb_periods_per_frame = 5; // 10ms/2ms + break; + + case 5: + nb_periods_per_frame = 4; // 10ms/2p5ms + break; + + case 6: + nb_periods_per_frame = 2; // 10ms/5ms + break; + + case 7: + nb_periods_per_frame = 1; // 10ms/10ms + break; + + default: + AssertFatal(1==0,"Undefined tdd period %d\n", tdd_period); + } + return nb_periods_per_frame; +} + int get_dmrs_port(int nl, uint16_t dmrs_ports) { @@ -276,14 +316,6 @@ int get_dmrs_port(int nl, uint16_t dmrs_ports) { return p; } -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); -} - lte_frame_type_t get_frame_type(uint16_t current_band, uint8_t scs_index) { lte_frame_type_t current_type; @@ -425,31 +457,27 @@ uint16_t config_bandwidth(int mu, int nb_rb, int nr_band) // Returns the corresponding row index of the NR table int get_nr_table_idx(int nr_bandP, uint8_t scs_index) { - int i, j; int scs_khz = 15 << scs_index; int supplementary_bands[] = {29,75,76,80,81,82,83,84,86,89,95}; - size_t s = sizeof(supplementary_bands)/sizeof(supplementary_bands[0]); - - for(j = 0; j < s; j++){ + for(int j = 0; j < sizeofArray(supplementary_bands); j++){ if (nr_bandP == supplementary_bands[j]) AssertFatal(0 == 1, "Band %d is a supplementary band (%d). This is not supported yet.\n", nr_bandP, supplementary_bands[j]); } - AssertFatal(nr_bandP <= nr_bandtable[nr_bandtable_size-1].band, "NR band %d exceeds NR bands table maximum limit %d\n", nr_bandP, nr_bandtable[nr_bandtable_size-1].band); - for (i = 0; i < nr_bandtable_size && nr_bandtable[i].band != nr_bandP; i++); - - // In frequency bands with two deltaFRaster, - // the higher deltaFRaster applies to channels using only the SCS that is equal to or larger than the higher deltaFRaster - // and SSB SCS is equal to the higher deltaFRaster. - while(((i+1)<nr_bandtable_size) && - (nr_bandtable[i+1].band == nr_bandtable[i].band) && - (nr_bandtable[i].deltaf_raster != scs_khz)) { - i++; + int i; + for (i = 0; i < sizeofArray(nr_bandtable); i++) { + if ( nr_bandtable[i].band == nr_bandP && nr_bandtable[i].deltaf_raster == scs_khz ) + break; } - AssertFatal(nr_bandtable[i].band == nr_bandP, "Found band table %d does not correspond to the input one %d\n",nr_bandtable[i].band,nr_bandP); - + if (i == sizeofArray(nr_bandtable)) { + LOG_I(PHY, "not found same deltaf_raster == scs_khz, use only band and last deltaf_raster \n"); + for(i=sizeofArray(nr_bandtable)-1; i >=0; i--) + if ( nr_bandtable[i].band == nr_bandP ) + break; + } + AssertFatal(i > 0 && i < sizeofArray(nr_bandtable), "band is not existing: %d\n",nr_bandP); LOG_D(PHY, "NR band table index %d (Band %d, dl_min %lu, ul_min %lu)\n", i, nr_bandtable[i].band, nr_bandtable[i].dl_min,nr_bandtable[i].ul_min); return i; @@ -472,6 +500,16 @@ int get_subband_size(int NPRB,int size) { } + +// from start symbol index and nb or symbols to symbol occupation bitmap in a slot +uint16_t SL_to_bitmap(int startSymbolIndex, int nrOfSymbols) { + return ((1<<nrOfSymbols)-1)<<startSymbolIndex; +} + +int get_SLIV(uint8_t S, uint8_t L) { + return ( (uint16_t)(((L-1)<=7)? (14*(L-1)+S) : (14*(15-L)+(13-S))) ); +} + void SLIV2SL(int SLIV,int *S,int *L) { int SLIVdiv14 = SLIV/14; diff --git a/common/utils/nr/nr_common.h b/common/utils/nr/nr_common.h index d9f2b0c03a384e3109147e5cf0e536ffda045347..882f99338c3533c785a567adbaafe0db88bf843d 100644 --- a/common/utils/nr/nr_common.h +++ b/common/utils/nr/nr_common.h @@ -48,11 +48,18 @@ typedef struct nr_bandentry_s { uint8_t deltaf_raster; } nr_bandentry_t; -extern const size_t nr_bandtable_size; -extern nr_bandentry_t nr_bandtable[]; +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); +} + + +int get_SLIV(uint8_t S, uint8_t L); void get_coreset_rballoc(uint8_t *FreqDomainResource,int *n_rb,int *rb_offset); -int get_num_dmrs(uint16_t dmrs_mask); uint16_t config_bandwidth(int mu, int nb_rb, int nr_band); int get_nr_table_idx(int nr_bandP, uint8_t scs_index); int32_t get_delta_duplex(int nr_bandP, uint8_t scs_index); @@ -71,6 +78,9 @@ uint32_t nr_get_code_rate(uint8_t Imcs, uint8_t table_idx); int get_subband_size(int NPRB,int size); void SLIV2SL(int SLIV,int *S,int *L); int get_dmrs_port(int nl, uint16_t dmrs_ports); +uint16_t SL_to_bitmap(int startSymbolIndex, int nrOfSymbols); +int get_nb_periods_per_frame(uint8_t tdd_period); +long rrc_get_max_nr_csrs(uint8_t max_rbs, long b_SRS); #define CEILIDIV(a,b) ((a+b-1)/b) #define ROUNDIDIV(a,b) (((a<<1)+b)/(b<<1)) diff --git a/common/utils/ocp_itti/intertask_interface.cpp b/common/utils/ocp_itti/intertask_interface.cpp index 4e5323aec98c85d0c807ad195bbfa6ed4f022c8e..44fae9f78884e9b5d47ce0226bfb76eca6aae7d5 100644 --- a/common/utils/ocp_itti/intertask_interface.cpp +++ b/common/utils/ocp_itti/intertask_interface.cpp @@ -136,12 +136,12 @@ extern "C" { LOG_E(TMR,"Queue for %s task contains %ld messages\n", itti_get_task_name(destination_task_id), s ); if ( s > 50 ) - LOG_I(TMR,"Queue for %s task size: %ld (last message %s)\n",itti_get_task_name(destination_task_id), s+1,ITTI_MSG_NAME(message)); + LOG_I(ITTI,"Queue for %s task size: %ld (last message %s)\n",itti_get_task_name(destination_task_id), s+1,ITTI_MSG_NAME(message)); t->message_queue.insert(t->message_queue.begin(), message); eventfd_t sem_counter = 1; AssertFatal ( sizeof(sem_counter) == write(t->sem_fd, &sem_counter, sizeof(sem_counter)), ""); - LOG_D(TMR,"sent messages id=%d to %s\n",message_id, t->admin.name); + LOG_D(ITTI,"sent messages id=%d to %s\n",message_id, t->admin.name); return 0; } @@ -152,7 +152,7 @@ extern "C" { while ( t->message_queue.size()>0 && t->admin.func != NULL ) { if (t->message_queue.size()>1) - LOG_W(TMR,"queue in no thread mode is %ld\n", t->message_queue.size()); + LOG_W(ITTI,"queue in no thread mode is %ld\n", t->message_queue.size()); pthread_mutex_unlock (&t->queue_cond_lock); t->admin.func(NULL); @@ -208,7 +208,7 @@ extern "C" { message->ittiMsg.timer_has_expired.arg=it->second.timer_arg; if (itti_send_msg_to_task_locked(task_id, it->second.instance, message) < 0) { - LOG_W(TMR,"Failed to send msg TIMER_HAS_EXPIRED to task %u\n", task_id); + LOG_W(ITTI,"Failed to send msg TIMER_HAS_EXPIRED to task %u\n", task_id); free(message); t->timer_map.erase(it); return -1; @@ -233,7 +233,7 @@ extern "C" { epoll_timeout = t->next_timer-current_time; pthread_mutex_unlock(&t->queue_cond_lock); - LOG_D(TMR,"enter blocking wait for %s\n", itti_get_task_name(task_id)); + 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); if ( t->nb_events < 0 && (errno == EINTR || errno == EAGAIN ) ) @@ -243,7 +243,7 @@ extern "C" { AssertFatal (t->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(TMR,"receive on %d descriptors for %s\n", t->nb_events, itti_get_task_name(task_id)); + LOG_D(ITTI,"receive on %d descriptors for %s\n", t->nb_events, itti_get_task_name(task_id)); if (t->nb_events == 0) /* No data to read -> return */ @@ -292,11 +292,11 @@ extern "C" { // in this case, *received_msg is NULL if (t->message_queue.empty()) { *received_msg=NULL; - LOG_D(TMR,"task %s received even from other fd (total fds: %d), returning msg NULL\n",t->admin.name, t->nb_fd_epoll); + LOG_D(ITTI,"task %s received even from other fd (total fds: %d), returning msg NULL\n",t->admin.name, t->nb_fd_epoll); } else { *received_msg=t->message_queue.back(); t->message_queue.pop_back(); - LOG_D(TMR,"task %s received a message\n",t->admin.name); + LOG_D(ITTI,"task %s received a message\n",t->admin.name); } pthread_mutex_unlock (&t->queue_cond_lock); @@ -308,7 +308,7 @@ extern "C" { pthread_mutex_lock(&t->queue_cond_lock); if (!t->message_queue.empty()) { - LOG_D(TMR,"task %s received a message in polling mode\n",t->admin.name); + LOG_D(ITTI,"task %s received a message in polling mode\n",t->admin.name); *received_msg=t->message_queue.back(); t->message_queue.pop_back(); } else @@ -322,7 +322,7 @@ extern "C" { void *args_p) { task_list_t *t=tasks[task_id]; threadCreate (&t->thread, start_routine, args_p, (char *)itti_get_task_name(task_id),-1,OAI_PRIORITY_RT); - LOG_I(TMR,"Created Posix thread %s\n", itti_get_task_name(task_id) ); + LOG_I(ITTI,"Created Posix thread %s\n", itti_get_task_name(task_id) ); return 0; } @@ -344,7 +344,7 @@ extern "C" { tasks = new_tasks; tasks[newQueue]= new task_list_t; pthread_mutex_unlock (&lock_nb_queues); - LOG_I(TMR,"Starting itti queue: %s as task %d\n", taskInfo->name, newQueue); + LOG_I(ITTI,"Starting itti queue: %s as task %d\n", taskInfo->name, newQueue); pthread_mutex_init(&tasks[newQueue]->queue_cond_lock, NULL); memcpy(&tasks[newQueue]->admin, taskInfo, sizeof(task_info_t)); AssertFatal( ( tasks[newQueue]->epoll_fd = epoll_create1(0) ) >=0, ""); @@ -392,7 +392,7 @@ extern "C" { clock_gettime(CLOCK_MONOTONIC, &tp); if (interval_us%1000 != 0) - LOG_W(TMR, "Can't set timer precision below 1ms, rounding it\n"); + LOG_W(ITTI, "Can't set timer precision below 1ms, rounding it\n"); timer.duration = interval_sec*1000+interval_us/1000; timer.timeout= ((uint64_t)tp.tv_sec*1000+tp.tv_nsec/(1000*1000)+timer.duration); @@ -421,7 +421,7 @@ extern "C" { if (ret==1) return 0; else { - LOG_W(TMR, "tried to remove a non existing timer\n"); + LOG_W(ITTI, "tried to remove a non existing timer\n"); return 1; } } @@ -438,9 +438,22 @@ extern "C" { void itti_send_terminate_message(task_id_t task_id) { } + static volatile bool shutting_down; + + static void catch_sigterm(int) { + static const char msg[] = "\n** Caught SIGTERM, shutting down\n"; + __attribute__((unused)) + int unused = write(STDOUT_FILENO, msg, sizeof(msg) - 1); + shutting_down = true; + } + void itti_wait_tasks_end(void) { - while(1) - sleep(24*3600); + shutting_down = false; + signal(SIGTERM, catch_sigterm); + while (! shutting_down) + { + sleep(24 * 3600); + } } void itti_update_lte_time(uint32_t frame, uint8_t slot) {} @@ -455,4 +468,42 @@ extern "C" { int signal_mask(void) { return 0; } + +void log_scheduler(const char* label) +{ + int policy = sched_getscheduler(0); + struct sched_param param; + if (sched_getparam(0, ¶m) == -1) + { + LOG_E(HW, "sched_getparam: %s\n", strerror(errno)); + abort(); + } + + cpu_set_t cpu_set; + if (sched_getaffinity(0, sizeof(cpu_set), &cpu_set) == -1) + { + LOG_E(HW, "sched_getaffinity: %s\n", strerror(errno)); + abort(); + } + int num_cpus = sysconf(_SC_NPROCESSORS_ONLN); + if (num_cpus < 1) + { + LOG_E(HW, "sysconf(_SC_NPROCESSORS_ONLN): %s\n", strerror(errno)); + abort(); + } + char buffer[num_cpus]; + for (int i = 0; i < num_cpus; i++) + { + buffer[i] = CPU_ISSET(i, &cpu_set) ? 'Y' : '-'; + } + + LOG_A(HW, "Scheduler policy=%d priority=%d affinity=[%d]%.*s label=%s\n", + policy, + param.sched_priority, + num_cpus, + num_cpus, + buffer, + label); } +} // extern "C" + diff --git a/common/utils/ocp_itti/intertask_interface.h b/common/utils/ocp_itti/intertask_interface.h index 7c17a6f3b12fe9d060b8fb3a9053d7c922ead83f..3188e5889f0d2b43d47c4a1b0e67c620e7a09c18 100644 --- a/common/utils/ocp_itti/intertask_interface.h +++ b/common/utils/ocp_itti/intertask_interface.h @@ -346,6 +346,8 @@ void *rrc_enb_process_msg(void *); TASK_DEF(TASK_DU_F1, TASK_PRIORITY_MED, 200, NULL, NULL) \ TASK_DEF(TASK_RRC_UE_SIM, TASK_PRIORITY_MED, 200, NULL, NULL) \ TASK_DEF(TASK_RRC_GNB_SIM, TASK_PRIORITY_MED, 200, NULL, NULL) \ + TASK_DEF(TASK_RRC_NSA_UE, TASK_PRIORITY_MED, 200, NULL, NULL) \ + TASK_DEF(TASK_RRC_NSA_NRUE, TASK_PRIORITY_MED, 200, NULL, NULL) \ TASK_DEF(TASK_NAS_NRUE, TASK_PRIORITY_MED, 200, NULL, NULL) \ TASK_DEF(TASK_MAX, TASK_PRIORITY_MED, 200, NULL, NULL) @@ -362,6 +364,8 @@ typedef enum { FOREACH_TASK(TASK_ENUM) } task_id_t; +extern uint16_t ue_idx_standalone; +extern uint16_t node_number; typedef task_id_t thread_id_t; @@ -586,6 +590,7 @@ int timer_remove(long timer_id); int signal_handle(int *end); int signal_mask(void); +void log_scheduler(const char *label); #ifdef __cplusplus } #endif diff --git a/common/utils/ocp_itti/itti.md b/common/utils/ocp_itti/itti.md new file mode 100644 index 0000000000000000000000000000000000000000..89bc3ee29f72951111070ae0d45af93c3b971ed7 --- /dev/null +++ b/common/utils/ocp_itti/itti.md @@ -0,0 +1,91 @@ +# interthread interface (ITTI) + +A Middleware called “itti†(interthread interface) provides classical send/receive message queues between threads. + +A simpler thread safe message queue is available in the thread-pool, as it is a required lower level feature. + +ITTI is providing more feature, to be used as the thread event main loop. + +It is also made for strong type definition is source code. + +It is able to add in the managed events: external sockets, timers + +All queues are created in .h files, as static permanent queues, nevertheless the possibility to add queues during runtime is available. + +The queues are called tasks because it is often read in a single thread that have the same name. + +# API definition + +## itti_send_msg_to_task, itti_receive_msg, itti_poll_msg + +Standard messages queues, thread safe +The reader is responsible of freeing the message + +## itti_subscribe_event_fd, itti_get_events + +Add external sockets to itti based main loop + +## timer_setup timer_remove + +When a timer expire, it adds a message in a itti queue + +## itti_terminate_tasks + +Calling this function push a “terminate†message on each itti queue + +# Example code of a thread using ITTI + +``` +Thread_aLayer_main(void * context) { + // initialize the layer data + // and register in itti the external sockets (like S1AP, GTP) + aLayer_init(); + while (1) { + MessageDef * msg + itti_receive_msg(TASK_aLayer, &msg); + // itti receive released, so we have incoming data + // Can be a itti message + if ( msg != NULL) { + switch(ITTI_MSG_ID(msg)) { + case …: + processThisMsgType1(msg); + break; + case …: + processThisMsgType2(msg); + break; + } + Itti_free(msg); + } + // or data/event on external entries (sockets) + Struct eppol_events* events; + int nbEvents=itti_get_events(TASK_aLayer, &events); + if ( nbEvents > 0) + processLayerEvents(events, nbEvents); + } +} + + +``` + +# Current usage in OpenAir + +## UDP, SCTP + +Simple threads that interface itti internal messages to Linux + +## GTPV1-U, S1AP + +Threads to implement S1AP and GTP protocols + +## PDCP + +4G Pdcp is not following itti design pattern, but it uses itti internally , 5G PDCP uses ad hoc design + +## RRC + +Implements 3GPP Rrc features +Interfaces the layer 1 and the above itti tasks + +## X2, ENP_APP (configuration), L1L2 + +Are declared itti queues with a dedicated thread, but they are almost empty \ No newline at end of file diff --git a/common/utils/system.c b/common/utils/system.c index 38d1c1d7ad001202368bca781545fd161b8c7b12..d8970631446dc4b112b65af896f111120b40fcf5 100644 --- a/common/utils/system.c +++ b/common/utils/system.c @@ -95,53 +95,16 @@ static void read_pipe(int p, char *b, int size) { size -= ret; } } - -static int baseRunTimeCommand(char* cmd, size_t cmdSize) { - FILE *fp; - size_t retSize = 0; - - fp = popen(cmd, "r"); - if(fp) { - memset(cmd, 0, cmdSize); - retSize = fread(cmd, 1, cmdSize, fp); - fclose(fp); - } else { - LOG_D(HW,"%s:%d:%s: Cannot open %s\n", __FILE__, __LINE__, __FUNCTION__, cmd); - } - - if (retSize == 0) { - return 0; - } - return atoi(cmd); -} - int checkIfFedoraDistribution(void) { - char cmd[200]; - - memset(cmd, 0, 200); - sprintf(cmd, "cat /etc/os-release | grep ID_LIKE | grep -ic fedora || true"); - return baseRunTimeCommand(cmd, 200); + return !system("grep -iq 'ID_LIKE.*fedora' /etc/os-release "); } int checkIfGenericKernelOnFedora(void) { - char cmd[200]; - - memset(cmd, 0, 200); - sprintf(cmd, "uname -a | grep -c rt || true"); - return (1 - baseRunTimeCommand(cmd, 200)); + return system("uname -a | grep -q rt"); } int checkIfInsideContainer(void) { - char cmd[200]; - int res = 0; - - memset(cmd, 0, 200); - sprintf(cmd, "cat /proc/self/cgroup | egrep -c 'libpod|podman|kubepods' || true"); - res = baseRunTimeCommand(cmd, 200); - if (res > 0) - return 1; - else - return 0; + return !system("egrep -q 'libpod|podman|kubepods' /proc/self/cgroup"); } /********************************************************************/ @@ -248,6 +211,19 @@ void start_background_system(void) { background_system_process(); } +int rt_sleep_ns (uint64_t x) +{ + struct timespec myTime; + clock_gettime(CLOCK_MONOTONIC, &myTime); + myTime.tv_sec += x/1000000000ULL; + myTime.tv_nsec = x%1000000000ULL; + if (myTime.tv_nsec>=1000000000) { + myTime.tv_nsec -= 1000000000; + myTime.tv_sec++; + } + + return clock_nanosleep(CLOCK_MONOTONIC, TIMER_ABSTIME, &myTime, NULL); +} void threadCreate(pthread_t* t, void * (*func)(void*), void * param, char* name, int affinity, int priority){ pthread_attr_t attr; @@ -257,21 +233,21 @@ void threadCreate(pthread_t* t, void * (*func)(void*), void * param, char* name, AssertFatal(ret==0,"ret: %d, errno: %d\n",ret, errno); ret=pthread_attr_setdetachstate(&attr, PTHREAD_CREATE_DETACHED); AssertFatal(ret==0,"ret: %d, errno: %d\n",ret, errno); - ret=pthread_attr_setinheritsched(&attr, PTHREAD_EXPLICIT_SCHED); - AssertFatal(ret==0,"ret: %d, errno: %d\n",ret, errno); - if (checkIfFedoraDistribution()) - if (checkIfGenericKernelOnFedora()) - if (checkIfInsideContainer()) - settingPriority = 0; - + + if (system("grep -iq 'ID_LIKE.*fedora' /etc/os-release && uname -a | grep -c rt")==0) + if (system("cat /proc/self/cgroup | egrep -c 'libpod|podman|kubepods'")==0) + settingPriority = 0; + if (settingPriority) { + ret=pthread_attr_setinheritsched(&attr, PTHREAD_EXPLICIT_SCHED); + AssertFatal(ret==0,"ret: %d, errno: %d\n",ret, errno); ret=pthread_attr_setschedpolicy(&attr, SCHED_OAI); AssertFatal(ret==0,"ret: %d, errno: %d\n",ret, errno); - if(priority<sched_get_priority_min(SCHED_OAI) || priority>sched_get_priority_max(SCHED_FIFO)) { - LOG_E(TMR,"Prio not possible: %d, min is %d, max: %d, forced in the range\n", - priority, - sched_get_priority_min(SCHED_OAI), - sched_get_priority_max(SCHED_OAI)); + if(priority<sched_get_priority_min(SCHED_OAI) || priority>sched_get_priority_max(SCHED_OAI)) { + LOG_E(UTIL,"Prio not possible: %d, min is %d, max: %d, forced in the range\n", + priority, + sched_get_priority_min(SCHED_OAI), + sched_get_priority_max(SCHED_OAI)); if(priority<sched_get_priority_min(SCHED_OAI)) priority=sched_get_priority_min(SCHED_OAI); if(priority>sched_get_priority_max(SCHED_OAI)) @@ -283,10 +259,10 @@ void threadCreate(pthread_t* t, void * (*func)(void*), void * param, char* name, ret=pthread_attr_setschedparam(&attr, &sparam); AssertFatal(ret==0,"ret: %d, errno: %d\n",ret, errno); } - + ret=pthread_create(t, &attr, func, param); AssertFatal(ret==0,"ret: %d, errno: %d\n",ret, errno); - + pthread_setname_np(*t, name); if (affinity != -1 ) { cpu_set_t cpuset; @@ -297,11 +273,128 @@ void threadCreate(pthread_t* t, void * (*func)(void*), void * param, char* name, pthread_attr_destroy(&attr); } +// Legacy, pthread_create + thread_top_init() should be replaced by threadCreate +// threadCreate encapsulates the posix pthread api +void thread_top_init(char *thread_name, + int affinity, + uint64_t runtime, + uint64_t deadline, + uint64_t period) { + +#ifdef DEADLINE_SCHEDULER + struct sched_attr attr; + + unsigned int flags = 0; + + attr.size = sizeof(attr); + attr.sched_flags = 0; + attr.sched_nice = 0; + attr.sched_priority = 0; + + attr.sched_policy = SCHED_DEADLINE; + attr.sched_runtime = runtime; + attr.sched_deadline = deadline; + attr.sched_period = period; + + if (sched_setattr(0, &attr, flags) < 0 ) { + perror("[SCHED] eNB tx thread: sched_setattr failed\n"); + fprintf(stderr,"sched_setattr Error = %s",strerror(errno)); + exit(1); + } + +#else //LOW_LATENCY + int policy, s, j; + struct sched_param sparam; + char cpu_affinity[1024]; + cpu_set_t cpuset; + int settingPriority = 1; + + /* Set affinity mask to include CPUs 2 to MAX_CPUS */ + /* CPU 0 is reserved for UHD threads */ + /* CPU 1 is reserved for all RX_TX threads */ + /* Enable CPU Affinity only if number of CPUs > 2 */ + CPU_ZERO(&cpuset); + +#ifdef CPU_AFFINITY + if (affinity == 0) { + LOG_W(HW,"thread_top_init() called with affinity==0, but overruled by #ifdef CPU_AFFINITY\n"); + } + else if (get_nprocs() > 2) + { + for (j = 2; j < get_nprocs(); j++) + CPU_SET(j, &cpuset); + s = pthread_setaffinity_np(pthread_self(), sizeof(cpu_set_t), &cpuset); + if (s != 0) + { + perror( "pthread_setaffinity_np"); + exit_fun("Error setting processor affinity"); + } + } +#else //CPU_AFFINITY + if (affinity) { + LOG_W(HW,"thread_top_init() called with affinity>0, but overruled by #ifndef CPU_AFFINITY.\n"); + } +#endif //CPU_AFFINITY + + /* Check the actual affinity mask assigned to the thread */ + s = pthread_getaffinity_np(pthread_self(), sizeof(cpu_set_t), &cpuset); + if (s != 0) + { + perror( "pthread_getaffinity_np"); + exit_fun("Error getting processor affinity "); + } + memset(cpu_affinity,0,sizeof(cpu_affinity)); + for (j = 0; j < 1024; j++) + { + if (CPU_ISSET(j, &cpuset)) + { + char temp[1024]; + sprintf (temp, " CPU_%d", j); + strcat(cpu_affinity, temp); + } + } + + if (checkIfFedoraDistribution()) + if (checkIfGenericKernelOnFedora()) + if (checkIfInsideContainer()) + settingPriority = 0; + + if (settingPriority) { + memset(&sparam, 0, sizeof(sparam)); + sparam.sched_priority = sched_get_priority_max(SCHED_FIFO); + policy = SCHED_FIFO; + + s = pthread_setschedparam(pthread_self(), policy, &sparam); + if (s != 0) { + perror("pthread_setschedparam : "); + exit_fun("Error setting thread priority"); + } + + s = pthread_getschedparam(pthread_self(), &policy, &sparam); + if (s != 0) { + perror("pthread_getschedparam : "); + exit_fun("Error getting thread priority"); + } + + pthread_setname_np(pthread_self(), thread_name); + + LOG_I(HW, "[SCHED][eNB] %s started on CPU %d, sched_policy = %s , priority = %d, CPU Affinity=%s \n",thread_name,sched_getcpu(), + (policy == SCHED_FIFO) ? "SCHED_FIFO" : + (policy == SCHED_RR) ? "SCHED_RR" : + (policy == SCHED_OTHER) ? "SCHED_OTHER" : + "???", + sparam.sched_priority, cpu_affinity ); + } + +#endif //LOW_LATENCY +} + + // Block CPU C-states deep sleep -void configure_linux(void) { +void set_latency_target(void) { int ret; static int latency_target_fd=-1; - uint32_t latency_target_value=10; // in microseconds + uint32_t latency_target_value=2; // in microseconds if (latency_target_fd == -1) { if ( (latency_target_fd = open("/dev/cpu_dma_latency", O_RDWR)) != -1 ) { ret = write(latency_target_fd, &latency_target_value, sizeof(latency_target_value)); diff --git a/common/utils/system.h b/common/utils/system.h index c76fef9144a7c9cf64e78015046a020df416faf5..c25c2a6f1f7a6030776ee78292ceca8e4246036c 100644 --- a/common/utils/system.h +++ b/common/utils/system.h @@ -43,10 +43,9 @@ int background_system(char *command); void start_background_system(void); void set_latency_target(void); -void configure_linux(void); -void threadCreate(pthread_t* t, void * (*func)(void*), void * param, char* name, int affinity, int priority); - +void threadCreate(pthread_t *t, void *(*func)(void *), void *param, char *name, int affinity, int priority); + #define SCHED_OAI SCHED_RR #define OAI_PRIORITY_RT_LOW sched_get_priority_min(SCHED_OAI) #define OAI_PRIORITY_RT ((sched_get_priority_min(SCHED_OAI)+sched_get_priority_max(SCHED_OAI))/2) @@ -65,7 +64,7 @@ void thread_top_init(char *thread_name, int checkIfFedoraDistribution(void); int checkIfGenericKernelOnFedora(void); int checkIfInsideContainer(void); - +int rt_sleep_ns (uint64_t x); #ifdef __cplusplus } #endif diff --git a/common/utils/telnetsrv/telnetsrv.c b/common/utils/telnetsrv/telnetsrv.c index 9e4eeca205c1a57da35a517b53095916b981cb6b..aab8c843685c524778c66aeb2b96671927578620 100644 --- a/common/utils/telnetsrv/telnetsrv.c +++ b/common/utils/telnetsrv/telnetsrv.c @@ -51,7 +51,6 @@ #include <dlfcn.h> #include <sys/time.h> #include <sys/resource.h> -#include <form.h> #include "common/utils/load_module_shlib.h" #include "common/config/config_userapi.h" #include "common/utils/threadPool/thread-pool.h" diff --git a/common/utils/telnetsrv/telnetsrv_cpumeasur_def.h b/common/utils/telnetsrv/telnetsrv_cpumeasur_def.h index a275272e809ebd26eabfb98d9caf6a24a78dcde2..ed8b5e23013b6341175743177f58cb7bd7179b7f 100644 --- a/common/utils/telnetsrv/telnetsrv_cpumeasur_def.h +++ b/common/utils/telnetsrv/telnetsrv_cpumeasur_def.h @@ -106,12 +106,13 @@ {"phy_proc", &(UE->phy_proc[0]),0,RX_NB_TH},\ {"phy_proc_rx", &(UE-> phy_proc_rx[0]),0,RX_NB_TH},\ {"phy_proc_tx", &(UE->phy_proc_tx),0,1},\ + {"ue_ul_indication_stats", &(UE->ue_ul_indication_stats),0,1},\ {"ofdm_mod_stats", &(UE->ofdm_mod_stats),0,1},\ {"ulsch_encoding_stats", &(UE->ulsch_encoding_stats),0,1},\ {"ulsch_modulation_stats", &(UE->ulsch_modulation_stats),0,1},\ {"ulsch_segmentation_stats", &(UE->ulsch_segmentation_stats),0,1},\ {"ulsch_rate_matching_stats", &(UE->ulsch_rate_matching_stats),0,1},\ - {"ulsch_turbo_encoding_stats", &(UE->ulsch_turbo_encoding_stats),0,1},\ + {"ulsch_ldpc_encoding_stats", &(UE->ulsch_ldpc_encoding_stats),0,1},\ {"ulsch_interleaving_stats", &(UE->ulsch_interleaving_stats),0,1},\ {"ulsch_multiplexing_stats", &(UE->ulsch_multiplexing_stats),0,1},\ {"generic_stat", &(UE->generic_stat),0,1},\ @@ -123,12 +124,12 @@ {"dlsch_f...timation_stats", &(UE->dlsch_freq_offset_estimation_stats),0,1},\ {"dlsch_demodulation_stats", &(UE->dlsch_demodulation_stats),0,1},\ {"dlsch_rate_unmatching_stats", &(UE->dlsch_rate_unmatching_stats),0,1},\ - {"dlsch_turbo_decoding_stats", &(UE->dlsch_turbo_decoding_stats),0,1},\ + {"dlsch_ldpc_decoding_stats", &(UE->dlsch_ldpc_decoding_stats),0,1},\ {"dlsch_deinterleaving_stats", &(UE->dlsch_deinterleaving_stats),0,1},\ {"dlsch_llr_stats", &(UE->dlsch_llr_stats),0,1},\ {"dlsch_unscrambling_stats", &(UE->dlsch_unscrambling_stats),0,1},\ {"dlsch_rate_matching_stats", &(UE->dlsch_rate_matching_stats),0,1},\ - {"dlsch_turbo_encoding_stats", &(UE->dlsch_turbo_encoding_stats),0,1},\ + {"dlsch_ldpc_encoding_stats", &(UE->dlsch_ldpc_encoding_stats),0,1},\ {"dlsch_interleaving_stats", &(UE->dlsch_interleaving_stats),0,1},\ {"dlsch_tc_init_stats", &(UE->dlsch_tc_init_stats),0,1},\ {"dlsch_tc_alpha_stats", &(UE->dlsch_tc_alpha_stats),0,1},\ @@ -146,6 +147,7 @@ {"ue_front_end_stat", &(UE->ue_front_end_stat[0]),0,RX_NB_TH},\ {"ue_front_end_per_slot_stat", &(UE->ue_front_end_per_slot_stat[0][0]),0,RX_NB_TH,LTE_SLOTS_PER_SUBFRAME},\ {"pdcch_procedures_stat", &(UE->pdcch_procedures_stat[0]),0,RX_NB_TH},\ + {"rx_pdsch_stats", &(UE->rx_pdsch_stats), 0, 1}, \ {"pdsch_procedures_stat", &(UE->pdsch_procedures_stat[0]),0,RX_NB_TH},\ {"pdsch_procedures_per_slot_stat", &(UE->pdsch_procedures_per_slot_stat[0][0]),0,RX_NB_TH,LTE_SLOTS_PER_SUBFRAME},\ {"dlsch_procedures_stat", &(UE->dlsch_procedures_stat[0]),0,RX_NB_TH},\ diff --git a/common/utils/threadPool/Makefile b/common/utils/threadPool/Makefile index 6b28eb2ba8a6f7ba8808fc7d183a40ad903f7c40..729f9dd0e217dfc7ce80efcc72b2e46c30e1a561 100644 --- a/common/utils/threadPool/Makefile +++ b/common/utils/threadPool/Makefile @@ -1,13 +1,3 @@ -all: -measurement_display thread-pool-test - -measurement_display: -measurement_display.c thread-pool.h -gcc measurement_display.c -I $ {OPENAIR_DIR}/ -I $ {OPENAIR_DIR}/common/utils/ -I. $ {OPENAIR_DIR}/common/utils/backtrace.c -lpthread -D TEST_THREAD_POOL -I../LOG -I../../utils/T -o -measurement_display - -thread-pool-test: -thread-pool.c thread-pool.h -gcc -g thread-pool.c -I $ {OPENAIR_DIR}/ -I $ {OPENAIR_DIR}/common/utils/ -I. $ {OPENAIR_DIR}/common/utils/backtrace.c -I $ {OPENAIR_DIR}/openair2/COMMON $ {OPENAIR_DIR}/common/utils/LOG/log.c $ {OPENAIR_DIR}/common/config/config_userapi.c -$ {OPENAIR_DIR}/common/config/config_load_configmodule.c $ {OPENAIR_DIR}/common/config/config_cmdline.c -lpthread -ldl -D TEST_THREAD_POOL -I../LOG -I../../utils/T -o thread-pool-test +thread-pool-test: thread-pool.c thread-pool.h + gcc -g -O3 thread-pool.c -I ${OPENAIR_DIR}/nfapi/open-nFAPI/nfapi/public_inc -I ${OPENAIR_DIR}/ -I ${OPENAIR_DIR}/common/utils/ -I. ${OPENAIR_DIR}/common/utils/backtrace.c -I ${OPENAIR_DIR}/openair2/COMMON ${OPENAIR_DIR}/common/utils/system.c ${OPENAIR_DIR}/common/utils/LOG/log.c ${OPENAIR_DIR}/common/config/config_userapi.c ${OPENAIR_DIR}/common/config/config_load_configmodule.c ${OPENAIR_DIR}/common/config/config_cmdline.c -lpthread -ldl -D TEST_THREAD_POOL -DMAX_NUM_CCs=1 -I../LOG -I../../utils/T -o thread-pool-test diff --git a/common/utils/threadPool/thread-pool.c b/common/utils/threadPool/thread-pool.c index 77729ae7a7ae187feee5223d5bd3bc6a50657212..fff09528a856edbe39f2bbff52bad368ce7b1842 100644 --- a/common/utils/threadPool/thread-pool.c +++ b/common/utils/threadPool/thread-pool.c @@ -155,21 +155,24 @@ void initNamedTpool(char *params,tpool_t *pool, bool performanceMeas, char *name } #ifdef TEST_THREAD_POOL +volatile int oai_exit=0; void exit_function(const char *file, const char *function, const int line, const char *s) { } struct testData { int id; + int sleepTime; char txt[30]; }; void processing(void *arg) { struct testData *in=(struct testData *)arg; - printf("doing: %d, %s, in thr %ld\n",in->id, in->txt,pthread_self() ); + //printf("doing: %d, %s, in thr %ld\n",in->id, in->txt,pthread_self() ); sprintf(in->txt,"Done by %ld, job %d", pthread_self(), in->id); - usleep(rand()%100); - printf("done: %d, %s, in thr %ld\n",in->id, in->txt,pthread_self() ); + in->sleepTime=rand()%1000; + usleep(in->sleepTime); + //printf("done: %d, %s, in thr %ld\n",in->id, in->txt,pthread_self() ); } int main() { @@ -208,11 +211,43 @@ int main() { } while(tmp); tpool_t pool; - char params[]="1,2,3,u"; + char params[]="1,2,3,4,5"; initTpool(params,&pool, true); notifiedFIFO_t worker_back; initNotifiedFIFO(&worker_back); + sleep(1); + int cumulProcessTime=0, cumulTime=0; + struct timespec st,end; + clock_gettime(CLOCK_MONOTONIC, &st); + int nb_jobs=4; + for (int i=0; i <1000 ; i++) { + int parall=nb_jobs; + for (int j=0; j <parall ; j++) { + notifiedFIFO_elt_t *work=newNotifiedFIFO_elt(sizeof(struct testData), i, &worker_back, processing); + struct testData *x=(struct testData *)NotifiedFifoData(work); + x->id=i; + pushTpool(&pool, work); + } + int sleepmax=0; + while (parall) { + tmp=pullTpool(&worker_back,&pool); + if (tmp) { + parall--; + struct testData *dd=NotifiedFifoData(tmp); + if (dd->sleepTime > sleepmax) + sleepmax=dd->sleepTime; + delNotifiedFIFO_elt(tmp); + } + } + cumulProcessTime+=sleepmax; + } + clock_gettime(CLOCK_MONOTONIC, &end); + long long dur=(end.tv_sec-st.tv_sec)*1000*1000+(end.tv_nsec-st.tv_nsec)/1000; + printf("In µs, Total time per group of %d job:%lld, work time per job %d, overhead per job %lld\n", + nb_jobs, dur/1000, cumulProcessTime/1000, (dur-cumulProcessTime)/(1000*nb_jobs)); + + /* for (int i=0; i <1000 ; i++) { notifiedFIFO_elt_t *work=newNotifiedFIFO_elt(sizeof(struct testData), i, &worker_back, processing); struct testData *x=(struct testData *)NotifiedFifoData(work); @@ -232,7 +267,7 @@ int main() { abortTpool(&pool,510); } while(tmp); - + */ return 0; } #endif diff --git a/common/utils/threadPool/thread-pool.h b/common/utils/threadPool/thread-pool.h index a32b7c38595bbfe83ce446d2eddf81de87e4d995..a8f8572cfe9ff379fa277507fbf69593f1ed97de 100644 --- a/common/utils/threadPool/thread-pool.h +++ b/common/utils/threadPool/thread-pool.h @@ -31,6 +31,7 @@ #include <assertions.h> #include <LOG/log.h> #include <common/utils/system.h> +//#include <stdatomic.h> #ifdef DEBUG #define THREADINIT PTHREAD_ERRORCHECK_MUTEX_INITIALIZER_NP @@ -50,7 +51,7 @@ AssertFatal(ret==0,"ret=%d\n",ret);} #define condbroadcast(signal) {int ret=pthread_cond_broadcast(&signal); \ AssertFatal(ret==0,"ret=%d\n",ret);} -#define condsignal(signal) {int ret=pthread_cond_broadcast(&signal); \ +#define condsignal(signal) {int ret=pthread_cond_signal(&signal); \ AssertFatal(ret==0,"ret=%d\n",ret);} #define tpool_nbthreads(tpool) (tpool.nbThreads) typedef struct notifiedFIFO_elt_s { @@ -130,7 +131,7 @@ static inline void pushNotifiedFIFO_nothreadSafe(notifiedFIFO_t *nf, notifiedFIF static inline void pushNotifiedFIFO(notifiedFIFO_t *nf, notifiedFIFO_elt_t *msg) { mutexlock(nf->lockF); pushNotifiedFIFO_nothreadSafe(nf,msg); - condbroadcast(nf->notifF); + condsignal(nf->notifF); mutexunlock(nf->lockF); } @@ -141,7 +142,7 @@ static inline notifiedFIFO_elt_t *pullNotifiedFIFO_nothreadSafe(notifiedFIFO_t notifiedFIFO_elt_t *ret=nf->outF; if (nf->outF==nf->outF->next) - LOG_E(TMR,"Circular list in thread pool: push several times the same buffer is forbidden\n"); + LOG_E(UTIL,"Circular list in thread pool: push several times the same buffer is forbidden\n"); nf->outF=nf->outF->next; diff --git a/common/utils/utils.c b/common/utils/utils.c index 7f7aafc94a498f1dd53b006b98c1fc83e37d4e43..16402c1057fc052a628c6c61187fdcf456ed2f6d 100644 --- a/common/utils/utils.c +++ b/common/utils/utils.c @@ -2,26 +2,39 @@ #include <stdio.h> #include <stdlib.h> #include <stdint.h> +#include <unistd.h> +#include <sched.h> +#include <errno.h> #include "utils.h" -void *calloc_or_fail(size_t size) { - void *ptr = calloc(1, size); - if (ptr == NULL) { - fprintf(stderr, "[UE] Failed to calloc %zu bytes", size); - exit(EXIT_FAILURE); - } - return ptr; -} -void *malloc_or_fail(size_t size) { - void *ptr = malloc(size); - if (ptr == NULL) { - fprintf(stderr, "[UE] Failed to malloc %zu bytes", size); - exit(EXIT_FAILURE); - } - return ptr; + +const char *hexdump(const void *data, size_t data_len, char *out, size_t out_len) +{ + char *p = out; + char *endp = out + out_len; + const uint8_t *q = data; + snprintf(p, endp - p, "[%zu]", data_len); + p += strlen(p); + for (size_t i = 0; i < data_len; ++i) + { + if (p >= endp) + { + static const char ellipses[] = "..."; + char *s = endp - sizeof(ellipses); + if (s >= p) + { + strcpy(s, ellipses); + } + break; + } + snprintf(p, endp - p, " %02X", *q++); + p += strlen(p); + } + return out; } + /**************************************************************************** ** ** ** Name: hex_char_to_hex_value() ** @@ -111,3 +124,17 @@ void *memcpy1(void *dst,const void *src,size_t n) { asm volatile("rep movsb" : "+D" (dst) : "c"(n), "S"(src) : "cc","memory"); return(ret); } + +void set_priority(int priority) +{ + struct sched_param param = + { + .sched_priority = priority, + }; + fprintf(stderr, "Calling sched_setscheduler(%d)\n", priority); + if (sched_setscheduler(0, SCHED_RR, ¶m) == -1) + { + fprintf(stderr, "sched_setscheduler: %s\n", strerror(errno)); + abort(); + } +} diff --git a/common/utils/utils.h b/common/utils/utils.h index 16631586c413ec7532812da13f28ecd79dd7a9c1..5963ae0c8e03b0e9652c5954fc053123078fa90a 100644 --- a/common/utils/utils.h +++ b/common/utils/utils.h @@ -1,15 +1,113 @@ #ifndef _UTILS_H #define _UTILS_H -#include <stdint.h> -#include <sys/types.h> + #ifdef __cplusplus extern "C" { #endif +#include <stdint.h> +#include <stdlib.h> +#include <string.h> +#include <malloc.h> +#include <sys/types.h> +#include <common/utils/assertions.h> + +#ifdef MALLOC_TRACE +#define malloc myMalloc +#endif + #define sizeofArray(a) (sizeof(a)/sizeof(*(a))) -void *calloc_or_fail(size_t size); -void *malloc_or_fail(size_t size); + +#define cmax(a,b) ((a>b) ? (a) : (b)) +#define cmax3(a,b,c) ((cmax(a,b)>c) ? (cmax(a,b)) : (c)) +#define cmin(a,b) ((a<b) ? (a) : (b)) + +#ifdef __cplusplus +#ifdef min +#undef min +#undef max +#endif +#else +#define max(a,b) cmax(a,b) +#define min(a,b) cmin(a,b) +#endif + +#ifndef malloc16 +# ifdef __AVX2__ +# define malloc16(x) memalign(32,x+32) +# else +# define malloc16(x) memalign(16,x+16) +# endif +#endif +#define free16(y,x) free(y) +#define bigmalloc malloc +#define bigmalloc16 malloc16 +#define openair_free(y,x) free((y)) +#define PAGE_SIZE 4096 + +#define free_and_zero(PtR) do { \ + if (PtR) { \ + free(PtR); \ + PtR = NULL; \ + } \ + } while (0) + +static inline void *malloc16_clear( size_t size ) { +#ifdef __AVX2__ + void *ptr = memalign(32, size+32); +#else + void *ptr = memalign(16, size+16); +#endif + DevAssert(ptr); + memset( ptr, 0, size ); + return ptr; +} + + +static inline void *calloc_or_fail(size_t size) { + void *ptr = calloc(1, size); + + if (ptr == NULL) { + fprintf(stderr, "[UE] Failed to calloc %zu bytes", size); + exit(EXIT_FAILURE); + } + + return ptr; +} + +static inline void *malloc_or_fail(size_t size) { + void *ptr = malloc(size); + + if (ptr == NULL) { + fprintf(stderr, "[UE] Failed to malloc %zu bytes", size); + exit(EXIT_FAILURE); + } + + return ptr; +} + +#if !defined (msg) +# define msg(aRGS...) LOG_D(PHY, ##aRGS) +#endif +#ifndef malloc16 +# ifdef __AVX2__ +# define malloc16(x) memalign(32,x) +# else +# define malloc16(x) memalign(16,x) +# endif +#endif + +#define free16(y,x) free(y) +#define bigmalloc malloc +#define bigmalloc16 malloc16 +#define openair_free(y,x) free((y)) +#define PAGE_SIZE 4096 + +#define PAGE_MASK 0xfffff000 +#define virt_to_phys(x) (x) + +const char *hexdump(const void *data, size_t data_len, char *out, size_t out_len); // Converts an hexadecimal ASCII coded digit into its value. ** int hex_char_to_hex_value (char c); @@ -18,6 +116,7 @@ int hex_string_to_hex_value (uint8_t *hex_value, const char *hex_string, int siz void *memcpy1(void *dst,const void *src,size_t n); +void set_priority(int priority); char *itoa(int i); diff --git a/doc/BUILD.md b/doc/BUILD.md index 40b63ac697587fd2d4348dfeeb8e480ad3bd4cdf..852a2486595740315eb6b6427c43f40e514969a3 100644 --- a/doc/BUILD.md +++ b/doc/BUILD.md @@ -60,7 +60,7 @@ cd cmake_targets/ ./build_oai -I --phy_simulators ``` -After completing the build, the binaries are available in the cmake_targets/phy_simulators/build directory. +After completing the build, the binaries are available in the cmake_targets/ran_build/build directory. A copy is also available in the target/bin directory, with all binaries suffixed by the 3GPP release number, today **.Rel15**. diff --git a/doc/F1-design.md b/doc/F1-design.md new file mode 100644 index 0000000000000000000000000000000000000000..80417b1ae3e73c20d52f590ecde03fd505fb2284 --- /dev/null +++ b/doc/F1-design.md @@ -0,0 +1,210 @@ +<table style="border-collapse: collapse; border: none;"> + <tr style="border-collapse: collapse; border: none;"> + <td style="border-collapse: collapse; border: none;"> + <a href="http://www.openairinterface.org/"> + <img src="./images/oai_final_logo.png" alt="" border=3 height=50 width=150> + </img> + </a> + </td> + <td style="border-collapse: collapse; border: none; vertical-align: center;"> + <b><font size = "5">F1 split design</font></b> + </td> + </tr> +</table> +# 1. Introduction + +We use OpenAirInterface source code, and it's regular deployment scheme. + +F1 specification is in 3GPP documents: TS 38.470 header document and all documents listed in chapter 2 References of TS 38.470. + +This document explains how the source code works. + +Offered features and deployment instructions are described in: +https://gitlab.eurecom.fr/oai/openairinterface5g/-/wikis/f1-interface + +# 2. Common multi-threading architecture # + +The CU and DU interfaces are based on ITTI threads (see oai/common/utils/ocp_itti/itti.md) + +All OAI upper layers use the ITTI framework to run isolated threads dedicated to one feature. +The lower layers adopt case by case specific software architecture. + +```mermaid +graph TD +Linux[configuration file] --> APP[gNB_app_task] +Socks[Linux UDP] --> GTP[nr_gtpv1u_gNB_task] +APP --> CU +APP --> DU +A[Linux SCTP] -->|sockets| SCTP(OAI itti thread TASK_SCTP) +SCTP-->|TASK_NGAP| NG[ngap_gNB_task] +NG-->|TASK_SCTP| SCTP +SCTP-->|TASK_DU_F1| DU[F1AP_DU_task] +SCTP-->|TASK_CU_F1| CU[F1AP_CU_task] +CU-->|TASK_RRC_GNB| RRC +RRC -->|non ITTI| PHY[OAI L1+L2] +RRC -->|API calls to create tunnels| GTP +PHY --> |user plane| GTP +CU --> |TASK_GTPV1_U| GTP +DU --> |TASK_GTPV1_U| GTP +``` +A "task" is a Linux thread running infinite waiting loop on one ITTI queue + +app task manages the initial configuration + +sctp task mamanges the SCTP Linux sockets + +CU code runs in the task F1AP_CU_task. It stores it's private data context in a static variable. No mutex is used, as the single interface to CU ITTI tast in incoming ITTI messages. CU task is a single ITTI queue, but multiple CU could exist in one Linux process, using the "instance id" (called "module id" also) to create separate contextual information for each CU instance. + +DU code runs in the task F1AP_DU_task. The design is similar to CU task + +All GTP-U tunnels are managed in a Linux Thread, that have partially ITTI design: + +1. tunnel creation/deletion is by C API functions direct calls (a mutex protects it) +2. outgoing packets are pushed in a ITTI queue to the gtp thread +3. incoming packets are sent to the tunnel creator using a C callback (the callback function is given in tunnel creation order). The callback should not block + + +# 3. CU F1AP messages # + +## startup + +CU thread starts when the CU starts. It opens listening socket on F1AP_PORT_NUMBER by sending the appropriate message to TASK_SCTP. + +It will accept the first incoming connection on this port + +## F1 SETUP + +DU has connected, and sent this message. + +The CU receives, decode it and send relevant information to RRC thread by message F1AP_SETUP_REQ + +## F1 SETUP response + +RRC sends two messages to CU F1 task: the information to encode the F1 setup response and a second message to encode F1AP_GNB_CU_CONFIGURATION_UPDATE + +Upon reception of these two messages the CU task encodes and sends the messages to the DU + +## UE entry + +When CCH channel decoding finds a new UE identity, it call rrc_gNB_generate_RRCSetup() that will send F1AP_DL_RRC_MESSAGE to the CU task. + +The CU encodes and sends to DU DLRRCMessageTransfer + +## UE attach/detach + +When rrc_gNB_process_RRCReconfigurationComplete() occurs, the RRC sends to CU task the message F1AP_UE_CONTEXT_SETUP_REQ. The CU task encodes the F1 message UEContextSetup and send it to the DU over F1AP. + +This function rrc_gNB_process_RRCReconfigurationComplete() also creates the GTP-U user plane bearers. + +## F1AP incoming messages + +SCTP tasks sends a ITTI message SCTP_DATA_IND to the CU task. + +A array of functions pointers and the F1AP standard identifier "procedureCode", the CU calls the appropriate function + +Hereafter the most significant messages processing + +### CU_handle_F1_SETUP_REQUEST + +Transcodes information to the same message toward RRC (F1AP_SETUP_REQ) + +### CU_handle_INITIAL_UL_RRC_MESSAGE_TRANSFER + +Transcodes information to the same message toward RRC (NR_RRC_MAC_CCCH_DATA_IND) + +### CU_handle_UL_RRC_MESSAGE_TRANSFER + +Encode and send data to PDCP (calling pdcp_data_ind ()) for processing UL data. + +# DU F1 Messages + +## Startup + +The task "gNB app" after rzading the configuration file, sends a first message F1AP_SETUP_REQ to DU task + +Using this message, the uniq DU task (Linux Thread) creates a DU instance context memory space, calls SCTP task to create a socket to the CU. + +When it receives from the SCTP task the socket creation success, the DU task encodes+sends the F1 setup message to the CU. + +## F1AP_INITIAL_UL_RRC_MESSAGE + +When MAC layer push UL data to DU task, the DU sends to CU the message InitialULRRCMessageTransfer + +## F1AP_UL_RRC_MESSAGE + +In case of SRB bearer, the RLC layer use this message to push rlc bearer payload to DU task, that forward to CU + +## pdcp_data_ind + +This function call in RLC, when it is a DRB will be replaced by F1-U transport to CU + +## F1AP incoming messages + +SCTP tasks sends a ITTI message SCTP_DATA_IND to the DU task. + +A array of functions pointers and the F1AP standard identifier "procedureCode", the DU calls the appropriate function + +Hereafter the most significant messages processing + +### DU_send_F1_SETUP_RESPONSE + +Decode the CU message, then encode a message to TASK_GNB_APP. The thread "APP" extracts the system information block and reconfigure the DU with: du_extract_and_decode_SI(), configure_gnb_du_mac() + +### DU_handle_gNB_CU_CONFIGURATION_UPDATE + +No developped + +### DU_handle_UE_CONTEXT_SETUP_REQUEST + +Push data to RLC layer for transmisstion in DL (to the UE) by calling enqueue_rlc_data_req() + +### DU_handle_DL_RRC_MESSAGE_TRANSFER + +Depending on the content, adds UE context in DU low layers and/or send data to the UE with rlc_data_req() + +# F1-U messages + +The data path by itself doesn't make any difficulty: +1. for UL, rlc calls pdcp_data_ind (DRB) or sends a message to RRC (SRB). So, we can replace pdcp_data_ind() by du_pdcp_data_ind() that will push the message in the GTP tunnel. In CU, assuming the tunnel is in place, the right call back decapsulate the transport (cu_ul_recv()), then calls pdcp_data_ind() in CU +The SRB are sent in DU RRC tasks via itti F1AP_UL_RRC_MESSAGE (see above the processing) +2. For DL, pdcp (in CU for DRBs) calls rlc_data_req (by a decoupling queue and thread rlc_data_req_thread, so function du_rlc_data_req() or enqueue_rlc_data_req()). in DU, assuming the gtp-u tunnel exists, a reception call back (du_dl_recv()) decapsulate the gtp-u packet and calls du_rlc_data_req() + +Hereafter the processing design, that doesn't require to setup a new context storage, as we can use the GTP-U internal tables: rnti+rb=>teid for outgoing gtp-u packets and teid=>rnti+rb for incoming gtp-u packets + +In CU case, the DRB tunnel to DU and the tunnel on N3 have the same key (rnti, rb id), but they run in two different GTP-U instances. +Each instance binds on diffrent sockets. + +For F1-U, both DU and CU binds on the full quadruplet (IP source, port source, IP destination, port destination) from the configuration file parameters: +local_s_address, remote_s_address,local_s_portd, remote_s_portd + +These 4 values are in: +CU: at cell level (same level as nr_cellid parameter), they are read if tr_s_preference = "f1"; is set +DU: in block MACRLCs, if tr_n_preference = "f1"; is set in this block + +## tunnels setup +In GTP-U, TS 29.281 specifies a option header (NR RAN Container This extension header may be transmitted in a G-PDU over the X2-U, Xn-U and F1-U user plane interfaces), but it is not mandatory optional header (as is the N3 one). + +So, we can use this header a something reliable with other vendors implementation. + +In DL, we need to associate the packet with: rnti, rb (radio bearer) and "mui" (a OAI internal id that is optional and may be removed soon) to call rlc_data_req() + +In UL, we need also the RNTI, the rb + +So, we need to create a gtp-u tunnel for each rb over F1, then manage in CU and DU the association between a uniq TEid and the pair(rnti, rb). This is already what we have in existing OAI GTP-U layer interface. + +In F1AP, for each "DRB to Be Setup Item IEs", we have a field TNL (transport network layer) to set a specific GTP tunnel (@IP, TEid, udp port is always 2152). This is the same for each message related to DRBs. (F1AP carries the SRB payload inside F1AP). + +So, For each F1AP containing DRB setup/modification/deletion, the related GTP-U tunnels will be modified one to one. +The exception is the intialisation of new tunnel: in the call to tunnel creation, we need to send the remote TEID, but we don't know yet if we are the initial source. In this case, we issue a dummy (0xFFFF) remote teid; when we receive the remote answer, we get the source teid, that we can inform GTP-U with (using update tunnel). + +## processing on GTP-U incoming message + +Du_dl_recv() or cu_ul_recv() are called because we have set this callbacks in creat/update tunnel calls to gtp-u. As gtp-u maintains a pair(rnti,rbid) associated to each tunnel, the functions can be very simple stateless callback that calls pdcp_data_ind() or rlc_data_req() to get back in normal processing path + +## CU/DU outgoing + +DU rlc north output goes to du_pdcp_data_ind() that push a outgoing packet request to gtp-u, using the rnti+rb as ids. GTP-U must have the tunnel existing, then it simply implement the same as in N3 for exemple. + +CU pdcp south output calls cu_rlc_data_ind() that do the same symetric processing. + + diff --git a/doc/FEATURE_SET.md b/doc/FEATURE_SET.md index 9443fbd56e67fae3fc2e0e48d3fe479740768030..eaa691d6ef07142ba399cb1e308b7b9926183c3a 100644 --- a/doc/FEATURE_SET.md +++ b/doc/FEATURE_SET.md @@ -294,6 +294,10 @@ The following features are valid for the gNB and the 5G-NR UE. * NR-PUCCH - Format 0 (2 bits, for ACK/NACK and SR) - Format 2 (up to 11 bits, mainly for CSI feedback) +* NR-SRS + - SRS signal reception + - Channel estimation (with T tracer real time monitoring) + - Power noise estimation * NR-PRACH - Formats 0,1,2,3, A1-A3, B1-B3 * Highly efficient 3GPP compliant LDPC encoder and decoder (BG1 and BG2 are supported) @@ -307,8 +311,10 @@ The following features are valid for the gNB and the 5G-NR UE. - MAC <-> PHY data interface using FAPI P7 interface for BCH PDU, DCI PDU, PDSCH PDU - Scheduler procedures for SIB1 - Scheduler procedures for RA - - Contention free RA procedure - - Contention based RA procedure + - Contention Free RA procedure + - Contention Based RA procedure + - Msg3 can transfer uplink CCCH, DTCH or DCCH messages + - CBRA can be performed using MAC CE or C-RNTI - Scheduler procedures for CSI-RS - MAC downlink scheduler - phy-test scheduler (fixed allocation and usable also without UE) @@ -320,6 +326,8 @@ The following features are valid for the gNB and the 5G-NR UE. - phy-test scheduler (fixed allocation) - regular scheduler with dynamic allocation - HARQ procedures for uplink +- Scheduler procedures for SRS reception + - Periodic SRS reception - MAC procedures to handle CSI measurement report - evalution of RSRP report - evaluation of CQI report @@ -431,11 +439,12 @@ The following features are valid for the gNB and the 5G-NR UE. - Format 0 (2 bits for ACK/NACK and SR) - Format 2 (up to 64 bits, mainly for CSI feedback) - Format 1, 3 and 4 present but old code never dested (need restructuring before verification) -* NR-PRACH +* NR-SRS + - Generation of sequence at PHY + - SRS signal transmission +* NR-PRACH - Formats 0,1,2,3, A1-A3, B1-B3 -* NR-SRS - - Old code never dested (need restructuring before verification) -* SS-RSRP +* SS-RSRP - RSRP measured on synchronization SSB (ok only for single SSB) * Highly efficient 3GPP compliant LDPC encoder and decoder (BG1 and BG2 are supported) * Highly efficient 3GPP compliant polar encoder and decoder @@ -450,21 +459,21 @@ The following features are valid for the gNB and the 5G-NR UE. ## NR UE Higher Layers ## **UE MAC** -* Minimum system information (MSI) +* Minimum system information (MSI) - MIB processing - Scheduling of system information block 1 (SIB1) reception -* Random access procedure (needs improvement, there is still not a clear separation between MAC and PHY) +* Random access procedure (needs improvement, there is still not a clear separation between MAC and PHY) - Mapping SSBs to multiple ROs - Scheduling of PRACH - Processing of RAR - Transmission and re-transmission of Msg3 - Msg4 and contention resolution -* DCI processing +* DCI processing - format 10 (RA-RNTI, C-RNTI, SI-RNTI, TC-RNTI) - format 00 (C-RNTI, TC-RNTI) - format 11 (C-RNTI) - format 01 (C-RNTI) -* UCI processing +* UCI processing - ACK/NACK processing - Triggering periodic SR - CSI measurement reporting (SSB RSRP only) @@ -473,6 +482,8 @@ The following features are valid for the gNB and the 5G-NR UE. - HARQ procedures * ULSCH scheduler - Configuration of fapi PDU according to DCI +* Scheduler procedures for SRS transmission + - Periodic SRS transmission **UE RLC** diff --git a/doc/RUNMODEM.md b/doc/RUNMODEM.md index d063afd5d937d72fc4deb8e196c9dad5b5e039f5..89d2ec8a2de34ca4bc4214ba58de4ffb8b3a241a 100644 --- a/doc/RUNMODEM.md +++ b/doc/RUNMODEM.md @@ -89,6 +89,8 @@ At the UE the --phy-test flag will ```bash sudo ./nr-softmodem -O ../../../targets/PROJECTS/GENERIC-LTE-EPC/CONF/gnb.band78.tm1.106PRB.usrpn300.conf --phy-test``` +In phy-test mode it is possible to mimic the reception of UE Capabilities at gNB by passing through the command line parameter `--uecap_file` the location and file name of the input UE Capability file, e.g. `--uecap_file ../../../targets/PROJECTS/GENERIC-NR-5GC/CONF/uecap.xml` + ### Launch UE in another window ```bash sudo ./nr-uesoftmodem --phy-test [--rrc_config_path ../../../ci-scripts/rrc-files]``` @@ -122,6 +124,8 @@ gNB on machine 1: `sudo ./nr-softmodem -O ../../../targets/PROJECTS/GENERIC-LTE-EPC/CONF/gnb.band78.tm1.106PRB.usrpn300.conf --do-ra` +In do-ra mode it is possible to mimic the reception of UE Capabilities at gNB by passing through the command line parameter `--uecap_file` the location and file name of the input UE Capability file, e.g. `--uecap_file ../../../targets/PROJECTS/GENERIC-NR-5GC/CONF/uecap.xml` + UE on machine 2: `sudo ./nr-uesoftmodem --do-ra` @@ -161,13 +165,17 @@ gNB on machine 1: UE on machine 2: -`sudo ./nr-uesoftmodem -r 106 --numerology 1 --band 78 -C 3619200000 --sa` +`sudo ./nr-uesoftmodem -r 106 --numerology 1 --band 78 -C 3619200000 -s 516 --sa` With the RF simulator (on the same machine): `sudo ./nr-softmodem -O ../../../targets/PROJECTS/GENERIC-NR-5GC/CONF/gnb.sa.band78.fr1.106PRB.usrpb210.conf --rfsim --sa` -`sudo ./nr-uesoftmodem -r 106 --numerology 1 --band 78 -C 3619200000 --rfsim --sa` +`sudo ./nr-uesoftmodem -r 106 --numerology 1 --band 78 -C 3619200000 -s 516 --rfsim --sa` + +where `-r` sets the transmission bandwidth configuration in terms of RBs, `-C` sets the downlink carrier frequency and `-s` sets the SSB start subcarrier. + +Additionally, at UE side `--uecap_file` option can be used to pass the UE Capabilities input file (path location + filename), e.g. `--uecap_file ../../../targets/PROJECTS/GENERIC-NR-5GC/CONF/uecap.xml` ## IF setup with OAI diff --git a/doc/SW-archi-graph.md b/doc/SW-archi-graph.md new file mode 100644 index 0000000000000000000000000000000000000000..8f8a6f6e5cf1ed944d291c8e9fc02f48002c522a --- /dev/null +++ b/doc/SW-archi-graph.md @@ -0,0 +1,75 @@ +```mermaid +flowchart TB + A[ru_thread] --> RFin>block rx_rf] --> feprx + feprx --> half-slot --> end_feprx + feprx --> second-thread -- block_end_feprx --> end_feprx>feprx] + end_feprx --> rx_nr_prach_ru +rx_nr_prach_ru -- block_queue_singleton --> resp_L1>resp L1] +resp_L1 -- async launch --> rx_func +resp_L1 -- immediate return --> RFin + +subgraph rxfunc +rx_func_implem[rx_func] + subgraph rxfuncbeg + handle_nr_slot_ind + --> rnti_to_remove-mgmt + --> L1_nr_prach_procedures + --> apply_nr_rotation_ul + end + subgraph phy_procedures_gNB_uespec_RX + fill_ul_rb_mask + --> pucch(decode each gNB->pucch) + -->nr_fill_ul_indication + --> nr_ulsch_procedures + --> nr_ulsch_decoding + --> segInParallel[[all segments decode in parallel]] + --> barrier_end_of_ulsch_decoding + end + subgraph NR_UL_indication + handle_nr_rach + --> handle_nr_uci + --> handle_nr_ulsch + subgraph gNB_dlsch_ulsch_scheduler + run_pdcp + --> nr_rrc_trigger + --> schedule_xxxx + end + handle_nr_ulsch --> gNB_dlsch_ulsch_scheduler + subgraph NR_Schedule_response + L1_tx_free3>L1_tx_free] + --> handle_nr_nfapi_xxx_pdu + --> sendTxFilled((L1_tx_filled)) + --> nr_fill_ul_xxx + --> nr_fill_prach + end + gNB_dlsch_ulsch_scheduler --> NR_Schedule_response + end + rx_func_implem --> rxfuncbeg + rxfuncbeg --> phy_procedures_gNB_uespec_RX +phy_procedures_gNB_uespec_RX --> NR_UL_indication +-- block_queue_block_PNF_monolithic --> L1_tx_free2>L1 tx filled] +-- async launch --> tx_func +L1_tx_free2 -- send_msg --> rsp((resp_L1)) +end +rx_func --> rxfunc + + +subgraph tx_func + direction LR + subgraph phy_procedures_gNB_TX + dcitop[nr_generate dci top] + --> nr_generate_csi_rs + --> apply_nr_rotation + -- send_msg --> end_tx_func((L1_tx_out)) + end + subgraph tx_reorder_thread + L1_tx_out>L1_tx_out] + --> reorder{re order} --> reorder + reorder --> ru_tx_func + reorder --> L1_tx_free((L1_tx_free)) + ru_tx_func --> feptx_prec + --> feptx_ofdm + end +end + +``` diff --git a/doc/SW_archi.md b/doc/SW_archi.md index e5856d63bc73ac1486b807236d9eea2aca66e34f..0e77cfa580afa5647df6173fc9458adef0f23f20 100644 --- a/doc/SW_archi.md +++ b/doc/SW_archi.md @@ -17,6 +17,70 @@ body { </style> +```mermaid +flowchart TB + A[ru_thread] --> RFin>block rx_rf] --> feprx + feprx --> half-slot --> end_feprx + feprx --> second-thread -- block_end_feprx --> end_feprx>feprx] + end_feprx --> rx_nr_prach_ru +rx_nr_prach_ru -- block_queue --> resp_L1>resp L1] +resp_L1 -- async launch --> rx_func +resp_L1 -- immediate return --> RFin + +subgraph rxfunc +rx_func_implem[rx_func] + subgraph rxfuncbeg + handle_nr_slot_ind + --> rnti_to_remove-mgmt + --> L1_nr_prach_procedures + --> apply_nr_rotation_ul + end + subgraph phy_procedures_gNB_uespec_RX + fill_ul_rb_mask + --> pucch(decode each gNB->pucch) + -->nr_fill_ul_indication + --> nr_ulsch_procedures + --> nr_ulsch_decoding + --> segInParallel[[all segments decode in parallel]] + --> barrier_end_of_ulsch_decoding + end + subgraph NR_UL_indication + handle_nr_rach + --> handle_nr_uci + --> handle_nr_ulsch + --> gNB_dlsch_ulsch_scheduler + --> NR_Schedule_response + end + rx_func_implem --> rxfuncbeg + rxfuncbeg --> phy_procedures_gNB_uespec_RX +phy_procedures_gNB_uespec_RX --> NR_UL_indication +-- block_queue --> L1_tx_free2>L1 tx free] +-- async launch --> tx_func +L1_tx_free2 -- send_msg --> rsp((resp_L1)) +end +rx_func --> rxfunc + + +subgraph tx + direction LR + subgraph tx_func2 + phy_procedures_gNB_TX + --> dcitop[nr_generate dci top] + --> nr_generate_csi_rs + --> apply_nr_rotation + -- send_msg --> end_tx_func((L1_tx_out)) + end + subgraph tx_reorder_thread + L1_tx_out>L1_tx_out] + --> reorder{re order} --> reorder + reorder --> ru_tx_func + reorder --> L1_tx_free((L1_tx_free)) + ru_tx_func --> feptx_prec + --> feptx_ofdm + end + tx_func2 --> tx_reorder_thread +end +``` This tuto for 5G gNB design, with Open Cells main {: .text-center} @@ -304,25 +368,36 @@ gtpv1u_create_s1u_tunnel(), delete tunnel, ... functions are called inside the o # New GTP ## initialization -Coexistance until full merge with legacy GTP -cmake new option: NEW_GTPU to use the new implementation (it changes for the entire executable) -It is possible to use both old and new GTP in same executable because the itti task and all functions names are different -Current status of new implementation: not tested, X2 not developped, 5G new GTP option not developped, remain issues on data coming from void: muid, enb_flag, ... ocp_gtpv1uTask(): this creates only the thread, doesn't configure anything gtpv1Init(): creates a listening socket to Linux for a given reception and select a local IP address -newGtpuCreateTunnel() this function will replace the xxx_create_tunnel_xxx() for various cases -This creates a outgoing context for a teid (in input), it computes and return the incoming teid that will be used for incoming packets -These teids and in a "instance", so in a Linux socket: same teid can co-exist for different sockets - Remain here a lack to fill: the information given in the legacy funtions is not enough to fullfil the data needed by the callback -stuff like enb_flag, but also mui and more important data are not given explicitly by any legacy function (gtpv1u_create_s1u_tunnel), but the legacy and the new interface to lower layer (like pdcp) require this data. -The datamodel is still not fully understood, so this data source remain unknown -A new parameter is the callback function: will be pdpcp_data_req() and gtpv_data_req() (x2 case) for existing implementation and later other call backs like the F1-U implementation. - -incoming packets -the gtp layer retrieves the data, the teid, find out the related data: rnti, bearer and quite a lot of other parameters (not clear why, because it looks like all is statefull, so the lower layer should have the context) -if lower layers can be stateless, it is a good idea to keep the context in the gtp layer and pass it to the callback, but the design remain obfuscated. +## newGtpuCreateTunnel() +this function will replace the xxx_create_tunnel_xxx() for various cases +The parameters are: +1. outgoing TEid, associated with outpoing pair(rnti, id) +2. incoming packets callback, incoming pair(rnti,id) and a callback function for incoming data + +## outgoing packets + +Each call to newGtpuCreateTunnel() creates a outgoing context for a teid (given as function input), a pair(rnti,outgoing id). + Each outgoing packet received on GTP-U ITTI queue must match one pair(rnti,id), so the gtp-u thread can lookup the related TEid and use it to encode the outpoing GTP-U tunneled packet. + +## incoming packets + +newGtpuCreateTunnel() computes and return the incoming teid that will be used for incoming packets. +When a incoming packet arrives on this incoming teid, the GTP-U thread calls the defined callback, with the associated pair(rnti, incoming id). + +stuff like enb_flag, mui and more important data are not given explicitly by any legacy function (gtpv1u_create_s1u_tunnel), but the legacy and the new interface to lower layer (like pdcp) require this data. We hardcode it in first version. + +## remaining work +These teids and "instance", so in a Linux socket: same teid can co-exist for different sockets + Remain here a lack to fill: the information given in the legacy funtions is not enough to fullfil the data needed by the callback + +Coexistance until full merge with legacy GTP +cmake new option: NEW_GTPU to use the new implementation (it changes for the entire executable) +It is possible to use both old and new GTP in same executable because the itti task and all functions names are different +Current status of new implementation: not tested, X2 not developped, 5G new GTP option not developped, remain issues on data coming from void: muid, enb_flag, ... # NGAP NGAP would be a itti thread as is S1AP (+twin thread SCTP that is almost void processing)? diff --git a/doc/TESTING_5GSA_setup.md b/doc/TESTING_5GSA_setup.md index 475123c99094e9cce304418fe9e7a97c8d83a392..048d8c86ff2e7a212693f3c1a65becef2bfa962f 100644 --- a/doc/TESTING_5GSA_setup.md +++ b/doc/TESTING_5GSA_setup.md @@ -95,7 +95,7 @@ To get the code and build the gNB executable: ./build_oai --gNB -w USRP ``` -A reference configuration file for the gNB is provided [here](https://gitlab.eurecom.fr/oai/openairinterface5g/-/blob/develop/targets/PROJECTS/GENERIC-NR-5GC/CONF/gnb.sa.band78.fr1.106PRB.usrpb210.conf). +A reference configuration file for the **monolithic** gNB is provided [here](https://gitlab.eurecom.fr/oai/openairinterface5g/-/blob/develop/targets/PROJECTS/GENERIC-NR-5GC/CONF/gnb.sa.band78.fr1.106PRB.usrpb210.conf). In the following, we highlight the fields of the file that have to be configured according to the configuration and interfaces of the Core Network. First, the PLMN section has to be filled with the proper values that match the configuration of the AMF and the UE USIM. @@ -194,6 +194,8 @@ The SA setup with OAI UE has been validated with **RFSIMULATOR**. Both control p In the following, we provide the instructions on how to build, configure and execute this SA setup. +As another option, if you do not want to build anything and instead deploy the OAI RAN (RFSIMULATOR) and Core Network components directly using docker images and docker-compose, please have a look at [this tutorial](https://gitlab.eurecom.fr/oai/openairinterface5g/-/blob/develop/ci-scripts/yaml_files/5g_rfsimulator/README.md). + ### NAS configuration for the OAI UE The NAS configuration parameters of the OAI UE can be set as input parameters, configuration file or can be hardcoded. More specifically: - SUCI (*Subscription Concealed Identifier*) @@ -245,7 +247,6 @@ The gNB configuration can be performed according to what is described in [sectio ## 2.2 OAI 5G Core Network installation and configuration The instructions for the installation of OAI CN components (AMF, SMF, NRF, UPF) using `docker-compose` can be found [here](https://gitlab.eurecom.fr/oai/cn5g/oai-cn5g-fed/-/blob/master/README.md). -In addition, if you do not want to build anything, please have a look at [this tutorial](https://gitlab.eurecom.fr/oai/openairinterface5g/-/blob/develop/ci-scripts/yaml_files/5g_rfsimulator/README.md). ## 2.3 Execution of SA scenario diff --git a/doc/episys/Channel_Abstraction_UE_Handling_LTE.PNG b/doc/episys/Channel_Abstraction_UE_Handling_LTE.PNG new file mode 100644 index 0000000000000000000000000000000000000000..5e40d6ac1716057a941edbc79f5234d0b7d7b539 Binary files /dev/null and b/doc/episys/Channel_Abstraction_UE_Handling_LTE.PNG differ diff --git a/doc/episys/Proxy_Interface_Diagram.PNG b/doc/episys/Proxy_Interface_Diagram.PNG new file mode 100644 index 0000000000000000000000000000000000000000..a734f3d4b0010dd5998d064139fe49deb7727fc6 Binary files /dev/null and b/doc/episys/Proxy_Interface_Diagram.PNG differ diff --git a/doc/episys/functional_diagram_proxy_lte.png b/doc/episys/functional_diagram_proxy_lte.png new file mode 100644 index 0000000000000000000000000000000000000000..e2a3a2c8684f39fa91c34f9c41b2ee8bad26480a Binary files /dev/null and b/doc/episys/functional_diagram_proxy_lte.png differ diff --git a/doc/episys/functional_diagram_proxy_nsa.png b/doc/episys/functional_diagram_proxy_nsa.png new file mode 100644 index 0000000000000000000000000000000000000000..4a555d12ea2a91474b496878faaf630ab4c25c8d Binary files /dev/null and b/doc/episys/functional_diagram_proxy_nsa.png differ diff --git a/doc/episys/lte_mode_l2_emulator/README.txt b/doc/episys/lte_mode_l2_emulator/README.txt new file mode 100644 index 0000000000000000000000000000000000000000..7b555b84426c84c79f1176134a480a6fe178db8a --- /dev/null +++ b/doc/episys/lte_mode_l2_emulator/README.txt @@ -0,0 +1,49 @@ +There are fundamental changes to the L2 emulation mechanism; these changes allow the +user to run multiple UEs in separate Linux processes/machines/VMs/etc. They use a separate +entity between the UE(s) and eNB. The UEs use nFAPI to communicate with the eNB. The +nFAPI interface allows us to run in an emulated layer 2 mode, meaning that we are bypassing +the layer 1 (PHY) functionality. Because we are bypassing the PHY layer, +channel modeling capabilties have been added in the LTE UE phy_stub_ue.c file. To understand +the interfaces between the different components associated with LTE mode, the image +functional_diagram_proxy_lte.png has been provided. + +This functionality allows the user to plug in their own channel model and emulate the packet dropping procedure +in real time. The channel modeling has not been provided by EpiSci, but the OAI code +base already has some BLER curves available for use. The channel modeling functionality +that is included in the phy_stub_ue.c file only includes the downlink channel modeling. +Any uplink channel modeling must be conducted in some sort of proxy, which would sit +between the UEs and eNB. (A description of the downlink channel modeling is shown in the +Channel_Abstraction_UE_Handling_LTE.PNG image). + +The updates to the OAI code base removed some latent bugs, added multi-UE scalability, +and were tested with a standard bypass proxy between the UE(s) and eNB. The bypass proxy is +publicly available on GitHub (https://github.com/EpiSci/oai-lte-multi-ue-proxy). With this package, +various multi-UE scenarios can be tested without the overhead of PHY-layer features +of underlying radios. The features added in the L2 Emulator Mode for LTE are: + + - Ease of use of gprof and address sanitizer for debugging purposes + - Updated json files to allow for GDB, real-time debugging capabilities + - Updated logging features to minimally log only key connection milestones. This improves scalability of multiple UEs. +The logging mechanism described here is located in the log.c and log.h files. The LOG_MINIMAL +function allows us to remove most OAI logging and includes LOG_A(...) logs and above. The LOG_A +logs were chosen as analysis logs to meet EpiSci's internal testing procedure. The LOG_As +only include logs that are considered to be milestones in a given test. For example, a +log indicating that the RACH procedure has been completed for LTE. To select full logging, +set LOG_MINIMAL = 0 in the log.h file. + - Updated logging to include time stamp for timing analysis + - Updated memory allocation procedures to correct size requirements + - Added debugging features to handle signal terminations + - nfapi.c pullarray8 fix invalid pointer math + - Overlapping destination and source memory in memcpy, so updated to memmove to check for this bug + - Advanced error checking mechanisms in critical pack and unpack functions + - Created option for CPU assignment to UE to improve scalability + - Added EPC integration to allow multiple individual UE entities to each have their USIM information parsed by the executables + - Updated random value seeds to minimize probability of error in generation of random values + - Enables capability round robin scheduler if desired + - Enables capability real time scheduler if desired + - Added new standalone functions to the UE phy-layer (phy_stub_ue.c) to incorporate individual UE entities + - Updated sending and packing functions in UE (lte_ue.c) to incorporate new standalone changes + - Incorporated semaphores to control timing of incoming downlink packets + - Implemented new queuing system to handle message exchange from UE to eNB and vice versa + - Updated global value in nFAPI for size of subframe + - Updated global value to increase scalability in system diff --git a/doc/episys/nsa_mode_l2_emulator/README.txt b/doc/episys/nsa_mode_l2_emulator/README.txt new file mode 100644 index 0000000000000000000000000000000000000000..fefaf63f4479c019ac5107c990d33d850d4b110f --- /dev/null +++ b/doc/episys/nsa_mode_l2_emulator/README.txt @@ -0,0 +1,94 @@ +There are fundamental changes to the L2 emulation mechanism; these changes allow the +user to run multiple UEs in separate Linux processes/machines/VMs/etc. They use a separate +entity between the UE(s) and eNB/gNB. The UEs use nFAPI to communicate with the eNB/gNB. The +nFAPI interface allows us to run in an emulated L2 mode, meaning that we are bypassing +the layer 1 (PHY) layer functionality. Becasue we are bypassing the PHY layer, special +channel modeling capabilty has been added in the LTE UE phy_stub_ue.c file. To understand +the interfaces between the different components associated with NSA mode, the image +functional_diagram_proxy_nsa.png has been provided. + +This functionality allows the user to plug in their own channel model and emulate the packet dropping procedure +in real time. The channel modeling has not been provided by EpiSci, but the OAI code +base already has some BLER curves available for use. The chanel modeling functionality +that is included in the phy_stub_ue.c file only includes the downlink channel modeling. +Any uplink channel modeling must be conducted in some sort of proxy, which would sit +between the UEs and eNB/gNB. (A description of the downlink channel modeling is shown in the +Channel_Abstraction_UE_Handling_LTE.PNG image). + +The updates to the OAI code base removed some latent bugs, added multi-UE scalability, +and were tested with a standard bypass proxy between the UE(s) and eNB/gNB. The bypass proxy is +publicly available on GitHub (https://github.com/EpiSci/oai-lte-multi-ue-proxy). With this package, +various multi-UE scenarios can be tested without the overhead of PHY-layer features +of underlying radios. The added features to the OAI code base are listed below. + + - Ease of use of gprof and address sanitizer for debugging purposes + - Updated json files to allow for GDB, real-time debugging capabilities + - Updated logging features to minimally log only key connection milestones. This improves scalability of multiple UEs. +The logging mechanism described here is located in the log.c and log.h files. The LOG_MINIMAL +function allows us to remove most logs and include LOG_A(...) logs and above. The LOG_A +logs were chosen as analysis logs to meet EpiSci's internal testing procedure. The LOG_As +only include logs that are considered to be milestones in a given test. For example, a +log indicating that the CFRA procedure has been completed for NSA mode. To revert to full logging, +set LOG_MINIMAL = 0 in the log.h file. + - Updated logging to include time stamp for timing analysis + - Updated memory allocation procedures to correct size requirements + - Added debugging features to handle signal terminations + - nfapi.c pullarray8 fix invalid pointer math + - Overlapping destination and source memory in memcpy, so updated to memmove to check for this bug + - Advanced error checking mechanisms in critical pack and unpack functions + - Created option for CPU assignment to UE to improve scalability + - Added EPC integration to allow multiple individual UE entities to each have their USIM information parsed by the executables + - Updated random value seeds to minimize probability of error in generation of random values + - Enables capability round robin scheduler if desired + - Enables capability real time scheduler if desired + - Added new standalone functions to the UE phy-layer (phy_stub_ue.c) to incorporate individual UE entities + - Updated sending and packing functions in UE (lte_ue.c) to incorporate new standalone changes + - Incorporated semaphores to control timing of incoming downlink packets + - Implemented new queuing system to handle message exchange from UE to eNB and vice versa + - Updated global value in nFAPI for size of subframe + - Updated global value to increase scalability in system + + +Additionally, NSA mode includes the establishment between an NR UE and the gNB via the LTE UE and eNB +connection. For NSA mode, the downlink channel abstraction has not been added to the feature set yet. +NSA mode has been tested and is fully functional with EpiSci's public version of the nFAPI proxy +located at https://github.com/EpiSci/oai-lte-multi-ue-proxy +NSA mode establishment includes the following steps: + + - First UE capability enquiry is sent to NR UE + - NR UE updates and fills first capability enquiry + - eNB request for a measurement report + - Measurement request is sent to NR UE + - Measurement report is filled in NR UE + - Measurement report is received in eNB + - Request for second UE capability enquiry + - Send second enquiry to NR UE + - Second capability information is filled by NR UE + - Second capability information is sent to eNB + - NR UE capability information is received in gNB + - Periodic measurement report received in gNB + - RRCReconfigurationRequest is sent to NR UE + - RRCReconfigurationComplete is sent from NR UE + - RACH is received in the gNB + - RAR is received in NR UE + - Msg 3 is generated and sent to gNB + - CFRA procedure is complete + +Please note, the current status is: + - A single NSA UE is able to ping an external source + - Up to 4 NSA UEs can complete the CFRA procedure with a single gNB + - UE-to-UE traffic is still in work (incomplete due to gNB crashing) + - The gNB is crashing regularly and is still in work + +Test Setup: +For launching the multi-UE for NSA mode, there is a provided test script in the +public EpiSci GitHub multi-ue-proxy repository. However, a brief outline of the +test set up is included below. + + If running multiple NSA UEs in a single machine, you will need to launch + multiple LTE and NR UE processes. For example, to launch a 2 NSA UE scenario + there will be a total of 7 processes running for this particular scenario. + These processes are LTE UE #1, LTE UE #2, NR UE #1, NR UE #2, eNB, gNB and the + proxy. A detailed description of the launch processes can be found at + https://github.com/EpiSci/oai-lte-multi-ue-proxy/blob/master/README.md + diff --git a/doc/testing_gnb_w_cots_ue_resources/gnb.conf b/doc/testing_gnb_w_cots_ue_resources/gnb.conf index 97935f92eef7a603ac02ba373e0591790c1dfd7b..aae22a92bac58dce87a8ddf94324f04469555243 100755 --- a/doc/testing_gnb_w_cots_ue_resources/gnb.conf +++ b/doc/testing_gnb_w_cots_ue_resources/gnb.conf @@ -53,29 +53,7 @@ gNBs = #pdcch-ConfigCommon initialDLBWPcontrolResourceSetZero = 0; 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=2,L=12 - initialDLBWPstartSymbolAndLength_1 = 53; - - initialDLBWPk0_2 = 0; - initialDLBWPmappingType_2 = 0; - #this is SS=1,L=12 - initialDLBWPstartSymbolAndLength_2 = 54; - - initialDLBWPk0_3 = 0; - initialDLBWPmappingType_3 = 0; - #this is SS=1,L=4 //5 (4 is for 43, 5 is for 57) - initialDLBWPstartSymbolAndLength_3 = 57; //43; //57; + #uplinkConfigCommon #frequencyInfoUL ul_frequencyBand = 78; @@ -129,21 +107,6 @@ gNBs = # restrictedSetConfig # 0=unrestricted, 1=restricted type A, 2=restricted type B restrictedSetConfig = 0, - # pusch-ConfigCommon (up to 16 elements) - initialULBWPk2_0 = 2; - initialULBWPmappingType_0 = 1 - # this is SS=0 L=11 - initialULBWPstartSymbolAndLength_0 = 55; - - initialULBWPk2_1 = 2; - initialULBWPmappingType_1 = 1; - # this is SS=0 L=12 - initialULBWPstartSymbolAndLength_1 = 69; - - initialULBWPk2_2 = 7; - initialULBWPmappingType_2 = 1; - # this is SS=10 L=4 - initialULBWPstartSymbolAndLength_2 = 52; msg3_DeltaPreamble = 1; p0_NominalWithGrant =-90; diff --git a/docker/Dockerfile.ran.rhel8.2 b/docker/Dockerfile.base.rhel8.2 similarity index 95% rename from docker/Dockerfile.ran.rhel8.2 rename to docker/Dockerfile.base.rhel8.2 index 4d15220ca8f4c8c9c6ed53285975d13bc766bf76..3050f09849870f6c03f67114c68813d4c54f564b 100644 --- a/docker/Dockerfile.ran.rhel8.2 +++ b/docker/Dockerfile.base.rhel8.2 @@ -26,7 +26,7 @@ #--------------------------------------------------------------------- -FROM registry.access.redhat.com/ubi8/ubi:latest AS ran-build +FROM registry.access.redhat.com/ubi8/ubi:latest AS ran-base ARG NEEDED_GIT_PROXY ENV TZ=Europe/Paris ENV BUILD_UHD_FROM_SOURCE=True @@ -66,6 +66,5 @@ COPY . . RUN /bin/sh oaienv && \ cd cmake_targets && \ mkdir -p log && \ - ./build_oai -I -w USRP - -RUN rm /etc/pki/entitlement/*pem + ./build_oai -I -w USRP && \ + rm /etc/pki/entitlement/*pem diff --git a/docker/Dockerfile.ran.ubuntu18 b/docker/Dockerfile.base.ubuntu18 similarity index 98% rename from docker/Dockerfile.ran.ubuntu18 rename to docker/Dockerfile.base.ubuntu18 index 3ef81ec030235f58634b89864e3f8896d24b74fc..ca23688430d2153ed1db91ba7cd3683d2b047187 100644 --- a/docker/Dockerfile.ran.ubuntu18 +++ b/docker/Dockerfile.base.ubuntu18 @@ -26,7 +26,7 @@ #--------------------------------------------------------------------- -FROM ubuntu:bionic AS ran-build +FROM ubuntu:bionic AS ran-base ARG NEEDED_GIT_PROXY ENV DEBIAN_FRONTEND=noninteractive ENV TZ=Europe/Paris diff --git a/docker/Dockerfile.build.rhel8.2 b/docker/Dockerfile.build.rhel8.2 new file mode 100644 index 0000000000000000000000000000000000000000..22486c5e68082826d47a67cd88c4c4ddcf471fb5 --- /dev/null +++ b/docker/Dockerfile.build.rhel8.2 @@ -0,0 +1,38 @@ +#/* +# * 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 Ubuntu 18.04 +# +#--------------------------------------------------------------------- + +FROM ran-base:latest as ran-build + +RUN rm -Rf /oai-ran +WORKDIR /oai-ran +COPY . . + +#run build_oai to build the target image +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 diff --git a/docker/Dockerfile.build.ubuntu18 b/docker/Dockerfile.build.ubuntu18 new file mode 100644 index 0000000000000000000000000000000000000000..3ba1e41442f6c653f22dc2a9dd62aae50e3af979 --- /dev/null +++ b/docker/Dockerfile.build.ubuntu18 @@ -0,0 +1,38 @@ +#/* +# * 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 Ubuntu 18.04 +# +#--------------------------------------------------------------------- + +FROM ran-base:latest as ran-build + +RUN rm -Rf /oai-ran +WORKDIR /oai-ran +COPY . . + +# build all targets so final targets can be created afterwards +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 diff --git a/docker/Dockerfile.eNB.rhel8.2 b/docker/Dockerfile.eNB.rhel8.2 index 0522271df013f32bd9038186853d7c62149d2a45..6c921a493226808c49ac80dde8d55dcf697c65a9 100644 --- a/docker/Dockerfile.eNB.rhel8.2 +++ b/docker/Dockerfile.eNB.rhel8.2 @@ -25,19 +25,12 @@ # #--------------------------------------------------------------------- -FROM ran-build:latest AS enb-build - -RUN rm -Rf /oai-ran -WORKDIR /oai-ran -COPY . . +FROM ran-base:latest AS enb-base -#run build_oai to build the target image -RUN /bin/sh oaienv && \ - cd cmake_targets && \ - mkdir -p log && \ - ./build_oai --eNB --ninja -w USRP --verbose-ci +FROM ran-build:latest AS enb-build -RUN python3 ./docker/scripts/generateTemplate.py ./docker/scripts/enb_parameters.yaml +RUN python3 ./docker/scripts/generateTemplate.py ./docker/scripts/enb_parameters.yaml && \ + cp /oai-ran/docker/scripts/enb_entrypoint.sh /oai-ran/docker/scripts/entrypoint.sh #start from scratch for target executable FROM registry.access.redhat.com/ubi8/ubi:latest as oai-enb @@ -62,50 +55,57 @@ RUN yum update -y && \ 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 . -COPY --from=enb-build /oai-ran/docker/scripts/enb_entrypoint.sh entrypoint.sh - -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/libtcp_bridge_oai.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 \ + /oai-ran/targets/bin/lte-softmodem.Rel15 \ + /oai-ran/docker/scripts/entrypoint.sh \ + ./ + +COPY --from=enb-build \ + /oai-ran/cmake_targets/ran_build/build/liboai_eth_transpro.so \ + /oai-ran/cmake_targets/ran_build/build/libtcp_bridge_oai.so \ + /oai-ran/cmake_targets/ran_build/build/librfsimulator.so \ + /oai-ran/cmake_targets/ran_build/build/liboai_usrpdevif.so \ + /oai-ran/cmake_targets/ran_build/build/libcoding.so \ + /oai-ran/cmake_targets/ran_build/build/libparams_libconfig.so \ + /oai-ran/cmake_targets/ran_build/build/libdfts.so \ + /oai-ran/cmake_targets/ran_build/build/liboai_iqplayer.so \ + /oai-ran/cmake_targets/ran_build/build/libtelnetsrv.so \ + /oai-ran/cmake_targets/ran_build/build/libtelnetsrv_enb.so \ + /usr/local/lib/ + +COPY --from=enb-base \ + /lib64/libconfig.so.9 \ + /lib64/libblas.so.3 \ + /lib64/liblapack.so.3 \ + /lib64/liblapacke.so.3 \ + /lib64/libboost_chrono.so.1.66.0 \ + /lib64/libboost_date_time.so.1.66.0 \ + /lib64/libboost_filesystem.so.1.66.0 \ + /lib64/libboost_program_options.so.1.66.0 \ + /lib64/libboost_serialization.so.1.66.0 \ + /lib64/libboost_thread.so.1.66.0 \ + /lib64/libboost_system.so.1.66.0 \ + /lib64/libboost_unit_test_framework.so.1.66.0 \ + /lib64/libboost_atomic.so.1.66.0 \ + /lib64/libboost_timer.so.1.66.0 \ + /lib64/libboost_regex.so.1.66.0 \ + /lib64/libicudata.so.60 \ + /lib64/libicui18n.so.60 \ + /lib64/libicuuc.so.60 \ + /lib64/ + # Now we are copying from builder-image the UHD files. -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 /lib64/libboost_regex.so.1.66.0 /lib64 - -COPY --from=enb-build /usr/local/bin/uhd_find_devices /usr/local/bin -COPY --from=enb-build /usr/local/lib64/libuhd.so.3.15.0 /usr/local/lib64 -COPY --from=enb-build /usr/local/lib64/uhd/utils/uhd_images_downloader.py /opt/oai-enb/bin +COPY --from=enb-base /usr/local/bin/uhd_find_devices /usr/local/bin +COPY --from=enb-base /usr/local/lib/libprotobuf-c.so.1 /usr/local/lib +COPY --from=enb-base /usr/local/lib64/libuhd.so.3.15.0 /usr/local/lib64 +COPY --from=enb-base /usr/local/lib64/uhd/utils/uhd_images_downloader.py /opt/oai-enb/bin WORKDIR /usr/local/share/uhd/rfnoc -COPY --from=enb-build /usr/local/share/uhd/rfnoc/ . +COPY --from=enb-base /usr/local/share/uhd/rfnoc/ . -RUN ldconfig +RUN /bin/bash -c "ln -s /usr/local/lib/liboai_usrpdevif.so /usr/local/lib/liboai_device.so" && \ + ldconfig # Copy the relevant configuration files for eNB WORKDIR /opt/oai-enb/etc diff --git a/docker/Dockerfile.eNB.ubuntu18 b/docker/Dockerfile.eNB.ubuntu18 index 360bf2e7cf17e51a96791b1b41ebf2ee545500fe..1f375a20dc9ab0725258024ad1433128008946c8 100644 --- a/docker/Dockerfile.eNB.ubuntu18 +++ b/docker/Dockerfile.eNB.ubuntu18 @@ -25,19 +25,12 @@ # #--------------------------------------------------------------------- -FROM ran-build:latest AS enb-build - -RUN rm -Rf /oai-ran -WORKDIR /oai-ran -COPY . . +FROM ran-base:latest as enb-base -#run build_oai to build the target image -RUN /bin/sh oaienv && \ - cd cmake_targets && \ - mkdir -p log && \ - ./build_oai --eNB --ninja -w USRP --verbose-ci +FROM ran-build:latest AS enb-build -RUN python3 ./docker/scripts/generateTemplate.py ./docker/scripts/enb_parameters.yaml +RUN python3 ./docker/scripts/generateTemplate.py ./docker/scripts/enb_parameters.yaml && \ + cp /oai-ran/docker/scripts/enb_entrypoint.sh /oai-ran/docker/scripts/entrypoint.sh #start from scratch for target executable FROM ubuntu:bionic as oai-enb @@ -48,6 +41,7 @@ RUN apt-get update && \ DEBIAN_FRONTEND=noninteractive apt-get upgrade --yes && \ DEBIAN_FRONTEND=noninteractive apt-get install --yes \ software-properties-common \ + tzdata \ procps \ libsctp1 \ libnettle6 \ @@ -68,37 +62,43 @@ RUN apt-get update && \ rm -rf /var/lib/apt/lists/* WORKDIR /opt/oai-enb/bin -COPY --from=enb-build /oai-ran/targets/bin/lte-softmodem.Rel15 . -COPY --from=enb-build /oai-ran/docker/scripts/enb_entrypoint.sh entrypoint.sh +COPY --from=enb-build \ + /oai-ran/targets/bin/lte-softmodem.Rel15 \ + /oai-ran/docker/scripts/entrypoint.sh \ + ./ -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/libtcp_bridge_oai.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 \ + /oai-ran/cmake_targets/ran_build/build/liboai_eth_transpro.so \ + /oai-ran/cmake_targets/ran_build/build/libtcp_bridge_oai.so \ + /oai-ran/cmake_targets/ran_build/build/librfsimulator.so \ + /oai-ran/cmake_targets/ran_build/build/liboai_usrpdevif.so \ + /oai-ran/cmake_targets/ran_build/build/libcoding.so \ + /oai-ran/cmake_targets/ran_build/build/libparams_libconfig.so \ + /oai-ran/cmake_targets/ran_build/build/libdfts.so \ + /oai-ran/cmake_targets/ran_build/build/liboai_iqplayer.so \ + /oai-ran/cmake_targets/ran_build/build/libtelnetsrv.so \ + /oai-ran/cmake_targets/ran_build/build/libtelnetsrv_enb.so \ + /usr/local/lib/ -COPY --from=enb-build /usr/local/lib/libprotobuf-c.so.1 . # Now we are copying from builder-image the UHD files. -COPY --from=enb-build /usr/local/bin/uhd_find_devices /usr/local/bin -COPY --from=enb-build /usr/local/lib/libuhd.so.3.15.0 /usr/local/lib -COPY --from=enb-build /usr/local/lib/uhd/utils/uhd_images_downloader.py /opt/oai-enb/bin -WORKDIR /usr/lib/x86_64-linux-gnu -COPY --from=enb-build /usr/lib/x86_64-linux-gnu/libboost_date_time.so.1.65.1 . -COPY --from=enb-build /usr/lib/x86_64-linux-gnu/libboost_filesystem.so.1.65.1 . -COPY --from=enb-build /usr/lib/x86_64-linux-gnu/libboost_regex.so.1.65.1 . -COPY --from=enb-build /usr/lib/x86_64-linux-gnu/libboost_serialization.so.1.65.1 . -COPY --from=enb-build /usr/lib/x86_64-linux-gnu/libboost_thread.so.1.65.1 . -COPY --from=enb-build /usr/lib/x86_64-linux-gnu/libboost_system.so.1.65.1 . -COPY --from=enb-build /usr/lib/x86_64-linux-gnu/libboost_program_options.so.1.65.1 . +COPY --from=enb-base /usr/local/bin/uhd_find_devices /usr/local/bin +COPY --from=enb-base \ + /usr/local/lib/libuhd.so.3.15.0 \ + /usr/local/lib/libprotobuf-c.so.1 \ + /usr/local/lib/ +COPY --from=enb-base /usr/local/lib/uhd/utils/uhd_images_downloader.py /opt/oai-enb/bin +COPY --from=enb-base \ + /usr/lib/x86_64-linux-gnu/libboost_date_time.so.1.65.1 \ + /usr/lib/x86_64-linux-gnu/libboost_filesystem.so.1.65.1 \ + /usr/lib/x86_64-linux-gnu/libboost_regex.so.1.65.1 \ + /usr/lib/x86_64-linux-gnu/libboost_serialization.so.1.65.1 \ + /usr/lib/x86_64-linux-gnu/libboost_thread.so.1.65.1 \ + /usr/lib/x86_64-linux-gnu/libboost_system.so.1.65.1 \ + /usr/lib/x86_64-linux-gnu/libboost_program_options.so.1.65.1 \ + /usr/lib/x86_64-linux-gnu/ -RUN ldconfig +RUN /bin/bash -c "ln -s /usr/local/lib/liboai_usrpdevif.so /usr/local/lib/liboai_device.so" && \ + ldconfig # Copy the relevant configuration files for eNB WORKDIR /opt/oai-enb/etc diff --git a/docker/Dockerfile.gNB.rhel8.2 b/docker/Dockerfile.gNB.rhel8.2 index b34a9d242d094776aa3f3c0782bccc4cde5650f7..703f4c67b5e1748a9405f5e348522bc659c40b5b 100644 --- a/docker/Dockerfile.gNB.rhel8.2 +++ b/docker/Dockerfile.gNB.rhel8.2 @@ -25,19 +25,12 @@ # #--------------------------------------------------------------------- -FROM ran-build:latest AS gnb-build - -RUN rm -Rf /oai-ran -WORKDIR /oai-ran -COPY . . +FROM ran-base:latest AS gnb-base -#run build_oai to build the target image -RUN /bin/sh oaienv && \ - cd cmake_targets && \ - mkdir -p log && \ - ./build_oai --gNB --ninja -w USRP --verbose-ci +FROM ran-build:latest AS gnb-build -RUN python3 ./docker/scripts/generateTemplate.py ./docker/scripts/gnb_parameters.yaml +RUN python3 ./docker/scripts/generateTemplate.py ./docker/scripts/gnb_parameters.yaml && \ + cp /oai-ran/docker/scripts/gnb_entrypoint.sh /oai-ran/docker/scripts/entrypoint.sh #start from scratch for target executable FROM registry.access.redhat.com/ubi8/ubi:latest as oai-gnb @@ -64,54 +57,59 @@ RUN yum repolist --disablerepo=* && \ 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 . -COPY --from=gnb-build /oai-ran/docker/scripts/gnb_entrypoint.sh entrypoint.sh - -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/libtcp_bridge_oai.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 \ + /oai-ran/targets/bin/nr-softmodem.Rel15 \ + /oai-ran/docker/scripts/entrypoint.sh \ + ./ + +COPY --from=gnb-build \ + /oai-ran/cmake_targets/ran_build/build/liboai_eth_transpro.so \ + /oai-ran/cmake_targets/ran_build/build/libtcp_bridge_oai.so \ + /oai-ran/cmake_targets/ran_build/build/librfsimulator.so \ + /oai-ran/cmake_targets/ran_build/build/liboai_usrpdevif.so \ + /oai-ran/cmake_targets/ran_build/build/libcoding.so \ + /oai-ran/cmake_targets/ran_build/build/libparams_libconfig.so \ + /oai-ran/cmake_targets/ran_build/build/libdfts.so \ + /oai-ran/cmake_targets/ran_build/build/libldpc.so \ + /oai-ran/cmake_targets/ran_build/build/libldpc_optim.so \ + /oai-ran/cmake_targets/ran_build/build/libldpc_optim8seg.so \ + /oai-ran/cmake_targets/ran_build/build/libldpc_orig.so \ + /oai-ran/cmake_targets/ran_build/build/libtelnetsrv.so \ + /usr/local/lib/ + +COPY --from=gnb-base \ + /lib64/libconfig.so.9 \ + /lib64/libforms.so.2 \ + /lib64/libblas.so.3 \ + /lib64/liblapack.so.3 \ + /lib64/liblapacke.so.3 \ + /lib64/libboost_chrono.so.1.66.0 \ + /lib64/libboost_date_time.so.1.66.0 \ + /lib64/libboost_filesystem.so.1.66.0 \ + /lib64/libboost_program_options.so.1.66.0 \ + /lib64/libboost_serialization.so.1.66.0 \ + /lib64/libboost_thread.so.1.66.0 \ + /lib64/libboost_system.so.1.66.0 \ + /lib64/libboost_unit_test_framework.so.1.66.0 \ + /lib64/libboost_atomic.so.1.66.0 \ + /lib64/libboost_timer.so.1.66.0 \ + /lib64/libboost_regex.so.1.66.0 \ + /lib64/libicudata.so.60 \ + /lib64/libicui18n.so.60 \ + /lib64/libicuuc.so.60 \ + /lib64/ # Now we are copying from builder-image the UHD files. -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 /lib64/libboost_regex.so.1.66.0 /lib64 - -COPY --from=gnb-build /usr/local/bin/uhd_find_devices /usr/local/bin -COPY --from=gnb-build /usr/local/lib64/libuhd.so.3.15.0 /usr/local/lib64 -COPY --from=gnb-build /usr/local/lib64/uhd/utils/uhd_images_downloader.py /opt/oai-gnb/bin +COPY --from=gnb-base /usr/local/bin/uhd_find_devices /usr/local/bin +COPY --from=gnb-base /usr/local/lib/libprotobuf-c.so.1 /usr/local/lib +COPY --from=gnb-base /usr/local/lib64/libuhd.so.3.15.0 /usr/local/lib64 +COPY --from=gnb-base /usr/local/lib64/uhd/utils/uhd_images_downloader.py /opt/oai-gnb/bin WORKDIR /usr/local/share/uhd/rfnoc -COPY --from=gnb-build /usr/local/share/uhd/rfnoc/ . +COPY --from=gnb-base /usr/local/share/uhd/rfnoc/ . -RUN ldconfig +RUN /bin/bash -c "ln -s /usr/local/lib/liboai_usrpdevif.so /usr/local/lib/liboai_device.so" && \ + ldconfig # Copy the relevant configuration files for gNB WORKDIR /opt/oai-gnb/etc diff --git a/docker/Dockerfile.gNB.ubuntu18 b/docker/Dockerfile.gNB.ubuntu18 index 030ce80ede6422f711dcdd13d7b95ec130c662ed..24e4bcbc7c16762ea0787a9109934dfc2d517d4f 100644 --- a/docker/Dockerfile.gNB.ubuntu18 +++ b/docker/Dockerfile.gNB.ubuntu18 @@ -25,19 +25,12 @@ # #--------------------------------------------------------------------- -FROM ran-build:latest AS gnb-build - -RUN rm -Rf /oai-ran -WORKDIR /oai-ran -COPY . . +FROM ran-base:latest as gnb-base -#run build_oai to build the target image -RUN /bin/sh oaienv && \ - cd cmake_targets && \ - mkdir -p log && \ - ./build_oai --gNB --ninja -w USRP --verbose-ci +FROM ran-build:latest AS gnb-build -RUN python3 ./docker/scripts/generateTemplate.py ./docker/scripts/gnb_parameters.yaml +RUN python3 ./docker/scripts/generateTemplate.py ./docker/scripts/gnb_parameters.yaml && \ + cp /oai-ran/docker/scripts/gnb_entrypoint.sh /oai-ran/docker/scripts/entrypoint.sh #start from scratch for target executable FROM ubuntu:bionic as oai-gnb @@ -68,41 +61,45 @@ RUN apt-get update && \ rm -rf /var/lib/apt/lists/* WORKDIR /opt/oai-gnb/bin -COPY --from=gnb-build /oai-ran/targets/bin/nr-softmodem.Rel15 . -COPY --from=gnb-build /oai-ran/docker/scripts/gnb_entrypoint.sh entrypoint.sh - -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/libtcp_bridge_oai.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 . +COPY --from=gnb-build \ + /oai-ran/targets/bin/nr-softmodem.Rel15 \ + /oai-ran/docker/scripts/entrypoint.sh \ + ./ -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 \ + /oai-ran/cmake_targets/ran_build/build/liboai_eth_transpro.so \ + /oai-ran/cmake_targets/ran_build/build/libtcp_bridge_oai.so \ + /oai-ran/cmake_targets/ran_build/build/librfsimulator.so \ + /oai-ran/cmake_targets/ran_build/build/liboai_usrpdevif.so \ + /oai-ran/cmake_targets/ran_build/build/libcoding.so \ + /oai-ran/cmake_targets/ran_build/build/libparams_libconfig.so \ + /oai-ran/cmake_targets/ran_build/build/libdfts.so \ + /oai-ran/cmake_targets/ran_build/build/libldpc.so \ + /oai-ran/cmake_targets/ran_build/build/libldpc_optim.so \ + /oai-ran/cmake_targets/ran_build/build/libldpc_optim8seg.so \ + /oai-ran/cmake_targets/ran_build/build/libldpc_orig.so \ + /oai-ran/cmake_targets/ran_build/build/libtelnetsrv.so \ + /usr/local/lib/ # Now we are copying from builder-image the UHD files. -COPY --from=gnb-build /usr/local/bin/uhd_find_devices /usr/local/bin -COPY --from=gnb-build /usr/local/lib/libuhd.so.3.15.0 /usr/local/lib -COPY --from=gnb-build /usr/local/lib/uhd/utils/uhd_images_downloader.py /opt/oai-gnb/bin -WORKDIR /usr/lib/x86_64-linux-gnu -COPY --from=gnb-build /usr/lib/x86_64-linux-gnu/libboost_date_time.so.1.65.1 . -COPY --from=gnb-build /usr/lib/x86_64-linux-gnu/libboost_filesystem.so.1.65.1 . -COPY --from=gnb-build /usr/lib/x86_64-linux-gnu/libboost_regex.so.1.65.1 . -COPY --from=gnb-build /usr/lib/x86_64-linux-gnu/libboost_serialization.so.1.65.1 . -COPY --from=gnb-build /usr/lib/x86_64-linux-gnu/libboost_thread.so.1.65.1 . -COPY --from=gnb-build /usr/lib/x86_64-linux-gnu/libboost_system.so.1.65.1 . -COPY --from=gnb-build /usr/lib/x86_64-linux-gnu/libboost_program_options.so.1.65.1 . +COPY --from=gnb-base /usr/local/bin/uhd_find_devices /usr/local/bin +COPY --from=gnb-base \ + /usr/local/lib/libuhd.so.3.15.0 \ + /usr/local/lib/libprotobuf-c.so.1 \ + /usr/local/lib/ +COPY --from=gnb-base /usr/local/lib/uhd/utils/uhd_images_downloader.py /opt/oai-gnb/bin +COPY --from=gnb-base \ + /usr/lib/x86_64-linux-gnu/libboost_date_time.so.1.65.1 \ + /usr/lib/x86_64-linux-gnu/libboost_filesystem.so.1.65.1 \ + /usr/lib/x86_64-linux-gnu/libboost_regex.so.1.65.1 \ + /usr/lib/x86_64-linux-gnu/libboost_serialization.so.1.65.1 \ + /usr/lib/x86_64-linux-gnu/libboost_thread.so.1.65.1 \ + /usr/lib/x86_64-linux-gnu/libboost_system.so.1.65.1 \ + /usr/lib/x86_64-linux-gnu/libboost_program_options.so.1.65.1 \ + /usr/lib/x86_64-linux-gnu/ -RUN ldconfig +RUN /bin/bash -c "ln -s /usr/local/lib/liboai_usrpdevif.so /usr/local/lib/liboai_device.so" && \ + ldconfig # Copy the relevant configuration files for gNB WORKDIR /opt/oai-gnb/etc diff --git a/docker/Dockerfile.lteRU.rhel8.2 b/docker/Dockerfile.lteRU.rhel8.2 index 7e2a054a1291a08128e19b796ee2148b4d95571a..5addbca65565be888cb3fc07772c8e97ba23fd94 100644 --- a/docker/Dockerfile.lteRU.rhel8.2 +++ b/docker/Dockerfile.lteRU.rhel8.2 @@ -25,19 +25,12 @@ # #--------------------------------------------------------------------- -FROM ran-build:latest AS ru-build - -RUN rm -Rf /oai-ran -WORKDIR /oai-ran -COPY . . +FROM ran-base:latest AS ru-base -#run build_oai to build the target image -RUN /bin/sh oaienv && \ - cd cmake_targets && \ - mkdir -p log && \ - ./build_oai --RU --ninja -w USRP --verbose-ci +FROM ran-build:latest AS ru-build -RUN python3 ./docker/scripts/generateTemplate.py ./docker/scripts/enb_parameters.yaml +RUN python3 ./docker/scripts/generateTemplate.py ./docker/scripts/enb_parameters.yaml && \ + cp /oai-ran/docker/scripts/lte_ru_entrypoint.sh /oai-ran/docker/scripts/entrypoint.sh #start from scratch for target executable FROM registry.access.redhat.com/ubi8/ubi:latest as oai-lte-ru @@ -59,45 +52,47 @@ RUN yum update -y && \ echo "/usr/local/lib64" >> /etc/ld.so.conf.d/local-lib.conf WORKDIR /opt/oai-lte-ru/bin -COPY --from=ru-build /oai-ran/targets/bin/oairu.Rel15 . -COPY --from=ru-build /oai-ran/docker/scripts/lte_ru_entrypoint.sh entrypoint.sh - -WORKDIR /usr/local/lib/ -COPY --from=ru-build /oai-ran/targets/bin/liboai_eth_transpro.so.Rel15 . -COPY --from=ru-build /oai-ran/targets/bin/libtcp_bridge_oai.so.Rel15 . -COPY --from=ru-build /oai-ran/targets/bin/librfsimulator.so.Rel15 . -COPY --from=ru-build /oai-ran/targets/bin/liboai_usrpdevif.so.Rel15 . -COPY --from=ru-build /oai-ran/targets/bin/libparams_libconfig.so . -COPY --from=ru-build /oai-ran/cmake_targets/ran_build/build/libdfts.so . - -COPY --from=ru-build /lib64/libconfig.so.9 /lib64 -COPY --from=ru-build /lib64/libblas.so.3 /lib64 -COPY --from=ru-build /lib64/liblapack.so.3 /lib64 -COPY --from=ru-build /lib64/liblapacke.so.3 /lib64 +COPY --from=ru-build \ + /oai-ran/targets/bin/oairu.Rel15 \ + /oai-ran/docker/scripts/entrypoint.sh \ + . + +COPY --from=ru-build \ + /oai-ran/cmake_targets/ran_build/build/liboai_eth_transpro.so \ + /oai-ran/cmake_targets/ran_build/build/libtcp_bridge_oai.so \ + /oai-ran/cmake_targets/ran_build/build/librfsimulator.so \ + /oai-ran/cmake_targets/ran_build/build/liboai_usrpdevif.so \ + /oai-ran/cmake_targets/ran_build/build/libparams_libconfig.so \ + /oai-ran/cmake_targets/ran_build/build/libdfts.so \ + /usr/local/lib/ + +COPY --from=ru-base \ + /lib64/libconfig.so.9 \ + /lib64/libblas.so.3 \ + /lib64/liblapack.so.3 \ + /lib64/liblapacke.so.3 \ + /lib64/libboost_chrono.so.1.66.0 \ + /lib64/libboost_date_time.so.1.66.0 \ + /lib64/libboost_filesystem.so.1.66.0 \ + /lib64/libboost_program_options.so.1.66.0 \ + /lib64/libboost_serialization.so.1.66.0 \ + /lib64/libboost_thread.so.1.66.0 \ + /lib64/libboost_system.so.1.66.0 \ + /lib64/libboost_unit_test_framework.so.1.66.0 \ + /lib64/libboost_atomic.so.1.66.0 \ + /lib64/libboost_timer.so.1.66.0 \ + /lib64/libboost_regex.so.1.66.0 \ + /lib64/ # Copying from the ran-build image the USRP needed packages -COPY --from=ru-build /lib64/libboost_chrono.so.1.66.0 /lib64 -COPY --from=ru-build /lib64/libboost_date_time.so.1.66.0 /lib64 -COPY --from=ru-build /lib64/libboost_filesystem.so.1.66.0 /lib64 -COPY --from=ru-build /lib64/libboost_program_options.so.1.66.0 /lib64 -COPY --from=ru-build /lib64/libboost_serialization.so.1.66.0 /lib64 -COPY --from=ru-build /lib64/libboost_thread.so.1.66.0 /lib64 -COPY --from=ru-build /lib64/libboost_system.so.1.66.0 /lib64 -COPY --from=ru-build /lib64/libboost_unit_test_framework.so.1.66.0 /lib64 -COPY --from=ru-build /lib64/libboost_atomic.so.1.66.0 /lib64 -COPY --from=ru-build /lib64/libboost_timer.so.1.66.0 /lib64 -COPY --from=ru-build /lib64/libboost_regex.so.1.66.0 /lib64 - -COPY --from=ru-build /usr/local/bin/uhd_find_devices /usr/local/bin -COPY --from=ru-build /usr/local/lib64/libuhd.so.3.15.0 /usr/local/lib64 -COPY --from=ru-build /usr/local/lib64/uhd/utils/uhd_images_downloader.py /opt/oai-lte-ru/bin +COPY --from=ru-base /usr/local/bin/uhd_find_devices /usr/local/bin +COPY --from=ru-base /usr/local/lib64/libuhd.so.3.15.0 /usr/local/lib64 +COPY --from=ru-base /usr/local/lib64/uhd/utils/uhd_images_downloader.py /opt/oai-lte-ru/bin WORKDIR /usr/local/share/uhd/rfnoc -COPY --from=ru-build /usr/local/share/uhd/rfnoc/ . +COPY --from=ru-base /usr/local/share/uhd/rfnoc/ . -RUN /bin/bash -c "ln -s /usr/local/lib/liboai_eth_transpro.so.Rel15 /usr/local/lib/liboai_transpro.so" && \ - /bin/bash -c "ln -s /usr/local/lib/liboai_usrpdevif.so.Rel15 /usr/local/lib/liboai_device.so" && \ - /bin/bash -c "ln -s /usr/local/lib/librfsimulator.so.Rel15 /usr/local/lib/librfsimulator.so" && \ +RUN /bin/bash -c "ln -s /usr/local/lib/liboai_usrpdevif.so /usr/local/lib/liboai_device.so" && \ ldconfig # Copy the relevant configuration files for RRU diff --git a/docker/Dockerfile.lteRU.ubuntu18 b/docker/Dockerfile.lteRU.ubuntu18 index eafb8fa8af495631bdc0a6a88852422351ca0cc2..1f1c903a159fc19a3decf88f9f54633bef231635 100644 --- a/docker/Dockerfile.lteRU.ubuntu18 +++ b/docker/Dockerfile.lteRU.ubuntu18 @@ -25,19 +25,12 @@ # #--------------------------------------------------------------------- -FROM ran-build:latest AS ru-build - -RUN rm -Rf /oai-ran -WORKDIR /oai-ran -COPY . . +FROM ran-base:latest as ru-base -#run build_oai to build the target image -RUN /bin/sh oaienv && \ - cd cmake_targets && \ - mkdir -p log && \ - ./build_oai --RU --ninja -w USRP --verbose-ci +FROM ran-build:latest AS ru-build -RUN python3 ./docker/scripts/generateTemplate.py ./docker/scripts/enb_parameters.yaml +RUN python3 ./docker/scripts/generateTemplate.py ./docker/scripts/enb_parameters.yaml && \ + cp /oai-ran/docker/scripts/lte_ru_entrypoint.sh /oai-ran/docker/scripts/entrypoint.sh #start from scratch for target executable FROM ubuntu:bionic as oai-lte-ru @@ -64,32 +57,35 @@ RUN apt-get update && \ rm -rf /var/lib/apt/lists/* WORKDIR /opt/oai-lte-ru/bin -COPY --from=ru-build /oai-ran/targets/bin/oairu.Rel15 . -COPY --from=ru-build /oai-ran/docker/scripts/lte_ru_entrypoint.sh entrypoint.sh +COPY --from=ru-build \ + /oai-ran/targets/bin/oairu.Rel15 \ + /oai-ran/docker/scripts/entrypoint.sh \ + ./ -WORKDIR /usr/local/lib/ -COPY --from=ru-build /oai-ran/targets/bin/liboai_eth_transpro.so.Rel15 . -COPY --from=ru-build /oai-ran/targets/bin/libtcp_bridge_oai.so.Rel15 . -COPY --from=ru-build /oai-ran/targets/bin/librfsimulator.so.Rel15 . -COPY --from=ru-build /oai-ran/targets/bin/liboai_usrpdevif.so.Rel15 . -COPY --from=ru-build /oai-ran/targets/bin/libparams_libconfig.so . -COPY --from=ru-build /oai-ran/cmake_targets/ran_build/build/libdfts.so . +COPY --from=ru-build \ + /oai-ran/cmake_targets/ran_build/build/liboai_eth_transpro.so \ + /oai-ran/cmake_targets/ran_build/build/libtcp_bridge_oai.so \ + /oai-ran/cmake_targets/ran_build/build/librfsimulator.so \ + /oai-ran/cmake_targets/ran_build/build/liboai_usrpdevif.so \ + /oai-ran/cmake_targets/ran_build/build/libparams_libconfig.so \ + /oai-ran/cmake_targets/ran_build/build/libdfts.so \ + /usr/local/lib/ # Now we are copying from builder-image the UHD files. -COPY --from=ru-build /usr/local/bin/uhd_find_devices /usr/local/bin -COPY --from=ru-build /usr/local/lib/libuhd.so.3.15.0 /usr/local/lib -COPY --from=ru-build /usr/local/lib/uhd/utils/uhd_images_downloader.py /opt/oai-lte-ru/bin -WORKDIR /usr/lib/x86_64-linux-gnu -COPY --from=ru-build /usr/lib/x86_64-linux-gnu/libboost_date_time.so.1.65.1 . -COPY --from=ru-build /usr/lib/x86_64-linux-gnu/libboost_filesystem.so.1.65.1 . -COPY --from=ru-build /usr/lib/x86_64-linux-gnu/libboost_regex.so.1.65.1 . -COPY --from=ru-build /usr/lib/x86_64-linux-gnu/libboost_serialization.so.1.65.1 . -COPY --from=ru-build /usr/lib/x86_64-linux-gnu/libboost_thread.so.1.65.1 . -COPY --from=ru-build /usr/lib/x86_64-linux-gnu/libboost_system.so.1.65.1 . +COPY --from=ru-base /usr/local/bin/uhd_find_devices /usr/local/bin +COPY --from=ru-base /usr/local/lib/libuhd.so.3.15.0 /usr/local/lib +COPY --from=ru-base /usr/local/lib/uhd/utils/uhd_images_downloader.py /opt/oai-lte-ru/bin + +COPY --from=ru-base \ + /usr/lib/x86_64-linux-gnu/libboost_date_time.so.1.65.1 \ + /usr/lib/x86_64-linux-gnu/libboost_filesystem.so.1.65.1 \ + /usr/lib/x86_64-linux-gnu/libboost_regex.so.1.65.1 \ + /usr/lib/x86_64-linux-gnu/libboost_serialization.so.1.65.1 \ + /usr/lib/x86_64-linux-gnu/libboost_thread.so.1.65.1 \ + /usr/lib/x86_64-linux-gnu/libboost_system.so.1.65.1 \ + /usr/lib/x86_64-linux-gnu/ -RUN /bin/bash -c "ln -s /usr/local/lib/liboai_eth_transpro.so.Rel15 /usr/local/lib/liboai_transpro.so" && \ - /bin/bash -c "ln -s /usr/local/lib/liboai_usrpdevif.so.Rel15 /usr/local/lib/liboai_device.so" && \ - /bin/bash -c "ln -s /usr/local/lib/librfsimulator.so.Rel15 /usr/local/lib/librfsimulator.so" && \ +RUN /bin/bash -c "ln -s /usr/local/lib/liboai_usrpdevif.so /usr/local/lib/liboai_device.so" && \ ldconfig # Copy the relevant configuration files for RRU diff --git a/docker/Dockerfile.lteUE.rhel8.2 b/docker/Dockerfile.lteUE.rhel8.2 index a6814be1361333445c03e2d51a51bfbf943a84b4..f547558bdb7cab32f41da185f9ee4ca79de6a788 100644 --- a/docker/Dockerfile.lteUE.rhel8.2 +++ b/docker/Dockerfile.lteUE.rhel8.2 @@ -25,20 +25,13 @@ # #--------------------------------------------------------------------- -FROM ran-build:latest AS lte-ue-build - -RUN rm -Rf /oai-ran -WORKDIR /oai-ran -COPY . . +FROM ran-base:latest AS lte-ue-base -#run build_oai to build the target image -RUN /bin/sh oaienv && \ - cd cmake_targets && \ - mkdir -p log && \ - ./build_oai --UE --ninja -w USRP --verbose-ci +FROM ran-build:latest AS lte-ue-build RUN python3 ./docker/scripts/generateTemplate.py ./docker/scripts/lte_ue_parameters.yaml && \ - python3 ./docker/scripts/generateTemplate.py ./docker/scripts/lte_ue_sim_parameters.yaml + python3 ./docker/scripts/generateTemplate.py ./docker/scripts/lte_ue_sim_parameters.yaml && \ + cp /oai-ran/docker/scripts/lte_ue_entrypoint.sh /oai-ran/docker/scripts/entrypoint.sh #start from scratch for target executable FROM registry.access.redhat.com/ubi8/ubi:latest as oai-lte-ue @@ -63,53 +56,58 @@ RUN yum update -y && \ 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/docker/scripts/lte_ue_entrypoint.sh entrypoint.sh -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 . - -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/libtcp_bridge_oai.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 \ + /oai-ran/targets/bin/lte-uesoftmodem.Rel15 \ + /oai-ran/docker/scripts/entrypoint.sh \ + /oai-ran/targets/bin/conf2uedata \ + /oai-ran/targets/bin/nvram \ + /oai-ran/targets/bin/usim \ + ./ + +COPY --from=lte-ue-build \ + /oai-ran/cmake_targets/ran_build/build/liboai_eth_transpro.so \ + /oai-ran/cmake_targets/ran_build/build/libtcp_bridge_oai.so \ + /oai-ran/cmake_targets/ran_build/build/librfsimulator.so \ + /oai-ran/cmake_targets/ran_build/build/liboai_usrpdevif.so \ + /oai-ran/cmake_targets/ran_build/build/libcoding.so \ + /oai-ran/cmake_targets/ran_build/build/libparams_libconfig.so \ + /oai-ran/cmake_targets/ran_build/build/libSIMU.so \ + /oai-ran/cmake_targets/ran_build/build/libdfts.so \ + /oai-ran/cmake_targets/ran_build/build/libtelnetsrv.so \ + /usr/local/lib/ + +COPY --from=lte-ue-base \ + /lib64/libconfig.so.9 \ + /lib64/libblas.so.3 \ + /lib64/liblapack.so.3 \ + /lib64/liblapacke.so.3 \ + /lib64/libboost_chrono.so.1.66.0 \ + /lib64/libboost_date_time.so.1.66.0 \ + /lib64/libboost_filesystem.so.1.66.0 \ + /lib64/libboost_program_options.so.1.66.0 \ + /lib64/libboost_serialization.so.1.66.0 \ + /lib64/libboost_thread.so.1.66.0 \ + /lib64/libboost_system.so.1.66.0 \ + /lib64/libboost_unit_test_framework.so.1.66.0 \ + /lib64/libboost_atomic.so.1.66.0 \ + /lib64/libboost_timer.so.1.66.0 \ + /lib64/libboost_regex.so.1.66.0 \ + /lib64/libicudata.so.60 \ + /lib64/libicui18n.so.60 \ + /lib64/libicuuc.so.60 \ + /lib64/ # Now we are copying from builder-image the UHD files. -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 /lib64/libboost_regex.so.1.66.0 /lib64 - -COPY --from=lte-ue-build /usr/local/bin/uhd_find_devices /usr/local/bin -COPY --from=lte-ue-build /usr/local/lib64/libuhd.so.3.15.0 /usr/local/lib64 -COPY --from=lte-ue-build /usr/local/lib64/uhd/utils/uhd_images_downloader.py /opt/oai-lte-ue/bin +COPY --from=lte-ue-base /usr/local/bin/uhd_find_devices /usr/local/bin +COPY --from=lte-ue-base /usr/local/lib/libprotobuf-c.so.1 /usr/local/lib +COPY --from=lte-ue-base /usr/local/lib64/libuhd.so.3.15.0 /usr/local/lib64 +COPY --from=lte-ue-base /usr/local/lib64/uhd/utils/uhd_images_downloader.py /opt/oai-lte-ue/bin WORKDIR /usr/local/share/uhd/rfnoc -COPY --from=lte-ue-build /usr/local/share/uhd/rfnoc/ . +COPY --from=lte-ue-base /usr/local/share/uhd/rfnoc/ . -RUN ldconfig +RUN /bin/bash -c "ln -s /usr/local/lib/liboai_usrpdevif.so /usr/local/lib/liboai_device.so" && \ + ldconfig # Copy the relevant configuration files for UE WORKDIR /opt/oai-lte-ue/etc diff --git a/docker/Dockerfile.lteUE.ubuntu18 b/docker/Dockerfile.lteUE.ubuntu18 index 31a3ae41ae4787fcaa5e98b05a9a45688703c631..a5bf4cfe9441c5fa0d4c9c9b2fefb4bf6db4de1e 100644 --- a/docker/Dockerfile.lteUE.ubuntu18 +++ b/docker/Dockerfile.lteUE.ubuntu18 @@ -25,20 +25,13 @@ # #--------------------------------------------------------------------- -FROM ran-build:latest AS lte-ue-build - -RUN rm -Rf /oai-ran -WORKDIR /oai-ran -COPY . . +FROM ran-base:latest AS lte-ue-base -#run build_oai to build the target image -RUN /bin/sh oaienv && \ - cd cmake_targets && \ - mkdir -p log && \ - ./build_oai --UE --ninja -w USRP --verbose-ci +FROM ran-build:latest AS lte-ue-build RUN python3 ./docker/scripts/generateTemplate.py ./docker/scripts/lte_ue_parameters.yaml && \ - python3 ./docker/scripts/generateTemplate.py ./docker/scripts/lte_ue_sim_parameters.yaml + python3 ./docker/scripts/generateTemplate.py ./docker/scripts/lte_ue_sim_parameters.yaml && \ + cp /oai-ran/docker/scripts/lte_ue_entrypoint.sh /oai-ran/docker/scripts/entrypoint.sh #start from scratch for target executable FROM ubuntu:bionic as oai-lte-ue @@ -49,6 +42,7 @@ RUN apt-get update && \ DEBIAN_FRONTEND=noninteractive apt-get upgrade --yes && \ DEBIAN_FRONTEND=noninteractive apt-get install --yes \ software-properties-common \ + tzdata \ procps \ libsctp1 \ libnettle6 \ @@ -69,41 +63,46 @@ RUN apt-get update && \ rm -rf /var/lib/apt/lists/* 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/docker/scripts/lte_ue_entrypoint.sh entrypoint.sh -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/lte-uesoftmodem.Rel15 \ + /oai-ran/docker/scripts/entrypoint.sh \ + /oai-ran/targets/bin/conf2uedata \ + /oai-ran/targets/bin/nvram \ + /oai-ran/targets/bin/usim \ + ./ -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/libtcp_bridge_oai.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 \ + /oai-ran/cmake_targets/ran_build/build/liboai_eth_transpro.so \ + /oai-ran/cmake_targets/ran_build/build/libtcp_bridge_oai.so \ + /oai-ran/cmake_targets/ran_build/build/librfsimulator.so \ + /oai-ran/cmake_targets/ran_build/build/liboai_usrpdevif.so \ + /oai-ran/cmake_targets/ran_build/build/libcoding.so \ + /oai-ran/cmake_targets/ran_build/build/libparams_libconfig.so \ + /oai-ran/cmake_targets/ran_build/build/libSIMU.so \ + /oai-ran/cmake_targets/ran_build/build/libdfts.so \ + /oai-ran/cmake_targets/ran_build/build/libtelnetsrv.so \ + /usr/local/lib/ # Now we are copying from builder-image the UHD files. -COPY --from=lte-ue-build /usr/local/bin/uhd_find_devices /usr/local/bin -COPY --from=lte-ue-build /usr/local/lib/libuhd.so.3.15.0 /usr/local/lib -COPY --from=lte-ue-build /usr/local/lib/uhd/utils/uhd_images_downloader.py /opt/oai-lte-ue/bin -WORKDIR /usr/lib/x86_64-linux-gnu -COPY --from=lte-ue-build /usr/lib/x86_64-linux-gnu/libboost_date_time.so.1.65.1 . -COPY --from=lte-ue-build /usr/lib/x86_64-linux-gnu/libboost_filesystem.so.1.65.1 . -COPY --from=lte-ue-build /usr/lib/x86_64-linux-gnu/libboost_regex.so.1.65.1 . -COPY --from=lte-ue-build /usr/lib/x86_64-linux-gnu/libboost_serialization.so.1.65.1 . -COPY --from=lte-ue-build /usr/lib/x86_64-linux-gnu/libboost_thread.so.1.65.1 . -COPY --from=lte-ue-build /usr/lib/x86_64-linux-gnu/libboost_system.so.1.65.1 . -COPY --from=lte-ue-build /usr/lib/x86_64-linux-gnu/libboost_program_options.so.1.65.1 . +COPY --from=lte-ue-base /usr/local/bin/uhd_find_devices /usr/local/bin +COPY --from=lte-ue-base \ + /usr/local/lib/libuhd.so.3.15.0 \ + /usr/local/lib/libprotobuf-c.so.1 \ + /usr/local/lib/ +COPY --from=lte-ue-base /usr/local/lib/uhd/utils/uhd_images_downloader.py /opt/oai-lte-ue/bin + +COPY --from=lte-ue-base \ + /usr/lib/x86_64-linux-gnu/libboost_date_time.so.1.65.1 \ + /usr/lib/x86_64-linux-gnu/libboost_filesystem.so.1.65.1 \ + /usr/lib/x86_64-linux-gnu/libboost_regex.so.1.65.1 \ + /usr/lib/x86_64-linux-gnu/libboost_serialization.so.1.65.1 \ + /usr/lib/x86_64-linux-gnu/libboost_thread.so.1.65.1 \ + /usr/lib/x86_64-linux-gnu/libboost_system.so.1.65.1 \ + /usr/lib/x86_64-linux-gnu/libboost_program_options.so.1.65.1 \ + /usr/lib/x86_64-linux-gnu/ -RUN ldconfig +RUN /bin/bash -c "ln -s /usr/local/lib/liboai_usrpdevif.so /usr/local/lib/liboai_device.so" && \ + ldconfig # Copy the relevant configuration files for UE WORKDIR /opt/oai-lte-ue/etc diff --git a/docker/Dockerfile.nrUE.rhel8.2 b/docker/Dockerfile.nrUE.rhel8.2 index ec74d1194018d134f1558d0fc3f5345d37c45383..cbc8d8c65fd87db590233a6012b59def69bbc04e 100644 --- a/docker/Dockerfile.nrUE.rhel8.2 +++ b/docker/Dockerfile.nrUE.rhel8.2 @@ -25,17 +25,11 @@ # #--------------------------------------------------------------------- -FROM ran-build:latest AS nr-ue-build +FROM ran-base:latest AS nr-ue-base -RUN rm -Rf /oai-ran -WORKDIR /oai-ran -COPY . . +FROM ran-build:latest AS nr-ue-build -#run build_oai to build the target image -RUN /bin/sh oaienv && \ - cd cmake_targets && \ - mkdir -p log && \ - ./build_oai --nrUE --ninja -w USRP --verbose-ci +RUN cp /oai-ran/docker/scripts/nr_ue_entrypoint.sh /oai-ran/docker/scripts/entrypoint.sh #start from scratch for target executable FROM registry.access.redhat.com/ubi8/ubi:latest as oai-nr-ue @@ -62,58 +56,63 @@ RUN yum update -y && \ 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 . -COPY --from=nr-ue-build /oai-ran/docker/scripts/nr_ue_entrypoint.sh entrypoint.sh +COPY --from=nr-ue-build \ + /oai-ran/targets/bin/nr-uesoftmodem.Rel15 \ + /oai-ran/docker/scripts/entrypoint.sh \ + ./ WORKDIR /opt/oai-nr-ue/etc COPY --from=nr-ue-build /oai-ran/ci-scripts/conf_files/nr-ue-sim.conf . -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/libtcp_bridge_oai.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 \ + /oai-ran/cmake_targets/ran_build/build/liboai_eth_transpro.so \ + /oai-ran/cmake_targets/ran_build/build/libtcp_bridge_oai.so \ + /oai-ran/cmake_targets/ran_build/build/librfsimulator.so \ + /oai-ran/cmake_targets/ran_build/build/liboai_usrpdevif.so \ + /oai-ran/cmake_targets/ran_build/build/libcoding.so \ + /oai-ran/cmake_targets/ran_build/build/libparams_libconfig.so \ + /oai-ran/cmake_targets/ran_build/build/libdfts.so \ + /oai-ran/cmake_targets/ran_build/build/libldpc.so \ + /oai-ran/cmake_targets/ran_build/build/libldpc_optim.so \ + /oai-ran/cmake_targets/ran_build/build/libldpc_optim8seg.so \ + /oai-ran/cmake_targets/ran_build/build/libldpc_orig.so \ + /oai-ran/cmake_targets/ran_build/build/libtelnetsrv.so \ + /oai-ran/cmake_targets/ran_build/build/libtelnetsrv_5Gue.so \ + /usr/local/lib/ + +COPY --from=nr-ue-base \ + /lib64/libconfig.so.9 \ + /lib64/libblas.so.3 \ + /lib64/liblapack.so.3 \ + /lib64/liblapacke.so.3 \ + /lib64/libforms.so.2 \ + /lib64/libboost_chrono.so.1.66.0 \ + /lib64/libboost_date_time.so.1.66.0 \ + /lib64/libboost_filesystem.so.1.66.0 \ + /lib64/libboost_program_options.so.1.66.0 \ + /lib64/libboost_serialization.so.1.66.0 \ + /lib64/libboost_thread.so.1.66.0 \ + /lib64/libboost_system.so.1.66.0 \ + /lib64/libboost_unit_test_framework.so.1.66.0 \ + /lib64/libboost_atomic.so.1.66.0 \ + /lib64/libboost_timer.so.1.66.0 \ + /lib64/libboost_regex.so.1.66.0 \ + /lib64/libicudata.so.60 \ + /lib64/libicui18n.so.60 \ + /lib64/libicuuc.so.60 \ + /lib64/ # Now we are copying from builder-image the UHD files. -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 /lib64/libboost_regex.so.1.66.0 /lib64 - -COPY --from=nr-ue-build /usr/local/bin/uhd_find_devices /usr/local/bin -COPY --from=nr-ue-build /usr/local/lib64/libuhd.so.3.15.0 /usr/local/lib64 -COPY --from=nr-ue-build /usr/local/lib64/uhd/utils/uhd_images_downloader.py /opt/oai-nr-ue/bin +COPY --from=nr-ue-base /usr/local/bin/uhd_find_devices /usr/local/bin +COPY --from=nr-ue-base /usr/local/lib/libprotobuf-c.so.1 /usr/local/lib +COPY --from=nr-ue-base /usr/local/lib64/libuhd.so.3.15.0 /usr/local/lib64 +COPY --from=nr-ue-base /usr/local/lib64/uhd/utils/uhd_images_downloader.py /opt/oai-nr-ue/bin WORKDIR /usr/local/share/uhd/rfnoc -COPY --from=nr-ue-build /usr/local/share/uhd/rfnoc/ . - +COPY --from=nr-ue-base /usr/local/share/uhd/rfnoc/ . -RUN ldconfig +RUN /bin/bash -c "ln -s /usr/local/lib/liboai_usrpdevif.so /usr/local/lib/liboai_device.so" && \ + ldconfig # Copy the relevant configuration files for eNB WORKDIR /opt/oai-nr-ue/etc diff --git a/docker/Dockerfile.nrUE.ubuntu18 b/docker/Dockerfile.nrUE.ubuntu18 index 38d437940ca5322e54e70925b8d8b2106c2c5ee9..126f268e000e24bdf552dbe27482d4573eec8379 100644 --- a/docker/Dockerfile.nrUE.ubuntu18 +++ b/docker/Dockerfile.nrUE.ubuntu18 @@ -25,17 +25,11 @@ # #--------------------------------------------------------------------- -FROM ran-build:latest AS nr-ue-build +FROM ran-base:latest AS nr-ue-base -RUN rm -Rf /oai-ran -WORKDIR /oai-ran -COPY . . +FROM ran-build:latest AS nr-ue-build -#run build_oai to build the target image -RUN /bin/sh oaienv && \ - cd cmake_targets && \ - mkdir -p log && \ - ./build_oai --nrUE --ninja -w USRP --verbose-ci +RUN cp /oai-ran/docker/scripts/nr_ue_entrypoint.sh /oai-ran/docker/scripts/entrypoint.sh #start from scratch for target executable FROM ubuntu:bionic as oai-nr-ue @@ -67,44 +61,50 @@ RUN apt-get update && \ rm -rf /var/lib/apt/lists/* WORKDIR /opt/oai-nr-ue/bin -COPY --from=nr-ue-build /oai-ran/targets/bin/nr-uesoftmodem.Rel15 . -COPY --from=nr-ue-build /oai-ran/docker/scripts/nr_ue_entrypoint.sh entrypoint.sh +COPY --from=nr-ue-build \ + /oai-ran/targets/bin/nr-uesoftmodem.Rel15 \ + /oai-ran/docker/scripts/entrypoint.sh \ + ./ WORKDIR /opt/oai-nr-ue/etc COPY --from=nr-ue-build /oai-ran/ci-scripts/conf_files/nr-ue-sim.conf . -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/libtcp_bridge_oai.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 \ + /oai-ran/cmake_targets/ran_build/build/liboai_eth_transpro.so \ + /oai-ran/cmake_targets/ran_build/build/libtcp_bridge_oai.so \ + /oai-ran/cmake_targets/ran_build/build/librfsimulator.so \ + /oai-ran/cmake_targets/ran_build/build/liboai_usrpdevif.so \ + /oai-ran/cmake_targets/ran_build/build/libcoding.so \ + /oai-ran/cmake_targets/ran_build/build/libparams_libconfig.so \ + /oai-ran/cmake_targets/ran_build/build/libdfts.so \ + /oai-ran/cmake_targets/ran_build/build/libldpc.so \ + /oai-ran/cmake_targets/ran_build/build/libldpc_optim.so \ + /oai-ran/cmake_targets/ran_build/build/libldpc_optim8seg.so \ + /oai-ran/cmake_targets/ran_build/build/libldpc_orig.so \ + /oai-ran/cmake_targets/ran_build/build/libtelnetsrv.so \ + /oai-ran/cmake_targets/ran_build/build/libtelnetsrv_5Gue.so \ + /usr/local/lib/ # Now we are copying from builder-image the UHD files. -COPY --from=nr-ue-build /usr/local/bin/uhd_find_devices /usr/local/bin -COPY --from=nr-ue-build /usr/local/lib/libuhd.so.3.15.0 /usr/local/lib -COPY --from=nr-ue-build /usr/local/lib/uhd/utils/uhd_images_downloader.py /opt/oai-nr-ue/bin -WORKDIR /usr/lib/x86_64-linux-gnu -COPY --from=nr-ue-build /usr/lib/x86_64-linux-gnu/libboost_date_time.so.1.65.1 . -COPY --from=nr-ue-build /usr/lib/x86_64-linux-gnu/libboost_filesystem.so.1.65.1 . -COPY --from=nr-ue-build /usr/lib/x86_64-linux-gnu/libboost_regex.so.1.65.1 . -COPY --from=nr-ue-build /usr/lib/x86_64-linux-gnu/libboost_serialization.so.1.65.1 . -COPY --from=nr-ue-build /usr/lib/x86_64-linux-gnu/libboost_thread.so.1.65.1 . -COPY --from=nr-ue-build /usr/lib/x86_64-linux-gnu/libboost_system.so.1.65.1 . -COPY --from=nr-ue-build /usr/lib/x86_64-linux-gnu/libboost_program_options.so.1.65.1 . +COPY --from=nr-ue-base /usr/local/bin/uhd_find_devices /usr/local/bin +COPY --from=nr-ue-base \ + /usr/local/lib/libuhd.so.3.15.0 \ + /usr/local/lib/libprotobuf-c.so.1 \ + /usr/local/lib/ +COPY --from=nr-ue-base /usr/local/lib/uhd/utils/uhd_images_downloader.py /opt/oai-nr-ue/bin + +COPY --from=nr-ue-base \ + /usr/lib/x86_64-linux-gnu/libboost_date_time.so.1.65.1 \ + /usr/lib/x86_64-linux-gnu/libboost_filesystem.so.1.65.1 \ + /usr/lib/x86_64-linux-gnu/libboost_regex.so.1.65.1 \ + /usr/lib/x86_64-linux-gnu/libboost_serialization.so.1.65.1 \ + /usr/lib/x86_64-linux-gnu/libboost_thread.so.1.65.1 \ + /usr/lib/x86_64-linux-gnu/libboost_system.so.1.65.1 \ + /usr/lib/x86_64-linux-gnu/libboost_program_options.so.1.65.1 \ + /usr/lib/x86_64-linux-gnu/ -RUN ldconfig +RUN /bin/bash -c "ln -s /usr/local/lib/liboai_usrpdevif.so /usr/local/lib/liboai_device.so" && \ + ldconfig WORKDIR /opt/oai-nr-ue CMD ["/opt/oai-nr-ue/bin/nr-uesoftmodem.Rel15", "-O", "/opt/oai-nr-ue/etc/nr-ue-sim.conf"] diff --git a/docker/Dockerfile.phySim.rhel8.2 b/docker/Dockerfile.phySim.rhel8.2 index 2333098bd715a4b44c3ec3e07f00395c96f383dd..9f4b27ec0e4255a4b2bb4938fd67359e561a4e6f 100644 --- a/docker/Dockerfile.phySim.rhel8.2 +++ b/docker/Dockerfile.phySim.rhel8.2 @@ -25,7 +25,7 @@ # #--------------------------------------------------------------------- -FROM ran-build:develop AS phy-sim-build +FROM ran-base:latest AS phy-sim-build RUN rm -Rf /oai-ran WORKDIR /oai-ran @@ -37,7 +37,6 @@ RUN /bin/sh oaienv && \ mkdir -p log && \ ./build_oai --phy_simulators --ninja --verbose-ci - #start from scratch for target executable FROM registry.access.redhat.com/ubi8/ubi:latest as oai-physim @@ -45,6 +44,7 @@ RUN yum update -y && \ yum install -y --enablerepo="ubi-8-codeready-builder" \ lksctp-tools \ nettle \ + tzdata \ atlas \ hostname \ sudo \ @@ -58,66 +58,61 @@ RUN yum update -y && \ echo "/usr/local/lib64" >> /etc/ld.so.conf.d/local-lib.conf WORKDIR /opt/oai-physim/targets/bin -COPY --from=phy-sim-build /oai-ran/targets/bin/dlsim.Rel15 . -COPY --from=phy-sim-build /oai-ran/targets/bin/nr_dlsim.Rel15 . -COPY --from=phy-sim-build /oai-ran/targets/bin/nr_prachsim.Rel15 . -COPY --from=phy-sim-build /oai-ran/targets/bin/nr_ulschsim.Rel15 . -COPY --from=phy-sim-build /oai-ran/targets/bin/polartest.Rel15 . -COPY --from=phy-sim-build /oai-ran/targets/bin/ulsim.Rel15 . -COPY --from=phy-sim-build /oai-ran/targets/bin/ldpctest.Rel15 . -COPY --from=phy-sim-build /oai-ran/targets/bin/nr_dlschsim.Rel15 . -COPY --from=phy-sim-build /oai-ran/targets/bin/nr_pbchsim.Rel15 . -COPY --from=phy-sim-build /oai-ran/targets/bin/nr_pucchsim.Rel15 . -COPY --from=phy-sim-build /oai-ran/targets/bin/nr_ulsim.Rel15 . -COPY --from=phy-sim-build /oai-ran/targets/bin/smallblocktest.Rel15 . +COPY --from=phy-sim-build \ + /oai-ran/targets/bin/dlsim.Rel15 \ + /oai-ran/targets/bin/nr_dlsim.Rel15 \ + /oai-ran/targets/bin/nr_prachsim.Rel15 \ + /oai-ran/targets/bin/nr_ulschsim.Rel15 \ + /oai-ran/targets/bin/polartest.Rel15 \ + /oai-ran/targets/bin/ulsim.Rel15 \ + /oai-ran/targets/bin/ldpctest.Rel15 \ + /oai-ran/targets/bin/nr_dlschsim.Rel15 \ + /oai-ran/targets/bin/nr_pbchsim.Rel15 \ + /oai-ran/targets/bin/nr_pucchsim.Rel15 \ + /oai-ran/targets/bin/nr_ulsim.Rel15 \ + /oai-ran/targets/bin/smallblocktest.Rel15 \ + ./ -WORKDIR /usr/local/lib/ -COPY --from=phy-sim-build /oai-ran/targets/bin/libcoding.so . -COPY --from=phy-sim-build /lib64/liblapacke.so.3 . -COPY --from=phy-sim-build /lib64/libX11.so.6 . -COPY --from=phy-sim-build /lib64/libXpm.so.4 . -COPY --from=phy-sim-build /lib64/libxcb.so.1 . -COPY --from=phy-sim-build /lib64/libXau.so.6 . -COPY --from=phy-sim-build /lib64/libforms.so.2 . -COPY --from=phy-sim-build /lib64/libblas.so.3 . -COPY --from=phy-sim-build /lib64/liblapack.so.3 . -COPY --from=phy-sim-build /lib64/libexslt.so.0 . -COPY --from=phy-sim-build /lib64/libxslt.so.1 . -COPY --from=phy-sim-build /oai-ran/cmake_targets/phy_simulators/build/libdfts.so . -COPY --from=phy-sim-build /oai-ran/cmake_targets/phy_simulators/build/libSIMU.so . -COPY --from=phy-sim-build /oai-ran/cmake_targets/phy_simulators/build/libldpc.so . -COPY --from=phy-sim-build /oai-ran/cmake_targets/phy_simulators/build/libldpc_orig.so . +COPY --from=phy-sim-build \ + /oai-ran/targets/bin/libcoding.so \ + /lib64/liblapacke.so.3 \ + /lib64/libX11.so.6 \ + /lib64/libXpm.so.4 \ + /lib64/libxcb.so.1 \ + /lib64/libXau.so.6 \ + /lib64/libforms.so.2 \ + /lib64/libblas.so.3 \ + /lib64/liblapack.so.3 \ + /lib64/libexslt.so.0 \ + /lib64/libxslt.so.1 \ + /oai-ran/cmake_targets/ran_build/build/libdfts.so \ + /oai-ran/cmake_targets/ran_build/build/libSIMU.so \ + /oai-ran/cmake_targets/ran_build/build/libldpc.so \ + /oai-ran/cmake_targets/ran_build/build/libldpc_orig.so \ + /usr/local/lib/ RUN ldconfig -#debug -#RUN ldd /opt/oai-physim/targets/bin/dlsim.Rel15 -#RUN ldd /opt/oai-physim/targets/bin/nr_dlsim.Rel15 -#RUN ldd /opt/oai-physim/targets/bin/nr_prachsim.Rel15 -#RUN ldd /opt/oai-physim/targets/bin/nr_ulschsim.Rel15 -#RUN ldd /opt/oai-physim/targets/bin/polartest.Rel15 -#RUN ldd /opt/oai-physim/targets/bin/ulsim.Rel15 -#RUN ldd /opt/oai-physim/targets/bin/ldpctest.Rel15 -#RUN ldd /opt/oai-physim/targets/bin/nr_dlschsim.Rel15 -#RUN ldd /opt/oai-physim/targets/bin/nr_pbchsim.Rel15 -#RUN ldd /opt/oai-physim/targets/bin/nr_pucchsim.Rel15 -#RUN ldd /opt/oai-physim/targets/bin/nr_ulsim.Rel15 -#RUN ldd /opt/oai-physim/targets/bin/smallblocktest.Rel15 - # Copy some executables WORKDIR /usr/bin/ -COPY --from=phy-sim-build /usr/bin/killall . -COPY --from=phy-sim-build /usr/bin/xmlstarlet . -COPY --from=phy-sim-build /usr/bin/svn . +COPY --from=phy-sim-build \ + /usr/bin/killall \ + /usr/bin/xmlstarlet \ + /usr/bin/svn \ + ./ # Copy the relevant configuration files for phySim WORKDIR /opt/oai-physim/ -COPY --from=phy-sim-build /oai-ran/cmake_targets/autotests/run_exec_autotests.bash /opt/oai-physim/cmake_targets/autotests/ -COPY --from=phy-sim-build /oai-ran/cmake_targets/autotests/test_case_list.xml /opt/oai-physim/cmake_targets/autotests/ -COPY --from=phy-sim-build /oai-ran/cmake_targets/autotests/tools/free_mem.bash /opt/oai-physim/cmake_targets/autotests/tools/ -COPY --from=phy-sim-build /oai-ran/cmake_targets/tools/build_helper /opt/oai-physim/cmake_targets/tools/ -COPY --from=phy-sim-build /oai-ran/cmake_targets/tools/test_helper /opt/oai-physim/cmake_targets/tools/ +COPY --from=phy-sim-build \ + /oai-ran/cmake_targets/autotests/run_exec_autotests.bash \ + /oai-ran/cmake_targets/autotests/test_case_list.xml \ + /opt/oai-physim/cmake_targets/autotests/ +COPY --from=phy-sim-build \ + /oai-ran/cmake_targets/autotests/tools/free_mem.bash \ + /oai-ran/cmake_targets/tools/build_helper \ + /oai-ran/cmake_targets/tools/test_helper \ + /opt/oai-physim/cmake_targets/tools/ #CMD ["sleep", "infinity"] diff --git a/docker/Dockerfile.ran.rhel7.oc4-4 b/docker/Dockerfile.ran.rhel7.oc4-4 index e32fa9b36d14e13a7682b2dfff4b10405b4a2b94..2f0423801a87163dca4aad3f4b47803b0d2c4c99 100644 --- a/docker/Dockerfile.ran.rhel7.oc4-4 +++ b/docker/Dockerfile.ran.rhel7.oc4-4 @@ -26,7 +26,7 @@ #--------------------------------------------------------------------- -FROM registry.access.redhat.com/ubi7/ubi:latest AS ran-build +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 diff --git a/docker/Dockerfile.ran.rhel8.2.oc4-4 b/docker/Dockerfile.ran.rhel8.2.oc4-4 index 127d66fccb58185e2d3574abbdb9b16527fb032e..93af2b0e370fe16075788e75c0cf9e04c0092e64 100644 --- a/docker/Dockerfile.ran.rhel8.2.oc4-4 +++ b/docker/Dockerfile.ran.rhel8.2.oc4-4 @@ -26,7 +26,7 @@ #--------------------------------------------------------------------- -FROM registry.access.redhat.com/ubi8/ubi:latest AS ran-build +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 diff --git a/docker/README.md b/docker/README.md index 3966196bb158ffb7f92c1dc586e592b18976890e..85f553c7217216fad43440da6c714234ed9ee33d 100644 --- a/docker/README.md +++ b/docker/README.md @@ -29,12 +29,18 @@ For all platforms, the strategy for building docker/podman images is the same: -* First we create a common shared image that contains: +* First we create a common shared image `ran-base` that contains: - the latest source files (by using the `COPY` function) - all the means to build an OAI RAN executable * all packages, compilers, ... * especially UHD is installed -* Then from this shared image (`ran-build`) we can build target images for: +* Then, from the `ran-base` shared image, we create a shared image `ran-build` + in which all targets are compiled: + - eNB + - gNB + - lte-UE + - nr-UE +* Then from the `ran-build` shared image we can build target images for: - eNB - gNB - lte-UE @@ -58,7 +64,8 @@ Dockerfiles are named with the following naming convention: `Dockerfile.${target Targets can be: -- `ran` for an image named `ran-build` (the shared image) +- `base` for an image named `ran-base` (shared image) +- `ran` for an image named `ran-build` (shared image) - `eNB` for an image named `oai-enb` - `gNB` for an image named `oai-gnb` - `lteUE` for an image named `oai-lte-ue` @@ -85,9 +92,11 @@ For more details in build within a Openshift Cluster, see [OpenShift README](../ * `docker-ce` installed * Pulling `ubuntu:bionic` from DockerHub -## 3.2. Building the shared image ## +## 3.2. Building the shared images ## -This can be done starting `2020.w41` tag on the `develop` branch, or any branch that includes that tag. +Note: This can be done starting `2020.XX` tag on the `develop` branch, or any branch that includes that tag. + +There are two shared images: one that has all dependencies, and a second that compiles all targets (eNB, gNB, [nr]UE). ```bash git clone https://gitlab.eurecom.fr/oai/openairinterface5g.git @@ -98,21 +107,25 @@ git checkout develop In our Eurecom/OSA environment we need to pass a GIT proxy. ```bash -docker build --target ran-build --tag ran-build:latest --file docker/Dockerfile.ran.ubuntu18 --build-arg NEEDED_GIT_PROXY="http://proxy.eurecom.fr:8080" . +docker build --target ran-base --tag ran-base:latest --file docker/Dockerfile.base.ubuntu18 --build-arg NEEDED_GIT_PROXY="http://proxy.eurecom.fr:8080" . +docker build --target ran-build --tag ran-build:latest --file docker/Dockerfile.build.ubuntu18 --build-arg NEEDED_GIT_PROXY="http://proxy.eurecom.fr:8080" . ``` if you don't need it, do NOT pass any value: ```bash -docker build --target ran-build --tag ran-build:latest --file docker/Dockerfile.ran.ubuntu18 . +docker build --target ran-base --tag ran-base:latest --file docker/Dockerfile.base.ubuntu18 . +docker build --target ran-build --tag ran-build:latest --file docker/Dockerfile.build.ubuntu18 . ``` -After a while: +After building both: ```bash docker image ls REPOSITORY TAG IMAGE ID CREATED SIZE -ran-build latest ccb721bc0b57 1 minute ago 4.06GB +ran-build latest f2633a7f5102 1 minute ago 6.81GB +ran-base latest 5c9c02a5b4a8 1 minute ago 2.4GB + ... ``` @@ -131,7 +144,8 @@ docker image ls REPOSITORY TAG IMAGE ID CREATED SIZE oai-enb latest 25ddbd8b7187 1 minute ago 516MB <none> <none> 875ea3b05b60 8 minutes ago 8.18GB -ran-build latest ccb721bc0b57 1 hour ago 4.06GB +ran-build latest f2633a7f5102 1 hour ago 6.81GB +ran-base latest 5c9c02a5b4a8 1 hour ago 2.4GB ``` Do not forget to remove the temporary image: diff --git a/docker/scripts/enb_entrypoint.sh b/docker/scripts/enb_entrypoint.sh index c71a2cf12f5c8cea28d9865ad1cc8cca94434329..06e94b1e7a9d64696e92c2c6768f342333a6bb2b 100755 --- a/docker/scripts/enb_entrypoint.sh +++ b/docker/scripts/enb_entrypoint.sh @@ -18,11 +18,19 @@ if [[ -v USE_FDD_IF4P5_RCC ]]; then cp $PREFIX/etc/rcc.if4p5.fdd.conf $PREFIX/et if [[ -v USE_TDD_IF4P5_RCC ]]; then cp $PREFIX/etc/rcc.if4p5.tdd.conf $PREFIX/etc/enb.conf; fi if [[ -v USE_FDD_RRU ]]; then cp $PREFIX/etc/rru.fdd.conf $PREFIX/etc/enb.conf; fi if [[ -v USE_TDD_RRU ]]; then cp $PREFIX/etc/rru.tdd.conf $PREFIX/etc/enb.conf; fi +# Sometimes, the templates are not enough. We mount a conf file on $PREFIX/etc. It can be a template itself. +if [[ -v USE_VOLUMED_CONF ]]; then cp $PREFIX/etc/mounted.conf $PREFIX/etc/enb.conf; fi # Only this template will be manipulated CONFIG_FILES=`ls $PREFIX/etc/enb.conf || true` for c in ${CONFIG_FILES}; do + # Sometimes templates have no pattern to be replaced. + if ! grep -oP '@[a-zA-Z0-9_]+@' ${c}; then + echo "Configuration is already set" + break + fi + # grep variable names (format: ${VAR}) from template to be rendered VARS=$(grep -oP '@[a-zA-Z0-9_]+@' ${c} | sort | uniq | xargs) diff --git a/docker/scripts/generateTemplate.py b/docker/scripts/generateTemplate.py index cc4b72a7035159ebbae7e77767cfc150bfeb106b..3d037294e6b479a6030e7ae921a71a8e4331817a 100644 --- a/docker/scripts/generateTemplate.py +++ b/docker/scripts/generateTemplate.py @@ -55,6 +55,8 @@ def main(): "rcc.band40.tm1.25PRB": f'{data[0]["paths"]["dest_dir"]}/{outputfilename}', "gnb.band78.tm1.fr1.106PRB.usrpb210.conf": f'{data[0]["paths"]["dest_dir"]}/{outputfilename}', "gnb.band78.sa.fr1.106PRB.usrpn310.conf": f'{data[0]["paths"]["dest_dir"]}/{outputfilename}', + "gNB_SA_CU.conf": f'{data[0]["paths"]["dest_dir"]}/{outputfilename}', + "gNB_SA_DU.conf": f'{data[0]["paths"]["dest_dir"]}/{outputfilename}', "ue.nfapi": f'{data[0]["paths"]["dest_dir"]}/{outputfilename}', "ue_sim_ci": f'{data[0]["paths"]["dest_dir"]}/{outputfilename}' } @@ -77,6 +79,10 @@ def main(): 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) diff --git a/docker/scripts/gnb_entrypoint.sh b/docker/scripts/gnb_entrypoint.sh index d2bdc636c95972e1a17ab93a8636459b83ad03d3..79d6c6dc372e62f172b97a06934d411d66b8623e 100755 --- a/docker/scripts/gnb_entrypoint.sh +++ b/docker/scripts/gnb_entrypoint.sh @@ -7,13 +7,24 @@ ENABLE_X2=${ENABLE_X2:-yes} THREAD_PARALLEL_CONFIG=${THREAD_PARALLEL_CONFIG:-PARALLEL_SINGLE_THREAD} # Based another env var, pick one template to use + if [[ -v USE_NSA_TDD_MONO ]]; then cp $PREFIX/etc/gnb.nsa.tdd.conf $PREFIX/etc/gnb.conf; fi if [[ -v USE_SA_TDD_MONO ]]; then cp $PREFIX/etc/gnb.sa.tdd.conf $PREFIX/etc/gnb.conf; fi +if [[ -v USE_SA_CU ]]; then ln -s $PREFIX/etc/gnb.sa.cu.conf $PREFIX/etc/gnb.conf; fi +if [[ -v USE_SA_TDD_CU ]]; then cp $PREFIX/etc/gnb.sa.du.tdd.conf $PREFIX/etc/gnb.conf; fi +# Sometimes, the templates are not enough. We mount a conf file on $PREFIX/etc. It can be a template itself. +if [[ -v USE_VOLUMED_CONF ]]; then cp $PREFIX/etc/mounted.conf $PREFIX/etc/gnb.conf; fi # Only this template will be manipulated CONFIG_FILES=`ls $PREFIX/etc/gnb.conf || true` for c in ${CONFIG_FILES}; do + # Sometimes templates have no pattern to be replaced. + if ! grep -oP '@[a-zA-Z0-9_]+@' ${c}; then + echo "Configuration is already set" + break + fi + # grep variable names (format: ${VAR}) from template to be rendered VARS=$(grep -oP '@[a-zA-Z0-9_]+@' ${c} | sort | uniq | xargs) diff --git a/docker/scripts/gnb_parameters.yaml b/docker/scripts/gnb_parameters.yaml index ac5a6cb971629cbc69d0c6959625c83c18b1c518..2f150d394a04697108d04804bfda617ddec6f628 100644 --- a/docker/scripts/gnb_parameters.yaml +++ b/docker/scripts/gnb_parameters.yaml @@ -94,3 +94,81 @@ - key: parallel_config env: "@THREAD_PARALLEL_CONFIG@" + - filePrefix: gNB_SA_CU.conf + outputfilename: "gnb.sa.cu.conf" + config: + - key: Active_gNBs + env: "@GNB_NAME@" + - key: gNB_name + env: "@GNB_NAME@" + - key: mcc + env: "@MCC@" + - key: mnc + env: "@MNC@" + - key: mnc_length + env: "@MNC_LENGTH@" + - key: tracking_area_code + env: "@TAC@" + - key: sst + env: "@NSSAI_SST@" + - key: ipv4 + env: "@AMF_IP_ADDRESS@" + - key: GNB_INTERFACE_NAME_FOR_NG_AMF + env: "@GNB_NGA_IF_NAME@" + - key: GNB_IPV4_ADDRESS_FOR_NG_AMF + env: "@GNB_NGA_IP_ADDRESS@" + - key: GNB_INTERFACE_NAME_FOR_NGU + env: "@GNB_NGU_IF_NAME@" + - key: GNB_IPV4_ADDRESS_FOR_NGU + env: "@GNB_NGU_IP_ADDRESS@" + - key: local_s_if_name + env: "@F1_IF_NAME@" + - key: local_s_address + env: "@F1_CU_IP_ADDRESS@" + - key: local_s_portd + env: "@F1_CU_D_PORT@" + - key: remote_s_address + env: "@F1_DU_IP_ADDRESS@" + - key: remote_s_portd + env: "@F1_DU_D_PORT@" + + - filePrefix: gNB_SA_DU.conf + outputfilename: "gnb.sa.du.tdd.conf" + config: + - key: Active_gNBs + env: "@GNB_NAME@" + - key: gNB_name + env: "@GNB_NAME@" + - key: mcc + env: "@MCC@" + - key: mnc + env: "@MNC@" + - key: mnc_length + env: "@MNC_LENGTH@" + - key: tracking_area_code + env: "@TAC@" + - key: sst + env: "@NSSAI_SST@" + - key: ipv4 + env: "@AMF_IP_ADDRESS@" + - key: GNB_INTERFACE_NAME_FOR_NG_AMF + env: "@GNB_NGA_IF_NAME@" + - key: GNB_IPV4_ADDRESS_FOR_NG_AMF + env: "@GNB_NGA_IP_ADDRESS@" + - key: GNB_INTERFACE_NAME_FOR_NGU + env: "@GNB_NGU_IF_NAME@" + - key: GNB_IPV4_ADDRESS_FOR_NGU + env: "@GNB_NGU_IP_ADDRESS@" + - key: parallel_config + env: "@THREAD_PARALLEL_CONFIG@" + - key: local_n_if_name + env: "@F1_IF_NAME@" + - key: local_n_address + env: "@F1_DU_IP_ADDRESS@" + - key: local_n_portd + env: "@F1_DU_D_PORT@" + - key: remote_n_address + env: "@F1_CU_IP_ADDRESS@" + - key: remote_n_portd + env: "@F1_CU_D_PORT@" + diff --git a/executables/main-fs6.c b/executables/main-fs6.c index 438edb4044dd02dc766029406697c6094c4e300c..9e92f2e41af1b9fcdadca62d0c1c6cb0909560a7 100644 --- a/executables/main-fs6.c +++ b/executables/main-fs6.c @@ -553,7 +553,11 @@ void fill_rx_indication_from_split(uint8_t *bufferZone, PHY_VARS_eNB *eNB,int UE pdu->rx_indication_rel8.tl.tag = NFAPI_RX_INDICATION_REL8_TAG; pdu->rx_indication_rel8.length = eNB->ulsch[UE_id]->harq_processes[harq_pid]->TBS>>3; pdu->rx_indication_rel8.offset = 1; // DJP - I dont understand - but broken unless 1 ???? 0; // filled in at the end of the UL_INFO formation - pdu->data = eNB->ulsch[UE_id]->harq_processes[harq_pid]->decodedBytes; + AssertFatal(pdu->rx_indication_rel8.length <= NFAPI_RX_IND_DATA_MAX, "Invalid PDU len %d\n", + pdu->rx_indication_rel8.length); + memcpy(pdu->rx_ind_data, + eNB->ulsch[UE_id]->harq_processes[harq_pid]->decodedBytes, + pdu->rx_indication_rel8.length); // estimate timing advance for MAC timing_advance_update = ul_propa[UE_id].ta; diff --git a/executables/main-ocp.c b/executables/main-ocp.c index 0355582b2b4e76848588cd22a580dd4577569ab0..04315a4d57f3939e9187a7cf5b0a20113614039e 100644 --- a/executables/main-ocp.c +++ b/executables/main-ocp.c @@ -81,17 +81,16 @@ int otg_enabled; uint64_t downlink_frequency[MAX_NUM_CCs][4]; int32_t uplink_frequency_offset[MAX_NUM_CCs][4]; int split73; -char * split73_config; +char *split73_config; int split73; AGENT_RRC_xface *agent_rrc_xface[NUM_MAX_ENB]= {0}; AGENT_MAC_xface *agent_mac_xface[NUM_MAX_ENB]= {0}; -uint8_t proto_agent_flag = 0; void flexran_agent_slice_update(mid_t module_idP) { } -int proto_agent_start(mod_id_t mod_id, const cudu_params_t *p){ - return 0; +int proto_agent_start(mod_id_t mod_id, const cudu_params_t *p) { + return 0; } -void proto_agent_stop(mod_id_t mod_id){ +void proto_agent_stop(mod_id_t mod_id) { } static void *ru_thread( void *param ); @@ -112,7 +111,6 @@ void exit_function(const char *file, const char *function, const int line, const close_log_mem(); oai_exit = 1; - sleep(1); //allow lte-softmodem threads to exit first exit(1); } @@ -145,14 +143,16 @@ void init_RU_proc(RU_t *ru) { pthread_t t; switch(split73) { - case SPLIT73_CU: - threadCreate(&t, cu_fs6, (void *)ru, "MainCu", -1, OAI_PRIORITY_RT_MAX); - break; - case SPLIT73_DU: - threadCreate(&t, du_fs6, (void *)ru, "MainDuRx", -1, OAI_PRIORITY_RT_MAX); - break; - default: - threadCreate(&t, ru_thread, (void *)ru, "MainRu", -1, OAI_PRIORITY_RT_MAX); + case SPLIT73_CU: + threadCreate(&t, cu_fs6, (void *)ru, "MainCu", -1, OAI_PRIORITY_RT_MAX); + break; + + case SPLIT73_DU: + threadCreate(&t, du_fs6, (void *)ru, "MainDuRx", -1, OAI_PRIORITY_RT_MAX); + break; + + default: + threadCreate(&t, ru_thread, (void *)ru, "MainRu", -1, OAI_PRIORITY_RT_MAX); } } @@ -161,7 +161,7 @@ void init_transport(PHY_VARS_eNB *eNB) { LTE_DL_FRAME_PARMS *fp = &eNB->frame_parms; LOG_I(PHY, "Initialise transport\n"); - for (int i=0; i<NUMBER_OF_UE_MAX; i++) { + for (int i=0; i<NUMBER_OF_DLSCH_MAX; i++) { LOG_D(PHY,"Allocating Transport Channel Buffers for DLSCH, UE %d\n",i); for (int j=0; j<2; j++) { @@ -170,7 +170,9 @@ void init_transport(PHY_VARS_eNB *eNB) { eNB->dlsch[i][j]->rnti=0; LOG_D(PHY,"dlsch[%d][%d] => %p rnti:%d\n",i,j,eNB->dlsch[i][j], eNB->dlsch[i][j]->rnti); } + } + for (int i=0; i<NUMBER_OF_ULSCH_MAX; i++) { LOG_D(PHY,"Allocating Transport Channel Buffer for ULSCH, UE %d\n",i); AssertFatal((eNB->ulsch[1+i] = new_eNB_ulsch(MAX_TURBO_ITERATIONS,fp->N_RB_UL, 0)) != NULL, "Can't get eNB ulsch structures\n"); @@ -198,6 +200,9 @@ void init_transport(PHY_VARS_eNB *eNB) { eNB->FULL_MUMIMO_transmissions = 0; eNB->check_for_SUMIMO_transmissions = 0; fp->pucch_config_common.deltaPUCCH_Shift = 1; + + if (eNB->use_DTX == 0) + fill_subframe_mask(eNB); } void init_eNB_afterRU(void) { @@ -228,25 +233,23 @@ void init_eNB_afterRU(void) { for (int ce_level=0; ce_level<4; ce_level++) eNB->prach_vars_br.rxsigF[ce_level][aa] = eNB->RU_list[ru_id]->prach_rxsigF_br[ce_level][i]; - } } - AssertFatal( eNB->frame_parms.nb_antennas_rx > 0 && eNB->frame_parms.nb_antennas_rx < 5, ""); AssertFatal( eNB->frame_parms.nb_antennas_tx > 0 && eNB->frame_parms.nb_antennas_rx < 5, ""); - phy_init_lte_eNB(eNB,0,0); // need to copy rxdataF after L1 variables are allocated for (int inst=0; inst<RC.nb_inst; inst++) { - for (int CC_id=0; CC_id<RC.nb_CC[inst]; CC_id++) { - PHY_VARS_eNB *eNB = RC.eNB[inst][CC_id]; - for (int ru_id=0,aa=0; ru_id<eNB->num_RU; ru_id++) { - for (int i=0; i<eNB->RU_list[ru_id]->nb_rx; aa++,i++) - eNB->common_vars.rxdataF[aa] = eNB->RU_list[ru_id]->common.rxdataF[i]; - } - } + for (int CC_id=0; CC_id<RC.nb_CC[inst]; CC_id++) { + PHY_VARS_eNB *eNB = RC.eNB[inst][CC_id]; + + for (int ru_id=0,aa=0; ru_id<eNB->num_RU; ru_id++) { + for (int i=0; i<eNB->RU_list[ru_id]->nb_rx; aa++,i++) + eNB->common_vars.rxdataF[aa] = eNB->RU_list[ru_id]->common.rxdataF[i]; + } + } } LOG_I(PHY,"inst %d, CC_id %d : nb_antennas_rx %d\n",inst,CC_id,eNB->frame_parms.nb_antennas_rx); @@ -300,7 +303,7 @@ void fill_rf_config(RU_t *ru, char *rf_config_file) { LTE_DL_FRAME_PARMS *fp = ru->frame_parms; openair0_config_t *cfg = &ru->openair0_cfg; //printf("////////////////numerology in config = %d\n",numerology); - int numerology = get_softmodem_params()->numerology; + int numerology = 0; //get_softmodem_params()->numerology; if(fp->N_RB_DL == 100) { if(numerology == 0) { @@ -347,7 +350,8 @@ void fill_rf_config(RU_t *ru, char *rf_config_file) { cfg->samples_per_frame = 19200; cfg->tx_bw = 1.5e6; cfg->rx_bw = 1.5e6; - } else AssertFatal(1==0,"Unknown N_RB_DL %d\n",fp->N_RB_DL); + } else + AssertFatal(1==0,"Unknown N_RB_DL %d\n",fp->N_RB_DL); if (fp->frame_type==TDD) cfg->duplex_mode = duplex_mode_TDD; @@ -468,7 +472,8 @@ void ocp_rx_prach(PHY_VARS_eNB *eNB, ((prach_mask&(1<<(i+1))) > 0)) { // check that prach CE level is active now // if first reception in group of repetitions store frame for later (in RA-RNTI for Msg2) - if (eNB->prach_vars_br.repetition_number[i]==0) eNB->prach_vars_br.first_frame[i]=proc->frame_prach_br; + if (eNB->prach_vars_br.repetition_number[i]==0) + eNB->prach_vars_br.first_frame[i]=proc->frame_prach_br; // increment repetition number eNB->prach_vars_br.repetition_number[i]++; @@ -771,7 +776,8 @@ static void *ru_thread( void *param ) { // Start RF device if any if (ru->rfdevice.trx_start_func(&ru->rfdevice) != 0) LOG_E(HW,"Could not start the RF device\n"); - else LOG_I(PHY,"RU %d rf device ready\n",ru->idx); + else + LOG_I(PHY,"RU %d rf device ready\n",ru->idx); // This is a forever while loop, it loops over subframes which are scheduled by incoming samples from HW devices while (!oai_exit) { @@ -815,7 +821,7 @@ int init_rf(RU_t *ru) { pthread_setname_np(pthread_self(),name); return ret; } - + void ocp_init_RU(RU_t *ru, char *rf_config_file, int send_dmrssync) { PHY_VARS_eNB *eNB0= (PHY_VARS_eNB *)NULL; int i; @@ -831,48 +837,47 @@ void ocp_init_RU(RU_t *ru, char *rf_config_file, int send_dmrssync) { RC.eNB[i][CC_id]->num_RU=0; LOG_D(PHY,"Process RUs RC.nb_RU:%d\n",RC.nb_RU); + ru->rf_config_file = rf_config_file; + ru->idx = 0; + ru->ts_offset = 0; - ru->rf_config_file = rf_config_file; - ru->idx = 0; - ru->ts_offset = 0; - - if (ru->is_slave == 1) { - ru->in_synch = 0; - ru->generate_dmrs_sync = 0; - } else { - ru->in_synch = 1; - ru->generate_dmrs_sync=send_dmrssync; - } + if (ru->is_slave == 1) { + ru->in_synch = 0; + ru->generate_dmrs_sync = 0; + } else { + ru->in_synch = 1; + ru->generate_dmrs_sync=send_dmrssync; + } - ru->cmd = EMPTY; - ru->south_out_cnt= 0; + ru->cmd = EMPTY; + ru->south_out_cnt= 0; - // ru->generate_dmrs_sync = (ru->is_slave == 0) ? 1 : 0; - if (ru->generate_dmrs_sync == 1) { - generate_ul_ref_sigs(); - ru->dmrssync = (int16_t *)malloc16_clear(ru->frame_parms->ofdm_symbol_size*2*sizeof(int16_t)); - } + // ru->generate_dmrs_sync = (ru->is_slave == 0) ? 1 : 0; + if (ru->generate_dmrs_sync == 1) { + generate_ul_ref_sigs(); + ru->dmrssync = (int16_t *)malloc16_clear(ru->frame_parms->ofdm_symbol_size*2*sizeof(int16_t)); + } - ru->wakeup_L1_sleeptime = 2000; - ru->wakeup_L1_sleep_cnt_max = 3; + ru->wakeup_L1_sleeptime = 2000; + ru->wakeup_L1_sleep_cnt_max = 3; - if (ru->num_eNB > 0) { - AssertFatal(ru->eNB_list[0], "ru->eNB_list is not initialized\n"); - } else { - LOG_E(PHY,"Wrong data model, assigning eNB 0, carrier 0 to RU 0\n"); - ru->eNB_list[0] = RC.eNB[0][0]; - ru->num_eNB=1; - } + if (ru->num_eNB > 0) { + AssertFatal(ru->eNB_list[0], "ru->eNB_list is not initialized\n"); + } else { + LOG_E(PHY,"Wrong data model, assigning eNB 0, carrier 0 to RU 0\n"); + ru->eNB_list[0] = RC.eNB[0][0]; + ru->num_eNB=1; + } - eNB0 = ru->eNB_list[0]; - // datamodel error in regular OAI: a RU uses one single eNB carrier parameters! - ru->frame_parms = &eNB0->frame_parms; + eNB0 = ru->eNB_list[0]; + // datamodel error in regular OAI: a RU uses one single eNB carrier parameters! + ru->frame_parms = &eNB0->frame_parms; - for (i=0; i<ru->num_eNB; i++) { - eNB0 = ru->eNB_list[i]; - int ruIndex=eNB0->num_RU++; - eNB0->RU_list[ruIndex] = ru; - } + for (i=0; i<ru->num_eNB; i++) { + eNB0 = ru->eNB_list[i]; + int ruIndex=eNB0->num_RU++; + eNB0->RU_list[ruIndex] = ru; + } } void stop_RU(int nb_ru) { @@ -885,7 +890,7 @@ void stop_RU(int nb_ru) { /* --------------------------------------------------------*/ /* from here function to use configuration module */ static int DEFBFW[] = {0x00007fff}; -void ocpRCconfig_RU(RU_t* ru) { +void ocpRCconfig_RU(RU_t *ru) { paramdef_t RUParams[] = RUPARAMS_DESC; paramlist_def_t RUParamList = {CONFIG_STRING_RU_LIST,NULL,0}; config_getlist( &RUParamList,RUParams,sizeof(RUParams)/sizeof(paramdef_t), NULL); @@ -915,7 +920,7 @@ void ocpRCconfig_RU(RU_t* ru) { if (config_isparamset(vals, RU_SDR_CLK_SRC)) { char *paramVal=*(vals[RU_SDR_CLK_SRC].strptr); LOG_D(PHY, "RU clock source set as %s\n", paramVal); - + if (strcmp(paramVal, "internal") == 0) { ru->openair0_cfg.clock_source = internal; } else if (strcmp(paramVal, "external") == 0) { @@ -929,42 +934,41 @@ void ocpRCconfig_RU(RU_t* ru) { if (strcmp(*(vals[RU_LOCAL_RF_IDX].strptr), "yes") == 0) { if ( !(config_isparamset(vals,RU_LOCAL_IF_NAME_IDX)) ) { - ru->if_south = LOCAL_RF; - ru->function = eNodeB_3GPP; - } else { - ru->eth_params.local_if_name = strdup(*(vals[RU_LOCAL_IF_NAME_IDX].strptr)); - ru->eth_params.my_addr = strdup(*(vals[RU_LOCAL_ADDRESS_IDX].strptr)); - ru->eth_params.remote_addr = strdup(*(vals[RU_REMOTE_ADDRESS_IDX].strptr)); - ru->eth_params.my_portc = *(vals[RU_LOCAL_PORTC_IDX].uptr); - ru->eth_params.remote_portc = *(vals[RU_REMOTE_PORTC_IDX].uptr); - ru->eth_params.my_portd = *(vals[RU_LOCAL_PORTD_IDX].uptr); - ru->eth_params.remote_portd = *(vals[RU_REMOTE_PORTD_IDX].uptr); - } - - ru->max_pdschReferenceSignalPower = *(vals[RU_MAX_RS_EPRE_IDX].uptr);; - ru->max_rxgain = *(vals[RU_MAX_RXGAIN_IDX].uptr); - ru->num_bands = vals[RU_BAND_LIST_IDX].numelt; - /* sf_extension is in unit of samples for 30.72MHz here, has to be scaled later */ - ru->sf_extension = *(vals[RU_SF_EXTENSION_IDX].uptr); - ru->end_of_burst_delay = *(vals[RU_END_OF_BURST_DELAY_IDX].uptr); - - for (int i=0; i<ru->num_bands; i++) - ru->band[i] = vals[RU_BAND_LIST_IDX].iptr[i]; + ru->if_south = LOCAL_RF; + ru->function = eNodeB_3GPP; } else { - ru->eth_params.local_if_name = strdup(*(vals[RU_LOCAL_IF_NAME_IDX].strptr)); - ru->eth_params.my_addr = strdup(*(vals[RU_LOCAL_ADDRESS_IDX].strptr)); - ru->eth_params.remote_addr = strdup(*(vals[RU_REMOTE_ADDRESS_IDX].strptr)); - ru->eth_params.my_portc = *(vals[RU_LOCAL_PORTC_IDX].uptr); - ru->eth_params.remote_portc = *(vals[RU_REMOTE_PORTC_IDX].uptr); - ru->eth_params.my_portd = *(vals[RU_LOCAL_PORTD_IDX].uptr); - ru->eth_params.remote_portd = *(vals[RU_REMOTE_PORTD_IDX].uptr); - } /* strcmp(local_rf, "yes") != 0 */ - - ru->nb_tx = *(vals[RU_NB_TX_IDX].uptr); - ru->nb_rx = *(vals[RU_NB_RX_IDX].uptr); - ru->att_tx = *(vals[RU_ATT_TX_IDX].uptr); - ru->att_rx = *(vals[RU_ATT_RX_IDX].uptr); + ru->eth_params.local_if_name = strdup(*(vals[RU_LOCAL_IF_NAME_IDX].strptr)); + ru->eth_params.my_addr = strdup(*(vals[RU_LOCAL_ADDRESS_IDX].strptr)); + ru->eth_params.remote_addr = strdup(*(vals[RU_REMOTE_ADDRESS_IDX].strptr)); + ru->eth_params.my_portc = *(vals[RU_LOCAL_PORTC_IDX].uptr); + ru->eth_params.remote_portc = *(vals[RU_REMOTE_PORTC_IDX].uptr); + ru->eth_params.my_portd = *(vals[RU_LOCAL_PORTD_IDX].uptr); + ru->eth_params.remote_portd = *(vals[RU_REMOTE_PORTD_IDX].uptr); + } + + ru->max_pdschReferenceSignalPower = *(vals[RU_MAX_RS_EPRE_IDX].uptr);; + ru->max_rxgain = *(vals[RU_MAX_RXGAIN_IDX].uptr); + ru->num_bands = vals[RU_BAND_LIST_IDX].numelt; + /* sf_extension is in unit of samples for 30.72MHz here, has to be scaled later */ + ru->sf_extension = *(vals[RU_SF_EXTENSION_IDX].uptr); + ru->end_of_burst_delay = *(vals[RU_END_OF_BURST_DELAY_IDX].uptr); + for (int i=0; i<ru->num_bands; i++) + ru->band[i] = vals[RU_BAND_LIST_IDX].iptr[i]; + } else { + ru->eth_params.local_if_name = strdup(*(vals[RU_LOCAL_IF_NAME_IDX].strptr)); + ru->eth_params.my_addr = strdup(*(vals[RU_LOCAL_ADDRESS_IDX].strptr)); + ru->eth_params.remote_addr = strdup(*(vals[RU_REMOTE_ADDRESS_IDX].strptr)); + ru->eth_params.my_portc = *(vals[RU_LOCAL_PORTC_IDX].uptr); + ru->eth_params.remote_portc = *(vals[RU_REMOTE_PORTC_IDX].uptr); + ru->eth_params.my_portd = *(vals[RU_LOCAL_PORTD_IDX].uptr); + ru->eth_params.remote_portd = *(vals[RU_REMOTE_PORTD_IDX].uptr); + } /* strcmp(local_rf, "yes") != 0 */ + + ru->nb_tx = *(vals[RU_NB_TX_IDX].uptr); + ru->nb_rx = *(vals[RU_NB_RX_IDX].uptr); + ru->att_tx = *(vals[RU_ATT_TX_IDX].uptr); + ru->att_rx = *(vals[RU_ATT_RX_IDX].uptr); return; } @@ -1044,28 +1048,28 @@ void init_pdcp(void) { pdcp_initmask = pdcp_initmask | ENB_NAS_USE_TUN_W_MBMS_BIT; if ( split73!=SPLIT73_DU) - pdcp_module_init(pdcp_initmask); + pdcp_module_init(pdcp_initmask, 0); if (NODE_IS_CU(RC.rrc[0]->node_type)) { - //pdcp_set_rlc_data_req_func((send_rlc_data_req_func_t)proto_agent_send_rlc_data_req); + //pdcp_set_rlc_data_req_func(proto_agent_send_rlc_data_req); } else { - pdcp_set_rlc_data_req_func((send_rlc_data_req_func_t) rlc_data_req); - pdcp_set_pdcp_data_ind_func((pdcp_data_ind_func_t) pdcp_data_ind); + pdcp_set_rlc_data_req_func(rlc_data_req); + pdcp_set_pdcp_data_ind_func(pdcp_data_ind); } } else { - //pdcp_set_pdcp_data_ind_func((pdcp_data_ind_func_t) proto_agent_send_pdcp_data_ind); + //pdcp_set_pdcp_data_ind_func(proto_agent_send_pdcp_data_ind); } } static void wait_nfapi_init(char *thread_name) { - printf( "waiting for NFAPI PNF connection and population of global structure (%s)\n",thread_name); + LOG_I(ENB_APP, "waiting for NFAPI PNF connection and population of global structure (%s)\n",thread_name); pthread_mutex_lock( &nfapi_sync_mutex ); while (nfapi_sync_var<0) pthread_cond_wait( &nfapi_sync_cond, &nfapi_sync_mutex ); pthread_mutex_unlock(&nfapi_sync_mutex); - printf( "NFAPI: got sync (%s)\n", thread_name); + LOG_I(ENB_APP, "NFAPI: got sync (%s)\n", thread_name); } void terminate_task(module_id_t mod_id, task_id_t from, task_id_t to) { @@ -1078,7 +1082,6 @@ void terminate_task(module_id_t mod_id, task_id_t from, task_id_t to) { int stop_L1L2(module_id_t enb_id) { LOG_W(ENB_APP, "stopping lte-softmodem\n"); - /* these tasks need to pick up new configuration */ terminate_task(enb_id, TASK_ENB_APP, TASK_RRC_ENB); oai_exit = 1; @@ -1109,11 +1112,9 @@ int restart_L1L2(module_id_t enb_id) { pthread_mutex_lock(&sync_mutex); sync_var = -1; pthread_mutex_unlock(&sync_mutex); - /* copy the changed frame parameters to the RU */ /* TODO this should be done for all RUs associated to this eNB */ memcpy(&ru->frame_parms, &RC.eNB[enb_id][0]->frame_parms, sizeof(LTE_DL_FRAME_PARMS)); - /* reset the list of connected UEs in the MAC, since in this process with * loose all UEs (have to reconnect) */ init_UE_info(&RC.mac[enb_id]->UE_info); @@ -1149,7 +1150,7 @@ int main ( int argc, char **argv ) { #if T_TRACER T_Config_Init(); #endif - configure_linux(); + set_latency_target(); set_softmodem_sighandler(); cpuf=get_cpu_freq_GHz(); set_taus_seed (0); @@ -1177,7 +1178,6 @@ int main ( int argc, char **argv ) { // but RU thread deals with pre_scd and this is necessary in VNF and simulator. // some initialization is necessary and init_ru_vnf do this. RU_t ru; - /* We need to read RU configuration before FlexRAN starts so it knows what * splits to report. Actual RU start comes later. */ @@ -1189,9 +1189,10 @@ int main ( int argc, char **argv ) { } if ( strlen(get_softmodem_params()->split73) > 0 ) { - char tmp[1024]={0}; + char tmp[1024]= {0}; strncpy(tmp,get_softmodem_params()->split73, 1023); tmp[2]=0; + if ( strncasecmp(tmp,"cu", 2)==0 ) split73=SPLIT73_CU; else if ( strncasecmp(tmp,"du", 2)==0 ) @@ -1199,13 +1200,13 @@ int main ( int argc, char **argv ) { else AssertFatal(false,"split73 syntax: <cu|du>:<remote ip addr>[:<ip port>] (string found: %s) \n",get_softmodem_params()->split73); } - + if (RC.nb_inst > 0) { /* Start the agent. If it is turned off in the configuration, it won't start */ for (i = 0; i < RC.nb_inst; i++) { //flexran_agent_start(i); } - + /* initializes PDCP and sets correct RLC Request/PDCP Indication callbacks * for monolithic/F1 modes */ init_pdcp(); @@ -1284,17 +1285,14 @@ int main ( int argc, char **argv ) { printf("About to Init RU threads RC.nb_RU:%d\n", RC.nb_RU); - if (RC.nb_RU >0 && NFAPI_MODE!=NFAPI_MODE_VNF) { printf("Initializing RU threads\n"); ocp_init_RU(&ru, - get_softmodem_params()->rf_config_file, - get_softmodem_params()->send_dmrs_sync); - - ru.rf_map.card=0; - ru.rf_map.chain=CC_id+(get_softmodem_params()->chain_offset); - init_RU_proc(&ru); - + get_softmodem_params()->rf_config_file, + get_softmodem_params()->send_dmrs_sync); + ru.rf_map.card=0; + ru.rf_map.chain=CC_id+(get_softmodem_params()->chain_offset); + init_RU_proc(&ru); config_sync_var=0; if (NFAPI_MODE==NFAPI_MODE_PNF) { // PNF @@ -1365,7 +1363,6 @@ int main ( int argc, char **argv ) { pthread_cond_destroy(&nfapi_sync_cond); pthread_mutex_destroy(&nfapi_sync_mutex); pthread_mutex_destroy(&ue_pf_po_mutex); - } terminate_opt(); diff --git a/executables/nr-gnb.c b/executables/nr-gnb.c index 8e1b9c6765bb9496e2e84b66a84ad3f06666dff2..2b1c36407bd7073198d89539b103ab72b6c0bf20 100644 --- a/executables/nr-gnb.c +++ b/executables/nr-gnb.c @@ -87,7 +87,6 @@ #include <openair1/PHY/NR_TRANSPORT/nr_ulsch.h> #include <openair1/PHY/NR_TRANSPORT/nr_dlsch.h> #include <PHY/NR_ESTIMATION/nr_ul_estimation.h> -//#define DEBUG_THREADS 1 //#define USRP_DEBUG 1 // Fix per CC openair rf/if device update @@ -114,7 +113,6 @@ time_stats_t softmodem_stats_rx_sf; // total rx time void tx_func(void *param) { processingData_L1tx_t *info = (processingData_L1tx_t *) param; - PHY_VARS_gNB *gNB = info->gNB; int frame_tx = info->frame; int slot_tx = info->slot; @@ -122,35 +120,9 @@ void tx_func(void *param) { frame_tx, slot_tx, 1); - info->slot = -1; - //if ((frame_tx&127) == 0) dump_pdsch_stats(fd,gNB); - - // If the later of the 2 L1 tx thread finishes first, - // we wait for the earlier one to finish and start the RU thread - // to avoid realtime issues with USRP - - // Start RU TX processing. - notifiedFIFO_elt_t *res; - res = pullTpool(gNB->resp_RU_tx, gNB->threadPool); - processingData_RU_t *syncMsg = (processingData_RU_t *)NotifiedFifoData(res); - LOG_D(PHY,"waiting for previous tx to finish, next slot %d,%d\n",syncMsg->next_slot,slot_tx); - while (syncMsg->next_slot != slot_tx) { - pushNotifiedFIFO(gNB->resp_RU_tx, res); - res = pullTpool(gNB->resp_RU_tx, gNB->threadPool); - syncMsg = (processingData_RU_t *)NotifiedFifoData(res); - } - LOG_D(PHY,"previous tx finished, next slot %d,%d\n",syncMsg->next_slot,slot_tx); - syncMsg->frame_tx = frame_tx; - syncMsg->slot_tx = slot_tx; - syncMsg->next_slot = get_next_downlink_slot(gNB, &gNB->gNB_config, frame_tx, slot_tx); - syncMsg->timestamp_tx = info->timestamp_tx; - syncMsg->ru = gNB->RU_list[0]; - res->key = slot_tx; - pushTpool(gNB->threadPool, res); } void rx_func(void *param) { - processingData_L1_t *info = (processingData_L1_t *) param; PHY_VARS_gNB *gNB = info->gNB; int frame_rx = info->frame_rx; @@ -200,7 +172,7 @@ void rx_func(void *param) { int down_removed = 0; int pucch_removed = 0; for (int i = 0; i < rnti_to_remove_count; i++) { - LOG_W(NR_PHY, "to remove rnti %d\n", rnti_to_remove[i]); + LOG_W(NR_PHY, "to remove rnti 0x%04x\n", rnti_to_remove[i]); void clean_gNB_ulsch(NR_gNB_ULSCH_t *ulsch); void clean_gNB_dlsch(NR_gNB_DLSCH_t *dlsch); int j; @@ -240,7 +212,6 @@ void rx_func(void *param) { // RX processing int tx_slot_type = nr_slot_select(cfg,frame_tx,slot_tx); int rx_slot_type = nr_slot_select(cfg,frame_rx,slot_rx); - if (rx_slot_type == NR_UPLINK_SLOT || rx_slot_type == NR_MIXED_SLOT) { // UE-specific RX processing for subframe n // TODO: check if this is correct for PARALLEL_RU_L1_TRX_SPLIT @@ -276,15 +247,12 @@ void rx_func(void *param) { if (tx_slot_type == NR_DOWNLINK_SLOT || tx_slot_type == NR_MIXED_SLOT) { notifiedFIFO_elt_t *res; - res = pullTpool(gNB->resp_L1_tx, gNB->threadPool); - processingData_L1tx_t *syncMsg = (processingData_L1tx_t *)NotifiedFifoData(res); - while (syncMsg->slot != slot_tx) { - pushNotifiedFIFO(gNB->resp_L1_tx, res); - res = pullTpool(gNB->resp_L1_tx, gNB->threadPool); - syncMsg = (processingData_L1tx_t *)NotifiedFifoData(res); - } + processingData_L1tx_t *syncMsg; + // Its a FIFO so it maitains the order in which the MAC fills the messages + // so no need for checking for right slot + res = pullTpool(gNB->L1_tx_filled, gNB->threadPool); + syncMsg = (processingData_L1tx_t *)NotifiedFifoData(res); syncMsg->gNB = gNB; - AssertFatal(syncMsg->slot == slot_tx, "Thread message slot and logical slot number do not match\n"); syncMsg->timestamp_tx = info->timestamp_tx; res->key = slot_tx; pushTpool(gNB->threadPool, res); @@ -332,8 +300,8 @@ void rx_func(void *param) { } static void dump_L1_meas_stats(PHY_VARS_gNB *gNB, RU_t *ru, char *output) { int stroff = 0; - stroff += print_meas_log(gNB->phy_proc_tx_0, "L1 Tx processing thread 0", NULL, NULL, output); - stroff += print_meas_log(gNB->phy_proc_tx_1, "L1 Tx processing thread 1", NULL, NULL, output+stroff); + stroff += print_meas_log(gNB->phy_proc_tx[0], "L1 Tx processing thread 0", NULL, NULL, output); + //stroff += print_meas_log(gNB->phy_proc_tx[1], "L1 Tx processing thread 1", NULL, NULL, output+stroff); stroff += print_meas_log(&gNB->dlsch_encoding_stats, "DLSCH encoding", NULL, NULL, output+stroff); stroff += print_meas_log(&gNB->phy_proc_rx, "L1 Rx processing", NULL, NULL, output+stroff); stroff += print_meas_log(&gNB->ul_indication_stats, "UL Indication", NULL, NULL, output+stroff); @@ -369,8 +337,8 @@ void *nrL1_stats_thread(void *param) { fd=fopen("nrL1_stats.log","w"); AssertFatal(fd!=NULL,"Cannot open nrL1_stats.log\n"); - reset_meas(gNB->phy_proc_tx_0); - reset_meas(gNB->phy_proc_tx_1); + reset_meas(gNB->phy_proc_tx[0]); + //reset_meas(gNB->phy_proc_tx[1]); reset_meas(&gNB->dlsch_encoding_stats); reset_meas(&gNB->phy_proc_rx); reset_meas(&gNB->ul_indication_stats); @@ -392,6 +360,52 @@ void *nrL1_stats_thread(void *param) { return(NULL); } +// This thread reads the finished L1 tx jobs from threaPool +// and pushes RU tx thread in the right order. It works only +// two parallel L1 tx threads. +void *tx_reorder_thread(void* param) { + PHY_VARS_gNB *gNB = (PHY_VARS_gNB *)param; + notifiedFIFO_elt_t *resL1Reserve = NULL; + + + resL1Reserve=pullTpool(gNB->L1_tx_out, gNB->threadPool); + int next_tx_slot=((processingData_L1tx_t *)NotifiedFifoData(resL1Reserve))->slot; + + while (!oai_exit) { + notifiedFIFO_elt_t *resL1; + if (resL1Reserve) { + resL1=resL1Reserve; + if (((processingData_L1tx_t *)NotifiedFifoData(resL1))->slot != next_tx_slot) { + LOG_E(PHY,"order mistake"); + resL1Reserve=NULL; + resL1 = pullTpool(gNB->L1_tx_out, gNB->threadPool); + } + } else { + resL1 = pullTpool(gNB->L1_tx_out, gNB->threadPool); + if (((processingData_L1tx_t *)NotifiedFifoData(resL1))->slot != next_tx_slot) { + if (resL1Reserve) + LOG_E(PHY,"error, have a stored packet, then a second one\n"); + resL1Reserve=resL1; + resL1 = pullTpool(gNB->L1_tx_out, gNB->threadPool); + if (((processingData_L1tx_t *)NotifiedFifoData(resL1))->slot != next_tx_slot) + LOG_E(PHY,"error, pull two msg, none is good\n"); + } + } + processingData_L1tx_t *syncMsgL1= (processingData_L1tx_t *)NotifiedFifoData(resL1); + processingData_RU_t syncMsgRU; + syncMsgRU.frame_tx = syncMsgL1->frame; + syncMsgRU.slot_tx = syncMsgL1->slot; + syncMsgRU.timestamp_tx = syncMsgL1->timestamp_tx; + syncMsgRU.ru = gNB->RU_list[0]; + next_tx_slot = get_next_downlink_slot(gNB, &gNB->gNB_config, syncMsgRU.frame_tx, syncMsgRU.slot_tx); + pushNotifiedFIFO(gNB->L1_tx_free, resL1); + if (resL1==resL1Reserve) + resL1Reserve=NULL; + ru_tx_func((void*)&syncMsgRU); + } + return(NULL); +} + void init_gNB_Tpool(int inst) { PHY_VARS_gNB *gNB; gNB = RC.gNB[inst]; @@ -400,8 +414,8 @@ void init_gNB_Tpool(int inst) { // ULSCH decoding threadpool gNB->threadPool = (tpool_t*)malloc(sizeof(tpool_t)); 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->pusch_proc_threads,numCPU); - int threadCnt = min(numCPU, gNB->pusch_proc_threads); + 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"); @@ -423,37 +437,28 @@ void init_gNB_Tpool(int inst) { pushNotifiedFIFO(gNB->resp_L1,msg); // to unblock the process in the beginning // L1 TX result FIFO - gNB->resp_L1_tx = (notifiedFIFO_t*) malloc(sizeof(notifiedFIFO_t)); - initNotifiedFIFO(gNB->resp_L1_tx); + gNB->L1_tx_free = (notifiedFIFO_t*) malloc(sizeof(notifiedFIFO_t)); + gNB->L1_tx_filled = (notifiedFIFO_t*) malloc(sizeof(notifiedFIFO_t)); + gNB->L1_tx_out = (notifiedFIFO_t*) malloc(sizeof(notifiedFIFO_t)); + initNotifiedFIFO(gNB->L1_tx_free); + initNotifiedFIFO(gNB->L1_tx_filled); + initNotifiedFIFO(gNB->L1_tx_out); + // we create 2 threads for L1 tx processing - notifiedFIFO_elt_t *msgL1Tx = newNotifiedFIFO_elt(sizeof(processingData_L1tx_t),0,gNB->resp_L1_tx,tx_func); - processingData_L1tx_t *msgDataTx = (processingData_L1tx_t *)NotifiedFifoData(msgL1Tx); - init_DLSCH_struct(gNB, msgDataTx); - msgDataTx->slot = -1; - memset(msgDataTx->ssb, 0, 64*sizeof(NR_gNB_SSB_t)); - reset_meas(&msgDataTx->phy_proc_tx); - gNB->phy_proc_tx_0 = &msgDataTx->phy_proc_tx; - pushNotifiedFIFO(gNB->resp_L1_tx,msgL1Tx); // to unblock the process in the beginning - - msgL1Tx = newNotifiedFIFO_elt(sizeof(processingData_L1tx_t),0,gNB->resp_L1_tx,tx_func); - msgDataTx = (processingData_L1tx_t *)NotifiedFifoData(msgL1Tx); - init_DLSCH_struct(gNB, msgDataTx); - msgDataTx->slot = -1; - memset(msgDataTx->ssb, 0, 64*sizeof(NR_gNB_SSB_t)); - reset_meas(&msgDataTx->phy_proc_tx); - gNB->phy_proc_tx_1 = &msgDataTx->phy_proc_tx; - pushNotifiedFIFO(gNB->resp_L1_tx,msgL1Tx); // to unblock the process in the beginning - - // RU TX result FIFO - gNB->resp_RU_tx = (notifiedFIFO_t*) malloc(sizeof(notifiedFIFO_t)); - initNotifiedFIFO(gNB->resp_RU_tx); - notifiedFIFO_elt_t *msgRUTx = newNotifiedFIFO_elt(sizeof(processingData_RU_t),0,gNB->resp_RU_tx,ru_tx_func); - processingData_RU_t *msgData = (processingData_RU_t*)msgRUTx->msgData; - int first_tx_slot = sf_ahead*gNB->frame_parms.slots_per_subframe; - msgData->next_slot = get_next_downlink_slot(gNB, &gNB->gNB_config, 0, first_tx_slot-1); - pushNotifiedFIFO(gNB->resp_RU_tx,msgRUTx); // to unblock the process in the beginning - - threadCreate(&proc->L1_stats_thread,nrL1_stats_thread,(void*)gNB,"L1_stats",-1,OAI_PRIORITY_RT_LOW); + for (int i=0; i < 2; i++) { + notifiedFIFO_elt_t *msgL1Tx = newNotifiedFIFO_elt(sizeof(processingData_L1tx_t),0,gNB->L1_tx_out,tx_func); + processingData_L1tx_t *msgDataTx = (processingData_L1tx_t *)NotifiedFifoData(msgL1Tx); + init_DLSCH_struct(gNB, msgDataTx); + memset(msgDataTx->ssb, 0, 64*sizeof(NR_gNB_SSB_t)); + reset_meas(&msgDataTx->phy_proc_tx); + gNB->phy_proc_tx[i] = &msgDataTx->phy_proc_tx; + pushNotifiedFIFO(gNB->L1_tx_free,msgL1Tx); // to unblock the process in the beginning + } + + if (!get_softmodem_params()->emulate_l1) + threadCreate(&proc->L1_stats_thread,nrL1_stats_thread,(void*)gNB,"L1_stats",-1,OAI_PRIORITY_RT_LOW); + + threadCreate(&proc->pthread_tx_reorder, tx_reorder_thread, (void *)gNB, "thread_tx_reorder", -1, OAI_PRIORITY_RT_MAX); } diff --git a/executables/nr-ru.c b/executables/nr-ru.c index 3a2589632bde85268a9c5a5f76eb2604cb7f26e8..08decf0f679a6c15d1f9e51a56a50951dfeb3143 100644 --- a/executables/nr-ru.c +++ b/executables/nr-ru.c @@ -77,10 +77,12 @@ static int DEFBFW[] = {0x00007fff}; #include "T.h" #include "nfapi_interface.h" +#include <nfapi/oai_integration/vendor_ext.h> extern volatile int oai_exit; - +extern struct timespec timespec_sub(struct timespec lhs, struct timespec rhs); +extern struct timespec timespec_add(struct timespec lhs, struct timespec rhs); extern void nr_phy_free_RU(RU_t *); extern void nr_phy_config_request(NR_PHY_Config_t *gNB); #include "executables/thread-common.h" @@ -1323,9 +1325,33 @@ void *ru_thread( void *param ) { } // This is a forever while loop, it loops over subframes which are scheduled by incoming samples from HW devices + struct timespec slot_start; + clock_gettime(CLOCK_MONOTONIC, &slot_start); + + struct timespec slot_duration; + slot_duration.tv_sec = 0; + //slot_duration.tv_nsec = 0.5e6; + slot_duration.tv_nsec = 0.5e6; + + + while (!oai_exit) { - // these are local subframe/frame counters to check that we are in synch with the fronthaul timing. - // They are set on the first rx/tx in the underly FH routines. + + if (NFAPI_MODE==NFAPI_MODE_VNF) { + // We should make a VNF main loop with proper tasks calls in case of VNF + slot_start = timespec_add(slot_start,slot_duration); + struct timespec curr_time; + clock_gettime(CLOCK_MONOTONIC, &curr_time); + + struct timespec sleep_time; + + if((slot_start.tv_sec > curr_time.tv_sec) || (slot_start.tv_sec == curr_time.tv_sec && slot_start.tv_nsec > curr_time.tv_nsec)){ + sleep_time = timespec_sub(slot_start,curr_time); + + usleep(sleep_time.tv_nsec * 1e-3); + } + } + if (slot==(fp->slots_per_frame-1)) { slot=0; frame++; @@ -1445,11 +1471,9 @@ void *ru_thread( void *param ) { res = pullNotifiedFIFO(gNB->resp_L1); delNotifiedFIFO_elt(res); - res = pullNotifiedFIFO(gNB->resp_L1_tx); - delNotifiedFIFO_elt(res); - res = pullNotifiedFIFO(gNB->resp_L1_tx); + res = pullNotifiedFIFO(gNB->L1_tx_free); delNotifiedFIFO_elt(res); - res = pullNotifiedFIFO(gNB->resp_RU_tx); + res = pullNotifiedFIFO(gNB->L1_tx_free); delNotifiedFIFO_elt(res); ru_thread_status = 0; diff --git a/executables/nr-softmodem-common.h b/executables/nr-softmodem-common.h index c02155326b6b5be42f0c2225604078d70ba430f5..45d7852adc134fb6de30b5b60d598563ff90097d 100644 --- a/executables/nr-softmodem-common.h +++ b/executables/nr-softmodem-common.h @@ -87,8 +87,9 @@ #define CONFIG_HLP_NOTWAIT "don't wait for tracer, start immediately\n" #define CONFIG_HLP_TNOFORK "to ease debugging with gdb\n" #define CONFIG_HLP_DISABLNBIOT "disable nb-iot, even if defined in config\n" -#define CONFIG_HLP_DISABLETIMECORR "disable UE timing correction\n" -#define CONFIG_HLP_RRC_CFG_PATH "path for RRC configuration\n" +#define CONFIG_HLP_DISABLETIMECORR "disable UE timing correction\n" +#define CONFIG_HLP_RRC_CFG_PATH "path for RRC configuration\n" +#define CONFIG_HLP_UECAP_FILE "path for UE Capabilities file\n" #define CONFIG_HLP_NUMEROLOGY "adding numerology for 5G\n" #define CONFIG_HLP_EMULATE_RF "Emulated RF enabled(disable by defult)\n" diff --git a/executables/nr-softmodem.c b/executables/nr-softmodem.c index a2b5c18b6c0a99b0cf516febc6601622c7691704..5f579196455bd3afce45f6c989211cb917b2c295 100644 --- a/executables/nr-softmodem.c +++ b/executables/nr-softmodem.c @@ -111,16 +111,11 @@ int32_t uplink_frequency_offset[MAX_NUM_CCs][4]; //Temp fix for inexistent NR upper layer unsigned char NB_gNB_INST = 1; +char *uecap_file; - -int UE_scan = 1; -int UE_scan_carrier = 0; runmode_t mode = normal_txrx; static double snr_dB=20; -FILE *input_fd=NULL; - - #if MAX_NUM_CCs == 1 rx_gain_t rx_gain_mode[MAX_NUM_CCs][4] = {{max_gain,max_gain,max_gain,max_gain}}; double tx_gain[MAX_NUM_CCs][4] = {{20,0,0,0}}; @@ -193,8 +188,6 @@ openair0_config_t openair0_cfg[MAX_CARDS]; double cpuf; -extern char uecap_xer[1024]; -char uecap_xer_in=0; /* see file openair2/LAYER2/MAC/main.c for why abstraction_flag is needed * this is very hackish - find a proper solution @@ -324,48 +317,36 @@ int create_gNB_tasks(uint32_t gnb_nb) { } } - paramdef_t NETParams[] = GNBNETPARAMS_DESC; - char aprefix[MAX_OPTNAME_SIZE*2 + 8]; - sprintf(aprefix,"%s.[%i].%s",GNB_CONFIG_STRING_GNB_LIST,0,GNB_CONFIG_STRING_NETWORK_INTERFACES_CONFIG); - config_get( NETParams,sizeof(NETParams)/sizeof(paramdef_t),aprefix); + if (AMF_MODE_ENABLED) { - for(int i = GNB_INTERFACE_NAME_FOR_NG_AMF_IDX; i <= GNB_IPV4_ADDRESS_FOR_NG_AMF_IDX; i++) { - if( NETParams[i].strptr == NULL) { - LOG_E(NGAP, "No configuration in the file.\n"); - NGAP_CONF_MODE = 0; - } else { - LOG_D(NGAP, "Configuration in the file: %s.\n",*NETParams[i].strptr); + char* gnb_ipv4_address_for_NGU = NULL; + uint32_t gnb_port_for_NGU = 0; + char* gnb_ipv4_address_for_S1U = NULL; + uint32_t gnb_port_for_S1U = 0; + paramdef_t NETParams[] = GNBNETPARAMS_DESC; + char aprefix[MAX_OPTNAME_SIZE*2 + 8]; + sprintf(aprefix,"%s.[%i].%s",GNB_CONFIG_STRING_GNB_LIST,0,GNB_CONFIG_STRING_NETWORK_INTERFACES_CONFIG); + config_get( NETParams,sizeof(NETParams)/sizeof(paramdef_t),aprefix); + + for(int i = GNB_INTERFACE_NAME_FOR_NG_AMF_IDX; i <= GNB_IPV4_ADDRESS_FOR_NG_AMF_IDX; i++) { + if( NETParams[i].strptr == NULL) { + LOG_E(NGAP, "No configuration in the file.\n"); + NGAP_CONF_MODE = 0; + } else { + LOG_D(NGAP, "Configuration in the file: %s.\n",*NETParams[i].strptr); + } } - } - if (AMF_MODE_ENABLED) { if (gnb_nb > 0) { - /* - if (itti_create_task (TASK_SCTP, sctp_eNB_task, NULL) < 0) { - LOG_E(SCTP, "Create task for SCTP failed\n"); - return -1; - } - */ if(NGAP_CONF_MODE) { if (itti_create_task (TASK_NGAP, ngap_gNB_task, NULL) < 0) { LOG_E(NGAP, "Create task for NGAP failed\n"); return -1; } } else { - LOG_E(NGAP, "Ngap task not created\n"); + LOG_I(NGAP, "Ngap task not created\n"); } - if(!emulate_rf) { - if (itti_create_task (TASK_UDP, udp_eNB_task, NULL) < 0) { - LOG_E(UDP_, "Create task for UDP failed\n"); - return -1; - } - } - - /*if (itti_create_task (TASK_GTPV1_U, &nr_gtpv1u_gNB_task, NULL) < 0) { - LOG_E(GTPU, "Create task for GTPV1U failed\n"); - return -1; - }*/ } } @@ -608,8 +589,33 @@ static void wait_nfapi_init(char *thread_name) { } void init_pdcp(void) { - if (!NODE_IS_DU(RC.nrrrc[0]->node_type)) { - // pdcp_layer_init(); + if (!get_softmodem_params()->nsa) { + if (!NODE_IS_DU(RC.nrrrc[0]->node_type)) { + //pdcp_layer_init(); + uint32_t pdcp_initmask = (IS_SOFTMODEM_NOS1) ? + (PDCP_USE_NETLINK_BIT | LINK_ENB_PDCP_TO_IP_DRIVER_BIT) : LINK_ENB_PDCP_TO_GTPV1U_BIT; + + if (IS_SOFTMODEM_NOS1) { + printf("IS_SOFTMODEM_NOS1 option enabled \n"); + pdcp_initmask = pdcp_initmask | ENB_NAS_USE_TUN_BIT | SOFTMODEM_NOKRNMOD_BIT; + } + + nr_pdcp_module_init(pdcp_initmask, 0); + + if (NODE_IS_CU(RC.nrrrc[0]->node_type)) { + LOG_I(PDCP, "node is CU, pdcp send rlc_data_req by proto_agent \n"); + pdcp_set_rlc_data_req_func((send_rlc_data_req_func_t)proto_agent_send_rlc_data_req); + } else { + LOG_I(PDCP, "node is gNB \n"); + pdcp_set_rlc_data_req_func((send_rlc_data_req_func_t) rlc_data_req); + pdcp_set_pdcp_data_ind_func((pdcp_data_ind_func_t) pdcp_data_ind); + } + } else { + LOG_I(PDCP, "node is DU, rlc send pdcp_data_ind by proto_agent \n"); + pdcp_set_pdcp_data_ind_func((pdcp_data_ind_func_t) proto_agent_send_pdcp_data_ind); + } + } else { + pdcp_layer_init(); uint32_t pdcp_initmask = (IS_SOFTMODEM_NOS1) ? (PDCP_USE_NETLINK_BIT | LINK_ENB_PDCP_TO_IP_DRIVER_BIT) : LINK_ENB_PDCP_TO_GTPV1U_BIT; @@ -618,19 +624,9 @@ void init_pdcp(void) { pdcp_initmask = pdcp_initmask | ENB_NAS_USE_TUN_BIT | SOFTMODEM_NOKRNMOD_BIT; } - pdcp_module_init(pdcp_initmask); - - if (NODE_IS_CU(RC.nrrrc[0]->node_type)) { - LOG_I(PDCP, "node is CU, pdcp send rlc_data_req by proto_agent \n"); - pdcp_set_rlc_data_req_func((send_rlc_data_req_func_t)proto_agent_send_rlc_data_req); - } else { - LOG_I(PDCP, "node is gNB \n"); - pdcp_set_rlc_data_req_func((send_rlc_data_req_func_t) rlc_data_req); - pdcp_set_pdcp_data_ind_func((pdcp_data_ind_func_t) pdcp_data_ind); - } - } else { - LOG_I(PDCP, "node is DU, rlc send pdcp_data_ind by proto_agent \n"); - pdcp_set_pdcp_data_ind_func((pdcp_data_ind_func_t) proto_agent_send_pdcp_data_ind); + nr_pdcp_module_init(pdcp_initmask, 0); + pdcp_set_rlc_data_req_func((send_rlc_data_req_func_t) rlc_data_req); + pdcp_set_pdcp_data_ind_func((pdcp_data_ind_func_t) pdcp_data_ind); } } @@ -653,10 +649,12 @@ int main( int argc, char **argv ) { memset(&openair0_cfg[0],0,sizeof(openair0_config_t)*MAX_CARDS); memset(tx_max_power,0,sizeof(int)*MAX_NUM_CCs); logInit(); - configure_linux(); + set_latency_target(); printf("Reading in command-line options\n"); get_options (); + EPC_MODE_ENABLED = !IS_SOFTMODEM_NOS1; + if (CONFIG_ISFLAGSET(CONFIG_ABORT) ) { fprintf(stderr,"Getting configuration failed\n"); exit(-1); @@ -688,10 +686,12 @@ int main( int argc, char **argv ) { // initialize mscgen log after ITTI MSC_INIT(MSC_E_UTRAN, ADDED_QUEUES_MAX+TASK_MAX); init_opt(); - if(PDCP_USE_NETLINK) - if(!IS_SOFTMODEM_NOS1) - netlink_init(); - + if(PDCP_USE_NETLINK && !IS_SOFTMODEM_NOS1) { + netlink_init(); + if (get_softmodem_params()->nsa) { + init_pdcp(); + } + } #ifndef PACKAGE_VERSION # define PACKAGE_VERSION "UNKNOWN-EXPERIMENTAL" #endif @@ -701,7 +701,9 @@ int main( int argc, char **argv ) { RCconfig_NR_L1(); // don't create if node doesn't connect to RRC/S1/GTP - AssertFatal(create_gNB_tasks(1) == 0,"cannot create ITTI tasks\n"); + int ret=create_gNB_tasks(1); + AssertFatal(ret==0,"cannot create ITTI tasks\n"); + /* Start the agent. If it is turned off in the configuration, it won't start */ /* RCconfig_nr_flexran(); @@ -814,7 +816,9 @@ int main( int argc, char **argv ) { } printf("About to call end_configmodule() from %s() %s:%d\n", __FUNCTION__, __FILE__, __LINE__); + // We have to set PARAMFLAG_NOFREE on right paramters before re-enabling end_configmodule() + //end_configmodule(); printf("Called end_configmodule() from %s() %s:%d\n", __FUNCTION__, __FILE__, __LINE__); // wait for end of program diff --git a/executables/nr-softmodem.h b/executables/nr-softmodem.h index 896c363cbf15ed17d06d6ea242d8c912f9e9b4a1..4190a6074bde182afcacec428a31dc4a84f57471 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}, \ + {"uecap_file", CONFIG_HLP_UECAP_FILE, 0, strptr:(char **)&uecap_file, defstrval:"./uecap.xml", TYPE_STRING, 0}, \ {"s" , CONFIG_HLP_SNR, 0, dblptr:&snr_dB, defdblval:25, TYPE_DOUBLE, 0}, \ } @@ -41,6 +42,7 @@ extern uint32_t target_dl_bw; extern uint32_t target_ul_bw; extern uint64_t dlsch_slot_bitmap; extern uint64_t ulsch_slot_bitmap; +extern char *uecap_file; // 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 60ff40abeb16f8eaaf5a49c1d55085a31291c6cf..dc162a8753b832a84dfe3ee6a76165ce9d46c7c2 100644 --- a/executables/nr-ue.c +++ b/executables/nr-ue.c @@ -29,7 +29,9 @@ #include "SCHED_NR_UE/defs.h" #include "PHY/NR_UE_TRANSPORT/nr_transport_proto_ue.h" #include "executables/softmodem-common.h" +#include "LAYER2/nr_pdcp/nr_pdcp_entity.h" #include "SCHED_NR_UE/pucch_uci_ue_nr.h" +#include "openair2/NR_UE_PHY_INTERFACE/NR_IF_Module.h" /* * NR SLOT PROCESSING SEQUENCE @@ -98,6 +100,53 @@ typedef enum { si = 2 } sync_mode_t; +queue_t nr_rach_ind_queue; + +static void *NRUE_phy_stub_standalone_pnf_task(void *arg); + +static int dump_L1_UE_meas_stats(PHY_VARS_NR_UE *ue, char *output, int max_len) +{ + int stroff = 0; + stroff += print_meas_log(&ue->phy_proc_tx, "L1 TX processing", NULL, NULL, output); + stroff += print_meas_log(&ue->ulsch_encoding_stats, "ULSCH encoding", NULL, NULL, output + stroff); + stroff += print_meas_log(&ue->phy_proc_rx[0], "L1 RX processing t0", NULL, NULL, output + stroff); + stroff += print_meas_log(&ue->phy_proc_rx[1], "L1 RX processing t1", NULL, NULL, output + stroff); + stroff += print_meas_log(&ue->ue_ul_indication_stats, "UL Indication", NULL, NULL, output + stroff); + stroff += print_meas_log(&ue->rx_pdsch_stats, "PDSCH receiver", NULL, NULL, output + stroff); + stroff += print_meas_log(&ue->dlsch_decoding_stats[0], "PDSCH decoding t0", NULL, NULL, output + stroff); + stroff += print_meas_log(&ue->dlsch_decoding_stats[1], "PDSCH decoding t1", NULL, NULL, output + stroff); + stroff += print_meas_log(&ue->dlsch_deinterleaving_stats, " -> Deinterleive", NULL, NULL, output + stroff); + stroff += print_meas_log(&ue->dlsch_rate_unmatching_stats, " -> Rate Unmatch", NULL, NULL, output + stroff); + stroff += print_meas_log(&ue->dlsch_ldpc_decoding_stats, " -> LDPC Decode", NULL, NULL, output + stroff); + stroff += print_meas_log(&ue->dlsch_unscrambling_stats, "PDSCH unscrambling", NULL, NULL, output + stroff); + stroff += print_meas_log(&ue->dlsch_rx_pdcch_stats, "PDCCH handling", NULL, NULL, output + stroff); + return stroff; +} + +static void *nrL1_UE_stats_thread(void *param) +{ + PHY_VARS_NR_UE *ue = (PHY_VARS_NR_UE *) param; + const int max_len = 16384; + char output[max_len]; + char filename[30]; + snprintf(filename, 29, "nrL1_UE_stats-%d.log", ue->Mod_id); + filename[29] = 0; + FILE *fd = fopen(filename, "w"); + AssertFatal(fd != NULL, "Cannot open %s\n", filename); + + while (!oai_exit) { + sleep(1); + const int len = dump_L1_UE_meas_stats(ue, output, max_len); + AssertFatal(len < max_len, "exceeded length\n"); + fwrite(output, len + 1, 1, fd); // + 1 for terminating NULL byte + fflush(fd); + fseek(fd, 0, SEEK_SET); + } + fclose(fd); + + return NULL; +} + void init_nr_ue_vars(PHY_VARS_NR_UE *ue, uint8_t UE_id, uint8_t abstraction_flag) @@ -126,6 +175,382 @@ void init_nr_ue_vars(PHY_VARS_NR_UE *ue, init_N_TA_offset(ue); } +void init_nrUE_standalone_thread(int ue_idx) +{ + int standalone_tx_port = 3611 + ue_idx * 2; + int standalone_rx_port = 3612 + ue_idx * 2; + nrue_init_standalone_socket(standalone_tx_port, standalone_rx_port); + + NR_UE_MAC_INST_t *mac = get_mac_inst(0); + pthread_mutex_init(&mac->mutex_dl_info, NULL); + + pthread_t thread; + if (pthread_create(&thread, NULL, nrue_standalone_pnf_task, NULL) != 0) { + LOG_E(NR_MAC, "pthread_create failed for calling nrue_standalone_pnf_task"); + } + pthread_setname_np(thread, "oai:nrue-stand"); + pthread_t phy_thread; + if (pthread_create(&phy_thread, NULL, NRUE_phy_stub_standalone_pnf_task, NULL) != 0) { + LOG_E(NR_MAC, "pthread_create failed for calling NRUE_phy_stub_standalone_pnf_task"); + } + pthread_setname_np(phy_thread, "oai:nrue-stand-phy"); +} + +static void L1_nsa_prach_procedures(frame_t frame, int slot, fapi_nr_ul_config_prach_pdu *prach_pdu) +{ + NR_UE_MAC_INST_t *mac = get_mac_inst(0); + nfapi_nr_rach_indication_t *rach_ind = CALLOC(1, sizeof(*rach_ind)); + rach_ind->sfn = frame; + rach_ind->slot = slot; + rach_ind->header.message_id = NFAPI_NR_PHY_MSG_TYPE_RACH_INDICATION; + + uint8_t pdu_index = 0; + rach_ind->pdu_list = CALLOC(1, sizeof(*rach_ind->pdu_list)); + rach_ind->number_of_pdus = 1; + rach_ind->pdu_list[pdu_index].phy_cell_id = prach_pdu->phys_cell_id; + rach_ind->pdu_list[pdu_index].symbol_index = prach_pdu->prach_start_symbol; + rach_ind->pdu_list[pdu_index].slot_index = prach_pdu->prach_slot; + rach_ind->pdu_list[pdu_index].freq_index = prach_pdu->num_ra; + rach_ind->pdu_list[pdu_index].avg_rssi = 128; + rach_ind->pdu_list[pdu_index].avg_snr = 0xff; // invalid for now + + rach_ind->pdu_list[pdu_index].num_preamble = 1; + const int num_p = rach_ind->pdu_list[pdu_index].num_preamble; + rach_ind->pdu_list[pdu_index].preamble_list = calloc(num_p, sizeof(nfapi_nr_prach_indication_preamble_t)); + uint8_t preamble_index = get_softmodem_params()->nsa ? + mac->ra.rach_ConfigDedicated->cfra->resources.choice.ssb->ssb_ResourceList.list.array[0]->ra_PreambleIndex : + mac->ra.ra_PreambleIndex; + rach_ind->pdu_list[pdu_index].preamble_list[0].preamble_index = preamble_index; + + rach_ind->pdu_list[pdu_index].preamble_list[0].timing_advance = 0; + rach_ind->pdu_list[pdu_index].preamble_list[0].preamble_pwr = 0xffffffff; + + if (!put_queue(&nr_rach_ind_queue, rach_ind)) + { + for (int pdu_index = 0; pdu_index < rach_ind->number_of_pdus; pdu_index++) + { + free(rach_ind->pdu_list[pdu_index].preamble_list); + } + free(rach_ind->pdu_list); + free(rach_ind); + } + LOG_D(NR_MAC, "We have successfully filled the rach_ind queue with the recently filled rach ind\n"); +} + +static bool sfn_slot_matcher(void *wanted, void *candidate) +{ + nfapi_p7_message_header_t *msg = candidate; + int sfn_sf = *(int*)wanted; + + switch (msg->message_id) + { + case NFAPI_NR_PHY_MSG_TYPE_RACH_INDICATION: + { + nfapi_nr_rach_indication_t *ind = candidate; + return NFAPI_SFNSLOT2SFN(sfn_sf) == ind->sfn && NFAPI_SFNSLOT2SLOT(sfn_sf) == ind->slot; + } + + case NFAPI_NR_PHY_MSG_TYPE_RX_DATA_INDICATION: + { + nfapi_nr_rx_data_indication_t *ind = candidate; + return NFAPI_SFNSLOT2SFN(sfn_sf) == ind->sfn && NFAPI_SFNSLOT2SLOT(sfn_sf) == ind->slot; + } + + case NFAPI_NR_PHY_MSG_TYPE_CRC_INDICATION: + { + nfapi_nr_crc_indication_t *ind = candidate; + return NFAPI_SFNSLOT2SFN(sfn_sf) == ind->sfn && NFAPI_SFNSLOT2SLOT(sfn_sf) == ind->slot; + } + + case NFAPI_NR_PHY_MSG_TYPE_UCI_INDICATION: + { + nfapi_nr_uci_indication_t *ind = candidate; + return NFAPI_SFNSLOT2SFN(sfn_sf) == ind->sfn && NFAPI_SFNSLOT2SLOT(sfn_sf) == ind->slot; + } + + case NFAPI_NR_PHY_MSG_TYPE_DL_TTI_REQUEST: + { + nfapi_nr_dl_tti_request_t *ind = candidate; + return NFAPI_SFNSLOT2SFN(sfn_sf) == ind->SFN && NFAPI_SFNSLOT2SLOT(sfn_sf) == ind->Slot; + } + + case NFAPI_NR_PHY_MSG_TYPE_TX_DATA_REQUEST: + { + nfapi_nr_tx_data_request_t *ind = candidate; + return NFAPI_SFNSLOT2SFN(sfn_sf) == ind->SFN && NFAPI_SFNSLOT2SLOT(sfn_sf) == ind->Slot; + } + + case NFAPI_NR_PHY_MSG_TYPE_UL_DCI_REQUEST: + { + nfapi_nr_ul_dci_request_t *ind = candidate; + return NFAPI_SFNSLOT2SFN(sfn_sf) == ind->SFN && NFAPI_SFNSLOT2SLOT(sfn_sf) == ind->Slot; + } + + case NFAPI_NR_PHY_MSG_TYPE_UL_TTI_REQUEST: + { + nfapi_nr_ul_tti_request_t *ind = candidate; + return NFAPI_SFNSLOT2SFN(sfn_sf) == ind->SFN && NFAPI_SFNSLOT2SLOT(sfn_sf) == ind->Slot; + } + + default: + LOG_E(NR_MAC, "sfn_slot_match bad ID: %d\n", msg->message_id); + + } + + return false; +} + +static void process_queued_nr_nfapi_msgs(NR_UE_MAC_INST_t *mac, int sfn_slot) +{ + nfapi_nr_rach_indication_t *rach_ind = unqueue_matching(&nr_rach_ind_queue, MAX_QUEUE_SIZE, sfn_slot_matcher, &sfn_slot); + nfapi_nr_rx_data_indication_t *rx_ind = unqueue_matching(&nr_rx_ind_queue, MAX_QUEUE_SIZE, sfn_slot_matcher, &sfn_slot); + nfapi_nr_crc_indication_t *crc_ind = unqueue_matching(&nr_crc_ind_queue, MAX_QUEUE_SIZE, sfn_slot_matcher, &sfn_slot); + nfapi_nr_dl_tti_request_t *dl_tti_request = get_queue(&nr_dl_tti_req_queue); + nfapi_nr_ul_dci_request_t *ul_dci_request = get_queue(&nr_ul_dci_req_queue); + + LOG_D(NR_MAC, "Try to get a ul_tti_req for sfn/slot %d %d from queue with %lu items\n", + NFAPI_SFNSLOT2SFN(mac->nr_ue_emul_l1.active_harq_sfn_slot),NFAPI_SFNSLOT2SLOT(mac->nr_ue_emul_l1.active_harq_sfn_slot), nr_ul_tti_req_queue.num_items); + nfapi_nr_ul_tti_request_t *ul_tti_request = unqueue_matching(&nr_ul_tti_req_queue, MAX_QUEUE_SIZE, sfn_slot_matcher, &mac->nr_ue_emul_l1.active_harq_sfn_slot); + if (!ul_tti_request) + { + LOG_D(NR_MAC, "Try to get a ul_tti_req from seprate queue because dl_tti_req was late\n"); + ul_tti_request = unqueue_matching(&nr_wait_ul_tti_req_queue, MAX_QUEUE_SIZE, sfn_slot_matcher, &mac->nr_ue_emul_l1.active_harq_sfn_slot); + } + + if (rach_ind && rach_ind->number_of_pdus > 0) + { + NR_UL_IND_t UL_INFO = { + .rach_ind = *rach_ind, + }; + send_nsa_standalone_msg(&UL_INFO, rach_ind->header.message_id); + for (int i = 0; i < rach_ind->number_of_pdus; i++) + { + free(rach_ind->pdu_list[i].preamble_list); + } + free(rach_ind->pdu_list); + free(rach_ind); + nr_Msg1_transmitted(0, 0, NFAPI_SFNSLOT2SFN(sfn_slot), 0); + } + if (crc_ind && crc_ind->number_crcs > 0) + { + NR_UL_IND_t UL_INFO = { + .crc_ind = *crc_ind, + }; + send_nsa_standalone_msg(&UL_INFO, crc_ind->header.message_id); + free(crc_ind->crc_list); + free(crc_ind); + } + if (rx_ind && rx_ind->number_of_pdus > 0) + { + NR_UL_IND_t UL_INFO = { + .rx_ind = *rx_ind, + }; + send_nsa_standalone_msg(&UL_INFO, rx_ind->header.message_id); + free(rx_ind->pdu_list); + free(rx_ind); + } + if (dl_tti_request) + { + int dl_tti_sfn_slot = NFAPI_SFNSLOT2HEX(dl_tti_request->SFN, dl_tti_request->Slot); + nfapi_nr_tx_data_request_t *tx_data_request = unqueue_matching(&nr_tx_req_queue, MAX_QUEUE_SIZE, sfn_slot_matcher, &dl_tti_sfn_slot); + if (!tx_data_request) + { + LOG_E(NR_MAC, "[%d %d] No corresponding tx_data_request for given dl_tti_request sfn/slot\n", + NFAPI_SFNSLOT2SFN(dl_tti_sfn_slot), NFAPI_SFNSLOT2SLOT(dl_tti_sfn_slot)); + if (get_softmodem_params()->nsa) + save_nr_measurement_info(dl_tti_request); + free(dl_tti_request); + dl_tti_request = NULL; + } + else if (dl_tti_request->dl_tti_request_body.nPDUs > 0 && tx_data_request->Number_of_PDUs > 0) + { + if (get_softmodem_params()->nsa) + save_nr_measurement_info(dl_tti_request); + check_and_process_dci(dl_tti_request, tx_data_request, NULL, NULL); + } + else + { + AssertFatal(false, "We dont have PDUs in either dl_tti %d or tx_req %d\n", + dl_tti_request->dl_tti_request_body.nPDUs, tx_data_request->Number_of_PDUs); + } + } + if (ul_dci_request && ul_dci_request->numPdus > 0) + { + check_and_process_dci(NULL, NULL, ul_dci_request, NULL); + } + if (ul_tti_request && ul_tti_request->n_pdus > 0) + { + check_and_process_dci(NULL, NULL, NULL, ul_tti_request); + } +} + +static void check_nr_prach(NR_UE_MAC_INST_t *mac, nr_uplink_indication_t *ul_info, NR_PRACH_RESOURCES_t *prach_resources) +{ + fapi_nr_ul_config_request_t *ul_config = get_ul_config_request(mac, ul_info->slot_tx); + if (!ul_config) + { + LOG_E(NR_MAC, "mac->ul_config is null! \n"); + return; + } + if (mac->ra.ra_state != RA_SUCCEEDED) + { + AssertFatal(ul_config->number_pdus < sizeof(ul_config->ul_config_list) / sizeof(ul_config->ul_config_list[0]), + "Number of PDUS in ul_config = %d > ul_config_list num elements", ul_config->number_pdus); + fapi_nr_ul_config_prach_pdu *prach_pdu = &ul_config->ul_config_list[ul_config->number_pdus].prach_config_pdu; + uint8_t nr_prach = nr_ue_get_rach(prach_resources, + prach_pdu, + ul_info->module_id, + ul_info->cc_id, + ul_info->frame_tx, + ul_info->gNB_index, + ul_info->slot_tx); + if (nr_prach == 1) + { + L1_nsa_prach_procedures(ul_info->frame_tx, ul_info->slot_tx, prach_pdu); + ul_config->number_pdus = 0; + ul_info->ue_sched_mode = SCHED_ALL; + } + else if (nr_prach == 2) + { + LOG_I(NR_PHY, "In %s: [UE %d] RA completed, setting UE mode to PUSCH\n", __FUNCTION__, ul_info->module_id); + } + else if(nr_prach == 3) + { + LOG_I(NR_PHY, "In %s: [UE %d] RA failed, setting UE mode to PRACH\n", __FUNCTION__, ul_info->module_id); + } + } +} + +static void *NRUE_phy_stub_standalone_pnf_task(void *arg) +{ + LOG_I(MAC, "Clearing Queues\n"); + reset_queue(&nr_rach_ind_queue); + reset_queue(&nr_rx_ind_queue); + reset_queue(&nr_crc_ind_queue); + reset_queue(&nr_uci_ind_queue); + reset_queue(&nr_dl_tti_req_queue); + reset_queue(&nr_tx_req_queue); + reset_queue(&nr_ul_dci_req_queue); + reset_queue(&nr_ul_tti_req_queue); + reset_queue(&nr_wait_ul_tti_req_queue); + + NR_PRACH_RESOURCES_t prach_resources; + memset(&prach_resources, 0, sizeof(prach_resources)); + NR_UL_TIME_ALIGNMENT_t ul_time_alignment; + memset(&ul_time_alignment, 0, sizeof(ul_time_alignment)); + int last_sfn_slot = -1; + uint16_t sfn_slot = 0; + + while (!oai_exit) + { + if (sem_wait(&sfn_slot_semaphore) != 0) + { + LOG_E(NR_MAC, "sem_wait() error\n"); + abort(); + } + uint16_t *slot_ind = get_queue(&nr_sfn_slot_queue); + nr_phy_channel_params_t *ch_info = get_queue(&nr_chan_param_queue); + if (!slot_ind && !ch_info) + { + LOG_D(MAC, "get nr_sfn_slot_queue and nr_chan_param_queue == NULL!\n"); + continue; + } + if (slot_ind) { + sfn_slot = *slot_ind; + } + else if (ch_info) { + sfn_slot = ch_info->sfn_slot; + } + + frame_t frame = NFAPI_SFNSLOT2SFN(sfn_slot); + int slot = NFAPI_SFNSLOT2SLOT(sfn_slot); + if (sfn_slot == last_sfn_slot) + { + LOG_D(NR_MAC, "repeated sfn_sf = %d.%d\n", + frame, slot); + continue; + } + last_sfn_slot = sfn_slot; + + LOG_D(NR_MAC, "The received sfn/slot [%d %d] from proxy\n", + frame, slot); + + module_id_t mod_id = 0; + NR_UE_MAC_INST_t *mac = get_mac_inst(mod_id); + if (get_softmodem_params()->sa && mac->mib == NULL) + { + LOG_D(NR_MAC, "We haven't gotten MIB. Lets see if we received it\n"); + nr_ue_dl_indication(&mac->dl_info, &ul_time_alignment); + process_queued_nr_nfapi_msgs(mac, sfn_slot); + } + if (mac->scc == NULL && mac->scc_SIB == NULL) + { + LOG_D(MAC, "[NSA] mac->scc == NULL and [SA] mac->scc_SIB == NULL!\n"); + continue; + } + + mac->ra.generate_nr_prach = 0; + int CC_id = 0; + uint8_t gNB_id = 0; + nr_uplink_indication_t ul_info; + int slots_per_frame = 20; //30 kHZ subcarrier spacing + int slot_ahead = 2; // TODO: Make this dynamic + ul_info.cc_id = CC_id; + ul_info.gNB_index = gNB_id; + ul_info.module_id = mod_id; + ul_info.frame_rx = frame; + ul_info.slot_rx = slot; + ul_info.slot_tx = (slot + slot_ahead) % slots_per_frame; + ul_info.frame_tx = (ul_info.slot_rx + slot_ahead >= slots_per_frame) ? ul_info.frame_rx + 1 : ul_info.frame_rx; + ul_info.ue_sched_mode = SCHED_ALL; + + if (pthread_mutex_lock(&mac->mutex_dl_info)) abort(); + + memset(&mac->dl_info, 0, sizeof(mac->dl_info)); + mac->dl_info.cc_id = CC_id; + mac->dl_info.gNB_index = gNB_id; + mac->dl_info.module_id = mod_id; + mac->dl_info.frame = frame; + mac->dl_info.slot = slot; + mac->dl_info.thread_id = 0; + mac->dl_info.dci_ind = NULL; + mac->dl_info.rx_ind = NULL; + + if (is_nr_DL_slot(get_softmodem_params()->nsa ? + mac->scc->tdd_UL_DL_ConfigurationCommon : + mac->scc_SIB->tdd_UL_DL_ConfigurationCommon, + ul_info.slot_rx)) + { + nr_ue_dl_indication(&mac->dl_info, &ul_time_alignment); + } + + if (pthread_mutex_unlock(&mac->mutex_dl_info)) abort(); + + if (is_nr_UL_slot(get_softmodem_params()->nsa ? + mac->scc->tdd_UL_DL_ConfigurationCommon : + mac->scc_SIB->tdd_UL_DL_ConfigurationCommon, + ul_info.slot_tx, mac->frame_type)) + { + LOG_D(NR_MAC, "Slot %d. calling nr_ue_ul_ind() from %s\n", ul_info.slot_tx, __FUNCTION__); + nr_ue_ul_indication(&ul_info); + check_nr_prach(mac, &ul_info, &prach_resources); + } + if (!IS_SOFTMODEM_NOS1 && get_softmodem_params()->sa) { + NR_UE_MAC_INST_t *mac = get_mac_inst(0); + protocol_ctxt_t ctxt; + PROTOCOL_CTXT_SET_BY_MODULE_ID(&ctxt, 0, ENB_FLAG_NO, mac->crnti, frame, slot, 0); + pdcp_run(&ctxt); + } + process_queued_nr_nfapi_msgs(mac, sfn_slot); + free(slot_ind); + slot_ind = NULL; + free(ch_info); + ch_info = NULL; + } + return NULL; +} + + /*! * It performs band scanning and synchonization. * \param arg is a pointer to a \ref PHY_VARS_NR_UE structure. @@ -211,7 +636,7 @@ static void UE_synch(void *arg) { uint64_t dl_carrier, ul_carrier; nr_get_carrier_frequencies(UE, &dl_carrier, &ul_carrier); - if (nr_initial_sync(&syncD->proc, UE, 2, get_softmodem_params()->sa, get_nrUE_params()->nr_dlsch_parallel) == 0) { + if (nr_initial_sync(&syncD->proc, UE, 2, get_softmodem_params()->sa) == 0) { freq_offset = UE->common_vars.freq_offset; // frequency offset computed with pss in initial sync hw_slot_offset = ((UE->rx_offset<<1) / UE->frame_parms.samples_per_subframe * UE->frame_parms.slots_per_subframe) + round((float)((UE->rx_offset<<1) % UE->frame_parms.samples_per_subframe)/UE->frame_parms.samples_per_slot0); @@ -284,6 +709,7 @@ void processSlotTX(void *arg) { // trigger L2 to run ue_scheduler thru IF module // [TODO] mapping right after NR initial sync if(UE->if_inst != NULL && UE->if_inst->ul_indication != NULL) { + start_meas(&UE->ue_ul_indication_stats); nr_uplink_indication_t ul_indication; memset((void*)&ul_indication, 0, sizeof(ul_indication)); @@ -298,6 +724,7 @@ void processSlotTX(void *arg) { ul_indication.ue_sched_mode = rxtxD->ue_sched_mode; UE->if_inst->ul_indication(&ul_indication); + stop_meas(&UE->ue_ul_indication_stats); } if ((UE->mode != loop_through_memory) && (rxtxD->ue_sched_mode != NOT_PUSCH)) { @@ -316,6 +743,16 @@ void processSlotRX(void *arg) { int tx_slot_type = nr_ue_slot_select(cfg, proc->frame_tx, proc->nr_slot_tx); uint8_t gNB_id = 0; + if (IS_SOFTMODEM_NOS1 || get_softmodem_params()->sa) { + /* send tick to RLC and PDCP every ms */ + if (proc->nr_slot_rx % UE->frame_parms.slots_per_subframe == 0) { + void nr_rlc_tick(int frame, int subframe); + void nr_pdcp_tick(int frame, int subframe); + nr_rlc_tick(proc->frame_rx, proc->nr_slot_rx / UE->frame_parms.slots_per_subframe); + nr_pdcp_tick(proc->frame_rx, proc->nr_slot_rx / UE->frame_parms.slots_per_subframe); + } + } + if (rx_slot_type == NR_DOWNLINK_SLOT || rx_slot_type == NR_MIXED_SLOT){ if(UE->if_inst != NULL && UE->if_inst->dl_indication != NULL) { @@ -338,14 +775,6 @@ void processSlotRX(void *arg) { protocol_ctxt_t ctxt; PROTOCOL_CTXT_SET_BY_MODULE_ID(&ctxt, UE->Mod_id, ENB_FLAG_NO, mac->crnti, proc->frame_rx, proc->nr_slot_rx, 0); pdcp_run(&ctxt); - - /* send tick to RLC and PDCP every ms */ - if (proc->nr_slot_rx % UE->frame_parms.slots_per_subframe == 0) { - void nr_rlc_tick(int frame, int subframe); - void nr_pdcp_tick(int frame, int subframe); - nr_rlc_tick(proc->frame_rx, proc->nr_slot_rx / UE->frame_parms.slots_per_subframe); - nr_pdcp_tick(proc->frame_rx, proc->nr_slot_rx / UE->frame_parms.slots_per_subframe); - } } // calling UL_indication to schedule things other than PUSCH (eg, PUCCH) rxtxD->ue_sched_mode = NOT_PUSCH; @@ -756,13 +1185,15 @@ void *UE_thread(void *arg) { return NULL; } -void init_NR_UE(int nb_inst, char* rrc_config_path) { +void init_NR_UE(int nb_inst, + char* uecap_file, + char* rrc_config_path) { int inst; NR_UE_MAC_INST_t *mac_inst; NR_UE_RRC_INST_t* rrc_inst; for (inst=0; inst < nb_inst; inst++) { - AssertFatal((rrc_inst = nr_l3_init_ue(rrc_config_path)) != NULL, "can not initialize RRC module\n"); + AssertFatal((rrc_inst = nr_l3_init_ue(uecap_file,rrc_config_path)) != NULL, "can not initialize RRC module\n"); AssertFatal((mac_inst = nr_l2_init_ue(rrc_inst)) != NULL, "can not initialize L2 module\n"); AssertFatal((mac_inst->if_module = nr_ue_if_module_init(inst)) != NULL, "can not initialize IF module\n"); } @@ -778,13 +1209,15 @@ void init_NR_UE_threads(int nb_inst) { LOG_I(PHY,"Intializing UE Threads for instance %d (%p,%p)...\n",inst,PHY_vars_UE_g[inst],PHY_vars_UE_g[inst][0]); threadCreate(&threads[inst], UE_thread, (void *)UE, "UEthread", -1, OAI_PRIORITY_RT_MAX); + pthread_t stat_pthread; + threadCreate(&stat_pthread, nrL1_UE_stats_thread, UE, "L1_UE_stats", -1, OAI_PRIORITY_RT_LOW); } } /* HACK: this function is needed to compile the UE * fix it somehow */ -int8_t find_dlsch(uint16_t rnti, +int find_dlsch(uint16_t rnti, PHY_VARS_eNB *eNB, find_type_t type) { diff --git a/executables/nr-uesoftmodem.c b/executables/nr-uesoftmodem.c index ad5ea982c944e7a32fbc2d69fc56afc4b2e5f755..7663e9ebd8da5d439ae7fb35a8600dfa5ee34aca 100644 --- a/executables/nr-uesoftmodem.c +++ b/executables/nr-uesoftmodem.c @@ -84,6 +84,7 @@ unsigned short config_frames[4] = {2,9,11,13}; #include "executables/thread-common.h" #include "nr_nas_msg_sim.h" +#include <openair1/PHY/MODULATION/nr_modulation.h> extern const char *duplex_mode[]; THREAD_STRUCT thread_struct; @@ -99,7 +100,9 @@ pthread_mutex_t sync_mutex; int sync_var=-1; //!< protected by mutex \ref sync_mutex. int config_sync_var=-1; - +// not used in UE +instance_t CUuniqInstance=0; +instance_t DUuniqInstance=0; RAN_CONTEXT_t RC; volatile int oai_exit = 0; @@ -115,6 +118,7 @@ int vcdflag = 0; double rx_gain_off = 0.0; char *usrp_args = NULL; char *rrc_config_path = NULL; +char *uecap_file = NULL; int dumpframe = 0; uint64_t downlink_frequency[MAX_NUM_CCs][4]; @@ -147,14 +151,13 @@ int numerology = 0; int oaisim_flag = 0; int emulate_rf = 0; uint32_t N_RB_DL = 106; -char uecap_xer_in = 0; -char uecap_xer[1024]; /* see file openair2/LAYER2/MAC/main.c for why abstraction_flag is needed * this is very hackish - find a proper solution */ uint8_t abstraction_flag=0; + /*---------------------BMC: timespec helpers -----------------------------*/ struct timespec min_diff_time = { .tv_sec = 0, .tv_nsec = 0 }; @@ -188,10 +191,17 @@ int create_tasks_nrue(uint32_t ue_nb) { LOG_E(NR_RRC, "Create task for RRC UE failed\n"); return -1; } - if (itti_create_task (TASK_NAS_NRUE, nas_nrue_task, NULL) < 0) { - LOG_E(NR_RRC, "Create task for NAS UE failed\n"); - return -1; - } + if (get_softmodem_params()->nsa) { + init_connections_with_lte_ue(); + if (itti_create_task (TASK_RRC_NSA_NRUE, recv_msgs_from_lte_ue, NULL) < 0) { + LOG_E(NR_RRC, "Create task for RRC NSA nr-UE failed\n"); + return -1; + } + } + if (itti_create_task (TASK_NAS_NRUE, nas_nrue_task, NULL) < 0) { + LOG_E(NR_RRC, "Create task for NAS UE failed\n"); + return -1; + } } itti_wait_ready(0); @@ -233,20 +243,15 @@ nrUE_params_t *get_nrUE_params(void) { /* initialie thread pools used for NRUE processing paralleliation */ void init_tpools(uint8_t nun_dlsch_threads) { char *params = NULL; - if (IS_SOFTMODEM_RFSIM) { - params = calloc(1,2); - memcpy(params,"N",1); - } - else { - params = calloc(1,(NR_RX_NB_TH*NR_NB_TH_SLOT*3)+1); - for (int i=0; i<NR_RX_NB_TH*NR_NB_TH_SLOT; i++) { - memcpy(params+(i*3),"-1,",3); - } + params = calloc(1,(NR_RX_NB_TH*NR_NB_TH_SLOT*3)+1); + for (int i=0; i<NR_RX_NB_TH*NR_NB_TH_SLOT; i++) { + memcpy(params+(i*3),"-1,",3); } initTpool(params, &(nrUE_params.Tpool), false); free(params); init_dlsch_tpool( nun_dlsch_threads); } + static void get_options(void) { nrUE_params.ofdm_offset_divisor = 8; @@ -258,14 +263,6 @@ static void get_options(void) { if (vcdflag > 0) ouput_vcd = 1; - - if ( !(CONFIG_ISFLAGSET(CONFIG_ABORT)) && (!(CONFIG_ISFLAGSET(CONFIG_NOOOPT))) ) { - // Here the configuration file is the XER encoded UE capabilities - // Read it in and store in asn1c data structures - sprintf(uecap_xer,"%stargets/PROJECTS/GENERIC-LTE-EPC/CONF/UE_config.xml",getenv("OPENAIR_HOME")); - printf("%s\n",uecap_xer); - uecap_xer_in=1; - } /* UE with config file */ } // set PHY vars from command line @@ -374,23 +371,21 @@ void init_openair0(void) { } } -void init_pdcp(void) { +static void init_pdcp(int ue_id) { uint32_t pdcp_initmask = (!IS_SOFTMODEM_NOS1) ? LINK_ENB_PDCP_TO_GTPV1U_BIT : (LINK_ENB_PDCP_TO_GTPV1U_BIT | PDCP_USE_NETLINK_BIT | LINK_ENB_PDCP_TO_IP_DRIVER_BIT); /*if (IS_SOFTMODEM_BASICSIM || IS_SOFTMODEM_RFSIM || (nfapi_getmode()==NFAPI_UE_STUB_PNF)) { pdcp_initmask = pdcp_initmask | UE_NAS_USE_TUN_BIT; }*/ - if (IS_SOFTMODEM_NOKRNMOD) + if (IS_SOFTMODEM_NOKRNMOD) { pdcp_initmask = pdcp_initmask | UE_NAS_USE_TUN_BIT; - - /*if (rlc_module_init() != 0) { + } + if (get_softmodem_params()->nsa && rlc_module_init(0) != 0) { LOG_I(RLC, "Problem at RLC initiation \n"); } pdcp_layer_init(); - nr_DRB_preconfiguration();*/ - pdcp_layer_init(); - pdcp_module_init(pdcp_initmask); + nr_pdcp_module_init(pdcp_initmask, ue_id); pdcp_set_rlc_data_req_func((send_rlc_data_req_func_t) rlc_data_req); pdcp_set_pdcp_data_ind_func((pdcp_data_ind_func_t) pdcp_data_ind); } @@ -402,6 +397,13 @@ void *rrc_enb_process_msg(void *notUsed) { int main( int argc, char **argv ) { + set_priority(79); + if (mlockall(MCL_CURRENT | MCL_FUTURE) == -1) + { + fprintf(stderr, "mlockall: %s\n", strerror(errno)); + return EXIT_FAILURE; + } + //uint8_t beta_ACK=0,beta_RI=0,beta_CQI=2; PHY_VARS_NR_UE *UE[MAX_NUM_CCs]; start_background_system(); @@ -420,11 +422,11 @@ int main( int argc, char **argv ) { get_options (); //Command-line options specific for NRUE get_common_options(SOFTMODEM_5GUE_BIT); - init_tpools(nrUE_params.nr_dlsch_parallel); CONFIG_CLEARRTFLAG(CONFIG_NOEXITONHELP); #if T_TRACER T_Config_Init(); #endif + init_tpools(nrUE_params.nr_dlsch_parallel); //randominit (0); set_taus_seed (0); @@ -443,14 +445,28 @@ int main( int argc, char **argv ) { #endif LOG_I(HW, "Version: %s\n", PACKAGE_VERSION); - init_NR_UE(1,rrc_config_path); - if(IS_SOFTMODEM_NOS1 || get_softmodem_params()->sa) - init_pdcp(); + init_NR_UE(1,uecap_file,rrc_config_path); + + int mode_offset = get_softmodem_params()->nsa ? NUMBER_OF_UE_MAX : 1; + uint16_t node_number = get_softmodem_params()->node_number; + ue_id_g = (node_number == 0) ? 0 : node_number - 2; + AssertFatal(ue_id_g >= 0, "UE id is expected to be nonnegative.\n"); + if(IS_SOFTMODEM_NOS1 || get_softmodem_params()->sa || get_softmodem_params()->nsa) { + if(node_number == 0) { + init_pdcp(0); + } + else { + init_pdcp(mode_offset + ue_id_g); + } + } NB_UE_INST=1; NB_INST=1; PHY_vars_UE_g = malloc(sizeof(PHY_VARS_NR_UE **)); PHY_vars_UE_g[0] = malloc(sizeof(PHY_VARS_NR_UE *)*MAX_NUM_CCs); + if (get_softmodem_params()->emulate_l1) { + RCconfig_nr_ue_L1(); + } if (get_softmodem_params()->do_ra) AssertFatal(get_softmodem_params()->phy_test == 0,"RA and phy_test are mutually exclusive\n"); @@ -458,54 +474,57 @@ int main( int argc, char **argv ) { if (get_softmodem_params()->sa) AssertFatal(get_softmodem_params()->phy_test == 0,"Standalone mode and phy_test are mutually exclusive\n"); - for (int CC_id=0; CC_id<MAX_NUM_CCs; CC_id++) { - - PHY_vars_UE_g[0][CC_id] = (PHY_VARS_NR_UE *)malloc(sizeof(PHY_VARS_NR_UE)); - UE[CC_id] = PHY_vars_UE_g[0][CC_id]; - memset(UE[CC_id],0,sizeof(PHY_VARS_NR_UE)); - - set_options(CC_id, UE[CC_id]); - NR_UE_MAC_INST_t *mac = get_mac_inst(0); - - if (get_softmodem_params()->sa) { - uint16_t nr_band = get_band(downlink_frequency[CC_id][0],uplink_frequency_offset[CC_id][0]); - mac->nr_band = nr_band; - nr_init_frame_parms_ue_sa(&UE[CC_id]->frame_parms, - downlink_frequency[CC_id][0], - uplink_frequency_offset[CC_id][0], - get_softmodem_params()->numerology, - nr_band); + if (!get_softmodem_params()->nsa && get_softmodem_params()->emulate_l1) + start_oai_nrue_threads(); + + if (!get_softmodem_params()->emulate_l1) { + for (int CC_id=0; CC_id<MAX_NUM_CCs; CC_id++) { + PHY_vars_UE_g[0][CC_id] = (PHY_VARS_NR_UE *)malloc(sizeof(PHY_VARS_NR_UE)); + UE[CC_id] = PHY_vars_UE_g[0][CC_id]; + memset(UE[CC_id],0,sizeof(PHY_VARS_NR_UE)); + + set_options(CC_id, UE[CC_id]); + NR_UE_MAC_INST_t *mac = get_mac_inst(0); + + if (get_softmodem_params()->sa) { // set frame config to initial values from command line and assume that the SSB is centered on the grid + uint16_t nr_band = get_band(downlink_frequency[CC_id][0],uplink_frequency_offset[CC_id][0]); + mac->nr_band = nr_band; + nr_init_frame_parms_ue_sa(&UE[CC_id]->frame_parms, + downlink_frequency[CC_id][0], + uplink_frequency_offset[CC_id][0], + get_softmodem_params()->numerology, + nr_band); + } + else{ + if(mac->if_module != NULL && mac->if_module->phy_config_request != NULL) + mac->if_module->phy_config_request(&mac->phy_config); + + fapi_nr_config_request_t *nrUE_config = &UE[CC_id]->nrUE_config; + + nr_init_frame_parms_ue(&UE[CC_id]->frame_parms, nrUE_config, + *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); } - else{ - if(mac->if_module != NULL && mac->if_module->phy_config_request != NULL) - mac->if_module->phy_config_request(&mac->phy_config); - fapi_nr_config_request_t *nrUE_config = &UE[CC_id]->nrUE_config; + init_openair0(); + // init UE_PF_PO and mutex lock + pthread_mutex_init(&ue_pf_po_mutex, NULL); + memset (&UE_PF_PO[0][0], 0, sizeof(UE_PF_PO_t)*NUMBER_OF_UE_MAX*MAX_NUM_CCs); + set_latency_target(); + mlockall(MCL_CURRENT | MCL_FUTURE); - nr_init_frame_parms_ue(&UE[CC_id]->frame_parms, nrUE_config, *mac->scc->downlinkConfigCommon->frequencyInfoDL->frequencyBandList.list.array[0]); + if(IS_SOFTMODEM_DOSCOPE) { + load_softscope("nr",PHY_vars_UE_g[0][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); - + init_NR_UE_threads(1); + printf("UE threads created by %ld\n", gettid()); } - init_openair0(); - // init UE_PF_PO and mutex lock - pthread_mutex_init(&ue_pf_po_mutex, NULL); - memset (&UE_PF_PO[0][0], 0, sizeof(UE_PF_PO_t)*NUMBER_OF_UE_MAX*MAX_NUM_CCs); - configure_linux(); - mlockall(MCL_CURRENT | MCL_FUTURE); - - if(IS_SOFTMODEM_DOSCOPE) { - load_softscope("nr",PHY_vars_UE_g[0][0]); - } - - - init_NR_UE_threads(1); - printf("UE threads created by %ld\n", gettid()); - // wait for end of program printf("TYPE <CTRL-C> TO TERMINATE\n"); diff --git a/executables/nr-uesoftmodem.h b/executables/nr-uesoftmodem.h index 7f47ed5eb3c14b6534a2bdd0704b028472ccb892..95914678e5ba84418d7d65ab1c04510e9b664fc6 100644 --- a/executables/nr-uesoftmodem.h +++ b/executables/nr-uesoftmodem.h @@ -33,8 +33,10 @@ {"dlsch-parallel", CONFIG_HLP_DLSCH_PARA, 0, iptr:(int32_t *)&nrUE_params.nr_dlsch_parallel, defintval:0, TYPE_UINT8, 0}, \ {"offset-divisor", CONFIG_HLP_OFFSET_DIV, 0, uptr:(uint32_t *)&nrUE_params.ofdm_offset_divisor, defuintval:UINT_MAX, TYPE_UINT32, 0}, \ {"nr-dlsch-demod-shift", CONFIG_HLP_DLSHIFT, 0, iptr:(int32_t *)&nr_dlsch_demod_shift, defintval:0, TYPE_INT, 0}, \ - {"V" , CONFIG_HLP_VCD, PARAMFLAG_BOOL, iptr:&vcdflag, defintval:0, TYPE_INT, 0}, \ - {"rrc_config_path", CONFIG_HLP_RRC_CFG_PATH,0, strptr:(char **)&rrc_config_path, defstrval:"./", TYPE_STRING, 0} \ + {"V" , CONFIG_HLP_VCD, PARAMFLAG_BOOL, iptr:&vcdflag, defintval:0, TYPE_INT, 0}, \ + {"uecap_file", CONFIG_HLP_UECAP_FILE, 0, strptr:(char **)&uecap_file, defstrval:"./uecap.xml", TYPE_STRING, 0}, \ + {"rrc_config_path", CONFIG_HLP_RRC_CFG_PATH,0, strptr:(char **)&rrc_config_path, defstrval:"./", TYPE_STRING, 0}, \ + {"ue-idx-standalone", NULL, 0, u16ptr:&ue_idx_standalone, defuintval:0xFFFF, TYPE_UINT16, 0} \ } @@ -84,11 +86,13 @@ extern nrUE_params_t *get_nrUE_params(void); // In nr-ue.c extern int setup_nr_ue_buffers(PHY_VARS_NR_UE **phy_vars_ue, openair0_config_t *openair0_cfg); extern void fill_ue_band_info(void); -extern void init_NR_UE(int, char*); +extern void init_NR_UE(int, char*, char*); extern void init_NR_UE_threads(int); extern void reset_opp_meas(void); extern void print_opp_meas(void); +extern void start_oai_nrue_threads(void); void *UE_thread(void *arg); void init_nr_ue_vars(PHY_VARS_NR_UE *ue, uint8_t UE_id, uint8_t abstraction_flag); +void init_nrUE_standalone_thread(int ue_idx); #endif diff --git a/executables/ocp-gnb.c b/executables/ocp-gnb.c index 326f7d277f7df5c5ff20f09da30d174d63d8f605..462a07c7073884df12af47c2830efa59abe9bc32 100644 --- a/executables/ocp-gnb.c +++ b/executables/ocp-gnb.c @@ -328,9 +328,9 @@ static void init_pdcp(void) { pdcp_initmask = pdcp_initmask | ENB_NAS_USE_TUN_BIT | SOFTMODEM_NOKRNMOD_BIT ; } - pdcp_module_init(pdcp_initmask); - pdcp_set_rlc_data_req_func((send_rlc_data_req_func_t) rlc_data_req); - pdcp_set_pdcp_data_ind_func((pdcp_data_ind_func_t) pdcp_data_ind); + nr_pdcp_module_init(pdcp_initmask, 0); + pdcp_set_rlc_data_req_func(rlc_data_req); + pdcp_set_pdcp_data_ind_func(pdcp_data_ind); } void init_main_gNB(void) { @@ -920,7 +920,7 @@ int main( int argc, char **argv ) { # define PACKAGE_VERSION "UNKNOWN" #endif LOG_I(HW, "Version: %s\n", PACKAGE_VERSION); - configure_linux(); + set_latency_target(); get_options (); get_common_options(SOFTMODEM_GNB_BIT ); AssertFatal(!CONFIG_ISFLAGSET(CONFIG_ABORT),"Getting configuration failed\n"); diff --git a/executables/softmodem-common.c b/executables/softmodem-common.c index e10515ea1acab5330d18e23a0ded937459d23965..3e20081b18ee32de4bdd2c8bdca47ca1eac4507e 100644 --- a/executables/softmodem-common.c +++ b/executables/softmodem-common.c @@ -180,15 +180,18 @@ void softmodem_printresources(int sig, telnet_printfunc_t pf) { } void signal_handler(int sig) { - void *array[10]; - size_t size; + //void *array[10]; + //size_t size; if (sig==SIGSEGV) { // get void*'s for all entries on the stack + /* backtrace uses malloc, that is not good in signal handlers + * I let the code, because it would be nice to make it better size = backtrace(array, 10); // print out all the frames to stderr fprintf(stderr, "Error: signal %d:\n", sig); backtrace_symbols_fd(array, size, 2); + */ exit(-1); } else { if(sig==SIGINT ||sig==SOFTMODEM_RTSIGNAL) @@ -208,10 +211,13 @@ void set_softmodem_sighandler(void) { memset(&act,0,sizeof(act)); act.sa_handler=signal_handler; sigaction(SOFTMODEM_RTSIGNAL,&act,&oldact); + // Disabled in order generate a core dump for analysis with gdb + # if 0 printf("Send signal %d to display resource usage...\n",SIGRTMIN+1); signal(SIGSEGV, signal_handler); signal(SIGINT, signal_handler); signal(SIGTERM, signal_handler); signal(SIGABRT, signal_handler); + #endif } diff --git a/executables/softmodem-common.h b/executables/softmodem-common.h index 3a7022a502c6b2ecd7566ac66618aac57a072d58..9aca677473566301b97a45d51635496ac4a0407d 100644 --- a/executables/softmodem-common.h +++ b/executables/softmodem-common.h @@ -98,6 +98,7 @@ extern "C" #define CONFIG_HLP_DISABLNBIOT "disable nb-iot, even if defined in config\n" #define CONFIG_HLP_USRP_THREAD "having extra thead for usrp tx\n" #define CONFIG_HLP_NFAPI "Change the nFAPI mode for NR\n" +#define CONFIG_L1_EMULATOR "Run in L1 emulated mode (disable PHY layer)\n" /*-----------------------------------------------------------------------------------------------------------------------------------------------------*/ /* command line parameters common to eNodeB and UE */ @@ -122,7 +123,10 @@ extern "C" #define USE_256QAM_TABLE softmodem_params.use_256qam_table #define PRB_INTERPOLATION softmodem_params.prb_interpolation #define NFAPI softmodem_params.nfapi +#define NSA softmodem_params.nsa +#define NODE_NUMBER softmodem_params.node_number #define NON_STOP softmodem_params.non_stop +#define EMULATE_L1 softmodem_params.emulate_l1 #define DEFAULT_RFCONFIG_FILE "/usr/local/etc/syriq/ue.band7.tm1.PRB100.NR40.dat"; @@ -155,13 +159,16 @@ extern int usrp_tx_thread; {"nokrnmod", CONFIG_HLP_NOKRNMOD, PARAMFLAG_BOOL, uptr:&nokrnmod, defintval:0, TYPE_INT, 0}, \ {"nbiot-disable", CONFIG_HLP_DISABLNBIOT, PARAMFLAG_BOOL, uptr:&nonbiot, defuintval:0, TYPE_INT, 0}, \ {"use-256qam-table", CONFIG_HLP_256QAM, PARAMFLAG_BOOL, iptr:&USE_256QAM_TABLE, defintval:0, TYPE_INT, 0}, \ - {"do-prb-interpolation", CONFIG_HLP_PRBINTER, PARAMFLAG_BOOL, iptr:&PRB_INTERPOLATION, defintval:0, TYPE_INT, 0}, \ - {"usrp-tx-thread-config", CONFIG_HLP_USRP_THREAD, 0, iptr:&usrp_tx_thread, defstrval:0, TYPE_INT, 0}, \ - {"nfapi", CONFIG_HLP_NFAPI, 0, u8ptr:&nfapi_mode, defintval:0, TYPE_UINT8, 0}, \ - {"non-stop", CONFIG_HLP_NONSTOP, PARAMFLAG_BOOL, iptr:&NON_STOP, defintval:0, TYPE_INT, 0}, \ + {"nsa", CONFIG_HLP_NSA, PARAMFLAG_BOOL, iptr:&NSA, defintval:0, TYPE_INT, 0}, \ + {"node-number", NULL, 0, u16ptr:&NODE_NUMBER, defuintval:0, TYPE_UINT16, 0}, \ + {"usrp-tx-thread-config", CONFIG_HLP_USRP_THREAD, 0, iptr:&usrp_tx_thread, defstrval:0, TYPE_INT, 0}, \ + {"do-prb-interpolation", CONFIG_HLP_PRBINTER, PARAMFLAG_BOOL, iptr:&PRB_INTERPOLATION, defintval:0, TYPE_INT, 0}, \ + {"nfapi", CONFIG_HLP_NFAPI, 0, u8ptr:&nfapi_mode, defintval:0, TYPE_UINT8, 0}, \ + {"non-stop", CONFIG_HLP_NONSTOP, PARAMFLAG_BOOL, iptr:&NON_STOP, defintval:0, TYPE_INT, 0}, \ + {"emulate-l1", CONFIG_L1_EMULATOR, PARAMFLAG_BOOL, iptr:&EMULATE_L1, defintval:0, TYPE_INT, 0}, \ } - +#define CONFIG_HLP_NSA "Enable NSA mode \n" #define CONFIG_HLP_FLOG "Enable online log \n" #define CONFIG_HLP_LOGL "Set the global log level, valid options: (4:trace, 3:debug, 2:info, 1:warn, (0:error))\n" #define CONFIG_HLP_LOGV "Set the global log verbosity \n" @@ -251,7 +258,10 @@ typedef struct { int use_256qam_table; int prb_interpolation; uint8_t nfapi; + int nsa; + uint16_t node_number; int non_stop; + int emulate_l1; } softmodem_params_t; extern uint64_t get_softmodem_optmask(void); @@ -272,6 +282,7 @@ void tx_func(void *param); void rx_func(void *param); void ru_tx_func(void *param); extern uint8_t nfapi_mode; +extern int16_t vnf_pnf_sfnslot_delta; #ifdef __cplusplus } #endif diff --git a/nfapi/oai_integration/gnb_ind_vars.c b/nfapi/oai_integration/gnb_ind_vars.c new file mode 100644 index 0000000000000000000000000000000000000000..148c28a5c4dd7db66594ffc81abcb354220dd223 --- /dev/null +++ b/nfapi/oai_integration/gnb_ind_vars.c @@ -0,0 +1,7 @@ +#include "gnb_ind_vars.h" + +queue_t gnb_rach_ind_queue; +queue_t gnb_rx_ind_queue; +queue_t gnb_crc_ind_queue; +queue_t gnb_uci_ind_queue; +queue_t gnb_slot_ind_queue; diff --git a/nfapi/oai_integration/gnb_ind_vars.h b/nfapi/oai_integration/gnb_ind_vars.h new file mode 100644 index 0000000000000000000000000000000000000000..8561037d3e444ca2f6686714da556407e6cb482e --- /dev/null +++ b/nfapi/oai_integration/gnb_ind_vars.h @@ -0,0 +1,9 @@ +#pragma once + +#include "openair2/PHY_INTERFACE/queue_t.h" + +extern queue_t gnb_rach_ind_queue; +extern queue_t gnb_rx_ind_queue; +extern queue_t gnb_crc_ind_queue; +extern queue_t gnb_uci_ind_queue; +extern queue_t gnb_slot_ind_queue; diff --git a/nfapi/oai_integration/nfapi.c b/nfapi/oai_integration/nfapi.c index 86d1ae3127d33c13c71977c43c950830feb1ecdd..5e71c5e2a4458fcff77c9336bbdb36768dd16cb0 100644 --- a/nfapi/oai_integration/nfapi.c +++ b/nfapi/oai_integration/nfapi.c @@ -23,7 +23,15 @@ #include <pthread.h> #include "nfapi/oai_integration/vendor_ext.h" #include "common/utils/LOG/log.h" -static char nfapi_str_mode[6][24] = {"MONOLITHIC","PNF","VNF","UE_STUB_PNF","UE_STUB_OFFNET","<UNKNOWN NFAPI MODE>"}; +static const char *const nfapi_str_mode[] = { + "MONOLITHIC", + "PNF", + "VNF", + "UE_STUB_PNF", + "UE_STUB_OFFNET", + "STANDALONE_PNF", + "<UNKNOWN NFAPI MODE>" +}; typedef struct { nfapi_mode_t nfapi_mode; @@ -32,15 +40,9 @@ typedef struct { static nfapi_params_t nfapi_params = {0}; void set_thread_priority(int priority) { - //printf("%s(priority:%d)\n", __FUNCTION__, priority); - pthread_attr_t ptAttr; - struct sched_param schedParam; - schedParam.__sched_priority = priority; //79; - - if(sched_setscheduler(0, SCHED_RR, &schedParam) != 0) { - printf("Failed to set scheduler to SCHED_RR\n"); - } + set_priority(priority); + pthread_attr_t ptAttr; if(pthread_attr_setschedpolicy(&ptAttr, SCHED_RR) != 0) { printf("Failed to set pthread sched policy SCHED_RR\n"); } @@ -54,7 +56,7 @@ void set_thread_priority(int priority) { } } -char *nfapi_get_strmode(void) { +const char *nfapi_get_strmode(void) { if (nfapi_params.nfapi_mode > NFAPI_MODE_UNKNOWN) return nfapi_str_mode[NFAPI_MODE_UNKNOWN]; diff --git a/nfapi/oai_integration/nfapi_pnf.c b/nfapi/oai_integration/nfapi_pnf.c index 4edbeee342d9ee69c93b6c3262e9ae52682b4a0c..205f8799645a35583e25ab2d0c6c9f514547fa7a 100644 --- a/nfapi/oai_integration/nfapi_pnf.c +++ b/nfapi/oai_integration/nfapi_pnf.c @@ -218,14 +218,9 @@ void pnf_nfapi_trace(nfapi_trace_level_t nfapi_level, const char *message, ...) } void pnf_set_thread_priority(int priority) { - pthread_attr_t ptAttr; - struct sched_param schedParam; - schedParam.__sched_priority = priority; - - if(sched_setscheduler(0, SCHED_RR, &schedParam) != 0) { - printf("failed to set SCHED_RR\n"); - } + set_priority(priority); + pthread_attr_t ptAttr; if(pthread_attr_setschedpolicy(&ptAttr, SCHED_RR) != 0) { printf("failed to set pthread SCHED_RR %d\n", errno); } @@ -248,7 +243,7 @@ void *pnf_p7_thread_start(void *ptr) { } void *pnf_nr_p7_thread_start(void *ptr) { - NFAPI_TRACE(NFAPI_TRACE_INFO, "[PNF] P7 THREAD %s\n", __FUNCTION__); + NFAPI_TRACE(NFAPI_TRACE_INFO, "[NR_PNF] NR P7 THREAD %s\n", __FUNCTION__); pnf_set_thread_priority(79); nfapi_pnf_p7_config_t *config = (nfapi_pnf_p7_config_t *)ptr; nfapi_nr_pnf_p7_start(config); @@ -805,7 +800,7 @@ int config_request(nfapi_pnf_config_t *config, nfapi_pnf_phy_config_t *phy, nfap // to keep only the necessary just to keep the nfapi FSM rolling by sending a dummy response. LTE_DL_FRAME_PARMS *fp; - if (NFAPI_MODE!=NFAPI_UE_STUB_PNF) { + if (NFAPI_MODE!=NFAPI_UE_STUB_PNF && NFAPI_MODE!=NFAPI_MODE_STANDALONE_PNF) { struct PHY_VARS_eNB_s *eNB = RC.eNB[0][0]; fp = &eNB->frame_parms; } else { @@ -967,7 +962,7 @@ int config_request(nfapi_pnf_config_t *config, nfapi_pnf_phy_config_t *phy, nfap num_tlv++; } - if(NFAPI_MODE!=NFAPI_UE_STUB_PNF) { + if(NFAPI_MODE!=NFAPI_UE_STUB_PNF && NFAPI_MODE!=NFAPI_MODE_STANDALONE_PNF) { printf("[PNF] CONFIG_REQUEST[num_tlv:%d] TLVs processed:%d\n", req->num_tlv, num_tlv); printf("[PNF] Simulating PHY CONFIG - DJP\n"); PHY_Config_t phy_config; @@ -991,7 +986,7 @@ int config_request(nfapi_pnf_config_t *config, nfapi_pnf_phy_config_t *phy, nfap nfapi_pnf_config_resp(config, &nfapi_resp); printf("[PNF] Sent NFAPI_CONFIG_RESPONSE phy_id:%d\n", phy_info->id); - if(NFAPI_MODE==NFAPI_UE_STUB_PNF) + if(NFAPI_MODE==NFAPI_UE_STUB_PNF || NFAPI_MODE==NFAPI_MODE_STANDALONE_PNF) free(fp); return 0; @@ -1106,41 +1101,10 @@ void pnf_phy_deallocate_p7_vendor_ext(nfapi_p7_message_header_t *header) { notifiedFIFO_elt_t *l1tx_message_extract(PHY_VARS_gNB *gNB, int frame, int slot) { notifiedFIFO_elt_t *res; - notifiedFIFO_elt_t *freeRes = NULL; - - // check first message - res = pullTpool(gNB->resp_L1_tx, gNB->threadPool); - processingData_L1tx_t *msgTx = (processingData_L1tx_t *)NotifiedFifoData(res); - if (msgTx->slot == slot) { - return res; - } - if (msgTx->slot == -1) { - freeRes = res; - } - // check second message - pushNotifiedFIFO(gNB->resp_L1_tx,res); - res = pullTpool(gNB->resp_L1_tx, gNB->threadPool); - msgTx = (processingData_L1tx_t *)NotifiedFifoData(res); - if (msgTx->slot == slot) { - return res; - } - if (msgTx->slot == -1) { - freeRes = res; - } - - if (freeRes) { - msgTx = (processingData_L1tx_t *)NotifiedFifoData(res); - msgTx->num_pdsch_slot=0; - msgTx->pdcch_pdu.pdcch_pdu_rel15.numDlDci = 0; - msgTx->ul_pdcch_pdu.pdcch_pdu.pdcch_pdu_rel15.numDlDci = 0; - msgTx->slot = slot; - msgTx->frame = frame; - return freeRes; - } - pushNotifiedFIFO(gNB->resp_L1_tx,res); - AssertFatal(1==0, "It means both L1 Tx messages are still waiting to be processed. This happens when L1 Tx processing is too slow. Message slot %d, scheduled slot %d\n", - msgTx->slot, slot); + //TODO: This needs to be reworked for nfapi to work + res = pullTpool(gNB->L1_tx_free, gNB->threadPool); + return res; } int pnf_phy_ul_dci_req(gNB_L1_rxtx_proc_t *proc, nfapi_pnf_p7_config_t *pnf_p7, nfapi_nr_ul_dci_request_t *req) { @@ -1158,15 +1122,15 @@ int pnf_phy_ul_dci_req(gNB_L1_rxtx_proc_t *proc, nfapi_pnf_p7_config_t *pnf_p7, proc = &gNB->proc.L1_proc; if (req->numPdus > 0) { - if (req->ul_dci_pdu_list[req->numPdus-1].PDUType == 0) { // copy only the last PDU (PHY can have only one UL PDCCH pdu) - msgTx->ul_pdcch_pdu = req->ul_dci_pdu_list[req->numPdus-1]; // copy the last pdu - } - else { - LOG_E(PHY,"[PNF] UL_DCI_REQ sfn_slot:%d PDU[%d] - unknown pdu type:%d\n", NFAPI_SFNSLOT2DEC(req->SFN, req->Slot), req->numPdus-1, req->ul_dci_pdu_list[req->numPdus-1].PDUType); + for (int i=0; i<req->numPdus; i++) { + if (req->ul_dci_pdu_list[i].PDUType == NFAPI_NR_DL_TTI_PDCCH_PDU_TYPE) // only possible value 0: PDCCH PDU + msgTx->ul_pdcch_pdu[i] = req->ul_dci_pdu_list[i]; + else + LOG_E(PHY,"[PNF] UL_DCI_REQ sfn_slot:%d PDU[%d] - unknown pdu type:%d\n", NFAPI_SFNSLOT2DEC(req->SFN, req->Slot), req->numPdus-1, req->ul_dci_pdu_list[req->numPdus-1].PDUType); } } - pushNotifiedFIFO(gNB->resp_L1_tx,res); + pushNotifiedFIFO(gNB->L1_tx_filled,res); return 0; } @@ -1226,15 +1190,15 @@ int pnf_phy_dl_tti_req(gNB_L1_rxtx_proc_t *proc, nfapi_pnf_p7_config_t *pnf_p7, proc = &gNB->proc.L1_proc; nfapi_nr_dl_tti_request_pdu_t *dl_tti_pdu_list = req->dl_tti_request_body.dl_tti_pdu_list; - //if (req->dl_tti_request_body.nPDUs) - // NFAPI_TRACE(NFAPI_TRACE_INFO, "%s() TX:%d/%d RX:%d/%d; sfn:%d, slot:%d, nGroup:%u, nPDUs: %u, nUE: %u, PduIdx: %u,\n", - // __FUNCTION__, proc->frame_tx, proc->slot_tx, proc->frame_rx, proc->slot_rx, // TODO: change subframes to slot - // req->SFN, - // req->Slot, - // req->dl_tti_request_body.nGroup, - // req->dl_tti_request_body.nPDUs, - // req->dl_tti_request_body.nUe, - // req->dl_tti_request_body.PduIdx); + if (req->dl_tti_request_body.nPDUs) + NFAPI_TRACE(NFAPI_TRACE_INFO, "%s() TX:%d/%d RX:%d/%d; sfn:%d, slot:%d, nGroup:%u, nPDUs: %u, nUE: %p, PduIdx: %p,\n", + __FUNCTION__, proc->frame_tx, proc->slot_tx, proc->frame_rx, proc->slot_rx, // TODO: change subframes to slot + req->SFN, + req->Slot, + req->dl_tti_request_body.nGroup, + req->dl_tti_request_body.nPDUs, + req->dl_tti_request_body.nUe, + req->dl_tti_request_body.PduIdx); for (int i=0; i<req->dl_tti_request_body.nPDUs; i++) { // NFAPI_TRACE(NFAPI_TRACE_INFO, "%s() sfn/sf:%d PDU[%d] size:%d pdcch_vars->num_dci:%d\n", __FUNCTION__, NFAPI_SFNSF2DEC(req->sfn_sf), i, dl_config_pdu_list[i].pdu_size,pdcch_vars->num_dci); @@ -1243,17 +1207,16 @@ int pnf_phy_dl_tti_req(gNB_L1_rxtx_proc_t *proc, nfapi_pnf_p7_config_t *pnf_p7, processingData_L1tx_t *msgTx = (processingData_L1tx_t *)NotifiedFifoData(res); if (dl_tti_pdu_list[i].PDUType == NFAPI_NR_DL_TTI_PDCCH_PDU_TYPE) { - // we trust the scheduler sends only one PDCCH PDU per slot - msgTx->pdcch_pdu = dl_tti_pdu_list[i].pdcch_pdu; // fills the last received PDCCH PDU + msgTx->pdcch_pdu[i] = dl_tti_pdu_list[i].pdcch_pdu; // copies all the received PDCCH PDUs } else if (dl_tti_pdu_list[i].PDUType == NFAPI_NR_DL_TTI_SSB_PDU_TYPE) { //NFAPI_TRACE(NFAPI_TRACE_INFO, "%s() PDU:%d BCH: pdu_index:%u pdu_length:%d sdu_length:%d BCH_SDU:%x,%x,%x\n", __FUNCTION__, i, pdu_index, bch_pdu->bch_pdu_rel8.length, tx_request_pdu[sfn][sf][pdu_index]->segments[0].segment_length, sdu[0], sdu[1], sdu[2]); handle_nr_nfapi_ssb_pdu(msgTx, sfn, slot, &dl_tti_pdu_list[i]); gNB->pbch_configured=1; - } + } else if (dl_tti_pdu_list[i].PDUType == NFAPI_NR_DL_TTI_PDSCH_PDU_TYPE) { nfapi_nr_dl_tti_pdsch_pdu *pdsch_pdu = &dl_tti_pdu_list[i].pdsch_pdu; - nfapi_nr_dl_tti_pdsch_pdu_rel15_t *rel15_pdu = &pdsch_pdu->pdsch_pdu_rel15; + nfapi_nr_dl_tti_pdsch_pdu_rel15_t *rel15_pdu = &pdsch_pdu->pdsch_pdu_rel15; nfapi_nr_pdu_t *tx_data = tx_data_request[sfn][slot][rel15_pdu->pduIndex]; if (tx_data != NULL) { @@ -1274,7 +1237,7 @@ int pnf_phy_dl_tti_req(gNB_L1_rxtx_proc_t *proc, nfapi_pnf_p7_config_t *pnf_p7, else { NFAPI_TRACE(NFAPI_TRACE_ERROR, "%s() UNKNOWN:%d\n", __FUNCTION__, dl_tti_pdu_list[i].PDUType); } - pushNotifiedFIFO(gNB->resp_L1_tx,res); + pushNotifiedFIFO(gNB->L1_tx_filled,res); } if(req->vendor_extension) @@ -1466,6 +1429,7 @@ int pnf_phy_ul_tti_req(gNB_L1_rxtx_proc_t *proc, nfapi_pnf_p7_config_t *pnf_p7, switch (ul_tti_pdu_list[i].pdu_type) { case NFAPI_NR_UL_CONFIG_PUSCH_PDU_TYPE: //LOG_D(PHY,"frame %d, slot %d, Got NFAPI_NR_UL_TTI_PUSCH_PDU_TYPE for %d.%d\n", frame, slot, UL_tti_req->SFN, UL_tti_req->Slot); + //curr_sfn = curr_sfn + 3; //Gokul nr_fill_ulsch(gNB,curr_sfn, curr_slot, &ul_tti_pdu_list[i].pusch_pdu); break; case NFAPI_NR_UL_CONFIG_PUCCH_PDU_TYPE: @@ -1661,7 +1625,6 @@ nfapi_pnf_p7_subframe_buffer_t dummy_subframe; int start_request(nfapi_pnf_config_t *config, nfapi_pnf_phy_config_t *phy, nfapi_start_request_t *req) { printf("[PNF] Received NFAPI_START_REQ phy_id:%d\n", req->header.phy_id); - nfapi_set_trace_level(NFAPI_TRACE_INFO); pnf_info *pnf = (pnf_info *)(config->user_data); phy_info *phy_info = pnf->phys; nfapi_pnf_p7_config_t *p7_config = nfapi_pnf_p7_config_create(); @@ -1697,11 +1660,11 @@ int start_request(nfapi_pnf_config_t *config, nfapi_pnf_phy_config_t *phy, nfapi p7_config->tx_req = &pnf_phy_tx_req; p7_config->lbt_dl_config_req = &pnf_phy_lbt_dl_config_req; p7_config->ue_release_req = &pnf_phy_ue_release_req; - if (NFAPI_MODE==NFAPI_UE_STUB_PNF) { - p7_config->dl_config_req = &memcpy_dl_config_req; - p7_config->ul_config_req = &memcpy_ul_config_req; - p7_config->hi_dci0_req = &memcpy_hi_dci0_req; - p7_config->tx_req = &memcpy_tx_req; + if (NFAPI_MODE==NFAPI_UE_STUB_PNF || NFAPI_MODE==NFAPI_MODE_STANDALONE_PNF) { + p7_config->dl_config_req = NULL; + p7_config->ul_config_req = NULL; + p7_config->hi_dci0_req = NULL; + p7_config->tx_req = NULL; } else { p7_config->dl_config_req = &pnf_phy_dl_config_req; p7_config->ul_config_req = &pnf_phy_ul_config_req; @@ -1754,7 +1717,7 @@ int start_request(nfapi_pnf_config_t *config, nfapi_pnf_phy_config_t *phy, nfapi //phy_init_RU(RC.ru[0]); printf("[PNF] About to call init_eNB_afterRU()\n"); - if (NFAPI_MODE!=NFAPI_UE_STUB_PNF) { + if (NFAPI_MODE!=NFAPI_UE_STUB_PNF && NFAPI_MODE!=NFAPI_MODE_STANDALONE_PNF) { init_eNB_afterRU(); } @@ -1781,7 +1744,6 @@ int start_request(nfapi_pnf_config_t *config, nfapi_pnf_phy_config_t *phy, nfapi int nr_start_request(nfapi_pnf_config_t *config, nfapi_pnf_phy_config_t *phy, nfapi_nr_start_request_scf_t *req) { printf("[PNF] Received NFAPI_START_REQ phy_id:%d\n", req->header.phy_id); - nfapi_set_trace_level(NFAPI_TRACE_INFO); pnf_info *pnf = (pnf_info *)(config->user_data); phy_info *phy_info = pnf->phys; nfapi_pnf_p7_config_t *p7_config = nfapi_pnf_p7_config_create(); @@ -1827,10 +1789,10 @@ int nr_start_request(nfapi_pnf_config_t *config, nfapi_pnf_phy_config_t *phy, n p7_config->lbt_dl_config_req = &pnf_phy_lbt_dl_config_req; p7_config->ue_release_req = &pnf_phy_ue_release_req; if (NFAPI_MODE==NFAPI_UE_STUB_PNF) { - p7_config->dl_config_req = &memcpy_dl_config_req; - p7_config->ul_config_req = &memcpy_ul_config_req; - p7_config->hi_dci0_req = &memcpy_hi_dci0_req; - p7_config->tx_req = &memcpy_tx_req; + p7_config->dl_config_req = NULL; + p7_config->ul_config_req = NULL; + p7_config->hi_dci0_req = NULL; + p7_config->tx_req = NULL; } else { p7_config->dl_config_req = &pnf_phy_dl_config_req; p7_config->ul_config_req = &pnf_phy_ul_config_req; @@ -2232,7 +2194,7 @@ void configure_nr_nfapi_pnf(char *vnf_ip_addr, int vnf_p5_port, char *pnf_ip_add void configure_nfapi_pnf(char *vnf_ip_addr, int vnf_p5_port, char *pnf_ip_addr, int pnf_p7_port, int vnf_p7_port) { printf("%s() PNF\n\n\n\n\n\n", __FUNCTION__); - if(NFAPI_MODE!=NFAPI_UE_STUB_PNF) { + if(NFAPI_MODE!=NFAPI_UE_STUB_PNF && NFAPI_MODE!=NFAPI_MODE_STANDALONE_PNF) { nfapi_setmode(NFAPI_MODE_PNF); // PNF! } nfapi_pnf_config_t *config = nfapi_pnf_config_create(); @@ -2286,15 +2248,13 @@ void oai_subframe_ind(uint16_t sfn, uint16_t sf) { uint16_t sfn_sf_tx = sfn<<4 | sf; if ((sfn % 100 == 0) && sf==0) { - struct timespec ts; - clock_gettime(CLOCK_MONOTONIC, &ts); - NFAPI_TRACE(NFAPI_TRACE_INFO, "[PNF] %s %d.%d (sfn:%u sf:%u) SFN/SF(TX):%u\n", __FUNCTION__, ts.tv_sec, ts.tv_nsec, sfn, sf, NFAPI_SFNSF2DEC(sfn_sf_tx)); + NFAPI_TRACE(NFAPI_TRACE_INFO, "[PNF] (sfn:%u sf:%u) SFN/SF(TX):%u\n", sfn, sf, NFAPI_SFNSF2DEC(sfn_sf_tx)); } int subframe_ret = nfapi_pnf_p7_subframe_ind(p7_config_g, p7_config_g->phy_id, sfn_sf_tx); if (subframe_ret) { - NFAPI_TRACE(NFAPI_TRACE_INFO, "[PNF] %s(frame:%u subframe:%u) SFN/SF(TX):%u - PROBLEM with pnf_p7_subframe_ind()\n", __FUNCTION__, sfn, sf, sfn_sf_tx, NFAPI_SFNSF2DEC(sfn_sf_tx)); + NFAPI_TRACE(NFAPI_TRACE_INFO, "[PNF] (frame:%u subframe:%u) SFN/SF(TX):%u - PROBLEM with pnf_p7_subframe_ind()\n", sfn, sf, sfn_sf_tx); } else { //NFAPI_TRACE(NFAPI_TRACE_INFO, "***NFAPI subframe handler finished *** \n"); } diff --git a/nfapi/oai_integration/nfapi_vnf.c b/nfapi/oai_integration/nfapi_vnf.c index d96829e127756976157f746ea5176fd7b35378bf..44ee05940fc3aa6879867582f57fe65773b0f8d2 100644 --- a/nfapi/oai_integration/nfapi_vnf.c +++ b/nfapi/oai_integration/nfapi_vnf.c @@ -43,6 +43,8 @@ #include <targets/RT/USER/lte-softmodem.h> #include "common/ran_context.h" +#include "openair2/PHY_INTERFACE/queue_t.h" +#include "gnb_ind_vars.h" #define TEST @@ -203,7 +205,7 @@ extern uint16_t slot_ahead; void oai_create_enb(void) { int bodge_counter=0; PHY_VARS_eNB *eNB = RC.eNB[0][0]; - printf("[VNF] RC.eNB[0][0]. Mod_id:%d CC_id:%d nb_CC[0]:%d abstraction_flag:%d single_thread_flag:%d if_inst:%p\n", eNB->Mod_id, eNB->CC_id, RC.nb_CC[0], eNB->abstraction_flag, + NFAPI_TRACE(NFAPI_TRACE_INFO, "[VNF] RC.eNB[0][0]. Mod_id:%d CC_id:%d nb_CC[0]:%d abstraction_flag:%d single_thread_flag:%d if_inst:%p\n", eNB->Mod_id, eNB->CC_id, RC.nb_CC[0], eNB->abstraction_flag, eNB->single_thread_flag, eNB->if_inst); eNB->Mod_id = bodge_counter; eNB->CC_id = bodge_counter; @@ -219,20 +221,20 @@ void oai_create_enb(void) { // that will result in eNB->configured being set to TRUE. // See we need to wait for that to happen otherwise the NFAPI message exchanges won't contain the right parameter values if (RC.eNB[0][0]->if_inst==0 || RC.eNB[0][0]->if_inst->PHY_config_req==0 || RC.eNB[0][0]->if_inst->schedule_response==0) { - printf("RC.eNB[0][0]->if_inst->PHY_config_req is not installed - install it\n"); + NFAPI_TRACE(NFAPI_TRACE_INFO, "RC.eNB[0][0]->if_inst->PHY_config_req is not installed - install it\n"); install_schedule_handlers(RC.eNB[0][0]->if_inst); } do { - printf("%s() Waiting for eNB to become configured (by RRC/PHY) - need to wait otherwise NFAPI messages won't contain correct values\n", __FUNCTION__); + NFAPI_TRACE(NFAPI_TRACE_INFO, "%s() Waiting for eNB to become configured (by RRC/PHY) - need to wait otherwise NFAPI messages won't contain correct values\n", __FUNCTION__); usleep(50000); } while(eNB->configured != 1); - printf("%s() eNB is now configured\n", __FUNCTION__); + NFAPI_TRACE(NFAPI_TRACE_INFO, "%s() eNB is now configured\n", __FUNCTION__); } void oai_enb_init(void) { - printf("%s() About to call init_eNB_afterRU()\n", __FUNCTION__); + NFAPI_TRACE(NFAPI_TRACE_INFO, "%s() About to call init_eNB_afterRU()\n", __FUNCTION__); init_eNB_afterRU(); } @@ -253,7 +255,7 @@ void oai_create_gnb(void) { PHY_VARS_gNB *gNB = RC.gNB[0]; RC.nb_nr_CC = (int *)malloc(sizeof(int)); // TODO: find a better function to place this in - + gNB->Mod_id = bodge_counter; gNB->CC_id = bodge_counter; gNB->abstraction_flag = 0; @@ -263,26 +265,26 @@ void oai_create_gnb(void) { if (gNB->if_inst==0) { gNB->if_inst = NR_IF_Module_init(bodge_counter); } - + // This will cause phy_config_request to be installed. That will result in RRC configuring the PHY // that will result in gNB->configured being set to TRUE. // See we need to wait for that to happen otherwise the NFAPI message exchanges won't contain the right parameter values if (RC.gNB[0]->if_inst==0 || RC.gNB[0]->if_inst->NR_PHY_config_req==0 || RC.gNB[0]->if_inst->NR_Schedule_response==0) { - printf("RC.gNB[0][0]->if_inst->NR_PHY_config_req is not installed - install it\n"); + NFAPI_TRACE(NFAPI_TRACE_INFO, "RC.gNB[0][0]->if_inst->NR_PHY_config_req is not installed - install it\n"); install_nr_schedule_handlers(RC.gNB[0]->if_inst); } do { - printf("%s() Waiting for gNB to become configured (by RRC/PHY) - need to wait otherwise NFAPI messages won't contain correct values\n", __FUNCTION__); + NFAPI_TRACE(NFAPI_TRACE_INFO, "%s() Waiting for gNB to become configured (by RRC/PHY) - need to wait otherwise NFAPI messages won't contain correct values\n", __FUNCTION__); usleep(50000); } while(gNB->configured != 1); - printf("%s() gNB is now configured\n", __FUNCTION__); + NFAPI_TRACE(NFAPI_TRACE_INFO, "%s() gNB is now configured\n", __FUNCTION__); } int pnf_connection_indication_cb(nfapi_vnf_config_t *config, int p5_idx) { - printf("[VNF] pnf connection indication idx:%d\n", p5_idx); + NFAPI_TRACE(NFAPI_TRACE_INFO, "[VNF] pnf connection indication idx:%d\n", p5_idx); oai_create_enb(); nfapi_pnf_param_request_t req; memset(&req, 0, sizeof(req)); @@ -292,7 +294,7 @@ int pnf_connection_indication_cb(nfapi_vnf_config_t *config, int p5_idx) { } int pnf_nr_connection_indication_cb(nfapi_vnf_config_t *config, int p5_idx) { - printf("[VNF] pnf connection indication idx:%d\n", p5_idx); + NFAPI_TRACE(NFAPI_TRACE_INFO, "[VNF] pnf connection indication idx:%d\n", p5_idx); oai_create_gnb(); nfapi_nr_pnf_param_request_t req; memset(&req, 0, sizeof(req)); @@ -302,7 +304,7 @@ int pnf_nr_connection_indication_cb(nfapi_vnf_config_t *config, int p5_idx) { } int pnf_disconnection_indication_cb(nfapi_vnf_config_t *config, int p5_idx) { - printf("[VNF] pnf disconnection indication idx:%d\n", p5_idx); + NFAPI_TRACE(NFAPI_TRACE_INFO, "[VNF] pnf disconnection indication idx:%d\n", p5_idx); vnf_info *vnf = (vnf_info *)(config->user_data); pnf_info *pnf = vnf->pnfs; phy_info *phy = pnf->phys; @@ -312,7 +314,7 @@ int pnf_disconnection_indication_cb(nfapi_vnf_config_t *config, int p5_idx) { } int pnf_nr_param_resp_cb(nfapi_vnf_config_t *config, int p5_idx, nfapi_nr_pnf_param_response_t *resp) { - printf("[VNF] pnf param response idx:%d error:%d\n", p5_idx, resp->error_code); + NFAPI_TRACE(NFAPI_TRACE_INFO, "[VNF] pnf param response idx:%d error:%d\n", p5_idx, resp->error_code); vnf_info *vnf = (vnf_info *)(config->user_data); pnf_info *pnf = vnf->pnfs; @@ -320,11 +322,11 @@ int pnf_nr_param_resp_cb(nfapi_vnf_config_t *config, int p5_idx, nfapi_nr_pnf_pa phy_info phy; memset(&phy,0,sizeof(phy)); phy.index = resp->pnf_phy.phy[i].phy_config_index; - printf("[VNF] (PHY:%d) phy_config_idx:%d\n", i, resp->pnf_phy.phy[i].phy_config_index); + NFAPI_TRACE(NFAPI_TRACE_INFO, "[VNF] (PHY:%d) phy_config_idx:%d\n", i, resp->pnf_phy.phy[i].phy_config_index); nfapi_vnf_allocate_phy(config, p5_idx, &(phy.id)); for(int j = 0; j < resp->pnf_phy.phy[i].number_of_rfs; ++j) { - printf("[VNF] (PHY:%d) (RF%d) %d\n", i, j, resp->pnf_phy.phy[i].rf_config[j].rf_config_index); + NFAPI_TRACE(NFAPI_TRACE_INFO, "[VNF] (PHY:%d) (RF%d) %d\n", i, j, resp->pnf_phy.phy[i].rf_config[j].rf_config_index); phy.rfs[0] = resp->pnf_phy.phy[i].rf_config[j].rf_config_index; } @@ -335,7 +337,7 @@ int pnf_nr_param_resp_cb(nfapi_vnf_config_t *config, int p5_idx, nfapi_nr_pnf_pa req.header.message_id = NFAPI_PNF_CONFIG_REQUEST; req.pnf_phy_rf_config.tl.tag = NFAPI_PNF_PHY_RF_TAG; req.pnf_phy_rf_config.number_phy_rf_config_info = 2; // DJP pnf.phys.size(); - printf("DJP:Hard coded num phy rf to 2\n"); + NFAPI_TRACE(NFAPI_TRACE_INFO, "DJP:Hard coded num phy rf to 2\n"); for(unsigned i = 0; i < 2; ++i) { req.pnf_phy_rf_config.phy_rf_config[i].phy_id = pnf->phys[i].id; @@ -348,7 +350,7 @@ int pnf_nr_param_resp_cb(nfapi_vnf_config_t *config, int p5_idx, nfapi_nr_pnf_pa } int pnf_param_resp_cb(nfapi_vnf_config_t *config, int p5_idx, nfapi_pnf_param_response_t *resp) { - printf("[VNF] pnf param response idx:%d error:%d\n", p5_idx, resp->error_code); + NFAPI_TRACE(NFAPI_TRACE_INFO, "[VNF] pnf param response idx:%d error:%d\n", p5_idx, resp->error_code); vnf_info *vnf = (vnf_info *)(config->user_data); pnf_info *pnf = vnf->pnfs; @@ -356,11 +358,11 @@ int pnf_param_resp_cb(nfapi_vnf_config_t *config, int p5_idx, nfapi_pnf_param_re phy_info phy; memset(&phy,0,sizeof(phy)); phy.index = resp->pnf_phy.phy[i].phy_config_index; - printf("[VNF] (PHY:%d) phy_config_idx:%d\n", i, resp->pnf_phy.phy[i].phy_config_index); + NFAPI_TRACE(NFAPI_TRACE_INFO, "[VNF] (PHY:%d) phy_config_idx:%d\n", i, resp->pnf_phy.phy[i].phy_config_index); nfapi_vnf_allocate_phy(config, p5_idx, &(phy.id)); for(int j = 0; j < resp->pnf_phy.phy[i].number_of_rfs; ++j) { - printf("[VNF] (PHY:%d) (RF%d) %d\n", i, j, resp->pnf_phy.phy[i].rf_config[j].rf_config_index); + NFAPI_TRACE(NFAPI_TRACE_INFO, "[VNF] (PHY:%d) (RF%d) %d\n", i, j, resp->pnf_phy.phy[i].rf_config[j].rf_config_index); phy.rfs[0] = resp->pnf_phy.phy[i].rf_config[j].rf_config_index; } @@ -370,7 +372,7 @@ int pnf_param_resp_cb(nfapi_vnf_config_t *config, int p5_idx, nfapi_pnf_param_re rf_info rf; memset(&rf,0,sizeof(rf)); rf.index = resp->pnf_rf.rf[i].rf_config_index; - printf("[VNF] (RF:%d) rf_config_idx:%d\n", i, resp->pnf_rf.rf[i].rf_config_index); + NFAPI_TRACE(NFAPI_TRACE_INFO, "[VNF] (RF:%d) rf_config_idx:%d\n", i, resp->pnf_rf.rf[i].rf_config_index); pnf->rfs[0] = rf; } nfapi_pnf_config_request_t req; @@ -378,7 +380,7 @@ int pnf_param_resp_cb(nfapi_vnf_config_t *config, int p5_idx, nfapi_pnf_param_re req.header.message_id = NFAPI_PNF_CONFIG_REQUEST; req.pnf_phy_rf_config.tl.tag = NFAPI_PNF_PHY_RF_TAG; req.pnf_phy_rf_config.number_phy_rf_config_info = 2; // DJP pnf.phys.size(); - printf("DJP:Hard coded num phy rf to 2\n"); + NFAPI_TRACE(NFAPI_TRACE_INFO, "DJP:Hard coded num phy rf to 2\n"); for(unsigned i = 0; i < 2; ++i) { req.pnf_phy_rf_config.phy_rf_config[i].phy_id = pnf->phys[i].id; @@ -391,7 +393,7 @@ int pnf_param_resp_cb(nfapi_vnf_config_t *config, int p5_idx, nfapi_pnf_param_re } int pnf_nr_config_resp_cb(nfapi_vnf_config_t *config, int p5_idx, nfapi_nr_pnf_config_response_t *resp) { - printf("[VNF] pnf config response idx:%d resp[header[phy_id:%u message_id:%02x message_length:%u]]\n", p5_idx, resp->header.phy_id, resp->header.message_id, resp->header.message_length); + NFAPI_TRACE(NFAPI_TRACE_INFO, "[VNF] pnf config response idx:%d resp[header[phy_id:%u message_id:%02x message_length:%u]]\n", p5_idx, resp->header.phy_id, resp->header.message_id, resp->header.message_length); if(1) { nfapi_nr_pnf_start_request_t req; @@ -416,7 +418,7 @@ int pnf_nr_config_resp_cb(nfapi_vnf_config_t *config, int p5_idx, nfapi_nr_pnf_c } int pnf_config_resp_cb(nfapi_vnf_config_t *config, int p5_idx, nfapi_pnf_config_response_t *resp) { - printf("[VNF] pnf config response idx:%d resp[header[phy_id:%u message_id:%02x message_length:%u]]\n", p5_idx, resp->header.phy_id, resp->header.message_id, resp->header.message_length); + NFAPI_TRACE(NFAPI_TRACE_INFO, "[VNF] pnf config response idx:%d resp[header[phy_id:%u message_id:%02x message_length:%u]]\n", p5_idx, resp->header.phy_id, resp->header.message_id, resp->header.message_length); if(1) { nfapi_pnf_start_request_t req; @@ -443,12 +445,12 @@ int pnf_config_resp_cb(nfapi_vnf_config_t *config, int p5_idx, nfapi_pnf_config_ int wake_gNB_rxtx(PHY_VARS_gNB *gNB, uint16_t sfn, uint16_t slot) { struct timespec curr_t; clock_gettime(CLOCK_MONOTONIC,&curr_t); - //printf("\n wake_gNB_rxtx before assignment sfn:%d slot:%d TIME %d.%d",sfn,slot,curr_t.tv_sec,curr_t.tv_nsec); + //NFAPI_TRACE(NFAPI_TRACE_INFO, "\n wake_gNB_rxtx before assignment sfn:%d slot:%d TIME %d.%d",sfn,slot,curr_t.tv_sec,curr_t.tv_nsec); gNB_L1_proc_t *proc=&gNB->proc; gNB_L1_rxtx_proc_t *L1_proc= (slot&1)? &proc->L1_proc : &proc->L1_proc_tx; NR_DL_FRAME_PARMS *fp = &gNB->frame_parms; - //printf("%s(eNB:%p, sfn:%d, sf:%d)\n", __FUNCTION__, eNB, sfn, sf); + //NFAPI_TRACE(NFAPI_TRACE_INFO, "%s(eNB:%p, sfn:%d, sf:%d)\n", __FUNCTION__, eNB, sfn, sf); //int i; struct timespec wait; clock_gettime(CLOCK_REALTIME, &wait); @@ -471,7 +473,7 @@ int wake_gNB_rxtx(PHY_VARS_gNB *gNB, uint16_t sfn, uint16_t slot) { // Try to be 1 frame back old_slot = slot; old_sfn = sfn; - //printf("\n wake_gNB_rxtx after assignment sfn:%d slot:%d",proc->frame_rx,proc->slot_rx); + //NFAPI_TRACE(NFAPI_TRACE_INFO, "\n wake_gNB_rxtx after assignment sfn:%d slot:%d",proc->frame_rx,proc->slot_rx); if (old_slot == 0 && old_sfn % 100 == 0) LOG_W( PHY,"[gNB] sfn/slot:%d%d old_sfn/slot:%d%d proc[rx:%d%d]\n", sfn, slot, old_sfn, old_slot, proc->frame_rx, proc->slot_rx); } @@ -490,7 +492,7 @@ int wake_gNB_rxtx(PHY_VARS_gNB *gNB, uint16_t sfn, uint16_t slot) { L1_proc->slot_tx = (L1_proc->slot_rx + slot_ahead)%20; //LOG_I(PHY, "sfn/sf:%d%d proc[rx:%d%d] rx:%d%d] About to wake rxtx thread\n\n", sfn, slot, proc->frame_rx, proc->slot_rx, L1_proc->frame_rx, L1_proc->slot_rx); - //printf("\nEntering wake_gNB_rxtx sfn %d slot %d\n",L1_proc->frame_rx,L1_proc->slot_rx); + //NFAPI_TRACE(NFAPI_TRACE_INFO, "\nEntering wake_gNB_rxtx sfn %d slot %d\n",L1_proc->frame_rx,L1_proc->slot_rx); // the thread can now be woken up if (pthread_cond_signal(&L1_proc->cond) != 0) { LOG_E( PHY, "[gNB] ERROR pthread_cond_signal for gNB RXn-TXnp4 thread\n"); @@ -508,7 +510,7 @@ int wake_eNB_rxtx(PHY_VARS_eNB *eNB, uint16_t sfn, uint16_t sf) { L1_proc_t *proc=&eNB->proc; L1_rxtx_proc_t *L1_proc= (sf&1)? &proc->L1_proc : &proc->L1_proc_tx; LTE_DL_FRAME_PARMS *fp = &eNB->frame_parms; - //printf("%s(eNB:%p, sfn:%d, sf:%d)\n", __FUNCTION__, eNB, sfn, sf); + //NFAPI_TRACE(NFAPI_TRACE_INFO, "%s(eNB:%p, sfn:%d, sf:%d)\n", __FUNCTION__, eNB, sfn, sf); //int i; struct timespec wait; wait.tv_sec=0; @@ -596,11 +598,11 @@ extern pthread_mutex_t nfapi_sync_mutex; extern int nfapi_sync_var; int phy_sync_indication(struct nfapi_vnf_p7_config *config, uint8_t sync) { - //printf("[VNF] SYNC %s\n", sync==1 ? "ACHIEVED" : "LOST"); + //NFAPI_TRACE(NFAPI_TRACE_INFO, "[VNF] SYNC %s\n", sync==1 ? "ACHIEVED" : "LOST"); if (sync==1 && nfapi_sync_var!=0) { - - printf("[VNF] Signal to OAI main code that it can go\n"); + + NFAPI_TRACE(NFAPI_TRACE_INFO, "[VNF] Signal to OAI main code that it can go\n"); pthread_mutex_lock(&nfapi_sync_mutex); nfapi_sync_var=0; pthread_cond_broadcast(&nfapi_sync_cond); @@ -615,19 +617,19 @@ int phy_slot_indication(struct nfapi_vnf_p7_config *config, uint16_t phy_id, uin static uint8_t first_time = 1; if (first_time) { - printf("[VNF] slot indication %d\n", NFAPI_SFNSLOT2DEC(sfn, slot)); + NFAPI_TRACE(NFAPI_TRACE_INFO, "[VNF] slot indication %d\n", NFAPI_SFNSLOT2DEC(sfn, slot)); first_time = 0; } if (RC.gNB && RC.gNB[0]->configured) { // uint16_t sfn = NFAPI_SFNSF2SFN(sfn_sf); // uint16_t sf = NFAPI_SFNSF2SF(sfn_sf); - LOG_D(PHY,"[VNF] slot indication sfn:%d sf:%d\n", sfn, slot); + LOG_D(PHY,"[VNF] slot indication sfn:%d slot:%d\n", sfn, slot); wake_gNB_rxtx(RC.gNB[0], sfn, slot); // DONE: find NR equivalent } else { - printf("[VNF] %s() RC.gNB:%p\n", __FUNCTION__, RC.gNB); + NFAPI_TRACE(NFAPI_TRACE_INFO, "[VNF] %s() RC.gNB:%p\n", __FUNCTION__, RC.gNB); - if (RC.gNB) printf("RC.gNB[0]->configured:%d\n", RC.gNB[0]->configured); + if (RC.gNB) NFAPI_TRACE(NFAPI_TRACE_INFO, "RC.gNB[0]->configured:%d\n", RC.gNB[0]->configured); } return 0; @@ -637,7 +639,7 @@ int phy_subframe_indication(struct nfapi_vnf_p7_config *config, uint16_t phy_id, static uint8_t first_time = 1; if (first_time) { - printf("[VNF] subframe indication %d\n", NFAPI_SFNSF2DEC(sfn_sf)); + NFAPI_TRACE(NFAPI_TRACE_INFO, "[VNF] subframe indication %d\n", NFAPI_SFNSF2DEC(sfn_sf)); first_time = 0; } @@ -647,9 +649,9 @@ int phy_subframe_indication(struct nfapi_vnf_p7_config *config, uint16_t phy_id, //LOG_D(PHY,"[VNF] subframe indication sfn_sf:%d sfn:%d sf:%d\n", sfn_sf, sfn, sf); wake_eNB_rxtx(RC.eNB[0][0], sfn, sf); } else { - printf("[VNF] %s() RC.eNB:%p\n", __FUNCTION__, RC.eNB); + NFAPI_TRACE(NFAPI_TRACE_INFO, "[VNF] %s() RC.eNB:%p\n", __FUNCTION__, RC.eNB); - if (RC.eNB) printf("RC.eNB[0][0]->configured:%d\n", RC.eNB[0][0]->configured); + if (RC.eNB) NFAPI_TRACE(NFAPI_TRACE_INFO, "RC.eNB[0][0]->configured:%d\n", RC.eNB[0][0]->configured); } return 0; @@ -658,21 +660,11 @@ int phy_subframe_indication(struct nfapi_vnf_p7_config *config, uint16_t phy_id, int phy_rach_indication(struct nfapi_vnf_p7_config *config, nfapi_rach_indication_t *ind) { LOG_D(MAC, "%s() NFAPI SFN/SF:%d number_of_preambles:%u\n", __FUNCTION__, NFAPI_SFNSF2DEC(ind->sfn_sf), ind->rach_indication_body.number_of_preambles); struct PHY_VARS_eNB_s *eNB = RC.eNB[0][0]; - printf("[VNF] RACH_IND eNB:%p sfn_sf:%d number_of_preambles:%d\n", eNB, NFAPI_SFNSF2DEC(ind->sfn_sf), ind->rach_indication_body.number_of_preambles); - pthread_mutex_lock(&eNB->UL_INFO_mutex); + LOG_D(MAC, "[VNF] RACH_IND eNB:%p sfn_sf:%d number_of_preambles:%d\n", eNB, NFAPI_SFNSF2DEC(ind->sfn_sf), ind->rach_indication_body.number_of_preambles); + AssertFatal(pthread_mutex_lock(&eNB->UL_INFO_mutex)==0, "Mutex lock failed"); if(NFAPI_MODE == NFAPI_MODE_VNF){ - int8_t index = -1; - for(uint8_t i= 0;i< NUM_NFPAI_SUBFRAME;i++){ - if((UL_RCC_INFO.rach_ind[i].header.message_id == 0) && (index == -1)){ - index = i; - break; - } - } - if(index == -1){ - LOG_E(MAC,"phy_rach_indication : num of rach reach max \n"); - pthread_mutex_unlock(&eNB->UL_INFO_mutex); - return 0; - } + int8_t index = NFAPI_SFNSF2SF(ind->sfn_sf); + UL_RCC_INFO.rach_ind[index] = *ind; if (ind->rach_indication_body.number_of_preambles > 0) @@ -681,7 +673,7 @@ int phy_rach_indication(struct nfapi_vnf_p7_config *config, nfapi_rach_indicatio for (int i=0; i<ind->rach_indication_body.number_of_preambles; i++) { if (ind->rach_indication_body.preamble_list[i].preamble_rel8.tl.tag == NFAPI_PREAMBLE_REL8_TAG) { - printf("preamble[%d]: rnti:%02x preamble:%d timing_advance:%d\n", + LOG_D(MAC, "preamble[%d]: rnti:%02x preamble:%d timing_advance:%d\n", i, ind->rach_indication_body.preamble_list[i].preamble_rel8.rnti, ind->rach_indication_body.preamble_list[i].preamble_rel8.preamble, @@ -689,7 +681,7 @@ int phy_rach_indication(struct nfapi_vnf_p7_config *config, nfapi_rach_indicatio ); } if(ind->rach_indication_body.preamble_list[i].preamble_rel13.tl.tag == NFAPI_PREAMBLE_REL13_TAG) { - printf("RACH PREAMBLE REL13 present\n"); + LOG_D(MAC, "RACH PREAMBLE REL13 present\n"); } UL_RCC_INFO.rach_ind[index].rach_indication_body.preamble_list[i] = ind->rach_indication_body.preamble_list[i]; @@ -700,7 +692,7 @@ int phy_rach_indication(struct nfapi_vnf_p7_config *config, nfapi_rach_indicatio for (int i=0; i<ind->rach_indication_body.number_of_preambles; i++) { if (ind->rach_indication_body.preamble_list[i].preamble_rel8.tl.tag == NFAPI_PREAMBLE_REL8_TAG) { - printf("preamble[%d]: rnti:%02x preamble:%d timing_advance:%d\n", + LOG_D(MAC, "preamble[%d]: rnti:%02x preamble:%d timing_advance:%d\n", i, ind->rach_indication_body.preamble_list[i].preamble_rel8.rnti, ind->rach_indication_body.preamble_list[i].preamble_rel8.preamble, @@ -709,51 +701,190 @@ int phy_rach_indication(struct nfapi_vnf_p7_config *config, nfapi_rach_indicatio } if(ind->rach_indication_body.preamble_list[i].preamble_rel13.tl.tag == NFAPI_PREAMBLE_REL13_TAG) { - printf("RACH PREAMBLE REL13 present\n"); + LOG_D(MAC, "RACH PREAMBLE REL13 present\n"); } eNB->preamble_list[i] = ind->rach_indication_body.preamble_list[i]; } } - pthread_mutex_unlock(&eNB->UL_INFO_mutex); + AssertFatal(pthread_mutex_unlock(&eNB->UL_INFO_mutex)==0, "Mutex unlock failed"); // vnf_p7_info* p7_vnf = (vnf_p7_info*)(config->user_data); //mac_rach_ind(p7_vnf->mac, ind); return 1; } +int phy_nr_rach_indication(nfapi_nr_rach_indication_t *ind) +{ + if(NFAPI_MODE == NFAPI_MODE_VNF) + { + nfapi_nr_rach_indication_t *rach_ind = CALLOC(1, sizeof(*rach_ind)); + rach_ind->header.message_id = ind->header.message_id; + rach_ind->number_of_pdus = ind->number_of_pdus; + rach_ind->sfn = ind->sfn; + rach_ind->slot = ind->slot; + rach_ind->pdu_list = CALLOC(rach_ind->number_of_pdus, sizeof(*rach_ind->pdu_list)); + AssertFatal(rach_ind->pdu_list != NULL, "Memory not allocated for rach_ind->pdu_list in phy_nr_rach_indication."); + for (int i = 0; i < ind->number_of_pdus; i++) + { + rach_ind->pdu_list[i].num_preamble = ind->pdu_list[i].num_preamble; + rach_ind->pdu_list[i].freq_index = ind->pdu_list[i].freq_index; + rach_ind->pdu_list[i].symbol_index = ind->pdu_list[i].symbol_index; + rach_ind->pdu_list[i].preamble_list = CALLOC(ind->pdu_list[i].num_preamble, sizeof(nfapi_nr_prach_indication_preamble_t)); + AssertFatal(rach_ind->pdu_list[i].preamble_list != NULL, "Memory not allocated for rach_ind->pdu_list[i].preamble_list in phy_nr_rach_indication."); + for (int j = 0; j < ind->number_of_pdus; j++) + { + rach_ind->pdu_list[i].preamble_list[j].preamble_index = ind->pdu_list[i].preamble_list[j].preamble_index; + rach_ind->pdu_list[i].preamble_list[j].timing_advance = ind->pdu_list[i].preamble_list[j].timing_advance; + } + } + if (!put_queue(&gnb_rach_ind_queue, rach_ind)) + { + LOG_E(NR_MAC, "Put_queue failed for rach_ind\n"); + for (int i = 0; i < ind->number_of_pdus; i++) + { + free(rach_ind->pdu_list[i].preamble_list); + } + free(rach_ind->pdu_list); + free(rach_ind); + } + } + else { + LOG_E(NR_MAC, "NFAPI_MODE = %d not NFAPI_MODE_VNF(2)\n", nfapi_getmode()); + } + return 1; +} + +int phy_nr_uci_indication(nfapi_nr_uci_indication_t *ind) +{ + + LOG_I(NR_MAC, "In %s() NFAPI SFN/SF: %d/%d number_of_pdus :%u\n", + __FUNCTION__,ind->sfn, ind->slot, ind->num_ucis); + if(NFAPI_MODE == NFAPI_MODE_VNF) + { + nfapi_nr_uci_indication_t *uci_ind = CALLOC(1, sizeof(*uci_ind)); + AssertFatal(uci_ind != NULL, "Memory not allocated for uci_ind in phy_nr_uci_indication."); + *uci_ind = *ind; + + uci_ind->uci_list = CALLOC(NFAPI_NR_UCI_IND_MAX_PDU, sizeof(nfapi_nr_uci_t)); + AssertFatal(uci_ind->uci_list != NULL, "Memory not allocated for uci_ind->uci_list in phy_nr_uci_indication."); + for (int i = 0; i < ind->num_ucis; i++) + { + uci_ind->uci_list[i] = ind->uci_list[i]; + + switch (uci_ind->uci_list[i].pdu_type) { + case NFAPI_NR_UCI_PUSCH_PDU_TYPE: + LOG_E(MAC, "%s(): unhandled NFAPI_NR_UCI_PUSCH_PDU_TYPE\n", __func__); + break; + + case NFAPI_NR_UCI_FORMAT_0_1_PDU_TYPE: { + nfapi_nr_uci_pucch_pdu_format_0_1_t *uci_ind_pdu = &uci_ind->uci_list[i].pucch_pdu_format_0_1; + nfapi_nr_uci_pucch_pdu_format_0_1_t *ind_pdu = &ind->uci_list[i].pucch_pdu_format_0_1; + if (ind_pdu->sr) { + uci_ind_pdu->sr = CALLOC(1, sizeof(*uci_ind_pdu->sr)); + AssertFatal(uci_ind_pdu->sr != NULL, "Memory not allocated for uci_ind_pdu->harq in phy_nr_uci_indication."); + *uci_ind_pdu->sr = *ind_pdu->sr; + } + if (ind_pdu->harq) { + uci_ind_pdu->harq = CALLOC(1, sizeof(*uci_ind_pdu->harq)); + AssertFatal(uci_ind_pdu->harq != NULL, "Memory not allocated for uci_ind_pdu->harq in phy_nr_uci_indication."); + + *uci_ind_pdu->harq = *ind_pdu->harq; + uci_ind_pdu->harq->harq_list = CALLOC(uci_ind_pdu->harq->num_harq, sizeof(*uci_ind_pdu->harq->harq_list)); + AssertFatal(uci_ind_pdu->harq->harq_list != NULL, "Memory not allocated for uci_ind_pdu->harq->harq_list in phy_nr_uci_indication."); + for (int j = 0; j < uci_ind_pdu->harq->num_harq; j++) + uci_ind_pdu->harq->harq_list[j].harq_value = ind_pdu->harq->harq_list[j].harq_value; + } + break; + } + + case NFAPI_NR_UCI_FORMAT_2_3_4_PDU_TYPE: { + nfapi_nr_uci_pucch_pdu_format_2_3_4_t *uci_ind_pdu = &uci_ind->uci_list[i].pucch_pdu_format_2_3_4; + nfapi_nr_uci_pucch_pdu_format_2_3_4_t *ind_pdu = &ind->uci_list[i].pucch_pdu_format_2_3_4; + + uci_ind_pdu->harq.harq_payload = CALLOC(1, sizeof(*uci_ind_pdu->harq.harq_payload)); + AssertFatal(uci_ind_pdu->harq.harq_payload != NULL, "Memory not allocated for uci_ind_pdu->harq.harq_payload in phy_nr_uci_indication."); + *uci_ind_pdu->harq.harq_payload = *ind_pdu->harq.harq_payload; + + + uci_ind_pdu->csi_part1.csi_part1_payload = CALLOC(1, sizeof(*uci_ind_pdu->csi_part1.csi_part1_payload)); + AssertFatal(uci_ind_pdu->csi_part1.csi_part1_payload != NULL, "Memory not allocated for uci_ind_pdu->csi_part1.csi_part1_payload in phy_nr_uci_indication."); + *uci_ind_pdu->csi_part1.csi_part1_payload = *ind_pdu->csi_part1.csi_part1_payload; + + + uci_ind_pdu->csi_part2.csi_part2_payload = CALLOC(1, sizeof(*uci_ind_pdu->csi_part2.csi_part2_payload)); + AssertFatal(uci_ind_pdu->csi_part2.csi_part2_payload != NULL, "Memory not allocated for uci_ind_pdu->csi_part2.csi_part2_payload in phy_nr_uci_indication."); + *uci_ind_pdu->csi_part2.csi_part2_payload = *ind_pdu->csi_part2.csi_part2_payload; + + break; + } + } + } + + if (!put_queue(&gnb_uci_ind_queue, uci_ind)) + { + LOG_E(NR_MAC, "Put_queue failed for uci_ind\n"); + for (int i = 0; i < ind->num_ucis; i++) + { + if (uci_ind->uci_list[i].pdu_type == NFAPI_NR_UCI_FORMAT_0_1_PDU_TYPE) + { + if (uci_ind->uci_list[i].pucch_pdu_format_0_1.harq) { + free(uci_ind->uci_list[i].pucch_pdu_format_0_1.harq->harq_list); + uci_ind->uci_list[i].pucch_pdu_format_0_1.harq->harq_list = NULL; + free(uci_ind->uci_list[i].pucch_pdu_format_0_1.harq); + uci_ind->uci_list[i].pucch_pdu_format_0_1.harq = NULL; + } + if (uci_ind->uci_list[i].pucch_pdu_format_0_1.sr) { + free(uci_ind->uci_list[i].pucch_pdu_format_0_1.sr); + uci_ind->uci_list[i].pucch_pdu_format_0_1.sr = NULL; + } + } + if (uci_ind->uci_list[i].pdu_type == NFAPI_NR_UCI_FORMAT_2_3_4_PDU_TYPE) + { + free(uci_ind->uci_list[i].pucch_pdu_format_2_3_4.harq.harq_payload); + free(uci_ind->uci_list[i].pucch_pdu_format_2_3_4.csi_part1.csi_part1_payload); + free(uci_ind->uci_list[i].pucch_pdu_format_2_3_4.csi_part2.csi_part2_payload); + } + } + free(uci_ind->uci_list); + uci_ind->uci_list = NULL; + free(uci_ind); + uci_ind = NULL; + } + } + else { + LOG_E(NR_MAC, "NFAPI_MODE = %d not NFAPI_MODE_VNF(2)\n", nfapi_getmode()); + } + return 1; +} + int phy_harq_indication(struct nfapi_vnf_p7_config *config, nfapi_harq_indication_t *ind) { struct PHY_VARS_eNB_s *eNB = RC.eNB[0][0]; LOG_D(MAC, "%s() NFAPI SFN/SF:%d number_of_harqs:%u\n", __FUNCTION__, NFAPI_SFNSF2DEC(ind->sfn_sf), ind->harq_indication_body.number_of_harqs); - pthread_mutex_lock(&eNB->UL_INFO_mutex); + AssertFatal(pthread_mutex_lock(&eNB->UL_INFO_mutex)==0, "Mutex lock failed"); if(NFAPI_MODE == NFAPI_MODE_VNF){ - int8_t index = -1; - for(uint8_t i= 0;i< NUM_NFPAI_SUBFRAME;i++){ - if((UL_RCC_INFO.harq_ind[i].header.message_id == 0) && (index == -1)){ - index = i; - break; - } - } - if(index == -1){ - LOG_E(MAC,"phy_harq_indication : num of harq reach max \n"); - pthread_mutex_unlock(&eNB->UL_INFO_mutex); - return 0; - } + int8_t index = NFAPI_SFNSF2SF(ind->sfn_sf); + UL_RCC_INFO.harq_ind[index] = *ind; - if (ind->harq_indication_body.number_of_harqs > 0) - UL_RCC_INFO.harq_ind[index].harq_indication_body.harq_pdu_list = malloc(sizeof(nfapi_harq_indication_pdu_t)*ind->harq_indication_body.number_of_harqs ); + assert(ind->harq_indication_body.number_of_harqs <= NFAPI_HARQ_IND_MAX_PDU); + if (ind->harq_indication_body.number_of_harqs > 0) { + UL_RCC_INFO.harq_ind[index].harq_indication_body.harq_pdu_list = malloc(sizeof(nfapi_harq_indication_pdu_t) * NFAPI_HARQ_IND_MAX_PDU); + } for (int i=0; i<ind->harq_indication_body.number_of_harqs; i++) { memcpy(&UL_RCC_INFO.harq_ind[index].harq_indication_body.harq_pdu_list[i], &ind->harq_indication_body.harq_pdu_list[i], sizeof(nfapi_harq_indication_pdu_t)); } }else{ - eNB->UL_INFO.harq_ind = *ind; - eNB->UL_INFO.harq_ind.harq_indication_body.harq_pdu_list = eNB->harq_pdu_list; + eNB->UL_INFO.harq_ind = *ind; + eNB->UL_INFO.harq_ind.harq_indication_body.harq_pdu_list = eNB->harq_pdu_list; - for (int i=0; i<ind->harq_indication_body.number_of_harqs; i++) { - memcpy(&eNB->UL_INFO.harq_ind.harq_indication_body.harq_pdu_list[i], &ind->harq_indication_body.harq_pdu_list[i], sizeof(eNB->UL_INFO.harq_ind.harq_indication_body.harq_pdu_list[i])); - } + assert(ind->harq_indication_body.number_of_harqs <= NFAPI_HARQ_IND_MAX_PDU); + for (int i=0; i<ind->harq_indication_body.number_of_harqs; i++) { + memcpy(&eNB->UL_INFO.harq_ind.harq_indication_body.harq_pdu_list[i], + &ind->harq_indication_body.harq_pdu_list[i], + sizeof(eNB->UL_INFO.harq_ind.harq_indication_body.harq_pdu_list[i])); + } } - pthread_mutex_unlock(&eNB->UL_INFO_mutex); + AssertFatal(pthread_mutex_unlock(&eNB->UL_INFO_mutex)==0, "Mutex unlock failed"); // vnf_p7_info* p7_vnf = (vnf_p7_info*)(config->user_data); //mac_harq_ind(p7_vnf->mac, ind); return 1; @@ -761,28 +892,18 @@ int phy_harq_indication(struct nfapi_vnf_p7_config *config, nfapi_harq_indicatio int phy_crc_indication(struct nfapi_vnf_p7_config *config, nfapi_crc_indication_t *ind) { struct PHY_VARS_eNB_s *eNB = RC.eNB[0][0]; - pthread_mutex_lock(&eNB->UL_INFO_mutex); + AssertFatal(pthread_mutex_lock(&eNB->UL_INFO_mutex)==0, "Mutex lock failed"); if(NFAPI_MODE == NFAPI_MODE_VNF){ - int8_t index = -1; - for(uint8_t i= 0;i< NUM_NFPAI_SUBFRAME;i++){ - if((UL_RCC_INFO.crc_ind[i].header.message_id == 0) && (index == -1)){ - index = i; - } - if(UL_RCC_INFO.rx_ind[i].sfn_sf == ind->sfn_sf){ - index = i; - break; - } - } - if(index == -1){ - LOG_E(MAC,"phy_crc_indication : num of crc reach max \n"); - pthread_mutex_unlock(&eNB->UL_INFO_mutex); - return 0; - } + int8_t index = NFAPI_SFNSF2SF(ind->sfn_sf); + UL_RCC_INFO.crc_ind[index] = *ind; - if (ind->crc_indication_body.number_of_crcs > 0) - UL_RCC_INFO.crc_ind[index].crc_indication_body.crc_pdu_list = malloc(sizeof(nfapi_crc_indication_pdu_t)*ind->crc_indication_body.number_of_crcs ); + assert(ind->crc_indication_body.number_of_crcs <= NFAPI_CRC_IND_MAX_PDU); + if (ind->crc_indication_body.number_of_crcs > 0) { + UL_RCC_INFO.crc_ind[index].crc_indication_body.crc_pdu_list = malloc(sizeof(nfapi_crc_indication_pdu_t) * NFAPI_CRC_IND_MAX_PDU); + } + assert(ind->crc_indication_body.number_of_crcs <= NFAPI_CRC_IND_MAX_PDU); for (int i=0; i<ind->crc_indication_body.number_of_crcs; i++) { memcpy(&UL_RCC_INFO.crc_ind[index].crc_indication_body.crc_pdu_list[i], &ind->crc_indication_body.crc_pdu_list[i], sizeof(ind->crc_indication_body.crc_pdu_list[0])); @@ -804,6 +925,7 @@ int phy_crc_indication(struct nfapi_vnf_p7_config *config, nfapi_crc_indication_ LOG_D(MAC, "%s() NFAPI SFN/SF:%d IND:number_of_crcs:%u UL_INFO:crcs:%d\n", __FUNCTION__, NFAPI_SFNSF2DEC(ind->sfn_sf), ind->crc_indication_body.number_of_crcs, eNB->UL_INFO.crc_ind.crc_indication_body.number_of_crcs); + assert(ind->crc_indication_body.number_of_crcs <= NFAPI_CRC_IND_MAX_PDU); for (int i=0; i<ind->crc_indication_body.number_of_crcs; i++) { memcpy(&dest_ind->crc_indication_body.crc_pdu_list[i], &ind->crc_indication_body.crc_pdu_list[i], sizeof(ind->crc_indication_body.crc_pdu_list[0])); LOG_D(MAC, "%s() NFAPI SFN/SF:%d CRC_IND:number_of_crcs:%u UL_INFO:crcs:%d PDU[%d] rnti:%04x UL_INFO:rnti:%04x\n", @@ -814,12 +936,54 @@ int phy_crc_indication(struct nfapi_vnf_p7_config *config, nfapi_crc_indication_ eNB->UL_INFO.crc_ind.crc_indication_body.crc_pdu_list[i].rx_ue_information.rnti); } } - pthread_mutex_unlock(&eNB->UL_INFO_mutex); + AssertFatal(pthread_mutex_unlock(&eNB->UL_INFO_mutex)==0, "Mutex unlock failed"); // vnf_p7_info* p7_vnf = (vnf_p7_info*)(config->user_data); //mac_crc_ind(p7_vnf->mac, ind); return 1; } +int phy_nr_crc_indication(nfapi_nr_crc_indication_t *ind) { + + LOG_I(NR_MAC, "In %s() NFAPI SFN/SF: %d/%d number_of_pdus :%u\n", + __FUNCTION__,ind->sfn, ind->slot, ind->number_crcs); + + if(NFAPI_MODE == NFAPI_MODE_VNF) + { + nfapi_nr_crc_indication_t *crc_ind = CALLOC(1, sizeof(*crc_ind)); + crc_ind->header.message_id = ind->header.message_id; + crc_ind->number_crcs = ind->number_crcs; + crc_ind->sfn = ind->sfn; + crc_ind->slot = ind->slot; + if (ind->number_crcs > 0) { + crc_ind->crc_list = CALLOC(NFAPI_NR_CRC_IND_MAX_PDU, sizeof(nfapi_nr_crc_t)); + AssertFatal(crc_ind->crc_list != NULL, "Memory not allocated for crc_ind->crc_list in phy_nr_crc_indication."); + } + for (int j = 0; j < ind->number_crcs; j++) + { + crc_ind->crc_list[j].handle = ind->crc_list[j].handle; + crc_ind->crc_list[j].harq_id = ind->crc_list[j].harq_id; + crc_ind->crc_list[j].num_cb = ind->crc_list[j].num_cb; + crc_ind->crc_list[j].rnti = ind->crc_list[j].rnti; + crc_ind->crc_list[j].tb_crc_status = ind->crc_list[j].tb_crc_status; + crc_ind->crc_list[j].timing_advance = ind->crc_list[j].timing_advance; + crc_ind->crc_list[j].ul_cqi = ind->crc_list[j].ul_cqi; + LOG_I(NR_MAC, "Received crc_ind.harq_id = %d for %d index SFN SLot %u %u with rnti %x\n", + ind->crc_list[j].harq_id, j, ind->sfn, ind->slot, ind->crc_list[j].rnti); + } + if (!put_queue(&gnb_crc_ind_queue, crc_ind)) + { + LOG_E(NR_MAC, "Put_queue failed for crc_ind\n"); + free(crc_ind->crc_list); + free(crc_ind); + } + } + else + { + LOG_E(NR_MAC, "NFAPI_MODE = %d not NFAPI_MODE_VNF(2)\n", nfapi_getmode()); + } + return 1; +} + int phy_rx_indication(struct nfapi_vnf_p7_config *config, nfapi_rx_indication_t *ind) { struct PHY_VARS_eNB_s *eNB = RC.eNB[0][0]; @@ -827,51 +991,40 @@ int phy_rx_indication(struct nfapi_vnf_p7_config *config, nfapi_rx_indication_t LOG_D(MAC, "%s() NFAPI SFN/SF:%d number_of_pdus:%u\n", __FUNCTION__, NFAPI_SFNSF2DEC(ind->sfn_sf), ind->rx_indication_body.number_of_pdus); } - pthread_mutex_lock(&eNB->UL_INFO_mutex); + AssertFatal(pthread_mutex_lock(&eNB->UL_INFO_mutex)==0, "Mutex lock failed"); if(NFAPI_MODE == NFAPI_MODE_VNF){ - int8_t index = -1; - for(uint8_t i= 0;i< NUM_NFPAI_SUBFRAME;i++){ - if((UL_RCC_INFO.rx_ind[i].header.message_id == 0) && (index == -1)){ - index = i; - } - if(UL_RCC_INFO.crc_ind[i].sfn_sf == ind->sfn_sf){ - index = i; - break; - } - } - if(index == -1){ - LOG_E(MAC,"phy_rx_indication : num of rx reach max \n"); - pthread_mutex_unlock(&eNB->UL_INFO_mutex); - return 0; - } + int8_t index = NFAPI_SFNSF2SF(ind->sfn_sf); + UL_RCC_INFO.rx_ind[index] = *ind; - if (ind->rx_indication_body.number_of_pdus > 0) - UL_RCC_INFO.rx_ind[index].rx_indication_body.rx_pdu_list = malloc(sizeof(nfapi_rx_indication_pdu_t)*ind->rx_indication_body.number_of_pdus ); + size_t number_of_pdus = ind->rx_indication_body.number_of_pdus; + assert(number_of_pdus <= NFAPI_RX_IND_MAX_PDU); + + if (number_of_pdus > 0) { + UL_RCC_INFO.rx_ind[index].rx_indication_body.rx_pdu_list = + malloc(sizeof(nfapi_rx_indication_pdu_t) * NFAPI_RX_IND_MAX_PDU); + } - for (int i=0; i<ind->rx_indication_body.number_of_pdus; i++) { + for (int i=0; i<number_of_pdus; i++) { nfapi_rx_indication_pdu_t *dest_pdu = &UL_RCC_INFO.rx_ind[index].rx_indication_body.rx_pdu_list[i]; nfapi_rx_indication_pdu_t *src_pdu = &ind->rx_indication_body.rx_pdu_list[i]; memcpy(dest_pdu, src_pdu, sizeof(*src_pdu)); - // DJP - TODO FIXME - intentional memory leak if(dest_pdu->rx_indication_rel8.length > 0){ - dest_pdu->data = malloc(dest_pdu->rx_indication_rel8.length); - memcpy(dest_pdu->data, src_pdu->data, dest_pdu->rx_indication_rel8.length); - }else{ - dest_pdu->data = NULL; + assert(dest_pdu->rx_indication_rel8.length <= NFAPI_RX_IND_DATA_MAX); + memcpy(dest_pdu->rx_ind_data, src_pdu->rx_ind_data, dest_pdu->rx_indication_rel8.length); } - LOG_D(PHY, "%s() NFAPI SFN/SF:%d PDUs:%d [PDU:%d] handle:%d rnti:%04x length:%d offset:%d ul_cqi:%d ta:%d data:%p\n", + LOG_D(PHY, "%s() NFAPI SFN/SF:%d PDUs:%zu [PDU:%d] handle:%d rnti:%04x length:%d offset:%d ul_cqi:%d ta:%d data:%p\n", __FUNCTION__, - NFAPI_SFNSF2DEC(ind->sfn_sf), ind->rx_indication_body.number_of_pdus, i, + NFAPI_SFNSF2DEC(ind->sfn_sf), number_of_pdus, i, dest_pdu->rx_ue_information.handle, dest_pdu->rx_ue_information.rnti, dest_pdu->rx_indication_rel8.length, dest_pdu->rx_indication_rel8.offset, dest_pdu->rx_indication_rel8.ul_cqi, dest_pdu->rx_indication_rel8.timing_advance, - dest_pdu->data + dest_pdu->rx_ind_data ); } }else{ @@ -880,13 +1033,15 @@ int phy_rx_indication(struct nfapi_vnf_p7_config *config, nfapi_rx_indication_t *dest_ind = *ind; dest_ind->rx_indication_body.rx_pdu_list = dest_pdu_list; + assert(ind->rx_indication_body.number_of_pdus <= NFAPI_RX_IND_MAX_PDU); for(int i=0; i<ind->rx_indication_body.number_of_pdus; i++) { nfapi_rx_indication_pdu_t *dest_pdu = &dest_ind->rx_indication_body.rx_pdu_list[i]; nfapi_rx_indication_pdu_t *src_pdu = &ind->rx_indication_body.rx_pdu_list[i]; memcpy(dest_pdu, src_pdu, sizeof(*src_pdu)); - // DJP - TODO FIXME - intentional memory leak - dest_pdu->data = malloc(dest_pdu->rx_indication_rel8.length); - memcpy(dest_pdu->data, src_pdu->data, dest_pdu->rx_indication_rel8.length); + + assert(dest_pdu->rx_indication_rel8.length <= NFAPI_RX_IND_DATA_MAX); + memcpy(dest_pdu->rx_ind_data, src_pdu->rx_ind_data, dest_pdu->rx_indication_rel8.length); + LOG_D(PHY, "%s() NFAPI SFN/SF:%d PDUs:%d [PDU:%d] handle:%d rnti:%04x length:%d offset:%d ul_cqi:%d ta:%d data:%p\n", __FUNCTION__, NFAPI_SFNSF2DEC(ind->sfn_sf), ind->rx_indication_body.number_of_pdus, i, @@ -896,15 +1051,57 @@ int phy_rx_indication(struct nfapi_vnf_p7_config *config, nfapi_rx_indication_t dest_pdu->rx_indication_rel8.offset, dest_pdu->rx_indication_rel8.ul_cqi, dest_pdu->rx_indication_rel8.timing_advance, - dest_pdu->data + dest_pdu->rx_ind_data ); } } - pthread_mutex_unlock(&eNB->UL_INFO_mutex); + AssertFatal(pthread_mutex_unlock(&eNB->UL_INFO_mutex)==0, "Mutex unlock failed"); // vnf_p7_info* p7_vnf = (vnf_p7_info*)(config->user_data); //mac_rx_ind(p7_vnf->mac, ind); return 1; } + +int phy_nr_rx_data_indication(nfapi_nr_rx_data_indication_t *ind) { + + LOG_I(NR_MAC, "In %s() NFAPI SFN/SF: %d/%d number_of_pdus :%u, and pdu %p\n", + __FUNCTION__,ind->sfn, ind->slot, ind->number_of_pdus, ind->pdu_list[0].pdu); + + if(NFAPI_MODE == NFAPI_MODE_VNF) + { + nfapi_nr_rx_data_indication_t *rx_ind = CALLOC(1, sizeof(*rx_ind)); + rx_ind->header.message_id = ind->header.message_id; + rx_ind->sfn = ind->sfn; + rx_ind->slot = ind->slot; + rx_ind->number_of_pdus = ind->number_of_pdus; + + if (ind->number_of_pdus > 0) { + rx_ind->pdu_list = CALLOC(NFAPI_NR_RX_DATA_IND_MAX_PDU, sizeof(nfapi_nr_rx_data_pdu_t)); + AssertFatal(rx_ind->pdu_list != NULL, "Memory not allocated for rx_ind->pdu_list in phy_nr_rx_data_indication."); + } + for (int j = 0; j < ind->number_of_pdus; j++) + { + rx_ind->pdu_list[j].handle = ind->pdu_list[j].handle; + rx_ind->pdu_list[j].harq_id = ind->pdu_list[j].harq_id; + rx_ind->pdu_list[j].pdu = ind->pdu_list[j].pdu; + rx_ind->pdu_list[j].pdu_length = ind->pdu_list[j].pdu_length; + rx_ind->pdu_list[j].rnti = ind->pdu_list[j].rnti; + rx_ind->pdu_list[j].timing_advance = ind->pdu_list[j].timing_advance; + rx_ind->pdu_list[j].ul_cqi = ind->pdu_list[j].ul_cqi; + } + if (!put_queue(&gnb_rx_ind_queue, rx_ind)) + { + LOG_E(NR_MAC, "Put_queue failed for rx_ind\n"); + free(rx_ind->pdu_list); + free(rx_ind); + } + } + else + { + LOG_E(NR_MAC, "NFAPI_MODE = %d not NFAPI_MODE_VNF(2)\n", nfapi_getmode()); + } + return 1; +} + int phy_srs_indication(struct nfapi_vnf_p7_config *config, nfapi_srs_indication_t *ind) { // vnf_p7_info* p7_vnf = (vnf_p7_info*)(config->user_data); //mac_srs_ind(p7_vnf->mac, ind); @@ -914,25 +1111,18 @@ int phy_srs_indication(struct nfapi_vnf_p7_config *config, nfapi_srs_indication_ int phy_sr_indication(struct nfapi_vnf_p7_config *config, nfapi_sr_indication_t *ind) { struct PHY_VARS_eNB_s *eNB = RC.eNB[0][0]; LOG_D(MAC, "%s() NFAPI SFN/SF:%d srs:%d\n", __FUNCTION__, NFAPI_SFNSF2DEC(ind->sfn_sf), ind->sr_indication_body.number_of_srs); - pthread_mutex_lock(&eNB->UL_INFO_mutex); + AssertFatal(pthread_mutex_lock(&eNB->UL_INFO_mutex)==0, "Mutex lock failed"); if(NFAPI_MODE == NFAPI_MODE_VNF){ - int8_t index = -1; - for(uint8_t i= 0;i< NUM_NFPAI_SUBFRAME;i++){ - if((UL_RCC_INFO.sr_ind[i].header.message_id == 0) && (index == -1)){ - index = i; - break; - } - } - if(index == -1){ - LOG_E(MAC,"phy_sr_indication : num of sr reach max \n"); - pthread_mutex_unlock(&eNB->UL_INFO_mutex); - return 0; - } + int8_t index = NFAPI_SFNSF2SF(ind->sfn_sf); + UL_RCC_INFO.sr_ind[index] = *ind; LOG_D(MAC,"%s() UL_INFO[%d].sr_ind.sr_indication_body.number_of_srs:%d\n", __FUNCTION__, index, eNB->UL_INFO.sr_ind.sr_indication_body.number_of_srs); - if (ind->sr_indication_body.number_of_srs > 0) - UL_RCC_INFO.sr_ind[index].sr_indication_body.sr_pdu_list = malloc(sizeof(nfapi_sr_indication_pdu_t)*ind->sr_indication_body.number_of_srs ); + if (ind->sr_indication_body.number_of_srs > 0) { + assert(ind->sr_indication_body.number_of_srs <= NFAPI_SR_IND_MAX_PDU); + UL_RCC_INFO.sr_ind[index].sr_indication_body.sr_pdu_list = malloc(sizeof(nfapi_sr_indication_pdu_t) * NFAPI_SR_IND_MAX_PDU); + } + assert(ind->sr_indication_body.number_of_srs <= NFAPI_SR_IND_MAX_PDU); for (int i=0; i<ind->sr_indication_body.number_of_srs; i++) { nfapi_sr_indication_pdu_t *dest_pdu = &UL_RCC_INFO.sr_ind[index].sr_indication_body.sr_pdu_list[i]; nfapi_sr_indication_pdu_t *src_pdu = &ind->sr_indication_body.sr_pdu_list[i]; @@ -948,6 +1138,7 @@ int phy_sr_indication(struct nfapi_vnf_p7_config *config, nfapi_sr_indication_t dest_ind->sr_indication_body.sr_pdu_list = dest_pdu_list; LOG_D(MAC,"%s() eNB->UL_INFO.sr_ind.sr_indication_body.number_of_srs:%d\n", __FUNCTION__, eNB->UL_INFO.sr_ind.sr_indication_body.number_of_srs); + assert(eNB->UL_INFO.sr_ind.sr_indication_body.number_of_srs <= NFAPI_SR_IND_MAX_PDU); for (int i=0; i<eNB->UL_INFO.sr_ind.sr_indication_body.number_of_srs; i++) { nfapi_sr_indication_pdu_t *dest_pdu = &dest_ind->sr_indication_body.sr_pdu_list[i]; nfapi_sr_indication_pdu_t *src_pdu = &ind->sr_indication_body.sr_pdu_list[i]; @@ -955,36 +1146,63 @@ int phy_sr_indication(struct nfapi_vnf_p7_config *config, nfapi_sr_indication_t memcpy(dest_pdu, src_pdu, sizeof(*src_pdu)); } } - pthread_mutex_unlock(&eNB->UL_INFO_mutex); + AssertFatal(pthread_mutex_unlock(&eNB->UL_INFO_mutex)==0, "Mutex unlock failed"); // vnf_p7_info* p7_vnf = (vnf_p7_info*)(config->user_data); //mac_sr_ind(p7_vnf->mac, ind); return 1; } +static bool is_ue_same(uint16_t ue_id_1, uint16_t ue_id_2) +{ + return (ue_id_1 == ue_id_2); +} + +static void analyze_cqi_pdus_for_duplicates(nfapi_cqi_indication_t *ind) +{ + uint16_t num_cqis = ind->cqi_indication_body.number_of_cqis; + assert(num_cqis <= NFAPI_CQI_IND_MAX_PDU); + for (int i = 0; i < num_cqis; i++) + { + nfapi_cqi_indication_pdu_t *src_pdu = &ind->cqi_indication_body.cqi_pdu_list[i]; + + LOG_I(MAC, "CQI_IND[PDU:%d][rnti:%x cqi:%d channel:%d]\n", i, src_pdu->rx_ue_information.rnti, + src_pdu->ul_cqi_information.ul_cqi, src_pdu->ul_cqi_information.channel); + + for (int j = i + 1; j < num_cqis; j++) + { + uint16_t rnti_i = ind->cqi_indication_body.cqi_pdu_list[i].rx_ue_information.rnti; + uint16_t rnti_j = ind->cqi_indication_body.cqi_pdu_list[j].rx_ue_information.rnti; + if (is_ue_same(rnti_i, rnti_j)) + { + LOG_E(MAC, "Problem, two cqis received from a single UE for rnti %x\n", + rnti_i); + //abort(); This will be fixed in merge request which handles multiple CQIs. + } + } + } +} + int phy_cqi_indication(struct nfapi_vnf_p7_config *config, nfapi_cqi_indication_t *ind) { // vnf_p7_info* p7_vnf = (vnf_p7_info*)(config->user_data); //mac_cqi_ind(p7_vnf->mac, ind); struct PHY_VARS_eNB_s *eNB = RC.eNB[0][0]; LOG_D(MAC, "%s() NFAPI SFN/SF:%d number_of_cqis:%u\n", __FUNCTION__, NFAPI_SFNSF2DEC(ind->sfn_sf), ind->cqi_indication_body.number_of_cqis); - pthread_mutex_lock(&eNB->UL_INFO_mutex); + AssertFatal(pthread_mutex_lock(&eNB->UL_INFO_mutex)==0, "Mutex lock failed"); if(NFAPI_MODE == NFAPI_MODE_VNF){ - int8_t index = -1; - for(uint8_t i= 0;i< NUM_NFPAI_SUBFRAME;i++){ - if((UL_RCC_INFO.cqi_ind[i].header.message_id == 0) && (index == -1)){ - index = i; - break; - } - } - if(index == -1){ - LOG_E(MAC,"phy_cqi_indication : num of cqi reach max \n"); - pthread_mutex_unlock(&eNB->UL_INFO_mutex); - return 0; - } + int8_t index = NFAPI_SFNSF2SF(ind->sfn_sf); + UL_RCC_INFO.cqi_ind[index] = *ind; + assert(ind->cqi_indication_body.number_of_cqis <= NFAPI_CQI_IND_MAX_PDU); if (ind->cqi_indication_body.number_of_cqis > 0){ - UL_RCC_INFO.cqi_ind[index].cqi_indication_body.cqi_pdu_list = malloc(sizeof(nfapi_cqi_indication_pdu_t)*ind->cqi_indication_body.number_of_cqis ); - UL_RCC_INFO.cqi_ind[index].cqi_indication_body.cqi_raw_pdu_list = malloc(sizeof(nfapi_cqi_indication_raw_pdu_t)*ind->cqi_indication_body.number_of_cqis ); + UL_RCC_INFO.cqi_ind[index].cqi_indication_body.cqi_pdu_list = + malloc(sizeof(nfapi_cqi_indication_pdu_t) * NFAPI_CQI_IND_MAX_PDU); + UL_RCC_INFO.cqi_ind[index].cqi_indication_body.cqi_raw_pdu_list = + malloc(sizeof(nfapi_cqi_indication_raw_pdu_t) * NFAPI_CQI_IND_MAX_PDU); } + + analyze_cqi_pdus_for_duplicates(ind); + + assert(ind->cqi_indication_body.number_of_cqis <= NFAPI_CQI_IND_MAX_PDU); for (int i=0; i<ind->cqi_indication_body.number_of_cqis; i++) { nfapi_cqi_indication_pdu_t *src_pdu = &ind->cqi_indication_body.cqi_pdu_list[i]; LOG_D(MAC, "SR_IND[PDU:%d][rnti:%x cqi:%d channel:%d]\n", i, src_pdu->rx_ue_information.rnti, @@ -1000,9 +1218,10 @@ int phy_cqi_indication(struct nfapi_vnf_p7_config *config, nfapi_cqi_indication_ *dest_ind = *ind; dest_ind->cqi_indication_body.cqi_pdu_list = ind->cqi_indication_body.cqi_pdu_list; dest_ind->cqi_indication_body.cqi_raw_pdu_list = ind->cqi_indication_body.cqi_raw_pdu_list; + assert(ind->cqi_indication_body.number_of_cqis <= NFAPI_CQI_IND_MAX_PDU); for(int i=0; i<ind->cqi_indication_body.number_of_cqis; i++) { nfapi_cqi_indication_pdu_t *src_pdu = &ind->cqi_indication_body.cqi_pdu_list[i]; - LOG_D(MAC, "SR_IND[PDU:%d][rnti:%x cqi:%d channel:%d]\n", i, src_pdu->rx_ue_information.rnti, + LOG_D(MAC, "CQI_IND[PDU:%d][rnti:%x cqi:%d channel:%d]\n", i, src_pdu->rx_ue_information.rnti, src_pdu->ul_cqi_information.ul_cqi, src_pdu->ul_cqi_information.channel); memcpy(&dest_ind->cqi_indication_body.cqi_pdu_list[i], src_pdu, sizeof(nfapi_cqi_indication_pdu_t)); @@ -1010,79 +1229,34 @@ int phy_cqi_indication(struct nfapi_vnf_p7_config *config, nfapi_cqi_indication_ &ind->cqi_indication_body.cqi_raw_pdu_list[i], sizeof(nfapi_cqi_indication_raw_pdu_t)); } } - pthread_mutex_unlock(&eNB->UL_INFO_mutex); + AssertFatal(pthread_mutex_unlock(&eNB->UL_INFO_mutex)==0, "Mutex unlock failed"); return 1; } //NR phy indication int phy_nr_slot_indication(nfapi_nr_slot_indication_scf_t *ind) { - - uint8_t vnf_slot_ahead = 2; - uint32_t vnf_sfn_slot = sfnslot_add_slot(ind->sfn, ind->slot, vnf_slot_ahead); - uint16_t vnf_sfn = NFAPI_SFNSLOT2SFN(vnf_sfn_slot); - uint8_t vnf_slot = NFAPI_SFNSLOT2SLOT(vnf_sfn_slot); //offsetting the vnf from pnf by vnf_slot_head slots - struct PHY_VARS_gNB_s *gNB = RC.gNB[0]; - pthread_mutex_lock(&gNB->UL_INFO_mutex); - gNB->UL_INFO.frame = vnf_sfn; - gNB->UL_INFO.slot = vnf_slot; - pthread_mutex_unlock(&gNB->UL_INFO_mutex); - LOG_D(MAC, "VNF SFN/Slot %d.%d \n", gNB->UL_INFO.frame, gNB->UL_INFO.slot); - - return 1; -} - -int phy_nr_crc_indication(nfapi_nr_crc_indication_t *ind) { - struct PHY_VARS_gNB_s *gNB = RC.gNB[0]; - pthread_mutex_lock(&gNB->UL_INFO_mutex); - - gNB->UL_INFO.crc_ind = *ind; - - if (ind->number_crcs > 0) - gNB->UL_INFO.crc_ind.crc_list = malloc(sizeof(nfapi_nr_crc_t)*ind->number_crcs); - - for (int i=0; i<ind->number_crcs; i++) - memcpy(&gNB->UL_INFO.crc_ind.crc_list[i], &ind->crc_list[i], sizeof(ind->crc_list[0])); - - pthread_mutex_unlock(&gNB->UL_INFO_mutex); - - return 1; -} - -int phy_nr_rx_data_indication(nfapi_nr_rx_data_indication_t *ind) { - struct PHY_VARS_gNB_s *gNB = RC.gNB[0]; - pthread_mutex_lock(&gNB->UL_INFO_mutex); - - gNB->UL_INFO.rx_ind = *ind; - - if (ind->number_of_pdus > 0) - gNB->UL_INFO.rx_ind.pdu_list = malloc(sizeof(nfapi_nr_rx_data_pdu_t)*ind->number_of_pdus); - - for (int i=0; i<ind->number_of_pdus; i++) - memcpy(&gNB->UL_INFO.rx_ind.pdu_list[i], &ind->pdu_list[i], sizeof(ind->pdu_list[0])); - - pthread_mutex_unlock(&gNB->UL_INFO_mutex); + uint8_t vnf_slot_ahead = 0; + uint32_t vnf_sfn_slot = sfnslot_add_slot(ind->sfn, ind->slot, vnf_slot_ahead); + uint16_t vnf_sfn = NFAPI_SFNSLOT2SFN(vnf_sfn_slot); + uint8_t vnf_slot = NFAPI_SFNSLOT2SLOT(vnf_sfn_slot); + LOG_D(MAC, "VNF SFN/Slot %d.%d \n", vnf_sfn, vnf_slot); + + nfapi_nr_slot_indication_scf_t *nr_slot_ind = CALLOC(1, sizeof(*nr_slot_ind)); + nr_slot_ind->header = ind->header; + nr_slot_ind->sfn = vnf_sfn; + nr_slot_ind->slot = vnf_slot; + if (!put_queue(&gnb_slot_ind_queue, nr_slot_ind)) + { + LOG_E(NR_MAC, "Put_queue failed for slot_ind\n"); + free(nr_slot_ind); + nr_slot_ind = NULL; + } return 1; } -int phy_nr_uci_indication(nfapi_nr_uci_indication_t *ind) { - struct PHY_VARS_gNB_s *gNB = RC.gNB[0]; - pthread_mutex_lock(&gNB->UL_INFO_mutex); - - gNB->UL_INFO.uci_ind = *ind; - - if (ind->num_ucis > 0) - gNB->UL_INFO.uci_ind.uci_list = malloc(sizeof(nfapi_nr_uci_t)*ind->num_ucis); - - for (int i=0; i<ind->num_ucis; i++) - memcpy(&gNB->UL_INFO.uci_ind.uci_list[i], &ind->uci_list[i], sizeof(ind->uci_list[0])); - //printf("UCI ind written to UL_info: num_ucis: %d, PDU_type : %d. \n", ind->num_ucis, ind->uci_list[0].pdu_type); - pthread_mutex_unlock(&gNB->UL_INFO_mutex); - - return 1; -} int phy_nr_srs_indication(nfapi_nr_srs_indication_t *ind) { struct PHY_VARS_gNB_s *gNB = RC.gNB[0]; @@ -1106,30 +1280,6 @@ int phy_nr_srs_indication(nfapi_nr_srs_indication_t *ind) { return 1; } - -int phy_nr_rach_indication(nfapi_nr_rach_indication_t *ind) { - struct PHY_VARS_gNB_s *gNB = RC.gNB[0]; - pthread_mutex_lock(&gNB->UL_INFO_mutex); - - gNB->UL_INFO.rach_ind = *ind; - - if (ind->number_of_pdus > 0) - gNB->UL_INFO.rach_ind.pdu_list = malloc(sizeof(nfapi_nr_prach_indication_pdu_t)*ind->number_of_pdus); - - for (int i=0; i<ind->number_of_pdus; i++) { - memcpy(&gNB->UL_INFO.rach_ind.pdu_list[i], &ind->pdu_list[i], sizeof(ind->pdu_list[0])); - - LOG_D(MAC, "%s() NFAPI SFN/Slot:%d.%d RACH_IND:number_of_pdus:%d UL_INFO:pdus:%d\n", - __FUNCTION__, - ind->sfn,ind->slot, ind->number_of_pdus, gNB->UL_INFO.rach_ind.number_of_pdus - ); - } - - pthread_mutex_unlock(&gNB->UL_INFO_mutex); - - return 1; -} - //end NR phy indication int phy_lbt_dl_indication(struct nfapi_vnf_p7_config *config, nfapi_lbt_dl_indication_t *ind) { @@ -1171,9 +1321,9 @@ void vnf_trace(nfapi_trace_level_t nfapi_level, const char *message, ...) { int phy_vendor_ext(struct nfapi_vnf_p7_config *config, nfapi_p7_message_header_t *msg) { if(msg->message_id == P7_VENDOR_EXT_IND) { //vendor_ext_p7_ind* ind = (vendor_ext_p7_ind*)msg; - //printf("[VNF] vendor_ext (error_code:%d)\n", ind->error_code); + //NFAPI_TRACE(NFAPI_TRACE_INFO, "[VNF] vendor_ext (error_code:%d)\n", ind->error_code); } else { - printf("[VNF] unknown %02x\n", msg->message_id); + NFAPI_TRACE(NFAPI_TRACE_INFO, "[VNF] unknown %02x\n", msg->message_id); } return 0; @@ -1263,7 +1413,7 @@ static pthread_t vnf_start_pthread; static pthread_t vnf_p7_start_pthread; void *vnf_nr_p7_start_thread(void *ptr) { - printf("%s()\n", __FUNCTION__); + NFAPI_TRACE(NFAPI_TRACE_INFO, "%s()\n", __FUNCTION__); pthread_setname_np(pthread_self(), "VNF_P7"); nfapi_vnf_p7_config_t *config = (nfapi_vnf_p7_config_t *)ptr; nfapi_nr_vnf_p7_start(config); @@ -1271,7 +1421,7 @@ void *vnf_nr_p7_start_thread(void *ptr) { } void *vnf_p7_start_thread(void *ptr) { - printf("%s()\n", __FUNCTION__); + NFAPI_TRACE(NFAPI_TRACE_INFO, "%s()\n", __FUNCTION__); pthread_setname_np(pthread_self(), "VNF_P7"); nfapi_vnf_p7_config_t *config = (nfapi_vnf_p7_config_t *)ptr; nfapi_vnf_p7_start(config); @@ -1282,30 +1432,31 @@ void set_thread_priority(int priority); void *vnf_nr_p7_thread_start(void *ptr) { set_thread_priority(79); + init_queue(&gnb_rach_ind_queue); + init_queue(&gnb_rx_ind_queue); + init_queue(&gnb_crc_ind_queue); + init_queue(&gnb_uci_ind_queue); + init_queue(&gnb_slot_ind_queue); + vnf_p7_info *p7_vnf = (vnf_p7_info *)ptr; p7_vnf->config->port = p7_vnf->local_port; p7_vnf->config->sync_indication = &phy_sync_indication; p7_vnf->config->slot_indication = &phy_slot_indication; - p7_vnf->config->harq_indication = &phy_harq_indication; - p7_vnf->config->crc_indication = &phy_crc_indication; - p7_vnf->config->rx_indication = &phy_rx_indication; - p7_vnf->config->rach_indication = &phy_rach_indication; + p7_vnf->config->nr_crc_indication = &phy_nr_crc_indication; + p7_vnf->config->nr_rx_data_indication = &phy_nr_rx_data_indication; + p7_vnf->config->nr_rach_indication = &phy_nr_rach_indication; + p7_vnf->config->nr_uci_indication = &phy_nr_uci_indication; p7_vnf->config->srs_indication = &phy_srs_indication; p7_vnf->config->sr_indication = &phy_sr_indication; p7_vnf->config->cqi_indication = &phy_cqi_indication; p7_vnf->config->lbt_dl_indication = &phy_lbt_dl_indication; p7_vnf->config->nb_harq_indication = &phy_nb_harq_indication; p7_vnf->config->nrach_indication = &phy_nrach_indication; - p7_vnf->config->nr_crc_indication = &phy_nr_crc_indication; - p7_vnf->config->nr_slot_indication = &phy_nr_slot_indication; - p7_vnf->config->nr_rx_data_indication = &phy_nr_rx_data_indication; - p7_vnf->config->nr_uci_indication = &phy_nr_uci_indication; - p7_vnf->config->nr_rach_indication = &phy_nr_rach_indication; + p7_vnf->config->nr_slot_indication = &phy_nr_slot_indication; p7_vnf->config->nr_srs_indication = &phy_nr_srs_indication; p7_vnf->config->malloc = &vnf_allocate; p7_vnf->config->free = &vnf_deallocate; - p7_vnf->config->trace = &vnf_trace; p7_vnf->config->vendor_ext = &phy_vendor_ext; p7_vnf->config->user_data = p7_vnf; p7_vnf->mac->user_data = p7_vnf; @@ -1342,7 +1493,6 @@ void *vnf_p7_thread_start(void *ptr) { p7_vnf->config->nrach_indication = &phy_nrach_indication; p7_vnf->config->malloc = &vnf_allocate; p7_vnf->config->free = &vnf_deallocate; - p7_vnf->config->trace = &vnf_trace; p7_vnf->config->vendor_ext = &phy_vendor_ext; p7_vnf->config->user_data = p7_vnf; p7_vnf->mac->user_data = p7_vnf; @@ -1364,7 +1514,7 @@ int pnf_nr_start_resp_cb(nfapi_vnf_config_t *config, int p5_idx, nfapi_nr_pnf_st vnf_p7_info *p7_vnf = vnf->p7_vnfs; pnf_info *pnf = vnf->pnfs; nfapi_nr_param_request_scf_t req; - printf("[VNF] pnf start response idx:%d config:%p user_data:%p p7_vnf[config:%p thread_started:%d]\n", p5_idx, config, config->user_data, vnf->p7_vnfs[0].config, vnf->p7_vnfs[0].thread_started); + NFAPI_TRACE(NFAPI_TRACE_INFO, "[VNF] pnf start response idx:%d config:%p user_data:%p p7_vnf[config:%p thread_started:%d]\n", p5_idx, config, config->user_data, vnf->p7_vnfs[0].config, vnf->p7_vnfs[0].thread_started); if(p7_vnf->thread_started == 0) { pthread_t vnf_p7_thread; @@ -1375,7 +1525,7 @@ int pnf_nr_start_resp_cb(nfapi_vnf_config_t *config, int p5_idx, nfapi_nr_pnf_st } // start all the phys in the pnf. - printf("[VNF] Sending NFAPI_VNF_PARAM_REQUEST phy_id:%d\n", pnf->phys[0].id); + NFAPI_TRACE(NFAPI_TRACE_INFO, "[VNF] Sending NFAPI_VNF_PARAM_REQUEST phy_id:%d\n", pnf->phys[0].id); memset(&req, 0, sizeof(req)); req.header.message_id = NFAPI_NR_PHY_MSG_TYPE_PARAM_REQUEST; req.header.phy_id = pnf->phys[0].id; @@ -1388,7 +1538,7 @@ int pnf_start_resp_cb(nfapi_vnf_config_t *config, int p5_idx, nfapi_pnf_start_re vnf_p7_info *p7_vnf = vnf->p7_vnfs; pnf_info *pnf = vnf->pnfs; nfapi_param_request_t req; - printf("[VNF] pnf start response idx:%d config:%p user_data:%p p7_vnf[config:%p thread_started:%d]\n", p5_idx, config, config->user_data, vnf->p7_vnfs[0].config, vnf->p7_vnfs[0].thread_started); + NFAPI_TRACE(NFAPI_TRACE_INFO, "[VNF] pnf start response idx:%d config:%p user_data:%p p7_vnf[config:%p thread_started:%d]\n", p5_idx, config, config->user_data, vnf->p7_vnfs[0].config, vnf->p7_vnfs[0].thread_started); if(p7_vnf->thread_started == 0) { pthread_t vnf_p7_thread; @@ -1399,7 +1549,7 @@ int pnf_start_resp_cb(nfapi_vnf_config_t *config, int p5_idx, nfapi_pnf_start_re } // start all the phys in the pnf. - printf("[VNF] Sending NFAPI_VNF_PARAM_REQUEST phy_id:%d\n", pnf->phys[0].id); + NFAPI_TRACE(NFAPI_TRACE_INFO, "[VNF] Sending NFAPI_VNF_PARAM_REQUEST phy_id:%d\n", pnf->phys[0].id); memset(&req, 0, sizeof(req)); req.header.message_id = NFAPI_PARAM_REQUEST; req.header.phy_id = pnf->phys[0].id; @@ -1411,37 +1561,38 @@ extern uint32_t to_earfcn(int eutra_bandP,uint32_t dl_CarrierFreq,uint32_t bw); int nr_param_resp_cb(nfapi_vnf_config_t *config, int p5_idx, nfapi_nr_param_response_scf_t *resp) { - printf("[VNF] Received NFAPI_PARAM_RESP idx:%d phy_id:%d\n", p5_idx, resp->header.phy_id); + NFAPI_TRACE(NFAPI_TRACE_INFO, "[VNF] Received NFAPI_PARAM_RESP idx:%d phy_id:%d\n", p5_idx, resp->header.phy_id); vnf_info *vnf = (vnf_info *)(config->user_data); vnf_p7_info *p7_vnf = vnf->p7_vnfs; pnf_info *pnf = vnf->pnfs; phy_info *phy = pnf->phys; struct sockaddr_in pnf_p7_sockaddr; nfapi_nr_config_request_scf_t *req = &RC.nrmac[0]->config[0]; // check - phy->remote_port = 32123;//resp->nfapi_config.p7_pnf_port.value; + phy->remote_port = 50610;//resp->nfapi_config.p7_pnf_port.value; + //phy->remote_port = 32123;//resp->nfapi_config.p7_pnf_port.value; memcpy(&pnf_p7_sockaddr.sin_addr.s_addr, &(resp->nfapi_config.p7_pnf_address_ipv4.address[0]), 4); phy->remote_addr = inet_ntoa(pnf_p7_sockaddr.sin_addr); // for now just 1 - printf("[VNF] %d.%d pnf p7 %s:%d timing %u %u %u %u\n", p5_idx, phy->id, phy->remote_addr, phy->remote_port, p7_vnf->timing_window, p7_vnf->periodic_timing_period, p7_vnf->aperiodic_timing_enabled, + NFAPI_TRACE(NFAPI_TRACE_INFO, "[VNF] %d.%d pnf p7 %s:%d timing %u %u %u %u\n", p5_idx, phy->id, phy->remote_addr, phy->remote_port, p7_vnf->timing_window, p7_vnf->periodic_timing_period, p7_vnf->aperiodic_timing_enabled, p7_vnf->periodic_timing_period); req->header.message_id = NFAPI_NR_PHY_MSG_TYPE_CONFIG_REQUEST; req->header.phy_id = phy->id; - printf("[VNF] Send NFAPI_CONFIG_REQUEST\n"); - //printf("\n NR bandP =%d\n",req->nfapi_config.rf_bands.rf_band[0]); + NFAPI_TRACE(NFAPI_TRACE_INFO, "[VNF] Send NFAPI_CONFIG_REQUEST\n"); + //NFAPI_TRACE(NFAPI_TRACE_INFO, "\n NR bandP =%d\n",req->nfapi_config.rf_bands.rf_band[0]); req->nfapi_config.p7_vnf_port.tl.tag = NFAPI_NR_NFAPI_P7_VNF_PORT_TAG; req->nfapi_config.p7_vnf_port.value = p7_vnf->local_port; req->num_tlv++; - printf("[VNF] DJP local_port:%d\n", p7_vnf->local_port); + NFAPI_TRACE(NFAPI_TRACE_INFO, "[VNF] DJP local_port:%d\n", p7_vnf->local_port); req->nfapi_config.p7_vnf_address_ipv4.tl.tag = NFAPI_NR_NFAPI_P7_VNF_ADDRESS_IPV4_TAG; struct sockaddr_in vnf_p7_sockaddr; vnf_p7_sockaddr.sin_addr.s_addr = inet_addr(p7_vnf->local_addr); memcpy(&(req->nfapi_config.p7_vnf_address_ipv4.address[0]), &vnf_p7_sockaddr.sin_addr.s_addr, 4); req->num_tlv++; - printf("[VNF] DJP local_addr:%s\n", p7_vnf->local_addr); + NFAPI_TRACE(NFAPI_TRACE_INFO, "[VNF] DJP local_addr:%s\n", p7_vnf->local_addr); req->nfapi_config.timing_window.tl.tag = NFAPI_NR_NFAPI_TIMING_WINDOW_TAG; req->nfapi_config.timing_window.value = p7_vnf->timing_window; - printf("\n[VNF]Timing window tag : %d Timing window:%u\n",NFAPI_NR_NFAPI_TIMING_WINDOW_TAG, p7_vnf->timing_window); + NFAPI_TRACE(NFAPI_TRACE_INFO, "\n[VNF]Timing window tag : %d Timing window:%u\n",NFAPI_NR_NFAPI_TIMING_WINDOW_TAG, p7_vnf->timing_window); req->num_tlv++; if(p7_vnf->periodic_timing_enabled || p7_vnf->aperiodic_timing_enabled) { @@ -1455,7 +1606,7 @@ int nr_param_resp_cb(nfapi_vnf_config_t *config, int p5_idx, nfapi_nr_param_resp req->num_tlv++; } } -//TODO: Assign tag and value for P7 message offsets +//TODO: Assign tag and value for P7 message offsets req->nfapi_config.dl_tti_timing_offset.tl.tag = NFAPI_NR_NFAPI_DL_TTI_TIMING_OFFSET; req->nfapi_config.ul_tti_timing_offset.tl.tag = NFAPI_NR_NFAPI_UL_TTI_TIMING_OFFSET; req->nfapi_config.ul_dci_timing_offset.tl.tag = NFAPI_NR_NFAPI_UL_DCI_TIMING_OFFSET; @@ -1473,7 +1624,7 @@ req->nfapi_config.tx_data_timing_offset.tl.tag = NFAPI_NR_NFAPI_TX_DATA_TIMING_O int param_resp_cb(nfapi_vnf_config_t *config, int p5_idx, nfapi_param_response_t *resp) { - printf("[VNF] Received NFAPI_PARAM_RESP idx:%d phy_id:%d\n", p5_idx, resp->header.phy_id); + NFAPI_TRACE(NFAPI_TRACE_INFO, "[VNF] Received NFAPI_PARAM_RESP idx:%d phy_id:%d\n", p5_idx, resp->header.phy_id); vnf_info *vnf = (vnf_info *)(config->user_data); vnf_p7_info *p7_vnf = vnf->p7_vnfs; pnf_info *pnf = vnf->pnfs; @@ -1484,24 +1635,24 @@ int param_resp_cb(nfapi_vnf_config_t *config, int p5_idx, nfapi_param_response_t memcpy(&pnf_p7_sockaddr.sin_addr.s_addr, &(resp->nfapi_config.p7_pnf_address_ipv4.address[0]), 4); phy->remote_addr = inet_ntoa(pnf_p7_sockaddr.sin_addr); // for now just 1 - printf("[VNF] %d.%d pnf p7 %s:%d timing %u %u %u %u\n", p5_idx, phy->id, phy->remote_addr, phy->remote_port, p7_vnf->timing_window, p7_vnf->periodic_timing_period, p7_vnf->aperiodic_timing_enabled, + NFAPI_TRACE(NFAPI_TRACE_INFO, "[VNF] %d.%d pnf p7 %s:%d timing %u %u %u %u\n", p5_idx, phy->id, phy->remote_addr, phy->remote_port, p7_vnf->timing_window, p7_vnf->periodic_timing_period, p7_vnf->aperiodic_timing_enabled, p7_vnf->periodic_timing_period); req->header.message_id = NFAPI_CONFIG_REQUEST; req->header.phy_id = phy->id; - printf("[VNF] Send NFAPI_CONFIG_REQUEST\n"); + NFAPI_TRACE(NFAPI_TRACE_INFO, "[VNF] Send NFAPI_CONFIG_REQUEST\n"); req->nfapi_config.p7_vnf_port.tl.tag = NFAPI_NFAPI_P7_VNF_PORT_TAG; req->nfapi_config.p7_vnf_port.value = p7_vnf->local_port; req->num_tlv++; - printf("[VNF] DJP local_port:%d\n", p7_vnf->local_port); + NFAPI_TRACE(NFAPI_TRACE_INFO, "[VNF] DJP local_port:%d\n", p7_vnf->local_port); req->nfapi_config.p7_vnf_address_ipv4.tl.tag = NFAPI_NFAPI_P7_VNF_ADDRESS_IPV4_TAG; struct sockaddr_in vnf_p7_sockaddr; vnf_p7_sockaddr.sin_addr.s_addr = inet_addr(p7_vnf->local_addr); memcpy(&(req->nfapi_config.p7_vnf_address_ipv4.address[0]), &vnf_p7_sockaddr.sin_addr.s_addr, 4); req->num_tlv++; - printf("[VNF] DJP local_addr:%s\n", p7_vnf->local_addr); + NFAPI_TRACE(NFAPI_TRACE_INFO, "[VNF] DJP local_addr:%s\n", p7_vnf->local_addr); req->nfapi_config.timing_window.tl.tag = NFAPI_NFAPI_TIMING_WINDOW_TAG; req->nfapi_config.timing_window.value = p7_vnf->timing_window; - printf("[VNF] Timing window:%u\n", p7_vnf->timing_window); + NFAPI_TRACE(NFAPI_TRACE_INFO, "[VNF] Timing window:%u\n", p7_vnf->timing_window); req->num_tlv++; if(p7_vnf->periodic_timing_enabled || p7_vnf->aperiodic_timing_enabled) { @@ -1528,42 +1679,41 @@ int param_resp_cb(nfapi_vnf_config_t *config, int p5_idx, nfapi_param_response_t int nr_config_resp_cb(nfapi_vnf_config_t *config, int p5_idx, nfapi_nr_config_response_scf_t *resp) { nfapi_nr_start_request_scf_t req; - printf("[VNF] Received NFAPI_CONFIG_RESP idx:%d phy_id:%d\n", p5_idx, resp->header.phy_id); - printf("[VNF] Calling oai_enb_init()\n"); + NFAPI_TRACE(NFAPI_TRACE_INFO, "[VNF] Received NFAPI_CONFIG_RESP idx:%d phy_id:%d\n", p5_idx, resp->header.phy_id); + NFAPI_TRACE(NFAPI_TRACE_INFO, "[VNF] Calling oai_enb_init()\n"); oai_enb_init(); // TODO: change to gnb memset(&req, 0, sizeof(req)); req.header.message_id = NFAPI_NR_PHY_MSG_TYPE_START_REQUEST; req.header.phy_id = resp->header.phy_id; nfapi_nr_vnf_start_req(config, p5_idx, &req); - printf("[VNF] Send NFAPI_VNF_START_REQUEST idx:%d phy_id:%d\n", p5_idx, resp->header.phy_id); return 0; } int config_resp_cb(nfapi_vnf_config_t *config, int p5_idx, nfapi_config_response_t *resp) { nfapi_start_request_t req; - printf("[VNF] Received NFAPI_CONFIG_RESP idx:%d phy_id:%d\n", p5_idx, resp->header.phy_id); - printf("[VNF] Calling oai_enb_init()\n"); + NFAPI_TRACE(NFAPI_TRACE_INFO, "[VNF] Received NFAPI_CONFIG_RESP idx:%d phy_id:%d\n", p5_idx, resp->header.phy_id); + NFAPI_TRACE(NFAPI_TRACE_INFO, "[VNF] Calling oai_enb_init()\n"); oai_enb_init(); memset(&req, 0, sizeof(req)); req.header.message_id = NFAPI_START_REQUEST; req.header.phy_id = resp->header.phy_id; nfapi_vnf_start_req(config, p5_idx, &req); - printf("[VNF] Send NFAPI_START_REQUEST idx:%d phy_id:%d\n", p5_idx, resp->header.phy_id); + NFAPI_TRACE(NFAPI_TRACE_INFO, "[VNF] Send NFAPI_VNF_START_REQUEST idx:%d phy_id:%d\n", p5_idx, resp->header.phy_id); return 0; } int start_resp_cb(nfapi_vnf_config_t *config, int p5_idx, nfapi_start_response_t *resp) { - printf("[VNF] Received NFAPI_START_RESP idx:%d phy_id:%d\n", p5_idx, resp->header.phy_id); + NFAPI_TRACE(NFAPI_TRACE_INFO, "[VNF] Received NFAPI_START_RESP idx:%d phy_id:%d\n", p5_idx, resp->header.phy_id); vnf_info *vnf = (vnf_info *)(config->user_data); pnf_info *pnf = vnf->pnfs; phy_info *phy = pnf->phys; vnf_p7_info *p7_vnf = vnf->p7_vnfs; - nfapi_vnf_p7_add_pnf((p7_vnf->config), phy->remote_addr, phy->remote_port, phy->id); + nfapi_vnf_p7_add_pnf((p7_vnf->config), phy->remote_addr, htons(phy->remote_port), phy->id); return 0; } int nr_start_resp_cb(nfapi_vnf_config_t *config, int p5_idx, nfapi_nr_start_response_scf_t *resp) { - printf("[VNF] Received NFAPI_START_RESP idx:%d phy_id:%d\n", p5_idx, resp->header.phy_id); + NFAPI_TRACE(NFAPI_TRACE_INFO, "[VNF] Received NFAPI_START_RESP idx:%d phy_id:%d\n", p5_idx, resp->header.phy_id); vnf_info *vnf = (vnf_info *)(config->user_data); pnf_info *pnf = vnf->pnfs; phy_info *phy = pnf->phys; @@ -1574,12 +1724,12 @@ int nr_start_resp_cb(nfapi_vnf_config_t *config, int p5_idx, nfapi_nr_start_resp } int vendor_ext_cb(nfapi_vnf_config_t *config, int p5_idx, nfapi_p4_p5_message_header_t *msg) { - printf("[VNF] %s\n", __FUNCTION__); + NFAPI_TRACE(NFAPI_TRACE_INFO, "[VNF] %s\n", __FUNCTION__); switch(msg->message_id) { case P5_VENDOR_EXT_RSP: { vendor_ext_p5_rsp *rsp = (vendor_ext_p5_rsp *)msg; - printf("[VNF] P5_VENDOR_EXT_RSP error_code:%d\n", rsp->error_code); + NFAPI_TRACE(NFAPI_TRACE_INFO, "[VNF] P5_VENDOR_EXT_RSP error_code:%d\n", rsp->error_code); // send the start request nfapi_pnf_start_request_t req; memset(&req, 0, sizeof(req)); @@ -1645,18 +1795,18 @@ void configure_nr_nfapi_vnf(char *vnf_addr, int vnf_p5_port) { NFAPI_TRACE(NFAPI_TRACE_INFO, "[VNF] %s() vnf.p7_vnfs[0].config:%p VNF ADDRESS:%s:%d\n", __FUNCTION__, vnf.p7_vnfs[0].config, vnf_addr, vnf_p5_port); strcpy(vnf.p7_vnfs[0].local_addr, vnf_addr); //vnf.p7_vnfs[0].local_port = vnf.p7_vnfs[0].local_port; // 50001; // TODO: remove hardcode - vnf.p7_vnfs[0].local_port = 50011; + vnf.p7_vnfs[0].local_port = 50611; + //vnf.p7_vnfs[0].local_port = 50011; vnf.p7_vnfs[0].mac = (mac_t *)malloc(sizeof(mac_t)); nfapi_vnf_config_t *config = nfapi_vnf_config_create(); config->malloc = malloc; config->free = free; - config->trace = &vnf_trace; config->vnf_p5_port = vnf_p5_port; config->vnf_ipv4 = 1; config->vnf_ipv6 = 0; config->pnf_list = 0; config->phy_list = 0; - + config->pnf_nr_connection_indication = &pnf_nr_connection_indication_cb; config->pnf_disconnect_indication = &pnf_disconnection_indication_cb; @@ -1701,7 +1851,6 @@ void configure_nfapi_vnf(char *vnf_addr, int vnf_p5_port) { nfapi_vnf_config_t *config = nfapi_vnf_config_create(); config->malloc = malloc; config->free = free; - config->trace = &vnf_trace; config->vnf_p5_port = vnf_p5_port; config->vnf_ipv4 = 1; config->vnf_ipv6 = 0; @@ -1738,6 +1887,23 @@ int oai_nfapi_dl_config_req(nfapi_dl_config_request_t *dl_config_req) { nfapi_vnf_p7_config_t *p7_config = vnf.p7_vnfs[0].config; dl_config_req->header.phy_id = 1; // DJP HACK TODO FIXME - need to pass this around!!!! dl_config_req->header.message_id = NFAPI_DL_CONFIG_REQUEST; + LOG_I(PHY, "[VNF] %s() DL_CONFIG_REQ sfn_sf:%d_%d number_of_pdus:%d\n", __FUNCTION__, + NFAPI_SFNSF2SFN(dl_config_req->sfn_sf),NFAPI_SFNSF2SF(dl_config_req->sfn_sf), dl_config_req->dl_config_request_body.number_pdu); + if (dl_config_req->dl_config_request_body.number_pdu > 0) + { + for (int i = 0; i < dl_config_req->dl_config_request_body.number_pdu; i++) + { + uint8_t pdu_type = dl_config_req->dl_config_request_body.dl_config_pdu_list[i].pdu_type; + if(pdu_type == NFAPI_DL_CONFIG_DLSCH_PDU_TYPE) + { + uint16_t dl_rnti = dl_config_req->dl_config_request_body.dl_config_pdu_list[i].dlsch_pdu.dlsch_pdu_rel8.rnti; + uint16_t numPDUs = dl_config_req->dl_config_request_body.number_pdu; + LOG_I(MAC, "(OAI eNB) Sending dl_config_req at VNF during Frame: %d and Subframe: %d," + " with a RNTI value of: %x and with number of PDUs: %u\n", + NFAPI_SFNSF2SFN(dl_config_req->sfn_sf),NFAPI_SFNSF2SF(dl_config_req->sfn_sf), dl_rnti, numPDUs); + } + } + } int retval = nfapi_vnf_p7_dl_config_req(p7_config, dl_config_req); dl_config_req->dl_config_request_body.number_pdcch_ofdm_symbols = 1; dl_config_req->dl_config_request_body.number_dci = 0; @@ -1838,12 +2004,31 @@ int oai_nfapi_hi_dci0_req(nfapi_hi_dci0_request_t *hi_dci0_req) { return retval; } +static void remove_ul_config_req_pdu(int index, nfapi_ul_config_request_t *ul_config_req) +{ + int num_pdus = ul_config_req->ul_config_request_body.number_of_pdus; + nfapi_ul_config_request_pdu_t *pdu_list = ul_config_req->ul_config_request_body.ul_config_pdu_list; + + if (index >= num_pdus || index < 0) + { + LOG_E(MAC, "%s() Unable to drop bad ul_config_req PDU\n", __FUNCTION__); + abort(); + } + + for(int i = index; i + 1 < num_pdus; i++) + { + pdu_list[i] = pdu_list[i + 1]; + } + + ul_config_req->ul_config_request_body.number_of_pdus--; +} + int oai_nfapi_ul_tti_req(nfapi_nr_ul_tti_request_t *ul_tti_req) { nfapi_vnf_p7_config_t *p7_config = vnf.p7_vnfs[0].config; ul_tti_req->header.phy_id = 1; // DJP HACK TODO FIXME - need to pass this around!!!! ul_tti_req->header.message_id = NFAPI_NR_PHY_MSG_TYPE_UL_TTI_REQUEST; - + int retval = nfapi_vnf_p7_ul_tti_req(p7_config, ul_tti_req); if (retval!=0) { @@ -1864,6 +2049,44 @@ int oai_nfapi_ul_config_req(nfapi_ul_config_request_t *ul_config_req) { ul_config_req->header.message_id = NFAPI_UL_CONFIG_REQUEST; //LOG_D(PHY, "[VNF] %s() header message_id:%02x\n", __FUNCTION__, ul_config_req->header.message_id); //LOG_D(PHY, "[VNF] %s() UL_CONFIG sfn_sf:%d PDUs:%d rach_prach_frequency_resources:%d srs_present:%d\n", __FUNCTION__, NFAPI_SFNSF2DEC(ul_config_req->sfn_sf), ul_config_req->ul_config_request_body.number_of_pdus, ul_config_req->ul_config_request_body.rach_prach_frequency_resources, ul_config_req->ul_config_request_body.srs_present); + + int num_pdus = ul_config_req->ul_config_request_body.number_of_pdus; + nfapi_ul_config_request_pdu_t *pdu_list = ul_config_req->ul_config_request_body.ul_config_pdu_list; + for (int i = 0; i < num_pdus; i++) + { + uint8_t pdu_type = pdu_list[i].pdu_type; + + LOG_I(MAC, "ul_config_req num_pdus: %u pdu_number: %d pdu_type: %u SFN.SF: %d.%d\n", + num_pdus, i, pdu_type, ul_config_req->sfn_sf >> 4, ul_config_req->sfn_sf & 15); + + if (pdu_type != NFAPI_UL_CONFIG_ULSCH_CQI_RI_PDU_TYPE) + { + continue; + } + + for (int j = i + 1; j < num_pdus; j++) + { + uint8_t pdu_type2 = pdu_list[j].pdu_type; + if (pdu_type != pdu_type2) + { + continue; + } + + uint16_t rnti_i = pdu_list[i].ulsch_cqi_ri_pdu.ulsch_pdu.ulsch_pdu_rel8.rnti; + uint16_t rnti_j = pdu_list[j].ulsch_cqi_ri_pdu.ulsch_pdu.ulsch_pdu_rel8.rnti; + if (!is_ue_same(rnti_i, rnti_j)) + { + continue; + } + remove_ul_config_req_pdu(j, ul_config_req); + j--; + num_pdus--; + + LOG_E(MAC, "Problem, two cqis being sent to a single UE for rnti %x dropping one\n", + rnti_i); + } + } + int retval = nfapi_vnf_p7_ul_config_req(p7_config, ul_config_req); if (retval!=0) { diff --git a/nfapi/oai_integration/vendor_ext.h b/nfapi/oai_integration/vendor_ext.h index f25aa703ccdb5a5f3eac99225585c6595309066d..9a377dc27d85f4af71eefe9ef92f534b1ab2cf2b 100644 --- a/nfapi/oai_integration/vendor_ext.h +++ b/nfapi/oai_integration/vendor_ext.h @@ -70,10 +70,11 @@ typedef enum { NFAPI_MODE_VNF, NFAPI_UE_STUB_PNF, NFAPI_UE_STUB_OFFNET, + NFAPI_MODE_STANDALONE_PNF, NFAPI_MODE_UNKNOWN } nfapi_mode_t; -char *nfapi_get_strmode(void); +const char *nfapi_get_strmode(void); void nfapi_logmode(void); nfapi_mode_t nfapi_getmode(void); void nfapi_setmode(nfapi_mode_t nfapi_mode); diff --git a/nfapi/open-nFAPI/common/public_inc/debug.h b/nfapi/open-nFAPI/common/public_inc/debug.h index 14f97a17f6f8fbe23bd2e3e414b51baaa90f4714..574b09730100b0b54bedb3f454aeeced9f065397 100644 --- a/nfapi/open-nFAPI/common/public_inc/debug.h +++ b/nfapi/open-nFAPI/common/public_inc/debug.h @@ -14,38 +14,31 @@ * limitations under the License. */ +#pragma once -#ifndef _DEBUG_H_ -#define _DEBUG_H_ +#include <string.h> +#include <errno.h> + +#define ERR strerror(errno) /*! The trace levels used by the nfapi libraries */ typedef enum nfapi_trace_level { - NFAPI_TRACE_ERROR = 1, - NFAPI_TRACE_WARN, - NFAPI_TRACE_NOTE, - NFAPI_TRACE_INFO, - - NFAPI_TRACE_LEVEL_MAX + NFAPI_TRACE_NONE, + NFAPI_TRACE_ERROR, + NFAPI_TRACE_WARN, + NFAPI_TRACE_NOTE, + NFAPI_TRACE_INFO, + NFAPI_TRACE_DEBUG, } nfapi_trace_level_t; -/*! The trace function pointer */ -typedef void (*nfapi_trace_fn_t)(nfapi_trace_level_t level, const char* format, ...); - -/*! Global trace function */ -extern nfapi_trace_fn_t nfapi_trace_g; +void nfapi_trace(nfapi_trace_level_t, char const *caller, const char *format, ...) + __attribute__((format(printf, 3, 4))); -/*! Global trace level */ -extern nfapi_trace_level_t nfapi_trace_level_g; - -/*! NFAPI trace macro */ -//#define NFAPI_TRACE(level, format, ...) { if(nfapi_trace_g && ((nfapi_trace_level_t)level <= nfapi_trace_level_g)) (*nfapi_trace_g)(level, format, ##__VA_ARGS__); } -#define NFAPI_TRACE(level, format, ...) { if (nfapi_trace_g) (*nfapi_trace_g)(level, format, ##__VA_ARGS__); } - -/*! Function to change the trace level - * \param new_level The modified trace level - */ +nfapi_trace_level_t nfapi_trace_level(void); -void nfapi_set_trace_level(nfapi_trace_level_t new_level); +#define NFAPI_TRACE(LEVEL, FORMAT, ...) do { \ + if (nfapi_trace_level() >= (LEVEL)) \ + nfapi_trace(LEVEL, __func__, FORMAT, ##__VA_ARGS__); \ +} while (0) -#endif /* _DEBUG_H_ */ diff --git a/nfapi/open-nFAPI/common/src/debug.c b/nfapi/open-nFAPI/common/src/debug.c index 5d4ad8a19499ed32ccdffb223a28f5f22dc741ac..628e64d9473b103815ac0b8f2eab14f1faa92384 100644 --- a/nfapi/open-nFAPI/common/src/debug.c +++ b/nfapi/open-nFAPI/common/src/debug.c @@ -1,75 +1,87 @@ -/* - * Copyright 2017 Cisco Systems, Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * 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. - */ - -#include <stdio.h> -#include <stdarg.h> -#include <stdint.h> -#include <stdlib.h> -#include <string.h> -#include <unistd.h> -#include <errno.h> -#include <sys/time.h> -#include <sys/types.h> -#include <pthread.h> -#include <syslog.h> - -#include <debug.h> - -#define MAX_MSG_LENGTH 2096 -#define TRACE_HEADER_LENGTH 44 - -void nfapi_trace_dbg(nfapi_trace_level_t level, const char *format, ...); - -// initialize the trace function to 0 -void (*nfapi_trace_g)(nfapi_trace_level_t level, const char* format, ...) = &nfapi_trace_dbg; - -nfapi_trace_level_t nfapi_trace_level_g = NFAPI_TRACE_INFO; -//nfapi_trace_level_t nfapi_trace_level_g = NFAPI_TRACE_WARN; - -void nfapi_set_trace_level(nfapi_trace_level_t new_level) -{ - nfapi_trace_level_g = new_level; -} - -void nfapi_trace_dbg(nfapi_trace_level_t level, const char *format, ...) -{ - char trace_buff[MAX_MSG_LENGTH + TRACE_HEADER_LENGTH]; - uint32_t num_chars; - va_list p_args; - struct timeval tv; - pthread_t tid = pthread_self(); - - (void)gettimeofday(&tv, NULL); - - num_chars = (uint32_t)snprintf(trace_buff, TRACE_HEADER_LENGTH, "%04u.%06u: 0x%02x: %10u: ", ((uint32_t)tv.tv_sec) & 0x1FFF, (uint32_t)tv.tv_usec, (uint32_t)level, (uint32_t)tid); - - if (num_chars > TRACE_HEADER_LENGTH) - { - printf("trace_dbg: Error, num_chars is too large: %d", num_chars); - return; - } - - va_start(p_args, format); - if ((num_chars = (uint32_t)vsnprintf(&trace_buff[num_chars], MAX_MSG_LENGTH, format, p_args))) - { - if (level <= NFAPI_TRACE_WARN) - { - printf("%s", trace_buff); - } - printf("%s", trace_buff); - } - va_end(p_args); -} +/* + * Copyright 2017 Cisco Systems, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * 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. + */ + +#include "debug.h" +#include <stdio.h> +#include <stdarg.h> +#include <stdlib.h> +#include <time.h> +#include <pthread.h> +#include <stdbool.h> + +static nfapi_trace_level_t trace_level = NFAPI_TRACE_WARN; + +static void nfapi_trace_init(void) +{ + static bool initialized; + if (initialized) + return; + initialized = true; + + const char *env = getenv("NFAPI_TRACE_LEVEL"); + if (!env) + return; + if (strcmp(env, "none") == 0) + trace_level = NFAPI_TRACE_NONE; + else if (strcmp(env, "error") == 0) + trace_level = NFAPI_TRACE_ERROR; + else if (strcmp(env, "warn") == 0) + trace_level = NFAPI_TRACE_WARN; + else if (strcmp(env, "note") == 0) + trace_level = NFAPI_TRACE_NOTE; + else if (strcmp(env, "info") == 0) + trace_level = NFAPI_TRACE_INFO; + else if (strcmp(env, "debug") == 0) + trace_level = NFAPI_TRACE_DEBUG; + else + { + nfapi_trace(NFAPI_TRACE_ERROR, __func__, "Invalid NFAPI_TRACE_LEVEL='%s'", env); + return; + } + nfapi_trace(trace_level, __func__, "NFAPI_TRACE_LEVEL='%s'", env); +} + +nfapi_trace_level_t nfapi_trace_level() +{ + nfapi_trace_init(); + return trace_level; +} + +void nfapi_trace(nfapi_trace_level_t level, + char const *caller, + char const *format, ...) +{ + struct timespec ts; + clock_gettime(CLOCK_MONOTONIC, &ts); + printf("%ld%06ld [%c] %10u: %s: ", + ts.tv_sec, + ts.tv_nsec / 1000, + "XEWNID"[level], // NFAPI_TRACE_NONE, NFAPI_TRACE_ERROR, ... + (unsigned) pthread_self(), + caller); + + va_list ap; + va_start(ap, format); + vprintf(format, ap); + va_end(ap); + + // Add a newline if the format string didn't have one + int len = strlen(format); + if (len == 0 || format[len - 1] != '\n') + putchar('\n'); + + fflush(stdout); +} diff --git a/nfapi/open-nFAPI/nfapi/public_inc/fapi_nr_ue_constants.h b/nfapi/open-nFAPI/nfapi/public_inc/fapi_nr_ue_constants.h index e144ce9447a4aee059b7c7994b9ff32d20cbfb9a..f107b5b9736c6418d12a896f8628fd4c24d8c909 100644 --- a/nfapi/open-nFAPI/nfapi/public_inc/fapi_nr_ue_constants.h +++ b/nfapi/open-nFAPI/nfapi/public_inc/fapi_nr_ue_constants.h @@ -57,6 +57,7 @@ /// UL_CONFIG_REQ #define FAPI_NR_UL_CONFIG_LIST_NUM 10 +#define FAPI_NR_UL_CONFIG_TYPE_DONE 0x00 #define FAPI_NR_UL_CONFIG_TYPE_PRACH 0x01 #define FAPI_NR_UL_CONFIG_TYPE_PUCCH 0x02 #define FAPI_NR_UL_CONFIG_TYPE_PUSCH 0x03 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 0e923931ad4163fd8e4d3f26f31a1ff9d248da4d..3b429a5e84e30edd094246b44bf2b65b5e15fff7 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 @@ -118,11 +118,18 @@ typedef struct { short rsrp_dBm; } fapi_nr_ssb_pdu_t; +typedef struct { + uint32_t pdu_length; + uint8_t* pdu; + uint32_t sibs_mask; +} fapi_nr_sib_pdu_t; + typedef struct { uint8_t pdu_type; union { fapi_nr_pdsch_pdu_t pdsch_pdu; fapi_nr_ssb_pdu_t ssb_pdu; + fapi_nr_sib_pdu_t sib_pdu; }; } fapi_nr_rx_indication_body_t; @@ -332,7 +339,33 @@ typedef struct } nfapi_nr_ue_pusch_pdu_t; typedef struct { +} fapi_nr_ul_srs_parms_v4; +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_ue_ul_beamforming_t beamforming; } fapi_nr_ul_config_srs_pdu; typedef struct { @@ -341,11 +374,13 @@ typedef struct { fapi_nr_ul_config_prach_pdu prach_config_pdu; fapi_nr_ul_config_pucch_pdu pucch_config_pdu; nfapi_nr_ue_pusch_pdu_t pusch_config_pdu; - fapi_nr_ul_config_srs_pdu srs_config_pdu; + fapi_nr_ul_config_srs_pdu srs_config_pdu; }; } fapi_nr_ul_config_request_pdu_t; typedef struct { + //uint16_t sfn; + //uint16_t slot; uint16_t sfn; uint16_t slot; uint8_t number_pdus; @@ -403,8 +438,11 @@ typedef struct { uint8_t tb2_rv; uint8_t harq_process_nbr; vrb_to_prb_mapping_t vrb_to_prb_mapping; + uint8_t dai; double scaling_factor_S; int8_t accumulated_delta_PUCCH; + uint8_t pucch_resource_id; + uint8_t pdsch_to_harq_feedback_time_ind; uint8_t n_dmrs_cdm_groups; uint8_t dmrs_ports[10]; uint8_t n_front_load_symb; @@ -451,6 +489,437 @@ typedef struct { } fapi_nr_dl_config_request_t; +// +// P5 +// + + + +typedef struct { + fapi_nr_coreset_t coreset; + + uint8_t monitoring_slot_peridicity; + uint8_t monitoring_slot_offset; + uint16_t duration; + uint16_t monitoring_symbols_within_slot; + uint8_t number_of_candidates[5]; // aggregation level 1, 2, 4, 8, 16 + + uint8_t dci_2_0_number_of_candidates[5]; // aggregation level 1, 2, 4, 8, 16 + uint8_t dci_2_3_monitorying_periodicity; + uint8_t dci_2_3_number_of_candidates; + +} fapi_nr_search_space_t; + +typedef struct { + fapi_nr_search_space_t search_space_sib1; + fapi_nr_search_space_t search_space_others_sib; + fapi_nr_search_space_t search_space_paging; + //fapi_nr_coreset_t coreset_ra; // common coreset + fapi_nr_search_space_t search_space_ra; +} fapi_nr_pdcch_config_common_t; + +typedef struct { + uint8_t k0; + uint8_t mapping_type; + uint8_t symbol_starting; + uint8_t symbol_length; +} fapi_nr_pdsch_time_domain_resource_allocation_t; + +typedef struct { + fapi_nr_pdsch_time_domain_resource_allocation_t allocation_list[FAPI_NR_MAX_NUM_DL_ALLOCATIONS]; +} fapi_nr_pdsch_config_common_t; + +typedef struct { + uint8_t prach_configuration_index; + uint8_t msg1_fdm; + uint8_t msg1_frequency_start; + uint8_t zero_correlation_zone_config; + uint8_t preamble_received_target_power; + uint8_t preamble_transmission_max; + uint8_t power_ramping_step; + uint8_t ra_window_size; + + uint8_t total_number_of_preamble; + uint8_t ssb_occasion_per_rach; + uint8_t cb_preamble_per_ssb; + + uint8_t group_a_msg3_size; + uint8_t group_a_number_of_preamble; + uint8_t group_b_power_offset; + uint8_t contention_resolution_timer; + uint8_t rsrp_threshold_ssb; + uint8_t rsrp_threshold_ssb_sul; + uint8_t prach_length; // l839, l139 + uint8_t prach_root_sequence_index; // 0 - 837 for l839, 0 - 137 for l139 + uint8_t msg1_subcarrier_spacing; + uint8_t restrictedset_config; + uint8_t msg3_transform_precoding; +} fapi_nr_rach_config_common_t; + +typedef struct { + uint8_t k2; + uint8_t mapping_type; + uint8_t symbol_starting; + uint8_t symbol_length; +} fapi_nr_pusch_time_domain_resource_allocation_t; + +typedef struct { + uint8_t group_hopping_enabled_transform_precoding; + fapi_nr_pusch_time_domain_resource_allocation_t allocation_list[FAPI_NR_MAX_NUM_UL_ALLOCATIONS]; + uint8_t msg3_delta_preamble; + uint8_t p0_nominal_with_grant; +} fapi_nr_pusch_config_common_t; + +typedef struct { + uint8_t pucch_resource_common; + uint8_t pucch_group_hopping; + uint8_t hopping_id; + uint8_t p0_nominal; +} fapi_nr_pucch_config_common_t; + +typedef struct { + + fapi_nr_pdcch_config_common_t pdcch_config_common; + fapi_nr_pdsch_config_common_t pdsch_config_common; + +} fapi_nr_dl_bwp_common_config_t; + + + +typedef struct { + uint16_t int_rnti; + uint8_t time_frequency_set; + uint8_t dci_payload_size; + uint8_t serving_cell_id[FAPI_NR_MAX_NUM_SERVING_CELLS]; // interrupt configuration per serving cell + uint8_t position_in_dci[FAPI_NR_MAX_NUM_SERVING_CELLS]; // interrupt configuration per serving cell +} fapi_nr_downlink_preemption_t; + +typedef struct { + uint8_t tpc_index; + uint8_t tpc_index_sul; + uint8_t target_cell; +} fapi_nr_pusch_tpc_command_config_t; + +typedef struct { + uint8_t tpc_index_pcell; + uint8_t tpc_index_pucch_scell; +} fapi_nr_pucch_tpc_command_config_t; + +typedef struct { + uint8_t starting_bit_of_format_2_3; + uint8_t feild_type_format_2_3; +} fapi_nr_srs_tpc_command_config_t; + +typedef struct { + fapi_nr_downlink_preemption_t downlink_preemption; + fapi_nr_pusch_tpc_command_config_t tpc_pusch; + fapi_nr_pucch_tpc_command_config_t tpc_pucch; + fapi_nr_srs_tpc_command_config_t tpc_srs; +} fapi_nr_pdcch_config_dedicated_t; + +typedef struct { + uint8_t dmrs_type; + uint8_t dmrs_addition_position; + uint8_t max_length; + uint16_t scrambling_id0; + uint16_t scrambling_id1; + uint8_t ptrs_frequency_density[2]; // phase tracking rs + uint8_t ptrs_time_density[3]; // phase tracking rs + uint8_t ptrs_epre_ratio; // phase tracking rs + uint8_t ptrs_resource_element_offset; // phase tracking rs +} fapi_nr_dmrs_downlink_config_t; + +typedef struct { + uint8_t bwp_or_cell_level; + uint8_t pattern_type; + uint32_t resource_blocks[9]; // bitmaps type 275 bits + uint8_t slot_type; // bitmaps type one/two slot(s) + uint32_t symbols_in_resouece_block; // bitmaps type 14/28 bits + uint8_t periodic; // bitmaps type + uint32_t pattern[2]; // bitmaps type 2/4/5/8/10/20/40 bits + + fapi_nr_coreset_t coreset; // coreset + + uint8_t subcarrier_spacing; + uint8_t mode; +} fapi_nr_rate_matching_pattern_group_t; + +typedef struct { + // resource mapping + uint8_t row; // row1/row2/row4/other + uint16_t frequency_domain_allocation; // 4/12/3/6 bits + uint8_t number_of_ports; + uint8_t first_ofdm_symbol_in_time_domain; + uint8_t first_ofdm_symbol_in_time_domain2; + uint8_t cdm_type; + uint8_t density; // .5/1/3 + uint8_t density_dot5_type; // even/odd PRBs + + uint8_t frequency_band_starting_rb; // freqBand + uint8_t frequency_band_number_of_rb; // freqBand + + // periodicityAndOffset + uint8_t periodicity; // slot4/5/8/10/16/20/32/40/64/80/160/320/640 + uint32_t offset; // 0..639 bits +} fapi_nr_zp_csi_rs_resource_t; + +typedef struct { + uint16_t data_scrambling_id_pdsch; + fapi_nr_dmrs_downlink_config_t dmrs_dl_for_pdsch_mapping_type_a; + fapi_nr_dmrs_downlink_config_t dmrs_dl_for_pdsch_mapping_type_b; + uint8_t vrb_to_prb_interleaver; + uint8_t resource_allocation; + fapi_nr_pdsch_time_domain_resource_allocation_t allocation_list[FAPI_NR_MAX_NUM_DL_ALLOCATIONS]; + uint8_t pdsch_aggregation_factor; + fapi_nr_rate_matching_pattern_group_t rate_matching_pattern_group1; + fapi_nr_rate_matching_pattern_group_t rate_matching_pattern_group2; + uint8_t rbg_size; + uint8_t mcs_table; + uint8_t max_num_of_code_word_scheduled_by_dci; + uint8_t bundle_size; // prb_bundling static + uint8_t bundle_size_set1; // prb_bundling dynamic + uint8_t bundle_size_set2; // prb_bundling dynamic + fapi_nr_zp_csi_rs_resource_t periodically_zp_csi_rs_resource_set[FAPI_NR_MAX_NUM_ZP_CSI_RS_RESOURCE_PER_SET]; +} fapi_nr_pdsch_config_dedicated_t; + +typedef struct { + uint16_t starting_prb; + uint8_t intra_slot_frequency_hopping; + uint16_t second_hop_prb; + uint8_t format; // pucch format 0..4 + uint8_t initial_cyclic_shift; + uint8_t number_of_symbols; + uint8_t starting_symbol_index; + uint8_t time_domain_occ; + uint8_t number_of_prbs; + uint8_t occ_length; + uint8_t occ_index; +} fapi_nr_pucch_resource_t; + +typedef struct { + uint8_t periodicity; + uint8_t number_of_harq_process; + fapi_nr_pucch_resource_t n1_pucch_an; +} fapi_nr_sps_config_t; + +typedef struct { + uint8_t beam_failure_instance_max_count; + uint8_t beam_failure_detection_timer; +} fapi_nr_radio_link_monitoring_config_t; + +typedef struct { + fapi_nr_pdcch_config_dedicated_t pdcch_config_dedicated; + fapi_nr_pdsch_config_dedicated_t pdsch_config_dedicated; + fapi_nr_sps_config_t sps_config; + fapi_nr_radio_link_monitoring_config_t radio_link_monitoring_config; + +} fapi_nr_dl_bwp_dedicated_config_t; + +typedef struct { + fapi_nr_rach_config_common_t rach_config_common; + fapi_nr_pusch_config_common_t pusch_config_common; + fapi_nr_pucch_config_common_t pucch_config_common; + +} fapi_nr_ul_bwp_common_config_t; + +typedef struct { + uint8_t inter_slot_frequency_hopping; + uint8_t additional_dmrs; + uint8_t max_code_rate; + uint8_t number_of_slots; + uint8_t pi2bpsk; + uint8_t simultaneous_harq_ack_csi; +} fapi_nr_pucch_format_config_t; + +typedef struct { + fapi_nr_pucch_format_config_t format1; + fapi_nr_pucch_format_config_t format2; + fapi_nr_pucch_format_config_t format3; + fapi_nr_pucch_format_config_t format4; + fapi_nr_pucch_resource_t multi_csi_pucch_resources[2]; + uint8_t dl_data_to_ul_ack[8]; + // pucch power control + uint8_t deltaF_pucch_f0; + uint8_t deltaF_pucch_f1; + uint8_t deltaF_pucch_f2; + uint8_t deltaF_pucch_f3; + uint8_t deltaF_pucch_f4; + uint8_t two_pucch_pc_adjusment_states; +} fapi_nr_pucch_config_dedicated_t; + +typedef struct { + uint8_t dmrs_type; + uint8_t dmrs_addition_position; + uint8_t ptrs_uplink_config; // to indicate if PTRS Uplink is configured of not + uint8_t ptrs_type; //cp-OFDM, dft-S-OFDM + uint16_t ptrs_frequency_density[2]; + uint8_t ptrs_time_density[3]; + uint8_t ptrs_max_number_of_ports; + uint8_t ptrs_resource_element_offset; + uint8_t ptrs_power; + uint16_t ptrs_sample_density[5]; + uint8_t ptrs_time_density_transform_precoding; + + uint8_t max_length; + uint16_t scrambling_id0; + uint16_t scrambling_id1; + uint8_t npusch_identity; + uint8_t disable_sequence_group_hopping; + uint8_t sequence_hopping_enable; +} fapi_nr_dmrs_uplink_config_t; + +typedef struct { + uint8_t tpc_accmulation; + uint8_t msg3_alpha; + uint8_t p0_nominal_with_grant; + uint8_t two_pusch_pc_adjustments_states; + uint8_t delta_mcs; +} fapi_nr_pusch_power_control_t; + +typedef enum {tx_config_codebook = 1, tx_config_nonCodebook = 2} tx_config_t; +typedef enum {transform_precoder_enabled = 0, transform_precoder_disabled = 1} transform_precoder_t; +typedef enum { + codebook_subset_fullyAndPartialAndNonCoherent = 1, + codebook_subset_partialAndNonCoherent = 2, + codebook_subset_nonCoherent = 3} codebook_subset_t; +typedef struct { + uint16_t data_scrambling_identity; + tx_config_t tx_config; + fapi_nr_dmrs_uplink_config_t dmrs_ul_for_pusch_mapping_type_a; + fapi_nr_dmrs_uplink_config_t dmrs_ul_for_pusch_mapping_type_b; + fapi_nr_pusch_power_control_t pusch_power_control; + uint8_t frequency_hopping; + uint16_t frequency_hopping_offset_lists[4]; + uint8_t resource_allocation; + fapi_nr_pusch_time_domain_resource_allocation_t allocation_list[FAPI_NR_MAX_NUM_UL_ALLOCATIONS]; + uint8_t pusch_aggregation_factor; + uint8_t mcs_table; + uint8_t mcs_table_transform_precoder; + transform_precoder_t transform_precoder; + codebook_subset_t codebook_subset; + uint8_t max_rank; + uint8_t rbg_size; + + //uci-OnPUSCH + uint8_t uci_on_pusch_type; //dynamic, semi-static + uint8_t beta_offset_ack_index1[4]; + uint8_t beta_offset_ack_index2[4]; + uint8_t beta_offset_ack_index3[4]; + uint8_t beta_offset_csi_part1_index1[4]; + uint8_t beta_offset_csi_part1_index2[4]; + uint8_t beta_offset_csi_part2_index1[4]; + uint8_t beta_offset_csi_part2_index2[4]; + + uint8_t tp_pi2BPSK; +} fapi_nr_pusch_config_dedicated_t; + +typedef struct { + uint8_t frequency_hopping; + fapi_nr_dmrs_uplink_config_t cg_dmrs_configuration; + uint8_t mcs_table; + uint8_t mcs_table_transform_precoder; + + //uci-OnPUSCH + uint8_t uci_on_pusch_type; //dynamic, semi-static + uint8_t beta_offset_ack_index1[4]; + uint8_t beta_offset_ack_index2[4]; + uint8_t beta_offset_ack_index3[4]; + uint8_t beta_offset_csi_part1_index1[4]; + uint8_t beta_offset_csi_part1_index2[4]; + uint8_t beta_offset_csi_part2_index1[4]; + uint8_t beta_offset_csi_part2_index2[4]; + + uint8_t resource_allocation; + // rgb-Size structure missing in spec. + uint8_t power_control_loop_to_use; + // p0-PUSCH-Alpha + uint8_t p0; + uint8_t alpha; + + uint8_t transform_precoder; + uint8_t number_of_harq_process; + uint8_t rep_k; + uint8_t rep_k_rv; + uint8_t periodicity; + uint8_t configured_grant_timer; + // rrc-ConfiguredUplinkGrant + uint16_t time_domain_offset; + uint8_t time_domain_allocation; + uint32_t frequency_domain_allocation; + uint8_t antenna_ports; + uint8_t dmrs_seq_initialization; + uint8_t precoding_and_number_of_layers; + uint8_t srs_resource_indicator; + uint8_t mcs_and_tbs; + uint8_t frequency_hopping_offset; + uint8_t path_loss_reference_index; + +} fapi_nr_configured_grant_config_t; + +typedef struct { + uint8_t qcl_type1_serving_cell_index; + uint8_t qcl_type1_bwp_id; + uint8_t qcl_type1_rs_type; // csi-rs or ssb + uint8_t qcl_type1_nzp_csi_rs_resource_id; + uint8_t qcl_type1_ssb_index; + uint8_t qcl_type1_type; + + uint8_t qcl_type2_serving_cell_index; + uint8_t qcl_type2_bwp_id; + uint8_t qcl_type2_rs_type; // csi-rs or ssb + uint8_t qcl_type2_nzp_csi_rs_resource_id; + uint8_t qcl_type2_ssb_index; + uint8_t qcl_type2_type; + +} fapi_nr_tci_state_t; + +typedef struct { + uint8_t root_sequence_index; + // rach genertic + uint8_t prach_configuration_index; + uint8_t msg1_fdm; + uint8_t msg1_frequency_start; + uint8_t zero_correlation_zone_config; + uint8_t preamble_received_target_power; + uint8_t preamble_transmission_max; + uint8_t power_ramping_step; + uint8_t ra_window_size; + + uint8_t rsrp_threshold_ssb; + // PRACH-ResourceDedicatedBFR + uint8_t bfr_ssb_index[FAPI_NR_MAX_NUM_CANDIDATE_BEAMS]; + uint8_t bfr_ssb_ra_preamble_index[FAPI_NR_MAX_NUM_CANDIDATE_BEAMS]; + // NZP-CSI-RS-Resource + uint8_t bfr_csi_rs_nzp_resource_mapping[FAPI_NR_MAX_NUM_CANDIDATE_BEAMS]; + uint8_t bfr_csi_rs_power_control_offset[FAPI_NR_MAX_NUM_CANDIDATE_BEAMS]; + uint8_t bfr_csi_rs_power_control_offset_ss[FAPI_NR_MAX_NUM_CANDIDATE_BEAMS]; + uint16_t bfr_csi_rs_scrambling_id[FAPI_NR_MAX_NUM_CANDIDATE_BEAMS]; + uint8_t bfr_csi_rs_resource_periodicity[FAPI_NR_MAX_NUM_CANDIDATE_BEAMS]; + uint16_t bfr_csi_rs_resource_offset[FAPI_NR_MAX_NUM_CANDIDATE_BEAMS]; + fapi_nr_tci_state_t qcl_infomation_periodic_csi_rs[FAPI_NR_MAX_NUM_CANDIDATE_BEAMS]; + + uint8_t bfr_csirs_ra_occasions[FAPI_NR_MAX_NUM_CANDIDATE_BEAMS]; + uint8_t bfr_csirs_ra_preamble_index[FAPI_NR_MAX_NUM_CANDIDATE_BEAMS][FAPI_NR_MAX_RA_OCCASION_PER_CSIRS]; + + uint8_t ssb_per_rach_occasion; + uint8_t ra_ssb_occasion_mask_index; + fapi_nr_search_space_t recovery_search_space; + // RA-Prioritization + uint8_t power_ramping_step_high_priority; + uint8_t scaling_factor_bi; + uint8_t beam_failure_recovery_timer; +} fapi_nr_beam_failure_recovery_config_t; + +typedef struct { + fapi_nr_pucch_config_dedicated_t pucch_config_dedicated; + fapi_nr_pusch_config_dedicated_t pusch_config_dedicated; + fapi_nr_configured_grant_config_t configured_grant_config; + // SRS-Config + uint8_t srs_tpc_accumulation; + fapi_nr_beam_failure_recovery_config_t beam_failure_recovery_config; + +} fapi_nr_ul_bwp_dedicated_config_t; + #define FAPI_NR_CONFIG_REQUEST_MASK_PBCH 0x01 #define FAPI_NR_CONFIG_REQUEST_MASK_DL_BWP_COMMON 0x02 #define FAPI_NR_CONFIG_REQUEST_MASK_UL_BWP_COMMON 0x04 diff --git a/nfapi/open-nFAPI/nfapi/public_inc/nfapi_interface.h b/nfapi/open-nFAPI/nfapi/public_inc/nfapi_interface.h index ea459138e1e00aff374b50d0081ff07e9d476132..e1cfc2633607f4a8c95b81c4a469aa878bcd0b41 100644 --- a/nfapi/open-nFAPI/nfapi/public_inc/nfapi_interface.h +++ b/nfapi/open-nFAPI/nfapi/public_inc/nfapi_interface.h @@ -27,6 +27,8 @@ #define NFAPI_PNF_PARAM_GENERAL_OUI_LENGTH 3 #define NFAPI_MAX_NUM_RF_BANDS 16 +#define NFAPI_MAX_PACKED_MESSAGE_SIZE 8192 + // The following definition control the size of arrays used in the interface. // These may be changed if desired. They are used in the encoder to make sure // that the user has not specified a 'count' larger than the max array, and also @@ -122,12 +124,13 @@ typedef struct { // Convenience methods to convert between SFN/SLOT formats #define NFAPI_SFNSLOT2DEC(_sfn,_slot) ( _sfn*20 + _slot ) // total count of slots -#define NFAPI_SFNSLOTDEC2SFNSLOT(_sfnslot_dec) ((((_sfnslot_dec) / 20) << 4) | (((_sfnslot_dec) - (((_sfnslot_dec) / 20) * 10)) & 0x3F)) +#define NFAPI_SFNSLOTDEC2SFNSLOT(_sfnslot_dec) ((((_sfnslot_dec) / 20) << 6) | (((_sfnslot_dec) - (((_sfnslot_dec) / 20) * 20)) & 0x3F)) #define NFAPI_SFNSLOT2SFN(_sfnslot) ((_sfnslot) >> 6) #define NFAPI_SFNSLOT2SLOT(_sfnslot) ((_sfnslot) & 0x3F) #define NFAPI_SFNSLOTDEC2SFN(_sfnslot_dec) ((_sfnslot_dec) / 20) #define NFAPI_SFNSLOTDEC2SLOT(_sfnslot_dec) ((_sfnslot_dec) % 20) +#define NFAPI_SFNSLOT2HEX(_sfn,_slot) ((_sfn << 6) | (_slot & 0x3F)) #define NFAPI_MAX_SFNSLOTDEC 1024*20 // 20 is for numerology 1 @@ -706,7 +709,6 @@ typedef struct { #define NFAPI_PHICH_CONFIG_PHICH_DURATION_TAG 0x0015 #define NFAPI_PHICH_CONFIG_PHICH_POWER_OFFSET_TAG 0x0016 - typedef struct { nfapi_uint16_tlv_t primary_synchronization_signal_epre_eprers; nfapi_uint16_tlv_t secondary_synchronization_signal_epre_eprers; @@ -2497,7 +2499,7 @@ typedef struct { typedef struct { nfapi_p7_message_header_t header; uint32_t t1; - int32_t delta_sfn_sf; + int32_t delta_sfn_sf; nfapi_vendor_extension_tlv_t vendor_extension; } nfapi_dl_node_sync_t; @@ -2872,11 +2874,12 @@ typedef struct { } nfapi_rx_indication_rel9_t; #define NFAPI_RX_INDICATION_REL9_TAG 0x2025 +#define NFAPI_RX_IND_DATA_MAX 8192 typedef struct { nfapi_rx_ue_information rx_ue_information; nfapi_rx_indication_rel8_t rx_indication_rel8; nfapi_rx_indication_rel9_t rx_indication_rel9; - uint8_t* data; + uint8_t rx_ind_data[NFAPI_RX_IND_DATA_MAX]; } nfapi_rx_indication_pdu_t; #define NFAPI_RX_IND_MAX_PDU 100 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 9d245446c86d00283f5ce6f678aeac630ce1e8bd..c3a173758cc30cceb688775293039799780b6604 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 @@ -984,6 +984,8 @@ typedef struct { /// A value indicating how the BCH payload is generated. This should match the PARAM/CONFIG TLVs. Value: 0: MAC generates the full PBCH payload, see Table 3-41, where bchPayload has 31 bits 1: PHY generates the timing PBCH bits, see Table 3-41, where the bchPayload has 24 bits 2: PHY generates the full PBCH payload uint8_t bchPayloadFlag; uint32_t bchPayload; + /// A value indicating the channel quality between the gNB and nrUE. Value: 0->255 dBM + uint8_t ssbRsrp; nfapi_nr_tx_precoding_and_beamforming_t precoding_and_beamforming; } nfapi_nr_dl_tti_ssb_pdu_rel15_t; @@ -1310,7 +1312,7 @@ typedef struct 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; - uint8_t frequency_shift; + 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 @@ -1400,9 +1402,6 @@ typedef struct } nfapi_nr_ul_dci_request_t; */ - // normally one PDU per coreset per BWP -#define NFAPI_NR_MAX_UL_DCI_PDUS 4 - typedef struct { /// only possible value 0: PDCCH PDU uint16_t PDUType; @@ -1416,7 +1415,7 @@ typedef struct { uint16_t SFN; uint16_t Slot; uint8_t numPdus; - nfapi_nr_ul_dci_request_pdus_t ul_dci_pdu_list[NFAPI_NR_MAX_UL_DCI_PDUS]; + nfapi_nr_ul_dci_request_pdus_t ul_dci_pdu_list[NFAPI_NR_MAX_NB_CORESETS]; } nfapi_nr_ul_dci_request_t; //3.4.5 slot_errors @@ -1476,7 +1475,7 @@ typedef enum { //section 3.4.7 rx_data_indication //table 3-61 - +#define NFAPI_NR_RX_DATA_IND_MAX_PDU 100 typedef struct { uint32_t handle; @@ -1497,12 +1496,13 @@ typedef struct uint16_t sfn; uint16_t slot; uint16_t number_of_pdus; - nfapi_nr_rx_data_pdu_t *pdu_list; + nfapi_nr_rx_data_pdu_t *pdu_list; } nfapi_nr_rx_data_indication_t; //3.4.8 crc_indication //table 3-62 +#define NFAPI_NR_CRC_IND_MAX_PDU 100 typedef struct { uint32_t handle; @@ -1642,6 +1642,7 @@ typedef enum { NFAPI_NR_UCI_FORMAT_2_3_4_PDU_TYPE = 2, } nfapi_nr_uci_pdu_type_e; +#define NFAPI_NR_UCI_IND_MAX_PDU 100 typedef struct { uint16_t pdu_type; // 0 for PDU on PUSCH, 1 for PUCCH format 0 or 1, 2 for PUCCH format 2 to 4 @@ -1678,7 +1679,7 @@ typedef struct nfapi_nr_srs_indication_reported_symbol_resource_block_t* rb_list; }nfapi_nr_srs_indication_reported_symbol_t; - +#define NFAPI_NR_SRS_IND_MAX_PDU 100 typedef struct { uint32_t handle; diff --git a/nfapi/open-nFAPI/nfapi/src/nfapi.c b/nfapi/open-nFAPI/nfapi/src/nfapi.c index 63dd8a16ae81489f3fd655ec469766a23461651d..2783781e2c39b9ceb46d00df2609bb087b453194 100644 --- a/nfapi/open-nFAPI/nfapi/src/nfapi.c +++ b/nfapi/open-nFAPI/nfapi/src/nfapi.c @@ -1,783 +1,783 @@ -/* - * Copyright (c) 2001-2016, Cisco Systems, Inc. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * - * Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following - * disclaimer in the documentation and/or other materials provided - * with the distribution. - * - * Neither the name of the Cisco Systems, Inc. nor the names of its - * contributors may be used to endorse or promote products derived - * from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS - * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE - * COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, - * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES - * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR - * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, - * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED - * OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -#include <signal.h> -#include <sys/time.h> -#include <sys/socket.h> -#include <sys/types.h> -#include <netinet/in.h> -#include <arpa/inet.h> -#include <sched.h> -#include <time.h> -#include <stdio.h> -#include <stdlib.h> -#include <string.h> -#include <unistd.h> -#include <errno.h> -#include <pthread.h> - -#include <nfapi_interface.h> -#include <nfapi.h> -#include <debug.h> - - -// Fundamental routines - -uint8_t push8(uint8_t in, uint8_t **out, uint8_t *end) { - uint8_t *pOut = *out; - - if((end - pOut) >= 1) { - pOut[0] = in; - (*out)+=1; - return 1; - } else { - NFAPI_TRACE(NFAPI_TRACE_ERROR, "%s no space in buffer\n", __FUNCTION__); - return 0; - } -} - -uint8_t pushs8(int8_t in, uint8_t **out, uint8_t *end) { - uint8_t *pOut = *out; - - if((end - pOut) >= 1) { - pOut[0] = in; - (*out)+=1; - return 1; - } else { - NFAPI_TRACE(NFAPI_TRACE_ERROR, "%s no space in buffer\n", __FUNCTION__); - return 0; - } -} - -uint8_t push16(uint16_t in, uint8_t **out, uint8_t *end) { - uint8_t *pOut = *out; - - if((end - pOut) >= 2) { - pOut[0] = (in & 0xFF00) >> 8; - pOut[1] = (in & 0xFF); - (*out)+=2; - return 2; - } else { - NFAPI_TRACE(NFAPI_TRACE_ERROR, "%s no space in buffer\n", __FUNCTION__); - return 0; - } -} - -uint8_t pushs16(int16_t in, uint8_t **out, uint8_t *end) { - uint8_t *pOut = *out; - - if((end - pOut) >= 2) { - pOut[0] = (in & 0xFF00) >> 8; - pOut[1] = (in & 0xFF); - (*out)+=2; - return 2; - } else { - NFAPI_TRACE(NFAPI_TRACE_ERROR, "%s no space in buffer\n", __FUNCTION__); - return 0; - } -} - -uint8_t push32(uint32_t in, uint8_t **out, uint8_t *end) { - uint8_t *pOut = *out; - - if((end - pOut) >= 4) { - pOut[0] = (in & 0xFF000000) >> 24; - pOut[1] = (in & 0xFF0000) >> 16; - pOut[2] = (in & 0xFF00) >> 8; - pOut[3] = (in & 0xFF); - (*out)+=4; - return 4; - } else { - NFAPI_TRACE(NFAPI_TRACE_ERROR, "%s no space in buffer\n", __FUNCTION__); - return 0; - } -} - -uint8_t pushs32(int32_t in, uint8_t **out, uint8_t *end) { - uint8_t *pOut = *out; - - if((end - pOut) >= 4) { - pOut[0] = (in & 0xFF000000) >> 24; - pOut[1] = (in & 0xFF0000) >> 16; - pOut[2] = (in & 0xFF00) >> 8; - pOut[3] = (in & 0xFF); - (*out)+=4; - return 4; - } else { - NFAPI_TRACE(NFAPI_TRACE_ERROR, "%s no space in buffer\n", __FUNCTION__); - return 0; - } -} - -uint8_t pull8(uint8_t **in, uint8_t *out, uint8_t *end) { - uint8_t *pIn = *in; - - if((end - pIn) >= 1 ) { - *out = *pIn; - (*in)+=1; - return 1; - } else { - NFAPI_TRACE(NFAPI_TRACE_ERROR, "%s no space in buffer\n", __FUNCTION__); - return 0; - } -} - -uint8_t pulls8(uint8_t **in, int8_t *out, uint8_t *end) { - uint8_t *pIn = *in; - - if((end - pIn) >= 1 ) { - *out = *pIn; - (*in)+=1; - return 1; - } else { - NFAPI_TRACE(NFAPI_TRACE_ERROR, "%s no space in buffer\n", __FUNCTION__); - return 0; - } -} - -uint8_t pull16(uint8_t **in, uint16_t *out, uint8_t *end) { - uint8_t *pIn = *in; - - if((end - pIn) >=2 ) { - *out = ((pIn[0]) << 8) | pIn[1]; - (*in)+=2; - return 2; - } else { - NFAPI_TRACE(NFAPI_TRACE_ERROR, "%s no space in buffer\n", __FUNCTION__); - return 0; - } -} - -uint8_t pulls16(uint8_t **in, int16_t *out, uint8_t *end) { - uint8_t *pIn = *in; - - if((end - pIn) >=2 ) { - *out = ((pIn[0]) << 8) | pIn[1]; - (*in)+=2; - return 2; - } else { - NFAPI_TRACE(NFAPI_TRACE_ERROR, "%s no space in buffer\n", __FUNCTION__); - return 0; - } -} - -uint8_t pull32(uint8_t **in, uint32_t *out, uint8_t *end) { - uint8_t *pIn = *in; - - if((end - pIn) >=4 ) { - *out = (pIn[0] << 24) | (pIn[1] << 16) | (pIn[2] << 8) | pIn[3]; - (*in)+=4; - return 4; - } else { - NFAPI_TRACE(NFAPI_TRACE_ERROR, "%s no space in buffer\n", __FUNCTION__); - return 0; - } -} - -uint8_t pulls32(uint8_t **in, int32_t *out, uint8_t *end) { - uint8_t *pIn = *in; - - if((end - pIn) >=4 ) { - *out = (pIn[0] << 24) | (pIn[1] << 16) | (pIn[2] << 8) | pIn[3]; - (*in)+=4; - return 4; - } else { - NFAPI_TRACE(NFAPI_TRACE_ERROR, "%s no space in buffer\n", __FUNCTION__); - return 0; - } -} - -/* -inline void pusharray16(uint8_t **, uint16_t, uint32_t len) -{ -} -*/ - -uint32_t pullarray16(uint8_t **in, uint16_t out[], uint32_t max_len, uint32_t len, uint8_t *end) { - if(len == 0) - return 1; - - if(len > max_len) { - NFAPI_TRACE(NFAPI_TRACE_ERROR, "%s exceed array size (%d > %d)\n", __FUNCTION__, len, max_len); - return 0; - } - - if((end - (*in)) >= sizeof(uint16_t) * len) { - uint32_t idx; - - for(idx = 0; idx < len; ++idx) { - if(!pull16(in, &out[idx], end)) - return 0; - } - - return sizeof(uint16_t) * len; - } else { - NFAPI_TRACE(NFAPI_TRACE_ERROR, "%s no space in buffer\n", __FUNCTION__); - return 0; - } -} - -uint32_t pullarrays16(uint8_t **in, int16_t out[], uint32_t max_len, uint32_t len, uint8_t *end) { - if(len == 0) - return 1; - - if(len > max_len) { - NFAPI_TRACE(NFAPI_TRACE_ERROR, "%s exceed array size (%d > %d)\n", __FUNCTION__, len, max_len); - return 0; - } - - if((end - (*in)) >= sizeof(uint16_t) * len) { - uint32_t idx; - - for(idx = 0; idx < len; ++idx) { - if(!pulls16(in, &out[idx], end)) - return 0; - } - - return sizeof(uint16_t) * len; - } else { - NFAPI_TRACE(NFAPI_TRACE_ERROR, "%s no space in buffer\n", __FUNCTION__); - return 0; - } -} -uint32_t pusharray16(uint16_t in[], uint32_t max_len, uint32_t len, uint8_t **out, uint8_t *end) { - if(len == 0) - return 1; - - if(len > max_len) { - NFAPI_TRACE(NFAPI_TRACE_ERROR, "%s exceed array size (%d > %d)\n", __FUNCTION__, len, max_len); - return 0; - } - - if((end - (*out)) >= sizeof(uint16_t) * len) { - uint32_t idx; - - for(idx = 0; idx < len; ++idx) { - if(!push16(in[idx], out, end)) - return 0; - } - - return sizeof(uint16_t) * len; - } else { - NFAPI_TRACE(NFAPI_TRACE_ERROR, "%s no space in buffer\n", __FUNCTION__); - return 0; - } -} -uint32_t pusharrays16(int16_t in[], uint32_t max_len, uint32_t len, uint8_t **out, uint8_t *end) { - if(len == 0) - return 1; - - if(len > max_len) { - NFAPI_TRACE(NFAPI_TRACE_ERROR, "%s exceed array size (%d > %d)\n", __FUNCTION__, len, max_len); - return 0; - } - - if((end - (*out)) >= sizeof(uint16_t) * len) { - uint32_t idx; - - for(idx = 0; idx < len; ++idx) { - pushs16(in[idx], out, end); - } - - return sizeof(uint16_t) * len; - } else { - NFAPI_TRACE(NFAPI_TRACE_ERROR, "%s no space in buffer\n", __FUNCTION__); - return 0; - } -} -uint32_t pullarray32(uint8_t **in, uint32_t out[], uint32_t max_len, uint32_t len, uint8_t *end) { - if(len == 0) - return 1; - - if(len > max_len) { - NFAPI_TRACE(NFAPI_TRACE_ERROR, "%s exceed array size (%d > %d)\n", __FUNCTION__, len, max_len); - return 0; - } - - if((end - (*in)) >= sizeof(uint32_t) * len) { - uint32_t idx; - - for(idx = 0; idx < len; ++idx) { - if(!pull32(in, &out[idx], end)) - return 0; - } - - return sizeof(uint32_t) * len; - } else { - NFAPI_TRACE(NFAPI_TRACE_ERROR, "%s no space in buffer\n", __FUNCTION__); - return 0; - } -} - -uint32_t pullarrays32(uint8_t **in, int32_t out[], uint32_t max_len, uint32_t len, uint8_t *end) { - if(len == 0) - return 1; - - if(len > max_len) { - NFAPI_TRACE(NFAPI_TRACE_ERROR, "%s exceed array size (%d > %d)\n", __FUNCTION__, len, max_len); - return 0; - } - - if((end - (*in)) >= sizeof(uint32_t) * len) { - uint32_t idx; - - for(idx = 0; idx < len; ++idx) { - if(!pulls32(in, &out[idx], end)) - return 0; - } - - return sizeof(uint32_t) * len; - } else { - NFAPI_TRACE(NFAPI_TRACE_ERROR, "%s no space in buffer\n", __FUNCTION__); - return 0; - } -} -uint32_t pusharray32(uint32_t in[], uint32_t max_len, uint32_t len, uint8_t **out, uint8_t *end) { - if(len == 0) - return 1; - - if(len > max_len) { - NFAPI_TRACE(NFAPI_TRACE_ERROR, "%s exceed array size (%d > %d)\n", __FUNCTION__, len, max_len); - return 0; - } - - if((end - (*out)) >= sizeof(uint32_t) * len) { - uint32_t idx; - - for(idx = 0; idx < len; ++idx) { - if(!push32(in[idx], out, end)) - return 0; - } - - return sizeof(uint32_t) * len; - } else { - NFAPI_TRACE(NFAPI_TRACE_ERROR, "%s no space in buffer\n", __FUNCTION__); - return 0; - } -} -uint32_t pusharrays32(int32_t in[], uint32_t max_len, uint32_t len, uint8_t **out, uint8_t *end) { - if(len == 0) - return 1; - - if(len > max_len) { - NFAPI_TRACE(NFAPI_TRACE_ERROR, "%s exceed array size (%d > %d)\n", __FUNCTION__, len, max_len); - return 0; - } - - if((end - (*out)) >= sizeof(uint32_t) * len) { - uint32_t idx; - - for(idx = 0; idx < len; ++idx) { - pushs32(in[idx], out, end); - } - - return sizeof(uint32_t) * len; - } else { - NFAPI_TRACE(NFAPI_TRACE_ERROR, "%s no space in buffer\n", __FUNCTION__); - return 0; - } -} -uint32_t pullarray8(uint8_t **in, uint8_t out[], uint32_t max_len, uint32_t len, uint8_t *end) { - if(len == 0) - return 1; - - if(len > max_len) { - NFAPI_TRACE(NFAPI_TRACE_ERROR, "%s exceed array size (%d > %d)\n", __FUNCTION__, len, max_len); - return 0; - } - - if((end - (*in)) >= sizeof(uint8_t) * len) { - memcpy(out, (*in), len); - (*in)+=len; - return sizeof(uint8_t) * len; - } else { - NFAPI_TRACE(NFAPI_TRACE_ERROR, "%s no space in buffer\n", __FUNCTION__); - return 0; - } -} - -uint32_t pusharray8(uint8_t in[], uint32_t max_len, uint32_t len, uint8_t **out, uint8_t *end) { - if(len == 0) - return 1; - - if(len > max_len) { - NFAPI_TRACE(NFAPI_TRACE_ERROR, "%s exceed array size (%d > %d)\n", __FUNCTION__, len, max_len); - return 0; - } - - if((end - (*out)) >= sizeof(uint8_t) * len) { - memcpy((*out), in, len); - (*out)+=len; - return sizeof(uint8_t) * len; - } else { - NFAPI_TRACE(NFAPI_TRACE_ERROR, "%s no space in buffer\n", __FUNCTION__); - return 0; - } -} - -uint8_t packarray(void *array, uint16_t array_element_size, uint16_t max_count, uint16_t count, uint8_t **ppwritepackedmsg, uint8_t *end, pack_array_elem_fn fn) { - if(count > max_count) { - NFAPI_TRACE(NFAPI_TRACE_ERROR, "%s exceed array size (%d > %d)\n", __FUNCTION__, count, max_count); - return 0; - } - - uint16_t i = 0; - - for(i = 0; i < count; ++i) { - if((fn)(array, ppwritepackedmsg, end) == 0) - return 0; - - array += array_element_size; - } - - return 1; -} - -uint8_t unpackarray(uint8_t **ppReadPackedMsg, void *array, uint16_t array_element_size, uint16_t max_count, uint16_t count, uint8_t *end, unpack_array_elem_fn fn) { - if(count > max_count) { - NFAPI_TRACE(NFAPI_TRACE_ERROR, "%s exceed array size (%d > %d)\n", __FUNCTION__, count, max_count); - return 0; - } - - uint16_t i = 0; - - for(i = 0; i < count; ++i) { - if((fn)(array, ppReadPackedMsg, end) == 0) - return 0; - - array += array_element_size; - } - - return 1; -} - - -uint32_t pack_vendor_extension_tlv(nfapi_tl_t *ve, uint8_t **ppWritePackedMsg, uint8_t *end, nfapi_p4_p5_codec_config_t *config) { - if(ve != 0 && config != 0) { - if(config->pack_vendor_extension_tlv) { - uint8_t *pStartOfTlv = *ppWritePackedMsg; - - if(pack_tl(ve, ppWritePackedMsg, end) == 0) - return 0; - - uint8_t *pStartOfValue = *ppWritePackedMsg; - - if((config->pack_vendor_extension_tlv)(ve, ppWritePackedMsg, end, config) == 0) - return 0; - - ve->length = (*ppWritePackedMsg) - pStartOfValue; - pack_tl(ve, &pStartOfTlv, end); - return 1; - } - } - - return 1; -} - -uint32_t unpack_vendor_extension_tlv(nfapi_tl_t *tl, uint8_t **ppReadPackedMsg, uint8_t *end, nfapi_p4_p5_codec_config_t *config, nfapi_tl_t **ve_tlv) { - if(ve_tlv != 0 && config != 0) { - if(config->unpack_vendor_extension_tlv) { - return (config->unpack_vendor_extension_tlv)(tl, ppReadPackedMsg, end, (void **)ve_tlv, config); - } - } - - return 1; -} - -uint32_t pack_p7_vendor_extension_tlv(nfapi_tl_t *ve, uint8_t **ppWritePackedMsg, uint8_t *end,nfapi_p7_codec_config_t *config) { - if(ve != 0 && config != 0) { - if(config->pack_vendor_extension_tlv) { - uint8_t *pStartOfTlv = *ppWritePackedMsg; - - if(pack_tl(ve, ppWritePackedMsg, end) == 0) - return 0; - - uint8_t *pStartOfValue = *ppWritePackedMsg; - - if((config->pack_vendor_extension_tlv)(ve, ppWritePackedMsg, end, config) == 0) - return 0; - - ve->length = (*ppWritePackedMsg) - pStartOfValue; - pack_tl(ve, &pStartOfTlv, end); - return 1; - } - } - - return 1; -} - -int unpack_p7_vendor_extension_tlv(nfapi_tl_t *tl, uint8_t **ppReadPackedMsg, uint8_t *end, nfapi_p7_codec_config_t *config, nfapi_tl_t **ve_tlv) { - if(ve_tlv != 0 && config != 0) { - if(config->unpack_vendor_extension_tlv) { - return (config->unpack_vendor_extension_tlv)(tl, ppReadPackedMsg, end, (void **)ve_tlv, config); - } - } - - return 1; -} - - -uint8_t pack_tl(nfapi_tl_t *tl, uint8_t **ppWritePackedMsg, uint8_t *end) { - return (push16(tl->tag, ppWritePackedMsg, end) && - push16(tl->length, ppWritePackedMsg, end)); -} - -uint8_t unpack_tl(uint8_t **ppReadPackedMsg, nfapi_tl_t *tl, uint8_t *end) { - return (pull16(ppReadPackedMsg, &tl->tag, end) && - pull16(ppReadPackedMsg, &tl->length, end)); -} - -int unpack_tlv_list(unpack_tlv_t unpack_fns[], uint16_t size, uint8_t **ppReadPackedMsg, uint8_t *end, nfapi_p4_p5_codec_config_t *config, nfapi_tl_t **ve) { - nfapi_tl_t generic_tl; - uint8_t numBadTags = 0; - uint16_t idx = 0; - - while ((uint8_t *)(*ppReadPackedMsg) < end) { - // unpack the tl and process the values accordingly - if(unpack_tl(ppReadPackedMsg, &generic_tl, end) == 0) - return 0; - - uint8_t tagMatch = 0; - uint8_t *pStartOfValue = *ppReadPackedMsg; - - for(idx = 0; idx < size; ++idx) { - if(unpack_fns[idx].tag == generic_tl.tag) { // match the extracted tag value with all the tags in unpack_fn list - tagMatch = 1; - nfapi_tl_t *tl = (nfapi_tl_t *)(unpack_fns[idx].tlv); - tl->tag = generic_tl.tag; - tl->length = generic_tl.length; - int result = (*unpack_fns[idx].unpack_func)(tl, ppReadPackedMsg, end); - - if(result == 0) { - return 0; - } - - // check if the length was right; - if(tl->length != (*ppReadPackedMsg - pStartOfValue)) { - NFAPI_TRACE(NFAPI_TRACE_ERROR, "Warning tlv tag 0x%x length %d not equal to unpack %d\n", tl->tag, tl->length, (*ppReadPackedMsg - pStartOfValue)); - } - } - } - - if(tagMatch == 0) { - if(generic_tl.tag >= NFAPI_VENDOR_EXTENSION_MIN_TAG_VALUE && - generic_tl.tag <= NFAPI_VENDOR_EXTENSION_MAX_TAG_VALUE) { - int result = unpack_vendor_extension_tlv(&generic_tl, ppReadPackedMsg, end, config, ve); - - if(result == 0) { - // got tot the end. - return 0; - } else if(result < 0) { - NFAPI_TRACE(NFAPI_TRACE_ERROR, "Unknown VE TAG value: 0x%04x\n", generic_tl.tag); - - if (++numBadTags > MAX_BAD_TAG) { - NFAPI_TRACE(NFAPI_TRACE_ERROR, "Supplied message has had too many bad tags\n"); - return 0; - } - - if((end - *ppReadPackedMsg) >= generic_tl.length) { - // Advance past the unknown TLV - (*ppReadPackedMsg) += generic_tl.length; - } else { - // go to the end - return 0; - } - } - } else { - NFAPI_TRACE(NFAPI_TRACE_ERROR, "Unknown TAG value: 0x%04x\n", generic_tl.tag); - - if (++numBadTags > MAX_BAD_TAG) { - NFAPI_TRACE(NFAPI_TRACE_ERROR, "Supplied message has had too many bad tags\n"); - return 0; - } - - if((end - *ppReadPackedMsg) >= generic_tl.length) { - // Advance past the unknown TLV - (*ppReadPackedMsg) += generic_tl.length; - } else { - // go to the end - return 0; - } - } - } - } - - return 1; -} -int unpack_p7_tlv_list(unpack_p7_tlv_t unpack_fns[], uint16_t size, uint8_t **ppReadPackedMsg, uint8_t *end, nfapi_p7_codec_config_t *config, nfapi_tl_t **ve) { - nfapi_tl_t generic_tl; - uint8_t numBadTags = 0; - uint16_t idx = 0; - - while ((uint8_t *)(*ppReadPackedMsg) < end) { - // unpack the tl and process the values accordingly - if(unpack_tl(ppReadPackedMsg, &generic_tl, end) == 0) - return 0; - - uint8_t tagMatch = 0; - uint8_t *pStartOfValue = *ppReadPackedMsg; - - for(idx = 0; idx < size; ++idx) { - if(unpack_fns[idx].tag == generic_tl.tag) { - tagMatch = 1; - nfapi_tl_t *tl = (nfapi_tl_t *)(unpack_fns[idx].tlv); - tl->tag = generic_tl.tag; - tl->length = generic_tl.length; - int result = (*unpack_fns[idx].unpack_func)(tl, ppReadPackedMsg, end, config); - - if(result == 0) { - return 0; - } - - // check if the length was right; - if(tl->length != (*ppReadPackedMsg - pStartOfValue)) { - NFAPI_TRACE(NFAPI_TRACE_ERROR, "Warning tlv tag 0x%x length %d not equal to unpack %d\n", tl->tag, tl->length, (*ppReadPackedMsg - pStartOfValue)); - } - } - } - - if(tagMatch == 0) { - if(generic_tl.tag >= NFAPI_VENDOR_EXTENSION_MIN_TAG_VALUE && - generic_tl.tag <= NFAPI_VENDOR_EXTENSION_MAX_TAG_VALUE) { - int result = unpack_p7_vendor_extension_tlv(&generic_tl, ppReadPackedMsg, end, config, ve); - - if(result == 0) { - // got to end - return 0; - } else if(result < 0) { - NFAPI_TRACE(NFAPI_TRACE_ERROR, "Unknown TAG value: 0x%04x\n", generic_tl.tag); - - if (++numBadTags > MAX_BAD_TAG) { - NFAPI_TRACE(NFAPI_TRACE_ERROR, "Supplied message has had too many bad tags\n"); - return -1; - } - - if((end - *ppReadPackedMsg) >= generic_tl.length) { - // Advance past the unknown TLV - (*ppReadPackedMsg) += generic_tl.length; - } else { - // got ot the dn - return 0; - } - } - } else { - NFAPI_TRACE(NFAPI_TRACE_ERROR, "Unknown TAG value: 0x%04x\n", generic_tl.tag); - - if (++numBadTags > MAX_BAD_TAG) { - NFAPI_TRACE(NFAPI_TRACE_ERROR, "Supplied message has had too many bad tags\n"); - return -1; - } - - if((end - *ppReadPackedMsg) >= generic_tl.length) { - // Advance past the unknown TLV - (*ppReadPackedMsg) += generic_tl.length; - } else { - // got ot the dn - return 0; - } - } - } - } - - return 1; -} - -// This intermediate function deals with calculating the length of the value -// and writing into the tlv header. -uint8_t pack_tlv(uint16_t tag, void *tlv, uint8_t **ppWritePackedMsg, uint8_t *end, pack_tlv_fn fn) { - nfapi_tl_t *tl = (nfapi_tl_t *)tlv; - - // If the tag is defined - if(tl->tag == tag) { - uint8_t *pStartOfTlv = *ppWritePackedMsg; - - // write a dumy tlv header - if(pack_tl(tl, ppWritePackedMsg, end) == 0) - return 0; - - // Record the start of the value - uint8_t *pStartOfValue = *ppWritePackedMsg; - - // pack the tlv value - if(fn(tlv, ppWritePackedMsg, end) == 0) - return 0; - - // calculate the length of the value and rewrite the tl header - tl->length = (*ppWritePackedMsg) - pStartOfValue; - // rewrite the header with the correct length - pack_tl(tl, &pStartOfTlv, end); - } else { - if(tl->tag != 0) { - NFAPI_TRACE(NFAPI_TRACE_WARN, "Warning pack_tlv tag 0x%x does not match expected 0x%x\n", tl->tag, tag); - } else { - //NFAPI_TRACE(NFAPI_TRACE_ERROR, "Warning pack_tlv tag 0x%x ZERO does not match expected 0x%x\n", tl->tag, tag); - } - } - - return 1; -} - -const char *nfapi_error_code_to_str(nfapi_error_code_e value) { - switch(value) { - case NFAPI_MSG_OK: - return "NFAPI_MSG_OK"; - - case NFAPI_MSG_INVALID_STATE: - return "NFAPI_MSG_INVALID_STATE"; - - case NFAPI_MSG_INVALID_CONFIG: - return "NFAPI_MSG_INVALID_CONFIG"; - - case NFAPI_SFN_OUT_OF_SYNC: - return "NFAPI_SFN_OUT_OF_SYNC"; - - case NFAPI_MSG_SUBFRAME_ERR: - return "NFAPI_MSG_SUBFRAME_ERR"; - - case NFAPI_MSG_BCH_MISSING: - return "NFAPI_MSG_BCH_MISSING"; - - case NFAPI_MSG_INVALID_SFN: - return "NFAPI_MSG_INVALID_SFN"; - - case NFAPI_MSG_HI_ERR: - return "NFAPI_MSG_HI_ERR"; - - case NFAPI_MSG_TX_ERR: - return "NFAPI_MSG_TX_ERR"; - - default: - return "UNKNOWN"; - } -} +/* + * Copyright (c) 2001-2016, Cisco Systems, Inc. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * + * Redistributions in binary form must reproduce the above + * copyright notice, this list of conditions and the following + * disclaimer in the documentation and/or other materials provided + * with the distribution. + * + * Neither the name of the Cisco Systems, Inc. nor the names of its + * contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS + * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE + * COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, + * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, + * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED + * OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#include <signal.h> +#include <sys/time.h> +#include <sys/socket.h> +#include <sys/types.h> +#include <netinet/in.h> +#include <arpa/inet.h> +#include <sched.h> +#include <time.h> +#include <stdio.h> +#include <stdlib.h> +#include <string.h> +#include <unistd.h> +#include <errno.h> +#include <pthread.h> + +#include <nfapi_interface.h> +#include <nfapi.h> +#include <debug.h> + + +// Fundamental routines + +uint8_t push8(uint8_t in, uint8_t **out, uint8_t *end) { + uint8_t *pOut = *out; + + if((end - pOut) >= 1) { + pOut[0] = in; + (*out)+=1; + return 1; + } else { + NFAPI_TRACE(NFAPI_TRACE_ERROR, "%s no space in buffer\n", __FUNCTION__); + return 0; + } +} + +uint8_t pushs8(int8_t in, uint8_t **out, uint8_t *end) { + uint8_t *pOut = *out; + + if((end - pOut) >= 1) { + pOut[0] = in; + (*out)+=1; + return 1; + } else { + NFAPI_TRACE(NFAPI_TRACE_ERROR, "%s no space in buffer\n", __FUNCTION__); + return 0; + } +} + +uint8_t push16(uint16_t in, uint8_t **out, uint8_t *end) { + uint8_t *pOut = *out; + + if((end - pOut) >= 2) { + pOut[0] = (in & 0xFF00) >> 8; + pOut[1] = (in & 0xFF); + (*out)+=2; + return 2; + } else { + NFAPI_TRACE(NFAPI_TRACE_ERROR, "%s no space in buffer\n", __FUNCTION__); + return 0; + } +} + +uint8_t pushs16(int16_t in, uint8_t **out, uint8_t *end) { + uint8_t *pOut = *out; + + if((end - pOut) >= 2) { + pOut[0] = (in & 0xFF00) >> 8; + pOut[1] = (in & 0xFF); + (*out)+=2; + return 2; + } else { + NFAPI_TRACE(NFAPI_TRACE_ERROR, "%s no space in buffer\n", __FUNCTION__); + return 0; + } +} + +uint8_t push32(uint32_t in, uint8_t **out, uint8_t *end) { + uint8_t *pOut = *out; + + if((end - pOut) >= 4) { + pOut[0] = (in & 0xFF000000) >> 24; + pOut[1] = (in & 0xFF0000) >> 16; + pOut[2] = (in & 0xFF00) >> 8; + pOut[3] = (in & 0xFF); + (*out)+=4; + return 4; + } else { + NFAPI_TRACE(NFAPI_TRACE_ERROR, "%s no space in buffer\n", __FUNCTION__); + return 0; + } +} + +uint8_t pushs32(int32_t in, uint8_t **out, uint8_t *end) { + uint8_t *pOut = *out; + + if((end - pOut) >= 4) { + pOut[0] = (in & 0xFF000000) >> 24; + pOut[1] = (in & 0xFF0000) >> 16; + pOut[2] = (in & 0xFF00) >> 8; + pOut[3] = (in & 0xFF); + (*out)+=4; + return 4; + } else { + NFAPI_TRACE(NFAPI_TRACE_ERROR, "%s no space in buffer\n", __FUNCTION__); + return 0; + } +} + +uint8_t pull8(uint8_t **in, uint8_t *out, uint8_t *end) { + uint8_t *pIn = *in; + + if((end - pIn) >= 1 ) { + *out = *pIn; + (*in)+=1; + return 1; + } else { + NFAPI_TRACE(NFAPI_TRACE_ERROR, "%s no space in buffer\n", __FUNCTION__); + return 0; + } +} + +uint8_t pulls8(uint8_t **in, int8_t *out, uint8_t *end) { + uint8_t *pIn = *in; + + if((end - pIn) >= 1 ) { + *out = *pIn; + (*in)+=1; + return 1; + } else { + NFAPI_TRACE(NFAPI_TRACE_ERROR, "%s no space in buffer\n", __FUNCTION__); + return 0; + } +} + +uint8_t pull16(uint8_t **in, uint16_t *out, uint8_t *end) { + uint8_t *pIn = *in; + + if((end - pIn) >=2 ) { + *out = ((pIn[0]) << 8) | pIn[1]; + (*in)+=2; + return 2; + } else { + NFAPI_TRACE(NFAPI_TRACE_ERROR, "%s no space in buffer\n", __FUNCTION__); + return 0; + } +} + +uint8_t pulls16(uint8_t **in, int16_t *out, uint8_t *end) { + uint8_t *pIn = *in; + + if((end - pIn) >=2 ) { + *out = ((pIn[0]) << 8) | pIn[1]; + (*in)+=2; + return 2; + } else { + NFAPI_TRACE(NFAPI_TRACE_ERROR, "%s no space in buffer\n", __FUNCTION__); + return 0; + } +} + +uint8_t pull32(uint8_t **in, uint32_t *out, uint8_t *end) { + uint8_t *pIn = *in; + + if((end - pIn) >=4 ) { + *out = (pIn[0] << 24) | (pIn[1] << 16) | (pIn[2] << 8) | pIn[3]; + (*in)+=4; + return 4; + } else { + NFAPI_TRACE(NFAPI_TRACE_ERROR, "%s no space in buffer\n", __FUNCTION__); + return 0; + } +} + +uint8_t pulls32(uint8_t **in, int32_t *out, uint8_t *end) { + uint8_t *pIn = *in; + + if((end - pIn) >=4 ) { + *out = (pIn[0] << 24) | (pIn[1] << 16) | (pIn[2] << 8) | pIn[3]; + (*in)+=4; + return 4; + } else { + NFAPI_TRACE(NFAPI_TRACE_ERROR, "%s no space in buffer\n", __FUNCTION__); + return 0; + } +} + +/* +inline void pusharray16(uint8_t **, uint16_t, uint32_t len) +{ +} +*/ + +uint32_t pullarray16(uint8_t **in, uint16_t out[], uint32_t max_len, uint32_t len, uint8_t *end) { + if(len == 0) + return 1; + + if(len > max_len) { + NFAPI_TRACE(NFAPI_TRACE_ERROR, "%s exceed array size (%d > %d)\n", __FUNCTION__, len, max_len); + return 0; + } + + if((end - (*in)) >= sizeof(uint16_t) * len) { + uint32_t idx; + + for(idx = 0; idx < len; ++idx) { + if(!pull16(in, &out[idx], end)) + return 0; + } + + return sizeof(uint16_t) * len; + } else { + NFAPI_TRACE(NFAPI_TRACE_ERROR, "%s no space in buffer\n", __FUNCTION__); + return 0; + } +} + +uint32_t pullarrays16(uint8_t **in, int16_t out[], uint32_t max_len, uint32_t len, uint8_t *end) { + if(len == 0) + return 1; + + if(len > max_len) { + NFAPI_TRACE(NFAPI_TRACE_ERROR, "%s exceed array size (%d > %d)\n", __FUNCTION__, len, max_len); + return 0; + } + + if((end - (*in)) >= sizeof(uint16_t) * len) { + uint32_t idx; + + for(idx = 0; idx < len; ++idx) { + if(!pulls16(in, &out[idx], end)) + return 0; + } + + return sizeof(uint16_t) * len; + } else { + NFAPI_TRACE(NFAPI_TRACE_ERROR, "%s no space in buffer\n", __FUNCTION__); + return 0; + } +} +uint32_t pusharray16(uint16_t in[], uint32_t max_len, uint32_t len, uint8_t **out, uint8_t *end) { + if(len == 0) + return 1; + + if(len > max_len) { + NFAPI_TRACE(NFAPI_TRACE_ERROR, "%s exceed array size (%d > %d)\n", __FUNCTION__, len, max_len); + return 0; + } + + if((end - (*out)) >= sizeof(uint16_t) * len) { + uint32_t idx; + + for(idx = 0; idx < len; ++idx) { + if(!push16(in[idx], out, end)) + return 0; + } + + return sizeof(uint16_t) * len; + } else { + NFAPI_TRACE(NFAPI_TRACE_ERROR, "%s no space in buffer\n", __FUNCTION__); + return 0; + } +} +uint32_t pusharrays16(int16_t in[], uint32_t max_len, uint32_t len, uint8_t **out, uint8_t *end) { + if(len == 0) + return 1; + + if(len > max_len) { + NFAPI_TRACE(NFAPI_TRACE_ERROR, "%s exceed array size (%d > %d)\n", __FUNCTION__, len, max_len); + return 0; + } + + if((end - (*out)) >= sizeof(uint16_t) * len) { + uint32_t idx; + + for(idx = 0; idx < len; ++idx) { + pushs16(in[idx], out, end); + } + + return sizeof(uint16_t) * len; + } else { + NFAPI_TRACE(NFAPI_TRACE_ERROR, "%s no space in buffer\n", __FUNCTION__); + return 0; + } +} +uint32_t pullarray32(uint8_t **in, uint32_t out[], uint32_t max_len, uint32_t len, uint8_t *end) { + if(len == 0) + return 1; + + if(len > max_len) { + NFAPI_TRACE(NFAPI_TRACE_ERROR, "%s exceed array size (%d > %d)\n", __FUNCTION__, len, max_len); + return 0; + } + + if((end - (*in)) >= sizeof(uint32_t) * len) { + uint32_t idx; + + for(idx = 0; idx < len; ++idx) { + if(!pull32(in, &out[idx], end)) + return 0; + } + + return sizeof(uint32_t) * len; + } else { + NFAPI_TRACE(NFAPI_TRACE_ERROR, "%s no space in buffer\n", __FUNCTION__); + return 0; + } +} + +uint32_t pullarrays32(uint8_t **in, int32_t out[], uint32_t max_len, uint32_t len, uint8_t *end) { + if(len == 0) + return 1; + + if(len > max_len) { + NFAPI_TRACE(NFAPI_TRACE_ERROR, "%s exceed array size (%d > %d)\n", __FUNCTION__, len, max_len); + return 0; + } + + if((end - (*in)) >= sizeof(uint32_t) * len) { + uint32_t idx; + + for(idx = 0; idx < len; ++idx) { + if(!pulls32(in, &out[idx], end)) + return 0; + } + + return sizeof(uint32_t) * len; + } else { + NFAPI_TRACE(NFAPI_TRACE_ERROR, "%s no space in buffer\n", __FUNCTION__); + return 0; + } +} +uint32_t pusharray32(uint32_t in[], uint32_t max_len, uint32_t len, uint8_t **out, uint8_t *end) { + if(len == 0) + return 1; + + if(len > max_len) { + NFAPI_TRACE(NFAPI_TRACE_ERROR, "%s exceed array size (%d > %d)\n", __FUNCTION__, len, max_len); + return 0; + } + + if((end - (*out)) >= sizeof(uint32_t) * len) { + uint32_t idx; + + for(idx = 0; idx < len; ++idx) { + if(!push32(in[idx], out, end)) + return 0; + } + + return sizeof(uint32_t) * len; + } else { + NFAPI_TRACE(NFAPI_TRACE_ERROR, "%s no space in buffer\n", __FUNCTION__); + return 0; + } +} +uint32_t pusharrays32(int32_t in[], uint32_t max_len, uint32_t len, uint8_t **out, uint8_t *end) { + if(len == 0) + return 1; + + if(len > max_len) { + NFAPI_TRACE(NFAPI_TRACE_ERROR, "%s exceed array size (%d > %d)\n", __FUNCTION__, len, max_len); + return 0; + } + + if((end - (*out)) >= sizeof(uint32_t) * len) { + uint32_t idx; + + for(idx = 0; idx < len; ++idx) { + pushs32(in[idx], out, end); + } + + return sizeof(uint32_t) * len; + } else { + NFAPI_TRACE(NFAPI_TRACE_ERROR, "%s no space in buffer\n", __FUNCTION__); + return 0; + } +} +uint32_t pullarray8(uint8_t **in, uint8_t out[], uint32_t max_len, uint32_t len, uint8_t *end) { + if(len == 0) + return 1; + + if(len > max_len) { + NFAPI_TRACE(NFAPI_TRACE_ERROR, "%s exceed array size (%d > %d)\n", __FUNCTION__, len, max_len); + return 0; + } + + if((end - (*in)) >= sizeof(uint8_t) * len) { + memcpy(out, (*in), len); + (*in)+=len; + return sizeof(uint8_t) * len; + } else { + NFAPI_TRACE(NFAPI_TRACE_ERROR, "%s no space in buffer\n", __FUNCTION__); + return 0; + } +} + +uint32_t pusharray8(uint8_t in[], uint32_t max_len, uint32_t len, uint8_t **out, uint8_t *end) { + if(len == 0) + return 1; + + if(len > max_len) { + NFAPI_TRACE(NFAPI_TRACE_ERROR, "%s exceed array size (%d > %d)\n", __FUNCTION__, len, max_len); + return 0; + } + + if((end - (*out)) >= sizeof(uint8_t) * len) { + memcpy((*out), in, len); + (*out)+=len; + return sizeof(uint8_t) * len; + } else { + NFAPI_TRACE(NFAPI_TRACE_ERROR, "%s no space in buffer\n", __FUNCTION__); + return 0; + } +} + +uint8_t packarray(void *array, uint16_t array_element_size, uint16_t max_count, uint16_t count, uint8_t **ppwritepackedmsg, uint8_t *end, pack_array_elem_fn fn) { + if(count > max_count) { + NFAPI_TRACE(NFAPI_TRACE_ERROR, "%s exceed array size (%d > %d)\n", __FUNCTION__, count, max_count); + return 0; + } + + uint16_t i = 0; + + for(i = 0; i < count; ++i) { + if((fn)(array, ppwritepackedmsg, end) == 0) + return 0; + + array += array_element_size; + } + + return 1; +} + +uint8_t unpackarray(uint8_t **ppReadPackedMsg, void *array, uint16_t array_element_size, uint16_t max_count, uint16_t count, uint8_t *end, unpack_array_elem_fn fn) { + if(count > max_count) { + NFAPI_TRACE(NFAPI_TRACE_ERROR, "%s exceed array size (%d > %d)\n", __FUNCTION__, count, max_count); + return 0; + } + + uint16_t i = 0; + + for(i = 0; i < count; ++i) { + if((fn)(array, ppReadPackedMsg, end) == 0) + return 0; + + array += array_element_size; + } + + return 1; +} + + +uint32_t pack_vendor_extension_tlv(nfapi_tl_t *ve, uint8_t **ppWritePackedMsg, uint8_t *end, nfapi_p4_p5_codec_config_t *config) { + if(ve != 0 && config != 0) { + if(config->pack_vendor_extension_tlv) { + uint8_t *pStartOfTlv = *ppWritePackedMsg; + + if(pack_tl(ve, ppWritePackedMsg, end) == 0) + return 0; + + uint8_t *pStartOfValue = *ppWritePackedMsg; + + if((config->pack_vendor_extension_tlv)(ve, ppWritePackedMsg, end, config) == 0) + return 0; + + ve->length = (*ppWritePackedMsg) - pStartOfValue; + pack_tl(ve, &pStartOfTlv, end); + return 1; + } + } + + return 1; +} + +uint32_t unpack_vendor_extension_tlv(nfapi_tl_t *tl, uint8_t **ppReadPackedMsg, uint8_t *end, nfapi_p4_p5_codec_config_t *config, nfapi_tl_t **ve_tlv) { + if(ve_tlv != 0 && config != 0) { + if(config->unpack_vendor_extension_tlv) { + return (config->unpack_vendor_extension_tlv)(tl, ppReadPackedMsg, end, (void **)ve_tlv, config); + } + } + + return 1; +} + +uint32_t pack_p7_vendor_extension_tlv(nfapi_tl_t *ve, uint8_t **ppWritePackedMsg, uint8_t *end,nfapi_p7_codec_config_t *config) { + if(ve != 0 && config != 0) { + if(config->pack_vendor_extension_tlv) { + uint8_t *pStartOfTlv = *ppWritePackedMsg; + + if(pack_tl(ve, ppWritePackedMsg, end) == 0) + return 0; + + uint8_t *pStartOfValue = *ppWritePackedMsg; + + if((config->pack_vendor_extension_tlv)(ve, ppWritePackedMsg, end, config) == 0) + return 0; + + ve->length = (*ppWritePackedMsg) - pStartOfValue; + pack_tl(ve, &pStartOfTlv, end); + return 1; + } + } + + return 1; +} + +int unpack_p7_vendor_extension_tlv(nfapi_tl_t *tl, uint8_t **ppReadPackedMsg, uint8_t *end, nfapi_p7_codec_config_t *config, nfapi_tl_t **ve_tlv) { + if(ve_tlv != 0 && config != 0) { + if(config->unpack_vendor_extension_tlv) { + return (config->unpack_vendor_extension_tlv)(tl, ppReadPackedMsg, end, (void **)ve_tlv, config); + } + } + + return 1; +} + + +uint8_t pack_tl(nfapi_tl_t *tl, uint8_t **ppWritePackedMsg, uint8_t *end) { + return (push16(tl->tag, ppWritePackedMsg, end) && + push16(tl->length, ppWritePackedMsg, end)); +} + +uint8_t unpack_tl(uint8_t **ppReadPackedMsg, nfapi_tl_t *tl, uint8_t *end) { + return (pull16(ppReadPackedMsg, &tl->tag, end) && + pull16(ppReadPackedMsg, &tl->length, end)); +} + +int unpack_tlv_list(unpack_tlv_t unpack_fns[], uint16_t size, uint8_t **ppReadPackedMsg, uint8_t *end, nfapi_p4_p5_codec_config_t *config, nfapi_tl_t **ve) { + nfapi_tl_t generic_tl; + uint8_t numBadTags = 0; + uint16_t idx = 0; + + while ((uint8_t *)(*ppReadPackedMsg) < end) { + // unpack the tl and process the values accordingly + if(unpack_tl(ppReadPackedMsg, &generic_tl, end) == 0) + return 0; + + uint8_t tagMatch = 0; + uint8_t *pStartOfValue = *ppReadPackedMsg; + + for(idx = 0; idx < size; ++idx) { + if(unpack_fns[idx].tag == generic_tl.tag) { // match the extracted tag value with all the tags in unpack_fn list + tagMatch = 1; + nfapi_tl_t *tl = (nfapi_tl_t *)(unpack_fns[idx].tlv); + tl->tag = generic_tl.tag; + tl->length = generic_tl.length; + int result = (*unpack_fns[idx].unpack_func)(tl, ppReadPackedMsg, end); + + if(result == 0) { + return 0; + } + + // check if the length was right; + if(tl->length != (*ppReadPackedMsg - pStartOfValue)) { + NFAPI_TRACE(NFAPI_TRACE_ERROR, "Warning tlv tag 0x%x length %d not equal to unpack %ld\n", tl->tag, tl->length, (*ppReadPackedMsg - pStartOfValue)); + } + } + } + + if(tagMatch == 0) { + if(generic_tl.tag >= NFAPI_VENDOR_EXTENSION_MIN_TAG_VALUE && + generic_tl.tag <= NFAPI_VENDOR_EXTENSION_MAX_TAG_VALUE) { + int result = unpack_vendor_extension_tlv(&generic_tl, ppReadPackedMsg, end, config, ve); + + if(result == 0) { + // got tot the end. + return 0; + } else if(result < 0) { + NFAPI_TRACE(NFAPI_TRACE_ERROR, "Unknown VE TAG value: 0x%04x\n", generic_tl.tag); + + if (++numBadTags > MAX_BAD_TAG) { + NFAPI_TRACE(NFAPI_TRACE_ERROR, "Supplied message has had too many bad tags\n"); + return 0; + } + + if((end - *ppReadPackedMsg) >= generic_tl.length) { + // Advance past the unknown TLV + (*ppReadPackedMsg) += generic_tl.length; + } else { + // go to the end + return 0; + } + } + } else { + NFAPI_TRACE(NFAPI_TRACE_ERROR, "Unknown TAG value: 0x%04x\n", generic_tl.tag); + + if (++numBadTags > MAX_BAD_TAG) { + NFAPI_TRACE(NFAPI_TRACE_ERROR, "Supplied message has had too many bad tags\n"); + return 0; + } + + if((end - *ppReadPackedMsg) >= generic_tl.length) { + // Advance past the unknown TLV + (*ppReadPackedMsg) += generic_tl.length; + } else { + // go to the end + return 0; + } + } + } + } + + return 1; +} +int unpack_p7_tlv_list(unpack_p7_tlv_t unpack_fns[], uint16_t size, uint8_t **ppReadPackedMsg, uint8_t *end, nfapi_p7_codec_config_t *config, nfapi_tl_t **ve) { + nfapi_tl_t generic_tl; + uint8_t numBadTags = 0; + uint16_t idx = 0; + + while ((uint8_t *)(*ppReadPackedMsg) < end) { + // unpack the tl and process the values accordingly + if(unpack_tl(ppReadPackedMsg, &generic_tl, end) == 0) + return 0; + + uint8_t tagMatch = 0; + uint8_t *pStartOfValue = *ppReadPackedMsg; + + for(idx = 0; idx < size; ++idx) { + if(unpack_fns[idx].tag == generic_tl.tag) { + tagMatch = 1; + nfapi_tl_t *tl = (nfapi_tl_t *)(unpack_fns[idx].tlv); + tl->tag = generic_tl.tag; + tl->length = generic_tl.length; + int result = (*unpack_fns[idx].unpack_func)(tl, ppReadPackedMsg, end, config); + + if(result == 0) { + return 0; + } + + // check if the length was right; + if(tl->length != (*ppReadPackedMsg - pStartOfValue)) { + NFAPI_TRACE(NFAPI_TRACE_ERROR, "Warning tlv tag 0x%x length %d not equal to unpack %ld\n", tl->tag, tl->length, (*ppReadPackedMsg - pStartOfValue)); + } + } + } + + if(tagMatch == 0) { + if(generic_tl.tag >= NFAPI_VENDOR_EXTENSION_MIN_TAG_VALUE && + generic_tl.tag <= NFAPI_VENDOR_EXTENSION_MAX_TAG_VALUE) { + int result = unpack_p7_vendor_extension_tlv(&generic_tl, ppReadPackedMsg, end, config, ve); + + if(result == 0) { + // got to end + return 0; + } else if(result < 0) { + NFAPI_TRACE(NFAPI_TRACE_ERROR, "Unknown TAG value: 0x%04x\n", generic_tl.tag); + + if (++numBadTags > MAX_BAD_TAG) { + NFAPI_TRACE(NFAPI_TRACE_ERROR, "Supplied message has had too many bad tags\n"); + return -1; + } + + if((end - *ppReadPackedMsg) >= generic_tl.length) { + // Advance past the unknown TLV + (*ppReadPackedMsg) += generic_tl.length; + } else { + // got ot the dn + return 0; + } + } + } else { + NFAPI_TRACE(NFAPI_TRACE_ERROR, "Unknown TAG value: 0x%04x\n", generic_tl.tag); + + if (++numBadTags > MAX_BAD_TAG) { + NFAPI_TRACE(NFAPI_TRACE_ERROR, "Supplied message has had too many bad tags\n"); + return -1; + } + + if((end - *ppReadPackedMsg) >= generic_tl.length) { + // Advance past the unknown TLV + (*ppReadPackedMsg) += generic_tl.length; + } else { + // got ot the dn + return 0; + } + } + } + } + + return 1; +} + +// This intermediate function deals with calculating the length of the value +// and writing into the tlv header. +uint8_t pack_tlv(uint16_t tag, void *tlv, uint8_t **ppWritePackedMsg, uint8_t *end, pack_tlv_fn fn) { + nfapi_tl_t *tl = (nfapi_tl_t *)tlv; + + // If the tag is defined + if(tl->tag == tag) { + uint8_t *pStartOfTlv = *ppWritePackedMsg; + + // write a dumy tlv header + if(pack_tl(tl, ppWritePackedMsg, end) == 0) + return 0; + + // Record the start of the value + uint8_t *pStartOfValue = *ppWritePackedMsg; + + // pack the tlv value + if(fn(tlv, ppWritePackedMsg, end) == 0) + return 0; + + // calculate the length of the value and rewrite the tl header + tl->length = (*ppWritePackedMsg) - pStartOfValue; + // rewrite the header with the correct length + pack_tl(tl, &pStartOfTlv, end); + } else { + if(tl->tag != 0) { + NFAPI_TRACE(NFAPI_TRACE_WARN, "Warning pack_tlv tag 0x%x does not match expected 0x%x\n", tl->tag, tag); + } else { + //NFAPI_TRACE(NFAPI_TRACE_ERROR, "Warning pack_tlv tag 0x%x ZERO does not match expected 0x%x\n", tl->tag, tag); + } + } + + return 1; +} + +const char *nfapi_error_code_to_str(nfapi_error_code_e value) { + switch(value) { + case NFAPI_MSG_OK: + return "NFAPI_MSG_OK"; + + case NFAPI_MSG_INVALID_STATE: + return "NFAPI_MSG_INVALID_STATE"; + + case NFAPI_MSG_INVALID_CONFIG: + return "NFAPI_MSG_INVALID_CONFIG"; + + case NFAPI_SFN_OUT_OF_SYNC: + return "NFAPI_SFN_OUT_OF_SYNC"; + + case NFAPI_MSG_SUBFRAME_ERR: + return "NFAPI_MSG_SUBFRAME_ERR"; + + case NFAPI_MSG_BCH_MISSING: + return "NFAPI_MSG_BCH_MISSING"; + + case NFAPI_MSG_INVALID_SFN: + return "NFAPI_MSG_INVALID_SFN"; + + case NFAPI_MSG_HI_ERR: + return "NFAPI_MSG_HI_ERR"; + + case NFAPI_MSG_TX_ERR: + return "NFAPI_MSG_TX_ERR"; + + default: + return "UNKNOWN"; + } +} diff --git a/nfapi/open-nFAPI/nfapi/src/nfapi_p4.c b/nfapi/open-nFAPI/nfapi/src/nfapi_p4.c index dbaa4347d33313ce4957b106c623d02ddf28c858..6e79af6348a7f11c72df0067fe925e25f427f492 100644 --- a/nfapi/open-nFAPI/nfapi/src/nfapi_p4.c +++ b/nfapi/open-nFAPI/nfapi/src/nfapi_p4.c @@ -29,7 +29,7 @@ static uint32_t get_packed_msg_len(uintptr_t msgHead, uintptr_t msgEnd) { if (msgEnd < msgHead) { - NFAPI_TRACE(NFAPI_TRACE_ERROR, "get_packed_msg_len: Error in pointers supplied %d, %d\n", msgHead, msgEnd); + NFAPI_TRACE(NFAPI_TRACE_ERROR, "get_packed_msg_len: Error in pointers supplied %lu, %lu\n", msgHead, msgEnd); return 0; } diff --git a/nfapi/open-nFAPI/nfapi/src/nfapi_p5.c b/nfapi/open-nFAPI/nfapi/src/nfapi_p5.c index 3a6d807bdd08c06c1fe707f092df8a40b2d3a907..ce9c22f7f71ae29ebafcd59f07d6aa7ab4b0bb09 100644 --- a/nfapi/open-nFAPI/nfapi/src/nfapi_p5.c +++ b/nfapi/open-nFAPI/nfapi/src/nfapi_p5.c @@ -263,8 +263,8 @@ static uint8_t pack_nr_pnf_config_request(void *msg, uint8_t **ppWritePackedMsg, static uint8_t pack_pnf_config_request(void *msg, uint8_t **ppWritePackedMsg, uint8_t *end, nfapi_p4_p5_codec_config_t *config) { nfapi_pnf_config_request_t *pNfapiMsg = (nfapi_pnf_config_request_t *)msg; - return (pack_tlv(NFAPI_PNF_PHY_RF_TAG, &pNfapiMsg->pnf_phy_rf_config, ppWritePackedMsg, end, &pack_pnf_phy_rf_config_value) && - push8(pNfapiMsg->num_tlvs,ppWritePackedMsg,end) && + return (push8(pNfapiMsg->num_tlvs,ppWritePackedMsg,end) && + pack_tlv(NFAPI_PNF_PHY_RF_TAG, &pNfapiMsg->pnf_phy_rf_config, ppWritePackedMsg, end, &pack_pnf_phy_rf_config_value) && pack_vendor_extension_tlv(pNfapiMsg->vendor_extension, ppWritePackedMsg, end, config)); } @@ -429,16 +429,6 @@ static uint8_t pack_embms_mbsfn_config_value(void *tlv, uint8_t **ppWritePackedM pusharray8(value->fourframes_flag, 8,value->num_mbsfn_config,ppWritePackedMsg, end) && pusharrays32(value->mbsfn_subframeconfig, 8, value->num_mbsfn_config, ppWritePackedMsg, end)); } -// static uint8_t unpack_embms_mbsfn_config_value(void* tlv, uint8_t **ppReadPackedMsg, uint8_t* end) -// { -// nfapi_embms_mbsfn_config_t* value = (nfapi_embms_mbsfn_config_t*)tlv; - -// return ( pull16(ppReadPackedMsg, &value->num_mbsfn_config, end) && -// pull16(ppReadPackedMsg, &value->radioframe_allocation_period, end) && -// pull16(ppReadPackedMsg, &value->radioframe_allocation_offset, end) && -// pull8(ppReadPackedMsg, &value->fourframes_flag, end) && -// pullarrays32(ppReadPackedMsg, value->mbsfn_subframeconfig, 8, value->num_mbsfn_config, end)); -// } static uint8_t pack_param_response(void *msg, uint8_t **ppWritePackedMsg, uint8_t *end, nfapi_p4_p5_codec_config_t *config) { nfapi_param_response_t *pNfapiMsg = (nfapi_param_response_t *)msg; @@ -707,8 +697,7 @@ static uint8_t pack_config_request(void *msg, uint8_t **ppWritePackedMsg, uint8_ pack_tlv(NFAPI_NFAPI_NMM_GSM_FREQUENCY_BANDS_TAG, &(pNfapiMsg->nfapi_config.nmm_gsm_frequency_bands), ppWritePackedMsg, end, &pack_nmm_frequency_bands_value) && pack_tlv(NFAPI_NFAPI_NMM_UMTS_FREQUENCY_BANDS_TAG, &(pNfapiMsg->nfapi_config.nmm_umts_frequency_bands), ppWritePackedMsg, end, &pack_nmm_frequency_bands_value) && pack_tlv(NFAPI_NFAPI_NMM_LTE_FREQUENCY_BANDS_TAG, &(pNfapiMsg->nfapi_config.nmm_lte_frequency_bands), ppWritePackedMsg, end, &pack_nmm_frequency_bands_value) && - pack_tlv(NFAPI_NFAPI_NMM_UPLINK_RSSI_SUPPORTED_TAG, &(pNfapiMsg->nfapi_config.nmm_uplink_rssi_supported), ppWritePackedMsg, end, &pack_uint8_tlv_value) && - pack_vendor_extension_tlv(pNfapiMsg->vendor_extension, ppWritePackedMsg, end, config) ); + pack_tlv(NFAPI_NFAPI_NMM_UPLINK_RSSI_SUPPORTED_TAG, &(pNfapiMsg->nfapi_config.nmm_uplink_rssi_supported), ppWritePackedMsg, end, &pack_uint8_tlv_value)); } @@ -734,47 +723,50 @@ static uint8_t pack_nr_config_request(void *msg, uint8_t **ppWritePackedMsg, uin pack_tlv(NFAPI_NR_CONFIG_UL_K0_TAG, &(pNfapiMsg->carrier_config.ul_k0[1]), ppWritePackedMsg, end, &pack_uint16_tlv_value) && pack_tlv(NFAPI_NR_CONFIG_UPLINK_BANDWIDTH_TAG, &(pNfapiMsg->carrier_config.uplink_bandwidth), ppWritePackedMsg, end, &pack_uint16_tlv_value) && pack_tlv(NFAPI_NR_CONFIG_UPLINK_FREQUENCY_TAG, &(pNfapiMsg->carrier_config.uplink_frequency), ppWritePackedMsg, end, &pack_uint32_tlv_value) && + pack_tlv(NFAPI_NR_CONFIG_FREQUENCY_SHIFT_7P5KHZ_TAG, &(pNfapiMsg->carrier_config.frequency_shift_7p5khz), ppWritePackedMsg, end, &pack_uint8_tlv_value) && pack_tlv(NFAPI_NR_CONFIG_FRAME_DUPLEX_TYPE_TAG, &(pNfapiMsg->cell_config.frame_duplex_type), ppWritePackedMsg, end, &pack_uint8_tlv_value) && - pack_tlv(NFAPI_NR_CONFIG_PHY_CELL_ID_TAG, &(pNfapiMsg->cell_config.phy_cell_id), ppWritePackedMsg, end, &pack_uint8_tlv_value) && + pack_tlv(NFAPI_NR_CONFIG_PHY_CELL_ID_TAG, &(pNfapiMsg->cell_config.phy_cell_id), ppWritePackedMsg, end, &pack_uint16_tlv_value) && + pack_tlv(NFAPI_NR_CONFIG_PRACH_MULTIPLE_CARRIERS_IN_A_BAND_TAG, &(pNfapiMsg->prach_config.prach_multiple_carriers_in_a_band), ppWritePackedMsg, end, &pack_uint8_tlv_value) && + pack_tlv(NFAPI_NR_CONFIG_PRACH_CONFIG_INDEX_TAG, &(pNfapiMsg->prach_config.prach_ConfigurationIndex), ppWritePackedMsg, end, &pack_uint8_tlv_value) && pack_tlv(NFAPI_NR_CONFIG_NUM_PRACH_FD_OCCASIONS_TAG, &(pNfapiMsg->prach_config.num_prach_fd_occasions), ppWritePackedMsg, end, &pack_uint8_tlv_value) && pack_tlv(NFAPI_NR_CONFIG_PRACH_SEQUENCE_LENGTH_TAG, &(pNfapiMsg->prach_config.prach_sequence_length), ppWritePackedMsg, end, &pack_uint8_tlv_value) && pack_tlv(NFAPI_NR_CONFIG_RESTRICTED_SET_CONFIG_TAG, &(pNfapiMsg->prach_config.restricted_set_config), ppWritePackedMsg, end, &pack_uint8_tlv_value) && pack_tlv(NFAPI_NR_CONFIG_SSB_PER_RACH_TAG, &(pNfapiMsg->prach_config.ssb_per_rach), ppWritePackedMsg, end, &pack_uint8_tlv_value) && - pack_tlv(NFAPI_NR_CONFIG_PRACH_SUB_C_SPACING_TAG, &(pNfapiMsg->prach_config.prach_sub_c_spacing), ppWritePackedMsg, end, &pack_uint8_tlv_value) && - pack_tlv(NFAPI_NR_CONFIG_PRACH_ROOT_SEQUENCE_INDEX_TAG, &(pNfapiMsg->prach_config.num_prach_fd_occasions_list[0].prach_root_sequence_index), ppWritePackedMsg, end, &pack_uint16_tlv_value) && - pack_tlv(NFAPI_NR_CONFIG_K1_TAG, &(pNfapiMsg->prach_config.num_prach_fd_occasions_list[0].k1), ppWritePackedMsg, end, &pack_uint16_tlv_value) && - pack_tlv(NFAPI_NR_CONFIG_PRACH_ZERO_CORR_CONF_TAG, &(pNfapiMsg->prach_config.num_prach_fd_occasions_list[0].prach_zero_corr_conf), ppWritePackedMsg, end, &pack_uint8_tlv_value) && + pack_tlv(NFAPI_NR_CONFIG_PRACH_SUB_C_SPACING_TAG, &(pNfapiMsg->prach_config.prach_sub_c_spacing), ppWritePackedMsg, end, &pack_uint8_tlv_value) && + pack_tlv(NFAPI_NR_CONFIG_PRACH_ROOT_SEQUENCE_INDEX_TAG, &(pNfapiMsg->prach_config.num_prach_fd_occasions_list[0].prach_root_sequence_index), ppWritePackedMsg, end, &pack_uint16_tlv_value) && + pack_tlv(NFAPI_NR_CONFIG_K1_TAG, &(pNfapiMsg->prach_config.num_prach_fd_occasions_list[0].k1), ppWritePackedMsg, end, &pack_uint16_tlv_value) && + pack_tlv(NFAPI_NR_CONFIG_PRACH_ZERO_CORR_CONF_TAG, &(pNfapiMsg->prach_config.num_prach_fd_occasions_list[0].prach_zero_corr_conf), ppWritePackedMsg, end, &pack_uint8_tlv_value) && pack_tlv(NFAPI_NR_CONFIG_NUM_ROOT_SEQUENCES_TAG, &(pNfapiMsg->prach_config.num_prach_fd_occasions_list[0].num_root_sequences), ppWritePackedMsg, end, &pack_uint8_tlv_value) && - pack_tlv(NFAPI_NR_CONFIG_SCS_COMMON_TAG, &(pNfapiMsg->ssb_config.scs_common), ppWritePackedMsg, end, &pack_uint8_tlv_value) && + pack_tlv(NFAPI_NR_CONFIG_BCH_PAYLOAD_TAG, &(pNfapiMsg->ssb_config.bch_payload), ppWritePackedMsg, end, &pack_uint8_tlv_value) && pack_tlv(NFAPI_NR_CONFIG_SS_PBCH_POWER_TAG, &(pNfapiMsg->ssb_config.ss_pbch_power), ppWritePackedMsg, end, &pack_uint32_tlv_value) && pack_tlv(NFAPI_NR_CONFIG_BETA_PSS_TAG, &(pNfapiMsg->ssb_table.beta_pss), ppWritePackedMsg, end, &pack_uint8_tlv_value) && pack_tlv(NFAPI_NR_CONFIG_MIB_TAG, &(pNfapiMsg->ssb_table.MIB), ppWritePackedMsg, end, &pack_uint32_tlv_value) && pack_tlv(NFAPI_NR_CONFIG_SSB_MASK_TAG, &(pNfapiMsg->ssb_table.ssb_mask_list[0].ssb_mask), ppWritePackedMsg, end, &pack_uint32_tlv_value) && - pack_tlv(NFAPI_NR_CONFIG_SSB_MASK_TAG, &(pNfapiMsg->ssb_table.ssb_mask_list[1].ssb_mask), ppWritePackedMsg, end, &pack_uint32_tlv_value) && - + // TODO: Not sure what's going on, ssb_mask_list[1] packing below seems to match unpack, but is causing problems + // pack_tlv(NFAPI_NR_CONFIG_SSB_MASK_TAG, &(pNfapiMsg->ssb_table.ssb_mask_list[1].ssb_mask), ppWritePackedMsg, end, &pack_uint32_tlv_value) && + pack_tlv(NFAPI_NR_CONFIG_BEAM_ID_TAG, &(pNfapiMsg->ssb_table.ssb_beam_id_list[0].beam_id), ppWritePackedMsg, end, &pack_uint8_tlv_value) && pack_tlv(NFAPI_NR_CONFIG_SSB_OFFSET_POINT_A_TAG, &(pNfapiMsg->ssb_table.ssb_offset_point_a), ppWritePackedMsg, end, &pack_uint16_tlv_value) && pack_tlv(NFAPI_NR_CONFIG_SSB_PERIOD_TAG, &(pNfapiMsg->ssb_table.ssb_period), ppWritePackedMsg, end, &pack_uint8_tlv_value) && pack_tlv(NFAPI_NR_CONFIG_SSB_SUBCARRIER_OFFSET_TAG, &(pNfapiMsg->ssb_table.ssb_subcarrier_offset), ppWritePackedMsg, end, &pack_uint8_tlv_value) && + pack_tlv(NFAPI_NR_CONFIG_SS_PBCH_MULTIPLE_CARRIERS_IN_A_BAND_TAG, &(pNfapiMsg->ssb_table.ss_pbch_multiple_carriers_in_a_band), ppWritePackedMsg, end, &pack_uint8_tlv_value) && + pack_tlv(NFAPI_NR_CONFIG_MULTIPLE_CELLS_SS_PBCH_IN_A_CARRIER_TAG, &(pNfapiMsg->ssb_table.multiple_cells_ss_pbch_in_a_carrier), ppWritePackedMsg, end, &pack_uint8_tlv_value) && pack_tlv(NFAPI_NR_CONFIG_TDD_PERIOD_TAG, &(pNfapiMsg->tdd_table.tdd_period), ppWritePackedMsg, end, &pack_uint8_tlv_value) && - pack_tlv(NFAPI_NR_NFAPI_P7_PNF_ADDRESS_IPV4_TAG, &(pNfapiMsg->nfapi_config.p7_pnf_address_ipv4), ppWritePackedMsg, end, &pack_ipv4_address_value) && - pack_tlv(NFAPI_NR_NFAPI_P7_PNF_ADDRESS_IPV6_TAG, &(pNfapiMsg->nfapi_config.p7_pnf_address_ipv6), ppWritePackedMsg, end, &pack_ipv6_address_value) && - pack_tlv(NFAPI_NR_NFAPI_P7_PNF_PORT_TAG, &(pNfapiMsg->nfapi_config.p7_pnf_port), ppWritePackedMsg, end, &pack_uint16_tlv_value) && + pack_tlv(NFAPI_NR_NFAPI_P7_VNF_ADDRESS_IPV4_TAG, &(pNfapiMsg->nfapi_config.p7_vnf_address_ipv4), ppWritePackedMsg, end, &pack_ipv4_address_value) && pack_tlv(NFAPI_NR_NFAPI_P7_VNF_ADDRESS_IPV6_TAG, &(pNfapiMsg->nfapi_config.p7_vnf_address_ipv6), ppWritePackedMsg, end, &pack_ipv6_address_value) && pack_tlv(NFAPI_NR_NFAPI_P7_VNF_PORT_TAG, &(pNfapiMsg->nfapi_config.p7_vnf_port), ppWritePackedMsg, end, &pack_uint16_tlv_value) && - //pack_tlv(NFAPI_NR_NFAPI_RF_BANDS_TAG, &(pNfapiMsg->nfapi_config.rf_bands), ppWritePackedMsg, end, &pack_rf_bands_value) && - pack_tlv(NFAPI_NR_NFAPI_TIMING_INFO_MODE_TAG, &(pNfapiMsg->nfapi_config.timing_info_mode), ppWritePackedMsg, end, &pack_uint8_tlv_value) && - pack_tlv(NFAPI_NR_NFAPI_TIMING_INFO_PERIOD_TAG, &(pNfapiMsg->nfapi_config.timing_info_period), ppWritePackedMsg, end, &pack_uint8_tlv_value) && + pack_tlv(NFAPI_NR_NFAPI_P7_PNF_ADDRESS_IPV4_TAG, &(pNfapiMsg->nfapi_config.p7_pnf_address_ipv4), ppWritePackedMsg, end, &pack_ipv4_address_value) && + pack_tlv(NFAPI_NR_NFAPI_P7_PNF_ADDRESS_IPV6_TAG, &(pNfapiMsg->nfapi_config.p7_pnf_address_ipv6), ppWritePackedMsg, end, &pack_ipv6_address_value) && + pack_tlv(NFAPI_NR_NFAPI_P7_PNF_PORT_TAG, &(pNfapiMsg->nfapi_config.p7_pnf_port), ppWritePackedMsg, end, &pack_uint16_tlv_value) && pack_tlv(NFAPI_NR_NFAPI_TIMING_WINDOW_TAG, &(pNfapiMsg->nfapi_config.timing_window), ppWritePackedMsg, end, &pack_uint8_tlv_value) && - //pack_tlv(NFAPI_NR_NFAPI_UPLINK_UES_PER_SUBFRAME_TAG, &(pNfapiMsg->nfapi_config.ul_ue_per_sf), ppWritePackedMsg, end, &pack_uint8_tlv_value) && - - pack_vendor_extension_tlv(pNfapiMsg->vendor_extension, ppWritePackedMsg, end, config) ); + pack_tlv(NFAPI_NR_NFAPI_TIMING_INFO_MODE_TAG, &(pNfapiMsg->nfapi_config.timing_info_mode), ppWritePackedMsg, end, &pack_uint8_tlv_value) && + pack_tlv(NFAPI_NR_NFAPI_TIMING_INFO_PERIOD_TAG, &(pNfapiMsg->nfapi_config.timing_info_period), ppWritePackedMsg, end, &pack_uint8_tlv_value)); } static uint8_t pack_nr_config_response(void *msg, uint8_t **ppWritePackedMsg, uint8_t *end, nfapi_p4_p5_codec_config_t *config) { @@ -785,7 +777,7 @@ static uint8_t pack_nr_config_response(void *msg, uint8_t **ppWritePackedMsg, ui static uint8_t pack_config_response(void *msg, uint8_t **ppWritePackedMsg, uint8_t *end, nfapi_p4_p5_codec_config_t *config) { nfapi_config_response_t *pNfapiMsg = (nfapi_config_response_t *)msg; - return ( push8(pNfapiMsg->error_code, ppWritePackedMsg, end) && + return ( push32(pNfapiMsg->error_code, ppWritePackedMsg, end) && pack_vendor_extension_tlv(pNfapiMsg->vendor_extension, ppWritePackedMsg, end, config) ); } @@ -1036,7 +1028,7 @@ static uint8_t pack_p5_message_body(nfapi_p4_p5_message_header_t *header, uint8_ static uint32_t get_packed_msg_len(uintptr_t msgHead, uintptr_t msgEnd) { if (msgEnd < msgHead) { - NFAPI_TRACE(NFAPI_TRACE_ERROR, "get_packed_msg_len: Error in pointers supplied %d, %d\n", msgHead, msgEnd); + NFAPI_TRACE(NFAPI_TRACE_ERROR, "get_packed_msg_len: Error in pointers supplied %lu, %lu\n", msgHead, msgEnd); return 0; } @@ -1351,13 +1343,13 @@ static uint8_t unpack_nr_pnf_config_request(uint8_t **ppReadPackedMsg, uint8_t * } - static uint8_t unpack_pnf_config_request(uint8_t **ppReadPackedMsg, uint8_t *end, void *msg, nfapi_p4_p5_codec_config_t *config) { nfapi_pnf_config_request_t *pNfapiMsg = (nfapi_pnf_config_request_t *)msg; unpack_tlv_t unpack_fns[] = { { NFAPI_PNF_PHY_RF_TAG, &pNfapiMsg->pnf_phy_rf_config, &unpack_pnf_phy_rf_config_value}, }; - return unpack_tlv_list(unpack_fns, sizeof(unpack_fns)/sizeof(unpack_tlv_t), ppReadPackedMsg, end, config, &pNfapiMsg->vendor_extension); + return (pull8(ppReadPackedMsg, &pNfapiMsg->num_tlvs, end) && + unpack_tlv_list(unpack_fns, sizeof(unpack_fns)/sizeof(unpack_tlv_t), ppReadPackedMsg, end, config, &pNfapiMsg->vendor_extension)); } @@ -1723,6 +1715,7 @@ static uint8_t unpack_config_request(uint8_t **ppReadPackedMsg, uint8_t *end, vo return ( pull8(ppReadPackedMsg, &pNfapiMsg->num_tlv, end) && unpack_tlv_list(unpack_fns, sizeof(unpack_fns)/sizeof(unpack_tlv_t), ppReadPackedMsg, end, config, &pNfapiMsg->vendor_extension)); } + static uint8_t unpack_nr_config_request(uint8_t **ppReadPackedMsg, uint8_t *end, void *msg, nfapi_p4_p5_codec_config_t* config) { nfapi_nr_config_request_scf_t *pNfapiMsg = (nfapi_nr_config_request_scf_t*)msg; @@ -1732,13 +1725,14 @@ static uint8_t unpack_nr_config_request(uint8_t **ppReadPackedMsg, uint8_t *end, for(int i=0;i<40;i++) pNfapiMsg->tdd_table.max_tdd_periodicity_list[i].max_num_of_symbol_per_slot_list = (nfapi_nr_max_num_of_symbol_per_slot_t*) malloc(14*sizeof(nfapi_nr_max_num_of_symbol_per_slot_t)); - pNfapiMsg->prach_config.num_prach_fd_occasions_list=(nfapi_nr_num_prach_fd_occasions_t *) malloc(sizeof(nfapi_nr_num_prach_fd_occasions_t)); for(int i = 0; i < 40; i++){ //unpacking tdd slot config for(int symbol = 0; symbol<14;symbol++){ pull8(ppReadPackedMsg,&pNfapiMsg->tdd_table.max_tdd_periodicity_list[i].max_num_of_symbol_per_slot_list[symbol].slot_config.value, end); } } + pNfapiMsg->prach_config.num_prach_fd_occasions_list=(nfapi_nr_num_prach_fd_occasions_t *) malloc(sizeof(nfapi_nr_num_prach_fd_occasions_t)); + unpack_tlv_t unpack_fns[] = { { NFAPI_NR_CONFIG_DL_BANDWIDTH_TAG, &(pNfapiMsg->carrier_config.dl_bandwidth), &unpack_uint16_tlv_value}, @@ -1751,8 +1745,13 @@ static uint8_t unpack_nr_config_request(uint8_t **ppReadPackedMsg, uint8_t *end, { NFAPI_NR_CONFIG_UL_K0_TAG, &(pNfapiMsg->carrier_config.ul_k0[1]), &unpack_uint16_tlv_value}, { NFAPI_NR_CONFIG_UPLINK_BANDWIDTH_TAG, &(pNfapiMsg->carrier_config.uplink_bandwidth), &unpack_uint16_tlv_value}, { NFAPI_NR_CONFIG_UPLINK_FREQUENCY_TAG, &(pNfapiMsg->carrier_config.uplink_frequency), &unpack_uint32_tlv_value}, + { NFAPI_NR_CONFIG_FREQUENCY_SHIFT_7P5KHZ_TAG, &(pNfapiMsg->carrier_config.frequency_shift_7p5khz), &unpack_uint8_tlv_value}, + { NFAPI_NR_CONFIG_FRAME_DUPLEX_TYPE_TAG, &(pNfapiMsg->cell_config.frame_duplex_type), &unpack_uint8_tlv_value}, - { NFAPI_NR_CONFIG_PHY_CELL_ID_TAG, &(pNfapiMsg->cell_config.phy_cell_id), &unpack_uint8_tlv_value}, + { NFAPI_NR_CONFIG_PHY_CELL_ID_TAG, &(pNfapiMsg->cell_config.phy_cell_id), &unpack_uint16_tlv_value}, + + { NFAPI_NR_CONFIG_PRACH_MULTIPLE_CARRIERS_IN_A_BAND_TAG, &(pNfapiMsg->prach_config.prach_multiple_carriers_in_a_band), &unpack_uint8_tlv_value}, + { NFAPI_NR_CONFIG_PRACH_CONFIG_INDEX_TAG, &(pNfapiMsg->prach_config.prach_ConfigurationIndex), &unpack_uint8_tlv_value}, { NFAPI_NR_CONFIG_NUM_PRACH_FD_OCCASIONS_TAG, &(pNfapiMsg->prach_config.num_prach_fd_occasions), &unpack_uint8_tlv_value}, { NFAPI_NR_CONFIG_PRACH_SEQUENCE_LENGTH_TAG, &(pNfapiMsg->prach_config.prach_sequence_length), &unpack_uint8_tlv_value}, { NFAPI_NR_CONFIG_RESTRICTED_SET_CONFIG_TAG, &(pNfapiMsg->prach_config.restricted_set_config), &unpack_uint8_tlv_value}, @@ -1764,29 +1763,37 @@ static uint8_t unpack_nr_config_request(uint8_t **ppReadPackedMsg, uint8_t *end, { NFAPI_NR_CONFIG_NUM_ROOT_SEQUENCES_TAG, &(pNfapiMsg->prach_config.num_prach_fd_occasions_list[0].num_root_sequences), &unpack_uint8_tlv_value}, { NFAPI_NR_CONFIG_SCS_COMMON_TAG, &(pNfapiMsg->ssb_config.scs_common), &unpack_uint8_tlv_value}, + { NFAPI_NR_CONFIG_BCH_PAYLOAD_TAG, &(pNfapiMsg->ssb_config.bch_payload), &unpack_uint8_tlv_value}, { NFAPI_NR_CONFIG_SS_PBCH_POWER_TAG, &(pNfapiMsg->ssb_config.ss_pbch_power), &unpack_uint32_tlv_value}, + { NFAPI_NR_CONFIG_BETA_PSS_TAG, &(pNfapiMsg->ssb_table.beta_pss), &unpack_uint8_tlv_value}, { NFAPI_NR_CONFIG_MIB_TAG, &(pNfapiMsg->ssb_table.MIB), &unpack_uint32_tlv_value}, { NFAPI_NR_CONFIG_SSB_MASK_TAG, &(pNfapiMsg->ssb_table.ssb_mask_list[0].ssb_mask), &unpack_uint32_tlv_value}, - { NFAPI_NR_CONFIG_SSB_MASK_TAG, &(pNfapiMsg->ssb_table.ssb_mask_list[1].ssb_mask), &unpack_uint32_tlv_value}, - + // TODO: Not sure what's going on, ssb_mask_list[1] unpacking below seems to match pack, but is causing problems + // { NFAPI_NR_CONFIG_SSB_MASK_TAG, &(pNfapiMsg->ssb_table.ssb_mask_list[1].ssb_mask), &unpack_uint32_tlv_value}, + { NFAPI_NR_CONFIG_BEAM_ID_TAG, &(pNfapiMsg->ssb_table.ssb_beam_id_list[0].beam_id), &unpack_uint8_tlv_value}, { NFAPI_NR_CONFIG_SSB_OFFSET_POINT_A_TAG, &(pNfapiMsg->ssb_table.ssb_offset_point_a), &unpack_uint16_tlv_value}, { NFAPI_NR_CONFIG_SSB_PERIOD_TAG, &(pNfapiMsg->ssb_table.ssb_period), &unpack_uint8_tlv_value}, { NFAPI_NR_CONFIG_SSB_SUBCARRIER_OFFSET_TAG, &(pNfapiMsg->ssb_table.ssb_subcarrier_offset), &unpack_uint8_tlv_value}, + { NFAPI_NR_CONFIG_SS_PBCH_MULTIPLE_CARRIERS_IN_A_BAND_TAG, &(pNfapiMsg->ssb_table.ss_pbch_multiple_carriers_in_a_band), &unpack_uint8_tlv_value}, + { NFAPI_NR_CONFIG_MULTIPLE_CELLS_SS_PBCH_IN_A_CARRIER_TAG, &(pNfapiMsg->ssb_table.multiple_cells_ss_pbch_in_a_carrier), &unpack_uint8_tlv_value}, + { NFAPI_NR_CONFIG_TDD_PERIOD_TAG, &(pNfapiMsg->tdd_table.tdd_period), &unpack_uint8_tlv_value}, - { NFAPI_NR_NFAPI_P7_PNF_ADDRESS_IPV6_TAG, &(pNfapiMsg->nfapi_config.p7_pnf_address_ipv6), &unpack_ipv6_address_value}, - { NFAPI_NR_NFAPI_P7_PNF_PORT_TAG, &(pNfapiMsg->nfapi_config.p7_pnf_port), &unpack_uint16_tlv_value}, + { NFAPI_NR_NFAPI_P7_VNF_ADDRESS_IPV4_TAG, &(pNfapiMsg->nfapi_config.p7_vnf_address_ipv4), &unpack_ipv4_address_value}, { NFAPI_NR_NFAPI_P7_VNF_ADDRESS_IPV6_TAG, &(pNfapiMsg->nfapi_config.p7_vnf_address_ipv6), &unpack_ipv6_address_value}, { NFAPI_NR_NFAPI_P7_VNF_PORT_TAG, &(pNfapiMsg->nfapi_config.p7_vnf_port), &unpack_uint16_tlv_value}, + { NFAPI_NR_NFAPI_P7_PNF_ADDRESS_IPV4_TAG, &(pNfapiMsg->nfapi_config.p7_pnf_address_ipv4), &unpack_ipv4_address_value}, + { NFAPI_NR_NFAPI_P7_PNF_ADDRESS_IPV6_TAG, &(pNfapiMsg->nfapi_config.p7_pnf_address_ipv6), &unpack_ipv6_address_value}, + { NFAPI_NR_NFAPI_P7_PNF_PORT_TAG, &(pNfapiMsg->nfapi_config.p7_pnf_port), &unpack_uint16_tlv_value}, + { NFAPI_NR_NFAPI_TIMING_WINDOW_TAG, &(pNfapiMsg->nfapi_config.timing_window), &unpack_uint8_tlv_value}, { NFAPI_NR_NFAPI_TIMING_INFO_MODE_TAG, &(pNfapiMsg->nfapi_config.timing_info_mode), &unpack_uint8_tlv_value}, { NFAPI_NR_NFAPI_TIMING_INFO_PERIOD_TAG, &(pNfapiMsg->nfapi_config.timing_info_period), &unpack_uint8_tlv_value}, - { NFAPI_NR_NFAPI_TIMING_WINDOW_TAG, &(pNfapiMsg->nfapi_config.timing_window), &unpack_uint8_tlv_value}, }; return ( pull8(ppReadPackedMsg, &pNfapiMsg->num_tlv, end) && unpack_tlv_list(unpack_fns, sizeof(unpack_fns)/sizeof(unpack_tlv_t), ppReadPackedMsg, end, config, &pNfapiMsg->vendor_extension)); - + } static uint8_t unpack_config_response(uint8_t **ppReadPackedMsg, uint8_t *end, void *msg, nfapi_p4_p5_codec_config_t *config) { @@ -2386,3 +2393,4 @@ int nfapi_p5_message_unpack(void *pMessageBuf, uint32_t messageBufLen, void *pUn return result; } + diff --git a/nfapi/open-nFAPI/nfapi/src/nfapi_p7.c b/nfapi/open-nFAPI/nfapi/src/nfapi_p7.c index 7cb74f8562c34ac307659fad66bab82dddad5eee..0e43c803e75a26f31632e8c605f346c3d4775f82 100644 --- a/nfapi/open-nFAPI/nfapi/src/nfapi_p7.c +++ b/nfapi/open-nFAPI/nfapi/src/nfapi_p7.c @@ -223,7 +223,6 @@ static uint8_t pack_dl_tti_csi_rs_pdu_rel15_value(void *tlv, uint8_t **ppWritePa static uint8_t pack_dl_tti_pdcch_pdu_rel15_value(void* tlv, uint8_t **ppWritePackedMsg, uint8_t *end) { nfapi_nr_dl_tti_pdcch_pdu_rel15_t* value = (nfapi_nr_dl_tti_pdcch_pdu_rel15_t*)tlv; - for(uint8_t i = 0; i < MAX_DCI_CORESET; ++i) { if(!(push16(value->dci_pdu[i].RNTI, ppWritePackedMsg, end) && @@ -236,7 +235,6 @@ static uint8_t pack_dl_tti_pdcch_pdu_rel15_value(void* tlv, uint8_t **ppWritePac push16(value->dci_pdu[i].PayloadSizeBits, ppWritePackedMsg, end) && pusharray8(value->dci_pdu[i].Payload, value->dci_pdu[i].PayloadSizeBits, value->dci_pdu[i].PayloadSizeBits, ppWritePackedMsg, end))) return 0; - } // TODO: resolve the packaging of array (currently sending a single element) return( @@ -300,17 +298,21 @@ static uint8_t pack_dl_tti_pdsch_pdu_rel15_value(void *tlv, uint8_t **ppWritePac static uint8_t pack_dl_tti_ssb_pdu_rel15_value(void *tlv, uint8_t **ppWritePackedMsg, uint8_t *end) { - nfapi_nr_dl_tti_ssb_pdu_rel15_t *value = (nfapi_nr_dl_tti_ssb_pdu_rel15_t *)tlv; - return( - push16(value->PhysCellId, ppWritePackedMsg, end) && - push8(value->BetaPss, ppWritePackedMsg, end) && - push8(value->SsbBlockIndex, ppWritePackedMsg, end) && - push8(value->SsbSubcarrierOffset, ppWritePackedMsg, end) && - push16(value->ssbOffsetPointA, ppWritePackedMsg, end) && - push8(value->bchPayloadFlag, ppWritePackedMsg, end) && - push32(value->bchPayload, ppWritePackedMsg, end) - // TODO: pack precoding_and_beamforming too - ); + NFAPI_TRACE(NFAPI_TRACE_DEBUG, "Packing ssb. \n"); + nfapi_nr_dl_tti_ssb_pdu_rel15_t* value = (nfapi_nr_dl_tti_ssb_pdu_rel15_t*)tlv; + + return( + push16(value->PhysCellId, ppWritePackedMsg, end) && + push8(value->BetaPss, ppWritePackedMsg, end) && + push8(value->SsbBlockIndex, ppWritePackedMsg, end) && + push8(value->SsbSubcarrierOffset, ppWritePackedMsg, end) && + push16(value->ssbOffsetPointA, ppWritePackedMsg, end) && + push8(value->bchPayloadFlag, ppWritePackedMsg, end) && + push32(value->bchPayload, ppWritePackedMsg, end) && + push8(value->ssbRsrp, ppWritePackedMsg, end) + // TODO: pack precoding_and_beamforming too + ); + } @@ -778,38 +780,41 @@ static uint8_t pack_dl_config_request_body_value(void *tlv, uint8_t **ppWritePac } -static uint8_t pack_dl_tti_request(void *msg, uint8_t **ppWritePackedMsg, uint8_t *end, nfapi_p7_codec_config_t *config) { - nfapi_nr_dl_tti_request_t *pNfapiMsg = (nfapi_nr_dl_tti_request_t *)msg; - - if (!(push16(pNfapiMsg->SFN, ppWritePackedMsg, end) && - push16(pNfapiMsg->Slot, ppWritePackedMsg, end) && - push8(pNfapiMsg->dl_tti_request_body.nGroup, ppWritePackedMsg, end) && - push8(pNfapiMsg->dl_tti_request_body.nPDUs, ppWritePackedMsg, end) && - pusharray8(pNfapiMsg->dl_tti_request_body.nUe,256,pNfapiMsg->dl_tti_request_body.nGroup, ppWritePackedMsg, end) - //pusharray8(pNfapiMsg->PduIdx[0] ,256,256, ppWritePackedMsg, end) - )) - return 0; - - int arr[12]; - - for(int i=0; i<pNfapiMsg->dl_tti_request_body.nGroup; i++) { - for(int j=0; j<pNfapiMsg->dl_tti_request_body.nUe[i]; j++) { - arr[j] = pNfapiMsg->dl_tti_request_body.PduIdx[i][j]; - } +static uint8_t pack_dl_tti_request(void *msg, uint8_t **ppWritePackedMsg, uint8_t *end, nfapi_p7_codec_config_t* config) +{ + nfapi_nr_dl_tti_request_t *pNfapiMsg = (nfapi_nr_dl_tti_request_t*)msg; + + if (!(push16(pNfapiMsg->SFN , ppWritePackedMsg, end) && + push16(pNfapiMsg->Slot , ppWritePackedMsg, end) && + push8(pNfapiMsg->dl_tti_request_body.nGroup , ppWritePackedMsg, end) && + push8(pNfapiMsg->dl_tti_request_body.nPDUs , ppWritePackedMsg, end) && + pusharray8(pNfapiMsg->dl_tti_request_body.nUe, 256, pNfapiMsg->dl_tti_request_body.nGroup, ppWritePackedMsg, end) + //pusharray8(pNfapiMsg->PduIdx[0] ,256,256, ppWritePackedMsg, end) + )) + return 0; - if(!(pusharrays32(arr,12,pNfapiMsg->dl_tti_request_body.nUe[i],ppWritePackedMsg, end))) - return 0; - } + int arr[12]; + for(int i=0;i<pNfapiMsg->dl_tti_request_body.nGroup;i++) + { + for(int j=0;j<pNfapiMsg->dl_tti_request_body.nUe[i];j++) + { + arr[j] = pNfapiMsg->dl_tti_request_body.PduIdx[i][j]; + } + if(!(pusharrays32(arr, 12, pNfapiMsg->dl_tti_request_body.nUe[i], ppWritePackedMsg, end))) + return 0; + } - for(int i=0; i<pNfapiMsg->dl_tti_request_body.nPDUs; i++) { - if(!pack_dl_tti_request_body_value(&pNfapiMsg->dl_tti_request_body.dl_tti_pdu_list[i],ppWritePackedMsg,end)) - return 0; - } + for(int i=0;i<pNfapiMsg->dl_tti_request_body.nPDUs;i++) + { + if(!pack_dl_tti_request_body_value(&pNfapiMsg->dl_tti_request_body.dl_tti_pdu_list[i],ppWritePackedMsg,end)) + return 0; + } - return 1; +return 1; } + static uint8_t pack_dl_config_request(void *msg, uint8_t **ppWritePackedMsg, uint8_t *end, nfapi_p7_codec_config_t *config) { nfapi_dl_config_request_t *pNfapiMsg = (nfapi_dl_config_request_t *)msg; //return ( push16(pNfapiMsg->sfn_sf, ppWritePackedMsg, end) && @@ -902,6 +907,7 @@ static uint8_t pack_ul_tti_request_pucch_pdu(nfapi_nr_pucch_pdu_t *pucch_pdu, ui push8(pucch_pdu->cyclic_prefix, ppWritePackedMsg, end) && push8(pucch_pdu->format_type, ppWritePackedMsg, end) && push8(pucch_pdu->multi_slot_tx_indicator, ppWritePackedMsg, end) && + push8(pucch_pdu->pi_2bpsk, ppWritePackedMsg, end) && push16(pucch_pdu->prb_start, ppWritePackedMsg, end) && push16(pucch_pdu->prb_size, ppWritePackedMsg, end) && push8(pucch_pdu->start_symbol_index, ppWritePackedMsg, end) && @@ -1803,7 +1809,6 @@ static uint8_t pack_hi_dci0_request_body_value(void *tlv, uint8_t **ppWritePacke static uint8_t pack_ul_dci_pdu_list_value(void* tlv, uint8_t **ppWritePackedMsg, uint8_t *end) { nfapi_nr_ul_dci_request_pdus_t* value = (nfapi_nr_ul_dci_request_pdus_t*)tlv; - for(uint8_t i = 0; i < MAX_DCI_CORESET; ++i) { if(!(push16(value->pdcch_pdu.pdcch_pdu_rel15.dci_pdu[i].RNTI, ppWritePackedMsg, end) && @@ -1816,7 +1821,6 @@ static uint8_t pack_ul_dci_pdu_list_value(void* tlv, uint8_t **ppWritePackedMsg, push8(value->pdcch_pdu.pdcch_pdu_rel15.dci_pdu[i].powerControlOffsetSS, ppWritePackedMsg, end) && push16(value->pdcch_pdu.pdcch_pdu_rel15.dci_pdu[i].PayloadSizeBits, ppWritePackedMsg, end) && - pusharray8(value->pdcch_pdu.pdcch_pdu_rel15.dci_pdu[i].Payload, value->pdcch_pdu.pdcch_pdu_rel15.dci_pdu[i].PayloadSizeBits, value->pdcch_pdu.pdcch_pdu_rel15.dci_pdu[i].PayloadSizeBits, ppWritePackedMsg, end))) return 0; @@ -2263,6 +2267,7 @@ static uint8_t pack_crc_indication_body_value(void *tlv, uint8_t **ppWritePacked uint16_t i = 0; uint16_t total_number_of_pdus = value->number_of_crcs; + assert(total_number_of_pdus <= NFAPI_CRC_IND_MAX_PDU); for(; i < total_number_of_pdus; ++i) { nfapi_crc_indication_pdu_t *pdu = &(value->crc_pdu_list[i]); uint8_t *instance_length_p = *ppWritePackedMsg; @@ -2304,7 +2309,7 @@ static uint8_t pack_rx_indication_rel9_value(void *tlv, uint8_t **ppWritePackedM static uint8_t pack_rx_ulsch_indication_body_value(void *tlv, uint8_t **ppWritePackedMsg, uint8_t *end) { nfapi_rx_indication_body_t *value = (nfapi_rx_indication_body_t *)tlv; - //printf("RX ULSCH BODY\n"); + //NFAPI_TRACE(NFAPI_TRACE_DEBUG, "RX ULSCH BODY\n"); if( push16(value->number_of_pdus, ppWritePackedMsg, end) == 0) return 0; @@ -2313,28 +2318,30 @@ static uint8_t pack_rx_ulsch_indication_body_value(void *tlv, uint8_t **ppWriteP uint16_t i = 0; uint16_t offset = 2; // taking into account the number_of_pdus uint16_t total_number_of_pdus = value->number_of_pdus; - //printf("ULSCH:pdus:%d\n", total_number_of_pdus); + //NFAPI_TRACE(NFAPI_TRACE_DEBUG, "ULSCH:pdus:%d\n", total_number_of_pdus); + assert(total_number_of_pdus <= NFAPI_RX_IND_MAX_PDU); for(i = 0; i < total_number_of_pdus; ++i) { nfapi_rx_indication_pdu_t *pdu = &(value->rx_pdu_list[i]); if(pdu->rx_ue_information.tl.tag == NFAPI_RX_UE_INFORMATION_TAG) { - //printf("NFAPI_RX_UE_INFORMATION_TAG\n"); + //NFAPI_TRACE(NFAPI_TRACE_DEBUG, "NFAPI_RX_UE_INFORMATION_TAG\n"); offset += 4 + 6; } if(pdu->rx_indication_rel8.tl.tag == NFAPI_RX_INDICATION_REL8_TAG) { - //printf("NFAPI_RX_INDICATION_REL8_TAG\n"); + //NFAPI_TRACE(NFAPI_TRACE_DEBUG, "NFAPI_RX_INDICATION_REL8_TAG\n"); offset += 4 + 7; } if(pdu->rx_indication_rel9.tl.tag == NFAPI_RX_INDICATION_REL9_TAG) { - //printf("NFAPI_RX_INDICATION_REL9_TAG\n"); + //NFAPI_TRACE(NFAPI_TRACE_DEBUG, "NFAPI_RX_INDICATION_REL9_TAG\n"); offset += 4 + 2; } } // Now update the structure to include the offset + assert(total_number_of_pdus <= NFAPI_RX_IND_MAX_PDU); for(i =0; i < total_number_of_pdus; ++i) { nfapi_rx_indication_pdu_t *pdu = &(value->rx_pdu_list[i]); @@ -2347,6 +2354,7 @@ static uint8_t pack_rx_ulsch_indication_body_value(void *tlv, uint8_t **ppWriteP } // Write out the pdu + assert(total_number_of_pdus <= NFAPI_RX_IND_MAX_PDU); for(i = 0; i < total_number_of_pdus; ++i) { nfapi_rx_indication_pdu_t *pdu = &(value->rx_pdu_list[i]); @@ -2357,6 +2365,7 @@ static uint8_t pack_rx_ulsch_indication_body_value(void *tlv, uint8_t **ppWriteP } // Write out the pdu data + assert(total_number_of_pdus <= NFAPI_RX_IND_MAX_PDU); for(i = 0; i < total_number_of_pdus; ++i) { uint16_t length = 0; nfapi_rx_indication_pdu_t *pdu = &(value->rx_pdu_list[i]); @@ -2365,7 +2374,7 @@ static uint8_t pack_rx_ulsch_indication_body_value(void *tlv, uint8_t **ppWriteP length = pdu->rx_indication_rel8.length; } - if( pusharray8(value->rx_pdu_list[i].data, length, length, ppWritePackedMsg, end) == 0) + if( pusharray8(value->rx_pdu_list[i].rx_ind_data, NFAPI_RX_IND_DATA_MAX, length, ppWritePackedMsg, end) == 0) return 0; } @@ -2584,6 +2593,7 @@ static uint8_t pack_cqi_indication_body_value(void *tlv, uint8_t **ppWritePacked uint16_t offset = 2; // taking into account the number_of_cqis uint16_t total_number_of_pdus = value->number_of_cqis; + assert(total_number_of_pdus <= NFAPI_CQI_IND_MAX_PDU); for(i = 0; i < total_number_of_pdus; ++i) { nfapi_cqi_indication_pdu_t *pdu = &(value->cqi_pdu_list[i]); offset += 2; // for the instance length @@ -2625,6 +2635,7 @@ static uint8_t pack_cqi_indication_body_value(void *tlv, uint8_t **ppWritePacked } // Write out the cqi information + assert(total_number_of_pdus <= NFAPI_CQI_IND_MAX_PDU); for(i = 0; i < total_number_of_pdus; ++i) { nfapi_cqi_indication_pdu_t *pdu = &(value->cqi_pdu_list[i]); uint8_t *instance_length_p = *ppWritePackedMsg; @@ -2645,6 +2656,7 @@ static uint8_t pack_cqi_indication_body_value(void *tlv, uint8_t **ppWritePacked } // Write out the cqi raw data + assert(total_number_of_pdus <= NFAPI_CQI_IND_MAX_PDU); for(i = 0; i < total_number_of_pdus; ++i) { uint16_t length = 0; nfapi_cqi_indication_pdu_t *pdu = &(value->cqi_pdu_list[i]); @@ -3008,7 +3020,10 @@ static uint8_t pack_nr_rx_data_indication_body(void* tlv, uint8_t **ppWritePacke push16(value->timing_advance, ppWritePackedMsg, end) && push16(value->rssi, ppWritePackedMsg, end) )) - return 0; + return 0; + + if(pusharray8(value->pdu, value->pdu_length, value->pdu_length, ppWritePackedMsg, end) == 0) + return 0; return 1; } @@ -3022,22 +3037,21 @@ static uint8_t pack_nr_rx_data_indication(void *msg, uint8_t **ppWritePackedMsg, push16(pNfapiMsg->slot , ppWritePackedMsg, end) && push16(pNfapiMsg->number_of_pdus, ppWritePackedMsg, end) )) - return 0; + return 0; - for(int i=0; i<pNfapiMsg->number_of_pdus;i++) + for (int i = 0; i < pNfapiMsg->number_of_pdus; i++) { - if(!pack_nr_rx_data_indication_body(pNfapiMsg->pdu_list,ppWritePackedMsg,end)) - return 0; + if(!pack_nr_rx_data_indication_body(&(pNfapiMsg->pdu_list[i]), ppWritePackedMsg, end)) + return 0; } -return 1; + return 1; } //NR CRC INDICATION -static uint8_t pack_nr_crc_indication_body(void* tlv, uint8_t **ppWritePackedMsg, uint8_t *end) +static uint8_t pack_nr_crc_indication_body(nfapi_nr_crc_t* value, uint8_t **ppWritePackedMsg, uint8_t *end) { - nfapi_nr_crc_t* value = (nfapi_nr_crc_t*)tlv; if(!(push32(value->handle, ppWritePackedMsg, end) && push16(value->rnti, ppWritePackedMsg, end) && @@ -3064,9 +3078,9 @@ static uint8_t pack_nr_crc_indication(void *msg, uint8_t **ppWritePackedMsg, uin )) return 0; - for(int i=0; i<pNfapiMsg->number_crcs;i++) + for (int i = 0; i < pNfapiMsg->number_crcs; i++) { - if(!pack_nr_crc_indication_body(pNfapiMsg->crc_list,ppWritePackedMsg,end)) + if(!pack_nr_crc_indication_body(&pNfapiMsg->crc_list[i], ppWritePackedMsg, end)) return 0; } @@ -3133,9 +3147,9 @@ static uint8_t pack_nr_rach_indication_body(void* tlv, uint8_t **ppWritePackedMs return 0; for(int i = 0; i < value->num_preamble; i++) { - if(!(push8(value->preamble_list->preamble_index, ppWritePackedMsg, end) && - push16(value->preamble_list->timing_advance, ppWritePackedMsg, end) && - push32(value->preamble_list->preamble_pwr, ppWritePackedMsg, end) + if(!(push8(value->preamble_list[i].preamble_index, ppWritePackedMsg, end) && + push16(value->preamble_list[i].timing_advance, ppWritePackedMsg, end) && + push32(value->preamble_list[i].preamble_pwr, ppWritePackedMsg, end) )) return 0; } @@ -3177,23 +3191,22 @@ static uint8_t pack_nr_uci_pucch_0_1(void* tlv, uint8_t **ppWritePackedMsg, uint )) return 0; if (value->pduBitmap & 0x01) { //SR - if(!(push8(value->sr->sr_indication, ppWritePackedMsg, end) && - push8(value->sr->sr_confidence_level, ppWritePackedMsg, end) + if (!(push8(value->sr->sr_indication, ppWritePackedMsg, end) && + push8(value->sr->sr_confidence_level, ppWritePackedMsg, end) )) return 0; } if (((value->pduBitmap >> 1) & 0x01)) { //HARQ - if(!(push8(value->harq->num_harq, ppWritePackedMsg, end) && - push8(value->harq->harq_confidence_level, ppWritePackedMsg, end) + if (!(push8(value->harq->num_harq, ppWritePackedMsg, end) && + push8(value->harq->harq_confidence_level, ppWritePackedMsg, end) )) return 0; - - for(int i=0; i<value->harq->num_harq;i++) + for (int i = 0; i < value->harq->num_harq; i++) { - if(!(push8(value->harq->harq_list[i].harq_value, ppWritePackedMsg, end) + if (!(push8(value->harq->harq_list[i].harq_value, ppWritePackedMsg, end) )) - return 0; + return 0; } } @@ -3258,7 +3271,7 @@ static uint8_t pack_nr_uci_indication_body(void* tlv, uint8_t **ppWritePackedMsg switch (value->pdu_type) { case NFAPI_NR_UCI_PUSCH_PDU_TYPE: - printf("Unhandled NFAPI_NR_UCI_PUSCH_PDU_TYPE \n"); + NFAPI_TRACE(NFAPI_TRACE_WARN, "Unhandled NFAPI_NR_UCI_PUSCH_PDU_TYPE \n"); break; case NFAPI_NR_UCI_FORMAT_0_1_PDU_TYPE: @@ -3285,8 +3298,9 @@ static uint8_t pack_nr_uci_indication(void *msg, uint8_t **ppWritePackedMsg, uin for(int i=0; i<pNfapiMsg->num_ucis;i++) { - if(!pack_nr_uci_indication_body(pNfapiMsg->uci_list,ppWritePackedMsg,end)) - return 0; + if (!pack_nr_uci_indication_body(&pNfapiMsg->uci_list[i], ppWritePackedMsg, end)) + return 0; + } return 1; @@ -3307,13 +3321,6 @@ int nfapi_nr_p7_message_pack(void *pMessageBuf, void *pPackedBuf, uint32_t packe NFAPI_TRACE(NFAPI_TRACE_ERROR, "P7 Pack supplied pointers are null\n"); return -1; } - /* - printf("\n P7 MESSAGE SENT: \n"); - for(int i=0; i< packedBufLen; i++){ - printf("%d", *(uint8_t *)(pMessageBuf + i)); - } - printf("\n"); - */ // process the header if(!(push16(pMessageHeader->phy_id, &pWritePackedMessage, end) && push16(pMessageHeader->message_id, &pWritePackedMessage, end) && @@ -3349,7 +3356,6 @@ int nfapi_nr_p7_message_pack(void *pMessageBuf, void *pPackedBuf, uint32_t packe case NFAPI_NR_PHY_MSG_TYPE_UL_DCI_REQUEST: result = pack_ul_dci_request(pMessageHeader, &pWritePackedMessage, end, config); break; - case NFAPI_UE_RELEASE_REQUEST: result =pack_ue_release_request(pMessageHeader, &pWritePackedMessage, end, config); break; @@ -3465,13 +3471,6 @@ int nfapi_p7_message_pack(void *pMessageBuf, void *pPackedBuf, uint32_t packedBu return -1; } - /* - printf("\n P7 MESSAGE SENT: \n"); - for(int i=0; i< packedBufLen; i++){ - printf("%d", *(uint8_t *)(pMessageBuf + i)); - } - printf("\n"); - */ // process the header if(!(push16(pMessageHeader->phy_id, &pWritePackedMessage, end) && push16(pMessageHeader->message_id, &pWritePackedMessage, end) && @@ -3651,7 +3650,6 @@ static uint8_t unpack_dl_tti_csi_rs_pdu_rel15_value(void *tlv, uint8_t **ppReadP static uint8_t unpack_dl_tti_pdcch_pdu_rel15_value(void* tlv, uint8_t **ppReadPackedMsg, uint8_t *end) { nfapi_nr_dl_tti_pdcch_pdu_rel15_t* value = (nfapi_nr_dl_tti_pdcch_pdu_rel15_t*)tlv; - for(uint8_t i = 0; i < MAX_DCI_CORESET; ++i) { if(!(pull16(ppReadPackedMsg, &value->dci_pdu[i].RNTI, end) && @@ -3738,7 +3736,8 @@ static uint8_t unpack_dl_tti_ssb_pdu_rel15_value(void *tlv, uint8_t **ppReadPack pull8(ppReadPackedMsg, &value->SsbSubcarrierOffset, end) && pull16(ppReadPackedMsg, &value->ssbOffsetPointA, end) && pull8(ppReadPackedMsg, &value->bchPayloadFlag, end) && - pull32(ppReadPackedMsg, &value->bchPayload, end) + pull32(ppReadPackedMsg, &value->bchPayload, end) && + pull8(ppReadPackedMsg, &value->ssbRsrp, end) // TODO: pack precoding_and_beamforming too ); } @@ -4404,6 +4403,7 @@ static uint8_t unpack_ul_tti_request_pucch_pdu(void *tlv, uint8_t **ppReadPacked pull8(ppReadPackedMsg, &pucch_pdu->cyclic_prefix, end) && pull8(ppReadPackedMsg, &pucch_pdu->format_type, end) && pull8(ppReadPackedMsg, &pucch_pdu->multi_slot_tx_indicator, end) && + pull8(ppReadPackedMsg, &pucch_pdu->pi_2bpsk, end) && pull16(ppReadPackedMsg, &pucch_pdu->prb_start, end) && pull16(ppReadPackedMsg, &pucch_pdu->prb_size, end) && pull8(ppReadPackedMsg, &pucch_pdu->start_symbol_index, end) && @@ -4548,7 +4548,7 @@ static uint8_t unpack_ul_tti_request_srs_pdu(void *tlv, uint8_t **ppReadPackedMs pull8(ppReadPackedMsg, &srs_pdu->comb_offset, end) && pull8(ppReadPackedMsg, &srs_pdu->cyclic_shift, end) && pull8(ppReadPackedMsg, &srs_pdu->frequency_position, end) && - pull8(ppReadPackedMsg, &srs_pdu->frequency_shift, end) && + pull16(ppReadPackedMsg, &srs_pdu->frequency_shift, end) && pull8(ppReadPackedMsg, &srs_pdu->frequency_hopping, end) && pull8(ppReadPackedMsg, &srs_pdu->group_or_sequence_hopping, end) && pull8(ppReadPackedMsg, &srs_pdu->resource_type, end) && @@ -5364,7 +5364,7 @@ static uint8_t unpack_hi_dci0_request_body_value(void *tlv, uint8_t **ppReadPack if(packedPduEnd > end) { // pdu end if past buffer end - NFAPI_TRACE(NFAPI_TRACE_ERROR, "%s pdu size to big %d %d\n", __FUNCTION__, packedPduEnd, end); + NFAPI_TRACE(NFAPI_TRACE_ERROR, "%s pdu size to big %p %p\n", __FUNCTION__, packedPduEnd, end); return 0; } @@ -5464,7 +5464,6 @@ static uint8_t unpack_ul_dci_pdu_list_value(uint8_t **ppReadPackedMsg, uint8_t * pull16(ppReadPackedMsg, &value->pdcch_pdu.pdcch_pdu_rel15.ShiftIndex, end) && pull8(ppReadPackedMsg, &value->pdcch_pdu.pdcch_pdu_rel15.precoderGranularity, end) && pull16(ppReadPackedMsg, &value->pdcch_pdu.pdcch_pdu_rel15.numDlDci, end)); - } static uint8_t unpack_ul_dci_request(uint8_t **ppReadPackedMsg, uint8_t *end, void *msg, nfapi_p7_codec_config_t *config) { @@ -5654,12 +5653,13 @@ static uint8_t unpack_nr_slot_indication(uint8_t **ppReadPackedMsg, uint8_t *end return 1; } -//RX DATA INDICATION +//RX DATA INDICATION -static uint8_t unpack_nr_rx_data_indication_body(void* tlv, uint8_t **ppReadPackedMsg, uint8_t *end) +static uint8_t unpack_nr_rx_data_indication_body(nfapi_nr_rx_data_pdu_t* value, + uint8_t **ppReadPackedMsg, + uint8_t *end, + nfapi_p7_codec_config_t* config) { - nfapi_nr_rx_data_pdu_t* value = (nfapi_nr_rx_data_pdu_t*)tlv; - if(!(pull32(ppReadPackedMsg, &value->handle, end) && pull16(ppReadPackedMsg, &value->rnti, end) && pull8(ppReadPackedMsg, &value->harq_id, end) && @@ -5668,7 +5668,16 @@ static uint8_t unpack_nr_rx_data_indication_body(void* tlv, uint8_t **ppReadPack pull16(ppReadPackedMsg, &value->timing_advance, end) && pull16(ppReadPackedMsg, &value->rssi, end) )) - return 0; + return 0; + + uint16_t length = value->pdu_length; + value->pdu = nfapi_p7_allocate(length, config); + + if (pullarray8(ppReadPackedMsg, value->pdu, length, length, end) == 0) + { + NFAPI_TRACE(NFAPI_TRACE_ERROR, "%s pullarray8 failure\n", __FUNCTION__); + return 0; + } return 1; } @@ -5682,10 +5691,14 @@ static uint8_t unpack_nr_rx_data_indication(uint8_t **ppReadPackedMsg, uint8_t * pull16(ppReadPackedMsg, &pNfapiMsg->number_of_pdus, end) )) return 0; + if (pNfapiMsg->number_of_pdus > 0) + { + pNfapiMsg->pdu_list = nfapi_p7_allocate(sizeof(*pNfapiMsg->pdu_list) * pNfapiMsg->number_of_pdus, config); + } - for(int i=0; i<pNfapiMsg->number_of_pdus;i++) + for (int i = 0; i < pNfapiMsg->number_of_pdus; i++) { - if(!unpack_nr_rx_data_indication_body(pNfapiMsg->pdu_list, ppReadPackedMsg, end)) + if(!unpack_nr_rx_data_indication_body(&pNfapiMsg->pdu_list[i], ppReadPackedMsg, end, config)) return 0; } @@ -5715,21 +5728,23 @@ static uint8_t unpack_nr_crc_indication_body(nfapi_nr_crc_t* value, uint8_t **pp static uint8_t unpack_nr_crc_indication(uint8_t **ppReadPackedMsg, uint8_t *end, nfapi_nr_crc_indication_t *msg, nfapi_p7_codec_config_t* config) { - nfapi_nr_crc_indication_t *pNfapiMsg = (nfapi_nr_crc_indication_t *) msg; - // pNfapiMsg = (nfapi_nr_crc_indication_t *) malloc(sizeof(nfapi_nr_crc_indication_t)); - // pNfapiMsg->crc_list = (nfapi_nr_crc_t *) malloc(sizeof(nfapi_nr_crc_t)); + nfapi_nr_crc_indication_t *pNfapiMsg = (nfapi_nr_crc_indication_t*)msg; - if (!(pull16(ppReadPackedMsg, &pNfapiMsg->sfn, end) && - pull16(ppReadPackedMsg, &pNfapiMsg->slot, end) && + if (!(pull16(ppReadPackedMsg, &pNfapiMsg->sfn , end) && + pull16(ppReadPackedMsg, &pNfapiMsg->slot , end) && pull16(ppReadPackedMsg, &pNfapiMsg->number_crcs, end) )) - return 0; + return 0; + + if (pNfapiMsg->number_crcs > 0) + { + pNfapiMsg->crc_list = nfapi_p7_allocate(sizeof(*pNfapiMsg->crc_list) * pNfapiMsg->number_crcs, config); + } - for(int i=0; i<pNfapiMsg->number_crcs;i++) + for (int i = 0; i < pNfapiMsg->number_crcs; i++) { - if(!unpack_nr_crc_indication_body(pNfapiMsg->crc_list,ppReadPackedMsg,end)) - //if(!unpack_nr_crc_indication_body(value,ppReadPackedMsg,end)) - return 0; + if(!unpack_nr_crc_indication_body(&pNfapiMsg->crc_list[i], ppReadPackedMsg, end)) + return 0; } return 1; @@ -5780,9 +5795,11 @@ return 1; //NR RACH -static uint8_t unpack_nr_rach_indication_body(nfapi_nr_prach_indication_pdu_t* tlv, uint8_t **ppReadPackedMsg, uint8_t *end) +static uint8_t unpack_nr_rach_indication_body(nfapi_nr_prach_indication_pdu_t* value, + uint8_t **ppReadPackedMsg, + uint8_t *end, + nfapi_p7_codec_config_t* config) { - nfapi_nr_prach_indication_pdu_t* value = (nfapi_nr_prach_indication_pdu_t*)tlv; if(!(pull16(ppReadPackedMsg, &value->phy_cell_id, end) && pull8(ppReadPackedMsg, &value->symbol_index, end) && @@ -5793,15 +5810,18 @@ static uint8_t unpack_nr_rach_indication_body(nfapi_nr_prach_indication_pdu_t* t pull8(ppReadPackedMsg, &value->num_preamble, end) )) return 0; - value->preamble_list = (nfapi_nr_prach_indication_preamble_t*) malloc(sizeof(nfapi_nr_prach_indication_preamble_t) * value->num_preamble); - for(int i = 0; i < value->num_preamble; i++) - { - if(!(pull8(ppReadPackedMsg, &value->preamble_list->preamble_index, end) && - pull16(ppReadPackedMsg, &value->preamble_list->timing_advance, end) && - pull32(ppReadPackedMsg, &value->preamble_list->preamble_pwr, end) - )) - return 0; - } + + if (value->num_preamble > 0) { + value->preamble_list = nfapi_p7_allocate(sizeof(*value->preamble_list) * value->num_preamble, config); + for(int i = 0; i < value->num_preamble; i++) + { + if(!(pull8(ppReadPackedMsg, &value->preamble_list[i].preamble_index, end) && + pull16(ppReadPackedMsg, &value->preamble_list[i].timing_advance, end) && + pull32(ppReadPackedMsg, &value->preamble_list[i].preamble_pwr, end) + )) + return 0; + } + } return 1; } @@ -5812,31 +5832,27 @@ static uint8_t unpack_nr_rach_indication(uint8_t **ppReadPackedMsg, uint8_t *end pull16(ppReadPackedMsg, &pNfapiMsg->slot , end) && pull8(ppReadPackedMsg, &pNfapiMsg->number_of_pdus, end) )) - return 0; - pNfapiMsg->pdu_list = (nfapi_nr_prach_indication_pdu_t*) malloc(sizeof(nfapi_nr_prach_indication_pdu_t) * pNfapiMsg->number_of_pdus); - for(int i=0; i< pNfapiMsg->number_of_pdus;i++) - { - if(!unpack_nr_rach_indication_body(pNfapiMsg->pdu_list,ppReadPackedMsg,end)) return 0; - } -return 1; + if (pNfapiMsg->number_of_pdus > 0) { + pNfapiMsg->pdu_list = nfapi_p7_allocate(sizeof(*pNfapiMsg->pdu_list) * pNfapiMsg->number_of_pdus, config); + for(int i = 0; i < pNfapiMsg->number_of_pdus; i++) + { + if(!unpack_nr_rach_indication_body(&pNfapiMsg->pdu_list[i], ppReadPackedMsg, end, config)) + return 0; + } + } + return 1; } -//NR UCI - -static uint8_t unpack_nr_uci_pucch_0_1(nfapi_nr_uci_pucch_pdu_format_0_1_t* tlv, uint8_t **ppReadPackedMsg, uint8_t *end) { - nfapi_nr_uci_pucch_pdu_format_0_1_t* value = (nfapi_nr_uci_pucch_pdu_format_0_1_t*)tlv; +//NR UCI - // uint8_t *ptr = *ppReadPackedMsg; - // printf("\n Read P7 message uci_0_1 indication unpack: "); - // while(ptr < end){ - // printf(" %d ", *ptr); - // ptr++; - // } - // printf("\n"); +static uint8_t unpack_nr_uci_pucch_0_1(nfapi_nr_uci_pucch_pdu_format_0_1_t *value, + uint8_t **ppReadPackedMsg, + uint8_t *end, + nfapi_p7_codec_config_t *config) { - if(!(pull8(ppReadPackedMsg, &value->pduBitmap, end) && + if (!(pull8(ppReadPackedMsg, &value->pduBitmap, end) && pull32(ppReadPackedMsg, &value->handle, end) && pull16(ppReadPackedMsg, &value->rnti, end) && pull8(ppReadPackedMsg, &value->pucch_format, end) && @@ -5846,26 +5862,45 @@ static uint8_t unpack_nr_uci_pucch_0_1(nfapi_nr_uci_pucch_pdu_format_0_1_t* tlv, )) return 0; if (value->pduBitmap & 0x01) { //SR - value->sr = (nfapi_nr_sr_pdu_0_1_t*) malloc(sizeof(nfapi_nr_sr_pdu_0_1_t)); + value->sr = nfapi_p7_allocate(sizeof(*value->sr), config); + if (value->sr == NULL) + { + NFAPI_TRACE(NFAPI_TRACE_ERROR, "%s failed to allocate sr pdu\n", __FUNCTION__); + return 0; + } if(!(pull8(ppReadPackedMsg, &value->sr->sr_indication, end) && - pull8(ppReadPackedMsg, &value->sr->sr_confidence_level, end) + pull8(ppReadPackedMsg, &value->sr->sr_confidence_level, end) )) return 0; } if (((value->pduBitmap >> 1) & 0x01)) { //HARQ - value->harq = (nfapi_nr_harq_pdu_0_1_t*) malloc(sizeof(nfapi_nr_harq_pdu_0_1_t)); - if(!(pull8(ppReadPackedMsg, &value->harq->num_harq, end) && - pull8(ppReadPackedMsg, &value->harq->harq_confidence_level, end) - )) - return 0; - value->harq->harq_list = (nfapi_nr_harq_t*) malloc(sizeof(nfapi_nr_harq_t*) * value->harq->num_harq); - for(int i=0; i<value->harq->num_harq;i++) - { - if(!(pull8(ppReadPackedMsg, &value->harq->harq_list->harq_value, end) - )) - return 0; - } + + value->harq = nfapi_p7_allocate(sizeof(*value->harq), config); + if (value->harq == NULL) + { + NFAPI_TRACE(NFAPI_TRACE_ERROR, "%s failed to allocate nr_harq pdu\n", __FUNCTION__); + return 0; + } + if (!(pull8(ppReadPackedMsg, &value->harq->num_harq, end) && + pull8(ppReadPackedMsg, &value->harq->harq_confidence_level, end) + )) + return 0; + value->harq->harq_list = NULL; + if (value->harq->num_harq > 0) { + value->harq->harq_list = nfapi_p7_allocate(sizeof(*value->harq->harq_list) * value->harq->num_harq, config); + if (value->harq->harq_list == NULL) + { + NFAPI_TRACE(NFAPI_TRACE_ERROR, "%s failed to allocate harq ind pdu list (count:%d)\n", + __FUNCTION__, value->harq->num_harq); + return 0; + } + for (int i = 0; i < value->harq->num_harq; i++) { + if (!pull8(ppReadPackedMsg, &value->harq->harq_list[i].harq_value, end)) { + return 0; + } + } + } } return 1; @@ -5930,7 +5965,10 @@ static uint8_t unpack_nr_uci_pucch_2_3_4(nfapi_nr_uci_pucch_pdu_format_2_3_4_t* return 1; } -static uint8_t unpack_nr_uci_indication_body(nfapi_nr_uci_t* value, uint8_t **ppReadPackedMsg, uint8_t *end) +static uint8_t unpack_nr_uci_indication_body(nfapi_nr_uci_t *value, + uint8_t **ppReadPackedMsg, + uint8_t *end, + nfapi_p7_codec_config_t *config) { if(!(pull16(ppReadPackedMsg, &value->pdu_type, end) && pull16(ppReadPackedMsg, &value->pdu_size, end) @@ -5938,21 +5976,26 @@ static uint8_t unpack_nr_uci_indication_body(nfapi_nr_uci_t* value, uint8_t **pp return 0; switch (value->pdu_type) { - case NFAPI_NR_UCI_PUSCH_PDU_TYPE: - printf("Unhandled NFAPI_NR_UCI_PUSCH_PDU_TYPE \n"); - break; - - case NFAPI_NR_UCI_FORMAT_0_1_PDU_TYPE: { - nfapi_nr_uci_pucch_pdu_format_0_1_t* uci_pdu = &value->pucch_pdu_format_0_1; - unpack_nr_uci_pucch_0_1(uci_pdu, ppReadPackedMsg, end); - break; + case NFAPI_NR_UCI_PUSCH_PDU_TYPE: + NFAPI_TRACE(NFAPI_TRACE_WARN, "Unhandled NFAPI_NR_UCI_PUSCH_PDU_TYPE \n"); + break; + + case NFAPI_NR_UCI_FORMAT_0_1_PDU_TYPE: { + nfapi_nr_uci_pucch_pdu_format_0_1_t *uci_pdu = &value->pucch_pdu_format_0_1; + if (!unpack_nr_uci_pucch_0_1(uci_pdu, ppReadPackedMsg, end, config)) + return 0; + break; + } + case NFAPI_NR_UCI_FORMAT_2_3_4_PDU_TYPE: { + nfapi_nr_uci_pucch_pdu_format_2_3_4_t *uci_pdu = &value->pucch_pdu_format_2_3_4; + if (!unpack_nr_uci_pucch_2_3_4(uci_pdu, ppReadPackedMsg, end)) + return 0; + break; + } + default: + NFAPI_TRACE(NFAPI_TRACE_WARN, "Unexpected pdu type %d\n", value->pdu_type); + break; } - case NFAPI_NR_UCI_FORMAT_2_3_4_PDU_TYPE: { - nfapi_nr_uci_pucch_pdu_format_2_3_4_t *uci_pdu = &value->pucch_pdu_format_2_3_4; - unpack_nr_uci_pucch_2_3_4(uci_pdu, ppReadPackedMsg, end); - break; - } - } return 1; } @@ -5967,13 +6010,14 @@ static uint8_t unpack_nr_uci_indication(uint8_t **ppReadPackedMsg, uint8_t *end, )) return 0; - for(int i=0; i<pNfapiMsg->num_ucis;i++) + pNfapiMsg->uci_list = nfapi_p7_allocate(sizeof(*pNfapiMsg->uci_list) * pNfapiMsg->num_ucis, config); + for (int i = 0; i < pNfapiMsg->num_ucis; i++) { - if(!unpack_nr_uci_indication_body(pNfapiMsg->uci_list,ppReadPackedMsg,end)) - return 0; + if(!unpack_nr_uci_indication_body(&pNfapiMsg->uci_list[i], ppReadPackedMsg, end, config)) + return 0; } -return 1; + return 1; } static uint8_t unpack_ue_release_request(uint8_t **ppReadPackedMsg, uint8_t *end, void *msg, nfapi_p7_codec_config_t *config) { @@ -6233,6 +6277,7 @@ static uint8_t unpack_harq_indication_body_value(void *tlv, uint8_t **ppReadPack return 0; } + assert(value->number_of_harqs <= NFAPI_HARQ_IND_MAX_PDU); value->harq_pdu_list = (nfapi_harq_indication_pdu_t *)nfapi_p7_allocate(sizeof(nfapi_harq_indication_pdu_t) * value->number_of_harqs, config); if(value->harq_pdu_list == NULL) { @@ -6297,7 +6342,8 @@ static uint8_t unpack_crc_indication_body_value(void *tlv, uint8_t **ppReadPacke } if(value->number_of_crcs > 0) { - value->crc_pdu_list = (nfapi_crc_indication_pdu_t *)nfapi_p7_allocate(sizeof(nfapi_crc_indication_pdu_t) * value->number_of_crcs, config); + assert(value->number_of_crcs <= NFAPI_CRC_IND_MAX_PDU); + value->crc_pdu_list = (nfapi_crc_indication_pdu_t *)nfapi_p7_allocate(sizeof(nfapi_crc_indication_pdu_t) * NFAPI_CRC_IND_MAX_PDU, config); if(value->crc_pdu_list == NULL) { NFAPI_TRACE(NFAPI_TRACE_ERROR, "%s failed to allocate crc ind pdu list (count:%d)\n", __FUNCTION__, value->number_of_crcs); @@ -6349,114 +6395,141 @@ static uint8_t unpack_rx_indication_rel9_value(void *tlv, uint8_t **ppReadPacked return (pull16(ppReadPackedMsg, &value->timing_advance_r9, end)); } -static uint8_t unpack_rx_indication_body_value(void *tlv, uint8_t **ppReadPackedMsg, uint8_t *end, nfapi_p7_codec_config_t *config) { - nfapi_rx_indication_body_t *value = (nfapi_rx_indication_body_t *)tlv; - // the rxBodyEnd points to the end of the cqi PDU's - uint8_t *rxBodyEnd = *ppReadPackedMsg + value->tl.length; - uint8_t *rxPduEnd = rxBodyEnd; - uint8_t *numberOfPdusAddress = *ppReadPackedMsg; +static uint8_t unpack_rx_indication_body_value(void *tlv, uint8_t **ppReadPackedMsg, uint8_t *end, nfapi_p7_codec_config_t *config) +{ + nfapi_rx_indication_body_t *value = (nfapi_rx_indication_body_t*)tlv; - if(rxBodyEnd > end) { - // pdu end is past buffer end - return 0; - } + NFAPI_TRACE(NFAPI_TRACE_DEBUG, "%s value->tl.length in unpack: %u \n", __FUNCTION__, + value->tl.length); + uint8_t *rxBodyEnd = *ppReadPackedMsg + value->tl.length; - if(pull16(ppReadPackedMsg, &value->number_of_pdus, end) == 0) - return 0; + NFAPI_TRACE(NFAPI_TRACE_DEBUG, "%s rxBodyEnd: %p end: %p\n", __FUNCTION__, + rxBodyEnd, end); + if (rxBodyEnd > end) + { + // pdu end is past buffer end + return 0; + } - if(value->number_of_pdus > NFAPI_RX_IND_MAX_PDU) { - NFAPI_TRACE(NFAPI_TRACE_ERROR, "%s number of rx ind pdu's exceed maxium (count:%d max:%d)\n", __FUNCTION__, value->number_of_pdus, NFAPI_RX_IND_MAX_PDU); - return 0; - } + if (pull16(ppReadPackedMsg, &value->number_of_pdus, end) == 0) + return 0; - if(value->number_of_pdus > 0) { - value->rx_pdu_list = (nfapi_rx_indication_pdu_t *)nfapi_p7_allocate(sizeof(nfapi_rx_indication_pdu_t) * value->number_of_pdus, config); + if (value->number_of_pdus > NFAPI_RX_IND_MAX_PDU) + { + NFAPI_TRACE(NFAPI_TRACE_ERROR, "%s number of rx ind pdu's exceed maxium (count:%d max:%d)\n", __FUNCTION__, value->number_of_pdus, NFAPI_RX_IND_MAX_PDU); + return 0; + } - if(value->rx_pdu_list == NULL) { - NFAPI_TRACE(NFAPI_TRACE_ERROR, "%s failed to allocate rx ind pdu list (count:%d)\n", __FUNCTION__, value->number_of_pdus); - return 0; - } - } else { - value->rx_pdu_list = 0; - } + if (value->number_of_pdus > 0) + { + assert(value->number_of_pdus <= NFAPI_RX_IND_MAX_PDU); + value->rx_pdu_list = (nfapi_rx_indication_pdu_t *)nfapi_p7_allocate(sizeof(nfapi_rx_indication_pdu_t) * NFAPI_RX_IND_MAX_PDU, config); + if (value->rx_pdu_list == NULL) + { + NFAPI_TRACE(NFAPI_TRACE_ERROR, "%s failed to allocate rx ind pdu list (count:%d)\n", __FUNCTION__, value->number_of_pdus); + return 0; + } + } + else + { + value->rx_pdu_list = 0; + } - uint8_t i = 0; - nfapi_rx_indication_pdu_t *pdu = 0; + NFAPI_TRACE(NFAPI_TRACE_INFO, "%s number_of_pdus = %u\n", __FUNCTION__, value->number_of_pdus); + for (int i = 0; i < value->number_of_pdus; i++) + { + NFAPI_TRACE(NFAPI_TRACE_INFO, "%s i = %u\n", __FUNCTION__, i); + nfapi_tl_t generic_tl; - while((uint8_t *)(*ppReadPackedMsg) < rxBodyEnd && (uint8_t *)(*ppReadPackedMsg) < rxPduEnd) { - nfapi_tl_t generic_tl; + // NFAPI_RX_UE_INFORMATION_TAG + if (unpack_tl(ppReadPackedMsg, &generic_tl, end) == 0) + { + NFAPI_TRACE(NFAPI_TRACE_ERROR, "%s unpack_tl failed\n", __FUNCTION__); + return 0; + } - if( unpack_tl(ppReadPackedMsg, &generic_tl, end) == 0) - return 0; + NFAPI_TRACE(NFAPI_TRACE_INFO, "%s generic_tl.tag = 0x%x length = %u\n", __FUNCTION__, generic_tl.tag, generic_tl.length); - switch(generic_tl.tag) { - case NFAPI_RX_UE_INFORMATION_TAG: { - pdu = &(value->rx_pdu_list[i++]); - pdu->rx_ue_information.tl = generic_tl; + if (generic_tl.tag != NFAPI_RX_UE_INFORMATION_TAG) + { + NFAPI_TRACE(NFAPI_TRACE_ERROR, "%s generic_tl.tag wrong\n", __FUNCTION__); + return 0; + } - if(unpack_rx_ue_information_value(&pdu->rx_ue_information, ppReadPackedMsg, end) == 0) - return 0; - } - break; + assert(i < NFAPI_RX_IND_MAX_PDU); + nfapi_rx_indication_pdu_t *pdu = &value->rx_pdu_list[i]; - case NFAPI_RX_INDICATION_REL8_TAG: { - if(pdu != 0) { - pdu->rx_indication_rel8.tl = generic_tl; + pdu->rx_ue_information.tl = generic_tl; + if (unpack_rx_ue_information_value(&pdu->rx_ue_information, ppReadPackedMsg, end) == 0) + { + NFAPI_TRACE(NFAPI_TRACE_ERROR, "%s unpack_rx_ue_info failure\n", __FUNCTION__); + return 0; + } - if(unpack_rx_indication_rel8_value(&pdu->rx_indication_rel8, ppReadPackedMsg, end) == 0) - return 0; + // NFAPI_RX_INDICATION_REL8_TAG + if (unpack_tl(ppReadPackedMsg, &generic_tl, end) == 0) + { + NFAPI_TRACE(NFAPI_TRACE_ERROR, "%s unpack_tl failed\n", __FUNCTION__); + return 0; + } - if(pdu->rx_indication_rel8.offset > 0) { - // Need to check that the data is within the tlv - if(numberOfPdusAddress + pdu->rx_indication_rel8.offset + pdu->rx_indication_rel8.length <= rxBodyEnd) { - // If this the first pdu set the rxPduEnd - if(numberOfPdusAddress + pdu->rx_indication_rel8.offset < rxPduEnd) { - rxPduEnd = numberOfPdusAddress + pdu->rx_indication_rel8.offset; + NFAPI_TRACE(NFAPI_TRACE_INFO, "%s generic_tl.tag = 0x%x length = %u\n", __FUNCTION__, generic_tl.tag, generic_tl.length); - if(rxPduEnd > end) { - // pdu end is past buffer end - return 0; - } - } - } else { - NFAPI_TRACE(NFAPI_TRACE_ERROR, "FIXME: the rx data is outside of the tlv\n"); - } - } - } - } - break; + if (generic_tl.tag != NFAPI_RX_INDICATION_REL8_TAG) + { + NFAPI_TRACE(NFAPI_TRACE_ERROR, "%s generic_tl.tag wrong\n", __FUNCTION__); + return 0; + } - case NFAPI_RX_INDICATION_REL9_TAG: { - if(pdu != 0) { - pdu->rx_indication_rel9.tl = generic_tl; + pdu->rx_indication_rel8.tl = generic_tl; + if (unpack_rx_indication_rel8_value(&pdu->rx_indication_rel8, ppReadPackedMsg, end) == 0) + { + NFAPI_TRACE(NFAPI_TRACE_ERROR, "%s unpack_rx_indication_rel8 failure\n", __FUNCTION__); + return 0; + } + //What is offset not stripping 10 bytes + NFAPI_TRACE(NFAPI_TRACE_INFO, "%s pdu->rx_indication_rel8.offset = %u", __FUNCTION__, + pdu->rx_indication_rel8.offset); - if(unpack_rx_indication_rel9_value(&pdu->rx_indication_rel9, ppReadPackedMsg, end) == 0) - return 0; - } - } - break; + // NFAPI_RX_INDICATION_REL9_TAG + if (unpack_tl(ppReadPackedMsg, &generic_tl, end) == 0) + { + NFAPI_TRACE(NFAPI_TRACE_ERROR, "%s unpack_tl failed\n", __FUNCTION__); + return 0; + } - default: { - NFAPI_TRACE(NFAPI_TRACE_ERROR, "RX_ULSCH.indication Invalid pdu type %d \n", generic_tl.tag ); - } - break; - } - } + NFAPI_TRACE(NFAPI_TRACE_INFO, "%s generic_tl.tag = 0x%x length = %u\n", __FUNCTION__, generic_tl.tag, generic_tl.length); - uint8_t idx = 0; + if (generic_tl.tag != NFAPI_RX_INDICATION_REL9_TAG) + { + NFAPI_TRACE(NFAPI_TRACE_ERROR, "%s generic_tl.tag wrong\n", __FUNCTION__); + return 0; + } - for(idx = 0; idx < value->number_of_pdus; ++idx) { - if(value->rx_pdu_list[idx].rx_indication_rel8.tl.tag == NFAPI_RX_INDICATION_REL8_TAG) { - uint32_t length = value->rx_pdu_list[idx].rx_indication_rel8.length; - value->rx_pdu_list[idx].data = nfapi_p7_allocate(length, config); + pdu->rx_indication_rel9.tl = generic_tl; + if (unpack_rx_indication_rel9_value(&pdu->rx_indication_rel9, ppReadPackedMsg, end) == 0) + { + NFAPI_TRACE(NFAPI_TRACE_ERROR, "%s unpack_rx_indication_rel9 failure\n", __FUNCTION__); + return 0; + } + } - if(pullarray8(ppReadPackedMsg, value->rx_pdu_list[idx].data, length, length, end) == 0) { - return 0; - } - } - } + assert(value->number_of_pdus <= NFAPI_RX_IND_MAX_PDU); + for (int i = 0; i < value->number_of_pdus; ++i) + { + nfapi_rx_indication_pdu_t *pdu = &value->rx_pdu_list[i]; + if (pdu->rx_indication_rel8.tl.tag == NFAPI_RX_INDICATION_REL8_TAG) + { + uint32_t length = pdu->rx_indication_rel8.length; + if (pullarray8(ppReadPackedMsg, pdu->rx_ind_data, NFAPI_RX_IND_DATA_MAX, length, end) == 0) + { + NFAPI_TRACE(NFAPI_TRACE_ERROR, "%s pullarray8 failure\n", __FUNCTION__); + return 0; + } + } + } - return 1; + return 1; } static uint8_t unpack_rx_indication(uint8_t **ppReadPackedMsg, uint8_t *end, void *msg, nfapi_p7_codec_config_t *config) { @@ -7414,12 +7487,10 @@ static int check_nr_unpack_length(nfapi_message_id_e msgId, uint32_t unpackedBuf if (unpackedBufLen >= sizeof(nfapi_nr_tx_data_request_t)) retLen = sizeof(nfapi_nr_tx_data_request_t); break; - case NFAPI_NR_PHY_MSG_TYPE_RX_DATA_INDICATION: if (unpackedBufLen >= sizeof(nfapi_nr_rx_data_indication_t)) retLen = sizeof(nfapi_nr_rx_data_indication_t); break; - case NFAPI_NR_PHY_MSG_TYPE_CRC_INDICATION: if (unpackedBufLen >= sizeof(nfapi_nr_crc_indication_t)) retLen = sizeof(nfapi_nr_crc_indication_t); @@ -7429,17 +7500,14 @@ static int check_nr_unpack_length(nfapi_message_id_e msgId, uint32_t unpackedBuf if (unpackedBufLen >= sizeof(nfapi_nr_rach_indication_t)) retLen = sizeof(nfapi_nr_rach_indication_t); break; - case NFAPI_NR_PHY_MSG_TYPE_UCI_INDICATION: if (unpackedBufLen >= sizeof(nfapi_nr_uci_indication_t)) retLen = sizeof(nfapi_nr_uci_indication_t); break; - case NFAPI_NR_PHY_MSG_TYPE_SRS_INDICATION: if (unpackedBufLen >= sizeof(nfapi_nr_srs_indication_t)) retLen = sizeof(nfapi_nr_srs_indication_t); break; - case NFAPI_NR_PHY_MSG_TYPE_DL_NODE_SYNC: if (unpackedBufLen >= sizeof(nfapi_nr_dl_node_sync_t)) retLen = sizeof(nfapi_nr_dl_node_sync_t); @@ -7758,14 +7826,6 @@ int nfapi_nr_p7_message_unpack(void *pMessageBuf, uint32_t messageBufLen, void * return -1; } - // uint8_t *ptr = pMessageBuf; - // printf("\n Read P7 message unpack: "); - // while(ptr < end){ - // printf(" %d ", *ptr); - // ptr++; - // } - // printf("\n"); - // clean the supplied buffer for - tag value blanking (void)memset(pUnpackedBuf, 0, unpackedBufLen); @@ -7823,7 +7883,6 @@ int nfapi_nr_p7_message_unpack(void *pMessageBuf, uint32_t messageBufLen, void * else return -1; break; - case NFAPI_UE_RELEASE_REQUEST: if (check_nr_unpack_length(NFAPI_UE_RELEASE_REQUEST, unpackedBufLen)) result = unpack_ue_release_request(&pReadPackedMessage, end, pMessageHeader, config); diff --git a/nfapi/open-nFAPI/pnf/inc/pnf_p7.h b/nfapi/open-nFAPI/pnf/inc/pnf_p7.h index 763b5c9abe11fc153aa453b54bd27e689cfe85c5..cab245569165bd51a93c40ae6ca53b96ae4ba760 100644 --- a/nfapi/open-nFAPI/pnf/inc/pnf_p7.h +++ b/nfapi/open-nFAPI/pnf/inc/pnf_p7.h @@ -148,6 +148,7 @@ typedef struct { int pnf_p7_message_pump(pnf_p7_t* pnf_p7); int pnf_nr_p7_message_pump(pnf_p7_t* pnf_p7); int pnf_p7_pack_and_send_p7_message(pnf_p7_t* pnf_p7, nfapi_p7_message_header_t* msg, uint32_t msg_len); +int pnf_nr_p7_pack_and_send_p7_message(pnf_p7_t* pnf_p7, nfapi_p7_message_header_t* header, uint32_t msg_len); int pnf_p7_send_message(pnf_p7_t* pnf_p7, uint8_t* msg, uint32_t msg_len); diff --git a/nfapi/open-nFAPI/pnf/public_inc/nfapi_pnf_interface.h b/nfapi/open-nFAPI/pnf/public_inc/nfapi_pnf_interface.h index fc9cd660774bbf497e77eb76ecfa1691c8a2f965..ca8bc8d9a46525247fadd7d402af22d157849efb 100644 --- a/nfapi/open-nFAPI/pnf/public_inc/nfapi_pnf_interface.h +++ b/nfapi/open-nFAPI/pnf/public_inc/nfapi_pnf_interface.h @@ -800,6 +800,7 @@ int nfapi_pnf_p7_harq_ind(nfapi_pnf_p7_config_t* config, nfapi_harq_indication_t * \return 0 means success, -1 means failure */ int nfapi_pnf_p7_crc_ind(nfapi_pnf_p7_config_t* config, nfapi_crc_indication_t* ind); +int nfapi_pnf_p7_nr_crc_ind(nfapi_pnf_p7_config_t* config, nfapi_nr_crc_indication_t* ind); /*! Send the RX.indication * \param config A pointer to a PNF P7 config @@ -807,6 +808,7 @@ int nfapi_pnf_p7_crc_ind(nfapi_pnf_p7_config_t* config, nfapi_crc_indication_t* * \return 0 means success, -1 means failure */ int nfapi_pnf_p7_rx_ind(nfapi_pnf_p7_config_t* config, nfapi_rx_indication_t* ind); +int nfapi_pnf_p7_nr_rx_data_ind(nfapi_pnf_p7_config_t* config, nfapi_nr_rx_data_indication_t* ind); /*! Send the RACH.indication * \param config A pointer to a PNF P7 config @@ -821,6 +823,7 @@ int nfapi_pnf_p7_rach_ind(nfapi_pnf_p7_config_t* config, nfapi_rach_indication_t * \return 0 means success, -1 means failure */ int nfapi_pnf_p7_srs_ind(nfapi_pnf_p7_config_t* config, nfapi_srs_indication_t* ind); +int nfapi_pnf_p7_nr_srs_ind(nfapi_pnf_p7_config_t* config, nfapi_nr_srs_indication_t* ind); /*! Send the SR.indication * \param config A pointer to a PNF P7 config @@ -842,6 +845,7 @@ int nfapi_pnf_p7_cqi_ind(nfapi_pnf_p7_config_t* config, nfapi_cqi_indication_t* * \return 0 means success, -1 means failure */ int nfapi_pnf_p7_lbt_dl_ind(nfapi_pnf_p7_config_t* config, nfapi_lbt_dl_indication_t* ind); +int nfapi_pnf_p7_nr_uci_ind(nfapi_pnf_p7_config_t* config, nfapi_nr_uci_indication_t* ind); /*! Send the NB_HARQ.indication * \param config A pointer to a PNF P7 config @@ -856,6 +860,7 @@ int nfapi_pnf_p7_nb_harq_ind(nfapi_pnf_p7_config_t* config, nfapi_nb_harq_indica * \return 0 means success, -1 means failure */ int nfapi_pnf_p7_nrach_ind(nfapi_pnf_p7_config_t* config, nfapi_nrach_indication_t* ind); +int nfapi_pnf_p7_nr_rach_ind(nfapi_pnf_p7_config_t* config, nfapi_nr_rach_indication_t* ind); /*! Send a vendor exntesion message diff --git a/nfapi/open-nFAPI/pnf/src/pnf.c b/nfapi/open-nFAPI/pnf/src/pnf.c index fdafd93279179da659f75096b9cccbce0bf88272..b4158dbb40f6bec8c49126e789c2be8e262103d1 100644 --- a/nfapi/open-nFAPI/pnf/src/pnf.c +++ b/nfapi/open-nFAPI/pnf/src/pnf.c @@ -1,12 +1,12 @@ /* * Copyright 2017 Cisco Systems, Inc. - * + * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * 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. @@ -93,9 +93,9 @@ void pnf_nr_handle_pnf_param_request(pnf_t* pnf, void *pRecvMsg, int recvMsgLen) else { nfapi_nr_pnf_param_request_t req; - + NFAPI_TRACE(NFAPI_TRACE_INFO, "PNF_PARAM.request received\n"); - + // unpack the message if (nfapi_nr_p5_message_unpack(pRecvMsg, recvMsgLen, &req, sizeof(nfapi_nr_pnf_param_request_t), &pnf->_public.codec_config) >= 0) { @@ -109,7 +109,7 @@ void pnf_nr_handle_pnf_param_request(pnf_t* pnf, void *pRecvMsg, int recvMsgLen) else { NFAPI_TRACE(NFAPI_TRACE_ERROR, "%s: PNF not in IDLE state\n", __FUNCTION__); - + nfapi_nr_pnf_param_response_t resp; memset(&resp, 0, sizeof(resp)); resp.header.message_id = NFAPI_NR_PHY_MSG_TYPE_PNF_PARAM_RESPONSE; @@ -121,7 +121,7 @@ void pnf_nr_handle_pnf_param_request(pnf_t* pnf, void *pRecvMsg, int recvMsgLen) { NFAPI_TRACE(NFAPI_TRACE_ERROR, "%s: Unpack message failed, ignoring\n", __FUNCTION__); } - + if(req.vendor_extension) pnf->_public.codec_config.deallocate(req.vendor_extension); } @@ -137,9 +137,9 @@ void pnf_handle_pnf_param_request(pnf_t* pnf, void *pRecvMsg, int recvMsgLen) else { nfapi_pnf_param_request_t req; - + NFAPI_TRACE(NFAPI_TRACE_INFO, "PNF_PARAM.request received\n"); - + // unpack the message if (nfapi_p5_message_unpack(pRecvMsg, recvMsgLen, &req, sizeof(nfapi_pnf_param_request_t), &pnf->_public.codec_config) >= 0) { @@ -153,7 +153,7 @@ void pnf_handle_pnf_param_request(pnf_t* pnf, void *pRecvMsg, int recvMsgLen) else { NFAPI_TRACE(NFAPI_TRACE_ERROR, "%s: PNF not in IDLE state\n", __FUNCTION__); - + nfapi_pnf_param_response_t resp; memset(&resp, 0, sizeof(resp)); resp.header.message_id = NFAPI_PNF_PARAM_RESPONSE; @@ -165,7 +165,7 @@ void pnf_handle_pnf_param_request(pnf_t* pnf, void *pRecvMsg, int recvMsgLen) { NFAPI_TRACE(NFAPI_TRACE_ERROR, "%s: Unpack message failed, ignoring\n", __FUNCTION__); } - + if(req.vendor_extension) pnf->_public.codec_config.deallocate(req.vendor_extension); } @@ -185,7 +185,7 @@ void pnf_handle_pnf_config_request(pnf_t* pnf, void *pRecvMsg, int recvMsgLen) nfapi_pnf_config_request_t req; NFAPI_TRACE(NFAPI_TRACE_INFO, "PNF_CONFIG.request received\n"); - + // unpack the message if (nfapi_p5_message_unpack(pRecvMsg, recvMsgLen, &req, sizeof(req), &pnf->_public.codec_config) >= 0) { @@ -194,7 +194,7 @@ void pnf_handle_pnf_config_request(pnf_t* pnf, void *pRecvMsg, int recvMsgLen) { // delete the phy records nfapi_pnf_phy_config_delete_all(&pnf->_public); - + // create the phy records if (req.pnf_phy_rf_config.tl.tag == NFAPI_PNF_PHY_RF_TAG) { @@ -203,14 +203,14 @@ void pnf_handle_pnf_config_request(pnf_t* pnf, void *pRecvMsg, int recvMsgLen) { nfapi_pnf_phy_config_t* phy = (nfapi_pnf_phy_config_t*)malloc(sizeof(nfapi_pnf_phy_config_t)); memset(phy, 0, sizeof(nfapi_pnf_phy_config_t)); - + phy->state = NFAPI_PNF_PHY_IDLE; phy->phy_id = req.pnf_phy_rf_config.phy_rf_config[i].phy_id; - + nfapi_pnf_phy_config_add(&(pnf->_public), phy); } } - + if(pnf->_public.pnf_config_req) { (pnf->_public.pnf_config_req)(&(pnf->_public), &req); @@ -219,7 +219,7 @@ void pnf_handle_pnf_config_request(pnf_t* pnf, void *pRecvMsg, int recvMsgLen) else { NFAPI_TRACE(NFAPI_TRACE_ERROR, "%s: PNF not in correct state: %d\n", __FUNCTION__, pnf->_public.state); - + nfapi_pnf_config_response_t resp; memset(&resp, 0, sizeof(resp)); resp.header.message_id = NFAPI_PNF_CONFIG_RESPONSE; @@ -251,7 +251,7 @@ void pnf_nr_handle_pnf_config_request(pnf_t* pnf, void *pRecvMsg, int recvMsgLen nfapi_nr_pnf_config_request_t req; NFAPI_TRACE(NFAPI_TRACE_INFO, "PNF_CONFIG.request received\n"); - + // unpack the message if (nfapi_nr_p5_message_unpack(pRecvMsg, recvMsgLen, &req, sizeof(req), &pnf->_public.codec_config) >= 0) { @@ -260,7 +260,7 @@ void pnf_nr_handle_pnf_config_request(pnf_t* pnf, void *pRecvMsg, int recvMsgLen { // delete the phy records nfapi_pnf_phy_config_delete_all(&pnf->_public); - + // create the phy records if (req.pnf_phy_rf_config.tl.tag == NFAPI_PNF_PHY_RF_TAG) { @@ -269,14 +269,14 @@ void pnf_nr_handle_pnf_config_request(pnf_t* pnf, void *pRecvMsg, int recvMsgLen { nfapi_pnf_phy_config_t* phy = (nfapi_pnf_phy_config_t*)malloc(sizeof(nfapi_pnf_phy_config_t)); memset(phy, 0, sizeof(nfapi_pnf_phy_config_t)); - + phy->state = NFAPI_PNF_PHY_IDLE; phy->phy_id = req.pnf_phy_rf_config.phy_rf_config[i].phy_id; - + nfapi_pnf_phy_config_add(&(pnf->_public), phy); } } - + if(pnf->_public.pnf_nr_config_req) { (pnf->_public.pnf_nr_config_req)(&(pnf->_public), &req); @@ -285,7 +285,7 @@ void pnf_nr_handle_pnf_config_request(pnf_t* pnf, void *pRecvMsg, int recvMsgLen else { NFAPI_TRACE(NFAPI_TRACE_ERROR, "%s: PNF not in correct state: %d\n", __FUNCTION__, pnf->_public.state); - + nfapi_nr_pnf_config_response_t resp; memset(&resp, 0, sizeof(resp)); resp.header.message_id = NFAPI_PNF_CONFIG_RESPONSE; @@ -315,7 +315,7 @@ void pnf_handle_pnf_start_request(pnf_t* pnf, void *pRecvMsg, int recvMsgLen) nfapi_pnf_start_request_t req; NFAPI_TRACE(NFAPI_TRACE_INFO, "PNF_START.request Received\n"); - + // unpack the message if (nfapi_p5_message_unpack(pRecvMsg, recvMsgLen, &req, sizeof(req), &pnf->_public.codec_config) >= 0) { @@ -357,7 +357,7 @@ void pnf_nr_handle_pnf_start_request(pnf_t* pnf, void *pRecvMsg, int recvMsgLen) nfapi_nr_pnf_start_request_t req; NFAPI_TRACE(NFAPI_TRACE_INFO, "PNF_START.request Received\n"); - + // unpack the message if (nfapi_nr_p5_message_unpack(pRecvMsg, recvMsgLen, &req, sizeof(req), &pnf->_public.codec_config) >= 0) { @@ -397,9 +397,9 @@ void pnf_handle_pnf_stop_request(pnf_t* pnf, void *pRecvMsg, int recvMsgLen) else { nfapi_pnf_stop_request_t req; - + NFAPI_TRACE(NFAPI_TRACE_INFO, "PNF_STOP.request Received\n"); - + // unpack the message if (nfapi_p5_message_unpack(pRecvMsg, recvMsgLen, &req, sizeof(req), &pnf->_public.codec_config) >= 0) { @@ -423,7 +423,7 @@ void pnf_handle_pnf_stop_request(pnf_t* pnf, void *pRecvMsg, int recvMsgLen) { NFAPI_TRACE(NFAPI_TRACE_ERROR, "%s: Unpack message failed, ignoring\n", __FUNCTION__); } - + if(req.vendor_extension) pnf->_public.codec_config.deallocate(req.vendor_extension); @@ -440,11 +440,11 @@ void pnf_handle_param_request(pnf_t* pnf, void *pRecvMsg, int recvMsgLen) else { nfapi_param_request_t req; - + nfapi_pnf_config_t* config = &(pnf->_public); - + NFAPI_TRACE(NFAPI_TRACE_INFO, "PARAM.request received\n"); - + // unpack the message if (nfapi_p5_message_unpack(pRecvMsg, recvMsgLen, &req, sizeof(req), &config->codec_config) >= 0) { @@ -479,7 +479,7 @@ void pnf_handle_param_request(pnf_t* pnf, void *pRecvMsg, int recvMsgLen) resp.error_code = NFAPI_MSG_INVALID_CONFIG; nfapi_pnf_param_resp(config, &resp); } - + } else { @@ -495,7 +495,7 @@ void pnf_handle_param_request(pnf_t* pnf, void *pRecvMsg, int recvMsgLen) { NFAPI_TRACE(NFAPI_TRACE_ERROR, "%s: Unpack message failed, ignoring\n", __FUNCTION__); } - + if(req.vendor_extension) pnf->_public.codec_config.deallocate(req.vendor_extension); @@ -512,11 +512,11 @@ void pnf_nr_handle_param_request(pnf_t* pnf, void *pRecvMsg, int recvMsgLen) else { nfapi_nr_param_request_scf_t req; - + nfapi_pnf_config_t* config = &(pnf->_public); - + NFAPI_TRACE(NFAPI_TRACE_INFO, "PARAM.request received\n"); - + // unpack the message if (nfapi_nr_p5_message_unpack(pRecvMsg, recvMsgLen, &req, sizeof(req), &config->codec_config) >= 0) { @@ -551,7 +551,7 @@ void pnf_nr_handle_param_request(pnf_t* pnf, void *pRecvMsg, int recvMsgLen) resp.error_code = NFAPI_MSG_INVALID_CONFIG; nfapi_nr_pnf_param_resp(config, &resp); } - + } else { @@ -567,7 +567,7 @@ void pnf_nr_handle_param_request(pnf_t* pnf, void *pRecvMsg, int recvMsgLen) { NFAPI_TRACE(NFAPI_TRACE_ERROR, "%s: Unpack message failed, ignoring\n", __FUNCTION__); } - + if(req.vendor_extension) pnf->_public.codec_config.deallocate(req.vendor_extension); @@ -587,9 +587,9 @@ void pnf_handle_config_request(pnf_t* pnf, void *pRecvMsg, int recvMsgLen) nfapi_config_request_t req; NFAPI_TRACE(NFAPI_TRACE_INFO, "CONFIG.request received\n"); - + nfapi_pnf_config_t* config = &(pnf->_public); - + // unpack the message if (nfapi_p5_message_unpack(pRecvMsg, recvMsgLen, &req, sizeof(req), &config->codec_config) >= 0) { @@ -639,7 +639,7 @@ void pnf_handle_config_request(pnf_t* pnf, void *pRecvMsg, int recvMsgLen) { NFAPI_TRACE(NFAPI_TRACE_ERROR, "%s: Unpack message failed, ignoring\n", __FUNCTION__); } - + if(req.vendor_extension) pnf->_public.codec_config.deallocate(req.vendor_extension); } @@ -659,9 +659,9 @@ void pnf_nr_handle_config_request(pnf_t* pnf, void *pRecvMsg, int recvMsgLen) nfapi_nr_config_request_scf_t req; NFAPI_TRACE(NFAPI_TRACE_INFO, "CONFIG.request received\n"); - + nfapi_pnf_config_t* config = &(pnf->_public); - + // unpack the message if (nfapi_nr_p5_message_unpack(pRecvMsg, recvMsgLen, &req, sizeof(req), &config->codec_config) >= 0) { @@ -681,7 +681,7 @@ void pnf_nr_handle_config_request(pnf_t* pnf, void *pRecvMsg, int recvMsgLen) { (config->nr_config_req)(config, phy, &req); - + } } else @@ -718,7 +718,7 @@ void pnf_nr_handle_config_request(pnf_t* pnf, void *pRecvMsg, int recvMsgLen) { NFAPI_TRACE(NFAPI_TRACE_ERROR, "%s: Unpack message failed, ignoring\n", __FUNCTION__); } - + if(req.vendor_extension) pnf->_public.codec_config.deallocate(req.vendor_extension); } @@ -734,11 +734,11 @@ void pnf_handle_start_request(pnf_t* pnf, void *pRecvMsg, int recvMsgLen) else { nfapi_start_request_t req; - + nfapi_pnf_config_t* config = &(pnf->_public); - + NFAPI_TRACE(NFAPI_TRACE_INFO, "%s() START.request received state:%d\n", __FUNCTION__, config->state); - + // unpack the message if (nfapi_p5_message_unpack(pRecvMsg, recvMsgLen, &req, sizeof(req), &config->codec_config) >= 0) { @@ -788,7 +788,7 @@ void pnf_handle_start_request(pnf_t* pnf, void *pRecvMsg, int recvMsgLen) { NFAPI_TRACE(NFAPI_TRACE_ERROR, "%s: Unpack message failed, ignoring\n", __FUNCTION__); } - + if(req.vendor_extension) pnf->_public.codec_config.deallocate(req.vendor_extension); @@ -805,11 +805,11 @@ void pnf_nr_handle_start_request(pnf_t* pnf, void *pRecvMsg, int recvMsgLen) else { nfapi_nr_start_request_scf_t req; - + nfapi_pnf_config_t* config = &(pnf->_public); - + NFAPI_TRACE(NFAPI_TRACE_INFO, "%s() START.request received state:%d\n", __FUNCTION__, config->state); - + // unpack the message if (nfapi_nr_p5_message_unpack(pRecvMsg, recvMsgLen, &req, sizeof(req), &config->codec_config) >= 0) { @@ -859,7 +859,7 @@ void pnf_nr_handle_start_request(pnf_t* pnf, void *pRecvMsg, int recvMsgLen) { NFAPI_TRACE(NFAPI_TRACE_ERROR, "%s: Unpack message failed, ignoring\n", __FUNCTION__); } - + if(req.vendor_extension) pnf->_public.codec_config.deallocate(req.vendor_extension); @@ -878,9 +878,9 @@ void pnf_handle_stop_request(pnf_t* pnf, void *pRecvMsg, int recvMsgLen) nfapi_stop_request_t req; NFAPI_TRACE(NFAPI_TRACE_INFO, "STOP.request received\n"); - + nfapi_pnf_config_t* config = &(pnf->_public); - + // unpack the message if (nfapi_p5_message_unpack(pRecvMsg, recvMsgLen, &req, sizeof(req), &config->codec_config) >= 0) { @@ -930,10 +930,10 @@ void pnf_handle_stop_request(pnf_t* pnf, void *pRecvMsg, int recvMsgLen) { NFAPI_TRACE(NFAPI_TRACE_ERROR, "%s: Unpack message failed, ignoring\n", __FUNCTION__); } - + if(req.vendor_extension) pnf->_public.codec_config.deallocate(req.vendor_extension); - + } } @@ -949,9 +949,9 @@ void pnf_nr_handle_stop_request(pnf_t* pnf, void *pRecvMsg, int recvMsgLen) nfapi_nr_stop_request_t req; NFAPI_TRACE(NFAPI_TRACE_INFO, "STOP.request received\n"); - + nfapi_pnf_config_t* config = &(pnf->_public); - + // unpack the message if (nfapi_nr_p5_message_unpack(pRecvMsg, recvMsgLen, &req, sizeof(req), &config->codec_config) >= 0) { @@ -1001,10 +1001,10 @@ void pnf_nr_handle_stop_request(pnf_t* pnf, void *pRecvMsg, int recvMsgLen) { NFAPI_TRACE(NFAPI_TRACE_ERROR, "%s: Unpack message failed, ignoring\n", __FUNCTION__); } - + if(req.vendor_extension) pnf->_public.codec_config.deallocate(req.vendor_extension); - + } } @@ -1020,9 +1020,9 @@ void pnf_handle_measurement_request(pnf_t* pnf, void *pRecvMsg, int recvMsgLen) nfapi_measurement_request_t req; NFAPI_TRACE(NFAPI_TRACE_INFO, "MEASUREMENT.request received\n"); - + nfapi_pnf_config_t* config = &(pnf->_public); - + // unpack the message if (nfapi_p5_message_unpack(pRecvMsg, recvMsgLen, &req, sizeof(req), &config->codec_config) >= 0) { @@ -1072,7 +1072,7 @@ void pnf_handle_measurement_request(pnf_t* pnf, void *pRecvMsg, int recvMsgLen) { NFAPI_TRACE(NFAPI_TRACE_ERROR, "%s: Unpack message failed, ignoring\n", __FUNCTION__); } - + if(req.vendor_extension) pnf->_public.codec_config.deallocate(req.vendor_extension); } @@ -1087,13 +1087,13 @@ void pnf_handle_rssi_request(pnf_t* pnf, void *pRecvMsg, int recvMsgLen) NFAPI_TRACE(NFAPI_TRACE_ERROR, "%s: NULL parameters\n", __FUNCTION__); } else - { + { nfapi_rssi_request_t req; - + NFAPI_TRACE(NFAPI_TRACE_INFO, "RSSI.request received\n"); - + nfapi_pnf_config_t* config = &(pnf->_public); - + // unpack the message if (nfapi_p4_message_unpack(pRecvMsg, recvMsgLen, &req, sizeof(req), &config->codec_config) >= 0) { @@ -1143,10 +1143,10 @@ void pnf_handle_rssi_request(pnf_t* pnf, void *pRecvMsg, int recvMsgLen) { NFAPI_TRACE(NFAPI_TRACE_ERROR, "%s: Unpack message failed, ignoring\n", __FUNCTION__); } - + if(req.vendor_extension) pnf->_public.codec_config.deallocate(req.vendor_extension); - + } } @@ -1159,11 +1159,11 @@ void pnf_handle_cell_search_request(pnf_t* pnf, void *pRecvMsg, int recvMsgLen) else { nfapi_cell_search_request_t req; - + NFAPI_TRACE(NFAPI_TRACE_INFO, "CELL_SEARCH.request received\n"); - + nfapi_pnf_config_t* config = &(pnf->_public); - + if (nfapi_p4_message_unpack(pRecvMsg, recvMsgLen, &req, sizeof(req), &config->codec_config) >= 0) { if(config->state == NFAPI_PNF_RUNNING) @@ -1212,7 +1212,7 @@ void pnf_handle_cell_search_request(pnf_t* pnf, void *pRecvMsg, int recvMsgLen) { NFAPI_TRACE(NFAPI_TRACE_ERROR, "%s: Unpack message failed, ignoring\n", __FUNCTION__); } - + if(req.vendor_extension) pnf->_public.codec_config.deallocate(req.vendor_extension); } @@ -1231,9 +1231,9 @@ void pnf_handle_broadcast_detect_request(pnf_t* pnf, void *pRecvMsg, int recvMsg nfapi_broadcast_detect_request_t req; NFAPI_TRACE(NFAPI_TRACE_INFO, "BROADCAST_DETECT.request received\n"); - + nfapi_pnf_config_t* config = &(pnf->_public); - + if (nfapi_p4_message_unpack(pRecvMsg, recvMsgLen, &req, sizeof(req), &config->codec_config) >= 0) { if(config->state == NFAPI_PNF_RUNNING) @@ -1282,7 +1282,7 @@ void pnf_handle_broadcast_detect_request(pnf_t* pnf, void *pRecvMsg, int recvMsg { NFAPI_TRACE(NFAPI_TRACE_ERROR, "%s: Unpack message failed, ignoring\n", __FUNCTION__); } - + if(req.vendor_extension) pnf->_public.codec_config.deallocate(req.vendor_extension); @@ -1298,11 +1298,11 @@ void pnf_handle_system_information_schedule_request(pnf_t* pnf, void *pRecvMsg, else { nfapi_system_information_schedule_request_t req; - + NFAPI_TRACE(NFAPI_TRACE_INFO, "SYSTEM_INFORMATION_SCHEDULE.request received\n"); - + nfapi_pnf_config_t* config = &(pnf->_public); - + if (nfapi_p4_message_unpack(pRecvMsg, recvMsgLen, &req, sizeof(req), &config->codec_config) >= 0) { if(config->state == NFAPI_PNF_RUNNING) @@ -1351,7 +1351,7 @@ void pnf_handle_system_information_schedule_request(pnf_t* pnf, void *pRecvMsg, { NFAPI_TRACE(NFAPI_TRACE_ERROR, "%s: Unpack message failed, ignoring\n", __FUNCTION__); } - + if(req.vendor_extension) pnf->_public.codec_config.deallocate(req.vendor_extension); } @@ -1368,9 +1368,9 @@ void pnf_handle_system_information_request(pnf_t* pnf, void *pRecvMsg, int recvM nfapi_system_information_request_t req; NFAPI_TRACE(NFAPI_TRACE_INFO, "SYSTEM_INFORMATION.request received\n"); - + nfapi_pnf_config_t* config = &(pnf->_public); - + if (nfapi_p4_message_unpack(pRecvMsg, recvMsgLen, &req, sizeof(req), &config->codec_config) >= 0) { if(config->state == NFAPI_PNF_RUNNING) @@ -1419,7 +1419,7 @@ void pnf_handle_system_information_request(pnf_t* pnf, void *pRecvMsg, int recvM { NFAPI_TRACE(NFAPI_TRACE_ERROR, "%s: Unpack message failed, ignoring\n", __FUNCTION__); } - + if(req.vendor_extension) pnf->_public.codec_config.deallocate(req.vendor_extension); } @@ -1435,11 +1435,11 @@ void pnf_handle_nmm_stop_request(pnf_t* pnf, void *pRecvMsg, int recvMsgLen) else { nfapi_nmm_stop_request_t req; - + NFAPI_TRACE(NFAPI_TRACE_INFO, "NMM_STOP.request received\n"); - + nfapi_pnf_config_t* config = &(pnf->_public); - + if (nfapi_p4_message_unpack(pRecvMsg, recvMsgLen, &req, sizeof(req), &config->codec_config) >= 0) { if(config->state == NFAPI_PNF_RUNNING) @@ -1488,7 +1488,7 @@ void pnf_handle_nmm_stop_request(pnf_t* pnf, void *pRecvMsg, int recvMsgLen) { NFAPI_TRACE(NFAPI_TRACE_ERROR, "%s: Unpack message failed, ignoring\n", __FUNCTION__); } - + if(req.vendor_extension) pnf->_public.codec_config.deallocate(req.vendor_extension); } @@ -1504,21 +1504,21 @@ void pnf_handle_vendor_extension(void* pRecvMsg, int recvMsgLen, pnf_t* pnf, uin else { nfapi_pnf_config_t* config = &(pnf->_public); - + if(config->allocate_p4_p5_vendor_ext) { uint16_t msg_size; nfapi_p4_p5_message_header_t* msg = config->allocate_p4_p5_vendor_ext(message_id, &msg_size); - + if(msg == 0) { - NFAPI_TRACE(NFAPI_TRACE_INFO, "%s failed to allocate vendor extention structure\n"); + NFAPI_TRACE(NFAPI_TRACE_INFO, "failed to allocate vendor extention structure\n"); return; } - - + + int unpack_result = nfapi_p5_message_unpack(pRecvMsg, recvMsgLen, msg, msg_size, &config->codec_config); - + if(unpack_result == 0) { if(config->vendor_ext) @@ -1528,10 +1528,10 @@ void pnf_handle_vendor_extension(void* pRecvMsg, int recvMsgLen, pnf_t* pnf, uin { NFAPI_TRACE(NFAPI_TRACE_ERROR, "%s: Unpack message failed, ignoring\n", __FUNCTION__); } - + if(config->deallocate_p4_p5_vendor_ext) config->deallocate_p4_p5_vendor_ext(msg); - + } } } @@ -1732,8 +1732,8 @@ void pnf_handle_p5_message(pnf_t* pnf, void *pRecvMsg, int recvMsgLen) int pnf_nr_pack_and_send_p5_message(pnf_t* pnf, nfapi_p4_p5_message_header_t* msg, uint32_t msg_len) { int packed_len = nfapi_nr_p5_message_pack(msg, msg_len, - pnf->tx_message_buffer, - sizeof(pnf->tx_message_buffer), + pnf->tx_message_buffer, + sizeof(pnf->tx_message_buffer), &pnf->_public.codec_config); if (packed_len < 0) @@ -1749,8 +1749,8 @@ int pnf_nr_pack_and_send_p5_message(pnf_t* pnf, nfapi_p4_p5_message_header_t* ms int pnf_pack_and_send_p5_message(pnf_t* pnf, nfapi_p4_p5_message_header_t* msg, uint32_t msg_len) { int packed_len = nfapi_p5_message_pack(msg, msg_len, - pnf->tx_message_buffer, - sizeof(pnf->tx_message_buffer), + pnf->tx_message_buffer, + sizeof(pnf->tx_message_buffer), &pnf->_public.codec_config); if (packed_len < 0) @@ -1765,8 +1765,8 @@ int pnf_pack_and_send_p5_message(pnf_t* pnf, nfapi_p4_p5_message_header_t* msg, int pnf_pack_and_send_p4_message(pnf_t* pnf, nfapi_p4_p5_message_header_t* msg, uint32_t msg_len) { int packed_len = nfapi_p4_message_pack(msg, msg_len, - pnf->tx_message_buffer, - sizeof(pnf->tx_message_buffer), + pnf->tx_message_buffer, + sizeof(pnf->tx_message_buffer), &pnf->_public.codec_config); if (packed_len < 0) @@ -1797,14 +1797,14 @@ int pnf_connect(pnf_t* pnf) NFAPI_TRACE(NFAPI_TRACE_INFO, "Starting P5 PNF connection to VNF at %s:%u\n", pnf->_public.vnf_ip_addr, pnf->_public.vnf_p5_port); // todo split the vnf address list. currently only supporting 1 - + struct addrinfo hints, *servinfo; memset(&hints, 0, sizeof(hints)); hints.ai_socktype = SOCK_STREAM; // For SCTP we are only interested in SOCK_STREAM // todo : allow the client to restrict IPV4 or IPV6 // todo : randomize which address to connect to? - + char port_str[8]; snprintf(port_str, sizeof(port_str), "%d", pnf->_public.vnf_p5_port); if(getaddrinfo(pnf->_public.vnf_ip_addr, port_str, &hints, &servinfo) != 0) @@ -1822,7 +1822,7 @@ int pnf_connect(pnf_t* pnf) char* family = "Unknown"; char* address = "Unknown"; char _addr[128]; - + if(p->ai_family == AF_INET6) { family = "IPV6"; @@ -1886,7 +1886,7 @@ int pnf_connect(pnf_t* pnf) } else { - // Create an IP socket point + // Create an IP socket point if ((pnf->p5_sock = socket(p->ai_family, SOCK_STREAM, IPPROTO_IP)) < 0) { NFAPI_TRACE(NFAPI_TRACE_ERROR, "After P5 socket errno: %d\n", errno); @@ -1894,12 +1894,12 @@ int pnf_connect(pnf_t* pnf) return -1; } } - + NFAPI_TRACE(NFAPI_TRACE_INFO, "P5 socket created...\n"); - + if (connect(pnf->p5_sock, p->ai_addr, p->ai_addrlen ) < 0) { - NFAPI_TRACE(NFAPI_TRACE_ERROR, "After connect (address:%s port:%d) errno: %d\n", + NFAPI_TRACE(NFAPI_TRACE_ERROR, "After connect (address:%s port:%d) errno: %d\n", pnf->_public.vnf_ip_addr, pnf->_public.vnf_p5_port, errno); if(errno == EINVAL) @@ -1970,14 +1970,16 @@ int pnf_connect(pnf_t* pnf) int pnf_send_message(pnf_t* pnf, uint8_t *msg, uint32_t len, uint16_t stream) { - + if (pnf->sctp) { +#if 0 printf("\nPNF SENDS: \n"); for(int i=0; i<len; i++){ printf("%d", msg[i]); } printf("\n"); +#endif if (sctp_sendmsg(pnf->p5_sock, msg, len, NULL, 0, 42/*config->sctp_stream_number*/, 0, stream/*P5_STREAM_ID*/, 0, 0) < 0) { @@ -2069,12 +2071,14 @@ int pnf_read_dispatch_message(pnf_t* pnf) } else { +#if 0 // print the received message printf("\n MESSAGE RECEIVED: \n"); for(int i=0; i<message_size; i++){ printf("%d", read_buffer[i]); } printf("\n"); +#endif if (flags & MSG_NOTIFICATION) { @@ -2198,12 +2202,14 @@ int pnf_nr_read_dispatch_message(pnf_t* pnf) } else { +#if 0 // print the received message printf("\n MESSAGE RECEIVED: \n"); for(int i=0; i<message_size; i++){ printf("%d", read_buffer[i]); } printf("\n"); +#endif if (flags & MSG_NOTIFICATION) { @@ -2275,7 +2281,7 @@ int pnf_message_pump(pnf_t* pnf) selectRetval = select(pnf->p5_sock+1, &rfds, NULL, NULL, &timeout); if(selectRetval == 0) - { + { // timeout continue; } @@ -2336,7 +2342,7 @@ int pnf_nr_message_pump(pnf_t* pnf) selectRetval = select(pnf->p5_sock+1, &rfds, NULL, NULL, &timeout); if(selectRetval == 0) - { + { // timeout continue; } @@ -2376,4 +2382,3 @@ int pnf_nr_message_pump(pnf_t* pnf) return 0; } - diff --git a/nfapi/open-nFAPI/pnf/src/pnf_interface.c b/nfapi/open-nFAPI/pnf/src/pnf_interface.c index 8c9722c13e6df95df9115165ea70412ec0c19835..a53604640cfb12359d7c8aea02be85b8399f0dc9 100644 --- a/nfapi/open-nFAPI/pnf/src/pnf_interface.c +++ b/nfapi/open-nFAPI/pnf/src/pnf_interface.c @@ -1,12 +1,12 @@ /* * Copyright 2017 Cisco Systems, Inc. - * + * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * 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. @@ -32,11 +32,11 @@ nfapi_pnf_config_t* nfapi_pnf_config_create() memset(_this, 0, sizeof(pnf_t)); _this->sctp = 1; // enable sctp - + _this->_public.vnf_p5_port = NFAPI_P5_SCTP_PORT; - + _this->_public.malloc = &malloc; - _this->_public.free = &free; + _this->_public.free = &free; _this->_public.codec_config.allocate = &malloc; _this->_public.codec_config.deallocate = &free; @@ -55,10 +55,6 @@ int nfapi_pnf_start(nfapi_pnf_config_t* config) if(config == 0) return -1; - // Make sure to set the defined trace function before using NFAPI_TRACE - if(config->trace) - nfapi_trace_g = config->trace; - NFAPI_TRACE(NFAPI_TRACE_INFO, "%s\n", __FUNCTION__); pnf_t* _this = (pnf_t*)(config); @@ -89,10 +85,6 @@ int nfapi_nr_pnf_start(nfapi_pnf_config_t* config) if(config == 0) return -1; - // Make sure to set the defined trace function before using NFAPI_TRACE - if(config->trace) - nfapi_trace_g = config->trace; - NFAPI_TRACE(NFAPI_TRACE_INFO, "%s\n", __FUNCTION__); pnf_t* _this = (pnf_t*)(config); @@ -265,7 +257,7 @@ int nfapi_pnf_param_resp(nfapi_pnf_config_t* config, nfapi_param_response_t* res NFAPI_TRACE(NFAPI_TRACE_ERROR, "%s: NULL parameters\n", __FUNCTION__); return -1; } - + pnf_t* _this = (pnf_t*)(config); return pnf_pack_and_send_p5_message(_this, &(resp->header), sizeof(nfapi_param_response_t)); @@ -279,7 +271,7 @@ int nfapi_nr_pnf_param_resp(nfapi_pnf_config_t* config, nfapi_nr_param_response_ NFAPI_TRACE(NFAPI_TRACE_ERROR, "%s: NULL parameters\n", __FUNCTION__); return -1; } - + pnf_t* _this = (pnf_t*)(config); return pnf_nr_pack_and_send_p5_message(_this, &(resp->header), sizeof(nfapi_nr_param_response_scf_t)); @@ -591,4 +583,3 @@ int nfapi_pnf_vendor_extension(nfapi_pnf_config_t* config, nfapi_p4_p5_message_h return pnf_pack_and_send_p5_message(_this, msg, msg_len); } - diff --git a/nfapi/open-nFAPI/pnf/src/pnf_p7.c b/nfapi/open-nFAPI/pnf/src/pnf_p7.c index 092b967189b5050d057aaa87171dc547ac071e97..fb1a713e56532a60aac9f9ae6a9e3fac74cf14d7 100644 --- a/nfapi/open-nFAPI/pnf/src/pnf_p7.c +++ b/nfapi/open-nFAPI/pnf/src/pnf_p7.c @@ -1060,6 +1060,23 @@ int pnf_p7_slot_ind(pnf_p7_t* pnf_p7, uint16_t phy_id, uint16_t sfn, uint16_t sl (pnf_p7->_public.ul_dci_req_fn)(NULL, &(pnf_p7->_public), pnf_p7->_public.dummy_slot.ul_dci_req); } } + if(tx_slot_buffer->ul_tti_req != 0) + { + if(pnf_p7->_public.ul_tti_req_fn) + { + (pnf_p7->_public.ul_tti_req_fn)(NULL, &(pnf_p7->_public), tx_slot_buffer->ul_tti_req); + } + } + else + { + // send dummy + if(pnf_p7->_public.ul_tti_req_fn && pnf_p7->_public.dummy_slot.ul_tti_req) + { + pnf_p7->_public.dummy_slot.ul_tti_req->SFN = sfn_tx; + pnf_p7->_public.dummy_slot.ul_tti_req->Slot = slot_tx; + (pnf_p7->_public.ul_tti_req_fn)(NULL, &(pnf_p7->_public), pnf_p7->_public.dummy_slot.ul_tti_req); + } + } //deallocate slot buffers after passing down the PDUs to PHY processing @@ -1585,7 +1602,7 @@ void pnf_handle_dl_tti_request(void* pRecvMsg, int recvMsgLen, pnf_p7_t* pnf_p7) if(req == NULL) { - NFAPI_TRACE(NFAPI_TRACE_INFO, "%s failed to alloced nfapi_dl_tti_request structure\n"); + NFAPI_TRACE(NFAPI_TRACE_INFO, "failed to allocate nfapi_dl_tti_request structure\n"); return; } int unpack_result = nfapi_nr_p7_message_unpack(pRecvMsg, recvMsgLen, req, sizeof(nfapi_nr_dl_tti_request_t), &(pnf_p7->_public.codec_config)); @@ -1659,7 +1676,7 @@ void pnf_handle_dl_config_request(void* pRecvMsg, int recvMsgLen, pnf_p7_t* pnf_ if(req == NULL) { - NFAPI_TRACE(NFAPI_TRACE_INFO, "%s failed to alloced nfapi_dl_config_request structure\n"); + NFAPI_TRACE(NFAPI_TRACE_INFO, "failed to allocate nfapi_dl_config_request structure\n"); return; } @@ -1750,7 +1767,7 @@ void pnf_handle_ul_tti_request(void* pRecvMsg, int recvMsgLen, pnf_p7_t* pnf_p7) if(req == NULL) { - NFAPI_TRACE(NFAPI_TRACE_INFO, "%s failed to alloced nfapi_ul_tti_request structure\n"); + NFAPI_TRACE(NFAPI_TRACE_INFO, "failed to allocate nfapi_ul_tti_request structure\n"); return; } @@ -1825,7 +1842,7 @@ void pnf_handle_ul_config_request(void* pRecvMsg, int recvMsgLen, pnf_p7_t* pnf_ if(req == NULL) { - NFAPI_TRACE(NFAPI_TRACE_INFO, "%s failed to alloced nfapi_ul_config_request structure\n"); + NFAPI_TRACE(NFAPI_TRACE_INFO, "failed to allocate nfapi_ul_config_request structure\n"); return; } @@ -1898,7 +1915,7 @@ void pnf_handle_ul_dci_request(void* pRecvMsg, int recvMsgLen, pnf_p7_t* pnf_p7) if(req == NULL) { - NFAPI_TRACE(NFAPI_TRACE_INFO, "%s failed to allocate nfapi_ul_dci_request structure\n"); + NFAPI_TRACE(NFAPI_TRACE_INFO, "failed to allocate nfapi_ul_dci_request structure\n"); return; } @@ -1969,7 +1986,7 @@ void pnf_handle_hi_dci0_request(void* pRecvMsg, int recvMsgLen, pnf_p7_t* pnf_p7 if(req == NULL) { - NFAPI_TRACE(NFAPI_TRACE_INFO, "%s failed to alloced nfapi_hi_dci0_request structure\n"); + NFAPI_TRACE(NFAPI_TRACE_INFO, "failed to allocate nfapi_hi_dci0_request structure\n"); return; } @@ -2038,7 +2055,7 @@ void pnf_handle_tx_data_request(void* pRecvMsg, int recvMsgLen, pnf_p7_t* pnf_p7 if(req == NULL) { - NFAPI_TRACE(NFAPI_TRACE_INFO, "%s failed to alloced nfapi_tx_request structure\n"); + NFAPI_TRACE(NFAPI_TRACE_INFO, "failed to allocate nfapi_tx_request structure\n"); return; } @@ -2118,7 +2135,7 @@ void pnf_handle_tx_request(void* pRecvMsg, int recvMsgLen, pnf_p7_t* pnf_p7) if(req == NULL) { - NFAPI_TRACE(NFAPI_TRACE_INFO, "%s failed to alloced nfapi_tx_request structure\n"); + NFAPI_TRACE(NFAPI_TRACE_INFO, "failed to allocate nfapi_tx_request structure\n"); return; } @@ -2192,7 +2209,7 @@ void pnf_handle_lbt_dl_config_request(void* pRecvMsg, int recvMsgLen, pnf_p7_t* if(req == NULL) { - NFAPI_TRACE(NFAPI_TRACE_INFO, "%s failed to alloced nfapi_lbt_dl_config_request structure\n"); + NFAPI_TRACE(NFAPI_TRACE_INFO, "failed to allocate nfapi_lbt_dl_config_request structure\n"); return; } @@ -2255,7 +2272,7 @@ void pnf_handle_p7_vendor_extension(void* pRecvMsg, int recvMsgLen, pnf_p7_t* pn if(msg == 0) { - NFAPI_TRACE(NFAPI_TRACE_INFO, "%s failed to allocate vendor extention structure\n"); + NFAPI_TRACE(NFAPI_TRACE_INFO, "failed to allocate vendor extention structure\n"); return; } @@ -2279,7 +2296,7 @@ void pnf_handle_ue_release_request(void* pRecvMsg, int recvMsgLen, pnf_p7_t* pnf nfapi_ue_release_request_t* req = allocate_nfapi_ue_release_request(pnf_p7); if(req == NULL) { - NFAPI_TRACE(NFAPI_TRACE_ERROR, "%s failed to alloced nfapi_ue_release_request structure\n"); + NFAPI_TRACE(NFAPI_TRACE_ERROR, "failed to allocate nfapi_ue_release_request structure\n"); return; } @@ -2381,7 +2398,7 @@ uint32_t calculate_nr_t2(uint32_t now_time_hr, uint16_t sfn,uint16_t slot, uint3 { static uint32_t prev_t2 = 0; - NFAPI_TRACE(NFAPI_TRACE_ERROR, "%s(now_time_hr:%u sfn:%d slot:%d slot_start_time_Hr:%u) slot_time_us:%u t2:%u prev_t2:%u diff:%u\n", + NFAPI_TRACE(NFAPI_TRACE_ERROR, "%s(now_time_hr:%u sfn to slot:%d slot_start_time_Hr:%u) slot_time_us:%u t2:%u prev_t2:%u diff:%u\n", __FUNCTION__, now_time_hr, NFAPI_SFNSLOT2DEC(sfn, slot), slot_start_time_hr, slot_time_us, @@ -2656,7 +2673,7 @@ void pnf_handle_p7_message(void *pRecvMsg, int recvMsgLen, pnf_p7_t* pnf_p7, ui // validate the input params if(pRecvMsg == NULL || recvMsgLen < 4 || pnf_p7 == NULL) { - NFAPI_TRACE(NFAPI_TRACE_ERROR, "pnf_handle_p7_message: invalid input params (%d %d %d)\n", pRecvMsg, recvMsgLen, pnf_p7); + NFAPI_TRACE(NFAPI_TRACE_ERROR, "pnf_handle_p7_message: invalid input params (%p %d %p)\n", pRecvMsg, recvMsgLen, pnf_p7); return; } @@ -2762,7 +2779,7 @@ void pnf_nr_handle_p7_message(void *pRecvMsg, int recvMsgLen, pnf_p7_t* pnf_p7, // validate the input params if(pRecvMsg == NULL || recvMsgLen < 4 || pnf_p7 == NULL) { - NFAPI_TRACE(NFAPI_TRACE_ERROR, "pnf_handle_p7_message: invalid input params (%d %d %d)\n", pRecvMsg, recvMsgLen, pnf_p7); + NFAPI_TRACE(NFAPI_TRACE_ERROR, "pnf_handle_p7_message: invalid input params (%p %d %p)\n", pRecvMsg, recvMsgLen, pnf_p7); return; } @@ -2889,12 +2906,19 @@ void pnf_nfapi_p7_read_dispatch_message(pnf_p7_t* pnf_p7, uint32_t now_hr_time) } // read the segment - recvfrom_result = recvfrom(pnf_p7->p7_sock, pnf_p7->rx_message_buffer, header.message_length, MSG_DONTWAIT, (struct sockaddr*)&remote_addr, &remote_addr_size); + recvfrom_result = recvfrom(pnf_p7->p7_sock, pnf_p7->rx_message_buffer, pnf_p7->rx_message_buffer_size, + MSG_DONTWAIT | MSG_TRUNC, (struct sockaddr*)&remote_addr, &remote_addr_size); now_hr_time = pnf_get_current_time_hr(); //DJP - moved to here - get closer timestamp??? if(recvfrom_result > 0) { + if (recvfrom_result != header.message_length) + { + NFAPI_TRACE(NFAPI_TRACE_ERROR, "(%d) Received unexpected number of bytes. %d != %d", + __LINE__, recvfrom_result, header.message_length); + break; + } pnf_handle_p7_message(pnf_p7->rx_message_buffer, recvfrom_result, pnf_p7, now_hr_time); //printf("\npnf_handle_p7_message sfn=%d,slot=%d\n",pnf_p7->sfn,pnf_p7->slot); } @@ -3126,6 +3150,38 @@ int pnf_p7_message_pump(pnf_p7_t* pnf_p7) return 0; } +struct timespec pnf_timespec_add(struct timespec lhs, struct timespec rhs) +{ + struct timespec result; + + result.tv_sec = lhs.tv_sec + rhs.tv_sec; + result.tv_nsec = lhs.tv_nsec + rhs.tv_nsec; + + if(result.tv_nsec > 1e9) + { + result.tv_sec++; + result.tv_nsec-= 1e9; + } + + return result; +} + +struct timespec pnf_timespec_sub(struct timespec lhs, struct timespec rhs) +{ + struct timespec result; + if ((lhs.tv_nsec-rhs.tv_nsec)<0) + { + result.tv_sec = lhs.tv_sec-rhs.tv_sec-1; + result.tv_nsec = 1000000000+lhs.tv_nsec-rhs.tv_nsec; + } + else + { + result.tv_sec = lhs.tv_sec-rhs.tv_sec; + result.tv_nsec = lhs.tv_nsec-rhs.tv_nsec; + } + return result; +} + int pnf_nr_p7_message_pump(pnf_p7_t* pnf_p7) { @@ -3201,6 +3257,19 @@ int pnf_nr_p7_message_pump(pnf_p7_t* pnf_p7) } NFAPI_TRACE(NFAPI_TRACE_INFO, "PNF P7 bind succeeded...\n"); + //Initializaing timing structures needed for slot ticking + + struct timespec slot_start; + clock_gettime(CLOCK_MONOTONIC, &slot_start); + + struct timespec pselect_start; + + struct timespec slot_duration; + slot_duration.tv_sec = 0; + slot_duration.tv_nsec = 0.5e6; + + //Infinite loop + while(pnf_p7->terminate == 0) { fd_set rfds; @@ -3210,11 +3279,29 @@ int pnf_nr_p7_message_pump(pnf_p7_t* pnf_p7) FD_ZERO(&rfds); FD_SET(pnf_p7->p7_sock, &rfds); - struct timeval timeout; + struct timespec timeout; timeout.tv_sec = 100; - timeout.tv_usec = 0; + timeout.tv_nsec = 0; + clock_gettime(CLOCK_MONOTONIC, &pselect_start); - selectRetval = select(pnf_p7->p7_sock+1, &rfds, NULL, NULL, &timeout); + //setting the timeout + + if((pselect_start.tv_sec > slot_start.tv_sec) || ((pselect_start.tv_sec == slot_start.tv_sec) && (pselect_start.tv_nsec > slot_start.tv_nsec))) + { + // overran the end of the subframe we do not want to wait + timeout.tv_sec = 0; + timeout.tv_nsec = 0; + + //struct timespec overrun = pnf_timespec_sub(pselect_start, sf_start); + //NFAPI_TRACE(NFAPI_TRACE_INFO, "Subframe overrun detected of %d.%d running to catchup\n", overrun.tv_sec, overrun.tv_nsec); + } + else + { + // still time before the end of the subframe wait + timeout = pnf_timespec_sub(slot_start, pselect_start); + } + + selectRetval = pselect(pnf_p7->p7_sock+1, &rfds, NULL, NULL, &timeout, NULL); uint32_t now_hr_time = pnf_get_current_time_hr(); @@ -3224,6 +3311,17 @@ int pnf_nr_p7_message_pump(pnf_p7_t* pnf_p7) if(selectRetval == 0) { // timeout + + //update slot start timing + slot_start = pnf_timespec_add(slot_start, slot_duration); + + //increment sfn/slot + if (++pnf_p7->slot == 20) + { + pnf_p7->slot = 0; + pnf_p7->sfn = (pnf_p7->sfn + 1) % 1024; + } + continue; } else if (selectRetval == -1 && (errno == EINTR)) @@ -3242,7 +3340,7 @@ int pnf_nr_p7_message_pump(pnf_p7_t* pnf_p7) if(FD_ISSET(pnf_p7->p7_sock, &rfds)) { - pnf_nr_nfapi_p7_read_dispatch_message(pnf_p7, now_hr_time); + pnf_nr_nfapi_p7_read_dispatch_message(pnf_p7, now_hr_time); } } NFAPI_TRACE(NFAPI_TRACE_ERROR, "PNF_P7 Terminating..\n"); diff --git a/nfapi/open-nFAPI/pnf/src/pnf_p7_interface.c b/nfapi/open-nFAPI/pnf/src/pnf_p7_interface.c index 0db1feb398cc8922c954d0782337b8fc0c3e4691..a1be4d0edcd8eb66a7a3cb622157ff698d938cec 100644 --- a/nfapi/open-nFAPI/pnf/src/pnf_p7_interface.c +++ b/nfapi/open-nFAPI/pnf/src/pnf_p7_interface.c @@ -44,6 +44,7 @@ nfapi_pnf_p7_config_t* nfapi_pnf_p7_config_create() _this->_public.codec_config.allocate = &malloc; _this->_public.codec_config.deallocate = &free; + // cppcheck-suppress memleak return &(_this->_public); } @@ -63,10 +64,6 @@ int nfapi_pnf_p7_start(nfapi_pnf_p7_config_t* config) if(config == 0) return -1; - // Make sure to set the defined trace function before using NFAPI_TRACE - if(config->trace) - nfapi_trace_g = config->trace; - pnf_p7_t* _this = (pnf_p7_t*)(config); NFAPI_TRACE(NFAPI_TRACE_INFO, "%s\n", __FUNCTION__); @@ -82,10 +79,6 @@ int nfapi_nr_pnf_p7_start(nfapi_pnf_p7_config_t* config) if(config == 0) return -1; - // Make sure to set the defined trace function before using NFAPI_TRACE - if(config->trace) - nfapi_trace_g = config->trace; - pnf_p7_t* _this = (pnf_p7_t*)(config); NFAPI_TRACE(NFAPI_TRACE_INFO, "%s\n", __FUNCTION__); @@ -175,17 +168,7 @@ int nfapi_pnf_p7_rach_ind(nfapi_pnf_p7_config_t* config, nfapi_rach_indication_t pnf_p7_t* _this = (pnf_p7_t*)(config); return pnf_p7_pack_and_send_p7_message(_this, (nfapi_p7_message_header_t*)ind, sizeof(nfapi_rach_indication_t)); } -int nfapi_pnf_p7_srs_ind(nfapi_pnf_p7_config_t* config, nfapi_srs_indication_t* ind) -{ - if(config == NULL || ind == NULL) - { - NFAPI_TRACE(NFAPI_TRACE_ERROR, "%s: invalid input params\n", __FUNCTION__); - return -1; - } - pnf_p7_t* _this = (pnf_p7_t*)(config); - return pnf_p7_pack_and_send_p7_message(_this, (nfapi_p7_message_header_t*)ind, sizeof(nfapi_srs_indication_t)); -} int nfapi_pnf_p7_sr_ind(nfapi_pnf_p7_config_t* config, nfapi_sr_indication_t* ind) { if(config == NULL || ind == NULL) diff --git a/nfapi/open-nFAPI/pnf_sim/src/fapi_stub.cpp b/nfapi/open-nFAPI/pnf_sim/src/fapi_stub.cpp index 1c2f0bef8078a072d7abd9eab6de65cbe3b5568d..4fe5065ceac54c687c1fa73e159b87f3061fc549 100644 --- a/nfapi/open-nFAPI/pnf_sim/src/fapi_stub.cpp +++ b/nfapi/open-nFAPI/pnf_sim/src/fapi_stub.cpp @@ -278,7 +278,7 @@ void *fapi_thread_start(void *ptr) { if(instance->tick == 1000) { if(instance->tx_byte_count > 0) { - printf("[FAPI] Tx rate %d bytes/sec\n", instance->tx_byte_count); + printf("[FAPI] Tx rate %u bytes/sec\n", instance->tx_byte_count); instance->tx_byte_count = 0; } @@ -319,7 +319,7 @@ void *fapi_thread_start(void *ptr) { millisec = now_ts.tv_nsec / 1e6; if(last_millisec != -1 && ((last_millisec + 1 ) % 1000) != millisec) { - printf("*** missing millisec %d %d\n", last_millisec, millisec); + printf("*** missing millisec %u %u\n", last_millisec, millisec); catchup = millisec - last_millisec - 1; } diff --git a/nfapi/open-nFAPI/vnf/public_inc/nfapi_vnf_interface.h b/nfapi/open-nFAPI/vnf/public_inc/nfapi_vnf_interface.h index 31328393c9a5749f8dc784abf74c3a78638b4248..decb48e5c8334482029cc3c05a57f34d8c1ca4f2 100644 --- a/nfapi/open-nFAPI/vnf/public_inc/nfapi_vnf_interface.h +++ b/nfapi/open-nFAPI/vnf/public_inc/nfapi_vnf_interface.h @@ -20,6 +20,7 @@ #include "nfapi_interface.h" #include "nfapi_nr_interface_scf.h" #include "nfapi_nr_interface.h" +#include "openair2/PHY_INTERFACE/queue_t.h" #include "debug.h" @@ -86,8 +87,6 @@ typedef struct nfapi_vnf_config void* (*malloc)(size_t size); /*! A user define callback to override the default memory deallocation */ void (*free)(void*); - /*! A user define callback to handle trace from the pnf */ - void (*trace)(nfapi_trace_level_t level, const char* message, ...); /*! The port the VNF P5 SCTP connection listens on * @@ -662,12 +661,6 @@ typedef struct nfapi_vnf_p7_config * If not set the vnf p7 library will use free */ void (*free)(void*); - - /*! A user define callback to handle trace from the pnf - * \param level The trace level - * \param message The trace string - */ - void (*trace)(nfapi_trace_level_t level, const char* message, ...); /*! The port the vnf p7 will receive on */ int port; @@ -908,7 +901,7 @@ void nfapi_vnf_p7_config_destory(nfapi_vnf_p7_config_t* config); * This function is blocking and will not return until the nfapi_vnf_p7_stop * function is called. */ - +extern queue_t gnb_slot_ind_queue; int nfapi_vnf_p7_start(nfapi_vnf_p7_config_t* config); int nfapi_nr_vnf_p7_start(nfapi_vnf_p7_config_t* config); diff --git a/nfapi/open-nFAPI/vnf/src/vnf.c b/nfapi/open-nFAPI/vnf/src/vnf.c index 7fee47d6d5423b5acd381d998a9083a582632eb9..e0431ced174fb9185319201fe748cd8e41b1f8fe 100644 --- a/nfapi/open-nFAPI/vnf/src/vnf.c +++ b/nfapi/open-nFAPI/vnf/src/vnf.c @@ -85,7 +85,7 @@ void nfapi_vnf_pnf_list_add(nfapi_vnf_config_t* config, nfapi_vnf_pnf_info_t* no nfapi_vnf_pnf_info_t* nfapi_vnf_pnf_list_find(nfapi_vnf_config_t* config, int p5_idx) { - NFAPI_TRACE(NFAPI_TRACE_ERROR, "%s : config->pnf_list:%p\n", __FUNCTION__, config->pnf_list); + NFAPI_TRACE(NFAPI_TRACE_DEBUG, "config->pnf_list:%p\n", config->pnf_list); nfapi_vnf_pnf_info_t* curr = config->pnf_list; while(curr != 0) @@ -1051,7 +1051,7 @@ void vnf_handle_vendor_extension(void* pRecvMsg, int recvMsgLen, nfapi_vnf_confi } else { - NFAPI_TRACE(NFAPI_TRACE_INFO, "%s failed to allocate vendor extention structure\n"); + NFAPI_TRACE(NFAPI_TRACE_INFO, "failed to allocate vendor extention structure\n"); } } } @@ -1383,6 +1383,7 @@ int vnf_read_dispatch_message(nfapi_vnf_config_t* config, nfapi_vnf_pnf_info_t* uint32_t header_buffer_size = NFAPI_HEADER_LENGTH; uint8_t header_buffer[header_buffer_size]; + memset(header_buffer, 0, header_buffer_size); uint32_t stack_buffer_size = 32; //should it be the size of then sctp_notificatoin structure uint8_t stack_buffer[stack_buffer_size]; @@ -1393,6 +1394,7 @@ int vnf_read_dispatch_message(nfapi_vnf_config_t* config, nfapi_vnf_pnf_info_t* uint32_t message_size = 0; struct sockaddr_in addr; + memset(&addr, 0, sizeof(addr)); socklen_t addr_len = sizeof(addr); struct sctp_sndrcvinfo sndrcvinfo; diff --git a/nfapi/open-nFAPI/vnf/src/vnf_interface.c b/nfapi/open-nFAPI/vnf/src/vnf_interface.c index 084c4fa48547dcb1958dd806bed057eb2cea4a04..633dd18f2402c0759b9a625b251462fdaa5d525a 100644 --- a/nfapi/open-nFAPI/vnf/src/vnf_interface.c +++ b/nfapi/open-nFAPI/vnf/src/vnf_interface.c @@ -25,6 +25,7 @@ #include <string.h> #include <unistd.h> #include <errno.h> +#include <assert.h> #include <stdio.h> @@ -69,10 +70,6 @@ int nfapi_nr_vnf_start(nfapi_vnf_config_t* config) if(config == 0) return -1; - // Make sure to set the defined trace function before using NFAPI_TRACE - if(config->trace) - nfapi_trace_g = (nfapi_trace_fn_t)config->trace; - NFAPI_TRACE(NFAPI_TRACE_INFO, "%s()\n", __FUNCTION__); int p5ListenSock, p5Sock; @@ -218,7 +215,7 @@ int nfapi_nr_vnf_start(nfapi_vnf_config_t* config) initMsg.sinit_max_instreams = 5; //MAX_SCTP_STREAMS; // number of output streams can be greater if (setsockopt(p5ListenSock, IPPROTO_SCTP, SCTP_INITMSG, &initMsg, sizeof(initMsg)) < 0) { - NFAPI_TRACE(NFAPI_TRACE_ERROR, "After setsockopt (SCTP_INITMSG) errno: %d\n", errno) + NFAPI_TRACE(NFAPI_TRACE_ERROR, "After setsockopt (SCTP_INITMSG) errno: %d\n", errno); close(p5ListenSock); return 0; } @@ -477,14 +474,7 @@ int nfapi_nr_vnf_start(nfapi_vnf_config_t* config) int nfapi_vnf_start(nfapi_vnf_config_t* config) { - // Verify that config is not null - if(config == 0) - return -1; - - // Make sure to set the defined trace function before using NFAPI_TRACE - if(config->trace) - nfapi_trace_g = (nfapi_trace_fn_t)config->trace; - + assert(config != 0); NFAPI_TRACE(NFAPI_TRACE_INFO, "%s()\n", __FUNCTION__); int p5ListenSock, p5Sock; @@ -630,7 +620,7 @@ int nfapi_vnf_start(nfapi_vnf_config_t* config) initMsg.sinit_max_instreams = 5; //MAX_SCTP_STREAMS; // number of output streams can be greater if (setsockopt(p5ListenSock, IPPROTO_SCTP, SCTP_INITMSG, &initMsg, sizeof(initMsg)) < 0) { - NFAPI_TRACE(NFAPI_TRACE_ERROR, "After setsockopt (SCTP_INITMSG) errno: %d\n", errno) + NFAPI_TRACE(NFAPI_TRACE_ERROR, "After setsockopt (SCTP_INITMSG) errno: %d\n", errno); close(p5ListenSock); return 0; } @@ -1164,7 +1154,7 @@ int nfapi_vnf_allocate_phy(nfapi_vnf_config_t* config, int p5_idx, uint16_t* phy info->timing_window = 30; // This seems to override what gets set by the user - why??? //TODO: Change in NR in terms of microsecends,what should be the value? info->timing_info_mode = 0x03; - info->timing_info_period = 128; + info->timing_info_period = 10; nfapi_vnf_phy_info_list_add(config, info); diff --git a/nfapi/open-nFAPI/vnf/src/vnf_p7.c b/nfapi/open-nFAPI/vnf/src/vnf_p7.c index e3900315540f00e1dc88bea25da468fcf48a49a1..2ac59dd7be91f24ca40d6eb1cb8ac87d1393fb84 100644 --- a/nfapi/open-nFAPI/vnf/src/vnf_p7.c +++ b/nfapi/open-nFAPI/vnf/src/vnf_p7.c @@ -17,14 +17,21 @@ #include <time.h> +#include <stdio.h> #include <sys/time.h> #include <stdlib.h> #include <string.h> #include <unistd.h> #include <errno.h> #include <stdio.h> +#include <assert.h> + #include "vnf_p7.h" +#ifdef NDEBUG +# warning assert is disabled +#endif + #define SYNC_CYCLE_COUNT 2 void* vnf_p7_malloc(vnf_p7_t* vnf_p7, size_t size) @@ -816,11 +823,6 @@ void vnf_handle_rx_ulsch_indication(void *pRecvMsg, int recvMsgLen, vnf_p7_t* vn } } - uint16_t i = 0; - for(i = 0; i < ind.rx_indication_body.number_of_pdus; ++i) - { - vnf_p7_codec_free(vnf_p7, ind.rx_indication_body.rx_pdu_list[i].data); - } vnf_p7_codec_free(vnf_p7, ind.rx_indication_body.rx_pdu_list); vnf_p7_codec_free(vnf_p7, ind.vendor_extension); } @@ -1157,7 +1159,7 @@ void vnf_handle_ul_node_sync(void *pRecvMsg, int recvMsgLen, vnf_p7_t* vnf_p7) struct timespec ts; clock_gettime(CLOCK_MONOTONIC, &ts); - NFAPI_TRACE(NFAPI_TRACE_INFO, "(%4d/%1d) %d.%d PNF to VNF phy_id:%2d (t1/2/3/4:%8u, %8u, %8u, %8u) txrx:%4u procT:%3u latency(us):%4d(avg:%4d) offset(us):%8d filtered(us):%8d wrap[t1:%u t2:%u]\n", + NFAPI_TRACE(NFAPI_TRACE_INFO, "(%4d/%1d) %ld.%ld PNF to VNF phy_id:%2d (t1/2/3/4:%8u, %8u, %8u, %8u) txrx:%4u procT:%3u latency(us):%4d(avg:%4d) offset(us):%8d filtered(us):%8d wrap[t1:%u t2:%u]\n", NFAPI_SFNSF2SFN(phy->sfn_sf), NFAPI_SFNSF2SF(phy->sfn_sf), ts.tv_sec, ts.tv_nsec, ind.header.phy_id, ind.t1, ind.t2, ind.t3, t4, tx_2_rx, pnf_proc_time, latency, phy->average_latency, phy->sf_offset, phy->sf_offset_filtered, @@ -1292,7 +1294,7 @@ void vnf_handle_ul_node_sync(void *pRecvMsg, int recvMsgLen, vnf_p7_t* vnf_p7) //NFAPI_TRACE(NFAPI_TRACE_NOTE, "VNF P7 In Sync with phy (phy_id:%d)\n", phy->phy_id); if(vnf_p7->_public.sync_indication) - (vnf_p7->_public.sync_indication)(&(vnf_p7->_public), 1); + (vnf_p7->_public.sync_indication)(&(vnf_p7->_public), phy->in_sync); } phy->in_sync = 1; @@ -1471,7 +1473,8 @@ void vnf_handle_nr_slot_indication(void *pRecvMsg, int recvMsgLen, vnf_p7_t* vnf } else { - if(vnf_p7->_public.nr_slot_indication) + NFAPI_TRACE(NFAPI_TRACE_INFO, "%s: Handling NR SLOT Indication\n", __FUNCTION__); + if(vnf_p7->_public.nr_slot_indication) { (vnf_p7->_public.nr_slot_indication)(&ind); } @@ -1496,12 +1499,12 @@ void vnf_handle_nr_rx_data_indication(void *pRecvMsg, int recvMsgLen, vnf_p7_t* } else { - if(vnf_p7->_public.nr_rx_data_indication) + NFAPI_TRACE(NFAPI_TRACE_INFO, "%s: Handling RX Indication\n", __FUNCTION__); + if(vnf_p7->_public.nr_rx_data_indication) { (vnf_p7->_public.nr_rx_data_indication)(&ind); } } - } } @@ -1522,12 +1525,12 @@ void vnf_handle_nr_crc_indication(void *pRecvMsg, int recvMsgLen, vnf_p7_t* vnf_ } else { + NFAPI_TRACE(NFAPI_TRACE_INFO, "%s: Handling CRC Indication\n", __FUNCTION__); if(vnf_p7->_public.nr_crc_indication) - { + { (vnf_p7->_public.nr_crc_indication)(&ind); } } - } } @@ -1573,12 +1576,12 @@ void vnf_handle_nr_uci_indication(void *pRecvMsg, int recvMsgLen, vnf_p7_t* vnf_ } else { + NFAPI_TRACE(NFAPI_TRACE_INFO, "%s: Handling UCI Indication\n", __FUNCTION__); if(vnf_p7->_public.nr_uci_indication) { (vnf_p7->_public.nr_uci_indication)(&ind); } } - } } @@ -1599,12 +1602,12 @@ void vnf_handle_nr_rach_indication(void *pRecvMsg, int recvMsgLen, vnf_p7_t* vnf } else { + NFAPI_TRACE(NFAPI_TRACE_INFO, "%s: Handling RACH Indication\n", __FUNCTION__); if(vnf_p7->_public.nr_rach_indication) { (vnf_p7->_public.nr_rach_indication)(&ind); } } - } } @@ -1699,14 +1702,7 @@ void vnf_nr_handle_ul_node_sync(void *pRecvMsg, int recvMsgLen, vnf_p7_t* vnf_p7 } if (phy->filtered_adjust && (phy->slot_offset_filtered > 1e6 || phy->slot_offset_filtered < -1e6)) - { struct timespec ts; - clock_gettime(CLOCK_MONOTONIC, &ts); - NFAPI_TRACE(NFAPI_TRACE_NOTE, "(%4d/%1d) %d.%d PNF to VNF phy_id:%2d (t1/2/3/4:%8u, %8u, %8u, %8u) txrx:%4u procT:%3u latency(us):%4d(avg:%4d) offset(us):%8d filtered(us):%8d wrap[t1:%u t2:%u]\n", - phy->sfn, phy->slot, ts.tv_sec, ts.tv_nsec, ind.header.phy_id, - ind.t1, ind.t2, ind.t3, t4, - tx_2_rx, pnf_proc_time, latency, phy->average_latency, phy->slot_offset, phy->slot_offset_filtered, - (ind.t1<phy->previous_t1), (ind.t2<phy->previous_t2)); - + { phy->filtered_adjust = 0; phy->zero_count=0; phy->min_sync_cycle_count = 2; @@ -1738,7 +1734,7 @@ void vnf_nr_handle_ul_node_sync(void *pRecvMsg, int recvMsgLen, vnf_p7_t* vnf_p7 sfn_slot_dec += (phy->slot_offset / 500); - //NFAPI_TRACE(NFAPI_TRACE_NOTE, "PNF to VNF slot offset:%d sfn :%d slot:%d \n",phy->slot_offset,NFAPI_SFNSLOTDEC2SFN(sfn_slot_dec),NFAPI_SFNSLOTDEC2SLOT(sfn_slot_dec) ); + NFAPI_TRACE(NFAPI_TRACE_NOTE, "PNF to VNF slot offset:%d sfn :%d slot:%d \n",phy->slot_offset,NFAPI_SFNSLOTDEC2SFN(sfn_slot_dec),NFAPI_SFNSLOTDEC2SLOT(sfn_slot_dec) ); } @@ -1838,7 +1834,7 @@ void vnf_nr_handle_ul_node_sync(void *pRecvMsg, int recvMsgLen, vnf_p7_t* vnf_p7 NFAPI_TRACE(NFAPI_TRACE_NOTE, "VNF P7 In Sync with phy (phy_id:%d)\n", phy->phy_id); if(vnf_p7->_public.sync_indication) - (vnf_p7->_public.sync_indication)(&(vnf_p7->_public), 1); + (vnf_p7->_public.sync_indication)(&(vnf_p7->_public), phy->in_sync); } phy->in_sync = 1; @@ -2032,6 +2028,7 @@ void vnf_handle_timing_info(void *pRecvMsg, int recvMsgLen, vnf_p7_t* vnf_p7) } } +int16_t vnf_pnf_sfnslot_delta; void vnf_nr_handle_timing_info(void *pRecvMsg, int recvMsgLen, vnf_p7_t* vnf_p7) { @@ -2051,18 +2048,21 @@ void vnf_nr_handle_timing_info(void *pRecvMsg, int recvMsgLen, vnf_p7_t* vnf_p7) if (vnf_p7 && vnf_p7->p7_connections) { //int16_t vnf_pnf_sfnsf_delta = NFAPI_SFNSF2DEC(vnf_p7->p7_connections[0].sfn_sf) - NFAPI_SFNSF2DEC(ind.last_sfn_sf); - int16_t vnf_pnf_sfnslot_delta = NFAPI_SFNSLOT2DEC(vnf_p7->p7_connections[0].sfn,vnf_p7->p7_connections[0].slot) - NFAPI_SFNSLOT2DEC(ind.last_sfn,ind.last_slot); + vnf_pnf_sfnslot_delta = NFAPI_SFNSLOT2DEC(vnf_p7->p7_connections[0].sfn,vnf_p7->p7_connections[0].slot) - NFAPI_SFNSLOT2DEC(ind.last_sfn,ind.last_slot); //NFAPI_TRACE(NFAPI_TRACE_INFO, "%s() PNF:SFN/SF:%d VNF:SFN/SF:%d deltaSFNSF:%d\n", __FUNCTION__, NFAPI_SFNSF2DEC(ind.last_sfn_sf), NFAPI_SFNSF2DEC(vnf_p7->p7_connections[0].sfn_sf), vnf_pnf_sfnsf_delta); // Panos: Careful here!!! Modification of the original nfapi-code //if (vnf_pnf_sfnsf_delta>1 || vnf_pnf_sfnsf_delta < -1) //printf("VNF-PNF delta - %d", vnf_pnf_sfnslot_delta); - if (vnf_pnf_sfnslot_delta>0 || vnf_pnf_sfnslot_delta < 0) + if (vnf_pnf_sfnslot_delta != 0) { - NFAPI_TRACE(NFAPI_TRACE_INFO, "%s() LARGE SFN/SF DELTA between PNF and VNF delta:%d VNF:%d PNF:%d\n\n\n\n\n\n\n\n\n", __FUNCTION__, vnf_pnf_sfnslot_delta,NFAPI_SFNSLOT2DEC(vnf_p7->p7_connections[0].sfn,vnf_p7->p7_connections[0].slot),NFAPI_SFNSLOT2DEC(ind.last_sfn,ind.last_slot)) ; + NFAPI_TRACE(NFAPI_TRACE_INFO, "%s() LARGE SFN/SLOT DELTA between PNF and VNF. Delta %d. PNF:%d.%d VNF:%d.%d\n\n\n\n\n\n\n\n\n", + __FUNCTION__, vnf_pnf_sfnslot_delta, + ind.last_sfn, ind.last_slot, + vnf_p7->p7_connections[0].sfn, vnf_p7->p7_connections[0].slot); // Panos: Careful here!!! Modification of the original nfapi-code - // vnf_p7->p7_connections[0].sfn = ind.last_sfn; - // vnf_p7->p7_connections[0].slot = ind.last_slot; + vnf_p7->p7_connections[0].sfn = ind.last_sfn; + vnf_p7->p7_connections[0].slot = ind.last_slot; } } } @@ -2248,7 +2248,7 @@ void vnf_handle_p7_message(void *pRecvMsg, int recvMsgLen, vnf_p7_t* vnf_p7) // validate the input params if(pRecvMsg == NULL || recvMsgLen < 4 || vnf_p7 == NULL) { - NFAPI_TRACE(NFAPI_TRACE_ERROR, "vnf_handle_p7_message: invalid input params (%d %d %d)\n", pRecvMsg, recvMsgLen, vnf_p7); + NFAPI_TRACE(NFAPI_TRACE_ERROR, "vnf_handle_p7_message: invalid input params (%p %d %p)\n", pRecvMsg, recvMsgLen, vnf_p7); return; } @@ -2366,7 +2366,7 @@ void vnf_nr_handle_p7_message(void *pRecvMsg, int recvMsgLen, vnf_p7_t* vnf_p7) // validate the input params if(pRecvMsg == NULL || recvMsgLen < 4 || vnf_p7 == NULL) { - NFAPI_TRACE(NFAPI_TRACE_ERROR, "vnf_handle_p7_message: invalid input params (%d %d %d)\n", pRecvMsg, recvMsgLen, vnf_p7); + NFAPI_TRACE(NFAPI_TRACE_ERROR, "vnf_handle_p7_message: invalid input params (%p %d %p)\n", pRecvMsg, recvMsgLen, vnf_p7); return; } @@ -2508,26 +2508,22 @@ int vnf_nr_p7_read_dispatch_message(vnf_p7_t* vnf_p7) } // read the segment - recvfrom_result = recvfrom(vnf_p7->socket, vnf_p7->rx_message_buffer, header.message_length, MSG_WAITALL, (struct sockaddr*)&remote_addr, &remote_addr_size); + recvfrom_result = recvfrom(vnf_p7->socket, vnf_p7->rx_message_buffer, header.message_length, MSG_WAITALL | MSG_TRUNC, (struct sockaddr*)&remote_addr, &remote_addr_size); + NFAPI_TRACE(NFAPI_TRACE_DEBUG, "recvfrom_result = %d from %s():%d\n", recvfrom_result, __FUNCTION__, __LINE__); // todo : how to handle incomplete readfroms, need some sort of buffer/select - if(recvfrom_result == 0) - { - NFAPI_TRACE(NFAPI_TRACE_ERROR, "recvfrom returned 0\n"); - } - else if(recvfrom_result != header.message_length) - { - NFAPI_TRACE(NFAPI_TRACE_NOTE, "did not receive the entire message %d %d\n", recvfrom_result, header.message_length); - - recvfrom_result += recvfrom(vnf_p7->socket, &vnf_p7->rx_message_buffer[recvfrom_result], header.message_length - recvfrom_result, MSG_WAITALL, (struct sockaddr*)&remote_addr, &remote_addr_size); - - } - - - if(recvfrom_result > 0) + if (recvfrom_result > 0) { + if (recvfrom_result != header.message_length) + { + NFAPI_TRACE(NFAPI_TRACE_ERROR, "(%d) Received unexpected number of bytes. %d != %d", + __LINE__, recvfrom_result, header.message_length); + break; + } + NFAPI_TRACE(NFAPI_TRACE_DEBUG, "Calling vnf_nr_handle_p7_message from %d\n", __LINE__); vnf_nr_handle_p7_message(vnf_p7->rx_message_buffer, recvfrom_result, vnf_p7); + return 0; } else { @@ -2592,9 +2588,9 @@ int vnf_p7_read_dispatch_message(vnf_p7_t* vnf_p7) { NFAPI_TRACE(NFAPI_TRACE_ERROR, "recvfrom returned 0\n"); } - else if(recvfrom_result != header.message_length) + else if(recvfrom_result != -1 && recvfrom_result != header.message_length) { - NFAPI_TRACE(NFAPI_TRACE_NOTE, "did not receive the entire message %d %d\n", recvfrom_result, header.message_length); + NFAPI_TRACE(NFAPI_TRACE_ERROR, "Received unexpected number of bytes %d %d\n", recvfrom_result, header.message_length); recvfrom_result += recvfrom(vnf_p7->socket, &vnf_p7->rx_message_buffer[recvfrom_result], header.message_length - recvfrom_result, MSG_WAITALL, (struct sockaddr*)&remote_addr, &remote_addr_size); @@ -2646,10 +2642,11 @@ void vnf_p7_release_msg(vnf_p7_t* vnf_p7, nfapi_p7_message_header_t* header) case NFAPI_RX_ULSCH_INDICATION: { nfapi_rx_indication_t* rx_ind = (nfapi_rx_indication_t*)(header); - uint16_t i = 0; - for(i = 0; i < rx_ind->rx_indication_body.number_of_pdus; ++i) + size_t number_of_pdus = rx_ind->rx_indication_body.number_of_pdus; + assert(number_of_pdus <= NFAPI_RX_IND_MAX_PDU); + for(size_t i = 0; i < number_of_pdus; ++i) { - vnf_p7_codec_free(vnf_p7, rx_ind->rx_indication_body.rx_pdu_list[i].data); + vnf_p7_codec_free(vnf_p7, rx_ind->rx_indication_body.rx_pdu_list[i].rx_ind_data); } vnf_p7_codec_free(vnf_p7, rx_ind->rx_indication_body.rx_pdu_list); diff --git a/nfapi/open-nFAPI/vnf/src/vnf_p7_interface.c b/nfapi/open-nFAPI/vnf/src/vnf_p7_interface.c index 8cebf2b468b7f38b475d342639106ab421933617..852707fbbd25e964c8b60753ac375c99485d1275 100644 --- a/nfapi/open-nFAPI/vnf/src/vnf_p7_interface.c +++ b/nfapi/open-nFAPI/vnf/src/vnf_p7_interface.c @@ -1,12 +1,12 @@ /* * Copyright 2017 Cisco Systems, Inc. - * + * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * 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. @@ -45,13 +45,13 @@ nfapi_vnf_p7_config_t* nfapi_vnf_p7_config_create() _this->_public.segment_size = 1400; _this->_public.max_num_segments = 8; _this->_public.checksum_enabled = 1; - + _this->_public.malloc = &malloc; - _this->_public.free = &free; + _this->_public.free = &free; _this->_public.codec_config.allocate = &malloc; _this->_public.codec_config.deallocate = &free; - + return (nfapi_vnf_p7_config_t*)_this; } @@ -81,12 +81,12 @@ struct timespec timespec_add(struct timespec lhs, struct timespec rhs) struct timespec timespec_sub(struct timespec lhs, struct timespec rhs) { struct timespec result; - if ((lhs.tv_nsec-rhs.tv_nsec)<0) + if ((lhs.tv_nsec-rhs.tv_nsec)<0) { result.tv_sec = lhs.tv_sec-rhs.tv_sec-1; result.tv_nsec = 1000000000+lhs.tv_nsec-rhs.tv_nsec; - } - else + } + else { result.tv_sec = lhs.tv_sec-rhs.tv_sec; result.tv_nsec = lhs.tv_nsec-rhs.tv_nsec; @@ -94,7 +94,7 @@ struct timespec timespec_sub(struct timespec lhs, struct timespec rhs) return result; } -// monitor the p7 endpoints and the timing loop and +// monitor the p7 endpoints and the timing loop and // send indications to mac int nfapi_nr_vnf_p7_start(nfapi_vnf_p7_config_t* config) { @@ -107,9 +107,9 @@ int nfapi_nr_vnf_p7_start(nfapi_vnf_p7_config_t* config) vnf_p7_t* vnf_p7 = (vnf_p7_t*)config; - // Create p7 receive udp port + // Create p7 receive udp port // todo : this needs updating for Ipv6 - + NFAPI_TRACE(NFAPI_TRACE_INFO, "Initialising VNF P7 port:%u\n", config->port); // open the UDP socket @@ -128,7 +128,7 @@ int nfapi_nr_vnf_p7_start(nfapi_vnf_p7_config_t* config) NFAPI_TRACE(NFAPI_TRACE_ERROR, "After setsockopt (IP_TOS) errno: %d\n", errno); return -1; } - + NFAPI_TRACE(NFAPI_TRACE_INFO, "VNF P7 setsockopt succeeded...\n"); // Create the address structure @@ -168,20 +168,34 @@ int nfapi_nr_vnf_p7_start(nfapi_vnf_p7_config_t* config) // Add the p7 socket FD_SET(vnf_p7->socket, &rfds); maxSock = vnf_p7->socket; - + struct timespec curr_time; clock_gettime(CLOCK_MONOTONIC, &curr_time); setup_time = curr_time.tv_sec - ref_time.tv_sec; - if(setup_time > 10 && prev_slot != gNB->UL_INFO.slot){ //Give the VNF sufficient time to setup before starting scheduling - - //Call the scheduler + nfapi_nr_slot_indication_scf_t *slot_ind = get_queue(&gnb_slot_ind_queue); + NFAPI_TRACE(NFAPI_TRACE_DEBUG, "This is the slot_ind queue size %ld in %s():%d\n", + gnb_slot_ind_queue.num_items, __FUNCTION__, __LINE__); + if (slot_ind) { pthread_mutex_lock(&gNB->UL_INFO_mutex); - gNB->UL_INFO.module_id = gNB->Mod_id; - gNB->UL_INFO.CC_id = gNB->CC_id; - gNB->if_inst->NR_UL_indication(&gNB->UL_INFO); + gNB->UL_INFO.frame = slot_ind->sfn; + gNB->UL_INFO.slot = slot_ind->slot; + + NFAPI_TRACE(NFAPI_TRACE_DEBUG, "gNB->UL_INFO.frame = %d and slot %d, prev_slot = %d, setup_time = %d\n", + gNB->UL_INFO.frame, gNB->UL_INFO.slot, prev_slot, setup_time); + if (setup_time > 3 && prev_slot != gNB->UL_INFO.slot) { //Give the VNF sufficient time to setup before starting scheduling && prev_slot != gNB->UL_INFO.slot + + //Call the scheduler + gNB->UL_INFO.module_id = gNB->Mod_id; + gNB->UL_INFO.CC_id = gNB->CC_id; + NFAPI_TRACE(NFAPI_TRACE_DEBUG, "Calling NR_UL_indication for gNB->UL_INFO.frame = %d and slot %d\n", + gNB->UL_INFO.frame, gNB->UL_INFO.slot); + gNB->if_inst->NR_UL_indication(&gNB->UL_INFO); + prev_slot = gNB->UL_INFO.slot; + } pthread_mutex_unlock(&gNB->UL_INFO_mutex); - prev_slot = gNB->UL_INFO.slot; + free(slot_ind); + slot_ind = NULL; } selectRetval = pselect(maxSock+1, &rfds, NULL, NULL, &pselect_timeout, NULL); @@ -234,9 +248,9 @@ int nfapi_vnf_p7_start(nfapi_vnf_p7_config_t* config) vnf_p7_t* vnf_p7 = (vnf_p7_t*)config; - // Create p7 receive udp port + // Create p7 receive udp port // todo : this needs updating for Ipv6 - + NFAPI_TRACE(NFAPI_TRACE_INFO, "Initialising VNF P7 port:%u\n", config->port); // open the UDP socket @@ -255,7 +269,7 @@ int nfapi_vnf_p7_start(nfapi_vnf_p7_config_t* config) NFAPI_TRACE(NFAPI_TRACE_ERROR, "After setsockopt (IP_TOS) errno: %d\n", errno); return -1; } - + NFAPI_TRACE(NFAPI_TRACE_INFO, "VNF P7 setsockopt succeeded...\n"); // Create the address structure @@ -299,7 +313,7 @@ int nfapi_vnf_p7_start(nfapi_vnf_p7_config_t* config) clock_gettime(CLOCK_MONOTONIC, &sf_start); long millisecond = sf_start.tv_nsec / 1e6; sf_start = timespec_add(sf_start, sf_duration); - NFAPI_TRACE(NFAPI_TRACE_INFO, "next subframe will start at %d.%d\n", sf_start.tv_sec, sf_start.tv_nsec); + NFAPI_TRACE(NFAPI_TRACE_INFO, "next subframe will start at %ld.%ld\n", sf_start.tv_sec, sf_start.tv_nsec); while(vnf_p7->terminate == 0) { @@ -311,7 +325,7 @@ int nfapi_vnf_p7_start(nfapi_vnf_p7_config_t* config) // Add the p7 socket FD_SET(vnf_p7->socket, &rfds); maxSock = vnf_p7->socket; - + clock_gettime(CLOCK_MONOTONIC, &pselect_start); //long millisecond = pselect_start.tv_nsec / 1e6; @@ -320,7 +334,7 @@ int nfapi_vnf_p7_start(nfapi_vnf_p7_config_t* config) //NFAPI_TRACE(NFAPI_TRACE_INFO, "pselect_start:%d.%d sf_start:%d.%d\n", pselect_start.tv_sec, pselect_start.tv_nsec, sf_start.tv_sec, sf_start.tv_nsec); - if((pselect_start.tv_sec > sf_start.tv_sec) || + if((pselect_start.tv_sec > sf_start.tv_sec) || ((pselect_start.tv_sec == sf_start.tv_sec) && (pselect_start.tv_nsec > sf_start.tv_nsec))) { // overran the end of the subframe we do not want to wait @@ -343,7 +357,7 @@ int nfapi_vnf_p7_start(nfapi_vnf_p7_config_t* config) //pselect_timeout.tv_nsec = 1e6 - (pselect_start.tv_nsec % 1000000); //uint8_t underrun_possible =0; - + // if we are not sleeping until the next milisecond due to the // insycn minor adjment flag it so we don't consider it an error //uint8_t underrun_possible =0; @@ -353,7 +367,7 @@ int nfapi_vnf_p7_start(nfapi_vnf_p7_config_t* config) if(phy && phy->in_sync && phy->insync_minor_adjustment != 0 && phy->insync_minor_adjustment_duration > 0 && pselect_start.tv_nsec != 0) { NFAPI_TRACE(NFAPI_TRACE_NOTE, "[VNF] Subframe minor adjustment %d (%d->%d)\n", phy->insync_minor_adjustment, - pselect_timeout.tv_nsec, pselect_timeout.tv_nsec - (phy->insync_minor_adjustment * 1000)) + pselect_timeout.tv_nsec, pselect_timeout.tv_nsec - (phy->insync_minor_adjustment * 1000)) if(phy->insync_minor_adjustment > 0) { // todo check we don't go below 0 @@ -376,7 +390,7 @@ int nfapi_vnf_p7_start(nfapi_vnf_p7_config_t* config) } } */ - + //long wraps = pselect_timeout.tv_nsec % 1e9; @@ -389,9 +403,9 @@ int nfapi_vnf_p7_start(nfapi_vnf_p7_config_t* config) if (selectRetval==-1 && errno == 22) { - NFAPI_TRACE(NFAPI_TRACE_ERROR, "INVAL: pselect_timeout:%d.%ld adj[dur:%d adj:%d], sf_dur:%d.%ld\n", - pselect_timeout.tv_sec, pselect_timeout.tv_nsec, - phy->insync_minor_adjustment_duration, phy->insync_minor_adjustment, + NFAPI_TRACE(NFAPI_TRACE_ERROR, "INVAL: pselect_timeout:%ld.%ld adj[dur:%d adj:%d], sf_dur:%ld.%ld\n", + pselect_timeout.tv_sec, pselect_timeout.tv_nsec, + phy->insync_minor_adjustment_duration, phy->insync_minor_adjustment, sf_duration.tv_sec, sf_duration.tv_nsec); } if(selectRetval == 0) @@ -449,7 +463,7 @@ if (selectRetval==-1 && errno == 22) //phy->insync_minor_adjustment = 0; phy->insync_minor_adjustment_duration--; - NFAPI_TRACE(NFAPI_TRACE_NOTE, "[VNF] AFTER adjustment - Subframe minor adjustment %dus sf_start.tv_nsec:%d duration:%u\n", + NFAPI_TRACE(NFAPI_TRACE_NOTE, "[VNF] AFTER adjustment - Subframe minor adjustment %dus sf_start.tv_nsec:%ld duration:%u\n", phy->insync_minor_adjustment, sf_start.tv_nsec, phy->insync_minor_adjustment_duration); if (phy->insync_minor_adjustment_duration==0) @@ -473,7 +487,7 @@ if (selectRetval==-1 && errno == 22) } last_millisecond = millisecond; */ - + millisecond ++; } } @@ -497,9 +511,7 @@ if (selectRetval==-1 && errno == 22) while(curr != 0) { curr->sfn_sf = increment_sfn_sf(curr->sfn_sf); - vnf_sync(vnf_p7, curr); - curr = curr->next; } @@ -523,7 +535,7 @@ if (selectRetval==-1 && errno == 22) } else { - NFAPI_TRACE(NFAPI_TRACE_INFO, "P7 select failed result %d errno %d timeout:%d.%d orginal:%d.%d last_ms:%ld ms:%ld\n", selectRetval, errno, pselect_timeout.tv_sec, pselect_timeout.tv_nsec, pselect_timeout.tv_sec, pselect_timeout.tv_nsec, last_millisecond, millisecond); + NFAPI_TRACE(NFAPI_TRACE_INFO, "P7 select failed result %d errno %d timeout:%ld.%ld orginal:%ld.%ld last_ms:%ld ms:%ld\n", selectRetval, errno, pselect_timeout.tv_sec, pselect_timeout.tv_nsec, pselect_timeout.tv_sec, pselect_timeout.tv_nsec, last_millisecond, millisecond); // should we exit now? if (selectRetval == -1 && errno == 22) // invalid argument??? not sure about timeout duration { @@ -534,7 +546,7 @@ if (selectRetval==-1 && errno == 22) } - + NFAPI_TRACE(NFAPI_TRACE_INFO, "Closing p7 socket\n"); close(vnf_p7->socket); diff --git a/openair1/PHY/CODING/DOC/LDPCImplementation.md b/openair1/PHY/CODING/DOC/LDPCImplementation.md index c5411540b61a6c99bfbde094eb5d769690ca9737..a82c2040740dc1b3ab0597d44b575505b2e3f709 100644 --- a/openair1/PHY/CODING/DOC/LDPCImplementation.md +++ b/openair1/PHY/CODING/DOC/LDPCImplementation.md @@ -24,12 +24,33 @@ loading `libldpc_cl.so` instead of `libldpc.so`: `make ldpc_cl` -`cp ../../../openair1/PHY/CODING/nrLDPC_decoder/nrLDPC_decoder_kernels_CL.cl` +This command creates the `libldpc_cl.so` shared library. To perform this build successfully, only the OpenCL header `(/usr/include/CL/opencl.h)` and library `(/usr/lib/x86_64-linux-gnu/libOpenCL.so)`are required, they implement OpenCL API support which is not hardware dependent. + +``` +Scanning dependencies of target nrLDPC_decoder_kernels_CL +Built target nrLDPC_decoder_kernels_CL +Scanning dependencies of target ldpc_cl +Building C object CMakeFiles/ldpc_cl.dir/usr/local/oai/oai-develop/openairinterface5g/openair1/PHY/CODING/nrLDPC_decoder/nrLDPC_decoder_CL.c.o +In file included from /usr/include/CL/cl.h:32, + from /usr/include/CL/opencl.h:38, + from /usr/local/oai/oai-develop/openairinterface5g/openair1/PHY/CODING/nrLDPC_decoder/nrLDPC_decoder_CL.c:49: +/usr/include/CL/cl_version.h:34:9: note: #pragma message: cl_version.h: CL_TARGET_OPENCL_VERSION is not defined. Defaulting to 220 (OpenCL 2.2) + #pragma message("cl_version.h: CL_TARGET_OPENCL_VERSION is not defined. Defaulting to 220 (OpenCL 2.2)") + ^~~~~~~ + +Building C object CMakeFiles/ldpc_cl.dir/usr/local/oai/oai-develop/openairinterface5g/openair1/PHY/CODING/nrLDPC_encoder/ldpc_encoder_optim8segmulti.c.o +Linking C shared module libldpc_cl.so +Built target ldpc_cl + +``` + +At runtime, to successfully use hardware acceleration via OpenCL, you need to install vendor specific packages which deliver the required drivers and tools to make use of their GPU (Nvidia, Intel...) , fpga (Xilinx, Intel) or CPU (Intel, AMD, ARM...) through OpenCL. `./nr-softmodem -O libconfig:gnb.band78.sa.fr1.106PRB.usrpb210.conf:dbgl5 --rfsim --rfsimulator.serveraddr server --sa --log_config.gtpu_log_level info --loader.ldpc.shlibversion _cl` -``` [LOADER] library libldpc_cl.so successfully loaded +``` ------------------------------------------------ +[LOADER] library libldpc_cl.so successfully loaded [HW] Platform 0, OpenCL profile FULL_PROFILE [HW] Platform 0, OpenCL version OpenCL 2.1 LINUX [HW] Device 0 is available @@ -62,8 +83,9 @@ loading `libldpc_cl.so` instead of `libldpc.so`: `./nr-uesoftmodem -r 106 --numerology 1 --band 78 -C 3619200000 --rfsim --sa -O libconfig:/usr/local/oai/conf/nrue_sim.conf:dbgl5 --nokrnmod --loader.ldpc.shlibversion _cl --log_config.hw_log_level info` -```[CONFIG] shlibversion set to _cl from command line +``` ............................................................ +[CONFIG] shlibversion set to _cl from command line [CONFIG] loader.ldpc 1 options set from command line [LOADER] library libldpc_cl.so successfully loaded [HW] Platform 0, OpenCL profile FULL_PROFILE @@ -94,7 +116,6 @@ loading `libldpc_cl.so` instead of `libldpc.so`: [HW] Device 0, max Work Items size for dimension: 1 512 [HW] Device 0, max Work Items size for dimension: 2 512 ------------------------------------------------------------ -​``` ``` A mechanism to select ldpc implementation is also available in the `ldpctest` phy simulator via the `-v`option, which can be used to specify the version of the ldpc shared library to be used. @@ -103,7 +124,9 @@ A mechanism to select ldpc implementation is also available in the `ldpctest` ph Loading libldpc_cuda.so, the cuda implementation of the ldpc decoder: -```$ ./ldpctest -v _cuda +``` +$ ./ldpctest -v _cuda +ldpctest -v _cuda Initializing random number generator, seed 0 block length 8448: n_trials 1: @@ -119,18 +142,16 @@ log init done [CONFIG] loader.ldpc: 1/2 parameters successfully set [LOADER] library libldpc_cuda.so successfully loaded ................................... -​``` ``` + Loading libldpc_cl.so, the opencl implementation of the ldpc decoder: `make ldpc_cl` -`cp ../../../openair1/PHY/CODING/nrLDPC_decoder/nrLDPC_decoder_kernels_CL.cl` -`./ldpctest -v _cl` - -```$ ./ldpctest -v _cl +``` +$ ./ldpctest -v _cl Initializing random number generator, seed 0 block length 8448: n_trials 1: @@ -164,7 +185,6 @@ log init done [HW] Device 0, max Work Items size for dimension: 1 512 [HW] Device 0, max Work Items size for dimension: 2 512 ................................ -​``` ``` @@ -174,6 +194,6 @@ Libraries implementing the LDPC algorithms must be named `libldpc<_version>.so`, `libldpc_cuda.so`has been tested with the `ldpctest` executable, usage from the softmodem's has to be tested. -`libldpc_cl`is under development. +`libldpc_cl.so`is under development. [oai Wikis home](https://gitlab.eurecom.fr/oai/openairinterface5g/wikis/home) diff --git a/openair1/PHY/CODING/TESTBENCH/ldpctest.c b/openair1/PHY/CODING/TESTBENCH/ldpctest.c index aff707a1d5e74c7833f5e4782690d05df3220b30..371deba3f28546e5a01f0107c03f88e2fa6b8c14 100644 --- a/openair1/PHY/CODING/TESTBENCH/ldpctest.c +++ b/openair1/PHY/CODING/TESTBENCH/ldpctest.c @@ -514,7 +514,7 @@ int main(int argc, char *argv[]) unsigned char qbits=8; unsigned int decoded_errors[10000]; // initiate the size of matrix equivalent to size of SNR int c,i=0, i1 = 0; - + int loglvl=OAILOG_WARNING; int n_trials = 1; double SNR_step = 0.1; @@ -525,8 +525,11 @@ int main(int argc, char *argv[]) n_iter_stats_t dec_iter[3]; short BG=0,Zc,Kb=0; - - while ((c = getopt (argc, argv, "q:r:s:S:l:G:n:d:i:t:u:hv:")) != -1) + if ( load_configmodule(argc,argv,CONFIG_ENABLECMDLINEONLY) == 0) { + exit_fun(" Error, configuration module init failed\n"); + } // must be done before specific options parsing to prevent errasing them + + while ((c = getopt (argc, argv, "q:r:s:S:l:L:G:n:d:i:t:u:hv:")) != -1) switch (c) { case 'q': @@ -544,6 +547,10 @@ int main(int argc, char *argv[]) case 'l': block_length = atoi(optarg); break; + + case 'L': + loglvl = atoi(optarg); + break; case 'G': ldpc_version="_cuda"; @@ -581,10 +588,11 @@ int main(int argc, char *argv[]) printf("BG1 (blocklength > 3840): 1/3, 2/3, 22/25 (8/9) \n"); printf("BG2 (blocklength <= 3840): 1/5, 1/3, 2/3 \n\n"); printf("-h This message\n"); + printf("-L <log level, 0(errors), 1(warning), 2(info) 3(debug) 4 (trace)>\n"); printf("-q Quantization bits, Default: 8\n"); printf("-r Nominator rate, (1, 2, 22), Default: 1\n"); printf("-d Denominator rate, (3, 5, 25), Default: 1\n"); - printf("-l Block length (l > 3840 -> BG1, rest BG2 ), Default: 8448\n"); + printf("-l Block length (l > 3840 -> BG1, rest BG2 ), Default: 8448\n"); printf("-G give 1 to run cuda for LDPC, Default: 0\n"); printf("-n Number of simulation trials, Default: 1\n"); //printf("-M MCS2 for TB 2\n"); @@ -603,6 +611,8 @@ int main(int argc, char *argv[]) printf("n_trials %d: \n", n_trials); printf("SNR0 %f: \n", SNR0); + logInit(); + set_glog(loglvl); if (ldpc_version != NULL) load_nrLDPClib(ldpc_version); diff --git a/openair1/PHY/CODING/crc.h b/openair1/PHY/CODING/crc.h index c31366765f63beaae17afd0f1033793e6c912bb9..d6474eae9b7e49405724abccd147063a2b92c272 100644 --- a/openair1/PHY/CODING/crc.h +++ b/openair1/PHY/CODING/crc.h @@ -44,6 +44,8 @@ #include "crcext.h" #include "types.h" +#include <immintrin.h> +#include <wmmintrin.h> /** * PCLMULQDQ CRC computation context structure diff --git a/openair1/PHY/CODING/crc_byte.c b/openair1/PHY/CODING/crc_byte.c index a0ad837e877d4b49f0c559280eb482f0f7789776..7e37abcf8152c4b388dd206edd0d3aee6523beff 100644 --- a/openair1/PHY/CODING/crc_byte.c +++ b/openair1/PHY/CODING/crc_byte.c @@ -30,12 +30,15 @@ Modified in June, 2001, to include the length non multiple of 8 */ -#define USE_INTEL_CRC 1 +#ifndef __SSE4_1__ +#define USE_INTEL_CRC 0 +#else +#define USE_INTEL_CRC __SSE4_1__ +#endif #include "coding_defs.h" #include "assertions.h" -#ifdef USE_INTEL_CRC -#include "crc_intel.h" +#if USE_INTEL_CRC #include "crc.h" #endif /*ref 36-212 v8.6.0 , pp 8-9 */ @@ -98,7 +101,7 @@ static unsigned short crc11Table[256]; static unsigned char crc8Table[256]; static unsigned char crc6Table[256]; -#ifdef USE_INTEL_CRC +#if USE_INTEL_CRC static DECLARE_ALIGNED(struct crc_pclmulqdq_ctx lte_crc24a_pclmulqdq, 16) = { 0x64e4d700, /**< k1 */ 0x2c8c9d00, /**< k2 */ @@ -134,9 +137,9 @@ void crcTableInit (void) crc8Table[c] = (unsigned char) (crcbit (&c, 1, poly8) >> 24); crc6Table[c] = (unsigned char) (crcbit (&c, 1, poly6) >> 24); } while (++c); -#ifdef USE_INTEL_CRC - crc_xmm_be_le_swap128 = _mm_setr_epi32(0x0c0d0e0f, 0x08090a0b, - 0x04050607, 0x00010203); +#if USE_INTEL_CRC + crc_xmm_be_le_swap128 = _mm_setr_epi32(0x0c0d0e0f, 0x08090a0b, + 0x04050607, 0x00010203); #endif } @@ -153,26 +156,29 @@ unsigned int crc24a (unsigned char * inptr, { int octetlen = bitlen / 8; /* Change in octets */ - if ( bitlen % 8 /*|| !__builtin_cpu_supports ("pclmul")*/ ) { - unsigned int crc = 0; - int resbit = (bitlen % 8); - - while (octetlen-- > 0) { - // printf("crc24a: in %x => crc %x\n",crc,*inptr); - crc = (crc << 8) ^ crc24aTable[(*inptr++) ^ (crc >> 24)]; - } - - if (resbit > 0) - crc = (crc << resbit) ^ crc24aTable[((*inptr) >> (8 - resbit)) ^ (crc >> (32 - resbit))]; - return crc; - } else { - return crc32_calc_pclmulqdq(inptr, octetlen, 0, + if ( bitlen % 8 || !USE_INTEL_CRC ) { + unsigned int crc = 0; + int resbit= (bitlen % 8); + + while (octetlen-- > 0) { + // printf("crc24a: in %x => crc %x\n",crc,*inptr); + crc = (crc << 8) ^ crc24aTable[(*inptr++) ^ (crc >> 24)]; + } + + if (resbit > 0) + crc = (crc << resbit) ^ crc24aTable[((*inptr) >> (8 - resbit)) ^ (crc >> (32 - resbit))]; + return crc; + } + #if USE_INTEL_CRC + else { + return crc32_calc_pclmulqdq(inptr, octetlen, 0, <e_crc24a_pclmulqdq); } + #endif } -#ifdef USE_INTEL_CRC +#if USE_INTEL_CRC static DECLARE_ALIGNED(struct crc_pclmulqdq_ctx lte_crc24b_pclmulqdq, 16) = { 0x80140500, /**< k1 */ 0x42000100, /**< k2 */ @@ -186,8 +192,8 @@ unsigned int crc24b (unsigned char * inptr, int bitlen) { int octetlen = bitlen / 8; /* Change in octets */ - - if ( bitlen % 8 /*|| !__builtin_cpu_supports ("pclmul") */) { + + if ( bitlen % 8 || !USE_INTEL_CRC ) { unsigned int crc = 0; int resbit = (bitlen % 8); @@ -200,10 +206,13 @@ unsigned int crc24b (unsigned char * inptr, crc = (crc << resbit) ^ crc24bTable[((*inptr) >> (8 - resbit)) ^ (crc >> (32 - resbit))]; return crc; - } else { + } +#if USE_INTEL_CRC + else { return crc32_calc_pclmulqdq(inptr, octetlen, 0, <e_crc24b_pclmulqdq); } +#endif } unsigned int crc24c (unsigned char * inptr, diff --git a/openair1/PHY/CODING/crc_intel.h b/openair1/PHY/CODING/crc_intel.h deleted file mode 100644 index c31366765f63beaae17afd0f1033793e6c912bb9..0000000000000000000000000000000000000000 --- a/openair1/PHY/CODING/crc_intel.h +++ /dev/null @@ -1,541 +0,0 @@ -/******************************************************************************* - Copyright (c) 2009-2018, Intel Corporation - - Redistribution and use in source and binary forms, with or without - modification, are permitted provided that the following conditions are met: - - * Redistributions of source code must retain the above copyright notice, - this list of conditions and the following disclaimer. - * Redistributions in binary form must reproduce the above copyright - notice, this list of conditions and the following disclaimer in the - documentation and/or other materials provided with the distribution. - * Neither the name of Intel Corporation nor the names of its contributors - may be used to endorse or promote products derived from this software - without specific prior written permission. - - THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" - AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE - FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR - SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER - CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, - OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -*******************************************************************************/ - -/** - * Header file for module with CRC computation methods - * - * PCLMULQDQ implementation is based on work by: - * Erdinc Ozturk - * Vinodh Gopal - * James Guilford - * - * "Fast CRC Computation for Generic Polynomials Using PCLMULQDQ Instruction" - * URL: http://download.intel.com/design/intarch/papers/323102.pdf - */ - -#ifndef __CRC_H__ -#define __CRC_H__ - -#include <x86intrin.h> - -#include "crcext.h" -#include "types.h" - -/** - * PCLMULQDQ CRC computation context structure - */ -struct crc_pclmulqdq_ctx { - /** - * K1 = reminder X^128 / P(X) : 0-63 - * K2 = reminder X^192 / P(X) : 64-127 - */ - uint64_t k1; - uint64_t k2; - - /** - * K3 = reminder X^64 / P(X) : 0-63 - * q = quotient X^64 / P(X) : 64-127 - */ - uint64_t k3; - uint64_t q; - - /** - * p = polynomial / P(X) : 0-63 - * res = reserved : 64-127 - */ - uint64_t p; - uint64_t res; -}; - -/** - * Functions and prototypes - */ - -/** - * @brief Initializes look-up-table (LUT) for given 8 bit polynomial - * - * @param poly CRC polynomial - * @param lut pointer to look-up-table to be initialized - */ -void crc8_init_lut(const uint8_t poly, uint8_t *lut); - -/** - * @brief Calculates 8 bit CRC using LUT method. - * - * @param crc CRC initial value - * @param data pointer to data block to calculate CRC for - * @param data_len size of data block - * @param lut 256x8bits look-up-table pointer - * - * @return New CRC value - */ -__forceinline -uint8_t crc8_calc_lut(const uint8_t *data, - uint32_t data_len, - uint8_t crc, - const uint8_t *lut) -{ - if (unlikely(data == NULL || lut == NULL)) - return crc; - - while (data_len--) - crc = lut[*data++ ^ crc]; - - return crc; -} - -/** - * @brief Initializes look-up-table (LUT) for given 16 bit polynomial - * - * @param poly CRC polynomial - * @param lut pointer to 256x16bits look-up-table to be initialized - */ -void crc16_init_lut(const uint16_t poly, uint16_t *lut); - -/** - * @brief Calculates 16 bit CRC using LUT method. - * - * @param crc CRC initial value - * @param data pointer to data block to calculate CRC for - * @param data_len size of data block - * @param lut 256x16bits look-up-table pointer - * - * @return New CRC value - */ -__forceinline -uint16_t crc16_calc_lut(const uint8_t *data, - uint32_t data_len, - uint16_t crc, - const uint16_t *lut) -{ - if (unlikely(data == NULL || lut == NULL)) - return crc; - - while (data_len--) - crc = lut[(crc >> 8) ^ *data++] ^ (crc << 8); - - return crc; -} - -/** - * @brief Initializes look-up-table (LUT) for given 32 bit polynomial - * - * @param poly CRC polynomial - * @param lut pointer to 256x32bits look-up-table to be initialized - */ -void crc32_init_lut(const uint32_t poly, uint32_t *lut); - -/** - * @brief Calculates 32 bit CRC using LUT method. - * - * @param crc CRC initial value - * @param data pointer to data block to calculate CRC for - * @param data_len size of data block - * @param lut 256x32bits look-up-table pointer - * - * @return New CRC value - */ -__forceinline -uint32_t crc32_calc_lut(const uint8_t *data, - uint32_t data_len, - uint32_t crc, - const uint32_t *lut) -{ - if (unlikely(data == NULL || lut == NULL)) - return crc; - - while (data_len--) - crc = lut[(crc >> 24) ^ *data++] ^ (crc << 8); - - return crc; -} - -/** - * @brief Initializes look up tables for slice-By-2 method. - * - * @param poly CRC polynomial - * @param slice1 slice-by-2 look-up-table 1 - * @param slice2 slice-by-2 look-up-table 2 - * - * @return New CRC value - */ -void crc16_init_slice2(const uint16_t poly, - uint16_t *slice1, - uint16_t *slice2); - -/** - * @brief Calculates 16 bit CRC using Slice-By-2 method. - * - * @param crc CRC initial value - * @param data pointer to data block to calculate CRC for - * @param data_len size of data block - * @param slice1 256x16bits slice look-up-table 1 - * @param slice2 256x16bits slice look-up-table 2 - * - * @return New CRC value - */ -__forceinline -uint16_t crc16_calc_slice2(const uint8_t *data, - uint32_t data_len, - uint16_t crc, - const uint16_t *slice1, - const uint16_t *slice2) -{ - uint_fast32_t i; - - if (unlikely(data == NULL)) - return crc; - - if (unlikely(slice1 == NULL || slice2 == NULL)) - return crc; - - crc = bswap2(crc); - for (i = (data_len & (~1)), data += (data_len & (~1)); i != 0; - i -= sizeof(uint16_t)) { - crc ^= (*((const uint16_t *)(data - i))); - crc = slice2[(uint8_t)crc] ^ slice1[(uint8_t)(crc >> 8)]; - } - crc = bswap2(crc); - if (data_len & 1) - crc = (crc << 8) ^ bswap2(slice1[(crc >> 8) ^ *data]); - - return crc; -} - -/** - * @brief Initializes look up tables for slice-By-4 method. - * - * @param poly CRC polynomial - * @param slice1 256x32bits slice look-up-table 1 - * @param slice2 256x32bits slice look-up-table 2 - * @param slice3 256x32bits slice look-up-table 3 - * @param slice4 256x32bits slice look-up-table 4 - * - * @return New CRC value - */ -void crc32_init_slice4(const uint32_t poly, - uint32_t *slice1, uint32_t *slice2, - uint32_t *slice3, uint32_t *slice4); - -/** - * @brief Calculates 32 bit CRC using Slice-By-4 method. - * - * @param data pointer to data block to calculate CRC for - * @param data_len size of data block - * @param crc CRC initial value - * @param slice1 256x32bits slice look-up-table 1 - * @param slice2 256x32bits slice look-up-table 2 - * @param slice3 256x32bits slice look-up-table 3 - * @param slice4 256x32bits slice look-up-table 4 - * - * @return New CRC value - */ -__forceinline -uint32_t crc32_calc_slice4(const uint8_t *data, - uint32_t data_len, uint32_t crc, - const uint32_t *slice1, const uint32_t *slice2, - const uint32_t *slice3, const uint32_t *slice4) -{ - uint_fast32_t i; - - if (unlikely(data == NULL)) - return crc; - - if (unlikely(slice1 == NULL || slice2 == NULL || - slice3 == NULL || slice4 == NULL)) - return crc; - - crc = bswap4(crc); - for (i = data_len & (~3), data += (data_len & (~3)); i != 0; - i -= sizeof(uint32_t)) { - crc ^= (*((const uint32_t *)(data - i))); - crc = slice4[(uint8_t)(crc)] ^ - slice3[(uint8_t)(crc >> 8)] ^ - slice2[(uint8_t)(crc >> 16)] ^ - slice1[(uint8_t)(crc >> 24)]; - } - crc = bswap4(crc); - for (i = data_len & 3, data += (data_len & 3); i != 0; i--) - crc = (crc << 8) ^ - bswap4(slice1[(crc >> 24) ^ *(data - i)]); - - return crc; -} - -/** - * @brief Performs one folding round - * - * Logically function operates as follows: - * DATA = READ_NEXT_16BYTES(); - * F1 = LSB8(FOLD) - * F2 = MSB8(FOLD) - * T1 = CLMUL( F1, K1 ) - * T2 = CLMUL( F2, K2 ) - * FOLD = XOR( T1, T2, DATA ) - * - * @param data_block 16 byte data block - * @param k1_k2 k1 and k2 constanst enclosed in XMM register - * @param fold running 16 byte folded data - * - * @return New 16 byte folded data - */ -__forceinline -__m128i crc32_folding_round(const __m128i data_block, - const __m128i k1_k2, - const __m128i fold) -{ - __m128i tmp = _mm_clmulepi64_si128(fold, k1_k2, 0x11); - - return _mm_xor_si128(_mm_clmulepi64_si128(fold, k1_k2, 0x00), - _mm_xor_si128(data_block, tmp)); -} - -/** - * @brief Performs Barret's reduction from 128 bits to 64 bits - * - * @param data128 128 bits data to be reduced - * @param k3_q k3 and Q constants enclosed in XMM register - * - * @return data reduced to 64 bits - */ -__forceinline -__m128i crc32_reduce_128_to_64(__m128i data128, const __m128i k3_q) -{ - __m128i tmp; - - tmp = _mm_xor_si128(_mm_clmulepi64_si128(data128, k3_q, 0x01 /* k3 */), - data128); - - data128 = _mm_xor_si128(_mm_clmulepi64_si128(tmp, k3_q, 0x01 /* k3 */), - data128); - - return _mm_srli_si128(_mm_slli_si128(data128, 8), 8); -} - -/** - * @brief Performs Barret's reduction from 64 bits to 32 bits - * - * @param data64 64 bits data to be reduced - * @param k3_q k3 and Q constants enclosed in XMM register - * @param p_res P constant enclosed in XMM register - * - * @return data reduced to 32 bits - */ -__forceinline -uint32_t -crc32_reduce_64_to_32(__m128i fold, const __m128i k3_q, const __m128i p_res) -{ - __m128i temp; - - temp = _mm_clmulepi64_si128(_mm_srli_si128(fold, 4), - k3_q, 0x10 /* Q */); - temp = _mm_srli_si128(_mm_xor_si128(temp, fold), 4); - temp = _mm_clmulepi64_si128(temp, p_res, 0 /* P */); - return _mm_extract_epi32(_mm_xor_si128(temp, fold), 0); -} - -/** - * @brief Calculates 32 bit CRC for given \a data block by applying folding and - * reduction methods. - * - * Algorithm operates on 32 bit CRCs so polynomials and initial values may - * need to be promoted to 32 bits where required. - * - * @param crc initial CRC value (32 bit value) - * @param data pointer to data block - * @param data_len length of \a data block in bytes - * @param params pointer to PCLMULQDQ CRC calculation context - * - * @return CRC for given \a data block (32 bits wide). - */ -__forceinline -uint32_t -crc32_calc_pclmulqdq(const uint8_t *data, - uint32_t data_len, uint32_t crc, - const struct crc_pclmulqdq_ctx *params) -{ - __m128i temp, fold, k, swap; - uint32_t n; - - if (unlikely(data == NULL || data_len == 0 || params == NULL)) - return crc; - -#ifdef __KERNEL__ - /** - * Preserve FPU context - */ - kernel_fpu_begin(); -#endif - - /** - * Add 4 bytes to data block size - * This is to secure the following: - * CRC32 = M(X)^32 mod P(X) - * M(X) - message to compute CRC on - * P(X) - CRC polynomial - */ - data_len += 4; - - /** - * Load first 16 data bytes in \a fold and - * set \a swap BE<->LE 16 byte conversion variable - */ - fold = _mm_loadu_si128((__m128i *)data); - swap = crc_xmm_be_le_swap128; - - /** - * ------------------------------------------------- - * Folding all data into single 16 byte data block - * Assumes: \a fold holds first 16 bytes of data - */ - - if (unlikely(data_len <= 16)) { - /** - * Data block fits into 16 byte block - * - adjust data block - * - 4 least significant bytes need to be zero - */ - fold = _mm_shuffle_epi8(fold, swap); - fold = _mm_slli_si128(xmm_shift_right(fold, 20 - data_len), 4); - - /** - * Apply CRC init value - */ - temp = _mm_insert_epi32(_mm_setzero_si128(), bswap4(crc), 0); - temp = xmm_shift_left(temp, data_len - 4); - fold = _mm_xor_si128(fold, temp); - } else { - /** - * There are 2x16 data blocks or more - */ - __m128i next_data; - - /** - * n = number of bytes required to align \a data_len - * to multiple of 16 - */ - n = ((~data_len) + 1) & 15; - - /** - * Apply CRC initial value and - * get \a fold to BE format - */ - fold = _mm_xor_si128(fold, - _mm_insert_epi32(_mm_setzero_si128(), - crc, 0)); - fold = _mm_shuffle_epi8(fold, swap); - - /** - * Load next 16 bytes of data and - * adjust \a fold & \a next_data as follows: - * - * CONCAT(fold,next_data) >> (n*8) - */ - next_data = _mm_loadu_si128((__m128i *)&data[16]); - next_data = _mm_shuffle_epi8(next_data, swap); - next_data = _mm_or_si128(xmm_shift_right(next_data, n), - xmm_shift_left(fold, 16 - n)); - fold = xmm_shift_right(fold, n); - - if (unlikely(data_len <= 32)) - /** - * In such unlikely case clear 4 least significant bytes - */ - next_data = - _mm_slli_si128(_mm_srli_si128(next_data, 4), 4); - - /** - * Do the initial folding round on 2 first 16 byte chunks - */ - k = _mm_load_si128((__m128i *)(¶ms->k1)); - fold = crc32_folding_round(next_data, k, fold); - - if (likely(data_len > 32)) { - /** - * \a data_block needs to be at least 48 bytes long - * in order to get here - */ - __m128i new_data; - - /** - * Main folding loop - * - n is adjusted to point to next 16 data block - * to read - * (16+16) = 2x16; represents 2 first data blocks - * processed above - * (- n) is the number of zero bytes padded to - * the message in order to align it to 16 bytes - * - the last 16 bytes is processed separately - */ - for (n = 16 + 16 - n; n < (data_len - 16); n += 16) { - new_data = _mm_loadu_si128((__m128i *)&data[n]); - new_data = _mm_shuffle_epi8(new_data, swap); - fold = crc32_folding_round(new_data, k, fold); - } - - /** - * The last folding round works always on 12 bytes - * (12 bytes of data and 4 zero bytes) - * Read from offset -4 is to avoid one - * shift right operation. - */ - new_data = _mm_loadu_si128((__m128i *)&data[n - 4]); - new_data = _mm_shuffle_epi8(new_data, swap); - new_data = _mm_slli_si128(new_data, 4); - fold = crc32_folding_round(new_data, k, fold); - } /* if (data_len > 32) */ - } - - /** - * ------------------------------------------------- - * Reduction 128 -> 32 - * Assumes: \a fold holds 128bit folded data - */ - - /** - * REDUCTION 128 -> 64 - */ - k = _mm_load_si128((__m128i *)(¶ms->k3)); - fold = crc32_reduce_128_to_64(fold, k); - - /** - * REDUCTION 64 -> 32 - */ - n = crc32_reduce_64_to_32(fold, k, - _mm_load_si128((__m128i *)(¶ms->p))); - -#ifdef __KERNEL__ - /** - * - restore FPU context - */ - kernel_fpu_end(); -#endif - - return n; -} - -#endif /* __CRC_H__ */ diff --git a/openair1/PHY/CODING/nrLDPC_decoder/nrLDPC_decoder_CL.c b/openair1/PHY/CODING/nrLDPC_decoder/nrLDPC_decoder_CL.c index 58e6b507afd979f1db9fa4e13d3c11b5ca58b811..c60286ab3a27b343d99a609f65715b398677ac36 100644 --- a/openair1/PHY/CODING/nrLDPC_decoder/nrLDPC_decoder_CL.c +++ b/openair1/PHY/CODING/nrLDPC_decoder/nrLDPC_decoder_CL.c @@ -25,32 +25,37 @@ * \version 1.0 * \note initial implem - translation of cuda version */ + + +#define MAX_ITERATION 2 +#define MC 1 + +#define MAX_OCLDEV 10 +#define MAX_OCLRUNTIME 5 + +typedef struct{ + char x; + char y; + short value; +} h_element; + +#ifdef NRLDPC_KERNEL_SOURCE +#include "nrLDPC_decoder_kernels_CL.c" +#else /* uses HW component id for log messages ( --log_config.hw_log_level <warning| info|debug|trace>) */ #include <stdio.h> #include <unistd.h> -#include <cuda_runtime.h> +#include <sys/stat.h> #include <CL/opencl.h> #include "PHY/CODING/nrLDPC_decoder/nrLDPC_types.h" #include "PHY/CODING/nrLDPC_decoder/nrLDPCdecoder_defs.h" #include "assertions.h" #include "common/utils/LOG/log.h" -#define MAX_ITERATION 2 -#define MC 1 - -#define MAX_OCLDEV 10 -#define MAX_OCLRUNTIME 5 - - #define CLSETKERNELARG(A,B,C,D) \ rt=clSetKernelArg(A,B,C,D) ;\ AssertFatal(rt == CL_SUCCESS, "Error %d setting kernel argument index %d\n" , (int)rt, B); -typedef struct{ - char x; - char y; - short value; -} h_element; #include "../nrLDPC_decoder_LYC/bgs/BG1_compact_in_C.h" typedef struct{ @@ -213,20 +218,31 @@ void get_CompilErr(cl_program program, int pltf) { } -size_t load_source(char **source_str) { - int MAX_SOURCE_SIZE=(500*132); +size_t load_source(char **source_str, char *filename) { FILE *fp; + struct stat st ; size_t source_size; - - fp = fopen("nrLDPC_decoder_kernels_CL.cl", "r"); - AssertFatal(fp,"failed to open cl source: %s\n",strerror(errno)); + char *src= NULL; - *source_str = (char*)malloc(MAX_SOURCE_SIZE); - source_size = fread( *source_str, 1, MAX_SOURCE_SIZE, fp); - fclose( fp ); - return source_size; + if (filename == NULL) { + src = "nrLDPC_decoder_kernels_CL.clc"; + } else { + src = filename; + } + fp = fopen(src, "r"); + AssertFatal(fp,"failed to open cl source %s: %s\n",src,strerror(errno)); + + fstat(fileno(fp), &st); + source_size = st.st_size; + *source_str = (char*)malloc(source_size); + source_size = fread( *source_str, 1, source_size, fp); + fclose( fp ); + LOG_I(HW,"Loaded kernel sources from %s %u bytes\n", (filename==NULL)?"embedded cl code":src,(unsigned int)source_size ); + return source_size; } + + /* from here: entry points in decoder shared lib */ int ldpc_autoinit(void) { // called by the library loader cl_platform_id platforms[10]; @@ -284,11 +300,11 @@ int ldpc_autoinit(void) { // called by the library loader ocl.runtime[i].dev_tmp = clCreateBuffer(ocl.runtime[i].context, CL_MEM_READ_ONLY|CL_MEM_HOST_WRITE_ONLY, 68*384, NULL, (cl_int *)&rt); AssertFatal(rt == CL_SUCCESS, "Error %d creating buffer dev_tmp for platform %i \n" , (int)rt, i); char *source_str; - size_t source_size=load_source(&source_str); + size_t source_size=load_source(&source_str,"nrLDPC_decoder_kernels_CL.clc"); cl_program program = clCreateProgramWithSource(ocl.runtime[i].context, 1, (const char **)&source_str, (const size_t *)&source_size, (cl_int *)&rt); AssertFatal(rt == CL_SUCCESS, "Error %d creating program for platform %i \n" , (int)rt, i); - rt = clBuildProgram(program, ocl.runtime[i].num_devices,ocl.runtime[i].devices, NULL, NULL, NULL); + rt = clBuildProgram(program, ocl.runtime[i].num_devices,ocl.runtime[i].devices, NULL /* compile options */, NULL, NULL); if (rt == CL_BUILD_PROGRAM_FAILURE) { get_CompilErr(program,i); } @@ -434,3 +450,4 @@ int32_t nrLDPC_decod(t_nrLDPC_dec_params* p_decParams, int8_t* p_llr, int8_t* p_ return MAX_ITERATION; } +#endif //NRLDPC_KERNEL_SOURCE diff --git a/openair1/PHY/CODING/nrLDPC_decoder/nrLDPC_decoder_kernels_CL.cl b/openair1/PHY/CODING/nrLDPC_decoder/nrLDPC_decoder_kernels_CL.c similarity index 98% rename from openair1/PHY/CODING/nrLDPC_decoder/nrLDPC_decoder_kernels_CL.cl rename to openair1/PHY/CODING/nrLDPC_decoder/nrLDPC_decoder_kernels_CL.c index d5e2fa569559c227ee2a558ae32b5202b50b470b..42b25e41c0eb745539d143c6c07aafa49a216560 100644 --- a/openair1/PHY/CODING/nrLDPC_decoder/nrLDPC_decoder_kernels_CL.cl +++ b/openair1/PHY/CODING/nrLDPC_decoder/nrLDPC_decoder_kernels_CL.c @@ -29,16 +29,7 @@ * \note initial implem - translation of cuda version * \warning */ -#define define MAX_ITERATION 2 -#define MC 1 -#define INT32_MAX 2147483647 - -typedef struct{ - char x; - char y; - short value; -} h_element; //__global char dev_dt [46*68*384]; //__local char *dev_t; @@ -46,7 +37,7 @@ typedef struct{ //__global unsigned char dev_tmp[68*384]; - +#define INT32_MAX 2147483647 //__constant h_element dev_h_compact1[46*19] = {}; // used in kernel 1 //__constant h_element dev_h_compact2[68*30] = {}; // used in kernel 2 @@ -299,4 +290,3 @@ __kernel void pack_decoded_bit(__global unsigned char * dev_llr, __global unsign } } } - diff --git a/openair1/PHY/CODING/nrLDPC_encoder/ldpc_encode_parity_check.c b/openair1/PHY/CODING/nrLDPC_encoder/ldpc_encode_parity_check.c index 22868466957c490d0749f1b26c9b7d0fbb93c13e..69d2ac4972663846ed6ac9bc45ab12d512c1b897 100644 --- a/openair1/PHY/CODING/nrLDPC_encoder/ldpc_encode_parity_check.c +++ b/openair1/PHY/CODING/nrLDPC_encoder/ldpc_encode_parity_check.c @@ -38,8 +38,6 @@ #include "common/utils/LOG/log.h" -//#define DEBUG_LDPC - #include "ldpc384_byte.c" #include "ldpc352_byte.c" #include "ldpc320_byte.c" diff --git a/openair1/PHY/CODING/nrLDPC_encoder/ldpc_encoder2.c b/openair1/PHY/CODING/nrLDPC_encoder/ldpc_encoder2.c index 5ab55514cecf73c33c6e0375eb3ffb04c789b65c..bef5b291dc61b5e02af028e34fc80571f2c2b091 100644 --- a/openair1/PHY/CODING/nrLDPC_encoder/ldpc_encoder2.c +++ b/openair1/PHY/CODING/nrLDPC_encoder/ldpc_encoder2.c @@ -39,8 +39,6 @@ #include "PHY/TOOLS/time_meas.h" #include "defs.h" -//#define DEBUG_LDPC - #include "ldpc384_byte.c" #include "ldpc352_byte.c" #include "ldpc320_byte.c" diff --git a/openair1/PHY/CODING/nrLDPC_encoder/ldpc_encoder_optim.c b/openair1/PHY/CODING/nrLDPC_encoder/ldpc_encoder_optim.c index 056ead3ab1d6f04a1df4be113155c7ee9db6ea24..07062f612311c95de6c845543f07132314b4385a 100644 --- a/openair1/PHY/CODING/nrLDPC_encoder/ldpc_encoder_optim.c +++ b/openair1/PHY/CODING/nrLDPC_encoder/ldpc_encoder_optim.c @@ -40,9 +40,6 @@ #include "openair1/PHY/CODING/nrLDPC_defs.h" #include "ldpc_encode_parity_check.c" #include "ldpc_generate_coefficient.c" -//#define DEBUG_LDPC - - @@ -50,7 +47,7 @@ int nrLDPC_encod(unsigned char **test_input,unsigned char **channel_input,int Zc { short nrows=0,ncols=0; - int i,rate=3; + int rate=3; int no_punctured_columns,removed_bit; int simd_size; @@ -96,7 +93,7 @@ int nrLDPC_encod(unsigned char **test_input,unsigned char **channel_input,int Zc memset(d,0,sizeof(unsigned char) * nrows * Zc); if(impp->tinput != NULL) start_meas(impp->tinput); - for (i=0; i<block_length; i++) { + for (int i=0; i<block_length; i++) { c[i] = (test_input[0][i/8]&(128>>(i&7)))>>(7-(i&7)); //printf("c(%d,%d)=%d\n",j,i,temp); } diff --git a/openair1/PHY/CODING/nrLDPC_encoder/ldpc_encoder_optim8seg.c b/openair1/PHY/CODING/nrLDPC_encoder/ldpc_encoder_optim8seg.c index 460ee80a21a95c96e99fd29a07e696bcf34ca575..6fa9c5ff53c9f5b245c01a9482a16c48fb1e0202 100644 --- a/openair1/PHY/CODING/nrLDPC_encoder/ldpc_encoder_optim8seg.c +++ b/openair1/PHY/CODING/nrLDPC_encoder/ldpc_encoder_optim8seg.c @@ -38,7 +38,6 @@ #include "common/utils/LOG/log.h" #include "PHY/TOOLS/time_meas.h" #include "openair1/PHY/CODING/nrLDPC_defs.h" -//#define DEBUG_LDPC #include "ldpc_encode_parity_check.c" #include "ldpc_generate_coefficient.c" diff --git a/openair1/PHY/CODING/nrLDPC_encoder/ldpc_encoder_optim8segmulti.c b/openair1/PHY/CODING/nrLDPC_encoder/ldpc_encoder_optim8segmulti.c index 57643a1bd835e1c2ee0d0503208b383c94e08208..15d4481eb605cccb2f4473ce11fee324a2a3aacc 100644 --- a/openair1/PHY/CODING/nrLDPC_encoder/ldpc_encoder_optim8segmulti.c +++ b/openair1/PHY/CODING/nrLDPC_encoder/ldpc_encoder_optim8segmulti.c @@ -38,7 +38,6 @@ #include "common/utils/LOG/log.h" #include "PHY/TOOLS/time_meas.h" #include "openair1/PHY/CODING/nrLDPC_defs.h" -//#define DEBUG_LDPC #include "ldpc_encode_parity_check.c" #include "ldpc_generate_coefficient.c" diff --git a/openair1/PHY/CODING/nrLDPC_load.c b/openair1/PHY/CODING/nrLDPC_load.c index 23e5032badcddd69ad2a1d51288f0f57454b7a98..3049070cd653f9b99f458babc3485f227bd679e2 100644 --- a/openair1/PHY/CODING/nrLDPC_load.c +++ b/openair1/PHY/CODING/nrLDPC_load.c @@ -46,14 +46,14 @@ static loader_shlibfunc_t shlib_fdesc[3]; /* arguments used when called from phy simulators exec's which do not use the config module */ /* arg is used to initialize the config module so that the loader works as expected */ -char *arg[64]={"ldpctest","-O","cmdlineonly::dbgl0",NULL,NULL}; +char *arg[64]={"ldpctest",NULL}; int load_nrLDPClib(char *version) { char *ptr = (char*)config_get_if(); char libname[64]="ldpc"; if ( ptr==NULL ) {// phy simulators, config module possibly not loaded - load_configmodule(0,(char **)NULL,CONFIG_ENABLECMDLINEONLY) ; + load_configmodule(1,arg,CONFIG_ENABLECMDLINEONLY) ; logInit(); } shlib_fdesc[0].fname = "nrLDPC_decod"; diff --git a/openair1/PHY/CODING/nr_rate_matching.c b/openair1/PHY/CODING/nr_rate_matching.c index ae49f9a4a7cb82d74ac320ab999458a970056767..29cba0a55729b2b7347a4a8b8324afeeb9a10f43 100644 --- a/openair1/PHY/CODING/nr_rate_matching.c +++ b/openair1/PHY/CODING/nr_rate_matching.c @@ -405,7 +405,7 @@ int nr_rate_matching_ldpc(uint8_t Ilbrm, ind = (index_k0[BG-1][rvidx]*Ncb/N)*Z; #ifdef RM_DEBUG - printf("nr_rate_matching_ldpc: E %d, F %d, Foffset %d, k0 %d, Ncb %d, rvidx %d\n", E, F, Foffset,ind, Ncb, rvidx); + printf("nr_rate_matching_ldpc: E %d, F %d, Foffset %d, k0 %d, Ncb %d, rvidx %d, Ilbrm %d\n", E, F, Foffset,ind, Ncb, rvidx, Ilbrm); #endif if (Foffset > E) { @@ -502,7 +502,7 @@ int nr_rate_matching_ldpc_rx(uint8_t Ilbrm, } #ifdef RM_DEBUG - printf("nr_rate_matching_ldpc_rx: Clear %d, E %d, k0 %d, Ncb %d, rvidx %d\n", clear, E, ind, Ncb, rvidx); + printf("nr_rate_matching_ldpc_rx: Clear %d, E %d, k0 %d, Ncb %d, rvidx %d, Ilbrm %d\n", clear, E, ind, Ncb, rvidx, Ilbrm); #endif if (clear==1) memset(w,0,Ncb*sizeof(int16_t)); diff --git a/openair1/PHY/INIT/lte_init.c b/openair1/PHY/INIT/lte_init.c index 1daeb72187b81454ecc2ed359b234b86ec4dec69..308a059d51417cc760318d98da2419e25ffb99b8 100644 --- a/openair1/PHY/INIT/lte_init.c +++ b/openair1/PHY/INIT/lte_init.c @@ -106,7 +106,7 @@ void phy_config_request(PHY_Config_t *phy_config) { int Ncp = cfg->subframe_config.dl_cyclic_prefix_type.value; int p_eNB = cfg->rf_config.tx_antenna_ports.value; uint32_t dl_CarrierFreq = cfg->nfapi_config.earfcn.value; - LOG_I(PHY,"Configuring MIB for instance %d, CCid %d : (band %d,N_RB_DL %d, N_RB_UL %d, Nid_cell %d,eNB_tx_antenna_ports %d,Ncp %d,DL freq %u,phich_config.resource %d, phich_config.duration %d)\n", + LOG_A(PHY,"Configuring MIB for instance %d, CCid %d : (band %d,N_RB_DL %d, N_RB_UL %d, Nid_cell %d,eNB_tx_antenna_ports %d,Ncp %d,DL freq %u,phich_config.resource %d, phich_config.duration %d)\n", Mod_id, CC_id, eutra_band, dl_Bandwidth, ul_Bandwidth, Nid_cell, p_eNB,Ncp,dl_CarrierFreq, cfg->phich_config.phich_resource.value, cfg->phich_config.phich_duration.value); diff --git a/openair1/PHY/INIT/lte_init_ue.c b/openair1/PHY/INIT/lte_init_ue.c index b75673581687731b5d51bd9eac0c9fd0d4802fde..c3f09fa78c3c6925af5891992e8f52aff2090ad7 100644 --- a/openair1/PHY/INIT/lte_init_ue.c +++ b/openair1/PHY/INIT/lte_init_ue.c @@ -548,7 +548,7 @@ void phy_config_dedicated_ue(module_id_t Mod_id,int CC_id,uint8_t eNB_id, phy_vars_ue->decode_MIB = 0; } - if(NFAPI_MODE!=NFAPI_UE_STUB_PNF) { + if(NFAPI_MODE!=NFAPI_UE_STUB_PNF && NFAPI_MODE!=NFAPI_MODE_STANDALONE_PNF) { //phy_vars_ue->pdcch_vars[1][eNB_id]->crnti = phy_vars_ue->pdcch_vars[0][eNB_id]->crnti; if(phy_vars_ue->pdcch_vars[0][eNB_id]->crnti == 0x1234) phy_vars_ue->pdcch_vars[0][eNB_id]->crnti = phy_vars_ue->pdcch_vars[1][eNB_id]->crnti; diff --git a/openair1/PHY/INIT/nr_init.c b/openair1/PHY/INIT/nr_init.c index cd4848ea8ce22cd530b11f70ca57eec9a9ad441a..3bf450703cddc6384adcb2bc91035735f7f7f50d 100644 --- a/openair1/PHY/INIT/nr_init.c +++ b/openair1/PHY/INIT/nr_init.c @@ -195,6 +195,26 @@ int phy_init_nr_gNB(PHY_VARS_gNB *gNB, nr_init_csi_rs(gNB, cfg->cell_config.phy_cell_id.value); + for (int id=0; id<NUMBER_OF_NR_SRS_MAX; id++) { + gNB->nr_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(fp->ofdm_symbol_size*MAX_NUM_NR_SRS_SYMBOLS*sizeof(int32_t)); + gNB->nr_srs_info[id]->noise_power = (uint32_t*)malloc16_clear(sizeof(uint32_t)); + gNB->nr_srs_info[id]->srs_received_signal = (int32_t **)malloc16(Prx*sizeof(int32_t*)); + gNB->nr_srs_info[id]->srs_ls_estimated_channel = (int32_t **)malloc16(Prx*sizeof(int32_t*)); + gNB->nr_srs_info[id]->srs_estimated_channel_freq = (int32_t **)malloc16(Prx*sizeof(int32_t*)); + gNB->nr_srs_info[id]->srs_estimated_channel_time = (int32_t **)malloc16(Prx*sizeof(int32_t*)); + gNB->nr_srs_info[id]->srs_estimated_channel_time_shifted = (int32_t **)malloc16(Prx*sizeof(int32_t*)); + for (i=0;i<Prx;i++){ + gNB->nr_srs_info[id]->srs_received_signal[i] = (int32_t*)malloc16_clear(fp->ofdm_symbol_size*MAX_NUM_NR_SRS_SYMBOLS*sizeof(int32_t)); + gNB->nr_srs_info[id]->srs_ls_estimated_channel[i] = (int32_t*)malloc16_clear(fp->ofdm_symbol_size*MAX_NUM_NR_SRS_SYMBOLS*sizeof(int32_t)); + gNB->nr_srs_info[id]->srs_estimated_channel_freq[i] = (int32_t*)malloc16_clear(fp->ofdm_symbol_size*MAX_NUM_NR_SRS_SYMBOLS*sizeof(int32_t)); + gNB->nr_srs_info[id]->srs_estimated_channel_time[i] = (int32_t*)malloc16_clear(fp->ofdm_symbol_size*MAX_NUM_NR_SRS_SYMBOLS*sizeof(int32_t)); + gNB->nr_srs_info[id]->srs_estimated_channel_time_shifted[i] = (int32_t*)malloc16_clear(fp->ofdm_symbol_size*MAX_NUM_NR_SRS_SYMBOLS*sizeof(int32_t)); + } + } + + generate_ul_reference_signal_sequences(SHRT_MAX); + /* Generate low PAPR type 1 sequences for PUSCH DMRS, these are used if transform precoding is enabled. */ generate_lowpapr_typ1_refsig_sequences(SHRT_MAX); @@ -487,7 +507,7 @@ void nr_phy_config_request(NR_PHY_Config_t *phy_config) { LOG_I(PHY, "DL frequency %lu Hz, UL frequency %lu Hz: band %d, uldl offset %d Hz\n", fp->dl_CarrierFreq, fp->ul_CarrierFreq, fp->nr_band, dlul_offset); fp->threequarter_fs = openair0_cfg[0].threequarter_fs; - LOG_I(PHY,"Configuring MIB for instance %d, : (Nid_cell %d,DL freq %llu, UL freq %llu)\n", + LOG_A(PHY,"Configuring MIB for instance %d, : (Nid_cell %d,DL freq %llu, UL freq %llu)\n", Mod_id, gNB_config->cell_config.phy_cell_id.value, (unsigned long long)fp->dl_CarrierFreq, @@ -546,6 +566,12 @@ void init_nr_transport(PHY_VARS_gNB *gNB) { AssertFatal(gNB->pucch[i]!=NULL,"Can't initialize pucch %d \n", i); } + for (int i=0; i<NUMBER_OF_NR_SRS_MAX; i++) { + LOG_I(PHY,"Allocating Transport Channel Buffers for SRS %d/%d\n",i,NUMBER_OF_NR_SRS_MAX); + gNB->srs[i] = new_gNB_srs(); + AssertFatal(gNB->srs[i]!=NULL,"Can't initialize srs %d \n", i); + } + for (int i=0; i<gNB->number_of_nr_ulsch_max; i++) { LOG_I(PHY,"Allocating Transport Channel Buffer for ULSCH %d/%d\n",i,gNB->number_of_nr_ulsch_max); diff --git a/openair1/PHY/INIT/nr_init_ue.c b/openair1/PHY/INIT/nr_init_ue.c index b60e77e814b41023cfec4f64cda18286058d4de5..b571afe41631da5a307b3e31cce8fd5067cef195 100644 --- a/openair1/PHY/INIT/nr_init_ue.c +++ b/openair1/PHY/INIT/nr_init_ue.c @@ -20,27 +20,19 @@ */ #include "phy_init.h" -#include "SCHED_UE/sched_UE.h" #include "PHY/phy_extern_nr_ue.h" -//#include "SIMULATION/TOOLS/sim.h" -/*#include "RadioResourceConfigCommonSIB.h" -#include "RadioResourceConfigDedicated.h" -#include "TDD-Config.h" -#include "MBSFN-SubframeConfigList.h"*/ #include "openair1/PHY/defs_RU.h" #include "openair1/PHY/impl_defs_nr.h" #include "common/utils/LOG/vcd_signal_dumper.h" #include "assertions.h" -#include <math.h> +#include "PHY/MODULATION/nr_modulation.h" #include "PHY/NR_UE_TRANSPORT/nr_transport_ue.h" #include "PHY/NR_UE_TRANSPORT/nr_transport_proto_ue.h" -//#include "PHY/LTE_REFSIG/lte_refsig.h" -#include "PHY/CODING/nrPolar_tools/nr_polar_pbch_defs.h" -#include "PHY/INIT/phy_init.h" #include "PHY/NR_REFSIG/pss_nr.h" #include "PHY/NR_REFSIG/ul_ref_seq_nr.h" #include "PHY/NR_REFSIG/refsig_defs_ue.h" #include "PHY/NR_REFSIG/nr_refsig.h" +#include "PHY/MODULATION/nr_modulation.h" #if 0 void phy_config_harq_ue(module_id_t Mod_id, @@ -136,6 +128,8 @@ int init_nr_ue_signal(PHY_VARS_NR_UE *ue, NR_UE_COMMON *const common_vars = &ue->common_vars; NR_UE_PBCH **const pbch_vars = ue->pbch_vars; NR_UE_PRACH **const prach_vars = ue->prach_vars; + NR_UE_SRS **const srs_vars = ue->srs_vars; + int i,j,k,l,slot,symb,q; int gNB_id; int th_id; @@ -318,6 +312,24 @@ int init_nr_ue_signal(PHY_VARS_NR_UE *ue, prach_vars[gNB_id] = (NR_UE_PRACH *)malloc16_clear(sizeof(NR_UE_PRACH)); pbch_vars[gNB_id] = (NR_UE_PBCH *)malloc16_clear(sizeof(NR_UE_PBCH)); + srs_vars[gNB_id] = (NR_UE_SRS *)malloc16_clear(sizeof(NR_UE_SRS)); + + srs_vars[gNB_id]->active = false; + ue->nr_srs_info = (nr_srs_info_t *)malloc16_clear(sizeof(nr_srs_info_t)); + ue->nr_srs_info->srs_generated_signal = (int32_t *) malloc16_clear( (2*(fp->samples_per_frame)+2048)*sizeof(int32_t) ); + ue->nr_srs_info->noise_power = (uint32_t*)malloc16_clear(sizeof(uint32_t)); + ue->nr_srs_info->srs_received_signal = (int32_t **)malloc16( fp->nb_antennas_rx*sizeof(int32_t *) ); + ue->nr_srs_info->srs_ls_estimated_channel = (int32_t **)malloc16( fp->nb_antennas_rx*sizeof(int32_t *) ); + ue->nr_srs_info->srs_estimated_channel_freq = (int32_t **)malloc16( fp->nb_antennas_rx*sizeof(int32_t *) ); + ue->nr_srs_info->srs_estimated_channel_time = (int32_t **)malloc16( fp->nb_antennas_rx*sizeof(int32_t *) ); + ue->nr_srs_info->srs_estimated_channel_time_shifted = (int32_t **)malloc16( fp->nb_antennas_rx*sizeof(int32_t *) ); + for (i=0; i<fp->nb_antennas_rx; i++) { + ue->nr_srs_info->srs_received_signal[i] = (int32_t *) malloc16_clear(fp->ofdm_symbol_size*MAX_NUM_NR_SRS_SYMBOLS*sizeof(int32_t)); + ue->nr_srs_info->srs_ls_estimated_channel[i] = (int32_t *) malloc16_clear(fp->ofdm_symbol_size*MAX_NUM_NR_SRS_SYMBOLS*sizeof(int32_t)); + ue->nr_srs_info->srs_estimated_channel_freq[i] = (int32_t *) malloc16_clear(fp->ofdm_symbol_size*MAX_NUM_NR_SRS_SYMBOLS*sizeof(int32_t)); + ue->nr_srs_info->srs_estimated_channel_time[i] = (int32_t *) malloc16_clear(fp->ofdm_symbol_size*MAX_NUM_NR_SRS_SYMBOLS*sizeof(int32_t)); + ue->nr_srs_info->srs_estimated_channel_time_shifted[i] = (int32_t *) malloc16_clear(fp->ofdm_symbol_size*MAX_NUM_NR_SRS_SYMBOLS*sizeof(int32_t)); + } if (abstraction_flag == 0) { for (th_id=0; th_id<RX_NB_TH_MAX; th_id++) { @@ -458,7 +470,7 @@ int init_nr_ue_signal(PHY_VARS_NR_UE *ue, ue->decode_SIB = 1; init_nr_prach_tables(839); - + init_symbol_rotation(fp); return 0; } @@ -530,6 +542,7 @@ void init_N_TA_offset(PHY_VARS_NR_UE *ue){ void phy_init_nr_top(PHY_VARS_NR_UE *ue) { NR_DL_FRAME_PARMS *frame_parms = &ue->frame_parms; crcTableInit(); + init_scrambling_luts(); load_dftslib(); init_context_synchro_nr(frame_parms); generate_ul_reference_signal_sequences(SHRT_MAX); @@ -541,6 +554,5 @@ void phy_init_nr_top(PHY_VARS_NR_UE *ue) { //generate_16qam_table(); //generate_RIV_tables(); //init_unscrambling_lut(); - //init_scrambling_lut(); //set_taus_seed(1328); } diff --git a/openair1/PHY/INIT/nr_parms.c b/openair1/PHY/INIT/nr_parms.c index 42d4a30e3ba3943bec2fbd79aabe8bd5196d3050..35bc28d9c111f67aada20fa34a9984b65b04d2af 100644 --- a/openair1/PHY/INIT/nr_parms.c +++ b/openair1/PHY/INIT/nr_parms.c @@ -209,7 +209,6 @@ uint32_t get_samples_per_slot(int slot, NR_DL_FRAME_PARMS* fp) return samp_count; } - uint32_t get_slot_from_timestamp(openair0_timestamp timestamp_rx, NR_DL_FRAME_PARMS* fp) { uint32_t slot_idx = 0; @@ -251,11 +250,9 @@ int nr_init_frame_parms(nfapi_nr_config_request_scf_t* cfg, int Ncp = NFAPI_CP_NORMAL; int mu = cfg->ssb_config.scs_common.value; -#if DISABLE_LOG_X - printf("Initializing frame parms for mu %d, N_RB %d, Ncp %d\n",mu, fp->N_RB_DL, Ncp); -#else + LOG_I(PHY,"Initializing frame parms for mu %d, N_RB %d, Ncp %d\n",mu, fp->N_RB_DL, Ncp); -#endif + if (Ncp == NFAPI_CP_EXTENDED) AssertFatal(mu == NR_MU_2,"Invalid cyclic prefix %d for numerology index %d\n", Ncp, mu); @@ -344,11 +341,8 @@ int nr_init_frame_parms_ue(NR_DL_FRAME_PARMS *fp, AssertFatal(fp->ul_CarrierFreq == (fp->dl_CarrierFreq + uplink_frequency_offset), "Disagreement in uplink frequency for band %d: ul_CarrierFreq = %lu Hz vs expected %lu Hz\n", fp->nr_band, fp->ul_CarrierFreq, fp->dl_CarrierFreq + uplink_frequency_offset); -#if DISABLE_LOG_X - printf("Initializing UE frame parms for mu %d, N_RB %d, Ncp %d\n",fp->numerology_index, fp->N_RB_DL, Ncp); -#else LOG_I(PHY,"Initializing frame parms for mu %d, N_RB %d, Ncp %d\n",fp->numerology_index, fp->N_RB_DL, Ncp); -#endif + if (Ncp == NFAPI_CP_EXTENDED) AssertFatal(fp->numerology_index == NR_MU_2,"Invalid cyclic prefix %d for numerology index %d\n", Ncp, fp->numerology_index); diff --git a/openair1/PHY/LTE_REFSIG/lte_refsig.h b/openair1/PHY/LTE_REFSIG/lte_refsig.h index 84a2676082fe151c208e31709cd4d0078b2fb012..9d3bae503b2348c110de5bf92acedac939313429 100644 --- a/openair1/PHY/LTE_REFSIG/lte_refsig.h +++ b/openair1/PHY/LTE_REFSIG/lte_refsig.h @@ -36,8 +36,7 @@ \param reset resets the generator \return 32 bits of the gold sequence */ -uint32_t lte_gold_generic(uint32_t *x1, uint32_t *x2, uint8_t reset); - +#include <openair1/PHY/LTE_TRANSPORT/transport_proto.h> /*!\brief This function generates the LTE Gold sequence (36-211, Sec 7.2), specifically for DL reference signals. @param frame_parms LTE DL Frame parameters diff --git a/openair1/PHY/LTE_TRANSPORT/dlsch_coding.c b/openair1/PHY/LTE_TRANSPORT/dlsch_coding.c index b5bcb0848d4d489f6ba862f21f81ddc74aba7fec..3ccbd8ca35ad7218ffccebfee25c00fd35816261 100644 --- a/openair1/PHY/LTE_TRANSPORT/dlsch_coding.c +++ b/openair1/PHY/LTE_TRANSPORT/dlsch_coding.c @@ -42,7 +42,6 @@ #include "common/utils/LOG/log.h" #include "targets/RT/USER/lte-softmodem.h" #include <syscall.h> -#include "targets/RT/USER/rt_wrapper.h" #include <common/utils/threadPool/thread-pool.h> //#define DEBUG_DLSCH_CODING diff --git a/openair1/PHY/LTE_TRANSPORT/dlsch_modulation.c b/openair1/PHY/LTE_TRANSPORT/dlsch_modulation.c index aba4a464f2bcbbfbef7b008b4801216891674ea0..c6b312cc61a1ffd34e38e6573b9aeae8f16a6825 100644 --- a/openair1/PHY/LTE_TRANSPORT/dlsch_modulation.c +++ b/openair1/PHY/LTE_TRANSPORT/dlsch_modulation.c @@ -2921,6 +2921,9 @@ int allocate_REs_in_RB_MCH_khz_1dot25(int32_t **txdataF, uint8_t skip_dc, LTE_DL_FRAME_PARMS *frame_parms) { + if (!qam_table_s) + abort(); + uint32_t tti_offset; uint8_t re,offset; uint8_t qam64_table_offset_re = 0; diff --git a/openair1/PHY/LTE_TRANSPORT/lte_gold_generic.c b/openair1/PHY/LTE_TRANSPORT/lte_gold_generic.c deleted file mode 100644 index a23f8db4f28f0a3c861e65281904287f7c2f8634..0000000000000000000000000000000000000000 --- a/openair1/PHY/LTE_TRANSPORT/lte_gold_generic.c +++ /dev/null @@ -1,75 +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" - -/** - \brief Gold Sequence Generation defined in 3x.211 - \param x1 x1 shift register - \param x2 x2 shift register / cinit if reset is set - \param reset Reset flag / reinitialize the generator - \return c 32 bits of gold output -*/ -extern inline uint32_t lte_gold_generic(uint32_t *x1, uint32_t *x2, uint8_t reset) -{ - int32_t n; - - // 3GPP 3x.211 - // Nc = 1600 - // c(n) = [x1(n+Nc) + x2(n+Nc)]mod2 - // x1(n+31) = [x1(n+3) + x1(n)]mod2 - // x2(n+31) = [x2(n+3) + x2(n+2) + x2(n+1) + x2(n)]mod2 - if (reset) - { - // Init value for x1: x1(0) = 1, x1(n) = 0, n=1,2,...,30 - // x1(31) = [x1(3) + x1(0)]mod2 = 1 - *x1 = 1 + (1U<<31); - // Init value for x2: cinit = sum_{i=0}^30 x2*2^i - // x2(31) = [x2(3) + x2(2) + x2(1) + x2(0)]mod2 - // = (*x2>>3) ^ (*x2>>2) + (*x2>>1) + *x2 - *x2 = *x2 ^ ((*x2 ^ (*x2>>1) ^ (*x2>>2) ^ (*x2>>3))<<31); - - // x1 and x2 contain bits n = 0,1,...,31 - - // Nc = 1600 bits are skipped at the beginning - // i.e., 1600 / 32 = 50 32bit words - - for (n = 1; n < 50; n++) - { - // Compute x1(0),...,x1(27) - *x1 = (*x1>>1) ^ (*x1>>4); - // Compute x1(28),..,x1(31) and xor - *x1 = *x1 ^ (*x1<<31) ^ (*x1<<28); - // Compute x2(0),...,x2(27) - *x2 = (*x2>>1) ^ (*x2>>2) ^ (*x2>>3) ^ (*x2>>4); - // Compute x2(28),..,x2(31) and xor - *x2 = *x2 ^ (*x2<<31) ^ (*x2<<30) ^ (*x2<<29) ^ (*x2<<28); - } - } - - *x1 = (*x1>>1) ^ (*x1>>4); - *x1 = *x1 ^ (*x1<<31) ^ (*x1<<28); - *x2 = (*x2>>1) ^ (*x2>>2) ^ (*x2>>3) ^ (*x2>>4); - *x2 = *x2 ^ (*x2<<31) ^ (*x2<<30) ^ (*x2<<29) ^ (*x2<<28); - - // c(n) = [x1(n+Nc) + x2(n+Nc)]mod2 - return(*x1^*x2); -} diff --git a/openair1/PHY/LTE_TRANSPORT/lte_mcs.c b/openair1/PHY/LTE_TRANSPORT/lte_mcs.c index 6144b978bf432bf20ddb5d2c2be98ead053c1d90..38914506eef4a9a4db776c72cf6fbd16f4bcee92 100644 --- a/openair1/PHY/LTE_TRANSPORT/lte_mcs.c +++ b/openair1/PHY/LTE_TRANSPORT/lte_mcs.c @@ -147,10 +147,10 @@ uint32_t get_TBS_UL(uint8_t mcs, uint16_t nb_rb) { } } -int adjust_G2(LTE_DL_FRAME_PARMS *frame_parms, uint32_t *rb_alloc, uint8_t mod_order, uint8_t subframe, uint8_t symbol) { +int adjust_G2(int Ncp, int frame_type, int N_RB_DL, uint32_t *rb_alloc, uint8_t mod_order, uint8_t subframe, uint8_t symbol) { int rb,re_pbch_sss=0; int rb_alloc_ind,nsymb; - nsymb = (frame_parms->Ncp==NORMAL) ? 14 : 12; + nsymb = (Ncp==NORMAL) ? 14 : 12; // printf("adjust_G2 : symbol %d, subframe %d\n",symbol,subframe); if ((subframe!=0) && (subframe!=5) && (subframe!=6)) // if not PBCH/SSS or SSS @@ -158,12 +158,12 @@ int adjust_G2(LTE_DL_FRAME_PARMS *frame_parms, uint32_t *rb_alloc, uint8_t mod_o //first half of slot and TDD (no adjustments in first slot except for subframe 6 - PSS) if ((symbol<(nsymb>>1))&& - (frame_parms->frame_type == TDD)&& + (frame_type == TDD)&& (subframe!=6)) return(0); // after PBCH - if (frame_parms->frame_type==TDD) { //TDD + if (frame_type==TDD) { //TDD if ((symbol>((nsymb>>1)+3)) && (symbol!=(nsymb-1))) ///SSS return(0); @@ -185,9 +185,9 @@ int adjust_G2(LTE_DL_FRAME_PARMS *frame_parms, uint32_t *rb_alloc, uint8_t mod_o return(0); } - if ((frame_parms->N_RB_DL&1) == 1) { // ODD N_RB_DL - for (rb=((frame_parms->N_RB_DL>>1)-3); - rb<=((frame_parms->N_RB_DL>>1)+3); + if ((N_RB_DL&1) == 1) { // ODD N_RB_DL + for (rb=((N_RB_DL>>1)-3); + rb<=((N_RB_DL>>1)+3); rb++) { if (rb < 32) rb_alloc_ind = (rb_alloc[0]>>rb) & 1; @@ -201,16 +201,16 @@ int adjust_G2(LTE_DL_FRAME_PARMS *frame_parms, uint32_t *rb_alloc, uint8_t mod_o rb_alloc_ind = 0; if (rb_alloc_ind==1) { - if ((rb==(frame_parms->N_RB_DL>>1)-3) || - (rb==((frame_parms->N_RB_DL>>1)+3))) { + if ((rb==(N_RB_DL>>1)-3) || + (rb==((N_RB_DL>>1)+3))) { re_pbch_sss += 6; } else re_pbch_sss += 12; } } } else { - for (rb=((frame_parms->N_RB_DL>>1)-3); - rb<((frame_parms->N_RB_DL>>1)+3); + for (rb=((N_RB_DL>>1)-3); + rb<((N_RB_DL>>1)+3); rb++) { if (rb < 32) rb_alloc_ind = (rb_alloc[0]>>rb) & 1; diff --git a/openair1/PHY/LTE_TRANSPORT/pcfich.c b/openair1/PHY/LTE_TRANSPORT/pcfich.c index 3646732ce3b74b2c167e39ae852fd9f88ada3a42..0ba63019a1f7ba40bb27428c73f3423990641355 100644 --- a/openair1/PHY/LTE_TRANSPORT/pcfich.c +++ b/openair1/PHY/LTE_TRANSPORT/pcfich.c @@ -44,7 +44,7 @@ void pcfich_scrambling(LTE_DL_FRAME_PARMS *frame_parms, { uint32_t i; uint8_t reset; - uint32_t x1, x2, s=0; + uint32_t x1=0, x2, s=0; reset = 1; // x1 is set in lte_gold_generic diff --git a/openair1/PHY/LTE_TRANSPORT/pucch.c b/openair1/PHY/LTE_TRANSPORT/pucch.c index 32700664480e2d9a37a60b2ead13dfcbacc0221a..998edf235fb5323f702a2c1aac3bcdf6d4073f4b 100644 --- a/openair1/PHY/LTE_TRANSPORT/pucch.c +++ b/openair1/PHY/LTE_TRANSPORT/pucch.c @@ -895,7 +895,7 @@ uint32_t rx_pucch(PHY_VARS_eNB *eNB, int frame, uint8_t subframe, uint8_t pucch1_thres, - uint8_t br_flag + int br_flag ) //----------------------------------------------------------------------------- { diff --git a/openair1/PHY/LTE_TRANSPORT/transport_common_proto.h b/openair1/PHY/LTE_TRANSPORT/transport_common_proto.h index 622f37b3bcba54d22fc46e719e78c33e25603eb3..af8e63c3edc02823e0b9a7ad45f674d579de7dc2 100644 --- a/openair1/PHY/LTE_TRANSPORT/transport_common_proto.h +++ b/openair1/PHY/LTE_TRANSPORT/transport_common_proto.h @@ -101,7 +101,7 @@ int get_G(LTE_DL_FRAME_PARMS *frame_parms,uint16_t nb_rb,uint32_t *rb_alloc,uint int get_G_khz_1dot25(LTE_DL_FRAME_PARMS *frame_parms,uint16_t nb_rb,uint32_t *rb_alloc,uint8_t mod_order,uint8_t Nl,uint8_t num_pdcch_symbols,int frame,uint8_t subframe, uint8_t beamforming_mode); int adjust_G(LTE_DL_FRAME_PARMS *frame_parms,uint32_t *rb_alloc,uint8_t mod_order,uint8_t subframe); -int adjust_G2(LTE_DL_FRAME_PARMS *frame_parms,uint32_t *rb_alloc,uint8_t mod_order,uint8_t subframe,uint8_t symbol); +int adjust_G2(int Ncp, int frame_type, int N_RB_DL, uint32_t *rb_alloc,uint8_t mod_order,uint8_t subframe,uint8_t symbol); #ifndef modOrder diff --git a/openair1/PHY/LTE_TRANSPORT/transport_proto.h b/openair1/PHY/LTE_TRANSPORT/transport_proto.h index 19af50056c558160a86dd3888f08747ccbbe1afd..1fbd1266d762d42b850f3da8e912bc10f4557141 100644 --- a/openair1/PHY/LTE_TRANSPORT/transport_proto.h +++ b/openair1/PHY/LTE_TRANSPORT/transport_proto.h @@ -700,7 +700,51 @@ int find_ulsch(uint16_t rnti, PHY_VARS_eNB *eNB,find_type_t type); int find_uci(uint16_t rnti, int frame, int subframe, PHY_VARS_eNB *eNB,find_type_t type); -uint32_t lte_gold_generic(uint32_t *x1, uint32_t *x2, uint8_t reset); +static inline uint32_t lte_gold_generic(uint32_t *x1, uint32_t *x2, uint8_t reset) +{ + int32_t n; + + // 3GPP 3x.211 + // Nc = 1600 + // c(n) = [x1(n+Nc) + x2(n+Nc)]mod2 + // x1(n+31) = [x1(n+3) + x1(n)]mod2 + // x2(n+31) = [x2(n+3) + x2(n+2) + x2(n+1) + x2(n)]mod2 + if (reset) + { + // Init value for x1: x1(0) = 1, x1(n) = 0, n=1,2,...,30 + // x1(31) = [x1(3) + x1(0)]mod2 = 1 + *x1 = 1 + (1U<<31); + // Init value for x2: cinit = sum_{i=0}^30 x2*2^i + // x2(31) = [x2(3) + x2(2) + x2(1) + x2(0)]mod2 + // = (*x2>>3) ^ (*x2>>2) + (*x2>>1) + *x2 + *x2 = *x2 ^ ((*x2 ^ (*x2>>1) ^ (*x2>>2) ^ (*x2>>3))<<31); + + // x1 and x2 contain bits n = 0,1,...,31 + + // Nc = 1600 bits are skipped at the beginning + // i.e., 1600 / 32 = 50 32bit words + + for (n = 1; n < 50; n++) + { + // Compute x1(0),...,x1(27) + *x1 = (*x1>>1) ^ (*x1>>4); + // Compute x1(28),..,x1(31) and xor + *x1 = *x1 ^ (*x1<<31) ^ (*x1<<28); + // Compute x2(0),...,x2(27) + *x2 = (*x2>>1) ^ (*x2>>2) ^ (*x2>>3) ^ (*x2>>4); + // Compute x2(28),..,x2(31) and xor + *x2 = *x2 ^ (*x2<<31) ^ (*x2<<30) ^ (*x2<<29) ^ (*x2<<28); + } + } + + *x1 = (*x1>>1) ^ (*x1>>4); + *x1 = *x1 ^ (*x1<<31) ^ (*x1<<28); + *x2 = (*x2>>1) ^ (*x2>>2) ^ (*x2>>3) ^ (*x2>>4); + *x2 = *x2 ^ (*x2<<31) ^ (*x2<<30) ^ (*x2<<29) ^ (*x2<<28); + + // c(n) = [x1(n+Nc) + x2(n+Nc)]mod2 + return(*x1^*x2); +} /**@}*/ diff --git a/openair1/PHY/LTE_UE_TRANSPORT/dci_tools_ue.c b/openair1/PHY/LTE_UE_TRANSPORT/dci_tools_ue.c index 4f65edd6d5fe5b87fac4866b08ce23ca4e8ea879..efde277203d2a93a9c953fd49945105c82090e4f 100644 --- a/openair1/PHY/LTE_UE_TRANSPORT/dci_tools_ue.c +++ b/openair1/PHY/LTE_UE_TRANSPORT/dci_tools_ue.c @@ -1293,7 +1293,7 @@ void compute_llr_offset(LTE_DL_FRAME_PARMS *frame_parms, } granted_re = nb_rb_alloc * (12-crs_re); - pbch_pss_sss_re = adjust_G2(frame_parms,dlsch0_harq->rb_alloc_even,dlsch0_harq->Qm,subframe,symbol); + pbch_pss_sss_re = adjust_G2(frame_parms->Ncp,frame_parms->frame_type, frame_parms->N_RB_DL,dlsch0_harq->rb_alloc_even,dlsch0_harq->Qm,subframe,symbol); pbch_pss_sss_re = (double)pbch_pss_sss_re * ((double)(12-crs_re)/12); data_re = granted_re - pbch_pss_sss_re; llr_offset = data_re * dlsch0_harq->Qm * 2; diff --git a/openair1/PHY/LTE_UE_TRANSPORT/dlsch_demodulation.c b/openair1/PHY/LTE_UE_TRANSPORT/dlsch_demodulation.c index 91de5386ae45cf5fa012d553c3cbd319bd559ce9..a7054a44d2474df6d6d36297853fc8f0ffb3a9ea 100644 --- a/openair1/PHY/LTE_UE_TRANSPORT/dlsch_demodulation.c +++ b/openair1/PHY/LTE_UE_TRANSPORT/dlsch_demodulation.c @@ -370,7 +370,7 @@ int rx_pdsch(PHY_VARS_UE *ue, #if UE_TIMING_TRACE stop_meas(&ue->generic_stat_bis[ue->current_thread_id[subframe]][slot]); - LOG_I(PHY, "[AbsSFN %d.%d] Slot%d Symbol %d Flag %d type %d: Pilot/Data extraction %5.2f \n",frame,subframe,slot,symbol, + LOG_D(PHY, "[AbsSFN %d.%d] Slot%d Symbol %d Flag %d type %d: Pilot/Data extraction %5.2f \n",frame,subframe,slot,symbol, ue->high_speed_flag,type,ue->generic_stat_bis[ue->current_thread_id[subframe]][slot].p_time/(cpuf*1000.0)); #endif #if UE_TIMING_TRACE @@ -398,7 +398,7 @@ int rx_pdsch(PHY_VARS_UE *ue, #if UE_TIMING_TRACE stop_meas(&ue->generic_stat_bis[ue->current_thread_id[subframe]][slot]); - LOG_I(PHY, "[AbsSFN %d.%d] Slot%d Symbol %d: Channel Scale %5.2f \n",frame,subframe,slot,symbol,ue->generic_stat_bis[ue->current_thread_id[subframe]][slot].p_time/(cpuf*1000.0)); + LOG_D(PHY, "[AbsSFN %d.%d] Slot%d Symbol %d: Channel Scale %5.2f \n",frame,subframe,slot,symbol,ue->generic_stat_bis[ue->current_thread_id[subframe]][slot].p_time/(cpuf*1000.0)); start_meas(&ue->generic_stat_bis[ue->current_thread_id[subframe]][slot]); #endif @@ -507,7 +507,7 @@ int rx_pdsch(PHY_VARS_UE *ue, #endif #if UE_TIMING_TRACE stop_meas(&ue->generic_stat_bis[ue->current_thread_id[subframe]][slot]); - LOG_I(PHY, "[AbsSFN %d.%d] Slot%d Symbol %d first_symbol_flag %d: Channel Level %5.2f \n",frame,subframe,slot,symbol,first_symbol_flag, + LOG_D(PHY, "[AbsSFN %d.%d] Slot%d Symbol %d first_symbol_flag %d: Channel Level %5.2f \n",frame,subframe,slot,symbol,first_symbol_flag, ue->generic_stat_bis[ue->current_thread_id[subframe]][slot].p_time/(cpuf*1000.0)); start_meas(&ue->generic_stat_bis[ue->current_thread_id[subframe]][slot]); #endif @@ -731,7 +731,7 @@ int rx_pdsch(PHY_VARS_UE *ue, #if UE_TIMING_TRACE stop_meas(&ue->generic_stat_bis[ue->current_thread_id[subframe]][slot]); - LOG_I(PHY, "[AbsSFN %d.%d] Slot%d Symbol %d log2_maxh %d Channel Comp %5.2f \n",frame,subframe,slot,symbol,pdsch_vars[eNB_id]->log2_maxh, + LOG_D(PHY, "[AbsSFN %d.%d] Slot%d Symbol %d log2_maxh %d Channel Comp %5.2f \n",frame,subframe,slot,symbol,pdsch_vars[eNB_id]->log2_maxh, ue->generic_stat_bis[ue->current_thread_id[subframe]][slot].p_time/(cpuf*1000.0)); start_meas(&ue->generic_stat_bis[ue->current_thread_id[subframe]][slot]); #endif @@ -805,7 +805,7 @@ int rx_pdsch(PHY_VARS_UE *ue, #if UE_TIMING_TRACE stop_meas(&ue->generic_stat_bis[ue->current_thread_id[subframe]][slot]); - LOG_I(PHY, "[AbsSFN %d.%d] Slot%d Symbol %d: Channel Combine %5.2f \n",frame,subframe,slot,symbol,ue->generic_stat_bis[ue->current_thread_id[subframe]][slot].p_time/(cpuf*1000.0)); + LOG_D(PHY, "[AbsSFN %d.%d] Slot%d Symbol %d: Channel Combine %5.2f \n",frame,subframe,slot,symbol,ue->generic_stat_bis[ue->current_thread_id[subframe]][slot].p_time/(cpuf*1000.0)); start_meas(&ue->generic_stat_bis[ue->current_thread_id[subframe]][slot]); #endif //printf("LLR dlsch0_harq->Qm %d rx_type %d cw0 %d cw1 %d symbol %d \n",dlsch0_harq->Qm,rx_type,codeword_TB0,codeword_TB1,symbol); @@ -837,7 +837,7 @@ int rx_pdsch(PHY_VARS_UE *ue, symbol, first_symbol_flag, nb_rb, - adjust_G2(frame_parms,dlsch0_harq->rb_alloc_even,2,subframe,symbol), + adjust_G2(frame_parms->Ncp,frame_parms->frame_type, frame_parms->N_RB_DL,dlsch0_harq->rb_alloc_even,2,subframe,symbol), beamforming_mode); } else if (codeword_TB0 == -1) { dlsch_qpsk_llr(frame_parms, @@ -846,7 +846,7 @@ int rx_pdsch(PHY_VARS_UE *ue, symbol, first_symbol_flag, nb_rb, - adjust_G2(frame_parms,dlsch0_harq->rb_alloc_even,2,subframe,symbol), + adjust_G2(frame_parms->Ncp,frame_parms->frame_type, frame_parms->N_RB_DL,dlsch0_harq->rb_alloc_even,2,subframe,symbol), beamforming_mode); } else if (rx_type >= rx_IC_single_stream) { if (dlsch1_harq->Qm == 2) { @@ -856,7 +856,7 @@ int rx_pdsch(PHY_VARS_UE *ue, pdsch_vars[eNB_id]->dl_ch_rho2_ext, pdsch_vars[eNB_id]->llr[0], symbol,first_symbol_flag,nb_rb, - adjust_G2(frame_parms,dlsch0_harq->rb_alloc_even,2,subframe,symbol), + adjust_G2(frame_parms->Ncp,frame_parms->frame_type, frame_parms->N_RB_DL,dlsch0_harq->rb_alloc_even,2,subframe,symbol), pdsch_vars[eNB_id]->llr128); if (rx_type==rx_IC_dual_stream) { @@ -866,7 +866,7 @@ int rx_pdsch(PHY_VARS_UE *ue, pdsch_vars[eNB_id]->dl_ch_rho_ext[harq_pid][round], pdsch_vars[eNB_id]->llr[1], symbol,first_symbol_flag,nb_rb, - adjust_G2(frame_parms,dlsch1_harq->rb_alloc_even,2,subframe,symbol), + adjust_G2(frame_parms->Ncp,frame_parms->frame_type, frame_parms->N_RB_DL,dlsch1_harq->rb_alloc_even,2,subframe,symbol), pdsch_vars[eNB_id]->llr128_2ndstream); } } else if (dlsch1_harq->Qm == 4) { @@ -877,7 +877,7 @@ int rx_pdsch(PHY_VARS_UE *ue, pdsch_vars[eNB_id]->dl_ch_rho2_ext, pdsch_vars[eNB_id]->llr[0], symbol,first_symbol_flag,nb_rb, - adjust_G2(frame_parms,dlsch0_harq->rb_alloc_even,2,subframe,symbol), + adjust_G2(frame_parms->Ncp,frame_parms->frame_type, frame_parms->N_RB_DL,dlsch0_harq->rb_alloc_even,2,subframe,symbol), pdsch_vars[eNB_id]->llr128); if (rx_type==rx_IC_dual_stream) { @@ -888,7 +888,7 @@ int rx_pdsch(PHY_VARS_UE *ue, pdsch_vars[eNB_id]->dl_ch_rho_ext[harq_pid][round], pdsch_vars[eNB_id]->llr[1], symbol,first_symbol_flag,nb_rb, - adjust_G2(frame_parms,dlsch1_harq->rb_alloc_even,4,subframe,symbol), + adjust_G2(frame_parms->Ncp,frame_parms->frame_type, frame_parms->N_RB_DL,dlsch1_harq->rb_alloc_even,4,subframe,symbol), pdsch_vars[eNB_id]->llr128_2ndstream); } } else { @@ -899,7 +899,7 @@ int rx_pdsch(PHY_VARS_UE *ue, pdsch_vars[eNB_id]->dl_ch_rho2_ext, pdsch_vars[eNB_id]->llr[0], symbol,first_symbol_flag,nb_rb, - adjust_G2(frame_parms,dlsch0_harq->rb_alloc_even,2,subframe,symbol), + adjust_G2(frame_parms->Ncp,frame_parms->frame_type, frame_parms->N_RB_DL,dlsch0_harq->rb_alloc_even,2,subframe,symbol), pdsch_vars[eNB_id]->llr128); if (rx_type==rx_IC_dual_stream) { @@ -910,7 +910,7 @@ int rx_pdsch(PHY_VARS_UE *ue, pdsch_vars[eNB_id]->dl_ch_rho_ext[harq_pid][round], pdsch_vars[eNB_id]->llr[1], symbol,first_symbol_flag,nb_rb, - adjust_G2(frame_parms,dlsch1_harq->rb_alloc_even,6,subframe,symbol), + adjust_G2(frame_parms->Ncp,frame_parms->frame_type, frame_parms->N_RB_DL,dlsch1_harq->rb_alloc_even,6,subframe,symbol), pdsch_vars[eNB_id]->llr128_2ndstream); } } @@ -925,7 +925,7 @@ int rx_pdsch(PHY_VARS_UE *ue, pdsch_vars[eNB_id]->llr[0], pdsch_vars[eNB_id]->dl_ch_mag0, symbol,first_symbol_flag,nb_rb, - adjust_G2(frame_parms,dlsch0_harq->rb_alloc_even,4,subframe,symbol), + adjust_G2(frame_parms->Ncp,frame_parms->frame_type, frame_parms->N_RB_DL,dlsch0_harq->rb_alloc_even,4,subframe,symbol), pdsch_vars[eNB_id]->llr128, beamforming_mode); } else if (codeword_TB0 == -1) { @@ -934,7 +934,7 @@ int rx_pdsch(PHY_VARS_UE *ue, pdsch_vars[eNB_id]->llr[1], pdsch_vars[eNB_id]->dl_ch_mag0, symbol,first_symbol_flag,nb_rb, - adjust_G2(frame_parms,dlsch0_harq->rb_alloc_even,4,subframe,symbol), + adjust_G2(frame_parms->Ncp,frame_parms->frame_type, frame_parms->N_RB_DL,dlsch0_harq->rb_alloc_even,4,subframe,symbol), pdsch_vars[eNB_id]->llr128_2ndstream, beamforming_mode); } else if (rx_type >= rx_IC_single_stream) { @@ -946,7 +946,7 @@ int rx_pdsch(PHY_VARS_UE *ue, pdsch_vars[eNB_id]->dl_ch_rho2_ext, pdsch_vars[eNB_id]->llr[0], symbol,first_symbol_flag,nb_rb, - adjust_G2(frame_parms,dlsch0_harq->rb_alloc_even,4,subframe,symbol), + adjust_G2(frame_parms->Ncp,frame_parms->frame_type, frame_parms->N_RB_DL,dlsch0_harq->rb_alloc_even,4,subframe,symbol), pdsch_vars[eNB_id]->llr128); if (rx_type==rx_IC_dual_stream) { @@ -957,7 +957,7 @@ int rx_pdsch(PHY_VARS_UE *ue, pdsch_vars[eNB_id]->dl_ch_rho_ext[harq_pid][round], pdsch_vars[eNB_id]->llr[1], symbol,first_symbol_flag,nb_rb, - adjust_G2(frame_parms,dlsch1_harq->rb_alloc_even,2,subframe,symbol), + adjust_G2(frame_parms->Ncp,frame_parms->frame_type, frame_parms->N_RB_DL,dlsch1_harq->rb_alloc_even,2,subframe,symbol), pdsch_vars[eNB_id]->llr128_2ndstream); } } else if (dlsch1_harq->Qm == 4) { @@ -969,7 +969,7 @@ int rx_pdsch(PHY_VARS_UE *ue, pdsch_vars[eNB_id]->dl_ch_rho2_ext, pdsch_vars[eNB_id]->llr[0], symbol,first_symbol_flag,nb_rb, - adjust_G2(frame_parms,dlsch0_harq->rb_alloc_even,4,subframe,symbol), + adjust_G2(frame_parms->Ncp,frame_parms->frame_type, frame_parms->N_RB_DL,dlsch0_harq->rb_alloc_even,4,subframe,symbol), pdsch_vars[eNB_id]->llr128); if (rx_type==rx_IC_dual_stream) { @@ -981,7 +981,7 @@ int rx_pdsch(PHY_VARS_UE *ue, pdsch_vars[eNB_id]->dl_ch_rho_ext[harq_pid][round], pdsch_vars[eNB_id]->llr[1], symbol,first_symbol_flag,nb_rb, - adjust_G2(frame_parms,dlsch1_harq->rb_alloc_even,4,subframe,symbol), + adjust_G2(frame_parms->Ncp,frame_parms->frame_type, frame_parms->N_RB_DL,dlsch1_harq->rb_alloc_even,4,subframe,symbol), pdsch_vars[eNB_id]->llr128_2ndstream); } } else { @@ -993,7 +993,7 @@ int rx_pdsch(PHY_VARS_UE *ue, pdsch_vars[eNB_id]->dl_ch_rho2_ext, pdsch_vars[eNB_id]->llr[0], symbol,first_symbol_flag,nb_rb, - adjust_G2(frame_parms,dlsch0_harq->rb_alloc_even,4,subframe,symbol), + adjust_G2(frame_parms->Ncp,frame_parms->frame_type, frame_parms->N_RB_DL,dlsch0_harq->rb_alloc_even,4,subframe,symbol), pdsch_vars[eNB_id]->llr128); if (rx_type==rx_IC_dual_stream) { @@ -1005,7 +1005,7 @@ int rx_pdsch(PHY_VARS_UE *ue, pdsch_vars[eNB_id]->dl_ch_rho_ext[harq_pid][round], pdsch_vars[eNB_id]->llr[1], symbol,first_symbol_flag,nb_rb, - adjust_G2(frame_parms,dlsch1_harq->rb_alloc_even,6,subframe,symbol), + adjust_G2(frame_parms->Ncp,frame_parms->frame_type, frame_parms->N_RB_DL,dlsch1_harq->rb_alloc_even,6,subframe,symbol), pdsch_vars[eNB_id]->llr128_2ndstream); } } @@ -1021,7 +1021,7 @@ int rx_pdsch(PHY_VARS_UE *ue, pdsch_vars[eNB_id]->dl_ch_mag0, pdsch_vars[eNB_id]->dl_ch_magb0, symbol,first_symbol_flag,nb_rb, - adjust_G2(frame_parms,dlsch0_harq->rb_alloc_even,6,subframe,symbol), + adjust_G2(frame_parms->Ncp,frame_parms->frame_type, frame_parms->N_RB_DL,dlsch0_harq->rb_alloc_even,6,subframe,symbol), pdsch_vars[eNB_id]->llr_offset[symbol], beamforming_mode); } else if (codeword_TB0 == -1) { @@ -1031,7 +1031,7 @@ int rx_pdsch(PHY_VARS_UE *ue, pdsch_vars[eNB_id]->dl_ch_mag0, pdsch_vars[eNB_id]->dl_ch_magb0, symbol,first_symbol_flag,nb_rb, - adjust_G2(frame_parms,dlsch0_harq->rb_alloc_even,6,subframe,symbol), + adjust_G2(frame_parms->Ncp,frame_parms->frame_type, frame_parms->N_RB_DL,dlsch0_harq->rb_alloc_even,6,subframe,symbol), pdsch_vars[eNB_id]->llr_offset[symbol], beamforming_mode); } else if (rx_type >= rx_IC_single_stream) { @@ -1043,7 +1043,7 @@ int rx_pdsch(PHY_VARS_UE *ue, pdsch_vars[eNB_id]->dl_ch_rho2_ext, pdsch_vars[eNB_id]->llr[0], symbol,first_symbol_flag,nb_rb, - adjust_G2(frame_parms,dlsch0_harq->rb_alloc_even,6,subframe,symbol), + adjust_G2(frame_parms->Ncp,frame_parms->frame_type, frame_parms->N_RB_DL,dlsch0_harq->rb_alloc_even,6,subframe,symbol), pdsch_vars[eNB_id]->llr128); if (rx_type==rx_IC_dual_stream) { @@ -1054,7 +1054,7 @@ int rx_pdsch(PHY_VARS_UE *ue, pdsch_vars[eNB_id]->dl_ch_rho_ext[harq_pid][round], pdsch_vars[eNB_id]->llr[1], symbol,first_symbol_flag,nb_rb, - adjust_G2(frame_parms,dlsch1_harq->rb_alloc_even,2,subframe,symbol), + adjust_G2(frame_parms->Ncp,frame_parms->frame_type, frame_parms->N_RB_DL,dlsch1_harq->rb_alloc_even,2,subframe,symbol), pdsch_vars[eNB_id]->llr128_2ndstream); } } else if (dlsch1_harq->Qm == 4) { @@ -1066,7 +1066,7 @@ int rx_pdsch(PHY_VARS_UE *ue, pdsch_vars[eNB_id]->dl_ch_rho2_ext, pdsch_vars[eNB_id]->llr[0], symbol,first_symbol_flag,nb_rb, - adjust_G2(frame_parms,dlsch0_harq->rb_alloc_even,6,subframe,symbol), + adjust_G2(frame_parms->Ncp,frame_parms->frame_type, frame_parms->N_RB_DL,dlsch0_harq->rb_alloc_even,6,subframe,symbol), pdsch_vars[eNB_id]->llr128); if (rx_type==rx_IC_dual_stream) { @@ -1078,7 +1078,7 @@ int rx_pdsch(PHY_VARS_UE *ue, pdsch_vars[eNB_id]->dl_ch_rho_ext[harq_pid][round], pdsch_vars[eNB_id]->llr[1], symbol,first_symbol_flag,nb_rb, - adjust_G2(frame_parms,dlsch1_harq->rb_alloc_even,4,subframe,symbol), + adjust_G2(frame_parms->Ncp,frame_parms->frame_type, frame_parms->N_RB_DL,dlsch1_harq->rb_alloc_even,4,subframe,symbol), pdsch_vars[eNB_id]->llr128_2ndstream); } } else { @@ -1090,7 +1090,7 @@ int rx_pdsch(PHY_VARS_UE *ue, pdsch_vars[eNB_id]->dl_ch_rho2_ext, (int16_t *)pllr_symbol_cw0, symbol,first_symbol_flag,nb_rb, - adjust_G2(frame_parms,dlsch0_harq->rb_alloc_even,6,subframe,symbol), + adjust_G2(frame_parms->Ncp,frame_parms->frame_type, frame_parms->N_RB_DL,dlsch0_harq->rb_alloc_even,6,subframe,symbol), pdsch_vars[eNB_id]->llr_offset[symbol]); if (rx_type==rx_IC_dual_stream) { @@ -1102,7 +1102,7 @@ int rx_pdsch(PHY_VARS_UE *ue, pdsch_vars[eNB_id]->dl_ch_rho_ext[harq_pid][round], (int16_t *)pllr_symbol_cw1, symbol,first_symbol_flag,nb_rb, - adjust_G2(frame_parms,dlsch1_harq->rb_alloc_even,6,subframe,symbol), + adjust_G2(frame_parms->Ncp,frame_parms->frame_type, frame_parms->N_RB_DL,dlsch1_harq->rb_alloc_even,6,subframe,symbol), pdsch_vars[eNB_id]->llr_offset[symbol]); } } @@ -1124,7 +1124,7 @@ int rx_pdsch(PHY_VARS_UE *ue, pdsch_vars[eNB_id]->rxdataF_comp0, (int16_t *)pllr_symbol_cw0, symbol,first_symbol_flag,nb_rb, - adjust_G2(frame_parms,dlsch0_harq->rb_alloc_even,2,subframe,symbol), + adjust_G2(frame_parms->Ncp,frame_parms->frame_type, frame_parms->N_RB_DL,dlsch0_harq->rb_alloc_even,2,subframe,symbol), beamforming_mode); } @@ -1137,7 +1137,7 @@ int rx_pdsch(PHY_VARS_UE *ue, pdsch_vars[eNB_id]->llr[0], pdsch_vars[eNB_id]->dl_ch_mag0, symbol,first_symbol_flag,nb_rb, - adjust_G2(frame_parms,dlsch0_harq->rb_alloc_even,4,subframe,symbol), + adjust_G2(frame_parms->Ncp,frame_parms->frame_type, frame_parms->N_RB_DL,dlsch0_harq->rb_alloc_even,4,subframe,symbol), pdsch_vars[eNB_id]->llr128, beamforming_mode); } @@ -1152,7 +1152,7 @@ int rx_pdsch(PHY_VARS_UE *ue, pdsch_vars[eNB_id]->dl_ch_mag0, pdsch_vars[eNB_id]->dl_ch_magb0, symbol,first_symbol_flag,nb_rb, - adjust_G2(frame_parms,dlsch0_harq->rb_alloc_even,6,subframe,symbol), + adjust_G2(frame_parms->Ncp,frame_parms->frame_type, frame_parms->N_RB_DL,dlsch0_harq->rb_alloc_even,6,subframe,symbol), pdsch_vars[eNB_id]->llr_offset[symbol], beamforming_mode); } diff --git a/openair1/PHY/LTE_UE_TRANSPORT/dlsch_llr_computation.c b/openair1/PHY/LTE_UE_TRANSPORT/dlsch_llr_computation.c index 4c74377ef6f4a323df9d96b46e993beadeac2908..43f3b5451fc2de1fe86590983631395a9bb3a62d 100644 --- a/openair1/PHY/LTE_UE_TRANSPORT/dlsch_llr_computation.c +++ b/openair1/PHY/LTE_UE_TRANSPORT/dlsch_llr_computation.c @@ -746,7 +746,7 @@ int32_t dlsch_qpsk_llr_SIC(LTE_DL_FRAME_PARMS *frame_parms, amp_tmp=amp_tmp<<1; // to compensate for >> 1 shift in modulation - pbch_pss_sss_adjust=adjust_G2(frame_parms,&rb_alloc,2,subframe,symbol); + pbch_pss_sss_adjust=adjust_G2(frame_parms->Ncp,frame_parms->frame_type, frame_parms->N_RB_DL ,&rb_alloc,2,subframe,symbol); if ((symbol_mod==0) || (symbol_mod==(4-frame_parms->Ncp))) { if (frame_parms->nb_antenna_ports_eNB!=1) @@ -981,7 +981,7 @@ void dlsch_16qam_llr_SIC (LTE_DL_FRAME_PARMS *frame_parms, symbol_mod = (symbol>=(7-frame_parms->Ncp)) ? symbol-(7-frame_parms->Ncp) : symbol; - pbch_pss_sss_adjust=adjust_G2(frame_parms,&rb_alloc,4,subframe,symbol); + pbch_pss_sss_adjust=adjust_G2(frame_parms->Ncp,frame_parms->frame_type, frame_parms->N_RB_DL,&rb_alloc,4,subframe,symbol); if ((symbol_mod==0) || (symbol_mod==(4-frame_parms->Ncp))) { amp_tmp=0x1fff;//dlsch0->sqrt_rho_b; already taken into account @@ -1281,7 +1281,7 @@ void dlsch_64qam_llr_SIC(LTE_DL_FRAME_PARMS *frame_parms, symbol_mod = (symbol>=(7-frame_parms->Ncp)) ? symbol-(7-frame_parms->Ncp) : symbol; - pbch_pss_sss_adjust=adjust_G2(frame_parms,&rb_alloc,6,subframe,symbol); + pbch_pss_sss_adjust=adjust_G2(frame_parms->Ncp,frame_parms->frame_type, frame_parms->N_RB_DL,&rb_alloc,6,subframe,symbol); if ((symbol_mod==0) || (symbol_mod==(4-frame_parms->Ncp))) { amp_tmp = 0x1fff;//dlsch0->sqrt_rho_b; already taken into account diff --git a/openair1/PHY/LTE_UE_TRANSPORT/pcfich_ue.c b/openair1/PHY/LTE_UE_TRANSPORT/pcfich_ue.c index 82bb0a2659ed9ff4e4ea8a09fc4d068f2c516092..740d1be5013d3f2c5685b66fd50809cb71b69cc0 100644 --- a/openair1/PHY/LTE_UE_TRANSPORT/pcfich_ue.c +++ b/openair1/PHY/LTE_UE_TRANSPORT/pcfich_ue.c @@ -44,15 +44,13 @@ void pcfich_unscrambling(LTE_DL_FRAME_PARMS *frame_parms, int16_t *d) { - uint32_t i; - uint8_t reset; - uint32_t x1, x2, s=0; + uint8_t reset = 1; + uint32_t x1 = 0; // x1 is set in lte_gold_generic + uint32_t s = 0; - reset = 1; - // x1 is set in lte_gold_generic - x2 = ((((2*frame_parms->Nid_cell)+1)*(1+subframe))<<9) + frame_parms->Nid_cell; //this is c_init in 36.211 Sec 6.7.1 + uint32_t x2 = ((((2*frame_parms->Nid_cell)+1)*(1+subframe))<<9) + frame_parms->Nid_cell; //this is c_init in 36.211 Sec 6.7.1 - for (i=0; i<32; i++) { + for (uint32_t i=0; i<32; i++) { if ((i&0x1f)==0) { s = lte_gold_generic(&x1, &x2, reset); //printf("lte_gold[%d]=%x\n",i,s); diff --git a/openair1/PHY/LTE_UE_TRANSPORT/pucch_ue.c b/openair1/PHY/LTE_UE_TRANSPORT/pucch_ue.c index 1f9fb86f80a6dd147b2fa1329db0772742393581..9427ec3a5bb06fb4596e7bb79f47eb14b4aeb826 100644 --- a/openair1/PHY/LTE_UE_TRANSPORT/pucch_ue.c +++ b/openair1/PHY/LTE_UE_TRANSPORT/pucch_ue.c @@ -336,8 +336,8 @@ void generate_pucch1x(int32_t **txdataF, -inline void pucch2x_scrambling(LTE_DL_FRAME_PARMS *fp,int subframe,uint16_t rnti,uint32_t B,uint8_t *btilde) __attribute__((always_inline)); -inline void pucch2x_scrambling(LTE_DL_FRAME_PARMS *fp,int subframe,uint16_t rnti,uint32_t B,uint8_t *btilde) { +static inline void pucch2x_scrambling(LTE_DL_FRAME_PARMS *fp,int subframe,uint16_t rnti,uint32_t B,uint8_t *btilde) __attribute__((always_inline)); +static inline void pucch2x_scrambling(LTE_DL_FRAME_PARMS *fp,int subframe,uint16_t rnti,uint32_t B,uint8_t *btilde) { uint32_t x1, x2, s=0; int i; diff --git a/openair1/PHY/LTE_UE_TRANSPORT/transport_proto_ue.h b/openair1/PHY/LTE_UE_TRANSPORT/transport_proto_ue.h index 7ab795cae9a0eced9d89f06d39814256cc270713..c5d096ceb789573d70aea15784f4aff9e1c8f374 100644 --- a/openair1/PHY/LTE_UE_TRANSPORT/transport_proto_ue.h +++ b/openair1/PHY/LTE_UE_TRANSPORT/transport_proto_ue.h @@ -1303,7 +1303,7 @@ uint32_t conv_nprb(uint8_t ra_header,uint32_t rb_alloc,int N_RB_DL); int get_G(LTE_DL_FRAME_PARMS *frame_parms,uint16_t nb_rb,uint32_t *rb_alloc,uint8_t mod_order,uint8_t Nl,uint8_t num_pdcch_symbols,int frame,uint8_t subframe, uint8_t beamforming_mode); int adjust_G(LTE_DL_FRAME_PARMS *frame_parms,uint32_t *rb_alloc,uint8_t mod_order,uint8_t subframe); -int adjust_G2(LTE_DL_FRAME_PARMS *frame_parms,uint32_t *rb_alloc,uint8_t mod_order,uint8_t subframe,uint8_t symbol); + #ifndef modOrder diff --git a/openair1/PHY/NR_ESTIMATION/nr_ul_channel_estimation.c b/openair1/PHY/NR_ESTIMATION/nr_ul_channel_estimation.c index 1f164748bf53d5936044e16c0169c9e6fa6aaf86..9aaba7fb66789bcda3d29103ff383a4aa944c40d 100644 --- a/openair1/PHY/NR_ESTIMATION/nr_ul_channel_estimation.c +++ b/openair1/PHY/NR_ESTIMATION/nr_ul_channel_estimation.c @@ -36,10 +36,46 @@ //#define DEBUG_CH //#define DEBUG_PUSCH +//#define SRS_DEBUG #define NO_INTERP 1 #define dBc(x,y) (dB_fixed(((int32_t)(x))*(x) + ((int32_t)(y))*(y))) +void freq2time(uint16_t ofdm_symbol_size, + int16_t *freq_signal, + int16_t *time_signal) { + + switch (ofdm_symbol_size) { + case 128: + idft(IDFT_128, freq_signal, time_signal, 1); + break; + case 256: + idft(IDFT_256, freq_signal, time_signal, 1); + break; + case 512: + idft(IDFT_512, freq_signal, time_signal, 1); + break; + case 1024: + idft(IDFT_1024, freq_signal, time_signal, 1); + break; + case 1536: + idft(IDFT_1536, freq_signal, time_signal, 1); + break; + case 2048: + idft(IDFT_2048, freq_signal, time_signal, 1); + break; + case 4096: + idft(IDFT_4096, freq_signal, time_signal, 1); + break; + case 8192: + idft(IDFT_8192, freq_signal, time_signal, 1); + break; + default: + idft(IDFT_512, freq_signal, time_signal, 1); + break; + } +} + int nr_pusch_channel_estimation(PHY_VARS_gNB *gNB, unsigned char Ns, unsigned short p, @@ -273,10 +309,10 @@ int nr_pusch_channel_estimation(PHY_VARS_gNB *gNB, ch, ul_ch, 8); - + //for (int i= 0; i<16; i++) //printf("ul_ch addr %p %d\n", ul_ch+i, *(ul_ch+i)); - + pil += 2; re_offset = (re_offset+2) % gNB->frame_parms.ofdm_symbol_size; rxF = (int16_t *)&rxdataF[aarx][(soffset+symbol_offset+nushift+re_offset)]; @@ -898,63 +934,9 @@ int nr_pusch_channel_estimation(PHY_VARS_gNB *gNB, #endif // Convert to time domain - - switch (gNB->frame_parms.ofdm_symbol_size) { - case 128: - idft(IDFT_128,(int16_t*) &ul_ch_estimates[aarx][symbol_offset], - (int16_t*) ul_ch_estimates_time[aarx], - 1); - break; - - case 256: - idft(IDFT_256,(int16_t*) &ul_ch_estimates[aarx][symbol_offset], - (int16_t*) ul_ch_estimates_time[aarx], - 1); - break; - - case 512: - idft(IDFT_512,(int16_t*) &ul_ch_estimates[aarx][symbol_offset], - (int16_t*) ul_ch_estimates_time[aarx], - 1); - break; - - case 1024: - idft(IDFT_1024,(int16_t*) &ul_ch_estimates[aarx][symbol_offset], - (int16_t*) ul_ch_estimates_time[aarx], - 1); - break; - - case 1536: - idft(IDFT_1536,(int16_t*) &ul_ch_estimates[aarx][symbol_offset], - (int16_t*) ul_ch_estimates_time[aarx], - 1); - break; - - case 2048: - idft(IDFT_2048,(int16_t*) &ul_ch_estimates[aarx][symbol_offset], - (int16_t*) ul_ch_estimates_time[aarx], - 1); - break; - - case 4096: - idft(IDFT_4096,(int16_t*) &ul_ch_estimates[aarx][symbol_offset], - (int16_t*) ul_ch_estimates_time[aarx], - 1); - break; - - case 8192: - idft(IDFT_8192,(int16_t*) &ul_ch_estimates[aarx][symbol_offset], - (int16_t*) ul_ch_estimates_time[aarx], - 1); - break; - - default: - idft(IDFT_512,(int16_t*) &ul_ch_estimates[aarx][symbol_offset], - (int16_t*) ul_ch_estimates_time[aarx], - 1); - break; - } - + freq2time(gNB->frame_parms.ofdm_symbol_size, + (int16_t*) &ul_ch_estimates[aarx][symbol_offset], + (int16_t*) ul_ch_estimates_time[aarx]); } #ifdef DEBUG_CH @@ -1091,3 +1073,178 @@ void nr_pusch_ptrs_processing(PHY_VARS_gNB *gNB, }// last symbol check }//Antenna loop } + +uint32_t calc_power(uint16_t *x, uint32_t size) { + uint64_t sum_x = 0; + uint64_t sum_x2 = 0; + for(int k = 0; k<size; k++) { + sum_x = sum_x + x[k]; + sum_x2 = sum_x2 + x[k]*x[k]; + } + return sum_x2/size - (sum_x/size)*(sum_x/size); +} + +int nr_srs_channel_estimation(PHY_VARS_gNB *gNB, + int frame, + int slot, + nfapi_nr_srs_pdu_t *srs_pdu, + nr_srs_info_t *nr_srs_info, + int32_t *srs_generated_signal, + int32_t **srs_received_signal, + int32_t **srs_estimated_channel_freq, + int32_t **srs_estimated_channel_time, + int32_t **srs_estimated_channel_time_shifted, + uint32_t *noise_power) { + + 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; + } + + NR_DL_FRAME_PARMS *frame_parms = &gNB->frame_parms; + int32_t **srs_ls_estimated_channel = nr_srs_info->srs_ls_estimated_channel; + + uint16_t noise_real[frame_parms->nb_antennas_rx*nr_srs_info->sc_list_length]; + uint16_t noise_imag[frame_parms->nb_antennas_rx*nr_srs_info->sc_list_length]; + + int16_t ls_estimated[2]; + + for (int ant = 0; ant < frame_parms->nb_antennas_rx; ant++) { + + memset(srs_ls_estimated_channel[ant], 0, frame_parms->ofdm_symbol_size*(1<<srs_pdu->num_symbols)*sizeof(int32_t)); + memset(srs_estimated_channel_freq[ant], 0, frame_parms->ofdm_symbol_size*(1<<srs_pdu->num_symbols)*sizeof(int32_t)); + + int16_t *srs_estimated_channel16 = (int16_t *)&srs_estimated_channel_freq[ant][nr_srs_info->sc_list[0]]; + + for(int sc_idx = 0; sc_idx < nr_srs_info->sc_list_length; sc_idx++) { + + int16_t generated_real = srs_generated_signal[nr_srs_info->sc_list[sc_idx]] & 0xFFFF; + int16_t generated_imag = (srs_generated_signal[nr_srs_info->sc_list[sc_idx]] >> 16) & 0xFFFF; + + int16_t received_real = srs_received_signal[ant][nr_srs_info->sc_list[sc_idx]] & 0xFFFF; + int16_t received_imag = (srs_received_signal[ant][nr_srs_info->sc_list[sc_idx]] >> 16) & 0xFFFF; + + // 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); + + // 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_estimated_channel_freq[ant][nr_srs_info->sc_list[sc_idx + 2]] - sizeof(uint64_t); + multadd_real_vector_complex_scalar(filt8_start, 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} + multadd_real_vector_complex_scalar(filt8_end, 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_estimated_channel_freq[ant][nr_srs_info->sc_list[sc_idx]]; + } + } 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_estimated_channel_freq[ant][nr_srs_info->sc_list[sc_idx + 1]] - sizeof(uint64_t); + // 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_estimated_channel_freq[ant][nr_srs_info->sc_list[sc_idx]]; + } + } + +#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,"\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 + } + + // Compute noise + for(int sc_idx = 0; sc_idx < nr_srs_info->sc_list_length; sc_idx++) { + noise_real[ant*nr_srs_info->sc_list_length + sc_idx] = abs((int16_t)((srs_ls_estimated_channel[ant][nr_srs_info->sc_list[sc_idx]]-srs_estimated_channel_freq[ant][nr_srs_info->sc_list[sc_idx]]) & 0xFFFF)); + noise_imag[ant*nr_srs_info->sc_list_length + sc_idx] = abs((int16_t)(((srs_ls_estimated_channel[ant][nr_srs_info->sc_list[sc_idx]]-srs_estimated_channel_freq[ant][nr_srs_info->sc_list[sc_idx]]) >> 16) & 0xFFFF)); + } + + // 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][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)); + } + + *noise_power = calc_power(noise_real,frame_parms->nb_antennas_rx*nr_srs_info->sc_list_length) + + calc_power(noise_imag,frame_parms->nb_antennas_rx*nr_srs_info->sc_list_length); + +#ifdef SRS_DEBUG + uint64_t subcarrier_offset = frame_parms->first_carrier_offset + srs_pdu->bwp_start*12; + uint8_t R = srs_pdu->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; r<R; r++) { + 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\n", *noise_power); +#endif + + return 0; +} \ No newline at end of file diff --git a/openair1/PHY/NR_ESTIMATION/nr_ul_estimation.h b/openair1/PHY/NR_ESTIMATION/nr_ul_estimation.h index fd3403236e9ef244a22d19dbe52170ba82b84930..a01106adb5465e96536c67721ddf82e8361c63cf 100644 --- a/openair1/PHY/NR_ESTIMATION/nr_ul_estimation.h +++ b/openair1/PHY/NR_ESTIMATION/nr_ul_estimation.h @@ -62,4 +62,16 @@ void nr_pusch_ptrs_processing(PHY_VARS_gNB *gNB, uint8_t nr_tti_rx, unsigned char symbol, uint32_t nb_re_pusch); + +int nr_srs_channel_estimation(PHY_VARS_gNB *gNB, + int frame, + int slot, + nfapi_nr_srs_pdu_t *srs_pdu, + nr_srs_info_t *nr_srs_info, + int32_t *srs_generated_signal, + int32_t **srs_received_signal, + int32_t **srs_estimated_channel_freq, + int32_t **srs_estimated_channel_time, + int32_t **srs_estimated_channel_time_shifted, + uint32_t *noise_power); #endif diff --git a/openair1/PHY/NR_REFSIG/ptrs_nr.c b/openair1/PHY/NR_REFSIG/ptrs_nr.c index b50c9a7bc9e33494e8a7881c4f58573de6c64112..40a6a56611ebbf0db6bbb2f2e2f8a6f4d2859f0b 100644 --- a/openair1/PHY/NR_REFSIG/ptrs_nr.c +++ b/openair1/PHY/NR_REFSIG/ptrs_nr.c @@ -105,14 +105,18 @@ void set_ptrs_symb_idx(uint16_t *ptrs_symbols, uint8_t L_ptrs, uint16_t ul_dmrs_symb_pos) { - uint8_t i = 0, last_symbol, is_dmrs_symbol, l_ref; - int8_t l_counter; - l_ref = start_symbol; - last_symbol = start_symbol + duration_in_symbols - 1; + int i = 0; + int l_ref = start_symbol; + const int last_symbol = start_symbol + duration_in_symbols - 1; + if (L_ptrs==0) { + LOG_E(PHY,"bug: impossible L_ptrs\n"); + *ptrs_symbols = 0; + return; + } while ( (l_ref + i*L_ptrs) <= last_symbol) { - is_dmrs_symbol = 0; + int is_dmrs_symbol = 0, l_counter; for(l_counter = l_ref + i*L_ptrs; l_counter >= max(l_ref + (i-1)*L_ptrs + 1, l_ref); l_counter--) { @@ -259,9 +263,13 @@ void nr_ptrs_cpe_estimation(uint8_t K_ptrs, uint16_t re_cnt = 0; uint16_t cnt = 0; unsigned short nb_re_pdsch = NR_NB_SC_PER_RB * nb_rb; + if (K_ptrs==0) { + LOG_E(PHY,"K_ptrs == 0\n"); + return; + } uint16_t sc_per_symbol = (nb_rb + K_ptrs - 1)/K_ptrs; - int16_t *ptrs_p = (int16_t *)malloc(sizeof(int32_t)*(sc_per_symbol)); - int16_t *dmrs_comp_p = (int16_t *)malloc(sizeof(int32_t)*(sc_per_symbol)); + struct complex16 ptrs_p[(1 + sc_per_symbol/4)*4]; + struct complex16 dmrs_comp_p[(1 + sc_per_symbol/4)*4]; double abs = 0.0; double real = 0.0; double imag = 0.0; @@ -269,7 +277,7 @@ void nr_ptrs_cpe_estimation(uint8_t K_ptrs, double alpha = 0; #endif /* generate PTRS RE for the symbol */ - nr_gen_ref_conj_symbols(gold_seq,sc_per_symbol*2,ptrs_p, NR_MOD_TABLE_QPSK_OFFSET,2);// 2 for QPSK + nr_gen_ref_conj_symbols(gold_seq,sc_per_symbol*2,(int16_t*)ptrs_p, NR_MOD_TABLE_QPSK_OFFSET,2);// 2 for QPSK /* loop over all sub carriers to get compensated RE on ptrs symbols*/ for (int re = 0; re < nb_re_pdsch; re++) { @@ -283,8 +291,8 @@ void nr_ptrs_cpe_estimation(uint8_t K_ptrs, 0,// start_re is 0 here ofdm_symbol_size); if(is_ptrs_re) { - dmrs_comp_p[re_cnt*2] = rxF_comp[re *2]; - dmrs_comp_p[(re_cnt*2)+1] = rxF_comp[(re *2)+1]; + dmrs_comp_p[re_cnt].r = rxF_comp[re *2]; + dmrs_comp_p[re_cnt].i = rxF_comp[(re *2)+1]; re_cnt++; } else { @@ -298,7 +306,7 @@ void nr_ptrs_cpe_estimation(uint8_t K_ptrs, *ptrs_sc = re_cnt; /*Multiple compensated data with conj of PTRS */ - mult_cpx_vector(dmrs_comp_p, ptrs_p, ptrs_ch_p,(1 + sc_per_symbol/4)*4,15); // 2^15 shifted + mult_cpx_vector((int16_t*)dmrs_comp_p, (int16_t*)ptrs_p, ptrs_ch_p,(1 + sc_per_symbol/4)*4,15); // 2^15 shifted /* loop over all ptrs sub carriers in a symbol */ /* sum the error vector */ @@ -322,9 +330,6 @@ void nr_ptrs_cpe_estimation(uint8_t K_ptrs, #ifdef DEBUG_PTRS printf("[PHY][PTRS]: Estimated Symbol %d -> %d + j* %d \n",symbol, error_est[0], error_est[1] ); #endif - /* free vectors */ - free(ptrs_p); - free(dmrs_comp_p); } @@ -417,9 +422,10 @@ void get_slope_from_estimates(uint8_t start, uint8_t end, int16_t *est_p, double /* estimate from slope */ void ptrs_estimate_from_slope(int16_t *error_est, double *slope_p, uint8_t start, uint8_t end) { + struct complex16 *error=(struct complex16 *) error_est; for(uint8_t i = 1; i< (end -start);i++) { - error_est[(start+i)*2] = (error_est[start*2] + (int16_t)(i * slope_p[0]));// real - error_est[((start +i)*2)+1] = (error_est[(start*2)+1] + (int16_t)( i * slope_p[1])); //imag + error[start+i].r = error[start].r + (int16_t)(i * slope_p[0]);// real + error[start+i].i = error[start].i + (int16_t)(i * slope_p[1]); //imag #ifdef DEBUG_PTRS printf("[PHY][PTRS]: Estimated Symbol %2d -> %4d %4d from Slope (%4f %4f)\n", start+i,error_est[(start+i)*2],error_est[((start +i)*2)+1], slope_p[0],slope_p[1]); diff --git a/openair1/PHY/NR_REFSIG/ul_ref_seq_nr.h b/openair1/PHY/NR_REFSIG/ul_ref_seq_nr.h index 43ec0c03dc65bd2eee15e5f4dbfe7c7933d7da41..dab8e040592bca6a7290f843ca66dc26c817050d 100644 --- a/openair1/PHY/NR_REFSIG/ul_ref_seq_nr.h +++ b/openair1/PHY/NR_REFSIG/ul_ref_seq_nr.h @@ -108,22 +108,22 @@ EXTERN const char phi_M_ZC_6[6*U_GROUP_NUMBER] #ifdef INIT_VARIABLES_LOWPAPR_SEQUENCES_NR_H = { /* 0 1 2 3 4 5 */ -/* 0 */ -3, -1, 3, 3, -1, -3, -/* 1 */ -3, 3, -1, -1, 3, -3, -/* 2 */ -3, -3, -3, 3, 1, -3, -/* 3 */ 1, 1, 1, 3, -1, -3, -/* 4 */ 1, 1, 1, -3, -1, 3, -/* 5 */ -3, 1, -1, -3, -3, -3, -/* 6 */ -3, 1, 3, -3, -3, -3, -/* 7 */ -3, -1, 1, -3, 1, -1, -/* 8 */ -3, -1, -3, 1, -3, -3, -/* 9 */ -3, -3, 1, -3, 3, -3, +/* 0 */ -3, -1, 3, 3, -1, -3, +/* 1 */ -3, 3, -1, -1, 3, -3, +/* 2 */ -3, -3, -3, 3, 1, -3, +/* 3 */ 1, 1, 1, 3, -1, -3, +/* 4 */ 1, 1, 1, -3, -1, 3, +/* 5 */ -3, 1, -1, -3, -3, -3, +/* 6 */ -3, 1, 3, -3, -3, -3, +/* 7 */ -3, -1, 1, -3, 1, -1, +/* 8 */ -3, -1, -3, 1, -3, -3, +/* 9 */ -3, -3, 1, -3, 3, -3, /* 10 */ -3, 1, 3, 1, -3, -3, /* 11 */ -3, -1, -3, 1, 1, -3, /* 12 */ 1, 1, 3, -1, -3, 3, /* 13 */ 1, 1, 3, 3, -1, 3, /* 14 */ 1, 1, 1, -3, 3, -1, -/* 15 */ -1, 1, 1, -1, 3, -3, +/* 15 */ 1, 1, 1, -1, 3, -3, /* 16 */ -3, -1, -1, -1, 3, -1, /* 17 */ -3, -3, -1, 1, -1, -3, /* 18 */ -3, -3, -3, 1, -3, -1, @@ -146,36 +146,36 @@ EXTERN const char phi_M_ZC_12[12*U_GROUP_NUMBER] #ifdef INIT_VARIABLES_LOWPAPR_SEQUENCES_NR_H = { /* 0 1 2 3 4 5 6 7 8 9 10 11 */ -/* 0 */ 1, -1, 3, 1, 1, -1, -1, -1, 1, 3, -3, 1, -/* 1 */ -1, -1, -1, -1, 1, -3, -1, 3, 3, -1, -3, 1, -/* 2 */ -3, 1, -3, -3, -3, 3, -3, -1, 1, 1, 1, -3, -/* 3 */ -3, 3, 1, 3, -3, 1, 1, 1, 1, 3, -3, 3, -/* 4 */ -3, 1, 3, -1, -1, -3, -3, -1, -1, 3, 1, -3, -/* 5 */ -1, 1, 1, -1, 1, 3, 3, -1, -1, -3, 1, -3, -/* 6 */ -3, -3, -1, 3, 3, 3, -3, 3, -3, 1, -1, -3, -/* 7 */ -3, 3, -3, 3, 3, -3, -1, -1, 3, 3, 1, -3, -/* 8 */ -3, -1, -3, -1, -1, -3, 3, 3, -1, -1, 1, -3, -/* 9 */ -3, 3, 3, 3, -1, -3, -3, -1, -3, 1, 3, -3, -/* 10 */ 1, 3, -3, 1, 3, 3, 3, 1, -1, 1, -1, 3, -/* 11 */ -1, -3, 3, -1, -3, -3, -3, -1, 1, -1, 1, -3, -/* 12 */ 3, 1, 3, 1, 3, -3, -1, 1, 3, 1, -1, -3, -/* 13 */ -3, -3, 3, 3, 3, -3, -1, 1, -3, 3, 1, -3, -/* 14 */ -3, -1, 1, -3, 1, 3, 3, 3, -1, -3, 3, 3, -/* 15 */ -3, -3, 3, 1, -3, -3, -3, -1, 3, -1, 1, 3, -/* 16 */ -1, 1, 3, -3, 1, -1, 1, -1, -1, -3, 1, -1, -/* 17 */ -3, -1, -1, 1, 3, 1, 1, -1, 1, -1, -3, 1, -/* 18 */ -3, -1, 3, -3, -3, -1, -3, 1, -1, -3, 3, 3, +/* 0 */ -3, 1, -3, -3, -3, 3, -3, -1, 1, 1, 1, -3, +/* 1 */ -3, 3, 1, -3, 1, 3, -1, -1, 1, 3, 3, 3, +/* 2 */ -3, 3, 3, 1, -3, 3, -1, 1, 3, -3, 3, -3, +/* 3 */ -3, -3, -1, 3, 3, 3, -3, 3, -3, 1, -1, -3, +/* 4 */ -3, -1, -1, 1, 3, 1, 1, -1, 1, -1, -3, 1, +/* 5 */ -3, -3, 3, 1, -3, -3, -3, -1, 3, -1, 1, 3, +/* 6 */ 1, -1, 3, -1, -1, -1, -3, -1, 1, 1, 1, -3, +/* 7 */ -1, -3, 3, -1, -3, -3, -3, -1, 1, -1, 1, -3, +/* 8 */ -3, -1, 3, 1, -3, -1, -3, 3, 1, 3, 3, 1, +/* 9 */ -3, -1, -1, -3, -3, -1, -3, 3, 1, 3, -1, -3, +/* 10 */ -3, 3, -3, 3, 3, -3, -1, -1, 3, 3, 1, -3, +/* 11 */ -3, -1, -3, -1, -1, -3, 3, 3, -1, -1, 1, -3, +/* 12 */ -3, -1, 3, -3, -3, -1, -3, 1, -1, -3, 3, 3, +/* 13 */ -3, 1, -1, -1, 3, 3, -3, -1, -1, -3, -1, -3, +/* 14 */ 1, 3, -3, 1, 3, 3, 3, 1, -1, 1, -1, 3, +/* 15 */ -3, 1, 3, -1, -1, -3, -3, -1, -1, 3, 1, -3, +/* 16 */ -1, -1, -1, -1, 1, -3, -1, 3, 3, -1, -3, 1, +/* 17 */ -1, 1, 1, -1, 1, 3, 3, -1, -1, -3, 1, -3, +/* 18 */ -3, 1, 3, 3, -1, -1, -3, 3, 3, -3, 3, -3, /* 19 */ -3, -3, 3, -3, -1, 3, 3, 3, -1, -3, 1, -3, -/* 20 */ -3, 1, -1, -1, 3, 3, -3, -1, -1, -3, -1, -3, -/* 21 */ -3, 1, 3, 3, -1, -1, -3, 3, 3, -3, 3, -3, -/* 22 */ -3, -1, -1, -3, -3, -1, -3, 3, 1, 3, -1, -3, -/* 23 */ -3, -1, 3, 1, -3, -1, -3, 3, 1, 3, 3, 1, -/* 24 */ -3, 3, 3, 1, -3, 3, -1, 1, 3, -3, 3, -3, -/* 25 */ 3, -1, -3, 3, -3, -1, 3, 3, 3, -3, -1, -3, -/* 26 */ 1, -1, 3, -1, -1, -1, -3, -1, 1, 1, 1, -3, -/* 27 */ -3, 3, 1, -3, 1, 3, -1, -1, 1, 3, 3, 3, -/* 28 */ -3, 3, -3, 3, -3, -3, 3, -1, -1, 1, 3, -3, -/* 29 */ -3, 3, 1, -1, 3, 3, -3, 1, -1, 1, -1, 1, +/* 20 */ 3, 1, 3, 1, 3, -3, -1, 1, 3, 1, -1, -3, +/* 21 */ -3, 3, 1, 3, -3, 1, 1, 1, 1, 3, -3, 3, +/* 22 */ -3, 3, 3, 3, -1, -3, -3, -1, -3, 1, 3, -3, +/* 23 */ 3, -1, -3, 3, -3, -1, 3, 3, 3, -3, -1, -3, +/* 24 */ -3, -1, 1, -3, 1, 3, 3, 3, -1, -3, 3, 3, +/* 25 */ -3, 3, 1, -1, 3, 3, -3, 1, -1, 1, -1, 1, +/* 26 */ -1, 1, 3, -3, 1, -1, 1, -1, -1, -3, 1, -1, +/* 27 */ -3, -3, 3, 3, 3, -3, -1, 1, -3, 3, 1, -3, +/* 28 */ 1, -1, 3, 1, 1, -1, -1, -1, 1, 3, -3, 1, +/* 29 */ -3, 3, -3, 3, -3, -3, 3, -1, -1, 1, 3, -3, } #endif ; @@ -185,36 +185,36 @@ EXTERN const char phi_M_ZC_18[18*U_GROUP_NUMBER] #ifdef INIT_VARIABLES_LOWPAPR_SEQUENCES_NR_H = { /* 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 */ -/* 0 */ 3, -3, 3, -1, 1, 3, -3, -1, -3, -3, -1, -3, 3, 1, -1, 3, -3, 3, -/* 1 */ 3, -3, 1, 1, 3, -1, 1, -1, -1, -3, 1, 1, -1, 3, 3, -3, 3, -1, -/* 2 */ -3, 3, -1, -3, -1, -3, 1, 1, -3, -3, -1, -1, 3, -3, 1, 3, 1, 1, -/* 3 */ 1, 1, -1, -1, -3, -1, 1, -3, -3, -3, 1, -3, -1, -1, 1, -1, 3, 1, -/* 4 */ 1, 1, -3, 3, 3, 1, 3, -3, 3, -1, 1, 1, -1, 1, -3, -3, -1, 3, -/* 5 */ -3, -3, 1, -3, 3, 3, 3, -1, 3, 1, 1, -3, -3, -3, 3, -3, -1, -1, -/* 6 */ -1, 3, -1, -3, 3, 1, -3, -1, 3, -3, -1, -1, 1, 1, 1, -1, -1, -1, -/* 7 */ -3, 1, -3, -3, 1, -3, -3, 3, 1, -3, -1, -3, -3, -3, -1, 1, 1, 3, -/* 8 */ 1, -3, -1, -3, 3, 3, -1, -3, 1, -3, -3, -1, -3, -1, 1, 3, 3, 3, -/* 9 */ -3, 3, 1, -1, -1, -1, -1, 1, -1, 3, 3, -3, -1, 1, 3, -1, 3, -1, -/* 10 */ -3, -3, 1, -1, -1, 1, 1, -3, -1, 3, 3, 3, 3, -1, 3, 1, 3, 1, -/* 11 */ -3, -3, 3, 3, -3, 1, 3, -1, -3, 1, -1, -3, 3, -3, -1, -1, -1, 3, -/* 12 */ -3, -3, 3, 3, 3, 1, -3, 1, 3, 3, 1, -3, -3, 3, -1, -3, -1, 1, -/* 13 */ -3, 3, -1, 1, 3, 1, -3, -1, 1, 1, -3, 1, 3, 3, -1, -3, -3, -3, -/* 14 */ -3, 1, -3, -1, -1, 3, 1, -3, -3, -3, -1, -3, -3, 1, 1, 1, -1, -1, -/* 15 */ -3, -3, 3, 3, 3, -1, -1, -3, -1, -1, -1, 3, 1, -3, -3, -1, 3, -1, -/* 16 */ -3, -1, 3, 3, -1, 3, -1, -3, -1, 1, -1, -3, -1, -1, -1, 3, 3, 1, -/* 17 */ -3, -1, -3, -1, -3, 1, 3, -3, -1, 3, 3, 3, 1, -1, -3, 3, -1, -3, -/* 18 */ -3, 3, 1, -1, -1, 3, -3, -1, 1, 1, 1, 1, 1, -1, 3, -1, -3, -1, -/* 19 */ 3, -1, -3, 1, -3, -3, -3, 3, 3, -1, 1, -3, -1, 3, 1, 1, 3, 3, -/* 20 */ 3, 3, 3, -3, -1, -3, -1, 3, -1, 1, -1, -3, 1, -3, -3, -1, 3, 3, -/* 21 */ 3, -1, 3, 1, -3, -3, -1, 1, -3, -3, 3, 3, 3, 1, 3, -3, 3, -3, -/* 22 */ -3, 1, 1, -3, 1, 1, 3, -3, -1, -3, -1, 3, -3, 3, -1, -1, -1, -3, -/* 23 */ -3, -1, -1, -3, 1, -3, 3, -1, -1, -3, 3, 3, -3, -1, 3, -1, -1, -1, -/* 24 */ -3, -3, -3, 1, -3, 3, 1, 1, 3, -3, -3, 1, 3, -1, 3, -3, -3, 3, -/* 25 */ 1, 1, -3, -3, -3, -3, 1, 3, -3, 3, 3, 1, -3, -1, 3, -1, -3, 1, -/* 26 */ 3, -1, -1, 1, -3, -1, -3, -1, -3, -3, -1, -3, 1, 1, 1, -3, -3, 3, -/* 27 */ 3, 1, -3, 1, -3, 3, 3, -1, -3, -3, -1, -3, -3, 3, -3, -1, 1, 3, +/* 0 */ -1, 3, -1, -3, 3, 1, -3, -1, 3, -3, -1, -1, 1, 1, 1, -1, -1, -1, +/* 1 */ 3, -3, 3, -1, 1, 3, -3, -1, -3, -3, -1, -3, 3, 1, -1, 3, -3, 3, +/* 2 */ -3, 3, 1, -1, -1, 3, -3, -1, 1, 1, 1, 1, 1, -1, 3, -1, -3, -1, +/* 3 */ -3, -3, 3, 3, 3, 1, -3, 1, 3, 3, 1, -3, -3, 3, -1, -3, -1, 1, +/* 4 */ 1, 1, -1, -1, -3, -1, 1, -3, -3, -3, 1, -3, -1, -1, 1, -1, 3, 1, +/* 5 */ 3, -3, 1, 1, 3, -1, 1, -1, -1, -3, 1, 1, -1, 3, 3, -3, 3, -1, +/* 6 */ -3, 3, -1, 1, 3, 1, -3, -1, 1, 1, -3, 1, 3, 3, -1, -3, -3, -3, +/* 7 */ 1, 1, -3, 3, 3, 1, 3, -3, 3, -1, 1, 1, -1, 1, -3, -3, -1, 3, +/* 8 */ -3, 1, -3, -3, 1, -3, -3, 3, 1, -3, -1, -3, -3, -3, -1, 1, 1, 3, +/* 9 */ 3, -1, 3, 1, -3, -3, -1, 1, -3, -3, 3, 3, 3, 1, 3, -3, 3, -3, +/* 10 */ -3, -3, -3, 1, -3, 3, 1, 1, 3, -3, -3, 1, 3, -1, 3, -3, -3, 3, +/* 11 */ -3, -3, 3, 3, 3, -1, -1, -3, -1, -1, -1, 3, 1, -3, -3, -1, 3, -1, +/* 12 */ -3, -1, -3, -3, 1, 1, -1, -3, -1, -3, -1, -1, 3, 3, -1, 3, 1, 3, +/* 13 */ 1, 1, -3, -3, -3, -3, 1, 3, -3, 3, 3, 1, -3, -1, 3, -1, -3, 1, +/* 14 */ -3, 3, -1, -3, -1, -3, 1, 1, -3, -3, -1, -1, 3, -3, 1, 3, 1, 1, +/* 15 */ 3, 1, -3, 1, -3, 3, 3, -1, -3, -3, -1, -3, -3, 3, -3, -1, 1, 3, +/* 16 */ -3, -1, -3, -1, -3, 1, 3, -3, -1, 3, 3, 3, 1, -1, -3, 3, -1, -3, +/* 17 */ -3, -1, 3, 3, -1, 3, -1, -3, -1, 1, -1, -3, -1, -1, -1, 3, 3, 1, +/* 18 */ -3, 1, -3, -1, -1, 3, 1, -3, -3, -3, -1, -3, -3, 1, 1, 1, -1, -1, +/* 19 */ 3, 3, 3, -3, -1, -3, -1, 3, -1, 1, -1, -3, 1, -3, -3, -1, 3, 3, +/* 20 */ -3, 1, 1, -3, 1, 1, 3, -3, -1, -3, -1, 3, -3, 3, -1, -1, -1, -3, +/* 21 */ 1, -3, -1, -3, 3, 3, -1, -3, 1, -3, -3, -1, -3, -1, 1, 3, 3, 3, +/* 22 */ -3, -3, 1, -1, -1, 1, 1, -3, -1, 3, 3, 3, 3, -1, 3, 1, 3, 1, +/* 23 */ 3, -1, -3, 1, -3, -3, -3, 3, 3, -1, 1, -3, -1, 3, 1, 1, 3, 3, +/* 24 */ 3, -1, -1, 1, -3, -1, -3, -1, -3, -3, -1, -3, 1, 1, 1, -3, -3, 3, +/* 25 */ -3, -3, 1, -3, 3, 3, 3, -1, 3, 1, 1, -3, -3, -3, 3, -3, -1, -1, +/* 26 */ -3, -1, -1, -3, 1, -3, 3, -1, -1, -3, 3, 3, -3, -1, 3, -1, -1, -1, +/* 27 */ -3, -3, 3, 3, -3, 1, 3, -1, -3, 1, -1, -3, 3, -3, -1, -1, -1, 3, /* 28 */ -1, -3, 1, -3, -3, -3, 1, 1, 3, 3, -3, 3, 3, -3, -1, 3, -3, 1, -/* 29 */ -3, -1, -3, -3, 1, 1, -1, -3, -1, -3, -1, -1, 3, 3, -1, 3, 1, 3, +/* 29 */ -3, 3, 1, -1, -1, -1, -1, 1, -1, 3, 3, -3, -1, 1, 3, -1, 3, -1, } #endif ; @@ -224,36 +224,36 @@ EXTERN const char phi_M_ZC_24[24*U_GROUP_NUMBER] #ifdef INIT_VARIABLES_LOWPAPR_SEQUENCES_NR_H = { /* 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 */ -/* 0 */ -1, -3, 3, 1, 1, -3, 1, -3, -3, 1, -3, -1, -1, 3, -3, 3, 3, 3, -3, 1, 3, 3, -3, -3, -/* 1 */ -1, -3, 3, -1, 3, 1, 3, -1, 1, -3, -1, -3, -1, 1, 3, -3, -1, -3, 3, 3, 3, -3, -3, -3, -/* 2 */ -3, 3, 1, 3, -1, 1, -3, 1, -3, 1, -1, -3, -1, -3, -3, -3, -3, -1, -1, -1, 1, 1, -3, -3, -/* 3 */ 3, -1, 3, -1, 1, -3, 1, 1, -3, -3, 3, -3, -1, -1, -1, -1, -1, -3, -3, -1, 1, 1, -3, -3, -/* 4 */ 1, -3, 3, -1, -3, -1, 3, 3, 1, -1, 1, 1, 3, -3, -1, -3, -3, -3, -1, 3, -3, -1, -3, -3, -/* 5 */ 3, -1, 1, -1, 3, -3, 1, 1, 3, -1, -3, 3, 1, -3, 3, -1, -1, -1, -1, 1, -3, -3, -3, -3, -/* 6 */ -3, 3, -1, 3, 1, -1, -1, -1, 3, 3, 1, 1, 1, 3, 3, 1, -3, -3, -1, 1, -3, 1, 3, -3, -/* 7 */ -3, -1, 1, -3, -3, 1, 1, -3, 3, -1, -1, -3, 1, 3, 1, -1, -3, -1, -3, 1, -3, -3, -3, -3, -/* 8 */ -3, 1, -3, 1, -3, -3, 1, -3, 1, -3, -3, -3, -3, -3, 1, -3, -3, 1, 1, -3, 1, 1, -3, -3, -/* 9 */ 3, -3, -3, -1, 3, 3, -3, -1, 3, 1, 1, 1, 3, -1, 3, -3, -1, 3, -1, 3, 1, -1, -3, -3, -/* 10 */ -3, -3, -1, -1, -1, -3, 1, -1, -3, -1, 3, -3, 1, -3, 3, -3, 3, 3, 1, -1, -1, 1, -3, -3, -/* 11 */ -3, -3, 3, 3, 1, -1, -1, -1, 1, -3, -1, 1, -1, 3, -3, -1, -3, -1, -1, 1, -3, 3, -1, -3, -/* 12 */ -3, -3, 1, -1, 3, 3, -3, -1, 1, -1, -1, 1, 1, -1, -1, 3, -3, 1, -3, 1, -1, -1, -1, -3, -/* 13 */ -3, 1, -3, 3, -1, -1, -1, -3, 3, 1, -1, -3, -1, 1, 3, -1, 1, -1, 1, -3, -3, -3, -3, -3, -/* 14 */ -3, -3, -3, -1, 3, -3, 3, 1, 3, 1, -3, -1, -1, -3, 1, 1, 3, 1, -1, -3, 3, 1, 3, -3, -/* 15 */ 1, 1, -1, -3, -1, 1, 1, -3, 1, -1, 1, -3, 3, -3, -3, 3, -1, -3, 1, 3, -3, 1, -3, -3, -/* 16 */ -3, 3, -1, 3, -1, 3, 3, 1, 1, -3, 1, 3, -3, 3, -3, -3, -1, 1, 3, -3, -1, -1, -3, -3, -/* 17 */ -1, -3, -3, 1, -1, -1, -3, 1, 3, -1, -3, -1, -1, -3, 1, 1, 3, 1, -3, -1, -1, 3, -3, -3, -/* 18 */ -3, 1, -3, 1, -3, 1, 1, 3, 1, -3, -3, -1, 1, 3, -1, -3, 3, 1, -1, -3, -3, -3, -3, -3, -/* 19 */ 3, -3, 3, -1, -3, 1, 3, 1, -1, -1, -3, -1, 3, -3, 3, -1, -1, 3, 3, -3, -3, 3, -3, -3, -/* 20 */ -1, 3, -3, -3, -1, 3, -1, -1, 1, 3, 1, 3, -1, -1, -3, 1, 3, 1, -1, -3, 1, -1, -3, -3, -/* 21 */ -3, 1, -3, -1, -1, 3, 1, 3, -3, 1, -1, 3, 3, -1, -3, 3, -3, -1, -1, -3, -3, -3, 3, -3, -/* 22 */ -3, -1, -1, -3, 1, -3, -3, -1, -1, 3, -1, 1, -1, 3, 1, -3, -1, 3, 1, 1, -1, -1, -3, -3, -/* 23 */ -3, 1, -3, 3, -3, 1, -3, 3, 1, -1, -3, -1, -3, -3, -3, -3, 1, 3, -1, 1, 3, 3, 3, -3, -/* 24 */ -3, -1, 1, -3, -1, -1, 1, 1, 1, 3, 3, -1, 1, -1, 1, -1, -1, -3, -3, -3, 3, 1, -1, -3, -/* 25 */ 3, -3, -1, 1, 3, -1, -1, -3, -1, 3, -1, -3, -1, -3, 3, -1, 3, 1, 1, -3, 3, -3, -3, -3, -/* 26 */ -3, 1, 3, -1, 1, -1, 3, -3, 3, -1, -3, -1, -3, 3, -1, -1, -1, -3, -1, -1, -3, 3, 3, -3, -/* 27 */ -3, 3, -1, -3, -1, -1, -1, 3, -1, -1, 3, -3, -1, 3, -3, 3, -3, -1, 3, 1, 1, -1, -3, -3, -/* 28 */ -3, 1, -1, -3, -3, -1, 1, -3, -1, -3, 1, 1, -1, 1, 1, 3, 3, 3, -1, 1, -1, 1, -1, -3, -/* 29 */ -1, 3, -1, -1, 3, 3, -1, -1, -1, 3, -1, -3, 1, 3, 1, 1, -3, -3, -3, -1, -3, -1, -3, -3, +/* 0 */ -1, -3, 3, -1, 3, 1, 3, -1, 1, -3, -1, -3, -1, 1, 3, -3, -1, -3, 3, 3, 3, -3, -3, -3, +/* 1 */ -1, -3, 3, 1, 1, -3, 1, -3, -3, 1, -3, -1, -1, 3, -3, 3, 3, 3, -3, 1, 3, 3, -3, -3, +/* 2 */ -1, -3, -3, 1, -1, -1, -3, 1, 3, -1, -3, -1, -1, -3, 1, 1, 3, 1, -3, -1, -1, 3, -3, -3, +/* 3 */ 1, -3, 3, -1, -3, -1, 3, 3, 1, -1, 1, 1, 3, -3, -1, -3, -3, -3, -1, 3, -3, -1, -3, -3, +/* 4 */ -1, 3, -3, -3, -1, 3, -1, -1, 1, 3, 1, 3, -1, -1, -3, 1, 3, 1, -1, -3, 1, -1, -3, -3, +/* 5 */ -3, -1, 1, -3, -3, 1, 1, -3, 3, -1, -1, -3, 1, 3, 1, -1, -3, -1, -3, 1, -3, -3, -3, -3, +/* 6 */ -3, 3, 1, 3, -1, 1, -3, 1, -3, 1, -1, -3, -1, -3, -3, -3, -3, -1, -1, -1, 1, 1, -3, -3, +/* 7 */ -3, 1, 3, -1, 1, -1, 3, -3, 3, -1, -3, -1, -3, 3, -1, -1, -1, -3, -1, -1, -3, 3, 3, -3, +/* 8 */ -3, 1, -3, 3, -1, -1, -1, -3, 3, 1, -1, -3, -1, 1, 3, -1, 1, -1, 1, -3, -3, -3, -3, -3, +/* 9 */ 1, 1, -1, -3, -1, 1, 1, -3, 1, -1, 1, -3, 3, -3, -3, 3, -1, -3, 1, 3, -3, 1, -3, -3, +/* 10 */ -3, -3, -3, -1, 3, -3, 3, 1, 3, 1, -3, -1, -1, -3, 1, 1, 3, 1, -1, -3, 3, 1, 3, -3, +/* 11 */ -3, 3, -1, 3, 1, -1, -1, -1, 3, 3, 1, 1, 1, 3, 3, 1, -3, -3, -1, 1, -3, 1, 3, -3, +/* 12 */ 3, -3, 3, -1, -3, 1, 3, 1, -1, -1, -3, -1, 3, -3, 3, -1, -1, 3, 3, -3, -3, 3, -3, -3, +/* 13 */ -3, 3, -1, 3, -1, 3, 3, 1, 1, -3, 1, 3, -3, 3, -3, -3, -1, 1, 3, -3, -1, -1, -3, -3, +/* 14 */ -3, 1, -3, -1, -1, 3, 1, 3, -3, 1, -1, 3, 3, -1, -3, 3, -3, -1, -1, -3, -3, -3, 3, -3, +/* 15 */ -3, -1, -1, -3, 1, -3, -3, -1, -1, 3, -1, 1, -1, 3, 1, -3, -1, 3, 1, 1, -1, -1, -3, -3, +/* 16 */ -3, -3, 1, -1, 3, 3, -3, -1, 1, -1, -1, 1, 1, -1, -1, 3, -3, 1, -3, 1, -1, -1, -1, -3, +/* 17 */ 3, -1, 3, -1, 1, -3, 1, 1, -3, -3, 3, -3, -1, -1, -1, -1, -1, -3, -3, -1, 1, 1, -3, -3, +/* 18 */ 3, 1, -3, 1, -3, -3, 1, -3, 1, -3, -3, -3, -3, -3, 1, -3, -3, 1, 1, -3, 1, 1, -3, -3, +/* 19 */ -3, -3, 3, 3, 1, -1, -1, -1, 1, -3, -1, 1, -1, 3, -3, -1, -3, -1, -1, 1, -3, 3, -1, -3, +/* 20 */ -3, -3, -1, -1, -1, -3, 1, -1, -3, -1, 3, -3, 1, -3, 3, -3, 3, 3, 1, -1, -1, 1, -3, -3, +/* 21 */ 3, -1, 1, -1, 3, -3, 1, 1, 3, -1, -3, 3, 1, -3, 3, -1, -1, -1, -1, 1, -3, -3, -3, -3, +/* 22 */ -3, 1, -3, 3, -3, 1, -3, 3, 1, -1, -3, -1, -3, -3, -3, -3, 1, 3, -1, 1, 3, 3, 3, -3, +/* 23 */ -3, -1, 1, -3, -1, -1, 1, 1, 1, 3, 3, -1, 1, -1, 1, -1, -1, -3, -3, -3, 3, 1, -1, -3, +/* 24 */ -3, 3, -1, -3, -1, -1, -1, 3, -1, -1, 3, -3, -1, 3, -3, 3, -3, -1, 3, 1, 1, -1, -3, -3, +/* 25 */ -3, 1, -1, -3, -3, -1, 1, -3, -1, -3, 1, 1, -1, 1, 1, 3, 3, 3, -1, 1, -1, 1, -1, -3, +/* 26 */ -1, 3, -1, -1, 3, 3, -1, -1, -1, 3, -1, -3, 1, 3, 1, 1, -3, -3, -3, -1, -3, -1, -3, -3, +/* 27 */ 3, -3, -3, -1, 3, 3, -3, -1, 3, 1, 1, 1, 3, -1, 3, -3, -1, 3, -1, 3, 1, -1, -3, -3, +/* 28 */ -3, 1, -3, 1, -3, 1, 1, 3, 1, -3, -3, -1, 1, 3, -1, -3, 3, 1, -1, -3, -3, -3, -3, -3, +/* 29 */ 3, -3, -1, 1, 3, -1, -1, -3, -1, 3, -1, -3, -1, -3, 3, -1, 3, 1, 1, -3, 3, -3, -3, -3, } #endif ; diff --git a/openair1/PHY/NR_TRANSPORT/nr_csi_rs.c b/openair1/PHY/NR_TRANSPORT/nr_csi_rs.c index ac0eac8a79c32683ba95053da38336183f95727f..4f5baacc34e0fc1c8af47aeff418882a5132ea96 100644 --- a/openair1/PHY/NR_TRANSPORT/nr_csi_rs.c +++ b/openair1/PHY/NR_TRANSPORT/nr_csi_rs.c @@ -35,7 +35,7 @@ void nr_generate_csi_rs(PHY_VARS_gNB *gNB, NR_DL_FRAME_PARMS frame_parms=gNB->frame_parms; int32_t **txdataF = gNB->common_vars.txdataF; - int txdataF_offset = (slot%2)*frame_parms.samples_per_slot_wCP; + int txdataF_offset = slot*frame_parms.samples_per_slot_wCP; uint32_t **gold_csi_rs = gNB->nr_gold_csi_rs[slot]; int16_t mod_csi[frame_parms.symbols_per_slot][NR_MAX_CSI_RS_LENGTH>>1] __attribute__((aligned(16)));; uint16_t b = csi_params.freq_domain; diff --git a/openair1/PHY/NR_TRANSPORT/nr_dci.c b/openair1/PHY/NR_TRANSPORT/nr_dci.c index 3dd44a7896145639afc4e89678ad69517651979c..d233eb9ba6a89f38190c8d84bb1150704341c6d4 100644 --- a/openair1/PHY/NR_TRANSPORT/nr_dci.c +++ b/openair1/PHY/NR_TRANSPORT/nr_dci.c @@ -66,12 +66,11 @@ void nr_pdcch_scrambling(uint32_t *in, } } -void nr_generate_dci(PHY_VARS_gNB *gNB, - nfapi_nr_dl_tti_pdcch_pdu_rel15_t *pdcch_pdu_rel15, - uint32_t **gold_pdcch_dmrs, - int32_t *txdataF, - int16_t amp, - NR_DL_FRAME_PARMS *frame_parms) { +void nr_generate_dci(nfapi_nr_dl_tti_pdcch_pdu_rel15_t *pdcch_pdu_rel15, + uint32_t **gold_pdcch_dmrs, + int32_t *txdataF, + int16_t amp, + NR_DL_FRAME_PARMS *frame_parms) { int16_t mod_dmrs[NR_MAX_CSET_DURATION][NR_MAX_PDCCH_DMRS_LENGTH>>1] __attribute__((aligned(16))); // 3 for the max coreset duration uint16_t cset_start_sc; @@ -84,7 +83,8 @@ void nr_generate_dci(PHY_VARS_gNB *gNB, int n_rb; // compute rb_offset and n_prb based on frequency allocation - nr_fill_cce_list(gNB,0,pdcch_pdu_rel15); + nr_cce_t cce_list[MAX_DCI_CORESET][NR_MAX_PDCCH_AGG_LEVEL]; + nr_fill_cce_list(cce_list,0,pdcch_pdu_rel15); get_coreset_rballoc(pdcch_pdu_rel15->FreqDomainResource,&n_rb,&rb_offset); cset_start_sc = frame_parms->first_carrier_offset + (pdcch_pdu_rel15->BWPStart + rb_offset) * NR_NB_SC_PER_RB; @@ -135,8 +135,8 @@ void nr_generate_dci(PHY_VARS_gNB *gNB, dci_pdu->AggregationLevel, 0,NULL); polar_encoder_fast((uint64_t*)dci_pdu->Payload, (void*)encoder_output, n_RNTI,1,currentPtr); -#if DEBUG_CHANNEL_CODING - printf("polar rnti %x,length %d, L %d\n",n_RNTI, dci_pdu->PayloadSizeBits,dci_pdu->AggregationLevel); +#ifdef DEBUG_CHANNEL_CODING + printf("polar rnti %x,length %d, L %d\n",n_RNTI, dci_pdu->PayloadSizeBits,pdcch_pdu_rel15->dci_pdu->AggregationLevel); printf("DCI PDU: [0]->0x%lx \t [1]->0x%lx\n", ((uint64_t*)dci_pdu->Payload)[0], ((uint64_t*)dci_pdu->Payload)[1]); printf("Encoded Payload (length:%d dwords):\n", encoded_length>>5); @@ -175,7 +175,7 @@ void nr_generate_dci(PHY_VARS_gNB *gNB, int reg_list_order[NR_MAX_PDCCH_AGG_LEVEL] = {}; for (int p = 0; p < NR_MAX_PDCCH_AGG_LEVEL; p++) { for(int p2 = 0; p2 < dci_pdu->AggregationLevel; p2++) { - if(gNB->cce_list[d][p2].reg_list[0].reg_idx == p * NR_NB_REG_PER_CCE) { + if(cce_list[d][p2].reg_list[0].reg_idx == p * NR_NB_REG_PER_CCE) { reg_list_order[reg_list_index] = p2; reg_list_index++; break; @@ -191,7 +191,7 @@ void nr_generate_dci(PHY_VARS_gNB *gNB, for (int reg_in_cce_idx = 0; reg_in_cce_idx < NR_NB_REG_PER_CCE; reg_in_cce_idx++) { - k = cset_start_sc + gNB->cce_list[d][cce_idx].reg_list[reg_in_cce_idx].start_sc_idx; + k = cset_start_sc + cce_list[d][cce_idx].reg_list[reg_in_cce_idx].start_sc_idx; if (k >= frame_parms->ofdm_symbol_size) k -= frame_parms->ofdm_symbol_size; @@ -200,9 +200,9 @@ void nr_generate_dci(PHY_VARS_gNB *gNB, // dmrs index depends on reference point for k according to 38.211 7.4.1.3.2 if (pdcch_pdu_rel15->CoreSetType == NFAPI_NR_CSET_CONFIG_PDCCH_CONFIG) - dmrs_idx = (gNB->cce_list[d][cce_idx].reg_list[reg_in_cce_idx].reg_idx) * 3; + dmrs_idx = (cce_list[d][cce_idx].reg_list[reg_in_cce_idx].reg_idx) * 3; else - dmrs_idx = (gNB->cce_list[d][cce_idx].reg_list[reg_in_cce_idx].reg_idx + rb_offset) * 3; + dmrs_idx = (cce_list[d][cce_idx].reg_list[reg_in_cce_idx].reg_idx + rb_offset) * 3; k_prime = 0; @@ -250,21 +250,16 @@ void nr_generate_dci(PHY_VARS_gNB *gNB, } // for (int d=0;d<pdcch_pdu_rel15->numDlDci;d++) } -void nr_generate_dci_top(PHY_VARS_gNB *gNB, - nfapi_nr_dl_tti_pdcch_pdu *pdcch_pdu, - nfapi_nr_dl_tti_pdcch_pdu *ul_dci_pdu, - uint32_t **gold_pdcch_dmrs, - int32_t *txdataF, - int16_t amp, - NR_DL_FRAME_PARMS *frame_parms) { +void nr_generate_dci_top(processingData_L1tx_t *msgTx, + uint32_t **gold_pdcch_dmrs, + int32_t *txdataF, + int16_t amp, + NR_DL_FRAME_PARMS *frame_parms) { - AssertFatal(pdcch_pdu!=NULL || ul_dci_pdu!=NULL,"At least one pointer has to be !NULL\n"); + for (int i=0; i<msgTx->num_ul_pdcch; i++) + nr_generate_dci(&msgTx->ul_pdcch_pdu[i].pdcch_pdu.pdcch_pdu_rel15,gold_pdcch_dmrs,txdataF,amp,frame_parms); + for (int i=0; i<msgTx->num_dl_pdcch; i++) + nr_generate_dci(&msgTx->pdcch_pdu[i].pdcch_pdu_rel15,gold_pdcch_dmrs,txdataF,amp,frame_parms); - if (pdcch_pdu) { - nr_generate_dci(gNB,&pdcch_pdu->pdcch_pdu_rel15,gold_pdcch_dmrs,txdataF,amp,frame_parms); - } - if (ul_dci_pdu) { - nr_generate_dci(gNB,&ul_dci_pdu->pdcch_pdu_rel15,gold_pdcch_dmrs,txdataF,amp,frame_parms); - } } diff --git a/openair1/PHY/NR_TRANSPORT/nr_dci.h b/openair1/PHY/NR_TRANSPORT/nr_dci.h index 07baaf2728f8b02d163623fa664694d2a36d6c51..bdc8509d12a2768b033370bede1b0da97b589c90 100644 --- a/openair1/PHY/NR_TRANSPORT/nr_dci.h +++ b/openair1/PHY/NR_TRANSPORT/nr_dci.h @@ -29,13 +29,11 @@ uint16_t nr_get_dci_size(nfapi_nr_dci_format_e format, nfapi_nr_rnti_type_e rnti_type, uint16_t N_RB); -void nr_generate_dci_top(PHY_VARS_gNB *gNB, - nfapi_nr_dl_tti_pdcch_pdu *pdcch_pdu, - nfapi_nr_dl_tti_pdcch_pdu *ul_pdcch_pdu, - uint32_t **gold_pdcch_dmrs, - int32_t *txdataF, - int16_t amp, - NR_DL_FRAME_PARMS *frame_parms); +void nr_generate_dci_top(processingData_L1tx_t *msgTx, + uint32_t **gold_pdcch_dmrs, + int32_t *txdataF, + int16_t amp, + NR_DL_FRAME_PARMS *frame_parms); void nr_pdcch_scrambling(uint32_t *in, uint32_t size, @@ -57,6 +55,6 @@ void nr_fill_ul_dci(PHY_VARS_gNB *gNB, int slot, nfapi_nr_ul_dci_request_pdus_t *pdcch_pdu); -void nr_fill_cce_list(PHY_VARS_gNB *gNB, uint8_t m,nfapi_nr_dl_tti_pdcch_pdu_rel15_t *); +void nr_fill_cce_list(nr_cce_t cce_list[MAX_DCI_CORESET][NR_MAX_PDCCH_AGG_LEVEL], uint8_t m,nfapi_nr_dl_tti_pdcch_pdu_rel15_t *pdcch_pdu_rel15); #endif //__PHY_NR_TRANSPORT_DCI__H diff --git a/openair1/PHY/NR_TRANSPORT/nr_dci_tools.c b/openair1/PHY/NR_TRANSPORT/nr_dci_tools.c index 167504544355c042c1290c0b586077aa20f7bcfb..8d5eb4a66072ca56684ebee75c12cc2f69c07a47 100644 --- a/openair1/PHY/NR_TRANSPORT/nr_dci_tools.c +++ b/openair1/PHY/NR_TRANSPORT/nr_dci_tools.c @@ -119,7 +119,7 @@ void nr_fill_cce_list(PHY_VARS_gNB *gNB, uint16_t n_shift, uint8_t m) { */ -void nr_fill_cce_list(PHY_VARS_gNB *gNB, uint8_t m, nfapi_nr_dl_tti_pdcch_pdu_rel15_t *pdcch_pdu_rel15) { +void nr_fill_cce_list(nr_cce_t cce_list[MAX_DCI_CORESET][NR_MAX_PDCCH_AGG_LEVEL], uint8_t m, nfapi_nr_dl_tti_pdcch_pdu_rel15_t *pdcch_pdu_rel15) { nr_cce_t* cce; nr_reg_t* reg; @@ -156,7 +156,7 @@ void nr_fill_cce_list(PHY_VARS_gNB *gNB, uint8_t m, nfapi_nr_dl_tti_pdcch_pdu_r if (pdcch_pdu_rel15->dci_pdu[d].RNTI != 0xFFFF) LOG_D(PHY, "CCE list generation for candidate %d: bundle size %d ilv size %d CceIndex %d\n", m, bsize, R, pdcch_pdu_rel15->dci_pdu[d].CceIndex); for (uint8_t cce_idx=0; cce_idx<L; cce_idx++) { - cce = &gNB->cce_list[d][cce_idx]; + cce = &cce_list[d][cce_idx]; cce->cce_idx = pdcch_pdu_rel15->dci_pdu[d].CceIndex + cce_idx; LOG_D(PHY, "cce_idx %d\n", cce->cce_idx); diff --git a/openair1/PHY/NR_TRANSPORT/nr_dlsch.c b/openair1/PHY/NR_TRANSPORT/nr_dlsch.c index 00cc968b87151117893a518773e14af875ea664e..c6c89c80be9d415c8181cf32211b16009cb7e7e4 100644 --- a/openair1/PHY/NR_TRANSPORT/nr_dlsch.c +++ b/openair1/PHY/NR_TRANSPORT/nr_dlsch.c @@ -47,70 +47,11 @@ void nr_pdsch_codeword_scrambling(uint8_t *in, uint8_t q, uint32_t Nid, uint32_t n_RNTI, - uint32_t* out) { - - uint8_t reset, b_idx; - uint32_t x1, x2, s=0; - VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_gNB_PDSCH_CODEWORD_SCRAMBLING, 1); - reset = 1; - x2 = (n_RNTI<<15) + (q<<14) + Nid; - - for (int i=0; i<size; i++) { - b_idx = i&0x1f; - if (b_idx==0) { - s = lte_gold_generic(&x1, &x2, reset); - reset = 0; - if (i) - out++; - } - *out ^= (((in[i])&1) ^ ((s>>b_idx)&1))<<b_idx; - //printf("i %d b_idx %d in %d s 0x%08x out 0x%08x\n", i, b_idx, in[i], s, *out); - } - VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_gNB_PDSCH_CODEWORD_SCRAMBLING, 0); + uint32_t* out) +{ + nr_codeword_scrambling(in, size, q, Nid, n_RNTI, out); } -void nr_pdsch_codeword_scrambling_optim(uint8_t *in, - uint32_t size, - uint8_t q, - uint32_t Nid, - uint32_t n_RNTI, - uint32_t* out) { - - uint32_t x1, x2, s=0,in32; - - x2 = (n_RNTI<<15) + (q<<14) + Nid; - - s=lte_gold_generic(&x1, &x2, 1); - -#if defined(__AVX2__) - for (int i=0; i<((size>>5)+((size&0x1f) > 0 ? 1 : 0)); i++) { - in32=_mm256_movemask_epi8(_mm256_slli_epi16(((__m256i*)in)[i],7)); - out[i]=(in32^s); - //printf("in[%d] %x => %x\n",i,in32,out[i]); - s=lte_gold_generic(&x1, &x2, 0); - } -#elif defined(__SSE4__) - _m128i *in128; - for (int i=0; i<((size>>5)+((size&0x1f) > 0 ? 1 : 0)); i++) { - in128=&((__m128i*)in)[i<<1]; - ((uint16_t*)&in32)[0] = _mm128_movemask_epi8(_mm256_slli_epi16(in128[0],7)); - ((uint16_t*)&in32)[1] = _mm128_movemask_epi8(_mm256_slli_epi16(in128[1],7)); - out[i]=(in32^s); - s=lte_gold_generic(&x1, &x2, 0); - } - //#elsif defined(__arm__) || defined(__aarch64) - -#else - nr_pdsch_codeword_scrambling(in, - size, - q, - Nid, - n_RNTI, - out); -#endif -} - - void nr_generate_pdsch(processingData_L1tx_t *msgTx, int frame, int slot) { @@ -214,12 +155,12 @@ void nr_generate_pdsch(processingData_L1tx_t *msgTx, for (int q=0; q<rel15->NrOfCodewords; q++) memset((void*)scrambled_output[q], 0, (encoded_length>>5)*sizeof(uint32_t)); for (int q=0; q<rel15->NrOfCodewords; q++) - nr_pdsch_codeword_scrambling_optim(output, - encoded_length, - q, - rel15->dataScramblingId, - rel15->rnti, - scrambled_output[q]); + nr_pdsch_codeword_scrambling(output, + encoded_length, + q, + rel15->dataScramblingId, + rel15->rnti, + scrambled_output[q]); stop_meas(dlsch_scrambling_stats); #ifdef DEBUG_DLSCH @@ -277,7 +218,7 @@ void nr_generate_pdsch(processingData_L1tx_t *msgTx, if (start_sc >= frame_parms->ofdm_symbol_size) start_sc -= frame_parms->ofdm_symbol_size; - int txdataF_offset = (slot%2)*frame_parms->samples_per_slot_wCP; + int txdataF_offset = slot*frame_parms->samples_per_slot_wCP; #ifdef DEBUG_DLSCH_MAPPING printf("PDSCH resource mapping started (start SC %d\tstart symbol %d\tN_PRB %d\tnb_re %d,nb_layers %d)\n", @@ -352,6 +293,7 @@ void nr_generate_pdsch(processingData_L1tx_t *msgTx, ptrs_symbol = is_ptrs_symbol(l,dlPtrsSymPos); if(ptrs_symbol) { /* PTRS QPSK Modulation for each OFDM symbol in a slot */ + printf("Doing ptrs modulation for symbol %d, n_ptrs %d\n",l,n_ptrs); nr_modulation(pdsch_dmrs[l][0], (n_ptrs<<1), DMRS_MOD_ORDER, mod_ptrs); } } @@ -375,12 +317,12 @@ void nr_generate_pdsch(processingData_L1tx_t *msgTx, /* Map DMRS Symbol */ if ( (dmrs_symbol_map & (1 << l)) && (k == ((start_sc+get_dmrs_freq_idx(n, k_prime, delta, dmrs_Type))%(frame_parms->ofdm_symbol_size)))) { - txdataF_precoding[ap][((l*frame_parms->ofdm_symbol_size + k)<<1) + (2*txdataF_offset)] = (Wt[l_prime]*Wf[k_prime]*amp*mod_dmrs[dmrs_idx<<1]) >> 15; - txdataF_precoding[ap][((l*frame_parms->ofdm_symbol_size + k)<<1) + 1 + (2*txdataF_offset)] = (Wt[l_prime]*Wf[k_prime]*amp*mod_dmrs[(dmrs_idx<<1) + 1]) >> 15; + txdataF_precoding[ap][((l*frame_parms->ofdm_symbol_size + k)<<1) ] = (Wt[l_prime]*Wf[k_prime]*amp*mod_dmrs[dmrs_idx<<1]) >> 15; + txdataF_precoding[ap][((l*frame_parms->ofdm_symbol_size + k)<<1) + 1 ] = (Wt[l_prime]*Wf[k_prime]*amp*mod_dmrs[(dmrs_idx<<1) + 1]) >> 15; #ifdef DEBUG_DLSCH_MAPPING printf("dmrs_idx %d\t l %d \t k %d \t k_prime %d \t n %d \t txdataF: %d %d\n", - dmrs_idx, l, k, k_prime, n, txdataF_precoding[ap][((l*frame_parms->ofdm_symbol_size + k)<<1) + (2*txdataF_offset)], - txdataF_precoding[ap][((l*frame_parms->ofdm_symbol_size + k)<<1) + 1 + (2*txdataF_offset)]); + dmrs_idx, l, k, k_prime, n, txdataF_precoding[ap][((l*frame_parms->ofdm_symbol_size + k)<<1)], + txdataF_precoding[ap][((l*frame_parms->ofdm_symbol_size + k)<<1) + 1]); #endif dmrs_idx++; k_prime++; @@ -388,30 +330,30 @@ void nr_generate_pdsch(processingData_L1tx_t *msgTx, n+=(k_prime)?0:1; } else if(is_ptrs_re){ - txdataF_precoding[ap][((l*frame_parms->ofdm_symbol_size + k)<<1) + (2*txdataF_offset)] = (beta_ptrs*amp*mod_ptrs[ptrs_idx<<1]) >> 15; - txdataF_precoding[ap][((l*frame_parms->ofdm_symbol_size + k)<<1) + 1 + (2*txdataF_offset)] = (beta_ptrs*amp*mod_ptrs[(ptrs_idx<<1) + 1])>> 15; + txdataF_precoding[ap][((l*frame_parms->ofdm_symbol_size + k)<<1) ] = (beta_ptrs*amp*mod_ptrs[ptrs_idx<<1]) >> 15; + txdataF_precoding[ap][((l*frame_parms->ofdm_symbol_size + k)<<1) + 1] = (beta_ptrs*amp*mod_ptrs[(ptrs_idx<<1) + 1])>> 15; #ifdef DEBUG_DLSCH_MAPPING - printf("ptrs_idx %d\t l %d \t k %d \t k_prime %d \t n %d \t txdataF: %d %d\n", + printf("ptrs_idx %d\t l %d \t k %d \t k_prime %d \t n %d \t txdataF: %d %d, mod_ptrs: %d %d\n", ptrs_idx, l, k, k_prime, n, ((int16_t*)txdataF[ap])[((l*frame_parms->ofdm_symbol_size + k)<<1) + (2*txdataF_offset)], - ((int16_t*)txdataF[ap])[((l*frame_parms->ofdm_symbol_size + k)<<1) + 1 + (2*txdataF_offset)]); + ((int16_t*)txdataF[ap])[((l*frame_parms->ofdm_symbol_size + k)<<1) + 1 + (2*txdataF_offset)],mod_ptrs[ptrs_idx<<1],mod_ptrs[(ptrs_idx<<1)+1]); #endif ptrs_idx++; } /* Map DATA Symbol */ - else if( allowed_xlsch_re_in_dmrs_symbol(k,start_sc,frame_parms->ofdm_symbol_size,rel15->numDmrsCdmGrpsNoData,dmrs_Type)) { - txdataF_precoding[ap][((l*frame_parms->ofdm_symbol_size + k)<<1) + (2*txdataF_offset)] = (amp * tx_layers[ap][m<<1]) >> 15; - txdataF_precoding[ap][((l*frame_parms->ofdm_symbol_size + k)<<1) + 1 + (2*txdataF_offset)] = (amp * tx_layers[ap][(m<<1) + 1]) >> 15; + else if( ptrs_symbol || allowed_xlsch_re_in_dmrs_symbol(k,start_sc,frame_parms->ofdm_symbol_size,rel15->numDmrsCdmGrpsNoData,dmrs_Type)) { + txdataF_precoding[ap][((l*frame_parms->ofdm_symbol_size + k)<<1) ] = (amp * tx_layers[ap][m<<1]) >> 15; + txdataF_precoding[ap][((l*frame_parms->ofdm_symbol_size + k)<<1) + 1] = (amp * tx_layers[ap][(m<<1) + 1]) >> 15; #ifdef DEBUG_DLSCH_MAPPING printf("m %d\t l %d \t k %d \t txdataF: %d %d\n", - m, l, k, txdataF_precoding[ap][((l*frame_parms->ofdm_symbol_size + k)<<1) + (2*txdataF_offset)], - txdataF_precoding[ap][((l*frame_parms->ofdm_symbol_size + k)<<1) + 1 + (2*txdataF_offset)]); + m, l, k, txdataF_precoding[ap][((l*frame_parms->ofdm_symbol_size + k)<<1)], + txdataF_precoding[ap][((l*frame_parms->ofdm_symbol_size + k)<<1) + 1]); #endif m++; } /* mute RE */ else { - txdataF_precoding[ap][((l*frame_parms->ofdm_symbol_size + k)<<1) + (2*txdataF_offset)] = 0; - txdataF_precoding[ap][((l*frame_parms->ofdm_symbol_size + k)<<1) + 1 + (2*txdataF_offset)] = 0; + txdataF_precoding[ap][((l*frame_parms->ofdm_symbol_size + k)<<1) ] = 0; + txdataF_precoding[ap][((l*frame_parms->ofdm_symbol_size + k)<<1) + 1] = 0; } if (++k >= frame_parms->ofdm_symbol_size) k -= frame_parms->ofdm_symbol_size; @@ -425,8 +367,9 @@ void nr_generate_pdsch(processingData_L1tx_t *msgTx, remaining_re = upper_limit + start_sc - frame_parms->ofdm_symbol_size; upper_limit = frame_parms->ofdm_symbol_size - start_sc; } + // fix the alignment issues later, use 64-bit SIMD below instead of 128. if (0/*(frame_parms->N_RB_DL&1)==0*/) { - __m128i *txF=(__m128i*)&txdataF_precoding[ap][((l*frame_parms->ofdm_symbol_size+start_sc+txdataF_offset)<<1)]; + __m128i *txF=(__m128i*)&txdataF_precoding[ap][((l*frame_parms->ofdm_symbol_size+start_sc)<<1)]; __m128i *txl = (__m128i*)&tx_layers[ap][m<<1]; __m128i amp128=_mm_set1_epi16(amp); @@ -435,7 +378,7 @@ void nr_generate_pdsch(processingData_L1tx_t *msgTx, } //RE loop, first part m+=upper_limit; if (remaining_re > 0) { - txF = (__m128i*)&txdataF_precoding[ap][((l*frame_parms->ofdm_symbol_size+txdataF_offset)<<1)]; + txF = (__m128i*)&txdataF_precoding[ap][((l*frame_parms->ofdm_symbol_size)<<1)]; txl = (__m128i*)&tx_layers[ap][m<<1]; for (int i=0; i<(remaining_re>>2); i++) { txF[i] = _mm_mulhrs_epi16(amp128,txl[i]); @@ -443,7 +386,7 @@ void nr_generate_pdsch(processingData_L1tx_t *msgTx, } } else { - __m64 *txF=(__m64*)&txdataF_precoding[ap][((l*frame_parms->ofdm_symbol_size+start_sc+txdataF_offset)<<1)]; + __m64 *txF=(__m64*)&txdataF_precoding[ap][((l*frame_parms->ofdm_symbol_size+start_sc)<<1)]; __m64 *txl = (__m64*)&tx_layers[ap][m<<1]; __m64 amp64=_mm_set1_pi16(amp); @@ -453,31 +396,31 @@ void nr_generate_pdsch(processingData_L1tx_t *msgTx, #ifdef DEBUG_DLSCH_MAPPING if ((i&1) > 0) printf("m %d\t l %d \t k %d \t txdataF: %d %d\n", - m, l, start_sc+(i>>1), txdataF_precoding[ap][((l*frame_parms->ofdm_symbol_size + start_sc+(i>>1))<<1) + (2*txdataF_offset)], - txdataF_precoding[ap][((l*frame_parms->ofdm_symbol_size + start_sc+(i>>1))<<1) + 1 + (2*txdataF_offset)]); + m, l, start_sc+(i>>1), txdataF_precoding[ap][((l*frame_parms->ofdm_symbol_size + start_sc+(i>>1))<<1)], + txdataF_precoding[ap][((l*frame_parms->ofdm_symbol_size + start_sc+(i>>1))<<1) + 1]); #endif /* handle this, mute RE */ /*else { - txdataF_precoding[ap][((l*frame_parms->ofdm_symbol_size + k)<<1) + (2*txdataF_offset)] = 0; - txdataF_precoding[ap][((l*frame_parms->ofdm_symbol_size + k)<<1) + 1 + (2*txdataF_offset)] = 0; + txdataF_precoding[ap][((l*frame_parms->ofdm_symbol_size + k)<<1) ] = 0; + txdataF_precoding[ap][((l*frame_parms->ofdm_symbol_size + k)<<1) + 1] = 0; }*/ } //RE loop, first part m+=upper_limit; if (remaining_re > 0) { - txF = (__m64*)&txdataF_precoding[ap][((l*frame_parms->ofdm_symbol_size+txdataF_offset)<<1)]; + txF = (__m64*)&txdataF_precoding[ap][((l*frame_parms->ofdm_symbol_size)<<1)]; txl = (__m64*)&tx_layers[ap][m<<1]; for (int i=0; i<(remaining_re>>1); i++) { txF[i] = _mm_mulhrs_pi16(amp64,txl[i]); #ifdef DEBUG_DLSCH_MAPPING if ((i&1) > 0) printf("m %d\t l %d \t k %d \t txdataF: %d %d\n", - m, l, i>>1, txdataF_precoding[ap][((l*frame_parms->ofdm_symbol_size + (i>>1))<<1) + (2*txdataF_offset)], - txdataF_precoding[ap][((l*frame_parms->ofdm_symbol_size + (i>>1))<<1) + 1 + (2*txdataF_offset)]); + m, l, i>>1, txdataF_precoding[ap][((l*frame_parms->ofdm_symbol_size + (i>>1))<<1) ], + txdataF_precoding[ap][((l*frame_parms->ofdm_symbol_size + (i>>1))<<1) + 1]); #endif /* handle this, mute RE */ /*else { - txdataF_precoding[ap][((l*frame_parms->ofdm_symbol_size + k)<<1) + (2*txdataF_offset)] = 0; - txdataF_precoding[ap][((l*frame_parms->ofdm_symbol_size + k)<<1) + 1 + (2*txdataF_offset)] = 0; + txdataF_precoding[ap][((l*frame_parms->ofdm_symbol_size + k)<<1) ] = 0; + txdataF_precoding[ap][((l*frame_parms->ofdm_symbol_size + k)<<1) + 1] = 0; }*/ } //RE loop, second part } // @@ -514,7 +457,7 @@ void nr_generate_pdsch(processingData_L1tx_t *msgTx, if (pmi == 0) {//unitary Precoding if(ap<rel15->nrOfLayers) memcpy((void*)&txdataF[ap][l*frame_parms->ofdm_symbol_size + txdataF_offset + k], - (void*)&txdataF_precoding[ap][2*(l*frame_parms->ofdm_symbol_size + txdataF_offset+ k)], + (void*)&txdataF_precoding[ap][2*(l*frame_parms->ofdm_symbol_size + k)], NR_NB_SC_PER_RB*sizeof(int32_t)); else memset((void*)&txdataF[ap][l*frame_parms->ofdm_symbol_size + txdataF_offset + k], @@ -555,7 +498,7 @@ void nr_generate_pdsch(processingData_L1tx_t *msgTx, } for (int i=0; i<NR_NB_SC_PER_RB; i++) { int32_t re_offset = l*frame_parms->ofdm_symbol_size + k; - int32_t precodatatx_F = nr_layer_precoder(txdataF_precoding, W_prec, rel15->nrOfLayers, re_offset+txdataF_offset); + int32_t precodatatx_F = nr_layer_precoder(txdataF_precoding, W_prec, rel15->nrOfLayers, re_offset); ((int16_t*)txdataF[ap])[(re_offset<<1) + (2*txdataF_offset)] = ((int16_t *) &precodatatx_F)[0]; ((int16_t*)txdataF[ap])[(re_offset<<1) + 1 + (2*txdataF_offset)] = ((int16_t *) &precodatatx_F)[1]; #ifdef DEBUG_DLSCH_MAPPING diff --git a/openair1/PHY/NR_TRANSPORT/nr_dlsch.h b/openair1/PHY/NR_TRANSPORT/nr_dlsch.h index 578053fd91bdb1e66b1c4680c5e47ee07efaf857..77db12672f33952564a0c791fdb09d4a40221b40 100644 --- a/openair1/PHY/NR_TRANSPORT/nr_dlsch.h +++ b/openair1/PHY/NR_TRANSPORT/nr_dlsch.h @@ -43,8 +43,6 @@ void nr_check_time_alloc(uint8_t S, uint8_t L,nfapi_nr_dl_tti_pdsch_pdu_rel15_t uint16_t get_RIV(uint16_t rb_start, uint16_t L, uint16_t N_RB); -uint16_t get_SLIV(uint8_t S, uint8_t L); - uint8_t nr_get_S(uint8_t row_idx, uint8_t CP, uint8_t time_alloc_type, uint8_t dmrs_typeA_position); void nr_get_rbg_parms(NR_BWP_PARMS* bwp, uint8_t config_type); diff --git a/openair1/PHY/NR_TRANSPORT/nr_dlsch_coding.c b/openair1/PHY/NR_TRANSPORT/nr_dlsch_coding.c index 9f5f800031ec2fa8c04a335f887c902009367cd9..6d16fa531c96f905abf93f7ba574207ad3aff017 100644 --- a/openair1/PHY/NR_TRANSPORT/nr_dlsch_coding.c +++ b/openair1/PHY/NR_TRANSPORT/nr_dlsch_coding.c @@ -108,7 +108,7 @@ NR_gNB_DLSCH_t *new_gNB_dlsch(NR_DL_FRAME_PARMS *frame_parms, a_segments = a_segments/273 +1; } - uint16_t dlsch_bytes = a_segments*1056; // allocated bytes per segment + uint32_t dlsch_bytes = a_segments*1056; // allocated bytes per segment NR_gNB_DLSCH_t *dlsch = malloc16(sizeof(NR_gNB_DLSCH_t)); AssertFatal(dlsch, "cannot allocate dlsch\n"); bzero(dlsch,sizeof(NR_gNB_DLSCH_t)); @@ -213,7 +213,7 @@ void ldpc8blocks( void *p) { for (int rr=impp->macro_num*8; rr < impp->n_segments && rr < (impp->macro_num+1)*8; rr++ ) { if (impp->F>0) { // writing into positions d[r][k-2Zc] as in clause 5.3.2 step 2) in 38.212 - memset(&impp->d[rr][Kr-impp->F-2*(*impp->Zc)], impp->F, NR_NULL); + memset(&impp->d[rr][Kr-impp->F-2*(*impp->Zc)], NR_NULL, impp->F); } #ifdef DEBUG_DLSCH_CODING @@ -266,6 +266,8 @@ void ldpc8blocks( void *p) { for (int i =0; i<16; i++) printf("output interleaving f[%d]= %d r_offset %u\n", i,impp->output[i+r_offset], r_offset); + if (r==impp->n_segments-1) + write_output("enc_output.m","enc",impp->output,G,1,4); #endif r_offset += E; @@ -292,8 +294,8 @@ int nr_dlsch_encoding(PHY_VARS_gNB *gNB, VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_gNB_DLSCH_ENCODING, VCD_FUNCTION_IN); uint32_t A = rel15->TBSize[0]<<3; - if ( dlsch->rnti != SI_RNTI ) - trace_NRpdu(DIRECTION_DOWNLINK, a, rel15->TBSize[0], 0, WS_C_RNTI, dlsch->rnti, frame, slot,0, 0); + if ( rel15->rnti != SI_RNTI) + trace_NRpdu(DIRECTION_DOWNLINK, a, rel15->TBSize[0], 0, WS_C_RNTI, rel15->rnti, frame, slot,0, 0); NR_gNB_SCH_STATS_t *stats=NULL; int first_free=-1; diff --git a/openair1/PHY/NR_TRANSPORT/nr_dlsch_tools.c b/openair1/PHY/NR_TRANSPORT/nr_dlsch_tools.c index 3ba13d2f44d10956512ce5aa9b7df32b1d15b975..2dc21af0c503d47908422105273d33859dd3e934 100644 --- a/openair1/PHY/NR_TRANSPORT/nr_dlsch_tools.c +++ b/openair1/PHY/NR_TRANSPORT/nr_dlsch_tools.c @@ -32,6 +32,7 @@ */ #include "nr_dlsch.h" +#include "../../../nfapi/oai_integration/vendor_ext.h" extern void set_taus_seed(unsigned int seed_type); @@ -96,11 +97,6 @@ void nr_get_time_domain_allocation_type(nfapi_nr_config_request_t config, } } - -uint16_t get_SLIV(uint8_t S, uint8_t L) { - return ( (uint16_t)(((L-1)<=7)? (14*(L-1)+S) : (14*(15-L)+(13-S))) ); -} - static inline uint8_t get_K0(uint8_t row_idx, uint8_t time_alloc_type) { return ( (time_alloc_type == NFAPI_NR_PDSCH_TIME_DOMAIN_ALLOC_TYPE_DEFAULT_A)|| (time_alloc_type == NFAPI_NR_PDSCH_TIME_DOMAIN_ALLOC_TYPE_DEFAULT_C)? 0 : diff --git a/openair1/PHY/NR_TRANSPORT/nr_pbch.c b/openair1/PHY/NR_TRANSPORT/nr_pbch.c index a4cec432de30d4b2805db685964b7dc7a52b137d..bf5edccb1bedccc6098d19d256bcd2b891cefdce 100644 --- a/openair1/PHY/NR_TRANSPORT/nr_pbch.c +++ b/openair1/PHY/NR_TRANSPORT/nr_pbch.c @@ -219,8 +219,7 @@ void nr_init_pbch_interleaver(uint8_t *interleaver) { *(interleaver+i) = *(nr_pbch_payload_interleaving_pattern+j_ssb++); } -int nr_generate_pbch(NR_gNB_PBCH *pbch, - nfapi_nr_dl_tti_ssb_pdu *ssb_pdu, +int nr_generate_pbch(nfapi_nr_dl_tti_ssb_pdu *ssb_pdu, uint8_t *interleaver, int32_t *txdataF, int16_t amp, @@ -239,6 +238,8 @@ int nr_generate_pbch(NR_gNB_PBCH *pbch, uint64_t a_reversed=0; LOG_D(PHY, "PBCH generation started\n"); ///Payload generation + NR_gNB_PBCH m_pbch; + NR_gNB_PBCH *pbch = &m_pbch; memset((void *)pbch, 0, sizeof(NR_gNB_PBCH)); pbch->pbch_a=0; uint8_t ssb_index = ssb_pdu->ssb_pdu_rel15.SsbBlockIndex; diff --git a/openair1/PHY/NR_TRANSPORT/nr_pss.c b/openair1/PHY/NR_TRANSPORT/nr_pss.c index 535ce991438c9ed3220cd7a94eb851ef019e39aa..8564efe3de0d4fd73a45fe1610b0f07938e2c6be 100644 --- a/openair1/PHY/NR_TRANSPORT/nr_pss.c +++ b/openair1/PHY/NR_TRANSPORT/nr_pss.c @@ -24,55 +24,47 @@ //#define NR_PSS_DEBUG -int nr_generate_pss( int16_t *d_pss, - int32_t *txdataF, +int nr_generate_pss( int32_t *txdataF, int16_t amp, uint8_t ssb_start_symbol, nfapi_nr_config_request_scf_t* config, NR_DL_FRAME_PARMS *frame_parms) { - int i,k,l,m; - int16_t a; int16_t x[NR_PSS_LENGTH]; const int x_initial[7] = {0, 1, 1 , 0, 1, 1, 1}; - uint8_t Nid2 = config->cell_config.phy_cell_id.value % 3; - /// Sequence generation - for (i=0; i < 7; i++) + for (int i=0; i < 7; i++) x[i] = x_initial[i]; - for (i=0; i < (NR_PSS_LENGTH - 7); i++) { + for (int i=0; i < (NR_PSS_LENGTH - 7); i++) { x[i+7] = (x[i + 4] + x[i]) %2; } - for (i=0; i < NR_PSS_LENGTH; i++) { - m = (i + 43*Nid2)%(NR_PSS_LENGTH); - d_pss[i] = (1 - 2*x[m]) * 23170; - } - #ifdef NR_PSS_DEBUG write_output("d_pss.m", "d_pss", (void*)d_pss, NR_PSS_LENGTH, 1, 0); printf("PSS: ofdm_symbol_size %d, first_carrier_offset %d\n",frame_parms->ofdm_symbol_size,frame_parms->first_carrier_offset); #endif /// Resource mapping - a = amp; - // PSS occupies a predefined position (subcarriers 56-182, symbol 0) within the SSB block starting from - k = frame_parms->first_carrier_offset + frame_parms->ssb_start_subcarrier + 56; //and - if (k>= frame_parms->ofdm_symbol_size) k-=frame_parms->ofdm_symbol_size; + // PSS occupies a predefined position (subcarriers 56-182, symbol 0) within the SSB block starting from + int k = frame_parms->first_carrier_offset + frame_parms->ssb_start_subcarrier + 56; //and + if (k>= frame_parms->ofdm_symbol_size) k-=frame_parms->ofdm_symbol_size; - l = ssb_start_symbol; + int l = ssb_start_symbol; - for (m = 0; m < NR_PSS_LENGTH; m++) { - // printf("pss: writing position k %d / %d\n",k,frame_parms->ofdm_symbol_size); - ((int16_t*)txdataF)[2*(l*frame_parms->ofdm_symbol_size + k)] = (a * d_pss[m]) >> 15; - k++; - - if (k >= frame_parms->ofdm_symbol_size) - k-=frame_parms->ofdm_symbol_size; - } + uint8_t Nid2 = config->cell_config.phy_cell_id.value % 3; + for (int i = 0; i < NR_PSS_LENGTH; i++) { + int m = (i + 43*Nid2)%(NR_PSS_LENGTH); + int16_t d_pss = (1 - 2*x[m]) * 23170; + // printf("pss: writing position k %d / %d\n",k,frame_parms->ofdm_symbol_size); + ((int16_t*)txdataF)[2*(l*frame_parms->ofdm_symbol_size + k)] = (((int16_t)amp) * d_pss) >> 15; + k++; + + if (k >= frame_parms->ofdm_symbol_size) + k-=frame_parms->ofdm_symbol_size; + } #ifdef NR_PSS_DEBUG LOG_M("pss_0.m", "pss_0", diff --git a/openair1/PHY/NR_TRANSPORT/nr_scrambling.c b/openair1/PHY/NR_TRANSPORT/nr_scrambling.c new file mode 100644 index 0000000000000000000000000000000000000000..b68ad2d89f9b86259bc613ba9fb315af140424f8 --- /dev/null +++ b/openair1/PHY/NR_TRANSPORT/nr_scrambling.c @@ -0,0 +1,107 @@ +/* + * 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 "nr_transport_common_proto.h" +#include "PHY/NR_REFSIG/nr_refsig.h" +#include "common/utils/LOG/vcd_signal_dumper.h" + +void nr_codeword_scrambling(uint8_t *in, + uint32_t size, + uint8_t q, + uint32_t Nid, + uint32_t n_RNTI, + uint32_t* out) +{ + uint32_t x1; + uint32_t x2 = (n_RNTI<<15) + (q<<14) + Nid; + uint32_t s = 0; + +#if defined(__AVX2__) + s=lte_gold_generic(&x1, &x2, 1); + for (int i=0; i<((size>>5)+((size&0x1f) > 0 ? 1 : 0)); i++) { + __m256i c = ((__m256i*)in)[i]; + uint32_t in32 = _mm256_movemask_epi8(_mm256_slli_epi16(c,7)); + out[i]=(in32^s); + //printf("in[%d] %x => %x\n",i,in32,out[i]); + s=lte_gold_generic(&x1, &x2, 0); + } +#elif defined(__SSE4__) + s=lte_gold_generic(&x1, &x2, 1); + __m128i *in128; + for (int i=0; i<((size>>5)+((size&0x1f) > 0 ? 1 : 0)); i++) { + in128=&((__m128i*)in)[i<<1]; + uint32_t in32; + ((uint16_t*)&in32)[0] = _mm_movemask_epi8(_mm_slli_epi16(in128[0],7)); + ((uint16_t*)&in32)[1] = _mm_movemask_epi8(_mm_slli_epi16(in128[1],7)); + out[i]=(in32^s); + s=lte_gold_generic(&x1, &x2, 0); + } +//#elsif defined(__arm__) || defined(__aarch64) +#else + uint8_t reset = 1; + + VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_gNB_PDSCH_CODEWORD_SCRAMBLING, 1); + for (int i = 0; i < size; i++) { + const uint8_t b_idx = i&0x1f; + if (b_idx==0) { + s = lte_gold_generic(&x1, &x2, reset); + reset = 0; + if (i) + out++; + } + *out ^= (((in[i])&1) ^ ((s>>b_idx)&1))<<b_idx; + //printf("i %d b_idx %d in %d s 0x%08x out 0x%08x\n", i, b_idx, in[i], s, *out); + } + VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_gNB_PDSCH_CODEWORD_SCRAMBLING, 0); +#endif +} + +void nr_codeword_unscrambling(int16_t* llr, uint32_t size, uint8_t q, uint32_t Nid, uint32_t n_RNTI) +{ + uint32_t x1; + uint32_t x2 = (n_RNTI << 15) + (q << 14) + Nid; + uint32_t s = 0; + +#if defined(__x86_64__) || defined(__i386__) + uint8_t *s8=(uint8_t *)&s; + __m128i *llr128 = (__m128i*)llr; + s = lte_gold_generic(&x1, &x2, 1); + + for (int i = 0, j = 0; i < ((size >> 5) + ((size & 0x1f) > 0 ? 1 : 0)); i++, j += 4) { + llr128[j] = _mm_mullo_epi16(llr128[j],byte2m128i[s8[0]]); + llr128[j+1] = _mm_mullo_epi16(llr128[j+1],byte2m128i[s8[1]]); + llr128[j+2] = _mm_mullo_epi16(llr128[j+2],byte2m128i[s8[2]]); + llr128[j+3] = _mm_mullo_epi16(llr128[j+3],byte2m128i[s8[3]]); + s = lte_gold_generic(&x1, &x2, 0); + } +#else + uint8_t reset = 1; + + for (uint32_t i=0; i<size; i++) { + if ((i&0x1f)==0) { + s = lte_gold_generic(&x1, &x2, reset); + reset = 0; + } + if (((s>>(i&0x1f))&1)==1) + llr[i] = -llr[i]; + } +#endif +} diff --git a/openair1/PHY/NR_TRANSPORT/nr_sss.c b/openair1/PHY/NR_TRANSPORT/nr_sss.c index de92237f6caf2b45cb325da09b0b550a08c83b81..5181f6bac18de7af72c174310e5811459ebb28b8 100644 --- a/openair1/PHY/NR_TRANSPORT/nr_sss.c +++ b/openair1/PHY/NR_TRANSPORT/nr_sss.c @@ -23,42 +23,34 @@ //#define NR_SSS_DEBUG -int nr_generate_sss( int16_t *d_sss, - int32_t *txdataF, +int nr_generate_sss( int32_t *txdataF, int16_t amp, uint8_t ssb_start_symbol, nfapi_nr_config_request_scf_t* config, NR_DL_FRAME_PARMS *frame_parms) { - int i,k,l; - int m0, m1; - int Nid, Nid1, Nid2; - //int16_t a; - int16_t x0[NR_SSS_LENGTH], x1[NR_SSS_LENGTH]; + int16_t x0[NR_SSS_LENGTH]; + int16_t x1[NR_SSS_LENGTH]; const int x0_initial[7] = { 1, 0, 0, 0, 0, 0, 0 }; const int x1_initial[7] = { 1, 0, 0, 0, 0, 0, 0 }; /// Sequence generation - Nid = config->cell_config.phy_cell_id.value; - Nid2 = Nid % 3; - Nid1 = (Nid - Nid2)/3; + int Nid = config->cell_config.phy_cell_id.value; + int Nid2 = Nid % 3; + int Nid1 = (Nid - Nid2)/3; - for ( i=0 ; i < 7 ; i++) { + for (int i=0; i < 7; i++) { x0[i] = x0_initial[i]; x1[i] = x1_initial[i]; } - for ( i=0 ; i < NR_SSS_LENGTH - 7 ; i++) { + for (int i=0; i < NR_SSS_LENGTH - 7; i++) { x0[i+7] = (x0[i + 4] + x0[i]) % 2; x1[i+7] = (x1[i + 1] + x1[i]) % 2; } - m0 = 15*(Nid1/112) + (5*Nid2); - m1 = Nid1 % 112; - - for (i = 0; i < NR_SSS_LENGTH ; i++) { - d_sss[i] = (1 - 2*x0[(i + m0) % NR_SSS_LENGTH] ) * (1 - 2*x1[(i + m1) % NR_SSS_LENGTH] ) * 23170; - } + int m0 = 15*(Nid1/112) + (5*Nid2); + int m1 = Nid1 % 112; #ifdef NR_SSS_DEBUG write_output("d_sss.m", "d_sss", (void*)d_sss, NR_SSS_LENGTH, 1, 1); @@ -66,17 +58,18 @@ int nr_generate_sss( int16_t *d_sss, /// Resource mapping - // SSS occupies a predefined position (subcarriers 56-182, symbol 2) within the SSB block starting from - k = frame_parms->first_carrier_offset + frame_parms->ssb_start_subcarrier + 56; //and - l = ssb_start_symbol + 2; + // SSS occupies a predefined position (subcarriers 56-182, symbol 2) within the SSB block starting from + int k = frame_parms->first_carrier_offset + frame_parms->ssb_start_subcarrier + 56; //and + int l = ssb_start_symbol + 2; - for (int m = 0; m < NR_SSS_LENGTH; m++) { - ((int16_t*)txdataF)[2*(l*frame_parms->ofdm_symbol_size + k)] = (amp * d_sss[m]) >> 15; - k++; + for (int i = 0; i < NR_SSS_LENGTH; i++) { + int16_t d_sss = (1 - 2*x0[(i + m0) % NR_SSS_LENGTH] ) * (1 - 2*x1[(i + m1) % NR_SSS_LENGTH] ) * 23170; + ((int16_t*)txdataF)[2*(l*frame_parms->ofdm_symbol_size + k)] = (((int16_t)amp) * d_sss) >> 15; + k++; - if (k >= frame_parms->ofdm_symbol_size) - k-=frame_parms->ofdm_symbol_size; - } + if (k >= frame_parms->ofdm_symbol_size) + k-=frame_parms->ofdm_symbol_size; + } #ifdef NR_SSS_DEBUG // write_output("sss_0.m", "sss_0", (void*)txdataF[0][l*frame_parms->ofdm_symbol_size], frame_parms->ofdm_symbol_size, 1, 1); #endif diff --git a/openair1/PHY/NR_TRANSPORT/nr_transport_common_proto.h b/openair1/PHY/NR_TRANSPORT/nr_transport_common_proto.h index 02e594e76a3509ab2488f9639434d2c760d71791..2daf2af1fb80922c90caacd2796ca39ff4eb4df8 100644 --- a/openair1/PHY/NR_TRANSPORT/nr_transport_common_proto.h +++ b/openair1/PHY/NR_TRANSPORT/nr_transport_common_proto.h @@ -77,6 +77,15 @@ void nr_fill_du(uint16_t N_ZC,uint16_t *prach_root_sequence_map); void init_nr_prach_tables(int N_ZC); +void nr_codeword_scrambling(uint8_t *in, + uint32_t size, + uint8_t q, + uint32_t Nid, + uint32_t n_RNTI, + uint32_t* out); + +void nr_codeword_unscrambling(int16_t* llr, uint32_t size, uint8_t q, uint32_t Nid, uint32_t n_RNTI); + /**@}*/ void init_pucch2_luts(void); diff --git a/openair1/PHY/NR_TRANSPORT/nr_transport_proto.h b/openair1/PHY/NR_TRANSPORT/nr_transport_proto.h index 4fed3a468febf4ce41809d33765d3c17f8abb8a3..d45858bca0814c1155ffb4e86237e64602bb28b6 100644 --- a/openair1/PHY/NR_TRANSPORT/nr_transport_proto.h +++ b/openair1/PHY/NR_TRANSPORT/nr_transport_proto.h @@ -44,8 +44,7 @@ @param @returns 0 on success */ -int nr_generate_pss(int16_t *d_pss, - int32_t *txdataF, +int nr_generate_pss(int32_t *txdataF, int16_t amp, uint8_t ssb_start_symbol, nfapi_nr_config_request_scf_t *config, @@ -57,8 +56,7 @@ int nr_generate_pss(int16_t *d_pss, @param @returns 0 on success */ -int nr_generate_sss(int16_t *d_sss, - int32_t *txdataF, +int nr_generate_sss(int32_t *txdataF, int16_t amp, uint8_t ssb_start_symbol, nfapi_nr_config_request_scf_t *config, @@ -83,8 +81,7 @@ int nr_generate_pbch_dmrs(uint32_t *gold_pbch_dmrs, @param @returns 0 on success */ -int nr_generate_pbch(NR_gNB_PBCH *pbch, - nfapi_nr_dl_tti_ssb_pdu *ssb_pdu, +int nr_generate_pbch(nfapi_nr_dl_tti_ssb_pdu *ssb_pdu, uint8_t *interleaver, int32_t *txdataF, int16_t amp, @@ -310,6 +307,24 @@ int nr_find_pucch(uint16_t rnti, int slot, PHY_VARS_gNB *gNB); +NR_gNB_SRS_t *new_gNB_srs(void); + +int nr_find_srs(uint16_t rnti, + int frame, + int slot, + PHY_VARS_gNB *gNB); + +void nr_fill_srs(PHY_VARS_gNB *gNB, + int frame, + int slot, + nfapi_nr_srs_pdu_t *srs_pdu); + +int nr_get_srs_signal(PHY_VARS_gNB *gNB, + int frame, + int slot, + nfapi_nr_srs_pdu_t *srs_pdu, + nr_srs_info_t *nr_srs_info, + int32_t **srs_received_signal); void init_prach_list(PHY_VARS_gNB *gNB); void init_prach_ru_list(RU_t *ru); diff --git a/openair1/PHY/NR_TRANSPORT/nr_ulsch.c b/openair1/PHY/NR_TRANSPORT/nr_ulsch.c index 4278338dbcc382d3e81ce1566161b380b89c5342..1cb503489bbdcf28d10c1c07e34662e9f3537930 100644 --- a/openair1/PHY/NR_TRANSPORT/nr_ulsch.c +++ b/openair1/PHY/NR_TRANSPORT/nr_ulsch.c @@ -33,7 +33,6 @@ #include <stdint.h> #include "PHY/NR_TRANSPORT/nr_transport_common_proto.h" #include "PHY/NR_TRANSPORT/nr_ulsch.h" -#include "PHY/NR_REFSIG/nr_refsig.h" int16_t find_nr_ulsch(uint16_t rnti, PHY_VARS_gNB *gNB,find_type_t type) { @@ -82,59 +81,9 @@ void nr_fill_ulsch(PHY_VARS_gNB *gNB, } -void nr_ulsch_unscrambling(int16_t* llr, - uint32_t size, - uint8_t q, - uint32_t Nid, - uint32_t n_RNTI) { - - uint8_t reset; - uint32_t x1, x2, s=0; - - reset = 1; - x2 = (n_RNTI<<15) + Nid; - - for (uint32_t i=0; i<size; i++) { - if ((i&0x1f)==0) { - s = lte_gold_generic(&x1, &x2, reset); - reset = 0; - } - if (((s>>(i&0x1f))&1)==1) - llr[i] = -llr[i]; - } -} - -void nr_ulsch_unscrambling_optim(int16_t* llr, - uint32_t size, - uint8_t q, - uint32_t Nid, - uint32_t n_RNTI) { - -#if defined(__x86_64__) || defined(__i386__) - uint32_t x1, x2, s=0; - - x2 = (n_RNTI<<15) + Nid; - - uint8_t *s8=(uint8_t *)&s; - __m128i *llr128 = (__m128i*)llr; - int j=0; - s = lte_gold_generic(&x1, &x2, 1); - - for (int i=0; i<((size>>5)+((size&0x1f) > 0 ? 1 : 0)); i++,j+=4) { - llr128[j] = _mm_mullo_epi16(llr128[j],byte2m128i[s8[0]]); - llr128[j+1] = _mm_mullo_epi16(llr128[j+1],byte2m128i[s8[1]]); - llr128[j+2] = _mm_mullo_epi16(llr128[j+2],byte2m128i[s8[2]]); - llr128[j+3] = _mm_mullo_epi16(llr128[j+3],byte2m128i[s8[3]]); - s = lte_gold_generic(&x1, &x2, 0); - } -#else - - nr_ulsch_unscrambling(llr, - size, - q, - Nid, - n_RNTI); -#endif +void nr_ulsch_unscrambling(int16_t* llr, uint32_t size, uint32_t Nid, uint32_t n_RNTI) +{ + nr_codeword_unscrambling(llr, size, 0, Nid, n_RNTI); } void dump_pusch_stats(FILE *fd,PHY_VARS_gNB *gNB) { diff --git a/openair1/PHY/NR_TRANSPORT/nr_ulsch.h b/openair1/PHY/NR_TRANSPORT/nr_ulsch.h index 80c10d74b15a4c7bc82862efe7142d049975320f..f7bb3be5772ecb11fe7e789ed9b07ac9b975ff41 100644 --- a/openair1/PHY/NR_TRANSPORT/nr_ulsch.h +++ b/openair1/PHY/NR_TRANSPORT/nr_ulsch.h @@ -69,18 +69,7 @@ uint32_t nr_ulsch_decoding(PHY_VARS_gNB *phy_vars_gNB, @param n_RNTI, CRNTI */ -void nr_ulsch_unscrambling(int16_t* llr, - uint32_t size, - uint8_t q, - uint32_t Nid, - uint32_t n_RNTI); - - -void nr_ulsch_unscrambling_optim(int16_t* llr, - uint32_t size, - uint8_t q, - uint32_t Nid, - uint32_t n_RNTI); +void nr_ulsch_unscrambling(int16_t* llr, uint32_t size, uint32_t Nid, uint32_t n_RNTI); void nr_ulsch_procedures(PHY_VARS_gNB *gNB, int frame_rx, diff --git a/openair1/PHY/NR_TRANSPORT/nr_ulsch_decoding.c b/openair1/PHY/NR_TRANSPORT/nr_ulsch_decoding.c index 8bbf569814795d36cb6ad4d94134264126ad6a4a..31d44736d4ba758d8a7e88757046a4f0e0611811 100644 --- a/openair1/PHY/NR_TRANSPORT/nr_ulsch_decoding.c +++ b/openair1/PHY/NR_TRANSPORT/nr_ulsch_decoding.c @@ -111,7 +111,7 @@ NR_gNB_ULSCH_t *new_gNB_ulsch(uint8_t max_ldpc_iterations,uint16_t N_RB_UL, uint { NR_gNB_ULSCH_t *ulsch; - uint8_t exit_flag = 0,i,r; + uint8_t i,r; uint16_t a_segments = MAX_NUM_NR_ULSCH_SEGMENTS; //number of segments to be allocated if (N_RB_UL != 273) { @@ -119,69 +119,27 @@ NR_gNB_ULSCH_t *new_gNB_ulsch(uint8_t max_ldpc_iterations,uint16_t N_RB_UL, uint a_segments = a_segments/273 +1; } - uint16_t ulsch_bytes = a_segments*1056; // allocated bytes per segment - ulsch = (NR_gNB_ULSCH_t *)malloc16(sizeof(NR_gNB_ULSCH_t)); - - if (ulsch) { - - memset(ulsch,0,sizeof(NR_gNB_ULSCH_t)); - - ulsch->max_ldpc_iterations = max_ldpc_iterations; - ulsch->Mlimit = 4; - - for (i=0; i<NR_MAX_ULSCH_HARQ_PROCESSES; i++) { - - ulsch->harq_processes[i] = (NR_UL_gNB_HARQ_t *)malloc16(sizeof(NR_UL_gNB_HARQ_t)); - - if (ulsch->harq_processes[i]) { - - memset(ulsch->harq_processes[i],0,sizeof(NR_UL_gNB_HARQ_t)); - - ulsch->harq_processes[i]->b = (uint8_t*)malloc16(ulsch_bytes); - - if (ulsch->harq_processes[i]->b) - memset(ulsch->harq_processes[i]->b,0,ulsch_bytes); - else - exit_flag=3; - - if (abstraction_flag == 0) { - for (r=0; r<a_segments; r++) { - - ulsch->harq_processes[i]->p_nrLDPC_procBuf[r] = nrLDPC_init_mem(); - - ulsch->harq_processes[i]->c[r] = (uint8_t*)malloc16(8448*sizeof(uint8_t)); - - if (ulsch->harq_processes[i]->c[r]) - memset(ulsch->harq_processes[i]->c[r],0,8448*sizeof(uint8_t)); - else - exit_flag=2; - - ulsch->harq_processes[i]->d[r] = (int16_t*)malloc16((68*384)*sizeof(int16_t)); - - if (ulsch->harq_processes[i]->d[r]) - memset(ulsch->harq_processes[i]->d[r],0,(68*384)*sizeof(int16_t)); - else - exit_flag=2; - - ulsch->harq_processes[i]->w[r] = (int16_t*)malloc16((3*(6144+64))*sizeof(int16_t)); - - if (ulsch->harq_processes[i]->w[r]) - memset(ulsch->harq_processes[i]->w[r],0,(3*(6144+64))*sizeof(int16_t)); - else - exit_flag=2; - } - } - } else { - exit_flag=1; + uint32_t ulsch_bytes = a_segments*1056; // allocated bytes per segment + ulsch = (NR_gNB_ULSCH_t *)malloc16_clear(sizeof(NR_gNB_ULSCH_t)); + + ulsch->max_ldpc_iterations = max_ldpc_iterations; + ulsch->Mlimit = 4; + + for (i=0; i<NR_MAX_ULSCH_HARQ_PROCESSES; i++) { + + ulsch->harq_processes[i] = (NR_UL_gNB_HARQ_t *)malloc16_clear(sizeof(NR_UL_gNB_HARQ_t)); + ulsch->harq_processes[i]->b = (uint8_t*)malloc16_clear(ulsch_bytes); + if (abstraction_flag == 0) { + for (r=0; r<a_segments; r++) { + ulsch->harq_processes[i]->p_nrLDPC_procBuf[r] = nrLDPC_init_mem(); + ulsch->harq_processes[i]->c[r] = (uint8_t*)malloc16_clear(8448*sizeof(uint8_t)); + ulsch->harq_processes[i]->d[r] = (int16_t*)malloc16_clear((68*384)*sizeof(int16_t)); + ulsch->harq_processes[i]->w[r] = (int16_t*)malloc16_clear((3*(6144+64))*sizeof(int16_t)); } } - - if (exit_flag==0) - return(ulsch); } - printf("new_gNB_ulsch with size %zu: exit_flag = %hhu\n",sizeof(NR_UL_gNB_HARQ_t), exit_flag); - free_gNB_ulsch(&ulsch,N_RB_UL); - return(NULL); + + return(ulsch); } void clean_gNB_ulsch(NR_gNB_ULSCH_t *ulsch) @@ -505,7 +463,7 @@ uint32_t nr_ulsch_decoding(PHY_VARS_gNB *phy_vars_gNB, VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_PHY_gNB_ULSCH_DECODING,1); harq_process->TBS = pusch_pdu->pusch_data.tb_size; - harq_process->round = nr_rv_round_map[pusch_pdu->pusch_data.rv_index]; + 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) if (harq_process->round == 0) { diff --git a/openair1/PHY/NR_TRANSPORT/nr_ulsch_demodulation.c b/openair1/PHY/NR_TRANSPORT/nr_ulsch_demodulation.c index 28dd5ab21924dd546b829e7d6ccb6c5ba93ff1fb..681a9eae16b11946a8aa0d85722e68f275caab47 100644 --- a/openair1/PHY/NR_TRANSPORT/nr_ulsch_demodulation.c +++ b/openair1/PHY/NR_TRANSPORT/nr_ulsch_demodulation.c @@ -1174,7 +1174,7 @@ int nr_rx_pusch(PHY_VARS_gNB *gNB, uint8_t aarx, aatx; uint32_t nb_re_pusch, bwp_start_subcarrier; - int avgs; + int avgs = 0; NR_DL_FRAME_PARMS *frame_parms = &gNB->frame_parms; nfapi_nr_pusch_pdu_t *rel15_ul = &gNB->ulsch[ulsch_id][0]->harq_processes[harq_pid]->ulsch_pdu; diff --git a/openair1/PHY/NR_TRANSPORT/pucch_rx.c b/openair1/PHY/NR_TRANSPORT/pucch_rx.c index ea926d0bbbb60b866b8de48cb4e1ef4e977955b7..a7710ace5e1b20aab91a05aee3914ceaadf6c072 100644 --- a/openair1/PHY/NR_TRANSPORT/pucch_rx.c +++ b/openair1/PHY/NR_TRANSPORT/pucch_rx.c @@ -47,6 +47,7 @@ #include "PHY/NR_REFSIG/nr_refsig.h" #include "common/utils/LOG/log.h" #include "common/utils/LOG/vcd_signal_dumper.h" +#include "nfapi/oai_integration/vendor_ext.h" #include "nfapi/oai_integration/vendor_ext.h" @@ -88,7 +89,8 @@ void nr_fill_pucch(PHY_VARS_gNB *gNB, int frame, int slot, nfapi_nr_pucch_pdu_t *pucch_pdu) { - + if (NFAPI_MODE == NFAPI_MODE_PNF) + gNB->pucch[0]->active = 0; //check if ture in monolithic mode int id = nr_find_pucch(pucch_pdu->rnti,frame,slot,gNB); AssertFatal( (id>=0) && (id<NUMBER_OF_NR_PUCCH_MAX), "invalid id found for pucch !!! rnti %04x id %d\n",pucch_pdu->rnti,id); @@ -300,7 +302,7 @@ void nr_decode_pucch0(PHY_VARS_gNB *gNB, int32_t corr_re[1+frame_parms->nb_antennas_rx][2]; int32_t corr_im[1+frame_parms->nb_antennas_rx][2]; //int32_t no_corr = 0; - int seq_index; + int seq_index = 0; int64_t temp; for(i=0;i<nr_sequences;i++){ diff --git a/openair1/PHY/NR_TRANSPORT/srs_rx.c b/openair1/PHY/NR_TRANSPORT/srs_rx.c new file mode 100644 index 0000000000000000000000000000000000000000..c16becdb20b2aa0403ef19253e6379f565c86076 --- /dev/null +++ b/openair1/PHY/NR_TRANSPORT/srs_rx.c @@ -0,0 +1,139 @@ +/* + * 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 PHY/NR_TRANSPORT/srs_rx.c + * \brief Top-level routines for getting the SRS physical channel + * \date 2021 + * \version 1.0 + */ + +#include <stdio.h> +#include <string.h> +#include <unistd.h> +#include <fcntl.h> + +#include "PHY/impl_defs_nr.h" +#include "PHY/defs_nr_common.h" +#include "PHY/defs_gNB.h" +#include <openair1/PHY/CODING/nrSmallBlock/nr_small_block_defs.h> +#include "common/utils/LOG/log.h" + +#include "nfapi/oai_integration/vendor_ext.h" + +#include "T.h" + +//#define SRS_DEBUG + +NR_gNB_SRS_t *new_gNB_srs(void){ + NR_gNB_SRS_t *srs; + srs = (NR_gNB_SRS_t *)malloc16(sizeof(NR_gNB_SRS_t)); + srs->active = 0; + return (srs); +} + +int nr_find_srs(uint16_t rnti, + int frame, + int slot, + PHY_VARS_gNB *gNB) { + + AssertFatal(gNB!=NULL,"gNB is null\n"); + int index = -1; + + for (int i=0; i<NUMBER_OF_NR_SRS_MAX; i++) { + AssertFatal(gNB->srs[i]!=NULL,"gNB->srs[%d] is null\n",i); + if ((gNB->srs[i]->active>0) && + (gNB->srs[i]->srs_pdu.rnti==rnti) && + (gNB->srs[i]->frame==frame) && + (gNB->srs[i]->slot==slot)) return(i); + else if ((gNB->srs[i]->active == 0) && (index==-1)) index=i; + } + + if (index==-1) + LOG_E(MAC,"SRS list is full\n"); + + return(index); +} + +void nr_fill_srs(PHY_VARS_gNB *gNB, + int frame, + int slot, + nfapi_nr_srs_pdu_t *srs_pdu) { + + int id = nr_find_srs(srs_pdu->rnti,frame,slot,gNB); + AssertFatal( (id>=0) && (id<NUMBER_OF_NR_SRS_MAX), + "invalid id found for srs !!! rnti %04x id %d\n",srs_pdu->rnti,id); + + NR_gNB_SRS_t *srs = gNB->srs[id]; + srs->frame = frame; + srs->slot = slot; + srs->active = 1; + memcpy((void*)&srs->srs_pdu, (void*)srs_pdu, sizeof(nfapi_nr_srs_pdu_t)); +} + +int nr_get_srs_signal(PHY_VARS_gNB *gNB, + int frame, + int slot, + nfapi_nr_srs_pdu_t *srs_pdu, + nr_srs_info_t *nr_srs_info, + int32_t **srs_received_signal) { + + 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; + } + + int32_t **rxdataF = gNB->common_vars.rxdataF; + 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; + + int32_t *rx_signal; + for (int ant = 0; ant < frame_parms->nb_antennas_rx; ant++) { + + 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]]; + +#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)); +#endif + } + } + return 0; +} \ No newline at end of file diff --git a/openair1/PHY/NR_UE_ESTIMATION/filt16a_32.c b/openair1/PHY/NR_UE_ESTIMATION/filt16a_32.c index 65ae28825201321ced5139d9bc785e2284f1f076..0c520aabe79418c3d077535e95bffd501cda95b1 100644 --- a/openair1/PHY/NR_UE_ESTIMATION/filt16a_32.c +++ b/openair1/PHY/NR_UE_ESTIMATION/filt16a_32.c @@ -260,3 +260,26 @@ short filt8_avlip5[8] = { short filt8_avlip6[8] = { 13653,15019,16384,16384,16384,16384,16384,16384}; + +// Comb size 2 +short filt8_start[8] = { + 12288,8192,4096,0,0,0,0,0}; + +short filt8_middle2[8] = { + 4096,8192,8192,8192,4096,0,0,0}; + +short filt8_middle4[8] = { + 0,0,4096,8192,8192,8192,4096,0}; + +short filt8_end[8] = { + 4096,8192,12288,16384,0,0,0,0}; + +// Comb size 4 +short filt16_start[16] = { + 12288,8192,8192,8192,4096,0,0,0,0,0,0,0,0,0,0,0}; + +short filt16_middle4[16] = { + 4096,8192,8192,8192,8192,8192,8192,8192,4096,0,0,0,0,0,0,0}; + +short filt16_end[16] = { + 4096,8192,8192,8192,12288,16384,16384,16384,0,0,0,0,0,0,0,0}; \ No newline at end of file diff --git a/openair1/PHY/NR_UE_ESTIMATION/filt16a_32.h b/openair1/PHY/NR_UE_ESTIMATION/filt16a_32.h index e28736b51daf45dc7c133f1f210d46c89abfd571..72d1318545509905aed6c27e6d3a207311876a3a 100644 --- a/openair1/PHY/NR_UE_ESTIMATION/filt16a_32.h +++ b/openair1/PHY/NR_UE_ESTIMATION/filt16a_32.h @@ -182,4 +182,15 @@ extern short filt8_avlip4[8]; extern short filt8_avlip5[8]; extern short filt8_avlip6[8]; + +/*Comb size 2*/ +extern short filt8_start[8]; +extern short filt8_middle2[8]; +extern short filt8_middle4[8]; +extern short filt8_end[8]; + +/*Comb size 4*/ +extern short filt16_start[16]; +extern short filt16_middle4[16]; +extern short filt16_end[16]; #endif diff --git a/openair1/PHY/NR_UE_TRANSPORT/nr_dlsch_decoding.c b/openair1/PHY/NR_UE_TRANSPORT/nr_dlsch_decoding.c index b8cd59eeadf5af4f4dc5dcf07b1bf4aee9edef84..8064093eed6e86c78ae92d29fb3143ee45480b30 100644 --- a/openair1/PHY/NR_UE_TRANSPORT/nr_dlsch_decoding.c +++ b/openair1/PHY/NR_UE_TRANSPORT/nr_dlsch_decoding.c @@ -141,7 +141,7 @@ NR_UE_DLSCH_t *new_nr_ue_dlsch(uint8_t Kmimo,uint8_t Mdlharq,uint32_t Nsoft,uint a_segments = (a_segments/273)+1; } - uint16_t dlsch_bytes = a_segments*1056; // allocated bytes per segment + uint32_t dlsch_bytes = a_segments*1056; // allocated bytes per segment dlsch = (NR_UE_DLSCH_t *)malloc16(sizeof(NR_UE_DLSCH_t)); if (dlsch) { @@ -206,25 +206,9 @@ NR_UE_DLSCH_t *new_nr_ue_dlsch(uint8_t Kmimo,uint8_t Mdlharq,uint32_t Nsoft,uint return(NULL); } -void nr_dlsch_unscrambling(int16_t *llr, - uint32_t size, - uint8_t q, - uint32_t Nid, - uint32_t n_RNTI) { - uint8_t reset; - uint32_t x1, x2, s=0; - reset = 1; - x2 = (n_RNTI<<15) + (q<<14) + Nid; - - for (int i=0; i<size; i++) { - if ((i&0x1f)==0) { - s = lte_gold_generic(&x1, &x2, reset); - reset = 0; - } - - if (((s>>(i&0x1f))&1)==1) - llr[i] = -llr[i]; - } +void nr_dlsch_unscrambling(int16_t *llr, uint32_t size, uint8_t q, uint32_t Nid, uint32_t n_RNTI) +{ + nr_codeword_unscrambling(llr, size, q, Nid, n_RNTI); } bool nr_ue_postDecode(PHY_VARS_NR_UE *phy_vars_ue, notifiedFIFO_elt_t *req, bool last, notifiedFIFO_t *nf_p) { @@ -233,6 +217,10 @@ bool nr_ue_postDecode(PHY_VARS_NR_UE *phy_vars_ue, notifiedFIFO_elt_t *req, bool NR_UE_DLSCH_t *dlsch = (NR_UE_DLSCH_t *) rdata->dlsch; int r = rdata->segment_r; + merge_meas(&phy_vars_ue->dlsch_deinterleaving_stats, &rdata->ts_deinterleave); + merge_meas(&phy_vars_ue->dlsch_rate_unmatching_stats, &rdata->ts_rate_unmatch); + merge_meas(&phy_vars_ue->dlsch_ldpc_decoding_stats, &rdata->ts_ldpc_decode); + bool decodeSuccess = (rdata->decodeIterations < (1+dlsch->max_ldpc_iterations)); if (decodeSuccess) { @@ -271,7 +259,6 @@ bool nr_ue_postDecode(PHY_VARS_NR_UE *phy_vars_ue, notifiedFIFO_elt_t *req, bool //LOG_D(PHY,"[UE %d] DLSCH: Setting NAK for SFN/SF %d/%d (pid %d, status %d, round %d, TBS %d, mcs %d) Kr %d r %d harq_process->round %d\n", // phy_vars_ue->Mod_id, frame, nr_slot_rx, harq_pid,harq_process->status, harq_process->round,harq_process->TBS,harq_process->mcs,Kr,r,harq_process->round); harq_process->ack = 0; - harq_process->round++; if (harq_process->round >= dlsch->Mlimit) { harq_process->status = SCH_IDLE; harq_process->round = 0; @@ -296,12 +283,6 @@ bool nr_ue_postDecode(PHY_VARS_NR_UE *phy_vars_ue, notifiedFIFO_elt_t *req, bool void nr_processDLSegment(void* arg) { ldpcDecode_ue_t *rdata = (ldpcDecode_ue_t*) arg; NR_UE_DLSCH_t *dlsch = rdata->dlsch; -#if UE_TIMING_TRACE //TBD - PHY_VARS_NR_UE *phy_vars_ue = rdata->phy_vars_ue; - time_stats_t *dlsch_rate_unmatching_stats=&phy_vars_ue->dlsch_rate_unmatching_stats; - time_stats_t *dlsch_turbo_decoding_stats=&phy_vars_ue->dlsch_turbo_decoding_stats; - time_stats_t *dlsch_deinterleaving_stats=&phy_vars_ue->dlsch_deinterleaving_stats; -#endif NR_DL_UE_HARQ_t *harq_process= rdata->harq_process; t_nrLDPC_dec_params *p_decoderParms = &rdata->decoderParms; int length_dec; @@ -330,7 +311,7 @@ void nr_processDLSegment(void* arg) { __m128i *pv = (__m128i*)&z; __m128i *pl = (__m128i*)&l; - uint8_t Ilbrm = 0; + uint8_t Ilbrm = 1; Kr = harq_process->K; // [hna] overwrites this line "Kr = p_decParams->Z*kb" Kr_bytes = Kr>>3; @@ -341,21 +322,16 @@ void nr_processDLSegment(void* arg) { t_nrLDPC_procBuf **p_nrLDPC_procBuf = harq_process->p_nrLDPC_procBuf; -#if UE_TIMING_TRACE - start_meas(dlsch_deinterleaving_stats); -#endif + start_meas(&rdata->ts_deinterleave); //VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_DLSCH_DEINTERLEAVING, VCD_FUNCTION_IN); nr_deinterleaving_ldpc(E, Qm, harq_process->w[r], // [hna] w is e dlsch_llr+r_offset); //VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_DLSCH_DEINTERLEAVING, VCD_FUNCTION_OUT); -#if UE_TIMING_TRACE - stop_meas(dlsch_deinterleaving_stats); -#endif -#if UE_TIMING_TRACE - start_meas(dlsch_rate_unmatching_stats); -#endif + stop_meas(&rdata->ts_deinterleave); + + start_meas(&rdata->ts_rate_unmatch); /* LOG_D(PHY,"HARQ_PID %d Rate Matching Segment %d (coded bits %d,E %d, F %d,unpunctured/repeated bits %d, TBS %d, mod_order %d, nb_rb %d, Nl %d, rv %d, round %d)...\n", harq_pid,r, G,E,harq_process->F, Kr*3, @@ -380,22 +356,17 @@ void nr_processDLSegment(void* arg) { harq_process->F, Kr-harq_process->F-2*(p_decoderParms->Z))==-1) { //VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_DLSCH_RATE_MATCHING, VCD_FUNCTION_OUT); -#if UE_TIMING_TRACE - stop_meas(dlsch_rate_unmatching_stats); -#endif + stop_meas(&rdata->ts_rate_unmatch); LOG_E(PHY,"dlsch_decoding.c: Problem in rate_matching\n"); rdata->decodeIterations = dlsch->max_ldpc_iterations + 1; - return; - } else { -#if UE_TIMING_TRACE - stop_meas(dlsch_rate_unmatching_stats); -#endif + return; } + stop_meas(&rdata->ts_rate_unmatch); r_offset += E; if (LOG_DEBUGFLAG(DEBUG_DLSCH_DECOD)) { - LOG_I(PHY,"decoder input(segment %u) :",r); + LOG_D(PHY,"decoder input(segment %u) :",r); for (int i=0; i<E; i++) LOG_D(PHY,"%d : %d\n",i,harq_process->d[r][i]); @@ -418,9 +389,7 @@ void nr_processDLSegment(void* arg) { } { -#if UE_TIMING_TRACE - start_meas(dlsch_turbo_decoding_stats); -#endif + start_meas(&rdata->ts_ldpc_decode); //set first 2*Z_c bits to zeros memset(&z[0],0,2*harq_process->Z*sizeof(int16_t)); //set Filler bits @@ -470,9 +439,7 @@ void nr_processDLSegment(void* arg) { harq_process->c[r][m]= (uint8_t) llrProcBuf[m]; } -#if UE_TIMING_TRACE - stop_meas(dlsch_turbo_decoding_stats); -#endif + stop_meas(&rdata->ts_ldpc_decode); } } @@ -503,6 +470,7 @@ uint32_t nr_dlsch_decoding(PHY_VARS_NR_UE *phy_vars_ue, // HARQ stats phy_vars_ue->dl_stats[harq_process->round]++; + LOG_D(PHY,"Round %d RV idx %d\n",harq_process->round,harq_process->rvidx); uint8_t kc; uint32_t Tbslbrm;// = 950984; uint16_t nb_rb;// = 30; @@ -642,7 +610,6 @@ uint32_t nr_dlsch_decoding(PHY_VARS_NR_UE *phy_vars_ue, if (LOG_DEBUGFLAG(DEBUG_DLSCH_DECOD)) LOG_I(PHY,"Segmentation: C %d, K %d\n",harq_process->C,harq_process->K); - opp_enabled=1; Kr = harq_process->K; // [hna] overwrites this line "Kr = p_decParams->Z*kb" Kr_bytes = Kr>>3; offset = 0; @@ -674,6 +641,9 @@ uint32_t nr_dlsch_decoding(PHY_VARS_NR_UE *phy_vars_ue, rdata->offset = offset; rdata->dlsch = dlsch; rdata->dlsch_id = 0; + reset_meas(&rdata->ts_deinterleave); + reset_meas(&rdata->ts_rate_unmatch); + reset_meas(&rdata->ts_ldpc_decode); pushTpool(&(pool_dl),req); nbDecode++; LOG_D(PHY,"Added a block to decode, in pipe: %d\n",nbDecode); diff --git a/openair1/PHY/NR_UE_TRANSPORT/nr_dlsch_demodulation.c b/openair1/PHY/NR_UE_TRANSPORT/nr_dlsch_demodulation.c index 0894ae91669193c0d64ec30f1826e7696885e25d..075aaecc08d64e253d224995c42ce76a62d72cb8 100644 --- a/openair1/PHY/NR_UE_TRANSPORT/nr_dlsch_demodulation.c +++ b/openair1/PHY/NR_UE_TRANSPORT/nr_dlsch_demodulation.c @@ -32,9 +32,6 @@ #include "PHY/phy_extern_nr_ue.h" #include "PHY/NR_TRANSPORT/nr_transport_proto.h" #include "nr_transport_proto_ue.h" -//#include "SCHED/defs.h" -//#include "PHY/defs.h" -//#include "extern.h" #include "PHY/sse_intrin.h" #include "T.h" #include "openair1/PHY/NR_UE_ESTIMATION/nr_estimation.h" @@ -379,13 +376,10 @@ int nr_rx_pdsch(PHY_VARS_NR_UE *ue, len = (pilots==1)? ((config_type==NFAPI_NR_DMRS_TYPE1)?nb_rb*(12-6*dlsch0_harq->n_dmrs_cdm_groups): nb_rb*(12-4*dlsch0_harq->n_dmrs_cdm_groups)):(nb_rb*12); stop_meas(&ue->generic_stat_bis[proc->thread_id][slot]); -#if DISABLE_LOG_X - printf("[AbsSFN %u.%d] Slot%d Symbol %d type %d: Pilot/Data extraction %5.2f \n", - frame,nr_slot_rx,slot,symbol,type,ue->generic_stat_bis[proc->thread_id][slot].p_time/(cpuf*1000.0)); -#else - LOG_D(PHY, "[AbsSFN %u.%d] Slot%d Symbol %d type %d: Pilot/Data extraction %5.2f \n", - frame,nr_slot_rx,slot,symbol,type,ue->generic_stat_bis[proc->thread_id][slot].p_time/(cpuf*1000.0)); -#endif + if (cpumeas(CPUMEAS_GETSTATE)) + LOG_D(PHY, "[AbsSFN %u.%d] Slot%d Symbol %d type %d: Pilot/Data extraction %5.2f \n", + frame,nr_slot_rx,slot,symbol,type,ue->generic_stat_bis[proc->thread_id][slot].p_time/(cpuf*1000.0)); + start_meas(&ue->generic_stat_bis[proc->thread_id][slot]); n_tx = dlsch0_harq->Nl; @@ -402,11 +396,9 @@ int nr_rx_pdsch(PHY_VARS_NR_UE *ue, nb_rb_pdsch); stop_meas(&ue->generic_stat_bis[proc->thread_id][slot]); -#if DISABLE_LOG_X - printf("[AbsSFN %u.%d] Slot%d Symbol %d: Channel Scale %5.2f \n",frame,nr_slot_rx,slot,symbol,ue->generic_stat_bis[proc->thread_id][slot].p_time/(cpuf*1000.0)); -#else - LOG_D(PHY, "[AbsSFN %u.%d] Slot%d Symbol %d: Channel Scale %5.2f \n",frame,nr_slot_rx,slot,symbol,ue->generic_stat_bis[proc->thread_id][slot].p_time/(cpuf*1000.0)); -#endif + if (cpumeas(CPUMEAS_GETSTATE)) + LOG_D(PHY, "[AbsSFN %u.%d] Slot%d Symbol %d: Channel Scale %5.2f \n",frame,nr_slot_rx,slot,symbol,ue->generic_stat_bis[proc->thread_id][slot].p_time/(cpuf*1000.0)); + start_meas(&ue->generic_stat_bis[proc->thread_id][slot]); if (first_symbol_flag==1) { if (beamforming_mode==0){ @@ -463,11 +455,8 @@ int nr_rx_pdsch(PHY_VARS_NR_UE *ue, #endif stop_meas(&ue->generic_stat_bis[proc->thread_id][slot]); -#if DISABLE_LOG_X - printf("[AbsSFN %u.%d] Slot%d Symbol %d first_symbol_flag %d: Channel Level %5.2f \n",frame,nr_slot_rx,slot,symbol,first_symbol_flag,ue->generic_stat_bis[proc->thread_id][slot].p_time/(cpuf*1000.0)); -#else - LOG_D(PHY, "[AbsSFN %u.%d] Slot%d Symbol %d first_symbol_flag %d: Channel Level %5.2f \n",frame,nr_slot_rx,slot,symbol,first_symbol_flag,ue->generic_stat_bis[proc->thread_id][slot].p_time/(cpuf*1000.0)); -#endif + if (cpumeas(CPUMEAS_GETSTATE)) + LOG_D(PHY, "[AbsSFN %u.%d] Slot%d Symbol %d first_symbol_flag %d: Channel Level %5.2f \n",frame,nr_slot_rx,slot,symbol,first_symbol_flag,ue->generic_stat_bis[proc->thread_id][slot].p_time/(cpuf*1000.0)); start_meas(&ue->generic_stat_bis[proc->thread_id][slot]); // Now channel compensation @@ -515,11 +504,9 @@ int nr_rx_pdsch(PHY_VARS_NR_UE *ue, } stop_meas(&ue->generic_stat_bis[proc->thread_id][slot]); -#if DISABLE_LOG_X - printf("[AbsSFN %u.%d] Slot%d Symbol %d log2_maxh %d channel_level %d: Channel Comp %5.2f \n", frame, nr_slot_rx, slot, symbol, pdsch_vars[gNB_id]->log2_maxh, proc->channel_level, ue->generic_stat_bis[proc->thread_id][slot].p_time/(cpuf*1000.0)); -#else - LOG_D(PHY, "[AbsSFN %u.%d] Slot%d Symbol %d log2_maxh %d channel_level %d: Channel Comp %5.2f \n", frame, nr_slot_rx, slot, symbol, pdsch_vars[gNB_id]->log2_maxh, proc->channel_level, ue->generic_stat_bis[proc->thread_id][slot].p_time/(cpuf*1000.0)); -#endif + if (cpumeas(CPUMEAS_GETSTATE)) + LOG_D(PHY, "[AbsSFN %u.%d] Slot%d Symbol %d log2_maxh %d channel_level %d: Channel Comp %5.2f \n", frame, nr_slot_rx, slot, symbol, pdsch_vars[gNB_id]->log2_maxh, proc->channel_level, ue->generic_stat_bis[proc->thread_id][slot].p_time/(cpuf*1000.0)); + start_meas(&ue->generic_stat_bis[proc->thread_id][slot]); if (frame_parms->nb_antennas_rx > 1) { @@ -574,11 +561,9 @@ int nr_rx_pdsch(PHY_VARS_NR_UE *ue, } stop_meas(&ue->generic_stat_bis[proc->thread_id][slot]); -#if DISABLE_LOG_X - printf("[AbsSFN %u.%d] Slot%d Symbol %d: Channel Combine %5.2f \n",frame,nr_slot_rx,slot,symbol,ue->generic_stat_bis[proc->thread_id][slot].p_time/(cpuf*1000.0)); -#else - LOG_D(PHY, "[AbsSFN %u.%d] Slot%d Symbol %d: Channel Combine %5.2f \n",frame,nr_slot_rx,slot,symbol,ue->generic_stat_bis[proc->thread_id][slot].p_time/(cpuf*1000.0)); -#endif + if (cpumeas(CPUMEAS_GETSTATE)) + LOG_D(PHY, "[AbsSFN %u.%d] Slot%d Symbol %d: Channel Combine %5.2f \n",frame,nr_slot_rx,slot,symbol,ue->generic_stat_bis[proc->thread_id][slot].p_time/(cpuf*1000.0)); + start_meas(&ue->generic_stat_bis[proc->thread_id][slot]); /* Store the valid DL RE's */ pdsch_vars[gNB_id]->dl_valid_re[symbol-1] = len; @@ -657,11 +642,8 @@ int nr_rx_pdsch(PHY_VARS_NR_UE *ue, } stop_meas(&ue->generic_stat_bis[proc->thread_id][slot]); -#if DISABLE_LOG_X - printf("[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)); -#else - 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)); -#endif + 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 diff --git a/openair1/PHY/NR_UE_TRANSPORT/nr_dlsch_llr_computation.c b/openair1/PHY/NR_UE_TRANSPORT/nr_dlsch_llr_computation.c index a064a91d87eaee53622854dbecb986eadcd69ccb..7c75884fa6b3da080ba4f2587c784f26f30137fe 100644 --- a/openair1/PHY/NR_UE_TRANSPORT/nr_dlsch_llr_computation.c +++ b/openair1/PHY/NR_UE_TRANSPORT/nr_dlsch_llr_computation.c @@ -947,7 +947,7 @@ void nr_dlsch_64qam_llr_SIC(NR_DL_FRAME_PARMS *frame_parms, symbol_mod = (symbol>=(7-frame_parms->Ncp)) ? symbol-(7-frame_parms->Ncp) : symbol; - pbch_pss_sss_adjust=adjust_G2(frame_parms,&rb_alloc,6,subframe,symbol); + pbch_pss_sss_adjust=adjust_G2(frame_parms->Ncp,frame_parms->frame_type, frame_parms->N_RB_DL,&rb_alloc,6,subframe,symbol); if ((symbol_mod==0) || (symbol_mod==(4-frame_parms->Ncp))) { amp_tmp = 0x1fff;//dlsch0->sqrt_rho_b; already taken into account diff --git a/openair1/PHY/NR_UE_TRANSPORT/nr_initial_sync.c b/openair1/PHY/NR_UE_TRANSPORT/nr_initial_sync.c index 767edf9cc65a29f730ce1484b74b33c47ba1dc03..8917a8bc1b1ebc4ca0a6db92073c18be024e044c 100644 --- a/openair1/PHY/NR_UE_TRANSPORT/nr_initial_sync.c +++ b/openair1/PHY/NR_UE_TRANSPORT/nr_initial_sync.c @@ -196,8 +196,7 @@ char prefix_string[2][9] = {"NORMAL","EXTENDED"}; int nr_initial_sync(UE_nr_rxtx_proc_t *proc, PHY_VARS_NR_UE *ue, - int n_frames, int sa, - int dlsch_parallel) + int n_frames, int sa) { int32_t sync_pos, sync_pos_frame; // k_ssb, N_ssb_crb, sync_pos2, @@ -353,21 +352,15 @@ int nr_initial_sync(UE_nr_rxtx_proc_t *proc, if( (abs(ue->common_vars.freq_offset) > 150) && (ret == 0) ) { ret=-1; -#if DISABLE_LOG_X - printf("Ignore MIB with high freq offset [%d Hz] estimation \n",ue->common_vars.freq_offset); -#else LOG_E(HW, "Ignore MIB with high freq offset [%d Hz] estimation \n",ue->common_vars.freq_offset); -#endif }*/ if (ret==0) { // PBCH found so indicate sync to higher layers and configure frame parameters //#ifdef DEBUG_INITIAL_SYNCH -#if DISABLE_LOG_X - printf("[UE%d] In synch, rx_offset %d samples\n",ue->Mod_id, ue->rx_offset); -#else + LOG_I(PHY, "[UE%d] In synch, rx_offset %d samples\n",ue->Mod_id, ue->rx_offset); -#endif + //#endif if (ue->UE_scan_carrier == 0) { @@ -534,8 +527,7 @@ int nr_initial_sync(UE_nr_rxtx_proc_t *proc, SI_PDSCH, ue->dlsch_SI[gnb_id], NULL, - &ue->dlsch_SI_errors[gnb_id], - dlsch_parallel); + &ue->dlsch_SI_errors[gnb_id]); // deactivate dlsch once dlsch proc is done ue->dlsch_SI[gnb_id]->active = 0; diff --git a/openair1/PHY/NR_UE_TRANSPORT/nr_pbch.c b/openair1/PHY/NR_UE_TRANSPORT/nr_pbch.c index 86c9974f68377a7a4f80d10297672ad90235aca3..dff347f7c04fb0cc8a6bff4e1a9e994551d817a6 100644 --- a/openair1/PHY/NR_UE_TRANSPORT/nr_pbch.c +++ b/openair1/PHY/NR_UE_TRANSPORT/nr_pbch.c @@ -601,11 +601,11 @@ int nr_rx_pbch( PHY_VARS_NR_UE *ue, #endif nr_downlink_indication_t dl_indication; - fapi_nr_rx_indication_t rx_ind; + fapi_nr_rx_indication_t *rx_ind = calloc(1, sizeof(*rx_ind)); uint16_t number_pdus = 1; - nr_fill_dl_indication(&dl_indication, NULL, &rx_ind, proc, ue, gNB_id); - nr_fill_rx_indication(&rx_ind, FAPI_NR_RX_PDU_TYPE_SSB, gNB_id, ue, NULL, NULL, number_pdus); + nr_fill_dl_indication(&dl_indication, NULL, rx_ind, proc, ue, gNB_id); + nr_fill_rx_indication(rx_ind, FAPI_NR_RX_PDU_TYPE_SSB, gNB_id, ue, NULL, NULL, number_pdus, proc); if (ue->if_inst && ue->if_inst->dl_indication) ue->if_inst->dl_indication(&dl_indication, NULL); diff --git a/openair1/PHY/NR_UE_TRANSPORT/nr_transport_proto_ue.h b/openair1/PHY/NR_UE_TRANSPORT/nr_transport_proto_ue.h index 0ab17c11e687c02a8655e08718990e7bdccc0e18..239731208eb45ff117e4faff8ecee59348aef30b 100644 --- a/openair1/PHY/NR_UE_TRANSPORT/nr_transport_proto_ue.h +++ b/openair1/PHY/NR_UE_TRANSPORT/nr_transport_proto_ue.h @@ -1055,14 +1055,15 @@ int nr_ulsch_encoding(PHY_VARS_NR_UE *ue, @param[in] size, of input bits @param[in] Nid, cell id @param[in] n_RNTI, CRNTI + @param[in] uci_on_pusch whether UCI placeholder bits need to be scrambled (true -> no optimized scrambling) @param[out] out, the scrambled bits */ - void nr_pusch_codeword_scrambling(uint8_t *in, - uint32_t size, - uint32_t Nid, - uint32_t n_RNTI, - uint32_t* out); + uint32_t size, + uint32_t Nid, + uint32_t n_RNTI, + bool uci_on_pusch, + uint32_t* out); /** \brief Perform the following functionalities: - encoding @@ -1286,8 +1287,8 @@ uint8_t get_transmission_mode(module_id_t Mod_id, uint8_t CC_id, rnti_t rnti); */ uint32_t conv_nprb(uint8_t ra_header,uint32_t rb_alloc,int N_RB_DL); -int adjust_G(NR_DL_FRAME_PARMS *frame_parms,uint32_t *rb_alloc,uint8_t mod_order,uint8_t subframe); -int adjust_G2(NR_DL_FRAME_PARMS *frame_parms,uint32_t *rb_alloc,uint8_t mod_order,uint8_t subframe,uint8_t symbol); +//int adjust_G(NR_DL_FRAME_PARMS *frame_parms,uint32_t *rb_alloc,uint8_t mod_order,uint8_t subframe); +//int adjust_G2(NR_DL_FRAME_PARMS *frame_parms,uint32_t *rb_alloc,uint8_t mod_order,uint8_t subframe,uint8_t symbol); #ifndef modOrder @@ -1313,16 +1314,6 @@ uint8_t I_TBS2I_MCS(uint8_t I_TBS); uint8_t SE2I_TBS(float SE, uint8_t N_PRB, uint8_t symbPerRB); -/** \brief This function generates the sounding reference symbol (SRS) for the uplink according to 36.211 v8.6.0. If IFFT_FPGA is defined, the SRS is quantized to a QPSK sequence. - @param frame_parms LTE DL Frame Parameters - @param soundingrs_ul_config_dedicated Dynamic configuration from RRC during Connection Establishment - @param txdataF pointer to the frequency domain TX signal - @returns 0 on success*/ -int generate_srs(NR_DL_FRAME_PARMS *frame_parms, - SOUNDINGRS_UL_CONFIG_DEDICATED *soundingrs_ul_config_dedicated, - int *txdataF, - int16_t amp, - uint32_t subframe); /*! @@ -1352,12 +1343,6 @@ int32_t generate_drs_pusch(PHY_VARS_NR_UE *phy_vars_ue, uint32_t nb_rb, uint8_t ant); -/*! - \brief This function initializes the Group Hopping, Sequence Hopping and nPRS sequences for PUCCH/PUSCH according to 36.211 v8.6.0. It should be called after configuration of UE (reception of SIB2/3) and initial configuration of eNB (or after reconfiguration of cell-specific parameters). - @param frame_parms Pointer to a NR_DL_FRAME_PARMS structure (eNB or UE)*/ -void init_ul_hopping(NR_DL_FRAME_PARMS *frame_parms); - - /*! \brief This function implements the initialization of paging parameters for UE (See Section 7, 36.304).It must be called after setting IMSImod1024 during UE startup and after receiving SIB2 @param ue Pointer to UE context @@ -1422,8 +1407,6 @@ double sinr_eff_cqi_calc(PHY_VARS_NR_UE *phy_vars_ue, uint8_t sinr2cqi(double sinr,uint8_t trans_mode); -int dump_dci(NR_DL_FRAME_PARMS *frame_parms, DCI_ALLOC_t *dci); - int dump_ue_stats(PHY_VARS_NR_UE *phy_vars_ue, UE_nr_rxtx_proc_t *proc, char* buffer, int length, runmode_t mode, int input_level_dBm); void init_transport_channels(uint8_t); @@ -1441,8 +1424,7 @@ void generate_RIV_tables(void); int nr_initial_sync(UE_nr_rxtx_proc_t *proc, PHY_VARS_NR_UE *phy_vars_ue, int n_frames, - int sa, - int dlsch_parallel); + int sa); /*! \brief This function gets the carrier frequencies either from FP or command-line-set global variables, depending on the availability of the latter @@ -1513,18 +1495,11 @@ int get_nCCE_offset_l1(int *CCE_table, const unsigned short rnti, const unsigned char subframe); -uint16_t get_nCCE(uint8_t num_pdcch_symbols,NR_DL_FRAME_PARMS *frame_parms,uint8_t mi); -uint16_t get_nquad(uint8_t num_pdcch_symbols,NR_DL_FRAME_PARMS *frame_parms,uint8_t mi); - -uint8_t get_mi(NR_DL_FRAME_PARMS *frame,uint8_t subframe); +//uint8_t get_mi(NR_DL_FRAME_PARMS *frame,uint8_t subframe); uint16_t get_nCCE_mac(uint8_t Mod_id,uint8_t CC_id,int num_pdcch_symbols,int subframe); -uint8_t get_num_pdcch_symbols(uint8_t num_dci,DCI_ALLOC_t *dci_alloc,NR_DL_FRAME_PARMS *frame_parms,uint8_t subframe); - -void pdcch_interleaving(NR_DL_FRAME_PARMS *frame_parms,int32_t **z, int32_t **wbar,uint8_t n_symbols_pdcch,uint8_t mi); - void nr_pdcch_unscrambling(int16_t *z, uint16_t scrambling_RNTI, uint32_t length, @@ -1539,7 +1514,6 @@ void dlsch_unscrambling(NR_DL_FRAME_PARMS *frame_parms, uint8_t q, uint8_t Ns); -void init_ncs_cell(NR_DL_FRAME_PARMS *frame_parms,uint8_t ncs_cell[20][7]); void generate_pucch1x(int32_t **txdataF, NR_DL_FRAME_PARMS *frame_parms, @@ -1587,7 +1561,7 @@ void init_ulsch_power_LUT(void); @param subframe subframe index to check @returns 0 on success */ -int is_prach_subframe(NR_DL_FRAME_PARMS *frame_parms,frame_t frame, uint8_t subframe); +//int is_prach_subframe(NR_DL_FRAME_PARMS *frame_parms,frame_t frame, uint8_t subframe); /*! \brief Generate PRACH waveform @@ -1653,8 +1627,6 @@ void init_scrambling_lut(void); @param frame_parms Pointer to frame parameters @returns 1 if subframe is for MBSFN */ -int is_pmch_subframe(frame_t frame, int subframe, NR_DL_FRAME_PARMS *frame_parms); - uint8_t is_not_pilot(uint8_t pilots, uint8_t re, uint8_t nushift, uint8_t use2ndpilots); uint8_t is_not_UEspecRS(int8_t lprime, uint8_t re, uint8_t nushift, uint8_t Ncp, uint8_t beamforming_mode); @@ -1691,8 +1663,7 @@ uint8_t get_prach_prb_offset(NR_DL_FRAME_PARMS *frame_parms, uint8_t n_ra_prboffset, uint8_t tdd_mapindex, uint16_t Nf); - -uint32_t lte_gold_generic(uint32_t *x1, uint32_t *x2, uint8_t reset); +#include <openair1/PHY/LTE_TRANSPORT/transport_proto.h> uint8_t nr_dci_decoding_procedure(PHY_VARS_NR_UE *ue, UE_nr_rxtx_proc_t *proc, diff --git a/openair1/PHY/NR_UE_TRANSPORT/nr_transport_ue.h b/openair1/PHY/NR_UE_TRANSPORT/nr_transport_ue.h index b4ee4f5b41d047483cdd90afa7491a225072d478..9b9f1add6e175dd9d391e55660c956ff5739b1f7 100644 --- a/openair1/PHY/NR_UE_TRANSPORT/nr_transport_ue.h +++ b/openair1/PHY/NR_UE_TRANSPORT/nr_transport_ue.h @@ -149,7 +149,7 @@ typedef struct { /// ACK/NAK Bundling flag uint8_t bundling; /// Concatenated "g"-sequences (for definition see 36-212 V15.4.0 2018-12, p.31) - uint8_t g[MAX_NUM_NR_CHANNEL_BITS]; + uint8_t g[MAX_NUM_NR_CHANNEL_BITS] __attribute__ ((aligned(32))); /// Interleaved "h"-sequences (for definition see 36-212 V8.6 2009-03, p.17-18) uint8_t h[MAX_NUM_NR_CHANNEL_BITS]; /// Scrambled "b"-sequences (for definition see 36-211 V8.6 2009-03, p.14) diff --git a/openair1/PHY/NR_UE_TRANSPORT/nr_ulsch_coding.c b/openair1/PHY/NR_UE_TRANSPORT/nr_ulsch_coding.c index 945dc516737c8bebc221e151fe89e69f3274291a..553d4fa4f7baed980f9aeefb0d0432a7a32093ed 100644 --- a/openair1/PHY/NR_UE_TRANSPORT/nr_ulsch_coding.c +++ b/openair1/PHY/NR_UE_TRANSPORT/nr_ulsch_coding.c @@ -118,7 +118,7 @@ NR_UE_ULSCH_t *new_nr_ue_ulsch(uint16_t N_RB_UL, a_segments = a_segments/273 +1; } - uint16_t ulsch_bytes = a_segments*1056; // allocated bytes per segment + uint32_t ulsch_bytes = a_segments*1056; // allocated bytes per segment ulsch = (NR_UE_ULSCH_t *)malloc16(sizeof(NR_UE_ULSCH_t)); @@ -258,7 +258,6 @@ int nr_ulsch_encoding(PHY_VARS_NR_UE *ue, Ilbrm = 0; Tbslbrm = 950984; //max tbs Coderate = 0.0; - trace_NRpdu(DIRECTION_UPLINK, harq_process->a, harq_process->pusch_pdu.pusch_data.tb_size, 0, WS_C_RNTI, 0, 0, 0,0, 0); /////////// ///////////////////////////////////////////////////////////////////////////////////////// diff --git a/openair1/PHY/NR_UE_TRANSPORT/nr_ulsch_ue.c b/openair1/PHY/NR_UE_TRANSPORT/nr_ulsch_ue.c index 99dc2b658e7024f94121d48a2940c5f164e17e40..0c188e9119ff49a4a1b9137b9cf4295b8354127e 100644 --- a/openair1/PHY/NR_UE_TRANSPORT/nr_ulsch_ue.c +++ b/openair1/PHY/NR_UE_TRANSPORT/nr_ulsch_ue.c @@ -45,6 +45,7 @@ #include "executables/nr-softmodem.h" #include "executables/softmodem-common.h" #include "PHY/NR_REFSIG/ul_ref_seq_nr.h" +#include <openair2/UTIL/OPT/opt.h> //#define DEBUG_PUSCH_MAPPING //#define DEBUG_MAC_PDU @@ -52,12 +53,12 @@ //extern int32_t uplink_counter; -void nr_pusch_codeword_scrambling(uint8_t *in, - uint32_t size, - uint32_t Nid, - uint32_t n_RNTI, - uint32_t* out) { - +void nr_pusch_codeword_scrambling_uci(uint8_t *in, + uint32_t size, + uint32_t Nid, + uint32_t n_RNTI, + uint32_t* out) +{ uint8_t reset, b_idx; uint32_t x1, x2, s=0, temp_out; @@ -88,7 +89,19 @@ void nr_pusch_codeword_scrambling(uint8_t *in, *out ^= (((in[i])&1) ^ ((s>>b_idx)&1))<<b_idx; //printf("i %d b_idx %d in %d s 0x%08x out 0x%08x\n", i, b_idx, in[i], s, *out); } +} +void nr_pusch_codeword_scrambling(uint8_t *in, + uint32_t size, + uint32_t Nid, + uint32_t n_RNTI, + bool uci_on_pusch, + uint32_t* out) +{ + if (uci_on_pusch) + nr_pusch_codeword_scrambling_uci(in, size, Nid, n_RNTI, out); + else + nr_codeword_scrambling(in, size, 0, Nid, n_RNTI, out); } void nr_ue_ulsch_procedures(PHY_VARS_NR_UE *UE, @@ -105,7 +118,8 @@ void nr_ue_ulsch_procedures(PHY_VARS_NR_UE *UE, uint32_t scrambled_output[NR_MAX_NB_CODEWORDS][NR_MAX_PDSCH_ENCODED_LENGTH>>5]; int16_t **tx_layers; int32_t **txdataF; - int8_t Wf[2], Wt[2], l_prime[2], delta; + int8_t Wf[2], Wt[2]; + int l_prime[2], delta; uint8_t nb_dmrs_re_per_rb; int ap, i; int sample_offsetF, N_RE_prime; @@ -162,9 +176,15 @@ void nr_ue_ulsch_procedures(PHY_VARS_NR_UE *UE, nb_dmrs_re_per_rb, number_dmrs_symbols, mod_order, Nl); + trace_NRpdu(DIRECTION_UPLINK, + ulsch_ue->harq_processes[harq_pid]->a, + ulsch_ue->harq_processes[harq_pid]->pusch_pdu.pusch_data.tb_size, + 0, WS_C_RNTI, rnti, frame, slot, 0, 0); + if (nr_ulsch_encoding(UE, ulsch_ue, frame_parms, harq_pid, G) == -1) return; + /////////// //////////////////////////////////////////////////////////////////// @@ -179,6 +199,7 @@ void nr_ue_ulsch_procedures(PHY_VARS_NR_UE *UE, available_bits, ulsch_ue->Nid_cell, rnti, + false, scrambled_output[cwd_index]); // assume one codeword for the moment @@ -411,7 +432,7 @@ void nr_ue_ulsch_procedures(PHY_VARS_NR_UE *UE, if (is_dmrs == 1) { // if transform precoding is enabled if (pusch_pdu->transform_precoding == 0) { - + ((int16_t*)txdataF[ap])[(sample_offsetF)<<1] = (Wt[l_prime[0]]*Wf[k_prime]*AMP*dmrs_seq[2*dmrs_idx]) >> 15; ((int16_t*)txdataF[ap])[((sample_offsetF)<<1) + 1] = (Wt[l_prime[0]]*Wf[k_prime]*AMP*dmrs_seq[(2*dmrs_idx) + 1]) >> 15; diff --git a/openair1/PHY/NR_UE_TRANSPORT/pucch_nr.c b/openair1/PHY/NR_UE_TRANSPORT/pucch_nr.c index cb929f1642439e95ab17274a9e0e283c0046c744..ddec605253b3f87779c62761061ea4b01fe139de 100644 --- a/openair1/PHY/NR_UE_TRANSPORT/pucch_nr.c +++ b/openair1/PHY/NR_UE_TRANSPORT/pucch_nr.c @@ -805,8 +805,8 @@ void nr_generate_pucch1_old(PHY_VARS_NR_UE *ue, } #endif //0 -inline void nr_pucch2_3_4_scrambling(uint16_t M_bit,uint16_t rnti,uint16_t n_id,uint64_t *B64,uint8_t *btilde) __attribute__((always_inline)); -inline void nr_pucch2_3_4_scrambling(uint16_t M_bit,uint16_t rnti,uint16_t n_id,uint64_t *B64,uint8_t *btilde) { +static inline void nr_pucch2_3_4_scrambling(uint16_t M_bit,uint16_t rnti,uint16_t n_id,uint64_t *B64,uint8_t *btilde) __attribute__((always_inline)); +static inline void nr_pucch2_3_4_scrambling(uint16_t M_bit,uint16_t rnti,uint16_t n_id,uint64_t *B64,uint8_t *btilde) { uint32_t x1, x2, s=0; int i; uint8_t c; diff --git a/openair1/PHY/NR_UE_TRANSPORT/srs_modulation_nr.c b/openair1/PHY/NR_UE_TRANSPORT/srs_modulation_nr.c index 4109950df6156da0204c7d4e7fe7faa5f93d9971..f3a953c9a85f58030b28e0251c92e969e4b382e8 100644 --- a/openair1/PHY/NR_UE_TRANSPORT/srs_modulation_nr.c +++ b/openair1/PHY/NR_UE_TRANSPORT/srs_modulation_nr.c @@ -38,7 +38,6 @@ #undef DEFINE_VARIABLES_PHY_IMPLEMENTATION_DEFS_NR_H #include "PHY/defs_nr_UE.h" -//#include "extern.h" #include "PHY/NR_REFSIG/ss_pbch_nr.h" #include "PHY/NR_REFSIG/dmrs_nr.h" #include "PHY/NR_REFSIG/ul_ref_seq_nr.h" @@ -47,11 +46,13 @@ #include "PHY/NR_UE_TRANSPORT/srs_modulation_nr.h" #undef DEFINE_VARIABLES_SRS_MODULATION_NR_H +//#define SRS_DEBUG + /******************************************************************* * * NAME : generate_srs * -* PARAMETERS : pointer to resource set +* PARAMETERS : pointer to srs config pdu * pointer to transmit buffer * amplitude scaling for this physical signal * slot number of transmission @@ -73,84 +74,94 @@ * - no antenna switching* * *********************************************************************/ -int32_t generate_srs_nr(SRS_ResourceSet_t *p_srs_resource_set, - NR_DL_FRAME_PARMS *frame_parms, - int32_t *txptr, - int16_t amp, - UE_nr_rxtx_proc_t *proc) +int generate_srs_nr(nfapi_nr_srs_pdu_t *srs_config_pdu, + NR_DL_FRAME_PARMS *frame_parms, + int32_t *txptr, + 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, v_nu; + uint8_t u; + uint8_t v_nu; uint32_t f_gh = 0; - SRS_Resource_t *p_SRS_Resource; - int frame_number = proc->frame_tx; - int slot_number = proc->nr_slot_tx; - uint16_t n_SRS, n_SRS_cs_i; + 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], F_b, subcarrier; - uint8_t N_b, k_0_overbar_p; - - if (p_srs_resource_set->p_srs_ResourceList[0] == NULL) { - LOG_E(PHY,"generate_srs: No resource associated with the SRS resource set!\n"); - return (-1); - } - else { - if (p_srs_resource_set->number_srs_Resource <= MAX_NR_OF_SRS_RESOURCES_PER_SET) { - p_SRS_Resource = p_srs_resource_set->p_srs_ResourceList[0]; - } - else { - LOG_E(PHY,"generate_srs: resource number of this resource set %d exceeds maximum supported value %d!\n", p_srs_resource_set->number_srs_Resource, MAX_NR_OF_SRS_RESOURCES_PER_SET); - return (-1); - } + uint16_t n_b[B_SRS_NUMBER]; + uint16_t F_b; + uint16_t subcarrier; + uint8_t N_b; + uint8_t k_0_overbar_p; + + // get parameters from srs_config_pdu + 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<<srs_config_pdu->comb_size; + uint8_t K_TC_overbar = srs_config_pdu->comb_offset; // FFS_TODO_NR is this parameter for K_TC_overbar ?? + 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_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 + uint8_t R = 1<<srs_config_pdu->num_repetitions; + uint8_t N_ap = 1<<srs_config_pdu->num_ant_ports; // antenna port for transmission + uint8_t N_symb_SRS = 1<<srs_config_pdu->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); } - if (p_srs_resource_set->resourceType != periodic) { - LOG_E(PHY,"generate_srs: only SRS periodic is supported up to now!\n"); - return (-1); - } - /* get parameters from SRS resource configuration */ - uint8_t B_SRS = p_SRS_Resource->freqHopping_b_SRS; - uint8_t C_SRS = p_SRS_Resource->freqHopping_c_SRS; - uint8_t b_hop = p_SRS_Resource->freqHopping_b_hop; - uint8_t K_TC = p_SRS_Resource->transmissionComb; - uint8_t K_TC_overbar = p_SRS_Resource->combOffset; /* FFS_TODO_NR is this parameter for K_TC_overbar ?? */ - uint8_t n_SRS_cs = p_SRS_Resource->cyclicShift; - uint8_t n_ID_SRS = p_SRS_Resource->sequenceId; - uint8_t n_shift = p_SRS_Resource->freqDomainPosition; /* it adjusts the SRS allocation to align with the common resource block grid in multiples of four */ - uint8_t n_RRC = p_SRS_Resource->freqDomainShift; - uint8_t groupOrSequenceHopping = p_SRS_Resource->groupOrSequenceHopping; - - uint8_t l_offset = p_SRS_Resource->resourceMapping_startPosition; - - uint16_t T_SRS = srs_period[p_SRS_Resource->SRS_Periodicity]; - uint16_t T_offset = p_SRS_Resource->SRS_Offset;; /* FFS_TODO_NR to check interface with RRC */ - uint8_t R = p_SRS_Resource->resourceMapping_repetitionFactor; - - /* TS 38.211 6.4.1.4.1 SRS resource */ - uint8_t N_ap = (uint8_t)p_SRS_Resource->nrof_SrsPorts; /* antenna port for transmission */ - uint8_t N_symb_SRS = p_SRS_Resource->resourceMapping_nrofSymbols; /* consecutive OFDM symbols */ - uint8_t l0 = N_SYMB_SLOT - 1 - l_offset; /* starting position in the time domain */ - uint8_t k_0_p; /* frequency domain starting position */ +#ifdef SRS_DEBUG + LOG_I(NR_PHY,"Frame = %i, slot = %i\n", frame_number, slot_number); + LOG_I(NR_PHY,"B_SRS = %i\n", B_SRS); + LOG_I(NR_PHY,"C_SRS = %i\n", C_SRS); + LOG_I(NR_PHY,"b_hop = %i\n", b_hop); + LOG_I(NR_PHY,"K_TC = %i\n", K_TC); + LOG_I(NR_PHY,"K_TC_overbar = %i\n", K_TC_overbar); + LOG_I(NR_PHY,"n_SRS_cs = %i\n", n_SRS_cs); + LOG_I(NR_PHY,"n_ID_SRS = %i\n", n_ID_SRS); + LOG_I(NR_PHY,"n_shift = %i\n", n_shift); + LOG_I(NR_PHY,"n_RRC = %i\n", n_RRC); + LOG_I(NR_PHY,"groupOrSequenceHopping = %i\n", groupOrSequenceHopping); + LOG_I(NR_PHY,"l_offset = %i\n", l_offset); + LOG_I(NR_PHY,"T_SRS = %i\n", T_SRS); + LOG_I(NR_PHY,"T_offset = %i\n", T_offset); + LOG_I(NR_PHY,"R = %i\n", R); + 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); +#endif if (N_ap != port1) { - LOG_E(PHY, "generate_srs: this number of antenna ports %d is not yet supported!\n", N_ap); + 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(PHY, "generate_srs: this number of srs symbol %d is not yet supported!\n", N_symb_SRS); + 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(PHY, "generate_srs: sequence hopping is not yet supported!\n"); + LOG_E(NR_PHY, "generate_srs: sequence hopping is not yet supported!\n"); return (-1); } if (R == 0) { - LOG_E(PHY, "generate_srs: this parameter repetition factor %d is not consistent !\n", R); + LOG_E(NR_PHY, "generate_srs: this parameter repetition factor %d is not consistent !\n", R); return (-1); } else if (R > N_symb_SRS) { - LOG_E(PHY, "generate_srs: R %d can not be greater than N_symb_SRS %d !\n", 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 */ @@ -163,15 +174,15 @@ int32_t generate_srs_nr(SRS_ResourceSet_t *p_srs_resource_set, // delta = 1; /* delta = log2(K_TC) */ } else { - LOG_E(PHY, "generate_srs: SRS unknown value for K_TC %d !\n", K_TC); + LOG_E(NR_PHY, "generate_srs: SRS unknown value for K_TC %d !\n", K_TC); return (-1); } if (n_SRS_cs >= n_SRS_cs_max) { - LOG_E(PHY, "generate_srs: inconsistent parameter n_SRS_cs %d >= n_SRS_cs_max %d !\n", 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); } if (T_SRS == 0) { - LOG_E(PHY, "generate_srs: inconsistent parameter T_SRS %d can not be equal to zero !\n", T_SRS); + LOG_E(NR_PHY, "generate_srs: inconsistent parameter T_SRS %d can not be equal to zero !\n", T_SRS); return (-1); } else @@ -180,7 +191,7 @@ int32_t generate_srs_nr(SRS_ResourceSet_t *p_srs_resource_set, while (srs_periodicity[index] != T_SRS) { index++; if (index == SRS_PERIODICITY) { - LOG_E(PHY, "generate_srs: inconsistent parameter T_SRS %d not specified !\n", T_SRS); + LOG_E(NR_PHY, "generate_srs: inconsistent parameter T_SRS %d not specified !\n", T_SRS); return (-1); } } @@ -202,10 +213,9 @@ int32_t generate_srs_nr(SRS_ResourceSet_t *p_srs_resource_set, /* 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(PHY, "generate_srs: number of antenna ports %d and number of srs symbols %d are different !\n", N_ap, 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) { @@ -247,7 +257,7 @@ int32_t generate_srs_nr(SRS_ResourceSet_t *p_srs_resource_set, } default: { - LOG_E(PHY, "generate_srs: unknown hopping setting %d !\n", groupOrSequenceHopping); + LOG_E(NR_PHY, "generate_srs: unknown hopping setting %d !\n", groupOrSequenceHopping); return (-1); } } @@ -274,7 +284,7 @@ int32_t generate_srs_nr(SRS_ResourceSet_t *p_srs_resource_set, N_b = 1; } /* periodicity and offset */ - if (p_srs_resource_set->resourceType == aperiodic) { + if (srs_config_pdu->resource_type == aperiodic) { n_SRS = l/R; } else { @@ -315,7 +325,7 @@ int32_t generate_srs_nr(SRS_ResourceSet_t *p_srs_resource_set, k_0_p += K_TC * M_sc_b_SRS * n_b[b]; } - subcarrier = (frame_parms->first_carrier_offset) + k_0_p; + subcarrier = subcarrier_offset + k_0_p; if (subcarrier>frame_parms->ofdm_symbol_size) { subcarrier -= frame_parms->ofdm_symbol_size; } @@ -327,7 +337,7 @@ int32_t generate_srs_nr(SRS_ResourceSet_t *p_srs_resource_set, } if (ul_allocated_re[M_sc_b_SRS_index] != M_sc_b_SRS) { - LOG_E(PHY, "generate_srs: srs uplink allocation %d can not be found! \n", 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); } @@ -363,13 +373,31 @@ int32_t generate_srs_nr(SRS_ResourceSet_t *p_srs_resource_set, txptr[subcarrier] = (real_amp & 0xFFFF) + ((imag_amp<<16)&0xFFFF0000); + 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 + 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)); +#endif + subcarrier += (K_TC); /* subcarrier increment */ - if (subcarrier >= frame_parms->ofdm_symbol_size) + if (subcarrier >= frame_parms->ofdm_symbol_size) { subcarrier=subcarrier-frame_parms->ofdm_symbol_size; + } + } /* process next symbol */ - txptr = txptr + frame_parms->ofdm_symbol_size; + //txptr = txptr + frame_parms->ofdm_symbol_size; } return (0); @@ -377,40 +405,7 @@ int32_t generate_srs_nr(SRS_ResourceSet_t *p_srs_resource_set, /******************************************************************* * -* NAME : is_srs_period_nr -* -* PARAMETERS : pointer to resource set -* pointer to transmit buffer -* amplitude scaling for this physical signal -* slot number of transmission -* RETURN : 0 if it is a valid slot for transmitting srs -* -1 if srs should not be transmitted -* -* DESCRIPTION : for periodic, -* -*********************************************************************/ -int is_srs_period_nr(SRS_Resource_t *p_SRS_Resource, NR_DL_FRAME_PARMS *frame_parms, int frame_tx, int slot_tx) -{ - uint16_t T_SRS = srs_period[p_SRS_Resource->SRS_Periodicity]; - uint16_t T_offset = p_SRS_Resource->SRS_Offset; /* FFS_TODO_NR to check interface */ - - if (T_offset > T_SRS) { - LOG_E(PHY,"is_srs_occasion_nr: T_offset %d is greater than T_SRS %d!\n", T_offset, T_SRS); - return (-1); - } - - int16_t N_slot_frame = frame_parms->slots_per_frame; - if ((N_slot_frame*frame_tx + slot_tx - T_offset)%T_SRS == 0) { - return (0); - } - else { - return (-1); - } -} - -/******************************************************************* -* -* NAME : ue_srs_procedure_nr +* NAME : ue_srs_procedures_nr * * PARAMETERS : pointer to ue context * pointer to rxtx context* @@ -422,54 +417,51 @@ int is_srs_period_nr(SRS_Resource_t *p_SRS_Resource, NR_DL_FRAME_PARMS *frame_pa * send srs according to current configuration * *********************************************************************/ -int ue_srs_procedure_nr(PHY_VARS_NR_UE *ue, UE_nr_rxtx_proc_t *proc, uint8_t eNB_id) +int ue_srs_procedures_nr(PHY_VARS_NR_UE *ue, UE_nr_rxtx_proc_t *proc, uint8_t gNB_id) { - NR_DL_FRAME_PARMS *frame_parms = &(ue->frame_parms); - SRS_NR *p_srs_nr = &(ue->frame_parms.srs_nr); - SRS_ResourceSet_t *p_srs_resource_set = frame_parms->srs_nr.p_SRS_ResourceSetList[p_srs_nr->active_srs_Resource_Set]; - int generate_srs = 0; - /* is there any resource set which has been configurated ? */ - if (p_srs_nr->number_srs_Resource_Set != 0) { - - /* what is the current active resource set ? */ - if (p_srs_nr->active_srs_Resource_Set > MAX_NR_OF_SRS_RESOURCE_SET) { - LOG_W(PHY,"phy_procedures_UE_TX: srs active %d greater than maximum %d!\n", p_srs_nr->active_srs_Resource_Set, MAX_NR_OF_SRS_RESOURCE_SET); - } - else { - /* SRS resource set configurated ? */ - if (p_srs_resource_set != NULL) { + if(!ue->srs_vars[0]->active) { + return -1; + } + ue->srs_vars[0]->active = false; + + nfapi_nr_srs_pdu_t *srs_config_pdu = (nfapi_nr_srs_pdu_t*)&ue->srs_vars[0]->srs_config_pdu; + +#ifdef SRS_DEBUG + LOG_I(NR_PHY,"Frame = %i, slot = %i\n", proc->frame_tx, proc->nr_slot_tx); + LOG_I(NR_PHY,"srs_config_pdu->rnti = 0x%04x\n", srs_config_pdu->rnti); + LOG_I(NR_PHY,"srs_config_pdu->handle = %u\n", srs_config_pdu->handle); + LOG_I(NR_PHY,"srs_config_pdu->bwp_size = %u\n", srs_config_pdu->bwp_size); + LOG_I(NR_PHY,"srs_config_pdu->bwp_start = %u\n", srs_config_pdu->bwp_start); + LOG_I(NR_PHY,"srs_config_pdu->subcarrier_spacing = %u\n", srs_config_pdu->subcarrier_spacing); + LOG_I(NR_PHY,"srs_config_pdu->cyclic_prefix = %u (0: Normal; 1: Extended)\n", srs_config_pdu->cyclic_prefix); + LOG_I(NR_PHY,"srs_config_pdu->num_ant_ports = %u (0 = 1 port, 1 = 2 ports, 2 = 4 ports)\n", srs_config_pdu->num_ant_ports); + LOG_I(NR_PHY,"srs_config_pdu->num_symbols = %u (0 = 1 symbol, 1 = 2 symbols, 2 = 4 symbols)\n", srs_config_pdu->num_symbols); + LOG_I(NR_PHY,"srs_config_pdu->num_repetitions = %u (0 = 1, 1 = 2, 2 = 4)\n", srs_config_pdu->num_repetitions); + LOG_I(NR_PHY,"srs_config_pdu->time_start_position = %u\n", srs_config_pdu->time_start_position); + LOG_I(NR_PHY,"srs_config_pdu->config_index = %u\n", srs_config_pdu->config_index); + LOG_I(NR_PHY,"srs_config_pdu->sequence_id = %u\n", srs_config_pdu->sequence_id); + LOG_I(NR_PHY,"srs_config_pdu->bandwidth_index = %u\n", srs_config_pdu->bandwidth_index); + LOG_I(NR_PHY,"srs_config_pdu->comb_size = %u (0 = comb size 2, 1 = comb size 4, 2 = comb size 8)\n", srs_config_pdu->comb_size); + LOG_I(NR_PHY,"srs_config_pdu->comb_offset = %u\n", srs_config_pdu->comb_offset); + LOG_I(NR_PHY,"srs_config_pdu->cyclic_shift = %u\n", srs_config_pdu->cyclic_shift); + LOG_I(NR_PHY,"srs_config_pdu->frequency_position = %u\n", srs_config_pdu->frequency_position); + LOG_I(NR_PHY,"srs_config_pdu->frequency_shift = %u\n", srs_config_pdu->frequency_shift); + LOG_I(NR_PHY,"srs_config_pdu->frequency_hopping = %u\n", srs_config_pdu->frequency_hopping); + LOG_I(NR_PHY,"srs_config_pdu->group_or_sequence_hopping = %u (0 = No hopping, 1 = Group hopping groupOrSequenceHopping, 2 = Sequence hopping)\n", srs_config_pdu->group_or_sequence_hopping); + LOG_I(NR_PHY,"srs_config_pdu->resource_type = %u (0: aperiodic, 1: semi-persistent, 2: periodic)\n", srs_config_pdu->resource_type); + LOG_I(NR_PHY,"srs_config_pdu->t_srs = %u\n", srs_config_pdu->t_srs); + LOG_I(NR_PHY,"srs_config_pdu->t_offset = %u\n", srs_config_pdu->t_offset); +#endif - SRS_Resource_t *p_srs_resource = frame_parms->srs_nr.p_SRS_ResourceSetList[p_srs_nr->active_srs_Resource_Set]->p_srs_ResourceList[0]; + 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; - /* SRS resource configurated ? */ - if (p_srs_resource != NULL) { - if (p_srs_resource_set->resourceType == periodic) { - if (is_srs_period_nr(p_srs_resource, frame_parms, proc->frame_tx, proc->nr_slot_tx) == 0) { - generate_srs = 1; - } - } - } - else { - LOG_W(PHY,"phy_procedures_UE_TX: no configurated srs resource!\n"); - } - } - } - } - if (generate_srs == 1) { - int16_t txptr = AMP; - uint16_t nsymb = (ue->frame_parms.Ncp==0) ? 14:12; - uint16_t symbol_offset = (int)ue->frame_parms.ofdm_symbol_size*((proc->nr_slot_tx*nsymb)+(nsymb-1)); - if (generate_srs_nr(p_srs_resource_set, frame_parms, &ue->common_vars.txdataF[eNB_id][symbol_offset], txptr, proc) == 0) { - return 0; - } - else - { - return (-1); - } - } - else { - return (-1); + if (generate_srs_nr(srs_config_pdu, frame_parms, &ue->common_vars.txdataF[gNB_id][symbol_offset], ue->nr_srs_info, + AMP, proc->frame_tx, proc->nr_slot_tx) == 0) { + return 0; + } else { + return -1; } } diff --git a/openair1/PHY/NR_UE_TRANSPORT/srs_modulation_nr.h b/openair1/PHY/NR_UE_TRANSPORT/srs_modulation_nr.h index 86fd7fcc917f5ada3eaff86d814198576d6ece62..e43bbe4934bc58c8312dd99cd61845525c312145 100644 --- a/openair1/PHY/NR_UE_TRANSPORT/srs_modulation_nr.h +++ b/openair1/PHY/NR_UE_TRANSPORT/srs_modulation_nr.h @@ -136,15 +136,19 @@ EXTERN const uint16_t srs_periodicity[SRS_PERIODICITY] /** \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 nr_srs_info pointer to the srs info structure @param amp amplitude of generated signal - @param proc pointer to the transmit parameters + @param frame_number frame number + @param slot_number slot number @returns 0 on success -1 on error with message */ -int32_t generate_srs_nr(SRS_ResourceSet_t *p_srs_resource_set, - NR_DL_FRAME_PARMS *frame_parms, - int32_t *txptr, - int16_t amp, - UE_nr_rxtx_proc_t *proc); +int generate_srs_nr(nfapi_nr_srs_pdu_t *srs_config_pdu, + NR_DL_FRAME_PARMS *frame_parms, + int32_t *txptr, + nr_srs_info_t *nr_srs_info, + int16_t amp, + int frame_number, + int 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 @@ -155,13 +159,14 @@ int32_t generate_srs_nr(SRS_ResourceSet_t *p_srs_resource_set, int is_srs_period_nr(SRS_Resource_t *p_SRS_Resource, NR_DL_FRAME_PARMS *frame_parms, int frame_tx, int slot_tx); + /** \brief This function processes srs configuration * @param ue context @param rxtx context - @param current eNB identifier + @param current gNB_id identifier @returns 0 if srs is transmitted -1 otherwise */ -int ue_srs_procedure_nr(PHY_VARS_NR_UE *ue, UE_nr_rxtx_proc_t *proc, uint8_t eNB_id); +int ue_srs_procedures_nr(PHY_VARS_NR_UE *ue, UE_nr_rxtx_proc_t *proc, uint8_t gNB_id); #undef EXTERN #undef INIT_VARIABLES_SRS_MODULATION_NR_H diff --git a/openair1/PHY/TOOLS/calibration_test.c b/openair1/PHY/TOOLS/calibration_test.c index 53baf83d41dbaab0834f88219300ce6fabfe4c43..5dced270604cfa0ec5f8b6a40a4886d2758d9021 100644 --- a/openair1/PHY/TOOLS/calibration_test.c +++ b/openair1/PHY/TOOLS/calibration_test.c @@ -42,7 +42,7 @@ int main(int argc, char **argv) { get_common_options(SOFTMODEM_GNB_BIT ); config_process_cmdline( cmdline_params,sizeof(cmdline_params)/sizeof(paramdef_t),NULL); CONFIG_CLEARRTFLAG(CONFIG_NOEXITONHELP); - configure_linux(); + set_latency_target(); int N_RB=50; diff --git a/openair1/PHY/TOOLS/lte_enb_scope.c b/openair1/PHY/TOOLS/lte_enb_scope.c index bed507feeebafcada8f75c7367e492f038c9e8c6..7fde9f244c00468c3c13913186bf6813c69a0549 100644 --- a/openair1/PHY/TOOLS/lte_enb_scope.c +++ b/openair1/PHY/TOOLS/lte_enb_scope.c @@ -49,9 +49,15 @@ void reset_stats(FL_OBJECT *button, long arg) { int i,j,k; PHY_VARS_eNB *phy_vars_eNB = RC.eNB[0][0]; - for (i=0; i<NUMBER_OF_UE_MAX; i++) { - for (k=0; k<8; k++) { //harq_processes - for (j=0; j<phy_vars_eNB->dlsch[i][0]->Mlimit; j++) { + printf("XXX %d %d %d\n", + sizeofArray(phy_vars_eNB->UE_stats), + sizeofArray( phy_vars_eNB->UE_stats[i].dlsch_NAK), + sizeofArray( *phy_vars_eNB->UE_stats[i].dlsch_NAK) + ); + + for (i=0; i<sizeofArray(phy_vars_eNB->UE_stats); i++) { + for (k=0; k<sizeofArray(phy_vars_eNB->UE_stats[i].dlsch_NAK); k++) { //harq_processes + for (j=0; j<sizeofArray(*phy_vars_eNB->UE_stats[i].dlsch_NAK); j++) { phy_vars_eNB->UE_stats[i].dlsch_NAK[k][j]=0; phy_vars_eNB->UE_stats[i].dlsch_ACK[k][j]=0; phy_vars_eNB->UE_stats[i].dlsch_trials[k][j]=0; @@ -67,7 +73,6 @@ void reset_stats(FL_OBJECT *button, long arg) { } } - static void *scope_thread_eNB(void *arg) { struct sched_param sched_param; int UE_id, CC_id; @@ -75,7 +80,6 @@ static void *scope_thread_eNB(void *arg) { sched_param.sched_priority = sched_get_priority_min(SCHED_FIFO)+1; sched_setscheduler(0, SCHED_FIFO,&sched_param); printf("Scope thread has priority %d\n",sched_param.sched_priority); - while (!oai_exit) { ue_cnt=0; diff --git a/openair1/PHY/TOOLS/nr_phy_scope.c b/openair1/PHY/TOOLS/nr_phy_scope.c index 3440e4f28c50391d41179557e9f2f1c212ab3308..5594d566934d659c322ce19382d67c90b5c8e57d 100644 --- a/openair1/PHY/TOOLS/nr_phy_scope.c +++ b/openair1/PHY/TOOLS/nr_phy_scope.c @@ -33,7 +33,6 @@ #define ScaleZone 4 #define localBuff(NaMe,SiZe) float NaMe[SiZe]; memset(NaMe,0,sizeof(NaMe)); -int otg_enabled; const FL_COLOR rx_antenna_colors[4] = {FL_RED,FL_BLUE,FL_GREEN,FL_YELLOW}; const FL_COLOR water_colors[4] = {FL_BLUE,FL_GREEN,FL_YELLOW,FL_RED}; @@ -240,7 +239,7 @@ static void genericWaterFall (OAIgraph_t *graph, scopeSample_t *values, const in for (int pix=0; pix<graph->w; pix++) { scopeSample_t *end=values+(pix+1)*samplesPerPixel; end-=2; - AssertFatal(end <= values+datasize,"diff : %ld", end-values+datasize); + AssertFatal(end <= values+datasize,"diff : %tu", end-values+datasize); double val=0; for (scopeSample_t *s=values+(pix)*samplesPerPixel; @@ -449,6 +448,7 @@ static OAI_phy_scope_t *create_phy_scope_gnb(void) { OAI_phy_scope_t *fdui = calloc(( sizeof *fdui ),1); // Define form fdui->phy_scope = fl_bgn_form( FL_NO_BOX, 800, 800 ); + fl_set_form_dblbuffer(fdui->phy_scope, 1); // This the whole UI box obj = fl_add_box( FL_BORDER_BOX, 0, 0, 800, 800, "" ); fl_set_object_color( obj, FL_BLACK, FL_WHITE ); @@ -530,7 +530,10 @@ static void *scope_thread_gNB(void *arg) { OAI_phy_scope_t *form_gnb = create_phy_scope_gnb(); while (!oai_exit) { + fl_freeze_form(form_gnb->phy_scope); phy_scope_gNB(form_gnb, p, nb_ue); + fl_unfreeze_form(form_gnb->phy_scope); + fl_redraw_form(form_gnb->phy_scope); usleep(99*1000); } @@ -801,6 +804,7 @@ static OAI_phy_scope_t *create_phy_scope_nrue( int ID ) { OAI_phy_scope_t *fdui = calloc(( sizeof *fdui ),1); // Define form fdui->phy_scope = fl_bgn_form( FL_NO_BOX, 800, 900 ); + fl_set_form_dblbuffer(fdui->phy_scope, 1); // This the whole UI box obj = fl_add_box( FL_BORDER_BOX, 0, 0, 800, 900, "" ); fl_set_object_color( obj, FL_BLACK, FL_BLACK ); diff --git a/openair1/PHY/TOOLS/time_meas.c b/openair1/PHY/TOOLS/time_meas.c index 996f7fb2777007bf9cf6970d0c70220420f3c116..353f170434a2d4ddbc2cff2d6d4b2a5704186cda 100644 --- a/openair1/PHY/TOOLS/time_meas.c +++ b/openair1/PHY/TOOLS/time_meas.c @@ -25,20 +25,17 @@ #include <unistd.h> #include <string.h> #include "assertions.h" -#ifndef PHYSIM - #include <pthread.h> - #include "common/config/config_userapi.h" -#endif +#include <pthread.h> +#include "common/config/config_userapi.h" +#include <common/utils/threadPool/thread-pool.h> // global var for openair performance profiler int opp_enabled = 0; double cpu_freq_GHz __attribute__ ((aligned(32))); double cpu_freq_GHz __attribute__ ((aligned(32)))=0.0; -#ifndef PHYSIM static uint32_t max_cpumeasur; static time_stats_t **measur_table; notifiedFIFO_t measur_fifo; -#endif double get_cpu_freq_GHz(void) { if (cpu_freq_GHz <1 ) { @@ -54,24 +51,7 @@ double get_cpu_freq_GHz(void) return cpu_freq_GHz; } -int cpumeas(int action) -{ - switch (action) { - case CPUMEAS_ENABLE: - opp_enabled = 1; - break; - - case CPUMEAS_DISABLE: - opp_enabled = 0; - break; - case CPUMEAS_GETSTATE: - default: - break; - } - - return opp_enabled; -} void print_meas_now(time_stats_t *ts, const char *name, @@ -187,7 +167,6 @@ double get_time_meas_us(time_stats_t *ts) return 0; } -#ifndef PHYSIM /* function for the asynchronous measurment module: cpu stat are sent to a dedicated thread * which is in charge of computing the cpu time spent in a given function/algorithm... */ @@ -294,4 +273,3 @@ void end_meas(void) { msg->msgid = TIMESTAT_MSGID_END ; pushNotifiedFIFO(&measur_fifo, nfe); } -#endif diff --git a/openair1/PHY/TOOLS/time_meas.h b/openair1/PHY/TOOLS/time_meas.h index a403675d1d283a608a0395129f052af9206d396f..ed4e9a125f1c5cf496c8819937a8d45df01a711d 100644 --- a/openair1/PHY/TOOLS/time_meas.h +++ b/openair1/PHY/TOOLS/time_meas.h @@ -31,9 +31,7 @@ #include <pthread.h> #include <linux/kernel.h> #include <linux/types.h> -#ifndef PHYSIM - #include "common/utils/threadPool/thread-pool.h" -#endif +#include "common/utils/threadPool/thread-pool.h" // global var to enable openair performance profiler extern int opp_enabled; extern double cpu_freq_GHz __attribute__ ((aligned(32)));; @@ -72,10 +70,8 @@ typedef struct { char *meas_name; /*!< \brief name to use when printing the measure (not used for PHY simulators)*/ int meas_index; /*!< \brief index of this measure in the measure array (not used for PHY simulators)*/ int meas_enabled; /*!< \brief per measure enablement flag. send_meas tests this flag, unused today in start_meas and stop_meas*/ -#ifndef PHYSIM notifiedFIFO_elt_t *tpoolmsg; /*!< \brief message pushed to the cpu measurment queue to report a measure START or STOP */ time_stats_msg_t *tstatptr; /*!< \brief pointer to the time_stats_msg_t data in the tpoolmsg, stored here for perf considerations*/ -#endif } time_stats_t; #define MEASURE_ENABLED(X) (X->meas_enabled) @@ -119,7 +115,24 @@ static inline uint32_t rdtsc_oai(void) { #define CPUMEAS_DISABLE 0 #define CPUMEAS_ENABLE 1 #define CPUMEAS_GETSTATE 2 -int cpumeas(int action); +static inline int cpumeas(int action) { + switch (action) { + case CPUMEAS_ENABLE: + opp_enabled = 1; + break; + + case CPUMEAS_DISABLE: + opp_enabled = 0; + break; + + case CPUMEAS_GETSTATE: + default: + break; + } + + return opp_enabled; +} + static inline void start_meas(time_stats_t *ts) { if (opp_enabled) { if (ts->meas_flag==0) { @@ -166,7 +179,16 @@ static inline void copy_meas(time_stats_t *dst_ts,time_stats_t *src_ts) { } } -#ifndef PHYSIM +static inline void merge_meas(time_stats_t *dst_ts, time_stats_t *src_ts) +{ + if (!opp_enabled) + return; + dst_ts->trials += src_ts->trials; + dst_ts->diff += src_ts->diff; + if (src_ts->max > dst_ts->max) + dst_ts->max = src_ts->max; +} + extern notifiedFIFO_t measur_fifo; #define CPUMEASUR_SECTION "cpumeasur" @@ -188,5 +210,4 @@ extern notifiedFIFO_t measur_fifo; } void end_meas(void); -#endif //ifndef PHYSIM #endif diff --git a/openair1/PHY/defs_gNB.h b/openair1/PHY/defs_gNB.h index 1db4f6328a86a05cfcb16c8aaf5eb7ea153a1887..7c7d30a6e2f21ddb8c5dcf73fa7fb6f809f17320 100644 --- a/openair1/PHY/defs_gNB.h +++ b/openair1/PHY/defs_gNB.h @@ -397,6 +397,16 @@ typedef struct { nfapi_nr_pucch_pdu_t pucch_pdu; } NR_gNB_PUCCH_t; +typedef struct { + uint8_t active; + /// Frame where current SRS pdu was received + uint32_t frame; + /// Slot where current SRS pdu was received + uint32_t slot; + /// ULSCH PDU + nfapi_nr_srs_pdu_t srs_pdu; +} NR_gNB_SRS_t; + typedef struct { /// \brief Pointers (dynamic) to the received data in the time domain. /// - first index: rx antenna [0..nb_antennas_rx[ @@ -594,6 +604,8 @@ typedef struct gNB_L1_proc_t_s { pthread_t L1_stats_thread; /// pthread structure for printing time meas pthread_t process_stats_thread; + /// pthread structure for reordering L1 tx thread messages + pthread_t pthread_tx_reorder; /// flag to indicate first RX acquisition int first_rx; /// flag to indicate first TX transmission @@ -751,11 +763,11 @@ typedef struct PHY_VARS_gNB_s { // nfapi_nr_ul_dci_request_pdus_t *ul_dci_pdu; uint16_t num_pdsch_rnti[80]; NR_gNB_PBCH pbch; - nr_cce_t cce_list[MAX_DCI_CORESET][NR_MAX_PDCCH_AGG_LEVEL]; NR_gNB_COMMON common_vars; NR_gNB_PRACH prach_vars; NR_gNB_PUSCH *pusch_vars[NUMBER_OF_NR_ULSCH_MAX]; NR_gNB_PUCCH_t *pucch[NUMBER_OF_NR_PUCCH_MAX]; + NR_gNB_SRS_t *srs[NUMBER_OF_NR_SRS_MAX]; NR_gNB_PDCCH_t pdcch_pdu[NUMBER_OF_NR_PDCCH_MAX]; NR_gNB_UL_PDCCH_t ul_pdcch_pdu[NUMBER_OF_NR_PDCCH_MAX]; NR_gNB_DLSCH_t *dlsch[NUMBER_OF_NR_DLSCH_MAX][2]; // Nusers times two spatial streams @@ -769,14 +781,14 @@ typedef struct PHY_VARS_gNB_s { NR_gNB_UCI_STATS_t uci_stats[NUMBER_OF_NR_UCI_STATS_MAX]; t_nrPolar_params *uci_polarParams; + /// SRS variables + nr_srs_info_t *nr_srs_info[NUMBER_OF_NR_SRS_MAX]; + uint8_t pbch_configured; char gNB_generate_rar; // PUCCH0 Look-up table for cyclic-shifts NR_gNB_PUCCH0_LUT_t pucch0_lut; - /// NR synchronization sequences - int16_t d_pss[NR_PSS_LENGTH]; - int16_t d_sss[NR_SSS_LENGTH]; /// PBCH DMRS sequence uint32_t nr_gold_pbch_dmrs[2][64][NR_PBCH_DMRS_LENGTH_DWORD]; @@ -844,8 +856,7 @@ typedef struct PHY_VARS_gNB_s { /* time_stats_t phy_proc; */ - time_stats_t *phy_proc_tx_0; - time_stats_t *phy_proc_tx_1; + time_stats_t *phy_proc_tx[2]; time_stats_t phy_proc_rx; time_stats_t rx_prach; /* @@ -887,11 +898,13 @@ typedef struct PHY_VARS_gNB_s { */ notifiedFIFO_t *respDecode; notifiedFIFO_t *resp_L1; - notifiedFIFO_t *resp_L1_tx; + notifiedFIFO_t *L1_tx_free; + notifiedFIFO_t *L1_tx_filled; + notifiedFIFO_t *L1_tx_out; notifiedFIFO_t *resp_RU_tx; tpool_t *threadPool; int nbDecode; - uint8_t pusch_proc_threads; + uint8_t thread_pool_size; int number_of_nr_dlsch_max; int number_of_nr_ulsch_max; void * scopeData; @@ -952,12 +965,14 @@ typedef struct processingData_L1tx { int slot; openair0_timestamp timestamp_tx; PHY_VARS_gNB *gNB; - nfapi_nr_dl_tti_pdcch_pdu pdcch_pdu; - nfapi_nr_ul_dci_request_pdus_t ul_pdcch_pdu; + nfapi_nr_dl_tti_pdcch_pdu pdcch_pdu[NFAPI_NR_MAX_NB_CORESETS]; + nfapi_nr_ul_dci_request_pdus_t ul_pdcch_pdu[NFAPI_NR_MAX_NB_CORESETS]; NR_gNB_CSIRS_t csirs_pdu[NUMBER_OF_NR_CSIRS_MAX]; NR_gNB_DLSCH_t *dlsch[NUMBER_OF_NR_DLSCH_MAX][2]; NR_gNB_SSB_t ssb[64]; uint16_t num_pdsch_slot; + int num_dl_pdcch; + int num_ul_pdcch; time_stats_t phy_proc_tx; } processingData_L1tx_t; diff --git a/openair1/PHY/defs_nr_UE.h b/openair1/PHY/defs_nr_UE.h index 69978f55482aa4675ad4600f7f0dacc44d480330..bca956bf75bcafb31526b77f3a2a803201bb17ad 100644 --- a/openair1/PHY/defs_nr_UE.h +++ b/openair1/PHY/defs_nr_UE.h @@ -706,6 +706,11 @@ typedef struct { fapi_nr_ul_config_prach_pdu prach_pdu; } NR_UE_PRACH; +typedef struct { + bool active; + fapi_nr_ul_config_srs_pdu srs_config_pdu; +} NR_UE_SRS; + // structure used for multiple SSB detection typedef struct NR_UE_SSB { uint8_t i_ssb; // i_ssb between 0 and 7 (it corresponds to ssb_index only for Lmax=4,8) @@ -815,6 +820,7 @@ typedef struct { NR_UE_PBCH *pbch_vars[NUMBER_OF_CONNECTED_gNB_MAX]; NR_UE_PDCCH *pdcch_vars[RX_NB_TH_MAX][NUMBER_OF_CONNECTED_gNB_MAX]; NR_UE_PRACH *prach_vars[NUMBER_OF_CONNECTED_gNB_MAX]; + NR_UE_SRS *srs_vars[NUMBER_OF_CONNECTED_gNB_MAX]; NR_UE_PUSCH *pusch_vars[RX_NB_TH_MAX][NUMBER_OF_CONNECTED_gNB_MAX]; NR_UE_PUCCH *pucch_vars[RX_NB_TH_MAX][NUMBER_OF_CONNECTED_gNB_MAX]; NR_UE_DLSCH_t *dlsch[RX_NB_TH_MAX][NUMBER_OF_CONNECTED_gNB_MAX][NR_MAX_NB_CODEWORDS]; // two RxTx Threads @@ -967,6 +973,8 @@ typedef struct { /// PUSCH contention-based access vars PUSCH_CA_CONFIG_DEDICATED pusch_ca_config_dedicated[NUMBER_OF_eNB_MAX]; // lola + /// SRS variables + nr_srs_info_t *nr_srs_info; //#if defined(UPGRADE_RAT_NR) #if 1 @@ -1004,6 +1012,8 @@ typedef struct { time_stats_t phy_proc_tx; time_stats_t phy_proc_rx[RX_NB_TH]; + time_stats_t ue_ul_indication_stats; + uint32_t use_ia_receiver; time_stats_t ofdm_mod_stats; @@ -1012,7 +1022,6 @@ typedef struct { time_stats_t ulsch_modulation_stats; time_stats_t ulsch_segmentation_stats; time_stats_t ulsch_rate_matching_stats; - time_stats_t ulsch_turbo_encoding_stats; time_stats_t ulsch_interleaving_stats; time_stats_t ulsch_multiplexing_stats; @@ -1025,6 +1034,7 @@ typedef struct { time_stats_t pdsch_procedures_per_slot_stat[RX_NB_TH][LTE_SLOTS_PER_SUBFRAME]; time_stats_t dlsch_procedures_stat[RX_NB_TH]; + time_stats_t rx_pdsch_stats; time_stats_t ofdm_demod_stats; time_stats_t dlsch_rx_pdcch_stats; time_stats_t rx_dft_stats; @@ -1033,13 +1043,13 @@ typedef struct { time_stats_t dlsch_decoding_stats[2]; time_stats_t dlsch_demodulation_stats; time_stats_t dlsch_rate_unmatching_stats; - time_stats_t dlsch_turbo_decoding_stats; + time_stats_t dlsch_ldpc_decoding_stats; time_stats_t dlsch_deinterleaving_stats; time_stats_t dlsch_llr_stats; time_stats_t dlsch_llr_stats_parallelization[RX_NB_TH][LTE_SLOTS_PER_SUBFRAME]; time_stats_t dlsch_unscrambling_stats; time_stats_t dlsch_rate_matching_stats; - time_stats_t dlsch_turbo_encoding_stats; + time_stats_t dlsch_ldpc_encoding_stats; time_stats_t dlsch_interleaving_stats; time_stats_t dlsch_tc_init_stats; time_stats_t dlsch_tc_alpha_stats; @@ -1098,6 +1108,9 @@ typedef struct LDPCDecode_ue_s { int offset; int Tbslbrm; int decodeIterations; + time_stats_t ts_deinterleave; + time_stats_t ts_rate_unmatch; + time_stats_t ts_ldpc_decode; } ldpcDecode_ue_t; #include "SIMULATION/ETH_TRANSPORT/defs.h" diff --git a/openair1/PHY/defs_nr_common.h b/openair1/PHY/defs_nr_common.h index c385d323e3b51e4deddd9a9e5606d8f3c045e00b..78599dcbb65f3ab118aad088eecf24c2101e4fd5 100644 --- a/openair1/PHY/defs_nr_common.h +++ b/openair1/PHY/defs_nr_common.h @@ -107,13 +107,24 @@ #define MAX_NUM_NR_ULSCH_SEGMENTS 34 #define MAX_NR_ULSCH_PAYLOAD_BYTES (MAX_NUM_NR_ULSCH_SEGMENTS*1056) +#define MAX_NUM_NR_SRS_SYMBOLS 4 + #define MAX_NUM_NR_CHANNEL_BITS (14*273*12*8) // 14 symbols, 273 RB #define MAX_NUM_NR_RE (14*273*12) #define NR_RX_NB_TH 1 #define NR_NB_TH_SLOT 2 extern const uint8_t nr_rv_round_map[4]; -extern const uint8_t nr_rv_round_map_ue[4]; + +static inline +uint8_t nr_rv_to_round(uint8_t rv) +{ + for (uint8_t round = 0; round < 4; round++) { + if (nr_rv_round_map[round] == rv) + return round; + } + return 0; +} typedef enum { NR_MU_0=0, @@ -240,6 +251,19 @@ typedef struct { uint8_t init_msg1; } NR_PRACH_RESOURCES_t; +typedef struct { + uint16_t sc_list_length; + uint16_t sc_list[6 * NR_MAX_NB_RB]; + uint8_t srs_generated_signal_bits; + int32_t *srs_generated_signal; + int32_t **srs_received_signal; + int32_t **srs_ls_estimated_channel; + int32_t **srs_estimated_channel_freq; + int32_t **srs_estimated_channel_time; + int32_t **srs_estimated_channel_time_shifted; + uint32_t *noise_power; +} nr_srs_info_t; + typedef struct NR_DL_FRAME_PARMS NR_DL_FRAME_PARMS; typedef uint32_t (*get_samples_per_slot_t)(int slot, NR_DL_FRAME_PARMS* fp); diff --git a/openair1/PHY/impl_defs_nr.h b/openair1/PHY/impl_defs_nr.h index 59d82166790b791a6d6128f85da00d0488f238e9..87d193b4a31aa0c692dfba9d268a249d6576a46f 100644 --- a/openair1/PHY/impl_defs_nr.h +++ b/openair1/PHY/impl_defs_nr.h @@ -211,10 +211,10 @@ typedef enum { srs_sl2560 = 16 } SRS_Periodicity_t; -#define NB_SRS_PERIOD (17) +#define NB_SRS_PERIOD (18) static const uint16_t srs_period[NB_SRS_PERIOD] -= { 1, 2, 4, 5, 8, 10, 16, 20, 32, 40, 64, 80, 160, 320, 640, 1280, 2560} += { 0, 1, 2, 4, 5, 8, 10, 16, 20, 32, 40, 64, 80, 160, 320, 640, 1280, 2560} ; /// SRS_Resource of SRS_Config information element from 38.331 RRC specifications diff --git a/openair1/PHY/impl_defs_top.h b/openair1/PHY/impl_defs_top.h index 31b98996057b1a677d1c2cfed93d6ceff0750417..ad68bc5769113e0f067ddf66188d410184e13537 100644 --- a/openair1/PHY/impl_defs_top.h +++ b/openair1/PHY/impl_defs_top.h @@ -107,11 +107,10 @@ * @} */ +#include <common/utils/utils.h> #include "defs_eNB.h" #include "types.h" - - /** @addtogroup _PHY_STRUCTURES_ * @{ */ @@ -315,50 +314,6 @@ typedef struct { #include "openairinterface5g_limits.h" #include "assertions.h" -#define cmax(a,b) ((a>b) ? (a) : (b)) -#define cmax3(a,b,c) ((cmax(a,b)>c) ? (cmax(a,b)) : (c)) -#define cmin(a,b) ((a<b) ? (a) : (b)) - -#ifdef __cplusplus -#ifdef min -#undef min -#undef max -#endif -#else -#define max(a,b) cmax(a,b) -#define min(a,b) cmin(a,b) -#endif - -#ifndef malloc16 -# ifdef __AVX2__ -# define malloc16(x) memalign(32,x+32) -# else -# define malloc16(x) memalign(16,x+16) -# endif -#endif -#define free16(y,x) free(y) -#define bigmalloc malloc -#define bigmalloc16 malloc16 -#define openair_free(y,x) free((y)) -#define PAGE_SIZE 4096 -#define free_and_zero(PtR) do { \ - if (PtR) { \ - free(PtR); \ - PtR = NULL; \ - } \ - } while (0) -static inline void* malloc16_clear( size_t size ) -{ -#ifdef __AVX2__ - void* ptr = memalign(32, size+32); -#else - void* ptr = memalign(16, size+16); -#endif - DevAssert(ptr); - memset( ptr, 0, size ); - return ptr; -} - #endif //__PHY_IMPLEMENTATION_DEFS_H__ /**@} */ diff --git a/openair1/PHY/phy_vars.h b/openair1/PHY/phy_vars.h index 58797848271b735bec713c2b62b4494eb1b63407..d99a3016ba6a07a012cb9a6f1640c156fedd495f 100644 --- a/openair1/PHY/phy_vars.h +++ b/openair1/PHY/phy_vars.h @@ -24,6 +24,7 @@ #include "PHY/types.h" #include "PHY/defs_eNB.h" +#include "PHY/defs_gNB.h" #include "PHY/defs_UE.h" char* namepointer_chMag ; @@ -42,6 +43,7 @@ char* namepointer_log2; PHY_VARS_UE ***PHY_vars_UE_g; UL_RCC_IND_t UL_RCC_INFO; +NR_UL_IND_t UL_INFO; unsigned short rev[2048],rev_times4[8192],rev_half[1024]; unsigned short rev256[256],rev512[512],rev1024[1024],rev4096[4096],rev2048[2048],rev8192[8192]; @@ -80,7 +82,6 @@ const double sinr_to_cqi[4][16]= { {-2.5051, -2.5051, -1.7451, -0.3655, 1.0812, { -4.1057, -4.1057, -3.3768, -2.2916, -1.1392, 0.1236, 1.2849, 3.1933, 5.9298, 6.4052, 9.6245, 10.9414, 13.5166, 14.9545, 14.9545, 14.9545} }; -//int cqi_to_mcs[16]={0, 0, 1, 3, 5, 7, 9, 13, 15, 16, 20, 23, 25, 27, 27, 27}; const int cqi_to_mcs[16]= {0, 0, 1, 2, 4, 6, 8, 11, 13, 16, 18, 20, 23, 25, 27, 28}; //for SNR to MI conversion 7 th order Polynomial coeff diff --git a/openair1/PHY/phy_vars_nr_ue.h b/openair1/PHY/phy_vars_nr_ue.h index cfdfbeb49d009b9fd4c1f70c642b5e70e9cf367a..550a2f0394665bda6fef28b3ca8f5acc42defd25 100644 --- a/openair1/PHY/phy_vars_nr_ue.h +++ b/openair1/PHY/phy_vars_nr_ue.h @@ -83,9 +83,6 @@ const double sinr_to_cqi[4][16]= { {-2.5051, -2.5051, -1.7451, -0.3655, 1.0812, { -4.1057, -4.1057, -3.3768, -2.2916, -1.1392, 0.1236, 1.2849, 3.1933, 5.9298, 6.4052, 9.6245, 10.9414, 13.5166, 14.9545, 14.9545, 14.9545} }; -//int cqi_to_mcs[16]={0, 0, 1, 3, 5, 7, 9, 13, 15, 16, 20, 23, 25, 27, 27, 27}; -const int cqi_to_mcs[16]= {0, 0, 1, 2, 4, 6, 8, 11, 13, 16, 18, 20, 23, 25, 27, 28}; - //for SNR to MI conversion 7 th order Polynomial coeff const double q_qam16[8]= {3.21151853033897e-10,5.55435952230651e-09,-2.30760065362117e-07,-6.25587743817859e-06,4.62251036452795e-06,0.00224150813158937,0.0393723140344367,0.245486379182639}; const double q_qpsk[8]= {1.94491167814437e-09,8.40494123817774e-08,4.75527131198034e-07,-2.48946285301621e-05,-0.000347614016158364,0.00209252225437100,0.0742986115462510,0.488297879889425}; diff --git a/openair1/PHY/phy_vars_ue.h b/openair1/PHY/phy_vars_ue.h index ca35ab6629c765e33af7d22616a54cd67a308340..2cdec82f0f9565a9fd2519c7460ff476ad531e43 100644 --- a/openair1/PHY/phy_vars_ue.h +++ b/openair1/PHY/phy_vars_ue.h @@ -72,7 +72,6 @@ const double sinr_to_cqi[4][16]= { {-2.5051, -2.5051, -1.7451, -0.3655, 1.0812, { -4.1057, -4.1057, -3.3768, -2.2916, -1.1392, 0.1236, 1.2849, 3.1933, 5.9298, 6.4052, 9.6245, 10.9414, 13.5166, 14.9545, 14.9545, 14.9545} }; -//int cqi_to_mcs[16]={0, 0, 1, 3, 5, 7, 9, 13, 15, 16, 20, 23, 25, 27, 27, 27}; const int cqi_to_mcs[16]= {0, 0, 1, 2, 4, 6, 8, 11, 13, 16, 18, 20, 23, 25, 27, 28}; //for SNR to MI conversion 7 th order Polynomial coeff diff --git a/openair1/SCHED/phy_procedures_lte_eNb.c b/openair1/SCHED/phy_procedures_lte_eNb.c index 973c921d2347d7c14f276af87255c83a067b5988..569d2a464a10397b72744f025d4a198375312c40 100644 --- a/openair1/SCHED/phy_procedures_lte_eNb.c +++ b/openair1/SCHED/phy_procedures_lte_eNb.c @@ -755,6 +755,7 @@ void fill_sr_indication(int UEid, PHY_VARS_eNB *eNB,uint16_t rnti,int frame,int pthread_mutex_lock(&eNB->UL_INFO_mutex); nfapi_sr_indication_t *sr_ind = &eNB->UL_INFO.sr_ind; nfapi_sr_indication_body_t *sr_ind_body = &sr_ind->sr_indication_body; + assert(sr_ind_body->number_of_srs <= NFAPI_SR_IND_MAX_PDU); nfapi_sr_indication_pdu_t *pdu = &sr_ind_body->sr_pdu_list[sr_ind_body->number_of_srs]; sr_ind->sfn_sf = frame<<4|subframe; sr_ind->header.message_id = NFAPI_RX_SR_INDICATION; @@ -1580,6 +1581,7 @@ void fill_rx_indication(PHY_VARS_eNB *eNB, pthread_mutex_lock(&eNB->UL_INFO_mutex); eNB->UL_INFO.rx_ind.sfn_sf = frame<<4| subframe; eNB->UL_INFO.rx_ind.rx_indication_body.tl.tag = NFAPI_RX_INDICATION_BODY_TAG; + assert(eNB->UL_INFO.rx_ind.rx_indication_body.number_of_pdus <= NFAPI_RX_IND_MAX_PDU); pdu = &eNB->UL_INFO.rx_ind.rx_indication_body.rx_pdu_list[eNB->UL_INFO.rx_ind.rx_indication_body.number_of_pdus]; // pdu->rx_ue_information.handle = eNB->ulsch[ULSCH_id]->handle; pdu->rx_ue_information.tl.tag = NFAPI_RX_UE_INFORMATION_TAG; @@ -1587,7 +1589,11 @@ void fill_rx_indication(PHY_VARS_eNB *eNB, pdu->rx_indication_rel8.tl.tag = NFAPI_RX_INDICATION_REL8_TAG; pdu->rx_indication_rel8.length = eNB->ulsch[ULSCH_id]->harq_processes[harq_pid]->TBS>>3; pdu->rx_indication_rel8.offset = 1; // DJP - I dont understand - but broken unless 1 ???? 0; // filled in at the end of the UL_INFO formation - pdu->data = eNB->ulsch[ULSCH_id]->harq_processes[harq_pid]->decodedBytes; + assert(pdu->rx_indication_rel8.length <= NFAPI_RX_IND_DATA_MAX); + memcpy(pdu->rx_ind_data, + eNB->ulsch[ULSCH_id]->harq_processes[harq_pid]->decodedBytes, + pdu->rx_indication_rel8.length); + // estimate timing advance for MAC sync_pos = lte_est_timing_advance_pusch(&eNB->frame_parms, eNB->pusch_vars[ULSCH_id]->drs_ch_estimates_time); timing_advance_update = sync_pos; @@ -1832,6 +1838,7 @@ int getM(PHY_VARS_eNB *eNB,int frame,int subframe) { void fill_ulsch_cqi_indication (PHY_VARS_eNB *eNB, uint16_t frame, uint8_t subframe, LTE_UL_eNB_HARQ_t *ulsch_harq, uint16_t rnti) { pthread_mutex_lock (&eNB->UL_INFO_mutex); + assert(eNB->UL_INFO.cqi_ind.cqi_indication_body.number_of_cqis <= NFAPI_CQI_IND_MAX_PDU); nfapi_cqi_indication_pdu_t *pdu = &eNB->UL_INFO.cqi_ind.cqi_indication_body.cqi_pdu_list[eNB->UL_INFO.cqi_ind.cqi_indication_body.number_of_cqis]; nfapi_cqi_indication_raw_pdu_t *raw_pdu = &eNB->UL_INFO.cqi_ind.cqi_indication_body.cqi_raw_pdu_list[eNB->UL_INFO.cqi_ind.cqi_indication_body.number_of_cqis]; pdu->instance_length = 0; @@ -1878,6 +1885,7 @@ void fill_ulsch_harq_indication (PHY_VARS_eNB *eNB, LTE_UL_eNB_HARQ_t *ulsch_har //AssertFatal(DLSCH_id>=0,"DLSCH_id doesn't exist\n"); pthread_mutex_lock(&eNB->UL_INFO_mutex); + assert(eNB->UL_INFO.harq_ind.harq_indication_body.number_of_harqs <= NFAPI_HARQ_IND_MAX_PDU); nfapi_harq_indication_pdu_t *pdu = &eNB->UL_INFO.harq_ind.harq_indication_body.harq_pdu_list[eNB->UL_INFO.harq_ind.harq_indication_body.number_of_harqs]; int M; int i; @@ -1948,6 +1956,7 @@ void fill_uci_harq_indication (int UEid, PHY_VARS_eNB *eNB, LTE_eNB_UCI *uci, in pthread_mutex_lock(&eNB->UL_INFO_mutex); nfapi_harq_indication_t *ind = &eNB->UL_INFO.harq_ind; nfapi_harq_indication_body_t *body = &ind->harq_indication_body; + assert(eNB->UL_INFO.harq_ind.harq_indication_body.number_of_harqs <= NFAPI_HARQ_IND_MAX_PDU); nfapi_harq_indication_pdu_t *pdu = &body->harq_pdu_list[eNB->UL_INFO.harq_ind.harq_indication_body.number_of_harqs]; ind->sfn_sf = frame<<4|subframe; ind->header.message_id = NFAPI_HARQ_INDICATION; @@ -2124,6 +2133,7 @@ void fill_uci_harq_indication (int UEid, PHY_VARS_eNB *eNB, LTE_eNB_UCI *uci, in void fill_crc_indication (PHY_VARS_eNB *eNB, int ULSCH_id, int frame, int subframe, uint8_t crc_flag) { pthread_mutex_lock(&eNB->UL_INFO_mutex); + assert(eNB->UL_INFO.crc_ind.crc_indication_body.number_of_crcs <= NFAPI_CRC_IND_MAX_PDU); nfapi_crc_indication_pdu_t *pdu = &eNB->UL_INFO.crc_ind.crc_indication_body.crc_pdu_list[eNB->UL_INFO.crc_ind.crc_indication_body.number_of_crcs]; eNB->UL_INFO.crc_ind.sfn_sf = frame<<4 | subframe; eNB->UL_INFO.crc_ind.header.message_id = NFAPI_CRC_INDICATION; diff --git a/openair1/SCHED_NR/fapi_nr_l1.c b/openair1/SCHED_NR/fapi_nr_l1.c index f9d90d9204d49560ba760e2810711d05e56abcd2..2dbaa738dc364a279592c7821879e5f176af683b 100644 --- a/openair1/SCHED_NR/fapi_nr_l1.c +++ b/openair1/SCHED_NR/fapi_nr_l1.c @@ -149,9 +149,10 @@ void nr_schedule_response(NR_Sched_Rsp_t *Sched_INFO){ gNB = RC.gNB[Mod_id]; start_meas(&gNB->schedule_response_stats); - notifiedFIFO_elt_t *res; - res = pullTpool(gNB->resp_L1_tx, gNB->threadPool); - processingData_L1tx_t *msgTx = (processingData_L1tx_t *)NotifiedFifoData(res); + + nfapi_nr_config_request_scf_t *cfg = &gNB->gNB_config; + + int slot_type = nr_slot_select(cfg,frame,slot); uint8_t number_dl_pdu = (DL_req==NULL) ? 0 : DL_req->dl_tti_request_body.nPDUs; uint8_t number_ul_dci_pdu = (UL_dci_req==NULL) ? 0 : UL_dci_req->numPdus; @@ -159,59 +160,56 @@ void nr_schedule_response(NR_Sched_Rsp_t *Sched_INFO){ uint8_t number_tx_data_pdu = (TX_req == NULL) ? 0 : TX_req->Number_of_PDUs; if (NFAPI_MODE == NFAPI_MONOLITHIC){ - if (DL_req != NULL && TX_req!=NULL && (number_dl_pdu > 0 || number_ul_dci_pdu > 0 || number_ul_tti_pdu > 0)) - LOG_D(PHY,"NFAPI: Sched_INFO:SFN/SLOT:%04d/%d DL_req:SFN/SLO:%04d/%d:dl_pdu:%d tx_req:SFN/SLOT:%04d/%d:pdus:%d;ul_dci %d ul_tti %d\n", - frame,slot, - DL_req->SFN,DL_req->Slot,number_dl_pdu, - TX_req->SFN,TX_req->Slot,TX_req->Number_of_PDUs, - number_ul_dci_pdu,number_ul_tti_pdu); - - int pdcch_received=0; - msgTx->num_pdsch_slot=0; - msgTx->pdcch_pdu.pdcch_pdu_rel15.numDlDci = 0; - msgTx->ul_pdcch_pdu.pdcch_pdu.pdcch_pdu_rel15.numDlDci = 0; - msgTx->slot = slot; - msgTx->frame = frame; - - for (int i=0;i<number_dl_pdu;i++) { - nfapi_nr_dl_tti_request_pdu_t *dl_tti_pdu = &DL_req->dl_tti_request_body.dl_tti_pdu_list[i]; - LOG_D(PHY,"NFAPI: dl_pdu %d : type %d\n",i,dl_tti_pdu->PDUType); - switch (dl_tti_pdu->PDUType) { - case NFAPI_NR_DL_TTI_SSB_PDU_TYPE: - handle_nr_nfapi_ssb_pdu(msgTx,frame,slot, - dl_tti_pdu); - break; - case NFAPI_NR_DL_TTI_PDCCH_PDU_TYPE: - AssertFatal(pdcch_received == 0, "pdcch_received is not 0, we can only handle one PDCCH PDU per slot\n"); - msgTx->pdcch_pdu = dl_tti_pdu->pdcch_pdu; - - pdcch_received = 1; - break; - - case NFAPI_NR_DL_TTI_CSI_RS_PDU_TYPE: - LOG_D(PHY,"frame %d, slot %d, Got NFAPI_NR_DL_TTI_CSI_RS_PDU_TYPE for %d.%d\n",frame,slot,DL_req->SFN,DL_req->Slot); - handle_nfapi_nr_csirs_pdu(msgTx,frame,slot, - &dl_tti_pdu->csi_rs_pdu); - break; - - case NFAPI_NR_DL_TTI_PDSCH_PDU_TYPE: - LOG_D(PHY,"frame %d, slot %d, Got NFAPI_NR_DL_TTI_PDSCH_PDU_TYPE for %d.%d\n",frame,slot,DL_req->SFN,DL_req->Slot); - nfapi_nr_dl_tti_pdsch_pdu_rel15_t *pdsch_pdu_rel15 = &dl_tti_pdu->pdsch_pdu.pdsch_pdu_rel15; - uint16_t pduIndex = pdsch_pdu_rel15->pduIndex; - AssertFatal(TX_req->pdu_list[pduIndex].num_TLV == 1, "TX_req->pdu_list[%d].num_TLV %d != 1\n", - pduIndex,TX_req->pdu_list[pduIndex].num_TLV); - uint8_t *sdu = (uint8_t *)TX_req->pdu_list[pduIndex].TLVs[0].value.direct; - AssertFatal(msgTx->num_pdsch_slot < gNB->number_of_nr_dlsch_max,"Number of PDSCH PDUs %d exceeded the limit %d\n", - msgTx->num_pdsch_slot,gNB->number_of_nr_dlsch_max); - handle_nr_nfapi_pdsch_pdu(msgTx,&dl_tti_pdu->pdsch_pdu, sdu); + if (slot_type == NR_DOWNLINK_SLOT || slot_type == NR_MIXED_SLOT) { + notifiedFIFO_elt_t *res; + res = pullTpool(gNB->L1_tx_free, gNB->threadPool); + processingData_L1tx_t *msgTx = (processingData_L1tx_t *)NotifiedFifoData(res); + + msgTx->num_pdsch_slot=0; + msgTx->num_dl_pdcch=0; + msgTx->num_ul_pdcch=number_ul_dci_pdu; + msgTx->slot = slot; + msgTx->frame = frame; + + for (int i=0;i<number_dl_pdu;i++) { + nfapi_nr_dl_tti_request_pdu_t *dl_tti_pdu = &DL_req->dl_tti_request_body.dl_tti_pdu_list[i]; + LOG_D(PHY,"NFAPI: dl_pdu %d : type %d\n",i,dl_tti_pdu->PDUType); + switch (dl_tti_pdu->PDUType) { + case NFAPI_NR_DL_TTI_SSB_PDU_TYPE: + handle_nr_nfapi_ssb_pdu(msgTx,frame,slot, + dl_tti_pdu); + break; + + case NFAPI_NR_DL_TTI_PDCCH_PDU_TYPE: + LOG_D(PHY,"frame %d, slot %d, Got NFAPI_NR_DL_TTI_PDCCH_PDU_TYPE for %d.%d\n",frame,slot,DL_req->SFN,DL_req->Slot); + msgTx->pdcch_pdu[msgTx->num_dl_pdcch] = dl_tti_pdu->pdcch_pdu; + msgTx->num_dl_pdcch++; + break; + + case NFAPI_NR_DL_TTI_CSI_RS_PDU_TYPE: + LOG_D(PHY,"frame %d, slot %d, Got NFAPI_NR_DL_TTI_CSI_RS_PDU_TYPE for %d.%d\n",frame,slot,DL_req->SFN,DL_req->Slot); + handle_nfapi_nr_csirs_pdu(msgTx,frame,slot,&dl_tti_pdu->csi_rs_pdu); + break; + + case NFAPI_NR_DL_TTI_PDSCH_PDU_TYPE: + LOG_D(PHY,"frame %d, slot %d, Got NFAPI_NR_DL_TTI_PDSCH_PDU_TYPE for %d.%d\n",frame,slot,DL_req->SFN,DL_req->Slot); + nfapi_nr_dl_tti_pdsch_pdu_rel15_t *pdsch_pdu_rel15 = &dl_tti_pdu->pdsch_pdu.pdsch_pdu_rel15; + uint16_t pduIndex = pdsch_pdu_rel15->pduIndex; + AssertFatal(TX_req->pdu_list[pduIndex].num_TLV == 1, "TX_req->pdu_list[%d].num_TLV %d != 1\n", + pduIndex,TX_req->pdu_list[pduIndex].num_TLV); + uint8_t *sdu = (uint8_t *)TX_req->pdu_list[pduIndex].TLVs[0].value.direct; + AssertFatal(msgTx->num_pdsch_slot < gNB->number_of_nr_dlsch_max,"Number of PDSCH PDUs %d exceeded the limit %d\n", + msgTx->num_pdsch_slot,gNB->number_of_nr_dlsch_max); + handle_nr_nfapi_pdsch_pdu(msgTx,&dl_tti_pdu->pdsch_pdu, sdu); + } } - } - if (number_ul_dci_pdu > 0) - msgTx->ul_pdcch_pdu = UL_dci_req->ul_dci_pdu_list[number_ul_dci_pdu-1]; // copy the last pdu + for (int i=0; i<number_ul_dci_pdu; i++) + msgTx->ul_pdcch_pdu[i] = UL_dci_req->ul_dci_pdu_list[i]; - pushNotifiedFIFO(gNB->resp_L1_tx,res); + pushNotifiedFIFO(gNB->L1_tx_filled,res); + } for (int i = 0; i < number_ul_tti_pdu; i++) { switch (UL_tti_req->pdus_list[i].pdu_type) { @@ -229,6 +227,10 @@ void nr_schedule_response(NR_Sched_Rsp_t *Sched_INFO){ nr_fill_prach(gNB, UL_tti_req->SFN, UL_tti_req->Slot, prach_pdu); if (gNB->RU_list[0]->if_south == LOCAL_RF) nr_fill_prach_ru(gNB->RU_list[0], UL_tti_req->SFN, UL_tti_req->Slot, prach_pdu); break; + case NFAPI_NR_UL_CONFIG_SRS_PDU_TYPE: + LOG_D(PHY,"frame %d, slot %d, Got NFAPI_NR_UL_CONFIG_SRS_PDU_TYPE for %d.%d\n", frame, slot, UL_tti_req->SFN, UL_tti_req->Slot); + nr_fill_srs(gNB,UL_tti_req->SFN, UL_tti_req->Slot, &UL_tti_req->pdus_list[i].srs_pdu); + break; } } } @@ -241,12 +243,12 @@ void nr_schedule_response(NR_Sched_Rsp_t *Sched_INFO){ if (number_ul_dci_pdu>0) oai_nfapi_ul_dci_req(UL_dci_req); - if (number_dl_pdu>0) - oai_nfapi_dl_tti_req(DL_req); - if (number_tx_data_pdu>0) oai_nfapi_tx_data_req(TX_req); + if (number_dl_pdu>0) + oai_nfapi_dl_tti_req(DL_req); + } stop_meas(&gNB->schedule_response_stats); } diff --git a/openair1/SCHED_NR/nr_ru_procedures.c b/openair1/SCHED_NR/nr_ru_procedures.c index d8fa11d1571cba60bfdccd1ec96967e616170398..4d3174007a62d7895fbe92f32ceb4bc6c1ed6c34 100644 --- a/openair1/SCHED_NR/nr_ru_procedures.c +++ b/openair1/SCHED_NR/nr_ru_procedures.c @@ -155,7 +155,7 @@ void nr_feptx_ofdm_2thread(RU_t *ru,int frame_tx,int tti_tx) { int aa = 0;//physical antenna number int ret = 0; int ofdm_mask_full = (1<<(ru->nb_tx*2))-1; - int txdataF_offset = ((tti_tx%2)*fp->samples_per_slot_wCP); + int txdataF_offset = (tti_tx*fp->samples_per_slot_wCP); if (nr_slot_select(cfg,frame_tx,slot) == NR_UPLINK_SLOT) return; for (aa=0; aa<ru->nb_tx; aa++) memset(ru->common.txdataF[aa],0,fp->samples_per_slot_wCP*sizeof(int32_t)); @@ -300,7 +300,7 @@ static void *nr_feptx_thread(void *param) { ofdm_mask_full = (1<<(ru->nb_tx*2))-1; if(ru->num_gNB != 0){ - txdataF_offset = ((slot%2)*fp->samples_per_slot_wCP); + txdataF_offset = (slot*fp->samples_per_slot_wCP); ////////////precoding//////////// VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_PHY_PROCEDURES_RU_FEPTX_PREC+feptx->index+1 , 1); @@ -464,7 +464,7 @@ void nr_feptx_prec(RU_t *ru,int frame_tx,int tti_tx) { int32_t ***bw; int i=0; int slot_tx = tti_tx; - int txdataF_offset = ((tti_tx%2)*fp->samples_per_slot_wCP); + int txdataF_offset = (tti_tx*fp->samples_per_slot_wCP); start_meas(&ru->precoding_stats); AssertFatal(ru->nb_log_antennas > 0,"ru->nb_log_antennas is 0!\n"); @@ -477,9 +477,10 @@ void nr_feptx_prec(RU_t *ru,int frame_tx,int tti_tx) { memcpy((void*)ru->common.txdataF[i], (void*)&gNB->common_vars.txdataF[i][txdataF_offset], fp->samples_per_slot_wCP*sizeof(int32_t)); - memcpy((void*)&ru->common.beam_id[i][slot_tx*fp->symbols_per_slot], - (void*)&gNB->common_vars.beam_id[i][slot_tx*fp->symbols_per_slot], - fp->symbols_per_slot*sizeof(uint8_t)); + if (ru->do_precoding == 1) + memcpy((void*)&ru->common.beam_id[i][slot_tx*fp->symbols_per_slot], + (void*)&gNB->common_vars.beam_id[i][slot_tx*fp->symbols_per_slot], + fp->symbols_per_slot*sizeof(uint8_t)); } if (ru->nb_tx == 1 && ru->nb_log_antennas == 1) { diff --git a/openair1/SCHED_NR/phy_procedures_nr_gNB.c b/openair1/SCHED_NR/phy_procedures_nr_gNB.c index 1685e206ae45105829d69560cd7b12db850620c8..7e9f4d091a988f649f830ed3d9f507d8c997f826 100644 --- a/openair1/SCHED_NR/phy_procedures_nr_gNB.c +++ b/openair1/SCHED_NR/phy_procedures_nr_gNB.c @@ -19,19 +19,13 @@ * contact@openairinterface.org */ -#include "PHY/phy_extern.h" #include "PHY/defs_gNB.h" #include "sched_nr.h" -#include "PHY/NR_REFSIG/dmrs_nr.h" #include "PHY/NR_TRANSPORT/nr_transport_proto.h" #include "PHY/NR_TRANSPORT/nr_dlsch.h" #include "PHY/NR_TRANSPORT/nr_ulsch.h" #include "PHY/NR_TRANSPORT/nr_dci.h" #include "PHY/NR_ESTIMATION/nr_ul_estimation.h" -#include "PHY/NR_UE_TRANSPORT/pucch_nr.h" -#include "SCHED/sched_eNB.h" -#include "sched_nr.h" -#include "SCHED/sched_common_extern.h" #include "nfapi/open-nFAPI/nfapi/public_inc/nfapi_interface.h" #include "nfapi/open-nFAPI/nfapi/public_inc/nfapi_nr_interface.h" #include "fapi_nr_l1.h" @@ -39,6 +33,7 @@ #include "common/utils/LOG/vcd_signal_dumper.h" #include "PHY/INIT/phy_init.h" #include "PHY/MODULATION/nr_modulation.h" +#include "PHY/NR_UE_TRANSPORT/srs_modulation_nr.h" #include "T.h" #include "executables/nr-softmodem.h" #include "executables/softmodem-common.h" @@ -74,7 +69,7 @@ void nr_common_signal_procedures (PHY_VARS_gNB *gNB,int frame,int slot,nfapi_nr_ int **txdataF = gNB->common_vars.txdataF; uint8_t ssb_index, n_hf; uint16_t ssb_start_symbol; - int txdataF_offset = (slot%2)*fp->samples_per_slot_wCP; + int txdataF_offset = slot*fp->samples_per_slot_wCP; uint16_t slots_per_hf = (fp->slots_per_frame)>>1; if (slot<slots_per_hf) @@ -91,8 +86,8 @@ void nr_common_signal_procedures (PHY_VARS_gNB *gNB,int frame,int slot,nfapi_nr_ nr_set_ssb_first_subcarrier(cfg, fp); // setting the first subcarrier LOG_D(PHY,"SS TX: frame %d, slot %d, start_symbol %d\n",frame,slot, ssb_start_symbol); - nr_generate_pss(gNB->d_pss, &txdataF[0][txdataF_offset], AMP, ssb_start_symbol, cfg, fp); - nr_generate_sss(gNB->d_sss, &txdataF[0][txdataF_offset], AMP, ssb_start_symbol, cfg, fp); + nr_generate_pss(&txdataF[0][txdataF_offset], AMP, ssb_start_symbol, cfg, fp); + nr_generate_sss(&txdataF[0][txdataF_offset], AMP, ssb_start_symbol, cfg, fp); if (cfg->carrier_config.num_tx_ant.value <= 4) nr_generate_pbch_dmrs(gNB->nr_gold_pbch_dmrs[n_hf][ssb_index&7],&txdataF[0][txdataF_offset], AMP, ssb_start_symbol, cfg, fp); @@ -114,8 +109,7 @@ void nr_common_signal_procedures (PHY_VARS_gNB *gNB,int frame,int slot,nfapi_nr_ gNB->common_vars.beam_id[0][slot*fp->symbols_per_slot+j] = cfg->ssb_table.ssb_beam_id_list[ssb_index].beam_id.value; } - nr_generate_pbch(&gNB->pbch, - &ssb_pdu, + nr_generate_pbch(&ssb_pdu, gNB->nr_pbch_interleaver, &txdataF[0][txdataF_offset], AMP, @@ -128,12 +122,13 @@ void phy_procedures_gNB_TX(processingData_L1tx_t *msgTx, int frame, int slot, int do_meas) { + int aa; PHY_VARS_gNB *gNB = msgTx->gNB; NR_DL_FRAME_PARMS *fp=&gNB->frame_parms; nfapi_nr_config_request_scf_t *cfg = &gNB->gNB_config; int offset = gNB->CC_id; - int txdataF_offset = (slot%2)*fp->samples_per_slot_wCP; + int txdataF_offset = slot*fp->samples_per_slot_wCP; if ((cfg->cell_config.frame_duplex_type.value == TDD) && (nr_slot_select(cfg,frame,slot) == NR_UPLINK_SLOT)) return; @@ -158,18 +153,15 @@ void phy_procedures_gNB_TX(processingData_L1tx_t *msgTx, VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_PHY_PROCEDURES_gNB_COMMON_TX,0); - int num_dl_dci = msgTx->pdcch_pdu.pdcch_pdu_rel15.numDlDci; - int num_ul_dci = msgTx->ul_pdcch_pdu.pdcch_pdu.pdcch_pdu_rel15.numDlDci; + int num_pdcch_pdus = msgTx->num_ul_pdcch + msgTx->num_dl_pdcch; - if (num_dl_dci > 0 || num_ul_dci > 0) { - LOG_D(PHY, "[gNB %d] Frame %d slot %d Calling nr_generate_dci_top (number of UL/DL DCI %d/%d)\n", - gNB->Mod_id, frame, slot, num_ul_dci, num_dl_dci); + if (num_pdcch_pdus > 0) { + LOG_D(PHY, "[gNB %d] Frame %d slot %d Calling nr_generate_dci_top (number of UL/DL PDCCH PDUs %d/%d)\n", + gNB->Mod_id, frame, slot, msgTx->num_ul_pdcch, msgTx->num_dl_pdcch); VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_PHY_gNB_PDCCH_TX,1); - nr_generate_dci_top(gNB, - num_dl_dci > 0 ? &msgTx->pdcch_pdu : NULL, - num_ul_dci > 0 ? &msgTx->ul_pdcch_pdu.pdcch_pdu : NULL, + nr_generate_dci_top(msgTx, gNB->nr_gold_pdcch_dmrs[slot], &gNB->common_vars.txdataF[0][txdataF_offset], AMP, fp); @@ -186,7 +178,7 @@ void phy_procedures_gNB_TX(processingData_L1tx_t *msgTx, for (int i=0;i<NUMBER_OF_NR_CSIRS_MAX;i++){ NR_gNB_CSIRS_t *csirs = &msgTx->csirs_pdu[i]; - if ((csirs->active == 1)) { + if (csirs->active == 1) { LOG_D(PHY, "CSI-RS generation started in frame %d.%d\n",frame,slot); nfapi_nr_dl_tti_csi_rs_pdu_rel15_t csi_params = csirs->csirs_pdu.csi_rs_pdu_rel15; nr_generate_csi_rs(gNB, AMP, csi_params, gNB->gNB_config.cell_config.phy_cell_id.value, slot); @@ -194,8 +186,6 @@ void phy_procedures_gNB_TX(processingData_L1tx_t *msgTx, } } - if (do_meas==1) stop_meas(&msgTx->phy_proc_tx); - // if ((frame&127) == 0) dump_pdsch_stats(gNB); //apply the OFDM symbol rotation here @@ -204,18 +194,9 @@ void phy_procedures_gNB_TX(processingData_L1tx_t *msgTx, } VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_PHY_PROCEDURES_gNB_TX+offset,0); -} - - - -/* - if ((cfg->subframe_config.duplex_mode.value == TDD) && - ((nr_slot_select(fp,frame,slot)&NR_DOWNLINK_SLOT)==SF_DL)) return; - - // VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_PHY_PROCEDURES_ENB_RX,1); - -*/ + if (do_meas==1) stop_meas(&msgTx->phy_proc_tx); +} void nr_postDecode(PHY_VARS_gNB *gNB, notifiedFIFO_elt_t *req) { ldpcDecode_t *rdata = (ldpcDecode_t*) NotifiedFifoData(req); @@ -263,7 +244,7 @@ void nr_postDecode(PHY_VARS_gNB *gNB, notifiedFIFO_elt_t *req) { nr_fill_indication(gNB,ulsch_harq->frame, ulsch_harq->slot, rdata->ulsch_id, rdata->harq_pid, 0,0); //dumpsig=1; } else { - LOG_I(PHY,"[gNB %d] ULSCH: Setting NAK for SFN/SF %d/%d (pid %d, ndi %d, status %d, round %d, RV %d, prb_start %d, prb_size %d, TBS %d) r %d\n", + LOG_D(PHY,"[gNB %d] ULSCH: Setting NAK for SFN/SF %d/%d (pid %d, ndi %d, status %d, round %d, RV %d, prb_start %d, prb_size %d, TBS %d) r %d\n", gNB->Mod_id, ulsch_harq->frame, ulsch_harq->slot, rdata->harq_pid, pusch_pdu->pusch_data.new_data_indicator, ulsch_harq->status, ulsch_harq->round, @@ -358,10 +339,11 @@ void nr_ulsch_procedures(PHY_VARS_gNB *gNB, int frame_rx, int slot_rx, int ULSCH number_dmrs_symbols, // number of dmrs symbols irrespective of single or double symbol dmrs pusch_pdu->qam_mod_order, pusch_pdu->nrOfLayers); - LOG_D(PHY,"rb_size %d, number_symbols %d, nb_re_dmrs %d, number_dmrs_symbols %d, qam_mod_order %d, nrOfLayer %d\n", + LOG_D(PHY,"rb_size %d, number_symbols %d, nb_re_dmrs %d, dmrs symbol positions %d, number_dmrs_symbols %d, qam_mod_order %d, nrOfLayer %d\n", pusch_pdu->rb_size, number_symbols, nb_re_dmrs, + pusch_pdu->ul_dmrs_symb_pos, number_dmrs_symbols, // number of dmrs symbols irrespective of single or double symbol dmrs pusch_pdu->qam_mod_order, pusch_pdu->nrOfLayers); @@ -369,11 +351,10 @@ void nr_ulsch_procedures(PHY_VARS_gNB *gNB, int frame_rx, int slot_rx, int ULSCH //------------------- ULSCH unscrambling ------------------- //---------------------------------------------------------- start_meas(&gNB->ulsch_unscrambling_stats); - nr_ulsch_unscrambling_optim(gNB->pusch_vars[ULSCH_id]->llr, - G, - 0, - pusch_pdu->data_scrambling_id, - pusch_pdu->rnti); + nr_ulsch_unscrambling(gNB->pusch_vars[ULSCH_id]->llr, + G, + pusch_pdu->data_scrambling_id, + pusch_pdu->rnti); stop_meas(&gNB->ulsch_unscrambling_stats); //---------------------------------------------------------- //--------------------- ULSCH decoding --------------------- @@ -455,6 +436,7 @@ void nr_fill_indication(PHY_VARS_gNB *gNB, int frame, int slot_rx, int ULSCH_id, if (0/*pusch_pdu->mcs_index == 9*/) { + __attribute__((unused)) #ifdef __AVX2__ int off = ((pusch_pdu->rb_size&1) == 1)? 4:0; #else @@ -600,6 +582,20 @@ void fill_ul_rb_mask(PHY_VARS_gNB *gNB, int frame_rx, int slot_rx) { } } + for (int i=0;i<NUMBER_OF_NR_SRS_MAX;i++) { + NR_gNB_SRS_t *srs = gNB->srs[i]; + if (srs) { + if ((srs->active == 1) && (srs->frame == frame_rx) && (srs->slot == slot_rx)) { + nfapi_nr_srs_pdu_t *srs_pdu = &srs->srs_pdu; + for(int symbol = 0; symbol<(1<<srs_pdu->num_symbols); symbol++) { + for(rb = srs_pdu->bwp_start; rb < (srs_pdu->bwp_start+srs_pdu->bwp_size); rb++) { + gNB->rb_mask_ul[gNB->frame_parms.symbols_per_slot-srs_pdu->time_start_position-1+symbol][rb>>5] |= 1<<(rb&31); + } + } + } + } + } + } void phy_procedures_gNB_common_RX(PHY_VARS_gNB *gNB, int frame_rx, int slot_rx) { @@ -659,6 +655,8 @@ int phy_procedures_gNB_uespec_RX(PHY_VARS_gNB *gNB, int frame_rx, int slot_rx) { for (int i=0;i<NUMBER_OF_NR_PUCCH_MAX;i++){ NR_gNB_PUCCH_t *pucch = gNB->pucch[i]; if (pucch) { + if (NFAPI_MODE == NFAPI_MODE_PNF) + pucch->frame = frame_rx; if ((pucch->active == 1) && (pucch->frame == frame_rx) && (pucch->slot == slot_rx) ) { @@ -805,6 +803,43 @@ int phy_procedures_gNB_uespec_RX(PHY_VARS_gNB *gNB, int frame_rx, int slot_rx) { } } } + + for (int i=0;i<NUMBER_OF_NR_SRS_MAX;i++) { + NR_gNB_SRS_t *srs = gNB->srs[i]; + if (srs) { + if ((srs->active == 1) && (srs->frame == frame_rx) && (srs->slot == slot_rx)) { + + LOG_D(NR_PHY, "(%d.%d) gNB is waiting for SRS, id = %i\n", frame_rx, slot_rx, i); + + nfapi_nr_srs_pdu_t *srs_pdu = &srs->srs_pdu; + + // 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, &gNB->frame_parms, gNB->nr_srs_info[i]->srs_generated_signal, gNB->nr_srs_info[i], AMP, frame_rx, slot_rx); + } + + nr_get_srs_signal(gNB,frame_rx,slot_rx,srs_pdu, gNB->nr_srs_info[i], gNB->nr_srs_info[i]->srs_received_signal); + + nr_srs_channel_estimation(gNB,frame_rx,slot_rx,srs_pdu, + gNB->nr_srs_info[i], + gNB->nr_srs_info[i]->srs_generated_signal, + gNB->nr_srs_info[i]->srs_received_signal, + gNB->nr_srs_info[i]->srs_estimated_channel_freq, + gNB->nr_srs_info[i]->srs_estimated_channel_time, + gNB->nr_srs_info[i]->srs_estimated_channel_time_shifted, + gNB->nr_srs_info[i]->noise_power); + + 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(gNB->nr_srs_info[i]->srs_estimated_channel_freq[0], gNB->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(gNB->nr_srs_info[i]->srs_estimated_channel_time_shifted[0], gNB->frame_parms.ofdm_symbol_size*sizeof(int32_t))); + + srs->active = 0; + } + } + } + stop_meas(&gNB->phy_proc_rx); // figure out a better way to choose slot_rx, 19 is ok for a particular TDD configuration with 30kHz SCS if ((frame_rx&127) == 0 && slot_rx==19) { diff --git a/openair1/SCHED_NR_UE/defs.h b/openair1/SCHED_NR_UE/defs.h index c98574ec42f35addc4758ff8290303605a7d96e1..b85d4c1b507b43e6b62d11d4ebfdaa31ce582638 100644 --- a/openair1/SCHED_NR_UE/defs.h +++ b/openair1/SCHED_NR_UE/defs.h @@ -358,31 +358,12 @@ int16_t nr_pucch_power_cntl(PHY_VARS_NR_UE *ue,UE_nr_rxtx_proc_t *proc,uint8_t s */ void nr_pusch_power_cntl(PHY_VARS_NR_UE *phy_vars_ue,UE_nr_rxtx_proc_t *proc,uint8_t eNB_id,uint8_t j, uint8_t abstraction_flag); -/*! \brief This function implements the power control mechanism for SRS from 36.213. - @param phy_vars_ue PHY variables - @param proc Pointer to proc descriptor - @param eNB_id Index of eNB - @param j index of type of PUSCH (SPS, Normal, Msg3) - @returns Transmit power - */ -void nr_srs_power_cntl(PHY_VARS_NR_UE *ue,UE_nr_rxtx_proc_t *proc,uint8_t eNB_id,uint8_t *pnb_rb_srs, uint8_t abstraction_flag); - void nr_get_cqipmiri_params(PHY_VARS_NR_UE *ue,uint8_t eNB_id); - - - - - void nr_dump_dlsch(PHY_VARS_NR_UE *phy_vars_ue,UE_nr_rxtx_proc_t *proc,uint8_t eNB_id,uint8_t subframe,uint8_t harq_pid); void nr_dump_dlsch_SI(PHY_VARS_NR_UE *phy_vars_ue,UE_nr_rxtx_proc_t *proc,uint8_t eNB_id,uint8_t subframe); void nr_dump_dlsch_ra(PHY_VARS_NR_UE *phy_vars_ue,UE_nr_rxtx_proc_t *proc,uint8_t eNB_id,uint8_t subframe); - -int nr_is_srs_occasion_common(NR_DL_FRAME_PARMS *frame_parms,int frame_tx,int subframe_tx); - -void nr_compute_srs_pos(lte_frame_type_t frameType,uint16_t isrs,uint16_t *psrsPeriodicity,uint16_t *psrsOffset); - void set_tx_harq_id(NR_UE_ULSCH_t *ulsch, int harq_pid, int slot_tx); int get_tx_harq_id(NR_UE_ULSCH_t *ulsch, int slot_tx); @@ -416,7 +397,8 @@ void nr_fill_rx_indication(fapi_nr_rx_indication_t *rx_ind, PHY_VARS_NR_UE *ue, NR_UE_DLSCH_t *dlsch0, NR_UE_DLSCH_t *dlsch1, - uint16_t n_pdus); + uint16_t n_pdus, + UE_nr_rxtx_proc_t *proc); bool nr_ue_dlsch_procedures(PHY_VARS_NR_UE *ue, UE_nr_rxtx_proc_t *proc, @@ -424,8 +406,7 @@ bool nr_ue_dlsch_procedures(PHY_VARS_NR_UE *ue, PDSCH_t pdsch, NR_UE_DLSCH_t *dlsch0, NR_UE_DLSCH_t *dlsch1, - int *dlsch_errors, - uint8_t dlsch_parallel); + int *dlsch_errors); int nr_ue_pdsch_procedures(PHY_VARS_NR_UE *ue, UE_nr_rxtx_proc_t *proc, diff --git a/openair1/SCHED_NR_UE/fapi_nr_ue_l1.c b/openair1/SCHED_NR_UE/fapi_nr_ue_l1.c index f6e4d90beed5925749ae8b1fc32a5eece712e296..4f4757ec5a43f6bb27822930a165f27866cd6e16 100644 --- a/openair1/SCHED_NR_UE/fapi_nr_ue_l1.c +++ b/openair1/SCHED_NR_UE/fapi_nr_ue_l1.c @@ -39,11 +39,176 @@ #include "PHY/defs_nr_UE.h" #include "PHY/impl_defs_nr.h" +#include "utils.h" extern PHY_VARS_NR_UE ***PHY_vars_UE_g; const char *dl_pdu_type[]={"DCI", "DLSCH", "RA_DLSCH", "SI_DLSCH", "P_DLSCH"}; const char *ul_pdu_type[]={"PRACH", "PUCCH", "PUSCH", "SRS"}; +queue_t nr_rx_ind_queue; +queue_t nr_crc_ind_queue; +queue_t nr_uci_ind_queue; + +int8_t nr_ue_scheduled_response_stub(nr_scheduled_response_t *scheduled_response) { + + if(scheduled_response != NULL) + { + if (scheduled_response->ul_config != NULL) + { + fapi_nr_ul_config_request_t *ul_config = scheduled_response->ul_config; + AssertFatal(ul_config->number_pdus < sizeof(ul_config->ul_config_list) / sizeof(ul_config->ul_config_list[0]), + "Too many ul_config pdus %d", ul_config->number_pdus); + for (int i = 0; i < ul_config->number_pdus; ++i) + { + LOG_I(PHY, "In %s: processing type %d PDU of %d total UL PDUs (ul_config %p) \n", + __FUNCTION__, ul_config->ul_config_list[i].pdu_type, ul_config->number_pdus, ul_config); + + uint8_t pdu_type = ul_config->ul_config_list[i].pdu_type; + switch (pdu_type) + { + case (FAPI_NR_UL_CONFIG_TYPE_PUSCH): + { + nfapi_nr_rx_data_indication_t *rx_ind = CALLOC(1, sizeof(*rx_ind)); + nfapi_nr_crc_indication_t *crc_ind = CALLOC(1, sizeof(*crc_ind)); + nfapi_nr_ue_pusch_pdu_t *pusch_config_pdu = &ul_config->ul_config_list[i].pusch_config_pdu; + if (scheduled_response->tx_request) + { + AssertFatal(scheduled_response->tx_request->number_of_pdus < + sizeof(scheduled_response->tx_request->tx_request_body) / sizeof(scheduled_response->tx_request->tx_request_body[0]), + "Too many tx_req pdus %d", scheduled_response->tx_request->number_of_pdus); + rx_ind->header.message_id = NFAPI_NR_PHY_MSG_TYPE_RX_DATA_INDICATION; + rx_ind->sfn = scheduled_response->ul_config->sfn; + rx_ind->slot = scheduled_response->ul_config->slot; + rx_ind->number_of_pdus = scheduled_response->tx_request->number_of_pdus; + rx_ind->pdu_list = CALLOC(rx_ind->number_of_pdus, sizeof(*rx_ind->pdu_list)); + for (int j = 0; j < rx_ind->number_of_pdus; j++) + { + fapi_nr_tx_request_body_t *tx_req_body = &scheduled_response->tx_request->tx_request_body[j]; + rx_ind->pdu_list[j].handle = pusch_config_pdu->handle; + rx_ind->pdu_list[j].harq_id = pusch_config_pdu->pusch_data.harq_process_id; + rx_ind->pdu_list[j].pdu_length = tx_req_body->pdu_length; + rx_ind->pdu_list[j].pdu = CALLOC(tx_req_body->pdu_length, sizeof(*rx_ind->pdu_list[j].pdu)); + memcpy(rx_ind->pdu_list[j].pdu, tx_req_body->pdu, tx_req_body->pdu_length * sizeof(*rx_ind->pdu_list[j].pdu)); + rx_ind->pdu_list[j].rnti = pusch_config_pdu->rnti; + rx_ind->pdu_list[j].timing_advance = scheduled_response->tx_request->tx_config.timing_advance; + rx_ind->pdu_list[j].ul_cqi = scheduled_response->tx_request->tx_config.ul_cqi; + char buffer[1024]; + hexdump(rx_ind->pdu_list[j].pdu, rx_ind->pdu_list[j].pdu_length, buffer, sizeof(buffer)); + LOG_D(NR_MAC, "Hexdump of pdu %s before queuing rx_ind\n", + buffer); + } + + crc_ind->header.message_id = NFAPI_NR_PHY_MSG_TYPE_CRC_INDICATION; + crc_ind->number_crcs = scheduled_response->ul_config->number_pdus; + crc_ind->sfn = scheduled_response->ul_config->sfn; + crc_ind->slot = scheduled_response->ul_config->slot; + crc_ind->crc_list = CALLOC(crc_ind->number_crcs, sizeof(*crc_ind->crc_list)); + for (int j = 0; j < crc_ind->number_crcs; j++) + { + crc_ind->crc_list[j].handle = pusch_config_pdu->handle; + crc_ind->crc_list[j].harq_id = pusch_config_pdu->pusch_data.harq_process_id; + LOG_D(NR_MAC, "This is the harq pid %d for crc_list[%d]\n", crc_ind->crc_list[j].harq_id, j); + LOG_D(NR_MAC, "This is sched sfn/sl [%d %d] and crc sfn/sl [%d %d]\n", + scheduled_response->frame, scheduled_response->slot, crc_ind->sfn, crc_ind->slot); + crc_ind->crc_list[j].num_cb = pusch_config_pdu->pusch_data.num_cb; + crc_ind->crc_list[j].rnti = pusch_config_pdu->rnti; + crc_ind->crc_list[j].tb_crc_status = 0; + crc_ind->crc_list[j].timing_advance = scheduled_response->tx_request->tx_config.timing_advance; + crc_ind->crc_list[j].ul_cqi = 255; + } + + if (!put_queue(&nr_rx_ind_queue, rx_ind)) + { + LOG_E(NR_MAC, "Put_queue failed for rx_ind\n"); + for (int i = 0; i < rx_ind->number_of_pdus; i++) + { + free(rx_ind->pdu_list[i].pdu); + rx_ind->pdu_list[i].pdu = NULL; + } + + free(rx_ind->pdu_list); + rx_ind->pdu_list = NULL; + free(rx_ind); + rx_ind = NULL; + } + if (!put_queue(&nr_crc_ind_queue, crc_ind)) + { + LOG_E(NR_MAC, "Put_queue failed for crc_ind\n"); + free(crc_ind->crc_list); + crc_ind->crc_list = NULL; + free(crc_ind); + crc_ind = NULL; + } + + LOG_D(PHY, "In %s: Filled queue rx/crc_ind which was filled by ulconfig. \n", __FUNCTION__); + + scheduled_response->tx_request->number_of_pdus = 0; + } + break; + } + + default: + LOG_I(NR_MAC, "Unknown ul_config->pdu_type %d\n", pdu_type); + break; + } + } + scheduled_response->ul_config->number_pdus = 0; + } + + if (scheduled_response->dl_config != NULL) + { + fapi_nr_dl_config_request_t *dl_config = scheduled_response->dl_config; + AssertFatal(dl_config->number_pdus < sizeof(dl_config->dl_config_list) / sizeof(dl_config->dl_config_list[0]), + "Too many dl_config pdus %d", dl_config->number_pdus); + for (int i = 0; i < dl_config->number_pdus; ++i) + { + LOG_D(PHY, "In %s: processing %s PDU of %d total DL PDUs (dl_config %p) \n", + __FUNCTION__, dl_pdu_type[dl_config->dl_config_list[i].pdu_type - 1], dl_config->number_pdus, dl_config); + + uint8_t pdu_type = dl_config->dl_config_list[i].pdu_type; + switch (pdu_type) + { + case (FAPI_NR_DL_CONFIG_TYPE_DLSCH): + { + nfapi_nr_uci_indication_t *uci_ind = CALLOC(1, sizeof(*uci_ind)); + uci_ind->header.message_id = NFAPI_NR_PHY_MSG_TYPE_UCI_INDICATION; + uci_ind->sfn = scheduled_response->frame; + uci_ind->slot = scheduled_response->slot; + uci_ind->num_ucis = 1; + uci_ind->uci_list = CALLOC(uci_ind->num_ucis, sizeof(*uci_ind->uci_list)); + for (int j = 0; j < uci_ind->num_ucis; j++) + { + nfapi_nr_uci_pucch_pdu_format_0_1_t *pdu_0_1 = &uci_ind->uci_list[j].pucch_pdu_format_0_1; + uci_ind->uci_list[j].pdu_type = NFAPI_NR_UCI_FORMAT_0_1_PDU_TYPE; + uci_ind->uci_list[j].pdu_size = sizeof(nfapi_nr_uci_pucch_pdu_format_0_1_t); + memset(pdu_0_1, 0, sizeof(*pdu_0_1)); + pdu_0_1->handle = 0; + pdu_0_1->rnti = dl_config->dl_config_list[i].dlsch_config_pdu.rnti; + pdu_0_1->pucch_format = 1; + pdu_0_1->ul_cqi = 255; + pdu_0_1->timing_advance = 0; + pdu_0_1->rssi = 0; + } + + LOG_I(NR_PHY, "In %s: Filled queue uci_ind which was filled by dlconfig.\n" + "uci_num %d, SFN/SLOT: [%d, %d]\n", + __FUNCTION__, uci_ind->num_ucis, uci_ind->sfn, uci_ind->slot); + + if (!put_queue(&nr_uci_ind_queue, uci_ind)) + { + LOG_E(NR_MAC, "Put_queue failed for uci_ind\n"); + free(uci_ind->uci_list); + free(uci_ind); + } + break; + } + } + } + } + + } + return 0; +} int8_t nr_ue_scheduled_response(nr_scheduled_response_t *scheduled_response){ @@ -105,7 +270,7 @@ int8_t nr_ue_scheduled_response(nr_scheduled_response_t *scheduled_response){ dlsch0->active = 1; dlsch0->rnti = dl_config->dl_config_list[i].dlsch_config_pdu.rnti; - LOG_D(PHY,"current_harq_pid = %d\n", current_harq_pid); + LOG_D(PHY,"slot %d current_harq_pid = %d\n",slot, current_harq_pid); NR_DL_UE_HARQ_t *dlsch0_harq = dlsch0->harq_processes[current_harq_pid]; if (dlsch0_harq){ @@ -131,9 +296,10 @@ int8_t nr_ue_scheduled_response(nr_scheduled_response_t *scheduled_response){ dlsch0_harq->mcs_table=dlsch_config_pdu->mcs_table; downlink_harq_process(dlsch0_harq, dlsch0->current_harq_pid, dlsch_config_pdu->ndi, dlsch_config_pdu->rv, dlsch0->rnti_type); if (dlsch0_harq->status != ACTIVE) { - // dlsch0_harq->status not ACTIVE may be due to false retransmission. Reset the - // following flag to skip PDSCH procedures in that case. + // dlsch0_harq->status not ACTIVE due to false retransmission + // Reset the following flag to skip PDSCH procedures in that case and retrasmit harq status dlsch0->active = 0; + update_harq_status(module_id,dlsch0->current_harq_pid,dlsch0_harq->ack); } /* PTRS */ dlsch0_harq->PTRSFreqDensity = dlsch_config_pdu->PTRSFreqDensity; @@ -152,8 +318,10 @@ int8_t nr_ue_scheduled_response(nr_scheduled_response_t *scheduled_response){ if (scheduled_response->ul_config != NULL){ fapi_nr_ul_config_request_t *ul_config = scheduled_response->ul_config; - + int pdu_done = 0; pthread_mutex_lock(&ul_config->mutex_ul_config); + LOG_D(PHY, "%d.%d ul S ul_config %p pdu_done %d number_pdus %d\n", scheduled_response->frame, slot, ul_config, pdu_done, ul_config->number_pdus); + for (i = 0; i < ul_config->number_pdus; ++i){ AssertFatal(ul_config->ul_config_list[i].pdu_type <= FAPI_NR_UL_CONFIG_TYPES,"pdu_type %d out of bounds\n",ul_config->ul_config_list[i].pdu_type); @@ -167,6 +335,9 @@ int8_t nr_ue_scheduled_response(nr_scheduled_response_t *scheduled_response){ nfapi_nr_ue_pusch_pdu_t *pusch_config_pdu; /* PUCCH */ fapi_nr_ul_config_pucch_pdu *pucch_config_pdu; + LOG_D(PHY, "%d.%d ul B ul_config %p t %d pdu_done %d number_pdus %d\n", scheduled_response->frame, slot, ul_config, pdu_type, pdu_done, ul_config->number_pdus); + /* SRS */ + fapi_nr_ul_config_srs_pdu *srs_config_pdu; switch (pdu_type){ @@ -188,10 +359,13 @@ int8_t nr_ue_scheduled_response(nr_scheduled_response_t *scheduled_response){ if (scheduled_response->tx_request) { for (int j=0; j<scheduled_response->tx_request->number_of_pdus; j++) { fapi_nr_tx_request_body_t *tx_req_body = &scheduled_response->tx_request->tx_request_body[j]; - if (tx_req_body->pdu_index == i) { + if ((tx_req_body->pdu_index == i) && (tx_req_body->pdu_length > 0)) { LOG_D(PHY,"%d.%d Copying %d bytes to harq_process_ul_ue->a (harq_pid %d)\n",scheduled_response->frame,slot,tx_req_body->pdu_length,current_harq_pid); memcpy(harq_process_ul_ue->a, tx_req_body->pdu, tx_req_body->pdu_length); harq_process_ul_ue->status = ACTIVE; + ul_config->ul_config_list[i].pdu_type = FAPI_NR_UL_CONFIG_TYPE_DONE; // not handle it any more + pdu_done++; + LOG_D(PHY, "%d.%d ul A ul_config %p t %d pdu_done %d number_pdus %d\n", scheduled_response->frame, slot, ul_config, pdu_type, pdu_done, ul_config->number_pdus); break; } } @@ -215,6 +389,9 @@ int8_t nr_ue_scheduled_response(nr_scheduled_response_t *scheduled_response){ memcpy((void*)&(pucch_vars->pucch_pdu[j]), (void*)pucch_config_pdu, sizeof(fapi_nr_ul_config_pucch_pdu)); pucch_vars->active[j] = true; found = true; + ul_config->ul_config_list[i].pdu_type = FAPI_NR_UL_CONFIG_TYPE_DONE; // not handle it any more + pdu_done++; + LOG_D(PHY, "%d.%d ul A ul_config %p t %d pdu_done %d number_pdus %d\n", scheduled_response->frame, slot, ul_config, pdu_type, pdu_done, ul_config->number_pdus); break; } } @@ -226,18 +403,45 @@ int8_t nr_ue_scheduled_response(nr_scheduled_response_t *scheduled_response){ // prach config pdu prach_config_pdu = &ul_config->ul_config_list[i].prach_config_pdu; memcpy((void*)&(PHY_vars_UE_g[module_id][cc_id]->prach_vars[gNB_id]->prach_pdu), (void*)prach_config_pdu, sizeof(fapi_nr_ul_config_prach_pdu)); + ul_config->ul_config_list[i].pdu_type = FAPI_NR_UL_CONFIG_TYPE_DONE; // not handle it any more + pdu_done++; + LOG_D(PHY, "%d.%d ul A ul_config %p t %d pdu_done %d number_pdus %d\n", scheduled_response->frame, slot, ul_config, pdu_type, pdu_done, ul_config->number_pdus); + break; + + case (FAPI_NR_UL_CONFIG_TYPE_DONE): + pdu_done++; // count the no of pdu processed + LOG_D(PHY, "%d.%d ul A ul_config %p t %d pdu_done %d number_pdus %d\n", scheduled_response->frame, slot, ul_config, pdu_type, pdu_done, ul_config->number_pdus); + break; + + case (FAPI_NR_UL_CONFIG_TYPE_SRS): + // srs config pdu + srs_config_pdu = &ul_config->ul_config_list[i].srs_config_pdu; + memcpy((void*)&(PHY_vars_UE_g[module_id][cc_id]->srs_vars[gNB_id]->srs_config_pdu), (void*)srs_config_pdu, sizeof(fapi_nr_ul_config_srs_pdu)); + PHY_vars_UE_g[module_id][cc_id]->srs_vars[gNB_id]->active = true; + ul_config->ul_config_list[i].pdu_type = FAPI_NR_UL_CONFIG_TYPE_DONE; // not handle it any more + pdu_done++; break; default: + ul_config->ul_config_list[i].pdu_type = FAPI_NR_UL_CONFIG_TYPE_DONE; // not handle it any more + pdu_done++; // count the no of pdu processed + LOG_D(PHY, "%d.%d ul A ul_config %p t %d pdu_done %d number_pdus %d\n", scheduled_response->frame, slot, ul_config, pdu_type, pdu_done, ul_config->number_pdus); break; } } - if (scheduled_response->tx_request) - scheduled_response->tx_request->number_of_pdus = 0; - ul_config->sfn = 0; - ul_config->slot = 0; - ul_config->number_pdus = 0; - memset(ul_config->ul_config_list, 0, sizeof(ul_config->ul_config_list)); + + + //Clear the fields when all the config pdu are done + if (pdu_done == ul_config->number_pdus) { + if (scheduled_response->tx_request) + scheduled_response->tx_request->number_of_pdus = 0; + ul_config->sfn = 0; + ul_config->slot = 0; + ul_config->number_pdus = 0; + LOG_D(PHY, "%d.%d clear ul_config %p\n", scheduled_response->frame, slot, ul_config); + memset(ul_config->ul_config_list, 0, sizeof(ul_config->ul_config_list)); + } + pthread_mutex_unlock(&ul_config->mutex_ul_config); } } diff --git a/openair1/SCHED_NR_UE/fapi_nr_ue_l1.h b/openair1/SCHED_NR_UE/fapi_nr_ue_l1.h index f00ce14b56cc8333e9e9102e6261688113f25000..a0b0b805afed872e22ebc639d916d86d6a7574bc 100755 --- a/openair1/SCHED_NR_UE/fapi_nr_ue_l1.h +++ b/openair1/SCHED_NR_UE/fapi_nr_ue_l1.h @@ -34,14 +34,19 @@ #define __FAPI_NR_UE_L1_H__ #include "NR_IF_Module.h" +#include "openair2/NR_UE_PHY_INTERFACE/NR_IF_Module.h" +#include "openair2/LAYER2/NR_MAC_UE/mac_proto.h" /**\brief NR UE FAPI-like P7 messages, scheduled response from L2 indicating L1 \param scheduled_response including transmission config(dl_config, ul_config) and data transmission (tx_req)*/ int8_t nr_ue_scheduled_response(nr_scheduled_response_t *scheduled_response); +int8_t nr_ue_scheduled_response_stub(nr_scheduled_response_t *scheduled_response); + /**\brief NR UE FAPI-like P5 message, physical configuration from L2 to configure L1 \param scheduled_response including transmission config(dl_config, ul_config) and data transmission (tx_req)*/ int8_t nr_ue_phy_config_request(nr_phy_config_t *phy_config); +void update_harq_status(module_id_t module_id, uint8_t harq_pid, uint8_t ack_nack); #endif diff --git a/openair1/SCHED_NR_UE/harq_nr.c b/openair1/SCHED_NR_UE/harq_nr.c index 7bc1f3053bafec50360e2ac01517ca87d6b757ef..4d92509d48e4985d31793b1eaf392c4a056d5742 100644 --- a/openair1/SCHED_NR_UE/harq_nr.c +++ b/openair1/SCHED_NR_UE/harq_nr.c @@ -331,7 +331,6 @@ void init_downlink_harq_status(NR_DL_UE_HARQ_t *dl_harq) void downlink_harq_process(NR_DL_UE_HARQ_t *dl_harq, int harq_pid, int ndi, int rv, uint8_t rnti_type) { - if (rnti_type == _SI_RNTI_ || rnti_type == _P_RNTI_ || rnti_type == _RA_RNTI_) { @@ -350,39 +349,39 @@ void downlink_harq_process(NR_DL_UE_HARQ_t *dl_harq, int harq_pid, int ndi, int dl_harq->DCINdi = ndi; break; case 1: - dl_harq->round = 2; + dl_harq->round = 3; + dl_harq->status = ACTIVE; dl_harq->first_rx = 0; if (dl_harq->DCINdi != ndi) { LOG_E(PHY,"Missed previous DCI detections. NDI toggled but rv %d does not correspond to first reception\n",rv); - dl_harq->status = ACTIVE; dl_harq->first_rx = 1; dl_harq->DCINdi = ndi; } - else if (dl_harq->ack) + else if (dl_harq->ack == 1) dl_harq->status = SCH_IDLE; break; case 2: dl_harq->round = 1; + dl_harq->status = ACTIVE; dl_harq->first_rx = 0; if (dl_harq->DCINdi != ndi) { LOG_E(PHY,"Missed previous DCI detections. NDI toggled but rv %d does not correspond to first reception\n",rv); - dl_harq->status = ACTIVE; dl_harq->first_rx = 1; dl_harq->DCINdi = ndi; } - else if (dl_harq->ack) + else if (dl_harq->ack == 1) dl_harq->status = SCH_IDLE; break; case 3: - dl_harq->round = 3; + dl_harq->round = 2; + dl_harq->status = ACTIVE; dl_harq->first_rx = 0; if (dl_harq->DCINdi != ndi) { LOG_E(PHY,"Missed previous DCI detections. NDI toggled but rv %d does not correspond to first reception\n",rv); - dl_harq->status = ACTIVE; dl_harq->first_rx = 1; dl_harq->DCINdi = ndi; } - else if (dl_harq->ack) + else if (dl_harq->ack == 1) dl_harq->status = SCH_IDLE; break; default: diff --git a/openair1/SCHED_NR_UE/phy_procedures_nr_ue.c b/openair1/SCHED_NR_UE/phy_procedures_nr_ue.c index 9843f5951d96f0e5f02e272daaf31cd822f07354..97a7e2e48996860b2815a2412bb42fc95f864709 100644 --- a/openair1/SCHED_NR_UE/phy_procedures_nr_ue.c +++ b/openair1/SCHED_NR_UE/phy_procedures_nr_ue.c @@ -38,15 +38,12 @@ #include "PHY/defs_nr_UE.h" #include "PHY/phy_extern_nr_ue.h" #include "PHY/MODULATION/modulation_UE.h" -#include "PHY/NR_REFSIG/refsig_defs_ue.h" #include "PHY/NR_UE_TRANSPORT/nr_transport_ue.h" #include "PHY/NR_UE_TRANSPORT/nr_transport_proto_ue.h" -#include "SCHED_NR_UE/defs.h" -#include "SCHED_NR_UE/pucch_uci_ue_nr.h" +#include "PHY/NR_UE_TRANSPORT/srs_modulation_nr.h" #include "SCHED_NR/extern.h" #include "SCHED_NR_UE/phy_sch_processing_time.h" #include "PHY/NR_UE_ESTIMATION/nr_estimation.h" -#include "PHY/NR_TRANSPORT/nr_dci.h" #ifdef EMOS #include "SCHED/phy_procedures_emos.h" #endif @@ -60,6 +57,7 @@ //#define NR_PDCCH_SCHED_DEBUG //#define NR_PUCCH_SCHED //#define NR_PUCCH_SCHED_DEBUG +//#define NR_PDSCH_DEBUG #ifndef PUCCH #define PUCCH @@ -78,8 +76,6 @@ fifo_dump_emos_UE emos_dump_UE; char nr_mode_string[NUM_UE_MODE][20] = {"NOT SYNCHED","PRACH","RAR","RA_WAIT_CR", "PUSCH", "RESYNCH"}; -const uint8_t nr_rv_round_map_ue[4] = {0, 2, 1, 3}; - #if defined(EXMIMO) || defined(OAI_USRP) || defined(OAI_BLADERF) || defined(OAI_LMSSDR) || defined(OAI_ADRV9371_ZC706) extern uint64_t downlink_frequency[MAX_NUM_CCs][4]; #endif @@ -121,7 +117,8 @@ void nr_fill_rx_indication(fapi_nr_rx_indication_t *rx_ind, PHY_VARS_NR_UE *ue, NR_UE_DLSCH_t *dlsch0, NR_UE_DLSCH_t *dlsch1, - uint16_t n_pdus){ + uint16_t n_pdus, + UE_nr_rxtx_proc_t *proc ){ NR_DL_FRAME_PARMS *frame_parms = &ue->frame_parms; @@ -130,6 +127,16 @@ void nr_fill_rx_indication(fapi_nr_rx_indication_t *rx_ind, LOG_E(PHY, "In %s: multiple number of DL PDUs not supported yet...\n", __FUNCTION__); } + if (pdu_type != FAPI_NR_RX_PDU_TYPE_SSB) + trace_NRpdu(DIRECTION_DOWNLINK, + dlsch0->harq_processes[dlsch0->current_harq_pid]->b, + dlsch0->harq_processes[dlsch0->current_harq_pid]->TBS / 8, + pdu_type, + WS_C_RNTI, + dlsch0->rnti, + proc->frame_rx, + proc->nr_slot_rx, + 0,0); switch (pdu_type){ case FAPI_NR_RX_PDU_TYPE_SIB: rx_ind->rx_indication_body[n_pdus - 1].pdsch_pdu.harq_pid = dlsch0->current_harq_pid; @@ -275,16 +282,17 @@ void phy_procedures_nrUE_TX(PHY_VARS_NR_UE *ue, LOG_D(PHY,"****** start TX-Chain for AbsSubframe %d.%d ******\n", frame_tx, slot_tx); - start_meas(&ue->phy_proc_tx); if (ue->UE_mode[gNB_id] <= PUSCH){ - for (uint8_t harq_pid = 0; harq_pid < ue->ulsch[proc->thread_id][gNB_id][0]->number_harq_processes_for_pusch; harq_pid++) { if (ue->ulsch[proc->thread_id][gNB_id][0]->harq_processes[harq_pid]->status == ACTIVE) nr_ue_ulsch_procedures(ue, harq_pid, frame_tx, slot_tx, proc->thread_id, gNB_id); } + } + if (ue->UE_mode[gNB_id] == PUSCH) { + ue_srs_procedures_nr(ue, proc, gNB_id); } VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_PHY_PROCEDURES_UE_TX, VCD_FUNCTION_OUT); @@ -478,193 +486,14 @@ int nr_ue_pdcch_procedures(uint8_t gNB_id, int frame_rx = proc->frame_rx; int nr_slot_rx = proc->nr_slot_rx; unsigned int dci_cnt=0; - fapi_nr_dci_indication_t dci_ind = {0}; + fapi_nr_dci_indication_t *dci_ind = calloc(1, sizeof(*dci_ind)); nr_downlink_indication_t dl_indication; NR_UE_PDCCH *pdcch_vars = ue->pdcch_vars[proc->thread_id][gNB_id]; fapi_nr_dl_config_dci_dl_pdu_rel15_t *rel15 = &pdcch_vars->pdcch_config[n_ss]; - /* - // unsigned int dci_cnt=0, i; //removed for nr_ue_pdcch_procedures and added in the loop for nb_coreset_active -#ifdef NR_PDCCH_SCHED_DEBUG - printf("<-NR_PDCCH_PHY_PROCEDURES_LTE_UE (nr_ue_pdcch_procedures)-> Entering function nr_ue_pdcch_procedures() \n"); -#endif - - int frame_rx = proc->frame_rx; - int nr_slot_rx = proc->nr_slot_rx; - NR_DCI_ALLOC_t dci_alloc_rx[8]; - - //uint8_t next1_thread_id = proc->thread_id== (RX_NB_TH-1) ? 0:(proc->thread_id+1); - //uint8_t next2_thread_id = next1_thread_id== (RX_NB_TH-1) ? 0:(next1_thread_id+1); - - - // table dci_fields_sizes_cnt contains dci_fields_sizes for each time a dci is decoded in the slot - // each element represents the size in bits for each dci field, for each decoded dci -> [dci_cnt-1] - // each time a dci is decode at dci_cnt, the values of the table dci_fields_sizes[i][j] will be copied at table dci_fields_sizes_cnt[dci_cnt-1][i][j] - // table dci_fields_sizes_cnt[dci_cnt-1][i][j] will then be used in function nr_extract_dci_info - uint8_t dci_fields_sizes_cnt[MAX_NR_DCI_DECODED_SLOT][NBR_NR_DCI_FIELDS][NBR_NR_FORMATS]; - - int nb_searchspace_active=0; - NR_UE_PDCCH **pdcch_vars = ue->pdcch_vars[proc->thread_id]; - NR_UE_PDCCH *pdcch_vars2 = ue->pdcch_vars[proc->thread_id][gNB_id]; - // s in TS 38.212 Subclause 10.1, for each active BWP the UE can deal with 10 different search spaces - // Higher layers have updated the number of searchSpaces with are active in the current slot and this value is stored in variable nb_searchspace_total - int nb_searchspace_total = pdcch_vars2->nb_search_space; - - pdcch_vars[gNB_id]->crnti = 0x1234; //to be check how to set when using loop memory - - uint16_t c_rnti=pdcch_vars[gNB_id]->crnti; - uint16_t cs_rnti=0,new_rnti=0,tc_rnti=0; - uint16_t p_rnti=P_RNTI; - uint16_t si_rnti=SI_RNTI; - uint16_t ra_rnti=99; - uint16_t sp_csi_rnti=0,sfi_rnti=0,int_rnti=0,tpc_pusch_rnti=0,tpc_pucch_rnti=0,tpc_srs_rnti=0; //FIXME - uint16_t crc_scrambled_values[TOTAL_NBR_SCRAMBLED_VALUES] = - {c_rnti,cs_rnti,new_rnti,tc_rnti,p_rnti,si_rnti,ra_rnti,sp_csi_rnti,sfi_rnti,int_rnti,tpc_pusch_rnti,tpc_pucch_rnti,tpc_srs_rnti}; - #ifdef NR_PDCCH_SCHED_DEBUG - printf("<-NR_PDCCH_PHY_PROCEDURES_LTE_UE (nr_ue_pdcch_procedures)-> there is a bug in FAPI to calculate nb_searchspace_total=%d\n",nb_searchspace_total); - #endif - if (nb_searchspace_total>1) nb_searchspace_total=1; // to be removed when fixing bug in FAPI - #ifdef NR_PDCCH_SCHED_DEBUG - printf("<-NR_PDCCH_PHY_PROCEDURES_LTE_UE (nr_ue_pdcch_procedures)-> there is a bug in FAPI to calculate nb_searchspace_total so we set it to 1...\n"); - printf("<-NR_PDCCH_PHY_PROCEDURES_LTE_UE (nr_ue_pdcch_procedures)-> the number of searchSpaces active in the current slot(%d) is %d) \n", - nr_slot_rx,nb_searchspace_total); - #endif - - //FK: we define dci_ind and dl_indication as local variables, this way the call to the mac should be thread safe - fapi_nr_dci_indication_t dci_ind; - nr_downlink_indication_t dl_indication; - - // p in TS 38.212 Subclause 10.1, for each active BWP the UE can deal with 3 different CORESETs (including coresetId 0 for common search space) - //int nb_coreset_total = NR_NBR_CORESET_ACT_BWP; - unsigned int dci_cnt=0; - // this table contains 56 (NBR_NR_DCI_FIELDS) elements for each dci field and format described in TS 38.212. Each element represents the size in bits for each dci field - //uint8_t dci_fields_sizes[NBR_NR_DCI_FIELDS][NBR_NR_FORMATS] = {{0}}; - // this is the UL bandwidth part. FIXME! To be defined where this value comes from - // uint16_t n_RB_ULBWP = 106; - // this is the DL bandwidth part. FIXME! To be defined where this value comes from - - // First we have to identify each searchSpace active at a time and do PDCCH monitoring corresponding to current searchSpace - // Up to 10 searchSpaces can be configured to UE (s<=10) - for (nb_searchspace_active=0; nb_searchspace_active<nb_searchspace_total; nb_searchspace_active++){ - int nb_coreset_active=nb_searchspace_active; - //int do_pdcch_monitoring_current_slot=1; // this variable can be removed and fapi is handling - - // The following code has been removed as it is handled by higher layers (fapi) - // - // Verify that monitoring is required at the slot nr_slot_rx. We will run pdcch procedure only if do_pdcch_monitoring_current_slot=1 - // For Type0-PDCCH searchspace, we need to calculate the monitoring slot from Tables 13-1 .. 13-15 in TS 38.213 Subsection 13 - //NR_UE_SLOT_PERIOD_OFFSET_t sl_period_offset_mon = pdcch_vars2->searchSpace[nb_searchspace_active].monitoringSlotPeriodicityAndOffset; - //if (sl_period_offset_mon == nr_sl1) { - //do_pdcch_monitoring_current_slot=1; // PDCCH monitoring in every slot - //} else if (nr_slot_rx%(uint16_t)sl_period_offset_mon == pdcch_vars2->searchSpace[nb_searchspace_active].monitoringSlotPeriodicityAndOffset_offset) { - //do_pdcch_monitoring_current_slot=1; // PDCCH monitoring in every monitoringSlotPeriodicityAndOffset slot with offset - //} - - // FIXME - // For PDCCH monitoring when overlap with SS/PBCH according to 38.213 v15.1.0 Section 10 - // To be implemented LATER !!! - - //int _offset,_index,_M; - //int searchSpace_id = pdcch_vars2->searchSpace[nb_searchspace_active].searchSpaceId; - - - #ifdef NR_PDCCH_SCHED_DEBUG - printf("<-NR_PDCCH_PHY_PROCEDURES_LTE_UE (nr_ue_pdcch_procedures)-> nb_searchspace_active=%d do_pdcch_monitoring_current_slot=%d (to be removed)\n", - nb_searchspace_active, - do_pdcch_monitoring_current_slot); - #endif - -// if (do_pdcch_monitoring_current_slot) { - // the searchSpace indicates that we need to monitor PDCCH in current nr_slot_rx - // get the parameters describing the current SEARCHSPACE - // the CORESET id applicable to the current SearchSpace - //int searchSpace_coreset_id = pdcch_vars2->searchSpace[nb_searchspace_active].controlResourceSetId; - // FIXME this variable is a bit string (14 bits) identifying every OFDM symbol in a slot. - // at the moment we will not take into consideration this variable and we will consider that the OFDM symbol offset is always the first OFDM in a symbol - uint16_t symbol_within_slot_mon = pdcch_vars2->searchSpace[nb_searchspace_active].monitoringSymbolWithinSlot; - // get the remaining parameters describing the current SEARCHSPACE: // FIXME! To be defined where we get this information from - //NR_UE_SEARCHSPACE_nbrCAND_t num_cand_L1 = pdcch_vars2->searchSpace[nb_searchspace_active].nrofCandidates_aggrlevel1; - //NR_UE_SEARCHSPACE_nbrCAND_t num_cand_L2 = pdcch_vars2->searchSpace[nb_searchspace_active].nrofCandidates_aggrlevel2; - //NR_UE_SEARCHSPACE_nbrCAND_t num_cand_L4 = pdcch_vars2->searchSpace[nb_searchspace_active].nrofCandidates_aggrlevel4; - //NR_UE_SEARCHSPACE_nbrCAND_t num_cand_L8 = pdcch_vars2->searchSpace[nb_searchspace_active].nrofCandidates_aggrlevel8; - //NR_UE_SEARCHSPACE_nbrCAND_t num_cand_L16 = pdcch_vars2->searchSpace[nb_searchspace_active].nrofCandidates_aggrlevel16; - // FIXME! A table of five enum elements - // searchSpaceType indicates whether this is a common search space or a UE-specific search space - //int searchSpaceType = pdcch_vars2->searchSpace[nb_searchspace_active].searchSpaceType.type; - NR_SEARCHSPACE_TYPE_t searchSpaceType = ue_specific;//common; - #ifdef NR_PDCCH_SCHED_DEBUG - printf("<-NR_PDCCH_PHY_PROCEDURES_LTE_UE (nr_ue_pdcch_procedures)-> searchSpaceType=%d is hardcoded THIS HAS TO BE FIXED!!!\n", - searchSpaceType); - #endif - - //while ((searchSpace_coreset_id != pdcch_vars2->coreset[nb_coreset_active].controlResourceSetId) && (nb_coreset_active<nb_coreset_total)) { - // we need to identify the CORESET associated to the active searchSpace - //nb_coreset_active++; - if (nb_coreset_active >= nb_coreset_total) return 0; // the coreset_id could not be found. There is a problem - } - - - - //we do not need these parameters yet - - // get the parameters describing the current CORESET - //int coreset_duration = pdcch_vars2->coreset[nb_coreset_active].duration; - //uint64_t coreset_freq_dom = pdcch_vars2->coreset[nb_coreset_active].frequencyDomainResources; - //int coreset_shift_index = pdcch_vars2->coreset[nb_coreset_active].cce_reg_mappingType.shiftIndex; - // NR_UE_CORESET_REG_bundlesize_t coreset_bundlesize = pdcch_vars2->coreset[nb_coreset_active].cce_reg_mappingType.reg_bundlesize; - // NR_UE_CORESET_interleaversize_t coreset_interleaversize = pdcch_vars2->coreset[nb_coreset_active].cce_reg_mappingType.interleaversize; - // NR_UE_CORESET_precoder_granularity_t precoder_granularity = pdcch_vars2->coreset[nb_coreset_active].precoderGranularity; - // int tci_statesPDCCH = pdcch_vars2->coreset[nb_coreset_active].tciStatesPDCCH; - // int tci_present = pdcch_vars2->coreset[nb_coreset_active].tciPresentInDCI; - // uint16_t pdcch_DMRS_scrambling_id = pdcch_vars2->coreset[nb_coreset_active].pdcchDMRSScramblingID; - - - // A set of PDCCH candidates for a UE to monitor is defined in terms of PDCCH search spaces. - // Searchspace types: - // Type0-PDCCH common search space for a DCI format with CRC scrambled by a SI-RNTI - // number of consecutive resource blocks and a number of consecutive symbols for - // the control resource set of the Type0-PDCCH common search space from - // the four most significant bits of RMSI-PDCCH-Config as described in Tables 13-1 through 13-10 - // and determines PDCCH monitoring occasions - // from the four least significant bits of RMSI-PDCCH-Config, - // included in MasterInformationBlock, as described in Tables 13-11 through 13-15 - // Type0A-PDCCH common search space for a DCI format with CRC scrambled by a SI-RNTI - // Type1-PDCCH common search space for a DCI format with CRC scrambled by a RA-RNTI, or a TC-RNTI, or a C-RNTI - // Type2-PDCCH common search space for a DCI format with CRC scrambled by a P-RNTI - // Type3-PDCCH common search space for a DCI format with CRC scrambled by INT-RNTI, or SFI-RNTI, - // or TPC-PUSCH-RNTI, or TPC-PUCCH-RNTI, or TPC-SRS-RNTI, or C-RNTI, or CS-RNTI(s), or SP-CSI-RNTI + start_meas(&ue->dlsch_rx_pdcch_stats); - - - VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_UE_PDCCH_PROCEDURES, VCD_FUNCTION_IN); - start_meas(&ue->dlsch_rx_pdcch_stats); - - VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_RX_PDCCH, VCD_FUNCTION_IN); -#ifdef NR_PDCCH_SCHED_DEBUG - printf("<-NR_PDCCH_PHY_PROCEDURES_LTE_UE (nr_ue_pdcch_procedures)-> Entering function nr_rx_pdcch with gNB_id=%d (nb_coreset_active=%d, (symbol_within_slot_mon&0x3FFF)=%d, searchSpaceType=%d)\n", - gNB_id,nb_coreset_active,(symbol_within_slot_mon&0x3FFF), - searchSpaceType); -#endif - nr_rx_pdcch(ue, - frame_rx, - nr_slot_rx, - gNB_id, - //(ue->frame_parms.mode1_flag == 1) ? SISO : ALAMOUTI, - SISO, - ue->high_speed_flag, - ue->is_secondary_ue, - nb_coreset_active, - (symbol_within_slot_mon&0x3FFF), - searchSpaceType); -#ifdef NR_PDCCH_SCHED_DEBUG - printf("<-NR_PDCCH_PHY_PROCEDURES_LTE_UE (nr_ue_pdcch_procedures)-> Ending function nr_rx_pdcch(nb_coreset_active=%d, (symbol_within_slot_mon&0x3FFF)=%d, searchSpaceType=%d)\n", - nb_coreset_active,(symbol_within_slot_mon&0x3FFF), - searchSpaceType); -#endif - - */ - VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_RX_PDCCH, VCD_FUNCTION_IN); nr_rx_pdcch(ue, proc, rel15); VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_RX_PDCCH, VCD_FUNCTION_OUT); @@ -677,7 +506,7 @@ int nr_ue_pdcch_procedures(uint8_t gNB_id, n_ss); #endif - dci_cnt = nr_dci_decoding_procedure(ue, proc, &dci_ind, rel15); + dci_cnt = nr_dci_decoding_procedure(ue, proc, dci_ind, rel15); #ifdef NR_PDCCH_SCHED_DEBUG LOG_I(PHY,"<-NR_PDCCH_PHY_PROCEDURES_LTE_UE (nr_ue_pdcch_procedures)-> Ending function nr_dci_decoding_procedure() -> dci_cnt=%u\n",dci_cnt); @@ -691,52 +520,16 @@ int nr_ue_pdcch_procedures(uint8_t gNB_id, ue->Mod_id,frame_rx%1024,nr_slot_rx,nr_mode_string[ue->UE_mode[gNB_id]], i + 1, dci_cnt, - dci_ind.dci_list[i].rnti, - dci_ind.dci_list[i].dci_format); + dci_ind->dci_list[i].rnti, + dci_ind->dci_list[i].dci_format); } ue->pdcch_vars[proc->thread_id][gNB_id]->dci_received += dci_cnt; - dci_ind.number_of_dcis = dci_cnt; - /* - for (int i=0; i<dci_cnt; i++) { - - memset(&dci_ind.dci_list[i].dci,0,sizeof(fapi_nr_dci_pdu_rel15_t)); - - dci_ind.dci_list[i].rnti = dci_alloc_rx[i].rnti; - dci_ind.dci_list[i].dci_format = dci_alloc_rx[i].format; - dci_ind.dci_list[i].n_CCE = dci_alloc_rx[i].firstCCE; - dci_ind.dci_list[i].N_CCE = (int)dci_alloc_rx[i].L; - - status = nr_extract_dci_info(ue, - gNB_id, - ue->frame_parms.frame_type, - dci_alloc_rx[i].dci_length, - dci_alloc_rx[i].rnti, - dci_alloc_rx[i].dci_pdu, - &dci_ind.dci_list[i].dci, - dci_fields_sizes_cnt[i], - dci_alloc_rx[i].format, - nr_slot_rx, - pdcch_vars2->n_RB_BWP[nb_searchspace_active], - pdcch_vars2->n_RB_BWP[nb_searchspace_active], - crc_scrambled_values); - - if(status == 0) { - LOG_W(PHY,"<-NR_PDCCH_PHY_PROCEDURES_UE (nr_ue_pdcch_procedures)-> bad DCI %d !!! \n",dci_alloc_rx[i].format); - return(-1); - } - - LOG_D(PHY,"<-NR_PDCCH_PHY_PROCEDURES_UE (nr_ue_pdcch_procedures)-> Ending function nr_extract_dci_info()\n"); - - - - } // end for loop dci_cnt - */ - - // fill dl_indication message - nr_fill_dl_indication(&dl_indication, &dci_ind, NULL, proc, ue, gNB_id); - // send to mac - ue->if_inst->dl_indication(&dl_indication, NULL); + dci_ind->number_of_dcis = dci_cnt; + // fill dl_indication message + nr_fill_dl_indication(&dl_indication, dci_ind, NULL, proc, ue, gNB_id); + // send to mac + ue->if_inst->dl_indication(&dl_indication, NULL); stop_meas(&ue->dlsch_rx_pdcch_stats); @@ -811,6 +604,7 @@ int nr_ue_pdsch_procedures(PHY_VARS_NR_UE *ue, UE_nr_rxtx_proc_t *proc, int gNB_ first_symbol_with_data++; } + start_meas(&ue->rx_pdsch_stats); for (m = s0; m < (s1 + s0); m++) { dual_stream_UE = 0; @@ -844,12 +638,13 @@ int nr_ue_pdsch_procedures(PHY_VARS_NR_UE *ue, UE_nr_rxtx_proc_t *proc, int gNB_ } else AssertFatal(1==0,"Not RA_PDSCH, SI_PDSCH or PDSCH\n"); stop_meas(&ue->dlsch_llr_stats_parallelization[proc->thread_id][slot]); - LOG_D(PHY, "[AbsSFN %d.%d] LLR Computation Symbol %d %5.2f \n",frame_rx,nr_slot_rx,m,ue->dlsch_llr_stats_parallelization[proc->thread_id][slot].p_time/(cpuf*1000.0)); - + if (cpumeas(CPUMEAS_GETSTATE)) + LOG_D(PHY, "[AbsSFN %d.%d] LLR Computation Symbol %d %5.2f \n",frame_rx,nr_slot_rx,m,ue->dlsch_llr_stats_parallelization[proc->thread_id][slot].p_time/(cpuf*1000.0)); if(first_symbol_flag) { proc->first_symbol_available = 1; } } // CRNTI active + stop_meas(&ue->rx_pdsch_stats); } return 0; } @@ -860,8 +655,7 @@ bool nr_ue_dlsch_procedures(PHY_VARS_NR_UE *ue, PDSCH_t pdsch, NR_UE_DLSCH_t *dlsch0, NR_UE_DLSCH_t *dlsch1, - int *dlsch_errors, - uint8_t dlsch_parallel) { + int *dlsch_errors) { if (dlsch0==NULL) AssertFatal(0,"dlsch0 should be defined at this level \n"); @@ -873,7 +667,7 @@ bool nr_ue_dlsch_procedures(PHY_VARS_NR_UE *ue, NR_UE_PDSCH *pdsch_vars; uint16_t dmrs_len = get_num_dmrs(dlsch0->harq_processes[dlsch0->current_harq_pid]->dlDmrsSymbPos); nr_downlink_indication_t dl_indication; - fapi_nr_rx_indication_t rx_ind; + fapi_nr_rx_indication_t *rx_ind = calloc(1, sizeof(*rx_ind)); uint16_t number_pdus = 1; // params for UL time alignment procedure NR_UL_TIME_ALIGNMENT_t *ul_time_alignment = &ue->ul_time_alignment[gNB_id]; @@ -990,29 +784,26 @@ bool nr_ue_dlsch_procedures(PHY_VARS_NR_UE *ue, harq_pid, pdsch==PDSCH?1:0, dlsch0->harq_processes[harq_pid]->TBS>256?1:0); - if( dlsch_parallel) { - LOG_T(PHY,"dlsch decoding is parallelized, ret = %d\n", ret); - } - else { - LOG_T(PHY,"Sequential dlsch decoding , ret = %d\n", ret); - } + + LOG_T(PHY,"dlsch decoding, ret = %d\n", ret); + if(ret<dlsch0->max_ldpc_iterations+1) dec = true; switch (pdsch) { case RA_PDSCH: - nr_fill_dl_indication(&dl_indication, NULL, &rx_ind, proc, ue, gNB_id); - nr_fill_rx_indication(&rx_ind, FAPI_NR_RX_PDU_TYPE_RAR, gNB_id, ue, dlsch0, NULL, number_pdus); + nr_fill_dl_indication(&dl_indication, NULL, rx_ind, proc, ue, gNB_id); + nr_fill_rx_indication(rx_ind, FAPI_NR_RX_PDU_TYPE_RAR, gNB_id, ue, dlsch0, NULL, number_pdus, proc); ue->UE_mode[gNB_id] = RA_RESPONSE; break; case PDSCH: - nr_fill_dl_indication(&dl_indication, NULL, &rx_ind, proc, ue, gNB_id); - nr_fill_rx_indication(&rx_ind, FAPI_NR_RX_PDU_TYPE_DLSCH, gNB_id, ue, dlsch0, NULL, number_pdus); + nr_fill_dl_indication(&dl_indication, NULL, rx_ind, proc, ue, gNB_id); + nr_fill_rx_indication(rx_ind, FAPI_NR_RX_PDU_TYPE_DLSCH, gNB_id, ue, dlsch0, NULL, number_pdus, proc); break; case SI_PDSCH: - nr_fill_dl_indication(&dl_indication, NULL, &rx_ind, proc, ue, gNB_id); - nr_fill_rx_indication(&rx_ind, FAPI_NR_RX_PDU_TYPE_SIB, gNB_id, ue, dlsch0, NULL, number_pdus); + nr_fill_dl_indication(&dl_indication, NULL, rx_ind, proc, ue, gNB_id); + nr_fill_rx_indication(rx_ind, FAPI_NR_RX_PDU_TYPE_SIB, gNB_id, ue, dlsch0, NULL, number_pdus, proc); break; default: break; @@ -1020,14 +811,13 @@ bool nr_ue_dlsch_procedures(PHY_VARS_NR_UE *ue, LOG_D(PHY, "In %s DL PDU length in bits: %d, in bytes: %d \n", __FUNCTION__, dlsch0->harq_processes[harq_pid]->TBS, dlsch0->harq_processes[harq_pid]->TBS / 8); - - - - stop_meas(&ue->dlsch_decoding_stats[proc->thread_id]); - LOG_D(PHY, " --> Unscrambling for CW0 %5.3f\n", - (ue->dlsch_unscrambling_stats.p_time)/(cpuf*1000.0)); - LOG_D(PHY, "AbsSubframe %d.%d --> LDPC Decoding for CW0 %5.3f\n", - frame_rx%1024, nr_slot_rx,(ue->dlsch_decoding_stats[proc->thread_id].p_time)/(cpuf*1000.0)); + stop_meas(&ue->dlsch_decoding_stats[proc->thread_id]); + if (cpumeas(CPUMEAS_GETSTATE)) { + LOG_D(PHY, " --> Unscrambling for CW0 %5.3f\n", + (ue->dlsch_unscrambling_stats.p_time)/(cpuf*1000.0)); + LOG_D(PHY, "AbsSubframe %d.%d --> LDPC Decoding for CW0 %5.3f\n", + frame_rx%1024, nr_slot_rx,(ue->dlsch_decoding_stats[proc->thread_id].p_time)/(cpuf*1000.0)); + } if(is_cw1_active) { // start ldpc decode for CW 1 @@ -1071,30 +861,17 @@ bool nr_ue_dlsch_procedures(PHY_VARS_NR_UE *ue, harq_pid, pdsch==PDSCH?1:0,//proc->decoder_switch, dlsch1->harq_processes[harq_pid]->TBS>256?1:0); - if(dlsch_parallel) { - LOG_T(PHY,"CW dlsch decoding is parallelized, ret1 = %d\n", ret1); - } - else { - - LOG_T(PHY,"CWW sequential dlsch decoding, ret1 = %d\n", ret1); - } + LOG_T(PHY,"CW dlsch decoding, ret1 = %d\n", ret1); - - stop_meas(&ue->dlsch_decoding_stats[proc->thread_id]); - LOG_D(PHY, " --> Unscrambling for CW1 %5.3f\n", - (ue->dlsch_unscrambling_stats.p_time)/(cpuf*1000.0)); - LOG_D(PHY, "AbsSubframe %d.%d --> ldpc Decoding for CW1 %5.3f\n", - frame_rx%1024, nr_slot_rx,(ue->dlsch_decoding_stats[proc->thread_id].p_time)/(cpuf*1000.0)); - - - LOG_D(PHY,"AbsSubframe %d.%d --> ldpc Decoding for CW1 %5.3f\n", - frame_rx%1024, nr_slot_rx,(ue->dlsch_decoding_stats[proc->thread_id].p_time)/(cpuf*1000.0)); - - LOG_D(PHY, "harq_pid: %d, TBS expected dlsch1: %d \n", harq_pid, dlsch1->harq_processes[harq_pid]->TBS); + stop_meas(&ue->dlsch_decoding_stats[proc->thread_id]); + if (cpumeas(CPUMEAS_GETSTATE)) { + LOG_D(PHY, " --> Unscrambling for CW1 %5.3f\n", + (ue->dlsch_unscrambling_stats.p_time)/(cpuf*1000.0)); + LOG_D(PHY, "AbsSubframe %d.%d --> ldpc Decoding for CW1 %5.3f\n", + frame_rx%1024, nr_slot_rx,(ue->dlsch_decoding_stats[proc->thread_id].p_time)/(cpuf*1000.0)); + } + LOG_D(PHY, "harq_pid: %d, TBS expected dlsch1: %d \n", harq_pid, dlsch1->harq_processes[harq_pid]->TBS); } - - LOG_D(PHY," ------ end ldpc decoder for AbsSubframe %d.%d ------ decoded in %d \n", frame_rx, nr_slot_rx, ret); - // send to mac if (ue->if_inst && ue->if_inst->dl_indication) { ue->if_inst->dl_indication(&dl_indication, ul_time_alignment); @@ -1395,8 +1172,8 @@ void *UE_thread_slot1_dl_processing(void *arg) { stop_meas(&ue->ue_front_end_per_slot_stat[proc->thread_id][1]); - LOG_D(PHY, "[AbsSFN %d.%d] Slot1: FFT + Channel Estimate + Pdsch Proc Slot0 %5.2f \n",frame_rx,nr_slot_rx,ue->ue_front_end_per_slot_stat[proc->thread_id][1].p_time/(cpuf*1000.0)); - + if (cpumeas(CPUMEAS_GETSTATE)) + LOG_D(PHY, "[AbsSFN %d.%d] Slot1: FFT + Channel Estimate + Pdsch Proc Slot0 %5.2f \n",frame_rx,nr_slot_rx,ue->ue_front_end_per_slot_stat[proc->thread_id][1].p_time/(cpuf*1000.0)); //wait until pdcch is decoded uint32_t wait = 0; @@ -1485,7 +1262,8 @@ void *UE_thread_slot1_dl_processing(void *arg) { //printf("Set available LLR slot1 to 1 AbsSubframe %d.%d \n",frame_rx,nr_slot_rx); stop_meas(&ue->pdsch_procedures_per_slot_stat[proc->thread_id][1]); - LOG_D(PHY, "[AbsSFN %d.%d] Slot1: LLR Computation %5.2f \n",frame_rx,nr_slot_rx,ue->pdsch_procedures_per_slot_stat[proc->thread_id][1].p_time/(cpuf*1000.0)); + if (cpumeas(CPUMEAS_GETSTATE)) + LOG_D(PHY, "[AbsSFN %d.%d] Slot1: LLR Computation %5.2f \n",frame_rx,nr_slot_rx,ue->pdsch_procedures_per_slot_stat[proc->thread_id][1].p_time/(cpuf*1000.0)); if (pthread_mutex_lock(&proc->mutex_slot1_dl_processing) != 0) { LOG_E( PHY, "[SCHED][UE] error locking mutex for UE RXTX\n" ); @@ -1597,6 +1375,7 @@ int phy_procedures_nrUE_RX(PHY_VARS_NR_UE *ue, NR_DL_FRAME_PARMS *fp = &ue->frame_parms; VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_PHY_PROCEDURES_UE_RX, VCD_FUNCTION_IN); + start_meas(&ue->phy_proc_rx[proc->thread_id]); LOG_D(PHY," ****** start RX-Chain for Frame.Slot %d.%d (energy %d dB)****** \n", frame_rx%1024, nr_slot_rx, @@ -1778,8 +1557,7 @@ int phy_procedures_nrUE_RX(PHY_VARS_NR_UE *ue, SI_PDSCH, ue->dlsch_SI[gNB_id], NULL, - &ue->dlsch_SI_errors[gNB_id], - dlsch_parallel); + &ue->dlsch_SI_errors[gNB_id]); // deactivate dlsch once dlsch proc is done ue->dlsch_SI[gNB_id]->active = 0; @@ -1803,8 +1581,7 @@ int phy_procedures_nrUE_RX(PHY_VARS_NR_UE *ue, P_PDSCH, ue->dlsch_p[gNB_id], NULL, - &ue->dlsch_p_errors[gNB_id], - dlsch_parallel); + &ue->dlsch_p_errors[gNB_id]); // deactivate dlsch once dlsch proc is done ue->dlsch_p[gNB_id]->active = 0; @@ -1827,19 +1604,17 @@ int phy_procedures_nrUE_RX(PHY_VARS_NR_UE *ue, RA_PDSCH, ue->dlsch_ra[gNB_id], NULL, - &ue->dlsch_ra_errors[gNB_id], - dlsch_parallel); + &ue->dlsch_ra_errors[gNB_id]); // deactivate dlsch once dlsch proc is done ue->dlsch_ra[gNB_id]->active = 0; VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_PDSCH_PROC_RA, VCD_FUNCTION_OUT); } - // do procedures for C-RNTI if (ue->dlsch[proc->thread_id][gNB_id][0]->active == 1) { - LOG_D(PHY, "DLSCH data reception at nr_slot_rx: %d \n \n", nr_slot_rx); + LOG_D(PHY, "DLSCH data reception at nr_slot_rx: %d\n", nr_slot_rx); VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_PDSCH_PROC, VCD_FUNCTION_IN); start_meas(&ue->dlsch_procedures_stat[proc->thread_id]); @@ -1851,14 +1626,13 @@ int phy_procedures_nrUE_RX(PHY_VARS_NR_UE *ue, PDSCH, ue->dlsch[proc->thread_id][gNB_id][0], ue->dlsch[proc->thread_id][gNB_id][1], - &ue->dlsch_errors[gNB_id], - dlsch_parallel); + &ue->dlsch_errors[gNB_id]); stop_meas(&ue->dlsch_procedures_stat[proc->thread_id]); - LOG_D(PHY, "[SFN %d] Slot1: Pdsch Proc %5.2f\n",nr_slot_rx,ue->pdsch_procedures_stat[proc->thread_id].p_time/(cpuf*1000.0)); - LOG_D(PHY, "[SFN %d] Slot0 Slot1: Dlsch Proc %5.2f\n",nr_slot_rx,ue->dlsch_procedures_stat[proc->thread_id].p_time/(cpuf*1000.0)); - - + if (cpumeas(CPUMEAS_GETSTATE)) { + LOG_D(PHY, "[SFN %d] Slot1: Pdsch Proc %5.2f\n",nr_slot_rx,ue->pdsch_procedures_stat[proc->thread_id].p_time/(cpuf*1000.0)); + LOG_D(PHY, "[SFN %d] Slot0 Slot1: Dlsch Proc %5.2f\n",nr_slot_rx,ue->dlsch_procedures_stat[proc->thread_id].p_time/(cpuf*1000.0)); + } // deactivate dlsch once dlsch proc is done ue->dlsch[proc->thread_id][gNB_id][0]->active = 0; @@ -1867,87 +1641,49 @@ int phy_procedures_nrUE_RX(PHY_VARS_NR_UE *ue, } -start_meas(&ue->generic_stat); - -#if 0 - - if(nr_slot_rx==5 && ue->dlsch[proc->thread_id][gNB_id][0]->harq_processes[ue->dlsch[proc->thread_id][gNB_id][0]->current_harq_pid]->nb_rb > 20){ - //write_output("decoder_llr.m","decllr",dlsch_llr,G,1,0); - //write_output("llr.m","llr", &ue->pdsch_vars[proc->thread_id][gNB_id]->llr[0][0],(14*nb_rb*12*dlsch1_harq->Qm) - 4*(nb_rb*4*dlsch1_harq->Qm),1,0); - - write_output("rxdataF0_current.m" , "rxdataF0", &ue->common_vars.common_vars_rx_data_per_thread[proc->thread_id].rxdataF[0][0],14*fp->ofdm_symbol_size,1,1); - //write_output("rxdataF0_previous.m" , "rxdataF0_prev_sss", &ue->common_vars.common_vars_rx_data_per_thread[next_thread_id].rxdataF[0][0],14*fp->ofdm_symbol_size,1,1); - - //write_output("rxdataF0_previous.m" , "rxdataF0_prev", &ue->common_vars.common_vars_rx_data_per_thread[next_thread_id].rxdataF[0][0],14*fp->ofdm_symbol_size,1,1); - - write_output("dl_ch_estimates.m", "dl_ch_estimates_sfn5", &ue->common_vars.common_vars_rx_data_per_thread[proc->thread_id].dl_ch_estimates[0][0][0],14*fp->ofdm_symbol_size,1,1); - write_output("dl_ch_estimates_ext.m", "dl_ch_estimatesExt_sfn5", &ue->pdsch_vars[proc->thread_id][gNB_id]->dl_ch_estimates_ext[0][0],14*fp->N_RB_DL*12,1,1); - write_output("rxdataF_comp00.m","rxdataF_comp00", &ue->pdsch_vars[proc->thread_id][gNB_id]->rxdataF_comp0[0][0],14*fp->N_RB_DL*12,1,1); - //write_output("magDLFirst.m", "magDLFirst", &phy_vars_ue->pdsch_vars[proc->thread_id][gNB_id]->dl_ch_mag0[0][0],14*fp->N_RB_DL*12,1,1); - //write_output("magDLSecond.m", "magDLSecond", &phy_vars_ue->pdsch_vars[proc->thread_id][gNB_id]->dl_ch_magb0[0][0],14*fp->N_RB_DL*12,1,1); - - AssertFatal (0,""); - } -#endif - - // duplicate harq structure -/* - uint8_t current_harq_pid = ue->dlsch[proc->thread_id][gNB_id][0]->current_harq_pid; - NR_DL_UE_HARQ_t *current_harq_processes = ue->dlsch[proc->thread_id][gNB_id][0]->harq_processes[current_harq_pid]; - NR_DL_UE_HARQ_t *harq_processes_dest = ue->dlsch[next1_thread_id][gNB_id][0]->harq_processes[current_harq_pid]; - NR_DL_UE_HARQ_t *harq_processes_dest1 = ue->dlsch[next2_thread_id][gNB_id][0]->harq_processes[current_harq_pid]; - */ - /*nr_harq_status_t *current_harq_ack = &ue->dlsch[proc->thread_id][gNB_id][0]->harq_ack[nr_slot_rx]; - nr_harq_status_t *harq_ack_dest = &ue->dlsch[next1_thread_id][gNB_id][0]->harq_ack[nr_slot_rx]; - nr_harq_status_t *harq_ack_dest1 = &ue->dlsch[next2_thread_id][gNB_id][0]->harq_ack[nr_slot_rx]; -*/ - - //copy_harq_proc_struct(harq_processes_dest, current_harq_processes); -//copy_ack_struct(harq_ack_dest, current_harq_ack); - -//copy_harq_proc_struct(harq_processes_dest1, current_harq_processes); -//copy_ack_struct(harq_ack_dest1, current_harq_ack); + start_meas(&ue->generic_stat); -if (nr_slot_rx==9) { - if (frame_rx % 10 == 0) { - if ((ue->dlsch_received[gNB_id] - ue->dlsch_received_last[gNB_id]) != 0) - ue->dlsch_fer[gNB_id] = (100*(ue->dlsch_errors[gNB_id] - ue->dlsch_errors_last[gNB_id]))/(ue->dlsch_received[gNB_id] - ue->dlsch_received_last[gNB_id]); + if (nr_slot_rx==9) { + if (frame_rx % 10 == 0) { + if ((ue->dlsch_received[gNB_id] - ue->dlsch_received_last[gNB_id]) != 0) + ue->dlsch_fer[gNB_id] = (100*(ue->dlsch_errors[gNB_id] - ue->dlsch_errors_last[gNB_id]))/(ue->dlsch_received[gNB_id] - ue->dlsch_received_last[gNB_id]); - ue->dlsch_errors_last[gNB_id] = ue->dlsch_errors[gNB_id]; - ue->dlsch_received_last[gNB_id] = ue->dlsch_received[gNB_id]; - } + ue->dlsch_errors_last[gNB_id] = ue->dlsch_errors[gNB_id]; + ue->dlsch_received_last[gNB_id] = ue->dlsch_received[gNB_id]; + } - ue->bitrate[gNB_id] = (ue->total_TBS[gNB_id] - ue->total_TBS_last[gNB_id])*100; - ue->total_TBS_last[gNB_id] = ue->total_TBS[gNB_id]; - LOG_D(PHY,"[UE %d] Calculating bitrate Frame %d: total_TBS = %d, total_TBS_last = %d, bitrate %f kbits\n", - ue->Mod_id,frame_rx,ue->total_TBS[gNB_id], - ue->total_TBS_last[gNB_id],(float) ue->bitrate[gNB_id]/1000.0); + ue->bitrate[gNB_id] = (ue->total_TBS[gNB_id] - ue->total_TBS_last[gNB_id])*100; + ue->total_TBS_last[gNB_id] = ue->total_TBS[gNB_id]; + LOG_D(PHY,"[UE %d] Calculating bitrate Frame %d: total_TBS = %d, total_TBS_last = %d, bitrate %f kbits\n", + ue->Mod_id,frame_rx,ue->total_TBS[gNB_id], + ue->total_TBS_last[gNB_id],(float) ue->bitrate[gNB_id]/1000.0); #if UE_AUTOTEST_TRACE - if ((frame_rx % 100 == 0)) { - LOG_I(PHY,"[UE %d] AUTOTEST Metric : UE_DLSCH_BITRATE = %5.2f kbps (frame = %d) \n", ue->Mod_id, (float) ue->bitrate[gNB_id]/1000.0, frame_rx); - } + if ((frame_rx % 100 == 0)) { + LOG_I(PHY,"[UE %d] AUTOTEST Metric : UE_DLSCH_BITRATE = %5.2f kbps (frame = %d) \n", ue->Mod_id, (float) ue->bitrate[gNB_id]/1000.0, frame_rx); + } #endif - } + } -stop_meas(&ue->generic_stat); + stop_meas(&ue->generic_stat); + if (cpumeas(CPUMEAS_GETSTATE)) + LOG_D(PHY,"after tubo until end of Rx %5.2f \n",ue->generic_stat.p_time/(cpuf*1000.0)); #ifdef EMOS -phy_procedures_emos_UE_RX(ue,slot,gNB_id); + phy_procedures_emos_UE_RX(ue,slot,gNB_id); #endif -VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_PHY_PROCEDURES_UE_RX, VCD_FUNCTION_OUT); - -stop_meas(&ue->phy_proc_rx[proc->thread_id]); -LOG_D(PHY, "------FULL RX PROC [SFN %d]: %5.2f ------\n",nr_slot_rx,ue->phy_proc_rx[proc->thread_id].p_time/(cpuf*1000.0)); + VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_PHY_PROCEDURES_UE_RX, VCD_FUNCTION_OUT); -//#endif //pdsch + stop_meas(&ue->phy_proc_rx[proc->thread_id]); + if (cpumeas(CPUMEAS_GETSTATE)) + LOG_D(PHY, "------FULL RX PROC [SFN %d]: %5.2f ------\n",nr_slot_rx,ue->phy_proc_rx[proc->thread_id].p_time/(cpuf*1000.0)); -LOG_D(PHY," ****** end RX-Chain for AbsSubframe %d.%d ****** \n", frame_rx%1024, nr_slot_rx); -return (0); + LOG_D(PHY," ****** end RX-Chain for AbsSubframe %d.%d ****** \n", frame_rx%1024, nr_slot_rx); + return (0); } diff --git a/openair1/SCHED_UE/phy_procedures_lte_ue.c b/openair1/SCHED_UE/phy_procedures_lte_ue.c index 5f8269c513d0608f86f39e8a246f165150cd45aa..4635f2b7412eea602cbf2e1714131c5f5854c048 100644 --- a/openair1/SCHED_UE/phy_procedures_lte_ue.c +++ b/openair1/SCHED_UE/phy_procedures_lte_ue.c @@ -3193,7 +3193,7 @@ void ue_pdsch_procedures(PHY_VARS_UE *ue, slot = 1; stop_meas(&ue->dlsch_llr_stats_parallelization[ue->current_thread_id[subframe_rx]][slot]); - LOG_I(PHY, "[AbsSFN %d.%d] LLR Computation Symbol %d %5.2f \n",proc->frame_rx,subframe_rx,m,ue->dlsch_llr_stats_parallelization[ue->current_thread_id[subframe_rx]][slot].p_time/(cpuf*1000.0)); + LOG_D(PHY, "[AbsSFN %d.%d] LLR Computation Symbol %d %5.2f \n",proc->frame_rx,subframe_rx,m,ue->dlsch_llr_stats_parallelization[ue->current_thread_id[subframe_rx]][slot].p_time/(cpuf*1000.0)); } if(first_symbol_flag) { @@ -3686,6 +3686,7 @@ void *UE_thread_slot1_dl_processing(void *arg) { if ( (proc->sub_frame_start+1)%RX_NB_TH == 1 && threads.slot1_proc_two != -1 ) CPU_SET(threads.slot1_proc_two, &cpuset); + // cppcheck-suppress moduloAlwaysTrueFalse if ( (proc->sub_frame_start+1)%RX_NB_TH == 2 && threads.slot1_proc_three != -1 ) CPU_SET(threads.slot1_proc_three, &cpuset); @@ -3825,7 +3826,7 @@ void *UE_thread_slot1_dl_processing(void *arg) { if ( LOG_DEBUGFLAG(UE_TIMING)) { stop_meas(&ue->ue_front_end_per_slot_stat[ue->current_thread_id[subframe_rx]][1]); - LOG_I(PHY, "[AbsSFN %d.%d] Slot1: FFT + Channel Estimate + Pdsch Proc Slot0 %5.2f \n",frame_rx,subframe_rx,ue->ue_front_end_per_slot_stat[ue->current_thread_id[subframe_rx]][1].p_time/(cpuf*1000.0)); + LOG_D(PHY, "[AbsSFN %d.%d] Slot1: FFT + Channel Estimate + Pdsch Proc Slot0 %5.2f \n",frame_rx,subframe_rx,ue->ue_front_end_per_slot_stat[ue->current_thread_id[subframe_rx]][1].p_time/(cpuf*1000.0)); } //wait until pdcch is decoded @@ -3919,7 +3920,7 @@ void *UE_thread_slot1_dl_processing(void *arg) { if ( LOG_DEBUGFLAG(UE_TIMING)) { stop_meas(&ue->pdsch_procedures_per_slot_stat[ue->current_thread_id[subframe_rx]][1]); - LOG_I(PHY, "[AbsSFN %d.%d] Slot1: LLR Computation %5.2f \n",frame_rx,subframe_rx,ue->pdsch_procedures_per_slot_stat[ue->current_thread_id[subframe_rx]][1].p_time/(cpuf*1000.0)); + LOG_D(PHY, "[AbsSFN %d.%d] Slot1: LLR Computation %5.2f \n",frame_rx,subframe_rx,ue->pdsch_procedures_per_slot_stat[ue->current_thread_id[subframe_rx]][1].p_time/(cpuf*1000.0)); } if (pthread_mutex_lock(&proc->mutex_slot1_dl_processing) != 0) { @@ -4145,7 +4146,7 @@ int phy_procedures_slot_parallelization_UE_RX(PHY_VARS_UE *ue, LOG_E(PHY,"[UE %d] Frame %d, subframe %d: Error in pdcch procedures\n",ue->Mod_id,frame_rx,subframe_rx); if (LOG_DEBUGFLAG(UE_TIMING)) { - LOG_I(PHY, "[AbsSFN %d.%d] Slot0: PDCCH %5.2f \n",frame_rx,subframe_rx,ue->pdcch_procedures_stat[ue->current_thread_id[subframe_rx]].p_time/(cpuf*1000.0)); + LOG_D(PHY, "[AbsSFN %d.%d] Slot0: PDCCH %5.2f \n",frame_rx,subframe_rx,ue->pdcch_procedures_stat[ue->current_thread_id[subframe_rx]].p_time/(cpuf*1000.0)); } //proc->dci_slot0_available = 1; @@ -4155,7 +4156,7 @@ int phy_procedures_slot_parallelization_UE_RX(PHY_VARS_UE *ue, //proc->dci_slot0_available=1; if (LOG_DEBUGFLAG(UE_TIMING)) { stop_meas(&ue->pdcch_procedures_stat[ue->current_thread_id[subframe_rx]]); - LOG_I(PHY, "[AbsSFN %d.%d] Slot0: PDCCH %5.2f \n",frame_rx,subframe_rx,ue->pdcch_procedures_stat[ue->current_thread_id[subframe_rx]].p_time/(cpuf*1000.0)); + LOG_D(PHY, "[AbsSFN %d.%d] Slot0: PDCCH %5.2f \n",frame_rx,subframe_rx,ue->pdcch_procedures_stat[ue->current_thread_id[subframe_rx]].p_time/(cpuf*1000.0)); } } @@ -4164,7 +4165,7 @@ int phy_procedures_slot_parallelization_UE_RX(PHY_VARS_UE *ue, // first slot has been processed (FFTs + Channel Estimation, PCFICH/PHICH/PDCCH) if (LOG_DEBUGFLAG(UE_TIMING)) { stop_meas(&ue->ue_front_end_per_slot_stat[ue->current_thread_id[subframe_rx]][0]); - LOG_I(PHY, "[AbsSFN %d.%d] Slot0: FFT + Channel Estimate + PCFICH/PHICH/PDCCH %5.2f \n",frame_rx,subframe_rx, + LOG_D(PHY, "[AbsSFN %d.%d] Slot0: FFT + Channel Estimate + PCFICH/PHICH/PDCCH %5.2f \n",frame_rx,subframe_rx, ue->ue_front_end_per_slot_stat[ue->current_thread_id[subframe_rx]][0].p_time/(cpuf*1000.0)); } @@ -4178,7 +4179,7 @@ int phy_procedures_slot_parallelization_UE_RX(PHY_VARS_UE *ue, if (LOG_DEBUGFLAG(UE_TIMING)) { stop_meas(&ue->ue_front_end_stat[ue->current_thread_id[subframe_rx]]); - LOG_I(PHY, "[AbsSFN %d.%d] FULL FE Processing %5.2f \n",frame_rx,subframe_rx,ue->ue_front_end_per_slot_stat[ue->current_thread_id[subframe_rx]][0].p_time/(cpuf*1000.0)); + LOG_D(PHY, "[AbsSFN %d.%d] FULL FE Processing %5.2f \n",frame_rx,subframe_rx,ue->ue_front_end_per_slot_stat[ue->current_thread_id[subframe_rx]][0].p_time/(cpuf*1000.0)); } /**** End Subframe FE Processing ****/ @@ -4266,7 +4267,7 @@ int phy_procedures_slot_parallelization_UE_RX(PHY_VARS_UE *ue, if (LOG_DEBUGFLAG(UE_TIMING)) { stop_meas(&ue->pdsch_procedures_per_slot_stat[ue->current_thread_id[subframe_rx]][0]); - LOG_I(PHY, "[AbsSFN %d.%d] Slot0: LLR Computation %5.2f \n",frame_rx,subframe_rx,ue->pdsch_procedures_per_slot_stat[ue->current_thread_id[subframe_rx]][0].p_time/(cpuf*1000.0)); + LOG_D(PHY, "[AbsSFN %d.%d] Slot0: LLR Computation %5.2f \n",frame_rx,subframe_rx,ue->pdsch_procedures_per_slot_stat[ue->current_thread_id[subframe_rx]][0].p_time/(cpuf*1000.0)); } //wait until LLR Slot1 is done @@ -4279,7 +4280,7 @@ int phy_procedures_slot_parallelization_UE_RX(PHY_VARS_UE *ue, if (LOG_DEBUGFLAG(UE_TIMING)) { stop_meas(&ue->pdsch_procedures_stat[ue->current_thread_id[subframe_rx]]); - LOG_I(PHY, "[AbsSFN %d.%d] Full LLR Computation %5.2f \n",frame_rx,subframe_rx,ue->pdsch_procedures_stat[ue->current_thread_id[subframe_rx]].p_time/(cpuf*1000.0)); + LOG_D(PHY, "[AbsSFN %d.%d] Full LLR Computation %5.2f \n",frame_rx,subframe_rx,ue->pdsch_procedures_stat[ue->current_thread_id[subframe_rx]].p_time/(cpuf*1000.0)); } //=====================================================================// @@ -4351,7 +4352,7 @@ int phy_procedures_slot_parallelization_UE_RX(PHY_VARS_UE *ue, if (LOG_DEBUGFLAG(UE_TIMING)) { stop_meas(&ue->dlsch_procedures_stat[ue->current_thread_id[subframe_rx]]); - LOG_I(PHY, "[AbsSFN %d.%d] Channel Decoder: %5.2f \n",frame_rx,subframe_rx,ue->dlsch_procedures_stat[ue->current_thread_id[subframe_rx]].p_time/(cpuf*1000.0)); + LOG_D(PHY, "[AbsSFN %d.%d] Channel Decoder: %5.2f \n",frame_rx,subframe_rx,ue->dlsch_procedures_stat[ue->current_thread_id[subframe_rx]].p_time/(cpuf*1000.0)); } // duplicate harq structure diff --git a/openair1/SCHED_UE/pusch_pc.c b/openair1/SCHED_UE/pusch_pc.c index 503d73005f25adcc5bd7afe8b8d2fe61ff0af2ea..55c8c7c547cfd2055e28bdc1eba3f9329ac544b8 100644 --- a/openair1/SCHED_UE/pusch_pc.c +++ b/openair1/SCHED_UE/pusch_pc.c @@ -115,7 +115,7 @@ void pusch_power_cntl(PHY_VARS_UE *ue,UE_rxtx_proc_t *proc,uint8_t eNB_id,uint8_ } int8_t get_PHR(uint8_t Mod_id, uint8_t CC_id,uint8_t eNB_index) { - if(NFAPI_MODE!=NFAPI_UE_STUB_PNF) + if(NFAPI_MODE!=NFAPI_UE_STUB_PNF && NFAPI_MODE!=NFAPI_MODE_STANDALONE_PNF) return PHY_vars_UE_g[Mod_id][CC_id]->ulsch[eNB_index]->PHR; else return 40; // l1l2 simulator => ideal conditions diff --git a/openair1/SIMULATION/ETH_TRANSPORT/netlink_init.c b/openair1/SIMULATION/ETH_TRANSPORT/netlink_init.c index 9b4aba46c394f1715b6209bcb802449fddd5c450..53374476782af8f5db96aab0878001cd24a034c9 100644 --- a/openair1/SIMULATION/ETH_TRANSPORT/netlink_init.c +++ b/openair1/SIMULATION/ETH_TRANSPORT/netlink_init.c @@ -56,7 +56,7 @@ struct nlmsghdr *nas_nlh_rx = NULL; struct iovec nas_iov_tx; struct iovec nas_iov_rx = {nl_rx_buf, sizeof(nl_rx_buf)}; -int nas_sock_fd[MAX_MOBILES_PER_ENB]; +int nas_sock_fd[MAX_MOBILES_PER_ENB*2]; //Allocated for both LTE UE and NR UE. int nas_sock_mbms_fd; @@ -70,7 +70,7 @@ static int tun_alloc(char *dev) { int fd, err; if( (fd = open("/dev/net/tun", O_RDWR)) < 0 ) { - printf("[TUN] failed to open /dev/net/tun\n"); + LOG_E(PDCP, "[TUN] failed to open /dev/net/tun\n"); return -1; } @@ -95,15 +95,20 @@ static int tun_alloc(char *dev) { } -int netlink_init_mbms_tun(char *ifprefix) { +int netlink_init_mbms_tun(char *ifprefix, int id) {//for UE, id = 1, 2, ..., int ret; char ifname[64]; - sprintf(ifname, "oaitun_%.3s1",ifprefix); // added "1": for historical reasons + if (id > 0) { + sprintf(ifname, "oaitun_%.3s%d", ifprefix, id-1); + } + else { + sprintf(ifname, "oaitun_%.3s1", ifprefix); // added "1": for historical reasons + } nas_sock_mbms_fd = tun_alloc(ifname); if (nas_sock_mbms_fd == -1) { - printf("[NETLINK] Error opening socket %s (%d:%s)\n",ifname,errno, strerror(errno)); + printf("[NETLINK] Error opening mbms socket %s (%d:%s)\n",ifname,errno, strerror(errno)); exit(1); } @@ -123,88 +128,36 @@ int netlink_init_mbms_tun(char *ifprefix) { nas_src_addr.nl_pid = 1;//getpid(); /* self pid */ nas_src_addr.nl_groups = 0; /* not in mcast groups */ ret = bind(nas_sock_mbms_fd, (struct sockaddr *)&nas_src_addr, sizeof(nas_src_addr)); - memset(&nas_dest_addr, 0, sizeof(nas_dest_addr)); - nas_dest_addr.nl_family = AF_NETLINK; - nas_dest_addr.nl_pid = 0; /* For Linux Kernel */ - nas_dest_addr.nl_groups = 0; /* unicast */ - // TX PART - nas_nlh_tx=(struct nlmsghdr *)malloc(NLMSG_SPACE(NL_MAX_PAYLOAD)); - memset(nas_nlh_tx, 0, NLMSG_SPACE(NL_MAX_PAYLOAD)); - /* Fill the netlink message header */ - nas_nlh_tx->nlmsg_len = NLMSG_SPACE(NL_MAX_PAYLOAD); - nas_nlh_tx->nlmsg_pid = 1;//getpid(); /* self pid */ - nas_nlh_tx->nlmsg_flags = 0; - nas_iov_tx.iov_base = (void *)nas_nlh_tx; - nas_iov_tx.iov_len = nas_nlh_tx->nlmsg_len; - memset(&nas_msg_tx,0,sizeof(nas_msg_tx)); - nas_msg_tx.msg_name = (void *)&nas_dest_addr; - nas_msg_tx.msg_namelen = sizeof(nas_dest_addr); - nas_msg_tx.msg_iov = &nas_iov_tx; - nas_msg_tx.msg_iovlen = 1; - // RX PART - memset(&nas_msg_rx,0,sizeof(nas_msg_rx)); - nas_msg_rx.msg_name = (void *)&nas_src_addr; - nas_msg_rx.msg_namelen = sizeof(nas_src_addr); - nas_msg_rx.msg_iov = &nas_iov_rx; - nas_msg_rx.msg_iovlen = 1; return 1; } -int netlink_init_tun(char *ifprefix, int num_if) { +int netlink_init_tun(char *ifprefix, int num_if, int id) {//for UE, id = 1, 2, ..., int ret; char ifname[64]; - for (int i = 0; i < num_if; i++) { + int begx = (id == 0) ? 0 : id - 1; + int endx = (id == 0) ? num_if : id; + for (int i = begx; i < endx; i++) { sprintf(ifname, "oaitun_%.3s%d",ifprefix,i+1); nas_sock_fd[i] = tun_alloc(ifname); if (nas_sock_fd[i] == -1) { - printf("[NETLINK] Error opening socket %s (%d:%s)\n",ifname,errno, strerror(errno)); + LOG_E(PDCP, "TUN: Error opening socket %s (%d:%s)\n",ifname,errno, strerror(errno)); exit(1); } - printf("[NETLINK]Opened socket %s with fd nas_sock_fd[%d]=%d\n", + LOG_I(PDCP, "TUN: Opened socket %s with fd nas_sock_fd[%d]=%d\n", ifname, i, nas_sock_fd[i]); ret = fcntl(nas_sock_fd[i],F_SETFL,O_NONBLOCK); if (ret == -1) { - printf("[NETLINK] Error fcntl (%d:%s)\n",errno, strerror(errno)); + LOG_E(PDCP, "TUN: Error fcntl (%d:%s)\n",errno, strerror(errno)); if (LINK_ENB_PDCP_TO_IP_DRIVER) { exit(1); } } - - memset(&nas_src_addr, 0, sizeof(nas_src_addr)); - nas_src_addr.nl_family = AF_NETLINK; - nas_src_addr.nl_pid = 1;//getpid(); /* self pid */ - nas_src_addr.nl_groups = 0; /* not in mcast groups */ - ret = bind(nas_sock_fd[i], (struct sockaddr *)&nas_src_addr, sizeof(nas_src_addr)); - memset(&nas_dest_addr, 0, sizeof(nas_dest_addr)); - nas_dest_addr.nl_family = AF_NETLINK; - nas_dest_addr.nl_pid = 0; /* For Linux Kernel */ - nas_dest_addr.nl_groups = 0; /* unicast */ - // TX PART - nas_nlh_tx=(struct nlmsghdr *)malloc(NLMSG_SPACE(NL_MAX_PAYLOAD)); - memset(nas_nlh_tx, 0, NLMSG_SPACE(NL_MAX_PAYLOAD)); - /* Fill the netlink message header */ - nas_nlh_tx->nlmsg_len = NLMSG_SPACE(NL_MAX_PAYLOAD); - nas_nlh_tx->nlmsg_pid = 1;//getpid(); /* self pid */ - nas_nlh_tx->nlmsg_flags = 0; - nas_iov_tx.iov_base = (void *)nas_nlh_tx; - nas_iov_tx.iov_len = nas_nlh_tx->nlmsg_len; - memset(&nas_msg_tx,0,sizeof(nas_msg_tx)); - nas_msg_tx.msg_name = (void *)&nas_dest_addr; - nas_msg_tx.msg_namelen = sizeof(nas_dest_addr); - nas_msg_tx.msg_iov = &nas_iov_tx; - nas_msg_tx.msg_iovlen = 1; - // RX PART - memset(&nas_msg_rx,0,sizeof(nas_msg_rx)); - nas_msg_rx.msg_name = (void *)&nas_src_addr; - nas_msg_rx.msg_namelen = sizeof(nas_src_addr); - nas_msg_rx.msg_iov = &nas_iov_rx; - nas_msg_rx.msg_iovlen = 1; } /* for */ return 1; @@ -216,7 +169,7 @@ int netlink_init(void) { nas_sock_fd[0] = socket(PF_NETLINK, SOCK_RAW,GRAAL_NETLINK_ID); if (nas_sock_fd[0] == -1) { - printf("[NETLINK] Error opening socket %d (%d:%s)\n",nas_sock_fd[0],errno, strerror(errno)); + printf("[NETLINK] Error opening GRAAL_NETLINK_ID socket %d (%d:%s)\n",nas_sock_fd[0],errno, strerror(errno)); if (LINK_ENB_PDCP_TO_IP_DRIVER) { exit(1); @@ -244,6 +197,7 @@ int netlink_init(void) { nas_dest_addr.nl_pid = 0; /* For Linux Kernel */ nas_dest_addr.nl_groups = 0; /* unicast */ // TX PART + free(nas_nlh_tx); nas_nlh_tx=(struct nlmsghdr *)malloc(NLMSG_SPACE(NL_MAX_PAYLOAD)); memset(nas_nlh_tx, 0, NLMSG_SPACE(NL_MAX_PAYLOAD)); /* Fill the netlink message header */ @@ -266,3 +220,8 @@ int netlink_init(void) { return(nas_sock_fd[0]); } +void netlink_cleanup(void) +{ + free(nas_nlh_tx); + nas_nlh_tx = NULL; +} diff --git a/openair1/SIMULATION/ETH_TRANSPORT/proto.h b/openair1/SIMULATION/ETH_TRANSPORT/proto.h index e6159199d40898b0d8357a03cac3210a8c0d4426..bc6990ac3e84fdb45d781490e7f58cc64d633d0c 100644 --- a/openair1/SIMULATION/ETH_TRANSPORT/proto.h +++ b/openair1/SIMULATION/ETH_TRANSPORT/proto.h @@ -62,7 +62,8 @@ int multicast_link_read_data_from_sock(uint8_t eNB_flag); void clear_eNB_transport_info(uint8_t); void clear_UE_transport_info(uint8_t); int netlink_init(void); -int netlink_init_tun(char *ifsuffix, int num_if); -int netlink_init_mbms_tun(char *ifsuffix); +int netlink_init_tun(char *ifsuffix, int num_if, int id); +int netlink_init_mbms_tun(char *ifsuffix, int id); +void netlink_cleanup(void); #endif /* EMU_PROTO_H_ */ diff --git a/openair1/SIMULATION/LTE_PHY/common_sim.h b/openair1/SIMULATION/LTE_PHY/common_sim.h index 5e0be3de895bcfce53c3e643643f498e2a08eb8f..5625cf8e2f65c22a00c66f8ead548d9ebb5cd40b 100644 --- a/openair1/SIMULATION/LTE_PHY/common_sim.h +++ b/openair1/SIMULATION/LTE_PHY/common_sim.h @@ -134,16 +134,16 @@ struct option * parse_oai_options(paramdef_t *options) { void display_options_values(paramdef_t *options, int verbose) { for(paramdef_t * ptr=options; ptr->optname[0]!=0; ptr++) { - char varText[256]="need specific display"; + char varText[256]={0}; if (ptr->voidptr != NULL) { if ( (ptr->paramflags & PARAMFLAG_BOOL) ) strcpy(varText, *(bool *)ptr->iptr ? "True": "False" ); else switch (ptr->type) { - case TYPE_INT: - sprintf(varText,"%d",*ptr->iptr); - break; - + case TYPE_INT: + sprintf(varText,"%d",*ptr->iptr); + break; + case TYPE_DOUBLE: sprintf(varText,"%.2f",*ptr->dblptr); break; @@ -157,6 +157,7 @@ void display_options_values(paramdef_t *options, int verbose) { break; default: + strcpy(varText,"Need specific display"); printf("not decoded type\n"); exit(1); } diff --git a/openair1/SIMULATION/LTE_PHY/dlsim.c b/openair1/SIMULATION/LTE_PHY/dlsim.c index d4106cb29a50b839538ff212c6a908bc40a69cb0..c1443700f331362add8263ef43c598f9ed6eb282 100644 --- a/openair1/SIMULATION/LTE_PHY/dlsim.c +++ b/openair1/SIMULATION/LTE_PHY/dlsim.c @@ -634,7 +634,7 @@ int main(int argc, char **argv) { // num_layers = 1; perfect_ce = 0; static paramdef_t options[] = { - { "awgn", "Use AWGN channel and not multipath", PARAMFLAG_BOOL, strptr:NULL, defintval:0, TYPE_INT, 0, NULL, NULL }, + { "awgn", "Use AWGN channel and not multipath", PARAMFLAG_BOOL, iptr:&awgn_flag, defintval:0, TYPE_INT, 0, NULL, NULL }, { "Abstx", "Turns on calibration mode for abstraction.", PARAMFLAG_BOOL, iptr:&abstx, defintval:0, TYPE_INT, 0 }, { "bTDD", "Set the tdd configuration mode",0, iptr:&tdd_config, defintval:3, TYPE_INT, 0 }, { "BnbRBs", "The LTE bandwith in RBs (100 is 20MHz)",0, iptr:&N_RB_DL, defintval:25, TYPE_INT, 0 }, @@ -1234,7 +1234,7 @@ int main(int argc, char **argv) { break; } - for (k=0; k<NUMBER_OF_UE_MAX; k++) { + for (k=0; k<NUMBER_OF_DLSCH_MAX; k++) { // Create transport channel structures for 2 transport blocks (MIMO) for (i=0; i<2; i++) { eNB->dlsch[k][i] = new_eNB_dlsch(Kmimo,8,Nsoft,N_RB_DL,0,&eNB->frame_parms); @@ -1247,6 +1247,17 @@ int main(int argc, char **argv) { eNB->dlsch[k][i]->rnti = n_rnti+k; } } + + for (int i=0;i<NUMBER_OF_ULSCH_MAX; i++) { + + LOG_I(PHY,"Allocating Transport Channel Buffer for ULSCH %d/%d\n",i,NUMBER_OF_ULSCH_MAX); + eNB->ulsch[i] = new_eNB_ulsch(MAX_TURBO_ITERATIONS,eNB->frame_parms.N_RB_UL, 0); + + if (!eNB->ulsch[i]) { + LOG_E(PHY,"Can't get eNB ulsch structures\n"); + exit(-1); + } + } /* allocate memory for both subframes (only one is really used * but there is now "copy_harq_proc_struct" which needs both @@ -1815,12 +1826,12 @@ int main(int argc, char **argv) { if (t_rx > 2000 ) n_rx_dropped++; - appendVarArray(table_tx, &t_tx); - appendVarArray(table_tx_ifft, &t_tx_ifft); - appendVarArray(table_rx, &t_rx ); - appendVarArray(table_rx_fft, &t_rx_fft ); - appendVarArray(table_rx_demod, &t_rx_demod ); - appendVarArray(table_rx_dec, &t_rx_dec ); + appendVarArray(&table_tx, &t_tx); + appendVarArray(&table_tx_ifft, &t_tx_ifft); + appendVarArray(&table_rx, &t_rx ); + appendVarArray(&table_rx_fft, &t_rx_fft ); + appendVarArray(&table_rx_demod, &t_rx_demod ); + appendVarArray(&table_rx_dec, &t_rx_dec ); } //trials // round_trials[0]: number of code word : goodput the protocol diff --git a/openair1/SIMULATION/LTE_PHY/dummy_functions.c b/openair1/SIMULATION/LTE_PHY/dummy_functions.c index 120e4845d92608ccc11c9f30080030fc70f8e103..fcbab51f4b4f7cb662178e084706982e74b7e042 100644 --- a/openair1/SIMULATION/LTE_PHY/dummy_functions.c +++ b/openair1/SIMULATION/LTE_PHY/dummy_functions.c @@ -86,12 +86,6 @@ int8_t get_Po_NOMINAL_PUSCH(module_id_t module_idP, uint8_t CC_id) { return(0);} int8_t get_deltaP_rampup(module_id_t module_idP, uint8_t CC_id) { return(0);} -void thread_top_init(char *thread_name, - int affinity, - uint64_t runtime, - uint64_t deadline, - uint64_t period) {} - int oai_nfapi_hi_dci0_req(nfapi_hi_dci0_request_t *hi_dci0_req) { return(0);} int oai_nfapi_tx_req(nfapi_tx_request_t *tx_req) { return(0); } diff --git a/openair1/SIMULATION/LTE_PHY/mbmssim.c b/openair1/SIMULATION/LTE_PHY/mbmssim.c index 53c15ccc89c287ec2a70a3456495126372ef8f99..31c3b47227aa680235300adbc7bcfe5ebbaa8d09 100644 --- a/openair1/SIMULATION/LTE_PHY/mbmssim.c +++ b/openair1/SIMULATION/LTE_PHY/mbmssim.c @@ -1971,12 +1971,12 @@ int main(int argc, char **argv) { if (t_rx > 2000 ) n_rx_dropped++; - appendVarArray(table_tx, &t_tx); - appendVarArray(table_tx_ifft, &t_tx_ifft); - appendVarArray(table_rx, &t_rx ); - appendVarArray(table_rx_fft, &t_rx_fft ); - appendVarArray(table_rx_demod, &t_rx_demod ); - appendVarArray(table_rx_dec, &t_rx_dec ); + appendVarArray(&table_tx, &t_tx); + appendVarArray(&table_tx_ifft, &t_tx_ifft); + appendVarArray(&table_rx, &t_rx ); + appendVarArray(&table_rx_fft, &t_rx_fft ); + appendVarArray(&table_rx_demod, &t_rx_demod ); + appendVarArray(&table_rx_dec, &t_rx_dec ); } //trials // round_trials[0]: number of code word : goodput the protocol diff --git a/openair1/SIMULATION/LTE_PHY/ulsim.c b/openair1/SIMULATION/LTE_PHY/ulsim.c index 39593a640c487eba7b90448a89a4589e3c810664..1b1058535e6fc6d77c931d37e0bd6dfc9aed1d2b 100644 --- a/openair1/SIMULATION/LTE_PHY/ulsim.c +++ b/openair1/SIMULATION/LTE_PHY/ulsim.c @@ -743,7 +743,7 @@ int main(int argc, char **argv) { UE2eNB->max_Doppler = maxDoppler; // NN: N_RB_UL has to be defined in ulsim - for (int k=0; k<NUMBER_OF_UE_MAX; k++) eNB->ulsch[k] = new_eNB_ulsch(max_turbo_iterations,N_RB_DL,0); + for (int k=0; k<NUMBER_OF_ULSCH_MAX; k++) eNB->ulsch[k] = new_eNB_ulsch(max_turbo_iterations,N_RB_DL,0); UE->ulsch[0] = new_ue_ulsch(N_RB_DL,0); printf("ULSCH %p\n",UE->ulsch[0]); @@ -1279,14 +1279,14 @@ int main(int argc, char **argv) { n_rx_dropped++; if (trials < 1000) { - appendVarArray(table_tx, &t_tx); - appendVarArray(table_tx_ifft, &t_tx_ifft); - appendVarArray(table_tx_mod, &t_tx_mod ); - appendVarArray(table_tx_enc, &t_tx_enc ); - appendVarArray(table_rx, &t_rx ); - appendVarArray(table_rx_fft, &t_rx_fft ); - appendVarArray(table_rx_demod, &t_rx_demod ); - appendVarArray(table_rx_dec, &t_rx_dec ); + appendVarArray(&table_tx, &t_tx); + appendVarArray(&table_tx_ifft, &t_tx_ifft); + appendVarArray(&table_tx_mod, &t_tx_mod ); + appendVarArray(&table_tx_enc, &t_tx_enc ); + appendVarArray(&table_rx, &t_rx ); + appendVarArray(&table_rx_fft, &t_rx_fft ); + appendVarArray(&table_rx_demod, &t_rx_demod ); + appendVarArray(&table_rx_dec, &t_rx_dec ); } } //trials diff --git a/openair1/SIMULATION/NR_PHY/dlschsim.c b/openair1/SIMULATION/NR_PHY/dlschsim.c index b268e46233b89beadbf9cd1857f831667fcd2b7d..f566b93d9c31c138eb4351aabac30309f1ce60ed 100644 --- a/openair1/SIMULATION/NR_PHY/dlschsim.c +++ b/openair1/SIMULATION/NR_PHY/dlschsim.c @@ -59,8 +59,7 @@ double cpuf; //uint8_t nfapi_mode = 0; uint16_t NB_UE_INST = 1; -uint8_t const nr_rv_round_map[4] = {0, 2, 1, 3}; -uint8_t const nr_rv_round_map_ue[4] = {0, 2, 1, 3}; +uint8_t const nr_rv_round_map[4] = {0, 2, 3, 1}; // needed for some functions PHY_VARS_NR_UE *PHY_vars_UE_g[1][1] = { { NULL } }; @@ -68,7 +67,6 @@ uint16_t n_rnti = 0x1234; openair0_config_t openair0_cfg[MAX_CARDS]; void init_downlink_harq_status(NR_DL_UE_HARQ_t *dl_harq) {} -void processSlotTX(void *arg) {} int main(int argc, char **argv) { @@ -118,10 +116,9 @@ int main(int argc, char **argv) uint8_t Imcs = 9; uint8_t mcs_table = 0; double DS_TDL = .03; - cpuf = get_cpu_freq_GHz(); - char gNBthreads[128]="n"; + cpuf = get_cpu_freq_GHz(); + char gNBthreads[128]="n"; - if (load_configmodule(argc, argv, CONFIG_ENABLECMDLINEONLY) == 0) { exit_fun("[NR_DLSCHSIM] Error, configuration module init failed\n"); } @@ -129,7 +126,7 @@ int main(int argc, char **argv) //logInit(); randominit(0); - while ((c = getopt(argc, argv, "df:hpVg:i:j:n:l:m:r:s:S:y:z:M:N:F:R:P:L:")) != -1) { + while ((c = getopt(argc, argv, "df:hpVg:i:j:n:l:m:r:s:S:y:z:M:N:F:R:P:L:X:")) != -1) { switch (c) { /*case 'f': write_output_file = 1; @@ -295,6 +292,11 @@ int main(int argc, char **argv) nb_rb = atoi(optarg); break; + case 'X': + strncpy(gNBthreads, optarg, sizeof(gNBthreads)); + gNBthreads[sizeof(gNBthreads)-1]=0; + break; + /*case 'x': transmission_mode = atoi(optarg); break;*/ @@ -355,6 +357,8 @@ int main(int argc, char **argv) RC.gNB = (PHY_VARS_gNB **) malloc(sizeof(PHY_VARS_gNB *)); RC.gNB[0] = malloc(sizeof(PHY_VARS_gNB)); gNB = RC.gNB[0]; + gNB->threadPool = (tpool_t*)malloc(sizeof(tpool_t)); + initTpool(gNBthreads, gNB->threadPool, true); //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; @@ -432,22 +436,9 @@ int main(int argc, char **argv) UE->dlsch_SI[0] = new_nr_ue_dlsch(1, 1, Nsoft, 5, N_RB_DL, 0); UE->dlsch_ra[0] = new_nr_ue_dlsch(1, 1, Nsoft, 5, N_RB_DL, 0); unsigned char harq_pid = 0; //dlsch->harq_ids[subframe]; - - gNB->threadPool = (tpool_t*)malloc(sizeof(tpool_t)); - initTpool(gNBthreads, gNB->threadPool, true); - gNB->resp_L1_tx = (notifiedFIFO_t*) malloc(sizeof(notifiedFIFO_t)); - initNotifiedFIFO(gNB->resp_L1_tx); - // we create 2 threads for L1 tx processing - notifiedFIFO_elt_t *msgL1Tx = newNotifiedFIFO_elt(sizeof(processingData_L1tx_t),0,gNB->resp_L1_tx,processSlotTX); - processingData_L1tx_t *msgDataTx = (processingData_L1tx_t *)NotifiedFifoData(msgL1Tx); - init_DLSCH_struct(gNB, msgDataTx); - msgDataTx->slot = slot; - msgDataTx->frame = frame; - memset(msgDataTx->ssb, 0, 64*sizeof(NR_gNB_SSB_t)); - reset_meas(&msgDataTx->phy_proc_tx); - gNB->phy_proc_tx_0 = &msgDataTx->phy_proc_tx; - pushTpool(gNB->threadPool,msgL1Tx); - NR_gNB_DLSCH_t *dlsch = msgDataTx->dlsch[0][0]; + processingData_L1tx_t msgDataTx; + init_DLSCH_struct(gNB, &msgDataTx); + NR_gNB_DLSCH_t *dlsch = msgDataTx.dlsch[0][0]; nfapi_nr_dl_tti_pdsch_pdu_rel15_t *rel15 = &dlsch->harq_process.pdsch_pdu.pdsch_pdu_rel15; //time_stats_t *rm_stats, *te_stats, *i_stats; uint8_t is_crnti = 0, llr8_flag = 0; @@ -484,7 +475,6 @@ int main(int argc, char **argv) double *modulated_input = malloc16(sizeof(double) * 16 * 68 * 384); // [hna] 16 segments, 68*Zc short *channel_output_fixed = malloc16(sizeof(short) * 16 * 68 * 384); short *channel_output_uncoded = malloc16(sizeof(unsigned short) * 16 * 68 * 384); - double errors_bit_uncoded = 0; //unsigned char *estimated_output; unsigned char *estimated_output_bit; unsigned char *test_input_bit; @@ -520,11 +510,10 @@ int main(int argc, char **argv) /*for (int i=0; i<TBS/8; i++) printf("test input[%d]=%d \n",i,test_input[i]);*/ - //printf("crc32: [0]->0x%08x\n",crc24c(test_input, 32)); // generate signal - unsigned char output[rel15->rbSize * NR_SYMBOLS_PER_SLOT * NR_NB_SC_PER_RB * 8 * NR_MAX_NB_LAYERS] __attribute__((aligned(32))); - bzero(output,rel15->rbSize * NR_SYMBOLS_PER_SLOT * NR_NB_SC_PER_RB * 8 * NR_MAX_NB_LAYERS); + unsigned char output[rel15->rbSize * NR_SYMBOLS_PER_SLOT * NR_NB_SC_PER_RB * 8 * NR_MAX_NB_LAYERS] __attribute__((aligned(32))); + bzero(output,rel15->rbSize * NR_SYMBOLS_PER_SLOT * NR_NB_SC_PER_RB * 8 * NR_MAX_NB_LAYERS); if (input_fd == NULL) { nr_dlsch_encoding(gNB, test_input, frame, slot, dlsch, frame_parms,output,NULL,NULL,NULL,NULL,NULL,NULL,NULL); } @@ -534,7 +523,6 @@ int main(int argc, char **argv) n_false_positive = 0; for (trial = 0; trial < n_trials; trial++) { - errors_bit_uncoded = 0; for (i = 0; i < available_bits; i++) { #ifdef DEBUG_CODER if ((i&0xf)==0) @@ -543,12 +531,12 @@ int main(int argc, char **argv) //if (i<16) // printf("encoder output f[%d] = %d\n",i,dlsch->harq_processes[0]->f[i]); - /* - if (dlsch->harq_process.f[i] == 0) + + if (output[i] == 0) modulated_input[i] = 1.0; ///sqrt(2); //QPSK else modulated_input[i] = -1.0; ///sqrt(2); - */ + //if (i<16) printf("modulated_input[%d] = %d\n",i,modulated_input[i]); //SNR =10; SNR_lin = pow(10, SNR / 10.0); @@ -566,19 +554,14 @@ int main(int argc, char **argv) i,modulated_input[i], i,channel_output_fixed[i]); */ + //Uncoded BER if (channel_output_fixed[i] < 0) channel_output_uncoded[i] = 1; //QPSK demod else channel_output_uncoded[i] = 0; - /* - if (channel_output_uncoded[i] != dlsch->harq_process.f[i]) - errors_bit_uncoded = errors_bit_uncoded + 1; - */ } - //if (errors_bit_uncoded>10) - //printf("errors bits uncoded %f\n", errors_bit_uncoded); #ifdef DEBUG_CODER printf("\n"); exit(-1); @@ -660,7 +643,7 @@ int main(int argc, char **argv) for (i = 0; i < 2; i++) { printf("gNB %d\n", i); - free_gNB_dlsch(&(msgDataTx->dlsch[0][i]),N_RB_DL); + free_gNB_dlsch(&(msgDataTx.dlsch[0][i]),N_RB_DL); printf("UE %d\n", i); free_nr_ue_dlsch(&(UE->dlsch[0][0][i]),N_RB_DL); } diff --git a/openair1/SIMULATION/NR_PHY/dlsim.c b/openair1/SIMULATION/NR_PHY/dlsim.c index 8d4191d8e3a032abd3eb3e560b1e92c7eef4643f..b8f51f8e958fe0c69d11bdbba82a54f703e8acd6 100644 --- a/openair1/SIMULATION/NR_PHY/dlsim.c +++ b/openair1/SIMULATION/NR_PHY/dlsim.c @@ -71,6 +71,7 @@ #include <openair2/RRC/LTE/rrc_vars.h> #include <executables/softmodem-common.h> +#include <openair3/ocp-gtpu/gtp_itf.h> LCHAN_DESC DCCH_LCHAN_DESC,DTCH_DL_LCHAN_DESC,DTCH_UL_LCHAN_DESC; rlc_info_t Rlc_info_um,Rlc_info_am_config; @@ -81,6 +82,7 @@ RAN_CONTEXT_t RC; int32_t uplink_frequency_offset[MAX_NUM_CCs][4]; double cpuf; +char *uecap_file; uint16_t sf_ahead=4 ; uint16_t sl_ahead=0; @@ -89,6 +91,13 @@ uint64_t downlink_frequency[MAX_NUM_CCs][4]; THREAD_STRUCT thread_struct; nfapi_ue_release_request_body_t release_rntis; uint32_t N_RB_DL = 106; +//Fixme: Uniq dirty DU instance, by global var, datamodel need better management +instance_t DUuniqInstance=0; +instance_t CUuniqInstance=0; +teid_t newGtpuCreateTunnel(instance_t instance, rnti_t rnti, int incoming_bearer_id, int outgoing_bearer_id, teid_t outgoing_teid, + transport_layer_addr_t remoteAddr, int port, gtpCallback callBack) { +return 0; +} // dummy functions int dummy_nr_ue_ul_indication(nr_uplink_indication_t *ul_info) { return(0); } @@ -131,12 +140,6 @@ rrc_data_ind( { } -int ocp_gtpv1u_create_s1u_tunnel(instance_t instance, - const gtpv1u_enb_create_tunnel_req_t *create_tunnel_req, - gtpv1u_enb_create_tunnel_resp_t *create_tunnel_resp) { - return 0; -} - int gtpv1u_create_s1u_tunnel( const instance_t instanceP, @@ -400,7 +403,7 @@ int main(int argc, char **argv) NR_UE_MAC_INST_t *UE_mac; int cyclic_prefix_type = NFAPI_CP_NORMAL; int run_initial_sync=0; - int loglvl=OAILOG_INFO; + int loglvl=OAILOG_WARNING; //float target_error_rate = 0.01; int css_flag=0; @@ -645,6 +648,7 @@ int main(int argc, char **argv) printf("%s -h(elp) -p(extended_prefix) -N cell_id -f output_filename -F input_filename -g channel_model -n n_frames -t Delayspread -s snr0 -S snr1 -x transmission_mode -y TXant -z RXant -i Intefrence0 -j Interference1 -A interpolation_file -C(alibration offset dB) -N CellId\n", argv[0]); printf("-h This message\n"); + printf("-L <log level, 0(errors), 1(warning), 2(info) 3(debug) 4 (trace)>\n"); //printf("-p Use extended prefix mode\n"); //printf("-d Use TDD\n"); printf("-n Number of frames to simulate\n"); @@ -767,13 +771,13 @@ int main(int argc, char **argv) NR_CellGroupConfig_t *secondaryCellGroup=calloc(1,sizeof(*secondaryCellGroup)); prepare_scc(rrc.carrier.servingcellconfigcommon); uint64_t ssb_bitmap = 1; - fill_scc(rrc.carrier.servingcellconfigcommon,&ssb_bitmap,N_RB_DL,N_RB_DL,mu,mu); + fill_scc_sim(rrc.carrier.servingcellconfigcommon,&ssb_bitmap,N_RB_DL,N_RB_DL,mu,mu); ssb_bitmap = 1;// Enable only first SSB with index ssb_indx=0 fix_scc(scc,ssb_bitmap); prepare_scd(scd); - fill_default_secondaryCellGroup(scc, scd, secondaryCellGroup, 0, 1, n_tx, 0, 0, 0); + fill_default_secondaryCellGroup(scc, scd, secondaryCellGroup, 0, 1, n_tx, 6, 0, 0, 0, 0); /* RRC parameter validation for secondaryCellGroup */ fix_scd(scd); @@ -980,18 +984,21 @@ int main(int argc, char **argv) gNB->threadPool = (tpool_t*)malloc(sizeof(tpool_t)); initTpool(gNBthreads, gNB->threadPool, true); - gNB->resp_L1_tx = (notifiedFIFO_t*) malloc(sizeof(notifiedFIFO_t)); - initNotifiedFIFO(gNB->resp_L1_tx); + gNB->L1_tx_free = (notifiedFIFO_t*) malloc(sizeof(notifiedFIFO_t)); + gNB->L1_tx_filled = (notifiedFIFO_t*) malloc(sizeof(notifiedFIFO_t)); + gNB->L1_tx_out = (notifiedFIFO_t*) malloc(sizeof(notifiedFIFO_t)); + initNotifiedFIFO(gNB->L1_tx_free); + initNotifiedFIFO(gNB->L1_tx_filled); + initNotifiedFIFO(gNB->L1_tx_out); // we create 2 threads for L1 tx processing - notifiedFIFO_elt_t *msgL1Tx = newNotifiedFIFO_elt(sizeof(processingData_L1tx_t),0,gNB->resp_L1_tx,processSlotTX); + notifiedFIFO_elt_t *msgL1Tx = newNotifiedFIFO_elt(sizeof(processingData_L1tx_t),0,gNB->L1_tx_free,processSlotTX); processingData_L1tx_t *msgDataTx = (processingData_L1tx_t *)NotifiedFifoData(msgL1Tx); init_DLSCH_struct(gNB, msgDataTx); msgDataTx->slot = slot; msgDataTx->frame = frame; memset(msgDataTx->ssb, 0, 64*sizeof(NR_gNB_SSB_t)); reset_meas(&msgDataTx->phy_proc_tx); - gNB->phy_proc_tx_0 = &msgDataTx->phy_proc_tx; - pushTpool(gNB->threadPool,msgL1Tx); + gNB->phy_proc_tx[0] = &msgDataTx->phy_proc_tx; for (SNR = snr0; SNR < snr1; SNR += .2) { @@ -1046,8 +1053,6 @@ int main(int argc, char **argv) while ((round<num_rounds) && (UE_harq_process->ack==0)) { - memset(RC.nrmac[0]->cce_list[1][0],0,MAX_NUM_CCE*sizeof(int)); - memset(RC.nrmac[0]->cce_list[1][1],0,MAX_NUM_CCE*sizeof(int)); clear_nr_nfapi_information(RC.nrmac[0], 0, frame, slot); UE_info->UE_sched_ctrl[0].harq_processes[harq_pid].ndi = !(trial&1); @@ -1055,7 +1060,7 @@ int main(int argc, char **argv) UE_info->UE_sched_ctrl[0].harq_processes[harq_pid].round = round; for (int i=0; i<MAX_NUM_CORESET; i++) - gNB_mac->UE_info.num_pdcch_cand[0][i] = 0; + gNB_mac->pdcch_cand[i] = 0; if (css_flag == 0) { nr_schedule_ue_spec(0, frame, slot); @@ -1070,6 +1075,7 @@ int main(int argc, char **argv) Sched_INFO.UL_tti_req = gNB_mac->UL_tti_req_ahead[slot]; Sched_INFO.UL_dci_req = NULL; Sched_INFO.TX_req = &gNB_mac->TX_req[0]; + pushNotifiedFIFO(gNB->L1_tx_free,msgL1Tx); nr_schedule_response(&Sched_INFO); /* PTRS values for DLSIM calculations */ @@ -1096,7 +1102,7 @@ int main(int argc, char **argv) else phy_procedures_gNB_TX(msgDataTx,frame,slot,1); - int txdataF_offset = (slot%2) * frame_parms->samples_per_slot_wCP; + int txdataF_offset = slot * frame_parms->samples_per_slot_wCP; if (n_trials==1) { LOG_M("txsigF0.m","txsF0=", &gNB->common_vars.txdataF[0][txdataF_offset+2*frame_parms->ofdm_symbol_size],frame_parms->ofdm_symbol_size,1,1); @@ -1303,10 +1309,10 @@ int main(int argc, char **argv) printf("\n"); if (print_perf==1) { - printf("\ngNB TX function statistics (per %d us slot, NPRB %d, mcs %d, TBS %d)\n", + printf("\ngNB TX function statistics (per %d us slot, NPRB %d, mcs %d, block %d)\n", 1000>>*scc->ssbSubcarrierSpacing, g_rbSize, g_mcsIndex, msgDataTx->dlsch[0][0]->harq_process.pdsch_pdu.pdsch_pdu_rel15.TBSize[0]<<3); - printDistribution(gNB->phy_proc_tx_0,table_tx,"PHY proc tx"); + printDistribution(gNB->phy_proc_tx[0],table_tx,"PHY proc tx"); printStatIndent2(&gNB->dlsch_encoding_stats,"DLSCH encoding time"); printStatIndent3(&gNB->dlsch_segmentation_stats,"DLSCH segmentation time"); printStatIndent3(&gNB->tinput,"DLSCH LDPC input processing time"); diff --git a/openair1/SIMULATION/NR_PHY/nr_dummy_functions.c b/openair1/SIMULATION/NR_PHY/nr_dummy_functions.c index 056b018504ab6387e2eb82f5a3cae3a0d367c748..7a47410129f2f78f43df8f9b597675a7c6217e78 100644 --- a/openair1/SIMULATION/NR_PHY/nr_dummy_functions.c +++ b/openair1/SIMULATION/NR_PHY/nr_dummy_functions.c @@ -34,4 +34,5 @@ void nr_fill_rx_indication(fapi_nr_rx_indication_t *rx_ind, PHY_VARS_NR_UE *ue, NR_UE_DLSCH_t *dlsch0, NR_UE_DLSCH_t *dlsch1, - uint16_t n_pdus) {} + uint16_t n_pdus, + UE_nr_rxtx_proc_t *proc) {} diff --git a/openair1/SIMULATION/NR_PHY/nr_unitary_defs.h b/openair1/SIMULATION/NR_PHY/nr_unitary_defs.h index 8d4acd1af1f2b2726a6885f8f6e53d34b284e7aa..805913d055511bae547898822e9a3e8681bf4c4c 100644 --- a/openair1/SIMULATION/NR_PHY/nr_unitary_defs.h +++ b/openair1/SIMULATION/NR_PHY/nr_unitary_defs.h @@ -59,167 +59,7 @@ int oai_nfapi_rach_ind(nfapi_rach_indication_t *rach_ind) {return(0);} //NR_IF_Module_t *NR_IF_Module_init(int Mod_id){return(NULL);} int oai_nfapi_ul_config_req(nfapi_ul_config_request_t *ul_config_req) { return(0); } - -void fill_scc(NR_ServingCellConfigCommon_t *scc,uint64_t *ssb_bitmap,int N_RB_DL,int N_RB_UL,int mu_dl,int mu_ul) { - - *scc->physCellId=0; \ - // *scc->n_TimingAdvanceOffset=NR_ServingCellConfigCommon__n_TimingAdvanceOffset_n0; - *scc->ssb_periodicityServingCell=NR_ServingCellConfigCommon__ssb_periodicityServingCell_ms20; - scc->dmrs_TypeA_Position=NR_ServingCellConfigCommon__dmrs_TypeA_Position_pos2; - *scc->ssbSubcarrierSpacing=NR_SubcarrierSpacing_kHz30; - *scc->downlinkConfigCommon->frequencyInfoDL->absoluteFrequencySSB=641032; - *scc->downlinkConfigCommon->frequencyInfoDL->frequencyBandList.list.array[0]=78; - scc->downlinkConfigCommon->frequencyInfoDL->absoluteFrequencyPointA=640000; - scc->downlinkConfigCommon->frequencyInfoDL->scs_SpecificCarrierList.list.array[0]->offsetToCarrier=0; - scc->downlinkConfigCommon->frequencyInfoDL->scs_SpecificCarrierList.list.array[0]->subcarrierSpacing=NR_SubcarrierSpacing_kHz30; - - scc->downlinkConfigCommon->frequencyInfoDL->scs_SpecificCarrierList.list.array[0]->carrierBandwidth=N_RB_DL; - scc->downlinkConfigCommon->initialDownlinkBWP->genericParameters.locationAndBandwidth=13036; - scc->downlinkConfigCommon->initialDownlinkBWP->genericParameters.subcarrierSpacing=mu_dl;//NR_SubcarrierSpacing_kHz30; - *scc->downlinkConfigCommon->initialDownlinkBWP->pdcch_ConfigCommon->choice.setup->controlResourceSetZero=12; - *scc->downlinkConfigCommon->initialDownlinkBWP->pdcch_ConfigCommon->choice.setup->searchSpaceZero=0; - *scc->downlinkConfigCommon->initialDownlinkBWP->pdsch_ConfigCommon->choice.setup->pdsch_TimeDomainAllocationList->list.array[0]->k0=0; - scc->downlinkConfigCommon->initialDownlinkBWP->pdsch_ConfigCommon->choice.setup->pdsch_TimeDomainAllocationList->list.array[0]->mappingType=NR_PDSCH_TimeDomainResourceAllocation__mappingType_typeA; - scc->downlinkConfigCommon->initialDownlinkBWP->pdsch_ConfigCommon->choice.setup->pdsch_TimeDomainAllocationList->list.array[0]->startSymbolAndLength=40; - *scc->downlinkConfigCommon->initialDownlinkBWP->pdsch_ConfigCommon->choice.setup->pdsch_TimeDomainAllocationList->list.array[1]->k0=0; - scc->downlinkConfigCommon->initialDownlinkBWP->pdsch_ConfigCommon->choice.setup->pdsch_TimeDomainAllocationList->list.array[1]->mappingType=NR_PDSCH_TimeDomainResourceAllocation__mappingType_typeA; - scc->downlinkConfigCommon->initialDownlinkBWP->pdsch_ConfigCommon->choice.setup->pdsch_TimeDomainAllocationList->list.array[1]->startSymbolAndLength=53; - *scc->downlinkConfigCommon->initialDownlinkBWP->pdsch_ConfigCommon->choice.setup->pdsch_TimeDomainAllocationList->list.array[2]->k0=0; - scc->downlinkConfigCommon->initialDownlinkBWP->pdsch_ConfigCommon->choice.setup->pdsch_TimeDomainAllocationList->list.array[2]->mappingType=NR_PDSCH_TimeDomainResourceAllocation__mappingType_typeA; - scc->downlinkConfigCommon->initialDownlinkBWP->pdsch_ConfigCommon->choice.setup->pdsch_TimeDomainAllocationList->list.array[2]->startSymbolAndLength=54; - *scc->downlinkConfigCommon->initialDownlinkBWP->pdsch_ConfigCommon->choice.setup->pdsch_TimeDomainAllocationList->list.array[3]->k0=-1; - scc->downlinkConfigCommon->initialDownlinkBWP->pdsch_ConfigCommon->choice.setup->pdsch_TimeDomainAllocationList->list.array[3]->mappingType=NR_PDSCH_TimeDomainResourceAllocation__mappingType_typeA; - scc->downlinkConfigCommon->initialDownlinkBWP->pdsch_ConfigCommon->choice.setup->pdsch_TimeDomainAllocationList->list.array[3]->startSymbolAndLength=54; - *scc->downlinkConfigCommon->initialDownlinkBWP->pdsch_ConfigCommon->choice.setup->pdsch_TimeDomainAllocationList->list.array[4]->k0=-1; - scc->downlinkConfigCommon->initialDownlinkBWP->pdsch_ConfigCommon->choice.setup->pdsch_TimeDomainAllocationList->list.array[4]->mappingType=NR_PDSCH_TimeDomainResourceAllocation__mappingType_typeA; - scc->downlinkConfigCommon->initialDownlinkBWP->pdsch_ConfigCommon->choice.setup->pdsch_TimeDomainAllocationList->list.array[4]->startSymbolAndLength=54; - *scc->downlinkConfigCommon->initialDownlinkBWP->pdsch_ConfigCommon->choice.setup->pdsch_TimeDomainAllocationList->list.array[5]->k0=-1; - scc->downlinkConfigCommon->initialDownlinkBWP->pdsch_ConfigCommon->choice.setup->pdsch_TimeDomainAllocationList->list.array[5]->mappingType=NR_PDSCH_TimeDomainResourceAllocation__mappingType_typeA; - scc->downlinkConfigCommon->initialDownlinkBWP->pdsch_ConfigCommon->choice.setup->pdsch_TimeDomainAllocationList->list.array[5]->startSymbolAndLength=54; - *scc->downlinkConfigCommon->initialDownlinkBWP->pdsch_ConfigCommon->choice.setup->pdsch_TimeDomainAllocationList->list.array[6]->k0=-1; - scc->downlinkConfigCommon->initialDownlinkBWP->pdsch_ConfigCommon->choice.setup->pdsch_TimeDomainAllocationList->list.array[6]->mappingType=NR_PDSCH_TimeDomainResourceAllocation__mappingType_typeA; - scc->downlinkConfigCommon->initialDownlinkBWP->pdsch_ConfigCommon->choice.setup->pdsch_TimeDomainAllocationList->list.array[6]->startSymbolAndLength=54; - *scc->downlinkConfigCommon->initialDownlinkBWP->pdsch_ConfigCommon->choice.setup->pdsch_TimeDomainAllocationList->list.array[7]->k0=-1; - scc->downlinkConfigCommon->initialDownlinkBWP->pdsch_ConfigCommon->choice.setup->pdsch_TimeDomainAllocationList->list.array[7]->mappingType=NR_PDSCH_TimeDomainResourceAllocation__mappingType_typeA; - scc->downlinkConfigCommon->initialDownlinkBWP->pdsch_ConfigCommon->choice.setup->pdsch_TimeDomainAllocationList->list.array[7]->startSymbolAndLength=54; - *scc->downlinkConfigCommon->initialDownlinkBWP->pdsch_ConfigCommon->choice.setup->pdsch_TimeDomainAllocationList->list.array[8]->k0=-1; - scc->downlinkConfigCommon->initialDownlinkBWP->pdsch_ConfigCommon->choice.setup->pdsch_TimeDomainAllocationList->list.array[8]->mappingType=NR_PDSCH_TimeDomainResourceAllocation__mappingType_typeA; - scc->downlinkConfigCommon->initialDownlinkBWP->pdsch_ConfigCommon->choice.setup->pdsch_TimeDomainAllocationList->list.array[8]->startSymbolAndLength=54; - *scc->downlinkConfigCommon->initialDownlinkBWP->pdsch_ConfigCommon->choice.setup->pdsch_TimeDomainAllocationList->list.array[9]->k0=-1; - scc->downlinkConfigCommon->initialDownlinkBWP->pdsch_ConfigCommon->choice.setup->pdsch_TimeDomainAllocationList->list.array[9]->mappingType=NR_PDSCH_TimeDomainResourceAllocation__mappingType_typeA; - scc->downlinkConfigCommon->initialDownlinkBWP->pdsch_ConfigCommon->choice.setup->pdsch_TimeDomainAllocationList->list.array[9]->startSymbolAndLength=54; - *scc->downlinkConfigCommon->initialDownlinkBWP->pdsch_ConfigCommon->choice.setup->pdsch_TimeDomainAllocationList->list.array[10]->k0=-1; - scc->downlinkConfigCommon->initialDownlinkBWP->pdsch_ConfigCommon->choice.setup->pdsch_TimeDomainAllocationList->list.array[10]->mappingType=NR_PDSCH_TimeDomainResourceAllocation__mappingType_typeA; - scc->downlinkConfigCommon->initialDownlinkBWP->pdsch_ConfigCommon->choice.setup->pdsch_TimeDomainAllocationList->list.array[10]->startSymbolAndLength=54; - *scc->downlinkConfigCommon->initialDownlinkBWP->pdsch_ConfigCommon->choice.setup->pdsch_TimeDomainAllocationList->list.array[11]->k0=-1; - scc->downlinkConfigCommon->initialDownlinkBWP->pdsch_ConfigCommon->choice.setup->pdsch_TimeDomainAllocationList->list.array[11]->mappingType=NR_PDSCH_TimeDomainResourceAllocation__mappingType_typeA; - scc->downlinkConfigCommon->initialDownlinkBWP->pdsch_ConfigCommon->choice.setup->pdsch_TimeDomainAllocationList->list.array[11]->startSymbolAndLength=54; - *scc->downlinkConfigCommon->initialDownlinkBWP->pdsch_ConfigCommon->choice.setup->pdsch_TimeDomainAllocationList->list.array[12]->k0=-1; - scc->downlinkConfigCommon->initialDownlinkBWP->pdsch_ConfigCommon->choice.setup->pdsch_TimeDomainAllocationList->list.array[12]->mappingType=NR_PDSCH_TimeDomainResourceAllocation__mappingType_typeA; - scc->downlinkConfigCommon->initialDownlinkBWP->pdsch_ConfigCommon->choice.setup->pdsch_TimeDomainAllocationList->list.array[12]->startSymbolAndLength=54; - *scc->downlinkConfigCommon->initialDownlinkBWP->pdsch_ConfigCommon->choice.setup->pdsch_TimeDomainAllocationList->list.array[13]->k0=-1; - scc->downlinkConfigCommon->initialDownlinkBWP->pdsch_ConfigCommon->choice.setup->pdsch_TimeDomainAllocationList->list.array[13]->mappingType=NR_PDSCH_TimeDomainResourceAllocation__mappingType_typeA; - scc->downlinkConfigCommon->initialDownlinkBWP->pdsch_ConfigCommon->choice.setup->pdsch_TimeDomainAllocationList->list.array[13]->startSymbolAndLength=54; - *scc->downlinkConfigCommon->initialDownlinkBWP->pdsch_ConfigCommon->choice.setup->pdsch_TimeDomainAllocationList->list.array[14]->k0=-1; - scc->downlinkConfigCommon->initialDownlinkBWP->pdsch_ConfigCommon->choice.setup->pdsch_TimeDomainAllocationList->list.array[14]->mappingType=NR_PDSCH_TimeDomainResourceAllocation__mappingType_typeA; - scc->downlinkConfigCommon->initialDownlinkBWP->pdsch_ConfigCommon->choice.setup->pdsch_TimeDomainAllocationList->list.array[14]->startSymbolAndLength=54; - *scc->downlinkConfigCommon->initialDownlinkBWP->pdsch_ConfigCommon->choice.setup->pdsch_TimeDomainAllocationList->list.array[15]->k0=-1; - scc->downlinkConfigCommon->initialDownlinkBWP->pdsch_ConfigCommon->choice.setup->pdsch_TimeDomainAllocationList->list.array[15]->mappingType=NR_PDSCH_TimeDomainResourceAllocation__mappingType_typeA; - scc->downlinkConfigCommon->initialDownlinkBWP->pdsch_ConfigCommon->choice.setup->pdsch_TimeDomainAllocationList->list.array[15]->startSymbolAndLength=54; - *scc->uplinkConfigCommon->frequencyInfoUL->frequencyBandList->list.array[0]=78; - *scc->uplinkConfigCommon->frequencyInfoUL->absoluteFrequencyPointA=-1; - scc->uplinkConfigCommon->frequencyInfoUL->scs_SpecificCarrierList.list.array[0]->offsetToCarrier=0; - scc->uplinkConfigCommon->frequencyInfoUL->scs_SpecificCarrierList.list.array[0]->subcarrierSpacing=NR_SubcarrierSpacing_kHz30; - scc->uplinkConfigCommon->frequencyInfoUL->scs_SpecificCarrierList.list.array[0]->carrierBandwidth=N_RB_UL; - *scc->uplinkConfigCommon->frequencyInfoUL->p_Max=20; - scc->uplinkConfigCommon->initialUplinkBWP->genericParameters.locationAndBandwidth=13036; - scc->uplinkConfigCommon->initialUplinkBWP->genericParameters.subcarrierSpacing=mu_ul;//NR_SubcarrierSpacing_kHz30; - scc->uplinkConfigCommon->initialUplinkBWP->rach_ConfigCommon->choice.setup->rach_ConfigGeneric.prach_ConfigurationIndex=98; - scc->uplinkConfigCommon->initialUplinkBWP->rach_ConfigCommon->choice.setup->rach_ConfigGeneric.msg1_FDM=NR_RACH_ConfigGeneric__msg1_FDM_one; - scc->uplinkConfigCommon->initialUplinkBWP->rach_ConfigCommon->choice.setup->rach_ConfigGeneric.msg1_FrequencyStart=0; - scc->uplinkConfigCommon->initialUplinkBWP->rach_ConfigCommon->choice.setup->rach_ConfigGeneric.zeroCorrelationZoneConfig=13; - scc->uplinkConfigCommon->initialUplinkBWP->rach_ConfigCommon->choice.setup->rach_ConfigGeneric.preambleReceivedTargetPower=-118; - scc->uplinkConfigCommon->initialUplinkBWP->rach_ConfigCommon->choice.setup->rach_ConfigGeneric.preambleTransMax=NR_RACH_ConfigGeneric__preambleTransMax_n10; - scc->uplinkConfigCommon->initialUplinkBWP->rach_ConfigCommon->choice.setup->rach_ConfigGeneric.powerRampingStep=NR_RACH_ConfigGeneric__powerRampingStep_dB2; - scc->uplinkConfigCommon->initialUplinkBWP->rach_ConfigCommon->choice.setup->rach_ConfigGeneric.ra_ResponseWindow=NR_RACH_ConfigGeneric__ra_ResponseWindow_sl20; - scc->uplinkConfigCommon->initialUplinkBWP->rach_ConfigCommon->choice.setup->ssb_perRACH_OccasionAndCB_PreamblesPerSSB->present=NR_RACH_ConfigCommon__ssb_perRACH_OccasionAndCB_PreamblesPerSSB_PR_one; - scc->uplinkConfigCommon->initialUplinkBWP->rach_ConfigCommon->choice.setup->ssb_perRACH_OccasionAndCB_PreamblesPerSSB->choice.one=NR_RACH_ConfigCommon__ssb_perRACH_OccasionAndCB_PreamblesPerSSB__one_n64; - scc->uplinkConfigCommon->initialUplinkBWP->rach_ConfigCommon->choice.setup->ra_ContentionResolutionTimer=NR_RACH_ConfigCommon__ra_ContentionResolutionTimer_sf64; - *scc->uplinkConfigCommon->initialUplinkBWP->rach_ConfigCommon->choice.setup->rsrp_ThresholdSSB=19; - scc->uplinkConfigCommon->initialUplinkBWP->rach_ConfigCommon->choice.setup->prach_RootSequenceIndex.present=NR_RACH_ConfigCommon__prach_RootSequenceIndex_PR_l139; - scc->uplinkConfigCommon->initialUplinkBWP->rach_ConfigCommon->choice.setup->prach_RootSequenceIndex.choice.l139=0; - scc->uplinkConfigCommon->initialUplinkBWP->rach_ConfigCommon->choice.setup->restrictedSetConfig=NR_RACH_ConfigCommon__restrictedSetConfig_unrestrictedSet; - *scc->uplinkConfigCommon->initialUplinkBWP->pusch_ConfigCommon->choice.setup->pusch_TimeDomainAllocationList->list.array[0]->k2=6; - scc->uplinkConfigCommon->initialUplinkBWP->pusch_ConfigCommon->choice.setup->pusch_TimeDomainAllocationList->list.array[0]->mappingType=NR_PUSCH_TimeDomainResourceAllocation__mappingType_typeB; - scc->uplinkConfigCommon->initialUplinkBWP->pusch_ConfigCommon->choice.setup->pusch_TimeDomainAllocationList->list.array[0]->startSymbolAndLength=55; - *scc->uplinkConfigCommon->initialUplinkBWP->pusch_ConfigCommon->choice.setup->pusch_TimeDomainAllocationList->list.array[1]->k2=6; - scc->uplinkConfigCommon->initialUplinkBWP->pusch_ConfigCommon->choice.setup->pusch_TimeDomainAllocationList->list.array[1]->mappingType=NR_PUSCH_TimeDomainResourceAllocation__mappingType_typeB; - scc->uplinkConfigCommon->initialUplinkBWP->pusch_ConfigCommon->choice.setup->pusch_TimeDomainAllocationList->list.array[1]->startSymbolAndLength=69; - *scc->uplinkConfigCommon->initialUplinkBWP->pusch_ConfigCommon->choice.setup->pusch_TimeDomainAllocationList->list.array[2]->k2=6; - scc->uplinkConfigCommon->initialUplinkBWP->pusch_ConfigCommon->choice.setup->pusch_TimeDomainAllocationList->list.array[2]->mappingType=NR_PUSCH_TimeDomainResourceAllocation__mappingType_typeB; - scc->uplinkConfigCommon->initialUplinkBWP->pusch_ConfigCommon->choice.setup->pusch_TimeDomainAllocationList->list.array[2]->startSymbolAndLength=55; - *scc->uplinkConfigCommon->initialUplinkBWP->pusch_ConfigCommon->choice.setup->pusch_TimeDomainAllocationList->list.array[3]->k2=33; - scc->uplinkConfigCommon->initialUplinkBWP->pusch_ConfigCommon->choice.setup->pusch_TimeDomainAllocationList->list.array[3]->mappingType=NR_PUSCH_TimeDomainResourceAllocation__mappingType_typeB; - scc->uplinkConfigCommon->initialUplinkBWP->pusch_ConfigCommon->choice.setup->pusch_TimeDomainAllocationList->list.array[3]->startSymbolAndLength=55; - *scc->uplinkConfigCommon->initialUplinkBWP->pusch_ConfigCommon->choice.setup->pusch_TimeDomainAllocationList->list.array[4]->k2=33; - scc->uplinkConfigCommon->initialUplinkBWP->pusch_ConfigCommon->choice.setup->pusch_TimeDomainAllocationList->list.array[4]->mappingType=NR_PUSCH_TimeDomainResourceAllocation__mappingType_typeB; - scc->uplinkConfigCommon->initialUplinkBWP->pusch_ConfigCommon->choice.setup->pusch_TimeDomainAllocationList->list.array[4]->startSymbolAndLength=55; - *scc->uplinkConfigCommon->initialUplinkBWP->pusch_ConfigCommon->choice.setup->pusch_TimeDomainAllocationList->list.array[5]->k2=33; - scc->uplinkConfigCommon->initialUplinkBWP->pusch_ConfigCommon->choice.setup->pusch_TimeDomainAllocationList->list.array[5]->mappingType=NR_PUSCH_TimeDomainResourceAllocation__mappingType_typeB; - scc->uplinkConfigCommon->initialUplinkBWP->pusch_ConfigCommon->choice.setup->pusch_TimeDomainAllocationList->list.array[5]->startSymbolAndLength=55; - *scc->uplinkConfigCommon->initialUplinkBWP->pusch_ConfigCommon->choice.setup->pusch_TimeDomainAllocationList->list.array[6]->k2=33; - scc->uplinkConfigCommon->initialUplinkBWP->pusch_ConfigCommon->choice.setup->pusch_TimeDomainAllocationList->list.array[6]->mappingType=NR_PUSCH_TimeDomainResourceAllocation__mappingType_typeB; - scc->uplinkConfigCommon->initialUplinkBWP->pusch_ConfigCommon->choice.setup->pusch_TimeDomainAllocationList->list.array[6]->startSymbolAndLength=55; - *scc->uplinkConfigCommon->initialUplinkBWP->pusch_ConfigCommon->choice.setup->pusch_TimeDomainAllocationList->list.array[7]->k2=33; - scc->uplinkConfigCommon->initialUplinkBWP->pusch_ConfigCommon->choice.setup->pusch_TimeDomainAllocationList->list.array[7]->mappingType=NR_PUSCH_TimeDomainResourceAllocation__mappingType_typeB; - scc->uplinkConfigCommon->initialUplinkBWP->pusch_ConfigCommon->choice.setup->pusch_TimeDomainAllocationList->list.array[7]->startSymbolAndLength=55; - *scc->uplinkConfigCommon->initialUplinkBWP->pusch_ConfigCommon->choice.setup->pusch_TimeDomainAllocationList->list.array[8]->k2=33; - scc->uplinkConfigCommon->initialUplinkBWP->pusch_ConfigCommon->choice.setup->pusch_TimeDomainAllocationList->list.array[8]->mappingType=NR_PUSCH_TimeDomainResourceAllocation__mappingType_typeB; - scc->uplinkConfigCommon->initialUplinkBWP->pusch_ConfigCommon->choice.setup->pusch_TimeDomainAllocationList->list.array[8]->startSymbolAndLength=55; - *scc->uplinkConfigCommon->initialUplinkBWP->pusch_ConfigCommon->choice.setup->pusch_TimeDomainAllocationList->list.array[9]->k2=33; - scc->uplinkConfigCommon->initialUplinkBWP->pusch_ConfigCommon->choice.setup->pusch_TimeDomainAllocationList->list.array[9]->mappingType=NR_PUSCH_TimeDomainResourceAllocation__mappingType_typeB; - scc->uplinkConfigCommon->initialUplinkBWP->pusch_ConfigCommon->choice.setup->pusch_TimeDomainAllocationList->list.array[9]->startSymbolAndLength=55; - *scc->uplinkConfigCommon->initialUplinkBWP->pusch_ConfigCommon->choice.setup->pusch_TimeDomainAllocationList->list.array[10]->k2=33; - scc->uplinkConfigCommon->initialUplinkBWP->pusch_ConfigCommon->choice.setup->pusch_TimeDomainAllocationList->list.array[10]->mappingType=NR_PUSCH_TimeDomainResourceAllocation__mappingType_typeB; - scc->uplinkConfigCommon->initialUplinkBWP->pusch_ConfigCommon->choice.setup->pusch_TimeDomainAllocationList->list.array[10]->startSymbolAndLength=55; - *scc->uplinkConfigCommon->initialUplinkBWP->pusch_ConfigCommon->choice.setup->pusch_TimeDomainAllocationList->list.array[11]->k2=33; - scc->uplinkConfigCommon->initialUplinkBWP->pusch_ConfigCommon->choice.setup->pusch_TimeDomainAllocationList->list.array[11]->mappingType=NR_PUSCH_TimeDomainResourceAllocation__mappingType_typeB; - scc->uplinkConfigCommon->initialUplinkBWP->pusch_ConfigCommon->choice.setup->pusch_TimeDomainAllocationList->list.array[11]->startSymbolAndLength=55; - *scc->uplinkConfigCommon->initialUplinkBWP->pusch_ConfigCommon->choice.setup->pusch_TimeDomainAllocationList->list.array[12]->k2=33; - scc->uplinkConfigCommon->initialUplinkBWP->pusch_ConfigCommon->choice.setup->pusch_TimeDomainAllocationList->list.array[12]->mappingType=NR_PUSCH_TimeDomainResourceAllocation__mappingType_typeB; - scc->uplinkConfigCommon->initialUplinkBWP->pusch_ConfigCommon->choice.setup->pusch_TimeDomainAllocationList->list.array[12]->startSymbolAndLength=55; - *scc->uplinkConfigCommon->initialUplinkBWP->pusch_ConfigCommon->choice.setup->pusch_TimeDomainAllocationList->list.array[13]->k2=33; - scc->uplinkConfigCommon->initialUplinkBWP->pusch_ConfigCommon->choice.setup->pusch_TimeDomainAllocationList->list.array[13]->mappingType=NR_PUSCH_TimeDomainResourceAllocation__mappingType_typeB; - scc->uplinkConfigCommon->initialUplinkBWP->pusch_ConfigCommon->choice.setup->pusch_TimeDomainAllocationList->list.array[13]->startSymbolAndLength=55; - *scc->uplinkConfigCommon->initialUplinkBWP->pusch_ConfigCommon->choice.setup->pusch_TimeDomainAllocationList->list.array[14]->k2=33; - scc->uplinkConfigCommon->initialUplinkBWP->pusch_ConfigCommon->choice.setup->pusch_TimeDomainAllocationList->list.array[14]->mappingType=NR_PUSCH_TimeDomainResourceAllocation__mappingType_typeB; - scc->uplinkConfigCommon->initialUplinkBWP->pusch_ConfigCommon->choice.setup->pusch_TimeDomainAllocationList->list.array[14]->startSymbolAndLength=55; - *scc->uplinkConfigCommon->initialUplinkBWP->pusch_ConfigCommon->choice.setup->pusch_TimeDomainAllocationList->list.array[15]->k2=33; - scc->uplinkConfigCommon->initialUplinkBWP->pusch_ConfigCommon->choice.setup->pusch_TimeDomainAllocationList->list.array[15]->mappingType=NR_PUSCH_TimeDomainResourceAllocation__mappingType_typeB; - scc->uplinkConfigCommon->initialUplinkBWP->pusch_ConfigCommon->choice.setup->pusch_TimeDomainAllocationList->list.array[15]->startSymbolAndLength=55; - *scc->uplinkConfigCommon->initialUplinkBWP->pusch_ConfigCommon->choice.setup->msg3_DeltaPreamble=1; - *scc->uplinkConfigCommon->initialUplinkBWP->pusch_ConfigCommon->choice.setup->p0_NominalWithGrant=-90; - scc->uplinkConfigCommon->initialUplinkBWP->pucch_ConfigCommon->choice.setup->pucch_GroupHopping=NR_PUCCH_ConfigCommon__pucch_GroupHopping_neither; - *scc->uplinkConfigCommon->initialUplinkBWP->pucch_ConfigCommon->choice.setup->hoppingId=40; - *scc->uplinkConfigCommon->initialUplinkBWP->pucch_ConfigCommon->choice.setup->p0_nominal=-90; - scc->ssb_PositionsInBurst->present=NR_ServingCellConfigCommon__ssb_PositionsInBurst_PR_mediumBitmap; - *ssb_bitmap=0xff; - scc->tdd_UL_DL_ConfigurationCommon->referenceSubcarrierSpacing=NR_SubcarrierSpacing_kHz30; - scc->tdd_UL_DL_ConfigurationCommon->pattern1.dl_UL_TransmissionPeriodicity=NR_TDD_UL_DL_Pattern__dl_UL_TransmissionPeriodicity_ms5; - scc->tdd_UL_DL_ConfigurationCommon->pattern1.nrofDownlinkSlots=7; - scc->tdd_UL_DL_ConfigurationCommon->pattern1.nrofDownlinkSymbols=6; - scc->tdd_UL_DL_ConfigurationCommon->pattern1.nrofUplinkSlots=2; - scc->tdd_UL_DL_ConfigurationCommon->pattern1.nrofUplinkSymbols=4; - scc->tdd_UL_DL_ConfigurationCommon->pattern2->dl_UL_TransmissionPeriodicity=321; - - scc->tdd_UL_DL_ConfigurationCommon->pattern2->nrofDownlinkSlots=-1; - scc->tdd_UL_DL_ConfigurationCommon->pattern2->nrofDownlinkSymbols=-1; - scc->tdd_UL_DL_ConfigurationCommon->pattern2->nrofUplinkSlots=-1; - scc->tdd_UL_DL_ConfigurationCommon->pattern2->nrofUplinkSymbols=-1; - scc->ss_PBCH_BlockPower=20; - *scc->uplinkConfigCommon->initialUplinkBWP->rach_ConfigCommon->choice.setup->msg1_SubcarrierSpacing=-1; -} - +void fill_scc_sim(NR_ServingCellConfigCommon_t *scc,uint64_t *ssb_bitmap,int N_RB_DL,int N_RB_UL,int mu_dl,int mu_ul); void fix_scc(NR_ServingCellConfigCommon_t *scc,uint64_t ssbmap); void prepare_scc(NR_ServingCellConfigCommon_t *scc); void prepare_scd(NR_ServingCellConfig_t *scd); diff --git a/openair1/SIMULATION/NR_PHY/pbchsim.c b/openair1/SIMULATION/NR_PHY/pbchsim.c index 1169b8ecd8e5e18b67a1157717c7f1bb1f4ebb7f..c6b547cd79b4346dac610adfbde956497c5aa069 100644 --- a/openair1/SIMULATION/NR_PHY/pbchsim.c +++ b/openair1/SIMULATION/NR_PHY/pbchsim.c @@ -63,8 +63,7 @@ uint16_t NB_UE_INST = 1; // needed for some functions openair0_config_t openair0_cfg[MAX_CARDS]; -uint8_t const nr_rv_round_map[4] = {0, 2, 1, 3}; -uint8_t const nr_rv_round_map_ue[4] = {0, 2, 1, 3}; +uint8_t const nr_rv_round_map[4] = {0, 2, 3, 1}; uint64_t get_softmodem_optmask(void) {return 0;} softmodem_params_t *get_softmodem_params(void) {return 0;} @@ -91,8 +90,7 @@ bool nr_ue_dlsch_procedures(PHY_VARS_NR_UE *ue, PDSCH_t pdsch, NR_UE_DLSCH_t *dlsch0, NR_UE_DLSCH_t *dlsch1, - int *dlsch_errors, - uint8_t dlsch_parallel) { + int *dlsch_errors) { return false; } @@ -193,6 +191,7 @@ int main(int argc, char **argv) int frame=0; int frame_length_complex_samples; + __attribute__((unused)) int frame_length_complex_samples_no_prefix; NR_DL_FRAME_PARMS *frame_parms; @@ -713,7 +712,7 @@ int main(int argc, char **argv) } if (UE->is_synchronized == 0) { UE_nr_rxtx_proc_t proc={0}; - ret = nr_initial_sync(&proc, UE, 1, 0, 0); + ret = nr_initial_sync(&proc, UE, 1, 0); printf("nr_initial_sync1 returns %d\n",ret); if (ret<0) n_errors++; } diff --git a/openair1/SIMULATION/NR_PHY/prachsim.c b/openair1/SIMULATION/NR_PHY/prachsim.c index a33713234c174ecdbd1f75bdb927c2bdde766f87..fb0f37d7ac6665e3a1ab6d39f9fbf1bdb72b1b53 100644 --- a/openair1/SIMULATION/NR_PHY/prachsim.c +++ b/openair1/SIMULATION/NR_PHY/prachsim.c @@ -52,6 +52,7 @@ #include <executables/softmodem-common.h> #include <openair2/RRC/NR_UE/rrc_defs.h> //#include "openair1/SIMULATION/NR_PHY/nr_dummy_functions.c" +#include <openair3/ocp-gtpu/gtp_itf.h> #define NR_PRACH_DEBUG 1 #define PRACH_WRITE_OUTPUT_DEBUG 1 @@ -59,6 +60,7 @@ LCHAN_DESC DCCH_LCHAN_DESC,DTCH_DL_LCHAN_DESC,DTCH_UL_LCHAN_DESC; rlc_info_t Rlc_info_um,Rlc_info_am_config; +char *uecap_file; PHY_VARS_gNB *gNB; PHY_VARS_NR_UE *UE; RAN_CONTEXT_t RC; @@ -88,6 +90,13 @@ int oai_nfapi_nr_crc_indication(nfapi_nr_crc_indication_t *ind) { return(0); } int oai_nfapi_nr_srs_indication(nfapi_nr_srs_indication_t *ind) { return(0); } int oai_nfapi_nr_uci_indication(nfapi_nr_uci_indication_t *ind) { return(0); } int oai_nfapi_nr_rach_indication(nfapi_nr_rach_indication_t *ind) { return(0); } +//Fixme: Uniq dirty DU instance, by global var, datamodel need better management +instance_t DUuniqInstance=0; +instance_t CUuniqInstance=0; +teid_t newGtpuCreateTunnel(instance_t instance, rnti_t rnti, int incoming_bearer_id, int outgoing_bearer_id, teid_t outgoing_teid, + transport_layer_addr_t remoteAddr, int port, gtpCallback callBack) { +return 0; +} void rrc_data_ind( @@ -99,12 +108,6 @@ rrc_data_ind( { } -int ocp_gtpv1u_create_s1u_tunnel(instance_t instance, - const gtpv1u_enb_create_tunnel_req_t *create_tunnel_req, - gtpv1u_enb_create_tunnel_resp_t *create_tunnel_resp) { - return 0; -} - int gtpv1u_create_s1u_tunnel( const instance_t instanceP, diff --git a/openair1/SIMULATION/NR_PHY/pucchsim.c b/openair1/SIMULATION/NR_PHY/pucchsim.c index 213924e5fd7425509d75ebacf387afb594ea32ef..d07469a4b79e87cc63f6c38c05ceaab3fdc953af 100644 --- a/openair1/SIMULATION/NR_PHY/pucchsim.c +++ b/openair1/SIMULATION/NR_PHY/pucchsim.c @@ -56,8 +56,7 @@ int32_t uplink_frequency_offset[MAX_NUM_CCs][4]; double cpuf; //uint8_t nfapi_mode = 0; uint16_t NB_UE_INST = 1; -uint8_t const nr_rv_round_map[4] = {0, 2, 1, 3}; -uint8_t const nr_rv_round_map_ue[4] = {0, 2, 1, 3}; +uint8_t const nr_rv_round_map[4] = {0, 2, 3, 1}; // needed for some functions PHY_VARS_NR_UE * PHY_vars_UE_g[1][1]={{NULL}}; diff --git a/openair1/SIMULATION/NR_PHY/ulschsim.c b/openair1/SIMULATION/NR_PHY/ulschsim.c index 94aea36a670ce960ffcc663080cb48473813b31d..931a63a77e3aae6d3f74a04de84c4ce03c2bb31a 100644 --- a/openair1/SIMULATION/NR_PHY/ulschsim.c +++ b/openair1/SIMULATION/NR_PHY/ulschsim.c @@ -56,8 +56,7 @@ int32_t uplink_frequency_offset[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, 1, 3}; -uint8_t const nr_rv_round_map_ue[4] = {0, 2, 1, 3}; +uint8_t const nr_rv_round_map[4] = {0, 2, 3, 1}; double cpuf; //uint8_t nfapi_mode = 0; diff --git a/openair1/SIMULATION/NR_PHY/ulsim.c b/openair1/SIMULATION/NR_PHY/ulsim.c index 69316d6b884c21dab4290b0e505dff962799f462..c71f52c41a65b148ebc8dbf49a6e8440b2b117b4 100644 --- a/openair1/SIMULATION/NR_PHY/ulsim.c +++ b/openair1/SIMULATION/NR_PHY/ulsim.c @@ -65,6 +65,7 @@ #include <executables/softmodem-common.h> #include "PHY/NR_REFSIG/ul_ref_seq_nr.h" +#include <openair3/ocp-gtpu/gtp_itf.h> //#define DEBUG_ULSIM LCHAN_DESC DCCH_LCHAN_DESC,DTCH_DL_LCHAN_DESC,DTCH_UL_LCHAN_DESC; @@ -73,6 +74,7 @@ rlc_info_t Rlc_info_um,Rlc_info_am_config; PHY_VARS_gNB *gNB; PHY_VARS_NR_UE *UE; RAN_CONTEXT_t RC; +char *uecap_file; int32_t uplink_frequency_offset[MAX_NUM_CCs][4]; uint16_t sf_ahead=4 ; @@ -85,6 +87,13 @@ THREAD_STRUCT thread_struct; nfapi_ue_release_request_body_t release_rntis; uint32_t N_RB_DL = 106; +//Fixme: Uniq dirty DU instance, by global var, datamodel need better management +instance_t DUuniqInstance=0; +instance_t CUuniqInstance=0; +teid_t newGtpuCreateTunnel(instance_t instance, rnti_t rnti, int incoming_bearer_id, int outgoing_bearer_id, teid_t outgoing_teid, + transport_layer_addr_t remoteAddr, int port, gtpCallback callBack) { +return 0; +} extern void fix_scd(NR_ServingCellConfig_t *scd);// forward declaration int8_t nr_mac_rrc_data_ind_ue(const module_id_t module_id, @@ -120,11 +129,6 @@ rrc_data_ind( { } -int ocp_gtpv1u_create_s1u_tunnel(instance_t instance, - const gtpv1u_enb_create_tunnel_req_t *create_tunnel_req, - gtpv1u_enb_create_tunnel_resp_t *create_tunnel_resp) { - return 0; -} int gtpv1u_create_s1u_tunnel( @@ -240,7 +244,6 @@ nrUE_params_t *get_nrUE_params(void) { // needed for some functions uint16_t n_rnti = 0x1234; openair0_config_t openair0_cfg[MAX_CARDS]; -//const uint8_t nr_rv_round_map[4] = {0, 2, 1, 3}; channel_desc_t *UE2gNB[NUMBER_OF_UE_MAX][NUMBER_OF_gNB_MAX]; @@ -272,7 +275,7 @@ int main(int argc, char **argv) //unsigned char frame_type = 0; NR_DL_FRAME_PARMS *frame_parms; - int loglvl = OAILOG_INFO; + int loglvl = OAILOG_WARNING; //uint64_t SSB_positions=0x01; uint16_t nb_symb_sch = 12; int start_symbol = 0; @@ -600,6 +603,7 @@ int main(int argc, char **argv) //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 <log level, 0(errors), 1(warning), 2(info) 3(debug) 4 (trace)>\n"); printf("-M Multiple SSB positions in burst\n"); printf("-N Nid_cell\n"); printf("-O oversampling factor (1,2,4,8,16)\n"); @@ -640,7 +644,7 @@ int main(int argc, char **argv) else if (N_RB_UL == 106) bandwidth = 40; else if (N_RB_UL == 32) bandwidth = 50; else { printf("Add N_RB_UL %d\n",N_RB_UL); exit(-1); } - + LOG_I( PHY,"++++++++++++++++++++++++++++++++++++++++++++++%i+++++++++++++++++++++++++++++++++++++++++",loglvl); if (openair0_cfg[0].threequarter_fs == 1) sampling_frequency*=.75; UE2gNB = new_channel_desc_scm(n_tx, n_rx, channel_model, @@ -665,13 +669,16 @@ int main(int argc, char **argv) char tp_param[] = "n"; initTpool(tp_param, gNB->threadPool, false); initNotifiedFIFO(gNB->respDecode); - gNB->resp_L1_tx = (notifiedFIFO_t*) malloc(sizeof(notifiedFIFO_t)); - initNotifiedFIFO(gNB->resp_L1_tx); - notifiedFIFO_elt_t *msgL1Tx = newNotifiedFIFO_elt(sizeof(processingData_L1tx_t),0,gNB->resp_L1_tx,NULL); + gNB->L1_tx_free = (notifiedFIFO_t*) malloc(sizeof(notifiedFIFO_t)); + gNB->L1_tx_filled = (notifiedFIFO_t*) malloc(sizeof(notifiedFIFO_t)); + gNB->L1_tx_out = (notifiedFIFO_t*) malloc(sizeof(notifiedFIFO_t)); + initNotifiedFIFO(gNB->L1_tx_free); + initNotifiedFIFO(gNB->L1_tx_filled); + initNotifiedFIFO(gNB->L1_tx_out); + notifiedFIFO_elt_t *msgL1Tx = newNotifiedFIFO_elt(sizeof(processingData_L1tx_t),0,gNB->L1_tx_free,NULL); processingData_L1tx_t *msgDataTx = (processingData_L1tx_t *)NotifiedFifoData(msgL1Tx); msgDataTx->slot = -1; - gNB->phy_proc_tx_0 = &msgDataTx->phy_proc_tx; - pushNotifiedFIFO(gNB->resp_L1_tx,msgL1Tx); // to unblock the process in the beginning + gNB->phy_proc_tx[0] = &msgDataTx->phy_proc_tx; //gNB_config = &gNB->gNB_config; //memset((void *)&gNB->UL_INFO,0,sizeof(gNB->UL_INFO)); @@ -707,13 +714,13 @@ int main(int argc, char **argv) NR_CellGroupConfig_t *secondaryCellGroup=calloc(1,sizeof(*secondaryCellGroup)); prepare_scc(rrc.carrier.servingcellconfigcommon); uint64_t ssb_bitmap; - fill_scc(rrc.carrier.servingcellconfigcommon,&ssb_bitmap,N_RB_DL,N_RB_DL,mu,mu); + fill_scc_sim(rrc.carrier.servingcellconfigcommon,&ssb_bitmap,N_RB_DL,N_RB_DL,mu,mu); fix_scc(scc,ssb_bitmap); prepare_scd(scd); - fill_default_secondaryCellGroup(scc, scd, secondaryCellGroup, 0, 1, n_tx, 0, 0, 0); + fill_default_secondaryCellGroup(scc, scd, secondaryCellGroup, 0, 1, n_tx, 0, 0, 0, 0, 0); // xer_fprint(stdout, &asn_DEF_NR_CellGroupConfig, (const void*)secondaryCellGroup); @@ -732,17 +739,13 @@ int main(int argc, char **argv) nfapi_nr_config_request_scf_t *cfg = &gNB->gNB_config; cfg->carrier_config.num_tx_ant.value = n_tx; cfg->carrier_config.num_rx_ant.value = n_rx; - nr_phy_config_request_sim(gNB,N_RB_DL,N_RB_DL,mu,0,0x01); +// nr_phy_config_request_sim(gNB,N_RB_DL,N_RB_DL,mu,0,0x01); phy_init_nr_gNB(gNB,0,1); N_RB_DL = gNB->frame_parms.N_RB_DL; NR_BWP_Uplink_t *ubwp=secondaryCellGroup->spCellConfig->spCellConfigDedicated->uplinkConfig->uplinkBWP_ToAddModList->list.array[0]; - //crcTableInit(); - - //nr_phy_config_request_sim(gNB, N_RB_DL, N_RB_UL, mu, Nid_cell, SSB_positions); - //configure UE UE = malloc(sizeof(PHY_VARS_NR_UE)); @@ -1117,6 +1120,7 @@ int main(int argc, char **argv) } // prepare ULSCH/PUSCH reception + pushNotifiedFIFO(gNB->L1_tx_free,msgL1Tx); // to unblock the process in the beginning nr_schedule_response(Sched_INFO); // --------- setting parameters for UE -------- @@ -1282,8 +1286,10 @@ int main(int argc, char **argv) if (n_trials == 1 && round==0) { #ifdef __AVX2__ + __attribute__((unused)) int off = ((nb_rb&1) == 1)? 4:0; #else + __attribute__((unused)) int off = 0; #endif diff --git a/openair1/SIMULATION/NR_UE_PHY/unit_tests/src/srs_test.c b/openair1/SIMULATION/NR_UE_PHY/unit_tests/src/srs_test.c index aedb5729a353a02c3040b235020f5522a5e94cf0..34ea68bc61f1ddb6d353a02a665254dbc5d7f292 100644 --- a/openair1/SIMULATION/NR_UE_PHY/unit_tests/src/srs_test.c +++ b/openair1/SIMULATION/NR_UE_PHY/unit_tests/src/srs_test.c @@ -229,7 +229,7 @@ int test_srs_periodicity(PHY_VARS_NR_UE *ue, UE_nr_rxtx_proc_t *proc) for (int slot_tx = 0; slot_tx < frame_parms->slots_per_frame; slot_tx++) { proc->frame_tx = frame_tx; proc->nr_slot_tx = slot_tx; - if (ue_srs_procedure_nr( ue, proc, 0) == 0) { + if (ue_srs_procedures_nr( ue, proc, 0) == 0) { printf("test_srs_periodicity srs at frame %d slot %d \n", frame_tx, slot_tx); } } diff --git a/openair1/SIMULATION/TOOLS/taus.c b/openair1/SIMULATION/TOOLS/taus.c index cdd4aebec3dff23605946f97d1fb45e3e9ba81f1..a9d2750c06374d80d4b0575176c7bd65e56feccf 100644 --- a/openair1/SIMULATION/TOOLS/taus.c +++ b/openair1/SIMULATION/TOOLS/taus.c @@ -21,10 +21,12 @@ #include <time.h> #include <stdlib.h> +#include <fcntl.h> +#include <unistd.h> //#include "SIMULATION/TOOLS/sim.h" -unsigned int s0, s1, s2, b; +static unsigned int s0, s1, s2; //---------------------------------------------- // @@ -34,7 +36,7 @@ unsigned int s0, s1, s2, b; unsigned int taus(void) { - b = (((s0 << 13) ^ s0) >> 19); + unsigned int b = (((s0 << 13) ^ s0) >> 19); s0 = (((s0 & 0xFFFFFFFE) << 12)^ b); b = (((s1 << 2) ^ s1) >> 25); s1 = (((s1 & 0xFFFFFFF8) << 4)^ b); @@ -50,9 +52,20 @@ void set_taus_seed(unsigned int seed_init) unsigned long result = 0; if (seed_init == 0) { - s0 = (unsigned int)time(NULL); - s1 = (unsigned int)time(NULL); - s2 = (unsigned int)time(NULL); + unsigned int data[3]; + int fd = open("/dev/urandom", O_RDONLY); + if (fd == -1) + { + abort(); + } + if (read(fd, data, sizeof(data)) != sizeof(data)) + { + abort(); + } + close(fd); + s0 = data[0]; + s1 = data[1]; + s2 = data[2]; } else { /* Use reentrant version of rand48 to ensure that no conflicts with other generators occur */ srand48_r((long int)seed_init, &buffer); diff --git a/openair2/COMMON/as_message.h b/openair2/COMMON/as_message.h index 829c3c9e33a203aeac0d21f24a612224f874697a..b0ca06daec6aef6b197804d383941f9576dccbee 100644 --- a/openair2/COMMON/as_message.h +++ b/openair2/COMMON/as_message.h @@ -219,6 +219,10 @@ typedef struct kenb_refresh_req_s { Byte_t kenb[32]; } kenb_refresh_req_t; +typedef struct nsa_oai_tun_nsa_s { + uint8_t buffer[500]; +} nas_oai_tun_nsa_t; + /* * NAS->AS - Cell Information request * NAS request AS to search for a suitable cell belonging to the selected diff --git a/openair2/COMMON/f1ap_messages_def.h b/openair2/COMMON/f1ap_messages_def.h index 6b1c6d94954582f0347caa77711702ea3e0b4eba..0e857f3a83cb5cb6fd9843728359e6748117ee6c 100644 --- a/openair2/COMMON/f1ap_messages_def.h +++ b/openair2/COMMON/f1ap_messages_def.h @@ -44,7 +44,8 @@ MESSAGE_DEF(F1AP_UE_CONTEXT_RELEASE_CMD, MESSAGE_PRIORITY_MED, f1ap_ue_context_r /* RRC -> F1AP messages */ MESSAGE_DEF(F1AP_DL_RRC_MESSAGE , MESSAGE_PRIORITY_MED, f1ap_dl_rrc_message_t , f1ap_dl_rrc_message ) //MESSAGE_DEF(F1AP_INITIAL_CONTEXT_SETUP_REQ , MESSAGE_PRIORITY_MED, f1ap_initial_context_setup_req_t , f1ap_initial_context_setup_req ) -MESSAGE_DEF(F1AP_UE_CONTEXT_SETUP_REQ, MESSAGE_PRIORITY_MED, f1ap_ue_context_setup_req_t, f1ap_ue_context_setup_req) +MESSAGE_DEF(F1AP_UE_CONTEXT_SETUP_REQ, MESSAGE_PRIORITY_MED, f1ap_ue_context_setup_t, f1ap_ue_context_setup_req) +MESSAGE_DEF(F1AP_UE_CONTEXT_SETUP_RESP, MESSAGE_PRIORITY_MED, f1ap_ue_context_setup_t, f1ap_ue_context_setup_resp) diff --git a/openair2/COMMON/f1ap_messages_types.h b/openair2/COMMON/f1ap_messages_types.h index c2fb4a9cf7b7e4f1d1adc3c8047e81e033933651..cb1a8c9577704b29d6da8ab86401c0d500e80e2b 100644 --- a/openair2/COMMON/f1ap_messages_types.h +++ b/openair2/COMMON/f1ap_messages_types.h @@ -39,6 +39,7 @@ #define F1AP_INITIAL_UL_RRC_MESSAGE(mSGpTR) (mSGpTR)->ittiMsg.f1ap_initial_ul_rrc_message #define F1AP_UL_RRC_MESSAGE(mSGpTR) (mSGpTR)->ittiMsg.f1ap_ul_rrc_message #define F1AP_UE_CONTEXT_SETUP_REQ(mSGpTR) (mSGpTR)->ittiMsg.f1ap_ue_context_setup_req +#define F1AP_UE_CONTEXT_SETUP_RESP(mSGpTR) (mSGpTR)->ittiMsg.f1ap_ue_context_setup_resp #define F1AP_UE_CONTEXT_RELEASE_RESP(mSGpTR) (mSGpTR)->ittiMsg.f1ap_ue_context_release_resp #define F1AP_UE_CONTEXT_MODIFICATION_RESP(mSGpTR) (mSGpTR)->ittiMsg.f1ap_ue_context_modification_resp #define F1AP_UE_CONTEXT_MODIFICATION_FAIL(mSGpTR) (mSGpTR)->ittiMsg.f1ap_ue_context_modification_fail @@ -71,6 +72,29 @@ typedef struct f1ap_cu_setup_req_s { // } f1ap_cu_setup_req_t; +typedef struct cellIDs_s { + + // Served Cell Information + /* Tracking area code */ + uint32_t tac; + + /* Mobile Country Codes + * Mobile Network Codes + */ + uint16_t mcc; + uint16_t mnc; + uint8_t mnc_digit_length; + + // NR Global Cell Id + uint64_t nr_cellid; + // NR Physical Cell Ids + uint16_t nr_pci; + // Number of slide support items (max 16, could be increased to as much as 1024) + uint16_t num_ssi; + uint8_t sst; + uint8_t sd; +} cellIDs_t; + typedef struct f1ap_setup_req_s { // Midhaul networking parameters @@ -84,6 +108,8 @@ typedef struct f1ap_setup_req_s { /* The eNB IP address to bind */ f1ap_net_ip_address_t CU_f1_ip_address; f1ap_net_ip_address_t DU_f1_ip_address; + uint16_t CUport; + uint16_t DUport; /* Number of SCTP streams used for a mme association */ uint16_t sctp_in_streams; @@ -100,31 +126,12 @@ typedef struct f1ap_setup_req_s { /// number of DU cells available uint16_t num_cells_available; //0< num_cells_available <= 512; - - // Served Cell Information - /* Tracking area code */ - uint32_t tac[F1AP_MAX_NB_CELLS]; - - /* Mobile Country Codes - * Mobile Network Codes - */ - uint16_t mcc[F1AP_MAX_NB_CELLS];//[6]; - uint16_t mnc[F1AP_MAX_NB_CELLS];//[6]; - uint8_t mnc_digit_length[F1AP_MAX_NB_CELLS];//[6]; - - // NR Global Cell Id - uint64_t nr_cellid[F1AP_MAX_NB_CELLS]; - // NR Physical Cell Ids - uint16_t nr_pci[F1AP_MAX_NB_CELLS]; - // Number of slide support items (max 16, could be increased to as much as 1024) - uint16_t num_ssi[F1AP_MAX_NB_CELLS];//[6]; - uint8_t sst[F1AP_MAX_NB_CELLS];//[16][6]; - uint8_t sd[F1AP_MAX_NB_CELLS];//[16][6]; + cellIDs_t cell[F1AP_MAX_NB_CELLS]; // fdd_flag = 1 means FDD, 0 means TDD int fdd_flag; union { - struct { + struct fdd_s { uint32_t ul_nr_arfcn; uint8_t ul_scs; uint8_t ul_nrb; @@ -148,7 +155,7 @@ typedef struct f1ap_setup_req_s { uint8_t dl_num_sul_frequency_bands; uint16_t dl_nr_sul_band[32]; } fdd; - struct { + struct tdd_s { uint32_t nr_arfcn; uint8_t scs; @@ -195,6 +202,7 @@ typedef struct served_cells_to_activate_s { /// SI message containers (up to 21 messages per cell) uint8_t *SI_container[21]; int SI_container_length[21]; + int SI_type[21]; } served_cells_to_activate_t; typedef struct f1ap_setup_resp_s { @@ -299,7 +307,7 @@ typedef struct f1ap_initial_ul_rrc_message_s { uint16_t crnti; uint8_t *rrc_container; int rrc_container_length; - int8_t *du2cu_rrc_container; + char du2cu_rrc_container[200]; int du2cu_rrc_container_length; } f1ap_initial_ul_rrc_message_t; @@ -312,19 +320,32 @@ typedef struct f1ap_ul_rrc_message_s { typedef struct f1ap_up_tnl_s { in_addr_t tl_address; // currently only IPv4 supported - uint32_t gtp_teid; + teid_t teid; + uint16_t port; } f1ap_up_tnl_t; typedef struct f1ap_drb_to_be_setup_s { - uint8_t drb_id; + long drb_id; f1ap_up_tnl_t up_ul_tnl[2]; uint8_t up_ul_tnl_length; + f1ap_up_tnl_t up_dl_tnl[2]; + uint8_t up_dl_tnl_length; rlc_mode_t rlc_mode; } f1ap_drb_to_be_setup_t; -typedef struct f1ap_ue_context_setup_req_s { +typedef struct f1ap_srb_to_be_setup_s { + long srb_id; + rlc_mode_t rlc_mode; + uint8_t lcid; +} f1ap_srb_to_be_setup_t; + +typedef struct f1ap_rb_failed_to_be_setup_s { + long rb_id; +} f1ap_rb_failed_to_be_setup_t; + +typedef struct f1ap_ue_context_setup_s { uint32_t gNB_CU_ue_id; // BK: need to replace by use from rnti - uint32_t *gNB_DU_ue_id; + uint32_t gNB_DU_ue_id; uint16_t rnti; // SpCell Info uint16_t mcc; @@ -336,13 +357,37 @@ typedef struct f1ap_ue_context_setup_req_s { uint32_t servCellId; uint8_t *cu_to_du_rrc_information; uint8_t cu_to_du_rrc_information_length; + uint8_t *du_to_cu_rrc_information; + uint8_t du_to_cu_rrc_information_length; f1ap_drb_to_be_setup_t *drbs_to_be_setup; // BK: need to replace by s1ap_initial_context_setup_req uint8_t drbs_to_be_setup_length; // BK: need to replace by s1ap_initial_context_setup_req + uint8_t drbs_failed_to_be_setup_length; + f1ap_rb_failed_to_be_setup_t *drbs_failed_to_be_setup; + f1ap_srb_to_be_setup_t *srbs_to_be_setup; + uint8_t srbs_to_be_setup_length; + uint8_t srbs_failed_to_be_setup_length; + f1ap_rb_failed_to_be_setup_t *srbs_failed_to_be_setup; s1ap_initial_context_setup_req_t *s1ap_initial_context_setup_req; // coniatner for the rrc_eNB_generate_SecurityModeCommand message uint8_t *rrc_container; int rrc_container_length; -} f1ap_ue_context_setup_req_t; +} f1ap_ue_context_setup_t; + +typedef struct f1ap_ue_context_setup_resp_s { + uint32_t gNB_CU_ue_id; // BK: need to replace by use from rnti + uint32_t gNB_DU_ue_id; + uint16_t rnti; + uint8_t du_to_cu_rrc_information[1024 /*Arbitrarily big enough*/]; + uint32_t du_to_cu_rrc_information_length; + f1ap_drb_to_be_setup_t *drbs_setup; // BK: need to replace by s1ap_initial_context_setup_req + uint8_t drbs_setup_length; // BK: need to replace by s1ap_initial_context_setup_req + f1ap_srb_to_be_setup_t *srbs_setup; + uint8_t srbs_setup_length; + uint8_t srbs_failed_to_be_setup_length; + f1ap_rb_failed_to_be_setup_t *srbs_failed_to_be_setup; + uint8_t drbs_failed_to_be_setup_length; + f1ap_rb_failed_to_be_setup_t *drbs_failed_to_be_setup; +} f1ap_ue_context_setup_resp_t; typedef enum F1ap_Cause_e { F1AP_CAUSE_NOTHING, /* No components present */ diff --git a/openair2/COMMON/gtpv1_u_messages_def.h b/openair2/COMMON/gtpv1_u_messages_def.h index e5ce496701ad552f1431e6c3d5df622f934f1499..2835d07e4ae9c523c17411e1842fe5792473fa3b 100644 --- a/openair2/COMMON/gtpv1_u_messages_def.h +++ b/openair2/COMMON/gtpv1_u_messages_def.h @@ -29,9 +29,8 @@ MESSAGE_DEF(GTPV1U_ENB_DATA_FORWARDING_REQ, MESSAGE_PRIORITY_MED, gtpv1u_enb_dat MESSAGE_DEF(GTPV1U_ENB_DATA_FORWARDING_IND, MESSAGE_PRIORITY_MED, gtpv1u_enb_data_forwarding_ind_t,Gtpv1uDataForwardingInd) MESSAGE_DEF(GTPV1U_ENB_END_MARKER_REQ, MESSAGE_PRIORITY_MED, gtpv1u_enb_end_marker_req_t, Gtpv1uEndMarkerReq) MESSAGE_DEF(GTPV1U_ENB_END_MARKER_IND, MESSAGE_PRIORITY_MED, gtpv1u_enb_end_marker_ind_t, Gtpv1uEndMarkerInd) -MESSAGE_DEF(GTPV1U_ENB_S1_REQ, MESSAGE_PRIORITY_MED, Gtpv1uS1Req, gtpv1uS1Req) +MESSAGE_DEF(GTPV1U_REQ, MESSAGE_PRIORITY_MED, Gtpv1uReq, gtpv1uReq) MESSAGE_DEF(GTPV1U_GNB_DELETE_TUNNEL_REQ, MESSAGE_PRIORITY_MED, gtpv1u_gnb_delete_tunnel_req_t, NRGtpv1uDeleteTunnelReq) MESSAGE_DEF(GTPV1U_GNB_DELETE_TUNNEL_RESP, MESSAGE_PRIORITY_MED, gtpv1u_gnb_delete_tunnel_resp_t, NRGtpv1uDeleteTunnelResp) -MESSAGE_DEF(GTPV1U_GNB_NG_REQ, MESSAGE_PRIORITY_MED, Gtpv1uNGReq, gtpv1uNGReq) MESSAGE_DEF(GTPV1U_GNB_TUNNEL_DATA_REQ, MESSAGE_PRIORITY_MED, gtpv1u_gnb_tunnel_data_req_t, NRGtpv1uTunnelDataReq) diff --git a/openair2/COMMON/gtpv1_u_messages_types.h b/openair2/COMMON/gtpv1_u_messages_types.h index 3c820765103c917cdaaf7a54e3f36e4fd38b1061..2dd476ab686c06a950294334c6e5bf90150154ed 100644 --- a/openair2/COMMON/gtpv1_u_messages_types.h +++ b/openair2/COMMON/gtpv1_u_messages_types.h @@ -39,11 +39,10 @@ #define GTPV1U_ENB_END_MARKER_REQ(mSGpTR) (mSGpTR)->ittiMsg.Gtpv1uEndMarkerReq #define GTPV1U_ENB_END_MARKER_IND(mSGpTR) (mSGpTR)->ittiMsg.Gtpv1uEndMarkerInd -#define GTPV1U_ENB_S1_REQ(mSGpTR) (mSGpTR)->ittiMsg.gtpv1uS1Req +#define GTPV1U_REQ(mSGpTR) (mSGpTR)->ittiMsg.gtpv1uReq #define GTPV1U_GNB_DELETE_TUNNEL_REQ(mSGpTR) (mSGpTR)->ittiMsg.NRGtpv1uDeleteTunnelReq #define GTPV1U_GNB_DELETE_TUNNEL_RESP(mSGpTR) (mSGpTR)->ittiMsg.NRGtpv1uDeleteTunnelResp -#define GTPV1U_GNB_NG_REQ(mSGpTR) (mSGpTR)->ittiMsg.gtpv1uNGReq #define GTPV1U_GNB_TUNNEL_DATA_REQ(mSGpTR) (mSGpTR)->ittiMsg.NRGtpv1uTunnelDataReq #define GTPV1U_ALL_TUNNELS_TEID (teid_t)0xFFFFFFFF @@ -174,25 +173,23 @@ typedef struct gtpv1u_enb_end_marker_ind_s { } gtpv1u_enb_end_marker_ind_t; typedef struct { - in_addr_t enb_ip_address_for_S1u_S12_S4_up; - tcp_udp_port_t enb_port_for_S1u_S12_S4_up; - char addrStr[256]; - char portStr[256]; -} Gtpv1uS1Req; + in_addr_t localAddr; + tcp_udp_port_t localPort; + char localAddrStr[256]; + char localPortStr[256]; +} Gtpv1uReq; + -typedef struct { - in_addr_t gnb_ip_address_for_NGu_up; - tcp_udp_port_t gnb_port_for_NGu_up; - char addrStr[256]; - char portStr[256]; -} Gtpv1uNGReq; typedef struct gtpv1u_gnb_create_tunnel_req_s { rnti_t rnti; int num_tunnels; - teid_t upf_NGu_teid[NR_GTPV1U_MAX_BEARERS_PER_UE]; ///< Tunnel Endpoint Identifier + //teid_t upf_NGu_teid[NR_GTPV1U_MAX_BEARERS_PER_UE]; ///< Tunnel Endpoint Identifier + teid_t outgoing_teid[NR_GTPV1U_MAX_BEARERS_PER_UE]; pdusessionid_t pdusession_id[NR_GTPV1U_MAX_BEARERS_PER_UE]; ebi_t incoming_rb_id[NR_GTPV1U_MAX_BEARERS_PER_UE]; - transport_layer_addr_t upf_addr[NR_GTPV1U_MAX_BEARERS_PER_UE]; + //ebi_t outgoing_rb_id[NR_GTPV1U_MAX_BEARERS_PER_UE]; + //transport_layer_addr_t upf_addr[NR_GTPV1U_MAX_BEARERS_PER_UE]; + transport_layer_addr_t dst_addr[NR_GTPV1U_MAX_BEARERS_PER_UE]; } gtpv1u_gnb_create_tunnel_req_t; typedef struct gtpv1u_gnb_create_tunnel_resp_s { diff --git a/openair2/COMMON/mac_messages_types.h b/openair2/COMMON/mac_messages_types.h index a9336a58a999817c90f7bbe571134d9d29f57e54..cad7b9f172b645d0e182f78fc8899fcae3ca6c10 100644 --- a/openair2/COMMON/mac_messages_types.h +++ b/openair2/COMMON/mac_messages_types.h @@ -147,6 +147,7 @@ typedef struct NRRrcMacCcchDataInd_s { OCTET_STRING_t *du_to_cu_rrc_container; uint8_t gnb_index; int CC_id; + uint64_t nr_cellid; } NRRrcMacCcchDataInd; typedef struct RrcMacMcchDataReq_s { diff --git a/openair2/COMMON/openair_defs.h b/openair2/COMMON/openair_defs.h index 4d8d50606c814a6e6ccc77ebbfbba93686c19042..cdda6a7e87fe98509e777ac767fff2b111897d88 100644 --- a/openair2/COMMON/openair_defs.h +++ b/openair2/COMMON/openair_defs.h @@ -24,26 +24,6 @@ #include <stdio.h> #include <stdlib.h> -#if !defined (msg) -# define msg(aRGS...) LOG_D(PHY, ##aRGS) -#endif -#ifndef malloc16 -# ifdef __AVX2__ -# define malloc16(x) memalign(32,x) -# else -# define malloc16(x) memalign(16,x) -# endif -#endif -#define free16(y,x) free(y) -#define bigmalloc malloc -#define bigmalloc16 malloc16 -#define openair_free(y,x) free((y)) -#define PAGE_SIZE 4096 - -#define PAGE_MASK 0xfffff000 -#define virt_to_phys(x) (x) - -#define cmax(a,b) ((a>b) ? (a) : (b)) -#define cmin(a,b) ((a<b) ? (a) : (b)) +#include <common/utils/utils.h> #endif // /*__openair_DEFS_H__ */ diff --git a/openair2/COMMON/pdcp_messages_def.h b/openair2/COMMON/pdcp_messages_def.h index 59d47eb81b992c660c4d9b47a3e19724edf01189..5392c9e04dfe9e069f473b23f898deb136479924 100644 --- a/openair2/COMMON/pdcp_messages_def.h +++ b/openair2/COMMON/pdcp_messages_def.h @@ -31,6 +31,8 @@ MESSAGE_DEF(RRC_DCCH_DATA_REQ, MESSAGE_PRIORITY_MED_PLUS, RrcDcchDataReq, rrc_dcch_data_req) MESSAGE_DEF(RRC_DCCH_DATA_IND, MESSAGE_PRIORITY_MED_PLUS, RrcDcchDataInd, rrc_dcch_data_ind) MESSAGE_DEF(RRC_PCCH_DATA_REQ, MESSAGE_PRIORITY_MED_PLUS, RrcPcchDataReq, rrc_pcch_data_req) +MESSAGE_DEF(RRC_NRUE_CAP_INFO_IND, MESSAGE_PRIORITY_MED_PLUS, RrcDcchDataInd, rrc_nrue_cap_info_ind) +MESSAGE_DEF(RRC_DCCH_DATA_COPY_IND, MESSAGE_PRIORITY_MED_PLUS, RrcDcchDataInd, rrc_dcch_data_copy_ind) // gNB MESSAGE_DEF(NR_RRC_DCCH_DATA_REQ, MESSAGE_PRIORITY_MED_PLUS, NRRrcDcchDataReq, nr_rrc_dcch_data_req) diff --git a/openair2/COMMON/pdcp_messages_types.h b/openair2/COMMON/pdcp_messages_types.h index 0390fd80f440dc8af4c02971991085d2ec89799a..d7c84a24a14a6c8cd0284e47b319df6c9ddb40ff 100644 --- a/openair2/COMMON/pdcp_messages_types.h +++ b/openair2/COMMON/pdcp_messages_types.h @@ -34,6 +34,8 @@ #define RRC_DCCH_DATA_REQ(mSGpTR) (mSGpTR)->ittiMsg.rrc_dcch_data_req #define RRC_DCCH_DATA_IND(mSGpTR) (mSGpTR)->ittiMsg.rrc_dcch_data_ind #define RRC_PCCH_DATA_REQ(mSGpTR) (mSGpTR)->ittiMsg.rrc_pcch_data_req +#define RRC_NRUE_CAP_INFO_IND(mSGpTR) (mSGpTR)->ittiMsg.rrc_nrue_cap_info_ind +#define RRC_DCCH_DATA_COPY_IND(mSGpTR) (mSGpTR)->ittiMsg.rrc_dcch_data_copy_ind // gNB #define NR_RRC_DCCH_DATA_REQ(mSGpTR) (mSGpTR)->ittiMsg.nr_rrc_dcch_data_req @@ -65,6 +67,13 @@ typedef struct RrcDcchDataInd_s { uint8_t eNB_index; // LG: needed in UE } RrcDcchDataInd; +typedef struct RrcDcchDataCopyInd_s { + uint8_t dcch_index; + uint32_t sdu_size; + uint8_t *sdu_p; + uint8_t eNB_index; +} RrcDcchDataCopyInd; + typedef struct NRRrcDcchDataReq_s { uint32_t frame; uint8_t gnb_flag; diff --git a/openair2/COMMON/platform_constants.h b/openair2/COMMON/platform_constants.h index 355f56f9c9356bfa13acebd645ae6191f7f62dbb..d40965052899ee87e6c1fe15e40764372f25f555 100644 --- a/openair2/COMMON/platform_constants.h +++ b/openair2/COMMON/platform_constants.h @@ -75,9 +75,9 @@ #define MAX_eNB 2 #define MAX_gNB 2 #else - #define MAX_MOBILES_PER_ENB 4 - #define MAX_MOBILES_PER_ENB_NB_IoT 4 - #define MAX_MOBILES_PER_GNB 4//16 + #define MAX_MOBILES_PER_ENB 40 + #define MAX_MOBILES_PER_ENB_NB_IoT 40 + #define MAX_MOBILES_PER_GNB 16 #define MAX_eNB 2 #define MAX_gNB 2 #endif diff --git a/openair2/COMMON/platform_types.h b/openair2/COMMON/platform_types.h index 23b33dd8b13ab1f8249942f2e304c5e800d72dd4..c24291de645460de2e063368cfb0566c82e54273 100644 --- a/openair2/COMMON/platform_types.h +++ b/openair2/COMMON/platform_types.h @@ -212,6 +212,14 @@ typedef enum config_action_e { CONFIG_ACTION_MBMS_MODIFY = 11 } config_action_t; +/* Maximum size of any message we might send or receive (e.g., via a socket) */ +#define MAX_MESSAGE_SIZE 8192 + +typedef struct nsa_msg_t { + uint8_t msg_type; + uint8_t msg_buffer[MAX_MESSAGE_SIZE]; +} nsa_msg_t; + //----------------------------------------------------------------------------- // GTPV1U TYPES //----------------------------------------------------------------------------- @@ -233,7 +241,6 @@ typedef struct protocol_ctxt_s { frame_t frame; /*!< \brief LTE frame number.*/ sub_frame_t subframe; /*!< \brief LTE sub frame number.*/ eNB_index_t eNB_index; /*!< \brief valid for UE indicating the index of connected eNB(s) */ - boolean_t configured; /*!< \brief flag indicating whether the instance is configured or not */ boolean_t brOption; } protocol_ctxt_t; // warning time hardcoded diff --git a/openair2/COMMON/rrc_messages_def.h b/openair2/COMMON/rrc_messages_def.h index cde2497880849bccbbbafb3c5e787a946eddde17..35caf3c34274b8603fb4e9fccce25c8b924b88e7 100644 --- a/openair2/COMMON/rrc_messages_def.h +++ b/openair2/COMMON/rrc_messages_def.h @@ -65,6 +65,8 @@ MESSAGE_DEF(NAS_UPLINK_DATA_REQ, MESSAGE_PRIORITY_MED, NasUlDataReq MESSAGE_DEF(NAS_RAB_ESTABLI_RSP, MESSAGE_PRIORITY_MED, NasRabEstRsp, nas_rab_est_rsp) +MESSAGE_DEF(NAS_OAI_TUN_NSA, MESSAGE_PRIORITY_MED, NasOaiTunNsa, nas_oai_tun_nsa) + // UE: RRC -> NAS messages MESSAGE_DEF(NAS_CELL_SELECTION_CNF, MESSAGE_PRIORITY_MED, NasCellSelectionCnf, nas_cell_selection_cnf) MESSAGE_DEF(NAS_CELL_SELECTION_IND, MESSAGE_PRIORITY_MED, NasCellSelectionInd, nas_cell_selection_ind) @@ -79,3 +81,5 @@ MESSAGE_DEF(RRC_SUBFRAME_PROCESS, MESSAGE_PRIORITY_MED, RrcSubframeP // eNB: RLC -> RRC messages MESSAGE_DEF(RLC_SDU_INDICATION, MESSAGE_PRIORITY_MED, RlcSduIndication, rlc_sdu_indication) + +MESSAGE_DEF(NR_DU_RRC_DL_INDICATION, MESSAGE_PRIORITY_MED, NRDuDlReq_t, nr_du_dl_req) diff --git a/openair2/COMMON/rrc_messages_types.h b/openair2/COMMON/rrc_messages_types.h index f61648d8b400ba9232a1972e2eced2f3fa8f12c5..769bc7d01d3bffd3569651dc1cb34d0bda946b8d 100644 --- a/openair2/COMMON/rrc_messages_types.h +++ b/openair2/COMMON/rrc_messages_types.h @@ -89,6 +89,9 @@ #define RRC_SUBFRAME_PROCESS(mSGpTR) (mSGpTR)->ittiMsg.rrc_subframe_process #define RLC_SDU_INDICATION(mSGpTR) (mSGpTR)->ittiMsg.rlc_sdu_indication +#define NRDuDlReq(mSGpTR) (mSGpTR)->ittiMsg.nr_du_dl_req + +#define NAS_OAI_TUN_NSA(mSGpTR) (mSGpTR)->ittiMsg.nas_oai_tun_nsa //-------------------------------------------------------------------------------------------// typedef struct RrcStateInd_s { @@ -412,12 +415,18 @@ typedef struct NRRrcConfigurationReq_s { int sib1_tda; int pdsch_AntennaPorts; int pusch_AntennaPorts; - int minRXTXTIMEpdsch; + int minRXTXTIME; int do_CSIRS; + int do_SRS; int pusch_TargetSNRx10; int pucch_TargetSNRx10; } gNB_RrcConfigurationReq; +typedef struct NRDuDlReq_s { + rnti_t rnti; + mem_block_t * buf; + uint64_t srb_id; +} NRDuDlReq_t; // UE: NAS -> RRC messages typedef kenb_refresh_req_t NasKenbRefreshReq; @@ -427,6 +436,8 @@ typedef ul_info_transfer_req_t NasUlDataReq; typedef rab_establish_rsp_t NasRabEstRsp; +typedef nas_oai_tun_nsa_t NasOaiTunNsa; + // UE: RRC -> NAS messages typedef cell_info_cnf_t NasCellSelectionCnf; typedef cell_info_ind_t NasCellSelectionInd; diff --git a/openair2/ENB_APP/enb_config.c b/openair2/ENB_APP/enb_config.c index 4751596931cbbb78d7acdb7162cdb37d8b15f5a8..a08bcf4baf96e922a754a319362693329217ec03 100644 --- a/openair2/ENB_APP/enb_config.c +++ b/openair2/ENB_APP/enb_config.c @@ -1925,6 +1925,7 @@ int RCconfig_DU_F1(MessageDef *msg_p, uint32_t i) { AssertFatal(ENBParamList.paramarray[i][ENB_ENB_ID_IDX].uptr != NULL, "eNB id %u is not defined in configuration file\n",i); F1AP_SETUP_REQ (msg_p).num_cells_available = 0; + F1AP_SETUP_REQ (msg_p).cell_type = CELL_MACRO_ENB; for (k=0; k <num_enbs ; k++) { if (strcmp(ENBSParams[ENB_ACTIVE_ENBS_IDX].strlistptr[k], *(ENBParamList.paramarray[i][ENB_ENB_NAME_IDX].strptr) )== 0) { @@ -1945,20 +1946,20 @@ int RCconfig_DU_F1(MessageDef *msg_p, uint32_t i) { LOG_I(ENB_APP,"F1AP: gNB_DU_id[%d] %ld\n",k,F1AP_SETUP_REQ (msg_p).gNB_DU_id); F1AP_SETUP_REQ (msg_p).gNB_DU_name = strdup(*(ENBParamList.paramarray[0][ENB_ENB_NAME_IDX].strptr)); LOG_I(ENB_APP,"F1AP: gNB_DU_name[%d] %s\n",k,F1AP_SETUP_REQ (msg_p).gNB_DU_name); - F1AP_SETUP_REQ (msg_p).tac[k] = *ENBParamList.paramarray[i][ENB_TRACKING_AREA_CODE_IDX].uptr; - LOG_I(ENB_APP,"F1AP: tac[%d] %d\n",k,F1AP_SETUP_REQ (msg_p).tac[k]); - F1AP_SETUP_REQ (msg_p).mcc[k] = *PLMNParamList.paramarray[0][ENB_MOBILE_COUNTRY_CODE_IDX].uptr; - LOG_I(ENB_APP,"F1AP: mcc[%d] %d\n",k,F1AP_SETUP_REQ (msg_p).mcc[k]); - F1AP_SETUP_REQ (msg_p).mnc[k] = *PLMNParamList.paramarray[0][ENB_MOBILE_NETWORK_CODE_IDX].uptr; - LOG_I(ENB_APP,"F1AP: mnc[%d] %d\n",k,F1AP_SETUP_REQ (msg_p).mnc[k]); - F1AP_SETUP_REQ (msg_p).mnc_digit_length[k] = *PLMNParamList.paramarray[0][ENB_MNC_DIGIT_LENGTH].u8ptr; - LOG_I(ENB_APP,"F1AP: mnc_digit_length[%d] %d\n",k,F1AP_SETUP_REQ (msg_p).mnc_digit_length[k]); - AssertFatal((F1AP_SETUP_REQ (msg_p).mnc_digit_length[k] == 2) || - (F1AP_SETUP_REQ (msg_p).mnc_digit_length[k] == 3), + F1AP_SETUP_REQ (msg_p).cell[k].tac = *ENBParamList.paramarray[i][ENB_TRACKING_AREA_CODE_IDX].uptr; + LOG_I(ENB_APP,"F1AP: tac[%d] %d\n",k,F1AP_SETUP_REQ (msg_p).cell[k].tac); + F1AP_SETUP_REQ (msg_p).cell[k].mcc = *PLMNParamList.paramarray[0][ENB_MOBILE_COUNTRY_CODE_IDX].uptr; + LOG_I(ENB_APP,"F1AP: mcc[%d] %d\n",k,F1AP_SETUP_REQ (msg_p).cell[k].mcc); + F1AP_SETUP_REQ (msg_p).cell[k].mnc = *PLMNParamList.paramarray[0][ENB_MOBILE_NETWORK_CODE_IDX].uptr; + LOG_I(ENB_APP,"F1AP: mnc[%d] %d\n",k,F1AP_SETUP_REQ (msg_p).cell[k].mnc); + F1AP_SETUP_REQ (msg_p).cell[k].mnc_digit_length = *PLMNParamList.paramarray[0][ENB_MNC_DIGIT_LENGTH].u8ptr; + LOG_I(ENB_APP,"F1AP: mnc_digit_length[%d] %d\n",k,F1AP_SETUP_REQ (msg_p).cell[k].mnc_digit_length); + AssertFatal((F1AP_SETUP_REQ (msg_p).cell[k].mnc_digit_length == 2) || + (F1AP_SETUP_REQ (msg_p).cell[k].mnc_digit_length == 3), "BAD MNC DIGIT LENGTH %d", - F1AP_SETUP_REQ (msg_p).mnc_digit_length[k]); - F1AP_SETUP_REQ (msg_p).nr_cellid[k] = (uint64_t)*(ENBParamList.paramarray[i][ENB_NRCELLID_IDX].u64ptr); - LOG_I(ENB_APP,"F1AP: nr_cellid[%d] %ld\n",k,F1AP_SETUP_REQ (msg_p).nr_cellid[k]); + F1AP_SETUP_REQ (msg_p).cell[k].mnc_digit_length); + F1AP_SETUP_REQ (msg_p).cell[k].nr_cellid = (uint64_t)*(ENBParamList.paramarray[i][ENB_NRCELLID_IDX].u64ptr); + LOG_I(ENB_APP,"F1AP: nr_cellid[%d] %ld\n",k,F1AP_SETUP_REQ (msg_p).cell[k].nr_cellid); LOG_I(ENB_APP,"F1AP: CU_ip4_address in DU %s\n",RC.mac[k]->eth_params_n.remote_addr); LOG_I(ENB_APP,"FIAP: CU_ip4_address in DU %p, strlen %d\n",F1AP_SETUP_REQ (msg_p).CU_f1_ip_address.ipv4_address,(int)strlen(RC.mac[k]->eth_params_n.remote_addr)); F1AP_SETUP_REQ (msg_p).CU_f1_ip_address.ipv6 = 0; @@ -1969,8 +1970,11 @@ int RCconfig_DU_F1(MessageDef *msg_p, uint32_t i) { LOG_I(ENB_APP,"FIAP: DU_ip4_address in DU %p, strlen %d\n",F1AP_SETUP_REQ (msg_p).DU_f1_ip_address.ipv4_address,(int)strlen(RC.mac[k]->eth_params_n.my_addr)); F1AP_SETUP_REQ (msg_p).DU_f1_ip_address.ipv6 = 0; F1AP_SETUP_REQ (msg_p).DU_f1_ip_address.ipv4 = 1; + //strcpy(F1AP_SETUP_REQ (msg_p).DU_f1_ip_address.ipv6_address, ""); strcpy(F1AP_SETUP_REQ (msg_p).DU_f1_ip_address.ipv4_address, RC.mac[k]->eth_params_n.my_addr); + F1AP_SETUP_REQ (msg_p).DUport= RC.mac[k]->eth_params_n.my_portd; + F1AP_SETUP_REQ (msg_p).CUport= RC.mac[k]->eth_params_n.remote_portd; //strcpy(F1AP_SETUP_REQ (msg_p).CU_ip_address[l].ipv6_address,*(F1ParamList.paramarray[l][ENB_CU_IPV6_ADDRESS_IDX].strptr)); //F1AP_SETUP_REQ (msg_p).CU_port = RC.mac[k]->eth_params_n.remote_portc; // maybe we dont need it sprintf(aprefix,"%s.[%i].%s",ENB_CONFIG_STRING_ENB_LIST,k,ENB_CONFIG_STRING_SCTP_CONFIG); @@ -1989,12 +1993,12 @@ int RCconfig_DU_F1(MessageDef *msg_p, uint32_t i) { pthread_mutex_unlock(&rrc->cell_info_mutex); } while (cell_info_configured ==0); - rrc->configuration.mcc[0] = F1AP_SETUP_REQ (msg_p).mcc[k]; - rrc->configuration.mnc[0] = F1AP_SETUP_REQ (msg_p).mnc[k]; - rrc->configuration.tac = F1AP_SETUP_REQ (msg_p).tac[k]; - rrc->nr_cellid = F1AP_SETUP_REQ (msg_p).nr_cellid[k]; - F1AP_SETUP_REQ (msg_p).nr_pci[k] = rrc->carrier[0].physCellId; - F1AP_SETUP_REQ (msg_p).num_ssi[k] = 0; + rrc->configuration.mcc[0] = F1AP_SETUP_REQ (msg_p).cell[k].mcc; + rrc->configuration.mnc[0] = F1AP_SETUP_REQ (msg_p).cell[k].mnc; + rrc->configuration.tac = F1AP_SETUP_REQ (msg_p).cell[k].tac; + rrc->nr_cellid = F1AP_SETUP_REQ (msg_p).cell[k].nr_cellid; + F1AP_SETUP_REQ (msg_p).cell[k].nr_pci = rrc->carrier[0].physCellId; + F1AP_SETUP_REQ (msg_p).cell[k].num_ssi = 0; if (rrc->carrier[0].sib1->tdd_Config) { LOG_I(ENB_APP,"ngran_DU: Configuring Cell %d for TDD\n",k); @@ -2070,12 +2074,12 @@ int RCconfig_gtpu(void ) { if (address) { MessageDef *message; - AssertFatal((message = itti_alloc_new_message(TASK_ENB_APP, 0, GTPV1U_ENB_S1_REQ))!=NULL,""); - IPV4_STR_ADDR_TO_INT_NWBO ( address, GTPV1U_ENB_S1_REQ(message).enb_ip_address_for_S1u_S12_S4_up, "BAD IP ADDRESS FORMAT FOR eNB S1_U !\n" ); - LOG_I(GTPU,"Configuring GTPu address : %s -> %x\n",address,GTPV1U_ENB_S1_REQ(message).enb_ip_address_for_S1u_S12_S4_up); - GTPV1U_ENB_S1_REQ(message).enb_port_for_S1u_S12_S4_up = enb_port_for_S1U; - strcpy(GTPV1U_ENB_S1_REQ(message).addrStr,address); - sprintf(GTPV1U_ENB_S1_REQ(message).portStr,"%d", enb_port_for_S1U); + AssertFatal((message = itti_alloc_new_message(TASK_ENB_APP, 0, GTPV1U_REQ))!=NULL,""); + IPV4_STR_ADDR_TO_INT_NWBO ( address, GTPV1U_REQ(message).localAddr, "BAD IP ADDRESS FORMAT FOR eNB S1_U !\n" ); + LOG_I(GTPU,"Configuring GTPu address : %s -> %x\n",address,GTPV1U_REQ(message).localAddr); + GTPV1U_REQ(message).localPort = enb_port_for_S1U; + strcpy(GTPV1U_REQ(message).localAddrStr,address); + sprintf(GTPV1U_REQ(message).localPortStr,"%d", enb_port_for_S1U); itti_send_msg_to_task (TASK_VARIABLE, 0, message); // data model is wrong: gtpu doesn't have enb_id (or module_id) } else LOG_E(GTPU,"invalid address for S1U\n"); @@ -3167,7 +3171,7 @@ void handle_f1ap_setup_resp(f1ap_setup_resp_t *resp) { (check_plmn_identity(carrier, resp->cells_to_activate[j].mcc, resp->cells_to_activate[j].mnc, resp->cells_to_activate[j].mnc_digit_length)>0 && resp->cells_to_activate[j].nrpci == carrier->physCellId)) { // copy system information and decode it - for (si_ind=2; si_ind<resp->cells_to_activate[j].num_SI + 2; si_ind++) { + for (si_ind=0; si_ind<resp->cells_to_activate[j].num_SI; si_ind++) { //printf("SI %d size %d: ", si_ind, resp->cells_to_activate[j].SI_container_length[si_ind]); //for (int n=0;n<resp->cells_to_activate[j].SI_container_length[si_ind];n++) // printf("%02x ",resp->cells_to_activate[j].SI_container[si_ind][n]); @@ -3175,7 +3179,7 @@ void handle_f1ap_setup_resp(f1ap_setup_resp_t *resp) { if (si_ind==6) si_ind=9; if (resp->cells_to_activate[j].SI_container[si_ind] != NULL) { extract_and_decode_SI(i, - si_ind, + resp->cells_to_activate[j].SI_type[si_ind], resp->cells_to_activate[j].SI_container[si_ind], resp->cells_to_activate[j].SI_container_length[si_ind]); } diff --git a/openair2/F1AP/dummy_enb.c b/openair2/F1AP/dummy_enb.c index fe6dfb6a06af9f3130cc418a4136ac6f1e487fc6..d54f9b8df7b21bb90ec9ea8ca182f785e7e20787 100644 --- a/openair2/F1AP/dummy_enb.c +++ b/openair2/F1AP/dummy_enb.c @@ -29,6 +29,19 @@ void apply_macrlc_config(gNB_RRC_INST *rrc, rrc_gNB_ue_context_t *const ue_context_pP, const protocol_ctxt_t *const ctxt_pP ) { -abort(); + abort(); } +boolean_t sdap_gnb_data_req(protocol_ctxt_t *ctxt_p, + const srb_flag_t srb_flag, + const rb_id_t rb_id, + const mui_t mui, + const confirm_t confirm, + const sdu_size_t sdu_buffer_size, + unsigned char *const sdu_buffer, + const pdcp_transmission_mode_t pt_mode, + const uint32_t *sourceL2Id, + const uint32_t *destinationL2Id + ) { +abort(); +} diff --git a/openair2/F1AP/f1ap_common.c b/openair2/F1AP/f1ap_common.c index 267626dd5ceecddea419461d7b2f7895d3430915..338b5f0c2b89e577c8651213a4681f1f5bf2f534 100644 --- a/openair2/F1AP/f1ap_common.c +++ b/openair2/F1AP/f1ap_common.c @@ -32,19 +32,22 @@ #include "f1ap_common.h" +static f1ap_cudu_inst_t *f1_du_inst[NUMBER_OF_eNB_MAX]= {0}; +static f1ap_cudu_inst_t *f1_cu_inst[NUMBER_OF_eNB_MAX]= {0}; + #if defined(EMIT_ASN_DEBUG_EXTERN) int asn_debug = 0; int asn1_xer_print = 0; -inline void ASN_DEBUG(const char *fmt, ...) -{ +inline void ASN_DEBUG(const char *fmt, ...) { if (asn_debug) { int adi = asn_debug_indent; va_list ap; va_start(ap, fmt); fprintf(stderr, "[ASN1]"); - while(adi--) fprintf(stderr, " "); + while(adi--) + fprintf(stderr, " "); vfprintf(stderr, fmt, ap); fprintf(stderr, "\n"); @@ -53,142 +56,157 @@ inline void ASN_DEBUG(const char *fmt, ...) } #endif -uint8_t F1AP_get_next_transaction_identifier(module_id_t enb_mod_idP, module_id_t cu_mod_idP) -{ +uint8_t F1AP_get_next_transaction_identifier(instance_t enb_mod_idP, instance_t cu_mod_idP) { static uint8_t transaction_identifier[NUMBER_OF_eNB_MAX]; transaction_identifier[enb_mod_idP+cu_mod_idP] = - (transaction_identifier[enb_mod_idP+cu_mod_idP] + 1) % F1AP_TRANSACTION_IDENTIFIER_NUMBER; + (transaction_identifier[enb_mod_idP+cu_mod_idP] + 1) % F1AP_TRANSACTION_IDENTIFIER_NUMBER; //LOG_T(F1AP,"generated xid is %d\n",transaction_identifier[enb_mod_idP+cu_mod_idP]); return transaction_identifier[enb_mod_idP+cu_mod_idP]; } -int f1ap_add_ue(f1ap_cudu_inst_t *f1_inst, - module_id_t module_idP, - int CC_idP, - int UE_id, +f1ap_cudu_inst_t *getCxt(F1_t isCU, instance_t instanceP) { + //Fixme: 4G F1 has race condtions, someone may debug it, using this test + /* + static pid_t t=-1; + pid_t tNew=gettid(); + AssertFatal ( t==-1 || t==tNew, "This is not thread safe\n"); + t=tNew; + */ + AssertFatal( instanceP < sizeofArray(f1_cu_inst), ""); + return isCU == CUtype ? f1_cu_inst[ instanceP]: f1_du_inst[ instanceP]; +} + +void createF1inst(F1_t isCU, instance_t instanceP, f1ap_setup_req_t *req) { + if (isCU == CUtype) { + AssertFatal(f1_cu_inst[instanceP] == NULL, "Double call to F1 CU init\n"); + f1_cu_inst[instanceP]=( f1ap_cudu_inst_t *) calloc(1, sizeof( f1ap_cudu_inst_t)); + //memcpy(f1_cu_inst[instanceP]->setupReq, req, sizeof(f1ap_setup_req_t) ); + } else { + AssertFatal(f1_du_inst[instanceP] == NULL, "Double call to F1 DU init\n"); + f1_du_inst[instanceP]=( f1ap_cudu_inst_t *) calloc(1, sizeof(f1ap_cudu_inst_t)); + memcpy(&f1_du_inst[instanceP]->setupReq, req, sizeof(f1ap_setup_req_t) ); + } +} + +int f1ap_add_ue(F1_t isCu, + instance_t instanceP, rnti_t rntiP) { + f1ap_cudu_inst_t *f1_inst=getCxt(isCu, instanceP); + for (int i = 0; i < MAX_MOBILES_PER_ENB; i++) { if (f1_inst->f1ap_ue[i].rnti == rntiP) { f1_inst->f1ap_ue[i].f1ap_uid = i; - f1_inst->f1ap_ue[i].mac_uid = UE_id; - LOG_I(F1AP, "Updating the index of UE with RNTI %x and du_ue_f1ap_id %d\n", f1_inst->f1ap_ue[i].rnti, f1_inst->f1ap_ue[i].du_ue_f1ap_id); + LOG_I(F1AP, "Updating the index of UE with RNTI %x and du_ue_f1ap_id %ld\n", f1_inst->f1ap_ue[i].rnti, f1_inst->f1ap_ue[i].du_ue_f1ap_id); return i; } } + + // We didn't find the rnti for (int i = 0; i < MAX_MOBILES_PER_ENB; i++) { if (f1_inst->f1ap_ue[i].rnti == 0 ) { f1_inst->f1ap_ue[i].rnti = rntiP; f1_inst->f1ap_ue[i].f1ap_uid = i; - f1_inst->f1ap_ue[i].mac_uid = UE_id; f1_inst->f1ap_ue[i].du_ue_f1ap_id = rntiP; f1_inst->f1ap_ue[i].cu_ue_f1ap_id = rntiP; f1_inst->num_ues++; - LOG_I(F1AP, "Adding a new UE with RNTI %x and cu/du ue_f1ap_id %d\n", f1_inst->f1ap_ue[i].rnti, f1_inst->f1ap_ue[i].du_ue_f1ap_id); + LOG_I(F1AP, "Adding a new UE with RNTI %x and cu/du ue_f1ap_id %ld\n", f1_inst->f1ap_ue[i].rnti, f1_inst->f1ap_ue[i].du_ue_f1ap_id); return i; } } + return -1; } -int f1ap_remove_ue(f1ap_cudu_inst_t *f1_inst, +int f1ap_remove_ue(F1_t isCu, instance_t instanceP, rnti_t rntiP) { + f1ap_cudu_inst_t *f1_inst=getCxt(isCu, instanceP); + for (int i = 0; i < MAX_MOBILES_PER_ENB; i++) { if (f1_inst->f1ap_ue[i].rnti == rntiP) { f1_inst->f1ap_ue[i].rnti = 0; break; } } + f1_inst->num_ues--; return 0; } -int f1ap_get_du_ue_f1ap_id(f1ap_cudu_inst_t *f1_inst, - rnti_t rntiP) { +int f1ap_get_du_ue_f1ap_id(F1_t isCu, instance_t instanceP, + rnti_t rntiP) { + f1ap_cudu_inst_t *f1_inst=getCxt(isCu, instanceP); + for (int i = 0; i < MAX_MOBILES_PER_ENB; i++) { if (f1_inst->f1ap_ue[i].rnti == rntiP) { return f1_inst->f1ap_ue[i].du_ue_f1ap_id; } } + return -1; } -int f1ap_get_cu_ue_f1ap_id(f1ap_cudu_inst_t *f1_inst, - rnti_t rntiP) { +int f1ap_get_cu_ue_f1ap_id(F1_t isCu, instance_t instanceP, + rnti_t rntiP) { + f1ap_cudu_inst_t *f1_inst=getCxt(isCu, instanceP); + for (int i = 0; i < MAX_MOBILES_PER_ENB; i++) { if (f1_inst->f1ap_ue[i].rnti == rntiP) { return f1_inst->f1ap_ue[i].cu_ue_f1ap_id; } } + return -1; } -int f1ap_get_rnti_by_du_id(f1ap_cudu_inst_t *f1_inst, - module_id_t du_ue_f1ap_id ) { +int f1ap_get_rnti_by_du_id(F1_t isCu, instance_t instanceP, + instance_t du_ue_f1ap_id ) { + f1ap_cudu_inst_t *f1_inst=getCxt(isCu, instanceP); + for (int i = 0; i < MAX_MOBILES_PER_ENB; i++) { if (f1_inst->f1ap_ue[i].du_ue_f1ap_id == du_ue_f1ap_id) { return f1_inst->f1ap_ue[i].rnti; } } + return -1; } -int f1ap_get_rnti_by_cu_id(f1ap_cudu_inst_t *f1_inst, - module_id_t cu_ue_f1ap_id ) { +int f1ap_get_rnti_by_cu_id(F1_t isCu, instance_t instanceP, + instance_t cu_ue_f1ap_id ) { + f1ap_cudu_inst_t *f1_inst=getCxt(isCu, instanceP); + for (int i = 0; i < MAX_MOBILES_PER_ENB; i++) { if (f1_inst->f1ap_ue[i].cu_ue_f1ap_id == cu_ue_f1ap_id) { return f1_inst->f1ap_ue[i].rnti; } } - return -1; -} -int f1ap_get_du_uid(f1ap_cudu_inst_t *f1_inst, - module_id_t du_ue_f1ap_id ) { - for (int i = 0; i < MAX_MOBILES_PER_ENB; i++) { - if (f1_inst->f1ap_ue[i].du_ue_f1ap_id == du_ue_f1ap_id) { - return i; - } - } return -1; } -int f1ap_get_cu_uid(f1ap_cudu_inst_t *f1_inst, - module_id_t cu_ue_f1ap_id ) { - for (int i = 0; i < MAX_MOBILES_PER_ENB; i++) { - if (f1_inst->f1ap_ue[i].cu_ue_f1ap_id == cu_ue_f1ap_id) { - return i; - } - } - return -1; -} +int f1ap_du_add_cu_ue_id(instance_t instanceP, + instance_t du_ue_f1ap_id, + instance_t cu_ue_f1ap_id) { + f1ap_cudu_inst_t *f1_inst=getCxt(DUtype, instanceP); + instance_t f1ap_uid=-1; -int f1ap_get_uid_by_rnti(f1ap_cudu_inst_t *f1_inst, - rnti_t rntiP ) { for (int i = 0; i < MAX_MOBILES_PER_ENB; i++) { - if (f1_inst->f1ap_ue[i].rnti == rntiP) { - return i; + if (f1_inst->f1ap_ue[i].du_ue_f1ap_id == du_ue_f1ap_id) { + f1ap_uid=i; + break; } } - return -1; -} -int f1ap_du_add_cu_ue_id(f1ap_cudu_inst_t *f1_inst, - module_id_t du_ue_f1ap_id, - module_id_t cu_ue_f1ap_id) { - module_id_t f1ap_uid = f1ap_get_du_uid(f1_inst,du_ue_f1ap_id); - if (f1ap_uid < 0 || f1ap_uid >= MAX_MOBILES_PER_ENB) return -1; + if (f1ap_uid < 0 || f1ap_uid >= MAX_MOBILES_PER_ENB) + return -1; + f1_inst->f1ap_ue[f1ap_uid].cu_ue_f1ap_id = cu_ue_f1ap_id; - LOG_I(F1AP, "Adding cu_ue_f1ap_id %d for UE with RNTI %x\n", cu_ue_f1ap_id, f1_inst->f1ap_ue[f1ap_uid].rnti); + LOG_I(F1AP, "Adding cu_ue_f1ap_id %ld for UE with RNTI %x\n", cu_ue_f1ap_id, f1_inst->f1ap_ue[f1ap_uid].rnti); return 0; } -int f1ap_cu_add_du_ue_id(f1ap_cudu_inst_t *f1_inst, - module_id_t cu_ue_f1ap_id, - module_id_t du_ue_f1ap_id) { - module_id_t f1ap_uid = f1ap_get_cu_uid(f1_inst,cu_ue_f1ap_id); - if (f1ap_uid < 0 || f1ap_uid >= MAX_MOBILES_PER_ENB) return -1; - f1_inst->f1ap_ue[f1ap_uid].du_ue_f1ap_id = du_ue_f1ap_id; - LOG_I(F1AP, "Adding du_ue_f1ap_id %d for UE with RNTI %x\n", du_ue_f1ap_id, f1_inst->f1ap_ue[f1ap_uid].rnti); - return 0; +int f1ap_assoc_id(F1_t isCu, instance_t instanceP) { + f1ap_setup_req_t *f1_inst=f1ap_req(isCu, instanceP); + return f1_inst->assoc_id; } diff --git a/openair2/F1AP/f1ap_common.h b/openair2/F1AP/f1ap_common.h index 7781a78412ecb4e1c9caf08d805c62995a9c79ed..a393930c8186c138086645a638b7d78ff79db17f 100644 --- a/openair2/F1AP/f1ap_common.h +++ b/openair2/F1AP/f1ap_common.h @@ -31,19 +31,20 @@ */ #if HAVE_CONFIG_H_ -# include "config.h" + #include "config.h" #endif #ifndef F1AP_COMMON_H_ #define F1AP_COMMON_H_ #include "openairinterface5g_limits.h" +#include <openair2/RRC/NR/MESSAGES/asn1_msg.h> #define F1AP_UE_IDENTIFIER_NUMBER 3 #define F1AP_TRANSACTION_IDENTIFIER_NUMBER 3 #if defined(EMIT_ASN_DEBUG_EXTERN) -inline void ASN_DEBUG(const char *fmt, ...); + inline void ASN_DEBUG(const char *fmt, ...); #endif #include "F1AP_RAT-FrequencyPriorityInformation.h" @@ -360,14 +361,14 @@ inline void ASN_DEBUG(const char *fmt, ...); /* Checking version of ASN1C compiler */ #if (ASN1C_ENVIRONMENT_VERSION < ASN1C_MINIMUM_VERSION) -# error "You are compiling f1ap with the wrong version of ASN1C" + # error "You are compiling f1ap with the wrong version of ASN1C" #endif #ifndef FALSE -# define FALSE (0) + #define FALSE (0) #endif #ifndef TRUE -# define TRUE (!FALSE) + #define TRUE (!FALSE) #endif #define F1AP_UE_ID_FMT "0x%06"PRIX32 @@ -375,20 +376,20 @@ inline void ASN_DEBUG(const char *fmt, ...); #include "assertions.h" #if defined(ENB_MODE) -# include "common/utils/LOG/log.h" -# include "f1ap_default_values.h" -# define F1AP_ERROR(x, args...) LOG_E(F1AP, x, ##args) -# define F1AP_WARN(x, args...) LOG_W(F1AP, x, ##args) -# define F1AP_TRAF(x, args...) LOG_I(F1AP, x, ##args) -# define F1AP_INFO(x, args...) LOG_I(F1AP, x, ##args) -# define F1AP_DEBUG(x, args...) LOG_I(F1AP, x, ##args) + #include "common/utils/LOG/log.h" + #include "f1ap_default_values.h" + #define F1AP_ERROR(x, args...) LOG_E(F1AP, x, ##args) + #define F1AP_WARN(x, args...) LOG_W(F1AP, x, ##args) + #define F1AP_TRAF(x, args...) LOG_I(F1AP, x, ##args) + #define F1AP_INFO(x, args...) LOG_I(F1AP, x, ##args) + #define F1AP_DEBUG(x, args...) LOG_I(F1AP, x, ##args) #else -//# include "mme_default_values.h" -# define F1AP_ERROR(x, args...) do { fprintf(stdout, "[F1AP][E]"x, ##args); } while(0) -# define F1AP_WARN(x, args...) do { fprintf(stdout, "[F1AP][W]"x, ##args); } while(0) -# define F1AP_TRAF(x, args...) do { fprintf(stdout, "[F1AP][T]"x, ##args); } while(0) -# define F1AP_INFO(x, args...) do { fprintf(stdout, "[F1AP][I]"x, ##args); } while(0) -# define F1AP_DEBUG(x, args...) do { fprintf(stdout, "[F1AP][D]"x, ##args); } while(0) + //# include "mme_default_values.h" + #define F1AP_ERROR(x, args...) do { fprintf(stdout, "[F1AP][E]"x, ##args); } while(0) + #define F1AP_WARN(x, args...) do { fprintf(stdout, "[F1AP][W]"x, ##args); } while(0) + #define F1AP_TRAF(x, args...) do { fprintf(stdout, "[F1AP][T]"x, ##args); } while(0) + #define F1AP_INFO(x, args...) do { fprintf(stdout, "[F1AP][I]"x, ##args); } while(0) + #define F1AP_DEBUG(x, args...) do { fprintf(stdout, "[F1AP][D]"x, ##args); } while(0) #endif //Forward declaration @@ -407,73 +408,86 @@ inline void ASN_DEBUG(const char *fmt, ...); if (mandatory) DevAssert(ie != NULL); \ } while(0) -/** \brief Function callback prototype. +/** \brief Function array prototype. **/ -typedef int (*f1ap_message_decoded_callback)( +typedef int (*f1ap_message_processing_t)( instance_t instance, uint32_t assoc_id, uint32_t stream, F1AP_F1AP_PDU_t *message_p ); +int f1ap_handle_message(instance_t instance, uint32_t assoc_id, int32_t stream, + const uint8_t *const data, const uint32_t data_length); typedef struct f1ap_cudu_ue_inst_s { // used for eNB stats generation rnti_t rnti; - module_id_t f1ap_uid; - module_id_t mac_uid; - module_id_t du_ue_f1ap_id; - module_id_t cu_ue_f1ap_id; + instance_t f1ap_uid; + instance_t du_ue_f1ap_id; + instance_t cu_ue_f1ap_id; } f1ap_cudu_ue_t; typedef struct f1ap_cudu_inst_s { + f1ap_setup_req_t setupReq; + uint16_t sctp_in_streams; + uint16_t sctp_out_streams; + uint16_t default_sctp_stream_id; + instance_t gtpInst; + uint64_t gNB_DU_id; uint16_t num_ues; f1ap_cudu_ue_t f1ap_ue[MAX_MOBILES_PER_ENB]; } f1ap_cudu_inst_t; +typedef enum { + DUtype=0, + CUtype +} F1_t; +static const int nrb_lut[29] = {11, 18, 24, 25, 31, 32, 38, 51, 52, 65, 66, 78, 79, 93, 106, 107, 121, 132, 133, 135, 160, 162, 189, 216, 217, 245, 264, 270, 273}; -uint8_t F1AP_get_next_transaction_identifier(module_id_t enb_mod_idP, module_id_t cu_mod_idP); +uint8_t F1AP_get_next_transaction_identifier(instance_t enb_mod_idP, instance_t cu_mod_idP); +f1ap_cudu_inst_t *getCxt(F1_t isCU, instance_t instanceP); -int f1ap_add_ue(f1ap_cudu_inst_t *f1_inst, - module_id_t module_idP, - int CC_idP, - int UE_id, +void createF1inst(F1_t isCU, instance_t instanceP, f1ap_setup_req_t *req); +int f1ap_add_ue(F1_t isCu, + instance_t instanceP, rnti_t rntiP); -int f1ap_remove_ue(f1ap_cudu_inst_t *f1_inst, +int f1ap_remove_ue(F1_t isCu, instance_t instanceP, rnti_t rntiP); -int f1ap_get_du_ue_f1ap_id (f1ap_cudu_inst_t *f1_inst, +int f1ap_get_du_ue_f1ap_id (F1_t isCu, instance_t instanceP, rnti_t rntiP); -int f1ap_get_cu_ue_f1ap_id (f1ap_cudu_inst_t *f1_inst, +int f1ap_get_cu_ue_f1ap_id (F1_t isCu, instance_t instanceP, rnti_t rntiP); -int f1ap_get_rnti_by_du_id(f1ap_cudu_inst_t *f1_inst, - module_id_t du_ue_f1ap_id ); +int f1ap_get_rnti_by_du_id(F1_t isCu, instance_t instanceP, + instance_t du_ue_f1ap_id ); -int f1ap_get_rnti_by_cu_id(f1ap_cudu_inst_t *f1_inst, - module_id_t cu_ue_f1ap_id ); +int f1ap_get_rnti_by_cu_id(F1_t isCu, instance_t instanceP, + instance_t cu_ue_f1ap_id ); +int f1ap_du_add_cu_ue_id(instance_t instanceP, + instance_t du_ue_f1ap_id, + instance_t cu_ue_f1ap_id); -int f1ap_get_du_uid(f1ap_cudu_inst_t *f1_inst, - module_id_t du_ue_f1ap_id ); +int f1ap_assoc_id(F1_t isCu, instance_t instanceP); -int f1ap_get_cu_uid(f1ap_cudu_inst_t *f1_inst, - module_id_t cu_ue_f1ap_id ); +static inline f1ap_setup_req_t *f1ap_req(F1_t isCu, instance_t instanceP) { + return &getCxt(isCu, instanceP)->setupReq; +} -int f1ap_get_uid_by_rnti(f1ap_cudu_inst_t *f1_inst, - rnti_t rntiP ); +#define TASK_F1APP f1ap_req(false, instance)->cell_type==CELL_MACRO_GNB?TASK_GNB_APP:TASK_ENB_APP -int f1ap_du_add_cu_ue_id(f1ap_cudu_inst_t *f1_inst, - module_id_t du_ue_f1ap_id, - module_id_t cu_ue_f1ap_id); - -int f1ap_cu_add_du_ue_id(f1ap_cudu_inst_t *f1_inst, - module_id_t cu_ue_f1ap_id, - module_id_t du_ue_f1ap_id); +//lts: C struct type is not homogeneous, so we need macros instead of functions +#define addnRCGI(nRCGi, servedCelL) \ + MCC_MNC_TO_PLMNID((servedCelL)->mcc,(servedCelL)-> mnc,(servedCelL)->mnc_digit_length, \ + &((nRCGi).pLMN_Identity)); \ + NR_CELL_ID_TO_BIT_STRING((servedCelL)->nr_cellid, &((nRCGi).nRCellIdentity)); +extern RAN_CONTEXT_t RC; #endif /* F1AP_COMMON_H_ */ diff --git a/openair2/F1AP/f1ap_cu_interface_management.c b/openair2/F1AP/f1ap_cu_interface_management.c index 057d0d97a0bbc3b835a3974539f2a6c61d9e72b2..fdd5f3ea3e70d47d7fb8d96d481aab038f16c65a 100644 --- a/openair2/F1AP/f1ap_cu_interface_management.c +++ b/openair2/F1AP/f1ap_cu_interface_management.c @@ -36,24 +36,21 @@ #include "f1ap_itti_messaging.h" #include "f1ap_cu_interface_management.h" -extern f1ap_setup_req_t *f1ap_du_data_from_du; -extern RAN_CONTEXT_t RC; - int CU_send_RESET(instance_t instance, F1AP_Reset_t *Reset) { AssertFatal(1==0,"Not implemented yet\n"); } int CU_handle_RESET_ACKKNOWLEDGE(instance_t instance, - uint32_t assoc_id, - uint32_t stream, - F1AP_F1AP_PDU_t *pdu) { + uint32_t assoc_id, + uint32_t stream, + F1AP_F1AP_PDU_t *pdu) { AssertFatal(1==0,"Not implemented yet\n"); } int CU_handle_RESET(instance_t instance, - uint32_t assoc_id, - uint32_t stream, - F1AP_F1AP_PDU_t *pdu) { + uint32_t assoc_id, + uint32_t stream, + F1AP_F1AP_PDU_t *pdu) { AssertFatal(1==0,"Not implemented yet\n"); } @@ -66,9 +63,9 @@ int CU_send_RESET_ACKNOWLEDGE(instance_t instance, F1AP_ResetAcknowledge_t *Rese Error Indication */ int CU_handle_ERROR_INDICATION(instance_t instance, - uint32_t assoc_id, - uint32_t stream, - F1AP_F1AP_PDU_t *pdu) { + uint32_t assoc_id, + uint32_t stream, + F1AP_F1AP_PDU_t *pdu) { AssertFatal(1==0,"Not implemented yet\n"); } @@ -83,330 +80,295 @@ int CU_send_ERROR_INDICATION(instance_t instance, F1AP_ErrorIndication_t *ErrorI int CU_handle_F1_SETUP_REQUEST(instance_t instance, uint32_t assoc_id, uint32_t stream, - F1AP_F1AP_PDU_t *pdu) -{ + F1AP_F1AP_PDU_t *pdu) { LOG_D(F1AP, "CU_handle_F1_SETUP_REQUEST\n"); - MessageDef *message_p; F1AP_F1SetupRequest_t *container; F1AP_F1SetupRequestIEs_t *ie; int i = 0; - - DevAssert(pdu != NULL); - container = &pdu->choice.initiatingMessage->value.choice.F1SetupRequest; /* F1 Setup Request == Non UE-related procedure -> stream 0 */ if (stream != 0) { LOG_W(F1AP, "[SCTP %d] Received f1 setup request on stream != 0 (%d)\n", - assoc_id, stream); - } - - if(RC.nrrrc) { - message_p = itti_alloc_new_message(TASK_CU_F1, 0, F1AP_SETUP_REQ); - } else { - message_p = itti_alloc_new_message(TASK_RRC_ENB, 0, F1AP_SETUP_REQ); + assoc_id, stream); } /* assoc_id */ - F1AP_SETUP_REQ(message_p).assoc_id = assoc_id; - + f1ap_setup_req_t *req=&getCxt(true, instance)->setupReq; + req->assoc_id = assoc_id; /* gNB_DU_id */ // this function exits if the ie is mandatory F1AP_FIND_PROTOCOLIE_BY_ID(F1AP_F1SetupRequestIEs_t, ie, container, F1AP_ProtocolIE_ID_id_gNB_DU_ID, true); - asn_INTEGER2ulong(&ie->value.choice.GNB_DU_ID, &F1AP_SETUP_REQ(message_p).gNB_DU_id); - LOG_D(F1AP, "F1AP_SETUP_REQ(message_p).gNB_DU_id %lu \n", F1AP_SETUP_REQ(message_p).gNB_DU_id); - + asn_INTEGER2ulong(&ie->value.choice.GNB_DU_ID, &req->gNB_DU_id); + LOG_D(F1AP, "req->gNB_DU_id %lu \n", req->gNB_DU_id); /* gNB_DU_name */ F1AP_FIND_PROTOCOLIE_BY_ID(F1AP_F1SetupRequestIEs_t, ie, container, - F1AP_ProtocolIE_ID_id_gNB_DU_Name, true); - F1AP_SETUP_REQ(message_p).gNB_DU_name = calloc(ie->value.choice.GNB_DU_Name.size + 1, sizeof(char)); - memcpy(F1AP_SETUP_REQ(message_p).gNB_DU_name, ie->value.choice.GNB_DU_Name.buf, + F1AP_ProtocolIE_ID_id_gNB_DU_Name, true); + req->gNB_DU_name = calloc(ie->value.choice.GNB_DU_Name.size + 1, sizeof(char)); + memcpy(req->gNB_DU_name, ie->value.choice.GNB_DU_Name.buf, ie->value.choice.GNB_DU_Name.size); - /* Convert the mme name to a printable string */ - F1AP_SETUP_REQ(message_p).gNB_DU_name[ie->value.choice.GNB_DU_Name.size] = '\0'; - LOG_D(F1AP, "F1AP_SETUP_REQ(message_p).gNB_DU_name %s \n", F1AP_SETUP_REQ(message_p).gNB_DU_name); - + LOG_D(F1AP, "req->gNB_DU_name %s \n", req->gNB_DU_name); /* GNB_DU_Served_Cells_List */ F1AP_FIND_PROTOCOLIE_BY_ID(F1AP_F1SetupRequestIEs_t, ie, container, - F1AP_ProtocolIE_ID_id_gNB_DU_Served_Cells_List, true); - F1AP_SETUP_REQ(message_p).num_cells_available = ie->value.choice.GNB_DU_Served_Cells_List.list.count; - LOG_D(F1AP, "F1AP_SETUP_REQ(message_p).num_cells_available %d \n", - F1AP_SETUP_REQ(message_p).num_cells_available); - - int num_cells_available = F1AP_SETUP_REQ(message_p).num_cells_available; - - for (i=0; i<num_cells_available; i++) { - F1AP_GNB_DU_Served_Cells_Item_t *served_cells_item_p; - - served_cells_item_p = &(((F1AP_GNB_DU_Served_Cells_ItemIEs_t *)ie->value.choice.GNB_DU_Served_Cells_List.list.array[i])->value.choice.GNB_DU_Served_Cells_Item); - + F1AP_ProtocolIE_ID_id_gNB_DU_Served_Cells_List, true); + req->num_cells_available = ie->value.choice.GNB_DU_Served_Cells_List.list.count; + LOG_D(F1AP, "req->num_cells_available %d \n", req->num_cells_available); + + for (i=0; i<req->num_cells_available; i++) { + F1AP_GNB_DU_Served_Cells_Item_t *served_cells_item = &(((F1AP_GNB_DU_Served_Cells_ItemIEs_t *) + ie->value.choice.GNB_DU_Served_Cells_List.list.array[i])-> + value.choice.GNB_DU_Served_Cells_Item); + F1AP_Served_Cell_Information_t *servedCellInformation= &served_cells_item->served_Cell_Information; /* tac */ - if (served_cells_item_p->served_Cell_Information.fiveGS_TAC) { - OCTET_STRING_TO_INT16(served_cells_item_p->served_Cell_Information.fiveGS_TAC, F1AP_SETUP_REQ(message_p).tac[i]); - LOG_D(F1AP, "F1AP_SETUP_REQ(message_p).tac[%d] %d \n", i, F1AP_SETUP_REQ(message_p).tac[i]); + if (servedCellInformation->fiveGS_TAC) { + OCTET_STRING_TO_INT16(servedCellInformation->fiveGS_TAC, req->cell[i].tac); + LOG_D(F1AP, "req->tac[%d] %d \n", i, req->cell[i].tac); } - /* - nRCGI */ - TBCD_TO_MCC_MNC(&(served_cells_item_p->served_Cell_Information.nRCGI.pLMN_Identity), F1AP_SETUP_REQ(message_p).mcc[i], - F1AP_SETUP_REQ(message_p).mnc[i], - F1AP_SETUP_REQ(message_p).mnc_digit_length[i]); - + /* - nRCGI */ + TBCD_TO_MCC_MNC(&(servedCellInformation->nRCGI.pLMN_Identity), req->cell[i].mcc, + req->cell[i].mnc,req->cell[i].mnc_digit_length); // NR cellID - BIT_STRING_TO_NR_CELL_IDENTITY(&served_cells_item_p->served_Cell_Information.nRCGI.nRCellIdentity, - F1AP_SETUP_REQ(message_p).nr_cellid[i]); + BIT_STRING_TO_NR_CELL_IDENTITY(&servedCellInformation->nRCGI.nRCellIdentity, + req->cell[i].nr_cellid); LOG_D(F1AP, "[SCTP %d] Received nRCGI: MCC %d, MNC %d, CELL_ID %llu\n", assoc_id, - F1AP_SETUP_REQ(message_p).mcc[i], - F1AP_SETUP_REQ(message_p).mnc[i], - (long long unsigned int)F1AP_SETUP_REQ(message_p).nr_cellid[i]); - LOG_D(F1AP, "nr_cellId : %x %x %x %x %x\n", - served_cells_item_p->served_Cell_Information.nRCGI.nRCellIdentity.buf[0], - served_cells_item_p->served_Cell_Information.nRCGI.nRCellIdentity.buf[1], - served_cells_item_p->served_Cell_Information.nRCGI.nRCellIdentity.buf[2], - served_cells_item_p->served_Cell_Information.nRCGI.nRCellIdentity.buf[3], - served_cells_item_p->served_Cell_Information.nRCGI.nRCellIdentity.buf[4]); + req->cell[i].mcc, + req->cell[i].mnc, + (long long unsigned int)req->cell[i].nr_cellid); /* - nRPCI */ - F1AP_SETUP_REQ(message_p).nr_pci[i] = served_cells_item_p->served_Cell_Information.nRPCI; - LOG_D(F1AP, "F1AP_SETUP_REQ(message_p).nr_pci[%d] %d \n", - i, F1AP_SETUP_REQ(message_p).nr_pci[i]); - + req->cell[i].nr_pci = servedCellInformation->nRPCI; + LOG_D(F1AP, "req->nr_pci[%d] %d \n", i, req->cell[i].nr_pci); + + // LTS: FIXME data model failure: we don't KNOW if we receive a 4G or a 5G cell + // Furthermore, cell_type is not a attribute of a cell in the data structure !!!!!!!!!! + if (RC.nrrrc && RC.nrrrc[GNB_INSTANCE_TO_MODULE_ID(instance)]->node_type == ngran_gNB_CU) + f1ap_req(true, instance)->cell_type=CELL_MACRO_GNB; + else + f1ap_req(true, instance)->cell_type=CELL_MACRO_ENB; + + // FDD Cells + if (servedCellInformation->nR_Mode_Info.present==F1AP_NR_Mode_Info_PR_fDD) { + struct fdd_s *FDDs=&req->nr_mode_info[i].fdd; + F1AP_FDD_Info_t * fDD_Info=servedCellInformation->nR_Mode_Info.choice.fDD; + FDDs->ul_nr_arfcn=fDD_Info->uL_NRFreqInfo.nRARFCN; + FDDs->ul_num_frequency_bands=fDD_Info->uL_NRFreqInfo.freqBandListNr.list.count; + for (int f=0; f < fDD_Info->uL_NRFreqInfo.freqBandListNr.list.count; f++) { + F1AP_FreqBandNrItem_t * FreqItem=fDD_Info->uL_NRFreqInfo.freqBandListNr.list.array[f]; + FDDs->ul_nr_band[f]=FreqItem->freqBandIndicatorNr; + int num_available_supported_SULBands=FreqItem->supportedSULBandList.list.count; + for (int sul=0; sul < num_available_supported_SULBands; sul ++ ) { + F1AP_SupportedSULFreqBandItem_t * SulItem= FreqItem->supportedSULBandList.list.array[sul]; + FDDs->ul_nr_sul_band[sul]=SulItem->freqBandIndicatorNr; + } + } + FDDs->dl_nr_arfcn=fDD_Info->dL_NRFreqInfo.nRARFCN; + int dlBands=fDD_Info->dL_NRFreqInfo.freqBandListNr.list.count; + for (int dlB=0; dlB < dlBands; dlB++) { + F1AP_FreqBandNrItem_t * FreqItem=fDD_Info->dL_NRFreqInfo.freqBandListNr.list.array[dlB]; + FDDs->dl_nr_band[dlB]=FreqItem->freqBandIndicatorNr; + int num_available_supported_SULBands = FreqItem->supportedSULBandList.list.count; + for (int sul=0; sul < num_available_supported_SULBands; sul ++ ) { + F1AP_SupportedSULFreqBandItem_t * SulItem= FreqItem->supportedSULBandList.list.array[sul]; + FDDs->ul_nr_sul_band[sul]=SulItem->freqBandIndicatorNr; + } + } + FDDs->ul_scs=fDD_Info->uL_Transmission_Bandwidth.nRSCS; + FDDs->ul_nrb=nrb_lut[fDD_Info->uL_Transmission_Bandwidth.nRNRB]; + FDDs->dl_scs=fDD_Info->dL_Transmission_Bandwidth.nRSCS; + FDDs->dl_nrb=nrb_lut[fDD_Info->dL_Transmission_Bandwidth.nRNRB]; + } + + // TDD + if (servedCellInformation->nR_Mode_Info.present==F1AP_NR_Mode_Info_PR_tDD) { + struct tdd_s *TDDs=&req->nr_mode_info[i].tdd; + F1AP_TDD_Info_t * tDD_Info=servedCellInformation->nR_Mode_Info.choice.tDD; + TDDs->nr_arfcn=tDD_Info->nRFreqInfo.nRARFCN; + TDDs->num_frequency_bands=tDD_Info->nRFreqInfo.freqBandListNr.list.count; + for (int f=0; f < tDD_Info->nRFreqInfo.freqBandListNr.list.count; f++) { + struct F1AP_FreqBandNrItem * FreqItem=tDD_Info->nRFreqInfo.freqBandListNr.list.array[f]; + TDDs->nr_band[f]=FreqItem->freqBandIndicatorNr; + int num_available_supported_SULBands=FreqItem->supportedSULBandList.list.count; + for (int sul=0; sul < num_available_supported_SULBands; sul ++ ) { + struct F1AP_SupportedSULFreqBandItem * SulItem= FreqItem->supportedSULBandList.list.array[sul]; + TDDs->nr_sul_band[sul]=SulItem->freqBandIndicatorNr; + } + } + TDDs->scs=tDD_Info->transmission_Bandwidth.nRSCS; + TDDs->nrb=nrb_lut[tDD_Info->transmission_Bandwidth.nRNRB]; + } + + struct F1AP_GNB_DU_System_Information * DUsi=served_cells_item->gNB_DU_System_Information; + LOG_I(F1AP, "Received Cell in %d context\n", f1ap_req(true, instance)->cell_type==CELL_MACRO_GNB); // System Information /* mib */ - F1AP_SETUP_REQ(message_p).mib[i] = calloc(served_cells_item_p->gNB_DU_System_Information->mIB_message.size + 1, sizeof(char)); - memcpy(F1AP_SETUP_REQ(message_p).mib[i], served_cells_item_p->gNB_DU_System_Information->mIB_message.buf, - served_cells_item_p->gNB_DU_System_Information->mIB_message.size); + req->mib[i] = calloc(DUsi->mIB_message.size + 1, sizeof(char)); + memcpy(req->mib[i], DUsi->mIB_message.buf, DUsi->mIB_message.size); /* Convert the mme name to a printable string */ - F1AP_SETUP_REQ(message_p).mib[i][served_cells_item_p->gNB_DU_System_Information->mIB_message.size] = '\0'; - F1AP_SETUP_REQ(message_p).mib_length[i] = served_cells_item_p->gNB_DU_System_Information->mIB_message.size; - LOG_D(F1AP, "F1AP_SETUP_REQ(message_p).mib[%d] %s , len = %d \n", - i, F1AP_SETUP_REQ(message_p).mib[i], F1AP_SETUP_REQ(message_p).mib_length[i]); - + req->mib[i][DUsi->mIB_message.size] = '\0'; + req->mib_length[i] = DUsi->mIB_message.size; + LOG_D(F1AP, "req->mib[%d] len = %d \n", i, req->mib_length[i]); /* sib1 */ - F1AP_SETUP_REQ(message_p).sib1[i] = calloc(served_cells_item_p->gNB_DU_System_Information->sIB1_message.size + 1, sizeof(char)); - memcpy(F1AP_SETUP_REQ(message_p).sib1[i], served_cells_item_p->gNB_DU_System_Information->sIB1_message.buf, - served_cells_item_p->gNB_DU_System_Information->sIB1_message.size); + req->sib1[i] = calloc(DUsi->sIB1_message.size + 1, sizeof(char)); + memcpy(req->sib1[i], DUsi->sIB1_message.buf, DUsi->sIB1_message.size); /* Convert the mme name to a printable string */ - F1AP_SETUP_REQ(message_p).sib1[i][served_cells_item_p->gNB_DU_System_Information->sIB1_message.size] = '\0'; - F1AP_SETUP_REQ(message_p).sib1_length[i] = served_cells_item_p->gNB_DU_System_Information->sIB1_message.size; - LOG_D(F1AP, "F1AP_SETUP_REQ(message_p).sib1[%d] %s , len = %d \n", - i, F1AP_SETUP_REQ(message_p).sib1[i], F1AP_SETUP_REQ(message_p).sib1_length[i]); + req->sib1[i][DUsi->sIB1_message.size] = '\0'; + req->sib1_length[i] = DUsi->sIB1_message.size; + LOG_D(F1AP, "req->sib1[%d] len = %d \n", i, req->sib1_length[i]); } - - *f1ap_du_data_from_du = F1AP_SETUP_REQ(message_p); // char *measurement_timing_information[F1AP_MAX_NB_CELLS]; // uint8_t ranac[F1AP_MAX_NB_CELLS]; - // int fdd_flag = f1ap_setup_req->fdd_flag; - // union { // struct { // uint32_t ul_nr_arfcn; // uint8_t ul_scs; // uint8_t ul_nrb; - // uint32_t dl_nr_arfcn; // uint8_t dl_scs; // uint8_t dl_nrb; - // uint32_t sul_active; // uint32_t sul_nr_arfcn; // uint8_t sul_scs; // uint8_t sul_nrb; - // uint8_t num_frequency_bands; // uint16_t nr_band[32]; // uint8_t num_sul_frequency_bands; // uint16_t nr_sul_band[32]; // } fdd; // struct { - // uint32_t nr_arfcn; // uint8_t scs; // uint8_t nrb; - // uint32_t sul_active; // uint32_t sul_nr_arfcn; // uint8_t sul_scs; // uint8_t sul_nrb; - // uint8_t num_frequency_bands; // uint16_t nr_band[32]; // uint8_t num_sul_frequency_bands; // uint16_t nr_sul_band[32]; - // } tdd; // } nr_mode_info[F1AP_MAX_NB_CELLS]; - MSC_LOG_TX_MESSAGE( - MSC_F1AP_CU, - MSC_RRC_ENB, - 0, - 0, - MSC_AS_TIME_FMT" CU_handle_F1_SETUP_REQUEST", - 0,0//MSC_AS_TIME_ARGS(ctxt_pP), - ); - - if (num_cells_available > 0) { - if (RC.nrrrc && RC.nrrrc[0]->node_type == ngran_gNB_CU) { + + + // We copy and store in F1 task data, RRC will free "req" as it frees all itti received messages + message_p = itti_alloc_new_message(TASK_CU_F1, 0, F1AP_SETUP_REQ); + memcpy(&F1AP_SETUP_REQ(message_p), req, sizeof(f1ap_setup_req_t) ); + + if (req->num_cells_available > 0) { + if (f1ap_req(true, instance)->cell_type == CELL_MACRO_GNB) { itti_send_msg_to_task(TASK_RRC_GNB, GNB_MODULE_ID_TO_INSTANCE(instance), message_p); } else { itti_send_msg_to_task(TASK_RRC_ENB, ENB_MODULE_ID_TO_INSTANCE(instance), message_p); } } else { CU_send_F1_SETUP_FAILURE(instance); - if (RC.nrrrc && RC.nrrrc[0]->node_type == ngran_gNB_CU) { - itti_free(TASK_RRC_GNB,message_p); - } else { - itti_free(TASK_RRC_ENB,message_p); - } + itti_free(TASK_CU_F1,message_p); return -1; } + return 0; } int CU_send_F1_SETUP_RESPONSE(instance_t instance, - f1ap_setup_resp_t *f1ap_setup_resp) { - - module_id_t enb_mod_idP; - module_id_t cu_mod_idP; - + f1ap_setup_resp_t *f1ap_setup_resp) { + instance_t enb_mod_idP; + instance_t cu_mod_idP; // This should be fixed - enb_mod_idP = (module_id_t)0; - cu_mod_idP = (module_id_t)0; - - F1AP_F1AP_PDU_t pdu; - F1AP_F1SetupResponse_t *out; - F1AP_F1SetupResponseIEs_t *ie; - - uint8_t *buffer; - uint32_t len; - int i = 0; - + enb_mod_idP = (instance_t)0; + cu_mod_idP = (instance_t)0; + F1AP_F1AP_PDU_t pdu= {0}; + uint8_t *buffer=NULL; + uint32_t len=0; /* Create */ /* 0. Message Type */ - memset(&pdu, 0, sizeof(pdu)); pdu.present = F1AP_F1AP_PDU_PR_successfulOutcome; - pdu.choice.successfulOutcome = (F1AP_SuccessfulOutcome_t *)calloc(1, sizeof(F1AP_SuccessfulOutcome_t)); - pdu.choice.successfulOutcome->procedureCode = F1AP_ProcedureCode_id_F1Setup; - pdu.choice.successfulOutcome->criticality = F1AP_Criticality_reject; - pdu.choice.successfulOutcome->value.present = F1AP_SuccessfulOutcome__value_PR_F1SetupResponse; - out = &pdu.choice.successfulOutcome->value.choice.F1SetupResponse; - + asn1cCalloc(pdu.choice.successfulOutcome, tmp); + tmp->procedureCode = F1AP_ProcedureCode_id_F1Setup; + tmp->criticality = F1AP_Criticality_reject; + tmp->value.present = F1AP_SuccessfulOutcome__value_PR_F1SetupResponse; + F1AP_F1SetupResponse_t *out = &pdu.choice.successfulOutcome->value.choice.F1SetupResponse; /* mandatory */ /* c1. Transaction ID (integer value)*/ - ie = (F1AP_F1SetupResponseIEs_t *)calloc(1, sizeof(F1AP_F1SetupResponseIEs_t)); - ie->id = F1AP_ProtocolIE_ID_id_TransactionID; - ie->criticality = F1AP_Criticality_reject; - ie->value.present = F1AP_F1SetupResponseIEs__value_PR_TransactionID; - ie->value.choice.TransactionID = F1AP_get_next_transaction_identifier(enb_mod_idP, cu_mod_idP); - ASN_SEQUENCE_ADD(&out->protocolIEs.list, ie); - + asn1cSequenceAdd(out->protocolIEs.list, F1AP_F1SetupResponseIEs_t, ie1); + ie1->id = F1AP_ProtocolIE_ID_id_TransactionID; + ie1->criticality = F1AP_Criticality_reject; + ie1->value.present = F1AP_F1SetupResponseIEs__value_PR_TransactionID; + ie1->value.choice.TransactionID = F1AP_get_next_transaction_identifier(enb_mod_idP, cu_mod_idP); + /* optional */ /* c2. GNB_CU_Name */ if (f1ap_setup_resp->gNB_CU_name != NULL) { - ie = (F1AP_F1SetupResponseIEs_t *)calloc(1, sizeof(F1AP_F1SetupResponseIEs_t)); - ie->id = F1AP_ProtocolIE_ID_id_gNB_CU_Name; - ie->criticality = F1AP_Criticality_ignore; - ie->value.present = F1AP_F1SetupResponseIEs__value_PR_GNB_CU_Name; - OCTET_STRING_fromBuf(&ie->value.choice.GNB_CU_Name, f1ap_setup_resp->gNB_CU_name, + asn1cSequenceAdd(out->protocolIEs.list, F1AP_F1SetupResponseIEs_t, ie2); + ie2->id = F1AP_ProtocolIE_ID_id_gNB_CU_Name; + ie2->criticality = F1AP_Criticality_ignore; + ie2->value.present = F1AP_F1SetupResponseIEs__value_PR_GNB_CU_Name; + OCTET_STRING_fromBuf(&ie2->value.choice.GNB_CU_Name, f1ap_setup_resp->gNB_CU_name, strlen(f1ap_setup_resp->gNB_CU_name)); - ASN_SEQUENCE_ADD(&out->protocolIEs.list, ie); } /* mandatory */ /* c3. cells to be Activated list */ int num_cells_to_activate = f1ap_setup_resp->num_cells_to_activate; LOG_D(F1AP, "num_cells_to_activate = %d \n", num_cells_to_activate); - if (num_cells_to_activate >0) { - ie = (F1AP_F1SetupResponseIEs_t *)calloc(1, sizeof(F1AP_F1SetupResponseIEs_t)); - ie->id = F1AP_ProtocolIE_ID_id_Cells_to_be_Activated_List; - ie->criticality = F1AP_Criticality_reject; - ie->value.present = F1AP_F1SetupResponseIEs__value_PR_Cells_to_be_Activated_List; - - for (i=0; i<num_cells_to_activate; i++) { - - LOG_D(F1AP, "[c3] (cell %d) mcc = %d, mnc = %d, mnc_digit_length = %d, nr_cellid = %lu\n", - i, - f1ap_setup_resp->cells_to_activate[i].mcc, - f1ap_setup_resp->cells_to_activate[i].mnc, - f1ap_setup_resp->cells_to_activate[i].mnc_digit_length, - f1ap_setup_resp->cells_to_activate[i].nr_cellid); - - F1AP_Cells_to_be_Activated_List_ItemIEs_t *cells_to_be_activated_list_item_ies; - cells_to_be_activated_list_item_ies = (F1AP_Cells_to_be_Activated_List_ItemIEs_t *)calloc(1, sizeof(F1AP_Cells_to_be_Activated_List_ItemIEs_t)); - cells_to_be_activated_list_item_ies->id = F1AP_ProtocolIE_ID_id_Cells_to_be_Activated_List_Item; - cells_to_be_activated_list_item_ies->criticality = F1AP_Criticality_reject; - cells_to_be_activated_list_item_ies->value.present = F1AP_Cells_to_be_Activated_List_ItemIEs__value_PR_Cells_to_be_Activated_List_Item; + if (num_cells_to_activate >0) { + asn1cSequenceAdd(out->protocolIEs.list, F1AP_F1SetupResponseIEs_t, ie3); + ie3->id = F1AP_ProtocolIE_ID_id_Cells_to_be_Activated_List; + ie3->criticality = F1AP_Criticality_reject; + ie3->value.present = F1AP_F1SetupResponseIEs__value_PR_Cells_to_be_Activated_List; + + for (int i=0; i<num_cells_to_activate; i++) { + asn1cSequenceAdd(ie3->value.choice.Cells_to_be_Activated_List.list, + F1AP_Cells_to_be_Activated_List_ItemIEs_t, cells_to_be_activated_ies); + cells_to_be_activated_ies->id = F1AP_ProtocolIE_ID_id_Cells_to_be_Activated_List_Item; + cells_to_be_activated_ies->criticality = F1AP_Criticality_reject; + cells_to_be_activated_ies->value.present = F1AP_Cells_to_be_Activated_List_ItemIEs__value_PR_Cells_to_be_Activated_List_Item; /* 3.1 cells to be Activated list item */ - F1AP_Cells_to_be_Activated_List_Item_t cells_to_be_activated_list_item; - memset((void *)&cells_to_be_activated_list_item, 0, sizeof(F1AP_Cells_to_be_Activated_List_Item_t)); - + F1AP_Cells_to_be_Activated_List_Item_t *cells_to_be_activated_item= + &cells_to_be_activated_ies->value.choice.Cells_to_be_Activated_List_Item; /* - nRCGI */ - F1AP_NRCGI_t nRCGI; - memset(&nRCGI, 0, sizeof(F1AP_NRCGI_t)); - MCC_MNC_TO_PLMNID(f1ap_setup_resp->cells_to_activate[i].mcc, f1ap_setup_resp->cells_to_activate[i].mnc, f1ap_setup_resp->cells_to_activate[i].mnc_digit_length, - &nRCGI.pLMN_Identity); - NR_CELL_ID_TO_BIT_STRING(f1ap_setup_resp->cells_to_activate[i].nr_cellid, &nRCGI.nRCellIdentity); - cells_to_be_activated_list_item.nRCGI = nRCGI; + addnRCGI(cells_to_be_activated_item->nRCGI, f1ap_setup_resp->cells_to_activate+i); /* optional */ /* - nRPCI */ if (1) { - cells_to_be_activated_list_item.nRPCI = (F1AP_NRPCI_t *)calloc(1, sizeof(F1AP_NRPCI_t)); - *cells_to_be_activated_list_item.nRPCI = f1ap_setup_resp->cells_to_activate[i].nrpci; // int 0..1007 + cells_to_be_activated_item->nRPCI = (F1AP_NRPCI_t *)calloc(1, sizeof(F1AP_NRPCI_t)); + *cells_to_be_activated_item->nRPCI = f1ap_setup_resp->cells_to_activate[i].nrpci; // int 0..1007 } /* optional */ /* - gNB-CU System Information */ if (1) { - /* 3.1.2 gNB-CUSystem Information */ - F1AP_Cells_to_be_Activated_List_ItemExtIEs_t *cells_to_be_activated_list_itemExtIEs; - cells_to_be_activated_list_itemExtIEs = (F1AP_Cells_to_be_Activated_List_ItemExtIEs_t *)calloc(1, sizeof(F1AP_Cells_to_be_Activated_List_ItemExtIEs_t)); - cells_to_be_activated_list_itemExtIEs->id = F1AP_ProtocolIE_ID_id_gNB_CUSystemInformation; - cells_to_be_activated_list_itemExtIEs->criticality = F1AP_Criticality_reject; - cells_to_be_activated_list_itemExtIEs->extensionValue.present = F1AP_Cells_to_be_Activated_List_ItemExtIEs__extensionValue_PR_GNB_CUSystemInformation; - - F1AP_GNB_CUSystemInformation_t *gNB_CUSystemInformation = (F1AP_GNB_CUSystemInformation_t *)calloc(1, sizeof(F1AP_GNB_CUSystemInformation_t)); - //LOG_I(F1AP, "%s() SI %d size %d: ", __func__, i, f1ap_setup_resp->SI_container_length[i][0]); - //for (int n = 0; n < f1ap_setup_resp->SI_container_length[i][0]; n++) - // printf("%02x ", f1ap_setup_resp->SI_container[i][0][n]); - //printf("\n"); - - // for (int sIBtype=2;sIBtype<33;sIBtype++) { //21 ? 33 ? - for (int sIBtype=2;sIBtype<21;sIBtype++) { - if (f1ap_setup_resp->cells_to_activate[i].SI_container[sIBtype]!=NULL) { - AssertFatal(sIBtype < 6 || sIBtype == 9, "Illegal SI type %d\n",sIBtype); - F1AP_SibtypetobeupdatedListItem_t *sib_item = calloc(1,sizeof(*sib_item)); - memset((void*)sib_item,0,sizeof(*sib_item)); - sib_item->sIBtype = sIBtype; - OCTET_STRING_fromBuf(&sib_item->sIBmessage, - (const char*)f1ap_setup_resp->cells_to_activate[i].SI_container[sIBtype], - f1ap_setup_resp->cells_to_activate[i].SI_container_length[sIBtype]); - - LOG_D(F1AP, "f1ap_setup_resp->SI_container_length[%d][%d] = %d \n", i,sIBtype,f1ap_setup_resp->cells_to_activate[i].SI_container_length[sIBtype]); - ASN_SEQUENCE_ADD(&gNB_CUSystemInformation->sibtypetobeupdatedlist.list,sib_item); + /* 3.1.2 gNB-CUSystem Information */ + F1AP_ProtocolExtensionContainer_154P112_t *p_154P112=calloc(1, sizeof(* p_154P112)); + cells_to_be_activated_item->iE_Extensions = (struct F1AP_ProtocolExtensionContainer *)p_154P112; + asn1cSequenceAdd(p_154P112->list, F1AP_Cells_to_be_Activated_List_ItemExtIEs_t, cells_to_be_activated_itemExtIEs); + cells_to_be_activated_itemExtIEs->id = F1AP_ProtocolIE_ID_id_gNB_CUSystemInformation; + cells_to_be_activated_itemExtIEs->criticality = F1AP_Criticality_reject; + cells_to_be_activated_itemExtIEs->extensionValue.present = F1AP_Cells_to_be_Activated_List_ItemExtIEs__extensionValue_PR_GNB_CUSystemInformation; + F1AP_GNB_CUSystemInformation_t *gNB_CUSystemInformation = + &cells_to_be_activated_itemExtIEs->extensionValue.choice.GNB_CUSystemInformation; + + // for (int sIBtype=2;sIBtype<33;sIBtype++) { //21 ? 33 ? + for (int sIBtype=2; sIBtype<21; sIBtype++) { + if (f1ap_setup_resp->cells_to_activate[i].SI_container[sIBtype]!=NULL) { + AssertFatal(sIBtype < 6 || sIBtype == 9, "Illegal SI type %d\n",sIBtype); + asn1cSequenceAdd(gNB_CUSystemInformation->sibtypetobeupdatedlist.list, F1AP_SibtypetobeupdatedListItem_t, sib_item); + sib_item->sIBtype = sIBtype; + OCTET_STRING_fromBuf(&sib_item->sIBmessage, + (const char *)f1ap_setup_resp->cells_to_activate[i].SI_container[sIBtype], + f1ap_setup_resp->cells_to_activate[i].SI_container_length[sIBtype]); + LOG_D(F1AP, "f1ap_setup_resp->SI_container_length[%d][%d] = %d \n", i,sIBtype,f1ap_setup_resp->cells_to_activate[i].SI_container_length[sIBtype]); + } } } - cells_to_be_activated_list_itemExtIEs->extensionValue.choice.GNB_CUSystemInformation = *gNB_CUSystemInformation; - - F1AP_ProtocolExtensionContainer_154P112_t p_154P112_t; - memset((void *)&p_154P112_t, 0, sizeof(F1AP_ProtocolExtensionContainer_154P112_t)); - - ASN_SEQUENCE_ADD(&p_154P112_t.list, cells_to_be_activated_list_itemExtIEs); - cells_to_be_activated_list_item.iE_Extensions = (struct F1AP_ProtocolExtensionContainer*)&p_154P112_t; - - free(gNB_CUSystemInformation); - gNB_CUSystemInformation = NULL; - } - /* ADD */ - cells_to_be_activated_list_item_ies->value.choice.Cells_to_be_Activated_List_Item = cells_to_be_activated_list_item; - ASN_SEQUENCE_ADD(&ie->value.choice.Cells_to_be_Activated_List.list, cells_to_be_activated_list_item_ies); } - ASN_SEQUENCE_ADD(&out->protocolIEs.list, ie); } /* encode */ @@ -415,84 +377,68 @@ int CU_send_F1_SETUP_RESPONSE(instance_t instance, return -1; } - cu_f1ap_itti_send_sctp_data_req(instance, f1ap_du_data_from_du->assoc_id, buffer, len, 0); - + ASN_STRUCT_RESET(asn_DEF_F1AP_F1AP_PDU, &pdu); + f1ap_itti_send_sctp_data_req(true, instance, buffer, len, 0); return 0; } int CU_send_F1_SETUP_FAILURE(instance_t instance) { LOG_D(F1AP, "CU_send_F1_SETUP_FAILURE\n"); - - module_id_t enb_mod_idP; - module_id_t cu_mod_idP; - + instance_t enb_mod_idP=0; + instance_t cu_mod_idP=0; // This should be fixed - enb_mod_idP = (module_id_t)0; - cu_mod_idP = (module_id_t)0; - - F1AP_F1AP_PDU_t pdu; - F1AP_F1SetupFailure_t *out; - F1AP_F1SetupFailureIEs_t *ie; - - uint8_t *buffer; - uint32_t len; - + F1AP_F1AP_PDU_t pdu= {0}; + uint8_t *buffer=NULL; + uint32_t len=0; /* Create */ /* 0. Message Type */ - memset(&pdu, 0, sizeof(pdu)); + asn1cCalloc(pdu.choice.unsuccessfulOutcome, UnsuccessfulOutcome); pdu.present = F1AP_F1AP_PDU_PR_unsuccessfulOutcome; - pdu.choice.unsuccessfulOutcome = (F1AP_UnsuccessfulOutcome_t *)calloc(1, sizeof(F1AP_UnsuccessfulOutcome_t)); - pdu.choice.unsuccessfulOutcome->procedureCode = F1AP_ProcedureCode_id_F1Setup; - pdu.choice.unsuccessfulOutcome->criticality = F1AP_Criticality_reject; - pdu.choice.unsuccessfulOutcome->value.present = F1AP_UnsuccessfulOutcome__value_PR_F1SetupFailure; - out = &pdu.choice.unsuccessfulOutcome->value.choice.F1SetupFailure; - + UnsuccessfulOutcome->procedureCode = F1AP_ProcedureCode_id_F1Setup; + UnsuccessfulOutcome->criticality = F1AP_Criticality_reject; + UnsuccessfulOutcome->value.present = F1AP_UnsuccessfulOutcome__value_PR_F1SetupFailure; + F1AP_F1SetupFailure_t *out = &pdu.choice.unsuccessfulOutcome->value.choice.F1SetupFailure; /* mandatory */ /* c1. Transaction ID (integer value)*/ - ie = (F1AP_F1SetupFailureIEs_t *)calloc(1, sizeof(F1AP_F1SetupFailureIEs_t)); - ie->id = F1AP_ProtocolIE_ID_id_TransactionID; - ie->criticality = F1AP_Criticality_reject; - ie->value.present = F1AP_F1SetupFailureIEs__value_PR_TransactionID; - ie->value.choice.TransactionID = F1AP_get_next_transaction_identifier(enb_mod_idP, cu_mod_idP); - ASN_SEQUENCE_ADD(&out->protocolIEs.list, ie); - + asn1cSequenceAdd(out->protocolIEs.list, F1AP_F1SetupFailureIEs_t, ie1); + ie1->id = F1AP_ProtocolIE_ID_id_TransactionID; + ie1->criticality = F1AP_Criticality_reject; + ie1->value.present = F1AP_F1SetupFailureIEs__value_PR_TransactionID; + ie1->value.choice.TransactionID = F1AP_get_next_transaction_identifier(enb_mod_idP, cu_mod_idP); /* mandatory */ /* c2. Cause */ - ie = (F1AP_F1SetupFailureIEs_t *)calloc(1, sizeof(F1AP_F1SetupFailureIEs_t)); - ie->id = F1AP_ProtocolIE_ID_id_Cause; - ie->criticality = F1AP_Criticality_ignore; - ie->value.present = F1AP_F1SetupFailureIEs__value_PR_Cause; - ie->value.choice.Cause.present = F1AP_Cause_PR_radioNetwork; - ie->value.choice.Cause.choice.radioNetwork = F1AP_CauseRadioNetwork_unspecified; - ASN_SEQUENCE_ADD(&out->protocolIEs.list, ie); + asn1cSequenceAdd(out->protocolIEs.list, F1AP_F1SetupFailureIEs_t, ie2); + ie2->id = F1AP_ProtocolIE_ID_id_Cause; + ie2->criticality = F1AP_Criticality_ignore; + ie2->value.present = F1AP_F1SetupFailureIEs__value_PR_Cause; + ie2->value.choice.Cause.present = F1AP_Cause_PR_radioNetwork; + ie2->value.choice.Cause.choice.radioNetwork = F1AP_CauseRadioNetwork_unspecified; /* optional */ /* c3. TimeToWait */ if (0) { - ie = (F1AP_F1SetupFailureIEs_t *)calloc(1, sizeof(F1AP_F1SetupFailureIEs_t)); - ie->id = F1AP_ProtocolIE_ID_id_TimeToWait; - ie->criticality = F1AP_Criticality_ignore; - ie->value.present = F1AP_F1SetupFailureIEs__value_PR_TimeToWait; - ie->value.choice.TimeToWait = F1AP_TimeToWait_v10s; - ASN_SEQUENCE_ADD(&out->protocolIEs.list, ie); + asn1cSequenceAdd(out->protocolIEs.list, F1AP_F1SetupFailureIEs_t, ie3); + ie3->id = F1AP_ProtocolIE_ID_id_TimeToWait; + ie3->criticality = F1AP_Criticality_ignore; + ie3->value.present = F1AP_F1SetupFailureIEs__value_PR_TimeToWait; + ie3->value.choice.TimeToWait = F1AP_TimeToWait_v10s; } /* optional */ /* c4. CriticalityDiagnostics*/ if (0) { - ie = (F1AP_F1SetupFailureIEs_t *)calloc(1, sizeof(F1AP_F1SetupFailureIEs_t)); - ie->id = F1AP_ProtocolIE_ID_id_CriticalityDiagnostics; - ie->criticality = F1AP_Criticality_ignore; - ie->value.present = F1AP_F1SetupFailureIEs__value_PR_CriticalityDiagnostics; - ie->value.choice.CriticalityDiagnostics.procedureCode = (F1AP_ProcedureCode_t *)calloc(1, sizeof(F1AP_ProcedureCode_t)); - *ie->value.choice.CriticalityDiagnostics.procedureCode = F1AP_ProcedureCode_id_UEContextSetup; - ie->value.choice.CriticalityDiagnostics.triggeringMessage = (F1AP_TriggeringMessage_t *)calloc(1, sizeof(F1AP_TriggeringMessage_t)); - *ie->value.choice.CriticalityDiagnostics.triggeringMessage = F1AP_TriggeringMessage_initiating_message; - ie->value.choice.CriticalityDiagnostics.procedureCriticality = (F1AP_Criticality_t *)calloc(1, sizeof(F1AP_Criticality_t)); - *ie->value.choice.CriticalityDiagnostics.procedureCriticality = F1AP_Criticality_reject; - ie->value.choice.CriticalityDiagnostics.transactionID = (F1AP_TransactionID_t *)calloc(1, sizeof(F1AP_TransactionID_t)); - *ie->value.choice.CriticalityDiagnostics.transactionID = 0; - ASN_SEQUENCE_ADD(&out->protocolIEs.list, ie); + asn1cSequenceAdd(out->protocolIEs.list, F1AP_F1SetupFailureIEs_t, ie4); + ie4->id = F1AP_ProtocolIE_ID_id_CriticalityDiagnostics; + ie4->criticality = F1AP_Criticality_ignore; + ie4->value.present = F1AP_F1SetupFailureIEs__value_PR_CriticalityDiagnostics; + asn1cCallocOne(ie4->value.choice.CriticalityDiagnostics.procedureCode, + F1AP_ProcedureCode_id_UEContextSetup); + asn1cCallocOne(ie4->value.choice.CriticalityDiagnostics.triggeringMessage, + F1AP_TriggeringMessage_initiating_message); + asn1cCallocOne(ie4->value.choice.CriticalityDiagnostics.procedureCriticality, + F1AP_Criticality_reject); + asn1cCallocOne(ie4->value.choice.CriticalityDiagnostics.transactionID, + 0); } /* encode */ @@ -501,451 +447,306 @@ int CU_send_F1_SETUP_FAILURE(instance_t instance) { return -1; } - cu_f1ap_itti_send_sctp_data_req(instance, f1ap_du_data_from_du->assoc_id, buffer, len, 0); - + ASN_STRUCT_RESET(asn_DEF_F1AP_F1AP_PDU, &pdu); + f1ap_itti_send_sctp_data_req(true,instance, buffer, len, 0); return 0; } - - /* gNB-DU Configuration Update */ int CU_handle_gNB_DU_CONFIGURATION_UPDATE(instance_t instance, - uint32_t assoc_id, - uint32_t stream, - F1AP_F1AP_PDU_t *pdu) { + uint32_t assoc_id, + uint32_t stream, + F1AP_F1AP_PDU_t *pdu) { AssertFatal(1==0,"Not implemented yet\n"); } int CU_send_gNB_DU_CONFIGURATION_FAILURE(instance_t instance, - F1AP_GNBDUConfigurationUpdateFailure_t *GNBDUConfigurationUpdateFailure) { + F1AP_GNBDUConfigurationUpdateFailure_t *GNBDUConfigurationUpdateFailure) { AssertFatal(1==0,"Not implemented yet\n"); } int CU_send_gNB_DU_CONFIGURATION_UPDATE_ACKNOWLEDGE(instance_t instance, - F1AP_GNBDUConfigurationUpdateAcknowledge_t *GNBDUConfigurationUpdateAcknowledge) { + F1AP_GNBDUConfigurationUpdateAcknowledge_t *GNBDUConfigurationUpdateAcknowledge) { AssertFatal(1==0,"Not implemented yet\n"); } - - /* gNB-CU Configuration Update */ //void CU_send_gNB_CU_CONFIGURATION_UPDATE(F1AP_GNBCUConfigurationUpdate_t *GNBCUConfigurationUpdate) { int CU_send_gNB_CU_CONFIGURATION_UPDATE(instance_t instance, f1ap_gnb_cu_configuration_update_t *f1ap_gnb_cu_configuration_update) { - F1AP_F1AP_PDU_t pdu; - F1AP_GNBCUConfigurationUpdate_t *out; - F1AP_GNBCUConfigurationUpdateIEs_t *ie; - + F1AP_F1AP_PDU_t pdu= {0}; uint8_t *buffer; uint32_t len; - int i = 0; - - /* Create */ /* 0. Message Type */ - memset(&pdu, 0, sizeof(pdu)); pdu.present = F1AP_F1AP_PDU_PR_initiatingMessage; - pdu.choice.initiatingMessage = (F1AP_InitiatingMessage_t *)calloc(1, sizeof(F1AP_InitiatingMessage_t)); - pdu.choice.initiatingMessage->procedureCode = F1AP_ProcedureCode_id_gNBCUConfigurationUpdate; - pdu.choice.initiatingMessage->criticality = F1AP_Criticality_ignore; - pdu.choice.initiatingMessage->value.present = F1AP_InitiatingMessage__value_PR_GNBCUConfigurationUpdate; - out = &pdu.choice.initiatingMessage->value.choice.GNBCUConfigurationUpdate; - + asn1cCalloc(pdu.choice.initiatingMessage, initMsg); + initMsg->procedureCode = F1AP_ProcedureCode_id_gNBCUConfigurationUpdate; + initMsg->criticality = F1AP_Criticality_reject; + initMsg->value.present = F1AP_InitiatingMessage__value_PR_GNBCUConfigurationUpdate; + F1AP_GNBCUConfigurationUpdate_t *cfgUpdate = &pdu.choice.initiatingMessage->value.choice.GNBCUConfigurationUpdate; /* mandatory */ /* c1. Transaction ID (integer value) */ - ie = (F1AP_GNBCUConfigurationUpdateIEs_t *)calloc(1, sizeof(F1AP_GNBCUConfigurationUpdateIEs_t)); - ie->id = F1AP_ProtocolIE_ID_id_TransactionID; - ie->criticality = F1AP_Criticality_reject; - ie->value.present = F1AP_GNBCUConfigurationUpdateIEs__value_PR_TransactionID; - ie->value.choice.TransactionID = F1AP_get_next_transaction_identifier(instance, 0); - ASN_SEQUENCE_ADD(&out->protocolIEs.list, ie); - - + asn1cSequenceAdd(cfgUpdate->protocolIEs.list, F1AP_GNBCUConfigurationUpdateIEs_t, ieC1); + ieC1->id = F1AP_ProtocolIE_ID_id_TransactionID; + ieC1->criticality = F1AP_Criticality_reject; + ieC1->value.present = F1AP_GNBCUConfigurationUpdateIEs__value_PR_TransactionID; + ieC1->value.choice.TransactionID = F1AP_get_next_transaction_identifier(instance, 0); // mandatory // c2. Cells_to_be_Activated_List if (f1ap_gnb_cu_configuration_update->num_cells_to_activate > 0) { - ie = (F1AP_GNBCUConfigurationUpdateIEs_t *)calloc(1, sizeof(F1AP_GNBCUConfigurationUpdateIEs_t)); - ie->id = F1AP_ProtocolIE_ID_id_Cells_to_be_Activated_List; - ie->criticality = F1AP_Criticality_reject; - ie->value.present = F1AP_GNBCUConfigurationUpdateIEs__value_PR_Cells_to_be_Activated_List; - - for (i=0; i<f1ap_gnb_cu_configuration_update->num_cells_to_activate; i++) { - - LOG_D(F1AP, "[c2] (cell %d) mcc = %d, mnc = %d, mnc_digit_length = %d, nr_cellid = %lu\n", - i, - f1ap_gnb_cu_configuration_update->cells_to_activate[i].mcc, - f1ap_gnb_cu_configuration_update->cells_to_activate[i].mnc, - f1ap_gnb_cu_configuration_update->cells_to_activate[i].mnc_digit_length, - f1ap_gnb_cu_configuration_update->cells_to_activate[i].nr_cellid); - - F1AP_Cells_to_be_Activated_List_ItemIEs_t *cells_to_be_activated_list_item_ies; - cells_to_be_activated_list_item_ies = (F1AP_Cells_to_be_Activated_List_ItemIEs_t *)calloc(1, sizeof(F1AP_Cells_to_be_Activated_List_ItemIEs_t)); - cells_to_be_activated_list_item_ies->id = F1AP_ProtocolIE_ID_id_Cells_to_be_Activated_List_Item; - cells_to_be_activated_list_item_ies->criticality = F1AP_Criticality_reject; - cells_to_be_activated_list_item_ies->value.present = F1AP_Cells_to_be_Activated_List_ItemIEs__value_PR_Cells_to_be_Activated_List_Item; - + asn1cSequenceAdd(cfgUpdate->protocolIEs.list, F1AP_GNBCUConfigurationUpdateIEs_t, ieC3); + ieC3->id = F1AP_ProtocolIE_ID_id_Cells_to_be_Activated_List; + ieC3->criticality = F1AP_Criticality_reject; + ieC3->value.present = F1AP_GNBCUConfigurationUpdateIEs__value_PR_Cells_to_be_Activated_List; + + for (int i=0; i<f1ap_gnb_cu_configuration_update->num_cells_to_activate; i++) { + asn1cSequenceAdd(ieC3->value.choice.Cells_to_be_Activated_List.list,F1AP_Cells_to_be_Activated_List_ItemIEs_t, + cells_to_be_activated_ies); + cells_to_be_activated_ies->id = F1AP_ProtocolIE_ID_id_Cells_to_be_Activated_List_Item; + cells_to_be_activated_ies->criticality = F1AP_Criticality_reject; + cells_to_be_activated_ies->value.present = F1AP_Cells_to_be_Activated_List_ItemIEs__value_PR_Cells_to_be_Activated_List_Item; // 2.1 cells to be Activated list item - F1AP_Cells_to_be_Activated_List_Item_t cells_to_be_activated_list_item; - memset((void *)&cells_to_be_activated_list_item, 0, sizeof(F1AP_Cells_to_be_Activated_List_Item_t)); - + F1AP_Cells_to_be_Activated_List_Item_t *cells_to_be_activated_list_item= + &cells_to_be_activated_ies->value.choice.Cells_to_be_Activated_List_Item; // - nRCGI - F1AP_NRCGI_t nRCGI; - memset(&nRCGI, 0, sizeof(F1AP_NRCGI_t)); - MCC_MNC_TO_PLMNID(f1ap_gnb_cu_configuration_update->cells_to_activate[i].mcc, - f1ap_gnb_cu_configuration_update->cells_to_activate[i].mnc, - f1ap_gnb_cu_configuration_update->cells_to_activate[i].mnc_digit_length, - &nRCGI.pLMN_Identity); - NR_CELL_ID_TO_BIT_STRING(f1ap_gnb_cu_configuration_update->cells_to_activate[i].nr_cellid, - &nRCGI.nRCellIdentity); - cells_to_be_activated_list_item.nRCGI = nRCGI; - - if(RC.nrrrc) { - - // optional - // -nRPCI - cells_to_be_activated_list_item.nRPCI = (F1AP_NRPCI_t *)calloc(1, sizeof(F1AP_NRPCI_t)); - *cells_to_be_activated_list_item.nRPCI = f1ap_gnb_cu_configuration_update->cells_to_activate[i].nrpci; // int 0..1007 - - // optional - // 3.1.2 gNB-CUSystem Information - F1AP_Cells_to_be_Activated_List_ItemExtIEs_t *cells_to_be_activated_list_itemExtIEs; - cells_to_be_activated_list_itemExtIEs = (F1AP_Cells_to_be_Activated_List_ItemExtIEs_t *)calloc(1, sizeof(F1AP_Cells_to_be_Activated_List_ItemExtIEs_t)); - cells_to_be_activated_list_itemExtIEs->id = F1AP_ProtocolIE_ID_id_gNB_CUSystemInformation; - cells_to_be_activated_list_itemExtIEs->criticality = F1AP_Criticality_reject; - cells_to_be_activated_list_itemExtIEs->extensionValue.present = F1AP_Cells_to_be_Activated_List_ItemExtIEs__extensionValue_PR_GNB_CUSystemInformation; - - if (f1ap_gnb_cu_configuration_update->cells_to_activate[i].num_SI > 0) { - F1AP_GNB_CUSystemInformation_t *gNB_CUSystemInformation = (F1AP_GNB_CUSystemInformation_t *)calloc(1, sizeof(F1AP_GNB_CUSystemInformation_t)); - //LOG_I(F1AP, "%s() SI %d size %d: ", __func__, i, f1ap_setup_resp->SI_container_length[i][0]); - //for (int n = 0; n < f1ap_setup_resp->SI_container_length[i][0]; n++) - // printf("%02x ", f1ap_setup_resp->SI_container[i][0][n]); - //printf("\n"); - - // for (int sIBtype=2;sIBtype<33;sIBtype++) { //21 ? 33 ? - for (int sIBtype=2;sIBtype<21;sIBtype++) { - if (f1ap_gnb_cu_configuration_update->cells_to_activate[i].SI_container[sIBtype]!=NULL) { - AssertFatal(sIBtype < 6 || sIBtype == 9, "Illegal SI type %d\n",sIBtype); - F1AP_SibtypetobeupdatedListItem_t *sib_item = calloc(1,sizeof(*sib_item)); - memset((void*)sib_item,0,sizeof(*sib_item)); - sib_item->sIBtype = sIBtype; - OCTET_STRING_fromBuf(&sib_item->sIBmessage, - (const char*)f1ap_gnb_cu_configuration_update->cells_to_activate[i].SI_container[sIBtype], - f1ap_gnb_cu_configuration_update->cells_to_activate[i].SI_container_length[sIBtype]); - - LOG_D(F1AP, "f1ap_setup_resp->SI_container_length[%d][%d] = %d \n", i,sIBtype,f1ap_gnb_cu_configuration_update->cells_to_activate[i].SI_container_length[sIBtype]); - ASN_SEQUENCE_ADD(&gNB_CUSystemInformation->sibtypetobeupdatedlist.list,sib_item); - } + addnRCGI(cells_to_be_activated_list_item->nRCGI, f1ap_gnb_cu_configuration_update->cells_to_activate+i); + // optional + // -nRPCI + asn1cCalloc(cells_to_be_activated_list_item->nRPCI, tmp); + *tmp = f1ap_gnb_cu_configuration_update->cells_to_activate[i].nrpci; // int 0..1007 + // optional + // 3.1.2 gNB-CUSystem Information + F1AP_ProtocolExtensionContainer_154P112_t *p_154P112=(F1AP_ProtocolExtensionContainer_154P112_t *) calloc(1,sizeof(*p_154P112)); + cells_to_be_activated_list_item->iE_Extensions = (struct F1AP_ProtocolExtensionContainer *)p_154P112; + //F1AP_ProtocolExtensionContainer_154P112_t + asn1cSequenceAdd(p_154P112->list,F1AP_Cells_to_be_Activated_List_ItemExtIEs_t, cells_to_be_activated_itemExtIEs); + cells_to_be_activated_itemExtIEs->id = F1AP_ProtocolIE_ID_id_gNB_CUSystemInformation; + cells_to_be_activated_itemExtIEs->criticality = F1AP_Criticality_reject; + cells_to_be_activated_itemExtIEs->extensionValue.present = F1AP_Cells_to_be_Activated_List_ItemExtIEs__extensionValue_PR_GNB_CUSystemInformation; + + if (f1ap_gnb_cu_configuration_update->cells_to_activate[i].num_SI > 0) { + F1AP_GNB_CUSystemInformation_t *gNB_CUSystemInformation = + &cells_to_be_activated_itemExtIEs->extensionValue.choice.GNB_CUSystemInformation; + //LOG_I(F1AP, "%s() SI %d size %d: ", __func__, i, f1ap_setup_resp->SI_container_length[i][0]); + //for (int n = 0; n < f1ap_setup_resp->SI_container_length[i][0]; n++) + // printf("%02x ", f1ap_setup_resp->SI_container[i][0][n]); + //printf("\n"); + + // for (int sIBtype=2;sIBtype<33;sIBtype++) { //21 ? 33 ? + for (int sIBtype=2; sIBtype<21; sIBtype++) { + if (f1ap_gnb_cu_configuration_update->cells_to_activate[i].SI_container[sIBtype]!=NULL) { + AssertFatal(sIBtype < 6 || sIBtype == 9, "Illegal SI type %d\n",sIBtype); + asn1cSequenceAdd(gNB_CUSystemInformation->sibtypetobeupdatedlist.list, F1AP_SibtypetobeupdatedListItem_t, sib_item); + sib_item->sIBtype = sIBtype; + OCTET_STRING_fromBuf(&sib_item->sIBmessage, + (const char *)f1ap_gnb_cu_configuration_update->cells_to_activate[i].SI_container[sIBtype], + f1ap_gnb_cu_configuration_update->cells_to_activate[i].SI_container_length[sIBtype]); + LOG_D(F1AP, "f1ap_setup_resp->SI_container_length[%d][%d] = %d \n", i,sIBtype, + f1ap_gnb_cu_configuration_update->cells_to_activate[i].SI_container_length[sIBtype]); } - cells_to_be_activated_list_itemExtIEs->extensionValue.choice.GNB_CUSystemInformation = *gNB_CUSystemInformation; - - - F1AP_ProtocolExtensionContainer_154P112_t p_154P112_t; - memset((void *)&p_154P112_t, 0, sizeof(F1AP_ProtocolExtensionContainer_154P112_t)); - - ASN_SEQUENCE_ADD(&p_154P112_t.list, - cells_to_be_activated_list_itemExtIEs); - cells_to_be_activated_list_item.iE_Extensions = (struct F1AP_ProtocolExtensionContainer*)&p_154P112_t; - - free(gNB_CUSystemInformation); - gNB_CUSystemInformation = NULL; } } - - // ADD - cells_to_be_activated_list_item_ies->value.choice.Cells_to_be_Activated_List_Item = cells_to_be_activated_list_item; - ASN_SEQUENCE_ADD(&ie->value.choice.Cells_to_be_Activated_List.list, - cells_to_be_activated_list_item_ies); } - ASN_SEQUENCE_ADD(&out->protocolIEs.list, ie); - } - + // c3. Cells_to_be_Deactivated_List + // + /* if(!RC.nrrrc) { - - /* mandatory */ - /* c3. Cells_to_be_Deactivated_List */ - ie = (F1AP_GNBCUConfigurationUpdateIEs_t *)calloc(1, sizeof(F1AP_GNBCUConfigurationUpdateIEs_t)); - ie->id = F1AP_ProtocolIE_ID_id_Cells_to_be_Deactivated_List; - ie->criticality = F1AP_Criticality_reject; - ie->value.present = F1AP_GNBCUConfigurationUpdateIEs__value_PR_Cells_to_be_Deactivated_List; - - for (i=0; - i<1; - i++) { - - F1AP_Cells_to_be_Deactivated_List_ItemIEs_t *cells_to_be_deactivated_list_item_ies; - cells_to_be_deactivated_list_item_ies = (F1AP_Cells_to_be_Deactivated_List_ItemIEs_t *)calloc(1, sizeof(F1AP_Cells_to_be_Deactivated_List_ItemIEs_t)); - cells_to_be_deactivated_list_item_ies->id = F1AP_ProtocolIE_ID_id_Cells_to_be_Activated_List_Item; - cells_to_be_deactivated_list_item_ies->criticality = F1AP_Criticality_reject; - cells_to_be_deactivated_list_item_ies->value.present = F1AP_Cells_to_be_Deactivated_List_ItemIEs__value_PR_Cells_to_be_Deactivated_List_Item; - + // mandatory + // c3. Cells_to_be_Deactivated_List + asn1cSequenceAdd(cfgUpdate->protocolIEs.list, F1AP_GNBCUConfigurationUpdateIEs_t, ieC3); + ieC3->id = F1AP_ProtocolIE_ID_id_Cells_to_be_Deactivated_List; + ieC3->criticality = F1AP_Criticality_reject; + ieC3->value.present = F1AP_GNBCUConfigurationUpdateIEs__value_PR_Cells_to_be_Deactivated_List; + + for (int i=0; i<1; i++) { + asn1cSequenceAdd(ieC3->value.choice.Cells_to_be_Deactivated_List.list, + F1AP_Cells_to_be_Deactivated_List_ItemIEs_t, cells_to_be_deactivated); + cells_to_be_deactivated->id = F1AP_ProtocolIE_ID_id_Cells_to_be_Activated_List_Item; + cells_to_be_deactivated->criticality = F1AP_Criticality_reject; + cells_to_be_deactivated->value.present = F1AP_Cells_to_be_Deactivated_List_ItemIEs__value_PR_Cells_to_be_Deactivated_List_Item; // 3.1 cells to be Deactivated list item - F1AP_Cells_to_be_Deactivated_List_Item_t cells_to_be_deactivated_list_item; - memset((void *)&cells_to_be_deactivated_list_item, 0, sizeof(F1AP_Cells_to_be_Deactivated_List_Item_t)); - - - F1AP_NRCGI_t nRCGI; - memset(&nRCGI, 0, sizeof(F1AP_NRCGI_t)); - MCC_MNC_TO_PLMNID(f1ap_gnb_cu_configuration_update->cells_to_activate[i].mcc, - f1ap_gnb_cu_configuration_update->cells_to_activate[i].mnc, - f1ap_gnb_cu_configuration_update->cells_to_activate[i].mnc_digit_length, - &nRCGI.pLMN_Identity); - NR_CELL_ID_TO_BIT_STRING(f1ap_gnb_cu_configuration_update->cells_to_activate[i].nr_cellid, &nRCGI.nRCellIdentity); - cells_to_be_deactivated_list_item.nRCGI = nRCGI; - - cells_to_be_deactivated_list_item_ies->value.choice.Cells_to_be_Deactivated_List_Item = cells_to_be_deactivated_list_item; - ASN_SEQUENCE_ADD(&ie->value.choice.Cells_to_be_Deactivated_List.list, - cells_to_be_deactivated_list_item_ies); - } - ASN_SEQUENCE_ADD(&out->protocolIEs.list, ie); - - - /* mandatory */ - /* c4. GNB_CU_TNL_Association_To_Add_List */ - ie = (F1AP_GNBCUConfigurationUpdateIEs_t *)calloc(1, sizeof(F1AP_GNBCUConfigurationUpdateIEs_t)); - ie->id = F1AP_ProtocolIE_ID_id_GNB_CU_TNL_Association_To_Add_List; - ie->criticality = F1AP_Criticality_reject; - ie->value.present = F1AP_GNBCUConfigurationUpdateIEs__value_PR_GNB_CU_TNL_Association_To_Add_List; - - for (i=0; - i<1; - i++) { - - F1AP_GNB_CU_TNL_Association_To_Add_ItemIEs_t *gnb_cu_tnl_association_to_add_item_ies; - gnb_cu_tnl_association_to_add_item_ies = (F1AP_GNB_CU_TNL_Association_To_Add_ItemIEs_t *)calloc(1, sizeof(F1AP_GNB_CU_TNL_Association_To_Add_ItemIEs_t)); - gnb_cu_tnl_association_to_add_item_ies->id = F1AP_ProtocolIE_ID_id_GNB_CU_TNL_Association_To_Add_Item; - gnb_cu_tnl_association_to_add_item_ies->criticality = F1AP_Criticality_reject; - gnb_cu_tnl_association_to_add_item_ies->value.present = F1AP_GNB_CU_TNL_Association_To_Add_ItemIEs__value_PR_GNB_CU_TNL_Association_To_Add_Item; - - // 4.1 GNB_CU_TNL_Association_To_Add_Item - F1AP_GNB_CU_TNL_Association_To_Add_Item_t gnb_cu_tnl_association_to_add_item; - memset((void *)&gnb_cu_tnl_association_to_add_item, 0, sizeof(F1AP_GNB_CU_TNL_Association_To_Add_Item_t)); - - - // 4.1.1 tNLAssociationTransportLayerAddress - F1AP_CP_TransportLayerAddress_t transportLayerAddress; - memset((void *)&transportLayerAddress, 0, sizeof(F1AP_CP_TransportLayerAddress_t)); - transportLayerAddress.present = F1AP_CP_TransportLayerAddress_PR_endpoint_IP_address; - TRANSPORT_LAYER_ADDRESS_IPv4_TO_BIT_STRING(1234, &transportLayerAddress.choice.endpoint_IP_address); - - // memset((void *)&transportLayerAddress, 0, sizeof(F1AP_CP_TransportLayerAddress_t)); - // transportLayerAddress.present = F1AP_CP_TransportLayerAddress_PR_endpoint_IP_address_and_port; - // transportLayerAddress.choice.endpoint_IP_address_and_port = (F1AP_Endpoint_IP_address_and_port_t *)calloc(1, sizeof(F1AP_Endpoint_IP_address_and_port_t)); - // TRANSPORT_LAYER_ADDRESS_IPv4_TO_BIT_STRING(1234, &transportLayerAddress.choice.endpoint_IP_address_and_port.endpoint_IP_address); - - gnb_cu_tnl_association_to_add_item.tNLAssociationTransportLayerAddress = transportLayerAddress; - - // 4.1.2 tNLAssociationUsage - gnb_cu_tnl_association_to_add_item.tNLAssociationUsage = F1AP_TNLAssociationUsage_non_ue; - - - - gnb_cu_tnl_association_to_add_item_ies->value.choice.GNB_CU_TNL_Association_To_Add_Item = gnb_cu_tnl_association_to_add_item; - ASN_SEQUENCE_ADD(&ie->value.choice.GNB_CU_TNL_Association_To_Add_List.list, - gnb_cu_tnl_association_to_add_item_ies); - } - ASN_SEQUENCE_ADD(&out->protocolIEs.list, ie); - - - /* mandatory */ - /* c5. GNB_CU_TNL_Association_To_Remove_List */ - ie = (F1AP_GNBCUConfigurationUpdateIEs_t *)calloc(1, sizeof(F1AP_GNBCUConfigurationUpdateIEs_t)); - ie->id = F1AP_ProtocolIE_ID_id_GNB_CU_TNL_Association_To_Remove_List; - ie->criticality = F1AP_Criticality_reject; - ie->value.present = F1AP_GNBCUConfigurationUpdateIEs__value_PR_GNB_CU_TNL_Association_To_Remove_List; - for (i=0; - i<1; - i++) { - - F1AP_GNB_CU_TNL_Association_To_Remove_ItemIEs_t *gnb_cu_tnl_association_to_remove_item_ies; - gnb_cu_tnl_association_to_remove_item_ies = (F1AP_GNB_CU_TNL_Association_To_Remove_ItemIEs_t *)calloc(1, sizeof(F1AP_GNB_CU_TNL_Association_To_Remove_ItemIEs_t)); - gnb_cu_tnl_association_to_remove_item_ies->id = F1AP_ProtocolIE_ID_id_GNB_CU_TNL_Association_To_Remove_Item; - gnb_cu_tnl_association_to_remove_item_ies->criticality = F1AP_Criticality_reject; - gnb_cu_tnl_association_to_remove_item_ies->value.present = F1AP_GNB_CU_TNL_Association_To_Remove_ItemIEs__value_PR_GNB_CU_TNL_Association_To_Remove_Item; - - // 4.1 GNB_CU_TNL_Association_To_Remove_Item - F1AP_GNB_CU_TNL_Association_To_Remove_Item_t gnb_cu_tnl_association_to_remove_item; - memset((void *)&gnb_cu_tnl_association_to_remove_item, 0, sizeof(F1AP_GNB_CU_TNL_Association_To_Remove_Item_t)); - - - // 4.1.1 tNLAssociationTransportLayerAddress - F1AP_CP_TransportLayerAddress_t transportLayerAddress; - memset((void *)&transportLayerAddress, 0, sizeof(F1AP_CP_TransportLayerAddress_t)); - transportLayerAddress.present = F1AP_CP_TransportLayerAddress_PR_endpoint_IP_address; - TRANSPORT_LAYER_ADDRESS_IPv4_TO_BIT_STRING(1234, &transportLayerAddress.choice.endpoint_IP_address); - - // memset((void *)&transportLayerAddress, 0, sizeof(F1AP_CP_TransportLayerAddress_t)); - // transportLayerAddress.present = F1AP_CP_TransportLayerAddress_PR_endpoint_IP_address_and_port; - // transportLayerAddress.choice.endpoint_IP_address_and_port = (F1AP_Endpoint_IP_address_and_port_t *)calloc(1, sizeof(F1AP_Endpoint_IP_address_and_port_t)); - // TRANSPORT_LAYER_ADDRESS_IPv4_TO_BIT_STRING(1234, &transportLayerAddress.choice.endpoint_IP_address_and_port.endpoint_IP_address); - - gnb_cu_tnl_association_to_remove_item.tNLAssociationTransportLayerAddress = transportLayerAddress; - - - - gnb_cu_tnl_association_to_remove_item_ies->value.choice.GNB_CU_TNL_Association_To_Remove_Item = gnb_cu_tnl_association_to_remove_item; - ASN_SEQUENCE_ADD(&ie->value.choice.GNB_CU_TNL_Association_To_Remove_List.list, - gnb_cu_tnl_association_to_remove_item_ies); - } - ASN_SEQUENCE_ADD(&out->protocolIEs.list, ie); - - - /* mandatory */ - /* c6. GNB_CU_TNL_Association_To_Update_List */ - ie = (F1AP_GNBCUConfigurationUpdateIEs_t *)calloc(1, sizeof(F1AP_GNBCUConfigurationUpdateIEs_t)); - ie->id = F1AP_ProtocolIE_ID_id_GNB_CU_TNL_Association_To_Update_List; - ie->criticality = F1AP_Criticality_reject; - ie->value.present = F1AP_GNBCUConfigurationUpdateIEs__value_PR_GNB_CU_TNL_Association_To_Update_List; - for (i=0; - i<1; - i++) { - - F1AP_GNB_CU_TNL_Association_To_Update_ItemIEs_t *gnb_cu_tnl_association_to_update_item_ies; - gnb_cu_tnl_association_to_update_item_ies = (F1AP_GNB_CU_TNL_Association_To_Update_ItemIEs_t *)calloc(1, sizeof(F1AP_GNB_CU_TNL_Association_To_Update_ItemIEs_t)); - gnb_cu_tnl_association_to_update_item_ies->id = F1AP_ProtocolIE_ID_id_GNB_CU_TNL_Association_To_Update_Item; - gnb_cu_tnl_association_to_update_item_ies->criticality = F1AP_Criticality_reject; - gnb_cu_tnl_association_to_update_item_ies->value.present = F1AP_GNB_CU_TNL_Association_To_Update_ItemIEs__value_PR_GNB_CU_TNL_Association_To_Update_Item; - - // 4.1 GNB_CU_TNL_Association_To_Update_Item - F1AP_GNB_CU_TNL_Association_To_Update_Item_t gnb_cu_tnl_association_to_update_item; - memset((void *)&gnb_cu_tnl_association_to_update_item, 0, sizeof(F1AP_GNB_CU_TNL_Association_To_Update_Item_t)); - - - // 4.1.1 tNLAssociationTransportLayerAddress - F1AP_CP_TransportLayerAddress_t transportLayerAddress; - memset((void *)&transportLayerAddress, 0, sizeof(F1AP_CP_TransportLayerAddress_t)); - transportLayerAddress.present = F1AP_CP_TransportLayerAddress_PR_endpoint_IP_address; - TRANSPORT_LAYER_ADDRESS_IPv4_TO_BIT_STRING(1234, &transportLayerAddress.choice.endpoint_IP_address); - - // memset((void *)&transportLayerAddress, 0, sizeof(F1AP_CP_TransportLayerAddress_t)); - // transportLayerAddress.present = F1AP_CP_TransportLayerAddress_PR_endpoint_IP_address_and_port; - // transportLayerAddress.choice.endpoint_IP_address_and_port = (F1AP_Endpoint_IP_address_and_port_t *)calloc(1, sizeof(F1AP_Endpoint_IP_address_and_port_t)); - // TRANSPORT_LAYER_ADDRESS_IPv4_TO_BIT_STRING(1234, &transportLayerAddress.choice.endpoint_IP_address_and_port.endpoint_IP_address); - - gnb_cu_tnl_association_to_update_item.tNLAssociationTransportLayerAddress = transportLayerAddress; - - - // 4.1.2 tNLAssociationUsage - if (1) { - gnb_cu_tnl_association_to_update_item.tNLAssociationUsage = (F1AP_TNLAssociationUsage_t *)calloc(1, sizeof(F1AP_TNLAssociationUsage_t)); - *gnb_cu_tnl_association_to_update_item.tNLAssociationUsage = F1AP_TNLAssociationUsage_non_ue; + F1AP_Cells_to_be_Deactivated_List_Item_t *cells_to_be_deactivated_list= + cells_to_be_deactivated->value.choice.Cells_to_be_Deactivated_List_Item; + addnRCGI(cells_to_be_deactivated_item->nRCGI, f1ap_setup_resp->cells_to_deactivate+i); } - - - gnb_cu_tnl_association_to_update_item_ies->value.choice.GNB_CU_TNL_Association_To_Update_Item = gnb_cu_tnl_association_to_update_item; - ASN_SEQUENCE_ADD(&ie->value.choice.GNB_CU_TNL_Association_To_Update_List.list, - gnb_cu_tnl_association_to_update_item_ies); - } - ASN_SEQUENCE_ADD(&out->protocolIEs.list, ie); - - - /* mandatory */ - /* c7. Cells_to_be_Barred_List */ - ie = (F1AP_GNBCUConfigurationUpdateIEs_t *)calloc(1, sizeof(F1AP_GNBCUConfigurationUpdateIEs_t)); - ie->id = F1AP_ProtocolIE_ID_id_Cells_to_be_Barred_List; - ie->criticality = F1AP_Criticality_reject; - ie->value.present = F1AP_GNBCUConfigurationUpdateIEs__value_PR_Cells_to_be_Barred_List; - for (i=0; - i<1; - i++) { - - F1AP_Cells_to_be_Barred_ItemIEs_t *cells_to_be_barred_item_ies; - cells_to_be_barred_item_ies = (F1AP_Cells_to_be_Barred_ItemIEs_t *)calloc(1, sizeof(F1AP_Cells_to_be_Barred_ItemIEs_t)); - cells_to_be_barred_item_ies->id = F1AP_ProtocolIE_ID_id_Cells_to_be_Activated_List_Item; - cells_to_be_barred_item_ies->criticality = F1AP_Criticality_reject; - cells_to_be_barred_item_ies->value.present = F1AP_Cells_to_be_Barred_ItemIEs__value_PR_Cells_to_be_Barred_Item; - - // 7.1 cells to be Deactivated list item - F1AP_Cells_to_be_Barred_Item_t cells_to_be_barred_item; - memset((void *)&cells_to_be_barred_item, 0, sizeof(F1AP_Cells_to_be_Barred_Item_t)); - - // - nRCGI - F1AP_NRCGI_t nRCGI; - memset(&nRCGI,0,sizeof(F1AP_NRCGI_t)); - MCC_MNC_TO_PLMNID(f1ap_gnb_cu_configuration_update->cells_to_activate[i].mcc, - f1ap_gnb_cu_configuration_update->cells_to_activate[i].mnc, - f1ap_gnb_cu_configuration_update->cells_to_activate[i].mnc_digit_length, - &nRCGI.pLMN_Identity); - NR_CELL_ID_TO_BIT_STRING(f1ap_gnb_cu_configuration_update->cells_to_activate[i].nr_cellid, &nRCGI.nRCellIdentity); - cells_to_be_barred_item.nRCGI = nRCGI; - - // 7.2 cellBarred - cells_to_be_barred_item.cellBarred = F1AP_CellBarred_not_barred; - - cells_to_be_barred_item_ies->value.choice.Cells_to_be_Barred_Item = cells_to_be_barred_item; - ASN_SEQUENCE_ADD(&ie->value.choice.Cells_to_be_Barred_List.list, - cells_to_be_barred_item_ies); - } - ASN_SEQUENCE_ADD(&out->protocolIEs.list, ie); - - - /* mandatory */ - /* c8. Protected_EUTRA_Resources_List */ - ie = (F1AP_GNBCUConfigurationUpdateIEs_t *)calloc(1, sizeof(F1AP_GNBCUConfigurationUpdateIEs_t)); - ie->id = F1AP_ProtocolIE_ID_id_Protected_EUTRA_Resources_List; - ie->criticality = F1AP_Criticality_reject; - ie->value.present = F1AP_GNBCUConfigurationUpdateIEs__value_PR_Protected_EUTRA_Resources_List; - - for (i=0; - i<1; - i++) { - - - F1AP_Protected_EUTRA_Resources_ItemIEs_t *protected_eutra_resources_item_ies; - - // 8.1 SpectrumSharingGroupID - protected_eutra_resources_item_ies = (F1AP_Protected_EUTRA_Resources_ItemIEs_t *)calloc(1, sizeof(F1AP_Protected_EUTRA_Resources_ItemIEs_t)); - protected_eutra_resources_item_ies->id = F1AP_ProtocolIE_ID_id_Protected_EUTRA_Resources_List; - protected_eutra_resources_item_ies->criticality = F1AP_Criticality_reject; - protected_eutra_resources_item_ies->value.present = F1AP_Protected_EUTRA_Resources_ItemIEs__value_PR_Protected_EUTRA_Resources_Item; - ((F1AP_Protected_EUTRA_Resources_Item_t*)&protected_eutra_resources_item_ies->value.choice.Protected_EUTRA_Resources_Item)->spectrumSharingGroupID = 123L; - memset(&protected_eutra_resources_item_ies->value.choice.Protected_EUTRA_Resources_Item,0, - sizeof(F1AP_Protected_EUTRA_Resources_Item_t)); - ASN_SEQUENCE_ADD(&ie->value.choice.Protected_EUTRA_Resources_List.list, protected_eutra_resources_item_ies); - - /* - F1AP_Served_EUTRA_Cells_Information_t served_eutra_cells_information; - memset((void *)&served_eutra_cells_information, 0, sizeof(F1AP_Served_EUTRA_Cells_Information_t)); - - F1AP_EUTRA_Mode_Info_t eUTRA_Mode_Info; - memset((void *)&eUTRA_Mode_Info, 0, sizeof(F1AP_EUTRA_Mode_Info_t)); - - // eUTRAFDD - eUTRA_Mode_Info.present = F1AP_EUTRA_Mode_Info_PR_eUTRAFDD; - F1AP_EUTRA_FDD_Info_t *eutra_fdd_info; - eutra_fdd_info = (F1AP_EUTRA_FDD_Info_t *)calloc(1, sizeof(F1AP_EUTRA_FDD_Info_t)); - eutra_fdd_info->uL_offsetToPointA = 123L; - eutra_fdd_info->dL_offsetToPointA = 456L; - eUTRA_Mode_Info.choice.eUTRAFDD = eutra_fdd_info; - - // eUTRATDD - // eUTRA_Mode_Info.present = F1AP_EUTRA_Mode_Info_PR_eUTRATDD; - // F1AP_EUTRA_TDD_Info_t *eutra_tdd_info; - // eutra_tdd_info = (F1AP_EUTRA_TDD_Info_t *)calloc(1, sizeof(F1AP_EUTRA_TDD_Info_t)); - // eutra_tdd_info->uL_offsetToPointA = 123L; - // eutra_tdd_info->dL_offsetToPointA = 456L; - // eUTRA_Mode_Info.choice.eUTRATDD = eutra_tdd_info; - - served_eutra_cells_information.eUTRA_Mode_Info = eUTRA_Mode_Info; - - OCTET_STRING_fromBuf(&served_eutra_cells_information.protectedEUTRAResourceIndication, "asdsa1d32sa1d31asd31as", - strlen("asdsa1d32sa1d31asd31as")); - - ASN_SEQUENCE_ADD(&protected_eutra_resources_item_ies->value.choice.ListofEUTRACellsinGNBDUCoordination.list, &served_eutra_cells_information); - - ASN_SEQUENCE_ADD(&ie->value.choice.Protected_EUTRA_Resources_List.list, protected_eutra_resources_item_ies); - */ + } + */ + + // c4. GNB_CU_TNL_Association_To_Add_List + /* + asn1cSequenceAdd(cfgUpdate->protocolIEs.list, F1AP_GNBCUConfigurationUpdateIEs_t, ieC4); + ieC4->id = F1AP_ProtocolIE_ID_id_GNB_CU_TNL_Association_To_Add_List; + ieC4->criticality = F1AP_Criticality_reject; + ieC4->value.present = F1AP_GNBCUConfigurationUpdateIEs__value_PR_GNB_CU_TNL_Association_To_Add_List; + + for (int i=0; i<1; i++) { + asn1cSequenceAdd(ieC4->value.choice.GNB_CU_TNL_Association_To_Add_List.list, + F1AP_GNB_CU_TNL_Association_To_Add_ItemIEs_t, gnb_cu_tnl_association_to_add; + gnb_cu_tnl_association_to_add->id = F1AP_ProtocolIE_ID_id_GNB_CU_TNL_Association_To_Add_Item; + gnb_cu_tnl_association_to_add->criticality = F1AP_Criticality_reject; + gnb_cu_tnl_association_to_add->value.present = F1AP_GNB_CU_TNL_Association_To_Add_ItemIEs__value_PR_GNB_CU_TNL_Association_To_Add_Item; + + // 4.1 GNB_CU_TNL_Association_To_Add_Item + F1AP_GNB_CU_TNL_Association_To_Add_Item_t *gnb_cu_tnl_association_to_add_item= + &gnb_cu_tnl_association_to_add_item_ies->value.choice.GNB_CU_TNL_Association_To_Add_Item; + + // 4.1.1 tNLAssociationTransportLayerAddress + F1AP_CP_TransportLayerAddress_t *transportLayerAddress=; + gnb_cu_tnl_association_to_add->value.choice.GNB_CU_TNL_Association_To_Add_Item; + + transportLayerAddress->present = F1AP_CP_TransportLayerAddress_PR_endpoint_IP_address; + TRANSPORT_LAYER_ADDRESS_IPv4_TO_BIT_STRING(1234, &transportLayerAddress->choice.endpoint_IP_address); + + // memset((void *)&transportLayerAddress, 0, sizeof(F1AP_CP_TransportLayerAddress_t)); + // transportLayerAddress.present = F1AP_CP_TransportLayerAddress_PR_endpoint_IP_address_and_port; + // transportLayerAddress.choice.endpoint_IP_address_and_port = (F1AP_Endpoint_IP_address_and_port_t *)calloc(1, sizeof(F1AP_Endpoint_IP_address_and_port_t)); + // TRANSPORT_LAYER_ADDRESS_IPv4_TO_BIT_STRING(1234, &transportLayerAddress.choice.endpoint_IP_address_and_port.endpoint_IP_address); + + // 4.1.2 tNLAssociationUsage + gnb_cu_tnl_association_to_add_item->tNLAssociationUsage = F1AP_TNLAssociationUsage_non_ue; + } + */ + + /* + // c5. GNB_CU_TNL_Association_To_Remove_List + asn1cSequenceAdd(cfgUpdate->protocolIEs.list, F1AP_GNBCUConfigurationUpdateIEs_t, ieC5); + ieC5->id = F1AP_ProtocolIE_ID_id_GNB_CU_TNL_Association_To_Remove_List; + ieC5->criticality = F1AP_Criticality_reject; + ieC5->value.present = F1AP_GNBCUConfigurationUpdateIEs__value_PR_GNB_CU_TNL_Association_To_Remove_List; + for (int i=0; i<1; i++) { + asn1cSequenceAdd(ieC5->value.choice.GNB_CU_TNL_Association_To_Remove_List.list, + F1AP_GNB_CU_TNL_Association_To_Remove_ItemIEs_t, gnb_cu_tnl_association_to_remove); + gnb_cu_tnl_association_to_remove->id = F1AP_ProtocolIE_ID_id_GNB_CU_TNL_Association_To_Remove_Item; + gnb_cu_tnl_association_to_remove->criticality = F1AP_Criticality_reject; + gnb_cu_tnl_association_to_remove->value.present = F1AP_GNB_CU_TNL_Association_To_Remove_ItemIEs__value_PR_GNB_CU_TNL_Association_To_Remove_Item; + + // 4.1 GNB_CU_TNL_Association_To_Remove_Item + F1AP_GNB_CU_TNL_Association_To_Remove_Item_t *gnb_cu_tnl_association_to_remove_item= + &gnb_cu_tnl_association_to_remove->value.choice.GNB_CU_TNL_Association_To_Remove_Item; + + // 4.1.1 tNLAssociationTransportLayerAddress + F1AP_CP_TransportLayerAddress_t *transportLayerAddress= + &gnb_cu_tnl_association_to_remove_item->tNLAssociationTransportLayerAddress; + transportLayerAddress->present = F1AP_CP_TransportLayerAddress_PR_endpoint_IP_address; + TRANSPORT_LAYER_ADDRESS_IPv4_TO_BIT_STRING(1234, &transportLayerAddress->choice.endpoint_IP_address); + + // memset((void *)&transportLayerAddress, 0, sizeof(F1AP_CP_TransportLayerAddress_t)); + // transportLayerAddress.present = F1AP_CP_TransportLayerAddress_PR_endpoint_IP_address_and_port; + // transportLayerAddress.choice.endpoint_IP_address_and_port = (F1AP_Endpoint_IP_address_and_port_t *)calloc(1, sizeof(F1AP_Endpoint_IP_address_and_port_t)); + // TRANSPORT_LAYER_ADDRESS_IPv4_TO_BIT_STRING(1234, &transportLayerAddress.choice.endpoint_IP_address_and_port.endpoint_IP_address); } - ASN_SEQUENCE_ADD(&out->protocolIEs.list, ie); + */ + + /* + //mandatory + // c6. GNB_CU_TNL_Association_To_Update_List + asn1cSequenceAdd(cfgUpdate->protocolIEs.list, F1AP_GNBCUConfigurationUpdateIEs_t, ieC6); + ieC6->id = F1AP_ProtocolIE_ID_id_GNB_CU_TNL_Association_To_Update_List; + ieC6->criticality = F1AP_Criticality_reject; + ieC6->value.present = F1AP_GNBCUConfigurationUpdateIEs__value_PR_GNB_CU_TNL_Association_To_Update_List; + + for (int i=0; i<1; i++) { + asn1cSequenceAdd(ieC3->value.choice.GNB_CU_TNL_Association_To_Update_List.list, + F1AP_GNB_CU_TNL_Association_To_Update_ItemIEs_t, gnb_cu_tnl_association_to_update); + gnb_cu_tnl_association_to_update->id = F1AP_ProtocolIE_ID_id_GNB_CU_TNL_Association_To_Update_Item; + gnb_cu_tnl_association_to_update->criticality = F1AP_Criticality_reject; + gnb_cu_tnl_association_to_update->value.present = F1AP_GNB_CU_TNL_Association_To_Update_ItemIEs__value_PR_GNB_CU_TNL_Association_To_Update_Item; + // 4.1 GNB_CU_TNL_Association_To_Update_Item + F1AP_GNB_CU_TNL_Association_To_Update_Item_t *gnb_cu_tnl_association_to_update_item= + &gnb_cu_tnl_association_to_update->value.choice.GNB_CU_TNL_Association_To_Update_Item; + // 4.1.1 tNLAssociationTransportLayerAddress + F1AP_CP_TransportLayerAddress_t *transportLayerAddress= + &gnb_cu_tnl_association_to_update_item.tNLAssociationTransportLayerAddress; + transportLayerAddress->present = F1AP_CP_TransportLayerAddress_PR_endpoint_IP_address; + TRANSPORT_LAYER_ADDRESS_IPv4_TO_BIT_STRING(1234, &transportLayerAddress->choice.endpoint_IP_address); + // memset((void *)&transportLayerAddress, 0, sizeof(F1AP_CP_TransportLayerAddress_t)); + // transportLayerAddress.present = F1AP_CP_TransportLayerAddress_PR_endpoint_IP_address_and_port; + // transportLayerAddress.choice.endpoint_IP_address_and_port = (F1AP_Endpoint_IP_address_and_port_t *)calloc(1, sizeof(F1AP_Endpoint_IP_address_and_port_t)); + // TRANSPORT_LAYER_ADDRESS_IPv4_TO_BIT_STRING(1234, &transportLayerAddress.choice.endpoint_IP_address_and_port.endpoint_IP_address); + // 4.1.2 tNLAssociationUsage + if (1) { + gnb_cu_tnl_association_to_update_item.tNLAssociationUsage = (F1AP_TNLAssociationUsage_t *)calloc(1, sizeof(F1AP_TNLAssociationUsage_t)); + *gnb_cu_tnl_association_to_update_item.tNLAssociationUsage = F1AP_TNLAssociationUsage_non_ue; + } + } + */ + + /* + // c7. Cells_to_be_Barred_List + asn1cSequenceAdd(cfgUpdate->protocolIEs.list, F1AP_GNBCUConfigurationUpdateIEs_t, ieC7); + ieC7->id = F1AP_ProtocolIE_ID_id_Cells_to_be_Barred_List; + ieC7->criticality = F1AP_Criticality_reject; + ieC7->value.present = F1AP_GNBCUConfigurationUpdateIEs__value_PR_Cells_to_be_Barred_List; + + for (int i=0; i<1; i++) { + asn1cSequenceAdd(ieC7->value.choice.Cells_to_be_Barred_List.list, + F1AP_Cells_to_be_Barred_ItemIEs_t,cells_to_be_barred); + cells_to_be_barred->id = F1AP_ProtocolIE_ID_id_Cells_to_be_Activated_List_Item; + cells_to_be_barred->criticality = F1AP_Criticality_reject; + cells_to_be_barred->value.present = F1AP_Cells_to_be_Barred_ItemIEs__value_PR_Cells_to_be_Barred_Item; + // 7.1 cells to be Deactivated list item + F1AP_Cells_to_be_Barred_Item_t *cells_to_be_barred_item= + &cells_to_be_barred_item_ies->value.choice.Cells_to_be_Barred_Item; + // - nRCGI + addnRCGI(cells_to_be_barred_item->nRCGI, f1ap_gnb_cu_configuration_update->cells_to_activate+i); + // 7.2 cellBarred + cells_to_be_barred_item->cellBarred = F1AP_CellBarred_not_barred; } - + */ + + /* + // c8. Protected_EUTRA_Resources_List + asn1cSequenceAdd(cfgUpdate->protocolIEs.list, F1AP_GNBCUConfigurationUpdateIEs_t, ieC8); + ieC8->id = F1AP_ProtocolIE_ID_id_Protected_EUTRA_Resources_List; + ieC8->criticality = F1AP_Criticality_reject; + ieC8->value.present = F1AP_GNBCUConfigurationUpdateIEs__value_PR_Protected_EUTRA_Resources_List; + + for (int i=0; i<1; i++) { + asn1cSequenceAdd(ieC8->value.choice.Protected_EUTRA_Resources_List.list, + F1AP_Protected_EUTRA_Resources_ItemIEs_t, protected_eutra_resources); + // 8.1 SpectrumSharingGroupID + protected_eutra_resources->id = F1AP_ProtocolIE_ID_id_Protected_EUTRA_Resources_List; + protected_eutra_resources->criticality = F1AP_Criticality_reject; + protected_eutra_resources->value.present = F1AP_Protected_EUTRA_Resources_ItemIEs__value_PR_Protected_EUTRA_Resources_Item; + ((F1AP_Protected_EUTRA_Resources_Item_t *)&protected_eutra_resources->value.choice.Protected_EUTRA_Resources_Item)->spectrumSharingGroupID = 123L; + memset(&protected_eutra_resources->value.choice.Protected_EUTRA_Resources_Item,0, + sizeof(F1AP_Protected_EUTRA_Resources_Item_t)); + + asn1cSequenceAdd(protected_eutra_resources->value.choice.ListofEUTRACellsinGNBDUCoordination.list, + F1AP_Served_EUTRA_Cells_Information_t, served_eutra_cells_information); + memset((void *)&served_eutra_cells_information, 0, sizeof(F1AP_Served_EUTRA_Cells_Information_t)); + + F1AP_EUTRA_Mode_Info_t *eUTRA_Mode_Info= + &served_eutra_cells_information.eUTRA_Mode_Info; + + // eUTRAFDD + eUTRA_Mode_Info->present = F1AP_EUTRA_Mode_Info_PR_eUTRAFDD; + F1AP_EUTRA_FDD_Info_t *eutra_fdd_info = (F1AP_EUTRA_FDD_Info_t *)calloc(1, sizeof(F1AP_EUTRA_FDD_Info_t)); + eutra_fdd_info->uL_offsetToPointA = 123L; + eutra_fdd_info->dL_offsetToPointA = 456L; + eUTRA_Mode_Info.choice.eUTRAFDD = eutra_fdd_info; + + // eUTRATDD + // eUTRA_Mode_Info.present = F1AP_EUTRA_Mode_Info_PR_eUTRATDD; + // F1AP_EUTRA_TDD_Info_t *eutra_tdd_info; + // eutra_tdd_info = (F1AP_EUTRA_TDD_Info_t *)calloc(1, sizeof(F1AP_EUTRA_TDD_Info_t)); + // eutra_tdd_info->uL_offsetToPointA = 123L; + // eutra_tdd_info->dL_offsetToPointA = 456L; + // eUTRA_Mode_Info.choice.eUTRATDD = eutra_tdd_info; + + OCTET_STRING_fromBuf(&served_eutra_cells_information.protectedEUTRAResourceIndication, "asdsa1d32sa1d31asd31as", + strlen("asdsa1d32sa1d31asd31as")); + } + */ /* encode */ if (f1ap_encode_pdu(&pdu, &buffer, &len) < 0) { @@ -953,38 +754,36 @@ int CU_send_gNB_CU_CONFIGURATION_UPDATE(instance_t instance, f1ap_gnb_cu_configu return -1; } - LOG_D(F1AP, "F1AP gNB-CU CONFIGURATION UPDATE\n"); - //for (int i=0;i<len;i++) printf("%02x ",buffer[i]); - //printf("\n"); - - cu_f1ap_itti_send_sctp_data_req(instance, f1ap_du_data_from_du->assoc_id, buffer, len, 0); + LOG_DUMPMSG(F1AP, LOG_DUMP_CHAR, buffer, len, "F1AP gNB-CU CONFIGURATION UPDATE : "); + ASN_STRUCT_RESET(asn_DEF_F1AP_F1AP_PDU, &pdu); + f1ap_itti_send_sctp_data_req(true,instance, buffer, len, 0); return 0; } int CU_handle_gNB_CU_CONFIGURATION_UPDATE_FAILURE(instance_t instance, - uint32_t assoc_id, - uint32_t stream, - F1AP_F1AP_PDU_t *pdu) { + uint32_t assoc_id, + uint32_t stream, + F1AP_F1AP_PDU_t *pdu) { AssertFatal(1==0,"Not implemented yet\n"); } int CU_handle_gNB_CU_CONFIGURATION_UPDATE_ACKNOWLEDGE(instance_t instance, - uint32_t assoc_id, - uint32_t stream, - F1AP_F1AP_PDU_t *pdu) { - LOG_D(F1AP,"Cell Configuration ok (assoc_id %d)\n",assoc_id); + uint32_t assoc_id, + uint32_t stream, + F1AP_F1AP_PDU_t *pdu) { + LOG_I(F1AP,"Cell Configuration ok (assoc_id %d)\n",assoc_id); return(0); } int CU_handle_gNB_DU_RESOURCE_COORDINATION_REQUEST(instance_t instance, - uint32_t assoc_id, - uint32_t stream, - F1AP_F1AP_PDU_t *pdu) { + uint32_t assoc_id, + uint32_t stream, + F1AP_F1AP_PDU_t *pdu) { AssertFatal(0, "Not implemented yet\n"); } int CU_send_gNB_DU_RESOURCE_COORDINATION_RESPONSE(instance_t instance, - F1AP_GNBDUResourceCoordinationResponse_t *GNBDUResourceCoordinationResponse) { + F1AP_GNBDUResourceCoordinationResponse_t *GNBDUResourceCoordinationResponse) { AssertFatal(0, "Not implemented yet\n"); } diff --git a/openair2/F1AP/f1ap_cu_interface_management.h b/openair2/F1AP/f1ap_cu_interface_management.h index de7dcfe99ba9b9b475813010a406a0a12d6297af..83da037925544a3648f60a8c79c6c0fbcb65dd87 100644 --- a/openair2/F1AP/f1ap_cu_interface_management.h +++ b/openair2/F1AP/f1ap_cu_interface_management.h @@ -72,39 +72,39 @@ int CU_send_F1_SETUP_FAILURE(instance_t instance); * gNB-DU Configuration Update */ int CU_handle_gNB_DU_CONFIGURATION_UPDATE(instance_t instance, - uint32_t assoc_id, - uint32_t stream, - F1AP_F1AP_PDU_t *pdu); + uint32_t assoc_id, + uint32_t stream, + F1AP_F1AP_PDU_t *pdu); int CU_send_gNB_DU_CONFIGURATION_FAILURE(instance_t instance, - F1AP_GNBDUConfigurationUpdateFailure_t *GNBDUConfigurationUpdateFailure); + F1AP_GNBDUConfigurationUpdateFailure_t *GNBDUConfigurationUpdateFailure); int CU_send_gNB_DU_CONFIGURATION_UPDATE_ACKNOWLEDGE(instance_t instance, - F1AP_GNBDUConfigurationUpdateAcknowledge_t *GNBDUConfigurationUpdateAcknowledge); + F1AP_GNBDUConfigurationUpdateAcknowledge_t *GNBDUConfigurationUpdateAcknowledge); /* * gNB-CU Configuration Update */ int CU_send_gNB_CU_CONFIGURATION_UPDATE(instance_t instance, f1ap_gnb_cu_configuration_update_t *f1ap_gnb_cu_configuration_update); int CU_handle_gNB_CU_CONFIGURATION_UPDATE_FAILURE(instance_t instance, - uint32_t assoc_id, - uint32_t stream, - F1AP_F1AP_PDU_t *pdu); + uint32_t assoc_id, + uint32_t stream, + F1AP_F1AP_PDU_t *pdu); int CU_handle_gNB_CU_CONFIGURATION_UPDATE_ACKNOWLEDGE(instance_t instance, - uint32_t assoc_id, - uint32_t stream, - F1AP_F1AP_PDU_t *pdu); + uint32_t assoc_id, + uint32_t stream, + F1AP_F1AP_PDU_t *pdu); /* * gNB-DU Resource Coordination */ int CU_handle_gNB_DU_RESOURCE_COORDINATION_REQUEST(instance_t instance, - uint32_t assoc_id, - uint32_t stream, - F1AP_F1AP_PDU_t *pdu); + uint32_t assoc_id, + uint32_t stream, + F1AP_F1AP_PDU_t *pdu); int CU_send_gNB_DU_RESOURCE_COORDINATION_RESPONSE(instance_t instance, - F1AP_GNBDUResourceCoordinationResponse_t *GNBDUResourceCoordinationResponse); + F1AP_GNBDUResourceCoordinationResponse_t *GNBDUResourceCoordinationResponse); #endif /* F1AP_CU_INTERFACE_MANAGEMENT_H_ */ diff --git a/openair2/F1AP/f1ap_cu_rrc_message_transfer.c b/openair2/F1AP/f1ap_cu_rrc_message_transfer.c index 8a5b9785b50f50c95beea62d6f93cbd540db0724..62a62095b16fcd22f70632be95d298bc0cdf901a 100644 --- a/openair2/F1AP/f1ap_cu_rrc_message_transfer.c +++ b/openair2/F1AP/f1ap_cu_rrc_message_transfer.c @@ -38,78 +38,54 @@ #include "common/ran_context.h" #include "openair3/UTILS/conversions.h" -// Bing Kai: create CU and DU context, and put all the information there. -uint64_t du_ue_f1ap_id = 0; -uint32_t f1ap_assoc_id = 0; -uint32_t f1ap_stream = 0; - - -extern f1ap_cudu_inst_t f1ap_cu_inst[MAX_eNB]; - /* Initial UL RRC Message Transfer */ -extern RAN_CONTEXT_t RC; - int CU_handle_INITIAL_UL_RRC_MESSAGE_TRANSFER(instance_t instance, - uint32_t assoc_id, - uint32_t stream, - F1AP_F1AP_PDU_t *pdu) { - + uint32_t assoc_id, + uint32_t stream, + F1AP_F1AP_PDU_t *pdu) { LOG_D(F1AP, "CU_handle_INITIAL_UL_RRC_MESSAGE_TRANSFER\n"); // decode the F1 message - // get the rrc message from the contauiner + // get the rrc message from the contauiner // call func rrc_eNB_decode_ccch: <-- needs some update here MessageDef *message_p; F1AP_InitialULRRCMessageTransfer_t *container; F1AP_InitialULRRCMessageTransferIEs_t *ie; - rnti_t rnti; sdu_size_t ccch_sdu_len; int CC_id =0; - - DevAssert(pdu != NULL); - + if (stream != 0) { LOG_E(F1AP, "[SCTP %d] Received F1 on stream != 0 (%d)\n", assoc_id, stream); return -1; } - // TODO: use context - f1ap_stream = stream; - f1ap_assoc_id = assoc_id; container = &pdu->choice.initiatingMessage->value.choice.InitialULRRCMessageTransfer; - /* GNB_DU_UE_F1AP_ID */ F1AP_FIND_PROTOCOLIE_BY_ID(F1AP_InitialULRRCMessageTransferIEs_t, ie, container, F1AP_ProtocolIE_ID_id_gNB_DU_UE_F1AP_ID, true); - du_ue_f1ap_id = ie->value.choice.GNB_DU_UE_F1AP_ID; - LOG_D(F1AP, "du_ue_f1ap_id %lu \n", du_ue_f1ap_id); - - /* NRCGI - * TODO: process NRCGI + /* NRCGI + * Fixme: process NRCGI */ F1AP_FIND_PROTOCOLIE_BY_ID(F1AP_InitialULRRCMessageTransferIEs_t, ie, container, F1AP_ProtocolIE_ID_id_NRCGI, true); - - uint64_t nr_cellid; BIT_STRING_TO_NR_CELL_IDENTITY(&ie->value.choice.NRCGI.nRCellIdentity,nr_cellid); - /* RNTI */ F1AP_FIND_PROTOCOLIE_BY_ID(F1AP_InitialULRRCMessageTransferIEs_t, ie, container, F1AP_ProtocolIE_ID_id_C_RNTI, true); rnti = ie->value.choice.C_RNTI; - /* RRC Container */ F1AP_FIND_PROTOCOLIE_BY_ID(F1AP_InitialULRRCMessageTransferIEs_t, ie, container, F1AP_ProtocolIE_ID_id_RRCContainer, true); AssertFatal(ie!=NULL,"RRCContainer is missing\n"); + // create an ITTI message and copy SDU - if (RC.nrrrc && RC.nrrrc[GNB_INSTANCE_TO_MODULE_ID(instance)]->node_type == ngran_gNB_CU) { + if (f1ap_req(true, instance)->cell_type==CELL_MACRO_GNB) { message_p = itti_alloc_new_message (TASK_CU_F1, 0, NR_RRC_MAC_CCCH_DATA_IND); memset (NR_RRC_MAC_CCCH_DATA_IND (message_p).sdu, 0, CCCH_SDU_SIZE); ccch_sdu_len = ie->value.choice.RRCContainer.size; @@ -123,310 +99,212 @@ int CU_handle_INITIAL_UL_RRC_MESSAGE_TRANSFER(instance_t instance, ccch_sdu_len); } - if (RC.nrrrc && RC.nrrrc[GNB_INSTANCE_TO_MODULE_ID(instance)]->node_type == ngran_gNB_CU) { - - LOG_D(F1AP, "%s() RRCContainer (CCCH) size %ld: ", __func__, ie->value.choice.RRCContainer.size); - //for (int i = 0; i < ie->value.choice.RRCContainer.size; i++) - // printf("%02x ", RRC_MAC_CCCH_DATA_IND (message_p).sdu[i]); - //printf("\n"); - - /* DUtoCURRCContainer */ - F1AP_FIND_PROTOCOLIE_BY_ID(F1AP_InitialULRRCMessageTransferIEs_t, ie, container, - F1AP_ProtocolIE_ID_id_DUtoCURRCContainer, true); - if (ie) { - NR_RRC_MAC_CCCH_DATA_IND (message_p).du_to_cu_rrc_container = malloc(sizeof(OCTET_STRING_t)); - NR_RRC_MAC_CCCH_DATA_IND (message_p).du_to_cu_rrc_container->size = ie->value.choice.DUtoCURRCContainer.size; - NR_RRC_MAC_CCCH_DATA_IND (message_p).du_to_cu_rrc_container->buf = malloc( - ie->value.choice.DUtoCURRCContainer.size); - memcpy(NR_RRC_MAC_CCCH_DATA_IND (message_p).du_to_cu_rrc_container->buf, - ie->value.choice.DUtoCURRCContainer.buf, - ie->value.choice.DUtoCURRCContainer.size); - } + LOG_I(F1AP, "%s() RRCContainer (CCCH) size %ld: ", __func__, ie->value.choice.RRCContainer.size); + /* DUtoCURRCContainer */ + F1AP_FIND_PROTOCOLIE_BY_ID(F1AP_InitialULRRCMessageTransferIEs_t, ie, container, + F1AP_ProtocolIE_ID_id_DUtoCURRCContainer, false); + + if (ie) { + NR_RRC_MAC_CCCH_DATA_IND (message_p).du_to_cu_rrc_container = malloc(sizeof(OCTET_STRING_t)); + NR_RRC_MAC_CCCH_DATA_IND (message_p).du_to_cu_rrc_container->size = ie->value.choice.DUtoCURRCContainer.size; + NR_RRC_MAC_CCCH_DATA_IND (message_p).du_to_cu_rrc_container->buf = malloc(ie->value.choice.DUtoCURRCContainer.size); + memcpy(NR_RRC_MAC_CCCH_DATA_IND (message_p).du_to_cu_rrc_container->buf, + ie->value.choice.DUtoCURRCContainer.buf, + ie->value.choice.DUtoCURRCContainer.size); } - // Find instance from nr_cellid - int rrc_inst = -1; - if (RC.nrrrc && RC.nrrrc[GNB_INSTANCE_TO_MODULE_ID(instance)]->node_type == ngran_gNB_CU) { - for (int i=0;i<RC.nb_nr_inst;i++) { - // first get RRC instance (note, no the ITTI instance) - gNB_RRC_INST *rrc = RC.nrrrc[i]; - if (rrc->nr_cellid == nr_cellid) { - rrc_inst = i; - break; - } - } - } else { - for (int i=0;i<RC.nb_inst;i++) { - // first get RRC instance (note, no the ITTI instance) - eNB_RRC_INST *rrc = RC.rrc[i]; - if (rrc->nr_cellid == nr_cellid) { - rrc_inst = i; - break; - } - } - } - AssertFatal(rrc_inst>=0,"couldn't find an RRC instance for nr_cell %llu\n",(unsigned long long int)nr_cellid); + int f1ap_uid = f1ap_add_ue(CUtype, instance, rnti); - int f1ap_uid = f1ap_add_ue(&f1ap_cu_inst[rrc_inst], rrc_inst, CC_id, 0, rnti); if (f1ap_uid < 0 ) { LOG_E(F1AP, "Failed to add UE \n"); itti_free(ITTI_MSG_ORIGIN_ID(message_p), message_p); return -1; } - f1ap_cu_inst[rrc_inst].f1ap_ue[f1ap_uid].du_ue_f1ap_id = du_ue_f1ap_id; - - if (RC.nrrrc && RC.nrrrc[GNB_INSTANCE_TO_MODULE_ID(instance)]->node_type == ngran_gNB_CU) { - NR_RRC_MAC_CCCH_DATA_IND (message_p).frame = 0; - NR_RRC_MAC_CCCH_DATA_IND (message_p).sub_frame = 0; - NR_RRC_MAC_CCCH_DATA_IND (message_p).sdu_size = ccch_sdu_len; - NR_RRC_MAC_CCCH_DATA_IND (message_p).gnb_index = rrc_inst; // CU instance - NR_RRC_MAC_CCCH_DATA_IND (message_p).rnti = rnti; - NR_RRC_MAC_CCCH_DATA_IND (message_p).CC_id = CC_id; - itti_send_msg_to_task (TASK_RRC_GNB, instance, message_p); - } else { - RRC_MAC_CCCH_DATA_IND (message_p).frame = 0; - RRC_MAC_CCCH_DATA_IND (message_p).sub_frame = 0; - RRC_MAC_CCCH_DATA_IND (message_p).sdu_size = ccch_sdu_len; - RRC_MAC_CCCH_DATA_IND (message_p).enb_index = rrc_inst; // CU instance - RRC_MAC_CCCH_DATA_IND (message_p).rnti = rnti; - RRC_MAC_CCCH_DATA_IND (message_p).CC_id = CC_id; - itti_send_msg_to_task (TASK_RRC_ENB, instance, message_p); - } + //getCxt(true,ITTI_MSG_DESTINATION_ID(message_p))->f1ap_ue[f1ap_uid].du_ue_f1ap_id = du_ue_f1ap_id; + NR_RRC_MAC_CCCH_DATA_IND (message_p).frame = 0; + NR_RRC_MAC_CCCH_DATA_IND (message_p).sub_frame = 0; + NR_RRC_MAC_CCCH_DATA_IND (message_p).sdu_size = ccch_sdu_len; + NR_RRC_MAC_CCCH_DATA_IND (message_p).nr_cellid = nr_cellid; // CU instance + NR_RRC_MAC_CCCH_DATA_IND (message_p).rnti = rnti; + NR_RRC_MAC_CCCH_DATA_IND (message_p).CC_id = CC_id; + itti_send_msg_to_task (f1ap_req(true,ITTI_MSG_DESTINATION_ID(message_p))->cell_type==CELL_MACRO_GNB?TASK_RRC_GNB:TASK_RRC_ENB, instance, message_p); return 0; } - /* DL RRC Message Transfer. */ - //void CU_send_DL_RRC_MESSAGE_TRANSFER(F1AP_DLRRCMessageTransfer_t *DLRRCMessageTransfer) { int CU_send_DL_RRC_MESSAGE_TRANSFER(instance_t instance, - f1ap_dl_rrc_message_t *f1ap_dl_rrc) - { - + f1ap_dl_rrc_message_t *f1ap_dl_rrc) { LOG_D(F1AP, "CU send DL_RRC_MESSAGE_TRANSFER \n"); - F1AP_F1AP_PDU_t pdu; + F1AP_F1AP_PDU_t pdu= {0}; F1AP_DLRRCMessageTransfer_t *out; - F1AP_DLRRCMessageTransferIEs_t *ie; - - uint8_t *buffer; - uint32_t len; - + uint8_t *buffer=NULL; + uint32_t len=0; /* Create */ - /* 0. Message Type */ - memset(&pdu, 0, sizeof(pdu)); + /* 0. Message Type */ pdu.present = F1AP_F1AP_PDU_PR_initiatingMessage; - pdu.choice.initiatingMessage = (F1AP_InitiatingMessage_t *)calloc(1, sizeof(F1AP_InitiatingMessage_t)); - pdu.choice.initiatingMessage->procedureCode = F1AP_ProcedureCode_id_DLRRCMessageTransfer; - pdu.choice.initiatingMessage->criticality = F1AP_Criticality_ignore; - pdu.choice.initiatingMessage->value.present = F1AP_InitiatingMessage__value_PR_DLRRCMessageTransfer; - out = &pdu.choice.initiatingMessage->value.choice.DLRRCMessageTransfer; - + asn1cCalloc(pdu.choice.initiatingMessage, tmp); + tmp->procedureCode = F1AP_ProcedureCode_id_DLRRCMessageTransfer; + tmp->criticality = F1AP_Criticality_ignore; + tmp->value.present = F1AP_InitiatingMessage__value_PR_DLRRCMessageTransfer; + out = &tmp->value.choice.DLRRCMessageTransfer; /* mandatory */ /* c1. GNB_CU_UE_F1AP_ID */ - - ie = (F1AP_DLRRCMessageTransferIEs_t *)calloc(1, sizeof(F1AP_DLRRCMessageTransferIEs_t)); - ie->id = F1AP_ProtocolIE_ID_id_gNB_CU_UE_F1AP_ID; - ie->criticality = F1AP_Criticality_reject; - ie->value.present = F1AP_DLRRCMessageTransferIEs__value_PR_GNB_CU_UE_F1AP_ID; - ie->value.choice.GNB_CU_UE_F1AP_ID = f1ap_get_cu_ue_f1ap_id(&f1ap_cu_inst[instance], f1ap_dl_rrc->rnti); - ASN_SEQUENCE_ADD(&out->protocolIEs.list, ie); + asn1cSequenceAdd(out->protocolIEs.list, F1AP_DLRRCMessageTransferIEs_t, ie1); + ie1->id = F1AP_ProtocolIE_ID_id_gNB_CU_UE_F1AP_ID; + ie1->criticality = F1AP_Criticality_reject; + ie1->value.present = F1AP_DLRRCMessageTransferIEs__value_PR_GNB_CU_UE_F1AP_ID; + ie1->value.choice.GNB_CU_UE_F1AP_ID = f1ap_get_cu_ue_f1ap_id(CUtype, instance, f1ap_dl_rrc->rnti); LOG_I(F1AP, "Setting GNB_CU_UE_F1AP_ID %llu associated with UE RNTI %x (instance %ld)\n", - (unsigned long long int)ie->value.choice.GNB_CU_UE_F1AP_ID, f1ap_dl_rrc->rnti, instance); - - + (unsigned long long int)ie1->value.choice.GNB_CU_UE_F1AP_ID, f1ap_dl_rrc->rnti, instance); /* mandatory */ /* c2. GNB_DU_UE_F1AP_ID */ - ie = (F1AP_DLRRCMessageTransferIEs_t *)calloc(1, sizeof(F1AP_DLRRCMessageTransferIEs_t)); - ie->id = F1AP_ProtocolIE_ID_id_gNB_DU_UE_F1AP_ID; - ie->criticality = F1AP_Criticality_reject; - ie->value.present = F1AP_DLRRCMessageTransferIEs__value_PR_GNB_DU_UE_F1AP_ID; - ie->value.choice.GNB_DU_UE_F1AP_ID = f1ap_get_du_ue_f1ap_id(&f1ap_cu_inst[instance], f1ap_dl_rrc->rnti); - ASN_SEQUENCE_ADD(&out->protocolIEs.list, ie); - LOG_I(F1AP, "GNB_DU_UE_F1AP_ID %llu associated with UE RNTI %x \n", (unsigned long long int)ie->value.choice.GNB_DU_UE_F1AP_ID, f1ap_dl_rrc->rnti); - + asn1cSequenceAdd(out->protocolIEs.list, F1AP_DLRRCMessageTransferIEs_t, ie2); + ie2->id = F1AP_ProtocolIE_ID_id_gNB_DU_UE_F1AP_ID; + ie2->criticality = F1AP_Criticality_reject; + ie2->value.present = F1AP_DLRRCMessageTransferIEs__value_PR_GNB_DU_UE_F1AP_ID; + ie2->value.choice.GNB_DU_UE_F1AP_ID = f1ap_get_du_ue_f1ap_id(CUtype, instance, f1ap_dl_rrc->rnti); + LOG_I(F1AP, "GNB_DU_UE_F1AP_ID %llu associated with UE RNTI %x \n", (unsigned long long int)ie2->value.choice.GNB_DU_UE_F1AP_ID, f1ap_dl_rrc->rnti); /* optional */ /* c3. oldgNB_DU_UE_F1AP_ID */ - /* if (f1ap_dl_rrc->old_gNB_DU_ue_id != 0xFFFFFFFF) { - ie = (F1AP_DLRRCMessageTransferIEs_t *)calloc(1, sizeof(F1AP_DLRRCMessageTransferIEs_t)); - ie->id = F1AP_ProtocolIE_ID_id_oldgNB_DU_UE_F1AP_ID; - ie->criticality = F1AP_Criticality_reject; - ie->value.present = F1AP_DLRRCMessageTransferIEs__value_PR_NOTHING; - ie->value.choice.oldgNB_DU_UE_F1AP_ID = f1ap_dl_rrc->old_gNB_DU_ue_id; - ASN_SEQUENCE_ADD(&out->protocolIEs.list, ie); - }*/ - + /* if (f1ap_dl_rrc->old_gNB_DU_ue_id != 0xFFFFFFFF) { + asn1cSequenceAdd(out->protocolIEs.list, F1AP_DLRRCMessageTransferIEs_t, ie3); + ie3->id = F1AP_ProtocolIE_ID_id_oldgNB_DU_UE_F1AP_ID; + ie3->criticality = F1AP_Criticality_reject; + ie3->value.present = F1AP_DLRRCMessageTransferIEs__value_PR_NOTHING; + ie3->value.choice.oldgNB_DU_UE_F1AP_ID = f1ap_dl_rrc->old_gNB_DU_ue_id; + }*/ /* mandatory */ /* c4. SRBID */ - ie = (F1AP_DLRRCMessageTransferIEs_t *)calloc(1, sizeof(F1AP_DLRRCMessageTransferIEs_t)); - ie->id = F1AP_ProtocolIE_ID_id_SRBID; - ie->criticality = F1AP_Criticality_reject; - ie->value.present = F1AP_DLRRCMessageTransferIEs__value_PR_SRBID; - ie->value.choice.SRBID = f1ap_dl_rrc->srb_id; - ASN_SEQUENCE_ADD(&out->protocolIEs.list, ie); + asn1cSequenceAdd(out->protocolIEs.list, F1AP_DLRRCMessageTransferIEs_t, ie4); + ie4->id = F1AP_ProtocolIE_ID_id_SRBID; + ie4->criticality = F1AP_Criticality_reject; + ie4->value.present = F1AP_DLRRCMessageTransferIEs__value_PR_SRBID; + ie4->value.choice.SRBID = f1ap_dl_rrc->srb_id; /* optional */ /* c5. ExecuteDuplication */ if (f1ap_dl_rrc->execute_duplication) { - ie = (F1AP_DLRRCMessageTransferIEs_t *)calloc(1, sizeof(F1AP_DLRRCMessageTransferIEs_t)); - ie->id = F1AP_ProtocolIE_ID_id_ExecuteDuplication; - ie->criticality = F1AP_Criticality_ignore; - ie->value.present = F1AP_DLRRCMessageTransferIEs__value_PR_ExecuteDuplication; - ie->value.choice.ExecuteDuplication = F1AP_ExecuteDuplication_true; - ASN_SEQUENCE_ADD(&out->protocolIEs.list, ie); + asn1cSequenceAdd(out->protocolIEs.list, F1AP_DLRRCMessageTransferIEs_t, ie5); + ie5->id = F1AP_ProtocolIE_ID_id_ExecuteDuplication; + ie5->criticality = F1AP_Criticality_ignore; + ie5->value.present = F1AP_DLRRCMessageTransferIEs__value_PR_ExecuteDuplication; + ie5->value.choice.ExecuteDuplication = F1AP_ExecuteDuplication_true; } // issue in here /* mandatory */ /* c6. RRCContainer */ - ie = (F1AP_DLRRCMessageTransferIEs_t *)calloc(1, sizeof(F1AP_DLRRCMessageTransferIEs_t)); - ie->id = F1AP_ProtocolIE_ID_id_RRCContainer; - ie->criticality = F1AP_Criticality_reject; - ie->value.present = F1AP_DLRRCMessageTransferIEs__value_PR_RRCContainer; - OCTET_STRING_fromBuf(&ie->value.choice.RRCContainer, (const char*)f1ap_dl_rrc->rrc_container, f1ap_dl_rrc->rrc_container_length); - ASN_SEQUENCE_ADD(&out->protocolIEs.list, ie); - - if (RC.nrrrc && RC.nrrrc[GNB_INSTANCE_TO_MODULE_ID(instance)]->node_type == ngran_gNB_CU) { - LOG_I(F1AP, "%s() RRCContainer size %d: ", __func__, f1ap_dl_rrc->rrc_container_length); - for (int i = 0; i < ie->value.choice.RRCContainer.size; i++) - printf("%02x ", f1ap_dl_rrc->rrc_container[i]); - printf("\n"); - } + asn1cSequenceAdd(out->protocolIEs.list, F1AP_DLRRCMessageTransferIEs_t, ie6); + ie6->id = F1AP_ProtocolIE_ID_id_RRCContainer; + ie6->criticality = F1AP_Criticality_reject; + ie6->value.present = F1AP_DLRRCMessageTransferIEs__value_PR_RRCContainer; + OCTET_STRING_fromBuf(&ie6->value.choice.RRCContainer, + (const char *)f1ap_dl_rrc->rrc_container, f1ap_dl_rrc->rrc_container_length); /* optional */ /* c7. RAT_FrequencyPriorityInformation */ - /* TODO */ - int endc=1; - ie = (F1AP_DLRRCMessageTransferIEs_t *)calloc(1, sizeof(F1AP_DLRRCMessageTransferIEs_t)); - ie->id = F1AP_ProtocolIE_ID_id_RAT_FrequencyPriorityInformation; - ie->criticality = F1AP_Criticality_reject; - ie->value.present = F1AP_DLRRCMessageTransferIEs__value_PR_RAT_FrequencyPriorityInformation; - if (endc==1) { - ie->value.choice.RAT_FrequencyPriorityInformation.present = F1AP_RAT_FrequencyPriorityInformation_PR_eNDC; - ie->value.choice.RAT_FrequencyPriorityInformation.choice.eNDC = 123L; - } - else { - ie->value.choice.RAT_FrequencyPriorityInformation.present = F1AP_RAT_FrequencyPriorityInformation_PR_nGRAN; - ie->value.choice.RAT_FrequencyPriorityInformation.choice.nGRAN = 11L; - } + /* TODO */ + if (0) { + int endc=1; + asn1cSequenceAdd(out->protocolIEs.list, F1AP_DLRRCMessageTransferIEs_t, ie7); + ie7->id = F1AP_ProtocolIE_ID_id_RAT_FrequencyPriorityInformation; + ie7->criticality = F1AP_Criticality_reject; + ie7->value.present = F1AP_DLRRCMessageTransferIEs__value_PR_RAT_FrequencyPriorityInformation; + + if (endc==1) { + ie7->value.choice.RAT_FrequencyPriorityInformation.present = F1AP_RAT_FrequencyPriorityInformation_PR_eNDC; + ie7->value.choice.RAT_FrequencyPriorityInformation.choice.eNDC = 123L; + } else { + ie7->value.choice.RAT_FrequencyPriorityInformation.present = F1AP_RAT_FrequencyPriorityInformation_PR_nGRAN; + ie7->value.choice.RAT_FrequencyPriorityInformation.choice.nGRAN = 11L; + } + //ie->value.choice.RAT_FrequencyPriorityInformation.present = F1AP_RAT_FrequencyPriorityInformation_PR_rAT_FrequencySelectionPriority; //ie->value.choice.RAT_FrequencyPriorityInformation.choice.rAT_FrequencySelectionPriority = 123L; - ASN_SEQUENCE_ADD(&out->protocolIEs.list, ie); - + } + /* encode */ if (f1ap_encode_pdu(&pdu, &buffer, &len) < 0) { LOG_E(F1AP, "Failed to encode F1 DL RRC MESSAGE TRANSFER \n"); return -1; } - cu_f1ap_itti_send_sctp_data_req(instance, f1ap_assoc_id /* BK: fix me*/ , buffer, len, 0 /* BK: fix me*/); - + f1ap_itti_send_sctp_data_req(true, instance, buffer, len, 0 /* BK: fix me*/); return 0; } /* UL RRC Message Transfer */ - int CU_handle_UL_RRC_MESSAGE_TRANSFER(instance_t instance, uint32_t assoc_id, uint32_t stream, F1AP_F1AP_PDU_t *pdu) { - LOG_D(F1AP, "CU_handle_UL_RRC_MESSAGE_TRANSFER \n"); - F1AP_ULRRCMessageTransfer_t *container; F1AP_ULRRCMessageTransferIEs_t *ie; - uint64_t cu_ue_f1ap_id; uint64_t du_ue_f1ap_id; uint64_t srb_id; - DevAssert(pdu != NULL); - + if (stream != 0) { LOG_E(F1AP, "[SCTP %d] Received F1 on stream != 0 (%d)\n", - assoc_id, stream); + assoc_id, stream); return -1; } container = &pdu->choice.initiatingMessage->value.choice.ULRRCMessageTransfer; - - /* GNB_CU_UE_F1AP_ID */ F1AP_FIND_PROTOCOLIE_BY_ID(F1AP_ULRRCMessageTransferIEs_t, ie, container, F1AP_ProtocolIE_ID_id_gNB_CU_UE_F1AP_ID, true); cu_ue_f1ap_id = ie->value.choice.GNB_CU_UE_F1AP_ID; - LOG_D(F1AP, "cu_ue_f1ap_id %lu associated with RNTI %x\n", cu_ue_f1ap_id, f1ap_get_rnti_by_cu_id(&f1ap_cu_inst[instance], cu_ue_f1ap_id)); - - + LOG_D(F1AP, "cu_ue_f1ap_id %lu associated with RNTI %x\n", + cu_ue_f1ap_id, f1ap_get_rnti_by_cu_id(CUtype, instance, cu_ue_f1ap_id)); /* GNB_DU_UE_F1AP_ID */ F1AP_FIND_PROTOCOLIE_BY_ID(F1AP_ULRRCMessageTransferIEs_t, ie, container, F1AP_ProtocolIE_ID_id_gNB_DU_UE_F1AP_ID, true); du_ue_f1ap_id = ie->value.choice.GNB_DU_UE_F1AP_ID; - LOG_D(F1AP, "du_ue_f1ap_id %lu associated with RNTI %x\n", du_ue_f1ap_id, f1ap_get_rnti_by_cu_id(&f1ap_cu_inst[instance], du_ue_f1ap_id)); - - + LOG_D(F1AP, "du_ue_f1ap_id %lu associated with RNTI %x\n", + du_ue_f1ap_id, f1ap_get_rnti_by_cu_id(CUtype, instance, du_ue_f1ap_id)); /* mandatory */ /* SRBID */ F1AP_FIND_PROTOCOLIE_BY_ID(F1AP_ULRRCMessageTransferIEs_t, ie, container, F1AP_ProtocolIE_ID_id_SRBID, true); srb_id = ie->value.choice.SRBID; - if (srb_id < 1 ) + + if (srb_id < 1 ) LOG_E(F1AP, "Unexpected UL RRC MESSAGE for srb_id %lu \n", srb_id); - else + else LOG_D(F1AP, "UL RRC MESSAGE for srb_id %lu in DCCH \n", srb_id); - // issue in here /* mandatory */ /* RRC Container */ F1AP_FIND_PROTOCOLIE_BY_ID(F1AP_ULRRCMessageTransferIEs_t, ie, container, F1AP_ProtocolIE_ID_id_RRCContainer, true); - // print message in debug mode - - // create an ITTI message and copy SDU - - /* - - message_p = itti_alloc_new_message (TASK_CU_F1, 0, RRC_DCCH_DATA_IND); - - RRC_DCCH_DATA_IND (message_p).sdu_p = malloc(ie->value.choice.RRCContainer.size); - - RRC_DCCH_DATA_IND (message_p).sdu_size = ie->value.choice.RRCContainer.size; - memcpy(RRC_DCCH_DATA_IND (message_p).sdu_p, ie->value.choice.RRCContainer.buf, - ie->value.choice.RRCContainer.size); - - RRC_DCCH_DATA_IND (message_p).dcch_index = srb_id; - RRC_DCCH_DATA_IND (message_p).rnti = f1ap_get_rnti_by_cu_id(&f1ap_cu_inst[instance], cu_ue_f1ap_id); - RRC_DCCH_DATA_IND (message_p).module_id = instance; - RRC_DCCH_DATA_IND (message_p).eNB_index = instance; // not needed for CU - - itti_send_msg_to_task(TASK_RRC_ENB, instance, message_p); - */ - protocol_ctxt_t ctxt; - ctxt.module_id = instance; + protocol_ctxt_t ctxt={0}; ctxt.instance = instance; - ctxt.rnti = f1ap_get_rnti_by_cu_id(&f1ap_cu_inst[instance], cu_ue_f1ap_id); + ctxt.module_id = instance; + ctxt.rnti = f1ap_get_rnti_by_cu_id(CUtype, instance, cu_ue_f1ap_id); ctxt.enb_flag = 1; ctxt.eNB_index = 0; - ctxt.configured = 1; mem_block_t *mb = get_free_mem_block(ie->value.choice.RRCContainer.size,__func__); - memcpy((void*)mb->data,(void*)ie->value.choice.RRCContainer.buf,ie->value.choice.RRCContainer.size); + memcpy((void *)mb->data,(void *)ie->value.choice.RRCContainer.buf,ie->value.choice.RRCContainer.size); LOG_I(F1AP, "Calling pdcp_data_ind for UE RNTI %x srb_id %lu with size %ld (DCCH) \n", ctxt.rnti, srb_id, ie->value.choice.RRCContainer.size); - //LOG_I(F1AP, "%s() RRCContainer size %lu: ", __func__, ie->value.choice.RRCContainer.size); //for (int i = 0; i < ie->value.choice.RRCContainer.size; i++) // printf("%02x ", mb->data[i]); //printf("\n"); - pdcp_data_ind (&ctxt, - 1, // srb_flag - 0, // embms_flag - srb_id, - ie->value.choice.RRCContainer.size, - mb); + 1, // srb_flag + 0, // embms_flag + srb_id, + ie->value.choice.RRCContainer.size, + mb, NULL, NULL); return 0; } diff --git a/openair2/F1AP/f1ap_cu_rrc_message_transfer.h b/openair2/F1AP/f1ap_cu_rrc_message_transfer.h index 68ebbfe41e81ad2704fd44733943cde85dd62cab..c8c9d3a6f9b79d117287d2df416c5435c68f26b6 100644 --- a/openair2/F1AP/f1ap_cu_rrc_message_transfer.h +++ b/openair2/F1AP/f1ap_cu_rrc_message_transfer.h @@ -34,9 +34,9 @@ #define F1AP_CU_RRC_MESSAGE_TRANSFER_H_ int CU_handle_INITIAL_UL_RRC_MESSAGE_TRANSFER(instance_t instance, - uint32_t assoc_id, - uint32_t stream, - F1AP_F1AP_PDU_t *pdu); + uint32_t assoc_id, + uint32_t stream, + F1AP_F1AP_PDU_t *pdu); int CU_send_DL_RRC_MESSAGE_TRANSFER(instance_t instance, f1ap_dl_rrc_message_t *f1ap_dl_rrc); diff --git a/openair2/F1AP/f1ap_cu_task.c b/openair2/F1AP/f1ap_cu_task.c index b261d8e85b2bd63b0af30ee4605b8f01d7504279..13f08b9458846c5118190b3adac681fe51257846 100644 --- a/openair2/F1AP/f1ap_cu_task.c +++ b/openair2/F1AP/f1ap_cu_task.c @@ -31,150 +31,134 @@ */ #include "f1ap_common.h" -#include "f1ap_handlers.h" #include "f1ap_cu_interface_management.h" #include "f1ap_cu_rrc_message_transfer.h" #include "f1ap_cu_ue_context_management.h" #include "f1ap_cu_task.h" #include "proto_agent.h" - -extern RAN_CONTEXT_t RC; -extern uint8_t proto_agent_flag; - -f1ap_setup_req_t *f1ap_du_data_from_du; -f1ap_cudu_inst_t f1ap_cu_inst[MAX_eNB]; - -void cu_task_handle_sctp_association_ind(instance_t instance, sctp_new_association_ind_t *sctp_new_association_ind) { - // Nothing +#include <openair3/ocp-gtpu/gtp_itf.h> + +//Fixme: Uniq dirty DU instance, by global var, datamodel need better management +instance_t CUuniqInstance=0; + +static instance_t cu_task_create_gtpu_instance_to_du(eth_params_t *IPaddrs) { + openAddr_t tmp= {0}; + strncpy(tmp.originHost, IPaddrs->my_addr, sizeof(tmp.originHost)-1); + strncpy(tmp.destinationHost, IPaddrs->remote_addr, sizeof(tmp.destinationHost)-1); + sprintf(tmp.originService, "%d", IPaddrs->my_portd); + sprintf(tmp.destinationService, "%d", IPaddrs->remote_portd); + return ocp_gtpv1Init(tmp); } -void cu_task_handle_sctp_association_resp(instance_t instance, sctp_new_association_resp_t *sctp_new_association_resp) { +static void cu_task_handle_sctp_association_ind(instance_t instance, sctp_new_association_ind_t *sctp_new_association_ind, + eth_params_t *IPaddrs) { + createF1inst(true, instance, NULL); + // save the assoc id + f1ap_setup_req_t *f1ap_cu_data=f1ap_req(true, instance); + f1ap_cu_data->assoc_id = sctp_new_association_ind->assoc_id; + f1ap_cu_data->sctp_in_streams = sctp_new_association_ind->in_streams; + f1ap_cu_data->sctp_out_streams = sctp_new_association_ind->out_streams; + f1ap_cu_data->default_sctp_stream_id = 0; + getCxt(CUtype, instance)->gtpInst=cu_task_create_gtpu_instance_to_du(IPaddrs); + AssertFatal(getCxt(CUtype, instance)->gtpInst>0,"Failed to create CU F1-U UDP listener"); + // Fixme: fully inconsistent instances management + // dirty global var is a bad fix + CUuniqInstance=getCxt(CUtype, instance)->gtpInst; +} +static void cu_task_handle_sctp_association_resp(instance_t instance, sctp_new_association_resp_t *sctp_new_association_resp) { DevAssert(sctp_new_association_resp != NULL); if (sctp_new_association_resp->sctp_state != SCTP_STATE_ESTABLISHED) { LOG_W(F1AP, "Received unsuccessful result for SCTP association (%u), instance %ld, cnx_id %u\n", - sctp_new_association_resp->sctp_state, - instance, - sctp_new_association_resp->ulp_cnx_id); - - if (sctp_new_association_resp->sctp_state == SCTP_STATE_SHUTDOWN) - proto_agent_stop(instance); - //f1ap_handle_setup_message(instance, sctp_new_association_resp->sctp_state == SCTP_STATE_SHUTDOWN); - return; // exit -1 for debugging + sctp_new_association_resp->sctp_state, + instance, + sctp_new_association_resp->ulp_cnx_id); + //if (sctp_new_association_resp->sctp_state == SCTP_STATE_SHUTDOWN) + //proto_agent_stop(instance); + //f1ap_handle_setup_message(instance, sctp_new_association_resp->sctp_state == SCTP_STATE_SHUTDOWN); + return; // exit -1 for debugging } - - // go to an init func - f1ap_du_data_from_du = (f1ap_setup_req_t *)calloc(1, sizeof(f1ap_setup_req_t)); - // save the assoc id - f1ap_du_data_from_du->assoc_id = sctp_new_association_resp->assoc_id; - f1ap_du_data_from_du->sctp_in_streams = sctp_new_association_resp->in_streams; - f1ap_du_data_from_du->sctp_out_streams = sctp_new_association_resp->out_streams; - - /* setup parameters for F1U and start the server */ - const cudu_params_t params = (RC.nrrrc && RC.nrrrc[instance]->node_type == ngran_gNB_CU) ? (cudu_params_t){ - .local_ipv4_address = RC.nrrrc[instance]->eth_params_s.my_addr, - .local_port = RC.nrrrc[instance]->eth_params_s.my_portd, - .remote_ipv4_address = RC.nrrrc[instance]->eth_params_s.remote_addr, - .remote_port = RC.nrrrc[instance]->eth_params_s.remote_portd - } : (cudu_params_t){ - .local_ipv4_address = RC.rrc[instance]->eth_params_s.my_addr, - .local_port = RC.rrc[instance]->eth_params_s.my_portd, - .remote_ipv4_address = RC.rrc[instance]->eth_params_s.remote_addr, - .remote_port = RC.rrc[instance]->eth_params_s.remote_portd - }; - AssertFatal(proto_agent_start(instance, ¶ms) == 0, - "could not start PROTO_AGENT for F1U on instance %ld!\n", instance); - proto_agent_flag = 1; } -void cu_task_handle_sctp_data_ind(instance_t instance, sctp_data_ind_t *sctp_data_ind) { +static void cu_task_handle_sctp_data_ind(instance_t instance, sctp_data_ind_t *sctp_data_ind) { int result; - DevAssert(sctp_data_ind != NULL); - f1ap_handle_message(instance, sctp_data_ind->assoc_id, sctp_data_ind->stream, - sctp_data_ind->buffer, sctp_data_ind->buffer_length); - + sctp_data_ind->buffer, sctp_data_ind->buffer_length); result = itti_free(TASK_UNKNOWN, sctp_data_ind->buffer); AssertFatal (result == EXIT_SUCCESS, "Failed to free memory (%d)!\n", result); } -void cu_task_send_sctp_init_req(instance_t enb_id) { +static void cu_task_send_sctp_init_req(instance_t instance, char *my_addr) { // 1. get the itti msg, and retrive the enb_id from the message // 2. use RC.rrc[enb_id] to fill the sctp_init_t with the ip, port // 3. creat an itti message to init - LOG_I(F1AP, "F1AP_CU_SCTP_REQ(create socket)\n"); MessageDef *message_p = NULL; - message_p = itti_alloc_new_message (TASK_CU_F1, 0, SCTP_INIT_MSG); message_p->ittiMsg.sctp_init.port = F1AP_PORT_NUMBER; message_p->ittiMsg.sctp_init.ppid = F1AP_SCTP_PPID; message_p->ittiMsg.sctp_init.ipv4 = 1; message_p->ittiMsg.sctp_init.ipv6 = 0; message_p->ittiMsg.sctp_init.nb_ipv4_addr = 1; - if (RC.nrrrc && RC.nrrrc[0]->node_type == ngran_gNB_CU) { - message_p->ittiMsg.sctp_init.ipv4_address[0] = inet_addr(RC.nrrrc[enb_id]->eth_params_s.my_addr); - } else{ - message_p->ittiMsg.sctp_init.ipv4_address[0] = inet_addr(RC.rrc[enb_id]->eth_params_s.my_addr); - } + message_p->ittiMsg.sctp_init.ipv4_address[0] = inet_addr(my_addr); /* * SR WARNING: ipv6 multi-homing fails sometimes for localhost. * * * * Disable it for now. */ message_p->ittiMsg.sctp_init.nb_ipv6_addr = 0; message_p->ittiMsg.sctp_init.ipv6_address[0] = "0:0:0:0:0:0:0:1"; - - itti_send_msg_to_task(TASK_SCTP, enb_id, message_p); + itti_send_msg_to_task(TASK_SCTP, instance, message_p); } - void *F1AP_CU_task(void *arg) { - MessageDef *received_msg = NULL; int result; - LOG_I(F1AP, "Starting F1AP at CU\n"); - // no RLC in CU, initialize mem pool for PDCP pool_buffer_init(); - itti_mark_task_ready(TASK_CU_F1); + eth_params_t *IPaddrs; + + // Hardcoded instance id! + if (RC.nrrrc && RC.nrrrc[0]->node_type == ngran_gNB_CU) + IPaddrs=&RC.nrrrc[0]->eth_params_s; + else + IPaddrs=&RC.rrc[0]->eth_params_s; - cu_task_send_sctp_init_req(0); + cu_task_send_sctp_init_req(0, IPaddrs->my_addr); while (1) { itti_receive_msg(TASK_CU_F1, &received_msg); - switch (ITTI_MSG_ID(received_msg)) { + switch (ITTI_MSG_ID(received_msg)) { case SCTP_NEW_ASSOCIATION_IND: LOG_I(F1AP, "CU Task Received SCTP_NEW_ASSOCIATION_IND for instance %ld\n", ITTI_MSG_DESTINATION_INSTANCE(received_msg)); - cu_task_handle_sctp_association_ind(ITTI_MSG_DESTINATION_INSTANCE(received_msg), - &received_msg->ittiMsg.sctp_new_association_ind); + cu_task_handle_sctp_association_ind(ITTI_MSG_ORIGIN_INSTANCE(received_msg), + &received_msg->ittiMsg.sctp_new_association_ind, + IPaddrs); break; case SCTP_NEW_ASSOCIATION_RESP: LOG_I(F1AP, "CU Task Received SCTP_NEW_ASSOCIATION_RESP for instance %ld\n", ITTI_MSG_DESTINATION_INSTANCE(received_msg)); cu_task_handle_sctp_association_resp(ITTI_MSG_DESTINATION_INSTANCE(received_msg), - &received_msg->ittiMsg.sctp_new_association_resp); + &received_msg->ittiMsg.sctp_new_association_resp); break; case SCTP_DATA_IND: LOG_I(F1AP, "CU Task Received SCTP_DATA_IND for Instance %ld\n", ITTI_MSG_DESTINATION_INSTANCE(received_msg)); cu_task_handle_sctp_data_ind(ITTI_MSG_DESTINATION_INSTANCE(received_msg), - &received_msg->ittiMsg.sctp_data_ind); + &received_msg->ittiMsg.sctp_data_ind); break; case F1AP_SETUP_RESP: // from rrc LOG_I(F1AP, "CU Task Received F1AP_SETUP_RESP\n"); - // CU_send_f1setup_resp(ITTI_MSG_DESTINATION_INSTANCE(received_msg), - // &F1AP_SETUP_RESP(received_msg)); CU_send_F1_SETUP_RESPONSE(ITTI_MSG_DESTINATION_INSTANCE(received_msg), - &F1AP_SETUP_RESP(received_msg)); + &F1AP_SETUP_RESP(received_msg)); break; case F1AP_GNB_CU_CONFIGURATION_UPDATE: // from rrc @@ -182,19 +166,19 @@ void *F1AP_CU_task(void *arg) { // CU_send_f1setup_resp(ITTI_MSG_DESTINATION_INSTANCE(received_msg), // &F1AP_SETUP_RESP(received_msg)); CU_send_gNB_CU_CONFIGURATION_UPDATE(ITTI_MSG_DESTINATION_INSTANCE(received_msg), - &F1AP_GNB_CU_CONFIGURATION_UPDATE(received_msg)); + &F1AP_GNB_CU_CONFIGURATION_UPDATE(received_msg)); break; case F1AP_DL_RRC_MESSAGE: // from rrc LOG_I(F1AP, "CU Task Received F1AP_DL_RRC_MESSAGE\n"); CU_send_DL_RRC_MESSAGE_TRANSFER(ITTI_MSG_DESTINATION_INSTANCE(received_msg), - &F1AP_DL_RRC_MESSAGE(received_msg)); + &F1AP_DL_RRC_MESSAGE(received_msg)); break; case F1AP_UE_CONTEXT_SETUP_REQ: // from rrc LOG_I(F1AP, "CU Task Received F1AP_UE_CONTEXT_SETUP_REQ\n"); CU_send_UE_CONTEXT_SETUP_REQUEST(ITTI_MSG_DESTINATION_INSTANCE(received_msg), - &F1AP_UE_CONTEXT_SETUP_REQ(received_msg)); + &F1AP_UE_CONTEXT_SETUP_REQ(received_msg)); break; case F1AP_UE_CONTEXT_RELEASE_CMD: // from rrc @@ -203,13 +187,13 @@ void *F1AP_CU_task(void *arg) { &F1AP_UE_CONTEXT_RELEASE_CMD(received_msg)); break; -// case F1AP_SETUP_RESPONSE: // This is from RRC -// CU_send_F1_SETUP_RESPONSE(instance, *f1ap_setup_ind, &(F1AP_SETUP_RESP) f1ap_setup_resp) -// break; - -// case F1AP_SETUP_FAILURE: // This is from RRC -// CU_send_F1_SETUP_FAILURE(instance, *f1ap_setup_ind, &(F1AP_SETUP_FAILURE) f1ap_setup_failure) -// break; + // case F1AP_SETUP_RESPONSE: // This is from RRC + // CU_send_F1_SETUP_RESPONSE(instance, *f1ap_setup_ind, &(F1AP_SETUP_RESP) f1ap_setup_resp) + // break; + + // case F1AP_SETUP_FAILURE: // This is from RRC + // CU_send_F1_SETUP_FAILURE(instance, *f1ap_setup_ind, &(F1AP_SETUP_FAILURE) f1ap_setup_failure) + // break; case TERMINATE_MESSAGE: LOG_W(F1AP, " *** Exiting F1AP thread\n"); @@ -221,9 +205,9 @@ void *F1AP_CU_task(void *arg) { ITTI_MSG_ID(received_msg), ITTI_MSG_NAME(received_msg)); break; } // switch + result = itti_free (ITTI_MSG_ORIGIN_ID(received_msg), received_msg); AssertFatal (result == EXIT_SUCCESS, "Failed to free memory (%d)!\n", result); - received_msg = NULL; } // while diff --git a/openair2/F1AP/f1ap_cu_task.h b/openair2/F1AP/f1ap_cu_task.h index dec844accfb0f00d840ff630cc0a6bcf94a66752..9048d2b157de6312c24a07dd58915283ca7fecb1 100644 --- a/openair2/F1AP/f1ap_cu_task.h +++ b/openair2/F1AP/f1ap_cu_task.h @@ -22,11 +22,6 @@ #ifndef F1AP_CU_TASK_H_ #define F1AP_CU_TASK_H_ -void cu_task_handle_sctp_association_ind(instance_t instance, sctp_new_association_ind_t *sctp_new_association_ind); -void cu_task_handle_sctp_association_resp(instance_t instance, sctp_new_association_resp_t *sctp_new_association_resp); -void cu_task_handle_sctp_data_ind(instance_t instance, sctp_data_ind_t *sctp_data_ind); -void cu_task_send_sctp_init_req(instance_t enb_id); - void *F1AP_CU_task(void *arg); #endif /* F1AP_CU_TASK_H_ */ diff --git a/openair2/F1AP/f1ap_cu_ue_context_management.c b/openair2/F1AP/f1ap_cu_ue_context_management.c index da723ba5a38f8612efb899afb1b2532a8be0d0f3..c68bfb3852f1119e445a47197c2452f666625be4 100644 --- a/openair2/F1AP/f1ap_cu_ue_context_management.c +++ b/openair2/F1AP/f1ap_cu_ue_context_management.c @@ -43,752 +43,589 @@ #include "rrc_eNB_S1AP.h" #include "rrc_eNB_GTPV1U.h" #include "openair2/RRC/NR/rrc_gNB_NGAP.h" +#include <openair3/ocp-gtpu/gtp_itf.h> -extern f1ap_setup_req_t *f1ap_du_data_from_du; -extern f1ap_cudu_inst_t f1ap_cu_inst[MAX_eNB]; -extern RAN_CONTEXT_t RC; -extern uint32_t f1ap_assoc_id; +static void setQos(F1AP_NonDynamic5QIDescriptor_t *toFill) { + asn1cCalloc(toFill, tmp); + /* fiveQI */ + tmp->fiveQI = 1L; -int CU_send_UE_CONTEXT_SETUP_REQUEST(instance_t instance, - f1ap_ue_context_setup_req_t *f1ap_ue_context_setup_req) { - F1AP_F1AP_PDU_t pdu; - F1AP_UEContextSetupRequest_t *out; - F1AP_UEContextSetupRequestIEs_t *ie; + /* OPTIONAL */ + /* qoSPriorityLevel */ + if (0) { + asn1cCallocOne(toFill->qoSPriorityLevel, 1L); + } - uint8_t *buffer; - uint32_t len; - int i = 0, j = 0; + /* OPTIONAL */ + /* averagingWindow */ + if (0) { + asn1cCallocOne(toFill->averagingWindow, 1L); + } + /* OPTIONAL */ + /* maxDataBurstVolume */ + if (0) { + asn1cCallocOne(toFill->maxDataBurstVolume, 1L); + } +} + +int CU_send_UE_CONTEXT_SETUP_REQUEST(instance_t instance, + f1ap_ue_context_setup_t *f1ap_ue_context_setup_req) { + F1AP_F1AP_PDU_t pdu= {0}; /* Create */ /* 0. Message Type */ - memset(&pdu, 0, sizeof(pdu)); pdu.present = F1AP_F1AP_PDU_PR_initiatingMessage; - pdu.choice.initiatingMessage = (F1AP_InitiatingMessage_t *)calloc(1, sizeof(F1AP_InitiatingMessage_t)); - pdu.choice.initiatingMessage->procedureCode = F1AP_ProcedureCode_id_UEContextSetup; - pdu.choice.initiatingMessage->criticality = F1AP_Criticality_reject; - pdu.choice.initiatingMessage->value.present = F1AP_InitiatingMessage__value_PR_UEContextSetupRequest; - out = &pdu.choice.initiatingMessage->value.choice.UEContextSetupRequest; - + asn1cCalloc(pdu.choice.initiatingMessage, tmp); + tmp->procedureCode = F1AP_ProcedureCode_id_UEContextSetup; + tmp->criticality = F1AP_Criticality_reject; + tmp->value.present = F1AP_InitiatingMessage__value_PR_UEContextSetupRequest; + F1AP_UEContextSetupRequest_t *out = &pdu.choice.initiatingMessage->value.choice.UEContextSetupRequest; /* mandatory */ /* c1. GNB_CU_UE_F1AP_ID */ - ie = (F1AP_UEContextSetupRequestIEs_t *)calloc(1, sizeof(F1AP_UEContextSetupRequestIEs_t)); - ie->id = F1AP_ProtocolIE_ID_id_gNB_CU_UE_F1AP_ID; - ie->criticality = F1AP_Criticality_reject; - ie->value.present = F1AP_UEContextSetupRequestIEs__value_PR_GNB_CU_UE_F1AP_ID; - ie->value.choice.GNB_CU_UE_F1AP_ID = f1ap_ue_context_setup_req->gNB_CU_ue_id; - ASN_SEQUENCE_ADD(&out->protocolIEs.list, ie); + asn1cSequenceAdd(out->protocolIEs.list, F1AP_UEContextSetupRequestIEs_t, ie1); + ie1->id = F1AP_ProtocolIE_ID_id_gNB_CU_UE_F1AP_ID; + ie1->criticality = F1AP_Criticality_reject; + ie1->value.present = F1AP_UEContextSetupRequestIEs__value_PR_GNB_CU_UE_F1AP_ID; + ie1->value.choice.GNB_CU_UE_F1AP_ID = f1ap_get_cu_ue_f1ap_id(CUtype, instance, f1ap_ue_context_setup_req->rnti); //f1ap_ue_context_setup_req->gNB_CU_ue_id; /* optional */ /* c2. GNB_DU_UE_F1AP_ID */ if (f1ap_ue_context_setup_req->gNB_DU_ue_id) { - ie = (F1AP_UEContextSetupRequestIEs_t *)calloc(1, sizeof(F1AP_UEContextSetupRequestIEs_t)); - ie->id = F1AP_ProtocolIE_ID_id_gNB_DU_UE_F1AP_ID; - ie->criticality = F1AP_Criticality_ignore; - ie->value.present = F1AP_UEContextSetupRequestIEs__value_PR_GNB_DU_UE_F1AP_ID; - ie->value.choice.GNB_DU_UE_F1AP_ID = *f1ap_ue_context_setup_req->gNB_DU_ue_id; - ASN_SEQUENCE_ADD(&out->protocolIEs.list, ie); + asn1cSequenceAdd(out->protocolIEs.list, F1AP_UEContextSetupRequestIEs_t, ie2); + ie2->id = F1AP_ProtocolIE_ID_id_gNB_DU_UE_F1AP_ID; + ie2->criticality = F1AP_Criticality_ignore; + ie2->value.present = F1AP_UEContextSetupRequestIEs__value_PR_GNB_DU_UE_F1AP_ID; + ie2->value.choice.GNB_DU_UE_F1AP_ID = f1ap_get_du_ue_f1ap_id(CUtype, instance, f1ap_ue_context_setup_req->rnti); //*f1ap_ue_context_setup_req->gNB_DU_ue_id; } /* mandatory */ /* c3. SpCell_ID */ - ie = (F1AP_UEContextSetupRequestIEs_t *)calloc(1, sizeof(F1AP_UEContextSetupRequestIEs_t)); - ie->id = F1AP_ProtocolIE_ID_id_SpCell_ID; - ie->criticality = F1AP_Criticality_reject; - ie->value.present = F1AP_UEContextSetupRequestIEs__value_PR_NRCGI; + asn1cSequenceAdd(out->protocolIEs.list, F1AP_UEContextSetupRequestIEs_t, ie3); + ie3->id = F1AP_ProtocolIE_ID_id_SpCell_ID; + ie3->criticality = F1AP_Criticality_reject; + ie3->value.present = F1AP_UEContextSetupRequestIEs__value_PR_NRCGI; /* - nRCGI */ - F1AP_NRCGI_t nRCGI; - memset(&nRCGI, 0, sizeof(F1AP_NRCGI_t)); - MCC_MNC_TO_PLMNID(f1ap_ue_context_setup_req->mcc, - f1ap_ue_context_setup_req->mnc, - f1ap_ue_context_setup_req->mnc_digit_length, - &nRCGI.pLMN_Identity); - NR_CELL_ID_TO_BIT_STRING(f1ap_ue_context_setup_req->nr_cellid, &nRCGI.nRCellIdentity); - - ie->value.choice.NRCGI = nRCGI; - - ASN_SEQUENCE_ADD(&out->protocolIEs.list, ie); - + addnRCGI(ie3->value.choice.NRCGI, f1ap_ue_context_setup_req); /* mandatory */ /* c4. ServCellIndex */ - ie = (F1AP_UEContextSetupRequestIEs_t *)calloc(1, sizeof(F1AP_UEContextSetupRequestIEs_t)); - ie->id = F1AP_ProtocolIE_ID_id_ServCellIndex; - ie->criticality = F1AP_Criticality_reject; - ie->value.present = F1AP_UEContextSetupRequestIEs__value_PR_ServCellIndex; - ie->value.choice.ServCellIndex = 2; - ASN_SEQUENCE_ADD(&out->protocolIEs.list, ie); + asn1cSequenceAdd(out->protocolIEs.list, F1AP_UEContextSetupRequestIEs_t, ie4); + ie4->id = F1AP_ProtocolIE_ID_id_ServCellIndex; + ie4->criticality = F1AP_Criticality_reject; + ie4->value.present = F1AP_UEContextSetupRequestIEs__value_PR_ServCellIndex; + ie4->value.choice.ServCellIndex = 0; /* optional */ /* c5. CellULConfigured */ if (0) { - ie = (F1AP_UEContextSetupRequestIEs_t *)calloc(1, sizeof(F1AP_UEContextSetupRequestIEs_t)); - ie->id = F1AP_ProtocolIE_ID_id_SpCellULConfigured; - ie->criticality = F1AP_Criticality_ignore; - ie->value.present = F1AP_UEContextSetupRequestIEs__value_PR_CellULConfigured; - ie->value.choice.CellULConfigured = F1AP_CellULConfigured_ul; - ASN_SEQUENCE_ADD(&out->protocolIEs.list, ie); + asn1cSequenceAdd(out->protocolIEs.list, F1AP_UEContextSetupRequestIEs_t, ie5); + ie5->id = F1AP_ProtocolIE_ID_id_SpCellULConfigured; + ie5->criticality = F1AP_Criticality_ignore; + ie5->value.present = F1AP_UEContextSetupRequestIEs__value_PR_CellULConfigured; + ie5->value.choice.CellULConfigured = F1AP_CellULConfigured_ul; } /* mandatory */ /* c6. CUtoDURRCInformation */ - ie = (F1AP_UEContextSetupRequestIEs_t *)calloc(1, sizeof(F1AP_UEContextSetupRequestIEs_t)); - ie->id = F1AP_ProtocolIE_ID_id_CUtoDURRCInformation; - ie->criticality = F1AP_Criticality_reject; - ie->value.present = F1AP_UEContextSetupRequestIEs__value_PR_CUtoDURRCInformation; - + asn1cSequenceAdd(out->protocolIEs.list, F1AP_UEContextSetupRequestIEs_t, ie6); + ie6->id = F1AP_ProtocolIE_ID_id_CUtoDURRCInformation; + ie6->criticality = F1AP_Criticality_reject; + ie6->value.present = F1AP_UEContextSetupRequestIEs__value_PR_CUtoDURRCInformation; + /* optional */ /* 6.1 cG_ConfigInfo */ - ie->value.choice.CUtoDURRCInformation.cG_ConfigInfo = (F1AP_CG_ConfigInfo_t *)calloc(1, sizeof(F1AP_CG_ConfigInfo_t)); - OCTET_STRING_fromBuf(ie->value.choice.CUtoDURRCInformation.cG_ConfigInfo, "asdsa1d32sa1d31asd31as", - strlen("asdsa1d32sa1d31asd31as")); - /* optional */ - /* 6.2 uE_CapabilityRAT_ContainerList */ - ie->value.choice.CUtoDURRCInformation.uE_CapabilityRAT_ContainerList = (F1AP_UE_CapabilityRAT_ContainerList_t *)calloc(1, sizeof(F1AP_UE_CapabilityRAT_ContainerList_t)); - OCTET_STRING_fromBuf(ie->value.choice.CUtoDURRCInformation.uE_CapabilityRAT_ContainerList, "asdsa1d32sa1d31asd31as", - strlen("asdsa1d32sa1d31asd31as")); - /* optional */ - /* 6.3 measConfig */ - ie->value.choice.CUtoDURRCInformation.measConfig = (F1AP_MeasConfig_t *)calloc(1, sizeof(F1AP_MeasConfig_t)); - OCTET_STRING_fromBuf(ie->value.choice.CUtoDURRCInformation.measConfig, "asdsa1d32sa1d31asd31as", - strlen("asdsa1d32sa1d31asd31as")); - - ASN_SEQUENCE_ADD(&out->protocolIEs.list, ie); - + if (0) { + const char cG_ConfigInfoStr[]="asdsa1d32sa1d31asd31as"; + asn1cCalloc(ie6->value.choice.CUtoDURRCInformation.cG_ConfigInfo, cG_ConfigInfo); + OCTET_STRING_fromBuf(cG_ConfigInfo, cG_ConfigInfoStr, strlen( cG_ConfigInfoStr )) ; + /* optional */ + /* 6.2 uE_CapabilityRAT_ContainerList */ + asn1cCalloc(ie6->value.choice.CUtoDURRCInformation.uE_CapabilityRAT_ContainerList, uE_CapabilityRAT_ContainerList ); + OCTET_STRING_fromBuf(uE_CapabilityRAT_ContainerList, cG_ConfigInfoStr, strlen( cG_ConfigInfoStr )) ; + /* optional */ + /* 6.3 measConfig */ + asn1cCalloc(ie6->value.choice.CUtoDURRCInformation.measConfig, measConfig); + OCTET_STRING_fromBuf(measConfig, cG_ConfigInfoStr, strlen( cG_ConfigInfoStr )) ; + } /* mandatory */ /* c7. Candidate_SpCell_List */ - ie = (F1AP_UEContextSetupRequestIEs_t *)calloc(1, sizeof(F1AP_UEContextSetupRequestIEs_t)); - ie->id = F1AP_ProtocolIE_ID_id_Candidate_SpCell_List; //90 - ie->criticality = F1AP_Criticality_ignore; - ie->value.present = F1AP_UEContextSetupRequestIEs__value_PR_Candidate_SpCell_List; - - for (i=0; - i<0; - i++) { + asn1cSequenceAdd(out->protocolIEs.list, F1AP_UEContextSetupRequestIEs_t, ie7); + ie7->id = F1AP_ProtocolIE_ID_id_Candidate_SpCell_List; //90 + ie7->criticality = F1AP_Criticality_ignore; + ie7->value.present = F1AP_UEContextSetupRequestIEs__value_PR_Candidate_SpCell_List; - F1AP_Candidate_SpCell_ItemIEs_t *candidate_spCell_item_ies; - candidate_spCell_item_ies = (F1AP_Candidate_SpCell_ItemIEs_t *)calloc(1, sizeof(F1AP_Candidate_SpCell_ItemIEs_t)); + for (int i=0; i<1; i++) { + asn1cSequenceAdd(ie7->value.choice.Candidate_SpCell_List.list,F1AP_Candidate_SpCell_ItemIEs_t, candidate_spCell_item_ies); candidate_spCell_item_ies->id = F1AP_ProtocolIE_ID_id_Candidate_SpCell_Item; // 91 candidate_spCell_item_ies->criticality = F1AP_Criticality_reject; candidate_spCell_item_ies->value.present = F1AP_Candidate_SpCell_ItemIEs__value_PR_Candidate_SpCell_Item; - /* 7.1 Candidate_SpCell_Item */ - F1AP_Candidate_SpCell_Item_t candidate_spCell_item; - memset((void *)&candidate_spCell_item, 0, sizeof(F1AP_Candidate_SpCell_Item_t)); - + F1AP_Candidate_SpCell_Item_t *candidate_spCell_item= + &candidate_spCell_item_ies->value.choice.Candidate_SpCell_Item; /* - candidate_SpCell_ID */ - F1AP_NRCGI_t nRCGI; + //FixMe: first cell ??? + addnRCGI(candidate_spCell_item->candidate_SpCell_ID,f1ap_ue_context_setup_req); /* TODO add correct mcc/mnc */ - MCC_MNC_TO_PLMNID(f1ap_ue_context_setup_req->mcc, - f1ap_ue_context_setup_req->mnc, - f1ap_ue_context_setup_req->mnc_digit_length, - &nRCGI.pLMN_Identity); - NR_CELL_ID_TO_BIT_STRING(f1ap_ue_context_setup_req->nr_cellid, &nRCGI.nRCellIdentity); - - candidate_spCell_item.candidate_SpCell_ID = nRCGI; - - /* ADD */ - candidate_spCell_item_ies->value.choice.Candidate_SpCell_Item = candidate_spCell_item; - ASN_SEQUENCE_ADD(&ie->value.choice.Candidate_SpCell_List.list, - candidate_spCell_item_ies); } - ASN_SEQUENCE_ADD(&out->protocolIEs.list, ie); /* optional */ /* c8. DRXCycle */ if (0) { - ie = (F1AP_UEContextSetupRequestIEs_t *)calloc(1, sizeof(F1AP_UEContextSetupRequestIEs_t)); - ie->id = F1AP_ProtocolIE_ID_id_DRXCycle; - ie->criticality = F1AP_Criticality_ignore; - ie->value.present = F1AP_UEContextSetupRequestIEs__value_PR_DRXCycle; + asn1cSequenceAdd(out->protocolIEs.list, F1AP_UEContextSetupRequestIEs_t, ie8); + ie8->id = F1AP_ProtocolIE_ID_id_DRXCycle; + ie8->criticality = F1AP_Criticality_ignore; + ie8->value.present = F1AP_UEContextSetupRequestIEs__value_PR_DRXCycle; /* 8.1 longDRXCycleLength */ - ie->value.choice.DRXCycle.longDRXCycleLength = F1AP_LongDRXCycleLength_ms10; // enum + ie8->value.choice.DRXCycle.longDRXCycleLength = F1AP_LongDRXCycleLength_ms10; // enum /* optional */ /* 8.2 shortDRXCycleLength */ if (0) { - ie->value.choice.DRXCycle.shortDRXCycleLength = (F1AP_ShortDRXCycleLength_t *)calloc(1, sizeof(F1AP_ShortDRXCycleLength_t)); - *ie->value.choice.DRXCycle.shortDRXCycleLength = F1AP_ShortDRXCycleLength_ms2; // enum + asn1cCallocOne(ie6->value.choice.DRXCycle.shortDRXCycleLength, + F1AP_ShortDRXCycleLength_ms2); // enum } /* optional */ /* 8.3 shortDRXCycleTimer */ if (0) { - ie->value.choice.DRXCycle.shortDRXCycleTimer = (F1AP_ShortDRXCycleTimer_t *)calloc(1, sizeof(F1AP_ShortDRXCycleTimer_t)); - *ie->value.choice.DRXCycle.shortDRXCycleTimer = 123L; + asn1cCallocOne(ie8->value.choice.DRXCycle.shortDRXCycleTimer, + 123L); } - ASN_SEQUENCE_ADD(&out->protocolIEs.list, ie); } /* optional */ /* c9. ResourceCoordinationTransferContainer */ if (0) { - ie = (F1AP_UEContextSetupRequestIEs_t *)calloc(1, sizeof(F1AP_UEContextSetupRequestIEs_t)); - ie->id = F1AP_ProtocolIE_ID_id_ResourceCoordinationTransferContainer; - ie->criticality = F1AP_Criticality_ignore; - ie->value.present = F1AP_UEContextSetupRequestIEs__value_PR_ResourceCoordinationTransferContainer; - - ie->value.choice.ResourceCoordinationTransferContainer.buf = malloc(4); - ie->value.choice.ResourceCoordinationTransferContainer.size = 4; - strncpy((char *)ie->value.choice.ResourceCoordinationTransferContainer.buf, "123", 4); - - - OCTET_STRING_fromBuf(&ie->value.choice.ResourceCoordinationTransferContainer, "asdsa1d32sa1d31asd31as", + asn1cSequenceAdd(out->protocolIEs.list, F1AP_UEContextSetupRequestIEs_t, ie9); + ie9->id = F1AP_ProtocolIE_ID_id_ResourceCoordinationTransferContainer; + ie9->criticality = F1AP_Criticality_ignore; + ie9->value.present = F1AP_UEContextSetupRequestIEs__value_PR_ResourceCoordinationTransferContainer; + ie9->value.choice.ResourceCoordinationTransferContainer.buf = malloc(4); + ie9->value.choice.ResourceCoordinationTransferContainer.size = 4; + strncpy((char *)ie9->value.choice.ResourceCoordinationTransferContainer.buf, "123", 4); + OCTET_STRING_fromBuf(&ie9->value.choice.ResourceCoordinationTransferContainer, "asdsa1d32sa1d31asd31as", strlen("asdsa1d32sa1d31asd31as")); - - ASN_SEQUENCE_ADD(&out->protocolIEs.list, ie); } /* mandatory */ /* c10. SCell_ToBeSetup_List */ - ie = (F1AP_UEContextSetupRequestIEs_t *)calloc(1, sizeof(F1AP_UEContextSetupRequestIEs_t)); - ie->id = F1AP_ProtocolIE_ID_id_SCell_ToBeSetup_List; - ie->criticality = F1AP_Criticality_ignore; - ie->value.present = F1AP_UEContextSetupRequestIEs__value_PR_SCell_ToBeSetup_List; - - for (i=0; - i<0; - i++) { - // - F1AP_SCell_ToBeSetup_ItemIEs_t *scell_toBeSetup_item_ies; - scell_toBeSetup_item_ies = (F1AP_SCell_ToBeSetup_ItemIEs_t *)calloc(1, sizeof(F1AP_SCell_ToBeSetup_ItemIEs_t)); - scell_toBeSetup_item_ies->id = F1AP_ProtocolIE_ID_id_SCell_ToBeSetup_Item; //53 - scell_toBeSetup_item_ies->criticality = F1AP_Criticality_ignore; - scell_toBeSetup_item_ies->value.present = F1AP_SCell_ToBeSetup_ItemIEs__value_PR_SCell_ToBeSetup_Item; - - /* 10.1 SCell_ToBeSetup_Item */ - F1AP_SCell_ToBeSetup_Item_t scell_toBeSetup_item; - memset((void *)&scell_toBeSetup_item, 0, sizeof(F1AP_SCell_ToBeSetup_Item_t)); - - /* 10.1.1 sCell_ID */ - F1AP_NRCGI_t nRCGI; - /* TODO correct MCC/MNC */ - MCC_MNC_TO_PLMNID(f1ap_ue_context_setup_req->mcc, - f1ap_ue_context_setup_req->mnc, - f1ap_ue_context_setup_req->mnc_digit_length, - &nRCGI.pLMN_Identity); - NR_CELL_ID_TO_BIT_STRING(12345678, &nRCGI.nRCellIdentity); - scell_toBeSetup_item.sCell_ID = nRCGI; - - /* 10.1.2 sCellIndex */ - scell_toBeSetup_item.sCellIndex = 3; // issue here - - /* OPTIONAL */ - /* 10.1.3 sCellULConfigured*/ - if (0) { - scell_toBeSetup_item.sCellULConfigured = (F1AP_CellULConfigured_t *)calloc(1, sizeof(F1AP_CellULConfigured_t)); - *scell_toBeSetup_item.sCellULConfigured = F1AP_CellULConfigured_ul_and_sul; // enum - } - - /* ADD */ - scell_toBeSetup_item_ies->value.choice.SCell_ToBeSetup_Item = scell_toBeSetup_item; - - ASN_SEQUENCE_ADD(&ie->value.choice.SCell_ToBeSetup_List.list, - scell_toBeSetup_item_ies); - } - ASN_SEQUENCE_ADD(&out->protocolIEs.list, ie); + asn1cSequenceAdd(out->protocolIEs.list, F1AP_UEContextSetupRequestIEs_t, ie10); + ie10->id = F1AP_ProtocolIE_ID_id_SCell_ToBeSetup_List; + ie10->criticality = F1AP_Criticality_ignore; + ie10->value.present = F1AP_UEContextSetupRequestIEs__value_PR_SCell_ToBeSetup_List; + for (int i=0; i<1; i++) { + // + asn1cSequenceAdd(ie10->value.choice.SCell_ToBeSetup_List.list, F1AP_SCell_ToBeSetup_ItemIEs_t, scell_toBeSetup_item_ies); + scell_toBeSetup_item_ies->id = F1AP_ProtocolIE_ID_id_SCell_ToBeSetup_Item; //53 + scell_toBeSetup_item_ies->criticality = F1AP_Criticality_ignore; + scell_toBeSetup_item_ies->value.present = F1AP_SCell_ToBeSetup_ItemIEs__value_PR_SCell_ToBeSetup_Item; + /* 10.1 SCell_ToBeSetup_Item */ + F1AP_SCell_ToBeSetup_Item_t *scell_toBeSetup_item=&scell_toBeSetup_item_ies->value.choice.SCell_ToBeSetup_Item; + /* 10.1.1 sCell_ID */ + addnRCGI(scell_toBeSetup_item->sCell_ID, f1ap_ue_context_setup_req); + /* TODO correct MCC/MNC */ + /* 10.1.2 sCellIndex */ + scell_toBeSetup_item->sCellIndex = 3; // issue here + + /* OPTIONAL */ + /* 10.1.3 sCellULConfigured*/ + if (0) { + asn1cCallocOne(scell_toBeSetup_item->sCellULConfigured, + F1AP_CellULConfigured_ul_and_sul); // enum + } + } /* mandatory */ /* c11. SRBs_ToBeSetup_List */ - ie = (F1AP_UEContextSetupRequestIEs_t *)calloc(1, sizeof(F1AP_UEContextSetupRequestIEs_t)); - ie->id = F1AP_ProtocolIE_ID_id_SRBs_ToBeSetup_List; - ie->criticality = F1AP_Criticality_reject; // ? - ie->value.present = F1AP_UEContextSetupRequestIEs__value_PR_SRBs_ToBeSetup_List; - - for (i=0; - i<0; - i++) { + asn1cSequenceAdd(out->protocolIEs.list, F1AP_UEContextSetupRequestIEs_t, ie11); + ie11->id = F1AP_ProtocolIE_ID_id_SRBs_ToBeSetup_List; + ie11->criticality = F1AP_Criticality_reject; // ? + ie11->value.present = F1AP_UEContextSetupRequestIEs__value_PR_SRBs_ToBeSetup_List; + + for (int i=0; i<f1ap_ue_context_setup_req->srbs_to_be_setup_length; i++) { // - F1AP_SRBs_ToBeSetup_ItemIEs_t *srbs_toBeSetup_item_ies; - srbs_toBeSetup_item_ies = (F1AP_SRBs_ToBeSetup_ItemIEs_t *)calloc(1, sizeof(F1AP_SRBs_ToBeSetup_ItemIEs_t)); + asn1cSequenceAdd(ie11->value.choice.SRBs_ToBeSetup_List.list, F1AP_SRBs_ToBeSetup_ItemIEs_t, srbs_toBeSetup_item_ies); srbs_toBeSetup_item_ies->id = F1AP_ProtocolIE_ID_id_SRBs_ToBeSetup_Item; // 73 srbs_toBeSetup_item_ies->criticality = F1AP_Criticality_ignore; srbs_toBeSetup_item_ies->value.present = F1AP_SRBs_ToBeSetup_ItemIEs__value_PR_SRBs_ToBeSetup_Item; - /* 11.1 SRBs_ToBeSetup_Item */ - F1AP_SRBs_ToBeSetup_Item_t srbs_toBeSetup_item; - memset((void *)&srbs_toBeSetup_item, 0, sizeof(F1AP_SRBs_ToBeSetup_Item_t)); - + F1AP_SRBs_ToBeSetup_Item_t *srbs_toBeSetup_item=&srbs_toBeSetup_item_ies->value.choice.SRBs_ToBeSetup_Item; /* 11.1.1 sRBID */ - srbs_toBeSetup_item.sRBID = 2L; - + srbs_toBeSetup_item->sRBID = f1ap_ue_context_setup_req->srbs_to_be_setup[i].srb_id; /* OPTIONAL */ /* 11.1.2 duplicationIndication */ - if (0) { - srbs_toBeSetup_item.duplicationIndication = (F1AP_DuplicationIndication_t *)calloc(1, sizeof(F1AP_DuplicationIndication_t)); - srbs_toBeSetup_item.duplicationIndication = F1AP_DuplicationIndication_true; // enum - } - - /* ADD */ - srbs_toBeSetup_item_ies->value.choice.SRBs_ToBeSetup_Item = srbs_toBeSetup_item; - ASN_SEQUENCE_ADD(&ie->value.choice.SRBs_ToBeSetup_List.list, - srbs_toBeSetup_item_ies); + //if (0) { + asn1cCallocOne(srbs_toBeSetup_item->duplicationIndication, + F1AP_DuplicationIndication_true); // enum + //} } - ASN_SEQUENCE_ADD(&out->protocolIEs.list, ie); /* mandatory */ /* c12. DRBs_ToBeSetup_List */ - ie = (F1AP_UEContextSetupRequestIEs_t *)calloc(1, sizeof(F1AP_UEContextSetupRequestIEs_t)); - ie->id = F1AP_ProtocolIE_ID_id_DRBs_ToBeSetup_List; - ie->criticality = F1AP_Criticality_reject; - ie->value.present = F1AP_UEContextSetupRequestIEs__value_PR_DRBs_ToBeSetup_List; + asn1cSequenceAdd(out->protocolIEs.list, F1AP_UEContextSetupRequestIEs_t, ie12); + ie12->id = F1AP_ProtocolIE_ID_id_DRBs_ToBeSetup_List; + ie12->criticality = F1AP_Criticality_reject; + ie12->value.present = F1AP_UEContextSetupRequestIEs__value_PR_DRBs_ToBeSetup_List; + LOG_I(F1AP, "Length of drbs_to_be_setup: %d \n", f1ap_ue_context_setup_req->drbs_to_be_setup_length); - for (i = 0; i < f1ap_ue_context_setup_req->drbs_to_be_setup_length; i++) { + for (int i = 0; i < f1ap_ue_context_setup_req->drbs_to_be_setup_length; i++) { // - F1AP_DRBs_ToBeSetup_ItemIEs_t *drbs_toBeSetup_item_ies; - drbs_toBeSetup_item_ies = (F1AP_DRBs_ToBeSetup_ItemIEs_t *)calloc(1, sizeof(F1AP_DRBs_ToBeSetup_ItemIEs_t)); + asn1cSequenceAdd(ie12->value.choice.DRBs_ToBeSetup_List.list, F1AP_DRBs_ToBeSetup_ItemIEs_t, drbs_toBeSetup_item_ies); drbs_toBeSetup_item_ies->id = F1AP_ProtocolIE_ID_id_DRBs_ToBeSetup_Item; drbs_toBeSetup_item_ies->criticality = F1AP_Criticality_reject; drbs_toBeSetup_item_ies->value.present = F1AP_DRBs_ToBeSetup_ItemIEs__value_PR_DRBs_ToBeSetup_Item; - /* 12.1 DRBs_ToBeSetup_Item */ - F1AP_DRBs_ToBeSetup_Item_t drbs_toBeSetup_item; - memset((void *)&drbs_toBeSetup_item, 0, sizeof(F1AP_DRBs_ToBeSetup_Item_t)); - + F1AP_DRBs_ToBeSetup_Item_t *drbs_toBeSetup_item=&drbs_toBeSetup_item_ies->value.choice.DRBs_ToBeSetup_Item; /* 12.1.1 dRBID */ - drbs_toBeSetup_item.dRBID = f1ap_ue_context_setup_req->drbs_to_be_setup[i].drb_id; // 9 - + drbs_toBeSetup_item->dRBID = f1ap_ue_context_setup_req->drbs_to_be_setup[i].drb_id; // 9 /* 12.1.2 qoSInformation */ - int some_decide_qos = 1; // BK: Need Check - if (some_decide_qos) { - drbs_toBeSetup_item.qoSInformation.present = F1AP_QoSInformation_PR_eUTRANQoS; + int some_decide_qos = 0; // BK: Need Check + if (some_decide_qos) { + drbs_toBeSetup_item->qoSInformation.present = F1AP_QoSInformation_PR_eUTRANQoS; /* 12.1.2.1 eUTRANQoS */ - drbs_toBeSetup_item.qoSInformation.choice.eUTRANQoS = (F1AP_EUTRANQoS_t *)calloc(1, sizeof(F1AP_EUTRANQoS_t)); - + asn1cCalloc(drbs_toBeSetup_item->qoSInformation.choice.eUTRANQoS, eUTRANQoS); /* 12.1.2.1.1 qCI */ - drbs_toBeSetup_item.qoSInformation.choice.eUTRANQoS->qCI = 254L; - + eUTRANQoS->qCI = 254L; /* 12.1.2.1.2 allocationAndRetentionPriority */ { /* 12.1.2.1.2.1 priorityLevel */ - drbs_toBeSetup_item.qoSInformation.choice.eUTRANQoS->allocationAndRetentionPriority.priorityLevel = F1AP_PriorityLevel_highest; // enum - + eUTRANQoS->allocationAndRetentionPriority.priorityLevel = F1AP_PriorityLevel_highest; // enum /* 12.1.2.1.2.2 pre_emptionCapability */ - drbs_toBeSetup_item.qoSInformation.choice.eUTRANQoS->allocationAndRetentionPriority.pre_emptionCapability = F1AP_Pre_emptionCapability_may_trigger_pre_emption; // enum - + eUTRANQoS->allocationAndRetentionPriority.pre_emptionCapability = F1AP_Pre_emptionCapability_may_trigger_pre_emption; // enum /* 12.1.2.1.2.2 pre_emptionVulnerability */ - drbs_toBeSetup_item.qoSInformation.choice.eUTRANQoS->allocationAndRetentionPriority.pre_emptionVulnerability = F1AP_Pre_emptionVulnerability_not_pre_emptable; // enum + eUTRANQoS->allocationAndRetentionPriority.pre_emptionVulnerability = F1AP_Pre_emptionVulnerability_not_pre_emptable; // enum } /* OPTIONAL */ /* 12.1.2.1.3 gbrQosInformation */ if (0) { - drbs_toBeSetup_item.qoSInformation.choice.eUTRANQoS->gbrQosInformation = (F1AP_GBR_QosInformation_t *)calloc(1, sizeof(F1AP_GBR_QosInformation_t)); - asn_long2INTEGER(&drbs_toBeSetup_item.qoSInformation.choice.eUTRANQoS->gbrQosInformation->e_RAB_MaximumBitrateDL, 1L); - asn_long2INTEGER(&drbs_toBeSetup_item.qoSInformation.choice.eUTRANQoS->gbrQosInformation->e_RAB_MaximumBitrateUL, 1L); - asn_long2INTEGER(&drbs_toBeSetup_item.qoSInformation.choice.eUTRANQoS->gbrQosInformation->e_RAB_GuaranteedBitrateDL, 1L); - asn_long2INTEGER(&drbs_toBeSetup_item.qoSInformation.choice.eUTRANQoS->gbrQosInformation->e_RAB_GuaranteedBitrateUL, 1L); + eUTRANQoS->gbrQosInformation = (F1AP_GBR_QosInformation_t *)calloc(1, sizeof(F1AP_GBR_QosInformation_t)); + asn_long2INTEGER(&eUTRANQoS->gbrQosInformation->e_RAB_MaximumBitrateDL, 1L); + asn_long2INTEGER(&eUTRANQoS->gbrQosInformation->e_RAB_MaximumBitrateUL, 1L); + asn_long2INTEGER(&eUTRANQoS->gbrQosInformation->e_RAB_GuaranteedBitrateDL, 1L); + asn_long2INTEGER(&eUTRANQoS->gbrQosInformation->e_RAB_GuaranteedBitrateUL, 1L); } - - } else { + } else { /* 12.1.2 DRB_Information */ - drbs_toBeSetup_item.qoSInformation.present = F1AP_QoSInformation_PR_choice_extension; - - F1AP_QoSInformation_ExtIEs_t *ie; - ie = (F1AP_QoSInformation_ExtIEs_t *)calloc(1, sizeof(F1AP_QoS_Characteristics_ExtIEs_t)); + drbs_toBeSetup_item->qoSInformation.present = F1AP_QoSInformation_PR_choice_extension; + F1AP_QoSInformation_ExtIEs_t *ie = (F1AP_QoSInformation_ExtIEs_t *)calloc(1, sizeof(*ie)); ie->id = F1AP_ProtocolIE_ID_id_DRB_Information; ie->criticality = F1AP_Criticality_reject; ie->value.present = F1AP_QoSInformation_ExtIEs__value_PR_DRB_Information; F1AP_DRB_Information_t *DRB_Information = &ie->value.choice.DRB_Information; - - drbs_toBeSetup_item.qoSInformation.choice.choice_extension = (struct F1AP_ProtocolIE_SingleContainer*)ie; - - + drbs_toBeSetup_item->qoSInformation.choice.choice_extension = (struct F1AP_ProtocolIE_SingleContainer *)ie; /* 12.1.2.1 dRB_QoS */ { /* qoS_Characteristics */ { - int some_decide_qoS_characteristics = 1; // BK: Need Check + int some_decide_qoS_characteristics = 0; // BK: Need Check + if (some_decide_qoS_characteristics) { DRB_Information->dRB_QoS.qoS_Characteristics.present = F1AP_QoS_Characteristics_PR_non_Dynamic_5QI; - DRB_Information->dRB_QoS.qoS_Characteristics.choice.non_Dynamic_5QI = (F1AP_NonDynamic5QIDescriptor_t *)calloc(1, sizeof(F1AP_NonDynamic5QIDescriptor_t)); - - /* fiveQI */ - DRB_Information->dRB_QoS.qoS_Characteristics.choice.non_Dynamic_5QI->fiveQI = 1L; - - /* OPTIONAL */ - /* qoSPriorityLevel */ - if (0) { - DRB_Information->dRB_QoS.qoS_Characteristics.choice.non_Dynamic_5QI->qoSPriorityLevel = (long *)calloc(1, sizeof(long)); - *DRB_Information->dRB_QoS.qoS_Characteristics.choice.non_Dynamic_5QI->qoSPriorityLevel = 1L; - } - - /* OPTIONAL */ - /* averagingWindow */ - if (0) { - DRB_Information->dRB_QoS.qoS_Characteristics.choice.non_Dynamic_5QI->averagingWindow = (F1AP_AveragingWindow_t *)calloc(1, sizeof(F1AP_AveragingWindow_t)); - *DRB_Information->dRB_QoS.qoS_Characteristics.choice.non_Dynamic_5QI->averagingWindow = 1L; - } - - /* OPTIONAL */ - /* maxDataBurstVolume */ - if (0) { - DRB_Information->dRB_QoS.qoS_Characteristics.choice.non_Dynamic_5QI->maxDataBurstVolume = (F1AP_MaxDataBurstVolume_t *)calloc(1, sizeof(F1AP_MaxDataBurstVolume_t)); - *DRB_Information->dRB_QoS.qoS_Characteristics.choice.non_Dynamic_5QI->maxDataBurstVolume = 1L; - } - + setQos(DRB_Information->dRB_QoS.qoS_Characteristics.choice.non_Dynamic_5QI); } else { DRB_Information->dRB_QoS.qoS_Characteristics.present = F1AP_QoS_Characteristics_PR_dynamic_5QI; - DRB_Information->dRB_QoS.qoS_Characteristics.choice.dynamic_5QI = (F1AP_Dynamic5QIDescriptor_t *)calloc(1, sizeof(F1AP_Dynamic5QIDescriptor_t)); - + asn1cCalloc(DRB_Information->dRB_QoS.qoS_Characteristics.choice.dynamic_5QI, tmp); /* qoSPriorityLevel */ - DRB_Information->dRB_QoS.qoS_Characteristics.choice.dynamic_5QI->qoSPriorityLevel = 1L; - + tmp->qoSPriorityLevel = 1L; /* packetDelayBudget */ - DRB_Information->dRB_QoS.qoS_Characteristics.choice.dynamic_5QI->packetDelayBudget = 1L; - + tmp->packetDelayBudget = 1L; /* packetErrorRate */ - DRB_Information->dRB_QoS.qoS_Characteristics.choice.dynamic_5QI->packetErrorRate.pER_Scalar = 1L; - DRB_Information->dRB_QoS.qoS_Characteristics.choice.dynamic_5QI->packetErrorRate.pER_Exponent = 6L; - + tmp->packetErrorRate.pER_Scalar = 1L; + tmp->packetErrorRate.pER_Exponent = 6L; /* OPTIONAL */ /* delayCritical */ if (0) { - DRB_Information->dRB_QoS.qoS_Characteristics.choice.dynamic_5QI->delayCritical = (long *)calloc(1, sizeof(long)); - *DRB_Information->dRB_QoS.qoS_Characteristics.choice.dynamic_5QI->delayCritical = 1L; + asn1cCallocOne(DRB_Information->dRB_QoS.qoS_Characteristics.choice.dynamic_5QI->delayCritical, 1L); } /* OPTIONAL */ /* averagingWindow */ if (0) { - DRB_Information->dRB_QoS.qoS_Characteristics.choice.dynamic_5QI->averagingWindow = (F1AP_AveragingWindow_t *)calloc(1, sizeof(F1AP_AveragingWindow_t)); - *DRB_Information->dRB_QoS.qoS_Characteristics.choice.dynamic_5QI->averagingWindow = 1L; + asn1cCallocOne(DRB_Information->dRB_QoS.qoS_Characteristics.choice.dynamic_5QI->averagingWindow, 1L); } /* OPTIONAL */ /* maxDataBurstVolume */ if (0) { - DRB_Information->dRB_QoS.qoS_Characteristics.choice.dynamic_5QI->maxDataBurstVolume = (F1AP_MaxDataBurstVolume_t *)calloc(1, sizeof(F1AP_MaxDataBurstVolume_t)); - *DRB_Information->dRB_QoS.qoS_Characteristics.choice.dynamic_5QI->maxDataBurstVolume = 1L; + asn1cCallocOne(DRB_Information->dRB_QoS.qoS_Characteristics.choice.dynamic_5QI->maxDataBurstVolume, 1L); } - } // if some_decide_qoS_characteristics - } // qoS_Characteristics - /* nGRANallocationRetentionPriority */ { - DRB_Information->dRB_QoS.nGRANallocationRetentionPriority.priorityLevel = F1AP_PriorityLevel_highest; // enum - DRB_Information->dRB_QoS.nGRANallocationRetentionPriority.pre_emptionCapability = F1AP_Pre_emptionCapability_shall_not_trigger_pre_emption; // enum - DRB_Information->dRB_QoS.nGRANallocationRetentionPriority.pre_emptionVulnerability = F1AP_Pre_emptionVulnerability_not_pre_emptable; // enum + DRB_Information->dRB_QoS.nGRANallocationRetentionPriority.priorityLevel = F1AP_PriorityLevel_highest; // enum + DRB_Information->dRB_QoS.nGRANallocationRetentionPriority.pre_emptionCapability = F1AP_Pre_emptionCapability_shall_not_trigger_pre_emption; // enum + DRB_Information->dRB_QoS.nGRANallocationRetentionPriority.pre_emptionVulnerability = F1AP_Pre_emptionVulnerability_not_pre_emptable; // enum } // nGRANallocationRetentionPriority /* OPTIONAL */ /* gBR_QoS_Flow_Information */ if (0) { - DRB_Information->dRB_QoS.gBR_QoS_Flow_Information = (F1AP_GBR_QoSFlowInformation_t *)calloc(1, sizeof(F1AP_GBR_QoSFlowInformation_t)); - asn_long2INTEGER(&DRB_Information->dRB_QoS.gBR_QoS_Flow_Information->maxFlowBitRateDownlink, 1L); - asn_long2INTEGER(&DRB_Information->dRB_QoS.gBR_QoS_Flow_Information->maxFlowBitRateUplink, 1L); - asn_long2INTEGER(&DRB_Information->dRB_QoS.gBR_QoS_Flow_Information->guaranteedFlowBitRateDownlink, 1L); - asn_long2INTEGER(&DRB_Information->dRB_QoS.gBR_QoS_Flow_Information->guaranteedFlowBitRateUplink, 1L); + asn1cCalloc(DRB_Information->dRB_QoS.gBR_QoS_Flow_Information, tmp); + asn_long2INTEGER(&tmp->maxFlowBitRateDownlink, 1L); + asn_long2INTEGER(&tmp->maxFlowBitRateUplink, 1L); + asn_long2INTEGER(&tmp->guaranteedFlowBitRateDownlink, 1L); + asn_long2INTEGER(&tmp->guaranteedFlowBitRateUplink, 1L); /* OPTIONAL */ /* maxPacketLossRateDownlink */ if (0) { - DRB_Information->dRB_QoS.gBR_QoS_Flow_Information->maxPacketLossRateDownlink = (F1AP_MaxPacketLossRate_t *)calloc(1, sizeof(F1AP_MaxPacketLossRate_t)); - *DRB_Information->dRB_QoS.gBR_QoS_Flow_Information->maxPacketLossRateDownlink = 1L; + asn1cCallocOne(DRB_Information->dRB_QoS.gBR_QoS_Flow_Information->maxPacketLossRateDownlink, 1L); } /* OPTIONAL */ /* maxPacketLossRateUplink */ if (0) { - DRB_Information->dRB_QoS.gBR_QoS_Flow_Information->maxPacketLossRateUplink = (F1AP_MaxPacketLossRate_t *)calloc(1, sizeof(F1AP_MaxPacketLossRate_t)); - *DRB_Information->dRB_QoS.gBR_QoS_Flow_Information->maxPacketLossRateUplink = 1L; + asn1cCallocOne(DRB_Information->dRB_QoS.gBR_QoS_Flow_Information->maxPacketLossRateUplink, 1L); } - } /* OPTIONAL */ /* reflective_QoS_Attribute */ if (0) { - DRB_Information->dRB_QoS.reflective_QoS_Attribute = (long *)calloc(1, sizeof(long)); - *DRB_Information->dRB_QoS.reflective_QoS_Attribute = 1L; + asn1cCallocOne(DRB_Information->dRB_QoS.reflective_QoS_Attribute, 1L); } - } // dRB_QoS - /* 12.1.2.2 sNSSAI */ { /* sST */ - OCTET_STRING_fromBuf(&DRB_Information->sNSSAI.sST, "asdsa1d32sa1d31asd31as", - strlen("asdsa1d32sa1d31asd31as")); + OCTET_STRING_fromBuf(&DRB_Information->sNSSAI.sST, "1", 1); + /* OPTIONAL */ /* sD */ if (0) { - DRB_Information->sNSSAI.sD = (OCTET_STRING_t *)calloc(1, sizeof(OCTET_STRING_t)); - OCTET_STRING_fromBuf(DRB_Information->sNSSAI.sD, "asdsa1d32sa1d31asd31as", - strlen("asdsa1d32sa1d31asd31as")); + asn1cCalloc(DRB_Information->sNSSAI.sD, tmp); + OCTET_STRING_fromBuf(tmp, "asdsa1d32sa1d31asd31as", + strlen("asdsa1d32sa1d31asd31as")); } } + /* OPTIONAL */ /* 12.1.2.3 notificationControl */ if (0) { - DRB_Information->notificationControl = (F1AP_NotificationControl_t *)calloc(1, sizeof(F1AP_NotificationControl_t)); - *DRB_Information->notificationControl = F1AP_NotificationControl_active; // enum + asn1cCallocOne(DRB_Information->notificationControl, + F1AP_NotificationControl_active); // enum } /* 12.1.2.4 flows_Mapped_To_DRB_List */ // BK: need verifiy - int k; - for (k = 0; k < 1; k ++) { - - F1AP_Flows_Mapped_To_DRB_Item_t flows_mapped_to_drb_item; - memset((void *)&flows_mapped_to_drb_item, 0, sizeof(F1AP_Flows_Mapped_To_DRB_Item_t)); - - /* qoSFlowIndicator */ - flows_mapped_to_drb_item.qoSFlowIdentifier = 1L; + for (int k = 0; k < 1; k ++) { + asn1cSequenceAdd(DRB_Information->flows_Mapped_To_DRB_List.list, + F1AP_Flows_Mapped_To_DRB_Item_t, flows_mapped_to_drb_item); + /* qoSFlowIndicator */ + flows_mapped_to_drb_item->qoSFlowIdentifier = 1L; /* qoSFlowLevelQoSParameters */ - { + { /* qoS_Characteristics */ { - int some_decide_qoS_characteristics = 1; // BK: Need Check - if (some_decide_qoS_characteristics) { - flows_mapped_to_drb_item.qoSFlowLevelQoSParameters.qoS_Characteristics.present = F1AP_QoS_Characteristics_PR_non_Dynamic_5QI; - flows_mapped_to_drb_item.qoSFlowLevelQoSParameters.qoS_Characteristics.choice.non_Dynamic_5QI = (F1AP_NonDynamic5QIDescriptor_t *)calloc(1, sizeof(F1AP_NonDynamic5QIDescriptor_t)); - - /* fiveQI */ - flows_mapped_to_drb_item.qoSFlowLevelQoSParameters.qoS_Characteristics.choice.non_Dynamic_5QI->fiveQI = 1L; - - /* OPTIONAL */ - /* qoSPriorityLevel */ - if (0) { - flows_mapped_to_drb_item.qoSFlowLevelQoSParameters.qoS_Characteristics.choice.non_Dynamic_5QI->qoSPriorityLevel = (long *)calloc(1, sizeof(long)); - *flows_mapped_to_drb_item.qoSFlowLevelQoSParameters.qoS_Characteristics.choice.non_Dynamic_5QI->qoSPriorityLevel = 1L; - } - - /* OPTIONAL */ - /* averagingWindow */ - if (0) { - flows_mapped_to_drb_item.qoSFlowLevelQoSParameters.qoS_Characteristics.choice.non_Dynamic_5QI->averagingWindow = (F1AP_AveragingWindow_t *)calloc(1, sizeof(F1AP_AveragingWindow_t)); - *flows_mapped_to_drb_item.qoSFlowLevelQoSParameters.qoS_Characteristics.choice.non_Dynamic_5QI->averagingWindow = 1L; - } - - /* OPTIONAL */ - /* maxDataBurstVolume */ - if (0) { - flows_mapped_to_drb_item.qoSFlowLevelQoSParameters.qoS_Characteristics.choice.non_Dynamic_5QI->maxDataBurstVolume = (F1AP_MaxDataBurstVolume_t *)calloc(1, sizeof(F1AP_MaxDataBurstVolume_t)); - *flows_mapped_to_drb_item.qoSFlowLevelQoSParameters.qoS_Characteristics.choice.non_Dynamic_5QI->maxDataBurstVolume = 1L; - } + int some_decide_qoS_characteristics = 0; // BK: Need Check + F1AP_QoS_Characteristics_t *QosParams=&flows_mapped_to_drb_item->qoSFlowLevelQoSParameters.qoS_Characteristics; + if (some_decide_qoS_characteristics) { + QosParams->present = F1AP_QoS_Characteristics_PR_non_Dynamic_5QI; + setQos(QosParams->choice.non_Dynamic_5QI); } else { - flows_mapped_to_drb_item.qoSFlowLevelQoSParameters.qoS_Characteristics.present = F1AP_QoS_Characteristics_PR_dynamic_5QI; - flows_mapped_to_drb_item.qoSFlowLevelQoSParameters.qoS_Characteristics.choice.dynamic_5QI = (F1AP_Dynamic5QIDescriptor_t *)calloc(1, sizeof(F1AP_Dynamic5QIDescriptor_t)); - + QosParams->present = F1AP_QoS_Characteristics_PR_dynamic_5QI; + asn1cCalloc(QosParams->choice.dynamic_5QI, tmp); /* qoSPriorityLevel */ - flows_mapped_to_drb_item.qoSFlowLevelQoSParameters.qoS_Characteristics.choice.dynamic_5QI->qoSPriorityLevel = 1L; - + tmp->qoSPriorityLevel = 1L; /* packetDelayBudget */ - flows_mapped_to_drb_item.qoSFlowLevelQoSParameters.qoS_Characteristics.choice.dynamic_5QI->packetDelayBudget = 1L; - + tmp->packetDelayBudget = 1L; /* packetErrorRate */ - flows_mapped_to_drb_item.qoSFlowLevelQoSParameters.qoS_Characteristics.choice.dynamic_5QI->packetErrorRate.pER_Scalar = 1L; - flows_mapped_to_drb_item.qoSFlowLevelQoSParameters.qoS_Characteristics.choice.dynamic_5QI->packetErrorRate.pER_Exponent = 6L; + tmp->packetErrorRate.pER_Scalar = 1L; + tmp->packetErrorRate.pER_Exponent = 6L; - /* OPTIONAL */ + /* OPTIONAL */ /* delayCritical */ if (0) { - flows_mapped_to_drb_item.qoSFlowLevelQoSParameters.qoS_Characteristics.choice.dynamic_5QI->delayCritical = (long *)calloc(1, sizeof(long)); - *flows_mapped_to_drb_item.qoSFlowLevelQoSParameters.qoS_Characteristics.choice.dynamic_5QI->delayCritical = 1L; + asn1cCalloc(QosParams->choice.dynamic_5QI->delayCritical, tmp); + *tmp = 1L; } /* OPTIONAL */ /* averagingWindow */ if (0) { - flows_mapped_to_drb_item.qoSFlowLevelQoSParameters.qoS_Characteristics.choice.dynamic_5QI->averagingWindow = (F1AP_AveragingWindow_t *)calloc(1, sizeof(F1AP_AveragingWindow_t)); - *flows_mapped_to_drb_item.qoSFlowLevelQoSParameters.qoS_Characteristics.choice.dynamic_5QI->averagingWindow = 1L; + asn1cCalloc(QosParams->choice.dynamic_5QI->averagingWindow, tmp); + *tmp = 1L; } /* OPTIONAL */ /* maxDataBurstVolume */ if (0) { - flows_mapped_to_drb_item.qoSFlowLevelQoSParameters.qoS_Characteristics.choice.dynamic_5QI->maxDataBurstVolume = (F1AP_MaxDataBurstVolume_t *)calloc(1, sizeof(F1AP_MaxDataBurstVolume_t)); - *flows_mapped_to_drb_item.qoSFlowLevelQoSParameters.qoS_Characteristics.choice.dynamic_5QI->maxDataBurstVolume = 1L; + asn1cCalloc(QosParams->choice.dynamic_5QI->maxDataBurstVolume, tmp); + *tmp= 1L; } - } // if some_decide_qoS_characteristics - } // qoS_Characteristics - /* nGRANallocationRetentionPriority */ { - flows_mapped_to_drb_item.qoSFlowLevelQoSParameters.nGRANallocationRetentionPriority.priorityLevel = F1AP_PriorityLevel_highest; // enum - flows_mapped_to_drb_item.qoSFlowLevelQoSParameters.nGRANallocationRetentionPriority.pre_emptionCapability = F1AP_Pre_emptionCapability_shall_not_trigger_pre_emption; // enum - flows_mapped_to_drb_item.qoSFlowLevelQoSParameters.nGRANallocationRetentionPriority.pre_emptionVulnerability = F1AP_Pre_emptionVulnerability_not_pre_emptable; // enum + flows_mapped_to_drb_item->qoSFlowLevelQoSParameters.nGRANallocationRetentionPriority.priorityLevel = F1AP_PriorityLevel_highest; // enum + flows_mapped_to_drb_item->qoSFlowLevelQoSParameters.nGRANallocationRetentionPriority.pre_emptionCapability = F1AP_Pre_emptionCapability_shall_not_trigger_pre_emption; // enum + flows_mapped_to_drb_item->qoSFlowLevelQoSParameters.nGRANallocationRetentionPriority.pre_emptionVulnerability = F1AP_Pre_emptionVulnerability_not_pre_emptable; // enum } // nGRANallocationRetentionPriority /* OPTIONAL */ /* gBR_QoS_Flow_Information */ if (0) { - flows_mapped_to_drb_item.qoSFlowLevelQoSParameters.gBR_QoS_Flow_Information = (F1AP_GBR_QoSFlowInformation_t *)calloc(1, sizeof(F1AP_GBR_QoSFlowInformation_t)); - asn_long2INTEGER(&flows_mapped_to_drb_item.qoSFlowLevelQoSParameters.gBR_QoS_Flow_Information->maxFlowBitRateDownlink, 1L); - asn_long2INTEGER(&flows_mapped_to_drb_item.qoSFlowLevelQoSParameters.gBR_QoS_Flow_Information->maxFlowBitRateUplink, 1L); - asn_long2INTEGER(&flows_mapped_to_drb_item.qoSFlowLevelQoSParameters.gBR_QoS_Flow_Information->guaranteedFlowBitRateDownlink, 1L); - asn_long2INTEGER(&flows_mapped_to_drb_item.qoSFlowLevelQoSParameters.gBR_QoS_Flow_Information->guaranteedFlowBitRateUplink, 1L); + asn1cCalloc(flows_mapped_to_drb_item->qoSFlowLevelQoSParameters.gBR_QoS_Flow_Information, tmp); + asn_long2INTEGER(&tmp->maxFlowBitRateDownlink, 1L); + asn_long2INTEGER(&tmp->maxFlowBitRateUplink, 1L); + asn_long2INTEGER(&tmp->guaranteedFlowBitRateDownlink, 1L); + asn_long2INTEGER(&tmp->guaranteedFlowBitRateUplink, 1L); /* OPTIONAL */ /* maxPacketLossRateDownlink */ if (0) { - flows_mapped_to_drb_item.qoSFlowLevelQoSParameters.gBR_QoS_Flow_Information->maxPacketLossRateDownlink = (F1AP_MaxPacketLossRate_t *)calloc(1, sizeof(F1AP_MaxPacketLossRate_t)); - *flows_mapped_to_drb_item.qoSFlowLevelQoSParameters.gBR_QoS_Flow_Information->maxPacketLossRateDownlink = 1L; + asn1cCallocOne(flows_mapped_to_drb_item->qoSFlowLevelQoSParameters.gBR_QoS_Flow_Information->maxPacketLossRateDownlink, 1L); } /* OPTIONAL */ /* maxPacketLossRateUplink */ if (0) { - flows_mapped_to_drb_item.qoSFlowLevelQoSParameters.gBR_QoS_Flow_Information->maxPacketLossRateUplink = (F1AP_MaxPacketLossRate_t *)calloc(1, sizeof(F1AP_MaxPacketLossRate_t)); - *flows_mapped_to_drb_item.qoSFlowLevelQoSParameters.gBR_QoS_Flow_Information->maxPacketLossRateUplink = 1L; + asn1cCallocOne(flows_mapped_to_drb_item->qoSFlowLevelQoSParameters.gBR_QoS_Flow_Information->maxPacketLossRateUplink, 1L); } - } /* OPTIONAL */ /* reflective_QoS_Attribute */ if (0) { - flows_mapped_to_drb_item.qoSFlowLevelQoSParameters.reflective_QoS_Attribute = (long *)calloc(1, sizeof(long)); - *flows_mapped_to_drb_item.qoSFlowLevelQoSParameters.reflective_QoS_Attribute = 1L; + asn1cCallocOne(flows_mapped_to_drb_item->qoSFlowLevelQoSParameters.reflective_QoS_Attribute, 1L); } - } // qoSFlowLevelQoSParameters - // BK: need check - ASN_SEQUENCE_ADD(&DRB_Information->flows_Mapped_To_DRB_List.list, &flows_mapped_to_drb_item); } - } // if some_decide_qos /* 12.1.3 uLUPTNLInformation_ToBeSetup_List */ - for (j = 0; j < f1ap_ue_context_setup_req->drbs_to_be_setup[i].up_ul_tnl_length; j++) { - f1ap_up_tnl_t *up_tnl = &f1ap_ue_context_setup_req->drbs_to_be_setup[i].up_ul_tnl[j]; - + for (int j = 0; j < f1ap_ue_context_setup_req->drbs_to_be_setup[i].up_ul_tnl_length; j++) { + /* Here the callback function used as input is not the right one. Need to create a new one probably for F1-U, not sure + * if the kind of input parameters to the callback function are convenient though for gtp-u over F1-U.*/ + //Use a dummy teid for the outgoing GTP-U tunnel (DU) which will be updated once we get the UE context setup response from the DU + transport_layer_addr_t addr; + int sz=sizeof(f1ap_ue_context_setup_req->drbs_to_be_setup[i].up_dl_tnl[0].tl_address); + memcpy(addr.buffer,&f1ap_ue_context_setup_req->drbs_to_be_setup[i].up_dl_tnl[0].tl_address, sz); + addr.length = sz*8; + f1ap_ue_context_setup_req->drbs_to_be_setup[i].up_ul_tnl[j].teid= + newGtpuCreateTunnel(getCxt(CUtype, instance)->gtpInst, + f1ap_ue_context_setup_req->rnti, + f1ap_ue_context_setup_req->drbs_to_be_setup[i].drb_id, + f1ap_ue_context_setup_req->drbs_to_be_setup[i].drb_id, + 0xFFFF, // We will set the right value from DU answer + addr, + f1ap_ue_context_setup_req->drbs_to_be_setup[i].up_dl_tnl[0].port, + cu_f1u_data_req); /* 12.3.1 ULTunnels_ToBeSetup_Item */ - F1AP_ULUPTNLInformation_ToBeSetup_Item_t *uLUPTNLInformation_ToBeSetup_Item; - - /* 12.3.1.1 gTPTunnel */ - uLUPTNLInformation_ToBeSetup_Item = calloc(1, sizeof(F1AP_ULUPTNLInformation_ToBeSetup_Item_t)); + asn1cSequenceAdd(drbs_toBeSetup_item->uLUPTNLInformation_ToBeSetup_List.list, + F1AP_ULUPTNLInformation_ToBeSetup_Item_t, uLUPTNLInformation_ToBeSetup_Item); uLUPTNLInformation_ToBeSetup_Item->uLUPTNLInformation.present = F1AP_UPTransportLayerInformation_PR_gTPTunnel; - F1AP_GTPTunnel_t *gTPTunnel = (F1AP_GTPTunnel_t *)calloc(1, sizeof(F1AP_GTPTunnel_t)); - + asn1cCalloc( uLUPTNLInformation_ToBeSetup_Item->uLUPTNLInformation.choice.gTPTunnel, + gTPTunnel); /* 12.3.1.1.1 transportLayerAddress */ - TRANSPORT_LAYER_ADDRESS_IPv4_TO_BIT_STRING(up_tnl->tl_address, &gTPTunnel->transportLayerAddress); - + TRANSPORT_LAYER_ADDRESS_IPv4_TO_BIT_STRING(f1ap_ue_context_setup_req->drbs_to_be_setup[i].up_ul_tnl[j].tl_address, + &gTPTunnel->transportLayerAddress); /* 12.3.1.1.2 gTP_TEID */ - INT32_TO_OCTET_STRING(up_tnl->gtp_teid, &gTPTunnel->gTP_TEID); - - // Add - uLUPTNLInformation_ToBeSetup_Item->uLUPTNLInformation.choice.gTPTunnel = gTPTunnel; - ASN_SEQUENCE_ADD(&drbs_toBeSetup_item.uLUPTNLInformation_ToBeSetup_List.list, uLUPTNLInformation_ToBeSetup_Item); + INT32_TO_OCTET_STRING(f1ap_ue_context_setup_req->drbs_to_be_setup[i].up_ul_tnl[j].teid, + &gTPTunnel->gTP_TEID); } /* 12.1.4 rLCMode */ /* TODO use rlc_mode from f1ap_drb_to_be_setup */ switch (f1ap_ue_context_setup_req->drbs_to_be_setup[i].rlc_mode) { case RLC_MODE_AM: - drbs_toBeSetup_item.rLCMode = F1AP_RLCMode_rlc_am; + drbs_toBeSetup_item->rLCMode = F1AP_RLCMode_rlc_am; break; + default: - drbs_toBeSetup_item.rLCMode = F1AP_RLCMode_rlc_um_bidirectional; + drbs_toBeSetup_item->rLCMode = F1AP_RLCMode_rlc_um_bidirectional; } /* OPTIONAL */ /* 12.1.5 ULConfiguration */ if (0) { - drbs_toBeSetup_item.uLConfiguration = (F1AP_ULConfiguration_t *)calloc(1, sizeof(F1AP_ULConfiguration_t)); - drbs_toBeSetup_item.uLConfiguration->uLUEConfiguration = F1AP_ULUEConfiguration_no_data; + asn1cCalloc(drbs_toBeSetup_item->uLConfiguration, tmp); + tmp->uLUEConfiguration = F1AP_ULUEConfiguration_no_data; } /* OPTIONAL */ /* 12.1.6 duplicationActivation */ if (0) { - drbs_toBeSetup_item.duplicationActivation = (F1AP_DuplicationActivation_t *)calloc(1, sizeof(F1AP_DuplicationActivation_t)); - drbs_toBeSetup_item.duplicationActivation = F1AP_DuplicationActivation_active; // enum + asn1cCalloc(drbs_toBeSetup_item->duplicationActivation, tmp); + *tmp = F1AP_DuplicationActivation_active; // enum } - - /* ADD */ - drbs_toBeSetup_item_ies->value.choice.DRBs_ToBeSetup_Item = drbs_toBeSetup_item; - ASN_SEQUENCE_ADD(&ie->value.choice.DRBs_ToBeSetup_List.list, - drbs_toBeSetup_item_ies); - } - ASN_SEQUENCE_ADD(&out->protocolIEs.list, ie); /* OPTIONAL */ /* InactivityMonitoringRequest */ if (0) { - ie = (F1AP_UEContextSetupRequestIEs_t *)calloc(1, sizeof(F1AP_UEContextSetupRequestIEs_t)); - ie->id = F1AP_ProtocolIE_ID_id_InactivityMonitoringRequest; - ie->criticality = F1AP_Criticality_reject; - ie->value.present = F1AP_UEContextSetupRequestIEs__value_PR_InactivityMonitoringRequest; - ie->value.choice.InactivityMonitoringRequest = F1AP_InactivityMonitoringRequest_true; // 0 - ASN_SEQUENCE_ADD(&out->protocolIEs.list, ie); + asn1cSequenceAdd(out->protocolIEs.list, F1AP_UEContextSetupRequestIEs_t, ie12); + ie12->id = F1AP_ProtocolIE_ID_id_InactivityMonitoringRequest; + ie12->criticality = F1AP_Criticality_reject; + ie12->value.present = F1AP_UEContextSetupRequestIEs__value_PR_InactivityMonitoringRequest; + ie12->value.choice.InactivityMonitoringRequest = F1AP_InactivityMonitoringRequest_true; // 0 } /* OPTIONAL */ /* RAT_FrequencyPriorityInformation */ if (0) { - ie = (F1AP_UEContextSetupRequestIEs_t *)calloc(1, sizeof(F1AP_UEContextSetupRequestIEs_t)); - ie->id = F1AP_ProtocolIE_ID_id_RAT_FrequencyPriorityInformation; - ie->criticality = F1AP_Criticality_reject; - ie->value.present = F1AP_UEContextSetupRequestIEs__value_PR_RAT_FrequencyPriorityInformation; - + asn1cSequenceAdd(out->protocolIEs.list, F1AP_UEContextSetupRequestIEs_t, ie13); + ie13->id = F1AP_ProtocolIE_ID_id_RAT_FrequencyPriorityInformation; + ie13->criticality = F1AP_Criticality_reject; + ie13->value.present = F1AP_UEContextSetupRequestIEs__value_PR_RAT_FrequencyPriorityInformation; int endc = 1; // RK: Get this from somewhere ... + if (endc) { - ie->value.choice.RAT_FrequencyPriorityInformation.present = F1AP_RAT_FrequencyPriorityInformation_PR_eNDC; - ie->value.choice.RAT_FrequencyPriorityInformation.choice.eNDC = 11L; + ie13->value.choice.RAT_FrequencyPriorityInformation.present = F1AP_RAT_FrequencyPriorityInformation_PR_eNDC; + ie13->value.choice.RAT_FrequencyPriorityInformation.choice.eNDC = 11L; } else { - ie->value.choice.RAT_FrequencyPriorityInformation.present = F1AP_RAT_FrequencyPriorityInformation_PR_nGRAN; - ie->value.choice.RAT_FrequencyPriorityInformation.choice.nGRAN = 11L; + ie13->value.choice.RAT_FrequencyPriorityInformation.present = F1AP_RAT_FrequencyPriorityInformation_PR_nGRAN; + ie13->value.choice.RAT_FrequencyPriorityInformation.choice.nGRAN = 11L; } - ASN_SEQUENCE_ADD(&out->protocolIEs.list, ie); } /* OPTIONAL */ /* RRCContainer */ - if(RC.nrrrc) { - ie = (F1AP_UEContextSetupRequestIEs_t *)calloc(1, sizeof(F1AP_UEContextSetupRequestIEs_t)); - ie->id = F1AP_ProtocolIE_ID_id_RRCContainer; - ie->criticality = F1AP_Criticality_reject; - ie->value.present = F1AP_UEContextSetupRequestIEs__value_PR_RRCContainer; - OCTET_STRING_fromBuf(&ie->value.choice.RRCContainer, (const char*)f1ap_ue_context_setup_req->rrc_container, - f1ap_ue_context_setup_req->rrc_container_length); - ASN_SEQUENCE_ADD(&out->protocolIEs.list, ie); + if(f1ap_ue_context_setup_req->rrc_container_length > 0) { + asn1cSequenceAdd(out->protocolIEs.list, F1AP_UEContextSetupRequestIEs_t, ie14); + ie14->id = F1AP_ProtocolIE_ID_id_RRCContainer; + ie14->criticality = F1AP_Criticality_reject; + ie14->value.present = F1AP_UEContextSetupRequestIEs__value_PR_RRCContainer; + OCTET_STRING_fromBuf(&ie14->value.choice.RRCContainer, (const char *)f1ap_ue_context_setup_req->rrc_container, + f1ap_ue_context_setup_req->rrc_container_length); } /* OPTIONAL */ /* MaskedIMEISV */ if (0) { - ie = (F1AP_UEContextSetupRequestIEs_t *)calloc(1, sizeof(F1AP_UEContextSetupRequestIEs_t)); - ie->id = F1AP_ProtocolIE_ID_id_MaskedIMEISV; - ie->criticality = F1AP_Criticality_reject; - ie->value.present = F1AP_UEContextSetupRequestIEs__value_PR_MaskedIMEISV; - MaskedIMEISV_TO_BIT_STRING(12340000l, &ie->value.choice.MaskedIMEISV); // size (64) - ASN_SEQUENCE_ADD(&out->protocolIEs.list, ie); + asn1cSequenceAdd(out->protocolIEs.list, F1AP_UEContextSetupRequestIEs_t, ie15); + ie15->id = F1AP_ProtocolIE_ID_id_MaskedIMEISV; + ie15->criticality = F1AP_Criticality_reject; + ie15->value.present = F1AP_UEContextSetupRequestIEs__value_PR_MaskedIMEISV; + MaskedIMEISV_TO_BIT_STRING(12340000l, &ie15->value.choice.MaskedIMEISV); // size (64) } /* encode */ + uint8_t *buffer=NULL; + uint32_t len=0; + if (f1ap_encode_pdu(&pdu, &buffer, &len) < 0) { LOG_E(F1AP, "Failed to encode F1 UE CONTEXT SETUP REQUEST\n"); return -1; } // xer_fprint(stdout, &asn_DEF_F1AP_F1AP_PDU, (void *)pdu); - // asn_encode_to_new_buffer_result_t res = { NULL, {0, NULL, NULL} }; // res = asn_encode_to_new_buffer(NULL, ATS_CANONICAL_XER, &asn_DEF_F1AP_F1AP_PDU, pdu); // buffer = res.buffer; // len = res.result.encoded; - // if (res.result.encoded <= 0) { // LOG_E(F1AP, "ASN1 message encoding failed (%s, %lu)!\n", res.result.failed_type->name, res.result.encoded); // return -1; // } - LOG_D(F1AP,"F1AP UEContextSetupRequest Encoded %u bits\n", len); - - if(RC.nrrrc) { - cu_f1ap_itti_send_sctp_data_req(instance, f1ap_assoc_id /* BK: fix me*/ , buffer, len, 0 /* BK: fix me*/); - } - + f1ap_itti_send_sctp_data_req(true, instance, buffer, len, 0 /* BK: fix me*/); return 0; } @@ -796,41 +633,133 @@ int CU_handle_UE_CONTEXT_SETUP_RESPONSE(instance_t instance, uint32_t assoc_id, uint32_t stream, F1AP_F1AP_PDU_t *pdu) { + MessageDef *msg_p; F1AP_UEContextSetupResponse_t *container; F1AP_UEContextSetupResponseIEs_t *ie; - DevAssert(pdu); - + msg_p = itti_alloc_new_message(TASK_DU_F1, 0, F1AP_UE_CONTEXT_SETUP_RESP); + f1ap_ue_context_setup_t *f1ap_ue_context_setup_resp = &F1AP_UE_CONTEXT_SETUP_RESP(msg_p); container = &pdu->choice.successfulOutcome->value.choice.UEContextSetupResponse; - + int i; /* GNB_CU_UE_F1AP_ID */ F1AP_FIND_PROTOCOLIE_BY_ID(F1AP_UEContextSetupResponseIEs_t, ie, container, F1AP_ProtocolIE_ID_id_gNB_CU_UE_F1AP_ID, true); - + f1ap_ue_context_setup_resp->gNB_CU_ue_id = ie->value.choice.GNB_CU_UE_F1AP_ID; + LOG_D(F1AP, "f1ap_ue_context_setup_resp->gNB_CU_ue_id is: %d \n", f1ap_ue_context_setup_resp->gNB_CU_ue_id); /* GNB_DU_UE_F1AP_ID */ F1AP_FIND_PROTOCOLIE_BY_ID(F1AP_UEContextSetupResponseIEs_t, ie, container, F1AP_ProtocolIE_ID_id_gNB_DU_UE_F1AP_ID, true); - - /* DUtoCURRCInformation */ + f1ap_ue_context_setup_resp->gNB_DU_ue_id = ie->value.choice.GNB_DU_UE_F1AP_ID; + LOG_D(F1AP, "f1ap_ue_context_setup_resp->gNB_DU_ue_id is: %d \n", f1ap_ue_context_setup_resp->gNB_DU_ue_id); + f1ap_ue_context_setup_resp->rnti = + f1ap_get_rnti_by_du_id(CUtype, instance, f1ap_ue_context_setup_resp->gNB_DU_ue_id); + // DUtoCURRCInformation F1AP_FIND_PROTOCOLIE_BY_ID(F1AP_UEContextSetupResponseIEs_t, ie, container, F1AP_ProtocolIE_ID_id_DUtoCURRCInformation, true); - /* DRBs_Setup_List */ + if (ie == NULL) { + LOG_E(F1AP,"%s %d: ie is a NULL pointer \n",__FILE__,__LINE__); + return -1; + } + + f1ap_ue_context_setup_resp->du_to_cu_rrc_information = (uint8_t *)calloc(1,ie->value.choice.DUtoCURRCInformation.cellGroupConfig.size); + memcpy(f1ap_ue_context_setup_resp->du_to_cu_rrc_information, ie->value.choice.DUtoCURRCInformation.cellGroupConfig.buf, ie->value.choice.DUtoCURRCInformation.cellGroupConfig.size); + f1ap_ue_context_setup_resp->du_to_cu_rrc_information_length = ie->value.choice.DUtoCURRCInformation.cellGroupConfig.size; + // DRBs_Setup_List + F1AP_FIND_PROTOCOLIE_BY_ID(F1AP_UEContextSetupResponseIEs_t, ie, container, + F1AP_ProtocolIE_ID_id_DRBs_Setup_List, false); + + if(ie!=NULL) { + f1ap_ue_context_setup_resp->drbs_to_be_setup_length = ie->value.choice.DRBs_Setup_List.list.count; + f1ap_ue_context_setup_resp->drbs_to_be_setup = calloc(f1ap_ue_context_setup_resp->drbs_to_be_setup_length, + sizeof(f1ap_drb_to_be_setup_t)); + AssertFatal(f1ap_ue_context_setup_resp->drbs_to_be_setup, + "could not allocate memory for f1ap_ue_context_setup_resp->drbs_setup\n"); + + for (i = 0; i < f1ap_ue_context_setup_resp->drbs_to_be_setup_length; ++i) { + f1ap_drb_to_be_setup_t *drb_p = &f1ap_ue_context_setup_resp->drbs_to_be_setup[i]; + F1AP_DRBs_Setup_Item_t *drbs_setup_item_p; + drbs_setup_item_p = &((F1AP_DRBs_Setup_ItemIEs_t *)ie->value.choice.DRBs_Setup_List.list.array[i])->value.choice.DRBs_Setup_Item; + drb_p->drb_id = drbs_setup_item_p->dRBID; + // TODO in the following, assume only one UP UL TNL is present. + // this matches/assumes OAI CU/DU implementation, can be up to 2! + drb_p->up_dl_tnl_length = 1; + AssertFatal(drbs_setup_item_p->dLUPTNLInformation_ToBeSetup_List.list.count > 0, + "no DL UP TNL Information in DRBs to be Setup list\n"); + F1AP_DLUPTNLInformation_ToBeSetup_Item_t *dl_up_tnl_info_p = (F1AP_DLUPTNLInformation_ToBeSetup_Item_t *)drbs_setup_item_p->dLUPTNLInformation_ToBeSetup_List.list.array[0]; + F1AP_GTPTunnel_t *dl_up_tnl0 = dl_up_tnl_info_p->dLUPTNLInformation.choice.gTPTunnel; + BIT_STRING_TO_TRANSPORT_LAYER_ADDRESS_IPv4(&dl_up_tnl0->transportLayerAddress, drb_p->up_dl_tnl[0].tl_address); + OCTET_STRING_TO_INT32(&dl_up_tnl0->gTP_TEID, drb_p->up_dl_tnl[0].teid); + GtpuUpdateTunnelOutgoingTeid(getCxt(CUtype, instance)->gtpInst, + f1ap_ue_context_setup_resp->rnti, + (ebi_t)drbs_setup_item_p->dRBID, + drb_p->up_dl_tnl[0].teid); + } + } + + // SRBs_FailedToBeSetup_List F1AP_FIND_PROTOCOLIE_BY_ID(F1AP_UEContextSetupResponseIEs_t, ie, container, - F1AP_ProtocolIE_ID_id_DRBs_Setup_List, true); + F1AP_ProtocolIE_ID_id_SRBs_FailedToBeSetup_List, false); + + if(ie!=NULL) { + f1ap_ue_context_setup_resp->srbs_failed_to_be_setup_length = ie->value.choice.SRBs_FailedToBeSetup_List.list.count; + f1ap_ue_context_setup_resp->srbs_failed_to_be_setup = calloc(f1ap_ue_context_setup_resp->srbs_failed_to_be_setup_length, + sizeof(f1ap_rb_failed_to_be_setup_t)); + AssertFatal(f1ap_ue_context_setup_resp->srbs_failed_to_be_setup, + "could not allocate memory for f1ap_ue_context_setup_resp->srbs_failed_to_be_setup\n"); + + for (i = 0; i < f1ap_ue_context_setup_resp->srbs_failed_to_be_setup_length; ++i) { + f1ap_rb_failed_to_be_setup_t *srb_p = &f1ap_ue_context_setup_resp->srbs_failed_to_be_setup[i]; + srb_p->rb_id = ((F1AP_SRBs_FailedToBeSetup_Item_t *)ie->value.choice.SRBs_FailedToBeSetup_List.list.array[i])->sRBID; + } + } - /* SRBs_FailedToBeSetup_List */ + // DRBs_FailedToBeSetup_List F1AP_FIND_PROTOCOLIE_BY_ID(F1AP_UEContextSetupResponseIEs_t, ie, container, - F1AP_ProtocolIE_ID_id_SRBs_FailedToBeSetup_List, true); + F1AP_ProtocolIE_ID_id_DRBs_FailedToBeSetup_List, false); + + if(ie!=NULL) { + f1ap_ue_context_setup_resp->drbs_failed_to_be_setup_length = ie->value.choice.DRBs_FailedToBeSetup_List.list.count; + f1ap_ue_context_setup_resp->drbs_failed_to_be_setup = calloc(f1ap_ue_context_setup_resp->drbs_failed_to_be_setup_length, + sizeof(f1ap_rb_failed_to_be_setup_t)); + AssertFatal(f1ap_ue_context_setup_resp->drbs_failed_to_be_setup, + "could not allocate memory for f1ap_ue_context_setup_resp->drbs_failed_to_be_setup\n"); + + for (i = 0; i < f1ap_ue_context_setup_resp->drbs_failed_to_be_setup_length; ++i) { + f1ap_rb_failed_to_be_setup_t *drb_p = &f1ap_ue_context_setup_resp->drbs_failed_to_be_setup[i]; + drb_p->rb_id = ((F1AP_DRBs_FailedToBeSetup_Item_t *)ie->value.choice.DRBs_FailedToBeSetup_List.list.array[i])->dRBID; + } + } - /* DRBs_FailedToBeSetup_List */ + // SCell_FailedtoSetup_List F1AP_FIND_PROTOCOLIE_BY_ID(F1AP_UEContextSetupResponseIEs_t, ie, container, - F1AP_ProtocolIE_ID_id_DRBs_FailedToBeSetup_List, true); + F1AP_ProtocolIE_ID_id_SCell_FailedtoSetup_List, false); - /* SCell_FailedtoSetup_List */ + if(ie!=NULL) { + LOG_E (F1AP, "Not supporting handling of SCell_FailedtoSetup_List \n"); + } + + // SRBs_Setup_List F1AP_FIND_PROTOCOLIE_BY_ID(F1AP_UEContextSetupResponseIEs_t, ie, container, - F1AP_ProtocolIE_ID_id_SCell_FailedtoSetup_List, true); + F1AP_ProtocolIE_ID_id_SRBs_Setup_List, false); + + if(ie!=NULL) { + f1ap_ue_context_setup_resp->srbs_to_be_setup_length = ie->value.choice.SRBs_Setup_List.list.count; + f1ap_ue_context_setup_resp->srbs_to_be_setup = calloc(f1ap_ue_context_setup_resp->srbs_to_be_setup_length, + sizeof(f1ap_srb_to_be_setup_t)); + AssertFatal(f1ap_ue_context_setup_resp->srbs_to_be_setup, + "could not allocate memory for f1ap_ue_context_setup_resp->drbs_setup\n"); + + for (i = 0; i < f1ap_ue_context_setup_resp->srbs_to_be_setup_length; ++i) { + f1ap_srb_to_be_setup_t *srb_p = &f1ap_ue_context_setup_resp->srbs_to_be_setup[i]; + F1AP_SRBs_Setup_Item_t *srbs_setup_item_p; + srbs_setup_item_p = &((F1AP_SRBs_Setup_ItemIEs_t *)ie->value.choice.SRBs_Setup_List.list.array[i])->value.choice.SRBs_Setup_Item; + srb_p->srb_id = srbs_setup_item_p->sRBID; + srb_p->lcid = srbs_setup_item_p->lCID; + } + } + itti_send_msg_to_task(TASK_RRC_GNB, instance, msg_p); return 0; } @@ -841,31 +770,26 @@ int CU_handle_UE_CONTEXT_SETUP_FAILURE(instance_t instance, AssertFatal(1==0,"Not implemented yet\n"); } - int CU_handle_UE_CONTEXT_RELEASE_REQUEST(instance_t instance, - uint32_t assoc_id, - uint32_t stream, - F1AP_F1AP_PDU_t *pdu) { + uint32_t assoc_id, + uint32_t stream, + F1AP_F1AP_PDU_t *pdu) { F1AP_UEContextReleaseRequest_t *container; F1AP_UEContextReleaseRequestIEs_t *ie; - DevAssert(pdu); - container = &pdu->choice.initiatingMessage->value.choice.UEContextReleaseRequest; /* GNB_CU_UE_F1AP_ID */ F1AP_FIND_PROTOCOLIE_BY_ID(F1AP_UEContextReleaseRequestIEs_t, ie, container, F1AP_ProtocolIE_ID_id_gNB_CU_UE_F1AP_ID, true); - const rnti_t rnti = f1ap_get_rnti_by_cu_id(&f1ap_cu_inst[instance], - ie->value.choice.GNB_CU_UE_F1AP_ID); - + const rnti_t rnti = f1ap_get_rnti_by_cu_id(true, instance, + ie->value.choice.GNB_CU_UE_F1AP_ID); /* GNB_DU_UE_F1AP_ID */ F1AP_FIND_PROTOCOLIE_BY_ID(F1AP_UEContextReleaseRequestIEs_t, ie, container, F1AP_ProtocolIE_ID_id_gNB_DU_UE_F1AP_ID, true); - const rnti_t rnti2 = f1ap_get_rnti_by_du_id(&f1ap_cu_inst[instance], - ie->value.choice.GNB_DU_UE_F1AP_ID); + const rnti_t rnti2 = f1ap_get_rnti_by_du_id(CUtype, instance, + ie->value.choice.GNB_DU_UE_F1AP_ID); AssertFatal(rnti == rnti2, "RNTI obtained through DU ID (%x) is different from CU ID (%x)\n", rnti2, rnti); - /* Cause */ /* We don't care for the moment F1AP_FIND_PROTOCOLIE_BY_ID(F1AP_UEContextReleaseRequestIEs_t, ie, container, @@ -890,15 +814,19 @@ int CU_handle_UE_CONTEXT_RELEASE_REQUEST(instance_t instance, break; } */ - LOG_I(F1AP, "Received UE CONTEXT RELEASE REQUEST: Trigger RRC for RNTI %x\n", rnti); - struct rrc_eNB_ue_context_s *ue_context_pP; - ue_context_pP = rrc_eNB_get_ue_context(RC.rrc[instance], rnti); - rrc_eNB_send_S1AP_UE_CONTEXT_RELEASE_REQ( + + if (f1ap_req(true, instance)->cell_type==CELL_MACRO_GNB) { + AssertFatal(false,"must be devlopped\n"); + } else { + struct rrc_eNB_ue_context_s *ue_context_pP; + ue_context_pP = rrc_eNB_get_ue_context(RC.rrc[instance], rnti); + rrc_eNB_send_S1AP_UE_CONTEXT_RELEASE_REQ( instance, ue_context_pP, S1AP_CAUSE_RADIO_NETWORK, 21); // send cause 21: connection with ue lost + } return 0; } @@ -906,82 +834,74 @@ int CU_handle_UE_CONTEXT_RELEASE_REQUEST(instance_t instance, int CU_send_UE_CONTEXT_RELEASE_COMMAND(instance_t instance, f1ap_ue_context_release_cmd_t *cmd) { - F1AP_F1AP_PDU_t pdu; + F1AP_F1AP_PDU_t pdu= {0}; F1AP_UEContextReleaseCommand_t *out; - F1AP_UEContextReleaseCommandIEs_t *ie; - - uint8_t *buffer; - uint32_t len; - + uint8_t *buffer=NULL; + uint32_t len=0; /* Create */ /* 0. Message Type */ - memset(&pdu, 0, sizeof(pdu)); pdu.present = F1AP_F1AP_PDU_PR_initiatingMessage; - pdu.choice.initiatingMessage = (F1AP_InitiatingMessage_t *)calloc(1, sizeof(F1AP_InitiatingMessage_t)); - pdu.choice.initiatingMessage->procedureCode = F1AP_ProcedureCode_id_UEContextRelease; - pdu.choice.initiatingMessage->criticality = F1AP_Criticality_reject; - pdu.choice.initiatingMessage->value.present = F1AP_InitiatingMessage__value_PR_UEContextReleaseCommand; - out = &pdu.choice.initiatingMessage->value.choice.UEContextReleaseCommand; - + asn1cCalloc(pdu.choice.initiatingMessage, tmp); + tmp->procedureCode = F1AP_ProcedureCode_id_UEContextRelease; + tmp->criticality = F1AP_Criticality_reject; + tmp->value.present = F1AP_InitiatingMessage__value_PR_UEContextReleaseCommand; + out = &tmp->value.choice.UEContextReleaseCommand; /* mandatory */ /* c1. GNB_CU_UE_F1AP_ID */ - ie = (F1AP_UEContextReleaseCommandIEs_t *)calloc(1, sizeof(F1AP_UEContextReleaseCommandIEs_t)); - ie->id = F1AP_ProtocolIE_ID_id_gNB_CU_UE_F1AP_ID; - ie->criticality = F1AP_Criticality_reject; - ie->value.present = F1AP_UEContextReleaseCommandIEs__value_PR_GNB_CU_UE_F1AP_ID; - ie->value.choice.GNB_CU_UE_F1AP_ID = f1ap_get_cu_ue_f1ap_id(&f1ap_cu_inst[instance], cmd->rnti); - ASN_SEQUENCE_ADD(&out->protocolIEs.list, ie); - + asn1cSequenceAdd(out->protocolIEs.list, F1AP_UEContextReleaseCommandIEs_t, ie1); + ie1->id = F1AP_ProtocolIE_ID_id_gNB_CU_UE_F1AP_ID; + ie1->criticality = F1AP_Criticality_reject; + ie1->value.present = F1AP_UEContextReleaseCommandIEs__value_PR_GNB_CU_UE_F1AP_ID; + ie1->value.choice.GNB_CU_UE_F1AP_ID = f1ap_get_cu_ue_f1ap_id(CUtype, instance, cmd->rnti); /* mandatory */ /* c2. GNB_DU_UE_F1AP_ID */ - ie = (F1AP_UEContextReleaseCommandIEs_t *)calloc(1, sizeof(F1AP_UEContextReleaseCommandIEs_t)); - ie->id = F1AP_ProtocolIE_ID_id_gNB_DU_UE_F1AP_ID; - ie->criticality = F1AP_Criticality_reject; - ie->value.present = F1AP_UEContextReleaseCommandIEs__value_PR_GNB_DU_UE_F1AP_ID; - ie->value.choice.GNB_DU_UE_F1AP_ID = f1ap_get_du_ue_f1ap_id(&f1ap_cu_inst[instance], cmd->rnti); - ASN_SEQUENCE_ADD(&out->protocolIEs.list, ie); - + asn1cSequenceAdd(out->protocolIEs.list, F1AP_UEContextReleaseCommandIEs_t, ie2); + ie2->id = F1AP_ProtocolIE_ID_id_gNB_DU_UE_F1AP_ID; + ie2->criticality = F1AP_Criticality_reject; + ie2->value.present = F1AP_UEContextReleaseCommandIEs__value_PR_GNB_DU_UE_F1AP_ID; + ie2->value.choice.GNB_DU_UE_F1AP_ID = f1ap_get_du_ue_f1ap_id(CUtype, instance, cmd->rnti); /* mandatory */ /* c3. Cause */ - ie = (F1AP_UEContextReleaseCommandIEs_t *)calloc(1, sizeof(F1AP_UEContextReleaseCommandIEs_t)); - ie->id = F1AP_ProtocolIE_ID_id_Cause; - ie->criticality = F1AP_Criticality_ignore; - ie->value.present = F1AP_UEContextReleaseCommandIEs__value_PR_Cause; + asn1cSequenceAdd(out->protocolIEs.list, F1AP_UEContextReleaseCommandIEs_t, ie3); + ie3->id = F1AP_ProtocolIE_ID_id_Cause; + ie3->criticality = F1AP_Criticality_ignore; + ie3->value.present = F1AP_UEContextReleaseCommandIEs__value_PR_Cause; switch (cmd->cause) { case F1AP_CAUSE_RADIO_NETWORK: - ie->value.choice.Cause.present = F1AP_Cause_PR_radioNetwork; - ie->value.choice.Cause.choice.radioNetwork = cmd->cause_value; + ie3->value.choice.Cause.present = F1AP_Cause_PR_radioNetwork; + ie3->value.choice.Cause.choice.radioNetwork = cmd->cause_value; break; + case F1AP_CAUSE_TRANSPORT: - ie->value.choice.Cause.present = F1AP_Cause_PR_transport; - ie->value.choice.Cause.choice.transport = cmd->cause_value; + ie3->value.choice.Cause.present = F1AP_Cause_PR_transport; + ie3->value.choice.Cause.choice.transport = cmd->cause_value; break; + case F1AP_CAUSE_PROTOCOL: - ie->value.choice.Cause.present = F1AP_Cause_PR_protocol; - ie->value.choice.Cause.choice.protocol = cmd->cause_value; + ie3->value.choice.Cause.present = F1AP_Cause_PR_protocol; + ie3->value.choice.Cause.choice.protocol = cmd->cause_value; break; + case F1AP_CAUSE_MISC: - ie->value.choice.Cause.present = F1AP_Cause_PR_misc; - ie->value.choice.Cause.choice.misc = cmd->cause_value; + ie3->value.choice.Cause.present = F1AP_Cause_PR_misc; + ie3->value.choice.Cause.choice.misc = cmd->cause_value; break; + case F1AP_CAUSE_NOTHING: default: - ie->value.choice.Cause.present = F1AP_Cause_PR_NOTHING; + ie3->value.choice.Cause.present = F1AP_Cause_PR_NOTHING; break; } - ASN_SEQUENCE_ADD(&out->protocolIEs.list, ie); /* optional */ /* c4. RRCContainer */ - ie = (F1AP_UEContextReleaseCommandIEs_t *)calloc(1, sizeof(F1AP_UEContextReleaseCommandIEs_t)); - ie->id = F1AP_ProtocolIE_ID_id_RRCContainer; - ie->criticality = F1AP_Criticality_ignore; - ie->value.present = F1AP_UEContextReleaseCommandIEs__value_PR_RRCContainer; - - OCTET_STRING_fromBuf(&ie->value.choice.RRCContainer, (const char *)cmd->rrc_container, + asn1cSequenceAdd(out->protocolIEs.list, F1AP_UEContextReleaseCommandIEs_t, ie4); + ie4->id = F1AP_ProtocolIE_ID_id_RRCContainer; + ie4->criticality = F1AP_Criticality_ignore; + ie4->value.present = F1AP_UEContextReleaseCommandIEs__value_PR_RRCContainer; + OCTET_STRING_fromBuf(&ie4->value.choice.RRCContainer, (const char *)cmd->rrc_container, cmd->rrc_container_length); - ASN_SEQUENCE_ADD(&out->protocolIEs.list, ie); /* encode */ if (f1ap_encode_pdu(&pdu, &buffer, &len) < 0) { @@ -989,91 +909,85 @@ int CU_send_UE_CONTEXT_RELEASE_COMMAND(instance_t instance, return -1; } - cu_f1ap_itti_send_sctp_data_req(instance, f1ap_du_data_from_du->assoc_id, buffer, len, 0); - + f1ap_itti_send_sctp_data_req(true, instance, buffer, len, 0); return 0; } - int CU_handle_UE_CONTEXT_RELEASE_COMPLETE(instance_t instance, - uint32_t assoc_id, - uint32_t stream, - F1AP_F1AP_PDU_t *pdu) { + uint32_t assoc_id, + uint32_t stream, + F1AP_F1AP_PDU_t *pdu) { F1AP_UEContextReleaseComplete_t *container; F1AP_UEContextReleaseCompleteIEs_t *ie; - DevAssert(pdu); - container = &pdu->choice.successfulOutcome->value.choice.UEContextReleaseComplete; /* GNB_CU_UE_F1AP_ID */ F1AP_FIND_PROTOCOLIE_BY_ID(F1AP_UEContextReleaseCompleteIEs_t, ie, container, F1AP_ProtocolIE_ID_id_gNB_CU_UE_F1AP_ID, true); - const rnti_t rnti = f1ap_get_rnti_by_cu_id(&f1ap_cu_inst[instance], - ie->value.choice.GNB_CU_UE_F1AP_ID); - + const rnti_t rnti = f1ap_get_rnti_by_cu_id(CUtype, instance, + ie->value.choice.GNB_CU_UE_F1AP_ID); /* GNB_DU_UE_F1AP_ID */ F1AP_FIND_PROTOCOLIE_BY_ID(F1AP_UEContextReleaseCompleteIEs_t, ie, container, F1AP_ProtocolIE_ID_id_gNB_DU_UE_F1AP_ID, true); - const rnti_t rnti2 = f1ap_get_rnti_by_du_id(&f1ap_cu_inst[instance], - ie->value.choice.GNB_DU_UE_F1AP_ID); + const rnti_t rnti2 = f1ap_get_rnti_by_du_id(CUtype, instance, + ie->value.choice.GNB_DU_UE_F1AP_ID); AssertFatal(rnti == rnti2, "RNTI obtained through DU ID (%x) is different from CU ID (%x)\n", rnti2, rnti); - /* Optional*/ /* CriticalityDiagnostics */ F1AP_FIND_PROTOCOLIE_BY_ID(F1AP_UEContextReleaseCompleteIEs_t, ie, container, F1AP_ProtocolIE_ID_id_CriticalityDiagnostics, false); + if (ie) { // ie->value.choice.CriticalityDiagnostics.procedureCode // ie->value.choice.CriticalityDiagnostics.triggeringMessage // ie->value.choice.CriticalityDiagnostics.procedureCriticality // ie->value.choice.CriticalityDiagnostics.transactionID - // F1AP_CriticalityDiagnostics_IE_List } protocol_ctxt_t ctxt; PROTOCOL_CTXT_SET_BY_MODULE_ID(&ctxt, instance, ENB_FLAG_YES, rnti, 0, 0, instance); - if (RC.nrrrc[instance]->node_type == ngran_gNB_CU) { + if (f1ap_req(true, instance)->cell_type==CELL_MACRO_GNB) { struct rrc_gNB_ue_context_s *ue_context_p = - rrc_gNB_get_ue_context(RC.nrrrc[instance], rnti); + rrc_gNB_get_ue_context(RC.nrrrc[instance], rnti); if (ue_context_p) { MessageDef *msg = itti_alloc_new_message(TASK_CU_F1, 0, NGAP_UE_CONTEXT_RELEASE_COMPLETE); NGAP_UE_CONTEXT_RELEASE_COMPLETE(msg).gNB_ue_ngap_id = ue_context_p->ue_context.gNB_ue_ngap_id; itti_send_msg_to_task(TASK_NGAP, instance, msg); - rrc_gNB_remove_ue_context(&ctxt, RC.nrrrc[instance], ue_context_p); } else { LOG_E(F1AP, "could not find ue_context of UE RNTI %x\n", rnti); } + #ifdef ITTI_SIM return 0; #endif - } else { struct rrc_eNB_ue_context_s *ue_context_p = - rrc_eNB_get_ue_context(RC.rrc[instance], rnti); + rrc_eNB_get_ue_context(RC.rrc[instance], rnti); if (ue_context_p) { /* The following is normally done in the function rrc_rx_tx() */ rrc_eNB_send_S1AP_UE_CONTEXT_RELEASE_CPLT(instance, ue_context_p->ue_context.eNB_ue_s1ap_id); - rrc_eNB_send_GTPV1U_ENB_DELETE_TUNNEL_REQ(instance, ue_context_p); + // erase data of GTP tunnels in UE context for (int e_rab = 0; e_rab < ue_context_p->ue_context.nb_of_e_rabs; e_rab++) { ue_context_p->ue_context.enb_gtp_teid[e_rab] = 0; memset(&ue_context_p->ue_context.enb_gtp_addrs[e_rab], - 0, sizeof(ue_context_p->ue_context.enb_gtp_addrs[e_rab])); + 0, sizeof(ue_context_p->ue_context.enb_gtp_addrs[e_rab])); ue_context_p->ue_context.enb_gtp_ebi[e_rab] = 0; } struct rrc_ue_s1ap_ids_s *rrc_ue_s1ap_ids = - rrc_eNB_S1AP_get_ue_ids(RC.rrc[instance], 0, - ue_context_p->ue_context.eNB_ue_s1ap_id); + rrc_eNB_S1AP_get_ue_ids(RC.rrc[instance], 0, + ue_context_p->ue_context.eNB_ue_s1ap_id); + if (rrc_ue_s1ap_ids) - rrc_eNB_S1AP_remove_ue_ids(RC.rrc[instance], rrc_ue_s1ap_ids); + rrc_eNB_S1AP_remove_ue_ids(RC.rrc[instance], rrc_ue_s1ap_ids); /* trigger UE release in RRC */ rrc_eNB_remove_ue_context(&ctxt, RC.rrc[instance], ue_context_p); @@ -1087,477 +1001,345 @@ int CU_handle_UE_CONTEXT_RELEASE_COMPLETE(instance_t instance, /* notify the agent */ if (flexran_agent_get_rrc_xface(instance)) flexran_agent_get_rrc_xface(instance)->flexran_agent_notify_ue_state_change( - instance, rnti, PROTOCOL__FLEX_UE_STATE_CHANGE_TYPE__FLUESC_DEACTIVATED); + instance, rnti, PROTOCOL__FLEX_UE_STATE_CHANGE_TYPE__FLUESC_DEACTIVATED); LOG_I(F1AP, "Received UE CONTEXT RELEASE COMPLETE: Removing CU UE entry for RNTI %x\n", rnti); - f1ap_remove_ue(&f1ap_cu_inst[instance], rnti); + f1ap_remove_ue(CUtype, instance, rnti); return 0; } - - //void CU_send_UE_CONTEXT_MODIFICATION_REQUEST(F1AP_UEContextModificationRequest_t *UEContextModificationRequest) { int CU_send_UE_CONTEXT_MODIFICATION_REQUEST(instance_t instance) { - F1AP_F1AP_PDU_t pdu; + F1AP_F1AP_PDU_t pdu= {0}; F1AP_UEContextModificationRequest_t *out; - F1AP_UEContextModificationRequestIEs_t *ie; - - uint8_t *buffer; - uint32_t len; - int i = 0; - + uint8_t *buffer=NULL; + uint32_t len=0; // for test - int mcc = 208; - int mnc = 92; - int mnc_digit_length = 2; - + cellIDs_t hardCoded= { .mcc=208, .mnc=93, .mnc_digit_length=2}; /* Create */ /* 0. Message Type */ - memset(&pdu, 0, sizeof(pdu)); pdu.present = F1AP_F1AP_PDU_PR_initiatingMessage; - pdu.choice.initiatingMessage = (F1AP_InitiatingMessage_t *)calloc(1, sizeof(F1AP_InitiatingMessage_t)); - pdu.choice.initiatingMessage->procedureCode = F1AP_ProcedureCode_id_UEContextModification; - pdu.choice.initiatingMessage->criticality = F1AP_Criticality_reject; - pdu.choice.initiatingMessage->value.present = F1AP_InitiatingMessage__value_PR_UEContextModificationRequest; - out = &pdu.choice.initiatingMessage->value.choice.UEContextModificationRequest; - + asn1cCalloc(pdu.choice.initiatingMessage, tmp); + tmp->procedureCode = F1AP_ProcedureCode_id_UEContextModification; + tmp->criticality = F1AP_Criticality_reject; + tmp->value.present = F1AP_InitiatingMessage__value_PR_UEContextModificationRequest; + out = &tmp->value.choice.UEContextModificationRequest; /* mandatory */ /* c1. GNB_CU_UE_F1AP_ID */ - ie = (F1AP_UEContextModificationRequestIEs_t *)calloc(1, sizeof(F1AP_UEContextModificationRequestIEs_t)); - ie->id = F1AP_ProtocolIE_ID_id_gNB_CU_UE_F1AP_ID; - ie->criticality = F1AP_Criticality_reject; - ie->value.present = F1AP_UEContextModificationRequestIEs__value_PR_GNB_CU_UE_F1AP_ID; - ie->value.choice.GNB_CU_UE_F1AP_ID = 126L; - ASN_SEQUENCE_ADD(&out->protocolIEs.list, ie); - + asn1cSequenceAdd(out->protocolIEs.list, F1AP_UEContextModificationRequestIEs_t, ie1); + ie1->id = F1AP_ProtocolIE_ID_id_gNB_CU_UE_F1AP_ID; + ie1->criticality = F1AP_Criticality_reject; + ie1->value.present = F1AP_UEContextModificationRequestIEs__value_PR_GNB_CU_UE_F1AP_ID; + ie1->value.choice.GNB_CU_UE_F1AP_ID = 126L; /* mandatory */ /* c2. GNB_DU_UE_F1AP_ID */ - ie = (F1AP_UEContextModificationRequestIEs_t *)calloc(1, sizeof(F1AP_UEContextModificationRequestIEs_t)); - ie->id = F1AP_ProtocolIE_ID_id_gNB_DU_UE_F1AP_ID; - ie->criticality = F1AP_Criticality_reject; - ie->value.present = F1AP_UEContextModificationRequestIEs__value_PR_GNB_DU_UE_F1AP_ID; - ie->value.choice.GNB_DU_UE_F1AP_ID = 651L; - ASN_SEQUENCE_ADD(&out->protocolIEs.list, ie); + asn1cSequenceAdd(out->protocolIEs.list, F1AP_UEContextModificationRequestIEs_t, ie2); + ie2->id = F1AP_ProtocolIE_ID_id_gNB_DU_UE_F1AP_ID; + ie2->criticality = F1AP_Criticality_reject; + ie2->value.present = F1AP_UEContextModificationRequestIEs__value_PR_GNB_DU_UE_F1AP_ID; + ie2->value.choice.GNB_DU_UE_F1AP_ID = 651L; /* optional */ /* c3. NRCGI */ if (0) { - ie = (F1AP_UEContextModificationRequestIEs_t *)calloc(1, sizeof(F1AP_UEContextModificationRequestIEs_t)); - ie->id = F1AP_ProtocolIE_ID_id_SpCell_ID; - ie->criticality = F1AP_Criticality_ignore; - ie->value.present = F1AP_UEContextModificationRequestIEs__value_PR_NRCGI; + asn1cSequenceAdd(out->protocolIEs.list, F1AP_UEContextModificationRequestIEs_t, ie3); + ie3->id = F1AP_ProtocolIE_ID_id_SpCell_ID; + ie3->criticality = F1AP_Criticality_ignore; + ie3->value.present = F1AP_UEContextModificationRequestIEs__value_PR_NRCGI; /* - nRCGI */ - F1AP_NRCGI_t nRCGI; - MCC_MNC_TO_PLMNID(mcc, mnc, mnc_digit_length, - &nRCGI.pLMN_Identity); - NR_CELL_ID_TO_BIT_STRING(12345678, &nRCGI.nRCellIdentity); - ie->value.choice.NRCGI = nRCGI; - - ASN_SEQUENCE_ADD(&out->protocolIEs.list, ie); + addnRCGI(ie3->value.choice.NRCGI, &hardCoded); } /* mandatory */ /* c4. ServCellIndex */ - ie = (F1AP_UEContextModificationRequestIEs_t *)calloc(1, sizeof(F1AP_UEContextModificationRequestIEs_t)); - ie->id = F1AP_ProtocolIE_ID_id_ServCellIndex; - ie->criticality = F1AP_Criticality_reject; - ie->value.present = F1AP_UEContextModificationRequestIEs__value_PR_ServCellIndex; - ie->value.choice.ServCellIndex = 5L; - ASN_SEQUENCE_ADD(&out->protocolIEs.list, ie); + asn1cSequenceAdd(out->protocolIEs.list, F1AP_UEContextModificationRequestIEs_t, ie4); + ie4->id = F1AP_ProtocolIE_ID_id_ServCellIndex; + ie4->criticality = F1AP_Criticality_reject; + ie4->value.present = F1AP_UEContextModificationRequestIEs__value_PR_ServCellIndex; + ie4->value.choice.ServCellIndex = 5L; /* optional */ /* c5. DRXCycle */ if (0) { - ie = (F1AP_UEContextModificationRequestIEs_t *)calloc(1, sizeof(F1AP_UEContextModificationRequestIEs_t)); - ie->id = F1AP_ProtocolIE_ID_id_DRXCycle; - ie->criticality = F1AP_Criticality_ignore; - ie->value.present = F1AP_UEContextModificationRequestIEs__value_PR_DRXCycle; - ie->value.choice.DRXCycle.longDRXCycleLength = F1AP_LongDRXCycleLength_ms10; // enum + asn1cSequenceAdd(out->protocolIEs.list, F1AP_UEContextModificationRequestIEs_t, ie5); + ie5->id = F1AP_ProtocolIE_ID_id_DRXCycle; + ie5->criticality = F1AP_Criticality_ignore; + ie5->value.present = F1AP_UEContextModificationRequestIEs__value_PR_DRXCycle; + ie5->value.choice.DRXCycle.longDRXCycleLength = F1AP_LongDRXCycleLength_ms10; // enum + if (0) { - ie->value.choice.DRXCycle.shortDRXCycleLength = (F1AP_ShortDRXCycleLength_t *)calloc(1, sizeof(F1AP_ShortDRXCycleLength_t)); - *ie->value.choice.DRXCycle.shortDRXCycleLength = F1AP_ShortDRXCycleLength_ms2; // enum + asn1cCallocOne(ie5->value.choice.DRXCycle.shortDRXCycleLength, + F1AP_ShortDRXCycleLength_ms2); // enum } + if (0) { - ie->value.choice.DRXCycle.shortDRXCycleTimer = (F1AP_ShortDRXCycleTimer_t *)calloc(1, sizeof(F1AP_ShortDRXCycleTimer_t)); - *ie->value.choice.DRXCycle.shortDRXCycleTimer = 123L; + asn1cCallocOne(ie5->value.choice.DRXCycle.shortDRXCycleTimer, 123L); } - ASN_SEQUENCE_ADD(&out->protocolIEs.list, ie); } /* optional */ /* c5. CUtoDURRCInformation */ if (1) { - ie = (F1AP_UEContextModificationRequestIEs_t *)calloc(1, sizeof(F1AP_UEContextModificationRequestIEs_t)); - ie->id = F1AP_ProtocolIE_ID_id_CUtoDURRCInformation; - ie->criticality = F1AP_Criticality_reject; - ie->value.present = F1AP_UEContextModificationRequestIEs__value_PR_CUtoDURRCInformation; - ie->value.choice.CUtoDURRCInformation.cG_ConfigInfo = (F1AP_CG_ConfigInfo_t *)calloc(1, sizeof(F1AP_CG_ConfigInfo_t)); + asn1cSequenceAdd(out->protocolIEs.list, F1AP_UEContextModificationRequestIEs_t, ie5); + ie5->id = F1AP_ProtocolIE_ID_id_CUtoDURRCInformation; + ie5->criticality = F1AP_Criticality_reject; + ie5->value.present = F1AP_UEContextModificationRequestIEs__value_PR_CUtoDURRCInformation; + asn1cCalloc(ie5->value.choice.CUtoDURRCInformation.cG_ConfigInfo, tmp); /* optional */ - OCTET_STRING_fromBuf(ie->value.choice.CUtoDURRCInformation.cG_ConfigInfo, "asdsa1d32sa1d31asd31as", + OCTET_STRING_fromBuf(tmp, "asdsa1d32sa1d31asd31as", strlen("asdsa1d32sa1d31asd31as")); - ie->value.choice.CUtoDURRCInformation.uE_CapabilityRAT_ContainerList = (F1AP_UE_CapabilityRAT_ContainerList_t *)calloc(1, sizeof(F1AP_UE_CapabilityRAT_ContainerList_t)); + asn1cCalloc(ie5->value.choice.CUtoDURRCInformation.uE_CapabilityRAT_ContainerList, + tmp2); /* optional */ - OCTET_STRING_fromBuf(ie->value.choice.CUtoDURRCInformation.uE_CapabilityRAT_ContainerList, "asdsa1d32sa1d31asd31as", + OCTET_STRING_fromBuf(tmp2, "asdsa1d32sa1d31asd31as", strlen("asdsa1d32sa1d31asd31as")); - ASN_SEQUENCE_ADD(&out->protocolIEs.list, ie); } /* optional */ /* c6. TransmissionActionIndicator */ if (1) { - ie = (F1AP_UEContextModificationRequestIEs_t *)calloc(1, sizeof(F1AP_UEContextModificationRequestIEs_t)); - ie->id = F1AP_ProtocolIE_ID_id_TransmissionActionIndicator; - ie->criticality = F1AP_Criticality_ignore; - ie->value.present = F1AP_UEContextModificationRequestIEs__value_PR_TransmissionActionIndicator; - ie->value.choice.TransmissionActionIndicator = F1AP_TransmissionActionIndicator_stop; - ASN_SEQUENCE_ADD(&out->protocolIEs.list, ie); + asn1cSequenceAdd(out->protocolIEs.list, F1AP_UEContextModificationRequestIEs_t, ie6); + ie6->id = F1AP_ProtocolIE_ID_id_TransmissionActionIndicator; + ie6->criticality = F1AP_Criticality_ignore; + ie6->value.present = F1AP_UEContextModificationRequestIEs__value_PR_TransmissionActionIndicator; + ie6->value.choice.TransmissionActionIndicator = F1AP_TransmissionActionIndicator_stop; } /* optional */ /* c7. ResourceCoordinationTransferContainer */ if (0) { - ie = (F1AP_UEContextModificationRequestIEs_t *)calloc(1, sizeof(F1AP_UEContextModificationRequestIEs_t)); - ie->id = F1AP_ProtocolIE_ID_id_ResourceCoordinationTransferContainer; - ie->criticality = F1AP_Criticality_ignore; - ie->value.present = F1AP_UEContextModificationRequestIEs__value_PR_ResourceCoordinationTransferContainer; - OCTET_STRING_fromBuf(&ie->value.choice.ResourceCoordinationTransferContainer, "asdsa1d32sa1d31asd31as", + asn1cSequenceAdd(out->protocolIEs.list, F1AP_UEContextModificationRequestIEs_t, ie7); + ie7->id = F1AP_ProtocolIE_ID_id_ResourceCoordinationTransferContainer; + ie7->criticality = F1AP_Criticality_ignore; + ie7->value.present = F1AP_UEContextModificationRequestIEs__value_PR_ResourceCoordinationTransferContainer; + OCTET_STRING_fromBuf(&ie7->value.choice.ResourceCoordinationTransferContainer, "asdsa1d32sa1d31asd31as", strlen("asdsa1d32sa1d31asd31as")); - ASN_SEQUENCE_ADD(&out->protocolIEs.list, ie); } /* optional */ /* c7. RRCRconfigurationCompleteIndicator */ if (1) { - ie = (F1AP_UEContextModificationRequestIEs_t *)calloc(1, sizeof(F1AP_UEContextModificationRequestIEs_t)); - ie->id = F1AP_ProtocolIE_ID_id_RRCReconfigurationCompleteIndicator; - ie->criticality = F1AP_Criticality_ignore; - ie->value.present = F1AP_UEContextModificationRequestIEs__value_PR_RRCReconfigurationCompleteIndicator; - ie->value.choice.RRCReconfigurationCompleteIndicator = F1AP_RRCReconfigurationCompleteIndicator_true; - ASN_SEQUENCE_ADD(&out->protocolIEs.list, ie); + asn1cSequenceAdd(out->protocolIEs.list, F1AP_UEContextModificationRequestIEs_t, ie71); + ie71->id = F1AP_ProtocolIE_ID_id_RRCReconfigurationCompleteIndicator; + ie71->criticality = F1AP_Criticality_ignore; + ie71->value.present = F1AP_UEContextModificationRequestIEs__value_PR_RRCReconfigurationCompleteIndicator; + ie71->value.choice.RRCReconfigurationCompleteIndicator = F1AP_RRCReconfigurationCompleteIndicator_true; } /* optional */ /* c8. RRCContainer */ if (1) { - ie = (F1AP_UEContextModificationRequestIEs_t *)calloc(1, sizeof(F1AP_UEContextModificationRequestIEs_t)); - ie->id = F1AP_ProtocolIE_ID_id_RRCContainer; - ie->criticality = F1AP_Criticality_ignore; - ie->value.present = F1AP_UEContextModificationRequestIEs__value_PR_RRCContainer; - OCTET_STRING_fromBuf(&ie->value.choice.RRCContainer, "asdsa1d32sa1d31asd31as", + asn1cSequenceAdd(out->protocolIEs.list, F1AP_UEContextModificationRequestIEs_t, ie8); + ie8->id = F1AP_ProtocolIE_ID_id_RRCContainer; + ie8->criticality = F1AP_Criticality_ignore; + ie8->value.present = F1AP_UEContextModificationRequestIEs__value_PR_RRCContainer; + OCTET_STRING_fromBuf(&ie8->value.choice.RRCContainer, "asdsa1d32sa1d31asd31as", strlen("asdsa1d32sa1d31asd31as")); - ASN_SEQUENCE_ADD(&out->protocolIEs.list, ie); } /* mandatory */ /* c9. SCell_ToBeSetupMod_List */ - ie = (F1AP_UEContextModificationRequestIEs_t *)calloc(1, sizeof(F1AP_UEContextModificationRequestIEs_t)); - ie->id = F1AP_ProtocolIE_ID_id_SCell_ToBeSetupMod_List; - ie->criticality = F1AP_Criticality_ignore; - ie->value.present = F1AP_UEContextModificationRequestIEs__value_PR_SCell_ToBeSetupMod_List; - - for (i=0; - i<1; - i++) { - // - F1AP_SCell_ToBeSetupMod_ItemIEs_t *scell_toBeSetupMod_item_ies; - scell_toBeSetupMod_item_ies = (F1AP_SCell_ToBeSetupMod_ItemIEs_t *)calloc(1, sizeof(F1AP_SCell_ToBeSetupMod_ItemIEs_t)); - //memset((void *)&scell_toBeSetupMod_item_ies, 0, sizeof(F1AP_SCell_ToBeSetupMod_ItemIEs_t)); - scell_toBeSetupMod_item_ies->id = F1AP_ProtocolIE_ID_id_SCell_ToBeSetupMod_Item; - scell_toBeSetupMod_item_ies->criticality = F1AP_Criticality_ignore; - scell_toBeSetupMod_item_ies->value.present = F1AP_SCell_ToBeSetupMod_ItemIEs__value_PR_SCell_ToBeSetupMod_Item; - - /* 8.1 SCell_ToBeSetup_Item */ - F1AP_SCell_ToBeSetupMod_Item_t scell_toBeSetupMod_item; - memset((void *)&scell_toBeSetupMod_item, 0, sizeof(F1AP_SCell_ToBeSetupMod_Item_t)); - - // /* - sCell_ID */ - F1AP_NRCGI_t nRCGI; - memset(&nRCGI, 0, sizeof(F1AP_NRCGI_t)); - MCC_MNC_TO_PLMNID(mcc, mnc, mnc_digit_length, - &nRCGI.pLMN_Identity); - NR_CELL_ID_TO_BIT_STRING(12345678, &nRCGI.nRCellIdentity); - scell_toBeSetupMod_item.sCell_ID = nRCGI; - - /* sCellIndex */ - scell_toBeSetupMod_item.sCellIndex = 6; // issue here - - // /* ADD */ - scell_toBeSetupMod_item_ies->value.choice.SCell_ToBeSetupMod_Item = scell_toBeSetupMod_item; - ASN_SEQUENCE_ADD(&ie->value.choice.SCell_ToBeSetupMod_List.list, - scell_toBeSetupMod_item_ies); + asn1cSequenceAdd(out->protocolIEs.list, F1AP_UEContextModificationRequestIEs_t, ie9); + ie9->id = F1AP_ProtocolIE_ID_id_SCell_ToBeSetupMod_List; + ie9->criticality = F1AP_Criticality_ignore; + ie9->value.present = F1AP_UEContextModificationRequestIEs__value_PR_SCell_ToBeSetupMod_List; + + for (int i=0; i<1; i++) { + // + asn1cSequenceAdd(ie9->value.choice.SCell_ToBeSetupMod_List.list, + F1AP_SCell_ToBeSetupMod_ItemIEs_t, scell_toBeSetupMod_item_ies); + scell_toBeSetupMod_item_ies->id = F1AP_ProtocolIE_ID_id_SCell_ToBeSetupMod_Item; + scell_toBeSetupMod_item_ies->criticality = F1AP_Criticality_ignore; + scell_toBeSetupMod_item_ies->value.present = F1AP_SCell_ToBeSetupMod_ItemIEs__value_PR_SCell_ToBeSetupMod_Item; + /* 8.1 SCell_ToBeSetup_Item */ + F1AP_SCell_ToBeSetupMod_Item_t *scell_toBeSetupMod_item= + &scell_toBeSetupMod_item_ies->value.choice.SCell_ToBeSetupMod_Item; + // /* - sCell_ID */ + addnRCGI(scell_toBeSetupMod_item->sCell_ID, &hardCoded); + /* sCellIndex */ + scell_toBeSetupMod_item->sCellIndex = 6; // issue here } - ASN_SEQUENCE_ADD(&out->protocolIEs.list, ie); /* mandatory */ /* c10. SCell_ToBeRemoved_List */ - ie = (F1AP_UEContextModificationRequestIEs_t *)calloc(1, sizeof(F1AP_UEContextModificationRequestIEs_t)); - ie->id = F1AP_ProtocolIE_ID_id_SCell_ToBeRemoved_List; - ie->criticality = F1AP_Criticality_ignore; - ie->value.present = F1AP_UEContextModificationRequestIEs__value_PR_SCell_ToBeRemoved_List; - - for (i=0; - i<1; - i++) { - // - F1AP_SCell_ToBeRemoved_ItemIEs_t *scell_toBeRemoved_item_ies; - scell_toBeRemoved_item_ies = (F1AP_SCell_ToBeRemoved_ItemIEs_t *)calloc(1, sizeof(F1AP_SCell_ToBeRemoved_ItemIEs_t)); - //memset((void *)&scell_toBeRemoved_item_ies, 0, sizeof(F1AP_SCell_ToBeRemoved_ItemIEs_t)); - scell_toBeRemoved_item_ies->id = F1AP_ProtocolIE_ID_id_SCell_ToBeRemoved_Item; - scell_toBeRemoved_item_ies->criticality = F1AP_Criticality_ignore; - scell_toBeRemoved_item_ies->value.present = F1AP_SCell_ToBeRemoved_ItemIEs__value_PR_SCell_ToBeRemoved_Item; - - /* 10.1 SCell_ToBeRemoved_Item */ - F1AP_SCell_ToBeRemoved_Item_t scell_toBeRemoved_item; - memset((void *)&scell_toBeRemoved_item, 0, sizeof(F1AP_SCell_ToBeRemoved_Item_t)); - - /* - sCell_ID */ - F1AP_NRCGI_t nRCGI; - memset(&nRCGI, 0, sizeof(F1AP_NRCGI_t)); - MCC_MNC_TO_PLMNID(mcc, mnc, mnc_digit_length, - &nRCGI.pLMN_Identity); - NR_CELL_ID_TO_BIT_STRING(12345678, &nRCGI.nRCellIdentity); - scell_toBeRemoved_item.sCell_ID = nRCGI; - - /* ADD */ - scell_toBeRemoved_item_ies->value.choice.SCell_ToBeRemoved_Item = scell_toBeRemoved_item; - ASN_SEQUENCE_ADD(&ie->value.choice.SCell_ToBeRemoved_List.list, - scell_toBeRemoved_item_ies); + asn1cSequenceAdd(out->protocolIEs.list, F1AP_UEContextModificationRequestIEs_t, ie10); + ie10->id = F1AP_ProtocolIE_ID_id_SCell_ToBeRemoved_List; + ie10->criticality = F1AP_Criticality_ignore; + ie10->value.present = F1AP_UEContextModificationRequestIEs__value_PR_SCell_ToBeRemoved_List; + + for (int i=0; i<1; i++) { + // + asn1cSequenceAdd(ie10->value.choice.SCell_ToBeRemoved_List.list, + F1AP_SCell_ToBeRemoved_ItemIEs_t, scell_toBeRemoved_item_ies); + scell_toBeRemoved_item_ies = (F1AP_SCell_ToBeRemoved_ItemIEs_t *)calloc(1, sizeof(F1AP_SCell_ToBeRemoved_ItemIEs_t)); + //memset((void *)&scell_toBeRemoved_item_ies, 0, sizeof(F1AP_SCell_ToBeRemoved_ItemIEs_t)); + scell_toBeRemoved_item_ies->id = F1AP_ProtocolIE_ID_id_SCell_ToBeRemoved_Item; + scell_toBeRemoved_item_ies->criticality = F1AP_Criticality_ignore; + scell_toBeRemoved_item_ies->value.present = F1AP_SCell_ToBeRemoved_ItemIEs__value_PR_SCell_ToBeRemoved_Item; + /* 10.1 SCell_ToBeRemoved_Item */ + F1AP_SCell_ToBeRemoved_Item_t *scell_toBeRemoved_item= + &scell_toBeRemoved_item_ies->value.choice.SCell_ToBeRemoved_Item; + /* - sCell_ID */ + addnRCGI(scell_toBeRemoved_item->sCell_ID, &hardCoded); } - ASN_SEQUENCE_ADD(&out->protocolIEs.list, ie); /* mandatory */ /* c11. SRBs_ToBeSetupMod_List */ - ie = (F1AP_UEContextModificationRequestIEs_t *)calloc(1, sizeof(F1AP_UEContextModificationRequestIEs_t)); - ie->id = F1AP_ProtocolIE_ID_id_SRBs_ToBeSetupMod_List; - ie->criticality = F1AP_Criticality_reject; - ie->value.present = F1AP_UEContextModificationRequestIEs__value_PR_SRBs_ToBeSetupMod_List; - - for (i=0; - i<1; - i++) { + asn1cSequenceAdd(out->protocolIEs.list, F1AP_UEContextModificationRequestIEs_t, ie11); + ie11->id = F1AP_ProtocolIE_ID_id_SRBs_ToBeSetupMod_List; + ie11->criticality = F1AP_Criticality_reject; + ie11->value.present = F1AP_UEContextModificationRequestIEs__value_PR_SRBs_ToBeSetupMod_List; + + for (int i=0; i<1; i++) { // - F1AP_SRBs_ToBeSetupMod_ItemIEs_t *srbs_toBeSetupMod_item_ies; - srbs_toBeSetupMod_item_ies = (F1AP_SRBs_ToBeSetupMod_ItemIEs_t *)calloc(1, sizeof(F1AP_SRBs_ToBeSetupMod_ItemIEs_t)); - //memset((void *)&srbs_toBeSetupMod_item_ies, 0, sizeof(F1AP_SRBs_ToBeSetupMod_ItemIEs_t)); + asn1cSequenceAdd(ie11->value.choice.SRBs_ToBeSetupMod_List.list, + F1AP_SRBs_ToBeSetupMod_ItemIEs_t, srbs_toBeSetupMod_item_ies); srbs_toBeSetupMod_item_ies->id = F1AP_ProtocolIE_ID_id_SRBs_ToBeSetupMod_Item; srbs_toBeSetupMod_item_ies->criticality = F1AP_Criticality_ignore; srbs_toBeSetupMod_item_ies->value.present = F1AP_SRBs_ToBeSetupMod_ItemIEs__value_PR_SRBs_ToBeSetupMod_Item; - /* 9.1 SRBs_ToBeSetupMod_Item */ - F1AP_SRBs_ToBeSetupMod_Item_t srbs_toBeSetupMod_item; - memset((void *)&srbs_toBeSetupMod_item, 0, sizeof(F1AP_SRBs_ToBeSetupMod_Item_t)); - + F1AP_SRBs_ToBeSetupMod_Item_t *srbs_toBeSetupMod_item= + &srbs_toBeSetupMod_item_ies->value.choice.SRBs_ToBeSetupMod_Item; /* - sRBID */ - srbs_toBeSetupMod_item.sRBID = 3L; - - /* ADD */ - srbs_toBeSetupMod_item_ies->value.choice.SRBs_ToBeSetupMod_Item = srbs_toBeSetupMod_item; - - ASN_SEQUENCE_ADD(&ie->value.choice.SRBs_ToBeSetupMod_List.list, - srbs_toBeSetupMod_item_ies); + srbs_toBeSetupMod_item->sRBID = 3L; } - ASN_SEQUENCE_ADD(&out->protocolIEs.list, ie); - /* mandatory */ /* c12. DRBs_ToBeSetupMod_List */ - ie = (F1AP_UEContextModificationRequestIEs_t *)calloc(1, sizeof(F1AP_UEContextModificationRequestIEs_t)); - ie->id = F1AP_ProtocolIE_ID_id_DRBs_ToBeSetupMod_List; - ie->criticality = F1AP_Criticality_reject; - ie->value.present = F1AP_UEContextModificationRequestIEs__value_PR_DRBs_ToBeSetupMod_List; - - for (i=0; - i<1; - i++) { + asn1cSequenceAdd(out->protocolIEs.list, F1AP_UEContextModificationRequestIEs_t, ie12); + ie12->id = F1AP_ProtocolIE_ID_id_DRBs_ToBeSetupMod_List; + ie12->criticality = F1AP_Criticality_reject; + ie12->value.present = F1AP_UEContextModificationRequestIEs__value_PR_DRBs_ToBeSetupMod_List; + + for (int i=0; i<1; i++) { // - F1AP_DRBs_ToBeSetupMod_ItemIEs_t *drbs_toBeSetupMod_item_ies; - drbs_toBeSetupMod_item_ies = (F1AP_DRBs_ToBeSetupMod_ItemIEs_t *)calloc(1, sizeof(F1AP_DRBs_ToBeSetupMod_ItemIEs_t)); + asn1cSequenceAdd(ie12->value.choice.DRBs_ToBeSetupMod_List.list, + F1AP_DRBs_ToBeSetupMod_ItemIEs_t, drbs_toBeSetupMod_item_ies); drbs_toBeSetupMod_item_ies->id = F1AP_ProtocolIE_ID_id_DRBs_ToBeSetupMod_Item; drbs_toBeSetupMod_item_ies->criticality = F1AP_Criticality_reject; drbs_toBeSetupMod_item_ies->value.present = F1AP_DRBs_ToBeSetupMod_ItemIEs__value_PR_DRBs_ToBeSetupMod_Item; - /* 12.1 DRBs_ToBeSetupMod_Item */ - F1AP_DRBs_ToBeSetupMod_Item_t drbs_toBeSetupMod_item; - memset((void *)&drbs_toBeSetupMod_item, 0, sizeof(F1AP_DRBs_ToBeSetupMod_Item_t)); - + F1AP_DRBs_ToBeSetupMod_Item_t *drbs_toBeSetupMod_item= + &drbs_toBeSetupMod_item_ies->value.choice.DRBs_ToBeSetupMod_Item; /* dRBID */ - drbs_toBeSetupMod_item.dRBID = 30L; - + drbs_toBeSetupMod_item->dRBID = 30L; /* qoSInformation */ - drbs_toBeSetupMod_item.qoSInformation.present = F1AP_QoSInformation_PR_eUTRANQoS; - drbs_toBeSetupMod_item.qoSInformation.choice.eUTRANQoS = (F1AP_EUTRANQoS_t *)calloc(1, sizeof(F1AP_EUTRANQoS_t)); - drbs_toBeSetupMod_item.qoSInformation.choice.eUTRANQoS->qCI = 253L; - + drbs_toBeSetupMod_item->qoSInformation.present = F1AP_QoSInformation_PR_eUTRANQoS; + drbs_toBeSetupMod_item->qoSInformation.choice.eUTRANQoS = (F1AP_EUTRANQoS_t *)calloc(1, sizeof(F1AP_EUTRANQoS_t)); + drbs_toBeSetupMod_item->qoSInformation.choice.eUTRANQoS->qCI = 253L; /* uLUPTNLInformation_ToBeSetup_List */ - int j = 0; int maxnoofULTunnels = 1; // 2; - for (j=0; - j<maxnoofULTunnels; - j++) { - /* ULTunnels_ToBeSetup_Item */ - - F1AP_ULUPTNLInformation_ToBeSetup_Item_t *uLUPTNLInformation_ToBeSetup_Item; - uLUPTNLInformation_ToBeSetup_Item = (F1AP_ULUPTNLInformation_ToBeSetup_Item_t *)calloc(1, sizeof(F1AP_ULUPTNLInformation_ToBeSetup_Item_t)); - uLUPTNLInformation_ToBeSetup_Item->uLUPTNLInformation.present = F1AP_UPTransportLayerInformation_PR_gTPTunnel; - F1AP_GTPTunnel_t *gTPTunnel = (F1AP_GTPTunnel_t *)calloc(1, sizeof(F1AP_GTPTunnel_t)); - - /* transportLayerAddress */ - TRANSPORT_LAYER_ADDRESS_IPv4_TO_BIT_STRING(1234, &gTPTunnel->transportLayerAddress); - - /* gTP_TEID */ - OCTET_STRING_fromBuf(&gTPTunnel->gTP_TEID, "4567", - strlen("4567")); - - // Add - uLUPTNLInformation_ToBeSetup_Item->uLUPTNLInformation.choice.gTPTunnel = gTPTunnel; - ASN_SEQUENCE_ADD(&drbs_toBeSetupMod_item.uLUPTNLInformation_ToBeSetup_List.list, uLUPTNLInformation_ToBeSetup_Item); + + for (int j=0; j<maxnoofULTunnels; j++) { + /* ULTunnels_ToBeSetup_Item */ + asn1cSequenceAdd( drbs_toBeSetupMod_item->uLUPTNLInformation_ToBeSetup_List.list, + F1AP_ULUPTNLInformation_ToBeSetup_Item_t, uLUPTNLInformation_ToBeSetup_Item); + uLUPTNLInformation_ToBeSetup_Item->uLUPTNLInformation.present = F1AP_UPTransportLayerInformation_PR_gTPTunnel; + asn1cCalloc(uLUPTNLInformation_ToBeSetup_Item->uLUPTNLInformation.choice.gTPTunnel, + gTPTunnel) + /* transportLayerAddress */ + TRANSPORT_LAYER_ADDRESS_IPv4_TO_BIT_STRING(1234, &gTPTunnel->transportLayerAddress); + /* gTP_TEID */ + OCTET_STRING_fromBuf(&gTPTunnel->gTP_TEID, "4567", + strlen("4567")); } /* rLCMode */ - drbs_toBeSetupMod_item.rLCMode = F1AP_RLCMode_rlc_um_bidirectional; // enum + drbs_toBeSetupMod_item->rLCMode = F1AP_RLCMode_rlc_um_bidirectional; // enum /* OPTIONAL */ /* ULConfiguration */ if (0) { - drbs_toBeSetupMod_item.uLConfiguration = (F1AP_ULConfiguration_t *)calloc(1, sizeof(F1AP_ULConfiguration_t)); + drbs_toBeSetupMod_item->uLConfiguration = (F1AP_ULConfiguration_t *)calloc(1, sizeof(F1AP_ULConfiguration_t)); } - - /* ADD */ - drbs_toBeSetupMod_item_ies->value.choice.DRBs_ToBeSetupMod_Item = drbs_toBeSetupMod_item; - ASN_SEQUENCE_ADD(&ie->value.choice.DRBs_ToBeSetupMod_List.list, - drbs_toBeSetupMod_item_ies); - } - ASN_SEQUENCE_ADD(&out->protocolIEs.list, ie); /* mandatory */ /* c13. DRBs_ToBeModified_List */ - ie = (F1AP_UEContextModificationRequestIEs_t *)calloc(1, sizeof(F1AP_UEContextModificationRequestIEs_t)); - ie->id = F1AP_ProtocolIE_ID_id_DRBs_ToBeModified_List; - ie->criticality = F1AP_Criticality_reject; - ie->value.present = F1AP_UEContextModificationRequestIEs__value_PR_DRBs_ToBeModified_List; - - for (i=0; - i<1; - i++) { + asn1cSequenceAdd(out->protocolIEs.list, F1AP_UEContextModificationRequestIEs_t, ie13); + ie13->id = F1AP_ProtocolIE_ID_id_DRBs_ToBeModified_List; + ie13->criticality = F1AP_Criticality_reject; + ie13->value.present = F1AP_UEContextModificationRequestIEs__value_PR_DRBs_ToBeModified_List; + + for (int i=0; i<1; i++) { // - F1AP_DRBs_ToBeModified_ItemIEs_t *drbs_toBeModified_item_ies; - drbs_toBeModified_item_ies = (F1AP_DRBs_ToBeModified_ItemIEs_t *)calloc(1, sizeof(F1AP_DRBs_ToBeModified_ItemIEs_t)); + asn1cSequenceAdd( ie13->value.choice.DRBs_ToBeModified_List.list, + F1AP_DRBs_ToBeModified_ItemIEs_t, drbs_toBeModified_item_ies); drbs_toBeModified_item_ies->id = F1AP_ProtocolIE_ID_id_DRBs_ToBeModified_Item; drbs_toBeModified_item_ies->criticality = F1AP_Criticality_reject; drbs_toBeModified_item_ies->value.present = F1AP_DRBs_ToBeModified_ItemIEs__value_PR_DRBs_ToBeModified_Item; - /* 13.1 SRBs_ToBeModified_Item */ - F1AP_DRBs_ToBeModified_Item_t drbs_toBeModified_item; - memset((void *)&drbs_toBeModified_item, 0, sizeof(F1AP_DRBs_ToBeModified_Item_t)); - + F1AP_DRBs_ToBeModified_Item_t *drbs_toBeModified_item= + &drbs_toBeModified_item_ies->value.choice.DRBs_ToBeModified_Item; /* dRBID */ - drbs_toBeModified_item.dRBID = 30L; - + drbs_toBeModified_item->dRBID = 30L; /* qoSInformation */ - drbs_toBeModified_item.qoSInformation =calloc(1,sizeof(*drbs_toBeModified_item.qoSInformation)); - drbs_toBeModified_item.qoSInformation->present = F1AP_QoSInformation_PR_eUTRANQoS; - drbs_toBeModified_item.qoSInformation->choice.eUTRANQoS = (F1AP_EUTRANQoS_t *)calloc(1, sizeof(F1AP_EUTRANQoS_t)); - drbs_toBeModified_item.qoSInformation->choice.eUTRANQoS->qCI = 254L; - + asn1cCalloc(drbs_toBeModified_item->qoSInformation, tmp); + tmp->present = F1AP_QoSInformation_PR_eUTRANQoS; + tmp->choice.eUTRANQoS = (F1AP_EUTRANQoS_t *)calloc(1, sizeof(F1AP_EUTRANQoS_t)); + tmp->choice.eUTRANQoS->qCI = 254L; /* ULTunnels_ToBeModified_List */ - int j = 0; int maxnoofULTunnels = 1; // 2; - for (j=0; - j<maxnoofULTunnels; - j++) { - /* ULTunnels_ToBeModified_Item */ - F1AP_ULUPTNLInformation_ToBeSetup_Item_t *uLUPTNLInformation_ToBeSetup_Item; - uLUPTNLInformation_ToBeSetup_Item = (F1AP_ULUPTNLInformation_ToBeSetup_Item_t *)calloc(1, sizeof(F1AP_ULUPTNLInformation_ToBeSetup_Item_t)); - uLUPTNLInformation_ToBeSetup_Item->uLUPTNLInformation.present = F1AP_UPTransportLayerInformation_PR_gTPTunnel; - F1AP_GTPTunnel_t *gTPTunnel = (F1AP_GTPTunnel_t *)calloc(1, sizeof(F1AP_GTPTunnel_t)); - - TRANSPORT_LAYER_ADDRESS_IPv4_TO_BIT_STRING(1234, &gTPTunnel->transportLayerAddress); - OCTET_STRING_fromBuf(&gTPTunnel->gTP_TEID, "1204", - strlen("1204")); - - uLUPTNLInformation_ToBeSetup_Item->uLUPTNLInformation.choice.gTPTunnel = gTPTunnel; - - ASN_SEQUENCE_ADD(&drbs_toBeModified_item.uLUPTNLInformation_ToBeSetup_List.list, uLUPTNLInformation_ToBeSetup_Item); + for (int j=0; j<maxnoofULTunnels; j++) { + /* ULTunnels_ToBeModified_Item */ + asn1cSequenceAdd(drbs_toBeModified_item->uLUPTNLInformation_ToBeSetup_List.list, + F1AP_ULUPTNLInformation_ToBeSetup_Item_t, uLUPTNLInformation_ToBeSetup_Item); + uLUPTNLInformation_ToBeSetup_Item->uLUPTNLInformation.present = F1AP_UPTransportLayerInformation_PR_gTPTunnel; + asn1cCalloc(uLUPTNLInformation_ToBeSetup_Item->uLUPTNLInformation.choice.gTPTunnel, + gTPTunnel); + TRANSPORT_LAYER_ADDRESS_IPv4_TO_BIT_STRING(1234, &gTPTunnel->transportLayerAddress); + OCTET_STRING_fromBuf(&gTPTunnel->gTP_TEID, "1204", + strlen("1204")); } /* OPTIONAL */ /* ULConfiguration */ if (0) { - drbs_toBeModified_item.uLConfiguration = (F1AP_ULConfiguration_t *)calloc(1, sizeof(F1AP_ULConfiguration_t)); + drbs_toBeModified_item->uLConfiguration = (F1AP_ULConfiguration_t *)calloc(1, sizeof(F1AP_ULConfiguration_t)); } - - /* ADD */ - drbs_toBeModified_item_ies->value.choice.DRBs_ToBeModified_Item = drbs_toBeModified_item; - ASN_SEQUENCE_ADD(&ie->value.choice.DRBs_ToBeModified_List.list, - drbs_toBeModified_item_ies); - } - ASN_SEQUENCE_ADD(&out->protocolIEs.list, ie); /* mandatory */ /* c14. SRBs_ToBeReleased_List */ - ie = (F1AP_UEContextModificationRequestIEs_t *)calloc(1, sizeof(F1AP_UEContextModificationRequestIEs_t)); - ie->id = F1AP_ProtocolIE_ID_id_SRBs_ToBeReleased_List; - ie->criticality = F1AP_Criticality_reject; - ie->value.present = F1AP_UEContextModificationRequestIEs__value_PR_SRBs_ToBeReleased_List; - - for (i=0; - i<1; - i++) { + asn1cSequenceAdd(out->protocolIEs.list, F1AP_UEContextModificationRequestIEs_t, ie14); + ie14->id = F1AP_ProtocolIE_ID_id_SRBs_ToBeReleased_List; + ie14->criticality = F1AP_Criticality_reject; + ie14->value.present = F1AP_UEContextModificationRequestIEs__value_PR_SRBs_ToBeReleased_List; + + for (int i=0; i<1; i++) { // - F1AP_SRBs_ToBeReleased_ItemIEs_t *srbs_toBeReleased_item_ies; - srbs_toBeReleased_item_ies = (F1AP_SRBs_ToBeReleased_ItemIEs_t *)calloc(1, sizeof(F1AP_SRBs_ToBeReleased_ItemIEs_t)); - //memset((void *)&srbs_toBeReleased_item_ies, 0, sizeof(F1AP_SRBs_ToBeReleased_ItemIEs_t)); + asn1cSequenceAdd(ie14->value.choice.SRBs_ToBeReleased_List.list, + F1AP_SRBs_ToBeReleased_ItemIEs_t, srbs_toBeReleased_item_ies); srbs_toBeReleased_item_ies->id = F1AP_ProtocolIE_ID_id_SRBs_ToBeReleased_Item; srbs_toBeReleased_item_ies->criticality = F1AP_Criticality_ignore; srbs_toBeReleased_item_ies->value.present = F1AP_SRBs_ToBeReleased_ItemIEs__value_PR_SRBs_ToBeReleased_Item; - /* 9.1 SRBs_ToBeReleased_Item */ - F1AP_SRBs_ToBeReleased_Item_t srbs_toBeReleased_item; - memset((void *)&srbs_toBeReleased_item, 0, sizeof(F1AP_SRBs_ToBeReleased_Item_t)); - + F1AP_SRBs_ToBeReleased_Item_t *srbs_toBeReleased_item= + &srbs_toBeReleased_item_ies->value.choice.SRBs_ToBeReleased_Item; /* - sRBID */ - srbs_toBeReleased_item.sRBID = 2L; - - /* ADD */ - srbs_toBeReleased_item_ies->value.choice.SRBs_ToBeReleased_Item = srbs_toBeReleased_item; - ASN_SEQUENCE_ADD(&ie->value.choice.SRBs_ToBeReleased_List.list, - srbs_toBeReleased_item_ies); + srbs_toBeReleased_item->sRBID = 2L; } - ASN_SEQUENCE_ADD(&out->protocolIEs.list, ie); /* mandatory */ /* c15. DRBs_ToBeReleased_List */ - ie = (F1AP_UEContextModificationRequestIEs_t *)calloc(1, sizeof(F1AP_UEContextModificationRequestIEs_t)); - ie->id = F1AP_ProtocolIE_ID_id_DRBs_ToBeReleased_List; - ie->criticality = F1AP_Criticality_reject; - ie->value.present = F1AP_UEContextModificationRequestIEs__value_PR_DRBs_ToBeReleased_List; - - for (i=0; - i<1; - i++) { + asn1cSequenceAdd(out->protocolIEs.list, F1AP_UEContextModificationRequestIEs_t, ie15); + ie15->id = F1AP_ProtocolIE_ID_id_DRBs_ToBeReleased_List; + ie15->criticality = F1AP_Criticality_reject; + ie15->value.present = F1AP_UEContextModificationRequestIEs__value_PR_DRBs_ToBeReleased_List; + + for (int i=0; i<1; i++) { // - F1AP_DRBs_ToBeReleased_ItemIEs_t *drbs_toBeReleased_item_ies; - drbs_toBeReleased_item_ies = (F1AP_DRBs_ToBeReleased_ItemIEs_t *)calloc(1, sizeof(F1AP_DRBs_ToBeReleased_ItemIEs_t)); + asn1cSequenceAdd(ie15->value.choice.DRBs_ToBeReleased_List.list, + F1AP_DRBs_ToBeReleased_ItemIEs_t, drbs_toBeReleased_item_ies); drbs_toBeReleased_item_ies->id = F1AP_ProtocolIE_ID_id_DRBs_ToBeReleased_Item; drbs_toBeReleased_item_ies->criticality = F1AP_Criticality_reject; drbs_toBeReleased_item_ies->value.present = F1AP_DRBs_ToBeReleased_ItemIEs__value_PR_DRBs_ToBeReleased_Item; - /* 14.1 SRBs_ToBeReleased_Item */ - F1AP_DRBs_ToBeReleased_Item_t drbs_toBeReleased_item; - memset((void *)&drbs_toBeReleased_item, 0, sizeof(F1AP_DRBs_ToBeReleased_Item_t)); - + F1AP_DRBs_ToBeReleased_Item_t *drbs_toBeReleased_item= + &drbs_toBeReleased_item_ies->value.choice.DRBs_ToBeReleased_Item; /* dRBID */ - drbs_toBeReleased_item.dRBID = 30L; - - /* ADD */ - drbs_toBeReleased_item_ies->value.choice.DRBs_ToBeReleased_Item = drbs_toBeReleased_item; - ASN_SEQUENCE_ADD(&ie->value.choice.DRBs_ToBeReleased_List.list, - drbs_toBeReleased_item_ies); - + drbs_toBeReleased_item->dRBID = 30L; } - ASN_SEQUENCE_ADD(&out->protocolIEs.list, ie); /* encode */ if (f1ap_encode_pdu(&pdu, &buffer, &len) < 0) { @@ -1569,27 +1351,27 @@ int CU_send_UE_CONTEXT_MODIFICATION_REQUEST(instance_t instance) { } int CU_handle_UE_CONTEXT_MODIFICATION_RESPONSE(instance_t instance, - uint32_t assoc_id, - uint32_t stream, - F1AP_F1AP_PDU_t *pdu) { + uint32_t assoc_id, + uint32_t stream, + F1AP_F1AP_PDU_t *pdu) { AssertFatal(1==0,"Not implemented yet\n"); } int CU_handle_UE_CONTEXT_MODIFICATION_FAILURE(instance_t instance, - uint32_t assoc_id, - uint32_t stream, - F1AP_F1AP_PDU_t *pdu) { + uint32_t assoc_id, + uint32_t stream, + F1AP_F1AP_PDU_t *pdu) { AssertFatal(1==0,"Not implemented yet\n"); } int CU_handle_UE_CONTEXT_MODIFICATION_REQUIRED(instance_t instance, - uint32_t assoc_id, - uint32_t stream, - F1AP_F1AP_PDU_t *pdu) { + uint32_t assoc_id, + uint32_t stream, + F1AP_F1AP_PDU_t *pdu) { AssertFatal(1==0,"Not implemented yet\n"); } int CU_send_UE_CONTEXT_MODIFICATION_CONFIRM(instance_t instance, - F1AP_UEContextModificationConfirm_t UEContextModificationConfirm_t) { + F1AP_UEContextModificationConfirm_t UEContextModificationConfirm_t) { AssertFatal(1==0,"Not implemented yet\n"); } diff --git a/openair2/F1AP/f1ap_cu_ue_context_management.h b/openair2/F1AP/f1ap_cu_ue_context_management.h index cc4ca3e35f08cf768842e14a2410db6f4b828518..09af51ec54c2a9328e840e92151895c009fa9513 100644 --- a/openair2/F1AP/f1ap_cu_ue_context_management.h +++ b/openair2/F1AP/f1ap_cu_ue_context_management.h @@ -37,7 +37,7 @@ * UE Context Setup */ int CU_send_UE_CONTEXT_SETUP_REQUEST(instance_t instance, - f1ap_ue_context_setup_req_t *f1ap_ue_context_setup_req); + f1ap_ue_context_setup_t *f1ap_ue_context_setup_req); int CU_handle_UE_CONTEXT_SETUP_RESPONSE(instance_t instance, uint32_t assoc_id, @@ -54,9 +54,9 @@ int CU_handle_UE_CONTEXT_SETUP_FAILURE(instance_t instance, * UE Context Release Request (gNB-DU initiated) */ int CU_handle_UE_CONTEXT_RELEASE_REQUEST(instance_t instance, - uint32_t assoc_id, - uint32_t stream, - F1AP_F1AP_PDU_t *pdu); + uint32_t assoc_id, + uint32_t stream, + F1AP_F1AP_PDU_t *pdu); /* * UE Context Release (gNB-CU initiated) @@ -65,32 +65,32 @@ int CU_send_UE_CONTEXT_RELEASE_COMMAND(instance_t instance, f1ap_ue_context_release_cmd_t *cmd); int CU_handle_UE_CONTEXT_RELEASE_COMPLETE(instance_t instance, - uint32_t assoc_id, - uint32_t stream, - F1AP_F1AP_PDU_t *pdu); + uint32_t assoc_id, + uint32_t stream, + F1AP_F1AP_PDU_t *pdu); /* * UE Context Modification (gNB-CU initiated) */ int CU_send_UE_CONTEXT_MODIFICATION_REQUEST(instance_t instance); int CU_handle_UE_CONTEXT_MODIFICATION_RESPONSE(instance_t instance, - uint32_t assoc_id, - uint32_t stream, - F1AP_F1AP_PDU_t *pdu); + uint32_t assoc_id, + uint32_t stream, + F1AP_F1AP_PDU_t *pdu); int CU_handle_UE_CONTEXT_MODIFICATION_FAILURE(instance_t instance, - uint32_t assoc_id, - uint32_t stream, - F1AP_F1AP_PDU_t *pdu); + uint32_t assoc_id, + uint32_t stream, + F1AP_F1AP_PDU_t *pdu); /* * UE Context Modification Required (gNB-DU initiated) */ int CU_handle_UE_CONTEXT_MODIFICATION_REQUIRED(instance_t instance, - uint32_t assoc_id, - uint32_t stream, - F1AP_F1AP_PDU_t *pdu); + uint32_t assoc_id, + uint32_t stream, + F1AP_F1AP_PDU_t *pdu); int CU_send_UE_CONTEXT_MODIFICATION_CONFIRM(instance_t instance, - F1AP_UEContextModificationConfirm_t UEContextModificationConfirm_t); + F1AP_UEContextModificationConfirm_t UEContextModificationConfirm_t); /* * UE Inactivity Notification diff --git a/openair2/F1AP/f1ap_decoder.c b/openair2/F1AP/f1ap_decoder.c index ac55db7fda7f9f16603d850d74004098f67b4f3a..6ebf1cc16d483445fe7095cfc633109f1193fc53 100644 --- a/openair2/F1AP/f1ap_decoder.c +++ b/openair2/F1AP/f1ap_decoder.c @@ -35,15 +35,13 @@ int asn1_decoder_xer_print = 0; -static int f1ap_decode_initiating_message(F1AP_F1AP_PDU_t *pdu) -{ +static int f1ap_decode_initiating_message(F1AP_F1AP_PDU_t *pdu) { //MessageDef *message_p; //MessagesIds message_id; //asn_encode_to_new_buffer_result_t res = { NULL, {0, NULL, NULL} }; DevAssert(pdu != NULL); switch(pdu->choice.initiatingMessage->procedureCode) { - case F1AP_ProcedureCode_id_F1Setup: //res = asn_encode_to_new_buffer(NULL, ATS_CANONICAL_XER, &asn_DEF_F1AP_F1AP_PDU, pdu); LOG_I(F1AP, "%s(): F1AP_ProcedureCode_id_F1Setup\n", __func__); @@ -68,15 +66,19 @@ static int f1ap_decode_initiating_message(F1AP_F1AP_PDU_t *pdu) //res = asn_encode_to_new_buffer(NULL, ATS_CANONICAL_XER, &asn_DEF_F1AP_F1AP_PDU, pdu); LOG_I(F1AP, "%s(): F1AP_ProcedureCode_id_ULRRCMessageTransfer\n", __func__); break; + case F1AP_ProcedureCode_id_UEContextRelease: LOG_I(F1AP, "%s(): F1AP_ProcedureCode_id_UEContextRelease\n", __func__); break; + case F1AP_ProcedureCode_id_UEContextReleaseRequest: LOG_I(F1AP, "%s(): F1AP_ProcedureCode_id_UEContextReleaseRequest\n", __func__); break; + case F1AP_ProcedureCode_id_UEContextSetup: LOG_I(F1AP, "%s(): F1AP_ProcedureCode_id_UEContextSetup\n", __func__); break; + // case F1AP_ProcedureCode_id_InitialContextSetup: // res = asn_encode_to_new_buffer(NULL, ATS_CANONICAL_XER, &asn_DEF_F1AP_F1AP_PDU, pdu); // message_id = F1AP_INITIAL_CONTEXT_SETUP_LOG; @@ -92,7 +94,7 @@ static int f1ap_decode_initiating_message(F1AP_F1AP_PDU_t *pdu) // F1AP_ERROR("Unknown procedure ID (%d) for initiating message\n", // (int)pdu->choice.initiatingMessage->procedureCode); LOG_E(F1AP, "Unknown procedure ID (%d) for initiating message\n", - (int)pdu->choice.initiatingMessage->procedureCode); + (int)pdu->choice.initiatingMessage->procedureCode); AssertFatal( 0, "Unknown procedure ID (%d) for initiating message\n", (int)pdu->choice.initiatingMessage->procedureCode); return -1; @@ -101,8 +103,7 @@ static int f1ap_decode_initiating_message(F1AP_F1AP_PDU_t *pdu) return 0; } -static int f1ap_decode_successful_outcome(F1AP_F1AP_PDU_t *pdu) -{ +static int f1ap_decode_successful_outcome(F1AP_F1AP_PDU_t *pdu) { DevAssert(pdu != NULL); switch(pdu->choice.successfulOutcome->procedureCode) { @@ -118,41 +119,41 @@ static int f1ap_decode_successful_outcome(F1AP_F1AP_PDU_t *pdu) LOG_I(F1AP, "%s(): F1AP_ProcedureCode_id_UEContextRelease\n", __func__); break; + case F1AP_ProcedureCode_id_UEContextSetup: + LOG_I(F1AP, "%s(): F1AP_ProcedureCode_id_UEContextSetup\n", __func__); + break; + default: LOG_E(F1AP,"Unknown procedure ID (%d) for successfull outcome message\n", - (int)pdu->choice.successfulOutcome->procedureCode); + (int)pdu->choice.successfulOutcome->procedureCode); return -1; } return 0; } -static int f1ap_decode_unsuccessful_outcome(F1AP_F1AP_PDU_t *pdu) -{ +static int f1ap_decode_unsuccessful_outcome(F1AP_F1AP_PDU_t *pdu) { DevAssert(pdu != NULL); switch(pdu->choice.unsuccessfulOutcome->procedureCode) { case F1AP_ProcedureCode_id_F1Setup: - LOG_I(F1AP, "%s(): F1AP_ProcedureCode_id_F1Setup\n", __func__); - break; + LOG_I(F1AP, "%s(): F1AP_ProcedureCode_id_F1Setup\n", __func__); + break; default: // F1AP_ERROR("Unknown procedure ID (%d) for unsuccessfull outcome message\n", // (int)pdu->choice.unsuccessfulOutcome->procedureCode); LOG_E(F1AP, "Unknown procedure ID (%d) for unsuccessfull outcome message\n", - (int)pdu->choice.unsuccessfulOutcome->procedureCode); + (int)pdu->choice.unsuccessfulOutcome->procedureCode); return -1; } return 0; } -int f1ap_decode_pdu(F1AP_F1AP_PDU_t *pdu, const uint8_t *const buffer, uint32_t length) -{ +int f1ap_decode_pdu(F1AP_F1AP_PDU_t *pdu, const uint8_t *const buffer, uint32_t length) { asn_dec_rval_t dec_ret; - DevAssert(buffer != NULL); - dec_ret = aper_decode(NULL, &asn_DEF_F1AP_F1AP_PDU, (void **)&pdu, @@ -166,6 +167,7 @@ int f1ap_decode_pdu(F1AP_F1AP_PDU_t *pdu, const uint8_t *const buffer, uint32_t xer_fprint(stdout, &asn_DEF_F1AP_F1AP_PDU, pdu); LOG_E(F1AP, "----------------- ASN1 DECODER PRINT END ----------------- \n"); } + //LOG_I(F1AP, "f1ap_decode_pdu.dec_ret.code = %d\n", dec_ret.code); if (dec_ret.code != RC_OK) { @@ -188,6 +190,5 @@ int f1ap_decode_pdu(F1AP_F1AP_PDU_t *pdu, const uint8_t *const buffer, uint32_t break; } - return -1; } diff --git a/openair2/F1AP/f1ap_du_interface_management.c b/openair2/F1AP/f1ap_du_interface_management.c index b6ece9b13ff9c207d7e8ac0e61c464dd839e44e5..ce54e901919ea60b8e56a2016ae3fdff0dfa3c1b 100644 --- a/openair2/F1AP/f1ap_du_interface_management.c +++ b/openair2/F1AP/f1ap_du_interface_management.c @@ -37,24 +37,21 @@ #include "f1ap_du_interface_management.h" #include "assertions.h" -extern f1ap_setup_req_t *f1ap_du_data; -extern RAN_CONTEXT_t RC; +int to_NRNRB(int nrb) { + for (int i=0; i<sizeofArray(nrb_lut); i++) + if (nrb_lut[i] == nrb) + return i; -int nrb_lut[29] = {11, 18, 24, 25, 31, 32, 38, 51, 52, 65, 66, 78, 79, 93, 106, 107, 121, 132, 133, 135, 160, 162, 189, 216, 217, 245, 264, 270, 273}; + if(!RC.nrrrc) + return 0; -int to_NRNRB(int nrb) { - if (RC.nrrrc) { - for (int i=0;i<29;i++) if (nrb_lut[i] == nrb) return i; - AssertFatal(1==0,"nrb %d is not in the list of possible NRNRB\n",nrb); - } else { - return nrb; - } + AssertFatal(1==0,"nrb %d is not in the list of possible NRNRB\n",nrb); } int DU_handle_RESET(instance_t instance, - uint32_t assoc_id, - uint32_t stream, - F1AP_F1AP_PDU_t *pdu) { + uint32_t assoc_id, + uint32_t stream, + F1AP_F1AP_PDU_t *pdu) { AssertFatal(1==0,"Not implemented yet\n"); } @@ -83,9 +80,9 @@ int DU_send_ERROR_INDICATION(instance_t instance, F1AP_F1AP_PDU_t *pdu_p) { } int DU_handle_ERROR_INDICATION(instance_t instance, - uint32_t assoc_id, - uint32_t stream, - F1AP_F1AP_PDU_t *pdu) { + uint32_t assoc_id, + uint32_t stream, + F1AP_F1AP_PDU_t *pdu) { AssertFatal(1==0,"Not implemented yet\n"); } @@ -96,336 +93,221 @@ int DU_handle_ERROR_INDICATION(instance_t instance, // SETUP REQUEST int DU_send_F1_SETUP_REQUEST(instance_t instance) { - module_id_t enb_mod_idP=0; - module_id_t du_mod_idP=0; - - F1AP_F1AP_PDU_t pdu; - F1AP_F1SetupRequest_t *out; - F1AP_F1SetupRequestIEs_t *ie; - + instance_t enb_mod_idP=0; + instance_t du_mod_idP=0; + F1AP_F1AP_PDU_t pdu= {0}; uint8_t *buffer; uint32_t len; - int i = 0; - /* Create */ /* 0. pdu Type */ - memset(&pdu, 0, sizeof(pdu)); pdu.present = F1AP_F1AP_PDU_PR_initiatingMessage; - pdu.choice.initiatingMessage = (F1AP_InitiatingMessage_t *)calloc(1, sizeof(F1AP_InitiatingMessage_t)); - pdu.choice.initiatingMessage->procedureCode = F1AP_ProcedureCode_id_F1Setup; - pdu.choice.initiatingMessage->criticality = F1AP_Criticality_reject; - pdu.choice.initiatingMessage->value.present = F1AP_InitiatingMessage__value_PR_F1SetupRequest; - out = &pdu.choice.initiatingMessage->value.choice.F1SetupRequest; - + asn1cCalloc(pdu.choice.initiatingMessage, initMsg); + initMsg->procedureCode = F1AP_ProcedureCode_id_F1Setup; + initMsg->criticality = F1AP_Criticality_reject; + initMsg->value.present = F1AP_InitiatingMessage__value_PR_F1SetupRequest; + F1AP_F1SetupRequest_t *f1Setup = &initMsg->value.choice.F1SetupRequest; /* mandatory */ /* c1. Transaction ID (integer value) */ - ie = (F1AP_F1SetupRequestIEs_t *)calloc(1, sizeof(F1AP_F1SetupRequestIEs_t)); - ie->id = F1AP_ProtocolIE_ID_id_TransactionID; - ie->criticality = F1AP_Criticality_reject; - ie->value.present = F1AP_F1SetupRequestIEs__value_PR_TransactionID; - ie->value.choice.TransactionID = F1AP_get_next_transaction_identifier(enb_mod_idP, du_mod_idP); - ASN_SEQUENCE_ADD(&out->protocolIEs.list, ie); - + asn1cSequenceAdd(f1Setup->protocolIEs.list, F1AP_F1SetupRequestIEs_t, ieC1); + ieC1->id = F1AP_ProtocolIE_ID_id_TransactionID; + ieC1->criticality = F1AP_Criticality_reject; + ieC1->value.present = F1AP_F1SetupRequestIEs__value_PR_TransactionID; + ieC1->value.choice.TransactionID = F1AP_get_next_transaction_identifier(enb_mod_idP, du_mod_idP); /* mandatory */ /* c2. GNB_DU_ID (integer value) */ - ie = (F1AP_F1SetupRequestIEs_t *)calloc(1, sizeof(F1AP_F1SetupRequestIEs_t)); - ie->id = F1AP_ProtocolIE_ID_id_gNB_DU_ID; - ie->criticality = F1AP_Criticality_reject; - ie->value.present = F1AP_F1SetupRequestIEs__value_PR_GNB_DU_ID; - asn_int642INTEGER(&ie->value.choice.GNB_DU_ID, f1ap_du_data->gNB_DU_id); - ASN_SEQUENCE_ADD(&out->protocolIEs.list, ie); + asn1cSequenceAdd(f1Setup->protocolIEs.list, F1AP_F1SetupRequestIEs_t, ieC2); + ieC2->id = F1AP_ProtocolIE_ID_id_gNB_DU_ID; + ieC2->criticality = F1AP_Criticality_reject; + ieC2->value.present = F1AP_F1SetupRequestIEs__value_PR_GNB_DU_ID; + asn_int642INTEGER(&ieC2->value.choice.GNB_DU_ID, f1ap_req(false, instance)->gNB_DU_id); /* optional */ /* c3. GNB_DU_Name */ - if (f1ap_du_data->gNB_DU_name != NULL) { - ie = (F1AP_F1SetupRequestIEs_t *)calloc(1, sizeof(F1AP_F1SetupRequestIEs_t)); - ie->id = F1AP_ProtocolIE_ID_id_gNB_DU_Name; - ie->criticality = F1AP_Criticality_ignore; - ie->value.present = F1AP_F1SetupRequestIEs__value_PR_GNB_DU_Name; - OCTET_STRING_fromBuf(&ie->value.choice.GNB_DU_Name, f1ap_du_data->gNB_DU_name, - strlen(f1ap_du_data->gNB_DU_name)); - ASN_SEQUENCE_ADD(&out->protocolIEs.list, ie); + if (f1ap_req(false,instance)->gNB_DU_name != NULL) { + asn1cSequenceAdd(f1Setup->protocolIEs.list, F1AP_F1SetupRequestIEs_t, ieC3); + ieC3->id = F1AP_ProtocolIE_ID_id_gNB_DU_Name; + ieC3->criticality = F1AP_Criticality_ignore; + ieC3->value.present = F1AP_F1SetupRequestIEs__value_PR_GNB_DU_Name; + char *gNB_DU_name=f1ap_req(false, instance)->gNB_DU_name; + OCTET_STRING_fromBuf(&ieC3->value.choice.GNB_DU_Name, gNB_DU_name, strlen(gNB_DU_name)); } /* mandatory */ /* c4. served cells list */ - ie = (F1AP_F1SetupRequestIEs_t *)calloc(1, sizeof(F1AP_F1SetupRequestIEs_t)); - ie->id = F1AP_ProtocolIE_ID_id_gNB_DU_Served_Cells_List; - ie->criticality = F1AP_Criticality_reject; - ie->value.present = F1AP_F1SetupRequestIEs__value_PR_GNB_DU_Served_Cells_List; - - int num_cells_available = f1ap_du_data->num_cells_available; + asn1cSequenceAdd(f1Setup->protocolIEs.list, F1AP_F1SetupRequestIEs_t, ieCells); + ieCells->id = F1AP_ProtocolIE_ID_id_gNB_DU_Served_Cells_List; + ieCells->criticality = F1AP_Criticality_reject; + ieCells->value.present = F1AP_F1SetupRequestIEs__value_PR_GNB_DU_Served_Cells_List; + int num_cells_available = f1ap_req(false, instance)->num_cells_available; LOG_D(F1AP, "num_cells_available = %d \n", num_cells_available); - for (i=0; - i<num_cells_available; - i++) { - /* mandatory */ - /* 4.1 served cells item */ - - F1AP_GNB_DU_Served_Cells_ItemIEs_t *gnb_du_served_cell_list_item_ies; - gnb_du_served_cell_list_item_ies = (F1AP_GNB_DU_Served_Cells_ItemIEs_t *)calloc(1, sizeof(F1AP_GNB_DU_Served_Cells_ItemIEs_t)); - gnb_du_served_cell_list_item_ies->id = F1AP_ProtocolIE_ID_id_GNB_DU_Served_Cells_Item; - gnb_du_served_cell_list_item_ies->criticality = F1AP_Criticality_reject; - gnb_du_served_cell_list_item_ies->value.present = F1AP_GNB_DU_Served_Cells_ItemIEs__value_PR_GNB_DU_Served_Cells_Item; - - - F1AP_GNB_DU_Served_Cells_Item_t gnb_du_served_cells_item; - memset((void *)&gnb_du_served_cells_item, 0, sizeof(F1AP_GNB_DU_Served_Cells_Item_t)); - - /* 4.1.1 served cell Information */ - F1AP_Served_Cell_Information_t served_cell_information; - - memset((void *)&served_cell_information, 0, sizeof(F1AP_Served_Cell_Information_t)); - - /* - nRCGI */ - F1AP_NRCGI_t nRCGI; - memset(&nRCGI, 0, sizeof(F1AP_NRCGI_t)); - MCC_MNC_TO_PLMNID(f1ap_du_data->mcc[i], f1ap_du_data->mnc[i], f1ap_du_data->mnc_digit_length[i], &nRCGI.pLMN_Identity); - LOG_D(F1AP, "plmn: (%d,%d)\n",f1ap_du_data->mcc[i],f1ap_du_data->mnc[i]); - //MCC_MNC_TO_PLMNID(208, 95, 2, &nRCGI.pLMN_Identity); - - NR_CELL_ID_TO_BIT_STRING(f1ap_du_data->nr_cellid[i], &nRCGI.nRCellIdentity); - LOG_D(F1AP, "nRCellIdentity (%llx): %x.%x.%x.%x.%x\n", - (long long unsigned int)f1ap_du_data->nr_cellid[i], - nRCGI.nRCellIdentity.buf[0], - nRCGI.nRCellIdentity.buf[1], - nRCGI.nRCellIdentity.buf[2], - nRCGI.nRCellIdentity.buf[3], - nRCGI.nRCellIdentity.buf[4]); - - served_cell_information.nRCGI = nRCGI; - - /* - nRPCI */ - served_cell_information.nRPCI = f1ap_du_data->nr_pci[i]; // int 0..1007 - - /* - fiveGS_TAC */ - if (RC.nrrrc) { - uint8_t fiveGS_TAC[3]; - fiveGS_TAC[0] = ((uint8_t*)&f1ap_du_data->tac[i])[2]; - fiveGS_TAC[1] = ((uint8_t*)&f1ap_du_data->tac[i])[1]; - fiveGS_TAC[2] = ((uint8_t*)&f1ap_du_data->tac[i])[0]; - OCTET_STRING_fromBuf(served_cell_information.fiveGS_TAC, - (const char *)fiveGS_TAC, - 3); - } else { - OCTET_STRING_fromBuf(served_cell_information.fiveGS_TAC, - (const char*)&f1ap_du_data->tac[i], - 3); - } - - /* - Configured_EPS_TAC */ - if(0){ - served_cell_information.configured_EPS_TAC = (F1AP_Configured_EPS_TAC_t *)calloc(1, sizeof(F1AP_Configured_EPS_TAC_t)); - OCTET_STRING_fromBuf(served_cell_information.configured_EPS_TAC, - "2", - 2); - } - - /* servedPLMN information */ - F1AP_ServedPLMNs_Item_t *servedPLMN_item = calloc(1,sizeof(*servedPLMN_item)); - memset(servedPLMN_item,0,sizeof(*servedPLMN_item)); - MCC_MNC_TO_PLMNID(f1ap_du_data->mcc[i], f1ap_du_data->mnc[i], f1ap_du_data->mnc_digit_length[i], &servedPLMN_item->pLMN_Identity); - ASN_SEQUENCE_ADD(&served_cell_information.servedPLMNs.list, servedPLMN_item); - - // // /* - CHOICE NR-MODE-Info */ - F1AP_NR_Mode_Info_t nR_Mode_Info; - //f1ap_du_data->fdd_flag = 1; - if (f1ap_du_data->fdd_flag) { // FDD - nR_Mode_Info.present = F1AP_NR_Mode_Info_PR_fDD; - F1AP_FDD_Info_t *fDD_Info = (F1AP_FDD_Info_t *)calloc(1, sizeof(F1AP_FDD_Info_t)); - - /* FDD.1 UL NRFreqInfo */ - /* FDD.1.1 UL NRFreqInfo ARFCN */ - fDD_Info->uL_NRFreqInfo.nRARFCN = f1ap_du_data->nr_mode_info[i].fdd.ul_nr_arfcn; // Integer - - /* FDD.1.2 F1AP_SUL_Information */ - if(0) { // Optional - F1AP_SUL_Information_t *fdd_sul_info = (F1AP_SUL_Information_t *)calloc(1, sizeof(F1AP_SUL_Information_t)); - fdd_sul_info->sUL_NRARFCN = 0; - fdd_sul_info->sUL_transmission_Bandwidth.nRSCS = 0; - fdd_sul_info->sUL_transmission_Bandwidth.nRNRB = 0; - fDD_Info->uL_NRFreqInfo.sul_Information = fdd_sul_info; - } - - /* FDD.1.3 freqBandListNr */ - int fdd_ul_num_available_freq_Bands = f1ap_du_data->nr_mode_info[i].fdd.ul_num_frequency_bands; - LOG_I(F1AP, "fdd_ul_num_available_freq_Bands = %d \n", fdd_ul_num_available_freq_Bands); - int fdd_ul_j; - for (fdd_ul_j=0; - fdd_ul_j<fdd_ul_num_available_freq_Bands; - fdd_ul_j++) { - - F1AP_FreqBandNrItem_t nr_freqBandNrItem; - memset((void *)&nr_freqBandNrItem, 0, sizeof(F1AP_FreqBandNrItem_t)); - /* FDD.1.3.1 freqBandIndicatorNr*/ - nr_freqBandNrItem.freqBandIndicatorNr = f1ap_du_data->nr_mode_info[i].fdd.ul_nr_band[fdd_ul_j]; // - - /* FDD.1.3.2 supportedSULBandList*/ - int num_available_supported_SULBands = f1ap_du_data->nr_mode_info[i].fdd.ul_num_sul_frequency_bands; - LOG_D(F1AP, "num_available_supported_SULBands = %d \n", num_available_supported_SULBands); - int fdd_ul_k; - for (fdd_ul_k=0; - fdd_ul_k<num_available_supported_SULBands; - fdd_ul_k++) { - F1AP_SupportedSULFreqBandItem_t nr_supportedSULFreqBandItem; - memset((void *)&nr_supportedSULFreqBandItem, 0, sizeof(F1AP_SupportedSULFreqBandItem_t)); - /* FDD.1.3.2.1 freqBandIndicatorNr */ - nr_supportedSULFreqBandItem.freqBandIndicatorNr = f1ap_du_data->nr_mode_info[i].fdd.ul_nr_sul_band[fdd_ul_k]; // - ASN_SEQUENCE_ADD(&nr_freqBandNrItem.supportedSULBandList.list, &nr_supportedSULFreqBandItem); - } // for FDD : UL supported_SULBands - ASN_SEQUENCE_ADD(&fDD_Info->uL_NRFreqInfo.freqBandListNr.list, &nr_freqBandNrItem); - } // for FDD : UL freq_Bands - - /* FDD.2 DL NRFreqInfo */ - /* FDD.2.1 DL NRFreqInfo ARFCN */ - fDD_Info->dL_NRFreqInfo.nRARFCN = f1ap_du_data->nr_mode_info[i].fdd.dl_nr_arfcn; // Integer - - /* FDD.2.2 F1AP_SUL_Information */ - if(0) { // Optional - F1AP_SUL_Information_t *fdd_sul_info = (F1AP_SUL_Information_t *)calloc(1, sizeof(F1AP_SUL_Information_t)); - fdd_sul_info->sUL_NRARFCN = 0; - fdd_sul_info->sUL_transmission_Bandwidth.nRSCS = 0; - fdd_sul_info->sUL_transmission_Bandwidth.nRNRB = 0; - fDD_Info->dL_NRFreqInfo.sul_Information = fdd_sul_info; - } - - /* FDD.2.3 freqBandListNr */ - int fdd_dl_num_available_freq_Bands = f1ap_du_data->nr_mode_info[i].fdd.dl_num_frequency_bands; - LOG_I(F1AP, "fdd_dl_num_available_freq_Bands = %d \n", fdd_dl_num_available_freq_Bands); - int fdd_dl_j; - for (fdd_dl_j=0; - fdd_dl_j<fdd_dl_num_available_freq_Bands; - fdd_dl_j++) { - - F1AP_FreqBandNrItem_t nr_freqBandNrItem; - memset((void *)&nr_freqBandNrItem, 0, sizeof(F1AP_FreqBandNrItem_t)); - /* FDD.2.3.1 freqBandIndicatorNr*/ - nr_freqBandNrItem.freqBandIndicatorNr = f1ap_du_data->nr_mode_info[i].fdd.dl_nr_band[fdd_dl_j]; // - - /* FDD.2.3.2 supportedSULBandList*/ - int num_available_supported_SULBands = f1ap_du_data->nr_mode_info[i].fdd.dl_num_sul_frequency_bands; - LOG_D(F1AP, "num_available_supported_SULBands = %d \n", num_available_supported_SULBands); - int fdd_dl_k; - for (fdd_dl_k=0; - fdd_dl_k<num_available_supported_SULBands; - fdd_dl_k++) { - F1AP_SupportedSULFreqBandItem_t nr_supportedSULFreqBandItem; - memset((void *)&nr_supportedSULFreqBandItem, 0, sizeof(F1AP_SupportedSULFreqBandItem_t)); - /* FDD.2.3.2.1 freqBandIndicatorNr */ - nr_supportedSULFreqBandItem.freqBandIndicatorNr = f1ap_du_data->nr_mode_info[i].fdd.dl_nr_sul_band[fdd_dl_k]; // - ASN_SEQUENCE_ADD(&nr_freqBandNrItem.supportedSULBandList.list, &nr_supportedSULFreqBandItem); - } // for FDD : DL supported_SULBands - ASN_SEQUENCE_ADD(&fDD_Info->dL_NRFreqInfo.freqBandListNr.list, &nr_freqBandNrItem); - } // for FDD : DL freq_Bands - - /* FDD.3 UL Transmission Bandwidth */ - fDD_Info->uL_Transmission_Bandwidth.nRSCS = f1ap_du_data->nr_mode_info[i].fdd.ul_scs; - fDD_Info->uL_Transmission_Bandwidth.nRNRB = to_NRNRB(f1ap_du_data->nr_mode_info[i].fdd.ul_nrb); - /* FDD.4 DL Transmission Bandwidth */ - fDD_Info->dL_Transmission_Bandwidth.nRSCS = f1ap_du_data->nr_mode_info[i].fdd.dl_scs; - fDD_Info->dL_Transmission_Bandwidth.nRNRB = to_NRNRB(f1ap_du_data->nr_mode_info[i].fdd.dl_nrb); - - nR_Mode_Info.choice.fDD = fDD_Info; - } else { // TDD - nR_Mode_Info.present = F1AP_NR_Mode_Info_PR_tDD; - F1AP_TDD_Info_t *tDD_Info = (F1AP_TDD_Info_t *)calloc(1, sizeof(F1AP_TDD_Info_t)); - - /* TDD.1 nRFreqInfo */ - /* TDD.1.1 nRFreqInfo ARFCN */ - tDD_Info->nRFreqInfo.nRARFCN = f1ap_du_data->nr_mode_info[i].tdd.nr_arfcn; // Integer - - /* TDD.1.2 F1AP_SUL_Information */ - if(0) { // Optional - F1AP_SUL_Information_t *tdd_sul_info = (F1AP_SUL_Information_t *)calloc(1, sizeof(F1AP_SUL_Information_t)); - tdd_sul_info->sUL_NRARFCN = 0; - tdd_sul_info->sUL_transmission_Bandwidth.nRSCS = 0; - tdd_sul_info->sUL_transmission_Bandwidth.nRNRB = 0; - tDD_Info->nRFreqInfo.sul_Information = tdd_sul_info; - } - - /* TDD.1.3 freqBandListNr */ - int tdd_num_available_freq_Bands = f1ap_du_data->nr_mode_info[i].tdd.num_frequency_bands; - LOG_I(F1AP, "tdd_num_available_freq_Bands = %d \n", tdd_num_available_freq_Bands); - AssertFatal(tdd_num_available_freq_Bands > 0, "should have at least one TDD band available\n"); - int j; - for (j=0; - j<tdd_num_available_freq_Bands; - j++) { - - F1AP_FreqBandNrItem_t nr_freqBandNrItem; - memset((void *)&nr_freqBandNrItem, 0, sizeof(F1AP_FreqBandNrItem_t)); - /* TDD.1.3.1 freqBandIndicatorNr*/ - nr_freqBandNrItem.freqBandIndicatorNr = *f1ap_du_data->nr_mode_info[i].tdd.nr_band; // - - /* TDD.1.3.2 supportedSULBandList*/ - int num_available_supported_SULBands = f1ap_du_data->nr_mode_info[i].tdd.num_sul_frequency_bands; - LOG_D(F1AP, "num_available_supported_SULBands = %d \n", num_available_supported_SULBands); - int k; - for (k=0; - k<num_available_supported_SULBands; - k++) { - F1AP_SupportedSULFreqBandItem_t nr_supportedSULFreqBandItem; - memset((void *)&nr_supportedSULFreqBandItem, 0, sizeof(F1AP_SupportedSULFreqBandItem_t)); - /* TDD.1.3.2.1 freqBandIndicatorNr */ - nr_supportedSULFreqBandItem.freqBandIndicatorNr = *f1ap_du_data->nr_mode_info[i].tdd.nr_sul_band; // - ASN_SEQUENCE_ADD(&nr_freqBandNrItem.supportedSULBandList.list, &nr_supportedSULFreqBandItem); - } // for TDD : supported_SULBands - ASN_SEQUENCE_ADD(&tDD_Info->nRFreqInfo.freqBandListNr.list, &nr_freqBandNrItem); - } // for TDD : freq_Bands - - /* TDD.2 transmission_Bandwidth */ - tDD_Info->transmission_Bandwidth.nRSCS = f1ap_du_data->nr_mode_info[i].tdd.scs; - tDD_Info->transmission_Bandwidth.nRNRB = to_NRNRB(f1ap_du_data->nr_mode_info[i].tdd.nrb); - - nR_Mode_Info.choice.tDD = tDD_Info; - } // if nR_Mode_Info - - served_cell_information.nR_Mode_Info = nR_Mode_Info; - - /* - measurementTimingConfiguration */ - char *measurementTimingConfiguration = f1ap_du_data->measurement_timing_information[i]; // sept. 2018 - - OCTET_STRING_fromBuf(&served_cell_information.measurementTimingConfiguration, - measurementTimingConfiguration, - strlen(measurementTimingConfiguration)); - gnb_du_served_cells_item.served_Cell_Information = served_cell_information; // - - /* 4.1.2 gNB-DU System Information */ - F1AP_GNB_DU_System_Information_t *gNB_DU_System_Information = (F1AP_GNB_DU_System_Information_t *)calloc(1, sizeof(F1AP_GNB_DU_System_Information_t)); - - OCTET_STRING_fromBuf(&gNB_DU_System_Information->mIB_message, // sept. 2018 - (const char*)f1ap_du_data->mib[i],//f1ap_du_data->mib, - f1ap_du_data->mib_length[i]); - - LOG_D(F1AP,"Filling SIB1_message for cell %d, length %d\n",i,f1ap_du_data->sib1_length[i]); - OCTET_STRING_fromBuf(&gNB_DU_System_Information->sIB1_message, // sept. 2018 - (const char*)f1ap_du_data->sib1[i], - f1ap_du_data->sib1_length[i]); - - gnb_du_served_cells_item.gNB_DU_System_Information = gNB_DU_System_Information; // - - /* ADD */ - gnb_du_served_cell_list_item_ies->value.choice.GNB_DU_Served_Cells_Item = gnb_du_served_cells_item; - - ASN_SEQUENCE_ADD(&ie->value.choice.GNB_DU_Served_Cells_List.list, - gnb_du_served_cell_list_item_ies); + for (int i=0; i<num_cells_available; i++) { + /* mandatory */ + /* 4.1 served cells item */ + cellIDs_t *cell=&f1ap_req(false, instance)->cell[i]; + asn1cSequenceAdd(ieCells->value.choice.GNB_DU_Served_Cells_List.list, + F1AP_GNB_DU_Served_Cells_ItemIEs_t, duServedCell); + duServedCell->id = F1AP_ProtocolIE_ID_id_GNB_DU_Served_Cells_Item; + duServedCell->criticality = F1AP_Criticality_reject; + duServedCell->value.present = F1AP_GNB_DU_Served_Cells_ItemIEs__value_PR_GNB_DU_Served_Cells_Item; + F1AP_GNB_DU_Served_Cells_Item_t *gnb_du_served_cells_item=&duServedCell->value.choice.GNB_DU_Served_Cells_Item; + /* 4.1.1 served cell Information */ + F1AP_Served_Cell_Information_t *served_cell_information= &gnb_du_served_cells_item->served_Cell_Information; + addnRCGI(served_cell_information->nRCGI,cell); + /* - nRPCI */ + served_cell_information->nRPCI = cell->nr_pci; // int 0..1007 + /* - fiveGS_TAC */ + uint32_t tac=htonl(cell->tac); + asn1cCalloc(served_cell_information->fiveGS_TAC, netOrder); + OCTET_STRING_fromBuf(netOrder, ((char *)&tac)+1, 3); + + /* - Configured_EPS_TAC */ + if(0) { + served_cell_information->configured_EPS_TAC = (F1AP_Configured_EPS_TAC_t *)calloc(1, sizeof(F1AP_Configured_EPS_TAC_t)); + OCTET_STRING_fromBuf(served_cell_information->configured_EPS_TAC, "2", 2); + } + + /* servedPLMN information */ + asn1cSequenceAdd(served_cell_information->servedPLMNs.list, F1AP_ServedPLMNs_Item_t,servedPLMN_item); + MCC_MNC_TO_PLMNID(cell->mcc, cell->mnc, cell->mnc_digit_length, &servedPLMN_item->pLMN_Identity); + // // /* - CHOICE NR-MODE-Info */ + F1AP_NR_Mode_Info_t *nR_Mode_Info= &served_cell_information->nR_Mode_Info; + + if (f1ap_req(false, instance)->fdd_flag) { // FDD + nR_Mode_Info->present = F1AP_NR_Mode_Info_PR_fDD; + asn1cCalloc(nR_Mode_Info->choice.fDD, fDD_Info); + /* FDD.1 UL NRFreqInfo */ + /* FDD.1.1 UL NRFreqInfo ARFCN */ + fDD_Info->uL_NRFreqInfo.nRARFCN = f1ap_req(false,instance)->nr_mode_info[i].fdd.ul_nr_arfcn; // Integer + + /* FDD.1.2 F1AP_SUL_Information */ + if(0) { // Optional + asn1cCalloc(fDD_Info->uL_NRFreqInfo.sul_Information, fdd_sul_info); + fdd_sul_info->sUL_NRARFCN = 0; + fdd_sul_info->sUL_transmission_Bandwidth.nRSCS = 0; + fdd_sul_info->sUL_transmission_Bandwidth.nRNRB = 0; + } + + /* FDD.1.3 freqBandListNr */ + int fdd_ul_num_available_freq_Bands = f1ap_req(false,instance)->nr_mode_info[i].fdd.ul_num_frequency_bands; + LOG_D(F1AP, "fdd_ul_num_available_freq_Bands = %d \n", fdd_ul_num_available_freq_Bands); + + for (int fdd_ul_j=0; fdd_ul_j<fdd_ul_num_available_freq_Bands; fdd_ul_j++) { + asn1cSequenceAdd(fDD_Info->uL_NRFreqInfo.freqBandListNr.list, F1AP_FreqBandNrItem_t, nr_freqBandNrItem); + /* FDD.1.3.1 freqBandIndicatorNr*/ + nr_freqBandNrItem->freqBandIndicatorNr = f1ap_req(false,instance)->nr_mode_info[i].fdd.ul_nr_band[fdd_ul_j]; // + /* FDD.1.3.2 supportedSULBandList*/ + int num_available_supported_SULBands = f1ap_req(false,instance)->nr_mode_info[i].fdd.ul_num_sul_frequency_bands; + LOG_D(F1AP, "num_available_supported_SULBands = %d \n", num_available_supported_SULBands); + + for (int fdd_ul_k=0; fdd_ul_k<num_available_supported_SULBands; fdd_ul_k++) { + asn1cSequenceAdd(nr_freqBandNrItem->supportedSULBandList.list, F1AP_SupportedSULFreqBandItem_t, nr_supportedSULFreqBandItem); + /* FDD.1.3.2.1 freqBandIndicatorNr */ + nr_supportedSULFreqBandItem->freqBandIndicatorNr = f1ap_req(false,instance)->nr_mode_info[i].fdd.ul_nr_sul_band[fdd_ul_k]; // + } // for FDD : UL supported_SULBands + } // for FDD : UL freq_Bands + + /* FDD.2 DL NRFreqInfo */ + /* FDD.2.1 DL NRFreqInfo ARFCN */ + fDD_Info->dL_NRFreqInfo.nRARFCN = f1ap_req(false,instance)->nr_mode_info[i].fdd.dl_nr_arfcn; // Integer + + /* FDD.2.2 F1AP_SUL_Information */ + if(0) { // Optional + F1AP_SUL_Information_t *fdd_sul_info=fDD_Info->dL_NRFreqInfo.sul_Information; + fdd_sul_info->sUL_NRARFCN = 0; + fdd_sul_info->sUL_transmission_Bandwidth.nRSCS = 0; + fdd_sul_info->sUL_transmission_Bandwidth.nRNRB = 0; + } + + /* FDD.2.3 freqBandListNr */ + int fdd_dl_num_available_freq_Bands = f1ap_req(false,instance)->nr_mode_info[i].fdd.dl_num_frequency_bands; + LOG_D(F1AP, "fdd_dl_num_available_freq_Bands = %d \n", fdd_dl_num_available_freq_Bands); + + for (int fdd_dl_j=0; fdd_dl_j<fdd_dl_num_available_freq_Bands; fdd_dl_j++) { + asn1cSequenceAdd(fDD_Info->dL_NRFreqInfo.freqBandListNr.list, F1AP_FreqBandNrItem_t, nr_freqBandNrItem); + /* FDD.2.3.1 freqBandIndicatorNr*/ + nr_freqBandNrItem->freqBandIndicatorNr = f1ap_req(false,instance)->nr_mode_info[i].fdd.dl_nr_band[fdd_dl_j]; // + /* FDD.2.3.2 supportedSULBandList*/ + int num_available_supported_SULBands = f1ap_req(false,instance)->nr_mode_info[i].fdd.dl_num_sul_frequency_bands; + LOG_D(F1AP, "num_available_supported_SULBands = %d \n", num_available_supported_SULBands); + + for (int fdd_dl_k=0; fdd_dl_k<num_available_supported_SULBands; fdd_dl_k++) { + asn1cSequenceAdd(nr_freqBandNrItem->supportedSULBandList.list, F1AP_SupportedSULFreqBandItem_t, nr_supportedSULFreqBandItem); + /* FDD.2.3.2.1 freqBandIndicatorNr */ + nr_supportedSULFreqBandItem->freqBandIndicatorNr = f1ap_req(false,instance)->nr_mode_info[i].fdd.dl_nr_sul_band[fdd_dl_k]; // + } // for FDD : DL supported_SULBands + } // for FDD : DL freq_Bands + + /* FDD.3 UL Transmission Bandwidth */ + fDD_Info->uL_Transmission_Bandwidth.nRSCS = f1ap_req(false,instance)->nr_mode_info[i].fdd.ul_scs; + fDD_Info->uL_Transmission_Bandwidth.nRNRB = to_NRNRB(f1ap_req(false,instance)->nr_mode_info[i].fdd.ul_nrb); + /* FDD.4 DL Transmission Bandwidth */ + fDD_Info->dL_Transmission_Bandwidth.nRSCS = f1ap_req(false,instance)->nr_mode_info[i].fdd.dl_scs; + fDD_Info->dL_Transmission_Bandwidth.nRNRB = to_NRNRB(f1ap_req(false,instance)->nr_mode_info[i].fdd.dl_nrb); + } else { // TDD + nR_Mode_Info->present = F1AP_NR_Mode_Info_PR_tDD; + asn1cCalloc(nR_Mode_Info->choice.tDD, tDD_Info); + /* TDD.1 nRFreqInfo */ + /* TDD.1.1 nRFreqInfo ARFCN */ + tDD_Info->nRFreqInfo.nRARFCN = f1ap_req(false,instance)->nr_mode_info[i].tdd.nr_arfcn; // Integer + + /* TDD.1.2 F1AP_SUL_Information */ + if(0) { // Optional + F1AP_SUL_Information_t *tdd_sul_info= tDD_Info->nRFreqInfo.sul_Information; + tdd_sul_info->sUL_NRARFCN = 0; + tdd_sul_info->sUL_transmission_Bandwidth.nRSCS = 0; + tdd_sul_info->sUL_transmission_Bandwidth.nRNRB = 0; + } + + /* TDD.1.3 freqBandListNr */ + int tdd_num_available_freq_Bands = f1ap_req(false,instance)->nr_mode_info[i].tdd.num_frequency_bands; + LOG_D(F1AP, "tdd_num_available_freq_Bands = %d \n", tdd_num_available_freq_Bands); + + for (int j=0; j<tdd_num_available_freq_Bands; j++) { + asn1cSequenceAdd(tDD_Info->nRFreqInfo.freqBandListNr.list, F1AP_FreqBandNrItem_t, nr_freqBandNrItem); + /* TDD.1.3.1 freqBandIndicatorNr*/ + nr_freqBandNrItem->freqBandIndicatorNr = *f1ap_req(false,instance)->nr_mode_info[i].tdd.nr_band; // + /* TDD.1.3.2 supportedSULBandList*/ + int num_available_supported_SULBands = f1ap_req(false,instance)->nr_mode_info[i].tdd.num_sul_frequency_bands; + LOG_D(F1AP, "num_available_supported_SULBands = %d \n", num_available_supported_SULBands); + + for (int k=0; k<num_available_supported_SULBands; k++) { + asn1cSequenceAdd(nr_freqBandNrItem->supportedSULBandList.list,F1AP_SupportedSULFreqBandItem_t, nr_supportedSULFreqBandItem); + /* TDD.1.3.2.1 freqBandIndicatorNr */ + nr_supportedSULFreqBandItem->freqBandIndicatorNr = *f1ap_req(false,instance)->nr_mode_info[i].tdd.nr_sul_band; // + } // for TDD : supported_SULBands + } // for TDD : freq_Bands + + /* TDD.2 transmission_Bandwidth */ + tDD_Info->transmission_Bandwidth.nRSCS = f1ap_req(false,instance)->nr_mode_info[i].tdd.scs; + tDD_Info->transmission_Bandwidth.nRNRB = to_NRNRB(f1ap_req(false,instance)->nr_mode_info[i].tdd.nrb); + } // if nR_Mode_Info + + /* - measurementTimingConfiguration */ + char *measurementTimingConfiguration = f1ap_req(false,instance)->measurement_timing_information[i]; // sept. 2018 + OCTET_STRING_fromBuf(&served_cell_information->measurementTimingConfiguration, + measurementTimingConfiguration, + strlen(measurementTimingConfiguration)); + asn1cCalloc(gnb_du_served_cells_item->gNB_DU_System_Information, gNB_DU_System_Information); + /* 4.1.2 gNB-DU System Information */ + OCTET_STRING_fromBuf(&gNB_DU_System_Information->mIB_message, // sept. 2018 + (const char *)f1ap_req(false,instance)->mib[i], //f1ap_du_data->mib, + f1ap_req(false,instance)->mib_length[i]); + OCTET_STRING_fromBuf(&gNB_DU_System_Information->sIB1_message, // sept. 2018 + (const char *)f1ap_req(false,instance)->sib1[i], + f1ap_req(false,instance)->sib1_length[i]); } - ASN_SEQUENCE_ADD(&out->protocolIEs.list, ie); /* mandatory */ /* c5. RRC VERSION */ - if(RC.nrrrc) { - ie = (F1AP_F1SetupRequestIEs_t *) calloc(1, sizeof(F1AP_F1SetupRequestIEs_t)); - ie->id = F1AP_ProtocolIE_ID_id_GNB_DU_RRC_Version; - ie->criticality = F1AP_Criticality_reject; - ie->value.present = F1AP_F1SetupRequestIEs__value_PR_RRC_Version; - ie->value.choice.RRC_Version.latest_RRC_Version.buf = calloc(1, sizeof(char)); - ie->value.choice.RRC_Version.latest_RRC_Version.buf[0] = 0xe0; - ie->value.choice.RRC_Version.latest_RRC_Version.size = 1; - ie->value.choice.RRC_Version.latest_RRC_Version.bits_unused = 5; - ASN_SEQUENCE_ADD(&out->protocolIEs.list, ie); - } + asn1cSequenceAdd(f1Setup->protocolIEs.list, F1AP_F1SetupRequestIEs_t, ie2); + ie2->id = F1AP_ProtocolIE_ID_id_GNB_DU_RRC_Version; + ie2->criticality = F1AP_Criticality_reject; + ie2->value.present = F1AP_F1SetupRequestIEs__value_PR_RRC_Version; + ie2->value.choice.RRC_Version.latest_RRC_Version.buf=calloc(1,sizeof(char)); + ie2->value.choice.RRC_Version.latest_RRC_Version.buf[0] = 0xe0; + ie2->value.choice.RRC_Version.latest_RRC_Version.size = 1; + ie2->value.choice.RRC_Version.latest_RRC_Version.bits_unused = 5; /* encode */ if (f1ap_encode_pdu(&pdu, &buffer, &len) < 0) { @@ -433,161 +315,154 @@ int DU_send_F1_SETUP_REQUEST(instance_t instance) { return -1; } - MSC_LOG_TX_MESSAGE( - MSC_F1AP_DU, - MSC_F1AP_CU, - (const char *)buffer, - len, - MSC_AS_TIME_FMT" F1_SETUP_REQUEST initiatingMessage gNB_DU_name %s", - 0,0,//MSC_AS_TIME_ARGS(ctxt_pP), - f1ap_du_data->gNB_DU_name); - - du_f1ap_itti_send_sctp_data_req(instance, f1ap_du_data->assoc_id, buffer, len, 0); - + ASN_STRUCT_RESET(asn_DEF_F1AP_F1AP_PDU, &pdu); + f1ap_itti_send_sctp_data_req(false, instance, buffer, len, 0); return 0; } int DU_handle_F1_SETUP_RESPONSE(instance_t instance, - uint32_t assoc_id, - uint32_t stream, - F1AP_F1AP_PDU_t *pdu) -{ - + uint32_t assoc_id, + uint32_t stream, + F1AP_F1AP_PDU_t *pdu) { LOG_D(F1AP, "DU_handle_F1_SETUP_RESPONSE\n"); - AssertFatal(pdu->present == F1AP_F1AP_PDU_PR_successfulOutcome, - "pdu->present != F1AP_F1AP_PDU_PR_successfulOutcome\n"); + "pdu->present != F1AP_F1AP_PDU_PR_successfulOutcome\n"); AssertFatal(pdu->choice.successfulOutcome->procedureCode == F1AP_ProcedureCode_id_F1Setup, - "pdu->choice.successfulOutcome->procedureCode != F1AP_ProcedureCode_id_F1Setup\n"); + "pdu->choice.successfulOutcome->procedureCode != F1AP_ProcedureCode_id_F1Setup\n"); AssertFatal(pdu->choice.successfulOutcome->criticality == F1AP_Criticality_reject, - "pdu->choice.successfulOutcome->criticality != F1AP_Criticality_reject\n"); + "pdu->choice.successfulOutcome->criticality != F1AP_Criticality_reject\n"); AssertFatal(pdu->choice.successfulOutcome->value.present == F1AP_SuccessfulOutcome__value_PR_F1SetupResponse, - "pdu->choice.successfulOutcome->value.present != F1AP_SuccessfulOutcome__value_PR_F1SetupResponse\n"); - + "pdu->choice.successfulOutcome->value.present != F1AP_SuccessfulOutcome__value_PR_F1SetupResponse\n"); F1AP_F1SetupResponse_t *in = &pdu->choice.successfulOutcome->value.choice.F1SetupResponse; - - F1AP_F1SetupResponseIEs_t *ie; int TransactionId = -1; int num_cells_to_activate = 0; F1AP_Cells_to_be_Activated_List_Item_t *cell; - MessageDef *msg_p = itti_alloc_new_message (TASK_DU_F1, 0, F1AP_SETUP_RESP); - LOG_D(F1AP, "F1AP: F1Setup-Resp: protocolIEs.list.count %d\n", in->protocolIEs.list.count); - for (int i=0;i < in->protocolIEs.list.count; i++) { + + for (int i=0; i < in->protocolIEs.list.count; i++) { ie = in->protocolIEs.list.array[i]; + switch (ie->id) { case F1AP_ProtocolIE_ID_id_TransactionID: AssertFatal(ie->criticality == F1AP_Criticality_reject, - "ie->criticality != F1AP_Criticality_reject\n"); + "ie->criticality != F1AP_Criticality_reject\n"); AssertFatal(ie->value.present == F1AP_F1SetupResponseIEs__value_PR_TransactionID, - "ie->value.present != F1AP_F1SetupResponseIEs__value_PR_TransactionID\n"); + "ie->value.present != F1AP_F1SetupResponseIEs__value_PR_TransactionID\n"); TransactionId=ie->value.choice.TransactionID; LOG_D(F1AP, "F1AP: F1Setup-Resp: TransactionId %d\n", TransactionId); break; + case F1AP_ProtocolIE_ID_id_gNB_CU_Name: AssertFatal(ie->criticality == F1AP_Criticality_ignore, - "ie->criticality != F1AP_Criticality_ignore\n"); + "ie->criticality != F1AP_Criticality_ignore\n"); AssertFatal(ie->value.present == F1AP_F1SetupResponseIEs__value_PR_GNB_CU_Name, - "ie->value.present != F1AP_F1SetupResponseIEs__value_PR_TransactionID\n"); + "ie->value.present != F1AP_F1SetupResponseIEs__value_PR_TransactionID\n"); F1AP_SETUP_RESP (msg_p).gNB_CU_name = malloc(ie->value.choice.GNB_CU_Name.size+1); memcpy(F1AP_SETUP_RESP (msg_p).gNB_CU_name,ie->value.choice.GNB_CU_Name.buf,ie->value.choice.GNB_CU_Name.size); F1AP_SETUP_RESP (msg_p).gNB_CU_name[ie->value.choice.GNB_CU_Name.size]='\0'; LOG_D(F1AP, "F1AP: F1Setup-Resp: gNB_CU_name %s\n", F1AP_SETUP_RESP (msg_p).gNB_CU_name); break; + case F1AP_ProtocolIE_ID_id_GNB_CU_RRC_Version: LOG_D(F1AP, "F1AP: Received GNB-CU-RRC-Version, ignoring\n"); break; - case F1AP_ProtocolIE_ID_id_Cells_to_be_Activated_List: - { + + case F1AP_ProtocolIE_ID_id_Cells_to_be_Activated_List: { AssertFatal(ie->criticality == F1AP_Criticality_reject, - "ie->criticality != F1AP_Criticality_reject\n"); + "ie->criticality != F1AP_Criticality_reject\n"); AssertFatal(ie->value.present == F1AP_F1SetupResponseIEs__value_PR_Cells_to_be_Activated_List, - "ie->value.present != F1AP_F1SetupResponseIEs__value_PR_Cells_to_be_Activated_List\n"); + "ie->value.present != F1AP_F1SetupResponseIEs__value_PR_Cells_to_be_Activated_List\n"); num_cells_to_activate = ie->value.choice.Cells_to_be_Activated_List.list.count; LOG_D(F1AP, "F1AP: Activating %d cells\n",num_cells_to_activate); - for (int i=0;i<num_cells_to_activate;i++) { + for (int i=0; i<num_cells_to_activate; i++) { F1AP_Cells_to_be_Activated_List_ItemIEs_t *cells_to_be_activated_list_item_ies = (F1AP_Cells_to_be_Activated_List_ItemIEs_t *) ie->value.choice.Cells_to_be_Activated_List.list.array[i]; - AssertFatal(cells_to_be_activated_list_item_ies->id == F1AP_ProtocolIE_ID_id_Cells_to_be_Activated_List_Item, - "cells_to_be_activated_list_item_ies->id != F1AP_ProtocolIE_ID_id_Cells_to_be_Activated_List_Item"); + "cells_to_be_activated_list_item_ies->id != F1AP_ProtocolIE_ID_id_Cells_to_be_Activated_List_Item"); AssertFatal(cells_to_be_activated_list_item_ies->criticality == F1AP_Criticality_reject, - "cells_to_be_activated_list_item_ies->criticality == F1AP_Criticality_reject"); + "cells_to_be_activated_list_item_ies->criticality == F1AP_Criticality_reject"); AssertFatal(cells_to_be_activated_list_item_ies->value.present == F1AP_Cells_to_be_Activated_List_ItemIEs__value_PR_Cells_to_be_Activated_List_Item, - "cells_to_be_activated_list_item_ies->value.present == F1AP_Cells_to_be_Activated_List_ItemIEs__value_PR_Cells_to_be_Activated_List_Item"); - + "cells_to_be_activated_list_item_ies->value.present == F1AP_Cells_to_be_Activated_List_ItemIEs__value_PR_Cells_to_be_Activated_List_Item"); cell = &cells_to_be_activated_list_item_ies->value.choice.Cells_to_be_Activated_List_Item; - - TBCD_TO_MCC_MNC(&cell->nRCGI.pLMN_Identity, F1AP_SETUP_RESP (msg_p).cells_to_activate[i].mcc, F1AP_SETUP_RESP (msg_p).cells_to_activate[i].mnc, F1AP_SETUP_RESP (msg_p).cells_to_activate[i].mnc_digit_length); - + TBCD_TO_MCC_MNC(&cell->nRCGI.pLMN_Identity, F1AP_SETUP_RESP (msg_p).cells_to_activate[i].mcc, F1AP_SETUP_RESP (msg_p).cells_to_activate[i].mnc, + F1AP_SETUP_RESP (msg_p).cells_to_activate[i].mnc_digit_length); LOG_D(F1AP, "nr_cellId : %x %x %x %x %x\n", cell->nRCGI.nRCellIdentity.buf[0], cell->nRCGI.nRCellIdentity.buf[1], cell->nRCGI.nRCellIdentity.buf[2], cell->nRCGI.nRCellIdentity.buf[3], cell->nRCGI.nRCellIdentity.buf[4]); - BIT_STRING_TO_NR_CELL_IDENTITY(&cell->nRCGI.nRCellIdentity, - F1AP_SETUP_RESP (msg_p).cells_to_activate[i].nr_cellid); + F1AP_SETUP_RESP (msg_p).cells_to_activate[i].nr_cellid); F1AP_ProtocolExtensionContainer_154P112_t *ext = (F1AP_ProtocolExtensionContainer_154P112_t *)cell->iE_Extensions; - if (ext==NULL) continue; + if (ext==NULL) + continue; - for (int cnt=0;cnt<ext->list.count;cnt++) { + for (int cnt=0; cnt<ext->list.count; cnt++) { F1AP_Cells_to_be_Activated_List_ItemExtIEs_t *cells_to_be_activated_list_itemExtIEs=(F1AP_Cells_to_be_Activated_List_ItemExtIEs_t *)ext->list.array[cnt]; + switch (cells_to_be_activated_list_itemExtIEs->id) { - /* - case F1AP_Cells_to_be_Activated_List_ItemExtIEs__extensionValue_PR_NOTHING: - case F1AP_Cells_to_be_Activated_List_ItemExtIEs__extensionValue_PR_GNB_CUSystemInformation, - case F1AP_Cells_to_be_Activated_List_ItemExtIEs__extensionValue_PR_AvailablePLMNList, - case F1AP_Cells_to_be_Activated_List_ItemExtIEs__extensionValue_PR_ExtendedAvailablePLMN_List, - case F1AP_Cells_to_be_Activated_List_ItemExtIEs__extensionValue_PR_IAB_Info_IAB_donor_CU, - case F1AP_Cells_to_be_Activated_List_ItemExtIEs__extensionValue_PR_AvailableSNPN_ID_List - */ - case F1AP_ProtocolIE_ID_id_gNB_CUSystemInformation: - { + /* + case F1AP_Cells_to_be_Activated_List_ItemExtIEs__extensionValue_PR_NOTHING: + case F1AP_Cells_to_be_Activated_List_ItemExtIEs__extensionValue_PR_GNB_CUSystemInformation, + case F1AP_Cells_to_be_Activated_List_ItemExtIEs__extensionValue_PR_AvailablePLMNList, + case F1AP_Cells_to_be_Activated_List_ItemExtIEs__extensionValue_PR_ExtendedAvailablePLMN_List, + case F1AP_Cells_to_be_Activated_List_ItemExtIEs__extensionValue_PR_IAB_Info_IAB_donor_CU, + case F1AP_Cells_to_be_Activated_List_ItemExtIEs__extensionValue_PR_AvailableSNPN_ID_List + */ + case F1AP_ProtocolIE_ID_id_gNB_CUSystemInformation: { F1AP_SETUP_RESP (msg_p).cells_to_activate[i].nrpci = (cell->nRPCI != NULL) ? *cell->nRPCI : 0; - F1AP_GNB_CUSystemInformation_t *gNB_CUSystemInformation = (F1AP_GNB_CUSystemInformation_t*)&cells_to_be_activated_list_itemExtIEs->extensionValue.choice.GNB_CUSystemInformation; + F1AP_GNB_CUSystemInformation_t *gNB_CUSystemInformation = (F1AP_GNB_CUSystemInformation_t *)&cells_to_be_activated_list_itemExtIEs->extensionValue.choice.GNB_CUSystemInformation; F1AP_SETUP_RESP (msg_p).cells_to_activate[i].num_SI = gNB_CUSystemInformation->sibtypetobeupdatedlist.list.count; AssertFatal(ext->list.count==1,"At least one SI message should be there, and only 1 for now!\n"); LOG_D(F1AP, "F1AP: Cell %d MCC %d MNC %d NRCellid %lx num_si %d\n", i, F1AP_SETUP_RESP (msg_p).cells_to_activate[i].mcc, F1AP_SETUP_RESP (msg_p).cells_to_activate[i].mnc, F1AP_SETUP_RESP (msg_p).cells_to_activate[i].nr_cellid, F1AP_SETUP_RESP (msg_p).cells_to_activate[i].num_SI); - for (int si = 0;si < gNB_CUSystemInformation->sibtypetobeupdatedlist.list.count;si++) { + + for (int si = 0; si < gNB_CUSystemInformation->sibtypetobeupdatedlist.list.count; si++) { F1AP_SibtypetobeupdatedListItem_t *sib_item = gNB_CUSystemInformation->sibtypetobeupdatedlist.list.array[si]; size_t size = sib_item->sIBmessage.size; - F1AP_SETUP_RESP (msg_p).cells_to_activate[i].SI_container_length[sib_item->sIBtype] = size; - LOG_I(F1AP, "F1AP: SI_container_length[%d][%d] %ld bytes\n", i, (int)sib_item->sIBtype, size); - F1AP_SETUP_RESP (msg_p).cells_to_activate[i].SI_container[sib_item->sIBtype] = malloc(size); - memcpy((void*)F1AP_SETUP_RESP (msg_p).cells_to_activate[i].SI_container[sib_item->sIBtype], - (void*)sib_item->sIBmessage.buf, - size); + F1AP_SETUP_RESP (msg_p).cells_to_activate[i].SI_container_length[si] = size; + LOG_D(F1AP, "F1AP: SI_container_length[%d][%ld] %ld bytes\n", i, sib_item->sIBtype, size); + F1AP_SETUP_RESP (msg_p).cells_to_activate[i].SI_container[si] = malloc(F1AP_SETUP_RESP (msg_p).cells_to_activate[i].SI_container_length[si]); + memcpy((void *)F1AP_SETUP_RESP (msg_p).cells_to_activate[i].SI_container[si], + (void *)sib_item->sIBmessage.buf, + size); + F1AP_SETUP_RESP (msg_p).cells_to_activate[i].SI_type[si]=sib_item->sIBtype; } + break; } + case F1AP_ProtocolIE_ID_id_AvailablePLMNList: AssertFatal(1==0,"F1AP_ProtocolIE_ID_id_AvailablePLMNList not supported yet\n"); break; + case F1AP_ProtocolIE_ID_id_ExtendedAvailablePLMN_List: AssertFatal(1==0,"F1AP_ProtocolIE_ID_id_AvailablePLMNList not supported yet\n"); break; + case F1AP_ProtocolIE_ID_id_IAB_Info_IAB_donor_CU: AssertFatal(1==0,"F1AP_ProtocolIE_ID_id_AvailablePLMNList not supported yet\n"); break; + case F1AP_ProtocolIE_ID_id_AvailableSNPN_ID_List: AssertFatal(1==0,"F1AP_ProtocolIE_ID_id_AvailablePLMNList not supported yet\n"); break; + default: AssertFatal(1==0,"F1AP_ProtocolIE_ID_id %d unknown\n",(int)cells_to_be_activated_list_itemExtIEs->id); break; } } // for (cnt=... } // for (cells_to_activate... + break; } // case F1AP_ProtocolIE_ID_id_Cells_to_be_Activated_List @@ -596,31 +471,26 @@ int DU_handle_F1_SETUP_RESPONSE(instance_t instance, break; } // switch ie } // for IE + AssertFatal(TransactionId!=-1,"TransactionId was not sent\n"); + LOG_D(F1AP,"F1AP: num_cells_to_activate %d\n",num_cells_to_activate); F1AP_SETUP_RESP (msg_p).num_cells_to_activate = num_cells_to_activate; - for (int i=0;i<num_cells_to_activate;i++) + // tmp + // F1AP_SETUP_RESP (msg_p).num_SI[0] = 1; + for (int i=0; i<num_cells_to_activate; i++) AssertFatal(F1AP_SETUP_RESP (msg_p).cells_to_activate[i].num_SI > 0, "System Information %d is missing",i); MSC_LOG_RX_MESSAGE( - MSC_F1AP_DU, - MSC_F1AP_CU, - 0, - 0, - MSC_AS_TIME_FMT" DU_handle_F1_SETUP_RESPONSE successfulOutcome assoc_id %d", - 0,0,//MSC_AS_TIME_ARGS(ctxt_pP), - assoc_id); - - if (RC.nrrrc && RC.nrrrc[0]->node_type == ngran_gNB_DU) { - LOG_D(F1AP, "Sending F1AP_SETUP_RESP ITTI message to GNB_APP with assoc_id (%d->%d)\n", - assoc_id,ENB_MODULE_ID_TO_INSTANCE(assoc_id)); - itti_send_msg_to_task(TASK_GNB_APP, GNB_MODULE_ID_TO_INSTANCE(assoc_id), msg_p); - } else { - LOG_D(F1AP, "Sending F1AP_SETUP_RESP ITTI message to ENB_APP with assoc_id (%d->%d)\n", - assoc_id,ENB_MODULE_ID_TO_INSTANCE(assoc_id)); - itti_send_msg_to_task(TASK_ENB_APP, instance, msg_p); - } - + MSC_F1AP_DU, + MSC_F1AP_CU, + 0, + 0, + MSC_AS_TIME_FMT" DU_handle_F1_SETUP_RESPONSE successfulOutcome assoc_id %d", + 0,0,//MSC_AS_TIME_ARGS(ctxt_pP), + assoc_id); + LOG_D(F1AP, "Sending F1AP_SETUP_RESP ITTI message\n"); + itti_send_msg_to_task(TASK_F1APP, GNB_MODULE_ID_TO_INSTANCE(assoc_id), msg_p); return 0; } @@ -630,24 +500,20 @@ int DU_handle_F1_SETUP_FAILURE(instance_t instance, uint32_t stream, F1AP_F1AP_PDU_t *pdu) { LOG_E(F1AP, "DU_handle_F1_SETUP_FAILURE\n"); - F1AP_F1SetupFailure_t *out; F1AP_F1SetupFailureIEs_t *ie; - out = &pdu->choice.unsuccessfulOutcome->value.choice.F1SetupFailure; - /* Transaction ID */ F1AP_FIND_PROTOCOLIE_BY_ID(F1AP_F1SetupFailureIEs_t, ie, out, - F1AP_ProtocolIE_ID_id_TransactionID, true); - + F1AP_ProtocolIE_ID_id_TransactionID, true); /* Cause */ F1AP_FIND_PROTOCOLIE_BY_ID(F1AP_F1SetupFailureIEs_t, ie, out, - F1AP_ProtocolIE_ID_id_Cause, true); + F1AP_ProtocolIE_ID_id_Cause, true); if(0) { /* TimeToWait */ F1AP_FIND_PROTOCOLIE_BY_ID(F1AP_F1SetupFailureIEs_t, ie, out, - F1AP_ProtocolIE_ID_id_TimeToWait, true); + F1AP_ProtocolIE_ID_id_TimeToWait, true); } return 0; @@ -660,495 +526,306 @@ int DU_handle_F1_SETUP_FAILURE(instance_t instance, //void DU_send_gNB_DU_CONFIGURATION_UPDATE(F1AP_GNBDUConfigurationUpdate_t *GNBDUConfigurationUpdate) { int DU_send_gNB_DU_CONFIGURATION_UPDATE(instance_t instance, - instance_t du_mod_idP, - f1ap_setup_req_t *f1ap_setup_req) { - F1AP_F1AP_PDU_t pdu; - F1AP_GNBDUConfigurationUpdate_t *out; - F1AP_GNBDUConfigurationUpdateIEs_t *ie; - - uint8_t *buffer; - uint32_t len; - int i = 0; - int j = 0; - + instance_t du_mod_idP, + f1ap_setup_req_t *f1ap_setup_req) { + F1AP_F1AP_PDU_t pdu= {0}; + uint8_t *buffer=NULL; + uint32_t len=0; /* Create */ /* 0. Message Type */ - memset(&pdu, 0, sizeof(pdu)); pdu.present = F1AP_F1AP_PDU_PR_initiatingMessage; - pdu.choice.initiatingMessage = (F1AP_InitiatingMessage_t *)calloc(1, sizeof(F1AP_InitiatingMessage_t)); - pdu.choice.initiatingMessage->procedureCode = F1AP_ProcedureCode_id_gNBDUConfigurationUpdate; - pdu.choice.initiatingMessage->criticality = F1AP_Criticality_reject; - pdu.choice.initiatingMessage->value.present = F1AP_InitiatingMessage__value_PR_GNBDUConfigurationUpdate; - out = &pdu.choice.initiatingMessage->value.choice.GNBDUConfigurationUpdate; - + asn1cCalloc(pdu.choice.initiatingMessage, initMsg); + initMsg->procedureCode = F1AP_ProcedureCode_id_gNBDUConfigurationUpdate; + initMsg->criticality = F1AP_Criticality_reject; + initMsg->value.present = F1AP_InitiatingMessage__value_PR_GNBDUConfigurationUpdate; + F1AP_GNBDUConfigurationUpdate_t *out = &pdu.choice.initiatingMessage->value.choice.GNBDUConfigurationUpdate; /* mandatory */ /* c1. Transaction ID (integer value) */ - ie = (F1AP_GNBDUConfigurationUpdateIEs_t *)calloc(1, sizeof(F1AP_GNBDUConfigurationUpdateIEs_t)); - ie->id = F1AP_ProtocolIE_ID_id_TransactionID; - ie->criticality = F1AP_Criticality_reject; - ie->value.present = F1AP_GNBDUConfigurationUpdateIEs__value_PR_TransactionID; - ie->value.choice.TransactionID = F1AP_get_next_transaction_identifier(instance, du_mod_idP); - ASN_SEQUENCE_ADD(&out->protocolIEs.list, ie); - - + asn1cSequenceAdd(out, F1AP_GNBDUConfigurationUpdateIEs_t, ie1); + ie1->id = F1AP_ProtocolIE_ID_id_TransactionID; + ie1->criticality = F1AP_Criticality_reject; + ie1->value.present = F1AP_GNBDUConfigurationUpdateIEs__value_PR_TransactionID; + ie1->value.choice.TransactionID = F1AP_get_next_transaction_identifier(instance, du_mod_idP); /* mandatory */ /* c2. Served_Cells_To_Add */ - ie = (F1AP_GNBDUConfigurationUpdateIEs_t *)calloc(1, sizeof(F1AP_GNBDUConfigurationUpdateIEs_t)); - ie->id = F1AP_ProtocolIE_ID_id_Served_Cells_To_Add_List; - ie->criticality = F1AP_Criticality_reject; - ie->value.present = F1AP_GNBDUConfigurationUpdateIEs__value_PR_Served_Cells_To_Add_List; - - for (j=0; - j<1; - j++) { - // - F1AP_Served_Cells_To_Add_ItemIEs_t *served_cells_to_add_item_ies; - served_cells_to_add_item_ies = (F1AP_Served_Cells_To_Add_ItemIEs_t *)calloc(1, sizeof(F1AP_Served_Cells_To_Add_ItemIEs_t)); - served_cells_to_add_item_ies->id = F1AP_ProtocolIE_ID_id_Served_Cells_To_Add_Item; - served_cells_to_add_item_ies->criticality = F1AP_Criticality_reject; - served_cells_to_add_item_ies->value.present = F1AP_Served_Cells_To_Add_ItemIEs__value_PR_Served_Cells_To_Add_Item; - - F1AP_Served_Cells_To_Add_Item_t served_cells_to_add_item; - memset((void *)&served_cells_to_add_item, 0, sizeof(F1AP_Served_Cells_To_Add_Item_t)); - - /* 2.1.1 serverd cell Information */ - F1AP_Served_Cell_Information_t served_cell_information; - - memset((void *)&served_cell_information, 0, sizeof(F1AP_Served_Cell_Information_t)); - /* - nRCGI */ - F1AP_NRCGI_t nRCGI; - memset(&nRCGI, 0, sizeof(F1AP_NRCGI_t)); - MCC_MNC_TO_PLMNID(f1ap_setup_req->mcc[i], f1ap_setup_req->mnc[i], f1ap_setup_req->mnc_digit_length[i], &nRCGI.pLMN_Identity); - LOG_D(F1AP, "nr_cellId : %x %x %x %x %x\n", - nRCGI.nRCellIdentity.buf[0], - nRCGI.nRCellIdentity.buf[1], - nRCGI.nRCellIdentity.buf[2], - nRCGI.nRCellIdentity.buf[3], - nRCGI.nRCellIdentity.buf[4]); - NR_CELL_ID_TO_BIT_STRING(f1ap_setup_req->nr_cellid[i], &nRCGI.nRCellIdentity); - served_cell_information.nRCGI = nRCGI; - - /* - nRPCI */ - served_cell_information.nRPCI = f1ap_setup_req->nr_pci[i]; // int 0..1007 - - /* - fiveGS_TAC */ - if (RC.nrrrc) { - uint8_t fiveGS_TAC[3]; - fiveGS_TAC[0] = ((uint8_t*)&f1ap_setup_req->tac[i])[2]; - fiveGS_TAC[1] = ((uint8_t*)&f1ap_setup_req->tac[i])[1]; - fiveGS_TAC[2] = ((uint8_t*)&f1ap_setup_req->tac[i])[0]; - OCTET_STRING_fromBuf(served_cell_information.fiveGS_TAC, - (const char *)fiveGS_TAC, - 3); - } else { - OCTET_STRING_fromBuf(served_cell_information.fiveGS_TAC, - (const char *) &f1ap_setup_req->tac[i], - 3); - } - - /* - Configured_EPS_TAC */ - if(1){ - served_cell_information.configured_EPS_TAC = (F1AP_Configured_EPS_TAC_t *)calloc(1, sizeof(F1AP_Configured_EPS_TAC_t)); - OCTET_STRING_fromBuf(served_cell_information.configured_EPS_TAC, - "2", - 2); - } - - F1AP_ServedPLMNs_Item_t *servedPLMN_item = calloc(1,sizeof(*servedPLMN_item)); - memset(servedPLMN_item,0,sizeof(*servedPLMN_item)); - MCC_MNC_TO_PLMNID(f1ap_du_data->mcc[i], f1ap_du_data->mnc[i], f1ap_du_data->mnc_digit_length[i], &servedPLMN_item->pLMN_Identity); - ASN_SEQUENCE_ADD(&served_cell_information.servedPLMNs.list, servedPLMN_item); - - // // /* - CHOICE NR-MODE-Info */ - F1AP_NR_Mode_Info_t nR_Mode_Info; - - if (f1ap_setup_req->fdd_flag) { - nR_Mode_Info.present = F1AP_NR_Mode_Info_PR_fDD; - /* > FDD >> FDD Info */ - F1AP_FDD_Info_t *fDD_Info = (F1AP_FDD_Info_t *)calloc(1, sizeof(F1AP_FDD_Info_t)); - /* >>> UL NRFreqInfo */ - fDD_Info->uL_NRFreqInfo.nRARFCN = 999L; - - F1AP_FreqBandNrItem_t ul_freqBandNrItem; - memset((void *)&ul_freqBandNrItem, 0, sizeof(F1AP_FreqBandNrItem_t)); - ul_freqBandNrItem.freqBandIndicatorNr = 888L; - - F1AP_SupportedSULFreqBandItem_t ul_supportedSULFreqBandItem; - memset((void *)&ul_supportedSULFreqBandItem, 0, sizeof(F1AP_SupportedSULFreqBandItem_t)); - ul_supportedSULFreqBandItem.freqBandIndicatorNr = 777L; - ASN_SEQUENCE_ADD(&ul_freqBandNrItem.supportedSULBandList.list, &ul_supportedSULFreqBandItem); - - ASN_SEQUENCE_ADD(&fDD_Info->uL_NRFreqInfo.freqBandListNr.list, &ul_freqBandNrItem); - - /* >>> DL NRFreqInfo */ - fDD_Info->dL_NRFreqInfo.nRARFCN = 666L; - - F1AP_FreqBandNrItem_t dl_freqBandNrItem; - memset((void *)&dl_freqBandNrItem, 0, sizeof(F1AP_FreqBandNrItem_t)); - dl_freqBandNrItem.freqBandIndicatorNr = 555L; - - F1AP_SupportedSULFreqBandItem_t dl_supportedSULFreqBandItem; - memset((void *)&dl_supportedSULFreqBandItem, 0, sizeof(F1AP_SupportedSULFreqBandItem_t)); - dl_supportedSULFreqBandItem.freqBandIndicatorNr = 444L; - ASN_SEQUENCE_ADD(&dl_freqBandNrItem.supportedSULBandList.list, &dl_supportedSULFreqBandItem); - - ASN_SEQUENCE_ADD(&fDD_Info->dL_NRFreqInfo.freqBandListNr.list, &dl_freqBandNrItem); - - /* >>> UL Transmission Bandwidth */ - fDD_Info->uL_Transmission_Bandwidth.nRSCS = F1AP_NRSCS_scs15; - fDD_Info->uL_Transmission_Bandwidth.nRNRB = F1AP_NRNRB_nrb11; - /* >>> DL Transmission Bandwidth */ - fDD_Info->dL_Transmission_Bandwidth.nRSCS = F1AP_NRSCS_scs15; - fDD_Info->dL_Transmission_Bandwidth.nRNRB = F1AP_NRNRB_nrb11; - - nR_Mode_Info.choice.fDD = fDD_Info; - } else { // TDD - nR_Mode_Info.present = F1AP_NR_Mode_Info_PR_tDD; - - /* > TDD >> TDD Info */ - F1AP_TDD_Info_t *tDD_Info = (F1AP_TDD_Info_t *)calloc(1, sizeof(F1AP_TDD_Info_t)); - /* >>> ARFCN */ - tDD_Info->nRFreqInfo.nRARFCN = 999L; // Integer - F1AP_FreqBandNrItem_t nr_freqBandNrItem; - memset((void *)&nr_freqBandNrItem, 0, sizeof(F1AP_FreqBandNrItem_t)); - nr_freqBandNrItem.freqBandIndicatorNr = 555L; - - F1AP_SupportedSULFreqBandItem_t nr_supportedSULFreqBandItem; - memset((void *)&nr_supportedSULFreqBandItem, 0, sizeof(F1AP_SupportedSULFreqBandItem_t)); - nr_supportedSULFreqBandItem.freqBandIndicatorNr = 444L; - ASN_SEQUENCE_ADD(&nr_freqBandNrItem.supportedSULBandList.list, &nr_supportedSULFreqBandItem); - - ASN_SEQUENCE_ADD(&tDD_Info->nRFreqInfo.freqBandListNr.list, &nr_freqBandNrItem); - - tDD_Info->transmission_Bandwidth.nRSCS= F1AP_NRSCS_scs15; - tDD_Info->transmission_Bandwidth.nRNRB= F1AP_NRNRB_nrb11; - - nR_Mode_Info.choice.tDD = tDD_Info; - } - - served_cell_information.nR_Mode_Info = nR_Mode_Info; - - /* - measurementTimingConfiguration */ - char *measurementTimingConfiguration = "0"; // sept. 2018 - - OCTET_STRING_fromBuf(&served_cell_information.measurementTimingConfiguration, - measurementTimingConfiguration, - strlen(measurementTimingConfiguration)); - served_cells_to_add_item.served_Cell_Information = served_cell_information; // - - /* 2.1.2 gNB-DU System Information */ - F1AP_GNB_DU_System_Information_t *gNB_DU_System_Information = (F1AP_GNB_DU_System_Information_t *)calloc(1, sizeof(F1AP_GNB_DU_System_Information_t)); - - OCTET_STRING_fromBuf(&gNB_DU_System_Information->mIB_message, // sept. 2018 - "1", - sizeof("1")); - - OCTET_STRING_fromBuf(&gNB_DU_System_Information->sIB1_message, // sept. 2018 - "1", - sizeof("1")); - served_cells_to_add_item.gNB_DU_System_Information = gNB_DU_System_Information; // - - /* ADD */ - served_cells_to_add_item_ies->value.choice.Served_Cells_To_Add_Item = served_cells_to_add_item; - - ASN_SEQUENCE_ADD(&ie->value.choice.Served_Cells_To_Add_List.list, - served_cells_to_add_item_ies); - + asn1cSequenceAdd(out, F1AP_GNBDUConfigurationUpdateIEs_t, ie2); + ie2->id = F1AP_ProtocolIE_ID_id_Served_Cells_To_Add_List; + ie2->criticality = F1AP_Criticality_reject; + ie2->value.present = F1AP_GNBDUConfigurationUpdateIEs__value_PR_Served_Cells_To_Add_List; + + for (int j=0; j<1; j++) { + // + asn1cSequenceAdd(ie2->value.choice.Served_Cells_To_Add_List.list, F1AP_Served_Cells_To_Add_ItemIEs_t, served_cells_to_add_item_ies); + served_cells_to_add_item_ies->id = F1AP_ProtocolIE_ID_id_Served_Cells_To_Add_Item; + served_cells_to_add_item_ies->criticality = F1AP_Criticality_reject; + served_cells_to_add_item_ies->value.present = F1AP_Served_Cells_To_Add_ItemIEs__value_PR_Served_Cells_To_Add_Item; + F1AP_Served_Cells_To_Add_Item_t *served_cells_to_add_item= &served_cells_to_add_item_ies->value.choice.Served_Cells_To_Add_Item; + F1AP_Served_Cell_Information_t *served_cell_information=&served_cells_to_add_item->served_Cell_Information; + /* - nRCGI */ + addnRCGI(served_cell_information->nRCGI, &f1ap_setup_req->cell[j]); + /* - nRPCI */ + /* 2.1.1 serverd cell Information */ + cellIDs_t *cell=&f1ap_req(false, instance)->cell[j]; + served_cell_information->nRPCI = cell->nr_pci; // int 0..1007 + /* - fiveGS_TAC */ + uint32_t tac=htonl(cell->tac); + served_cell_information->fiveGS_TAC=(F1AP_FiveGS_TAC_t *) calloc(1,sizeof(F1AP_FiveGS_TAC_t *)); + OCTET_STRING_fromBuf(served_cell_information->fiveGS_TAC, ((char *)&tac)+1, 3); + + /* - Configured_EPS_TAC */ + if(1) { + served_cell_information->configured_EPS_TAC = (F1AP_Configured_EPS_TAC_t *)calloc(1, sizeof(F1AP_Configured_EPS_TAC_t)); + OCTET_STRING_fromBuf(served_cell_information->configured_EPS_TAC,"2", 2); + } + + asn1cSequenceAdd(served_cell_information->servedPLMNs.list, F1AP_ServedPLMNs_Item_t, servedPLMN_item); + MCC_MNC_TO_PLMNID(cell->mcc, cell->mnc, cell->mnc_digit_length, &servedPLMN_item->pLMN_Identity); + // // /* - CHOICE NR-MODE-Info */ + F1AP_NR_Mode_Info_t *nR_Mode_Info=&served_cell_information->nR_Mode_Info; + LOG_E(F1AP,"Here hardcoded values instead of values from configuration file\n"); + + if (f1ap_setup_req->fdd_flag) { + nR_Mode_Info->present = F1AP_NR_Mode_Info_PR_fDD; + /* > FDD >> FDD Info */ + asn1cCalloc(nR_Mode_Info->choice.fDD, fDD_Info); + /* >>> UL NRFreqInfo */ + fDD_Info->uL_NRFreqInfo.nRARFCN = 999L; + asn1cSequenceAdd(fDD_Info->uL_NRFreqInfo.freqBandListNr.list, F1AP_FreqBandNrItem_t, ul_freqBandNrItem); + ul_freqBandNrItem->freqBandIndicatorNr = 888L; + asn1cSequenceAdd(ul_freqBandNrItem->supportedSULBandList.list, F1AP_SupportedSULFreqBandItem_t, ul_supportedSULFreqBandItem); + ul_supportedSULFreqBandItem->freqBandIndicatorNr = 777L; + /* >>> DL NRFreqInfo */ + fDD_Info->dL_NRFreqInfo.nRARFCN = 666L; + asn1cSequenceAdd(fDD_Info->dL_NRFreqInfo.freqBandListNr.list, F1AP_FreqBandNrItem_t, dl_freqBandNrItem); + dl_freqBandNrItem->freqBandIndicatorNr = 555L; + asn1cSequenceAdd(dl_freqBandNrItem->supportedSULBandList.list, F1AP_SupportedSULFreqBandItem_t, dl_supportedSULFreqBandItem); + dl_supportedSULFreqBandItem->freqBandIndicatorNr = 444L; + /* >>> UL Transmission Bandwidth */ + fDD_Info->uL_Transmission_Bandwidth.nRSCS = F1AP_NRSCS_scs15; + fDD_Info->uL_Transmission_Bandwidth.nRNRB = F1AP_NRNRB_nrb11; + /* >>> DL Transmission Bandwidth */ + fDD_Info->dL_Transmission_Bandwidth.nRSCS = F1AP_NRSCS_scs15; + fDD_Info->dL_Transmission_Bandwidth.nRNRB = F1AP_NRNRB_nrb11; + } else { // TDD + nR_Mode_Info->present = F1AP_NR_Mode_Info_PR_tDD; + /* > TDD >> TDD Info */ + asn1cCalloc(nR_Mode_Info->choice.tDD, tDD_Info); + /* >>> ARFCN */ + tDD_Info->nRFreqInfo.nRARFCN = 999L; // Integer + asn1cSequenceAdd(tDD_Info->nRFreqInfo.freqBandListNr.list, F1AP_FreqBandNrItem_t, nr_freqBandNrItem); + nr_freqBandNrItem->freqBandIndicatorNr = 555L; + asn1cSequenceAdd(nr_freqBandNrItem->supportedSULBandList.list, F1AP_SupportedSULFreqBandItem_t, nr_supportedSULFreqBandItem); + nr_supportedSULFreqBandItem->freqBandIndicatorNr = 444L; + tDD_Info->transmission_Bandwidth.nRSCS= F1AP_NRSCS_scs15; + tDD_Info->transmission_Bandwidth.nRNRB= F1AP_NRNRB_nrb11; + } + + /* - measurementTimingConfiguration */ + char *measurementTimingConfiguration = "0"; // sept. 2018 + OCTET_STRING_fromBuf(&served_cell_information->measurementTimingConfiguration, + measurementTimingConfiguration, + strlen(measurementTimingConfiguration)); + /* 2.1.2 gNB-DU System Information */ + asn1cCalloc(served_cells_to_add_item->gNB_DU_System_Information, gNB_DU_System_Information); + OCTET_STRING_fromBuf(&gNB_DU_System_Information->mIB_message, // sept. 2018 + "1", + sizeof("1")); + OCTET_STRING_fromBuf(&gNB_DU_System_Information->sIB1_message, // sept. 2018 + "1", + sizeof("1")); } - ASN_SEQUENCE_ADD(&out->protocolIEs.list, ie); - /* mandatory */ /* c3. Served_Cells_To_Modify */ - ie = (F1AP_GNBDUConfigurationUpdateIEs_t *)calloc(1, sizeof(F1AP_GNBDUConfigurationUpdateIEs_t)); - ie->id = F1AP_ProtocolIE_ID_id_Served_Cells_To_Modify_List; - ie->criticality = F1AP_Criticality_reject; - ie->value.present = F1AP_GNBDUConfigurationUpdateIEs__value_PR_Served_Cells_To_Modify_List; - - for (i=0; - i<1; - i++) { - // - F1AP_Served_Cells_To_Modify_ItemIEs_t *served_cells_to_modify_item_ies; - served_cells_to_modify_item_ies = (F1AP_Served_Cells_To_Modify_ItemIEs_t *)calloc(1, sizeof(F1AP_Served_Cells_To_Modify_ItemIEs_t)); - served_cells_to_modify_item_ies->id = F1AP_ProtocolIE_ID_id_Served_Cells_To_Modify_Item; - served_cells_to_modify_item_ies->criticality = F1AP_Criticality_reject; - served_cells_to_modify_item_ies->value.present = F1AP_Served_Cells_To_Modify_ItemIEs__value_PR_Served_Cells_To_Modify_Item; - - F1AP_Served_Cells_To_Modify_Item_t served_cells_to_modify_item; - memset((void *)&served_cells_to_modify_item, 0, sizeof(F1AP_Served_Cells_To_Modify_Item_t)); - - /* 3.1 oldNRCGI */ - F1AP_NRCGI_t oldNRCGI; - memset(&oldNRCGI, 0, sizeof(F1AP_NRCGI_t)); - MCC_MNC_TO_PLMNID(f1ap_setup_req->mcc[i], f1ap_setup_req->mnc[i], f1ap_setup_req->mnc_digit_length[i], - &oldNRCGI.pLMN_Identity); - NR_CELL_ID_TO_BIT_STRING(f1ap_setup_req->nr_cellid[i], &oldNRCGI.nRCellIdentity); - served_cells_to_modify_item.oldNRCGI = oldNRCGI; - - - /* 3.2.1 serverd cell Information */ - F1AP_Served_Cell_Information_t served_cell_information; - memset((void *)&served_cell_information, 0, sizeof(F1AP_Served_Cell_Information_t)); - - /* - nRCGI */ - F1AP_NRCGI_t nRCGI; - memset(&nRCGI, 0, sizeof(F1AP_NRCGI_t)); - MCC_MNC_TO_PLMNID(f1ap_setup_req->mcc[i], f1ap_setup_req->mnc[i], f1ap_setup_req->mnc_digit_length[i], - &nRCGI.pLMN_Identity); - NR_CELL_ID_TO_BIT_STRING(f1ap_setup_req->nr_cellid[i], &nRCGI.nRCellIdentity); - served_cell_information.nRCGI = nRCGI; - - /* - nRPCI */ - served_cell_information.nRPCI = f1ap_setup_req->nr_pci[i]; // int 0..1007 - - /* - fiveGS_TAC */ - OCTET_STRING_fromBuf(served_cell_information.fiveGS_TAC, - (const char *) &f1ap_setup_req->tac[i], - 3); - - /* - Configured_EPS_TAC */ - if(1){ - served_cell_information.configured_EPS_TAC = (F1AP_Configured_EPS_TAC_t *)calloc(1, sizeof(F1AP_Configured_EPS_TAC_t)); - OCTET_STRING_fromBuf(served_cell_information.configured_EPS_TAC, - "2", - 2); - } - - F1AP_ServedPLMNs_Item_t *servedPLMN_item = calloc(1,sizeof(*servedPLMN_item)); - memset(servedPLMN_item,0,sizeof(*servedPLMN_item)); - MCC_MNC_TO_PLMNID(f1ap_du_data->mcc[i], f1ap_du_data->mnc[i], f1ap_du_data->mnc_digit_length[i], &servedPLMN_item->pLMN_Identity); - ASN_SEQUENCE_ADD(&served_cell_information.servedPLMNs.list, servedPLMN_item); - - // // /* - CHOICE NR-MODE-Info */ - F1AP_NR_Mode_Info_t nR_Mode_Info; - - if (f1ap_setup_req->fdd_flag) { - nR_Mode_Info.present = F1AP_NR_Mode_Info_PR_fDD; - /* > FDD >> FDD Info */ - F1AP_FDD_Info_t *fDD_Info = (F1AP_FDD_Info_t *)calloc(1, sizeof(F1AP_FDD_Info_t)); - /* >>> UL NRFreqInfo */ - fDD_Info->uL_NRFreqInfo.nRARFCN = 999L; - - F1AP_FreqBandNrItem_t ul_freqBandNrItem; - memset((void *)&ul_freqBandNrItem, 0, sizeof(F1AP_FreqBandNrItem_t)); - ul_freqBandNrItem.freqBandIndicatorNr = 888L; - - F1AP_SupportedSULFreqBandItem_t ul_supportedSULFreqBandItem; - memset((void *)&ul_supportedSULFreqBandItem, 0, sizeof(F1AP_SupportedSULFreqBandItem_t)); - ul_supportedSULFreqBandItem.freqBandIndicatorNr = 777L; - ASN_SEQUENCE_ADD(&ul_freqBandNrItem.supportedSULBandList.list, &ul_supportedSULFreqBandItem); - - ASN_SEQUENCE_ADD(&fDD_Info->uL_NRFreqInfo.freqBandListNr.list, &ul_freqBandNrItem); - - /* >>> DL NRFreqInfo */ - fDD_Info->dL_NRFreqInfo.nRARFCN = 666L; - - F1AP_FreqBandNrItem_t dl_freqBandNrItem; - memset((void *)&dl_freqBandNrItem, 0, sizeof(F1AP_FreqBandNrItem_t)); - dl_freqBandNrItem.freqBandIndicatorNr = 555L; - - F1AP_SupportedSULFreqBandItem_t dl_supportedSULFreqBandItem; - memset((void *)&dl_supportedSULFreqBandItem, 0, sizeof(F1AP_SupportedSULFreqBandItem_t)); - dl_supportedSULFreqBandItem.freqBandIndicatorNr = 444L; - ASN_SEQUENCE_ADD(&dl_freqBandNrItem.supportedSULBandList.list, &dl_supportedSULFreqBandItem); - - ASN_SEQUENCE_ADD(&fDD_Info->dL_NRFreqInfo.freqBandListNr.list, &dl_freqBandNrItem); - - /* >>> UL Transmission Bandwidth */ - fDD_Info->uL_Transmission_Bandwidth.nRSCS = F1AP_NRSCS_scs15; - fDD_Info->uL_Transmission_Bandwidth.nRNRB = F1AP_NRNRB_nrb11; - /* >>> DL Transmission Bandwidth */ - fDD_Info->dL_Transmission_Bandwidth.nRSCS = F1AP_NRSCS_scs15; - fDD_Info->dL_Transmission_Bandwidth.nRNRB = F1AP_NRNRB_nrb11; - - nR_Mode_Info.choice.fDD = fDD_Info; - } else { // TDD - nR_Mode_Info.present = F1AP_NR_Mode_Info_PR_tDD; - - /* > TDD >> TDD Info */ - F1AP_TDD_Info_t *tDD_Info = (F1AP_TDD_Info_t *)calloc(1, sizeof(F1AP_TDD_Info_t)); - /* >>> ARFCN */ - tDD_Info->nRFreqInfo.nRARFCN = 999L; // Integer - F1AP_FreqBandNrItem_t nr_freqBandNrItem; - memset((void *)&nr_freqBandNrItem, 0, sizeof(F1AP_FreqBandNrItem_t)); - nr_freqBandNrItem.freqBandIndicatorNr = 555L; - - F1AP_SupportedSULFreqBandItem_t nr_supportedSULFreqBandItem; - memset((void *)&nr_supportedSULFreqBandItem, 0, sizeof(F1AP_SupportedSULFreqBandItem_t)); - nr_supportedSULFreqBandItem.freqBandIndicatorNr = 444L; - ASN_SEQUENCE_ADD(&nr_freqBandNrItem.supportedSULBandList.list, &nr_supportedSULFreqBandItem); - - ASN_SEQUENCE_ADD(&tDD_Info->nRFreqInfo.freqBandListNr.list, &nr_freqBandNrItem); - - tDD_Info->transmission_Bandwidth.nRSCS= F1AP_NRSCS_scs15; - tDD_Info->transmission_Bandwidth.nRNRB= F1AP_NRNRB_nrb11; - - nR_Mode_Info.choice.tDD = tDD_Info; - } - - served_cell_information.nR_Mode_Info = nR_Mode_Info; - - /* - measurementTimingConfiguration */ - char *measurementTimingConfiguration = "0"; // sept. 2018 - - OCTET_STRING_fromBuf(&served_cell_information.measurementTimingConfiguration, - measurementTimingConfiguration, - strlen(measurementTimingConfiguration)); - served_cells_to_modify_item.served_Cell_Information = served_cell_information; // - - /* 3.2.2 gNB-DU System Information */ - F1AP_GNB_DU_System_Information_t *gNB_DU_System_Information = (F1AP_GNB_DU_System_Information_t *)calloc(1, sizeof(F1AP_GNB_DU_System_Information_t)); - - OCTET_STRING_fromBuf(&gNB_DU_System_Information->mIB_message, // sept. 2018 - "1", - sizeof("1")); - - OCTET_STRING_fromBuf(&gNB_DU_System_Information->sIB1_message, // sept. 2018 - "1", - sizeof("1")); - served_cells_to_modify_item.gNB_DU_System_Information = gNB_DU_System_Information; // - - /* ADD */ - served_cells_to_modify_item_ies->value.choice.Served_Cells_To_Modify_Item = served_cells_to_modify_item; - - ASN_SEQUENCE_ADD(&ie->value.choice.Served_Cells_To_Modify_List.list, - served_cells_to_modify_item_ies); - + asn1cSequenceAdd(out, F1AP_GNBDUConfigurationUpdateIEs_t, ie3); + ie3->id = F1AP_ProtocolIE_ID_id_Served_Cells_To_Modify_List; + ie3->criticality = F1AP_Criticality_reject; + ie3->value.present = F1AP_GNBDUConfigurationUpdateIEs__value_PR_Served_Cells_To_Modify_List; + + for (int i=0; i<1; i++) { + // + cellIDs_t *cell=&f1ap_req(false, instance)->cell[i]; + asn1cSequenceAdd(ie3->value.choice.Served_Cells_To_Modify_List.list, F1AP_Served_Cells_To_Modify_ItemIEs_t, served_cells_to_modify_item_ies); + served_cells_to_modify_item_ies->id = F1AP_ProtocolIE_ID_id_Served_Cells_To_Modify_Item; + served_cells_to_modify_item_ies->criticality = F1AP_Criticality_reject; + served_cells_to_modify_item_ies->value.present = F1AP_Served_Cells_To_Modify_ItemIEs__value_PR_Served_Cells_To_Modify_Item; + F1AP_Served_Cells_To_Modify_Item_t *served_cells_to_modify_item=&served_cells_to_modify_item_ies->value.choice.Served_Cells_To_Modify_Item; + /* 3.1 oldNRCGI */ + //addnRGCI(served_cells_to_modify_item->oldNRCGI, f1ap_setup_req->cell[i]); + /* 3.2.1 serverd cell Information */ + F1AP_Served_Cell_Information_t *served_cell_information= &served_cells_to_modify_item->served_Cell_Information; + /* - nRCGI */ + //addnRGCI(served_cell_information->nRCGI,f1ap_setup_req->cell[i]); + /* - nRPCI */ + served_cell_information->nRPCI = f1ap_setup_req->cell[i].nr_pci; // int 0..1007 + /* - fiveGS_TAC */ + asn1cCalloc(served_cell_information->fiveGS_TAC, tac ); + OCTET_STRING_fromBuf(tac, + (const char *) &f1ap_setup_req->cell[i].tac, + 3); + + /* - Configured_EPS_TAC */ + if(1) { + asn1cCalloc(served_cell_information->configured_EPS_TAC, tmp2); + OCTET_STRING_fromBuf(tmp2, + "2", + 2); + } + + asn1cSequenceAdd(served_cell_information->servedPLMNs.list, F1AP_ServedPLMNs_Item_t, servedPLMN_item); + MCC_MNC_TO_PLMNID(cell->mcc, cell->mnc, cell->mnc_digit_length, &servedPLMN_item->pLMN_Identity); + // // /* - CHOICE NR-MODE-Info */ + F1AP_NR_Mode_Info_t *nR_Mode_Info= &served_cell_information->nR_Mode_Info; + + if (f1ap_setup_req->fdd_flag) { + nR_Mode_Info->present = F1AP_NR_Mode_Info_PR_fDD; + /* > FDD >> FDD Info */ + asn1cCalloc(nR_Mode_Info->choice.fDD, fDD_Info); + /* >>> UL NRFreqInfo */ + fDD_Info->uL_NRFreqInfo.nRARFCN = 999L; + asn1cSequenceAdd(fDD_Info->uL_NRFreqInfo.freqBandListNr.list, F1AP_FreqBandNrItem_t, ul_freqBandNrItem); + ul_freqBandNrItem->freqBandIndicatorNr = 888L; + asn1cSequenceAdd(ul_freqBandNrItem->supportedSULBandList.list, F1AP_SupportedSULFreqBandItem_t, ul_supportedSULFreqBandItem); + ul_supportedSULFreqBandItem->freqBandIndicatorNr = 777L; + /* >>> DL NRFreqInfo */ + fDD_Info->dL_NRFreqInfo.nRARFCN = 666L; + asn1cSequenceAdd(dl_freqBandNrItem->supportedSULBandList.list, F1AP_FreqBandNrItem_t, dl_freqBandNrItem); + dl_freqBandNrItem->freqBandIndicatorNr = 555L; + F1AP_SupportedSULFreqBandItem_t dl_supportedSULFreqBandItem; + memset((void *)&dl_supportedSULFreqBandItem, 0, sizeof(F1AP_SupportedSULFreqBandItem_t)); + dl_supportedSULFreqBandItem.freqBandIndicatorNr = 444L; + /* >>> UL Transmission Bandwidth */ + fDD_Info->uL_Transmission_Bandwidth.nRSCS = F1AP_NRSCS_scs15; + fDD_Info->uL_Transmission_Bandwidth.nRNRB = F1AP_NRNRB_nrb11; + /* >>> DL Transmission Bandwidth */ + fDD_Info->dL_Transmission_Bandwidth.nRSCS = F1AP_NRSCS_scs15; + fDD_Info->dL_Transmission_Bandwidth.nRNRB = F1AP_NRNRB_nrb11; + } else { // TDD + nR_Mode_Info->present = F1AP_NR_Mode_Info_PR_tDD; + /* > TDD >> TDD Info */ + asn1cCalloc(nR_Mode_Info->choice.tDD, tDD_Info); + /* >>> ARFCN */ + tDD_Info->nRFreqInfo.nRARFCN = 999L; // Integer + asn1cSequenceAdd(tDD_Info->nRFreqInfo.freqBandListNr.list, F1AP_FreqBandNrItem_t, nr_freqBandNrItem); + nr_freqBandNrItem->freqBandIndicatorNr = 555L; + asn1cSequenceAdd(nr_freqBandNrItem->supportedSULBandList.list, F1AP_SupportedSULFreqBandItem_t, nr_supportedSULFreqBandItem); + nr_supportedSULFreqBandItem->freqBandIndicatorNr = 444L; + tDD_Info->transmission_Bandwidth.nRSCS= F1AP_NRSCS_scs15; + tDD_Info->transmission_Bandwidth.nRNRB= F1AP_NRNRB_nrb11; + } + + /* - measurementTimingConfiguration */ + char *measurementTimingConfiguration = "0"; // sept. 2018 + OCTET_STRING_fromBuf(&served_cell_information->measurementTimingConfiguration, + measurementTimingConfiguration, + strlen(measurementTimingConfiguration)); + /* 3.2.2 gNB-DU System Information */ + asn1cCalloc( served_cells_to_modify_item->gNB_DU_System_Information, gNB_DU_System_Information); + OCTET_STRING_fromBuf(&gNB_DU_System_Information->mIB_message, // sept. 2018 + "1", + sizeof("1")); + OCTET_STRING_fromBuf(&gNB_DU_System_Information->sIB1_message, // sept. 2018 + "1", + sizeof("1")); } - ASN_SEQUENCE_ADD(&out->protocolIEs.list, ie); - /* mandatory */ /* c4. Served_Cells_To_Delete */ - ie = (F1AP_GNBDUConfigurationUpdateIEs_t *)calloc(1, sizeof(F1AP_GNBDUConfigurationUpdateIEs_t)); - ie->id = F1AP_ProtocolIE_ID_id_Served_Cells_To_Delete_List; - ie->criticality = F1AP_Criticality_reject; - ie->value.present = F1AP_GNBDUConfigurationUpdateIEs__value_PR_Served_Cells_To_Delete_List; - - for (i=0; - i<1; - i++) { - // - F1AP_Served_Cells_To_Delete_ItemIEs_t *served_cells_to_delete_item_ies; - served_cells_to_delete_item_ies = (F1AP_Served_Cells_To_Delete_ItemIEs_t *)calloc(1, sizeof(F1AP_Served_Cells_To_Delete_ItemIEs_t)); - served_cells_to_delete_item_ies->id = F1AP_ProtocolIE_ID_id_Served_Cells_To_Delete_Item; - served_cells_to_delete_item_ies->criticality = F1AP_Criticality_reject; - served_cells_to_delete_item_ies->value.present = F1AP_Served_Cells_To_Delete_ItemIEs__value_PR_Served_Cells_To_Delete_Item; - - F1AP_Served_Cells_To_Delete_Item_t served_cells_to_delete_item; - memset((void *)&served_cells_to_delete_item, 0, sizeof(F1AP_Served_Cells_To_Delete_Item_t)); - - /* 3.1 oldNRCGI */ - F1AP_NRCGI_t oldNRCGI; - memset(&oldNRCGI, 0, sizeof(F1AP_NRCGI_t)); - MCC_MNC_TO_PLMNID(f1ap_setup_req->mcc[i], f1ap_setup_req->mnc[i], f1ap_setup_req->mnc_digit_length[i], - &oldNRCGI.pLMN_Identity); - NR_CELL_ID_TO_BIT_STRING(f1ap_setup_req->nr_cellid[i], &oldNRCGI.nRCellIdentity); - served_cells_to_delete_item.oldNRCGI = oldNRCGI; - - /* ADD */ - served_cells_to_delete_item_ies->value.choice.Served_Cells_To_Delete_Item = served_cells_to_delete_item; - - ASN_SEQUENCE_ADD(&ie->value.choice.Served_Cells_To_Delete_List.list, - served_cells_to_delete_item_ies); + asn1cSequenceAdd(out, F1AP_GNBDUConfigurationUpdateIEs_t, ie4); + ie4->id = F1AP_ProtocolIE_ID_id_Served_Cells_To_Delete_List; + ie4->criticality = F1AP_Criticality_reject; + ie4->value.present = F1AP_GNBDUConfigurationUpdateIEs__value_PR_Served_Cells_To_Delete_List; + + for (int i=0; i<1; i++) { + // + asn1cSequenceAdd(ie4->value.choice.Served_Cells_To_Delete_List.list, F1AP_Served_Cells_To_Delete_ItemIEs_t, served_cells_to_delete_item_ies); + served_cells_to_delete_item_ies->id = F1AP_ProtocolIE_ID_id_Served_Cells_To_Delete_Item; + served_cells_to_delete_item_ies->criticality = F1AP_Criticality_reject; + served_cells_to_delete_item_ies->value.present = F1AP_Served_Cells_To_Delete_ItemIEs__value_PR_Served_Cells_To_Delete_Item; + F1AP_Served_Cells_To_Delete_Item_t *served_cells_to_delete_item=&served_cells_to_delete_item_ies->value.choice.Served_Cells_To_Delete_Item; + /* 3.1 oldNRCGI */ + addnRCGI(served_cells_to_delete_item->oldNRCGI, &f1ap_setup_req->cell[i]); } - ASN_SEQUENCE_ADD(&out->protocolIEs.list, ie); - - if (f1ap_encode_pdu(&pdu, &buffer, &len) < 0) { LOG_E(F1AP, "Failed to encode F1 gNB-DU CONFIGURATION UPDATE\n"); return -1; } + ASN_STRUCT_RESET(asn_DEF_F1AP_F1AP_PDU, &pdu); return 0; } - - int DU_handle_gNB_DU_CONFIGURATION_FAILURE(instance_t instance, - uint32_t assoc_id, - uint32_t stream, - F1AP_F1AP_PDU_t *pdu) { + uint32_t assoc_id, + uint32_t stream, + F1AP_F1AP_PDU_t *pdu) { AssertFatal(1==0,"Not implemented yet\n"); } int DU_handle_gNB_DU_CONFIGURATION_UPDATE_ACKNOWLEDGE(instance_t instance, - uint32_t assoc_id, - uint32_t stream, - F1AP_F1AP_PDU_t *pdu) { + uint32_t assoc_id, + uint32_t stream, + F1AP_F1AP_PDU_t *pdu) { AssertFatal(1==0,"Not implemented yet\n"); } int DU_handle_gNB_CU_CONFIGURATION_UPDATE(instance_t instance, - uint32_t assoc_id, - uint32_t stream, - F1AP_F1AP_PDU_t *pdu) { - - if(!RC.nrrrc) { - return 0; - } - + uint32_t assoc_id, + uint32_t stream, + F1AP_F1AP_PDU_t *pdu) { LOG_D(F1AP, "DU_handle_gNB_CU_CONFIGURATION_UPDATE\n"); - AssertFatal(pdu->present == F1AP_F1AP_PDU_PR_initiatingMessage, - "pdu->present != F1AP_F1AP_PDU_PR_initiatingMessage\n"); + "pdu->present != F1AP_F1AP_PDU_PR_initiatingMessage\n"); AssertFatal(pdu->choice.initiatingMessage->procedureCode == F1AP_ProcedureCode_id_gNBCUConfigurationUpdate, - "pdu->choice.initiatingMessage->procedureCode != F1AP_ProcedureCode_id_gNBCUConfigurationUpdate\n"); + "pdu->choice.initiatingMessage->procedureCode != F1AP_ProcedureCode_id_gNBCUConfigurationUpdate\n"); AssertFatal(pdu->choice.initiatingMessage->criticality == F1AP_Criticality_reject, - "pdu->choice.initiatingMessage->criticality != F1AP_Criticality_reject\n"); + "pdu->choice.initiatingMessage->criticality != F1AP_Criticality_reject\n"); AssertFatal(pdu->choice.initiatingMessage->value.present == F1AP_InitiatingMessage__value_PR_GNBCUConfigurationUpdate, - "pdu->choice.initiatingMessage->value.present != F1AP_InitiatingMessage__value_PR_GNBCUConfigurationUpdate\n"); - + "pdu->choice.initiatingMessage->value.present != F1AP_InitiatingMessage__value_PR_GNBCUConfigurationUpdate\n"); F1AP_GNBCUConfigurationUpdate_t *in = &pdu->choice.initiatingMessage->value.choice.GNBCUConfigurationUpdate; - - F1AP_GNBCUConfigurationUpdateIEs_t *ie; int TransactionId = -1; int num_cells_to_activate = 0; F1AP_Cells_to_be_Activated_List_Item_t *cell; - MessageDef *msg_p = itti_alloc_new_message (TASK_DU_F1, 0, F1AP_GNB_CU_CONFIGURATION_UPDATE); - LOG_D(F1AP, "F1AP: gNB_CU_Configuration_Update: protocolIEs.list.count %d\n", in->protocolIEs.list.count); - for (int i=0;i < in->protocolIEs.list.count; i++) { + + for (int i=0; i < in->protocolIEs.list.count; i++) { ie = in->protocolIEs.list.array[i]; + switch (ie->id) { case F1AP_ProtocolIE_ID_id_TransactionID: AssertFatal(ie->criticality == F1AP_Criticality_reject, - "ie->criticality != F1AP_Criticality_reject\n"); + "ie->criticality != F1AP_Criticality_reject\n"); AssertFatal(ie->value.present == F1AP_GNBCUConfigurationUpdateIEs__value_PR_TransactionID, - "ie->value.present != F1AP_GNBCUConfigurationUpdateIEs__value_PR_TransactionID\n"); + "ie->value.present != F1AP_GNBCUConfigurationUpdateIEs__value_PR_TransactionID\n"); TransactionId=ie->value.choice.TransactionID; LOG_D(F1AP, "F1AP: GNB-CU-ConfigurationUpdate: TransactionId %d\n", TransactionId); break; - case F1AP_ProtocolIE_ID_id_Cells_to_be_Activated_List: - { + + case F1AP_ProtocolIE_ID_id_Cells_to_be_Activated_List: { AssertFatal(ie->criticality == F1AP_Criticality_reject, - "ie->criticality != F1AP_Criticality_reject\n"); + "ie->criticality != F1AP_Criticality_reject\n"); AssertFatal(ie->value.present == F1AP_GNBCUConfigurationUpdateIEs__value_PR_Cells_to_be_Activated_List, - "ie->value.present != F1AP_GNBCUConfigurationUpdateIEs__value_PR_Cells_to_be_Activated_List\n"); + "ie->value.present != F1AP_GNBCUConfigurationUpdateIEs__value_PR_Cells_to_be_Activated_List\n"); num_cells_to_activate = ie->value.choice.Cells_to_be_Activated_List.list.count; LOG_D(F1AP, "F1AP: Activating %d cells\n",num_cells_to_activate); - for (int i=0;i<num_cells_to_activate;i++) { + for (int i=0; i<num_cells_to_activate; i++) { F1AP_Cells_to_be_Activated_List_ItemIEs_t *cells_to_be_activated_list_item_ies = (F1AP_Cells_to_be_Activated_List_ItemIEs_t *) ie->value.choice.Cells_to_be_Activated_List.list.array[i]; - AssertFatal(cells_to_be_activated_list_item_ies->id == F1AP_ProtocolIE_ID_id_Cells_to_be_Activated_List_Item, - "cells_to_be_activated_list_item_ies->id != F1AP_ProtocolIE_ID_id_Cells_to_be_Activated_List_Item"); + "cells_to_be_activated_list_item_ies->id != F1AP_ProtocolIE_ID_id_Cells_to_be_Activated_List_Item"); AssertFatal(cells_to_be_activated_list_item_ies->criticality == F1AP_Criticality_reject, - "cells_to_be_activated_list_item_ies->criticality == F1AP_Criticality_reject"); + "cells_to_be_activated_list_item_ies->criticality == F1AP_Criticality_reject"); AssertFatal(cells_to_be_activated_list_item_ies->value.present == F1AP_Cells_to_be_Activated_List_ItemIEs__value_PR_Cells_to_be_Activated_List_Item, - "cells_to_be_activated_list_item_ies->value.present == F1AP_Cells_to_be_Activated_List_ItemIEs__value_PR_Cells_to_be_Activated_List_Item"); - + "cells_to_be_activated_list_item_ies->value.present == F1AP_Cells_to_be_Activated_List_ItemIEs__value_PR_Cells_to_be_Activated_List_Item"); cell = &cells_to_be_activated_list_item_ies->value.choice.Cells_to_be_Activated_List_Item; - - TBCD_TO_MCC_MNC(&cell->nRCGI.pLMN_Identity, F1AP_GNB_CU_CONFIGURATION_UPDATE (msg_p).cells_to_activate[i].mcc, F1AP_GNB_CU_CONFIGURATION_UPDATE (msg_p).cells_to_activate[i].mnc, F1AP_GNB_CU_CONFIGURATION_UPDATE (msg_p).cells_to_activate[i].mnc_digit_length); - + TBCD_TO_MCC_MNC(&cell->nRCGI.pLMN_Identity, F1AP_GNB_CU_CONFIGURATION_UPDATE (msg_p).cells_to_activate[i].mcc, F1AP_GNB_CU_CONFIGURATION_UPDATE (msg_p).cells_to_activate[i].mnc, + F1AP_GNB_CU_CONFIGURATION_UPDATE (msg_p).cells_to_activate[i].mnc_digit_length); LOG_D(F1AP, "nr_cellId : %x %x %x %x %x\n", cell->nRCGI.nRCellIdentity.buf[0], cell->nRCGI.nRCellIdentity.buf[1], @@ -1156,61 +833,71 @@ int DU_handle_gNB_CU_CONFIGURATION_UPDATE(instance_t instance, cell->nRCGI.nRCellIdentity.buf[3], cell->nRCGI.nRCellIdentity.buf[4]); BIT_STRING_TO_NR_CELL_IDENTITY(&cell->nRCGI.nRCellIdentity, - F1AP_GNB_CU_CONFIGURATION_UPDATE (msg_p).cells_to_activate[i].nr_cellid); - F1AP_ProtocolExtensionContainer_154P112_t *ext = (F1AP_ProtocolExtensionContainer_154P112_t *)cell->iE_Extensions; + F1AP_GNB_CU_CONFIGURATION_UPDATE (msg_p).cells_to_activate[i].nr_cellid); + F1AP_ProtocolExtensionContainer_154P112_t *ext = (F1AP_ProtocolExtensionContainer_154P112_t *)cell->iE_Extensions; - if (ext==NULL) continue; + if (ext==NULL) + continue; - for (int cnt=0;cnt<ext->list.count;cnt++) { + for (int cnt=0; cnt<ext->list.count; cnt++) { F1AP_Cells_to_be_Activated_List_ItemExtIEs_t *cells_to_be_activated_list_itemExtIEs=(F1AP_Cells_to_be_Activated_List_ItemExtIEs_t *)ext->list.array[cnt]; + switch (cells_to_be_activated_list_itemExtIEs->id) { - /* - case F1AP_Cells_to_be_Activated_List_ItemExtIEs__extensionValue_PR_NOTHING: - case F1AP_Cells_to_be_Activated_List_ItemExtIEs__extensionValue_PR_GNB_CUSystemInformation, - case F1AP_Cells_to_be_Activated_List_ItemExtIEs__extensionValue_PR_AvailablePLMNList, - case F1AP_Cells_to_be_Activated_List_ItemExtIEs__extensionValue_PR_ExtendedAvailablePLMN_List, - case F1AP_Cells_to_be_Activated_List_ItemExtIEs__extensionValue_PR_IAB_Info_IAB_donor_CU, - case F1AP_Cells_to_be_Activated_List_ItemExtIEs__extensionValue_PR_AvailableSNPN_ID_List - */ - case F1AP_ProtocolIE_ID_id_gNB_CUSystemInformation: - { + /* + case F1AP_Cells_to_be_Activated_List_ItemExtIEs__extensionValue_PR_NOTHING: + case F1AP_Cells_to_be_Activated_List_ItemExtIEs__extensionValue_PR_GNB_CUSystemInformation, + case F1AP_Cells_to_be_Activated_List_ItemExtIEs__extensionValue_PR_AvailablePLMNList, + case F1AP_Cells_to_be_Activated_List_ItemExtIEs__extensionValue_PR_ExtendedAvailablePLMN_List, + case F1AP_Cells_to_be_Activated_List_ItemExtIEs__extensionValue_PR_IAB_Info_IAB_donor_CU, + case F1AP_Cells_to_be_Activated_List_ItemExtIEs__extensionValue_PR_AvailableSNPN_ID_List + */ + case F1AP_ProtocolIE_ID_id_gNB_CUSystemInformation: { F1AP_GNB_CU_CONFIGURATION_UPDATE (msg_p).cells_to_activate[i].nrpci = (cell->nRPCI != NULL) ? *cell->nRPCI : 0; - F1AP_GNB_CUSystemInformation_t *gNB_CUSystemInformation = (F1AP_GNB_CUSystemInformation_t*)&cells_to_be_activated_list_itemExtIEs->extensionValue.choice.GNB_CUSystemInformation; + F1AP_GNB_CUSystemInformation_t *gNB_CUSystemInformation = (F1AP_GNB_CUSystemInformation_t *)&cells_to_be_activated_list_itemExtIEs->extensionValue.choice.GNB_CUSystemInformation; F1AP_GNB_CU_CONFIGURATION_UPDATE (msg_p).cells_to_activate[i].num_SI = gNB_CUSystemInformation->sibtypetobeupdatedlist.list.count; AssertFatal(ext->list.count==1,"At least one SI message should be there, and only 1 for now!\n"); LOG_D(F1AP, "F1AP: Cell %d MCC %d MNC %d NRCellid %lx num_si %d\n", i, F1AP_GNB_CU_CONFIGURATION_UPDATE (msg_p).cells_to_activate[i].mcc, F1AP_GNB_CU_CONFIGURATION_UPDATE (msg_p).cells_to_activate[i].mnc, F1AP_GNB_CU_CONFIGURATION_UPDATE (msg_p).cells_to_activate[i].nr_cellid, F1AP_GNB_CU_CONFIGURATION_UPDATE (msg_p).cells_to_activate[i].num_SI); - for (int si = 0;si < gNB_CUSystemInformation->sibtypetobeupdatedlist.list.count;si++) { + + for (int si = 0; si < gNB_CUSystemInformation->sibtypetobeupdatedlist.list.count; si++) { F1AP_SibtypetobeupdatedListItem_t *sib_item = gNB_CUSystemInformation->sibtypetobeupdatedlist.list.array[si]; size_t size = sib_item->sIBmessage.size; - F1AP_GNB_CU_CONFIGURATION_UPDATE (msg_p).cells_to_activate[i].SI_container_length[sib_item->sIBtype] = size; - LOG_I(F1AP, "F1AP: SI_container_length[%d][%d] %ld bytes\n", i, (int)sib_item->sIBtype, size); - F1AP_GNB_CU_CONFIGURATION_UPDATE (msg_p).cells_to_activate[i].SI_container[sib_item->sIBtype] = malloc(size); - memcpy((void*)F1AP_GNB_CU_CONFIGURATION_UPDATE (msg_p).cells_to_activate[i].SI_container[sib_item->sIBtype], - (void*)sib_item->sIBmessage.buf, - size); + F1AP_GNB_CU_CONFIGURATION_UPDATE (msg_p).cells_to_activate[i].SI_container_length[si] = size; + LOG_D(F1AP, "F1AP: SI_container_length[%d][%ld] %ld bytes\n", i, sib_item->sIBtype, size); + F1AP_GNB_CU_CONFIGURATION_UPDATE (msg_p).cells_to_activate[i].SI_container[si] = malloc(F1AP_GNB_CU_CONFIGURATION_UPDATE (msg_p).cells_to_activate[i].SI_container_length[si]); + memcpy((void *)F1AP_GNB_CU_CONFIGURATION_UPDATE (msg_p).cells_to_activate[i].SI_container[si], + (void *)sib_item->sIBmessage.buf, + size); + F1AP_GNB_CU_CONFIGURATION_UPDATE (msg_p).cells_to_activate[i].SI_type[si]=sib_item->sIBtype; } + break; } + case F1AP_ProtocolIE_ID_id_AvailablePLMNList: AssertFatal(1==0,"F1AP_ProtocolIE_ID_id_AvailablePLMNList not supported yet\n"); break; + case F1AP_ProtocolIE_ID_id_ExtendedAvailablePLMN_List: AssertFatal(1==0,"F1AP_ProtocolIE_ID_id_AvailablePLMNList not supported yet\n"); break; + case F1AP_ProtocolIE_ID_id_IAB_Info_IAB_donor_CU: AssertFatal(1==0,"F1AP_ProtocolIE_ID_id_AvailablePLMNList not supported yet\n"); break; + case F1AP_ProtocolIE_ID_id_AvailableSNPN_ID_List: AssertFatal(1==0,"F1AP_ProtocolIE_ID_id_AvailablePLMNList not supported yet\n"); break; + default: AssertFatal(1==0,"F1AP_ProtocolIE_ID_id %d unknown\n",(int)cells_to_be_activated_list_itemExtIEs->id); break; } } // for (cnt=... } // for (cells_to_activate... + break; } // case F1AP_ProtocolIE_ID_id_Cells_to_be_Activated_List @@ -1219,84 +906,61 @@ int DU_handle_gNB_CU_CONFIGURATION_UPDATE(instance_t instance, break; } // switch ie } // for IE + AssertFatal(TransactionId!=-1,"TransactionId was not sent\n"); LOG_D(F1AP,"F1AP: num_cells_to_activate %d\n",num_cells_to_activate); F1AP_GNB_CU_CONFIGURATION_UPDATE (msg_p).num_cells_to_activate = num_cells_to_activate; - MSC_LOG_RX_MESSAGE( - MSC_F1AP_DU, - MSC_F1AP_CU, - 0, - 0, - MSC_AS_TIME_FMT" DU_handle_GNB_CU_CONFIGURATION_UPDATE initiatingMessage assoc_id %d", - 0,0,//MSC_AS_TIME_ARGS(ctxt_pP), - assoc_id); - - if (RC.nrrrc && RC.nrrrc[0]->node_type == ngran_gNB_DU) { - LOG_D(F1AP, "Sending F1AP_GNB_CU_CONFIGURATION_UPDATE ITTI message to GNB_APP with assoc_id (%d->%d)\n", - assoc_id,ENB_MODULE_ID_TO_INSTANCE(assoc_id)); - itti_send_msg_to_task(TASK_GNB_APP, GNB_MODULE_ID_TO_INSTANCE(assoc_id), msg_p); - } else { - LOG_D(F1AP, "Sending F1AP_GNB_CU_CONFIGURATION_UPDATE ITTI message to ENB_APP with assoc_id (%d->%d)\n", - assoc_id,ENB_MODULE_ID_TO_INSTANCE(assoc_id)); - itti_send_msg_to_task(TASK_ENB_APP, ENB_MODULE_ID_TO_INSTANCE(assoc_id), msg_p); - } - + MSC_F1AP_DU, + MSC_F1AP_CU, + 0, + 0, + MSC_AS_TIME_FMT" DU_handle_GNB_CU_CONFIGURATION_UPDATE initiatingMessage assoc_id %d", + 0,0,//MSC_AS_TIME_ARGS(ctxt_pP), + assoc_id); + LOG_D(F1AP, "Sending F1AP_GNB_CU_CONFIGURATION_UPDATE ITTI message \n"); + itti_send_msg_to_task(TASK_F1APP, GNB_MODULE_ID_TO_INSTANCE(assoc_id), msg_p); return 0; } int DU_send_gNB_CU_CONFIGURATION_UPDATE_FAILURE(instance_t instance, - f1ap_gnb_cu_configuration_update_failure_t *GNBCUConfigurationUpdateFailure) { + f1ap_gnb_cu_configuration_update_failure_t *GNBCUConfigurationUpdateFailure) { AssertFatal(1==0,"received gNB CU CONFIGURATION UPDATE FAILURE with cause %d\n", - GNBCUConfigurationUpdateFailure->cause); + GNBCUConfigurationUpdateFailure->cause); } int DU_send_gNB_CU_CONFIGURATION_UPDATE_ACKNOWLEDGE(instance_t instance, - f1ap_gnb_cu_configuration_update_acknowledge_t *GNBCUConfigurationUpdateAcknowledge) { - - if(!RC.nrrrc) { - return 0; - } - + f1ap_gnb_cu_configuration_update_acknowledge_t *GNBCUConfigurationUpdateAcknowledge) { AssertFatal(GNBCUConfigurationUpdateAcknowledge->num_cells_failed_to_be_activated == 0, - "%d cells failed to activate\n", - GNBCUConfigurationUpdateAcknowledge->num_cells_failed_to_be_activated); - + "%d cells failed to activate\n", + GNBCUConfigurationUpdateAcknowledge->num_cells_failed_to_be_activated); AssertFatal(GNBCUConfigurationUpdateAcknowledge->noofTNLAssociations_to_setup == 0, - "%d TNLAssociations to setup, handle this ...\n", - GNBCUConfigurationUpdateAcknowledge->noofTNLAssociations_to_setup); - - + "%d TNLAssociations to setup, handle this ...\n", + GNBCUConfigurationUpdateAcknowledge->noofTNLAssociations_to_setup); AssertFatal(GNBCUConfigurationUpdateAcknowledge->noofTNLAssociations_failed == 0, - "%d TNLAssociations failed\n", - GNBCUConfigurationUpdateAcknowledge->noofTNLAssociations_failed); - + "%d TNLAssociations failed\n", + GNBCUConfigurationUpdateAcknowledge->noofTNLAssociations_failed); AssertFatal(GNBCUConfigurationUpdateAcknowledge->noofDedicatedSIDeliveryNeededUEs == 0, - "%d DedicatedSIDeliveryNeededUEs\n", - GNBCUConfigurationUpdateAcknowledge->noofDedicatedSIDeliveryNeededUEs); - - F1AP_F1AP_PDU_t pdu; - uint8_t *buffer; - uint32_t len; - + "%d DedicatedSIDeliveryNeededUEs\n", + GNBCUConfigurationUpdateAcknowledge->noofDedicatedSIDeliveryNeededUEs); + F1AP_F1AP_PDU_t pdu= {0}; + uint8_t *buffer=NULL; + uint32_t len=0; /* Create */ /* 0. pdu Type */ - memset(&pdu, 0, sizeof(pdu)); pdu.present = F1AP_F1AP_PDU_PR_successfulOutcome; - pdu.choice.successfulOutcome = (F1AP_SuccessfulOutcome_t *)calloc(1, sizeof(F1AP_SuccessfulOutcome_t)); - pdu.choice.successfulOutcome->procedureCode = F1AP_ProcedureCode_id_gNBCUConfigurationUpdate; - pdu.choice.successfulOutcome->criticality = F1AP_Criticality_reject; - pdu.choice.successfulOutcome->value.present = F1AP_SuccessfulOutcome__value_PR_GNBCUConfigurationUpdateAcknowledge; - F1AP_GNBCUConfigurationUpdateAcknowledge_t *out = &pdu.choice.successfulOutcome->value.choice.GNBCUConfigurationUpdateAcknowledge; - + asn1cCalloc(pdu.choice.successfulOutcome, tmp); + tmp->procedureCode = F1AP_ProcedureCode_id_gNBCUConfigurationUpdate; + tmp->criticality = F1AP_Criticality_reject; + tmp->value.present = F1AP_SuccessfulOutcome__value_PR_GNBCUConfigurationUpdateAcknowledge; + F1AP_GNBCUConfigurationUpdateAcknowledge_t *out = &tmp->value.choice.GNBCUConfigurationUpdateAcknowledge; /* mandatory */ /* c1. Transaction ID (integer value)*/ - F1AP_GNBCUConfigurationUpdateAcknowledgeIEs_t *ie = (F1AP_GNBCUConfigurationUpdateAcknowledgeIEs_t *)calloc(1, sizeof(F1AP_F1SetupResponseIEs_t)); + asn1cSequenceAdd(out->protocolIEs.list, F1AP_GNBCUConfigurationUpdateAcknowledgeIEs_t, ie); ie->id = F1AP_ProtocolIE_ID_id_TransactionID; ie->criticality = F1AP_Criticality_reject; ie->value.present = F1AP_GNBCUConfigurationUpdateAcknowledgeIEs__value_PR_TransactionID; ie->value.choice.TransactionID = F1AP_get_next_transaction_identifier(0, 0); - ASN_SEQUENCE_ADD(&out->protocolIEs.list, ie); /* encode */ if (f1ap_encode_pdu(&pdu, &buffer, &len) < 0) { @@ -1304,22 +968,20 @@ int DU_send_gNB_CU_CONFIGURATION_UPDATE_ACKNOWLEDGE(instance_t instance, return -1; } - du_f1ap_itti_send_sctp_data_req(instance, f1ap_du_data->assoc_id, buffer, len, 0); - - - + ASN_STRUCT_RESET(asn_DEF_F1AP_F1AP_PDU, &pdu); + f1ap_itti_send_sctp_data_req(false, instance, buffer, len, 0); return 0; } int DU_send_gNB_DU_RESOURCE_COORDINATION_REQUEST(instance_t instance, - F1AP_GNBDUResourceCoordinationRequest_t *GNBDUResourceCoordinationRequest) { + F1AP_GNBDUResourceCoordinationRequest_t *GNBDUResourceCoordinationRequest) { AssertFatal(0, "Not implemented yet\n"); } int DU_handle_gNB_DU_RESOURCE_COORDINATION_RESPONSE(instance_t instance, - uint32_t assoc_id, - uint32_t stream, - F1AP_F1AP_PDU_t *pdu) { + uint32_t assoc_id, + uint32_t stream, + F1AP_F1AP_PDU_t *pdu) { AssertFatal(0, "Not implemented yet\n"); } diff --git a/openair2/F1AP/f1ap_du_interface_management.h b/openair2/F1AP/f1ap_du_interface_management.h index 619b725f38832478d4260d89ff9d4b844875a6fb..83cd69cf6c0b6c05a72692fb1f943d417a2fc79d 100644 --- a/openair2/F1AP/f1ap_du_interface_management.h +++ b/openair2/F1AP/f1ap_du_interface_management.h @@ -76,43 +76,44 @@ int DU_handle_F1_SETUP_FAILURE(instance_t instance, * gNB-DU Configuration Update */ int DU_send_gNB_DU_CONFIGURATION_UPDATE(instance_t instance, - instance_t du_mod_idP, - f1ap_setup_req_t *f1ap_du_data); + instance_t du_mod_idP, + f1ap_setup_req_t *f1ap_du_data); int DU_handle_gNB_DU_CONFIGURATION_FAILURE(instance_t instance, - uint32_t assoc_id, - uint32_t stream, - F1AP_F1AP_PDU_t *pdu); + uint32_t assoc_id, + uint32_t stream, + F1AP_F1AP_PDU_t *pdu); int DU_handle_gNB_DU_CONFIGURATION_UPDATE_ACKNOWLEDGE(instance_t instance, - uint32_t assoc_id, - uint32_t stream, - F1AP_F1AP_PDU_t *pdu); + uint32_t assoc_id, + uint32_t stream, + F1AP_F1AP_PDU_t *pdu); /* * gNB-CU Configuration Update */ int DU_handle_gNB_CU_CONFIGURATION_UPDATE(instance_t instance, - uint32_t assoc_id, - uint32_t stream, - F1AP_F1AP_PDU_t *pdu); + uint32_t assoc_id, + uint32_t stream, + F1AP_F1AP_PDU_t *pdu); int DU_send_gNB_CU_CONFIGURATION_UPDATE_FAILURE(instance_t instance, - f1ap_gnb_cu_configuration_update_failure_t *GNBCUConfigurationUpdateFailure); + f1ap_gnb_cu_configuration_update_failure_t *GNBCUConfigurationUpdateFailure); int DU_send_gNB_CU_CONFIGURATION_UPDATE_ACKNOWLEDGE(instance_t instance, - f1ap_gnb_cu_configuration_update_acknowledge_t *GNBCUConfigurationUpdateAcknowledge); + f1ap_gnb_cu_configuration_update_acknowledge_t *GNBCUConfigurationUpdateAcknowledge); + /* * gNB-DU Resource Coordination */ int DU_send_gNB_DU_RESOURCE_COORDINATION_REQUEST(instance_t instance, - F1AP_GNBDUResourceCoordinationRequest_t *GNBDUResourceCoordinationRequest); + F1AP_GNBDUResourceCoordinationRequest_t *GNBDUResourceCoordinationRequest); int DU_handle_gNB_DU_RESOURCE_COORDINATION_RESPONSE(instance_t instance, - uint32_t assoc_id, - uint32_t stream, - F1AP_F1AP_PDU_t *pdu); + uint32_t assoc_id, + uint32_t stream, + F1AP_F1AP_PDU_t *pdu); #endif /* F1AP_DU_INTERFACE_MANAGEMENT_H_ */ diff --git a/openair2/F1AP/f1ap_du_rrc_message_transfer.c b/openair2/F1AP/f1ap_du_rrc_message_transfer.c index 0c8f566fd669fc2e30a189b352cf5e7bc7c8230c..90ea324a2821479682a1bedd3aa5b2e1665f43f4 100644 --- a/openair2/F1AP/f1ap_du_rrc_message_transfer.c +++ b/openair2/F1AP/f1ap_du_rrc_message_transfer.c @@ -56,76 +56,55 @@ #include "intertask_interface.h" #include "LAYER2/NR_MAC_gNB/mac_proto.h" -extern f1ap_setup_req_t *f1ap_du_data; -extern RAN_CONTEXT_t RC; -extern f1ap_cudu_inst_t f1ap_du_inst[MAX_eNB]; - -extern rlc_op_status_t nr_rrc_rlc_config_asn1_req (const protocol_ctxt_t * const ctxt_pP, - const NR_SRB_ToAddModList_t * const srb2add_listP, - const NR_DRB_ToAddModList_t * const drb2add_listP, - const NR_DRB_ToReleaseList_t * const drb2release_listP, - const LTE_PMCH_InfoList_r9_t * const pmch_InfoList_r9_pP, - struct NR_CellGroupConfig__rlc_BearerToAddModList *rlc_srb_bearer2add_list, - struct NR_CellGroupConfig__rlc_BearerToAddModList *rlc_drb_bearer2add_list); - -uint8_t du_ccch_flag = 1; int DU_handle_DL_NR_RRC_MESSAGE_TRANSFER(instance_t instance, - uint32_t assoc_id, - uint32_t stream, - F1AP_F1AP_PDU_t *pdu); + uint32_t assoc_id, + uint32_t stream, + F1AP_F1AP_PDU_t *pdu); /* DL RRC Message Transfer */ int DU_handle_DL_RRC_MESSAGE_TRANSFER(instance_t instance, uint32_t assoc_id, uint32_t stream, F1AP_F1AP_PDU_t *pdu) { - if (RC.nrrrc && RC.nrrrc[instance]->node_type == ngran_gNB_DU) { LOG_I(F1AP, "node is gNB DU, call DU_handle_DL_NR_RRC_MESSAGE_TRANSFER \n"); return DU_handle_DL_NR_RRC_MESSAGE_TRANSFER(instance, assoc_id, stream, pdu); } - LOG_D(F1AP, "DU_handle_DL_RRC_MESSAGE_TRANSFER \n"); - + LOG_W(F1AP, "DU_handle_DL_RRC_MESSAGE_TRANSFER is a big race condition with rrc \n"); F1AP_DLRRCMessageTransfer_t *container; F1AP_DLRRCMessageTransferIEs_t *ie; - uint64_t cu_ue_f1ap_id; uint64_t du_ue_f1ap_id; - uint64_t srb_id; int executeDuplication; sdu_size_t rrc_dl_sdu_len; //uint64_t subscriberProfileIDforRFP; //uint64_t rAT_FrequencySelectionPriority; - DevAssert(pdu != NULL); if (stream != 0) { LOG_E(F1AP, "[SCTP %d] Received F1 on stream != 0 (%d)\n", - assoc_id, stream); + assoc_id, stream); return -1; } container = &pdu->choice.initiatingMessage->value.choice.DLRRCMessageTransfer; - - /* GNB_CU_UE_F1AP_ID */ F1AP_FIND_PROTOCOLIE_BY_ID(F1AP_DLRRCMessageTransferIEs_t, ie, container, F1AP_ProtocolIE_ID_id_gNB_CU_UE_F1AP_ID, true); cu_ue_f1ap_id = ie->value.choice.GNB_CU_UE_F1AP_ID; LOG_D(F1AP, "cu_ue_f1ap_id %lu \n", cu_ue_f1ap_id); - - /* GNB_DU_UE_F1AP_ID */ F1AP_FIND_PROTOCOLIE_BY_ID(F1AP_DLRRCMessageTransferIEs_t, ie, container, F1AP_ProtocolIE_ID_id_gNB_DU_UE_F1AP_ID, true); du_ue_f1ap_id = ie->value.choice.GNB_DU_UE_F1AP_ID; LOG_D(F1AP, "du_ue_f1ap_id %lu associated with UE RNTI %x \n", du_ue_f1ap_id, - f1ap_get_rnti_by_du_id(&f1ap_du_inst[instance], du_ue_f1ap_id)); // this should be the one transmitted via initial ul rrc message transfer + f1ap_get_rnti_by_du_id(DUtype, instance, du_ue_f1ap_id)); + // this should be the one transmitted via initial ul rrc message transfer - if (f1ap_du_add_cu_ue_id(&f1ap_du_inst[instance],du_ue_f1ap_id, cu_ue_f1ap_id) < 0 ) { + if (f1ap_du_add_cu_ue_id(instance,du_ue_f1ap_id, cu_ue_f1ap_id) < 0 ) { LOG_E(F1AP, "Failed to find the F1AP UID \n"); //return -1; } @@ -134,21 +113,21 @@ int DU_handle_DL_RRC_MESSAGE_TRANSFER(instance_t instance, /* oldgNB_DU_UE_F1AP_ID */ if (0) { F1AP_FIND_PROTOCOLIE_BY_ID(F1AP_DLRRCMessageTransferIEs_t, ie, container, - F1AP_ProtocolIE_ID_id_oldgNB_DU_UE_F1AP_ID, true); + F1AP_ProtocolIE_ID_id_oldgNB_DU_UE_F1AP_ID, true); } /* mandatory */ /* SRBID */ F1AP_FIND_PROTOCOLIE_BY_ID(F1AP_DLRRCMessageTransferIEs_t, ie, container, F1AP_ProtocolIE_ID_id_SRBID, true); - srb_id = ie->value.choice.SRBID; + uint64_t srb_id = ie->value.choice.SRBID; LOG_D(F1AP, "srb_id %lu \n", srb_id); /* optional */ /* ExecuteDuplication */ if (0) { F1AP_FIND_PROTOCOLIE_BY_ID(F1AP_DLRRCMessageTransferIEs_t, ie, container, - F1AP_ProtocolIE_ID_id_ExecuteDuplication, true); + F1AP_ProtocolIE_ID_id_ExecuteDuplication, true); executeDuplication = ie->value.choice.ExecuteDuplication; LOG_D(F1AP, "ExecuteDuplication %d \n", executeDuplication); } @@ -158,33 +137,23 @@ int DU_handle_DL_RRC_MESSAGE_TRANSFER(instance_t instance, /* RRC Container */ F1AP_FIND_PROTOCOLIE_BY_ID(F1AP_DLRRCMessageTransferIEs_t, ie, container, F1AP_ProtocolIE_ID_id_RRCContainer, true); - // BK: need check - // create an ITTI message and copy SDU - - // message_p = itti_alloc_new_message (TASK_CU_F1, 0, RRC_MAC_CCCH_DATA_IND); - // memset (RRC_MAC_CCCH_DATA_IND (message_p).sdu, 0, CCCH_SDU_SIZE); rrc_dl_sdu_len = ie->value.choice.RRCContainer.size; - // memcpy(RRC_MAC_CCCH_DATA_IND (message_p).sdu, ie->value.choice.RRCContainer.buf, - // ccch_sdu_len); - - //LOG_I(F1AP, "%s() RRCContainer size %lu: ", __func__, ie->value.choice.RRCContainer.size); - //for (int i = 0;i < ie->value.choice.RRCContainer.size; i++) - // printf("%02x ", ie->value.choice.RRCContainer.buf[i]); - //printf("\n"); /* optional */ /* RAT_FrequencyPriorityInformation */ if (0) { F1AP_FIND_PROTOCOLIE_BY_ID(F1AP_DLRRCMessageTransferIEs_t, ie, container, - F1AP_ProtocolIE_ID_id_RAT_FrequencyPriorityInformation, true); + F1AP_ProtocolIE_ID_id_RAT_FrequencyPriorityInformation, true); switch(ie->value.choice.RAT_FrequencyPriorityInformation.present) { case F1AP_RAT_FrequencyPriorityInformation_PR_eNDC: //subscriberProfileIDforRFP = ie->value.choice.RAT_FrequencyPriorityInformation.choice.subscriberProfileIDforRFP; break; + case F1AP_RAT_FrequencyPriorityInformation_PR_nGRAN: //rAT_FrequencySelectionPriority = ie->value.choice.RAT_FrequencyPriorityInformation.choice.rAT_FrequencySelectionPriority; break; + default: LOG_W(F1AP, "unhandled IE RAT_FrequencyPriorityInformation.present\n"); break; @@ -193,28 +162,26 @@ int DU_handle_DL_RRC_MESSAGE_TRANSFER(instance_t instance, // decode RRC Container and act on the message type AssertFatal(srb_id<3,"illegal srb_id\n"); - protocol_ctxt_t ctxt; - ctxt.rnti = f1ap_get_rnti_by_du_id(&f1ap_du_inst[instance], du_ue_f1ap_id); + ctxt.rnti = f1ap_get_rnti_by_du_id(DUtype, instance, du_ue_f1ap_id); + ctxt.instance = instance; ctxt.module_id = instance; - ctxt.instance = instance; ctxt.enb_flag = 1; - - struct rrc_eNB_ue_context_s* ue_context_p = rrc_eNB_get_ue_context( - RC.rrc[ctxt.module_id], - ctxt.rnti); + struct rrc_eNB_ue_context_s *ue_context_p = rrc_eNB_get_ue_context( + RC.rrc[ctxt.instance], + ctxt.rnti); if (srb_id == 0) { - LTE_DL_CCCH_Message_t* dl_ccch_msg=NULL; + LTE_DL_CCCH_Message_t *dl_ccch_msg=NULL; asn_dec_rval_t dec_rval; dec_rval = uper_decode(NULL, - &asn_DEF_LTE_DL_CCCH_Message, - (void**)&dl_ccch_msg, - ie->value.choice.RRCContainer.buf, - rrc_dl_sdu_len,0,0); + &asn_DEF_LTE_DL_CCCH_Message, + (void **)&dl_ccch_msg, + ie->value.choice.RRCContainer.buf, + rrc_dl_sdu_len,0,0); AssertFatal(dec_rval.code == RC_OK, "could not decode F1AP message\n"); - switch (dl_ccch_msg->message.choice.c1.present) { + switch (dl_ccch_msg->message.choice.c1.present) { case LTE_DL_CCCH_MessageType__c1_PR_NOTHING: LOG_I(F1AP, "Received PR_NOTHING on DL-CCCH-Message\n"); break; @@ -234,32 +201,27 @@ int DU_handle_DL_RRC_MESSAGE_TRANSFER(instance_t instance, "Logical Channel DL-CCCH (SRB0), Received RRCConnectionReject \n"); break; - case LTE_DL_CCCH_MessageType__c1_PR_rrcConnectionSetup: - { + case LTE_DL_CCCH_MessageType__c1_PR_rrcConnectionSetup: { LOG_I(F1AP, "Logical Channel DL-CCCH (SRB0), Received RRCConnectionSetup DU_ID %lx/RNTI %x\n", du_ue_f1ap_id, - f1ap_get_rnti_by_du_id(&f1ap_du_inst[instance], du_ue_f1ap_id)); - // Get configuration - - LTE_RRCConnectionSetup_t* rrcConnectionSetup = &dl_ccch_msg->message.choice.c1.choice.rrcConnectionSetup; + f1ap_get_rnti_by_du_id(DUtype, instance, du_ue_f1ap_id)); + // Get configuration + LTE_RRCConnectionSetup_t *rrcConnectionSetup = &dl_ccch_msg->message.choice.c1.choice.rrcConnectionSetup; AssertFatal(rrcConnectionSetup!=NULL,"rrcConnectionSetup is null\n"); - LTE_RadioResourceConfigDedicated_t* radioResourceConfigDedicated = &rrcConnectionSetup->criticalExtensions.choice.c1.choice.rrcConnectionSetup_r8.radioResourceConfigDedicated; - + LTE_RadioResourceConfigDedicated_t *radioResourceConfigDedicated = &rrcConnectionSetup->criticalExtensions.choice.c1.choice.rrcConnectionSetup_r8.radioResourceConfigDedicated; // get SRB logical channel information - LTE_SRB_ToAddModList_t *SRB_configList; - LTE_SRB_ToAddMod_t *SRB1_config; + LTE_SRB_ToAddModList_t *SRB_configList = radioResourceConfigDedicated->srb_ToAddModList; + AssertFatal(SRB_configList!=NULL,"SRB_configList is null\n"); LTE_LogicalChannelConfig_t *SRB1_logicalChannelConfig = NULL; - SRB_configList = radioResourceConfigDedicated->srb_ToAddModList; - AssertFatal(SRB_configList!=NULL,"SRB_configList is null\n"); for (int cnt = 0; cnt < (SRB_configList)->list.count; cnt++) { if ((SRB_configList)->list.array[cnt]->srb_Identity == 1) { - SRB1_config = (SRB_configList)->list.array[cnt]; + LTE_SRB_ToAddMod_t * SRB1_config = (SRB_configList)->list.array[cnt]; if (SRB1_config->logicalChannelConfig) { if (SRB1_config->logicalChannelConfig->present == - LTE_SRB_ToAddMod__logicalChannelConfig_PR_explicitValue) { + LTE_SRB_ToAddMod__logicalChannelConfig_PR_explicitValue) { SRB1_logicalChannelConfig = &SRB1_config->logicalChannelConfig->choice.explicitValue; } else { SRB1_logicalChannelConfig = &SRB1_logicalChannelConfig_defaultValue; @@ -269,35 +231,33 @@ int DU_handle_DL_RRC_MESSAGE_TRANSFER(instance_t instance, } } } // for + rrc_rlc_config_asn1_req(&ctxt, - SRB_configList, - (LTE_DRB_ToAddModList_t*) NULL, - (LTE_DRB_ToReleaseList_t*) NULL - , (LTE_PMCH_InfoList_r9_t *) NULL, - 0,0 - ); - - // This should be somewhere in the f1ap_cudu_ue_inst_t - /*int macrlc_instance = 0; - - rnti_t rnti = f1ap_get_rnti_by_du_id(&f1ap_du_inst[0], du_ue_f1ap_id); - struct rrc_eNB_ue_context_s *ue_context_p = rrc_eNB_get_ue_context(RC.rrc[macrlc_instance],rnti); - */ - eNB_RRC_UE_t *ue_p = &ue_context_p->ue_context; - AssertFatal(ue_p->Srb0.Active == 1,"SRB0 is not active\n"); - - memcpy((void*)ue_p->Srb0.Tx_buffer.Payload, - (void*)ie->value.choice.RRCContainer.buf, - rrc_dl_sdu_len); // ie->value.choice.RRCContainer.size - - ue_p->Srb0.Tx_buffer.payload_size = rrc_dl_sdu_len; - - LTE_MAC_MainConfig_t *mac_MainConfig = NULL; - if (radioResourceConfigDedicated->mac_MainConfig) - mac_MainConfig = &radioResourceConfigDedicated->mac_MainConfig->choice.explicitValue; - - rrc_mac_config_req_eNB( - ctxt.module_id, + SRB_configList, + (LTE_DRB_ToAddModList_t *) NULL, + (LTE_DRB_ToReleaseList_t *) NULL + , (LTE_PMCH_InfoList_r9_t *) NULL, + 0,0 + ); + // This should be somewhere in the f1ap_cudu_ue_inst_t + /*int macrlc_instance = 0; + + rnti_t rnti = f1ap_get_rnti_by_du_id(DUtype, instance, du_ue_f1ap_id); + struct rrc_eNB_ue_context_s *ue_context_p = rrc_eNB_get_ue_context(RC.rrc[macrlc_instance],rnti); + */ + eNB_RRC_UE_t *ue_p = &ue_context_p->ue_context; + AssertFatal(ue_p->Srb0.Active == 1,"SRB0 is not active\n"); + memcpy((void *)ue_p->Srb0.Tx_buffer.Payload, + (void *)ie->value.choice.RRCContainer.buf, + rrc_dl_sdu_len); // ie->value.choice.RRCContainer.size + ue_p->Srb0.Tx_buffer.payload_size = rrc_dl_sdu_len; + LTE_MAC_MainConfig_t *mac_MainConfig = NULL; + + if (radioResourceConfigDedicated->mac_MainConfig) + mac_MainConfig = &radioResourceConfigDedicated->mac_MainConfig->choice.explicitValue; + + rrc_mac_config_req_eNB( + ctxt.instance, 0, //primaryCC_id, 0,0,0,0,0,0, ctxt.rnti, @@ -318,234 +278,239 @@ int DU_handle_DL_RRC_MESSAGE_TRANSFER(instance_t instance, 0, NULL, NULL, (LTE_MBSFN_SubframeConfigList_t *) NULL , 0, (LTE_MBSFN_AreaInfoList_r9_t *) NULL, (LTE_PMCH_InfoList_r9_t *) NULL, (LTE_SystemInformationBlockType1_v1310_IEs_t *)NULL - , - 0, - (LTE_BCCH_DL_SCH_Message_MBMS_t *) NULL, - (LTE_SchedulingInfo_MBMS_r14_t *) NULL, - (struct LTE_NonMBSFN_SubframeConfig_r14 *) NULL, - (LTE_SystemInformationBlockType1_MBMS_r14_t *) NULL, - (LTE_MBSFN_AreaInfoList_r9_t *) NULL, - (LTE_MBSFNAreaConfiguration_r9_t*) NULL - ); - break; + , + 0, + (LTE_BCCH_DL_SCH_Message_MBMS_t *) NULL, + (LTE_SchedulingInfo_MBMS_r14_t *) NULL, + (struct LTE_NonMBSFN_SubframeConfig_r14 *) NULL, + (LTE_SystemInformationBlockType1_MBMS_r14_t *) NULL, + (LTE_MBSFN_AreaInfoList_r9_t *) NULL, + (LTE_MBSFNAreaConfiguration_r9_t *) NULL + ); + break; } // case default: AssertFatal(1==0, - "Unknown message\n"); + "Unknown message\n"); break; }// switch case - return(0); - } else if (srb_id == 1) { - LTE_DL_DCCH_Message_t* dl_dcch_msg=NULL; + return(0); + } else if (srb_id == 1) { + LTE_DL_DCCH_Message_t *dl_dcch_msg=NULL; asn_dec_rval_t dec_rval; dec_rval = uper_decode(NULL, - &asn_DEF_LTE_DL_DCCH_Message, - (void**)&dl_dcch_msg, - &ie->value.choice.RRCContainer.buf[1], // buf[0] includes the pdcp header - rrc_dl_sdu_len,0,0); - - if ((dec_rval.code != RC_OK) && (dec_rval.consumed == 0)) + &asn_DEF_LTE_DL_DCCH_Message, + (void **)&dl_dcch_msg, + &ie->value.choice.RRCContainer.buf[1], // buf[0] includes the pdcp header + rrc_dl_sdu_len,0,0); + + if ((dec_rval.code != RC_OK) && (dec_rval.consumed == 0)) LOG_E(F1AP," Failed to decode DL-DCCH (%zu bytes)\n",dec_rval.consumed); else LOG_D(F1AP, "Received message: present %d and c1 present %d\n", dl_dcch_msg->message.present, dl_dcch_msg->message.choice.c1.present); if (dl_dcch_msg->message.present == LTE_DL_DCCH_MessageType_PR_c1) { - switch (dl_dcch_msg->message.choice.c1.present) { - - case LTE_DL_DCCH_MessageType__c1_PR_NOTHING: - LOG_I(F1AP, "Received PR_NOTHING on DL-DCCH-Message\n"); - return 0; - case LTE_DL_DCCH_MessageType__c1_PR_dlInformationTransfer: - LOG_I(F1AP,"Received NAS DL Information Transfer\n"); - break; - case LTE_DL_DCCH_MessageType__c1_PR_csfbParametersResponseCDMA2000: - LOG_I(F1AP,"Received NAS sfbParametersResponseCDMA2000\n"); - break; - case LTE_DL_DCCH_MessageType__c1_PR_handoverFromEUTRAPreparationRequest: - LOG_I(F1AP,"Received NAS andoverFromEUTRAPreparationRequest\n"); - break; - case LTE_DL_DCCH_MessageType__c1_PR_mobilityFromEUTRACommand: - LOG_I(F1AP,"Received NAS mobilityFromEUTRACommand\n"); - break; - case LTE_DL_DCCH_MessageType__c1_PR_rrcConnectionReconfiguration: - // handle RRCConnectionReconfiguration - LOG_I(F1AP, - "Logical Channel DL-DCCH (SRB1), Received RRCConnectionReconfiguration DU_ID %lx/RNTI %x\n", - du_ue_f1ap_id, - f1ap_get_rnti_by_du_id(&f1ap_du_inst[instance], du_ue_f1ap_id)); - - LTE_RRCConnectionReconfiguration_t* rrcConnectionReconfiguration = &dl_dcch_msg->message.choice.c1.choice.rrcConnectionReconfiguration; - - if (rrcConnectionReconfiguration->criticalExtensions.present == LTE_RRCConnectionReconfiguration__criticalExtensions_PR_c1) { - if (rrcConnectionReconfiguration->criticalExtensions.choice.c1.present == - LTE_RRCConnectionReconfiguration__criticalExtensions__c1_PR_rrcConnectionReconfiguration_r8) { - LTE_RRCConnectionReconfiguration_r8_IEs_t* rrcConnectionReconfiguration_r8 = - &rrcConnectionReconfiguration->criticalExtensions.choice.c1.choice.rrcConnectionReconfiguration_r8; - - if (rrcConnectionReconfiguration_r8->mobilityControlInfo) { - LOG_I(F1AP, "Mobility Control Information is present\n"); - AssertFatal(1==0,"Can't handle this yet in DU\n"); - } - if (rrcConnectionReconfiguration_r8->measConfig != NULL) { - LOG_I(F1AP, "Measurement Configuration is present\n"); - } - - if (rrcConnectionReconfiguration_r8->radioResourceConfigDedicated) { - LOG_I(F1AP, "Radio Resource Configuration is present\n"); - uint8_t DRB2LCHAN[8]; - long drb_id; - int i; - LTE_DRB_ToAddModList_t *DRB_configList = rrcConnectionReconfiguration_r8->radioResourceConfigDedicated->drb_ToAddModList; - LTE_SRB_ToAddModList_t *SRB_configList = rrcConnectionReconfiguration_r8->radioResourceConfigDedicated->srb_ToAddModList; - LTE_DRB_ToReleaseList_t *DRB_ReleaseList = rrcConnectionReconfiguration_r8->radioResourceConfigDedicated->drb_ToReleaseList; - LTE_MAC_MainConfig_t *mac_MainConfig = NULL; - - for (i = 0; i< 8; i++){ - DRB2LCHAN[i] = 0; + case LTE_DL_DCCH_MessageType__c1_PR_NOTHING: + LOG_I(F1AP, "Received PR_NOTHING on DL-DCCH-Message\n"); + return 0; + + case LTE_DL_DCCH_MessageType__c1_PR_dlInformationTransfer: + LOG_I(F1AP,"Received NAS DL Information Transfer\n"); + break; + + case LTE_DL_DCCH_MessageType__c1_PR_csfbParametersResponseCDMA2000: + LOG_I(F1AP,"Received NAS sfbParametersResponseCDMA2000\n"); + break; + + case LTE_DL_DCCH_MessageType__c1_PR_handoverFromEUTRAPreparationRequest: + LOG_I(F1AP,"Received NAS andoverFromEUTRAPreparationRequest\n"); + break; + + case LTE_DL_DCCH_MessageType__c1_PR_mobilityFromEUTRACommand: + LOG_I(F1AP,"Received NAS mobilityFromEUTRACommand\n"); + break; + + case LTE_DL_DCCH_MessageType__c1_PR_rrcConnectionReconfiguration: + // handle RRCConnectionReconfiguration + LOG_I(F1AP, + "Logical Channel DL-DCCH (SRB1), Received RRCConnectionReconfiguration DU_ID %lx/RNTI %x\n", + du_ue_f1ap_id, + f1ap_get_rnti_by_du_id(DUtype, instance, du_ue_f1ap_id)); + LTE_RRCConnectionReconfiguration_t *rrcConnectionReconfiguration = &dl_dcch_msg->message.choice.c1.choice.rrcConnectionReconfiguration; + + if (rrcConnectionReconfiguration->criticalExtensions.present == LTE_RRCConnectionReconfiguration__criticalExtensions_PR_c1) { + if (rrcConnectionReconfiguration->criticalExtensions.choice.c1.present == + LTE_RRCConnectionReconfiguration__criticalExtensions__c1_PR_rrcConnectionReconfiguration_r8) { + LTE_RRCConnectionReconfiguration_r8_IEs_t *rrcConnectionReconfiguration_r8 = + &rrcConnectionReconfiguration->criticalExtensions.choice.c1.choice.rrcConnectionReconfiguration_r8; + + if (rrcConnectionReconfiguration_r8->mobilityControlInfo) { + LOG_I(F1AP, "Mobility Control Information is present\n"); + AssertFatal(1==0,"Can't handle this yet in DU\n"); } - if (rrcConnectionReconfiguration_r8->radioResourceConfigDedicated->mac_MainConfig) { - LOG_D(F1AP, "MAC Main Configuration is present\n"); + if (rrcConnectionReconfiguration_r8->measConfig != NULL) { + LOG_I(F1AP, "Measurement Configuration is present\n"); + } - mac_MainConfig = &rrcConnectionReconfiguration_r8->radioResourceConfigDedicated->mac_MainConfig->choice.explicitValue; + if (rrcConnectionReconfiguration_r8->radioResourceConfigDedicated) { + LOG_I(F1AP, "Radio Resource Configuration is present\n"); + uint8_t DRB2LCHAN[8]; + long drb_id; + int i; + LTE_DRB_ToAddModList_t *DRB_configList = rrcConnectionReconfiguration_r8->radioResourceConfigDedicated->drb_ToAddModList; + LTE_SRB_ToAddModList_t *SRB_configList = rrcConnectionReconfiguration_r8->radioResourceConfigDedicated->srb_ToAddModList; + LTE_DRB_ToReleaseList_t *DRB_ReleaseList = rrcConnectionReconfiguration_r8->radioResourceConfigDedicated->drb_ToReleaseList; + LTE_MAC_MainConfig_t *mac_MainConfig = NULL; - /* CDRX Configuration */ - if (mac_MainConfig->drx_Config == NULL) { - LOG_W(F1AP, "drx_Configuration parameter is NULL, cannot configure local UE parameters or CDRX is deactivated\n"); - } else { - MessageDef *message_p = NULL; + for (i = 0; i< 8; i++) { + DRB2LCHAN[i] = 0; + } + + if (rrcConnectionReconfiguration_r8->radioResourceConfigDedicated->mac_MainConfig) { + LOG_D(F1AP, "MAC Main Configuration is present\n"); + mac_MainConfig = &rrcConnectionReconfiguration_r8->radioResourceConfigDedicated->mac_MainConfig->choice.explicitValue; - /* Send DRX configuration to MAC task to configure timers of local UE context */ - message_p = itti_alloc_new_message(TASK_DU_F1, 0, RRC_MAC_DRX_CONFIG_REQ); - RRC_MAC_DRX_CONFIG_REQ(message_p).rnti = ctxt.rnti; - RRC_MAC_DRX_CONFIG_REQ(message_p).drx_Configuration = mac_MainConfig->drx_Config; - itti_send_msg_to_task(TASK_MAC_ENB, ctxt.module_id, message_p); - LOG_D(F1AP, "DRX configured in MAC Main Configuration for RRC Connection Reconfiguration\n"); + /* CDRX Configuration */ + if (mac_MainConfig->drx_Config == NULL) { + LOG_W(F1AP, "drx_Configuration parameter is NULL, cannot configure local UE parameters or CDRX is deactivated\n"); + } else { + MessageDef *message_p = NULL; + /* Send DRX configuration to MAC task to configure timers of local UE context */ + message_p = itti_alloc_new_message(TASK_DU_F1, 0, RRC_MAC_DRX_CONFIG_REQ); + RRC_MAC_DRX_CONFIG_REQ(message_p).rnti = ctxt.rnti; + RRC_MAC_DRX_CONFIG_REQ(message_p).drx_Configuration = mac_MainConfig->drx_Config; + itti_send_msg_to_task(TASK_MAC_ENB, ctxt.instance, message_p); + LOG_D(F1AP, "DRX configured in MAC Main Configuration for RRC Connection Reconfiguration\n"); + } + + /* End of CDRX configuration */ } - /* End of CDRX configuration */ - } - LTE_MeasGapConfig_t *measGapConfig = NULL; - struct LTE_PhysicalConfigDedicated* physicalConfigDedicated = rrcConnectionReconfiguration_r8->radioResourceConfigDedicated->physicalConfigDedicated; - rrc_rlc_config_asn1_req( - &ctxt, - SRB_configList, // NULL, //LG-RK 14/05/2014 SRB_configList, - DRB_configList, - DRB_ReleaseList, (LTE_PMCH_InfoList_r9_t *) NULL, 0, 0 + LTE_MeasGapConfig_t *measGapConfig = NULL; + struct LTE_PhysicalConfigDedicated *physicalConfigDedicated = rrcConnectionReconfiguration_r8->radioResourceConfigDedicated->physicalConfigDedicated; + rrc_rlc_config_asn1_req( + &ctxt, + SRB_configList, // NULL, //LG-RK 14/05/2014 SRB_configList, + DRB_configList, + DRB_ReleaseList, (LTE_PMCH_InfoList_r9_t *) NULL, 0, 0 ); - if (SRB_configList != NULL) { - for (i = 0; (i < SRB_configList->list.count) && (i < 3); i++) { - if (SRB_configList->list.array[i]->srb_Identity == 1 ){ - ue_context_p->ue_context.Srb1.Active=1; + if (SRB_configList != NULL) { + for (i = 0; (i < SRB_configList->list.count) && (i < 3); i++) { + if (SRB_configList->list.array[i]->srb_Identity == 1 ) { + ue_context_p->ue_context.Srb1.Active=1; + } else if (SRB_configList->list.array[i]->srb_Identity == 2 ) { + ue_context_p->ue_context.Srb2.Active=1; + ue_context_p->ue_context.Srb2.Srb_info.Srb_id=2; + LOG_I(F1AP, "[DU %ld] SRB2 is now active\n",ctxt.instance); + } else { + LOG_W(F1AP, "[DU %ld] invalid SRB identity %ld\n",ctxt.instance, + SRB_configList->list.array[i]->srb_Identity); + } } - else if (SRB_configList->list.array[i]->srb_Identity == 2 ) { - ue_context_p->ue_context.Srb2.Active=1; - ue_context_p->ue_context.Srb2.Srb_info.Srb_id=2; - LOG_I(F1AP, "[DU %d] SRB2 is now active\n",ctxt.module_id); - } else { - LOG_W(F1AP, "[DU %d] invalide SRB identity %ld\n",ctxt.module_id, - SRB_configList->list.array[i]->srb_Identity); + } + + if (DRB_configList != NULL) { + for (i = 0; i < DRB_configList->list.count; i++) { // num max DRB (11-3-8) + if (DRB_configList->list.array[i]) { + drb_id = (int)DRB_configList->list.array[i]->drb_Identity; + LOG_I(F1AP, + "[DU %ld] Logical Channel UL-DCCH, Received RRCConnectionReconfiguration for UE rnti %x, reconfiguring DRB %d/LCID %d\n", + ctxt.instance, + ctxt.rnti, + (int)DRB_configList->list.array[i]->drb_Identity, + (int)*DRB_configList->list.array[i]->logicalChannelIdentity); + + if (ue_context_p->ue_context.DRB_active[drb_id] == 0) { + ue_context_p->ue_context.DRB_active[drb_id] = 1; + + if (DRB_configList->list.array[i]->logicalChannelIdentity) { + DRB2LCHAN[i] = (uint8_t) * DRB_configList->list.array[i]->logicalChannelIdentity; + } + + rrc_mac_config_req_eNB( + ctxt.instance, + 0,0,0,0,0,0, + 0, + ue_context_p->ue_context.rnti, + (LTE_BCCH_BCH_Message_t *) NULL, + (LTE_RadioResourceConfigCommonSIB_t *) NULL, + (LTE_RadioResourceConfigCommonSIB_t *) NULL, + physicalConfigDedicated, + (LTE_SCellToAddMod_r10_t *)NULL, + //(struct PhysicalConfigDedicatedSCell_r10 *)NULL, + (LTE_MeasObjectToAddMod_t **) NULL, + mac_MainConfig, + DRB2LCHAN[i], + DRB_configList->list.array[i]->logicalChannelConfig, + measGapConfig, + (LTE_TDD_Config_t *) NULL, + NULL, + (LTE_SchedulingInfoList_t *) NULL, + 0, NULL, NULL, (LTE_MBSFN_SubframeConfigList_t *) NULL + , 0, (LTE_MBSFN_AreaInfoList_r9_t *) NULL, (LTE_PMCH_InfoList_r9_t *) NULL, + (LTE_SystemInformationBlockType1_v1310_IEs_t *)NULL, + 0, + (LTE_BCCH_DL_SCH_Message_MBMS_t *) NULL, + (LTE_SchedulingInfo_MBMS_r14_t *) NULL, + (struct LTE_NonMBSFN_SubframeConfig_r14 *) NULL, + (LTE_SystemInformationBlockType1_MBMS_r14_t *) NULL, + (LTE_MBSFN_AreaInfoList_r9_t *) NULL, + (LTE_MBSFNAreaConfiguration_r9_t *) NULL + ); + } + } else { // remove LCHAN from MAC/PHY + AssertFatal(1==0,"Can't handle this yet in DU\n"); + } } } } + } + } - if (DRB_configList != NULL) { - for (i = 0; i < DRB_configList->list.count; i++) { // num max DRB (11-3-8) - if (DRB_configList->list.array[i]) { - drb_id = (int)DRB_configList->list.array[i]->drb_Identity; - LOG_I(F1AP, - "[DU %d] Logical Channel UL-DCCH, Received RRCConnectionReconfiguration for UE rnti %x, reconfiguring DRB %d/LCID %d\n", - ctxt.module_id, - ctxt.rnti, - (int)DRB_configList->list.array[i]->drb_Identity, - (int)*DRB_configList->list.array[i]->logicalChannelIdentity); - - if (ue_context_p->ue_context.DRB_active[drb_id] == 0) { - ue_context_p->ue_context.DRB_active[drb_id] = 1; - - if (DRB_configList->list.array[i]->logicalChannelIdentity) { - DRB2LCHAN[i] = (uint8_t) * DRB_configList->list.array[i]->logicalChannelIdentity; - } + break; - rrc_mac_config_req_eNB( - ctxt.module_id, - 0,0,0,0,0,0, - 0, - ue_context_p->ue_context.rnti, - (LTE_BCCH_BCH_Message_t *) NULL, - (LTE_RadioResourceConfigCommonSIB_t *) NULL, - (LTE_RadioResourceConfigCommonSIB_t *) NULL, - physicalConfigDedicated, - (LTE_SCellToAddMod_r10_t *)NULL, - //(struct PhysicalConfigDedicatedSCell_r10 *)NULL, - (LTE_MeasObjectToAddMod_t **) NULL, - mac_MainConfig, - DRB2LCHAN[i], - DRB_configList->list.array[i]->logicalChannelConfig, - measGapConfig, - (LTE_TDD_Config_t *) NULL, - NULL, - (LTE_SchedulingInfoList_t *) NULL, - 0, NULL, NULL, (LTE_MBSFN_SubframeConfigList_t *) NULL - , 0, (LTE_MBSFN_AreaInfoList_r9_t *) NULL, (LTE_PMCH_InfoList_r9_t *) NULL, - (LTE_SystemInformationBlockType1_v1310_IEs_t *)NULL, - 0, - (LTE_BCCH_DL_SCH_Message_MBMS_t *) NULL, - (LTE_SchedulingInfo_MBMS_r14_t *) NULL, - (struct LTE_NonMBSFN_SubframeConfig_r14 *) NULL, - (LTE_SystemInformationBlockType1_MBMS_r14_t *) NULL, - (LTE_MBSFN_AreaInfoList_r9_t *) NULL, - (LTE_MBSFNAreaConfiguration_r9_t*) NULL - ); - } + case LTE_DL_DCCH_MessageType__c1_PR_rrcConnectionRelease: + // handle RRCConnectionRelease + LOG_I(F1AP, "Received RRCConnectionRelease\n"); + break; - } else { // remove LCHAN from MAC/PHY - AssertFatal(1==0,"Can't handle this yet in DU\n"); - } - } - } - } - } - } - break; - case LTE_DL_DCCH_MessageType__c1_PR_rrcConnectionRelease: - // handle RRCConnectionRelease - LOG_I(F1AP, "Received RRCConnectionRelease\n"); - break; - case LTE_DL_DCCH_MessageType__c1_PR_securityModeCommand: - LOG_I(F1AP, "Received securityModeCommand\n"); - break; - case LTE_DL_DCCH_MessageType__c1_PR_ueCapabilityEnquiry: - LOG_I(F1AP, "Received ueCapabilityEnquiry\n"); + case LTE_DL_DCCH_MessageType__c1_PR_securityModeCommand: + LOG_I(F1AP, "Received securityModeCommand\n"); break; - case LTE_DL_DCCH_MessageType__c1_PR_counterCheck: - case LTE_DL_DCCH_MessageType__c1_PR_loggedMeasurementConfiguration_r10: - case LTE_DL_DCCH_MessageType__c1_PR_rnReconfiguration_r10: - case LTE_DL_DCCH_MessageType__c1_PR_spare1: - case LTE_DL_DCCH_MessageType__c1_PR_spare2: - case LTE_DL_DCCH_MessageType__c1_PR_spare3: - break; - case LTE_DL_DCCH_MessageType__c1_PR_ueInformationRequest_r9: - LOG_I(F1AP, "Received ueInformationRequest_r9\n"); - break; - case LTE_DL_DCCH_MessageType__c1_PR_rrcConnectionResume_r13: - LOG_I(F1AP, "Received rrcConnectionResume_r13\n"); - } - } - } - else if (srb_id == 2) { - + + case LTE_DL_DCCH_MessageType__c1_PR_ueCapabilityEnquiry: + LOG_I(F1AP, "Received ueCapabilityEnquiry\n"); + break; + + case LTE_DL_DCCH_MessageType__c1_PR_counterCheck: + case LTE_DL_DCCH_MessageType__c1_PR_loggedMeasurementConfiguration_r10: + case LTE_DL_DCCH_MessageType__c1_PR_rnReconfiguration_r10: + case LTE_DL_DCCH_MessageType__c1_PR_spare1: + case LTE_DL_DCCH_MessageType__c1_PR_spare2: + case LTE_DL_DCCH_MessageType__c1_PR_spare3: + break; + + case LTE_DL_DCCH_MessageType__c1_PR_ueInformationRequest_r9: + LOG_I(F1AP, "Received ueInformationRequest_r9\n"); + break; + + case LTE_DL_DCCH_MessageType__c1_PR_rrcConnectionResume_r13: + LOG_I(F1AP, "Received rrcConnectionResume_r13\n"); + } + } + } else if (srb_id == 2) { } LOG_I(F1AP, "Received DL RRC Transfer on srb_id %ld\n", srb_id); rlc_op_status_t rlc_status; boolean_t ret = TRUE; - mem_block_t *pdcp_pdu_p = NULL; + mem_block_t *pdcp_pdu_p = NULL; pdcp_pdu_p = get_free_mem_block(rrc_dl_sdu_len, __func__); //LOG_I(F1AP, "PRRCContainer size %lu:", ie->value.choice.RRCContainer.size); @@ -556,75 +521,68 @@ int DU_handle_DL_RRC_MESSAGE_TRANSFER(instance_t instance, //for (int i=0;i<rrc_dl_sdu_len;i++) printf("%2x ",pdcp_pdu_p->data[i]); //printf("\n"); - if (pdcp_pdu_p != NULL) { memset(pdcp_pdu_p->data, 0, rrc_dl_sdu_len); memcpy(&pdcp_pdu_p->data[0], ie->value.choice.RRCContainer.buf, rrc_dl_sdu_len); + rlc_status = rlc_data_req(&ctxt + , 1 + , MBMS_FLAG_NO + , srb_id + , 0 + , 0 + , rrc_dl_sdu_len + , pdcp_pdu_p + ,NULL + ,NULL + ); - rlc_status = rlc_data_req(&ctxt - , 1 - , MBMS_FLAG_NO - , srb_id - , 0 - , 0 - , rrc_dl_sdu_len - , pdcp_pdu_p - ,NULL - ,NULL - ); - switch (rlc_status) { - case RLC_OP_STATUS_OK: - //LOG_I(F1AP, "Data sending request over RLC succeeded!\n"); - ret=TRUE; - break; + switch (rlc_status) { + case RLC_OP_STATUS_OK: + //LOG_I(F1AP, "Data sending request over RLC succeeded!\n"); + ret=TRUE; + break; - case RLC_OP_STATUS_BAD_PARAMETER: - LOG_W(F1AP, "Data sending request over RLC failed with 'Bad Parameter' reason!\n"); - ret= FALSE; - break; + case RLC_OP_STATUS_BAD_PARAMETER: + LOG_W(F1AP, "Data sending request over RLC failed with 'Bad Parameter' reason!\n"); + ret= FALSE; + break; - case RLC_OP_STATUS_INTERNAL_ERROR: - LOG_W(F1AP, "Data sending request over RLC failed with 'Internal Error' reason!\n"); - ret= FALSE; - break; + case RLC_OP_STATUS_INTERNAL_ERROR: + LOG_W(F1AP, "Data sending request over RLC failed with 'Internal Error' reason!\n"); + ret= FALSE; + break; - case RLC_OP_STATUS_OUT_OF_RESSOURCES: - LOG_W(F1AP, "Data sending request over RLC failed with 'Out of Resources' reason!\n"); - ret= FALSE; - break; + case RLC_OP_STATUS_OUT_OF_RESSOURCES: + LOG_W(F1AP, "Data sending request over RLC failed with 'Out of Resources' reason!\n"); + ret= FALSE; + break; + + default: + LOG_W(F1AP, "RLC returned an unknown status code after PDCP placed the order to send some data (Status Code:%d)\n", rlc_status); + ret= FALSE; + break; + } // switch case + + return ret; + } // if pdcp_pdu_p - default: - LOG_W(F1AP, "RLC returned an unknown status code after PDCP placed the order to send some data (Status Code:%d)\n", rlc_status); - ret= FALSE; - break; - } // switch case - return ret; - } // if pdcp_pdu_p - return 0; - } -int DU_send_UL_RRC_MESSAGE_TRANSFER(instance_t instance, +int DU_send_UL_RRC_MESSAGE_TRANSFER(instance_t instance, const f1ap_ul_rrc_message_t *msg) { const rnti_t rnti = msg->rnti; - F1AP_F1AP_PDU_t pdu; F1AP_ULRRCMessageTransfer_t *out; F1AP_ULRRCMessageTransferIEs_t *ie; - uint8_t *buffer = NULL; uint32_t len; - - LOG_I(F1AP, "[DU %ld] %s: size %d UE RNTI %x in SRB %d\n", instance, __func__, msg->rrc_container_length, rnti, msg->srb_id); - //LOG_I(F1AP, "%s() RRCContainer size %d: ", __func__, msg->rrc_container_length); //for (int i = 0;i < msg->rrc_container_length; i++) // printf("%02x ", msg->rrc_container[i]); //printf("\n"); - /* Create */ /* 0. Message Type */ memset(&pdu, 0, sizeof(pdu)); @@ -634,27 +592,22 @@ int DU_send_UL_RRC_MESSAGE_TRANSFER(instance_t instance, pdu.choice.initiatingMessage->criticality = F1AP_Criticality_ignore; pdu.choice.initiatingMessage->value.present = F1AP_InitiatingMessage__value_PR_ULRRCMessageTransfer; out = &pdu.choice.initiatingMessage->value.choice.ULRRCMessageTransfer; - /* mandatory */ /* c1. GNB_CU_UE_F1AP_ID */ ie = (F1AP_ULRRCMessageTransferIEs_t *)calloc(1, sizeof(F1AP_ULRRCMessageTransferIEs_t)); ie->id = F1AP_ProtocolIE_ID_id_gNB_CU_UE_F1AP_ID; ie->criticality = F1AP_Criticality_reject; ie->value.present = F1AP_ULRRCMessageTransferIEs__value_PR_GNB_CU_UE_F1AP_ID; - - ie->value.choice.GNB_CU_UE_F1AP_ID = f1ap_get_cu_ue_f1ap_id(&f1ap_du_inst[instance], rnti); - + ie->value.choice.GNB_CU_UE_F1AP_ID = f1ap_get_cu_ue_f1ap_id(DUtype, instance, rnti); ASN_SEQUENCE_ADD(&out->protocolIEs.list, ie); - /* mandatory */ /* c2. GNB_DU_UE_F1AP_ID */ ie = (F1AP_ULRRCMessageTransferIEs_t *)calloc(1, sizeof(F1AP_ULRRCMessageTransferIEs_t)); ie->id = F1AP_ProtocolIE_ID_id_gNB_DU_UE_F1AP_ID; ie->criticality = F1AP_Criticality_reject; ie->value.present = F1AP_ULRRCMessageTransferIEs__value_PR_GNB_DU_UE_F1AP_ID; - ie->value.choice.GNB_DU_UE_F1AP_ID = f1ap_get_du_ue_f1ap_id(&f1ap_du_inst[instance], rnti); + ie->value.choice.GNB_DU_UE_F1AP_ID = f1ap_get_du_ue_f1ap_id(DUtype, instance, rnti); ASN_SEQUENCE_ADD(&out->protocolIEs.list, ie); - /* mandatory */ /* c3. SRBID */ ie = (F1AP_ULRRCMessageTransferIEs_t *)calloc(1, sizeof(F1AP_ULRRCMessageTransferIEs_t)); @@ -663,7 +616,6 @@ int DU_send_UL_RRC_MESSAGE_TRANSFER(instance_t instance, ie->value.present = F1AP_ULRRCMessageTransferIEs__value_PR_SRBID; ie->value.choice.SRBID = msg->srb_id; ASN_SEQUENCE_ADD(&out->protocolIEs.list, ie); - // issue in here /* mandatory */ /* c4. RRCContainer */ @@ -677,138 +629,132 @@ int DU_send_UL_RRC_MESSAGE_TRANSFER(instance_t instance, ASN_SEQUENCE_ADD(&out->protocolIEs.list, ie); if (msg->srb_id == 1 || msg->srb_id == 2) { - struct rrc_eNB_ue_context_s* ue_context_p = rrc_eNB_get_ue_context(RC.rrc[instance], rnti); - - - LTE_UL_DCCH_Message_t* ul_dcch_msg=NULL; + struct rrc_eNB_ue_context_s *ue_context_p = rrc_eNB_get_ue_context(RC.rrc[instance], rnti); + LTE_UL_DCCH_Message_t *ul_dcch_msg=NULL; asn_dec_rval_t dec_rval; dec_rval = uper_decode(NULL, - &asn_DEF_LTE_UL_DCCH_Message, - (void**)&ul_dcch_msg, - &ie->value.choice.RRCContainer.buf[1], // buf[0] includes the pdcp header - msg->rrc_container_length, 0, 0); - - if ((dec_rval.code != RC_OK) && (dec_rval.consumed == 0)) + &asn_DEF_LTE_UL_DCCH_Message, + (void **)&ul_dcch_msg, + &ie->value.choice.RRCContainer.buf[1], // buf[0] includes the pdcp header + msg->rrc_container_length, 0, 0); + + if ((dec_rval.code != RC_OK) && (dec_rval.consumed == 0)) LOG_E(F1AP, " Failed to decode UL-DCCH (%zu bytes)\n",dec_rval.consumed); else LOG_I(F1AP, "Received message: present %d and c1 present %d\n", ul_dcch_msg->message.present, ul_dcch_msg->message.choice.c1.present); if (ul_dcch_msg->message.present == LTE_UL_DCCH_MessageType_PR_c1) { - switch (ul_dcch_msg->message.choice.c1.present) { - case LTE_UL_DCCH_MessageType__c1_PR_NOTHING: /* No components present */ - break; + case LTE_UL_DCCH_MessageType__c1_PR_NOTHING: /* No components present */ + break; - case LTE_UL_DCCH_MessageType__c1_PR_csfbParametersRequestCDMA2000: - break; + case LTE_UL_DCCH_MessageType__c1_PR_csfbParametersRequestCDMA2000: + break; - case LTE_UL_DCCH_MessageType__c1_PR_measurementReport: - break; + case LTE_UL_DCCH_MessageType__c1_PR_measurementReport: + break; + + case LTE_UL_DCCH_MessageType__c1_PR_rrcConnectionReconfigurationComplete: + LOG_I(F1AP, "[MSG] RRC UL rrcConnectionReconfigurationComplete\n"); + /* CDRX: activated when RRC Connection Reconfiguration Complete is received */ + int UE_id_mac = find_UE_id(instance, rnti); + + if (UE_id_mac == -1) { + LOG_E(F1AP, "Can't find UE_id(MAC) of UE rnti %x\n", rnti); + break; + } - case LTE_UL_DCCH_MessageType__c1_PR_rrcConnectionReconfigurationComplete: - LOG_I(F1AP, "[MSG] RRC UL rrcConnectionReconfigurationComplete\n"); - - /* CDRX: activated when RRC Connection Reconfiguration Complete is received */ - int UE_id_mac = find_UE_id(instance, rnti); - - if (UE_id_mac == -1) { - LOG_E(F1AP, "Can't find UE_id(MAC) of UE rnti %x\n", rnti); + UE_sched_ctrl_t *UE_scheduling_control = &(RC.mac[instance]->UE_info.UE_sched_ctrl[UE_id_mac]); + + if (UE_scheduling_control->cdrx_waiting_ack == TRUE) { + UE_scheduling_control->cdrx_waiting_ack = FALSE; + UE_scheduling_control->cdrx_configured = TRUE; // Set to TRUE when RRC Connection Reconfiguration Complete is received + LOG_I(F1AP, "CDRX configuration activated after RRC Connection Reconfiguration Complete reception\n"); + } + + /* End of CDRX processing */ break; - } - - UE_sched_ctrl_t *UE_scheduling_control = &(RC.mac[instance]->UE_info.UE_sched_ctrl[UE_id_mac]); - - if (UE_scheduling_control->cdrx_waiting_ack == TRUE) { - UE_scheduling_control->cdrx_waiting_ack = FALSE; - UE_scheduling_control->cdrx_configured = TRUE; // Set to TRUE when RRC Connection Reconfiguration Complete is received - LOG_I(F1AP, "CDRX configuration activated after RRC Connection Reconfiguration Complete reception\n"); - } - /* End of CDRX processing */ - - break; - case LTE_UL_DCCH_MessageType__c1_PR_rrcConnectionReestablishmentComplete: - break; + case LTE_UL_DCCH_MessageType__c1_PR_rrcConnectionReestablishmentComplete: + break; - case LTE_UL_DCCH_MessageType__c1_PR_rrcConnectionSetupComplete: - LOG_I(F1AP, "[MSG] RRC UL rrcConnectionSetupComplete \n"); - - if(!ue_context_p){ - LOG_E(F1AP, "Did not find the UE context associated with UE RNTOI %x, ue_context_p is NULL\n", rnti); + case LTE_UL_DCCH_MessageType__c1_PR_rrcConnectionSetupComplete: + LOG_I(F1AP, "[MSG] RRC UL rrcConnectionSetupComplete \n"); - } else { - LOG_I(F1AP, "Processing RRCConnectionSetupComplete UE %x\n", rnti); - ue_context_p->ue_context.StatusRrc = RRC_CONNECTED; - } - break; + if(!ue_context_p) { + LOG_E(F1AP, "Did not find the UE context associated with UE RNTOI %x, ue_context_p is NULL\n", rnti); + } else { + LOG_I(F1AP, "Processing RRCConnectionSetupComplete UE %x\n", rnti); + ue_context_p->ue_context.StatusRrc = RRC_CONNECTED; + } - case LTE_UL_DCCH_MessageType__c1_PR_securityModeComplete: - LOG_I(F1AP, "[MSG] RRC securityModeComplete \n"); - break; + break; - case LTE_UL_DCCH_MessageType__c1_PR_securityModeFailure: - break; + case LTE_UL_DCCH_MessageType__c1_PR_securityModeComplete: + LOG_I(F1AP, "[MSG] RRC securityModeComplete \n"); + break; - case LTE_UL_DCCH_MessageType__c1_PR_ueCapabilityInformation: - LOG_I(F1AP, "[MSG] RRC ueCapabilityInformation \n"); - break; + case LTE_UL_DCCH_MessageType__c1_PR_securityModeFailure: + break; - case LTE_UL_DCCH_MessageType__c1_PR_ulHandoverPreparationTransfer: - break; + case LTE_UL_DCCH_MessageType__c1_PR_ueCapabilityInformation: + LOG_I(F1AP, "[MSG] RRC ueCapabilityInformation \n"); + break; - case LTE_UL_DCCH_MessageType__c1_PR_ulInformationTransfer: - LOG_I(F1AP,"[MSG] RRC UL Information Transfer \n"); - break; + case LTE_UL_DCCH_MessageType__c1_PR_ulHandoverPreparationTransfer: + break; - case LTE_UL_DCCH_MessageType__c1_PR_counterCheckResponse: - break; + case LTE_UL_DCCH_MessageType__c1_PR_ulInformationTransfer: + LOG_I(F1AP,"[MSG] RRC UL Information Transfer \n"); + break; - case LTE_UL_DCCH_MessageType__c1_PR_ueInformationResponse_r9: - break; + case LTE_UL_DCCH_MessageType__c1_PR_counterCheckResponse: + break; - case LTE_UL_DCCH_MessageType__c1_PR_proximityIndication_r9: - break; + case LTE_UL_DCCH_MessageType__c1_PR_ueInformationResponse_r9: + break; - case LTE_UL_DCCH_MessageType__c1_PR_rnReconfigurationComplete_r10: - break; + case LTE_UL_DCCH_MessageType__c1_PR_proximityIndication_r9: + break; + + case LTE_UL_DCCH_MessageType__c1_PR_rnReconfigurationComplete_r10: + break; - case LTE_UL_DCCH_MessageType__c1_PR_mbmsCountingResponse_r10: - break; + case LTE_UL_DCCH_MessageType__c1_PR_mbmsCountingResponse_r10: + break; - case LTE_UL_DCCH_MessageType__c1_PR_interFreqRSTDMeasurementIndication_r10: - break; + case LTE_UL_DCCH_MessageType__c1_PR_interFreqRSTDMeasurementIndication_r10: + break; } } } - /* encode */ + + /* encode */ if (f1ap_encode_pdu(&pdu, &buffer, &len) < 0) { LOG_E(F1AP, "Failed to encode F1 UL RRC MESSAGE TRANSFER\n"); return -1; } - du_f1ap_itti_send_sctp_data_req(instance, f1ap_du_data->assoc_id, buffer, len, f1ap_du_data->default_sctp_stream_id); + ASN_STRUCT_RESET(asn_DEF_F1AP_F1AP_PDU, &pdu); + f1ap_itti_send_sctp_data_req(false, instance, buffer, len, getCxt(DUtype, instance)->default_sctp_stream_id); return 0; } - /* UL RRC Message Transfer */ -int DU_send_INITIAL_UL_RRC_MESSAGE_TRANSFER(module_id_t module_idP, - int CC_idP, - int UE_id, - rnti_t rntiP, - const uint8_t *sduP, - sdu_size_t sdu_lenP, - const int8_t *sdu2P, - sdu_size_t sdu2_lenP) { - - F1AP_F1AP_PDU_t pdu; +int DU_send_INITIAL_UL_RRC_MESSAGE_TRANSFER(instance_t instanceP, + int CC_idP, + int UE_id, + rnti_t rntiP, + const uint8_t *sduP, + sdu_size_t sdu_lenP, + const char *sdu2P, + sdu_size_t sdu2_lenP) { + F1AP_F1AP_PDU_t pdu= {0}; F1AP_InitialULRRCMessageTransfer_t *out; - F1AP_InitialULRRCMessageTransferIEs_t *ie; - - uint8_t *buffer; - uint32_t len; - int f1ap_uid = f1ap_add_ue (&f1ap_du_inst[module_idP], module_idP, CC_idP,UE_id, rntiP); + uint8_t *buffer=NULL; + uint32_t len=0; + int f1ap_uid = f1ap_add_ue (DUtype, instanceP, rntiP); if (f1ap_uid < 0 ) { LOG_E(F1AP, "Failed to add UE \n"); @@ -817,227 +763,157 @@ int DU_send_INITIAL_UL_RRC_MESSAGE_TRANSFER(module_id_t module_idP, /* Create */ /* 0. Message Type */ - memset(&pdu, 0, sizeof(pdu)); pdu.present = F1AP_F1AP_PDU_PR_initiatingMessage; - pdu.choice.initiatingMessage = (F1AP_InitiatingMessage_t *)calloc(1, sizeof(F1AP_InitiatingMessage_t)); - pdu.choice.initiatingMessage->procedureCode = F1AP_ProcedureCode_id_InitialULRRCMessageTransfer; - pdu.choice.initiatingMessage->criticality = F1AP_Criticality_ignore; - pdu.choice.initiatingMessage->value.present = F1AP_InitiatingMessage__value_PR_InitialULRRCMessageTransfer; - out = &pdu.choice.initiatingMessage->value.choice.InitialULRRCMessageTransfer; - - + asn1cCalloc(pdu.choice.initiatingMessage, tmp); + tmp->procedureCode = F1AP_ProcedureCode_id_InitialULRRCMessageTransfer; + tmp->criticality = F1AP_Criticality_ignore; + tmp->value.present = F1AP_InitiatingMessage__value_PR_InitialULRRCMessageTransfer; + out = &tmp->value.choice.InitialULRRCMessageTransfer; /* mandatory */ /* c1. GNB_DU_UE_F1AP_ID */ - ie = (F1AP_InitialULRRCMessageTransferIEs_t *)calloc(1, sizeof(F1AP_InitialULRRCMessageTransferIEs_t)); - ie->id = F1AP_ProtocolIE_ID_id_gNB_DU_UE_F1AP_ID; - ie->criticality = F1AP_Criticality_reject; - ie->value.present = F1AP_InitialULRRCMessageTransferIEs__value_PR_GNB_DU_UE_F1AP_ID; - ie->value.choice.GNB_DU_UE_F1AP_ID = f1ap_du_inst[module_idP].f1ap_ue[f1ap_uid].du_ue_f1ap_id; - ASN_SEQUENCE_ADD(&out->protocolIEs.list, ie); - + asn1cSequenceAdd(out->protocolIEs.list, F1AP_InitialULRRCMessageTransferIEs_t, ie1); + ie1->id = F1AP_ProtocolIE_ID_id_gNB_DU_UE_F1AP_ID; + ie1->criticality = F1AP_Criticality_reject; + ie1->value.present = F1AP_InitialULRRCMessageTransferIEs__value_PR_GNB_DU_UE_F1AP_ID; + ie1->value.choice.GNB_DU_UE_F1AP_ID = getCxt(DUtype, instanceP)->f1ap_ue[f1ap_uid].du_ue_f1ap_id; /* mandatory */ /* c2. NRCGI */ - ie = (F1AP_InitialULRRCMessageTransferIEs_t *)calloc(1, sizeof(F1AP_InitialULRRCMessageTransferIEs_t)); - ie->id = F1AP_ProtocolIE_ID_id_NRCGI; - ie->criticality = F1AP_Criticality_reject; - ie->value.present = F1AP_InitialULRRCMessageTransferIEs__value_PR_NRCGI; - - F1AP_NRCGI_t nRCGI; - memset(&nRCGI, 0, sizeof(F1AP_NRCGI_t)); - MCC_MNC_TO_PLMNID(f1ap_du_data->mcc[0], f1ap_du_data->mnc[0], f1ap_du_data->mnc_digit_length[0], - &nRCGI.pLMN_Identity); - NR_CELL_ID_TO_BIT_STRING(f1ap_du_data->nr_cellid[0], &nRCGI.nRCellIdentity); - ie->value.choice.NRCGI = nRCGI; - - ASN_SEQUENCE_ADD(&out->protocolIEs.list, ie); - + asn1cSequenceAdd(out->protocolIEs.list, F1AP_InitialULRRCMessageTransferIEs_t, ie2); + ie2->id = F1AP_ProtocolIE_ID_id_NRCGI; + ie2->criticality = F1AP_Criticality_reject; + ie2->value.present = F1AP_InitialULRRCMessageTransferIEs__value_PR_NRCGI; + //Fixme: takes always the first cell + addnRCGI(ie2->value.choice.NRCGI, getCxt(DUtype, instanceP)->setupReq.cell); /* mandatory */ /* c3. C_RNTI */ // 16 - ie = (F1AP_InitialULRRCMessageTransferIEs_t *)calloc(1, sizeof(F1AP_InitialULRRCMessageTransferIEs_t)); - ie->id = F1AP_ProtocolIE_ID_id_C_RNTI; - ie->criticality = F1AP_Criticality_reject; - ie->value.present = F1AP_InitialULRRCMessageTransferIEs__value_PR_C_RNTI; - ie->value.choice.C_RNTI=rntiP; - ASN_SEQUENCE_ADD(&out->protocolIEs.list, ie); - + asn1cSequenceAdd(out->protocolIEs.list, F1AP_InitialULRRCMessageTransferIEs_t, ie3); + ie3->id = F1AP_ProtocolIE_ID_id_C_RNTI; + ie3->criticality = F1AP_Criticality_reject; + ie3->value.present = F1AP_InitialULRRCMessageTransferIEs__value_PR_C_RNTI; + ie3->value.choice.C_RNTI=rntiP; /* mandatory */ /* c4. RRCContainer */ - ie = (F1AP_InitialULRRCMessageTransferIEs_t *)calloc(1, sizeof(F1AP_InitialULRRCMessageTransferIEs_t)); - ie->id = F1AP_ProtocolIE_ID_id_RRCContainer; - ie->criticality = F1AP_Criticality_reject; - ie->value.present = F1AP_InitialULRRCMessageTransferIEs__value_PR_RRCContainer; - OCTET_STRING_fromBuf(&ie->value.choice.RRCContainer, (const char *)sduP, sdu_lenP); - ASN_SEQUENCE_ADD(&out->protocolIEs.list, ie); + asn1cSequenceAdd(out->protocolIEs.list, F1AP_InitialULRRCMessageTransferIEs_t, ie4); + ie4->id = F1AP_ProtocolIE_ID_id_RRCContainer; + ie4->criticality = F1AP_Criticality_reject; + ie4->value.present = F1AP_InitialULRRCMessageTransferIEs__value_PR_RRCContainer; + OCTET_STRING_fromBuf(&ie4->value.choice.RRCContainer, (const char *)sduP, sdu_lenP); /* optional */ /* c5. DUtoCURRCContainer */ - if (sdu2P && RC.nrrrc) { - ie = (F1AP_InitialULRRCMessageTransferIEs_t *)calloc(1, sizeof(F1AP_InitialULRRCMessageTransferIEs_t)); - ie->id = F1AP_ProtocolIE_ID_id_DUtoCURRCContainer; - ie->criticality = F1AP_Criticality_reject; - ie->value.present = F1AP_InitialULRRCMessageTransferIEs__value_PR_DUtoCURRCContainer; - OCTET_STRING_fromBuf(&ie->value.choice.DUtoCURRCContainer, (char *)sdu2P, sdu2_lenP); - ASN_SEQUENCE_ADD(&out->protocolIEs.list, ie); - } - - /* encode */ + if (sdu2P) { + asn1cSequenceAdd(out->protocolIEs.list, F1AP_InitialULRRCMessageTransferIEs_t, ie5); + ie5->id = F1AP_ProtocolIE_ID_id_DUtoCURRCContainer; + ie5->criticality = F1AP_Criticality_reject; + ie5->value.present = F1AP_InitialULRRCMessageTransferIEs__value_PR_DUtoCURRCContainer; + OCTET_STRING_fromBuf(&ie5->value.choice.DUtoCURRCContainer, + sdu2P, + sdu2_lenP); + } + + /* encode */ if (f1ap_encode_pdu(&pdu, &buffer, &len) < 0) { LOG_E(F1AP, "Failed to encode F1 INITIAL UL RRC MESSAGE TRANSFER\n"); return -1; } - if (RC.nrrrc && RC.nrrrc[module_idP]->node_type == ngran_gNB_DU) { - struct rrc_gNB_ue_context_s* ue_context_p = rrc_gNB_allocate_new_UE_context(RC.nrrrc[module_idP]); - ue_context_p->ue_id_rnti = rntiP; - ue_context_p->ue_context.rnti = rntiP; - ue_context_p->ue_context.random_ue_identity = rntiP; - ue_context_p->ue_context.Srb0.Active = 1; - RB_INSERT(rrc_nr_ue_tree_s, &RC.nrrrc[module_idP]->rrc_ue_head, ue_context_p); - } else { - struct rrc_eNB_ue_context_s* ue_context_p = rrc_eNB_allocate_new_UE_context(RC.rrc[module_idP]); - ue_context_p->ue_id_rnti = rntiP; - ue_context_p->ue_context.rnti = rntiP; - ue_context_p->ue_context.random_ue_identity = rntiP; - ue_context_p->ue_context.Srb0.Active = 1; - RB_INSERT(rrc_ue_tree_s, &RC.rrc[module_idP]->rrc_ue_head, ue_context_p); - } - du_f1ap_itti_send_sctp_data_req(module_idP, f1ap_du_data->assoc_id, buffer, len, f1ap_du_data->default_sctp_stream_id); - + f1ap_itti_send_sctp_data_req(false, instanceP, buffer, len, getCxt(DUtype, instanceP)->default_sctp_stream_id); return 0; } - - -void init_f1ap_du_ue_inst (void) { - memset(f1ap_du_inst, 0, sizeof(f1ap_du_inst)); -} -int DU_send_UL_NR_RRC_MESSAGE_TRANSFER(instance_t instance, - const f1ap_ul_rrc_message_t *msg) { +int DU_send_UL_NR_RRC_MESSAGE_TRANSFER(instance_t instance, + const f1ap_ul_rrc_message_t *msg) { const rnti_t rnti = msg->rnti; - - F1AP_F1AP_PDU_t pdu; + F1AP_F1AP_PDU_t pdu= {0}; F1AP_ULRRCMessageTransfer_t *out; - F1AP_ULRRCMessageTransferIEs_t *ie; - uint8_t *buffer = NULL; uint32_t len; - - LOG_I(F1AP, "[DU %ld] %s: size %d UE RNTI %x in SRB %d\n", instance, __func__, msg->rrc_container_length, rnti, msg->srb_id); - //LOG_I(F1AP, "%s() RRCContainer size %d: ", __func__, msg->rrc_container_length); //for (int i = 0;i < msg->rrc_container_length; i++) // printf("%02x ", msg->rrc_container[i]); //printf("\n"); - /* Create */ /* 0. Message Type */ - memset(&pdu, 0, sizeof(pdu)); pdu.present = F1AP_F1AP_PDU_PR_initiatingMessage; - pdu.choice.initiatingMessage = (F1AP_InitiatingMessage_t *)calloc(1, sizeof(F1AP_InitiatingMessage_t)); - pdu.choice.initiatingMessage->procedureCode = F1AP_ProcedureCode_id_ULRRCMessageTransfer; - pdu.choice.initiatingMessage->criticality = F1AP_Criticality_ignore; - pdu.choice.initiatingMessage->value.present = F1AP_InitiatingMessage__value_PR_ULRRCMessageTransfer; - out = &pdu.choice.initiatingMessage->value.choice.ULRRCMessageTransfer; - + asn1cCalloc(pdu.choice.initiatingMessage, tmp); + tmp->procedureCode = F1AP_ProcedureCode_id_ULRRCMessageTransfer; + tmp->criticality = F1AP_Criticality_ignore; + tmp->value.present = F1AP_InitiatingMessage__value_PR_ULRRCMessageTransfer; + out = &tmp->value.choice.ULRRCMessageTransfer; /* mandatory */ /* c1. GNB_CU_UE_F1AP_ID */ - ie = (F1AP_ULRRCMessageTransferIEs_t *)calloc(1, sizeof(F1AP_ULRRCMessageTransferIEs_t)); - ie->id = F1AP_ProtocolIE_ID_id_gNB_CU_UE_F1AP_ID; - ie->criticality = F1AP_Criticality_reject; - ie->value.present = F1AP_ULRRCMessageTransferIEs__value_PR_GNB_CU_UE_F1AP_ID; - - ie->value.choice.GNB_CU_UE_F1AP_ID = f1ap_get_cu_ue_f1ap_id(&f1ap_du_inst[instance], rnti); - - ASN_SEQUENCE_ADD(&out->protocolIEs.list, ie); - + asn1cSequenceAdd(out->protocolIEs.list, F1AP_ULRRCMessageTransferIEs_t, ie1); + ie1->id = F1AP_ProtocolIE_ID_id_gNB_CU_UE_F1AP_ID; + ie1->criticality = F1AP_Criticality_reject; + ie1->value.present = F1AP_ULRRCMessageTransferIEs__value_PR_GNB_CU_UE_F1AP_ID; + ie1->value.choice.GNB_CU_UE_F1AP_ID = f1ap_get_cu_ue_f1ap_id(DUtype, instance, rnti); /* mandatory */ /* c2. GNB_DU_UE_F1AP_ID */ - ie = (F1AP_ULRRCMessageTransferIEs_t *)calloc(1, sizeof(F1AP_ULRRCMessageTransferIEs_t)); - ie->id = F1AP_ProtocolIE_ID_id_gNB_DU_UE_F1AP_ID; - ie->criticality = F1AP_Criticality_reject; - ie->value.present = F1AP_ULRRCMessageTransferIEs__value_PR_GNB_DU_UE_F1AP_ID; - ie->value.choice.GNB_DU_UE_F1AP_ID = f1ap_get_du_ue_f1ap_id(&f1ap_du_inst[instance], rnti); - ASN_SEQUENCE_ADD(&out->protocolIEs.list, ie); - + asn1cSequenceAdd(out->protocolIEs.list, F1AP_ULRRCMessageTransferIEs_t, ie2); + ie2->id = F1AP_ProtocolIE_ID_id_gNB_DU_UE_F1AP_ID; + ie2->criticality = F1AP_Criticality_reject; + ie2->value.present = F1AP_ULRRCMessageTransferIEs__value_PR_GNB_DU_UE_F1AP_ID; + ie2->value.choice.GNB_DU_UE_F1AP_ID = f1ap_get_du_ue_f1ap_id(DUtype, instance, rnti); /* mandatory */ /* c3. SRBID */ - ie = (F1AP_ULRRCMessageTransferIEs_t *)calloc(1, sizeof(F1AP_ULRRCMessageTransferIEs_t)); - ie->id = F1AP_ProtocolIE_ID_id_SRBID; - ie->criticality = F1AP_Criticality_reject; - ie->value.present = F1AP_ULRRCMessageTransferIEs__value_PR_SRBID; - ie->value.choice.SRBID = msg->srb_id; - ASN_SEQUENCE_ADD(&out->protocolIEs.list, ie); - + asn1cSequenceAdd(out->protocolIEs.list, F1AP_ULRRCMessageTransferIEs_t, ie3); + ie3->id = F1AP_ProtocolIE_ID_id_SRBID; + ie3->criticality = F1AP_Criticality_reject; + ie3->value.present = F1AP_ULRRCMessageTransferIEs__value_PR_SRBID; + ie3->value.choice.SRBID = msg->srb_id; // issue in here /* mandatory */ /* c4. RRCContainer */ - ie = (F1AP_ULRRCMessageTransferIEs_t *)calloc(1, sizeof(F1AP_ULRRCMessageTransferIEs_t)); - ie->id = F1AP_ProtocolIE_ID_id_RRCContainer; - ie->criticality = F1AP_Criticality_reject; - ie->value.present = F1AP_ULRRCMessageTransferIEs__value_PR_RRCContainer; - OCTET_STRING_fromBuf(&ie->value.choice.RRCContainer, + asn1cSequenceAdd(out->protocolIEs.list, F1AP_ULRRCMessageTransferIEs_t, ie4); + ie4->id = F1AP_ProtocolIE_ID_id_RRCContainer; + ie4->criticality = F1AP_Criticality_reject; + ie4->value.present = F1AP_ULRRCMessageTransferIEs__value_PR_RRCContainer; + OCTET_STRING_fromBuf(&ie4->value.choice.RRCContainer, (const char *) msg->rrc_container, msg->rrc_container_length); - ASN_SEQUENCE_ADD(&out->protocolIEs.list, ie); - /* encode */ + /* encode */ if (f1ap_encode_pdu(&pdu, &buffer, &len) < 0) { LOG_E(F1AP, "Failed to encode F1 UL RRC MESSAGE TRANSFER \n"); return -1; } - du_f1ap_itti_send_sctp_data_req(instance, f1ap_du_data->assoc_id, buffer, len, f1ap_du_data->default_sctp_stream_id); + f1ap_itti_send_sctp_data_req(false, instance, buffer, len, getCxt(DUtype, instance)->default_sctp_stream_id); return 0; } /* DL NR RRC Message Transfer */ int DU_handle_DL_NR_RRC_MESSAGE_TRANSFER(instance_t instance, - uint32_t assoc_id, - uint32_t stream, - F1AP_F1AP_PDU_t *pdu) { + uint32_t assoc_id, + uint32_t stream, + F1AP_F1AP_PDU_t *pdu) { LOG_D(F1AP, "DU_handle_DL_NR_RRC_MESSAGE_TRANSFER \n"); - F1AP_DLRRCMessageTransfer_t *container; F1AP_DLRRCMessageTransferIEs_t *ie; - uint64_t cu_ue_f1ap_id; uint64_t du_ue_f1ap_id; - uint64_t srb_id; int executeDuplication; - sdu_size_t rrc_dl_sdu_len; //uint64_t subscriberProfileIDforRFP; //uint64_t rAT_FrequencySelectionPriority; - DevAssert(pdu != NULL); - - if (stream != 0) { - LOG_E(F1AP, "[SCTP %d] Received F1 on stream != 0 (%d)\n", - assoc_id, stream); - return -1; - } - container = &pdu->choice.initiatingMessage->value.choice.DLRRCMessageTransfer; - - /* GNB_CU_UE_F1AP_ID */ F1AP_FIND_PROTOCOLIE_BY_ID(F1AP_DLRRCMessageTransferIEs_t, ie, container, F1AP_ProtocolIE_ID_id_gNB_CU_UE_F1AP_ID, true); cu_ue_f1ap_id = ie->value.choice.GNB_CU_UE_F1AP_ID; LOG_D(F1AP, "cu_ue_f1ap_id %lu \n", cu_ue_f1ap_id); - - /* GNB_DU_UE_F1AP_ID */ F1AP_FIND_PROTOCOLIE_BY_ID(F1AP_DLRRCMessageTransferIEs_t, ie, container, F1AP_ProtocolIE_ID_id_gNB_DU_UE_F1AP_ID, true); du_ue_f1ap_id = ie->value.choice.GNB_DU_UE_F1AP_ID; LOG_D(F1AP, "du_ue_f1ap_id %lu associated with UE RNTI %x \n", du_ue_f1ap_id, - f1ap_get_rnti_by_du_id(&f1ap_du_inst[instance], du_ue_f1ap_id)); // this should be the one transmitted via initial ul rrc message transfer + f1ap_get_rnti_by_du_id(DUtype, instance, du_ue_f1ap_id)); // this should be the one transmitted via initial ul rrc message transfer - if (f1ap_du_add_cu_ue_id(&f1ap_du_inst[instance],du_ue_f1ap_id, cu_ue_f1ap_id) < 0 ) { + if (f1ap_du_add_cu_ue_id(instance,du_ue_f1ap_id, cu_ue_f1ap_id) < 0 ) { LOG_E(F1AP, "Failed to find the F1AP UID \n"); //return -1; } @@ -1046,21 +922,21 @@ int DU_handle_DL_NR_RRC_MESSAGE_TRANSFER(instance_t instance, /* oldgNB_DU_UE_F1AP_ID */ if (0) { F1AP_FIND_PROTOCOLIE_BY_ID(F1AP_DLRRCMessageTransferIEs_t, ie, container, - F1AP_ProtocolIE_ID_id_oldgNB_DU_UE_F1AP_ID, true); + F1AP_ProtocolIE_ID_id_oldgNB_DU_UE_F1AP_ID, true); } /* mandatory */ /* SRBID */ F1AP_FIND_PROTOCOLIE_BY_ID(F1AP_DLRRCMessageTransferIEs_t, ie, container, F1AP_ProtocolIE_ID_id_SRBID, true); - srb_id = ie->value.choice.SRBID; + uint64_t srb_id = ie->value.choice.SRBID; LOG_D(F1AP, "srb_id %lu \n", srb_id); /* optional */ /* ExecuteDuplication */ if (0) { F1AP_FIND_PROTOCOLIE_BY_ID(F1AP_DLRRCMessageTransferIEs_t, ie, container, - F1AP_ProtocolIE_ID_id_ExecuteDuplication, true); + F1AP_ProtocolIE_ID_id_ExecuteDuplication, true); executeDuplication = ie->value.choice.ExecuteDuplication; LOG_D(F1AP, "ExecuteDuplication %d \n", executeDuplication); } @@ -1072,10 +948,8 @@ int DU_handle_DL_NR_RRC_MESSAGE_TRANSFER(instance_t instance, F1AP_ProtocolIE_ID_id_RRCContainer, true); // BK: need check // create an ITTI message and copy SDU - // message_p = itti_alloc_new_message (TASK_CU_F1, RRC_MAC_CCCH_DATA_IND); // memset (RRC_MAC_CCCH_DATA_IND (message_p).sdu, 0, CCCH_SDU_SIZE); - rrc_dl_sdu_len = ie->value.choice.RRCContainer.size; // memcpy(RRC_MAC_CCCH_DATA_IND (message_p).sdu, ie->value.choice.RRCContainer.buf, // ccch_sdu_len); @@ -1088,15 +962,17 @@ int DU_handle_DL_NR_RRC_MESSAGE_TRANSFER(instance_t instance, /* RAT_FrequencyPriorityInformation */ if (0) { F1AP_FIND_PROTOCOLIE_BY_ID(F1AP_DLRRCMessageTransferIEs_t, ie, container, - F1AP_ProtocolIE_ID_id_RAT_FrequencyPriorityInformation, true); + F1AP_ProtocolIE_ID_id_RAT_FrequencyPriorityInformation, true); switch(ie->value.choice.RAT_FrequencyPriorityInformation.present) { case F1AP_RAT_FrequencyPriorityInformation_PR_eNDC: //subscriberProfileIDforRFP = ie->value.choice.RAT_FrequencyPriorityInformation.choice.subscriberProfileIDforRFP; break; + case F1AP_RAT_FrequencyPriorityInformation_PR_nGRAN: //rAT_FrequencySelectionPriority = ie->value.choice.RAT_FrequencyPriorityInformation.choice.rAT_FrequencySelectionPriority; break; + default: LOG_W(F1AP, "unhandled IE RAT_FrequencyPriorityInformation.present\n"); break; @@ -1105,280 +981,12 @@ int DU_handle_DL_NR_RRC_MESSAGE_TRANSFER(instance_t instance, // decode RRC Container and act on the message type AssertFatal(srb_id<3,"illegal srb_id\n"); - - protocol_ctxt_t ctxt; - ctxt.rnti = f1ap_get_rnti_by_du_id(&f1ap_du_inst[instance], du_ue_f1ap_id); - ctxt.module_id = instance; - ctxt.instance = instance; - ctxt.enb_flag = 1; - - struct rrc_gNB_ue_context_s* ue_context_p = rrc_gNB_get_ue_context( - RC.nrrrc[ctxt.module_id], - ctxt.rnti); - - gNB_RRC_INST *rrc = RC.nrrrc[ctxt.module_id]; - if (srb_id == 0) { - NR_DL_CCCH_Message_t* dl_ccch_msg=NULL; - asn_dec_rval_t dec_rval; - dec_rval = uper_decode(NULL, - &asn_DEF_NR_DL_CCCH_Message, - (void**)&dl_ccch_msg, - ie->value.choice.RRCContainer.buf, - rrc_dl_sdu_len,0,0); - AssertFatal(dec_rval.code == RC_OK, "could not decode F1AP message\n"); - switch (dl_ccch_msg->message.choice.c1->present) { - - case NR_DL_CCCH_MessageType__c1_PR_NOTHING: - - LOG_I(F1AP, "Received PR_NOTHING on DL-CCCH-Message\n"); - break; - - case NR_DL_CCCH_MessageType__c1_PR_rrcReject: - LOG_I(F1AP, - "Logical Channel DL-CCCH (SRB0), Received RRCReject\n"); - break; - - case NR_DL_CCCH_MessageType__c1_PR_rrcSetup: - { - LOG_I(F1AP, - "Logical Channel DL-CCCH (SRB0), Received RRCSetup DU_ID %lx/RNTI %x\n", - du_ue_f1ap_id, - f1ap_get_rnti_by_du_id(&f1ap_du_inst[instance], du_ue_f1ap_id)); - // Get configuration - - NR_RRCSetup_t* rrcSetup = dl_ccch_msg->message.choice.c1->choice.rrcSetup; - AssertFatal(rrcSetup!=NULL, "rrcSetup is null\n"); - NR_RRCSetup_IEs_t *rrcSetup_ies = rrcSetup->criticalExtensions.choice.rrcSetup; - - ue_context_p->ue_context.SRB_configList = rrcSetup_ies->radioBearerConfig.srb_ToAddModList; - AssertFatal(rrcSetup_ies->masterCellGroup.buf!=NULL,"masterCellGroup is null\n"); - asn_dec_rval_t dec_rval; - dec_rval = uper_decode(NULL, - &asn_DEF_NR_CellGroupConfig, - (void**)&ue_context_p->ue_context.masterCellGroup, - rrcSetup_ies->masterCellGroup.buf, - rrcSetup_ies->masterCellGroup.size,0,0); - AssertFatal(dec_rval.code == RC_OK, "could not decode masterCellGroup\n"); - - apply_macrlc_config(rrc,ue_context_p,&ctxt); - - gNB_RRC_UE_t *ue_p = &ue_context_p->ue_context; - AssertFatal(ue_p->Srb0.Active == 1,"SRB0 is not active\n"); - - memcpy((void*)ue_p->Srb0.Tx_buffer.Payload, - (void*)ie->value.choice.RRCContainer.buf, - rrc_dl_sdu_len); // ie->value.choice.RRCContainer.size - - ue_p->Srb0.Tx_buffer.payload_size = rrc_dl_sdu_len; - - break; - } // case - - case NR_DL_CCCH_MessageType__c1_PR_spare2: - LOG_I(F1AP, - "Logical Channel DL-CCCH (SRB0), Received spare2\n"); - break; - - case NR_DL_CCCH_MessageType__c1_PR_spare1: - LOG_I(F1AP, - "Logical Channel DL-CCCH (SRB0), Received spare1\n"); - break; - - default: - AssertFatal(1==0, - "Unknown message\n"); - break; - }// switch case - return(0); - } else if (srb_id == 1) { - - NR_DL_DCCH_Message_t* dl_dcch_msg=NULL; - asn_dec_rval_t dec_rval; - dec_rval = uper_decode(NULL, - &asn_DEF_NR_DL_DCCH_Message, - (void**)&dl_dcch_msg, - &ie->value.choice.RRCContainer.buf[2], // buf[0] includes the pdcp header - rrc_dl_sdu_len-6,0,0); - - if ((dec_rval.code != RC_OK) && (dec_rval.consumed == 0)) - LOG_E(F1AP," Failed to decode DL-DCCH (%zu bytes)\n",dec_rval.consumed); - else - LOG_D(F1AP, "Received message: present %d and c1 present %d\n", - dl_dcch_msg->message.present, dl_dcch_msg->message.choice.c1->present); - - if (dl_dcch_msg->message.present == NR_DL_DCCH_MessageType_PR_c1) { - switch (dl_dcch_msg->message.choice.c1->present) { - case NR_DL_DCCH_MessageType__c1_PR_NOTHING: - LOG_I(F1AP, "Received PR_NOTHING on DL-DCCH-Message\n"); - return 0; - - case NR_DL_DCCH_MessageType__c1_PR_rrcReconfiguration: - // handle RRCReconfiguration - LOG_I(F1AP, - "Logical Channel DL-DCCH (SRB1), Received RRCReconfiguration DU_ID %lx/RNTI %x\n", - du_ue_f1ap_id, - f1ap_get_rnti_by_du_id(&f1ap_du_inst[instance], du_ue_f1ap_id)); - - NR_RRCReconfiguration_t* rrcReconfiguration = dl_dcch_msg->message.choice.c1->choice.rrcReconfiguration; - - if (rrcReconfiguration->criticalExtensions.present == NR_RRCReconfiguration__criticalExtensions_PR_rrcReconfiguration) { - NR_RRCReconfiguration_IEs_t* rrcReconfiguration_ies = - rrcReconfiguration->criticalExtensions.choice.rrcReconfiguration; - - if (rrcReconfiguration_ies->measConfig != NULL) { - LOG_I(F1AP, "Measurement Configuration is present\n"); - } - - if (rrcReconfiguration_ies->radioBearerConfig) { - LOG_I(F1AP, "Radio Resource Configuration is present\n"); - long drb_id; - int i; - NR_DRB_ToAddModList_t *DRB_configList = rrcReconfiguration_ies->radioBearerConfig->drb_ToAddModList; - NR_SRB_ToAddModList_t *SRB_configList = rrcReconfiguration_ies->radioBearerConfig->srb_ToAddModList; - // NR_DRB_ToReleaseList_t *DRB_ReleaseList = rrcReconfiguration_ies->radioBearerConfig->drb_ToReleaseList; - - // rrc_rlc_config_asn1_req - - if (SRB_configList != NULL) { - for (i = 0; (i < SRB_configList->list.count) && (i < 3); i++) { - if (SRB_configList->list.array[i]->srb_Identity == 1 ){ - ue_context_p->ue_context.Srb1.Active=1; - } - else if (SRB_configList->list.array[i]->srb_Identity == 2 ) { - ue_context_p->ue_context.Srb2.Active=1; - ue_context_p->ue_context.Srb2.Srb_info.Srb_id=2; - LOG_I(F1AP, "[DU %d] SRB2 is now active\n",ctxt.module_id); - } else { - LOG_W(F1AP, "[DU %d] invalide SRB identity %ld\n",ctxt.module_id, - SRB_configList->list.array[i]->srb_Identity); - } - } - } - - if (DRB_configList != NULL) { - for (i = 0; i < DRB_configList->list.count; i++) { // num max DRB (11-3-8) - if (DRB_configList->list.array[i]) { - drb_id = (int)DRB_configList->list.array[i]->drb_Identity; - LOG_I(F1AP, - "[DU %d] Logical Channel UL-DCCH, Received RRCConnectionReconfiguration for UE rnti %x, reconfiguring DRB %d\n", - ctxt.module_id, - ctxt.rnti, - (int)DRB_configList->list.array[i]->drb_Identity); - // (int)*DRB_configList->list.array[i]->logicalChannelIdentity); - - if (ue_context_p->ue_context.DRB_active[drb_id] == 0) { - ue_context_p->ue_context.DRB_active[drb_id] = 1; - - // logicalChannelIdentity - // rrc_mac_config_req_eNB - } - - } else { // remove LCHAN from MAC/PHY - AssertFatal(1==0,"Can't handle this yet in DU\n"); - } - } - } - } - } - break; - case NR_DL_DCCH_MessageType__c1_PR_rrcResume: - LOG_I(F1AP,"Received rrcResume\n"); - break; - case NR_DL_DCCH_MessageType__c1_PR_rrcRelease: - LOG_I(F1AP,"Received rrcRelease\n"); - break; - case NR_DL_DCCH_MessageType__c1_PR_rrcReestablishment: - LOG_I(F1AP,"Received rrcReestablishment\n"); - break; - case NR_DL_DCCH_MessageType__c1_PR_securityModeCommand: - LOG_I(F1AP,"Received securityModeCommand\n"); - break; - case NR_DL_DCCH_MessageType__c1_PR_dlInformationTransfer: - LOG_I(F1AP, "Received dlInformationTransfer\n"); - break; - case NR_DL_DCCH_MessageType__c1_PR_ueCapabilityEnquiry: - LOG_I(F1AP, "Received ueCapabilityEnquiry\n"); - break; - case NR_DL_DCCH_MessageType__c1_PR_counterCheck: - LOG_I(F1AP, "Received counterCheck\n"); - break; - case NR_DL_DCCH_MessageType__c1_PR_mobilityFromNRCommand: - case NR_DL_DCCH_MessageType__c1_PR_dlDedicatedMessageSegment_r16: - case NR_DL_DCCH_MessageType__c1_PR_ueInformationRequest_r16: - case NR_DL_DCCH_MessageType__c1_PR_dlInformationTransferMRDC_r16: - case NR_DL_DCCH_MessageType__c1_PR_loggedMeasurementConfiguration_r16: - case NR_DL_DCCH_MessageType__c1_PR_spare3: - case NR_DL_DCCH_MessageType__c1_PR_spare2: - case NR_DL_DCCH_MessageType__c1_PR_spare1: - break; - } - } - } - else if (srb_id == 2) { - // TODO - } - - LOG_I(F1AP, "Received DL RRC Transfer on srb_id %ld\n", srb_id); - - -// rlc_op_status_t rlc_status; -// boolean_t ret = TRUE; - mem_block_t *pdcp_pdu_p = NULL; - pdcp_pdu_p = get_free_mem_block(rrc_dl_sdu_len, __func__); - - //LOG_I(F1AP, "PRRCContainer size %lu:", ie->value.choice.RRCContainer.size); - //for (int i = 0; i < ie->value.choice.RRCContainer.size; i++) - // printf("%02x ", ie->value.choice.RRCContainer.buf[i]); - - //printf (", PDCP PDU size %d:", rrc_dl_sdu_len); - //for (int i=0;i<rrc_dl_sdu_len;i++) printf("%2x ",pdcp_pdu_p->data[i]); - //printf("\n"); - - if (pdcp_pdu_p != NULL) { - memset(pdcp_pdu_p->data, 0, rrc_dl_sdu_len); - memcpy(&pdcp_pdu_p->data[0], ie->value.choice.RRCContainer.buf, rrc_dl_sdu_len); - - /* for rfsim */ - du_rlc_data_req(&ctxt, 1, 0x00, 1, 1, 0, rrc_dl_sdu_len, pdcp_pdu_p); - // rlc_status = rlc_data_req(&ctxt - // , 1 - // , MBMS_FLAG_NO - // , srb_id - // , 0 - // , 0 - // , rrc_dl_sdu_len - // , pdcp_pdu_p - // ,NULL - // ,NULL - // ); - // switch (rlc_status) { - // case RLC_OP_STATUS_OK: - // //LOG_I(F1AP, "Data sending request over RLC succeeded!\n"); - // ret=TRUE; - // break; - - // case RLC_OP_STATUS_BAD_PARAMETER: - // LOG_W(F1AP, "Data sending request over RLC failed with 'Bad Parameter' reason!\n"); - // ret= FALSE; - // break; - - // case RLC_OP_STATUS_INTERNAL_ERROR: - // LOG_W(F1AP, "Data sending request over RLC failed with 'Internal Error' reason!\n"); - // ret= FALSE; - // break; - - // case RLC_OP_STATUS_OUT_OF_RESSOURCES: - // LOG_W(F1AP, "Data sending request over RLC failed with 'Out of Resources' reason!\n"); - // ret= FALSE; - // break; - - // default: - // LOG_W(F1AP, "RLC returned an unknown status code after PDCP placed the order to send some data (Status Code:%d)\n", rlc_status); - // ret= FALSE; - // break; - // } // switch case - // return ret; - } // if pdcp_pdu_p - + MessageDef *msg = itti_alloc_new_message(TASK_DU_F1, 0, NR_DU_RRC_DL_INDICATION); + NRDuDlReq_t *req=&NRDuDlReq(msg); + req->rnti=f1ap_get_rnti_by_du_id(DUtype, instance, du_ue_f1ap_id); + req->srb_id=srb_id; + req->buf= get_free_mem_block( ie->value.choice.RRCContainer.size, __func__); + memcpy(req->buf->data, ie->value.choice.RRCContainer.buf, ie->value.choice.RRCContainer.size); + itti_send_msg_to_task(TASK_RRC_GNB, instance, msg); return 0; } diff --git a/openair2/F1AP/f1ap_du_rrc_message_transfer.h b/openair2/F1AP/f1ap_du_rrc_message_transfer.h index 3036c66d709942babf98e857620ab56e2964bbf2..d6f196e38431add79afde8ad4848f4ea50d469d9 100644 --- a/openair2/F1AP/f1ap_du_rrc_message_transfer.h +++ b/openair2/F1AP/f1ap_du_rrc_message_transfer.h @@ -44,13 +44,13 @@ int DU_handle_DL_RRC_MESSAGE_TRANSFER(instance_t instance, int DU_send_UL_RRC_MESSAGE_TRANSFER(instance_t instance, const f1ap_ul_rrc_message_t *msg); int DU_send_UL_NR_RRC_MESSAGE_TRANSFER(instance_t instance, const f1ap_ul_rrc_message_t *msg); -int DU_send_INITIAL_UL_RRC_MESSAGE_TRANSFER(module_id_t module_idP, - int CC_idP, - int UE_id, - rnti_t rntiP, - const uint8_t *sduP, - sdu_size_t sdu_lenP, - const int8_t *sdu2P, - sdu_size_t sdu2_lenP); +int DU_send_INITIAL_UL_RRC_MESSAGE_TRANSFER(instance_t instanceP, + int CC_idP, + int UE_id, + rnti_t rntiP, + const uint8_t *sduP, + sdu_size_t sdu_lenP, + const char *sdu2P, + sdu_size_t sdu2_lenP); #endif /* F1AP_DU_RRC_MESSAGE_TRANSFER_H_ */ diff --git a/openair2/F1AP/f1ap_du_task.c b/openair2/F1AP/f1ap_du_task.c index 50f7cdff805ec3811ab4bd70fc958da1bec101ef..537f0060aecb072e6789c85ae7b6eb18ce8dacad 100644 --- a/openair2/F1AP/f1ap_du_task.c +++ b/openair2/F1AP/f1ap_du_task.c @@ -31,189 +31,171 @@ */ #include "f1ap_common.h" -#include "f1ap_handlers.h" #include "f1ap_du_interface_management.h" #include "f1ap_du_ue_context_management.h" #include "f1ap_du_rrc_message_transfer.h" #include "f1ap_du_task.h" #include "proto_agent.h" +#include <openair3/ocp-gtpu/gtp_itf.h> -extern RAN_CONTEXT_t RC; - -f1ap_setup_req_t *f1ap_du_data; -f1ap_cudu_inst_t f1ap_du_inst[MAX_eNB]; +//Fixme: Uniq dirty DU instance, by global var, datamodel need better management +instance_t DUuniqInstance=0; void du_task_send_sctp_association_req(instance_t instance, f1ap_setup_req_t *f1ap_setup_req) { - DevAssert(f1ap_setup_req != NULL); - MessageDef *message_p = NULL; sctp_new_association_req_t *sctp_new_association_req_p = NULL; - message_p = itti_alloc_new_message(TASK_DU_F1, 0, SCTP_NEW_ASSOCIATION_REQ); - sctp_new_association_req_p = &message_p->ittiMsg.sctp_new_association_req; sctp_new_association_req_p->ulp_cnx_id = instance; sctp_new_association_req_p->port = F1AP_PORT_NUMBER; sctp_new_association_req_p->ppid = F1AP_SCTP_PPID; - sctp_new_association_req_p->in_streams = f1ap_setup_req->sctp_in_streams; sctp_new_association_req_p->out_streams = f1ap_setup_req->sctp_out_streams; - // remote memcpy(&sctp_new_association_req_p->remote_address, &f1ap_setup_req->CU_f1_ip_address, sizeof(f1ap_setup_req->CU_f1_ip_address)); - // local memcpy(&sctp_new_association_req_p->local_address, &f1ap_setup_req->DU_f1_ip_address, sizeof(f1ap_setup_req->DU_f1_ip_address)); - - // store data - f1ap_du_data = (f1ap_setup_req_t *)calloc(1, sizeof(f1ap_setup_req_t)); - *f1ap_du_data = *f1ap_setup_req; //printf("sib itti message %s\n", f1ap_setup_req_t->sib1[0]); - //printf("nr_cellid : %llx (%lld)",f1ap_setup_req->nr_cellid[0],f1ap_setup_req->nr_cellid[0]); - //du_f1ap_register_to_sctp itti_send_msg_to_task(TASK_SCTP, instance, message_p); } void du_task_handle_sctp_association_resp(instance_t instance, sctp_new_association_resp_t *sctp_new_association_resp) { - DevAssert(sctp_new_association_resp != NULL); if (sctp_new_association_resp->sctp_state != SCTP_STATE_ESTABLISHED) { - LOG_E(F1AP, "Received unsuccessful result for SCTP association (%u), instance %d, cnx_id %u\n", - sctp_new_association_resp->sctp_state, - (int)instance, - sctp_new_association_resp->ulp_cnx_id); - - //f1ap_handle_setup_message(instance, sctp_new_association_resp->sctp_state == SCTP_STATE_SHUTDOWN); - return; // exit -1 for debugging - } - - // save the assoc id + LOG_W(F1AP, "Received unsuccessful result for SCTP association (%u), instance %ld, cnx_id %u\n", + sctp_new_association_resp->sctp_state, + instance, + sctp_new_association_resp->ulp_cnx_id); + //f1ap_handle_setup_message(instance, sctp_new_association_resp->sctp_state == SCTP_STATE_SHUTDOWN); + return; // exit -1 for debugging + } + + // save the assoc id + f1ap_setup_req_t *f1ap_du_data=f1ap_req(false, instance); f1ap_du_data->assoc_id = sctp_new_association_resp->assoc_id; f1ap_du_data->sctp_in_streams = sctp_new_association_resp->in_streams; f1ap_du_data->sctp_out_streams = sctp_new_association_resp->out_streams; f1ap_du_data->default_sctp_stream_id = 0; - /* setup parameters for F1U and start the server */ - const cudu_params_t params = (RC.nrrrc && RC.nrrrc[instance]->node_type == ngran_gNB_DU) ? (cudu_params_t){ - .local_ipv4_address = RC.nrmac[instance]->eth_params_n.my_addr, - .local_port = RC.nrmac[instance]->eth_params_n.my_portd, - .remote_ipv4_address = RC.nrmac[instance]->eth_params_n.remote_addr, - .remote_port = RC.nrmac[instance]->eth_params_n.remote_portd - } : (cudu_params_t){ - .local_ipv4_address = RC.mac[instance]->eth_params_n.my_addr, - .local_port = RC.mac[instance]->eth_params_n.my_portd, - .remote_ipv4_address = RC.mac[instance]->eth_params_n.remote_addr, - .remote_port = RC.mac[instance]->eth_params_n.remote_portd - }; - AssertFatal(proto_agent_start(instance, ¶ms) == 0, - "could not start PROTO_AGENT for F1U on instance %ld!\n", instance); - DU_send_F1_SETUP_REQUEST(instance); } -void du_task_handle_sctp_data_ind(instance_t instance, sctp_data_ind_t *sctp_data_ind) -{ +void du_task_handle_sctp_data_ind(instance_t instance, sctp_data_ind_t *sctp_data_ind) { int result; - DevAssert(sctp_data_ind != NULL); - f1ap_handle_message(instance, sctp_data_ind->assoc_id, sctp_data_ind->stream, - sctp_data_ind->buffer, sctp_data_ind->buffer_length); - + sctp_data_ind->buffer, sctp_data_ind->buffer_length); result = itti_free(TASK_UNKNOWN, sctp_data_ind->buffer); AssertFatal (result == EXIT_SUCCESS, "Failed to free memory (%d)!\n", result); } +static instance_t du_create_gtpu_instance_to_cu(char *CUaddr, uint16_t CUport, char *DUaddr, uint16_t DUport) { + openAddr_t tmp= {0}; + strncpy(tmp.originHost, DUaddr, sizeof(tmp.originHost)-1); + strncpy(tmp.destinationHost, CUaddr, sizeof(tmp.destinationHost)-1); + sprintf(tmp.originService, "%d", DUport); + sprintf(tmp.destinationService, "%d", CUport); + return ocp_gtpv1Init(tmp); +} void *F1AP_DU_task(void *arg) { - //sctp_cu_init(); - MessageDef *received_msg = NULL; - int result; - LOG_I(F1AP, "Starting F1AP at DU\n"); - //f1ap_eNB_prepare_internal_data(); - itti_mark_task_ready(TASK_DU_F1); // SCTP while (1) { - itti_receive_msg(TASK_DU_F1, &received_msg); - - switch (ITTI_MSG_ID(received_msg)) { - - // case TERMINATE_MESSAGE: - // //F1AP_WARN(" *** Exiting F1AP DU thread\n"); - // itti_exit_task(); - // break; - - case F1AP_SETUP_REQ: // this is not a true F1 message, but rather an ITTI message sent by enb_app - // 1. save the itti msg so that you can use it to sen f1ap_setup_req, fill the f1ap_setup_req message, + MessageDef *msg = NULL; + itti_receive_msg(TASK_DU_F1, &msg); + instance_t myInstance=ITTI_MSG_DESTINATION_INSTANCE(msg); + + switch (ITTI_MSG_ID(msg)) { + case F1AP_SETUP_REQ: + // this is not a true F1 message, but rather an ITTI message sent by enb_app + // 1. save the itti msg so that you can use it to sen f1ap_setup_req, fill the f1ap_setup_req message, // 2. store the message in f1ap context, that is also stored in RC // 2. send a sctp_association req LOG_I(F1AP, "DU Task Received F1AP_SETUP_REQ\n"); - du_task_send_sctp_association_req(ITTI_MSG_DESTINATION_INSTANCE(received_msg), - &F1AP_SETUP_REQ(received_msg)); + f1ap_setup_req_t *msgSetup=&F1AP_SETUP_REQ(msg); + createF1inst(false, myInstance, msgSetup); + getCxt(DUtype, myInstance)->gtpInst=du_create_gtpu_instance_to_cu(msgSetup->CU_f1_ip_address.ipv4_address, + msgSetup->CUport, + msgSetup->DU_f1_ip_address.ipv4_address, + msgSetup->DUport); + AssertFatal(getCxt(DUtype, myInstance)->gtpInst>0,"Failed to create CU F1-U UDP listener"); + // Fixme: fully inconsistent instances management + // dirty global var is a bad fix + extern instance_t legacyInstanceMapping; + legacyInstanceMapping = DUuniqInstance = getCxt(DUtype, myInstance)->gtpInst; + du_task_send_sctp_association_req(myInstance,msgSetup); break; + case F1AP_GNB_CU_CONFIGURATION_UPDATE_ACKNOWLEDGE: - DU_send_gNB_CU_CONFIGURATION_UPDATE_ACKNOWLEDGE(ITTI_MSG_DESTINATION_INSTANCE(received_msg), - &F1AP_GNB_CU_CONFIGURATION_UPDATE_ACKNOWLEDGE(received_msg)); - break; + DU_send_gNB_CU_CONFIGURATION_UPDATE_ACKNOWLEDGE(ITTI_MSG_ORIGIN_INSTANCE(msg), + &F1AP_GNB_CU_CONFIGURATION_UPDATE_ACKNOWLEDGE(msg)); + break; + case F1AP_GNB_CU_CONFIGURATION_UPDATE_FAILURE: - DU_send_gNB_CU_CONFIGURATION_UPDATE_FAILURE(ITTI_MSG_DESTINATION_INSTANCE(received_msg), - &F1AP_GNB_CU_CONFIGURATION_UPDATE_FAILURE(received_msg)); - break; + DU_send_gNB_CU_CONFIGURATION_UPDATE_FAILURE(myInstance, + &F1AP_GNB_CU_CONFIGURATION_UPDATE_FAILURE(msg)); + break; case SCTP_NEW_ASSOCIATION_RESP: // 1. store the respon // 2. send the f1setup_req LOG_I(F1AP, "DU Task Received SCTP_NEW_ASSOCIATION_RESP\n"); - du_task_handle_sctp_association_resp(ITTI_MSG_DESTINATION_INSTANCE(received_msg), - &received_msg->ittiMsg.sctp_new_association_resp); + du_task_handle_sctp_association_resp(myInstance, + &msg->ittiMsg.sctp_new_association_resp); break; - case SCTP_DATA_IND: + case SCTP_DATA_IND: // ex: any F1 incoming message for DU ends here LOG_I(F1AP, "DU Task Received SCTP_DATA_IND\n"); - du_task_handle_sctp_data_ind(ITTI_MSG_DESTINATION_INSTANCE(received_msg), - &received_msg->ittiMsg.sctp_data_ind); + du_task_handle_sctp_data_ind(myInstance, + &msg->ittiMsg.sctp_data_ind); break; - case F1AP_INITIAL_UL_RRC_MESSAGE: // to rrc + case F1AP_INITIAL_UL_RRC_MESSAGE: // from rrc LOG_I(F1AP, "DU Task Received F1AP_INITIAL_UL_RRC_MESSAGE\n"); - - f1ap_initial_ul_rrc_message_t *msg = &F1AP_INITIAL_UL_RRC_MESSAGE(received_msg); - DU_send_INITIAL_UL_RRC_MESSAGE_TRANSFER(0,0,0,msg->crnti, - msg->rrc_container, - msg->rrc_container_length, - (const int8_t*)msg->du2cu_rrc_container, - msg->du2cu_rrc_container_length); + f1ap_initial_ul_rrc_message_t *msgRrc = &F1AP_INITIAL_UL_RRC_MESSAGE(msg); + DU_send_INITIAL_UL_RRC_MESSAGE_TRANSFER(0,0,0,msgRrc->crnti, + msgRrc->rrc_container, + msgRrc->rrc_container_length, + msgRrc->du2cu_rrc_container, + msgRrc->du2cu_rrc_container_length + ); break; - case F1AP_UL_RRC_MESSAGE: // to rrc + case F1AP_UL_RRC_MESSAGE: // to rrc LOG_I(F1AP, "DU Task Received F1AP_UL_RRC_MESSAGE\n"); + if (RC.nrrrc && RC.nrrrc[0]->node_type == ngran_gNB_DU) { - DU_send_UL_NR_RRC_MESSAGE_TRANSFER(ITTI_MSG_DESTINATION_INSTANCE(received_msg), - &F1AP_UL_RRC_MESSAGE(received_msg)); + DU_send_UL_NR_RRC_MESSAGE_TRANSFER(myInstance, + &F1AP_UL_RRC_MESSAGE(msg)); } else { - DU_send_UL_RRC_MESSAGE_TRANSFER(ITTI_MSG_DESTINATION_INSTANCE(received_msg), - &F1AP_UL_RRC_MESSAGE(received_msg)); + DU_send_UL_RRC_MESSAGE_TRANSFER(myInstance, + &F1AP_UL_RRC_MESSAGE(msg)); } + + break; + + case F1AP_UE_CONTEXT_SETUP_RESP: + DU_send_UE_CONTEXT_SETUP_RESPONSE(myInstance, &F1AP_UE_CONTEXT_SETUP_RESP(msg)); break; case F1AP_UE_CONTEXT_RELEASE_REQ: // from MAC LOG_I(F1AP, "DU Task Received F1AP_UE_CONTEXT_RELEASE_REQ\n"); - DU_send_UE_CONTEXT_RELEASE_REQUEST(ITTI_MSG_DESTINATION_INSTANCE(received_msg), - &F1AP_UE_CONTEXT_RELEASE_REQ(received_msg)); + DU_send_UE_CONTEXT_RELEASE_REQUEST(myInstance, + &F1AP_UE_CONTEXT_RELEASE_REQ(msg)); break; case TERMINATE_MESSAGE: @@ -223,13 +205,12 @@ void *F1AP_DU_task(void *arg) { default: LOG_E(F1AP, "DU Received unhandled message: %d:%s\n", - ITTI_MSG_ID(received_msg), ITTI_MSG_NAME(received_msg)); + ITTI_MSG_ID(msg), ITTI_MSG_NAME(msg)); break; } // switch - result = itti_free (ITTI_MSG_ORIGIN_ID(received_msg), received_msg); - AssertFatal (result == EXIT_SUCCESS, "Failed to free memory (%d)!\n", result); - received_msg = NULL; + int result = itti_free (ITTI_MSG_ORIGIN_ID(msg), msg); + AssertFatal (result == EXIT_SUCCESS, "Failed to free memory (%d)!\n", result); } // while return NULL; diff --git a/openair2/F1AP/f1ap_du_ue_context_management.c b/openair2/F1AP/f1ap_du_ue_context_management.c index 131dbce8efad12aa46f060c12ee2f51b4ba62e8a..7b20bfb2aa54aa81962809ce9c7bdd6a21d0a72d 100644 --- a/openair2/F1AP/f1ap_du_ue_context_management.c +++ b/openair2/F1AP/f1ap_du_ue_context_management.c @@ -40,10 +40,28 @@ #include "rrc_eNB_UE_context.h" #include "openair2/RRC/NR/rrc_gNB_UE_context.h" #include "openair2/LAYER2/NR_MAC_gNB/nr_mac_gNB.h" - -extern f1ap_setup_req_t *f1ap_du_data; -extern f1ap_cudu_inst_t f1ap_du_inst[MAX_eNB]; -extern RAN_CONTEXT_t RC; +#include <openair3/ocp-gtpu/gtp_itf.h> + +boolean_t lteDURecvCb( protocol_ctxt_t *ctxt_pP, + const srb_flag_t srb_flagP, + const rb_id_t rb_idP, + const mui_t muiP, + const confirm_t confirmP, + const sdu_size_t sdu_buffer_sizeP, + unsigned char *const sdu_buffer_pP, + const pdcp_transmission_mode_t modeP, + const uint32_t *sourceL2Id, + const uint32_t *destinationL2Id) { + // The buffer comes from the stack in gtp-u thread, we have a make a separate buffer to enqueue in a inter-thread message queue + mem_block_t *sdu=get_free_mem_block(sdu_buffer_sizeP, __func__); + memcpy(sdu->data, sdu_buffer_pP, sdu_buffer_sizeP); + // weird rb id management in 4G, not fully understand (looks bad design) + // overcomplex: if i understand, on the interface DRB start at 4 because there can be SRB 0..3 + // but it would be much simpler to use absolute numbering + // instead of this "srb flag" associated to these +/-4 + du_rlc_data_req(ctxt_pP,srb_flagP, false, rb_idP-4,muiP, confirmP, sdu_buffer_sizeP, sdu); + return true; +} int DU_handle_UE_CONTEXT_SETUP_REQUEST(instance_t instance, uint32_t assoc_id, @@ -51,121 +69,96 @@ int DU_handle_UE_CONTEXT_SETUP_REQUEST(instance_t instance, F1AP_F1AP_PDU_t *pdu) { MessageDef *msg_p; // message to RRC F1AP_UEContextSetupRequest_t *container; - F1AP_UEContextSetupRequestIEs_t *ie; int i; DevAssert(pdu); - msg_p = itti_alloc_new_message(TASK_DU_F1, 0, F1AP_UE_CONTEXT_SETUP_REQ); - f1ap_ue_context_setup_req_t *f1ap_ue_context_setup_req; - f1ap_ue_context_setup_req = &F1AP_UE_CONTEXT_SETUP_REQ(msg_p); + msg_p = itti_alloc_new_message(TASK_DU_F1, 0, F1AP_UE_CONTEXT_SETUP_REQ); + f1ap_ue_context_setup_t *f1ap_ue_context_setup_req = &F1AP_UE_CONTEXT_SETUP_REQ(msg_p); container = &pdu->choice.initiatingMessage->value.choice.UEContextSetupRequest; /* GNB_CU_UE_F1AP_ID */ - F1AP_FIND_PROTOCOLIE_BY_ID(F1AP_UEContextSetupRequestIEs_t, ie, container, + F1AP_UEContextSetupRequestIEs_t *ieCU; + F1AP_FIND_PROTOCOLIE_BY_ID(F1AP_UEContextSetupRequestIEs_t, ieCU, container, F1AP_ProtocolIE_ID_id_gNB_CU_UE_F1AP_ID, true); - f1ap_ue_context_setup_req->gNB_CU_ue_id = ie->value.choice.GNB_CU_UE_F1AP_ID; + f1ap_ue_context_setup_req->gNB_CU_ue_id = ieCU->value.choice.GNB_CU_UE_F1AP_ID; /* optional */ /* GNB_DU_UE_F1AP_ID */ - F1AP_FIND_PROTOCOLIE_BY_ID(F1AP_UEContextSetupRequestIEs_t, ie, container, + F1AP_UEContextSetupRequestIEs_t *ieDU_UE; + F1AP_FIND_PROTOCOLIE_BY_ID(F1AP_UEContextSetupRequestIEs_t, ieDU_UE, container, F1AP_ProtocolIE_ID_id_gNB_DU_UE_F1AP_ID, false); - if (ie) { - f1ap_ue_context_setup_req->gNB_DU_ue_id = malloc(sizeof(uint32_t)); - - if (f1ap_ue_context_setup_req->gNB_DU_ue_id) - *f1ap_ue_context_setup_req->gNB_DU_ue_id = ie->value.choice.GNB_DU_UE_F1AP_ID; + if (ieDU_UE) { + f1ap_ue_context_setup_req->gNB_DU_ue_id = + ieDU_UE->value.choice.GNB_DU_UE_F1AP_ID; + f1ap_ue_context_setup_req->rnti = + f1ap_get_rnti_by_du_id(DUtype, instance, f1ap_ue_context_setup_req->gNB_DU_ue_id); } else { - f1ap_ue_context_setup_req->gNB_DU_ue_id = NULL; + f1ap_ue_context_setup_req->gNB_DU_ue_id = -1; + f1ap_ue_context_setup_req->rnti = + f1ap_get_rnti_by_cu_id(DUtype, instance, f1ap_ue_context_setup_req->gNB_CU_ue_id); } + if(f1ap_ue_context_setup_req->rnti<0) + LOG_E(F1AP, "Could not retrieve UE rnti based on the CU/DU UE id \n"); + else + LOG_I(F1AP, "Retrieved rnti is: %d \n", f1ap_ue_context_setup_req->rnti); + /* SpCell_ID */ - F1AP_FIND_PROTOCOLIE_BY_ID(F1AP_UEContextSetupRequestIEs_t, ie, container, + F1AP_UEContextSetupRequestIEs_t *ieNet; + F1AP_FIND_PROTOCOLIE_BY_ID(F1AP_UEContextSetupRequestIEs_t, ieNet, container, F1AP_ProtocolIE_ID_id_SpCell_ID, true); - PLMNID_TO_MCC_MNC(&ie->value.choice.NRCGI.pLMN_Identity, + PLMNID_TO_MCC_MNC(&ieNet->value.choice.NRCGI.pLMN_Identity, f1ap_ue_context_setup_req->mcc, f1ap_ue_context_setup_req->mnc, f1ap_ue_context_setup_req->mnc_digit_length); - BIT_STRING_TO_NR_CELL_IDENTITY(&ie->value.choice.NRCGI.nRCellIdentity, f1ap_ue_context_setup_req->nr_cellid); + BIT_STRING_TO_NR_CELL_IDENTITY(&ieNet->value.choice.NRCGI.nRCellIdentity, f1ap_ue_context_setup_req->nr_cellid); /* ServCellIndex */ - F1AP_FIND_PROTOCOLIE_BY_ID(F1AP_UEContextSetupRequestIEs_t, ie, container, + F1AP_UEContextSetupRequestIEs_t *ieCell; + F1AP_FIND_PROTOCOLIE_BY_ID(F1AP_UEContextSetupRequestIEs_t, ieCell, container, F1AP_ProtocolIE_ID_id_ServCellIndex, true); - f1ap_ue_context_setup_req->servCellIndex = ie->value.choice.ServCellIndex; + f1ap_ue_context_setup_req->servCellIndex = ieCell->value.choice.ServCellIndex; /* optional */ /* CellULConfigured */ - F1AP_FIND_PROTOCOLIE_BY_ID(F1AP_UEContextSetupRequestIEs_t, ie, container, + F1AP_UEContextSetupRequestIEs_t *ieULCell; + F1AP_FIND_PROTOCOLIE_BY_ID(F1AP_UEContextSetupRequestIEs_t, ieULCell, container, F1AP_ProtocolIE_ID_id_SpCellULConfigured, false); // SpCellULConfigured - if (ie) { + if (ieULCell) { /* correct here */ f1ap_ue_context_setup_req->cellULConfigured = malloc(sizeof(uint32_t)); if (f1ap_ue_context_setup_req->cellULConfigured) - *f1ap_ue_context_setup_req->cellULConfigured = ie->value.choice.CellULConfigured; + *f1ap_ue_context_setup_req->cellULConfigured = ieULCell->value.choice.CellULConfigured; } else { f1ap_ue_context_setup_req->cellULConfigured = NULL; } - if (RC.nrrrc) { - /* RRCContainer */ - F1AP_FIND_PROTOCOLIE_BY_ID(F1AP_UEContextSetupRequestIEs_t, ie, container, - F1AP_ProtocolIE_ID_id_RRCContainer, false); - if (ie) { - /* correct here */ - f1ap_ue_context_setup_req->rrc_container = malloc(ie->value.choice.RRCContainer.size); - memcpy(f1ap_ue_context_setup_req->rrc_container, ie->value.choice.RRCContainer.buf, ie->value.choice.RRCContainer.size); - } else { - LOG_E(F1AP, "can't find RRCContainer in UEContextSetupRequestIEs by id %ld \n", F1AP_ProtocolIE_ID_id_RRCContainer); - } - - // AssertFatal(0, "check configuration, send to appropriate handler\n"); - - protocol_ctxt_t ctxt; - // ctxt.rnti = f1ap_get_rnti_by_du_id(&f1ap_du_inst[instance], ie->value.choice.GNB_DU_UE_F1AP_ID); - ctxt.rnti = 0x1234; - ctxt.module_id = instance; - ctxt.instance = instance; - ctxt.enb_flag = 1; + /* DRB */ + F1AP_UEContextSetupRequestIEs_t *ieDrb; + F1AP_FIND_PROTOCOLIE_BY_ID(F1AP_UEContextSetupRequestIEs_t, ieDrb, container, + F1AP_ProtocolIE_ID_id_DRBs_ToBeSetup_List, false); - mem_block_t *pdcp_pdu_p = NULL; - pdcp_pdu_p = get_free_mem_block(ie->value.choice.RRCContainer.size, __func__); - if (pdcp_pdu_p != NULL) { - memset(pdcp_pdu_p->data, 0, ie->value.choice.RRCContainer.size); - memcpy(&pdcp_pdu_p->data[0], ie->value.choice.RRCContainer.buf, ie->value.choice.RRCContainer.size); - - /* for rfsim */ - du_rlc_data_req(&ctxt, 1, 0x00, 1, 1, 0, ie->value.choice.RRCContainer.size, pdcp_pdu_p); - } - } else { - /* CUtoDURRCInformation */ - /* Candidate_SpCell_List */ - /* optional */ - /* DRXCycle */ - /* optional */ - /* ResourceCoordinationTransferContainer */ - /* SCell_ToBeSetup_List */ - /* SRBs_ToBeSetup_List */ - /* DRBs_ToBeSetup_List */ - /* Decode DRBs_ToBeSetup_List */ - F1AP_FIND_PROTOCOLIE_BY_ID(F1AP_UEContextSetupRequestIEs_t, ie, container, - F1AP_ProtocolIE_ID_id_DRBs_ToBeSetup_List, true); - f1ap_ue_context_setup_req->drbs_to_be_setup_length = ie->value.choice.DRBs_ToBeSetup_List.list.count; + if(ieDrb!=NULL) { + f1ap_ue_context_setup_req->drbs_to_be_setup_length = ieDrb->value.choice.DRBs_ToBeSetup_List.list.count; f1ap_ue_context_setup_req->drbs_to_be_setup = calloc(f1ap_ue_context_setup_req->drbs_to_be_setup_length, - sizeof(f1ap_drb_to_be_setup_t)); + sizeof(f1ap_drb_to_be_setup_t)); AssertFatal(f1ap_ue_context_setup_req->drbs_to_be_setup, "could not allocate memory for f1ap_ue_context_setup_req->drbs_to_be_setup\n"); for (i = 0; i < f1ap_ue_context_setup_req->drbs_to_be_setup_length; ++i) { f1ap_drb_to_be_setup_t *drb_p = &f1ap_ue_context_setup_req->drbs_to_be_setup[i]; - F1AP_DRBs_ToBeSetup_Item_t *drbs_tobesetup_item_p; - drbs_tobesetup_item_p = &((F1AP_DRBs_ToBeSetup_ItemIEs_t *)ie->value.choice.DRBs_ToBeSetup_List.list.array[i])->value.choice.DRBs_ToBeSetup_Item; + F1AP_DRBs_ToBeSetup_Item_t *drbs_tobesetup_item_p = + &((F1AP_DRBs_ToBeSetup_ItemIEs_t *)ieDrb->value.choice.DRBs_ToBeSetup_List.list.array[i])->value.choice.DRBs_ToBeSetup_Item; drb_p->drb_id = drbs_tobesetup_item_p->dRBID; /* TODO in the following, assume only one UP UL TNL is present. - * this matches/assumes OAI CU implementation, can be up to 2! */ + * this matches/assumes OAI CU implementation, can be up to 2! */ drb_p->up_ul_tnl_length = 1; AssertFatal(drbs_tobesetup_item_p->uLUPTNLInformation_ToBeSetup_List.list.count > 0, "no UL UP TNL Information in DRBs to be Setup list\n"); F1AP_ULUPTNLInformation_ToBeSetup_Item_t *ul_up_tnl_info_p = (F1AP_ULUPTNLInformation_ToBeSetup_Item_t *)drbs_tobesetup_item_p->uLUPTNLInformation_ToBeSetup_List.list.array[0]; F1AP_GTPTunnel_t *ul_up_tnl0 = ul_up_tnl_info_p->uLUPTNLInformation.choice.gTPTunnel; BIT_STRING_TO_TRANSPORT_LAYER_ADDRESS_IPv4(&ul_up_tnl0->transportLayerAddress, drb_p->up_ul_tnl[0].tl_address); - OCTET_STRING_TO_INT32(&ul_up_tnl0->gTP_TEID, drb_p->up_ul_tnl[0].gtp_teid); + OCTET_STRING_TO_INT32(&ul_up_tnl0->gTP_TEID, drb_p->up_ul_tnl[0].teid); + // 3GPP assumes GTP-U is on port 2152, but OAI is configurable + drb_p->up_ul_tnl[0].port=getCxt(false,instance)->setupReq.CUport; switch (drbs_tobesetup_item_p->rLCMode) { case F1AP_RLCMode_rlc_am: @@ -176,363 +169,404 @@ int DU_handle_UE_CONTEXT_SETUP_REQUEST(instance_t instance, drb_p->rlc_mode = RLC_MODE_TM; break; } + + if (!(RC.nrrrc && RC.nrrrc[instance]->node_type == ngran_gNB_DU)) { + transport_layer_addr_t addr; + memcpy(addr.buffer, &drb_p->up_ul_tnl[0].tl_address, sizeof(drb_p->up_ul_tnl[0].tl_address)); + addr.length=sizeof(drb_p->up_ul_tnl[0].tl_address)*8; + drb_p->up_dl_tnl[0].teid=newGtpuCreateTunnel(INSTANCE_DEFAULT, + f1ap_ue_context_setup_req->rnti, + drb_p->drb_id, + drb_p->drb_id, + drb_p->up_ul_tnl[0].teid, + addr, + drb_p->up_ul_tnl[0].port, + lteDURecvCb); + drb_p->up_dl_tnl_length++; + } } } + /* SRB */ + F1AP_UEContextSetupRequestIEs_t *ieSrb; + F1AP_FIND_PROTOCOLIE_BY_ID(F1AP_UEContextSetupRequestIEs_t, ieSrb, container, + F1AP_ProtocolIE_ID_id_SRBs_ToBeSetup_List, false); + + if(ieSrb != NULL) { + f1ap_ue_context_setup_req->srbs_to_be_setup_length = ieSrb->value.choice.SRBs_ToBeSetup_List.list.count; + f1ap_ue_context_setup_req->srbs_to_be_setup = calloc(f1ap_ue_context_setup_req->srbs_to_be_setup_length, + sizeof(f1ap_srb_to_be_setup_t)); + AssertFatal(f1ap_ue_context_setup_req->srbs_to_be_setup, + "could not allocate memory for f1ap_ue_context_setup_req->srbs_to_be_setup\n"); + + for (i = 0; i < f1ap_ue_context_setup_req->srbs_to_be_setup_length; ++i) { + f1ap_srb_to_be_setup_t *srb_p = &f1ap_ue_context_setup_req->srbs_to_be_setup[i]; + F1AP_SRBs_ToBeSetup_Item_t *srbs_tobesetup_item_p; + srbs_tobesetup_item_p = &((F1AP_SRBs_ToBeSetup_ItemIEs_t *)ieSrb->value.choice.SRBs_ToBeSetup_List.list.array[i])->value.choice.SRBs_ToBeSetup_Item; + srb_p->srb_id = srbs_tobesetup_item_p->sRBID; + } + } + + /* RRCContainer */ + F1AP_UEContextSetupRequestIEs_t *ieRRC; + F1AP_FIND_PROTOCOLIE_BY_ID(F1AP_UEContextSetupRequestIEs_t, ieRRC, container, + F1AP_ProtocolIE_ID_id_RRCContainer, false); + + if (ieRRC) { + /* correct here */ + if ( ieRRC->value.choice.RRCContainer.size ) { + f1ap_ue_context_setup_req->rrc_container = malloc(ieRRC->value.choice.RRCContainer.size); + memcpy(f1ap_ue_context_setup_req->rrc_container, + ieRRC->value.choice.RRCContainer.buf, ieRRC->value.choice.RRCContainer.size); + // AssertFatal(0, "check configuration, send to appropriate handler\n"); + protocol_ctxt_t ctxt; + // decode RRC Container and act on the message type + //FIXME + //rnti_t rnti = f1ap_get_rnti_by_du_id(DUtype, instance, du_ue_f1ap_id); + ctxt.instance = instance; + ctxt.instance = instance; + ctxt.enb_flag = 1; + mem_block_t *pdcp_pdu_p = get_free_mem_block(ieRRC->value.choice.RRCContainer.size, __func__); + memcpy(&pdcp_pdu_p->data[0], ieRRC->value.choice.RRCContainer.buf, ieRRC->value.choice.RRCContainer.size); + du_rlc_data_req(&ctxt, 1, 0x00, 1, 1, 0, ieRRC->value.choice.RRCContainer.size, pdcp_pdu_p); + } else { + LOG_E(F1AP, " RRCContainer in UEContextSetupRequestIEs size id 0\n"); + } + } else { + LOG_W(F1AP, "can't find RRCContainer in UEContextSetupRequestIEs by id %ld \n", F1AP_ProtocolIE_ID_id_RRCContainer); + } + + if (RC.nrrrc && RC.nrrrc[instance]->node_type == ngran_gNB_DU) + itti_send_msg_to_task(TASK_RRC_GNB, instance, msg_p); + else + // in 4G, race conditon is to fix + DU_send_UE_CONTEXT_SETUP_RESPONSE(instance, f1ap_ue_context_setup_req); + return 0; } -//void DU_send_UE_CONTEXT_SETUP_RESPONSE(F1AP_UEContextSetupResponse_t *UEContextSetupResponse) { -int DU_send_UE_CONTEXT_SETUP_RESPONSE(instance_t instance) { - F1AP_F1AP_PDU_t pdu; +int DU_send_UE_CONTEXT_SETUP_RESPONSE(instance_t instance, f1ap_ue_context_setup_t *req) { + F1AP_F1AP_PDU_t pdu= {0}; F1AP_UEContextSetupResponse_t *out; - F1AP_UEContextSetupResponseIEs_t *ie; - uint8_t *buffer; - uint32_t len; - int i = 0, j = 0; - rnti_t rntiP; // note: need get value + uint8_t *buffer=NULL; + uint32_t len=0; /* Create */ /* 0. Message Type */ - memset(&pdu, 0, sizeof(pdu)); pdu.present = F1AP_F1AP_PDU_PR_successfulOutcome; - pdu.choice.successfulOutcome = (F1AP_SuccessfulOutcome_t *)calloc(1, sizeof(F1AP_SuccessfulOutcome_t)); - pdu.choice.successfulOutcome->procedureCode = F1AP_ProcedureCode_id_UEContextSetup; - pdu.choice.successfulOutcome->criticality = F1AP_Criticality_reject; - pdu.choice.successfulOutcome->value.present = F1AP_SuccessfulOutcome__value_PR_UEContextSetupResponse; - out = &pdu.choice.successfulOutcome->value.choice.UEContextSetupResponse; + asn1cCalloc(pdu.choice.successfulOutcome, tmp); + tmp->procedureCode = F1AP_ProcedureCode_id_UEContextSetup; + tmp->criticality = F1AP_Criticality_reject; + tmp->value.present = F1AP_SuccessfulOutcome__value_PR_UEContextSetupResponse; + out = &tmp->value.choice.UEContextSetupResponse; /* mandatory */ /* c1. GNB_CU_UE_F1AP_ID */ - ie = (F1AP_UEContextSetupResponseIEs_t *)calloc(1, sizeof(F1AP_UEContextSetupResponseIEs_t)); - ie->id = F1AP_ProtocolIE_ID_id_gNB_CU_UE_F1AP_ID; - ie->criticality = F1AP_Criticality_reject; - ie->value.present = F1AP_UEContextSetupResponseIEs__value_PR_GNB_CU_UE_F1AP_ID; - ie->value.choice.GNB_CU_UE_F1AP_ID = 126L; - ASN_SEQUENCE_ADD(&out->protocolIEs.list, ie); + asn1cSequenceAdd(out->protocolIEs.list, F1AP_UEContextSetupResponseIEs_t, ie1); + ie1->id = F1AP_ProtocolIE_ID_id_gNB_CU_UE_F1AP_ID; + ie1->criticality = F1AP_Criticality_reject; + ie1->value.present = F1AP_UEContextSetupResponseIEs__value_PR_GNB_CU_UE_F1AP_ID; + ie1->value.choice.GNB_CU_UE_F1AP_ID = req->gNB_CU_ue_id; /* mandatory */ /* c2. GNB_DU_UE_F1AP_ID */ - ie = (F1AP_UEContextSetupResponseIEs_t *)calloc(1, sizeof(F1AP_UEContextSetupResponseIEs_t)); - ie->id = F1AP_ProtocolIE_ID_id_gNB_DU_UE_F1AP_ID; - ie->criticality = F1AP_Criticality_reject; - ie->value.present = F1AP_UEContextSetupResponseIEs__value_PR_GNB_DU_UE_F1AP_ID; - ie->value.choice.GNB_DU_UE_F1AP_ID = 651L; - ASN_SEQUENCE_ADD(&out->protocolIEs.list, ie); + asn1cSequenceAdd(out->protocolIEs.list, F1AP_UEContextSetupResponseIEs_t, ie2); + ie2->id = F1AP_ProtocolIE_ID_id_gNB_DU_UE_F1AP_ID; + ie2->criticality = F1AP_Criticality_reject; + ie2->value.present = F1AP_UEContextSetupResponseIEs__value_PR_GNB_DU_UE_F1AP_ID; + ie2->value.choice.GNB_DU_UE_F1AP_ID = f1ap_get_du_ue_f1ap_id(DUtype, instance, req->rnti); /* mandatory */ /* c3. DUtoCURRCInformation */ - ie = (F1AP_UEContextSetupResponseIEs_t *)calloc(1, sizeof(F1AP_UEContextSetupResponseIEs_t)); - ie->id = F1AP_ProtocolIE_ID_id_DUtoCURRCInformation; - ie->criticality = F1AP_Criticality_reject; - ie->value.present = F1AP_UEContextSetupResponseIEs__value_PR_DUtoCURRCInformation; + //if (0) { + asn1cSequenceAdd(out->protocolIEs.list, F1AP_UEContextSetupResponseIEs_t, ie3); + ie3->id = F1AP_ProtocolIE_ID_id_DUtoCURRCInformation; + ie3->criticality = F1AP_Criticality_reject; + ie3->value.present = F1AP_UEContextSetupResponseIEs__value_PR_DUtoCURRCInformation; { /* cellGroupConfig */ - OCTET_STRING_fromBuf(&ie->value.choice.DUtoCURRCInformation.cellGroupConfig, "asdsa", - strlen("asdsa")); + OCTET_STRING_fromBuf(&ie3->value.choice.DUtoCURRCInformation.cellGroupConfig, (const char *)req->du_to_cu_rrc_information, + req->du_to_cu_rrc_information_length); /* OPTIONAL */ /* measGapConfig */ if (0) { - ie->value.choice.DUtoCURRCInformation.measGapConfig = (F1AP_MeasGapConfig_t *)calloc(1, sizeof(F1AP_MeasGapConfig_t)); - OCTET_STRING_fromBuf( ie->value.choice.DUtoCURRCInformation.measGapConfig, "asdsa", - strlen("asdsa")); + asn1cCalloc(ie3->value.choice.DUtoCURRCInformation.measGapConfig, tmp); + OCTET_STRING_fromBuf(tmp, "asdsa", strlen("asdsa")); } /* OPTIONAL */ /* requestedP_MaxFR1 */ if (0) { - ie->value.choice.DUtoCURRCInformation.requestedP_MaxFR1 = (OCTET_STRING_t *)calloc(1, sizeof(OCTET_STRING_t)); - OCTET_STRING_fromBuf( ie->value.choice.DUtoCURRCInformation.requestedP_MaxFR1, "asdsa", - strlen("asdsa")); + asn1cCalloc(ie3->value.choice.DUtoCURRCInformation.requestedP_MaxFR1, tmp); + OCTET_STRING_fromBuf(tmp, "asdsa", strlen("asdsa")); } - - ASN_SEQUENCE_ADD(&out->protocolIEs.list, ie); } + //} /* optional */ /* c4. C_RNTI */ if (0) { - ie = (F1AP_UEContextSetupResponseIEs_t *)calloc(1, sizeof(F1AP_UEContextSetupResponseIEs_t)); - ie->id = F1AP_ProtocolIE_ID_id_C_RNTI; - ie->criticality = F1AP_Criticality_ignore; - ie->value.present = F1AP_UEContextSetupResponseIEs__value_PR_C_RNTI; + asn1cSequenceAdd(out->protocolIEs.list, F1AP_UEContextSetupResponseIEs_t, ie4); + ie4->id = F1AP_ProtocolIE_ID_id_C_RNTI; + ie4->criticality = F1AP_Criticality_ignore; + ie4->value.present = F1AP_UEContextSetupResponseIEs__value_PR_C_RNTI; //C_RNTI_TO_BIT_STRING(rntiP, &ie->value.choice.C_RNTI); - ie->value.choice.C_RNTI=rntiP; - ASN_SEQUENCE_ADD(&out->protocolIEs.list, ie); + ie4->value.choice.C_RNTI=req->rnti; + LOG_E(F1AP,"RNTI to code!\n"); } /* optional */ /* c5. ResourceCoordinationTransferContainer */ if (0) { - ie = (F1AP_UEContextSetupResponseIEs_t *)calloc(1, sizeof(F1AP_UEContextSetupResponseIEs_t)); - ie->id = F1AP_ProtocolIE_ID_id_ResourceCoordinationTransferContainer; - ie->criticality = F1AP_Criticality_ignore; - ie->value.present = F1AP_UEContextSetupResponseIEs__value_PR_ResourceCoordinationTransferContainer; - OCTET_STRING_fromBuf(&ie->value.choice.ResourceCoordinationTransferContainer, "asdsa", + asn1cSequenceAdd(out->protocolIEs.list, F1AP_UEContextSetupResponseIEs_t, ie5); + ie5->id = F1AP_ProtocolIE_ID_id_ResourceCoordinationTransferContainer; + ie5->criticality = F1AP_Criticality_ignore; + ie5->value.present = F1AP_UEContextSetupResponseIEs__value_PR_ResourceCoordinationTransferContainer; + OCTET_STRING_fromBuf(&ie5->value.choice.ResourceCoordinationTransferContainer, "asdsa", strlen("asdsa")); - ASN_SEQUENCE_ADD(&out->protocolIEs.list, ie); } /* optional */ /* c6. FullConfiguration */ if (0) { - ie = (F1AP_UEContextSetupResponseIEs_t *)calloc(1, sizeof(F1AP_UEContextSetupResponseIEs_t)); - ie->id = F1AP_ProtocolIE_ID_id_FullConfiguration; - ie->criticality = F1AP_Criticality_ignore; - ie->value.present = F1AP_UEContextSetupResponseIEs__value_PR_FullConfiguration; - ie->value.choice.FullConfiguration = F1AP_FullConfiguration_full; //enum - ASN_SEQUENCE_ADD(&out->protocolIEs.list, ie); + asn1cSequenceAdd(out->protocolIEs.list, F1AP_UEContextSetupResponseIEs_t, ie6); + ie6->id = F1AP_ProtocolIE_ID_id_FullConfiguration; + ie6->criticality = F1AP_Criticality_ignore; + ie6->value.present = F1AP_UEContextSetupResponseIEs__value_PR_FullConfiguration; + ie6->value.choice.FullConfiguration = F1AP_FullConfiguration_full; //enum } /* mandatory */ /* c7. DRBs_Setup_List */ - ie = (F1AP_UEContextSetupResponseIEs_t *)calloc(1, sizeof(F1AP_UEContextSetupResponseIEs_t)); - ie->id = F1AP_ProtocolIE_ID_id_DRBs_Setup_List; - ie->criticality = F1AP_Criticality_ignore; - ie->value.present = F1AP_UEContextSetupResponseIEs__value_PR_DRBs_Setup_List; - - for (i=0; - i<1; - i++) { + asn1cSequenceAdd(out->protocolIEs.list, F1AP_UEContextSetupResponseIEs_t, ie7); + ie7->id = F1AP_ProtocolIE_ID_id_DRBs_Setup_List; + ie7->criticality = F1AP_Criticality_ignore; + ie7->value.present = F1AP_UEContextSetupResponseIEs__value_PR_DRBs_Setup_List; + + for (int i=0; i< req->drbs_to_be_setup_length; i++) { // - F1AP_DRBs_Setup_ItemIEs_t *drbs_setup_item_ies; - drbs_setup_item_ies = (F1AP_DRBs_Setup_ItemIEs_t *)calloc(1, sizeof(F1AP_DRBs_Setup_ItemIEs_t)); + asn1cSequenceAdd(ie7->value.choice.DRBs_Setup_List.list, + F1AP_DRBs_Setup_ItemIEs_t, drbs_setup_item_ies); drbs_setup_item_ies->id = F1AP_ProtocolIE_ID_id_DRBs_Setup_Item; drbs_setup_item_ies->criticality = F1AP_Criticality_ignore; drbs_setup_item_ies->value.present = F1AP_SRBs_FailedToBeSetup_ItemIEs__value_PR_SRBs_FailedToBeSetup_Item; /* 7.1 DRBs_Setup_Item */ - F1AP_DRBs_Setup_Item_t drbs_setup_item; - memset((void *)&drbs_setup_item, 0, sizeof(F1AP_DRBs_Setup_Item_t)); + /* ADD */ + F1AP_DRBs_Setup_Item_t *drbs_setup_item=&drbs_setup_item_ies->value.choice.DRBs_Setup_Item; /* dRBID */ - drbs_setup_item.dRBID = 12; + drbs_setup_item->dRBID = req->drbs_to_be_setup[i].drb_id; /* OPTIONAL */ /* lCID */ //drbs_setup_item.lCID = (F1AP_LCID_t *)calloc(1, sizeof(F1AP_LCID_t)); //drbs_setup_item.lCID = 1L; - for (j=0; - j<1; - j++) { - F1AP_DLUPTNLInformation_ToBeSetup_Item_t *dLUPTNLInformation_ToBeSetup_Item; - dLUPTNLInformation_ToBeSetup_Item = (F1AP_DLUPTNLInformation_ToBeSetup_Item_t *)calloc(1, sizeof(F1AP_DLUPTNLInformation_ToBeSetup_Item_t)); + for (int j=0; j<req->drbs_to_be_setup[i].up_dl_tnl_length; j++) { + /* ADD */ + asn1cSequenceAdd(drbs_setup_item->dLUPTNLInformation_ToBeSetup_List.list, + F1AP_DLUPTNLInformation_ToBeSetup_Item_t, dLUPTNLInformation_ToBeSetup_Item); dLUPTNLInformation_ToBeSetup_Item->dLUPTNLInformation.present = F1AP_UPTransportLayerInformation_PR_gTPTunnel; /* gTPTunnel */ - F1AP_GTPTunnel_t *gTPTunnel = (F1AP_GTPTunnel_t *)calloc(1, sizeof(F1AP_GTPTunnel_t)); - { - /* transportLayerAddress */ - TRANSPORT_LAYER_ADDRESS_IPv4_TO_BIT_STRING(1234, &gTPTunnel->transportLayerAddress); - /* gTP_TEID */ - OCTET_STRING_fromBuf(&gTPTunnel->gTP_TEID, "1204", - strlen("1204")); - dLUPTNLInformation_ToBeSetup_Item->dLUPTNLInformation.choice.gTPTunnel = gTPTunnel; - } - /* ADD */ - ASN_SEQUENCE_ADD(&drbs_setup_item.dLUPTNLInformation_ToBeSetup_List.list, - dLUPTNLInformation_ToBeSetup_Item); + asn1cCalloc(dLUPTNLInformation_ToBeSetup_Item->dLUPTNLInformation.choice.gTPTunnel,gTPTunnel); + /* transportLayerAddress */ + struct sockaddr_in addr= {0}; + inet_pton(AF_INET, getCxt(false,instance)->setupReq.DU_f1_ip_address.ipv4_address, + &addr.sin_addr.s_addr); + TRANSPORT_LAYER_ADDRESS_IPv4_TO_BIT_STRING(addr.sin_addr.s_addr, + &gTPTunnel->transportLayerAddress); + /* gTP_TEID */ + INT32_TO_OCTET_STRING(req->drbs_to_be_setup[i].up_dl_tnl[j].teid, &gTPTunnel->gTP_TEID); } // for j - - /* ADD */ - drbs_setup_item_ies->value.choice.DRBs_Setup_Item = drbs_setup_item; - ASN_SEQUENCE_ADD(&ie->value.choice.DRBs_Setup_List.list, - drbs_setup_item_ies); } // for i - ASN_SEQUENCE_ADD(&out->protocolIEs.list, ie); /* mandatory */ /* c8. SRBs_FailedToBeSetup_List */ - ie = (F1AP_UEContextSetupResponseIEs_t *)calloc(1, sizeof(F1AP_UEContextSetupResponseIEs_t)); - ie->id = F1AP_ProtocolIE_ID_id_SRBs_FailedToBeSetup_List; - ie->criticality = F1AP_Criticality_ignore; - ie->value.present = F1AP_UEContextSetupResponseIEs__value_PR_SRBs_FailedToBeSetup_List; - - for (i=0; - i<1; - i++) { - // - F1AP_SRBs_FailedToBeSetup_ItemIEs_t *srbs_failedToBeSetup_item_ies; - srbs_failedToBeSetup_item_ies = (F1AP_SRBs_FailedToBeSetup_ItemIEs_t *)calloc(1, sizeof(F1AP_SRBs_FailedToBeSetup_ItemIEs_t)); - srbs_failedToBeSetup_item_ies->id = F1AP_ProtocolIE_ID_id_SRBs_FailedToBeSetup_Item; - srbs_failedToBeSetup_item_ies->criticality = F1AP_Criticality_ignore; - srbs_failedToBeSetup_item_ies->value.present = F1AP_SRBs_FailedToBeSetup_ItemIEs__value_PR_SRBs_FailedToBeSetup_Item; - /* 8.1 SRBs_Setup_Item */ - F1AP_SRBs_FailedToBeSetup_Item_t srbs_failedToBeSetup_item; - memset((void *)&srbs_failedToBeSetup_item, 0, sizeof(F1AP_SRBs_FailedToBeSetup_Item_t)); - /* sRBID */ - srbs_failedToBeSetup_item.sRBID = 13L; - /* cause */ - srbs_failedToBeSetup_item.cause = (F1AP_Cause_t *)calloc(1, sizeof(F1AP_Cause_t)); - // dummy value - srbs_failedToBeSetup_item.cause->present = F1AP_Cause_PR_radioNetwork; - - switch(srbs_failedToBeSetup_item.cause->present) { - case F1AP_Cause_PR_radioNetwork: - srbs_failedToBeSetup_item.cause->choice.radioNetwork = F1AP_CauseRadioNetwork_unspecified; - break; - - case F1AP_Cause_PR_transport: - srbs_failedToBeSetup_item.cause->choice.transport = F1AP_CauseTransport_unspecified; - break; + if(0) { + asn1cSequenceAdd(out->protocolIEs.list, F1AP_UEContextSetupResponseIEs_t, ie8); + ie8->id = F1AP_ProtocolIE_ID_id_SRBs_FailedToBeSetup_List; + ie8->criticality = F1AP_Criticality_ignore; + ie8->value.present = F1AP_UEContextSetupResponseIEs__value_PR_SRBs_FailedToBeSetup_List; + + for (int i=0; i<1; i++) { + // + asn1cSequenceAdd(ie8->value.choice.SRBs_FailedToBeSetup_List.list, + F1AP_SRBs_FailedToBeSetup_ItemIEs_t, srbs_failedToBeSetup_item_ies); + srbs_failedToBeSetup_item_ies->id = F1AP_ProtocolIE_ID_id_SRBs_FailedToBeSetup_Item; + srbs_failedToBeSetup_item_ies->criticality = F1AP_Criticality_ignore; + srbs_failedToBeSetup_item_ies->value.present = F1AP_SRBs_FailedToBeSetup_ItemIEs__value_PR_SRBs_FailedToBeSetup_Item; + /* 8.1 SRBs_Setup_Item */ + F1AP_SRBs_FailedToBeSetup_Item_t *srbs_failedToBeSetup_item= + &srbs_failedToBeSetup_item_ies->value.choice.SRBs_FailedToBeSetup_Item; + /* sRBID */ + srbs_failedToBeSetup_item->sRBID = 13L; + /* cause */ + asn1cCalloc(srbs_failedToBeSetup_item->cause, tmp); + // dummy value + tmp->present = F1AP_Cause_PR_radioNetwork; + + switch(tmp->present) { + case F1AP_Cause_PR_radioNetwork: + tmp->choice.radioNetwork = F1AP_CauseRadioNetwork_unspecified; + break; - case F1AP_Cause_PR_protocol: - srbs_failedToBeSetup_item.cause->choice.protocol = F1AP_CauseProtocol_unspecified; - break; + case F1AP_Cause_PR_transport: + tmp->choice.transport = F1AP_CauseTransport_unspecified; + break; - case F1AP_Cause_PR_misc: - srbs_failedToBeSetup_item.cause->choice.misc = F1AP_CauseMisc_unspecified; - break; + case F1AP_Cause_PR_protocol: + tmp->choice.protocol = F1AP_CauseProtocol_unspecified; + break; - case F1AP_Cause_PR_NOTHING: - default: - break; - } // switch + case F1AP_Cause_PR_misc: + tmp->choice.misc = F1AP_CauseMisc_unspecified; + break; - /* ADD */ - srbs_failedToBeSetup_item_ies->value.choice.SRBs_FailedToBeSetup_Item = srbs_failedToBeSetup_item; - ASN_SEQUENCE_ADD(&ie->value.choice.SRBs_FailedToBeSetup_List.list, - srbs_failedToBeSetup_item_ies); - } // for i + case F1AP_Cause_PR_NOTHING: + default: + break; + } // switch + } // for i + } - ASN_SEQUENCE_ADD(&out->protocolIEs.list, ie); /* */ /* c9. DRBs_FailedToBeSetup_List */ - ie = (F1AP_UEContextSetupResponseIEs_t *)calloc(1, sizeof(F1AP_UEContextSetupResponseIEs_t)); - ie->id = F1AP_ProtocolIE_ID_id_DRBs_FailedToBeSetup_List; - ie->criticality = F1AP_Criticality_ignore; - ie->value.present = F1AP_UEContextSetupResponseIEs__value_PR_DRBs_FailedToBeSetup_List; - - for (i=0; - i<1; - i++) { - // - F1AP_DRBs_FailedToBeSetup_ItemIEs_t *drbs_failedToBeSetup_item_ies; - drbs_failedToBeSetup_item_ies = (F1AP_DRBs_FailedToBeSetup_ItemIEs_t *)calloc(1, sizeof(F1AP_DRBs_FailedToBeSetup_ItemIEs_t)); - drbs_failedToBeSetup_item_ies->id = F1AP_ProtocolIE_ID_id_DRBs_FailedToBeSetup_Item; - drbs_failedToBeSetup_item_ies->criticality = F1AP_Criticality_ignore; - drbs_failedToBeSetup_item_ies->value.present = F1AP_DRBs_FailedToBeSetup_ItemIEs__value_PR_DRBs_FailedToBeSetup_Item; - /* 9.1 DRBs_Setup_Item */ - F1AP_DRBs_FailedToBeSetup_Item_t drbs_failedToBeSetup_item; - memset((void *)&drbs_failedToBeSetup_item, 0, sizeof(F1AP_DRBs_FailedToBeSetup_Item_t)); - /* dRBID */ - drbs_failedToBeSetup_item.dRBID = 14; - /* cause */ - drbs_failedToBeSetup_item.cause = (F1AP_Cause_t *)calloc(1, sizeof(F1AP_Cause_t)); - // dummy value - drbs_failedToBeSetup_item.cause->present = F1AP_Cause_PR_radioNetwork; - - switch(drbs_failedToBeSetup_item.cause->present) { - case F1AP_Cause_PR_radioNetwork: - drbs_failedToBeSetup_item.cause->choice.radioNetwork = F1AP_CauseRadioNetwork_unspecified; - break; - - case F1AP_Cause_PR_transport: - drbs_failedToBeSetup_item.cause->choice.transport = F1AP_CauseTransport_unspecified; - break; + if(0) { + asn1cSequenceAdd(out->protocolIEs.list, F1AP_UEContextSetupResponseIEs_t, ie9); + ie9->id = F1AP_ProtocolIE_ID_id_DRBs_FailedToBeSetup_List; + ie9->criticality = F1AP_Criticality_ignore; + ie9->value.present = F1AP_UEContextSetupResponseIEs__value_PR_DRBs_FailedToBeSetup_List; + + for (int i=0; i<1; i++) { + asn1cSequenceAdd(ie9->value.choice.DRBs_FailedToBeSetup_List.list, + F1AP_DRBs_FailedToBeSetup_ItemIEs_t, drbs_failedToBeSetup_item_ies); + drbs_failedToBeSetup_item_ies->id = F1AP_ProtocolIE_ID_id_DRBs_FailedToBeSetup_Item; + drbs_failedToBeSetup_item_ies->criticality = F1AP_Criticality_ignore; + drbs_failedToBeSetup_item_ies->value.present = F1AP_DRBs_FailedToBeSetup_ItemIEs__value_PR_DRBs_FailedToBeSetup_Item; + /* 9.1 DRBs_Setup_Item */ + /* ADD */ + F1AP_DRBs_FailedToBeSetup_Item_t *drbs_failedToBeSetup_item= + &drbs_failedToBeSetup_item_ies->value.choice.DRBs_FailedToBeSetup_Item; + /* dRBID */ + drbs_failedToBeSetup_item->dRBID = 14; + /* cause */ + asn1cCalloc(drbs_failedToBeSetup_item->cause,tmp); + // dummy value + tmp->present = F1AP_Cause_PR_radioNetwork; + + switch(tmp->present) { + case F1AP_Cause_PR_radioNetwork: + tmp->choice.radioNetwork = F1AP_CauseRadioNetwork_unspecified; + break; - case F1AP_Cause_PR_protocol: - drbs_failedToBeSetup_item.cause->choice.protocol = F1AP_CauseProtocol_unspecified; - break; + case F1AP_Cause_PR_transport: + tmp->choice.transport = F1AP_CauseTransport_unspecified; + break; - case F1AP_Cause_PR_misc: - drbs_failedToBeSetup_item.cause->choice.misc = F1AP_CauseMisc_unspecified; - break; + case F1AP_Cause_PR_protocol: + tmp->choice.protocol = F1AP_CauseProtocol_unspecified; + break; - case F1AP_Cause_PR_NOTHING: - default: - break; - } // switch + case F1AP_Cause_PR_misc: + tmp->choice.misc = F1AP_CauseMisc_unspecified; + break; - /* ADD */ - drbs_failedToBeSetup_item_ies->value.choice.DRBs_FailedToBeSetup_Item = drbs_failedToBeSetup_item; - ASN_SEQUENCE_ADD(&ie->value.choice.DRBs_FailedToBeSetup_List.list, - drbs_failedToBeSetup_item_ies); - } // for i + case F1AP_Cause_PR_NOTHING: + default: + break; + } // switch + } // for i + } - ASN_SEQUENCE_ADD(&out->protocolIEs.list, ie); // /* */ /* c10. SCell_FailedtoSetup_List */ - ie = (F1AP_UEContextSetupResponseIEs_t *)calloc(1, sizeof(F1AP_UEContextSetupResponseIEs_t)); - ie->id = F1AP_ProtocolIE_ID_id_SCell_FailedtoSetup_List; - ie->criticality = F1AP_Criticality_ignore; - ie->value.present = F1AP_UEContextSetupResponseIEs__value_PR_SCell_FailedtoSetup_List; - - for (i=0; - i<1; - i++) { - // - F1AP_SCell_FailedtoSetup_ItemIEs_t *sCell_FailedtoSetup_item_ies; - sCell_FailedtoSetup_item_ies = (F1AP_SCell_FailedtoSetup_ItemIEs_t *)calloc(1, sizeof(F1AP_SCell_FailedtoSetup_ItemIEs_t)); - sCell_FailedtoSetup_item_ies->id = F1AP_ProtocolIE_ID_id_SCell_FailedtoSetup_Item; - sCell_FailedtoSetup_item_ies->criticality = F1AP_Criticality_ignore; - sCell_FailedtoSetup_item_ies->value.present = F1AP_SCell_FailedtoSetup_ItemIEs__value_PR_SCell_FailedtoSetup_Item; - /* 10.1 DRBs_Setup_Item */ - F1AP_SCell_FailedtoSetup_Item_t sCell_FailedtoSetup_item; - memset((void *)&sCell_FailedtoSetup_item, 0, sizeof(F1AP_SCell_FailedtoSetup_Item_t)); - /* sCell_ID */ - F1AP_NRCGI_t nRCGI; // issue here - memset(&nRCGI, 0, sizeof(F1AP_NRCGI_t)); - MCC_MNC_TO_PLMNID(f1ap_du_data->mcc[i], f1ap_du_data->mnc[i], f1ap_du_data->mnc_digit_length[i], &nRCGI.pLMN_Identity); - NR_CELL_ID_TO_BIT_STRING(f1ap_du_data->nr_cellid[0], &nRCGI.nRCellIdentity); - sCell_FailedtoSetup_item.sCell_ID = nRCGI; - /* cause */ - sCell_FailedtoSetup_item.cause = (F1AP_Cause_t *)calloc(1, sizeof(F1AP_Cause_t)); - // dummy value - sCell_FailedtoSetup_item.cause->present = F1AP_Cause_PR_radioNetwork; - - switch(sCell_FailedtoSetup_item.cause->present) { - case F1AP_Cause_PR_radioNetwork: - sCell_FailedtoSetup_item.cause->choice.radioNetwork = F1AP_CauseRadioNetwork_unspecified; - break; + if(0) { + asn1cSequenceAdd(out->protocolIEs.list, F1AP_UEContextSetupResponseIEs_t, ie10); + ie10->id = F1AP_ProtocolIE_ID_id_SCell_FailedtoSetup_List; + ie10->criticality = F1AP_Criticality_ignore; + ie10->value.present = F1AP_UEContextSetupResponseIEs__value_PR_SCell_FailedtoSetup_List; + + for (int i=0; i<1; i++) { + asn1cSequenceAdd(ie10->value.choice.SCell_FailedtoSetup_List.list, + F1AP_SCell_FailedtoSetup_ItemIEs_t, sCell_FailedtoSetup_item_ies); + sCell_FailedtoSetup_item_ies->id = F1AP_ProtocolIE_ID_id_SCell_FailedtoSetup_Item; + sCell_FailedtoSetup_item_ies->criticality = F1AP_Criticality_ignore; + sCell_FailedtoSetup_item_ies->value.present = F1AP_SCell_FailedtoSetup_ItemIEs__value_PR_SCell_FailedtoSetup_Item; + /* 10.1 DRBs_Setup_Item */ + F1AP_SCell_FailedtoSetup_Item_t *sCell_FailedtoSetup_item= + &sCell_FailedtoSetup_item_ies->value.choice.SCell_FailedtoSetup_Item; + /* sCell_ID */ + addnRCGI(sCell_FailedtoSetup_item->sCell_ID,f1ap_req(false, instance)->cell+i); + /* cause */ + asn1cCalloc(sCell_FailedtoSetup_item->cause, tmp); + // dummy value + tmp->present = F1AP_Cause_PR_radioNetwork; + + switch(tmp->present) { + case F1AP_Cause_PR_radioNetwork: + tmp->choice.radioNetwork = F1AP_CauseRadioNetwork_unspecified; + break; - case F1AP_Cause_PR_transport: - sCell_FailedtoSetup_item.cause->choice.transport = F1AP_CauseTransport_unspecified; - break; + case F1AP_Cause_PR_transport: + tmp->choice.transport = F1AP_CauseTransport_unspecified; + break; - case F1AP_Cause_PR_protocol: - sCell_FailedtoSetup_item.cause->choice.protocol = F1AP_CauseProtocol_unspecified; - break; + case F1AP_Cause_PR_protocol: + tmp->choice.protocol = F1AP_CauseProtocol_unspecified; + break; - case F1AP_Cause_PR_misc: - sCell_FailedtoSetup_item.cause->choice.misc = F1AP_CauseMisc_unspecified; - break; + case F1AP_Cause_PR_misc: + tmp->choice.misc = F1AP_CauseMisc_unspecified; + break; - case F1AP_Cause_PR_NOTHING: - default: - break; - } // switch + case F1AP_Cause_PR_NOTHING: + default: + break; + } // switch + } // for i + } + /* mandatory */ + /* c11. SRBs_Setup_List */ + asn1cSequenceAdd(out->protocolIEs.list, F1AP_UEContextSetupResponseIEs_t, ie11); + ie11->id = F1AP_ProtocolIE_ID_id_SRBs_Setup_List; + ie11->criticality = F1AP_Criticality_ignore; + ie11->value.present = F1AP_UEContextSetupResponseIEs__value_PR_SRBs_Setup_List; + + for (int i=0; i< req->srbs_to_be_setup_length; i++) {// + asn1cSequenceAdd(ie11->value.choice.SRBs_Setup_List.list, + F1AP_SRBs_Setup_ItemIEs_t, srbs_setup_item_ies); + srbs_setup_item_ies->id = F1AP_ProtocolIE_ID_id_SRBs_Setup_Item; + srbs_setup_item_ies->criticality = F1AP_Criticality_ignore; + srbs_setup_item_ies->value.present = F1AP_SRBs_Setup_ItemIEs__value_PR_SRBs_Setup_Item; + /* 11.1 SRBs_Setup_Item */ /* ADD */ - sCell_FailedtoSetup_item_ies->value.choice.SCell_FailedtoSetup_Item = sCell_FailedtoSetup_item; - ASN_SEQUENCE_ADD(&ie->value.choice.SCell_FailedtoSetup_List.list, - sCell_FailedtoSetup_item_ies); - } // for i - - ASN_SEQUENCE_ADD(&out->protocolIEs.list, ie); + F1AP_SRBs_Setup_Item_t *srbs_setup_item=&srbs_setup_item_ies->value.choice.SRBs_Setup_Item; + /* sRBID */ + srbs_setup_item->sRBID = req->srbs_to_be_setup[i].srb_id; + } /* Optional */ - /* c11. InactivityMonitoringResponse */ + /* c12. InactivityMonitoringResponse */ if (0) { - ie = (F1AP_UEContextSetupResponseIEs_t *)calloc(1, sizeof(F1AP_UEContextSetupResponseIEs_t)); - ie->id = F1AP_ProtocolIE_ID_id_InactivityMonitoringResponse; - ie->criticality = F1AP_Criticality_ignore; - ie->value.present = F1AP_UEContextSetupResponseIEs__value_PR_InactivityMonitoringResponse; - ie->value.choice.InactivityMonitoringResponse = F1AP_InactivityMonitoringResponse_not_supported; - ASN_SEQUENCE_ADD(&out->protocolIEs.list, ie); + asn1cSequenceAdd(out->protocolIEs.list, F1AP_UEContextSetupResponseIEs_t, ie11); + ie11->id = F1AP_ProtocolIE_ID_id_InactivityMonitoringResponse; + ie11->criticality = F1AP_Criticality_ignore; + ie11->value.present = F1AP_UEContextSetupResponseIEs__value_PR_InactivityMonitoringResponse; + ie11->value.choice.InactivityMonitoringResponse = F1AP_InactivityMonitoringResponse_not_supported; } /* Optional */ - /* c12. CriticalityDiagnostics */ + /* c13. CriticalityDiagnostics */ if (0) { - ie = (F1AP_UEContextSetupResponseIEs_t *)calloc(1, sizeof(F1AP_UEContextSetupResponseIEs_t)); - ie->id = F1AP_ProtocolIE_ID_id_CriticalityDiagnostics; - ie->criticality = F1AP_Criticality_ignore; - ie->value.present = F1AP_UEContextSetupResponseIEs__value_PR_CriticalityDiagnostics; - ie->value.choice.CriticalityDiagnostics.procedureCode = (F1AP_ProcedureCode_t *)calloc(1, sizeof(F1AP_ProcedureCode_t)); - *ie->value.choice.CriticalityDiagnostics.procedureCode = F1AP_ProcedureCode_id_UEContextSetup; - ie->value.choice.CriticalityDiagnostics.triggeringMessage = (F1AP_TriggeringMessage_t *)calloc(1, sizeof(F1AP_TriggeringMessage_t)); - *ie->value.choice.CriticalityDiagnostics.triggeringMessage = F1AP_TriggeringMessage_initiating_message; - ie->value.choice.CriticalityDiagnostics.procedureCriticality = (F1AP_Criticality_t *)calloc(1, sizeof(F1AP_Criticality_t)); - *ie->value.choice.CriticalityDiagnostics.procedureCriticality = F1AP_Criticality_reject; - ie->value.choice.CriticalityDiagnostics.transactionID = (F1AP_TransactionID_t *)calloc(1, sizeof(F1AP_TransactionID_t)); - *ie->value.choice.CriticalityDiagnostics.transactionID = 0; - ASN_SEQUENCE_ADD(&out->protocolIEs.list, ie); + asn1cSequenceAdd(out->protocolIEs.list, F1AP_UEContextSetupResponseIEs_t, ie12); + ie12->id = F1AP_ProtocolIE_ID_id_CriticalityDiagnostics; + ie12->criticality = F1AP_Criticality_ignore; + ie12->value.present = F1AP_UEContextSetupResponseIEs__value_PR_CriticalityDiagnostics; + asn1cCallocOne(ie12->value.choice.CriticalityDiagnostics.procedureCode, + F1AP_ProcedureCode_id_UEContextSetup); + asn1cCallocOne(ie12->value.choice.CriticalityDiagnostics.triggeringMessage, + F1AP_TriggeringMessage_initiating_message); + asn1cCallocOne(ie12->value.choice.CriticalityDiagnostics.procedureCriticality, + F1AP_Criticality_reject); + asn1cCallocOne(ie12->value.choice.CriticalityDiagnostics.transactionID, + 0); } /* encode */ @@ -541,98 +575,89 @@ int DU_send_UE_CONTEXT_SETUP_RESPONSE(instance_t instance) { return -1; } + f1ap_itti_send_sctp_data_req(false, instance, + buffer, + len, + getCxt(false, instance)->default_sctp_stream_id); return 0; } - int DU_send_UE_CONTEXT_SETUP_FAILURE(instance_t instance) { AssertFatal(1==0,"Not implemented yet\n"); } - - int DU_send_UE_CONTEXT_RELEASE_REQUEST(instance_t instance, f1ap_ue_context_release_req_t *req) { F1AP_F1AP_PDU_t pdu; F1AP_UEContextReleaseRequest_t *out; - F1AP_UEContextReleaseRequestIEs_t *ie; - uint8_t *buffer; - uint32_t len; - //int i = 0, j = 0; + uint8_t *buffer=NULL; + uint32_t len=0; /* Create */ /* 0. Message Type */ - memset(&pdu, 0, sizeof(pdu)); pdu.present = F1AP_F1AP_PDU_PR_initiatingMessage; - pdu.choice.initiatingMessage = (F1AP_InitiatingMessage_t *)calloc(1, sizeof(F1AP_InitiatingMessage_t)); - pdu.choice.initiatingMessage->procedureCode = F1AP_ProcedureCode_id_UEContextReleaseRequest; - pdu.choice.initiatingMessage->criticality = F1AP_Criticality_reject; - pdu.choice.initiatingMessage->value.present = F1AP_InitiatingMessage__value_PR_UEContextReleaseRequest; - out = &pdu.choice.initiatingMessage->value.choice.UEContextReleaseRequest; + asn1cCalloc(pdu.choice.initiatingMessage, tmp); + tmp->procedureCode = F1AP_ProcedureCode_id_UEContextReleaseRequest; + tmp->criticality = F1AP_Criticality_reject; + tmp->value.present = F1AP_InitiatingMessage__value_PR_UEContextReleaseRequest; + out = &tmp->value.choice.UEContextReleaseRequest; /* mandatory */ /* c1. GNB_CU_UE_F1AP_ID */ - ie = (F1AP_UEContextReleaseRequestIEs_t *)calloc(1, sizeof(F1AP_UEContextReleaseRequestIEs_t)); - ie->id = F1AP_ProtocolIE_ID_id_gNB_CU_UE_F1AP_ID; - ie->criticality = F1AP_Criticality_reject; - ie->value.present = F1AP_UEContextReleaseRequestIEs__value_PR_GNB_CU_UE_F1AP_ID; - ie->value.choice.GNB_CU_UE_F1AP_ID = f1ap_get_cu_ue_f1ap_id(&f1ap_du_inst[instance], req->rnti); - ASN_SEQUENCE_ADD(&out->protocolIEs.list, ie); + asn1cSequenceAdd(out->protocolIEs.list, F1AP_UEContextReleaseRequestIEs_t, ie1); + ie1->id = F1AP_ProtocolIE_ID_id_gNB_CU_UE_F1AP_ID; + ie1->criticality = F1AP_Criticality_reject; + ie1->value.present = F1AP_UEContextReleaseRequestIEs__value_PR_GNB_CU_UE_F1AP_ID; + ie1->value.choice.GNB_CU_UE_F1AP_ID = f1ap_get_cu_ue_f1ap_id(DUtype, instance, req->rnti); /* mandatory */ /* c2. GNB_DU_UE_F1AP_ID */ - ie = (F1AP_UEContextReleaseRequestIEs_t *)calloc(1, sizeof(F1AP_UEContextReleaseRequestIEs_t)); - ie->id = F1AP_ProtocolIE_ID_id_gNB_DU_UE_F1AP_ID; - ie->criticality = F1AP_Criticality_reject; - ie->value.present = F1AP_UEContextReleaseRequestIEs__value_PR_GNB_DU_UE_F1AP_ID; - ie->value.choice.GNB_DU_UE_F1AP_ID = f1ap_get_du_ue_f1ap_id(&f1ap_du_inst[instance], req->rnti); - ASN_SEQUENCE_ADD(&out->protocolIEs.list, ie); + asn1cSequenceAdd(out->protocolIEs.list, F1AP_UEContextReleaseRequestIEs_t, ie2); + ie2->id = F1AP_ProtocolIE_ID_id_gNB_DU_UE_F1AP_ID; + ie2->criticality = F1AP_Criticality_reject; + ie2->value.present = F1AP_UEContextReleaseRequestIEs__value_PR_GNB_DU_UE_F1AP_ID; + ie2->value.choice.GNB_DU_UE_F1AP_ID = f1ap_get_du_ue_f1ap_id(DUtype, instance, req->rnti); /* mandatory */ /* c3. Cause */ - ie = (F1AP_UEContextReleaseRequestIEs_t *)calloc(1, sizeof(F1AP_UEContextReleaseRequestIEs_t)); - ie->id = F1AP_ProtocolIE_ID_id_Cause; - ie->criticality = F1AP_Criticality_ignore; - ie->value.present = F1AP_UEContextReleaseRequestIEs__value_PR_Cause; + asn1cSequenceAdd(out->protocolIEs.list, F1AP_UEContextReleaseRequestIEs_t, ie3); + ie3->id = F1AP_ProtocolIE_ID_id_Cause; + ie3->criticality = F1AP_Criticality_ignore; + ie3->value.present = F1AP_UEContextReleaseRequestIEs__value_PR_Cause; switch (req->cause) { case F1AP_CAUSE_RADIO_NETWORK: - ie->value.choice.Cause.present = F1AP_Cause_PR_radioNetwork; - ie->value.choice.Cause.choice.radioNetwork = req->cause_value; + ie3->value.choice.Cause.present = F1AP_Cause_PR_radioNetwork; + ie3->value.choice.Cause.choice.radioNetwork = req->cause_value; break; case F1AP_CAUSE_TRANSPORT: - ie->value.choice.Cause.present = F1AP_Cause_PR_transport; - ie->value.choice.Cause.choice.transport = req->cause_value; + ie3->value.choice.Cause.present = F1AP_Cause_PR_transport; + ie3->value.choice.Cause.choice.transport = req->cause_value; break; case F1AP_CAUSE_PROTOCOL: - ie->value.choice.Cause.present = F1AP_Cause_PR_protocol; - ie->value.choice.Cause.choice.protocol = req->cause_value; + ie3->value.choice.Cause.present = F1AP_Cause_PR_protocol; + ie3->value.choice.Cause.choice.protocol = req->cause_value; break; case F1AP_CAUSE_MISC: - ie->value.choice.Cause.present = F1AP_Cause_PR_misc; - ie->value.choice.Cause.choice.misc = req->cause_value; + ie3->value.choice.Cause.present = F1AP_Cause_PR_misc; + ie3->value.choice.Cause.choice.misc = req->cause_value; break; case F1AP_CAUSE_NOTHING: default: - ie->value.choice.Cause.present = F1AP_Cause_PR_NOTHING; + ie3->value.choice.Cause.present = F1AP_Cause_PR_NOTHING; break; } - ASN_SEQUENCE_ADD(&out->protocolIEs.list, ie); - /* encode */ if (f1ap_encode_pdu(&pdu, &buffer, &len) < 0) { LOG_E(F1AP, "Failed to encode F1 context release request\n"); return -1; } - du_f1ap_itti_send_sctp_data_req(instance, - f1ap_du_data->assoc_id, - buffer, - len, - f1ap_du_data->default_sctp_stream_id); + f1ap_itti_send_sctp_data_req(false, instance, + buffer, + len, + getCxt(false, instance)->default_sctp_stream_id); return 0; } - - int DU_handle_UE_CONTEXT_RELEASE_COMMAND(instance_t instance, uint32_t assoc_id, uint32_t stream, @@ -645,21 +670,21 @@ int DU_handle_UE_CONTEXT_RELEASE_COMMAND(instance_t instance, /* GNB_CU_UE_F1AP_ID */ F1AP_FIND_PROTOCOLIE_BY_ID(F1AP_UEContextReleaseCommandIEs_t, ie, container, F1AP_ProtocolIE_ID_id_gNB_CU_UE_F1AP_ID, true); - ctxt.rnti = f1ap_get_rnti_by_cu_id(&f1ap_du_inst[instance], ie->value.choice.GNB_CU_UE_F1AP_ID); + ctxt.rnti = f1ap_get_rnti_by_cu_id(DUtype, instance, ie->value.choice.GNB_CU_UE_F1AP_ID); + ctxt.instance = instance; ctxt.module_id = instance; - ctxt.instance = instance; ctxt.enb_flag = 1; /* GNB_DU_UE_F1AP_ID */ F1AP_FIND_PROTOCOLIE_BY_ID(F1AP_UEContextReleaseCommandIEs_t, ie, container, F1AP_ProtocolIE_ID_id_gNB_DU_UE_F1AP_ID, true); - const rnti_t rnti = f1ap_get_rnti_by_du_id(&f1ap_du_inst[instance], + const rnti_t rnti = f1ap_get_rnti_by_du_id(DUtype, instance, ie->value.choice.GNB_DU_UE_F1AP_ID); AssertFatal(ctxt.rnti == rnti, "RNTI obtained through DU ID (%x) is different from CU ID (%x)\n", rnti, ctxt.rnti); int UE_out_of_sync = 0; - if (RC.nrrrc[instance]->node_type == ngran_gNB_DU) { + if (RC.nrrrc && RC.nrrrc[instance]->node_type == ngran_gNB_DU) { for (int n = 0; n < MAX_MOBILES_PER_GNB; ++n) { if (RC.nrmac[instance]->UE_info.active[n] == TRUE && rnti == RC.nrmac[instance]->UE_info.rnti[n]) { @@ -723,89 +748,81 @@ int DU_handle_UE_CONTEXT_RELEASE_COMMAND(instance_t instance, } } - if (RC.nrrrc[instance]->node_type == ngran_gNB_DU) { + if (RC.nrrrc && RC.nrrrc[instance]->node_type == ngran_gNB_DU) { // struct rrc_gNB_ue_context_s *ue_context_p; - f1ap_ue_context_release_cplt_t cplt; cplt.rnti = ctxt.rnti; DU_send_UE_CONTEXT_RELEASE_COMPLETE(instance, &cplt); return 0; - } - - struct rrc_eNB_ue_context_s *ue_context_p; - - ue_context_p = rrc_eNB_get_ue_context(RC.rrc[ctxt.module_id], ctxt.rnti); - - if (ue_context_p && !UE_out_of_sync) { - /* UE exists and is in sync so we start a timer before releasing the - * connection */ - pthread_mutex_lock(&rrc_release_freelist); - - for (uint16_t release_num = 0; release_num < NUMBER_OF_UE_MAX; release_num++) { - if (rrc_release_info.RRC_release_ctrl[release_num].flag == 0) { - if (ue_context_p->ue_context.ue_release_timer_s1 > 0) - rrc_release_info.RRC_release_ctrl[release_num].flag = 1; - else - rrc_release_info.RRC_release_ctrl[release_num].flag = 2; - - rrc_release_info.RRC_release_ctrl[release_num].rnti = ctxt.rnti; - LOG_D(F1AP, "add rrc_release_info RNTI %x\n", ctxt.rnti); - // TODO: how to provide the correct MUI? - rrc_release_info.RRC_release_ctrl[release_num].rrc_eNB_mui = 0; - rrc_release_info.num_UEs++; - LOG_D(RRC,"Generate DLSCH Release send: index %d rnti %x mui %d flag %d \n",release_num, - ctxt.rnti, 0, rrc_release_info.RRC_release_ctrl[release_num].flag); - break; + } else { + struct rrc_eNB_ue_context_s *ue_context_p; + ue_context_p = rrc_eNB_get_ue_context(RC.rrc[ctxt.instance], ctxt.rnti); + + if (ue_context_p && !UE_out_of_sync) { + /* UE exists and is in sync so we start a timer before releasing the + * connection */ + pthread_mutex_lock(&rrc_release_freelist); + + for (uint16_t release_num = 0; release_num < NUMBER_OF_UE_MAX; release_num++) { + if (rrc_release_info.RRC_release_ctrl[release_num].flag == 0) { + if (ue_context_p->ue_context.ue_release_timer_s1 > 0) + rrc_release_info.RRC_release_ctrl[release_num].flag = 1; + else + rrc_release_info.RRC_release_ctrl[release_num].flag = 2; + + rrc_release_info.RRC_release_ctrl[release_num].rnti = ctxt.rnti; + LOG_D(F1AP, "add rrc_release_info RNTI %x\n", ctxt.rnti); + // TODO: how to provide the correct MUI? + rrc_release_info.RRC_release_ctrl[release_num].rrc_eNB_mui = 0; + rrc_release_info.num_UEs++; + LOG_D(RRC,"Generate DLSCH Release send: index %d rnti %x mui %d flag %d \n",release_num, + ctxt.rnti, 0, rrc_release_info.RRC_release_ctrl[release_num].flag); + break; + } } + + pthread_mutex_unlock(&rrc_release_freelist); + ue_context_p->ue_context.ue_release_timer_s1 = 0; + } else if (ue_context_p && UE_out_of_sync) { + /* UE exists and is out of sync, drop the connection */ + mac_eNB_rrc_ul_failure(instance, 0, 0, 0, rnti); + } else { + LOG_E(F1AP, "no ue_context for RNTI %x, acknowledging release\n", rnti); } - pthread_mutex_unlock(&rrc_release_freelist); - ue_context_p->ue_context.ue_release_timer_s1 = 0; - } else if (ue_context_p && UE_out_of_sync) { - /* UE exists and is out of sync, drop the connection */ - mac_eNB_rrc_ul_failure(instance, 0, 0, 0, rnti); - } else { - LOG_E(F1AP, "no ue_context for RNTI %x, acknowledging release\n", rnti); + /* TODO send this once the connection has really been released */ + f1ap_ue_context_release_cplt_t cplt; + cplt.rnti = ctxt.rnti; + DU_send_UE_CONTEXT_RELEASE_COMPLETE(instance, &cplt); + return 0; } - - /* TODO send this once the connection has really been released */ - f1ap_ue_context_release_cplt_t cplt; - cplt.rnti = ctxt.rnti; - DU_send_UE_CONTEXT_RELEASE_COMPLETE(instance, &cplt); - return 0; } - - int DU_send_UE_CONTEXT_RELEASE_COMPLETE(instance_t instance, f1ap_ue_context_release_cplt_t *cplt) { - F1AP_F1AP_PDU_t pdu; + F1AP_F1AP_PDU_t pdu= {0}; F1AP_UEContextReleaseComplete_t *out; - F1AP_UEContextReleaseCompleteIEs_t *ie; /* Create */ /* 0. Message Type */ - memset(&pdu, 0, sizeof(pdu)); pdu.present = F1AP_F1AP_PDU_PR_successfulOutcome; - pdu.choice.successfulOutcome = (F1AP_SuccessfulOutcome_t *)calloc(1, sizeof(F1AP_SuccessfulOutcome_t)); - pdu.choice.successfulOutcome->procedureCode = F1AP_ProcedureCode_id_UEContextRelease; - pdu.choice.successfulOutcome->criticality = F1AP_Criticality_reject; - pdu.choice.successfulOutcome->value.present = F1AP_SuccessfulOutcome__value_PR_UEContextReleaseComplete; - out = &pdu.choice.successfulOutcome->value.choice.UEContextReleaseComplete; + asn1cCalloc(pdu.choice.successfulOutcome, tmp); + tmp->procedureCode = F1AP_ProcedureCode_id_UEContextRelease; + tmp->criticality = F1AP_Criticality_reject; + tmp->value.present = F1AP_SuccessfulOutcome__value_PR_UEContextReleaseComplete; + out = &tmp->value.choice.UEContextReleaseComplete; /* mandatory */ /* c1. GNB_CU_UE_F1AP_ID */ - ie = (F1AP_UEContextReleaseCompleteIEs_t *)calloc(1, sizeof(F1AP_UEContextReleaseCompleteIEs_t)); - ie->id = F1AP_ProtocolIE_ID_id_gNB_CU_UE_F1AP_ID; - ie->criticality = F1AP_Criticality_reject; - ie->value.present = F1AP_UEContextReleaseCompleteIEs__value_PR_GNB_CU_UE_F1AP_ID; - ie->value.choice.GNB_CU_UE_F1AP_ID = f1ap_get_cu_ue_f1ap_id(&f1ap_du_inst[instance], cplt->rnti); - ASN_SEQUENCE_ADD(&out->protocolIEs.list, ie); + asn1cSequenceAdd(out->protocolIEs.list, F1AP_UEContextReleaseCompleteIEs_t, ie1); + ie1->id = F1AP_ProtocolIE_ID_id_gNB_CU_UE_F1AP_ID; + ie1->criticality = F1AP_Criticality_reject; + ie1->value.present = F1AP_UEContextReleaseCompleteIEs__value_PR_GNB_CU_UE_F1AP_ID; + ie1->value.choice.GNB_CU_UE_F1AP_ID = f1ap_get_cu_ue_f1ap_id(DUtype, instance, cplt->rnti); /* mandatory */ /* c2. GNB_DU_UE_F1AP_ID */ - ie = (F1AP_UEContextReleaseCompleteIEs_t *)calloc(1, sizeof(F1AP_UEContextReleaseCompleteIEs_t)); - ie->id = F1AP_ProtocolIE_ID_id_gNB_DU_UE_F1AP_ID; - ie->criticality = F1AP_Criticality_reject; - ie->value.present = F1AP_UEContextReleaseCompleteIEs__value_PR_GNB_DU_UE_F1AP_ID; - ie->value.choice.GNB_DU_UE_F1AP_ID = f1ap_get_du_ue_f1ap_id(&f1ap_du_inst[instance], cplt->rnti); - ASN_SEQUENCE_ADD(&out->protocolIEs.list, ie); + asn1cSequenceAdd(out->protocolIEs.list,F1AP_UEContextReleaseCompleteIEs_t, ie2); + ie2->id = F1AP_ProtocolIE_ID_id_gNB_DU_UE_F1AP_ID; + ie2->criticality = F1AP_Criticality_reject; + ie2->value.present = F1AP_UEContextReleaseCompleteIEs__value_PR_GNB_DU_UE_F1AP_ID; + ie2->value.choice.GNB_DU_UE_F1AP_ID = f1ap_get_du_ue_f1ap_id(DUtype, instance, cplt->rnti); /* optional -> currently not used */ /* c3. CriticalityDiagnostics */ //if (0) { @@ -863,365 +880,288 @@ int DU_send_UE_CONTEXT_RELEASE_COMPLETE(instance_t instance, return -1; } - du_f1ap_itti_send_sctp_data_req(instance, - f1ap_du_data->assoc_id, - buffer, - len, - f1ap_du_data->default_sctp_stream_id); - f1ap_remove_ue(&f1ap_du_inst[instance], cplt->rnti); + f1ap_itti_send_sctp_data_req(false, instance, + buffer, + len, + getCxt(false, instance)->default_sctp_stream_id); + f1ap_remove_ue(DUtype, instance, cplt->rnti); return 0; } - - int DU_handle_UE_CONTEXT_MODIFICATION_REQUEST(instance_t instance, uint32_t assoc_id, uint32_t stream, F1AP_F1AP_PDU_t *pdu) { AssertFatal(1==0,"Not implemented yet\n"); } - //void DU_send_UE_CONTEXT_MODIFICATION_RESPONSE(F1AP_UEContextModificationResponse_t *UEContextModificationResponse) { int DU_send_UE_CONTEXT_MODIFICATION_RESPONSE(instance_t instance) { - F1AP_F1AP_PDU_t pdu; + F1AP_F1AP_PDU_t pdu= {0}; F1AP_UEContextModificationResponse_t *out; - F1AP_UEContextModificationResponseIEs_t *ie; - uint8_t *buffer; - uint32_t len; - int i = 0; + uint8_t *buffer=NULL; + uint32_t len=0; /* Create */ /* 0. Message Type */ - memset(&pdu, 0, sizeof(pdu)); pdu.present = F1AP_F1AP_PDU_PR_successfulOutcome; - pdu.choice.successfulOutcome = (F1AP_SuccessfulOutcome_t *)calloc(1, sizeof(F1AP_SuccessfulOutcome_t)); - pdu.choice.successfulOutcome->procedureCode = F1AP_ProcedureCode_id_UEContextModification; - pdu.choice.successfulOutcome->criticality = F1AP_Criticality_reject; - pdu.choice.successfulOutcome->value.present = F1AP_SuccessfulOutcome__value_PR_UEContextModificationResponse; - out = &pdu.choice.successfulOutcome->value.choice.UEContextModificationResponse; + asn1cCalloc(pdu.choice.successfulOutcome,tmp); + tmp->procedureCode = F1AP_ProcedureCode_id_UEContextModification; + tmp->criticality = F1AP_Criticality_reject; + tmp->value.present = F1AP_SuccessfulOutcome__value_PR_UEContextModificationResponse; + out = &tmp->value.choice.UEContextModificationResponse; /* mandatory */ /* c1. GNB_CU_UE_F1AP_ID */ - ie = (F1AP_UEContextModificationResponseIEs_t *)calloc(1, sizeof(F1AP_UEContextModificationResponseIEs_t)); - ie->id = F1AP_ProtocolIE_ID_id_gNB_CU_UE_F1AP_ID; - ie->criticality = F1AP_Criticality_reject; - ie->value.present = F1AP_UEContextModificationResponseIEs__value_PR_GNB_CU_UE_F1AP_ID; - ie->value.choice.GNB_CU_UE_F1AP_ID = 126L; - ASN_SEQUENCE_ADD(&out->protocolIEs.list, ie); + asn1cSequenceAdd(out->protocolIEs.list, F1AP_UEContextModificationResponseIEs_t, ie1); + ie1->id = F1AP_ProtocolIE_ID_id_gNB_CU_UE_F1AP_ID; + ie1->criticality = F1AP_Criticality_reject; + ie1->value.present = F1AP_UEContextModificationResponseIEs__value_PR_GNB_CU_UE_F1AP_ID; + ie1->value.choice.GNB_CU_UE_F1AP_ID = 126L; /* mandatory */ /* c2. GNB_DU_UE_F1AP_ID */ - ie = (F1AP_UEContextModificationResponseIEs_t *)calloc(1, sizeof(F1AP_UEContextModificationResponseIEs_t)); - ie->id = F1AP_ProtocolIE_ID_id_gNB_DU_UE_F1AP_ID; - ie->criticality = F1AP_Criticality_reject; - ie->value.present = F1AP_UEContextModificationResponseIEs__value_PR_GNB_DU_UE_F1AP_ID; - ie->value.choice.GNB_DU_UE_F1AP_ID = 651L; - ASN_SEQUENCE_ADD(&out->protocolIEs.list, ie); + asn1cSequenceAdd(out->protocolIEs.list, F1AP_UEContextModificationResponseIEs_t, ie2); + ie2->id = F1AP_ProtocolIE_ID_id_gNB_DU_UE_F1AP_ID; + ie2->criticality = F1AP_Criticality_reject; + ie2->value.present = F1AP_UEContextModificationResponseIEs__value_PR_GNB_DU_UE_F1AP_ID; + ie2->value.choice.GNB_DU_UE_F1AP_ID = 651L; /* optional */ /* c3. ResourceCoordinationTransferContainer */ if (0) { - ie = (F1AP_UEContextModificationResponseIEs_t *)calloc(1, sizeof(F1AP_UEContextModificationResponseIEs_t)); - ie->id = F1AP_ProtocolIE_ID_id_ResourceCoordinationTransferContainer; - ie->criticality = F1AP_Criticality_ignore; - ie->value.present = F1AP_UEContextModificationResponseIEs__value_PR_ResourceCoordinationTransferContainer; - OCTET_STRING_fromBuf(&ie->value.choice.ResourceCoordinationTransferContainer, "asdsa1d32sa1d31asd31as", + asn1cSequenceAdd(out->protocolIEs.list, F1AP_UEContextModificationResponseIEs_t, ie3); + ie3->id = F1AP_ProtocolIE_ID_id_ResourceCoordinationTransferContainer; + ie3->criticality = F1AP_Criticality_ignore; + ie3->value.present = F1AP_UEContextModificationResponseIEs__value_PR_ResourceCoordinationTransferContainer; + OCTET_STRING_fromBuf(&ie3->value.choice.ResourceCoordinationTransferContainer, "asdsa1d32sa1d31asd31as", strlen("asdsa1d32sa1d31asd31as")); - ASN_SEQUENCE_ADD(&out->protocolIEs.list, ie); } /* optional */ /* c4. DUtoCURRCInformation */ if (0) { - ie = (F1AP_UEContextModificationResponseIEs_t *)calloc(1, sizeof(F1AP_UEContextModificationResponseIEs_t)); - ie->id = F1AP_ProtocolIE_ID_id_DUtoCURRCInformation; - ie->criticality = F1AP_Criticality_reject; - ie->value.present = F1AP_UEContextModificationResponseIEs__value_PR_DUtoCURRCInformation; - OCTET_STRING_fromBuf(&ie->value.choice.DUtoCURRCInformation.cellGroupConfig, "asdsa1d32sa1d31asd31as", + asn1cSequenceAdd(out->protocolIEs.list, F1AP_UEContextModificationResponseIEs_t, ie4); + ie4->id = F1AP_ProtocolIE_ID_id_DUtoCURRCInformation; + ie4->criticality = F1AP_Criticality_reject; + ie4->value.present = F1AP_UEContextModificationResponseIEs__value_PR_DUtoCURRCInformation; + OCTET_STRING_fromBuf(&ie4->value.choice.DUtoCURRCInformation.cellGroupConfig, "asdsa1d32sa1d31asd31as", strlen("asdsa1d32sa1d31asd31as")); /* OPTIONAL */ if (1) { - ie->value.choice.DUtoCURRCInformation.measGapConfig = (F1AP_MeasGapConfig_t *)calloc(1, sizeof(F1AP_MeasGapConfig_t)); - OCTET_STRING_fromBuf( ie->value.choice.DUtoCURRCInformation.measGapConfig, "asdsa1d32sa1d31asd31as", + asn1cSequenceAdd(out->protocolIEs.list, F1AP_UEContextModificationResponseIEs_t, ie41); + ie41->value.choice.DUtoCURRCInformation.measGapConfig = (F1AP_MeasGapConfig_t *)calloc(1, sizeof(F1AP_MeasGapConfig_t)); + OCTET_STRING_fromBuf( ie41->value.choice.DUtoCURRCInformation.measGapConfig, "asdsa1d32sa1d31asd31as", strlen("asdsa1d32sa1d31asd31as")); - ASN_SEQUENCE_ADD(&out->protocolIEs.list, ie); } } /* mandatory */ /* c5. DRBs_SetupMod_List */ - ie = (F1AP_UEContextModificationResponseIEs_t *)calloc(1, sizeof(F1AP_UEContextModificationResponseIEs_t)); - ie->id = F1AP_ProtocolIE_ID_id_DRBs_SetupMod_List; - ie->criticality = F1AP_Criticality_reject; - ie->value.present = F1AP_UEContextModificationResponseIEs__value_PR_DRBs_SetupMod_List; - - for (i=0; - i<1; - i++) { + asn1cSequenceAdd(out->protocolIEs.list, F1AP_UEContextModificationResponseIEs_t, ie5); + ie5->id = F1AP_ProtocolIE_ID_id_DRBs_SetupMod_List; + ie5->criticality = F1AP_Criticality_reject; + ie5->value.present = F1AP_UEContextModificationResponseIEs__value_PR_DRBs_SetupMod_List; + + for (int i=0; i<1; i++) { // - F1AP_DRBs_SetupMod_ItemIEs_t *drbs_setupMod_item_ies; - drbs_setupMod_item_ies = (F1AP_DRBs_SetupMod_ItemIEs_t *)calloc(1, sizeof(F1AP_DRBs_SetupMod_ItemIEs_t)); + asn1cSequenceAdd(ie5->value.choice.DRBs_SetupMod_List.list, + F1AP_DRBs_SetupMod_ItemIEs_t, drbs_setupMod_item_ies); drbs_setupMod_item_ies->id = F1AP_ProtocolIE_ID_id_DRBs_SetupMod_Item; drbs_setupMod_item_ies->criticality = F1AP_Criticality_reject; drbs_setupMod_item_ies->value.present = F1AP_DRBs_SetupMod_ItemIEs__value_PR_DRBs_SetupMod_Item; /* 10.1 DRBs_SetupMod_Item */ - F1AP_DRBs_SetupMod_Item_t drbs_setupMod_item; - memset((void *)&drbs_setupMod_item, 0, sizeof(F1AP_DRBs_SetupMod_Item_t)); + F1AP_DRBs_SetupMod_Item_t *drbs_setupMod_item=&drbs_setupMod_item_ies->value.choice.DRBs_SetupMod_Item; /* dRBID */ - drbs_setupMod_item.dRBID = 30L; + drbs_setupMod_item->dRBID = 30L; /* DLTunnels_SetupMod_List */ - int j = 0; int maxnoofDLUPTNLInformation = 1; // 2; - for (j=0; - j<maxnoofDLUPTNLInformation; - j++) { + for (int j=0; j<maxnoofDLUPTNLInformation; j++) { /* DLTunnels_ToBeSetup_Item */ - F1AP_DLUPTNLInformation_ToBeSetup_Item_t *dLUPTNLInformation_ToBeSetup_Item; - dLUPTNLInformation_ToBeSetup_Item = (F1AP_DLUPTNLInformation_ToBeSetup_Item_t *)calloc(1, sizeof(F1AP_DLUPTNLInformation_ToBeSetup_Item_t)); + asn1cSequenceAdd(ie5->value.choice.DRBs_SetupMod_List.list, + F1AP_DLUPTNLInformation_ToBeSetup_Item_t, dLUPTNLInformation_ToBeSetup_Item); dLUPTNLInformation_ToBeSetup_Item->dLUPTNLInformation.present = F1AP_UPTransportLayerInformation_PR_gTPTunnel; - F1AP_GTPTunnel_t *gTPTunnel = (F1AP_GTPTunnel_t *)calloc(1, sizeof(F1AP_GTPTunnel_t)); + asn1cCalloc(dLUPTNLInformation_ToBeSetup_Item->dLUPTNLInformation.choice.gTPTunnel, + gTPTunnel); TRANSPORT_LAYER_ADDRESS_IPv4_TO_BIT_STRING(1234, &gTPTunnel->transportLayerAddress); OCTET_STRING_fromBuf(&gTPTunnel->gTP_TEID, "1204", strlen("1204")); - dLUPTNLInformation_ToBeSetup_Item->dLUPTNLInformation.choice.gTPTunnel = gTPTunnel; - ASN_SEQUENCE_ADD(&drbs_setupMod_item.dLUPTNLInformation_ToBeSetup_List.list, dLUPTNLInformation_ToBeSetup_Item); } - - /* ADD */ - drbs_setupMod_item_ies->value.choice.DRBs_SetupMod_Item = drbs_setupMod_item; - ASN_SEQUENCE_ADD(&ie->value.choice.DRBs_SetupMod_List.list, - drbs_setupMod_item_ies); } - ASN_SEQUENCE_ADD(&out->protocolIEs.list, ie); /* mandatory */ /* c6. DRBs_Modified_List */ - ie = (F1AP_UEContextModificationResponseIEs_t *)calloc(1, sizeof(F1AP_UEContextModificationResponseIEs_t)); - ie->id = F1AP_ProtocolIE_ID_id_DRBs_Modified_List; - ie->criticality = F1AP_Criticality_reject; - ie->value.present = F1AP_UEContextModificationResponseIEs__value_PR_DRBs_Modified_List; - - for (i=0; - i<1; - i++) { + asn1cSequenceAdd(out->protocolIEs.list, F1AP_UEContextModificationResponseIEs_t, ie6); + ie6->id = F1AP_ProtocolIE_ID_id_DRBs_Modified_List; + ie6->criticality = F1AP_Criticality_reject; + ie6->value.present = F1AP_UEContextModificationResponseIEs__value_PR_DRBs_Modified_List; + + for (int i=0; i<1; i++) { // - F1AP_DRBs_Modified_ItemIEs_t *drbs_modified_item_ies; - drbs_modified_item_ies = (F1AP_DRBs_Modified_ItemIEs_t *)calloc(1, sizeof(F1AP_DRBs_Modified_ItemIEs_t)); + asn1cSequenceAdd(ie6->value.choice.DRBs_Modified_List.list, + F1AP_DRBs_Modified_ItemIEs_t, drbs_modified_item_ies); drbs_modified_item_ies->id = F1AP_ProtocolIE_ID_id_DRBs_Modified_Item; drbs_modified_item_ies->criticality = F1AP_Criticality_reject; drbs_modified_item_ies->value.present = F1AP_DRBs_Modified_ItemIEs__value_PR_DRBs_Modified_Item; /* 13.1 SRBs_modified_Item */ - F1AP_DRBs_Modified_Item_t drbs_modified_item; - memset((void *)&drbs_modified_item, 0, sizeof(F1AP_DRBs_Modified_Item_t)); + F1AP_DRBs_Modified_Item_t *drbs_modified_item= + &drbs_modified_item_ies->value.choice.DRBs_Modified_Item; /* dRBID */ - drbs_modified_item.dRBID = 25L; + drbs_modified_item->dRBID = 25L; /* ULTunnels_Modified_List */ int maxnoofULTunnels = 1; // 2; - int j = 0; - for (j=0; - j<maxnoofULTunnels; - j++) { + for (int j=0; j<maxnoofULTunnels; j++) { /* DLTunnels_Modified_Item */ - F1AP_DLUPTNLInformation_ToBeSetup_Item_t *dLUPTNLInformation_ToBeSetup_Item; - dLUPTNLInformation_ToBeSetup_Item = (F1AP_DLUPTNLInformation_ToBeSetup_Item_t *)calloc(1, sizeof(F1AP_DLUPTNLInformation_ToBeSetup_Item_t)); - dLUPTNLInformation_ToBeSetup_Item->dLUPTNLInformation.present = F1AP_UPTransportLayerInformation_PR_gTPTunnel; - F1AP_GTPTunnel_t *gTPTunnel = (F1AP_GTPTunnel_t *)calloc(1, sizeof(F1AP_GTPTunnel_t)); + asn1cSequenceAdd(drbs_modified_item->dLUPTNLInformation_ToBeSetup_List.list, + F1AP_DLUPTNLInformation_ToBeSetup_Item_t, dLUPTNLInformation_ToBeSetup_Item); + asn1cCalloc(dLUPTNLInformation_ToBeSetup_Item, tmp); + tmp->dLUPTNLInformation.present = F1AP_UPTransportLayerInformation_PR_gTPTunnel; + asn1cCalloc(dLUPTNLInformation_ToBeSetup_Item->dLUPTNLInformation.choice.gTPTunnel, gTPTunnel); TRANSPORT_LAYER_ADDRESS_IPv4_TO_BIT_STRING(1234, &gTPTunnel->transportLayerAddress); - OCTET_STRING_fromBuf(&gTPTunnel->gTP_TEID, "1204", - strlen("1204")); - dLUPTNLInformation_ToBeSetup_Item->dLUPTNLInformation.choice.gTPTunnel = gTPTunnel; - ASN_SEQUENCE_ADD(&drbs_modified_item.dLUPTNLInformation_ToBeSetup_List.list, dLUPTNLInformation_ToBeSetup_Item); + OCTET_STRING_fromBuf(&gTPTunnel->gTP_TEID, "1204", strlen("1204")); } - - /* ADD */ - drbs_modified_item_ies->value.choice.DRBs_Modified_Item = drbs_modified_item; - ASN_SEQUENCE_ADD(&ie->value.choice.DRBs_Modified_List.list, - drbs_modified_item_ies); } - ASN_SEQUENCE_ADD(&out->protocolIEs.list, ie); /* mandatory */ /* c7. SRBs_FailedToBeSetupMod_List */ - ie = (F1AP_UEContextModificationResponseIEs_t *)calloc(1, sizeof(F1AP_UEContextModificationResponseIEs_t)); - ie->id = F1AP_ProtocolIE_ID_id_SRBs_FailedToBeSetupMod_List; - ie->criticality = F1AP_Criticality_reject; - ie->value.present = F1AP_UEContextModificationResponseIEs__value_PR_SRBs_FailedToBeSetupMod_List; - - for (i=0; - i<1; - i++) { + asn1cSequenceAdd(out->protocolIEs.list, F1AP_UEContextModificationResponseIEs_t, ie7); + ie7->id = F1AP_ProtocolIE_ID_id_SRBs_FailedToBeSetupMod_List; + ie7->criticality = F1AP_Criticality_reject; + ie7->value.present = F1AP_UEContextModificationResponseIEs__value_PR_SRBs_FailedToBeSetupMod_List; + + for (int i=0; i<1; i++) { // - F1AP_SRBs_FailedToBeSetupMod_ItemIEs_t *srbs_failedToBeSetupMod_item_ies; - srbs_failedToBeSetupMod_item_ies = (F1AP_SRBs_FailedToBeSetupMod_ItemIEs_t *)calloc(1, sizeof(F1AP_SRBs_FailedToBeSetupMod_ItemIEs_t)); + asn1cSequenceAdd(ie7->value.choice.SRBs_FailedToBeSetupMod_List.list, + F1AP_SRBs_FailedToBeSetupMod_ItemIEs_t, srbs_failedToBeSetupMod_item_ies); srbs_failedToBeSetupMod_item_ies->id = F1AP_ProtocolIE_ID_id_SRBs_FailedToBeSetupMod_Item; srbs_failedToBeSetupMod_item_ies->criticality = F1AP_Criticality_ignore; srbs_failedToBeSetupMod_item_ies->value.present = F1AP_SRBs_FailedToBeSetupMod_ItemIEs__value_PR_SRBs_FailedToBeSetupMod_Item; /* 9.1 SRBs_FailedToBeSetupMod_Item */ - F1AP_SRBs_FailedToBeSetupMod_Item_t srbs_failedToBeSetupMod_item; - memset((void *)&srbs_failedToBeSetupMod_item, 0, sizeof(F1AP_SRBs_FailedToBeSetupMod_Item_t)); + F1AP_SRBs_FailedToBeSetupMod_Item_t *srbs_failedToBeSetupMod_item= + &srbs_failedToBeSetupMod_item_ies->value.choice.SRBs_FailedToBeSetupMod_Item; /* - sRBID */ - srbs_failedToBeSetupMod_item.sRBID = 50L; - srbs_failedToBeSetupMod_item.cause = (F1AP_Cause_t *)calloc(1, sizeof(F1AP_Cause_t)); - srbs_failedToBeSetupMod_item.cause->present = F1AP_Cause_PR_radioNetwork; - srbs_failedToBeSetupMod_item.cause->choice.radioNetwork = F1AP_CauseRadioNetwork_unknown_or_already_allocated_gnb_du_ue_f1ap_id; - /* ADD */ - srbs_failedToBeSetupMod_item_ies->value.choice.SRBs_FailedToBeSetupMod_Item = srbs_failedToBeSetupMod_item; - ASN_SEQUENCE_ADD(&ie->value.choice.SRBs_FailedToBeSetupMod_List.list, - srbs_failedToBeSetupMod_item_ies); + srbs_failedToBeSetupMod_item->sRBID = 50L; + asn1cCalloc(srbs_failedToBeSetupMod_item->cause, tmp) + tmp->present = F1AP_Cause_PR_radioNetwork; + tmp->choice.radioNetwork = F1AP_CauseRadioNetwork_unknown_or_already_allocated_gnb_du_ue_f1ap_id; } - ASN_SEQUENCE_ADD(&out->protocolIEs.list, ie); /* mandatory */ /* c8. DRBs_FailedToBeSetupMod_List */ - ie = (F1AP_UEContextModificationResponseIEs_t *)calloc(1, sizeof(F1AP_UEContextModificationResponseIEs_t)); - ie->id = F1AP_ProtocolIE_ID_id_DRBs_FailedToBeSetupMod_List; - ie->criticality = F1AP_Criticality_reject; - ie->value.present = F1AP_UEContextModificationResponseIEs__value_PR_DRBs_FailedToBeSetupMod_List; - - for (i=0; - i<1; - i++) { + asn1cSequenceAdd(out->protocolIEs.list, F1AP_UEContextModificationResponseIEs_t, ie8); + ie8->id = F1AP_ProtocolIE_ID_id_DRBs_FailedToBeSetupMod_List; + ie8->criticality = F1AP_Criticality_reject; + ie8->value.present = F1AP_UEContextModificationResponseIEs__value_PR_DRBs_FailedToBeSetupMod_List; + + for (int i=0; i<1; i++) { // - F1AP_DRBs_FailedToBeSetupMod_ItemIEs_t *drbs_failedToBeSetupMod_item_ies; - drbs_failedToBeSetupMod_item_ies = (F1AP_DRBs_FailedToBeSetupMod_ItemIEs_t *)calloc(1, sizeof(F1AP_DRBs_FailedToBeSetupMod_ItemIEs_t)); + asn1cSequenceAdd(ie8->value.choice.DRBs_FailedToBeSetupMod_List.list, + F1AP_DRBs_FailedToBeSetupMod_ItemIEs_t, drbs_failedToBeSetupMod_item_ies); drbs_failedToBeSetupMod_item_ies->id = F1AP_ProtocolIE_ID_id_DRBs_FailedToBeSetupMod_Item; drbs_failedToBeSetupMod_item_ies->criticality = F1AP_Criticality_reject; drbs_failedToBeSetupMod_item_ies->value.present = F1AP_DRBs_FailedToBeSetupMod_ItemIEs__value_PR_DRBs_FailedToBeSetupMod_Item; /* 10.1 DRBs_ToBeSetupMod_Item */ - F1AP_DRBs_FailedToBeSetupMod_Item_t drbs_failedToBeSetupMod_item; - memset((void *)&drbs_failedToBeSetupMod_item, 0, sizeof(F1AP_DRBs_FailedToBeSetupMod_Item_t)); + F1AP_DRBs_FailedToBeSetupMod_Item_t *drbs_failedToBeSetupMod_item= + &drbs_failedToBeSetupMod_item_ies->value.choice.DRBs_FailedToBeSetupMod_Item; /* dRBID */ - drbs_failedToBeSetupMod_item.dRBID = 30L; - drbs_failedToBeSetupMod_item.cause = (F1AP_Cause_t *)calloc(1, sizeof(F1AP_Cause_t)); - drbs_failedToBeSetupMod_item.cause->present = F1AP_Cause_PR_radioNetwork; - drbs_failedToBeSetupMod_item.cause->choice.radioNetwork = F1AP_CauseRadioNetwork_unknown_or_already_allocated_gnb_du_ue_f1ap_id; - /* ADD */ - drbs_failedToBeSetupMod_item_ies->value.choice.DRBs_FailedToBeSetupMod_Item = drbs_failedToBeSetupMod_item; - ASN_SEQUENCE_ADD(&ie->value.choice.DRBs_FailedToBeSetupMod_List.list, - drbs_failedToBeSetupMod_item_ies); + drbs_failedToBeSetupMod_item->dRBID = 30L; + drbs_failedToBeSetupMod_item->cause = (F1AP_Cause_t *)calloc(1, sizeof(F1AP_Cause_t)); + drbs_failedToBeSetupMod_item->cause->present = F1AP_Cause_PR_radioNetwork; + drbs_failedToBeSetupMod_item->cause->choice.radioNetwork = F1AP_CauseRadioNetwork_unknown_or_already_allocated_gnb_du_ue_f1ap_id; } - ASN_SEQUENCE_ADD(&out->protocolIEs.list, ie); /* mandatory */ /* c9. SCell_FailedtoSetupMod_List */ - ie = (F1AP_UEContextModificationResponseIEs_t *)calloc(1, sizeof(F1AP_UEContextModificationResponseIEs_t)); - ie->id = F1AP_ProtocolIE_ID_id_SCell_FailedtoSetupMod_List; - ie->criticality = F1AP_Criticality_ignore; - ie->value.present = F1AP_UEContextModificationResponseIEs__value_PR_SCell_FailedtoSetupMod_List; - - for (i=0; - i<1; - i++) { + asn1cSequenceAdd(out->protocolIEs.list, F1AP_UEContextModificationResponseIEs_t, ie9); + ie9->id = F1AP_ProtocolIE_ID_id_SCell_FailedtoSetupMod_List; + ie9->criticality = F1AP_Criticality_ignore; + ie9->value.present = F1AP_UEContextModificationResponseIEs__value_PR_SCell_FailedtoSetupMod_List; + + for (int i=0; i<1; i++) { // - F1AP_SCell_FailedtoSetupMod_ItemIEs_t *scell_failedtoSetupMod_item_ies; - scell_failedtoSetupMod_item_ies = (F1AP_SCell_FailedtoSetupMod_ItemIEs_t *)calloc(1, sizeof(F1AP_SCell_FailedtoSetupMod_ItemIEs_t)); + asn1cSequenceAdd(ie9->value.choice.SCell_FailedtoSetupMod_List.list, + F1AP_SCell_FailedtoSetupMod_ItemIEs_t, scell_failedtoSetupMod_item_ies); scell_failedtoSetupMod_item_ies->id = F1AP_ProtocolIE_ID_id_SCell_FailedtoSetupMod_Item; scell_failedtoSetupMod_item_ies->criticality = F1AP_Criticality_ignore; scell_failedtoSetupMod_item_ies->value.present = F1AP_SCell_FailedtoSetupMod_ItemIEs__value_PR_SCell_FailedtoSetupMod_Item; /* 8.1 SCell_ToBeSetup_Item */ - F1AP_SCell_FailedtoSetupMod_Item_t scell_failedtoSetupMod_item; - memset((void *)&scell_failedtoSetupMod_item, 0, sizeof(F1AP_SCell_FailedtoSetupMod_Item_t)); + F1AP_SCell_FailedtoSetupMod_Item_t *scell_failedtoSetupMod_item=&scell_failedtoSetupMod_item_ies->value.choice.SCell_FailedtoSetupMod_Item; /* - sCell_ID */ - F1AP_NRCGI_t nRCGI; - memset(&nRCGI, 0, sizeof(F1AP_NRCGI_t)); - MCC_MNC_TO_PLMNID(f1ap_du_data->mcc[i], f1ap_du_data->mnc[i], f1ap_du_data->mnc_digit_length[i], - &nRCGI.pLMN_Identity); - NR_CELL_ID_TO_BIT_STRING(f1ap_du_data->nr_cellid[0], &nRCGI.nRCellIdentity); - scell_failedtoSetupMod_item.sCell_ID = nRCGI; - scell_failedtoSetupMod_item.cause = (F1AP_Cause_t *)calloc(1, sizeof(F1AP_Cause_t)); - scell_failedtoSetupMod_item.cause->present = F1AP_Cause_PR_radioNetwork; - scell_failedtoSetupMod_item.cause->choice.radioNetwork = F1AP_CauseRadioNetwork_unknown_or_already_allocated_gnb_du_ue_f1ap_id; - /* ADD */ - scell_failedtoSetupMod_item_ies->value.choice.SCell_FailedtoSetupMod_Item = scell_failedtoSetupMod_item; - ASN_SEQUENCE_ADD(&ie->value.choice.SCell_FailedtoSetupMod_List.list, - scell_failedtoSetupMod_item_ies); + addnRCGI(scell_failedtoSetupMod_item->sCell_ID, &f1ap_req(false, instance)->cell[i]); + asn1cCalloc(scell_failedtoSetupMod_item->cause, tmp); + tmp->present = F1AP_Cause_PR_radioNetwork; + tmp->choice.radioNetwork = F1AP_CauseRadioNetwork_unknown_or_already_allocated_gnb_du_ue_f1ap_id; } - ASN_SEQUENCE_ADD(&out->protocolIEs.list, ie); /* mandatory */ /* c10. DRBs_FailedToBeModified_List */ - ie = (F1AP_UEContextModificationResponseIEs_t *)calloc(1, sizeof(F1AP_UEContextModificationResponseIEs_t)); - ie->id = F1AP_ProtocolIE_ID_id_DRBs_FailedToBeModified_List; - ie->criticality = F1AP_Criticality_reject; - ie->value.present = F1AP_UEContextModificationResponseIEs__value_PR_DRBs_FailedToBeModified_List; - - for (i=0; - i<1; - i++) { + asn1cSequenceAdd(out->protocolIEs.list, F1AP_UEContextModificationResponseIEs_t, ie10); + ie10->id = F1AP_ProtocolIE_ID_id_DRBs_FailedToBeModified_List; + ie10->criticality = F1AP_Criticality_reject; + ie10->value.present = F1AP_UEContextModificationResponseIEs__value_PR_DRBs_FailedToBeModified_List; + + for (int i=0; i<1; i++) { // - F1AP_DRBs_FailedToBeModified_ItemIEs_t *drbs_failedToBeModified_item_ies; - drbs_failedToBeModified_item_ies = (F1AP_DRBs_FailedToBeModified_ItemIEs_t *)calloc(1, sizeof(F1AP_DRBs_FailedToBeModified_ItemIEs_t)); + asn1cSequenceAdd(ie10->value.choice.DRBs_FailedToBeModified_List.list, + F1AP_DRBs_FailedToBeModified_ItemIEs_t, drbs_failedToBeModified_item_ies); drbs_failedToBeModified_item_ies->id = F1AP_ProtocolIE_ID_id_DRBs_FailedToBeModified_Item; drbs_failedToBeModified_item_ies->criticality = F1AP_Criticality_reject; drbs_failedToBeModified_item_ies->value.present = F1AP_DRBs_FailedToBeModified_ItemIEs__value_PR_DRBs_FailedToBeModified_Item; /* 13.1 DRBs_FailedToBeModified_Item */ - F1AP_DRBs_FailedToBeModified_Item_t drbs_failedToBeModified_item; - memset((void *)&drbs_failedToBeModified_item, 0, sizeof(F1AP_DRBs_FailedToBeModified_Item_t)); + F1AP_DRBs_FailedToBeModified_Item_t *drbs_failedToBeModified_item= + &drbs_failedToBeModified_item_ies->value.choice.DRBs_FailedToBeModified_Item ; /* dRBID */ - drbs_failedToBeModified_item.dRBID = 30L; - drbs_failedToBeModified_item.cause = (F1AP_Cause_t *)calloc(1, sizeof(F1AP_Cause_t)); - drbs_failedToBeModified_item.cause->present = F1AP_Cause_PR_radioNetwork; - drbs_failedToBeModified_item.cause->choice.radioNetwork = F1AP_CauseRadioNetwork_unknown_or_already_allocated_gnb_du_ue_f1ap_id; - /* ADD */ - drbs_failedToBeModified_item_ies->value.choice.DRBs_FailedToBeModified_Item = drbs_failedToBeModified_item; - ASN_SEQUENCE_ADD(&ie->value.choice.DRBs_FailedToBeModified_List.list, - drbs_failedToBeModified_item_ies); + drbs_failedToBeModified_item->dRBID = 30L; + asn1cCalloc(drbs_failedToBeModified_item->cause, tmp); + tmp->present = F1AP_Cause_PR_radioNetwork; + tmp->choice.radioNetwork = F1AP_CauseRadioNetwork_unknown_or_already_allocated_gnb_du_ue_f1ap_id; } - ASN_SEQUENCE_ADD(&out->protocolIEs.list, ie); - // /* */ /* c11. CriticalityDiagnostics */ if (0) { - ie = (F1AP_UEContextModificationResponseIEs_t *)calloc(1, sizeof(F1AP_UEContextModificationResponseIEs_t)); - ie->id = F1AP_ProtocolIE_ID_id_CriticalityDiagnostics; - ie->criticality = F1AP_Criticality_ignore; - ie->value.present = F1AP_UEContextModificationResponseIEs__value_PR_CriticalityDiagnostics; + asn1cSequenceAdd(out->protocolIEs.list, F1AP_UEContextModificationResponseIEs_t, ie11); + ie11->id = F1AP_ProtocolIE_ID_id_CriticalityDiagnostics; + ie11->criticality = F1AP_Criticality_ignore; + ie11->value.present = F1AP_UEContextModificationResponseIEs__value_PR_CriticalityDiagnostics; // dummy value /* optional */ /* procedureCode */ if (0) { - ie->value.choice.CriticalityDiagnostics.procedureCode = (F1AP_ProcedureCode_t *)calloc(1, sizeof(F1AP_ProcedureCode_t)); - ie->value.choice.CriticalityDiagnostics.procedureCode = 0L; + ie11->value.choice.CriticalityDiagnostics.procedureCode = (F1AP_ProcedureCode_t *)calloc(1, sizeof(F1AP_ProcedureCode_t)); + ie11->value.choice.CriticalityDiagnostics.procedureCode = 0L; } /* optional */ /* triggeringMessage */ if (0) { - ie->value.choice.CriticalityDiagnostics.triggeringMessage = (F1AP_TriggeringMessage_t *)calloc(1, sizeof(F1AP_TriggeringMessage_t)); - ie->value.choice.CriticalityDiagnostics.triggeringMessage = (F1AP_TriggeringMessage_t *)F1AP_TriggeringMessage_successful_outcome; + ie11->value.choice.CriticalityDiagnostics.triggeringMessage = (F1AP_TriggeringMessage_t *)calloc(1, sizeof(F1AP_TriggeringMessage_t)); + *ie11->value.choice.CriticalityDiagnostics.triggeringMessage = F1AP_TriggeringMessage_successful_outcome; } /* optional */ /* procedureCriticality */ if (0) { - ie->value.choice.CriticalityDiagnostics.procedureCriticality = (F1AP_Criticality_t *)calloc(1, sizeof(F1AP_Criticality_t)); - ie->value.choice.CriticalityDiagnostics.procedureCriticality = F1AP_Criticality_reject; + ie11->value.choice.CriticalityDiagnostics.procedureCriticality = (F1AP_Criticality_t *)calloc(1, sizeof(F1AP_Criticality_t)); + ie11->value.choice.CriticalityDiagnostics.procedureCriticality = F1AP_Criticality_reject; } /* optional */ /* transactionID */ if (0) { - ie->value.choice.CriticalityDiagnostics.transactionID = (F1AP_TransactionID_t *)calloc(1, sizeof(F1AP_TransactionID_t)); - ie->value.choice.CriticalityDiagnostics.transactionID = 0L; + ie11->value.choice.CriticalityDiagnostics.transactionID = (F1AP_TransactionID_t *)calloc(1, sizeof(F1AP_TransactionID_t)); + ie11->value.choice.CriticalityDiagnostics.transactionID = 0L; } /* optional */ /* F1AP_CriticalityDiagnostics_IE_List */ if (0) { - for (i=0; - i<0; - i++) { - F1AP_CriticalityDiagnostics_IE_Item_t *criticalityDiagnostics_ie_item = (F1AP_CriticalityDiagnostics_IE_Item_t *)calloc(1, sizeof(F1AP_CriticalityDiagnostics_IE_Item_t));; + for (int i=0; i<0; i++) { + asn1cSequenceAdd(ie11->value.choice.CriticalityDiagnostics.iEsCriticalityDiagnostics->list, F1AP_CriticalityDiagnostics_IE_Item_t, criticalityDiagnostics_ie_item); criticalityDiagnostics_ie_item->iECriticality = F1AP_Criticality_reject; criticalityDiagnostics_ie_item->iE_ID = 0L; criticalityDiagnostics_ie_item->typeOfError = F1AP_TypeOfError_not_understood; - ASN_SEQUENCE_ADD(&ie->value.choice.CriticalityDiagnostics.iEsCriticalityDiagnostics->list, - criticalityDiagnostics_ie_item); } } - - ASN_SEQUENCE_ADD(&out->protocolIEs.list, ie); } /* encode */ @@ -1230,18 +1170,15 @@ int DU_send_UE_CONTEXT_MODIFICATION_RESPONSE(instance_t instance) { return -1; } - //du_f1ap_itti_send_sctp_data_req(instance, f1ap_setup_req->assoc_id, buffer, len, 0); + //f1ap_itti_send_sctp_data_req(false, instance, buffer, len, 0); return 0; } - int DU_send_UE_CONTEXT_MODIFICATION_FAILURE(instance_t instance) { AssertFatal(1==0,"Not implemented yet\n"); } - int DU_send_UE_CONTEXT_MODIFICATION_REQUIRED(instance_t instance) { AssertFatal(1==0,"Not implemented yet\n"); } - int DU_handle_UE_CONTEXT_MODIFICATION_CONFIRM(instance_t instance, uint32_t assoc_id, uint32_t stream, diff --git a/openair2/F1AP/f1ap_du_ue_context_management.h b/openair2/F1AP/f1ap_du_ue_context_management.h index 2bb3ca95b9600cc552d616d9788e78bb79eccee4..82643fa933ca306e73781730be184b8b7dcbd7a3 100644 --- a/openair2/F1AP/f1ap_du_ue_context_management.h +++ b/openair2/F1AP/f1ap_du_ue_context_management.h @@ -36,11 +36,12 @@ /* * UE Context Setup */ +int DU_send_UE_CONTEXT_SETUP_RESPONSE(instance_t instance, f1ap_ue_context_setup_t *req); + int DU_handle_UE_CONTEXT_SETUP_REQUEST(instance_t instance, uint32_t assoc_id, uint32_t stream, F1AP_F1AP_PDU_t *pdu); -int DU_send_UE_CONTEXT_SETUP_RESPONSE(instance_t instance); int DU_send_UE_CONTEXT_SETUP_FAILURE(instance_t instance); @@ -55,9 +56,9 @@ int DU_send_UE_CONTEXT_RELEASE_REQUEST(instance_t instance, * UE Context Release Command (gNB-CU initiated) */ int DU_handle_UE_CONTEXT_RELEASE_COMMAND(instance_t instance, - uint32_t assoc_id, - uint32_t stream, - F1AP_F1AP_PDU_t *pdu); + uint32_t assoc_id, + uint32_t stream, + F1AP_F1AP_PDU_t *pdu); /* * UE Context Release Complete (gNB-DU initiated) @@ -70,9 +71,9 @@ int DU_send_UE_CONTEXT_RELEASE_COMPLETE(instance_t instance, * UE Context Modification (gNB-CU initiated) */ int DU_handle_UE_CONTEXT_MODIFICATION_REQUEST(instance_t instance, - uint32_t assoc_id, - uint32_t stream, - F1AP_F1AP_PDU_t *pdu); + uint32_t assoc_id, + uint32_t stream, + F1AP_F1AP_PDU_t *pdu); int DU_send_UE_CONTEXT_MODIFICATION_RESPONSE(instance_t instance); int DU_send_UE_CONTEXT_MODIFICATION_FAILURE(instance_t instance); @@ -82,9 +83,11 @@ int DU_send_UE_CONTEXT_MODIFICATION_FAILURE(instance_t instance); */ int DU_send_UE_CONTEXT_MODIFICATION_REQUIRED(instance_t instance); int DU_handle_UE_CONTEXT_MODIFICATION_CONFIRM(instance_t instance, - uint32_t assoc_id, - uint32_t stream, - F1AP_F1AP_PDU_t *pdu); + uint32_t assoc_id, + uint32_t stream, + F1AP_F1AP_PDU_t *pdu); + +int DU_send_UE_CONTEXT_SETUP_RESPONSE(instance_t instance, f1ap_ue_context_setup_t *req); /* * UE Inactivity Notification diff --git a/openair2/F1AP/f1ap_encoder.c b/openair2/F1AP/f1ap_encoder.c index 6e5f0f4e493ed63a12498d617fe7fb59fb1e4e2e..e623e665362ec38227b55b8558d8ce9d0ec8e68e 100644 --- a/openair2/F1AP/f1ap_encoder.c +++ b/openair2/F1AP/f1ap_encoder.c @@ -33,46 +33,9 @@ #include "f1ap_common.h" #include "f1ap_encoder.h" -int asn1_encoder_xer_print = 0; +int asn1_encoder_xer_print = 1; -/* -static inline int f1ap_encode_initiating(f1ap_message *message, - uint8_t **buffer, - uint32_t *len); - -static inline int f1ap_encode_successfull_outcome(f1ap_message *message, - uint8_t **buffer, uint32_t *len); - -static inline int f1ap_encode_unsuccessfull_outcome(f1ap_message *message, - uint8_t **buffer, uint32_t *len); - -static inline int f1ap_encode_f1_setup_request( - F1ap_F1SetupRequestIEs_t *f1SetupRequestIEs, uint8_t **buffer, uint32_t *length); - -static inline int f1ap_encode_trace_failure(F1ap_TraceFailureIndicationIEs_t - *trace_failure_ies_p, uint8_t **buffer, - uint32_t *length); - -static inline int f1ap_encode_initial_context_setup_response( - F1ap_InitialContextSetupResponseIEs_t *initialContextSetupResponseIEs, - uint8_t **buffer, - uint32_t *length); - -static inline -int f1ap_encode_ue_context_release_complete( - F1ap_UEContextReleaseCompleteIEs_t *f1ap_UEContextReleaseCompleteIEs, - uint8_t **buffer, - uint32_t *length); - -static inline -int f1ap_encode_ue_context_release_request( - F1ap_UEContextReleaseRequestIEs_t *f1ap_UEContextReleaseRequestIEs, - uint8_t **buffer, - uint32_t *length); - */ - -int f1ap_encode_pdu(F1AP_F1AP_PDU_t *pdu, uint8_t **buffer, uint32_t *length) -{ +int f1ap_encode_pdu(F1AP_F1AP_PDU_t *pdu, uint8_t **buffer, uint32_t *length) { ssize_t encoded; DevAssert(pdu != NULL); DevAssert(buffer != NULL); @@ -84,11 +47,23 @@ int f1ap_encode_pdu(F1AP_F1AP_PDU_t *pdu, uint8_t **buffer, uint32_t *length) LOG_E(F1AP, "----------------- ASN1 ENCODER PRINT END----------------- \n"); } - AssertFatal((encoded = aper_encode_to_new_buffer(&asn_DEF_F1AP_F1AP_PDU, 0, pdu, (void **)buffer))>0, - "Failed to encode F1AP message\n"); + char errbuf[128]; /* Buffer for error message */ + size_t errlen = sizeof(errbuf); /* Size of the buffer */ + int ret = asn_check_constraints(&asn_DEF_F1AP_F1AP_PDU, pdu, errbuf, &errlen); - *length = encoded; + /* assert(errlen < sizeof(errbuf)); // Guaranteed: you may rely on that */ + if(ret) { + fprintf(stderr, "Constraint validation failed: %s\n", errbuf); + } + + encoded = aper_encode_to_new_buffer(&asn_DEF_F1AP_F1AP_PDU, 0, pdu, (void **)buffer); + + if (encoded < 0) { + LOG_E(F1AP, "Failed to encode F1AP message\n"); + return -1; + } + *length = encoded; return encoded; } diff --git a/openair2/F1AP/f1ap_handlers.c b/openair2/F1AP/f1ap_handlers.c index 5aca059ae40d297a607fb9779bac8993cb5b74ab..fec03bb0b90002a399cdfd027fccf92acd5c0d0c 100644 --- a/openair2/F1AP/f1ap_handlers.c +++ b/openair2/F1AP/f1ap_handlers.c @@ -31,7 +31,6 @@ */ #include "f1ap_common.h" -#include "f1ap_handlers.h" #include "f1ap_decoder.h" #include "f1ap_cu_interface_management.h" #include "f1ap_du_interface_management.h" @@ -40,11 +39,9 @@ #include "f1ap_cu_ue_context_management.h" #include "f1ap_du_ue_context_management.h" -extern f1ap_setup_req_t *f1ap_du_data_from_du; - /* Handlers matrix. Only f1 related procedure present here */ -f1ap_message_decoded_callback f1ap_messages_callback[][3] = { - +f1ap_message_processing_t f1ap_messages_processing[][3] = { + { 0, 0, 0 }, /* Reset */ { CU_handle_F1_SETUP_REQUEST, DU_handle_F1_SETUP_RESPONSE, DU_handle_F1_SETUP_FAILURE }, /* F1Setup */ @@ -73,55 +70,50 @@ f1ap_message_decoded_callback f1ap_messages_callback[][3] = { }; const char *f1ap_direction2String(int f1ap_dir) { -static const char *f1ap_direction_String[] = { - "", /* Nothing */ - "Initiating message", /* initiating message */ - "Successfull outcome", /* successfull outcome */ - "UnSuccessfull outcome", /* successfull outcome */ -}; -return(f1ap_direction_String[f1ap_dir]); + static const char *f1ap_direction_String[] = { + "", /* Nothing */ + "Initiating message", /* initiating message */ + "Successfull outcome", /* successfull outcome */ + "UnSuccessfull outcome", /* successfull outcome */ + }; + return(f1ap_direction_String[f1ap_dir]); } int f1ap_handle_message(instance_t instance, uint32_t assoc_id, int32_t stream, - const uint8_t * const data, const uint32_t data_length) -{ - F1AP_F1AP_PDU_t pdu; + const uint8_t *const data, const uint32_t data_length) { + F1AP_F1AP_PDU_t pdu= {0}; int ret; - DevAssert(data != NULL); - memset(&pdu, 0, sizeof(pdu)); - if (f1ap_decode_pdu(&pdu, data, data_length) < 0) { LOG_E(F1AP, "Failed to decode PDU\n"); return -1; } /* Checking procedure Code and direction of message */ - if (pdu.choice.initiatingMessage->procedureCode >= sizeof(f1ap_messages_callback) / (3 * sizeof( - f1ap_message_decoded_callback)) + if (pdu.choice.initiatingMessage->procedureCode >= + sizeof(f1ap_messages_processing) / + (3 * sizeof(f1ap_message_processing_t)) || (pdu.present > F1AP_F1AP_PDU_PR_unsuccessfulOutcome)) { LOG_E(F1AP, "[SCTP %d] Either procedureCode %ld or direction %d exceed expected\n", - assoc_id, pdu.choice.initiatingMessage->procedureCode, pdu.present); + assoc_id, pdu.choice.initiatingMessage->procedureCode, pdu.present); ASN_STRUCT_FREE_CONTENTS_ONLY(asn_DEF_F1AP_F1AP_PDU, &pdu); return -1; } - /* No handler present. - * This can mean not implemented or no procedure for eNB (wrong direction). - */ - if (f1ap_messages_callback[pdu.choice.initiatingMessage->procedureCode][pdu.present - 1] == NULL) { + if (f1ap_messages_processing[pdu.choice.initiatingMessage->procedureCode][pdu.present - 1] == NULL) { + // No handler present. This can mean not implemented or no procedure for eNB (wrong direction). LOG_E(F1AP, "[SCTP %d] No handler for procedureCode %ld in %s\n", - assoc_id, pdu.choice.initiatingMessage->procedureCode, - f1ap_direction2String(pdu.present - 1)); - ASN_STRUCT_FREE_CONTENTS_ONLY(asn_DEF_F1AP_F1AP_PDU, &pdu); - return -1; + assoc_id, pdu.choice.initiatingMessage->procedureCode, + f1ap_direction2String(pdu.present - 1)); + ret=-1; + } else { + /* Calling the right handler */ + LOG_I(F1AP, "Calling handler with instance %ld\n",instance); + ret = (*f1ap_messages_processing[pdu.choice.initiatingMessage->procedureCode][pdu.present - 1]) + (instance, assoc_id, stream, &pdu); } - /* Calling the right handler */ - LOG_I(F1AP, "Calling handler with instance %ld\n",instance); - ret = (*f1ap_messages_callback[pdu.choice.initiatingMessage->procedureCode][pdu.present - 1]) - (instance, assoc_id, stream, &pdu); ASN_STRUCT_FREE_CONTENTS_ONLY(asn_DEF_F1AP_F1AP_PDU, &pdu); return ret; } diff --git a/openair2/F1AP/f1ap_handlers.h b/openair2/F1AP/f1ap_handlers.h deleted file mode 100644 index 631249a324287607d7c2c3ea539f6aea85913a9d..0000000000000000000000000000000000000000 --- a/openair2/F1AP/f1ap_handlers.h +++ /dev/null @@ -1,39 +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 - */ - -/*! \file f1ap_handlers.h - * \brief f1ap messages handlers - * \author EURECOM/NTUST - * \date 2018 - * \version 0.1 - * \company Eurecom - * \email: navid.nikaein@eurecom.fr, bing-kai.hong@eurecom.fr - * \note - * \warning - */ - -#ifndef F1AP_HANDLERS_H_ -#define F1AP_HANDLERS_H_ - -int f1ap_handle_message(instance_t instance, uint32_t assoc_id, int32_t stream, - const uint8_t * const data, const uint32_t data_length); - -#endif /* F1AP_HANDLERS_H_ */ diff --git a/openair2/F1AP/f1ap_itti_messaging.c b/openair2/F1AP/f1ap_itti_messaging.c index 443357a45e329dd87886eefe61af71883fc26cec..21096a65188cb41ffb8f6946be24047b61ee5bf0 100644 --- a/openair2/F1AP/f1ap_itti_messaging.c +++ b/openair2/F1AP/f1ap_itti_messaging.c @@ -22,52 +22,26 @@ #include "f1ap_common.h" #include "f1ap_itti_messaging.h" -void cu_f1ap_itti_send_sctp_data_req(instance_t instance, int32_t assoc_id, uint8_t *buffer, - uint32_t buffer_length, uint16_t stream) -{ +void f1ap_itti_send_sctp_data_req(bool isCu, instance_t instance, uint8_t *buffer, + uint32_t buffer_length, uint16_t stream) { MessageDef *message_p; sctp_data_req_t *sctp_data_req; - - message_p = itti_alloc_new_message(TASK_CU_F1, 0, SCTP_DATA_REQ); - + message_p = itti_alloc_new_message(isCu?TASK_CU_F1:TASK_DU_F1, 0, SCTP_DATA_REQ); sctp_data_req = &message_p->ittiMsg.sctp_data_req; - - sctp_data_req->assoc_id = assoc_id; + sctp_data_req->assoc_id = f1ap_assoc_id(isCu,instance); sctp_data_req->buffer = buffer; sctp_data_req->buffer_length = buffer_length; sctp_data_req->stream = stream; - - itti_send_msg_to_task(TASK_SCTP, instance, message_p); -} - -void du_f1ap_itti_send_sctp_data_req(instance_t instance, int32_t assoc_id, uint8_t *buffer, - uint32_t buffer_length, uint16_t stream) -{ - MessageDef *message_p; - sctp_data_req_t *sctp_data_req; - - message_p = itti_alloc_new_message(TASK_DU_F1, 0, SCTP_DATA_REQ); - - sctp_data_req = &message_p->ittiMsg.sctp_data_req; - - sctp_data_req->assoc_id = assoc_id; - sctp_data_req->buffer = buffer; - sctp_data_req->buffer_length = buffer_length; - sctp_data_req->stream = stream; - LOG_I(F1AP, "Sending ITTI message to SCTP Task\n"); itti_send_msg_to_task(TASK_SCTP, instance, message_p); } -void f1ap_itti_send_sctp_close_association(instance_t instance, int32_t assoc_id) -{ +void f1ap_itti_send_sctp_close_association(bool isCu, instance_t instance) { MessageDef *message_p = NULL; sctp_close_association_t *sctp_close_association_p = NULL; - message_p = itti_alloc_new_message(TASK_S1AP, 0, SCTP_CLOSE_ASSOCIATION); sctp_close_association_p = &message_p->ittiMsg.sctp_close_association; - sctp_close_association_p->assoc_id = assoc_id; - + sctp_close_association_p->assoc_id = f1ap_assoc_id(isCu,instance); itti_send_msg_to_task(TASK_SCTP, instance, message_p); } diff --git a/openair2/F1AP/f1ap_itti_messaging.h b/openair2/F1AP/f1ap_itti_messaging.h index 66c59a72e72ee1f721aa7bd41b4b07e6c961073a..a5560e6c8159eb22ba22aa4ea7944bacc7d00db2 100644 --- a/openair2/F1AP/f1ap_itti_messaging.h +++ b/openair2/F1AP/f1ap_itti_messaging.h @@ -22,14 +22,10 @@ #ifndef F1AP_ITTI_MESSAGING_H_ #define F1AP_ITTI_MESSAGING_H_ -void cu_f1ap_itti_send_sctp_data_req(instance_t instance, int32_t assoc_id, uint8_t *buffer, - uint32_t buffer_length, uint16_t stream); +void f1ap_itti_send_sctp_data_req(bool isCu,instance_t instance, uint8_t *buffer, + uint32_t buffer_length, uint16_t stream); -void du_f1ap_itti_send_sctp_data_req(instance_t instance, int32_t assoc_id, uint8_t *buffer, - uint32_t buffer_length, uint16_t stream); - -void f1ap_eNB_itti_send_sctp_close_association(instance_t instance, - int32_t assoc_id); +void f1ap_eNB_itti_send_sctp_close_association(bool isCu,instance_t instance); #endif /* F1AP_ITTI_MESSAGING_H_ */ diff --git a/openair2/F1AP/f1ap_messaging.c b/openair2/F1AP/f1ap_messaging.c deleted file mode 100644 index fb189eaed3d28c9cc6c22c6bb7c8dd0110ab4814..0000000000000000000000000000000000000000 --- a/openair2/F1AP/f1ap_messaging.c +++ /dev/null @@ -1,66 +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 - */ - -/*! \file f1ap_messaging.c - * \brief f1ap procedures - * \author EURECOM/NTUST - * \date 2018 - * \version 0.1 - * \company Eurecom - * \email: navid.nikaein@eurecom.fr, bing-kai.hong@eurecom.fr - * \note - * \warning - */ - - -#include "f1ap_common.h" -#include "f1ap_messaging.h" - -// void f1ap_send_sctp_data_req(instance_t instance, int32_t assoc_id, uint8_t *buffer, -// uint32_t buffer_length, uint16_t stream) -// { -// MessageDef *message_p; -// sctp_data_req_t *sctp_data_req; - -// message_p = itti_alloc_new_message(TASK_F1AP, SCTP_DATA_REQ); - -// sctp_data_req = &message_p->ittiMsg.sctp_data_req; - -// sctp_data_req->assoc_id = assoc_id; -// sctp_data_req->buffer = buffer; -// sctp_data_req->buffer_length = buffer_length; -// sctp_data_req->stream = stream; - -// itti_send_msg_to_task(TASK_SCTP, instance, message_p); -// } - -// void f1ap_send_sctp_close_association(instance_t instance, int32_t assoc_id) -// { -// MessageDef *message_p = NULL; -// sctp_close_association_t *sctp_close_association_p = NULL; - -// message_p = itti_alloc_new_message(TASK_F1AP, SCTP_CLOSE_ASSOCIATION); -// sctp_close_association_p = &message_p->ittiMsg.sctp_close_association; -// sctp_close_association_p->assoc_id = assoc_id; - -// itti_send_msg_to_task(TASK_SCTP, instance, message_p); -// } - diff --git a/openair2/F1AP/f1ap_messaging.h b/openair2/F1AP/f1ap_messaging.h index 9ad0388d0198179d164e0176b246aa98f154522d..eb3b4224e933f0c93aeae114535a233e43af6473 100644 --- a/openair2/F1AP/f1ap_messaging.h +++ b/openair2/F1AP/f1ap_messaging.h @@ -35,10 +35,10 @@ #define F1AP_MESSAGING_H_ void f1ap_send_sctp_data_req(instance_t instance, int32_t assoc_id, uint8_t *buffer, - uint32_t buffer_length, uint16_t stream); + uint32_t buffer_length, uint16_t stream); void f1ap_send_sctp_close_association(instance_t instance, - int32_t assoc_id); + int32_t assoc_id); #endif /* F1AP_MESSAGING_H_ */ diff --git a/openair2/GNB_APP/L1_nr_paramdef.h b/openair2/GNB_APP/L1_nr_paramdef.h index 0306713845b9f302a42a44b5bef53ae61b8030ed..90cd9aae2900054567423a3bcadc822b7c6eedab 100644 --- a/openair2/GNB_APP/L1_nr_paramdef.h +++ b/openair2/GNB_APP/L1_nr_paramdef.h @@ -46,7 +46,7 @@ #define CONFIG_STRING_L1_LOCAL_N_PORTD "local_n_portd" #define CONFIG_STRING_L1_REMOTE_N_PORTD "remote_n_portd" #define CONFIG_STRING_L1_TRANSPORT_N_PREFERENCE "tr_n_preference" -#define CONFIG_STRING_L1_PUSCH_PROC_THREADS "pusch_proc_threads" +#define CONFIG_STRING_L1_THREAD_POOL_SIZE "thread_pool_size" #define CONFIG_STRING_L1_OFDM_OFFSET_DIVISOR "ofdm_offset_divisor" #define CONFIG_STRING_L1_PUCCH0_DTX_THRESHOLD "pucch0_dtx_threshold" #define CONFIG_STRING_L1_PRACH_DTX_THRESHOLD "prach_dtx_threshold" @@ -65,8 +65,8 @@ {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_PUSCH_PROC_THREADS, NULL, 0, uptr:NULL, defintval:3, TYPE_UINT, 0}, \ -{CONFIG_STRING_L1_OFDM_OFFSET_DIVISOR, NULL, 0, uptr:NULL, defuintval:8, 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_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}, \ {CONFIG_STRING_L1_PUSCH_DTX_THRESHOLD, NULL, 0, uptr:NULL, defintval:50, TYPE_UINT, 0} \ @@ -80,7 +80,7 @@ #define L1_REMOTE_N_PORTC_IDX 6 #define L1_LOCAL_N_PORTD_IDX 7 #define L1_REMOTE_N_PORTD_IDX 8 -#define L1_PUSCH_PROC_THREADS 9 +#define L1_THREAD_POOL_SIZE 9 #define L1_OFDM_OFFSET_DIVISOR 10 #define L1_PUCCH0_DTX_THRESHOLD 11 #define L1_PRACH_DTX_THRESHOLD 12 diff --git a/openair2/GNB_APP/RRC_nr_paramsvalues.h b/openair2/GNB_APP/RRC_nr_paramsvalues.h index 70295b1c313ada7c60650c4106f9b5f8dcd08ece..8a7ce64d91cdb969471630225e10b11a58042011 100644 --- a/openair2/GNB_APP/RRC_nr_paramsvalues.h +++ b/openair2/GNB_APP/RRC_nr_paramsvalues.h @@ -58,56 +58,6 @@ #define GNB_CONFIG_STRING_INITIALDLBWPCONTROLRESOURCESETZERO "initialDLBWPcontrolResourceSetZero" #define GNB_CONFIG_STRING_INITIALDLBWPSEARCHSPACEZERO "initialDLBWPsearchSpaceZero" - -#define GNB_CONFIG_STRING_INITIALDLBWPK0_0 "initialDLBWPk0_0" -#define GNB_CONFIG_STRING_INITIALDLBWPMAPPINGTYPE_0 "initialDLBWPmappingType_0" -#define GNB_CONFIG_STRING_INITIALDLBWPSTARTSYMBOLANDLENGTH_0 "initialDLBWPstartSymbolAndLength_0" -#define GNB_CONFIG_STRING_INITIALDLBWPK0_1 "initialDLBWPk0_1" -#define GNB_CONFIG_STRING_INITIALDLBWPMAPPINGTYPE_1 "initialDLBWPmappingType_1" -#define GNB_CONFIG_STRING_INITIALDLBWPSTARTSYMBOLANDLENGTH_1 "initialDLBWPstartSymbolAndLength_1" -#define GNB_CONFIG_STRING_INITIALDLBWPK0_2 "initialDLBWPk0_2" -#define GNB_CONFIG_STRING_INITIALDLBWPMAPPINGTYPE_2 "initialDLBWPmappingType_2" -#define GNB_CONFIG_STRING_INITIALDLBWPSTARTSYMBOLANDLENGTH_2 "initialDLBWPstartSymbolAndLength_2" -#define GNB_CONFIG_STRING_INITIALDLBWPK0_3 "initialDLBWPk0_3" -#define GNB_CONFIG_STRING_INITIALDLBWPMAPPINGTYPE_3 "initialDLBWPmappingType_3" -#define GNB_CONFIG_STRING_INITIALDLBWPSTARTSYMBOLANDLENGTH_3 "initialDLBWPstartSymbolAndLength_3" -#define GNB_CONFIG_STRING_INITIALDLBWPK0_4 "initialDLBWPk0_4" -#define GNB_CONFIG_STRING_INITIALDLBWPMAPPINGTYPE_4 "initialDLBWPmappingType_4" -#define GNB_CONFIG_STRING_INITIALDLBWPSTARTSYMBOLANDLENGTH_4 "initialDLBWPstartSymbolAndLength_4" -#define GNB_CONFIG_STRING_INITIALDLBWPK0_5 "initialDLBWPk0_5" -#define GNB_CONFIG_STRING_INITIALDLBWPMAPPINGTYPE_5 "initialDLBWPmappingType_5" -#define GNB_CONFIG_STRING_INITIALDLBWPSTARTSYMBOLANDLENGTH_5 "initialDLBWPstartSymbolAndLength_5" -#define GNB_CONFIG_STRING_INITIALDLBWPK0_6 "initialDLBWPk0_6" -#define GNB_CONFIG_STRING_INITIALDLBWPMAPPINGTYPE_6 "initialDLBWPmappingType_6" -#define GNB_CONFIG_STRING_INITIALDLBWPSTARTSYMBOLANDLENGTH_6 "initialDLBWPstartSymbolAndLength_6" -#define GNB_CONFIG_STRING_INITIALDLBWPK0_7 "initialDLBWPk0_7" -#define GNB_CONFIG_STRING_INITIALDLBWPMAPPINGTYPE_7 "initialDLBWPmappingType_7" -#define GNB_CONFIG_STRING_INITIALDLBWPSTARTSYMBOLANDLENGTH_7 "initialDLBWPstartSymbolAndLength_7" -#define GNB_CONFIG_STRING_INITIALDLBWPK0_8 "initialDLBWPk0_8" -#define GNB_CONFIG_STRING_INITIALDLBWPMAPPINGTYPE_8 "initialDLBWPmappingType_8" -#define GNB_CONFIG_STRING_INITIALDLBWPSTARTSYMBOLANDLENGTH_8 "initialDLBWPstartSymbolAndLength_8" -#define GNB_CONFIG_STRING_INITIALDLBWPK0_9 "initialDLBWPk0_9" -#define GNB_CONFIG_STRING_INITIALDLBWPMAPPINGTYPE_9 "initialDLBWPmappingType_9" -#define GNB_CONFIG_STRING_INITIALDLBWPSTARTSYMBOLANDLENGTH_9 "initialDLBWPstartSymbolAndLength_9" -#define GNB_CONFIG_STRING_INITIALDLBWPK0_10 "initialDLBWPk0_10" -#define GNB_CONFIG_STRING_INITIALDLBWPMAPPINGTYPE_10 "initialDLBWPmappingType_10" -#define GNB_CONFIG_STRING_INITIALDLBWPSTARTSYMBOLANDLENGTH_10 "initialDLBWPstartSymbolAndLength_10" -#define GNB_CONFIG_STRING_INITIALDLBWPK0_11 "initialDLBWPk0_11" -#define GNB_CONFIG_STRING_INITIALDLBWPMAPPINGTYPE_11 "initialDLBWPmappingType_11" -#define GNB_CONFIG_STRING_INITIALDLBWPSTARTSYMBOLANDLENGTH_11 "initialDLBWPstartSymbolAndLength_11" -#define GNB_CONFIG_STRING_INITIALDLBWPK0_12 "initialDLBWPk0_12" -#define GNB_CONFIG_STRING_INITIALDLBWPMAPPINGTYPE_12 "initialDLBWPmappingType_12" -#define GNB_CONFIG_STRING_INITIALDLBWPSTARTSYMBOLANDLENGTH_12 "initialDLBWPstartSymbolAndLength_12" -#define GNB_CONFIG_STRING_INITIALDLBWPK0_13 "initialDLBWPk0_13" -#define GNB_CONFIG_STRING_INITIALDLBWPMAPPINGTYPE_13 "initialDLBWPmappingType_13" -#define GNB_CONFIG_STRING_INITIALDLBWPSTARTSYMBOLANDLENGTH_13 "initialDLBWPstartSymbolAndLength_13" -#define GNB_CONFIG_STRING_INITIALDLBWPK0_14 "initialDLBWPk0_14" -#define GNB_CONFIG_STRING_INITIALDLBWPMAPPINGTYPE_14 "initialDLBWPmappingType_14" -#define GNB_CONFIG_STRING_INITIALDLBWPSTARTSYMBOLANDLENGTH_14 "initialDLBWPstartSymbolAndLength_14" -#define GNB_CONFIG_STRING_INITIALDLBWPK0_15 "initialDLBWPk0_15" -#define GNB_CONFIG_STRING_INITIALDLBWPMAPPINGTYPE_15 "initialDLBWPmappingType_15" -#define GNB_CONFIG_STRING_INITIALDLBWPSTARTSYMBOLANDLENGTH_15 "initialDLBWPstartSymbolAndLength_15" - #define GNB_CONFIG_STRING_ULFREQUENCYBAND "ul_frequencyBand" #define GNB_CONFIG_STRING_ULABSOLUEFREQUENCYPOINTA "ul_absoluteFrequencyPointA" #define GNB_CONFIG_STRING_ULOFFSETTOCARRIER "ul_offstToCarrier" @@ -142,54 +92,6 @@ #define GNB_CONFIG_STRING_HOPPINGID "hoppingId" #define GNB_CONFIG_STRING_P0NOMINAL "p0_nominal" #define GNB_CONFIG_STRING_PUCCHRES "pucch_ResourceCommon" -#define GNB_CONFIG_STRING_INITIALULBWPK2_0 "initialULBWPk2_0" -#define GNB_CONFIG_STRING_INITIALULBWPMAPPINGTYPE_0 "initialULBWPmappingType_0" -#define GNB_CONFIG_STRING_INITIALULBWPSTARTSYMBOLANDLENGTH_0 "initialULBWPstartSymbolAndLength_0" -#define GNB_CONFIG_STRING_INITIALULBWPK2_1 "initialULBWPk2_1" -#define GNB_CONFIG_STRING_INITIALULBWPMAPPINGTYPE_1 "initialULBWPmappingType_1" -#define GNB_CONFIG_STRING_INITIALULBWPSTARTSYMBOLANDLENGTH_1 "initialULBWPstartSymbolAndLength_1" -#define GNB_CONFIG_STRING_INITIALULBWPK2_2 "initialULBWPk2_2" -#define GNB_CONFIG_STRING_INITIALULBWPMAPPINGTYPE_2 "initialULBWPmappingType_2" -#define GNB_CONFIG_STRING_INITIALULBWPSTARTSYMBOLANDLENGTH_2 "initialULBWPstartSymbolAndLength_2" -#define GNB_CONFIG_STRING_INITIALULBWPK2_3 "initialULBWPk2_3" -#define GNB_CONFIG_STRING_INITIALULBWPMAPPINGTYPE_3 "initialULBWPmappingType_3" -#define GNB_CONFIG_STRING_INITIALULBWPSTARTSYMBOLANDLENGTH_3 "initialULBWPstartSymbolAndLength_3" -#define GNB_CONFIG_STRING_INITIALULBWPK2_4 "initialULBWPk2_4" -#define GNB_CONFIG_STRING_INITIALULBWPMAPPINGTYPE_4 "initialULBWPmappingType_4" -#define GNB_CONFIG_STRING_INITIALULBWPSTARTSYMBOLANDLENGTH_4 "initialULBWPstartSymbolAndLength_4" -#define GNB_CONFIG_STRING_INITIALULBWPK2_5 "initialULBWPk2_5" -#define GNB_CONFIG_STRING_INITIALULBWPMAPPINGTYPE_5 "initialULBWPmappingType_5" -#define GNB_CONFIG_STRING_INITIALULBWPSTARTSYMBOLANDLENGTH_5 "initialULBWPstartSymbolAndLength_5" -#define GNB_CONFIG_STRING_INITIALULBWPK2_6 "initialULBWPk2_6" -#define GNB_CONFIG_STRING_INITIALULBWPMAPPINGTYPE_6 "initialULBWPmappingType_6" -#define GNB_CONFIG_STRING_INITIALULBWPSTARTSYMBOLANDLENGTH_6 "initialULBWPstartSymbolAndLength_6" -#define GNB_CONFIG_STRING_INITIALULBWPK2_7 "initialULBWPk2_7" -#define GNB_CONFIG_STRING_INITIALULBWPMAPPINGTYPE_7 "initialULBWPmappingType_7" -#define GNB_CONFIG_STRING_INITIALULBWPSTARTSYMBOLANDLENGTH_7 "initialULBWPstartSymbolAndLength_7" -#define GNB_CONFIG_STRING_INITIALULBWPK2_8 "initialULBWPk2_8" -#define GNB_CONFIG_STRING_INITIALULBWPMAPPINGTYPE_8 "initialULBWPmappingType_8" -#define GNB_CONFIG_STRING_INITIALULBWPSTARTSYMBOLANDLENGTH_8 "initialULBWPstartSymbolAndLength_8" -#define GNB_CONFIG_STRING_INITIALULBWPK2_9 "initialULBWPk2_9" -#define GNB_CONFIG_STRING_INITIALULBWPMAPPINGTYPE_9 "initialULBWPmappingType_9" -#define GNB_CONFIG_STRING_INITIALULBWPSTARTSYMBOLANDLENGTH_9 "initialULBWPstartSymbolAndLength_9" -#define GNB_CONFIG_STRING_INITIALULBWPK2_10 "initialULBWPk2_10" -#define GNB_CONFIG_STRING_INITIALULBWPMAPPINGTYPE_10 "initialULBWPmappingType_10" -#define GNB_CONFIG_STRING_INITIALULBWPSTARTSYMBOLANDLENGTH_10 "initialULBWPstartSymbolAndLength_10" -#define GNB_CONFIG_STRING_INITIALULBWPK2_11 "initialULBWPk2_11" -#define GNB_CONFIG_STRING_INITIALULBWPMAPPINGTYPE_11 "initialULBWPmappingType_11" -#define GNB_CONFIG_STRING_INITIALULBWPSTARTSYMBOLANDLENGTH_11 "initialULBWPstartSymbolAndLength_11" -#define GNB_CONFIG_STRING_INITIALULBWPK2_12 "initialULBWPk2_12" -#define GNB_CONFIG_STRING_INITIALULBWPMAPPINGTYPE_12 "initialULBWPmappingType_12" -#define GNB_CONFIG_STRING_INITIALULBWPSTARTSYMBOLANDLENGTH_12 "initialULBWPstartSymbolAndLength_12" -#define GNB_CONFIG_STRING_INITIALULBWPK2_13 "initialULBWPk2_13" -#define GNB_CONFIG_STRING_INITIALULBWPMAPPINGTYPE_13 "initialULBWPmappingType_13" -#define GNB_CONFIG_STRING_INITIALULBWPSTARTSYMBOLANDLENGTH_13 "initialULBWPstartSymbolAndLength_13" -#define GNB_CONFIG_STRING_INITIALULBWPK2_14 "initialULBWPk2_14" -#define GNB_CONFIG_STRING_INITIALULBWPMAPPINGTYPE_14 "initialULBWPmappingType_14" -#define GNB_CONFIG_STRING_INITIALULBWPSTARTSYMBOLANDLENGTH_14 "initialULBWPstartSymbolAndLength_14" -#define GNB_CONFIG_STRING_INITIALULBWPK2_15 "initialULBWPk2_15" -#define GNB_CONFIG_STRING_INITIALULBWPMAPPINGTYPE_15 "initialULBWPmappingType_15" -#define GNB_CONFIG_STRING_INITIALULBWPSTARTSYMBOLANDLENGTH_15 "initialULBWPstartSymbolAndLength_15" #define GNB_CONFIG_STRING_SSBPOSITIONSINBURSTPR "ssb_PositionsInBurst_PR" @@ -273,54 +175,6 @@ {GNB_CONFIG_STRING_INITIALDLBWPSUBCARRIERSPACING,NULL,0,i64ptr:&scc->downlinkConfigCommon->initialDownlinkBWP->genericParameters.subcarrierSpacing,defint64val:NR_SubcarrierSpacing_kHz30,TYPE_INT64,0/*12*/},\ {GNB_CONFIG_STRING_INITIALDLBWPCONTROLRESOURCESETZERO,NULL,0,i64ptr:scc->downlinkConfigCommon->initialDownlinkBWP->pdcch_ConfigCommon->choice.setup->controlResourceSetZero,defint64val:12,TYPE_INT64,0/*13*/},\ {GNB_CONFIG_STRING_INITIALDLBWPSEARCHSPACEZERO,NULL,0,i64ptr:scc->downlinkConfigCommon->initialDownlinkBWP->pdcch_ConfigCommon->choice.setup->searchSpaceZero,defint64val:0,TYPE_INT64,0/*14*/},\ -{GNB_CONFIG_STRING_INITIALDLBWPK0_0,NULL,0,i64ptr:scc->downlinkConfigCommon->initialDownlinkBWP->pdsch_ConfigCommon->choice.setup->pdsch_TimeDomainAllocationList->list.array[0]->k0,defint64val:-1,TYPE_INT64,0/*15*/},\ -{GNB_CONFIG_STRING_INITIALDLBWPMAPPINGTYPE_0,NULL,0,i64ptr:&scc->downlinkConfigCommon->initialDownlinkBWP->pdsch_ConfigCommon->choice.setup->pdsch_TimeDomainAllocationList->list.array[0]->mappingType,defint64val:-1,TYPE_INT64,0/*16*/},\ -{GNB_CONFIG_STRING_INITIALDLBWPSTARTSYMBOLANDLENGTH_0,NULL,0,i64ptr:&scc->downlinkConfigCommon->initialDownlinkBWP->pdsch_ConfigCommon->choice.setup->pdsch_TimeDomainAllocationList->list.array[0]->startSymbolAndLength,defint64val:-1,TYPE_INT64,0/*17*/},\ -{GNB_CONFIG_STRING_INITIALDLBWPK0_1,NULL,0,i64ptr:scc->downlinkConfigCommon->initialDownlinkBWP->pdsch_ConfigCommon->choice.setup->pdsch_TimeDomainAllocationList->list.array[1]->k0,defint64val:-1,TYPE_INT64,0/*18*/},\ -{GNB_CONFIG_STRING_INITIALDLBWPMAPPINGTYPE_1,NULL,0,i64ptr:&scc->downlinkConfigCommon->initialDownlinkBWP->pdsch_ConfigCommon->choice.setup->pdsch_TimeDomainAllocationList->list.array[1]->mappingType,defint64val:NR_PDSCH_TimeDomainResourceAllocation__mappingType_typeA,TYPE_INT64,0/*19*/},\ -{GNB_CONFIG_STRING_INITIALDLBWPSTARTSYMBOLANDLENGTH_1,NULL,0,i64ptr:&scc->downlinkConfigCommon->initialDownlinkBWP->pdsch_ConfigCommon->choice.setup->pdsch_TimeDomainAllocationList->list.array[1]->startSymbolAndLength,defint64val:53,TYPE_INT64,0/*20*/}, \ -{GNB_CONFIG_STRING_INITIALDLBWPK0_2,NULL,0,i64ptr:scc->downlinkConfigCommon->initialDownlinkBWP->pdsch_ConfigCommon->choice.setup->pdsch_TimeDomainAllocationList->list.array[2]->k0,defint64val:-1,TYPE_INT64,0/*21*/},\ -{GNB_CONFIG_STRING_INITIALDLBWPMAPPINGTYPE_2,NULL,0,i64ptr:&scc->downlinkConfigCommon->initialDownlinkBWP->pdsch_ConfigCommon->choice.setup->pdsch_TimeDomainAllocationList->list.array[2]->mappingType,defint64val:NR_PDSCH_TimeDomainResourceAllocation__mappingType_typeA,TYPE_INT64,0/*22*/},\ -{GNB_CONFIG_STRING_INITIALDLBWPSTARTSYMBOLANDLENGTH_2,NULL,0,i64ptr:&scc->downlinkConfigCommon->initialDownlinkBWP->pdsch_ConfigCommon->choice.setup->pdsch_TimeDomainAllocationList->list.array[2]->startSymbolAndLength,defint64val:54,TYPE_INT64,0/*23*/},\ -{GNB_CONFIG_STRING_INITIALDLBWPK0_3,NULL,0,i64ptr:scc->downlinkConfigCommon->initialDownlinkBWP->pdsch_ConfigCommon->choice.setup->pdsch_TimeDomainAllocationList->list.array[3]->k0,defint64val:-1,TYPE_INT64,0/*24*/},\ -{GNB_CONFIG_STRING_INITIALDLBWPMAPPINGTYPE_3,NULL,0,i64ptr:&scc->downlinkConfigCommon->initialDownlinkBWP->pdsch_ConfigCommon->choice.setup->pdsch_TimeDomainAllocationList->list.array[3]->mappingType,defint64val:NR_PDSCH_TimeDomainResourceAllocation__mappingType_typeA,TYPE_INT64,0/*25*/},\ -{GNB_CONFIG_STRING_INITIALDLBWPSTARTSYMBOLANDLENGTH_3,NULL,0,i64ptr:&scc->downlinkConfigCommon->initialDownlinkBWP->pdsch_ConfigCommon->choice.setup->pdsch_TimeDomainAllocationList->list.array[3]->startSymbolAndLength,defint64val:54,TYPE_INT64,0/*26*/},\ -{GNB_CONFIG_STRING_INITIALDLBWPK0_4,NULL,0,i64ptr:scc->downlinkConfigCommon->initialDownlinkBWP->pdsch_ConfigCommon->choice.setup->pdsch_TimeDomainAllocationList->list.array[4]->k0,defint64val:-1,TYPE_INT64,0/*27*/},\ -{GNB_CONFIG_STRING_INITIALDLBWPMAPPINGTYPE_4,NULL,0,i64ptr:&scc->downlinkConfigCommon->initialDownlinkBWP->pdsch_ConfigCommon->choice.setup->pdsch_TimeDomainAllocationList->list.array[4]->mappingType,defint64val:NR_PDSCH_TimeDomainResourceAllocation__mappingType_typeA,TYPE_INT64,0/*28*/}, \ -{GNB_CONFIG_STRING_INITIALDLBWPSTARTSYMBOLANDLENGTH_4,NULL,0,i64ptr:&scc->downlinkConfigCommon->initialDownlinkBWP->pdsch_ConfigCommon->choice.setup->pdsch_TimeDomainAllocationList->list.array[4]->startSymbolAndLength,defint64val:54,TYPE_INT64,0/*29*/},\ -{GNB_CONFIG_STRING_INITIALDLBWPK0_5,NULL,0,i64ptr:scc->downlinkConfigCommon->initialDownlinkBWP->pdsch_ConfigCommon->choice.setup->pdsch_TimeDomainAllocationList->list.array[5]->k0,defint64val:-1,TYPE_INT64,0/*30*/}, \ -{GNB_CONFIG_STRING_INITIALDLBWPMAPPINGTYPE_5,NULL,0,i64ptr:&scc->downlinkConfigCommon->initialDownlinkBWP->pdsch_ConfigCommon->choice.setup->pdsch_TimeDomainAllocationList->list.array[5]->mappingType,defint64val:NR_PDSCH_TimeDomainResourceAllocation__mappingType_typeA,TYPE_INT64,0/*31*/},\ -{GNB_CONFIG_STRING_INITIALDLBWPSTARTSYMBOLANDLENGTH_5,NULL,0,i64ptr:&scc->downlinkConfigCommon->initialDownlinkBWP->pdsch_ConfigCommon->choice.setup->pdsch_TimeDomainAllocationList->list.array[5]->startSymbolAndLength,defint64val:54,TYPE_INT64,0/*32*/},\ -{GNB_CONFIG_STRING_INITIALDLBWPK0_6,NULL,0,i64ptr:scc->downlinkConfigCommon->initialDownlinkBWP->pdsch_ConfigCommon->choice.setup->pdsch_TimeDomainAllocationList->list.array[6]->k0,defint64val:-1,TYPE_INT64,0/*33*/},\ -{GNB_CONFIG_STRING_INITIALDLBWPMAPPINGTYPE_6,NULL,0,i64ptr:&scc->downlinkConfigCommon->initialDownlinkBWP->pdsch_ConfigCommon->choice.setup->pdsch_TimeDomainAllocationList->list.array[6]->mappingType,defint64val:NR_PDSCH_TimeDomainResourceAllocation__mappingType_typeA,TYPE_INT64,0/*34*/}, \ -{GNB_CONFIG_STRING_INITIALDLBWPSTARTSYMBOLANDLENGTH_6,NULL,0,i64ptr:&scc->downlinkConfigCommon->initialDownlinkBWP->pdsch_ConfigCommon->choice.setup->pdsch_TimeDomainAllocationList->list.array[6]->startSymbolAndLength,defint64val:54,TYPE_INT64,0/*35*/},\ -{GNB_CONFIG_STRING_INITIALDLBWPK0_7,NULL,0,i64ptr:scc->downlinkConfigCommon->initialDownlinkBWP->pdsch_ConfigCommon->choice.setup->pdsch_TimeDomainAllocationList->list.array[7]->k0,defint64val:-1,TYPE_INT64,0/*36*/},\ -{GNB_CONFIG_STRING_INITIALDLBWPMAPPINGTYPE_7,NULL,0,i64ptr:&scc->downlinkConfigCommon->initialDownlinkBWP->pdsch_ConfigCommon->choice.setup->pdsch_TimeDomainAllocationList->list.array[7]->mappingType,defint64val:NR_PDSCH_TimeDomainResourceAllocation__mappingType_typeA,TYPE_INT64,0/*37*/},\ -{GNB_CONFIG_STRING_INITIALDLBWPSTARTSYMBOLANDLENGTH_7,NULL,0,i64ptr:&scc->downlinkConfigCommon->initialDownlinkBWP->pdsch_ConfigCommon->choice.setup->pdsch_TimeDomainAllocationList->list.array[7]->startSymbolAndLength,defint64val:54,TYPE_INT64,0/*38*/},\ -{GNB_CONFIG_STRING_INITIALDLBWPK0_8,NULL,0,i64ptr:scc->downlinkConfigCommon->initialDownlinkBWP->pdsch_ConfigCommon->choice.setup->pdsch_TimeDomainAllocationList->list.array[8]->k0,defint64val:-1,TYPE_INT64,0/*39*/},\ -{GNB_CONFIG_STRING_INITIALDLBWPMAPPINGTYPE_8,NULL,0,i64ptr:&scc->downlinkConfigCommon->initialDownlinkBWP->pdsch_ConfigCommon->choice.setup->pdsch_TimeDomainAllocationList->list.array[8]->mappingType,defint64val:NR_PDSCH_TimeDomainResourceAllocation__mappingType_typeA,TYPE_INT64,0/*40*/}, \ -{GNB_CONFIG_STRING_INITIALDLBWPSTARTSYMBOLANDLENGTH_8,NULL,0,i64ptr:&scc->downlinkConfigCommon->initialDownlinkBWP->pdsch_ConfigCommon->choice.setup->pdsch_TimeDomainAllocationList->list.array[8]->startSymbolAndLength,defint64val:54,TYPE_INT64,0/*41*/},\ -{GNB_CONFIG_STRING_INITIALDLBWPK0_9,NULL,0,i64ptr:scc->downlinkConfigCommon->initialDownlinkBWP->pdsch_ConfigCommon->choice.setup->pdsch_TimeDomainAllocationList->list.array[9]->k0,defint64val:-1,TYPE_INT64,0/*42*/}, \ -{GNB_CONFIG_STRING_INITIALDLBWPMAPPINGTYPE_9,NULL,0,i64ptr:&scc->downlinkConfigCommon->initialDownlinkBWP->pdsch_ConfigCommon->choice.setup->pdsch_TimeDomainAllocationList->list.array[9]->mappingType,defint64val:NR_PDSCH_TimeDomainResourceAllocation__mappingType_typeA,TYPE_INT64,0/*43*/},\ -{GNB_CONFIG_STRING_INITIALDLBWPSTARTSYMBOLANDLENGTH_9,NULL,0,i64ptr:&scc->downlinkConfigCommon->initialDownlinkBWP->pdsch_ConfigCommon->choice.setup->pdsch_TimeDomainAllocationList->list.array[9]->startSymbolAndLength,defint64val:54,TYPE_INT64,0/*44*/},\ -{GNB_CONFIG_STRING_INITIALDLBWPK0_10,NULL,0,i64ptr:scc->downlinkConfigCommon->initialDownlinkBWP->pdsch_ConfigCommon->choice.setup->pdsch_TimeDomainAllocationList->list.array[10]->k0,defint64val:-1,TYPE_INT64,0/*45*/},\ -{GNB_CONFIG_STRING_INITIALDLBWPMAPPINGTYPE_10,NULL,0,i64ptr:&scc->downlinkConfigCommon->initialDownlinkBWP->pdsch_ConfigCommon->choice.setup->pdsch_TimeDomainAllocationList->list.array[10]->mappingType,defint64val:NR_PDSCH_TimeDomainResourceAllocation__mappingType_typeA,TYPE_INT64,0/*46*/},\ -{GNB_CONFIG_STRING_INITIALDLBWPSTARTSYMBOLANDLENGTH_10,NULL,0,i64ptr:&scc->downlinkConfigCommon->initialDownlinkBWP->pdsch_ConfigCommon->choice.setup->pdsch_TimeDomainAllocationList->list.array[10]->startSymbolAndLength,defint64val:54,TYPE_INT64,0/*47*/},\ -{GNB_CONFIG_STRING_INITIALDLBWPK0_11,NULL,0,i64ptr:scc->downlinkConfigCommon->initialDownlinkBWP->pdsch_ConfigCommon->choice.setup->pdsch_TimeDomainAllocationList->list.array[11]->k0,defint64val:-1,TYPE_INT64,0/*48*/},\ -{GNB_CONFIG_STRING_INITIALDLBWPMAPPINGTYPE_11,NULL,0,i64ptr:&scc->downlinkConfigCommon->initialDownlinkBWP->pdsch_ConfigCommon->choice.setup->pdsch_TimeDomainAllocationList->list.array[11]->mappingType,defint64val:NR_PDSCH_TimeDomainResourceAllocation__mappingType_typeA,TYPE_INT64,0/*49*/},\ -{GNB_CONFIG_STRING_INITIALDLBWPSTARTSYMBOLANDLENGTH_11,NULL,0,i64ptr:&scc->downlinkConfigCommon->initialDownlinkBWP->pdsch_ConfigCommon->choice.setup->pdsch_TimeDomainAllocationList->list.array[11]->startSymbolAndLength,defint64val:54,TYPE_INT64,0/*50*/}, \ -{GNB_CONFIG_STRING_INITIALDLBWPK0_12,NULL,0,i64ptr:scc->downlinkConfigCommon->initialDownlinkBWP->pdsch_ConfigCommon->choice.setup->pdsch_TimeDomainAllocationList->list.array[12]->k0,defint64val:-1,TYPE_INT64,0/*51*/},\ -{GNB_CONFIG_STRING_INITIALDLBWPMAPPINGTYPE_12,NULL,0,i64ptr:&scc->downlinkConfigCommon->initialDownlinkBWP->pdsch_ConfigCommon->choice.setup->pdsch_TimeDomainAllocationList->list.array[12]->mappingType,defint64val:NR_PDSCH_TimeDomainResourceAllocation__mappingType_typeA,TYPE_INT64,0/*52*/},\ -{GNB_CONFIG_STRING_INITIALDLBWPSTARTSYMBOLANDLENGTH_12,NULL,0,i64ptr:&scc->downlinkConfigCommon->initialDownlinkBWP->pdsch_ConfigCommon->choice.setup->pdsch_TimeDomainAllocationList->list.array[12]->startSymbolAndLength,defint64val:54,TYPE_INT64,0/*53*/},\ -{GNB_CONFIG_STRING_INITIALDLBWPK0_13,NULL,0,i64ptr:scc->downlinkConfigCommon->initialDownlinkBWP->pdsch_ConfigCommon->choice.setup->pdsch_TimeDomainAllocationList->list.array[13]->k0,defint64val:-1,TYPE_INT64,0/*54*/},\ -{GNB_CONFIG_STRING_INITIALDLBWPMAPPINGTYPE_13,NULL,0,i64ptr:&scc->downlinkConfigCommon->initialDownlinkBWP->pdsch_ConfigCommon->choice.setup->pdsch_TimeDomainAllocationList->list.array[13]->mappingType,defint64val:NR_PDSCH_TimeDomainResourceAllocation__mappingType_typeA,TYPE_INT64,0/*55*/},\ -{GNB_CONFIG_STRING_INITIALDLBWPSTARTSYMBOLANDLENGTH_13,NULL,0,i64ptr:&scc->downlinkConfigCommon->initialDownlinkBWP->pdsch_ConfigCommon->choice.setup->pdsch_TimeDomainAllocationList->list.array[13]->startSymbolAndLength,defint64val:54,TYPE_INT64,0/*56*/},\ -{GNB_CONFIG_STRING_INITIALDLBWPK0_14,NULL,0,i64ptr:scc->downlinkConfigCommon->initialDownlinkBWP->pdsch_ConfigCommon->choice.setup->pdsch_TimeDomainAllocationList->list.array[14]->k0,defint64val:-1,TYPE_INT64,0/*57*/},\ -{GNB_CONFIG_STRING_INITIALDLBWPMAPPINGTYPE_14,NULL,0,i64ptr:&scc->downlinkConfigCommon->initialDownlinkBWP->pdsch_ConfigCommon->choice.setup->pdsch_TimeDomainAllocationList->list.array[14]->mappingType,defint64val:NR_PDSCH_TimeDomainResourceAllocation__mappingType_typeA,TYPE_INT64,0/*58*/},\ -{GNB_CONFIG_STRING_INITIALDLBWPSTARTSYMBOLANDLENGTH_14,NULL,0,i64ptr:&scc->downlinkConfigCommon->initialDownlinkBWP->pdsch_ConfigCommon->choice.setup->pdsch_TimeDomainAllocationList->list.array[14]->startSymbolAndLength,defint64val:54,TYPE_INT64,0/*59*/},\ -{GNB_CONFIG_STRING_INITIALDLBWPK0_15,NULL,0,i64ptr:scc->downlinkConfigCommon->initialDownlinkBWP->pdsch_ConfigCommon->choice.setup->pdsch_TimeDomainAllocationList->list.array[15]->k0,defint64val:-1,TYPE_INT64,0/*60*/}, \ -{GNB_CONFIG_STRING_INITIALDLBWPMAPPINGTYPE_15,NULL,0,i64ptr:&scc->downlinkConfigCommon->initialDownlinkBWP->pdsch_ConfigCommon->choice.setup->pdsch_TimeDomainAllocationList->list.array[15]->mappingType,defint64val:NR_PDSCH_TimeDomainResourceAllocation__mappingType_typeA,TYPE_INT64,0/*61*/},\ -{GNB_CONFIG_STRING_INITIALDLBWPSTARTSYMBOLANDLENGTH_15,NULL,0,i64ptr:&scc->downlinkConfigCommon->initialDownlinkBWP->pdsch_ConfigCommon->choice.setup->pdsch_TimeDomainAllocationList->list.array[15]->startSymbolAndLength,defint64val:54,TYPE_INT64,0/*62*/},\ {GNB_CONFIG_STRING_ULFREQUENCYBAND,NULL,0,i64ptr:scc->uplinkConfigCommon->frequencyInfoUL->frequencyBandList->list.array[0],defint64val:-1,TYPE_INT64,0/*63*/},\ {GNB_CONFIG_STRING_ULABSOLUEFREQUENCYPOINTA,NULL,0,i64ptr:scc->uplinkConfigCommon->frequencyInfoUL->absoluteFrequencyPointA,defint64val:-1,TYPE_INT64,0/*64*/},\ {GNB_CONFIG_STRING_ULOFFSETTOCARRIER,NULL,0,i64ptr:&scc->uplinkConfigCommon->frequencyInfoUL->scs_SpecificCarrierList.list.array[0]->offsetToCarrier,defint64val:0,TYPE_INT64,0/*65*/},\ @@ -345,54 +199,6 @@ {GNB_CONFIG_STRING_PRACHROOTSEQUENCEINDEX,NULL,0,i64ptr:&scc->uplinkConfigCommon->initialUplinkBWP->rach_ConfigCommon->choice.setup->prach_RootSequenceIndex.choice.l139,defint64val:0,TYPE_INT64,0/*84*/},\ {GNB_CONFIG_STRING_RESTRICTEDSETCONFIG,NULL,0,i64ptr:&scc->uplinkConfigCommon->initialUplinkBWP->rach_ConfigCommon->choice.setup->restrictedSetConfig,defintval:NR_RACH_ConfigCommon__restrictedSetConfig_unrestrictedSet,TYPE_INT64,0/*85*/}, \ {GNB_CONFIG_STRING_MSG3TRANSFPREC,NULL,0,i64ptr:scc->uplinkConfigCommon->initialUplinkBWP->rach_ConfigCommon->choice.setup->msg3_transformPrecoder,defintval:1,TYPE_INT64,0/*86*/}, \ -{GNB_CONFIG_STRING_INITIALULBWPK2_0,NULL,0,i64ptr:scc->uplinkConfigCommon->initialUplinkBWP->pusch_ConfigCommon->choice.setup->pusch_TimeDomainAllocationList->list.array[0]->k2,defint64val:-1,TYPE_INT64,0/*87*/},\ -{GNB_CONFIG_STRING_INITIALULBWPMAPPINGTYPE_0,NULL,0,i64ptr:&scc->uplinkConfigCommon->initialUplinkBWP->pusch_ConfigCommon->choice.setup->pusch_TimeDomainAllocationList->list.array[0]->mappingType,defint64val:NR_PDSCH_TimeDomainResourceAllocation__mappingType_typeB,TYPE_INT64,/*88*/},\ -{GNB_CONFIG_STRING_INITIALULBWPSTARTSYMBOLANDLENGTH_0,NULL,0,i64ptr:&scc->uplinkConfigCommon->initialUplinkBWP->pusch_ConfigCommon->choice.setup->pusch_TimeDomainAllocationList->list.array[0]->startSymbolAndLength,defint64val:55,TYPE_INT64,0/*89*/},\ -{GNB_CONFIG_STRING_INITIALULBWPK2_1,NULL,0,i64ptr:scc->uplinkConfigCommon->initialUplinkBWP->pusch_ConfigCommon->choice.setup->pusch_TimeDomainAllocationList->list.array[1]->k2,defint64val:-1,TYPE_INT64,0/*90*/}, \ -{GNB_CONFIG_STRING_INITIALULBWPMAPPINGTYPE_1,NULL,0,i64ptr:&scc->uplinkConfigCommon->initialUplinkBWP->pusch_ConfigCommon->choice.setup->pusch_TimeDomainAllocationList->list.array[1]->mappingType,defint64val:NR_PUSCH_TimeDomainResourceAllocation__mappingType_typeB,TYPE_INT64,0},\ -{GNB_CONFIG_STRING_INITIALULBWPSTARTSYMBOLANDLENGTH_1,NULL,0,i64ptr:&scc->uplinkConfigCommon->initialUplinkBWP->pusch_ConfigCommon->choice.setup->pusch_TimeDomainAllocationList->list.array[1]->startSymbolAndLength,defint64val:53,TYPE_INT64,0},\ -{GNB_CONFIG_STRING_INITIALULBWPK2_2,NULL,0,i64ptr:scc->uplinkConfigCommon->initialUplinkBWP->pusch_ConfigCommon->choice.setup->pusch_TimeDomainAllocationList->list.array[2]->k2,defint64val:-1,TYPE_INT64,0},\ -{GNB_CONFIG_STRING_INITIALULBWPMAPPINGTYPE_2,NULL,0,i64ptr:&scc->uplinkConfigCommon->initialUplinkBWP->pusch_ConfigCommon->choice.setup->pusch_TimeDomainAllocationList->list.array[2]->mappingType,defint64val:NR_PDSCH_TimeDomainResourceAllocation__mappingType_typeB,TYPE_INT64,0},\ -{GNB_CONFIG_STRING_INITIALULBWPSTARTSYMBOLANDLENGTH_2,NULL,0,i64ptr:&scc->uplinkConfigCommon->initialUplinkBWP->pusch_ConfigCommon->choice.setup->pusch_TimeDomainAllocationList->list.array[2]->startSymbolAndLength,defint64val:55,TYPE_INT64,0},\ -{GNB_CONFIG_STRING_INITIALULBWPK2_3,NULL,0,i64ptr:scc->uplinkConfigCommon->initialUplinkBWP->pusch_ConfigCommon->choice.setup->pusch_TimeDomainAllocationList->list.array[3]->k2,defint64val:-1,TYPE_INT64,0},\ -{GNB_CONFIG_STRING_INITIALULBWPMAPPINGTYPE_3,NULL,0,i64ptr:&scc->uplinkConfigCommon->initialUplinkBWP->pusch_ConfigCommon->choice.setup->pusch_TimeDomainAllocationList->list.array[3]->mappingType,defint64val:NR_PUSCH_TimeDomainResourceAllocation__mappingType_typeB,TYPE_INT64,0},\ -{GNB_CONFIG_STRING_INITIALULBWPSTARTSYMBOLANDLENGTH_3,NULL,0,i64ptr:&scc->uplinkConfigCommon->initialUplinkBWP->pusch_ConfigCommon->choice.setup->pusch_TimeDomainAllocationList->list.array[3]->startSymbolAndLength,defint64val:53,TYPE_INT64,0},\ -{GNB_CONFIG_STRING_INITIALULBWPK2_4,NULL,0,i64ptr:scc->uplinkConfigCommon->initialUplinkBWP->pusch_ConfigCommon->choice.setup->pusch_TimeDomainAllocationList->list.array[4]->k2,defint64val:-1,TYPE_INT64,0},\ -{GNB_CONFIG_STRING_INITIALULBWPMAPPINGTYPE_4,NULL,0,i64ptr:&scc->uplinkConfigCommon->initialUplinkBWP->pusch_ConfigCommon->choice.setup->pusch_TimeDomainAllocationList->list.array[4]->mappingType,defint64val:NR_PDSCH_TimeDomainResourceAllocation__mappingType_typeB,TYPE_INT64,0 /*100*/}, \ -{GNB_CONFIG_STRING_INITIALULBWPSTARTSYMBOLANDLENGTH_4,NULL,0,i64ptr:&scc->uplinkConfigCommon->initialUplinkBWP->pusch_ConfigCommon->choice.setup->pusch_TimeDomainAllocationList->list.array[4]->startSymbolAndLength,defint64val:55,TYPE_INT64,0},\ -{GNB_CONFIG_STRING_INITIALULBWPK2_5,NULL,0,i64ptr:scc->uplinkConfigCommon->initialUplinkBWP->pusch_ConfigCommon->choice.setup->pusch_TimeDomainAllocationList->list.array[5]->k2,defint64val:-1,TYPE_INT64,0},\ -{GNB_CONFIG_STRING_INITIALULBWPMAPPINGTYPE_5,NULL,0,i64ptr:&scc->uplinkConfigCommon->initialUplinkBWP->pusch_ConfigCommon->choice.setup->pusch_TimeDomainAllocationList->list.array[5]->mappingType,defint64val:NR_PUSCH_TimeDomainResourceAllocation__mappingType_typeB,TYPE_INT64,0},\ -{GNB_CONFIG_STRING_INITIALULBWPSTARTSYMBOLANDLENGTH_5,NULL,0,i64ptr:&scc->uplinkConfigCommon->initialUplinkBWP->pusch_ConfigCommon->choice.setup->pusch_TimeDomainAllocationList->list.array[5]->startSymbolAndLength,defint64val:53,TYPE_INT64,0},\ -{GNB_CONFIG_STRING_INITIALULBWPK2_6,NULL,0,i64ptr:scc->uplinkConfigCommon->initialUplinkBWP->pusch_ConfigCommon->choice.setup->pusch_TimeDomainAllocationList->list.array[6]->k2,defint64val:-1,TYPE_INT64,0},\ -{GNB_CONFIG_STRING_INITIALULBWPMAPPINGTYPE_6,NULL,0,i64ptr:&scc->uplinkConfigCommon->initialUplinkBWP->pusch_ConfigCommon->choice.setup->pusch_TimeDomainAllocationList->list.array[6]->mappingType,defint64val:NR_PDSCH_TimeDomainResourceAllocation__mappingType_typeB,TYPE_INT64,0},\ -{GNB_CONFIG_STRING_INITIALULBWPSTARTSYMBOLANDLENGTH_6,NULL,0,i64ptr:&scc->uplinkConfigCommon->initialUplinkBWP->pusch_ConfigCommon->choice.setup->pusch_TimeDomainAllocationList->list.array[6]->startSymbolAndLength,defint64val:55,TYPE_INT64,0},\ -{GNB_CONFIG_STRING_INITIALULBWPK2_7,NULL,0,i64ptr:scc->uplinkConfigCommon->initialUplinkBWP->pusch_ConfigCommon->choice.setup->pusch_TimeDomainAllocationList->list.array[7]->k2,defint64val:-1,TYPE_INT64,0},\ -{GNB_CONFIG_STRING_INITIALULBWPMAPPINGTYPE_7,NULL,0,i64ptr:&scc->uplinkConfigCommon->initialUplinkBWP->pusch_ConfigCommon->choice.setup->pusch_TimeDomainAllocationList->list.array[7]->mappingType,defint64val:NR_PUSCH_TimeDomainResourceAllocation__mappingType_typeB,TYPE_INT64,0},\ -{GNB_CONFIG_STRING_INITIALULBWPSTARTSYMBOLANDLENGTH_7,NULL,0,i64ptr:&scc->uplinkConfigCommon->initialUplinkBWP->pusch_ConfigCommon->choice.setup->pusch_TimeDomainAllocationList->list.array[7]->startSymbolAndLength,defint64val:53,TYPE_INT64,0/*110*/}, \ -{GNB_CONFIG_STRING_INITIALULBWPK2_8,NULL,0,i64ptr:scc->uplinkConfigCommon->initialUplinkBWP->pusch_ConfigCommon->choice.setup->pusch_TimeDomainAllocationList->list.array[8]->k2,defint64val:-1,TYPE_INT64,0},\ -{GNB_CONFIG_STRING_INITIALULBWPMAPPINGTYPE_8,NULL,0,i64ptr:&scc->uplinkConfigCommon->initialUplinkBWP->pusch_ConfigCommon->choice.setup->pusch_TimeDomainAllocationList->list.array[8]->mappingType,defint64val:NR_PDSCH_TimeDomainResourceAllocation__mappingType_typeB,TYPE_INT64,0},\ -{GNB_CONFIG_STRING_INITIALULBWPSTARTSYMBOLANDLENGTH_8,NULL,0,i64ptr:&scc->uplinkConfigCommon->initialUplinkBWP->pusch_ConfigCommon->choice.setup->pusch_TimeDomainAllocationList->list.array[8]->startSymbolAndLength,defint64val:55,TYPE_INT64,0},\ -{GNB_CONFIG_STRING_INITIALULBWPK2_9,NULL,0,i64ptr:scc->uplinkConfigCommon->initialUplinkBWP->pusch_ConfigCommon->choice.setup->pusch_TimeDomainAllocationList->list.array[9]->k2,defint64val:-1,TYPE_INT64,0},\ -{GNB_CONFIG_STRING_INITIALULBWPMAPPINGTYPE_9,NULL,0,i64ptr:&scc->uplinkConfigCommon->initialUplinkBWP->pusch_ConfigCommon->choice.setup->pusch_TimeDomainAllocationList->list.array[9]->mappingType,defint64val:NR_PUSCH_TimeDomainResourceAllocation__mappingType_typeB,TYPE_INT64,0},\ -{GNB_CONFIG_STRING_INITIALULBWPSTARTSYMBOLANDLENGTH_9,NULL,0,i64ptr:&scc->uplinkConfigCommon->initialUplinkBWP->pusch_ConfigCommon->choice.setup->pusch_TimeDomainAllocationList->list.array[9]->startSymbolAndLength,defint64val:53,TYPE_INT64,0},\ -{GNB_CONFIG_STRING_INITIALULBWPK2_10,NULL,0,i64ptr:scc->uplinkConfigCommon->initialUplinkBWP->pusch_ConfigCommon->choice.setup->pusch_TimeDomainAllocationList->list.array[10]->k2,defint64val:-1,TYPE_INT64,0},\ -{GNB_CONFIG_STRING_INITIALULBWPMAPPINGTYPE_10,NULL,0,i64ptr:&scc->uplinkConfigCommon->initialUplinkBWP->pusch_ConfigCommon->choice.setup->pusch_TimeDomainAllocationList->list.array[10]->mappingType,defint64val:NR_PDSCH_TimeDomainResourceAllocation__mappingType_typeB,TYPE_INT64,0},\ -{GNB_CONFIG_STRING_INITIALULBWPSTARTSYMBOLANDLENGTH_10,NULL,0,i64ptr:&scc->uplinkConfigCommon->initialUplinkBWP->pusch_ConfigCommon->choice.setup->pusch_TimeDomainAllocationList->list.array[10]->startSymbolAndLength,defint64val:55,TYPE_INT64,0},\ -{GNB_CONFIG_STRING_INITIALULBWPK2_11,NULL,0,i64ptr:scc->uplinkConfigCommon->initialUplinkBWP->pusch_ConfigCommon->choice.setup->pusch_TimeDomainAllocationList->list.array[11]->k2,defint64val:-1,TYPE_INT64,0/*120*/}, \ -{GNB_CONFIG_STRING_INITIALULBWPMAPPINGTYPE_11,NULL,0,i64ptr:&scc->uplinkConfigCommon->initialUplinkBWP->pusch_ConfigCommon->choice.setup->pusch_TimeDomainAllocationList->list.array[11]->mappingType,defint64val:NR_PUSCH_TimeDomainResourceAllocation__mappingType_typeB,TYPE_INT64,0},\ -{GNB_CONFIG_STRING_INITIALULBWPSTARTSYMBOLANDLENGTH_11,NULL,0,i64ptr:&scc->uplinkConfigCommon->initialUplinkBWP->pusch_ConfigCommon->choice.setup->pusch_TimeDomainAllocationList->list.array[11]->startSymbolAndLength,defint64val:53,TYPE_INT64,0},\ -{GNB_CONFIG_STRING_INITIALULBWPK2_12,NULL,0,i64ptr:scc->uplinkConfigCommon->initialUplinkBWP->pusch_ConfigCommon->choice.setup->pusch_TimeDomainAllocationList->list.array[12]->k2,defint64val:-1,TYPE_INT64,0},\ -{GNB_CONFIG_STRING_INITIALULBWPMAPPINGTYPE_12,NULL,0,i64ptr:&scc->uplinkConfigCommon->initialUplinkBWP->pusch_ConfigCommon->choice.setup->pusch_TimeDomainAllocationList->list.array[12]->mappingType,defint64val:NR_PDSCH_TimeDomainResourceAllocation__mappingType_typeB,TYPE_INT64,0},\ -{GNB_CONFIG_STRING_INITIALULBWPSTARTSYMBOLANDLENGTH_12,NULL,0,i64ptr:&scc->uplinkConfigCommon->initialUplinkBWP->pusch_ConfigCommon->choice.setup->pusch_TimeDomainAllocationList->list.array[12]->startSymbolAndLength,defint64val:55,TYPE_INT64,0},\ -{GNB_CONFIG_STRING_INITIALULBWPK2_13,NULL,0,i64ptr:scc->uplinkConfigCommon->initialUplinkBWP->pusch_ConfigCommon->choice.setup->pusch_TimeDomainAllocationList->list.array[13]->k2,defint64val:-1,TYPE_INT64,0},\ -{GNB_CONFIG_STRING_INITIALULBWPMAPPINGTYPE_13,NULL,0,i64ptr:&scc->uplinkConfigCommon->initialUplinkBWP->pusch_ConfigCommon->choice.setup->pusch_TimeDomainAllocationList->list.array[13]->mappingType,defint64val:NR_PUSCH_TimeDomainResourceAllocation__mappingType_typeB,TYPE_INT64,0},\ -{GNB_CONFIG_STRING_INITIALULBWPSTARTSYMBOLANDLENGTH_13,NULL,0,i64ptr:&scc->uplinkConfigCommon->initialUplinkBWP->pusch_ConfigCommon->choice.setup->pusch_TimeDomainAllocationList->list.array[13]->startSymbolAndLength,defint64val:53,TYPE_INT64,0},\ -{GNB_CONFIG_STRING_INITIALULBWPK2_14,NULL,0,i64ptr:scc->uplinkConfigCommon->initialUplinkBWP->pusch_ConfigCommon->choice.setup->pusch_TimeDomainAllocationList->list.array[14]->k2,defint64val:-1,TYPE_INT64,0},\ -{GNB_CONFIG_STRING_INITIALULBWPMAPPINGTYPE_14,NULL,0,i64ptr:&scc->uplinkConfigCommon->initialUplinkBWP->pusch_ConfigCommon->choice.setup->pusch_TimeDomainAllocationList->list.array[14]->mappingType,defint64val:NR_PDSCH_TimeDomainResourceAllocation__mappingType_typeB,TYPE_INT64,0 /*130*/}, \ -{GNB_CONFIG_STRING_INITIALULBWPSTARTSYMBOLANDLENGTH_14,NULL,0,i64ptr:&scc->uplinkConfigCommon->initialUplinkBWP->pusch_ConfigCommon->choice.setup->pusch_TimeDomainAllocationList->list.array[14]->startSymbolAndLength,defint64val:55,TYPE_INT64,0},\ -{GNB_CONFIG_STRING_INITIALULBWPK2_15,NULL,0,i64ptr:scc->uplinkConfigCommon->initialUplinkBWP->pusch_ConfigCommon->choice.setup->pusch_TimeDomainAllocationList->list.array[15]->k2,defint64val:-1,TYPE_INT64,0},\ -{GNB_CONFIG_STRING_INITIALULBWPMAPPINGTYPE_15,NULL,0,i64ptr:&scc->uplinkConfigCommon->initialUplinkBWP->pusch_ConfigCommon->choice.setup->pusch_TimeDomainAllocationList->list.array[15]->mappingType,defint64val:NR_PUSCH_TimeDomainResourceAllocation__mappingType_typeB,TYPE_INT64,0},\ -{GNB_CONFIG_STRING_INITIALULBWPSTARTSYMBOLANDLENGTH_15,NULL,0,i64ptr:&scc->uplinkConfigCommon->initialUplinkBWP->pusch_ConfigCommon->choice.setup->pusch_TimeDomainAllocationList->list.array[15]->startSymbolAndLength,defint64val:53,TYPE_INT64,0},\ {GNB_CONFIG_STRING_MSG3DELTAPREABMLE, NULL,0,i64ptr:scc->uplinkConfigCommon->initialUplinkBWP->pusch_ConfigCommon->choice.setup->msg3_DeltaPreamble,defint64val:1,TYPE_INT64,0},\ {GNB_CONFIG_STRING_P0NOMINALWITHGRANT, NULL,0,i64ptr:scc->uplinkConfigCommon->initialUplinkBWP->pusch_ConfigCommon->choice.setup->p0_NominalWithGrant,defint64val:1,TYPE_INT64,0},\ {GNB_CONFIG_STRING_PUCCHGROUPHOPPING, NULL,0,i64ptr:&scc->uplinkConfigCommon->initialUplinkBWP->pucch_ConfigCommon->choice.setup->pucch_GroupHopping,defint64val:NR_PUCCH_ConfigCommon__pucch_GroupHopping_neither,TYPE_INT64,0},\ diff --git a/openair2/GNB_APP/gnb_app.c b/openair2/GNB_APP/gnb_app.c index 510402139995171f0dc43fab6b1eacbea3989cec..7d51d95840635fe98dcfc104f07392797b74c106 100644 --- a/openair2/GNB_APP/gnb_app.c +++ b/openair2/GNB_APP/gnb_app.c @@ -51,6 +51,7 @@ #include "f1ap_du_task.h" #include "nfapi/oai_integration/vendor_ext.h" #include <openair2/LAYER2/nr_pdcp/nr_pdcp.h> +#include "openair2/LAYER2/PDCP_v10.1.0/pdcp.h" extern unsigned char NB_gNB_INST; extern RAN_CONTEXT_t RC; @@ -144,19 +145,19 @@ static void init_pdcp(void) { pdcp_initmask = pdcp_initmask | ENB_NAS_USE_TUN_BIT | SOFTMODEM_NOKRNMOD_BIT; } - pdcp_module_init(pdcp_initmask); + nr_pdcp_module_init(pdcp_initmask, 0); if (NODE_IS_CU(RC.nrrrc[0]->node_type)) { LOG_I(PDCP, "node is CU, pdcp send rlc_data_req by proto_agent \n"); - pdcp_set_rlc_data_req_func((send_rlc_data_req_func_t)proto_agent_send_rlc_data_req); + pdcp_set_rlc_data_req_func(proto_agent_send_rlc_data_req); } else { LOG_I(PDCP, "node is gNB \n"); - pdcp_set_rlc_data_req_func((send_rlc_data_req_func_t) rlc_data_req); - pdcp_set_pdcp_data_ind_func((pdcp_data_ind_func_t) pdcp_data_ind); + pdcp_set_rlc_data_req_func(rlc_data_req); + pdcp_set_pdcp_data_ind_func(pdcp_data_ind); } } else { LOG_I(PDCP, "node is DU, rlc send pdcp_data_ind by proto_agent \n"); - pdcp_set_pdcp_data_ind_func((pdcp_data_ind_func_t) proto_agent_send_pdcp_data_ind); + pdcp_set_pdcp_data_ind_func(proto_agent_send_pdcp_data_ind); } } @@ -181,6 +182,8 @@ void *gNB_app_task(void *args_p) LOG_I(PHY, "%s() Task ready initialize structures\n", __FUNCTION__); + RCconfig_NR_L1(); + if (RC.nb_nr_macrlc_inst>0) RCconfig_nr_macrlc(); LOG_I(PHY, "%s() RC.nb_nr_L1_inst:%d\n", __FUNCTION__, RC.nb_nr_L1_inst); @@ -195,15 +198,13 @@ void *gNB_app_task(void *args_p) RC.nrrrc = (gNB_RRC_INST **)malloc(RC.nb_nr_inst*sizeof(gNB_RRC_INST *)); LOG_I(PHY, "%s() RC.nb_nr_inst:%d RC.nrrrc:%p\n", __FUNCTION__, RC.nb_nr_inst, RC.nrrrc); - for (gnb_id = gnb_id_start; (gnb_id < gnb_id_end) ; gnb_id++) { - RC.nrrrc[gnb_id] = (gNB_RRC_INST*)malloc(sizeof(gNB_RRC_INST)); + RC.nrrrc[gnb_id] = (gNB_RRC_INST*)calloc(1,sizeof(gNB_RRC_INST)); LOG_I(PHY, "%s() Creating RRC instance RC.nrrrc[%d]:%p (%d of %d)\n", __FUNCTION__, gnb_id, RC.nrrrc[gnb_id], gnb_id+1, gnb_id_end); - memset((void *)RC.nrrrc[gnb_id],0,sizeof(gNB_RRC_INST)); configure_nr_rrc(gnb_id); } - if (RC.nb_nr_inst > 0) { + if (RC.nb_nr_inst > 0 && !get_softmodem_params()->nsa) { init_pdcp(); } @@ -214,7 +215,7 @@ void *gNB_app_task(void *args_p) /* For the CU case the gNB registration with the AMF might have to take place after the F1 setup, as the PLMN info * can originate from the DU. Add check on whether x2ap is enabled to account for ENDC NSA scenario.*/ - if ((AMF_MODE_ENABLED || is_x2ap_enabled()) && !NODE_IS_DU(RC.nrrrc[0]->node_type) && !NODE_IS_CU(RC.nrrrc[0]->node_type)) { + if ((AMF_MODE_ENABLED || is_x2ap_enabled()) && !NODE_IS_DU(RC.nrrrc[0]->node_type) ) { //&& !NODE_IS_CU(RC.nrrrc[0]->node_type)) { /* Try to register each gNB */ //registered_gnb = 0; __attribute__((unused)) uint32_t register_gnb_pending = gNB_app_register (gnb_id_start, gnb_id_end); diff --git a/openair2/GNB_APP/gnb_config.c b/openair2/GNB_APP/gnb_config.c index 7f851641401f9fecec82dc42fdd32b40922231c8..88248315f58b73095fe207e0083c325b3b068bb9 100644 --- a/openair2/GNB_APP/gnb_config.c +++ b/openair2/GNB_APP/gnb_config.c @@ -94,8 +94,6 @@ void prepare_scc(NR_ServingCellConfigCommon_t *scc) { NR_FreqBandIndicatorNR_t *dl_frequencyBandList,*ul_frequencyBandList; struct NR_SCS_SpecificCarrier *dl_scs_SpecificCarrierList,*ul_scs_SpecificCarrierList; - struct NR_PDSCH_TimeDomainResourceAllocation *bwp_dl_timedomainresourceallocation; - struct NR_PUSCH_TimeDomainResourceAllocation *pusch_configcommontimedomainresourceallocation; // struct NR_RateMatchPattern *ratematchpattern; // NR_RateMatchPatternId_t *ratematchpatternid; // NR_TCI_StateId_t *TCI_StateId; @@ -143,14 +141,6 @@ void prepare_scc(NR_ServingCellConfigCommon_t *scc) { scc->downlinkConfigCommon->initialDownlinkBWP->pdsch_ConfigCommon->present = NR_SetupRelease_PDSCH_ConfigCommon_PR_setup; scc->downlinkConfigCommon->initialDownlinkBWP->pdsch_ConfigCommon->choice.setup = CALLOC(1,sizeof(struct NR_PDSCH_ConfigCommon)); scc->downlinkConfigCommon->initialDownlinkBWP->pdsch_ConfigCommon->choice.setup->pdsch_TimeDomainAllocationList = CALLOC(1,sizeof(struct NR_PDSCH_TimeDomainResourceAllocationList)); - // - for (int i=0;i<NR_maxNrofDL_Allocations;i++) { - bwp_dl_timedomainresourceallocation = CALLOC(1,sizeof(NR_PDSCH_TimeDomainResourceAllocation_t)); - bwp_dl_timedomainresourceallocation->k0 = CALLOC(1,sizeof(long)); - *bwp_dl_timedomainresourceallocation->k0=0; - ASN_SEQUENCE_ADD(&scc->downlinkConfigCommon->initialDownlinkBWP->pdsch_ConfigCommon->choice.setup->pdsch_TimeDomainAllocationList->list, - bwp_dl_timedomainresourceallocation); - } ul_frequencyBandList = CALLOC(1,sizeof(NR_FreqBandIndicatorNR_t)); scc->uplinkConfigCommon->frequencyInfoUL->frequencyBandList = CALLOC(1,sizeof(struct NR_MultiFrequencyBandListNR)); @@ -199,12 +189,6 @@ void prepare_scc(NR_ServingCellConfigCommon_t *scc) { ul_scs_SpecificCarrierList = CALLOC(1,sizeof(struct NR_SCS_SpecificCarrier)); ASN_SEQUENCE_ADD(&scc->uplinkConfigCommon->frequencyInfoUL->scs_SpecificCarrierList.list,ul_scs_SpecificCarrierList); - for (int i=0;i<NR_maxNrofUL_Allocations;i++) { - pusch_configcommontimedomainresourceallocation = CALLOC(1,sizeof(struct NR_PUSCH_TimeDomainResourceAllocation)); - pusch_configcommontimedomainresourceallocation->k2 = CALLOC(1,sizeof(long)); - *pusch_configcommontimedomainresourceallocation->k2=0; - ASN_SEQUENCE_ADD(&scc->uplinkConfigCommon->initialUplinkBWP->pusch_ConfigCommon->choice.setup->pusch_TimeDomainAllocationList->list,pusch_configcommontimedomainresourceallocation); - } //ratematchpattern = CALLOC(1,sizeof(struct NR_RateMatchPattern)); //ratematchpattern->patternType.choice.bitmaps = CALLOC(1,sizeof(struct NR_RateMatchPattern__patternType__bitmaps)); //ratematchpattern->patternType.choice.bitmaps->resourceBlocks.buf = MALLOC(35); @@ -223,6 +207,92 @@ void prepare_scc(NR_ServingCellConfigCommon_t *scc) { } +void fill_scc_sim(NR_ServingCellConfigCommon_t *scc,uint64_t *ssb_bitmap,int N_RB_DL,int N_RB_UL,int mu_dl,int mu_ul) { + + *scc->physCellId=0; \ + // *scc->n_TimingAdvanceOffset=NR_ServingCellConfigCommon__n_TimingAdvanceOffset_n0; + *scc->ssb_periodicityServingCell=NR_ServingCellConfigCommon__ssb_periodicityServingCell_ms20; + scc->dmrs_TypeA_Position=NR_ServingCellConfigCommon__dmrs_TypeA_Position_pos2; + *scc->ssbSubcarrierSpacing=NR_SubcarrierSpacing_kHz30; + *scc->downlinkConfigCommon->frequencyInfoDL->absoluteFrequencySSB=641032; + *scc->downlinkConfigCommon->frequencyInfoDL->frequencyBandList.list.array[0]=78; + scc->downlinkConfigCommon->frequencyInfoDL->absoluteFrequencyPointA=640000; + scc->downlinkConfigCommon->frequencyInfoDL->scs_SpecificCarrierList.list.array[0]->offsetToCarrier=0; + scc->downlinkConfigCommon->frequencyInfoDL->scs_SpecificCarrierList.list.array[0]->subcarrierSpacing=NR_SubcarrierSpacing_kHz30; + + scc->downlinkConfigCommon->frequencyInfoDL->scs_SpecificCarrierList.list.array[0]->carrierBandwidth=N_RB_DL; + scc->downlinkConfigCommon->initialDownlinkBWP->genericParameters.locationAndBandwidth=13036; + scc->downlinkConfigCommon->initialDownlinkBWP->genericParameters.subcarrierSpacing=mu_dl;//NR_SubcarrierSpacing_kHz30; + *scc->downlinkConfigCommon->initialDownlinkBWP->pdcch_ConfigCommon->choice.setup->controlResourceSetZero=12; + *scc->downlinkConfigCommon->initialDownlinkBWP->pdcch_ConfigCommon->choice.setup->searchSpaceZero=0; + struct NR_PDSCH_TimeDomainResourceAllocation *timedomainresourceallocation0 = CALLOC(1,sizeof(NR_PDSCH_TimeDomainResourceAllocation_t)); + timedomainresourceallocation0->mappingType=NR_PDSCH_TimeDomainResourceAllocation__mappingType_typeA; + timedomainresourceallocation0->startSymbolAndLength=54; + ASN_SEQUENCE_ADD(&scc->downlinkConfigCommon->initialDownlinkBWP->pdsch_ConfigCommon->choice.setup->pdsch_TimeDomainAllocationList->list, + timedomainresourceallocation0); + struct NR_PDSCH_TimeDomainResourceAllocation *timedomainresourceallocation1 = CALLOC(1,sizeof(NR_PDSCH_TimeDomainResourceAllocation_t)); + timedomainresourceallocation1->mappingType=NR_PDSCH_TimeDomainResourceAllocation__mappingType_typeA; + timedomainresourceallocation1->startSymbolAndLength=57; + ASN_SEQUENCE_ADD(&scc->downlinkConfigCommon->initialDownlinkBWP->pdsch_ConfigCommon->choice.setup->pdsch_TimeDomainAllocationList->list, + timedomainresourceallocation1); + *scc->uplinkConfigCommon->frequencyInfoUL->frequencyBandList->list.array[0]=78; + *scc->uplinkConfigCommon->frequencyInfoUL->absoluteFrequencyPointA=-1; + scc->uplinkConfigCommon->frequencyInfoUL->scs_SpecificCarrierList.list.array[0]->offsetToCarrier=0; + scc->uplinkConfigCommon->frequencyInfoUL->scs_SpecificCarrierList.list.array[0]->subcarrierSpacing=NR_SubcarrierSpacing_kHz30; + scc->uplinkConfigCommon->frequencyInfoUL->scs_SpecificCarrierList.list.array[0]->carrierBandwidth=N_RB_UL; + *scc->uplinkConfigCommon->frequencyInfoUL->p_Max=20; + scc->uplinkConfigCommon->initialUplinkBWP->genericParameters.locationAndBandwidth=13036; + scc->uplinkConfigCommon->initialUplinkBWP->genericParameters.subcarrierSpacing=mu_ul;//NR_SubcarrierSpacing_kHz30; + scc->uplinkConfigCommon->initialUplinkBWP->rach_ConfigCommon->choice.setup->rach_ConfigGeneric.prach_ConfigurationIndex=98; + scc->uplinkConfigCommon->initialUplinkBWP->rach_ConfigCommon->choice.setup->rach_ConfigGeneric.msg1_FDM=NR_RACH_ConfigGeneric__msg1_FDM_one; + scc->uplinkConfigCommon->initialUplinkBWP->rach_ConfigCommon->choice.setup->rach_ConfigGeneric.msg1_FrequencyStart=0; + scc->uplinkConfigCommon->initialUplinkBWP->rach_ConfigCommon->choice.setup->rach_ConfigGeneric.zeroCorrelationZoneConfig=13; + scc->uplinkConfigCommon->initialUplinkBWP->rach_ConfigCommon->choice.setup->rach_ConfigGeneric.preambleReceivedTargetPower=-118; + scc->uplinkConfigCommon->initialUplinkBWP->rach_ConfigCommon->choice.setup->rach_ConfigGeneric.preambleTransMax=NR_RACH_ConfigGeneric__preambleTransMax_n10; + scc->uplinkConfigCommon->initialUplinkBWP->rach_ConfigCommon->choice.setup->rach_ConfigGeneric.powerRampingStep=NR_RACH_ConfigGeneric__powerRampingStep_dB2; + scc->uplinkConfigCommon->initialUplinkBWP->rach_ConfigCommon->choice.setup->rach_ConfigGeneric.ra_ResponseWindow=NR_RACH_ConfigGeneric__ra_ResponseWindow_sl20; + scc->uplinkConfigCommon->initialUplinkBWP->rach_ConfigCommon->choice.setup->ssb_perRACH_OccasionAndCB_PreamblesPerSSB->present=NR_RACH_ConfigCommon__ssb_perRACH_OccasionAndCB_PreamblesPerSSB_PR_one; + scc->uplinkConfigCommon->initialUplinkBWP->rach_ConfigCommon->choice.setup->ssb_perRACH_OccasionAndCB_PreamblesPerSSB->choice.one=NR_RACH_ConfigCommon__ssb_perRACH_OccasionAndCB_PreamblesPerSSB__one_n64; + scc->uplinkConfigCommon->initialUplinkBWP->rach_ConfigCommon->choice.setup->ra_ContentionResolutionTimer=NR_RACH_ConfigCommon__ra_ContentionResolutionTimer_sf64; + *scc->uplinkConfigCommon->initialUplinkBWP->rach_ConfigCommon->choice.setup->rsrp_ThresholdSSB=19; + scc->uplinkConfigCommon->initialUplinkBWP->rach_ConfigCommon->choice.setup->prach_RootSequenceIndex.present=NR_RACH_ConfigCommon__prach_RootSequenceIndex_PR_l139; + scc->uplinkConfigCommon->initialUplinkBWP->rach_ConfigCommon->choice.setup->prach_RootSequenceIndex.choice.l139=0; + scc->uplinkConfigCommon->initialUplinkBWP->rach_ConfigCommon->choice.setup->restrictedSetConfig=NR_RACH_ConfigCommon__restrictedSetConfig_unrestrictedSet; + struct NR_PUSCH_TimeDomainResourceAllocation *pusch_timedomainresourceallocation0 = CALLOC(1,sizeof(struct NR_PUSCH_TimeDomainResourceAllocation)); + pusch_timedomainresourceallocation0->k2 = CALLOC(1,sizeof(long)); + *pusch_timedomainresourceallocation0->k2=6; + pusch_timedomainresourceallocation0->mappingType=NR_PUSCH_TimeDomainResourceAllocation__mappingType_typeB; + pusch_timedomainresourceallocation0->startSymbolAndLength=55; + ASN_SEQUENCE_ADD(&scc->uplinkConfigCommon->initialUplinkBWP->pusch_ConfigCommon->choice.setup->pusch_TimeDomainAllocationList->list,pusch_timedomainresourceallocation0); + struct NR_PUSCH_TimeDomainResourceAllocation *pusch_timedomainresourceallocation1 = CALLOC(1,sizeof(struct NR_PUSCH_TimeDomainResourceAllocation)); + pusch_timedomainresourceallocation1->k2 = CALLOC(1,sizeof(long)); + *pusch_timedomainresourceallocation1->k2=6; + pusch_timedomainresourceallocation1->mappingType=NR_PUSCH_TimeDomainResourceAllocation__mappingType_typeB; + pusch_timedomainresourceallocation1->startSymbolAndLength=38; + ASN_SEQUENCE_ADD(&scc->uplinkConfigCommon->initialUplinkBWP->pusch_ConfigCommon->choice.setup->pusch_TimeDomainAllocationList->list,pusch_timedomainresourceallocation1); + *scc->uplinkConfigCommon->initialUplinkBWP->pusch_ConfigCommon->choice.setup->msg3_DeltaPreamble=1; + *scc->uplinkConfigCommon->initialUplinkBWP->pusch_ConfigCommon->choice.setup->p0_NominalWithGrant=-90; + scc->uplinkConfigCommon->initialUplinkBWP->pucch_ConfigCommon->choice.setup->pucch_GroupHopping=NR_PUCCH_ConfigCommon__pucch_GroupHopping_neither; + *scc->uplinkConfigCommon->initialUplinkBWP->pucch_ConfigCommon->choice.setup->hoppingId=40; + *scc->uplinkConfigCommon->initialUplinkBWP->pucch_ConfigCommon->choice.setup->p0_nominal=-90; + scc->ssb_PositionsInBurst->present=NR_ServingCellConfigCommon__ssb_PositionsInBurst_PR_mediumBitmap; + *ssb_bitmap=0xff; + scc->tdd_UL_DL_ConfigurationCommon->referenceSubcarrierSpacing=NR_SubcarrierSpacing_kHz30; + scc->tdd_UL_DL_ConfigurationCommon->pattern1.dl_UL_TransmissionPeriodicity=NR_TDD_UL_DL_Pattern__dl_UL_TransmissionPeriodicity_ms5; + scc->tdd_UL_DL_ConfigurationCommon->pattern1.nrofDownlinkSlots=7; + scc->tdd_UL_DL_ConfigurationCommon->pattern1.nrofDownlinkSymbols=6; + scc->tdd_UL_DL_ConfigurationCommon->pattern1.nrofUplinkSlots=2; + scc->tdd_UL_DL_ConfigurationCommon->pattern1.nrofUplinkSymbols=4; + scc->tdd_UL_DL_ConfigurationCommon->pattern2->dl_UL_TransmissionPeriodicity=321; + + scc->tdd_UL_DL_ConfigurationCommon->pattern2->nrofDownlinkSlots=-1; + scc->tdd_UL_DL_ConfigurationCommon->pattern2->nrofDownlinkSymbols=-1; + scc->tdd_UL_DL_ConfigurationCommon->pattern2->nrofUplinkSlots=-1; + scc->tdd_UL_DL_ConfigurationCommon->pattern2->nrofUplinkSymbols=-1; + scc->ss_PBCH_BlockPower=20; + *scc->uplinkConfigCommon->initialUplinkBWP->rach_ConfigCommon->choice.setup->msg1_SubcarrierSpacing=-1; +} + void fix_scc(NR_ServingCellConfigCommon_t *scc,uint64_t ssbmap) { @@ -273,24 +343,9 @@ void fix_scc(NR_ServingCellConfigCommon_t *scc,uint64_t ssbmap) { if (*scc->uplinkConfigCommon->initialUplinkBWP->rach_ConfigCommon->choice.setup->msg3_transformPrecoder!=0) scc->uplinkConfigCommon->initialUplinkBWP->rach_ConfigCommon->choice.setup->msg3_transformPrecoder = NULL; - // fix DL and UL Allocation lists - - for (int i=scc->downlinkConfigCommon->initialDownlinkBWP->pdsch_ConfigCommon->choice.setup->pdsch_TimeDomainAllocationList->list.count-1;i>=0;i--) { - printf("Checking element %d : %ld\n",i,*scc->downlinkConfigCommon->initialDownlinkBWP->pdsch_ConfigCommon->choice.setup->pdsch_TimeDomainAllocationList->list.array[i]->k0); - if (*scc->downlinkConfigCommon->initialDownlinkBWP->pdsch_ConfigCommon->choice.setup->pdsch_TimeDomainAllocationList->list.array[i]->k0>32) { - printf("removing pdsch_TimeDomainAllocationList element %d\n",i); - free(scc->downlinkConfigCommon->initialDownlinkBWP->pdsch_ConfigCommon->choice.setup->pdsch_TimeDomainAllocationList->list.array[i]->k0); - asn_sequence_del(&scc->downlinkConfigCommon->initialDownlinkBWP->pdsch_ConfigCommon->choice.setup->pdsch_TimeDomainAllocationList->list,i,1); - printf("List size now %d\n",scc->downlinkConfigCommon->initialDownlinkBWP->pdsch_ConfigCommon->choice.setup->pdsch_TimeDomainAllocationList->list.count); - } - } + // prepare DL Allocation lists + nr_rrc_config_dl_tda(scc); - for (int i=scc->uplinkConfigCommon->initialUplinkBWP->pusch_ConfigCommon->choice.setup->pusch_TimeDomainAllocationList->list.count-1;i>=0;i--) { - if (*scc->uplinkConfigCommon->initialUplinkBWP->pusch_ConfigCommon->choice.setup->pusch_TimeDomainAllocationList->list.array[i]->k2>32) { - free(scc->uplinkConfigCommon->initialUplinkBWP->pusch_ConfigCommon->choice.setup->pusch_TimeDomainAllocationList->list.array[i]->k2); - asn_sequence_del(&scc->uplinkConfigCommon->initialUplinkBWP->pusch_ConfigCommon->choice.setup->pusch_TimeDomainAllocationList->list,i,1); - } - } if (scc->tdd_UL_DL_ConfigurationCommon->pattern2->dl_UL_TransmissionPeriodicity > 320 ) { free(scc->tdd_UL_DL_ConfigurationCommon->pattern2); scc->tdd_UL_DL_ConfigurationCommon->pattern2=NULL; @@ -598,7 +653,7 @@ void RCconfig_NR_L1(void) { RC.gNB[j]->Mod_id = j; } - RC.gNB[j]->pusch_proc_threads = *(L1_ParamList.paramarray[j][L1_PUSCH_PROC_THREADS].uptr); + RC.gNB[j]->thread_pool_size = *(L1_ParamList.paramarray[j][L1_THREAD_POOL_SIZE].uptr); 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); @@ -903,9 +958,8 @@ void RCconfig_NRRRC(MessageDef *msg_p, uint32_t i, gNB_RRC_INST *rrc) { paramdef_t GNBParams[] = GNBPARAMS_DESC; paramlist_def_t GNBParamList = {GNB_CONFIG_STRING_GNB_LIST,NULL,0}; - NR_ServingCellConfigCommon_t *scc = calloc(1,sizeof(NR_ServingCellConfigCommon_t)); + NR_ServingCellConfigCommon_t *scc = calloc(1,sizeof(*scc)); uint64_t ssb_bitmap=0xff; - memset((void*)scc,0,sizeof(NR_ServingCellConfigCommon_t)); prepare_scc(scc); paramdef_t SCCsParams[] = SCCPARAMS_DESC(scc); paramlist_def_t SCCsParamList = {GNB_CONFIG_STRING_SERVINGCELLCONFIGCOMMON, NULL, 0}; @@ -1109,11 +1163,13 @@ void RCconfig_NRRRC(MessageDef *msg_p, uint32_t i, gNB_RRC_INST *rrc) { NRRRC_CONFIGURATION_REQ (msg_p).pdsch_AntennaPorts = *GNBParamList.paramarray[i][GNB_PDSCH_ANTENNAPORTS_IDX].iptr; printf("pusch_AntennaPorts %d\n",*GNBParamList.paramarray[i][GNB_PUSCH_ANTENNAPORTS_IDX].iptr); NRRRC_CONFIGURATION_REQ (msg_p).pusch_AntennaPorts = *GNBParamList.paramarray[i][GNB_PUSCH_ANTENNAPORTS_IDX].iptr; - printf("minTXRXTIMEpdsch %d\n",*GNBParamList.paramarray[i][GNB_MINRXTXTIMEPDSCH_IDX].iptr); - NRRRC_CONFIGURATION_REQ (msg_p).minRXTXTIMEpdsch = *GNBParamList.paramarray[i][GNB_MINRXTXTIMEPDSCH_IDX].iptr; + printf("minTXRXTIME %d\n",*GNBParamList.paramarray[i][GNB_MINRXTXTIME_IDX].iptr); + NRRRC_CONFIGURATION_REQ (msg_p).minRXTXTIME = *GNBParamList.paramarray[i][GNB_MINRXTXTIME_IDX].iptr; NRRRC_CONFIGURATION_REQ (msg_p).sib1_tda = *GNBParamList.paramarray[i][GNB_SIB1_TDA_IDX].iptr; printf("Do CSI-RS %d\n",*GNBParamList.paramarray[i][GNB_DO_CSIRS_IDX].iptr); NRRRC_CONFIGURATION_REQ (msg_p).do_CSIRS = *GNBParamList.paramarray[i][GNB_DO_CSIRS_IDX].iptr; + printf("Do SRS %d\n",*GNBParamList.paramarray[i][GNB_DO_SRS_IDX].iptr); + NRRRC_CONFIGURATION_REQ (msg_p).do_SRS = *GNBParamList.paramarray[i][GNB_DO_SRS_IDX].iptr; NRRRC_CONFIGURATION_REQ (msg_p).scc = scc; NRRRC_CONFIGURATION_REQ (msg_p).scd = scd; @@ -1129,23 +1185,14 @@ void RCconfig_NRRRC(MessageDef *msg_p, uint32_t i, gNB_RRC_INST *rrc) { int RCconfig_nr_gtpu(void ) { int num_gnbs = 0; - - - - char* gnb_interface_name_for_NGU = NULL; char* gnb_ipv4_address_for_NGU = NULL; uint32_t gnb_port_for_NGU = 0; - char* gnb_interface_name_for_S1U = NULL; char* gnb_ipv4_address_for_S1U = NULL; uint32_t gnb_port_for_S1U = 0; - char *address = NULL; - char *cidr = NULL; char gtpupath[MAX_OPTNAME_SIZE*2 + 8]; - uint8_t gnb_mode = 0; paramdef_t GNBSParams[] = GNBSPARAMS_DESC; paramdef_t NETParams[] = GNBNETPARAMS_DESC; - paramdef_t GTPUParams[] = GNBGTPUPARAMS_DESC; LOG_I(GTPU,"Configuring GTPu\n"); /* get number of active eNodeBs */ @@ -1155,49 +1202,32 @@ int RCconfig_nr_gtpu(void ) { "Failed to parse config file no active gNodeBs in %s \n", GNB_CONFIG_STRING_ACTIVE_GNBS); sprintf(gtpupath,"%s.[%i].%s",GNB_CONFIG_STRING_GNB_LIST,0,GNB_CONFIG_STRING_NETWORK_INTERFACES_CONFIG); - config_get(GTPUParams,sizeof(GTPUParams)/sizeof(paramdef_t),gtpupath); - config_get(NETParams,sizeof(NETParams)/sizeof(paramdef_t),gtpupath); - - if (NETParams[0].strptr != NULL) { // SA + char *cidr=NULL, *address = NULL; + int port; + if (NETParams[1].strptr != NULL) { LOG_I(GTPU, "SA mode \n"); - cidr = gnb_ipv4_address_for_NGU; - gnb_mode = 0; - } else {// NSA + address = strtok_r(gnb_ipv4_address_for_NGU, "/", &cidr); + port=gnb_port_for_NGU; + } else { LOG_I(GTPU, "NSA mode \n"); - cidr = gnb_ipv4_address_for_S1U; - gnb_mode = 1; + address = strtok_r(gnb_ipv4_address_for_S1U, "/", &cidr); + port=gnb_port_for_S1U; } - address = strtok(cidr, "/"); - - if (address) { - MessageDef *message; - - if (gnb_mode == 1) { // NSA - message = itti_alloc_new_message(TASK_GNB_APP, 0, GTPV1U_ENB_S1_REQ); - AssertFatal(message!=NULL,""); - // IPV4_STR_ADDR_TO_INT_NWBO ( address, RC.gtpv1u_data_g->enb_ip_address_for_S1u_S12_S4_up, "BAD IP ADDRESS FORMAT FOR eNB S1_U !\n" ); - // LOG_I(GTPU,"Configuring GTPu address : %s -> %x\n",address,RC.gtpv1u_data_g->enb_ip_address_for_S1u_S12_S4_up); - IPV4_STR_ADDR_TO_INT_NWBO (address, GTPV1U_ENB_S1_REQ(message).enb_ip_address_for_S1u_S12_S4_up, "BAD IP ADDRESS FORMAT FOR eNB S1_U !\n" ); - LOG_I(GTPU,"Configuring GTPu address : %s -> %x\n",address,GTPV1U_ENB_S1_REQ(message).enb_ip_address_for_S1u_S12_S4_up); - GTPV1U_ENB_S1_REQ(message).enb_port_for_S1u_S12_S4_up = gnb_port_for_S1U; - strcpy(GTPV1U_ENB_S1_REQ(message).addrStr,address); - sprintf(GTPV1U_ENB_S1_REQ(message).portStr,"%d", gnb_port_for_NGU); - } else {// TODO SA - message = itti_alloc_new_message(TASK_GNB_APP, 0, GTPV1U_GNB_NG_REQ); - AssertFatal(message!=NULL,""); - IPV4_STR_ADDR_TO_INT_NWBO (address, GTPV1U_GNB_NG_REQ(message).gnb_ip_address_for_NGu_up, "BAD IP ADDRESS FORMAT FOR gNB NG_U !\n" ); - LOG_I(GTPU,"Configuring GTPu address : %s -> %x\n",address,GTPV1U_GNB_NG_REQ(message).gnb_ip_address_for_NGu_up); - GTPV1U_GNB_NG_REQ(message).gnb_port_for_NGu_up = gnb_port_for_NGU; - strcpy(GTPV1U_GNB_NG_REQ(message).addrStr,address); - sprintf(GTPV1U_GNB_NG_REQ(message).portStr,"%d", gnb_port_for_NGU); - } - itti_send_msg_to_task (TASK_VARIABLE, 0, message); // data model is wrong: gtpu doesn't have enb_id (or module_id) - } else - LOG_E(GTPU,"invalid address for NGU\n"); - - + if (address) { + MessageDef *message; + message = itti_alloc_new_message(TASK_GNB_APP, 0, GTPV1U_REQ); + AssertFatal(message!=NULL,""); + IPV4_STR_ADDR_TO_INT_NWBO (address, GTPV1U_REQ(message).localAddr, "BAD IP ADDRESS FORMAT FOR gNB NG_U !\n" ); + LOG_I(GTPU,"Configuring GTPu address : %s -> %x\n",address,GTPV1U_REQ(message).localAddr); + GTPV1U_REQ(message).localPort = port; + strcpy(GTPV1U_REQ(message).localAddrStr,address); + sprintf(GTPV1U_REQ(message).localPortStr,"%d", port); + itti_send_msg_to_task (TASK_VARIABLE, 0, message); // data model is wrong: gtpu doesn't have enb_id (or module_id) + } else + LOG_E(GTPU,"invalid address for NGU or S1U\n"); + return 0; } @@ -1215,6 +1245,10 @@ int RCconfig_NR_NG(MessageDef *msg_p, uint32_t i) { (void) my_int; memset((char*)active_gnb,0,MAX_GNB* sizeof(char*)); + char* gnb_ipv4_address_for_NGU = NULL; + uint32_t gnb_port_for_NGU = 0; + char* gnb_ipv4_address_for_S1U = NULL; + uint32_t gnb_port_for_S1U = 0; paramdef_t GNBSParams[] = GNBSPARAMS_DESC; paramdef_t GNBParams[] = GNBPARAMS_DESC; @@ -1480,7 +1514,7 @@ void NRRCConfig(void) { config_get( GNBSParams,sizeof(GNBSParams)/sizeof(paramdef_t),NULL); RC.nb_nr_inst = GNBSParams[GNB_ACTIVE_GNBS_IDX].numelt; - // Get num MACRLC instances + // Get num MACRLC instances config_getlist( &MACRLCParamList,NULL,0, NULL); RC.nb_nr_macrlc_inst = MACRLCParamList.numelt; // Get num L1 instances @@ -1556,6 +1590,11 @@ int RCconfig_NR_X2(MessageDef *msg_p, uint32_t i) { paramdef_t X2Params[] = X2PARAMS_DESC; paramlist_def_t X2ParamList = {ENB_CONFIG_STRING_TARGET_ENB_X2_IP_ADDRESS,NULL,0}; paramdef_t SCTPParams[] = GNBSCTPPARAMS_DESC; + char* gnb_ipv4_address_for_NGU = NULL; + uint32_t gnb_port_for_NGU = 0; + char* gnb_ipv4_address_for_S1U = NULL; + uint32_t gnb_port_for_S1U = 0; + paramdef_t NETParams[] = GNBNETPARAMS_DESC; /* TODO: fix the size - if set lower we have a crash (MAX_OPTNAME_SIZE was 64 when this code was written) */ /* this is most probably a problem with the config module */ @@ -1716,7 +1755,9 @@ int RCconfig_NR_DU_F1(MessageDef *msg_p, uint32_t i) { config_getlist( &GNBParamList,GNBParams,sizeof(GNBParams)/sizeof(paramdef_t),NULL); AssertFatal(GNBParamList.paramarray[i][GNB_GNB_ID_IDX].uptr != NULL, "gNB id %u is not defined in configuration file\n",i); - F1AP_SETUP_REQ (msg_p).num_cells_available = 0; + f1ap_setup_req_t * f1Setup=&F1AP_SETUP_REQ(msg_p); + f1Setup->num_cells_available = 0; + f1Setup->cell_type=CELL_MACRO_GNB; for (k=0; k <num_gnbs ; k++) { if (strcmp(GNBSParams[GNB_ACTIVE_GNBS_IDX].strlistptr[k], *(GNBParamList.paramarray[i][GNB_GNB_NAME_IDX].strptr)) == 0) { @@ -1732,42 +1773,46 @@ int RCconfig_NR_DU_F1(MessageDef *msg_p, uint32_t i) { config_getlist(&PLMNParamList, PLMNParams, sizeof(PLMNParams)/sizeof(paramdef_t), aprefix); paramdef_t SCTPParams[] = SCTPPARAMS_DESC; - F1AP_SETUP_REQ (msg_p).num_cells_available++; - F1AP_SETUP_REQ (msg_p).gNB_DU_id = *(GNBParamList.paramarray[0][GNB_GNB_ID_IDX].uptr); - LOG_I(GNB_APP,"F1AP: gNB_DU_id[%d] %ld\n",k,F1AP_SETUP_REQ (msg_p).gNB_DU_id); - F1AP_SETUP_REQ (msg_p).gNB_DU_name = strdup(*(GNBParamList.paramarray[0][GNB_GNB_NAME_IDX].strptr)); - LOG_I(GNB_APP,"F1AP: gNB_DU_name[%d] %s\n",k,F1AP_SETUP_REQ (msg_p).gNB_DU_name); - F1AP_SETUP_REQ (msg_p).tac[k] = *GNBParamList.paramarray[i][GNB_TRACKING_AREA_CODE_IDX].uptr; - LOG_I(GNB_APP,"F1AP: tac[%d] %d\n",k,F1AP_SETUP_REQ (msg_p).tac[k]); - F1AP_SETUP_REQ (msg_p).mcc[k] = *PLMNParamList.paramarray[0][GNB_MOBILE_COUNTRY_CODE_IDX].uptr; - LOG_I(GNB_APP,"F1AP: mcc[%d] %d\n",k,F1AP_SETUP_REQ (msg_p).mcc[k]); - F1AP_SETUP_REQ (msg_p).mnc[k] = *PLMNParamList.paramarray[0][GNB_MOBILE_NETWORK_CODE_IDX].uptr; - LOG_I(GNB_APP,"F1AP: mnc[%d] %d\n",k,F1AP_SETUP_REQ (msg_p).mnc[k]); - F1AP_SETUP_REQ (msg_p).mnc_digit_length[k] = *PLMNParamList.paramarray[0][GNB_MNC_DIGIT_LENGTH].u8ptr; - LOG_I(GNB_APP,"F1AP: mnc_digit_length[%d] %d\n",k,F1AP_SETUP_REQ (msg_p).mnc_digit_length[k]); - AssertFatal((F1AP_SETUP_REQ (msg_p).mnc_digit_length[k] == 2) || - (F1AP_SETUP_REQ (msg_p).mnc_digit_length[k] == 3), + f1Setup->num_cells_available++; + f1Setup->gNB_DU_id = *(GNBParamList.paramarray[0][GNB_GNB_ID_IDX].uptr); + LOG_I(GNB_APP,"F1AP: gNB_DU_id[%d] %ld\n",k,f1Setup->gNB_DU_id); + f1Setup->gNB_DU_name = strdup(*(GNBParamList.paramarray[0][GNB_GNB_NAME_IDX].strptr)); + LOG_I(GNB_APP,"F1AP: gNB_DU_name[%d] %s\n",k,f1Setup->gNB_DU_name); + f1Setup->cell[k].tac = *GNBParamList.paramarray[i][GNB_TRACKING_AREA_CODE_IDX].uptr; + LOG_I(GNB_APP,"F1AP: tac[%d] %d\n",k,f1Setup->cell[k].tac); + f1Setup->cell[k].mcc = *PLMNParamList.paramarray[0][GNB_MOBILE_COUNTRY_CODE_IDX].uptr; + LOG_I(GNB_APP,"F1AP: mcc[%d] %d\n",k,f1Setup->cell[k].mcc); + f1Setup->cell[k].mnc = *PLMNParamList.paramarray[0][GNB_MOBILE_NETWORK_CODE_IDX].uptr; + LOG_I(GNB_APP,"F1AP: mnc[%d] %d\n",k,f1Setup->cell[k].mnc); + f1Setup->cell[k].mnc_digit_length = *PLMNParamList.paramarray[0][GNB_MNC_DIGIT_LENGTH].u8ptr; + LOG_I(GNB_APP,"F1AP: mnc_digit_length[%d] %d\n",k,f1Setup->cell[k].mnc_digit_length); + AssertFatal((f1Setup->cell[k].mnc_digit_length == 2) || + (f1Setup->cell[k].mnc_digit_length == 3), "BAD MNC DIGIT LENGTH %d", - F1AP_SETUP_REQ (msg_p).mnc_digit_length[k]); - F1AP_SETUP_REQ (msg_p).nr_cellid[k] = (uint64_t)*(GNBParamList.paramarray[i][GNB_NRCELLID_IDX].u64ptr); - LOG_I(GNB_APP,"F1AP: nr_cellid[%d] %ld\n",k,F1AP_SETUP_REQ (msg_p).nr_cellid[k]); + f1Setup->cell[k].mnc_digit_length); + f1Setup->cell[k].nr_cellid = (uint64_t)*(GNBParamList.paramarray[i][GNB_NRCELLID_IDX].u64ptr); + LOG_I(GNB_APP,"F1AP: nr_cellid[%d] %ld\n",k,f1Setup->cell[k].nr_cellid); LOG_I(GNB_APP,"F1AP: CU_ip4_address in DU %s\n",RC.nrmac[k]->eth_params_n.remote_addr); - LOG_I(GNB_APP,"FIAP: CU_ip4_address in DU %p, strlen %d\n",F1AP_SETUP_REQ (msg_p).CU_f1_ip_address.ipv4_address,(int)strlen(RC.nrmac[k]->eth_params_n.remote_addr)); - F1AP_SETUP_REQ (msg_p).CU_f1_ip_address.ipv6 = 0; - F1AP_SETUP_REQ (msg_p).CU_f1_ip_address.ipv4 = 1; - //strcpy(F1AP_SETUP_REQ (msg_p).CU_f1_ip_address.ipv6_address, ""); - strcpy(F1AP_SETUP_REQ (msg_p).CU_f1_ip_address.ipv4_address, RC.nrmac[k]->eth_params_n.remote_addr); + LOG_I(GNB_APP,"FIAP: CU_ip4_address in DU %p, strlen %d\n",f1Setup->CU_f1_ip_address.ipv4_address,(int)strlen(RC.nrmac[k]->eth_params_n.remote_addr)); + f1Setup->CU_f1_ip_address.ipv6 = 0; + f1Setup->CU_f1_ip_address.ipv4 = 1; + //strcpy(f1Setup->CU_f1_ip_address.ipv6_address, ""); + strcpy(f1Setup->CU_f1_ip_address.ipv4_address, RC.nrmac[k]->eth_params_n.remote_addr); LOG_I(GNB_APP,"F1AP: DU_ip4_address in DU %s\n",RC.nrmac[k]->eth_params_n.my_addr); - LOG_I(GNB_APP,"FIAP: DU_ip4_address in DU %p, strlen %d\n",F1AP_SETUP_REQ (msg_p).DU_f1_ip_address.ipv4_address,(int)strlen(RC.nrmac[k]->eth_params_n.my_addr)); - F1AP_SETUP_REQ (msg_p).DU_f1_ip_address.ipv6 = 0; - F1AP_SETUP_REQ (msg_p).DU_f1_ip_address.ipv4 = 1; - //strcpy(F1AP_SETUP_REQ (msg_p).DU_f1_ip_address.ipv6_address, ""); - strcpy(F1AP_SETUP_REQ (msg_p).DU_f1_ip_address.ipv4_address, RC.nrmac[k]->eth_params_n.my_addr); - //strcpy(F1AP_SETUP_REQ (msg_p).CU_ip_address[l].ipv6_address,*(F1ParamList.paramarray[l][ENB_CU_IPV6_ADDRESS_IDX].strptr)); + LOG_I(GNB_APP,"FIAP: DU_ip4_address in DU %p, strlen %ld\n", + f1Setup->DU_f1_ip_address.ipv4_address, + strlen(RC.nrmac[k]->eth_params_n.my_addr)); + f1Setup->DU_f1_ip_address.ipv6 = 0; + f1Setup->DU_f1_ip_address.ipv4 = 1; + //strcpy(f1Setup->DU_f1_ip_address.ipv6_address, ""); + strcpy(f1Setup->DU_f1_ip_address.ipv4_address, RC.nrmac[k]->eth_params_n.my_addr); + f1Setup->DUport= RC.nrmac[k]->eth_params_n.my_portd; + f1Setup->CUport= RC.nrmac[k]->eth_params_n.remote_portd; + //strcpy(f1Setup->CU_ip_address[l].ipv6_address,*(F1ParamList.paramarray[l][ENB_CU_IPV6_ADDRESS_IDX].strptr)); sprintf(aprefix,"%s.[%i].%s",GNB_CONFIG_STRING_GNB_LIST,k,GNB_CONFIG_STRING_SCTP_CONFIG); config_get(SCTPParams,sizeof(SCTPParams)/sizeof(paramdef_t),aprefix); - F1AP_SETUP_REQ (msg_p).sctp_in_streams = (uint16_t)*(SCTPParams[GNB_SCTP_INSTREAMS_IDX].uptr); - F1AP_SETUP_REQ (msg_p).sctp_out_streams = (uint16_t)*(SCTPParams[GNB_SCTP_OUTSTREAMS_IDX].uptr); + f1Setup->sctp_in_streams = (uint16_t)*(SCTPParams[GNB_SCTP_INSTREAMS_IDX].uptr); + f1Setup->sctp_out_streams = (uint16_t)*(SCTPParams[GNB_SCTP_OUTSTREAMS_IDX].uptr); gNB_RRC_INST *rrc = RC.nrrrc[k]; // wait until RRC cell information is configured int cell_info_configured = 0; @@ -1780,53 +1825,53 @@ int RCconfig_NR_DU_F1(MessageDef *msg_p, uint32_t i) { pthread_mutex_unlock(&rrc->cell_info_mutex); } while (cell_info_configured == 0); - rrc->configuration.mcc[0] = F1AP_SETUP_REQ (msg_p).mcc[k]; - rrc->configuration.mnc[0] = F1AP_SETUP_REQ (msg_p).mnc[k]; - rrc->configuration.tac = F1AP_SETUP_REQ (msg_p).tac[k]; - rrc->nr_cellid = F1AP_SETUP_REQ (msg_p).nr_cellid[k]; - F1AP_SETUP_REQ (msg_p).nr_pci[k] = *rrc->configuration.scc->physCellId; - F1AP_SETUP_REQ (msg_p).num_ssi[k] = 0; + rrc->configuration.mcc[0] = f1Setup->cell[k].mcc; + rrc->configuration.mnc[0] = f1Setup->cell[k].mnc; + rrc->configuration.tac = f1Setup->cell[k].tac; + rrc->nr_cellid = f1Setup->cell[k].nr_cellid; + f1Setup->cell[k].nr_pci = *rrc->configuration.scc->physCellId; + f1Setup->cell[k].num_ssi = 0; if (rrc->configuration.scc->tdd_UL_DL_ConfigurationCommon) { LOG_I(GNB_APP,"ngran_DU: Configuring Cell %d for TDD\n",k); - F1AP_SETUP_REQ (msg_p).fdd_flag = 0; - F1AP_SETUP_REQ (msg_p).nr_mode_info[k].tdd.nr_arfcn = rrc->configuration.scc->downlinkConfigCommon->frequencyInfoDL->absoluteFrequencyPointA; - F1AP_SETUP_REQ (msg_p).nr_mode_info[k].tdd.scs = rrc->configuration.scc->downlinkConfigCommon->frequencyInfoDL->scs_SpecificCarrierList.list.array[0]->subcarrierSpacing; - F1AP_SETUP_REQ (msg_p).nr_mode_info[k].tdd.nrb = rrc->configuration.scc->downlinkConfigCommon->frequencyInfoDL->scs_SpecificCarrierList.list.array[0]->carrierBandwidth; - F1AP_SETUP_REQ (msg_p).nr_mode_info[k].tdd.num_frequency_bands = 1; - F1AP_SETUP_REQ (msg_p).nr_mode_info[k].tdd.nr_band[0] = *rrc->configuration.scc->downlinkConfigCommon->frequencyInfoDL->frequencyBandList.list.array[0]; - F1AP_SETUP_REQ (msg_p).nr_mode_info[k].tdd.sul_active = 0; + f1Setup->fdd_flag = 0; + f1Setup->nr_mode_info[k].tdd.nr_arfcn = rrc->configuration.scc->downlinkConfigCommon->frequencyInfoDL->absoluteFrequencyPointA; + f1Setup->nr_mode_info[k].tdd.scs = rrc->configuration.scc->downlinkConfigCommon->frequencyInfoDL->scs_SpecificCarrierList.list.array[0]->subcarrierSpacing; + f1Setup->nr_mode_info[k].tdd.nrb = rrc->configuration.scc->downlinkConfigCommon->frequencyInfoDL->scs_SpecificCarrierList.list.array[0]->carrierBandwidth; + f1Setup->nr_mode_info[k].tdd.num_frequency_bands = 1; + f1Setup->nr_mode_info[k].tdd.nr_band[0] = *rrc->configuration.scc->downlinkConfigCommon->frequencyInfoDL->frequencyBandList.list.array[0]; + f1Setup->nr_mode_info[k].tdd.sul_active = 0; } else { /***************** for test *****************/ LOG_I(GNB_APP,"ngran_DU: Configuring Cell %d for FDD\n",k); - F1AP_SETUP_REQ (msg_p).fdd_flag = 1; - F1AP_SETUP_REQ (msg_p).nr_mode_info[k].fdd.dl_nr_arfcn = 26200UL; - F1AP_SETUP_REQ (msg_p).nr_mode_info[k].fdd.ul_nr_arfcn = 26200UL; + f1Setup->fdd_flag = 1; + f1Setup->nr_mode_info[k].fdd.dl_nr_arfcn = 26200UL; + f1Setup->nr_mode_info[k].fdd.ul_nr_arfcn = 26200UL; // For LTE use scs field to carry prefix type and number of antennas - F1AP_SETUP_REQ (msg_p).nr_mode_info[k].fdd.dl_scs = 0; - F1AP_SETUP_REQ (msg_p).nr_mode_info[k].fdd.ul_scs = 0; + f1Setup->nr_mode_info[k].fdd.dl_scs = 0; + f1Setup->nr_mode_info[k].fdd.ul_scs = 0; // use nrb field to hold LTE N_RB_DL (0...5) - F1AP_SETUP_REQ (msg_p).nr_mode_info[k].fdd.ul_nrb = 3; - F1AP_SETUP_REQ (msg_p).nr_mode_info[k].fdd.ul_nrb = 3; + f1Setup->nr_mode_info[k].fdd.ul_nrb = 3; + f1Setup->nr_mode_info[k].fdd.ul_nrb = 3; // RK: we need to check there value for FDD's frequency_bands DL/UL - F1AP_SETUP_REQ (msg_p).nr_mode_info[k].fdd.ul_num_frequency_bands = 1; - F1AP_SETUP_REQ (msg_p).nr_mode_info[k].fdd.ul_nr_band[0] = 7; - F1AP_SETUP_REQ (msg_p).nr_mode_info[k].fdd.dl_num_frequency_bands = 1; - F1AP_SETUP_REQ (msg_p).nr_mode_info[k].fdd.dl_nr_band[0] = 7; - F1AP_SETUP_REQ (msg_p).nr_mode_info[k].fdd.ul_num_sul_frequency_bands = 0; - F1AP_SETUP_REQ (msg_p).nr_mode_info[k].fdd.ul_nr_sul_band[0] = 7; - F1AP_SETUP_REQ (msg_p).nr_mode_info[k].fdd.dl_num_sul_frequency_bands = 0; - F1AP_SETUP_REQ (msg_p).nr_mode_info[k].fdd.dl_nr_sul_band[0] = 7; - F1AP_SETUP_REQ (msg_p).nr_mode_info[k].fdd.sul_active = 0; + f1Setup->nr_mode_info[k].fdd.ul_num_frequency_bands = 1; + f1Setup->nr_mode_info[k].fdd.ul_nr_band[0] = 7; + f1Setup->nr_mode_info[k].fdd.dl_num_frequency_bands = 1; + f1Setup->nr_mode_info[k].fdd.dl_nr_band[0] = 7; + f1Setup->nr_mode_info[k].fdd.ul_num_sul_frequency_bands = 0; + f1Setup->nr_mode_info[k].fdd.ul_nr_sul_band[0] = 7; + f1Setup->nr_mode_info[k].fdd.dl_num_sul_frequency_bands = 0; + f1Setup->nr_mode_info[k].fdd.dl_nr_sul_band[0] = 7; + f1Setup->nr_mode_info[k].fdd.sul_active = 0; /***************** for test *****************/ } - F1AP_SETUP_REQ (msg_p).measurement_timing_information[k] = "0"; - F1AP_SETUP_REQ (msg_p).ranac[k] = 0; - F1AP_SETUP_REQ (msg_p).mib[k] = rrc->carrier.MIB; - F1AP_SETUP_REQ (msg_p).sib1[k] = rrc->carrier.SIB1; - F1AP_SETUP_REQ (msg_p).mib_length[k] = rrc->carrier.sizeof_MIB; - F1AP_SETUP_REQ (msg_p).sib1_length[k] = rrc->carrier.sizeof_SIB1; + f1Setup->measurement_timing_information[k] = "0"; + f1Setup->ranac[k] = 0; + f1Setup->mib[k] = rrc->carrier.MIB; + f1Setup->sib1[k] = rrc->carrier.SIB1; + f1Setup->mib_length[k] = rrc->carrier.sizeof_MIB; + f1Setup->sib1_length[k] = rrc->carrier.sizeof_SIB1; break; } } @@ -2022,8 +2067,8 @@ int gNB_app_handle_f1ap_setup_resp(f1ap_setup_resp_t *resp) { du_extract_and_decode_SI(i, si_ind, - resp->cells_to_activate[j].SI_container[2+si_ind], - resp->cells_to_activate[j].SI_container_length[2+si_ind]); + resp->cells_to_activate[j].SI_container[si_ind], + resp->cells_to_activate[j].SI_container_length[si_ind]); } // perform MAC/L1 common configuration @@ -2057,8 +2102,8 @@ int gNB_app_handle_f1ap_gnb_cu_configuration_update(f1ap_gnb_cu_configuration_up du_extract_and_decode_SI(i, si_ind, - gnb_cu_cfg_update->cells_to_activate[j].SI_container[2+si_ind], - gnb_cu_cfg_update->cells_to_activate[j].SI_container_length[2+si_ind]); + gnb_cu_cfg_update->cells_to_activate[j].SI_container[si_ind], + gnb_cu_cfg_update->cells_to_activate[j].SI_container_length[si_ind]); } // perform MAC/L1 common configuration diff --git a/openair2/GNB_APP/gnb_paramdef.h b/openair2/GNB_APP/gnb_paramdef.h index 94e9735a31fb2f23a2ea1464ba73291de0aa634d..5439c44fa8ebb08d8314657b61e397592002a051 100644 --- a/openair2/GNB_APP/gnb_paramdef.h +++ b/openair2/GNB_APP/gnb_paramdef.h @@ -118,8 +118,9 @@ typedef enum { #define GNB_CONFIG_STRING_PUSCHANTENNAPORTS "pusch_AntennaPorts" #define GNB_CONFIG_STRING_SIB1TDA "sib1_tda" #define GNB_CONFIG_STRING_DOCSIRS "do_CSIRS" +#define GNB_CONFIG_STRING_DOSRS "do_SRS" #define GNB_CONFIG_STRING_NRCELLID "nr_cellid" -#define GNB_CONFIG_STRING_MINRXTXTIMEPDSCH "min_rxtxtime_pdsch" +#define GNB_CONFIG_STRING_MINRXTXTIME "min_rxtxtime" #define GNB_CONFIG_STRING_ULPRBBLACKLIST "ul_prbblacklist" #define GNB_CONFIG_STRING_UMONDEFAULTDRB "um_on_default_drb" @@ -147,9 +148,10 @@ typedef enum { {GNB_CONFIG_STRING_PUSCHANTENNAPORTS, NULL, 0, iptr:NULL, defintval:1, TYPE_INT, 0}, \ {GNB_CONFIG_STRING_SIB1TDA, NULL, 0, iptr:NULL, defintval:0, TYPE_INT, 0}, \ {GNB_CONFIG_STRING_DOCSIRS, NULL, 0, iptr:NULL, defintval:0, TYPE_INT, 0}, \ +{GNB_CONFIG_STRING_DOSRS, NULL, 0, iptr:NULL, defintval:0, TYPE_INT, 0}, \ {GNB_CONFIG_STRING_NRCELLID, NULL, 0, u64ptr:NULL, defint64val:1, TYPE_UINT64, 0}, \ -{GNB_CONFIG_STRING_MINRXTXTIMEPDSCH, NULL, 0, iptr:NULL, defintval:2, TYPE_INT, 0}, \ -{GNB_CONFIG_STRING_ULPRBBLACKLIST, NULL, 0, strptr:NULL, defstrval:"", TYPE_STRING, 0}, \ +{GNB_CONFIG_STRING_MINRXTXTIME, NULL, 0, iptr:NULL, defintval:2, TYPE_INT, 0}, \ +{GNB_CONFIG_STRING_ULPRBBLACKLIST, NULL, 0, strptr:NULL, defstrval:"", TYPE_STRING, 0} \ {GNB_CONFIG_STRING_UMONDEFAULTDRB, NULL, 0, uptr:NULL, defuintval:0, TYPE_UINT, 0} \ } @@ -172,10 +174,11 @@ typedef enum { #define GNB_PUSCH_ANTENNAPORTS_IDX 16 #define GNB_SIB1_TDA_IDX 17 #define GNB_DO_CSIRS_IDX 18 -#define GNB_NRCELLID_IDX 19 -#define GNB_MINRXTXTIMEPDSCH_IDX 20 -#define GNB_ULPRBBLACKLIST_IDX 21 -#define GNB_UMONDEFAULTDRB_IDX 22 +#define GNB_DO_SRS_IDX 19 +#define GNB_NRCELLID_IDX 20 +#define GNB_MINRXTXTIME_IDX 21 +#define GNB_ULPRBBLACKLIST_IDX 22 +#define GNB_UMONDEFAULTDRB_IDX 23 #define TRACKING_AREA_CODE_OKRANGE {0x0001,0xFFFD} #define GNBPARAMS_CHECK { \ @@ -336,29 +339,17 @@ typedef enum { /* optname helpstr paramflags XXXptr defXXXval type numelt */ /*--------------------------------------------------------------------------------------------------------------------------------------------------*/ #define GNBNETPARAMS_DESC { \ -{GNB_CONFIG_STRING_GNB_INTERFACE_NAME_FOR_NG_AMF, NULL, 0, strptr:NULL, defstrval:NULL, TYPE_STRING, 0}, \ -{GNB_CONFIG_STRING_GNB_IPV4_ADDRESS_FOR_NG_AMF, NULL, 0, strptr:NULL, defstrval:NULL, TYPE_STRING, 0}, \ -{GNB_CONFIG_STRING_GNB_INTERFACE_NAME_FOR_NGU, NULL, 0, strptr:NULL, defstrval:NULL, TYPE_STRING, 0}, \ -{GNB_CONFIG_STRING_GNB_IPV4_ADDR_FOR_NGU, NULL, 0, strptr:NULL, defstrval:NULL, TYPE_STRING, 0}, \ -{GNB_CONFIG_STRING_GNB_PORT_FOR_NGU, NULL, 0, uptr:NULL, defintval:2152L, TYPE_UINT, 0}, \ -{GNB_CONFIG_STRING_ENB_IPV4_ADDR_FOR_X2C, NULL, 0, strptr:NULL, defstrval:NULL, TYPE_STRING, 0}, \ -{GNB_CONFIG_STRING_ENB_PORT_FOR_X2C, NULL, 0, uptr:NULL, defintval:0L, TYPE_UINT, 0} \ -} - - - -/*--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------*/ -/* GTPU configuration parameters */ -/* optname helpstr paramflags XXXptr defXXXval type numelt */ -/*--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------*/ -#define GNBGTPUPARAMS_DESC { \ -{GNB_CONFIG_STRING_GNB_INTERFACE_NAME_FOR_NGU, NULL, 0, strptr:&gnb_interface_name_for_NGU, defstrval:"lo", TYPE_STRING, 0}, \ -{GNB_CONFIG_STRING_GNB_IPV4_ADDR_FOR_NGU, NULL, 0, strptr:&gnb_ipv4_address_for_NGU, defstrval:"127.0.0.1", TYPE_STRING, 0}, \ -{GNB_CONFIG_STRING_GNB_PORT_FOR_NGU, NULL, 0, uptr:&gnb_port_for_NGU, defintval:2152, TYPE_UINT, 0}, \ -{GNB_CONFIG_STRING_GNB_INTERFACE_NAME_FOR_S1U, NULL, 0, strptr:&gnb_interface_name_for_S1U, defstrval:"lo", TYPE_STRING, 0}, \ -{GNB_CONFIG_STRING_GNB_IPV4_ADDRESS_FOR_S1U, NULL, 0, strptr:&gnb_ipv4_address_for_S1U, defstrval:"127.0.0.1", TYPE_STRING, 0}, \ -{GNB_CONFIG_STRING_GNB_PORT_FOR_S1U, NULL, 0, uptr:&gnb_port_for_S1U, defintval:2152, TYPE_UINT, 0} \ -} + {GNB_CONFIG_STRING_GNB_INTERFACE_NAME_FOR_NG_AMF, NULL, 0, strptr:NULL, defstrval:NULL, TYPE_STRING, 0}, \ + {GNB_CONFIG_STRING_GNB_IPV4_ADDRESS_FOR_NG_AMF, NULL, 0, strptr:NULL, defstrval:NULL, TYPE_STRING, 0}, \ + {GNB_CONFIG_STRING_GNB_INTERFACE_NAME_FOR_NGU, NULL, 0, strptr:NULL, defstrval:NULL, TYPE_STRING, 0}, \ + {GNB_CONFIG_STRING_GNB_IPV4_ADDR_FOR_NGU, NULL, 0, strptr:&gnb_ipv4_address_for_NGU, defstrval:"127.0.0.1",TYPE_STRING, 0}, \ + {GNB_CONFIG_STRING_GNB_PORT_FOR_NGU, NULL, 0, uptr:&gnb_port_for_NGU, defintval:2152L, TYPE_UINT, 0}, \ + {GNB_CONFIG_STRING_ENB_IPV4_ADDR_FOR_X2C, NULL, 0, strptr:NULL, defstrval:NULL, TYPE_STRING, 0}, \ + {GNB_CONFIG_STRING_ENB_PORT_FOR_X2C, NULL, 0, uptr:NULL, defintval:0L, TYPE_UINT, 0}, \ + {GNB_CONFIG_STRING_GNB_INTERFACE_NAME_FOR_S1U, NULL, 0, strptr:NULL, defstrval:NULL, TYPE_STRING, 0}, \ + {GNB_CONFIG_STRING_GNB_IPV4_ADDRESS_FOR_S1U, NULL, 0, strptr:&gnb_ipv4_address_for_S1U, defstrval:"127.0.0.1",TYPE_STRING, 0}, \ + {GNB_CONFIG_STRING_GNB_PORT_FOR_S1U, NULL, 0, uptr:&gnb_port_for_S1U, defintval:2152L, TYPE_UINT, 0} \ + } /*-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------*/ /*-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------*/ diff --git a/openair2/LAYER2/MAC/config.c b/openair2/LAYER2/MAC/config.c index 8d4a53da6c21cad4d1e0d49ad7b2f91addde0a5f..209275acb38c69c6351fce0f87ed7fda56589662 100644 --- a/openair2/LAYER2/MAC/config.c +++ b/openair2/LAYER2/MAC/config.c @@ -799,7 +799,7 @@ int rrc_mac_config_req_eNB(module_id_t Mod_idP, RC.mac[Mod_idP]->common_channels[CC_idP].Ncp = Ncp; RC.mac[Mod_idP]->common_channels[CC_idP].eutra_band = eutra_band; RC.mac[Mod_idP]->common_channels[CC_idP].dl_CarrierFreq = dl_CarrierFreq; - LOG_I(MAC, + LOG_A(MAC, "Configuring MIB for instance %d, CCid %d : (band %d,N_RB_DL %d,Nid_cell %d,p %d,DL freq %u,phich_config.resource %d, phich_config.duration %d)\n", Mod_idP, CC_idP, @@ -1067,7 +1067,7 @@ int rrc_mac_config_req_eNB(module_id_t Mod_idP, while(RC.mac[Mod_idP]->if_inst->PHY_config_req == NULL) { // DJP AssertFatal(RC.mac[Mod_idP]->if_inst->PHY_config_req != NULL,"if_inst->phy_config_request is null\n"); usleep(100 * 1000); - printf("Waiting for PHY_config_req\n"); + LOG_I(MAC, "Waiting for PHY_config_req\n"); } } diff --git a/openair2/LAYER2/MAC/config_ue.c b/openair2/LAYER2/MAC/config_ue.c index f5c12e710d35103c2056206dfe28247e9d329c68..3cfc725fdb3f4d6e249740deccff972d0908bad9 100644 --- a/openair2/LAYER2/MAC/config_ue.c +++ b/openair2/LAYER2/MAC/config_ue.c @@ -200,7 +200,7 @@ rrc_mac_config_req_ue(module_id_t Mod_idP, LTE_MAC_MainConfig__ul_SCH_Config__maxHARQ_Tx_n5; } - if(NFAPI_MODE != NFAPI_UE_STUB_PNF) + if(NFAPI_MODE!=NFAPI_UE_STUB_PNF && NFAPI_MODE!=NFAPI_MODE_STANDALONE_PNF) phy_config_harq_ue(Mod_idP, 0, eNB_index, UE_mac_inst[Mod_idP].scheduling_info.maxHARQ_Tx); if (mac_MainConfig->ul_SCH_Config->retxBSR_Timer) { @@ -308,7 +308,7 @@ rrc_mac_config_req_ue(module_id_t Mod_idP, } if (physicalConfigDedicated != NULL) { - if(NFAPI_MODE != NFAPI_UE_STUB_PNF) + if(NFAPI_MODE != NFAPI_UE_STUB_PNF && NFAPI_MODE != NFAPI_MODE_STANDALONE_PNF) phy_config_dedicated_ue(Mod_idP, 0, eNB_index, physicalConfigDedicated); diff --git a/openair2/LAYER2/MAC/eNB_scheduler.c b/openair2/LAYER2/MAC/eNB_scheduler.c index 9d07018e2feddeea160bd9af1b94e6f20122e7e4..d647eff7cbe7800c5fe49d24cca69885a9c7314a 100644 --- a/openair2/LAYER2/MAC/eNB_scheduler.c +++ b/openair2/LAYER2/MAC/eNB_scheduler.c @@ -313,6 +313,7 @@ schedule_SR (module_id_t module_idP, nfapi_ul_config_request_body_t *ul_req_body = NULL; LTE_SchedulingRequestConfig_t *SRconfig = NULL; nfapi_ul_config_sr_information sr; + memset(&sr, 0, sizeof(sr)); for (int CC_id = 0; CC_id < MAX_NUM_CCs; CC_id++) { eNB->UL_req[CC_id].sfn_sf = (frameP << 4) + subframeP; @@ -573,6 +574,27 @@ eNB_dlsch_ulsch_scheduler(module_id_t module_idP, UE_sched_ctrl_t *UE_scheduling_control = NULL; start_meas(&(eNB->eNB_scheduler)); VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_ENB_DLSCH_ULSCH_SCHEDULER, VCD_FUNCTION_IN); + // TODO: Better solution needed this is the first + // 3 indications of this function on startup + // 1303275.278188 [MAC] XXX 0.0 -> 0.4 = 4 + // 1303275.279443 [MAC] XXX 0.4 -> 639.5 = 6391 + // 1303275.348686 [MAC] XXX 646.3 -> 646.3 = 0 + int delta = (frameP * 10 + subframeP) - (eNB->frame * 10 + eNB->subframe); + if (delta < 0) + { + delta += 10240; // sfn_sf decimal values range from 0 to 10239 + } + // If we ever see a difference this big something is very wrong + // This threshold is arbitrary + if (delta > 8500 || delta == 0) // 850 frames + { + LOG_I(MAC, "scheduler ignoring outerspace %d.%d -> %d.%d = %d\n", + eNB->frame, eNB->subframe, frameP, subframeP, delta); + return; + } + LOG_D(MAC, "Entering dlsch_ulsch scheduler %d.%d -> %d.%d = %d\n", + eNB->frame, eNB->subframe, frameP, subframeP, delta); + eNB->frame = frameP; eNB->subframe = subframeP; diff --git a/openair2/LAYER2/MAC/eNB_scheduler_RA.c b/openair2/LAYER2/MAC/eNB_scheduler_RA.c index 8a400af1f30a4b7576aad53ad6062c4ae013c9aa..e62978782c90f770056441b5f49d0d441c287780 100644 --- a/openair2/LAYER2/MAC/eNB_scheduler_RA.c +++ b/openair2/LAYER2/MAC/eNB_scheduler_RA.c @@ -918,7 +918,7 @@ generate_Msg4(module_id_t module_idP, module_idP, CC_idP, frameP, subframeP, UE_id, rrc_sdu_length); // AssertFatal(rrc_sdu_length > 0, // "[MAC][eNB Scheduler] CCCH not allocated, rrc_sdu_length: %d\n", rrc_sdu_length); - LOG_D(MAC,"[eNB %d][RAPROC] CC_id %d Frame %d, subframeP %d: Generating Msg4 with RRC Piggyback (RNTI %x)\n", + LOG_A(MAC,"[eNB %d][RAPROC] CC_id %d Frame %d, subframeP %d: Generating Msg4 with RRC Piggyback (RNTI %x)\n", module_idP, CC_idP, frameP, subframeP, ra->rnti); /// Choose first 4 RBs for Msg4, should really check that these are free! first_rb = 0; diff --git a/openair2/LAYER2/MAC/eNB_scheduler_fairRR.c b/openair2/LAYER2/MAC/eNB_scheduler_fairRR.c index e9f0b807c4f7d44f9a0360fd4b22e6a5b924d5b0..827d95dba5843c5e3d22ce259694620a85010246 100644 --- a/openair2/LAYER2/MAC/eNB_scheduler_fairRR.c +++ b/openair2/LAYER2/MAC/eNB_scheduler_fairRR.c @@ -560,7 +560,7 @@ void dlsch_scheduler_pre_ue_select_fairRR( return; } -void dlsch_scheduler_pre_processor_reset_fairRR( +static void dlsch_scheduler_pre_processor_reset_fairRR( module_id_t module_idP, frame_t frameP, sub_frame_t subframeP, @@ -729,7 +729,7 @@ void dlsch_scheduler_pre_processor_reset_fairRR( } // This function returns the estimated number of RBs required by each UE for downlink scheduling -void assign_rbs_required_fairRR( +static void assign_rbs_required_fairRR( module_id_t Mod_id, frame_t frameP, sub_frame_t subframe, @@ -1018,8 +1018,8 @@ void dlsch_scheduler_pre_processor_fairRR (module_id_t Mod_id, UE_id, CC_id, N_RBG[CC_id], - (uint16_t(*)[NUMBER_OF_UE_MAX])nb_rbs_required, - (uint16_t(*)[NUMBER_OF_UE_MAX])nb_rbs_required_remaining, + nb_rbs_required, + nb_rbs_required_remaining, rballoc_sub); temp_total_rbs_count -= ue_sched_ctl->pre_nb_available_rbs[CC_id]; temp_total_ue_count--; @@ -1925,7 +1925,7 @@ schedule_ue_spec_fairRR(module_id_t module_idP, } trace_pdu(DIRECTION_DOWNLINK, (uint8_t *)UE_info->DLSCH_pdu[CC_id][0][UE_id].payload[0], - TBS, module_idP, WS_RA_RNTI, UE_RNTI(module_idP, UE_id), + TBS, module_idP, WS_C_RNTI, UE_RNTI(module_idP, UE_id), eNB->frame, eNB->subframe,0,0); T(T_ENB_MAC_UE_DL_PDU_WITH_DATA, T_INT(module_idP), T_INT(CC_id), T_INT(rnti), T_INT(frameP), T_INT(subframeP), T_INT(harq_pid), T_BUFFER(UE_info->DLSCH_pdu[CC_id][0][UE_id].payload[0], TBS)); diff --git a/openair2/LAYER2/MAC/eNB_scheduler_fairRR.h b/openair2/LAYER2/MAC/eNB_scheduler_fairRR.h index 880e60ec199d747fea8bf0203105efd31eaab63e..9c4421abd285ca76427c0718481336d20e105444 100644 --- a/openair2/LAYER2/MAC/eNB_scheduler_fairRR.h +++ b/openair2/LAYER2/MAC/eNB_scheduler_fairRR.h @@ -85,21 +85,6 @@ void dlsch_scheduler_pre_ue_select_fairRR( uint16_t nb_rbs_required[MAX_NUM_CCs][MAX_MOBILES_PER_ENB], DLSCH_UE_SELECT dlsch_ue_select[MAX_NUM_CCs]); -void dlsch_scheduler_pre_processor_reset_fairRR( - module_id_t module_idP, - frame_t frameP, - sub_frame_t subframeP, - int min_rb_unit[NFAPI_CC_MAX], - uint16_t nb_rbs_required[NFAPI_CC_MAX][MAX_MOBILES_PER_ENB], - uint8_t rballoc_sub[NFAPI_CC_MAX][N_RBG_MAX], - uint8_t MIMO_mode_indicator[NFAPI_CC_MAX][N_RBG_MAX]); - -void assign_rbs_required_fairRR( - module_id_t Mod_id, - frame_t frameP, - sub_frame_t subframe, - uint16_t nb_rbs_required[NFAPI_CC_MAX][MAX_MOBILES_PER_ENB]); - void dlsch_scheduler_pre_processor_allocate_fairRR( module_id_t Mod_id, int UE_id, diff --git a/openair2/LAYER2/MAC/main_ue.c b/openair2/LAYER2/MAC/main_ue.c index 2140d66a1024e93ebeefc908c042c8371e9e6442..5ea2d26abdb063468e939fe1987806be019e0872 100644 --- a/openair2/LAYER2/MAC/main_ue.c +++ b/openair2/LAYER2/MAC/main_ue.c @@ -41,10 +41,12 @@ #include "common/utils/LOG/log.h" #include "nfapi/oai_integration/vendor_ext.h" #include "RRC/L2_INTERFACE/openair_rrc_L2_interface.h" - - +#include "PHY_INTERFACE/phy_stub_UE.h" #include "common/ran_context.h" #include <openair2/RRC/LTE/rrc_proto.h> + +extern void openair_rrc_top_init_ue( int eMBMS_active, char *uecap_xer, uint8_t cba_group_active, uint8_t HO_active); + void dl_phy_sync_success(module_id_t module_idP, frame_t frameP, unsigned char eNB_index, uint8_t first_sync) { //init as MR LOG_D(MAC, "[UE %d] Frame %d: PHY Sync to eNB_index %d successful \n", module_idP, frameP, eNB_index); @@ -88,6 +90,16 @@ mac_top_init_ue(int eMBMS_active, char *uecap_xer, UE_mac_inst = NULL; } + // mutex below are used for multiple UE's L2 FAPI simulation. + if (NFAPI_MODE == NFAPI_UE_STUB_PNF || NFAPI_MODE == NFAPI_MODE_STANDALONE_PNF) { + pthread_mutex_init(&fill_ul_mutex.rx_mutex,NULL); + pthread_mutex_init(&fill_ul_mutex.crc_mutex,NULL); + pthread_mutex_init(&fill_ul_mutex.sr_mutex,NULL); + pthread_mutex_init(&fill_ul_mutex.harq_mutex,NULL); + pthread_mutex_init(&fill_ul_mutex.cqi_mutex,NULL); + pthread_mutex_init(&fill_ul_mutex.rach_mutex,NULL); + } + LOG_I(MAC, "[MAIN] calling RRC\n"); openair_rrc_top_init_ue(eMBMS_active, uecap_xer, cba_group_active, HO_active); diff --git a/openair2/LAYER2/MAC/ra_procedures.c b/openair2/LAYER2/MAC/ra_procedures.c index 0d1afdf2a247814aed4ecac945051130544b4339..1aa959e103450f7b759585523c7959bdb933cc1f 100644 --- a/openair2/LAYER2/MAC/ra_procedures.c +++ b/openair2/LAYER2/MAC/ra_procedures.c @@ -287,9 +287,12 @@ PRACH_RESOURCES_t *ue_get_rach(module_id_t module_idP, int CC_id, sub_frame_t subframeP) { uint8_t Size = 0; UE_MODE_t UE_mode; - + protocol_ctxt_t ctxt; + PROTOCOL_CTXT_SET_BY_MODULE_ID(&ctxt, module_idP, ENB_FLAG_NO, + UE_mac_inst[module_idP].crnti, frameP, + subframeP, eNB_indexP); // Modification for phy_stub_ue operation - if(NFAPI_MODE == NFAPI_UE_STUB_PNF) { // phy_stub_ue mode + if(NFAPI_MODE == NFAPI_UE_STUB_PNF || NFAPI_MODE == NFAPI_MODE_STANDALONE_PNF) { // phy_stub_ue mode UE_mode = UE_mac_inst[module_idP].UE_mode[0]; LOG_D(MAC, "ue_get_rach , UE_mode: %d", UE_mode); } else { // Full stack mode @@ -320,6 +323,18 @@ PRACH_RESOURCES_t *ue_get_rach(module_id_t module_idP, int CC_id, if (UE_mac_inst[module_idP].RA_active == 0) { LOG_I(MAC, "RA not active\n"); + if (UE_rrc_inst[module_idP].Info[eNB_indexP].T300_cnt + != T300[UE_rrc_inst[module_idP].sib2[eNB_indexP]->ue_TimersAndConstants.t300]) { + /* Calling rrc_ue_generate_RRCConnectionRequest here to ensure that + every time we fill the UE_mac_inst context we generate new random + values in msg3. When the T300 timer has expired, rrc_common.c will + call rrc_ue_generate_RRCConnectionRequest, so we do not want to call + when UE_rrc_inst[module_idP].Info[eNB_indexP].T300_cnt == + T300[UE_rrc_inst[module_idP].sib2[eNB_indexP]->ue_TimersAndConstants.t300. */ + UE_rrc_inst[module_idP].Srb0[eNB_indexP].Tx_buffer.payload_size = 0; + rrc_ue_generate_RRCConnectionRequest(&ctxt, eNB_indexP); + } + // check if RRC is ready to initiate the RA procedure Size = mac_rrc_data_req_ue(module_idP, CC_id, diff --git a/openair2/LAYER2/MAC/rar_tools_ue.c b/openair2/LAYER2/MAC/rar_tools_ue.c index 611aaf865b27d1d36f21785f7dbdcfa2ef086764..9af5baec3998bedd25bc552087668fe1ff2356f8 100644 --- a/openair2/LAYER2/MAC/rar_tools_ue.c +++ b/openair2/LAYER2/MAC/rar_tools_ue.c @@ -67,6 +67,7 @@ uint16_t ue_process_rar(const module_id_t module_idP, const int CC_id, const fra LOG_D(PHY, "Found RAR with the intended RAPID %d\n", rarh->RAPID); rar = (uint8_t *) (dlsch_buffer + n_rarh + (n_rarpy - 1) * 6); + UE_mac_inst[module_idP].UE_mode[0] = RA_RESPONSE; break; } @@ -77,9 +78,10 @@ uint16_t ue_process_rar(const module_id_t module_idP, const int CC_id, const fra } if (rarh->E == 0) { - LOG_I(PHY, + LOG_I(MAC, "No RAR found with the intended RAPID. The closest RAPID in all RARs is %d\n", best_rx_rapid); + UE_mac_inst[module_idP].UE_mode[0] = PRACH; break; } else { rarh++; @@ -94,7 +96,7 @@ uint16_t ue_process_rar(const module_id_t module_idP, const int CC_id, const fra return (0xffff); } - LOG_I(MAC, + LOG_A(MAC, "[UE %d][RAPROC] Frame %d Received RAR (%02x|%02x.%02x.%02x.%02x.%02x.%02x) for preamble %d/%d\n", module_idP, frameP, *(uint8_t *) rarh, rar[0], rar[1], rar[2], rar[3], rar[4], rar[5], rarh->RAPID, preamble_index); @@ -130,7 +132,7 @@ uint16_t ue_process_rar(const module_id_t module_idP, const int CC_id, const fra } // move the selected RAR to the front of the RA_PDSCH buffer - memcpy(selected_rar_buffer + 0, (uint8_t *) rarh, 1); - memcpy(selected_rar_buffer + 1, (uint8_t *) rar, 6); + memmove(selected_rar_buffer + 0, (uint8_t *) rarh, 1); + memmove(selected_rar_buffer + 1, (uint8_t *) rar, 6); return ret; } diff --git a/openair2/LAYER2/MAC/ue_procedures.c b/openair2/LAYER2/MAC/ue_procedures.c index 21d349ea5284c468bfb27e08f772849e53d4431d..926c44381cbefccd38c6a35a798c48d5dc8ac59b 100644 --- a/openair2/LAYER2/MAC/ue_procedures.c +++ b/openair2/LAYER2/MAC/ue_procedures.c @@ -149,15 +149,13 @@ void ue_init_mac(module_id_t module_idP) { UE_mac_inst[module_idP].scheduling_info.LCID_buffer_remain[i] = 0; } - if(NFAPI_MODE==NFAPI_UE_STUB_PNF) { + if(NFAPI_MODE==NFAPI_UE_STUB_PNF || NFAPI_MODE==NFAPI_MODE_STANDALONE_PNF) { pthread_mutex_init(&UE_mac_inst[module_idP].UL_INFO_mutex,NULL); - UE_mac_inst[module_idP].UE_mode[0] = NOT_SYNCHED; //PRACH; + UE_mac_inst[module_idP].UE_mode[0] = PRACH; //NOT_SYNCHED; UE_mac_inst[module_idP].first_ULSCH_Tx =0; UE_mac_inst[module_idP].SI_Decoded = 0; next_ra_frame = 0; next_Mod_id = 0; - tx_request_pdu_list = NULL; - tx_req_num_elems = 0; } } @@ -411,7 +409,7 @@ ue_send_sdu(module_id_t module_idP, if (payload_ptr != NULL) { for (i = 0; i < num_ce; i++) { - // printf("ce %d : %d\n",i,rx_ces[i]); + LOG_I(MAC, "ce %d : %d\n",i,rx_ces[i]); switch (rx_ces[i]) { case UE_CONT_RES: LOG_I(MAC, @@ -436,7 +434,7 @@ ue_send_sdu(module_id_t module_idP, "[UE %d][RAPROC] Contention detected, RA failed\n", module_idP); - if(NFAPI_MODE==NFAPI_UE_STUB_PNF) { // phy_stub mode + if(NFAPI_MODE==NFAPI_UE_STUB_PNF || NFAPI_MODE==NFAPI_MODE_STANDALONE_PNF) { // phy_stub mode // Modification for phy_stub mode operation here. We only need to make sure that the ue_mode is back to // PRACH state. LOG_I(MAC, "nfapi_mode3: Setting UE_mode BACK to PRACH 1\n"); @@ -462,7 +460,7 @@ ue_send_sdu(module_id_t module_idP, [module_idP]. RA_contention_resolution_timer_active = 0; - if(NFAPI_MODE==NFAPI_UE_STUB_PNF) { // phy_stub mode + if(NFAPI_MODE==NFAPI_UE_STUB_PNF || NFAPI_MODE==NFAPI_MODE_STANDALONE_PNF) { // phy_stub mode // Modification for phy_stub mode operation here. We only need to change the ue_mode to PUSCH UE_mac_inst[module_idP].UE_mode[eNB_index] = PUSCH; } else { // Full stack mode @@ -480,7 +478,7 @@ ue_send_sdu(module_id_t module_idP, #endif // Eliminate call to process_timing_advance for the phy_stub UE operation mode. Is this correct? - if (NFAPI_MODE!=NFAPI_UE_STUB_PNF) { + if (NFAPI_MODE!=NFAPI_UE_STUB_PNF && NFAPI_MODE!=NFAPI_MODE_STANDALONE_PNF) { process_timing_advance(module_idP,CC_id,payload_ptr[0]); } @@ -2508,6 +2506,7 @@ ue_get_sdu(module_id_t module_idP, int CC_id, frame_t frameP, scheduling_info.BSR_bytes[UE_mac_inst[module_idP]. scheduling_info.LCGID [lcid]]); + AssertFatal(num_sdus < sizeof(sdu_lengths) / sizeof(sdu_lengths[0]), "num_sdus %d > num sdu_length elements\n", num_sdus); sdu_lengths[num_sdus] = mac_rlc_data_req(module_idP, UE_mac_inst [module_idP]. @@ -2639,7 +2638,7 @@ ue_get_sdu(module_id_t module_idP, int CC_id, frame_t frameP, // build PHR and update the timers if (phr_ce_len == sizeof(POWER_HEADROOM_CMD)) { - if(NFAPI_MODE==NFAPI_UE_STUB_PNF) { + if(NFAPI_MODE==NFAPI_UE_STUB_PNF || NFAPI_MODE==NFAPI_MODE_STANDALONE_PNF) { //Substitute with a static value for the MAC layer abstraction (phy_stub mode) phr_p->PH = 60; } else { @@ -3090,7 +3089,7 @@ ue_scheduler(const module_id_t module_idP, "Module id %u Contention resolution timer expired, RA failed\n", module_idP); - if(NFAPI_MODE==NFAPI_UE_STUB_PNF) { // phy_stub mode + if(NFAPI_MODE==NFAPI_UE_STUB_PNF || NFAPI_MODE==NFAPI_MODE_STANDALONE_PNF) { // phy_stub mode // Modification for phy_stub mode operation here. We only need to make sure that the ue_mode is back to // PRACH state. LOG_I(MAC, "nfapi_mode3: Setting UE_mode to PRACH 2 \n"); diff --git a/openair2/LAYER2/NR_MAC_COMMON/nr_mac.h b/openair2/LAYER2/NR_MAC_COMMON/nr_mac.h index 4ef0a55c6b96c0691fc754f29a9c61a11958f5f2..ba3128923fb32e86895f99fd183a7ec179db9619 100644 --- a/openair2/LAYER2/NR_MAC_COMMON/nr_mac.h +++ b/openair2/LAYER2/NR_MAC_COMMON/nr_mac.h @@ -264,6 +264,16 @@ typedef struct { uint8_t nbits; } dci_field_t; +typedef struct { + bool expected_sib; + bool index_has_sib[16]; + bool expected_rar; + bool index_has_rar[16]; + bool expected_dci; + bool index_has_dci[16]; + int active_harq_sfn_slot; +} nr_emulated_l1_t; + typedef struct { uint8_t format_indicator; //1 bit diff --git a/openair2/LAYER2/NR_MAC_COMMON/nr_mac_common.c b/openair2/LAYER2/NR_MAC_COMMON/nr_mac_common.c index 3f4be9dd58c4d119b9f10874e85c2069cf319b02..942e3afad166632f06ab107957e10556e1bff5eb 100644 --- a/openair2/LAYER2/NR_MAC_COMMON/nr_mac_common.c +++ b/openair2/LAYER2/NR_MAC_COMMON/nr_mac_common.c @@ -2495,6 +2495,61 @@ uint8_t get_K_ptrs(uint16_t nrb0, uint16_t nrb1, uint16_t N_RB) { return 4; } +/******************************************************************* +* +* NAME : get_nr_srs_offset +* +* PARAMETERS : periodicityAndOffset for SRS +* +* RETURN : the offset parameter for SRS +* +*********************************************************************/ + +uint16_t get_nr_srs_offset(NR_SRS_PeriodicityAndOffset_t periodicityAndOffset) { + + switch(periodicityAndOffset.present) { + case NR_SRS_PeriodicityAndOffset_PR_sl1: + return periodicityAndOffset.choice.sl1; + case NR_SRS_PeriodicityAndOffset_PR_sl2: + return periodicityAndOffset.choice.sl2; + case NR_SRS_PeriodicityAndOffset_PR_sl4: + return periodicityAndOffset.choice.sl4; + case NR_SRS_PeriodicityAndOffset_PR_sl5: + return periodicityAndOffset.choice.sl5; + case NR_SRS_PeriodicityAndOffset_PR_sl8: + return periodicityAndOffset.choice.sl8; + case NR_SRS_PeriodicityAndOffset_PR_sl10: + return periodicityAndOffset.choice.sl10; + case NR_SRS_PeriodicityAndOffset_PR_sl16: + return periodicityAndOffset.choice.sl16; + case NR_SRS_PeriodicityAndOffset_PR_sl20: + return periodicityAndOffset.choice.sl20; + case NR_SRS_PeriodicityAndOffset_PR_sl32: + return periodicityAndOffset.choice.sl32; + case NR_SRS_PeriodicityAndOffset_PR_sl40: + return periodicityAndOffset.choice.sl40; + case NR_SRS_PeriodicityAndOffset_PR_sl64: + return periodicityAndOffset.choice.sl64; + case NR_SRS_PeriodicityAndOffset_PR_sl80: + return periodicityAndOffset.choice.sl80; + case NR_SRS_PeriodicityAndOffset_PR_sl160: + return periodicityAndOffset.choice.sl160; + case NR_SRS_PeriodicityAndOffset_PR_sl320: + return periodicityAndOffset.choice.sl320; + case NR_SRS_PeriodicityAndOffset_PR_sl640: + return periodicityAndOffset.choice.sl640; + case NR_SRS_PeriodicityAndOffset_PR_sl1280: + return periodicityAndOffset.choice.sl1280; + case NR_SRS_PeriodicityAndOffset_PR_sl2560: + return periodicityAndOffset.choice.sl2560; + case NR_SRS_PeriodicityAndOffset_PR_NOTHING: + LOG_W(NR_MAC,"NR_SRS_PeriodicityAndOffset_PR_NOTHING\n"); + return 0; + default: + return 0; + } +} + // Set the transform precoding status according to 6.1.3 of 3GPP TS 38.214 version 16.3.0 Release 16: // - "UE procedure for applying transform precoding on PUSCH" uint8_t get_transformPrecoding(const NR_BWP_UplinkCommon_t *initialUplinkBWP, diff --git a/openair2/LAYER2/NR_MAC_COMMON/nr_mac_common.h b/openair2/LAYER2/NR_MAC_COMMON/nr_mac_common.h index ced29f066f14a93123597b8633114476daa6fba6..91450fc7960539691bd8a824fce0f554db5fc96c 100644 --- a/openair2/LAYER2/NR_MAC_COMMON/nr_mac_common.h +++ b/openair2/LAYER2/NR_MAC_COMMON/nr_mac_common.h @@ -119,6 +119,8 @@ int32_t get_l_prime(uint8_t duration_in_symbols, uint8_t mapping_type, pusch_dmr uint8_t get_L_ptrs(uint8_t mcs1, uint8_t mcs2, uint8_t mcs3, uint8_t I_mcs, uint8_t mcs_table); uint8_t get_K_ptrs(uint16_t nrb0, uint16_t nrb1, uint16_t N_RB); +uint16_t get_nr_srs_offset(NR_SRS_PeriodicityAndOffset_t periodicityAndOffset); + void get_type0_PDCCH_CSS_config_parameters(NR_Type0_PDCCH_CSS_config_t *type0_PDCCH_CSS_config, frame_t frameP, NR_MIB_t *mib, @@ -192,8 +194,13 @@ uint8_t get_transformPrecoding(const NR_BWP_UplinkCommon_t *initialUplinkBWP, uint8_t configuredGrant); void nr_mac_gNB_rrc_ul_failure(const module_id_t Mod_instP, - const int CC_idP, - const frame_t frameP, - const sub_frame_t subframeP, - const rnti_t rntiP) ; + const int CC_idP, + const frame_t frameP, + const sub_frame_t subframeP, + const rnti_t rntiP); + +void nr_mac_gNB_rrc_ul_failure_reset(const module_id_t Mod_instP, + const frame_t frameP, + const sub_frame_t subframeP, + const rnti_t rntiP); #endif diff --git a/openair2/LAYER2/NR_MAC_COMMON/nr_mac_extern.h b/openair2/LAYER2/NR_MAC_COMMON/nr_mac_extern.h index 5def748d42dc535877d22c4a055e5b521544a4ac..4b37c19dff25bdb6208aea2233338af8f61ac2fc 100644 --- a/openair2/LAYER2/NR_MAC_COMMON/nr_mac_extern.h +++ b/openair2/LAYER2/NR_MAC_COMMON/nr_mac_extern.h @@ -39,6 +39,8 @@ extern const uint8_t nr_slots_per_frame[5]; +extern dci_pdu_rel15_t *def_dci_pdu_rel15; + /* extern const uint32_t BSR_TABLE[BSR_TABLE_SIZE]; extern const uint32_t Extended_BSR_TABLE[BSR_TABLE_SIZE]; extern const uint8_t cqi2fmt0_agg[MAX_SUPPORTED_BW][CQI_VALUE_RANGE]; diff --git a/openair2/LAYER2/NR_MAC_UE/config_ue.c b/openair2/LAYER2/NR_MAC_UE/config_ue.c index f67a3e1fa52424c96c97f1e007febebb953d1d6c..b03c8fa55fa4ad56746e132e0796877892592838 100644 --- a/openair2/LAYER2/NR_MAC_UE/config_ue.c +++ b/openair2/LAYER2/NR_MAC_UE/config_ue.c @@ -44,46 +44,9 @@ int set_tdd_config_nr_ue(fapi_nr_config_request_t *cfg, int nrofUplinkSlots, int nrofUplinkSymbols) { int slot_number = 0; - int nb_periods_per_frame; + int nb_periods_per_frame = get_nb_periods_per_frame(cfg->tdd_table.tdd_period); int nb_slots_to_set = TDD_CONFIG_NB_FRAMES*(1<<mu)*NR_NUMBER_OF_SUBFRAMES_PER_FRAME; - switch(cfg->tdd_table.tdd_period) { - case 0: - nb_periods_per_frame = 20; // 10ms/0p5ms - break; - - case 1: - nb_periods_per_frame = 16; // 10ms/0p625ms - break; - - case 2: - nb_periods_per_frame = 10; // 10ms/1ms - break; - - case 3: - nb_periods_per_frame = 8; // 10ms/1p25ms - break; - - case 4: - nb_periods_per_frame = 5; // 10ms/2ms - break; - - case 5: - nb_periods_per_frame = 4; // 10ms/2p5ms - break; - - case 6: - nb_periods_per_frame = 2; // 10ms/5ms - break; - - case 7: - nb_periods_per_frame = 1; // 10ms/10ms - break; - - default: - AssertFatal(1==0,"Undefined tdd period %d\n", cfg->tdd_table.tdd_period); - } - int nb_slots_per_period = ((1<<mu) * NR_NUMBER_OF_SUBFRAMES_PER_FRAME)/nb_periods_per_frame; cfg->tdd_table.tdd_period_in_slots = nb_slots_per_period; @@ -664,7 +627,8 @@ int nr_rrc_mac_config_req_ue( pthread_mutex_init(&(mac->ul_config_request[i].mutex_ul_config), NULL); // Setup the SSB to Rach Occasions mapping according to the config build_ssb_to_ro_map(mac);//->scc, mac->phy_config.config_req.cell_config.frame_duplex_type); - mac->if_module->phy_config_request(&mac->phy_config); + if (!get_softmodem_params()->emulate_l1) + mac->if_module->phy_config_request(&mac->phy_config); mac->common_configuration_complete = 1; } if(scell_group_config != NULL ){ @@ -691,7 +655,16 @@ int nr_rrc_mac_config_req_ue( else if (cell_group_config != NULL ){ LOG_I(MAC,"Applying CellGroupConfig from gNodeB\n"); mac->cg = cell_group_config; - mac->servCellIndex = cell_group_config->spCellConfig->servCellIndex ? *cell_group_config->spCellConfig->servCellIndex : 0; + if (cell_group_config->spCellConfig) { + mac->servCellIndex = cell_group_config->spCellConfig->servCellIndex ? *cell_group_config->spCellConfig->servCellIndex : 0; + mac->DL_BWP_Id=mac->cg->spCellConfig->spCellConfigDedicated->firstActiveDownlinkBWP_Id ? *mac->cg->spCellConfig->spCellConfigDedicated->firstActiveDownlinkBWP_Id : 0; + mac->UL_BWP_Id=mac->cg->spCellConfig->spCellConfigDedicated->uplinkConfig->firstActiveUplinkBWP_Id ? *mac->cg->spCellConfig->spCellConfigDedicated->uplinkConfig->firstActiveUplinkBWP_Id : 0; + } + else { + mac->servCellIndex = 0; + mac->DL_BWP_Id = 0; + mac->UL_BWP_Id = 0; + } mac->scheduling_info.periodicBSR_SF = MAC_UE_BSR_TIMER_NOT_RUNNING; @@ -704,7 +677,26 @@ int nr_rrc_mac_config_req_ue( mac->scheduling_info.retxBSR_SF); config_control_ue(mac); - //config_common_ue(mac,module_id,cc_idP); + if (get_softmodem_params()->nsa) { + if (cell_group_config->spCellConfig && cell_group_config->spCellConfig->reconfigurationWithSync) { + if (cell_group_config->spCellConfig->reconfigurationWithSync->rach_ConfigDedicated) { + ra->rach_ConfigDedicated = cell_group_config->spCellConfig->reconfigurationWithSync->rach_ConfigDedicated->choice.uplink; + } + mac->scc = cell_group_config->spCellConfig->reconfigurationWithSync->spCellConfigCommon; + int num_slots = mac->scc->tdd_UL_DL_ConfigurationCommon->pattern1.nrofUplinkSlots; + if (mac->scc->tdd_UL_DL_ConfigurationCommon->pattern1.nrofUplinkSymbols > 0) { + num_slots++; + } + mac->ul_config_request = calloc(num_slots, sizeof(*mac->ul_config_request)); + config_common_ue(mac,module_id,cc_idP); + mac->crnti = cell_group_config->spCellConfig->reconfigurationWithSync->newUE_Identity; + LOG_I(MAC,"Configuring CRNTI %x\n",mac->crnti); + } + + // Setup the SSB to Rach Occasions mapping according to the config + build_ssb_to_ro_map(mac); + } + /* if(mac_cell_group_configP != NULL){ if(mac_cell_group_configP->drx_Config != NULL ){ diff --git a/openair2/LAYER2/NR_MAC_UE/mac_defs.h b/openair2/LAYER2/NR_MAC_UE/mac_defs.h index edfd37c3a00bc4073f6f914b1d29351dfdecb387..ad86b1385df114294fbe2f131a9a568c75f06a38 100644 --- a/openair2/LAYER2/NR_MAC_UE/mac_defs.h +++ b/openair2/LAYER2/NR_MAC_UE/mac_defs.h @@ -430,8 +430,14 @@ typedef struct { dci_pdu_rel15_t def_dci_pdu_rel15[8]; + // Defined for abstracted mode + nr_downlink_indication_t dl_info; NR_UE_HARQ_STATUS_t dl_harq_info[16]; + nr_emulated_l1_t nr_ue_emul_l1; + + pthread_mutex_t mutex_dl_info; + } NR_UE_MAC_INST_t; typedef enum seach_space_mask_e { diff --git a/openair2/LAYER2/NR_MAC_UE/mac_extern.h b/openair2/LAYER2/NR_MAC_UE/mac_extern.h index e551790f7aa1bd8e67f6bf4924fd6c5237817240..7fd63666f07957912441dc6fdf4fe85e13f51686 100644 --- a/openair2/LAYER2/NR_MAC_UE/mac_extern.h +++ b/openair2/LAYER2/NR_MAC_UE/mac_extern.h @@ -68,8 +68,6 @@ extern const uint16_t table_7_2_1[16]; extern dci_pdu_rel15_t *def_dci_pdu_rel15; -extern dci_pdu_rel15_t *def_dci_pdu_rel15; - extern void mac_rlc_data_ind(const module_id_t module_idP, const rnti_t rntiP, const eNB_index_t eNB_index, diff --git a/openair2/LAYER2/NR_MAC_UE/mac_proto.h b/openair2/LAYER2/NR_MAC_UE/mac_proto.h index a9632fb3309925f8ff53d940c00463bee37c8577..288716ed851b0a5da0c79a25be16cc8ed6339840 100644 --- a/openair2/LAYER2/NR_MAC_UE/mac_proto.h +++ b/openair2/LAYER2/NR_MAC_UE/mac_proto.h @@ -299,9 +299,6 @@ void set_harq_status(NR_UE_MAC_INST_t *mac, frame_t frame, int slot); -void update_harq_status(nr_downlink_indication_t *dl_info, - int pdu_id); - uint8_t get_downlink_ack(NR_UE_MAC_INST_t *mac, frame_t frame, int slot, diff --git a/openair2/LAYER2/NR_MAC_UE/nr_ra_procedures.c b/openair2/LAYER2/NR_MAC_UE/nr_ra_procedures.c index 2d059783fed0e56a4ebc1a807328c0ceb5a911b8..3851ee011d34e0498b126b7d2465a06172a1fe04 100644 --- a/openair2/LAYER2/NR_MAC_UE/nr_ra_procedures.c +++ b/openair2/LAYER2/NR_MAC_UE/nr_ra_procedures.c @@ -595,7 +595,9 @@ void nr_get_prach_resources(module_id_t mod_id, LOG_D(MAC, "In %s: selected RA preamble index %d for contention-free random access procedure for SSB with Id %d\n", __FUNCTION__, prach_resources->ra_PreambleIndex, cfra_ssb_resource_idx); } } else { - int16_t dl_pathloss = get_nr_PL(mod_id, CC_id, gNB_id); + /* TODO: This controls the tx_power of UE and the ramping procedure of RA of UE. Later we + can abstract this, perhaps in the proxy. But for the time being lets leave it as below. */ + int16_t dl_pathloss = !get_softmodem_params()->emulate_l1 ? get_nr_PL(mod_id, CC_id, gNB_id) : 0; ssb_rach_config(ra, prach_resources, nr_rach_ConfigCommon, prach_pdu); ra_preambles_config(prach_resources, mac, dl_pathloss); LOG_D(MAC, "[RAPROC] - Selected RA preamble index %d for contention-based random access procedure... \n", prach_resources->ra_PreambleIndex); @@ -674,7 +676,8 @@ uint8_t nr_ue_get_rach(NR_PRACH_RESOURCES_t *prach_resources, // Delay init RA procedure to allow the convergence of the IIR filter on PRACH noise measurements at gNB side if (!prach_resources->init_msg1) { - if ( (mac->common_configuration_complete>0 || get_softmodem_params()->do_ra==1) && ((MAX_FRAME_NUMBER+frame-prach_resources->sync_frame)%MAX_FRAME_NUMBER)>150 ){ + if ((mac->common_configuration_complete > 0 || get_softmodem_params()->do_ra || get_softmodem_params()->nsa) && + ((MAX_FRAME_NUMBER + frame - prach_resources->sync_frame) % MAX_FRAME_NUMBER) > 150) { prach_resources->init_msg1 = 1; } else { LOG_D(NR_MAC,"PRACH Condition not met: frame %d, prach_resources->sync_frame %d\n",frame,prach_resources->sync_frame); @@ -738,6 +741,30 @@ uint8_t nr_ue_get_rach(NR_PRACH_RESOURCES_t *prach_resources, pdu -= sh_size; } + } else if (get_softmodem_params()->nsa) { + + uint8_t mac_sdus[MAX_NR_ULSCH_PAYLOAD_BYTES]; + uint16_t sdu_lengths[NB_RB_MAX] = {0}; + int TBS_bytes = 848; + int mac_ce_len = 0; + int header_length_total=0; + unsigned short post_padding = 1; + + // fill ulsch_buffer with random data + for (int i = 0; i < TBS_bytes; i++){ + mac_sdus[i] = (unsigned char) (lrand48()&0xff); + } + //Sending SDUs with size 1 + //Initialize elements of sdu_lengths + sdu_lengths[0] = TBS_bytes - 3 - post_padding - mac_ce_len; + header_length_total += 2 + (sdu_lengths[0] >= 128); + size_sdu += sdu_lengths[0]; + + if (size_sdu > 0) { + memcpy(ra->cont_res_id, mac_sdus, sizeof(uint8_t) * 6); + ra->Msg3_size = size_sdu + sizeof(NR_MAC_SUBHEADER_SHORT) + sizeof(NR_MAC_SUBHEADER_SHORT); + } + } else { size_sdu = nr_write_ce_ulsch_pdu(pdu, mac, 0, &(mac->crnti), NULL, NULL, NULL); @@ -746,19 +773,20 @@ uint8_t nr_ue_get_rach(NR_PRACH_RESOURCES_t *prach_resources, } - if (size_sdu > 0 && ra->generate_nr_prach == GENERATE_PREAMBLE) { + if (size_sdu > 0 && (ra->generate_nr_prach == GENERATE_PREAMBLE || get_softmodem_params()->nsa)) { LOG_D(NR_MAC, "In %s: [UE %d][%d.%d]: starting initialisation Random Access Procedure...\n", __FUNCTION__, mod_id, frame, nr_slot_tx); - AssertFatal(TBS_max > ra->Msg3_size, "In %s: allocated resources are not enough for Msg3!\n", __FUNCTION__); // Init RA procedure init_RA(mod_id, prach_resources, setup, rach_ConfigGeneric, rach_ConfigDedicated); nr_get_RA_window(mac); // Fill in preamble and PRACH resources - nr_get_prach_resources(mod_id, CC_id, gNB_id, prach_resources, prach_pdu, rach_ConfigDedicated); + if (ra->generate_nr_prach == GENERATE_PREAMBLE) + nr_get_prach_resources(mod_id, CC_id, gNB_id, prach_resources, prach_pdu, rach_ConfigDedicated); // Padding: fill remainder with 0 if (TBS_max - ra->Msg3_size > 0) { + AssertFatal(TBS_max > ra->Msg3_size, "In %s: allocated resources are not enough for Msg3!\n", __FUNCTION__); LOG_D(NR_MAC, "In %s: remaining %d bytes, filling with padding\n", __FUNCTION__, TBS_max - ra->Msg3_size); ((NR_MAC_SUBHEADER_FIXED *) pdu)->R = 0; ((NR_MAC_SUBHEADER_FIXED *) pdu)->LCID = UL_SCH_LCID_PADDING; @@ -777,8 +805,10 @@ uint8_t nr_ue_get_rach(NR_PRACH_RESOURCES_t *prach_resources, // Msg3 was initialized with TBS_max bytes because the RA_Msg3_size will only be known after // receiving Msg2 (which contains the Msg3 resource reserve). // Msg3 will be transmitted with RA_Msg3_size bytes, removing unnecessary 0s. - mac->ulsch_pdu.Pdu_size = TBS_max; - memcpy(mac->ulsch_pdu.payload, payload, TBS_max); + if (!get_softmodem_params()->nsa) { + mac->ulsch_pdu.Pdu_size = TBS_max; + memcpy(mac->ulsch_pdu.payload, payload, TBS_max); + } } else { return 0; @@ -936,7 +966,7 @@ void nr_ra_succeeded(module_id_t mod_id, frame_t frame, int slot){ } else { - LOG_I(MAC, "[UE %d][%d.%d][RAPROC] RA procedure succeeded. CB-RA: Contention Resolution is successful.\n", mod_id, frame, slot); + LOG_A(MAC, "[UE %d][%d.%d][RAPROC] RA procedure succeeded. CB-RA: Contention Resolution is successful.\n", mod_id, frame, slot); ra->RA_contention_resolution_timer_active = 0; mac->crnti = ra->t_crnti; diff --git a/openair2/LAYER2/NR_MAC_UE/nr_ue_dci_configuration.c b/openair2/LAYER2/NR_MAC_UE/nr_ue_dci_configuration.c index ad82161fb977c03149842b1a28dbc7e463a56f2d..3453e071b10c897cfdb0e8fb8190081e4dbf62b9 100644 --- a/openair2/LAYER2/NR_MAC_UE/nr_ue_dci_configuration.c +++ b/openair2/LAYER2/NR_MAC_UE/nr_ue_dci_configuration.c @@ -428,7 +428,8 @@ void ue_dci_configuration(NR_UE_MAC_INST_t *mac, fapi_nr_dl_config_request_t *dl NR_SetupRelease_PDCCH_ConfigCommon_t *pdcch_ConfigCommon = bwp_Common->pdcch_ConfigCommon; if (pdcch_ConfigCommon && - pdcch_ConfigCommon->choice.setup->searchSpaceSIB1){ + pdcch_ConfigCommon->choice.setup->searchSpaceSIB1 && + !get_softmodem_params()->nsa) { NR_SearchSpace_t *ss0 = mac->search_space_zero; fapi_nr_dl_config_dci_dl_pdu_rel15_t *rel15 = &dl_config->dl_config_list[dl_config->number_pdus].dci_config_pdu.dci_config_rel15; @@ -442,7 +443,7 @@ void ue_dci_configuration(NR_UE_MAC_INST_t *mac, fapi_nr_dl_config_request_t *dl } } } - else { // use coreset0/ss0 + else if (!get_softmodem_params()->nsa) { // use coreset0/ss0 NR_SearchSpace_t *ss0 = mac->search_space_zero; if(ss0) { fapi_nr_dl_config_dci_dl_pdu_rel15_t *rel15 = &dl_config->dl_config_list[0].dci_config_pdu.dci_config_rel15; diff --git a/openair2/LAYER2/NR_MAC_UE/nr_ue_procedures.c b/openair2/LAYER2/NR_MAC_UE/nr_ue_procedures.c index 0f0a9a6a4b132b64e94e9fd9ac75869e11617199..85bb10290a9159d1c024f9522f382badcb51e3e2 100644 --- a/openair2/LAYER2/NR_MAC_UE/nr_ue_procedures.c +++ b/openair2/LAYER2/NR_MAC_UE/nr_ue_procedures.c @@ -608,7 +608,6 @@ int nr_ue_process_dci_indication_pdu(module_id_t module_id,int cc_id, int gNB_in def_dci_pdu_rel15 = &mac->def_dci_pdu_rel15[dci->dci_format]; } int8_t ret_proc = nr_ue_process_dci(module_id, cc_id, gNB_index, frame, slot, def_dci_pdu_rel15, dci); - memset(def_dci_pdu_rel15, 0, sizeof(dci_pdu_rel15_t)); return ret_proc; } @@ -728,6 +727,7 @@ int8_t nr_ue_process_dci(module_id_t module_id, int cc_id, uint8_t gNB_index, fr LOG_W(MAC, "In %s: ul_config request is NULL. Probably due to unexpected UL DCI in frame.slot %d.%d. Ignoring DCI!\n", __FUNCTION__, frame, slot); return -1; } + ul_config->number_pdus = 0; pthread_mutex_lock(&ul_config->mutex_ul_config); AssertFatal(ul_config->number_pdus<FAPI_NR_UL_CONFIG_LIST_NUM, "ul_config->number_pdus %d out of bounds\n",ul_config->number_pdus); @@ -868,7 +868,7 @@ int8_t nr_ue_process_dci(module_id_t module_id, int cc_id, uint8_t gNB_index, fr /* dmrs symbol positions*/ dlsch_config_pdu_1_0->dlDmrsSymbPos = fill_dmrs_mask(pdsch_config, - mac->mib->dmrs_TypeA_Position, + (get_softmodem_params()->nsa) ? mac->scc->dmrs_TypeA_Position : mac->mib->dmrs_TypeA_Position, dlsch_config_pdu_1_0->number_symbols, dlsch_config_pdu_1_0->start_symbol, mappingtype); @@ -944,6 +944,10 @@ int8_t nr_ue_process_dci(module_id_t module_id, int cc_id, uint8_t gNB_index, fr return -1; } + if(rnti != ra->ra_rnti && rnti != SI_RNTI) + AssertFatal(1+dci->pdsch_to_harq_feedback_timing_indicator.val>=DURATION_RX_TO_TX,"PDSCH to HARQ feedback time (%d) cannot be less than DURATION_RX_TO_TX (%d).\n", + 1+dci->pdsch_to_harq_feedback_timing_indicator.val,DURATION_RX_TO_TX); + // set the harq status at MAC for feedback set_harq_status(mac,dci->pucch_resource_indicator, dci->harq_pid, @@ -1232,14 +1236,17 @@ int8_t nr_ue_process_dci(module_id_t module_id, int cc_id, uint8_t gNB_index, fr uint8_t feedback_ti = ubwpd->pucch_Config->choice.setup->dl_DataToUL_ACK->list.array[dci->pdsch_to_harq_feedback_timing_indicator.val][0]; - // set the harq status at MAC for feedback - set_harq_status(mac,dci->pucch_resource_indicator, - dci->harq_pid, - dlsch_config_pdu_1_1->accumulated_delta_PUCCH, - feedback_ti, - dci->dai[0].val, - dci_ind->n_CCE,dci_ind->N_CCE,0, - frame,slot); + AssertFatal(feedback_ti>=DURATION_RX_TO_TX,"PDSCH to HARQ feedback time (%d) cannot be less than DURATION_RX_TO_TX (%d). Min feedback time set in config file (min_rxtxtime).\n", + feedback_ti,DURATION_RX_TO_TX); + + // set the harq status at MAC for feedback + set_harq_status(mac,dci->pucch_resource_indicator, + dci->harq_pid, + dlsch_config_pdu_1_1->accumulated_delta_PUCCH, + feedback_ti, + dci->dai[0].val, + dci_ind->n_CCE,dci_ind->N_CCE, + 0, frame,slot); dl_config->dl_config_list[dl_config->number_pdus].pdu_type = FAPI_NR_DL_CONFIG_TYPE_DLSCH; LOG_D(MAC,"(nr_ue_procedures.c) pdu_type=%d\n\n",dl_config->dl_config_list[dl_config->number_pdus].pdu_type); @@ -1248,6 +1255,7 @@ int8_t nr_ue_process_dci(module_id_t module_id, int cc_id, uint8_t gNB_index, fr /* TODO same calculation for MCS table as done in UL */ dlsch_config_pdu_1_1->mcs_table = (pdsch_Config->mcs_Table) ? (*pdsch_Config->mcs_Table + 1) : 0; /*PTRS configuration */ + dlsch_config_pdu_1_1->pduBitmap = 0; if(pdsch_Config->dmrs_DownlinkForPDSCH_MappingTypeA->choice.setup->phaseTrackingRS != NULL) { valid_ptrs_setup = set_dl_ptrs_values(pdsch_Config->dmrs_DownlinkForPDSCH_MappingTypeA->choice.setup->phaseTrackingRS->choice.setup, dlsch_config_pdu_1_1->number_rbs, dlsch_config_pdu_1_1->mcs, dlsch_config_pdu_1_1->mcs_table, @@ -1326,27 +1334,10 @@ void set_harq_status(NR_UE_MAC_INST_t *mac, // FIXME k0 != 0 currently not taken into consideration current_harq->dl_frame = frame; current_harq->dl_slot = slot; + mac->nr_ue_emul_l1.active_harq_sfn_slot = NFAPI_SFNSLOT2HEX(frame, (slot + data_toul_fb)); - LOG_D(PHY,"Setting harq_status for harq_id %d, dl %d.%d\n",harq_id,frame,slot); -} - - -void update_harq_status(nr_downlink_indication_t *dl_info, int pdu_id) { - - NR_UE_MAC_INST_t *mac = get_mac_inst(dl_info->module_id); - uint8_t harq_pid = dl_info->rx_ind->rx_indication_body[pdu_id].pdsch_pdu.harq_pid; - NR_UE_HARQ_STATUS_t *current_harq = &mac->dl_harq_info[harq_pid]; - - if (current_harq->active) { - current_harq->ack = dl_info->rx_ind->rx_indication_body[pdu_id].pdsch_pdu.ack_nack; - current_harq->ack_received = true; - LOG_D(PHY,"Updating harq_status for harq_id %d,ack/nak %d\n",harq_pid,current_harq->ack); - - } - else { - //shouldn't get here - LOG_E(MAC, "Trying to process acknack for an inactive harq process (%d)\n", harq_pid); - } + LOG_D(NR_PHY,"Setting harq_status for harq_id %d, dl %d.%d, sched ul %d.%d\n", + harq_id, frame, slot, frame, (slot + data_toul_fb)); } @@ -2123,7 +2114,7 @@ uint8_t get_downlink_ack(NR_UE_MAC_INST_t *mac, uint32_t V_temp = 0; uint32_t V_temp2 = 0; int O_ACK = 0; - int o_ACK = 0; + uint8_t o_ACK = 0; int O_bit_number_cw0 = 0; int O_bit_number_cw1 = 0; @@ -2151,6 +2142,7 @@ uint8_t get_downlink_ack(NR_UE_MAC_INST_t *mac, } o_ACK = o_ACK | (ack_data[0][m] << O_bit_number_cw0); + LOG_D(MAC,"m %d bit number %d o_ACK %d\n",m,O_bit_number_cw0,o_ACK); } if (V_temp2 < V_temp) { @@ -2169,8 +2161,11 @@ uint8_t get_downlink_ack(NR_UE_MAC_INST_t *mac, return (0); } + reverse_n_bits(&o_ACK,number_harq_feedback); pucch->ack_payload = o_ACK; + LOG_D(MAC,"frame %d slot %d pucch acknack payload %d\n",frame,slot,o_ACK); + return(number_harq_feedback); } @@ -2845,7 +2840,7 @@ uint8_t nr_extract_dci_info(NR_UE_MAC_INST_t *mac, // check BWP id if (mac->DLbwp[0]) N_RB=NRRIV2BW(mac->DLbwp[0]->bwp_Common->genericParameters.locationAndBandwidth, MAX_BWP_SIZE); else N_RB=mac->type0_PDCCH_CSS_config.num_rbs; -; + // indicating a DL DCI format 1bit pos++; @@ -3172,10 +3167,10 @@ uint8_t nr_extract_dci_info(NR_UE_MAC_INST_t *mac, pos+=fsize; dci_pdu_rel15->frequency_domain_assignment.val = (*dci_pdu>>(dci_size-pos))&((1<<fsize)-1); - // Time domain assignment 4bit + // Time domain assignment //pos+=4; pos+=dci_pdu_rel15->time_domain_assignment.nbits; - dci_pdu_rel15->time_domain_assignment.val = (*dci_pdu>>(dci_size-pos))&0x3; + dci_pdu_rel15->time_domain_assignment.val = (*dci_pdu>>(dci_size-pos))&((1<<dci_pdu_rel15->time_domain_assignment.nbits)-1); // Not supported yet - skip for now // Frequency hopping flag – 1 bit @@ -3339,6 +3334,9 @@ void nr_ue_process_mac_pdu(nr_downlink_indication_t *dl_info, mac_subheader_len = 2; } + AssertFatal(pdu_len > mac_sdu_len, "The mac_sdu_len (%d) has an invalid size. PDU len = %d! \n", + mac_sdu_len, pdu_len); + // Check if it is a valid CCCH message, we get all 00's messages very often int i = 0; for(i=0; i<(mac_subheader_len+mac_sdu_len); i++) { @@ -3504,47 +3502,56 @@ void nr_ue_process_mac_pdu(nr_downlink_indication_t *dl_info, case DL_SCH_LCID_DCCH1: // check if LCID is valid at current time. default: - // check if LCID is valid at current time. - if(((NR_MAC_SUBHEADER_SHORT *)pduP)->F){ - //mac_sdu_len |= (uint16_t)(((NR_MAC_SUBHEADER_LONG *)pduP)->L2)<<8; - mac_subheader_len = 3; - mac_sdu_len = ((uint16_t)(((NR_MAC_SUBHEADER_LONG *) pduP)->L1 & 0x7f) << 8) - | ((uint16_t)((NR_MAC_SUBHEADER_LONG *) pduP)->L2 & 0xff); - - } else { - mac_sdu_len = (uint16_t)((NR_MAC_SUBHEADER_SHORT *)pduP)->L; - mac_subheader_len = 2; - } - - LOG_D(MAC, "[UE %d] Frame %d : DLSCH -> DL-DTCH %d (gNB %d, %d bytes)\n", module_idP, frameP, rx_lcid, gNB_index, mac_sdu_len); + { + // check if LCID is valid at current time. + if (pdu_len < sizeof(NR_MAC_SUBHEADER_SHORT)) + return; + NR_MAC_SUBHEADER_SHORT *shs = (NR_MAC_SUBHEADER_SHORT *)pduP; + if (shs->F) { + //mac_sdu_len |= (uint16_t)(((NR_MAC_SUBHEADER_LONG *)pduP)->L2)<<8; + mac_subheader_len = 3; + if (pdu_len < sizeof(NR_MAC_SUBHEADER_LONG)) + return; + NR_MAC_SUBHEADER_LONG *shl = (NR_MAC_SUBHEADER_LONG *)pduP; + mac_sdu_len = ((uint16_t)(shl->L1 & 0x7f) << 8) | (uint16_t)(shl->L2 & 0xff); + } else { + if (pdu_len < sizeof(NR_MAC_SUBHEADER_SHORT)) + return; + mac_sdu_len = (uint16_t)((NR_MAC_SUBHEADER_SHORT *)pduP)->L; + mac_subheader_len = 2; + } + + LOG_D(NR_MAC, "[UE %d] Frame %d : DLSCH -> DL-DTCH %d (gNB %d, %d bytes)\n", module_idP, frameP, rx_lcid, gNB_index, mac_sdu_len); + + #if defined(ENABLE_MAC_PAYLOAD_DEBUG) + LOG_T(MAC, "[UE %d] First 32 bytes of DLSCH : \n", module_idP); + + for (i = 0; i < 32; i++) + LOG_T(MAC, "%x.", (pduP + mac_subheader_len)[i]); + + LOG_T(MAC, "\n"); + #endif + + if (rx_lcid < NB_RB_MAX && rx_lcid >= DL_SCH_LCID_DCCH) { + + mac_rlc_data_ind(module_idP, + mac->crnti, + gNB_index, + frameP, + ENB_FLAG_NO, + MBMS_FLAG_NO, + rx_lcid, + (char *) (pduP + mac_subheader_len), + mac_sdu_len, + 1, + NULL); + } else { + LOG_E(MAC, "[UE %d] Frame %d : unknown LCID %d (gNB %d)\n", module_idP, frameP, rx_lcid, gNB_index); + } - #if defined(ENABLE_MAC_PAYLOAD_DEBUG) - LOG_T(MAC, "[UE %d] First 32 bytes of DLSCH : \n", module_idP); - for (i = 0; i < 32; i++) - LOG_T(MAC, "%x.", (pduP + mac_subheader_len)[i]); - - LOG_T(MAC, "\n"); - #endif - - if (rx_lcid < NB_RB_MAX && rx_lcid >= DL_SCH_LCID_DCCH) { - - mac_rlc_data_ind(module_idP, - mac->crnti, - gNB_index, - frameP, - ENB_FLAG_NO, - MBMS_FLAG_NO, - rx_lcid, - (char *) (pduP + mac_subheader_len), - mac_sdu_len, - 1, - NULL); - } else { - LOG_E(MAC, "[UE %d] Frame %d : unknown LCID %d (gNB %d)\n", module_idP, frameP, rx_lcid, gNB_index); - } - - break; + break; + } } pduP += ( mac_subheader_len + mac_ce_len + mac_sdu_len ); pdu_len -= ( mac_subheader_len + mac_ce_len + mac_sdu_len ); @@ -3799,7 +3806,7 @@ int nr_ue_process_rar(nr_downlink_indication_t *dl_info, NR_UL_TIME_ALIGNMENT_t } } if (rarh->RAPID == preamble_index) { - LOG_I(NR_MAC, "[UE %d][RAPROC][%d.%d] Found RAR with the intended RAPID %d\n", mod_id, frame, slot, rarh->RAPID); + LOG_A(NR_MAC, "[UE %d][RAPROC][%d.%d] Found RAR with the intended RAPID %d\n", mod_id, frame, slot, rarh->RAPID); rar = (NR_MAC_RAR *) (dlsch_buffer + n_subheaders + (n_subPDUs - 1) * sizeof(NR_MAC_RAR)); ra->RA_RAPID_found = 1; break; @@ -3916,6 +3923,8 @@ int nr_ue_process_rar(nr_downlink_indication_t *dl_info, NR_UL_TIME_ALIGNMENT_t LOG_W(MAC, "In %s: ul_config request is NULL. Probably due to unexpected UL DCI in frame.slot %d.%d. Ignoring DCI!\n", __FUNCTION__, frame, slot); return -1; } + AssertFatal(ul_config->number_pdus < sizeof(ul_config->ul_config_list) / sizeof(ul_config->ul_config_list[0]), + "Number of PDUS in ul_config = %d > ul_config_list num elements", ul_config->number_pdus); // Upon successful reception, set the T-CRNTI to the RAR value if the RA preamble is selected among the contention-based RA Preambles if (!ra->cfra) { diff --git a/openair2/LAYER2/NR_MAC_UE/nr_ue_scheduler.c b/openair2/LAYER2/NR_MAC_UE/nr_ue_scheduler.c index c23d4bb0730061b99caeb096f15183d296330de9..44bd8f0ce35d5ba01e16771505c004e57aba1021 100644 --- a/openair2/LAYER2/NR_MAC_UE/nr_ue_scheduler.c +++ b/openair2/LAYER2/NR_MAC_UE/nr_ue_scheduler.c @@ -51,16 +51,32 @@ #include "assertions.h" #include "asn1_conversions.h" #include "SIMULATION/TOOLS/sim.h" // for taus +#include "utils.h" #include <executables/softmodem-common.h> #include "LAYER2/NR_MAC_COMMON/nr_mac_extern.h" +//#define SRS_DEBUG + static prach_association_pattern_t prach_assoc_pattern; static ssb_list_info_t ssb_list; void fill_ul_config(fapi_nr_ul_config_request_t *ul_config, frame_t frame_tx, int slot_tx, uint8_t pdu_type){ + + AssertFatal(ul_config->number_pdus < sizeof(ul_config->ul_config_list) / sizeof(ul_config->ul_config_list[0]), + "Number of PDUS in ul_config = %d > ul_config_list num elements", ul_config->number_pdus); + // clear ul_config for new frame/slot + if ((ul_config->slot != slot_tx || ul_config->sfn != frame_tx) && + ul_config->number_pdus != 0 && + !get_softmodem_params()->emulate_l1) { + LOG_D(MAC, "%d.%d %d.%d f clear ul_config %p t %d pdu %d\n", frame_tx, slot_tx, ul_config->sfn, ul_config->slot, ul_config, pdu_type, ul_config->number_pdus); + ul_config->number_pdus = 0; + memset(ul_config->ul_config_list, 0, sizeof(ul_config->ul_config_list)); + } ul_config->ul_config_list[ul_config->number_pdus].pdu_type = pdu_type; + //ul_config->slot = slot_tx; + //ul_config->sfn = frame_tx; ul_config->slot = slot_tx; ul_config->sfn = frame_tx; ul_config->number_pdus++; @@ -123,7 +139,7 @@ long get_k2(NR_UE_MAC_INST_t *mac, uint8_t time_domain_ind) { } AssertFatal(k2 >= DURATION_RX_TO_TX, - "Slot offset K2 (%ld) cannot be less than DURATION_RX_TO_TX (%d)\n", + "Slot offset K2 (%ld) cannot be less than DURATION_RX_TO_TX (%d). K2 set according to min_rxtxtime in config file.\n", k2,DURATION_RX_TO_TX); LOG_D(NR_MAC, "get_k2(): k2 is %ld\n", k2); @@ -160,6 +176,8 @@ fapi_nr_ul_config_request_t *get_ul_config_request(NR_UE_MAC_INST_t *mac, int sl num_slots_ul, index); + if(!mac->ul_config_request) + return NULL; return &mac->ul_config_request[index]; } @@ -878,6 +896,133 @@ int nr_config_pusch_pdu(NR_UE_MAC_INST_t *mac, } +// Periodic SRS scheduling +bool nr_ue_periodic_srs_scheduling(module_id_t mod_id, frame_t frame, slot_t slot) { + + bool srs_scheduled = false; + + NR_UE_MAC_INST_t *mac = get_mac_inst(mod_id); + + NR_SRS_Config_t *srs_config = NULL; + if (mac->cg && + mac->cg->spCellConfig && + mac->cg->spCellConfig->spCellConfigDedicated && + mac->cg->spCellConfig->spCellConfigDedicated->uplinkConfig && + mac->cg->spCellConfig->spCellConfigDedicated->uplinkConfig->initialUplinkBWP) { + srs_config = mac->cg->spCellConfig->spCellConfigDedicated->uplinkConfig->initialUplinkBWP->srs_Config->choice.setup; + } else { + return false; + } + + for(int rs = 0; rs < srs_config->srs_ResourceSetToAddModList->list.count; rs++) { + + // Find periodic resource set + NR_SRS_ResourceSet_t *srs_resource_set = srs_config->srs_ResourceSetToAddModList->list.array[rs]; + if(srs_resource_set->resourceType.present != NR_SRS_ResourceSet__resourceType_PR_periodic) { + continue; + } + + // Find the corresponding srs resource + NR_SRS_Resource_t *srs_resource = NULL; + for(int r1 = 0; r1 < srs_resource_set->srs_ResourceIdList->list.count; r1++) { + for (int r2 = 0; r2 < srs_config->srs_ResourceToAddModList->list.count; r2++) { + if ((*srs_resource_set->srs_ResourceIdList->list.array[r1] == srs_config->srs_ResourceToAddModList->list.array[r2]->srs_ResourceId) && + (srs_config->srs_ResourceToAddModList->list.array[r2]->resourceType.present == NR_SRS_Resource__resourceType_PR_periodic)) { + srs_resource = srs_config->srs_ResourceToAddModList->list.array[r2]; + break; + } + } + } + + if(srs_resource == NULL) { + continue; + } + + NR_BWP_t ubwp = mac->ULbwp[0] ? + mac->ULbwp[0]->bwp_Common->genericParameters : + mac->scc_SIB->uplinkConfigCommon->initialUplinkBWP.genericParameters; + + uint16_t period = srs_period[srs_resource->resourceType.choice.periodic->periodicityAndOffset_p.present]; + uint16_t offset = get_nr_srs_offset(srs_resource->resourceType.choice.periodic->periodicityAndOffset_p); + + int n_slots_frame = nr_slots_per_frame[ubwp.subcarrierSpacing]; + + // Check if UE should transmit the SRS + if((frame*n_slots_frame+slot-offset)%period == 0) { + + fapi_nr_ul_config_request_t *ul_config = get_ul_config_request(mac, slot); + fapi_nr_ul_config_srs_pdu *srs_config_pdu = &ul_config->ul_config_list[ul_config->number_pdus].srs_config_pdu; + + srs_config_pdu->rnti = mac->crnti; + srs_config_pdu->handle = 0; + srs_config_pdu->bwp_size = NRRIV2BW(ubwp.locationAndBandwidth, MAX_BWP_SIZE);; + srs_config_pdu->bwp_start = NRRIV2PRBOFFSET(ubwp.locationAndBandwidth, MAX_BWP_SIZE);; + srs_config_pdu->subcarrier_spacing = ubwp.subcarrierSpacing; + srs_config_pdu->cyclic_prefix = 0; + srs_config_pdu->num_ant_ports = srs_resource->nrofSRS_Ports; + srs_config_pdu->num_symbols = srs_resource->resourceMapping.nrofSymbols; + srs_config_pdu->num_repetitions = srs_resource->resourceMapping.repetitionFactor; + srs_config_pdu->time_start_position = srs_resource->resourceMapping.startPosition; + srs_config_pdu->config_index = srs_resource->freqHopping.c_SRS; + srs_config_pdu->sequence_id = srs_resource->sequenceId; + srs_config_pdu->bandwidth_index = srs_resource->freqHopping.b_SRS; + srs_config_pdu->comb_size = srs_resource->transmissionComb.present - 1; + + switch(srs_resource->transmissionComb.present) { + case NR_SRS_Resource__transmissionComb_PR_n2: + srs_config_pdu->comb_offset = srs_resource->transmissionComb.choice.n2->combOffset_n2; + srs_config_pdu->cyclic_shift = srs_resource->transmissionComb.choice.n2->cyclicShift_n2; + break; + case NR_SRS_Resource__transmissionComb_PR_n4: + srs_config_pdu->comb_offset = srs_resource->transmissionComb.choice.n4->combOffset_n4; + srs_config_pdu->cyclic_shift = srs_resource->transmissionComb.choice.n4->cyclicShift_n4; + break; + default: + LOG_W(NR_MAC, "Invalid or not implemented comb_size!\n"); + } + + srs_config_pdu->frequency_position = srs_resource->freqDomainPosition; + srs_config_pdu->frequency_shift = srs_resource->freqDomainShift; + srs_config_pdu->frequency_hopping = srs_resource->freqHopping.b_hop; + srs_config_pdu->group_or_sequence_hopping = srs_resource->groupOrSequenceHopping; + srs_config_pdu->resource_type = srs_resource->resourceType.present - 1; + srs_config_pdu->t_srs = period; + srs_config_pdu->t_offset = offset; + +#ifdef SRS_DEBUG + LOG_I(NR_MAC,"Frame = %i, slot = %i\n", frame, slot); + LOG_I(NR_MAC,"srs_config_pdu->rnti = 0x%04x\n", srs_config_pdu->rnti); + LOG_I(NR_MAC,"srs_config_pdu->handle = %u\n", srs_config_pdu->handle); + LOG_I(NR_MAC,"srs_config_pdu->bwp_size = %u\n", srs_config_pdu->bwp_size); + LOG_I(NR_MAC,"srs_config_pdu->bwp_start = %u\n", srs_config_pdu->bwp_start); + LOG_I(NR_MAC,"srs_config_pdu->subcarrier_spacing = %u\n", srs_config_pdu->subcarrier_spacing); + LOG_I(NR_MAC,"srs_config_pdu->cyclic_prefix = %u (0: Normal; 1: Extended)\n", srs_config_pdu->cyclic_prefix); + LOG_I(NR_MAC,"srs_config_pdu->num_ant_ports = %u (0 = 1 port, 1 = 2 ports, 2 = 4 ports)\n", srs_config_pdu->num_ant_ports); + LOG_I(NR_MAC,"srs_config_pdu->num_symbols = %u (0 = 1 symbol, 1 = 2 symbols, 2 = 4 symbols)\n", srs_config_pdu->num_symbols); + LOG_I(NR_MAC,"srs_config_pdu->num_repetitions = %u (0 = 1, 1 = 2, 2 = 4)\n", srs_config_pdu->num_repetitions); + LOG_I(NR_MAC,"srs_config_pdu->time_start_position = %u\n", srs_config_pdu->time_start_position); + LOG_I(NR_MAC,"srs_config_pdu->config_index = %u\n", srs_config_pdu->config_index); + LOG_I(NR_MAC,"srs_config_pdu->sequence_id = %u\n", srs_config_pdu->sequence_id); + LOG_I(NR_MAC,"srs_config_pdu->bandwidth_index = %u\n", srs_config_pdu->bandwidth_index); + LOG_I(NR_MAC,"srs_config_pdu->comb_size = %u (0 = comb size 2, 1 = comb size 4, 2 = comb size 8)\n", srs_config_pdu->comb_size); + LOG_I(NR_MAC,"srs_config_pdu->comb_offset = %u\n", srs_config_pdu->comb_offset); + LOG_I(NR_MAC,"srs_config_pdu->cyclic_shift = %u\n", srs_config_pdu->cyclic_shift); + LOG_I(NR_MAC,"srs_config_pdu->frequency_position = %u\n", srs_config_pdu->frequency_position); + LOG_I(NR_MAC,"srs_config_pdu->frequency_shift = %u\n", srs_config_pdu->frequency_shift); + LOG_I(NR_MAC,"srs_config_pdu->frequency_hopping = %u\n", srs_config_pdu->frequency_hopping); + LOG_I(NR_MAC,"srs_config_pdu->group_or_sequence_hopping = %u (0 = No hopping, 1 = Group hopping groupOrSequenceHopping, 2 = Sequence hopping)\n", srs_config_pdu->group_or_sequence_hopping); + LOG_I(NR_MAC,"srs_config_pdu->resource_type = %u (0: aperiodic, 1: semi-persistent, 2: periodic)\n", srs_config_pdu->resource_type); + LOG_I(NR_MAC,"srs_config_pdu->t_srs = %u\n", srs_config_pdu->t_srs); + LOG_I(NR_MAC,"srs_config_pdu->t_offset = %u\n", srs_config_pdu->t_offset); +#endif + + fill_ul_config(ul_config, frame, slot, FAPI_NR_UL_CONFIG_TYPE_SRS); + srs_scheduled = true; + } + } + return srs_scheduled; +} + // Performs : // 1. TODO: Call RRC for link status return to PHY // 2. TODO: Perform SR/BSR procedures for scheduling feedback @@ -906,6 +1051,7 @@ NR_UE_L2_STATE_t nr_ue_scheduler(nr_downlink_indication_t *dl_info, nr_uplink_in dcireq.slot = rx_slot; dcireq.dl_config_req.number_pdus = 0; nr_ue_dcireq(&dcireq); //to be replaced with function pointer later + mac->dl_config_request = dcireq.dl_config_req; fill_scheduled_response(&scheduled_response, &dcireq.dl_config_req, NULL, NULL, mod_id, cc_id, rx_frame, rx_slot, dl_info->thread_id); if(mac->if_module != NULL && mac->if_module->scheduled_response != NULL) @@ -931,8 +1077,8 @@ NR_UE_L2_STATE_t nr_ue_scheduler(nr_downlink_indication_t *dl_info, nr_uplink_in } else if (ul_info) { int cc_id = ul_info->cc_id; - frame_t rx_frame = ul_info->frame_rx; - slot_t rx_slot = ul_info->slot_rx; + //frame_t rx_frame = ul_info->frame_rx; + //slot_t rx_slot = ul_info->slot_rx; frame_t frame_tx = ul_info->frame_tx; slot_t slot_tx = ul_info->slot_tx; module_id_t mod_id = ul_info->module_id; @@ -942,6 +1088,12 @@ NR_UE_L2_STATE_t nr_ue_scheduler(nr_downlink_indication_t *dl_info, nr_uplink_in RA_config_t *ra = &mac->ra; fapi_nr_ul_config_request_t *ul_config = get_ul_config_request(mac, slot_tx); + if (!ul_config) { + LOG_E(NR_MAC, "mac->ul_config is null!\n"); + } + + // Periodic SRS scheduling + nr_ue_periodic_srs_scheduling(mod_id, frame_tx, slot_tx); // Schedule ULSCH only if the current frame and slot match those in ul_config_req // AND if a UL grant (UL DCI or Msg3) has been received (as indicated by num_pdus) @@ -954,6 +1106,8 @@ NR_UE_L2_STATE_t nr_ue_scheduler(nr_downlink_indication_t *dl_info, nr_uplink_in uint8_t ulsch_input_buffer_array[NFAPI_MAX_NUM_UL_PDU][MAX_ULSCH_PAYLOAD_BYTES]; nr_scheduled_response_t scheduled_response; fapi_nr_tx_request_t tx_req; + //tx_req.slot = slot_tx; + //tx_req.sfn = frame_tx; tx_req.slot = slot_tx; tx_req.sfn = frame_tx; tx_req.number_of_pdus = 0; @@ -1013,14 +1167,14 @@ NR_UE_L2_STATE_t nr_ue_scheduler(nr_downlink_indication_t *dl_info, nr_uplink_in nr_Msg3_transmitted(ul_info->module_id, ul_info->cc_id, ul_info->frame_tx, ul_info->slot_tx, ul_info->gNB_index); } if (ra->ra_state == WAIT_RAR && !ra->cfra){ - LOG_I(NR_MAC,"[RAPROC][%d.%d] RA-Msg3 transmitted\n", frame_tx, slot_tx); + LOG_A(NR_MAC, "[RAPROC][%d.%d] RA-Msg3 transmitted\n", frame_tx, slot_tx); nr_Msg3_transmitted(ul_info->module_id, ul_info->cc_id, ul_info->frame_tx, ul_info->slot_tx, ul_info->gNB_index); } } } pthread_mutex_unlock(&ul_config->mutex_ul_config); // avoid double lock - fill_scheduled_response(&scheduled_response, NULL, ul_config, &tx_req, mod_id, cc_id, rx_frame, rx_slot, ul_info->thread_id); + fill_scheduled_response(&scheduled_response, NULL, ul_config, &tx_req, mod_id, cc_id, frame_tx, slot_tx, ul_info->thread_id); if(mac->if_module != NULL && mac->if_module->scheduled_response != NULL){ mac->if_module->scheduled_response(&scheduled_response); } @@ -1031,7 +1185,7 @@ NR_UE_L2_STATE_t nr_ue_scheduler(nr_downlink_indication_t *dl_info, nr_uplink_in } if (dl_info) { - return (CONNECTION_OK); + return (UE_CONNECTION_OK); } module_id_t mod_id = ul_info->module_id; frame_t txFrameP = ul_info->frame_tx; @@ -2153,7 +2307,8 @@ void nr_ue_pucch_scheduler(module_id_t module_idP, frame_t frameP, int slotP, in if (N_UCI > 0) { - pucch->resource_set_id = find_pucch_resource_set(mac, N_UCI); + LOG_D(NR_MAC,"%d.%d configure pucch, O_SR %d, O_ACK %d, O_CSI %d\n",frameP,slotP,O_SR,O_ACK,O_CSI); + pucch->resource_set_id = find_pucch_resource_set(mac, O_ACK + O_CSI); select_pucch_resource(mac, pucch); fapi_nr_ul_config_request_t *ul_config = get_ul_config_request(mac, slotP); pthread_mutex_lock(&ul_config->mutex_ul_config); @@ -2190,9 +2345,12 @@ void nr_ue_prach_scheduler(module_id_t module_idP, frame_t frameP, sub_frame_t s NR_UE_MAC_INST_t *mac = get_mac_inst(module_idP); RA_config_t *ra = &mac->ra; + fapi_nr_ul_config_request_t *ul_config = get_ul_config_request(mac, slotP); + if (!ul_config) { + LOG_E(NR_MAC, "mac->ul_config is null! \n"); + return; + } - //fapi_nr_ul_config_request_t *ul_config = get_ul_config_request(mac, slotP); - fapi_nr_ul_config_request_t *ul_config = &mac->ul_config_request[0]; fapi_nr_ul_config_prach_pdu *prach_config_pdu; fapi_nr_config_request_t *cfg = &mac->phy_config.config_req; fapi_nr_prach_config_t *prach_config = &cfg->prach_config; @@ -2229,11 +2387,13 @@ void nr_ue_prach_scheduler(module_id_t module_idP, frame_t frameP, sub_frame_t s format = prach_occasion_info_p->format; format0 = format & 0xff; // single PRACH format format1 = (format >> 8) & 0xff; // dual PRACH format + AssertFatal(ul_config->number_pdus < sizeof(ul_config->ul_config_list) / sizeof(ul_config->ul_config_list[0]), + "Number of PDUS in ul_config = %d > ul_config_list num elements", ul_config->number_pdus); pthread_mutex_lock(&ul_config->mutex_ul_config); AssertFatal(ul_config->number_pdus<FAPI_NR_UL_CONFIG_LIST_NUM, "ul_config->number_pdus %d out of bounds\n",ul_config->number_pdus); prach_config_pdu = &ul_config->ul_config_list[ul_config->number_pdus].prach_config_pdu; - + memset(prach_config_pdu, 0, sizeof(fapi_nr_ul_config_prach_pdu)); fill_ul_config(ul_config, frameP, slotP, FAPI_NR_UL_CONFIG_TYPE_PRACH); pthread_mutex_unlock(&ul_config->mutex_ul_config); LOG_D(PHY, "In %s: (%p) %d UL PDUs:\n", __FUNCTION__, ul_config, ul_config->number_pdus); diff --git a/openair2/LAYER2/NR_MAC_gNB/config.c b/openair2/LAYER2/NR_MAC_gNB/config.c index 4687f6aeeadbf9e3b26c2e27b4c0cdb8ac6be1f2..64cc7fe9606350b6810978f3779b69e75bd9d20c 100644 --- a/openair2/LAYER2/NR_MAC_gNB/config.c +++ b/openair2/LAYER2/NR_MAC_gNB/config.c @@ -518,12 +518,13 @@ int rrc_mac_config_req_gNB(module_id_t Mod_idP, NR_COMMON_channels_t *cc = &RC.nrmac[Mod_idP]->common_channels[0]; RC.nrmac[Mod_idP]->sib1_tda = sib1_tda; for (int n=0;n<NR_NB_RA_PROC_MAX;n++ ) { - cc->ra[n].cfra = false; - cc->ra[n].rnti = 0; - cc->ra[n].preambles.num_preambles = MAX_NUM_NR_PRACH_PREAMBLES; - cc->ra[n].preambles.preamble_list = (uint8_t *) malloc(MAX_NUM_NR_PRACH_PREAMBLES*sizeof(uint8_t)); - for (int i = 0; i < MAX_NUM_NR_PRACH_PREAMBLES; i++) - cc->ra[n].preambles.preamble_list[i] = i; + cc->ra[n].cfra = false; + cc->ra[n].msg3_dcch_dtch = false; + cc->ra[n].rnti = 0; + cc->ra[n].preambles.num_preambles = MAX_NUM_NR_PRACH_PREAMBLES; + cc->ra[n].preambles.preamble_list = (uint8_t *) malloc(MAX_NUM_NR_PRACH_PREAMBLES*sizeof(uint8_t)); + for (int i = 0; i < MAX_NUM_NR_PRACH_PREAMBLES; i++) + cc->ra[n].preambles.preamble_list[i] = i; } } } @@ -533,7 +534,6 @@ int rrc_mac_config_req_gNB(module_id_t Mod_idP, if (CellGroup) { const NR_ServingCellConfig_t *servingCellConfig = CellGroup->spCellConfig->spCellConfigDedicated; - const struct NR_ServingCellConfig__downlinkBWP_ToAddModList *bwpList = servingCellConfig->downlinkBWP_ToAddModList; if(bwpList) { AssertFatal(bwpList->list.count > 0, "downlinkBWP_ToAddModList has no BWPs!\n"); @@ -601,8 +601,10 @@ int rrc_mac_config_req_gNB(module_id_t Mod_idP, for (int i = 0; i < MAX_NUM_NR_PRACH_PREAMBLES; i++) ra->preambles.preamble_list[i] = i; } + ra->msg3_dcch_dtch = false; LOG_I(NR_MAC,"Added new RA process for UE RNTI %04x with initial CellGroup\n", rnti); } else { // CellGroup has been updated + NR_ServingCellConfigCommon_t *scc = RC.nrmac[Mod_idP]->common_channels[0].ServingCellConfigCommon; const int UE_id = find_nr_UE_id(Mod_idP,rnti); int target_ss; UE_info->CellGroup[UE_id] = CellGroup; @@ -623,19 +625,30 @@ int rrc_mac_config_req_gNB(module_id_t Mod_idP, } // update coreset/searchspace void *bwpd = NULL; + NR_BWP_t *genericParameters = NULL; target_ss = NR_SearchSpace__searchSpaceType_PR_common; if ((sched_ctrl->active_bwp)) { target_ss = NR_SearchSpace__searchSpaceType_PR_ue_Specific; bwpd = (void*)sched_ctrl->active_bwp->bwp_Dedicated; + genericParameters = &sched_ctrl->active_bwp->bwp_Common->genericParameters; } else if (CellGroup->spCellConfig && CellGroup->spCellConfig->spCellConfigDedicated && (CellGroup->spCellConfig->spCellConfigDedicated->initialDownlinkBWP)) { target_ss = NR_SearchSpace__searchSpaceType_PR_ue_Specific; bwpd = (void*)CellGroup->spCellConfig->spCellConfigDedicated->initialDownlinkBWP; + genericParameters = &scc->downlinkConfigCommon->initialDownlinkBWP->genericParameters; } + else + AssertFatal(1==0,"Either initial BWP or active BWP should always be present\n"); sched_ctrl->search_space = get_searchspace(scc, bwpd, target_ss); sched_ctrl->coreset = get_coreset(Mod_idP, scc, bwpd, sched_ctrl->search_space, target_ss); + sched_ctrl->sched_pdcch = set_pdcch_structure(RC.nrmac[Mod_idP], + sched_ctrl->search_space, + sched_ctrl->coreset, + scc, + genericParameters, + NULL); sched_ctrl->maxL = 2; } } diff --git a/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler.c b/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler.c index c1f3196d2a8d9faa4eefb18571777f9563475f19..ba854608c53613889398c9d6fae85cc0f5070127 100644 --- a/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler.c +++ b/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler.c @@ -55,6 +55,7 @@ #include <errno.h> #include <string.h> +const uint8_t nr_rv_round_map[4] = { 0, 2, 3, 1 }; uint16_t nr_pdcch_order_table[6] = { 31, 31, 511, 2047, 2047, 8191 }; uint8_t vnf_first_sched_entry = 1; @@ -67,7 +68,7 @@ void clear_nr_nfapi_information(gNB_MAC_INST * gNB, const int num_slots = nr_slots_per_frame[*scc->ssbSubcarrierSpacing]; nfapi_nr_dl_tti_request_t *DL_req = &gNB->DL_req[0]; - nfapi_nr_dl_tti_pdcch_pdu_rel15_t ***pdcch = (nfapi_nr_dl_tti_pdcch_pdu_rel15_t ***)gNB->pdcch_pdu_idx[CC_idP]; + nfapi_nr_dl_tti_pdcch_pdu_rel15_t **pdcch = (nfapi_nr_dl_tti_pdcch_pdu_rel15_t **)gNB->pdcch_pdu_idx[CC_idP]; nfapi_nr_ul_tti_request_t *future_ul_tti_req = &gNB->UL_tti_req_ahead[CC_idP][(slotP + num_slots - 1) % num_slots]; nfapi_nr_ul_dci_request_t *UL_dci_req = &gNB->UL_dci_req[0]; @@ -80,7 +81,7 @@ void clear_nr_nfapi_information(gNB_MAC_INST * gNB, DL_req[CC_idP].dl_tti_request_body.nPDUs = 0; DL_req[CC_idP].dl_tti_request_body.nGroup = 0; //DL_req[CC_idP].dl_tti_request_body.transmission_power_pcfich = 6000; - memset(pdcch, 0, sizeof(**pdcch) * MAX_NUM_BWP * MAX_NUM_CORESET); + memset(pdcch, 0, sizeof(*pdcch) * MAX_NUM_CORESET); UL_dci_req[CC_idP].SFN = frameP; UL_dci_req[CC_idP].Slot = slotP; @@ -276,7 +277,6 @@ void gNB_dlsch_ulsch_scheduler(module_id_t module_idP, protocol_ctxt_t ctxt={0}; PROTOCOL_CTXT_SET_BY_MODULE_ID(&ctxt, module_idP, ENB_FLAG_YES, NOT_A_RNTI, frame, slot,module_idP); - const int bwp_id = 1; char stats_output[16384]; gNB_MAC_INST *gNB = RC.nrmac[module_idP]; @@ -307,13 +307,8 @@ void gNB_dlsch_ulsch_scheduler(module_id_t module_idP, nr_rrc_trigger(&ctxt, 0 /*CC_id*/, frame, slot >> *scc->ssbSubcarrierSpacing); } - memset(RC.nrmac[module_idP]->cce_list[0][0],0,MAX_NUM_CCE*sizeof(int)); // coreset0 - memset(RC.nrmac[module_idP]->cce_list[0][1],0,MAX_NUM_CCE*sizeof(int)); // coreset1 on initialBWP - memset(RC.nrmac[module_idP]->cce_list[bwp_id][1],0,MAX_NUM_CCE*sizeof(int)); // coresetid 1 - NR_UE_info_t *UE_info = &RC.nrmac[module_idP]->UE_info; - for (int UE_id = UE_info->list.head; UE_id >= 0; UE_id = UE_info->list.next[UE_id]) - for (int i=0; i<MAX_NUM_CORESET; i++) - UE_info->num_pdcch_cand[UE_id][i] = 0; + for (int i=0; i<MAX_NUM_CORESET; i++) + RC.nrmac[module_idP]->pdcch_cand[i] = 0; for (int CC_id = 0; CC_id < MAX_NUM_CCs; CC_id++) { //mbsfn_status[CC_id] = 0; @@ -373,7 +368,7 @@ void gNB_dlsch_ulsch_scheduler(module_id_t module_idP, schedule_nr_prach(module_idP, f, s); } - // This schedule SR + // This schedule SR nr_sr_reporting(module_idP, frame, slot); // Schedule CSI-RS transmission @@ -383,6 +378,10 @@ void gNB_dlsch_ulsch_scheduler(module_id_t module_idP, if (slot == 0) nr_csi_meas_reporting(module_idP, frame, slot); + // Schedule SRS: check in slot 0 for the whole frame + if (slot == 0) + nr_schedule_srs(module_idP, frame); + // This schedule RA procedure if not in phy_test mode // Otherwise already consider 5G already connected if (get_softmodem_params()->phy_test == 0) { diff --git a/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_RA.c b/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_RA.c index 6ac7f3f82e97ff35ee93c2f10cb543ee4779cc0c..4261020f767b3ac7746cfa57aa49a1eaf50b2926 100644 --- a/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_RA.c +++ b/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_RA.c @@ -519,10 +519,16 @@ void nr_initiate_ra_proc(module_id_t module_idP, for (int i = 0; i < NR_NB_RA_PROC_MAX; i++) { NR_RA_t *ra = &cc->ra[i]; pr_found = 0; + const int UE_id = find_nr_UE_id(module_idP, ra->rnti); + if (UE_id != -1) { + continue; + } if (ra->state == RA_IDLE) { for(int j = 0; j < ra->preambles.num_preambles; j++) { //check if the preamble received correspond to one of the listed or configured preambles if (preamble_index == ra->preambles.preamble_list[j]) { + if (ra->rnti == 0 && get_softmodem_params()->nsa) + continue; pr_found=1; break; } @@ -581,12 +587,15 @@ void nr_initiate_ra_proc(module_id_t module_idP, NR_SearchSpaceId_t ra_SearchSpace = 0; struct NR_PDCCH_ConfigCommon__commonSearchSpaceList *commonSearchSpaceList = NULL; + NR_BWP_t *genericParameters = NULL; if(bwp) { commonSearchSpaceList = bwp->bwp_Common->pdcch_ConfigCommon->choice.setup->commonSearchSpaceList; ra_SearchSpace = *bwp->bwp_Common->pdcch_ConfigCommon->choice.setup->ra_SearchSpace; + genericParameters = &bwp->bwp_Common->genericParameters; } else { commonSearchSpaceList = scc->downlinkConfigCommon->initialDownlinkBWP->pdcch_ConfigCommon->choice.setup->commonSearchSpaceList; ra_SearchSpace = *scc->downlinkConfigCommon->initialDownlinkBWP->pdcch_ConfigCommon->choice.setup->ra_SearchSpace; + genericParameters = &scc->downlinkConfigCommon->initialDownlinkBWP->genericParameters; } AssertFatal(commonSearchSpaceList->list.count > 0, "common SearchSpace list has 0 elements\n"); @@ -599,6 +608,14 @@ void nr_initiate_ra_proc(module_id_t module_idP, AssertFatal(ra->ra_ss!=NULL,"SearchSpace cannot be null for RA\n"); + ra->coreset = get_coreset(module_idP, scc, bwp, ra->ra_ss, NR_SearchSpace__searchSpaceType_PR_common); + ra->sched_pdcch = set_pdcch_structure(nr_mac, + ra->ra_ss, + ra->coreset, + scc, + genericParameters, + NULL); + // retrieving ra pdcch monitoring period and offset find_monitoring_periodicity_offset_common(ra->ra_ss, &monitoring_slot_period, &monitoring_offset); @@ -636,16 +653,17 @@ void nr_initiate_ra_proc(module_id_t module_idP, ra->preamble_index = preamble_index; ra->beam_id = beam_index; - LOG_D(NR_MAC, + LOG_I(NR_MAC, "[gNB %d][RAPROC] CC_id %d Frame %d Activating Msg2 generation in frame %d, slot %d using RA rnti %x SSB " - "index %u\n", + "index %u RA index %d\n", module_idP, CC_id, frameP, ra->Msg2_frame, ra->Msg2_slot, ra->RA_rnti, - cc->ssb_index[beam_index]); + cc->ssb_index[beam_index], + i); return; } @@ -774,13 +792,13 @@ void nr_generate_Msg3_retransmission(module_id_t module_idP, int CC_id, frame_t // generation of DCI 0_0 to schedule msg3 retransmission NR_SearchSpace_t *ss = ra->ra_ss; - NR_ControlResourceSet_t *coreset = get_coreset(module_idP, scc, NULL, ss, NR_SearchSpace__searchSpaceType_PR_common); + NR_ControlResourceSet_t *coreset = ra->coreset; AssertFatal(coreset!=NULL,"Coreset cannot be null for RA-Msg3 retransmission\n"); nfapi_nr_ul_dci_request_t *ul_dci_req = &nr_mac->UL_dci_req[CC_id]; const int coresetid = coreset->controlResourceSetId; - nfapi_nr_dl_tti_pdcch_pdu_rel15_t *pdcch_pdu_rel15 = nr_mac->pdcch_pdu_idx[CC_id][ra->bwp_id][coresetid]; + nfapi_nr_dl_tti_pdcch_pdu_rel15_t *pdcch_pdu_rel15 = nr_mac->pdcch_pdu_idx[CC_id][coresetid]; if (!pdcch_pdu_rel15) { nfapi_nr_ul_dci_request_pdus_t *ul_dci_request_pdu = &ul_dci_req->ul_dci_pdu_list[ul_dci_req->numPdus]; memset(ul_dci_request_pdu, 0, sizeof(nfapi_nr_ul_dci_request_pdus_t)); @@ -788,8 +806,8 @@ void nr_generate_Msg3_retransmission(module_id_t module_idP, int CC_id, frame_t ul_dci_request_pdu->PDUSize = (uint8_t)(2+sizeof(nfapi_nr_dl_tti_pdcch_pdu)); pdcch_pdu_rel15 = &ul_dci_request_pdu->pdcch_pdu.pdcch_pdu_rel15; ul_dci_req->numPdus += 1; - nr_configure_pdcch(nr_mac, pdcch_pdu_rel15, ss, coreset, scc, genericParameters, NULL); - nr_mac->pdcch_pdu_idx[CC_id][ra->bwp_id][coresetid] = pdcch_pdu_rel15; + nr_configure_pdcch(pdcch_pdu_rel15, coreset, genericParameters, &ra->sched_pdcch); + nr_mac->pdcch_pdu_idx[CC_id][coresetid] = pdcch_pdu_rel15; } uint8_t aggregation_level; @@ -800,9 +818,15 @@ void nr_generate_Msg3_retransmission(module_id_t module_idP, int CC_id, frame_t if(nr_of_candidates>0) break; } AssertFatal(nr_of_candidates>0,"nr_of_candidates is 0\n"); - int CCEIndex = allocate_nr_CCEs(nr_mac, NULL, coreset, aggregation_level, 0, 0, nr_of_candidates); + int CCEIndex = find_pdcch_candidate(nr_mac, + CC_id, + aggregation_level, + nr_of_candidates, + &ra->sched_pdcch, + coreset, + 0); if (CCEIndex < 0) { - LOG_E(NR_MAC, "%s(): cannot find free CCE for RA RNTI %04x!\n", __func__, ra->rnti); + LOG_E(NR_MAC, "%s(): cannot find free CCE for RA RNTI 0x%04x!\n", __func__, ra->rnti); return; } @@ -841,6 +865,13 @@ void nr_generate_Msg3_retransmission(module_id_t module_idP, int CC_id, frame_t ra->bwp_id); // Mark the corresponding RBs as used + + fill_pdcch_vrb_map(nr_mac, + CC_id, + &ra->sched_pdcch, + CCEIndex, + aggregation_level); + for (int rb = 0; rb < ra->msg3_nb_rb; rb++) { vrb_map_UL[rbStart + BWPStart + rb] = 1; } @@ -870,9 +901,6 @@ void nr_get_Msg3alloc(module_id_t module_id, int mu = ubwp ? ubwp->bwp_Common->genericParameters.subcarrierSpacing : scc->uplinkConfigCommon->initialUplinkBWP->genericParameters.subcarrierSpacing; - int StartSymbolIndex = 0; - int NrOfSymbols = 0; - int startSymbolAndLength = 0; int temp_slot = 0; ra->Msg3_tda_id = 16; // initialization to a value above limit @@ -881,20 +909,29 @@ void nr_get_Msg3alloc(module_id_t module_id, scc->uplinkConfigCommon->initialUplinkBWP->pusch_ConfigCommon->choice.setup->pusch_TimeDomainAllocationList; uint8_t k2 = 0; - for (int i=0; i<pusch_TimeDomainAllocationList->list.count; i++) { - startSymbolAndLength = pusch_TimeDomainAllocationList->list.array[i]->startSymbolAndLength; - SLIV2SL(startSymbolAndLength, &StartSymbolIndex, &NrOfSymbols); - // we want to transmit in the uplink symbols of mixed slot - if (NrOfSymbols == scc->tdd_UL_DL_ConfigurationCommon->pattern1.nrofUplinkSymbols) { + lte_frame_type_t frame_type = get_frame_type(*scc->downlinkConfigCommon->frequencyInfoDL->frequencyBandList.list.array[0], *scc->ssbSubcarrierSpacing); + if (frame_type == TDD) { + int nb_periods_per_frame = get_nb_periods_per_frame(scc->tdd_UL_DL_ConfigurationCommon->pattern1.dl_UL_TransmissionPeriodicity); + int nb_slots_per_period = ((1<<mu)*10)/nb_periods_per_frame; + for (int i=0; i<pusch_TimeDomainAllocationList->list.count; i++) { k2 = *pusch_TimeDomainAllocationList->list.array[i]->k2; - temp_slot = current_slot + k2 + DELTA[mu]; // msg3 slot according to 8.3 in 38.213 - ra->Msg3_slot = temp_slot%nr_slots_per_frame[mu]; - if (is_xlsch_in_slot(RC.nrmac[module_id]->ulsch_slot_bitmap[ra->Msg3_slot / 64], ra->Msg3_slot)) { - ra->Msg3_tda_id = i; - break; + // we want to transmit in the uplink symbols of mixed slot + if ((k2 + DELTA[mu])%nb_slots_per_period == 0) { + temp_slot = current_slot + k2 + DELTA[mu]; // msg3 slot according to 8.3 in 38.213 + ra->Msg3_slot = temp_slot%nr_slots_per_frame[mu]; + if (is_xlsch_in_slot(RC.nrmac[module_id]->ulsch_slot_bitmap[ra->Msg3_slot / 64], ra->Msg3_slot)) { + ra->Msg3_tda_id = i; + break; + } } } } + else { + ra->Msg3_tda_id = 0; + k2 = *pusch_TimeDomainAllocationList->list.array[0]->k2; + temp_slot = current_slot + k2 + DELTA[mu]; // msg3 slot according to 8.3 in 38.213 + ra->Msg3_slot = temp_slot%nr_slots_per_frame[mu]; + } AssertFatal(ra->Msg3_tda_id<16,"Unable to find Msg3 time domain allocation in list\n"); @@ -915,7 +952,7 @@ void nr_get_Msg3alloc(module_id_t module_id, tdd_beam_association[num_tdd_period] = ra->beam_id; } - LOG_D(NR_MAC, "[RAPROC] Msg3 slot %d: current slot %u Msg3 frame %u k2 %u Msg3_tda_id %u start symbol index %u\n", ra->Msg3_slot, current_slot, ra->Msg3_frame, k2,ra->Msg3_tda_id, StartSymbolIndex); + LOG_D(NR_MAC, "[RAPROC] Msg3 slot %d: current slot %u Msg3 frame %u k2 %u Msg3_tda_id %u\n", ra->Msg3_slot, current_slot, ra->Msg3_frame, k2,ra->Msg3_tda_id); uint16_t *vrb_map_UL = &RC.nrmac[module_id]->common_channels[CC_id].vrb_map_UL[ra->Msg3_slot * MAX_BWP_SIZE]; @@ -972,7 +1009,7 @@ void fill_msg3_pusch_pdu(nfapi_nr_pusch_pdu_t *pusch_pdu, pusch_pdu->bwp_size = bwp_size; pusch_pdu->subcarrier_spacing = scs; pusch_pdu->cyclic_prefix = 0; - pusch_pdu->mcs_index = 0; + pusch_pdu->mcs_index = 1; pusch_pdu->mcs_table = 0; pusch_pdu->target_code_rate = nr_get_code_rate_ul(pusch_pdu->mcs_index,pusch_pdu->mcs_table); pusch_pdu->qam_mod_order = nr_get_Qm_ul(pusch_pdu->mcs_index,pusch_pdu->mcs_table); @@ -1009,11 +1046,14 @@ void fill_msg3_pusch_pdu(nfapi_nr_pusch_pdu_t *pusch_pdu, pusch_pdu->pusch_data.harq_process_id = 0; pusch_pdu->pusch_data.new_data_indicator = 1; pusch_pdu->pusch_data.num_cb = 0; + int num_dmrs_symb = 0; + for(int i = start_symbol_index; i < start_symbol_index+nr_of_symbols; i++) + num_dmrs_symb += (pusch_pdu->ul_dmrs_symb_pos >> i) & 1; pusch_pdu->pusch_data.tb_size = nr_compute_tbs(pusch_pdu->qam_mod_order, pusch_pdu->target_code_rate, pusch_pdu->rb_size, pusch_pdu->nr_of_symbols, - 12, // nb dmrs set for no data in dmrs symbol + num_dmrs_symb*12, // nb dmrs set for no data in dmrs symbol 0, //nb_rb_oh 0, // to verify tb scaling pusch_pdu->nrOfLayers)>>3; @@ -1074,7 +1114,7 @@ void nr_add_msg3(module_id_t module_idP, int CC_id, frame_t frameP, sub_frame_t fh = ubwp->bwp_Dedicated->pusch_Config->choice.setup->frequencyHopping ? 1 : 0; } - LOG_D(NR_MAC, "Frame %d, Subframe %d Adding Msg3 UL Config Request for (%d,%d) : (%d,%d,%d) for rnti: %d\n", + LOG_D(NR_MAC, "Frame %d, Slot %d Adding Msg3 UL Config Request for (%d,%d) : (%d,%d,%d) for rnti: %d\n", frameP, slotP, ra->Msg3_frame, @@ -1105,7 +1145,12 @@ void nr_generate_Msg2(module_id_t module_idP, int CC_id, frame_t frameP, sub_fra if ((ra->Msg2_frame == frameP) && (ra->Msg2_slot == slotP)) { - uint8_t time_domain_assignment = 1; + //TODO time domain assignment for msg2 needs to be improved + uint8_t time_domain_assignment; + if(cc->frame_type == TDD) + time_domain_assignment = 1; + else + time_domain_assignment = 0; uint8_t mcsIndex = 0; int rbStart = 0; int rbSize = 8; @@ -1144,13 +1189,19 @@ void nr_generate_Msg2(module_id_t module_idP, int CC_id, frame_t frameP, sub_fra BWPSize = type0_PDCCH_CSS_config->num_rbs; } - coreset = get_coreset(module_idP, scc, bwp, ss, NR_SearchSpace__searchSpaceType_PR_common); + // Calculate number of symbols + int startSymbolIndex, nrOfSymbols; + const int startSymbolAndLength = pdsch_TimeDomainAllocationList->list.array[time_domain_assignment]->startSymbolAndLength; + SLIV2SL(startSymbolAndLength, &startSymbolIndex, &nrOfSymbols); + AssertFatal(startSymbolIndex >= 0, "StartSymbolIndex is negative\n"); + + coreset = ra->coreset; AssertFatal(coreset!=NULL,"Coreset cannot be null for RA-Msg2\n"); uint16_t *vrb_map = cc[CC_id].vrb_map; for (int i = 0; (i < rbSize) && (rbStart <= (BWPSize - rbSize)); i++) { - if (vrb_map[BWPStart + rbStart + i]) { + if (vrb_map[BWPStart + rbStart + i]&SL_to_bitmap(startSymbolIndex, nrOfSymbols)) { rbStart += i; i = 0; } @@ -1176,18 +1227,20 @@ void nr_generate_Msg2(module_id_t module_idP, int CC_id, frame_t frameP, sub_fra if(nr_of_candidates>0) break; } AssertFatal(nr_of_candidates>0,"nr_of_candidates is 0\n"); - int CCEIndex = allocate_nr_CCEs(nr_mac, bwp, coreset, aggregation_level,0,0,nr_of_candidates); + + int CCEIndex = find_pdcch_candidate(nr_mac, + CC_id, + aggregation_level, + nr_of_candidates, + &ra->sched_pdcch, + coreset, + 0); + if (CCEIndex < 0) { - LOG_E(NR_MAC, "%s(): cannot find free CCE for RA RNTI %04x!\n", __func__, ra->rnti); + LOG_E(NR_MAC, "%s(): cannot find free CCE for RA RNTI 0x%04x!\n", __func__, ra->rnti); return; } - // Calculate number of symbols - int startSymbolIndex, nrOfSymbols; - const int startSymbolAndLength = pdsch_TimeDomainAllocationList->list.array[time_domain_assignment]->startSymbolAndLength; - SLIV2SL(startSymbolAndLength, &startSymbolIndex, &nrOfSymbols); - AssertFatal(startSymbolIndex >= 0, "StartSymbolIndex is negative\n"); - LOG_D(NR_MAC,"Msg2 startSymbolIndex.nrOfSymbols %d.%d\n",startSymbolIndex,nrOfSymbols); int mappingtype = pdsch_TimeDomainAllocationList->list.array[time_domain_assignment]->mappingType; @@ -1196,7 +1249,7 @@ void nr_generate_Msg2(module_id_t module_idP, int CC_id, frame_t frameP, sub_fra // important if we have multiple RAs, and the DLSCH has to reuse them, so we need to mark them const int bwpid = bwp ? bwp->bwp_Id : 0; const int coresetid = coreset->controlResourceSetId; - nfapi_nr_dl_tti_pdcch_pdu_rel15_t *pdcch_pdu_rel15 = nr_mac->pdcch_pdu_idx[CC_id][bwpid][coresetid]; + nfapi_nr_dl_tti_pdcch_pdu_rel15_t *pdcch_pdu_rel15 = nr_mac->pdcch_pdu_idx[CC_id][coresetid]; if (!pdcch_pdu_rel15) { nfapi_nr_dl_tti_request_pdu_t *dl_tti_pdcch_pdu = &dl_req->dl_tti_pdu_list[dl_req->nPDUs]; memset(dl_tti_pdcch_pdu, 0, sizeof(nfapi_nr_dl_tti_request_pdu_t)); @@ -1204,8 +1257,8 @@ void nr_generate_Msg2(module_id_t module_idP, int CC_id, frame_t frameP, sub_fra dl_tti_pdcch_pdu->PDUSize = (uint8_t)(2 + sizeof(nfapi_nr_dl_tti_pdcch_pdu)); dl_req->nPDUs += 1; pdcch_pdu_rel15 = &dl_tti_pdcch_pdu->pdcch_pdu.pdcch_pdu_rel15; - nr_configure_pdcch(nr_mac, pdcch_pdu_rel15, ss, coreset, scc, genericParameters, NULL); - nr_mac->pdcch_pdu_idx[CC_id][bwpid][coresetid] = pdcch_pdu_rel15; + nr_configure_pdcch(pdcch_pdu_rel15, coreset, genericParameters, &ra->sched_pdcch); + nr_mac->pdcch_pdu_idx[CC_id][coresetid] = pdcch_pdu_rel15; } nfapi_nr_dl_tti_request_pdu_t *dl_tti_pdsch_pdu = &dl_req->dl_tti_pdu_list[dl_req->nPDUs]; @@ -1215,7 +1268,7 @@ void nr_generate_Msg2(module_id_t module_idP, int CC_id, frame_t frameP, sub_fra dl_req->nPDUs+=1; nfapi_nr_dl_tti_pdsch_pdu_rel15_t *pdsch_pdu_rel15 = &dl_tti_pdsch_pdu->pdsch_pdu.pdsch_pdu_rel15; - LOG_I(NR_MAC,"[gNB %d][RAPROC] CC_id %d Frame %d, slotP %d: Generating RA-Msg2 DCI, rnti 0x%x, state %d, CoreSetType %d\n", + LOG_A(NR_MAC,"[gNB %d][RAPROC] CC_id %d Frame %d, slotP %d: Generating RA-Msg2 DCI, rnti 0x%x, state %d, CoreSetType %d\n", module_idP, CC_id, frameP, slotP, ra->RA_rnti, ra->state,pdcch_pdu_rel15->CoreSetType); // SCF222: PDU index incremented for each PDSCH PDU sent in TX control message. This is used to associate control @@ -1245,6 +1298,8 @@ void nr_generate_Msg2(module_id_t module_idP, int CC_id, frame_t frameP, sub_fra bwp->bwp_Dedicated->pdsch_Config->choice.setup->dmrs_DownlinkForPDSCH_MappingTypeA->choice.setup->dmrs_Type) dmrsConfigType = 1; + NR_PDSCH_Config_t *pdsch_config = bwp && bwp->bwp_Dedicated && bwp->bwp_Dedicated->pdsch_Config ? bwp->bwp_Dedicated->pdsch_Config->choice.setup : NULL; + pdsch_pdu_rel15->pduBitmap = 0; pdsch_pdu_rel15->rnti = ra->RA_rnti; pdsch_pdu_rel15->pduIndex = pduindex; @@ -1273,7 +1328,7 @@ void nr_generate_Msg2(module_id_t module_idP, int CC_id, frame_t frameP, sub_fra pdsch_pdu_rel15->VRBtoPRBMapping = 0; pdsch_pdu_rel15->StartSymbolIndex = startSymbolIndex; pdsch_pdu_rel15->NrOfSymbols = nrOfSymbols; - pdsch_pdu_rel15->dlDmrsSymbPos = fill_dmrs_mask(NULL, + pdsch_pdu_rel15->dlDmrsSymbPos = fill_dmrs_mask(pdsch_config, nr_mac->common_channels->ServingCellConfigCommon->dmrs_TypeA_Position, nrOfSymbols, startSymbolIndex, @@ -1362,9 +1417,14 @@ void nr_generate_Msg2(module_id_t module_idP, int CC_id, frame_t frameP, sub_fra nr_mac->TX_req[CC_id].Number_of_PDUs++; nr_mac->TX_req[CC_id].Slot = slotP; - // Mark the corresponding RBs as used + // Mark the corresponding symbols RBs as used + fill_pdcch_vrb_map(nr_mac, + CC_id, + &ra->sched_pdcch, + CCEIndex, + aggregation_level); for (int rb = 0; rb < rbSize; rb++) { - vrb_map[BWPStart + rb + rbStart] = 1; + vrb_map[BWPStart + rb + rbStart] |= SL_to_bitmap(startSymbolIndex, nrOfSymbols); } ra->state = WAIT_Msg3; @@ -1401,10 +1461,16 @@ void nr_generate_Msg4(module_id_t module_idP, int CC_id, frame_t frameP, sub_fra pdsch_TimeDomainAllocationList = scc->downlinkConfigCommon->initialDownlinkBWP->pdsch_ConfigCommon->choice.setup->pdsch_TimeDomainAllocationList; } - coreset = get_coreset(module_idP, scc, bwp, ss, NR_SearchSpace__searchSpaceType_PR_common); + coreset = ra->coreset; AssertFatal(coreset!=NULL,"Coreset cannot be null for RA-Msg4\n"); + rnti_t tc_rnti = ra->rnti; + // If UE is known by the network, C-RNTI to be used instead of TC-RNTI + if(ra->msg3_dcch_dtch) { + ra->rnti = ra->crnti; + } + int UE_id = find_nr_UE_id(module_idP, ra->rnti); NR_UE_info_t *UE_info = &nr_mac->UE_info; NR_UE_sched_ctrl_t *sched_ctrl = &UE_info->UE_sched_ctrl[UE_id]; @@ -1438,6 +1504,11 @@ void nr_generate_Msg4(module_id_t module_idP, int CC_id, frame_t frameP, sub_fra harq->is_waiting = true; ra->harq_pid = current_harq_pid; + // Remove UE associated to TC-RNTI + if(harq->round==0 && ra->msg3_dcch_dtch) { + mac_remove_nr_ue(module_idP, tc_rnti); + } + // get CCEindex, needed also for PUCCH and then later for PDCCH uint8_t aggregation_level; uint8_t nr_of_candidates; @@ -1447,9 +1518,17 @@ void nr_generate_Msg4(module_id_t module_idP, int CC_id, frame_t frameP, sub_fra if(nr_of_candidates>0) break; } AssertFatal(nr_of_candidates>0,"nr_of_candidates is 0\n"); - int CCEIndex = allocate_nr_CCEs(nr_mac, bwp, coreset, aggregation_level,0,0,nr_of_candidates); + + int CCEIndex = find_pdcch_candidate(nr_mac, + CC_id, + aggregation_level, + nr_of_candidates, + &ra->sched_pdcch, + coreset, + 0); + if (CCEIndex < 0) { - LOG_E(NR_MAC, "%s(): cannot find free CCE for RA RNTI %04x!\n", __func__, ra->rnti); + LOG_E(NR_MAC, "%s(): cannot find free CCE for RA RNTI 0x%04x!\n", __func__, ra->rnti); return; } @@ -1473,15 +1552,21 @@ void nr_generate_Msg4(module_id_t module_idP, int CC_id, frame_t frameP, sub_fra uint8_t *buf = (uint8_t *) harq->tb; // Bytes to be transmitted if (harq->round == 0) { - uint16_t mac_pdu_length = nr_write_ce_dlsch_pdu(module_idP, nr_mac->sched_ctrlCommon, buf, 255, ra->cont_res_id); - LOG_D(NR_MAC,"Encoded contention resolution mac_pdu_length %d\n",mac_pdu_length); - uint16_t mac_sdu_length = mac_rrc_nr_data_req(module_idP, CC_id, frameP, CCCH, ra->rnti, 1, &buf[mac_pdu_length+2]); - ((NR_MAC_SUBHEADER_SHORT *) &buf[mac_pdu_length])->R = 0; - ((NR_MAC_SUBHEADER_SHORT *) &buf[mac_pdu_length])->F = 0; - ((NR_MAC_SUBHEADER_SHORT *) &buf[mac_pdu_length])->LCID = DL_SCH_LCID_CCCH; - ((NR_MAC_SUBHEADER_SHORT *) &buf[mac_pdu_length])->L = mac_sdu_length; - ra->mac_pdu_length = mac_pdu_length + mac_sdu_length + sizeof(NR_MAC_SUBHEADER_SHORT); - LOG_D(NR_MAC,"Encoded RRCSetup Piggyback (%d + %d bytes), mac_pdu_length %d\n", mac_sdu_length, (int)sizeof(NR_MAC_SUBHEADER_SHORT), ra->mac_pdu_length); + if (ra->msg3_dcch_dtch) { + // If the UE used MSG3 to transfer a DCCH or DTCH message, then contention resolution is successful if the UE receives a PDCCH transmission which has its CRC bits scrambled by the C-RNTI + // Just send padding LCID + ra->mac_pdu_length = 0; + } else { + uint16_t mac_pdu_length = nr_write_ce_dlsch_pdu(module_idP, nr_mac->sched_ctrlCommon, buf, 255, ra->cont_res_id); + LOG_D(NR_MAC,"Encoded contention resolution mac_pdu_length %d\n",mac_pdu_length); + uint16_t mac_sdu_length = mac_rrc_nr_data_req(module_idP, CC_id, frameP, CCCH, ra->rnti, 1, &buf[mac_pdu_length+2]); + ((NR_MAC_SUBHEADER_SHORT *) &buf[mac_pdu_length])->R = 0; + ((NR_MAC_SUBHEADER_SHORT *) &buf[mac_pdu_length])->F = 0; + ((NR_MAC_SUBHEADER_SHORT *) &buf[mac_pdu_length])->LCID = DL_SCH_LCID_CCCH; + ((NR_MAC_SUBHEADER_SHORT *) &buf[mac_pdu_length])->L = mac_sdu_length; + ra->mac_pdu_length = mac_pdu_length + mac_sdu_length + sizeof(NR_MAC_SUBHEADER_SHORT); + LOG_D(NR_MAC,"Encoded RRCSetup Piggyback (%d + %d bytes), mac_pdu_length %d\n", mac_sdu_length, (int)sizeof(NR_MAC_SUBHEADER_SHORT), ra->mac_pdu_length); + } } // Calculate number of symbols @@ -1547,7 +1632,7 @@ void nr_generate_Msg4(module_id_t module_idP, int CC_id, frame_t frameP, sub_fra int i = 0; while ((i < rbSize) && (rbStart + rbSize <= BWPSize)) { - if (vrb_map[BWPStart + rbStart + i]) { + if (vrb_map[BWPStart + rbStart + i]&SL_to_bitmap(startSymbolIndex, nrOfSymbols)) { rbStart += i+1; i = 0; } else { @@ -1572,7 +1657,7 @@ void nr_generate_Msg4(module_id_t module_idP, int CC_id, frame_t frameP, sub_fra // important if we have multiple RAs, and the DLSCH has to reuse them, so we need to mark them const int bwpid = bwp ? bwp->bwp_Id : 0; const int coresetid = coreset->controlResourceSetId; - nfapi_nr_dl_tti_pdcch_pdu_rel15_t *pdcch_pdu_rel15 = nr_mac->pdcch_pdu_idx[CC_id][bwpid][coresetid]; + nfapi_nr_dl_tti_pdcch_pdu_rel15_t *pdcch_pdu_rel15 = nr_mac->pdcch_pdu_idx[CC_id][coresetid]; if (!pdcch_pdu_rel15) { nfapi_nr_dl_tti_request_pdu_t *dl_tti_pdcch_pdu = &dl_req->dl_tti_pdu_list[dl_req->nPDUs]; memset(dl_tti_pdcch_pdu, 0, sizeof(nfapi_nr_dl_tti_request_pdu_t)); @@ -1580,8 +1665,8 @@ void nr_generate_Msg4(module_id_t module_idP, int CC_id, frame_t frameP, sub_fra dl_tti_pdcch_pdu->PDUSize = (uint8_t)(2 + sizeof(nfapi_nr_dl_tti_pdcch_pdu)); dl_req->nPDUs += 1; pdcch_pdu_rel15 = &dl_tti_pdcch_pdu->pdcch_pdu.pdcch_pdu_rel15; - nr_configure_pdcch(nr_mac, pdcch_pdu_rel15, ss, coreset, scc, genericParameters, NULL); - nr_mac->pdcch_pdu_idx[CC_id][bwpid][coresetid] = pdcch_pdu_rel15; + nr_configure_pdcch(pdcch_pdu_rel15, coreset, genericParameters, &ra->sched_pdcch); + nr_mac->pdcch_pdu_idx[CC_id][coresetid] = pdcch_pdu_rel15; } nfapi_nr_dl_tti_request_pdu_t *dl_tti_pdsch_pdu = &dl_req->dl_tti_pdu_list[dl_req->nPDUs]; @@ -1591,7 +1676,7 @@ void nr_generate_Msg4(module_id_t module_idP, int CC_id, frame_t frameP, sub_fra dl_req->nPDUs+=1; nfapi_nr_dl_tti_pdsch_pdu_rel15_t *pdsch_pdu_rel15 = &dl_tti_pdsch_pdu->pdsch_pdu.pdsch_pdu_rel15; - LOG_I(NR_MAC,"[gNB %d] [RAPROC] CC_id %d Frame %d, slotP %d: Generating RA-Msg4 DCI, state %d\n", module_idP, CC_id, frameP, slotP, ra->state); + LOG_A(NR_MAC, "[gNB %d] [RAPROC] CC_id %d Frame %d, slotP %d: Generating RA-Msg4 DCI, state %d\n", module_idP, CC_id, frameP, slotP, ra->state); // SCF222: PDU index incremented for each PDSCH PDU sent in TX control message. This is used to associate control // information to data and is reset every slot. @@ -1721,9 +1806,14 @@ void nr_generate_Msg4(module_id_t module_idP, int CC_id, frame_t frameP, sub_fra nr_mac->TX_req[CC_id].Number_of_PDUs++; nr_mac->TX_req[CC_id].Slot = slotP; - // Mark the corresponding RBs as used + // Mark the corresponding symbols and RBs as used + fill_pdcch_vrb_map(nr_mac, + CC_id, + &ra->sched_pdcch, + CCEIndex, + aggregation_level); for (int rb = 0; rb < pdsch_pdu_rel15->rbSize; rb++) { - vrb_map[BWPStart + rb + pdsch_pdu_rel15->rbStart] = 1; + vrb_map[BWPStart + rb + pdsch_pdu_rel15->rbStart] |= SL_to_bitmap(startSymbolIndex, nrOfSymbols); } LOG_D(NR_MAC,"BWPSize: %i\n", pdcch_pdu_rel15->BWPSize); @@ -1741,8 +1831,23 @@ void nr_generate_Msg4(module_id_t module_idP, int CC_id, frame_t frameP, sub_fra LOG_D(NR_MAC,"precoderGranularity: %i\n", pdcch_pdu_rel15->precoderGranularity); LOG_D(NR_MAC,"numDlDci: %i\n", pdcch_pdu_rel15->numDlDci); - ra->state = WAIT_Msg4_ACK; - LOG_D(NR_MAC,"[gNB %d][RAPROC] Frame %d, Subframe %d: RA state %d\n", module_idP, frameP, slotP, ra->state); + if(ra->msg3_dcch_dtch) { + // If the UE used MSG3 to transfer a DCCH or DTCH message, then contention resolution is successful upon transmission of PDCCH + LOG_I(NR_MAC, "(ue %i, rnti 0x%04x) CBRA procedure succeeded!\n", UE_id, ra->rnti); + nr_clear_ra_proc(module_idP, CC_id, frameP, ra); + UE_info->active[UE_id] = true; + UE_info->Msg4_ACKed[UE_id] = true; + + remove_front_nr_list(&sched_ctrl->feedback_dl_harq); + harq->feedback_slot = -1; + harq->is_waiting = false; + add_tail_nr_list(&sched_ctrl->available_dl_harq, current_harq_pid); + harq->round = 0; + harq->ndi ^= 1; + } else { + ra->state = WAIT_Msg4_ACK; + LOG_D(NR_MAC,"[gNB %d][RAPROC] Frame %d, Subframe %d: RA state %d\n", module_idP, frameP, slotP, ra->state); + } } } @@ -1756,23 +1861,22 @@ void nr_check_Msg4_Ack(module_id_t module_id, int CC_id, frame_t frame, sub_fram NR_UE_harq_t *harq = &sched_ctrl->harq_processes[current_harq_pid]; NR_mac_stats_t *stats = &UE_info->mac_stats[UE_id]; - LOG_D(NR_MAC, "ue %d, rnti %d, harq is waiting %d, round %d, frame %d %d, harq id %d\n", UE_id, ra->rnti, harq->is_waiting, harq->round, frame, slot, current_harq_pid); + LOG_D(NR_MAC, "ue %d, rnti 0x%04x, harq is waiting %d, round %d, frame %d %d, harq id %d\n", UE_id, ra->rnti, harq->is_waiting, harq->round, frame, slot, current_harq_pid); if (harq->is_waiting == 0) { if (harq->round == 0) { if (stats->dlsch_errors == 0) { - LOG_I(NR_MAC, "(ue %i, rnti 0x%04x) Received Ack of RA-Msg4. CBRA procedure succeeded!\n", UE_id, ra->rnti); - nr_clear_ra_proc(module_id, CC_id, frame, ra); + LOG_A(NR_MAC, "(ue %i, rnti 0x%04x) Received Ack of RA-Msg4. CBRA procedure succeeded!\n", UE_id, ra->rnti); UE_info->active[UE_id] = true; UE_info->Msg4_ACKed[UE_id] = true; - if(sched_ctrl->retrans_dl_harq.head>=0) - remove_nr_list(&sched_ctrl->retrans_dl_harq, current_harq_pid); } else { LOG_I(NR_MAC, "(ue %i, rnti 0x%04x) RA Procedure failed at Msg4!\n", UE_id, ra->rnti); - nr_mac_remove_ra_rnti(module_id, ra->rnti); - nr_clear_ra_proc(module_id, CC_id, frame, ra); - mac_remove_nr_ue(module_id, ra->rnti); + } + + nr_clear_ra_proc(module_id, CC_id, frame, ra); + if(sched_ctrl->retrans_dl_harq.head >= 0) { + remove_nr_list(&sched_ctrl->retrans_dl_harq, current_harq_pid); } } else { @@ -1790,6 +1894,8 @@ void nr_clear_ra_proc(module_id_t module_idP, int CC_id, frame_t frameP, NR_RA_t ra->timing_offset = 0; ra->RRC_timer = 20; ra->msg3_round = 0; + ra->msg3_dcch_dtch = false; + ra->crnti = 0; if(ra->cfra == false) { ra->rnti = 0; } diff --git a/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_bch.c b/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_bch.c index df25b085e6684222ae124d2be21b0d4e7841cc3c..0af340725a8621df90f6d1ed91f49a6a26485fb1 100644 --- a/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_bch.c +++ b/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_bch.c @@ -314,7 +314,7 @@ void fill_ssb_vrb_map (NR_COMMON_channels_t *cc, int rbStart, uint16_t symStart uint16_t *vrb_map = cc[CC_id].vrb_map; for (int rb = 0; rb < 20; rb++) - vrb_map[rbStart + rb] = 15<<symStart; + vrb_map[rbStart + rb] = SL_to_bitmap(symStart, 4); } @@ -329,7 +329,9 @@ uint32_t schedule_control_sib1(module_id_t module_id, int num_total_bytes) { gNB_MAC_INST *gNB_mac = RC.nrmac[module_id]; - uint16_t *vrb_map = RC.nrmac[module_id]->common_channels[CC_id].vrb_map; + NR_COMMON_channels_t *cc = &gNB_mac->common_channels[CC_id]; + NR_ServingCellConfigCommon_t *scc = cc->ServingCellConfigCommon; + uint16_t *vrb_map = cc->vrb_map; if (gNB_mac->sched_ctrlCommon == NULL){ LOG_D(NR_MAC,"schedule_control_common: Filling nr_mac->sched_ctrlCommon\n"); @@ -340,6 +342,12 @@ uint32_t schedule_control_sib1(module_id_t module_id, fill_coresetZero(gNB_mac->sched_ctrlCommon->coreset,type0_PDCCH_CSS_config); gNB_mac->cset0_bwp_start = type0_PDCCH_CSS_config->cset_start_rb; gNB_mac->cset0_bwp_size = type0_PDCCH_CSS_config->num_rbs; + gNB_mac->sched_ctrlCommon->sched_pdcch = set_pdcch_structure(NULL, + gNB_mac->sched_ctrlCommon->search_space, + gNB_mac->sched_ctrlCommon->coreset, + scc, + NULL, + type0_PDCCH_CSS_config); } gNB_mac->sched_ctrlCommon->pdsch_semi_static.time_domain_allocation = time_domain_allocation; @@ -354,13 +362,13 @@ uint32_t schedule_control_sib1(module_id_t module_id, if (nr_of_candidates>0) break; // choosing the lower value of aggregation level available } AssertFatal(nr_of_candidates>0,"nr_of_candidates is 0\n"); - gNB_mac->sched_ctrlCommon->cce_index = allocate_nr_CCEs(RC.nrmac[module_id], - NULL, - gNB_mac->sched_ctrlCommon->coreset, - gNB_mac->sched_ctrlCommon->aggregation_level, - 0, - candidate_idx, - nr_of_candidates); + gNB_mac->sched_ctrlCommon->cce_index = find_pdcch_candidate(gNB_mac, + CC_id, + gNB_mac->sched_ctrlCommon->aggregation_level, + nr_of_candidates, + &gNB_mac->sched_ctrlCommon->sched_pdcch, + gNB_mac->sched_ctrlCommon->coreset, + 0); AssertFatal(gNB_mac->sched_ctrlCommon->cce_index >= 0, "Could not find CCE for coreset0\n"); @@ -384,7 +392,7 @@ uint32_t schedule_control_sib1(module_id_t module_id, int rbSize = 0; uint32_t TBS = 0; do { - if(rbSize < bwpSize && !vrb_map[rbStart + rbSize]) + if(rbSize < bwpSize && !(vrb_map[rbStart + rbSize]&SL_to_bitmap(startSymbolIndex, nrOfSymbols))) rbSize++; else{ if (gNB_mac->sched_ctrlCommon->sched_pdsch.mcs<10) @@ -411,16 +419,21 @@ uint32_t schedule_control_sib1(module_id_t module_id, LOG_D(MAC,"dmrs_length %d\n",dmrs_length); LOG_D(MAC,"N_PRB_DMRS = %d\n",N_PRB_DMRS); LOG_D(MAC,"mappingtype = %d\n", mappingtype); - // Mark the corresponding RBs as used + fill_pdcch_vrb_map(gNB_mac, + CC_id, + &gNB_mac->sched_ctrlCommon->sched_pdcch, + gNB_mac->sched_ctrlCommon->cce_index, + gNB_mac->sched_ctrlCommon->aggregation_level); for (int rb = 0; rb < gNB_mac->sched_ctrlCommon->sched_pdsch.rbSize; rb++) { - vrb_map[rb + rbStart] = 1; + vrb_map[rb + rbStart] = SL_to_bitmap(startSymbolIndex, nrOfSymbols); } return TBS; } void nr_fill_nfapi_dl_sib1_pdu(int Mod_idP, nfapi_nr_dl_tti_request_body_t *dl_req, + int pdu_index, NR_Type0_PDCCH_CSS_config_t *type0_PDCCH_CSS_config, uint32_t TBS, int StartSymbolIndex, @@ -437,13 +450,10 @@ void nr_fill_nfapi_dl_sib1_pdu(int Mod_idP, dl_tti_pdcch_pdu->PDUSize = (uint8_t)(2+sizeof(nfapi_nr_dl_tti_pdcch_pdu)); dl_req->nPDUs += 1; nfapi_nr_dl_tti_pdcch_pdu_rel15_t *pdcch_pdu_rel15 = &dl_tti_pdcch_pdu->pdcch_pdu.pdcch_pdu_rel15; - nr_configure_pdcch(NULL, - pdcch_pdu_rel15, - gNB_mac->sched_ctrlCommon->search_space, + nr_configure_pdcch(pdcch_pdu_rel15, gNB_mac->sched_ctrlCommon->coreset, - scc, NULL, - type0_PDCCH_CSS_config); + &gNB_mac->sched_ctrlCommon->sched_pdcch); nfapi_nr_dl_tti_request_pdu_t *dl_tti_pdsch_pdu = &dl_req->dl_tti_pdu_list[dl_req->nPDUs]; memset((void*)dl_tti_pdsch_pdu,0,sizeof(nfapi_nr_dl_tti_request_pdu_t)); @@ -456,7 +466,7 @@ void nr_fill_nfapi_dl_sib1_pdu(int Mod_idP, pdsch_pdu_rel15->pduBitmap = 0; pdsch_pdu_rel15->rnti = SI_RNTI; - pdsch_pdu_rel15->pduIndex = gNB_mac->pdu_index[0]++; + pdsch_pdu_rel15->pduIndex = pdu_index; pdsch_pdu_rel15->BWPSize = type0_PDCCH_CSS_config->num_rbs; pdsch_pdu_rel15->BWPStart = type0_PDCCH_CSS_config->cset_start_rb; @@ -623,7 +633,8 @@ void schedule_nr_sib1(module_id_t module_idP, frame_t frameP, sub_frame_t slotP) candidate_idx, sib1_sdu_length); nfapi_nr_dl_tti_request_body_t *dl_req = &gNB_mac->DL_req[CC_id].dl_tti_request_body; - nr_fill_nfapi_dl_sib1_pdu(module_idP, dl_req, type0_PDCCH_CSS_config, TBS, startSymbolIndex, nrOfSymbols, dlDmrsSymbPos); + int pdu_index = gNB_mac->pdu_index[0]++; + nr_fill_nfapi_dl_sib1_pdu(module_idP, dl_req, pdu_index, type0_PDCCH_CSS_config, TBS, startSymbolIndex, nrOfSymbols, dlDmrsSymbPos); const int ntx_req = gNB_mac->TX_req[CC_id].Number_of_PDUs; nfapi_nr_pdu_t *tx_req = &gNB_mac->TX_req[CC_id].pdu_list[ntx_req]; @@ -633,7 +644,7 @@ void schedule_nr_sib1(module_id_t module_idP, frame_t frameP, sub_frame_t slotP) memcpy(tx_req->TLVs[0].value.direct, sib1_payload, sib1_sdu_length); tx_req->PDU_length = TBS; - tx_req->PDU_index = gNB_mac->pdu_index[0]++; + tx_req->PDU_index = pdu_index; tx_req->num_TLV = 1; tx_req->TLVs[0].length = TBS + 2; gNB_mac->TX_req[CC_id].Number_of_PDUs++; diff --git a/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_dlsch.c b/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_dlsch.c index 3f93f79621100f49542d96517782f61bc93acd56..c9aa5397bf1906aee2dc81b045426625971a3ff1 100644 --- a/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_dlsch.c +++ b/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_dlsch.c @@ -533,7 +533,7 @@ void nr_store_dlsch_buffer(module_id_t module_id, bool allocate_dl_retransmission(module_id_t module_id, frame_t frame, sub_frame_t slot, - uint8_t *rballoc_mask, + uint16_t *rballoc_mask, int *n_rb_sched, int UE_id, int current_harq_pid) { @@ -563,13 +563,16 @@ bool allocate_dl_retransmission(module_id_t module_id, while (rbSize < retInfo->rbSize) { rbStart += rbSize; /* last iteration rbSize was not enough, skip it */ rbSize = 0; - while (rbStart < bwpSize && !rballoc_mask[rbStart]) + while (rbStart < bwpSize && + !(rballoc_mask[rbStart]&SL_to_bitmap(ps->startSymbolIndex, ps->nrOfSymbols))) rbStart++; if (rbStart >= bwpSize) { LOG_D(NR_MAC, "cannot allocate retransmission for UE %d/RNTI %04x: no resources\n", UE_id, UE_info->rnti[UE_id]); return false; } - while (rbStart + rbSize < bwpSize && rballoc_mask[rbStart + rbSize] && rbSize < retInfo->rbSize) + while (rbStart + rbSize < bwpSize && + (rballoc_mask[rbStart + rbSize]&SL_to_bitmap(ps->startSymbolIndex, ps->nrOfSymbols)) && + rbSize < retInfo->rbSize) rbSize++; } /* check whether we need to switch the TDA allocation since the last @@ -579,13 +582,15 @@ bool allocate_dl_retransmission(module_id_t module_id, } else { /* the retransmission will use a different time domain allocation, check * that we have enough resources */ - while (rbStart < bwpSize && !rballoc_mask[rbStart]) - rbStart++; - while (rbStart + rbSize < bwpSize && rballoc_mask[rbStart + rbSize]) - rbSize++; NR_pdsch_semi_static_t temp_ps; temp_ps.nrOfLayers = 1; nr_set_pdsch_semi_static(scc, cg, sched_ctrl->active_bwp, bwpd, tda, f, &temp_ps); + while (rbStart < bwpSize && + !(rballoc_mask[rbStart]&SL_to_bitmap(temp_ps.startSymbolIndex, temp_ps.nrOfSymbols))) + rbStart++; + while (rbStart + rbSize < bwpSize && + (rballoc_mask[rbStart + rbSize]&SL_to_bitmap(temp_ps.startSymbolIndex, temp_ps.nrOfSymbols))) + rbSize++; uint32_t new_tbs; uint16_t new_rbSize; bool success = nr_find_nb_rb(retInfo->Qm, @@ -609,9 +614,28 @@ bool allocate_dl_retransmission(module_id_t module_id, } /* Find a free CCE */ - bool freeCCE = find_free_CCE(module_id, slot, UE_id); - if (!freeCCE) { - LOG_I(MAC, "%4d.%2d allocate_dl_transmission: could not find CCE for DL DCI retransmission UE %d/RNTI %04x\n", + const int cid = sched_ctrl->coreset->controlResourceSetId; + const uint16_t Y = get_Y(cid%3, slot, UE_info->rnti[UE_id]); + uint8_t nr_of_candidates; + for (int i=0; i<5; i++) { + // for now taking the lowest value among the available aggregation levels + find_aggregation_candidates(&sched_ctrl->aggregation_level, + &nr_of_candidates, + sched_ctrl->search_space, + 1<<i); + if(nr_of_candidates>0) break; + } + + int CCEIndex = find_pdcch_candidate(RC.nrmac[module_id], + /* CC_id = */ 0, + sched_ctrl->aggregation_level, + nr_of_candidates, + &sched_ctrl->sched_pdcch, + sched_ctrl->coreset, + Y); + + if (CCEIndex<0) { + LOG_D(MAC, "%4d.%2d could not find CCE for DL DCI retransmission UE %d/RNTI %04x\n", frame, slot, UE_id, UE_info->rnti[UE_id]); return false; } @@ -627,14 +651,18 @@ bool allocate_dl_retransmission(module_id_t module_id, UE_info->rnti[UE_id], frame, slot); - int cid = sched_ctrl->coreset->controlResourceSetId; - UE_info->num_pdcch_cand[UE_id][cid]--; - int *cce_list = RC.nrmac[module_id]->cce_list[sched_ctrl->active_bwp?sched_ctrl->active_bwp->bwp_Id:0][cid]; - for (int i = 0; i < sched_ctrl->aggregation_level; i++) - cce_list[sched_ctrl->cce_index + i] = 0; + RC.nrmac[module_id]->pdcch_cand[cid]--; return false; } + sched_ctrl->cce_index = CCEIndex; + + fill_pdcch_vrb_map(RC.nrmac[module_id], + /* CC_id = */ 0, + &sched_ctrl->sched_pdcch, + CCEIndex, + sched_ctrl->aggregation_level); + /* just reuse from previous scheduling opportunity, set new start RB */ sched_ctrl->sched_pdsch = *retInfo; sched_ctrl->sched_pdsch.rbStart = rbStart; @@ -644,7 +672,7 @@ bool allocate_dl_retransmission(module_id_t module_id, /* retransmissions: directly allocate */ *n_rb_sched -= sched_ctrl->sched_pdsch.rbSize; for (int rb = 0; rb < sched_ctrl->sched_pdsch.rbSize; rb++) - rballoc_mask[rb + sched_ctrl->sched_pdsch.rbStart] = 0; + rballoc_mask[rb + sched_ctrl->sched_pdsch.rbStart] -= SL_to_bitmap(ps->startSymbolIndex, ps->nrOfSymbols); return true; } @@ -657,7 +685,7 @@ void pf_dl(module_id_t module_id, NR_list_t *UE_list, int max_num_ue, int n_rb_sched, - uint8_t *rballoc_mask) { + uint16_t *rballoc_mask) { gNB_MAC_INST *mac = RC.nrmac[module_id]; NR_UE_info_t *UE_info = &mac->UE_info; @@ -734,7 +762,6 @@ void pf_dl(module_id_t module_id, NR_BWP_DownlinkDedicated_t *bwpd= cg ? cg->spCellConfig->spCellConfigDedicated->initialDownlinkBWP:NULL; NR_UE_sched_ctrl_t *sched_ctrl = &UE_info->UE_sched_ctrl[UE_id]; - int bwp_Id = sched_ctrl->active_bwp ? sched_ctrl->active_bwp->bwp_Id : 0; const uint16_t rnti = UE_info->rnti[UE_id]; NR_BWP_t *genericParameters = sched_ctrl->active_bwp ? &sched_ctrl->active_bwp->bwp_Common->genericParameters: @@ -743,10 +770,34 @@ void pf_dl(module_id_t module_id, const uint16_t bwpSize = NRRIV2BW(genericParameters->locationAndBandwidth,MAX_BWP_SIZE); int rbStart = 0; // start wrt BWPstart + if (sched_ctrl->available_dl_harq.head < 0) { + LOG_D(MAC, "UE %d RNTI %04x has no free HARQ process, skipping\n", UE_id, UE_info->rnti[UE_id]); + continue; + } + /* Find a free CCE */ - bool freeCCE = find_free_CCE(module_id, slot, UE_id); - if (!freeCCE) { - LOG_I(NR_MAC, "%4d.%2d could not find CCE for DL DCI UE %d/RNTI %04x\n", frame, slot, UE_id, rnti); + const int cid = sched_ctrl->coreset->controlResourceSetId; + const uint16_t Y = get_Y(cid%3, slot, UE_info->rnti[UE_id]); + uint8_t nr_of_candidates; + for (int i=0; i<5; i++) { + // for now taking the lowest value among the available aggregation levels + find_aggregation_candidates(&sched_ctrl->aggregation_level, + &nr_of_candidates, + sched_ctrl->search_space, + 1<<i); + if(nr_of_candidates>0) break; + } + + int CCEIndex = find_pdcch_candidate(mac, + /* CC_id = */ 0, + sched_ctrl->aggregation_level, + nr_of_candidates, + &sched_ctrl->sched_pdcch, + sched_ctrl->coreset, + Y); + + if (CCEIndex<0) { + LOG_D(NR_MAC, "%4d.%2d could not find CCE for DL DCI UE %d/RNTI %04x\n", frame, slot, UE_id, rnti); continue; } /* reduce max_num_ue once we are sure UE can be allocated, i.e., has CCE */ @@ -755,7 +806,7 @@ void pf_dl(module_id_t module_id, /* Find PUCCH occasion: if it fails, undo CCE allocation (undoing PUCCH * allocation after CCE alloc fail would be more complex) */ - const int alloc = nr_acknack_scheduling(module_id, UE_id, frame, slot, -1,0); + const int alloc = nr_acknack_scheduling(module_id, UE_id, frame, slot, -1, 0); if (alloc<0) { LOG_D(NR_MAC, "%s(): could not find PUCCH for UE %d/%04x@%d.%d\n", @@ -764,20 +815,17 @@ void pf_dl(module_id_t module_id, rnti, frame, slot); - int cid = sched_ctrl->coreset->controlResourceSetId; - UE_info->num_pdcch_cand[UE_id][cid]--; - int *cce_list = mac->cce_list[bwp_Id][cid]; - for (int i = 0; i < sched_ctrl->aggregation_level; i++) - cce_list[sched_ctrl->cce_index + i] = 0; + mac->pdcch_cand[cid]--; return; } - // Freq-demain allocation - while (rbStart < bwpSize && !rballoc_mask[rbStart]) rbStart++; + sched_ctrl->cce_index = CCEIndex; - uint16_t max_rbSize = 1; - while (rbStart + max_rbSize < bwpSize && rballoc_mask[rbStart + max_rbSize]) - max_rbSize++; + fill_pdcch_vrb_map(mac, + /* CC_id = */ 0, + &sched_ctrl->sched_pdcch, + CCEIndex, + sched_ctrl->aggregation_level); /* MCS has been set above */ @@ -788,6 +836,18 @@ void pf_dl(module_id_t module_id, const long f = (sched_ctrl->active_bwp || bwpd) ? sched_ctrl->search_space->searchSpaceType->choice.ue_Specific->dci_Formats : 0; if (ps->time_domain_allocation != tda) nr_set_pdsch_semi_static(scc, UE_info->CellGroup[UE_id], sched_ctrl->active_bwp, bwpd, tda, f, ps); + + const uint16_t slbitmap = SL_to_bitmap(ps->startSymbolIndex, ps->nrOfSymbols); + // Freq-demain allocation + while (rbStart < bwpSize && + !(rballoc_mask[rbStart]&slbitmap)) + rbStart++; + + uint16_t max_rbSize = 1; + while (rbStart + max_rbSize < bwpSize && + (rballoc_mask[rbStart + max_rbSize]&slbitmap)) + max_rbSize++; + sched_pdsch->Qm = nr_get_Qm_dl(sched_pdsch->mcs, ps->mcsTableIdx); sched_pdsch->R = nr_get_code_rate_dl(sched_pdsch->mcs, ps->mcsTableIdx); sched_pdsch->pucch_allocation = alloc; @@ -809,7 +869,7 @@ void pf_dl(module_id_t module_id, /* transmissions: directly allocate */ n_rb_sched -= sched_pdsch->rbSize; for (int rb = 0; rb < sched_pdsch->rbSize; rb++) - rballoc_mask[rb + sched_pdsch->rbStart] = 0; + rballoc_mask[rb + sched_pdsch->rbStart] -= slbitmap; } } @@ -822,9 +882,18 @@ void nr_fr1_dlsch_preprocessor(module_id_t module_id, frame_t frame, sub_frame_t NR_ServingCellConfigCommon_t *scc = RC.nrmac[module_id]->common_channels[0].ServingCellConfigCommon; const int CC_id = 0; - /* Get bwpSize from the first UE */ + /* Get bwpSize and TDAfrom the first UE */ + /* This is temporary and it assumes all UEs have the same BWP and TDA*/ int UE_id = UE_info->list.head; NR_UE_sched_ctrl_t *sched_ctrl = &UE_info->UE_sched_ctrl[UE_id]; + const int tda = RC.nrmac[module_id]->preferred_dl_tda[sched_ctrl->active_bwp ? sched_ctrl->active_bwp->bwp_Id : 0][slot]; + int startSymbolIndex, nrOfSymbols; + const struct NR_PDSCH_TimeDomainResourceAllocationList *tdaList = sched_ctrl->active_bwp ? + sched_ctrl->active_bwp->bwp_Common->pdsch_ConfigCommon->choice.setup->pdsch_TimeDomainAllocationList : + scc->downlinkConfigCommon->initialDownlinkBWP->pdsch_ConfigCommon->choice.setup->pdsch_TimeDomainAllocationList; + AssertFatal(tda < tdaList->list.count, "time_domain_allocation %d>=%d\n", tda, tdaList->list.count); + const int startSymbolAndLength = tdaList->list.array[tda]->startSymbolAndLength; + SLIV2SL(startSymbolAndLength, &startSymbolIndex, &nrOfSymbols); const uint16_t bwpSize = NRRIV2BW(sched_ctrl->active_bwp ? sched_ctrl->active_bwp->bwp_Common->genericParameters.locationAndBandwidth: @@ -835,14 +904,18 @@ void nr_fr1_dlsch_preprocessor(module_id_t module_id, frame_t frame, sub_frame_t scc->downlinkConfigCommon->initialDownlinkBWP->genericParameters.locationAndBandwidth, MAX_BWP_SIZE); + const uint16_t slbitmap = SL_to_bitmap(startSymbolIndex, nrOfSymbols); uint16_t *vrb_map = RC.nrmac[module_id]->common_channels[CC_id].vrb_map; - uint8_t rballoc_mask[bwpSize]; + uint16_t rballoc_mask[bwpSize]; int n_rb_sched = 0; for (int i = 0; i < bwpSize; i++) { // calculate mask: init with "NOT" vrb_map: // if any RB in vrb_map is blocked (1), the current RBG will be 0 - rballoc_mask[i] = !vrb_map[i+BWPStart]; - n_rb_sched += rballoc_mask[i]; + rballoc_mask[i] = (~vrb_map[i+BWPStart])&0x3fff; //bitwise not and 14 symbols + // if all the pdsch symbols are free + if((rballoc_mask[i]&slbitmap) == + slbitmap) + n_rb_sched++; } /* Retrieve amount of data to send for this UE */ @@ -853,7 +926,7 @@ void nr_fr1_dlsch_preprocessor(module_id_t module_id, frame_t frame, sub_frame_t frame, slot, &UE_info->list, - 2, + MAX_MOBILES_PER_GNB, n_rb_sched, rballoc_mask); } @@ -997,8 +1070,9 @@ void nr_schedule_ue_spec(module_id_t module_id, const int bwpid = bwp ? bwp->bwp_Id : 0; const int coresetid = (bwp||bwpd) ? sched_ctrl->coreset->controlResourceSetId : gNB_mac->sched_ctrlCommon->coreset->controlResourceSetId; - nfapi_nr_dl_tti_pdcch_pdu_rel15_t *pdcch_pdu = gNB_mac->pdcch_pdu_idx[CC_id][bwpid][coresetid]; + nfapi_nr_dl_tti_pdcch_pdu_rel15_t *pdcch_pdu = gNB_mac->pdcch_pdu_idx[CC_id][coresetid]; if (!pdcch_pdu) { + LOG_D(NR_MAC, "creating pdcch pdu, pdcch_pdu = NULL. \n"); nfapi_nr_dl_tti_request_pdu_t *dl_tti_pdcch_pdu = &dl_req->dl_tti_pdu_list[dl_req->nPDUs]; memset(dl_tti_pdcch_pdu, 0, sizeof(nfapi_nr_dl_tti_request_pdu_t)); dl_tti_pdcch_pdu->PDUType = NFAPI_NR_DL_TTI_PDCCH_PDU_TYPE; @@ -1006,10 +1080,9 @@ void nr_schedule_ue_spec(module_id_t module_id, dl_req->nPDUs += 1; pdcch_pdu = &dl_tti_pdcch_pdu->pdcch_pdu.pdcch_pdu_rel15; LOG_D(NR_MAC,"Trying to configure DL pdcch for UE %d, bwp %d, cs %d\n",UE_id,bwpid,coresetid); - NR_SearchSpace_t *ss = (bwp||bwpd) ? sched_ctrl->search_space:gNB_mac->sched_ctrlCommon->search_space; NR_ControlResourceSet_t *coreset = (bwp||bwpd)? sched_ctrl->coreset:gNB_mac->sched_ctrlCommon->coreset; - nr_configure_pdcch(gNB_mac, pdcch_pdu, ss, coreset, scc, genericParameters, NULL); - gNB_mac->pdcch_pdu_idx[CC_id][bwpid][coresetid] = pdcch_pdu; + nr_configure_pdcch(pdcch_pdu, coreset, genericParameters, &sched_ctrl->sched_pdcch); + gNB_mac->pdcch_pdu_idx[CC_id][coresetid] = pdcch_pdu; } nfapi_nr_dl_tti_request_pdu_t *dl_tti_pdsch_pdu = &dl_req->dl_tti_pdu_list[dl_req->nPDUs]; @@ -1092,6 +1165,7 @@ void nr_schedule_ue_spec(module_id_t module_id, pdsch_pdu->pduBitmap |= 0x1; // Bit 0: pdschPtrs - Indicates PTRS included (FR2) } + LOG_D(NR_MAC,"Configuring DCI/PDCCH in %d.%d at CCE %d, rnti %x\n", frame,slot,sched_ctrl->cce_index,rnti); /* Fill PDCCH DL DCI PDU */ nfapi_nr_dl_dci_pdu_t *dci_pdu = &pdcch_pdu->dci_pdu[pdcch_pdu->numDlDci]; pdcch_pdu->numDlDci++; diff --git a/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_phytest.c b/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_phytest.c index f1005cea70da10ae44b4d38df580b8604f0831c1..accb347533ebaeb15152e161ce3fd6d7dadb8034 100644 --- a/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_phytest.c +++ b/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_phytest.c @@ -53,7 +53,6 @@ //#define UL_HARQ_PRINT extern RAN_CONTEXT_t RC; -const uint8_t nr_rv_round_map[4] = {0, 2, 3, 1}; //#define ENABLE_MAC_PAYLOAD_DEBUG 1 //uint8_t mac_pdu[MAX_NR_DLSCH_PAYLOAD_BYTES]; @@ -278,6 +277,14 @@ void nr_preprocessor_phytest(module_id_t module_id, __func__, UE_id); NR_UE_sched_ctrl_t *sched_ctrl = &UE_info->UE_sched_ctrl[UE_id]; + const int tda = sched_ctrl->active_bwp ? RC.nrmac[module_id]->preferred_dl_tda[sched_ctrl->active_bwp->bwp_Id][slot] : 1; + const long f = sched_ctrl->active_bwp ? sched_ctrl->search_space->searchSpaceType->choice.ue_Specific->dci_Formats : 0; + NR_pdsch_semi_static_t *ps = &sched_ctrl->pdsch_semi_static; + ps->nrOfLayers = target_dl_Nl; + if (ps->time_domain_allocation != tda) + nr_set_pdsch_semi_static( + scc, UE_info->CellGroup[UE_id], sched_ctrl->active_bwp, NULL, tda, f, ps); + /* find largest unallocated chunk */ const int bwpSize = NRRIV2BW(sched_ctrl->active_bwp->bwp_Common->genericParameters.locationAndBandwidth, MAX_BWP_SIZE); const int BWPStart = NRRIV2PRBOFFSET(sched_ctrl->active_bwp->bwp_Common->genericParameters.locationAndBandwidth, MAX_BWP_SIZE); @@ -289,11 +296,14 @@ void nr_preprocessor_phytest(module_id_t module_id, /* loop ensures that we allocate exactly target_dl_bw, or return */ while (true) { /* advance to first free RB */ - while (rbStart < bwpSize && vrb_map[rbStart + BWPStart]) + while (rbStart < bwpSize && + (vrb_map[rbStart + BWPStart]&SL_to_bitmap(ps->startSymbolIndex, ps->nrOfSymbols))) rbStart++; rbSize = 1; /* iterate until we are at target_dl_bw or no available RBs */ - while (rbStart + rbSize < bwpSize && !vrb_map[rbStart + rbSize + BWPStart] && rbSize < target_dl_bw) + while (rbStart + rbSize < bwpSize && + !(vrb_map[rbStart + rbSize + BWPStart]&SL_to_bitmap(ps->startSymbolIndex, ps->nrOfSymbols)) && + rbSize < target_dl_bw) rbSize++; /* found target_dl_bw? */ if (rbSize == target_dl_bw) @@ -334,21 +344,22 @@ void nr_preprocessor_phytest(module_id_t module_id, AssertFatal(nr_of_candidates>0,"nr_of_candidates is 0\n"); const int cid = sched_ctrl->coreset->controlResourceSetId; - const uint16_t Y = UE_info->Y[UE_id][cid][slot]; - const int m = UE_info->num_pdcch_cand[UE_id][cid]; - sched_ctrl->cce_index = allocate_nr_CCEs(RC.nrmac[module_id], - sched_ctrl->active_bwp, - sched_ctrl->coreset, - sched_ctrl->aggregation_level, - Y, - m, - nr_of_candidates); - AssertFatal(sched_ctrl->cce_index >= 0, + const uint16_t Y = get_Y(cid%3, slot, UE_info->rnti[UE_id]); + + int CCEIndex = find_pdcch_candidate(RC.nrmac[module_id], + CC_id, + sched_ctrl->aggregation_level, + nr_of_candidates, + &sched_ctrl->sched_pdcch, + sched_ctrl->coreset, + Y); + + AssertFatal(CCEIndex >= 0, "%s(): could not find CCE for UE %d\n", __func__, UE_id); - const int alloc = nr_acknack_scheduling(module_id, UE_id, frame, slot, -1,0); + const int alloc = nr_acknack_scheduling(module_id, UE_id, frame, slot, -1, 0); if (alloc < 0) { LOG_D(MAC, "%s(): could not find PUCCH for UE %d/%04x@%d.%d\n", @@ -357,28 +368,26 @@ void nr_preprocessor_phytest(module_id_t module_id, rnti, frame, slot); - UE_info->num_pdcch_cand[UE_id][cid]--; - int *cce_list = RC.nrmac[module_id]->cce_list[sched_ctrl->active_bwp->bwp_Id][cid]; - for (int i = 0; i < sched_ctrl->aggregation_level; i++) - cce_list[sched_ctrl->cce_index + i] = 0; + RC.nrmac[module_id]->pdcch_cand[cid]--; return; } + sched_ctrl->cce_index = CCEIndex; + + fill_pdcch_vrb_map(RC.nrmac[module_id], + CC_id, + &sched_ctrl->sched_pdcch, + CCEIndex, + sched_ctrl->aggregation_level); + //AssertFatal(alloc, // "could not find uplink slot for PUCCH (RNTI %04x@%d.%d)!\n", // rnti, frame, slot); NR_sched_pdsch_t *sched_pdsch = &sched_ctrl->sched_pdsch; - NR_pdsch_semi_static_t *ps = &sched_ctrl->pdsch_semi_static; sched_pdsch->pucch_allocation = alloc; sched_pdsch->rbStart = rbStart; sched_pdsch->rbSize = rbSize; - const int tda = sched_ctrl->active_bwp ? RC.nrmac[module_id]->preferred_dl_tda[sched_ctrl->active_bwp->bwp_Id][slot] : 1; - const long f = sched_ctrl->active_bwp ? sched_ctrl->search_space->searchSpaceType->choice.ue_Specific->dci_Formats : 0; - ps->nrOfLayers = target_dl_Nl; - if (ps->time_domain_allocation != tda) - nr_set_pdsch_semi_static( - scc, UE_info->CellGroup[UE_id], sched_ctrl->active_bwp, NULL, tda, f, ps); sched_pdsch->mcs = target_dl_mcs; sched_pdsch->Qm = nr_get_Qm_dl(sched_pdsch->mcs, ps->mcsTableIdx); @@ -398,7 +407,7 @@ void nr_preprocessor_phytest(module_id_t module_id, /* mark the corresponding RBs as used */ for (int rb = 0; rb < sched_pdsch->rbSize; rb++) - vrb_map[rb + sched_pdsch->rbStart + BWPStart] = 1; + vrb_map[rb + sched_pdsch->rbStart + BWPStart] = SL_to_bitmap(ps->startSymbolIndex, ps->nrOfSymbols); if ((frame&127) == 0) LOG_D(MAC,"phytest: %d.%d DL mcs %d, DL rbStart %d, DL rbSize %d\n", frame, slot, sched_pdsch->mcs, rbStart,rbSize); } @@ -501,20 +510,21 @@ bool nr_ul_preprocessor_phytest(module_id_t module_id, frame_t frame, sub_frame_ AssertFatal(nr_of_candidates>0,"nr_of_candidates is 0\n"); const int cid = sched_ctrl->coreset->controlResourceSetId; - const uint16_t Y = UE_info->Y[UE_id][cid][slot]; - const int m = UE_info->num_pdcch_cand[UE_id][cid]; - sched_ctrl->cce_index = allocate_nr_CCEs(RC.nrmac[module_id], - sched_ctrl->active_bwp, - sched_ctrl->coreset, - sched_ctrl->aggregation_level, - Y, - m, - nr_of_candidates); + const uint16_t Y = get_Y(cid%3, slot, UE_info->rnti[UE_id]); + + int CCEIndex = find_pdcch_candidate(nr_mac, + CC_id, + sched_ctrl->aggregation_level, + nr_of_candidates, + &sched_ctrl->sched_pdcch, + sched_ctrl->coreset, + Y); + if (sched_ctrl->cce_index < 0) { LOG_E(MAC, "%s(): CCE list not empty, couldn't schedule PUSCH\n", __func__); + nr_mac->pdcch_cand[cid]--; return false; } - UE_info->num_pdcch_cand[UE_id][cid]++; const int mcs = target_ul_mcs; NR_sched_pusch_t *sched_pusch = &sched_ctrl->sched_pusch; @@ -543,6 +553,12 @@ bool nr_ul_preprocessor_phytest(module_id_t module_id, frame_t frame, sub_frame_ >> 3; /* mark the corresponding RBs as used */ + fill_pdcch_vrb_map(nr_mac, + CC_id, + &sched_ctrl->sched_pdcch, + CCEIndex, + sched_ctrl->aggregation_level); + for (int rb = rbStart; rb < rbStart + rbSize; rb++) vrb_map_UL[rb+BWPStart] = 1; return true; diff --git a/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_primitives.c b/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_primitives.c index 949d0d0358e175bb4414ecf976569a9a26ff16ef..a1dfc7c833f8df8eb4b6832602bb750e0b8dca15 100644 --- a/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_primitives.c +++ b/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_primitives.c @@ -159,6 +159,7 @@ NR_ControlResourceSet_t *get_coreset(module_id_t module_idP, NR_SearchSpace_t *ss, NR_SearchSpace__searchSpaceType_PR ss_type) { NR_ControlResourceSetId_t coreset_id = *ss->controlResourceSetId; + if (ss_type == NR_SearchSpace__searchSpaceType_PR_common) { // common search space NR_ControlResourceSet_t *coreset; if(coreset_id == 0) { @@ -208,53 +209,180 @@ NR_SearchSpace_t *get_searchspace(NR_ServingCellConfigCommon_t *scc, AssertFatal(0, "Couldn't find an adequate searchspace bwp_Dedicated %p\n",bwp_Dedicated); } -int allocate_nr_CCEs(gNB_MAC_INST *nr_mac, - NR_BWP_Downlink_t *bwp, - NR_ControlResourceSet_t *coreset, - int aggregation, - uint16_t Y, - int m, - int nr_of_candidates) { +NR_sched_pdcch_t set_pdcch_structure(gNB_MAC_INST *gNB_mac, + NR_SearchSpace_t *ss, + NR_ControlResourceSet_t *coreset, + NR_ServingCellConfigCommon_t *scc, + NR_BWP_t *bwp, + NR_Type0_PDCCH_CSS_config_t *type0_PDCCH_CSS_config) { - int coreset_id = coreset->controlResourceSetId; + int sps; + NR_sched_pdcch_t pdcch; - int *cce_list; - if(bwp == NULL) { - cce_list = nr_mac->cce_list[0][coreset_id]; - } else { - cce_list = nr_mac->cce_list[bwp->bwp_Id][coreset_id]; + AssertFatal(*ss->controlResourceSetId == coreset->controlResourceSetId, + "coreset id in SS %ld does not correspond to the one in coreset %ld", + *ss->controlResourceSetId, coreset->controlResourceSetId); + + if (bwp) { // This is not for SIB1 + if(coreset->controlResourceSetId == 0){ + pdcch.BWPSize = gNB_mac->cset0_bwp_size; + pdcch.BWPStart = gNB_mac->cset0_bwp_start; + } + else { + pdcch.BWPSize = NRRIV2BW(bwp->locationAndBandwidth, MAX_BWP_SIZE); + pdcch.BWPStart = NRRIV2PRBOFFSET(bwp->locationAndBandwidth, MAX_BWP_SIZE); + } + pdcch.SubcarrierSpacing = bwp->subcarrierSpacing; + pdcch.CyclicPrefix = (bwp->cyclicPrefix==NULL) ? 0 : *bwp->cyclicPrefix; + + //AssertFatal(pdcch_scs==kHz15, "PDCCH SCS above 15kHz not allowed if a symbol above 2 is monitored"); + sps = bwp->cyclicPrefix == NULL ? 14 : 12; + } + else { + AssertFatal(type0_PDCCH_CSS_config!=NULL,"type0_PDCCH_CSS_config is null,bwp %p\n",bwp); + pdcch.BWPSize = type0_PDCCH_CSS_config->num_rbs; + pdcch.BWPStart = type0_PDCCH_CSS_config->cset_start_rb; + pdcch.SubcarrierSpacing = type0_PDCCH_CSS_config->scs_pdcch; + pdcch.CyclicPrefix = 0; + sps = 14; } - int n_rb=0; - for (int i=0;i<6;i++) - for (int j=0;j<8;j++) { - n_rb+=((coreset->frequencyDomainResources.buf[i]>>j)&1); + AssertFatal(ss->monitoringSymbolsWithinSlot!=NULL,"ss->monitoringSymbolsWithinSlot is null\n"); + AssertFatal(ss->monitoringSymbolsWithinSlot->buf!=NULL,"ss->monitoringSymbolsWithinSlot->buf is null\n"); + + // for SPS=14 8 MSBs in positions 13 downto 6 + uint16_t monitoringSymbolsWithinSlot = (ss->monitoringSymbolsWithinSlot->buf[0]<<(sps-8)) | + (ss->monitoringSymbolsWithinSlot->buf[1]>>(16-sps)); + + for (int i=0; i<sps; i++) { + if ((monitoringSymbolsWithinSlot>>(sps-1-i))&1) { + pdcch.StartSymbolIndex=i; + break; } - n_rb*=6; + } - uint16_t N_reg = n_rb * coreset->duration; - uint16_t n_CI = 0; + pdcch.DurationSymbols = coreset->duration; - const uint16_t N_cce = N_reg / NR_NB_REG_PER_CCE; - const uint16_t M_s_max = nr_of_candidates; + //cce-REG-MappingType + pdcch.CceRegMappingType = coreset->cce_REG_MappingType.present == NR_ControlResourceSet__cce_REG_MappingType_PR_interleaved? + NFAPI_NR_CCE_REG_MAPPING_INTERLEAVED : NFAPI_NR_CCE_REG_MAPPING_NON_INTERLEAVED; - LOG_D(PHY,"allocate_NR_CCes : bwp_id %d, coreset_id %d : N_cce %d, m %d, nr_of_candidates %d, Y %d\n", - (int)(bwp ? bwp->bwp_Id : 0),coreset_id,N_cce,m,nr_of_candidates, Y); - //PDCCH candidate index m in CORESET exceeds the maximum number of PDCCH candidates - if(m >= nr_of_candidates) - return -1; + if (pdcch.CceRegMappingType == NFAPI_NR_CCE_REG_MAPPING_INTERLEAVED) { + pdcch.RegBundleSize = (coreset->cce_REG_MappingType.choice.interleaved->reg_BundleSize == + NR_ControlResourceSet__cce_REG_MappingType__interleaved__reg_BundleSize_n6) ? 6 : (2+coreset->cce_REG_MappingType.choice.interleaved->reg_BundleSize); + pdcch.InterleaverSize = (coreset->cce_REG_MappingType.choice.interleaved->interleaverSize == + NR_ControlResourceSet__cce_REG_MappingType__interleaved__interleaverSize_n6) ? 6 : (2+coreset->cce_REG_MappingType.choice.interleaved->interleaverSize); + AssertFatal(scc->physCellId != NULL,"scc->physCellId is null\n"); + pdcch.ShiftIndex = coreset->cce_REG_MappingType.choice.interleaved->shiftIndex != NULL ? *coreset->cce_REG_MappingType.choice.interleaved->shiftIndex : *scc->physCellId; + } + else { + pdcch.RegBundleSize = 6; + pdcch.InterleaverSize = 0; + pdcch.ShiftIndex = 0; + } + + int N_rb = 0; // nb of rbs of coreset per symbol + for (int i=0;i<6;i++) { + for (int t=0;t<8;t++) { + N_rb+=((coreset->frequencyDomainResources.buf[i]>>t)&1); + } + } + pdcch.n_rb = N_rb*=6; // each bit of frequencyDomainResources represents 6 PRBs - int first_cce = aggregation * (( Y + CEILIDIV((m*N_cce),(aggregation*M_s_max)) + n_CI ) % CEILIDIV(N_cce,aggregation)); + return pdcch; +} - for (int i=0;i<aggregation;i++) - if (cce_list[first_cce+i] != 0) return(-1); - - for (int i=0;i<aggregation;i++) cce_list[first_cce+i] = 1; - return(first_cce); +int cce_to_reg_interleaving(const int R, int k, int n_shift, const int C, int L, const int N_regs) { + int f; // interleaving function + if(R==0) + f = k; + else { + int c = k/R; + int r = k%R; + f = (r*C + c + n_shift)%(N_regs/L); + } + return f; } +int find_pdcch_candidate(gNB_MAC_INST *mac, + int cc_id, + int aggregation, + int nr_of_candidates, + NR_sched_pdcch_t *pdcch, + NR_ControlResourceSet_t *coreset, + uint16_t Y){ + + uint16_t *vrb_map = mac->common_channels[cc_id].vrb_map; + const int next_cand = mac->pdcch_cand[coreset->controlResourceSetId]; + const int N_ci = 0; + + if(next_cand>=nr_of_candidates) { + LOG_D(NR_MAC,"No more available candidates for this coreset\n"); + return -1; + } + + const int N_rb = pdcch->n_rb; // nb of rbs of coreset per symbol + const int N_symb = coreset->duration; // nb of coreset symbols + const int N_regs = N_rb*N_symb; // nb of REGs per coreset + const int N_cces = N_regs / NR_NB_REG_PER_CCE; // nb of cces in coreset + const int R = pdcch->InterleaverSize; + const int L = pdcch->RegBundleSize; + const int C = R>0 ? N_regs/(L*R) : 0; + const int B_rb = L/N_symb; // nb of RBs occupied by each REG bundle + + // loop over all the available candidates + // this implements TS 38.211 Sec. 7.3.2.2 + for(int m=next_cand; m<nr_of_candidates; m++) { // loop over candidates + bool taken = false; // flag if the resource for a given candidate are taken + int first_cce = aggregation * (( Y + CEILIDIV((m*N_cces),(aggregation*nr_of_candidates)) + N_ci ) % CEILIDIV(N_cces,aggregation)); + for (int j=first_cce; (j<first_cce+aggregation) && !taken; j++) { // loop over CCEs + for (int k=6*j/L; (k<(6*j/L+6/L)) && !taken; k++) { // loop over REG bundles + int f = cce_to_reg_interleaving(R, k, pdcch->ShiftIndex, C, L, N_regs); + for(int rb=0; rb<B_rb; rb++) { // loop over the RBs of the bundle + if(vrb_map[pdcch->BWPStart + f*B_rb + rb]&SL_to_bitmap(pdcch->StartSymbolIndex,N_symb)) { + taken = true; + break; + } + } + } + } + if(!taken){ + mac->pdcch_cand[coreset->controlResourceSetId] = m++; // using candidate m, next available is m+1 + return first_cce; + } + } + return -1; +} + +void fill_pdcch_vrb_map(gNB_MAC_INST *mac, + int CC_id, + NR_sched_pdcch_t *pdcch, + int first_cce, + int aggregation){ + + uint16_t *vrb_map = mac->common_channels[CC_id].vrb_map; + + int N_rb = pdcch->n_rb; // nb of rbs of coreset per symbol + int L = pdcch->RegBundleSize; + int R = pdcch->InterleaverSize; + int n_shift = pdcch->ShiftIndex; + int N_symb = pdcch->DurationSymbols; + int N_regs = N_rb*N_symb; // nb of REGs per coreset + int B_rb = L/N_symb; // nb of RBs occupied by each REG bundle + int C = R>0 ? N_regs/(L*R) : 0; + + for (int j=first_cce; j<first_cce+aggregation; j++) { // loop over CCEs + for (int k=6*j/L; k<(6*j/L+6/L); k++) { // loop over REG bundles + int f = cce_to_reg_interleaving(R, k, n_shift, C, L, N_regs); + for(int rb=0; rb<B_rb; rb++) // loop over the RBs of the bundle + vrb_map[pdcch->BWPStart + f*B_rb + rb] |= SL_to_bitmap(pdcch->StartSymbolIndex, N_symb); + } + } +} + + bool nr_find_nb_rb(uint16_t Qm, uint16_t R, uint16_t nb_symb_sch, @@ -351,7 +479,7 @@ void nr_set_pdsch_semi_static(const NR_ServingCellConfigCommon_t *scc, void nr_set_pusch_semi_static(const NR_ServingCellConfigCommon_t *scc, const NR_BWP_Uplink_t *ubwp, - const NR_BWP_UplinkDedicated_t *ubwpd, + const NR_BWP_UplinkDedicated_t *ubwpd, long dci_format, int tda, uint8_t num_dmrs_cdm_grps_no_data, @@ -723,81 +851,32 @@ int nr_get_default_pucch_res(int pucch_ResourceCommon) { return(default_pucch_csset[pucch_ResourceCommon]); } -void nr_configure_pdcch(gNB_MAC_INST *gNB_mac, - nfapi_nr_dl_tti_pdcch_pdu_rel15_t *pdcch_pdu, - NR_SearchSpace_t *ss, + + +void nr_configure_pdcch(nfapi_nr_dl_tti_pdcch_pdu_rel15_t *pdcch_pdu, NR_ControlResourceSet_t *coreset, - NR_ServingCellConfigCommon_t *scc, NR_BWP_t *bwp, - NR_Type0_PDCCH_CSS_config_t *type0_PDCCH_CSS_config) { + NR_sched_pdcch_t *pdcch) { - int sps; - AssertFatal(*ss->controlResourceSetId == coreset->controlResourceSetId, - "coreset id in SS %ld does not correspond to the one in coreset %ld", - *ss->controlResourceSetId, coreset->controlResourceSetId); - if (bwp) { // This is not for SIB1 - if(coreset->controlResourceSetId == 0){ - pdcch_pdu->BWPSize = gNB_mac->cset0_bwp_size; - pdcch_pdu->BWPStart = gNB_mac->cset0_bwp_start; - } - else { - pdcch_pdu->BWPSize = NRRIV2BW(bwp->locationAndBandwidth, MAX_BWP_SIZE); - pdcch_pdu->BWPStart = NRRIV2PRBOFFSET(bwp->locationAndBandwidth, MAX_BWP_SIZE); - } - pdcch_pdu->SubcarrierSpacing = bwp->subcarrierSpacing; - pdcch_pdu->CyclicPrefix = (bwp->cyclicPrefix==NULL) ? 0 : *bwp->cyclicPrefix; - - //AssertFatal(pdcch_scs==kHz15, "PDCCH SCS above 15kHz not allowed if a symbol above 2 is monitored"); - sps = bwp->cyclicPrefix == NULL ? 14 : 12; - } - else { - AssertFatal(type0_PDCCH_CSS_config!=NULL,"type0_PDCCH_CSS_config is null,bwp %p\n",bwp); - pdcch_pdu->BWPSize = type0_PDCCH_CSS_config->num_rbs; - pdcch_pdu->BWPStart = type0_PDCCH_CSS_config->cset_start_rb; - pdcch_pdu->SubcarrierSpacing = type0_PDCCH_CSS_config->scs_pdcch; - pdcch_pdu->CyclicPrefix = 0; - sps = 14; - } - - AssertFatal(ss->monitoringSymbolsWithinSlot!=NULL,"ss->monitoringSymbolsWithinSlot is null\n"); - AssertFatal(ss->monitoringSymbolsWithinSlot->buf!=NULL,"ss->monitoringSymbolsWithinSlot->buf is null\n"); - - // for SPS=14 8 MSBs in positions 13 downto 6 - uint16_t monitoringSymbolsWithinSlot = (ss->monitoringSymbolsWithinSlot->buf[0]<<(sps-8)) | - (ss->monitoringSymbolsWithinSlot->buf[1]>>(16-sps)); - - for (int i=0; i<sps; i++) { - if ((monitoringSymbolsWithinSlot>>(sps-1-i))&1) { - pdcch_pdu->StartSymbolIndex=i; - break; - } - } + pdcch_pdu->BWPSize = pdcch->BWPSize; + pdcch_pdu->BWPStart = pdcch->BWPStart; + pdcch_pdu->SubcarrierSpacing = pdcch->SubcarrierSpacing; + pdcch_pdu->CyclicPrefix = pdcch->CyclicPrefix; + pdcch_pdu->StartSymbolIndex = pdcch->StartSymbolIndex; pdcch_pdu->DurationSymbols = coreset->duration; for (int i=0;i<6;i++) pdcch_pdu->FreqDomainResource[i] = coreset->frequencyDomainResources.buf[i]; - LOG_D(MAC,"Coreset : BWPstart %d, BWPsize %d, SCS %d, freq %x, , duration %d, \n",pdcch_pdu->BWPStart,pdcch_pdu->BWPSize,(int)pdcch_pdu->SubcarrierSpacing,(int)coreset->frequencyDomainResources.buf[0],(int)coreset->duration); - - //cce-REG-MappingType - pdcch_pdu->CceRegMappingType = coreset->cce_REG_MappingType.present == NR_ControlResourceSet__cce_REG_MappingType_PR_interleaved? - NFAPI_NR_CCE_REG_MAPPING_INTERLEAVED : NFAPI_NR_CCE_REG_MAPPING_NON_INTERLEAVED; + LOG_D(MAC,"Coreset : BWPstart %d, BWPsize %d, SCS %d, freq %x, , duration %d, \n", + pdcch_pdu->BWPStart,pdcch_pdu->BWPSize,(int)pdcch_pdu->SubcarrierSpacing,(int)coreset->frequencyDomainResources.buf[0],(int)coreset->duration); - if (pdcch_pdu->CceRegMappingType == NFAPI_NR_CCE_REG_MAPPING_INTERLEAVED) { - pdcch_pdu->RegBundleSize = (coreset->cce_REG_MappingType.choice.interleaved->reg_BundleSize == - NR_ControlResourceSet__cce_REG_MappingType__interleaved__reg_BundleSize_n6) ? 6 : (2+coreset->cce_REG_MappingType.choice.interleaved->reg_BundleSize); - pdcch_pdu->InterleaverSize = (coreset->cce_REG_MappingType.choice.interleaved->interleaverSize == - NR_ControlResourceSet__cce_REG_MappingType__interleaved__interleaverSize_n6) ? 6 : (2+coreset->cce_REG_MappingType.choice.interleaved->interleaverSize); - AssertFatal(scc->physCellId != NULL,"scc->physCellId is null\n"); - pdcch_pdu->ShiftIndex = coreset->cce_REG_MappingType.choice.interleaved->shiftIndex != NULL ? *coreset->cce_REG_MappingType.choice.interleaved->shiftIndex : *scc->physCellId; - } - else { - pdcch_pdu->RegBundleSize = 0; - pdcch_pdu->InterleaverSize = 0; - pdcch_pdu->ShiftIndex = 0; - } + pdcch_pdu->CceRegMappingType = pdcch->CceRegMappingType; + pdcch_pdu->RegBundleSize = pdcch->RegBundleSize; + pdcch_pdu->InterleaverSize = pdcch->InterleaverSize; + pdcch_pdu->ShiftIndex = pdcch->ShiftIndex; if(coreset->controlResourceSetId == 0) { if(bwp == NULL) @@ -1849,19 +1928,18 @@ int find_nr_UE_id(module_id_t mod_idP, rnti_t rntiP) return -1; } -void set_Y(int Y[3][160], rnti_t rnti) { +uint16_t get_Y(int cid, int slot, rnti_t rnti) { + const int A[3] = {39827, 39829, 39839}; const int D = 65537; + int Y; - Y[0][0] = (A[0] * rnti) % D; - Y[1][0] = (A[1] * rnti) % D; - Y[2][0] = (A[2] * rnti) % D; + Y = (A[cid] * rnti) % D; - for (int s = 1; s < 160; s++) { - Y[0][s] = (A[0] * Y[0][s - 1]) % D; - Y[1][s] = (A[1] * Y[1][s - 1]) % D; - Y[2][s] = (A[2] * Y[2][s - 1]) % D; - } + for (int s = 0; s < slot; s++) + Y = (A[cid] * Y) % D; + + return Y; } int find_nr_RA_id(module_id_t mod_idP, int CC_idP, rnti_t rntiP) { @@ -1925,7 +2003,7 @@ int add_new_nr_ue(module_id_t mod_idP, rnti_t rntiP, NR_CellGroupConfig_t *CellG { NR_ServingCellConfigCommon_t *scc = RC.nrmac[mod_idP]->common_channels[0].ServingCellConfigCommon; NR_UE_info_t *UE_info = &RC.nrmac[mod_idP]->UE_info; - LOG_I(NR_MAC, "[gNB %d] Adding UE with rnti %x (num_UEs %d)\n", + LOG_I(NR_MAC, "[gNB %d] Adding UE with rnti 0x%04x (num_UEs %d)\n", mod_idP, rntiP, UE_info->num_UEs); @@ -1945,7 +2023,6 @@ int add_new_nr_ue(module_id_t mod_idP, rnti_t rntiP, NR_CellGroupConfig_t *CellG UE_info->CellGroup[UE_id] = CellGroup; add_nr_list(&UE_info->list, UE_id); memset(&UE_info->mac_stats[UE_id], 0, sizeof(NR_mac_stats_t)); - set_Y(UE_info->Y[UE_id], rntiP); if (CellGroup && CellGroup->spCellConfig && CellGroup->spCellConfig->spCellConfigDedicated) compute_csi_bitlen (CellGroup->spCellConfig->spCellConfigDedicated->csi_MeasConfig->choice.setup, UE_info, UE_id, mod_idP); NR_UE_sched_ctrl_t *sched_ctrl = &UE_info->UE_sched_ctrl[UE_id]; @@ -1961,6 +2038,11 @@ int add_new_nr_ue(module_id_t mod_idP, rnti_t rntiP, NR_CellGroupConfig_t *CellG sched_ctrl->pucch_consecutive_dtx_cnt = 0; sched_ctrl->pusch_consecutive_dtx_cnt = 0; sched_ctrl->ul_failure = 0; + + sched_ctrl->sched_srs.frame = -1; + sched_ctrl->sched_srs.slot = -1; + sched_ctrl->sched_srs.srs_scheduled = false; + /* set illegal time domain allocation to force recomputation of all fields */ sched_ctrl->pdsch_semi_static.time_domain_allocation = -1; sched_ctrl->pusch_semi_static.time_domain_allocation = -1; @@ -1971,8 +2053,12 @@ int add_new_nr_ue(module_id_t mod_idP, rnti_t rntiP, NR_CellGroupConfig_t *CellG if (bwpList) AssertFatal(bwpList->list.count == 1, "downlinkBWP_ToAddModList has %d BWP!\n", bwpList->list.count); + const int bwp_id = servingCellConfig ? *servingCellConfig->firstActiveDownlinkBWP_Id : 0; sched_ctrl->active_bwp = bwpList && bwp_id > 0 ? bwpList->list.array[bwp_id - 1] : NULL; + NR_BWP_t *genericParameters = sched_ctrl->active_bwp ? + &sched_ctrl->active_bwp->bwp_Common->genericParameters: + &scc->uplinkConfigCommon->initialUplinkBWP->genericParameters; const int target_ss = sched_ctrl->active_bwp ? NR_SearchSpace__searchSpaceType_PR_ue_Specific : NR_SearchSpace__searchSpaceType_PR_common; sched_ctrl->search_space = get_searchspace(scc, sched_ctrl->active_bwp ? sched_ctrl->active_bwp->bwp_Dedicated : NULL, @@ -1980,6 +2066,12 @@ int add_new_nr_ue(module_id_t mod_idP, rnti_t rntiP, NR_CellGroupConfig_t *CellG sched_ctrl->coreset = get_coreset(mod_idP, scc, sched_ctrl->active_bwp ? (void*)sched_ctrl->active_bwp->bwp_Dedicated : NULL, sched_ctrl->search_space, target_ss); + sched_ctrl->sched_pdcch = set_pdcch_structure(RC.nrmac[mod_idP], + sched_ctrl->search_space, + sched_ctrl->coreset, + scc, + genericParameters, + NULL); const struct NR_UplinkConfig__uplinkBWP_ToAddModList *ubwpList = servingCellConfig ? servingCellConfig->uplinkConfig->uplinkBWP_ToAddModList : NULL; if (ubwpList) AssertFatal(ubwpList->list.count == 1, "uplinkBWP_ToAddModList has %d BWP!\n", @@ -2063,7 +2155,7 @@ void mac_remove_nr_ue(module_id_t mod_id, rnti_t rnti) destroy_nr_list(&sched_ctrl->available_ul_harq); destroy_nr_list(&sched_ctrl->feedback_ul_harq); destroy_nr_list(&sched_ctrl->retrans_ul_harq); - LOG_I(NR_MAC, "[gNB %d] Remove NR UE_id %d : rnti %x\n", + LOG_I(NR_MAC, "[gNB %d] Remove NR UE_id %d: rnti 0x%04x\n", mod_id, UE_id, rnti); @@ -2203,6 +2295,7 @@ void get_pdsch_to_harq_feedback(int Mod_idP, } + void nr_csirs_scheduling(int Mod_idP, frame_t frame, sub_frame_t slot, @@ -2278,20 +2371,20 @@ void nr_csirs_scheduling(int Mod_idP, csirs_pdu_rel15->row = 1; csirs_pdu_rel15->freq_domain = ((resourceMapping.frequencyDomainAllocation.choice.row1.buf[0])>>4)&0x0f; for (int rb = csirs_pdu_rel15->start_rb; rb < (csirs_pdu_rel15->start_rb + csirs_pdu_rel15->nr_of_rbs); rb++) - vrb_map[rb+csirs_pdu_rel15->bwp_start] |= (1 << csirs_pdu_rel15->symb_l0); + vrb_map[rb+csirs_pdu_rel15->bwp_start] |= SL_to_bitmap(csirs_pdu_rel15->symb_l0, 1); break; case NR_CSI_RS_ResourceMapping__frequencyDomainAllocation_PR_row2: csirs_pdu_rel15->row = 2; csirs_pdu_rel15->freq_domain = (((resourceMapping.frequencyDomainAllocation.choice.row2.buf[1]>>4)&0x0f) | ((resourceMapping.frequencyDomainAllocation.choice.row2.buf[0]<<8)&0xff0)); for (int rb = csirs_pdu_rel15->start_rb; rb < (csirs_pdu_rel15->start_rb + csirs_pdu_rel15->nr_of_rbs); rb++) - vrb_map[rb+csirs_pdu_rel15->bwp_start] |= (1 << csirs_pdu_rel15->symb_l0); + vrb_map[rb+csirs_pdu_rel15->bwp_start] |= SL_to_bitmap(csirs_pdu_rel15->symb_l0, 1); break; case NR_CSI_RS_ResourceMapping__frequencyDomainAllocation_PR_row4: csirs_pdu_rel15->row = 4; csirs_pdu_rel15->freq_domain = ((resourceMapping.frequencyDomainAllocation.choice.row4.buf[0])>>5)&0x07; for (int rb = csirs_pdu_rel15->start_rb; rb < (csirs_pdu_rel15->start_rb + csirs_pdu_rel15->nr_of_rbs); rb++) - vrb_map[rb+csirs_pdu_rel15->bwp_start] |= (1 << csirs_pdu_rel15->symb_l0); + vrb_map[rb+csirs_pdu_rel15->bwp_start] |= SL_to_bitmap(csirs_pdu_rel15->symb_l0, 1); break; case NR_CSI_RS_ResourceMapping__frequencyDomainAllocation_PR_other: csirs_pdu_rel15->freq_domain = ((resourceMapping.frequencyDomainAllocation.choice.other.buf[0])>>2)&0x3f; @@ -2302,18 +2395,18 @@ void nr_csirs_scheduling(int Mod_idP, case NR_CSI_RS_ResourceMapping__nrofPorts_p2: csirs_pdu_rel15->row = 3; for (int rb = csirs_pdu_rel15->start_rb; rb < (csirs_pdu_rel15->start_rb + csirs_pdu_rel15->nr_of_rbs); rb++) - vrb_map[rb+csirs_pdu_rel15->bwp_start] |= (1 << csirs_pdu_rel15->symb_l0); + vrb_map[rb+csirs_pdu_rel15->bwp_start] |= SL_to_bitmap(csirs_pdu_rel15->symb_l0, 1); break; case NR_CSI_RS_ResourceMapping__nrofPorts_p4: csirs_pdu_rel15->row = 5; for (int rb = csirs_pdu_rel15->start_rb; rb < (csirs_pdu_rel15->start_rb + csirs_pdu_rel15->nr_of_rbs); rb++) - vrb_map[rb+csirs_pdu_rel15->bwp_start] |= ((1 << csirs_pdu_rel15->symb_l0) | (2 << csirs_pdu_rel15->symb_l0)); + vrb_map[rb+csirs_pdu_rel15->bwp_start] |= SL_to_bitmap(csirs_pdu_rel15->symb_l0, 2); break; case NR_CSI_RS_ResourceMapping__nrofPorts_p8: if (resourceMapping.cdm_Type == NR_CSI_RS_ResourceMapping__cdm_Type_cdm4_FD2_TD2) { csirs_pdu_rel15->row = 8; for (int rb = csirs_pdu_rel15->start_rb; rb < (csirs_pdu_rel15->start_rb + csirs_pdu_rel15->nr_of_rbs); rb++) - vrb_map[rb+csirs_pdu_rel15->bwp_start] |= ((1 << csirs_pdu_rel15->symb_l0) | (2 << csirs_pdu_rel15->symb_l0)); + vrb_map[rb+csirs_pdu_rel15->bwp_start] |= SL_to_bitmap(csirs_pdu_rel15->symb_l0, 2); } else{ int num_k = 0; @@ -2322,12 +2415,12 @@ void nr_csirs_scheduling(int Mod_idP, if(num_k==4) { csirs_pdu_rel15->row = 6; for (int rb = csirs_pdu_rel15->start_rb; rb < (csirs_pdu_rel15->start_rb + csirs_pdu_rel15->nr_of_rbs); rb++) - vrb_map[rb+csirs_pdu_rel15->bwp_start] |= (1 << csirs_pdu_rel15->symb_l0); + vrb_map[rb+csirs_pdu_rel15->bwp_start] |= SL_to_bitmap(csirs_pdu_rel15->symb_l0, 1); } else { csirs_pdu_rel15->row = 7; for (int rb = csirs_pdu_rel15->start_rb; rb < (csirs_pdu_rel15->start_rb + csirs_pdu_rel15->nr_of_rbs); rb++) - vrb_map[rb+csirs_pdu_rel15->bwp_start] |= ((1 << csirs_pdu_rel15->symb_l0) | (2 << csirs_pdu_rel15->symb_l0)); + vrb_map[rb+csirs_pdu_rel15->bwp_start] |= SL_to_bitmap(csirs_pdu_rel15->symb_l0, 2); } } break; @@ -2335,12 +2428,12 @@ void nr_csirs_scheduling(int Mod_idP, if (resourceMapping.cdm_Type == NR_CSI_RS_ResourceMapping__cdm_Type_cdm4_FD2_TD2) { csirs_pdu_rel15->row = 10; for (int rb = csirs_pdu_rel15->start_rb; rb < (csirs_pdu_rel15->start_rb + csirs_pdu_rel15->nr_of_rbs); rb++) - vrb_map[rb+csirs_pdu_rel15->bwp_start] |= ((1 << csirs_pdu_rel15->symb_l0) | (2 << csirs_pdu_rel15->symb_l0)); + vrb_map[rb+csirs_pdu_rel15->bwp_start] |= SL_to_bitmap(csirs_pdu_rel15->symb_l0, 2); } else { csirs_pdu_rel15->row = 9; for (int rb = csirs_pdu_rel15->start_rb; rb < (csirs_pdu_rel15->start_rb + csirs_pdu_rel15->nr_of_rbs); rb++) - vrb_map[rb+csirs_pdu_rel15->bwp_start] |= (1 << csirs_pdu_rel15->symb_l0); + vrb_map[rb+csirs_pdu_rel15->bwp_start] |= SL_to_bitmap(csirs_pdu_rel15->symb_l0, 1); } break; case NR_CSI_RS_ResourceMapping__nrofPorts_p16: @@ -2349,24 +2442,24 @@ void nr_csirs_scheduling(int Mod_idP, else csirs_pdu_rel15->row = 11; for (int rb = csirs_pdu_rel15->start_rb; rb < (csirs_pdu_rel15->start_rb + csirs_pdu_rel15->nr_of_rbs); rb++) - vrb_map[rb+csirs_pdu_rel15->bwp_start] |= ((1 << csirs_pdu_rel15->symb_l0) | (2 << csirs_pdu_rel15->symb_l0)); + vrb_map[rb+csirs_pdu_rel15->bwp_start] |= SL_to_bitmap(csirs_pdu_rel15->symb_l0, 2); break; case NR_CSI_RS_ResourceMapping__nrofPorts_p24: if (resourceMapping.cdm_Type == NR_CSI_RS_ResourceMapping__cdm_Type_cdm4_FD2_TD2) { csirs_pdu_rel15->row = 14; for (int rb = csirs_pdu_rel15->start_rb; rb < (csirs_pdu_rel15->start_rb + csirs_pdu_rel15->nr_of_rbs); rb++) - vrb_map[rb+csirs_pdu_rel15->bwp_start] |= ((3 << csirs_pdu_rel15->symb_l0) | (3 << csirs_pdu_rel15->symb_l1)); + vrb_map[rb+csirs_pdu_rel15->bwp_start] |= (SL_to_bitmap(csirs_pdu_rel15->symb_l0, 2) | SL_to_bitmap(csirs_pdu_rel15->symb_l1, 2)); } else{ if (resourceMapping.cdm_Type == NR_CSI_RS_ResourceMapping__cdm_Type_cdm8_FD2_TD4) { csirs_pdu_rel15->row = 15; for (int rb = csirs_pdu_rel15->start_rb; rb < (csirs_pdu_rel15->start_rb + csirs_pdu_rel15->nr_of_rbs); rb++) - vrb_map[rb+csirs_pdu_rel15->bwp_start] |= (7 << csirs_pdu_rel15->symb_l0); + vrb_map[rb+csirs_pdu_rel15->bwp_start] |= SL_to_bitmap(csirs_pdu_rel15->symb_l0, 3); } else { csirs_pdu_rel15->row = 13; for (int rb = csirs_pdu_rel15->start_rb; rb < (csirs_pdu_rel15->start_rb + csirs_pdu_rel15->nr_of_rbs); rb++) - vrb_map[rb+csirs_pdu_rel15->bwp_start] |= ((3 << csirs_pdu_rel15->symb_l0) | (3 << csirs_pdu_rel15->symb_l1)); + vrb_map[rb+csirs_pdu_rel15->bwp_start] |= (SL_to_bitmap(csirs_pdu_rel15->symb_l0, 2) | SL_to_bitmap(csirs_pdu_rel15->symb_l1, 2)); } } break; @@ -2374,18 +2467,18 @@ void nr_csirs_scheduling(int Mod_idP, if (resourceMapping.cdm_Type == NR_CSI_RS_ResourceMapping__cdm_Type_cdm4_FD2_TD2) { csirs_pdu_rel15->row = 17; for (int rb = csirs_pdu_rel15->start_rb; rb < (csirs_pdu_rel15->start_rb + csirs_pdu_rel15->nr_of_rbs); rb++) - vrb_map[rb+csirs_pdu_rel15->bwp_start] |= ((3 << csirs_pdu_rel15->symb_l0) | (3 << csirs_pdu_rel15->symb_l1)); + vrb_map[rb+csirs_pdu_rel15->bwp_start] |= (SL_to_bitmap(csirs_pdu_rel15->symb_l0, 2) | SL_to_bitmap(csirs_pdu_rel15->symb_l1, 2)); } else{ if (resourceMapping.cdm_Type == NR_CSI_RS_ResourceMapping__cdm_Type_cdm8_FD2_TD4) { csirs_pdu_rel15->row = 18; for (int rb = csirs_pdu_rel15->start_rb; rb < (csirs_pdu_rel15->start_rb + csirs_pdu_rel15->nr_of_rbs); rb++) - vrb_map[rb+csirs_pdu_rel15->bwp_start] |= (7 << csirs_pdu_rel15->symb_l0); + vrb_map[rb+csirs_pdu_rel15->bwp_start] |= SL_to_bitmap(csirs_pdu_rel15->symb_l0, 3); } else { csirs_pdu_rel15->row = 16; for (int rb = csirs_pdu_rel15->start_rb; rb < (csirs_pdu_rel15->start_rb + csirs_pdu_rel15->nr_of_rbs); rb++) - vrb_map[rb+csirs_pdu_rel15->bwp_start] |= ((3 << csirs_pdu_rel15->symb_l0) | (3 << csirs_pdu_rel15->symb_l1)); + vrb_map[rb+csirs_pdu_rel15->bwp_start] |= (SL_to_bitmap(csirs_pdu_rel15->symb_l0, 2) | SL_to_bitmap(csirs_pdu_rel15->symb_l1, 2)); } } break; @@ -2403,38 +2496,6 @@ void nr_csirs_scheduling(int Mod_idP, } } -bool find_free_CCE(module_id_t module_id, - sub_frame_t slot, - int UE_id){ - NR_UE_sched_ctrl_t *sched_ctrl = &RC.nrmac[module_id]->UE_info.UE_sched_ctrl[UE_id]; - uint8_t nr_of_candidates; - for (int i=0; i<5; i++) { - // for now taking the lowest value among the available aggregation levels - find_aggregation_candidates(&sched_ctrl->aggregation_level, - &nr_of_candidates, - sched_ctrl->search_space, - 1<<i); - if(nr_of_candidates>0) break; - } - AssertFatal(nr_of_candidates>0,"nr_of_candidates is 0\n"); - const int cid = sched_ctrl->coreset->controlResourceSetId; - const uint16_t Y = RC.nrmac[module_id]->UE_info.Y[UE_id][cid][slot]; - const int m = RC.nrmac[module_id]->UE_info.num_pdcch_cand[UE_id][cid]; - if (UE_id >= 0) LOG_D(NR_MAC,"calling allocate_nr_CCEs with L %d, nr_of_candidates %d, Y %x\n",sched_ctrl->aggregation_level,nr_of_candidates,Y); - sched_ctrl->cce_index = allocate_nr_CCEs(RC.nrmac[module_id], - sched_ctrl->active_bwp, - sched_ctrl->coreset, - sched_ctrl->aggregation_level, - Y, - m, - nr_of_candidates); - if (sched_ctrl->cce_index < 0) - return false; - - RC.nrmac[module_id]->UE_info.num_pdcch_cand[UE_id][cid]++; - return true; -} - /*void fill_nfapi_coresets_and_searchspaces(NR_CellGroupConfig_t *cg, nfapi_nr_coreset_t *coreset, diff --git a/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_srs.c b/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_srs.c new file mode 100644 index 0000000000000000000000000000000000000000..a2b27357dd99dbee1883860d753e7a512986bf28 --- /dev/null +++ b/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_srs.c @@ -0,0 +1,186 @@ +/* + * 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 gNB_scheduler_srs.c + * \brief MAC procedures related to SRS + * \date 2021 + * \version 1.0 + */ + +#include <softmodem-common.h> +#include "NR_MAC_gNB/nr_mac_gNB.h" +#include "NR_MAC_COMMON/nr_mac_extern.h" +#include "NR_MAC_gNB/mac_proto.h" +#include "common/ran_context.h" +#include "nfapi/oai_integration/vendor_ext.h" + +extern RAN_CONTEXT_t RC; + +void nr_configure_srs(nfapi_nr_srs_pdu_t *srs_pdu, int module_id, int CC_id, int UE_id, NR_SRS_Resource_t *srs_resource) { + + gNB_MAC_INST *nrmac = RC.nrmac[module_id]; + NR_ServingCellConfigCommon_t *scc = nrmac->common_channels[CC_id].ServingCellConfigCommon; + NR_UE_info_t *UE_info = &nrmac->UE_info; + NR_UE_sched_ctrl_t *sched_ctrl = &UE_info->UE_sched_ctrl[UE_id]; + + NR_BWP_t ubwp = sched_ctrl->active_ubwp ? + sched_ctrl->active_ubwp->bwp_Common->genericParameters : + scc->uplinkConfigCommon->initialUplinkBWP->genericParameters; + + srs_pdu->rnti = UE_info->rnti[UE_id]; + srs_pdu->handle = 0; + srs_pdu->bwp_size = NRRIV2BW(ubwp.locationAndBandwidth, MAX_BWP_SIZE);; + srs_pdu->bwp_start = NRRIV2PRBOFFSET(ubwp.locationAndBandwidth, MAX_BWP_SIZE);; + srs_pdu->subcarrier_spacing = ubwp.subcarrierSpacing; + srs_pdu->cyclic_prefix = 0; + srs_pdu->num_ant_ports = srs_resource->nrofSRS_Ports; + srs_pdu->num_symbols = srs_resource->resourceMapping.nrofSymbols; + srs_pdu->num_repetitions = srs_resource->resourceMapping.repetitionFactor; + srs_pdu->time_start_position = srs_resource->resourceMapping.startPosition; + srs_pdu->config_index = srs_resource->freqHopping.c_SRS; + srs_pdu->sequence_id = srs_resource->sequenceId; + srs_pdu->bandwidth_index = srs_resource->freqHopping.b_SRS; + srs_pdu->comb_size = srs_resource->transmissionComb.present - 1; + + switch(srs_resource->transmissionComb.present) { + case NR_SRS_Resource__transmissionComb_PR_n2: + srs_pdu->comb_offset = srs_resource->transmissionComb.choice.n2->combOffset_n2; + srs_pdu->cyclic_shift = srs_resource->transmissionComb.choice.n2->cyclicShift_n2; + break; + case NR_SRS_Resource__transmissionComb_PR_n4: + srs_pdu->comb_offset = srs_resource->transmissionComb.choice.n4->combOffset_n4; + srs_pdu->cyclic_shift = srs_resource->transmissionComb.choice.n4->cyclicShift_n4; + break; + default: + LOG_W(NR_MAC, "Invalid or not implemented comb_size!\n"); + } + + srs_pdu->frequency_position = srs_resource->freqDomainPosition; + srs_pdu->frequency_shift = srs_resource->freqDomainShift; + srs_pdu->frequency_hopping = srs_resource->freqHopping.b_hop; + srs_pdu->group_or_sequence_hopping = srs_resource->groupOrSequenceHopping; + srs_pdu->resource_type = srs_resource->resourceType.present - 1; + srs_pdu->t_srs = srs_period[srs_resource->resourceType.choice.periodic->periodicityAndOffset_p.present]; + srs_pdu->t_offset = get_nr_srs_offset(srs_resource->resourceType.choice.periodic->periodicityAndOffset_p); +} + +void nr_fill_nfapi_srs(int module_id, int CC_id, int UE_id, sub_frame_t slot, NR_SRS_Resource_t *srs_resource) { + + nfapi_nr_ul_tti_request_t *future_ul_tti_req = &RC.nrmac[module_id]->UL_tti_req_ahead[0][slot]; + + future_ul_tti_req->pdus_list[future_ul_tti_req->n_pdus].pdu_type = NFAPI_NR_UL_CONFIG_SRS_PDU_TYPE; + future_ul_tti_req->pdus_list[future_ul_tti_req->n_pdus].pdu_size = sizeof(nfapi_nr_srs_pdu_t); + nfapi_nr_srs_pdu_t *srs_pdu = &future_ul_tti_req->pdus_list[future_ul_tti_req->n_pdus].srs_pdu; + memset(srs_pdu, 0, sizeof(nfapi_nr_srs_pdu_t)); + future_ul_tti_req->n_pdus += 1; + + nr_configure_srs(srs_pdu, module_id, CC_id, UE_id, srs_resource); +} + +/******************************************************************* +* +* NAME : nr_schedule_srs +* +* PARAMETERS : module id +* frame number for possible SRS reception +* +* DESCRIPTION : It informs the PHY layer that has an SRS to receive. +* Only for periodic scheduling yet. +* +*********************************************************************/ +void nr_schedule_srs(int module_id, frame_t frame) { + + gNB_MAC_INST *nrmac = RC.nrmac[module_id]; + NR_UE_info_t *UE_info = &nrmac->UE_info; + const NR_list_t *UE_list = &UE_info->list; + + for (int UE_id = UE_list->head; UE_id >= 0; UE_id = UE_list->next[UE_id]) { + + const int CC_id = 0; + NR_ServingCellConfigCommon_t *scc = RC.nrmac[module_id]->common_channels[CC_id].ServingCellConfigCommon; + NR_CellGroupConfig_t *cg = UE_info->CellGroup[UE_id]; + NR_UE_sched_ctrl_t *sched_ctrl = &UE_info->UE_sched_ctrl[UE_id]; + + sched_ctrl->sched_srs.frame = -1; + sched_ctrl->sched_srs.slot = -1; + sched_ctrl->sched_srs.srs_scheduled = false; + + if(!UE_info->Msg4_ACKed[UE_id]) { + continue; + } + + NR_SRS_Config_t *srs_config = NULL; + if (cg && + cg->spCellConfig && + cg->spCellConfig->spCellConfigDedicated && + cg->spCellConfig->spCellConfigDedicated->uplinkConfig && + cg->spCellConfig->spCellConfigDedicated->uplinkConfig->initialUplinkBWP) { + srs_config = cg->spCellConfig->spCellConfigDedicated->uplinkConfig->initialUplinkBWP->srs_Config->choice.setup; + } else { + continue; + } + + for(int rs = 0; rs < srs_config->srs_ResourceSetToAddModList->list.count; rs++) { + + // Find periodic resource set + NR_SRS_ResourceSet_t *srs_resource_set = srs_config->srs_ResourceSetToAddModList->list.array[rs]; + if (srs_resource_set->resourceType.present != NR_SRS_ResourceSet__resourceType_PR_periodic) { + continue; + } + + // Find the corresponding srs resource + NR_SRS_Resource_t *srs_resource = NULL; + for (int r1 = 0; r1 < srs_resource_set->srs_ResourceIdList->list.count; r1++) { + for (int r2 = 0; r2 < srs_config->srs_ResourceToAddModList->list.count; r2++) { + if ((*srs_resource_set->srs_ResourceIdList->list.array[r1] == + srs_config->srs_ResourceToAddModList->list.array[r2]->srs_ResourceId) && + (srs_config->srs_ResourceToAddModList->list.array[r2]->resourceType.present == + NR_SRS_Resource__resourceType_PR_periodic)) { + srs_resource = srs_config->srs_ResourceToAddModList->list.array[r2]; + break; + } + } + } + + if (srs_resource == NULL) { + continue; + } + + NR_BWP_t ubwp = sched_ctrl->active_ubwp ? + sched_ctrl->active_ubwp->bwp_Common->genericParameters : + scc->uplinkConfigCommon->initialUplinkBWP->genericParameters; + + uint16_t period = srs_period[srs_resource->resourceType.choice.periodic->periodicityAndOffset_p.present]; + uint16_t offset = get_nr_srs_offset(srs_resource->resourceType.choice.periodic->periodicityAndOffset_p); + + int n_slots_frame = nr_slots_per_frame[ubwp.subcarrierSpacing]; + + // Check if UE will transmit the SRS in this frame + if ( ((frame - offset/n_slots_frame)*n_slots_frame)%period == 0) { + LOG_D(NR_MAC,"Scheduling SRS reception for %d.%d\n", frame, offset%n_slots_frame); + nr_fill_nfapi_srs(module_id, CC_id, UE_id, offset%n_slots_frame, srs_resource); + sched_ctrl->sched_srs.frame = frame; + sched_ctrl->sched_srs.slot = offset%n_slots_frame; + sched_ctrl->sched_srs.srs_scheduled = true; + } + } + } +} \ No newline at end of file diff --git a/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_uci.c b/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_uci.c index 9b48feab9dd5d050e990a7c61784803efb620c84..548c4acb5e7d7714a9c08bf602bc245ed51063ab 100644 --- a/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_uci.c +++ b/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_uci.c @@ -141,7 +141,6 @@ void nr_schedule_pucch(int Mod_idP, for (int UE_id = UE_list->head; UE_id >= 0; UE_id = UE_list->next[UE_id]) { NR_UE_sched_ctrl_t *sched_ctrl = &UE_info->UE_sched_ctrl[UE_id]; - if (sched_ctrl->ul_failure==1 && get_softmodem_params()->phy_test==0) continue; const int n = sizeof(sched_ctrl->sched_pucch) / sizeof(*sched_ctrl->sched_pucch); for (int i = 0; i < n; i++) { NR_sched_pucch_t *curr_pucch = &UE_info->UE_sched_ctrl[UE_id].sched_pucch[i]; @@ -292,7 +291,7 @@ uint8_t compute_ri_bitlen(struct NR_CSI_ReportConfig *csi_reportconfig, } return max_ri; } - else + else AssertFatal(1==0,"Other configurations not yet implemented\n"); return -1; } @@ -563,6 +562,7 @@ void nr_csi_meas_reporting(int Mod_idP, } } +__attribute__((unused)) static void handle_dl_harq(module_id_t mod_id, int UE_id, int8_t harq_pid, @@ -1094,11 +1094,14 @@ void handle_nr_uci_pucch_0_1(module_id_t mod_id, const uint8_t harq_value = uci_01->harq->harq_list[harq_bit].harq_value; const uint8_t harq_confidence = uci_01->harq->harq_confidence_level; NR_UE_harq_t *harq = find_harq(mod_id, frame, slot, UE_id); - if (!harq) + if (!harq) { + LOG_E(NR_MAC, "Oh no! Could not find a harq in %s!\n", __FUNCTION__); break; + } DevAssert(harq->is_waiting); const int8_t pid = sched_ctrl->feedback_dl_harq.head; remove_front_nr_list(&sched_ctrl->feedback_dl_harq); + LOG_D(NR_MAC,"bit %d pid %d ack/nack %d\n",harq_bit,pid,harq_value); handle_dl_harq(mod_id, UE_id, pid, harq_value == 0 && harq_confidence == 0); if (harq_confidence == 1) UE_info->mac_stats[UE_id].pucch0_DTX++; } @@ -1187,7 +1190,7 @@ int nr_acknack_scheduling(int mod_id, const int nr_mix_slots = tdd->nrofDownlinkSymbols != 0 || tdd->nrofUplinkSymbols != 0; const int nr_slots_period = tdd->nrofDownlinkSlots + tdd->nrofUplinkSlots + nr_mix_slots; const int first_ul_slot_tdd = tdd->nrofDownlinkSlots + nr_slots_period * (slot / nr_slots_period); - const int first_ul_slot_period = first_ul_slot_tdd%nr_slots_period; + const int first_ul_slot_period = tdd->nrofDownlinkSlots; const int CC_id = 0; NR_sched_pucch_t *csi_pucch; @@ -1236,11 +1239,11 @@ int nr_acknack_scheduling(int mod_id, && !csi_pucch->simultaneous_harqcsi) { nr_fill_nfapi_pucch(mod_id, frame, slot, csi_pucch, UE_id); memset(csi_pucch, 0, sizeof(*csi_pucch)); - pucch->frame = s == n_slots_frame - 1 ? (f + 1) % 1024 : f; - if(((s + 1)%nr_slots_period) == 0) - pucch->ul_slot = (s + 1 + first_ul_slot_period) % n_slots_frame; + pucch->frame = pucch->ul_slot == n_slots_frame - 1 ? (pucch->frame + 1) % 1024 : pucch->frame; + if(((pucch->ul_slot + 1)%nr_slots_period) == 0) + pucch->ul_slot = (pucch->ul_slot + 1 + first_ul_slot_period) % n_slots_frame; else - pucch->ul_slot = (s + 1) % n_slots_frame; + pucch->ul_slot = (pucch->ul_slot + 1) % n_slots_frame; } } @@ -1264,7 +1267,6 @@ int nr_acknack_scheduling(int mod_id, int max_fb_time = 0; get_pdsch_to_harq_feedback(mod_id, UE_id, bwp_Id, ss_type, &max_fb_time, pdsch_to_harq_feedback); - int max_absslot = frame*n_slots_frame + slot + max_fb_time; LOG_D(NR_MAC,"pucch_acknak 1b. DL %d.%d, UL_ACK %d.%d, DAI_C %d\n",frame,slot,pucch->frame,pucch->ul_slot,pucch->dai_c); /* there is a HARQ. Check whether we can use it for this ACKNACK */ @@ -1273,7 +1275,10 @@ int nr_acknack_scheduling(int mod_id, // Find the right timing_indicator value. int i = 0; while (i < 8) { - if (pdsch_to_harq_feedback[i] == pucch->ul_slot - slot) + int diff = pucch->ul_slot - slot; + if (diff<0) + diff += n_slots_frame; + if (pdsch_to_harq_feedback[i] == diff) break; ++i; } @@ -1303,8 +1308,10 @@ int nr_acknack_scheduling(int mod_id, LOG_D(NR_MAC,"pucch_acknak : %d.%d DAI = 0, looking for new pucch occasion\n",frame,slot); /* we need to find a new PUCCH occasion */ - /*Inizialization of timing information*/ - if (pucch->frame == 0 && pucch->ul_slot == 0) { + /*(Re)Inizialization of timing information*/ + if ((pucch->frame == 0 && pucch->ul_slot == 0) || + ((pucch->frame*n_slots_frame + pucch->ul_slot) < + (frame*n_slots_frame + slot))) { AssertFatal(pucch->sr_flag + pucch->dai_c == 0, "expected no SR/AckNack for UE %d in %4d.%2d, but has %d/%d for %4d.%2d\n", UE_id, frame, slot, pucch->sr_flag, pucch->dai_c, pucch->frame, pucch->ul_slot); @@ -1314,13 +1321,16 @@ int nr_acknack_scheduling(int mod_id, // Find the right timing_indicator value. int ind_found = -1; - // while we are within the feedback limits and it has not been - while ((pucch->frame*n_slots_frame + pucch->ul_slot) <= max_absslot) { + // while we are within the feedback limits + while ((n_slots_frame + pucch->ul_slot - slot) % n_slots_frame <= max_fb_time) { int i = 0; while (i < 8) { LOG_D(NR_MAC,"pdsch_to_harq_feedback[%d] = %d (pucch->ul_slot %d - slot %d)\n", i,pdsch_to_harq_feedback[i],pucch->ul_slot,slot); - if (pdsch_to_harq_feedback[i] == pucch->ul_slot - slot) { + int diff = pucch->ul_slot - slot; + if (diff<0) + diff += n_slots_frame; + if (pdsch_to_harq_feedback[i] == diff) { ind_found = i; break; } @@ -1408,6 +1418,7 @@ int nr_acknack_scheduling(int mod_id, /* verify that at that slot and symbol, resources are free. We only do this * for initialCyclicShift 0 (we assume it always has that one), so other * initialCyclicShifts can overlap with ICS 0!*/ + if (pucch_Config) { const NR_PUCCH_Resource_t *resource = pucch_Config->resourceToAddModList->list.array[pucch->resource_indicator]; DevAssert(resource->format.present == NR_PUCCH_Resource__format_PR_format0); @@ -1456,8 +1467,11 @@ void nr_sr_reporting(int Mod_idP, frame_t SFN, sub_frame_t slot) RC.nrmac[Mod_idP]->UE_info.CellGroup[UE_id]->spCellConfig->spCellConfigDedicated->uplinkConfig->initialUplinkBWP->pucch_Config->choice.setup) { pucch_Config = RC.nrmac[Mod_idP]->UE_info.CellGroup[UE_id]->spCellConfig->spCellConfigDedicated->uplinkConfig->initialUplinkBWP->pucch_Config->choice.setup; } + else continue; - if (!pucch_Config->schedulingRequestResourceToAddModList) continue; + if (!pucch_Config->schedulingRequestResourceToAddModList) + continue; + AssertFatal(pucch_Config->schedulingRequestResourceToAddModList->list.count>0,"NO SR configuration available"); for (int SR_resource_id =0; SR_resource_id < pucch_Config->schedulingRequestResourceToAddModList->list.count;SR_resource_id++) { diff --git a/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_ulsch.c b/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_ulsch.c index b2d2b51a301fc1dad31a84ce01261909c71fcadf..33be615210a85a17a6f62754b53b6902f7e7f438 100644 --- a/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_ulsch.c +++ b/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_ulsch.c @@ -32,6 +32,7 @@ #include "LAYER2/NR_MAC_gNB/mac_proto.h" #include "executables/softmodem-common.h" #include "common/utils/nr/nr_common.h" +#include "utils.h" #include <openair2/UTIL/OPT/opt.h> #include "LAYER2/NR_MAC_COMMON/nr_mac_extern.h" @@ -104,7 +105,6 @@ void calculate_preferred_ul_tda(module_id_t module_id, const NR_BWP_Uplink_t *ub /* check that TDA index 1 fits into UL slot and does not overlap with PUCCH */ const struct NR_PUSCH_TimeDomainResourceAllocationList *tdaList = ubwp->bwp_Common->pusch_ConfigCommon->choice.setup->pusch_TimeDomainAllocationList; - AssertFatal(tdaList->list.count >= 3, "need to have at least three TDAs for UL slots\n"); const NR_PUSCH_TimeDomainResourceAllocation_t *tdaP_UL = tdaList->list.array[0]; const int k2 = get_K2(scc, (NR_BWP_Uplink_t*)ubwp,0, mu); int start, len; @@ -117,27 +117,28 @@ void calculate_preferred_ul_tda(module_id_t module_id, const NR_BWP_Uplink_t *ub // get largest time domain allocation (TDA) for UL slot and UL in mixed slot int tdaMi = -1; - const NR_PUSCH_TimeDomainResourceAllocation_t *tdaP_Mi = tdaList->list.array[1]; - AssertFatal(k2 == get_K2(scc, (NR_BWP_Uplink_t*)ubwp, 1, mu), - "scheduler cannot handle different k2 for UL slot (%d) and UL Mixed slot (%ld)\n", - k2, - get_K2(scc, (NR_BWP_Uplink_t*)ubwp, 1, mu)); - SLIV2SL(tdaP_Mi->startSymbolAndLength, &start, &len); - const uint16_t symb_tda_mi = ((1 << len) - 1) << start; - // check whether PUCCH and TDA overlap: then, we cannot use it. Also, check - // whether TDA is entirely within mixed slot, UL. Note that here we assume - // that the PUCCH is scheduled in every slot, and on all RBs (which is - // mostly not true, this is a simplification) - if ((symb_pucch & symb_tda_mi) == 0 && (symb_ulMixed & symb_tda_mi) == symb_tda_mi) { - tdaMi = 1; - } else { - LOG_E(NR_MAC, - "TDA index 1 UL overlaps with PUCCH or is not entirely in mixed slot (symb_pucch %x symb_ulMixed %x symb_tda_mi %x), won't schedule UL mixed slot\n", - symb_pucch, - symb_ulMixed, - symb_tda_mi); + if(tdaList->list.count > 1) { + const NR_PUSCH_TimeDomainResourceAllocation_t *tdaP_Mi = tdaList->list.array[1]; + AssertFatal(k2 == get_K2(scc, (NR_BWP_Uplink_t*)ubwp, 1, mu), + "scheduler cannot handle different k2 for UL slot (%d) and UL Mixed slot (%ld)\n", + k2, + get_K2(scc, (NR_BWP_Uplink_t*)ubwp, 1, mu)); + SLIV2SL(tdaP_Mi->startSymbolAndLength, &start, &len); + const uint16_t symb_tda_mi = ((1 << len) - 1) << start; + // check whether PUCCH and TDA overlap: then, we cannot use it. Also, check + // whether TDA is entirely within mixed slot, UL. Note that here we assume + // that the PUCCH is scheduled in every slot, and on all RBs (which is + // mostly not true, this is a simplification) + if ((symb_pucch & symb_tda_mi) == 0 && (symb_ulMixed & symb_tda_mi) == symb_tda_mi) { + tdaMi = 1; + } else { + LOG_E(NR_MAC, + "TDA index 1 UL overlaps with PUCCH or is not entirely in mixed slot (symb_pucch %x symb_ulMixed %x symb_tda_mi %x), won't schedule UL mixed slot\n", + symb_pucch, + symb_ulMixed, + symb_tda_mi); + } } - const uint8_t slots_per_frame[5] = {10, 20, 40, 80, 160}; const int n = slots_per_frame[*scc->ssbSubcarrierSpacing]; nrmac->preferred_ul_tda[bwp_id] = malloc(n * sizeof(*nrmac->preferred_ul_tda[bwp_id])); @@ -298,6 +299,17 @@ int nr_process_mac_pdu(module_id_t module_idP, 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_info->rnti[UE_id]) { + 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_ce_len = 2; @@ -365,10 +377,25 @@ int nr_process_mac_pdu(module_id_t module_idP, mac_sdu_len = (uint16_t)((NR_MAC_SUBHEADER_SHORT *)pduP)->L; mac_subheader_len = 2; } - if (UE_info->CellGroup[UE_id]) { - LOG_D(NR_MAC, "[UE %d] Frame %d : ULSCH -> UL-DCCH %d (gNB %d, %d bytes), rnti: %d \n", module_idP, frameP, rx_lcid, module_idP, mac_sdu_len, UE_info->rnti[UE_id]); + + rnti_t crnti = UE_info->rnti[UE_id]; + int UE_idx = UE_id; + 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_info->rnti[UE_id]) { + uint8_t *next_subpduP = pduP + mac_subheader_len + mac_sdu_len; + if ((pduP[mac_subheader_len+mac_sdu_len] & 0x3F) == UL_SCH_LCID_C_RNTI) { + crnti = ((next_subpduP[1]&0xFF)<<8)|(next_subpduP[2]&0xFF); + UE_idx = find_nr_UE_id(module_idP, crnti); + break; + } + } + } + + if (UE_info->CellGroup[UE_idx]) { + LOG_D(NR_MAC, "[UE %d] Frame %d : ULSCH -> UL-DCCH %d (gNB %d, %d bytes), rnti: 0x%04x \n", module_idP, frameP, rx_lcid, module_idP, mac_sdu_len, crnti); mac_rlc_data_ind(module_idP, - UE_info->rnti[UE_id], + crnti, module_idP, frameP, ENB_FLAG_YES, @@ -533,15 +560,16 @@ void handle_nr_ul_harq(const int CC_idP, ra->rnti == crc_pdu->rnti) return; } - LOG_E(NR_MAC, "%s(): unknown RNTI %04x in PUSCH\n", __func__, crc_pdu->rnti); + LOG_E(NR_MAC, "%s(): unknown RNTI 0x%04x in PUSCH\n", __func__, crc_pdu->rnti); return; } NR_UE_info_t *UE_info = &RC.nrmac[mod_id]->UE_info; NR_UE_sched_ctrl_t *sched_ctrl = &UE_info->UE_sched_ctrl[UE_id]; int8_t harq_pid = sched_ctrl->feedback_ul_harq.head; + LOG_D(NR_MAC, "Comparing crc_pdu->harq_id vs feedback harq_pid = %d %d\n",crc_pdu->harq_id, harq_pid); while (crc_pdu->harq_id != harq_pid || harq_pid < 0) { LOG_W(NR_MAC, - "Unexpected ULSCH HARQ PID %d (have %d) for RNTI %04x (ignore this warning for RA)\n", + "Unexpected ULSCH HARQ PID %d (have %d) for RNTI 0x%04x (ignore this warning for RA)\n", crc_pdu->harq_id, harq_pid, crc_pdu->rnti); @@ -683,7 +711,8 @@ void nr_rx_sdu(const module_id_t gnb_mod_idP, UE_info->mac_stats[UE_id].ulsch_DTX++; } if (UE_info->UE_sched_ctrl[UE_id].pusch_consecutive_dtx_cnt >= pusch_failure_thres) { - LOG_D(NR_MAC,"Detected UL Failure on PUSCH, stopping scheduling\n"); + LOG_W(NR_MAC,"Detected UL Failure on PUSCH after %d PUSCH DTX, stopping scheduling\n", + UE_info->UE_sched_ctrl[UE_id].pusch_consecutive_dtx_cnt); UE_info->UE_sched_ctrl[UE_id].ul_failure = 1; nr_mac_gNB_rrc_ul_failure(gnb_mod_idP,CC_idP,frameP,slotP,rntiP); } @@ -752,13 +781,13 @@ void nr_rx_sdu(const module_id_t gnb_mod_idP, UE_info->UE_sched_ctrl[UE_id].ta_frame = frameP; LOG_D(NR_MAC, - "reset RA state information for RA-RNTI %04x/index %d\n", + "reset RA state information for RA-RNTI 0x%04x/index %d\n", ra->rnti, i); LOG_I(NR_MAC, - "[gNB %d][RAPROC] PUSCH with TC_RNTI %x received correctly, " - "adding UE MAC Context UE_id %d/RNTI %04x\n", + "[gNB %d][RAPROC] PUSCH with TC_RNTI 0x%04x received correctly, " + "adding UE MAC Context UE_id %d/RNTI 0x%04x\n", gnb_mod_idP, current_rnti, UE_id, @@ -774,14 +803,14 @@ void nr_rx_sdu(const module_id_t gnb_mod_idP, LOG_D(NR_MAC, "[UE %d] PUSCH TPC %d and TA %d\n",UE_id,UE_scheduling_control->tpc0,UE_scheduling_control->ta_update); if(ra->cfra) { - LOG_I(NR_MAC, "(ue %i, rnti 0x%04x) CFRA procedure succeeded!\n", UE_id, ra->rnti); + LOG_A(NR_MAC, "(ue %i, rnti 0x%04x) CFRA procedure succeeded!\n", UE_id, ra->rnti); nr_mac_remove_ra_rnti(gnb_mod_idP, ra->rnti); nr_clear_ra_proc(gnb_mod_idP, CC_idP, frameP, ra); UE_info->active[UE_id] = true; } else { - LOG_I(NR_MAC,"[RAPROC] RA-Msg3 received (sdu_lenP %d)\n",sdu_lenP); + LOG_A(NR_MAC,"[RAPROC] RA-Msg3 received (sdu_lenP %d)\n",sdu_lenP); LOG_D(NR_MAC,"[RAPROC] Received Msg3:\n"); for (int k = 0; k < sdu_lenP; k++) { LOG_D(NR_MAC,"(%i): 0x%x\n",k,sduP[k]); @@ -796,7 +825,26 @@ void nr_rx_sdu(const module_id_t gnb_mod_idP, ra->state = Msg4; ra->Msg4_frame = (frameP + 2) % 1024; ra->Msg4_slot = 1; - LOG_I(NR_MAC, "Scheduling RA-Msg4 for TC_RNTI %04x (state %d, frame %d, slot %d)\n", ra->rnti, ra->state, ra->Msg4_frame, ra->Msg4_slot); + + if (ra->msg3_dcch_dtch) { + // Check if the UE identified by C-RNTI still exists at the gNB + int UE_id_C = find_nr_UE_id(gnb_mod_idP, ra->crnti); + if (UE_id_C < 0) { + // The UE identified by C-RNTI no longer exists at the gNB + // Let's abort the current RA, so the UE will trigger a new RA later but using RRCSetupRequest instead. A better solution may be implemented + mac_remove_nr_ue(gnb_mod_idP, ra->rnti); + nr_clear_ra_proc(gnb_mod_idP, CC_idP, frameP, ra); + return; + } else { + // The UE identified by C-RNTI still exists at the gNB + // Reset uplink failure flags/counters/timers at MAC and at RRC so gNB will resume again scheduling resources for this UE + UE_info->UE_sched_ctrl[UE_id_C].pusch_consecutive_dtx_cnt = 0; + UE_info->UE_sched_ctrl[UE_id_C].ul_failure = 0; + nr_mac_gNB_rrc_ul_failure_reset(gnb_mod_idP, frameP, slotP, ra->crnti); + } + } + LOG_I(NR_MAC, "Scheduling RA-Msg4 for TC_RNTI 0x%04x (state %d, frame %d, slot %d)\n", + (ra->msg3_dcch_dtch?ra->crnti:ra->rnti), ra->state, ra->Msg4_frame, ra->Msg4_slot); } else { nr_mac_remove_ra_rnti(gnb_mod_idP, ra->rnti); @@ -972,13 +1020,38 @@ bool allocate_ul_retransmission(module_id_t module_id, sched_ctrl->pusch_semi_static = temp_ps; } - /* Find free CCE */ - bool freeCCE = find_free_CCE(module_id, slot, UE_id); - if (!freeCCE) { + /* Find a free CCE */ + const int cid = sched_ctrl->coreset->controlResourceSetId; + const uint16_t Y = get_Y(cid%3, slot, UE_info->rnti[UE_id]); + uint8_t nr_of_candidates; + for (int i=0; i<5; i++) { + // for now taking the lowest value among the available aggregation levels + find_aggregation_candidates(&sched_ctrl->aggregation_level, + &nr_of_candidates, + sched_ctrl->search_space, + 1<<i); + if(nr_of_candidates>0) break; + } + int CCEIndex = find_pdcch_candidate(RC.nrmac[module_id], + CC_id, + sched_ctrl->aggregation_level, + nr_of_candidates, + &sched_ctrl->sched_pdcch, + sched_ctrl->coreset, + Y); + + if (CCEIndex<0) { LOG_D(NR_MAC, "%4d.%2d no free CCE for retransmission UL DCI UE %04x\n", frame, slot, UE_info->rnti[UE_id]); return false; } + sched_ctrl->cce_index = CCEIndex; + fill_pdcch_vrb_map(RC.nrmac[module_id], + CC_id, + &sched_ctrl->sched_pdcch, + CCEIndex, + sched_ctrl->aggregation_level); + /* frame/slot in sched_pusch has been set previously. In the following, we * overwrite the information in the retransmission information before storing * as the new scheduling instruction */ @@ -1034,7 +1107,7 @@ void pf_ul(module_id_t module_id, gNB_MAC_INST *nrmac = RC.nrmac[module_id]; NR_ServingCellConfigCommon_t *scc = nrmac->common_channels[CC_id].ServingCellConfigCommon; NR_UE_info_t *UE_info = &nrmac->UE_info; - const int min_rb = 40; + const int min_rb = 5; float coeff_ue[MAX_MOBILES_PER_GNB]; // UEs that could be scheduled int ue_array[MAX_MOBILES_PER_GNB]; @@ -1093,8 +1166,27 @@ void pf_ul(module_id_t module_id, * based on data to transmit) */ if (B == 0 && do_sched) { /* if no data, pre-allocate 5RB */ - bool freeCCE = find_free_CCE(module_id, slot, UE_id); - if (!freeCCE) { + /* Find a free CCE */ + const int cid = sched_ctrl->coreset->controlResourceSetId; + const uint16_t Y = get_Y(cid%3, slot, UE_info->rnti[UE_id]); + uint8_t nr_of_candidates; + for (int i=0; i<5; i++) { + // for now taking the lowest value among the available aggregation levels + find_aggregation_candidates(&sched_ctrl->aggregation_level, + &nr_of_candidates, + sched_ctrl->search_space, + 1<<i); + if(nr_of_candidates>0) break; + } + int CCEIndex = find_pdcch_candidate(RC.nrmac[module_id], + CC_id, + sched_ctrl->aggregation_level, + nr_of_candidates, + &sched_ctrl->sched_pdcch, + sched_ctrl->coreset, + Y); + + if (CCEIndex<0) { LOG_D(NR_MAC, "%4d.%2d no free CCE for UL DCI UE %04x (BSR 0)\n", frame, slot, UE_info->rnti[UE_id]); continue; } @@ -1111,6 +1203,13 @@ void pf_ul(module_id_t module_id, return; } + sched_ctrl->cce_index = CCEIndex; + fill_pdcch_vrb_map(RC.nrmac[module_id], + CC_id, + &sched_ctrl->sched_pdcch, + CCEIndex, + sched_ctrl->aggregation_level); + /* Save PUSCH field */ /* we want to avoid a lengthy deduction of DMRS and other parameters in * every TTI if we can save it, so check whether dci_format, TDA, or @@ -1176,8 +1275,27 @@ void pf_ul(module_id_t module_id, *max = UE_sched.next[*max]; *p = -1; - bool freeCCE = find_free_CCE(module_id, slot, UE_id); - if (!freeCCE) { + NR_UE_sched_ctrl_t *sched_ctrl = &UE_info->UE_sched_ctrl[UE_id]; + + const int cid = sched_ctrl->coreset->controlResourceSetId; + const uint16_t Y = get_Y(cid%3, slot, UE_info->rnti[UE_id]); + uint8_t nr_of_candidates; + for (int i=0; i<5; i++) { + // for now taking the lowest value among the available aggregation levels + find_aggregation_candidates(&sched_ctrl->aggregation_level, + &nr_of_candidates, + sched_ctrl->search_space, + 1<<i); + if(nr_of_candidates>0) break; + } + int CCEIndex = find_pdcch_candidate(RC.nrmac[module_id], + CC_id, + sched_ctrl->aggregation_level, + nr_of_candidates, + &sched_ctrl->sched_pdcch, + sched_ctrl->coreset, + Y); + if (CCEIndex<0) { LOG_D(NR_MAC, "%4d.%2d no free CCE for UL DCI UE %04x\n", frame, slot, UE_info->rnti[UE_id]); continue; } @@ -1188,7 +1306,6 @@ void pf_ul(module_id_t module_id, if (max_num_ue < 0) return; - NR_UE_sched_ctrl_t *sched_ctrl = &UE_info->UE_sched_ctrl[UE_id]; NR_CellGroupConfig_t *cg = UE_info->CellGroup[UE_id]; NR_BWP_UplinkDedicated_t *ubwpd= cg ? cg->spCellConfig->spCellConfigDedicated->uplinkConfig->initialUplinkBWP:NULL; NR_BWP_t *genericParameters = sched_ctrl->active_ubwp ? &sched_ctrl->active_ubwp->bwp_Common->genericParameters : &scc->uplinkConfigCommon->initialUplinkBWP->genericParameters; @@ -1241,6 +1358,14 @@ void pf_ul(module_id_t module_id, rbSize, sched_pusch->tb_size, sched_ctrl->estimated_ul_buffer, sched_ctrl->sched_ul_bytes, B,sched_ctrl->cce_index,ps->num_dmrs_symb,ps->N_PRB_DMRS); /* Mark the corresponding RBs as used */ + + sched_ctrl->cce_index = CCEIndex; + fill_pdcch_vrb_map(RC.nrmac[module_id], + CC_id, + &sched_ctrl->sched_pdcch, + CCEIndex, + sched_ctrl->aggregation_level); + n_rb_sched -= sched_pusch->rbSize; for (int rb = 0; rb < sched_ctrl->sched_pusch.rbSize; rb++) rballoc_mask[rb + sched_ctrl->sched_pusch.rbStart] = 0; @@ -1283,6 +1408,15 @@ bool nr_fr1_ulsch_preprocessor(module_id_t module_id, frame_t frame, sub_frame_t if (sched_ctrl->active_ubwp==NULL && is_mixed_slot) return false; + // Avoid slots with the SRS + const NR_list_t *UE_list = &UE_info->list; + for (int UE_idx = UE_list->head; UE_idx >= 0; UE_idx = UE_list->next[UE_idx]) { + NR_sched_srs_t sched_srs = UE_info->UE_sched_ctrl[UE_idx].sched_srs; + if(sched_srs.srs_scheduled && sched_srs.frame==sched_frame && sched_srs.slot==sched_slot) { + return false; + } + } + sched_ctrl->sched_pusch.slot = sched_slot; sched_ctrl->sched_pusch.frame = sched_frame; for (UE_id = UE_info->list.next[UE_id]; UE_id >= 0; UE_id = UE_info->list.next[UE_id]) { @@ -1400,7 +1534,8 @@ void nr_schedule_ulsch(module_id_t module_id, frame_t frame, sub_frame_t slot) /* a PDCCH PDU groups DCIs per BWP and CORESET. Save a pointer to each * allocated PDCCH so we can easily allocate UE's DCIs independent of any * CORESET order */ - nfapi_nr_dl_tti_pdcch_pdu_rel15_t *pdcch_pdu_bwp_coreset[MAX_NUM_BWP][MAX_NUM_CORESET] = {{0}}; + nfapi_nr_dl_tti_pdcch_pdu_rel15_t *pdcch_pdu_coreset[MAX_NUM_CORESET] = {0}; + NR_ServingCellConfigCommon_t *scc = RC.nrmac[module_id]->common_channels[0].ServingCellConfigCommon; NR_UE_info_t *UE_info = &RC.nrmac[module_id]->UE_info; @@ -1455,6 +1590,7 @@ void nr_schedule_ulsch(module_id_t module_id, frame_t frame, sub_frame_t slot) NR_pusch_semi_static_t *ps = &sched_ctrl->pusch_semi_static; /* Statistics */ + AssertFatal(cur_harq->round < 8, "Indexing ulsch_rounds[%d] is out of bounds\n", cur_harq->round); UE_info->mac_stats[UE_id].ulsch_rounds[cur_harq->round]++; if (cur_harq->round == 0) { UE_info->mac_stats[UE_id].ulsch_total_bytes_scheduled += sched_pusch->tb_size; @@ -1522,7 +1658,7 @@ void nr_schedule_ulsch(module_id_t module_id, frame_t frame, sub_frame_t slot) memset(pusch_pdu, 0, sizeof(nfapi_nr_pusch_pdu_t)); future_ul_tti_req->n_pdus += 1; - LOG_D(NR_MAC, "%4d.%2d Scheduling UE specific PUSCH for sched %d.%d, ul_tto_req %d.%d\n", frame, slot, + LOG_D(NR_MAC, "%4d.%2d Scheduling UE specific PUSCH for sched %d.%d, ul_tti_req %d.%d\n", frame, slot, sched_pusch->frame,sched_pusch->slot,future_ul_tti_req->SFN,future_ul_tti_req->Slot); pusch_pdu->pdu_bit_map = PUSCH_PDU_BITMAP_PUSCH_DATA; @@ -1588,6 +1724,7 @@ void nr_schedule_ulsch(module_id_t module_id, frame_t frame, sub_frame_t slot) pusch_pdu->nr_of_symbols = ps->nrOfSymbols; /* PUSCH PDU */ + AssertFatal(cur_harq->round < 4, "Indexing nr_rv_round_map[%d] is out of bounds\n", cur_harq->round); pusch_pdu->pusch_data.rv_index = nr_rv_round_map[cur_harq->round]; pusch_pdu->pusch_data.harq_process_id = harq_id; pusch_pdu->pusch_data.new_data_indicator = cur_harq->ndi; @@ -1637,7 +1774,7 @@ void nr_schedule_ulsch(module_id_t module_id, frame_t frame, sub_frame_t slot) NR_SearchSpace_t *ss = (sched_ctrl->active_bwp || ubwpd) ? sched_ctrl->search_space: RC.nrmac[module_id]->sched_ctrlCommon->search_space; NR_ControlResourceSet_t *coreset = (sched_ctrl->active_bwp || ubwpd) ? sched_ctrl->coreset: RC.nrmac[module_id]->sched_ctrlCommon->coreset; const int coresetid = coreset->controlResourceSetId; - nfapi_nr_dl_tti_pdcch_pdu_rel15_t *pdcch_pdu = pdcch_pdu_bwp_coreset[bwpid][coresetid]; + nfapi_nr_dl_tti_pdcch_pdu_rel15_t *pdcch_pdu = pdcch_pdu_coreset[coresetid]; if (!pdcch_pdu) { nfapi_nr_ul_dci_request_pdus_t *ul_dci_request_pdu = &ul_dci_req->ul_dci_pdu_list[ul_dci_req->numPdus]; memset(ul_dci_request_pdu, 0, sizeof(nfapi_nr_ul_dci_request_pdus_t)); @@ -1645,8 +1782,8 @@ void nr_schedule_ulsch(module_id_t module_id, frame_t frame, sub_frame_t slot) ul_dci_request_pdu->PDUSize = (uint8_t)(2+sizeof(nfapi_nr_dl_tti_pdcch_pdu)); pdcch_pdu = &ul_dci_request_pdu->pdcch_pdu.pdcch_pdu_rel15; ul_dci_req->numPdus += 1; - nr_configure_pdcch(nr_mac, pdcch_pdu, ss, coreset, scc, genericParameters, NULL); - pdcch_pdu_bwp_coreset[bwpid][coresetid] = pdcch_pdu; + nr_configure_pdcch(pdcch_pdu, coreset, genericParameters, &sched_ctrl->sched_pdcch); + pdcch_pdu_coreset[coresetid] = pdcch_pdu; } LOG_D(NR_MAC,"Configuring ULDCI/PDCCH in %d.%d at CCE %d, rnti %x\n", frame,slot,sched_ctrl->cce_index,rnti); diff --git a/openair2/LAYER2/NR_MAC_gNB/mac_proto.h b/openair2/LAYER2/NR_MAC_gNB/mac_proto.h index 91221276b06d8ddb95b9d82322f082a0e6305f1f..9afd2a40836d77e1d71bb428e9e37a4d0bb45081 100644 --- a/openair2/LAYER2/NR_MAC_gNB/mac_proto.h +++ b/openair2/LAYER2/NR_MAC_gNB/mac_proto.h @@ -190,6 +190,8 @@ void nr_schedule_pucch(int Mod_idP, frame_t frameP, sub_frame_t slotP); +void nr_schedule_srs(int module_id, frame_t frame); + void nr_csirs_scheduling(int Mod_idP, frame_t frame, sub_frame_t slot, @@ -248,13 +250,31 @@ void find_search_space(int ss_type, NR_BWP_Downlink_t *bwp, NR_SearchSpace_t *ss); -void nr_configure_pdcch(gNB_MAC_INST *gNB_mac, - nfapi_nr_dl_tti_pdcch_pdu_rel15_t *pdcch_pdu, - NR_SearchSpace_t *ss, +void nr_configure_pdcch(nfapi_nr_dl_tti_pdcch_pdu_rel15_t *pdcch_pdu, NR_ControlResourceSet_t *coreset, - NR_ServingCellConfigCommon_t *scc, NR_BWP_t *bwp, - NR_Type0_PDCCH_CSS_config_t *type0_PDCCH_CSS_config); + NR_sched_pdcch_t *pdcch); + +NR_sched_pdcch_t set_pdcch_structure(gNB_MAC_INST *gNB_mac, + NR_SearchSpace_t *ss, + NR_ControlResourceSet_t *coreset, + NR_ServingCellConfigCommon_t *scc, + NR_BWP_t *bwp, + NR_Type0_PDCCH_CSS_config_t *type0_PDCCH_CSS_config); + +int find_pdcch_candidate(gNB_MAC_INST *mac, + int cc_id, + int aggregation, + int nr_of_candidates, + NR_sched_pdcch_t *pdcch, + NR_ControlResourceSet_t *coreset, + uint16_t Y); + +void fill_pdcch_vrb_map(gNB_MAC_INST *mac, + int CC_id, + NR_sched_pdcch_t *pdcch, + int first_cce, + int aggregation); void fill_dci_pdu_rel15(const NR_ServingCellConfigCommon_t *scc, const NR_CellGroupConfig_t *CellGroup, @@ -300,6 +320,8 @@ void nr_set_pusch_semi_static(const NR_ServingCellConfigCommon_t *scc, uint8_t num_dmrs_cdm_grps_no_data, NR_pusch_semi_static_t *ps); +uint16_t get_Y(int cid, int slot, rnti_t rnti); + uint8_t nr_get_tpc(int target, uint8_t cqi, int incr); int get_spf(nfapi_nr_config_request_scf_t *cfg); diff --git a/openair2/LAYER2/NR_MAC_gNB/nr_mac_gNB.h b/openair2/LAYER2/NR_MAC_gNB/nr_mac_gNB.h index 5091262a0bf7c5f018f4f2335924de7151887d9f..d2588e1abc60c60e2234982528d634f993fa3fea 100644 --- a/openair2/LAYER2/NR_MAC_gNB/nr_mac_gNB.h +++ b/openair2/LAYER2/NR_MAC_gNB/nr_mac_gNB.h @@ -73,7 +73,7 @@ /* Defs */ #define MAX_NUM_BWP 2 -#define MAX_NUM_CORESET 2 +#define MAX_NUM_CORESET 12 #define MAX_NUM_CCE 90 #define MAX_HARQ_ROUNDS 4 /*!\brief Maximum number of random access process */ @@ -103,6 +103,20 @@ typedef struct NR_preamble_ue { uint8_t *preamble_list; } NR_preamble_ue_t; +typedef struct NR_sched_pdcch { + uint16_t BWPSize; + uint16_t BWPStart; + uint8_t CyclicPrefix; + uint8_t SubcarrierSpacing; + uint8_t StartSymbolIndex; + uint8_t CceRegMappingType; + uint8_t RegBundleSize; + uint8_t InterleaverSize; + uint16_t ShiftIndex; + uint8_t DurationSymbols; + int n_rb; +} NR_sched_pdcch_t; + /*! \brief gNB template for the Random access information */ typedef struct { /// Flag to indicate this process is active @@ -155,6 +169,8 @@ typedef struct { uint8_t msg3_cqireq; /// Round of Msg3 HARQ uint8_t msg3_round; + /// Flag to indicate if Msg3 carries a DCCH or DTCH message + bool msg3_dcch_dtch; /// TBS used for Msg4 int msg4_TBsize; /// MCS used for Msg4 @@ -163,6 +179,9 @@ typedef struct { int mac_pdu_length; /// RA search space NR_SearchSpace_t *ra_ss; + /// RA Coreset + NR_ControlResourceSet_t *coreset; + NR_sched_pdcch_t sched_pdcch; // Beam index uint8_t beam_id; /// CellGroup for UE that is to come (NSA is non-null, null for SA) @@ -298,7 +317,6 @@ typedef struct UE_info { pdschTciStatesActDeact_t pdsch_TCI_States_ActDeact; } NR_UE_mac_ce_ctrl_t; - typedef struct NR_sched_pucch { int frame; int ul_slot; @@ -360,6 +378,12 @@ typedef struct NR_sched_pusch { int time_domain_allocation; } NR_sched_pusch_t; +typedef struct NR_sched_srs { + int frame; + int slot; + bool srs_scheduled; +} NR_sched_srs_t; + /* PDSCH semi-static configuratio: as long as the TDA/DMRS/mcsTable remains the * same, there is no need to recalculate all S/L or DMRS-related parameters * over and over again. Hence, we store them in this struct for easy @@ -533,6 +557,7 @@ typedef struct { /// CCE index and aggregation, should be coherent with cce_list NR_SearchSpace_t *search_space; NR_ControlResourceSet_t *coreset; + NR_sched_pdcch_t sched_pdcch; /// CCE index and Aggr. Level are shared for PUSCH/PDSCH allocation decisions /// corresponding to the sched_pusch/sched_pdsch structures below @@ -546,9 +571,12 @@ typedef struct { /// PUSCH semi-static configuration: is not cleared across TTIs NR_pusch_semi_static_t pusch_semi_static; - /// Sched PDSCH: scheduling decisions, copied into HARQ and cleared every TTI + /// Sched PUSCH: scheduling decisions, copied into HARQ and cleared every TTI NR_sched_pusch_t sched_pusch; + /// Sched SRS: scheduling decisions + NR_sched_srs_t sched_srs; + /// uplink bytes that are currently scheduled int sched_ul_bytes; /// estimation of the UL buffer size @@ -650,12 +678,11 @@ typedef struct { rnti_t rnti[MAX_MOBILES_PER_GNB]; NR_CellGroupConfig_t *CellGroup[MAX_MOBILES_PER_GNB]; /// CCE indexing - int Y[MAX_MOBILES_PER_GNB][3][160]; int m[MAX_MOBILES_PER_GNB]; - int num_pdcch_cand[MAX_MOBILES_PER_GNB][MAX_NUM_CORESET]; // UE selected beam index uint8_t UE_beam_index[MAX_MOBILES_PER_GNB]; bool Msg4_ACKed[MAX_MOBILES_PER_GNB]; + } NR_UE_info_t; typedef void (*nr_pp_impl_dl)(module_id_t mod_id, @@ -703,7 +730,7 @@ typedef struct gNB_MAC_INST_s { /// a PDCCH PDU groups DCIs per BWP and CORESET. The following structure /// keeps pointers to PDCCH PDUs within DL_req so that we can easily track /// PDCCH PDUs per CC/BWP/CORESET - nfapi_nr_dl_tti_pdcch_pdu_rel15_t *pdcch_pdu_idx[NFAPI_CC_MAX][MAX_NUM_BWP][MAX_NUM_CORESET]; + nfapi_nr_dl_tti_pdcch_pdu_rel15_t *pdcch_pdu_idx[NFAPI_CC_MAX][MAX_NUM_CORESET]; /// NFAPI UL TTI Request Structure, simple pointer into structure /// UL_tti_req_ahead for current frame/slot nfapi_nr_ul_tti_request_t *UL_tti_req[NFAPI_CC_MAX]; @@ -714,7 +741,7 @@ typedef struct gNB_MAC_INST_s { nfapi_nr_ul_dci_request_t UL_dci_req[NFAPI_CC_MAX]; /// NFAPI DL PDU structure nfapi_nr_tx_data_request_t TX_req[NFAPI_CC_MAX]; - + int pdcch_cand[MAX_NUM_CORESET]; NR_UE_info_t UE_info; /// UL handle @@ -746,8 +773,6 @@ typedef struct gNB_MAC_INST_s { time_stats_t rx_ulsch_sdu; // include rlc_data_ind /// processing time of eNB PCH scheduler time_stats_t schedule_pch; - /// CCE lists - int cce_list[MAX_NUM_BWP][MAX_NUM_CORESET][MAX_NUM_CCE]; /// list of allocated beams per period int16_t *tdd_beam_association; diff --git a/openair2/LAYER2/PDCP_v10.1.0/pdcp.c b/openair2/LAYER2/PDCP_v10.1.0/pdcp.c index cddb666bfdbd346cf2dc7ae4cd7837bc50d850bf..4d2e157728bb9595929924a819332f70bc038e8b 100644 --- a/openair2/LAYER2/PDCP_v10.1.0/pdcp.c +++ b/openair2/LAYER2/PDCP_v10.1.0/pdcp.c @@ -140,6 +140,36 @@ extern volatile int oai_exit; pthread_t pdcp_stats_thread_desc; +// will be called when 4G F1 implementation will use GTP-U instead of protobuf +boolean_t cu_f1u_data_req( + protocol_ctxt_t *ctxt_pP, + const srb_flag_t srb_flagP, + const rb_id_t rb_id, + const mui_t muiP, + const confirm_t confirmP, + const sdu_size_t sdu_buffer_size, + unsigned char *const sdu_buffer, + const pdcp_transmission_mode_t mode, + const uint32_t *const sourceL2Id, + const uint32_t *const destinationL2Id + ) { + mem_block_t *memblock = get_free_mem_block(sdu_buffer_size, __func__); + if (memblock == NULL) { + LOG_E(RLC, "%s:%d:%s: ERROR: get_free_mem_block failed\n", __FILE__, __LINE__, __FUNCTION__); + exit(1); + } + memcpy(memblock->data,sdu_buffer, sdu_buffer_size); + // weird rb id management in 4G, not fully understand (looks bad design) + // overcomplex: if i understand, on the interface DRB start at 4 because there can be SRB 0..3 + // but it would be much simpler to use absolute numbering + // instead of this "srb flag" associated to these +/-4 + int ret=pdcp_data_ind(ctxt_pP,srb_flagP, false, rb_id-4, sdu_buffer_size, memblock, NULL, NULL); + if (!ret) { + LOG_E(RLC, "%s:%d:%s: ERROR: pdcp_data_ind failed\n", __FILE__, __LINE__, __FUNCTION__); + /* what to do in case of failure? for the moment: nothing */ + } + return ret; +} void *pdcp_stats_thread(void *param) { FILE *fd; @@ -176,6 +206,33 @@ void *pdcp_stats_thread(void *param) { uint64_t get_pdcp_optmask(void) { return pdcp_params.optmask; } + +rlc_op_status_t cu_send_to_du(const protocol_ctxt_t *const ctxt, + const srb_flag_t srb_flag, const MBMS_flag_t MBMS_flag, + const rb_id_t rb_id, const mui_t mui, + confirm_t confirm, sdu_size_t size, mem_block_t *sdu, + const uint32_t *const sourceID, const uint32_t *const destID) { + uint8_t *gtpu_buffer_p = itti_malloc(TASK_PDCP_ENB, TASK_GTPV1_U, + size + GTPU_HEADER_OVERHEAD_MAX); + AssertFatal(gtpu_buffer_p != NULL, "OUT OF MEMORY"); + memcpy(gtpu_buffer_p+GTPU_HEADER_OVERHEAD_MAX, + sdu->data, + size ); + MessageDef *message_p = itti_alloc_new_message(TASK_PDCP_ENB, 0, GTPV1U_ENB_TUNNEL_DATA_REQ); + AssertFatal(message_p != NULL, "OUT OF MEMORY"); + gtpv1u_enb_tunnel_data_req_t *req=>PV1U_ENB_TUNNEL_DATA_REQ(message_p); + req->buffer = gtpu_buffer_p; + req->length = size; + req->offset = GTPU_HEADER_OVERHEAD_MAX; + req->rnti = ctxt->rnti; + req->rab_id = rb_id+4; + LOG_D(PDCP, "%s() (drb %ld) sending message to gtp size %d\n", + __func__, rb_id, size); + extern instance_t CUuniqInstance; + itti_send_msg_to_task(TASK_VARIABLE, CUuniqInstance, message_p); + return TRUE; +} + //----------------------------------------------------------------------------- /* * If PDCP_UNIT_TEST is set here then data flow between PDCP and RLC is broken @@ -249,12 +306,8 @@ boolean_t pdcp_data_req( LOG_W(PDCP, PROTOCOL_CTXT_FMT" Instance is not configured for rb_id %ld Ignoring SDU...\n", PROTOCOL_CTXT_ARGS(ctxt_pP), rb_idP); - ctxt_pP->configured=FALSE; return FALSE; } - } else { - // instance for a given RB is configured - ctxt_pP->configured=TRUE; } if (ctxt_pP->enb_flag == ENB_FLAG_YES) { @@ -575,7 +628,9 @@ pdcp_data_ind( const MBMS_flag_t MBMS_flagP, const rb_id_t rb_idP, const sdu_size_t sdu_buffer_sizeP, - mem_block_t *const sdu_buffer_pP + mem_block_t *const sdu_buffer_pP, + const uint32_t *const srcID, + const uint32_t *const dstID ) //----------------------------------------------------------------------------- { @@ -1072,7 +1127,7 @@ pdcp_data_ind( * for the UE compiled in noS1 mode, we need 0 * TODO: be sure of this */ - if (NFAPI_MODE == NFAPI_UE_STUB_PNF ) { + if (NFAPI_MODE == NFAPI_UE_STUB_PNF || NFAPI_MODE == NFAPI_MODE_STANDALONE_PNF) { pdcpHead->inst = ctxt_pP->module_id; } else { // nfapi_mode if (UE_NAS_USE_TUN) { @@ -1288,7 +1343,7 @@ pdcp_run ( // IP/NAS -> PDCP traffic : TX, read the pkt from the upper layer buffer // if (LINK_ENB_PDCP_TO_GTPV1U && ctxt_pP->enb_flag == ENB_FLAG_NO) { - if (!EPC_MODE_ENABLED || ctxt_pP->enb_flag == ENB_FLAG_NO ) { + if (!get_softmodem_params()->emulate_l1 && (!EPC_MODE_ENABLED || ctxt_pP->enb_flag == ENB_FLAG_NO)) { pdcp_fifo_read_input_sdus(ctxt_pP); } @@ -1298,8 +1353,9 @@ pdcp_run ( } else { start_meas(&UE_pdcp_stats[ctxt_pP->module_id].pdcp_ip); } - - pdcp_fifo_flush_sdus(ctxt_pP); + if (!get_softmodem_params()->emulate_l1) { + pdcp_fifo_flush_sdus(ctxt_pP); + } if (ctxt_pP->enb_flag) { stop_meas(&eNB_pdcp_stats[ctxt_pP->module_id].pdcp_ip); @@ -1491,7 +1547,7 @@ void pdcp_add_UE(const protocol_ctxt_t *const ctxt_pP) { pdcp_enb[ctxt_pP->module_id].rnti[i]=ctxt_pP->rnti; pdcp_enb[ctxt_pP->module_id].uid[i]=i; pdcp_enb[ctxt_pP->module_id].num_ues++; - printf("add new uid is %d %x\n\n", i, ctxt_pP->rnti); + LOG_I(PDCP,"add new uid is %d %x\n", i, ctxt_pP->rnti); pdcp_init_stats_UE(ctxt_pP->module_id, i); // ret=1; break; @@ -2342,7 +2398,7 @@ void pdcp_set_pdcp_data_ind_func(pdcp_data_ind_func_t pdcp_data_ind) { pdcp_params.pdcp_data_ind_func = pdcp_data_ind; } -uint64_t pdcp_module_init( uint64_t pdcp_optmask ) { +uint64_t pdcp_module_init( uint64_t pdcp_optmask, int id) { /* temporary enforce netlink when UE_NAS_USE_TUN is set, this is while switching from noS1 as build option to noS1 as config option */ @@ -2359,18 +2415,18 @@ uint64_t pdcp_module_init( uint64_t pdcp_optmask ) { nas_getparams(); if(UE_NAS_USE_TUN) { - int num_if = (NFAPI_MODE == NFAPI_UE_STUB_PNF || IS_SOFTMODEM_SIML1 )? MAX_MOBILES_PER_ENB : 1; - netlink_init_tun("ue",num_if); + int num_if = (NFAPI_MODE == NFAPI_UE_STUB_PNF || IS_SOFTMODEM_SIML1 || NFAPI_MODE == NFAPI_MODE_STANDALONE_PNF)? MAX_MOBILES_PER_ENB : 1; + netlink_init_tun("ue",num_if, id); if (IS_SOFTMODEM_NOS1) - nas_config(1, 1, 2, "ue"); - netlink_init_mbms_tun("uem"); + nas_config(1, 1, 2, "ue"); + netlink_init_mbms_tun("uem", id); nas_config_mbms(1, 2, 2, "uem"); LOG_I(PDCP, "UE pdcp will use tun interface\n"); } else if(ENB_NAS_USE_TUN) { - netlink_init_tun("enb",1); + netlink_init_tun("enb", 1, 0); nas_config(1, 1, 1, "enb"); if(pdcp_optmask & ENB_NAS_USE_TUN_W_MBMS_BIT){ - netlink_init_mbms_tun("enm"); + netlink_init_mbms_tun("enm", 0); nas_config_mbms(1, 2, 1, "enm"); LOG_I(PDCP, "ENB pdcp will use mbms tun interface\n"); } @@ -2382,8 +2438,8 @@ uint64_t pdcp_module_init( uint64_t pdcp_optmask ) { }else{ if(pdcp_optmask & ENB_NAS_USE_TUN_W_MBMS_BIT){ LOG_W(PDCP, "ENB pdcp will use tun interface for MBMS\n"); - netlink_init_mbms_tun("enm"); - nas_config_mbms_s1(1, 2, 1, "enm"); + netlink_init_mbms_tun("enm", 0); + nas_config_mbms_s1(1, 2, 1, "enm"); }else LOG_E(PDCP, "ENB pdcp will not use tun interface\n"); } @@ -2425,6 +2481,7 @@ pdcp_free ( void pdcp_module_cleanup (void) //----------------------------------------------------------------------------- { + netlink_cleanup(); } //----------------------------------------------------------------------------- diff --git a/openair2/LAYER2/PDCP_v10.1.0/pdcp.h b/openair2/LAYER2/PDCP_v10.1.0/pdcp.h index 9d9224d660493d43686cdb974f6a0b2702c854b3..332ee382d712bd3c161623845d9a08d1d002569a 100644 --- a/openair2/LAYER2/PDCP_v10.1.0/pdcp.h +++ b/openair2/LAYER2/PDCP_v10.1.0/pdcp.h @@ -47,13 +47,16 @@ typedef rlc_op_status_t (*send_rlc_data_req_func_t)(const protocol_ctxt_t *const, - const srb_flag_t, const MBMS_flag_t, - const rb_id_t, const mui_t, + const srb_flag_t, const MBMS_flag_t, + const rb_id_t, const mui_t, confirm_t, sdu_size_t, mem_block_t *,const uint32_t *const, const uint32_t *const); -typedef boolean_t (*pdcp_data_ind_func_t)( const protocol_ctxt_t *, const srb_flag_t, - const MBMS_flag_t, const rb_id_t, const sdu_size_t, - mem_block_t *,const uint32_t *const, const uint32_t *const); +typedef boolean_t (pdcp_data_ind_t)( const protocol_ctxt_t *, const srb_flag_t, + const MBMS_flag_t, const rb_id_t, const sdu_size_t, + mem_block_t *,const uint32_t *const, const uint32_t *const); +typedef pdcp_data_ind_t* pdcp_data_ind_func_t; + +#define MAX_NUMBER_NETIF 1 //16 #define ENB_NAS_USE_TUN_W_MBMS_BIT (1<< 10) #define PDCP_USE_NETLINK_BIT (1<< 11) #define LINK_ENB_PDCP_TO_IP_DRIVER_BIT (1<< 13) @@ -254,6 +257,19 @@ boolean_t pdcp_data_req( const uint32_t * destinationL2Id ); +boolean_t cu_f1u_data_req( + protocol_ctxt_t *ctxt_pP, + const srb_flag_t srb_flagP, + const rb_id_t rb_id, + const mui_t muiP, + const confirm_t confirmP, + const sdu_size_t sdu_buffer_size, + unsigned char *const sdu_buffer, + const pdcp_transmission_mode_t mode, + const uint32_t *const sourceL2Id, + const uint32_t *const destinationL2Id + ); + /*! \fn boolean_t pdcp_data_ind(const protocol_ctxt_t* const, srb_flag_t, MBMS_flag_t, rb_id_t, sdu_size_t, mem_block_t*, boolean_t) * \brief This functions handles data transfer indications coming from RLC * \param[in] ctxt_pP Running context. @@ -267,13 +283,7 @@ boolean_t pdcp_data_req( * \note None * @ingroup _pdcp */ -boolean_t pdcp_data_ind( - const protocol_ctxt_t *const ctxt_pP, - const srb_flag_t srb_flagP, - const MBMS_flag_t MBMS_flagP, - const rb_id_t rb_id, - const sdu_size_t sdu_buffer_size, - mem_block_t *const sdu_buffer); +pdcp_data_ind_t pdcp_data_ind; /*! \fn void rrc_pdcp_config_req(const protocol_ctxt_t* const ,uint32_t,rb_id_t,uint8_t) * \brief This functions initializes relevant PDCP entity @@ -401,7 +411,8 @@ void pdcp_mbms_run ( */ void pdcp_run ( const protocol_ctxt_t *const ctxt_pP); -uint64_t pdcp_module_init (uint64_t pdcp_optmask); +uint64_t pdcp_module_init (uint64_t pdcp_optmask, int ue_id); +uint64_t nr_pdcp_module_init(uint64_t _pdcp_optmask, int id); void pdcp_module_cleanup (void); void nr_ip_over_LTE_DRB_preconfiguration (void); void pdcp_layer_init (void); @@ -419,7 +430,10 @@ pdcp_data_ind_func_t get_pdcp_data_ind_func(void); //----------------------------------------------------------------------------- int pdcp_fifo_flush_mbms_sdus ( const protocol_ctxt_t *const ctxt_pP); int pdcp_fifo_read_input_mbms_sdus_fromtun ( const protocol_ctxt_t *const ctxt_pP); - +rlc_op_status_t cu_send_to_du(const protocol_ctxt_t *const ctxt_pP, + const srb_flag_t srb_flagP, const MBMS_flag_t MBMS_flagP, + const rb_id_t rb_idP, const mui_t muiP, + confirm_t confirmP, sdu_size_t sdu_sizeP, mem_block_t *sdu_pP, const uint32_t *const, const uint32_t *const); /* * Following two types are utilized between NAS driver and PDCP diff --git a/openair2/LAYER2/PDCP_v10.1.0/pdcp_control_primitive.c b/openair2/LAYER2/PDCP_v10.1.0/pdcp_control_primitive.c deleted file mode 100644 index c2736ddd840869392fd20bc236648594485cbc0f..0000000000000000000000000000000000000000 --- a/openair2/LAYER2/PDCP_v10.1.0/pdcp_control_primitive.c +++ /dev/null @@ -1,53 +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 - */ - -/*************************************************************************** - pdcp_control_primitives.c - ------------------- - begin : Mon Dec 10 2001 - email : Lionel.Gauthier@eurecom.fr - ------------------- - description - This file contains the functions used for configuration of pdcp - - ***************************************************************************/ -#include "rtos_header.h" -#include "platform.h" -#include "protocol_vars_extern.h" -//----------------------------------------------------------------------------- -#include "rlc.h" -#include "pdcp.h" -#include "debug_l2.h" -//----------------------------------------------------------------------------- -void -configure_pdcp_req (struct pdcp_entity *pdcpP, void *rlcP, uint8_t rlc_sap_typeP, uint8_t header_compression_typeP) -{ - //----------------------------------------------------------------------------- - mem_block *mb; - - mb = get_free_mem_block (sizeof (struct cpdcp_primitive), __func__); - if(mb==NULL) return; - ((struct cpdcp_primitive *) mb->data)->type = CPDCP_CONFIG_REQ; - ((struct cpdcp_primitive *) mb->data)->primitive.config_req.rlc_sap = rlcP; - ((struct cpdcp_primitive *) mb->data)->primitive.config_req.rlc_type_sap = rlc_sap_typeP; - ((struct cpdcp_primitive *) mb->data)->primitive.config_req.header_compression_type = header_compression_typeP; - send_pdcp_control_primitive (pdcpP, mb); -} diff --git a/openair2/LAYER2/PDCP_v10.1.0/pdcp_control_primitives_proto_extern.h b/openair2/LAYER2/PDCP_v10.1.0/pdcp_control_primitives_proto_extern.h deleted file mode 100644 index 6226dccc335c3b46d9010d224d8c103c28c331ca..0000000000000000000000000000000000000000 --- a/openair2/LAYER2/PDCP_v10.1.0/pdcp_control_primitives_proto_extern.h +++ /dev/null @@ -1,36 +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 - */ - -/*************************************************************************** - pdcp_control_primitives_proto_extern.h - ------------------- - begin : Mon Dec 10 2001 - email : Lionel.Gauthier@eurecom.fr - ------------------- - description - This file contains the prototypes of functions used for configuration of pdcp - - ***************************************************************************/ -#ifndef PDCP_CONTROL_PRIMITIVES_PROTO_EXTERN_H -# define PDCP_CONTROL_PRIMITIVES_PROTO_EXTERN_H -# include "pdcp.h" -void rrc_configure_pdcp (struct pdcp_entity *pdcpP, void *rlcP, uint8_t rlc_sap_typeP, uint8_t header_compression_typeP); -#endif diff --git a/openair2/LAYER2/PDCP_v10.1.0/pdcp_fifo.c b/openair2/LAYER2/PDCP_v10.1.0/pdcp_fifo.c index 05e77a935de7b17b3dc1db423228991d0dbd390d..b49b02042821d8d0c3071858703faa179dfce9bf 100644 --- a/openair2/LAYER2/PDCP_v10.1.0/pdcp_fifo.c +++ b/openair2/LAYER2/PDCP_v10.1.0/pdcp_fifo.c @@ -89,7 +89,7 @@ extern struct msghdr nas_msg_rx; extern int gtpv1u_new_data_req( uint8_t enb_module_idP, rnti_t ue_rntiP, uint8_t rab_idP, uint8_t *buffer_pP, uint32_t buf_lenP, uint32_t buf_offsetP); - +uint16_t ue_id_g; // Global variable to identify the ID for each UE. It is updated in main() of lte-uesoftmodem.c void debug_pdcp_pc5s_sdu(sidelink_pc5s_element *sl_pc5s_msg, char *title) { LOG_I(PDCP,"%s: \nPC5S message, header traffic_type: %d)\n", title, sl_pc5s_msg->pc5s_header.traffic_type); @@ -210,14 +210,46 @@ int pdcp_fifo_read_input_sdus_fromtun (const protocol_ctxt_t *const ctxt_pP) { pdcp_t *pdcp_p = NULL; int len; rb_id_t rab_id = DEFAULT_RAB_ID; + int sockd; - do { + if (UE_NAS_USE_TUN) { + if (ue_id_g == 0) { + sockd = nas_sock_fd[ctxt_pP->module_id]; + } + else { + sockd = nas_sock_fd[ue_id_g]; + } + } + else { + sockd = nas_sock_fd[0]; + } + + for (;;) { VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME( VCD_SIGNAL_DUMPER_FUNCTIONS_PDCP_FIFO_READ, 1 ); VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME( VCD_SIGNAL_DUMPER_FUNCTIONS_PDCP_FIFO_READ_BUFFER, 1 ); - len = read(UE_NAS_USE_TUN?nas_sock_fd[ctxt_pP->module_id]:nas_sock_fd[0], &nl_rx_buf, NL_MAX_PAYLOAD); - VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME( VCD_SIGNAL_DUMPER_FUNCTIONS_PDCP_FIFO_READ_BUFFER, 0 ); + len = read(sockd, &nl_rx_buf, NL_MAX_PAYLOAD); - if (len<=0) continue; + VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME( VCD_SIGNAL_DUMPER_FUNCTIONS_PDCP_FIFO_READ_BUFFER, 0 ); + if (len == -1) { + if (errno == EAGAIN) { + LOG_D(PDCP, "Error reading NAS socket: %s\n", strerror(errno)); + } + else { + LOG_E(PDCP, "Error reading NAS socket: %s\n", strerror(errno)); + } + break; + } + /* Check for message truncation. Strictly speaking if the packet is exactly sizeof(nl_rx_buf) bytes + that would not be an error. But we cannot distinguish that from a packet > sizeof(nl_rx_buf) */ + if (len == sizeof(nl_rx_buf)) + { + LOG_E(PDCP, "%s(%d). Message truncated %d\n", __FUNCTION__, __LINE__, len); + break; + } + if (len == 0) { + LOG_E(PDCP, "EOF Reading NAS socket\n"); + break; + } if (UE_NAS_USE_TUN) { key = PDCP_COLL_KEY_DEFAULT_DRB_VALUE(ctxt.module_id, ctxt.rnti, ctxt.enb_flag); @@ -263,7 +295,7 @@ int pdcp_fifo_read_input_sdus_fromtun (const protocol_ctxt_t *const ctxt_pP) { ctxt.frame, ctxt.instance, rab_id, len, ctxt.module_id, ctxt.rnti, rab_id, key); } - } while (len > 0); + } VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME( VCD_SIGNAL_DUMPER_FUNCTIONS_PDCP_FIFO_READ, 0 ); return len; @@ -474,8 +506,12 @@ int pdcp_fifo_read_input_sdus_fromnetlinksock (const protocol_ctxt_t *const ctx // never finished code, dropped } } else { // ctxt.enb_flag => UE - if (NFAPI_MODE == NFAPI_UE_STUB_PNF) { + if (NFAPI_MODE == NFAPI_UE_STUB_PNF || NFAPI_MODE == NFAPI_MODE_STANDALONE_PNF) { +#ifdef UESIM_EXPANSION + ctxt.module_id = inst_pdcp_list[pdcp_read_header_g.inst]; +#else ctxt.module_id = pdcp_read_header_g.inst; +#endif } else { ctxt.module_id = 0; } @@ -526,8 +562,8 @@ int pdcp_fifo_read_input_sdus_fromnetlinksock (const protocol_ctxt_t *const ctx pdcp_read_header_g.data_size, (unsigned char *)NLMSG_DATA(nas_nlh_rx), PDCP_TRANSMISSION_MODE_DATA, - (NFAPI_MODE == NFAPI_UE_STUB_PNF)?NULL:&pdcp_read_header_g.sourceL2Id, - (NFAPI_MODE == NFAPI_UE_STUB_PNF)?NULL:&pdcp_read_header_g.destinationL2Id + (NFAPI_MODE == NFAPI_UE_STUB_PNF || NFAPI_MODE == NFAPI_MODE_STANDALONE_PNF) ? NULL : &pdcp_read_header_g.sourceL2Id, + (NFAPI_MODE == NFAPI_UE_STUB_PNF || NFAPI_MODE == NFAPI_MODE_STANDALONE_PNF) ? NULL : &pdcp_read_header_g.destinationL2Id ); } else { /* else of h_rc == HASH_TABLE_OK */ MSC_LOG_RX_DISCARDED_MESSAGE( @@ -571,8 +607,8 @@ int pdcp_fifo_read_input_sdus_fromnetlinksock (const protocol_ctxt_t *const ctx pdcp_read_header_g.data_size, (unsigned char *)NLMSG_DATA(nas_nlh_rx), PDCP_TRANSMISSION_MODE_DATA, - (NFAPI_MODE == NFAPI_UE_STUB_PNF) ? NULL :&pdcp_read_header_g.sourceL2Id, - (NFAPI_MODE == NFAPI_UE_STUB_PNF) ? NULL :&pdcp_read_header_g.destinationL2Id + (NFAPI_MODE == NFAPI_UE_STUB_PNF|| NFAPI_MODE == NFAPI_MODE_STANDALONE_PNF) ? NULL : &pdcp_read_header_g.sourceL2Id, + (NFAPI_MODE == NFAPI_UE_STUB_PNF|| NFAPI_MODE == NFAPI_MODE_STANDALONE_PNF) ? NULL : &pdcp_read_header_g.destinationL2Id ); } /* rab_id == 0 */ } /*pdcp_read_state_g != 0 */ @@ -597,35 +633,45 @@ void pdcp_fifo_read_input_sdus_frompc5s (const protocol_ctxt_t *const ctxt_pP) /* avoid gcc warnings */ (void)data_p; pdcp_t *pdcp_p = NULL; - //TTN for D2D (PC5S) - int prose_addr_len = sizeof(prose_pdcp_addr); - char send_buf[BUFSIZE], receive_buf[BUFSIZE]; - //int optval; int bytes_received; sidelink_pc5s_element *sl_pc5s_msg_send = NULL; pc5s_header_t *pc5s_header = NULL; rb_id_t rab_id = 0; //TTN for D2D (PC5S) // receive a message from ProSe App - memset(receive_buf, 0, BUFSIZE); - bytes_received = recvfrom(pdcp_pc5_sockfd, receive_buf, BUFSIZE, 0, - (struct sockaddr *) &prose_pdcp_addr, (socklen_t *)&prose_addr_len); - + char receive_buf[MAX_MESSAGE_SIZE]; + memset(receive_buf, 0, sizeof(receive_buf)); + socklen_t prose_addr_len = sizeof(prose_pdcp_addr); + bytes_received = recvfrom(pdcp_pc5_sockfd, receive_buf, sizeof(receive_buf), MSG_TRUNC, + (struct sockaddr *) &prose_pdcp_addr, &prose_addr_len); + if (bytes_received == -1) { + LOG_E(PDCP, "%s(%d). recvfrom failed. %s\n", __FUNCTION__, __LINE__, strerror(errno)); + return; + } + if (bytes_received == 0) { + LOG_E(PDCP, "%s(%d). EOF pdcp_pc5_sockfd.\n", __FUNCTION__, __LINE__); + } + if (bytes_received > sizeof(receive_buf)) { + LOG_E(PDCP, "%s(%d). Message truncated. %d\n", __FUNCTION__, __LINE__, bytes_received); + return; + } if (bytes_received > 0) { pc5s_header = calloc(1, sizeof(pc5s_header_t)); memcpy((void *)pc5s_header, (void *)receive_buf, sizeof(pc5s_header_t)); + char send_buf[MAX_MESSAGE_SIZE]; switch(pc5s_header->traffic_type) { case TRAFFIC_PC5S_SESSION_INIT : //send reply to ProSe app LOG_D(PDCP,"Received a request to open PDCP socket and establish a new PDCP session ... send response to ProSe App \n"); - memset(send_buf, 0, BUFSIZE); + memset(send_buf, 0, sizeof(send_buf)); sl_pc5s_msg_send = calloc(1, sizeof(sidelink_pc5s_element)); sl_pc5s_msg_send->pc5s_header.traffic_type = TRAFFIC_PC5S_SESSION_INIT; sl_pc5s_msg_send->pc5sPrimitive.status = 1; - memcpy((void *)send_buf, (void *)sl_pc5s_msg_send, sizeof(sidelink_pc5s_element)); + memcpy(send_buf, sl_pc5s_msg_send, sizeof(sidelink_pc5s_element)); int prose_addr_len = sizeof(prose_pdcp_addr); - int bytes_sent = sendto(pdcp_pc5_sockfd, (char *)send_buf, sizeof(sidelink_pc5s_element), 0, (struct sockaddr *)&prose_pdcp_addr, prose_addr_len); + int bytes_sent = sendto(pdcp_pc5_sockfd, send_buf, sizeof(sidelink_pc5s_element), 0, + (struct sockaddr *) &prose_pdcp_addr, prose_addr_len); free (sl_pc5s_msg_send); if (bytes_sent < 0) { diff --git a/openair2/LAYER2/PDCP_v10.1.0/pdcp_thread.c b/openair2/LAYER2/PDCP_v10.1.0/pdcp_thread.c deleted file mode 100644 index f1f6ebb7941502e5ae176ce218f72922ab600b91..0000000000000000000000000000000000000000 --- a/openair2/LAYER2/PDCP_v10.1.0/pdcp_thread.c +++ /dev/null @@ -1,132 +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 - */ - -/*! \file pdcp_thread.c - * \brief - * \author F. Kaltenberger - * \date 2013 - * \version 0.1 - * \company Eurecom - * \email: florian.kaltenberger@eurecom.fr - * \note - * \warning - */ -#include <pthread.h> -//#include <inttypes.h> - -#include "pdcp.h" -#include "PHY/extern.h" //for PHY_vars -#include "UTIL/LOG/log.h" -#include "UTIL/LOG/vcd_signal_dumper.h" -#include "msc.h" - -#define OPENAIR_THREAD_STACK_SIZE 8192 -#define OPENAIR_THREAD_PRIORITY 255 - -extern int oai_exit; -extern char UE_flag; - -pthread_t pdcp_thread; -pthread_mutex_t pdcp_mutex; -pthread_cond_t pdcp_cond; -int pdcp_instance_cnt; - -static void *pdcp_thread_main(void* param); - -static void *pdcp_thread_main(void* param) -{ - uint8_t eNB_flag = !UE_flag; - - LOG_I(PDCP,"This is pdcp_thread eNB_flag = %d\n",eNB_flag); - MSC_START_USE(); - - while (!oai_exit) { - - if (pthread_mutex_lock(&pdcp_mutex) != 0) { - LOG_E(PDCP,"Error locking mutex.\n"); - } else { - while (pdcp_instance_cnt < 0) { - pthread_cond_wait(&pdcp_cond,&pdcp_mutex); - } - - if (pthread_mutex_unlock(&pdcp_mutex) != 0) { - LOG_E(PDCP,"Error unlocking mutex.\n"); - } - } - - if (oai_exit) break; - - if (eNB_flag) { - pdcp_run(PHY_vars_eNB_g[0]->frame, eNB_flag, PHY_vars_eNB_g[0]->Mod_id, 0); - LOG_D(PDCP,"Calling pdcp_run (eNB) for frame %d\n",PHY_vars_eNB_g[0]->frame); - } else { - pdcp_run(PHY_vars_UE_g[0]->frame, eNB_flag, 0, PHY_vars_UE_g[0]->Mod_id); - LOG_D(PDCP,"Calling pdcp_run (UE) for frame %d\n",PHY_vars_UE_g[0]->frame); - } - - if (pthread_mutex_lock(&pdcp_mutex) != 0) { - LOG_E(PDCP,"Error locking mutex.\n"); - } else { - pdcp_instance_cnt--; - - if (pthread_mutex_unlock(&pdcp_mutex) != 0) { - LOG_E(PDCP,"Error unlocking mutex.\n"); - } - } - } - - return(NULL); -} - - -int init_pdcp_thread(void) -{ - - pthread_mutex_init(&pdcp_mutex,NULL); - pthread_cond_init(&pdcp_cond,NULL); - - pdcp_instance_cnt = -1; - LOG_I(PDCP,"Allocating PDCP thread\n"); - threadCreate(&pdcp_thread, pdcp_thread_main, (void*)NULL, "PDCP", -1, OAI_PRIORITY_RT); - - return(0); -} - - -void cleanup_pdcp_thread(void) -{ - void *status_p = NULL; - - LOG_I(PDCP,"Scheduling PDCP thread to exit\n"); - - pdcp_instance_cnt = 0; - - if (pthread_cond_signal(&pdcp_cond) != 0) { - LOG_I(PDCP,"ERROR pthread_cond_signal\n"); - } else { - LOG_I(PDCP,"Signalled PDCP thread to exit\n"); - } - - pthread_join(pdcp_thread,&status_p); - LOG_I(PDCP,"PDCP thread exited\n"); - pthread_cond_destroy(&pdcp_cond); - pthread_mutex_destroy(&pdcp_mutex); -} diff --git a/openair2/LAYER2/PROTO_AGENT/proto_agent.c b/openair2/LAYER2/PROTO_AGENT/proto_agent.c index 6bf9cdce229a249417febf87340c68e6dce6f453..5cf71b826db089bb177df20d5d67590582c2c5cc 100644 --- a/openair2/LAYER2/PROTO_AGENT/proto_agent.c +++ b/openair2/LAYER2/PROTO_AGENT/proto_agent.c @@ -157,7 +157,7 @@ void proto_agent_stop(mod_id_t mod_id) { rlc_op_status_t proto_agent_send_rlc_data_req(const protocol_ctxt_t *const ctxt_pP, const srb_flag_t srb_flagP, const MBMS_flag_t MBMS_flagP, const rb_id_t rb_idP, const mui_t muiP, - confirm_t confirmP, sdu_size_t sdu_sizeP, mem_block_t *sdu_pP) { + confirm_t confirmP, sdu_size_t sdu_sizeP, mem_block_t *sdu_pP,const uint32_t *const SrcID, const uint32_t *const DstID) { uint8_t *msg = NULL; Protocol__FlexsplitMessage *init_msg=NULL; int msg_flag = 0; @@ -191,9 +191,10 @@ error: } -boolean_t -proto_agent_send_pdcp_data_ind(const protocol_ctxt_t *const ctxt_pP, const srb_flag_t srb_flagP, - const MBMS_flag_t MBMS_flagP, const rb_id_t rb_idP, sdu_size_t sdu_sizeP, mem_block_t *sdu_pP) { +boolean_t proto_agent_send_pdcp_data_ind(const protocol_ctxt_t *const ctxt_pP, const srb_flag_t srb_flagP, + const MBMS_flag_t MBMS_flagP, const rb_id_t rb_idP, + sdu_size_t sdu_sizeP, mem_block_t *sdu_pP, + const uint32_t *const SrcID, const uint32_t *const DstID) { uint8_t *msg = NULL; Protocol__FlexsplitMessage *init_msg = NULL; int msg_flag = 0; diff --git a/openair2/LAYER2/PROTO_AGENT/proto_agent.h b/openair2/LAYER2/PROTO_AGENT/proto_agent.h index 32bf5aa13c7793f07732c4af25d208f6133f45ec..4badda43b7953ba80be008b02e1cfc39320c25e1 100644 --- a/openair2/LAYER2/PROTO_AGENT/proto_agent.h +++ b/openair2/LAYER2/PROTO_AGENT/proto_agent.h @@ -42,10 +42,8 @@ void proto_agent_stop(mod_id_t mod_id); rlc_op_status_t proto_agent_send_rlc_data_req( const protocol_ctxt_t *const ctxt_pP, const srb_flag_t srb_flagP, const MBMS_flag_t MBMS_flagP, const rb_id_t rb_idP, const mui_t muiP, confirm_t confirmP, - sdu_size_t sdu_sizeP, mem_block_t *sdu_pP); + sdu_size_t sdu_sizeP, mem_block_t *sdu_pP,const uint32_t *const SrcID, const uint32_t *const DstID); -boolean_t proto_agent_send_pdcp_data_ind(const protocol_ctxt_t *const ctxt_pP, - const srb_flag_t srb_flagP, const MBMS_flag_t MBMS_flagP, - const rb_id_t rb_idP, sdu_size_t sdu_sizeP, mem_block_t *sdu_pP); +pdcp_data_ind_t proto_agent_send_pdcp_data_ind; #endif diff --git a/openair2/LAYER2/PROTO_AGENT/proto_agent_common.c b/openair2/LAYER2/PROTO_AGENT/proto_agent_common.c index f19d7526fe3dc0467bb346ccd8d1a5ed36c4d263..d3d00d1adaa0abf95b17603a9d19f30704acb0b4 100644 --- a/openair2/LAYER2/PROTO_AGENT/proto_agent_common.c +++ b/openair2/LAYER2/PROTO_AGENT/proto_agent_common.c @@ -496,14 +496,6 @@ error: return -1; } -boolean_t pdcp_data_ind( - const protocol_ctxt_t *const ctxt_pP, - const srb_flag_t srb_flagP, - const MBMS_flag_t MBMS_flagP, - const rb_id_t rb_id, - const sdu_size_t sdu_buffer_size, - mem_block_t *const sdu_buffer); - int proto_agent_pdcp_data_ind_process(mod_id_t mod_id, const void *params, Protocol__FlexsplitMessage **msg) { boolean_t result = 0; Protocol__FlexsplitMessage *input = (Protocol__FlexsplitMessage *)params; @@ -525,7 +517,6 @@ int proto_agent_pdcp_data_ind_process(mod_id_t mod_id, const void *params, Proto ctxt_pP.rnti = ctxt->fsp_rnti; ctxt_pP.frame = ctxt->fsp_frame; ctxt_pP.subframe = ctxt->fsp_subframe; - ctxt_pP.configured = 1; ctxt_pP.brOption = 0; ctxt_pP.eNB_index = ctxt->fsp_enb_index; srb_flagP = rlc_data->fsp_srb_flag; @@ -546,7 +537,7 @@ int proto_agent_pdcp_data_ind_process(mod_id_t mod_id, const void *params, Proto flag_MBMS, rb_idP, pdcp_pdu_size, - pdcp_pdu_p); + pdcp_pdu_p, NULL, NULL); return result; error: diff --git a/openair2/LAYER2/nr_pdcp/nr_pdcp_entity.c b/openair2/LAYER2/nr_pdcp/nr_pdcp_entity.c index 87b71894c7047c668abd174b8e136e17238a365e..62aa101a500534a1837579157b0825f0ee321cb4 100644 --- a/openair2/LAYER2/nr_pdcp/nr_pdcp_entity.c +++ b/openair2/LAYER2/nr_pdcp/nr_pdcp_entity.c @@ -108,7 +108,7 @@ static void nr_pdcp_entity_recv_pdu(nr_pdcp_entity_t *entity, if (rcvd_count < entity->rx_deliv || nr_pdcp_sdu_in_list(entity->rx_list, rcvd_count)) { - LOG_D(PDCP, "discard NR PDU rcvd_count=%d\n", rcvd_count); + LOG_W(PDCP, "discard NR PDU rcvd_count=%d\n", rcvd_count); return; } diff --git a/openair2/LAYER2/nr_pdcp/nr_pdcp_oai_api.c b/openair2/LAYER2/nr_pdcp/nr_pdcp_oai_api.c index bf9435346fb488558b2340adc35164da083e73e8..ab8578a0e7e5ccce3f3907a92b26fa0856124679 100644 --- a/openair2/LAYER2/nr_pdcp/nr_pdcp_oai_api.c +++ b/openair2/LAYER2/nr_pdcp/nr_pdcp_oai_api.c @@ -55,6 +55,7 @@ hash_table_t *pdcp_coll_p; static uint64_t pdcp_optmask; ngran_node_t node_type = ngran_gNB; +uint8_t first_dcch = 0; uint8_t proto_agent_flag = 0; /****************************************************************************/ @@ -160,8 +161,7 @@ static void enqueue_rlc_data_req(const protocol_ctxt_t *const ctxt_pP, const mui_t muiP, confirm_t confirmP, sdu_size_t sdu_sizeP, - mem_block_t *sdu_pP, - void *_unused1, void *_unused2) + mem_block_t *sdu_pP) { int i; int logged = 0; @@ -206,15 +206,190 @@ void du_rlc_data_req(const protocol_ctxt_t *const ctxt_pP, rb_idP, muiP, confirmP, sdu_sizeP, - sdu_pP, - NULL, - NULL); + sdu_pP); } /****************************************************************************/ /* rlc_data_req queue - end */ /****************************************************************************/ +/****************************************************************************/ +/* pdcp_data_ind thread - begin */ +/****************************************************************************/ + +typedef struct { + protocol_ctxt_t ctxt_pP; + srb_flag_t srb_flagP; + MBMS_flag_t MBMS_flagP; + rb_id_t rb_id; + sdu_size_t sdu_buffer_size; + mem_block_t *sdu_buffer; +} pdcp_data_ind_queue_item; + +#define PDCP_DATA_IND_QUEUE_SIZE 10000 + +typedef struct { + pdcp_data_ind_queue_item q[PDCP_DATA_IND_QUEUE_SIZE]; + volatile int start; + volatile int length; + pthread_mutex_t m; + pthread_cond_t c; +} pdcp_data_ind_queue; + +static pdcp_data_ind_queue pq; + +static void do_pdcp_data_ind( + const protocol_ctxt_t *const ctxt_pP, + const srb_flag_t srb_flagP, + const MBMS_flag_t MBMS_flagP, + const rb_id_t rb_id, + const sdu_size_t sdu_buffer_size, + mem_block_t *const sdu_buffer) +{ + nr_pdcp_ue_t *ue; + nr_pdcp_entity_t *rb; + int rnti = ctxt_pP->rnti; + + if (ctxt_pP->module_id != 0 || + //ctxt_pP->enb_flag != 1 || + ctxt_pP->instance != 0 || + ctxt_pP->eNB_index != 0 || + ctxt_pP->brOption != 0) { + LOG_E(PDCP, "%s:%d:%s: fatal\n", __FILE__, __LINE__, __FUNCTION__); + exit(1); + } + + if (ctxt_pP->enb_flag) + T(T_ENB_PDCP_UL, T_INT(ctxt_pP->module_id), T_INT(rnti), + T_INT(rb_id), T_INT(sdu_buffer_size)); + + nr_pdcp_manager_lock(nr_pdcp_ue_manager); + ue = nr_pdcp_manager_get_ue(nr_pdcp_ue_manager, rnti); + + if (srb_flagP == 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->recv_pdu(rb, (char *)sdu_buffer->data, sdu_buffer_size); + } else { + LOG_E(PDCP, "%s:%d:%s: fatal: no RB found (rb_id %ld, srb_flag %d)\n", + __FILE__, __LINE__, __FUNCTION__, rb_id, srb_flagP); + exit(1); + } + + nr_pdcp_manager_unlock(nr_pdcp_ue_manager); + + free_mem_block(sdu_buffer, __FUNCTION__); +} + +static void *pdcp_data_ind_thread(void *_) +{ + int i; + + pthread_setname_np(pthread_self(), "PDCP data ind"); + while (1) { + if (pthread_mutex_lock(&pq.m) != 0) abort(); + while (pq.length == 0) + if (pthread_cond_wait(&pq.c, &pq.m) != 0) abort(); + i = pq.start; + if (pthread_mutex_unlock(&pq.m) != 0) abort(); + + do_pdcp_data_ind(&pq.q[i].ctxt_pP, + pq.q[i].srb_flagP, + pq.q[i].MBMS_flagP, + pq.q[i].rb_id, + pq.q[i].sdu_buffer_size, + pq.q[i].sdu_buffer); + + if (pthread_mutex_lock(&pq.m) != 0) abort(); + + pq.length--; + pq.start = (pq.start + 1) % PDCP_DATA_IND_QUEUE_SIZE; + + if (pthread_cond_signal(&pq.c) != 0) abort(); + if (pthread_mutex_unlock(&pq.m) != 0) abort(); + } +} + +static void init_nr_pdcp_data_ind_queue(void) +{ + pthread_t t; + + pthread_mutex_init(&pq.m, NULL); + pthread_cond_init(&pq.c, NULL); + + if (pthread_create(&t, NULL, pdcp_data_ind_thread, NULL) != 0) { + LOG_E(PDCP, "%s:%d:%s: fatal\n", __FILE__, __LINE__, __FUNCTION__); + exit(1); + } +} + +static void enqueue_pdcp_data_ind( + const protocol_ctxt_t *const ctxt_pP, + const srb_flag_t srb_flagP, + const MBMS_flag_t MBMS_flagP, + const rb_id_t rb_id, + const sdu_size_t sdu_buffer_size, + mem_block_t *const sdu_buffer) +{ + int i; + int logged = 0; + + if (pthread_mutex_lock(&pq.m) != 0) abort(); + while (pq.length == PDCP_DATA_IND_QUEUE_SIZE) { + if (!logged) { + logged = 1; + LOG_W(PDCP, "%s: pdcp_data_ind queue is full\n", __FUNCTION__); + } + if (pthread_cond_wait(&pq.c, &pq.m) != 0) abort(); + } + + i = (pq.start + pq.length) % PDCP_DATA_IND_QUEUE_SIZE; + pq.length++; + + pq.q[i].ctxt_pP = *ctxt_pP; + pq.q[i].srb_flagP = srb_flagP; + pq.q[i].MBMS_flagP = MBMS_flagP; + pq.q[i].rb_id = rb_id; + pq.q[i].sdu_buffer_size = sdu_buffer_size; + pq.q[i].sdu_buffer = sdu_buffer; + + if (pthread_cond_signal(&pq.c) != 0) abort(); + if (pthread_mutex_unlock(&pq.m) != 0) abort(); +} + +boolean_t pdcp_data_ind( + const protocol_ctxt_t *const ctxt_pP, + const srb_flag_t srb_flagP, + const MBMS_flag_t MBMS_flagP, + const rb_id_t rb_id, + const sdu_size_t sdu_buffer_size, + mem_block_t *const sdu_buffer, + const uint32_t *const srcID, + const uint32_t *const dstID) +{ + enqueue_pdcp_data_ind(ctxt_pP, + srb_flagP, + MBMS_flagP, + rb_id, + sdu_buffer_size, + sdu_buffer); + return true; +} + +/****************************************************************************/ +/* pdcp_data_ind thread - end */ +/****************************************************************************/ + /****************************************************************************/ /* hacks to be cleaned up at some point - begin */ /****************************************************************************/ @@ -266,7 +441,6 @@ static void *enb_tun_read_thread(void *_) ctxt.frame = 0; ctxt.subframe = 0; ctxt.eNB_index = 0; - ctxt.configured = 1; ctxt.brOption = 0; ctxt.rnti = rnti; @@ -310,7 +484,6 @@ static void *ue_tun_read_thread(void *_) ctxt.frame = 0; ctxt.subframe = 0; ctxt.eNB_index = 0; - ctxt.configured = 1; ctxt.brOption = 0; ctxt.rnti = rnti; @@ -375,6 +548,7 @@ void pdcp_layer_init(void) init_nr_rlc_data_req_queue(); } + init_nr_pdcp_data_ind_queue(); nr_pdcp_init_timer_thread(nr_pdcp_ue_manager); } @@ -382,7 +556,7 @@ void pdcp_layer_init(void) #include "targets/RT/USER/lte-softmodem.h" #include "openair2/RRC/NAS/nas_config.h" -uint64_t pdcp_module_init(uint64_t _pdcp_optmask) +uint64_t nr_pdcp_module_init(uint64_t _pdcp_optmask, int id) { /* hack: be sure to initialize only once */ static pthread_mutex_t m = PTHREAD_MUTEX_INITIALIZER; @@ -414,16 +588,18 @@ uint64_t pdcp_module_init(uint64_t _pdcp_optmask) nas_getparams(); if(UE_NAS_USE_TUN) { - int num_if = (NFAPI_MODE == NFAPI_UE_STUB_PNF || IS_SOFTMODEM_SIML1 )? MAX_MOBILES_PER_ENB : 1; - netlink_init_tun("ue",num_if); + char *ifsuffix_ue = get_softmodem_params()->nsa ? "nrue" : "ue"; + int num_if = (NFAPI_MODE == NFAPI_UE_STUB_PNF || IS_SOFTMODEM_SIML1 || NFAPI_MODE == NFAPI_MODE_STANDALONE_PNF)? MAX_MOBILES_PER_ENB : 1; + netlink_init_tun(ifsuffix_ue, num_if, id); //Add --nr-ip-over-lte option check for next line if (IS_SOFTMODEM_NOS1) - nas_config(1, 1, 2, "ue"); + nas_config(1, 1, !get_softmodem_params()->nsa ? 2 : 3, ifsuffix_ue); LOG_I(PDCP, "UE pdcp will use tun interface\n"); start_pdcp_tun_ue(); } else if(ENB_NAS_USE_TUN) { - netlink_init_tun("enb",1); - nas_config(1, 1, 1, "enb"); + char *ifsuffix_base_s = get_softmodem_params()->nsa ? "gnb" : "enb"; + netlink_init_tun(ifsuffix_base_s, 1, id); + nas_config(1, 1, 1, ifsuffix_base_s); LOG_I(PDCP, "ENB pdcp will use tun interface\n"); start_pdcp_tun_enb(); } else { @@ -446,7 +622,7 @@ static void deliver_sdu_drb(void *_ue, nr_pdcp_entity_t *entity, int rb_id; int i; - if(IS_SOFTMODEM_NOS1 || UE_NAS_USE_TUN){ + if (IS_SOFTMODEM_NOS1 || UE_NAS_USE_TUN) { LOG_D(PDCP, "IP packet received, to be sent to TUN interface"); if(entity->has_sdapDLheader){ @@ -457,7 +633,7 @@ static void deliver_sdu_drb(void *_ue, nr_pdcp_entity_t *entity, } if (len != size) { - LOG_E(PDCP, "%s:%d:%s: fatal\n", __FILE__, __LINE__, __FUNCTION__); + LOG_E(PDCP, "%s:%d:%s: fatal error %d: %s\n", __FILE__, __LINE__, __FUNCTION__, errno, strerror(errno)); } } @@ -476,19 +652,23 @@ static void deliver_sdu_drb(void *_ue, nr_pdcp_entity_t *entity, rb_found: { int offset=0; - if (entity->has_sdap == 1 && entity->has_sdapULheader == 1) offset = 1; // this is the offset of the SDAP header in bytes + if (entity->has_sdap == 1 && entity->has_sdapULheader == 1) + offset = 1; // this is the offset of the SDAP header in bytes - gtpu_buffer_p = itti_malloc(TASK_PDCP_ENB, TASK_GTPV1_U, - size + GTPU_HEADER_OVERHEAD_MAX - offset); - AssertFatal(gtpu_buffer_p != NULL, "OUT OF MEMORY"); - memcpy(>pu_buffer_p[GTPU_HEADER_OVERHEAD_MAX], buf+offset, size-offset); - message_p = itti_alloc_new_message(TASK_PDCP_ENB, 0, GTPV1U_GNB_TUNNEL_DATA_REQ); + message_p = itti_alloc_new_message_sized(TASK_PDCP_ENB, 0, + GTPV1U_GNB_TUNNEL_DATA_REQ, + sizeof(gtpv1u_gnb_tunnel_data_req_t) + size + + GTPU_HEADER_OVERHEAD_MAX - offset); AssertFatal(message_p != NULL, "OUT OF MEMORY"); - GTPV1U_GNB_TUNNEL_DATA_REQ(message_p).buffer = gtpu_buffer_p; - GTPV1U_GNB_TUNNEL_DATA_REQ(message_p).length = size-offset; - GTPV1U_GNB_TUNNEL_DATA_REQ(message_p).offset = GTPU_HEADER_OVERHEAD_MAX; - GTPV1U_GNB_TUNNEL_DATA_REQ(message_p).rnti = ue->rnti; - GTPV1U_GNB_TUNNEL_DATA_REQ(message_p).pdusession_id = entity->pdusession_id; + + gtpv1u_gnb_tunnel_data_req_t *req=>PV1U_GNB_TUNNEL_DATA_REQ(message_p); + gtpu_buffer_p = (uint8_t*)(req+1); + memcpy(gtpu_buffer_p+GTPU_HEADER_OVERHEAD_MAX, buf+offset, size-offset); + req->buffer = gtpu_buffer_p; + req->length = size-offset; + req->offset = GTPU_HEADER_OVERHEAD_MAX; + req->rnti = ue->rnti; + req->pdusession_id = entity->pdusession_id; if (offset==1) { LOG_I(PDCP, "%s() (drb %d) SDAP header %2x\n",__func__, rb_id, buf[0]); sdap_gnb_ul_header_handler(buf[0]); // Handler for the UL gNB SDAP Header @@ -526,18 +706,39 @@ rb_found: ctxt.frame = 0; ctxt.subframe = 0; ctxt.eNB_index = 0; - ctxt.configured = 1; ctxt.brOption = 0; ctxt.rnti = ue->rnti; - - memblock = get_free_mem_block(size, __FUNCTION__); - memcpy(memblock->data, buf, size); - - LOG_D(PDCP, "%s(): (srb %d) calling rlc_data_req size %d\n", __func__, rb_id, size); - //for (i = 0; i < size; i++) printf(" %2.2x", (unsigned char)memblock->data[i]); - //printf("\n"); - enqueue_rlc_data_req(&ctxt, 0, MBMS_FLAG_NO, rb_id, sdu_id, 0, size, memblock, NULL, NULL); + if (RC.nrrrc != NULL && NODE_IS_CU(RC.nrrrc[0]->node_type)) { + MessageDef *message_p = itti_alloc_new_message_sized(TASK_PDCP_ENB, 0, + GTPV1U_GNB_TUNNEL_DATA_REQ, + sizeof(gtpv1u_gnb_tunnel_data_req_t) + + size + + GTPU_HEADER_OVERHEAD_MAX); + AssertFatal(message_p != NULL, "OUT OF MEMORY"); + gtpv1u_gnb_tunnel_data_req_t *req=>PV1U_GNB_TUNNEL_DATA_REQ(message_p); + uint8_t *gtpu_buffer_p = (uint8_t*)(req+1); + memcpy(gtpu_buffer_p+GTPU_HEADER_OVERHEAD_MAX, + buf, size); + req->buffer = gtpu_buffer_p; + req->length = size; + req->offset = GTPU_HEADER_OVERHEAD_MAX; + req->rnti = ue->rnti; + req->pdusession_id = rb_id; + LOG_D(PDCP, "%s() (drb %d) sending message to gtp size %d\n", + __func__, rb_id, size); + extern instance_t CUuniqInstance; + itti_send_msg_to_task(TASK_VARIABLE, CUuniqInstance, message_p); + } else { + + memblock = get_free_mem_block(size, __FUNCTION__); + memcpy(memblock->data, buf, size); + + LOG_D(PDCP, "%s(): (srb %d) calling rlc_data_req size %d\n", __func__, rb_id, size); + //for (i = 0; i < size; i++) printf(" %2.2x", (unsigned char)memblock->data[i]); + //printf("\n"); + enqueue_rlc_data_req(&ctxt, 0, MBMS_FLAG_NO, rb_id, sdu_id, 0, size, memblock); + } } static void deliver_sdu_srb(void *_ue, nr_pdcp_entity_t *entity, @@ -614,18 +815,19 @@ srb_found: ctxt.frame = 0; ctxt.subframe = 0; ctxt.eNB_index = 0; - ctxt.configured = 1; ctxt.brOption = 0; ctxt.rnti = ue->rnti; memblock = get_free_mem_block(size, __FUNCTION__); memcpy(memblock->data, buf, size); - enqueue_rlc_data_req(&ctxt, 1, MBMS_FLAG_NO, srb_id, sdu_id, 0, size, memblock, NULL, NULL); + enqueue_rlc_data_req(&ctxt, 1, MBMS_FLAG_NO, srb_id, sdu_id, 0, size, memblock); } else { MessageDef *message_p = itti_alloc_new_message (TASK_RRC_GNB, 0, F1AP_DL_RRC_MESSAGE); - F1AP_DL_RRC_MESSAGE (message_p).rrc_container = (uint8_t*)buf; + uint8_t *message_buffer = itti_malloc (TASK_RRC_GNB, TASK_CU_F1, size); + memcpy (message_buffer, buf, size); + F1AP_DL_RRC_MESSAGE (message_p).rrc_container = message_buffer; F1AP_DL_RRC_MESSAGE (message_p).rrc_container_length = size; F1AP_DL_RRC_MESSAGE (message_p).gNB_CU_ue_id = 0; F1AP_DL_RRC_MESSAGE (message_p).gNB_DU_ue_id = 0; @@ -639,62 +841,6 @@ srb_found: } } -boolean_t pdcp_data_ind( - const protocol_ctxt_t *const ctxt_pP, - const srb_flag_t srb_flagP, - const MBMS_flag_t MBMS_flagP, - const rb_id_t rb_id, - const sdu_size_t sdu_buffer_size, - mem_block_t *const sdu_buffer) -{ - nr_pdcp_ue_t *ue; - nr_pdcp_entity_t *rb; - int rnti = ctxt_pP->rnti; - - if (ctxt_pP->module_id != 0 || - //ctxt_pP->enb_flag != 1 || - ctxt_pP->instance != 0 || - ctxt_pP->eNB_index != 0 || - ctxt_pP->configured != 1 || - ctxt_pP->brOption != 0) { - LOG_E(PDCP, "%s:%d:%s: fatal\n", __FILE__, __LINE__, __FUNCTION__); - exit(1); - } - - if (ctxt_pP->enb_flag) - T(T_ENB_PDCP_UL, T_INT(ctxt_pP->module_id), T_INT(rnti), - T_INT(rb_id), T_INT(sdu_buffer_size)); - - nr_pdcp_manager_lock(nr_pdcp_ue_manager); - ue = nr_pdcp_manager_get_ue(nr_pdcp_ue_manager, rnti); - - if (srb_flagP == 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->recv_pdu(rb, (char *)sdu_buffer->data, sdu_buffer_size); - } else { - LOG_E(PDCP, "%s:%d:%s: fatal: no RB found (rb_id %ld, srb_flag %d)\n", - __FILE__, __LINE__, __FUNCTION__, rb_id, srb_flagP); - exit(1); - } - - nr_pdcp_manager_unlock(nr_pdcp_ue_manager); - - free_mem_block(sdu_buffer, __FUNCTION__); - - return 1; -} - void pdcp_run(const protocol_ctxt_t *const ctxt_pP) { MessageDef *msg_p; @@ -706,7 +852,6 @@ void pdcp_run(const protocol_ctxt_t *const ctxt_pP) .frame=-1, .subframe=-1, .eNB_index=0, - .configured=true, .brOption=false }; @@ -1043,7 +1188,7 @@ void nr_DRB_preconfiguration(uint16_t crnti) NR_RLC_BearerConfig_t *RLC_BearerConfig = calloc(1,sizeof(*RLC_BearerConfig)); nr_rlc_bearer_init(RLC_BearerConfig,NR_RLC_BearerConfig__servedRadioBearer_PR_drb_Identity); - nr_drb_config(RLC_BearerConfig->rlc_Config, NR_RLC_Config_PR_um_Bi_Directional); + nr_drb_config(RLC_BearerConfig->rlc_Config, NR_RLC_Config_PR_am); nr_rlc_bearer_init_ul_spec(RLC_BearerConfig->mac_LogicalChannelConfig); Rlc_Bearer_ToAdd_list = calloc(1,sizeof(*Rlc_Bearer_ToAdd_list)); @@ -1235,6 +1380,35 @@ static boolean_t pdcp_data_req_drb( return 1; } +boolean_t cu_f1u_data_req( + protocol_ctxt_t *ctxt_pP, + const srb_flag_t srb_flagP, + const rb_id_t rb_id, + const mui_t muiP, + const confirm_t confirmP, + const sdu_size_t sdu_buffer_size, + unsigned char *const sdu_buffer, + const pdcp_transmission_mode_t mode + ,const uint32_t *const sourceL2Id + ,const uint32_t *const destinationL2Id + ) { + + //Force instance id to 0, OAI incoherent instance management + ctxt_pP->instance=0; + mem_block_t *memblock = get_free_mem_block(sdu_buffer_size, __func__); + if (memblock == NULL) { + LOG_E(RLC, "%s:%d:%s: ERROR: get_free_mem_block failed\n", __FILE__, __LINE__, __FUNCTION__); + exit(1); + } + memcpy(memblock->data,sdu_buffer, sdu_buffer_size); + int ret=pdcp_data_ind(ctxt_pP,srb_flagP, false, rb_id, sdu_buffer_size, memblock, NULL, NULL); + if (!ret) { + LOG_E(RLC, "%s:%d:%s: ERROR: pdcp_data_ind failed\n", __FILE__, __LINE__, __FUNCTION__); + /* what to do in case of failure? for the moment: nothing */ + } + return ret; +} + boolean_t pdcp_data_req( protocol_ctxt_t *ctxt_pP, const srb_flag_t srb_flagP, diff --git a/openair2/LAYER2/nr_pdcp/nr_pdcp_timer_thread.c b/openair2/LAYER2/nr_pdcp/nr_pdcp_timer_thread.c index 36e9b16024879db067a7784c66eb898e36527dc7..5f6939e165e3d44b62dff08f91ed9bc65af6326f 100644 --- a/openair2/LAYER2/nr_pdcp/nr_pdcp_timer_thread.c +++ b/openair2/LAYER2/nr_pdcp/nr_pdcp_timer_thread.c @@ -19,6 +19,7 @@ * contact@openairinterface.org */ +#define _GNU_SOURCE #include "nr_pdcp_timer_thread.h" #include <stdlib.h> @@ -33,6 +34,7 @@ static volatile uint64_t timer_thread_curtime = 0; static void *nr_pdcp_timer_thread(void *_nr_pdcp_ue_manager) { + pthread_setname_np(pthread_self(),"pdcp_timer"); nr_pdcp_ue_manager_t *nr_pdcp_ue_manager = (nr_pdcp_ue_manager_t *)_nr_pdcp_ue_manager; nr_pdcp_ue_t **ue_list; int ue_count; diff --git a/openair2/LAYER2/nr_rlc/nr_rlc_entity.h b/openair2/LAYER2/nr_rlc/nr_rlc_entity.h index 5b12a90cfd1daf04437a276d5258e0849e7d9ca1..b9b638fe0784385c78ced73865ed2148c491ef1a 100644 --- a/openair2/LAYER2/nr_rlc/nr_rlc_entity.h +++ b/openair2/LAYER2/nr_rlc/nr_rlc_entity.h @@ -63,6 +63,8 @@ typedef struct nr_rlc_entity_t { void (*max_retx_reached)(void *max_retx_reached_data, struct nr_rlc_entity_t *entity); void *max_retx_reached_data; + /* buffer status computation */ + nr_rlc_entity_buffer_status_t bstatus; } 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 8db5ce31adf0885dcea340b2bac61b25c9ea0a83..d7923e5490bf0c0ebccb2b53044edc6efe4478cf 100644 --- a/openair2/LAYER2/nr_rlc/nr_rlc_entity_am.c +++ b/openair2/LAYER2/nr_rlc/nr_rlc_entity_am.c @@ -28,6 +28,19 @@ #include "LOG/log.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, + nr_rlc_sdu_segment_t *sdu) +{ + int header_size = 2; + /* one more byte if SN field length is 18 */ + if (entity->sn_field_length == 18) + header_size++; + /* two more bytes for SO if SDU segment is not the first */ + if (!sdu->is_first) header_size += 2; + return header_size; +} + /*************************************************************************/ /* PDU RX functions */ /*************************************************************************/ @@ -114,6 +127,10 @@ static void consider_retransmission(nr_rlc_entity_am_t *entity, nr_rlc_sdu_segment_list_append(&entity->retransmit_list, &entity->retransmit_end, cur); + + /* update buffer status */ + entity->common.bstatus.retx_size += compute_pdu_header_size(entity, cur) + + cur->size; } /* checks that all the bytes of the SDU sn have been received (but SDU @@ -351,6 +368,9 @@ static void process_received_ack(nr_rlc_entity_am_t *entity, int ack_sn) } /* remove from retransmit list */ prev->next = cur->next; + /* update buffer status */ + entity->common.bstatus.retx_size -= compute_pdu_header_size(entity, cur) + + cur->size; /* put the PDU in the ack list */ entity->ack_list = nr_rlc_sdu_segment_list_add(sn_compare_tx, entity, entity->ack_list, cur); @@ -576,20 +596,20 @@ void nr_rlc_entity_am_recv_pdu(nr_rlc_entity_t *_entity, /* dicard PDU if no data */ if (data_size <= 0) { - LOG_D(RLC, "%s:%d:%s: warning: discard PDU, no data\n", + LOG_W(RLC, "%s:%d:%s: warning: discard PDU, no data\n", __FILE__, __LINE__, __FUNCTION__); goto discard; } /* dicard PDU if rx buffer is full */ if (entity->rx_size + data_size > entity->rx_maxsize) { - LOG_D(RLC, "%s:%d:%s: warning: discard PDU, RX buffer full\n", + LOG_W(RLC, "%s:%d:%s: warning: discard PDU, RX buffer full\n", __FILE__, __LINE__, __FUNCTION__); goto discard; } if (!sn_in_recv_window(entity, sn)) { - LOG_D(RLC, "%s:%d:%s: warning: discard PDU, sn out of window (sn %d rx_next %d)\n", + LOG_W(RLC, "%s:%d:%s: warning: discard PDU, sn out of window (sn %d rx_next %d)\n", __FILE__, __LINE__, __FUNCTION__, sn, entity->rx_next); goto discard; @@ -597,7 +617,7 @@ void nr_rlc_entity_am_recv_pdu(nr_rlc_entity_t *_entity, /* discard segment if all the bytes of the segment are already there */ if (segment_already_received(entity, sn, so, data_size)) { - LOG_D(RLC, "%s:%d:%s: warning: discard PDU, already received\n", + LOG_W(RLC, "%s:%d:%s: warning: discard PDU, already received\n", __FILE__, __LINE__, __FUNCTION__); goto discard; } @@ -633,7 +653,7 @@ void nr_rlc_entity_am_recv_pdu(nr_rlc_entity_t *_entity, control: cpt = nr_rlc_pdu_decoder_get_bits(&decoder, 3); R(decoder); if (cpt != 0) { - LOG_D(RLC, "%s:%d:%s: warning: discard PDU, CPT not 0 (%d)\n", + LOG_W(RLC, "%s:%d:%s: warning: discard PDU, CPT not 0 (%d)\n", __FILE__, __LINE__, __FUNCTION__, cpt); goto discard; } @@ -840,19 +860,6 @@ static int serialize_sdu(nr_rlc_entity_am_t *entity, return encoder.byte + sdu->size; } -/* for a given SDU/SDU segment, computes the corresponding PDU header size */ -static int compute_pdu_header_size(nr_rlc_entity_am_t *entity, - nr_rlc_sdu_segment_t *sdu) -{ - int header_size = 2; - /* one more byte if SN field length is 18 */ - if (entity->sn_field_length == 18) - header_size++; - /* two more bytes for SO if SDU segment is not the first */ - if (!sdu->is_first) header_size += 2; - return header_size; -} - /* resize SDU/SDU segment for the corresponding PDU to fit into 'pdu_size' * bytes * - modifies SDU/SDU segment to become an SDU segment @@ -1426,8 +1433,12 @@ static int generate_retx_pdu(nr_rlc_entity_am_t *entity, char *buffer, sdu->next = NULL; - /* segment if necessary */ pdu_size = pdu_header_size + sdu->size; + + /* update buffer status */ + entity->common.bstatus.retx_size -= pdu_size; + + /* segment if necessary */ if (pdu_size > size) { nr_rlc_sdu_segment_t *next_sdu; next_sdu = resegment(sdu, entity, size); @@ -1436,6 +1447,9 @@ static int generate_retx_pdu(nr_rlc_entity_am_t *entity, char *buffer, entity->retransmit_list = next_sdu; if (entity->retransmit_end == NULL) entity->retransmit_end = entity->retransmit_list; + /* update buffer status */ + entity->common.bstatus.retx_size += compute_pdu_header_size(entity, next_sdu) + + next_sdu->size; } /* put SDU/SDU segment in the wait list */ @@ -1479,11 +1493,15 @@ static int generate_tx_pdu(nr_rlc_entity_am_t *entity, char *buffer, int size) sdu->next = NULL; + pdu_size = pdu_header_size + sdu->size; + + /* update buffer status */ + entity->common.bstatus.tx_size -= pdu_size; + /* assign SN to SDU */ sdu->sdu->sn = entity->tx_next; /* segment if necessary */ - pdu_size = pdu_header_size + sdu->size; if (pdu_size > size) { nr_rlc_sdu_segment_t *next_sdu; next_sdu = resegment(sdu, entity, size); @@ -1492,6 +1510,9 @@ 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; + /* update buffer status */ + entity->common.bstatus.tx_size += compute_pdu_header_size(entity, next_sdu) + + next_sdu->size; } /* update tx_next if the SDU segment is the last */ @@ -1520,24 +1541,6 @@ static int generate_tx_pdu(nr_rlc_entity_am_t *entity, char *buffer, int size) return serialize_sdu(entity, sdu, buffer, size, p); } -/* Pretend to serialize all the SDUs in a list and return the size - * of all the PDUs it would produce, limited to 'maxsize'. - * Used for buffer status reporting. - */ -static int tx_list_size(nr_rlc_entity_am_t *entity, - nr_rlc_sdu_segment_t *l, int maxsize) -{ - int ret = 0; - - while (l != NULL && ret < maxsize) { - ret += compute_pdu_header_size(entity, l) + l->size; - l = l->next; - } - - if (ret > maxsize) ret = maxsize; - return ret; -} - nr_rlc_entity_buffer_status_t nr_rlc_entity_am_buffer_status( nr_rlc_entity_t *_entity, int maxsize) { @@ -1549,8 +1552,8 @@ nr_rlc_entity_buffer_status_t nr_rlc_entity_am_buffer_status( else ret.status_size = 0; - ret.tx_size = tx_list_size(entity, entity->tx_list, maxsize); - ret.retx_size = tx_list_size(entity, entity->retransmit_list, maxsize); + ret.tx_size = entity->common.bstatus.tx_size; + ret.retx_size = entity->common.bstatus.retx_size; return ret; } @@ -1593,9 +1596,18 @@ void nr_rlc_entity_am_recv_sdu(nr_rlc_entity_t *_entity, exit(1); } + /* log SDUs rejected, at most once per second */ + if (entity->sdu_rejected != 0 + && entity->t_current > entity->t_log_buffer_full + 1000) { + LOG_E(RLC, "%s:%d:%s: warning: %d SDU rejected, SDU buffer full\n", + __FILE__, __LINE__, __FUNCTION__, + entity->sdu_rejected); + entity->sdu_rejected = 0; + entity->t_log_buffer_full = entity->t_current; + } + if (entity->tx_size + size > entity->tx_maxsize) { - LOG_E(RLC, "%s:%d:%s: warning: SDU rejected, SDU buffer full\n", - __FILE__, __LINE__, __FUNCTION__); + entity->sdu_rejected++; return; } @@ -1606,6 +1618,10 @@ void nr_rlc_entity_am_recv_sdu(nr_rlc_entity_t *_entity, LOG_D(RLC, "Created new RLC SDU and append it to the RLC list \n"); nr_rlc_sdu_segment_list_append(&entity->tx_list, &entity->tx_end, sdu); + + /* update buffer status */ + entity->common.bstatus.tx_size += compute_pdu_header_size(entity, sdu) + + sdu->size; } /*************************************************************************/ @@ -1644,7 +1660,7 @@ static void check_t_poll_retransmit(nr_rlc_entity_am_t *entity) */ entity->force_poll = 1; - LOG_D(RLC, "%s:%d:%s: warning: t_poll_retransmit expired\n", + LOG_W(RLC, "%s:%d:%s: warning: t_poll_retransmit expired\n", __FILE__, __LINE__, __FUNCTION__); /* do we meet conditions of 38.322 5.3.3.4? */ @@ -1735,6 +1751,9 @@ static void check_t_reassembly(nr_rlc_entity_am_t *entity) sn = (sn + 1) % entity->sn_modulus; entity->rx_highest_status = sn; + /* trigger status report */ + entity->status_triggered = 1; + if (sn_compare_rx(entity, entity->rx_next_highest, (entity->rx_highest_status+1) % entity->sn_modulus) > 0 || (entity->rx_next_highest == @@ -1793,6 +1812,10 @@ void nr_rlc_entity_am_discard_sdu(nr_rlc_entity_t *_entity, int sdu_id) entity->tx_end = NULL; } + /* update buffer status */ + entity->common.bstatus.tx_size -= compute_pdu_header_size(entity, cur) + + cur->size; + nr_rlc_free_sdu_segment(cur); } @@ -1816,6 +1839,9 @@ static void clear_entity(nr_rlc_entity_am_t *entity) entity->t_current = 0; + entity->t_log_buffer_full = 0; + entity->sdu_rejected = 0; + entity->t_poll_retransmit_start = 0; entity->t_reassembly_start = 0; entity->t_status_prohibit_start = 0; @@ -1845,6 +1871,9 @@ static void clear_entity(nr_rlc_entity_am_t *entity) entity->retransmit_end = NULL; entity->ack_list = NULL; + + entity->common.bstatus.tx_size = 0; + entity->common.bstatus.retx_size = 0; } void nr_rlc_entity_am_reestablishment(nr_rlc_entity_t *_entity) diff --git a/openair2/LAYER2/nr_rlc/nr_rlc_entity_am.h b/openair2/LAYER2/nr_rlc/nr_rlc_entity_am.h index 7a553a22a9d166bcd36b24ccc6b9fda6929897a7..453fe870265ac8e8fce2d104672d6ef213e11471 100644 --- a/openair2/LAYER2/nr_rlc/nr_rlc_entity_am.h +++ b/openair2/LAYER2/nr_rlc/nr_rlc_entity_am.h @@ -60,6 +60,10 @@ typedef struct { /* set to the latest know time by the user of the module. Unit: ms */ uint64_t t_current; + /* deal with logging of buffer full */ + uint64_t t_log_buffer_full; + int sdu_rejected; + /* timers (stores the TTI of activation, 0 means not active) */ uint64_t t_poll_retransmit_start; uint64_t t_reassembly_start; diff --git a/openair2/LAYER2/nr_rlc/nr_rlc_entity_tm.c b/openair2/LAYER2/nr_rlc/nr_rlc_entity_tm.c index 26ae4818891f2062113c4eeedd4d7da9a293141c..75408276d18e688491313d3e8fb589fcb754b68d 100644 --- a/openair2/LAYER2/nr_rlc/nr_rlc_entity_tm.c +++ b/openair2/LAYER2/nr_rlc/nr_rlc_entity_tm.c @@ -68,22 +68,12 @@ 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; - nr_rlc_free_sdu_segment(sdu); - return ret; -} - -static int tx_list_size(nr_rlc_entity_tm_t *entity, - nr_rlc_sdu_segment_t *l, int maxsize) -{ - int ret = 0; + /* update buffer status */ + entity->common.bstatus.tx_size -= sdu->size; - while (l != NULL && ret < maxsize) { - ret += l->size; - l = l->next; - } + nr_rlc_free_sdu_segment(sdu); - if (ret > maxsize) ret = maxsize; return ret; } @@ -94,7 +84,7 @@ nr_rlc_entity_buffer_status_t nr_rlc_entity_tm_buffer_status( nr_rlc_entity_buffer_status_t ret; ret.status_size = 0; - ret.tx_size = tx_list_size(entity, entity->tx_list, maxsize); + ret.tx_size = entity->common.bstatus.tx_size; ret.retx_size = 0; return ret; @@ -136,6 +126,9 @@ void nr_rlc_entity_tm_recv_sdu(nr_rlc_entity_t *_entity, sdu = nr_rlc_new_sdu(buffer, size, sdu_id); nr_rlc_sdu_segment_list_append(&entity->tx_list, &entity->tx_end, sdu); + + /* update buffer status */ + entity->common.bstatus.tx_size += sdu->size; } /*************************************************************************/ @@ -165,6 +158,8 @@ static void clear_entity(nr_rlc_entity_tm_t *entity) entity->tx_list = NULL; entity->tx_end = NULL; entity->tx_size = 0; + + entity->common.bstatus.tx_size = 0; } void nr_rlc_entity_tm_reestablishment(nr_rlc_entity_t *_entity) diff --git a/openair2/LAYER2/nr_rlc/nr_rlc_entity_um.c b/openair2/LAYER2/nr_rlc/nr_rlc_entity_um.c index 71173eee5af3ae0024f2cab860805057dcd05563..b34a7dc89410f621ca0a3fc68980a7648e13355e 100644 --- a/openair2/LAYER2/nr_rlc/nr_rlc_entity_um.c +++ b/openair2/LAYER2/nr_rlc/nr_rlc_entity_um.c @@ -28,6 +28,20 @@ #include "LOG/log.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, + nr_rlc_sdu_segment_t *sdu) +{ + int header_size = 1; + + /* if SN to be included then one more byte if SN field length is 12 */ + if (!(sdu->is_first && sdu->is_last) && entity->sn_field_length == 12) + header_size++; + /* two more bytes for SO if SDU segment is not the first */ + if (!sdu->is_first) header_size += 2; + return header_size; +} + /*************************************************************************/ /* PDU RX functions */ /*************************************************************************/ @@ -299,21 +313,21 @@ void nr_rlc_entity_um_recv_pdu(nr_rlc_entity_t *_entity, /* dicard PDU if no data */ if (data_size <= 0) { - LOG_D(RLC, "%s:%d:%s: warning: discard PDU, no data\n", + LOG_W(RLC, "%s:%d:%s: warning: discard PDU, no data\n", __FILE__, __LINE__, __FUNCTION__); goto discard; } /* dicard PDU if rx buffer is full */ if (entity->rx_size + data_size > entity->rx_maxsize) { - LOG_D(RLC, "%s:%d:%s: warning: discard PDU, RX buffer full\n", + LOG_W(RLC, "%s:%d:%s: warning: discard PDU, RX buffer full\n", __FILE__, __LINE__, __FUNCTION__); goto discard; } /* discard PDU if sn < rx_next_reassembly */ if (sn_compare_rx(entity, sn, entity->rx_next_reassembly) < 0) { - LOG_D(RLC, "%s:%d:%s: warning: discard PDU, SN (%d) < rx_next_reassembly (%d)\n", + LOG_W(RLC, "%s:%d:%s: warning: discard PDU, SN (%d) < rx_next_reassembly (%d)\n", __FILE__, __LINE__, __FUNCTION__, sn, entity->rx_next_reassembly); goto discard; @@ -375,20 +389,6 @@ static int serialize_sdu(nr_rlc_entity_um_t *entity, return encoder.byte + sdu->size; } -/* for a given SDU/SDU segment, computes the corresponding PDU header size */ -static int compute_pdu_header_size(nr_rlc_entity_um_t *entity, - nr_rlc_sdu_segment_t *sdu) -{ - int header_size = 1; - - /* if SN to be included then one more byte if SN field length is 12 */ - if (!(sdu->is_first && sdu->is_last) && entity->sn_field_length == 12) - header_size++; - /* two more bytes for SO if SDU segment is not the first */ - if (!sdu->is_first) header_size += 2; - return header_size; -} - /* resize SDU/SDU segment for the corresponding PDU to fit into 'pdu_size' * bytes * - modifies SDU/SDU segment to become an SDU segment @@ -462,8 +462,12 @@ static int generate_tx_pdu(nr_rlc_entity_um_t *entity, char *buffer, int size) /* assign SN to SDU */ sdu->sdu->sn = entity->tx_next; - /* segment if necessary */ pdu_size = pdu_header_size + sdu->size; + + /* update buffer status */ + entity->common.bstatus.tx_size -= pdu_size; + + /* segment if necessary */ if (pdu_size > size) { nr_rlc_sdu_segment_t *next_sdu; next_sdu = resegment(sdu, entity, size); @@ -474,6 +478,9 @@ 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; + /* update buffer status */ + entity->common.bstatus.tx_size += compute_pdu_header_size(entity, next_sdu) + + next_sdu->size; } /* update tx_next if the SDU is an SDU segment and is the last */ @@ -488,24 +495,6 @@ static int generate_tx_pdu(nr_rlc_entity_um_t *entity, char *buffer, int size) return ret; } -/* Pretend to serialize all the SDUs in a list and return the size - * of all the PDUs it would produce, limited to 'maxsize'. - * Used for buffer status reporting. - */ -static int tx_list_size(nr_rlc_entity_um_t *entity, - nr_rlc_sdu_segment_t *l, int maxsize) -{ - int ret = 0; - - while (l != NULL && ret < maxsize) { - ret += compute_pdu_header_size(entity, l) + l->size; - l = l->next; - } - - if (ret > maxsize) ret = maxsize; - return ret; -} - nr_rlc_entity_buffer_status_t nr_rlc_entity_um_buffer_status( nr_rlc_entity_t *_entity, int maxsize) { @@ -513,7 +502,7 @@ nr_rlc_entity_buffer_status_t nr_rlc_entity_um_buffer_status( nr_rlc_entity_buffer_status_t ret; ret.status_size = 0; - ret.tx_size = tx_list_size(entity, entity->tx_list, maxsize); + ret.tx_size = entity->common.bstatus.tx_size; ret.retx_size = 0; return ret; @@ -545,7 +534,7 @@ void nr_rlc_entity_um_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", + LOG_W(RLC, "%s:%d:%s: warning: SDU rejected, SDU buffer full\n", __FILE__, __LINE__, __FUNCTION__); return; } @@ -555,6 +544,10 @@ void nr_rlc_entity_um_recv_sdu(nr_rlc_entity_t *_entity, sdu = nr_rlc_new_sdu(buffer, size, sdu_id); nr_rlc_sdu_segment_list_append(&entity->tx_list, &entity->tx_end, sdu); + + /* update buffer status */ + entity->common.bstatus.tx_size += compute_pdu_header_size(entity, sdu) + + sdu->size; } /*************************************************************************/ @@ -650,6 +643,10 @@ void nr_rlc_entity_um_discard_sdu(nr_rlc_entity_t *_entity, int sdu_id) entity->tx_end = NULL; } + /* update buffer status */ + entity->common.bstatus.tx_size -= compute_pdu_header_size(entity, cur) + + cur->size; + nr_rlc_free_sdu_segment(cur); } @@ -682,6 +679,8 @@ static void clear_entity(nr_rlc_entity_um_t *entity) entity->tx_list = NULL; entity->tx_end = NULL; entity->tx_size = 0; + + entity->common.bstatus.tx_size = 0; } void nr_rlc_entity_um_reestablishment(nr_rlc_entity_t *_entity) diff --git a/openair2/LAYER2/nr_rlc/nr_rlc_oai_api.c b/openair2/LAYER2/nr_rlc/nr_rlc_oai_api.c index 046696d12fad32d660a790a4d0e8fdbe8fc40fa5..78e06d37e2914fde662a0ffe26471f59e108f122 100644 --- a/openair2/LAYER2/nr_rlc/nr_rlc_oai_api.c +++ b/openair2/LAYER2/nr_rlc/nr_rlc_oai_api.c @@ -346,16 +346,16 @@ rlc_buffer_occupancy_t mac_rlc_get_buffer_occupancy_ind( rlc_op_status_t rlc_data_req (const protocol_ctxt_t *const ctxt_pP, - const srb_flag_t srb_flagP, - const MBMS_flag_t MBMS_flagP, - const rb_id_t rb_idP, - const mui_t muiP, - confirm_t confirmP, - sdu_size_t sdu_sizeP, - mem_block_t *sdu_pP, - const uint32_t *const sourceL2Id, - const uint32_t *const destinationL2Id - ) + const srb_flag_t srb_flagP, + const MBMS_flag_t MBMS_flagP, + const rb_id_t rb_idP, + const mui_t muiP, + confirm_t confirmP, + sdu_size_t sdu_sizeP, + mem_block_t *sdu_pP, + const uint32_t *const sourceL2Id, + const uint32_t *const destinationL2Id + ) { int rnti = ctxt_pP->rnti; nr_rlc_ue_t *ue; @@ -465,19 +465,11 @@ rb_found: LOG_D(RLC, "%s:%d:%s: delivering SDU (rnti %d is_srb %d rb_id %d) size %d\n", __FILE__, __LINE__, __FUNCTION__, ue->rnti, is_srb, rb_id, size); - memblock = get_free_mem_block(size, __func__); - if (memblock == NULL) { - LOG_E(RLC, "%s:%d:%s: ERROR: get_free_mem_block failed\n", __FILE__, __LINE__, __FUNCTION__); - exit(1); - } - memcpy(memblock->data, buf, size); - /* unused fields? */ ctx.instance = 0; ctx.frame = 0; ctx.subframe = 0; ctx.eNB_index = 0; - ctx.configured = 1; ctx.brOption = 0; /* used fields? */ @@ -502,19 +494,44 @@ rb_found: // return; // } - if (NODE_IS_DU(type) && is_srb == 1) { - MessageDef *msg; - msg = itti_alloc_new_message(TASK_RLC_ENB, 0, F1AP_UL_RRC_MESSAGE); - F1AP_UL_RRC_MESSAGE(msg).rnti = ue->rnti; - F1AP_UL_RRC_MESSAGE(msg).srb_id = rb_id; - F1AP_UL_RRC_MESSAGE(msg).rrc_container = (unsigned char *)buf; - F1AP_UL_RRC_MESSAGE(msg).rrc_container_length = size; - itti_send_msg_to_task(TASK_DU_F1, ENB_MODULE_ID_TO_INSTANCE(0 /*ctxt_pP->module_id*/), msg); - return; + if (NODE_IS_DU(type)) { + if(is_srb) { + MessageDef *msg; + msg = itti_alloc_new_message(TASK_RLC_ENB, 0, F1AP_UL_RRC_MESSAGE); + uint8_t *message_buffer = itti_malloc (TASK_RLC_ENB, TASK_DU_F1, size); + memcpy (message_buffer, buf, size); + F1AP_UL_RRC_MESSAGE(msg).rnti = ue->rnti; + F1AP_UL_RRC_MESSAGE(msg).srb_id = rb_id; + F1AP_UL_RRC_MESSAGE(msg).rrc_container = message_buffer; + F1AP_UL_RRC_MESSAGE(msg).rrc_container_length = size; + itti_send_msg_to_task(TASK_DU_F1, ENB_MODULE_ID_TO_INSTANCE(0 /*ctxt_pP->module_id*/), msg); + return; + } else { + MessageDef *msg = itti_alloc_new_message_sized(TASK_RLC_ENB, 0, GTPV1U_GNB_TUNNEL_DATA_REQ, + sizeof(gtpv1u_gnb_tunnel_data_req_t) + size); + gtpv1u_gnb_tunnel_data_req_t *req=>PV1U_GNB_TUNNEL_DATA_REQ(msg); + req->buffer=(uint8_t*)(req+1); + memcpy(req->buffer,buf,size); + req->length=size; + req->offset=0; + req->rnti=ue->rnti; + req->pdusession_id=rb_id; + LOG_D(RLC, "Received uplink user-plane traffic at RLC-DU to be sent to the CU, size %d \n", size); + extern instance_t DUuniqInstance; + itti_send_msg_to_task(OCP_GTPV1_U, DUuniqInstance, msg); + return; + } } } - if (!pdcp_data_ind(&ctx, is_srb, 0, rb_id, size, memblock)) { + memblock = get_free_mem_block(size, __func__); + if (memblock == NULL) { + LOG_E(RLC, "%s:%d:%s: ERROR: get_free_mem_block failed\n", __FILE__, __LINE__, __FUNCTION__); + exit(1); + } + memcpy(memblock->data, buf, size); + LOG_D(PDCP, "Calling PDCP layer from RLC in %s\n", __FUNCTION__); + if (!pdcp_data_ind(&ctx, is_srb, 0, rb_id, size, memblock, NULL, NULL)) { LOG_E(RLC, "%s:%d:%s: ERROR: pdcp_data_ind failed\n", __FILE__, __LINE__, __FUNCTION__); /* what to do in case of failure? for the moment: nothing */ } @@ -721,7 +738,7 @@ static void add_rlc_srb(int rnti, struct NR_SRB_ToAddMod *s, NR_RLC_BearerConfig sn_field_length); nr_rlc_ue_add_srb_rlc_entity(ue, srb_id, nr_rlc_am); - LOG_D(RLC, "%s:%d:%s: added srb %d to UE with RNTI 0x%x\n", __FILE__, __LINE__, __FUNCTION__, srb_id, rnti); + LOG_I(RLC, "%s:%d:%s: added srb %d to UE with RNTI 0x%x\n", __FILE__, __LINE__, __FUNCTION__, srb_id, rnti); } nr_rlc_manager_unlock(nr_rlc_ue_manager); } @@ -803,7 +820,7 @@ static void add_drb_am(int rnti, struct NR_DRB_ToAddMod *s, NR_RLC_BearerConfig_ sn_field_length); nr_rlc_ue_add_drb_rlc_entity(ue, drb_id, nr_rlc_am); - LOG_D(RLC, "%s:%d:%s: added drb %d to UE with RNTI 0x%x\n", __FILE__, __LINE__, __FUNCTION__, drb_id, rnti); + LOG_I(RLC, "%s:%d:%s: added drb %d to UE with RNTI 0x%x\n", __FILE__, __LINE__, __FUNCTION__, drb_id, rnti); } nr_rlc_manager_unlock(nr_rlc_ue_manager); } @@ -918,10 +935,10 @@ rlc_op_status_t nr_rrc_rlc_config_asn1_req (const protocol_ctxt_t * const ctxt if (/*ctxt_pP->enb_flag != 1 ||*/ ctxt_pP->module_id != 0 /*|| ctxt_pP->instance != 0 || ctxt_pP->eNB_index != 0 || - ctxt_pP->configured != 1 || ctxt_pP->brOption != 0 */) { - LOG_E(RLC, "%s: ctxt_pP not handled (%d %d %ld %d %d %d)\n", __FUNCTION__, + ctxt_pP->brOption != 0 */) { + LOG_E(RLC, "%s: ctxt_pP not handled (%d %d %ld %d %d)\n", __FUNCTION__, ctxt_pP->enb_flag , ctxt_pP->module_id, ctxt_pP->instance, - ctxt_pP->eNB_index, ctxt_pP->configured, ctxt_pP->brOption); + ctxt_pP->eNB_index, ctxt_pP->brOption); exit(1); } diff --git a/openair2/LAYER2/nr_rlc/tests/test14.txt.gz b/openair2/LAYER2/nr_rlc/tests/test14.txt.gz index 7ab2fc34310c5652ac1557be39da6d5641e0cdb8..53616dae3d10b71375cea41ca9061d4304f64dcf 100644 Binary files a/openair2/LAYER2/nr_rlc/tests/test14.txt.gz and b/openair2/LAYER2/nr_rlc/tests/test14.txt.gz differ diff --git a/openair2/LAYER2/nr_rlc/tests/test15.txt.gz b/openair2/LAYER2/nr_rlc/tests/test15.txt.gz index e615a59a5faa88571ac77198d4f53f979163309c..2619436c2d4740017eb6b620d8fd0c7b919d3d84 100644 Binary files a/openair2/LAYER2/nr_rlc/tests/test15.txt.gz and b/openair2/LAYER2/nr_rlc/tests/test15.txt.gz differ diff --git a/openair2/LAYER2/nr_rlc/tests/test8.txt.gz b/openair2/LAYER2/nr_rlc/tests/test8.txt.gz index d69e43acdce5dd621905f0c2d731d189b0807e70..c20d43c63b331c2de77e0484922c1b0c1957eb7c 100644 Binary files a/openair2/LAYER2/nr_rlc/tests/test8.txt.gz and b/openair2/LAYER2/nr_rlc/tests/test8.txt.gz differ diff --git a/openair2/LAYER2/nr_rlc/tests/test9.txt.gz b/openair2/LAYER2/nr_rlc/tests/test9.txt.gz index 6def9c20f8dab3b8faa9284fc8cc24dc4201db2e..27590b7d71c435e04cd19603d90cc0c9c0798597 100644 Binary files a/openair2/LAYER2/nr_rlc/tests/test9.txt.gz and b/openair2/LAYER2/nr_rlc/tests/test9.txt.gz differ diff --git a/openair2/LAYER2/rlc_v2/rlc_oai_api.c b/openair2/LAYER2/rlc_v2/rlc_oai_api.c index 0cf4b85fa2cb98145cc1bc24f0a0a41f5eca793f..16c3db0cae3912a551bcff985123cf01a13cbc9d 100644 --- a/openair2/LAYER2/rlc_v2/rlc_oai_api.c +++ b/openair2/LAYER2/rlc_v2/rlc_oai_api.c @@ -394,19 +394,12 @@ rb_found: LOG_D(RLC, "%s:%d:%s: delivering SDU (rnti %d is_srb %d rb_id %d) size %d", __FILE__, __LINE__, __FUNCTION__, ue->rnti, is_srb, rb_id, size); - memblock = get_free_mem_block(size, __func__); - if (memblock == NULL) { - LOG_E(RLC, "%s:%d:%s: ERROR: get_free_mem_block failed\n", __FILE__, __LINE__, __FUNCTION__); - exit(1); - } - memcpy(memblock->data, buf, size); /* unused fields? */ ctx.instance = ue->module_id; ctx.frame = 0; ctx.subframe = 0; ctx.eNB_index = 0; - ctx.configured = 1; ctx.brOption = 0; /* used fields? */ @@ -425,17 +418,40 @@ rb_found: AssertFatal(type != ngran_eNB_CU && type != ngran_ng_eNB_CU && type != ngran_gNB_CU, "Can't be CU, bad node type %d\n", type); - if (NODE_IS_DU(type) && is_srb == 1) { - MessageDef *msg = itti_alloc_new_message(TASK_RLC_ENB, 0, F1AP_UL_RRC_MESSAGE); - F1AP_UL_RRC_MESSAGE(msg).rnti = ue->rnti; - F1AP_UL_RRC_MESSAGE(msg).srb_id = rb_id; - F1AP_UL_RRC_MESSAGE(msg).rrc_container = (unsigned char *)buf; - F1AP_UL_RRC_MESSAGE(msg).rrc_container_length = size; - itti_send_msg_to_task(TASK_DU_F1, ENB_MODULE_ID_TO_INSTANCE(0 /*ctxt_pP->module_id*/), msg); - return; + if (NODE_IS_DU(type)) { + if (is_srb == 1) { + MessageDef *msg = itti_alloc_new_message_sized(TASK_RLC_ENB, 0, F1AP_UL_RRC_MESSAGE, sizeof(*msg) + size); + F1AP_UL_RRC_MESSAGE(msg).rrc_container = (uint8_t*)(msg+1); + memcpy(F1AP_UL_RRC_MESSAGE(msg).rrc_container, buf, size); + F1AP_UL_RRC_MESSAGE(msg).rnti = ue->rnti; + F1AP_UL_RRC_MESSAGE(msg).srb_id = rb_id; + F1AP_UL_RRC_MESSAGE(msg).rrc_container_length = size; + itti_send_msg_to_task(TASK_DU_F1, ENB_MODULE_ID_TO_INSTANCE(0 /*ctxt_pP->module_id*/), msg); + return; + } else { + // Fixme: very dirty workaround of incomplete F1-U implementation + instance_t DUuniqInstance=0; + MessageDef *msg = itti_alloc_new_message(TASK_RLC_ENB, 0, GTPV1U_ENB_TUNNEL_DATA_REQ); + gtpv1u_enb_tunnel_data_req_t *req=>PV1U_ENB_TUNNEL_DATA_REQ(msg); + req->buffer=malloc(size); + memcpy(req->buffer,buf,size); + req->length=size; + req->offset=0; + req->rnti=ue->rnti; + req->rab_id=rb_id+4; + LOG_D(RLC, "Received uplink user-plane traffic at RLC-DU to be sent to the CU, size %d \n", size); + itti_send_msg_to_task(OCP_GTPV1_U, DUuniqInstance, msg); + return; + } } } - + + memblock = get_free_mem_block(size, __func__); + if (memblock == NULL) { + LOG_E(RLC, "%s:%d:%s: ERROR: get_free_mem_block failed\n", __FILE__, __LINE__, __FUNCTION__); + exit(1); + } + memcpy(memblock->data, buf, size); if (!get_pdcp_data_ind_func()(&ctx, is_srb, is_mbms, rb_id, size, memblock, NULL, NULL)) { LOG_E(RLC, "%s:%d:%s: ERROR: pdcp_data_ind failed (is_srb %d rb_id %d rnti %d)\n", __FILE__, __LINE__, __FUNCTION__, @@ -832,10 +848,10 @@ rlc_op_status_t rrc_rlc_config_asn1_req (const protocol_ctxt_t * const ctxt_pP if (0 /*|| ctxt_pP->instance != 0 || ctxt_pP->eNB_index != 0 || - ctxt_pP->configured != 1 || ctxt_pP->brOption != 0 */) { - LOG_E(RLC, "%s: ctxt_pP not handled (%d %d %ld %d %d %d)\n", __FUNCTION__, + ctxt_pP->brOption != 0 */) { + LOG_E(RLC, "%s: ctxt_pP not handled (%d %d %ld %d %d)\n", __FUNCTION__, ctxt_pP->enb_flag , ctxt_pP->module_id, ctxt_pP->instance, - ctxt_pP->eNB_index, ctxt_pP->configured, ctxt_pP->brOption); + ctxt_pP->eNB_index, ctxt_pP->brOption); exit(1); } @@ -1040,5 +1056,12 @@ void du_rlc_data_req(const protocol_ctxt_t *const ctxt_pP, confirm_t confirmP, sdu_size_t sdu_sizeP, mem_block_t *sdu_pP){ - -} \ No newline at end of file + rlc_data_req (ctxt_pP, + srb_flagP, + MBMS_flagP, + rb_idP, + muiP, + confirmP, + sdu_sizeP, + sdu_pP, NULL, NULL); +} diff --git a/openair2/NR_PHY_INTERFACE/NR_IF_Module.c b/openair2/NR_PHY_INTERFACE/NR_IF_Module.c index 4d04f4e0c8062b34283144390d0286b07bfe0bf8..57bb411dcc943c6248a66e211715ed26aecac394 100644 --- a/openair2/NR_PHY_INTERFACE/NR_IF_Module.c +++ b/openair2/NR_PHY_INTERFACE/NR_IF_Module.c @@ -37,6 +37,8 @@ #include "common/ran_context.h" #include "executables/softmodem-common.h" #include "nfapi/oai_integration/vendor_ext.h" +#include "nfapi/oai_integration/gnb_ind_vars.h" +#include "openair2/PHY_INTERFACE/queue_t.h" #define MAX_IF_MODULES 100 //#define UL_HARQ_PRINT @@ -58,150 +60,372 @@ extern uint8_t nfapi_mode; extern uint16_t sf_ahead; extern uint16_t sl_ahead; -void handle_nr_rach(NR_UL_IND_t *UL_info) { + +void handle_nr_rach(NR_UL_IND_t *UL_info) +{ if(NFAPI_MODE == NFAPI_MODE_PNF) { - if (UL_info->rach_ind.number_of_pdus>0) { + if (UL_info->rach_ind.number_of_pdus > 0) { LOG_D(PHY,"UL_info->UL_info->rach_ind.number_of_pdus:%d SFN/Slot:%d.%d \n", UL_info->rach_ind.number_of_pdus, UL_info->rach_ind.sfn,UL_info->rach_ind.slot); oai_nfapi_nr_rach_indication(&UL_info->rach_ind); UL_info->rach_ind.number_of_pdus = 0; } + return; + } + NR_UL_IND_t UL_INFO; + nfapi_nr_rach_indication_t *rach_ind = NULL; + if (get_softmodem_params()->emulate_l1) + { + if (gnb_rach_ind_queue.num_items == 0) + return; + LOG_I(NR_MAC, "gnb_rach_ind_queue size = %zu\n", gnb_rach_ind_queue.num_items); + rach_ind = get_queue(&gnb_rach_ind_queue); + + UL_INFO.rach_ind = *rach_ind; + UL_INFO.module_id = UL_info->module_id; + UL_INFO.CC_id = UL_info->CC_id; + } + else + { + UL_INFO.rach_ind = UL_info->rach_ind; + UL_INFO.module_id = UL_info->module_id; + UL_INFO.CC_id = UL_info->CC_id; } - else{ - if (UL_info->rach_ind.number_of_pdus>0) { - LOG_D(MAC,"UL_info[Frame %d, Slot %d] Calling initiate_ra_proc RACH:SFN/SLOT:%d/%d\n",UL_info->frame,UL_info->slot, UL_info->rach_ind.sfn,UL_info->rach_ind.slot); - int npdus = UL_info->rach_ind.number_of_pdus; - for(int i = 0; i < npdus; i++) { - UL_info->rach_ind.number_of_pdus--; - if (UL_info->rach_ind.pdu_list[i].num_preamble>0) - AssertFatal(UL_info->rach_ind.pdu_list[i].num_preamble==1, - "More than 1 preamble not supported\n"); - - nr_initiate_ra_proc(UL_info->module_id, - UL_info->CC_id, - UL_info->rach_ind.sfn, - UL_info->rach_ind.slot, - UL_info->rach_ind.pdu_list[i].preamble_list[0].preamble_index, - UL_info->rach_ind.pdu_list[i].freq_index, - UL_info->rach_ind.pdu_list[i].symbol_index, - UL_info->rach_ind.pdu_list[i].preamble_list[0].timing_advance); + + int frame_diff = UL_info->frame - UL_INFO.rach_ind.sfn; + if (frame_diff < 0) + { + frame_diff += 1024; + } + bool in_timewindow = frame_diff == 0 || (frame_diff == 1 && UL_info->slot < 7); + + if (UL_INFO.rach_ind.number_of_pdus>0 && in_timewindow) { + LOG_A(MAC,"UL_info[Frame %d, Slot %d] Calling initiate_ra_proc RACH:SFN/SLOT:%d/%d\n", + UL_info->frame, UL_info->slot, UL_INFO.rach_ind.sfn, UL_INFO.rach_ind.slot); + int npdus = UL_INFO.rach_ind.number_of_pdus; + for(int i = 0; i < npdus; i++) { + UL_INFO.rach_ind.number_of_pdus--; + UL_info->rach_ind.number_of_pdus--; + if (UL_INFO.rach_ind.pdu_list[i].num_preamble>0) + AssertFatal(UL_INFO.rach_ind.pdu_list[i].num_preamble==1, + "More than 1 preamble not supported\n"); + + nr_initiate_ra_proc(UL_INFO.module_id, + UL_INFO.CC_id, + UL_INFO.rach_ind.sfn, + UL_INFO.rach_ind.slot, + UL_INFO.rach_ind.pdu_list[i].preamble_list[0].preamble_index, + UL_INFO.rach_ind.pdu_list[i].freq_index, + UL_INFO.rach_ind.pdu_list[i].symbol_index, + UL_INFO.rach_ind.pdu_list[i].preamble_list[0].timing_advance); + } + } + if (get_softmodem_params()->emulate_l1) + { + if (rach_ind && rach_ind->number_of_pdus > 0) + { + for(int i = 0; i < rach_ind->number_of_pdus; i++) + { + free(rach_ind->pdu_list[i].preamble_list); + rach_ind->pdu_list[i].preamble_list = NULL; } + free(rach_ind->pdu_list); + rach_ind->pdu_list = NULL; } + free(rach_ind); + rach_ind = NULL; } } void handle_nr_uci(NR_UL_IND_t *UL_info) -{ +{ if(NFAPI_MODE == NFAPI_MODE_PNF) { - if (UL_info->uci_ind.num_ucis>0) { + if (UL_info->uci_ind.num_ucis > 0) { LOG_D(PHY,"PNF Sending UL_info->num_ucis:%d PDU_type: %d, SFN/SF:%d.%d \n", UL_info->uci_ind.num_ucis, UL_info->uci_ind.uci_list[0].pdu_type ,UL_info->frame, UL_info->slot); oai_nfapi_nr_uci_indication(&UL_info->uci_ind); UL_info->uci_ind.num_ucis = 0; } + return; } - else{ - const module_id_t mod_id = UL_info->module_id; - const frame_t frame = UL_info->frame; - const sub_frame_t slot = UL_info->slot; - int num_ucis = UL_info->uci_ind.num_ucis; - nfapi_nr_uci_t *uci_list = UL_info->uci_ind.uci_list; - LOG_D(MAC,"handling UCI SFN/slot: %d.%d, num_ucis: %d \n", frame,slot, num_ucis); - for (int i = 0; i < num_ucis; i++) { - switch (uci_list[i].pdu_type) { - case NFAPI_NR_UCI_PUSCH_PDU_TYPE: - LOG_E(MAC, "%s(): unhandled NFAPI_NR_UCI_PUSCH_PDU_TYPE\n", __func__); - break; - case NFAPI_NR_UCI_FORMAT_0_1_PDU_TYPE: { - const nfapi_nr_uci_pucch_pdu_format_0_1_t *uci_pdu = &uci_list[i].pucch_pdu_format_0_1; - handle_nr_uci_pucch_0_1(mod_id, frame, slot, uci_pdu); - break; - } + NR_UL_IND_t UL_INFO; + nfapi_nr_uci_indication_t *uci_ind = NULL; + if (get_softmodem_params()->emulate_l1) + { + if (gnb_uci_ind_queue.num_items == 0) + return; + LOG_I(NR_MAC, "gnb_uci_ind_queue size = %zu\n", gnb_uci_ind_queue.num_items); + uci_ind = get_queue(&gnb_uci_ind_queue); + UL_INFO.uci_ind = *uci_ind; + } + else + { + UL_INFO.uci_ind = UL_info->uci_ind; + } + + const module_id_t mod_id = UL_info->module_id; + const frame_t frame = UL_INFO.uci_ind.sfn; + const sub_frame_t slot = UL_INFO.uci_ind.slot; + int num_ucis = UL_INFO.uci_ind.num_ucis; + nfapi_nr_uci_t *uci_list = UL_INFO.uci_ind.uci_list; + + for (int i = 0; i < num_ucis; i++) { + switch (uci_list[i].pdu_type) { + case NFAPI_NR_UCI_PUSCH_PDU_TYPE: + LOG_E(MAC, "%s(): unhandled NFAPI_NR_UCI_PUSCH_PDU_TYPE\n", __func__); + break; + + case NFAPI_NR_UCI_FORMAT_0_1_PDU_TYPE: { + const nfapi_nr_uci_pucch_pdu_format_0_1_t *uci_pdu = &uci_list[i].pucch_pdu_format_0_1; + LOG_D(NR_MAC, "The received uci has sfn slot %d %d, num_ucis %d and pdu_size %d\n", + UL_INFO.uci_ind.sfn, UL_INFO.uci_ind.slot, num_ucis, uci_list[i].pdu_size); + handle_nr_uci_pucch_0_1(mod_id, frame, slot, uci_pdu); + break; + } case NFAPI_NR_UCI_FORMAT_2_3_4_PDU_TYPE: { const nfapi_nr_uci_pucch_pdu_format_2_3_4_t *uci_pdu = &uci_list[i].pucch_pdu_format_2_3_4; handle_nr_uci_pucch_2_3_4(mod_id, frame, slot, uci_pdu); break; } - } LOG_D(MAC, "UCI handled \n"); } } - UL_info->uci_ind.num_ucis = 0; + if (get_softmodem_params()->emulate_l1) + { + for (int i = 0; i < num_ucis; i++) { + switch (uci_list[i].pdu_type) { + case NFAPI_NR_UCI_FORMAT_0_1_PDU_TYPE: + if (uci_list[i].pucch_pdu_format_0_1.harq) { + free(uci_list[i].pucch_pdu_format_0_1.harq->harq_list); + uci_list[i].pucch_pdu_format_0_1.harq->harq_list = NULL; + } + free(uci_list[i].pucch_pdu_format_0_1.harq); + uci_list[i].pucch_pdu_format_0_1.harq = NULL; + free(uci_list[i].pucch_pdu_format_0_1.sr); + uci_list[i].pucch_pdu_format_0_1.sr = NULL; + break; + + case NFAPI_NR_UCI_FORMAT_2_3_4_PDU_TYPE: + free(uci_list[i].pucch_pdu_format_2_3_4.harq.harq_payload); + free(uci_list[i].pucch_pdu_format_2_3_4.csi_part1.csi_part1_payload); + free(uci_list[i].pucch_pdu_format_2_3_4.csi_part2.csi_part2_payload); + break; + } + } + if (uci_ind && num_ucis > 0) { + free(uci_list); + uci_list = NULL; + } + free(uci_ind); + uci_ind = NULL; + } + else + { + UL_info->uci_ind.num_ucis = 0; + } +} + +static bool crc_sfn_slot_matcher(void *wanted, void *candidate) +{ + nfapi_p7_message_header_t *msg = candidate; + int sfn_sf = *(int*)wanted; + + switch (msg->message_id) + { + case NFAPI_NR_PHY_MSG_TYPE_CRC_INDICATION: + { + nfapi_nr_crc_indication_t *ind = candidate; + return NFAPI_SFNSLOT2SFN(sfn_sf) == ind->sfn && NFAPI_SFNSLOT2SLOT(sfn_sf) == ind->slot; + } + + default: + LOG_E(NR_MAC, "sfn_slot_match bad ID: %d\n", msg->message_id); + + } + return false; } void handle_nr_ulsch(NR_UL_IND_t *UL_info) { if(NFAPI_MODE == NFAPI_MODE_PNF) { - if (UL_info->crc_ind.number_crcs>0) { + if (UL_info->crc_ind.number_crcs > 0) { LOG_D(PHY,"UL_info->UL_info->crc_ind.number_crcs:%d CRC_IND:SFN/Slot:%d.%d\n", UL_info->crc_ind.number_crcs, UL_info->crc_ind.sfn, UL_info->crc_ind.slot); oai_nfapi_nr_crc_indication(&UL_info->crc_ind); UL_info->crc_ind.number_crcs = 0; } - if (UL_info->rx_ind.number_of_pdus>0) { + if (UL_info->rx_ind.number_of_pdus > 0) { LOG_D(PHY,"UL_info->rx_ind.number_of_pdus:%d RX_IND:SFN/Slot:%d.%d \n", UL_info->rx_ind.number_of_pdus, UL_info->rx_ind.sfn, UL_info->rx_ind.slot); oai_nfapi_nr_rx_data_indication(&UL_info->rx_ind); UL_info->rx_ind.number_of_pdus = 0; } + return; } - else{ - if (UL_info->rx_ind.number_of_pdus > 0 && UL_info->crc_ind.number_crcs > 0) { - for (int i = 0; i < UL_info->rx_ind.number_of_pdus; i++) { - for (int j = 0; j < UL_info->crc_ind.number_crcs; j++) { - // find crc_indication j corresponding rx_indication i - const nfapi_nr_rx_data_pdu_t *rx = &UL_info->rx_ind.pdu_list[i]; - const nfapi_nr_crc_t *crc = &UL_info->crc_ind.crc_list[j]; - LOG_D(PHY, - "UL_info->crc_ind.pdu_list[%d].rnti:%04x " - "UL_info->rx_ind.pdu_list[%d].rnti:%04x\n", - j, - crc->rnti, - i, - rx->rnti); - - if (crc->rnti != rx->rnti) - continue; - - LOG_D(MAC, - "%4d.%2d Calling rx_sdu (CRC %s/tb_crc_status %d)\n", - UL_info->frame, - UL_info->slot, - crc->tb_crc_status ? "error" : "ok", - crc->tb_crc_status); - - /* if CRC passes, pass PDU, otherwise pass NULL as error indication */ - nr_rx_sdu(UL_info->module_id, - UL_info->CC_id, - UL_info->rx_ind.sfn, - UL_info->rx_ind.slot, - rx->rnti, - crc->tb_crc_status ? NULL : rx->pdu, - rx->pdu_length, - rx->timing_advance, - rx->ul_cqi, - rx->rssi); - handle_nr_ul_harq(UL_info->CC_id, UL_info->module_id, UL_info->frame, UL_info->slot, crc); - break; - } // for (j=0;j<UL_info->crc_ind.number_crcs;j++) - } // for (i=0;i<UL_info->rx_ind.number_of_pdus;i++) + NR_UL_IND_t UL_INFO; + nfapi_nr_rx_data_indication_t *rx_ind = NULL; + nfapi_nr_crc_indication_t *crc_ind = NULL; + if (get_softmodem_params()->emulate_l1) + { + rx_ind = get_queue(&gnb_rx_ind_queue); + if (!rx_ind) + { + LOG_D(NR_PHY, "No rx data indication (empty gnb_rx_ind_queue)\n"); + return; + } + + int sfn_slot = NFAPI_SFNSLOT2HEX(rx_ind->sfn, rx_ind->slot); + + crc_ind = unqueue_matching(&gnb_crc_ind_queue, + MAX_QUEUE_SIZE, + crc_sfn_slot_matcher, + &sfn_slot); + if (!crc_ind) + { + LOG_D(NR_PHY, "No crc indication with the same SFN SLOT of rx indication %u %u\n", rx_ind->sfn, rx_ind->slot); + put_queue(&gnb_rx_ind_queue, rx_ind); + return; + } + + UL_INFO.rx_ind = *rx_ind; + UL_INFO.crc_ind = *crc_ind; + UL_INFO.module_id = UL_info->module_id; + UL_INFO.CC_id = UL_info->CC_id; + } + else + { + UL_INFO.rx_ind = UL_info->rx_ind; + UL_INFO.crc_ind = UL_info->crc_ind; + UL_INFO.module_id = UL_info->module_id; + UL_INFO.CC_id = UL_info->CC_id; + } + + UL_INFO.frame = UL_INFO.rx_ind.sfn; + UL_INFO.slot = UL_INFO.rx_ind.slot; + UL_INFO.module_id = UL_info->module_id; + UL_INFO.CC_id = UL_info->CC_id; + LOG_D(NR_MAC, " UL_info frame slot vs rx_ind frame slot vs crc_ind slot frame slot = %u %u vs %u %u vs %u %u\n", + UL_info->frame, UL_info->slot, + UL_INFO.rx_ind.sfn, UL_INFO.rx_ind.slot, + UL_INFO.crc_ind.sfn, UL_INFO.crc_ind.slot + ); + + if (UL_INFO.rx_ind.number_of_pdus > 0 && UL_INFO.crc_ind.number_crcs > 0) { + for (int i = 0; i < UL_INFO.rx_ind.number_of_pdus; i++) { + int j; + for (j = 0; j < UL_INFO.crc_ind.number_crcs; j++) { + // find crc_indication j corresponding rx_indication i + const nfapi_nr_rx_data_pdu_t *rx = &UL_INFO.rx_ind.pdu_list[i]; + const nfapi_nr_crc_t *crc = &UL_INFO.crc_ind.crc_list[j]; + LOG_D(NR_PHY, + "UL_INFO.crc_ind.pdu_list[%d].rnti:%04x " + "UL_INFO.rx_ind.pdu_list[%d].rnti:%04x\n", + j, + crc->rnti, + i, + rx->rnti); + + if (crc->rnti != rx->rnti) + { + LOG_D(NR_MAC, "mis-match between CRC rnti %04x and RX rnit %04x\n", crc->rnti, rx->rnti); + continue; + } + + LOG_D(NR_MAC, + "%4d.%2d Calling rx_sdu (CRC %s/tb_crc_status %d)\n", + UL_INFO.frame, + UL_INFO.slot, + crc->tb_crc_status ? "error" : "ok", + crc->tb_crc_status); + + /* if CRC passes, pass PDU, otherwise pass NULL as error indication */ + nr_rx_sdu(UL_INFO.module_id, + UL_INFO.CC_id, + UL_INFO.rx_ind.sfn, + UL_INFO.rx_ind.slot, + rx->rnti, + crc->tb_crc_status ? NULL : rx->pdu, + rx->pdu_length, + rx->timing_advance, + rx->ul_cqi, + rx->rssi); + handle_nr_ul_harq(UL_INFO.CC_id, UL_INFO.module_id, UL_INFO.frame, UL_INFO.slot, crc); + break; + } // for (j=0;j<UL_INFO.crc_ind.number_crcs;j++) + if (get_softmodem_params()->emulate_l1) + { + int last = UL_INFO.crc_ind.number_crcs - 1; + if (j < last) + { + crc_ind->crc_list[j] = crc_ind->crc_list[last]; + UL_INFO.crc_ind.number_crcs--; + } + else if (j == last) + { + UL_INFO.crc_ind.number_crcs--; + } + + last = UL_INFO.rx_ind.number_of_pdus - 1; + if (i < last) + { + rx_ind->pdu_list[i] = rx_ind->pdu_list[last]; + UL_INFO.rx_ind.number_of_pdus--; + i--; + } + else if (i == last) + { + UL_INFO.rx_ind.number_of_pdus--; + } + } + } // for (i=0;i<UL_INFO.rx_ind.number_of_pdus;i++) + if (get_softmodem_params()->emulate_l1) + { + if (UL_INFO.crc_ind.number_crcs > 0) + { + crc_ind->number_crcs = UL_INFO.crc_ind.number_crcs; + requeue(&gnb_crc_ind_queue, crc_ind); + } + + if (UL_INFO.rx_ind.number_of_pdus > 0) + { + rx_ind->number_of_pdus = UL_INFO.rx_ind.number_of_pdus; + requeue(&gnb_rx_ind_queue, rx_ind); + } + + if (UL_INFO.crc_ind.number_crcs == 0) + { + free(crc_ind->crc_list); + crc_ind->crc_list = NULL; + free(crc_ind); + crc_ind = NULL; + } + if (UL_INFO.rx_ind.number_of_pdus == 0) + { + free(rx_ind->pdu_list); + rx_ind->pdu_list = NULL; + free(rx_ind); + rx_ind = NULL; + } + } + else + { UL_info->crc_ind.number_crcs = 0; UL_info->rx_ind.number_of_pdus = 0; - } else if (UL_info->rx_ind.number_of_pdus != 0 - || UL_info->crc_ind.number_crcs != 0) { - LOG_E(PHY, - "hoping not to have mis-match between CRC ind and RX ind - " - "hopefully the missing message is coming shortly " - "rx_ind:%d(SFN/SL:%d/%d) crc_ind:%d(SFN/SL:%d/%d) \n", - UL_info->rx_ind.number_of_pdus, - UL_info->rx_ind.sfn, - UL_info->rx_ind.slot, - UL_info->crc_ind.number_crcs, - UL_info->rx_ind.sfn, - UL_info->rx_ind.slot); } + } else if ((UL_INFO.rx_ind.number_of_pdus != 0) + || (UL_INFO.crc_ind.number_crcs != 0)) { + LOG_E(NR_PHY, + "hoping not to have mis-match between CRC ind and RX ind - " + "hopefully the missing message is coming shortly " + "rx_ind:%d(SFN/SL:%d/%d) crc_ind:%d(SFN/SL:%d/%d) \n", + UL_INFO.rx_ind.number_of_pdus, + UL_INFO.rx_ind.sfn, + UL_INFO.rx_ind.slot, + UL_INFO.crc_ind.number_crcs, + UL_INFO.crc_ind.sfn, + UL_INFO.crc_ind.slot); } } @@ -215,10 +439,10 @@ void NR_UL_indication(NR_UL_IND_t *UL_info) { NR_Sched_Rsp_t *sched_info = &NR_Sched_INFO[module_id][CC_id]; NR_IF_Module_t *ifi = nr_if_inst[module_id]; gNB_MAC_INST *mac = RC.nrmac[module_id]; - LOG_D(PHY,"SFN/SF:%d%d module_id:%d CC_id:%d UL_info[rach_pdus:%d rx_ind:%d crcs:%d]\n", + LOG_D(NR_PHY,"SFN/SLOT:%d.%d module_id:%d CC_id:%d UL_info[rach_pdus:%zu rx_ind:%zu crcs:%zu]\n", UL_info->frame,UL_info->slot, - module_id,CC_id, UL_info->rach_ind.number_of_pdus, - UL_info->rx_ind.number_of_pdus, UL_info->crc_ind.number_crcs); + module_id,CC_id, gnb_rach_ind_queue.num_items, + gnb_rx_ind_queue.num_items, gnb_crc_ind_queue.num_items); handle_nr_rach(UL_info); @@ -250,7 +474,7 @@ void NR_UL_indication(NR_UL_IND_t *UL_info) { gNB_dlsch_ulsch_scheduler(module_id, (UL_info->frame+((UL_info->slot>(spf-1-sl_ahead))?1:0)) % 1024, (UL_info->slot+sl_ahead)%spf); - + ifi->CC_mask = 0; sched_info->module_id = module_id; sched_info->CC_id = CC_id; @@ -272,7 +496,7 @@ void NR_UL_indication(NR_UL_IND_t *UL_info) { CC_id); ifi->NR_Schedule_response(sched_info); - LOG_D(PHY,"NR_Schedule_response: SFN_SF:%d%d dl_pdus:%d\n", + LOG_D(NR_PHY,"NR_Schedule_response: SFN SLOT:%d %d dl_pdus:%d\n", sched_info->frame, sched_info->slot, sched_info->DL_req->dl_tti_request_body.nPDUs); diff --git a/openair2/NR_PHY_INTERFACE/NR_IF_Module.h b/openair2/NR_PHY_INTERFACE/NR_IF_Module.h index d523d6e0f0dd948db17b42dc714b0389d3aad4a4..f857151763499653ee38e8ccf79995be93ddad83 100644 --- a/openair2/NR_PHY_INTERFACE/NR_IF_Module.h +++ b/openair2/NR_PHY_INTERFACE/NR_IF_Module.h @@ -124,6 +124,8 @@ void NR_IF_Module_kill(int Mod_id); void NR_UL_indication(NR_UL_IND_t *UL_INFO); +void RCconfig_nr_ue_L1(void); + /*Interface for Downlink, transmitting the DLSCH SDU, DCI SDU*/ void NR_Schedule_Response(NR_Sched_Rsp_t *Sched_INFO); diff --git a/openair2/NR_UE_PHY_INTERFACE/NR_IF_Module.c b/openair2/NR_UE_PHY_INTERFACE/NR_IF_Module.c index b5c2f666a295eb68ce83c06a6b9d2b07e1d45b93..c7b54950d7c66eb9cc16653fa1276953100a033c 100644 --- a/openair2/NR_UE_PHY_INTERFACE/NR_IF_Module.c +++ b/openair2/NR_UE_PHY_INTERFACE/NR_IF_Module.c @@ -37,14 +37,967 @@ #include "NR_MAC_UE/mac_extern.h" #include "SCHED_NR_UE/fapi_nr_ue_l1.h" #include "executables/softmodem-common.h" - +#include "openair2/RRC/NR_UE/rrc_proto.h" +#include "openair2/GNB_APP/L1_nr_paramdef.h" +#include "openair2/GNB_APP/gnb_paramdef.h" +#include "targets/ARCH/ETHERNET/USERSPACE/LIB/if_defs.h" #include <stdio.h> #define MAX_IF_MODULES 100 -const char *dl_indication_type[] = {"MIB", "SIB", "DLSCH", "DCI", "RAR"}; +UL_IND_t *UL_INFO = NULL; +static eth_params_t stub_eth_params; static nr_ue_if_module_t *nr_ue_if_module_inst[MAX_IF_MODULES]; +static int ue_tx_sock_descriptor = -1; +static int ue_rx_sock_descriptor = -1; +static int g_harq_pid; +sem_t sfn_slot_semaphore; + +queue_t nr_sfn_slot_queue; +queue_t nr_chan_param_queue; +queue_t nr_dl_tti_req_queue; +queue_t nr_tx_req_queue; +queue_t nr_ul_dci_req_queue; +queue_t nr_ul_tti_req_queue; +queue_t nr_wait_ul_tti_req_queue; + +void nrue_init_standalone_socket(int tx_port, int rx_port) +{ + { + struct sockaddr_in server_address; + int addr_len = sizeof(server_address); + memset(&server_address, 0, addr_len); + server_address.sin_family = AF_INET; + server_address.sin_port = htons(tx_port); + + int sd = socket(server_address.sin_family, SOCK_DGRAM, 0); + if (sd < 0) + { + LOG_E(MAC, "Socket creation error standalone PNF\n"); + return; + } + + if (inet_pton(server_address.sin_family, stub_eth_params.remote_addr, &server_address.sin_addr) <= 0) + { + LOG_E(MAC, "Invalid standalone PNF Address\n"); + close(sd); + return; + } + + // Using connect to use send() instead of sendto() + if (connect(sd, (struct sockaddr *)&server_address, addr_len) < 0) + { + LOG_E(MAC, "Connection to standalone PNF failed: %s\n", strerror(errno)); + close(sd); + return; + } + assert(ue_tx_sock_descriptor == -1); + ue_tx_sock_descriptor = sd; + LOG_D(NR_RRC, "Successfully set up tx_socket in %s.\n", __FUNCTION__); + } + + { + struct sockaddr_in server_address; + int addr_len = sizeof(server_address); + memset(&server_address, 0, addr_len); + server_address.sin_family = AF_INET; + server_address.sin_addr.s_addr = INADDR_ANY; + server_address.sin_port = htons(rx_port); + + int sd = socket(server_address.sin_family, SOCK_DGRAM, 0); + if (sd < 0) + { + LOG_E(MAC, "Socket creation error standalone PNF\n"); + return; + } + + if (bind(sd, (struct sockaddr *)&server_address, addr_len) < 0) + { + LOG_E(MAC, "Connection to standalone PNF failed: %s\n", strerror(errno)); + close(sd); + return; + } + assert(ue_rx_sock_descriptor == -1); + ue_rx_sock_descriptor = sd; + LOG_D(NR_RRC, "Successfully set up rx_socket in %s.\n", __FUNCTION__); + } + LOG_I(NR_RRC, "NRUE standalone socket info: tx_port %d rx_port %d on %s.\n", + tx_port, rx_port, stub_eth_params.remote_addr); +} + +void send_nsa_standalone_msg(NR_UL_IND_t *UL_INFO, uint16_t msg_id) +{ + switch(msg_id) + { + case NFAPI_NR_PHY_MSG_TYPE_RACH_INDICATION: + { + char buffer[NFAPI_MAX_PACKED_MESSAGE_SIZE]; + LOG_D(NR_MAC, "RACH header id :%d", UL_INFO->rach_ind.header.message_id); + int encoded_size = nfapi_nr_p7_message_pack(&UL_INFO->rach_ind, buffer, sizeof(buffer), NULL); + if (encoded_size <= 0) + { + LOG_E(NR_MAC, "nfapi_nr_p7_message_pack has failed. Encoded size = %d\n", encoded_size); + return; + } + + LOG_I(NR_MAC, "NR_RACH_IND sent to Proxy, Size: %d Frame %d Slot %d Num PDUS %d\n", encoded_size, + UL_INFO->rach_ind.sfn, UL_INFO->rach_ind.slot, UL_INFO->rach_ind.number_of_pdus); + if (send(ue_tx_sock_descriptor, buffer, encoded_size, 0) < 0) + { + LOG_E(NR_MAC, "Send Proxy NR_UE failed\n"); + return; + } + break; + } + case NFAPI_NR_PHY_MSG_TYPE_RX_DATA_INDICATION: + { + char buffer[NFAPI_MAX_PACKED_MESSAGE_SIZE]; + LOG_D(NR_MAC, "RX header id :%d", UL_INFO->rx_ind.header.message_id); + int encoded_size = nfapi_nr_p7_message_pack(&UL_INFO->rx_ind, buffer, sizeof(buffer), NULL); + if (encoded_size <= 0) + { + LOG_E(NR_MAC, "nfapi_nr_p7_message_pack has failed. Encoded size = %d\n", encoded_size); + return; + } + + LOG_I(NR_MAC, "NR_RX_IND sent to Proxy, Size: %d Frame %d Slot %d Num PDUS %d\n", encoded_size, + UL_INFO->rx_ind.sfn, UL_INFO->rx_ind.slot, UL_INFO->rx_ind.number_of_pdus); + if (send(ue_tx_sock_descriptor, buffer, encoded_size, 0) < 0) + { + LOG_E(NR_MAC, "Send Proxy NR_UE failed\n"); + return; + } + break; + } + case NFAPI_NR_PHY_MSG_TYPE_CRC_INDICATION: + { + char buffer[NFAPI_MAX_PACKED_MESSAGE_SIZE]; + LOG_D(NR_MAC, "CRC header id :%d", UL_INFO->crc_ind.header.message_id); + int encoded_size = nfapi_nr_p7_message_pack(&UL_INFO->crc_ind, buffer, sizeof(buffer), NULL); + if (encoded_size <= 0) + { + LOG_E(NR_MAC, "nfapi_nr_p7_message_pack has failed. Encoded size = %d\n", encoded_size); + return; + } + + LOG_I(NR_MAC, "NR_CRC_IND sent to Proxy, Size: %d Frame %d Slot %d Num PDUS %d\n", encoded_size, + UL_INFO->crc_ind.sfn, UL_INFO->crc_ind.slot, UL_INFO->crc_ind.number_crcs); + if (send(ue_tx_sock_descriptor, buffer, encoded_size, 0) < 0) + { + LOG_E(NR_MAC, "Send Proxy NR_UE failed\n"); + return; + } + break; + } + case NFAPI_NR_PHY_MSG_TYPE_UCI_INDICATION: + { + char buffer[NFAPI_MAX_PACKED_MESSAGE_SIZE]; + LOG_I(NR_MAC, "UCI header id :%d", UL_INFO->uci_ind.header.message_id); + int encoded_size = nfapi_nr_p7_message_pack(&UL_INFO->uci_ind, buffer, sizeof(buffer), NULL); + if (encoded_size <= 0) + { + LOG_E(NR_MAC, "nfapi_nr_p7_message_pack has failed. Encoded size = %d\n", encoded_size); + return; + } + + LOG_I(NR_MAC, "NR_UCI_IND sent to Proxy, Size: %d Frame %d Slot %d Num PDUS %d\n", encoded_size, + UL_INFO->uci_ind.sfn, UL_INFO->uci_ind.slot, UL_INFO->uci_ind.num_ucis); + if (send(ue_tx_sock_descriptor, buffer, encoded_size, 0) < 0) + { + LOG_E(NR_MAC, "Send Proxy NR_UE failed\n"); + return; + } + break; + } + case NFAPI_NR_PHY_MSG_TYPE_SRS_INDICATION: + break; + default: + break; + } +} + +static void fill_dl_info_with_pdcch(fapi_nr_dci_indication_t *dci, nfapi_nr_dl_dci_pdu_t *rx_dci, int idx) +{ + int num_bytes = (rx_dci->PayloadSizeBits + 7) / 8; + LOG_I(NR_PHY, "[%d, %d] PDCCH DCI (Payload) for rnti %x with PayloadSizeBits %d, num_bytes %d\n", + dci->SFN, dci->slot, rx_dci->RNTI, rx_dci->PayloadSizeBits, num_bytes); + for (int k = 0; k < num_bytes; k++) + { + LOG_I(NR_MAC, "PDCCH DCI PDU payload[%d] = %d\n", k, rx_dci->Payload[k]); + dci->dci_list[idx].payloadBits[k] = rx_dci->Payload[k]; + } + dci->dci_list[idx].payloadSize = rx_dci->PayloadSizeBits; + dci->dci_list[idx].rnti = rx_dci->RNTI; + dci->number_of_dcis = idx + 1; +} + +static void fill_mib_in_rx_ind(nfapi_nr_dl_tti_request_pdu_t *pdu_list, fapi_nr_rx_indication_t *rx_ind, int pdu_idx, int pdu_type) +{ + AssertFatal(pdu_idx < sizeof(rx_ind->rx_indication_body) / sizeof(rx_ind->rx_indication_body[0]), + "pdu_index (%d) is greater than rx_indication_body size!\n", pdu_idx); + AssertFatal(pdu_idx == rx_ind->number_pdus, "Invalid pdu_idx %d!\n", pdu_idx); + + LOG_D(NR_MAC, "Recevied an SSB and are filling rx_ind with the MIB!\n"); + + nfapi_nr_dl_tti_ssb_pdu_rel15_t *ssb_pdu = &pdu_list->ssb_pdu.ssb_pdu_rel15; + rx_ind->rx_indication_body[pdu_idx].ssb_pdu.cell_id = ssb_pdu->PhysCellId; + rx_ind->rx_indication_body[pdu_idx].ssb_pdu.pdu = MALLOC(3 * sizeof(*rx_ind->rx_indication_body[pdu_idx].ssb_pdu.pdu)); + rx_ind->rx_indication_body[pdu_idx].ssb_pdu.pdu[0] = (ssb_pdu->bchPayload) & 0xff; + rx_ind->rx_indication_body[pdu_idx].ssb_pdu.pdu[1] = (ssb_pdu->bchPayload >> 8) & 0xff; + rx_ind->rx_indication_body[pdu_idx].ssb_pdu.pdu[2] = (ssb_pdu->bchPayload >> 16) & 0xff; + rx_ind->rx_indication_body[pdu_idx].ssb_pdu.rsrp_dBm = ssb_pdu->ssbRsrp; + rx_ind->rx_indication_body[pdu_idx].ssb_pdu.ssb_index = ssb_pdu->SsbBlockIndex; + rx_ind->rx_indication_body[pdu_idx].ssb_pdu.ssb_length = pdu_list->PDUSize; + rx_ind->rx_indication_body[pdu_idx].ssb_pdu.ssb_start_subcarrier = ssb_pdu->SsbSubcarrierOffset; + rx_ind->rx_indication_body[pdu_idx].pdu_type = pdu_type; + rx_ind->number_pdus = pdu_idx + 1; + +} + +static bool is_my_dci(NR_UE_MAC_INST_t *mac, nfapi_nr_dl_dci_pdu_t *received_pdu) +{ + /* For multiple UEs, we need to be able to filter the rx'd messages by + the RNTI. The filtering is different between NSA mode and SA mode. + NSA mode has a two step CFRA procedure and SA has a 4 step procedure. + We only need to check if the rx'd RNTI doesnt match the CRNTI if the RAR + has been processed already, in NSA mode. + In SA, depending on the RA state, we can have a SIB (0xffff), RAR (0x10b), + Msg3 (TC_RNTI) or an actual DCI message (CRNTI). When we get Msg3, the + MAC instance of the UE still has a CRNTI = 0. We should only check if the + CRNTI doesnt match the received RNTI in SA mode if Msg3 has been processed + already. Only once the RA procedure succeeds is the CRNTI value updated + to the TC_RNTI. */ + if (get_softmodem_params()->nsa) + { + if (received_pdu->RNTI != mac->crnti && + (received_pdu->RNTI != mac->ra.ra_rnti || mac->ra.RA_RAPID_found)) + return false; + } + if (get_softmodem_params()->sa) + { + if (received_pdu->RNTI != mac->crnti && mac->ra.ra_state == RA_SUCCEEDED) + return false; + if (received_pdu->RNTI != mac->ra.t_crnti && mac->ra.ra_state == WAIT_CONTENTION_RESOLUTION) + return false; + if (received_pdu->RNTI != 0x10b && mac->ra.ra_state == WAIT_RAR) + return false; + if (received_pdu->RNTI != 0xFFFF && mac->ra.ra_state <= GENERATE_PREAMBLE) + return false; + } + return true; +} + +static void copy_dl_tti_req_to_dl_info(nr_downlink_indication_t *dl_info, nfapi_nr_dl_tti_request_t *dl_tti_request) +{ + NR_UE_MAC_INST_t *mac = get_mac_inst(dl_info->module_id); + mac->nr_ue_emul_l1.expected_sib = false; + memset(mac->nr_ue_emul_l1.index_has_sib, 0, sizeof(*mac->nr_ue_emul_l1.index_has_sib)); + mac->nr_ue_emul_l1.expected_rar = false; + memset(mac->nr_ue_emul_l1.index_has_rar, 0, sizeof(*mac->nr_ue_emul_l1.index_has_rar)); + mac->nr_ue_emul_l1.expected_dci = false; + memset(mac->nr_ue_emul_l1.index_has_dci, 0, sizeof(*mac->nr_ue_emul_l1.index_has_dci)); + int pdu_idx = 0; + + int num_pdus = dl_tti_request->dl_tti_request_body.nPDUs; + AssertFatal(num_pdus >= 0, "Invalid dl_tti_request number of PDUS\n"); + + for (int i = 0; i < num_pdus; i++) + { + nfapi_nr_dl_tti_request_pdu_t *pdu_list = &dl_tti_request->dl_tti_request_body.dl_tti_pdu_list[i]; + if (pdu_list->PDUType == NFAPI_NR_DL_TTI_PDSCH_PDU_TYPE) + { + LOG_I(NR_PHY, "[%d, %d] PDSCH PDU for rnti %x\n", + dl_tti_request->SFN, dl_tti_request->Slot, pdu_list->pdsch_pdu.pdsch_pdu_rel15.rnti); + } + + if (pdu_list->PDUType == NFAPI_NR_DL_TTI_PDCCH_PDU_TYPE) + { + LOG_I(NR_PHY, "[%d, %d] PDCCH DCI PDU (Format for incoming PDSCH PDU)\n", + dl_tti_request->SFN, dl_tti_request->Slot); + uint16_t num_dcis = pdu_list->pdcch_pdu.pdcch_pdu_rel15.numDlDci; + if (num_dcis > 0) + { + if (!dl_info->dci_ind) + { + dl_info->dci_ind = CALLOC(1, sizeof(fapi_nr_dci_indication_t)); + } + dl_info->dci_ind->SFN = dl_tti_request->SFN; + dl_info->dci_ind->slot = dl_tti_request->Slot; + AssertFatal(num_dcis <= sizeof(dl_info->dci_ind->dci_list) / sizeof(dl_info->dci_ind->dci_list[0]), + "The number of DCIs is greater than dci_list"); + for (int j = 0; j < num_dcis; j++) + { + nfapi_nr_dl_dci_pdu_t *dci_pdu_list = &pdu_list->pdcch_pdu.pdcch_pdu_rel15.dci_pdu[j]; + if (!is_my_dci(mac, dci_pdu_list)) + { + continue; + } + fill_dl_info_with_pdcch(dl_info->dci_ind, dci_pdu_list, pdu_idx); + if (dci_pdu_list->RNTI == 0xffff) + { + mac->nr_ue_emul_l1.expected_sib = true; + mac->nr_ue_emul_l1.index_has_sib[j] = true; + LOG_D(NR_MAC, "Setting index_has_sib[%d] = true\n", j); + } + else if (dci_pdu_list->RNTI == mac->ra.ra_rnti) + { + mac->nr_ue_emul_l1.expected_rar = true; + mac->nr_ue_emul_l1.index_has_rar[j] = true; + LOG_D(NR_MAC, "Setting index_has_rar[%d] = true\n", j); + } + else + { + mac->nr_ue_emul_l1.expected_dci = true; + mac->nr_ue_emul_l1.index_has_dci[j] = true; + LOG_D(NR_MAC, "Setting index_has_dci[%d] = true\n", j); + } + pdu_idx++; + } + } + } + if (pdu_list->PDUType == NFAPI_NR_DL_TTI_SSB_PDU_TYPE) + { + /* If we get a MIB, we want to handle it right away and then come back. + The MIB and SIB come in the same dl_tti_req but the MIB should be + processed first and then the DCI and payload of the SIB1 can be + processed. The MIB should be handled first and then the rx_ind + will be freed after handling. This is why the PDU index will + always be zero for the RX_IND becasue we should not have more than + one MIB. */ + if (!dl_info->rx_ind) + { + dl_info->rx_ind = CALLOC(1, sizeof(*dl_info->rx_ind)); + } + fapi_nr_rx_indication_t *rx_ind = dl_info->rx_ind; + rx_ind->sfn = dl_tti_request->SFN; + rx_ind->slot = dl_tti_request->Slot; + fill_mib_in_rx_ind(pdu_list, rx_ind, 0, FAPI_NR_RX_PDU_TYPE_SSB); + NR_UL_TIME_ALIGNMENT_t ul_time_alignment; + memset(&ul_time_alignment, 0, sizeof(ul_time_alignment)); + nr_ue_dl_indication(&mac->dl_info, &ul_time_alignment); + } + } + dl_info->slot = dl_tti_request->Slot; + dl_info->frame = dl_tti_request->SFN; +} + +static void fill_rx_ind(nfapi_nr_pdu_t *pdu_list, fapi_nr_rx_indication_t *rx_ind, int pdu_idx, int pdu_type) +{ + AssertFatal(pdu_list->num_TLV < sizeof(pdu_list->TLVs) / sizeof(pdu_list->TLVs[0]), "Num TLVs exceeds TLV array size"); + int length = 0; + for (int j = 0; j < pdu_list->num_TLV; j++) + { + length += pdu_list->TLVs[j].length; + } + LOG_I(NR_PHY, "%s: num_tlv %d and length %d, pdu index %d\n", + __FUNCTION__, pdu_list->num_TLV, length, pdu_idx); + uint8_t *pdu = malloc(length); + AssertFatal(pdu != NULL, "%s: Out of memory in malloc", __FUNCTION__); + rx_ind->rx_indication_body[pdu_idx].pdsch_pdu.pdu = pdu; + for (int j = 0; j < pdu_list->num_TLV; j++) + { + const uint32_t *ptr; + if (pdu_list->TLVs[j].tag) + ptr = pdu_list->TLVs[j].value.ptr; + else + ptr = pdu_list->TLVs[j].value.direct; + memcpy(pdu, ptr, pdu_list->TLVs[j].length); + pdu += pdu_list->TLVs[j].length; + } + rx_ind->rx_indication_body[pdu_idx].pdsch_pdu.ack_nack = 1; + rx_ind->rx_indication_body[pdu_idx].pdsch_pdu.pdu_length = length; + rx_ind->rx_indication_body[pdu_idx].pdu_type = pdu_type; + +} + + +static void copy_tx_data_req_to_dl_info(nr_downlink_indication_t *dl_info, nfapi_nr_tx_data_request_t *tx_data_request) +{ + NR_UE_MAC_INST_t *mac = get_mac_inst(dl_info->module_id); + int num_pdus = tx_data_request->Number_of_PDUs; + AssertFatal(num_pdus >= 0, "Invalid tx_data_request number of PDUS\n"); + + if (!dl_info->rx_ind) + { + dl_info->rx_ind = CALLOC(1, sizeof(fapi_nr_rx_indication_t)); + } + AssertFatal(dl_info->rx_ind != NULL, "%s: Out of memory in calloc", __FUNCTION__); + fapi_nr_rx_indication_t *rx_ind = dl_info->rx_ind; + rx_ind->sfn = tx_data_request->SFN; + rx_ind->slot = tx_data_request->Slot; + + int pdu_idx = 0; + + for (int i = 0; i < num_pdus; i++) + { + nfapi_nr_pdu_t *pdu_list = &tx_data_request->pdu_list[i]; + if (mac->nr_ue_emul_l1.index_has_sib[i]) + { + AssertFatal(!get_softmodem_params()->nsa, + "Should not be processing SIB in NSA mode, something bad happened\n"); + fill_rx_ind(pdu_list, rx_ind, pdu_idx, FAPI_NR_RX_PDU_TYPE_SIB); + pdu_idx++; + } + else if (mac->nr_ue_emul_l1.index_has_rar[i]) + { + fill_rx_ind(pdu_list, rx_ind, pdu_idx, FAPI_NR_RX_PDU_TYPE_RAR); + pdu_idx++; + } + else if (mac->nr_ue_emul_l1.index_has_dci[i]) + { + fill_rx_ind(pdu_list, rx_ind, pdu_idx, FAPI_NR_RX_PDU_TYPE_DLSCH); + pdu_idx++; + } + else + { + LOG_D(NR_MAC, "mac->nr_ue_emul_l1.index_has_dci[%d] = 0, so this index contained a DCI for a different UE\n", i); + } + + } + dl_info->slot = tx_data_request->Slot; + dl_info->frame = tx_data_request->SFN; + dl_info->rx_ind->number_pdus = pdu_idx; +} + +static void copy_ul_dci_data_req_to_dl_info(nr_downlink_indication_t *dl_info, nfapi_nr_ul_dci_request_t *ul_dci_req) +{ + NR_UE_MAC_INST_t *mac = get_mac_inst(dl_info->module_id); + int pdu_idx = 0; + + int num_pdus = ul_dci_req->numPdus; + AssertFatal(num_pdus >= 0, "Invalid ul_dci_request number of PDUS\n"); + + for (int i = 0; i < num_pdus; i++) + { + nfapi_nr_ul_dci_request_pdus_t *pdu_list = &ul_dci_req->ul_dci_pdu_list[i]; + AssertFatal(pdu_list->PDUType == 0, "ul_dci_req pdu type != PUCCH"); + LOG_I(NR_PHY, "[%d %d] PUCCH PDU in ul_dci for rnti %x and numDLDCI = %d\n", + ul_dci_req->SFN, ul_dci_req->Slot, pdu_list->pdcch_pdu.pdcch_pdu_rel15.dci_pdu->RNTI, + pdu_list->pdcch_pdu.pdcch_pdu_rel15.numDlDci); + uint16_t num_dci = pdu_list->pdcch_pdu.pdcch_pdu_rel15.numDlDci; + if (num_dci > 0) + { + if (!dl_info->dci_ind) + { + dl_info->dci_ind = CALLOC(1, sizeof(fapi_nr_dci_indication_t)); + } + AssertFatal(dl_info->dci_ind != NULL, "%s: Out of memory in calloc", __FUNCTION__); + dl_info->dci_ind->SFN = ul_dci_req->SFN; + dl_info->dci_ind->slot = ul_dci_req->Slot; + AssertFatal(num_dci < sizeof(dl_info->dci_ind->dci_list) / sizeof(dl_info->dci_ind->dci_list[0]), "The number of DCIs is greater than dci_list"); + for (int j = 0; j < num_dci; j++) + { + nfapi_nr_dl_dci_pdu_t *dci_pdu_list = &pdu_list->pdcch_pdu.pdcch_pdu_rel15.dci_pdu[j]; + if (dci_pdu_list->RNTI != mac->crnti) + { + LOG_D(NR_MAC, "dci_pdu_list->RNTI (%x) != mac->crnti (%x)\n", dci_pdu_list->RNTI, mac->crnti); + continue; + } + fill_dl_info_with_pdcch(dl_info->dci_ind, dci_pdu_list, pdu_idx); + pdu_idx++; + } + } + } + dl_info->frame = ul_dci_req->SFN; + dl_info->slot = ul_dci_req->Slot; +} + +static nfapi_nr_uci_indication_t *multiplex_uci_ind(NR_UE_MAC_INST_t *mac, int num_active_harqs) +{ + AssertFatal(num_active_harqs >= 0, "Invalid value for num_active_harqs %d\n", num_active_harqs); + if (num_active_harqs == 0) + { + return NULL; + } + if (num_active_harqs != nr_uci_ind_queue.num_items) + { + LOG_I(NR_MAC, "The number of active harqs %d doesn't match the number of UCIs in the queue %lu\n", + num_active_harqs, nr_uci_ind_queue.num_items); + return NULL; + } + + nfapi_nr_uci_indication_t *uci_ind = MALLOC(sizeof(*uci_ind)); + uci_ind->header.message_id = NFAPI_NR_PHY_MSG_TYPE_UCI_INDICATION; + uci_ind->sfn = NFAPI_SFNSLOT2SFN(mac->nr_ue_emul_l1.active_harq_sfn_slot); + uci_ind->slot = NFAPI_SFNSLOT2SLOT(mac->nr_ue_emul_l1.active_harq_sfn_slot); + uci_ind->num_ucis = num_active_harqs; + uci_ind->uci_list = CALLOC(uci_ind->num_ucis, sizeof(*uci_ind->uci_list)); + for (int i = 0; i < num_active_harqs; i++) + { + nfapi_nr_uci_indication_t *queued_uci_ind = get_queue(&nr_uci_ind_queue); + AssertFatal(queued_uci_ind, "There was not a UCI in the queue!\n"); + nfapi_nr_uci_pucch_pdu_format_0_1_t *pdu_0_1 = &uci_ind->uci_list[i].pucch_pdu_format_0_1; + + /* In openair1/SCHED_NR_UE/fapi_nr_ue_l1.c nr_ue_schedule_response_stub(), the + number of UCIs is hard coded to 1. This is why we always use index 0 of the + queued UCI indication to fill the new multiplexed UCI indication */ + AssertFatal(queued_uci_ind->num_ucis == 1, "The number of UCIs from de-queueud UCI is not 1, its %d\n", + queued_uci_ind->num_ucis); + uci_ind->uci_list[i].pdu_type = queued_uci_ind->uci_list[0].pdu_type; + uci_ind->uci_list[i].pdu_size = queued_uci_ind->uci_list[0].pdu_size; + + nfapi_nr_uci_pucch_pdu_format_0_1_t *queued_pdu_0_1 = &queued_uci_ind->uci_list[0].pucch_pdu_format_0_1; + pdu_0_1->handle = queued_pdu_0_1->handle; + pdu_0_1->rnti = queued_pdu_0_1->rnti; + pdu_0_1->pucch_format = queued_pdu_0_1->pucch_format; + pdu_0_1->ul_cqi = queued_pdu_0_1->ul_cqi; + pdu_0_1->timing_advance = queued_pdu_0_1->timing_advance; + pdu_0_1->rssi = queued_pdu_0_1->rssi; + free(queued_uci_ind->uci_list); + queued_uci_ind->uci_list = NULL; + free(queued_uci_ind); + queued_uci_ind = NULL; + } + return uci_ind; +} + +static void copy_ul_tti_data_req_to_dl_info(nr_downlink_indication_t *dl_info, nfapi_nr_ul_tti_request_t *ul_tti_req) +{ + NR_UE_MAC_INST_t *mac = get_mac_inst(dl_info->module_id); + int num_pdus = ul_tti_req->n_pdus; + AssertFatal(num_pdus >= 0, "Invalid ul_tti_request number of PDUS\n"); + AssertFatal(num_pdus <= sizeof(ul_tti_req->pdus_list) / sizeof(ul_tti_req->pdus_list[0]), + "Too many pdus %d in ul_tti_req\n", num_pdus); + + bool sent_uci = false; + for (int i = 0; i < num_pdus; i++) + { + nfapi_nr_ul_tti_request_number_of_pdus_t *pdu_list = &ul_tti_req->pdus_list[i]; + LOG_D(NR_PHY, "This is the pdu type %d and rnti %x and SR flag %d and harq_pdu_len %d in in ul_tti_req\n", + pdu_list->pdu_type, ul_tti_req->pdus_list[i].pucch_pdu.rnti, pdu_list->pucch_pdu.sr_flag, pdu_list->pucch_pdu.bit_len_harq); + if (pdu_list->pdu_type == NFAPI_NR_UL_CONFIG_PUCCH_PDU_TYPE && pdu_list->pucch_pdu.rnti == mac->crnti) + { + AssertFatal(nr_uci_ind_queue.num_items >= 0, "Invalid num_items in UCI_ind queue %lu\n", + nr_uci_ind_queue.num_items); + int num_active_harqs = pdu_list->pucch_pdu.bit_len_harq; + LOG_I(NR_MAC, "The number of active harqs %d from ul_tti_req\n", num_active_harqs); + nfapi_nr_uci_indication_t *uci_ind = multiplex_uci_ind(mac, num_active_harqs); + + if (uci_ind && uci_ind->num_ucis > 0) + { + LOG_D(NR_MAC, "This is the SFN/SF [%d, %d] and RNTI %x of the UCI ind. ul_tti_req.pdu[%d]->rnti = %x \n", + uci_ind->sfn, uci_ind->slot, uci_ind->uci_list[0].pucch_pdu_format_0_1.rnti, i, ul_tti_req->pdus_list[i].pucch_pdu.rnti); + uci_ind->sfn = ul_tti_req->SFN; + uci_ind->slot = ul_tti_req->Slot; + for (int j = 0; j < uci_ind->num_ucis; j++) + { + nfapi_nr_uci_pucch_pdu_format_0_1_t *pdu_0_1 = &uci_ind->uci_list[j].pucch_pdu_format_0_1; + if (pdu_list->pucch_pdu.sr_flag) + { + LOG_D(NR_MAC, "We have the SR flag in pdu i %d\n", i); + pdu_0_1->pduBitmap = 1; // (value->pduBitmap >> 1) & 0x01) == HARQ and (value->pduBitmap) & 0x01) == SR + pdu_0_1->sr = CALLOC(1, sizeof(*pdu_0_1->sr)); + pdu_0_1->sr->sr_confidence_level = 0; + pdu_0_1->sr->sr_indication = 1; + } + if (pdu_list->pucch_pdu.bit_len_harq > 0) + { + LOG_D(NR_MAC, "We have the Harq len bits %d\n", pdu_list->pucch_pdu.bit_len_harq); + pdu_0_1->pduBitmap = 2; // (value->pduBitmap >> 1) & 0x01) == HARQ and (value->pduBitmap) & 0x01) == SR + pdu_0_1->harq = CALLOC(1, sizeof(*pdu_0_1->harq)); + pdu_0_1->harq->num_harq = 1; + pdu_0_1->harq->harq_confidence_level = 0; + pdu_0_1->harq->harq_list = CALLOC(pdu_0_1->harq->num_harq, sizeof(*pdu_0_1->harq->harq_list)); + for (int k = 0; k < pdu_0_1->harq->num_harq; k++) + { + pdu_0_1->harq->harq_list[k].harq_value = 0; + } + } + } + LOG_I(NR_MAC, "We have dequeued the previously filled uci_ind and updated the snf/slot to %d/%d.\n", + uci_ind->sfn, uci_ind->slot); + NR_UL_IND_t UL_INFO = { + .uci_ind = *uci_ind, + }; + send_nsa_standalone_msg(&UL_INFO, uci_ind->header.message_id); + sent_uci = true; + + for (int k = 0; k < uci_ind->num_ucis; k++) + { + nfapi_nr_uci_pucch_pdu_format_0_1_t *pdu_0_1 = &uci_ind->uci_list[k].pucch_pdu_format_0_1; + if (pdu_list->pucch_pdu.sr_flag) + { + free(pdu_0_1->sr); + pdu_0_1->sr = NULL; + } + if (pdu_list->pucch_pdu.bit_len_harq > 1) + { + free(pdu_0_1->harq->harq_list); + pdu_0_1->harq->harq_list = NULL; + free(pdu_0_1->harq); + pdu_0_1->harq = NULL; + } + } + free(uci_ind->uci_list); + uci_ind->uci_list = NULL; + free(uci_ind); + uci_ind = NULL; + } + } + } + if (!sent_uci) + { + LOG_E(NR_MAC, "UCI ind not sent\n"); + if (!put_queue(&nr_ul_tti_req_queue, ul_tti_req)) + { + LOG_E(NR_PHY, "put_queue failed for ul_tti_req.\n"); + free(ul_tti_req); + ul_tti_req = NULL; + } + } +} + +static void fill_dci_from_dl_config(nr_downlink_indication_t*dl_ind, fapi_nr_dl_config_request_t *dl_config) +{ + if (!dl_ind->dci_ind) + { + return; + } + + AssertFatal(dl_config->number_pdus < sizeof(dl_config->dl_config_list) / sizeof(dl_config->dl_config_list[0]), + "Too many dl_config pdus %d", dl_config->number_pdus); + for (int i = 0; i < dl_config->number_pdus; i++) + { + LOG_I(PHY, "In %s: filling DCI with a total of %d total DL PDUs (dl_config %p) \n", + __FUNCTION__, dl_config->number_pdus, dl_config); + fapi_nr_dl_config_dci_dl_pdu_rel15_t *rel15_dci = &dl_config->dl_config_list[i].dci_config_pdu.dci_config_rel15; + int num_dci_options = rel15_dci->num_dci_options; + if (num_dci_options <= 0) + { + LOG_I(NR_MAC, "num_dci_opts = %d for pdu[%d] in dl_config_list\n", rel15_dci->num_dci_options, i); + } + AssertFatal(num_dci_options <= sizeof(rel15_dci->dci_length_options) / sizeof(rel15_dci->dci_length_options[0]), + "num_dci_options %d > dci_length_options array\n", num_dci_options); + AssertFatal(num_dci_options <= sizeof(rel15_dci->dci_format_options) / sizeof(rel15_dci->dci_format_options[0]), + "num_dci_options %d > dci_format_options array\n", num_dci_options); + + for (int j = 0; j < num_dci_options; j++) + { + int num_dcis = dl_ind->dci_ind->number_of_dcis; + AssertFatal(num_dcis <= sizeof(dl_ind->dci_ind->dci_list) / sizeof(dl_ind->dci_ind->dci_list[0]), + "dl_config->number_pdus %d > dci_ind->dci_list array\n", num_dcis); + for (int k = 0; k < num_dcis; k++) + { + LOG_I(NR_PHY, "Received len %d, length options[%d] %d, format assigned %d, format options[%d] %d\n", + dl_ind->dci_ind->dci_list[k].payloadSize, j, rel15_dci->dci_length_options[j], + dl_ind->dci_ind->dci_list[k].dci_format, j, rel15_dci->dci_format_options[j]); + if (rel15_dci->dci_length_options[j] == dl_ind->dci_ind->dci_list[k].payloadSize) + { + dl_ind->dci_ind->dci_list[k].dci_format = rel15_dci->dci_format_options[j]; + } + int CCEind = rel15_dci->CCE[j]; + int L = rel15_dci->L[j]; + dl_ind->dci_ind->dci_list[k].n_CCE = CCEind; + dl_ind->dci_ind->dci_list[k].N_CCE = L; + } + } + } +} + +void check_and_process_dci(nfapi_nr_dl_tti_request_t *dl_tti_request, + nfapi_nr_tx_data_request_t *tx_data_request, + nfapi_nr_ul_dci_request_t *ul_dci_request, + nfapi_nr_ul_tti_request_t *ul_tti_request) +{ + frame_t frame = 0; + int slot = 0; + NR_UE_MAC_INST_t *mac = get_mac_inst(0); + + if (pthread_mutex_lock(&mac->mutex_dl_info)) abort(); + + if (dl_tti_request) + { + frame = dl_tti_request->SFN; + slot = dl_tti_request->Slot; + LOG_I(NR_PHY, "[%d, %d] dl_tti_request\n", frame, slot); + copy_dl_tti_req_to_dl_info(&mac->dl_info, dl_tti_request); + } + /* This checks if the previously recevied DCI matches our current RNTI + value. The assumption is that if the DCI matches our RNTI, then the + incoming tx_data_request is also destined for the current UE. If the + RAR hasn't been processed yet, we do not want to be filtering the + tx_data_requests. */ + if (tx_data_request && (mac->nr_ue_emul_l1.expected_sib || + mac->nr_ue_emul_l1.expected_rar || + mac->nr_ue_emul_l1.expected_dci)) + { + frame = tx_data_request->SFN; + slot = tx_data_request->Slot; + LOG_I(NR_PHY, "[%d, %d] PDSCH in tx_request\n", frame, slot); + copy_tx_data_req_to_dl_info(&mac->dl_info, tx_data_request); + } + else if (ul_dci_request) + { + frame = ul_dci_request->SFN; + slot = ul_dci_request->Slot; + LOG_I(NR_PHY, "[%d, %d] ul_dci_request\n", frame, slot); + copy_ul_dci_data_req_to_dl_info(&mac->dl_info, ul_dci_request); + } + else if (ul_tti_request) + { + frame = ul_tti_request->SFN; + slot = ul_tti_request->Slot; + LOG_I(NR_PHY, "[%d, %d] ul_tti_request\n", frame, slot); + copy_ul_tti_data_req_to_dl_info(&mac->dl_info, ul_tti_request); + } + else + { + if (pthread_mutex_unlock(&mac->mutex_dl_info)) abort(); + LOG_E(NR_MAC, "Error! All indications were NULL\n"); + return; + } + + + NR_UL_TIME_ALIGNMENT_t ul_time_alignment; + memset(&ul_time_alignment, 0, sizeof(ul_time_alignment)); + fill_dci_from_dl_config(&mac->dl_info, &mac->dl_config_request); + nr_ue_dl_indication(&mac->dl_info, &ul_time_alignment); + + if (pthread_mutex_unlock(&mac->mutex_dl_info)) abort(); + + // If we filled dl_info AFTER we got the slot indication, we want to check if we should fill tx_req: + nr_uplink_indication_t ul_info; + memset(&ul_info, 0, sizeof(ul_info)); + int slots_per_frame = 20; //30 kHZ subcarrier spacing + int slot_ahead = 2; // TODO: Make this dynamic + ul_info.frame_rx = frame; + ul_info.slot_rx = slot; + ul_info.slot_tx = (slot + slot_ahead) % slots_per_frame; + ul_info.frame_tx = (ul_info.slot_rx + slot_ahead >= slots_per_frame) ? ul_info.frame_rx + 1 : ul_info.frame_rx; + ul_info.ue_sched_mode = SCHED_ALL; + if (mac->scc || mac->scc_SIB) + { + if (is_nr_UL_slot(mac->scc ? + mac->scc->tdd_UL_DL_ConfigurationCommon : + mac->scc_SIB->tdd_UL_DL_ConfigurationCommon, + ul_info.slot_tx, + mac->frame_type)) + nr_ue_ul_indication(&ul_info); + } +} + +void save_nr_measurement_info(nfapi_nr_dl_tti_request_t *dl_tti_request) +{ + int num_pdus = dl_tti_request->dl_tti_request_body.nPDUs; + char buffer[MAX_MESSAGE_SIZE]; + if (num_pdus <= 0) + { + LOG_E(NR_PHY, "%s: dl_tti_request number of PDUS <= 0\n", __FUNCTION__); + abort(); + } + LOG_D(NR_PHY, "%s: dl_tti_request number of PDUS: %d\n", __FUNCTION__, num_pdus); + for (int i = 0; i < num_pdus; i++) + { + nfapi_nr_dl_tti_request_pdu_t *pdu_list = &dl_tti_request->dl_tti_request_body.dl_tti_pdu_list[i]; + if (pdu_list->PDUType == NFAPI_NR_DL_TTI_SSB_PDU_TYPE) + { + LOG_D(NR_PHY, "Cell_id: %d, the ssb_block_idx %d, sc_offset: %d and payload %d\n", + pdu_list->ssb_pdu.ssb_pdu_rel15.PhysCellId, + pdu_list->ssb_pdu.ssb_pdu_rel15.SsbBlockIndex, + pdu_list->ssb_pdu.ssb_pdu_rel15.SsbSubcarrierOffset, + pdu_list->ssb_pdu.ssb_pdu_rel15.bchPayload); + pdu_list->ssb_pdu.ssb_pdu_rel15.ssbRsrp = 60; + LOG_D(NR_RRC, "Setting pdulist[%d].ssbRsrp to %d\n", i, pdu_list->ssb_pdu.ssb_pdu_rel15.ssbRsrp); + } + } + + size_t pack_len = nfapi_nr_p7_message_pack((void *)dl_tti_request, + buffer, + sizeof(buffer), + NULL); + if (pack_len < 0) + { + LOG_E(NR_PHY, "%s: Error packing nr p7 message.\n", __FUNCTION__); + } + nsa_sendmsg_to_lte_ue(buffer, pack_len, NR_UE_RRC_MEASUREMENT); + LOG_A(NR_RRC, "Populated NR_UE_RRC_MEASUREMENT information and sent to LTE UE\n"); +} + +static void enqueue_nr_nfapi_msg(void *buffer, ssize_t len, nfapi_p7_message_header_t header) +{ + + switch (header.message_id) + { + case NFAPI_NR_PHY_MSG_TYPE_DL_TTI_REQUEST: + { + nfapi_nr_dl_tti_request_t *dl_tti_request = MALLOC(sizeof(*dl_tti_request)); + if (nfapi_nr_p7_message_unpack(buffer, len, dl_tti_request, + sizeof(*dl_tti_request), NULL) < 0) + { + LOG_E(NR_PHY, "Message dl_tti_request failed to unpack\n"); + break; + } + LOG_I(NR_PHY, "Received an NFAPI_NR_PHY_MSG_TYPE_DL_TTI_REQUEST message in sfn/slot %d %d. \n", + dl_tti_request->SFN, dl_tti_request->Slot); + if (!put_queue(&nr_dl_tti_req_queue, dl_tti_request)) + { + LOG_E(NR_PHY, "put_queue failed for dl_tti_request.\n"); + free(dl_tti_request); + dl_tti_request = NULL; + } + break; + } + + case NFAPI_NR_PHY_MSG_TYPE_TX_DATA_REQUEST: + { + nfapi_nr_tx_data_request_t *tx_data_request = MALLOC(sizeof(*tx_data_request)); + if (nfapi_nr_p7_message_unpack(buffer, len, tx_data_request, + sizeof(*tx_data_request), NULL) < 0) + { + LOG_E(NR_PHY, "Message tx_data_request failed to unpack\n"); + break; + } + LOG_I(NR_PHY, "Received an NFAPI_NR_PHY_MSG_TYPE_TX_DATA_REQUEST message in SFN/slot %d %d. \n", + tx_data_request->SFN, tx_data_request->Slot); + if (!put_queue(&nr_tx_req_queue, tx_data_request)) + { + LOG_E(NR_PHY, "put_queue failed for tx_request.\n"); + free(tx_data_request); + tx_data_request = NULL; + } + break; + } + + case NFAPI_NR_PHY_MSG_TYPE_UL_DCI_REQUEST: + { + nfapi_nr_ul_dci_request_t *ul_dci_request = MALLOC(sizeof(*ul_dci_request)); + if (nfapi_nr_p7_message_unpack(buffer, len, ul_dci_request, + sizeof(*ul_dci_request), NULL) < 0) + { + LOG_E(NR_PHY, "Message ul_dci_request failed to unpack\n"); + break; + } + LOG_I(NR_PHY, "Received an NFAPI_NR_PHY_MSG_TYPE_UL_DCI_REQUEST message in SFN/slot %d %d. \n", + ul_dci_request->SFN, ul_dci_request->Slot); + if (!put_queue(&nr_ul_dci_req_queue, ul_dci_request)) + { + LOG_E(NR_PHY, "put_queue failed for ul_dci_request.\n"); + free(ul_dci_request); + ul_dci_request = NULL; + } + break; + } + + case NFAPI_NR_PHY_MSG_TYPE_UL_TTI_REQUEST: + { + nfapi_nr_ul_tti_request_t *ul_tti_request = MALLOC(sizeof(*ul_tti_request)); + if (nfapi_nr_p7_message_unpack(buffer, len, ul_tti_request, + sizeof(*ul_tti_request), NULL) < 0) + { + LOG_E(NR_PHY, "Message ul_tti_request failed to unpack\n"); + break; + } + LOG_I(NR_PHY, "Received an NFAPI_NR_PHY_MSG_TYPE_UL_TTI_REQUEST message in SFN/slot %d %d.\n", + ul_tti_request->SFN, ul_tti_request->Slot); + if (nr_uci_ind_queue.num_items > 0) //TODO: In the future UL_TTIs can be for ULSCH and SRS. + { + LOG_D(NR_MAC, "We added UL_TTI_REQ to queue for sfn slot %d %d\n", + ul_tti_request->SFN, ul_tti_request->Slot); + if (!put_queue(&nr_ul_tti_req_queue, ul_tti_request)) + { + LOG_E(NR_PHY, "put_queue failed for ul_tti_request.\n"); + free(ul_tti_request); + ul_tti_request = NULL; + } + } + /* TODO: This indicates that dl_tti_req was late or never arrived. If there are + not any prepared uci indications, the NRUE likely never had time to + populate the message is the dl_tti_req came in late and we received a + ul_tti_req immediately after the dl_tti_request. This is an attempt to + mitigate proxy timing issues. */ + else if (nr_uci_ind_queue.num_items == 0) + { + LOG_D(NR_MAC, "We added UL_TTI_REQ to queue for sfn slot %d %d\n", + ul_tti_request->SFN, ul_tti_request->Slot); + nfapi_nr_ul_tti_request_t *evicted_ul_tti_req = put_queue_replace(&nr_wait_ul_tti_req_queue, ul_tti_request); + free(evicted_ul_tti_req); + } + break; + } + + default: + LOG_E(NR_PHY, "Invalid nFAPI message. Header ID %d\n", + header.message_id); + break; + } + return; +} + +void *nrue_standalone_pnf_task(void *context) +{ + struct sockaddr_in server_address; + socklen_t addr_len = sizeof(server_address); + int sd = ue_rx_sock_descriptor; + assert(sd > 0); + + char buffer[NFAPI_MAX_PACKED_MESSAGE_SIZE]; + + LOG_I(NR_RRC, "Successfully started %s.\n", __FUNCTION__); + + while (true) + { + ssize_t len = recvfrom(sd, buffer, sizeof(buffer), MSG_TRUNC, (struct sockaddr *)&server_address, &addr_len); + if (len == -1) + { + LOG_E(NR_PHY, "reading from standalone pnf sctp socket failed \n"); + continue; + } + if (len > sizeof(buffer)) + { + LOG_E(NR_PHY, "%s(%d). Message truncated. %zd\n", __FUNCTION__, __LINE__, len); + continue; + } + if (len == sizeof(uint16_t)) + { + uint16_t *sfn_slot = CALLOC(1, sizeof(*sfn_slot)); + memcpy(sfn_slot, buffer, sizeof(*sfn_slot)); + + LOG_I(NR_PHY, "Received from proxy sfn %d slot %d\n", + NFAPI_SFNSLOT2SFN(*sfn_slot), NFAPI_SFNSLOT2SLOT(*sfn_slot)); + + if (!put_queue(&nr_sfn_slot_queue, sfn_slot)) + { + LOG_E(NR_PHY, "put_queue failed for sfn slot.\n"); + } + + if (sem_post(&sfn_slot_semaphore) != 0) + { + LOG_E(NR_PHY, "sem_post() error\n"); + abort(); + } + } + else if (len == sizeof(nr_phy_channel_params_t)) + { + nr_phy_channel_params_t *ch_info = CALLOC(1, sizeof(*ch_info)); + memcpy(ch_info, buffer, sizeof(*ch_info)); + + LOG_D(NR_PHY, "Received_SINR = %f, sfn:slot %d:%d\n", + ch_info->sinr, NFAPI_SFNSLOT2SFN(ch_info->sfn_slot), NFAPI_SFNSLOT2SLOT(ch_info->sfn_slot)); + + if (!put_queue(&nr_chan_param_queue, ch_info)) + { + LOG_E(NR_PHY, "put_queue failed for sfn slot.\n"); + } + + if (sem_post(&sfn_slot_semaphore) != 0) + { + LOG_E(MAC, "sem_post() error\n"); + abort(); + } + } + else + { + nfapi_p7_message_header_t header; + if (nfapi_p7_message_header_unpack(buffer, len, &header, sizeof(header), NULL) < 0) + { + LOG_E(NR_PHY, "Header unpack failed for nrue_standalone pnf\n"); + continue; + } + enqueue_nr_nfapi_msg(buffer, len, header); + } + } //while(true) +} // L2 Abstraction Layer int handle_bcch_bch(module_id_t module_id, int cc_id, @@ -81,13 +1034,34 @@ int handle_dci(module_id_t module_id, int cc_id, unsigned int gNB_index, frame_t // Note: sdu should always be processed because data and timing advance updates are transmitted by the UE int8_t handle_dlsch(nr_downlink_indication_t *dl_info, NR_UL_TIME_ALIGNMENT_t *ul_time_alignment, int pdu_id){ - update_harq_status(dl_info, pdu_id); + dl_info->rx_ind->rx_indication_body[pdu_id].pdsch_pdu.harq_pid = g_harq_pid; + + update_harq_status(dl_info->module_id, + dl_info->rx_ind->rx_indication_body[pdu_id].pdsch_pdu.harq_pid, + dl_info->rx_ind->rx_indication_body[pdu_id].pdsch_pdu.ack_nack); if(dl_info->rx_ind->rx_indication_body[pdu_id].pdsch_pdu.ack_nack) nr_ue_send_sdu(dl_info, ul_time_alignment, pdu_id); return 0; } +void update_harq_status(module_id_t module_id, uint8_t harq_pid, uint8_t ack_nack) { + + NR_UE_MAC_INST_t *mac = get_mac_inst(module_id); + NR_UE_HARQ_STATUS_t *current_harq = &mac->dl_harq_info[harq_pid]; + + if (current_harq->active) { + current_harq->ack = ack_nack; + current_harq->ack_received = true; + LOG_D(PHY,"Updating harq_status for harq_id %d,ack/nak %d\n",harq_pid,current_harq->ack); + } + else { + //shouldn't get here + LOG_E(MAC, "Trying to process acknack for an inactive harq process (%d)\n", harq_pid); + } +} + + int nr_ue_ul_indication(nr_uplink_indication_t *ul_info){ NR_UE_L2_STATE_t ret; @@ -98,8 +1072,12 @@ int nr_ue_ul_indication(nr_uplink_indication_t *ul_info){ ret = nr_ue_scheduler(NULL, ul_info); return 0; } - else if (ul_info->ue_sched_mode == SCHED_ALL) + if (ul_info->ue_sched_mode == SCHED_ALL) { ret = nr_ue_scheduler(NULL, ul_info); + } + else + LOG_D(NR_MAC, "In %s():%d not calling scheduler. sched mode = %d and mac->ra.ra_state = %d\n", + __FUNCTION__, __LINE__, ul_info->ue_sched_mode, mac->ra.ra_state); NR_TDD_UL_DL_ConfigCommon_t *tdd_UL_DL_ConfigurationCommon = mac->scc != NULL ? mac->scc->tdd_UL_DL_ConfigurationCommon : mac->scc_SIB->tdd_UL_DL_ConfigurationCommon; @@ -127,20 +1105,19 @@ int nr_ue_ul_indication(nr_uplink_indication_t *ul_info){ int nr_ue_dl_indication(nr_downlink_indication_t *dl_info, NR_UL_TIME_ALIGNMENT_t *ul_time_alignment){ - int32_t i; uint32_t ret_mask = 0x0; module_id_t module_id = dl_info->module_id; NR_UE_MAC_INST_t *mac = get_mac_inst(module_id); fapi_nr_dl_config_request_t *dl_config = &mac->dl_config_request; - - if (!dl_info->dci_ind && !dl_info->rx_ind) { + + if ((!dl_info->dci_ind && !dl_info->rx_ind)) { // UL indication to schedule DCI reception nr_ue_scheduler(dl_info, NULL); } else { // UL indication after reception of DCI or DL PDU - if(dl_info->dci_ind != NULL){ + if (dl_info && dl_info->dci_ind && dl_info->dci_ind->number_of_dcis) { LOG_D(MAC,"[L2][IF MODULE][DL INDICATION][DCI_IND]\n"); - for(i=0; i<dl_info->dci_ind->number_of_dcis; ++i){ + for (int i = 0; i < dl_info->dci_ind->number_of_dcis; i++) { LOG_D(MAC,">>>NR_IF_Module i=%d, dl_info->dci_ind->number_of_dcis=%d\n",i,dl_info->dci_ind->number_of_dcis); nr_scheduled_response_t scheduled_response; int8_t ret = handle_dci(dl_info->module_id, @@ -150,6 +1127,17 @@ int nr_ue_dl_indication(nr_downlink_indication_t *dl_info, NR_UL_TIME_ALIGNMENT_ dl_info->slot, dl_info->dci_ind->dci_list+i); + fapi_nr_dci_indication_pdu_t *dci_index = dl_info->dci_ind->dci_list+i; + + /* The check below filters out UL_DCIs (format 7) which are being processed as DL_DCIs. */ + if (dci_index->dci_format == 7 && mac->ra.ra_state == RA_SUCCEEDED) { + LOG_D(NR_MAC, "We are filtering a UL_DCI to prevent it from being treated like a DL_DCI\n"); + break; + } + dci_pdu_rel15_t *def_dci_pdu_rel15 = &mac->def_dci_pdu_rel15[dci_index->dci_format]; + g_harq_pid = def_dci_pdu_rel15->harq_pid; + LOG_D(NR_MAC, "Setting harq_pid = %d and dci_index = %d (based on format)\n", g_harq_pid, dci_index->dci_format); + ret_mask |= (ret << FAPI_NR_DCI_IND); if (ret >= 0) { AssertFatal( nr_ue_if_module_inst[module_id] != NULL, "IF module is NULL!\n" ); @@ -157,16 +1145,19 @@ int nr_ue_dl_indication(nr_downlink_indication_t *dl_info, NR_UL_TIME_ALIGNMENT_ fill_scheduled_response(&scheduled_response, dl_config, NULL, NULL, dl_info->module_id, dl_info->cc_id, dl_info->frame, dl_info->slot, dl_info->thread_id); nr_ue_if_module_inst[module_id]->scheduled_response(&scheduled_response); } + memset(def_dci_pdu_rel15, 0, sizeof(*def_dci_pdu_rel15)); } + free(dl_info->dci_ind); + dl_info->dci_ind = NULL; } - if(dl_info->rx_ind != NULL){ + if (dl_info->rx_ind != NULL) { - for(i=0; i<dl_info->rx_ind->number_pdus; ++i){ + for (int i=0; i<dl_info->rx_ind->number_pdus; ++i) { - LOG_D(MAC, "In %s sending DL indication to MAC. 1 PDU type %s of %d total number of PDUs \n", + LOG_D(MAC, "In %s sending DL indication to MAC. 1 PDU type %d of %d total number of PDUs \n", __FUNCTION__, - dl_indication_type[dl_info->rx_ind->rx_indication_body[i].pdu_type - 1], + dl_info->rx_ind->rx_indication_body[i].pdu_type, dl_info->rx_ind->number_pdus); switch(dl_info->rx_ind->rx_indication_body[i].pdu_type){ @@ -198,11 +1189,15 @@ int nr_ue_dl_indication(nr_downlink_indication_t *dl_info, NR_UL_TIME_ALIGNMENT_ break; } } + free(dl_info->rx_ind); + dl_info->rx_ind = NULL; } //clean up nr_downlink_indication_t *dl_info - dl_info->rx_ind = NULL; + free(dl_info->dci_ind); dl_info->dci_ind = NULL; + free(dl_info->rx_ind); + dl_info->rx_ind = NULL; } return 0; @@ -218,7 +1213,10 @@ nr_ue_if_module_t *nr_ue_if_module_init(uint32_t module_id){ nr_ue_if_module_inst[module_id]->current_frame = 0; nr_ue_if_module_inst[module_id]->current_slot = 0; nr_ue_if_module_inst[module_id]->phy_config_request = nr_ue_phy_config_request; - nr_ue_if_module_inst[module_id]->scheduled_response = nr_ue_scheduled_response; + if (get_softmodem_params()->emulate_l1) + nr_ue_if_module_inst[module_id]->scheduled_response = nr_ue_scheduled_response_stub; + else + nr_ue_if_module_inst[module_id]->scheduled_response = nr_ue_scheduled_response; nr_ue_if_module_inst[module_id]->dl_indication = nr_ue_dl_indication; nr_ue_if_module_inst[module_id]->ul_indication = nr_ue_ul_indication; } @@ -247,3 +1245,32 @@ int nr_ue_dcireq(nr_dcireq_t *dcireq) { return 0; } + +void RCconfig_nr_ue_L1(void) { + int j; + paramdef_t L1_Params[] = L1PARAMS_DESC; + paramlist_def_t L1_ParamList = {CONFIG_STRING_L1_LIST, NULL, 0}; + + config_getlist(&L1_ParamList, L1_Params, sizeof(L1_Params) / sizeof(paramdef_t), NULL); + if (L1_ParamList.numelt > 0) { + for (j = 0; j < L1_ParamList.numelt; j++) { + if (strcmp(*(L1_ParamList.paramarray[j][L1_TRANSPORT_N_PREFERENCE_IDX].strptr), "nfapi") == 0) { + stub_eth_params.local_if_name = strdup( + *(L1_ParamList.paramarray[j][L1_LOCAL_N_IF_NAME_IDX].strptr)); + stub_eth_params.my_addr = strdup( + *(L1_ParamList.paramarray[j][L1_LOCAL_N_ADDRESS_IDX].strptr)); + stub_eth_params.remote_addr = strdup( + *(L1_ParamList.paramarray[j][L1_REMOTE_N_ADDRESS_IDX].strptr)); + stub_eth_params.my_portc = + *(L1_ParamList.paramarray[j][L1_LOCAL_N_PORTC_IDX].iptr); + stub_eth_params.remote_portc = + *(L1_ParamList.paramarray[j][L1_REMOTE_N_PORTC_IDX].iptr); + stub_eth_params.my_portd = + *(L1_ParamList.paramarray[j][L1_LOCAL_N_PORTD_IDX].iptr); + stub_eth_params.remote_portd = + *(L1_ParamList.paramarray[j][L1_REMOTE_N_PORTD_IDX].iptr); + stub_eth_params.transp_preference = ETH_UDP_MODE; + } + } + } +} diff --git a/openair2/NR_UE_PHY_INTERFACE/NR_IF_Module.h b/openair2/NR_UE_PHY_INTERFACE/NR_IF_Module.h index 1ba8238f1ec7d04c262bb1cc2df78e4889ebc246..2a8a5147694b8d86dd6d0c488f2cf717cb8ef9f3 100755 --- a/openair2/NR_UE_PHY_INTERFACE/NR_IF_Module.h +++ b/openair2/NR_UE_PHY_INTERFACE/NR_IF_Module.h @@ -35,10 +35,21 @@ #include "platform_types.h" #include <openair1/PHY/thread_NR_UE.h> +#include <semaphore.h> #include "fapi_nr_ue_interface.h" +#include "openair2/PHY_INTERFACE/queue_t.h" +#include "nfapi_nr_interface_scf.h" +#include "openair2/NR_PHY_INTERFACE/NR_IF_Module.h" typedef struct NR_UL_TIME_ALIGNMENT NR_UL_TIME_ALIGNMENT_t; +typedef struct nr_phy_channel_params_t +{ + uint16_t sfn_slot; + float sinr; + // Incomplete, need all channel parameters +} nr_phy_channel_params_t; + typedef enum { ONLY_PUSCH, NOT_PUSCH, @@ -209,6 +220,25 @@ typedef struct nr_ue_if_module_s { \param module_id module id*/ nr_ue_if_module_t *nr_ue_if_module_init(uint32_t module_id); +void nrue_init_standalone_socket(int tx_port, int rx_port); + +void *nrue_standalone_pnf_task(void *context); +extern sem_t sfn_slot_semaphore; + +typedef struct nfapi_dl_tti_config_req_tx_data_req_t +{ + nfapi_nr_dl_tti_request_pdu_t *dl_itti_config_req; + nfapi_nr_tx_data_request_t *tx_data_req_pdu_list; +} nfapi_dl_tti_config_req_tx_data_req_t; + +void send_nsa_standalone_msg(NR_UL_IND_t *UL_INFO, uint16_t msg_id); + +void save_nr_measurement_info(nfapi_nr_dl_tti_request_t *dl_tti_request); + +void check_and_process_dci(nfapi_nr_dl_tti_request_t *dl_tti_request, + nfapi_nr_tx_data_request_t *tx_data_request, + nfapi_nr_ul_dci_request_t *ul_dci_request, + nfapi_nr_ul_tti_request_t *ul_tti_request); /**\brief done free of memory allocation by module_id and release to pointer pool. \param module_id module id*/ diff --git a/openair2/PHY_INTERFACE/.gitignore b/openair2/PHY_INTERFACE/.gitignore new file mode 100644 index 0000000000000000000000000000000000000000..2dca7a7611a5ca3548d6f4cd2d35b0c063402adb --- /dev/null +++ b/openair2/PHY_INTERFACE/.gitignore @@ -0,0 +1 @@ +/queue_test diff --git a/openair2/PHY_INTERFACE/IF_Module.c b/openair2/PHY_INTERFACE/IF_Module.c index ed3c9a5b7d2f7e84d59fc797e7730f0c1fa3c714..fba9e1d8b6382612736973a1b6a1f96b0b29838a 100644 --- a/openair2/PHY_INTERFACE/IF_Module.c +++ b/openair2/PHY_INTERFACE/IF_Module.c @@ -24,25 +24,31 @@ extern RAN_CONTEXT_t RC; uint16_t frame_cnt=0; void handle_rach(UL_IND_t *UL_info) { int i; - - if(NFAPI_MODE == NFAPI_MODE_VNF) { - for(uint8_t j = 0; j < NUM_NFPAI_SUBFRAME; j++) { - if (UL_RCC_INFO.rach_ind[j].rach_indication_body.number_of_preambles>0) { - AssertFatal(UL_RCC_INFO.rach_ind[j].rach_indication_body.number_of_preambles==1,"More than 1 preamble not supported\n"); - LOG_D(MAC,"UL_info[Frame %d, Subframe %d] Calling initiate_ra_proc RACH:SFN/SF:%d\n",UL_info->frame,UL_info->subframe, NFAPI_SFNSF2DEC(UL_RCC_INFO.rach_ind[j].sfn_sf)); - initiate_ra_proc(UL_info->module_id, - UL_info->CC_id, - NFAPI_SFNSF2SFN(UL_RCC_INFO.rach_ind[j].sfn_sf), - NFAPI_SFNSF2SF(UL_RCC_INFO.rach_ind[j].sfn_sf), - UL_RCC_INFO.rach_ind[j].rach_indication_body.preamble_list[0].preamble_rel8.preamble, - UL_RCC_INFO.rach_ind[j].rach_indication_body.preamble_list[0].preamble_rel8.timing_advance, - UL_RCC_INFO.rach_ind[j].rach_indication_body.preamble_list[0].preamble_rel8.rnti, - 0 - ); - free(UL_RCC_INFO.rach_ind[j].rach_indication_body.preamble_list); - UL_RCC_INFO.rach_ind[j].rach_indication_body.number_of_preambles = 0; - UL_RCC_INFO.rach_ind[j].header.message_id = 0; + int j = UL_info->subframe; + AssertFatal(j < sizeof(UL_RCC_INFO.rach_ind) / sizeof(UL_RCC_INFO.rach_ind[0]), "j index out of range of index of rach_ind\n"); + if (NFAPI_MODE == NFAPI_MODE_VNF) + { + if (UL_RCC_INFO.rach_ind[j].rach_indication_body.number_of_preambles > 0) + { + if (UL_RCC_INFO.rach_ind[j].rach_indication_body.number_of_preambles > 1) + { + LOG_D(MAC, "handle_rach j: %d UL_RCC_INFO.rach_ind[j].rach_indication_body.number_of_preambles: %d\n", + j, UL_RCC_INFO.rach_ind[j].rach_indication_body.number_of_preambles); + LOG_D(MAC, "UL_info[Frame %d, Subframe %d] Calling initiate_ra_proc RACH:Frame: %d Subframe: %d\n", + UL_info->frame, UL_info->subframe, NFAPI_SFNSF2SFN(UL_RCC_INFO.rach_ind[j].sfn_sf), NFAPI_SFNSF2SF(UL_RCC_INFO.rach_ind[j].sfn_sf)); } + AssertFatal(UL_RCC_INFO.rach_ind[j].rach_indication_body.number_of_preambles == 1, "More than 1 preamble not supported\n"); // dump frame/sf and all things in UL_RCC_INFO + initiate_ra_proc(UL_info->module_id, + UL_info->CC_id, + NFAPI_SFNSF2SFN(UL_RCC_INFO.rach_ind[j].sfn_sf), + NFAPI_SFNSF2SF(UL_RCC_INFO.rach_ind[j].sfn_sf), + UL_RCC_INFO.rach_ind[j].rach_indication_body.preamble_list[0].preamble_rel8.preamble, + UL_RCC_INFO.rach_ind[j].rach_indication_body.preamble_list[0].preamble_rel8.timing_advance, + UL_RCC_INFO.rach_ind[j].rach_indication_body.preamble_list[0].preamble_rel8.rnti, + 0); + free(UL_RCC_INFO.rach_ind[j].rach_indication_body.preamble_list); + UL_RCC_INFO.rach_ind[j].rach_indication_body.number_of_preambles = 0; + UL_RCC_INFO.rach_ind[j].header.message_id = 0; } } else { if (UL_info->rach_ind.rach_indication_body.number_of_preambles>0) { @@ -92,8 +98,9 @@ void handle_sr(UL_IND_t *UL_info) { oai_nfapi_sr_indication(&UL_info->sr_ind); } } else if(NFAPI_MODE == NFAPI_MODE_VNF) { - for(uint8_t j = 0; j < NUM_NFPAI_SUBFRAME; j++) { + for(uint8_t j = 0; j < NUM_NFAPI_SUBFRAME; j++) { if(UL_RCC_INFO.sr_ind[j].sr_indication_body.number_of_srs > 0) { + assert(UL_RCC_INFO.sr_ind[j].sr_indication_body.number_of_srs <= NFAPI_SR_IND_MAX_PDU); for (i=0; i<UL_RCC_INFO.sr_ind[j].sr_indication_body.number_of_srs; i++) { SR_indication(UL_info->module_id, UL_info->CC_id, @@ -109,6 +116,7 @@ void handle_sr(UL_IND_t *UL_info) { } } } else { + assert(UL_info->sr_ind.sr_indication_body.number_of_srs <= NFAPI_SR_IND_MAX_PDU); for (i=0; i<UL_info->sr_ind.sr_indication_body.number_of_srs; i++) SR_indication(UL_info->module_id, UL_info->CC_id, @@ -133,8 +141,9 @@ void handle_cqi(UL_IND_t *UL_info) { UL_info->cqi_ind.cqi_indication_body.number_of_cqis=0; } } else if (NFAPI_MODE == NFAPI_MODE_VNF) { - for(uint8_t j = 0; j < NUM_NFPAI_SUBFRAME; j++) { + for(uint8_t j = 0; j < NUM_NFAPI_SUBFRAME; j++) { if(UL_RCC_INFO.cqi_ind[j].cqi_indication_body.number_of_cqis > 0) { + assert(UL_RCC_INFO.cqi_ind[j].cqi_indication_body.number_of_cqis <= NFAPI_CQI_IND_MAX_PDU); for (i=0; i<UL_RCC_INFO.cqi_ind[j].cqi_indication_body.number_of_cqis; i++) { cqi_indication(UL_info->module_id, UL_info->CC_id, @@ -153,6 +162,7 @@ void handle_cqi(UL_IND_t *UL_info) { } } } else { + assert(UL_info->cqi_ind.cqi_indication_body.number_of_cqis <= NFAPI_CQI_IND_MAX_PDU); for (i=0; i<UL_info->cqi_ind.cqi_indication_body.number_of_cqis; i++) cqi_indication(UL_info->module_id, UL_info->CC_id, @@ -178,8 +188,9 @@ void handle_harq(UL_IND_t *UL_info) { UL_info->harq_ind.harq_indication_body.number_of_harqs = 0; } else if(NFAPI_MODE == NFAPI_MODE_VNF) { - for(uint8_t j = 0; j < NUM_NFPAI_SUBFRAME; j++) { + for(uint8_t j = 0; j < NUM_NFAPI_SUBFRAME; j++) { if(UL_RCC_INFO.harq_ind[j].harq_indication_body.number_of_harqs > 0) { + assert(UL_RCC_INFO.harq_ind[j].harq_indication_body.number_of_harqs <= NFAPI_HARQ_IND_MAX_PDU); for (int i=0; i<UL_RCC_INFO.harq_ind[j].harq_indication_body.number_of_harqs; i++) { harq_indication(UL_info->module_id, UL_info->CC_id, @@ -194,6 +205,7 @@ void handle_harq(UL_IND_t *UL_info) { } } } else { + assert(UL_info->harq_ind.harq_indication_body.number_of_harqs <= NFAPI_HARQ_IND_MAX_PDU); for (int i=0; i < UL_info->harq_ind.harq_indication_body.number_of_harqs; i++) harq_indication(UL_info->module_id, UL_info->CC_id, @@ -221,9 +233,11 @@ void handle_ulsch(UL_IND_t *UL_info) { UL_info->rx_ind.rx_indication_body.number_of_pdus = 0; } } else if(NFAPI_MODE == NFAPI_MODE_VNF) { - for(uint8_t k = 0; k < NUM_NFPAI_SUBFRAME; k++) { + for(uint8_t k = 0; k < NUM_NFAPI_SUBFRAME; k++) { if((UL_RCC_INFO.rx_ind[k].rx_indication_body.number_of_pdus>0) && (UL_RCC_INFO.crc_ind[k].crc_indication_body.number_of_crcs>0)) { + assert(UL_RCC_INFO.rx_ind[k].rx_indication_body.number_of_pdus <= NFAPI_RX_IND_MAX_PDU); for (i=0; i<UL_RCC_INFO.rx_ind[k].rx_indication_body.number_of_pdus; i++) { + assert(UL_RCC_INFO.crc_ind[k].crc_indication_body.number_of_crcs <= NFAPI_CRC_IND_MAX_PDU); for (j=0; j<UL_RCC_INFO.crc_ind[k].crc_indication_body.number_of_crcs; j++) { // find crc_indication j corresponding rx_indication i LOG_D(PHY,"UL_info->crc_ind.crc_indication_body.crc_pdu_list[%d].rx_ue_information.rnti:%04x UL_info->rx_ind.rx_indication_body.rx_pdu_list[%d].rx_ue_information.rnti:%04x\n", @@ -251,16 +265,12 @@ void handle_ulsch(UL_IND_t *UL_info) { NFAPI_SFNSF2SFN(UL_RCC_INFO.rx_ind[k].sfn_sf), //UL_info->frame, NFAPI_SFNSF2SF(UL_RCC_INFO.rx_ind[k].sfn_sf), //UL_info->subframe, UL_RCC_INFO.rx_ind[k].rx_indication_body.rx_pdu_list[i].rx_ue_information.rnti, - UL_RCC_INFO.rx_ind[k].rx_indication_body.rx_pdu_list[i].data, + UL_RCC_INFO.rx_ind[k].rx_indication_body.rx_pdu_list[i].rx_ind_data, UL_RCC_INFO.rx_ind[k].rx_indication_body.rx_pdu_list[i].rx_indication_rel8.length, UL_RCC_INFO.rx_ind[k].rx_indication_body.rx_pdu_list[i].rx_indication_rel8.timing_advance, UL_RCC_INFO.rx_ind[k].rx_indication_body.rx_pdu_list[i].rx_indication_rel8.ul_cqi); } - if(UL_RCC_INFO.rx_ind[k].rx_indication_body.rx_pdu_list[i].data != NULL) { - free(UL_RCC_INFO.rx_ind[k].rx_indication_body.rx_pdu_list[i].data); - } - break; } //if (UL_info->crc_ind.crc_pdu_list[j].rx_ue_information.rnti == UL_info->rx_ind.rx_pdu_list[i].rx_ue_information.rnti) } // for (j=0;j<UL_info->crc_ind.crc_indication_body.number_of_crcs;j++) @@ -276,7 +286,9 @@ void handle_ulsch(UL_IND_t *UL_info) { } } else { if (UL_info->rx_ind.rx_indication_body.number_of_pdus>0 && UL_info->crc_ind.crc_indication_body.number_of_crcs>0) { + assert(UL_info->rx_ind.rx_indication_body.number_of_pdus <= NFAPI_RX_IND_MAX_PDU); for (i=0; i<UL_info->rx_ind.rx_indication_body.number_of_pdus; i++) { + assert(UL_info->crc_ind.crc_indication_body.number_of_crcs <= NFAPI_CRC_IND_MAX_PDU); for (j=0; j<UL_info->crc_ind.crc_indication_body.number_of_crcs; j++) { // find crc_indication j corresponding rx_indication i LOG_D(PHY,"UL_info->crc_ind.crc_indication_body.crc_pdu_list[%d].rx_ue_information.rnti:%04x UL_info->rx_ind.rx_indication_body.rx_pdu_list[%d].rx_ue_information.rnti:%04x\n", j, @@ -304,7 +316,7 @@ void handle_ulsch(UL_IND_t *UL_info) { NFAPI_SFNSF2SFN(UL_info->rx_ind.sfn_sf), //UL_info->frame, NFAPI_SFNSF2SF(UL_info->rx_ind.sfn_sf), //UL_info->subframe, UL_info->rx_ind.rx_indication_body.rx_pdu_list[i].rx_ue_information.rnti, - UL_info->rx_ind.rx_indication_body.rx_pdu_list[i].data, + UL_info->rx_ind.rx_indication_body.rx_pdu_list[i].rx_ind_data, UL_info->rx_ind.rx_indication_body.rx_pdu_list[i].rx_indication_rel8.length, UL_info->rx_ind.rx_indication_body.rx_pdu_list[i].rx_indication_rel8.timing_advance, UL_info->rx_ind.rx_indication_body.rx_pdu_list[i].rx_indication_rel8.ul_cqi); @@ -790,6 +802,7 @@ IF_Module_t *IF_Module_init(int Mod_id) { "allocation of if_inst[%d]->if_mutex fails\n",Mod_id); } + memset(&UL_RCC_INFO, 0, sizeof(UL_RCC_INFO)); return if_inst[Mod_id]; } diff --git a/openair2/PHY_INTERFACE/IF_Module.h b/openair2/PHY_INTERFACE/IF_Module.h index 096979c4fd195595ac9e6076d3d06d686cfa5745..b1123dce5f7ff735880ffcfe479eab4cd1d9c016 100644 --- a/openair2/PHY_INTERFACE/IF_Module.h +++ b/openair2/PHY_INTERFACE/IF_Module.h @@ -87,25 +87,25 @@ typedef struct { } UL_IND_t; // Downlink subframe P7 -#define NUM_NFPAI_SUBFRAME 5 +#define NUM_NFAPI_SUBFRAME 10 typedef struct { /// harq indication list - nfapi_harq_indication_t harq_ind[NUM_NFPAI_SUBFRAME]; + nfapi_harq_indication_t harq_ind[NUM_NFAPI_SUBFRAME]; /// crc indication list - nfapi_crc_indication_t crc_ind[NUM_NFPAI_SUBFRAME]; + nfapi_crc_indication_t crc_ind[NUM_NFAPI_SUBFRAME]; /// SR indication list - nfapi_sr_indication_t sr_ind[NUM_NFPAI_SUBFRAME]; + nfapi_sr_indication_t sr_ind[NUM_NFAPI_SUBFRAME]; /// CQI indication list - nfapi_cqi_indication_t cqi_ind[NUM_NFPAI_SUBFRAME]; + nfapi_cqi_indication_t cqi_ind[NUM_NFAPI_SUBFRAME]; /// RACH indication list - nfapi_rach_indication_t rach_ind[NUM_NFPAI_SUBFRAME]; + nfapi_rach_indication_t rach_ind[NUM_NFAPI_SUBFRAME]; /// RX indication - nfapi_rx_indication_t rx_ind[NUM_NFPAI_SUBFRAME]; + nfapi_rx_indication_t rx_ind[NUM_NFAPI_SUBFRAME]; } UL_RCC_IND_t; @@ -151,6 +151,17 @@ typedef struct IF_Module_s{ pthread_mutex_t if_mutex; } IF_Module_t; +// These mutex is used for multiple UEs L2 FAPI simulator. +// Each UEs set these value in UL and UL_INFO is shared in all UE's thread. +typedef struct { + pthread_mutex_t rx_mutex; + pthread_mutex_t crc_mutex; + pthread_mutex_t sr_mutex; + pthread_mutex_t harq_mutex; + pthread_mutex_t cqi_mutex; + pthread_mutex_t rach_mutex; +} FILL_UL_INFO_MUTEX_t; + /*Initial */ IF_Module_t *IF_Module_init(int Mod_id); void IF_Module_kill(int Mod_id); diff --git a/openair2/PHY_INTERFACE/UE_MAC_interface.h b/openair2/PHY_INTERFACE/UE_MAC_interface.h index 42e790d1e96c188bf82e3a96ef2e14ef2b1499fa..207c3293b4f6718e086cab63dbabdb52da38e620 100644 --- a/openair2/PHY_INTERFACE/UE_MAC_interface.h +++ b/openair2/PHY_INTERFACE/UE_MAC_interface.h @@ -68,64 +68,6 @@ typedef enum { } UE_MAC_Tx_ind_type_e; - -// *** UE_UL_Config.request related structures - - -typedef struct{ - //module_id_t module_idP; - //int CC_id; - //frame_t frameP; - uint8_t eNB_id; - //uint16_t rnti; - //sub_frame_t subframe_tx; - uint32_t SR_payload; //0 or 1 -}UE_MAC_ul_config_SR; - - - -typedef struct{ - //module_id_t module_idP; - //int CC_id; - //frame_t frameP; - uint8_t eNB_indexP; - //sub_frame_t subframeP; - - uint8_t ra_RACH_MaskIndex; - int8_t ra_PREAMBLE_RECEIVED_TARGET_POWER; - uint8_t ra_TDD_map_index; - uint16_t ra_RNTI; - uint8_t *Msg3; -}UE_MAC_ul_config_rach; - -typedef struct { - union { - UE_MAC_ul_config_rach ue_rach_config; - //UE_MAC_ul_config_ULSCH ue_ULSCH_pdu; - UE_MAC_ul_config_SR ue_SR_config; - }; -} UE_MAC_ul_config_request_list; - -typedef struct { - nfapi_tl_t tl; - uint16_t length_list; - UE_MAC_ul_config_request_list* ue_ul_config_list; -} UE_MAC_ul_config_request_body_t; - -typedef struct { - //nfapi_p7_message_header_t header; - uint16_t sfn_sf; - UE_MAC_ul_config_request_body_t ue_ul_config_request_body; //nfapi_dl_config_request_body_t -} UE_MAC_ul_config_request_t; - - - - - - - - - // *** UE_Tx.request related structures typedef struct { diff --git a/openair2/PHY_INTERFACE/phy_stub_UE.c b/openair2/PHY_INTERFACE/phy_stub_UE.c index c212075934871c6b6a1994244eb0c490585f090a..1598e3d6203c91a80a838a538f55144544d7eaa4 100644 --- a/openair2/PHY_INTERFACE/phy_stub_UE.c +++ b/openair2/PHY_INTERFACE/phy_stub_UE.c @@ -30,10 +30,14 @@ #include "targets/ARCH/ETHERNET/USERSPACE/LIB/if_defs.h" #include "common/config/config_load_configmodule.h" #include "common/config/config_userapi.h" +#include <arpa/inet.h> +#include <string.h> +#include <errno.h> #include "openair2/NR_PHY_INTERFACE/NR_IF_Module.h" #include "openair1/PHY/defs_gNB.h" #include "nfapi/open-nFAPI/nfapi/public_inc/nfapi_nr_interface_scf.h" #include "openair1/PHY/LTE_TRANSPORT/transport_common.h" +#include "softmodem-common.h" extern int oai_nfapi_rach_ind(nfapi_rach_indication_t *rach_ind); void configure_nfapi_pnf(char *vnf_ip_addr, @@ -43,15 +47,33 @@ void configure_nfapi_pnf(char *vnf_ip_addr, int vnf_p7_port); UL_IND_t *UL_INFO = NULL; -nfapi_tx_request_pdu_t* tx_request_pdu_list = NULL; -nfapi_dl_config_request_t* dl_config_req = NULL; -nfapi_ul_config_request_t* ul_config_req = NULL; -nfapi_hi_dci0_request_t* hi_dci0_req = NULL; -extern nfapi_tx_request_pdu_t* tx_request_pdu[1023][10][10]; +queue_t dl_config_req_tx_req_queue; +queue_t ul_config_req_queue; +queue_t hi_dci0_req_queue; + +FILL_UL_INFO_MUTEX_t fill_ul_mutex; + +int current_sfn_sf; +sem_t sfn_semaphore; + +static sf_rnti_mcs_s sf_rnti_mcs[NUM_NFAPI_SUBFRAME]; + +static int ue_tx_sock_descriptor = -1; +static int ue_rx_sock_descriptor = -1; +static int get_mcs_from_sinr(float sinr); +static int get_cqi_from_mcs(void); +static void read_channel_param(const nfapi_dl_config_request_pdu_t * pdu, int sf, int index); +static bool did_drop_transport_block(int sf, uint16_t rnti); +static float get_bler_val(uint8_t mcs, int sinr); +static bool should_drop_transport_block(int sf, uint16_t rnti); +static void save_dci_pdu_for_crnti(nfapi_dl_config_request_t *dl_config_req); + +extern nfapi_tx_request_pdu_t* tx_request_pdu[1023][NUM_NFAPI_SUBFRAME][10]; //TODO: NFAPI_TX_MAX_PDU for last dim? Check nfapi_pnf.c ln. 81 //extern int timer_subframe; //extern int timer_frame; +extern UE_RRC_INST *UE_rrc_inst; extern uint16_t sf_ahead; static eth_params_t stub_eth_params; @@ -65,14 +87,19 @@ void fill_rx_indication_UE_MAC(module_id_t Mod_id, uint8_t *ulsch_buffer, uint16_t buflen, uint16_t rnti, - int index) { + int index, + nfapi_ul_config_request_t *ul_config_req) { nfapi_rx_indication_pdu_t *pdu; int timing_advance_update; + pthread_mutex_lock(&fill_ul_mutex.rx_mutex); + + UL_INFO->rx_ind.header.message_id = NFAPI_RX_ULSCH_INDICATION; UL_INFO->rx_ind.sfn_sf = frame << 4 | subframe; UL_INFO->rx_ind.rx_indication_body.tl.tag = NFAPI_RX_INDICATION_BODY_TAG; UL_INFO->rx_ind.vendor_extension = ul_config_req->vendor_extension; + assert(UL_INFO->rx_ind.rx_indication_body.number_of_pdus <= NFAPI_RX_IND_MAX_PDU); pdu = &UL_INFO->rx_ind.rx_indication_body .rx_pdu_list[UL_INFO->rx_ind.rx_indication_body.number_of_pdus]; // pdu = &UL_INFO->rx_ind.rx_indication_body.rx_pdu_list[index]; @@ -87,8 +114,10 @@ void fill_rx_indication_UE_MAC(module_id_t Mod_id, pdu->rx_indication_rel9.timing_advance_r9 = 0; // ulsch_buffer is necessary to keep its value. - pdu->data = malloc(buflen); - memcpy(pdu->data, ulsch_buffer, buflen); + assert(buflen <= NFAPI_RX_IND_DATA_MAX); + memcpy(pdu->rx_ind_data, ulsch_buffer, buflen); + LOG_I(MAC, "buflen of rx_ind pdu_data = %u SFN.SF: %d.%d\n", buflen, + frame, subframe); // estimate timing advance for MAC timing_advance_update = 0; // Don't know what to put here pdu->rx_indication_rel8.timing_advance = timing_advance_update; @@ -104,15 +133,21 @@ void fill_rx_indication_UE_MAC(module_id_t Mod_id, UL_INFO->rx_ind.rx_indication_body.number_of_pdus++; UL_INFO->rx_ind.sfn_sf = frame << 4 | subframe; + + pthread_mutex_unlock(&fill_ul_mutex.rx_mutex); } void fill_sr_indication_UE_MAC(int Mod_id, int frame, int subframe, UL_IND_t *UL_INFO, - uint16_t rnti) { + uint16_t rnti, + nfapi_ul_config_request_t *ul_config_req) { + pthread_mutex_lock(&fill_ul_mutex.sr_mutex); + nfapi_sr_indication_t *sr_ind = &UL_INFO->sr_ind; nfapi_sr_indication_body_t *sr_ind_body = &sr_ind->sr_indication_body; + assert(sr_ind_body->number_of_srs <= NFAPI_SR_IND_MAX_PDU); nfapi_sr_indication_pdu_t *pdu = &sr_ind_body->sr_pdu_list[sr_ind_body->number_of_srs]; UL_INFO->sr_ind.vendor_extension = ul_config_req->vendor_extension; @@ -139,6 +174,8 @@ void fill_sr_indication_UE_MAC(int Mod_id, // UL_INFO->rx_ind.rx_indication_body.number_of_pdus++; sr_ind_body->number_of_srs++; + + pthread_mutex_unlock(&fill_ul_mutex.sr_mutex); } void fill_crc_indication_UE_MAC(int Mod_id, @@ -147,7 +184,12 @@ void fill_crc_indication_UE_MAC(int Mod_id, UL_IND_t *UL_INFO, uint8_t crc_flag, int index, - uint16_t rnti) { + uint16_t rnti, + nfapi_ul_config_request_t *ul_config_req) { + pthread_mutex_lock(&fill_ul_mutex.crc_mutex); + LOG_D(MAC, "fill crc_indication num_crcs: %u\n", + UL_INFO->crc_ind.crc_indication_body.number_of_crcs); + assert(UL_INFO->crc_ind.crc_indication_body.number_of_crcs < NUMBER_OF_UE_MAX); nfapi_crc_indication_pdu_t *pdu = &UL_INFO->crc_ind.crc_indication_body .crc_pdu_list[UL_INFO->crc_ind.crc_indication_body.number_of_crcs]; @@ -171,6 +213,8 @@ void fill_crc_indication_UE_MAC(int Mod_id, __FUNCTION__, pdu->rx_ue_information.rnti, UL_INFO->crc_ind.crc_indication_body.number_of_crcs); + + pthread_mutex_unlock(&fill_ul_mutex.crc_mutex); } void fill_rach_indication_UE_MAC(int Mod_id, @@ -179,6 +223,8 @@ void fill_rach_indication_UE_MAC(int Mod_id, UL_IND_t *UL_INFO, uint8_t ra_PreambleIndex, uint16_t ra_RNTI) { + pthread_mutex_lock(&fill_ul_mutex.rach_mutex); + UL_INFO->rach_ind.rach_indication_body.number_of_preambles = 1; UL_INFO->rach_ind.header.message_id = NFAPI_RACH_INDICATION; @@ -221,8 +267,15 @@ void fill_rach_indication_UE_MAC(int Mod_id, // This function is currently defined only in the nfapi-RU-RAU-split so we // should call it when we merge with that branch. - oai_nfapi_rach_ind(&UL_INFO->rach_ind); + if (NFAPI_MODE == NFAPI_MODE_STANDALONE_PNF) { + send_standalone_msg(UL_INFO, UL_INFO->rach_ind.header.message_id); + } else { + oai_nfapi_rach_ind(&UL_INFO->rach_ind); + } + free(UL_INFO->rach_ind.rach_indication_body.preamble_list); + + pthread_mutex_unlock(&fill_ul_mutex.rach_mutex); } void fill_ulsch_cqi_indication_UE_MAC(int Mod_id, @@ -230,6 +283,10 @@ void fill_ulsch_cqi_indication_UE_MAC(int Mod_id, uint8_t subframe, UL_IND_t *UL_INFO, uint16_t rnti) { + pthread_mutex_lock(&fill_ul_mutex.cqi_mutex); + LOG_D(MAC, "num_cqis: %u in fill_ulsch_cqi_indication_UE_MAC\n", + UL_INFO->cqi_ind.cqi_indication_body.number_of_cqis); + assert(UL_INFO->cqi_ind.cqi_indication_body.number_of_cqis <= NFAPI_CQI_IND_MAX_PDU); nfapi_cqi_indication_pdu_t *pdu = &UL_INFO->cqi_ind.cqi_indication_body .cqi_pdu_list[UL_INFO->cqi_ind.cqi_indication_body.number_of_cqis]; @@ -240,7 +297,7 @@ void fill_ulsch_cqi_indication_UE_MAC(int Mod_id, UL_INFO->cqi_ind.sfn_sf = frame << 4 | subframe; // because of nfapi_vnf.c:733, set message id to 0, not // NFAPI_RX_CQI_INDICATION; - UL_INFO->cqi_ind.header.message_id = 0; + UL_INFO->cqi_ind.header.message_id = NFAPI_RX_CQI_INDICATION; UL_INFO->cqi_ind.cqi_indication_body.tl.tag = NFAPI_CQI_INDICATION_BODY_TAG; pdu->rx_ue_information.tl.tag = NFAPI_RX_UE_INFORMATION_TAG; @@ -256,13 +313,15 @@ void fill_ulsch_cqi_indication_UE_MAC(int Mod_id, pdu->cqi_indication_rel8.timing_advance = 0; // pdu->cqi_indication_rel8.number_of_cc_reported = 1; pdu->ul_cqi_information.tl.tag = NFAPI_UL_CQI_INFORMATION_TAG; - pdu->ul_cqi_information.channel = 1; // PUSCH + pdu->ul_cqi_information.channel = 1; // eNB_scheduler_primitives.c:4839: the upper four bits seem to be the CQI - const int cqi = 15; + const int cqi = get_cqi_from_mcs(); raw_pdu->pdu[0] = cqi << 4; UL_INFO->cqi_ind.cqi_indication_body.number_of_cqis++; + + pthread_mutex_unlock(&fill_ul_mutex.cqi_mutex); } void fill_ulsch_harq_indication_UE_MAC( @@ -271,7 +330,11 @@ void fill_ulsch_harq_indication_UE_MAC( int subframe, UL_IND_t *UL_INFO, nfapi_ul_config_ulsch_harq_information *harq_information, - uint16_t rnti) { + uint16_t rnti, + nfapi_ul_config_request_t *ul_config_req) { + pthread_mutex_lock(&fill_ul_mutex.harq_mutex); + + assert(UL_INFO->harq_ind.harq_indication_body.number_of_harqs <= NFAPI_HARQ_IND_MAX_PDU); nfapi_harq_indication_pdu_t *pdu = &UL_INFO->harq_ind.harq_indication_body.harq_pdu_list [UL_INFO->harq_ind.harq_indication_body.number_of_harqs]; @@ -303,6 +366,8 @@ void fill_ulsch_harq_indication_UE_MAC( } UL_INFO->harq_ind.harq_indication_body.number_of_harqs++; + + pthread_mutex_unlock(&fill_ul_mutex.harq_mutex); } void fill_uci_harq_indication_UE_MAC(int Mod_id, @@ -310,9 +375,13 @@ void fill_uci_harq_indication_UE_MAC(int Mod_id, int subframe, UL_IND_t *UL_INFO, nfapi_ul_config_harq_information *harq_information, - uint16_t rnti) { + uint16_t rnti, + nfapi_ul_config_request_t *ul_config_req) { + pthread_mutex_lock(&fill_ul_mutex.harq_mutex); + nfapi_harq_indication_t *ind = &UL_INFO->harq_ind; nfapi_harq_indication_body_t *body = &ind->harq_indication_body; + assert(UL_INFO->harq_ind.harq_indication_body.number_of_harqs <= NFAPI_HARQ_IND_MAX_PDU); nfapi_harq_indication_pdu_t *pdu = &body->harq_pdu_list[UL_INFO->harq_ind.harq_indication_body .number_of_harqs]; @@ -330,7 +399,7 @@ void fill_uci_harq_indication_UE_MAC(int Mod_id, pdu->ul_cqi_information.tl.tag = NFAPI_UL_CQI_INFORMATION_TAG; - int SNRtimes10 = 640; + int SNRtimes10 = 640; // TODO: Replace with EpiSci SNR * 10 if (SNRtimes10 < -640) pdu->ul_cqi_information.ul_cqi = 0; @@ -353,6 +422,17 @@ void fill_uci_harq_indication_UE_MAC(int Mod_id, pdu->harq_indication_fdd_rel13.harq_tb_n[0] = 1; // Assuming always an ACK (No NACK or DTX) + // TODO: Fix ack/dtx -- needed for 5G + // 1.) if received dl_config_req (with c-rnti) store this info and corresponding subframe. + // 2.) if receiving ul_config_req for uci ack/nack or ulsch ack/nak in subframe n + // go look to see if dl_config_req (with c-rnti) was received in subframe (n - 4) + // 3.) if the answer to #2 is yes then send ACK IF NOT send DTX + if (did_drop_transport_block(((subframe+6) % 10), rnti)) // TODO: Handle DTX. Also discuss handling PDCCH + { + pdu->harq_indication_fdd_rel13.harq_tb_n[0] = 2; + LOG_I(PHY, "Setting HARQ No ACK - Channel Model\n"); + } + } else if ((harq_information->harq_information_rel9_fdd.ack_nack_mode == 0) && (harq_information->harq_information_rel9_fdd.harq_size == 2)) { @@ -392,6 +472,8 @@ void fill_uci_harq_indication_UE_MAC(int Mod_id, LOG_D(PHY, "Incremented eNB->UL_INFO.harq_ind.number_of_harqs:%d\n", UL_INFO->harq_ind.harq_indication_body.number_of_harqs); + + pthread_mutex_unlock(&fill_ul_mutex.harq_mutex); } void handle_nfapi_ul_pdu_UE_MAC(module_id_t Mod_id, @@ -399,7 +481,8 @@ void handle_nfapi_ul_pdu_UE_MAC(module_id_t Mod_id, uint16_t frame, uint8_t subframe, uint8_t srs_present, - int index) { + int index, + nfapi_ul_config_request_t *ul_config_req) { if (ul_config_pdu->pdu_type == NFAPI_UL_CONFIG_ULSCH_PDU_TYPE) { LOG_D(PHY, "Applying UL config for UE, rnti %x for frame %d, subframe %d\n", @@ -418,7 +501,8 @@ void handle_nfapi_ul_pdu_UE_MAC(module_id_t Mod_id, Mod_id, frame, subframe); - fill_crc_indication_UE_MAC(Mod_id, frame, subframe, UL_INFO, 0, index, rnti); + fill_crc_indication_UE_MAC(Mod_id, frame, subframe, UL_INFO, 0, index, rnti, + ul_config_req); fill_rx_indication_UE_MAC(Mod_id, frame, subframe, @@ -426,7 +510,8 @@ void handle_nfapi_ul_pdu_UE_MAC(module_id_t Mod_id, UE_mac_inst[Mod_id].RA_prach_resources.Msg3, buflen, rnti, - index); + index, + ul_config_req); Msg3_transmitted(Mod_id, 0, frame, 0); // Modification UE_mac_inst[Mod_id].UE_mode[0] = PUSCH; @@ -436,7 +521,7 @@ void handle_nfapi_ul_pdu_UE_MAC(module_id_t Mod_id, // UE_mac_inst[Mod_id].first_ULSCH_Tx = 0; } else { ue_get_sdu(Mod_id, 0, frame, subframe, 0, ulsch_buffer, buflen, &access_mode); - fill_crc_indication_UE_MAC(Mod_id, frame, subframe, UL_INFO, 0, index, rnti); + fill_crc_indication_UE_MAC(Mod_id, frame, subframe, UL_INFO, 0, index, rnti, ul_config_req); fill_rx_indication_UE_MAC(Mod_id, frame, subframe, @@ -444,7 +529,8 @@ void handle_nfapi_ul_pdu_UE_MAC(module_id_t Mod_id, ulsch_buffer, buflen, rnti, - index); + index, + ul_config_req); } } } @@ -462,8 +548,8 @@ void handle_nfapi_ul_pdu_UE_MAC(module_id_t Mod_id, uint16_t rnti = ul_config_pdu->ulsch_harq_pdu.ulsch_pdu.ulsch_pdu_rel8.rnti; uint8_t access_mode = SCHEDULED_ACCESS; if (buflen > 0) { - if (UE_mac_inst[Mod_id].first_ULSCH_Tx == 1) { // Msg3 case - fill_crc_indication_UE_MAC(Mod_id, frame, subframe, UL_INFO, 0, index, rnti); + if (UE_mac_inst[Mod_id].first_ULSCH_Tx == 1) { + fill_crc_indication_UE_MAC(Mod_id, frame, subframe, UL_INFO, 0, index, rnti, ul_config_req); fill_rx_indication_UE_MAC(Mod_id, frame, subframe, @@ -471,7 +557,8 @@ void handle_nfapi_ul_pdu_UE_MAC(module_id_t Mod_id, UE_mac_inst[Mod_id].RA_prach_resources.Msg3, buflen, rnti, - index); + index, + ul_config_req); Msg3_transmitted(Mod_id, 0, frame, 0); // UE_mac_inst[Mod_id].first_ULSCH_Tx = 0; // Modification @@ -479,7 +566,7 @@ void handle_nfapi_ul_pdu_UE_MAC(module_id_t Mod_id, UE_mac_inst[Mod_id].first_ULSCH_Tx = 0; } else { ue_get_sdu(Mod_id, 0, frame, subframe, 0, ulsch_buffer, buflen, &access_mode); - fill_crc_indication_UE_MAC(Mod_id, frame, subframe, UL_INFO, 0, index, rnti); + fill_crc_indication_UE_MAC(Mod_id, frame, subframe, UL_INFO, 0, index, rnti, ul_config_req); fill_rx_indication_UE_MAC(Mod_id, frame, subframe, @@ -487,12 +574,13 @@ void handle_nfapi_ul_pdu_UE_MAC(module_id_t Mod_id, ulsch_buffer, buflen, rnti, - index); + index, + ul_config_req); } } if (ulsch_harq_information != NULL) fill_ulsch_harq_indication_UE_MAC( - Mod_id, frame, subframe, UL_INFO, ulsch_harq_information, rnti); + Mod_id, frame, subframe, UL_INFO, ulsch_harq_information, rnti, ul_config_req); } else if (ul_config_pdu->pdu_type == NFAPI_UL_CONFIG_ULSCH_CQI_RI_PDU_TYPE) { uint8_t ulsch_buffer[5477] __attribute__((aligned(32))); @@ -502,7 +590,7 @@ void handle_nfapi_ul_pdu_UE_MAC(module_id_t Mod_id, uint8_t access_mode = SCHEDULED_ACCESS; if (buflen > 0) { if (UE_mac_inst[Mod_id].first_ULSCH_Tx == 1) { // Msg3 case - fill_crc_indication_UE_MAC(Mod_id, frame, subframe, UL_INFO, 0, index, rnti); + fill_crc_indication_UE_MAC(Mod_id, frame, subframe, UL_INFO, 0, index, rnti, ul_config_req); fill_rx_indication_UE_MAC(Mod_id, frame, subframe, @@ -510,7 +598,8 @@ void handle_nfapi_ul_pdu_UE_MAC(module_id_t Mod_id, UE_mac_inst[Mod_id].RA_prach_resources.Msg3, buflen, rnti, - index); + index, + ul_config_req); Msg3_transmitted(Mod_id, 0, frame, 0); // UE_mac_inst[Mod_id].first_ULSCH_Tx = 0; // Modification @@ -518,7 +607,7 @@ void handle_nfapi_ul_pdu_UE_MAC(module_id_t Mod_id, UE_mac_inst[Mod_id].first_ULSCH_Tx = 0; } else { ue_get_sdu(Mod_id, 0, frame, subframe, 0, ulsch_buffer, buflen, &access_mode); - fill_crc_indication_UE_MAC(Mod_id, frame, subframe, UL_INFO, 0, index, rnti); + fill_crc_indication_UE_MAC(Mod_id, frame, subframe, UL_INFO, 0, index, rnti, ul_config_req); fill_rx_indication_UE_MAC(Mod_id, frame, subframe, @@ -526,7 +615,9 @@ void handle_nfapi_ul_pdu_UE_MAC(module_id_t Mod_id, ulsch_buffer, buflen, rnti, - index); + index, + ul_config_req); + fill_ulsch_cqi_indication_UE_MAC(Mod_id, frame, subframe, UL_INFO, rnti); } } } else if (ul_config_pdu->pdu_type == NFAPI_UL_CONFIG_ULSCH_CQI_HARQ_RI_PDU_TYPE) { @@ -539,7 +630,7 @@ void handle_nfapi_ul_pdu_UE_MAC(module_id_t Mod_id, uint8_t access_mode = SCHEDULED_ACCESS; if (buflen > 0) { if (UE_mac_inst[Mod_id].first_ULSCH_Tx == 1) { // Msg3 case - fill_crc_indication_UE_MAC(Mod_id, frame, subframe, UL_INFO, 0, index, rnti); + fill_crc_indication_UE_MAC(Mod_id, frame, subframe, UL_INFO, 0, index, rnti, ul_config_req); fill_rx_indication_UE_MAC(Mod_id, frame, subframe, @@ -547,7 +638,8 @@ void handle_nfapi_ul_pdu_UE_MAC(module_id_t Mod_id, UE_mac_inst[Mod_id].RA_prach_resources.Msg3, buflen, rnti, - index); + index, + ul_config_req); Msg3_transmitted(Mod_id, 0, frame, 0); // UE_mac_inst[Mod_id].first_ULSCH_Tx = 0; // Modification @@ -555,7 +647,7 @@ void handle_nfapi_ul_pdu_UE_MAC(module_id_t Mod_id, UE_mac_inst[Mod_id].first_ULSCH_Tx = 0; } else { ue_get_sdu(Mod_id, 0, frame, subframe, 0, ulsch_buffer, buflen, &access_mode); - fill_crc_indication_UE_MAC(Mod_id, frame, subframe, UL_INFO, 0, index, rnti); + fill_crc_indication_UE_MAC(Mod_id, frame, subframe, UL_INFO, 0, index, rnti, ul_config_req); fill_rx_indication_UE_MAC(Mod_id, frame, subframe, @@ -563,18 +655,20 @@ void handle_nfapi_ul_pdu_UE_MAC(module_id_t Mod_id, ulsch_buffer, buflen, rnti, - index); + index, + ul_config_req); + fill_ulsch_cqi_indication_UE_MAC(Mod_id, frame, subframe, UL_INFO, rnti); } } if (ulsch_harq_information != NULL) - fill_ulsch_harq_indication_UE_MAC(Mod_id, frame, subframe, UL_INFO, ulsch_harq_information, rnti); + fill_ulsch_harq_indication_UE_MAC(Mod_id, frame, subframe, UL_INFO, ulsch_harq_information, rnti, ul_config_req); } else if (ul_config_pdu->pdu_type == NFAPI_UL_CONFIG_UCI_HARQ_PDU_TYPE) { uint16_t rnti = ul_config_pdu->uci_harq_pdu.ue_information.ue_information_rel8.rnti; nfapi_ul_config_harq_information *ulsch_harq_information = &ul_config_pdu->uci_harq_pdu.harq_information; if (ulsch_harq_information != NULL) - fill_uci_harq_indication_UE_MAC(Mod_id, frame, subframe, UL_INFO, ulsch_harq_information, rnti); + fill_uci_harq_indication_UE_MAC(Mod_id, frame, subframe, UL_INFO, ulsch_harq_information, rnti, ul_config_req); } else if (ul_config_pdu->pdu_type == NFAPI_UL_CONFIG_UCI_CQI_PDU_TYPE) { AssertFatal(1 == 0, "NFAPI_UL_CONFIG_UCI_CQI_PDU_TYPE not handled yet\n"); } else if (ul_config_pdu->pdu_type == NFAPI_UL_CONFIG_UCI_CQI_HARQ_PDU_TYPE) { @@ -588,7 +682,7 @@ void handle_nfapi_ul_pdu_UE_MAC(module_id_t Mod_id, ul_config_pdu->uci_sr_pdu.ue_information.ue_information_rel8.rnti; if (ue_get_SR(Mod_id, 0, frame, 0, rnti, subframe)) - fill_sr_indication_UE_MAC(Mod_id, frame, subframe, UL_INFO, rnti); + fill_sr_indication_UE_MAC(Mod_id, frame, subframe, UL_INFO, rnti, ul_config_req); } else if (ul_config_pdu->pdu_type == NFAPI_UL_CONFIG_UCI_SR_HARQ_PDU_TYPE) { // AssertFatal((UE_id = @@ -602,13 +696,13 @@ void handle_nfapi_ul_pdu_UE_MAC(module_id_t Mod_id, // We fill the sr_indication only if ue_get_sr() would normally instruct PHY // to send a SR. if (ue_get_SR(Mod_id, 0, frame, 0, rnti, subframe)) - fill_sr_indication_UE_MAC(Mod_id, frame, subframe, UL_INFO, rnti); + fill_sr_indication_UE_MAC(Mod_id, frame, subframe, UL_INFO, rnti, ul_config_req); nfapi_ul_config_harq_information *ulsch_harq_information = &ul_config_pdu->uci_sr_harq_pdu.harq_information; if (ulsch_harq_information != NULL) fill_uci_harq_indication_UE_MAC( - Mod_id, frame, subframe, UL_INFO, ulsch_harq_information, rnti); + Mod_id, frame, subframe, UL_INFO, ulsch_harq_information, rnti, ul_config_req); } } @@ -625,6 +719,9 @@ int ul_config_req_UE_MAC(nfapi_ul_config_request_t *req, req->ul_config_request_body.rach_prach_frequency_resources, req->ul_config_request_body.srs_present); + LOG_D(MAC, "ul_config_req Frame: %d Subframe: %d Proxy Frame: %u Subframe: %u\n", + NFAPI_SFNSF2SFN(req->sfn_sf), NFAPI_SFNSF2SF(req->sfn_sf), + timer_frame, timer_subframe); int sfn = NFAPI_SFNSF2SFN(req->sfn_sf); int sf = NFAPI_SFNSF2SF(req->sfn_sf); @@ -654,10 +751,9 @@ int ul_config_req_UE_MAC(nfapi_ul_config_request_t *req, || (pdu_type == NFAPI_UL_CONFIG_UCI_SR_HARQ_PDU_TYPE && pdu->uci_cqi_sr_harq_pdu.ue_information.ue_information_rel8.rnti == rnti)) { handle_nfapi_ul_pdu_UE_MAC( - Mod_id, pdu, sfn, sf, req->ul_config_request_body.srs_present, i); + Mod_id, pdu, sfn, sf, req->ul_config_request_body.srs_present, i, req); } else { - // NFAPI_TRACE(NFAPI_TRACE_ERROR, "%s() PDU:%i UNKNOWN type :%d\n", - // __FUNCTION__, i, ul_config_pdu_list[i].pdu_type); + LOG_D(MAC, "UNKNOWN UL_CONFIG_REQ PDU_TYPE or RNTI not matching pdu type: %d\n", pdu_type); } } @@ -693,7 +789,8 @@ void dl_config_req_UE_MAC_dci(int sfn, int sf, nfapi_dl_config_request_pdu_t *dci, nfapi_dl_config_request_pdu_t *dlsch, - int num_ue) { + int num_ue, + nfapi_tx_req_pdu_list_t *tx_req_pdu_list) { DevAssert(dci->pdu_type == NFAPI_DL_CONFIG_DCI_DL_PDU_TYPE); DevAssert(dlsch->pdu_type == NFAPI_DL_CONFIG_DLSCH_PDU_TYPE); @@ -707,7 +804,7 @@ void dl_config_req_UE_MAC_dci(int sfn, } const int pdu_index = dlsch->dlsch_pdu.dlsch_pdu_rel8.pdu_index; - if (pdu_index < 0 || pdu_index >= tx_req_num_elems) { + if (pdu_index < 0 || pdu_index >= tx_req_pdu_list->num_pdus) { LOG_E(MAC, "%s(): Problem with receiving data: " "sfn/sf:%d.%d PDU size:%d, TX_PDU index: %d\n", @@ -716,6 +813,8 @@ void dl_config_req_UE_MAC_dci(int sfn, return; } + LOG_I(MAC, "%s() rnti value: 0x%x rnti type: %d\n", __func__, + rnti, rnti_type); if (rnti_type == 1) { // C-RNTI (Normal DLSCH case) for (int ue_id = 0; ue_id < num_ue; ue_id++) { if (UE_mac_inst[ue_id].crnti == rnti) { @@ -725,11 +824,18 @@ void dl_config_req_UE_MAC_dci(int sfn, __func__, sfn, sf, dci->pdu_size, dlsch->dlsch_pdu.dlsch_pdu_rel8.pdu_index, - tx_req_num_elems); - ue_send_sdu(ue_id, 0, sfn, sf, - tx_request_pdu_list[pdu_index].segments[0].segment_data, - tx_request_pdu_list[pdu_index].segments[0].segment_length, - 0); + tx_req_pdu_list->num_pdus); + if (node_number > 0 || !should_drop_transport_block(sf, dci->dci_dl_pdu.dci_dl_pdu_rel8.rnti)) + { + ue_send_sdu(ue_id, 0, sfn, sf, + tx_req_pdu_list->pdus[pdu_index].segments[0].segment_data, + tx_req_pdu_list->pdus[pdu_index].segments[0].segment_length, + 0); + } + else + { + LOG_I(MAC, "Transport Block discarded - ue_send_sdu not called. sf: %d", sf); + } return; } } @@ -738,18 +844,18 @@ void dl_config_req_UE_MAC_dci(int sfn, for (int ue_id = 0; ue_id < num_ue; ue_id++) { if (UE_mac_inst[ue_id].UE_mode[0] == NOT_SYNCHED) continue; - ue_decode_si(ue_id, 0, sfn, 0, - tx_request_pdu_list[pdu_index].segments[0].segment_data, - tx_request_pdu_list[pdu_index].segments[0].segment_length); + tx_req_pdu_list->pdus[pdu_index].segments[0].segment_data, + tx_req_pdu_list->pdus[pdu_index].segments[0].segment_length); } } else if (rnti == 0xFFFE) { /* PI-RNTI */ for (int ue_id = 0; ue_id < num_ue; ue_id++) { LOG_I(MAC, "%s() Received paging message: sfn/sf:%d.%d\n", __func__, sfn, sf); + ue_decode_p(ue_id, 0, sfn, 0, - tx_request_pdu_list[pdu_index].segments[0].segment_data, - tx_request_pdu_list[pdu_index].segments[0].segment_length); + tx_req_pdu_list->pdus[pdu_index].segments[0].segment_data, + tx_req_pdu_list->pdus[pdu_index].segments[0].segment_length); } } else if (rnti == 0x0002) { /* RA-RNTI */ for (int ue_id = 0; ue_id < num_ue; ue_id++) { @@ -769,19 +875,21 @@ void dl_config_req_UE_MAC_dci(int sfn, LOG_E(MAC, "%s(): Received RAR, PreambleIndex: %d\n", __func__, UE_mac_inst[ue_id].RA_prach_resources.ra_PreambleIndex); + ue_process_rar(ue_id, 0, sfn, ra_rnti, //RA-RNTI - tx_request_pdu_list[pdu_index].segments[0].segment_data, + tx_req_pdu_list->pdus[pdu_index].segments[0].segment_data, &UE_mac_inst[ue_id].crnti, //t-crnti UE_mac_inst[ue_id].RA_prach_resources.ra_PreambleIndex, - tx_request_pdu_list[pdu_index].segments[0].segment_data); - UE_mac_inst[ue_id].UE_mode[0] = RA_RESPONSE; + tx_req_pdu_list->pdus[pdu_index].segments[0].segment_data); + // UE_mac_inst[ue_id].UE_mode[0] = RA_RESPONSE; + LOG_I(MAC, "setting UE_MODE now: %d\n", UE_mac_inst[ue_id].UE_mode[0]); // Expecting an UL_CONFIG_ULSCH_PDU to enable Msg3 Txon (first // ULSCH Txon for the UE) UE_mac_inst[ue_id].first_ULSCH_Tx = 1; } } - } + } //else if (dl_config_pdu_list[i].pdu_type == NFAPI_DL_CONFIG_BCH_PDU_TYPE) { // // BCH case: Last parameter is 1 if first time synchronization and zero // // otherwise. Not sure which value to put for our case. @@ -810,7 +918,7 @@ void dl_config_req_UE_MAC_dci(int sfn, // tx_request_pdu_list[pdu_index].segments[0].segment_length, // 0,0); - //} + //} else { LOG_W(MAC, "can not handle special RNTI %x\n", rnti); } @@ -842,7 +950,8 @@ void dl_config_req_UE_MAC_bch(int sfn, void dl_config_req_UE_MAC_mch(int sfn, int sf, nfapi_dl_config_request_pdu_t *mch, - int num_ue) { + int num_ue, + nfapi_tx_req_pdu_list_t *tx_req_pdu_list) { DevAssert(mch->pdu_type == NFAPI_DL_CONFIG_MCH_PDU_TYPE); for (int ue_id = 0; ue_id < num_ue; ue_id++) { @@ -857,7 +966,7 @@ void dl_config_req_UE_MAC_mch(int sfn, } else { const int pdu_index = mch->mch_pdu.mch_pdu_rel8.pdu_index; - if (pdu_index < 0 || pdu_index >= tx_req_num_elems) { + if (pdu_index < 0 || pdu_index >= tx_req_pdu_list->num_pdus) { LOG_E(MAC, "%s(): Problem with receiving data: " "sfn/sf:%d.%d PDU size:%d, TX_PDU index: %d\n", @@ -866,8 +975,8 @@ void dl_config_req_UE_MAC_mch(int sfn, return; } ue_send_mch_sdu(ue_id, 0, sfn, - tx_request_pdu_list[pdu_index].segments[0].segment_data, - tx_request_pdu_list[pdu_index].segments[0].segment_length, + tx_req_pdu_list->pdus[pdu_index].segments[0].segment_data, + tx_req_pdu_list->pdus[pdu_index].segments[0].segment_length, 0,0); } } @@ -885,7 +994,6 @@ void hi_dci0_req_UE_MAC(int sfn, return; for (int ue_id = 0; ue_id < num_ue; ue_id++) { if (dci->rnti == UE_mac_inst[ue_id].crnti) { - fill_ulsch_cqi_indication_UE_MAC(ue_id, sfn, sf, UL_INFO, dci->rnti); return; } } @@ -893,114 +1001,147 @@ void hi_dci0_req_UE_MAC(int sfn, // The following set of memcpy functions should be getting called as callback // functions from pnf_p7_subframe_ind. -int memcpy_dl_config_req(L1_rxtx_proc_t *proc, - nfapi_pnf_p7_config_t *pnf_p7, - nfapi_dl_config_request_t *req) { - dl_config_req = (nfapi_dl_config_request_t *)malloc(sizeof(nfapi_dl_config_request_t)); - - // UE_mac_inst[Mod_id].dl_config_req->header = req->header; - dl_config_req->sfn_sf = req->sfn_sf; - - dl_config_req->vendor_extension = req->vendor_extension; - - dl_config_req->dl_config_request_body.number_dci = req->dl_config_request_body.number_dci; - dl_config_req->dl_config_request_body.number_pdcch_ofdm_symbols = req->dl_config_request_body.number_pdcch_ofdm_symbols; - dl_config_req->dl_config_request_body.number_pdsch_rnti = req->dl_config_request_body.number_pdsch_rnti; - dl_config_req->dl_config_request_body.number_pdu = req->dl_config_request_body.number_pdu; - - dl_config_req->dl_config_request_body.tl.tag = req->dl_config_request_body.tl.tag; - dl_config_req->dl_config_request_body.tl.length = req->dl_config_request_body.tl.length; - dl_config_req->dl_config_request_body.dl_config_pdu_list = - calloc(req->dl_config_request_body.number_pdu, - sizeof(nfapi_dl_config_request_pdu_t)); - for (int i = 0; i < dl_config_req->dl_config_request_body.number_pdu; i++) { - dl_config_req->dl_config_request_body.dl_config_pdu_list[i] = - req->dl_config_request_body.dl_config_pdu_list[i]; +static bool is_my_ul_config_req(nfapi_ul_config_request_t *req) +{ + bool is_my_rnti = false; + const rnti_t rnti = UE_mac_inst[0].crnti; // 0 for standalone pnf mode. TODO: Make this more clear - Andrew + for (int i = 0; i < req->ul_config_request_body.number_of_pdus; i++) + { + nfapi_ul_config_request_pdu_t *pdu = &req->ul_config_request_body.ul_config_pdu_list[i]; + const int pdu_type = pdu->pdu_type; + if ((pdu_type == NFAPI_UL_CONFIG_ULSCH_PDU_TYPE && pdu->ulsch_pdu.ulsch_pdu_rel8.rnti == rnti) || + (pdu_type == NFAPI_UL_CONFIG_ULSCH_HARQ_PDU_TYPE && pdu->ulsch_harq_pdu.ulsch_pdu.ulsch_pdu_rel8.rnti == rnti) || + (pdu_type == NFAPI_UL_CONFIG_ULSCH_CQI_RI_PDU_TYPE && pdu->ulsch_cqi_ri_pdu.ulsch_pdu.ulsch_pdu_rel8.rnti == rnti) || + (pdu_type == NFAPI_UL_CONFIG_ULSCH_CQI_HARQ_RI_PDU_TYPE && pdu->ulsch_cqi_harq_ri_pdu.ulsch_pdu.ulsch_pdu_rel8.rnti == rnti) || + (pdu_type == NFAPI_UL_CONFIG_UCI_HARQ_PDU_TYPE && pdu->uci_cqi_harq_pdu.ue_information.ue_information_rel8.rnti == rnti) || + (pdu_type == NFAPI_UL_CONFIG_UCI_SR_PDU_TYPE && pdu->uci_sr_pdu.ue_information.ue_information_rel8.rnti == rnti) || + (pdu_type == NFAPI_UL_CONFIG_UCI_SR_HARQ_PDU_TYPE && pdu->uci_cqi_sr_harq_pdu.ue_information.ue_information_rel8.rnti == rnti)) + { + is_my_rnti = true; + break; + } + else + { + LOG_D(MAC, "UNKNOWN UL_CONFIG_REQ PDU_TYPE: %d or RNTI is not mine \n", pdu_type); + } } - return 0; + return is_my_rnti; } -int memcpy_ul_config_req (L1_rxtx_proc_t *proc, nfapi_pnf_p7_config_t* pnf_p7, nfapi_ul_config_request_t* req) +int memcpy_ul_config_req(L1_rxtx_proc_t *proc, nfapi_pnf_p7_config_t *pnf_p7, nfapi_ul_config_request_t *req) { - ul_config_req = malloc(sizeof(nfapi_ul_config_request_t)); + if (!is_my_ul_config_req(req)) return 0; + nfapi_ul_config_request_t *p = malloc(sizeof(nfapi_ul_config_request_t)); - ul_config_req->sfn_sf = req->sfn_sf; - ul_config_req->vendor_extension = req->vendor_extension; + p->sfn_sf = req->sfn_sf; + p->vendor_extension = req->vendor_extension; - ul_config_req->ul_config_request_body.number_of_pdus = req->ul_config_request_body.number_of_pdus; - ul_config_req->ul_config_request_body.rach_prach_frequency_resources = req->ul_config_request_body.rach_prach_frequency_resources; - ul_config_req->ul_config_request_body.srs_present = req->ul_config_request_body.srs_present; + p->ul_config_request_body.number_of_pdus = req->ul_config_request_body.number_of_pdus; + p->ul_config_request_body.rach_prach_frequency_resources = req->ul_config_request_body.rach_prach_frequency_resources; + p->ul_config_request_body.srs_present = req->ul_config_request_body.srs_present; - ul_config_req->ul_config_request_body.tl.tag = req->ul_config_request_body.tl.tag; - ul_config_req->ul_config_request_body.tl.length = req->ul_config_request_body.tl.length; + p->ul_config_request_body.tl.tag = req->ul_config_request_body.tl.tag; + p->ul_config_request_body.tl.length = req->ul_config_request_body.tl.length; - ul_config_req->ul_config_request_body.ul_config_pdu_list = + p->ul_config_request_body.ul_config_pdu_list = calloc(req->ul_config_request_body.number_of_pdus, sizeof(nfapi_ul_config_request_pdu_t)); - for (int i = 0; i < ul_config_req->ul_config_request_body.number_of_pdus; i++) { - ul_config_req->ul_config_request_body.ul_config_pdu_list[i] = + for (int i = 0; i < p->ul_config_request_body.number_of_pdus; i++) + { + p->ul_config_request_body.ul_config_pdu_list[i] = req->ul_config_request_body.ul_config_pdu_list[i]; } + if (!put_queue(&ul_config_req_queue, p)) + { + free(p); + } + return 0; } -int memcpy_tx_req(nfapi_pnf_p7_config_t *pnf_p7, nfapi_tx_request_t *req) { - tx_req_num_elems = req->tx_request_body.number_of_pdus; - tx_request_pdu_list = calloc(tx_req_num_elems, sizeof(nfapi_tx_request_pdu_t)); - for (int i = 0; i < tx_req_num_elems; i++) { - tx_request_pdu_list[i].num_segments = req->tx_request_body.tx_pdu_list[i].num_segments; - tx_request_pdu_list[i].pdu_index = req->tx_request_body.tx_pdu_list[i].pdu_index; - tx_request_pdu_list[i].pdu_length = req->tx_request_body.tx_pdu_list[i].pdu_length; - for (int j = 0; j < req->tx_request_body.tx_pdu_list[i].num_segments; j++) { - tx_request_pdu_list[i].segments[j].segment_length = req->tx_request_body.tx_pdu_list[i].segments[j].segment_length; - if (tx_request_pdu_list[i].segments[j].segment_length > 0) { - tx_request_pdu_list[i].segments[j].segment_data = calloc( - tx_request_pdu_list[i].segments[j].segment_length, sizeof(uint8_t)); - memcpy(tx_request_pdu_list[i].segments[j].segment_data, - req->tx_request_body.tx_pdu_list[i].segments[j].segment_data, - tx_request_pdu_list[i].segments[j].segment_length); - } +void nfapi_free_tx_req_pdu_list(nfapi_tx_req_pdu_list_t *list) +{ + // free all the p[i].segments[j].segment_data memory + int num_pdus = list->num_pdus; + nfapi_tx_request_pdu_t *pdus = list->pdus; + for (int i = 0; i < num_pdus; i++) { + int num_segments = pdus[i].num_segments; + for (int j = 0; j < num_segments; j++) { + free(pdus[i].segments[j].segment_data); + pdus[i].segments[j].segment_data = NULL; } } + free(list); +} - return 0; +static bool is_my_hi_dci0_req(nfapi_hi_dci0_request_t *hi_dci0_req) +{ + bool is_my_rnti = false; + const rnti_t rnti = UE_mac_inst[0].crnti; // This is 0 representing the num_ues is 1 + nfapi_hi_dci0_request_body_t *hi_dci0_body = &hi_dci0_req->hi_dci0_request_body; + for (int i = 0; i < hi_dci0_body->number_of_dci + hi_dci0_body->number_of_hi; i++) + { + nfapi_hi_dci0_request_pdu_t *hi_dci0 = &hi_dci0_body->hi_dci0_pdu_list[i]; + if (hi_dci0->pdu_type != NFAPI_HI_DCI0_DCI_PDU_TYPE || hi_dci0->dci_pdu.dci_pdu_rel8.cqi_csi_request) + { + continue; + } + if (hi_dci0->dci_pdu.dci_pdu_rel8.rnti == rnti) + { + is_my_rnti = true; + break; + } + } + + return is_my_rnti; } -int memcpy_hi_dci0_req (L1_rxtx_proc_t *proc, - nfapi_pnf_p7_config_t* pnf_p7, +int memcpy_hi_dci0_req (L1_rxtx_proc_t *proc, + nfapi_pnf_p7_config_t* pnf_p7, nfapi_hi_dci0_request_t* req) { - hi_dci0_req = (nfapi_hi_dci0_request_t *)malloc(sizeof(nfapi_hi_dci0_request_t)); + + if (!is_my_hi_dci0_req(req)) + { + LOG_I(MAC, "Filtering hi_dci0_req\n"); + return 0; + } + nfapi_hi_dci0_request_t *p = (nfapi_hi_dci0_request_t *)malloc(sizeof(nfapi_hi_dci0_request_t)); //if(req!=0){ - hi_dci0_req->sfn_sf = req->sfn_sf; - hi_dci0_req->vendor_extension = req->vendor_extension; + p->sfn_sf = req->sfn_sf; + p->vendor_extension = req->vendor_extension; - hi_dci0_req->hi_dci0_request_body.number_of_dci = req->hi_dci0_request_body.number_of_dci; - hi_dci0_req->hi_dci0_request_body.number_of_hi = req->hi_dci0_request_body.number_of_hi; - hi_dci0_req->hi_dci0_request_body.sfnsf = req->hi_dci0_request_body.sfnsf; + p->hi_dci0_request_body.number_of_dci = req->hi_dci0_request_body.number_of_dci; + p->hi_dci0_request_body.number_of_hi = req->hi_dci0_request_body.number_of_hi; + p->hi_dci0_request_body.sfnsf = req->hi_dci0_request_body.sfnsf; - // UE_mac_inst[Mod_id].hi_dci0_req->hi_dci0_request_body.tl = + // UE_mac_inst[Mod_id].p->hi_dci0_request_body.tl = // req->hi_dci0_request_body.tl; - hi_dci0_req->hi_dci0_request_body.tl.tag = req->hi_dci0_request_body.tl.tag; - hi_dci0_req->hi_dci0_request_body.tl.length = req->hi_dci0_request_body.tl.length; + p->hi_dci0_request_body.tl.tag = req->hi_dci0_request_body.tl.tag; + p->hi_dci0_request_body.tl.length = req->hi_dci0_request_body.tl.length; - int total_pdus = hi_dci0_req->hi_dci0_request_body.number_of_dci - + hi_dci0_req->hi_dci0_request_body.number_of_hi; + int total_pdus = p->hi_dci0_request_body.number_of_dci + + p->hi_dci0_request_body.number_of_hi; - hi_dci0_req->hi_dci0_request_body.hi_dci0_pdu_list = + p->hi_dci0_request_body.hi_dci0_pdu_list = calloc(total_pdus, sizeof(nfapi_hi_dci0_request_pdu_t)); for (int i = 0; i < total_pdus; i++) { - hi_dci0_req->hi_dci0_request_body.hi_dci0_pdu_list[i] = req->hi_dci0_request_body.hi_dci0_pdu_list[i]; + p->hi_dci0_request_body.hi_dci0_pdu_list[i] = req->hi_dci0_request_body.hi_dci0_pdu_list[i]; // LOG_I(MAC, "Original hi_dci0 req. type:%d, Copy type: %d // \n",req->hi_dci0_request_body.hi_dci0_pdu_list[i].pdu_type, - // UE_mac_inst[Mod_id].hi_dci0_req->hi_dci0_request_body.hi_dci0_pdu_list[i].pdu_type); + // UE_mac_inst[Mod_id].p->hi_dci0_request_body.hi_dci0_pdu_list[i].pdu_type); + } + + if (!put_queue(&hi_dci0_req_queue, p)) { + free(p); } + LOG_I(MAC, "DCI0 QUEUE: %zu\n", hi_dci0_req_queue.num_items); return 0; } @@ -1039,6 +1180,9 @@ void UE_config_stub_pnf(void) { *(L1_ParamList.paramarray[j][L1_REMOTE_N_PORTD_IDX].iptr); stub_eth_params.transp_preference = ETH_UDP_MODE; + if (NFAPI_MODE!=NFAPI_UE_STUB_PNF) + continue; + sf_ahead = 2; // Cannot cope with 4 subframes betweem RX and TX - set it to 2 // configure_nfapi_pnf(UE_mac_inst[0].eth_params_n.remote_addr, // UE_mac_inst[0].eth_params_n.remote_portc, @@ -1055,79 +1199,934 @@ void UE_config_stub_pnf(void) { } } -/* Dummy functions*/ +void ue_init_standalone_socket(int tx_port, int rx_port) +{ + { + struct sockaddr_in server_address; + int addr_len = sizeof(server_address); + memset(&server_address, 0, addr_len); + server_address.sin_family = AF_INET; + server_address.sin_port = htons(tx_port); + + int sd = socket(server_address.sin_family, SOCK_DGRAM, 0); + if (sd < 0) + { + LOG_E(MAC, "Socket creation error standalone PNF\n"); + return; + } -void handle_nfapi_hi_dci0_dci_pdu( - PHY_VARS_eNB *eNB, - int frame, - int subframe, - L1_rxtx_proc_t *proc, - nfapi_hi_dci0_request_pdu_t *hi_dci0_config_pdu) { + if (inet_pton(server_address.sin_family, stub_eth_params.remote_addr, &server_address.sin_addr) <= 0) + { + LOG_E(MAC, "Invalid standalone PNF Address\n"); + close(sd); + return; + } + + // Using connect to use send() instead of sendto() + if (connect(sd, (struct sockaddr *)&server_address, addr_len) < 0) + { + LOG_E(MAC, "Connection to standalone PNF failed: %s\n", strerror(errno)); + close(sd); + return; + } + assert(ue_tx_sock_descriptor == -1); + ue_tx_sock_descriptor = sd; + } + + { + struct sockaddr_in server_address; + int addr_len = sizeof(server_address); + memset(&server_address, 0, addr_len); + server_address.sin_family = AF_INET; + server_address.sin_addr.s_addr = INADDR_ANY; + server_address.sin_port = htons(rx_port); + + int sd = socket(server_address.sin_family, SOCK_DGRAM, 0); + if (sd < 0) + { + LOG_E(MAC, "Socket creation error standalone PNF\n"); + return; + } + + if (bind(sd, (struct sockaddr *)&server_address, addr_len) < 0) + { + LOG_E(MAC, "Connection to standalone PNF failed: %s\n", strerror(errno)); + close(sd); + return; + } + assert(ue_rx_sock_descriptor == -1); + ue_rx_sock_descriptor = sd; + } } -void handle_nfapi_hi_dci0_hi_pdu( - PHY_VARS_eNB *eNB, - int frame, - int subframe, - L1_rxtx_proc_t *proc, - nfapi_hi_dci0_request_pdu_t *hi_dci0_config_pdu) { +void *ue_standalone_pnf_task(void *context) +{ + struct sockaddr_in server_address; + socklen_t addr_len = sizeof(server_address); + char buffer[NFAPI_MAX_PACKED_MESSAGE_SIZE]; + int sd = ue_rx_sock_descriptor; + assert(sd > 0); + + nfapi_tx_request_t tx_req; + nfapi_dl_config_request_t dl_config_req; + bool tx_req_valid = false; + bool dl_config_req_valid = false; + while (true) + { + ssize_t len = recvfrom(sd, buffer, sizeof(buffer), MSG_TRUNC, (struct sockaddr *)&server_address, &addr_len); + if (len == -1) + { + LOG_E(MAC, "reading from standalone pnf sctp socket failed \n"); + continue; + } + if (len > sizeof(buffer)) + { + LOG_E(MAC, "%s(%d). Message truncated. %zd\n", __FUNCTION__, __LINE__, len); + continue; + } + + /* First we'll check for possible messages from the proxy. We do this by checking + the length of the message. This works because sizeof(uint16_t) < sizeof(nfapi_p7_message_header_t) + and sizeof(phy_channel_params_t) < sizeof(nfapi_p7_message_header_t) and + sizeof(uint16_t) != sizeof(phy_channel_params_t). */ + if (len == sizeof(uint16_t)) + { + uint16_t sfn_sf = 0; + memcpy((void *)&sfn_sf, buffer, sizeof(sfn_sf)); + current_sfn_sf = sfn_sf; + + if (sem_post(&sfn_semaphore) != 0) + { + LOG_E(MAC, "sem_post() error\n"); + abort(); + } + } + else if (len == sizeof(phy_channel_params_t)) + { + phy_channel_params_t ch_info; + memcpy(&ch_info, buffer, sizeof(phy_channel_params_t)); + current_sfn_sf = ch_info.sfn_sf; + if (sem_post(&sfn_semaphore) != 0) + { + LOG_E(MAC, "sem_post() error\n"); + abort(); + } + uint16_t sf = ch_info.sfn_sf & 15; + assert(sf < 10); + + sf_rnti_mcs[sf].sinr = ch_info.sinr; + LOG_D(MAC, "Received_SINR = %f\n",ch_info.sinr); + } + else + { + nfapi_p7_message_header_t header; + if (nfapi_p7_message_header_unpack((void *)buffer, len, &header, sizeof(header), NULL) < 0) + { + LOG_E(MAC, "Header unpack failed for standalone pnf\n"); + continue; + } + switch (header.message_id) + { + case NFAPI_DL_CONFIG_REQUEST: + { + if (dl_config_req_valid) + { + LOG_W(MAC, "Received consecutive dl_config_reqs. Previous dl_config_req frame: %u, subframe: %u\n", + dl_config_req.sfn_sf >> 4, dl_config_req.sfn_sf & 15); + } + if (nfapi_p7_message_unpack((void *)buffer, len, &dl_config_req, + sizeof(dl_config_req), NULL) < 0) + { + LOG_E(MAC, "Message dl_config_req failed to unpack\n"); + break; + } + + LOG_I(MAC, "dl_config_req Frame: %u Subframe: %u\n", dl_config_req.sfn_sf >> 4, + dl_config_req.sfn_sf & 15); + + dl_config_req_valid = true; + + save_dci_pdu_for_crnti(&dl_config_req); + + if (tx_req_valid) + { + if (dl_config_req.sfn_sf != tx_req.sfn_sf) + { + LOG_W(MAC, "sfnsf mismatch. dl_config_req Frame: %u Subframe: %u, Discarding tx_req Frame: %u Subframe: %u\n", + dl_config_req.sfn_sf >> 4, dl_config_req.sfn_sf & 15, + tx_req.sfn_sf >> 4, tx_req.sfn_sf & 15); + tx_req_valid = false; + break; + } + enqueue_dl_config_req_tx_req(&dl_config_req, &tx_req); + dl_config_req_valid = false; + tx_req_valid = false; + } + + break; + } + case NFAPI_TX_REQUEST: + { + if (tx_req_valid) + { + LOG_W(MAC, "Received consecutive tx_reqs. Previous tx_req frame: %u, subframe: %u\n", + tx_req.sfn_sf >> 4, tx_req.sfn_sf & 15); + } + if (nfapi_p7_message_unpack((void *)buffer, len, &tx_req, + sizeof(tx_req), NULL) < 0) + { + LOG_E(MAC, "Message tx_req failed to unpack\n"); + break; + } + + LOG_I(MAC, "tx_req Frame: %u Subframe: %u\n", tx_req.sfn_sf >> 4, + tx_req.sfn_sf & 15); + + tx_req_valid = true; + if (dl_config_req_valid) + { + if (dl_config_req.sfn_sf != tx_req.sfn_sf) + { + LOG_W(MAC, "sfnsf mismatch. Discarding dl_config_req Frame: %u Subframe: %u, tx_req Frame: %u Subframe: %u\n", + dl_config_req.sfn_sf >> 4, dl_config_req.sfn_sf & 15, + tx_req.sfn_sf >> 4, tx_req.sfn_sf & 15); + dl_config_req_valid = false; + break; + } + enqueue_dl_config_req_tx_req(&dl_config_req, &tx_req); + dl_config_req_valid = false; + tx_req_valid = false; + } + + break; + } + case NFAPI_HI_DCI0_REQUEST: + { + nfapi_hi_dci0_request_t hi_dci0_req; + // lock this hi_dci0_req + if (nfapi_p7_message_unpack((void *)buffer, len, &hi_dci0_req, + sizeof(hi_dci0_req), NULL) < 0) + { + LOG_E(MAC, "Message hi_dci0_req failed to unpack\n"); + break; + } + + // check to see if hi_dci0_req is null + memcpy_hi_dci0_req(NULL, NULL, &hi_dci0_req); + + break; + } + case NFAPI_UL_CONFIG_REQUEST: + { + nfapi_ul_config_request_t ul_config_req; + // lock this ul_config_req + if (nfapi_p7_message_unpack((void *)buffer, len, &ul_config_req, + sizeof(ul_config_req), NULL) < 0) + { + LOG_E(MAC, "Message ul_config_req failed to unpack\n"); + break; + } + + // check to see if ul_config_req is null + memcpy_ul_config_req(NULL, NULL, &ul_config_req); + + break; + } + default: + LOG_E(MAC, "Case Statement has no corresponding nfapi message\n"); + break; + } + } + } +} + +static void save_dci_pdu_for_crnti(nfapi_dl_config_request_t *dl_config_req) +{ + int count_sent = 0; + int number_of_dci = dl_config_req->dl_config_request_body.number_dci; + int number_of_pdu = dl_config_req->dl_config_request_body.number_pdu; + if (number_of_pdu <= 0) + { + LOG_E(MAC, "%s: dl_config_req pdu size <= 0\n", __FUNCTION__); + abort(); + } + if (number_of_dci > 0) + { + for (int n = 0; n < number_of_pdu; n++) + { + const nfapi_dl_config_request_pdu_t *current_pdu_list = &dl_config_req->dl_config_request_body.dl_config_pdu_list[n]; + int rnti_type = current_pdu_list->dci_dl_pdu.dci_dl_pdu_rel8.rnti_type; + if (current_pdu_list->pdu_type == NFAPI_DL_CONFIG_DCI_DL_PDU_TYPE && rnti_type == 1 && count_sent < number_of_dci) + { + read_channel_param(current_pdu_list, (dl_config_req->sfn_sf & 15), count_sent); + count_sent++; + } + } + } +} + +void *memcpy_dl_config_req_standalone(nfapi_dl_config_request_t *dl_config_req) +{ + nfapi_dl_config_request_t *p = malloc(sizeof(nfapi_dl_config_request_t)); + + p->sfn_sf = dl_config_req->sfn_sf; + + p->vendor_extension = dl_config_req->vendor_extension; + + p->dl_config_request_body.number_dci = dl_config_req->dl_config_request_body.number_dci; + p->dl_config_request_body.number_pdcch_ofdm_symbols = dl_config_req->dl_config_request_body.number_pdcch_ofdm_symbols; + p->dl_config_request_body.number_pdsch_rnti = dl_config_req->dl_config_request_body.number_pdsch_rnti; + p->dl_config_request_body.number_pdu = dl_config_req->dl_config_request_body.number_pdu; + + p->dl_config_request_body.tl.tag = dl_config_req->dl_config_request_body.tl.tag; + p->dl_config_request_body.tl.length = dl_config_req->dl_config_request_body.tl.length; + + p->dl_config_request_body.dl_config_pdu_list = + calloc(dl_config_req->dl_config_request_body.number_pdu, + sizeof(nfapi_dl_config_request_pdu_t)); + for (int i = 0; i < p->dl_config_request_body.number_pdu; i++) { + p->dl_config_request_body.dl_config_pdu_list[i] = + dl_config_req->dl_config_request_body.dl_config_pdu_list[i]; + } + return p; } -void handle_nfapi_dci_dl_pdu(PHY_VARS_eNB *eNB, - int frame, - int subframe, - L1_rxtx_proc_t *proc, - nfapi_dl_config_request_pdu_t *dl_config_pdu) { +void *memcpy_tx_req_standalone(nfapi_tx_request_t *tx_req) +{ + int num_pdus = tx_req->tx_request_body.number_of_pdus; + + nfapi_tx_req_pdu_list_t *list = calloc(1, sizeof(nfapi_tx_req_pdu_list_t) + num_pdus * sizeof(nfapi_tx_request_pdu_t)); + list->num_pdus = num_pdus; + nfapi_tx_request_pdu_t *p = list->pdus; + + for (int i = 0; i < num_pdus; i++) + { + p[i].num_segments = tx_req->tx_request_body.tx_pdu_list[i].num_segments; + p[i].pdu_index = tx_req->tx_request_body.tx_pdu_list[i].pdu_index; + p[i].pdu_length = tx_req->tx_request_body.tx_pdu_list[i].pdu_length; + for (int j = 0; j < tx_req->tx_request_body.tx_pdu_list[i].num_segments; j++) + { + p[i].segments[j].segment_length = tx_req->tx_request_body.tx_pdu_list[i].segments[j].segment_length; + if (p[i].segments[j].segment_length > 0) + { + p[i].segments[j].segment_data = calloc( + p[i].segments[j].segment_length, sizeof(uint8_t)); + memcpy(p[i].segments[j].segment_data, + tx_req->tx_request_body.tx_pdu_list[i].segments[j].segment_data, + p[i].segments[j].segment_length); + } + } + } + return list; } -void handle_nfapi_bch_pdu(PHY_VARS_eNB *eNB, - L1_rxtx_proc_t *proc, - nfapi_dl_config_request_pdu_t *dl_config_pdu, - uint8_t *sdu) { +static bool is_my_dl_config_req(const nfapi_dl_config_request_t *req) +{ + + const rnti_t my_rnti = UE_mac_inst[0].crnti; + int num_pdus = req->dl_config_request_body.number_pdu; + // look through list of pdus for rnti type 1 with my_rnti (normal dlsch case) + for (int i = 0; i < num_pdus; i++) + { + nfapi_dl_config_request_pdu_t *pdu = &req->dl_config_request_body.dl_config_pdu_list[i]; + const int pdu_type = pdu->pdu_type; + if (pdu_type == NFAPI_DL_CONFIG_DCI_DL_PDU_TYPE) + { + const rnti_t dci_rnti = pdu->dci_dl_pdu.dci_dl_pdu_rel8.rnti; + const int rnti_type = pdu->dci_dl_pdu.dci_dl_pdu_rel8.rnti_type; + if (rnti_type == 1 && dci_rnti == my_rnti) + { + return true; + } + } + else if(pdu_type != NFAPI_DL_CONFIG_DLSCH_PDU_TYPE) + { + return true; // Because these two pdu_types are coupled and we have to accept all other pdu_types + } + } + + // Look for broadcasted rnti types + for (int i = 0; i < num_pdus; i++) + { + nfapi_dl_config_request_pdu_t *pdu = &req->dl_config_request_body.dl_config_pdu_list[i]; + const int pdu_type = pdu->pdu_type; + if (pdu_type == NFAPI_DL_CONFIG_DCI_DL_PDU_TYPE) + { + const int rnti_type = pdu->dci_dl_pdu.dci_dl_pdu_rel8.rnti_type; + if (rnti_type != 1) + { + return true; + } + } + } + + + return false; } -void handle_nfapi_dlsch_pdu(PHY_VARS_eNB *eNB, - int frame, - int subframe, - L1_rxtx_proc_t *proc, - nfapi_dl_config_request_pdu_t *dl_config_pdu, - uint8_t codeword_index, - uint8_t *sdu) { +void enqueue_dl_config_req_tx_req(nfapi_dl_config_request_t *dl_config_req, nfapi_tx_request_t *tx_req) +{ + if (!is_my_dl_config_req(dl_config_req)) + { + LOG_I(MAC, "Filtering dl_config_req and tx_req\n"); + return; + } + + nfapi_dl_config_request_t *dl_config_req_temp = memcpy_dl_config_req_standalone(dl_config_req); + nfapi_tx_req_pdu_list_t *tx_req_temp = memcpy_tx_req_standalone(tx_req); + LOG_I(MAC, "This is the num_pdus for tx_req: %d\n", tx_req_temp->num_pdus); + LOG_I(MAC, "This is the num_pdus for dl_config_req and the sfn_sf: %d, %d:%d\n", dl_config_req_temp->dl_config_request_body.number_pdu, + NFAPI_SFNSF2SFN(dl_config_req_temp->sfn_sf), NFAPI_SFNSF2SF(dl_config_req_temp->sfn_sf)); + + nfapi_dl_config_req_tx_req_t *req = malloc(sizeof(nfapi_dl_config_req_tx_req_t)); + req->dl_config_req = dl_config_req_temp; + req->tx_req_pdu_list = tx_req_temp; + + if (!put_queue(&dl_config_req_tx_req_queue, req)) + { + free(req->dl_config_req); + nfapi_free_tx_req_pdu_list(req->tx_req_pdu_list); + free(req); + } } -void handle_nfapi_ul_pdu(PHY_VARS_eNB *eNB, - L1_rxtx_proc_t *proc, - nfapi_ul_config_request_pdu_t *ul_config_pdu, - uint16_t frame, - uint8_t subframe, - uint8_t srs_present) { + +__attribute__((unused)) +static void print_rx_ind(nfapi_rx_indication_t *p) +{ + printf("Printing RX_IND fields\n"); + printf("header.message_id: %u\n", p->header.message_id); + printf("header.phy_id: %u\n", p->header.phy_id); + printf("header.message_id: %u\n", p->header.message_id); + printf("header.m_segment_sequence: %u\n", p->header.m_segment_sequence); + printf("header.checksum: %u\n", p->header.checksum); + printf("header.transmit_timestamp: %u\n", p->header.transmit_timestamp); + printf("sfn_sf: %u\n", p->sfn_sf); + printf("rx_indication_body.tl.tag: 0x%x\n", p->rx_indication_body.tl.tag); + printf("rx_indication_body.tl.length: %u\n", p->rx_indication_body.tl.length); + printf("rx_indication_body.number_of_pdus: %u\n", p->rx_indication_body.number_of_pdus); + + assert(p->rx_indication_body.number_of_pdus <= NFAPI_RX_IND_MAX_PDU); + nfapi_rx_indication_pdu_t *pdu = p->rx_indication_body.rx_pdu_list; + for (int i = 0; i < p->rx_indication_body.number_of_pdus; i++) + { + printf("pdu %d nfapi_rx_ue_information.tl.tag: 0x%x\n", i, pdu->rx_ue_information.tl.tag); + printf("pdu %d nfapi_rx_ue_information.tl.length: %u\n", i, pdu->rx_ue_information.tl.length); + printf("pdu %d nfapi_rx_ue_information.handle: %u\n", i, pdu->rx_ue_information.handle); + printf("pdu %d nfapi_rx_ue_information.rnti: %u\n", i, pdu->rx_ue_information.rnti); + printf("pdu %d nfapi_rx_indication_rel8.tl.tag: 0x%x\n", i, pdu->rx_indication_rel8.tl.tag); + printf("pdu %d nfapi_rx_indication_rel8.tl.length: %u\n", i, pdu->rx_indication_rel8.tl.length); + printf("pdu %d nfapi_rx_indication_rel8.length: %u\n", i, pdu->rx_indication_rel8.length); + printf("pdu %d nfapi_rx_indication_rel8.offset: %u\n", i, pdu->rx_indication_rel8.offset); + printf("pdu %d nfapi_rx_indication_rel8.ul_cqi: %u\n", i, pdu->rx_indication_rel8.ul_cqi); + printf("pdu %d nfapi_rx_indication_rel8.timing_advance: %u\n", i, pdu->rx_indication_rel8.timing_advance); + printf("pdu %d nfapi_rx_indication_rel9.tl.tag: 0x%x\n", i, pdu->rx_indication_rel9.tl.tag); + printf("pdu %d nfapi_rx_indication_rel9.tl.length: %u\n", i, pdu->rx_indication_rel9.tl.length); + printf("pdu %d nfapi_rx_indication_rel9.timing_advance_r9: %u\n", i, pdu->rx_indication_rel9.timing_advance_r9); + } + + fflush(stdout); } -void handle_nfapi_mch_pdu(PHY_VARS_eNB *eNB, - L1_rxtx_proc_t *proc, - nfapi_dl_config_request_pdu_t *dl_config_pdu, - uint8_t *sdu) { + + void send_standalone_msg(UL_IND_t *UL, nfapi_message_id_e msg_type) + { + int encoded_size = -1; + char buffer[NFAPI_MAX_PACKED_MESSAGE_SIZE]; + + switch (msg_type) + { + case NFAPI_RACH_INDICATION: + encoded_size = nfapi_p7_message_pack(&UL->rach_ind, buffer, sizeof(buffer), NULL); + LOG_A(MAC, "RACH_IND sent to Proxy, Size: %d Frame %d Subframe %d\n", encoded_size, + NFAPI_SFNSF2SFN(UL->rach_ind.sfn_sf), NFAPI_SFNSF2SF(UL->rach_ind.sfn_sf)); + break; + case NFAPI_CRC_INDICATION: + encoded_size = nfapi_p7_message_pack(&UL->crc_ind, buffer, sizeof(buffer), NULL); + LOG_I(MAC, "CRC_IND sent to Proxy, Size: %d Frame %d Subframe %d num_crcs: %u\n", encoded_size, + NFAPI_SFNSF2SFN(UL->crc_ind.sfn_sf), NFAPI_SFNSF2SF(UL->crc_ind.sfn_sf), + UL->crc_ind.crc_indication_body.number_of_crcs); + break; + case NFAPI_RX_ULSCH_INDICATION: + encoded_size = nfapi_p7_message_pack(&UL->rx_ind, buffer, sizeof(buffer), NULL); + LOG_I(MAC, "RX_IND sent to Proxy, Size: %d Frame %d Subframe %d rx_ind.tl.length: %u num_pdus: %u\n", + encoded_size, NFAPI_SFNSF2SFN(UL->rx_ind.sfn_sf), NFAPI_SFNSF2SF(UL->rx_ind.sfn_sf), + UL->rx_ind.rx_indication_body.tl.length, UL->rx_ind.rx_indication_body.number_of_pdus); + break; + case NFAPI_RX_CQI_INDICATION: + encoded_size = nfapi_p7_message_pack(&UL->cqi_ind, buffer, sizeof(buffer), NULL); + LOG_I(MAC, "CQI_IND sent to Proxy, Size: %d num_cqis: %u\n", encoded_size, + UL->cqi_ind.cqi_indication_body.number_of_cqis); + break; + case NFAPI_HARQ_INDICATION: + encoded_size = nfapi_p7_message_pack(&UL->harq_ind, buffer, sizeof(buffer), NULL); + LOG_I(MAC, "HARQ_IND sent to Proxy, Size: %d Frame %d Subframe %d\n", encoded_size, + NFAPI_SFNSF2SFN(UL->harq_ind.sfn_sf), NFAPI_SFNSF2SF(UL->harq_ind.sfn_sf)); + break; + case NFAPI_RX_SR_INDICATION: + encoded_size = nfapi_p7_message_pack(&UL->sr_ind, buffer, sizeof(buffer), NULL); + LOG_I(MAC, "SR_IND sent to Proxy, Size: %d\n", encoded_size); + break; + default: + LOG_I(MAC, "%s Unknown Message msg_type :: %u\n", __func__, msg_type); + return; + } + if (encoded_size < 0) + { + LOG_E(MAC, "standalone pack failed\n"); + return; + } + if (send(ue_tx_sock_descriptor, buffer, encoded_size, 0) < 0) + { + LOG_E(MAC, "Send Proxy UE failed\n"); + return; + } + } + + void send_standalone_dummy() + { + static const uint16_t dummy[] = {0, 0}; + if (send(ue_tx_sock_descriptor, dummy, sizeof(dummy), 0) < 0) + { + LOG_E(MAC, "send dummy to OAI UE failed: %s\n", strerror(errno)); + return; + } + } + +const char *dl_pdu_type_to_string(uint8_t pdu_type) +{ + switch (pdu_type) + { + case NFAPI_DL_CONFIG_DCI_DL_PDU_TYPE: + return "DCI_DL_PDU_TYPE"; + case NFAPI_DL_CONFIG_BCH_PDU_TYPE: + return "BCH_PDU_TYPE"; + case NFAPI_DL_CONFIG_MCH_PDU_TYPE: + return "MCH_PDU_TYPE"; + case NFAPI_DL_CONFIG_DLSCH_PDU_TYPE: + return "DLSCH_PDU_TYPE"; + case NFAPI_DL_CONFIG_PCH_PDU_TYPE: + return "PCH_PDU_TYPE"; + case NFAPI_DL_CONFIG_PRS_PDU_TYPE: + return "PRS_PDU_TYPE"; + case NFAPI_DL_CONFIG_CSI_RS_PDU_TYPE: + return "CSI_RS_PDU_TYPE"; + case NFAPI_DL_CONFIG_EPDCCH_DL_PDU_TYPE: + return "EPDCCH_DL_PDU_TYPE"; + case NFAPI_DL_CONFIG_MPDCCH_PDU_TYPE: + return "MPDCCH_PDU_TYPE"; + case NFAPI_DL_CONFIG_NBCH_PDU_TYPE: + return "NBCH_PDU_TYPE"; + case NFAPI_DL_CONFIG_NPDCCH_PDU_TYPE: + return "NPDCCH_PDU_TYPE"; + case NFAPI_DL_CONFIG_NDLSCH_PDU_TYPE: + return "NDLSCH_PDU_TYPE"; + default: + LOG_E(MAC, "%s No corresponding PDU for type: %u\n", __func__, pdu_type); + return "UNKNOWN"; + } } -void phy_config_request(PHY_Config_t *phy_config) { +const char *ul_pdu_type_to_string(uint8_t pdu_type) +{ + switch (pdu_type) + { + case NFAPI_UL_CONFIG_ULSCH_PDU_TYPE: + return "UL_CONFIG_ULSCH_PDU_TYPE"; + case NFAPI_UL_CONFIG_ULSCH_CQI_RI_PDU_TYPE: + return "UL_CONFIG_ULSCH_CQI_RI_PDU_TYPE"; + case NFAPI_UL_CONFIG_ULSCH_HARQ_PDU_TYPE: + return "UL_CONFIG_ULSCH_HARQ_PDU_TYPE"; + case NFAPI_UL_CONFIG_ULSCH_CQI_HARQ_RI_PDU_TYPE: + return "UL_CONFIG_ULSCH_CQI_HARQ_RI_PDU_TYPE"; + case NFAPI_UL_CONFIG_UCI_CQI_PDU_TYPE: + return "UL_CONFIG_UCI_CQI_PDU_TYPE"; + case NFAPI_UL_CONFIG_UCI_SR_PDU_TYPE: + return "UCI_SR_PDU_TYPE"; + case NFAPI_UL_CONFIG_UCI_HARQ_PDU_TYPE: + return "UCI_HARQ_PDU_TYPE"; + case NFAPI_UL_CONFIG_UCI_SR_HARQ_PDU_TYPE: + return "UCI_SR_HARQ_PDU_TYPE"; + case NFAPI_UL_CONFIG_UCI_CQI_HARQ_PDU_TYPE: + return "UCI_CQI_HARQ_PDU_TYPE"; + case NFAPI_UL_CONFIG_UCI_CQI_SR_PDU_TYPE: + return "UCI_CQI_SR_PDU_TYPE"; + case NFAPI_UL_CONFIG_UCI_CQI_SR_HARQ_PDU_TYPE: + return "UCI_CQI_SR_HARQ_PDU_TYPE"; + case NFAPI_UL_CONFIG_SRS_PDU_TYPE: + return "SRS_PDU_TYPE"; + case NFAPI_UL_CONFIG_HARQ_BUFFER_PDU_TYPE: + return "HARQ_BUFFER_PDU_TYPE"; + case NFAPI_UL_CONFIG_ULSCH_UCI_CSI_PDU_TYPE: + return "PDU_TYPE"; + case NFAPI_UL_CONFIG_ULSCH_UCI_HARQ_PDU_TYPE: + return "ULSCH_UCI_HARQ_PDU_TYPE"; + case NFAPI_UL_CONFIG_ULSCH_CSI_UCI_HARQ_PDU_TYPE: + return "ULSCH_CSI_UCI_HARQ_PDU_TYPE"; + case NFAPI_UL_CONFIG_NULSCH_PDU_TYPE: + return "NULSCH_PDU_TYPE"; + case NFAPI_UL_CONFIG_NRACH_PDU_TYPE: + return "NRACH_PDU_TYPE"; + default: + LOG_E(MAC, "%s No corresponding PDU for type: %u\n", __func__, pdu_type); + return "UNKNOWN"; + } } -void phy_config_update_sib2_request(PHY_Config_t *phy_config) { +char *nfapi_dl_config_req_to_string(nfapi_dl_config_request_t *req) +{ + const size_t max_result = 1024; + uint16_t num_pdus = req->dl_config_request_body.number_pdu; + int subframe = req->sfn_sf & 15; + int frame = req->sfn_sf >> 4; + char *result = malloc(max_result); + snprintf(result, max_result, "num_pdus=%u Frame=%d Subframe=%d", + num_pdus, frame, subframe); + for (size_t i = 0; i < num_pdus; ++i) + { + int len = strlen(result); + if (len >= max_result - 1) + { + break; + } + snprintf(result + len, max_result - len, " pdu_type=%s", + dl_pdu_type_to_string(req->dl_config_request_body.dl_config_pdu_list[i].pdu_type)); + } + return result; } -void phy_config_update_sib13_request(PHY_Config_t *phy_config) { +char *nfapi_ul_config_req_to_string(nfapi_ul_config_request_t *req) +{ + const size_t max_result = 1024; + uint16_t num_pdus = req->ul_config_request_body.number_of_pdus; + int subframe = req->sfn_sf & 15; + int frame = req->sfn_sf >> 4; + char *result = malloc(max_result); + snprintf(result, max_result, "num_pdus=%u Frame=%d Subframe=%d", + num_pdus, frame, subframe); + for (size_t i = 0; i < num_pdus; ++i) + { + int len = strlen(result); + if (len >= max_result - 1) + { + break; + } + snprintf(result + len, max_result - len, " pdu_type=%s", + ul_pdu_type_to_string(req->ul_config_request_body.ul_config_pdu_list[i].pdu_type)); + } + return result; } -uint32_t from_earfcn(int eutra_bandP, uint32_t dl_earfcn) { - return (0); +/* Dummy functions*/ + + void handle_nfapi_hi_dci0_dci_pdu( + PHY_VARS_eNB * eNB, + int frame, + int subframe, + L1_rxtx_proc_t *proc, + nfapi_hi_dci0_request_pdu_t *hi_dci0_config_pdu) + { + } + + void handle_nfapi_hi_dci0_hi_pdu( + PHY_VARS_eNB * eNB, + int frame, + int subframe, + L1_rxtx_proc_t *proc, + nfapi_hi_dci0_request_pdu_t *hi_dci0_config_pdu) + { + } + + void handle_nfapi_dci_dl_pdu(PHY_VARS_eNB * eNB, + int frame, + int subframe, + L1_rxtx_proc_t *proc, + nfapi_dl_config_request_pdu_t *dl_config_pdu) + { + } + + void handle_nfapi_bch_pdu(PHY_VARS_eNB * eNB, + L1_rxtx_proc_t * proc, + nfapi_dl_config_request_pdu_t * dl_config_pdu, + uint8_t * sdu) + { + } + + void handle_nfapi_dlsch_pdu(PHY_VARS_eNB * eNB, + int frame, + int subframe, + L1_rxtx_proc_t *proc, + nfapi_dl_config_request_pdu_t *dl_config_pdu, + uint8_t codeword_index, + uint8_t *sdu) + { + } + + void handle_nfapi_ul_pdu(PHY_VARS_eNB * eNB, + L1_rxtx_proc_t * proc, + nfapi_ul_config_request_pdu_t * ul_config_pdu, + uint16_t frame, + uint8_t subframe, + uint8_t srs_present) + { + } + void handle_nfapi_mch_pdu(PHY_VARS_eNB * eNB, + L1_rxtx_proc_t * proc, + nfapi_dl_config_request_pdu_t * dl_config_pdu, + uint8_t * sdu) + { + } + + void phy_config_request(PHY_Config_t * phy_config) + { + } + + void phy_config_update_sib2_request(PHY_Config_t * phy_config) + { + } + + void phy_config_update_sib13_request(PHY_Config_t * phy_config) + { + } + + uint32_t from_earfcn(int eutra_bandP, uint32_t dl_earfcn) + { + return (0); + } + + int32_t get_uldl_offset(int eutra_bandP) + { + return (0); + } + + int l1_north_init_eNB(void) + { + return 0; + } + + void init_eNB_afterRU(void) + { + } + +static int get_mcs_from_sinr(float sinr) +{ + if (sinr < (bler_data[0].bler_table[0][0])) + { + LOG_I(MAC, "The SINR was found is smaller than first MCS table\n"); + return 0; + } + + if (sinr > (bler_data[NUM_MCS-1].bler_table[bler_data[NUM_MCS-1].length - 1][0])) + { + LOG_I(MAC, "The SINR was found is larger than last MCS table\n"); + return NUM_MCS-1; + } + + for (int n = NUM_MCS-1; n >= 0; n--) + { + CHECK_INDEX(bler_data, n); + float largest_sinr = (bler_data[n].bler_table[bler_data[n].length - 1][0]); + float smallest_sinr = (bler_data[n].bler_table[0][0]); + if (sinr < largest_sinr && sinr > smallest_sinr) + { + LOG_I(MAC, "The SINR was found in MCS %d table\n", n); + return n; + } + } + LOG_E(MAC, "Unable to get an MCS value.\n"); + abort(); } -int32_t get_uldl_offset(int eutra_bandP) { - return (0); +static int get_cqi_from_mcs(void) +{ + static const int mcs_to_cqi[] = {0, 1, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10, 11, 11, 12, 12, 13, 13, 14, 14, 15}; + assert(NUM_ELEMENTS(mcs_to_cqi) == NUM_MCS); + int sf = 0; + while(sf < NUM_NFAPI_SUBFRAME) + { + if (sf_rnti_mcs[sf].latest) + { + int pdu_size = sf_rnti_mcs[sf].pdu_size; + if (pdu_size <= 0) + { + LOG_E(MAC, "%s: sf_rnti_mcs[%d].pdu_size = 0\n", __FUNCTION__, sf); + abort(); + } + + CHECK_INDEX(sf_rnti_mcs[sf].mcs, pdu_size); + int mcs = get_mcs_from_sinr(sf_rnti_mcs[sf].sinr); + CHECK_INDEX(mcs_to_cqi, mcs); + int cqi = mcs_to_cqi[mcs]; + LOG_I(MAC, "SINR: %f -> MCS: %d -> CQI: %d\n", sf_rnti_mcs[sf].sinr, mcs, cqi); + return cqi; + } + sf++; + } + LOG_E(MAC, "Unable to get CQI value because no MCS found\n"); + abort(); } -int l1_north_init_eNB(void) { - return 0; +static void read_channel_param(const nfapi_dl_config_request_pdu_t * pdu, int sf, int index) +{ + if (pdu == NULL) + { + LOG_E(MAC,"PDU NULL\n"); + abort(); + } + + /* This function is executed for every dci pdu type in a dl_config_req. We save + the assocaited MCS and RNTI value for each. The 'index' passed in is a count of + how many times we have called this function for a particular dl_config_req. It + allows us to save MCS/RNTI data in correct indicies when multiple dci's are received.*/ + for (int i = 0; i < NUM_NFAPI_SUBFRAME; i++) + { + if (i == sf) + { + CHECK_INDEX(sf_rnti_mcs[sf].rnti, index); + CHECK_INDEX(sf_rnti_mcs[sf].mcs, index); + CHECK_INDEX(sf_rnti_mcs[sf].drop_flag, index); + sf_rnti_mcs[sf].rnti[index] = pdu->dci_dl_pdu.dci_dl_pdu_rel8.rnti; + sf_rnti_mcs[sf].mcs[index] = pdu->dci_dl_pdu.dci_dl_pdu_rel8.mcs_1; + sf_rnti_mcs[sf].drop_flag[index] = false; + sf_rnti_mcs[sf].pdu_size = index+1; //index starts at 0 so we incrament to get num of pdus + sf_rnti_mcs[sf].latest = true; + LOG_I(MAC, "Adding MCS %d and RNTI %x for sf_rnti_mcs[%d]\n", sf_rnti_mcs[sf].mcs[index], sf_rnti_mcs[sf].rnti[index], sf); + } + else + { + sf_rnti_mcs[i].latest = false; + } + } + return; +} + +static bool did_drop_transport_block(int sf, uint16_t rnti) +{ + int pdu_size = sf_rnti_mcs[sf].pdu_size; + if(pdu_size <= 0) + { + LOG_E(MAC, "Problem, the PDU size is <= 0. We dropped this packet\n"); + return true; + } + CHECK_INDEX(sf_rnti_mcs[sf].rnti, pdu_size); + CHECK_INDEX(sf_rnti_mcs[sf].drop_flag, pdu_size); + for (int n = 0; n < pdu_size; n++) + { + if (sf_rnti_mcs[sf].rnti[n] == rnti && sf_rnti_mcs[sf].drop_flag[n]) + { + return true; + } + } + return false; +} + +static float get_bler_val(uint8_t mcs, int sinr) +{ + // 4th col = dropped packets, 5th col = total packets + float bler_val = 0.0; + CHECK_INDEX(bler_data, mcs); + if (sinr < (int)(bler_data[mcs].bler_table[0][0] * 10)) + { + LOG_I(MAC, "MCS %d table. SINR is smaller than lowest SINR, bler_val is set based on lowest SINR in table\n", mcs); + bler_val = bler_data[mcs].bler_table[0][4] / bler_data[mcs].bler_table[0][5]; + return bler_val; + } + if (sinr > (int)(bler_data[mcs].bler_table[bler_data[mcs].length - 1][0] * 10)) + { + LOG_I(MAC, "MCS %d table. SINR is greater than largest SINR. bler_val is set based on largest SINR in table\n", mcs); + bler_val = bler_data[mcs].bler_table[(bler_data[mcs].length - 1)][4] / bler_data[mcs].bler_table[(bler_data[mcs].length - 1)][5]; + return bler_val; + } + // Loop through bler table to find sinr_index + for (int i = 0; i < bler_data[mcs].length; i++) + { + int temp_sinr = (int)(bler_data[mcs].bler_table[i][0] * 10); + if (temp_sinr == sinr) + { + bler_val = bler_data[mcs].bler_table[i][4] / bler_data[mcs].bler_table[i][5]; + return bler_val; + } + // Linear interpolation when SINR is between indices + if (temp_sinr > sinr) + { + float bler_val1 = bler_data[mcs].bler_table[i - 1][4] / bler_data[mcs].bler_table[i - 1][5]; + float bler_val2 = bler_data[mcs].bler_table[i][4] / bler_data[mcs].bler_table[i][5]; + return ((bler_val1 + bler_val2) / 2); + } + } + LOG_E(MAC, "NO SINR INDEX FOUND!\n"); + abort(); + +} + +static inline bool is_channel_modeling(void) +{ + /* TODO: For now we enable channel modeling based on the node_number. + Replace with a command line option to enable/disable channel modeling. + The LTE UE will crash when channel modeling is conducted for NSA + mode. It does not crash for LTE mode. We have not implemented channel + modeling for NSA mode yet. For now, we ensure only do do chanel modeling + in LTE mode. */ + return node_number == 0 && !get_softmodem_params()->nsa; } -void init_eNB_afterRU(void) { +static bool should_drop_transport_block(int sf, uint16_t rnti) +{ + if (!is_channel_modeling()) + { + return false; + } + + /* We want to avoid dropping setup messages because this would be pathological. + This assumes were in standalone_pnf mode where + UE_rrc_inst[0] is module_id = 0 and Info[0] is eNB_index = 0. */ + UE_STATE_t state = UE_rrc_inst[0].Info[0].State; + if (state < RRC_CONNECTED) + { + LOG_I(MAC, "Not dropping because state: %d", state); + return false; + } + + /* Get block error rate (bler_val) from table based on every saved + MCS and SINR to be used as the cutoff rate for dropping packets. + Generate random uniform vairable to compare against bler_val. */ + int pdu_size = sf_rnti_mcs[sf].pdu_size; + assert(sf < 10 && sf >= 0); + assert(pdu_size > 0); + CHECK_INDEX(sf_rnti_mcs[sf].rnti, pdu_size); + CHECK_INDEX(sf_rnti_mcs[sf].mcs, pdu_size); + CHECK_INDEX(sf_rnti_mcs[sf].drop_flag, pdu_size); + int n = 0; + uint8_t mcs = 99; + for (n = 0; n < pdu_size; n++) + { + if (sf_rnti_mcs[sf].rnti[n] == rnti) + { + mcs = sf_rnti_mcs[sf].mcs[n]; + } + if (mcs != 99) + { + /* Use MCS to get the bler value. Since there can be multiple MCS + values for a particular subframe, we verify that all PDUs are not + flagged for drop before returning. If even one is flagged for drop + we return immediately because we drop the entire packet. */ + float bler_val = get_bler_val(mcs, ((int)(sf_rnti_mcs[sf].sinr * 10))); + double drop_cutoff = ((double) rand() / (RAND_MAX)); + assert(drop_cutoff <= 1); + LOG_I(MAC, "SINR = %f, Bler_val = %f, MCS = %"PRIu8"\n", sf_rnti_mcs[sf].sinr, bler_val, sf_rnti_mcs[sf].mcs[n]); + if (drop_cutoff <= bler_val) + { + sf_rnti_mcs[sf].drop_flag[n] = true; + LOG_D(MAC, "We are dropping this packet. Bler_val = %f, MCS = %"PRIu8", sf = %d\n", bler_val, sf_rnti_mcs[sf].mcs[n], sf); + return sf_rnti_mcs[sf].drop_flag[n]; + } + } + + } + + if (mcs == 99) + { + LOG_E(MAC, "NO MCS Found for rnti %x. sf_rnti_mcs[%d].mcs[%d] \n", rnti, sf, n); + abort(); + } + return false; } diff --git a/openair2/PHY_INTERFACE/phy_stub_UE.h b/openair2/PHY_INTERFACE/phy_stub_UE.h index bdf8872371e5e7f6b752a407f33f24d7ffc37497..ebaae6e667b8aa7f8a7a88415871ba73df23f34f 100644 --- a/openair2/PHY_INTERFACE/phy_stub_UE.h +++ b/openair2/PHY_INTERFACE/phy_stub_UE.h @@ -13,16 +13,51 @@ #include "openair2/PHY_INTERFACE/IF_Module.h" #include "nfapi_interface.h" #include "nfapi_pnf_interface.h" +#include <pthread.h> +#include <semaphore.h> +#include "nfapi/oai_integration/vendor_ext.h" //#include "openair1/PHY/LTE_TRANSPORT/defs.h" //#include "openair1/PHY/defs.h" //#include "openair1/PHY/LTE_TRANSPORT/defs.h" +#include "queue_t.h" +#define NUM_MCS 28 +#define NUM_SINR 100 +#define NUM_BLER_COL 13 + +// this mutex is used to set multiple UE's UL value in L2 FAPI simulator. +extern FILL_UL_INFO_MUTEX_t fill_ul_mutex; //below 2 difinitions move to phy_stub_UE.c to add initialization when difinition. extern UL_IND_t *UL_INFO; -extern nfapi_tx_request_pdu_t* tx_request_pdu_list; // New /// Pointers to config_request types. Used from nfapi callback functions. //below 3 difinitions move to phy_stub_UE.c to add initialization when difinition. + +//below 2 difinitions move to lte-ue.c to add initialization when difinition. +//int next_ra_frame; +//module_id_t next_Mod_id; + +typedef struct +{ + uint8_t sf; + uint16_t rnti[256]; + uint8_t mcs[256]; + float sinr; + uint16_t pdu_size; + bool drop_flag[256]; + bool latest; + +} sf_rnti_mcs_s; + +typedef struct +{ + uint16_t length; + float bler_table[NUM_SINR][NUM_BLER_COL]; +} bler_struct; + +extern bler_struct bler_data[NUM_MCS]; + + extern nfapi_dl_config_request_t* dl_config_req; extern nfapi_ul_config_request_t* ul_config_req; extern nfapi_hi_dci0_request_t* hi_dci0_req; @@ -52,16 +87,19 @@ void send_nfapi_UL_indications(UL_IND_t UL_INFO); //void fill_rx_indication_UE_MAC(module_id_t Mod_id,int frame,int subframe); -void fill_rx_indication_UE_MAC(module_id_t Mod_id,int frame,int subframe, UL_IND_t *UL_INFO, uint8_t *ulsch_buffer, uint16_t buflen, uint16_t rnti, int index); +void fill_rx_indication_UE_MAC(module_id_t Mod_id,int frame,int subframe, UL_IND_t *UL_INFO, uint8_t *ulsch_buffer, uint16_t buflen, uint16_t rnti, int index, + nfapi_ul_config_request_t *ul_config_req); // This function should be indicating directly to the eNB when there is a planned scheduling request at the MAC layer // of the UE. It should get called from ue_get_SR() -void fill_sr_indication_UE_MAC(int Mod_id,int frame,int subframe, UL_IND_t *UL_INFO, uint16_t rnti); +void fill_sr_indication_UE_MAC(int Mod_id,int frame,int subframe, UL_IND_t *UL_INFO, uint16_t rnti, + nfapi_ul_config_request_t *ul_config_req); // In our case the this function will be always indicating ACK to the MAC of the eNB (i.e. always assuming) // successful decoding. -void fill_crc_indication_UE_MAC(int Mod_id,int frame,int subframe, UL_IND_t *UL_INFO, uint8_t crc_flag, int index, uint16_t rnti); +void fill_crc_indication_UE_MAC(int Mod_id,int frame,int subframe, UL_IND_t *UL_INFO, uint8_t crc_flag, int index, uint16_t rnti, + nfapi_ul_config_request_t *ul_config_req); void fill_rach_indication_UE_MAC(int Mod_id,int frame,int subframe, UL_IND_t *UL_INFO, uint8_t ra_PreambleIndex, uint16_t ra_RNTI); @@ -70,9 +108,11 @@ void fill_rach_indication_UE_MAC(int Mod_id,int frame,int subframe, UL_IND_t *UL void fill_ulsch_cqi_indication_UE_MAC(int Mod_id, uint16_t frame,uint8_t subframe, UL_IND_t *UL_INFO, uint16_t rnti); -void fill_ulsch_harq_indication_UE_MAC(int Mod_id, int frame,int subframe, UL_IND_t *UL_INFO, nfapi_ul_config_ulsch_harq_information *harq_information, uint16_t rnti); +void fill_ulsch_harq_indication_UE_MAC(int Mod_id, int frame,int subframe, UL_IND_t *UL_INFO, nfapi_ul_config_ulsch_harq_information *harq_information, uint16_t rnti, + nfapi_ul_config_request_t *ul_config_req); -void fill_uci_harq_indication_UE_MAC(int Mod_id, int frame, int subframe, UL_IND_t *UL_INFO,nfapi_ul_config_harq_information *harq_information, uint16_t rnti +void fill_uci_harq_indication_UE_MAC(int Mod_id, int frame, int subframe, UL_IND_t *UL_INFO,nfapi_ul_config_harq_information *harq_information, uint16_t rnti, + nfapi_ul_config_request_t *ul_config_req /*uint8_t tdd_mapping_mode, uint16_t tdd_multiplexing_mask*/); @@ -80,13 +120,36 @@ int ul_config_req_UE_MAC(nfapi_ul_config_request_t* req, int frame, int subframe void handle_nfapi_ul_pdu_UE_MAC(module_id_t Mod_id, nfapi_ul_config_request_pdu_t *ul_config_pdu, - uint16_t frame,uint8_t subframe,uint8_t srs_present, int index); + uint16_t frame,uint8_t subframe,uint8_t srs_present, int index, + nfapi_ul_config_request_t *ul_config_req); + +typedef struct phy_channel_params_t +{ + uint16_t sfn_sf; + float sinr; + // Incomplete, need all channel parameters +} phy_channel_params_t; + +typedef struct nfapi_tx_req_pdu_list_t +{ + int num_pdus; /* number .pdus[] objects */ + nfapi_tx_request_pdu_t pdus[]; /* see "struct hack" */ +} nfapi_tx_req_pdu_list_t; + +typedef struct nfapi_dl_config_req_tx_req_t +{ + nfapi_dl_config_request_t *dl_config_req; + nfapi_tx_req_pdu_list_t *tx_req_pdu_list; +} nfapi_dl_config_req_tx_req_t; + +void nfapi_free_tx_req_pdu_list(nfapi_tx_req_pdu_list_t *); void dl_config_req_UE_MAC_dci(int sfn, int sf, nfapi_dl_config_request_pdu_t *dci, nfapi_dl_config_request_pdu_t *dlsch, - int num_ue); + int num_ue, + nfapi_tx_req_pdu_list_t *); void dl_config_req_UE_MAC_bch(int sfn, int sf, nfapi_dl_config_request_pdu_t *bch, @@ -94,7 +157,8 @@ void dl_config_req_UE_MAC_bch(int sfn, void dl_config_req_UE_MAC_mch(int sfn, int sf, nfapi_dl_config_request_pdu_t *bch, - int num_ue); + int num_ue, + nfapi_tx_req_pdu_list_t *); int tx_req_UE_MAC(nfapi_tx_request_t* req); @@ -107,19 +171,44 @@ void hi_dci0_req_UE_MAC(int sfn, // The following set of memcpy functions should be getting called as callback functions from // pnf_p7_subframe_ind. -int memcpy_dl_config_req (L1_rxtx_proc_t *proc, nfapi_pnf_p7_config_t* pnf_p7, nfapi_dl_config_request_t* req); +int memcpy_ul_config_req (L1_rxtx_proc_t *proc, nfapi_pnf_p7_config_t* pnf_p7, nfapi_ul_config_request_t* req); +int memcpy_hi_dci0_req (L1_rxtx_proc_t *proc, nfapi_pnf_p7_config_t* pnf_p7, nfapi_hi_dci0_request_t* req); -int memcpy_ul_config_req (L1_rxtx_proc_t *proc, nfapi_pnf_p7_config_t* pnf_p7, nfapi_ul_config_request_t* req); +void UE_config_stub_pnf(void); +void *memcpy_tx_req_standalone(nfapi_tx_request_t *tx_req); -int memcpy_tx_req (nfapi_pnf_p7_config_t* pnf_p7, nfapi_tx_request_t* req); +void *memcpy_dl_config_req_standalone(nfapi_dl_config_request_t *dl_config_req); +// open an SCTP socket with a standalone PNF module +void ue_init_standalone_socket(int tx_port, int rx_port); -int memcpy_hi_dci0_req (L1_rxtx_proc_t *proc, nfapi_pnf_p7_config_t* pnf_p7, nfapi_hi_dci0_request_t* req); +// read from standalone pnf socket call corresponding memcpy functions +void *ue_standalone_pnf_task(void *context); +void send_standalone_msg(UL_IND_t *UL, nfapi_message_id_e msg_type); +void send_standalone_dummy(void); +void enqueue_dl_config_req_tx_req(nfapi_dl_config_request_t *dl_config_req, nfapi_tx_request_t *tx_req); -void UE_config_stub_pnf(void); +// Convert downlink nfapi messages to a string. +// Returned memory is malloc'ed, caller is responsible for freeing. +char *nfapi_dl_config_req_to_string(nfapi_dl_config_request_t *req); +char *nfapi_ul_config_req_to_string(nfapi_ul_config_request_t *req); + +// Convert downlink nfapi messages to a string. +// Returned memory is statically allocated. +const char *dl_pdu_type_to_string(uint8_t pdu_type); +const char *ul_pdu_type_to_string(uint8_t pdu_type); + +extern queue_t dl_config_req_tx_req_queue; +extern queue_t ul_config_req_queue; +extern queue_t hi_dci0_req_queue; + +extern nfapi_ul_config_request_t* ul_config_req; +extern nfapi_hi_dci0_request_t* hi_dci0_req; +extern int current_sfn_sf; +extern sem_t sfn_semaphore; #endif /* PHY_STUB_UE_H_ */ diff --git a/openair2/PHY_INTERFACE/queue_t.c b/openair2/PHY_INTERFACE/queue_t.c new file mode 100644 index 0000000000000000000000000000000000000000..fd4b870676cf89391c682f0aab733e20aaf9e882 --- /dev/null +++ b/openair2/PHY_INTERFACE/queue_t.c @@ -0,0 +1,196 @@ +#include "queue_t.h" +#include <string.h> +#include <assert.h> + +#ifdef UNITTEST +#include <stdio.h> +#define LOG_ERROR(MSG) printf(MSG "\n") +#else +#include "common/utils/LOG/log.h" +#define LOG_ERROR(MSG) LOG_E(PHY, MSG "\n") +#endif + +void init_queue(queue_t *q) +{ + memset(q, 0, sizeof(*q)); + pthread_mutex_init(&q->mutex, NULL); +} + +void reset_queue(queue_t *q) +{ + void *p; + while ((p = get_queue(q)) != NULL) + { + free(p); + } +} + +void *put_queue_replace(queue_t *q, void *item) +{ + assert(item != NULL); + if (pthread_mutex_lock(&q->mutex) != 0) + { + LOG_ERROR("put_queue: mutex_lock failed"); + return false; + } + + void *evicted = NULL; + if (q->num_items >= MAX_QUEUE_SIZE) + { + evicted = q->items[q->read_index]; + assert(evicted != NULL); + q->items[q->read_index] = NULL; + q->read_index = (q->read_index + 1) % MAX_QUEUE_SIZE; + q->num_items--; + } + assert(q->items[q->write_index] == NULL); + q->items[q->write_index] = item; + q->write_index = (q->write_index + 1) % MAX_QUEUE_SIZE; + q->num_items++; + + pthread_mutex_unlock(&q->mutex); + return evicted; +} + + +bool put_queue(queue_t *q, void *item) +{ + assert(item != NULL); + if (pthread_mutex_lock(&q->mutex) != 0) + { + LOG_ERROR("put_queue: mutex_lock failed"); + return false; + } + + bool queued; + if (q->num_items >= MAX_QUEUE_SIZE) + { + LOG_ERROR("put_queue: queue is full"); + queued = false; + } + else + { + assert(q->items[q->write_index] == NULL); + q->items[q->write_index] = item; + q->write_index = (q->write_index + 1) % MAX_QUEUE_SIZE; + q->num_items++; + queued = true; + } + + pthread_mutex_unlock(&q->mutex); + return queued; +} + +void *get_queue(queue_t *q) +{ + void *item = NULL; + if (pthread_mutex_lock(&q->mutex) != 0) + { + LOG_ERROR("get_queue: mutex_lock failed"); + return NULL; + } + + if (q->num_items > 0) + { + item = q->items[q->read_index]; + assert(item != NULL); + q->items[q->read_index] = NULL; + q->read_index = (q->read_index + 1) % MAX_QUEUE_SIZE; + q->num_items--; + } + + pthread_mutex_unlock(&q->mutex); + return item; +} + +bool requeue(queue_t *q, void *item) +{ + assert(item != NULL); + if (pthread_mutex_lock(&q->mutex) != 0) + { + LOG_ERROR("requeue: mutex_lock failed"); + return false; + } + + bool queued; + if (q->num_items >= MAX_QUEUE_SIZE) + { + LOG_ERROR("requeue: queue is full"); + queued = false; + } + else + { + q->read_index = (q->read_index + MAX_QUEUE_SIZE - 1) % MAX_QUEUE_SIZE; + assert(q->items[q->read_index] == NULL); + q->items[q->read_index] = item; + q->num_items++; + queued = true; + } + + pthread_mutex_unlock(&q->mutex); + return queued; +} + +void *unqueue(queue_t *q) +{ + void *item = NULL; + if (pthread_mutex_lock(&q->mutex) != 0) { + LOG_ERROR("unqueue: mutex_lock failed"); + return NULL; + } + + if (q->num_items > 0) { + q->write_index = (q->write_index + MAX_QUEUE_SIZE - 1) % MAX_QUEUE_SIZE; + item = q->items[q->write_index]; + q->items[q->write_index] = NULL; + q->num_items--; + } + + pthread_mutex_unlock(&q->mutex); + return item; +} + +void *unqueue_matching(queue_t *q, size_t max_depth, queue_matcher_t *matcher, void *wanted) +{ + if (pthread_mutex_lock(&q->mutex) != 0) + { + LOG_ERROR("unqueue_matching: mutex_lock failed"); + return NULL; + } + + void *item = NULL; + size_t endi = q->write_index; + for (size_t i = 0; i < q->num_items; i++) + { + if (max_depth == 0) + { + break; + } + --max_depth; + + endi = (endi + MAX_QUEUE_SIZE - 1) % MAX_QUEUE_SIZE; + void *candidate = q->items[endi]; + if (matcher(wanted, candidate)) + { + item = candidate; + // delete item from the queue and move other items down + for (;;) + { + size_t j = (endi + 1) % MAX_QUEUE_SIZE; + if (j == q->write_index) + { + q->items[endi] = NULL; + q->write_index = endi; + q->num_items--; + break; + } + q->items[endi] = q->items[j]; + endi = j; + } + break; + } + } + + pthread_mutex_unlock(&q->mutex); + return item; +} diff --git a/openair2/PHY_INTERFACE/queue_t.h b/openair2/PHY_INTERFACE/queue_t.h new file mode 100644 index 0000000000000000000000000000000000000000..4678e310301ac4934ca1f7e2c241e18f481a01c4 --- /dev/null +++ b/openair2/PHY_INTERFACE/queue_t.h @@ -0,0 +1,64 @@ +/* + queue_t is a basic thread-safe non-blocking fixed-size queue. + + put_queue returns false if the queue is full. + get_queue returns NULL if the queue is empty. + + Example usage: + + // Initialization: + queue_t fooq; + init_queue(&fooq); + + // Producer: + foo_t *item = new_foo(); + if (!put_queue(&fooq, item)) + delete_foo(item); + + // Consumer: + foo_t *item = get_queue(&fooq); + if (item) + { + do_something_with_foo(item); + delete_foo(item); + } +*/ + +#pragma once + +#include <stdbool.h> +#include <stdint.h> +#include <pthread.h> + +#define MAX_QUEUE_SIZE 512 + +typedef struct queue_t +{ + void *items[MAX_QUEUE_SIZE]; + size_t read_index, write_index; + size_t num_items; + pthread_mutex_t mutex; +} queue_t; + +void init_queue(queue_t *q); +void reset_queue(queue_t *q); +void *put_queue_replace(queue_t *q, void *item); +bool put_queue(queue_t *q, void *item); +void *get_queue(queue_t *q); + +/* Put the given item back onto this queue at the head. + (The next call to put_queue would return this item.) + Return true if successful, false if the queue was full */ +bool requeue(queue_t *q, void *item); + +/* Remove the last item queued. + Return the item or NULL if the queue was empty */ +void *unqueue(queue_t *q); + +typedef bool queue_matcher_t(void *wanted, void *candidate); + +/* Unqueue the most recently queued item for which `matcher(wanted, candidate)` + returns true where `candidate` is an item currently on the queue. + Look only at the last `max_depth` items on the queue, at most. + Returns the candidate item, or NULL if none matches */ +void *unqueue_matching(queue_t *q, size_t max_depth, queue_matcher_t *matcher, void *wanted); diff --git a/openair2/PHY_INTERFACE/queue_test.c b/openair2/PHY_INTERFACE/queue_test.c new file mode 100644 index 0000000000000000000000000000000000000000..542b6a676b2a7f1a1f630f649e825aa37273f0ee --- /dev/null +++ b/openair2/PHY_INTERFACE/queue_test.c @@ -0,0 +1,226 @@ +#include "queue_t.h" +#include <stdio.h> +#include <stdlib.h> + +#define FAIL do { \ + printf("\n*** FAILED at %s line %d\n", __FILE__, __LINE__); \ + pass = false; \ +} while (0) + +#define EQUAL(A, B) do { \ + if ((A) != (B)) \ + FAIL; \ +} while (0) + +typedef uint32_t Thing_t; /* actual type doesn't matter */ + +static Thing_t things[MAX_QUEUE_SIZE]; +static Thing_t thing1, thing2; + +static bool matcher(void *wanted, void *candidate) +{ + return wanted == candidate; +} + +int main(void) +{ + bool pass = true; + queue_t queue; + init_queue(&queue); + + for (int i = 0; i < MAX_QUEUE_SIZE; ++i) + { + if (!put_queue(&queue, &things[i])) + { + FAIL; + } + } + + /* queue is full */ + if (put_queue(&queue, &thing1)) + FAIL; + + Thing_t *p; + for (int i = 0; i < MAX_QUEUE_SIZE; ++i) + { + p = get_queue(&queue); + EQUAL(p, &things[i]); + } + + /* queue is empty */ + p = get_queue(&queue); + EQUAL(p, NULL); + + for (int i = 0; i < MAX_QUEUE_SIZE; ++i) + { + if (!put_queue(&queue, &things[i])) + { + FAIL; + } + } + + p = get_queue(&queue); + EQUAL(p, &things[0]); + + p = get_queue(&queue); + EQUAL(p, &things[1]); + + if (!requeue(&queue, &thing1)) + FAIL; + if (!requeue(&queue, &thing2)) + FAIL; + p = get_queue(&queue); + EQUAL(p, &thing2); + p = get_queue(&queue); + EQUAL(p, &thing1); + + if (!requeue(&queue, &things[1])) + FAIL; + if (!requeue(&queue, &things[0])) + FAIL; + + for (int i = 0; i < MAX_QUEUE_SIZE / 2; ++i) + { + p = get_queue(&queue); + EQUAL(p, &things[i]); + } + + for (int i = MAX_QUEUE_SIZE / 2; i < MAX_QUEUE_SIZE; ++i) + { + if (!put_queue(&queue, &things[i])) + FAIL; + } + + p = get_queue(&queue); + EQUAL(p, &things[MAX_QUEUE_SIZE / 2]); + p = get_queue(&queue); + EQUAL(p, &things[MAX_QUEUE_SIZE / 2 + 1]); + + // ---- unqueue ---- + + init_queue(&queue); + for (int i = 0; i < MAX_QUEUE_SIZE; ++i) + { + if (!put_queue(&queue, &things[i])) + { + FAIL; + } + } + for (int i = MAX_QUEUE_SIZE; --i >= 0;) + { + p = unqueue(&queue); + EQUAL(p, &things[i]); + EQUAL(queue.num_items, i); + } + EQUAL(queue.num_items, 0); + if (!put_queue(&queue, &thing1)) + FAIL; + if (!put_queue(&queue, &thing2)) + FAIL; + EQUAL(queue.num_items, 2); + p = get_queue(&queue); + EQUAL(p, &thing1); + p = get_queue(&queue); + EQUAL(p, &thing2); + + // ---- unqueue_matching ---- + + init_queue(&queue); + + // empty queue + p = unqueue_matching(&queue, MAX_QUEUE_SIZE, matcher, &thing1); + EQUAL(p, NULL); + EQUAL(queue.num_items, 0); + + // one item in queue + if (!put_queue(&queue, &thing1)) + FAIL; + EQUAL(queue.num_items, 1); + p = unqueue_matching(&queue, MAX_QUEUE_SIZE, matcher, &thing2); + EQUAL(p, NULL); + EQUAL(queue.num_items, 1); + + p = unqueue_matching(&queue, /*max_queue=*/ 0, matcher, &thing1); + EQUAL(p, NULL); + EQUAL(queue.num_items, 1); + + p = unqueue_matching(&queue, /*max_queue=*/ 1, matcher, &thing1); + EQUAL(p, &thing1); + EQUAL(queue.num_items, 0); + + // more max_queue values + for (int i = 0; i < MAX_QUEUE_SIZE; ++i) + { + if (!put_queue(&queue, &things[i])) + { + FAIL; + } + } + p = unqueue_matching(&queue, /*max_queue=*/ 0, matcher, &things[MAX_QUEUE_SIZE - 1]); + EQUAL(p, NULL); + p = unqueue_matching(&queue, /*max_queue=*/ 1, matcher, &things[MAX_QUEUE_SIZE - 1]); + EQUAL(p, &things[MAX_QUEUE_SIZE - 1]); + EQUAL(queue.num_items, MAX_QUEUE_SIZE - 1); + p = unqueue_matching(&queue, /*max_queue=*/ MAX_QUEUE_SIZE - 2, matcher, &things[0]); + EQUAL(p, NULL); + p = unqueue_matching(&queue, /*max_queue=*/ MAX_QUEUE_SIZE - 1, matcher, &things[0]); + EQUAL(p, &things[0]); + EQUAL(queue.num_items, MAX_QUEUE_SIZE - 2); + + // fill the queue then remove every other item + init_queue(&queue); + for (int i = 0; i < MAX_QUEUE_SIZE; ++i) + { + if (!put_queue(&queue, &things[i])) + { + FAIL; + } + } + p = unqueue_matching(&queue, MAX_QUEUE_SIZE, matcher, &thing1); + EQUAL(p, NULL); + for (int i = MAX_QUEUE_SIZE - 1; i >= 0; i -= 2) + { + p = unqueue_matching(&queue, MAX_QUEUE_SIZE, matcher, &things[i]); + EQUAL(p, &things[i]); + } + EQUAL(queue.num_items, MAX_QUEUE_SIZE / 2); + p = unqueue_matching(&queue, MAX_QUEUE_SIZE, matcher, &thing1); + EQUAL(p, NULL); + for (int i = 0; i < MAX_QUEUE_SIZE; i += 2) + { + p = get_queue(&queue); + EQUAL(p, &things[i]); + } + EQUAL(queue.num_items, 0); + + // fill the queue then remove every third item + for (int i = 0; i < MAX_QUEUE_SIZE; ++i) + { + if (!put_queue(&queue, &things[i])) + { + FAIL; + } + } + p = unqueue_matching(&queue, MAX_QUEUE_SIZE, matcher, &thing1); + EQUAL(p, NULL); + for (int i = 0; i < MAX_QUEUE_SIZE; i += 3) + { + p = unqueue_matching(&queue, MAX_QUEUE_SIZE, matcher, &things[i]); + EQUAL(p, &things[i]); + } + EQUAL(queue.num_items, MAX_QUEUE_SIZE * 2 / 3); + p = unqueue_matching(&queue, MAX_QUEUE_SIZE, matcher, &thing1); + EQUAL(p, NULL); + for (int i = 0; i < MAX_QUEUE_SIZE; ++i) + { + if (i % 3 == 0) + continue; + p = get_queue(&queue); + EQUAL(p, &things[i]); + } + EQUAL(queue.num_items, 0); + + if (!pass) + return EXIT_FAILURE; + return EXIT_SUCCESS; +} diff --git a/openair2/PHY_INTERFACE/queue_test_run b/openair2/PHY_INTERFACE/queue_test_run new file mode 100755 index 0000000000000000000000000000000000000000..afb3842eb334e4a99b18c109ee80114c706ba67d --- /dev/null +++ b/openair2/PHY_INTERFACE/queue_test_run @@ -0,0 +1,18 @@ +#!/bin/bash + +opts=( + -Wall -Werror + -Wno-error=int-to-pointer-cast + -Wno-int-to-pointer-cast + -DUNITTEST +) + +set -x + +gcc "${opts[@]}" -fsanitize=address -o queue_test queue_test.c queue.c || exit +./queue_test || exit + +gcc "${opts[@]}" -o queue_test queue_test.c queue.c || exit +valgrind ./queue_test || exit + +: PASS diff --git a/openair2/RRC/L2_INTERFACE/openair_rrc_L2_interface.c b/openair2/RRC/L2_INTERFACE/openair_rrc_L2_interface.c deleted file mode 100644 index c64fd09bfcc1d0049f2ff260d7eefceb9e19a168..0000000000000000000000000000000000000000 --- a/openair2/RRC/L2_INTERFACE/openair_rrc_L2_interface.c +++ /dev/null @@ -1,247 +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 - */ - -/*! \file l2_interface.c -* \brief layer 2 interface -* \author Navid Nikaein and Raymond Knopp -* \date 2011 -* \version 1.0 -* \company Eurecom -* \email: navid.nikaein@eurecom.fr -*/ - -#include <fcntl.h> -#include <stdio.h> -#include <stdlib.h> - -#include "platform_types.h" -#include "openair_defs.h" - -#ifdef CELLULAR -#include "rrc_L2_proto.h" -#else -#include "RRC/LTE/defs.h" -#endif //CELLULAR -#include "COMMON/mac_rrc_primitives.h" -#include "openair_rrc_L2_interface.h" - -//------------------------------------------------------------------------------ -int8_t -mac_rrc_data_req( - const module_id_t module_idP, - const int CC_idP, - const frame_t frameP, - const rb_id_t srb_idP, - const uint8_t nb_tbP, - uint8_t* const buffer_pP, - const eNB_flag_t eNB_flagP, - const uint8_t eNB_indexP, - const uint8_t mbsfn_sync_areaP -) -//------------------------------------------------------------------------------ -{ - return(mac_rrc_lite_data_req( - module_idP, - CC_idP, - frameP, - srb_idP, - nb_tbP, - buffer_pP, - eNB_flagP, - eNB_indexP, - mbsfn_sync_areaP) - ); -} - -//------------------------------------------------------------------------------ -/*int8_t -mac_rrc_data_ind( - const module_id_t module_idP, - const int CC_idP, - const frame_t frameP, - const sub_frame_t subframeP, - const rnti_t rntiP, - const rb_id_t srb_idP, - const uint8_t *sduP, - const sdu_size_t sdu_lenP, - const eNB_flag_t eNB_flagP, - const mac_enb_index_t eNB_indexP, - const uint8_t mbsfn_sync_area -) -//------------------------------------------------------------------------------ -{ - return(mac_rrc_lite_data_ind( - module_idP, - CC_idP, - frameP,subframeP, - rntiP, - srb_idP, - sduP, - sdu_lenP, - eNB_flagP, - eNB_indexP, - mbsfn_sync_area) - ); -}*/ - -//------------------------------------------------------------------------------ -void -rlcrrc_data_ind( - const protocol_ctxt_t* const ctxt_pP, - const rb_id_t srb_idP, - const sdu_size_t sdu_lenP, - const uint8_t * const buffer_pP -) -//------------------------------------------------------------------------------ -{ - rrc_data_ind(ctxt_pP, - srb_idP, - sdu_lenP, - buffer_pP); -} - -//------------------------------------------------------------------------------ -uint8_t -pdcp_rrc_data_req( - const protocol_ctxt_t* const ctxt_pP, - const rb_id_t rb_idP, - const mui_t muiP, - const confirm_t confirmP, - const sdu_size_t sdu_buffer_sizeP, - uint8_t* const sdu_buffer_pP, - const pdcp_transmission_mode_t modeP -) -//------------------------------------------------------------------------------ -{ - return rrc_lite_data_req ( - ctxt_pP, - rb_idP, - muiP, - confirmP, - sdu_buffer_sizeP, - sdu_buffer_pP, - modeP); -} - -//------------------------------------------------------------------------------ -void -pdcp_rrc_data_ind( - const protocol_ctxt_t* const ctxt_pP, - const rb_id_t srb_idP, - const sdu_size_t sdu_sizeP, - uint8_t * const buffer_pP -) -//------------------------------------------------------------------------------ -{ - rrc_lite_data_ind( - ctxt_pP, - srb_idP, - sdu_sizeP, - buffer_pP); -} - -//------------------------------------------------------------------------------ -void -mac_rrc_meas_ind( - const module_id_t module_idP, - MAC_MEAS_REQ_ENTRY * const Meas_entry_pP -) -//------------------------------------------------------------------------------ -{ - // mac_rrc_meas_ind(module_idP,Meas_entry_pP); -} - -//------------------------------------------------------------------------------ -void -mac_sync_ind( - const module_id_t module_idP, - const uint8_t Status -) -//------------------------------------------------------------------------------ -{ - mac_lite_sync_ind(module_idP,Status); -} - -//------------------------------------------------------------------------------ -void -mac_in_sync_ind( - const module_id_t module_idP, - const frame_t frameP, - const uint16_t eNB_indexP -) -//------------------------------------------------------------------------------ -{ - rrc_lite_in_sync_ind(module_idP,frameP,eNB_indexP); -} - -//------------------------------------------------------------------------------ -void -mac_out_of_sync_ind( - const module_id_t module_idP, - const frame_t frameP, - const uint16_t eNB_indexP -) -//------------------------------------------------------------------------------ -{ - rrc_lite_out_of_sync_ind(module_idP,frameP,eNB_indexP); -} - -//------------------------------------------------------------------------------ -int -mac_eNB_get_rrc_status( - const module_id_t module_idP, - const rnti_t rntiP -) -//------------------------------------------------------------------------------ -{ - return mac_eNB_get_rrc_lite_status(module_idP, rntiP); -} -//------------------------------------------------------------------------------ -int -mac_UE_get_rrc_status( - const module_id_t module_idP, - const uint8_t sig_indexP -) -//------------------------------------------------------------------------------ -{ - return mac_UE_get_rrc_lite_status(module_idP, sig_indexP); -} - -//------------------------------------------------------------------------------ -char -openair_rrc_ue_init( - const module_id_t module_idP, - const unsigned char eNB_indexP -) -//------------------------------------------------------------------------------ -{ - return openair_rrc_lite_ue_init(module_idP, eNB_indexP); -} - -//------------------------------------------------------------------------------ -char -openair_rrc_eNB_init( - const module_id_t module_idP -) -//------------------------------------------------------------------------------ -{ - return openair_rrc_lite_eNB_init(module_idP); -} diff --git a/openair2/RRC/LTE/L2_interface.c b/openair2/RRC/LTE/L2_interface.c index 0b767b8ad6efa203c3317cb8c876a35bb7adf803..37595192281a06d39cd55d7839b6c73f7e0b8aab 100644 --- a/openair2/RRC/LTE/L2_interface.c +++ b/openair2/RRC/LTE/L2_interface.c @@ -317,6 +317,12 @@ mac_rrc_data_ind( sdu_lenP, NULL, 0); + struct rrc_eNB_ue_context_s *ue_context_p = rrc_eNB_allocate_new_UE_context(RC.rrc[module_idP]); + ue_context_p->ue_id_rnti = rntiP; + ue_context_p->ue_context.rnti = rntiP; + ue_context_p->ue_context.random_ue_identity = rntiP; + ue_context_p->ue_context.Srb0.Active = 1; + RB_INSERT(rrc_ue_tree_s, &RC.rrc[module_idP]->rrc_ue_head, ue_context_p); return(0); } diff --git a/openair2/RRC/LTE/MESSAGES/asn1_msg.c b/openair2/RRC/LTE/MESSAGES/asn1_msg.c index ce26aeef871a192f171d994e7449fdad95b63a72..b06959131618470ba8ce0c7cc9d82c64c23dbbd7 100644 --- a/openair2/RRC/LTE/MESSAGES/asn1_msg.c +++ b/openair2/RRC/LTE/MESSAGES/asn1_msg.c @@ -2129,7 +2129,7 @@ uint8_t do_SIB23(uint8_t Mod_id, return((enc_rval.encoded+7)/8); } -uint8_t do_RRCConnectionRequest(uint8_t Mod_id, uint8_t *buffer,uint8_t *rv) { +uint8_t do_RRCConnectionRequest(uint8_t Mod_id, uint8_t *buffer, size_t buffer_size, uint8_t *rv) { asn_enc_rval_t enc_rval; uint8_t buf[5],buf2=0; LTE_UL_CCCH_Message_t ul_ccch_msg; @@ -2178,7 +2178,7 @@ uint8_t do_RRCConnectionRequest(uint8_t Mod_id, uint8_t *buffer,uint8_t *rv) { NULL, (void *)&ul_ccch_msg, buffer, - 100); + buffer_size); AssertFatal (enc_rval.encoded > 0, "ASN1 message encoding failed (%s, %lu)!\n", enc_rval.failed_type->name, enc_rval.encoded); LOG_D(RRC,"[UE] RRCConnectionRequest Encoded %zd bits (%zd bytes)\n", enc_rval.encoded, (enc_rval.encoded+7)/8); return((enc_rval.encoded+7)/8); @@ -2378,12 +2378,39 @@ uint8_t do_RRCConnectionSetupComplete(uint8_t Mod_id, uint8_t *buffer, const uin return((enc_rval.encoded+7)/8); } +static void assign_scg_ConfigResponseNR_r15(LTE_RRCConnectionReconfigurationComplete_t *rrc, OCTET_STRING_t *str) +{ + LTE_RRCConnectionReconfigurationComplete_r8_IEs_t *rrc_r8 = &rrc->criticalExtensions.choice. + rrcConnectionReconfigurationComplete_r8; + typeof(rrc_r8->nonCriticalExtension) nce1; + rrc_r8->nonCriticalExtension = nce1 = CALLOC(1, sizeof(*nce1)); + + typeof(nce1->nonCriticalExtension) nce2; + nce1->nonCriticalExtension = nce2 = CALLOC(1, sizeof(*nce2)); + + typeof(nce2->nonCriticalExtension) nce3; + nce2->nonCriticalExtension = nce3 = CALLOC(1, sizeof(*nce3)); + + typeof(nce3->nonCriticalExtension) nce4; + nce3->nonCriticalExtension = nce4 = CALLOC(1, sizeof(*nce4)); + + typeof(nce4->nonCriticalExtension) nce5; + nce4->nonCriticalExtension = nce5 = CALLOC(1, sizeof(*nce5)); + + typeof(nce5->nonCriticalExtension) nce6; + nce5->nonCriticalExtension = nce6 = CALLOC(1, sizeof(*nce6)); + + nce6->scg_ConfigResponseNR_r15 = str; +} + //------------------------------------------------------------------------------ -uint8_t +size_t do_RRCConnectionReconfigurationComplete( const protocol_ctxt_t *const ctxt_pP, uint8_t *buffer, - const uint8_t Transaction_id + size_t buffer_size, + const uint8_t Transaction_id, + OCTET_STRING_t *str ) //------------------------------------------------------------------------------ { @@ -2397,7 +2424,13 @@ do_RRCConnectionReconfigurationComplete( rrcConnectionReconfigurationComplete->rrc_TransactionIdentifier = Transaction_id; rrcConnectionReconfigurationComplete->criticalExtensions.present = LTE_RRCConnectionReconfigurationComplete__criticalExtensions_PR_rrcConnectionReconfigurationComplete_r8; - rrcConnectionReconfigurationComplete->criticalExtensions.choice.rrcConnectionReconfigurationComplete_r8.nonCriticalExtension=NULL; + if (str != NULL) { + assign_scg_ConfigResponseNR_r15(rrcConnectionReconfigurationComplete, str); + LOG_D(RRC, "Successfully assigned scg_ConfigResponseNR_r15\n"); + } + else { + rrcConnectionReconfigurationComplete->criticalExtensions.choice.rrcConnectionReconfigurationComplete_r8.nonCriticalExtension=NULL; + } if ( LOG_DEBUGFLAG(DEBUG_ASN1) ) { xer_fprint(stdout, &asn_DEF_LTE_UL_DCCH_Message, (void *)&ul_dcch_msg); @@ -2407,7 +2440,7 @@ do_RRCConnectionReconfigurationComplete( NULL, (void *)&ul_dcch_msg, buffer, - 100); + buffer_size); AssertFatal (enc_rval.encoded > 0, "ASN1 message encoding failed (%s, %lu)!\n", enc_rval.failed_type->name, enc_rval.encoded); LOG_D(RRC,"RRCConnectionReconfigurationComplete Encoded %zd bits (%zd bytes)\n",enc_rval.encoded,(enc_rval.encoded+7)/8); @@ -3142,6 +3175,7 @@ uint8_t do_RRCConnectionSetup_BR( uint8_t do_SecurityModeCommand( const protocol_ctxt_t *const ctxt_pP, uint8_t *const buffer, + size_t buffer_size, const uint8_t Transaction_id, const uint8_t cipheringAlgorithm, const uint8_t integrityProtAlgorithm @@ -3171,7 +3205,7 @@ uint8_t do_SecurityModeCommand( NULL, (void *)&dl_dcch_msg, buffer, - 100); + buffer_size); if(enc_rval.encoded == -1) { LOG_I(RRC, "[eNB AssertFatal]ASN1 message encoding failed (%s, %lu)!\n", @@ -3200,6 +3234,7 @@ uint8_t do_SecurityModeCommand( //------------------------------------------------------------------------------ uint8_t do_UECapabilityEnquiry( const protocol_ctxt_t *const ctxt_pP, uint8_t *const buffer, + size_t buffer_size, const uint8_t Transaction_id, int16_t eutra_band, uint32_t nr_band) @@ -3220,58 +3255,56 @@ uint8_t do_UECapabilityEnquiry( const protocol_ctxt_t *const ctxt_pP, dl_dcch_msg.message.choice.c1.choice.ueCapabilityEnquiry.criticalExtensions.choice.c1.choice.ueCapabilityEnquiry_r8.ue_CapabilityRequest.list.count=0; ASN_SEQUENCE_ADD(&dl_dcch_msg.message.choice.c1.choice.ueCapabilityEnquiry.criticalExtensions.choice.c1.choice.ueCapabilityEnquiry_r8.ue_CapabilityRequest.list, &rat); + + /* request NR configuration */ LTE_UECapabilityEnquiry_r8_IEs_t *r8 = &dl_dcch_msg.message.choice.c1.choice.ueCapabilityEnquiry.criticalExtensions.choice.c1.choice.ueCapabilityEnquiry_r8; LTE_UECapabilityEnquiry_v8a0_IEs_t r8_a0; LTE_UECapabilityEnquiry_v1180_IEs_t r11_80; LTE_UECapabilityEnquiry_v1310_IEs_t r13_10; LTE_UECapabilityEnquiry_v1430_IEs_t r14_30; LTE_UECapabilityEnquiry_v1510_IEs_t r15_10; - OCTET_STRING_t req_freq; - - if (nr_band>0) { - - /* request NR configuration */ - memset(&r8_a0, 0, sizeof(r8_a0)); - memset(&r11_80, 0, sizeof(r11_80)); - memset(&r13_10, 0, sizeof(r13_10)); - memset(&r14_30, 0, sizeof(r14_30)); - memset(&r15_10, 0, sizeof(r15_10)); + memset(&r8_a0, 0, sizeof(r8_a0)); + memset(&r11_80, 0, sizeof(r11_80)); + memset(&r13_10, 0, sizeof(r13_10)); + memset(&r14_30, 0, sizeof(r14_30)); + memset(&r15_10, 0, sizeof(r15_10)); - r8->nonCriticalExtension = &r8_a0; - r8_a0.nonCriticalExtension = &r11_80; - r11_80.nonCriticalExtension = &r13_10; - r13_10.nonCriticalExtension = &r14_30; - r14_30.nonCriticalExtension = &r15_10; + r8->nonCriticalExtension = &r8_a0; + r8_a0.nonCriticalExtension = &r11_80; + r11_80.nonCriticalExtension = &r13_10; + r13_10.nonCriticalExtension = &r14_30; + r14_30.nonCriticalExtension = &r15_10; - /* TODO: no hardcoded values here */ + /* TODO: no hardcoded values here */ - nsa_band_list = (NR_FreqBandList_t *)calloc(1, sizeof(NR_FreqBandList_t)); + nsa_band_list = (NR_FreqBandList_t *)calloc(1, sizeof(NR_FreqBandList_t)); - nsa_band = (NR_FreqBandInformation_t *) calloc(1,sizeof(NR_FreqBandInformation_t)); - nsa_band->present = NR_FreqBandInformation_PR_bandInformationEUTRA; - nsa_band->choice.bandInformationEUTRA = (NR_FreqBandInformationEUTRA_t *) calloc(1, sizeof(NR_FreqBandInformationEUTRA_t)); - nsa_band->choice.bandInformationEUTRA->bandEUTRA = eutra_band; - ASN_SEQUENCE_ADD(&nsa_band_list->list, nsa_band); + nsa_band = (NR_FreqBandInformation_t *) calloc(1,sizeof(NR_FreqBandInformation_t)); + nsa_band->present = NR_FreqBandInformation_PR_bandInformationEUTRA; + nsa_band->choice.bandInformationEUTRA = (NR_FreqBandInformationEUTRA_t *) calloc(1, sizeof(NR_FreqBandInformationEUTRA_t)); + nsa_band->choice.bandInformationEUTRA->bandEUTRA = eutra_band; + ASN_SEQUENCE_ADD(&nsa_band_list->list, nsa_band); - nsa_band = (NR_FreqBandInformation_t *) calloc(1,sizeof(NR_FreqBandInformation_t)); - nsa_band->present = NR_FreqBandInformation_PR_bandInformationNR; - nsa_band->choice.bandInformationNR = (NR_FreqBandInformationNR_t *) calloc(1, sizeof(NR_FreqBandInformationNR_t)); - //if(nr_band > 0) + nsa_band = (NR_FreqBandInformation_t *) calloc(1,sizeof(NR_FreqBandInformation_t)); + nsa_band->present = NR_FreqBandInformation_PR_bandInformationNR; + nsa_band->choice.bandInformationNR = (NR_FreqBandInformationNR_t *) calloc(1, sizeof(NR_FreqBandInformationNR_t)); + if(nr_band > 0) nsa_band->choice.bandInformationNR->bandNR = nr_band; - //else - // nsa_band->choice.bandInformationNR->bandNR = 78; - ASN_SEQUENCE_ADD(&nsa_band_list->list, nsa_band); + else + nsa_band->choice.bandInformationNR->bandNR = 78; + ASN_SEQUENCE_ADD(&nsa_band_list->list, nsa_band); + OCTET_STRING_t req_freq; //unsigned char req_freq_buf[5] = { 0x00, 0x20, 0x1a, 0x02, 0x68 }; // bands 7 & nr78 - unsigned char req_freq_buf[1024]; - enc_rval = uper_encode_to_buffer(&asn_DEF_NR_FreqBandList, - NULL, - (void *)nsa_band_list, - req_freq_buf, - 1024); + unsigned char req_freq_buf[1024]; + enc_rval = uper_encode_to_buffer(&asn_DEF_NR_FreqBandList, + NULL, + (void *)nsa_band_list, + req_freq_buf, + 1024); - xer_fprint(stdout, &asn_DEF_NR_FreqBandList, (void *)nsa_band_list); + xer_fprint(stdout, &asn_DEF_NR_FreqBandList, (void *)nsa_band_list); @@ -3282,22 +3315,20 @@ uint8_t do_UECapabilityEnquiry( const protocol_ctxt_t *const ctxt_pP, //0x01, 0x60, 0x18, 0x05, 0x80, 0xc0, 0x04, 0x04, 0xc1, 0x2c, 0x10, 0x08, 0x20, 0x30, 0x40, 0xe0, 0x82, 0x40, 0x28, 0x80, 0x9a // }; - req_freq.buf = req_freq_buf; - req_freq.size = (enc_rval.encoded+7)/8; + req_freq.buf = req_freq_buf; + req_freq.size = (enc_rval.encoded+7)/8; // req_freq.size = 21; - r15_10.requestedFreqBandsNR_MRDC_r15 = &req_freq; - // Add request for eutra-nr - } -// if ( LOG_DEBUGFLAG(DEBUG_ASN1) ) { + r15_10.requestedFreqBandsNR_MRDC_r15 = &req_freq; + if ( LOG_DEBUGFLAG(DEBUG_ASN1) ) { xer_fprint(stdout, &asn_DEF_LTE_DL_DCCH_Message, (void *)&dl_dcch_msg); -// } + } enc_rval = uper_encode_to_buffer(&asn_DEF_LTE_DL_DCCH_Message, NULL, (void *)&dl_dcch_msg, buffer, - 100); + buffer_size); if(enc_rval.encoded == -1) { LOG_I(RRC, "[eNB AssertFatal]ASN1 message encoding failed (%s, %lu)!\n", @@ -3324,6 +3355,7 @@ uint8_t do_UECapabilityEnquiry( const protocol_ctxt_t *const ctxt_pP, //------------------------------------------------------------------------------ uint8_t do_NR_UECapabilityEnquiry( const protocol_ctxt_t *const ctxt_pP, uint8_t *const buffer, + size_t buffer_size, const uint8_t Transaction_id, int16_t eutra_band, uint32_t nr_band) @@ -3417,7 +3449,7 @@ uint8_t do_NR_UECapabilityEnquiry( const protocol_ctxt_t *const ctxt_pP, NULL, (void *)&dl_dcch_msg, buffer, - 100); + buffer_size); if(enc_rval.encoded == -1) { LOG_I(RRC, "[eNB AssertFatal]ASN1 message encoding failed (%s, %lu)!\n", @@ -3444,6 +3476,7 @@ uint8_t do_NR_UECapabilityEnquiry( const protocol_ctxt_t *const ctxt_pP, uint16_t do_RRCConnectionReconfiguration_BR(const protocol_ctxt_t *const ctxt_pP, uint8_t *buffer, + size_t buffer_size, uint8_t Transaction_id, LTE_SRB_ToAddModList_t *SRB_list, LTE_DRB_ToAddModList_t *DRB_list, @@ -3545,7 +3578,7 @@ uint16_t do_RRCConnectionReconfiguration_BR(const protocol_ctxt_t *const NULL, (void *)&dl_dcch_msg, buffer, - RRC_BUF_SIZE); + buffer_size); AssertFatal (enc_rval.encoded > 0, "ASN1 message encoding failed %s, %lu!\n", enc_rval.failed_type->name, enc_rval.encoded); if ( LOG_DEBUGFLAG(DEBUG_ASN1) ) { @@ -3562,6 +3595,7 @@ uint16_t do_RRCConnectionReconfiguration_BR(const protocol_ctxt_t *const */ uint16_t do_RRCConnectionReconfiguration(const protocol_ctxt_t *const ctxt_pP, uint8_t *buffer, + size_t buffer_size, uint8_t Transaction_id, LTE_SRB_ToAddModList_t *SRB_list, LTE_DRB_ToAddModList_t *DRB_list, @@ -3722,7 +3756,7 @@ uint16_t do_RRCConnectionReconfiguration(const protocol_ctxt_t *const ctxt_pP, NULL, (void *)&dl_dcch_msg, buffer, - RRC_BUF_SIZE); + buffer_size); if(enc_rval.encoded == -1) { LOG_I(RRC, "[eNB AssertFatal]ASN1 message encoding failed (%s, %lu)!\n", @@ -3977,6 +4011,7 @@ uint8_t do_RRCConnectionReject(uint8_t Mod_id, uint8_t do_RRCConnectionRelease(uint8_t Mod_id, uint8_t *buffer, + size_t buffer_size, uint8_t Transaction_id) { asn_enc_rval_t enc_rval; LTE_DL_DCCH_Message_t dl_dcch_msg; @@ -3998,7 +4033,7 @@ uint8_t do_RRCConnectionRelease(uint8_t Mod_id, NULL, (void *)&dl_dcch_msg, buffer, - RRC_BUF_SIZE); + buffer_size); return((enc_rval.encoded+7)/8); } @@ -4008,6 +4043,7 @@ uint8_t TMGI[5] = {4,3,2,1,0};//TMGI is a string of octet, ref. TS 24.008 fig. 1 uint8_t do_MBSFNAreaConfig(uint8_t Mod_id, uint8_t sync_area, uint8_t *buffer, + size_t buffer_size, LTE_MCCH_Message_t *mcch_message, LTE_MBSFNAreaConfiguration_r9_t **mbsfnAreaConfiguration) { asn_enc_rval_t enc_rval; @@ -4114,7 +4150,7 @@ uint8_t do_MBSFNAreaConfig(uint8_t Mod_id, NULL, (void *)mcch_message, buffer, - 100); + buffer_size); if(enc_rval.encoded == -1) { LOG_I(RRC, "[eNB AssertFatal]ASN1 message encoding failed (%s, %lu)!\n", @@ -4133,7 +4169,9 @@ uint8_t do_MBSFNAreaConfig(uint8_t Mod_id, } -uint8_t do_MeasurementReport(uint8_t Mod_id, uint8_t *buffer,int measid,int phy_id,long rsrp_s,long rsrq_s,long rsrp_t,long rsrq_t) { +uint8_t do_MeasurementReport(uint8_t Mod_id, uint8_t *buffer, size_t buffer_size, + int measid, int phy_id, long rsrp_s, long rsrq_s, + long rsrp_t, long rsrq_t) { asn_enc_rval_t enc_rval; LTE_UL_DCCH_Message_t ul_dcch_msg; LTE_MeasurementReport_t *measurementReport; @@ -4205,7 +4243,7 @@ uint8_t do_MeasurementReport(uint8_t Mod_id, uint8_t *buffer,int measid,int phy_ NULL, (void *)&ul_dcch_msg, buffer, - 100); + buffer_size); if(enc_rval.encoded == -1) { LOG_I(RRC, "[eNB AssertFatal]ASN1 message encoding failed (%s, %lu)!\n", @@ -4220,6 +4258,64 @@ uint8_t do_MeasurementReport(uint8_t Mod_id, uint8_t *buffer,int measid,int phy_ return((enc_rval.encoded+7)/8); } +#define asn1cCallocOne(VaR, VaLue) \ + VaR = calloc(1,sizeof(*VaR)); *VaR=VaLue; +#define asn1cCalloc(VaR, lOcPtr) \ + typeof(VaR) lOcPtr = VaR = calloc(1,sizeof(*VaR)); +#define asn1cSequenceAdd(VaR, TyPe, lOcPtr) \ + TyPe *lOcPtr= calloc(1,sizeof(TyPe)); \ + ASN_SEQUENCE_ADD(&VaR,lOcPtr); + +ssize_t do_nrMeasurementReport(uint8_t *buffer, + size_t bufsize, + LTE_MeasId_t measid, + LTE_PhysCellIdNR_r15_t phy_id, + long rsrp_s, + long rsrq_s, + long rsrp_tar, + long rsrq_tar) { + + LTE_UL_DCCH_Message_t ul_dcch_msg={0}; + ul_dcch_msg.message.present = LTE_UL_DCCH_MessageType_PR_c1; + ul_dcch_msg.message.choice.c1.present = LTE_UL_DCCH_MessageType__c1_PR_measurementReport; + + LTE_MeasurementReport_t *measurementReport = &ul_dcch_msg.message.choice.c1.choice.measurementReport; + measurementReport->criticalExtensions.present = LTE_MeasurementReport__criticalExtensions_PR_c1; + measurementReport->criticalExtensions.choice.c1.present = LTE_MeasurementReport__criticalExtensions__c1_PR_measurementReport_r8; + measurementReport->criticalExtensions.choice.c1.choice.measurementReport_r8.nonCriticalExtension = + calloc(1, sizeof(*measurementReport->criticalExtensions.choice.c1.choice.measurementReport_r8.nonCriticalExtension)); + measurementReport->criticalExtensions.choice.c1.choice.measurementReport_r8.measResults.measId = measid; + measurementReport->criticalExtensions.choice.c1.choice.measurementReport_r8.measResults.measResultPCell.rsrpResult = rsrp_s; + measurementReport->criticalExtensions.choice.c1.choice.measurementReport_r8.measResults.measResultPCell.rsrqResult = rsrq_s; + asn1cCalloc(measurementReport->criticalExtensions.choice.c1.choice.measurementReport_r8.measResults.measResultNeighCells, + measResultNeighCells); + measResultNeighCells->present = LTE_MeasResults__measResultNeighCells_PR_measResultNeighCellListNR_r15; + LTE_MeasResultListEUTRA_t *measResultListEUTRA2=&measResultNeighCells->choice.measResultListEUTRA; + asn1cSequenceAdd(measResultListEUTRA2->list, struct LTE_MeasResultEUTRA, measresulteutra_list); + measresulteutra_list->physCellId = phy_id; + //asn1cCalloc(measresulteutra_list->cgi_Info, measresult_cgi2); + //measresult_cgi2->cellGlobalId= {0}; + //measresult_cgi2->trackingAreaCode= {0}; + struct LTE_MeasResultEUTRA__measResult* measResult= &measresulteutra_list->measResult; + asn1cCallocOne(measResult->rsrpResult, rsrp_tar); + asn1cCallocOne(measResult->rsrqResult, rsrq_tar); + + + asn_enc_rval_t enc_rval = uper_encode_to_buffer(&asn_DEF_LTE_UL_DCCH_Message, + NULL, + &ul_dcch_msg, + buffer, + bufsize); + if(enc_rval.encoded == -1) { + LOG_I(RRC, "[eNB AssertFatal] ASN1 message encoding failed (%s, %lu)!\n", + enc_rval.failed_type->name, enc_rval.encoded); + SEQUENCE_free(&asn_DEF_LTE_UL_DCCH_Message, &ul_dcch_msg, ASFM_FREE_UNDERLYING_AND_RESET); + return -1; + } + + return((enc_rval.encoded+7)/8); +} + uint8_t do_DLInformationTransfer(uint8_t Mod_id, uint8_t **buffer, uint8_t transaction_id, uint32_t pdu_length, uint8_t *pdu_buffer) { ssize_t encoded; LTE_DL_DCCH_Message_t dl_dcch_msg; @@ -4237,7 +4333,8 @@ uint8_t do_DLInformationTransfer(uint8_t Mod_id, uint8_t **buffer, uint8_t trans return encoded; } -uint8_t do_Paging(uint8_t Mod_id, uint8_t *buffer, ue_paging_identity_t ue_paging_identity, cn_domain_t cn_domain) { +uint8_t do_Paging(uint8_t Mod_id, uint8_t *buffer, size_t buffer_size, + ue_paging_identity_t ue_paging_identity, cn_domain_t cn_domain) { LOG_D(RRC, "[eNB %d] do_Paging start\n", Mod_id); asn_enc_rval_t enc_rval; LTE_PCCH_Message_t pcch_msg; @@ -4289,7 +4386,8 @@ uint8_t do_Paging(uint8_t Mod_id, uint8_t *buffer, ue_paging_identity_t ue_pagin ASN_SEQUENCE_ADD(&pcch_msg.message.choice.c1.choice.paging.pagingRecordList->list, paging_record_p); LOG_D(RRC, "[eNB %d] do_Paging paging_record: cn_Domain %ld, ue_paging_identity.presenceMask %d, PagingRecordList.count %d\n", Mod_id, paging_record_p->cn_Domain, ue_paging_identity.presenceMask, pcch_msg.message.choice.c1.choice.paging.pagingRecordList->list.count); - enc_rval = uper_encode_to_buffer(&asn_DEF_LTE_PCCH_Message, NULL, (void *)&pcch_msg, buffer, RRC_BUF_SIZE); + enc_rval = uper_encode_to_buffer(&asn_DEF_LTE_PCCH_Message, NULL, (void *)&pcch_msg, + buffer, buffer_size); if(enc_rval.encoded == -1) { LOG_I(RRC, "[eNB AssertFatal]ASN1 message encoding failed (%s, %lu)!\n", @@ -4378,7 +4476,161 @@ int do_HandoverCommand(char *ho_buf, int ho_size, char *rrc_buf, int rrc_size) { return((enc_rval.encoded+7)/8); } -OAI_UECapability_t *fill_ue_capability(char *UE_EUTRA_Capability_xer_fname) { +//----------------------------------------------------------------------------- +int +is_en_dc_supported( + LTE_UE_EUTRA_Capability_t *c +) +//----------------------------------------------------------------------------- +{ + LOG_D(RRC, "Entered %s \n", __FUNCTION__); + /* to be refined - check that the bands supported by the UE include + * the band of the gNB + */ +#define NCE nonCriticalExtension + return c != NULL + && c->NCE != NULL + && c->NCE->NCE != NULL + && c->NCE->NCE->NCE != NULL + && c->NCE->NCE->NCE->NCE != NULL + && c->NCE->NCE->NCE->NCE->NCE != NULL + && c->NCE->NCE->NCE->NCE->NCE->NCE != NULL + && c->NCE->NCE->NCE->NCE->NCE->NCE->NCE != NULL + && c->NCE->NCE->NCE->NCE->NCE->NCE->NCE->NCE != NULL + && c->NCE->NCE->NCE->NCE->NCE->NCE->NCE->NCE->NCE != NULL + && c->NCE->NCE->NCE->NCE->NCE->NCE->NCE->NCE->NCE->NCE != NULL + && c->NCE->NCE->NCE->NCE->NCE->NCE->NCE->NCE->NCE->NCE->NCE != NULL + && c->NCE->NCE->NCE->NCE->NCE->NCE->NCE->NCE->NCE->NCE->NCE->NCE != NULL + && c->NCE->NCE->NCE->NCE->NCE->NCE->NCE->NCE->NCE->NCE->NCE->NCE->NCE != NULL + && c->NCE->NCE->NCE->NCE->NCE->NCE->NCE->NCE->NCE->NCE->NCE->NCE->NCE->NCE != NULL + && c->NCE->NCE->NCE->NCE->NCE->NCE->NCE->NCE->NCE->NCE->NCE->NCE->NCE->NCE->NCE != NULL + && c->NCE->NCE->NCE->NCE->NCE->NCE->NCE->NCE->NCE->NCE->NCE->NCE->NCE->NCE->NCE->NCE != NULL + && c->NCE->NCE->NCE->NCE->NCE->NCE->NCE->NCE->NCE->NCE->NCE->NCE->NCE->NCE->NCE->NCE->NCE != NULL + && c->NCE->NCE->NCE->NCE->NCE->NCE->NCE->NCE->NCE->NCE->NCE->NCE->NCE->NCE->NCE->NCE->NCE->NCE != NULL + && c->NCE->NCE->NCE->NCE->NCE->NCE->NCE->NCE->NCE->NCE->NCE->NCE->NCE->NCE->NCE->NCE->NCE->NCE->NCE != NULL + && c->NCE->NCE->NCE->NCE->NCE->NCE->NCE->NCE->NCE->NCE->NCE->NCE->NCE->NCE->NCE->NCE->NCE->NCE->NCE->NCE != NULL + && c->NCE->NCE->NCE->NCE->NCE->NCE->NCE->NCE->NCE->NCE->NCE->NCE->NCE->NCE->NCE->NCE->NCE->NCE->NCE->NCE->NCE != NULL + && c->NCE->NCE->NCE->NCE->NCE->NCE->NCE->NCE->NCE->NCE->NCE->NCE->NCE->NCE->NCE->NCE->NCE->NCE->NCE->NCE->NCE->NCE != NULL + && c->NCE->NCE->NCE->NCE->NCE->NCE->NCE->NCE->NCE->NCE->NCE->NCE->NCE->NCE->NCE->NCE->NCE->NCE->NCE->NCE->NCE->NCE->NCE != NULL + && c->NCE->NCE->NCE->NCE->NCE->NCE->NCE->NCE->NCE->NCE->NCE->NCE->NCE->NCE->NCE->NCE->NCE->NCE->NCE->NCE->NCE->NCE->NCE->NCE != NULL + && c->NCE->NCE->NCE->NCE->NCE->NCE->NCE->NCE->NCE->NCE->NCE->NCE->NCE->NCE->NCE->NCE->NCE->NCE->NCE->NCE->NCE->NCE->NCE->NCE->irat_ParametersNR_r15 != NULL + && c->NCE->NCE->NCE->NCE->NCE->NCE->NCE->NCE->NCE->NCE->NCE->NCE->NCE->NCE->NCE->NCE->NCE->NCE->NCE->NCE->NCE->NCE->NCE->NCE->irat_ParametersNR_r15->en_DC_r15 != NULL + && *c->NCE->NCE->NCE->NCE->NCE->NCE->NCE->NCE->NCE->NCE->NCE->NCE->NCE->NCE->NCE->NCE->NCE->NCE->NCE->NCE->NCE->NCE->NCE->NCE->irat_ParametersNR_r15->en_DC_r15 == + LTE_IRAT_ParametersNR_r15__en_DC_r15_supported; +#undef NCE +} + +void allocate_en_DC_r15(LTE_UE_EUTRA_Capability_t *cap) +{ + LOG_D(RRC, "Entered %s\n", __FUNCTION__); + if (!cap->nonCriticalExtension) + cap->nonCriticalExtension = CALLOC(1, sizeof(*cap->nonCriticalExtension)); + + typeof(cap->nonCriticalExtension) nce1 = cap->nonCriticalExtension; + if (!nce1->nonCriticalExtension) + nce1->nonCriticalExtension = CALLOC(1, sizeof(*nce1->nonCriticalExtension)); + + typeof(nce1->nonCriticalExtension) nce2 = nce1->nonCriticalExtension; + if (!nce2->nonCriticalExtension) + nce2->nonCriticalExtension = CALLOC(1, sizeof(*nce2->nonCriticalExtension)); + + typeof(nce2->nonCriticalExtension) nce3 = nce2->nonCriticalExtension; + if (!nce3->nonCriticalExtension) + nce3->nonCriticalExtension = CALLOC(1, sizeof(*nce3->nonCriticalExtension)); + + typeof(nce3->nonCriticalExtension) nce4 = nce3->nonCriticalExtension; + if (!nce4->nonCriticalExtension) + nce4->nonCriticalExtension = CALLOC(1, sizeof(*nce4->nonCriticalExtension)); + + typeof(nce4->nonCriticalExtension) nce5 = nce4->nonCriticalExtension; + if (!nce5->nonCriticalExtension) + nce5->nonCriticalExtension = CALLOC(1, sizeof(*nce5->nonCriticalExtension)); + + typeof(nce5->nonCriticalExtension) nce6 = nce5->nonCriticalExtension; + if (!nce6->nonCriticalExtension) + nce6->nonCriticalExtension = CALLOC(1, sizeof(*nce6->nonCriticalExtension)); + + typeof(nce6->nonCriticalExtension) nce7 = nce6->nonCriticalExtension; + if (!nce7->nonCriticalExtension) + nce7->nonCriticalExtension = CALLOC(1, sizeof(*nce7->nonCriticalExtension)); + + typeof(nce7->nonCriticalExtension) nce8 = nce7->nonCriticalExtension; + if (!nce8->nonCriticalExtension) + nce8->nonCriticalExtension = CALLOC(1, sizeof(*nce8->nonCriticalExtension)); + + typeof(nce8->nonCriticalExtension) nce9 = nce8->nonCriticalExtension; + if (!nce9->nonCriticalExtension) + nce9->nonCriticalExtension = CALLOC(1, sizeof(*nce9->nonCriticalExtension)); + + typeof(nce9->nonCriticalExtension) nce10 = nce9->nonCriticalExtension; + if (!nce10->nonCriticalExtension) + nce10->nonCriticalExtension = CALLOC(1, sizeof(*nce10->nonCriticalExtension)); + + typeof(nce10->nonCriticalExtension) nce11 = nce10->nonCriticalExtension; + if (!nce11->nonCriticalExtension) + nce11->nonCriticalExtension = CALLOC(1, sizeof(*nce11->nonCriticalExtension)); + + typeof(nce11->nonCriticalExtension) nce12 = nce11->nonCriticalExtension; + if (!nce12->nonCriticalExtension) + nce12->nonCriticalExtension = CALLOC(1, sizeof(*nce12->nonCriticalExtension)); + + typeof(nce12->nonCriticalExtension) nce13 = nce12->nonCriticalExtension; + if (!nce13->nonCriticalExtension) + nce13->nonCriticalExtension = CALLOC(1, sizeof(*nce13->nonCriticalExtension)); + + typeof(nce13->nonCriticalExtension) nce14 = nce13->nonCriticalExtension; + if (!nce14->nonCriticalExtension) + nce14->nonCriticalExtension = CALLOC(1, sizeof(*nce14->nonCriticalExtension)); + + typeof(nce14->nonCriticalExtension) nce15 = nce14->nonCriticalExtension; + if (!nce15->nonCriticalExtension) + nce15->nonCriticalExtension = CALLOC(1, sizeof(*nce15->nonCriticalExtension)); + + typeof(nce15->nonCriticalExtension) nce16 = nce15->nonCriticalExtension; + if (!nce16->nonCriticalExtension) + nce16->nonCriticalExtension = CALLOC(1, sizeof(*nce16->nonCriticalExtension)); + + typeof(nce16->nonCriticalExtension) nce17 = nce16->nonCriticalExtension; + if (!nce17->nonCriticalExtension) + nce17->nonCriticalExtension = CALLOC(1, sizeof(*nce17->nonCriticalExtension)); + + typeof(nce17->nonCriticalExtension) nce18 = nce17->nonCriticalExtension; + if (!nce18->nonCriticalExtension) + nce18->nonCriticalExtension = CALLOC(1, sizeof(*nce18->nonCriticalExtension)); + + typeof(nce18->nonCriticalExtension) nce19 = nce18->nonCriticalExtension; + if (!nce19->nonCriticalExtension) + nce19->nonCriticalExtension = CALLOC(1, sizeof(*nce19->nonCriticalExtension)); + + typeof(nce19->nonCriticalExtension) nce20 = nce19->nonCriticalExtension; + if (!nce20->nonCriticalExtension) + nce20->nonCriticalExtension = CALLOC(1, sizeof(*nce20->nonCriticalExtension)); + + typeof(nce20->nonCriticalExtension) nce21 = nce20->nonCriticalExtension; + if (!nce21->nonCriticalExtension) + nce21->nonCriticalExtension = CALLOC(1, sizeof(*nce21->nonCriticalExtension)); + + typeof(nce21->nonCriticalExtension) nce22 = nce21->nonCriticalExtension; + if (!nce22->nonCriticalExtension) + nce22->nonCriticalExtension = CALLOC(1, sizeof(*nce22->nonCriticalExtension)); + + typeof(nce22->nonCriticalExtension) nce23 = nce22->nonCriticalExtension; + if (!nce23->nonCriticalExtension) + nce23->nonCriticalExtension = CALLOC(1, sizeof(*nce23->nonCriticalExtension)); + + typeof(nce23->nonCriticalExtension) nce24 = nce23->nonCriticalExtension; + if (!nce24->irat_ParametersNR_r15) + nce24->irat_ParametersNR_r15 = CALLOC(1, sizeof(*nce24->irat_ParametersNR_r15)); + + typeof(nce24->irat_ParametersNR_r15) irat = nce24->irat_ParametersNR_r15; + if (!irat->en_DC_r15) + irat->en_DC_r15 = CALLOC(1, sizeof(*irat->en_DC_r15)); + + *irat->en_DC_r15 = LTE_IRAT_ParametersNR_r15__en_DC_r15_supported; + +} + +OAI_UECapability_t *fill_ue_capability(char *UE_EUTRA_Capability_xer_fname, bool received_nr_msg) { static OAI_UECapability_t UECapability; /* TODO declared static to allow returning this has an address should be allocated in a cleaner way. */ static LTE_SupportedBandEUTRA_t Bandlist[4]; // the macro ASN_SEQUENCE_ADD() does not copy the source, but only stores a reference to it static LTE_InterFreqBandInfo_t InterFreqBandInfo[4][4]; // the macro ASN_SEQUENCE_ADD() does not copy the source, but only stores a reference to it @@ -4476,7 +4728,13 @@ OAI_UECapability_t *fill_ue_capability(char *UE_EUTRA_Capability_xer_fname) { UE_EUTRA_Capability->featureGroupIndicators = bit_string; } - // UE_EUTRA_Capability->interRAT_Parameters // null + if (get_softmodem_params()->nsa && received_nr_msg) + { + allocate_en_DC_r15(UE_EUTRA_Capability); + if (!is_en_dc_supported(UE_EUTRA_Capability)){ + LOG_E(RRC, "We did not properly allocate en_DC_r15 for UE_EUTRA_Capability\n"); + } + } } else { FILE *f = fopen(UE_EUTRA_Capability_xer_fname, "r"); assert(f); diff --git a/openair2/RRC/LTE/MESSAGES/asn1_msg.h b/openair2/RRC/LTE/MESSAGES/asn1_msg.h index 0d9fe65aeb0a03ed3e6eb49ac36e574f887d40cc..d1d1d3febe15254bac219f28f439bd1578b8a749 100644 --- a/openair2/RRC/LTE/MESSAGES/asn1_msg.h +++ b/openair2/RRC/LTE/MESSAGES/asn1_msg.h @@ -41,6 +41,7 @@ #include "RRC/LTE/rrc_defs.h" #include "LTE_SL-DestinationInfoList-r12.h" +#include "OctetString.h" /* * The variant of the above function which dumps the BASIC-XER (XER_F_BASIC) @@ -52,6 +53,14 @@ */ int xer_sprint(char *string, size_t string_size, struct asn_TYPE_descriptor_s *td, void *sptr); +#define asn1cCallocOne(VaR, VaLue) \ + VaR = calloc(1,sizeof(*VaR)); *VaR=VaLue; +#define asn1cCalloc(VaR, lOcPtr) \ + typeof(VaR) lOcPtr = VaR = calloc(1,sizeof(*VaR)); +#define asn1cSequenceAdd(VaR, TyPe, lOcPtr) \ + TyPe *lOcPtr= calloc(1,sizeof(TyPe)); \ + ASN_SEQUENCE_ADD(&VaR,lOcPtr); + uint16_t get_adjacent_cell_id(uint8_t Mod_id,uint8_t index); uint8_t get_adjacent_cell_mod_id(uint16_t phyCellId); @@ -129,7 +138,7 @@ routine only generates an mo-data establishment cause. @param rv 5 byte random string or S-TMSI @returns Size of encoded bit stream in bytes*/ -uint8_t do_RRCConnectionRequest(uint8_t Mod_id, uint8_t *buffer,uint8_t *rv); +uint8_t do_RRCConnectionRequest(uint8_t Mod_id, uint8_t *buffer, size_t buffer_size, uint8_t *rv); /** \brief Generate an SidelinkUEInformation UL-DCCH-Message (UE). @@ -156,7 +165,9 @@ uint8_t do_RRCConnectionReconfigurationComplete( const protocol_ctxt_t *const ctxt_pP, uint8_t *buffer, - const uint8_t Transaction_id + size_t buffer_size, + const uint8_t Transaction_id, + OCTET_STRING_t *str ); /** @@ -204,6 +215,7 @@ uint16_t do_RRCConnectionReconfiguration_BR( const protocol_ctxt_t *const ctxt_pP, uint8_t *buffer, + size_t buffer_size, uint8_t Transaction_id, LTE_SRB_ToAddModList_t *SRB_list, LTE_DRB_ToAddModList_t *DRB_list, @@ -249,6 +261,7 @@ uint16_t do_RRCConnectionReconfiguration( const protocol_ctxt_t *const ctxt_pP, uint8_t *buffer, + size_t buffer_size, uint8_t Transaction_id, LTE_SRB_ToAddModList_t *SRB_list, LTE_DRB_ToAddModList_t *DRB_list, @@ -322,14 +335,8 @@ routine only generates an mo-data establishment cause. @param transaction_id Transaction index @returns Size of encoded bit stream in bytes*/ -uint8_t do_RRCConnectionRelease(uint8_t Mod_id, uint8_t *buffer,int Transaction_id); +uint8_t do_RRCConnectionRelease(uint8_t Mod_id, uint8_t *buffer, size_t buffer_size, int Transaction_id); -/*** - * \brief Generate an MCCH-Message (eNB). This routine configures MBSFNAreaConfiguration (PMCH-InfoList and Subframe Allocation for MBMS data) - * @param buffer Pointer to PER-encoded ASN.1 description of MCCH-Message PDU - * @returns Size of encoded bit stream in bytes -*/ -uint8_t do_MCCHMessage(uint8_t *buffer); /*** * \brief Generate an MCCH-Message (eNB). This routine configures MBSFNAreaConfiguration (PMCH-InfoList and Subframe Allocation for MBMS data) * @param buffer Pointer to PER-encoded ASN.1 description of MCCH-Message PDU @@ -338,14 +345,28 @@ uint8_t do_MCCHMessage(uint8_t *buffer); uint8_t do_MBSFNAreaConfig(uint8_t Mod_id, uint8_t sync_area, uint8_t *buffer, + size_t buffer_size, LTE_MCCH_Message_t *mcch_message, LTE_MBSFNAreaConfiguration_r9_t **mbsfnAreaConfiguration); -uint8_t do_MeasurementReport(uint8_t Mod_id, uint8_t *buffer,int measid,int phy_id,long rsrp_s,long rsrq_s,long rsrp_t,long rsrq_t); +ssize_t do_MeasurementReport(uint8_t Mod_id, uint8_t *buffer, size_t buffer_size, + int measid, int phy_id, + long rsrp_s, long rsrq_s, + long rsrp_t, long rsrq_t); + +ssize_t do_nrMeasurementReport(uint8_t *buffer, + size_t bufsize, + LTE_MeasId_t measid, + LTE_PhysCellIdNR_r15_t phy_id, + long rsrp_s, + long rsrq_s, + long rsrp_tar, + long rsrq_tar); uint8_t do_DLInformationTransfer(uint8_t Mod_id, uint8_t **buffer, uint8_t transaction_id, uint32_t pdu_length, uint8_t *pdu_buffer); -uint8_t do_Paging(uint8_t Mod_id, uint8_t *buffer, ue_paging_identity_t ue_paging_identity, cn_domain_t cn_domain); +uint8_t do_Paging(uint8_t Mod_id, uint8_t *buffer, size_t buffer_size, + ue_paging_identity_t ue_paging_identity, cn_domain_t cn_domain); uint8_t do_ULInformationTransfer(uint8_t **buffer, uint32_t pdu_length, uint8_t *pdu_buffer); @@ -353,12 +374,17 @@ int do_HandoverPreparation(char *ho_buf, int ho_size, LTE_UE_EUTRA_Capability_t int do_HandoverCommand(char *ho_buf, int ho_size, char *rrc_buf, int rrc_size); -OAI_UECapability_t *fill_ue_capability(char *LTE_UE_EUTRA_Capability_xer); +OAI_UECapability_t *fill_ue_capability(char *LTE_UE_EUTRA_Capability_xer, bool received_nr_msg); + +int is_en_dc_supported(LTE_UE_EUTRA_Capability_t *c); + +void allocate_en_DC_r15(LTE_UE_EUTRA_Capability_t *cap); uint8_t do_UECapabilityEnquiry( const protocol_ctxt_t *const ctxt_pP, uint8_t *const buffer, + size_t buffer_size, const uint8_t Transaction_id, int16_t eutra_band, uint32_t nr_band); @@ -367,6 +393,7 @@ uint8_t do_NR_UECapabilityEnquiry( const protocol_ctxt_t *const ctxt_pP, uint8_t *const buffer, + size_t buffer_size, const uint8_t Transaction_id, int16_t eutra_band, uint32_t nr_band); @@ -374,6 +401,7 @@ do_NR_UECapabilityEnquiry( uint8_t do_SecurityModeCommand( const protocol_ctxt_t *const ctxt_pP, uint8_t *const buffer, + size_t buffer_size, const uint8_t Transaction_id, const uint8_t cipheringAlgorithm, const uint8_t integrityProtAlgorithm); diff --git a/openair2/RRC/LTE/MESSAGES/asn1_msg_NB_IoT.c b/openair2/RRC/LTE/MESSAGES/asn1_msg_NB_IoT.c index 350a8baf77faec3e25b78207c1a46b51488f349f..d13dcb9918c828f46d4dfb6a51ac2be4d592fb26 100644 --- a/openair2/RRC/LTE/MESSAGES/asn1_msg_NB_IoT.c +++ b/openair2/RRC/LTE/MESSAGES/asn1_msg_NB_IoT.c @@ -834,6 +834,7 @@ uint8_t do_UECapabilityEnquiry_NB_IoT( uint16_t do_RRCConnectionReconfiguration_NB_IoT( const protocol_ctxt_t *const ctxt_pP, uint8_t *buffer, + size_t buffer_size, uint8_t Transaction_id, LTE_SRB_ToAddModList_NB_r13_t *SRB1_list_NB, //SRB_ConfigList2 (default)--> only SRB1 LTE_DRB_ToAddModList_NB_r13_t *DRB_list_NB_IoT, //DRB_ConfigList (default) @@ -886,7 +887,7 @@ uint16_t do_RRCConnectionReconfiguration_NB_IoT( NULL, (void *)&dl_dcch_msg_NB_IoT, buffer, - RRC_BUF_SIZE); + buffer_size); if (enc_rval.encoded <= 0) { LOG_E(RRC, "ASN1 message encoding failed %s, %li\n", @@ -1020,7 +1021,8 @@ uint8_t do_DLInformationTransfer_NB_IoT( /*do_RRCConnectionReestablishment_NB-->used to re-establish SRB1*/ //which parameter to use? uint8_t do_RRCConnectionReestablishment_NB_IoT( uint8_t Mod_id, - uint8_t *const buffer, + uint8_t *buffer, + size_t buffer_size, const uint8_t Transaction_id, const NB_IoT_DL_FRAME_PARMS *const frame_parms, //to be changed LTE_SRB_ToAddModList_NB_r13_t *SRB_list_NB_IoT) { //should contain SRB1 already configured? @@ -1046,7 +1048,7 @@ uint8_t do_RRCConnectionReestablishment_NB_IoT( NULL, (void *)&dl_ccch_msg_NB_IoT, buffer, - RRC_BUF_SIZE); + buffer_size); if (enc_rval.encoded <= 0) { LOG_E(RRC, "ASN1 message encoding failed (%s, %li)!\n", @@ -1065,6 +1067,7 @@ uint8_t do_RRCConnectionReestablishment_NB_IoT( uint8_t do_RRCConnectionRelease_NB_IoT( uint8_t Mod_id, uint8_t *buffer, + size_t buffer_size, const uint8_t Transaction_id) { asn_enc_rval_t enc_rval; LTE_DL_DCCH_Message_NB_t dl_dcch_msg_NB_IoT; @@ -1087,7 +1090,7 @@ uint8_t do_RRCConnectionRelease_NB_IoT( NULL, (void *)&dl_dcch_msg_NB_IoT, buffer, - RRC_BUF_SIZE);//check + buffer_size); return((enc_rval.encoded+7)/8); } diff --git a/openair2/RRC/LTE/MESSAGES/asn1_msg_NB_IoT.h b/openair2/RRC/LTE/MESSAGES/asn1_msg_NB_IoT.h index a862af783680c134aa859918a08f73256cc056a4..b52fdb76e03b88398519012624adc23285afbbd9 100644 --- a/openair2/RRC/LTE/MESSAGES/asn1_msg_NB_IoT.h +++ b/openair2/RRC/LTE/MESSAGES/asn1_msg_NB_IoT.h @@ -125,10 +125,12 @@ uint8_t do_RRCConnectionSetupComplete_NB_IoT(uint8_t Mod_id, uint8_t* buffer, co @param Transaction_id @returns Size of encoded bit stream in bytes*/ -uint8_t do_RRCConnectionReconfigurationComplete_NB_IoT( +size_t do_RRCConnectionReconfigurationComplete_NB_IoT( const protocol_ctxt_t* const ctxt_pP, uint8_t* buffer, - const uint8_t Transaction_id + size_t buffer_size, + const uint8_t Transaction_id, + OCTET_STRING_t *str ); /** @@ -178,6 +180,7 @@ uint16_t do_RRCConnectionReconfiguration_NB_IoT( const protocol_ctxt_t* const ctxt_pP, uint8_t *buffer, + size_t buffer_size, uint8_t Transaction_id, SRB_ToAddModList_NB_r13_t *SRB_list_NB_IoT, DRB_ToAddModList_NB_r13_t *DRB_list_NB_IoT, @@ -249,8 +252,8 @@ do_RRCConnectionReject_NB_IoT( @param transaction_id Transaction index @returns Size of encoded bit stream in bytes*/ -uint8_t do_RRCConnectionRelease_NB_IoT(uint8_t Mod_id, uint8_t *buffer,int Transaction_id); - +uint8_t do_RRCConnectionRelease_NB_IoT(uint8_t Mod_id, uint8_t *buffer, size_t buffer_size, + int Transaction_id); uint8_t do_DLInformationTransfer_NB_IoT( uint8_t Mod_id, @@ -273,7 +276,8 @@ uint8_t do_DLInformationTransfer_NB_IoT( uint8_t do_RRCConnectionReestablishment_NB_IoT( uint8_t Mod_id, - uint8_t* const buffer, + uint8_t* buffer, + size_t buffer_size, const uint8_t Transaction_id, const NB_IoT_DL_FRAME_PARMS* const frame_parms, //to be changed SRB_ToAddModList_NB_r13_t** SRB_configList_NB_IoT diff --git a/openair2/RRC/LTE/defs_NB_IoT.h b/openair2/RRC/LTE/defs_NB_IoT.h index 3907d2321d89aa6f2ee66ccfdb2c0211c5f9cbe8..37a26086b55902a4818aa37f3841bf27d7139780 100644 --- a/openair2/RRC/LTE/defs_NB_IoT.h +++ b/openair2/RRC/LTE/defs_NB_IoT.h @@ -148,7 +148,7 @@ typedef struct UE_RRC_INFO_NB_IoT_s { //Measurement Report not supported in NB-IoT #define PAYLOAD_SIZE_MAX 1024 -#define RRC_BUF_SIZE 8192 +#define RRC_BUF_SIZE 512 #define UNDEF_SECURITY_MODE 0xff #define NO_SECURITY_MODE 0x20 diff --git a/openair2/RRC/LTE/rrc_UE.c b/openair2/RRC/LTE/rrc_UE.c index 4b862fa11da37475ccb6b07882e8630c9843fd58..d0b89abb51e316f7af0a3cf18f410011523d2e8d 100644 --- a/openair2/RRC/LTE/rrc_UE.c +++ b/openair2/RRC/LTE/rrc_UE.c @@ -75,7 +75,7 @@ #include <common/utils/system.h> #include "intertask_interface.h" - +#include "targets/RT/USER/lte-softmodem.h" #include "SIMULATION/TOOLS/sim.h" // for taus @@ -92,8 +92,10 @@ //for D2D int ctrl_sock_fd; -#define BUFSIZE 1024 struct sockaddr_in prose_app_addr; +static const char nsa_ipaddr[] = "127.0.0.1"; +static int from_nr_ue_fd = -1; +static int to_nr_ue_fd = -1; int slrb_id; int send_ue_information = 0; @@ -123,6 +125,26 @@ static int decode_SIB1( const protocol_ctxt_t *const ctxt_pP, const uint8_t eNB_ static int decode_SIB1_MBMS( const protocol_ctxt_t *const ctxt_pP, const uint8_t eNB_index, const uint8_t rsrq, const uint8_t rsrp ); +typedef struct rrc_dcch_data_copy_t +{ + LTE_DL_DCCH_Message_t *dl_dcch_msg; +} rrc_dcch_data_copy_t; + +typedef struct rrc_nrue_cap_info_t +{ + uint8_t mesg[RRC_BUF_SIZE]; + size_t mesg_len; + LTE_DL_DCCH_Message_t *dl_dcch_msg; +} rrc_nrue_cap_info_t; + +static void rrc_ue_process_ueCapabilityEnquiry(const protocol_ctxt_t *const ctxt_pP, + LTE_UECapabilityEnquiry_t *UECapabilityEnquiry, + uint8_t eNB_index); + +static void rrc_ue_process_nrueCapabilityEnquiry(const protocol_ctxt_t *const ctxt_pP, + LTE_UECapabilityEnquiry_t *UECapabilityEnquiry, + rrc_nrue_cap_info_t *nrue_cap_info, + uint8_t eNB_index); /** \brief Generates/Encodes RRCConnnectionSetupComplete message at UE * \param ctxt_pP Running context @@ -141,10 +163,15 @@ static void rrc_ue_generate_RRCConnectionSetupComplete( * \param eNB_index Index of corresponding eNB/CH * \param Transaction_id RRC transaction identifier */ -static void rrc_ue_generate_RRCConnectionReconfigurationComplete( const protocol_ctxt_t *const ctxt_pP, const uint8_t eNB_index, const uint8_t Transaction_id ); +static void rrc_ue_generate_RRCConnectionReconfigurationComplete(const protocol_ctxt_t *const ctxt_pP, + const uint8_t eNB_index, + const uint8_t Transaction_id, + OCTET_STRING_t *str); static void rrc_ue_generate_MeasurementReport(protocol_ctxt_t *const ctxt_pP, uint8_t eNB_index ); +static void rrc_ue_generate_nrMeasurementReport(protocol_ctxt_t *const ctxt_pP, uint8_t eNB_index ); + static uint8_t check_trigger_meas_event( module_id_t module_idP, frame_t frameP, @@ -166,7 +193,9 @@ rrc_ue_process_MBMSCountingRequest( LTE_MBMSCountingRequest_r10_t *MBMSCountingRequest, uint8_t eNB_index ); - + +static void process_nr_nsa_msg(nsa_msg_t *msg, int msg_len); +static void nsa_sendmsg_to_nrue(const void *message, size_t msg_len, Rrc_Msg_Type_t msg_type); protocol_ctxt_t ctxt_pP_local; @@ -399,12 +428,12 @@ char openair_rrc_ue_init( const module_id_t ue_mod_idP, const unsigned char eNB_ //----------------------------------------------------------------------------- void rrc_ue_generate_RRCConnectionRequest( const protocol_ctxt_t *const ctxt_pP, const uint8_t eNB_index ) { - uint8_t i=0,rv[6]; + uint8_t rv[6]; if(UE_rrc_inst[ctxt_pP->module_id].Srb0[eNB_index].Tx_buffer.payload_size ==0) { // Get RRCConnectionRequest, fill random for now // Generate random byte stream for contention resolution - for (i=0; i<6; i++) { + for (int i=0; i<6; i++) { #ifdef SMBV // if SMBV is configured the contention resolution needs to be fix for the connection procedure to succeed rv[i]=i; @@ -419,12 +448,13 @@ void rrc_ue_generate_RRCConnectionRequest( const protocol_ctxt_t *const ctxt_pP, do_RRCConnectionRequest( ctxt_pP->module_id, (uint8_t *)UE_rrc_inst[ctxt_pP->module_id].Srb0[eNB_index].Tx_buffer.Payload, + sizeof(UE_rrc_inst[ctxt_pP->module_id].Srb0[eNB_index].Tx_buffer.Payload), rv); LOG_I(RRC,"[UE %d] : Frame %d, Logical Channel UL-CCCH (SRB0), Generating RRCConnectionRequest (bytes %d, eNB %d)\n", ctxt_pP->module_id, ctxt_pP->frame, UE_rrc_inst[ctxt_pP->module_id].Srb0[eNB_index].Tx_buffer.payload_size, eNB_index); - for (i=0; i<UE_rrc_inst[ctxt_pP->module_id].Srb0[eNB_index].Tx_buffer.payload_size; i++) { - LOG_T(RRC,"%x.",UE_rrc_inst[ctxt_pP->module_id].Srb0[eNB_index].Tx_buffer.Payload[i]); + for (int i=0; i<UE_rrc_inst[ctxt_pP->module_id].Srb0[eNB_index].Tx_buffer.payload_size; i++) { + LOG_T(RRC,"%x.\n",UE_rrc_inst[ctxt_pP->module_id].Srb0[eNB_index].Tx_buffer.Payload[i]); } LOG_T(RRC,"\n"); @@ -529,13 +559,16 @@ static void rrc_ue_generate_RRCConnectionSetupComplete( } //----------------------------------------------------------------------------- -void rrc_ue_generate_RRCConnectionReconfigurationComplete( const protocol_ctxt_t *const ctxt_pP, const uint8_t eNB_index, const uint8_t Transaction_id ) { - uint8_t buffer[32], size; - size = do_RRCConnectionReconfigurationComplete(ctxt_pP, buffer, Transaction_id); - LOG_I(RRC,PROTOCOL_RRC_CTXT_UE_FMT" Logical Channel UL-DCCH (SRB1), Generating RRCConnectionReconfigurationComplete (bytes %d, eNB_index %d)\n", +void rrc_ue_generate_RRCConnectionReconfigurationComplete(const protocol_ctxt_t *const ctxt_pP, + const uint8_t eNB_index, + const uint8_t Transaction_id, + OCTET_STRING_t *str) { + uint8_t buffer[RRC_BUF_SIZE]; + size_t size = do_RRCConnectionReconfigurationComplete(ctxt_pP, buffer, sizeof(buffer), Transaction_id, str); + LOG_I(RRC,PROTOCOL_RRC_CTXT_UE_FMT" Logical Channel UL-DCCH (SRB1), Generating RRCConnectionReconfigurationComplete (bytes %zu, eNB_index %d)\n", PROTOCOL_RRC_CTXT_UE_ARGS(ctxt_pP), size, eNB_index); LOG_D(RLC, - "[FRAME %05d][RRC_UE][INST %02d][][--- PDCP_DATA_REQ/%d Bytes (RRCConnectionReconfigurationComplete to eNB %d MUI %d) --->][PDCP][INST %02d][RB %02d]\n", + "[FRAME %05d][RRC_UE][INST %02d][][--- PDCP_DATA_REQ/%zu Bytes (RRCConnectionReconfigurationComplete to eNB %d MUI %d) --->][PDCP][INST %02d][RB %02d]\n", ctxt_pP->frame, UE_MODULE_ID_TO_INSTANCE(ctxt_pP->module_id), size, @@ -614,7 +647,7 @@ int rrc_ue_decode_ccch( const protocol_ctxt_t *const ctxt_pP, const SRB_INFO *co break; case LTE_DL_CCCH_MessageType__c1_PR_rrcConnectionSetup: - LOG_I(RRC, + LOG_A(RRC, "[UE%d][RAPROC] Frame %d : Logical Channel DL-CCCH (SRB0), Received RRCConnectionSetup RNTI %x\n", ctxt_pP->module_id, ctxt_pP->frame, @@ -761,38 +794,60 @@ rrc_ue_process_measConfig( int i; long ind; LTE_MeasObjectToAddMod_t *measObj; + UE_RRC_INST *ue = &UE_rrc_inst[ctxt_pP->module_id]; if (measConfig->measObjectToRemoveList != NULL) { - for (i=0; i<measConfig->measObjectToRemoveList->list.count; i++) { - ind = *measConfig->measObjectToRemoveList->list.array[i]; - free(UE_rrc_inst[ctxt_pP->module_id].MeasObj[eNB_index][ind-1]); + for (i = 0; i < measConfig->measObjectToRemoveList->list.count; i++) { + ind = *measConfig->measObjectToRemoveList->list.array[i]; + free(ue->MeasObj[eNB_index][ind-1]); + ue->MeasObj[eNB_index][ind-1] = NULL; } } if (measConfig->measObjectToAddModList != NULL) { - LOG_D(RRC,"Measurement Object List is present\n"); + LOG_I(RRC,"Measurement Object List is present\n"); - for (i=0; i<measConfig->measObjectToAddModList->list.count; i++) { + for (i = 0; i < measConfig->measObjectToAddModList->list.count; i++) { measObj = measConfig->measObjectToAddModList->list.array[i]; - ind = measConfig->measObjectToAddModList->list.array[i]->measObjectId; - - if (UE_rrc_inst[ctxt_pP->module_id].MeasObj[eNB_index][ind-1]) { - LOG_D(RRC,"Modifying measurement object %ld\n",ind); - memcpy((char *)UE_rrc_inst[ctxt_pP->module_id].MeasObj[eNB_index][ind-1], + ind = measConfig->measObjectToAddModList->list.array[i]->measObjectId; + AssertFatal(ind > 0 && ind <= MAX_MEAS_OBJ && eNB_index >= 0 && eNB_index < NB_CNX_UE, + "measObjectId is out of bounds. ind = %ld, eNB_index = %d, i = %d.\n", ind, eNB_index, i); + if (ue->MeasObj[eNB_index][ind-1]) { + LOG_D(RRC, "Modifying measurement object [%d][%ld]\n", eNB_index, ind); + memcpy((char *)ue->MeasObj[eNB_index][ind-1], (char *)measObj, sizeof(LTE_MeasObjectToAddMod_t)); } else { - LOG_I(RRC,"Adding measurement object %ld\n",ind); - - if (measObj->measObject.present == LTE_MeasObjectToAddMod__measObject_PR_measObjectEUTRA) { - LOG_I(RRC,"EUTRA Measurement : carrierFreq %ld, allowedMeasBandwidth %ld,presenceAntennaPort1 %d, neighCellConfig %d\n", - measObj->measObject.choice.measObjectEUTRA.carrierFreq, - measObj->measObject.choice.measObjectEUTRA.allowedMeasBandwidth, - measObj->measObject.choice.measObjectEUTRA.presenceAntennaPort1, - measObj->measObject.choice.measObjectEUTRA.neighCellConfig.buf[0]); - UE_rrc_inst[ctxt_pP->module_id].MeasObj[eNB_index][ind-1]=measObj; + if (measObj->measObject.present == LTE_MeasObjectToAddMod__measObject_PR_measObjectEUTRA) { + LOG_I(RRC,"EUTRA Measurement : carrierFreq %ld, allowedMeasBandwidth %ld,presenceAntennaPort1 %d, neighCellConfig %d\n", + measObj->measObject.choice.measObjectEUTRA.carrierFreq, + measObj->measObject.choice.measObjectEUTRA.allowedMeasBandwidth, + measObj->measObject.choice.measObjectEUTRA.presenceAntennaPort1, + measObj->measObject.choice.measObjectEUTRA.neighCellConfig.buf[0]); + } else if (measObj->measObject.present == LTE_MeasObjectToAddMod__measObject_PR_measObjectNR_r15) { + ue->subframeCount = 0; + LOG_I(RRC, "NR_r15 Measurement: carrierFreq: %ld\n", + measObj->measObject.choice.measObjectNR_r15.carrierFreq_r15); + if (!get_softmodem_params()->nsa) { + LOG_E(RRC, "Not in NSA mode but attempting to send measurement request to NR-UE\n"); + return; + } + uint8_t buffer[RRC_BUF_SIZE]; + asn_enc_rval_t enc_rval = uper_encode_to_buffer(&asn_DEF_LTE_MeasObjectToAddMod, + NULL, + measObj, + buffer, + sizeof(buffer)); + AssertFatal (enc_rval.encoded > 0, "ASN1 message encoding failed (%s, %zu)!\n", + enc_rval.failed_type->name, enc_rval.encoded); + nsa_sendmsg_to_nrue(buffer, (enc_rval.encoded + 7)/8, RRC_MEASUREMENT_PROCEDURE); + LOG_A(RRC, "Encoded measurement object %zu bits (%zu bytes) and sent to NR UE\n", + enc_rval.encoded, (enc_rval.encoded + 7)/8); + } + LOG_D(RRC, "Adding measurement object [%d][%ld]\n", eNB_index, ind); + ue->MeasObj[eNB_index][ind-1]=measObj; } - } + measConfig->measObjectToAddModList->list.array[i] = NULL; } LOG_I(RRC,"call rrc_mac_config_req \n"); @@ -800,7 +855,7 @@ rrc_ue_process_measConfig( (LTE_RadioResourceConfigCommonSIB_t *)NULL, (struct LTE_PhysicalConfigDedicated *)NULL, (LTE_SCellToAddMod_r10_t *)NULL, - UE_rrc_inst[ctxt_pP->module_id].MeasObj[eNB_index], + ue->MeasObj[eNB_index], (LTE_MAC_MainConfig_t *)NULL, 0, (struct LTE_LogicalChannelConfig *)NULL, @@ -828,109 +883,120 @@ rrc_ue_process_measConfig( if (measConfig->reportConfigToRemoveList != NULL) { for (i=0; i<measConfig->reportConfigToRemoveList->list.count; i++) { ind = *measConfig->reportConfigToRemoveList->list.array[i]; - free(UE_rrc_inst[ctxt_pP->module_id].ReportConfig[eNB_index][ind-1]); + free(ue->ReportConfig[eNB_index][ind-1]); + ue->ReportConfig[eNB_index][ind-1] = NULL; } } if (measConfig->reportConfigToAddModList != NULL) { LOG_I(RRC,"Report Configuration List is present\n"); - for (i=0; i<measConfig->reportConfigToAddModList->list.count; i++) { - ind = measConfig->reportConfigToAddModList->list.array[i]->reportConfigId; - - if (UE_rrc_inst[ctxt_pP->module_id].ReportConfig[eNB_index][ind-1]) { - LOG_I(RRC,"Modifying Report Configuration %ld\n",ind-1); - memcpy((char *)UE_rrc_inst[ctxt_pP->module_id].ReportConfig[eNB_index][ind-1], + for (i=0; i < measConfig->reportConfigToAddModList->list.count; i++) { + ind = measConfig->reportConfigToAddModList->list.array[i]->reportConfigId; + AssertFatal(ind > 0 && ind <= MAX_MEAS_CONFIG && eNB_index >= 0 && eNB_index < NB_CNX_UE, + "ReportConfigId is out of bounds. ind = %ld, eNB_index = %d, i = %d.\n", ind, eNB_index, i); + if (ue->ReportConfig[eNB_index][ind-1]) { + LOG_D(RRC,"Modifying ReportConfig [%d][%ld]\n", eNB_index, ind-1); + memcpy((char *)ue->ReportConfig[eNB_index][ind-1], (char *)measConfig->reportConfigToAddModList->list.array[i], sizeof(LTE_ReportConfigToAddMod_t)); } else { - LOG_D(RRC,"Adding Report Configuration %ld %p \n",ind-1,measConfig->reportConfigToAddModList->list.array[i]); - UE_rrc_inst[ctxt_pP->module_id].ReportConfig[eNB_index][ind-1] = measConfig->reportConfigToAddModList->list.array[i]; + LOG_D(RRC,"Adding ReportConfig [%d][%ld]\n", eNB_index, ind-1); + ue->ReportConfig[eNB_index][ind-1] = measConfig->reportConfigToAddModList->list.array[i]; } + measConfig->reportConfigToAddModList->list.array[i] = NULL; } } if (measConfig->quantityConfig != NULL) { - if (UE_rrc_inst[ctxt_pP->module_id].QuantityConfig[eNB_index]) { + if (ue->QuantityConfig[eNB_index]) { LOG_D(RRC,"Modifying Quantity Configuration \n"); - memcpy((char *)UE_rrc_inst[ctxt_pP->module_id].QuantityConfig[eNB_index], + memcpy((char *)ue->QuantityConfig[eNB_index], (char *)measConfig->quantityConfig, sizeof(LTE_QuantityConfig_t)); } else { LOG_D(RRC,"Adding Quantity configuration\n"); - UE_rrc_inst[ctxt_pP->module_id].QuantityConfig[eNB_index] = measConfig->quantityConfig; + ue->QuantityConfig[eNB_index] = measConfig->quantityConfig; } + measConfig->quantityConfig = NULL; } if (measConfig->measIdToRemoveList != NULL) { for (i=0; i<measConfig->measIdToRemoveList->list.count; i++) { ind = *measConfig->measIdToRemoveList->list.array[i]; - free(UE_rrc_inst[ctxt_pP->module_id].MeasId[eNB_index][ind-1]); + free(ue->MeasId[eNB_index][ind-1]); + ue->MeasId[eNB_index][ind-1] = NULL; } } if (measConfig->measIdToAddModList != NULL) { for (i=0; i<measConfig->measIdToAddModList->list.count; i++) { ind = measConfig->measIdToAddModList->list.array[i]->measId; - - if (UE_rrc_inst[ctxt_pP->module_id].MeasId[eNB_index][ind-1]) { - LOG_D(RRC,"Modifying Measurement ID %ld\n",ind-1); - memcpy((char *)UE_rrc_inst[ctxt_pP->module_id].MeasId[eNB_index][ind-1], + AssertFatal(ind > 0 && ind <= MAX_MEAS_ID && eNB_index >= 0 && eNB_index < NB_CNX_UE, + "measId is out of bounds. ind = %ld, eNB_index = %d, i = %d.\n", ind, eNB_index, i); + if (ue->MeasId[eNB_index][ind-1]) { + LOG_I(RRC,"Modifying Measurement ID [%d][%ld]\n", eNB_index, ind-1); + memcpy((char *)ue->MeasId[eNB_index][ind-1], (char *)measConfig->measIdToAddModList->list.array[i], sizeof(LTE_MeasIdToAddMod_t)); } else { - LOG_D(RRC,"Adding Measurement ID %ld %p\n",ind-1,measConfig->measIdToAddModList->list.array[i]); - UE_rrc_inst[ctxt_pP->module_id].MeasId[eNB_index][ind-1] = measConfig->measIdToAddModList->list.array[i]; + LOG_I(RRC,"Adding Measurement ID [%d][%ld]\n", eNB_index, ind-1); + ue->MeasId[eNB_index][ind-1] = measConfig->measIdToAddModList->list.array[i]; } + measConfig->measIdToAddModList->list.array[i] = NULL; } } if (measConfig->measGapConfig !=NULL) { - if (UE_rrc_inst[ctxt_pP->module_id].measGapConfig[eNB_index]) { - memcpy((char *)UE_rrc_inst[ctxt_pP->module_id].measGapConfig[eNB_index], + if (ue->measGapConfig[eNB_index]) { + memcpy((char *)ue->measGapConfig[eNB_index], (char *)measConfig->measGapConfig, sizeof(LTE_MeasGapConfig_t)); } else { - UE_rrc_inst[ctxt_pP->module_id].measGapConfig[eNB_index] = measConfig->measGapConfig; + ue->measGapConfig[eNB_index] = measConfig->measGapConfig; } + measConfig->measGapConfig = NULL; } if (measConfig->quantityConfig != NULL) { - if (UE_rrc_inst[ctxt_pP->module_id].QuantityConfig[eNB_index]) { + if (ue->QuantityConfig[eNB_index]) { LOG_I(RRC,"Modifying Quantity Configuration \n"); - memcpy((char *)UE_rrc_inst[ctxt_pP->module_id].QuantityConfig[eNB_index], + memcpy((char *)ue->QuantityConfig[eNB_index], (char *)measConfig->quantityConfig, sizeof(LTE_QuantityConfig_t)); } else { LOG_I(RRC,"Adding Quantity configuration\n"); - UE_rrc_inst[ctxt_pP->module_id].QuantityConfig[eNB_index] = measConfig->quantityConfig; + ue->QuantityConfig[eNB_index] = measConfig->quantityConfig; } + measConfig->quantityConfig = NULL; - UE_rrc_inst[ctxt_pP->module_id].filter_coeff_rsrp = 1./pow(2, - (*UE_rrc_inst[ctxt_pP->module_id].QuantityConfig[eNB_index]->quantityConfigEUTRA->filterCoefficientRSRP)/4); - UE_rrc_inst[ctxt_pP->module_id].filter_coeff_rsrq = 1./pow(2, - (*UE_rrc_inst[ctxt_pP->module_id].QuantityConfig[eNB_index]->quantityConfigEUTRA->filterCoefficientRSRQ)/4); + ue->filter_coeff_rsrp = 1./pow(2, + (*ue->QuantityConfig[eNB_index]->quantityConfigEUTRA->filterCoefficientRSRP)/4); + ue->filter_coeff_rsrq = 1./pow(2, + (*ue->QuantityConfig[eNB_index]->quantityConfigEUTRA->filterCoefficientRSRQ)/4); LOG_I(RRC,"[UE %d] set rsrp-coeff for eNB %d: %ld rsrq-coeff: %ld rsrp_factor: %f rsrq_factor: %f \n", ctxt_pP->module_id, eNB_index, // UE_rrc_inst[ue_mod_idP].Info[eNB_index].UE_index, - *UE_rrc_inst[ctxt_pP->module_id].QuantityConfig[eNB_index]->quantityConfigEUTRA->filterCoefficientRSRP, - *UE_rrc_inst[ctxt_pP->module_id].QuantityConfig[eNB_index]->quantityConfigEUTRA->filterCoefficientRSRQ, - UE_rrc_inst[ctxt_pP->module_id].filter_coeff_rsrp, - UE_rrc_inst[ctxt_pP->module_id].filter_coeff_rsrq); + *ue->QuantityConfig[eNB_index]->quantityConfigEUTRA->filterCoefficientRSRP, + *ue->QuantityConfig[eNB_index]->quantityConfigEUTRA->filterCoefficientRSRQ, + ue->filter_coeff_rsrp, + ue->filter_coeff_rsrq); } if (measConfig->s_Measure != NULL) { - UE_rrc_inst[ctxt_pP->module_id].s_measure = *measConfig->s_Measure; + ue->s_measure = *measConfig->s_Measure; } + measConfig->s_Measure = NULL; if (measConfig->speedStatePars != NULL) { - if (UE_rrc_inst[ctxt_pP->module_id].speedStatePars) { - memcpy((char *)UE_rrc_inst[ctxt_pP->module_id].speedStatePars,(char *)measConfig->speedStatePars,sizeof(struct LTE_MeasConfig__speedStatePars)); + if (ue->speedStatePars) { + memcpy((char *)ue->speedStatePars,(char *)measConfig->speedStatePars,sizeof(struct LTE_MeasConfig__speedStatePars)); } else { - UE_rrc_inst[ctxt_pP->module_id].speedStatePars = measConfig->speedStatePars; + ue->speedStatePars = measConfig->speedStatePars; } + measConfig->speedStatePars = NULL; LOG_I(RRC,"[UE %d] Configuring mobility optimization params for UE %d \n", - ctxt_pP->module_id,UE_rrc_inst[ctxt_pP->module_id].Info[0].UE_index); + ctxt_pP->module_id,ue->Info[0].UE_index); } } @@ -1141,6 +1207,7 @@ rrc_ue_process_radioResourceConfigDedicated( LOG_I(RRC,"Init physicalConfigDedicated UE_rrc_inst to radioResourceConfigDedicated->physicalConfigDedicated\n"); UE_rrc_inst[ctxt_pP->module_id].physicalConfigDedicated[eNB_index] = radioResourceConfigDedicated->physicalConfigDedicated; } + radioResourceConfigDedicated->physicalConfigDedicated = NULL; } // Apply macMainConfig if present @@ -1163,6 +1230,7 @@ rrc_ue_process_radioResourceConfigDedicated( } else { UE_rrc_inst[ctxt_pP->module_id].sps_Config[eNB_index] = radioResourceConfigDedicated->sps_Config; } + radioResourceConfigDedicated->sps_Config = NULL; } // Establish SRBs if present @@ -1211,7 +1279,7 @@ rrc_ue_process_radioResourceConfigDedicated( } else { UE_rrc_inst[ctxt_pP->module_id].SRB1_config[eNB_index] = radioResourceConfigDedicated->srb_ToAddModList->list.array[cnt]; rrc_ue_establish_srb1(ctxt_pP->module_id,ctxt_pP->frame,eNB_index,radioResourceConfigDedicated->srb_ToAddModList->list.array[cnt]); - + radioResourceConfigDedicated->srb_ToAddModList->list.array[cnt] = NULL; if (UE_rrc_inst[ctxt_pP->module_id].SRB1_config[eNB_index]->logicalChannelConfig) { if (UE_rrc_inst[ctxt_pP->module_id].SRB1_config[eNB_index]->logicalChannelConfig->present == LTE_SRB_ToAddMod__logicalChannelConfig_PR_explicitValue) { SRB1_logicalChannelConfig = &UE_rrc_inst[ctxt_pP->module_id].SRB1_config[eNB_index]->logicalChannelConfig->choice.explicitValue; @@ -1259,7 +1327,7 @@ rrc_ue_process_radioResourceConfigDedicated( } else { UE_rrc_inst[ctxt_pP->module_id].SRB2_config[eNB_index] = radioResourceConfigDedicated->srb_ToAddModList->list.array[cnt]; rrc_ue_establish_srb2(ctxt_pP->module_id,ctxt_pP->frame,eNB_index,radioResourceConfigDedicated->srb_ToAddModList->list.array[cnt]); - + radioResourceConfigDedicated->srb_ToAddModList->list.array[cnt] = NULL; if (UE_rrc_inst[ctxt_pP->module_id].SRB2_config[eNB_index]->logicalChannelConfig) { if (UE_rrc_inst[ctxt_pP->module_id].SRB2_config[eNB_index]->logicalChannelConfig->present == LTE_SRB_ToAddMod__logicalChannelConfig_PR_explicitValue) { LOG_I(RRC,"Applying Explicit SRB2 logicalChannelConfig\n"); @@ -1368,6 +1436,7 @@ rrc_ue_process_radioResourceConfigDedicated( radioResourceConfigDedicated->drb_ToAddModList->list.array[i]->drb_Identity, eNB_index, ctxt_pP->module_id); + radioResourceConfigDedicated->drb_ToAddModList->list.array[i] = NULL; rrc_mac_config_req_ue(ctxt_pP->module_id,0,eNB_index, (LTE_RadioResourceConfigCommonSIB_t *)NULL, UE_rrc_inst[ctxt_pP->module_id].physicalConfigDedicated[eNB_index], @@ -1629,6 +1698,101 @@ rrc_ue_process_MBMSCountingRequest( } +//----------------------------------------------------------------------------- +void +rrc_ue_process_nrueCapabilityEnquiry( + const protocol_ctxt_t *const ctxt_pP, + LTE_UECapabilityEnquiry_t *UECapabilityEnquiry, + rrc_nrue_cap_info_t *nrue_cap_info, + uint8_t eNB_index +) +//----------------------------------------------------------------------------- +{ + asn_enc_rval_t enc_rval; + uint8_t buffer[RRC_BUF_SIZE]; + LOG_I(RRC,"[UE %d] Frame %d: Receiving from SRB1 (DL-DCCH), Processing NRUECapabilityEnquiry (eNB %d)\n", + ctxt_pP->module_id, + ctxt_pP->frame, + eNB_index); + LTE_UL_DCCH_Message_t ul_dcch_msg; + memset(&ul_dcch_msg, 0, sizeof(ul_dcch_msg)); + LTE_UECapabilityInformation_t *ue_cap = &ul_dcch_msg.message.choice.c1.choice.ueCapabilityInformation; + ul_dcch_msg.message.present = LTE_UL_DCCH_MessageType_PR_c1; + ul_dcch_msg.message.choice.c1.present = LTE_UL_DCCH_MessageType__c1_PR_ueCapabilityInformation; + ue_cap->rrc_TransactionIdentifier = UECapabilityEnquiry->rrc_TransactionIdentifier; + + NR_UE_CapabilityRAT_Container_t ue_CapabilityRAT_Container; + memset(&ue_CapabilityRAT_Container, 0, sizeof(ue_CapabilityRAT_Container)); + ue_CapabilityRAT_Container.rat_Type = NR_RAT_Type_nr; + OCTET_STRING_fromBuf(&ue_CapabilityRAT_Container.ue_CapabilityRAT_Container, + (const char *)nrue_cap_info->mesg, + nrue_cap_info->mesg_len); + # if(1) // TODO: The MRDC capabilites should be filled in the NR UE + NR_UE_CapabilityRAT_Container_t ue_CapabilityRAT_Container_mrdc; + memset(&ue_CapabilityRAT_Container_mrdc, 0, sizeof(ue_CapabilityRAT_Container_mrdc)); + uint8_t buffer_mrdc[RRC_BUF_SIZE]; + NR_UE_MRDC_Capability_t *UE_Capability_MRDC = CALLOC(1, sizeof(NR_UE_MRDC_Capability_t)); + asn_enc_rval_t enc_rval_mrdc = uper_encode_to_buffer(&asn_DEF_NR_UE_MRDC_Capability, + NULL, + (void *)UE_Capability_MRDC, + &buffer_mrdc, + sizeof(buffer_mrdc)); + AssertFatal (enc_rval_mrdc.encoded > 0, "ASN1 message encoding failed (%s, %lu)!\n", + enc_rval_mrdc.failed_type->name, enc_rval_mrdc.encoded); + LOG_I(RRC, "[NR_RRC] NRUE MRDC Capability encoded, %ld bytes (%ld bits)\n", + (enc_rval_mrdc.encoded + 7) / 8, enc_rval_mrdc.encoded + 7); + + ue_CapabilityRAT_Container_mrdc.rat_Type = NR_RAT_Type_eutra_nr; + OCTET_STRING_fromBuf(&ue_CapabilityRAT_Container_mrdc.ue_CapabilityRAT_Container, + (const char *)buffer_mrdc, + (enc_rval_mrdc.encoded + 7) / 8); + #endif + + ue_cap->criticalExtensions.present = LTE_UECapabilityInformation__criticalExtensions_PR_c1; + ue_cap->criticalExtensions.choice.c1.present = LTE_UECapabilityInformation__criticalExtensions__c1_PR_ueCapabilityInformation_r8; + ue_cap->criticalExtensions.choice.c1.choice.ueCapabilityInformation_r8.ue_CapabilityRAT_ContainerList.list.count = 0; + int count = UECapabilityEnquiry->criticalExtensions.choice.c1.choice.ueCapabilityEnquiry_r8.ue_CapabilityRequest.list.count; + xer_fprint(stdout, &asn_DEF_NR_UE_CapabilityRAT_Container, (void *)&ue_CapabilityRAT_Container); + LTE_UE_CapabilityRequest_t *cap_req = &UECapabilityEnquiry->criticalExtensions.choice.c1.choice.ueCapabilityEnquiry_r8.ue_CapabilityRequest; + for (int i = 0; i < count; i++) { + enc_rval.encoded = 0; + if (*cap_req->list.array[i] == LTE_RAT_Type_nr) { + ASN_SEQUENCE_ADD(&ue_cap->criticalExtensions.choice.c1.choice.ueCapabilityInformation_r8.ue_CapabilityRAT_ContainerList.list, + &ue_CapabilityRAT_Container); + ue_cap->criticalExtensions.choice.c1.choice.ueCapabilityInformation_r8.ue_CapabilityRAT_ContainerList.list.array[i]->rat_Type = LTE_RAT_Type_nr; + asn_enc_rval_t enc_rval_nr = uper_encode_to_buffer(&asn_DEF_LTE_UL_DCCH_Message, NULL, (void *) &ul_dcch_msg, buffer, sizeof(buffer)); + AssertFatal (enc_rval_nr.encoded > 0, "ASN1 message encoding failed (%s, %jd)!\n", + enc_rval_nr.failed_type->name, enc_rval_nr.encoded); + enc_rval.encoded = enc_rval.encoded + enc_rval_nr.encoded; + xer_fprint(stdout, &asn_DEF_LTE_UL_DCCH_Message, (void *)&ul_dcch_msg); + LOG_A(RRC, "%s: NR_UECapInfo LTE_RAT_Type_nr Encoded %zd bits (%zd bytes)\n", + __FUNCTION__, enc_rval.encoded, (enc_rval.encoded+7)/8); + } + else if (*cap_req->list.array[i] == LTE_RAT_Type_eutra_nr) { + ASN_SEQUENCE_ADD(&ue_cap->criticalExtensions.choice.c1.choice.ueCapabilityInformation_r8.ue_CapabilityRAT_ContainerList.list, + &ue_CapabilityRAT_Container_mrdc); + ue_cap->criticalExtensions.choice.c1.choice.ueCapabilityInformation_r8.ue_CapabilityRAT_ContainerList.list.array[i]->rat_Type = LTE_RAT_Type_eutra_nr; + asn_enc_rval_t enc_rval_eutra_nr = uper_encode_to_buffer(&asn_DEF_LTE_UL_DCCH_Message, NULL, (void *) &ul_dcch_msg, buffer, sizeof(buffer)); + AssertFatal (enc_rval_eutra_nr.encoded > 0, "ASN1 message encoding failed (%s, %jd)!\n", + enc_rval_eutra_nr.failed_type->name, enc_rval_eutra_nr.encoded); + enc_rval.encoded = enc_rval.encoded + enc_rval_eutra_nr.encoded; + xer_fprint(stdout, &asn_DEF_LTE_UL_DCCH_Message, (void *)&ul_dcch_msg); + LOG_A(RRC, "%s: NR_UECapInfo LTE_RAT_Type_eutra_nr Encoded %zd bits (%zd bytes)\n", + __FUNCTION__, enc_rval.encoded, (enc_rval.encoded+7)/8); + } + rrc_data_req_ue ( + ctxt_pP, + DCCH, + rrc_mui++, + SDU_CONFIRM_NO, + (enc_rval.encoded + 7) / 8, + buffer, + PDCP_TRANSMISSION_MODE_CONTROL); + } +} + + + //----------------------------------------------------------------------------- void rrc_ue_process_ueCapabilityEnquiry( @@ -1686,7 +1850,8 @@ rrc_ue_process_ueCapabilityEnquiry( xer_fprint(stdout, &asn_DEF_LTE_UL_DCCH_Message, (void *)&ul_dcch_msg); } - LOG_I(RRC,"UECapabilityInformation Encoded %zd bits (%zd bytes)\n",enc_rval.encoded,(enc_rval.encoded+7)/8); + LOG_A(RRC, "%s: UECapabilityInformation Encoded %zd bits (%zd bytes)\n", + __FUNCTION__, enc_rval.encoded,(enc_rval.encoded+7)/8); rrc_data_req_ue ( ctxt_pP, DCCH, @@ -1696,9 +1861,57 @@ rrc_ue_process_ueCapabilityEnquiry( buffer, PDCP_TRANSMISSION_MODE_CONTROL); } + else if (*UECapabilityEnquiry->criticalExtensions.choice.c1.choice.ueCapabilityEnquiry_r8.ue_CapabilityRequest.list.array[i] + == LTE_RAT_Type_nr) { + ASN_SEQUENCE_ADD( + &ul_dcch_msg.message.choice.c1.choice.ueCapabilityInformation.criticalExtensions.choice.c1.choice.ueCapabilityInformation_r8.ue_CapabilityRAT_ContainerList.list, + &ue_CapabilityRAT_Container); + enc_rval = uper_encode_to_buffer(&asn_DEF_LTE_UL_DCCH_Message, NULL, (void *) &ul_dcch_msg, buffer, 100); + AssertFatal (enc_rval.encoded > 0, "ASN1 message encoding failed (%s, %jd)!\n", + enc_rval.failed_type->name, enc_rval.encoded); + + if ( LOG_DEBUGFLAG(DEBUG_ASN1) ) { + xer_fprint(stdout, &asn_DEF_LTE_UL_DCCH_Message, (void *)&ul_dcch_msg); + } + + LOG_A(RRC, "%s: NR_UECapabilityInformation Encoded %zd bits (%zd bytes)\n", + __FUNCTION__, enc_rval.encoded,(enc_rval.encoded+7)/8); + rrc_data_req_ue ( + ctxt_pP, + DCCH, + rrc_mui++, + SDU_CONFIRM_NO, + (enc_rval.encoded + 7) / 8, + buffer, + PDCP_TRANSMISSION_MODE_CONTROL); + } } } +static bool is_nr_r15_config_present(LTE_RRCConnectionReconfiguration_r8_IEs_t *c) +{ +#define NCE nonCriticalExtension +#define chk(x) do { \ + if ((x) == NULL) { \ + LOG_I(RRC, "NULL at %d\n", __LINE__); \ + return false; \ + } \ +} while(0) + chk(c); + chk(c->NCE); + chk(c->NCE->NCE); + chk(c->NCE->NCE->NCE); + chk(c->NCE->NCE->NCE->NCE); + chk(c->NCE->NCE->NCE->NCE->NCE); + chk(c->NCE->NCE->NCE->NCE->NCE->NCE); + chk(c->NCE->NCE->NCE->NCE->NCE->NCE->NCE); + chk(c->NCE->NCE->NCE->NCE->NCE->NCE->NCE->NCE); + return c->NCE->NCE->NCE->NCE->NCE->NCE->NCE->NCE->nr_Config_r15->present == + LTE_RRCConnectionReconfiguration_v1510_IEs__nr_Config_r15_PR_setup; + +#undef NCE +#undef chk +} //----------------------------------------------------------------------------- void @@ -1712,53 +1925,89 @@ rrc_ue_process_rrcConnectionReconfiguration( LOG_I(RRC,"[UE %d] Frame %d: Receiving from SRB1 (DL-DCCH), Processing RRCConnectionReconfiguration (eNB %d)\n", ctxt_pP->module_id,ctxt_pP->frame,eNB_index); - if (rrcConnectionReconfiguration->criticalExtensions.present == LTE_RRCConnectionReconfiguration__criticalExtensions_PR_c1) { + if (rrcConnectionReconfiguration->criticalExtensions.present == + LTE_RRCConnectionReconfiguration__criticalExtensions_PR_c1) { if (rrcConnectionReconfiguration->criticalExtensions.choice.c1.present == LTE_RRCConnectionReconfiguration__criticalExtensions__c1_PR_rrcConnectionReconfiguration_r8) { - LTE_RRCConnectionReconfiguration_r8_IEs_t *rrcConnectionReconfiguration_r8 = - &rrcConnectionReconfiguration->criticalExtensions.choice.c1.choice.rrcConnectionReconfiguration_r8; + LTE_RRCConnectionReconfiguration_r8_IEs_t *r_r8 = &rrcConnectionReconfiguration-> + criticalExtensions.choice.c1. + choice.rrcConnectionReconfiguration_r8; + + if (is_nr_r15_config_present(r_r8)) { + OCTET_STRING_t *nr_RadioBearer = r_r8->nonCriticalExtension->nonCriticalExtension-> + nonCriticalExtension->nonCriticalExtension->nonCriticalExtension-> + nonCriticalExtension->nonCriticalExtension->nonCriticalExtension-> + nr_RadioBearerConfig1_r15; + OCTET_STRING_t *nr_SecondaryCellGroup = r_r8->nonCriticalExtension->nonCriticalExtension-> + nonCriticalExtension->nonCriticalExtension->nonCriticalExtension-> + nonCriticalExtension->nonCriticalExtension->nonCriticalExtension-> + nr_Config_r15->choice.setup.nr_SecondaryCellGroupConfig_r15; + uint32_t total_size = nr_RadioBearer->size + nr_SecondaryCellGroup->size; + struct msg { + uint32_t RadioBearer_size; + uint32_t SecondaryCellGroup_size; + uint8_t trans_id; + uint8_t padding[3]; + uint8_t buffer[total_size]; + } msg; + + msg.RadioBearer_size = nr_RadioBearer->size; + msg.SecondaryCellGroup_size = nr_SecondaryCellGroup->size; + msg.trans_id = rrcConnectionReconfiguration->rrc_TransactionIdentifier; + memcpy(msg.buffer, nr_RadioBearer->buf, nr_RadioBearer->size); + memcpy(msg.buffer + nr_RadioBearer->size, nr_SecondaryCellGroup->buf, nr_SecondaryCellGroup->size); + + LOG_D(RRC, "nr_RadioBearerConfig1_r15 size %ld nr_SecondaryCellGroupConfig_r15 size %ld, sizeof(msg) = %zu\n", + nr_RadioBearer->size, + nr_SecondaryCellGroup->size, + sizeof(msg)); + + nsa_sendmsg_to_nrue(&msg, sizeof(msg), RRC_CONFIG_COMPLETE_REQ); + LOG_A(RRC, "Sent RRC_CONFIG_COMPLETE_REQ to the NR UE\n"); + } - if (rrcConnectionReconfiguration_r8->mobilityControlInfo) { + if (r_r8->mobilityControlInfo) { LOG_I(RRC,"Mobility Control Information is present\n"); rrc_ue_process_mobilityControlInfo( ctxt_pP, eNB_index, - rrcConnectionReconfiguration_r8->mobilityControlInfo); + r_r8->mobilityControlInfo); } - if (rrcConnectionReconfiguration_r8->measConfig != NULL) { + if (r_r8->measConfig != NULL) { LOG_I(RRC,"Measurement Configuration is present\n"); rrc_ue_process_measConfig(ctxt_pP, eNB_index, - rrcConnectionReconfiguration_r8->measConfig); + r_r8->measConfig); + r_r8->measConfig = NULL; } - if (rrcConnectionReconfiguration_r8->radioResourceConfigDedicated) { + if (r_r8->radioResourceConfigDedicated) { LOG_I(RRC,"Radio Resource Configuration is present\n"); - rrc_ue_process_radioResourceConfigDedicated(ctxt_pP,eNB_index, rrcConnectionReconfiguration_r8->radioResourceConfigDedicated); + rrc_ue_process_radioResourceConfigDedicated(ctxt_pP, + eNB_index, + r_r8->radioResourceConfigDedicated); + r_r8->radioResourceConfigDedicated = NULL; } //TTN for D2D //if RRCConnectionReconfiguration message includes the sl-CommConfig - if ((rrcConnectionReconfiguration_r8->nonCriticalExtension != NULL) - && (rrcConnectionReconfiguration_r8->nonCriticalExtension->nonCriticalExtension - != NULL) - && (rrcConnectionReconfiguration_r8->nonCriticalExtension->nonCriticalExtension->nonCriticalExtension - != NULL) - && (rrcConnectionReconfiguration_r8->nonCriticalExtension->nonCriticalExtension->nonCriticalExtension->nonCriticalExtension + if ((r_r8->nonCriticalExtension != NULL) + && (r_r8->nonCriticalExtension->nonCriticalExtension != NULL) + && (r_r8->nonCriticalExtension->nonCriticalExtension->nonCriticalExtension != NULL) + && (r_r8->nonCriticalExtension->nonCriticalExtension->nonCriticalExtension->nonCriticalExtension != NULL) + && (r_r8->nonCriticalExtension->nonCriticalExtension->nonCriticalExtension->nonCriticalExtension->nonCriticalExtension != NULL) - && (rrcConnectionReconfiguration_r8->nonCriticalExtension->nonCriticalExtension->nonCriticalExtension->nonCriticalExtension->nonCriticalExtension - != NULL) - && (rrcConnectionReconfiguration_r8->nonCriticalExtension->nonCriticalExtension->nonCriticalExtension->nonCriticalExtension->nonCriticalExtension->sl_CommConfig_r12 + && (r_r8->nonCriticalExtension->nonCriticalExtension->nonCriticalExtension->nonCriticalExtension->nonCriticalExtension->sl_CommConfig_r12 != NULL)) { - if (rrcConnectionReconfiguration_r8->nonCriticalExtension->nonCriticalExtension->nonCriticalExtension->nonCriticalExtension->nonCriticalExtension->sl_CommConfig_r12->commTxResources_r12->present != + if (r_r8->nonCriticalExtension->nonCriticalExtension->nonCriticalExtension->nonCriticalExtension->nonCriticalExtension->sl_CommConfig_r12->commTxResources_r12->present != LTE_SL_CommConfig_r12__commTxResources_r12_PR_NOTHING) { LOG_I(RRC,"sl-CommConfig is present\n"); //process sl-CommConfig rrc_ue_process_sidelink_radioResourceConfig(ctxt_pP->module_id,eNB_index, (LTE_SystemInformationBlockType18_r12_t *)NULL, (LTE_SystemInformationBlockType19_r12_t *)NULL, - rrcConnectionReconfiguration_r8->nonCriticalExtension->nonCriticalExtension->nonCriticalExtension->nonCriticalExtension->nonCriticalExtension->sl_CommConfig_r12, + r_r8->nonCriticalExtension->nonCriticalExtension->nonCriticalExtension->nonCriticalExtension->nonCriticalExtension->sl_CommConfig_r12, (LTE_SL_DiscConfig_r12_t *)NULL ); } @@ -1766,36 +2015,37 @@ rrc_ue_process_rrcConnectionReconfiguration( /* //if RRCConnectionReconfiguration message includes the sl-DiscConfig - if (rrcConnectionReconfiguration_r8->nonCriticalExtension->nonCriticalExtension->nonCriticalExtension->nonCriticalExtension->nonCriticalExtension->sl_DiscConfig_r12->discTxResources_r12->present != SL_DiscConfig_r12__discTxResources_r12_PR_NOTHING ){ + if (r_r8->nonCriticalExtension->nonCriticalExtension->nonCriticalExtension->nonCriticalExtension->nonCriticalExtension->sl_DiscConfig_r12->discTxResources_r12->present != SL_DiscConfig_r12__discTxResources_r12_PR_NOTHING ){ LOG_I(RRC,"sl-DiscConfig is present\n"); //process sl-DiscConfig rrc_ue_process_sidelink_radioResourceConfig(ctxt_pP->module_id,eNB_index, (SystemInformationBlockType18_r12_t *)NULL, (SystemInformationBlockType19_r12_t *)NULL, (SL_CommConfig_r12_t* )NULL, - rrcConnectionReconfiguration_r8->nonCriticalExtension->nonCriticalExtension->nonCriticalExtension->nonCriticalExtension->nonCriticalExtension->sl_DiscConfig_r12 + r_r8->nonCriticalExtension->nonCriticalExtension->nonCriticalExtension->nonCriticalExtension->nonCriticalExtension->sl_DiscConfig_r12 ); } */ /* Check if there is dedicated NAS information to forward to NAS */ - if (rrcConnectionReconfiguration_r8->dedicatedInfoNASList != NULL) { + if (r_r8->dedicatedInfoNASList != NULL) { int list_count; uint32_t pdu_length; uint8_t *pdu_buffer; MessageDef *msg_p; - for (list_count = 0; list_count < rrcConnectionReconfiguration_r8->dedicatedInfoNASList->list.count; list_count++) { - pdu_length = rrcConnectionReconfiguration_r8->dedicatedInfoNASList->list.array[list_count]->size; - pdu_buffer = rrcConnectionReconfiguration_r8->dedicatedInfoNASList->list.array[list_count]->buf; + for (list_count = 0; list_count < r_r8->dedicatedInfoNASList->list.count; list_count++) { + pdu_length = r_r8->dedicatedInfoNASList->list.array[list_count]->size; + pdu_buffer = r_r8->dedicatedInfoNASList->list.array[list_count]->buf; msg_p = itti_alloc_new_message(TASK_RRC_UE, 0, NAS_CONN_ESTABLI_CNF); NAS_CONN_ESTABLI_CNF(msg_p).errCode = AS_SUCCESS; NAS_CONN_ESTABLI_CNF(msg_p).nasMsg.length = pdu_length; NAS_CONN_ESTABLI_CNF(msg_p).nasMsg.data = pdu_buffer; itti_send_msg_to_task(TASK_NAS_UE, ctxt_pP->instance, msg_p); } + LOG_D(RRC, "Sent NAS_CONN_ESTABLI_CNF to NAS layer via itti!\n"); - free (rrcConnectionReconfiguration_r8->dedicatedInfoNASList); + free (r_r8->dedicatedInfoNASList); } #if ENABLE_RAL @@ -1945,6 +2195,7 @@ rrc_ue_decode_dcch( const protocol_ctxt_t *const ctxt_pP, const rb_id_t Srb_id, const uint8_t *const Buffer, + const uint32_t Buffer_size, const uint8_t eNB_indexP ) //----------------------------------------------------------------------------- @@ -1962,11 +2213,18 @@ rrc_ue_decode_dcch( return; } - uper_decode(NULL, + asn_dec_rval_t dec_rval = uper_decode(NULL, &asn_DEF_LTE_DL_DCCH_Message, (void **)&dl_dcch_msg, (uint8_t *)Buffer, - RRC_BUF_SIZE,0,0); + Buffer_size, 0, 0); + + if (dec_rval.code != RC_OK && dec_rval.consumed == 0) + { + LOG_E(RRC, "%s: Failed to decode LTE_DL_DCC_Msg\n", __FUNCTION__); + SEQUENCE_free(&asn_DEF_LTE_DL_DCCH_Message, dl_dcch_msg, ASFM_FREE_EVERYTHING); + return; + } if ( LOG_DEBUGFLAG(DEBUG_ASN1) ) { xer_fprint(stdout,&asn_DEF_LTE_DL_DCCH_Message,(void *)dl_dcch_msg); @@ -2055,7 +2313,8 @@ rrc_ue_decode_dcch( rrc_ue_generate_RRCConnectionReconfigurationComplete( ctxt_pP, target_eNB_index, - dl_dcch_msg->message.choice.c1.choice.rrcConnectionReconfiguration.rrc_TransactionIdentifier); + dl_dcch_msg->message.choice.c1.choice.rrcConnectionReconfiguration.rrc_TransactionIdentifier, + NULL); UE_rrc_inst[ctxt_pP->module_id].Info[eNB_indexP].State = RRC_HO_EXECUTION; UE_rrc_inst[ctxt_pP->module_id].Info[target_eNB_index].State = RRC_RECONFIGURED; LOG_I(RRC, "[UE %d] State = RRC_RECONFIGURED during HO (eNB %d)\n", @@ -2109,7 +2368,8 @@ rrc_ue_decode_dcch( rrc_ue_generate_RRCConnectionReconfigurationComplete( ctxt_pP, eNB_indexP, - dl_dcch_msg->message.choice.c1.choice.rrcConnectionReconfiguration.rrc_TransactionIdentifier); + dl_dcch_msg->message.choice.c1.choice.rrcConnectionReconfiguration.rrc_TransactionIdentifier, + NULL); UE_rrc_inst[ctxt_pP->module_id].Info[eNB_indexP].State = RRC_RECONFIGURED; LOG_I(RRC, "[UE %d] State = RRC_RECONFIGURED (eNB %d)\n", ctxt_pP->module_id, @@ -2178,6 +2438,12 @@ rrc_ue_decode_dcch( send_ue_information ++; } + UE_RRC_INFO *info = &UE_rrc_inst[ctxt_pP->module_id].Info[eNB_indexP]; + if (info->dl_dcch_msg != NULL) { + SEQUENCE_free(&asn_DEF_LTE_DL_DCCH_Message, info->dl_dcch_msg, ASFM_FREE_EVERYTHING); + } + info->dl_dcch_msg = dl_dcch_msg; + dl_dcch_msg = NULL; break; case LTE_DL_DCCH_MessageType__c1_PR_rrcConnectionRelease: @@ -2212,10 +2478,53 @@ rrc_ue_decode_dcch( LOG_I(RRC, "[UE %d] Received Capability Enquiry (eNB %d)\n", ctxt_pP->module_id, eNB_indexP); - rrc_ue_process_ueCapabilityEnquiry( - ctxt_pP, - &dl_dcch_msg->message.choice.c1.choice.ueCapabilityEnquiry, - eNB_indexP); + + LTE_UE_CapabilityRequest_t *ue_cap = &dl_dcch_msg->message.choice.c1.choice.ueCapabilityEnquiry.criticalExtensions. + choice.c1.choice.ueCapabilityEnquiry_r8.ue_CapabilityRequest; + bool have_received_nrue_cap = false; + for (int i = 0; i < ue_cap->list.count; i++) { + if (*ue_cap->list.array[i] == LTE_RAT_Type_nr || *ue_cap->list.array[i] == LTE_RAT_Type_eutra_nr) { + have_received_nrue_cap = true; + break; + } + } + if (have_received_nrue_cap) { + LTE_UECapabilityEnquiry_t *ueCapabilityEnquiry_nsa = &dl_dcch_msg->message.choice.c1.choice.ueCapabilityEnquiry; + OCTET_STRING_t * requestedFreqBandsNR = ueCapabilityEnquiry_nsa-> + criticalExtensions.choice.c1.choice.ueCapabilityEnquiry_r8.nonCriticalExtension-> + nonCriticalExtension->nonCriticalExtension->nonCriticalExtension-> + nonCriticalExtension->requestedFreqBandsNR_MRDC_r15; + nsa_sendmsg_to_nrue(requestedFreqBandsNR->buf, requestedFreqBandsNR->size, NRUE_CAPABILITY_ENQUIRY); + LOG_A(RRC, "Second ueCapabilityEnquiry (request for NR capabilities) sent to NR UE with size %zu\n", + requestedFreqBandsNR->size); + // Save ueCapabilityEnquiry so we can use in nsa mode after nrUE response is received + UE_RRC_INFO *info = &UE_rrc_inst[ctxt_pP->module_id].Info[eNB_indexP]; + if (info->dl_dcch_msg != NULL) { + info->dl_dcch_msg = NULL; + } + info->dl_dcch_msg = dl_dcch_msg; + dl_dcch_msg = NULL; + } else if (get_softmodem_params()->nsa && !have_received_nrue_cap) { + LTE_UECapabilityEnquiry_t *ueCapabilityEnquiry_nsa = &dl_dcch_msg->message.choice.c1.choice.ueCapabilityEnquiry; + OCTET_STRING_t * requestedFreqBandsNR = ueCapabilityEnquiry_nsa-> + criticalExtensions.choice.c1.choice.ueCapabilityEnquiry_r8.nonCriticalExtension-> + nonCriticalExtension->nonCriticalExtension->nonCriticalExtension-> + nonCriticalExtension->requestedFreqBandsNR_MRDC_r15; + nsa_sendmsg_to_nrue(requestedFreqBandsNR->buf, requestedFreqBandsNR->size, UE_CAPABILITY_ENQUIRY); + LOG_A(RRC, "Initial ueCapabilityEnquiry sent to NR UE with size %zu\n", requestedFreqBandsNR->size); + // Save ueCapabilityEnquiry so we can use in nsa mode after nrUE response is received + UE_RRC_INFO *info = &UE_rrc_inst[ctxt_pP->module_id].Info[eNB_indexP]; + if (info->dl_dcch_msg != NULL) { + info->dl_dcch_msg = NULL; + } + info->dl_dcch_msg = dl_dcch_msg; + dl_dcch_msg = NULL; + } else { + rrc_ue_process_ueCapabilityEnquiry( + ctxt_pP, + &dl_dcch_msg->message.choice.c1.choice.ueCapabilityEnquiry, + eNB_indexP); + } break; case LTE_DL_DCCH_MessageType__c1_PR_counterCheck: @@ -2872,16 +3181,18 @@ int decode_SIB1( const protocol_ctxt_t *const ctxt_pP, const uint8_t eNB_index, } LOG_I( RRC, "PLMN %d MCC %0*d, MNC %0*d\n", i + 1, mccdigits, mcc, mncdigits, mnc); - // search internal table for provider name - int plmn_ind = 0; - while (plmn_data[plmn_ind].mcc > 0) { + // search internal table for provider name + const size_t num_plmn_data = sizeof(plmn_data) / sizeof(plmn_data[0]); + for (size_t plmn_ind = 0;; ++plmn_ind) { + if (plmn_ind == num_plmn_data) { + LOG_E( RRC, "Did not find name from internal table for %u %u\n", mcc, mnc); + break; + } if ((plmn_data[plmn_ind].mcc == mcc) && (plmn_data[plmn_ind].mnc == mnc)) { LOG_I( RRC, "Found %s (name from internal table)\n", plmn_data[plmn_ind].oper_short ); break; } - - plmn_ind++; } } LOG_I( RRC, "TAC 0x%04x\n", @@ -4019,12 +4330,48 @@ void ue_meas_filtering( const protocol_ctxt_t *const ctxt_pP, const uint8_t eNB_ } } } +//Below routine implements Measurement Reporting procedure from 36.331 Section 5.5.5 +//----------------------------------------------------------------------------- +void rrc_ue_generate_nrMeasurementReport(protocol_ctxt_t *const ctxt_pP, uint8_t eNB_index ) { + uint8_t buffer[RRC_BUF_SIZE]; + UE_RRC_INST *ue = &UE_rrc_inst[ctxt_pP->module_id]; + uint8_t target_eNB_offset = ue->Info[0].handoverTarget; + LTE_PhysCellId_t targetCellId = ue->HandoverInfoUe.targetCellId; + + for (int i = 0; i < MAX_MEAS_ID; i++) { + if (ue->measReportList[eNB_index][i] != NULL) { + LTE_MeasId_t measId = ue->measReportList[eNB_index][i]->measId; + long rsrp_s = binary_search_float(RSRP_meas_mapping, 98, ue->rsrp_db_filtered[eNB_index]); + long rsrq_s = binary_search_float(RSRQ_meas_mapping, 35, ue->rsrq_db_filtered[eNB_index]); + long rsrp_tar = binary_search_float(RSRP_meas_mapping, 98, ue->rsrp_db_filtered[target_eNB_offset]); + long rsrq_tar = binary_search_float(RSRQ_meas_mapping, 35, ue->rsrq_db_filtered[target_eNB_offset]); + + LOG_I(RRC,"[UE %d] Frame %d: source eNB: %d target eNB: %d servingCell(%d) targetCell(%ld)\n", + ctxt_pP->module_id, + ctxt_pP->frame, + eNB_index, + target_eNB_offset, + get_adjacent_cell_id(ctxt_pP->module_id, eNB_index), + targetCellId); + + if (ctxt_pP->frame != 0) { + LOG_I(RRC, "measId %ld, targetCellId %ld, rsrp_s %ld, rsrq_s %ld, rsrp_t %ld, rsrq_t %ld\n", + measId, targetCellId, rsrp_s, rsrq_s, rsrp_tar, rsrq_tar); + ssize_t size = do_nrMeasurementReport(buffer, sizeof(buffer), measId, targetCellId, rsrp_s, rsrq_s, rsrp_tar, rsrq_tar); + AssertFatal(size >= 0, "do_nrMeasurementReport failed \n"); + LOG_I(RRC, "[UE %d] Frame %d : Generating Measurement Report for eNB %d\n", + ctxt_pP->module_id, ctxt_pP->frame, eNB_index); + int result = pdcp_data_req(ctxt_pP, SRB_FLAG_YES, DCCH, rrc_mui++, 0, size, buffer, PDCP_TRANSMISSION_MODE_DATA,NULL, NULL); + AssertFatal (result == TRUE, "PDCP data request failed!\n"); + } + } + } +} //Below routine implements Measurement Reporting procedure from 36.331 Section 5.5.5 //----------------------------------------------------------------------------- void rrc_ue_generate_MeasurementReport(protocol_ctxt_t *const ctxt_pP, uint8_t eNB_index ) { - uint8_t buffer[32], size; - uint8_t i; + uint8_t buffer[RRC_BUF_SIZE]; uint8_t target_eNB_offset; LTE_MeasId_t measId; LTE_PhysCellId_t targetCellId; @@ -4038,7 +4385,7 @@ void rrc_ue_generate_MeasurementReport(protocol_ctxt_t *const ctxt_pP, uint8_t e nElem1 = 35; target_eNB_offset = UE_rrc_inst[ctxt_pP->module_id].Info[0].handoverTarget; // eNB_offset of target eNB: used to obtain the mod_id of target eNB - for (i=0; i<MAX_MEAS_ID; i++) { + for (int i = 0; i < MAX_MEAS_ID; i++) { if (UE_rrc_inst[ctxt_pP->module_id].measReportList[0][i] != NULL) { measId = UE_rrc_inst[ctxt_pP->module_id].measReportList[0][i]->measId; // Note: Values in the meas report have to be the mapped values...to implement binary search for LUT @@ -4046,7 +4393,7 @@ void rrc_ue_generate_MeasurementReport(protocol_ctxt_t *const ctxt_pP, uint8_t e rsrp_s = binary_search_float(RSRP_meas_mapping,nElem, rsrp_filtered); rsrq_filtered = UE_rrc_inst[ctxt_pP->module_id].rsrq_db_filtered[eNB_index];//nid_cell]; //RSRQ of serving cell rsrq_s = binary_search_float(RSRQ_meas_mapping,nElem1,rsrq_filtered);//mapped RSRQ of serving cell - LOG_D(RRC,"[UE %d] Frame %d: source eNB %d :rsrp_s: %ld rsrq_s: %ld rsrp_filtered: %f rsrq_filtered: %f \n", + LOG_I(RRC,"[UE %d] Frame %d: source eNB %d :rsrp_s: %ld rsrq_s: %ld rsrp_filtered: %f rsrq_filtered: %f \n", ctxt_pP->module_id, ctxt_pP->frame, eNB_index, @@ -4056,7 +4403,7 @@ void rrc_ue_generate_MeasurementReport(protocol_ctxt_t *const ctxt_pP, uint8_t e rsrq_filtered); rsrp_t = binary_search_float(RSRP_meas_mapping,nElem,UE_rrc_inst[ctxt_pP->module_id].rsrp_db_filtered[target_eNB_offset]); //RSRP of target cell rsrq_t = binary_search_float(RSRQ_meas_mapping,nElem1,UE_rrc_inst[ctxt_pP->module_id].rsrq_db_filtered[target_eNB_offset]); //RSRQ of target cell - LOG_D(RRC,"[UE %d] Frame %d: target eNB %d :rsrp_t: %ld rsrq_t: %ld rsrp_filtered: %f rsrq_filtered: %f \n", + LOG_I(RRC,"[UE %d] Frame %d: target eNB %d :rsrp_t: %ld rsrq_t: %ld rsrp_filtered: %f rsrq_filtered: %f \n", ctxt_pP->module_id, ctxt_pP->frame, target_eNB_offset, @@ -4069,7 +4416,7 @@ void rrc_ue_generate_MeasurementReport(protocol_ctxt_t *const ctxt_pP, uint8_t e if (pframe!=ctxt_pP->frame) { pframe=ctxt_pP->frame; - LOG_D(RRC, "[UE %d] Frame %ld: doing MeasReport: servingCell(%ld) targetCell(%ld) rsrp_s(%ld) rsrq_s(%ld) rsrp_t(%ld) rsrq_t(%ld) \n", + LOG_I(RRC, "[UE %d] Frame %ld: doing MeasReport: servingCell(%ld) targetCell(%ld) rsrp_s(%ld) rsrq_s(%ld) rsrp_t(%ld) rsrq_t(%ld) \n", ctxt_pP->module_id, (long int)ctxt_pP->frame, (long int)get_adjacent_cell_id(ctxt_pP->module_id, eNB_index), @@ -4078,9 +4425,11 @@ void rrc_ue_generate_MeasurementReport(protocol_ctxt_t *const ctxt_pP, uint8_t e (long int)rsrq_s, (long int)rsrp_t, (long int)rsrq_t); - size = do_MeasurementReport(ctxt_pP->module_id, buffer,measId,targetCellId,rsrp_s,rsrq_s,rsrp_t,rsrq_t); - LOG_I(RRC, "[UE %d] Frame %d : Generating Measurement Report for eNB %d\n", - ctxt_pP->module_id, ctxt_pP->frame, eNB_index); + ssize_t size = do_MeasurementReport(ctxt_pP->module_id, buffer, sizeof(buffer), + measId, targetCellId, rsrp_s, rsrq_s, rsrp_t, rsrq_t); + AssertFatal(size >= 0, "do_MeasurementReport failed \n"); + LOG_I(RRC, "[UE %d] Frame %d : Generating Measurement Report for eNB %d. Size is %zu\n", + ctxt_pP->module_id, ctxt_pP->frame, eNB_index, size); result = pdcp_data_req(ctxt_pP, SRB_FLAG_YES, DCCH, rrc_mui++, 0, size, buffer, PDCP_TRANSMISSION_MODE_DATA,NULL, NULL); AssertFatal (result == TRUE, "PDCP data request failed!\n"); //LOG_D(RRC, "[UE %d] Frame %d Sending MeasReport (%d bytes) through DCCH%d to PDCP \n",ue_mod_idP,frameP, size, DCCH); @@ -4092,6 +4441,39 @@ void rrc_ue_generate_MeasurementReport(protocol_ctxt_t *const ctxt_pP, uint8_t e } } +static bool does_rrcConnReconfig_have_nr(const UE_RRC_INST *ue) { + for (int i = 0; i < NB_CNX_UE; i++) { + for (int j = 0; j < MAX_MEAS_ID; j++) { + LTE_ReportConfigId_t reportConfigId = ue->MeasId[i][j]->reportConfigId; + AssertFatal(reportConfigId >= 1 && reportConfigId <= MAX_MEAS_CONFIG, "Bad index\n"); + const LTE_ReportConfigToAddMod_t *rc = ue->ReportConfig[i][reportConfigId-1]; + if (rc == NULL) { + LOG_D(RRC, "UE_rrc_inst[ctxt_pP->module_id]->ReportConfig[%d][%ld] = NULL\n", i, reportConfigId-1); + continue; + } + if (rc->reportConfig.present != LTE_ReportConfigToAddMod__reportConfig_PR_reportConfigInterRAT) { + LOG_D(RRC, "reportConfig.present = %d, not LTE_ReportConfigToAddMod__reportConfig_PR_reportConfigInterRAT\n", + rc->reportConfig.present); + continue; + } + LTE_ReportConfigInterRAT_t irat = rc->reportConfig.choice.reportConfigInterRAT; + if (irat.triggerType.present != LTE_ReportConfigInterRAT__triggerType_PR_event) { + LOG_D(RRC, "irat.triggerType.present = %d, not LTE_ReportConfigInterRAT__triggerType_PR_event\n", + irat.triggerType.present); + continue; + } + if (irat.triggerType.choice.event.eventId.present != LTE_ReportConfigInterRAT__triggerType__event__eventId_PR_eventB1_NR_r15) { + LOG_D(RRC, "irat.triggerType.choice.event.eventId.present = %d\n", + irat.triggerType.choice.event.eventId.present); + continue; + } + return true; + } + } + return false; +} + + // Measurement report triggering, described in 36.331 Section 5.5.4.1: called periodically //----------------------------------------------------------------------------- void ue_measurement_report_triggering(protocol_ctxt_t *const ctxt_pP, const uint8_t eNB_index ) { @@ -4105,35 +4487,34 @@ void ue_measurement_report_triggering(protocol_ctxt_t *const ctxt_pP, const uint long a3_offset; LTE_MeasObjectId_t measObjId; LTE_ReportConfigId_t reportConfigId; - + UE_RRC_INST *ue = &UE_rrc_inst[ctxt_pP->module_id]; for(i=0 ; i<NB_CNX_UE ; i++) { for(j=0 ; j<MAX_MEAS_ID ; j++) { - if(UE_rrc_inst[ctxt_pP->module_id].MeasId[i][j] != NULL) { - measObjId = UE_rrc_inst[ctxt_pP->module_id].MeasId[i][j]->measObjectId; - reportConfigId = UE_rrc_inst[ctxt_pP->module_id].MeasId[i][j]->reportConfigId; + if(ue->MeasId[i][j] != NULL) { + measObjId = ue->MeasId[i][j]->measObjectId; + reportConfigId = ue->MeasId[i][j]->reportConfigId; - if( /*UE_rrc_inst[ctxt_pP->module_id].MeasId[i][j] != NULL && */ UE_rrc_inst[ctxt_pP->module_id].MeasObj[i][measObjId-1] != NULL) { - if(UE_rrc_inst[ctxt_pP->module_id].MeasObj[i][measObjId-1]->measObject.present == LTE_MeasObjectToAddMod__measObject_PR_measObjectEUTRA) { + if(ue->MeasObj[i][measObjId-1] != NULL) { + if(ue->MeasObj[i][measObjId-1]->measObject.present == LTE_MeasObjectToAddMod__measObject_PR_measObjectEUTRA) { /* consider any neighboring cell detected on the associated frequency to be * applicable when the concerned cell is not included in the blackCellsToAddModList * defined within the VarMeasConfig for this measId */ - // LOG_I(RRC,"event %d %d %p \n", measObjId,reportConfigId, UE_rrc_inst[ctxt_pP->module_id].ReportConfig[i][reportConfigId-1]); - if((UE_rrc_inst[ctxt_pP->module_id].ReportConfig[i][reportConfigId-1] != NULL) && - (UE_rrc_inst[ctxt_pP->module_id].ReportConfig[i][reportConfigId-1]->reportConfig.present == LTE_ReportConfigToAddMod__reportConfig_PR_reportConfigEUTRA) && - (UE_rrc_inst[ctxt_pP->module_id].ReportConfig[i][reportConfigId-1]->reportConfig.choice.reportConfigEUTRA.triggerType.present == + // LOG_I(RRC,"event %d %d %p \n", measObjId,reportConfigId, ue->ReportConfig[i][reportConfigId-1]); + if((ue->ReportConfig[i][reportConfigId-1] != NULL) && + (ue->ReportConfig[i][reportConfigId-1]->reportConfig.present == LTE_ReportConfigToAddMod__reportConfig_PR_reportConfigEUTRA) && + (ue->ReportConfig[i][reportConfigId-1]->reportConfig.choice.reportConfigEUTRA.triggerType.present == LTE_ReportConfigEUTRA__triggerType_PR_event)) { - hys = UE_rrc_inst[ctxt_pP->module_id].ReportConfig[i][reportConfigId-1]->reportConfig.choice.reportConfigEUTRA.triggerType.choice.event.hysteresis; - ttt_ms = timeToTrigger_ms[UE_rrc_inst[ctxt_pP->module_id].ReportConfig[i][reportConfigId + hys = ue->ReportConfig[i][reportConfigId-1]->reportConfig.choice.reportConfigEUTRA.triggerType.choice.event.hysteresis; + ttt_ms = timeToTrigger_ms[ue->ReportConfig[i][reportConfigId -1]->reportConfig.choice.reportConfigEUTRA.triggerType.choice.event.timeToTrigger]; // Freq specific offset of neighbor cell freq - ofn = 5;//((UE_rrc_inst[ctxt_pP->module_id].MeasObj[i][measObjId-1]->measObject.choice.measObjectEUTRA.offsetFreq != NULL) ? - // *UE_rrc_inst[ctxt_pP->module_id].MeasObj[i][measObjId-1]->measObject.choice.measObjectEUTRA.offsetFreq : 15); // /* 15 is the Default */ + ofn = 5;//((ue->MeasObj[i][measObjId-1]->measObject.choice.measObjectEUTRA.offsetFreq != NULL) ? + // *ue->MeasObj[i][measObjId-1]->measObject.choice.measObjectEUTRA.offsetFreq : 15); // /* 15 is the Default */ // cellIndividualOffset of neighbor cell - not defined yet ocn = 0; - a3_offset = UE_rrc_inst[ctxt_pP->module_id].ReportConfig[i][reportConfigId - -1]->reportConfig.choice.reportConfigEUTRA.triggerType.choice.event.eventId.choice.eventA3.a3_Offset; + a3_offset = ue->ReportConfig[i][reportConfigId-1]->reportConfig.choice.reportConfigEUTRA.triggerType.choice.event.eventId.choice.eventA3.a3_Offset; - switch (UE_rrc_inst[ctxt_pP->module_id].ReportConfig[i][reportConfigId-1]->reportConfig.choice.reportConfigEUTRA.triggerType.choice.event.eventId.present) { + switch (ue->ReportConfig[i][reportConfigId-1]->reportConfig.choice.reportConfigEUTRA.triggerType.choice.event.eventId.present) { case LTE_ReportConfigEUTRA__triggerType__event__eventId_PR_eventA1: LOG_D(RRC,"[UE %d] Frame %d : A1 event: check if serving becomes better than threshold\n", ctxt_pP->module_id, ctxt_pP->frame); @@ -4153,28 +4534,25 @@ void ue_measurement_report_triggering(protocol_ctxt_t *const ctxt_pP, const uint ctxt_pP->frame, eNB_index, i,j,ofn,ocn,hys,ofs,ocs,a3_offset,ttt_ms)) && - (UE_rrc_inst[ctxt_pP->module_id].Info[0].State >= RRC_CONNECTED) && - (UE_rrc_inst[ctxt_pP->module_id].Info[0].T304_active == 0 ) && - (UE_rrc_inst[ctxt_pP->module_id].HandoverInfoUe.measFlag == 1)) { + (ue->Info[0].State >= RRC_CONNECTED) && + (ue->Info[0].T304_active == 0 ) && + (ue->HandoverInfoUe.measFlag == 1)) { //trigger measurement reporting procedure (36.331, section 5.5.5) - if (UE_rrc_inst[ctxt_pP->module_id].measReportList[i][j] == NULL) { - UE_rrc_inst[ctxt_pP->module_id].measReportList[i][j] = malloc(sizeof(MEAS_REPORT_LIST)); + if (ue->measReportList[i][j] == NULL) { + ue->measReportList[i][j] = malloc(sizeof(MEAS_REPORT_LIST)); } - UE_rrc_inst[ctxt_pP->module_id].measReportList[i][j]->measId = UE_rrc_inst[ctxt_pP->module_id].MeasId[i][j]->measId; - UE_rrc_inst[ctxt_pP->module_id].measReportList[i][j]->numberOfReportsSent = 0; + ue->measReportList[i][j]->measId = ue->MeasId[i][j]->measId; + ue->measReportList[i][j]->numberOfReportsSent = 0; rrc_ue_generate_MeasurementReport( ctxt_pP, eNB_index); - UE_rrc_inst[ctxt_pP->module_id].HandoverInfoUe.measFlag = 1; - LOG_I(RRC,"[UE %d] Frame %d: A3 event detected, state: %d \n", - ctxt_pP->module_id, ctxt_pP->frame, UE_rrc_inst[ctxt_pP->module_id].Info[0].State); + ue->HandoverInfoUe.measFlag = 1; } else { - if(UE_rrc_inst[ctxt_pP->module_id].measReportList[i][j] != NULL) { - free(UE_rrc_inst[ctxt_pP->module_id].measReportList[i][j]); + if(ue->measReportList[i][j] != NULL) { + free(ue->measReportList[i][j]); } - - UE_rrc_inst[ctxt_pP->module_id].measReportList[i][j] = NULL; + ue->measReportList[i][j] = NULL; } break; @@ -4191,11 +4569,54 @@ void ue_measurement_report_triggering(protocol_ctxt_t *const ctxt_pP, const uint default: LOG_D(RRC,"Invalid ReportConfigEUTRA__triggerType__event__eventId: %d", - UE_rrc_inst[ctxt_pP->module_id].ReportConfig[i][j]->reportConfig.choice.reportConfigEUTRA.triggerType.present); + ue->ReportConfig[i][j]->reportConfig.choice.reportConfigEUTRA.triggerType.present); break; } } } + + if (ue->MeasObj[i][measObjId-1]->measObject.present == LTE_MeasObjectToAddMod__measObject_PR_measObjectNR_r15) { + if (!does_rrcConnReconfig_have_nr(ue)) + break; + LTE_ReportConfigInterRAT_t *rc = &ue->ReportConfig[i][reportConfigId-1]->reportConfig.choice.reportConfigInterRAT; + LTE_TimeToTrigger_t trig_per = rc->triggerType.choice.event.timeToTrigger; + ttt_ms = timeToTrigger_ms[trig_per]; + LOG_D(RRC, "[UE %d] Frame %d: B1_NR_r15 event. count %d, ttt %ld\n", + ctxt_pP->module_id, ctxt_pP->frame, ue->subframeCount, ttt_ms); + if (ue->subframeCount < ttt_ms) { + ++ue->subframeCount; + break; + } + ue->subframeCount = 0; + bool is_state_connected = false; + bool is_t304_inactive = false; + bool have_meas_flag = false; + if (ue->Info[0].State >= RRC_CONNECTED) + is_state_connected = true; + if (ue->Info[0].T304_active == 0) + is_t304_inactive = true; + if (ue->HandoverInfoUe.measFlag == 1) + have_meas_flag = true; + + if (is_state_connected && is_t304_inactive && have_meas_flag) { + LOG_I(RRC,"[UE %d] Frame %d: Triggering generation of Meas Report for NR_r15. count = %d\n", + ctxt_pP->module_id, ctxt_pP->frame, ue->subframeCount); + if (ue->measReportList[i][j] == NULL) { + ue->measReportList[i][j] = malloc(sizeof(MEAS_REPORT_LIST)); + } + ue->measReportList[i][j]->measId = ue->MeasId[i][j]->measId; + ue->measReportList[i][j]->numberOfReportsSent = 0; + rrc_ue_generate_nrMeasurementReport(ctxt_pP, eNB_index); + ue->HandoverInfoUe.measFlag = 1; + LOG_I(RRC,"[UE %d] Frame %d: RSRB detected, state: %d \n", + ctxt_pP->module_id, ctxt_pP->frame, ue->Info[0].State); + } else { + if(ue->measReportList[i][j] != NULL) { + free(ue->measReportList[i][j]); + } + ue->measReportList[i][j] = NULL; + } + } } } } @@ -4221,10 +4642,12 @@ uint8_t check_trigger_meas_event( uint8_t eNB_offset; // uint8_t currentCellIndex = frame_parms->Nid_cell; uint8_t tmp_offset; - LOG_D(RRC,"[UE %d] ofn(%ld) ocn(%ld) hys(%ld) ofs(%ld) ocs(%ld) a3_offset(%ld) ttt(%ld) rssi %3.1f\n", + LOG_D(RRC,"[UE %d] ofn(%ld) ocn(%ld) hys(%ld) ofs(%ld) ocs(%ld) ttt(%ld) rssi %3.1f\n", ue_mod_idP, - ofn,ocn,hys,ofs,ocs,a3_offset,ttt, + ofn,ocn,hys,ofs,ocs,ttt, 10*log10(get_RSSI(ue_mod_idP,0))-get_rx_total_gain_dB(ue_mod_idP,0)); + LOG_D(RRC, "[UE %d] Frame %d: num_adj: %d eNB_idx: %d, NB_eNB_INST: %d\n", + ue_mod_idP, frameP, get_n_adj_cells(ue_mod_idP,0), eNB_index, NB_eNB_INST); for (eNB_offset = 0; eNB_offset<1+get_n_adj_cells(ue_mod_idP,0); eNB_offset++) { /* RHS: Verify that idx 0 corresponds to currentCellIndex in rsrp array */ @@ -4447,6 +4870,7 @@ void *rrc_ue_task( void *args_p ) { instance = ITTI_MSG_DESTINATION_INSTANCE (msg_p); ue_mod_id = UE_INSTANCE_TO_MODULE_ID(instance); + /* TODO: Add case to handle nr-UE messages we want from nrUE RRC layer */ switch (ITTI_MSG_ID(msg_p)) { case TERMINATE_MESSAGE: LOG_W(RRC, " *** Exiting RRC thread\n"); @@ -4566,12 +4990,66 @@ void *rrc_ue_task( void *args_p ) { &ctxt, RRC_DCCH_DATA_IND (msg_p).dcch_index, RRC_DCCH_DATA_IND (msg_p).sdu_p, + RRC_DCCH_DATA_IND (msg_p).sdu_size, RRC_DCCH_DATA_IND (msg_p).eNB_index); // Message buffer has been processed, free it now. result = itti_free (ITTI_MSG_ORIGIN_ID(msg_p), RRC_DCCH_DATA_IND (msg_p).sdu_p); AssertFatal (result == EXIT_SUCCESS, "Failed to free memory (%d)!\n", result); break; + case RRC_DCCH_DATA_COPY_IND: + { + PROTOCOL_CTXT_SET_BY_MODULE_ID(&ctxt, RRC_DCCH_DATA_COPY_IND (msg_p).module_id, + ENB_FLAG_NO, RRC_DCCH_DATA_COPY_IND (msg_p).rnti, + RRC_DCCH_DATA_COPY_IND (msg_p).frame, + 0, + RRC_DCCH_DATA_COPY_IND (msg_p).eNB_index); + LOG_I(RRC, "[UE %d] Received %s. Now calling rrc_ue_process_ueCapabilityEnquiry\n", + ue_mod_id, ITTI_MSG_NAME (msg_p)); + rrc_dcch_data_copy_t *dl_dcch_buffer = (void *)RRC_DCCH_DATA_COPY_IND (msg_p).sdu_p; + AssertFatal(RRC_DCCH_DATA_COPY_IND (msg_p).sdu_size == sizeof(*dl_dcch_buffer), "Size of dl_dcch_buffer incorrect\n"); + rrc_ue_process_ueCapabilityEnquiry( + &ctxt, + &dl_dcch_buffer->dl_dcch_msg->message.choice.c1.choice.ueCapabilityEnquiry, + RRC_DCCH_DATA_COPY_IND (msg_p).eNB_index); + SEQUENCE_free(&asn_DEF_LTE_DL_DCCH_Message, dl_dcch_buffer->dl_dcch_msg, ASFM_FREE_EVERYTHING); + result = itti_free (ITTI_MSG_ORIGIN_ID(msg_p), RRC_DCCH_DATA_COPY_IND (msg_p).sdu_p); + AssertFatal (result == EXIT_SUCCESS, "Failed to free memory (%d)!\n", result); + break; + } + + case RRC_NRUE_CAP_INFO_IND: + { + PROTOCOL_CTXT_SET_BY_MODULE_ID(&ctxt, RRC_NRUE_CAP_INFO_IND (msg_p).module_id, + ENB_FLAG_NO, RRC_NRUE_CAP_INFO_IND (msg_p).rnti, + RRC_NRUE_CAP_INFO_IND (msg_p).frame, + 0, + RRC_NRUE_CAP_INFO_IND (msg_p).eNB_index); + LOG_I(RRC, "[UE %d] Received %s. Now calling rrc_ue_process_nrueCapabilityEnquiry\n", + ue_mod_id, ITTI_MSG_NAME (msg_p)); + rrc_nrue_cap_info_t *nrue_cap_info = (void *)RRC_NRUE_CAP_INFO_IND (msg_p).sdu_p; + AssertFatal(RRC_NRUE_CAP_INFO_IND (msg_p).sdu_size == sizeof(*nrue_cap_info), "Size of nrue_cap_info incorrect\n"); + rrc_ue_process_nrueCapabilityEnquiry( + &ctxt, + &nrue_cap_info->dl_dcch_msg->message.choice.c1.choice.ueCapabilityEnquiry, + nrue_cap_info, + RRC_NRUE_CAP_INFO_IND (msg_p).eNB_index); + SEQUENCE_free(&asn_DEF_LTE_DL_DCCH_Message, nrue_cap_info->dl_dcch_msg, ASFM_FREE_EVERYTHING); + result = itti_free (ITTI_MSG_ORIGIN_ID(msg_p), RRC_NRUE_CAP_INFO_IND (msg_p).sdu_p); + AssertFatal (result == EXIT_SUCCESS, "Failed to free memory (%d)!\n", result); + break; + } + case NAS_OAI_TUN_NSA: + { + LOG_D(NAS, "Received %s: length %lu. About to send this to the NR UE\n", ITTI_MSG_NAME (msg_p), + sizeof(NAS_OAI_TUN_NSA (msg_p).buffer)); + char buffer[RRC_BUF_SIZE]; + memcpy(buffer, NAS_OAI_TUN_NSA(msg_p).buffer, sizeof(buffer)); + nsa_sendmsg_to_nrue(buffer, sizeof(buffer), OAI_TUN_IFACE_NSA); + break; + } + + case NAS_KENB_REFRESH_REQ: memcpy((void *)UE_rrc_inst[ue_mod_id].kenb, (void *)NAS_KENB_REFRESH_REQ(msg_p).kenb, sizeof(UE_rrc_inst[ue_mod_id].kenb)); LOG_D(RRC, "[UE %d] Received %s: refreshed RRC::KeNB = " @@ -4900,7 +5378,8 @@ openair_rrc_top_init_ue( memset (UE_rrc_inst, 0, NB_UE_INST * sizeof(UE_RRC_INST)); LOG_D(RRC, "ALLOCATE %d Bytes for UE_RRC_INST @ %p\n", (unsigned int)(NB_UE_INST*sizeof(UE_RRC_INST)), UE_rrc_inst); // fill UE capability - UECap = fill_ue_capability (uecap_xer); + bool received_nr_msg = false; + UECap = fill_ue_capability (uecap_xer, received_nr_msg); for (module_id = 0; module_id < NB_UE_INST; module_id++) { UE_rrc_inst[module_id].UECap = UECap; @@ -5191,9 +5670,6 @@ void rrc_control_socket_init() { //-------------------------------------------------------- void *rrc_control_socket_thread_fct(void *arg) { - int prose_addr_len; - char send_buf[BUFSIZE]; - char receive_buf[BUFSIZE]; //int optval; int n; struct sidelink_ctrl_element *sl_ctrl_msg_recv = NULL; @@ -5212,20 +5688,28 @@ void *rrc_control_socket_thread_fct(void *arg) { int j = 0; int i = 0; //from the main program, listen for the incoming messages from control socket (ProSe App) - prose_addr_len = sizeof(prose_app_addr); //int enable_notification = 1; while (1) { LOG_I(RRC,"Listening to incoming connection from ProSe App \n"); // receive a message from ProSe App - memset(receive_buf, 0, BUFSIZE); - n = recvfrom(ctrl_sock_fd, receive_buf, BUFSIZE, 0, - (struct sockaddr *) &prose_app_addr, (socklen_t *)&prose_addr_len); + char receive_buf[MAX_MESSAGE_SIZE]; + memset(receive_buf, 0, sizeof(receive_buf)); + socklen_t prose_addr_len = sizeof(prose_app_addr); + n = recvfrom(ctrl_sock_fd, receive_buf, sizeof(receive_buf), MSG_TRUNC, + (struct sockaddr *) &prose_app_addr, &prose_addr_len); if (n < 0) { LOG_E(RRC, "ERROR: Failed to receive from ProSe App\n"); exit(EXIT_FAILURE); } + if (n == 0) { + LOG_E(RRC, "%s(%d). EOF for ctrl_sock_fd\n", __FUNCTION__, __LINE__); + } + if (n > MAX_MESSAGE_SIZE) { + LOG_E(RRC, "%s(%d). Message truncated. %d\n", __FUNCTION__, __LINE__, n); + exit(EXIT_FAILURE); + } //TODO: should store the address of ProSeApp [UE_rrc_inst] to be able to send UE state notification to the App //sl_ctrl_msg_recv = (struct sidelink_ctrl_element *) receive_buf; @@ -5233,6 +5717,7 @@ void *rrc_control_socket_thread_fct(void *arg) { memcpy((void *)sl_ctrl_msg_recv, (void *)receive_buf, sizeof(struct sidelink_ctrl_element)); //process the message + char send_buf[MAX_MESSAGE_SIZE]; switch (sl_ctrl_msg_recv->type) { case SESSION_INIT_REQ: if (LOG_DEBUGFLAG(DEBUG_CTRLSOCKET)) { @@ -5241,14 +5726,14 @@ void *rrc_control_socket_thread_fct(void *arg) { //TODO: get SL_UE_STATE from lower layer LOG_I(RRC,"Send UEStateInformation to ProSe App \n"); - memset(send_buf, 0, BUFSIZE); + memset(send_buf, 0, MAX_MESSAGE_SIZE); sl_ctrl_msg_send = calloc(1, sizeof(struct sidelink_ctrl_element)); sl_ctrl_msg_send->type = UE_STATUS_INFO; sl_ctrl_msg_send->sidelinkPrimitive.ue_state = UE_STATE_OFF_NETWORK; //off-network memcpy((void *)send_buf, (void *)sl_ctrl_msg_send, sizeof(struct sidelink_ctrl_element)); free(sl_ctrl_msg_send); - prose_addr_len = sizeof(prose_app_addr); - n = sendto(ctrl_sock_fd, (char *)send_buf, sizeof(struct sidelink_ctrl_element), 0, (struct sockaddr *)&prose_app_addr, prose_addr_len); + n = sendto(ctrl_sock_fd, (char *)send_buf, sizeof(struct sidelink_ctrl_element), 0, + (struct sockaddr *)&prose_app_addr, sizeof(prose_app_addr)); if (n < 0) { LOG_E(RRC, "ERROR: Failed to send to ProSe App\n"); @@ -5394,14 +5879,14 @@ void *rrc_control_socket_thread_fct(void *arg) { (LTE_MBSFN_AreaInfoList_r9_t *)NULL ); LOG_I(RRC,"Send GroupCommunicationEstablishResp to ProSe App\n"); - memset(send_buf, 0, BUFSIZE); + memset(send_buf, 0, MAX_MESSAGE_SIZE); sl_ctrl_msg_send = calloc(1, sizeof(struct sidelink_ctrl_element)); sl_ctrl_msg_send->type = GROUP_COMMUNICATION_ESTABLISH_RSP; sl_ctrl_msg_send->sidelinkPrimitive.slrb_id = 3; //slrb_id memcpy((void *)send_buf, (void *)sl_ctrl_msg_send, sizeof(struct sidelink_ctrl_element)); free(sl_ctrl_msg_send); - prose_addr_len = sizeof(prose_app_addr); - n = sendto(ctrl_sock_fd, (char *)send_buf, sizeof(struct sidelink_ctrl_element), 0, (struct sockaddr *)&prose_app_addr, prose_addr_len); + n = sendto(ctrl_sock_fd, (char *)send_buf, sizeof(struct sidelink_ctrl_element), 0, + (struct sockaddr *)&prose_app_addr, sizeof(prose_app_addr)); if (n < 0) { LOG_E(RRC, "ERROR: Failed to send to ProSe App\n"); @@ -5455,7 +5940,7 @@ void *rrc_control_socket_thread_fct(void *arg) { (LTE_MBSFN_AreaInfoList_r9_t *)NULL ); LOG_I(RRC,"Send GroupCommunicationReleaseResponse to ProSe App \n"); - memset(send_buf, 0, BUFSIZE); + memset(send_buf, 0, MAX_MESSAGE_SIZE); sl_ctrl_msg_send = calloc(1, sizeof(struct sidelink_ctrl_element)); sl_ctrl_msg_send->type = GROUP_COMMUNICATION_RELEASE_RSP; @@ -5469,8 +5954,8 @@ void *rrc_control_socket_thread_fct(void *arg) { memcpy((void *)send_buf, (void *)sl_ctrl_msg_send, sizeof(struct sidelink_ctrl_element)); free(sl_ctrl_msg_send); - prose_addr_len = sizeof(prose_app_addr); - n = sendto(ctrl_sock_fd, (char *)send_buf, sizeof(struct sidelink_ctrl_element), 0, (struct sockaddr *)&prose_app_addr, prose_addr_len); + n = sendto(ctrl_sock_fd, (char *)send_buf, sizeof(struct sidelink_ctrl_element), 0, + (struct sockaddr *)&prose_app_addr, sizeof(prose_app_addr)); if (n < 0) { LOG_E(RRC, "ERROR: Failed to send to ProSe App\n"); @@ -5598,14 +6083,14 @@ void *rrc_control_socket_thread_fct(void *arg) { (LTE_MBSFN_AreaInfoList_r9_t *)NULL ); LOG_I(RRC,"Send DirectCommunicationEstablishResp to ProSe App\n"); - memset(send_buf, 0, BUFSIZE); + memset(send_buf, 0, MAX_MESSAGE_SIZE); sl_ctrl_msg_send = calloc(1, sizeof(struct sidelink_ctrl_element)); sl_ctrl_msg_send->type = DIRECT_COMMUNICATION_ESTABLISH_RSP; sl_ctrl_msg_send->sidelinkPrimitive.slrb_id = 3; //slrb_id memcpy((void *)send_buf, (void *)sl_ctrl_msg_send, sizeof(struct sidelink_ctrl_element)); free(sl_ctrl_msg_send); - prose_addr_len = sizeof(prose_app_addr); - n = sendto(ctrl_sock_fd, (char *)send_buf, sizeof(struct sidelink_ctrl_element), 0, (struct sockaddr *)&prose_app_addr, prose_addr_len); + n = sendto(ctrl_sock_fd, (char *)send_buf, sizeof(struct sidelink_ctrl_element), 0, + (struct sockaddr *)&prose_app_addr, sizeof(prose_app_addr)); if (n < 0) { LOG_E(RRC, "ERROR: Failed to send to ProSe App\n"); @@ -5785,15 +6270,15 @@ void *rrc_control_socket_thread_fct(void *arg) { } LOG_I(RRC,"Send PC5EstablishRsp to ProSe App\n"); - memset(send_buf, 0, BUFSIZE); + memset(send_buf, 0, MAX_MESSAGE_SIZE); sl_ctrl_msg_send = calloc(1, sizeof(struct sidelink_ctrl_element)); sl_ctrl_msg_send->type = PC5S_ESTABLISH_RSP; sl_ctrl_msg_send->sidelinkPrimitive.pc5s_establish_rsp.slrbid_lcid28 = 10; sl_ctrl_msg_send->sidelinkPrimitive.pc5s_establish_rsp.slrbid_lcid29 = 10; sl_ctrl_msg_send->sidelinkPrimitive.pc5s_establish_rsp.slrbid_lcid30 = 10; memcpy((void *)send_buf, (void *)sl_ctrl_msg_send, sizeof(struct sidelink_ctrl_element)); - prose_addr_len = sizeof(prose_app_addr); - n = sendto(ctrl_sock_fd, (char *)send_buf, sizeof(struct sidelink_ctrl_element), 0, (struct sockaddr *)&prose_app_addr, prose_addr_len); + n = sendto(ctrl_sock_fd, (char *)send_buf, sizeof(struct sidelink_ctrl_element), 0, + (struct sockaddr *)&prose_app_addr, sizeof(prose_app_addr)); // free(sl_ctrl_msg_send); if (n < 0) { @@ -5833,27 +6318,24 @@ int decode_SL_Discovery_Message( const uint8_t eNB_index, const uint8_t *Sdu, const uint8_t Sdu_len) { - int prose_addr_len; - char send_buf[BUFSIZE]; + char send_buf[MAX_MESSAGE_SIZE]; int n; struct sidelink_ctrl_element *sl_ctrl_msg_send = NULL; //from the main program, listen for the incoming messages from control socket (ProSe App) - prose_addr_len = sizeof(prose_app_addr); //Store in Rx_buffer memcpy((void *)&UE_rrc_inst[ctxt_pP->module_id].SL_Discovery[0].Rx_buffer.Payload[0], (void *)Sdu, Sdu_len); UE_rrc_inst[ctxt_pP->module_id].SL_Discovery[0].Rx_buffer.payload_size = Sdu_len; - memset(send_buf, 0, BUFSIZE); + memset(send_buf, 0, MAX_MESSAGE_SIZE); //send to ProSeApp memcpy((void *)send_buf, (void *)Sdu, Sdu_len); - prose_addr_len = sizeof(prose_app_addr); sl_ctrl_msg_send = calloc(1, sizeof(struct sidelink_ctrl_element)); sl_ctrl_msg_send->type = PC5_DISCOVERY_MESSAGE; // TODO: Add a check for the SDU size. memcpy((void *)&sl_ctrl_msg_send->sidelinkPrimitive.pc5_discovery_message.payload[0], (void *) Sdu, PC5_DISCOVERY_PAYLOAD_SIZE); memcpy((void *)send_buf, (void *)sl_ctrl_msg_send, sizeof(struct sidelink_ctrl_element)); free(sl_ctrl_msg_send); - prose_addr_len = sizeof(prose_app_addr); - n = sendto(ctrl_sock_fd, (char *)send_buf, sizeof(struct sidelink_ctrl_element), 0, (struct sockaddr *)&prose_app_addr, prose_addr_len); + n = sendto(ctrl_sock_fd, (char *)send_buf, sizeof(struct sidelink_ctrl_element), 0, + (struct sockaddr *)&prose_app_addr, sizeof(prose_app_addr)); if (n < 0) { // TODO: We should not just exit if the Prose App has not yet attached. It creates a race condition. @@ -5977,3 +6459,235 @@ rrc_rx_tx_ue( return (RRC_OK); } +void *recv_msgs_from_nr_ue(void *args_p) +{ + itti_mark_task_ready (TASK_RRC_NSA_UE); + for (;;) + { + nsa_msg_t msg; + int recvLen = recvfrom(from_nr_ue_fd, &msg, sizeof(msg), + MSG_WAITALL | MSG_TRUNC, NULL, NULL); + if (recvLen == -1) + { + LOG_E(RRC, "%s: recvfrom: %s\n", __func__, strerror(errno)); + continue; + } + if (recvLen > sizeof(msg)) + { + LOG_E(NR_RRC, "%s: Received a truncated message %d\n", __func__, recvLen); + continue; + } + LOG_D(RRC, "We have received a %d msg (%d bytes). Calling process_nr_nsa_msg\n", msg.msg_type, recvLen); + process_nr_nsa_msg(&msg, recvLen); + } + +} + +void nsa_sendmsg_to_nrue(const void *message, size_t msg_len, Rrc_Msg_Type_t msg_type) +{ + LOG_I(RRC, "Entered %s \n", __FUNCTION__); + nsa_msg_t n_msg; + if (msg_len > sizeof(n_msg.msg_buffer)) + { + LOG_E(RRC, "%s: message too big: %zu\n", __func__, msg_len); + abort(); + } + n_msg.msg_type = msg_type; + memcpy(n_msg.msg_buffer, message, msg_len); + size_t to_send = sizeof(n_msg.msg_type) + msg_len; + + struct sockaddr_in sa = + { + .sin_family = AF_INET, + .sin_port = htons(6008 + ue_id_g * 2), + }; + int sent = sendto(to_nr_ue_fd, &n_msg, to_send, 0, + (struct sockaddr *)&sa, sizeof(sa)); + if (sent == -1) + { + LOG_E(RRC, "%s: sendto: %s\n", __func__, strerror(errno)); + return; + } + if (sent != to_send) + { + LOG_E(RRC, "%s: Short send %d != %zu\n", __func__, sent, to_send); + return; + } + LOG_I(RRC, "Sent a %d message to the nrUE (%d bytes) \n", msg_type, sent); +} + +void init_connections_with_nr_ue() +{ + struct sockaddr_in sa = + { + .sin_family = AF_INET, + .sin_port = htons(6007 + ue_id_g * 2), + }; + AssertFatal(from_nr_ue_fd == -1, "from_nr_ue_fd was assigned already"); + from_nr_ue_fd = socket(AF_INET, SOCK_DGRAM, 0); + if (from_nr_ue_fd == -1) + { + LOG_E(RRC, "%s: Error opening socket %d (%d:%s)\n", __FUNCTION__, from_nr_ue_fd, errno, strerror(errno)); + abort(); + } + + if (inet_aton(nsa_ipaddr, &sa.sin_addr) == 0) + { + LOG_E(RRC, "Bad nsa_ipaddr '%s'\n", nsa_ipaddr); + abort(); + } + + if (bind(from_nr_ue_fd, (struct sockaddr *) &sa, sizeof(sa)) == -1) + { + LOG_E(RRC,"%s: Failed to bind the socket\n", __FUNCTION__); + abort(); + } + + AssertFatal(to_nr_ue_fd == -1, "to_nr_ue_fd was assigned already"); + to_nr_ue_fd = socket(AF_INET, SOCK_DGRAM, 0); + if (to_nr_ue_fd == -1) + { + LOG_E(RRC, "%s: Error opening socket %d (%d:%s)\n", __FUNCTION__, to_nr_ue_fd, errno, strerror(errno)); + abort(); + } + +} + +void process_nr_nsa_msg(nsa_msg_t *msg, int msg_len) +{ + if (msg_len < sizeof(msg->msg_type)) + { + LOG_E(RRC, "Msg_len = %d\n", msg_len); + return; + } + LOG_D(RRC, "We are processing an NSA message %d \n", msg->msg_type); + Rrc_Msg_Type_t msg_type = msg->msg_type; + uint8_t *const msg_buffer = msg->msg_buffer; + msg_len -= sizeof(msg->msg_type); + bool received_nr_msg = true; + protocol_ctxt_t ctxt; + module_id_t module_id = 0; + eNB_index_t eNB_index = 0; + + switch (msg_type) + { + case NRUE_CAPABILITY_INFO: + { + LOG_I(RRC, "Create itti msg to send received NRUE_CAPABILITY_INFO to eNB\n"); + + MessageDef *message_p; + rrc_nrue_cap_info_t *nrue_cap_buf = itti_malloc (TASK_RRC_NSA_UE, + TASK_RRC_UE, + sizeof(rrc_nrue_cap_info_t)); + AssertFatal(msg_len <= sizeof(nrue_cap_buf->mesg), "msg_len = %d\n", msg_len); + memcpy(nrue_cap_buf->mesg, msg_buffer, msg_len); + nrue_cap_buf->mesg_len = msg_len; + UE_RRC_INFO *info = &UE_rrc_inst[module_id].Info[eNB_index]; + nrue_cap_buf->dl_dcch_msg = info->dl_dcch_msg; + info->dl_dcch_msg = NULL; + message_p = itti_alloc_new_message (TASK_RRC_UE, 0, RRC_NRUE_CAP_INFO_IND); + RRC_NRUE_CAP_INFO_IND (message_p).sdu_p = (void *)nrue_cap_buf; + RRC_NRUE_CAP_INFO_IND (message_p).sdu_size = sizeof(*nrue_cap_buf); + RRC_NRUE_CAP_INFO_IND (message_p).module_id = module_id; + RRC_NRUE_CAP_INFO_IND (message_p).rnti = info->rnti; + RRC_NRUE_CAP_INFO_IND (message_p).eNB_index = eNB_index; + itti_send_msg_to_task (TASK_RRC_UE, 0, message_p); + LOG_I(RRC, "Sent itti RRC_NRUE_CAP_INFO_IND\n"); + break; + } + case UE_CAPABILITY_DUMMY: + { + fill_ue_capability(NULL, received_nr_msg); + UE_rrc_inst[module_id].UECap = UE_rrc_inst->UECap; + UE_rrc_inst[module_id].UECapability = UE_rrc_inst->UECap->sdu; + UE_rrc_inst[module_id].UECapability_size = UE_rrc_inst->UECap->sdu_size; + + if (!is_en_dc_supported(UE_rrc_inst->UECap->UE_EUTRA_Capability)) + { + LOG_E(RRC, "en_dc is NOT supported! Not sending RRC_DCCH_DATA_COPY_IND to update UE_Capability_INFO\n"); + break; + } + + LOG_I(RRC, "Send itti msg to trigger processing of capabilites b/c we have a UE_CAPABILITY_DUMMY\n"); + MessageDef *message_p; + rrc_dcch_data_copy_t *dl_dcch_buffer = itti_malloc (TASK_RRC_NSA_UE, + TASK_RRC_UE, + sizeof(rrc_dcch_data_copy_t)); + UE_RRC_INFO *info = &UE_rrc_inst[module_id].Info[eNB_index]; + dl_dcch_buffer->dl_dcch_msg = info->dl_dcch_msg; + info->dl_dcch_msg = NULL; + message_p = itti_alloc_new_message (TASK_RRC_UE, 0, RRC_DCCH_DATA_COPY_IND); + RRC_DCCH_DATA_COPY_IND (message_p).sdu_p = (void *)dl_dcch_buffer; + RRC_DCCH_DATA_COPY_IND (message_p).sdu_size = sizeof(rrc_dcch_data_copy_t); + RRC_DCCH_DATA_COPY_IND (message_p).module_id = module_id; + RRC_DCCH_DATA_COPY_IND (message_p).rnti = info->rnti; + RRC_DCCH_DATA_COPY_IND (message_p).eNB_index = eNB_index; + itti_send_msg_to_task (TASK_RRC_UE, 0, message_p); + LOG_I(RRC, "Sent itti RRC_DCCH_DATA_COPY_IND\n"); + break; + } + + case NR_UE_RRC_MEASUREMENT: + { + nfapi_p7_message_header_t header; + if (nfapi_p7_message_header_unpack((void *)msg_buffer, msg_len, &header, sizeof(header), NULL) < 0) + { + LOG_E(MAC, "Header unpack failed in %s \n", __FUNCTION__); + break; + } + if (header.message_id != NFAPI_NR_PHY_MSG_TYPE_DL_TTI_REQUEST) + { + LOG_E(MAC, "%s: Unexpected nfapi message type: %d\n", __FUNCTION__, header.message_id); + break; + } + + nfapi_nr_dl_tti_request_t dl_tti_request; + int unpack_len = nfapi_nr_p7_message_unpack((void *)msg_buffer, + msg_len, + &dl_tti_request, + sizeof(nfapi_nr_dl_tti_request_t), + NULL); + if (unpack_len < 0) + { + LOG_E(RRC, "%s: SSB PDU unpack failed \n", __FUNCTION__); + break; + } + int num_pdus = dl_tti_request.dl_tti_request_body.nPDUs; + if (num_pdus <= 0) + { + LOG_E(RRC, "%s: dl_tti_request number of PDUS <= 0\n", __FUNCTION__); + abort(); + } + for (int i = 0; i < num_pdus; i++) + { + nfapi_nr_dl_tti_request_pdu_t *pdu_list = &dl_tti_request.dl_tti_request_body.dl_tti_pdu_list[i]; + if (pdu_list->PDUType == NFAPI_NR_DL_TTI_SSB_PDU_TYPE) + { + LOG_I(RRC, "Got an NR_UE_RRC_MEASUREMENT. pdulist[%d].ssbRsrp = %d\n", + i, pdu_list->ssb_pdu.ssb_pdu_rel15.ssbRsrp); + } + } + break; + } + + case NR_RRC_CONFIG_COMPLETE_REQ: + { + LOG_I(RRC, "Got an NR_RRC_CONFIG_COMPLETE_REQ. Now make octet string and call below!\n"); + OCTET_STRING_t rrcConfigurationComplete; + memset(&rrcConfigurationComplete, 0, sizeof(rrcConfigurationComplete)); + OCTET_STRING_fromBuf(&rrcConfigurationComplete, + (const char *)msg_buffer, + msg_len); + UE_RRC_INFO *info = &UE_rrc_inst[module_id].Info[eNB_index]; + uint8_t t_id = info->dl_dcch_msg->message.choice.c1.choice. + rrcConnectionReconfiguration.rrc_TransactionIdentifier; + PROTOCOL_CTXT_SET_BY_MODULE_ID(&ctxt, module_id, + ENB_FLAG_NO, info->rnti, + 0, 0, eNB_index); + rrc_ue_generate_RRCConnectionReconfigurationComplete(&ctxt, ctxt.eNB_index, t_id, &rrcConfigurationComplete); + break; + } + default: + LOG_E(RRC, "No NSA Message Found\n"); + } +} diff --git a/openair2/RRC/LTE/rrc_UE_ral.c b/openair2/RRC/LTE/rrc_UE_ral.c deleted file mode 100644 index 1ebba43d8b276ba04cb78a4def9288434406e5e9..0000000000000000000000000000000000000000 --- a/openair2/RRC/LTE/rrc_UE_ral.c +++ /dev/null @@ -1,238 +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 - */ - -/*! \file rrc_UE_ral.c - * \brief rrc procedures for handling RAL messages - * \author Lionel GAUTHIER - * \date 2013 - * \version 1.0 - * \company Eurecom - * \email: lionel.gauthier@eurecom.fr - */ -#define RRC_UE -#define RRC_UE_RAL_C -//----------------------------------------------------------------------------- -#include "rrc_UE_ral.h" -#include "assertions.h" -#include "collection/hashtable/obj_hashtable.h" -#include "RRC/LTE/defs.h" -#include "RRC/LTE/extern.h" - - -//----------------------------------------------------------------------------- -int rrc_ue_ral_delete_all_thresholds_type(unsigned int mod_idP, ral_link_param_type_t *param_type_pP) -//----------------------------------------------------------------------------- -{ - hashtable_rc_t rc; - rrc_ral_threshold_key_t *key; - rrc_ral_threshold_key_t *keys = NULL; - unsigned int num_keys = 0; - int return_code = 0; - rc = obj_hashtable_get_keys(UE_rrc_inst[mod_idP].ral_meas_thresholds, (void *)&keys, &num_keys); - - if (rc == HASH_TABLE_OK) { - key = keys; - - while (num_keys > 0) { - if (memcmp(&key->link_param_type, param_type_pP, sizeof(ral_link_param_type_t)) == 0) { - rc = obj_hashtable_remove (UE_rrc_inst[mod_idP].ral_meas_thresholds, key, sizeof(rrc_ral_threshold_key_t)); - - if (rc != HASH_TABLE_OK) { - return_code = -1; - } - } - - key = &key[1]; - num_keys--; - } - } else { - return_code = -1; - } - - if (keys != NULL) { - free(keys); - } - - return return_code; -} - - -//----------------------------------------------------------------------------- -int rrc_ue_ral_delete_threshold(unsigned int mod_idP, ral_link_param_type_t *param_type_pP, ral_threshold_t *threshold_pP) -//----------------------------------------------------------------------------- -{ - hashtable_rc_t rc; - rrc_ral_threshold_key_t ref_key; - memcpy(&ref_key.link_param_type, param_type_pP, sizeof(ral_link_param_type_t)); - memcpy(&ref_key.threshold, threshold_pP, sizeof(ral_threshold_t)); - rc = obj_hashtable_remove (UE_rrc_inst[mod_idP].ral_meas_thresholds, (void *)&ref_key, sizeof(rrc_ral_threshold_key_t)); - - if (rc == HASH_TABLE_OK) { - return 0; - } else { - return -1; - } -} - - -//----------------------------------------------------------------------------- -int rrc_ue_ral_handle_configure_threshold_request(unsigned int mod_idP, MessageDef *msg_pP) -//----------------------------------------------------------------------------- -{ - ral_transaction_id_t transaction_id = 0; - rrc_ral_configure_threshold_req_t *configure_threshold_req_p = NULL; - ral_link_cfg_param_t *link_cfg_param_p = NULL; - ral_threshold_t *threshold_p = NULL; - MessageDef *message_p = NULL; - unsigned int ix_param = 0; - unsigned int ix_thresholds = 0; - DevAssert(msg_pP != NULL); - LOG_I(RRC, "[UE %d] Received %s\n", mod_idP, ITTI_MSG_NAME (msg_pP)); - configure_threshold_req_p = &RRC_RAL_CONFIGURE_THRESHOLD_REQ(msg_pP); - transaction_id = configure_threshold_req_p->transaction_id; - - for (ix_param = 0; ix_param < configure_threshold_req_p->num_link_cfg_params; ix_param++) { - link_cfg_param_p = &configure_threshold_req_p->link_cfg_params[ix_param]; - - switch (link_cfg_param_p->th_action) { - case RAL_TH_ACTION_SET_NORMAL_THRESHOLD: - case RAL_TH_ACTION_SET_ONE_SHOT_THRESHOLD: - switch (link_cfg_param_p->link_param_type.choice) { - case RAL_LINK_PARAM_TYPE_CHOICE_GEN: - switch (link_cfg_param_p->link_param_type._union.link_param_gen) { - case RAL_LINK_PARAM_GEN_DATA_RATE: - case RAL_LINK_PARAM_GEN_SIGNAL_STRENGTH: - case RAL_LINK_PARAM_GEN_SINR: - case RAL_LINK_PARAM_GEN_THROUGHPUT: - case RAL_LINK_PARAM_GEN_PACKET_ERROR_RATE: - message_p = itti_alloc_new_message (TASK_RRC_UE, PHY_MEAS_THRESHOLD_REQ); - PHY_MEAS_THRESHOLD_REQ(message_p).transaction_id = transaction_id; - memcpy (&PHY_MEAS_THRESHOLD_REQ(message_p).cfg_param, (void *) link_cfg_param_p, sizeof(ral_link_cfg_param_t)); - itti_send_msg_to_task (TASK_PHY_UE, ITTI_MSG_DESTINATION_INSTANCE(msg_pP), message_p); - break; - - default: - LOG_E(RRC, "Message RRC_RAL_CONFIGURE_THRESHOLD_REQ malformed, unknown link_param_gen %d\n", link_cfg_param_p->link_param_type._union.link_param_gen); - return -1; - } - - break; - - case RAL_LINK_PARAM_TYPE_CHOICE_QOS: - switch (link_cfg_param_p->link_param_type._union.link_param_qos) { - case RAL_LINK_PARAM_QOS_MAX_NUM_DIF_COS_SUPPORTED: - case RAL_LINK_PARAM_QOS_MIN_PACKET_TRANSFER_DELAY_ALL_COS: - case RAL_LINK_PARAM_QOS_AVG_PACKET_TRANSFER_DELAY_ALL_COS: - case RAL_LINK_PARAM_QOS_MAX_PACKET_TRANSFER_DELAY_ALL_COS: - case RAL_LINK_PARAM_QOS_STD_DEVIATION_PACKET_TRANSFER_DELAY: - case RAL_LINK_PARAM_QOS_PACKET_LOSS_RATE_ALL_COS_FRAME_RATIO: - message_p = itti_alloc_new_message (TASK_RRC_UE, PHY_MEAS_THRESHOLD_REQ); - PHY_MEAS_THRESHOLD_REQ(message_p).transaction_id = transaction_id; - memcpy (&PHY_MEAS_THRESHOLD_REQ(message_p).cfg_param, (void *) link_cfg_param_p, sizeof(ral_link_cfg_param_t)); - itti_send_msg_to_task (TASK_MAC_UE, ITTI_MSG_DESTINATION_INSTANCE(msg_pP), message_p); - break; - - default: - LOG_E(RRC, "Message RRC_RAL_CONFIGURE_THRESHOLD_REQ malformed, unknown link_param_qos %d\n", link_cfg_param_p->link_param_type._union.link_param_qos); - return -1; - } - - break; - - case RAL_LINK_PARAM_TYPE_CHOICE_LTE: - switch (link_cfg_param_p->link_param_type._union.link_param_lte) { - // group by dest task id - case RAL_LINK_PARAM_LTE_UE_RSRP: - case RAL_LINK_PARAM_LTE_UE_RSRQ: - case RAL_LINK_PARAM_LTE_UE_CQI: - message_p = itti_alloc_new_message (TASK_RRC_UE, PHY_MEAS_THRESHOLD_REQ); - PHY_MEAS_THRESHOLD_REQ(message_p).transaction_id = transaction_id; - memcpy (&PHY_MEAS_THRESHOLD_REQ(message_p).cfg_param, (void *) link_cfg_param_p, sizeof(ral_link_cfg_param_t)); - itti_send_msg_to_task (TASK_PHY_UE, ITTI_MSG_DESTINATION_INSTANCE(msg_pP), message_p); - break; - - case RAL_LINK_PARAM_LTE_AVAILABLE_BW: - case RAL_LINK_PARAM_LTE_PACKET_LOSS_RATE: - case RAL_LINK_PARAM_LTE_L2_BUFFER_STATUS: - case RAL_LINK_PARAM_LTE_PACKET_DELAY: - message_p = itti_alloc_new_message (TASK_RRC_UE, PHY_MEAS_THRESHOLD_REQ); - PHY_MEAS_THRESHOLD_REQ(message_p).transaction_id = transaction_id; - memcpy (&PHY_MEAS_THRESHOLD_REQ(message_p).cfg_param, (void *) link_cfg_param_p, sizeof(ral_link_cfg_param_t)); - itti_send_msg_to_task (TASK_MAC_UE, ITTI_MSG_DESTINATION_INSTANCE(msg_pP), message_p); - break; - - case RAL_LINK_PARAM_LTE_MOBILE_NODE_CAPABILITIES: - case RAL_LINK_PARAM_LTE_EMBMS_CAPABILITY: - case RAL_LINK_PARAM_LTE_JUMBO_FEASIBILITY: - case RAL_LINK_PARAM_LTE_JUMBO_SETUP_STATUS: - case RAL_LINK_PARAM_LTE_NUM_ACTIVE_EMBMS_RECEIVERS_PER_FLOW: -#warning "TO DO MIH LTE LINK PARAMS IN RRC UE" - break; - - default: - LOG_E(RRC, "Message RRC_RAL_CONFIGURE_THRESHOLD_REQ malformed, unknown link_param_lte %d\n", link_cfg_param_p->link_param_type._union.link_param_lte); - return -1; - } - - break; - - default: - LOG_E(RRC, "Message RRC_RAL_CONFIGURE_THRESHOLD_REQ malformed, unknown link_param_type choice %d\n", link_cfg_param_p->link_param_type.choice); - return -1; - } - - for (ix_thresholds=0; ix_thresholds < link_cfg_param_p->num_thresholds; ix_thresholds++) { - threshold_p = &link_cfg_param_p->thresholds[ix_thresholds]; - } - - break; - - case RAL_TH_ACTION_CANCEL_THRESHOLD: - - // IEEE Std 802.21-2008, Table F4, Data type name=LINK_CFG_PARAM (page 228): - // When “Cancel threshold†is selected and no thresholds are specified, then all - // currently configured thresholds for the given LINK_PARAM_TYPE are cancelled. - if (link_cfg_param_p->num_thresholds == 0) { - rrc_ue_ral_delete_all_thresholds_type(mod_idP, &link_cfg_param_p->link_param_type); - } else { - // - // When “Cancel threshold†is selected and thresholds are specified only those - // configured thresholds for the given LINK_PARAM_TYPE and whose threshold value match what was - // specified are cancelled. - for (ix_thresholds=0; ix_thresholds < link_cfg_param_p->num_thresholds; ix_thresholds++) { - threshold_p = &link_cfg_param_p->thresholds[ix_thresholds]; - rrc_ue_ral_delete_threshold(mod_idP, &link_cfg_param_p->link_param_type, threshold_p); - } - } - - LOG_E(RRC, "Message RRC_RAL_CONFIGURE_THRESHOLD_REQ with RAL_TH_ACTION_CANCEL_THRESHOLD\n"); - break; - - default: - LOG_E(RRC, "Message RRC_RAL_CONFIGURE_THRESHOLD_REQ malformed, unknown th_action %d\n", link_cfg_param_p->th_action); - return -1; - } - } - - return 0; -} - - diff --git a/openair2/RRC/LTE/rrc_defs.h b/openair2/RRC/LTE/rrc_defs.h index 40aad67a06be702dbb1bc71b03d6845f8fca925d..f537dcbbd2bc8f6312da98955a10e855e7fb7c8b 100644 --- a/openair2/RRC/LTE/rrc_defs.h +++ b/openair2/RRC/LTE/rrc_defs.h @@ -52,7 +52,7 @@ //for D2D #define DEBUG_CTRL_SOCKET -#define BUFSIZE 1024 + #define CONTROL_SOCKET_PORT_NO 8888 #define MAX_NUM_DEST 10 //netlink @@ -311,12 +311,12 @@ typedef enum SL_TRIGGER_e { #define RRM_CALLOC(t,n) (t *) malloc16( sizeof(t) * n) #define RRM_CALLOC2(t,s) (t *) malloc16( s ) -#define MAX_MEAS_OBJ 6 -#define MAX_MEAS_CONFIG 6 -#define MAX_MEAS_ID 6 +#define MAX_MEAS_OBJ 7 +#define MAX_MEAS_CONFIG 7 +#define MAX_MEAS_ID 7 #define PAYLOAD_SIZE_MAX 1024 -#define RRC_BUF_SIZE 8192 +#define RRC_BUF_SIZE 512 #define UNDEF_SECURITY_MODE 0xff #define NO_SECURITY_MODE 0x20 @@ -363,6 +363,7 @@ typedef struct UE_RRC_INFO_s { uint32_t N310_cnt; uint32_t N311_cnt; rnti_t rnti; + struct LTE_DL_DCCH_Message *dl_dcch_msg; } __attribute__ ((__packed__)) UE_RRC_INFO; typedef struct UE_S_TMSI_s { @@ -916,6 +917,7 @@ typedef struct UE_RRC_INST_s { float rsrq_db[7]; float rsrp_db_filtered[7]; float rsrq_db_filtered[7]; + int subframeCount; /* KeNB as computed from parameters within USIM card */ uint8_t kenb[32]; uint8_t nh[32]; diff --git a/openair2/RRC/LTE/rrc_eNB.c b/openair2/RRC/LTE/rrc_eNB.c index 9283b64ded28281919b1a9e2f1f51b7f5a6ee64d..260b6fceaa69a4d4539a9518b8f077472fd3ba5f 100644 --- a/openair2/RRC/LTE/rrc_eNB.c +++ b/openair2/RRC/LTE/rrc_eNB.c @@ -90,6 +90,7 @@ #include <openair3/ocp-gtpu/gtp_itf.h> #include "intertask_interface.h" +#include "softmodem-common.h" #if ENABLE_RAL #include "rrc_eNB_ral.h" @@ -100,7 +101,6 @@ #define ASN_MAX_ENCODE_SIZE 4096 #define NUMBEROF_DRBS_TOBE_ADDED 1 static int encode_CG_ConfigInfo(char *buffer,int buffer_size,rrc_eNB_ue_context_t *const ue_context_pP,int *enc_size); -static int is_en_dc_supported(LTE_UE_EUTRA_Capability_t *c); extern RAN_CONTEXT_t RC; @@ -152,7 +152,7 @@ init_SI( LOG_D(RRC,"%s()\n\n\n\n",__FUNCTION__); if(configuration->radioresourceconfig[CC_id].mbms_dedicated_serving_cell == TRUE) { - LOG_I(RRC, "Configuring MIB FeMBMS (N_RB_DL %d)\n", + LOG_A(RRC, "Configuring MIB FeMBMS (N_RB_DL %d)\n", (int)configuration->N_RB_DL[CC_id]); RC.rrc[ctxt_pP->module_id]->carrier[CC_id].MIB_FeMBMS = (uint8_t *) malloc16(4); do_MIB_FeMBMS(&RC.rrc[ctxt_pP->module_id]->carrier[CC_id], @@ -253,7 +253,7 @@ init_SI( carrier->N_RB_DL = configuration->N_RB_DL[CC_id]; carrier->pbch_repetition = configuration->pbch_repetition[CC_id]; LOG_I(RRC, "configuration->schedulingInfoSIB1_BR_r13[CC_id] %d\n",(int)configuration->schedulingInfoSIB1_BR_r13[CC_id]); - LOG_I(RRC, "Configuring MIB (N_RB_DL %d,phich_Resource %d,phich_Duration %d)\n", + LOG_A(RRC, "Configuring MIB (N_RB_DL %d,phich_Resource %d,phich_Duration %d)\n", (int)configuration->N_RB_DL[CC_id], (int)configuration->radioresourceconfig[CC_id].phich_resource, (int)configuration->radioresourceconfig[CC_id].phich_duration); @@ -538,6 +538,7 @@ init_MCCH( RC.rrc[enb_mod_idP]->carrier[CC_id].sizeof_MCCH_MESSAGE[sync_area] = do_MBSFNAreaConfig(enb_mod_idP, sync_area, (uint8_t *)RC.rrc[enb_mod_idP]->carrier[CC_id].MCCH_MESSAGE[sync_area], + 32, /* TODO: what is the actual size of .MCCH_MESSAGE[sync_area]? */ &RC.rrc[enb_mod_idP]->carrier[CC_id].mcch, &RC.rrc[enb_mod_idP]->carrier[CC_id].mcch_message); LOG_I(RRC, "mcch message pointer %p for sync area %d \n", @@ -1196,7 +1197,7 @@ rrc_eNB_process_RRCConnectionSetupComplete( ) //----------------------------------------------------------------------------- { - LOG_I(RRC, PROTOCOL_RRC_CTXT_UE_FMT" [RAPROC] Logical Channel UL-DCCH, " "processing LTE_RRCConnectionSetupComplete from UE (SRB1 Active)\n", + LOG_A(RRC, PROTOCOL_RRC_CTXT_UE_FMT" [RAPROC] Logical Channel UL-DCCH, " "processing LTE_RRCConnectionSetupComplete from UE (SRB1 Active)\n", PROTOCOL_RRC_CTXT_UE_ARGS(ctxt_pP)); ue_context_pP->ue_context.Srb1.Active = 1; ue_context_pP->ue_context.StatusRrc = RRC_CONNECTED; @@ -1224,13 +1225,14 @@ rrc_eNB_generate_SecurityModeCommand( ) //----------------------------------------------------------------------------- { - uint8_t buffer[100]; + uint8_t buffer[100]={0}; uint8_t size; T(T_ENB_RRC_SECURITY_MODE_COMMAND, T_INT(ctxt_pP->module_id), T_INT(ctxt_pP->frame), T_INT(ctxt_pP->subframe), T_INT(ctxt_pP->rnti)); size = do_SecurityModeCommand( ctxt_pP, buffer, + sizeof(buffer), rrc_eNB_get_next_transaction_identifier(ctxt_pP->module_id), ue_context_pP->ue_context.ciphering_algorithm, ue_context_pP->ue_context.integrity_algorithm); @@ -1285,6 +1287,7 @@ rrc_eNB_generate_UECapabilityEnquiry( size = do_UECapabilityEnquiry( ctxt_pP, buffer, + sizeof(buffer), rrc_eNB_get_next_transaction_identifier(ctxt_pP->module_id), eutra_band, nr_band); @@ -1335,10 +1338,11 @@ rrc_eNB_generate_NR_UECapabilityEnquiry( size = do_NR_UECapabilityEnquiry( ctxt_pP, buffer, + sizeof(buffer), rrc_eNB_get_next_transaction_identifier(ctxt_pP->module_id), eutra_band, nr_band); - LOG_I(RRC, + LOG_A(RRC, PROTOCOL_RRC_CTXT_UE_FMT" Logical Channel DL-DCCH, Generate NR UECapabilityEnquiry (bytes %d)\n", PROTOCOL_RRC_CTXT_UE_ARGS(ctxt_pP), size); @@ -2001,9 +2005,10 @@ rrc_eNB_process_RRCConnectionReestablishmentComplete( measurements_enabled = RC.rrc[ENB_INSTANCE_TO_MODULE_ID(ctxt_pP->instance)]->configuration.enable_x2 || RC.rrc[ENB_INSTANCE_TO_MODULE_ID(ctxt_pP->instance)]->configuration.enable_measurement_reports; // send LTE_RRCConnectionReconfiguration - memset(buffer, 0, RRC_BUF_SIZE); + memset(buffer, 0, sizeof(buffer)); size = do_RRCConnectionReconfiguration(ctxt_pP, buffer, + sizeof(buffer), next_xid, //Transaction_id, (LTE_SRB_ToAddModList_t *)*SRB_configList2, // SRB_configList (LTE_DRB_ToAddModList_t *)DRB_configList, @@ -2196,10 +2201,9 @@ rrc_eNB_generate_RRCConnectionRelease( ) //----------------------------------------------------------------------------- { - uint8_t buffer[RRC_BUF_SIZE]; + uint8_t buffer[RRC_BUF_SIZE]={0}; uint16_t size = 0; int release_num; - memset(buffer, 0, RRC_BUF_SIZE); T(T_ENB_RRC_CONNECTION_RELEASE, T_INT(ctxt_pP->module_id), T_INT(ctxt_pP->frame), T_INT(ctxt_pP->subframe), T_INT(ctxt_pP->rnti)); #if 0 @@ -2211,7 +2215,8 @@ rrc_eNB_generate_RRCConnectionRelease( } #endif - size = do_RRCConnectionRelease(ctxt_pP->module_id, buffer,rrc_eNB_get_next_transaction_identifier(ctxt_pP->module_id)); + size = do_RRCConnectionRelease(ctxt_pP->module_id, buffer, sizeof(buffer), + rrc_eNB_get_next_transaction_identifier(ctxt_pP->module_id)); ue_context_pP->ue_context.ue_reestablishment_timer = 0; ue_context_pP->ue_context.ue_release_timer = 0; ue_context_pP->ue_context.ue_rrc_inactivity_timer = 0; @@ -2487,9 +2492,10 @@ rrc_eNB_generate_dedicatedRRCConnectionReconfiguration(const protocol_ctxt_t *co LOG_W(RRC,"dedlicated NAS list is empty\n"); } - memset(buffer, 0, RRC_BUF_SIZE); + memset(buffer, 0, sizeof(buffer)); size = do_RRCConnectionReconfiguration(ctxt_pP, buffer, + sizeof(buffer), xid, (LTE_SRB_ToAddModList_t *)NULL, (LTE_DRB_ToAddModList_t *)*DRB_configList2, @@ -2734,9 +2740,9 @@ rrc_eNB_modify_dedicatedRRCConnectionReconfiguration(const protocol_ctxt_t *cons LOG_W(RRC,"dedlicated NAS list is empty\n"); } - memset(buffer, 0, RRC_BUF_SIZE); + memset(buffer, 0, sizeof(buffer)); size = do_RRCConnectionReconfiguration(ctxt_pP, - buffer, + buffer, sizeof(buffer), xid, (LTE_SRB_ToAddModList_t *)NULL, (LTE_DRB_ToAddModList_t *)DRB_configList2, @@ -2835,9 +2841,10 @@ rrc_eNB_generate_dedicatedRRCConnectionReconfiguration_release( const protocol_ LOG_W(RRC,"dedlicated NAS list is empty\n"); } - memset(buffer, 0, RRC_BUF_SIZE); + memset(buffer, 0, sizeof(buffer)); size = do_RRCConnectionReconfiguration(ctxt_pP, buffer, + sizeof(buffer), xid, NULL, NULL, @@ -3465,6 +3472,7 @@ void rrc_eNB_generate_defaultRRCConnectionReconfiguration(const protocol_ctxt_t ReportConfig_NR->reportConfig.choice.reportConfigInterRAT.ext7->reportQuantityCellNR_r15->ss_rsrq = TRUE; ReportConfig_NR->reportConfig.choice.reportConfigInterRAT.ext7->reportQuantityCellNR_r15->ss_sinr = TRUE; ASN_SEQUENCE_ADD(&ReportConfig_list->list, ReportConfig_NR); + LOG_A(RRC, "Generating RRCCConnectionReconfigurationRequest (NRUE Measurement Report Request).\n"); } // LTE_RRCConnectionReconfiguration->criticalExtensions.choice.c1.choice.rrcConnectionReconfiguration_r8.measConfig->reportConfigToAddModList = ReportConfig_list; @@ -3545,9 +3553,10 @@ void rrc_eNB_generate_defaultRRCConnectionReconfiguration(const protocol_ctxt_t measurements_enabled = RC.rrc[ENB_INSTANCE_TO_MODULE_ID(ctxt_pP->instance)]->configuration.enable_x2 || RC.rrc[ENB_INSTANCE_TO_MODULE_ID(ctxt_pP->instance)]->configuration.enable_measurement_reports; - memset(buffer, 0, RRC_BUF_SIZE); + memset(buffer, 0, sizeof(buffer)); size = do_RRCConnectionReconfiguration(ctxt_pP, buffer, + sizeof(buffer), xid, // Transaction_id, (LTE_SRB_ToAddModList_t *) *SRB_configList2, // SRB_configList (LTE_DRB_ToAddModList_t *) *DRB_configList, @@ -4257,9 +4266,10 @@ flexran_rrc_eNB_generate_defaultRRCConnectionReconfiguration(const protocol_ctxt measurements_enabled = RC.rrc[ENB_INSTANCE_TO_MODULE_ID(ctxt_pP->instance)]->configuration.enable_x2 || RC.rrc[ENB_INSTANCE_TO_MODULE_ID(ctxt_pP->instance)]->configuration.enable_measurement_reports; - memset(buffer, 0, RRC_BUF_SIZE); + memset(buffer, 0, sizeof(buffer)); size = do_RRCConnectionReconfiguration(ctxt_pP, buffer, + sizeof(buffer), xid, // Transaction_id, (LTE_SRB_ToAddModList_t *) *SRB_configList2, // SRB_configList (LTE_DRB_ToAddModList_t *) *DRB_configList, @@ -4357,6 +4367,7 @@ rrc_eNB_generate_RRCConnectionReconfiguration_SCell( size = do_RRCConnectionReconfiguration(ctxt_pP, buffer, + sizeof(buffer), rrc_eNB_get_next_transaction_identifier(ctxt_pP->module_id),//Transaction_id, (LTE_SRB_ToAddModList_t *)NULL, (LTE_DRB_ToAddModList_t *)NULL, @@ -4421,7 +4432,6 @@ static int encode_CG_ConfigInfo( struct NR_CG_ConfigInfo *cg_configinfo = NULL; struct NR_RadioBearerConfig *rb_config = NULL; asn_enc_rval_t enc_rval; - int RRC_OK = 1; char temp_buff[ASN_MAX_ENCODE_SIZE]; NR_UE_CapabilityRAT_ContainerList_t *ue_cap_rat_container_list = NULL; NR_UE_CapabilityRAT_Container_t *ue_cap_rat_container_MRDC = NULL; @@ -4441,7 +4451,6 @@ static int encode_CG_ConfigInfo( = calloc(1,sizeof(struct NR_CG_ConfigInfo_IEs)); AssertFatal(cg_configinfo->criticalExtensions.choice.c1->choice.cg_ConfigInfo != NULL, "failed to allocate memory for cg_configinfo_IEs"); - if(ue_context_pP->ue_context.UE_Capability_MRDC) { RAT_Container_count++; enc_rval = uper_encode_to_buffer(&asn_DEF_NR_UE_MRDC_Capability,NULL, @@ -4611,6 +4620,7 @@ rrc_eNB_process_MeasurementReport( //= measResults2->measResultNeighCells->choice.measResultNeighCellListNR_r15.list.array[0]->pci_r15; = measResults2->measResultNeighCells->choice.measResultListEUTRA.list.array[0]->physCellId; + X2AP_ENDC_SGNB_ADDITION_REQ(msg).target_physCellId = 0; //For the moment we have a single E-RAB which will be the one to be added to the gNB //Not sure how to select bearers to be added if there are multiple. X2AP_ENDC_SGNB_ADDITION_REQ(msg).nb_e_rabs_tobeadded = 1; @@ -4624,7 +4634,7 @@ rrc_eNB_process_MeasurementReport( sizeof(transport_layer_addr_t)); } - LOG_I(RRC, + LOG_A(RRC, "[eNB %d] frame %d subframe %d: UE rnti %x switching to NSA mode\n", ctxt_pP->module_id, ctxt_pP->frame, ctxt_pP->subframe, ctxt_pP->rnti); itti_send_msg_to_task(TASK_X2AP, ENB_MODULE_ID_TO_INSTANCE(ctxt_pP->module_id), msg); @@ -4668,6 +4678,10 @@ rrc_eNB_process_MeasurementReport( if (ue_context_pP->ue_context.measResults->measResultNeighCells == NULL) { ue_context_pP->ue_context.measResults->measResultNeighCells = CALLOC(1, sizeof(*ue_context_pP->ue_context.measResults->measResultNeighCells)); } + if (!ue_context_pP->ue_context.measResults->measResultNeighCells->choice.measResultListEUTRA.list.array) { + ue_context_pP->ue_context.measResults->measResultNeighCells->choice.measResultListEUTRA.list.array = + calloc(neighboring_cells, sizeof(*ue_context_pP->ue_context.measResults->measResultNeighCells->choice.measResultListEUTRA.list.array)); + } for (i=0; i < neighboring_cells; i++) { if (i>=ue_context_pP->ue_context.measResults->measResultNeighCells->choice.measResultListEUTRA.list.count) { @@ -4677,6 +4691,11 @@ rrc_eNB_process_MeasurementReport( ue_context_pP->ue_context.measResults->measResultNeighCells->choice.measResultListEUTRA.list.array[i]->physCellId = measResults2->measResultNeighCells->choice.measResultListEUTRA.list.array[i]->physCellId; + + if (!ue_context_pP->ue_context.measResults->measResultNeighCells->choice.measResultListEUTRA.list.array[i]->measResult.rsrpResult) + ue_context_pP->ue_context.measResults->measResultNeighCells->choice.measResultListEUTRA.list.array[i]->measResult.rsrpResult = calloc(1, sizeof(*ue_context_pP->ue_context.measResults->measResultNeighCells->choice.measResultListEUTRA.list.array[i]->measResult.rsrpResult)); + if (!ue_context_pP->ue_context.measResults->measResultNeighCells->choice.measResultListEUTRA.list.array[i]->measResult.rsrqResult) + ue_context_pP->ue_context.measResults->measResultNeighCells->choice.measResultListEUTRA.list.array[i]->measResult.rsrqResult = calloc(1, sizeof(*ue_context_pP->ue_context.measResults->measResultNeighCells->choice.measResultListEUTRA.list.array[i]->measResult.rsrqResult)); ue_context_pP->ue_context.measResults->measResultNeighCells->choice.measResultListEUTRA.list.array[i]->measResult.rsrpResult = measResults2->measResultNeighCells->choice.measResultListEUTRA.list.array[i]->measResult.rsrpResult; ue_context_pP->ue_context.measResults->measResultNeighCells->choice.measResultListEUTRA.list.array[i]->measResult.rsrqResult = @@ -4973,19 +4992,17 @@ void rrc_eNB_handover_ue_context_release( struct rrc_eNB_ue_context_s *ue_context_p) { int e_rab = 0; //MessageDef *msg_release_p = NULL; - MessageDef *msg_delete_tunnels_p = NULL; uint32_t eNB_ue_s1ap_id = ue_context_p->ue_context.eNB_ue_s1ap_id; //msg_release_p = itti_alloc_new_message(TASK_RRC_ENB, 0, S1AP_UE_CONTEXT_RELEASE); //itti_send_msg_to_task(TASK_S1AP, ctxt_pP->module_id, msg_release_p); s1ap_ue_context_release(ctxt_pP->instance, ue_context_p->ue_context.eNB_ue_s1ap_id); //MSC_LOG_TX_MESSAGE(MSC_RRC_ENB, MSC_GTPU_ENB, NULL,0, "0 GTPV1U_ENB_DELETE_TUNNEL_REQ rnti %x ", eNB_ue_s1ap_id); - msg_delete_tunnels_p = itti_alloc_new_message(TASK_RRC_ENB, 0, GTPV1U_ENB_DELETE_TUNNEL_REQ); - memset(>PV1U_ENB_DELETE_TUNNEL_REQ(msg_delete_tunnels_p), 0, sizeof(GTPV1U_ENB_DELETE_TUNNEL_REQ(msg_delete_tunnels_p))); - GTPV1U_ENB_DELETE_TUNNEL_REQ(msg_delete_tunnels_p).rnti = ue_context_p->ue_context.rnti; - GTPV1U_ENB_DELETE_TUNNEL_REQ(msg_delete_tunnels_p).from_gnb = 0; + gtpv1u_enb_delete_tunnel_req_t delete_tunnels={0}; + delete_tunnels.rnti = ue_context_p->ue_context.rnti; + delete_tunnels.from_gnb = 0; for (e_rab = 0; e_rab < ue_context_p->ue_context.nb_of_e_rabs; e_rab++) { - GTPV1U_ENB_DELETE_TUNNEL_REQ(msg_delete_tunnels_p).eps_bearer_id[GTPV1U_ENB_DELETE_TUNNEL_REQ(msg_delete_tunnels_p).num_erab++] = + delete_tunnels.eps_bearer_id[delete_tunnels.num_erab++] = ue_context_p->ue_context.enb_gtp_ebi[e_rab]; // erase data ue_context_p->ue_context.enb_gtp_teid[e_rab] = 0; @@ -4993,7 +5010,7 @@ void rrc_eNB_handover_ue_context_release( ue_context_p->ue_context.enb_gtp_ebi[e_rab] = 0; } - itti_send_msg_to_task(TASK_VARIABLE, ctxt_pP->module_id, msg_delete_tunnels_p); + gtpv1u_delete_s1u_tunnel(ctxt_pP->module_id, &delete_tunnels); struct rrc_ue_s1ap_ids_s *rrc_ue_s1ap_ids = NULL; rrc_ue_s1ap_ids = rrc_eNB_S1AP_get_ue_ids(RC.rrc[ctxt_pP->module_id], 0, eNB_ue_s1ap_id); @@ -5144,7 +5161,9 @@ check_handovers( // Configure target ue_context_p->ue_context.handover_info->state = HO_FORWARDING; msg = itti_alloc_new_message(TASK_RRC_ENB, 0, X2AP_HANDOVER_REQ_ACK); - rrc_eNB_generate_HO_RRCConnectionReconfiguration(ctxt_pP, ue_context_p, X2AP_HANDOVER_REQ_ACK(msg).rrc_buffer, + rrc_eNB_generate_HO_RRCConnectionReconfiguration(ctxt_pP, ue_context_p, + X2AP_HANDOVER_REQ_ACK(msg).rrc_buffer, + sizeof(X2AP_HANDOVER_REQ_ACK(msg).rrc_buffer), &X2AP_HANDOVER_REQ_ACK(msg).rrc_buffer_size); rrc_eNB_configure_rbs_handover(ue_context_p,ctxt_pP); X2AP_HANDOVER_REQ_ACK(msg).rnti = ue_context_p->ue_context.rnti; @@ -5306,6 +5325,7 @@ void rrc_eNB_generate_HO_RRCConnectionReconfiguration(const protocol_ctxt_t *const ctxt_pP, rrc_eNB_ue_context_t *const ue_context_pP, uint8_t *buffer, + size_t buffer_size, int *_size //const uint8_t ho_state ) @@ -6247,11 +6267,12 @@ rrc_eNB_generate_HO_RRCConnectionReconfiguration(const protocol_ctxt_t *const ct measurements_enabled = RC.rrc[ENB_INSTANCE_TO_MODULE_ID(ctxt_pP->instance)]->configuration.enable_x2 || RC.rrc[ENB_INSTANCE_TO_MODULE_ID(ctxt_pP->instance)]->configuration.enable_measurement_reports; - memset(buffer, 0, RRC_BUF_SIZE); + memset(buffer, 0, buffer_size); char rrc_buf[1000 /* arbitrary, should be big enough, has to be less than size of return buf by a few bits/bytes */]; int rrc_size; rrc_size = do_RRCConnectionReconfiguration(ctxt_pP, (unsigned char *)rrc_buf, + sizeof(rrc_buf), xid, //Transaction_id, NULL, // SRB_configList NULL, @@ -6287,7 +6308,7 @@ rrc_eNB_generate_HO_RRCConnectionReconfiguration(const protocol_ctxt_t *const ct char *ho_buf = (char *)buffer; int ho_size; ho_size = do_HandoverCommand( - ho_buf, 1024 /* TODO: this is the value found in struct x2ap_handover_req_ack_s for array rrc_buffer */, + ho_buf, buffer_size, rrc_buf, rrc_size); *_size = size = ho_size; @@ -7791,47 +7812,6 @@ is_ul_256QAM_supported( && *c->NCE->NCE->NCE->NCE->NCE->NCE->NCE->NCE->NCE->NCE->NCE->NCE->NCE->NCE->NCE->NCE->NCE->NCE->NCE->NCE->rf_Parameters_v1430->supportedBandCombination_v1430->list.array[0]->bandParameterList_v1430->list.array[0]->ul_256QAM_r14==LTE_BandParameters_v1430__ul_256QAM_r14_supported; } -static int -is_en_dc_supported( - LTE_UE_EUTRA_Capability_t *c -) -//----------------------------------------------------------------------------- -{ - /* to be refined - check that the bands supported by the UE include - * the band of the gNB - */ - return c != NULL // R8 - && c->NCE != NULL // R92 - && c->NCE->NCE != NULL // R94 - && c->NCE->NCE->NCE != NULL // R102 - && c->NCE->NCE->NCE->NCE != NULL // R106 - && c->NCE->NCE->NCE->NCE->NCE != NULL // R109 - && c->NCE->NCE->NCE->NCE->NCE->NCE != NULL // R113 - && c->NCE->NCE->NCE->NCE->NCE->NCE->NCE != NULL // R117 - && c->NCE->NCE->NCE->NCE->NCE->NCE->NCE->NCE != NULL // R118 - && c->NCE->NCE->NCE->NCE->NCE->NCE->NCE->NCE->NCE != NULL // R11a - && c->NCE->NCE->NCE->NCE->NCE->NCE->NCE->NCE->NCE->NCE != NULL // R125 - && c->NCE->NCE->NCE->NCE->NCE->NCE->NCE->NCE->NCE->NCE->NCE != NULL // R126 - && c->NCE->NCE->NCE->NCE->NCE->NCE->NCE->NCE->NCE->NCE->NCE->NCE != NULL // 127 - && c->NCE->NCE->NCE->NCE->NCE->NCE->NCE->NCE->NCE->NCE->NCE->NCE->NCE != NULL // 128 - && c->NCE->NCE->NCE->NCE->NCE->NCE->NCE->NCE->NCE->NCE->NCE->NCE->NCE->NCE != NULL //131 - && c->NCE->NCE->NCE->NCE->NCE->NCE->NCE->NCE->NCE->NCE->NCE->NCE->NCE->NCE->NCE != NULL //132 - && c->NCE->NCE->NCE->NCE->NCE->NCE->NCE->NCE->NCE->NCE->NCE->NCE->NCE->NCE->NCE->NCE != NULL //133 - && c->NCE->NCE->NCE->NCE->NCE->NCE->NCE->NCE->NCE->NCE->NCE->NCE->NCE->NCE->NCE->NCE->NCE != NULL //134 - && c->NCE->NCE->NCE->NCE->NCE->NCE->NCE->NCE->NCE->NCE->NCE->NCE->NCE->NCE->NCE->NCE->NCE->NCE != NULL //135 - && c->NCE->NCE->NCE->NCE->NCE->NCE->NCE->NCE->NCE->NCE->NCE->NCE->NCE->NCE->NCE->NCE->NCE->NCE->NCE != NULL //136 - && c->NCE->NCE->NCE->NCE->NCE->NCE->NCE->NCE->NCE->NCE->NCE->NCE->NCE->NCE->NCE->NCE->NCE->NCE->NCE->NCE != NULL //143 - && c->NCE->NCE->NCE->NCE->NCE->NCE->NCE->NCE->NCE->NCE->NCE->NCE->NCE->NCE->NCE->NCE->NCE->NCE->NCE->NCE->NCE != NULL //144 - && c->NCE->NCE->NCE->NCE->NCE->NCE->NCE->NCE->NCE->NCE->NCE->NCE->NCE->NCE->NCE->NCE->NCE->NCE->NCE->NCE->NCE->NCE != NULL //145 - && c->NCE->NCE->NCE->NCE->NCE->NCE->NCE->NCE->NCE->NCE->NCE->NCE->NCE->NCE->NCE->NCE->NCE->NCE->NCE->NCE->NCE->NCE->NCE != NULL //146 - && c->NCE->NCE->NCE->NCE->NCE->NCE->NCE->NCE->NCE->NCE->NCE->NCE->NCE->NCE->NCE->NCE->NCE->NCE->NCE->NCE->NCE->NCE->NCE->NCE != NULL //151 - && c->NCE->NCE->NCE->NCE->NCE->NCE->NCE->NCE->NCE->NCE->NCE->NCE->NCE->NCE->NCE->NCE->NCE->NCE->NCE->NCE->NCE->NCE->NCE->NCE->irat_ParametersNR_r15 != NULL - && c->NCE->NCE->NCE->NCE->NCE->NCE->NCE->NCE->NCE->NCE->NCE->NCE->NCE->NCE->NCE->NCE->NCE->NCE->NCE->NCE->NCE->NCE->NCE->NCE->irat_ParametersNR_r15->en_DC_r15 != NULL - && *c->NCE->NCE->NCE->NCE->NCE->NCE->NCE->NCE->NCE->NCE->NCE->NCE->NCE->NCE->NCE->NCE->NCE->NCE->NCE->NCE->NCE->NCE->NCE->NCE->irat_ParametersNR_r15->en_DC_r15 == - LTE_IRAT_ParametersNR_r15__en_DC_r15_supported; -#undef NCE -} - int to_nr_rsrpq(long rsrpq_result,int nr_band) { switch(nr_band) { @@ -7886,7 +7866,6 @@ rrc_eNB_decode_dcch( LTE_UL_DCCH_Message_t *ul_dcch_msg = NULL; //&uldcchmsg; int i; struct rrc_eNB_ue_context_s *ue_context_p = NULL; - MessageDef *msg_delete_tunnels_p = NULL; uint8_t xid; int dedicated_DRB=0; T(T_ENB_RRC_UL_DCCH_DATA_IN, T_INT(ctxt_pP->module_id), T_INT(ctxt_pP->frame), @@ -7902,7 +7881,6 @@ rrc_eNB_decode_dcch( Srb_id); } - //memset(ul_dcch_msg,0,sizeof(UL_DCCH_Message_t)); LOG_D(RRC, PROTOCOL_RRC_CTXT_UE_FMT" Decoding UL-DCCH Message\n", PROTOCOL_RRC_CTXT_UE_ARGS(ctxt_pP)); dec_rval = uper_decode( @@ -7994,7 +7972,7 @@ rrc_eNB_decode_dcch( /*FK: left the condition as is for the case MME is used (S1 mode) but setting dedicated_DRB = 1 otherwise (noS1 mode) so that no second RRCReconfiguration message activationg more DRB is sent as this causes problems with the nasmesh driver.*/ int flexran_agent_handover = 0; - if (EPC_MODE_ENABLED) { + if (EPC_MODE_ENABLED || get_softmodem_params()->emulate_l1) { if (ue_context_p->ue_context.StatusRrc == RRC_RECONFIGURED) { dedicated_DRB = 1; LOG_I(RRC, @@ -8067,6 +8045,7 @@ rrc_eNB_decode_dcch( rrc_eNB_send_E_RAB_Modification_Indication(ctxt_pP, ue_context_p); /* send reconfiguration complete to gNB */ rrc_eNB_process_reconfiguration_complete_endc(ctxt_pP, ue_context_p); + LOG_A(RRC, "Sent rrcReconfigurationComplete to gNB\n"); } } } @@ -8124,21 +8103,19 @@ rrc_eNB_decode_dcch( xid = ul_dcch_msg->message.choice.c1.choice.rrcConnectionReconfigurationComplete.rrc_TransactionIdentifier; ue_context_p->ue_context.e_rab_release_command_flag = 0; //gtp tunnel delete - msg_delete_tunnels_p = itti_alloc_new_message(TASK_RRC_ENB, 0, GTPV1U_ENB_DELETE_TUNNEL_REQ); - memset(>PV1U_ENB_DELETE_TUNNEL_REQ(msg_delete_tunnels_p), 0, sizeof(GTPV1U_ENB_DELETE_TUNNEL_REQ(msg_delete_tunnels_p))); - GTPV1U_ENB_DELETE_TUNNEL_REQ(msg_delete_tunnels_p).rnti = ue_context_p->ue_context.rnti; - GTPV1U_ENB_DELETE_TUNNEL_REQ(msg_delete_tunnels_p).from_gnb = 0; + gtpv1u_enb_delete_tunnel_req_t delete_tunnels={0}; + delete_tunnels.rnti = ue_context_p->ue_context.rnti; + delete_tunnels.from_gnb = 0; for(i = 0; i < NB_RB_MAX; i++) { if(xid == ue_context_p->ue_context.e_rab[i].xid) { - GTPV1U_ENB_DELETE_TUNNEL_REQ(msg_delete_tunnels_p).eps_bearer_id[GTPV1U_ENB_DELETE_TUNNEL_REQ(msg_delete_tunnels_p).num_erab++] = ue_context_p->ue_context.enb_gtp_ebi[i]; + delete_tunnels.eps_bearer_id[delete_tunnels.num_erab++] = ue_context_p->ue_context.enb_gtp_ebi[i]; ue_context_p->ue_context.enb_gtp_teid[i] = 0; memset(&ue_context_p->ue_context.enb_gtp_addrs[i], 0, sizeof(ue_context_p->ue_context.enb_gtp_addrs[i])); ue_context_p->ue_context.enb_gtp_ebi[i] = 0; } } - - itti_send_msg_to_task(TASK_GTPV1_U, ctxt_pP->instance, msg_delete_tunnels_p); + gtpv1u_delete_s1u_tunnel(ctxt_pP->instance, &delete_tunnels); //S1AP_E_RAB_RELEASE_RESPONSE rrc_eNB_send_S1AP_E_RAB_RELEASE_RESPONSE(ctxt_pP, ue_context_p, @@ -8430,12 +8407,13 @@ rrc_eNB_decode_dcch( xer_fprint(stdout, &asn_DEF_LTE_UL_DCCH_Message, (void *)ul_dcch_msg); } - LOG_I(RRC, "got UE capabilities for UE %x\n", ctxt_pP->rnti); + LOG_A(RRC, "got UE capabilities for UE %x\n", ctxt_pP->rnti); int eutra_index = -1; for (i = 0; i < ul_dcch_msg->message.choice.c1.choice.ueCapabilityInformation.criticalExtensions.choice.c1.choice.ueCapabilityInformation_r8.ue_CapabilityRAT_ContainerList.list.count; i++) { if (ul_dcch_msg->message.choice.c1.choice.ueCapabilityInformation.criticalExtensions.choice.c1.choice.ueCapabilityInformation_r8.ue_CapabilityRAT_ContainerList.list.array[i]->rat_Type == LTE_RAT_Type_nr) { + LOG_A(RRC, "got nrUE capabilities for UE %x\n", ctxt_pP->rnti); if(ue_context_p->ue_context.UE_Capability_nr) { ASN_STRUCT_FREE(asn_DEF_NR_UE_NR_Capability,ue_context_p->ue_context.UE_Capability_nr); ue_context_p->ue_context.UE_Capability_nr = 0; @@ -8541,7 +8519,13 @@ rrc_eNB_decode_dcch( if (dec_rval.code == RC_OK) { /* do NR only if at least one gNB connected */ if (RC.rrc[ctxt_pP->module_id]->num_gnb_cells != 0) + { + allocate_en_DC_r15(ue_context_p->ue_context.UE_Capability); + if (!is_en_dc_supported(ue_context_p->ue_context.UE_Capability)){ + LOG_E(RRC, "We did not properly allocate en_DC_r15 for UE_EUTRA_Capability\n"); + } ue_context_p->ue_context.does_nr = is_en_dc_supported(ue_context_p->ue_context.UE_Capability); + } else ue_context_p->ue_context.does_nr = 0; } @@ -8767,9 +8751,9 @@ void handle_f1_setup_req(f1ap_setup_req_t *f1_setup_req) { for (int j=0; j<RC.nb_inst; j++) { eNB_RRC_INST *rrc = RC.rrc[j]; - if (rrc->configuration.mcc[0] == f1_setup_req->mcc[i] && - rrc->configuration.mnc[0] == f1_setup_req->mnc[i] && - rrc->nr_cellid == f1_setup_req->nr_cellid[i]) { + if (rrc->configuration.mcc[0] == f1_setup_req->cell[i].mcc && + rrc->configuration.mnc[0] == f1_setup_req->cell[i].mnc && + rrc->nr_cellid == f1_setup_req->cell[i].nr_cellid) { // check that CU rrc instance corresponds to mcc/mnc/cgi (normally cgi should be enough, but just in case) rrc->carrier[0].MIB = malloc(f1_setup_req->mib_length[i]); rrc->carrier[0].sizeof_MIB = f1_setup_req->mib_length[i]; @@ -8809,7 +8793,7 @@ void handle_f1_setup_req(f1ap_setup_req_t *f1_setup_req) { AssertFatal(bcch_message->message.choice.c1.present == LTE_BCCH_DL_SCH_MessageType__c1_PR_systemInformationBlockType1, "bcch_message->message.choice.c1.present != LTE_BCCH_DL_SCH_MessageType__c1_PR_systemInformationBlockType1\n"); rrc->carrier[0].sib1 = &bcch_message->message.choice.c1.choice.systemInformationBlockType1; - rrc->carrier[0].physCellId = f1_setup_req->nr_pci[i]; + rrc->carrier[0].physCellId = f1_setup_req->cell[i].nr_pci; // prepare F1_SETUP_RESPONSE if (msg_p == NULL) { @@ -8821,7 +8805,7 @@ void handle_f1_setup_req(f1ap_setup_req_t *f1_setup_req) { F1AP_SETUP_RESP (msg_p).cells_to_activate[cu_cell_ind].mnc = rrc->configuration.mnc[0]; F1AP_SETUP_RESP (msg_p).cells_to_activate[cu_cell_ind].mnc_digit_length = rrc->configuration.mnc_digit_length[0]; F1AP_SETUP_RESP (msg_p).cells_to_activate[cu_cell_ind].nr_cellid = rrc->nr_cellid; - F1AP_SETUP_RESP (msg_p).cells_to_activate[cu_cell_ind].nrpci = f1_setup_req->nr_pci[i]; + F1AP_SETUP_RESP (msg_p).cells_to_activate[cu_cell_ind].nrpci = f1_setup_req->cell[i].nr_pci; int num_SI= 0; if (rrc->carrier[0].SIB23) { F1AP_SETUP_RESP (msg_p).cells_to_activate[cu_cell_ind].SI_container[2+num_SI] = rrc->carrier[0].SIB23; @@ -8842,7 +8826,7 @@ void handle_f1_setup_req(f1ap_setup_req_t *f1_setup_req) { break; } else {// setup_req mcc/mnc match rrc internal list element LOG_W(RRC,"[Inst %d] No matching MCC/MNC: rrc->mcc/f1_setup_req->mcc %d/%d rrc->mnc/f1_setup_req->mnc %d/%d \n", - j, rrc->configuration.mcc[0], f1_setup_req->mcc[i],rrc->configuration.mnc[0], f1_setup_req->mnc[i]); + j, rrc->configuration.mcc[0], f1_setup_req->cell[i].mcc,rrc->configuration.mnc[0], f1_setup_req->cell[i].mnc); } }// for (int j=0;j<RC.nb_inst;j++) @@ -10053,7 +10037,7 @@ rrc_eNB_generate_RRCConnectionReconfiguration_Sidelink( { uint8_t buffer[RRC_BUF_SIZE]; uint16_t size = 0; - memset(buffer, 0, RRC_BUF_SIZE); + memset(buffer, 0, sizeof(buffer)); // allocate dedicated pools for UE -sl-CommConfig/sl-DiscConfig (sl-V2X-ConfigDedicated) //populate dedicated resources for SL communication (sl-CommConfig) @@ -10066,6 +10050,7 @@ rrc_eNB_generate_RRCConnectionReconfiguration_Sidelink( sl_CommConfig[0] = rrc_eNB_get_sidelink_commTXPool(ctxt_pP, ue_context_pP, destinationInfoList); size = do_RRCConnectionReconfiguration(ctxt_pP, buffer, + sizeof(buffer), rrc_eNB_get_next_transaction_identifier(ctxt_pP->module_id), //Transaction_id (LTE_SRB_ToAddModList_t *)NULL, (LTE_DRB_ToAddModList_t *)NULL, @@ -10088,6 +10073,7 @@ rrc_eNB_generate_RRCConnectionReconfiguration_Sidelink( sl_DiscConfig[0] = rrc_eNB_get_sidelink_discTXPool(ctxt_pP, ue_context_pP, n_discoveryMessages ); size = do_RRCConnectionReconfiguration(ctxt_pP, buffer, + sizeof(buffer), rrc_eNB_get_next_transaction_identifier(ctxt_pP->module_id), //Transaction_id (LTE_SRB_ToAddModList_t *)NULL, (LTE_DRB_ToAddModList_t *)NULL, diff --git a/openair2/RRC/LTE/rrc_eNB_GTPV1U.c b/openair2/RRC/LTE/rrc_eNB_GTPV1U.c index a6af6a4163a7f941e49ba89079b541799a6d1dc2..3fa17bcd6bdba76cee9054bd8af09e7c09eac88d 100644 --- a/openair2/RRC/LTE/rrc_eNB_GTPV1U.c +++ b/openair2/RRC/LTE/rrc_eNB_GTPV1U.c @@ -261,23 +261,33 @@ boolean_t gtpv_data_req_new ( void rrc_eNB_send_GTPV1U_ENB_DELETE_TUNNEL_REQ( module_id_t enb_mod_idP, - const rrc_eNB_ue_context_t* const ue_context_pP + rrc_eNB_ue_context_t* ue_context_pP ) { if (!ue_context_pP) { LOG_W(RRC, "[eNB] In %s: invalid UE\n", __func__); return; } + eNB_RRC_UE_t *ue = &ue_context_pP->ue_context; gtpv1u_enb_delete_tunnel_req_t tmp={0}; - tmp.rnti = ue_context_pP->ue_context.rnti; + tmp.rnti = ue->rnti; tmp.from_gnb = 0; - tmp.num_erab = ue_context_pP->ue_context.nb_of_e_rabs; - for (int e_rab = 0; e_rab < ue_context_pP->ue_context.nb_of_e_rabs; e_rab++) { - const rb_id_t gtp_ebi = ue_context_pP->ue_context.enb_gtp_ebi[e_rab]; + tmp.num_erab = ue->nb_of_e_rabs; + for (int e_rab = 0; e_rab < ue->nb_of_e_rabs; e_rab++) { + const rb_id_t gtp_ebi = ue->enb_gtp_ebi[e_rab]; tmp.eps_bearer_id[e_rab] = gtp_ebi; } - gtpv1u_delete_s1u_tunnel(enb_mod_idP,&tmp); + gtpv1u_delete_s1u_tunnel(enb_mod_idP,&tmp); + if ( ue->ue_release_timer_rrc > 0 + && (ue->handover_info == NULL || + (ue->handover_info->state != HO_RELEASE && + ue->handover_info->state != HO_CANCEL + ) + ) + ) + ue->ue_release_timer_rrc = ue->ue_release_timer_thres_rrc; + } diff --git a/openair2/RRC/LTE/rrc_eNB_GTPV1U.h b/openair2/RRC/LTE/rrc_eNB_GTPV1U.h index 6318ed4927cc051a1a3b3c2c70956fc22e85eeae..ab789099caeee90bee21c38ce0e9eea9c6160cb9 100644 --- a/openair2/RRC/LTE/rrc_eNB_GTPV1U.h +++ b/openair2/RRC/LTE/rrc_eNB_GTPV1U.h @@ -57,7 +57,7 @@ rrc_gNB_process_GTPV1U_CREATE_TUNNEL_RESP( */ void rrc_eNB_send_GTPV1U_ENB_DELETE_TUNNEL_REQ( module_id_t enb_mod_idP, - const rrc_eNB_ue_context_t* const ue_context_pP + rrc_eNB_ue_context_t* ue_context_pP ); boolean_t diff --git a/openair2/RRC/LTE/rrc_eNB_S1AP.c b/openair2/RRC/LTE/rrc_eNB_S1AP.c index 1cb575d1ddb323877700097692265f82ee28a0f8..1a5fe55c26feb2732bc731efedd1a468eb060551 100644 --- a/openair2/RRC/LTE/rrc_eNB_S1AP.c +++ b/openair2/RRC/LTE/rrc_eNB_S1AP.c @@ -62,11 +62,6 @@ #include "executables/softmodem-common.h" extern RAN_CONTEXT_t RC; -extern int -gtpv1u_delete_s1u_tunnel( - const instance_t instanceP, - const gtpv1u_enb_delete_tunnel_req_t *const req_pP); - /* Value to indicate an invalid UE initial id */ static const uint16_t UE_INITIAL_ID_INVALID = 0; @@ -169,7 +164,6 @@ rrc_eNB_S1AP_get_ue_ids( instance_t instance = 0; s1ap_eNB_instance_t *s1ap_eNB_instance_p = NULL; s1ap_eNB_ue_context_t *ue_desc_p = NULL; - rrc_eNB_ue_context_t *ue_context_p = NULL; /*****************************/ hashtable_rc_t h_rc; @@ -257,29 +251,7 @@ rrc_eNB_S1AP_get_ue_ids( LOG_E(RRC, "Removing UE context eNB_ue_s1ap_id %u: did not find context\n",ue_desc_p->eNB_ue_s1ap_id); } - return NULL; //skip the operation below to avoid loop - result = rrc_eNB_S1AP_get_ue_ids(rrc_instance_pP, ue_desc_p->ue_initial_id, eNB_ue_s1ap_id); - - if (ue_desc_p->ue_initial_id != UE_INITIAL_ID_INVALID) { - result = rrc_eNB_S1AP_get_ue_ids(rrc_instance_pP, ue_desc_p->ue_initial_id, eNB_ue_s1ap_id); - - if (result != NULL) { - ue_context_p = rrc_eNB_get_ue_context(RC.rrc[ENB_INSTANCE_TO_MODULE_ID(instance)], result->ue_rnti); - - if ((ue_context_p != NULL) && (ue_context_p->ue_context.eNB_ue_s1ap_id == 0)) { - ue_context_p->ue_context.eNB_ue_s1ap_id = eNB_ue_s1ap_id; - } else { - LOG_E(RRC, "[eNB %ld] Incoherence between RRC context and S1AP context (%d != %d) for UE RNTI %d or UE RRC context doesn't exist\n", - rrc_instance_pP - RC.rrc[0], - (ue_context_p==NULL)?99999:ue_context_p->ue_context.eNB_ue_s1ap_id, - eNB_ue_s1ap_id, - result->ue_rnti); - } - } - } else { - LOG_E(S1AP, "[eNB %ld] S1AP context found but ue_initial_id is invalid (0)\n", rrc_instance_pP - RC.rrc[0]); - return NULL; - } + return NULL; } else { LOG_E(S1AP, "[eNB %ld] In hashtable_get, couldn't find in s1ap_id2_s1ap_ids eNB_ue_s1ap_id %"PRIu32", because ue_initial_id is invalid in S1AP context\n", rrc_instance_pP - RC.rrc[0], @@ -593,14 +565,20 @@ rrc_eNB_send_S1AP_INITIAL_CONTEXT_SETUP_RESP( S1AP_INITIAL_CONTEXT_SETUP_RESP (msg_p).eNB_ue_s1ap_id = ue_context_pP->ue_context.eNB_ue_s1ap_id; for (e_rab = 0; e_rab < ue_context_pP->ue_context.nb_of_e_rabs; e_rab++) { - if (ue_context_pP->ue_context.e_rab[e_rab].status == E_RAB_STATUS_DONE) { + if (ue_context_pP->ue_context.e_rab[e_rab].status == E_RAB_STATUS_DONE || ue_context_pP->ue_context.e_rab[e_rab].status == E_RAB_STATUS_TOMODIFY) { e_rabs_done++; S1AP_INITIAL_CONTEXT_SETUP_RESP (msg_p).e_rabs[e_rab].e_rab_id = ue_context_pP->ue_context.e_rab[e_rab].param.e_rab_id; // TODO add other information from S1-U when it will be integrated S1AP_INITIAL_CONTEXT_SETUP_RESP (msg_p).e_rabs[e_rab].gtp_teid = ue_context_pP->ue_context.enb_gtp_teid[e_rab]; S1AP_INITIAL_CONTEXT_SETUP_RESP (msg_p).e_rabs[e_rab].eNB_addr = ue_context_pP->ue_context.enb_gtp_addrs[e_rab]; S1AP_INITIAL_CONTEXT_SETUP_RESP (msg_p).e_rabs[e_rab].eNB_addr.length = 4; - ue_context_pP->ue_context.e_rab[e_rab].status = E_RAB_STATUS_ESTABLISHED; + if (ue_context_pP->ue_context.e_rab[e_rab].status == E_RAB_STATUS_DONE) { + ue_context_pP->ue_context.e_rab[e_rab].status = E_RAB_STATUS_ESTABLISHED; + S1AP_INITIAL_CONTEXT_SETUP_RESP (msg_p).nb_of_e_rabs = e_rabs_done; + S1AP_INITIAL_CONTEXT_SETUP_RESP (msg_p).nb_of_e_rabs_failed = e_rabs_failed; + itti_send_msg_to_task (TASK_S1AP, ctxt_pP->instance, msg_p); + } + } else { e_rabs_failed++; ue_context_pP->ue_context.e_rab[e_rab].status = E_RAB_STATUS_FAILED; @@ -619,9 +597,6 @@ rrc_eNB_send_S1AP_INITIAL_CONTEXT_SETUP_RESP( ue_context_pP->ue_id_rnti, S1AP_INITIAL_CONTEXT_SETUP_RESP (msg_p).eNB_ue_s1ap_id, e_rabs_done, e_rabs_failed); - S1AP_INITIAL_CONTEXT_SETUP_RESP (msg_p).nb_of_e_rabs = e_rabs_done; - S1AP_INITIAL_CONTEXT_SETUP_RESP (msg_p).nb_of_e_rabs_failed = e_rabs_failed; - itti_send_msg_to_task (TASK_S1AP, ctxt_pP->instance, msg_p); } //------------------------------------------------------------------------------ @@ -1078,29 +1053,43 @@ int rrc_eNB_process_S1AP_INITIAL_CONTEXT_SETUP_REQ(MessageDef *msg_p, const char rrc_eNB_send_S1AP_INITIAL_CONTEXT_SETUP_RESP(&ctxt,ue_context_p); } - /* - if ((RC.rrc[ctxt.module_id]->node_type == ngran_eNB_CU) || - (RC.rrc[ctxt.module_id]->node_type == ngran_ng_eNB_CU) || - (RC.rrc[ctxt.module_id]->node_type == ngran_gNB_CU) ){ - - message_p = itti_alloc_new_message (TASK_RRC_ENB, 0, F1AP_UE_CONTEXT_SETUP_REQ); - F1AP_UE_CONTEXT_SETUP_REQ (message_p).rrc_container = ue_p->Srb0.Tx_buffer.Payload; - - F1AP_UE_CONTEXT_SETUP_REQ (message_p).rrc_container_length = ue_p->Srb0.Tx_buffer.payload_size; - F1AP_UE_CONTEXT_SETUP_REQ (message_p).gNB_CU_ue_id = 0; - F1AP_UE_CONTEXT_SETUP_REQ (message_p).gNB_DU_ue_id = 0; - F1AP_UE_CONTEXT_SETUP_REQ (message_p).old_gNB_DU_ue_id = 0xFFFFFFFF; // unknown - F1AP_UE_CONTEXT_SETUP_REQ (message_p).rnti = ue_p->rnti; - F1AP_UE_CONTEXT_SETUP_REQ (message_p).srb_id = CCCH; - F1AP_UE_CONTEXT_SETUP_REQ (message_p).execute_duplication = 1; - F1AP_UE_CONTEXT_SETUP_REQ (message_p).RAT_frequency_priority_information.en_dc = 0; - itti_send_msg_to_task (TASK_CU_F1, ctxt_pP->module_id, message_p); - LOG_D(RRC, "Send F1AP_UE_CONTEXT_SETUP_REQ with ITTI\n"); - - } - */ - return (0); + + if ((RC.rrc[ctxt.module_id]->node_type == ngran_eNB_CU) || + (RC.rrc[ctxt.module_id]->node_type == ngran_ng_eNB_CU) || + (RC.rrc[ctxt.module_id]->node_type == ngran_gNB_CU) ){ + struct eNB_RRC_INST_s *rrc= RC.rrc[0]; + MessageDef *message_p = itti_alloc_new_message (TASK_RRC_ENB, 0, F1AP_UE_CONTEXT_SETUP_REQ); + f1ap_ue_context_setup_t *req=&F1AP_UE_CONTEXT_SETUP_REQ (message_p); + req->gNB_CU_ue_id = 0; + req->gNB_DU_ue_id = 0; + req->rnti = ue_context_p->ue_context.rnti; + req->mcc = rrc->configuration.mcc[0]; + req->mnc = rrc->configuration.mnc[0]; + req->mnc_digit_length = rrc->configuration.mnc_digit_length[0]; + req->nr_cellid = rrc->nr_cellid; + req->srbs_to_be_setup = malloc(sizeof(f1ap_srb_to_be_setup_t)); + req->srbs_to_be_setup_length = 1; + f1ap_srb_to_be_setup_t *SRBs=req->srbs_to_be_setup; + SRBs[0].srb_id=CCCH; + req->drbs_to_be_setup_length = S1AP_INITIAL_CONTEXT_SETUP_REQ (msg_p).nb_of_e_rabs; + req->drbs_to_be_setup = malloc(req->drbs_to_be_setup_length * sizeof(f1ap_drb_to_be_setup_t)); + f1ap_drb_to_be_setup_t *DRBs=req->drbs_to_be_setup; + for (int i = 0; i < req->drbs_to_be_setup_length ; i++) { + DRBs[i].drb_id=S1AP_INITIAL_CONTEXT_SETUP_REQ (msg_p).e_rab_param[i].e_rab_id; + DRBs[i].rlc_mode = RLC_MODE_AM; + DRBs[i].up_ul_tnl[0].tl_address = inet_addr(rrc->eth_params_s.my_addr); + DRBs[i].up_ul_tnl[0].port=rrc->eth_params_s.my_portd; + DRBs[i].up_ul_tnl_length = 1; + DRBs[i].up_dl_tnl[0].tl_address = inet_addr(rrc->eth_params_s.remote_addr); + DRBs[i].up_dl_tnl[0].port=rrc->eth_params_s.remote_portd; + DRBs[i].up_dl_tnl_length = 1; + } + LOG_I(RRC, "Send F1AP_UE_CONTEXT_SETUP_REQ with ITTI\n"); + itti_send_msg_to_task (TASK_CU_F1, 0, message_p); + } } + + return (0); } /*------------------------------------------------------------------------------*/ @@ -1706,7 +1695,6 @@ int rrc_eNB_process_S1AP_E_RAB_RELEASE_COMMAND(MessageDef *msg_p, const char *ms uint8_t b_existed,is_existed; uint8_t xid; uint8_t e_rab_release_drb; - MessageDef *msg_delete_tunnels_p = NULL; e_rab_release_drb = 0; memcpy(&e_rab_release_params[0], &(S1AP_E_RAB_RELEASE_COMMAND (msg_p).e_rab_release_params[0]), sizeof(e_rab_release_t)*S1AP_MAX_E_RAB); eNB_ue_s1ap_id = S1AP_E_RAB_RELEASE_COMMAND (msg_p).eNB_ue_s1ap_id; @@ -1774,21 +1762,19 @@ int rrc_eNB_process_S1AP_E_RAB_RELEASE_COMMAND(MessageDef *msg_p, const char *ms rrc_eNB_generate_dedicatedRRCConnectionReconfiguration_release(&ctxt, ue_context_p, xid, S1AP_E_RAB_RELEASE_COMMAND (msg_p).nas_pdu.length, S1AP_E_RAB_RELEASE_COMMAND (msg_p).nas_pdu.buffer); } else { //gtp tunnel delete - msg_delete_tunnels_p = itti_alloc_new_message(TASK_RRC_ENB, 0, GTPV1U_ENB_DELETE_TUNNEL_REQ); - memset(>PV1U_ENB_DELETE_TUNNEL_REQ(msg_delete_tunnels_p), 0, sizeof(GTPV1U_ENB_DELETE_TUNNEL_REQ(msg_delete_tunnels_p))); - GTPV1U_ENB_DELETE_TUNNEL_REQ(msg_delete_tunnels_p).rnti = ue_context_p->ue_context.rnti; - GTPV1U_ENB_DELETE_TUNNEL_REQ(msg_delete_tunnels_p).from_gnb = 0; + gtpv1u_enb_delete_tunnel_req_t delete_tunnels={0}; + delete_tunnels.rnti = ue_context_p->ue_context.rnti; + delete_tunnels.from_gnb = 0; for(i = 0; i < NB_RB_MAX; i++) { if(xid == ue_context_p->ue_context.e_rab[i].xid) { - GTPV1U_ENB_DELETE_TUNNEL_REQ(msg_delete_tunnels_p).eps_bearer_id[GTPV1U_ENB_DELETE_TUNNEL_REQ(msg_delete_tunnels_p).num_erab++] = ue_context_p->ue_context.enb_gtp_ebi[i]; + delete_tunnels.eps_bearer_id[delete_tunnels.num_erab++] = ue_context_p->ue_context.enb_gtp_ebi[i]; ue_context_p->ue_context.enb_gtp_teid[i] = 0; memset(&ue_context_p->ue_context.enb_gtp_addrs[i], 0, sizeof(ue_context_p->ue_context.enb_gtp_addrs[i])); ue_context_p->ue_context.enb_gtp_ebi[i] = 0; } } - - itti_send_msg_to_task(TASK_VARIABLE, instance, msg_delete_tunnels_p); + gtpv1u_delete_s1u_tunnel(instance,&delete_tunnels); //S1AP_E_RAB_RELEASE_RESPONSE rrc_eNB_send_S1AP_E_RAB_RELEASE_RESPONSE(&ctxt, ue_context_p, xid); } @@ -1967,7 +1953,7 @@ int rrc_eNB_process_PAGING_IND(MessageDef *msg_p, const char *msg_name, instance message_p = itti_alloc_new_message (TASK_RRC_ENB, 0, RRC_PCCH_DATA_REQ); /* Create message for PDCP (DLInformationTransfer_t) */ length = do_Paging (instance, - buffer, + buffer, sizeof(buffer), S1AP_PAGING_IND(msg_p).ue_paging_identity, S1AP_PAGING_IND(msg_p).cn_domain); @@ -2253,8 +2239,16 @@ int rrc_eNB_process_S1AP_PATH_SWITCH_REQ_ACK (MessageDef *msg_p, &delete_tunnel_req); /* TBD: release the DRB not admitted */ //rrc_eNB_generate_dedicatedRRCConnectionReconfiguration(&ctxt, ue_context_p, 0); - } - + if ( ue_context_p->ue_context.ue_release_timer_rrc > 0 && + (ue_context_p->ue_context.handover_info == NULL || + (ue_context_p->ue_context.handover_info->state != HO_RELEASE && + ue_context_p->ue_context.handover_info->state != HO_CANCEL + ) + ) + ) + ue_context_p->ue_context.ue_release_timer_rrc = ue_context_p->ue_context.ue_release_timer_thres_rrc; + } + /* Security key */ ue_context_p->ue_context.next_hop_chain_count=S1AP_PATH_SWITCH_REQ_ACK (msg_p).next_hop_chain_count; memcpy ( ue_context_p->ue_context.next_security_key, diff --git a/openair2/RRC/LTE/rrc_eNB_endc.c b/openair2/RRC/LTE/rrc_eNB_endc.c index 3d3d9787b5954e03d2a9149afabf53179dfa95d7..a2792adba59289ccaf5997d390f67ab3b1178196 100644 --- a/openair2/RRC/LTE/rrc_eNB_endc.c +++ b/openair2/RRC/LTE/rrc_eNB_endc.c @@ -171,8 +171,10 @@ int rrc_eNB_generate_RRCConnectionReconfiguration_endc(protocol_ctxt_t *ctxt, OCTET_STRING_t dummy_scg_conf; unsigned char scg_conf_buf[4] = { 0, 0, 0, 0 }; - if (scg_group_config!=NULL) + if (scg_group_config!=NULL) { nr.choice.setup.nr_SecondaryCellGroupConfig_r15 = scg_group_config; //&scg_conf; + LOG_E(RRC, "setting scg_group_config\n"); + } else{ nr.choice.setup.nr_SecondaryCellGroupConfig_r15 = &dummy_scg_conf; dummy_scg_conf.buf = scg_conf_buf; @@ -197,8 +199,10 @@ int rrc_eNB_generate_RRCConnectionReconfiguration_endc(protocol_ctxt_t *ctxt, OCTET_STRING_t dummy_nr1_conf; unsigned char nr1_buf[4] = { 0, 0, 0, 0 }; - if(scg_RB_config!=NULL) + if(scg_RB_config!=NULL) { cr_1510.nr_RadioBearerConfig1_r15 = scg_RB_config; + LOG_E(RRC, "setting scg_RB_config\n"); + } else{ cr_1510.nr_RadioBearerConfig1_r15 = &dummy_nr1_conf; dummy_nr1_conf.buf = nr1_buf; @@ -230,7 +234,8 @@ int rrc_eNB_generate_RRCConnectionReconfiguration_endc(protocol_ctxt_t *ctxt, (void *)&dl_dcch_msg, buffer, buffer_size); - + AssertFatal (enc_rval.encoded > 0, "asn_DEF_LTE_DL_DCCH_Message message encoding failed (%s, %jd)!\n", + enc_rval.failed_type->name, enc_rval.encoded); { int len = (enc_rval.encoded + 7) / 8; int i; diff --git a/openair2/RRC/LTE/rrc_eNB_ral.c b/openair2/RRC/LTE/rrc_eNB_ral.c deleted file mode 100644 index 9e1486f6d8a3e4d8e1fd8081973cd13256bbe725..0000000000000000000000000000000000000000 --- a/openair2/RRC/LTE/rrc_eNB_ral.c +++ /dev/null @@ -1,236 +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 - */ - -/*! \file rrc_eNB_ral.c - * \brief rrc procedures for handling RAL messages - * \author Lionel GAUTHIER - * \date 2013 - * \version 1.0 - * \company Eurecom - * \email: lionel.gauthier@eurecom.fr - */ -#define RRC_ENB -#define RRC_ENB_RAL_C -//----------------------------------------------------------------------------- -#include "rrc_eNB_ral.h" -#include "assertions.h" -#include "collection/hashtable/obj_hashtable.h" -#include "RRC/LTE/defs.h" -#include "RRC/LTE/extern.h" - - -//----------------------------------------------------------------------------- -int rrc_enb_ral_delete_all_thresholds_type(unsigned int mod_idP, ral_link_param_type_t *param_type_pP) -//----------------------------------------------------------------------------- -{ - hashtable_rc_t rc; - rrc_ral_threshold_key_t *key; - rrc_ral_threshold_key_t *keys = NULL; - unsigned int num_keys = 0; - int return_code = 0; - rc = obj_hashtable_get_keys(eNB_rrc_inst[mod_idP].ral_meas_thresholds, (void *)&keys, &num_keys); - - if (rc == HASH_TABLE_OK) { - key = keys; - - while (num_keys > 0) { - if (memcmp(&key->link_param_type, param_type_pP, sizeof(ral_link_param_type_t)) == 0) { - rc = obj_hashtable_remove (eNB_rrc_inst[mod_idP].ral_meas_thresholds, key, sizeof(rrc_ral_threshold_key_t)); - - if (rc != HASH_TABLE_OK) { - return_code = -1; - } - } - - key = &key[1]; - num_keys--; - } - } else { - return_code = -1; - } - - if (keys != NULL) { - free(keys); - } - - return return_code; -} - - -//----------------------------------------------------------------------------- -int rrc_enb_ral_delete_threshold(unsigned int mod_idP, ral_link_param_type_t *param_type_pP, ral_threshold_t *threshold_pP) -//----------------------------------------------------------------------------- -{ - hashtable_rc_t rc; - rrc_ral_threshold_key_t ref_key; - memcpy(&ref_key.link_param_type, param_type_pP, sizeof(ral_link_param_type_t)); - memcpy(&ref_key.threshold, threshold_pP, sizeof(ral_threshold_t)); - rc = obj_hashtable_remove (eNB_rrc_inst[mod_idP].ral_meas_thresholds, (void *)&ref_key, sizeof(rrc_ral_threshold_key_t)); - - if (rc == HASH_TABLE_OK) { - return 0; - } else { - return -1; - } -} - - -//----------------------------------------------------------------------------- -int rrc_enb_ral_handle_configure_threshold_request(unsigned int mod_idP, MessageDef *msg_pP) -//----------------------------------------------------------------------------- -{ - ral_transaction_id_t transaction_id = 0; - rrc_ral_configure_threshold_req_t *configure_threshold_req_p = NULL; - ral_link_cfg_param_t *link_cfg_param_p = NULL; - ral_threshold_t *threshold_p = NULL; - MessageDef *message_p = NULL; - unsigned int ix_param = 0; - unsigned int ix_thresholds = 0; - DevAssert(msg_pP != NULL); - LOG_I(RRC, "[eNB %d] Received %s\n", mod_idP, ITTI_MSG_NAME (msg_pP)); - configure_threshold_req_p = &RRC_RAL_CONFIGURE_THRESHOLD_REQ(msg_pP); - transaction_id = configure_threshold_req_p->transaction_id; - - for (ix_param = 0; ix_param < configure_threshold_req_p->num_link_cfg_params; ix_param++) { - link_cfg_param_p = &configure_threshold_req_p->link_cfg_params[ix_param]; - - switch (link_cfg_param_p->th_action) { - case RAL_TH_ACTION_SET_NORMAL_THRESHOLD: - case RAL_TH_ACTION_SET_ONE_SHOT_THRESHOLD: - switch (link_cfg_param_p->link_param_type.choice) { - case RAL_LINK_PARAM_TYPE_CHOICE_GEN: - switch (link_cfg_param_p->link_param_type._union.link_param_gen) { - case RAL_LINK_PARAM_GEN_DATA_RATE: - case RAL_LINK_PARAM_GEN_SIGNAL_STRENGTH: - case RAL_LINK_PARAM_GEN_SINR: - case RAL_LINK_PARAM_GEN_THROUGHPUT: - case RAL_LINK_PARAM_GEN_PACKET_ERROR_RATE: - message_p = itti_alloc_new_message (TASK_RRC_ENB, PHY_MEAS_THRESHOLD_REQ); - PHY_MEAS_THRESHOLD_REQ(message_p).transaction_id = transaction_id; - memcpy (&PHY_MEAS_THRESHOLD_REQ(message_p).cfg_param, (void *) link_cfg_param_p, sizeof(ral_link_cfg_param_t)); - itti_send_msg_to_task (TASK_PHY_ENB, ITTI_MSG_DESTINATION_INSTANCE(msg_pP), message_p); - break; - - default: - LOG_E(RRC, "Message RRC_RAL_CONFIGURE_THRESHOLD_REQ malformed, unknown link_param_gen %d\n", link_cfg_param_p->link_param_type._union.link_param_gen); - return -1; - } - - break; - - case RAL_LINK_PARAM_TYPE_CHOICE_QOS: - switch (link_cfg_param_p->link_param_type._union.link_param_qos) { - case RAL_LINK_PARAM_QOS_MAX_NUM_DIF_COS_SUPPORTED: - case RAL_LINK_PARAM_QOS_MIN_PACKET_TRANSFER_DELAY_ALL_COS: - case RAL_LINK_PARAM_QOS_AVG_PACKET_TRANSFER_DELAY_ALL_COS: - case RAL_LINK_PARAM_QOS_MAX_PACKET_TRANSFER_DELAY_ALL_COS: - case RAL_LINK_PARAM_QOS_STD_DEVIATION_PACKET_TRANSFER_DELAY: - case RAL_LINK_PARAM_QOS_PACKET_LOSS_RATE_ALL_COS_FRAME_RATIO: - message_p = itti_alloc_new_message (TASK_RRC_ENB, PHY_MEAS_THRESHOLD_REQ); - PHY_MEAS_THRESHOLD_REQ(message_p).transaction_id = transaction_id; - memcpy (&PHY_MEAS_THRESHOLD_REQ(message_p).cfg_param, (void *) link_cfg_param_p, sizeof(ral_link_cfg_param_t)); - itti_send_msg_to_task (TASK_MAC_ENB, ITTI_MSG_DESTINATION_INSTANCE(msg_pP), message_p); - break; - - default: - LOG_E(RRC, "Message RRC_RAL_CONFIGURE_THRESHOLD_REQ malformed, unknown link_param_qos %d\n", link_cfg_param_p->link_param_type._union.link_param_qos); - return -1; - } - - break; - - case RAL_LINK_PARAM_TYPE_CHOICE_LTE: - switch (link_cfg_param_p->link_param_type._union.link_param_lte) { - // group by dest task id - case RAL_LINK_PARAM_LTE_UE_RSRP: - case RAL_LINK_PARAM_LTE_UE_RSRQ: - case RAL_LINK_PARAM_LTE_UE_CQI: - message_p = itti_alloc_new_message (TASK_RRC_ENB, PHY_MEAS_THRESHOLD_REQ); - PHY_MEAS_THRESHOLD_REQ(message_p).transaction_id = transaction_id; - memcpy (&PHY_MEAS_THRESHOLD_REQ(message_p).cfg_param, (void *) link_cfg_param_p, sizeof(ral_link_cfg_param_t)); - itti_send_msg_to_task (TASK_PHY_ENB, ITTI_MSG_DESTINATION_INSTANCE(msg_pP), message_p); - break; - - case RAL_LINK_PARAM_LTE_AVAILABLE_BW: - case RAL_LINK_PARAM_LTE_PACKET_LOSS_RATE: - case RAL_LINK_PARAM_LTE_L2_BUFFER_STATUS: - case RAL_LINK_PARAM_LTE_PACKET_DELAY: - message_p = itti_alloc_new_message (TASK_RRC_ENB, PHY_MEAS_THRESHOLD_REQ); - PHY_MEAS_THRESHOLD_REQ(message_p).transaction_id = transaction_id; - memcpy (&PHY_MEAS_THRESHOLD_REQ(message_p).cfg_param, (void *) link_cfg_param_p, sizeof(ral_link_cfg_param_t)); - itti_send_msg_to_task (TASK_MAC_ENB, ITTI_MSG_DESTINATION_INSTANCE(msg_pP), message_p); - break; - - case RAL_LINK_PARAM_LTE_MOBILE_NODE_CAPABILITIES: - case RAL_LINK_PARAM_LTE_EMBMS_CAPABILITY: - case RAL_LINK_PARAM_LTE_JUMBO_FEASIBILITY: - case RAL_LINK_PARAM_LTE_JUMBO_SETUP_STATUS: - case RAL_LINK_PARAM_LTE_NUM_ACTIVE_EMBMS_RECEIVERS_PER_FLOW: -#warning "TO DO MIH LTE LINK PARAMS IN RRC ENB" - break; - - default: - LOG_E(RRC, "Message RRC_RAL_CONFIGURE_THRESHOLD_REQ malformed, unknown link_param_lte %d\n", link_cfg_param_p->link_param_type._union.link_param_lte); - return -1; - } - - break; - - default: - LOG_E(RRC, "Message RRC_RAL_CONFIGURE_THRESHOLD_REQ malformed, unknown link_param_type choice %d\n", link_cfg_param_p->link_param_type.choice); - return -1; - } - - for (ix_thresholds=0; ix_thresholds < link_cfg_param_p->num_thresholds; ix_thresholds++) { - threshold_p = &link_cfg_param_p->thresholds[ix_thresholds]; - } - - break; - - case RAL_TH_ACTION_CANCEL_THRESHOLD: - - // IEEE Std 802.21-2008, Table F4, Data type name=LINK_CFG_PARAM (page 228): - // When “Cancel threshold†is selected and no thresholds are specified, then all - // currently configured thresholds for the given LINK_PARAM_TYPE are cancelled. - if (link_cfg_param_p->num_thresholds == 0) { - rrc_enb_ral_delete_all_thresholds_type(mod_idP, &link_cfg_param_p->link_param_type); - } else { - // - // When “Cancel threshold†is selected and thresholds are specified only those - // configured thresholds for the given LINK_PARAM_TYPE and whose threshold value match what was - // specified are cancelled. - for (ix_thresholds=0; ix_thresholds < link_cfg_param_p->num_thresholds; ix_thresholds++) { - threshold_p = &link_cfg_param_p->thresholds[ix_thresholds]; - rrc_enb_ral_delete_threshold(mod_idP, &link_cfg_param_p->link_param_type, threshold_p); - } - } - - break; - - default: - LOG_E(RRC, "Message RRC_RAL_CONFIGURE_THRESHOLD_REQ malformed, unknown th_action %d\n", link_cfg_param_p->th_action); - return -1; - } - } - - return 0; -} - diff --git a/openair2/RRC/LTE/rrc_proto.h b/openair2/RRC/LTE/rrc_proto.h index c50ddf3189e9fcb3e7d463835871d065baefa0ce..f0456005f5270a5a073aabe8134c87243d758e3e 100644 --- a/openair2/RRC/LTE/rrc_proto.h +++ b/openair2/RRC/LTE/rrc_proto.h @@ -31,6 +31,8 @@ * @{ */ +#pragma once + #include "RRC/LTE/rrc_defs.h" #include "x2ap_messages_types.h" #include "flexran_agent_extern.h" @@ -103,6 +105,7 @@ rrc_ue_decode_dcch( const protocol_ctxt_t *const ctxt_pP, const rb_id_t Srb_id, const uint8_t *const Buffer, + const uint32_t Buffer_size, const uint8_t eNB_indexP ); @@ -310,6 +313,7 @@ void rrc_eNB_generate_HO_RRCConnectionReconfiguration(const protocol_ctxt_t *const ctxt_pP, rrc_eNB_ue_context_t *const ue_context_pP, uint8_t *buffer, + size_t buffer_size, int *_size //const uint8_t ho_state ); @@ -354,6 +358,12 @@ void *rrc_enb_task(void *args_p); \param void *args_p Pointer on arguments to start the task. */ void *rrc_ue_task(void *args_p); +/**\brief RRC NSA UE task. + \param void *args_p Pointer on arguments to start the task. */ +void *recv_msgs_from_nr_ue(void *args_p); + +void init_connections_with_nr_ue(void); + void rrc_eNB_process_x2_setup_request(int mod_id, x2ap_setup_req_t *m); void rrc_eNB_process_x2_setup_response(int mod_id, x2ap_setup_resp_t *m); diff --git a/openair2/RRC/LTE/rrc_types.h b/openair2/RRC/LTE/rrc_types.h index 9c1e37494f1eda3b3546709d458fced10d5b6de3..6b339af563beebf27f07da9ea182c7bc93ec47c8 100644 --- a/openair2/RRC/LTE/rrc_types.h +++ b/openair2/RRC/LTE/rrc_types.h @@ -61,4 +61,18 @@ typedef enum Rrc_Sub_State_e { RRC_SUB_STATE_CONNECTED_LAST = RRC_SUB_STATE_CONNECTED, } Rrc_Sub_State_t; +typedef enum Rrc_Msg_Type_e { + UE_CAPABILITY_DUMMY = 0xa0, + UE_CAPABILITY_ENQUIRY, + NRUE_CAPABILITY_ENQUIRY, + UE_CAPABILITY_INFO, + NRUE_CAPABILITY_INFO, + RRC_MEASUREMENT_PROCEDURE, + NR_UE_RRC_MEASUREMENT, + RRC_CONFIG_COMPLETE_REQ, + NR_RRC_CONFIG_COMPLETE_REQ, + OAI_TUN_IFACE_NSA +} Rrc_Msg_Type_t; + + #endif /* RRC_TYPES_H_ */ diff --git a/openair2/RRC/LTE/rrc_vars.h b/openair2/RRC/LTE/rrc_vars.h index b1a0121c0018185f4a379d091fe190a118f1dcb8..dfb019193c14ea41a8b551471ba1d56c2d530e26 100644 --- a/openair2/RRC/LTE/rrc_vars.h +++ b/openair2/RRC/LTE/rrc_vars.h @@ -42,6 +42,8 @@ UE_RRC_INST *UE_rrc_inst = NULL; #include "LAYER2/MAC/mac_extern.h" #define MAX_U32 0xFFFFFFFF +extern uint16_t ue_id_g; + uint8_t DRB2LCHAN[8]; long logicalChannelGroup0 = 0; diff --git a/openair2/RRC/NR/L2_nr_interface.c b/openair2/RRC/NR/L2_nr_interface.c index 9cef23a6c51718a44147bfa5adef3009a4917a5a..cf7dcf1b644ee195b3e2bddac6ab63029d72b3b8 100644 --- a/openair2/RRC/NR/L2_nr_interface.c +++ b/openair2/RRC/NR/L2_nr_interface.c @@ -323,31 +323,37 @@ int8_t nr_mac_rrc_data_ind(const module_id_t module_idP, // call do_RRCSetup like full procedure and extract masterCellGroup NR_CellGroupConfig_t cellGroupConfig; NR_ServingCellConfigCommon_t *scc=RC.nrrrc[module_idP]->carrier.servingcellconfigcommon; - uint8_t sdu2[100]; memset(&cellGroupConfig,0,sizeof(cellGroupConfig)); - fill_initial_cellGroupConfig(rntiP,&cellGroupConfig,scc,&RC.nrrrc[module_idP]->carrier); + + fill_initial_cellGroupConfig(rntiP,-1,&cellGroupConfig,scc,&RC.nrrrc[module_idP]->carrier); + MessageDef* tmp=itti_alloc_new_message_sized(TASK_RRC_GNB, 0, F1AP_INITIAL_UL_RRC_MESSAGE, sizeof(f1ap_initial_ul_rrc_message_t) + sdu_lenP); + f1ap_initial_ul_rrc_message_t *msg = &F1AP_INITIAL_UL_RRC_MESSAGE(tmp); + asn_enc_rval_t enc_rval = uper_encode_to_buffer(&asn_DEF_NR_CellGroupConfig, NULL, (void *)&cellGroupConfig, - sdu2, - 100); + msg->du2cu_rrc_container, + 1024); //sizeof(msg->du2cu_rrc_container)); - int sdu2_len = (enc_rval.encoded+7)/8; if (enc_rval.encoded == -1) { LOG_E(F1AP,"Could not encoded cellGroupConfig, failed element %s\n",enc_rval.failed_type->name); exit(-1); } /* do ITTI message */ - DU_send_INITIAL_UL_RRC_MESSAGE_TRANSFER( - module_idP, - CC_id, - UE_id, - rntiP, - sduP, - sdu_lenP, - (const int8_t*)sdu2, - sdu2_len - ); + msg->du2cu_rrc_container_length = (enc_rval.encoded+7)/8; + msg->crnti=rntiP; + msg->rrc_container=(uint8_t*) (msg+1); // Made extra room after the struct with itti_alloc_msg_sized() + memcpy(msg->rrc_container, sduP, sdu_lenP); + msg->rrc_container_length=sdu_lenP; + itti_send_msg_to_task(TASK_DU_F1, 0, tmp); + + struct rrc_gNB_ue_context_s *ue_context_p = rrc_gNB_allocate_new_UE_context(RC.nrrrc[module_idP]); + ue_context_p->ue_id_rnti = rntiP; + ue_context_p->ue_context.rnti = rntiP; + ue_context_p->ue_context.random_ue_identity = rntiP; + ue_context_p->ue_context.Srb0.Active = 1; + RB_INSERT(rrc_nr_ue_tree_s, &RC.nrrrc[module_idP]->rrc_ue_head, ue_context_p); + return(0); } @@ -383,3 +389,17 @@ void nr_mac_gNB_rrc_ul_failure(const module_id_t Mod_instP, LOG_D(RRC,"Frame %d, Subframe %d: UL failure: UE %x unknown \n",frameP,subframeP,rntiP); } } + +void nr_mac_gNB_rrc_ul_failure_reset(const module_id_t Mod_instP, + const frame_t frameP, + const sub_frame_t subframeP, + const rnti_t rntiP) { + struct rrc_gNB_ue_context_s *ue_context_p = NULL; + ue_context_p = rrc_gNB_get_ue_context(RC.nrrrc[Mod_instP], rntiP); + if (ue_context_p != NULL) { + LOG_W(RRC,"Frame %d, Subframe %d: UE %x UL failure reset, deactivating timer\n",frameP,subframeP,rntiP); + ue_context_p->ue_context.ul_failure_timer=0; + } else { + LOG_W(RRC,"Frame %d, Subframe %d: UL failure reset: UE %x unknown \n",frameP,subframeP,rntiP); + } +} diff --git a/openair2/RRC/NR/MESSAGES/asn1_msg.c b/openair2/RRC/NR/MESSAGES/asn1_msg.c index f1cc264b9fb6bdf688e590631e100b44ee465883..c2f7ebfc513444d5eacc623a07f25187811f0dce 100755 --- a/openair2/RRC/NR/MESSAGES/asn1_msg.c +++ b/openair2/RRC/NR/MESSAGES/asn1_msg.c @@ -39,6 +39,7 @@ #include <asn_application.h> #include <asn_internal.h> /* for _ASN_DEFAULT_STACK_MAX */ #include <per_encoder.h> +#include <nr/nr_common.h> #include "asn1_msg.h" #include "../nr_rrc_proto.h" @@ -297,15 +298,6 @@ uint8_t do_SIB1_NR(rrc_gNB_carrier_data_t *carrier, ) { asn_enc_rval_t enc_rval; - // TODO : Add support for more than one PLMN - int num_plmn = 1; // int num_plmn = configuration->num_plmn; - struct NR_PLMN_Identity *nr_plmn = CALLOC(1, sizeof(struct NR_PLMN_Identity) * num_plmn); - NR_MCC_MNC_Digit_t (*nr_mcc_digit)[3] = (NR_MCC_MNC_Digit_t(*)[3])CALLOC(1, sizeof(NR_MCC_MNC_Digit_t)*num_plmn*3); - NR_MCC_MNC_Digit_t (*nr_mnc_digit)[3] = (NR_MCC_MNC_Digit_t(*)[3])CALLOC(1, sizeof(NR_MCC_MNC_Digit_t)*num_plmn*3);; - memset(nr_plmn,0,sizeof(struct NR_PLMN_Identity) * num_plmn); - memset(nr_mcc_digit,0,sizeof(NR_MCC_MNC_Digit_t)*num_plmn*3); - memset(nr_mnc_digit,0,sizeof(NR_MCC_MNC_Digit_t)*num_plmn*3); - NR_BCCH_DL_SCH_Message_t *sib1_message = CALLOC(1,sizeof(NR_BCCH_DL_SCH_Message_t)); carrier->siblock1 = sib1_message; sib1_message->message.present = NR_BCCH_DL_SCH_MessageType_PR_c1; @@ -317,51 +309,52 @@ uint8_t do_SIB1_NR(rrc_gNB_carrier_data_t *carrier, // cellSelectionInfo sib1->cellSelectionInfo = CALLOC(1,sizeof(struct NR_SIB1__cellSelectionInfo)); + // Fixme: should be in config file + //The IE Q-RxLevMin is used to indicate for cell selection/ re-selection the required minimum received RSRP level in the (NR) cell. + //Corresponds to parameter Qrxlevmin in TS38.304. + //Actual value Qrxlevmin = field value * 2 [dBm]. sib1->cellSelectionInfo->q_RxLevMin = -65; // cellAccessRelatedInfo - struct NR_PLMN_IdentityInfo *nr_plmn_info=CALLOC(1,sizeof(struct NR_PLMN_IdentityInfo)); - asn_set_empty(&nr_plmn_info->plmn_IdentityList.list); + // TODO : Add support for more than one PLMN + int num_plmn = 1; // int num_plmn = configuration->num_plmn; + asn1cSequenceAdd(sib1->cellAccessRelatedInfo.plmn_IdentityList.list, struct NR_PLMN_IdentityInfo, nr_plmn_info); for (int i = 0; i < num_plmn; ++i) { - nr_mcc_digit[i][0] = (configuration->mcc[i]/100)%10; - nr_mcc_digit[i][1] = (configuration->mcc[i]/10)%10; - nr_mcc_digit[i][2] = (configuration->mcc[i])%10; - nr_plmn[i].mcc = CALLOC(1,sizeof(struct NR_MCC)); - asn_set_empty(&nr_plmn[i].mcc->list); - ASN_SEQUENCE_ADD(&nr_plmn[i].mcc->list, &nr_mcc_digit[i][0]); - ASN_SEQUENCE_ADD(&nr_plmn[i].mcc->list, &nr_mcc_digit[i][1]); - ASN_SEQUENCE_ADD(&nr_plmn[i].mcc->list, &nr_mcc_digit[i][2]); - if(configuration->mnc_digit_length[i] == 3) nr_mnc_digit[i][0] = (configuration->mnc[i]/100)%10; - nr_mnc_digit[i][1] = (configuration->mnc[i]/10)%10; - nr_mnc_digit[i][2] = (configuration->mnc[i])%10; - nr_plmn[i].mnc.list.size=0; - nr_plmn[i].mnc.list.count=0; - if(configuration->mnc_digit_length[i] == 3) ASN_SEQUENCE_ADD(&nr_plmn[i].mnc.list, &nr_mnc_digit[i][0]); - ASN_SEQUENCE_ADD(&nr_plmn[i].mnc.list, &nr_mnc_digit[i][1]); - ASN_SEQUENCE_ADD(&nr_plmn[i].mnc.list, &nr_mnc_digit[i][2]); - ASN_SEQUENCE_ADD(&nr_plmn_info->plmn_IdentityList.list, &nr_plmn[i]); + asn1cSequenceAdd(nr_plmn_info->plmn_IdentityList.list, struct NR_PLMN_Identity, nr_plmn); + asn1cCalloc(nr_plmn->mcc, mcc); + int confMcc=configuration->mcc[i]; + asn1cSequenceAdd(mcc->list, NR_MCC_MNC_Digit_t, mcc0); + *mcc0=(confMcc/100)%10; + asn1cSequenceAdd(mcc->list, NR_MCC_MNC_Digit_t, mcc1); + *mcc1=(confMcc/10)%10; + asn1cSequenceAdd(mcc->list, NR_MCC_MNC_Digit_t, mcc2); + *mcc2=confMcc%10; + int mnc=configuration->mnc[i]; + if(configuration->mnc_digit_length[i] == 3) { + asn1cSequenceAdd(nr_plmn->mnc.list, NR_MCC_MNC_Digit_t, mnc0); + *mnc0=(configuration->mnc[i]/100)%10; + mnc/=10; + } + asn1cSequenceAdd(nr_plmn->mnc.list, NR_MCC_MNC_Digit_t, mnc1); + *mnc1=(mnc/10)%10; + asn1cSequenceAdd(nr_plmn->mnc.list, NR_MCC_MNC_Digit_t, mnc2); + *mnc2=(mnc)%10; }//end plmn loop nr_plmn_info->cellIdentity.buf = CALLOC(1,5); - nr_plmn_info->cellIdentity.buf[0]= (configuration->cell_identity >> 28) & 0xff; - nr_plmn_info->cellIdentity.buf[1]= (configuration->cell_identity >> 20) & 0xff; - nr_plmn_info->cellIdentity.buf[2]= (configuration->cell_identity >> 12) & 0xff; - nr_plmn_info->cellIdentity.buf[3]= (configuration->cell_identity >> 4) & 0xff; - nr_plmn_info->cellIdentity.buf[4]= (configuration->cell_identity << 4) & 0xff; nr_plmn_info->cellIdentity.size= 5; nr_plmn_info->cellIdentity.bits_unused= 4; + uint64_t tmp=htobe64(configuration->cell_identity)<<4; + memcpy(nr_plmn_info->cellIdentity.buf, ((char*)&tmp)+3, 5); nr_plmn_info->cellReservedForOperatorUse = NR_PLMN_IdentityInfo__cellReservedForOperatorUse_notReserved; nr_plmn_info->trackingAreaCode = CALLOC(1,sizeof(NR_TrackingAreaCode_t)); + uint32_t tmp2=htobe32(configuration->tac); nr_plmn_info->trackingAreaCode->buf = CALLOC(1,3); - nr_plmn_info->trackingAreaCode->buf[0] = ( ((uint32_t)configuration->tac) >> 16) & 0xff; - nr_plmn_info->trackingAreaCode->buf[1] = ( ((uint32_t)configuration->tac) >> 8) & 0xff; - nr_plmn_info->trackingAreaCode->buf[2] = ( ((uint32_t)configuration->tac) >> 0) & 0xff; + memcpy(nr_plmn_info->trackingAreaCode->buf, ((char*) &tmp2)+1, 3); nr_plmn_info->trackingAreaCode->size = 3; nr_plmn_info->trackingAreaCode->bits_unused = 0; - ASN_SEQUENCE_ADD(&sib1->cellAccessRelatedInfo.plmn_IdentityList.list, nr_plmn_info); - // connEstFailureControl // TODO: add connEstFailureControl @@ -397,19 +390,19 @@ uint8_t do_SIB1_NR(rrc_gNB_carrier_data_t *carrier, ASN_SEQUENCE_ADD(&sib1->si_SchedulingInfo->schedulingInfoList.list,schedulingInfo);*/ // servingCellConfigCommon - sib1->servingCellConfigCommon = CALLOC(1,sizeof(struct NR_ServingCellConfigCommonSIB)); + asn1cCalloc(sib1->servingCellConfigCommon, ServCellCom); + NR_BWP_DownlinkCommon_t *initialDownlinkBWP=&ServCellCom->downlinkConfigCommon.initialDownlinkBWP; + initialDownlinkBWP->genericParameters= + configuration->scc->downlinkConfigCommon->initialDownlinkBWP->genericParameters; + - asn_set_empty(&sib1->servingCellConfigCommon->downlinkConfigCommon.frequencyInfoDL.frequencyBandList.list); - asn_set_empty(&sib1->servingCellConfigCommon->downlinkConfigCommon.frequencyInfoDL.scs_SpecificCarrierList.list); - sib1->servingCellConfigCommon->downlinkConfigCommon.initialDownlinkBWP.genericParameters.locationAndBandwidth = configuration->scc->downlinkConfigCommon->initialDownlinkBWP->genericParameters.locationAndBandwidth; - sib1->servingCellConfigCommon->downlinkConfigCommon.initialDownlinkBWP.genericParameters.subcarrierSpacing = configuration->scc->downlinkConfigCommon->initialDownlinkBWP->genericParameters.subcarrierSpacing; - sib1->servingCellConfigCommon->downlinkConfigCommon.initialDownlinkBWP.genericParameters.cyclicPrefix = configuration->scc->downlinkConfigCommon->initialDownlinkBWP->genericParameters.cyclicPrefix; for(int i = 0; i< configuration->scc->downlinkConfigCommon->frequencyInfoDL->frequencyBandList.list.count; i++) { - struct NR_NR_MultiBandInfo *nrMultiBandInfo = CALLOC(1,sizeof(struct NR_NR_MultiBandInfo)); + asn1cSequenceAdd(ServCellCom->downlinkConfigCommon.frequencyInfoDL.frequencyBandList.list, + struct NR_NR_MultiBandInfo, nrMultiBandInfo); nrMultiBandInfo->freqBandIndicatorNR = configuration->scc->downlinkConfigCommon->frequencyInfoDL->frequencyBandList.list.array[i]; - ASN_SEQUENCE_ADD(&sib1->servingCellConfigCommon->downlinkConfigCommon.frequencyInfoDL.frequencyBandList.list,nrMultiBandInfo); } + int scs_scaling0 = 1<<(configuration->scc->downlinkConfigCommon->initialDownlinkBWP->genericParameters.subcarrierSpacing); int scs_scaling = scs_scaling0; int scs_scaling2 = scs_scaling0; @@ -432,17 +425,19 @@ uint8_t do_SIB1_NR(rrc_gNB_carrier_data_t *carrier, absolute_diff,scs_scaling2,scs_scaling,(int)sib1->servingCellConfigCommon->downlinkConfigCommon.frequencyInfoDL.offsetToPointA); for(int i = 0; i< configuration->scc->downlinkConfigCommon->frequencyInfoDL->scs_SpecificCarrierList.list.count; i++) { - ASN_SEQUENCE_ADD(&sib1->servingCellConfigCommon->downlinkConfigCommon.frequencyInfoDL.scs_SpecificCarrierList.list,configuration->scc->downlinkConfigCommon->frequencyInfoDL->scs_SpecificCarrierList.list.array[i]); + ASN_SEQUENCE_ADD(&ServCellCom->downlinkConfigCommon.frequencyInfoDL.scs_SpecificCarrierList.list, + configuration->scc->downlinkConfigCommon->frequencyInfoDL->scs_SpecificCarrierList.list.array[i]); } - sib1->servingCellConfigCommon->downlinkConfigCommon.initialDownlinkBWP.pdcch_ConfigCommon = configuration->scc->downlinkConfigCommon->initialDownlinkBWP->pdcch_ConfigCommon; - sib1->servingCellConfigCommon->downlinkConfigCommon.initialDownlinkBWP.pdcch_ConfigCommon->choice.setup->commonSearchSpaceList = CALLOC(1,sizeof(struct NR_PDCCH_ConfigCommon__commonSearchSpaceList)); - asn_set_empty(&sib1->servingCellConfigCommon->downlinkConfigCommon.initialDownlinkBWP.pdcch_ConfigCommon->choice.setup->commonSearchSpaceList->list); + initialDownlinkBWP->pdcch_ConfigCommon = + configuration->scc->downlinkConfigCommon->initialDownlinkBWP->pdcch_ConfigCommon; + initialDownlinkBWP->pdcch_ConfigCommon->choice.setup->commonSearchSpaceList = + CALLOC(1,sizeof(struct NR_PDCCH_ConfigCommon__commonSearchSpaceList)); - NR_SearchSpace_t *ss1 = calloc(1,sizeof(*ss1)); + asn1cSequenceAdd(initialDownlinkBWP->pdcch_ConfigCommon->choice.setup->commonSearchSpaceList->list, + NR_SearchSpace_t, ss1); ss1->searchSpaceId = 1; - ss1->controlResourceSetId=calloc(1,sizeof(*ss1->controlResourceSetId)); - *ss1->controlResourceSetId=0; + asn1cCallocOne(ss1->controlResourceSetId, 0); ss1->monitoringSlotPeriodicityAndOffset = calloc(1,sizeof(*ss1->monitoringSlotPeriodicityAndOffset)); ss1->monitoringSlotPeriodicityAndOffset->present = NR_SearchSpace__monitoringSlotPeriodicityAndOffset_PR_sl1; ss1->monitoringSymbolsWithinSlot = calloc(1,sizeof(*ss1->monitoringSymbolsWithinSlot)); @@ -462,9 +457,9 @@ uint8_t do_SIB1_NR(rrc_gNB_carrier_data_t *carrier, ss1->searchSpaceType->present = NR_SearchSpace__searchSpaceType_PR_common; ss1->searchSpaceType->choice.common=calloc(1,sizeof(*ss1->searchSpaceType->choice.common)); ss1->searchSpaceType->choice.common->dci_Format0_0_AndFormat1_0 = calloc(1,sizeof(*ss1->searchSpaceType->choice.common->dci_Format0_0_AndFormat1_0)); - ASN_SEQUENCE_ADD(&sib1->servingCellConfigCommon->downlinkConfigCommon.initialDownlinkBWP.pdcch_ConfigCommon->choice.setup->commonSearchSpaceList->list,ss1); - NR_SearchSpace_t *ss5 = calloc(1,sizeof(*ss5)); + asn1cSequenceAdd(initialDownlinkBWP->pdcch_ConfigCommon->choice.setup->commonSearchSpaceList->list, + NR_SearchSpace_t, ss5); ss5->searchSpaceId = 5; ss5->controlResourceSetId=calloc(1,sizeof(*ss5->controlResourceSetId)); *ss5->controlResourceSetId=0; @@ -490,9 +485,9 @@ uint8_t do_SIB1_NR(rrc_gNB_carrier_data_t *carrier, ss5->searchSpaceType->present = NR_SearchSpace__searchSpaceType_PR_common; ss5->searchSpaceType->choice.common=calloc(1,sizeof(*ss5->searchSpaceType->choice.common)); ss5->searchSpaceType->choice.common->dci_Format0_0_AndFormat1_0 = calloc(1,sizeof(*ss5->searchSpaceType->choice.common->dci_Format0_0_AndFormat1_0)); - ASN_SEQUENCE_ADD(&sib1->servingCellConfigCommon->downlinkConfigCommon.initialDownlinkBWP.pdcch_ConfigCommon->choice.setup->commonSearchSpaceList->list,ss5); - NR_SearchSpace_t *ss7 = calloc(1,sizeof(*ss7)); + asn1cSequenceAdd(initialDownlinkBWP->pdcch_ConfigCommon->choice.setup->commonSearchSpaceList->list, + NR_SearchSpace_t, ss7); ss7->searchSpaceId = 7; ss7->controlResourceSetId=calloc(1,sizeof(*ss7->controlResourceSetId)); *ss7->controlResourceSetId=0; @@ -515,63 +510,59 @@ uint8_t do_SIB1_NR(rrc_gNB_carrier_data_t *carrier, ss7->searchSpaceType->present = NR_SearchSpace__searchSpaceType_PR_common; ss7->searchSpaceType->choice.common=calloc(1,sizeof(*ss7->searchSpaceType->choice.common)); ss7->searchSpaceType->choice.common->dci_Format0_0_AndFormat1_0 = calloc(1,sizeof(*ss7->searchSpaceType->choice.common->dci_Format0_0_AndFormat1_0)); - ASN_SEQUENCE_ADD(&sib1->servingCellConfigCommon->downlinkConfigCommon.initialDownlinkBWP.pdcch_ConfigCommon->choice.setup->commonSearchSpaceList->list,ss7); - - sib1->servingCellConfigCommon->downlinkConfigCommon.initialDownlinkBWP.pdcch_ConfigCommon->choice.setup->searchSpaceSIB1 = calloc(1,sizeof(NR_SearchSpaceId_t)); - *sib1->servingCellConfigCommon->downlinkConfigCommon.initialDownlinkBWP.pdcch_ConfigCommon->choice.setup->searchSpaceSIB1 = 0; - sib1->servingCellConfigCommon->downlinkConfigCommon.initialDownlinkBWP.pdcch_ConfigCommon->choice.setup->searchSpaceOtherSystemInformation = calloc(1,sizeof(NR_SearchSpaceId_t)); - *sib1->servingCellConfigCommon->downlinkConfigCommon.initialDownlinkBWP.pdcch_ConfigCommon->choice.setup->searchSpaceOtherSystemInformation = 7; - sib1->servingCellConfigCommon->downlinkConfigCommon.initialDownlinkBWP.pdcch_ConfigCommon->choice.setup->pagingSearchSpace = calloc(1,sizeof(NR_SearchSpaceId_t)); - *sib1->servingCellConfigCommon->downlinkConfigCommon.initialDownlinkBWP.pdcch_ConfigCommon->choice.setup->pagingSearchSpace = 5; - sib1->servingCellConfigCommon->downlinkConfigCommon.initialDownlinkBWP.pdcch_ConfigCommon->choice.setup->ra_SearchSpace = calloc(1,sizeof(NR_SearchSpaceId_t)); - *sib1->servingCellConfigCommon->downlinkConfigCommon.initialDownlinkBWP.pdcch_ConfigCommon->choice.setup->ra_SearchSpace = 1; - - sib1->servingCellConfigCommon->downlinkConfigCommon.initialDownlinkBWP.pdsch_ConfigCommon = configuration->scc->downlinkConfigCommon->initialDownlinkBWP->pdsch_ConfigCommon; - sib1->servingCellConfigCommon->downlinkConfigCommon.bcch_Config.modificationPeriodCoeff = NR_BCCH_Config__modificationPeriodCoeff_n2; - sib1->servingCellConfigCommon->downlinkConfigCommon.pcch_Config.defaultPagingCycle = NR_PagingCycle_rf256; - sib1->servingCellConfigCommon->downlinkConfigCommon.pcch_Config.nAndPagingFrameOffset.present = NR_PCCH_Config__nAndPagingFrameOffset_PR_quarterT; - sib1->servingCellConfigCommon->downlinkConfigCommon.pcch_Config.nAndPagingFrameOffset.choice.quarterT = 1; - sib1->servingCellConfigCommon->downlinkConfigCommon.pcch_Config.ns = NR_PCCH_Config__ns_one; - - sib1->servingCellConfigCommon->downlinkConfigCommon.pcch_Config.firstPDCCH_MonitoringOccasionOfPO = calloc(1,sizeof(struct NR_PCCH_Config__firstPDCCH_MonitoringOccasionOfPO)); - sib1->servingCellConfigCommon->downlinkConfigCommon.pcch_Config.firstPDCCH_MonitoringOccasionOfPO->present = NR_PCCH_Config__firstPDCCH_MonitoringOccasionOfPO_PR_sCS120KHZoneT_SCS60KHZhalfT_SCS30KHZquarterT_SCS15KHZoneEighthT; - - sib1->servingCellConfigCommon->downlinkConfigCommon.pcch_Config.firstPDCCH_MonitoringOccasionOfPO->choice.sCS120KHZoneT_SCS60KHZhalfT_SCS30KHZquarterT_SCS15KHZoneEighthT = CALLOC(1,sizeof(struct NR_PCCH_Config__firstPDCCH_MonitoringOccasionOfPO__sCS120KHZoneT_SCS60KHZhalfT_SCS30KHZquarterT_SCS15KHZoneEighthT)); - asn_set_empty(&sib1->servingCellConfigCommon->downlinkConfigCommon.pcch_Config.firstPDCCH_MonitoringOccasionOfPO->choice.sCS120KHZoneT_SCS60KHZhalfT_SCS30KHZquarterT_SCS15KHZoneEighthT->list); - - long *sCS120KHZoneT_SCS60KHZhalfT_SCS30KHZquarterT_SCS15KHZoneEighthT = calloc(1,sizeof(long)); - *sCS120KHZoneT_SCS60KHZhalfT_SCS30KHZquarterT_SCS15KHZoneEighthT = 0; - ASN_SEQUENCE_ADD(&sib1->servingCellConfigCommon->downlinkConfigCommon.pcch_Config.firstPDCCH_MonitoringOccasionOfPO->choice.sCS120KHZoneT_SCS60KHZhalfT_SCS30KHZquarterT_SCS15KHZoneEighthT->list,sCS120KHZoneT_SCS60KHZhalfT_SCS30KHZquarterT_SCS15KHZoneEighthT); - - sib1->servingCellConfigCommon->uplinkConfigCommon = CALLOC(1,sizeof(struct NR_UplinkConfigCommonSIB)); - asn_set_empty(&sib1->servingCellConfigCommon->uplinkConfigCommon->frequencyInfoUL.scs_SpecificCarrierList.list); + + + asn1cCallocOne(initialDownlinkBWP->pdcch_ConfigCommon->choice.setup->searchSpaceSIB1, 0); + asn1cCallocOne(initialDownlinkBWP->pdcch_ConfigCommon->choice.setup->searchSpaceOtherSystemInformation, 7); + asn1cCallocOne(initialDownlinkBWP->pdcch_ConfigCommon->choice.setup->pagingSearchSpace, 5); + asn1cCallocOne( initialDownlinkBWP->pdcch_ConfigCommon->choice.setup->ra_SearchSpace, 1); + + initialDownlinkBWP->pdsch_ConfigCommon = configuration->scc->downlinkConfigCommon->initialDownlinkBWP->pdsch_ConfigCommon; + ServCellCom->downlinkConfigCommon.bcch_Config.modificationPeriodCoeff = NR_BCCH_Config__modificationPeriodCoeff_n2; + ServCellCom->downlinkConfigCommon.pcch_Config.defaultPagingCycle = NR_PagingCycle_rf256; + ServCellCom->downlinkConfigCommon.pcch_Config.nAndPagingFrameOffset.present = NR_PCCH_Config__nAndPagingFrameOffset_PR_quarterT; + ServCellCom->downlinkConfigCommon.pcch_Config.nAndPagingFrameOffset.choice.quarterT = 1; + ServCellCom->downlinkConfigCommon.pcch_Config.ns = NR_PCCH_Config__ns_one; + + asn1cCalloc(ServCellCom->downlinkConfigCommon.pcch_Config.firstPDCCH_MonitoringOccasionOfPO, + P0); + P0->present = NR_PCCH_Config__firstPDCCH_MonitoringOccasionOfPO_PR_sCS120KHZoneT_SCS60KHZhalfT_SCS30KHZquarterT_SCS15KHZoneEighthT; + + asn1cCalloc(P0->choice.sCS120KHZoneT_SCS60KHZhalfT_SCS30KHZquarterT_SCS15KHZoneEighthT, + Z8); + asn1cSequenceAdd(Z8->list, + long, + ZoneEight); + asn1cCallocOne(ZoneEight, 0); + + asn1cCalloc(ServCellCom->uplinkConfigCommon, UL) + asn_set_empty(&UL->frequencyInfoUL.scs_SpecificCarrierList.list); for(int i = 0; i< configuration->scc->uplinkConfigCommon->frequencyInfoUL->scs_SpecificCarrierList.list.count; i++) { - ASN_SEQUENCE_ADD(&sib1->servingCellConfigCommon->uplinkConfigCommon->frequencyInfoUL.scs_SpecificCarrierList.list,configuration->scc->uplinkConfigCommon->frequencyInfoUL->scs_SpecificCarrierList.list.array[i]); + ASN_SEQUENCE_ADD(&UL->frequencyInfoUL.scs_SpecificCarrierList.list, + configuration->scc->uplinkConfigCommon->frequencyInfoUL->scs_SpecificCarrierList.list.array[i]); } - sib1->servingCellConfigCommon->uplinkConfigCommon->frequencyInfoUL.p_Max = CALLOC(1,sizeof(NR_P_Max_t)); - *sib1->servingCellConfigCommon->uplinkConfigCommon->frequencyInfoUL.p_Max = 23; - - sib1->servingCellConfigCommon->uplinkConfigCommon->initialUplinkBWP.genericParameters = configuration->scc->uplinkConfigCommon->initialUplinkBWP->genericParameters; - sib1->servingCellConfigCommon->uplinkConfigCommon->initialUplinkBWP.rach_ConfigCommon = configuration->scc->uplinkConfigCommon->initialUplinkBWP->rach_ConfigCommon; + asn1cCallocOne(UL->frequencyInfoUL.p_Max, 23); - sib1->servingCellConfigCommon->uplinkConfigCommon->initialUplinkBWP.pusch_ConfigCommon = configuration->scc->uplinkConfigCommon->initialUplinkBWP->pusch_ConfigCommon; - sib1->servingCellConfigCommon->uplinkConfigCommon->initialUplinkBWP.pusch_ConfigCommon->choice.setup->groupHoppingEnabledTransformPrecoding = null; + UL->initialUplinkBWP.genericParameters = configuration->scc->uplinkConfigCommon->initialUplinkBWP->genericParameters; + UL->initialUplinkBWP.rach_ConfigCommon = configuration->scc->uplinkConfigCommon->initialUplinkBWP->rach_ConfigCommon; + UL->initialUplinkBWP.pusch_ConfigCommon = configuration->scc->uplinkConfigCommon->initialUplinkBWP->pusch_ConfigCommon; + UL->initialUplinkBWP.pusch_ConfigCommon->choice.setup->groupHoppingEnabledTransformPrecoding = null; - sib1->servingCellConfigCommon->uplinkConfigCommon->initialUplinkBWP.pucch_ConfigCommon = configuration->scc->uplinkConfigCommon->initialUplinkBWP->pucch_ConfigCommon; + UL->initialUplinkBWP.pucch_ConfigCommon = configuration->scc->uplinkConfigCommon->initialUplinkBWP->pucch_ConfigCommon; - sib1->servingCellConfigCommon->uplinkConfigCommon->timeAlignmentTimerCommon = NR_TimeAlignmentTimer_infinity; + UL->timeAlignmentTimerCommon = NR_TimeAlignmentTimer_infinity; - sib1->servingCellConfigCommon->n_TimingAdvanceOffset = configuration->scc->n_TimingAdvanceOffset; + ServCellCom->n_TimingAdvanceOffset = configuration->scc->n_TimingAdvanceOffset; - sib1->servingCellConfigCommon->ssb_PositionsInBurst.inOneGroup.buf = calloc(1, sizeof(uint8_t)); + ServCellCom->ssb_PositionsInBurst.inOneGroup.buf = calloc(1, sizeof(uint8_t)); uint8_t bitmap8,temp_bitmap=0; switch (configuration->scc->ssb_PositionsInBurst->present) { case NR_ServingCellConfigCommon__ssb_PositionsInBurst_PR_shortBitmap: - sib1->servingCellConfigCommon->ssb_PositionsInBurst.inOneGroup = configuration->scc->ssb_PositionsInBurst->choice.shortBitmap; + ServCellCom->ssb_PositionsInBurst.inOneGroup = configuration->scc->ssb_PositionsInBurst->choice.shortBitmap; break; case NR_ServingCellConfigCommon__ssb_PositionsInBurst_PR_mediumBitmap: - sib1->servingCellConfigCommon->ssb_PositionsInBurst.inOneGroup = configuration->scc->ssb_PositionsInBurst->choice.mediumBitmap; + ServCellCom->ssb_PositionsInBurst.inOneGroup = configuration->scc->ssb_PositionsInBurst->choice.mediumBitmap; break; /* groupPresence: This field is present when maximum number of SS/PBCH blocks per half frame equals to 64 as defined in TS 38.213 [13], clause 4.1. @@ -582,14 +573,13 @@ uint8_t do_SIB1_NR(rrc_gNB_carrier_data_t *carrier, (i.e., to SSB index 1, 9, and so on), and so on. Value 0 in the bitmap indicates that the corresponding SS/PBCH block is not transmitted while value 1 indicates that the corresponding SS/PBCH block is transmitted. */ case NR_ServingCellConfigCommon__ssb_PositionsInBurst_PR_longBitmap: - sib1->servingCellConfigCommon->ssb_PositionsInBurst.inOneGroup.size = 1; - sib1->servingCellConfigCommon->ssb_PositionsInBurst.inOneGroup.bits_unused = 0; - sib1->servingCellConfigCommon->ssb_PositionsInBurst.groupPresence = calloc(1, sizeof(BIT_STRING_t)); - memset(sib1->servingCellConfigCommon->ssb_PositionsInBurst.groupPresence, 0, sizeof(BIT_STRING_t)); - sib1->servingCellConfigCommon->ssb_PositionsInBurst.groupPresence->size = 1; - sib1->servingCellConfigCommon->ssb_PositionsInBurst.groupPresence->bits_unused = 0; - sib1->servingCellConfigCommon->ssb_PositionsInBurst.groupPresence->buf = calloc(1, sizeof(uint8_t)); - sib1->servingCellConfigCommon->ssb_PositionsInBurst.groupPresence->buf[0] = 0; + ServCellCom->ssb_PositionsInBurst.inOneGroup.size = 1; + ServCellCom->ssb_PositionsInBurst.inOneGroup.bits_unused = 0; + ServCellCom->ssb_PositionsInBurst.groupPresence = calloc(1, sizeof(BIT_STRING_t)); + ServCellCom->ssb_PositionsInBurst.groupPresence->size = 1; + ServCellCom->ssb_PositionsInBurst.groupPresence->bits_unused = 0; + ServCellCom->ssb_PositionsInBurst.groupPresence->buf = calloc(1, sizeof(uint8_t)); + ServCellCom->ssb_PositionsInBurst.groupPresence->buf[0] = 0; for (int i=0; i<8; i++){ bitmap8 = configuration->scc->ssb_PositionsInBurst->choice.longBitmap.buf[i]; if (bitmap8!=0){ @@ -598,8 +588,8 @@ uint8_t do_SIB1_NR(rrc_gNB_carrier_data_t *carrier, else AssertFatal(temp_bitmap==bitmap8,"For longBitmap the groups of 8 SSBs containing at least 1 transmitted SSB should be all the same\n"); - sib1->servingCellConfigCommon->ssb_PositionsInBurst.inOneGroup.buf[0] = bitmap8; - sib1->servingCellConfigCommon->ssb_PositionsInBurst.groupPresence->buf[0] |= 1<<(7-i); + ServCellCom->ssb_PositionsInBurst.inOneGroup.buf[0] = bitmap8; + ServCellCom->ssb_PositionsInBurst.groupPresence->buf[0] |= 1<<(7-i); } } break; @@ -608,12 +598,12 @@ uint8_t do_SIB1_NR(rrc_gNB_carrier_data_t *carrier, break; } - sib1->servingCellConfigCommon->ssb_PeriodicityServingCell = *configuration->scc->ssb_periodicityServingCell; - sib1->servingCellConfigCommon->tdd_UL_DL_ConfigurationCommon = CALLOC(1,sizeof(struct NR_TDD_UL_DL_ConfigCommon)); - sib1->servingCellConfigCommon->tdd_UL_DL_ConfigurationCommon->referenceSubcarrierSpacing = configuration->scc->tdd_UL_DL_ConfigurationCommon->referenceSubcarrierSpacing; - sib1->servingCellConfigCommon->tdd_UL_DL_ConfigurationCommon->pattern1 = configuration->scc->tdd_UL_DL_ConfigurationCommon->pattern1; - sib1->servingCellConfigCommon->tdd_UL_DL_ConfigurationCommon->pattern2 = configuration->scc->tdd_UL_DL_ConfigurationCommon->pattern2; - sib1->servingCellConfigCommon->ss_PBCH_BlockPower = configuration->scc->ss_PBCH_BlockPower; + ServCellCom->ssb_PeriodicityServingCell = *configuration->scc->ssb_periodicityServingCell; + ServCellCom->tdd_UL_DL_ConfigurationCommon = CALLOC(1,sizeof(struct NR_TDD_UL_DL_ConfigCommon)); + ServCellCom->tdd_UL_DL_ConfigurationCommon->referenceSubcarrierSpacing = configuration->scc->tdd_UL_DL_ConfigurationCommon->referenceSubcarrierSpacing; + ServCellCom->tdd_UL_DL_ConfigurationCommon->pattern1 = configuration->scc->tdd_UL_DL_ConfigurationCommon->pattern1; + ServCellCom->tdd_UL_DL_ConfigurationCommon->pattern2 = configuration->scc->tdd_UL_DL_ConfigurationCommon->pattern2; + ServCellCom->ss_PBCH_BlockPower = configuration->scc->ss_PBCH_BlockPower; // ims-EmergencySupport // TODO: add ims-EmergencySupport @@ -987,10 +977,42 @@ uint8_t do_RRCReject(uint8_t Mod_id, return((enc_rval.encoded+7)/8); } +// TODO: Implement to b_SRS = 1 and b_SRS = 2 +long rrc_get_max_nr_csrs(uint8_t max_rbs, long b_SRS) { + + if(b_SRS>0) { + LOG_E(NR_RRC,"rrc_get_max_nr_csrs(): Not implemented yet for b_SRS>0\n"); + return 0; // This c_srs is always valid + } + + const uint16_t m_SRS[64] = { 4, 8, 12, 16, 16, 20, 24, 24, 28, 32, 36, 40, 48, 48, 52, 56, 60, 64, 72, 72, 76, 80, 88, + 96, 96, 104, 112, 120, 120, 120, 128, 128, 128, 132, 136, 144, 144, 144, 144, 152, 160, + 160, 160, 168, 176, 184, 192, 192, 192, 192, 208, 216, 224, 240, 240, 240, 240, 256, 256, + 256, 264, 272, 272, 272 }; + + long c_srs = 0; + uint16_t m = 4; + for(int c = 1; c<64; c++) { + if(m_SRS[c]>m && m_SRS[c]<max_rbs) { + c_srs = c; + m = m_SRS[c]; + } + } + + return c_srs; +} + void fill_initial_SpCellConfig(rnti_t rnti, + int uid, NR_SpCellConfig_t *SpCellConfig, NR_ServingCellConfigCommon_t *scc, rrc_gNB_carrier_data_t *carrier) { + + // This assert will never happen in the current implementation because NUMBER_OF_UE_MAX = 4. + // However, if in the future NUMBER_OF_UE_MAX is increased, it will be necessary to improve the allocation of SRS resources, + // where the startPosition = 2 or 3 and sl160 = 17, 17, 27 ... 157 only give us 30 different allocations. + AssertFatal(uid>=0 && uid<30, "gNB cannot allocate the SRS resources\n"); + int curr_bwp = NRRIV2BW(scc->downlinkConfigCommon->initialDownlinkBWP->genericParameters.locationAndBandwidth,MAX_BWP_SIZE); SpCellConfig->servCellIndex = NULL; SpCellConfig->reconfigurationWithSync = NULL; @@ -1069,7 +1091,7 @@ void fill_initial_SpCellConfig(rnti_t rnti, pusch_Config->pusch_PowerControl->pathlossReferenceRSToAddModList = calloc(1,sizeof(*pusch_Config->pusch_PowerControl->pathlossReferenceRSToAddModList)); NR_PUSCH_PathlossReferenceRS_t *plrefRS = calloc(1,sizeof(*plrefRS)); plrefRS->pusch_PathlossReferenceRS_Id=0; - plrefRS->referenceSignal.present = NR_PathlossReferenceRS_Config_PR_ssb_Index; + plrefRS->referenceSignal.present = NR_PUSCH_PathlossReferenceRS__referenceSignal_PR_ssb_Index; plrefRS->referenceSignal.choice.ssb_Index = 0; ASN_SEQUENCE_ADD(&pusch_Config->pusch_PowerControl->pathlossReferenceRSToAddModList->list,plrefRS); pusch_Config->pusch_PowerControl->pathlossReferenceRSToReleaseList = NULL; @@ -1116,13 +1138,21 @@ void fill_initial_SpCellConfig(rnti_t rnti, *srs_resset0_id=0; ASN_SEQUENCE_ADD(&srs_resset0->srs_ResourceIdList->list,srs_resset0_id); srs_Config->srs_ResourceToReleaseList=NULL; - srs_resset0->resourceType.present = NR_SRS_ResourceSet__resourceType_PR_aperiodic; - srs_resset0->resourceType.choice.aperiodic = calloc(1,sizeof(*srs_resset0->resourceType.choice.aperiodic)); - srs_resset0->resourceType.choice.aperiodic->aperiodicSRS_ResourceTrigger=1; - srs_resset0->resourceType.choice.aperiodic->csi_RS=NULL; - srs_resset0->resourceType.choice.aperiodic->slotOffset= calloc(1,sizeof(*srs_resset0->resourceType.choice.aperiodic->slotOffset)); - *srs_resset0->resourceType.choice.aperiodic->slotOffset=2; - srs_resset0->resourceType.choice.aperiodic->ext1=NULL; + + if(carrier->do_SRS) { + srs_resset0->resourceType.present = NR_SRS_ResourceSet__resourceType_PR_periodic; + srs_resset0->resourceType.choice.periodic = calloc(1,sizeof(*srs_resset0->resourceType.choice.periodic)); + srs_resset0->resourceType.choice.periodic->associatedCSI_RS = NULL; + } else { + srs_resset0->resourceType.present = NR_SRS_ResourceSet__resourceType_PR_aperiodic; + srs_resset0->resourceType.choice.aperiodic = calloc(1,sizeof(*srs_resset0->resourceType.choice.aperiodic)); + srs_resset0->resourceType.choice.aperiodic->aperiodicSRS_ResourceTrigger=1; + srs_resset0->resourceType.choice.aperiodic->csi_RS=NULL; + srs_resset0->resourceType.choice.aperiodic->slotOffset= calloc(1,sizeof(*srs_resset0->resourceType.choice.aperiodic->slotOffset)); + *srs_resset0->resourceType.choice.aperiodic->slotOffset=2; + srs_resset0->resourceType.choice.aperiodic->ext1=NULL; + } + srs_resset0->usage=NR_SRS_ResourceSet__usage_codebook; srs_resset0->alpha = calloc(1,sizeof(*srs_resset0->alpha)); *srs_resset0->alpha = NR_Alpha_alpha1; @@ -1141,17 +1171,28 @@ void fill_initial_SpCellConfig(rnti_t rnti, srs_res0->transmissionComb.choice.n2=calloc(1,sizeof(*srs_res0->transmissionComb.choice.n2)); srs_res0->transmissionComb.choice.n2->combOffset_n2=0; srs_res0->transmissionComb.choice.n2->cyclicShift_n2=0; - srs_res0->resourceMapping.startPosition=2; + srs_res0->resourceMapping.startPosition = 2 + uid%2; srs_res0->resourceMapping.nrofSymbols=NR_SRS_Resource__resourceMapping__nrofSymbols_n1; srs_res0->resourceMapping.repetitionFactor=NR_SRS_Resource__resourceMapping__repetitionFactor_n1; srs_res0->freqDomainPosition=0; srs_res0->freqDomainShift=0; - srs_res0->freqHopping.c_SRS = 0; srs_res0->freqHopping.b_SRS=0; srs_res0->freqHopping.b_hop=0; + srs_res0->freqHopping.c_SRS = rrc_get_max_nr_csrs( + NRRIV2BW(scc->uplinkConfigCommon->initialUplinkBWP->genericParameters.locationAndBandwidth, 275), + srs_res0->freqHopping.b_SRS); srs_res0->groupOrSequenceHopping=NR_SRS_Resource__groupOrSequenceHopping_neither; - srs_res0->resourceType.present= NR_SRS_Resource__resourceType_PR_aperiodic; - srs_res0->resourceType.choice.aperiodic=calloc(1,sizeof(*srs_res0->resourceType.choice.aperiodic)); + + if(carrier->do_SRS) { + srs_res0->resourceType.present= NR_SRS_Resource__resourceType_PR_periodic; + srs_res0->resourceType.choice.periodic=calloc(1,sizeof(*srs_res0->resourceType.choice.periodic)); + srs_res0->resourceType.choice.periodic->periodicityAndOffset_p.present = NR_SRS_PeriodicityAndOffset_PR_sl160; + srs_res0->resourceType.choice.periodic->periodicityAndOffset_p.choice.sl160 = 17 + (uid>1)*10; // 17/17/.../147/157 are mixed slots + } else { + srs_res0->resourceType.present= NR_SRS_Resource__resourceType_PR_aperiodic; + srs_res0->resourceType.choice.aperiodic=calloc(1,sizeof(*srs_res0->resourceType.choice.aperiodic)); + } + srs_res0->sequenceId=40; srs_res0->spatialRelationInfo=calloc(1,sizeof(*srs_res0->spatialRelationInfo)); srs_res0->spatialRelationInfo->servingCellId=NULL; @@ -1185,9 +1226,9 @@ void fill_initial_SpCellConfig(rnti_t rnti, long *delay[8]; for (int i=0;i<8;i++) { delay[i] = calloc(1,sizeof(*delay[i])); - AssertFatal(carrier->minRXTXTIMEpdsch >=2 && carrier->minRXTXTIMEpdsch <7, - "check minRXTXTIMEpdsch %d\n",carrier->minRXTXTIMEpdsch); - *delay[i] = (i+carrier->minRXTXTIMEpdsch); + AssertFatal(carrier->minRXTXTIME >=2 && carrier->minRXTXTIME <7, + "check minRXTXTIME %d\n",carrier->minRXTXTIME); + *delay[i] = (i+carrier->minRXTXTIME); ASN_SEQUENCE_ADD(&pucch_Config->dl_DataToUL_ACK->list,delay[i]); } @@ -1401,6 +1442,7 @@ void fill_mastercellGroupConfig(NR_CellGroupConfig_t *cellGroupConfig, NR_CellGr } void fill_initial_cellGroupConfig(rnti_t rnti, + int uid, NR_CellGroupConfig_t *cellGroupConfig, NR_ServingCellConfigCommon_t *scc, rrc_gNB_carrier_data_t *carrier) { @@ -1494,7 +1536,7 @@ void fill_initial_cellGroupConfig(rnti_t rnti, cellGroupConfig->spCellConfig = calloc(1,sizeof(*cellGroupConfig->spCellConfig)); - fill_initial_SpCellConfig(rnti,cellGroupConfig->spCellConfig,scc,carrier); + fill_initial_SpCellConfig(rnti,uid,cellGroupConfig->spCellConfig,scc,carrier); cellGroupConfig->sCellToAddModList = NULL; cellGroupConfig->sCellToReleaseList = NULL; @@ -1573,7 +1615,7 @@ uint8_t do_RRCSetup(rrc_gNB_ue_context_t *const ue_context_pP, } else { cellGroupConfig = calloc(1, sizeof(NR_CellGroupConfig_t)); - fill_initial_cellGroupConfig(ue_context_pP->ue_context.rnti,cellGroupConfig,scc,carrier); + fill_initial_cellGroupConfig(ue_context_pP->ue_context.rnti,ue_context_pP->local_uid,cellGroupConfig,scc,carrier); enc_rval = uper_encode_to_buffer(&asn_DEF_NR_CellGroupConfig, NULL, @@ -1771,6 +1813,7 @@ uint8_t do_NR_SA_UECapabilityEnquiry( const protocol_ctxt_t *const ctxt_pP, uint8_t do_NR_RRCRelease(uint8_t *buffer, + size_t buffer_size, uint8_t Transaction_id) { asn_enc_rval_t enc_rval; NR_DL_DCCH_Message_t dl_dcch_msg; @@ -1796,7 +1839,7 @@ uint8_t do_NR_RRCRelease(uint8_t *buffer, NULL, (void *)&dl_dcch_msg, buffer, - RRC_BUF_SIZE); + buffer_size); if(enc_rval.encoded == -1) { LOG_I(NR_RRC, "[gNB AssertFatal]ASN1 message encoding failed (%s, %lu)!\n", enc_rval.failed_type->name, enc_rval.encoded); @@ -1809,6 +1852,7 @@ uint8_t do_NR_RRCRelease(uint8_t *buffer, int16_t do_RRCReconfiguration( const protocol_ctxt_t *const ctxt_pP, uint8_t *buffer, + size_t buffer_size, uint8_t Transaction_id, NR_SRB_ToAddModList_t *SRB_configList, NR_DRB_ToAddModList_t *DRB_configList, @@ -1904,7 +1948,7 @@ int16_t do_RRCReconfiguration( NULL, (void *)&dl_dcch_msg, buffer, - 1000); + buffer_size); if(enc_rval.encoded == -1) { LOG_I(NR_RRC, "[gNB AssertFatal]ASN1 message encoding failed (%s, %lu)!\n", @@ -1929,7 +1973,7 @@ int16_t do_RRCReconfiguration( } -uint8_t do_RRCSetupRequest(uint8_t Mod_id, uint8_t *buffer,uint8_t *rv) { +uint8_t do_RRCSetupRequest(uint8_t Mod_id, uint8_t *buffer, size_t buffer_size, uint8_t *rv) { asn_enc_rval_t enc_rval; uint8_t buf[5],buf2=0; NR_UL_CCCH_Message_t ul_ccch_msg; @@ -1973,16 +2017,51 @@ uint8_t do_RRCSetupRequest(uint8_t Mod_id, uint8_t *buffer,uint8_t *rv) { NULL, (void *)&ul_ccch_msg, buffer, - 100); + buffer_size); AssertFatal (enc_rval.encoded > 0, "ASN1 message encoding failed (%s, %lu)!\n", enc_rval.failed_type->name, enc_rval.encoded); LOG_D(NR_RRC,"[UE] RRCSetupRequest Encoded %zd bits (%zd bytes)\n", enc_rval.encoded, (enc_rval.encoded+7)/8); return((enc_rval.encoded+7)/8); } + +//------------------------------------------------------------------------------ +uint8_t +do_NR_RRCReconfigurationComplete_for_nsa( + uint8_t *buffer, + size_t buffer_size, + NR_RRC_TransactionIdentifier_t Transaction_id +) +//------------------------------------------------------------------------------ +{ + NR_RRCReconfigurationComplete_t rrc_complete_msg; + memset(&rrc_complete_msg, 0, sizeof(rrc_complete_msg)); + rrc_complete_msg.rrc_TransactionIdentifier = Transaction_id; + rrc_complete_msg.criticalExtensions.choice.rrcReconfigurationComplete = + CALLOC(1, sizeof(*rrc_complete_msg.criticalExtensions.choice.rrcReconfigurationComplete)); + rrc_complete_msg.criticalExtensions.present = + NR_RRCReconfigurationComplete__criticalExtensions_PR_rrcReconfigurationComplete; + rrc_complete_msg.criticalExtensions.choice.rrcReconfigurationComplete->nonCriticalExtension = NULL; + rrc_complete_msg.criticalExtensions.choice.rrcReconfigurationComplete->lateNonCriticalExtension = NULL; + if (0) { + xer_fprint(stdout, &asn_DEF_NR_RRCReconfigurationComplete, (void *)&rrc_complete_msg); + } + + asn_enc_rval_t enc_rval = uper_encode_to_buffer(&asn_DEF_NR_RRCReconfigurationComplete, + NULL, + (void *)&rrc_complete_msg, + buffer, + buffer_size); + AssertFatal (enc_rval.encoded > 0, "ASN1 message encoding failed (%s, %lu)!\n", + enc_rval.failed_type->name, enc_rval.encoded); + LOG_A(NR_RRC, "rrcReconfigurationComplete Encoded %zd bits (%zd bytes)\n", enc_rval.encoded, (enc_rval.encoded+7)/8); + return((enc_rval.encoded+7)/8); +} + //------------------------------------------------------------------------------ uint8_t do_NR_RRCReconfigurationComplete( const protocol_ctxt_t *const ctxt_pP, uint8_t *buffer, + size_t buffer_size, const uint8_t Transaction_id ) //------------------------------------------------------------------------------ @@ -2010,14 +2089,15 @@ do_NR_RRCReconfigurationComplete( NULL, (void *)&ul_dcch_msg, buffer, - 100); + buffer_size); AssertFatal (enc_rval.encoded > 0, "ASN1 message encoding failed (%s, %lu)!\n", enc_rval.failed_type->name, enc_rval.encoded); LOG_I(NR_RRC,"rrcReconfigurationComplete Encoded %zd bits (%zd bytes)\n",enc_rval.encoded,(enc_rval.encoded+7)/8); return((enc_rval.encoded+7)/8); } -uint8_t do_RRCSetupComplete(uint8_t Mod_id, uint8_t *buffer, const uint8_t Transaction_id, uint8_t sel_plmn_id, const int dedicatedInfoNASLength, const char *dedicatedInfoNAS){ +uint8_t do_RRCSetupComplete(uint8_t Mod_id, uint8_t *buffer, size_t buffer_size, + const uint8_t Transaction_id, uint8_t sel_plmn_id, const int dedicatedInfoNASLength, const char *dedicatedInfoNAS){ asn_enc_rval_t enc_rval; NR_UL_DCCH_Message_t ul_dcch_msg; @@ -2060,7 +2140,7 @@ enc_rval = uper_encode_to_buffer(&asn_DEF_NR_UL_DCCH_Message, NULL, (void *)&ul_dcch_msg, buffer, - 100); + buffer_size); AssertFatal(enc_rval.encoded > 0,"ASN1 message encoding failed (%s, %lu)!\n", enc_rval.failed_type->name,enc_rval.encoded); LOG_D(NR_RRC,"RRCSetupComplete Encoded %zd bits (%zd bytes)\n",enc_rval.encoded,(enc_rval.encoded+7)/8); @@ -2175,6 +2255,7 @@ const protocol_ctxt_t *const ctxt_pP, rrc_gNB_ue_context_t *const ue_context_pP, int CC_id, uint8_t *const buffer, +size_t buffer_size, //const uint8_t transmission_mode, const uint8_t Transaction_id, NR_SRB_ToAddModList_t **SRB_configList @@ -2297,7 +2378,7 @@ NR_SRB_ToAddModList_t **SRB_configList } uint8_t -do_RRCReestablishmentComplete(uint8_t *buffer, int64_t rrc_TransactionIdentifier) { +do_RRCReestablishmentComplete(uint8_t *buffer, size_t buffer_size, int64_t rrc_TransactionIdentifier) { asn_enc_rval_t enc_rval; NR_UL_DCCH_Message_t ul_dcch_msg; NR_RRCReestablishmentComplete_t *rrcReestablishmentComplete; @@ -2323,7 +2404,7 @@ do_RRCReestablishmentComplete(uint8_t *buffer, int64_t rrc_TransactionIdentifier NULL, (void *)&ul_dcch_msg, buffer, - 100); + buffer_size); AssertFatal (enc_rval.encoded > 0, "ASN1 message encoding failed (%s, %lu)!\n", enc_rval.failed_type->name, enc_rval.encoded); LOG_D(NR_RRC,"[UE] RRCReestablishmentComplete Encoded %zd bits (%zd bytes)\n", enc_rval.encoded, (enc_rval.encoded+7)/8); return((enc_rval.encoded+7)/8); diff --git a/openair2/RRC/NR/MESSAGES/asn1_msg.h b/openair2/RRC/NR/MESSAGES/asn1_msg.h index b9a3ea6dac9a2297d01d31161ec59389e9181e02..b029a42fa0738374813c55cc08ed0e122be9dcb6 100644 --- a/openair2/RRC/NR/MESSAGES/asn1_msg.h +++ b/openair2/RRC/NR/MESSAGES/asn1_msg.h @@ -28,6 +28,8 @@ * \email: raymond.knopp@eurecom.fr and navid.nikaein@eurecom.fr, kroempa@gmail.com */ +#pragma once + #include <stdio.h> #include <sys/types.h> #include <stdlib.h> /* for atoi(3) */ @@ -53,6 +55,15 @@ */ int xer_sprint_NR(char *string, size_t string_size, struct asn_TYPE_descriptor_s *td, void *sptr); + +#define asn1cCallocOne(VaR, VaLue) \ + VaR = calloc(1,sizeof(*VaR)); *VaR=VaLue; +#define asn1cCalloc(VaR, lOcPtr) \ + typeof(VaR) lOcPtr = VaR = calloc(1,sizeof(*VaR)); +#define asn1cSequenceAdd(VaR, TyPe, lOcPtr) \ + TyPe *lOcPtr= calloc(1,sizeof(TyPe)); \ + ASN_SEQUENCE_ADD(&VaR,lOcPtr); + uint8_t do_MIB_NR(gNB_RRC_INST *rrc, uint32_t frame); @@ -90,13 +101,15 @@ uint8_t do_RRCReject(uint8_t Mod_id, uint8_t *const buffer); void fill_initial_SpCellConfig(rnti_t rnti, - NR_SpCellConfig_t *SpCellConfig, - NR_ServingCellConfigCommon_t *scc, + int uid, + NR_SpCellConfig_t *SpCellConfig, + NR_ServingCellConfigCommon_t *scc, rrc_gNB_carrier_data_t *carrier); void fill_initial_cellGroupConfig(rnti_t rnti, - NR_CellGroupConfig_t *cellGroupConfig, - NR_ServingCellConfigCommon_t *scc, + int uid, + NR_CellGroupConfig_t *cellGroupConfig, + NR_ServingCellConfigCommon_t *scc, rrc_gNB_carrier_data_t *carrier); void fill_mastercellGroupConfig(NR_CellGroupConfig_t *cellGroupConfig, NR_CellGroupConfig_t *ue_context_mastercellGroup,int use_rlc_um_for_drb); @@ -119,12 +132,13 @@ uint8_t do_NR_SA_UECapabilityEnquiry( const protocol_ctxt_t *const ctxt_pP, uint8_t *const buffer, const uint8_t Transaction_id); -uint8_t do_NR_RRCRelease(uint8_t *buffer, +uint8_t do_NR_RRCRelease(uint8_t *buffer, size_t buffer_size, uint8_t Transaction_id); int16_t do_RRCReconfiguration( const protocol_ctxt_t *const ctxt_pP, uint8_t *buffer, + size_t buffer_size, uint8_t Transaction_id, NR_SRB_ToAddModList_t *SRB_configList, NR_DRB_ToAddModList_t *DRB_configList, @@ -135,19 +149,23 @@ int16_t do_RRCReconfiguration( struct NR_RRCReconfiguration_v1530_IEs__dedicatedNAS_MessageList *dedicatedNAS_MessageList, NR_MAC_CellGroupConfig_t *mac_CellGroupConfig, NR_CellGroupConfig_t *cellGroupConfig); - -uint8_t do_RRCSetupComplete(uint8_t Mod_id, - uint8_t *buffer, - const uint8_t Transaction_id, - uint8_t sel_plmn_id, - const int dedicatedInfoNASLength, + +uint8_t do_RRCSetupComplete(uint8_t Mod_id, + uint8_t *buffer, + size_t buffer_size, + const uint8_t Transaction_id, + uint8_t sel_plmn_id, + const int dedicatedInfoNASLength, const char *dedicatedInfoNAS); -uint8_t do_RRCSetupRequest(uint8_t Mod_id, uint8_t *buffer,uint8_t *rv); +uint8_t do_RRCSetupRequest(uint8_t Mod_id, uint8_t *buffer, size_t buffer_size, uint8_t *rv); + +uint8_t do_NR_RRCReconfigurationComplete_for_nsa(uint8_t *buffer, size_t buffer_size, NR_RRC_TransactionIdentifier_t Transaction_id); uint8_t do_NR_RRCReconfigurationComplete( const protocol_ctxt_t *const ctxt_pP, uint8_t *buffer, + size_t buffer_size, const uint8_t Transaction_id ); @@ -172,6 +190,7 @@ do_RRCReestablishment( rrc_gNB_ue_context_t *const ue_context_pP, int CC_id, uint8_t *const buffer, + size_t buffer_size, //const uint8_t transmission_mode, const uint8_t Transaction_id, NR_SRB_ToAddModList_t **SRB_configList @@ -179,6 +198,6 @@ do_RRCReestablishment( uint8_t do_RRCReestablishmentComplete( - uint8_t *buffer, + uint8_t *buffer, size_t buffer_size, int64_t rrc_TransactionIdentifier); diff --git a/openair2/RRC/NR/nr_rrc_config.c b/openair2/RRC/NR/nr_rrc_config.c index dedd4cf8396986a538f85960a781c840e89daa56..6b7f9a21b93cfc13f1f95d8c07c070014928b524 100644 --- a/openair2/RRC/NR/nr_rrc_config.c +++ b/openair2/RRC/NR/nr_rrc_config.c @@ -29,96 +29,79 @@ */ #include "nr_rrc_config.h" +#include "common/utils/nr/nr_common.h" -void rrc_config_rlc_bearer(uint8_t Mod_id, - int CC_id, - rlc_bearer_config_t *rlc_config - ){ - rlc_config->LogicalChannelIdentity[CC_id] = 0; - rlc_config->servedRadioBearer_present[CC_id] = 0; - rlc_config->srb_Identity[CC_id] = 0; - rlc_config->drb_Identity[CC_id] = 0; - rlc_config->reestablishRLC[CC_id] = 0; - rlc_config->rlc_Config_present[CC_id] = 0; - rlc_config->ul_AM_sn_FieldLength[CC_id] = 0; - rlc_config->t_PollRetransmit[CC_id] = 0; - rlc_config->pollPDU[CC_id] = 0; - rlc_config->pollByte[CC_id] = 0; - rlc_config->maxRetxThreshold[CC_id] = 0; - rlc_config->dl_AM_sn_FieldLength[CC_id] = 0; - rlc_config->dl_AM_t_Reassembly[CC_id] = 0; - rlc_config->t_StatusProhibit[CC_id] = 0; - rlc_config->ul_UM_sn_FieldLength[CC_id] = 0; - rlc_config->dl_UM_sn_FieldLength[CC_id] = 0; - rlc_config->dl_UM_t_Reassembly[CC_id] = 0; - rlc_config->priority[CC_id] = 0; - rlc_config->prioritisedBitRate[CC_id] = 0; - rlc_config->bucketSizeDuration[CC_id] = 0; - rlc_config->allowedServingCells[CC_id] = 0; - rlc_config->subcarrierspacing[CC_id] = 0; - rlc_config->maxPUSCH_Duration[CC_id] = 0; - rlc_config->configuredGrantType1Allowed[CC_id] = 0; - rlc_config->logicalChannelGroup[CC_id] = 0; - rlc_config->schedulingRequestID[CC_id] = 0; - rlc_config->logicalChannelSR_Mask[CC_id] = 0; - rlc_config->logicalChannelSR_DelayTimerApplied[CC_id] = 0; -} +void nr_rrc_config_dl_tda(NR_ServingCellConfigCommon_t *scc){ -void rrc_config_mac_cellgroup(uint8_t Mod_id, - int CC_id, - mac_cellgroup_t *mac_cellgroup_config - ){ - mac_cellgroup_config->DRX_Config_PR[CC_id] = 0; - mac_cellgroup_config->drx_onDurationTimer_PR[CC_id] = 0; - mac_cellgroup_config->subMilliSeconds[CC_id] = 0; - mac_cellgroup_config->milliSeconds[CC_id] = 0; - mac_cellgroup_config->drx_InactivityTimer[CC_id] = 0; - mac_cellgroup_config->drx_HARQ_RTT_TimerDL[CC_id] = 0; - mac_cellgroup_config->drx_HARQ_RTT_TimerUL[CC_id] = 0; - mac_cellgroup_config->drx_RetransmissionTimerDL[CC_id] = 0; - mac_cellgroup_config->drx_RetransmissionTimerUL[CC_id] = 0; - mac_cellgroup_config->drx_LongCycleStartOffset_PR[CC_id] = 0; - mac_cellgroup_config->drx_LongCycleStartOffset[CC_id] = 0; - mac_cellgroup_config->drx_ShortCycle[CC_id] = 0; - mac_cellgroup_config->drx_ShortCycleTimer[CC_id] = 0; - mac_cellgroup_config->drx_SlotOffset[CC_id] = 0; - mac_cellgroup_config->schedulingRequestId[CC_id] = 0; - mac_cellgroup_config->sr_ProhibitTimer[CC_id] = 0; - mac_cellgroup_config->sr_TransMax[CC_id] = 0; - mac_cellgroup_config->periodicBSR_Timer[CC_id] = 0; - mac_cellgroup_config->retxBSR_Timer[CC_id] = 0; - mac_cellgroup_config->logicalChannelSR_DelayTimer[CC_id] = 0; - mac_cellgroup_config->tag_Id[CC_id] = 0; - mac_cellgroup_config->timeAlignmentTimer[CC_id] = 0; - mac_cellgroup_config->PHR_Config_PR[CC_id] = 0; - mac_cellgroup_config->phr_PeriodicTimer[CC_id] = 0; - mac_cellgroup_config->phr_ProhibitTimer[CC_id] = 0; - mac_cellgroup_config->phr_Tx_PowerFactorChange[CC_id] = 0; - mac_cellgroup_config->multiplePHR[CC_id] = 0; - mac_cellgroup_config->phr_Type2SpCell[CC_id] = 0; - mac_cellgroup_config->phr_Type2OtherCell[CC_id] = 0; - mac_cellgroup_config->phr_ModeOtherCG[CC_id] = 0; - mac_cellgroup_config->skipUplinkTxDynamic[CC_id] = 0; -} + lte_frame_type_t frame_type = get_frame_type(*scc->downlinkConfigCommon->frequencyInfoDL->frequencyBandList.list.array[0], *scc->ssbSubcarrierSpacing); + + // setting default TDA for DL with + struct NR_PDSCH_TimeDomainResourceAllocation *timedomainresourceallocation = CALLOC(1,sizeof(NR_PDSCH_TimeDomainResourceAllocation_t)); + timedomainresourceallocation->mappingType = NR_PDSCH_TimeDomainResourceAllocation__mappingType_typeA; + timedomainresourceallocation->startSymbolAndLength = get_SLIV(1,13); // basic slot configuration starting in symbol 1 til the end of the slot + ASN_SEQUENCE_ADD(&scc->downlinkConfigCommon->initialDownlinkBWP->pdsch_ConfigCommon->choice.setup->pdsch_TimeDomainAllocationList->list, + timedomainresourceallocation); -void rrc_config_physicalcellgroup(uint8_t Mod_id, - int CC_id, - physicalcellgroup_t *physicalcellgroup_config - ){ - physicalcellgroup_config->harq_ACK_SpatialBundlingPUCCH[CC_id] = 0; - physicalcellgroup_config->harq_ACK_SpatialBundlingPUSCH[CC_id] = 0; - physicalcellgroup_config->p_NR[CC_id] = 0; - physicalcellgroup_config->pdsch_HARQ_ACK_Codebook[CC_id] = 0; - physicalcellgroup_config->tpc_SRS_RNTI[CC_id] = 0; - physicalcellgroup_config->tpc_PUCCH_RNTI[CC_id] = 0; - physicalcellgroup_config->tpc_PUSCH_RNTI[CC_id] = 0; - physicalcellgroup_config->sp_CSI_RNTI[CC_id] = 0; - physicalcellgroup_config->RNTI_Value[CC_id] = 0; + if(frame_type==TDD) { + // TDD + if(scc->tdd_UL_DL_ConfigurationCommon) { + int dl_symb = scc->tdd_UL_DL_ConfigurationCommon->pattern1.nrofDownlinkSymbols; + if(dl_symb > 1) { + timedomainresourceallocation = CALLOC(1,sizeof(NR_PDSCH_TimeDomainResourceAllocation_t)); + timedomainresourceallocation->mappingType = NR_PDSCH_TimeDomainResourceAllocation__mappingType_typeA; + timedomainresourceallocation->startSymbolAndLength = get_SLIV(1,dl_symb-1); // mixed slot configuration starting in symbol 1 til the end of the dl allocation + ASN_SEQUENCE_ADD(&scc->downlinkConfigCommon->initialDownlinkBWP->pdsch_ConfigCommon->choice.setup->pdsch_TimeDomainAllocationList->list, + timedomainresourceallocation); + } + } + } } -void rrc_config_rachdedicated(uint8_t Mod_id, - int CC_id, - physicalcellgroup_t *physicalcellgroup_config - ){ - + +void nr_rrc_config_ul_tda(NR_ServingCellConfigCommon_t *scc, int min_fb_delay){ + + //TODO change to accomodate for SRS + + int temp_min_delay = 6; // k2 = 2 or 3 won'r work as well as higher values + int k2 = (min_fb_delay<temp_min_delay)?temp_min_delay:min_fb_delay; + + uint8_t DELTA[4]= {2,3,4,6}; // Delta parameter for Msg3 + int mu = scc->uplinkConfigCommon->initialUplinkBWP->genericParameters.subcarrierSpacing; + lte_frame_type_t frame_type = get_frame_type(*scc->downlinkConfigCommon->frequencyInfoDL->frequencyBandList.list.array[0], *scc->ssbSubcarrierSpacing); + + struct NR_PUSCH_TimeDomainResourceAllocation *pusch_timedomainresourceallocation = CALLOC(1,sizeof(struct NR_PUSCH_TimeDomainResourceAllocation)); + pusch_timedomainresourceallocation->k2 = CALLOC(1,sizeof(long)); + *pusch_timedomainresourceallocation->k2 = k2; + pusch_timedomainresourceallocation->mappingType = NR_PUSCH_TimeDomainResourceAllocation__mappingType_typeB; + pusch_timedomainresourceallocation->startSymbolAndLength = get_SLIV(0,13); // basic slot configuration starting in symbol 0 til the last but one symbol + ASN_SEQUENCE_ADD(&scc->uplinkConfigCommon->initialUplinkBWP->pusch_ConfigCommon->choice.setup->pusch_TimeDomainAllocationList->list,pusch_timedomainresourceallocation); + + if(frame_type==TDD) { + // TDD + if(scc->tdd_UL_DL_ConfigurationCommon) { + int ul_symb = scc->tdd_UL_DL_ConfigurationCommon->pattern1.nrofUplinkSymbols; + pusch_timedomainresourceallocation = CALLOC(1,sizeof(struct NR_PUSCH_TimeDomainResourceAllocation)); + pusch_timedomainresourceallocation->k2 = CALLOC(1,sizeof(long)); + *pusch_timedomainresourceallocation->k2 = k2; + pusch_timedomainresourceallocation->mappingType = NR_PUSCH_TimeDomainResourceAllocation__mappingType_typeB; + pusch_timedomainresourceallocation->startSymbolAndLength = get_SLIV(14-ul_symb,ul_symb-1); // starting in fist ul symbol til the last but one + ASN_SEQUENCE_ADD(&scc->uplinkConfigCommon->initialUplinkBWP->pusch_ConfigCommon->choice.setup->pusch_TimeDomainAllocationList->list,pusch_timedomainresourceallocation); + + // for msg3 in the mixed slot + int nb_periods_per_frame = get_nb_periods_per_frame(scc->tdd_UL_DL_ConfigurationCommon->pattern1.dl_UL_TransmissionPeriodicity); + int nb_slots_per_period = ((1<<mu) * 10)/nb_periods_per_frame; + struct NR_PUSCH_TimeDomainResourceAllocation *pusch_timedomainresourceallocation_msg3 = CALLOC(1,sizeof(struct NR_PUSCH_TimeDomainResourceAllocation)); + pusch_timedomainresourceallocation_msg3->k2 = CALLOC(1,sizeof(long)); + *pusch_timedomainresourceallocation_msg3->k2 = nb_slots_per_period - DELTA[mu]; + if(*pusch_timedomainresourceallocation_msg3->k2 < min_fb_delay) + *pusch_timedomainresourceallocation_msg3->k2 += nb_slots_per_period; + AssertFatal(*pusch_timedomainresourceallocation_msg3->k2<33,"Computed k2 for msg3 %ld is larger than the range allowed by RRC (0..32)\n", + *pusch_timedomainresourceallocation_msg3->k2); + pusch_timedomainresourceallocation_msg3->mappingType = NR_PUSCH_TimeDomainResourceAllocation__mappingType_typeB; + pusch_timedomainresourceallocation_msg3->startSymbolAndLength = get_SLIV(14-ul_symb,ul_symb-1); // starting in fist ul symbol til the last but one + ASN_SEQUENCE_ADD(&scc->uplinkConfigCommon->initialUplinkBWP->pusch_ConfigCommon->choice.setup->pusch_TimeDomainAllocationList->list,pusch_timedomainresourceallocation_msg3); + } + } + } + diff --git a/openair2/RRC/NR/nr_rrc_config.h b/openair2/RRC/NR/nr_rrc_config.h index e19d94b34123076c173795322e046d6fbd97b8dd..192fee754ed28ae40526b1283ea0c6013da56926 100644 --- a/openair2/RRC/NR/nr_rrc_config.h +++ b/openair2/RRC/NR/nr_rrc_config.h @@ -111,29 +111,8 @@ typedef struct physicalcellgroup_s{ long RNTI_Value[MAX_NUM_CCs]; }physicalcellgroup_t; -typedef struct rach_dedicated_s{ - - -}rach_dedicated_t; +void nr_rrc_config_dl_tda(NR_ServingCellConfigCommon_t *scc); +void nr_rrc_config_ul_tda(NR_ServingCellConfigCommon_t *scc, int min_fb_delay); -void rrc_config_servingcellconfigcommon(uint8_t Mod_id, - int CC_id, - gNB_RrcConfigurationReq *common_configuration - ); - -void rrc_config_rlc_bearer(uint8_t Mod_id, - int CC_id, - rlc_bearer_config_t *rlc_config - ); - -void rrc_config_mac_cellgroup(uint8_t Mod_id, - int CC_id, - mac_cellgroup_t *mac_cellgroup_config - ); - -void rrc_config_physicalcellgroup(uint8_t Mod_id, - int CC_id, - physicalcellgroup_t *physicalcellgroup_config - ); #endif diff --git a/openair2/RRC/NR/nr_rrc_defs.h b/openair2/RRC/NR/nr_rrc_defs.h index 95f3772b719f4c89bf7f2843c4e7db563b3c49c2..75ef6df4d27e1b52d460fe91cbb40eea1346f012 100644 --- a/openair2/RRC/NR/nr_rrc_defs.h +++ b/openair2/RRC/NR/nr_rrc_defs.h @@ -123,12 +123,12 @@ typedef enum UE_STATE_NR_e { #define RRM_CALLOC(t,n) (t *) malloc16( sizeof(t) * n) #define RRM_CALLOC2(t,s) (t *) malloc16( s ) -#define MAX_MEAS_OBJ 6 -#define MAX_MEAS_CONFIG 6 -#define MAX_MEAS_ID 6 +#define MAX_MEAS_OBJ 7 +#define MAX_MEAS_CONFIG 7 +#define MAX_MEAS_ID 7 #define PAYLOAD_SIZE_MAX 1024 -#define RRC_BUF_SIZE 8192 +#define RRC_BUF_SIZE 512 #define UNDEF_SECURITY_MODE 0xff #define NO_SECURITY_MODE 0x20 @@ -367,6 +367,8 @@ typedef struct gNB_RRC_UE_s { transport_layer_addr_t gnb_gtp_addrs[S1AP_MAX_E_RAB]; rb_id_t gnb_gtp_ebi[S1AP_MAX_E_RAB]; rb_id_t gnb_gtp_psi[S1AP_MAX_E_RAB]; + //GTPV1 F1-U TUNNELS + uint32_t incoming_teid[S1AP_MAX_E_RAB]; uint32_t ul_failure_timer; uint32_t ue_release_timer; @@ -447,8 +449,9 @@ typedef struct { int sib1_tda; int pdsch_AntennaPorts; int pusch_AntennaPorts; - int minRXTXTIMEpdsch; + int minRXTXTIME; int do_CSIRS; + int do_SRS; NR_BCCH_DL_SCH_Message_t *siblock1; NR_ServingCellConfigCommon_t *servingcellconfigcommon; NR_PDCCH_ConfigSIB1_t *pdcch_ConfigSIB1; @@ -521,6 +524,8 @@ typedef struct gNB_RRC_INST_s { int cell_info_configured; pthread_mutex_t cell_info_mutex; + char *uecap_file; + // security configuration (preferred algorithms) nr_security_configuration_t security; } gNB_RRC_INST; diff --git a/openair2/RRC/NR/nr_rrc_proto.h b/openair2/RRC/NR/nr_rrc_proto.h index 9465b9b4b066f05be0c1431bb1a81d85c4dde931..40de13dfb03467fd5c341c19e4540c9fc0ce1bf4 100644 --- a/openair2/RRC/NR/nr_rrc_proto.h +++ b/openair2/RRC/NR/nr_rrc_proto.h @@ -79,7 +79,9 @@ void fill_default_secondaryCellGroup(NR_ServingCellConfigCommon_t *servingcellco int scg_id, int servCellIndex, int dl_antenna_ports, + int minRXTXTIMEpdsch, int do_csirs, + int do_srs, int initial_csi_index, int uid); @@ -90,7 +92,9 @@ void fill_default_reconfig(NR_ServingCellConfigCommon_t *servingcellconfigcommon NR_RRCReconfiguration_IEs_t *reconfig, NR_CellGroupConfig_t *secondaryCellGroup, int dl_antenna_ports, + int minRXTXTIMEpdsch, int do_csirs, + int do_srs, int initial_csi_index, int uid); diff --git a/openair2/RRC/NR/rrc_gNB.c b/openair2/RRC/NR/rrc_gNB.c index 2ff3da787c08d65dc6085b32698edf55a9cf6e68..cb350dbb698528595ad59f5671aa6d54373ac64d 100755 --- a/openair2/RRC/NR/rrc_gNB.c +++ b/openair2/RRC/NR/rrc_gNB.c @@ -47,6 +47,12 @@ #include "NR_BCCH-BCH-Message.h" #include "NR_UL-DCCH-Message.h" #include "NR_DL-DCCH-Message.h" +#include "NR_DL-CCCH-Message.h" +#include "NR_UL-CCCH-Message.h" +#include "NR_RRCReject.h" +#include "NR_RejectWaitTime.h" +#include "NR_RRCSetup.h" + #include "NR_CellGroupConfig.h" #include "NR_MeasResults.h" #include "LTE_UECapabilityInformation.h" @@ -88,6 +94,7 @@ #include "executables/softmodem-common.h" #include <openair2/RRC/NR/rrc_gNB_UE_context.h> #include <openair2/X2AP/x2ap_eNB.h> +#include <openair3/ocp-gtpu/gtp_itf.h> #include "BIT_STRING.h" #include "assertions.h" @@ -125,6 +132,23 @@ uint8_t first_rrcreconfiguration = 0; ///---------------------------------------------------------------------------------------------------------------/// ///---------------------------------------------------------------------------------------------------------------/// +boolean_t DURecvCb( protocol_ctxt_t *ctxt_pP, + const srb_flag_t srb_flagP, + const rb_id_t rb_idP, + const mui_t muiP, + const confirm_t confirmP, + const sdu_size_t sdu_buffer_sizeP, + unsigned char *const sdu_buffer_pP, + const pdcp_transmission_mode_t modeP, + const uint32_t *sourceL2Id, + const uint32_t *destinationL2Id) { + // The buffer comes from the stack in gtp-u thread, we have a make a separate buffer to enqueue in a inter-thread message queue + mem_block_t *sdu=get_free_mem_block(sdu_buffer_sizeP, __func__); + memcpy(sdu->data, sdu_buffer_pP, sdu_buffer_sizeP); + du_rlc_data_req(ctxt_pP,srb_flagP, false, rb_idP,muiP, confirmP, sdu_buffer_sizeP, sdu); + return true; +} + void openair_nr_rrc_on(const protocol_ctxt_t *const ctxt_pP) { LOG_I(NR_RRC, PROTOCOL_NR_RRC_CTXT_FMT" gNB:OPENAIR NR RRC IN....\n",PROTOCOL_NR_RRC_CTXT_ARGS(ctxt_pP)); rrc_config_nr_buffer (&RC.nrrrc[ctxt_pP->module_id]->carrier.SI, BCCH, 1); @@ -136,80 +160,6 @@ void openair_nr_rrc_on(const protocol_ctxt_t *const ctxt_pP) { ///---------------------------------------------------------------------------------------------------------------/// ///---------------------------------------------------------------------------------------------------------------/// -void rrc_gNB_process_SgNBAdditionRequest( - const protocol_ctxt_t *const ctxt_pP, - rrc_gNB_ue_context_t *ue_context_pP -) { - rrc_gNB_generate_SgNBAdditionRequestAcknowledge(ctxt_pP,ue_context_pP); -} - -void rrc_gNB_generate_SgNBAdditionRequestAcknowledge( - const protocol_ctxt_t *const ctxt_pP, - rrc_gNB_ue_context_t *const ue_context_pP) { - //uint8_t size; - //uint8_t buffer[100]; - //int CC_id = ue_context_pP->ue_context.primaryCC_id; - //OCTET_STRING_t *secondaryCellGroup; - NR_CellGroupConfig_t *cellGroupconfig; - struct NR_CellGroupConfig__rlc_BearerToAddModList *rlc_BearerToAddModList; - struct NR_MAC_CellGroupConfig *mac_CellGroupConfig; - struct NR_PhysicalCellGroupConfig *physicalCellGroupConfig; - struct NR_SpCellConfig *spCellConfig; - //struct NR_CellGroupConfig__sCellToAddModList *sCellToAddModList; - cellGroupconfig = CALLOC(1,sizeof(NR_CellGroupConfig_t)); - cellGroupconfig->rlc_BearerToAddModList = CALLOC(1,sizeof(struct NR_CellGroupConfig__rlc_BearerToAddModList)); - cellGroupconfig->mac_CellGroupConfig = CALLOC(1,sizeof(struct NR_MAC_CellGroupConfig)); - cellGroupconfig->physicalCellGroupConfig = CALLOC(1,sizeof(struct NR_PhysicalCellGroupConfig)); - cellGroupconfig->spCellConfig = CALLOC(1,sizeof(struct NR_SpCellConfig)); - //cellGroupconfig->sCellToAddModList = CALLOC(1,sizeof(struct NR_CellGroupConfig__sCellToAddModList)); - rlc_BearerToAddModList = cellGroupconfig->rlc_BearerToAddModList; - mac_CellGroupConfig = cellGroupconfig->mac_CellGroupConfig; - physicalCellGroupConfig = cellGroupconfig->physicalCellGroupConfig; - spCellConfig = cellGroupconfig->spCellConfig; - //sCellToAddModList = cellGroupconfig->sCellToAddModList; - rlc_bearer_config_t *rlc_config; - rlc_config = CALLOC(1,sizeof(rlc_bearer_config_t)); - //Fill rlc_bearer config value - rrc_config_rlc_bearer(ctxt_pP->module_id, - ue_context_pP->ue_context.primaryCC_id, - rlc_config - ); - //Fill rlc_bearer config to structure - do_RLC_BEARER(ctxt_pP->module_id, - ue_context_pP->ue_context.primaryCC_id, - rlc_BearerToAddModList, - rlc_config); - mac_cellgroup_t *mac_cellgroup_config; - mac_cellgroup_config = CALLOC(1,sizeof(mac_cellgroup_t)); - //Fill mac_cellgroup_config config value - rrc_config_mac_cellgroup(ctxt_pP->module_id, - ue_context_pP->ue_context.primaryCC_id, - mac_cellgroup_config - ); - //Fill mac_cellgroup config to structure - do_MAC_CELLGROUP(ctxt_pP->module_id, - ue_context_pP->ue_context.primaryCC_id, - mac_CellGroupConfig, - mac_cellgroup_config); - physicalcellgroup_t *physicalcellgroup_config; - physicalcellgroup_config = CALLOC(1,sizeof(physicalcellgroup_t)); - //Fill physicalcellgroup_config config value - rrc_config_physicalcellgroup(ctxt_pP->module_id, - ue_context_pP->ue_context.primaryCC_id, - physicalcellgroup_config - ); - //Fill physicalcellgroup config to structure - do_PHYSICALCELLGROUP(ctxt_pP->module_id, - ue_context_pP->ue_context.primaryCC_id, - physicalCellGroupConfig, - physicalcellgroup_config); - do_SpCellConfig(RC.nrrrc[ctxt_pP->module_id], - spCellConfig); -} - -///---------------------------------------------------------------------------------------------------------------/// -///---------------------------------------------------------------------------------------------------------------/// - static void init_NR_SI(gNB_RRC_INST *rrc, gNB_RrcConfigurationReq *configuration) { LOG_D(RRC,"%s()\n\n\n\n",__FUNCTION__); if (NODE_IS_DU(rrc->node_type) || NODE_IS_MONOLITHIC(rrc->node_type)) { @@ -252,56 +202,12 @@ static void init_NR_SI(gNB_RRC_INST *rrc, gNB_RrcConfigurationReq *configuration pthread_mutex_unlock(&rrc->cell_info_mutex); if (get_softmodem_params()->phy_test > 0 || get_softmodem_params()->do_ra > 0) { - // This is for phytest only, emulate first X2 message if uecap.raw file is present - FILE *fd; - fd = fopen("uecap.raw","r"); - - if (fd != NULL) { - char buffer[4096]; - int msg_len=fread(buffer,1,4096,fd); - LOG_I(RRC,"Read in %d bytes for uecap\n",msg_len); - LTE_UL_DCCH_Message_t *LTE_UL_DCCH_Message; - asn_dec_rval_t dec_rval = uper_decode_complete( NULL, - &asn_DEF_LTE_UL_DCCH_Message, - (void **)<E_UL_DCCH_Message, - (uint8_t *)buffer, - msg_len); - - if ((dec_rval.code != RC_OK) && (dec_rval.consumed == 0)) { - AssertFatal(1==0,"NR_UL_DCCH_MESSAGE decode error\n"); - // free the memory - SEQUENCE_free( &asn_DEF_LTE_UL_DCCH_Message, LTE_UL_DCCH_Message, 1 ); - return; - } - - fclose(fd); - xer_fprint(stdout,&asn_DEF_LTE_UL_DCCH_Message, LTE_UL_DCCH_Message); - // recreate enough of X2 EN-DC Container - AssertFatal(LTE_UL_DCCH_Message->message.choice.c1.present == LTE_UL_DCCH_MessageType__c1_PR_ueCapabilityInformation, - "ueCapabilityInformation not present\n"); - NR_CG_ConfigInfo_t *CG_ConfigInfo = calloc(1,sizeof(*CG_ConfigInfo)); - CG_ConfigInfo->criticalExtensions.present = NR_CG_ConfigInfo__criticalExtensions_PR_c1; - CG_ConfigInfo->criticalExtensions.choice.c1 = calloc(1,sizeof(*CG_ConfigInfo->criticalExtensions.choice.c1)); - CG_ConfigInfo->criticalExtensions.choice.c1->present = NR_CG_ConfigInfo__criticalExtensions__c1_PR_cg_ConfigInfo; - CG_ConfigInfo->criticalExtensions.choice.c1->choice.cg_ConfigInfo = calloc(1,sizeof(*CG_ConfigInfo->criticalExtensions.choice.c1->choice.cg_ConfigInfo)); - NR_CG_ConfigInfo_IEs_t *cg_ConfigInfo = CG_ConfigInfo->criticalExtensions.choice.c1->choice.cg_ConfigInfo; - cg_ConfigInfo->ue_CapabilityInfo = calloc(1,sizeof(*cg_ConfigInfo->ue_CapabilityInfo)); - asn_enc_rval_t enc_rval = uper_encode_to_buffer(&asn_DEF_LTE_UE_CapabilityRAT_ContainerList,NULL, - (void *)<E_UL_DCCH_Message->message.choice.c1.choice.ueCapabilityInformation.criticalExtensions.choice.c1.choice.ueCapabilityInformation_r8.ue_CapabilityRAT_ContainerList,buffer,4096); - AssertFatal (enc_rval.encoded > 0, "ASN1 message encoding failed (%s, %jd)!\n", - enc_rval.failed_type->name, enc_rval.encoded); - OCTET_STRING_fromBuf(cg_ConfigInfo->ue_CapabilityInfo, - (const char *)buffer, - (enc_rval.encoded+7)>>3); - parse_CG_ConfigInfo(rrc,CG_ConfigInfo,NULL); - } else { - struct rrc_gNB_ue_context_s *ue_context_p = rrc_gNB_allocate_new_UE_context(rrc); - ue_context_p->ue_context.spCellConfig = calloc(1, sizeof(struct NR_SpCellConfig)); - ue_context_p->ue_context.spCellConfig->spCellConfigDedicated = configuration->scd; - LOG_I(NR_RRC,"Adding new user (%p)\n",ue_context_p); - if (!NODE_IS_CU(RC.nrrrc[0]->node_type)) { - rrc_add_nsa_user(rrc,ue_context_p,NULL); - } + struct rrc_gNB_ue_context_s *ue_context_p = rrc_gNB_allocate_new_UE_context(rrc); + ue_context_p->ue_context.spCellConfig = calloc(1, sizeof(struct NR_SpCellConfig)); + ue_context_p->ue_context.spCellConfig->spCellConfigDedicated = configuration->scd; + LOG_I(NR_RRC,"Adding new user (%p)\n",ue_context_p); + if (!NODE_IS_CU(RC.nrrrc[0]->node_type)) { + rrc_add_nsa_user(rrc,ue_context_p,NULL); } } } @@ -330,9 +236,11 @@ char openair_rrc_gNB_configuration(const module_id_t gnb_mod_idP, gNB_RrcConfigu rrc->carrier.ssb_SubcarrierOffset = configuration->ssb_SubcarrierOffset; rrc->carrier.pdsch_AntennaPorts = configuration->pdsch_AntennaPorts; rrc->carrier.pusch_AntennaPorts = configuration->pusch_AntennaPorts; - rrc->carrier.minRXTXTIMEpdsch = configuration->minRXTXTIMEpdsch; + rrc->carrier.minRXTXTIME = configuration->minRXTXTIME; rrc->carrier.sib1_tda = configuration->sib1_tda; rrc->carrier.do_CSIRS = configuration->do_CSIRS; + rrc->carrier.do_SRS = configuration->do_SRS; + nr_rrc_config_ul_tda(configuration->scc,configuration->minRXTXTIME); /// System Information INIT pthread_mutex_init(&rrc->cell_info_mutex,NULL); rrc->cell_info_configured = 0; @@ -365,6 +273,8 @@ void rrc_gNB_process_AdditionRequestInformation(const module_id_t gnb_mod_idP, x AssertFatal(cg_configinfo->criticalExtensions.choice.c1->present == NR_CG_ConfigInfo__criticalExtensions__c1_PR_cg_ConfigInfo, "ueCapabilityInformation not present\n"); parse_CG_ConfigInfo(rrc,cg_configinfo,m); + LOG_A(NR_RRC, "Successfully parsed CG_ConfigInfo of size %zu bits. (%zu bytes)\n", + dec_rval.consumed, (dec_rval.consumed +7/8)); } @@ -398,7 +308,7 @@ void apply_macrlc_config(gNB_RRC_INST *rrc, nr_rrc_rlc_config_asn1_req(ctxt_pP, ue_context_pP->ue_context.SRB_configList, - NULL, + ue_context_pP->ue_context.DRB_configList, NULL, NULL, get_softmodem_params()->sa ? ue_context_pP->ue_context.masterCellGroup->rlc_BearerToAddModList : NULL); @@ -708,7 +618,7 @@ rrc_gNB_process_RRCSetupComplete( ) //----------------------------------------------------------------------------- { - LOG_I(NR_RRC, PROTOCOL_NR_RRC_CTXT_UE_FMT" [RAPROC] Logical Channel UL-DCCH, " "processing NR_RRCSetupComplete from UE (SRB1 Active)\n", + LOG_A(NR_RRC, PROTOCOL_NR_RRC_CTXT_UE_FMT" [RAPROC] Logical Channel UL-DCCH, " "processing NR_RRCSetupComplete from UE (SRB1 Active)\n", PROTOCOL_NR_RRC_CTXT_UE_ARGS(ctxt_pP)); ue_context_pP->ue_context.Srb1.Active = 1; ue_context_pP->ue_context.Srb1.Srb_info.Srb_id = 1; @@ -839,8 +749,8 @@ rrc_gNB_generate_defaultRRCReconfiguration( dedicatedNAS_MessageList = NULL; } - memset(buffer, 0, RRC_BUF_SIZE); - size = do_RRCReconfiguration(ctxt_pP, buffer, + memset(buffer, 0, sizeof(buffer)); + size = do_RRCReconfiguration(ctxt_pP, buffer, sizeof(buffer), xid, NULL, //*SRB_configList2, NULL, //*DRB_configList, @@ -1107,11 +1017,11 @@ rrc_gNB_generate_dedicatedRRCReconfiguration( dedicatedNAS_MessageList = NULL; } - memset(buffer, 0, RRC_BUF_SIZE); + memset(buffer, 0, sizeof(buffer)); cellGroupConfig = calloc(1, sizeof(NR_CellGroupConfig_t)); fill_mastercellGroupConfig(cellGroupConfig, ue_context_pP->ue_context.masterCellGroup, rrc->um_on_default_drb); - size = do_RRCReconfiguration(ctxt_pP, buffer, + size = do_RRCReconfiguration(ctxt_pP, buffer, sizeof(buffer), xid, *SRB_configList2, *DRB_configList, @@ -1219,8 +1129,8 @@ rrc_gNB_generate_dedicatedRRCReconfiguration_release( LOG_W(NR_RRC,"dedlicated NAS list is empty\n"); } - memset(buffer, 0, RRC_BUF_SIZE); - size = do_RRCReconfiguration(ctxt_pP, buffer, xid, + memset(buffer, 0, sizeof(buffer)); + size = do_RRCReconfiguration(ctxt_pP, buffer, sizeof(buffer), xid, NULL, NULL, *DRB_Release_configList2, @@ -1299,7 +1209,7 @@ rrc_gNB_process_RRCReconfigurationComplete( NR_SRB_ToAddModList_t *SRB_configList = ue_context_pP->ue_context.SRB_configList2[xid]; NR_DRB_ToReleaseList_t *DRB_Release_configList2 = ue_context_pP->ue_context.DRB_Release_configList2[xid]; NR_DRB_Identity_t *drb_id_p = NULL; -// uint8_t nr_DRB2LCHAN[8]; + // uint8_t nr_DRB2LCHAN[8]; gNB_RRC_INST *rrc = RC.nrrrc[ctxt_pP->module_id]; ue_context_pP->ue_context.ue_reestablishment_timer = 0; @@ -1363,6 +1273,49 @@ rrc_gNB_process_RRCReconfigurationComplete( NULL, get_softmodem_params()->sa ? ue_context_pP->ue_context.masterCellGroup->rlc_BearerToAddModList : NULL); } + else if(SRB_configList!=NULL || DRB_configList!=NULL){ + MessageDef *message_p; + message_p = itti_alloc_new_message (TASK_RRC_GNB, 0, F1AP_UE_CONTEXT_SETUP_REQ); + f1ap_ue_context_setup_t *req=&F1AP_UE_CONTEXT_SETUP_REQ (message_p); + req->gNB_CU_ue_id = 0; + req->gNB_DU_ue_id = 0; + req->rnti = ue_context_pP->ue_context.rnti; + req->mcc = rrc->configuration.mcc[0]; + req->mnc = rrc->configuration.mnc[0]; + req->mnc_digit_length = rrc->configuration.mnc_digit_length[0]; + req->nr_cellid = rrc->nr_cellid; + if(SRB_configList!=NULL){ + req->srbs_to_be_setup = malloc(SRB_configList->list.count*sizeof(f1ap_srb_to_be_setup_t)); + req->srbs_to_be_setup_length = SRB_configList->list.count; + f1ap_srb_to_be_setup_t *SRBs=req->srbs_to_be_setup; + for (int i = 0; i < SRB_configList->list.count; i++){ + if(SRB_configList->list.array[i]->srb_Identity > 1){ + SRBs[i].srb_id = SRB_configList->list.array[i]->srb_Identity; + SRBs[i].lcid = SRB_configList->list.array[i]->srb_Identity; + } + } + } + if(DRB_configList!=NULL){ + gtpv1u_gnb_create_tunnel_req_t create_tunnel_req; + memset(&create_tunnel_req, 0, sizeof(gtpv1u_gnb_create_tunnel_req_t)); + req->drbs_to_be_setup = malloc(DRB_configList->list.count*sizeof(f1ap_drb_to_be_setup_t)); + req->drbs_to_be_setup_length = DRB_configList->list.count; + f1ap_drb_to_be_setup_t *DRBs=req->drbs_to_be_setup; + LOG_I(RRC, "Length of DRB list:%d, %d \n", DRB_configList->list.count, req->drbs_to_be_setup_length); + for (int i = 0; i < DRB_configList->list.count; i++){ + DRBs[i].drb_id = DRB_configList->list.array[i]->drb_Identity; + DRBs[i].rlc_mode = RLC_MODE_AM; + DRBs[i].up_ul_tnl[0].tl_address = inet_addr(rrc->eth_params_s.my_addr); + DRBs[i].up_ul_tnl[0].port=rrc->eth_params_s.my_portd; + DRBs[i].up_ul_tnl_length = 1; + DRBs[i].up_dl_tnl[0].tl_address = inet_addr(rrc->eth_params_s.remote_addr); + DRBs[i].up_dl_tnl[0].port=rrc->eth_params_s.remote_portd; + DRBs[i].up_dl_tnl_length = 1; + } + LOG_I(RRC, "Send F1AP_UE_CONTEXT_SETUP_REQ with ITTI\n"); + } + itti_send_msg_to_task (TASK_CU_F1, ctxt_pP->module_id, message_p); + } #endif /* Set the SRB active in UE context */ @@ -1396,7 +1349,7 @@ rrc_gNB_process_RRCReconfigurationComplete( for (int i = 0; i < DRB_configList->list.count; i++) { if (DRB_configList->list.array[i]) { drb_id = (int)DRB_configList->list.array[i]->drb_Identity; - LOG_I(NR_RRC, "[gNB %d] Frame %d : Logical Channel UL-DCCH, Received NR_RRCReconfigurationComplete from UE rnti %x, reconfiguring DRB %d\n", + LOG_A(NR_RRC, "[gNB %d] Frame %d : Logical Channel UL-DCCH, Received NR_RRCReconfigurationComplete from UE rnti %x, reconfiguring DRB %d\n", ctxt_pP->module_id, ctxt_pP->frame, ctxt_pP->rnti, @@ -1487,6 +1440,7 @@ rrc_gNB_generate_RRCReestablishment( ue_context_pP, CC_id, (uint8_t *) ue_context->Srb0.Tx_buffer.Payload, + sizeof(ue_context->Srb0.Tx_buffer.Payload), //(uint8_t) carrier->p_gNB, // at this point we do not have the UE capability information, so it can only be TM1 or TM2 rrc_gNB_get_next_transaction_identifier(module_id), SRB_configList @@ -1672,11 +1626,11 @@ rrc_gNB_process_RRCConnectionReestablishmentComplete( if (ue_context_pP->ue_context.pduSession[i].status == PDU_SESSION_STATUS_ESTABLISHED || ue_context_pP->ue_context.pduSession[i].status == PDU_SESSION_STATUS_DONE) { create_tunnel_req.pdusession_id[j] = ue_context_pP->ue_context.pduSession[i].param.pdusession_id; create_tunnel_req.incoming_rb_id[j] = i+1; - create_tunnel_req.upf_NGu_teid[j] = ue_context_pP->ue_context.pduSession[i].param.gtp_teid; - memcpy(create_tunnel_req.upf_addr[j].buffer, + create_tunnel_req.outgoing_teid[j] = ue_context_pP->ue_context.pduSession[i].param.gtp_teid; + memcpy(create_tunnel_req.dst_addr[j].buffer, ue_context_pP->ue_context.pduSession[i].param.upf_addr.buffer, sizeof(uint8_t)*20); - create_tunnel_req.upf_addr[j].length = ue_context_pP->ue_context.pduSession[i].param.upf_addr.length; + create_tunnel_req.dst_addr[j].length = ue_context_pP->ue_context.pduSession[i].param.upf_addr.length; j++; } } @@ -1742,9 +1696,9 @@ rrc_gNB_process_RRCConnectionReestablishmentComplete( i, ue_context_pP->ue_context.pduSession[i].status, "PDU_SESSION_STATUS_DONE"); } - memset(buffer, 0, RRC_BUF_SIZE); + memset(buffer, 0, sizeof(buffer)); - size = do_RRCReconfiguration(ctxt_pP, buffer, + size = do_RRCReconfiguration(ctxt_pP, buffer, sizeof(buffer), xid, *SRB_configList2, DRB_configList, @@ -2737,16 +2691,19 @@ rrc_gNB_decode_dcch( void rrc_gNB_process_f1_setup_req(f1ap_setup_req_t *f1_setup_req) { LOG_I(NR_RRC,"Received F1 Setup Request from gNB_DU %llu (%s)\n",(unsigned long long int)f1_setup_req->gNB_DU_id,f1_setup_req->gNB_DU_name); int cu_cell_ind = 0; - MessageDef *msg_p = NULL,*msg_p2=NULL; + MessageDef *msg_p =itti_alloc_new_message (TASK_RRC_GNB, 0, F1AP_SETUP_RESP); + F1AP_SETUP_RESP (msg_p).num_cells_to_activate = 0; + MessageDef *msg_p2=itti_alloc_new_message (TASK_RRC_GNB, 0, F1AP_GNB_CU_CONFIGURATION_UPDATE); for (int i = 0; i < f1_setup_req->num_cells_available; i++) { - int found_cell=0; for (int j=0; j<RC.nb_nr_inst; j++) { gNB_RRC_INST *rrc = RC.nrrrc[j]; - if (rrc->configuration.mcc[0] == f1_setup_req->mcc[i] && - rrc->configuration.mnc[0] == f1_setup_req->mnc[i] && - rrc->nr_cellid == f1_setup_req->nr_cellid[i]) { + if (rrc->configuration.mcc[0] == f1_setup_req->cell[i].mcc && + rrc->configuration.mnc[0] == f1_setup_req->cell[i].mnc && + rrc->nr_cellid == f1_setup_req->cell[i].nr_cellid) { + //fixme: multi instance is not consistent here + F1AP_SETUP_RESP (msg_p).gNB_CU_name = rrc->node_name; // check that CU rrc instance corresponds to mcc/mnc/cgi (normally cgi should be enough, but just in case) rrc->carrier.MIB = malloc(f1_setup_req->mib_length[i]); rrc->carrier.sizeof_MIB = f1_setup_req->mib_length[i]; @@ -2759,7 +2716,7 @@ void rrc_gNB_process_f1_setup_req(f1ap_setup_req_t *f1_setup_req) { f1_setup_req->mib[i], f1_setup_req->mib_length[i]); AssertFatal(dec_rval.code == RC_OK, - "[gNB_DU %"PRIu8"] Failed to decode NR_BCCH_BCH_MESSAGE (%zu bits)\n", + "[gNB_CU %"PRIu8"] Failed to decode NR_BCCH_BCH_MESSAGE (%zu bits)\n", j, dec_rval.consumed ); NR_BCCH_BCH_Message_t *mib = &rrc->carrier.mib; @@ -2789,27 +2746,14 @@ void rrc_gNB_process_f1_setup_req(f1ap_setup_req_t *f1_setup_req) { AssertFatal(bcch_message->message.choice.c1->present == NR_BCCH_DL_SCH_MessageType__c1_PR_systemInformationBlockType1, "bcch_message->message.choice.c1->present != NR_BCCH_DL_SCH_MessageType__c1_PR_systemInformationBlockType1\n"); rrc->carrier.sib1 = bcch_message->message.choice.c1->choice.systemInformationBlockType1; - rrc->carrier.physCellId = f1_setup_req->nr_pci[i]; - if (cu_cell_ind == 0) { - // prepare F1_SETUP_RESPONSE + GNB_CU_CONFIGURATION_UPDATE - if (msg_p == NULL) { - msg_p = itti_alloc_new_message (TASK_RRC_GNB, 0, F1AP_SETUP_RESP); - } - if (msg_p2 == NULL) { - msg_p2 = itti_alloc_new_message (TASK_RRC_GNB, 0, F1AP_GNB_CU_CONFIGURATION_UPDATE); - } - - F1AP_SETUP_RESP (msg_p).gNB_CU_name = rrc->node_name; - F1AP_SETUP_RESP (msg_p).num_cells_to_activate = 0; - - } + rrc->carrier.physCellId = f1_setup_req->cell[i].nr_pci; F1AP_GNB_CU_CONFIGURATION_UPDATE (msg_p2).gNB_CU_name = rrc->node_name; F1AP_GNB_CU_CONFIGURATION_UPDATE (msg_p2).cells_to_activate[cu_cell_ind].mcc = rrc->configuration.mcc[0]; F1AP_GNB_CU_CONFIGURATION_UPDATE (msg_p2).cells_to_activate[cu_cell_ind].mnc = rrc->configuration.mnc[0]; F1AP_GNB_CU_CONFIGURATION_UPDATE (msg_p2).cells_to_activate[cu_cell_ind].mnc_digit_length = rrc->configuration.mnc_digit_length[0]; F1AP_GNB_CU_CONFIGURATION_UPDATE (msg_p2).cells_to_activate[cu_cell_ind].nr_cellid = rrc->nr_cellid; - F1AP_GNB_CU_CONFIGURATION_UPDATE (msg_p2).cells_to_activate[cu_cell_ind].nrpci = f1_setup_req->nr_pci[i]; + F1AP_GNB_CU_CONFIGURATION_UPDATE (msg_p2).cells_to_activate[cu_cell_ind].nrpci = f1_setup_req->cell[i].nr_pci; int num_SI= 0; if (rrc->carrier.SIB23) { @@ -2820,22 +2764,20 @@ void rrc_gNB_process_f1_setup_req(f1ap_setup_req_t *f1_setup_req) { F1AP_GNB_CU_CONFIGURATION_UPDATE (msg_p2).cells_to_activate[cu_cell_ind].num_SI = num_SI; cu_cell_ind++; - found_cell=1; F1AP_GNB_CU_CONFIGURATION_UPDATE (msg_p2).num_cells_to_activate = cu_cell_ind; // send break; } else {// setup_req mcc/mnc match rrc internal list element LOG_W(NR_RRC,"[Inst %d] No matching MCC/MNC: rrc->mcc/f1_setup_req->mcc %d/%d rrc->mnc/f1_setup_req->mnc %d/%d rrc->nr_cellid/f1_setup_req->nr_cellid %ld/%ld \n", - j, rrc->configuration.mcc[0], f1_setup_req->mcc[i], - rrc->configuration.mnc[0], f1_setup_req->mnc[i], - rrc->nr_cellid, f1_setup_req->nr_cellid[i]); + j, rrc->configuration.mcc[0], f1_setup_req->cell[i].mcc, + rrc->configuration.mnc[0], f1_setup_req->cell[i].mnc, + rrc->nr_cellid, f1_setup_req->cell[i].nr_cellid); } }// for (int j=0;j<RC.nb_inst;j++) - if (found_cell == 0) { + if (cu_cell_ind == 0) { AssertFatal(1 == 0, "No cell found\n"); - } - else { + } else { // send ITTI message to F1AP-CU task itti_send_msg_to_task (TASK_CU_F1, 0, msg_p); @@ -2859,6 +2801,421 @@ void rrc_gNB_process_dc_overall_timeout(const module_id_t gnb_mod_idP, x2ap_ENDC rrc_remove_nsa_user(rrc, m->rnti); } +static int rrc_process_DU_DL(MessageDef *msg_p, const char *msg_name, instance_t instance) { + NRDuDlReq_t * req=&NRDuDlReq(msg_p); + protocol_ctxt_t ctxt; + ctxt.rnti = req->rnti; + ctxt.module_id = instance; + ctxt.instance = instance; + ctxt.enb_flag = 1; + gNB_RRC_INST *rrc = RC.nrrrc[ctxt.module_id]; + struct rrc_gNB_ue_context_s *ue_context_p = + rrc_gNB_get_ue_context(rrc, ctxt.rnti); + + if (req->srb_id == 0) { + NR_DL_CCCH_Message_t *dl_ccch_msg=NULL; + asn_dec_rval_t dec_rval; + dec_rval = uper_decode(NULL, + &asn_DEF_NR_DL_CCCH_Message, + (void **)&dl_ccch_msg, + req->buf->data, + req->buf->size,0,0); + AssertFatal(dec_rval.code == RC_OK, "could not decode F1AP message\n"); + + switch (dl_ccch_msg->message.choice.c1->present) { + case NR_DL_CCCH_MessageType__c1_PR_NOTHING: + LOG_I(F1AP,"Received PR_NOTHING on DL-CCCH-Message\n"); + break; + + case NR_DL_CCCH_MessageType__c1_PR_rrcReject: + LOG_I(F1AP,"Logical Channel DL-CCCH (SRB0), Received RRCReject\n"); + break; + + case NR_DL_CCCH_MessageType__c1_PR_rrcSetup: { + LOG_I(F1AP, "Logical Channel DL-CCCH (SRB0), Received RRCSetup RNTI %x\n", + req->rnti); + // Get configuration + NR_RRCSetup_t *rrcSetup = dl_ccch_msg->message.choice.c1->choice.rrcSetup; + AssertFatal(rrcSetup!=NULL, "rrcSetup is null\n"); + NR_RRCSetup_IEs_t *rrcSetup_ies = rrcSetup->criticalExtensions.choice.rrcSetup; + ue_context_p->ue_context.SRB_configList = rrcSetup_ies->radioBearerConfig.srb_ToAddModList; + AssertFatal(rrcSetup_ies->masterCellGroup.buf!=NULL,"masterCellGroup is null\n"); + asn_dec_rval_t dec_rval; + dec_rval = uper_decode(NULL, + &asn_DEF_NR_CellGroupConfig, + (void **)&ue_context_p->ue_context.masterCellGroup, + rrcSetup_ies->masterCellGroup.buf, + rrcSetup_ies->masterCellGroup.size,0,0); + AssertFatal(dec_rval.code == RC_OK, "could not decode masterCellGroup\n"); + apply_macrlc_config(rrc,ue_context_p,&ctxt); + gNB_RRC_UE_t *ue_p = &ue_context_p->ue_context; + AssertFatal(ue_p->Srb0.Active == 1,"SRB0 is not active\n"); + memcpy((void *)ue_p->Srb0.Tx_buffer.Payload, + (void *)req->buf->data, + req->buf->size); // ie->value.choice.RRCContainer.size + ue_p->Srb0.Tx_buffer.payload_size = req->buf->size; + break; + } // case + + case NR_DL_CCCH_MessageType__c1_PR_spare2: + LOG_I(F1AP, + "Logical Channel DL-CCCH (SRB0), Received spare2\n"); + break; + + case NR_DL_CCCH_MessageType__c1_PR_spare1: + LOG_I(F1AP, + "Logical Channel DL-CCCH (SRB0), Received spare1\n"); + break; + + default: + AssertFatal(1==0, + "Unknown message\n"); + break; + }// switch case + + return(0); + } else if (req->srb_id == 1) { + NR_DL_DCCH_Message_t *dl_dcch_msg=NULL; + asn_dec_rval_t dec_rval; + dec_rval = uper_decode(NULL, + &asn_DEF_NR_DL_DCCH_Message, + (void **)&dl_dcch_msg, + &req->buf->data[2], // buf[0] includes the pdcp header + req->buf->size-6,0,0); + + if ((dec_rval.code != RC_OK) && (dec_rval.consumed == 0)) + LOG_E(F1AP," Failed to decode DL-DCCH (%zu bytes)\n",dec_rval.consumed); + else + LOG_D(F1AP, "Received message: present %d and c1 present %d\n", + dl_dcch_msg->message.present, dl_dcch_msg->message.choice.c1->present); + + if (dl_dcch_msg->message.present == NR_DL_DCCH_MessageType_PR_c1) { + switch (dl_dcch_msg->message.choice.c1->present) { + case NR_DL_DCCH_MessageType__c1_PR_NOTHING: + LOG_I(F1AP, "Received PR_NOTHING on DL-DCCH-Message\n"); + return 0; + + case NR_DL_DCCH_MessageType__c1_PR_rrcReconfiguration: + // handle RRCReconfiguration + LOG_I(F1AP, "Logical Channel DL-DCCH (SRB1), Received RRCReconfiguration RNTI %x\n", + req->rnti); + NR_RRCReconfiguration_t *rrcReconfiguration = dl_dcch_msg->message.choice.c1->choice.rrcReconfiguration; + + if (rrcReconfiguration->criticalExtensions.present == NR_RRCReconfiguration__criticalExtensions_PR_rrcReconfiguration) { + NR_RRCReconfiguration_IEs_t *rrcReconfiguration_ies = + rrcReconfiguration->criticalExtensions.choice.rrcReconfiguration; + + if (rrcReconfiguration_ies->measConfig != NULL) { + LOG_I(F1AP, "Measurement Configuration is present\n"); + } + + if (rrcReconfiguration_ies->radioBearerConfig) { + LOG_I(F1AP, "Radio Resource Configuration is present\n"); + long drb_id; + int i; + NR_DRB_ToAddModList_t *DRB_configList = rrcReconfiguration_ies->radioBearerConfig->drb_ToAddModList; + NR_SRB_ToAddModList_t *SRB_configList = rrcReconfiguration_ies->radioBearerConfig->srb_ToAddModList; + + // NR_DRB_ToReleaseList_t *DRB_ReleaseList = rrcReconfiguration_ies->radioBearerConfig->drb_ToReleaseList; + + // rrc_rlc_config_asn1_req + + if (SRB_configList != NULL) { + for (i = 0; (i < SRB_configList->list.count) && (i < 3); i++) { + if (SRB_configList->list.array[i]->srb_Identity == 1 ) { + ue_context_p->ue_context.Srb1.Active=1; + } else if (SRB_configList->list.array[i]->srb_Identity == 2 ) { + ue_context_p->ue_context.Srb2.Active=1; + ue_context_p->ue_context.Srb2.Srb_info.Srb_id=2; + LOG_I(F1AP, "[DU %d] SRB2 is now active\n",ctxt.module_id); + } else { + LOG_W(F1AP, "[DU %d] invalide SRB identity %ld\n",ctxt.module_id, + SRB_configList->list.array[i]->srb_Identity); + } + } + } + + if (DRB_configList != NULL) { + for (i = 0; i < DRB_configList->list.count; i++) { // num max DRB (11-3-8) + if (DRB_configList->list.array[i]) { + drb_id = (int)DRB_configList->list.array[i]->drb_Identity; + LOG_I(F1AP, + "[DU %d] Logical Channel UL-DCCH, Received RRCConnectionReconfiguration for UE rnti %x, reconfiguring DRB %d\n", + ctxt.module_id, + ctxt.rnti, + (int)DRB_configList->list.array[i]->drb_Identity); + + // (int)*DRB_configList->list.array[i]->logicalChannelIdentity); + + if (ue_context_p->ue_context.DRB_active[drb_id] == 0) { + ue_context_p->ue_context.DRB_active[drb_id] = 1; + // logicalChannelIdentity + // rrc_mac_config_req_eNB + } + } else { // remove LCHAN from MAC/PHY + AssertFatal(1==0,"Can't handle this yet in DU\n"); + } + } + } + } + } + + break; + + case NR_DL_DCCH_MessageType__c1_PR_rrcResume: + LOG_I(F1AP,"Received rrcResume\n"); + break; + + case NR_DL_DCCH_MessageType__c1_PR_rrcRelease: + LOG_I(F1AP,"Received rrcRelease\n"); + break; + + case NR_DL_DCCH_MessageType__c1_PR_rrcReestablishment: + LOG_I(F1AP,"Received rrcReestablishment\n"); + break; + + case NR_DL_DCCH_MessageType__c1_PR_securityModeCommand: + LOG_I(F1AP,"Received securityModeCommand\n"); + break; + + case NR_DL_DCCH_MessageType__c1_PR_dlInformationTransfer: + LOG_I(F1AP, "Received dlInformationTransfer\n"); + break; + + case NR_DL_DCCH_MessageType__c1_PR_ueCapabilityEnquiry: + LOG_I(F1AP, "Received ueCapabilityEnquiry\n"); + break; + + case NR_DL_DCCH_MessageType__c1_PR_counterCheck: + LOG_I(F1AP, "Received counterCheck\n"); + break; + + case NR_DL_DCCH_MessageType__c1_PR_mobilityFromNRCommand: + case NR_DL_DCCH_MessageType__c1_PR_dlDedicatedMessageSegment_r16: + case NR_DL_DCCH_MessageType__c1_PR_ueInformationRequest_r16: + case NR_DL_DCCH_MessageType__c1_PR_dlInformationTransferMRDC_r16: + case NR_DL_DCCH_MessageType__c1_PR_loggedMeasurementConfiguration_r16: + case NR_DL_DCCH_MessageType__c1_PR_spare3: + case NR_DL_DCCH_MessageType__c1_PR_spare2: + case NR_DL_DCCH_MessageType__c1_PR_spare1: + break; + } + } + } else if (req->srb_id == 2) { + // TODO + //abort(); + } + + LOG_I(F1AP, "Received DL RRC Transfer on srb_id %ld\n", req->srb_id); + // rlc_op_status_t rlc_status; + // boolean_t ret = TRUE; + + //LOG_I(F1AP, "PRRCContainer size %lu:", ie->value.choice.RRCContainer.size); + //for (int i = 0; i < ie->value.choice.RRCContainer.size; i++) + // printf("%02x ", ie->value.choice.RRCContainer.buf[i]); + + //printf (", PDCP PDU size %d:", rrc_dl_sdu_len); + //for (int i=0;i<rrc_dl_sdu_len;i++) printf("%2x ",pdcp_pdu_p->data[i]); + //printf("\n"); + + du_rlc_data_req(&ctxt, 1, 0, req->srb_id , 1, 0, req->buf->size, req->buf); + // rlc_status = rlc_data_req(&ctxt + // , 1 + // , MBMS_FLAG_NO + // , srb_id + // , 0 + // , 0 + // , rrc_dl_sdu_len + // , pdcp_pdu_p + // ,NULL + // ,NULL + // ); + // switch (rlc_status) { + // case RLC_OP_STATUS_OK: + // //LOG_I(F1AP, "Data sending request over RLC succeeded!\n"); + // ret=TRUE; + // break; + // case RLC_OP_STATUS_BAD_PARAMETER: + // LOG_W(F1AP, "Data sending request over RLC failed with 'Bad Parameter' reason!\n"); + // ret= FALSE; + // break; + // case RLC_OP_STATUS_INTERNAL_ERROR: + // LOG_W(F1AP, "Data sending request over RLC failed with 'Internal Error' reason!\n"); + // ret= FALSE; + // break; + // case RLC_OP_STATUS_OUT_OF_RESSOURCES: + // LOG_W(F1AP, "Data sending request over RLC failed with 'Out of Resources' reason!\n"); + // ret= FALSE; + // break; + // default: + // LOG_W(F1AP, "RLC returned an unknown status code after PDCP placed the order to send some data (Status Code:%d)\n", rlc_status); + // ret= FALSE; + // break; + // } // switch case + // return ret; +return 0; +} + +static void rrc_DU_process_ue_context_setup_request(MessageDef *msg_p, const char *msg_name, instance_t instance){ + + f1ap_ue_context_setup_t * req=&F1AP_UE_CONTEXT_SETUP_REQ(msg_p); + protocol_ctxt_t ctxt; + ctxt.rnti = req->rnti; + ctxt.module_id = instance; + ctxt.instance = instance; + ctxt.enb_flag = 1; + gNB_RRC_INST *rrc = RC.nrrrc[ctxt.module_id]; + gNB_MAC_INST *mac = RC.nrmac[ctxt.module_id]; + struct rrc_gNB_ue_context_s *ue_context_p = + rrc_gNB_get_ue_context(rrc, ctxt.rnti); + MessageDef *message_p; + message_p = itti_alloc_new_message (TASK_RRC_GNB, 0, F1AP_UE_CONTEXT_SETUP_RESP); + f1ap_ue_context_setup_t * resp=&F1AP_UE_CONTEXT_SETUP_RESP(message_p); + uint32_t incoming_teid = 0; + + + NR_CellGroupConfig_t *cellGroupConfig; + cellGroupConfig = calloc(1, sizeof(NR_CellGroupConfig_t)); + fill_mastercellGroupConfig(cellGroupConfig, ue_context_p->ue_context.masterCellGroup); + + /* Configure SRB2 */ + NR_SRB_ToAddMod_t *SRB2_config = NULL; + NR_SRB_ToAddModList_t *SRB_configList = NULL; + uint8_t SRBs_before_new_addition = 0; + + if(req->srbs_to_be_setup_length>0){ + if(ue_context_p->ue_context.SRB_configList == NULL){ + LOG_W(NR_RRC, "The SRB list of the UE context is empty before the addition of new SRB at the DU \n"); + ue_context_p->ue_context.SRB_configList = CALLOC(1, sizeof(*ue_context_p->ue_context.SRB_configList)); + } + SRB_configList = ue_context_p->ue_context.SRB_configList; + SRBs_before_new_addition = SRB_configList->list.count; + for (int i=0; i<req->srbs_to_be_setup_length; i++){ + SRB2_config = CALLOC(1, sizeof(*SRB2_config)); + SRB2_config->srb_Identity = req->srbs_to_be_setup[i].srb_id; + ASN_SEQUENCE_ADD(&SRB_configList->list, SRB2_config); + } + } + + /* Configure DRB */ + NR_DRB_ToAddMod_t *DRB_config = NULL; + NR_DRB_ToAddModList_t *DRB_configList = NULL; + if(req->drbs_to_be_setup_length>0){ + if(ue_context_p->ue_context.DRB_configList == NULL){ + ue_context_p->ue_context.DRB_configList = CALLOC(1, sizeof(*ue_context_p->ue_context.DRB_configList)); + } + DRB_configList = ue_context_p->ue_context.DRB_configList; + for (int i=0; i<req->drbs_to_be_setup_length; i++){ + DRB_config = CALLOC(1, sizeof(*DRB_config)); + DRB_config->drb_Identity = req->drbs_to_be_setup[i].drb_id; + ASN_SEQUENCE_ADD(&DRB_configList->list, DRB_config); + f1ap_drb_to_be_setup_t drb_p = req->drbs_to_be_setup[i]; + transport_layer_addr_t addr; + memcpy(addr.buffer, &drb_p.up_ul_tnl[0].tl_address, sizeof(drb_p.up_ul_tnl[0].tl_address)); + addr.length=sizeof(drb_p.up_ul_tnl[0].tl_address)*8; + extern instance_t DUuniqInstance; + incoming_teid=newGtpuCreateTunnel(DUuniqInstance, + req->rnti, + drb_p.drb_id, + drb_p.drb_id, + drb_p.up_ul_tnl[0].teid, + addr, + drb_p.up_ul_tnl[0].port, + DURecvCb); + } + } + + apply_macrlc_config(rrc, ue_context_p, &ctxt); + /* Fill the UE context setup response ITTI message to send to F1AP */ + resp->gNB_CU_ue_id = req->gNB_CU_ue_id; + resp->rnti = ctxt.rnti; + if(DRB_configList){ + if(DRB_configList->list.count > 0){ + resp->drbs_to_be_setup = calloc(1,DRB_configList->list.count*sizeof(f1ap_drb_to_be_setup_t)); + resp->drbs_to_be_setup_length = DRB_configList->list.count; + for (int i=0; i<DRB_configList->list.count; i++){ + resp->drbs_to_be_setup[i].drb_id = DRB_configList->list.array[i]->drb_Identity; + resp->drbs_to_be_setup[i].rlc_mode = RLC_MODE_AM; + resp->drbs_to_be_setup[i].up_dl_tnl[0].teid = incoming_teid; + resp->drbs_to_be_setup[i].up_dl_tnl[0].tl_address = inet_addr(mac->eth_params_n.my_addr); + resp->drbs_to_be_setup[i].up_dl_tnl_length = 1; + } + } + else{ + LOG_W(NR_RRC, "No DRB added upon reception of F1 UE context setup request with a DRB to setup list\n"); + } + } + if(SRB_configList){ + if(SRB_configList->list.count >0 && SRBs_before_new_addition < SRB_configList->list.count){ + resp->srbs_to_be_setup = calloc(1,req->srbs_to_be_setup_length*sizeof(f1ap_srb_to_be_setup_t)); + resp->srbs_to_be_setup_length = req->srbs_to_be_setup_length; + for (int i=SRBs_before_new_addition; i<SRB_configList->list.count; i++){ + resp->srbs_to_be_setup[i-SRBs_before_new_addition].srb_id = SRB_configList->list.array[i]->srb_Identity; + } + } + else{ + LOG_W(NR_RRC, "No SRB added upon reception of F1 UE Context setup request at the DU\n"); + } + } + else{ + LOG_W(NR_RRC, "No SRB added upon reception of F1 UE Context setup request at the DU\n"); + } + resp->du_to_cu_rrc_information = calloc(1,1024*sizeof(uint8_t)); + asn_enc_rval_t enc_rval = uper_encode_to_buffer(&asn_DEF_NR_CellGroupConfig, + NULL, + (void *)cellGroupConfig, + resp->du_to_cu_rrc_information, + 1024); + resp->du_to_cu_rrc_information_length = (enc_rval.encoded+7)>>3; + free(cellGroupConfig); + itti_send_msg_to_task (TASK_DU_F1, ctxt.module_id, message_p); +} + +static void rrc_CU_process_ue_context_setup_response(MessageDef *msg_p, const char *msg_name, instance_t instance){ + + f1ap_ue_context_setup_t * resp=&F1AP_UE_CONTEXT_SETUP_RESP(msg_p); + protocol_ctxt_t ctxt; + ctxt.rnti = resp->rnti; + ctxt.module_id = instance; + ctxt.instance = instance; + ctxt.enb_flag = 1; + gNB_RRC_INST *rrc = RC.nrrrc[ctxt.module_id]; + struct rrc_gNB_ue_context_s *ue_context_p = rrc_gNB_get_ue_context(rrc, ctxt.rnti); + NR_CellGroupConfig_t *cellGroupConfig = NULL; + + asn_dec_rval_t dec_rval = uper_decode_complete( NULL, + &asn_DEF_NR_CellGroupConfig, + (void **)&cellGroupConfig, + (uint8_t *)resp->du_to_cu_rrc_information, + (int) resp->du_to_cu_rrc_information_length); + + if ((dec_rval.code != RC_OK) && (dec_rval.consumed == 0)) { + AssertFatal(1==0,"Cell group config decode error\n"); + // free the memory + SEQUENCE_free( &asn_DEF_NR_CellGroupConfig, cellGroupConfig, 1 ); + return; + } + //xer_fprint(stdout,&asn_DEF_NR_CellGroupConfig, cellGroupConfig); + + if(ue_context_p->ue_context.masterCellGroup == NULL){ + ue_context_p->ue_context.masterCellGroup = calloc(1, sizeof(NR_CellGroupConfig_t)); + } + if(cellGroupConfig->rlc_BearerToAddModList!=NULL){ + if(ue_context_p->ue_context.masterCellGroup->rlc_BearerToAddModList != NULL){ + LOG_I(NR_RRC, "rlc_BearerToAddModList not empty before filling it \n"); + free(ue_context_p->ue_context.masterCellGroup->rlc_BearerToAddModList); + } + ue_context_p->ue_context.masterCellGroup->rlc_BearerToAddModList = calloc(1, sizeof(*cellGroupConfig->rlc_BearerToAddModList)); + memcpy(ue_context_p->ue_context.masterCellGroup->rlc_BearerToAddModList, cellGroupConfig->rlc_BearerToAddModList, + sizeof(*cellGroupConfig->rlc_BearerToAddModList)); + } + xer_fprint(stdout,&asn_DEF_NR_CellGroupConfig, ue_context_p->ue_context.masterCellGroup); + + free(cellGroupConfig->rlc_BearerToAddModList); + free(cellGroupConfig); + +} + unsigned int mask_flip(unsigned int x) { return((((x>>8) + (x<<8))&0xffff)>>6); } @@ -3171,7 +3528,6 @@ void *rrc_gnb_task(void *args_p) { .frame=-1, .subframe=-1, .eNB_index=0, - .configured=true, .brOption=false }; itti_mark_task_ready(TASK_RRC_GNB); @@ -3203,36 +3559,46 @@ void *rrc_gnb_task(void *args_p) { /* Messages from MAC */ case NR_RRC_MAC_CCCH_DATA_IND: - PROTOCOL_CTXT_SET_BY_INSTANCE(&ctxt, - NR_RRC_MAC_CCCH_DATA_IND(msg_p).gnb_index, - GNB_FLAG_YES, - NR_RRC_MAC_CCCH_DATA_IND(msg_p).rnti, - msg_p->ittiMsgHeader.lte_time.frame, - msg_p->ittiMsgHeader.lte_time.slot); - LOG_I(NR_RRC,"Decoding CCCH : ue %d, inst %ld, CC_id %d, ctxt %p, sib_info_p->Rx_buffer.payload_size %d\n", - ctxt.rnti, - instance, - NR_RRC_MAC_CCCH_DATA_IND(msg_p).CC_id, - &ctxt, - NR_RRC_MAC_CCCH_DATA_IND(msg_p).sdu_size); - - if (NR_RRC_MAC_CCCH_DATA_IND(msg_p).sdu_size >= CCCH_SDU_SIZE) { - LOG_I(NR_RRC, "CCCH message has size %d > %d\n", - NR_RRC_MAC_CCCH_DATA_IND(msg_p).sdu_size,CCCH_SDU_SIZE); - break; - } - - nr_rrc_gNB_decode_ccch(&ctxt, - (uint8_t *)NR_RRC_MAC_CCCH_DATA_IND(msg_p).sdu, - NR_RRC_MAC_CCCH_DATA_IND(msg_p).sdu_size, - NR_RRC_MAC_CCCH_DATA_IND(msg_p).du_to_cu_rrc_container, - NR_RRC_MAC_CCCH_DATA_IND(msg_p).CC_id); - - if (NR_RRC_MAC_CCCH_DATA_IND(msg_p).du_to_cu_rrc_container) { - free(NR_RRC_MAC_CCCH_DATA_IND(msg_p).du_to_cu_rrc_container->buf); - free(NR_RRC_MAC_CCCH_DATA_IND(msg_p).du_to_cu_rrc_container); - } + { + instance_t i; + for (i=0; i<RC.nb_nr_inst; i++) { + // first get RRC instance (note, no the ITTI instance) + gNB_RRC_INST *rrc = RC.nrrrc[i]; + + if (rrc->nr_cellid == NR_RRC_MAC_CCCH_DATA_IND(msg_p).nr_cellid) + break; + } + AssertFatal(i!=RC.nb_nr_inst, "Cell_id not found\n"); + PROTOCOL_CTXT_SET_BY_INSTANCE(&ctxt, + i, + GNB_FLAG_YES, + NR_RRC_MAC_CCCH_DATA_IND(msg_p).rnti, + msg_p->ittiMsgHeader.lte_time.frame, + msg_p->ittiMsgHeader.lte_time.slot); + LOG_I(NR_RRC,"Decoding CCCH : ue %d, inst %ld, CC_id %d, ctxt %p, sib_info_p->Rx_buffer.payload_size %d\n", + ctxt.rnti, + i, + NR_RRC_MAC_CCCH_DATA_IND(msg_p).CC_id, + &ctxt, + NR_RRC_MAC_CCCH_DATA_IND(msg_p).sdu_size); + + if (NR_RRC_MAC_CCCH_DATA_IND(msg_p).sdu_size >= CCCH_SDU_SIZE) { + LOG_I(NR_RRC, "CCCH message has size %d > %d\n", + NR_RRC_MAC_CCCH_DATA_IND(msg_p).sdu_size,CCCH_SDU_SIZE); + break; + } + nr_rrc_gNB_decode_ccch(&ctxt, + (uint8_t *)NR_RRC_MAC_CCCH_DATA_IND(msg_p).sdu, + NR_RRC_MAC_CCCH_DATA_IND(msg_p).sdu_size, + NR_RRC_MAC_CCCH_DATA_IND(msg_p).du_to_cu_rrc_container, + NR_RRC_MAC_CCCH_DATA_IND(msg_p).CC_id); + + if (NR_RRC_MAC_CCCH_DATA_IND(msg_p).du_to_cu_rrc_container) { + free(NR_RRC_MAC_CCCH_DATA_IND(msg_p).du_to_cu_rrc_container->buf); + free(NR_RRC_MAC_CCCH_DATA_IND(msg_p).du_to_cu_rrc_container); + } + } break; /* Messages from PDCP */ @@ -3288,6 +3654,18 @@ void *rrc_gnb_task(void *args_p) { LOG_I(NR_RRC,"[gNB %ld] Received %s : %p\n", instance, msg_name_p, &F1AP_SETUP_REQ(msg_p)); rrc_gNB_process_f1_setup_req(&F1AP_SETUP_REQ(msg_p)); break; + + case NR_DU_RRC_DL_INDICATION: + rrc_process_DU_DL(msg_p, msg_name_p, instance); + break; + + case F1AP_UE_CONTEXT_SETUP_REQ: + rrc_DU_process_ue_context_setup_request(msg_p, msg_name_p, instance); + break; + + case F1AP_UE_CONTEXT_SETUP_RESP: + rrc_CU_process_ue_context_setup_response(msg_p, msg_name_p, instance); + break; /* Messages from X2AP */ case X2AP_ENDC_SGNB_ADDITION_REQ: @@ -3296,7 +3674,7 @@ void *rrc_gnb_task(void *args_p) { break; case X2AP_ENDC_SGNB_RECONF_COMPLETE: - LOG_I(NR_RRC, "Handling of reconfiguration complete message at RRC gNB is pending \n"); + LOG_A(NR_RRC, "Handling of reconfiguration complete message at RRC gNB is pending \n"); break; case NGAP_INITIAL_CONTEXT_SETUP_REQ: @@ -3523,9 +3901,10 @@ rrc_gNB_generate_RRCRelease( uint8_t buffer[RRC_BUF_SIZE]; uint16_t size = 0; - memset(buffer, 0, RRC_BUF_SIZE); + memset(buffer, 0, sizeof(buffer)); - size = do_NR_RRCRelease(buffer,rrc_gNB_get_next_transaction_identifier(ctxt_pP->module_id)); + size = do_NR_RRCRelease(buffer, sizeof(buffer), + rrc_gNB_get_next_transaction_identifier(ctxt_pP->module_id)); ue_context_pP->ue_context.ue_reestablishment_timer = 0; ue_context_pP->ue_context.ue_release_timer = 0; ue_context_pP->ue_context.ul_failure_timer = 0; diff --git a/openair2/RRC/NR/rrc_gNB_NGAP.c b/openair2/RRC/NR/rrc_gNB_NGAP.c index 60ee99a172a36a76116add718febf1c720c44ae0..043d136604582415d6239ac67a54219a412a1e09 100644 --- a/openair2/RRC/NR/rrc_gNB_NGAP.c +++ b/openair2/RRC/NR/rrc_gNB_NGAP.c @@ -306,7 +306,9 @@ nr_rrc_pdcp_config_security( uint8_t *kRRCenc = NULL; uint8_t *kRRCint = NULL; uint8_t *kUPenc = NULL; - static int print_keys= 1; + //uint8_t *k_kdf = NULL; + static int print_keys= 1; + /* Derive the keys from kgnb */ if (SRB_configList != NULL) { @@ -481,7 +483,7 @@ rrc_gNB_process_NGAP_INITIAL_CONTEXT_SETUP_REQ( uint16_t ue_initial_id; uint32_t gNB_ue_ngap_id; rrc_gNB_ue_context_t *ue_context_p = NULL; - protocol_ctxt_t ctxt; + protocol_ctxt_t ctxt={0}; uint8_t pdu_sessions_done = 0; gtpv1u_gnb_create_tunnel_req_t create_tunnel_req; gtpv1u_gnb_create_tunnel_resp_t create_tunnel_resp; @@ -520,14 +522,14 @@ rrc_gNB_process_NGAP_INITIAL_CONTEXT_SETUP_REQ( ue_context_p->ue_context.pduSession[i].param = NGAP_INITIAL_CONTEXT_SETUP_REQ (msg_p).pdusession_param[pdu_sessions_done]; create_tunnel_req.pdusession_id[pdu_sessions_done] = NGAP_INITIAL_CONTEXT_SETUP_REQ (msg_p).pdusession_param[pdu_sessions_done].pdusession_id; create_tunnel_req.incoming_rb_id[pdu_sessions_done] = i+1; - create_tunnel_req.upf_NGu_teid[pdu_sessions_done] = NGAP_INITIAL_CONTEXT_SETUP_REQ (msg_p).pdusession_param[pdu_sessions_done].gtp_teid; - create_tunnel_req.upf_addr[pdu_sessions_done].length = NGAP_INITIAL_CONTEXT_SETUP_REQ (msg_p).pdusession_param[pdu_sessions_done].upf_addr.length; - memcpy(create_tunnel_req.upf_addr[pdu_sessions_done].buffer, + create_tunnel_req.outgoing_teid[pdu_sessions_done] = NGAP_INITIAL_CONTEXT_SETUP_REQ (msg_p).pdusession_param[pdu_sessions_done].gtp_teid; + create_tunnel_req.dst_addr[pdu_sessions_done].length = NGAP_INITIAL_CONTEXT_SETUP_REQ (msg_p).pdusession_param[pdu_sessions_done].upf_addr.length; + memcpy(create_tunnel_req.dst_addr[pdu_sessions_done].buffer, NGAP_INITIAL_CONTEXT_SETUP_REQ (msg_p).pdusession_param[pdu_sessions_done].upf_addr.buffer, sizeof(uint8_t)*20); LOG_I(NR_RRC, "PDUSESSION SETUP: local index %d teid %u, pdusession id %d \n", i, - create_tunnel_req.upf_NGu_teid[pdu_sessions_done], + create_tunnel_req.outgoing_teid[pdu_sessions_done], create_tunnel_req.pdusession_id[pdu_sessions_done]); inde_list[pdu_sessions_done] = i; pdu_sessions_done++; @@ -1053,7 +1055,7 @@ rrc_gNB_process_NGAP_PDUSESSION_SETUP_REQ( uint8_t nb_pdusessions_tosetup = NGAP_PDUSESSION_SETUP_REQ(msg_p).nb_pdusessions_tosetup; pdu_sessions_done = 0; - PROTOCOL_CTXT_SET_BY_INSTANCE(&ctxt, instance, GNB_FLAG_YES, ue_context_p->ue_context.rnti, 0, 0); + PROTOCOL_CTXT_SET_BY_MODULE_ID(&ctxt, 0, GNB_FLAG_YES, ue_context_p->ue_context.rnti, 0, 0, 0); for (int i = 0; i < NR_NB_RB_MAX - 3; i++) { if(ue_context_p->ue_context.pduSession[i].status >= PDU_SESSION_STATUS_DONE) continue; @@ -1061,14 +1063,14 @@ rrc_gNB_process_NGAP_PDUSESSION_SETUP_REQ( ue_context_p->ue_context.pduSession[i].param = NGAP_PDUSESSION_SETUP_REQ(msg_p).pdusession_setup_params[pdu_sessions_done]; create_tunnel_req.pdusession_id[pdu_sessions_done] = NGAP_PDUSESSION_SETUP_REQ(msg_p).pdusession_setup_params[pdu_sessions_done].pdusession_id; create_tunnel_req.incoming_rb_id[pdu_sessions_done]= i+1; - create_tunnel_req.upf_NGu_teid[pdu_sessions_done] = NGAP_PDUSESSION_SETUP_REQ(msg_p).pdusession_setup_params[pdu_sessions_done].gtp_teid; - memcpy(create_tunnel_req.upf_addr[pdu_sessions_done].buffer, + create_tunnel_req.outgoing_teid[pdu_sessions_done] = NGAP_PDUSESSION_SETUP_REQ(msg_p).pdusession_setup_params[pdu_sessions_done].gtp_teid; + memcpy(create_tunnel_req.dst_addr[pdu_sessions_done].buffer, NGAP_PDUSESSION_SETUP_REQ(msg_p).pdusession_setup_params[pdu_sessions_done].upf_addr.buffer, sizeof(uint8_t)*20); - create_tunnel_req.upf_addr[pdu_sessions_done].length = NGAP_PDUSESSION_SETUP_REQ(msg_p).pdusession_setup_params[pdu_sessions_done].upf_addr.length; + create_tunnel_req.dst_addr[pdu_sessions_done].length = NGAP_PDUSESSION_SETUP_REQ(msg_p).pdusession_setup_params[pdu_sessions_done].upf_addr.length; LOG_I(NR_RRC,"NGAP PDUSESSION SETUP REQ: local index %d teid %u, pdusession id %d \n", i, - create_tunnel_req.upf_NGu_teid[pdu_sessions_done], + create_tunnel_req.outgoing_teid[pdu_sessions_done], create_tunnel_req.pdusession_id[pdu_sessions_done]); inde_list[pdu_sessions_done] = i; pdu_sessions_done++; diff --git a/openair2/RRC/NR/rrc_gNB_nsa.c b/openair2/RRC/NR/rrc_gNB_nsa.c index f9fce48f41294730093260766be7000364c7339a..536010bbc6b0c7bc3606b7859b786b2105d878e7 100644 --- a/openair2/RRC/NR/rrc_gNB_nsa.c +++ b/openair2/RRC/NR/rrc_gNB_nsa.c @@ -38,6 +38,7 @@ #include "openair2/LAYER2/NR_MAC_gNB/mac_proto.h" #include "openair2/RRC/LTE/rrc_eNB_GTPV1U.h" #include "executables/softmodem-common.h" +#include "executables/nr-softmodem.h" #include <openair2/RRC/NR/rrc_gNB_UE_context.h> #include <openair3/ocp-gtpu/gtp_itf.h> #include "UTIL/OSA/osa_defs.h" @@ -123,6 +124,7 @@ void rrc_parse_ue_capabilities(gNB_RRC_INST *rrc, NR_UE_CapabilityRAT_ContainerL if ( LOG_DEBUGFLAG(DEBUG_ASN1) && ueCapabilityRAT_Container_MRDC != NULL ) { xer_fprint(stdout, &asn_DEF_NR_UE_MRDC_Capability, ue_context_p->ue_context.UE_Capability_MRDC); } + LOG_A(NR_RRC, "Successfully decoded UE NR capabilities (NR and MRDC)\n"); rrc_add_nsa_user(rrc,ue_context_p, m); } @@ -142,6 +144,30 @@ void rrc_add_nsa_user(gNB_RRC_INST *rrc,struct rrc_gNB_ue_context_s *ue_context_ unsigned char *kUPenc = NULL; unsigned char *kUPint = NULL; int i; + + // In case of phy-test and do-ra mode, read UE capabilities directly from file + if (get_softmodem_params()->phy_test == 1 || get_softmodem_params()->do_ra == 1) { + NR_UE_NR_Capability_t* UE_Capability_nr = NULL; + char UE_NR_Capability_xer[65536]; + FILE *f = NULL; + if (uecap_file) + f = fopen(uecap_file, "r"); + if(f){ + size_t size = fread(UE_NR_Capability_xer, 1, sizeof UE_NR_Capability_xer, f); + if (size == 0 || size == sizeof UE_NR_Capability_xer) + LOG_E(NR_RRC,"UE Capabilities XER file %s is too large (%ld)\n", uecap_file, size); + else { + UE_Capability_nr = CALLOC(1,sizeof(NR_UE_NR_Capability_t)); + asn_dec_rval_t dec_rval = xer_decode(0, &asn_DEF_NR_UE_NR_Capability, (void *)&UE_Capability_nr, UE_NR_Capability_xer, size); + assert(dec_rval.code == RC_OK); + xer_fprint(stdout,&asn_DEF_NR_UE_NR_Capability,(void *)UE_Capability_nr); + } + } + else + LOG_E(NR_RRC,"Could not open UE Capabilities input file. Not handling OAI UE Capabilities.\n"); + ue_context_p->ue_context.UE_Capability_nr = UE_Capability_nr; + } + // NR RRCReconfiguration AssertFatal(rrc->Nb_ue < MAX_NR_RRC_UE_CONTEXTS,"cannot add another UE\n"); ue_context_p->ue_context.reconfig = calloc(1,sizeof(NR_RRCReconfiguration_t)); @@ -237,22 +263,26 @@ void rrc_add_nsa_user(gNB_RRC_INST *rrc,struct rrc_gNB_ue_context_s *ue_context_ } if (ue_context_p->ue_context.spCellConfig) { fill_default_reconfig(carrier->servingcellconfigcommon, - ue_context_p->ue_context.spCellConfig->spCellConfigDedicated, - reconfig_ies, - ue_context_p->ue_context.secondaryCellGroup, - carrier->pdsch_AntennaPorts, - carrier->do_CSIRS, - carrier->initial_csi_index[ue_context_p->local_uid + 1], - ue_context_p->local_uid); + ue_context_p->ue_context.spCellConfig->spCellConfigDedicated, + reconfig_ies, + ue_context_p->ue_context.secondaryCellGroup, + carrier->pdsch_AntennaPorts, + carrier->minRXTXTIME, + carrier->do_CSIRS, + carrier->do_SRS, + carrier->initial_csi_index[ue_context_p->local_uid + 1], + ue_context_p->local_uid); } else { fill_default_reconfig(carrier->servingcellconfigcommon, - NULL, - reconfig_ies, - ue_context_p->ue_context.secondaryCellGroup, - carrier->pdsch_AntennaPorts, - carrier->do_CSIRS, - carrier->initial_csi_index[ue_context_p->local_uid + 1], - ue_context_p->local_uid); + NULL, + reconfig_ies, + ue_context_p->ue_context.secondaryCellGroup, + carrier->pdsch_AntennaPorts, + carrier->minRXTXTIME, + carrier->do_CSIRS, + carrier->do_SRS, + carrier->initial_csi_index[ue_context_p->local_uid + 1], + ue_context_p->local_uid); } ue_context_p->ue_id_rnti = ue_context_p->ue_context.secondaryCellGroup->spCellConfig->reconfigurationWithSync->newUE_Identity; NR_CG_Config_t *CG_Config = calloc(1,sizeof(*CG_Config)); @@ -290,14 +320,18 @@ void rrc_add_nsa_user(gNB_RRC_INST *rrc,struct rrc_gNB_ue_context_s *ue_context_ create_tunnel_req.num_tunnels = m->nb_e_rabs_tobeadded; RB_INSERT(rrc_nr_ue_tree_s, &RC.nrrrc[rrc->module_id]->rrc_ue_head, ue_context_p); PROTOCOL_CTXT_SET_BY_MODULE_ID(&ctxt, rrc->module_id, GNB_FLAG_YES, ue_context_p->ue_id_rnti, 0, 0,rrc->module_id); - gtpv1u_create_s1u_tunnel( - ctxt.instance, - &create_tunnel_req, - &create_tunnel_resp); - rrc_gNB_process_GTPV1U_CREATE_TUNNEL_RESP( - &ctxt, - &create_tunnel_resp, - &inde_list[0]); + memset(&create_tunnel_resp, 0, sizeof(create_tunnel_resp)); + if (!IS_SOFTMODEM_NOS1) { + LOG_D(RRC, "Calling gtpv1u_create_s1u_tunnel()\n"); + gtpv1u_create_s1u_tunnel( + ctxt.instance, + &create_tunnel_req, + &create_tunnel_resp); + rrc_gNB_process_GTPV1U_CREATE_TUNNEL_RESP( + &ctxt, + &create_tunnel_resp, + &inde_list[0]); + } X2AP_ENDC_SGNB_ADDITION_REQ_ACK(msg).nb_e_rabs_admitted_tobeadded = m->nb_e_rabs_tobeadded; X2AP_ENDC_SGNB_ADDITION_REQ_ACK(msg).target_assoc_id = m->target_assoc_id; @@ -335,7 +369,7 @@ void rrc_add_nsa_user(gNB_RRC_INST *rrc,struct rrc_gNB_ue_context_s *ue_context_ NULL, (void *)CG_Config, X2AP_ENDC_SGNB_ADDITION_REQ_ACK(msg).rrc_buffer, - 1024); + sizeof(X2AP_ENDC_SGNB_ADDITION_REQ_ACK(msg).rrc_buffer)); X2AP_ENDC_SGNB_ADDITION_REQ_ACK(msg).rrc_buffer_size = (enc_rval.encoded+7)>>3; itti_send_msg_to_task(TASK_X2AP, ENB_MODULE_ID_TO_INSTANCE(0), msg); //Check right id instead of hardcoding } else if (get_softmodem_params()->do_ra || get_softmodem_params()->sa) { diff --git a/openair2/RRC/NR/rrc_gNB_reconfig.c b/openair2/RRC/NR/rrc_gNB_reconfig.c index 980bd39c379e7eab06f769f561b1158d68b31c7e..db4dc2d579af718f91c5e3e4c2e86ec2cae788e5 100644 --- a/openair2/RRC/NR/rrc_gNB_reconfig.c +++ b/openair2/RRC/NR/rrc_gNB_reconfig.c @@ -55,12 +55,19 @@ void fill_default_secondaryCellGroup(NR_ServingCellConfigCommon_t *servingcellco int scg_id, int servCellIndex, int dl_antenna_ports, + int minRXTXTIME, int do_csirs, + int do_srs, int initial_csi_index, int uid) { AssertFatal(servingcellconfigcommon!=NULL,"servingcellconfigcommon is null\n"); AssertFatal(secondaryCellGroup!=NULL,"secondaryCellGroup is null\n"); + // This assert will never happen in the current implementation because NUMBER_OF_UE_MAX = 4. + // However, if in the future NUMBER_OF_UE_MAX is increased, it will be necessary to improve the allocation of SRS resources, + // where the startPosition = 2 or 3 and sl160 = 17, 17, 27 ... 157 only give us 30 different allocations. + AssertFatal(uid>=0 && uid<30, "gNB cannot allocate the SRS resources\n"); + uint64_t bitmap=0; switch (servingcellconfigcommon->ssb_PositionsInBurst->present) { case 1 : @@ -482,10 +489,10 @@ void fill_default_secondaryCellGroup(NR_ServingCellConfigCommon_t *servingcellco NR_PDSCH_TimeDomainResourceAllocation_t *pdschi; for (int i=0;i<servingcellconfigcommon->downlinkConfigCommon->initialDownlinkBWP->pdsch_ConfigCommon->choice.setup->pdsch_TimeDomainAllocationList->list.count;i++) { pdschi= calloc(1,sizeof(*pdschi)); - AssertFatal(servingcellconfigcommon->downlinkConfigCommon->initialDownlinkBWP->pdsch_ConfigCommon->choice.setup->pdsch_TimeDomainAllocationList->list.array[i]->k0!=NULL,"element %d is null\n",i); - - pdschi->k0 = calloc(1,sizeof(*pdschi->k0)); - *pdschi->k0 = *servingcellconfigcommon->downlinkConfigCommon->initialDownlinkBWP->pdsch_ConfigCommon->choice.setup->pdsch_TimeDomainAllocationList->list.array[i]->k0; + if(servingcellconfigcommon->downlinkConfigCommon->initialDownlinkBWP->pdsch_ConfigCommon->choice.setup->pdsch_TimeDomainAllocationList->list.array[i]->k0){ + pdschi->k0 = calloc(1,sizeof(*pdschi->k0)); + *pdschi->k0 = *servingcellconfigcommon->downlinkConfigCommon->initialDownlinkBWP->pdsch_ConfigCommon->choice.setup->pdsch_TimeDomainAllocationList->list.array[i]->k0; + } pdschi->mappingType = servingcellconfigcommon->downlinkConfigCommon->initialDownlinkBWP->pdsch_ConfigCommon->choice.setup->pdsch_TimeDomainAllocationList->list.array[i]->mappingType; pdschi->startSymbolAndLength = servingcellconfigcommon->downlinkConfigCommon->initialDownlinkBWP->pdsch_ConfigCommon->choice.setup->pdsch_TimeDomainAllocationList->list.array[i]->startSymbolAndLength; ASN_SEQUENCE_ADD(&bwp->bwp_Common->pdsch_ConfigCommon->choice.setup->pdsch_TimeDomainAllocationList->list,pdschi); @@ -796,13 +803,21 @@ void fill_default_secondaryCellGroup(NR_ServingCellConfigCommon_t *servingcellco *srs_resset0_id=0; ASN_SEQUENCE_ADD(&srs_resset0->srs_ResourceIdList->list,srs_resset0_id); srs_Config->srs_ResourceToReleaseList=NULL; - srs_resset0->resourceType.present = NR_SRS_ResourceSet__resourceType_PR_aperiodic; - srs_resset0->resourceType.choice.aperiodic = calloc(1,sizeof(*srs_resset0->resourceType.choice.aperiodic)); - srs_resset0->resourceType.choice.aperiodic->aperiodicSRS_ResourceTrigger=1; - srs_resset0->resourceType.choice.aperiodic->csi_RS=NULL; - srs_resset0->resourceType.choice.aperiodic->slotOffset= calloc(1,sizeof(*srs_resset0->resourceType.choice.aperiodic->slotOffset)); - *srs_resset0->resourceType.choice.aperiodic->slotOffset=2; - srs_resset0->resourceType.choice.aperiodic->ext1=NULL; + + if(do_srs) { + srs_resset0->resourceType.present = NR_SRS_ResourceSet__resourceType_PR_periodic; + srs_resset0->resourceType.choice.periodic = calloc(1,sizeof(*srs_resset0->resourceType.choice.periodic)); + srs_resset0->resourceType.choice.periodic->associatedCSI_RS = NULL; + } else { + srs_resset0->resourceType.present = NR_SRS_ResourceSet__resourceType_PR_aperiodic; + srs_resset0->resourceType.choice.aperiodic = calloc(1,sizeof(*srs_resset0->resourceType.choice.aperiodic)); + srs_resset0->resourceType.choice.aperiodic->aperiodicSRS_ResourceTrigger=1; + srs_resset0->resourceType.choice.aperiodic->csi_RS=NULL; + srs_resset0->resourceType.choice.aperiodic->slotOffset= calloc(1,sizeof(*srs_resset0->resourceType.choice.aperiodic->slotOffset)); + *srs_resset0->resourceType.choice.aperiodic->slotOffset=2; + srs_resset0->resourceType.choice.aperiodic->ext1=NULL; + } + srs_resset0->usage=NR_SRS_ResourceSet__usage_codebook; srs_resset0->alpha = calloc(1,sizeof(*srs_resset0->alpha)); *srs_resset0->alpha = NR_Alpha_alpha1; @@ -821,17 +836,28 @@ void fill_default_secondaryCellGroup(NR_ServingCellConfigCommon_t *servingcellco srs_res0->transmissionComb.choice.n2=calloc(1,sizeof(*srs_res0->transmissionComb.choice.n2)); srs_res0->transmissionComb.choice.n2->combOffset_n2=0; srs_res0->transmissionComb.choice.n2->cyclicShift_n2=0; - srs_res0->resourceMapping.startPosition=2; + srs_res0->resourceMapping.startPosition = 2 + uid%2; srs_res0->resourceMapping.nrofSymbols=NR_SRS_Resource__resourceMapping__nrofSymbols_n1; srs_res0->resourceMapping.repetitionFactor=NR_SRS_Resource__resourceMapping__repetitionFactor_n1; srs_res0->freqDomainPosition=0; srs_res0->freqDomainShift=0; - srs_res0->freqHopping.c_SRS = 0; srs_res0->freqHopping.b_SRS=0; srs_res0->freqHopping.b_hop=0; + srs_res0->freqHopping.c_SRS = rrc_get_max_nr_csrs( + NRRIV2BW(servingcellconfigcommon->uplinkConfigCommon->initialUplinkBWP->genericParameters.locationAndBandwidth, 275), + srs_res0->freqHopping.b_SRS); srs_res0->groupOrSequenceHopping=NR_SRS_Resource__groupOrSequenceHopping_neither; - srs_res0->resourceType.present= NR_SRS_Resource__resourceType_PR_aperiodic; - srs_res0->resourceType.choice.aperiodic=calloc(1,sizeof(*srs_res0->resourceType.choice.aperiodic)); + + if(do_srs) { + srs_res0->resourceType.present= NR_SRS_Resource__resourceType_PR_periodic; + srs_res0->resourceType.choice.periodic=calloc(1,sizeof(*srs_res0->resourceType.choice.periodic)); + srs_res0->resourceType.choice.periodic->periodicityAndOffset_p.present = NR_SRS_PeriodicityAndOffset_PR_sl160; + srs_res0->resourceType.choice.periodic->periodicityAndOffset_p.choice.sl160 = 17 + (uid>1)*10; // 17/17/.../147/157 are mixed slots + } else { + srs_res0->resourceType.present= NR_SRS_Resource__resourceType_PR_aperiodic; + srs_res0->resourceType.choice.aperiodic=calloc(1,sizeof(*srs_res0->resourceType.choice.aperiodic)); + } + srs_res0->sequenceId=40; srs_res0->spatialRelationInfo=calloc(1,sizeof(*srs_res0->spatialRelationInfo)); srs_res0->spatialRelationInfo->servingCellId=NULL; @@ -945,7 +971,7 @@ void fill_default_secondaryCellGroup(NR_ServingCellConfigCommon_t *servingcellco long *delay[8]; for (int i=0;i<8;i++) { delay[i] = calloc(1,sizeof(*delay[i])); - *delay[i] = (i<6) ? (i+2) : 0; + *delay[i] = i+minRXTXTIME; ASN_SEQUENCE_ADD(&pucch_Config->dl_DataToUL_ACK->list,delay[i]); } pucch_Config->spatialRelationInfoToAddModList = calloc(1,sizeof(*pucch_Config->spatialRelationInfoToAddModList)); @@ -1348,7 +1374,9 @@ void fill_default_reconfig(NR_ServingCellConfigCommon_t *servingcellconfigcommon NR_RRCReconfiguration_IEs_t *reconfig, NR_CellGroupConfig_t *secondaryCellGroup, int dl_antenna_ports, + int minRXTXTIME, int do_csirs, + int do_srs, int initial_csi_index, int uid) { AssertFatal(servingcellconfigcommon!=NULL,"servingcellconfigcommon is null\n"); @@ -1363,7 +1391,9 @@ void fill_default_reconfig(NR_ServingCellConfigCommon_t *servingcellconfigcommon 1, 1, dl_antenna_ports, + minRXTXTIME, do_csirs, + do_srs, initial_csi_index, uid); diff --git a/openair2/RRC/NR_UE/L2_interface_ue.c b/openair2/RRC/NR_UE/L2_interface_ue.c index 5c9293dcf9c0951a61251bbca17d51d917c7b540..6f0c7fc27fa2c868ec456b0a4aa539fdd79ba774 100644 --- a/openair2/RRC/NR_UE/L2_interface_ue.c +++ b/openair2/RRC/NR_UE/L2_interface_ue.c @@ -149,7 +149,7 @@ int8_t nr_mac_rrc_data_req_ue(const module_id_t Mod_idP, } uint8_t -rrc_data_req_ue( +rrc_data_req_nr_ue( const protocol_ctxt_t *const ctxt_pP, const rb_id_t rb_idP, const mui_t muiP, diff --git a/openair2/RRC/NR_UE/main_ue.c b/openair2/RRC/NR_UE/main_ue.c index 07409c6026194f3512832678d61b4f506feebbc2..5e2bc429ebb0b59c784f49e2a3c3aa4080ce85cf 100644 --- a/openair2/RRC/NR_UE/main_ue.c +++ b/openair2/RRC/NR_UE/main_ue.c @@ -34,8 +34,8 @@ #include "rrc_proto.h" #include "common/utils/LOG/log.h" -NR_UE_RRC_INST_t* nr_l3_init_ue(char* rrc_config_path){ +NR_UE_RRC_INST_t* nr_l3_init_ue(char* uecap, char* rrc_config_path){ //LOG_I(RRC, "[MAIN] NR UE MAC initialization...\n"); - return openair_rrc_top_init_ue_nr(rrc_config_path); + return openair_rrc_top_init_ue_nr(uecap,rrc_config_path); } diff --git a/openair2/RRC/NR_UE/rrc_UE.c b/openair2/RRC/NR_UE/rrc_UE.c index 61f757ed53847d0f3ea0f86adafa80e682adcc34..f910ff68d45fcfc1616ed31c92d408676baaa2ea 100644 --- a/openair2/RRC/NR_UE/rrc_UE.c +++ b/openair2/RRC/NR_UE/rrc_UE.c @@ -49,10 +49,12 @@ #include "rrc_defs.h" #include "rrc_proto.h" #include "rrc_vars.h" +#include "rrc_extern.h" #include "LAYER2/NR_MAC_UE/mac_proto.h" #include "intertask_interface.h" +#include "nr-uesoftmodem.h" #include "executables/softmodem-common.h" #include "plmn_data.h" #include "pdcp.h" @@ -105,7 +107,7 @@ nr_rrc_ue_process_ueCapabilityEnquiry( ); void -nr_sa_rrc_ue_process_radioBearerConfig( +nr_rrc_ue_process_RadioBearerConfig( const protocol_ctxt_t *const ctxt_pP, const uint8_t gNB_index, NR_RadioBearerConfig_t *const radioBearerConfig @@ -114,11 +116,10 @@ nr_sa_rrc_ue_process_radioBearerConfig( uint8_t do_NR_RRCReconfigurationComplete( const protocol_ctxt_t *const ctxt_pP, uint8_t *buffer, + size_t buffer_size, const uint8_t Transaction_id ); -void rrc_ue_generate_RRCReestablishmentRequest( const protocol_ctxt_t *const ctxt_pP, const uint8_t gNB_index ); - void nr_rrc_ue_generate_rrcReestablishmentComplete( const protocol_ctxt_t *const ctxt_pP, @@ -233,16 +234,6 @@ int8_t nr_rrc_ue_decode_secondary_cellgroup_config(const module_id_t module_id, return 0; } -int8_t nr_rrc_ue_process_RadioBearerConfig(NR_RadioBearerConfig_t *RadioBearerConfig){ - - if ( LOG_DEBUGFLAG(DEBUG_ASN1) ) { - xer_fprint(stdout, &asn_DEF_NR_RadioBearerConfig, (const void *) RadioBearerConfig); - } - // Configure PDCP - - return 0; -} - // from LTE-RRC DL-DCCH RRCConnectionReconfiguration nr-secondary-cell-group-config (decoded) // RRCReconfiguration int8_t nr_rrc_ue_process_rrcReconfiguration(const module_id_t module_id, NR_RRCReconfiguration_t *rrcReconfiguration){ @@ -253,12 +244,15 @@ int8_t nr_rrc_ue_process_rrcReconfiguration(const module_id_t module_id, NR_RRCR if(NR_UE_rrc_inst[module_id].radio_bearer_config == NULL){ NR_UE_rrc_inst[module_id].radio_bearer_config = rrcReconfiguration->criticalExtensions.choice.rrcReconfiguration->radioBearerConfig; }else{ - nr_rrc_ue_process_RadioBearerConfig(rrcReconfiguration->criticalExtensions.choice.rrcReconfiguration->radioBearerConfig); + if ( LOG_DEBUGFLAG(DEBUG_ASN1) ) { + struct NR_RadioBearerConfig *RadioBearerConfig = rrcReconfiguration->criticalExtensions.choice.rrcReconfiguration->radioBearerConfig; + xer_fprint(stdout, &asn_DEF_NR_RadioBearerConfig, (const void *) RadioBearerConfig); + } } } if(rrcReconfiguration->criticalExtensions.choice.rrcReconfiguration->secondaryCellGroup != NULL){ - if(get_softmodem_params()->sa) { + if(get_softmodem_params()->sa || get_softmodem_params()->nsa) { NR_CellGroupConfig_t *cellGroupConfig = NULL; uper_decode(NULL, @@ -336,6 +330,10 @@ int8_t nr_rrc_ue_process_scg_config(const module_id_t module_id, NR_CellGroupCon }else{ // maintain list if(cell_group_config->spCellConfig != NULL){ + if (get_softmodem_params()->nsa) { + nr_rrc_mac_config_req_ue(0, 0, 0, NULL, NULL, cell_group_config, NULL); + LOG_D(NR_RRC, "Filled scc now \n"); + } if(cell_group_config->spCellConfig->spCellConfigDedicated != NULL){ // process element of list to be add by RRC message if(cell_group_config->spCellConfig->spCellConfigDedicated->downlinkBWP_ToAddModList != NULL){ @@ -375,7 +373,7 @@ void process_nsa_message(NR_UE_RRC_INST_t *rrc, nsa_message_t nsa_message_type, msg_len); if ((dec_rval.code != RC_OK) && (dec_rval.consumed == 0)) { - LOG_E(RRC,"NR_RRCReconfiguration decode error\n"); + LOG_E(NR_RRC, "NR_RRCReconfiguration decode error\n"); // free the memory SEQUENCE_free( &asn_DEF_NR_RRCReconfiguration, RRCReconfiguration, 1 ); return; @@ -394,12 +392,26 @@ void process_nsa_message(NR_UE_RRC_INST_t *rrc, nsa_message_t nsa_message_type, msg_len); if ((dec_rval.code != RC_OK) && (dec_rval.consumed == 0)) { - LOG_E(RRC,"NR_RadioBearerConfig decode error\n"); + LOG_E(NR_RRC, "NR_RadioBearerConfig decode error\n"); // free the memory SEQUENCE_free( &asn_DEF_NR_RadioBearerConfig, RadioBearerConfig, 1 ); return; } - nr_rrc_ue_process_RadioBearerConfig(RadioBearerConfig); + if (get_softmodem_params()->nsa) { + protocol_ctxt_t ctxt; + NR_UE_MAC_INST_t *mac = get_mac_inst(module_id); + PROTOCOL_CTXT_SET_BY_MODULE_ID(&ctxt, module_id, ENB_FLAG_YES, mac->crnti, 0, 0, 0); + xer_fprint(stdout, &asn_DEF_NR_RadioBearerConfig, (const void*)RadioBearerConfig); + LOG_D(NR_RRC, "Calling fill_default_rbconfig_ue at %d with: e_rab_id = %ld, drbID = %ld, cipher_algo = %ld, key = %ld \n", + __LINE__, RadioBearerConfig->drb_ToAddModList->list.array[0]->cnAssociation->choice.eps_BearerIdentity, + RadioBearerConfig->drb_ToAddModList->list.array[0]->drb_Identity, + RadioBearerConfig->securityConfig->securityAlgorithmConfig->cipheringAlgorithm, + *RadioBearerConfig->securityConfig->keyToUse); + nr_rrc_ue_process_RadioBearerConfig(&ctxt, 0, RadioBearerConfig); + } + else if ( LOG_DEBUGFLAG(DEBUG_ASN1) ) { + xer_fprint(stdout, &asn_DEF_NR_RadioBearerConfig, (const void *) RadioBearerConfig); + } } break; @@ -410,11 +422,10 @@ void process_nsa_message(NR_UE_RRC_INST_t *rrc, nsa_message_t nsa_message_type, } -NR_UE_RRC_INST_t* openair_rrc_top_init_ue_nr(char* rrc_config_path){ +NR_UE_RRC_INST_t* openair_rrc_top_init_ue_nr(char* uecap_file, char* rrc_config_path){ int nr_ue; if(NB_NR_UE_INST > 0){ - NR_UE_rrc_inst = (NR_UE_RRC_INST_t *)malloc(NB_NR_UE_INST * sizeof(NR_UE_RRC_INST_t)); - memset(NR_UE_rrc_inst, 0, NB_NR_UE_INST * sizeof(NR_UE_RRC_INST_t)); + NR_UE_rrc_inst = (NR_UE_RRC_INST_t *)calloc(NB_NR_UE_INST , sizeof(NR_UE_RRC_INST_t)); for(nr_ue=0;nr_ue<NB_NR_UE_INST;nr_ue++){ // fill UE-NR-Capability @ UE-CapabilityRAT-Container here. NR_UE_rrc_inst[nr_ue].selected_plmn_identity = 1; @@ -485,6 +496,8 @@ NR_UE_RRC_INST_t* openair_rrc_top_init_ue_nr(char* rrc_config_path){ RRC_LIST_INIT(NR_UE_rrc_inst[nr_ue].CSI_ReportConfig_list, NR_maxNrofCSI_ReportConfigurations); } + NR_UE_rrc_inst->uecap_file = uecap_file; + if (get_softmodem_params()->phy_test==1 || get_softmodem_params()->do_ra==1) { // read in files for RRCReconfiguration and RBconfig FILE *fd; @@ -494,7 +507,7 @@ NR_UE_RRC_INST_t* openair_rrc_top_init_ue_nr(char* rrc_config_path){ else sprintf(filename,"reconfig.raw"); fd = fopen(filename,"r"); - char buffer[1024]; + char buffer[1024]; AssertFatal(fd, "cannot read file %s: errno %d, %s\n", filename, @@ -517,6 +530,10 @@ NR_UE_RRC_INST_t* openair_rrc_top_init_ue_nr(char* rrc_config_path){ fclose(fd); process_nsa_message(NR_UE_rrc_inst, nr_RadioBearerConfigX_r15, buffer,msg_len); } + else if (get_softmodem_params()->nsa) + { + LOG_D(NR_RRC, "In NSA mode \n"); + } } else{ NR_UE_rrc_inst = NULL; @@ -562,7 +579,8 @@ int8_t nr_rrc_ue_decode_NR_BCCH_BCH_Message( if (NR_UE_rrc_inst[module_id].mib != NULL) SEQUENCE_free( &asn_DEF_NR_BCCH_BCH_Message, (void *)bcch_message, 1 ); - else LOG_I(NR_RRC,"Configuring MAC for first MIB reception\n"); + else + LOG_A(NR_RRC, "Configuring MAC for first MIB reception\n"); asn_dec_rval_t dec_rval = uper_decode_complete(NULL, &asn_DEF_NR_BCCH_BCH_Message, @@ -590,13 +608,6 @@ int8_t nr_rrc_ue_decode_NR_BCCH_BCH_Message( return 0; } -const char siWindowLength[10][5] = {"5s", "10s", "20s", "40s", "80s", "160s", "320s", "640s", "1280s","ERR"};// {"1ms","2ms","5ms","10ms","15ms","20ms","40ms","80ms","ERR"}; -const short siWindowLength_int[9] = {5,10,20,40,80,160,320,640,1280};//{1,2,5,10,15,20,40,80}; - -const char SIBType[12][6] = {"SIB3","SIB4","SIB5","SIB6","SIB7","SIB8","SIB9","SIB10","SIB11","SIB12","SIB13","Spare"}; -const char SIBPeriod[8][6] = {"rf8","rf16","rf32","rf64","rf128","rf256","rf512","ERR"}; -int siPeriod_int[7] = {80,160,320,640,1280,2560,5120}; - const char *nr_SIBreserved( long value ) { if (value < 0 || value > 1) return "ERR"; @@ -1026,7 +1037,7 @@ int nr_decode_SI( const protocol_ctxt_t *const ctxt_pP, const uint8_t gNB_index // if (NR_UE_rrc_inst[ctxt_pP->module_id].Info[gNB_index].SIcnt == sib1->schedulingInfoList.list.count) // rrc_set_sub_state( ctxt_pP->module_id, RRC_SUB_STATE_IDLE_SIB_COMPLETE ); - // LOG_I(RRC,"SIStatus %x, SIcnt %d/%d\n", + // LOG_I(NR_RRC, "SIStatus %x, SIcnt %d/%d\n", // NR_UE_rrc_inst[ctxt_pP->module_id].Info[gNB_index].SIStatus, // NR_UE_rrc_inst[ctxt_pP->module_id].Info[gNB_index].SIcnt, // sib1->schedulingInfoList.list.count); @@ -1036,7 +1047,7 @@ int nr_decode_SI( const protocol_ctxt_t *const ctxt_pP, const uint8_t gNB_index return 0; } -int8_t check_requested_SI_List(module_id_t module_id, BIT_STRING_t requested_SI_List, NR_SIB1_t sib1) { +static int8_t check_requested_SI_List(module_id_t module_id, BIT_STRING_t requested_SI_List, NR_SIB1_t sib1) { if(sib1.si_SchedulingInfo) { @@ -1186,7 +1197,7 @@ int8_t nr_rrc_ue_decode_NR_BCCH_DL_SCH_Message(module_id_t module_id, if( g_log->log_component[NR_RRC].level >= OAILOG_DEBUG ) { xer_fprint(stdout, &asn_DEF_NR_SIB1, (const void *) NR_UE_rrc_inst[module_id].sib1[gNB_index]); } - LOG_I(NR_RRC, "SIB1 decoded\n"); + LOG_A(NR_RRC, "SIB1 decoded\n"); /// dump_SIB1(); // FIXME: improve condition for the RA trigger @@ -1194,8 +1205,8 @@ int8_t nr_rrc_ue_decode_NR_BCCH_DL_SCH_Message(module_id_t module_id, check_requested_SI_List(module_id, NR_UE_rrc_inst[module_id].requested_SI_List, *sib1); if( nr_rrc_get_state(module_id) <= RRC_STATE_IDLE_NR ) { NR_UE_rrc_inst[module_id].ra_trigger = INITIAL_ACCESS_FROM_RRC_IDLE; - LOG_D(PHY,"Setting state to NR_RRC_SI_RECEIVED\n"); - nr_rrc_set_state (module_id, NR_RRC_SI_RECEIVED); + LOG_D(PHY,"Setting state to RRC_STATE_IDLE_NR\n"); + nr_rrc_set_state (module_id, RRC_STATE_IDLE_NR); } // take ServingCellConfigCommon and configure L1/L2 NR_UE_rrc_inst[module_id].servingCellConfigCommonSIB = sib1->servingCellConfigCommon; @@ -1281,7 +1292,8 @@ nr_rrc_ue_process_masterCellGroup( if( cellGroupConfig->rlc_BearerToAddModList != NULL){ //TODO (perform the RLC bearer addition/modification as specified in 5.3.5.5.4) if(NR_UE_rrc_inst[ctxt_pP->module_id].cell_group_config->rlc_BearerToAddModList != NULL){ - free(NR_UE_rrc_inst[ctxt_pP->module_id].cell_group_config->rlc_BearerToAddModList); + // Laurent: there are cases where the not NULL value is also not coming from a previous malloc + // so it is better to let the potential memory leak than corrupting the heap //free(NR_UE_rrc_inst[ctxt_pP->module_id].cell_group_config->rlc_BearerToAddModList); } NR_UE_rrc_inst[ctxt_pP->module_id].cell_group_config->rlc_BearerToAddModList = calloc(1, sizeof(struct NR_CellGroupConfig__rlc_BearerToAddModList)); memcpy(NR_UE_rrc_inst[ctxt_pP->module_id].cell_group_config->rlc_BearerToAddModList,cellGroupConfig->rlc_BearerToAddModList, @@ -1293,7 +1305,9 @@ nr_rrc_ue_process_masterCellGroup( LOG_I(RRC, "Received mac_CellGroupConfig from gNB\n"); if(NR_UE_rrc_inst[ctxt_pP->module_id].cell_group_config->mac_CellGroupConfig != NULL){ LOG_E(RRC, "UE RRC instance already contains mac CellGroupConfig which will be overwritten\n"); - free(NR_UE_rrc_inst[ctxt_pP->module_id].cell_group_config->mac_CellGroupConfig); + // Laurent: there are cases where the not NULL value is also not coming from a previous malloc + // so it is better to let the potential memory leak than corrupting the heap + //free(NR_UE_rrc_inst[ctxt_pP->module_id].cell_group_config->mac_CellGroupConfig); } NR_UE_rrc_inst[ctxt_pP->module_id].cell_group_config->mac_CellGroupConfig = malloc(sizeof(struct NR_MAC_CellGroupConfig)); memcpy(NR_UE_rrc_inst[ctxt_pP->module_id].cell_group_config->mac_CellGroupConfig,cellGroupConfig->mac_CellGroupConfig, @@ -1373,7 +1387,8 @@ static void rrc_ue_generate_RRCSetupComplete( nas_msg = nr_nas_attach_req_imsi; nas_msg_length = sizeof(nr_nas_attach_req_imsi); } - size = do_RRCSetupComplete(ctxt_pP->module_id,buffer,Transaction_id,sel_plmn_id,nas_msg_length,nas_msg); + size = do_RRCSetupComplete(ctxt_pP->module_id, buffer, sizeof(buffer), + Transaction_id, sel_plmn_id, nas_msg_length, nas_msg); LOG_I(NR_RRC,"[UE %d][RAPROC] Frame %d : Logical Channel UL-DCCH (SRB1), Generating RRCSetupComplete (bytes%d, gNB %d)\n", ctxt_pP->module_id,ctxt_pP->frame, size, gNB_index); LOG_D(NR_RRC, @@ -1384,7 +1399,7 @@ static void rrc_ue_generate_RRCSetupComplete( //printf("\n"); // ctxt_pP_local.rnti = ctxt_pP->rnti; - rrc_data_req_ue(ctxt_pP, + rrc_data_req_nr_ue(ctxt_pP, DCCH, nr_rrc_mui++, SDU_CONFIRM_NO, @@ -1462,10 +1477,9 @@ int8_t nr_rrc_ue_decode_ccch( const protocol_ctxt_t *const ctxt_pP, const NR_SRB ctxt_pP, gNB_index, &dl_ccch_msg->message.choice.c1->choice.rrcSetup->criticalExtensions.choice.rrcSetup->masterCellGroup); - nr_sa_rrc_ue_process_radioBearerConfig( - ctxt_pP, - gNB_index, - &dl_ccch_msg->message.choice.c1->choice.rrcSetup->criticalExtensions.choice.rrcSetup->radioBearerConfig); + nr_rrc_ue_process_RadioBearerConfig(ctxt_pP, + gNB_index, + &dl_ccch_msg->message.choice.c1->choice.rrcSetup->criticalExtensions.choice.rrcSetup->radioBearerConfig); nr_rrc_set_state (ctxt_pP->module_id, RRC_STATE_CONNECTED); nr_rrc_set_sub_state (ctxt_pP->module_id, RRC_SUB_STATE_CONNECTED); NR_UE_rrc_inst[ctxt_pP->module_id].Info[gNB_index].rnti = ctxt_pP->rnti; @@ -1735,7 +1749,7 @@ int8_t nr_rrc_ue_decode_ccch( const protocol_ctxt_t *const ctxt_pP, const NR_SRB GNB_RRC_DCCH_DATA_IND (message_p).size = (enc_rval.encoded + 7) / 8; itti_send_msg_to_task (TASK_RRC_GNB_SIM, ctxt_pP->instance, message_p); #else - rrc_data_req_ue (ctxt_pP, + rrc_data_req_nr_ue (ctxt_pP, DCCH, nr_rrc_mui++, SDU_CONFIRM_NO, @@ -1773,6 +1787,7 @@ int8_t nr_rrc_ue_decode_ccch( const protocol_ctxt_t *const ctxt_pP, const NR_SRB do_RRCSetupRequest( module_id, (uint8_t *)NR_UE_rrc_inst[module_id].Srb0[gNB_index].Tx_buffer.Payload, + sizeof(NR_UE_rrc_inst[module_id].Srb0[gNB_index].Tx_buffer.Payload), rv); LOG_I(NR_RRC,"[UE %d] : Logical Channel UL-CCCH (SRB0), Generating RRCSetupRequest (bytes %d, gNB %d)\n", module_id, NR_UE_rrc_inst[module_id].Srb0[gNB_index].Tx_buffer.payload_size, gNB_index); @@ -2013,7 +2028,7 @@ nr_rrc_ue_establish_srb2( //----------------------------------------------------------------------------- void - nr_sa_rrc_ue_process_radioBearerConfig( + nr_rrc_ue_process_RadioBearerConfig( const protocol_ctxt_t *const ctxt_pP, const uint8_t gNB_index, NR_RadioBearerConfig_t *const radioBearerConfig @@ -2165,7 +2180,8 @@ nr_rrc_ue_establish_srb2( NULL, radioBearerConfig->drb_ToAddModList, NULL, - 0, + NR_UE_rrc_inst[ctxt_pP->module_id].cipheringAlgorithm + | (NR_UE_rrc_inst[ctxt_pP->module_id].integrityProtAlgorithm << 4), NULL, NULL, kUPenc, @@ -2204,7 +2220,7 @@ nr_rrc_ue_establish_srb2( } //----------------------------------------------------------------------------- - void + static void rrc_ue_process_rrcReconfiguration( const protocol_ctxt_t *const ctxt_pP, NR_RRCReconfiguration_t *rrcReconfiguration, @@ -2234,7 +2250,7 @@ nr_rrc_ue_establish_srb2( if (ie->radioBearerConfig != NULL) { LOG_I(NR_RRC, "radio Bearer Configuration is present\n"); - nr_sa_rrc_ue_process_radioBearerConfig(ctxt_pP, gNB_index, ie->radioBearerConfig); + nr_rrc_ue_process_RadioBearerConfig(ctxt_pP, gNB_index, ie->radioBearerConfig); } /* Check if there is dedicated NAS information to forward to NAS */ @@ -2262,7 +2278,7 @@ nr_rrc_ue_establish_srb2( //----------------------------------------------------------------------------- void nr_rrc_ue_generate_RRCReconfigurationComplete( const protocol_ctxt_t *const ctxt_pP, const uint8_t gNB_index, const uint8_t Transaction_id ) { uint8_t buffer[32], size; - size = do_NR_RRCReconfigurationComplete(ctxt_pP, buffer, Transaction_id); + size = do_NR_RRCReconfigurationComplete(ctxt_pP, buffer, sizeof(buffer), Transaction_id); LOG_I(NR_RRC,PROTOCOL_RRC_CTXT_UE_FMT" Logical Channel UL-DCCH (SRB1), Generating RRCReconfigurationComplete (bytes %d, gNB_index %d)\n", PROTOCOL_RRC_CTXT_UE_ARGS(ctxt_pP), size, gNB_index); LOG_D(RLC, @@ -2287,7 +2303,7 @@ nr_rrc_ue_establish_srb2( itti_send_msg_to_task (TASK_RRC_GNB_SIM, ctxt_pP->instance, message_p); #else - rrc_data_req_ue ( + rrc_data_req_nr_ue ( ctxt_pP, DCCH, nr_rrc_mui++, @@ -2306,6 +2322,7 @@ nr_rrc_ue_establish_srb2( const protocol_ctxt_t *const ctxt_pP, const srb_id_t Srb_id, const uint8_t *const Buffer, + size_t Buffer_size, const uint8_t gNB_indexP ) //----------------------------------------------------------------------------- @@ -2326,7 +2343,7 @@ nr_rrc_ue_establish_srb2( &asn_DEF_NR_DL_DCCH_Message, (void **)&dl_dcch_msg, Buffer, - RRC_BUF_SIZE, + Buffer_size, 0, 0); @@ -2508,6 +2525,7 @@ nr_rrc_ue_establish_srb2( &ctxt, NR_RRC_DCCH_DATA_IND (msg_p).dcch_index, NR_RRC_DCCH_DATA_IND (msg_p).sdu_p, + NR_RRC_DCCH_DATA_IND (msg_p).sdu_size, NR_RRC_DCCH_DATA_IND (msg_p).gNB_index); break; @@ -2559,14 +2577,14 @@ nr_rrc_ue_establish_srb2( #else // check if SRB2 is created, if yes request data_req on DCCH1 (SRB2) if(NR_UE_rrc_inst[ue_mod_id].SRB2_config[0] == NULL) { - rrc_data_req_ue (&ctxt, + rrc_data_req_nr_ue (&ctxt, DCCH, nr_rrc_mui++, SDU_CONFIRM_NO, length, buffer, PDCP_TRANSMISSION_MODE_CONTROL); } else { - rrc_data_req_ue (&ctxt, + rrc_data_req_nr_ue (&ctxt, DCCH1, nr_rrc_mui++, SDU_CONFIRM_NO, @@ -2619,14 +2637,18 @@ nr_rrc_ue_process_ueCapabilityEnquiry( //----------------------------------------------------------------------------- { asn_enc_rval_t enc_rval; + asn_dec_rval_t dec_rval; NR_UL_DCCH_Message_t ul_dcch_msg; NR_UE_CapabilityRAT_Container_t ue_CapabilityRAT_Container; + char UE_NR_Capability_xer[65536]; + size_t size; uint8_t buffer[200]; int i; LOG_I(NR_RRC,"[UE %d] Frame %d: Receiving from SRB1 (DL-DCCH), Processing UECapabilityEnquiry (gNB %d)\n", ctxt_pP->module_id, ctxt_pP->frame, gNB_index); + memset((void *)&ul_dcch_msg,0,sizeof(NR_UL_DCCH_Message_t)); memset((void *)&ue_CapabilityRAT_Container,0,sizeof(NR_UE_CapabilityRAT_Container_t)); ul_dcch_msg.message.present = NR_UL_DCCH_MessageType_PR_c1; @@ -2635,20 +2657,35 @@ nr_rrc_ue_process_ueCapabilityEnquiry( ul_dcch_msg.message.choice.c1->choice.ueCapabilityInformation = CALLOC(1, sizeof(struct NR_UECapabilityInformation)); ul_dcch_msg.message.choice.c1->choice.ueCapabilityInformation->rrc_TransactionIdentifier = UECapabilityEnquiry->rrc_TransactionIdentifier; ue_CapabilityRAT_Container.rat_Type = NR_RAT_Type_nr; - NR_UE_NR_Capability_t* UE_Capability_nr; - UE_Capability_nr = CALLOC(1,sizeof(NR_UE_NR_Capability_t)); - NR_BandNR_t *nr_bandnr; - nr_bandnr = CALLOC(1,sizeof(NR_BandNR_t)); - nr_bandnr->bandNR = 1; - ASN_SEQUENCE_ADD( - &UE_Capability_nr->rf_Parameters.supportedBandListNR.list, - nr_bandnr); + NR_UE_NR_Capability_t* UE_Capability_nr = NULL; + + char *file_path = NR_UE_rrc_inst[ctxt_pP->module_id].uecap_file; + + FILE *f = NULL; + if (file_path) + f = fopen(file_path, "r"); + if(f){ + size = fread(UE_NR_Capability_xer, 1, sizeof UE_NR_Capability_xer, f); + if (size == 0 || size == sizeof UE_NR_Capability_xer) { + LOG_E(NR_RRC,"UE Capabilities XER file %s is too large (%ld)\n", file_path,size); + free(UE_Capability_nr); + return; + } + dec_rval = xer_decode(0, &asn_DEF_NR_UE_NR_Capability, (void *)&UE_Capability_nr, UE_NR_Capability_xer, size); + assert(dec_rval.code == RC_OK); + } + else { + UE_Capability_nr = CALLOC(1,sizeof(NR_UE_NR_Capability_t)); + NR_BandNR_t *nr_bandnr; + nr_bandnr = CALLOC(1,sizeof(NR_BandNR_t)); + nr_bandnr->bandNR = 1; + ASN_SEQUENCE_ADD(&UE_Capability_nr->rf_Parameters.supportedBandListNR.list, + nr_bandnr); + } OAI_NR_UECapability_t *UECap; UECap = CALLOC(1,sizeof(OAI_NR_UECapability_t)); UECap->UE_NR_Capability = UE_Capability_nr; - if ( LOG_DEBUGFLAG(DEBUG_ASN1) ) { - xer_fprint(stdout,&asn_DEF_NR_UE_NR_Capability,(void *)UE_Capability_nr); - } + xer_fprint(stdout,&asn_DEF_NR_UE_NR_Capability,(void *)UE_Capability_nr); enc_rval = uper_encode_to_buffer(&asn_DEF_NR_UE_NR_Capability, NULL, @@ -2667,6 +2704,11 @@ nr_rrc_ue_process_ueCapabilityEnquiry( OCTET_STRING_fromBuf(&ue_CapabilityRAT_Container.ue_CapabilityRAT_Container, (const char *)NR_UE_rrc_inst[ctxt_pP->module_id].UECapability, NR_UE_rrc_inst[ctxt_pP->module_id].UECapability_size); + + if (get_softmodem_params()->nsa == 1) { + OCTET_STRING_t * requestedFreqBandsNR = UECapabilityEnquiry->criticalExtensions.choice.ueCapabilityEnquiry->ue_CapabilityEnquiryExt; + nsa_sendmsg_to_lte_ue(requestedFreqBandsNR->buf, requestedFreqBandsNR->size, UE_CAPABILITY_INFO); + } // ue_CapabilityRAT_Container.ueCapabilityRAT_Container.buf = UE_rrc_inst[ue_mod_idP].UECapability; // ue_CapabilityRAT_Container.ueCapabilityRAT_Container.size = UE_rrc_inst[ue_mod_idP].UECapability_size; AssertFatal(UECapabilityEnquiry->criticalExtensions.present == NR_UECapabilityEnquiry__criticalExtensions_PR_ueCapabilityEnquiry, @@ -2692,7 +2734,7 @@ nr_rrc_ue_process_ueCapabilityEnquiry( xer_fprint(stdout, &asn_DEF_NR_UL_DCCH_Message, (void *)&ul_dcch_msg); } - LOG_I(RRC,"UECapabilityInformation Encoded %zd bits (%zd bytes)\n",enc_rval.encoded,(enc_rval.encoded+7)/8); + LOG_I(NR_RRC, "UECapabilityInformation Encoded %zd bits (%zd bytes)\n",enc_rval.encoded,(enc_rval.encoded+7)/8); #ifdef ITTI_SIM MessageDef *message_p; uint8_t *message_buffer; @@ -2706,7 +2748,7 @@ nr_rrc_ue_process_ueCapabilityEnquiry( GNB_RRC_DCCH_DATA_IND (message_p).size = (enc_rval.encoded + 7) / 8; itti_send_msg_to_task (TASK_RRC_GNB_SIM, ctxt_pP->instance, message_p); #else - rrc_data_req_ue ( + rrc_data_req_nr_ue ( ctxt_pP, DCCH, nr_rrc_mui++, @@ -2719,36 +2761,6 @@ nr_rrc_ue_process_ueCapabilityEnquiry( } } -//----------------------------------------------------------------------------- -void rrc_ue_generate_RRCReestablishmentRequest( const protocol_ctxt_t *const ctxt_pP, const uint8_t gNB_index ) -{ - NR_UE_rrc_inst[ctxt_pP->module_id].Srb0[gNB_index].Tx_buffer.payload_size = - do_RRCReestablishmentRequest( - ctxt_pP->module_id, - (uint8_t *)NR_UE_rrc_inst[ctxt_pP->module_id].Srb0[gNB_index].Tx_buffer.Payload, 1); - LOG_I(NR_RRC,"[UE %d] : Frame %d, Logical Channel UL-CCCH (SRB0), Generating RRCReestablishmentRequest (bytes %d, gNB %d)\n", - ctxt_pP->module_id, ctxt_pP->frame, NR_UE_rrc_inst[ctxt_pP->module_id].Srb0[gNB_index].Tx_buffer.payload_size, gNB_index); - - for (int i=0; i<NR_UE_rrc_inst[ctxt_pP->module_id].Srb0[gNB_index].Tx_buffer.payload_size; i++) { - LOG_T(NR_RRC,"%x.",NR_UE_rrc_inst[ctxt_pP->module_id].Srb0[gNB_index].Tx_buffer.Payload[i]); - } - - LOG_T(NR_RRC,"\n"); - -#ifdef ITTI_SIM - MessageDef *message_p; - uint8_t *message_buffer; - message_buffer = itti_malloc (TASK_RRC_NRUE,TASK_RRC_GNB_SIM, - NR_UE_rrc_inst[ctxt_pP->module_id].Srb0[gNB_index].Tx_buffer.payload_size); - memcpy (message_buffer, (uint8_t*)NR_UE_rrc_inst[ctxt_pP->module_id].Srb0[gNB_index].Tx_buffer.Payload, - NR_UE_rrc_inst[ctxt_pP->module_id].Srb0[gNB_index].Tx_buffer.payload_size); - message_p = itti_alloc_new_message (TASK_RRC_NRUE, 0, UE_RRC_CCCH_DATA_IND); - UE_RRC_CCCH_DATA_IND (message_p).sdu = message_buffer; - UE_RRC_CCCH_DATA_IND (message_p).size = NR_UE_rrc_inst[ctxt_pP->module_id].Srb0[gNB_index].Tx_buffer.payload_size; - itti_send_msg_to_task (TASK_RRC_GNB_SIM, ctxt_pP->instance, message_p); -#endif -} - void nr_rrc_ue_generate_rrcReestablishmentComplete( const protocol_ctxt_t *const ctxt_pP, @@ -2759,7 +2771,8 @@ nr_rrc_ue_generate_rrcReestablishmentComplete( { uint32_t length; uint8_t buffer[100]; - length = do_RRCReestablishmentComplete(buffer, rrcReestablishment->rrc_TransactionIdentifier); + length = do_RRCReestablishmentComplete(buffer, sizeof(buffer), + rrcReestablishment->rrc_TransactionIdentifier); LOG_I(NR_RRC,"[UE %d][RAPROC] Frame %d : Logical Channel UL-DCCH (SRB1), Generating RRCReestablishmentComplete (bytes%d, gNB %d)\n", ctxt_pP->module_id,ctxt_pP->frame, length, gNB_index); #ifdef ITTI_SIM @@ -2776,3 +2789,224 @@ nr_rrc_ue_generate_rrcReestablishmentComplete( #endif } + +void *recv_msgs_from_lte_ue(void *args_p) +{ + itti_mark_task_ready (TASK_RRC_NSA_NRUE); + int from_lte_ue_fd = get_from_lte_ue_fd(); + for (;;) + { + nsa_msg_t msg; + int recvLen = recvfrom(from_lte_ue_fd, &msg, sizeof(msg), + MSG_WAITALL | MSG_TRUNC, NULL, NULL); + if (recvLen == -1) + { + LOG_E(NR_RRC, "%s: recvfrom: %s\n", __func__, strerror(errno)); + continue; + } + if (recvLen > sizeof(msg)) + { + LOG_E(NR_RRC, "%s: Received truncated message %d\n", __func__, recvLen); + continue; + } + process_lte_nsa_msg(&msg, recvLen); + } + return NULL; +} + +void start_oai_nrue_threads() +{ + init_queue(&nr_rach_ind_queue); + init_queue(&nr_rx_ind_queue); + init_queue(&nr_crc_ind_queue); + init_queue(&nr_uci_ind_queue); + init_queue(&nr_sfn_slot_queue); + init_queue(&nr_chan_param_queue); + init_queue(&nr_dl_tti_req_queue); + init_queue(&nr_tx_req_queue); + init_queue(&nr_ul_dci_req_queue); + init_queue(&nr_ul_tti_req_queue); + init_queue(&nr_wait_ul_tti_req_queue); + + if (sem_init(&sfn_slot_semaphore, 0, 0) != 0) + { + LOG_E(MAC, "sem_init() error\n"); + abort(); + } + + init_nrUE_standalone_thread(ue_id_g); + +} + +static void nsa_rrc_ue_process_ueCapabilityEnquiry(void) +{ + NR_UE_NR_Capability_t *UE_Capability_nr = CALLOC(1, sizeof(NR_UE_NR_Capability_t)); + NR_BandNR_t *nr_bandnr = CALLOC(1, sizeof(NR_BandNR_t)); + nr_bandnr->bandNR = 78; + ASN_SEQUENCE_ADD(&UE_Capability_nr->rf_Parameters.supportedBandListNR.list, nr_bandnr); + OAI_NR_UECapability_t *UECap = CALLOC(1, sizeof(OAI_NR_UECapability_t)); + UECap->UE_NR_Capability = UE_Capability_nr; + + asn_enc_rval_t enc_rval = uper_encode_to_buffer(&asn_DEF_NR_UE_NR_Capability, + NULL, + (void *)UE_Capability_nr, + &UECap->sdu[0], + MAX_UE_NR_CAPABILITY_SIZE); + AssertFatal (enc_rval.encoded > 0, "ASN1 message encoding failed (%s, %lu)!\n", + enc_rval.failed_type->name, enc_rval.encoded); + UECap->sdu_size = (enc_rval.encoded + 7) / 8; + LOG_A(NR_RRC, "[NR_RRC] NRUE Capability encoded, %d bytes (%zd bits)\n", + UECap->sdu_size, enc_rval.encoded + 7); + + NR_UE_rrc_inst[0].UECap = UECap; + NR_UE_rrc_inst[0].UECapability = UECap->sdu; + NR_UE_rrc_inst[0].UECapability_size = UECap->sdu_size; + + NR_UE_CapabilityRAT_Container_t ue_CapabilityRAT_Container; + memset(&ue_CapabilityRAT_Container, 0, sizeof(NR_UE_CapabilityRAT_Container_t)); + ue_CapabilityRAT_Container.rat_Type = NR_RAT_Type_nr; + OCTET_STRING_fromBuf(&ue_CapabilityRAT_Container.ue_CapabilityRAT_Container, + (const char *)NR_UE_rrc_inst[0].UECapability, + NR_UE_rrc_inst[0].UECapability_size); + + nsa_sendmsg_to_lte_ue(ue_CapabilityRAT_Container.ue_CapabilityRAT_Container.buf, + ue_CapabilityRAT_Container.ue_CapabilityRAT_Container.size, + NRUE_CAPABILITY_INFO); +} + +void process_lte_nsa_msg(nsa_msg_t *msg, int msg_len) +{ + if (msg_len < sizeof(msg->msg_type)) + { + LOG_E(RRC, "Msg_len = %d\n", msg_len); + return; + } + LOG_D(NR_RRC, "Processing an NSA message\n"); + Rrc_Msg_Type_t msg_type = msg->msg_type; + uint8_t *const msg_buffer = msg->msg_buffer; + msg_len -= sizeof(msg->msg_type); + switch (msg_type) + { + case UE_CAPABILITY_ENQUIRY: + { + LOG_D(NR_RRC, "We are processing a %d message \n", msg_type); + NR_FreqBandList_t *nr_freq_band_list = NULL; + asn_dec_rval_t dec_rval = uper_decode_complete(NULL, + &asn_DEF_NR_FreqBandList, + (void **)&nr_freq_band_list, + msg_buffer, + msg_len); + if ((dec_rval.code != RC_OK) && (dec_rval.consumed == 0)) + { + SEQUENCE_free(&asn_DEF_NR_FreqBandList, nr_freq_band_list, ASFM_FREE_EVERYTHING); + LOG_E(RRC, "Failed to decode UECapabilityInfo (%zu bits)\n", dec_rval.consumed); + break; + } + for (int i = 0; i < nr_freq_band_list->list.count; i++) + { + LOG_D(NR_RRC, "Received NR band information: %ld.\n", + nr_freq_band_list->list.array[i]->choice.bandInformationNR->bandNR); + } + MessageDef *dummy_msg = itti_alloc_new_message(TASK_RRC_NSA_UE, 0, UE_CAPABILITY_DUMMY); + LOG_D(NR_RRC, "We are calling nsa_sendmsg_to_lte_ue to send a UE_CAPABILITY_DUMMY\n"); + nsa_sendmsg_to_lte_ue(dummy_msg, sizeof(dummy_msg), UE_CAPABILITY_DUMMY); + LOG_A(NR_RRC, "Sent initial NRUE Capability response to LTE UE\n"); + break; + } + + case NRUE_CAPABILITY_ENQUIRY: + { + LOG_I(NR_RRC, "We are processing a %d message \n", msg_type); + NR_FreqBandList_t *nr_freq_band_list = NULL; + asn_dec_rval_t dec_rval = uper_decode_complete(NULL, + &asn_DEF_NR_FreqBandList, + (void **)&nr_freq_band_list, + msg_buffer, + msg_len); + if ((dec_rval.code != RC_OK) && (dec_rval.consumed == 0)) + { + SEQUENCE_free(&asn_DEF_NR_FreqBandList, nr_freq_band_list, ASFM_FREE_EVERYTHING); + LOG_E(NR_RRC, "Failed to decode UECapabilityInfo (%zu bits)\n", dec_rval.consumed); + break; + } + LOG_I(NR_RRC, "Calling nsa_rrc_ue_process_ueCapabilityEnquiry\n"); + nsa_rrc_ue_process_ueCapabilityEnquiry(); + break; + } + + case RRC_MEASUREMENT_PROCEDURE: + { + LOG_I(NR_RRC, "We are processing a %d message \n", msg_type); + + LTE_MeasObjectToAddMod_t *nr_meas_obj = NULL; + asn_dec_rval_t dec_rval = uper_decode_complete(NULL, + &asn_DEF_LTE_MeasObjectToAddMod, + (void **)&nr_meas_obj, + msg_buffer, + msg_len); + if ((dec_rval.code != RC_OK) && (dec_rval.consumed == 0)) + { + SEQUENCE_free(&asn_DEF_LTE_MeasObjectToAddMod, nr_meas_obj, ASFM_FREE_EVERYTHING); + LOG_E(RRC, "Failed to decode measurement object (%zu bits) %d\n", dec_rval.consumed, dec_rval.code); + break; + } + LOG_D(NR_RRC, "NR carrierFreq_r15 (ssb): %ld and sub carrier spacing:%ld\n", + nr_meas_obj->measObject.choice.measObjectNR_r15.carrierFreq_r15, + nr_meas_obj->measObject.choice.measObjectNR_r15.rs_ConfigSSB_r15.subcarrierSpacingSSB_r15); + start_oai_nrue_threads(); + break; + } + case RRC_CONFIG_COMPLETE_REQ: + { + struct msg { + uint32_t RadioBearer_size; + uint32_t SecondaryCellGroup_size; + uint8_t trans_id; + uint8_t padding[3]; + uint8_t buffer[]; + } hdr; + AssertFatal(msg_len >= sizeof(hdr), "Bad received msg\n"); + memcpy(&hdr, msg_buffer, sizeof(hdr)); + LOG_I(NR_RRC, "We got an RRC_CONFIG_COMPLETE_REQ\n"); + uint32_t nr_RadioBearer_size = hdr.RadioBearer_size; + uint32_t nr_SecondaryCellGroup_size = hdr.SecondaryCellGroup_size; + AssertFatal(sizeof(hdr) + nr_RadioBearer_size + nr_SecondaryCellGroup_size <= msg_len, + "nr_RadioBearerConfig1_r15 size %d nr_SecondaryCellGroupConfig_r15 size %d sizeof(hdr) %zu, msg_len = %d\n", + nr_RadioBearer_size, + nr_SecondaryCellGroup_size, + sizeof(hdr), msg_len); + NR_RRC_TransactionIdentifier_t t_id = hdr.trans_id; + LOG_I(NR_RRC, "nr_RadioBearerConfig1_r15 size %d nr_SecondaryCellGroupConfig_r15 size %d t_id %ld\n", + nr_RadioBearer_size, + nr_SecondaryCellGroup_size, + t_id); + + uint8_t *nr_RadioBearer_buffer = msg_buffer + offsetof(struct msg, buffer); + uint8_t *nr_SecondaryCellGroup_buffer = nr_RadioBearer_buffer + nr_RadioBearer_size; + process_nsa_message(NR_UE_rrc_inst, nr_SecondaryCellGroupConfig_r15, nr_SecondaryCellGroup_buffer, + nr_SecondaryCellGroup_size); + process_nsa_message(NR_UE_rrc_inst, nr_RadioBearerConfigX_r15, nr_RadioBearer_buffer, nr_RadioBearer_size); + LOG_I(NR_RRC, "Calling do_NR_RRCReconfigurationComplete. t_id %ld \n", t_id); + uint8_t buffer[RRC_BUF_SIZE]; + size_t size = do_NR_RRCReconfigurationComplete_for_nsa(buffer, sizeof(buffer), t_id); + nsa_sendmsg_to_lte_ue(buffer, size, NR_RRC_CONFIG_COMPLETE_REQ); + break; + } + + case OAI_TUN_IFACE_NSA: + { + LOG_I(NR_RRC, "We got an OAI_TUN_IFACE_NSA!!\n"); + char cmd_line[RRC_BUF_SIZE]; + memcpy(cmd_line, msg_buffer, sizeof(cmd_line)); + LOG_D(NR_RRC, "Command line: %s\n", cmd_line); + if (background_system(cmd_line) != 0) + { + LOG_E(NR_RRC, "ESM-PROC - failed command '%s'", cmd_line); + } + break; + } + + default: + LOG_E(NR_RRC, "No NSA Message Found\n"); + } +} diff --git a/openair2/RRC/NR_UE/rrc_defs.h b/openair2/RRC/NR_UE/rrc_defs.h index b79cbb4bae5107bbeaff3f04306c3531cc629e20..bf2c99c219f381d5f26c2293fdfa89a6530f8ff0 100644 --- a/openair2/RRC/NR_UE/rrc_defs.h +++ b/openair2/RRC/NR_UE/rrc_defs.h @@ -59,9 +59,9 @@ #define NB_CNX_UE 2//MAX_MANAGED_RG_PER_MOBILE #define NB_SIG_CNX_UE 2 //MAX_MANAGED_RG_PER_MOBILE -#define MAX_MEAS_OBJ 6 -#define MAX_MEAS_CONFIG 6 -#define MAX_MEAS_ID 6 +#define MAX_MEAS_OBJ 7 +#define MAX_MEAS_CONFIG 7 +#define MAX_MEAS_ID 7 typedef uint32_t channel_t; @@ -70,7 +70,7 @@ typedef enum { nr_RadioBearerConfigX_r15=1 } nsa_message_t; -#define MAX_UE_NR_CAPABILITY_SIZE 255 +#define MAX_UE_NR_CAPABILITY_SIZE 2048 typedef struct OAI_NR_UECapability_s { uint8_t sdu[MAX_UE_NR_CAPABILITY_SIZE]; uint8_t sdu_size; @@ -120,13 +120,15 @@ typedef struct NR_UE_RRC_INST_s { NR_DRB_ToAddMod_t *DRB_config[NB_CNX_UE][8]; rb_id_t *defaultDRB; // remember the ID of the default DRB - NR_SRB_INFO Srb0[NB_SIG_CNX_UE]; + char *uecap_file; + + NR_SRB_INFO Srb0[NB_SIG_CNX_UE]; NR_SRB_INFO_TABLE_ENTRY Srb1[NB_CNX_UE]; NR_SRB_INFO_TABLE_ENTRY Srb2[NB_CNX_UE]; uint8_t MBMS_flag; OAI_NR_UECapability_t *UECap; - uint8_t *UECapability; + uint8_t *UECapability; uint8_t UECapability_size; RA_trigger_t ra_trigger; diff --git a/openair2/RRC/NR_UE/rrc_nsa.c b/openair2/RRC/NR_UE/rrc_nsa.c new file mode 100644 index 0000000000000000000000000000000000000000..9e62243c658698e472feb9c4c110b86b89eaef26 --- /dev/null +++ b/openair2/RRC/NR_UE/rrc_nsa.c @@ -0,0 +1,85 @@ +#include <sys/socket.h> +#include <netinet/in.h> +#include <arpa/inet.h> +#include "common/utils/LOG/log.h" +#include "openair2/RRC/NR_UE/rrc_proto.h" + +static const char nsa_ipaddr[] = "127.0.0.1"; +static int from_lte_ue_fd = -1; +static int to_lte_ue_fd = -1; +uint16_t ue_id_g; + +int get_from_lte_ue_fd() +{ + return from_lte_ue_fd; +} + +void nsa_sendmsg_to_lte_ue(const void *message, size_t msg_len, MessagesIds msg_type) +{ + LOG_I(NR_RRC, "Entered %s \n", __FUNCTION__); + nsa_msg_t n_msg; + if (msg_len > sizeof(n_msg.msg_buffer)) + { + LOG_E(NR_RRC, "%s: message too big: %zu\n", __func__, msg_len); + abort(); + } + n_msg.msg_type = msg_type; + memcpy(n_msg.msg_buffer, message, msg_len); + size_t to_send = sizeof(n_msg.msg_type) + msg_len; + + struct sockaddr_in sa = + { + .sin_family = AF_INET, + .sin_port = htons(6007 + ue_id_g * 2), + }; + int sent = sendto(from_lte_ue_fd, &n_msg, to_send, 0, + (struct sockaddr *)&sa, sizeof(sa)); + if (sent == -1) + { + LOG_E(NR_RRC, "%s: sendto: %s\n", __func__, strerror(errno)); + return; + } + if (sent != to_send) + { + LOG_E(NR_RRC, "%s: Short send %d != %zu\n", __func__, sent, to_send); + return; + } + LOG_D(NR_RRC, "Sent a %d message to the LTE UE (%d bytes) \n", msg_type, sent); +} + +void init_connections_with_lte_ue(void) +{ + struct sockaddr_in sa = + { + .sin_family = AF_INET, + .sin_port = htons(6008 + ue_id_g * 2), + }; + AssertFatal(from_lte_ue_fd == -1, "from_lte_ue_fd %d was assigned already", from_lte_ue_fd); + from_lte_ue_fd = socket(AF_INET, SOCK_DGRAM, 0); + if (from_lte_ue_fd == -1) + { + LOG_E(NR_RRC, "%s: Error opening socket %d (%d:%s)\n", __FUNCTION__, from_lte_ue_fd, errno, strerror(errno)); + abort(); + } + + if (inet_aton(nsa_ipaddr, &sa.sin_addr) == 0) + { + LOG_E(NR_RRC, "Bad nsa_ipaddr '%s'\n", nsa_ipaddr); + abort(); + } + + if (bind(from_lte_ue_fd, (struct sockaddr *) &sa, sizeof(sa)) == -1) + { + LOG_E(NR_RRC,"%s: Failed to bind the socket\n", __FUNCTION__); + abort(); + } + + AssertFatal(to_lte_ue_fd == -1, "to_lte_ue_fd was assigned already"); + to_lte_ue_fd = socket(AF_INET, SOCK_DGRAM, 0); + if (to_lte_ue_fd == -1) + { + LOG_E(NR_RRC, "%s: Error opening socket %d (%d:%s)\n", __FUNCTION__, to_lte_ue_fd, errno, strerror(errno)); + abort(); + } + LOG_I(NR_RRC, "Started LTE-NR link in the nr-UE\n"); +} diff --git a/openair2/RRC/NR_UE/rrc_proto.h b/openair2/RRC/NR_UE/rrc_proto.h index 534da0112bf3feedd45cf7682ebde12bb9a714b9..62d9167251300a064289082f07ddb7a6e6ed5fe5 100644 --- a/openair2/RRC/NR_UE/rrc_proto.h +++ b/openair2/RRC/NR_UE/rrc_proto.h @@ -39,18 +39,31 @@ #include "NR_MeasConfig.h" #include "NR_CellGroupConfig.h" #include "NR_RadioBearerConfig.h" +#include "openair2/PHY_INTERFACE/queue_t.h" + +extern queue_t nr_rach_ind_queue; +extern queue_t nr_rx_ind_queue; +extern queue_t nr_crc_ind_queue; +extern queue_t nr_uci_ind_queue; +extern queue_t nr_sfn_slot_queue; +extern queue_t nr_chan_param_queue; +extern queue_t nr_dl_tti_req_queue; +extern queue_t nr_tx_req_queue; +extern queue_t nr_ul_dci_req_queue; +extern queue_t nr_ul_tti_req_queue; +extern queue_t nr_wait_ul_tti_req_queue; // // main_rrc.c // /**\brief Layer 3 initialization*/ -NR_UE_RRC_INST_t* nr_l3_init_ue(char*); +NR_UE_RRC_INST_t* nr_l3_init_ue(char*,char*); // // UE_rrc.c // /**\brief Initial the top level RRC structure instance*/ -NR_UE_RRC_INST_t* openair_rrc_top_init_ue_nr(char*); +NR_UE_RRC_INST_t* openair_rrc_top_init_ue_nr(char*,char*); @@ -133,15 +146,40 @@ int8_t nr_mac_rrc_data_req_ue(const module_id_t Mod_idP, const rb_id_t Srb_id, uint8_t *buffer_pP); +uint8_t +rrc_data_req_nr_ue( + const protocol_ctxt_t *const ctxt_pP, + const rb_id_t rb_idP, + const mui_t muiP, + const confirm_t confirmP, + const sdu_size_t sdu_sizeP, + uint8_t *const buffer_pP, + const pdcp_transmission_mode_t modeP +); + /**\brief RRC UE task. \param void *args_p Pointer on arguments to start the task. */ void *rrc_nrue_task(void *args_p); +/**\brief RRC NSA UE task. + \param void *args_p Pointer on arguments to start the task. */ +void *recv_msgs_from_lte_ue(void *args_p); + +void init_connections_with_lte_ue(void); + +void nsa_sendmsg_to_lte_ue(const void *message, size_t msg_len, MessagesIds msg_type); + +void start_oai_nrue_threads(void); + /**\brief RRC UE generate RRCSetupRequest message. \param module_id module id \param gNB_index gNB index */ void nr_rrc_ue_generate_RRCSetupRequest(module_id_t module_id, const uint8_t gNB_index); +void process_lte_nsa_msg(nsa_msg_t *msg, int msg_len); + +int get_from_lte_ue_fd(); + /** @}*/ #endif diff --git a/openair2/RRC/NR_UE/rrc_vars.h b/openair2/RRC/NR_UE/rrc_vars.h index 30c74debdd2db39cc5f203782078627d24988800..ecb9335131af30de82e5765342a2c66dc528a7a0 100644 --- a/openair2/RRC/NR_UE/rrc_vars.h +++ b/openair2/RRC/NR_UE/rrc_vars.h @@ -37,5 +37,6 @@ #include "rrc_defs.h" extern NR_UE_RRC_INST_t *NR_UE_rrc_inst; +extern uint16_t ue_id_g; #endif diff --git a/openair2/SIMULATION/NR_RRC/itti_sim.c b/openair2/SIMULATION/NR_RRC/itti_sim.c index 67a03d8b06711fa58176f0d31136ce57f6e9b570..28de1ca3b83823a5b8f9e1da13e0fe9b808d10e6 100644 --- a/openair2/SIMULATION/NR_RRC/itti_sim.c +++ b/openair2/SIMULATION/NR_RRC/itti_sim.c @@ -383,7 +383,7 @@ void terminate_task(task_id_t task_id, module_id_t mod_id) { //extern void free_transport(PHY_VARS_gNB *); extern void nr_phy_free_RU(RU_t *); -void init_pdcp(void) { +statis void init_pdcp(void) { //if (!NODE_IS_DU(RC.rrc[0]->node_type)) { pdcp_layer_init(); uint32_t pdcp_initmask = (IS_SOFTMODEM_NOS1) ? @@ -394,10 +394,10 @@ void init_pdcp(void) { pdcp_initmask = pdcp_initmask | ENB_NAS_USE_TUN_BIT | SOFTMODEM_NOKRNMOD_BIT ; } - pdcp_module_init(pdcp_initmask); + pdcp_module_init(pdcp_initmask, 0); - pdcp_set_rlc_data_req_func((send_rlc_data_req_func_t) rlc_data_req); - pdcp_set_pdcp_data_ind_func((pdcp_data_ind_func_t) pdcp_data_ind); + pdcp_set_rlc_data_req_func(rlc_data_req); + pdcp_set_pdcp_data_ind_func(pdcp_data_ind); } @@ -406,7 +406,7 @@ int create_tasks_nrue(uint32_t ue_nb) { itti_wait_ready(1); if (ue_nb > 0) { - printf("create TASK_RRC_NRUE\n"); + LOG_D(NR_RRC, "create TASK_RRC_NRUE\n"); if (itti_create_task (TASK_RRC_NRUE, rrc_nrue_task, NULL) < 0) { LOG_E(NR_RRC, "Create task for RRC UE failed\n"); return -1; @@ -546,7 +546,7 @@ int main( int argc, char **argv ) #endif logInit(); - //configure_linux(); + //set_latency_target(); printf("Reading in command-line options\n"); get_options (); diff --git a/openair2/UTIL/ASYNC_IF/socket_link.c b/openair2/UTIL/ASYNC_IF/socket_link.c index 51c55116752ca0ae52e465bd4f77e3de7c86165f..eac0b910696820ecad427ccf04ac4a44172143d9 100644 --- a/openair2/UTIL/ASYNC_IF/socket_link.c +++ b/openair2/UTIL/ASYNC_IF/socket_link.c @@ -409,10 +409,14 @@ static int socket_udp_receive(int socket_fd, void *buf, int size) socklen_t slen = sizeof(client); int l; - l = recvfrom(socket_fd, buf, size, 0, (struct sockaddr *) &client, &slen); + l = recvfrom(socket_fd, buf, size, MSG_TRUNC, (struct sockaddr *) &client, &slen); //getsockname(socket_fd, (struct sockaddr *)&client, &slen); if (l == -1) goto error; if (l == 0) goto socket_closed; + if (l > size) { + LOG_E(MAC, "%s(%d). Message truncated. %d\n", __FUNCTION__, __LINE__, l); + return -1; + } return l; diff --git a/openair2/UTIL/LISTS/list.h b/openair2/UTIL/LISTS/list.h index b88c581deab6ecb65ee6c0e251d4abbf034184cf..079c723ebf7739727d2f50c8ccda7672bd326949 100644 --- a/openair2/UTIL/LISTS/list.h +++ b/openair2/UTIL/LISTS/list.h @@ -48,6 +48,8 @@ #include "UTIL/MEM/mem_block.h" +#include <common/utils/assertions.h> + //----------------------------------------------------------------------------- void list_init (list_t* , char *); @@ -126,10 +128,13 @@ static inline void * dataArray(varArray_t * input) { return input+1; } -static inline void appendVarArray(varArray_t * input, void* data) { +static inline void appendVarArray(varArray_t ** inputPtr, void* data) { + varArray_t *input=*inputPtr; if (input->size>=input->mallocedSize) { input->mallocedSize+=input->increment; - input=(varArray_t *)realloc(input,sizeof(varArray_t)+input->mallocedSize*input->atomSize); + *inputPtr=(varArray_t *)realloc(input,sizeof(varArray_t)+input->mallocedSize*input->atomSize); + AssertFatal(*inputPtr, "no memory left"); + input=*inputPtr; } memcpy((uint8_t*)(input+1)+input->atomSize*input->size++, data, input->atomSize); } diff --git a/openair2/UTIL/OPT/vars.h b/openair2/UTIL/OPT/vars.h deleted file mode 100644 index 0da315aa8b06b50fd96eded1f5bc4549c466d0c1..0000000000000000000000000000000000000000 --- a/openair2/UTIL/OPT/vars.h +++ /dev/null @@ -1,28 +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 - */ - -/*____________________________OPT/var.h___________________________ -Authors: Navid NIKAIEN -Company: EURECOM -Emails: -*/ -extern mac_lte_tap_info *WS_mac_lte_tap_info; -extern mac_lte_info *WS_mac_lte_info; diff --git a/openair2/X2AP/x2ap_eNB_generate_messages.c b/openair2/X2AP/x2ap_eNB_generate_messages.c index 7c3a89e7f4bff4b0a652f8224d1b94161b375cf0..9724e0cc381b0435256fb69f5fd3120631ee6640 100644 --- a/openair2/X2AP/x2ap_eNB_generate_messages.c +++ b/openair2/X2AP/x2ap_eNB_generate_messages.c @@ -1734,7 +1734,9 @@ int x2ap_eNB_generate_ENDC_x2_SgNB_addition_request( X2AP_ERROR("Failed to encode ENDC X2 SgNB_addition request message\n"); return -1; } + # if 0 // TODO: Sanitizer complains we are trying to access this after free. free(ie->value.choice.MeNBtoSgNBContainer.buf); + #endif MSC_LOG_TX_MESSAGE (MSC_X2AP_SRC_ENB, MSC_X2AP_TARGET_ENB, NULL, 0, "0 X2Setup/initiatingMessage assoc_id %u", x2ap_eNB_data_p->assoc_id); x2ap_eNB_itti_send_sctp_data_req(instance_p->instance, x2ap_eNB_data_p->assoc_id, buffer, len, 0); diff --git a/openair2/X2AP/x2ap_eNB_handler.c b/openair2/X2AP/x2ap_eNB_handler.c index d44f36e186cbd80436bfc107a9f80343616c18e0..f71229f066115a024958687ae61b455ca04f816d 100644 --- a/openair2/X2AP/x2ap_eNB_handler.c +++ b/openair2/X2AP/x2ap_eNB_handler.c @@ -512,8 +512,8 @@ x2ap_eNB_handle_x2_setup_request(instance_t instance, return x2ap_eNB_generate_x2_setup_response(instance_p, x2ap_eNB_data); } -const char *X2AP_cause_str1[4]={"radioNetwork","transport","protocol","misc"}; -const char *X2AP_case_str_radio[50]={" X2AP_CauseRadioNetwork_handover_desirable_for_radio_reasons", +const char *X2AP_ResetRequest_str[2]={"X2AP_ResetRequest_IEs__value_PR_Cause","X2AP_ResetRequest_IEs__value_PR_InterfaceInstanceIndication"}; +const char *X2AP_case_str_radio[50]={"X2AP_CauseRadioNetwork_handover_desirable_for_radio_reasons", "X2AP_CauseRadioNetwork_time_critical_handover", "X2AP_CauseRadioNetwork_resource_optimisation_handover", "X2AP_CauseRadioNetwork_reduce_load_in_serving_cell", @@ -617,8 +617,9 @@ x2ap_eNB_handle_x2_reset_request(instance_t instance, X2AP_ERROR("%s %d: ie is a NULL pointer \n",__FILE__,__LINE__); return -1; } else { - AssertFatal(ie->value.present <= X2AP_Cause_PR_misc && ie->value.present > 0,"Cause value %d, is impossible\n",ie->value.present); - LOG_I(X2AP,"Received X2AP Reset Request with Cause Type %s\n",X2AP_cause_str1[ie->value.present-1]); + AssertFatal(ie->value.present <= X2AP_ResetRequest_IEs__value_PR_InterfaceInstanceIndication && ie->value.present > 0, + "Cause value %d, is impossible\n",ie->value.present); + LOG_I(X2AP,"Received X2AP Reset Request with Cause Type %s\n",X2AP_ResetRequest_str[ie->value.present-1]); } X2AP_DEBUG("Adding eNB to the list of associated eNBs\n"); diff --git a/openair3/GTPV1-U/gtpv1u_eNB.c b/openair3/GTPV1-U/gtpv1u_eNB.c index 0fe2741d7bd1f3bd9d3b3357b64e8d01a32ce807..6f5ef004b5936d727afedb62635b392935044099 100644 --- a/openair3/GTPV1-U/gtpv1u_eNB.c +++ b/openair3/GTPV1-U/gtpv1u_eNB.c @@ -222,7 +222,7 @@ NwGtpv1uRcT gtpv1u_eNB_process_stack_req( * - END-MARKER */ case NW_GTPV1U_ULP_API_RECV_TPDU: { - uint8_t buffer[4096]; + uint8_t buffer[NFAPI_MAX_PACKED_MESSAGE_SIZE]; uint32_t buffer_len; struct rrc_eNB_ue_context_s *ue_context_p; uint16_t msgType = NW_GTP_GPDU; @@ -432,11 +432,7 @@ NwGtpv1uRcT gtpv1u_eNB_process_stack_req( ); if ( result == FALSE ) { - if (ctxt.configured == FALSE ) - LOG_W(GTPU, "PDCP data request failed, cause: [UE:%x]RB is not configured!\n", ctxt.rnti) ; - else - LOG_W(GTPU, "PDCP data request failed\n"); - + LOG_W(GTPU, "PDCP data request failed\n"); return NW_GTPV1U_FAILURE; } } else { @@ -912,7 +908,8 @@ gtpv1u_create_s1u_tunnel( do { s1u_teid = gtpv1u_new_teid(); - LOG_D(GTPU, "gtpv1u_create_s1u_tunnel() 0x%x %u(dec)\n", s1u_teid, s1u_teid); + LOG_I(GTPU, "gtpv1u_data_g %p\n", RC.gtpv1u_data_g); + LOG_I(GTPU, "gtpv1u_create_s1u_tunnel() 0x%x %u(dec)\n", s1u_teid, s1u_teid); stack_req.apiInfo.createTunnelEndPointInfo.teid = s1u_teid; stack_req.apiInfo.createTunnelEndPointInfo.hUlpSession = 0; stack_req.apiInfo.createTunnelEndPointInfo.hStackSession = 0; diff --git a/openair3/GTPV1-U/gtpv1u_gNB.c b/openair3/GTPV1-U/gtpv1u_gNB.c index d3f26aeff11dce59553b8457263ca1003bcf1c58..ff7c8c06042ada5c623c3090ac655e52d616012e 100644 --- a/openair3/GTPV1-U/gtpv1u_gNB.c +++ b/openair3/GTPV1-U/gtpv1u_gNB.c @@ -191,9 +191,6 @@ NwGtpv1uRcT gtpv1u_gNB_process_stack_req( ); if ( result == FALSE ) { - if (ctxt.configured == FALSE ) - LOG_W(GTPU, "gNB node PDCP data request failed, cause: [UE:%x]RB is not configured!\n", ctxt.rnti) ; - else LOG_W(GTPU, "PDCP data request failed\n"); return NW_GTPV1U_FAILURE; @@ -390,9 +387,6 @@ NwGtpv1uRcT nr_gtpv1u_gNB_process_stack_req( ); if ( result == FALSE ) { - if (ctxt.configured == FALSE ) - LOG_W(GTPU, "gNB node PDCP data request failed, cause: [UE:%x]RB is not configured!\n", ctxt.rnti) ; - else LOG_W(GTPU, "PDCP data request failed\n"); return NW_GTPV1U_FAILURE; @@ -528,7 +522,7 @@ gtpv1u_create_ngu_tunnel( MSC_AS_TIME_FMT" CREATE_TUNNEL_REQ RNTI %"PRIx16" inst %u ntuns %u psid %u upf-ngu teid %u", 0,0,create_tunnel_req_pP->rnti, instanceP, create_tunnel_req_pP->num_tunnels, create_tunnel_req_pP->pdusession_id[0], - create_tunnel_req_pP->upf_NGu_teid[0]); + create_tunnel_req_pP->outgoing_teid[0]); create_tunnel_resp_pP->rnti = create_tunnel_req_pP->rnti; create_tunnel_resp_pP->status = 0; create_tunnel_resp_pP->num_tunnels = 0; @@ -579,16 +573,16 @@ gtpv1u_create_ngu_tunnel( LOG_I(GTPU,"Configured GTPu address : %x\n",RC.nr_gtpv1u_data_g->gnb_ip_address_for_NGu_up); create_tunnel_resp_pP->gnb_addr.length = sizeof (in_addr_t); - addrs_length_in_bytes = create_tunnel_req_pP->upf_addr[i].length / 8; + addrs_length_in_bytes = create_tunnel_req_pP->dst_addr[i].length / 8; AssertFatal((addrs_length_in_bytes == 4) || (addrs_length_in_bytes == 16) || (addrs_length_in_bytes == 20), "Bad transport layer address length %d (bits) %d (bytes)", - create_tunnel_req_pP->upf_addr[i].length, addrs_length_in_bytes); + create_tunnel_req_pP->dst_addr[i].length, addrs_length_in_bytes); if ((addrs_length_in_bytes == 4) || (addrs_length_in_bytes == 20)) { - in_addr = *((in_addr_t *)create_tunnel_req_pP->upf_addr[i].buffer); + in_addr = *((in_addr_t *)create_tunnel_req_pP->dst_addr[i].buffer); ip_offset = 4; gtpv1u_ue_data_p->bearers[pdusession_id - GTPV1U_BEARER_OFFSET].upf_ip_addr = in_addr; } @@ -596,14 +590,14 @@ gtpv1u_create_ngu_tunnel( if ((addrs_length_in_bytes == 16) || (addrs_length_in_bytes == 20)) { memcpy(gtpv1u_ue_data_p->bearers[pdusession_id - GTPV1U_BEARER_OFFSET].upf_ip6_addr.s6_addr, - &create_tunnel_req_pP->upf_addr[i].buffer[ip_offset], + &create_tunnel_req_pP->dst_addr[i].buffer[ip_offset], 16); } gtpv1u_ue_data_p->bearers[pdusession_id - GTPV1U_BEARER_OFFSET].state = BEARER_IN_CONFIG; gtpv1u_ue_data_p->bearers[pdusession_id - GTPV1U_BEARER_OFFSET].teid_gNB = ngu_teid; gtpv1u_ue_data_p->bearers[pdusession_id - GTPV1U_BEARER_OFFSET].teid_gNB_stack_session = stack_req.apiInfo.createTunnelEndPointInfo.hStackSession; - gtpv1u_ue_data_p->bearers[pdusession_id - GTPV1U_BEARER_OFFSET].teid_upf = create_tunnel_req_pP->upf_NGu_teid[i]; + gtpv1u_ue_data_p->bearers[pdusession_id - GTPV1U_BEARER_OFFSET].teid_upf = create_tunnel_req_pP->outgoing_teid[i]; gtpv1u_ue_data_p->num_bearers++; create_tunnel_resp_pP->gnb_NGu_teid[i] = ngu_teid; @@ -861,7 +855,7 @@ static int gtpv1u_gnb_tunnel_data_req(gtpv1u_gnb_tunnel_data_req_t *gnb_tunnel_d hashtable_rc_t hash_rc = HASH_TABLE_KEY_NOT_EXISTS; nr_gtpv1u_ue_data_t *gtpv1u_ue_data_p = NULL; teid_t gnb_ngu_teid = 0; - teid_t upf_ngu_teid = 0; + teid_t outgoing_teid = 0; VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_GTPV1U_PROCESS_TUNNEL_DATA_REQ, VCD_FUNCTION_IN); data_req_p = gnb_tunnel_data_req; @@ -873,13 +867,13 @@ static int gtpv1u_gnb_tunnel_data_req(gtpv1u_gnb_tunnel_data_req_t *gnb_tunnel_d } else { if ((data_req_p->pdusession_id >= GTPV1U_BEARER_OFFSET) && (data_req_p->pdusession_id < max_val_NR_DRB_Identity)) { gnb_ngu_teid = gtpv1u_ue_data_p->bearers[data_req_p->pdusession_id - GTPV1U_BEARER_OFFSET].teid_gNB; - upf_ngu_teid = gtpv1u_ue_data_p->bearers[data_req_p->pdusession_id - GTPV1U_BEARER_OFFSET].teid_upf; + outgoing_teid = gtpv1u_ue_data_p->bearers[data_req_p->pdusession_id - GTPV1U_BEARER_OFFSET].teid_upf; stack_req.apiType = NW_GTPV1U_ULP_API_SEND_TPDU; - stack_req.apiInfo.sendtoInfo.teid = upf_ngu_teid; + stack_req.apiInfo.sendtoInfo.teid = outgoing_teid; stack_req.apiInfo.sendtoInfo.ipAddr = gtpv1u_ue_data_p->bearers[data_req_p->pdusession_id - GTPV1U_BEARER_OFFSET].upf_ip_addr; rc = nwGtpv1uGpduMsgNew( RC.nr_gtpv1u_data_g->gtpv1u_stack, - upf_ngu_teid, + outgoing_teid, NW_FALSE, RC.nr_gtpv1u_data_g->seq_num++, data_req_p->buffer, @@ -890,7 +884,7 @@ static int gtpv1u_gnb_tunnel_data_req(gtpv1u_gnb_tunnel_data_req_t *gnb_tunnel_d if (rc != NW_GTPV1U_OK) { LOG_E(GTPU, "nwGtpv1uGpduMsgNew failed: 0x%x\n", rc); MSC_LOG_EVENT(MSC_GTPU_GNB,"0 Failed send G-PDU ltid %u rtid %u size %u", - gnb_ngu_teid,upf_ngu_teid,data_req_p->length); + gnb_ngu_teid,outgoing_teid,data_req_p->length); (void)gnb_ngu_teid; /* avoid gcc warning "set but not used" */ } else { rc = nwGtpv1uProcessUlpReq(RC.nr_gtpv1u_data_g->gtpv1u_stack, &stack_req); @@ -898,7 +892,7 @@ static int gtpv1u_gnb_tunnel_data_req(gtpv1u_gnb_tunnel_data_req_t *gnb_tunnel_d if (rc != NW_GTPV1U_OK) { LOG_E(GTPU, "nwGtpv1uProcessUlpReq failed: 0x%x\n", rc); MSC_LOG_EVENT(MSC_GTPU_GNB,"0 Failed send G-PDU ltid %u rtid %u size %u", - gnb_ngu_teid,upf_ngu_teid,data_req_p->length); + gnb_ngu_teid,outgoing_teid,data_req_p->length); } else { MSC_LOG_TX_MESSAGE( MSC_GTPU_GNB, @@ -908,7 +902,7 @@ static int gtpv1u_gnb_tunnel_data_req(gtpv1u_gnb_tunnel_data_req_t *gnb_tunnel_d MSC_AS_TIME_FMT" G-PDU ltid %u rtid %u size %u", 0,0, gnb_ngu_teid, - upf_ngu_teid, + outgoing_teid, data_req_p->length); } diff --git a/openair3/GTPV1-U/gtpv1u_task.c b/openair3/GTPV1-U/gtpv1u_task.c deleted file mode 100644 index 1339839cf971edd203f2e9100a769a7b4df9ac26..0000000000000000000000000000000000000000 --- a/openair3/GTPV1-U/gtpv1u_task.c +++ /dev/null @@ -1,485 +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 - */ - -/*! \file gtpv1u_task.c -* \brief -* \author Sebastien ROUX, Lionel Gauthier -* \company Eurecom -* \email: lionel.gauthier@eurecom.fr -*/ -#include <stdio.h> -#include <string.h> -#include <unistd.h> -#include <errno.h> -#include <sys/time.h> - -#include "mme_config.h" - -#include "assertions.h" -#include "intertask_interface.h" - -#include "gtpv1u.h" -#include "NwGtpv1u.h" -#include "NwGtpv1uMsg.h" -#include "NwLog.h" -#include "gtpv1u_sgw_defs.h" -#include "NwGtpv1uPrivate.h" -#include "msc.h" - -//static NwGtpv1uStackHandleT gtpv1u_stack = 0; -static gtpv1u_data_t gtpv1u_sgw_data; - - -static int gtpv1u_create_s1u_tunnel(Gtpv1uCreateTunnelReq *create_tunnel_reqP); -static int gtpv1u_delete_s1u_tunnel(Teid_t context_teidP, Teid_t S1U_teidP); -static int gtpv1u_update_s1u_tunnel(Gtpv1uUpdateTunnelReq *reqP); -static void *gtpv1u_thread(void *args); - -NwGtpv1uRcT gtpv1u_send_udp_msg( - NwGtpv1uUdpHandleT udpHandle, - uint8_t *buffer, - uint32_t buffer_len, - uint32_t buffer_offset, - uint32_t peerIpAddr, - uint32_t peerPort); - -NwGtpv1uRcT gtpv1u_log_request( - NwGtpv1uLogMgrHandleT hLogMgr, - uint32_t logLevel, - NwCharT *file, - uint32_t line, - NwCharT *logStr); - -NwGtpv1uRcT gtpv1u_process_stack_req( - NwGtpv1uUlpHandleT hUlp, - NwGtpv1uUlpApiT *pUlpApi); - - -//----------------------------------------------------------------------------- -void gtpu_print_hex_octets(unsigned char* dataP, unsigned long sizeP) -//----------------------------------------------------------------------------- -{ - unsigned long octet_index = 0; - unsigned long buffer_marker = 0; - unsigned char aindex; -#define GTPU_2_PRINT_BUFFER_LEN 8000 - char gtpu_2_print_buffer[GTPU_2_PRINT_BUFFER_LEN]; - struct timeval tv; - struct timezone tz; - char timeofday[64]; - unsigned int h,m,s; - - if (dataP == NULL) { - return; - } - - gettimeofday(&tv, &tz); - h = tv.tv_sec/3600/24; - m = (tv.tv_sec / 60) % 60; - s = tv.tv_sec % 60; - snprintf(timeofday, 64, "%02u:%02u:%02u.%06d", h,m,s,tv.tv_usec); - - GTPU_DEBUG("%s------+-------------------------------------------------|\n",timeofday); - GTPU_DEBUG("%s | 0 1 2 3 4 5 6 7 8 9 a b c d e f |\n",timeofday); - GTPU_DEBUG("%s------+-------------------------------------------------|\n",timeofday); - - for (octet_index = 0; octet_index < sizeP; octet_index++) { - if (GTPU_2_PRINT_BUFFER_LEN < (buffer_marker + 32)) { - buffer_marker+=snprintf(>pu_2_print_buffer[buffer_marker], GTPU_2_PRINT_BUFFER_LEN - buffer_marker, - "... (print buffer overflow)"); - GTPU_DEBUG("%s%s",timeofday,gtpu_2_print_buffer); - return; - } - - if ((octet_index % 16) == 0) { - if (octet_index != 0) { - buffer_marker+=snprintf(>pu_2_print_buffer[buffer_marker], GTPU_2_PRINT_BUFFER_LEN - buffer_marker, " |\n"); - GTPU_DEBUG("%s%s",timeofday, gtpu_2_print_buffer); - buffer_marker = 0; - } - - buffer_marker+=snprintf(>pu_2_print_buffer[buffer_marker], GTPU_2_PRINT_BUFFER_LEN - buffer_marker, " %04lu |", octet_index); - } - - /* - * Print every single octet in hexadecimal form - */ - buffer_marker+=snprintf(>pu_2_print_buffer[buffer_marker], GTPU_2_PRINT_BUFFER_LEN - buffer_marker, " %02x", dataP[octet_index]); - /* - * Align newline and pipes according to the octets in groups of 2 - */ - } - - /* - * Append enough spaces and put final pipe - */ - for (aindex = octet_index; aindex < 16; ++aindex) - buffer_marker+=snprintf(>pu_2_print_buffer[buffer_marker], GTPU_2_PRINT_BUFFER_LEN - buffer_marker, " "); - - //GTPU_DEBUG(" "); - buffer_marker+=snprintf(>pu_2_print_buffer[buffer_marker], GTPU_2_PRINT_BUFFER_LEN - buffer_marker, " |\n"); - GTPU_DEBUG("%s%s",timeofday,gtpu_2_print_buffer); -} - - -NwGtpv1uRcT gtpv1u_log_request(NwGtpv1uLogMgrHandleT hLogMgr, - uint32_t logLevel, - NwCharT *file, - uint32_t line, - NwCharT *logStr) -{ - GTPU_DEBUG("%s\n", logStr); - return NW_GTPV1U_OK; -} - -NwGtpv1uRcT gtpv1u_send_udp_msg( - NwGtpv1uUdpHandleT udpHandle, - uint8_t *buffer, - uint32_t buffer_len, - uint32_t buffer_offset, - uint32_t peerIpAddr, - uint32_t peerPort) -{ - // Create and alloc new message - MessageDef *message_p; - udp_data_req_t *udp_data_req_p; - - message_p = itti_alloc_new_message(TASK_GTPV1_U, UDP_DATA_REQ); - - udp_data_req_p = &message_p->ittiMsg.udp_data_req; - - udp_data_req_p->peer_address = peerIpAddr; - udp_data_req_p->peer_port = peerPort; - udp_data_req_p->buffer = buffer; - udp_data_req_p->buffer_length = buffer_len; - udp_data_req_p->buffer_offset = buffer_offset; - - return itti_send_msg_to_task(TASK_UDP, INSTANCE_DEFAULT, message_p); -} - -/* Callback called when a gtpv1u message arrived on UDP interface */ -NwGtpv1uRcT gtpv1u_process_stack_req( - NwGtpv1uUlpHandleT hUlp, - NwGtpv1uUlpApiT *pUlpApi) -{ - switch(pUlpApi->apiType) { - /* Here there are two type of messages handled: - * - T-PDU - * - END-MARKER - */ - case NW_GTPV1U_ULP_API_RECV_TPDU: { - //uint8_t buffer[4096]; - //uint32_t buffer_len; - MessageDef *message_p = NULL; - Gtpv1uTunnelDataInd *data_ind_p = NULL; - - /* Nw-gptv1u stack has processed a PDU. we can forward it to IPV4 - * task for transmission. - */ - /*if (NW_GTPV1U_OK != nwGtpv1uMsgGetTpdu(pUlpApi->apiInfo.recvMsgInfo.hMsg, - buffer, (uint32_t *)&buffer_len)) { - GTPU_ERROR("Error while retrieving T-PDU\n"); - }*/ - GTPU_DEBUG("Received TPDU from gtpv1u stack %u with size %d\n", - pUlpApi->apiInfo.recvMsgInfo.teid, - ((NwGtpv1uMsgT*)pUlpApi->apiInfo.recvMsgInfo.hMsg)->msgBufLen); - - message_p = itti_alloc_new_message(TASK_GTPV1_U, GTPV1U_TUNNEL_DATA_IND); - - if (message_p == NULL) { - return -1; - } - - data_ind_p = &message_p->ittiMsg.gtpv1uTunnelDataInd; - data_ind_p->buffer = ((NwGtpv1uMsgT*)pUlpApi->apiInfo.recvMsgInfo.hMsg)->msgBuf; - data_ind_p->length = ((NwGtpv1uMsgT*)pUlpApi->apiInfo.recvMsgInfo.hMsg)->msgBufLen; - data_ind_p->offset = ((NwGtpv1uMsgT*)pUlpApi->apiInfo.recvMsgInfo.hMsg)->msgBufOffset; - data_ind_p->local_S1u_teid = pUlpApi->apiInfo.recvMsgInfo.teid; - - if (data_ind_p->buffer == NULL) { - GTPU_ERROR("Failed to allocate new buffer\n"); - itti_free(ITTI_MSG_ORIGIN_ID(message_p), message_p); - message_p = NULL; - } else { - //memcpy(data_ind_p->buffer, buffer, buffer_len); - //data_ind_p->length = buffer_len; - if (itti_send_msg_to_task(TASK_FW_IP, INSTANCE_DEFAULT, message_p) < 0) { - GTPU_ERROR("Failed to send message to task\n"); - itti_free(ITTI_MSG_ORIGIN_ID(message_p), message_p); - message_p = NULL; - } - } - } - break; - - case NW_GTPV1U_ULP_API_CREATE_TUNNEL_ENDPOINT: { - } - break; - - default: { - GTPU_ERROR("Received undefined UlpApi (%02x) from gtpv1u stack!\n", - pUlpApi->apiType); - } - } - - return NW_GTPV1U_OK; -} - -static int gtpv1u_create_s1u_tunnel(Gtpv1uCreateTunnelReq *create_tunnel_reqP) -{ - /* Create a new nw-gtpv1-u stack req using API */ - NwGtpv1uUlpApiT stack_req; - NwGtpv1uRcT rc; - /* Local tunnel end-point identifier */ - uint32_t s1u_teid = 0; - gtpv1u_teid2enb_info_t *gtpv1u_teid2enb_info = NULL; - MessageDef *message_p = NULL; - hashtable_rc_t hash_rc; - - GTPU_DEBUG("Rx GTPV1U_CREATE_TUNNEL_REQ Context %d\n", create_tunnel_reqP->context_teid); - memset(&stack_req, 0, sizeof(NwGtpv1uUlpApiT)); - - stack_req.apiType = NW_GTPV1U_ULP_API_CREATE_TUNNEL_ENDPOINT; - - do { - s1u_teid = gtpv1u_new_teid(); - GTPU_DEBUG("gtpv1u_create_s1u_tunnel() %u\n", s1u_teid); - stack_req.apiInfo.createTunnelEndPointInfo.teid = s1u_teid; - stack_req.apiInfo.createTunnelEndPointInfo.hUlpSession = 0; - stack_req.apiInfo.createTunnelEndPointInfo.hStackSession = 0; - - rc = nwGtpv1uProcessUlpReq(gtpv1u_sgw_data.gtpv1u_stack, &stack_req); - GTPU_DEBUG(".\n"); - } while (rc != NW_GTPV1U_OK); - - gtpv1u_teid2enb_info = malloc (sizeof(gtpv1u_teid2enb_info_t)); - memset(gtpv1u_teid2enb_info, 0, sizeof(gtpv1u_teid2enb_info_t)); - gtpv1u_teid2enb_info->state = BEARER_IN_CONFIG; - - //#warning !!! hack because missing modify session request, so force enb address - // gtpv1u_teid2enb_info->enb_ip_addr.pdn_type = IPv4; - // gtpv1u_teid2enb_info->enb_ip_addr.address.ipv4_address[0] = 192; - // gtpv1u_teid2enb_info->enb_ip_addr.address.ipv4_address[1] = 168; - // gtpv1u_teid2enb_info->enb_ip_addr.address.ipv4_address[2] = 1; - // gtpv1u_teid2enb_info->enb_ip_addr.address.ipv4_address[3] = 2; - - - message_p = itti_alloc_new_message(TASK_GTPV1_U, GTPV1U_CREATE_TUNNEL_RESP); - message_p->ittiMsg.gtpv1uCreateTunnelResp.S1u_teid = s1u_teid; - message_p->ittiMsg.gtpv1uCreateTunnelResp.context_teid = create_tunnel_reqP->context_teid; - message_p->ittiMsg.gtpv1uCreateTunnelResp.eps_bearer_id = create_tunnel_reqP->eps_bearer_id; - - hash_rc = hashtable_is_key_exists(gtpv1u_sgw_data.S1U_mapping, s1u_teid); - - if (hash_rc == HASH_TABLE_KEY_NOT_EXISTS) { - hash_rc = hashtable_insert(gtpv1u_sgw_data.S1U_mapping, s1u_teid, gtpv1u_teid2enb_info); - message_p->ittiMsg.gtpv1uCreateTunnelResp.status = 0; - } else { - message_p->ittiMsg.gtpv1uCreateTunnelResp.status = 0xFF; - } - - GTPU_DEBUG("Tx GTPV1U_CREATE_TUNNEL_RESP Context %u teid %u eps bearer id %u status %d\n", - message_p->ittiMsg.gtpv1uCreateTunnelResp.context_teid, - message_p->ittiMsg.gtpv1uCreateTunnelResp.S1u_teid, - message_p->ittiMsg.gtpv1uCreateTunnelResp.eps_bearer_id, - message_p->ittiMsg.gtpv1uCreateTunnelResp.status); - return itti_send_msg_to_task(TASK_SPGW_APP, INSTANCE_DEFAULT, message_p); -} - - - -static int gtpv1u_delete_s1u_tunnel(Teid_t context_teidP, Teid_t S1U_teidP) -{ - /* Local tunnel end-point identifier */ - MessageDef *message_p; - - GTPU_DEBUG("Rx GTPV1U_DELETE_TUNNEL Context %u S1U teid %u\n", context_teidP, S1U_teidP); - message_p = itti_alloc_new_message(TASK_GTPV1_U, GTPV1U_DELETE_TUNNEL_RESP); - - message_p->ittiMsg.gtpv1uDeleteTunnelResp.S1u_teid = S1U_teidP; - message_p->ittiMsg.gtpv1uDeleteTunnelResp.context_teid = context_teidP; - - if (hashtable_remove(gtpv1u_sgw_data.S1U_mapping, S1U_teidP) == HASH_TABLE_OK ) { - message_p->ittiMsg.gtpv1uDeleteTunnelResp.status = 0; - } else { - message_p->ittiMsg.gtpv1uDeleteTunnelResp.status = -1; - } - - GTPU_DEBUG("Tx SGW_S1U_ENDPOINT_CREATED Context %u teid %u status %d\n", context_teidP, S1U_teidP, message_p->ittiMsg.gtpv1uDeleteTunnelResp.status); - return itti_send_msg_to_task(TASK_SPGW_APP, INSTANCE_DEFAULT, message_p); -} - - -static int gtpv1u_update_s1u_tunnel(Gtpv1uUpdateTunnelReq *reqP) -{ - hashtable_rc_t hash_rc; - gtpv1u_teid2enb_info_t *gtpv1u_teid2enb_info; - MessageDef *message_p; - - GTPU_DEBUG("Rx GTPV1U_UPDATE_TUNNEL_REQ Context %u, S-GW S1U teid %u, eNB S1U teid %u\n", - reqP->context_teid, - reqP->sgw_S1u_teid, - reqP->enb_S1u_teid); - message_p = itti_alloc_new_message(TASK_GTPV1_U, GTPV1U_UPDATE_TUNNEL_RESP); - - hash_rc = hashtable_get(gtpv1u_sgw_data.S1U_mapping, reqP->sgw_S1u_teid, (void**)>pv1u_teid2enb_info); - - if (hash_rc == HASH_TABLE_OK) { - gtpv1u_teid2enb_info->teid_enb = reqP->enb_S1u_teid; - gtpv1u_teid2enb_info->enb_ip_addr = reqP->enb_ip_address_for_S1u; - gtpv1u_teid2enb_info->state = BEARER_UP; - gtpv1u_teid2enb_info->port = GTPV1U_UDP_PORT; - message_p->ittiMsg.gtpv1uUpdateTunnelResp.status = 0; ///< Status (Failed = 0xFF or Success = 0x0) - } else { - GTPU_ERROR("Mapping not found\n"); - message_p->ittiMsg.gtpv1uUpdateTunnelResp.status = 0xFF; ///< Status (Failed = 0xFF or Success = 0x0) - } - - message_p->ittiMsg.gtpv1uUpdateTunnelResp.context_teid = reqP->context_teid; - message_p->ittiMsg.gtpv1uUpdateTunnelResp.sgw_S1u_teid = reqP->sgw_S1u_teid; - message_p->ittiMsg.gtpv1uUpdateTunnelResp.enb_S1u_teid = reqP->enb_S1u_teid; - message_p->ittiMsg.gtpv1uUpdateTunnelResp.eps_bearer_id = reqP->eps_bearer_id; - return itti_send_msg_to_task(TASK_SPGW_APP, INSTANCE_DEFAULT, message_p); -} - - -static NwGtpv1uRcT gtpv1u_start_timer_wrapper( - NwGtpv1uTimerMgrHandleT tmrMgrHandle, - uint32_t timeoutSec, - uint32_t timeoutUsec, - uint32_t tmrType, - void *timeoutArg, - NwGtpv1uTimerHandleT *hTmr) -{ - - NwGtpv1uRcT rc = NW_GTPV1U_OK; - long timer_id; - - if (tmrType == NW_GTPV1U_TMR_TYPE_ONE_SHOT) { - timer_setup(timeoutSec, - timeoutUsec, - TASK_GTPV1_U, - INSTANCE_DEFAULT, - TIMER_ONE_SHOT, - timeoutArg, - &timer_id); - } else { - timer_setup(timeoutSec, - timeoutUsec, - TASK_GTPV1_U, - INSTANCE_DEFAULT, - TIMER_PERIODIC, - timeoutArg, - &timer_id); - } - - return rc; -} - -static NwGtpv1uRcT gtpv1u_stop_timer_wrapper( - NwGtpv1uTimerMgrHandleT tmrMgrHandle, - NwGtpv1uTimerHandleT hTmr) -{ - - NwGtpv1uRcT rc = NW_GTPV1U_OK; - - return rc; -} - -static void *gtpv1u_thread(void *args) -{ - itti_mark_task_ready(TASK_GTPV1_U); - MSC_START_USE(); - - while(1) { - /* Trying to fetch a message from the message queue. - * If the queue is empty, this function will block till a - * message is sent to the task. - */ - MessageDef *received_message_p = NULL; - itti_receive_msg(TASK_GTPV1_U, &received_message_p); - DevAssert(received_message_p != NULL); - - - switch (ITTI_MSG_ID(received_message_p)) { - - case TERMINATE_MESSAGE: { - GTPU_WARN(" *** Exiting GTPU thread\n"); - itti_exit_task(); - } - break; - - // DATA COMING FROM UDP - case UDP_DATA_IND: { - udp_data_ind_t *udp_data_ind_p; - udp_data_ind_p = &received_message_p->ittiMsg.udp_data_ind; - nwGtpv1uProcessUdpReq(gtpv1u_sgw_data.gtpv1u_stack, - udp_data_ind_p->buffer, - udp_data_ind_p->buffer_length, - udp_data_ind_p->peer_port, - udp_data_ind_p->peer_address); - //itti_free(ITTI_MSG_ORIGIN_ID(received_message_p), udp_data_ind_p->buffer); - } - break; - - case TIMER_HAS_EXPIRED: - nwGtpv1uProcessTimeout(&received_message_p->ittiMsg.timer_has_expired.arg); - break; - - default: { - GTPU_ERROR("Unkwnon message ID %d:%s\n", - ITTI_MSG_ID(received_message_p), - ITTI_MSG_NAME(received_message_p)); - } - break; - } - - itti_free(ITTI_MSG_ORIGIN_ID(received_message_p), received_message_p); - received_message_p = NULL; - } - - return NULL; -} - -int gtpv1u_init(const mme_config_t *mme_config_p) -{ - int ret = 0; - NwGtpv1uRcT rc = 0; - NwGtpv1uUlpEntityT ulp; - NwGtpv1uUdpEntityT udp; - NwGtpv1uLogMgrEntityT log; - NwGtpv1uTimerMgrEntityT tmr; - - GTPU_DEBUG("Initializing GTPV1U interface\n"); - - memset(>pv1u_sgw_data, 0, sizeof(gtpv1u_sgw_data)); - - gtpv1u_sgw_data.sgw_ip_address_for_S1u_S12_S4_up = mme_config_p->ipv4.sgw_ip_address_for_S1u_S12_S4_up; - - if (itti_create_task(TASK_GTPV1_U, >pv1u_thread, NULL) < 0) { - GTPU_ERROR("gtpv1u phtread_create: %s", strerror(errno)); - return -1; - } - - GTPU_DEBUG("Initializing GTPV1U interface: DONE\n"); - - return ret; -} diff --git a/openair3/NAS/COMMON/IES/EpsNetworkFeatureSupport.c b/openair3/NAS/COMMON/IES/EpsNetworkFeatureSupport.c index 3a842406f0d66d36d4bde92340a358eba49c5484..2ef36d759575d3e57b59d1089ee6d5ff566047a3 100644 --- a/openair3/NAS/COMMON/IES/EpsNetworkFeatureSupport.c +++ b/openair3/NAS/COMMON/IES/EpsNetworkFeatureSupport.c @@ -41,8 +41,11 @@ int decode_eps_network_feature_support(EpsNetworkFeatureSupport *epsnetworkfeatu ielen = *(buffer + decoded); decoded++; CHECK_LENGTH_DECODER(len - decoded, ielen); - *epsnetworkfeaturesupport = *buffer & 0x1; - decoded++; + /* note: only the bit "IMS voice over PS session in S1 mode" is processed + * TODO: deal with other bits? + */ + *epsnetworkfeaturesupport = (*(buffer + decoded)) & 0x1; + decoded += ielen; #if defined (NAS_DEBUG) dump_eps_network_feature_support_xml(epsnetworkfeaturesupport, iei); #endif diff --git a/openair3/NAS/NR_UE/nr_nas_msg_sim.c b/openair3/NAS/NR_UE/nr_nas_msg_sim.c index ad2f2c7c3c6795789e059bc8523f5b5e1be443c2..7cf1378d8b96773baef3b30fba8554e6a6ce1509 100644 --- a/openair3/NAS/NR_UE/nr_nas_msg_sim.c +++ b/openair3/NAS/NR_UE/nr_nas_msg_sim.c @@ -43,6 +43,7 @@ #include <openair3/UICC/usim_interface.h> #include <openair3/NAS/COMMON/NR_NAS_defs.h> #include <openair1/PHY/phy_extern_nr_ue.h> +#include <openair1/SIMULATION/ETH_TRANSPORT/proto.h> uint8_t *registration_request_buf; uint32_t registration_request_len; @@ -673,7 +674,7 @@ void decodeDownlinkNASTransport(as_nas_info_t *initialNasMsg, uint8_t * pdu_buff sprintf(baseNetAddress, "%d.%d", *(pdu_buffer + 39),*(pdu_buffer + 40)); int third_octet = *(pdu_buffer + 41); int fourth_octet = *(pdu_buffer + 42); - LOG_I(NAS, "Received PDU Session Establishment Accept\n"); + LOG_A(NAS, "Received PDU Session Establishment Accept\n"); nas_config(1,third_octet,fourth_octet,"ue"); } else { LOG_E(NAS, "Received unexpected message in DLinformationTransfer %d\n", msg_type); @@ -775,6 +776,30 @@ static void generatePduSessionEstablishRequest(int Mod_id, uicc_t * uicc, as_nas } +uint8_t get_msg_type(uint8_t *pdu_buffer, uint32_t length) { + uint8_t msg_type = 0; + uint8_t offset = 0; + + if ((pdu_buffer != NULL) && (length > 0)) { + if (((nas_msg_header_t *)(pdu_buffer))->choice.security_protected_nas_msg_header_t.security_header_type > 0) { + offset += SECURITY_PROTECTED_5GS_NAS_MESSAGE_HEADER_LENGTH; + if (offset < length) { + msg_type = ((mm_msg_header_t *)(pdu_buffer + offset))->message_type; + + if (msg_type == FGS_DOWNLINK_NAS_TRANSPORT) { + msg_type = ((dl_nas_transport_t *)(pdu_buffer+ offset))->sm_nas_msg_header.message_type; + } + } + } else { // plain 5GS NAS message + msg_type = ((nas_msg_header_t *)(pdu_buffer))->choice.plain_nas_msg_header.message_type; + } + } else { + LOG_I(NAS, "[UE] Received invalid downlink message\n"); + } + + return msg_type; +} + void *nas_nrue_task(void *args_p) { MessageDef *msg_p; @@ -848,23 +873,8 @@ void *nas_nrue_task(void *args_p) NAS_CONN_ESTABLI_CNF (msg_p).errCode, NAS_CONN_ESTABLI_CNF (msg_p).nasMsg.length); pdu_buffer = NAS_CONN_ESTABLI_CNF (msg_p).nasMsg.data; - if((pdu_buffer + 1) != NULL){ - if (*(pdu_buffer + 1) > 0 ) { - if((pdu_buffer + 9) != NULL){ - msg_type = *(pdu_buffer + 9); - } else { - LOG_W(NAS, "[UE] Received invalid downlink message\n"); - break; - } - } else { - if((pdu_buffer + 2) != NULL){ - msg_type = *(pdu_buffer + 2); - } else { - LOG_W(NAS, "[UE] Received invalid downlink message\n"); - break; - } - } - } + msg_type = get_msg_type(pdu_buffer, NAS_CONN_ESTABLI_CNF (msg_p).nasMsg.length); + if(msg_type == REGISTRATION_ACCEPT){ LOG_I(NAS, "[UE] Received REGISTRATION ACCEPT message\n"); @@ -893,20 +903,39 @@ void *nas_nrue_task(void *args_p) itti_send_msg_to_task(TASK_RRC_NRUE, instance, message_p); LOG_I(NAS, "Send NAS_UPLINK_DATA_REQ message(PduSessionEstablishRequest)\n"); } - } - else if((pdu_buffer + 16) != NULL){ - msg_type = *(pdu_buffer + 16); - if(msg_type == FGS_PDU_SESSION_ESTABLISHMENT_ACC){ - if(baseNetAddress==NULL) { - baseNetAddress = calloc(1,8); + } else if(msg_type == FGS_PDU_SESSION_ESTABLISHMENT_ACC){ + uint8_t offset = 0; + uint8_t *payload_container = NULL; + offset += SECURITY_PROTECTED_5GS_NAS_MESSAGE_HEADER_LENGTH; + uint16_t payload_container_length = htons(((dl_nas_transport_t *)(pdu_buffer + offset))->payload_container_length); + if ((payload_container_length >= PAYLOAD_CONTAINER_LENGTH_MIN) && (payload_container_length <= PAYLOAD_CONTAINER_LENGTH_MAX)) { + offset += (PLAIN_5GS_NAS_MESSAGE_HEADER_LENGTH + 3); + } + + if (offset < NAS_CONN_ESTABLI_CNF(msg_p).nasMsg.length) { + payload_container = pdu_buffer + offset; + } + offset = 0; + + while(offset < payload_container_length) { + // Fixme: this is not good 'type' 0x29 searching in TLV like structure + // AND fix dirsty code copy hereafter of the same!!! + if (*(payload_container + offset) == 0x29) { // PDU address IEI + if ((*(payload_container+offset+1) == 0x05) && (*(payload_container +offset+2) == 0x01)) { // IPV4 + nas_getparams(); + sprintf(baseNetAddress, "%d.%d", *(payload_container+offset+3), *(payload_container+offset+4)); + int third_octet = *(payload_container+offset+5); + int fourth_octet = *(payload_container+offset+6); + LOG_I(NAS, "Received PDU Session Establishment Accept, UE IP: %d.%d.%d.%d\n", + *(payload_container+offset+3), *(payload_container+offset+4), + *(payload_container+offset+5), *(payload_container+offset+6)); + nas_config(1,third_octet,fourth_octet,"oaitun_ue"); + break; + } + } + offset++; } - sprintf(baseNetAddress, "%d.%d", *(pdu_buffer + 39),*(pdu_buffer + 40)); - int third_octet = *(pdu_buffer + 41); - int fourth_octet = *(pdu_buffer + 42); - LOG_I(NAS, "Received PDU Session Establishment Accept\n"); - nas_config(1,third_octet,fourth_octet,"ue"); } - } break; } @@ -933,19 +962,10 @@ void *nas_nrue_task(void *args_p) as_nas_info_t initialNasMsg={0}; pdu_buffer = NAS_DOWNLINK_DATA_IND(msg_p).nasMsg.data; - if((pdu_buffer + 1) != NULL){ - if (*(pdu_buffer + 1) > 0 ) { - msg_type = *(pdu_buffer + 9); - } else { - msg_type = *(pdu_buffer + 2); - } - } - if((pdu_buffer + 2) == NULL){ - LOG_W(NAS, "[UE] Received invalid downlink message\n"); - return 0; - } + msg_type = get_msg_type(pdu_buffer, NAS_DOWNLINK_DATA_IND(msg_p).nasMsg.length); switch(msg_type){ + case FGS_IDENTITY_REQUEST: generateIdentityResponse(&initialNasMsg,*(pdu_buffer+3), uicc); break; @@ -959,7 +979,36 @@ void *nas_nrue_task(void *args_p) case FGS_DOWNLINK_NAS_TRANSPORT: decodeDownlinkNASTransport(&initialNasMsg, pdu_buffer); break; - + case FGS_PDU_SESSION_ESTABLISHMENT_ACC: + { + uint8_t offset = 0; + uint8_t *payload_container = pdu_buffer; + offset += SECURITY_PROTECTED_5GS_NAS_MESSAGE_HEADER_LENGTH; + uint16_t payload_container_length = htons(((dl_nas_transport_t *)(pdu_buffer + offset))->payload_container_length); + if ((payload_container_length >= PAYLOAD_CONTAINER_LENGTH_MIN) && + (payload_container_length <= PAYLOAD_CONTAINER_LENGTH_MAX)) + offset += (PLAIN_5GS_NAS_MESSAGE_HEADER_LENGTH + 3); + if (offset < NAS_CONN_ESTABLI_CNF(msg_p).nasMsg.length) + payload_container = pdu_buffer + offset; + + while(offset < payload_container_length) { + if (*(payload_container + offset) == 0x29) { // PDU address IEI + if ((*(payload_container+offset+1) == 0x05) && (*(payload_container +offset+2) == 0x01)) { // IPV4 + nas_getparams(); + sprintf(baseNetAddress, "%d.%d", *(payload_container+offset+3), *(payload_container+offset+4)); + int third_octet = *(payload_container+offset+5); + int fourth_octet = *(payload_container+offset+6); + LOG_I(NAS, "Received PDU Session Establishment Accept, UE IP: %d.%d.%d.%d\n", + *(payload_container+offset+3), *(payload_container+offset+4), + *(payload_container+offset+5), *(payload_container+offset+6)); + nas_config(1,third_octet,fourth_octet,"oaitun_ue"); + break; + } + } + offset++; + } + } + break; default: LOG_W(NR_RRC,"unknow message type %d\n",msg_type); break; @@ -970,13 +1019,13 @@ void *nas_nrue_task(void *args_p) message_p = itti_alloc_new_message(TASK_NAS_NRUE, 0, NAS_UPLINK_DATA_REQ); NAS_UPLINK_DATA_REQ(message_p).UEid = Mod_id; NAS_UPLINK_DATA_REQ(message_p).nasMsg.data = (uint8_t *)initialNasMsg.data; + NAS_UPLINK_DATA_REQ(message_p).nasMsg.length = initialNasMsg.length; itti_send_msg_to_task(TASK_RRC_NRUE, instance, message_p); LOG_I(NAS, "Send NAS_UPLINK_DATA_REQ message\n"); } - - break; } + break; default: LOG_E(NAS, "[UE %d] Received unexpected message %s\n", Mod_id, ITTI_MSG_NAME (msg_p)); diff --git a/openair3/NAS/NR_UE/nr_nas_msg_sim.h b/openair3/NAS/NR_UE/nr_nas_msg_sim.h index 1b593660376a966ba9fed53cbb87135b4c8e504c..9655f87130f472f13a18ce1ce182bf9a6eef3b3b 100644 --- a/openair3/NAS/NR_UE/nr_nas_msg_sim.h +++ b/openair3/NAS/NR_UE/nr_nas_msg_sim.h @@ -64,6 +64,11 @@ #define INITIAL_REGISTRATION 0b001 +#define PLAIN_5GS_NAS_MESSAGE_HEADER_LENGTH 3 +#define SECURITY_PROTECTED_5GS_NAS_MESSAGE_HEADER_LENGTH 7 +#define PAYLOAD_CONTAINER_LENGTH_MIN 3 +#define PAYLOAD_CONTAINER_LENGTH_MAX 65537 + /* Security Key for SA UE */ typedef struct { uint8_t kausf[32]; @@ -75,6 +80,7 @@ typedef struct { uint8_t kgnb[32]; } ue_sa_security_key_t; + typedef enum fgs_protocol_discriminator_e { /* Protocol discriminator identifier for 5GS Mobility Management */ FGS_MOBILITY_MANAGEMENT_MESSAGE = 0x7E, @@ -126,6 +132,33 @@ typedef union { fgs_nas_message_plain_t plain; } fgs_nas_message_t; +typedef struct { + union { + mm_msg_header_t plain_nas_msg_header; + struct security_protected_nas_msg_header_s { + uint8_t ex_protocol_discriminator; + uint8_t security_header_type; + uint16_t message_authentication_code1; + uint16_t message_authentication_code2; + uint8_t sequence_number; + } security_protected_nas_msg_header_t; + } choice; +} nas_msg_header_t; + +typedef struct { + uint8_t ex_protocol_discriminator; + uint8_t pdu_session_id; + uint8_t PTI; + uint8_t message_type; +} fgs_sm_nas_msg_header_t; + +typedef struct { + mm_msg_header_t plain_nas_msg_header; + uint8_t payload_container_type; + uint16_t payload_container_length; + fgs_sm_nas_msg_header_t sm_nas_msg_header; +} dl_nas_transport_t; + void generateRegistrationRequest(as_nas_info_t *initialNasMsg, int Mod_id); void *nas_nrue_task(void *args_p); diff --git a/openair3/NAS/TOOLS/display.c b/openair3/NAS/TOOLS/display.c index 363fae76b8eed58ee56e959058a03a3df705403a..0828eeb67383582d7cb97a5072437dab03a6d93f 100644 --- a/openair3/NAS/TOOLS/display.c +++ b/openair3/NAS/TOOLS/display.c @@ -262,10 +262,10 @@ void display_usim_data(const char *filename) { kasme[USIM_K_ASME_SIZE] = '\0'; memcpy(kasme, data.securityctx.Kasme.value, USIM_K_ASME_SIZE); printf("\tKasme\t: \"%s\"\n", kasme); - printf("\tulNAScount\t: 0x%.8x\n", + /*printf("\tulNAScount\t: 0x%.8x\n", *(uint32_t*) data.securityctx.ulNAScount.value); printf("\tdlNAScount\t: 0x%.8x\n", - *(uint32_t*) data.securityctx.dlNAScount.value); + *(uint32_t*) data.securityctx.dlNAScount.value);*/ printf("\talgorithmID\t: 0x%.2x\n\n", data.securityctx.algorithmID.value[0]); diff --git a/openair3/NAS/UE/API/USIM/usim_api.c b/openair3/NAS/UE/API/USIM/usim_api.c index b882689f9b072e34f53438ec97af067fc09206cb..7facdaba792d612b338e4b3ca654f18942042cc4 100644 --- a/openair3/NAS/UE/API/USIM/usim_api.c +++ b/openair3/NAS/UE/API/USIM/usim_api.c @@ -249,7 +249,9 @@ int usim_api_authenticate_test(usim_data_t *usim_data, LOG_TRACE(INFO, "USIM-API - Comparing the XMAC with the MAC included in AUTN Succeeded"); /* Verify that the received sequence number SQN is in the correct range */ - rc = _usim_api_check_sqn(*(uint32_t*)(sqn), sqn[USIM_API_SQN_SIZE - 1]); + uint32_t v; + memcpy(&v, sqn, sizeof(v)); + rc = _usim_api_check_sqn(v, sqn[USIM_API_SQN_SIZE - 1]); } @@ -392,7 +394,9 @@ int usim_api_authenticate(usim_data_t *usim_data, const OctetString* rand_pP, co LOG_TRACE(INFO, "USIM-API - Comparing the XMAC with the MAC included in AUTN Succeeded"); /* Verify that the received sequence number SQN is in the correct range */ - rc = _usim_api_check_sqn(*(uint32_t*)(sqn), sqn[USIM_API_SQN_SIZE - 1]); + uint32_t v; + memcpy(&v, sqn, sizeof(v)); + rc = _usim_api_check_sqn(v, sqn[USIM_API_SQN_SIZE - 1]); } diff --git a/openair3/NAS/UE/ESM/PdnConnectivity.c b/openair3/NAS/UE/ESM/PdnConnectivity.c index 3b5bad7529d386bca0eb92b4afca5bbe8de16d8a..d17b5fde3c72341a94af41151acffbd4f2960c5e 100644 --- a/openair3/NAS/UE/ESM/PdnConnectivity.c +++ b/openair3/NAS/UE/ESM/PdnConnectivity.c @@ -356,7 +356,7 @@ int esm_proc_pdn_connectivity_accept(nas_user_t *user, int pti, esm_proc_pdn_typ int pid = RETURNerror; char apn_first_char[4]; - LOG_VAR(char, str[128]); + char str[128] __attribute__((unused)); if (isprint(apn->value[0])) { apn_first_char[0] = '\0'; diff --git a/openair3/NAS/UE/ESM/esm_ebr_context.c b/openair3/NAS/UE/ESM/esm_ebr_context.c index 0c79fa3e3af330a22e1d294ffc6cd96f7e276327..b801ca2ad54e788a884f0e5cb2a6ee28a3a5f263 100644 --- a/openair3/NAS/UE/ESM/esm_ebr_context.c +++ b/openair3/NAS/UE/ESM/esm_ebr_context.c @@ -51,6 +51,7 @@ Description Defines functions used to handle EPS bearer contexts. #include "assertions.h" #include "pdcp.h" #include "nfapi/oai_integration/vendor_ext.h" +#include "executables/softmodem-common.h" #include <sys/socket.h> #include <netinet/in.h> @@ -262,8 +263,7 @@ int esm_ebr_context_create( netmask = 32; strcpy(broadcast, ipv4_addr); } - - res = sprintf(command_line, + LOG_D(NAS, "setting commandline string: " "ip address add %s/%d broadcast %s dev %s%d && " "ip link set %s%d up && " "ip rule add from %s/32 table %d && " @@ -276,26 +276,67 @@ int esm_ebr_context_create( ipv4_addr, ueid + 10000, UE_NAS_USE_TUN ? "oaitun_ue" : "oip", ueid + 1, ueid + 10000); - - if ( res<0 ) { - LOG_TRACE(WARNING, "ESM-PROC - Failed to system command string"); - } - - LOG_TRACE(INFO, "ESM-PROC - executing %s ", + if (!get_softmodem_params()->nsa) + { + res = sprintf(command_line, + "ip address add %s/%d broadcast %s dev %s%d && " + "ip link set %s%d up && " + "ip rule add from %s/32 table %d && " + "ip rule add to %s/32 table %d && " + "ip route add default dev %s%d table %d", + ipv4_addr, netmask, broadcast, + UE_NAS_USE_TUN ? "oaitun_ue" : "oip", ueid + 1, + UE_NAS_USE_TUN ? "oaitun_ue" : "oip", ueid + 1, + ipv4_addr, ueid + 10000, + ipv4_addr, ueid + 10000, + UE_NAS_USE_TUN ? "oaitun_ue" : "oip", + ueid + 1, ueid + 10000); + + if ( res<0 ) { + LOG_TRACE(WARNING, "ESM-PROC - Failed to system command string"); + } + + /* Calling system() here disrupts UE's realtime processing in some cases. + * This may be because of the call to fork(), which, for some + * unidentified reason, interacts badly with other (realtime) threads. + * background_system() is a replacement mechanism relying on a + * background process that does the system() and reports result to + * the parent process (lte-softmodem, oaisim, ...). The background + * process is created very early in the life of the parent process. + * The processes interact through standard pipes. See + * common/utils/system.c for details. + */ + + LOG_TRACE(INFO, "ESM-PROC - executing %s ", command_line); - - /* Calling system() here disrupts UE's realtime processing in some cases. - * This may be because of the call to fork(), which, for some - * unidentified reason, interacts badly with other (realtime) threads. - * background_system() is a replacement mechanism relying on a - * background process that does the system() and reports result to - * the parent process (lte-softmodem, oaisim, ...). The background - * process is created very early in the life of the parent process. - * The processes interact through standard pipes. See - * common/utils/system.c for details. - */ - if (background_system(command_line) != 0) - LOG_TRACE(ERROR, "ESM-PROC - failed command '%s'", command_line); + if (background_system(command_line) != 0) + { + LOG_TRACE(ERROR, "ESM-PROC - failed command '%s'", command_line); + } + } + else if (get_softmodem_params()->nsa) { + res = sprintf(command_line, + "ip address add %s/%d broadcast %s dev %s%d && " + "ip link set %s%d up && " + "ip rule add from %s/32 table %d && " + "ip rule add to %s/32 table %d && " + "ip route add default dev %s%d table %d", + ipv4_addr, netmask, broadcast, + UE_NAS_USE_TUN ? "oaitun_nru" : "oip", ueid + 1, + UE_NAS_USE_TUN ? "oaitun_nru" : "oip", ueid + 1, + ipv4_addr, ueid + 10000, + ipv4_addr, ueid + 10000, + UE_NAS_USE_TUN ? "oaitun_nru" : "oip", + ueid + 1, ueid + 10000); + + if ( res<0 ) { + LOG_TRACE(WARNING, "ESM-PROC - Failed to system command string"); + } + LOG_D(NAS, "Sending NAS_OAI_TUN_NSA msg to LTE UE via itti\n"); + MessageDef *msg_p = itti_alloc_new_message(TASK_NAS_UE, 0, NAS_OAI_TUN_NSA); + memcpy(NAS_OAI_TUN_NSA(msg_p).buffer, command_line, sizeof(NAS_OAI_TUN_NSA(msg_p).buffer)); + itti_send_msg_to_task(TASK_RRC_UE, 0, msg_p); + } break; diff --git a/openair3/NAS/UE/nas_ue_task.c b/openair3/NAS/UE/nas_ue_task.c index be887623bb56e49abaa0b17114c6032e67a1f260..88938c3c376e0aea7614192395e77c794114eebe 100644 --- a/openair3/NAS/UE/nas_ue_task.c +++ b/openair3/NAS/UE/nas_ue_task.c @@ -24,7 +24,7 @@ # include "intertask_interface.h" # include "nas_ue_task.h" # include "common/utils/LOG/log.h" - +# include "vendor_ext.h" # include "user_defs.h" # include "user_api.h" # include "nas_parser.h" @@ -42,6 +42,8 @@ extern unsigned char NB_eNB_INST; extern uint16_t NB_UE_INST; +uint16_t ue_idx_standalone = 0xFFFF; + char *make_port_str_from_ueid(const char *base_port_str, int ueid); static int nas_ue_process_events(nas_user_container_t *users, struct epoll_event *events, int nb_events) @@ -96,41 +98,89 @@ void *nas_ue_task(void *args_p) itti_mark_task_ready (TASK_NAS_UE); MSC_START_USE(); + LOG_I(NAS, "ue_idx_standalone val:: %u\n", ue_idx_standalone); /* Initialize UE NAS (EURECOM-NAS) */ - for (int i=0; i < users->count; i++) + // Intead of for loop for standalone mode + if (ue_idx_standalone == 0xFFFF) { - nas_user_t *user = &users->item[i]; - user->ueid=i; + for (int i = 0; i < users->count; i++) + { + nas_user_t *user = &users->item[i]; + user->ueid = i; + + /* Get USIM data application filename */ + user->usim_data_store = memory_get_path_from_ueid(USIM_API_NVRAM_DIRNAME, USIM_API_NVRAM_FILENAME, user->ueid); + if (user->usim_data_store == NULL) + { + LOG_E(NAS, "[UE %d] - Failed to get USIM data application filename", user->ueid); + exit(EXIT_FAILURE); + } - /* Get USIM data application filename */ - user->usim_data_store = memory_get_path_from_ueid(USIM_API_NVRAM_DIRNAME, USIM_API_NVRAM_FILENAME, user->ueid); - if ( user->usim_data_store == NULL ) { - LOG_E(NAS, "[UE %d] - Failed to get USIM data application filename", user->ueid); - exit(EXIT_FAILURE); - } + /* Get UE's data pathname */ + user->user_nvdata_store = memory_get_path_from_ueid(USER_NVRAM_DIRNAME, USER_NVRAM_FILENAME, user->ueid); + if (user->user_nvdata_store == NULL) + { + LOG_E(NAS, "[UE %d] - Failed to get USIM nvdata filename", user->ueid); + exit(EXIT_FAILURE); + } - /* Get UE's data pathname */ - user->user_nvdata_store = memory_get_path_from_ueid(USER_NVRAM_DIRNAME, USER_NVRAM_FILENAME, user->ueid); - if ( user->user_nvdata_store == NULL ) { - LOG_E(NAS, "[UE %d] - Failed to get USIM nvdata filename", user->ueid); - exit(EXIT_FAILURE); - } + /* Get EMM data pathname */ + user->emm_nvdata_store = memory_get_path_from_ueid(EMM_NVRAM_DIRNAME, EMM_NVRAM_FILENAME, user->ueid); + if (user->emm_nvdata_store == NULL) + { + LOG_E(NAS, "[UE %d] - Failed to get EMM nvdata filename", user->ueid); + exit(EXIT_FAILURE); + } - /* Get EMM data pathname */ - user->emm_nvdata_store = memory_get_path_from_ueid(EMM_NVRAM_DIRNAME, EMM_NVRAM_FILENAME, user->ueid); - if ( user->emm_nvdata_store == NULL ) { - LOG_E(NAS, "[UE %d] - Failed to get EMM nvdata filename", user->ueid); - exit(EXIT_FAILURE); + /* Initialize user interface (to exchange AT commands with user process) */ + nas_user_api_id_initialize(user); + /* allocate needed structures */ + user->user_at_commands = calloc_or_fail(sizeof(user_at_commands_t)); + user->at_response = calloc_or_fail(sizeof(at_response_t)); + user->lowerlayer_data = calloc_or_fail(sizeof(lowerlayer_data_t)); + /* Initialize NAS user */ + nas_user_initialize(user, &user_api_emm_callback, &user_api_esm_callback, FIRMWARE_VERSION); } - - /* Initialize user interface (to exchange AT commands with user process) */ - nas_user_api_id_initialize(user); - /* allocate needed structures */ - user->user_at_commands = calloc_or_fail(sizeof(user_at_commands_t)); - user->at_response = calloc_or_fail(sizeof(at_response_t)); - user->lowerlayer_data = calloc_or_fail(sizeof(lowerlayer_data_t)); - /* Initialize NAS user */ - nas_user_initialize (user, &user_api_emm_callback, &user_api_esm_callback, FIRMWARE_VERSION); + } + else + { + // use new parameter passed into lte-uesoftmodem which instead of looping + // calls functions on specific UE index. + + nas_user_t *user = &users->item[0]; + user->ueid = ue_idx_standalone; + LOG_I(NAS, "[UE %d] Configuring\n", user->ueid); + + /* Get USIM data application filename */ // + user->usim_data_store = memory_get_path_from_ueid(USIM_API_NVRAM_DIRNAME, USIM_API_NVRAM_FILENAME, user->ueid); + if (user->usim_data_store == NULL) + { + LOG_E(NAS, "[UE %d] - Failed to get USIM data application filename", user->ueid); + exit(EXIT_FAILURE); + } + /* Get UE's data pathname */ + user->user_nvdata_store = memory_get_path_from_ueid(USER_NVRAM_DIRNAME, USER_NVRAM_FILENAME, user->ueid); + if (user->user_nvdata_store == NULL) + { + LOG_E(NAS, "[UE %d] - Failed to get USIM nvdata filename", user->ueid); + exit(EXIT_FAILURE); + } + /* Get EMM data pathname */ + user->emm_nvdata_store = memory_get_path_from_ueid(EMM_NVRAM_DIRNAME, EMM_NVRAM_FILENAME, user->ueid); + if (user->emm_nvdata_store == NULL) + { + LOG_E(NAS, "[UE %d] - Failed to get EMM nvdata filename", user->ueid); + exit(EXIT_FAILURE); + } + /* Initialize user interface (to exchange AT commands with user process) */ + nas_user_api_id_initialize(user); + /* allocate needed structures */ + user->user_at_commands = calloc_or_fail(sizeof(user_at_commands_t)); + user->at_response = calloc_or_fail(sizeof(at_response_t)); + user->lowerlayer_data = calloc_or_fail(sizeof(lowerlayer_data_t)); + /* Initialize NAS user */ + nas_user_initialize(user, &user_api_emm_callback, &user_api_esm_callback, FIRMWARE_VERSION); + user->ueid = 0; } /* Set UE activation state */ diff --git a/openair3/S1AP/s1ap_common.h b/openair3/S1AP/s1ap_common.h index efac0201a31feaa1aa5dd5380e6ab5dcb7f2dd56..3c07f92a7f5b1dd6e91ad3a833772709caf300c4 100644 --- a/openair3/S1AP/s1ap_common.h +++ b/openair3/S1AP/s1ap_common.h @@ -82,7 +82,6 @@ extern int asn1_xer_print; # define S1AP_INFO(x, args...) LOG_I(S1AP, x, ##args) # define S1AP_DEBUG(x, args...) LOG_I(S1AP, x, ##args) #else -# include "mme_default_values.h" # define S1AP_ERROR(x, args...) do { fprintf(stdout, "[S1AP][E]"x, ##args); } while(0) # define S1AP_WARN(x, args...) do { fprintf(stdout, "[S1AP][W]"x, ##args); } while(0) # define S1AP_TRAF(x, args...) do { fprintf(stdout, "[S1AP][T]"x, ##args); } while(0) diff --git a/openair3/SCTP/sctp_eNB_task.c b/openair3/SCTP/sctp_eNB_task.c index a14d4b9780c487b8f1cf01d3b510de2bc486041a..8d0166f80534436b6017cb415a284d7fd7b86848 100644 --- a/openair3/SCTP/sctp_eNB_task.c +++ b/openair3/SCTP/sctp_eNB_task.c @@ -451,9 +451,9 @@ sctp_handle_new_association_req( if (s > 0 ) { if (((struct sockaddr_in*)ifa->ifa_addr)->sin_addr.s_addr == in.s_addr) { - struct sockaddr_in locaddr; + struct sockaddr_in locaddr={0}; locaddr.sin_family = AF_INET; - locaddr.sin_port = htons(sctp_new_association_req_p->port); + locaddr.sin_port = 0; locaddr.sin_addr.s_addr = in.s_addr; if (sctp_bindx(sd, (struct sockaddr*)&locaddr, 1, SCTP_BINDX_ADD_ADDR) < 0) { @@ -693,7 +693,7 @@ static int sctp_create_new_listener( sctp_init_t *init_p, int server_type) { - struct sctp_event_subscribe event; + struct sctp_event_subscribe event={0}; struct sockaddr *addr = NULL; struct sctp_cnx_list_elm_s *sctp_cnx = NULL; uint16_t i = 0, j = 0; @@ -925,21 +925,14 @@ void sctp_eNB_read_from_socket( struct sctp_cnx_list_elm_s *sctp_cnx) { - int flags = 0, n; - socklen_t from_len; - struct sctp_sndrcvinfo sinfo; - - struct sockaddr_in addr; - uint8_t buffer[SCTP_RECV_BUFFER_SIZE]; - DevAssert(sctp_cnx != NULL); - memset((void *)&addr, 0, sizeof(struct sockaddr_in)); - from_len = (socklen_t)sizeof(struct sockaddr_in); - memset((void *)&sinfo, 0, sizeof(struct sctp_sndrcvinfo)); + int flags = 0; + struct sctp_sndrcvinfo sinfo={0}; + uint8_t buffer[SCTP_RECV_BUFFER_SIZE]; - n = sctp_recvmsg(sctp_cnx->sd, (void *)buffer, SCTP_RECV_BUFFER_SIZE, - (struct sockaddr *)&addr, &from_len, + int n = sctp_recvmsg(sctp_cnx->sd, (void *)buffer, SCTP_RECV_BUFFER_SIZE, + NULL, NULL, &sinfo, &flags); if (n < 0) { @@ -1050,8 +1043,8 @@ sctp_eNB_read_from_socket( sctp_cnx->ppid); } - SCTP_DEBUG("[%d][%d] Msg of length %d received from port %u, on stream %d, PPID %d\n", - sinfo.sinfo_assoc_id, sctp_cnx->sd, n, ntohs(addr.sin_port), + SCTP_DEBUG("[%d][%d] Msg of length %d received, on stream %d, PPID %d\n", + sinfo.sinfo_assoc_id, sctp_cnx->sd, n, sinfo.sinfo_stream, ntohl(sinfo.sinfo_ppid)); sctp_itti_send_new_message_ind(sctp_cnx->task_id, diff --git a/openair3/UDP/udp_eNB_task.c b/openair3/UDP/udp_eNB_task.c index 05729ba6b1e8666e4162e9f06a2aefeab5b36832..8b9fc77bb14ebcff3ce765504113a385a2d408bf 100644 --- a/openair3/UDP/udp_eNB_task.c +++ b/openair3/UDP/udp_eNB_task.c @@ -235,7 +235,7 @@ udp_eNB_send_to( void udp_eNB_receiver(struct udp_socket_desc_s *udp_sock_pP) { - uint8_t l_buffer[2048]; + uint8_t l_buffer[NFAPI_MAX_PACKED_MESSAGE_SIZE]; int n; socklen_t from_len; struct sockaddr_in addr; @@ -246,10 +246,13 @@ void udp_eNB_receiver(struct udp_socket_desc_s *udp_sock_pP) if (1) { from_len = (socklen_t)sizeof(struct sockaddr_in); - if ((n = recvfrom(udp_sock_pP->sd, l_buffer, sizeof(l_buffer), 0, + if ((n = recvfrom(udp_sock_pP->sd, l_buffer, sizeof(l_buffer), MSG_TRUNC, (struct sockaddr *)&addr, &from_len)) < 0) { LOG_E(UDP_, "Recvfrom failed %s\n", strerror(errno)); return; + } else if (n > sizeof(l_buffer)) { + LOG_E(UDP_, "%s(%d). Message truncated. %d\n", __FUNCTION__, __LINE__, n); + return; } else if (n == 0) { LOG_W(UDP_, "Recvfrom returned 0\n"); return; diff --git a/openair3/UTILS/conversions.h b/openair3/UTILS/conversions.h index cfb2c8cdfc5c4ec56934d9abee19142053eed40e..00b650a3025af8748abde760f2daf14d58820459 100644 --- a/openair3/UTILS/conversions.h +++ b/openair3/UTILS/conversions.h @@ -400,10 +400,10 @@ do { \ #define TRANSPORT_LAYER_ADDRESS_IPv4_TO_BIT_STRING(mACRO, bITsTRING) \ do { \ (bITsTRING)->buf = calloc(4, sizeof(uint8_t)); \ - (bITsTRING)->buf[0] = (mACRO) >> 24 & 0xFF; \ - (bITsTRING)->buf[1] = (mACRO) >> 16 & 0xFF; \ - (bITsTRING)->buf[2] = (mACRO) >> 8 & 0xFF; \ - (bITsTRING)->buf[3] = (mACRO) >> 4 & 0xFF; \ + (bITsTRING)->buf[3] = (mACRO) >> 24 & 0xFF; \ + (bITsTRING)->buf[2] = (mACRO) >> 16 & 0xFF; \ + (bITsTRING)->buf[1] = (mACRO) >> 8 & 0xFF; \ + (bITsTRING)->buf[0] = (mACRO) & 0xFF; \ (bITsTRING)->size = 4; \ (bITsTRING)->bits_unused = 0; \ } while(0) @@ -412,10 +412,10 @@ do { \ do { \ DevCheck((bITsTRING)->size == 4, (bITsTRING)->size, 4, 0); \ DevCheck((bITsTRING)->bits_unused == 0, (bITsTRING)->bits_unused, 0, 0); \ - mACRO = ((bITsTRING)->buf[0] << 24) + \ - ((bITsTRING)->buf[1] << 16) + \ - ((bITsTRING)->buf[2] << 8) + \ - ((bITsTRING)->buf[3]); \ + mACRO = ((bITsTRING)->buf[3] << 24) + \ + ((bITsTRING)->buf[2] << 16) + \ + ((bITsTRING)->buf[1] << 8) + \ + ((bITsTRING)->buf[0]); \ } while (0) diff --git a/openair3/ocp-gtpu/gtp_itf.cpp b/openair3/ocp-gtpu/gtp_itf.cpp index a3eeb26540ce29fb7f42863867e5490000940978..64146bc7cac61caaf12b19a46629288f12ba16e2 100644 --- a/openair3/ocp-gtpu/gtp_itf.cpp +++ b/openair3/ocp-gtpu/gtp_itf.cpp @@ -93,7 +93,7 @@ class gtpEndPoints { gtpEndPoints globGtp; // note TEid 0 is reserved for specific usage: echo req/resp, error and supported extensions -static uint32_t gtpv1uNewTeid(void) { +static teid_t gtpv1uNewTeid(void) { #ifdef GTPV1U_LINEAR_TEID_ALLOCATION g_gtpv1u_teid = g_gtpv1u_teid + 1; return g_gtpv1u_teid; @@ -102,13 +102,13 @@ static uint32_t gtpv1uNewTeid(void) { #endif } -int legacyInstanceMapping=0; +instance_t legacyInstanceMapping=0; #define compatInst(a) ((a)==0 || (a)==INSTANCE_DEFAULT?legacyInstanceMapping:a) #define GTPV1U_HEADER_SIZE (8) - - -static int gtpv1uCreateAndSendMsg(int h, uint32_t peerIp, uint16_t peerPort, teid_t teid, uint8_t *Msg,int msgLen, + + + static int gtpv1uCreateAndSendMsg(int h, uint32_t peerIp, uint16_t peerPort, int msgType, teid_t teid, uint8_t *Msg,int msgLen, bool seqNumFlag, bool npduNumFlag, bool extHdrFlag, int seqNum, int npduNum, int extHdrType) { AssertFatal(extHdrFlag==false,"Not developped"); int headerAdditional=0; @@ -116,9 +116,8 @@ static int gtpv1uCreateAndSendMsg(int h, uint32_t peerIp, uint16_t peerPort, te if ( seqNumFlag || npduNumFlag || extHdrFlag) headerAdditional=4; - uint8_t *buffer; int fullSize=GTPV1U_HEADER_SIZE+headerAdditional+msgLen; - AssertFatal((buffer=(uint8_t *) malloc(fullSize)) != NULL, ""); + uint8_t buffer[fullSize]; Gtpv1uMsgHeaderT *msgHdr = (Gtpv1uMsgHeaderT *)buffer ; // N should be 0 for us (it was used only in 2G and 3G) msgHdr->PN=npduNumFlag; @@ -128,10 +127,12 @@ static int gtpv1uCreateAndSendMsg(int h, uint32_t peerIp, uint16_t peerPort, te //PT=0 is for GTP' TS 32.295 (charging) msgHdr->PT=1; msgHdr->version=1; - msgHdr->msgType=GTP_GPDU; + msgHdr->msgType=msgType; msgHdr->msgLength=htons(msgLen); + if ( seqNumFlag || extHdrFlag || npduNumFlag) msgHdr->msgLength+=4; + msgHdr->teid=htonl(teid); if(seqNumFlag || extHdrFlag || npduNumFlag) { @@ -147,16 +148,13 @@ static int gtpv1uCreateAndSendMsg(int h, uint32_t peerIp, uint16_t peerPort, te to.sin_port = htons(peerPort); to.sin_addr.s_addr = peerIp ; LOG_D(GTPU,"sending packet size: %d to %s\n",fullSize, inet_ntoa(to.sin_addr) ); - - if (sendto(h, (void *)buffer, (size_t)fullSize, 0,(struct sockaddr *)&to, sizeof(to) ) != fullSize ) { - LOG_E(GTPU, - "[SD %d] Failed to send data to " IPV4_ADDR " on port %d, buffer size %u\n", - h, IPV4_ADDR_FORMAT(peerIp), peerPort, fullSize); - free(buffer); + int ret; + if ((ret=sendto(h, (void *)buffer, (size_t)fullSize, 0,(struct sockaddr *)&to, sizeof(to) )) != fullSize ) { + LOG_E(GTPU, "[SD %d] Failed to send data to " IPV4_ADDR " on port %d, buffer size %u, ret: %d, errno: %d\n", + h, IPV4_ADDR_FORMAT(peerIp), peerPort, fullSize, ret, errno); return GTPNOK; } - free(buffer); return !GTPNOK; } @@ -170,33 +168,35 @@ static void gtpv1uSend(instance_t instance, gtpv1u_enb_tunnel_data_req_t *req, b auto ptrRnti=inst->ue2te_mapping.find(rnti); if ( ptrRnti==inst->ue2te_mapping.end() ) { - LOG_E(GTPU, "gtpv1uSend failed: while getting ue rnti %x in hashtable ue_mapping\n", rnti); + 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; } - auto ptr=ptrRnti->second.bearers; + map<int, ocp_gtpv1u_bearer_t>::iterator ptr2=ptrRnti->second.bearers.find(rab_id); - if ( ptr.find(rab_id) == ptr.end() ) { - LOG_E(GTPU,"sending a packet to a non existant RNTI:RAB: %x/%x\n", rnti, rab_id); + if ( ptr2 == ptrRnti->second.bearers.end() ) { + LOG_E(GTPU,"[%ld] GTP-U instance: sending a packet to a non existant RNTI:RAB: %x/%x\n", instance, rnti, rab_id); pthread_mutex_unlock(&globGtp.gtp_lock); return; - } else - LOG_D(GTPU,"sending a packet to RNTI:RAB:teid %x/%x/%x, len %lu, oldseq %d, oldnum %d\n", - rnti, rab_id,ptr[rab_id].teid_outgoing,length, ptr[rab_id].seqNum,ptr[rab_id].npduNum ); + } + + LOG_D(GTPU,"[%ld] sending a packet to RNTI:RAB:teid %x/%x/%x, len %lu, oldseq %d, oldnum %d\n", + instance, rnti, rab_id,ptr2->second.teid_outgoing,length, ptr2->second.seqNum,ptr2->second.npduNum ); if(seqNumFlag) - ptr[rab_id].seqNum++; + ptr2->second.seqNum++; if(npduNumFlag) - ptr[rab_id].npduNum++; + ptr2->second.npduNum++; - // We will release the lock, let's copy data before - ocp_gtpv1u_bearer_t tmp=ptr[rab_id]; + // copy to release the mutex + ocp_gtpv1u_bearer_t tmp=ptr2->second; pthread_mutex_unlock(&globGtp.gtp_lock); gtpv1uCreateAndSendMsg(compatInst(instance), tmp.outgoing_ip_addr, tmp.outgoing_port, + GTP_GPDU, tmp.teid_outgoing, buffer, length, seqNumFlag, npduNumFlag, false, tmp.seqNum, tmp.npduNum, 0) ; } @@ -211,33 +211,35 @@ static void gtpv1uSend2(instance_t instance, gtpv1u_gnb_tunnel_data_req_t *req, auto ptrRnti=inst->ue2te_mapping.find(rnti); if ( ptrRnti==inst->ue2te_mapping.end() ) { - LOG_E(GTPU, "gtpv1uSend failed: while getting ue rnti %x in hashtable ue_mapping\n", rnti); + 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; } - auto ptr=ptrRnti->second.bearers; + map<int, ocp_gtpv1u_bearer_t>::iterator ptr2=ptrRnti->second.bearers.find(rab_id); - if ( ptr.find(rab_id) == ptr.end() ) { - LOG_E(GTPU,"sending a packet to a non existant RNTI:RAB: %x/%x\n", rnti, rab_id); + if ( ptr2 == ptrRnti->second.bearers.end() ) { + LOG_D(GTPU,"GTP-U instance: %ld sending a packet to a non existant RNTI:RAB: %x/%x\n", instance, rnti, rab_id); pthread_mutex_unlock(&globGtp.gtp_lock); return; - } else - LOG_D(GTPU,"sending a packet to RNTI:RAB:teid %x/%x/%x, len %lu, oldseq %d, oldnum %d\n", - rnti, rab_id,ptr[rab_id].teid_outgoing,length, ptr[rab_id].seqNum,ptr[rab_id].npduNum ); + } + + LOG_D(GTPU,"[%ld] GTP-U sending a packet to RNTI:RAB:teid %x/%x/%x, len %lu, oldseq %d, oldnum %d\n", + instance, rnti, rab_id,ptr2->second.teid_outgoing,length, ptr2->second.seqNum,ptr2->second.npduNum ); if(seqNumFlag) - ptr[rab_id].seqNum++; + ptr2->second.seqNum++; if(npduNumFlag) - ptr[rab_id].npduNum++; + ptr2->second.npduNum++; - // We will release the lock, let's copy data before - ocp_gtpv1u_bearer_t tmp=ptr[rab_id]; + // copy to release the mutex + ocp_gtpv1u_bearer_t tmp=ptr2->second; pthread_mutex_unlock(&globGtp.gtp_lock); gtpv1uCreateAndSendMsg(compatInst(instance), tmp.outgoing_ip_addr, tmp.outgoing_port, + GTP_GPDU, tmp.teid_outgoing, buffer, length, seqNumFlag, npduNumFlag, false, tmp.seqNum, tmp.npduNum, 0) ; } @@ -250,22 +252,22 @@ static void gtpv1uEndTunnel(instance_t instance, gtpv1u_enb_tunnel_data_req_t *r auto ptrRnti=inst->ue2te_mapping.find(rnti); if ( ptrRnti==inst->ue2te_mapping.end() ) { - LOG_E(GTPU, "gtpv1uSend failed: while getting ue rnti %x in hashtable ue_mapping\n", rnti); + 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; } - auto ptr=ptrRnti->second.bearers; + map<int, ocp_gtpv1u_bearer_t>::iterator ptr2=ptrRnti->second.bearers.find(rab_id); - if ( ptr.find(rab_id) == ptr.end() ) { - LOG_E(GTPU,"sending a packet to a non existant RNTI:RAB: %x/%x\n", rnti, rab_id); + if ( ptr2 == ptrRnti->second.bearers.end() ) { + LOG_E(GTPU,"[%ld] GTP-U sending a packet to a non existant RNTI:RAB: %x/%x\n", instance, rnti, rab_id); pthread_mutex_unlock(&globGtp.gtp_lock); return; - } else - LOG_D(GTPU,"sending a end packet packet to RNTI:RAB:teid %x/%x/%x\n", - rnti, rab_id,ptr[rab_id].teid_outgoing); + } - ocp_gtpv1u_bearer_t tmp=ptr[rab_id]; + LOG_D(GTPU,"[%ld] sending a end packet packet to RNTI:RAB:teid %x/%x/%x\n", + instance, rnti, rab_id,ptr2->second.teid_outgoing); + ocp_gtpv1u_bearer_t tmp=ptr2->second; pthread_mutex_unlock(&globGtp.gtp_lock); Gtpv1uMsgHeaderT msgHdr; // N should be 0 for us (it was used only in 2G and 3G) @@ -284,14 +286,13 @@ static void gtpv1uEndTunnel(instance_t instance, gtpv1u_enb_tunnel_data_req_t *r to.sin_family = AF_INET; to.sin_port = htons(tmp.outgoing_port); to.sin_addr.s_addr = tmp.outgoing_ip_addr; - char ip4[INET_ADDRSTRLEN]; //char ip6[INET6_ADDRSTRLEN]; - LOG_D(GTPU,"sending end packet to %s\n", inet_ntoa(to.sin_addr) ); + LOG_D(GTPU,"[%ld] sending end packet to %s\n", instance, inet_ntoa(to.sin_addr) ); if (sendto(compatInst(instance), (void *)&msgHdr, sizeof(msgHdr), 0,(struct sockaddr *)&to, sizeof(to) ) != sizeof(msgHdr)) { LOG_E(GTPU, - "[SD %ld] Failed to send data to %s on port %d, buffer size %lu\n", + "[%ld] Failed to send data to %s on port %d, buffer size %lu\n", compatInst(instance), inet_ntop(AF_INET, &tmp.outgoing_ip_addr, ip4, INET_ADDRSTRLEN), tmp.outgoing_port, sizeof(msgHdr)); } } @@ -378,7 +379,7 @@ static int udpServerSocket(openAddr_s addr) { int sendbuff = 1000*1000*10; AssertFatal(0==setsockopt(sockfd, SOL_SOCKET, SO_SNDBUF, &sendbuff, sizeof(sendbuff)),""); - LOG_D(GTPU,"Created listener for paquets to: %s:%s, send buffer size: %d\n", addr.originHost, addr.originService,sendbuff); + LOG_D(GTPU,"[%d] Created listener for paquets to: %s:%s, send buffer size: %d\n", sockfd, addr.originHost, addr.originService,sendbuff); return sockfd; } @@ -392,24 +393,51 @@ instance_t ocp_gtpv1Init(openAddr_t context) { LOG_E(GTPU,"can't create GTP-U instance\n"); pthread_mutex_unlock(&globGtp.gtp_lock); + LOG_I(GTPU, "Created gtpu instance id: %d\n", id); return id; } +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; + } + + map<int, ocp_gtpv1u_bearer_t>::iterator ptr2=ptrRnti->second.bearers.find(bearer_id); + + if ( ptr2 == ptrRnti->second.bearers.end() ) { + LOG_E(GTPU,"[%ld] Update tunnel for a existing rnti %x, but wrong bearer_id %u\n", instance, rnti, bearer_id); + pthread_mutex_unlock(&globGtp.gtp_lock); + return; + } + + ptr2->second.teid_outgoing = newOutgoingTeid; + LOG_I(GTPU, "[%ld] Tunnel Outgoing TEID updated to %x \n", instance, ptr2->second.teid_outgoing); + pthread_mutex_unlock(&globGtp.gtp_lock); + return; +} + teid_t newGtpuCreateTunnel(instance_t instance, rnti_t rnti, int incoming_bearer_id, int outgoing_bearer_id, teid_t outgoing_teid, transport_layer_addr_t remoteAddr, int port, gtpCallback callBack) { pthread_mutex_lock(&globGtp.gtp_lock); + instance=compatInst(instance); auto inst=&globGtp.instances[instance]; auto it=inst->ue2te_mapping.find(rnti); if ( it != inst->ue2te_mapping.end() ) { - LOG_W(GTPU,"Create a config for a already existing GTP tunnel (rnti %x)\n", rnti); + LOG_W(GTPU,"[%ld] Create a config for a already existing GTP tunnel (rnti %x)\n", instance, rnti); inst->ue2te_mapping.erase(it); } - uint32_t incoming_teid=gtpv1uNewTeid(); + teid_t incoming_teid=gtpv1uNewTeid(); while ( inst->te2ue_mapping.find(incoming_teid) != inst->te2ue_mapping.end() ) { - LOG_W(GTPU, "generated a random Teid that exists, re-generating (%x)\n",incoming_teid); + LOG_W(GTPU, "[%ld] generated a random Teid that exists, re-generating (%x)\n", instance, incoming_teid); incoming_teid=gtpv1uNewTeid(); }; @@ -419,7 +447,7 @@ teid_t newGtpuCreateTunnel(instance_t instance, rnti_t rnti, int incoming_bearer inst->te2ue_mapping[incoming_teid].callBack=callBack; - auto tmp=&inst->ue2te_mapping[rnti].bearers[outgoing_bearer_id]; + ocp_gtpv1u_bearer_t *tmp=&inst->ue2te_mapping[rnti].bearers[outgoing_bearer_id]; int addrs_length_in_bytes = remoteAddr.length / 8; @@ -449,21 +477,21 @@ teid_t newGtpuCreateTunnel(instance_t instance, rnti_t rnti, int incoming_bearer pthread_mutex_unlock(&globGtp.gtp_lock); char ip4[INET_ADDRSTRLEN]; char ip6[INET6_ADDRSTRLEN]; - - LOG_I(GTPU, "Created tunnel for RNTI %x, teid for DL: %d, teid for UL %d to remote IPv4: %s, IPv6 %s\n", + LOG_I(GTPU, "[%ld] Created tunnel for RNTI %x, teid for DL: %x, teid for UL %x to remote IPv4: %s, IPv6 %s\n", + instance, rnti, tmp->teid_incoming, tmp->teid_outgoing, - inet_ntop(AF_INET,(void*)&tmp->outgoing_ip_addr, ip4,INET_ADDRSTRLEN ), - inet_ntop(AF_INET6,(void*)&tmp->outgoing_ip6_addr.s6_addr, ip6, INET6_ADDRSTRLEN)); - + inet_ntop(AF_INET,(void *)&tmp->outgoing_ip_addr, ip4,INET_ADDRSTRLEN ), + inet_ntop(AF_INET6,(void *)&tmp->outgoing_ip6_addr.s6_addr, ip6, INET6_ADDRSTRLEN)); return incoming_teid; } int ocp_gtpv1u_create_s1u_tunnel(instance_t instance, const gtpv1u_enb_create_tunnel_req_t *create_tunnel_req, gtpv1u_enb_create_tunnel_resp_t *create_tunnel_resp) { - LOG_D(GTPU, "Start create tunnels for RNTI %x, num_tunnels %d, sgw_S1u_teid %x\n", + LOG_D(GTPU, "[%ld] Start create tunnels for RNTI %x, num_tunnels %d, sgw_S1u_teid %x\n", + instance, create_tunnel_req->rnti, create_tunnel_req->num_tunnels, create_tunnel_req->sgw_S1u_teid[0]); @@ -498,7 +526,8 @@ int ocp_gtpv1u_update_s1u_tunnel( const gtpv1u_enb_create_tunnel_req_t *const create_tunnel_req, const rnti_t prior_rnti ) { - LOG_D(GTPU, "Start update tunnels for old RNTI %x, new RNTI %x, num_tunnels %d, sgw_S1u_teid %x, eps_bearer_id %x\n", + LOG_D(GTPU, "[%ld] Start update tunnels for old RNTI %x, new RNTI %x, num_tunnels %d, sgw_S1u_teid %x, eps_bearer_id %x\n", + instance, prior_rnti, create_tunnel_req->rnti, create_tunnel_req->num_tunnels, @@ -508,13 +537,13 @@ int ocp_gtpv1u_update_s1u_tunnel( auto inst=&globGtp.instances[compatInst(instance)]; if ( inst->ue2te_mapping.find(create_tunnel_req->rnti) == inst->ue2te_mapping.end() ) { - LOG_E(GTPU,"Update not already existing tunnel (new rnti %x, old rnti %x)\n", 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); if ( it != inst->ue2te_mapping.end() ) { - LOG_W(GTPU,"Update a not existing tunnel, start create the new one (new rnti %x, old rnti %x)\n", create_tunnel_req->rnti, prior_rnti); + LOG_W(GTPU,"[%ld] Update a not existing tunnel, start create the new one (new rnti %x, old rnti %x)\n", instance, create_tunnel_req->rnti, prior_rnti); pthread_mutex_unlock(&globGtp.gtp_lock); gtpv1u_enb_create_tunnel_resp_t tmp; (void)ocp_gtpv1u_create_s1u_tunnel(instance, create_tunnel_req, &tmp); @@ -530,17 +559,18 @@ int ocp_gtpv1u_update_s1u_tunnel( int gtpv1u_create_ngu_tunnel( const instance_t instance, const gtpv1u_gnb_create_tunnel_req_t *const create_tunnel_req, gtpv1u_gnb_create_tunnel_resp_t *const create_tunnel_resp) { - LOG_D(GTPU, "Start create tunnels for RNTI %x, num_tunnels %d, sgw_S1u_teid %x\n", + LOG_D(GTPU, "[%ld] Start create tunnels for RNTI %x, num_tunnels %d, sgw_S1u_teid %x\n", + instance, create_tunnel_req->rnti, create_tunnel_req->num_tunnels, - create_tunnel_req->upf_NGu_teid[0]); + create_tunnel_req->outgoing_teid[0]); tcp_udp_port_t dstport=globGtp.instances[compatInst(instance)].get_dstport(); for (int i = 0; i < create_tunnel_req->num_tunnels; i++) { - teid_t teid=newGtpuCreateTunnel(compatInst(instance), create_tunnel_req->rnti, + teid_t teid=newGtpuCreateTunnel(instance, create_tunnel_req->rnti, create_tunnel_req->incoming_rb_id[i], create_tunnel_req->pdusession_id[i], - create_tunnel_req->upf_NGu_teid[i], - create_tunnel_req->upf_addr[i], dstport, + create_tunnel_req->outgoing_teid[i], + create_tunnel_req->dst_addr[i], dstport, sdap_gnb_data_req); create_tunnel_resp->status=0; create_tunnel_resp->rnti=create_tunnel_req->rnti; @@ -571,14 +601,14 @@ int ocp_gtpv1u_create_x2u_tunnel( } int newGtpuDeleteTunnel(instance_t instance, rnti_t rnti) { - LOG_D(GTPU, "Start delete tunnels for RNTI %x\n", - 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,"Delete a non existing GTP tunnel\n"); + 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; } @@ -594,7 +624,7 @@ int newGtpuDeleteTunnel(instance_t instance, rnti_t rnti) { inst->ue2te_mapping.erase(it); pthread_mutex_unlock(&globGtp.gtp_lock); - LOG_I(GTPU, "Deleted all tunnels for RNTI %d (%d tunnels deleted)\n", rnti, nb); + LOG_I(GTPU, "[%ld] Deleted all tunnels for RNTI %x (%d tunnels deleted)\n", instance, rnti, nb); return !GTPNOK; } @@ -616,9 +646,26 @@ static int Gtpv1uHandleEchoReq(int h, uint32_t msgBufLen, uint16_t peerPort, uint32_t peerIp) { - LOG_E(GTPU,"to be dev\n"); - int rc = GTPNOK; - return rc; + Gtpv1uMsgHeaderT *msgHdr = (Gtpv1uMsgHeaderT *) msgBuf; + + if ( msgHdr->version != 1 || msgHdr->PT != 1 ) { + LOG_E(GTPU, "[%d] Received a packet that is not GTP header\n", h); + return GTPNOK; + } + + if ( msgHdr->S != 1 ) { + LOG_E(GTPU, "[%d] Received a echo request packet with no sequence number \n", h); + return GTPNOK; + } + + uint16_t seq=ntohs(*(uint16_t*)(msgHdr+1)); + LOG_D(GTPU, "[%d] Received a echo request, TEID: %d, seq: %hu\n", h, msgHdr->teid, seq); + uint8_t recovery[2]={14,0}; + + return gtpv1uCreateAndSendMsg(h, peerIp, peerPort, GTP_ECHO_RSP, ntohl(msgHdr->teid), + recovery, sizeof recovery, + 1, 0, 0, seq, 0, 0); + } static int Gtpv1uHandleError(int h, @@ -626,7 +673,7 @@ static int Gtpv1uHandleError(int h, uint32_t msgBufLen, uint16_t peerPort, uint32_t peerIp) { - LOG_E(GTPU,"to be dev\n"); + LOG_E(GTPU,"Hadle error to be dev\n"); int rc = GTPNOK; return rc; } @@ -636,7 +683,7 @@ static int Gtpv1uHandleSupportedExt(int h, uint32_t msgBufLen, uint16_t peerPort, uint32_t peerIp) { - LOG_E(GTPU,"to be dev\n"); + LOG_E(GTPU,"Supported extensions to be dev\n"); int rc = GTPNOK; return rc; } @@ -652,7 +699,7 @@ static int Gtpv1uHandleEndMarker(int h, Gtpv1uMsgHeaderT *msgHdr = (Gtpv1uMsgHeaderT *) msgBuf; if ( msgHdr->version != 1 || msgHdr->PT != 1 ) { - LOG_E(GTPU, "Received a packet that is not GTP header\n"); + LOG_E(GTPU, "[%d] Received a packet that is not GTP header\n", h); return GTPNOK; } @@ -662,7 +709,7 @@ static int Gtpv1uHandleEndMarker(int h, auto tunnel=inst->te2ue_mapping.find(ntohl(msgHdr->teid)); if ( tunnel == inst->te2ue_mapping.end() ) { - LOG_E(GTPU,"Received a incoming packet on unknown teid (%x) Dropping!\n", msgHdr->teid); + LOG_E(GTPU,"[%d] Received a incoming packet on unknown teid (%x) Dropping!\n", h, msgHdr->teid); pthread_mutex_unlock(&globGtp.gtp_lock); return GTPNOK; } @@ -678,7 +725,6 @@ static int Gtpv1uHandleEndMarker(int h, ctxt.frame = 0; ctxt.subframe = 0; ctxt.eNB_index = 0; - ctxt.configured = 0; ctxt.brOption = 0; const srb_flag_t srb_flag=SRB_FLAG_NO; const rb_id_t rb_id=tunnel->second.incoming_rb_id; @@ -699,9 +745,9 @@ static int Gtpv1uHandleEndMarker(int h, mode, &sourceL2Id, &destinationL2Id) ) - LOG_E(GTPU,"down layer refused incoming packet\n"); + LOG_E(GTPU,"[%d] down layer refused incoming packet\n", h); - LOG_D(GTPU,"Received END marker packet for: teid:%x\n", ntohl(msgHdr->teid)); + LOG_D(GTPU,"[%d] Received END marker packet for: teid:%x\n", h, ntohl(msgHdr->teid)); return !GTPNOK; } @@ -713,7 +759,7 @@ static int Gtpv1uHandleGpdu(int h, Gtpv1uMsgHeaderT *msgHdr = (Gtpv1uMsgHeaderT *) msgBuf; if ( msgHdr->version != 1 || msgHdr->PT != 1 ) { - LOG_E(GTPU, "Received a packet that is not GTP header\n"); + LOG_E(GTPU, "[%d] Received a packet that is not GTP header\n", h); return GTPNOK; } @@ -723,7 +769,7 @@ static int Gtpv1uHandleGpdu(int h, auto tunnel=inst->te2ue_mapping.find(ntohl(msgHdr->teid)); if ( tunnel == inst->te2ue_mapping.end() ) { - LOG_E(GTPU,"Received a incoming packet on unknown teid (%x) Dropping!\n", msgHdr->teid); + LOG_E(GTPU,"[%d] Received a incoming packet on unknown teid (%x) Dropping!\n", h, ntohl(msgHdr->teid)); pthread_mutex_unlock(&globGtp.gtp_lock); return GTPNOK; } @@ -744,7 +790,6 @@ static int Gtpv1uHandleGpdu(int h, ctxt.frame = 0; ctxt.subframe = 0; ctxt.eNB_index = 0; - ctxt.configured = 0; ctxt.brOption = 0; const srb_flag_t srb_flag=SRB_FLAG_NO; const rb_id_t rb_id=tunnel->second.incoming_rb_id; @@ -767,9 +812,9 @@ static int Gtpv1uHandleGpdu(int h, mode, &sourceL2Id, &destinationL2Id) ) - LOG_E(GTPU,"down layer refused incoming packet\n"); + LOG_E(GTPU,"[%d] down layer refused incoming packet\n", h); - LOG_D(GTPU,"Received a %d bytes packet for: teid:%x\n", + LOG_D(GTPU,"[%d] Received a %d bytes packet for: teid:%x\n", h, msgBufLen-offset, ntohl(msgHdr->teid)); return !GTPNOK; @@ -784,14 +829,14 @@ void gtpv1uReceiver(int h) { if ((udpDataLen = recvfrom(h, udpData, sizeof(udpData), 0, (struct sockaddr *)&addr, &from_len)) < 0) { - LOG_E(GTPU, "Recvfrom failed on %d (%s)\n", h, strerror(errno)); + LOG_E(GTPU, "[%d] Recvfrom failed (%s)\n", h, strerror(errno)); return; } else if (udpDataLen == 0) { - LOG_W(GTPU, "Recvfrom returned 0\n"); + LOG_W(GTPU, "[%d] Recvfrom returned 0\n", h); return; } else { uint8_t msgType = *((uint8_t *)(udpData + 1)); - LOG_D(GTPU, "Received GTP data, msg type: %x\n", msgType); + LOG_D(GTPU, "[%d] Received GTP data, msg type: %x\n", h, msgType); switch(msgType) { case GTP_ECHO_RSP: @@ -818,7 +863,7 @@ void gtpv1uReceiver(int h) { break; default: - LOG_E(GTPU, "Received a GTP packet of unknown type: %d\n",msgType); + LOG_E(GTPU, "[%d] Received a GTP packet of unknown type: %d\n", h, msgType); break; } } @@ -850,7 +895,6 @@ void *ocp_gtpv1uTask(void *args) { case GTPV1U_GNB_TUNNEL_DATA_REQ: { gtpv1uSend2(compatInst(ITTI_MSG_DESTINATION_INSTANCE(message_p)), >PV1U_GNB_TUNNEL_DATA_REQ(message_p), false, false); - itti_free(OCP_GTPV1_U, GTPV1U_GNB_TUNNEL_DATA_REQ(message_p).buffer); } break; @@ -874,18 +918,10 @@ void *ocp_gtpv1uTask(void *args) { abort(); break; - case GTPV1U_ENB_S1_REQ: - // to be dev: should be removed, to use API - strcpy(addr.originHost, GTPV1U_ENB_S1_REQ(message_p).addrStr); - strcpy(addr.originService, GTPV1U_ENB_S1_REQ(message_p).portStr); - strcpy(addr.destinationService,addr.originService); - AssertFatal((legacyInstanceMapping=ocp_gtpv1Init(addr))!=0,"Instance 0 reserved for legacy\n"); - break; - - case GTPV1U_GNB_NG_REQ: + case GTPV1U_REQ: // to be dev: should be removed, to use API - strcpy(addr.originHost, GTPV1U_ENB_S1_REQ(message_p).addrStr); - strcpy(addr.originService, GTPV1U_ENB_S1_REQ(message_p).portStr); + strcpy(addr.originHost, GTPV1U_REQ(message_p).localAddrStr); + strcpy(addr.originService, GTPV1U_REQ(message_p).localPortStr); strcpy(addr.destinationService,addr.originService); AssertFatal((legacyInstanceMapping=ocp_gtpv1Init(addr))!=0,"Instance 0 reserved for legacy\n"); break; diff --git a/openair3/ocp-gtpu/gtp_itf.h b/openair3/ocp-gtpu/gtp_itf.h index dd406e27cddc579eca574453c96b7ce2a2abd40b..3893acf40f0416b98b153b70e9b6153d79d49b09 100644 --- a/openair3/ocp-gtpu/gtp_itf.h +++ b/openair3/ocp-gtpu/gtp_itf.h @@ -1,5 +1,6 @@ #ifndef __GTPUNEW_ITF_H__ #define __GTPUNEW_ITF_H__ + #define GTPNOK -1 # define GTPU_HEADER_OVERHEAD_MAX 64 @@ -31,7 +32,7 @@ typedef boolean_t (*gtpCallback)( const pdcp_transmission_mode_t modeP, const uint32_t *sourceL2Id, const uint32_t *destinationL2Id); - + typedef struct openAddr_s { char originHost[HOST_NAME_MAX]; char originService[HOST_NAME_MAX]; @@ -62,6 +63,7 @@ int ocp_gtpv1u_create_x2u_tunnel( // New API teid_t newGtpuCreateTunnel(instance_t instance, rnti_t rnti, int incoming_bearer_id, int outgoing_rb_id, teid_t teid, transport_layer_addr_t remoteAddr, int port, gtpCallback callBack); +void GtpuUpdateTunnelOutgoingTeid(instance_t instance, rnti_t rnti, ebi_t bearer_id, teid_t newOutgoingTeid); instance_t ocp_gtpv1Init(openAddr_t context); void *ocp_gtpv1uTask(void *args); diff --git a/targets/ARCH/COMMON/common_lib.c b/targets/ARCH/COMMON/common_lib.c index 2758d01de3f11ae06217a1a7d705194d42e96520..c4f4e3ead5905648eccfeba6ebf7fb14702285e5 100644 --- a/targets/ARCH/COMMON/common_lib.c +++ b/targets/ARCH/COMMON/common_lib.c @@ -148,7 +148,8 @@ int openair0_device_load(openair0_device *device, LOG_E(HW, "%s %d:Unsupported radio head\n", __FILE__, __LINE__); return -1; } - } + } else + AssertFatal(false, "can't open the radio device: %s\n", get_devname(device->type)); return rc; } diff --git a/targets/ARCH/rfsimulator/simulator.c b/targets/ARCH/rfsimulator/simulator.c index 13945998d754faa5f0f490099a992baaa8ee5667..013e542689a54ea0982bbde323c1154d71f5ed7b 100644 --- a/targets/ARCH/rfsimulator/simulator.c +++ b/targets/ARCH/rfsimulator/simulator.c @@ -820,7 +820,8 @@ int device_init(openair0_device *device, openair0_config_t *openair0_cfg) { AssertFatal((rfsimulator->epollfd = epoll_create1(0)) != -1,""); - //randominit(0); + // we need to call randominit() for telnet server (use gaussdouble=>uniformrand) + randominit(0); set_taus_seed(0); /* look for telnet server, if it is loaded, add the channel modeling commands to it */ add_telnetcmd_func_t addcmd = (add_telnetcmd_func_t)get_shlibmodule_fptr("telnetsrv", TELNET_ADDCMD_FNAME); diff --git a/targets/COMMON/create_tasks.c b/targets/COMMON/create_tasks.c index ffeb368e73786ac09e7aa98b81879d5d3f2d5f55..4463228dc7386d850d4af8b044966c998d270c8f 100644 --- a/targets/COMMON/create_tasks.c +++ b/targets/COMMON/create_tasks.c @@ -59,7 +59,7 @@ int create_tasks(uint32_t enb_nb) { rc = itti_create_task (TASK_RRC_ENB, rrc_enb_task, NULL); AssertFatal(rc >= 0, "Create task for RRC eNB failed\n"); - if (EPC_MODE_ENABLED && ! ( split73==SPLIT73_DU ) ) { + if (get_softmodem_params()->emulate_l1 || (EPC_MODE_ENABLED && split73 != SPLIT73_DU)) { rc = itti_create_task(TASK_SCTP, sctp_eNB_task, NULL); AssertFatal(rc >= 0, "Create task for SCTP failed\n"); } @@ -73,12 +73,13 @@ int create_tasks(uint32_t enb_nb) { } rc = itti_create_task(TASK_GTPV1_U, gtpv1u_eNB_task, NULL); AssertFatal(rc >= 0, "Create task for GTPV1U failed\n"); - if (is_x2ap_enabled()) { + } + + if (is_x2ap_enabled()) { rc = itti_create_task(TASK_X2AP, x2ap_task, NULL); AssertFatal(rc >= 0, "Create task for X2AP failed\n"); - } else { + } else { LOG_I(X2AP, "X2AP is disabled.\n"); - } } if (NODE_IS_CU(type)) { @@ -89,6 +90,9 @@ int create_tasks(uint32_t enb_nb) { if (NODE_IS_DU(type)) { rc = itti_create_task(TASK_DU_F1, F1AP_DU_task, NULL); AssertFatal(rc >= 0, "Create task for DU F1AP failed\n"); + // DU is now GTP-U instead of protobuf + rc = itti_create_task(TASK_GTPV1_U, gtpv1u_eNB_task, NULL); + AssertFatal(rc >= 0, "Create task for GTPV1U failed\n"); } if (!NODE_IS_CU(type)) { diff --git a/targets/COMMON/create_tasks_mbms.c b/targets/COMMON/create_tasks_mbms.c index 8b1736853f2c648da1b962923d7608afc171cf16..1cd3bb2f3a75747ca4adfd9a58c3cd8eba0ef370 100644 --- a/targets/COMMON/create_tasks_mbms.c +++ b/targets/COMMON/create_tasks_mbms.c @@ -51,6 +51,7 @@ int create_tasks_mbms(uint32_t enb_nb) { // LOG_D(ENB_APP, "%s(enb_nb:%d\n", __FUNCTION__, enb_nb); // ngran_node_t type = RC.rrc[0]->node_type; + AssertFatal(!get_softmodem_params()->nsa, "In NSA mode\n"); int rc; if (enb_nb == 0) return 0; diff --git a/targets/COMMON/create_tasks_ue.c b/targets/COMMON/create_tasks_ue.c index 3b9b7cf7bb324e0d93cd9c79ef8af1fd1534d7fa..9341107af9bd53bb68132e1080a6103fc5054e49 100644 --- a/targets/COMMON/create_tasks_ue.c +++ b/targets/COMMON/create_tasks_ue.c @@ -22,6 +22,7 @@ # include "intertask_interface.h" # include "create_tasks.h" # include "common/utils/LOG/log.h" +# include "executables/softmodem-common.h" #include "sctp_eNB_task.h" #include "s1ap_eNB.h" @@ -63,6 +64,15 @@ int create_tasks_ue(uint32_t ue_nb) { LOG_E(RRC, "Create task for RRC UE failed\n"); return -1; } + + if (get_softmodem_params()->nsa) { + init_connections_with_nr_ue(); + LOG_I(RRC, "Started LTE-NR link in the LTE UE\n"); + if (itti_create_task (TASK_RRC_NSA_UE, recv_msgs_from_nr_ue, NULL) < 0) { + LOG_E(RRC, "Create task for RRC NSA UE failed\n"); + return -1; + } + } } itti_wait_ready(0); diff --git a/targets/COMMON/openairinterface5g_limits.h b/targets/COMMON/openairinterface5g_limits.h index 9260fe2701ff85b02e9c16faeb36c039845afd80..d68292bd3913c79e11acf014e9a9fd87ea3682c5 100644 --- a/targets/COMMON/openairinterface5g_limits.h +++ b/targets/COMMON/openairinterface5g_limits.h @@ -28,7 +28,7 @@ # ifndef PHYSIM # ifndef UE_EXPANSION -# define NUMBER_OF_UE_MAX 4 +# define NUMBER_OF_UE_MAX 40 # define NUMBER_OF_NR_UE_MAX 4 # define NUMBER_OF_CONNECTED_eNB_MAX 1 # define NUMBER_OF_CONNECTED_gNB_MAX 1 diff --git a/targets/PROJECTS/GENERIC-LTE-EPC/CONF/benetel-5g.conf b/targets/PROJECTS/GENERIC-LTE-EPC/CONF/benetel-5g.conf index b260eaa58dca95b725de3e7eed914bf11602d6e1..575fddda2b11614a23957930f4da58f1c73f0248 100644 --- a/targets/PROJECTS/GENERIC-LTE-EPC/CONF/benetel-5g.conf +++ b/targets/PROJECTS/GENERIC-LTE-EPC/CONF/benetel-5g.conf @@ -55,15 +55,6 @@ gNBs = #pdcch-ConfigCommon initialDLBWPcontrolResourceSetZero = 0; initialDLBWPsearchSpaceZero = 0; - #pdsch-ConfigCommon - #pdschTimeDomainAllocationList (up to 16 entries) - initialDLBWPk0_0 = 0; #for DL slot - initialDLBWPmappingType_0 = 0; #0=typeA,1=typeB - initialDLBWPstartSymbolAndLength_0 = 40; #this is SS=1,L=13 - - initialDLBWPk0_1 = 0; #for mixed slot - initialDLBWPmappingType_1 = 0; - initialDLBWPstartSymbolAndLength_1 = 57; #this is SS=1,L=5 #uplinkConfigCommon #frequencyInfoUL @@ -120,19 +111,6 @@ gNBs = # restrictedSetConfig # 0=unrestricted, 1=restricted type A, 2=restricted type B restrictedSetConfig = 0, - # pusch-ConfigCommon (up to 16 elements) - initialULBWPk2_0 = 2; # used for UL slot - initialULBWPmappingType_0 = 1 - initialULBWPstartSymbolAndLength_0 = 41; # this is SS=0 L=13 - - initialULBWPk2_1 = 2; # used for mixed slot - initialULBWPmappingType_1 = 1; - initialULBWPstartSymbolAndLength_1 = 69; # this is SS=10 L=2 - - initialULBWPk2_2 = 7; # used for Msg.3 during RA - initialULBWPmappingType_2 = 1; - initialULBWPstartSymbolAndLength_2 = 52; # this is SS=10 L=4 - msg3_DeltaPreamble = 1; #p0_NominalWithGrant =-90; @@ -238,11 +216,11 @@ MACRLCs = ( ); L1s = ( - { - num_cc = 1; - tr_n_preference = "local_mac"; - pusch_proc_threads = 8; - } +{ + num_cc = 1; + tr_n_preference = "local_mac"; + thread_pool_size = 8; +} ); RUs = ( 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 0306fe5d0bf1966885c758f01ec3d59b1adcd8cd..c3faa198ddac89ec1d406ee77d623124cc7a01fb 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 @@ -54,15 +54,6 @@ gNBs = #pdcch-ConfigCommon initialDLBWPcontrolResourceSetZero = 12; initialDLBWPsearchSpaceZero = 0; - #pdsch-ConfigCommon - #pdschTimeDomainAllocationList (up to 16 entries) - initialDLBWPk0_0 = 0; #for DL slot - initialDLBWPmappingType_0 = 0; #0=typeA,1=typeB - initialDLBWPstartSymbolAndLength_0 = 40; #this is SS=1,L=13 - - initialDLBWPk0_3 = 0; #for mixed slot - initialDLBWPmappingType_3 = 0; - initialDLBWPstartSymbolAndLength_3 = 57; #this is SS=1,L=5 #uplinkConfigCommon #frequencyInfoUL @@ -117,20 +108,6 @@ gNBs = # 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 - initialULBWPstartSymbolAndLength_0 = 41; # this is SS=0 L=13 - - initialULBWPk2_1 = 6; - initialULBWPmappingType_1 = 1; - # this is SS=0 L=12 - initialULBWPstartSymbolAndLength_1 = 69; - - initialULBWPk2_2 = 4; - initialULBWPmappingType_2 = 1; - # this is SS=10 L=4 - initialULBWPstartSymbolAndLength_2 = 52; msg3_DeltaPreamble = 1; p0_NominalWithGrant =-90; @@ -233,12 +210,12 @@ MACRLCs = ( ); L1s = ( - { +{ num_cc = 1; tr_n_preference = "local_mac"; - pusch_proc_threads = 8; + thread_pool_size = 8; ofdm_offset_divisor = 8; #set this to UINT_MAX for offset 0 - } +} ); RUs = ( 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 c14ad17b421a12e60582c6d488e7c28f2d618e6b..8fa8fcf99244344760c147d6730aaa8a85f2a813 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 @@ -54,15 +54,6 @@ gNBs = #pdcch-ConfigCommon initialDLBWPcontrolResourceSetZero = 12; initialDLBWPsearchSpaceZero = 0; - #pdsch-ConfigCommon - #pdschTimeDomainAllocationList (up to 16 entries) - initialDLBWPk0_0 = 0; #for DL slot - initialDLBWPmappingType_0 = 0; #0=typeA,1=typeB - initialDLBWPstartSymbolAndLength_0 = 40; #this is SS=1,L=13 - - initialDLBWPk0_1 = 0; #for mixed slot - initialDLBWPmappingType_1 = 0; - initialDLBWPstartSymbolAndLength_1 = 57; #this is SS=1,L=5 #uplinkConfigCommon #frequencyInfoUL @@ -117,18 +108,6 @@ gNBs = # restrictedSetConfig # 0=unrestricted, 1=restricted type A, 2=restricted type B restrictedSetConfig = 0, - # pusch-ConfigCommon (up to 16 elements) - initialULBWPk2_0 = 6; # used for UL slot - initialULBWPmappingType_0 = 1 - initialULBWPstartSymbolAndLength_0 = 41; # this is SS=0 L=13 - - initialULBWPk2_1 = 6; # used for mixed slot - initialULBWPmappingType_1 = 1; - initialULBWPstartSymbolAndLength_1 = 69; # this is SS=10 L=2 - - initialULBWPk2_2 = 4; # used for Msg.3 during RA - initialULBWPmappingType_2 = 1; - initialULBWPstartSymbolAndLength_2 = 52; # this is SS=10 L=4 msg3_DeltaPreamble = 1; p0_NominalWithGrant =-90; @@ -217,12 +196,12 @@ MACRLCs = ( ); L1s = ( - { +{ num_cc = 1; tr_n_preference = "local_mac"; - pusch_proc_threads = 8; + thread_pool_size = 8; ofdm_offset_divisor = 8; #set this to UINT_MAX for offset 0 - } +} ); RUs = ( 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 ff0fdd96bb8688b0d4ff7c71cee822fb553658b5..c2e364b75edba6e139f5e378abb0c64c169a81f9 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 @@ -54,15 +54,6 @@ gNBs = #pdcch-ConfigCommon initialDLBWPcontrolResourceSetZero = 12; initialDLBWPsearchSpaceZero = 0; - #pdsch-ConfigCommon - #pdschTimeDomainAllocationList (up to 16 entries) - initialDLBWPk0_0 = 0; #for DL slot - initialDLBWPmappingType_0 = 0; #0=typeA,1=typeB - initialDLBWPstartSymbolAndLength_0 = 40; #this is SS=1,L=13 - - initialDLBWPk0_1 = 0; #for mixed slot (but is not used here) - initialDLBWPmappingType_1 = 0; - initialDLBWPstartSymbolAndLength_1 = 57; #this is SS=1,L=5 #uplinkConfigCommon #frequencyInfoUL @@ -117,19 +108,6 @@ gNBs = # restrictedSetConfig # 0=unrestricted, 1=restricted type A, 2=restricted type B restrictedSetConfig = 0, - # pusch-ConfigCommon (up to 16 elements) - initialULBWPk2_0 = 2; # used for UL slot - initialULBWPmappingType_0 = 1 - initialULBWPstartSymbolAndLength_0 = 41; # this is SS=0 L=13 - - initialULBWPk2_1 = 2; # used for mixed slot (not used here) - initialULBWPmappingType_1 = 1; - initialULBWPstartSymbolAndLength_1 = 69; # this is SS=10 L=2 - - initialULBWPk2_2 = 7; # used for Msg.3 during RA - initialULBWPmappingType_2 = 1; - initialULBWPstartSymbolAndLength_2 = 52; # this is SS=10 L=4 - msg3_DeltaPreamble = 1; p0_NominalWithGrant =-90; @@ -215,12 +193,12 @@ MACRLCs = ( ); L1s = ( - { +{ num_cc = 1; tr_n_preference = "local_mac"; - pusch_proc_threads = 8; + thread_pool_size = 8; ofdm_offset_divisor = 8; #set this to UINT_MAX for offset 0 - } +} ); RUs = ( 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 937790d4ac4ad3d0e1755a033cc7e3cf772ec2b6..813a0e58e303b6f8fb33c22e8e8f91939a05dd9a 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 @@ -54,15 +54,6 @@ gNBs = #pdcch-ConfigCommon initialDLBWPcontrolResourceSetZero = 12; initialDLBWPsearchSpaceZero = 0; - #pdsch-ConfigCommon - #pdschTimeDomainAllocationList (up to 16 entries) - initialDLBWPk0_0 = 0; #for DL slot - initialDLBWPmappingType_0 = 0; #0=typeA,1=typeB - initialDLBWPstartSymbolAndLength_0 = 40; #this is SS=1,L=13 - - initialDLBWPk0_1 = 0; #for mixed slot - initialDLBWPmappingType_1 = 0; - initialDLBWPstartSymbolAndLength_1 = 57; #this is SS=1,L=5 #uplinkConfigCommon #frequencyInfoUL @@ -117,18 +108,6 @@ gNBs = # restrictedSetConfig # 0=unrestricted, 1=restricted type A, 2=restricted type B restrictedSetConfig = 0, - # pusch-ConfigCommon (up to 16 elements) - initialULBWPk2_0 = 6; # used for UL slot - initialULBWPmappingType_0 = 1 - initialULBWPstartSymbolAndLength_0 = 41; # this is SS=0 L=13 - - initialULBWPk2_1 = 6; # used for mixed slot - initialULBWPmappingType_1 = 1; - initialULBWPstartSymbolAndLength_1 = 69; # this is SS=10 L=2 - - initialULBWPk2_2 = 4; # used for Msg.3 during RA - initialULBWPmappingType_2 = 1; - initialULBWPstartSymbolAndLength_2 = 52; # this is SS=10 L=4 msg3_DeltaPreamble = 1; p0_NominalWithGrant =-90; @@ -231,12 +210,12 @@ MACRLCs = ( ); L1s = ( - { - num_cc = 1; - tr_n_preference = "local_mac"; - pusch_proc_threads = 8; - ofdm_offset_divisor = 8; #set this to UINT_MAX for offset 0 - } +{ + 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 = ( 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 c9a95d59e86e23e0ed1a9a0057451a7c391d9ca3..d81655e5d5a8db2aa74f2102d38b6b19118d8a9a 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 @@ -54,15 +54,6 @@ gNBs = #pdcch-ConfigCommon initialDLBWPcontrolResourceSetZero = 12; initialDLBWPsearchSpaceZero = 0; - #pdsch-ConfigCommon - #pdschTimeDomainAllocationList (up to 16 entries) - initialDLBWPk0_0 = 0; #for DL slot - initialDLBWPmappingType_0 = 0; #0=typeA,1=typeB - initialDLBWPstartSymbolAndLength_0 = 40; #this is SS=1,L=13 - - initialDLBWPk0_1 = 0; #for mixed slot - initialDLBWPmappingType_1 = 0; - initialDLBWPstartSymbolAndLength_1 = 57; #this is SS=1,L=5 #uplinkConfigCommon #frequencyInfoUL @@ -118,18 +109,6 @@ gNBs = # restrictedSetConfig # 0=unrestricted, 1=restricted type A, 2=restricted type B restrictedSetConfig = 0, - # pusch-ConfigCommon (up to 16 elements) - initialULBWPk2_0 = 6; # used for UL slot - initialULBWPmappingType_0 = 1 - initialULBWPstartSymbolAndLength_0 = 41; # this is SS=0 L=13 - - initialULBWPk2_1 = 6; # used for mixed slot - initialULBWPmappingType_1 = 1; - initialULBWPstartSymbolAndLength_1 = 69; # this is SS=10 L=2 - - initialULBWPk2_2 = 7; # used for Msg.3 during RA - initialULBWPmappingType_2 = 1; - initialULBWPstartSymbolAndLength_2 = 52; # this is SS=10 L=4 msg3_DeltaPreamble = 1; p0_NominalWithGrant =-90; @@ -215,12 +194,12 @@ MACRLCs = ( ); L1s = ( - { +{ num_cc = 1; tr_n_preference = "local_mac"; - pusch_proc_threads = 8; + thread_pool_size = 8; ofdm_offset_divisor = 8; #set this to UINT_MAX for offset 0 - } +} ); RUs = ( 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 524407c4ded605c1f2438729f5cfaa00033eb090..b063989fd257f3f98ba0f2f1ecfc2ae98d9ce897 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 @@ -54,15 +54,6 @@ gNBs = #pdcch-ConfigCommon initialDLBWPcontrolResourceSetZero = 12; initialDLBWPsearchSpaceZero = 0; - #pdsch-ConfigCommon - #pdschTimeDomainAllocationList (up to 16 entries) - initialDLBWPk0_0 = 0; #for DL slot - initialDLBWPmappingType_0 = 0; #0=typeA,1=typeB - initialDLBWPstartSymbolAndLength_0 = 40; #this is SS=1,L=13 - - initialDLBWPk0_1 = 0; #for mixed slot - initialDLBWPmappingType_1 = 0; - initialDLBWPstartSymbolAndLength_1 = 57; #this is SS=1,L=5 #uplinkConfigCommon #frequencyInfoUL @@ -118,18 +109,6 @@ gNBs = # restrictedSetConfig # 0=unrestricted, 1=restricted type A, 2=restricted type B restrictedSetConfig = 0, - # pusch-ConfigCommon (up to 16 elements) - initialULBWPk2_0 = 6; # used for UL slot - initialULBWPmappingType_0 = 1 - initialULBWPstartSymbolAndLength_0 = 41; # this is SS=0 L=13 - - initialULBWPk2_1 = 6; # used for mixed slot - initialULBWPmappingType_1 = 1; - initialULBWPstartSymbolAndLength_1 = 69; # this is SS=10 L=2 - - initialULBWPk2_2 = 7; # used for Msg.3 during RA - initialULBWPmappingType_2 = 1; - initialULBWPstartSymbolAndLength_2 = 52; # this is SS=10 L=4 msg3_DeltaPreamble = 1; p0_NominalWithGrant =-90; @@ -215,12 +194,12 @@ MACRLCs = ( ); L1s = ( - { +{ num_cc = 1; tr_n_preference = "local_mac"; - pusch_proc_threads = 8; + thread_pool_size = 8; ofdm_offset_divisor = 8; #set this to UINT_MAX for offset 0 - } +} ); RUs = ( diff --git a/targets/PROJECTS/GENERIC-LTE-EPC/CONF/gnb.band78.106PRB.30kHz,usrpb2x0.conf b/targets/PROJECTS/GENERIC-LTE-EPC/CONF/gnb.band78.106PRB.30kHz,usrpb2x0.conf index d191b6798863c811c6aa78e8f0d7e78e81b3f577..a171f2aae0ee2e014c6c066c1e58c2b9565222a5 100644 --- a/targets/PROJECTS/GENERIC-LTE-EPC/CONF/gnb.band78.106PRB.30kHz,usrpb2x0.conf +++ b/targets/PROJECTS/GENERIC-LTE-EPC/CONF/gnb.band78.106PRB.30kHz,usrpb2x0.conf @@ -54,15 +54,6 @@ gNBs = #pdcch-ConfigCommon initialDLBWPcontrolResourceSetZero = 0; initialDLBWPsearchSpaceZero = 0; - #pdsch-ConfigCommon - #pdschTimeDomainAllocationList (up to 16 entries) - initialDLBWPk0_0 = 0; #for DL slot - initialDLBWPmappingType_0 = 0; #0=typeA,1=typeB - initialDLBWPstartSymbolAndLength_0 = 40; #this is SS=1,L=13 - - initialDLBWPk0_1 = 0; #for mixed slot - initialDLBWPmappingType_1 = 0; - initialDLBWPstartSymbolAndLength_1 = 57; #this is SS=1,L=5 #uplinkConfigCommon #frequencyInfoUL @@ -117,18 +108,6 @@ gNBs = # restrictedSetConfig # 0=unrestricted, 1=restricted type A, 2=restricted type B restrictedSetConfig = 0, - # pusch-ConfigCommon (up to 16 elements) - initialULBWPk2_0 = 2; # used for UL slot - initialULBWPmappingType_0 = 1 - initialULBWPstartSymbolAndLength_0 = 41; # this is SS=0 L=13 - - initialULBWPk2_1 = 2; # used for mixed slot - initialULBWPmappingType_1 = 1; - initialULBWPstartSymbolAndLength_1 = 69; # this is SS=10 L=2 - - initialULBWPk2_2 = 7; # used for Msg.3 during RA - initialULBWPmappingType_2 = 1; - initialULBWPstartSymbolAndLength_2 = 52; # this is SS=10 L=4 msg3_DeltaPreamble = 1; p0_NominalWithGrant =-90; 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 2dfa329346134000692aadc4d9bcab1181296e92..856eed4fc2c877b87d08697b404467cc60c66a55 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 @@ -54,15 +54,6 @@ gNBs = #pdcch-ConfigCommon initialDLBWPcontrolResourceSetZero = 12; initialDLBWPsearchSpaceZero = 0; - #pdsch-ConfigCommon - #pdschTimeDomainAllocationList (up to 16 entries) - initialDLBWPk0_0 = 0; #for DL slot - initialDLBWPmappingType_0 = 0; #0=typeA,1=typeB - initialDLBWPstartSymbolAndLength_0 = 40; #this is SS=1,L=13 - - initialDLBWPk0_1 = 0; #for mixed slot - initialDLBWPmappingType_1 = 0; - initialDLBWPstartSymbolAndLength_1 = 57; #this is SS=1,L=5 #uplinkConfigCommon #frequencyInfoUL @@ -117,18 +108,6 @@ gNBs = # restrictedSetConfig # 0=unrestricted, 1=restricted type A, 2=restricted type B restrictedSetConfig = 0, - # pusch-ConfigCommon (up to 16 elements) - initialULBWPk2_0 = 2; # used for UL slot - initialULBWPmappingType_0 = 1 - initialULBWPstartSymbolAndLength_0 = 41; # this is SS=0 L=13 - - initialULBWPk2_1 = 2; # used for mixed slot - initialULBWPmappingType_1 = 1; - initialULBWPstartSymbolAndLength_1 = 69; # this is SS=10 L=2 - - initialULBWPk2_2 = 7; # used for Msg.3 during RA - initialULBWPmappingType_2 = 1; - initialULBWPstartSymbolAndLength_2 = 52; # this is SS=10 L=4 msg3_DeltaPreamble = 1; p0_NominalWithGrant =-90; @@ -230,12 +209,12 @@ MACRLCs = ( ); L1s = ( - { +{ num_cc = 1; tr_n_preference = "local_mac"; - pusch_proc_threads = 8; + thread_pool_size = 8; ofdm_offset_divisor = 8; #set this to UINT_MAX for offset 0 - } +} ); RUs = ( diff --git a/targets/PROJECTS/GENERIC-LTE-EPC/CONF/gnb.band78.slave.conf b/targets/PROJECTS/GENERIC-LTE-EPC/CONF/gnb.band78.slave.conf index 7f0829e40ac4afea9589abadf725e5eb26fc1a5b..012f46401ed53b11105aaa90fc33c54e6957224d 100644 --- a/targets/PROJECTS/GENERIC-LTE-EPC/CONF/gnb.band78.slave.conf +++ b/targets/PROJECTS/GENERIC-LTE-EPC/CONF/gnb.band78.slave.conf @@ -54,15 +54,6 @@ gNBs = #pdcch-ConfigCommon initialDLBWPcontrolResourceSetZero = 12; initialDLBWPsearchSpaceZero = 0; - #pdsch-ConfigCommon - #pdschTimeDomainAllocationList (up to 16 entries) - initialDLBWPk0_0 = 0; #for DL slot - initialDLBWPmappingType_0 = 0; #0=typeA,1=typeB - initialDLBWPstartSymbolAndLength_0 = 40; #this is SS=1,L=13 - - initialDLBWPk0_1 = 0; #for mixed slot (but not used here) - initialDLBWPmappingType_1 = 0; - initialDLBWPstartSymbolAndLength_1 = 57; #this is SS=1,L=5 #uplinkConfigCommon #frequencyInfoUL @@ -117,18 +108,6 @@ gNBs = # restrictedSetConfig # 0=unrestricted, 1=restricted type A, 2=restricted type B restrictedSetConfig = 0, - # pusch-ConfigCommon (up to 16 elements) - initialULBWPk2_0 = 2; # used for UL slot - initialULBWPmappingType_0 = 1 - initialULBWPstartSymbolAndLength_0 = 41; # this is SS=0 L=13 - - initialULBWPk2_1 = 2; # used for mixed slot - initialULBWPmappingType_1 = 1; - initialULBWPstartSymbolAndLength_1 = 63; # this is SS=7 L=5 - - initialULBWPk2_2 = 7; # used for Msg.3 during RA - initialULBWPmappingType_2 = 1; - initialULBWPstartSymbolAndLength_2 = 91; # this is SS=7 L=7 msg3_DeltaPreamble = 1; p0_NominalWithGrant =-90; 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 6248afab2fe7ccb3afe17a8eb65f06ca6ee439eb..2e4dc540f3aa2b1503d37d28100dfda15e87c395 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 @@ -54,15 +54,6 @@ gNBs = #pdcch-ConfigCommon initialDLBWPcontrolResourceSetZero = 12; initialDLBWPsearchSpaceZero = 0; - #pdsch-ConfigCommon - #pdschTimeDomainAllocationList (up to 16 entries) - initialDLBWPk0_0 = 0; #for DL slot - initialDLBWPmappingType_0 = 0; #0=typeA,1=typeB - initialDLBWPstartSymbolAndLength_0 = 40; #this is SS=1,L=13 - - initialDLBWPk0_3 = 0; #for mixed slot - initialDLBWPmappingType_3 = 0; - initialDLBWPstartSymbolAndLength_3 = 57; #this is SS=1,L=5 #uplinkConfigCommon #frequencyInfoUL @@ -117,20 +108,6 @@ gNBs = # 0=unrestricted, 1=restricted type A, 2=restricted type B restrictedSetConfig = 0, - # pusch-ConfigCommon (up to 16 elements) - initialULBWPk2_0 = 6; - initialULBWPmappingType_0 = 1 - initialULBWPstartSymbolAndLength_0 = 41; - - initialULBWPk2_1 = 6; - initialULBWPmappingType_1 = 1; - # this is SS=0 L=12 - initialULBWPstartSymbolAndLength_1 = 69; - initialULBWPk2_2 = 7; - initialULBWPmappingType_2 = 1; - # this is SS=10 L=4 - initialULBWPstartSymbolAndLength_2 = 52; - msg3_DeltaPreamble = 1; p0_NominalWithGrant =-90; @@ -265,12 +242,12 @@ MACRLCs = ( ); L1s = ( - { - num_cc = 1; - tr_n_preference = "local_mac"; - pusch_proc_threads = 8; +{ + 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 = ( 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 6f28cd36c14eeab8ebedfd6e272dae789b12de49..a454af7b21ffd9d02b3658cc4106522013c95c0e 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 @@ -54,15 +54,6 @@ gNBs = #pdcch-ConfigCommon initialDLBWPcontrolResourceSetZero = 12; initialDLBWPsearchSpaceZero = 0; - #pdsch-ConfigCommon - #pdschTimeDomainAllocationList (up to 16 entries) - initialDLBWPk0_0 = 0; #for DL slot - initialDLBWPmappingType_0 = 0; #0=typeA,1=typeB - initialDLBWPstartSymbolAndLength_0 = 40; #this is SS=1,L=13 - - initialDLBWPk0_1 = 0; #for mixed slot - initialDLBWPmappingType_1 = 0; - initialDLBWPstartSymbolAndLength_1 = 57; #this is SS=1,L=5 #uplinkConfigCommon #frequencyInfoUL @@ -117,18 +108,6 @@ gNBs = # restrictedSetConfig # 0=unrestricted, 1=restricted type A, 2=restricted type B restrictedSetConfig = 0, - # pusch-ConfigCommon (up to 16 elements) - initialULBWPk2_0 = 2; # used for UL slot - initialULBWPmappingType_0 = 1 - initialULBWPstartSymbolAndLength_0 = 41; # this is SS=0 L=13 - - initialULBWPk2_1 = 2; # used for mixed slot - initialULBWPmappingType_1 = 1; - initialULBWPstartSymbolAndLength_1 = 69; # this is SS=10 L=2 - - initialULBWPk2_2 = 7; # used for Msg.3 during RA - initialULBWPmappingType_2 = 1; - initialULBWPstartSymbolAndLength_2 = 52; # this is SS=10 L=4 msg3_DeltaPreamble = 1; p0_NominalWithGrant =-90; @@ -214,12 +193,12 @@ MACRLCs = ( ); L1s = ( - { +{ num_cc = 1; tr_n_preference = "local_mac"; - pusch_proc_threads = 8; + thread_pool_size = 8; ofdm_offset_divisor = 8; #set this to UINT_MAX for offset 0 - } +} ); RUs = ( 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 30194647b89fd6c255c8acde92408ebba829b417..af26091260466439ce424de8d5ec9d0075ece7fe 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 @@ -54,15 +54,6 @@ gNBs = #pdcch-ConfigCommon initialDLBWPcontrolResourceSetZero = 0; #12; initialDLBWPsearchSpaceZero = 0; - #pdsch-ConfigCommon - #pdschTimeDomainAllocationList (up to 16 entries) - initialDLBWPk0_0 = 0; # used for (full) DL slot - initialDLBWPmappingType_0 = 0; # 0=typeA,1=typeB - initialDLBWPstartSymbolAndLength_0 = 40; # this is SS=1,L=13 - - initialDLBWPk0_1 = 0; # used for DL part mixed slot - initialDLBWPmappingType_1 = 0; - initialDLBWPstartSymbolAndLength_1 = 57; # this is SS=1,L=5 #uplinkConfigCommon #frequencyInfoUL @@ -117,19 +108,6 @@ gNBs = # 0=unrestricted, 1=restricted type A, 2=restricted type B restrictedSetConfig = 0, - # pusch-ConfigCommon (up to 16 elements) - initialULBWPk2_0 = 6; # used for (full) UL slot - initialULBWPmappingType_0 = 1 - initialULBWPstartSymbolAndLength_0 = 41; # this is SS=0 L=13 - - initialULBWPk2_1 = 6; # used for UL part mixed slot - initialULBWPmappingType_1 = 1; - initialULBWPstartSymbolAndLength_1 = 69; # this is SS=10 L=2 - - initialULBWPk2_2 = 7; # used for Msg.3 during RA - initialULBWPmappingType_2 = 1; - initialULBWPstartSymbolAndLength_2 = 52; # this is SS=10 L=4 - msg3_DeltaPreamble = 1; p0_NominalWithGrant =-90; @@ -214,12 +192,12 @@ MACRLCs = ( ); L1s = ( - { - num_cc = 1; - tr_n_preference = "local_mac"; - pusch_proc_threads = 8; +{ + 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 = ( 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 fcbd3c0f0272e830ac07e16e6f288ab1c04c0fe2..928c70113f576a1f8682ac8edabcfc7d75b3bbd9 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 @@ -54,16 +54,6 @@ gNBs = #pdcch-ConfigCommon initialDLBWPcontrolResourceSetZero = 0; initialDLBWPsearchSpaceZero = 0; - #pdsch-ConfigCommon - #pdschTimeDomainAllocationList (up to 16 entries) - initialDLBWPk0_0 = 0; #for DL slot - initialDLBWPmappingType_0 = 0; #0=typeA,1=typeB - initialDLBWPstartSymbolAndLength_0 = 40; #this is SS=1,L=13 - - initialDLBWPk0_1 = 0; #for mixed slot - initialDLBWPmappingType_1 = 0; - initialDLBWPstartSymbolAndLength_1 = 57; #this is SS=1,L=5 - #uplinkConfigCommon #frequencyInfoUL @@ -118,19 +108,6 @@ gNBs = # 0=unrestricted, 1=restricted type A, 2=restricted type B restrictedSetConfig = 0, - # pusch-ConfigCommon (up to 16 elements) - initialULBWPk2_0 = 6; # used for UL slot - initialULBWPmappingType_0 = 1 - initialULBWPstartSymbolAndLength_0 = 41; # this is SS=0 L=13 - - initialULBWPk2_1 = 6; # used for mixed slot - initialULBWPmappingType_1 = 1; - initialULBWPstartSymbolAndLength_1 = 69; # this is SS=10 L=2 - - initialULBWPk2_2 = 7; # used for Msg.3 during RA - initialULBWPmappingType_2 = 1; - initialULBWPstartSymbolAndLength_2 = 52; # this is SS=10 L=4 - msg3_DeltaPreamble = 1; p0_NominalWithGrant =-90; @@ -215,12 +192,12 @@ MACRLCs = ( ); L1s = ( - { - num_cc = 1; - tr_n_preference = "local_mac"; - pusch_proc_threads = 8; +{ + 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 = ( 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 63123b82011572d5856b00aaf151d76128f271fd..76bc5bf99231784ee30833efce4d765b381392df 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 @@ -54,15 +54,6 @@ gNBs = #pdcch-ConfigCommon initialDLBWPcontrolResourceSetZero = 0; initialDLBWPsearchSpaceZero = 0; - #pdsch-ConfigCommon - #pdschTimeDomainAllocationList (up to 16 entries) - initialDLBWPk0_0 = 0; #for DL slot - initialDLBWPmappingType_0 = 0; #0=typeA,1=typeB - initialDLBWPstartSymbolAndLength_0 = 40; #this is SS=1,L=13 - - initialDLBWPk0_1 = 0; #for mixed slot - initialDLBWPmappingType_1 = 0; - initialDLBWPstartSymbolAndLength_1 = 57; #this is SS=1,L=5 #uplinkConfigCommon #frequencyInfoUL @@ -117,18 +108,6 @@ gNBs = # restrictedSetConfig # 0=unrestricted, 1=restricted type A, 2=restricted type B restrictedSetConfig = 0, - # pusch-ConfigCommon (up to 16 elements) - initialULBWPk2_0 = 6; # used for UL slot - initialULBWPmappingType_0 = 1 - initialULBWPstartSymbolAndLength_0 = 41; # this is SS=0 L=13 - - initialULBWPk2_1 = 6; # used for mixed slot - initialULBWPmappingType_1 = 1; - initialULBWPstartSymbolAndLength_1 = 69; # this is SS=10 L=2 - - initialULBWPk2_2 = 7; # used for Msg.3 during RA - initialULBWPmappingType_2 = 1; - initialULBWPstartSymbolAndLength_2 = 52; # this is SS=10 L=4 msg3_DeltaPreamble = 1; p0_NominalWithGrant =-90; @@ -230,12 +209,12 @@ MACRLCs = ( ); L1s = ( - { - num_cc = 1; - tr_n_preference = "local_mac"; - pusch_proc_threads = 8; - ofdm_offset_divisor = 8; #set this to UINT_MAX for offset 0 - } +{ + 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 = ( 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 217ff76376a7098c57eb0831db2ab16c96a2cee7..7ff9d0ea770b8a63e9b8cc9fef2b5447fbf9344e 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 @@ -54,15 +54,6 @@ gNBs = #pdcch-ConfigCommon initialDLBWPcontrolResourceSetZero = 0; initialDLBWPsearchSpaceZero = 0; - #pdsch-ConfigCommon - #pdschTimeDomainAllocationList (up to 16 entries) - initialDLBWPk0_0 = 0; #for DL slot - initialDLBWPmappingType_0 = 0; #0=typeA,1=typeB - initialDLBWPstartSymbolAndLength_0 = 40; #this is SS=1,L=13 - - initialDLBWPk0_1 = 0; #for mixed slot - initialDLBWPmappingType_1 = 0; - initialDLBWPstartSymbolAndLength_1 = 57; #this is SS=1,L=5 #uplinkConfigCommon #frequencyInfoUL @@ -117,18 +108,6 @@ gNBs = # restrictedSetConfig # 0=unrestricted, 1=restricted type A, 2=restricted type B restrictedSetConfig = 0, - # pusch-ConfigCommon (up to 16 elements) - initialULBWPk2_0 = 2; # used for UL slot - initialULBWPmappingType_0 = 1 - initialULBWPstartSymbolAndLength_0 = 41; # this is SS=0 L=13 - - initialULBWPk2_1 = 2; # used for mixed slot - initialULBWPmappingType_1 = 1; - initialULBWPstartSymbolAndLength_1 = 69; # this is SS=10 L=2 - - initialULBWPk2_2 = 7; # used for Msg.3 during RA - initialULBWPmappingType_2 = 1; - initialULBWPstartSymbolAndLength_2 = 52; # this is SS=10 L=4 msg3_DeltaPreamble = 1; p0_NominalWithGrant =-90; @@ -214,12 +193,12 @@ MACRLCs = ( ); L1s = ( - { - num_cc = 1; - tr_n_preference = "local_mac"; - pusch_proc_threads = 8; - ofdm_offset_divisor = 8; #set this to UINT_MAX for offset 0 - } +{ + 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 = ( 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 a1acfc313bf08004ce6534f7009b937fc337a45a..5c0434b57ef4f4f30cae38986e341dc3ccd49fb4 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 @@ -54,16 +54,6 @@ gNBs = #pdcch-ConfigCommon initialDLBWPcontrolResourceSetZero = 0; initialDLBWPsearchSpaceZero = 0; - #pdsch-ConfigCommon - #pdschTimeDomainAllocationList (up to 16 entries) - initialDLBWPk0_0 = 0; #for DL slot - initialDLBWPmappingType_0 = 0; #0=typeA,1=typeB - initialDLBWPstartSymbolAndLength_0 = 40; #this is SS=1,L=13 - - initialDLBWPk0_3 = 0; #for mixed slot - initialDLBWPmappingType_3 = 0; - initialDLBWPstartSymbolAndLength_3 = 57; #this is SS=1,L=5 - #uplinkConfigCommon #frequencyInfoUL @@ -118,19 +108,6 @@ gNBs = # 0=unrestricted, 1=restricted type A, 2=restricted type B restrictedSetConfig = 0, - # pusch-ConfigCommon (up to 16 elements) - initialULBWPk2_0 = 6; - initialULBWPmappingType_0 = 1 - initialULBWPstartSymbolAndLength_0 = 41; # this is SS=0 L=13 - - initialULBWPk2_1 = 6; - initialULBWPmappingType_1 = 1; - initialULBWPstartSymbolAndLength_1 = 69; - - initialULBWPk2_2 = 7; - initialULBWPmappingType_2 = 1; - initialULBWPstartSymbolAndLength_2 = 52; - msg3_DeltaPreamble = 1; p0_NominalWithGrant =-90; @@ -215,12 +192,12 @@ MACRLCs = ( ); L1s = ( - { - num_cc = 1; - tr_n_preference = "local_mac"; - pusch_proc_threads = 8; +{ + 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 = ( 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 540dddad214eeaa9f766717b7864ce14f3098dd6..4b1476a76d8f296421467286c4e5604999086062 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 @@ -54,16 +54,6 @@ gNBs = #pdcch-ConfigCommon initialDLBWPcontrolResourceSetZero = 0; initialDLBWPsearchSpaceZero = 0; - #pdsch-ConfigCommon - #pdschTimeDomainAllocationList (up to 16 entries) - initialDLBWPk0_0 = 0; #for DL slot - initialDLBWPmappingType_0 = 0; #0=typeA,1=typeB - initialDLBWPstartSymbolAndLength_0 = 40; #this is SS=1,L=13 - - initialDLBWPk0_3 = 0; #for mixed slot - initialDLBWPmappingType_3 = 0; - initialDLBWPstartSymbolAndLength_3 = 57; #this is SS=1,L=5 - #uplinkConfigCommon #frequencyInfoUL @@ -118,19 +108,6 @@ gNBs = # 0=unrestricted, 1=restricted type A, 2=restricted type B restrictedSetConfig = 0, - # pusch-ConfigCommon (up to 16 elements) - initialULBWPk2_0 = 6; - initialULBWPmappingType_0 = 1 - initialULBWPstartSymbolAndLength_0 = 41; # this is SS=0 L=13 - - initialULBWPk2_1 = 6; - initialULBWPmappingType_1 = 1; - initialULBWPstartSymbolAndLength_1 = 69; - - initialULBWPk2_2 = 7; - initialULBWPmappingType_2 = 1; - initialULBWPstartSymbolAndLength_2 = 52; - msg3_DeltaPreamble = 1; p0_NominalWithGrant =-90; @@ -215,12 +192,12 @@ MACRLCs = ( ); L1s = ( - { - num_cc = 1; - tr_n_preference = "local_mac"; - pusch_proc_threads = 8; +{ + 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 = ( 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 edc5eaa0d47cd139c3710a09395595e58c41df15..50169f4bce955887a224d7e0186c2d1a4c750c3e 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 @@ -54,16 +54,6 @@ gNBs = #pdcch-ConfigCommon initialDLBWPcontrolResourceSetZero = 0; initialDLBWPsearchSpaceZero = 0; - #pdsch-ConfigCommon - #pdschTimeDomainAllocationList (up to 16 entries) - initialDLBWPk0_0 = 0; #for DL slot - initialDLBWPmappingType_0 = 0; #0=typeA,1=typeB - initialDLBWPstartSymbolAndLength_0 = 40; #this is SS=1,L=13 - - initialDLBWPk0_3 = 0; #for mixed slot - initialDLBWPmappingType_3 = 0; - initialDLBWPstartSymbolAndLength_3 = 57; #this is SS=1,L=5 - #uplinkConfigCommon #frequencyInfoUL @@ -118,19 +108,6 @@ gNBs = # 0=unrestricted, 1=restricted type A, 2=restricted type B restrictedSetConfig = 0, - # pusch-ConfigCommon (up to 16 elements) - initialULBWPk2_0 = 6; - initialULBWPmappingType_0 = 1 - initialULBWPstartSymbolAndLength_0 = 41; # this is SS=0 L=13 - - initialULBWPk2_1 = 6; - initialULBWPmappingType_1 = 1; - initialULBWPstartSymbolAndLength_1 = 69; - - initialULBWPk2_2 = 7; - initialULBWPmappingType_2 = 1; - initialULBWPstartSymbolAndLength_2 = 52; - msg3_DeltaPreamble = 1; p0_NominalWithGrant =-90; @@ -215,12 +192,12 @@ MACRLCs = ( ); L1s = ( - { - num_cc = 1; - tr_n_preference = "local_mac"; - pusch_proc_threads = 8; - ofdm_offset_divisor = 8; #set this to UINT_MAX for offset 0 - } +{ + 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 = ( 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 362a280ccb8cafff248a70e7f9f092f7a33047cb..e217f39b94323ae3305dccde96694d5421862b3c 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 @@ -54,15 +54,6 @@ gNBs = #pdcch-ConfigCommon initialDLBWPcontrolResourceSetZero = 0; initialDLBWPsearchSpaceZero = 0; - #pdsch-ConfigCommon - #pdschTimeDomainAllocationList (up to 16 entries) - initialDLBWPk0_0 = 0; #for DL slot - initialDLBWPmappingType_0 = 0; #0=typeA,1=typeB - initialDLBWPstartSymbolAndLength_0 = 40; #this is SS=1,L=13 - - initialDLBWPk0_1 = 0; #for mixed slot - initialDLBWPmappingType_1 = 0; - initialDLBWPstartSymbolAndLength_1 = 57; #this is SS=1,L=5 #uplinkConfigCommon #frequencyInfoUL @@ -117,18 +108,6 @@ gNBs = # restrictedSetConfig # 0=unrestricted, 1=restricted type A, 2=restricted type B restrictedSetConfig = 0, - # pusch-ConfigCommon (up to 16 elements) - initialULBWPk2_0 = 6; # used for UL slot - initialULBWPmappingType_0 = 1 - initialULBWPstartSymbolAndLength_0 = 41; # this is SS=0 L=13 - - initialULBWPk2_1 = 6; # used for mixed slot - initialULBWPmappingType_1 = 1; - initialULBWPstartSymbolAndLength_1 = 69; # this is SS=10 L=2 - - initialULBWPk2_2 = 7; # used for Msg.3 during RA - initialULBWPmappingType_2 = 1; - initialULBWPstartSymbolAndLength_2 = 52; # this is SS=10 L=4 msg3_DeltaPreamble = 1; p0_NominalWithGrant =-90; @@ -214,12 +193,12 @@ MACRLCs = ( ); L1s = ( - { - num_cc = 1; - tr_n_preference = "local_mac"; - pusch_proc_threads = 8; - ofdm_offset_divisor = 8; #set this to UINT_MAX for offset 0 - } +{ + 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 = ( 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 06ae5af06678efcde9262c118b8c5b06075efab4..0b384958ae4b2b239d2a0a5884cd073ab660fe57 100644 --- a/targets/PROJECTS/GENERIC-LTE-EPC/CONF/oaiL1.nfapi.usrpx300.conf +++ b/targets/PROJECTS/GENERIC-LTE-EPC/CONF/oaiL1.nfapi.usrpx300.conf @@ -18,18 +18,18 @@ log_config = { L1s = ( - { - num_cc = 1; - tr_n_preference = "nfapi"; - local_n_if_name = "lo"; - remote_n_address = "127.0.0.2"; // vnf addr - local_n_address = "127.0.0.1"; // pnf addr - local_n_portc = 50000; // pnf p5 port [!] - remote_n_portc = 50001; // vnf p5 port - local_n_portd = 50010; // pnf p7 port - remote_n_portd = 50011; // vnf p7 port - pusch_proc_threads = 8; - } +{ + num_cc = 1; + tr_n_preference = "nfapi"; + local_n_if_name = "lo"; + remote_n_address = "127.0.0.2"; // vnf addr + local_n_address = "127.0.0.1"; // pnf addr + local_n_portc = 50000; // pnf p5 port [!] + 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; +} ); RUs = ( diff --git a/targets/PROJECTS/GENERIC-LTE-EPC/CONF/rcc.band78.tm1.106PRB.nfapi.conf b/targets/PROJECTS/GENERIC-LTE-EPC/CONF/rcc.band78.tm1.106PRB.nfapi.conf index e541607559c555b15cd1b05452ab8d1a1e30d3a0..1583e07ca1179d2b828acac83ea28f5d343108c2 100644 --- a/targets/PROJECTS/GENERIC-LTE-EPC/CONF/rcc.band78.tm1.106PRB.nfapi.conf +++ b/targets/PROJECTS/GENERIC-LTE-EPC/CONF/rcc.band78.tm1.106PRB.nfapi.conf @@ -54,29 +54,6 @@ gNBs = #pdcch-ConfigCommon initialDLBWPcontrolResourceSetZero = 12; 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=2,L=12 - initialDLBWPstartSymbolAndLength_1 = 53; - - initialDLBWPk0_2 = 0; - initialDLBWPmappingType_2 = 0; - #this is SS=1,L=12 - initialDLBWPstartSymbolAndLength_2 = 54; - - initialDLBWPk0_3 = 0; - initialDLBWPmappingType_3 = 0; - #this is SS=1,L=5 - initialDLBWPstartSymbolAndLength_3 = 57; #uplinkConfigCommon #frequencyInfoUL @@ -131,22 +108,6 @@ gNBs = # 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=0 L=11 - initialULBWPstartSymbolAndLength_0 = 55; - - initialULBWPk2_1 = 6; - initialULBWPmappingType_1 = 1; - # this is SS=0 L=12 - initialULBWPstartSymbolAndLength_1 = 69; - - initialULBWPk2_2 = 7; - initialULBWPmappingType_2 = 1; - # this is SS=10 L=4 - initialULBWPstartSymbolAndLength_2 = 52; - msg3_DeltaPreamble = 1; p0_NominalWithGrant =-90; diff --git a/targets/PROJECTS/GENERIC-LTE-EPC/CONF/testing_gnb.conf b/targets/PROJECTS/GENERIC-LTE-EPC/CONF/testing_gnb.conf index b1c78bc97824cfa1de1f54fa6ca2894c057934e0..5591ed082dcecc81b959d44502fd5c5cab00acfa 100644 --- a/targets/PROJECTS/GENERIC-LTE-EPC/CONF/testing_gnb.conf +++ b/targets/PROJECTS/GENERIC-LTE-EPC/CONF/testing_gnb.conf @@ -54,15 +54,6 @@ gNBs = #pdcch-ConfigCommon initialDLBWPcontrolResourceSetZero = 0; initialDLBWPsearchSpaceZero = 0; - #pdsch-ConfigCommon - #pdschTimeDomainAllocationList (up to 16 entries) - initialDLBWPk0_0 = 0; #for DL slot - initialDLBWPmappingType_0 = 0; #0=typeA,1=typeB - initialDLBWPstartSymbolAndLength_0 = 40; #this is SS=1,L=13 - - initialDLBWPk0_1 = 0; #for mixed slot - initialDLBWPmappingType_1 = 0; - initialDLBWPstartSymbolAndLength_1 = 57; #this is SS=1,L=5 #uplinkConfigCommon #frequencyInfoUL @@ -117,18 +108,6 @@ gNBs = # restrictedSetConfig # 0=unrestricted, 1=restricted type A, 2=restricted type B restrictedSetConfig = 0, - # pusch-ConfigCommon (up to 16 elements) - initialULBWPk2_0 = 2; # used for UL slot - initialULBWPmappingType_0 = 1 - initialULBWPstartSymbolAndLength_0 = 41; # this is SS=0 L=13 - - initialULBWPk2_1 = 2; # used for mixed slot - initialULBWPmappingType_1 = 1; - initialULBWPstartSymbolAndLength_1 = 24; # this is SS=10 L=2 - - initialULBWPk2_2 = 7; # used for Msg.3 during RA - initialULBWPmappingType_2 = 1; - initialULBWPstartSymbolAndLength_2 = 52; # this is SS=10 L=4 msg3_DeltaPreamble = 1; p0_NominalWithGrant =-90; @@ -231,12 +210,12 @@ MACRLCs = ( ); L1s = ( - { - num_cc = 1; - tr_n_preference = "local_mac"; - pusch_proc_threads = 8; +{ + 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 = ( 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 96f29090318a2b0ed254f4fc82cda8f96550ce81..dd8113e059020007251e9c152c2b2ee4cd2dc61d 100644 --- a/targets/PROJECTS/GENERIC-LTE-EPC/CONF/testing_gnb_24PRB.conf +++ b/targets/PROJECTS/GENERIC-LTE-EPC/CONF/testing_gnb_24PRB.conf @@ -55,28 +55,7 @@ gNBs = initialDLBWPcontrolResourceSetZero = 0; 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=2,L=12 - initialDLBWPstartSymbolAndLength_1 = 53; - - initialDLBWPk0_2 = 0; - initialDLBWPmappingType_2 = 0; - #this is SS=1,L=12 - initialDLBWPstartSymbolAndLength_2 = 54; - - initialDLBWPk0_3 = 0; - initialDLBWPmappingType_3 = 0; - #this is SS=1,L=4 //5 (4 is for 43, 5 is for 57) - initialDLBWPstartSymbolAndLength_3 = 57; //43; //57; + #uplinkConfigCommon #frequencyInfoUL ul_frequencyBand = 78; @@ -130,21 +109,6 @@ gNBs = # restrictedSetConfig # 0=unrestricted, 1=restricted type A, 2=restricted type B restrictedSetConfig = 0, - # pusch-ConfigCommon (up to 16 elements) - initialULBWPk2_0 = 2; - initialULBWPmappingType_0 = 1 - # this is SS=0 L=13 - initialULBWPstartSymbolAndLength_0 = 41; - - initialULBWPk2_1 = 2; - initialULBWPmappingType_1 = 1; - # this is SS=0 L=11 - initialULBWPstartSymbolAndLength_1 = 69; - - initialULBWPk2_2 = 7; - initialULBWPmappingType_2 = 1; - # this is SS=10 L=4 - initialULBWPstartSymbolAndLength_2 = 52; msg3_DeltaPreamble = 1; p0_NominalWithGrant =-90; @@ -247,12 +211,12 @@ MACRLCs = ( ); L1s = ( - { - num_cc = 1; - tr_n_preference = "local_mac"; - pusch_proc_threads = 8; +{ + 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 = ( diff --git a/targets/PROJECTS/GENERIC-LTE-EPC/CONF/testing_gnb_n310.conf b/targets/PROJECTS/GENERIC-LTE-EPC/CONF/testing_gnb_n310.conf index f51f59ae30b187f24a7d86466b03d2972c38acfb..198ad8471ccbf29c2275dd1c688204caa21f0063 100644 --- a/targets/PROJECTS/GENERIC-LTE-EPC/CONF/testing_gnb_n310.conf +++ b/targets/PROJECTS/GENERIC-LTE-EPC/CONF/testing_gnb_n310.conf @@ -54,15 +54,6 @@ gNBs = #pdcch-ConfigCommon initialDLBWPcontrolResourceSetZero = 0; initialDLBWPsearchSpaceZero = 0; - #pdsch-ConfigCommon - #pdschTimeDomainAllocationList (up to 16 entries) - initialDLBWPk0_0 = 0; #for DL slot - initialDLBWPmappingType_0 = 0; #0=typeA,1=typeB - initialDLBWPstartSymbolAndLength_0 = 40; #this is SS=1,L=13 - - initialDLBWPk0_1 = 0; #for mixed slot - initialDLBWPmappingType_1 = 0; - initialDLBWPstartSymbolAndLength_1 = 57; #this is SS=1,L=5 #uplinkConfigCommon #frequencyInfoUL @@ -117,18 +108,6 @@ gNBs = # restrictedSetConfig # 0=unrestricted, 1=restricted type A, 2=restricted type B restrictedSetConfig = 0, - # pusch-ConfigCommon (up to 16 elements) - initialULBWPk2_0 = 2; # used for UL slot - initialULBWPmappingType_0 = 1 - initialULBWPstartSymbolAndLength_0 = 41; # this is SS=0 L=13 - - initialULBWPk2_1 = 2; # used for mixed slot - initialULBWPmappingType_1 = 1; - initialULBWPstartSymbolAndLength_1 = 24; # this is SS=10 L=2 - - initialULBWPk2_2 = 7; # used for Msg.3 during RA - initialULBWPmappingType_2 = 1; - initialULBWPstartSymbolAndLength_2 = 52; # this is SS=10 L=4 msg3_DeltaPreamble = 1; p0_NominalWithGrant =-90; 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 59e507ed3e08b9dcda42713fe132efa896b29eea..96335f23caf5f2a0ea673476487de6ac3bee4e1b 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 @@ -56,15 +56,6 @@ gNBs = #pdcch-ConfigCommon initialDLBWPcontrolResourceSetZero = 0; initialDLBWPsearchSpaceZero = 0; - #pdsch-ConfigCommon - #pdschTimeDomainAllocationList (up to 16 entries) - initialDLBWPk0_0 = 0; #for DL slot - initialDLBWPmappingType_0 = 0; #0=typeA,1=typeB - initialDLBWPstartSymbolAndLength_0 = 40; #this is SS=1,L=13 - - initialDLBWPk0_1 = 0; #for mixed slot - initialDLBWPmappingType_1 = 0; - initialDLBWPstartSymbolAndLength_1 = 57; #this is SS=1,L=5 #uplinkConfigCommon #frequencyInfoUL @@ -119,18 +110,6 @@ gNBs = # restrictedSetConfig # 0=unrestricted, 1=restricted type A, 2=restricted type B restrictedSetConfig = 0, - # pusch-ConfigCommon (up to 16 elements) - initialULBWPk2_0 = 2; # used for UL slot - initialULBWPmappingType_0 = 1 - initialULBWPstartSymbolAndLength_0 = 41; # this is SS=0 L=13 - - initialULBWPk2_1 = 2; # used for mixed slot - initialULBWPmappingType_1 = 1; - initialULBWPstartSymbolAndLength_1 = 24; # this is SS=10 L=2 - - initialULBWPk2_2 = 7; # used for Msg.3 during RA - initialULBWPmappingType_2 = 1; - initialULBWPstartSymbolAndLength_2 = 52; # this is SS=10 L=4 msg3_DeltaPreamble = 1; p0_NominalWithGrant =-90; @@ -231,11 +210,11 @@ MACRLCs = ( ); L1s = ( - { - num_cc = 1; - tr_n_preference = "local_mac"; - pusch_proc_threads = 8; - } +{ + num_cc = 1; + tr_n_preference = "local_mac"; + thread_pool_size = 8; +} ); RUs = ( diff --git a/targets/PROJECTS/GENERIC-NR-5GC/CONF/du_gnb.conf b/targets/PROJECTS/GENERIC-NR-5GC/CONF/du_gnb.conf index 05e441d39641ae823e5f9a3703a8b8be7452e260..215a57b95c5ab25322d3bc5808049db6b0af233d 100644 --- a/targets/PROJECTS/GENERIC-NR-5GC/CONF/du_gnb.conf +++ b/targets/PROJECTS/GENERIC-NR-5GC/CONF/du_gnb.conf @@ -79,31 +79,9 @@ gNBs = # 0=kHz15, 1=kHz30, 2=kHz60, 3=kHz120 initialDLBWPsubcarrierSpacing = 1; #pdcch-ConfigCommon - initialDLBWPcontrolResourceSetZero = 12; + 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 = 53; - - initialDLBWPk0_1 = 0; - initialDLBWPmappingType_1 = 0; - #this is SS=2,L=12 - initialDLBWPstartSymbolAndLength_1 = 81; - - initialDLBWPk0_2 = 0; - initialDLBWPmappingType_2 = 0; - #this is SS=1,L=12 - initialDLBWPstartSymbolAndLength_2 = 54; - - initialDLBWPk0_3 = 0; - initialDLBWPmappingType_3 = 0; - #this is SS=1,L=5 - initialDLBWPstartSymbolAndLength_3 = 57; + #uplinkConfigCommon #frequencyInfoUL @@ -158,21 +136,6 @@ gNBs = # 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=12 - initialULBWPstartSymbolAndLength_0 = 53; - - initialULBWPk2_1 = 6; - initialULBWPmappingType_1 = 1; - # this is SS=0 L=12 - initialULBWPstartSymbolAndLength_1 = 69; - - initialULBWPk2_2 = 7; - initialULBWPmappingType_2 = 1; - # this is SS=10 L=4 - initialULBWPstartSymbolAndLength_2 = 52; msg3_DeltaPreamble = 1; p0_NominalWithGrant =-90; @@ -247,11 +210,11 @@ MACRLCs = ( ); L1s = ( - { - num_cc = 1; - tr_n_preference = "local_mac"; - pusch_proc_threads = 2; - } +{ + num_cc = 1; + tr_n_preference = "local_mac"; + thread_pool_size = 8; +} ); RUs = ( 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 3bd884b602a81f637ad384ee07f6f6c8cf47d53b..ab4713f8b5693914c0455e33b96b4b67492f76c2 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 @@ -69,29 +69,6 @@ gNBs = #pdcch-ConfigCommon initialDLBWPcontrolResourceSetZero = 12; 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=2,L=12 - initialDLBWPstartSymbolAndLength_1 = 53; - - initialDLBWPk0_2 = 0; - initialDLBWPmappingType_2 = 0; - #this is SS=1,L=12 - initialDLBWPstartSymbolAndLength_2 = 54; - - initialDLBWPk0_3 = 0; - initialDLBWPmappingType_3 = 0; - #this is SS=1,L=5 - initialDLBWPstartSymbolAndLength_3 = 57; #uplinkConfigCommon #frequencyInfoUL @@ -146,21 +123,6 @@ gNBs = # 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=0 L=11 - initialULBWPstartSymbolAndLength_0 = 55; - - initialULBWPk2_1 = 6; - initialULBWPmappingType_1 = 1; - # this is SS=0 L=12 - initialULBWPstartSymbolAndLength_1 = 69; - - initialULBWPk2_2 = 7; - initialULBWPmappingType_2 = 1; - # this is SS=10 L=4 - initialULBWPstartSymbolAndLength_2 = 52; msg3_DeltaPreamble = 1; p0_NominalWithGrant =-90; 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 a975b02154775b51d9f58c7fcd2d4d131f768563..b77ad0b264297e0bcf95b63bbf6e4ed3dcdd9553 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 @@ -35,7 +35,9 @@ gNBs = ssb_SubcarrierOffset = 0; pdsch_AntennaPorts = 1; pusch_AntennaPorts = 1; + min_rxtxtime = 6; sib1_tda = 0; + do_SRS = 1; pdcch_ConfigSIB1 = ( { @@ -66,22 +68,13 @@ gNBs = #initialDownlinkBWP #genericParameters # this is RBstart=27,L=48 (275*(L-1))+RBstart - initialDLBWPlocationAndBandwidth = 12952; # 6366 12925 12956 28875 12952 + initialDLBWPlocationAndBandwidth = 28875; # 6366 12925 12956 28875 12952 # subcarrierSpacing # 0=kHz15, 1=kHz30, 2=kHz60, 3=kHz120 initialDLBWPsubcarrierSpacing = 1; #pdcch-ConfigCommon initialDLBWPcontrolResourceSetZero = 12; initialDLBWPsearchSpaceZero = 0; - #pdsch-ConfigCommon - #pdschTimeDomainAllocationList (up to 16 entries) - initialDLBWPk0_0 = 0; #for DL slot - initialDLBWPmappingType_0 = 0; #0=typeA,1=typeB - initialDLBWPstartSymbolAndLength_0 = 40; #this is SS=1,L=13 - - initialDLBWPk0_1 = 0; #for mixed slot - initialDLBWPmappingType_1 = 0; - initialDLBWPstartSymbolAndLength_1 = 57; #this is SS=1,L=5 #uplinkConfigCommon #frequencyInfoUL @@ -95,7 +88,7 @@ gNBs = pMax = 20; #initialUplinkBWP #genericParameters - initialULBWPlocationAndBandwidth = 12952; + initialULBWPlocationAndBandwidth = 28875; # subcarrierSpacing # 0=kHz15, 1=kHz30, 2=kHz60, 3=kHz120 initialULBWPsubcarrierSpacing = 1; @@ -136,19 +129,6 @@ gNBs = # 0=unrestricted, 1=restricted type A, 2=restricted type B restrictedSetConfig = 0, - # pusch-ConfigCommon (up to 16 elements) - initialULBWPk2_0 = 6; # used for UL slot - initialULBWPmappingType_0 = 1 - initialULBWPstartSymbolAndLength_0 = 41; # this is SS=0 L=13 - - initialULBWPk2_1 = 6; # used for mixed slot - initialULBWPmappingType_1 = 1; - initialULBWPstartSymbolAndLength_1 = 52; # this is SS=10 L=4 - - initialULBWPk2_2 = 7; # used for Msg.3 during RA - initialULBWPmappingType_2 = 1; - initialULBWPstartSymbolAndLength_2 = 52; # this is SS=10 L=4 - msg3_DeltaPreamble = 1; p0_NominalWithGrant =-90; @@ -240,7 +220,6 @@ L1s = ( { num_cc = 1; tr_n_preference = "local_mac"; - pusch_proc_threads = 8; prach_dtx_threshold = 120; pucch0_dtx_threshold = 150; ofdm_offset_divisor = 8; #set this to UINT_MAX for offset 0 @@ -318,5 +297,7 @@ log_config : rrc_log_verbosity ="medium"; ngap_log_level ="debug"; ngap_log_verbosity ="medium"; + f1ap_log_level ="debug"; + f1ap_log_verbosity ="medium"; }; 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 a24139025cbd3d191a628d375757bae7003fc5a6..27a1b6ad62c0258eeb0e5a9dd2a639db9dba3941 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 @@ -35,6 +35,8 @@ gNBs = ssb_SubcarrierOffset = 0; pdsch_AntennaPorts = 1; pusch_AntennaPorts = 2; + sib1_tda = 0; + do_SRS = 1; ul_prbblacklist = "51,52,53,54" pdcch_ConfigSIB1 = ( @@ -73,15 +75,6 @@ gNBs = #pdcch-ConfigCommon initialDLBWPcontrolResourceSetZero = 11; initialDLBWPsearchSpaceZero = 0; - #pdsch-ConfigCommon - #pdschTimeDomainAllocationList (up to 16 entries) - initialDLBWPk0_0 = 0; #for DL slot - initialDLBWPmappingType_0 = 0; #0=typeA,1=typeB - initialDLBWPstartSymbolAndLength_0 = 40; #this is SS=1,L=13 - - initialDLBWPk0_1 = 0; #for mixed slot - initialDLBWPmappingType_1 = 0; - initialDLBWPstartSymbolAndLength_1 = 57; #this is SS=1,L=5 #uplinkConfigCommon #frequencyInfoUL @@ -136,19 +129,6 @@ gNBs = # 0=unrestricted, 1=restricted type A, 2=restricted type B restrictedSetConfig = 0, - # pusch-ConfigCommon (up to 16 elements) - initialULBWPk2_0 = 2; # used for UL slot - initialULBWPmappingType_0 = 1 - initialULBWPstartSymbolAndLength_0 = 41; # this is SS=0 L=13 - - initialULBWPk2_1 = 2; # used for mixed slot - initialULBWPmappingType_1 = 1; - initialULBWPstartSymbolAndLength_1 = 52; # this is SS=10 L=4 - - initialULBWPk2_2 = 7; # used for Msg.3 during RA - initialULBWPmappingType_2 = 1; - initialULBWPstartSymbolAndLength_2 = 52; # this is SS=10 L=4 - msg3_DeltaPreamble = 1; p0_NominalWithGrant =-90; @@ -240,7 +220,6 @@ L1s = ( { num_cc = 1; tr_n_preference = "local_mac"; - pusch_proc_threads = 4; prach_dtx_threshold = 120; #pucch0_dtx_threshold = 120; } 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 6e51487b83cd674b96afea5abb6f1213470a227b..e96c545a4e54838862762eb29d2534c6c0465607 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 @@ -35,7 +35,9 @@ gNBs = ssb_SubcarrierOffset = 0; pdsch_AntennaPorts = 1; pusch_AntennaPorts = 1; + min_rxtxtime = 6; sib1_tda = 0; + do_SRS = 1; pdcch_ConfigSIB1 = ( { @@ -73,15 +75,6 @@ gNBs = #pdcch-ConfigCommon initialDLBWPcontrolResourceSetZero = 12; initialDLBWPsearchSpaceZero = 0; - #pdsch-ConfigCommon - #pdschTimeDomainAllocationList (up to 16 entries) - initialDLBWPk0_0 = 0; #for DL slot - initialDLBWPmappingType_0 = 0; #0=typeA,1=typeB - initialDLBWPstartSymbolAndLength_0 = 40; #this is SS=1,L=13 - - initialDLBWPk0_1 = 0; #for mixed slot - initialDLBWPmappingType_1 = 0; - initialDLBWPstartSymbolAndLength_1 = 57; #this is SS=1,L=5 #uplinkConfigCommon #frequencyInfoUL @@ -136,19 +129,6 @@ gNBs = # 0=unrestricted, 1=restricted type A, 2=restricted type B restrictedSetConfig = 0, - # pusch-ConfigCommon (up to 16 elements) - initialULBWPk2_0 = 6; # used for UL slot - initialULBWPmappingType_0 = 1 - initialULBWPstartSymbolAndLength_0 = 41; # this is SS=0 L=13 - - initialULBWPk2_1 = 6; # used for mixed slot - initialULBWPmappingType_1 = 1; - initialULBWPstartSymbolAndLength_1 = 52; # this is SS=10 L=4 - - initialULBWPk2_2 = 7; # used for Msg.3 during RA - initialULBWPmappingType_2 = 1; - initialULBWPstartSymbolAndLength_2 = 52; # this is SS=10 L=4 - msg3_DeltaPreamble = 1; p0_NominalWithGrant =-90; @@ -240,7 +220,6 @@ L1s = ( { num_cc = 1; tr_n_preference = "local_mac"; - pusch_proc_threads = 8; prach_dtx_threshold = 120; pucch0_dtx_threshold = 150; ofdm_offset_divisor = 8; #set this to UINT_MAX for offset 0 @@ -318,5 +297,7 @@ log_config : rrc_log_verbosity ="medium"; ngap_log_level ="debug"; ngap_log_verbosity ="medium"; + f1ap_log_level ="debug"; + f1ap_log_verbosity ="medium"; }; 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 a0d25053b60f1c784a92449bb33eca6998867880..c8a0bace37b79f7bd99f1d2cacebfe5e265a6777 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 @@ -70,29 +70,6 @@ gNBs = #pdcch-ConfigCommon initialDLBWPcontrolResourceSetZero = 12; 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=2,L=12 - initialDLBWPstartSymbolAndLength_1 = 53; - - initialDLBWPk0_2 = 0; - initialDLBWPmappingType_2 = 0; - #this is SS=1,L=12 - initialDLBWPstartSymbolAndLength_2 = 54; - - initialDLBWPk0_3 = 0; - initialDLBWPmappingType_3 = 0; - #this is SS=1,L=5 - initialDLBWPstartSymbolAndLength_3 = 57; #uplinkConfigCommon #frequencyInfoUL @@ -147,22 +124,6 @@ gNBs = # 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=0 L=11 - initialULBWPstartSymbolAndLength_0 = 55; - - initialULBWPk2_1 = 6; - initialULBWPmappingType_1 = 1; - # this is SS=0 L=12 - initialULBWPstartSymbolAndLength_1 = 69; - - initialULBWPk2_2 = 7; - initialULBWPmappingType_2 = 1; - # this is SS=10 L=4 - initialULBWPstartSymbolAndLength_2 = 52; - msg3_DeltaPreamble = 1; p0_NominalWithGrant =-90; @@ -264,11 +225,11 @@ MACRLCs = ( ); L1s = ( - { - num_cc = 1; - tr_n_preference = "local_mac"; - pusch_proc_threads = 8; - } +{ + num_cc = 1; + tr_n_preference = "local_mac"; + thread_pool_size = 8; +} ); RUs = ( 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 new file mode 100644 index 0000000000000000000000000000000000000000..befceae6952fb739cbe4c47032f23ce8c92fbb37 --- /dev/null +++ b/targets/PROJECTS/GENERIC-NR-5GC/CONF/gnb.sa.band78.fr1.162PRB.2x2.usrpn300.conf @@ -0,0 +1,330 @@ +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; + sd = 0x1; // 0 false, else true + }, + { + sst = 1; + sd = 0x112233; // 0 false, else true + } + ); + + }); + + nr_cellid = 12345678L; + + ////////// Physical parameters: + + ssb_SubcarrierOffset = 0; + pdsch_AntennaPorts = 1; + pusch_AntennaPorts = 2; +# do_CSIRS = 1; + min_rxtxtime_pdsch = 2; + ul_prbblacklist = "79,80,81,82" + pdcch_ConfigSIB1 = ( + { + controlResourceSetZero = 11; + searchSpaceZero = 10; + } + ); + + servingCellConfigCommon = ( + { + #spCellConfigCommon + + physCellId = 0; + +# downlinkConfigCommon + #frequencyInfoDL + # this is 3300.60 MHz + 81*12*30e-3 MHz = 3329.76 + absoluteFrequencySSB = 621984; + # this is 3300.60 MHz + dl_absoluteFrequencyPointA = 620040; + #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=162 (275*(275-L+1))+(274-RBstart)) + initialDLBWPlocationAndBandwidth = 31899; + # +# subcarrierSpacing +# 0=kHz15, 1=kHz30, 2=kHz60, 3=kHz120 + initialDLBWPsubcarrierSpacing = 1; + #pdcch-ConfigCommon + initialDLBWPcontrolResourceSetZero = 11; + initialDLBWPsearchSpaceZero = 10; + #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 = 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, + + # pusch-ConfigCommon (up to 16 elements) + initialULBWPk2_0 = 2; + initialULBWPmappingType_0 = 1 + # this is SS=2 L=13 + initialULBWPstartSymbolAndLength_0 = 41; + + initialULBWPk2_1 = 2; + 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 = -70; +# 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 = 0; +} +); + +L1s = ( +{ + num_cc = 1; + tr_n_preference = "local_mac"; + prach_dtx_threshold = 120; + pucch0_dtx_threshold = 120; +} +); + +RUs = ( +{ + local_rf = "yes" + nb_tx = 2 + nb_rx = 2 + att_tx = 0 + att_rx = 0; + bands = [78]; + max_pdschReferenceSignalPower = -27; + max_rxgain = 75; + sf_extension = 0; + 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"; + 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"; + ngap_log_level ="debug"; + ngap_log_verbosity ="medium"; + f1ap_log_level ="debug"; + f1ap_log_verbosity ="medium"; +}; diff --git a/targets/PROJECTS/GENERIC-NR-5GC/CONF/uecap.xml b/targets/PROJECTS/GENERIC-NR-5GC/CONF/uecap.xml new file mode 100644 index 0000000000000000000000000000000000000000..baca6649cbf10848fd327d49b926a8f6ba11d3ab --- /dev/null +++ b/targets/PROJECTS/GENERIC-NR-5GC/CONF/uecap.xml @@ -0,0 +1,862 @@ +<UE-NR-Capability> + <accessStratumRelease><rel15/></accessStratumRelease> + <pdcp-Parameters> + <supportedROHC-Profiles> + <profile0x0000><false/></profile0x0000> + <profile0x0001><false/></profile0x0001> + <profile0x0002><false/></profile0x0002> + <profile0x0003><false/></profile0x0003> + <profile0x0004><false/></profile0x0004> + <profile0x0006><false/></profile0x0006> + <profile0x0101><false/></profile0x0101> + <profile0x0102><false/></profile0x0102> + <profile0x0103><false/></profile0x0103> + <profile0x0104><false/></profile0x0104> + </supportedROHC-Profiles> + <maxNumberROHC-ContextSessions><cs2/></maxNumberROHC-ContextSessions> + <shortSN><supported/></shortSN> + </pdcp-Parameters> + <rlc-Parameters> + <am-WithShortSN><supported/></am-WithShortSN> + <um-WithShortSN><supported/></um-WithShortSN> + <um-WithLongSN><supported/></um-WithLongSN> + </rlc-Parameters> + <mac-Parameters> + <mac-ParametersXDD-Diff> + <logicalChannelSR-DelayTimer><supported/></logicalChannelSR-DelayTimer> + <longDRX-Cycle><supported/></longDRX-Cycle> + <shortDRX-Cycle><supported/></shortDRX-Cycle> + <multipleSR-Configurations><supported/></multipleSR-Configurations> + </mac-ParametersXDD-Diff> + </mac-Parameters> + <phy-Parameters> + <phy-ParametersCommon> + <nzp-CSI-RS-IntefMgmt><supported/></nzp-CSI-RS-IntefMgmt> + <dynamicHARQ-ACK-Codebook><supported/></dynamicHARQ-ACK-Codebook> + <semiStaticHARQ-ACK-Codebook><supported/></semiStaticHARQ-ACK-Codebook> + <pdsch-MappingTypeA><supported/></pdsch-MappingTypeA> + <rateMatchingResrcSetSemi-Static><supported/></rateMatchingResrcSetSemi-Static> + <ext2> + <maxLayersMIMO-Indication><supported/></maxLayersMIMO-Indication> + </ext2> + </phy-ParametersCommon> + <phy-ParametersFRX-Diff> + <twoFL-DMRS> + 11 + </twoFL-DMRS> + <supportedDMRS-TypeDL><type1/></supportedDMRS-TypeDL> + <supportedDMRS-TypeUL><type1And2/></supportedDMRS-TypeUL> + <onePortsPTRS> + 01 + </onePortsPTRS> + <pucch-F2-WithFH><supported/></pucch-F2-WithFH> + <pucch-F3-WithFH><supported/></pucch-F3-WithFH> + <absoluteTPC-Command><supported/></absoluteTPC-Command> + <pusch-HalfPi-BPSK><supported/></pusch-HalfPi-BPSK> + <pucch-F3-4-HalfPi-BPSK><supported/></pucch-F3-4-HalfPi-BPSK> + <ext1> + <csi-RS-IM-ReceptionForFeedback> + <maxConfigNumberNZP-CSI-RS-PerCC>8</maxConfigNumberNZP-CSI-RS-PerCC> + <maxConfigNumberPortsAcrossNZP-CSI-RS-PerCC>64</maxConfigNumberPortsAcrossNZP-CSI-RS-PerCC> + <maxConfigNumberCSI-IM-PerCC><n8/></maxConfigNumberCSI-IM-PerCC> + <maxNumberSimultaneousNZP-CSI-RS-PerCC>4</maxNumberSimultaneousNZP-CSI-RS-PerCC> + <totalNumberPortsSimultaneousNZP-CSI-RS-PerCC>32</totalNumberPortsSimultaneousNZP-CSI-RS-PerCC> + </csi-RS-IM-ReceptionForFeedback> + <csi-ReportFramework> + <maxNumberPeriodicCSI-PerBWP-ForCSI-Report>2</maxNumberPeriodicCSI-PerBWP-ForCSI-Report> + <maxNumberAperiodicCSI-PerBWP-ForCSI-Report>2</maxNumberAperiodicCSI-PerBWP-ForCSI-Report> + <maxNumberSemiPersistentCSI-PerBWP-ForCSI-Report>0</maxNumberSemiPersistentCSI-PerBWP-ForCSI-Report> + <maxNumberPeriodicCSI-PerBWP-ForBeamReport>2</maxNumberPeriodicCSI-PerBWP-ForBeamReport> + <maxNumberAperiodicCSI-PerBWP-ForBeamReport>2</maxNumberAperiodicCSI-PerBWP-ForBeamReport> + <maxNumberAperiodicCSI-triggeringStatePerCC><n63/></maxNumberAperiodicCSI-triggeringStatePerCC> + <maxNumberSemiPersistentCSI-PerBWP-ForBeamReport>0</maxNumberSemiPersistentCSI-PerBWP-ForBeamReport> + <simultaneousCSI-ReportsPerCC>4</simultaneousCSI-ReportsPerCC> + </csi-ReportFramework> + <mux-SR-HARQ-ACK-CSI-PUCCH-OncePerSlot> + <sameSymbol><supported/></sameSymbol> + </mux-SR-HARQ-ACK-CSI-PUCCH-OncePerSlot> + <oneFL-DMRS-TwoAdditionalDMRS-UL><supported/></oneFL-DMRS-TwoAdditionalDMRS-UL> + <twoFL-DMRS-TwoAdditionalDMRS-UL><supported/></twoFL-DMRS-TwoAdditionalDMRS-UL> + </ext1> + </phy-ParametersFRX-Diff> + <phy-ParametersFR1> + <pdsch-256QAM-FR1><supported/></pdsch-256QAM-FR1> + <pdsch-RE-MappingFR1-PerSymbol><n10/></pdsch-RE-MappingFR1-PerSymbol> + <ext1> + <pdsch-RE-MappingFR1-PerSlot><n32/></pdsch-RE-MappingFR1-PerSlot> + </ext1> + </phy-ParametersFR1> + </phy-Parameters> + <rf-Parameters> + <supportedBandListNR> + <BandNR> + <bandNR>78</bandNR> + <mimo-ParametersPerBand> + <tci-StatePDSCH> + <maxNumberConfiguredTCIstatesPerCC><n16/></maxNumberConfiguredTCIstatesPerCC> + <maxNumberActiveTCI-PerBWP><n1/></maxNumberActiveTCI-PerBWP> + </tci-StatePDSCH> + <pusch-TransCoherence><nonCoherent/></pusch-TransCoherence> + <periodicBeamReport><supported/></periodicBeamReport> + <aperiodicBeamReport><supported/></aperiodicBeamReport> + <maxNumberNonGroupBeamReporting><n4/></maxNumberNonGroupBeamReporting> + <maxNumberSSB-BFD>2</maxNumberSSB-BFD> + <maxNumberCSI-RS-SSB-CBD>8</maxNumberCSI-RS-SSB-CBD> + <beamReportTiming> + <scs-15kHz><sym8/></scs-15kHz> + <scs-30kHz><sym14/></scs-30kHz> + </beamReportTiming> + <ext1> + <beamManagementSSB-CSI-RS> + <maxNumberSSB-CSI-RS-ResourceOneTx><n8/></maxNumberSSB-CSI-RS-ResourceOneTx> + <maxNumberCSI-RS-Resource><n32/></maxNumberCSI-RS-Resource> + <maxNumberCSI-RS-ResourceTwoTx><n8/></maxNumberCSI-RS-ResourceTwoTx> + <supportedCSI-RS-Density><oneAndThree/></supportedCSI-RS-Density> + <maxNumberAperiodicCSI-RS-Resource><n32/></maxNumberAperiodicCSI-RS-Resource> + </beamManagementSSB-CSI-RS> + <codebookParameters> + <type1> + <singlePanel> + <supportedCSI-RS-ResourceList> + <SupportedCSI-RS-Resource> + <maxNumberTxPortsPerResource><p8/></maxNumberTxPortsPerResource> + <maxNumberResourcesPerBand>8</maxNumberResourcesPerBand> + <totalNumberTxPortsPerBand>64</totalNumberTxPortsPerBand> + </SupportedCSI-RS-Resource> + <SupportedCSI-RS-Resource> + <maxNumberTxPortsPerResource><p4/></maxNumberTxPortsPerResource> + <maxNumberResourcesPerBand>8</maxNumberResourcesPerBand> + <totalNumberTxPortsPerBand>32</totalNumberTxPortsPerBand> + </SupportedCSI-RS-Resource> + <SupportedCSI-RS-Resource> + <maxNumberTxPortsPerResource><p16/></maxNumberTxPortsPerResource> + <maxNumberResourcesPerBand>4</maxNumberResourcesPerBand> + <totalNumberTxPortsPerBand>64</totalNumberTxPortsPerBand> + </SupportedCSI-RS-Resource> + <SupportedCSI-RS-Resource> + <maxNumberTxPortsPerResource><p32/></maxNumberTxPortsPerResource> + <maxNumberResourcesPerBand>2</maxNumberResourcesPerBand> + <totalNumberTxPortsPerBand>64</totalNumberTxPortsPerBand> + </SupportedCSI-RS-Resource> + </supportedCSI-RS-ResourceList> + <modes><mode1/></modes> + <maxNumberCSI-RS-PerResourceSet>4</maxNumberCSI-RS-PerResourceSet> + </singlePanel> + </type1> + </codebookParameters> + <csi-RS-IM-ReceptionForFeedback> + <maxConfigNumberNZP-CSI-RS-PerCC>8</maxConfigNumberNZP-CSI-RS-PerCC> + <maxConfigNumberPortsAcrossNZP-CSI-RS-PerCC>64</maxConfigNumberPortsAcrossNZP-CSI-RS-PerCC> + <maxConfigNumberCSI-IM-PerCC><n8/></maxConfigNumberCSI-IM-PerCC> + <maxNumberSimultaneousNZP-CSI-RS-PerCC>4</maxNumberSimultaneousNZP-CSI-RS-PerCC> + <totalNumberPortsSimultaneousNZP-CSI-RS-PerCC>32</totalNumberPortsSimultaneousNZP-CSI-RS-PerCC> + </csi-RS-IM-ReceptionForFeedback> + <csi-ReportFramework> + <maxNumberPeriodicCSI-PerBWP-ForCSI-Report>2</maxNumberPeriodicCSI-PerBWP-ForCSI-Report> + <maxNumberAperiodicCSI-PerBWP-ForCSI-Report>2</maxNumberAperiodicCSI-PerBWP-ForCSI-Report> + <maxNumberSemiPersistentCSI-PerBWP-ForCSI-Report>0</maxNumberSemiPersistentCSI-PerBWP-ForCSI-Report> + <maxNumberPeriodicCSI-PerBWP-ForBeamReport>2</maxNumberPeriodicCSI-PerBWP-ForBeamReport> + <maxNumberAperiodicCSI-PerBWP-ForBeamReport>2</maxNumberAperiodicCSI-PerBWP-ForBeamReport> + <maxNumberAperiodicCSI-triggeringStatePerCC><n63/></maxNumberAperiodicCSI-triggeringStatePerCC> + <maxNumberSemiPersistentCSI-PerBWP-ForBeamReport>0</maxNumberSemiPersistentCSI-PerBWP-ForBeamReport> + <simultaneousCSI-ReportsPerCC>4</simultaneousCSI-ReportsPerCC> + </csi-ReportFramework> + <csi-RS-ForTracking> + <maxBurstLength>2</maxBurstLength> + <maxSimultaneousResourceSetsPerCC>1</maxSimultaneousResourceSetsPerCC> + <maxConfiguredResourceSetsPerCC>8</maxConfiguredResourceSetsPerCC> + <maxConfiguredResourceSetsAllCC>16</maxConfiguredResourceSetsAllCC> + </csi-RS-ForTracking> + </ext1> + </mimo-ParametersPerBand> + <multipleTCI><supported/></multipleTCI> + <pusch-256QAM><supported/></pusch-256QAM> + <ue-PowerClass><pc2/></ue-PowerClass> + <channelBWs-DL> + <fr1> + <scs-15kHz> + 0000000000 + </scs-15kHz> + <scs-30kHz> + 0001011111 + </scs-30kHz> + <scs-60kHz> + 0000000000 + </scs-60kHz> + </fr1> + </channelBWs-DL> + <channelBWs-UL> + <fr1> + <scs-15kHz> + 0000000000 + </scs-15kHz> + <scs-30kHz> + 0001011111 + </scs-30kHz> + <scs-60kHz> + 0000000000 + </scs-60kHz> + </fr1> + </channelBWs-UL> + <ext1> + <maxUplinkDutyCycle-PC2-FR1><n100/></maxUplinkDutyCycle-PC2-FR1> + </ext1> + <ext4> + <channelBWs-DL-v1590> + <fr1> + <scs-30kHz> + 1000000000000000 + </scs-30kHz> + </fr1> + </channelBWs-DL-v1590> + <channelBWs-UL-v1590> + <fr1> + <scs-30kHz> + 1000000000000000 + </scs-30kHz> + </fr1> + </channelBWs-UL-v1590> + </ext4> + </BandNR> + </supportedBandListNR> + <supportedBandCombinationList> + <BandCombination> + <bandList> + <nr> + <bandNR>78</bandNR> + <ca-BandwidthClassDL-NR><a/></ca-BandwidthClassDL-NR> + <ca-BandwidthClassUL-NR><a/></ca-BandwidthClassUL-NR> + </nr> + </bandList> + <featureSetCombination>0</featureSetCombination> + <powerClass-v1530><pc2/></powerClass-v1530> + </BandCombination> + </supportedBandCombinationList> + <appliedFreqBandListFilter> + <bandInformationNR> + <bandNR>78</bandNR> + </bandInformationNR> + </appliedFreqBandListFilter> + <ext1> + <supportedBandCombinationList-v1540> + <BandCombination-v1540> + <bandList-v1540> + <BandParameters-v1540> + <srs-TxSwitch> + <supportedSRS-TxPortSwitch><t2r4/></supportedSRS-TxPortSwitch> + </srs-TxSwitch> + </BandParameters-v1540> + </bandList-v1540> + <ca-ParametersNR-v1540> + <csi-RS-IM-ReceptionForFeedbackPerBandComb> + <maxNumberSimultaneousNZP-CSI-RS-ActBWP-AllCC>8</maxNumberSimultaneousNZP-CSI-RS-ActBWP-AllCC> + <totalNumberPortsSimultaneousNZP-CSI-RS-ActBWP-AllCC>64</totalNumberPortsSimultaneousNZP-CSI-RS-ActBWP-AllCC> + </csi-RS-IM-ReceptionForFeedbackPerBandComb> + <simultaneousCSI-ReportsAllCC>8</simultaneousCSI-ReportsAllCC> + </ca-ParametersNR-v1540> + </BandCombination-v1540> + </supportedBandCombinationList-v1540> + </ext1> + </rf-Parameters> + <measAndMobParameters> + <measAndMobParametersCommon> + <ssb-RLM><supported/></ssb-RLM> + <ext1> + <eventB-MeasAndReport><supported/></eventB-MeasAndReport> + <handoverFDD-TDD><supported/></handoverFDD-TDD> + </ext1> + <ext2> + <periodicEUTRA-MeasAndReport><supported/></periodicEUTRA-MeasAndReport> + </ext2> + </measAndMobParametersCommon> + <measAndMobParametersXDD-Diff> + <intraAndInterF-MeasAndReport><supported/></intraAndInterF-MeasAndReport> + <eventA-MeasAndReport><supported/></eventA-MeasAndReport> + <ext1> + <handoverInterF><supported/></handoverInterF> + <handoverLTE-EPC><supported/></handoverLTE-EPC> + </ext1> + </measAndMobParametersXDD-Diff> + <measAndMobParametersFRX-Diff> + <ss-SINR-Meas><supported/></ss-SINR-Meas> + <ext1> + <handoverInterF><supported/></handoverInterF> + <handoverLTE-EPC><supported/></handoverLTE-EPC> + </ext1> + <ext3> + <simultaneousRxDataSSB-DiffNumerology><supported/></simultaneousRxDataSSB-DiffNumerology> + </ext3> + </measAndMobParametersFRX-Diff> + </measAndMobParameters> + <featureSets> + <featureSetsDownlink> + <FeatureSetDownlink> + <featureSetListPerDownlinkCC> + <FeatureSetDownlinkPerCC-Id>1</FeatureSetDownlinkPerCC-Id> + </featureSetListPerDownlinkCC> + <ue-SpecificUL-DL-Assignment><supported/></ue-SpecificUL-DL-Assignment> + </FeatureSetDownlink> + <FeatureSetDownlink> + <featureSetListPerDownlinkCC> + <FeatureSetDownlinkPerCC-Id>2</FeatureSetDownlinkPerCC-Id> + </featureSetListPerDownlinkCC> + <ue-SpecificUL-DL-Assignment><supported/></ue-SpecificUL-DL-Assignment> + </FeatureSetDownlink> + <FeatureSetDownlink> + <featureSetListPerDownlinkCC> + <FeatureSetDownlinkPerCC-Id>3</FeatureSetDownlinkPerCC-Id> + </featureSetListPerDownlinkCC> + <ue-SpecificUL-DL-Assignment><supported/></ue-SpecificUL-DL-Assignment> + </FeatureSetDownlink> + <FeatureSetDownlink> + <featureSetListPerDownlinkCC> + <FeatureSetDownlinkPerCC-Id>4</FeatureSetDownlinkPerCC-Id> + </featureSetListPerDownlinkCC> + <ue-SpecificUL-DL-Assignment><supported/></ue-SpecificUL-DL-Assignment> + </FeatureSetDownlink> + <FeatureSetDownlink> + <featureSetListPerDownlinkCC> + <FeatureSetDownlinkPerCC-Id>5</FeatureSetDownlinkPerCC-Id> + </featureSetListPerDownlinkCC> + <ue-SpecificUL-DL-Assignment><supported/></ue-SpecificUL-DL-Assignment> + </FeatureSetDownlink> + <FeatureSetDownlink> + <featureSetListPerDownlinkCC> + <FeatureSetDownlinkPerCC-Id>6</FeatureSetDownlinkPerCC-Id> + </featureSetListPerDownlinkCC> + <ue-SpecificUL-DL-Assignment><supported/></ue-SpecificUL-DL-Assignment> + </FeatureSetDownlink> + <FeatureSetDownlink> + <featureSetListPerDownlinkCC> + <FeatureSetDownlinkPerCC-Id>7</FeatureSetDownlinkPerCC-Id> + </featureSetListPerDownlinkCC> + <ue-SpecificUL-DL-Assignment><supported/></ue-SpecificUL-DL-Assignment> + </FeatureSetDownlink> + <FeatureSetDownlink> + <featureSetListPerDownlinkCC> + <FeatureSetDownlinkPerCC-Id>8</FeatureSetDownlinkPerCC-Id> + </featureSetListPerDownlinkCC> + <ue-SpecificUL-DL-Assignment><supported/></ue-SpecificUL-DL-Assignment> + </FeatureSetDownlink> + <FeatureSetDownlink> + <featureSetListPerDownlinkCC> + <FeatureSetDownlinkPerCC-Id>9</FeatureSetDownlinkPerCC-Id> + </featureSetListPerDownlinkCC> + <ue-SpecificUL-DL-Assignment><supported/></ue-SpecificUL-DL-Assignment> + </FeatureSetDownlink> + <FeatureSetDownlink> + <featureSetListPerDownlinkCC> + <FeatureSetDownlinkPerCC-Id>10</FeatureSetDownlinkPerCC-Id> + </featureSetListPerDownlinkCC> + <ue-SpecificUL-DL-Assignment><supported/></ue-SpecificUL-DL-Assignment> + </FeatureSetDownlink> + <FeatureSetDownlink> + <featureSetListPerDownlinkCC> + <FeatureSetDownlinkPerCC-Id>11</FeatureSetDownlinkPerCC-Id> + </featureSetListPerDownlinkCC> + <ue-SpecificUL-DL-Assignment><supported/></ue-SpecificUL-DL-Assignment> + </FeatureSetDownlink> + <FeatureSetDownlink> + <featureSetListPerDownlinkCC> + <FeatureSetDownlinkPerCC-Id>12</FeatureSetDownlinkPerCC-Id> + </featureSetListPerDownlinkCC> + <ue-SpecificUL-DL-Assignment><supported/></ue-SpecificUL-DL-Assignment> + </FeatureSetDownlink> + </featureSetsDownlink> + <featureSetsDownlinkPerCC> + <FeatureSetDownlinkPerCC> + <supportedSubcarrierSpacingDL><kHz30/></supportedSubcarrierSpacingDL> + <supportedBandwidthDL> + <fr1><mhz100/></fr1> + </supportedBandwidthDL> + <maxNumberMIMO-LayersPDSCH><fourLayers/></maxNumberMIMO-LayersPDSCH> + <supportedModulationOrderDL><qam256/></supportedModulationOrderDL> + </FeatureSetDownlinkPerCC> + <FeatureSetDownlinkPerCC> + <supportedSubcarrierSpacingDL><kHz30/></supportedSubcarrierSpacingDL> + <supportedBandwidthDL> + <fr1><mhz100/></fr1> + </supportedBandwidthDL> + <channelBW-90mhz><supported/></channelBW-90mhz> + <maxNumberMIMO-LayersPDSCH><fourLayers/></maxNumberMIMO-LayersPDSCH> + <supportedModulationOrderDL><qam256/></supportedModulationOrderDL> + </FeatureSetDownlinkPerCC> + <FeatureSetDownlinkPerCC> + <supportedSubcarrierSpacingDL><kHz15/></supportedSubcarrierSpacingDL> + <supportedBandwidthDL> + <fr1><mhz20/></fr1> + </supportedBandwidthDL> + <maxNumberMIMO-LayersPDSCH><twoLayers/></maxNumberMIMO-LayersPDSCH> + <supportedModulationOrderDL><qam256/></supportedModulationOrderDL> + </FeatureSetDownlinkPerCC> + <FeatureSetDownlinkPerCC> + <supportedSubcarrierSpacingDL><kHz15/></supportedSubcarrierSpacingDL> + <supportedBandwidthDL> + <fr1><mhz40/></fr1> + </supportedBandwidthDL> + <maxNumberMIMO-LayersPDSCH><fourLayers/></maxNumberMIMO-LayersPDSCH> + <supportedModulationOrderDL><qam256/></supportedModulationOrderDL> + </FeatureSetDownlinkPerCC> + <FeatureSetDownlinkPerCC> + <supportedSubcarrierSpacingDL><kHz30/></supportedSubcarrierSpacingDL> + <supportedBandwidthDL> + <fr1><mhz40/></fr1> + </supportedBandwidthDL> + <maxNumberMIMO-LayersPDSCH><fourLayers/></maxNumberMIMO-LayersPDSCH> + <supportedModulationOrderDL><qam256/></supportedModulationOrderDL> + </FeatureSetDownlinkPerCC> + <FeatureSetDownlinkPerCC> + <supportedSubcarrierSpacingDL><kHz30/></supportedSubcarrierSpacingDL> + <supportedBandwidthDL> + <fr1><mhz80/></fr1> + </supportedBandwidthDL> + <maxNumberMIMO-LayersPDSCH><fourLayers/></maxNumberMIMO-LayersPDSCH> + <supportedModulationOrderDL><qam256/></supportedModulationOrderDL> + </FeatureSetDownlinkPerCC> + <FeatureSetDownlinkPerCC> + <supportedSubcarrierSpacingDL><kHz30/></supportedSubcarrierSpacingDL> + <supportedBandwidthDL> + <fr1><mhz20/></fr1> + </supportedBandwidthDL> + <maxNumberMIMO-LayersPDSCH><fourLayers/></maxNumberMIMO-LayersPDSCH> + <supportedModulationOrderDL><qam256/></supportedModulationOrderDL> + </FeatureSetDownlinkPerCC> + <FeatureSetDownlinkPerCC> + <supportedSubcarrierSpacingDL><kHz15/></supportedSubcarrierSpacingDL> + <supportedBandwidthDL> + <fr1><mhz30/></fr1> + </supportedBandwidthDL> + <maxNumberMIMO-LayersPDSCH><twoLayers/></maxNumberMIMO-LayersPDSCH> + <supportedModulationOrderDL><qam256/></supportedModulationOrderDL> + </FeatureSetDownlinkPerCC> + <FeatureSetDownlinkPerCC> + <supportedSubcarrierSpacingDL><kHz15/></supportedSubcarrierSpacingDL> + <supportedBandwidthDL> + <fr1><mhz20/></fr1> + </supportedBandwidthDL> + <maxNumberMIMO-LayersPDSCH><fourLayers/></maxNumberMIMO-LayersPDSCH> + <supportedModulationOrderDL><qam256/></supportedModulationOrderDL> + </FeatureSetDownlinkPerCC> + <FeatureSetDownlinkPerCC> + <supportedSubcarrierSpacingDL><kHz15/></supportedSubcarrierSpacingDL> + <supportedBandwidthDL> + <fr1><mhz15/></fr1> + </supportedBandwidthDL> + <maxNumberMIMO-LayersPDSCH><twoLayers/></maxNumberMIMO-LayersPDSCH> + <supportedModulationOrderDL><qam256/></supportedModulationOrderDL> + </FeatureSetDownlinkPerCC> + <FeatureSetDownlinkPerCC> + <supportedSubcarrierSpacingDL><kHz15/></supportedSubcarrierSpacingDL> + <supportedBandwidthDL> + <fr1><mhz30/></fr1> + </supportedBandwidthDL> + <maxNumberMIMO-LayersPDSCH><fourLayers/></maxNumberMIMO-LayersPDSCH> + <supportedModulationOrderDL><qam256/></supportedModulationOrderDL> + </FeatureSetDownlinkPerCC> + <FeatureSetDownlinkPerCC> + <supportedSubcarrierSpacingDL><kHz30/></supportedSubcarrierSpacingDL> + <supportedBandwidthDL> + <fr1><mhz60/></fr1> + </supportedBandwidthDL> + <maxNumberMIMO-LayersPDSCH><fourLayers/></maxNumberMIMO-LayersPDSCH> + <supportedModulationOrderDL><qam256/></supportedModulationOrderDL> + </FeatureSetDownlinkPerCC> + </featureSetsDownlinkPerCC> + <featureSetsUplink> + <FeatureSetUplink> + <featureSetListPerUplinkCC> + <FeatureSetUplinkPerCC-Id>1</FeatureSetUplinkPerCC-Id> + </featureSetListPerUplinkCC> + <supportedSRS-Resources> + <maxNumberAperiodicSRS-PerBWP><n16/></maxNumberAperiodicSRS-PerBWP> + <maxNumberAperiodicSRS-PerBWP-PerSlot>6</maxNumberAperiodicSRS-PerBWP-PerSlot> + <maxNumberPeriodicSRS-PerBWP><n16/></maxNumberPeriodicSRS-PerBWP> + <maxNumberPeriodicSRS-PerBWP-PerSlot>6</maxNumberPeriodicSRS-PerBWP-PerSlot> + <maxNumberSemiPersistentSRS-PerBWP><n2/></maxNumberSemiPersistentSRS-PerBWP> + <maxNumberSemiPersistentSRS-PerBWP-PerSlot>2</maxNumberSemiPersistentSRS-PerBWP-PerSlot> + <maxNumberSRS-Ports-PerResource><n2/></maxNumberSRS-Ports-PerResource> + </supportedSRS-Resources> + </FeatureSetUplink> + <FeatureSetUplink> + <featureSetListPerUplinkCC> + <FeatureSetUplinkPerCC-Id>2</FeatureSetUplinkPerCC-Id> + </featureSetListPerUplinkCC> + <supportedSRS-Resources> + <maxNumberAperiodicSRS-PerBWP><n16/></maxNumberAperiodicSRS-PerBWP> + <maxNumberAperiodicSRS-PerBWP-PerSlot>6</maxNumberAperiodicSRS-PerBWP-PerSlot> + <maxNumberPeriodicSRS-PerBWP><n16/></maxNumberPeriodicSRS-PerBWP> + <maxNumberPeriodicSRS-PerBWP-PerSlot>6</maxNumberPeriodicSRS-PerBWP-PerSlot> + <maxNumberSemiPersistentSRS-PerBWP><n2/></maxNumberSemiPersistentSRS-PerBWP> + <maxNumberSemiPersistentSRS-PerBWP-PerSlot>2</maxNumberSemiPersistentSRS-PerBWP-PerSlot> + <maxNumberSRS-Ports-PerResource><n2/></maxNumberSRS-Ports-PerResource> + </supportedSRS-Resources> + </FeatureSetUplink> + <FeatureSetUplink> + <featureSetListPerUplinkCC> + <FeatureSetUplinkPerCC-Id>3</FeatureSetUplinkPerCC-Id> + </featureSetListPerUplinkCC> + <supportedSRS-Resources> + <maxNumberAperiodicSRS-PerBWP><n16/></maxNumberAperiodicSRS-PerBWP> + <maxNumberAperiodicSRS-PerBWP-PerSlot>6</maxNumberAperiodicSRS-PerBWP-PerSlot> + <maxNumberPeriodicSRS-PerBWP><n16/></maxNumberPeriodicSRS-PerBWP> + <maxNumberPeriodicSRS-PerBWP-PerSlot>6</maxNumberPeriodicSRS-PerBWP-PerSlot> + <maxNumberSemiPersistentSRS-PerBWP><n2/></maxNumberSemiPersistentSRS-PerBWP> + <maxNumberSemiPersistentSRS-PerBWP-PerSlot>2</maxNumberSemiPersistentSRS-PerBWP-PerSlot> + <maxNumberSRS-Ports-PerResource><n1/></maxNumberSRS-Ports-PerResource> + </supportedSRS-Resources> + </FeatureSetUplink> + <FeatureSetUplink> + <featureSetListPerUplinkCC> + <FeatureSetUplinkPerCC-Id>4</FeatureSetUplinkPerCC-Id> + </featureSetListPerUplinkCC> + <supportedSRS-Resources> + <maxNumberAperiodicSRS-PerBWP><n16/></maxNumberAperiodicSRS-PerBWP> + <maxNumberAperiodicSRS-PerBWP-PerSlot>6</maxNumberAperiodicSRS-PerBWP-PerSlot> + <maxNumberPeriodicSRS-PerBWP><n16/></maxNumberPeriodicSRS-PerBWP> + <maxNumberPeriodicSRS-PerBWP-PerSlot>6</maxNumberPeriodicSRS-PerBWP-PerSlot> + <maxNumberSemiPersistentSRS-PerBWP><n2/></maxNumberSemiPersistentSRS-PerBWP> + <maxNumberSemiPersistentSRS-PerBWP-PerSlot>2</maxNumberSemiPersistentSRS-PerBWP-PerSlot> + <maxNumberSRS-Ports-PerResource><n1/></maxNumberSRS-Ports-PerResource> + </supportedSRS-Resources> + </FeatureSetUplink> + <FeatureSetUplink> + <featureSetListPerUplinkCC> + <FeatureSetUplinkPerCC-Id>5</FeatureSetUplinkPerCC-Id> + </featureSetListPerUplinkCC> + <supportedSRS-Resources> + <maxNumberAperiodicSRS-PerBWP><n16/></maxNumberAperiodicSRS-PerBWP> + <maxNumberAperiodicSRS-PerBWP-PerSlot>6</maxNumberAperiodicSRS-PerBWP-PerSlot> + <maxNumberPeriodicSRS-PerBWP><n16/></maxNumberPeriodicSRS-PerBWP> + <maxNumberPeriodicSRS-PerBWP-PerSlot>6</maxNumberPeriodicSRS-PerBWP-PerSlot> + <maxNumberSemiPersistentSRS-PerBWP><n2/></maxNumberSemiPersistentSRS-PerBWP> + <maxNumberSemiPersistentSRS-PerBWP-PerSlot>2</maxNumberSemiPersistentSRS-PerBWP-PerSlot> + <maxNumberSRS-Ports-PerResource><n1/></maxNumberSRS-Ports-PerResource> + </supportedSRS-Resources> + </FeatureSetUplink> + <FeatureSetUplink> + <featureSetListPerUplinkCC> + <FeatureSetUplinkPerCC-Id>6</FeatureSetUplinkPerCC-Id> + </featureSetListPerUplinkCC> + <supportedSRS-Resources> + <maxNumberAperiodicSRS-PerBWP><n16/></maxNumberAperiodicSRS-PerBWP> + <maxNumberAperiodicSRS-PerBWP-PerSlot>6</maxNumberAperiodicSRS-PerBWP-PerSlot> + <maxNumberPeriodicSRS-PerBWP><n16/></maxNumberPeriodicSRS-PerBWP> + <maxNumberPeriodicSRS-PerBWP-PerSlot>6</maxNumberPeriodicSRS-PerBWP-PerSlot> + <maxNumberSemiPersistentSRS-PerBWP><n2/></maxNumberSemiPersistentSRS-PerBWP> + <maxNumberSemiPersistentSRS-PerBWP-PerSlot>2</maxNumberSemiPersistentSRS-PerBWP-PerSlot> + <maxNumberSRS-Ports-PerResource><n1/></maxNumberSRS-Ports-PerResource> + </supportedSRS-Resources> + </FeatureSetUplink> + <FeatureSetUplink> + <featureSetListPerUplinkCC> + <FeatureSetUplinkPerCC-Id>7</FeatureSetUplinkPerCC-Id> + </featureSetListPerUplinkCC> + <supportedSRS-Resources> + <maxNumberAperiodicSRS-PerBWP><n16/></maxNumberAperiodicSRS-PerBWP> + <maxNumberAperiodicSRS-PerBWP-PerSlot>6</maxNumberAperiodicSRS-PerBWP-PerSlot> + <maxNumberPeriodicSRS-PerBWP><n16/></maxNumberPeriodicSRS-PerBWP> + <maxNumberPeriodicSRS-PerBWP-PerSlot>6</maxNumberPeriodicSRS-PerBWP-PerSlot> + <maxNumberSemiPersistentSRS-PerBWP><n2/></maxNumberSemiPersistentSRS-PerBWP> + <maxNumberSemiPersistentSRS-PerBWP-PerSlot>2</maxNumberSemiPersistentSRS-PerBWP-PerSlot> + <maxNumberSRS-Ports-PerResource><n1/></maxNumberSRS-Ports-PerResource> + </supportedSRS-Resources> + </FeatureSetUplink> + <FeatureSetUplink> + <featureSetListPerUplinkCC> + <FeatureSetUplinkPerCC-Id>8</FeatureSetUplinkPerCC-Id> + </featureSetListPerUplinkCC> + <supportedSRS-Resources> + <maxNumberAperiodicSRS-PerBWP><n16/></maxNumberAperiodicSRS-PerBWP> + <maxNumberAperiodicSRS-PerBWP-PerSlot>6</maxNumberAperiodicSRS-PerBWP-PerSlot> + <maxNumberPeriodicSRS-PerBWP><n16/></maxNumberPeriodicSRS-PerBWP> + <maxNumberPeriodicSRS-PerBWP-PerSlot>6</maxNumberPeriodicSRS-PerBWP-PerSlot> + <maxNumberSemiPersistentSRS-PerBWP><n2/></maxNumberSemiPersistentSRS-PerBWP> + <maxNumberSemiPersistentSRS-PerBWP-PerSlot>2</maxNumberSemiPersistentSRS-PerBWP-PerSlot> + <maxNumberSRS-Ports-PerResource><n1/></maxNumberSRS-Ports-PerResource> + </supportedSRS-Resources> + </FeatureSetUplink> + <FeatureSetUplink> + <featureSetListPerUplinkCC> + <FeatureSetUplinkPerCC-Id>9</FeatureSetUplinkPerCC-Id> + </featureSetListPerUplinkCC> + <supportedSRS-Resources> + <maxNumberAperiodicSRS-PerBWP><n16/></maxNumberAperiodicSRS-PerBWP> + <maxNumberAperiodicSRS-PerBWP-PerSlot>6</maxNumberAperiodicSRS-PerBWP-PerSlot> + <maxNumberPeriodicSRS-PerBWP><n16/></maxNumberPeriodicSRS-PerBWP> + <maxNumberPeriodicSRS-PerBWP-PerSlot>6</maxNumberPeriodicSRS-PerBWP-PerSlot> + <maxNumberSemiPersistentSRS-PerBWP><n2/></maxNumberSemiPersistentSRS-PerBWP> + <maxNumberSemiPersistentSRS-PerBWP-PerSlot>2</maxNumberSemiPersistentSRS-PerBWP-PerSlot> + <maxNumberSRS-Ports-PerResource><n1/></maxNumberSRS-Ports-PerResource> + </supportedSRS-Resources> + </FeatureSetUplink> + <FeatureSetUplink> + <featureSetListPerUplinkCC> + <FeatureSetUplinkPerCC-Id>10</FeatureSetUplinkPerCC-Id> + </featureSetListPerUplinkCC> + <supportedSRS-Resources> + <maxNumberAperiodicSRS-PerBWP><n16/></maxNumberAperiodicSRS-PerBWP> + <maxNumberAperiodicSRS-PerBWP-PerSlot>6</maxNumberAperiodicSRS-PerBWP-PerSlot> + <maxNumberPeriodicSRS-PerBWP><n16/></maxNumberPeriodicSRS-PerBWP> + <maxNumberPeriodicSRS-PerBWP-PerSlot>6</maxNumberPeriodicSRS-PerBWP-PerSlot> + <maxNumberSemiPersistentSRS-PerBWP><n2/></maxNumberSemiPersistentSRS-PerBWP> + <maxNumberSemiPersistentSRS-PerBWP-PerSlot>2</maxNumberSemiPersistentSRS-PerBWP-PerSlot> + <maxNumberSRS-Ports-PerResource><n1/></maxNumberSRS-Ports-PerResource> + </supportedSRS-Resources> + </FeatureSetUplink> + <FeatureSetUplink> + <featureSetListPerUplinkCC> + <FeatureSetUplinkPerCC-Id>11</FeatureSetUplinkPerCC-Id> + </featureSetListPerUplinkCC> + <supportedSRS-Resources> + <maxNumberAperiodicSRS-PerBWP><n16/></maxNumberAperiodicSRS-PerBWP> + <maxNumberAperiodicSRS-PerBWP-PerSlot>6</maxNumberAperiodicSRS-PerBWP-PerSlot> + <maxNumberPeriodicSRS-PerBWP><n16/></maxNumberPeriodicSRS-PerBWP> + <maxNumberPeriodicSRS-PerBWP-PerSlot>6</maxNumberPeriodicSRS-PerBWP-PerSlot> + <maxNumberSemiPersistentSRS-PerBWP><n2/></maxNumberSemiPersistentSRS-PerBWP> + <maxNumberSemiPersistentSRS-PerBWP-PerSlot>2</maxNumberSemiPersistentSRS-PerBWP-PerSlot> + <maxNumberSRS-Ports-PerResource><n1/></maxNumberSRS-Ports-PerResource> + </supportedSRS-Resources> + </FeatureSetUplink> + <FeatureSetUplink> + <featureSetListPerUplinkCC> + <FeatureSetUplinkPerCC-Id>12</FeatureSetUplinkPerCC-Id> + </featureSetListPerUplinkCC> + <supportedSRS-Resources> + <maxNumberAperiodicSRS-PerBWP><n16/></maxNumberAperiodicSRS-PerBWP> + <maxNumberAperiodicSRS-PerBWP-PerSlot>6</maxNumberAperiodicSRS-PerBWP-PerSlot> + <maxNumberPeriodicSRS-PerBWP><n16/></maxNumberPeriodicSRS-PerBWP> + <maxNumberPeriodicSRS-PerBWP-PerSlot>6</maxNumberPeriodicSRS-PerBWP-PerSlot> + <maxNumberSemiPersistentSRS-PerBWP><n2/></maxNumberSemiPersistentSRS-PerBWP> + <maxNumberSemiPersistentSRS-PerBWP-PerSlot>2</maxNumberSemiPersistentSRS-PerBWP-PerSlot> + <maxNumberSRS-Ports-PerResource><n1/></maxNumberSRS-Ports-PerResource> + </supportedSRS-Resources> + </FeatureSetUplink> + <FeatureSetUplink> + <featureSetListPerUplinkCC> + <FeatureSetUplinkPerCC-Id>11</FeatureSetUplinkPerCC-Id> + </featureSetListPerUplinkCC> + <supportedSRS-Resources> + <maxNumberAperiodicSRS-PerBWP><n1/></maxNumberAperiodicSRS-PerBWP> + <maxNumberAperiodicSRS-PerBWP-PerSlot>6</maxNumberAperiodicSRS-PerBWP-PerSlot> + <maxNumberPeriodicSRS-PerBWP><n16/></maxNumberPeriodicSRS-PerBWP> + <maxNumberPeriodicSRS-PerBWP-PerSlot>6</maxNumberPeriodicSRS-PerBWP-PerSlot> + <maxNumberSemiPersistentSRS-PerBWP><n2/></maxNumberSemiPersistentSRS-PerBWP> + <maxNumberSemiPersistentSRS-PerBWP-PerSlot>2</maxNumberSemiPersistentSRS-PerBWP-PerSlot> + <maxNumberSRS-Ports-PerResource><n1/></maxNumberSRS-Ports-PerResource> + </supportedSRS-Resources> + </FeatureSetUplink> + </featureSetsUplink> + <featureSetsUplinkPerCC> + <FeatureSetUplinkPerCC> + <supportedSubcarrierSpacingUL><kHz30/></supportedSubcarrierSpacingUL> + <supportedBandwidthUL> + <fr1><mhz100/></fr1> + </supportedBandwidthUL> + <mimo-CB-PUSCH> + <maxNumberMIMO-LayersCB-PUSCH><twoLayers/></maxNumberMIMO-LayersCB-PUSCH> + <maxNumberSRS-ResourcePerSet>1</maxNumberSRS-ResourcePerSet> + </mimo-CB-PUSCH> + <supportedModulationOrderUL><qam256/></supportedModulationOrderUL> + </FeatureSetUplinkPerCC> + <FeatureSetUplinkPerCC> + <supportedSubcarrierSpacingUL><kHz30/></supportedSubcarrierSpacingUL> + <supportedBandwidthUL> + <fr1><mhz100/></fr1> + </supportedBandwidthUL> + <channelBW-90mhz><supported/></channelBW-90mhz> + <mimo-CB-PUSCH> + <maxNumberMIMO-LayersCB-PUSCH><twoLayers/></maxNumberMIMO-LayersCB-PUSCH> + <maxNumberSRS-ResourcePerSet>1</maxNumberSRS-ResourcePerSet> + </mimo-CB-PUSCH> + <supportedModulationOrderUL><qam256/></supportedModulationOrderUL> + </FeatureSetUplinkPerCC> + <FeatureSetUplinkPerCC> + <supportedSubcarrierSpacingUL><kHz15/></supportedSubcarrierSpacingUL> + <supportedBandwidthUL> + <fr1><mhz20/></fr1> + </supportedBandwidthUL> + <mimo-CB-PUSCH> + <maxNumberMIMO-LayersCB-PUSCH><oneLayer/></maxNumberMIMO-LayersCB-PUSCH> + <maxNumberSRS-ResourcePerSet>1</maxNumberSRS-ResourcePerSet> + </mimo-CB-PUSCH> + <supportedModulationOrderUL><qam256/></supportedModulationOrderUL> + </FeatureSetUplinkPerCC> + <FeatureSetUplinkPerCC> + <supportedSubcarrierSpacingUL><kHz15/></supportedSubcarrierSpacingUL> + <supportedBandwidthUL> + <fr1><mhz40/></fr1> + </supportedBandwidthUL> + <mimo-CB-PUSCH> + <maxNumberMIMO-LayersCB-PUSCH><oneLayer/></maxNumberMIMO-LayersCB-PUSCH> + <maxNumberSRS-ResourcePerSet>1</maxNumberSRS-ResourcePerSet> + </mimo-CB-PUSCH> + <supportedModulationOrderUL><qam256/></supportedModulationOrderUL> + </FeatureSetUplinkPerCC> + <FeatureSetUplinkPerCC> + <supportedSubcarrierSpacingUL><kHz30/></supportedSubcarrierSpacingUL> + <supportedBandwidthUL> + <fr1><mhz40/></fr1> + </supportedBandwidthUL> + <mimo-CB-PUSCH> + <maxNumberMIMO-LayersCB-PUSCH><oneLayer/></maxNumberMIMO-LayersCB-PUSCH> + <maxNumberSRS-ResourcePerSet>1</maxNumberSRS-ResourcePerSet> + </mimo-CB-PUSCH> + <supportedModulationOrderUL><qam256/></supportedModulationOrderUL> + </FeatureSetUplinkPerCC> + <FeatureSetUplinkPerCC> + <supportedSubcarrierSpacingUL><kHz30/></supportedSubcarrierSpacingUL> + <supportedBandwidthUL> + <fr1><mhz80/></fr1> + </supportedBandwidthUL> + <mimo-CB-PUSCH> + <maxNumberMIMO-LayersCB-PUSCH><oneLayer/></maxNumberMIMO-LayersCB-PUSCH> + <maxNumberSRS-ResourcePerSet>1</maxNumberSRS-ResourcePerSet> + </mimo-CB-PUSCH> + <supportedModulationOrderUL><qam256/></supportedModulationOrderUL> + </FeatureSetUplinkPerCC> + <FeatureSetUplinkPerCC> + <supportedSubcarrierSpacingUL><kHz30/></supportedSubcarrierSpacingUL> + <supportedBandwidthUL> + <fr1><mhz20/></fr1> + </supportedBandwidthUL> + <mimo-CB-PUSCH> + <maxNumberMIMO-LayersCB-PUSCH><oneLayer/></maxNumberMIMO-LayersCB-PUSCH> + <maxNumberSRS-ResourcePerSet>1</maxNumberSRS-ResourcePerSet> + </mimo-CB-PUSCH> + <supportedModulationOrderUL><qam256/></supportedModulationOrderUL> + </FeatureSetUplinkPerCC> + <FeatureSetUplinkPerCC> + <supportedSubcarrierSpacingUL><kHz15/></supportedSubcarrierSpacingUL> + <supportedBandwidthUL> + <fr1><mhz30/></fr1> + </supportedBandwidthUL> + <mimo-CB-PUSCH> + <maxNumberMIMO-LayersCB-PUSCH><oneLayer/></maxNumberMIMO-LayersCB-PUSCH> + <maxNumberSRS-ResourcePerSet>1</maxNumberSRS-ResourcePerSet> + </mimo-CB-PUSCH> + <supportedModulationOrderUL><qam256/></supportedModulationOrderUL> + </FeatureSetUplinkPerCC> + <FeatureSetUplinkPerCC> + <supportedSubcarrierSpacingUL><kHz15/></supportedSubcarrierSpacingUL> + <supportedBandwidthUL> + <fr1><mhz15/></fr1> + </supportedBandwidthUL> + <mimo-CB-PUSCH> + <maxNumberMIMO-LayersCB-PUSCH><oneLayer/></maxNumberMIMO-LayersCB-PUSCH> + <maxNumberSRS-ResourcePerSet>1</maxNumberSRS-ResourcePerSet> + </mimo-CB-PUSCH> + <supportedModulationOrderUL><qam256/></supportedModulationOrderUL> + </FeatureSetUplinkPerCC> + <FeatureSetUplinkPerCC> + <supportedSubcarrierSpacingUL><kHz30/></supportedSubcarrierSpacingUL> + <supportedBandwidthUL> + <fr1><mhz100/></fr1> + </supportedBandwidthUL> + <mimo-CB-PUSCH> + <maxNumberMIMO-LayersCB-PUSCH><oneLayer/></maxNumberMIMO-LayersCB-PUSCH> + <maxNumberSRS-ResourcePerSet>1</maxNumberSRS-ResourcePerSet> + </mimo-CB-PUSCH> + <supportedModulationOrderUL><qam256/></supportedModulationOrderUL> + </FeatureSetUplinkPerCC> + <FeatureSetUplinkPerCC> + <supportedSubcarrierSpacingUL><kHz30/></supportedSubcarrierSpacingUL> + <supportedBandwidthUL> + <fr1><mhz100/></fr1> + </supportedBandwidthUL> + <channelBW-90mhz><supported/></channelBW-90mhz> + <mimo-CB-PUSCH> + <maxNumberMIMO-LayersCB-PUSCH><oneLayer/></maxNumberMIMO-LayersCB-PUSCH> + <maxNumberSRS-ResourcePerSet>1</maxNumberSRS-ResourcePerSet> + </mimo-CB-PUSCH> + <supportedModulationOrderUL><qam256/></supportedModulationOrderUL> + </FeatureSetUplinkPerCC> + <FeatureSetUplinkPerCC> + <supportedSubcarrierSpacingUL><kHz30/></supportedSubcarrierSpacingUL> + <supportedBandwidthUL> + <fr1><mhz60/></fr1> + </supportedBandwidthUL> + <mimo-CB-PUSCH> + <maxNumberMIMO-LayersCB-PUSCH><oneLayer/></maxNumberMIMO-LayersCB-PUSCH> + <maxNumberSRS-ResourcePerSet>1</maxNumberSRS-ResourcePerSet> + </mimo-CB-PUSCH> + <supportedModulationOrderUL><qam256/></supportedModulationOrderUL> + </FeatureSetUplinkPerCC> + </featureSetsUplinkPerCC> + <ext1> + <featureSetsDownlink-v1540> + <FeatureSetDownlink-v1540> + <oneFL-DMRS-TwoAdditionalDMRS-DL><supported/></oneFL-DMRS-TwoAdditionalDMRS-DL> + <twoFL-DMRS-TwoAdditionalDMRS-DL><supported/></twoFL-DMRS-TwoAdditionalDMRS-DL> + </FeatureSetDownlink-v1540> + <FeatureSetDownlink-v1540> + <oneFL-DMRS-TwoAdditionalDMRS-DL><supported/></oneFL-DMRS-TwoAdditionalDMRS-DL> + <twoFL-DMRS-TwoAdditionalDMRS-DL><supported/></twoFL-DMRS-TwoAdditionalDMRS-DL> + </FeatureSetDownlink-v1540> + <FeatureSetDownlink-v1540> + <oneFL-DMRS-TwoAdditionalDMRS-DL><supported/></oneFL-DMRS-TwoAdditionalDMRS-DL> + <twoFL-DMRS-TwoAdditionalDMRS-DL><supported/></twoFL-DMRS-TwoAdditionalDMRS-DL> + </FeatureSetDownlink-v1540> + <FeatureSetDownlink-v1540> + <oneFL-DMRS-TwoAdditionalDMRS-DL><supported/></oneFL-DMRS-TwoAdditionalDMRS-DL> + <twoFL-DMRS-TwoAdditionalDMRS-DL><supported/></twoFL-DMRS-TwoAdditionalDMRS-DL> + </FeatureSetDownlink-v1540> + <FeatureSetDownlink-v1540> + <oneFL-DMRS-TwoAdditionalDMRS-DL><supported/></oneFL-DMRS-TwoAdditionalDMRS-DL> + <twoFL-DMRS-TwoAdditionalDMRS-DL><supported/></twoFL-DMRS-TwoAdditionalDMRS-DL> + </FeatureSetDownlink-v1540> + <FeatureSetDownlink-v1540> + <oneFL-DMRS-TwoAdditionalDMRS-DL><supported/></oneFL-DMRS-TwoAdditionalDMRS-DL> + <twoFL-DMRS-TwoAdditionalDMRS-DL><supported/></twoFL-DMRS-TwoAdditionalDMRS-DL> + </FeatureSetDownlink-v1540> + <FeatureSetDownlink-v1540> + <oneFL-DMRS-TwoAdditionalDMRS-DL><supported/></oneFL-DMRS-TwoAdditionalDMRS-DL> + <twoFL-DMRS-TwoAdditionalDMRS-DL><supported/></twoFL-DMRS-TwoAdditionalDMRS-DL> + </FeatureSetDownlink-v1540> + <FeatureSetDownlink-v1540> + <oneFL-DMRS-TwoAdditionalDMRS-DL><supported/></oneFL-DMRS-TwoAdditionalDMRS-DL> + <twoFL-DMRS-TwoAdditionalDMRS-DL><supported/></twoFL-DMRS-TwoAdditionalDMRS-DL> + </FeatureSetDownlink-v1540> + <FeatureSetDownlink-v1540> + <oneFL-DMRS-TwoAdditionalDMRS-DL><supported/></oneFL-DMRS-TwoAdditionalDMRS-DL> + <twoFL-DMRS-TwoAdditionalDMRS-DL><supported/></twoFL-DMRS-TwoAdditionalDMRS-DL> + </FeatureSetDownlink-v1540> + <FeatureSetDownlink-v1540> + <oneFL-DMRS-TwoAdditionalDMRS-DL><supported/></oneFL-DMRS-TwoAdditionalDMRS-DL> + <twoFL-DMRS-TwoAdditionalDMRS-DL><supported/></twoFL-DMRS-TwoAdditionalDMRS-DL> + </FeatureSetDownlink-v1540> + <FeatureSetDownlink-v1540> + <oneFL-DMRS-TwoAdditionalDMRS-DL><supported/></oneFL-DMRS-TwoAdditionalDMRS-DL> + <twoFL-DMRS-TwoAdditionalDMRS-DL><supported/></twoFL-DMRS-TwoAdditionalDMRS-DL> + </FeatureSetDownlink-v1540> + <FeatureSetDownlink-v1540> + <oneFL-DMRS-TwoAdditionalDMRS-DL><supported/></oneFL-DMRS-TwoAdditionalDMRS-DL> + <twoFL-DMRS-TwoAdditionalDMRS-DL><supported/></twoFL-DMRS-TwoAdditionalDMRS-DL> + </FeatureSetDownlink-v1540> + </featureSetsDownlink-v1540> + </ext1> + </featureSets> + <featureSetCombinations> + <FeatureSetCombination> + <FeatureSetsPerBand> + <nr> + <downlinkSetNR>2</downlinkSetNR> + <uplinkSetNR>2</uplinkSetNR> + </nr> + </FeatureSetsPerBand> + </FeatureSetCombination> + </featureSetCombinations> + <nonCriticalExtension> + <interRAT-Parameters> + <eutra> + <supportedBandListEUTRA> + <FreqBandIndicatorEUTRA>7</FreqBandIndicatorEUTRA> + <FreqBandIndicatorEUTRA>38</FreqBandIndicatorEUTRA> + </supportedBandListEUTRA> + <eutra-ParametersCommon> + <mfbi-EUTRA><supported/></mfbi-EUTRA> + </eutra-ParametersCommon> + </eutra> + </interRAT-Parameters> + <inactiveState><supported/></inactiveState> + </nonCriticalExtension> +</UE-NR-Capability> diff --git a/targets/RT/USER/TOOLS/thread_ipc.c b/targets/RT/USER/TOOLS/thread_ipc.c deleted file mode 100644 index 7eda3e843175e816fac2eed8987556e616e3b4b8..0000000000000000000000000000000000000000 --- a/targets/RT/USER/TOOLS/thread_ipc.c +++ /dev/null @@ -1,231 +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 <stdio.h> -#include <errno.h> -#include <string.h> -#include <stdlib.h> - -#include <pthread.h> -#include <sched.h> - -#include "thread_ipc.h" - -g_thread_ipc_t thread_ipc = {0}; - -void loop_buffer_reset(buffer_t *loop_buf) -{ - int i; - - for (i = 0; i < BUFFERMAX; i++) { - loop_buf[i].subframe_num = -1; - } - - return; -} - -static void loop_buffer_init(loop_buffer_op_t *loop_buffer) -{ - loop_buffer->packet_num = 0; - loop_buffer->isfull = 0; - loop_buffer->isempty = 1; - - pthread_mutex_init(&loop_buffer->buffer_mutex, NULL); - - pthread_cond_init(&loop_buffer->full_cond, NULL); - pthread_cond_init(&loop_buffer->empty_cond, NULL); - - loop_buffer_reset(loop_buffer->loop_buf); - - return; -} - -static void sync_buffer_init(sync_buffer_t *sync_buffer) -{ - sync_buffer->decoding_subframe_num = 0; - pthread_mutex_init(&sync_buffer->buffer_mutex, NULL); - - return; -} - -int thread_ipc_init(void) -{ - //printf("recv %d\n", thread_ipc.sync_buffer.decoding_subframe_num); - thread_ipc.ue_sync_state = 0; - thread_ipc.rx_timestamp = 0; - thread_ipc.tx_timestamp = 0; - thread_ipc.current_subframe = 0; - - pthread_mutex_init(&thread_ipc.dl_decode_mutex, NULL); - pthread_mutex_lock(&thread_ipc.dl_decode_mutex); - - pthread_mutex_init(&thread_ipc.ul_send_mutex, NULL); - pthread_mutex_lock(&thread_ipc.ul_send_mutex); - - pthread_mutex_init(&thread_ipc.sync_mutex, NULL); - pthread_mutex_lock(&thread_ipc.sync_mutex); - - loop_buffer_init(&thread_ipc.loop_buffer); - sync_buffer_init(&thread_ipc.sync_buffer); - - return 0; -} - -int thread_ipc_deinit(void) -{ - pthread_mutex_destroy(&thread_ipc.ul_send_mutex); - pthread_mutex_destroy(&thread_ipc.sync_mutex); - pthread_mutex_destroy(&thread_ipc.dl_decode_mutex); - - pthread_mutex_destroy(&thread_ipc.loop_buffer.buffer_mutex); - pthread_cond_destroy(&thread_ipc.loop_buffer.full_cond); - pthread_cond_destroy(&thread_ipc.loop_buffer.empty_cond); - - pthread_mutex_destroy(&thread_ipc.sync_buffer.buffer_mutex); - - return 0; -} - -int set_thread_attr(pthread_attr_t *attr, int policy, int priority, int cpuid) -{ - struct sched_param param; - cpu_set_t cpu_info; - - pthread_attr_init(attr); - - if (pthread_attr_setschedpolicy(attr, policy) != 0) { - perror("pthread_attr_setschedpolicy"); - return -1; - } - - param.sched_priority = priority; - - if (pthread_attr_setschedparam(attr, ¶m) != 0) { - perror("pthread_attr_setschedparam"); - return -1; - } - - CPU_ZERO(&cpu_info); - CPU_SET(cpuid, &cpu_info); - - if (pthread_attr_setaffinity_np(attr,sizeof(cpu_set_t),&cpu_info)) { - perror("pthread_attr_setaffinity_np"); - return -1; - } - - if (pthread_attr_setinheritsched(attr, PTHREAD_EXPLICIT_SCHED) != 0) { - perror("pthread_attr_setinheritsched"); - return -1; - } - - return 0; -} - - -int find_subframe_num(unsigned long long current_subframe_num, buffer_t *buf, int *flag) -{ - long long tmp; - int i; - - tmp = current_subframe_num; - - for ( i = 0; i < HIGHBUFFER + 1; i++) { - if(tmp == buf[i].subframe_num) { - return i; - } else if (tmp < buf[i].subframe_num) { - *flag = 1; - } - } - - return -1; -} - -int ue_unsync_thread_ipc_reset(void) -{ - thread_ipc.ue_sync_state = 0; - - pthread_mutex_lock(&thread_ipc.loop_buffer.buffer_mutex); - - if (thread_ipc.loop_buffer.isempty) { - pthread_cond_signal(&thread_ipc.loop_buffer.empty_cond); - } - - if (thread_ipc.loop_buffer.isfull) { - pthread_cond_signal(&thread_ipc.loop_buffer.full_cond); - } - - thread_ipc.loop_buffer.packet_num = 0; - thread_ipc.loop_buffer.isfull = 0; - thread_ipc.loop_buffer.isempty = 1; - - loop_buffer_reset(thread_ipc.loop_buffer.loop_buf); - pthread_mutex_unlock(&thread_ipc.loop_buffer.buffer_mutex); - - thread_ipc.current_subframe = 0; - - return 0; -} -void bind_thread2kernel(int cpu_id) -{ - cpu_set_t mask; - cpu_set_t get; - int i; - int num = sysconf(_SC_NPROCESSORS_CONF); - //printf("system has %d processor(s) by super\n", num); - CPU_ZERO(&mask); - CPU_SET(cpu_id, &mask); - - if (pthread_setaffinity_np(pthread_self(), sizeof(mask), &mask) < 0) { - fprintf(stderr, "set thread affinity failed\n"); - } - - /*CPU_ZERO(&get); - if (pthread_getaffinity_np(pthread_self(), sizeof(get), &get) < 0) { - fprintf(stderr, "get thread affinity failed\n"); - } - for (i = 0; i < num; i++) { - if (CPU_ISSET(i, &get)) { - printf("thread %d is running in processor %d\n", (int)pthread_self(), i); - } - } - if (CPU_ISSET(cpu_id, &get)) { - printf("thread %d is running in processor %d by super\n", (int)pthread_self(), cpu_id); - }*/ -} -void get_thread2kernel(void) -{ - cpu_set_t get; - int i; - int num = sysconf(_SC_NPROCESSORS_CONF); - printf("system has %d processor(s) by super\n", num); - CPU_ZERO(&get); - - if (pthread_getaffinity_np(pthread_self(), sizeof(get), &get) < 0) { - fprintf(stderr, "get thread affinity failed\n"); - } - - for (i = 0; i < num; i++) { - if (CPU_ISSET(i, &get)) { - printf("The thread %d is running in processor %d by super\n", (int)pthread_self(), i); - } - } -} - diff --git a/targets/RT/USER/lte-enb.c b/targets/RT/USER/lte-enb.c index 632a47707b4294f635f19676743d5762fb4be9d2..0b6b0b3a757ab61da2546348aa2b392e8118efda 100644 --- a/targets/RT/USER/lte-enb.c +++ b/targets/RT/USER/lte-enb.c @@ -48,8 +48,6 @@ #undef MALLOC //there are two conflicting definitions, so we better make sure we don't use it at all -#include "rt_wrapper.h" - #include "assertions.h" @@ -101,7 +99,6 @@ extern RAN_CONTEXT_t RC; //#define USRP_DEBUG 1 struct timing_info_t { //unsigned int frame, hw_slot, last_slot, next_slot; - RTIME time_min, time_max, time_avg, time_last, time_now; //unsigned int mbox0, mbox1, mbox2, mbox_target; unsigned int n_samples; } timing_info; @@ -398,8 +395,20 @@ static void *L1_thread( void *param ) { // set default return value eNB_thread_rxtx_status = 0; sprintf(thread_name,"RXn_TXnp4_%d\n",&eNB->proc.L1_proc == proc ? 0 : 1); +#if 1 + { + struct sched_param sparam = + { + .sched_priority = 79, + }; + if (pthread_setschedparam(pthread_self(), SCHED_RR, &sparam) != 0) + { + LOG_E(PHY,"pthread_setschedparam: %s\n", strerror(errno)); + } + } +#else thread_top_init(thread_name,1,470000,500000,500000); - pthread_setname_np( pthread_self(),"rxtx processing"); +#endif LOG_I(PHY,"thread rxtx created id=%ld\n", syscall(__NR_gettid)); while (!oai_exit) { @@ -943,7 +952,16 @@ void init_eNB_proc(int inst) { //pthread_create( &proc_rxtx[0].pthread_rxtx, attr0, eNB_thread_rxtx, &proc_rxtx[0] ); //pthread_create( &proc_rxtx[1].pthread_rxtx, attr1, eNB_thread_rxtx, &proc_rxtx[1] ); pthread_create( &L1_proc->pthread, attr0, L1_thread, L1_proc ); + if (pthread_setname_np(L1_proc->pthread, "oai:enb-L1-rx") != 0) + { + LOG_E(PHY, "pthread_setname_np: %s\n", strerror(errno)); + } + pthread_create( &L1_proc_tx->pthread, attr1, L1_thread, L1_proc_tx); + if (pthread_setname_np(L1_proc_tx->pthread, "oai:enb-L1-tx") != 0) + { + LOG_E(PHY, "pthread_setname_np: %s\n", strerror(errno)); + } } if (NFAPI_MODE!=NFAPI_MODE_VNF) { diff --git a/targets/RT/USER/lte-ru.c b/targets/RT/USER/lte-ru.c index 10ba121c44ce51b462c7a01b840abf24c02a0963..8ad610f1af7f8911a27e2f17b45f0e3fc4fdea9b 100644 --- a/targets/RT/USER/lte-ru.c +++ b/targets/RT/USER/lte-ru.c @@ -44,7 +44,6 @@ #include <execinfo.h> #include <getopt.h> #include <sys/sysinfo.h> -#include "rt_wrapper.h" #undef MALLOC //there are two conflicting definitions, so we better make sure we don't use it at all @@ -1490,6 +1489,7 @@ static void *ru_stats_thread(void *param) { static void *ru_thread_tx( void *param ) { RU_t *ru = (RU_t *)param; RU_proc_t *proc = &ru->proc; + __attribute__((unused)) LTE_DL_FRAME_PARMS *fp = ru->frame_parms; PHY_VARS_eNB *eNB; L1_proc_t *eNB_proc; @@ -1917,7 +1917,8 @@ static void *ru_thread( void *param ) { // This thread run the initial synchronization like a UE void *ru_thread_synch(void *arg) { RU_t *ru = (RU_t *)arg; - LTE_DL_FRAME_PARMS *fp; + __attribute__((unused)) + LTE_DL_FRAME_PARMS *fp = ru->frame_parms; int64_t peak_val, avg; static int ru_thread_synch_status = 0; int cnt=0; diff --git a/targets/RT/USER/lte-softmodem.c b/targets/RT/USER/lte-softmodem.c index ed9daf23f68ef2747f5f8385017f881fcd17f3e3..85e493f19485493bbe14cbe517337d22bbba0b1a 100644 --- a/targets/RT/USER/lte-softmodem.c +++ b/targets/RT/USER/lte-softmodem.c @@ -34,7 +34,6 @@ #define _GNU_SOURCE /* See feature_test_macros(7) */ #include <sched.h> -#include "rt_wrapper.h" #include <common/utils/msc/msc.h> @@ -94,6 +93,9 @@ unsigned short config_frames[4] = {2,9,11,13}; #include "NB_IoT_interface.h" #include <executables/split_headers.h> +#if USING_GPROF +# include "sys/gmon.h" +#endif pthread_cond_t nfapi_sync_cond; pthread_mutex_t nfapi_sync_mutex; @@ -178,7 +180,6 @@ eth_params_t *eth_params; double cpuf; int oaisim_flag=0; -uint8_t proto_agent_flag = 0; /* forward declarations */ @@ -479,7 +480,7 @@ int restart_L1L2(module_id_t enb_id) { return 0; } -void init_pdcp(void) { +static void init_pdcp(void) { if (!NODE_IS_DU(RC.rrc[0]->node_type)) { pdcp_layer_init(); uint32_t pdcp_initmask = (IS_SOFTMODEM_NOS1) ? @@ -490,16 +491,16 @@ void init_pdcp(void) { pdcp_initmask = pdcp_initmask | ENB_NAS_USE_TUN_W_MBMS_BIT; - pdcp_module_init(pdcp_initmask); + pdcp_module_init(pdcp_initmask, 0); if (NODE_IS_CU(RC.rrc[0]->node_type)) { - pdcp_set_rlc_data_req_func((send_rlc_data_req_func_t)proto_agent_send_rlc_data_req); + pdcp_set_rlc_data_req_func(cu_send_to_du); } else { - pdcp_set_rlc_data_req_func((send_rlc_data_req_func_t) rlc_data_req); - pdcp_set_pdcp_data_ind_func((pdcp_data_ind_func_t) pdcp_data_ind); + pdcp_set_rlc_data_req_func(rlc_data_req); + pdcp_set_pdcp_data_ind_func(pdcp_data_ind); } } else { - pdcp_set_pdcp_data_ind_func((pdcp_data_ind_func_t) proto_agent_send_pdcp_data_ind); + pdcp_set_pdcp_data_ind_func(proto_agent_send_pdcp_data_ind); } } @@ -528,8 +529,8 @@ int main ( int argc, char **argv ) } mode = normal_txrx; - set_latency_target(); logInit(); + set_latency_target(); printf("Reading in command-line options\n"); get_options (); @@ -564,13 +565,10 @@ int main ( int argc, char **argv ) init_opt(); // to make a graceful exit when ctrl-c is pressed set_softmodem_sighandler(); - check_clock(); #ifndef PACKAGE_VERSION # define PACKAGE_VERSION "UNKNOWN-EXPERIMENTAL" #endif LOG_I(HW, "Version: %s\n", PACKAGE_VERSION); - printf("Runtime table\n"); - fill_modeled_runtime_table(runtime_phy_rx,runtime_phy_tx); /* Read configuration */ if (RC.nb_inst > 0) { @@ -742,10 +740,19 @@ int main ( int argc, char **argv ) if(IS_SOFTMODEM_DOSCOPE) load_softscope("enb",NULL); itti_wait_tasks_end(); + +#if USING_GPROF + // Save the gprof data now (rather than via atexit) in case we crash while shutting down + fprintf(stderr, "Recording gprof data...\n"); + _mcleanup(); + fprintf(stderr, "Recording gprof data...done\n"); +#endif // USING_GPROF + oai_exit=1; LOG_I(ENB_APP,"oai_exit=%d\n",oai_exit); // stop threads + #if 0 //Disable clean up because this tends to crash (and unnecessary) if (RC.nb_inst == 0 || !NODE_IS_CU(node_type)) { if(IS_SOFTMODEM_DOSCOPE) end_forms(); @@ -787,7 +794,9 @@ int main ( int argc, char **argv ) } } } + #endif + pdcp_module_cleanup(); terminate_opt(); logClean(); printf("Bye.\n"); diff --git a/targets/RT/USER/lte-softmodem.h b/targets/RT/USER/lte-softmodem.h index a1b261f26361722dbbd96fc44fd93102d1a2b3ab..cf35a13fe907d851156ded04b32c9847123a9163 100644 --- a/targets/RT/USER/lte-softmodem.h +++ b/targets/RT/USER/lte-softmodem.h @@ -6,7 +6,6 @@ #include <fcntl.h> #include <getopt.h> #include <linux/sched.h> -#include "rt_wrapper.h" #include <sched.h> #include <signal.h> #include <stdint.h> @@ -21,7 +20,6 @@ #include <sys/types.h> #include <unistd.h> #include "threads_t.h" -#include "rt_wrapper.h" #include "../../ARCH/COMMON/common_lib.h" //#undef MALLOC #include "assertions.h" @@ -114,7 +112,9 @@ {"usrp-args", CONFIG_HLP_USRP_ARGS, 0, strptr:(char **)&usrp_args, defstrval:"type=b200",TYPE_STRING, 0}, \ {"mmapped-dma", CONFIG_HLP_DMAMAP, PARAMFLAG_BOOL, uptr:&mmapped_dma, defintval:0, TYPE_INT, 0}, \ {"T" , CONFIG_HLP_TDD, PARAMFLAG_BOOL, iptr:&tddflag, defintval:0, TYPE_INT, 0}, \ - {"A", CONFIG_HLP_TADV, 0, iptr:&(timingadv), defintval:0, TYPE_INT, 0} \ + {"A", CONFIG_HLP_TADV, 0, iptr:&(timingadv), defintval:0, TYPE_INT, 0}, \ + {"ue-idx-standalone", NULL, 0, u16ptr:&ue_idx_standalone, defuintval:0xFFFF, TYPE_UINT16, 0}, \ + {"node-number", NULL, 0, u16ptr:&node_number, defuintval:2, TYPE_UINT16, 0}, \ } /*-----------------------------------------------------------------------------------------------------------------------------*/ @@ -138,6 +138,9 @@ extern pthread_cond_t sync_cond; extern pthread_mutex_t sync_mutex; extern int sync_var; +extern uint16_t ue_id_g; +extern uint16_t node_number; + extern uint64_t downlink_frequency[MAX_NUM_CCs][4]; extern int32_t uplink_frequency_offset[MAX_NUM_CCs][4]; @@ -208,7 +211,10 @@ extern int stop_L1L2(module_id_t enb_id); extern int restart_L1L2(module_id_t enb_id); extern void init_UE_stub_single_thread(int nb_inst, int eMBMS_active, int uecap_xer_in, char *emul_iface); +extern void init_UE_standalone_thread(int ue_idx); extern PHY_VARS_UE *init_ue_vars(LTE_DL_FRAME_PARMS *frame_parms, uint8_t UE_id, uint8_t abstraction_flag); +extern void init_bler_table(void); + #endif diff --git a/targets/RT/USER/lte-ue.c b/targets/RT/USER/lte-ue.c index 1fae6c1e6621596cef3c8ba47c5d756b45a2cfb9..1643ca36ca71a2df537170e0c9d6e6bd8470e542 100644 --- a/targets/RT/USER/lte-ue.c +++ b/targets/RT/USER/lte-ue.c @@ -31,7 +31,6 @@ */ #include "lte-softmodem.h" -#include "rt_wrapper.h" #include "system.h" #include "LAYER2/MAC/mac.h" @@ -81,18 +80,10 @@ void init_UE_threads(int); void init_UE_threads_stub(int); void init_UE_single_thread_stub(int); void *UE_thread(void *arg); -void init_UE(int nb_inst,int eMBMS_active, int uecap_xer_in, int timing_correction, int phy_test, int UE_scan, int UE_scan_carrier, runmode_t mode,int rxgain,int txpowermax,LTE_DL_FRAME_PARMS *fp); -void init_UE_stub(int nb_inst,int,int,char *); -void init_UE_stub_single_thread(int nb_inst,int,int,char *); int init_timer_thread(void); -extern void oai_subframe_ind(uint16_t sfn, uint16_t sf); extern void multicast_link_start(void (*rx_handlerP) (unsigned int, char *), - unsigned char _multicast_group, char *multicast_ifname); -extern int oai_nfapi_crc_indication(nfapi_crc_indication_t *crc_ind); -extern int oai_nfapi_cqi_indication(nfapi_cqi_indication_t *cqi_ind); -extern int oai_nfapi_harq_indication(nfapi_harq_indication_t *harq_ind); -extern int oai_nfapi_sr_indication(nfapi_sr_indication_t *ind); -extern int oai_nfapi_rx_ind(nfapi_rx_indication_t *ind); + unsigned char _multicast_group, + char *multicast_ifname); extern int multicast_link_write_sock(int groupP, char *dataP, uint32_t sizeP); @@ -194,7 +185,7 @@ PHY_VARS_UE *init_ue_vars(LTE_DL_FRAME_PARMS *frame_parms, ue->mac_enabled = 1; // In phy_stub_UE (MAC-to-MAC) mode these init functions don't need to get called. Is this correct? - if (NFAPI_MODE!=NFAPI_UE_STUB_PNF) { + if (NFAPI_MODE!=NFAPI_UE_STUB_PNF && NFAPI_MODE!=NFAPI_MODE_STANDALONE_PNF) { // initialize all signal buffers init_lte_ue_signal(ue,1,abstraction_flag); // intialize transport @@ -413,15 +404,31 @@ void init_UE_stub_single_thread(int nb_inst, // PHY_vars_UE_g[inst][0] = init_ue_vars(NULL,inst,0); } - init_timer_thread(); + if(NFAPI_MODE != NFAPI_MODE_STANDALONE_PNF) { + init_timer_thread(); + } + init_UE_single_thread_stub(nb_inst); printf("UE threads created \n"); - LOG_I(PHY,"Starting multicast link on %s\n",emul_iface); - if(NFAPI_MODE!=NFAPI_UE_STUB_PNF) + if(NFAPI_MODE!=NFAPI_UE_STUB_PNF && NFAPI_MODE!=NFAPI_MODE_STANDALONE_PNF) { + LOG_I(PHY,"Starting multicast link on %s\n",emul_iface); multicast_link_start(ue_stub_rx_handler,0,emul_iface); + } } +void init_UE_standalone_thread(int ue_idx) +{ + int standalone_tx_port = 3211 + ue_idx * 2; + int standalone_rx_port = 3212 + ue_idx * 2; + ue_init_standalone_socket(standalone_tx_port, standalone_rx_port); + + pthread_t thread; + if (pthread_create(&thread, NULL, ue_standalone_pnf_task, NULL) != 0) { + LOG_E(MAC, "pthread_create failed for calling ue_standalone_pnf_task"); + } + pthread_setname_np(thread, "oai:ue-stand"); +} void init_UE_stub(int nb_inst, int eMBMS_active, @@ -449,7 +456,7 @@ void init_UE_stub(int nb_inst, printf("UE threads created \n"); LOG_I(PHY,"Starting multicast link on %s\n",emul_iface); - if(NFAPI_MODE!=NFAPI_UE_STUB_PNF) + if(NFAPI_MODE!=NFAPI_UE_STUB_PNF && NFAPI_MODE!=NFAPI_MODE_STANDALONE_PNF) multicast_link_start(ue_stub_rx_handler,0,emul_iface); } @@ -956,6 +963,396 @@ void ue_stub_rx_handler(unsigned int num_bytes, } } +uint64_t clock_usec(void) +{ + struct timespec t; + if (clock_gettime(CLOCK_MONOTONIC, &t) == -1) + { + abort(); + } + return (uint64_t)t.tv_sec * 1000000 + (t.tv_nsec / 1000); +} +/*! + * \brief This is the UE thread for RX subframe n and TX subframe n+4. + * This thread performs the phy_procedures_UE_RX() on every received slot. + * then, if TX is enabled it performs TX for n+4. + * \param arg is a pointer to a \ref PHY_VARS_UE structure. + * \returns a pointer to an int. The storage is not on the heap and must not be freed. + */ + +static void *UE_phy_stub_standalone_pnf_task(void *arg) +{ +#if 1 + { + struct sched_param sparam = + { + .sched_priority = 79, + }; + if (pthread_setschedparam(pthread_self(), SCHED_RR, &sparam) != 0) + { + LOG_E(PHY,"pthread_setschedparam: %s\n", strerror(errno)); + } + } +#else + thread_top_init("UE_phy_stub_thread_rxn_txnp4", 1, 870000L, 1000000L, 1000000L); +#endif + + // for multipule UE's L2-emulator + //module_id_t Mod_id = 0; + //int init_ra_UE = -1; // This counter is used to initiate the RA of each UE in different SFrames + struct rx_tx_thread_data *rtd = arg; + + if (rtd == NULL) { + LOG_E(MAC, "[SCHED][UE] rx_tx_thread_data *rtd: NULL pointer\n"); + exit_fun("nothing to add"); + } + + UE_rxtx_proc_t *proc = rtd->proc; + // settings for nfapi-L2-emulator mode + module_id_t ue_thread_id = rtd->ue_thread_id; + uint16_t ue_index = 0; + uint16_t ue_num = NB_UE_INST / NB_THREAD_INST + ((NB_UE_INST % NB_THREAD_INST > ue_thread_id) ? 1 : 0); + module_id_t ue_Mod_id; + PHY_VARS_UE *UE = NULL; + int ret; + proc = &PHY_vars_UE_g[0][0]->proc.proc_rxtx[0]; + + UE = rtd->UE; + + UL_INFO = (UL_IND_t *)calloc(1, sizeof(UL_IND_t)); + UL_INFO->rx_ind.rx_indication_body.rx_pdu_list = calloc(NFAPI_RX_IND_MAX_PDU, sizeof(nfapi_rx_indication_pdu_t)); + UL_INFO->rx_ind.rx_indication_body.number_of_pdus = 0; + UL_INFO->crc_ind.crc_indication_body.crc_pdu_list = calloc(NFAPI_CRC_IND_MAX_PDU, sizeof(nfapi_crc_indication_pdu_t)); + UL_INFO->crc_ind.crc_indication_body.number_of_crcs = 0; + UL_INFO->harq_ind.harq_indication_body.harq_pdu_list = calloc(NFAPI_HARQ_IND_MAX_PDU, sizeof(nfapi_harq_indication_pdu_t)); + UL_INFO->harq_ind.harq_indication_body.number_of_harqs = 0; + UL_INFO->sr_ind.sr_indication_body.sr_pdu_list = calloc(NFAPI_SR_IND_MAX_PDU, sizeof(nfapi_sr_indication_pdu_t)); + UL_INFO->sr_ind.sr_indication_body.number_of_srs = 0; + UL_INFO->cqi_ind.cqi_indication_body.cqi_pdu_list = calloc(NFAPI_CQI_IND_MAX_PDU, sizeof(nfapi_cqi_indication_pdu_t)); + UL_INFO->cqi_ind.cqi_indication_body.cqi_raw_pdu_list = calloc(NFAPI_CQI_IND_MAX_PDU, sizeof(nfapi_cqi_indication_raw_pdu_t)); + UL_INFO->cqi_ind.cqi_indication_body.number_of_cqis = 0; + + proc->subframe_rx = proc->sub_frame_start; + proc->subframe_tx = -1; + proc->frame_rx = -1; + proc->frame_tx = -1; + // Initializations for nfapi-L2-emulator mode + sync_var = 0; + + //PANOS: CAREFUL HERE! + wait_sync("UE_phy_stub_standalone_pnf_task"); + + int last_sfn_sf = -1; + + LOG_I(MAC, "Clearing Queues\n"); + reset_queue(&dl_config_req_tx_req_queue); + reset_queue(&ul_config_req_queue); + reset_queue(&hi_dci0_req_queue); + + while (!oai_exit) { + bool sent_any = false; + if (sem_wait(&sfn_semaphore) != 0) { + LOG_E(MAC, "sem_wait() error\n"); + abort(); + } + + int sfn_sf = current_sfn_sf; + if (sfn_sf == last_sfn_sf) + { + LOG_W(MAC, "repeated sfn_sf = %d.%d\n", + sfn_sf >> 4, sfn_sf & 15); + continue; + } + last_sfn_sf = sfn_sf; + + nfapi_dl_config_req_tx_req_t *dl_config_req_tx_req = get_queue(&dl_config_req_tx_req_queue); + nfapi_ul_config_request_t *ul_config_req = get_queue(&ul_config_req_queue); + nfapi_hi_dci0_request_t *hi_dci0_req = get_queue(&hi_dci0_req_queue); + + LOG_I(MAC, "received from proxy frame %d subframe %d\n", + NFAPI_SFNSF2SFN(sfn_sf), NFAPI_SFNSF2SF(sfn_sf)); + + if (ul_config_req != NULL) { + uint8_t ul_num_pdus = ul_config_req->ul_config_request_body.number_of_pdus; + if (ul_num_pdus > 0) { + char *ul_str = nfapi_ul_config_req_to_string(ul_config_req); + LOG_I(MAC, "ul_config_req: %s\n", ul_str); + free(ul_str); + } + } + if (hi_dci0_req != NULL) { + LOG_D(MAC, "hi_dci0_req pdus: %u Frame: %d Subframe: %d\n", + hi_dci0_req->hi_dci0_request_body.number_of_dci, + NFAPI_SFNSF2SFN(hi_dci0_req->sfn_sf), NFAPI_SFNSF2SF(hi_dci0_req->sfn_sf)); + } + + if (dl_config_req_tx_req != NULL) { + + nfapi_tx_req_pdu_list_t *tx_req_pdu_list = dl_config_req_tx_req->tx_req_pdu_list; + nfapi_dl_config_request_t *dl_config_req = dl_config_req_tx_req->dl_config_req; + + uint16_t dl_num_pdus = dl_config_req->dl_config_request_body.number_pdu; + LOG_I(MAC, "(OAI UE) Received dl_config_req from proxy at Frame: %d, Subframe: %d," + " with number of PDUs: %u\n", + NFAPI_SFNSF2SFN(dl_config_req->sfn_sf), NFAPI_SFNSF2SF(dl_config_req->sfn_sf), + dl_num_pdus); + if (dl_num_pdus > 0) { + char *dl_str = nfapi_dl_config_req_to_string(dl_config_req); + LOG_I(MAC, "dl_config_req: %s\n", dl_str); + free(dl_str); + } + LOG_D(MAC, "tx_req pdus: %d\n", tx_req_pdu_list->num_pdus); + + // Handling dl_config_req and tx_req: + nfapi_dl_config_request_body_t *dl_config_req_body = &dl_config_req->dl_config_request_body; + for (int i = 0; i < dl_config_req_body->number_pdu; ++i) { + nfapi_dl_config_request_pdu_t *pdu = &dl_config_req_body->dl_config_pdu_list[i]; + if (pdu->pdu_type == NFAPI_DL_CONFIG_DCI_DL_PDU_TYPE) { + i += 1; + AssertFatal(i < dl_config_req->dl_config_request_body.number_pdu, + "Need PDU following DCI at index %d, but not found\n", + i); + nfapi_dl_config_request_pdu_t *dlsch = &dl_config_req_body->dl_config_pdu_list[i]; + if (dlsch->pdu_type != NFAPI_DL_CONFIG_DLSCH_PDU_TYPE) { + LOG_E(MAC, "expected DLSCH PDU at index %d\n", i); + continue; + } + dl_config_req_UE_MAC_dci(NFAPI_SFNSF2SFN(dl_config_req->sfn_sf), + NFAPI_SFNSF2SF(dl_config_req->sfn_sf), + pdu, + dlsch, + ue_num, + tx_req_pdu_list); + } else if (pdu->pdu_type == NFAPI_DL_CONFIG_BCH_PDU_TYPE) { + dl_config_req_UE_MAC_bch(NFAPI_SFNSF2SFN(dl_config_req->sfn_sf), + NFAPI_SFNSF2SF(dl_config_req->sfn_sf), + pdu, + ue_num); + } else if (pdu->pdu_type == NFAPI_DL_CONFIG_MCH_PDU_TYPE) { + dl_config_req_UE_MAC_mch(NFAPI_SFNSF2SFN(dl_config_req->sfn_sf), + NFAPI_SFNSF2SF(dl_config_req->sfn_sf), + pdu, + ue_num, + tx_req_pdu_list); + } + } + } + if (hi_dci0_req) { + nfapi_hi_dci0_request_body_t *hi_dci0_body = &hi_dci0_req->hi_dci0_request_body; + for (int i = 0; i < hi_dci0_body->number_of_dci + hi_dci0_body->number_of_hi; i++) { + nfapi_hi_dci0_request_pdu_t *pdu = &hi_dci0_body->hi_dci0_pdu_list[i]; + hi_dci0_req_UE_MAC(NFAPI_SFNSF2SFN(hi_dci0_req->sfn_sf), + NFAPI_SFNSF2SF(hi_dci0_req->sfn_sf), + pdu, + ue_num); // This function doesnt do anything? - Andrew + } + } + + for (ue_index = 0; ue_index < ue_num; ue_index++) { + ue_Mod_id = ue_thread_id + NB_THREAD_INST * ue_index; // Always 0 in standalone pnf mode + UE = PHY_vars_UE_g[ue_Mod_id][0]; + +#if UE_TIMING_TRACE + start_meas(&UE->generic_stat); +#endif + int rx_frame = NFAPI_SFNSF2SF(sfn_sf) < 4 ? (NFAPI_SFNSF2SFN(sfn_sf) + 1023) % 1024 : NFAPI_SFNSF2SFN(sfn_sf); // subtracting 4 from subframe_tx + int rx_subframe = NFAPI_SFNSF2SF(sfn_sf) < 4 ? NFAPI_SFNSF2SF(sfn_sf) + 6 : NFAPI_SFNSF2SF(sfn_sf) - 4; + LOG_D(MAC, "rx_frame %d rx_subframe %d\n", rx_frame, rx_subframe); + if (UE->mac_enabled == 1) { + ret = ue_scheduler(ue_Mod_id, + rx_frame, + rx_subframe, + NFAPI_SFNSF2SFN(sfn_sf), + NFAPI_SFNSF2SF(sfn_sf), + subframe_select(&UE->frame_parms, NFAPI_SFNSF2SF(sfn_sf)), + 0, + 0 /*FIXME CC_id*/); + + if (ret != CONNECTION_OK) { + LOG_E(PHY, "[UE %" PRIu8 "] Frame %" PRIu32 ", subframe %u %s\n", + UE->Mod_id, rx_frame, NFAPI_SFNSF2SF(sfn_sf), get_connectionloss_errstr(ret)); + } + } + +#if UE_TIMING_TRACE + stop_meas(&UE->generic_stat); +#endif + + // Prepare the future Tx data + if ((subframe_select(&UE->frame_parms, NFAPI_SFNSF2SF(sfn_sf)) == SF_UL) || + (UE->frame_parms.frame_type == FDD)) + { + if (UE->mode != loop_through_memory) + { + // We make the start of RA between consecutive UEs differ by 20 frames + //if ((UE_mac_inst[Mod_id].UE_mode[0] == PRACH && Mod_id == 0) || (UE_mac_inst[Mod_id].UE_mode[0] == PRACH && Mod_id>0 && rx_frame >= UE_mac_inst[Mod_id-1].ra_frame + 20) ) { + if (UE_mac_inst[ue_Mod_id].UE_mode[0] == RA_RESPONSE && + is_prach_subframe(&UE->frame_parms, NFAPI_SFNSF2SFN(sfn_sf), NFAPI_SFNSF2SF(sfn_sf))) + { + UE_mac_inst[ue_Mod_id].UE_mode[0] = PRACH; + } + LOG_D(MAC, "UE_mode: %d\n", UE_mac_inst[ue_Mod_id].UE_mode[0]); + if (UE_mac_inst[ue_Mod_id].UE_mode[0] == PRACH) + { //&& ue_Mod_id == next_Mod_id) { + next_ra_frame++; + if (next_ra_frame > 500) + { + // check if we have PRACH opportunity + if (is_prach_subframe(&UE->frame_parms, NFAPI_SFNSF2SFN(sfn_sf), NFAPI_SFNSF2SF(sfn_sf)) && UE_mac_inst[ue_Mod_id].SI_Decoded == 1) + { + // The one working strangely... + //if (is_prach_subframe(&UE->frame_parms,NFAPI_SFNSF2SFN(sfn_sf), NFAPI_SFNSF2SF(sfn_sf) && Mod_id == (module_id_t) init_ra_UE) ) { + PRACH_RESOURCES_t *prach_resources = ue_get_rach(ue_Mod_id, 0, NFAPI_SFNSF2SFN(sfn_sf), 0, NFAPI_SFNSF2SF(sfn_sf)); + if (prach_resources != NULL) + { + LOG_I(MAC, "preamble_received_tar_power: %d\n", + prach_resources->ra_PREAMBLE_RECEIVED_TARGET_POWER); + UE_mac_inst[ue_Mod_id].ra_frame = NFAPI_SFNSF2SFN(sfn_sf); + LOG_D(MAC, "UE_phy_stub_thread_rxn_txnp4 before RACH, Mod_id: %d frame %d subframe %d\n", ue_Mod_id, NFAPI_SFNSF2SFN(sfn_sf), NFAPI_SFNSF2SF(sfn_sf)); + fill_rach_indication_UE_MAC(ue_Mod_id, NFAPI_SFNSF2SFN(sfn_sf), NFAPI_SFNSF2SF(sfn_sf), UL_INFO, prach_resources->ra_PreambleIndex, prach_resources->ra_RNTI); + sent_any = true; + Msg1_transmitted(ue_Mod_id, 0, NFAPI_SFNSF2SFN(sfn_sf), 0); + UE_mac_inst[ue_Mod_id].UE_mode[0] = RA_RESPONSE; + next_Mod_id = ue_Mod_id + 1; + //next_ra_frame = (rx_frame + 20)%1000; + next_ra_frame = 0; + } + //ue_prach_procedures(ue,proc,eNB_id,abstraction_flag,mode); + } + } + } // mode is PRACH + + // Substitute call to phy_procedures Tx with call to phy_stub functions in order to trigger + // UE Tx procedures directly at the MAC layer, based on the received ul_config requests from the vnf (eNB). + // Generate UL_indications which correspond to UL traffic. + if (ul_config_req != NULL) + { //&& UE_mac_inst[Mod_id].ul_config_req->ul_config_request_body.ul_config_pdu_list != NULL){ + ul_config_req_UE_MAC(ul_config_req, NFAPI_SFNSF2SFN(sfn_sf), NFAPI_SFNSF2SF(sfn_sf), ue_Mod_id); + } + } + + phy_procedures_UE_SL_RX(UE, proc); + } + else + { + LOG_I(MAC, "Skipping subframe select statement proxy SFN.SF: %d.%d\n", + NFAPI_SFNSF2SFN(sfn_sf), NFAPI_SFNSF2SF(sfn_sf)); + if (ul_config_req != NULL) + { + LOG_I(MAC, "Skipping subframe select statement ul_config_req SFN.SF: %d.%d\n", + NFAPI_SFNSF2SFN(ul_config_req->sfn_sf), NFAPI_SFNSF2SF(ul_config_req->sfn_sf)); + } + } + } //for (Mod_id=0; Mod_id<NB_UE_INST; Mod_id++) + + if (UL_INFO->crc_ind.crc_indication_body.number_of_crcs > 0) { + //LOG_D(PHY,"UL_info->crc_ind.crc_indication_body.number_of_crcs:%d CRC_IND:SFN/SF:%d\n", UL_info->crc_ind.crc_indication_body.number_of_crcs, NFAPI_SFNSF2DEC(UL_info->crc_ind.sfn_sf)); + //LOG_I(MAC, "ul_config_req_UE_MAC 2.2, SFN/SF of PNF counter:%d.%d, number_of_crcs: %d \n", timer_frame, timer_subframe, UL_INFO->crc_ind.crc_indication_body.number_of_crcs); + send_standalone_msg(UL_INFO, UL_INFO->crc_ind.header.message_id); + sent_any = true; + //LOG_I(MAC, "ul_config_req_UE_MAC 2.21 \n"); + UL_INFO->crc_ind.crc_indication_body.number_of_crcs = 0; + } + + if (UL_INFO->rx_ind.rx_indication_body.number_of_pdus > 0) { + + //LOG_D(PHY,"UL_info->rx_ind.number_of_pdus:%d RX_IND:SFN/SF:%d\n", UL_info->rx_ind.rx_indication_body.number_of_pdus, NFAPI_SFNSF2DEC(UL_info->rx_ind.sfn_sf)); + //LOG_I(MAC, "ul_config_req_UE_MAC 2.3, SFN/SF of PNF counter:%d.%d, number_of_pdus: %d \n", timer_frame, timer_subframe, UL_INFO->rx_ind.rx_indication_body.number_of_pdus); + send_standalone_msg(UL_INFO, UL_INFO->rx_ind.header.message_id); + sent_any = true; + + //LOG_I(MAC, "ul_config_req_UE_MAC 2.31 \n"); + UL_INFO->rx_ind.rx_indication_body.number_of_pdus = 0; + } + + if (UL_INFO->cqi_ind.cqi_indication_body.number_of_cqis > 0) { + send_standalone_msg(UL_INFO, UL_INFO->cqi_ind.header.message_id); + sent_any = true; + UL_INFO->cqi_ind.cqi_indication_body.number_of_cqis = 0; + } + + if (UL_INFO->harq_ind.harq_indication_body.number_of_harqs > 0) { + //LOG_D(MAC, "ul_config_req_UE_MAC 2.4, SFN/SF of PNF counter:%d.%d, number_of_harqs: %d \n", timer_frame, timer_subframe, UL_INFO->harq_ind.harq_indication_body.number_of_harqs); + send_standalone_msg(UL_INFO, UL_INFO->harq_ind.header.message_id); + sent_any = true; + //LOG_I(MAC, "ul_config_req_UE_MAC 2.41 \n"); + UL_INFO->harq_ind.harq_indication_body.number_of_harqs = 0; + } + + if (UL_INFO->sr_ind.sr_indication_body.number_of_srs > 0) { + //LOG_I(MAC, "ul_config_req_UE_MAC 2.5, SFN/SF of PNF counter:%d.%d, number_of_srs: %d \n", timer_frame, timer_subframe, UL_INFO->sr_ind.sr_indication_body.number_of_srs); + send_standalone_msg(UL_INFO, UL_INFO->sr_ind.header.message_id); + sent_any = true; + //LOG_I(MAC, "ul_config_req_UE_MAC 2.51 \n"); + UL_INFO->sr_ind.sr_indication_body.number_of_srs = 0; + } + + // De-allocate memory of nfapi requests copies before next subframe round + if (dl_config_req_tx_req != NULL) { + if (dl_config_req_tx_req->dl_config_req->vendor_extension != NULL) { + free(dl_config_req_tx_req->dl_config_req->vendor_extension); + dl_config_req_tx_req->dl_config_req->vendor_extension = NULL; + } + + if (dl_config_req_tx_req->dl_config_req->dl_config_request_body.dl_config_pdu_list != NULL) { + free(dl_config_req_tx_req->dl_config_req->dl_config_request_body.dl_config_pdu_list); + dl_config_req_tx_req->dl_config_req->dl_config_request_body.dl_config_pdu_list = NULL; + } + nfapi_free_tx_req_pdu_list(dl_config_req_tx_req->tx_req_pdu_list); + dl_config_req_tx_req->tx_req_pdu_list = NULL; + + free(dl_config_req_tx_req->dl_config_req); + dl_config_req_tx_req->dl_config_req = NULL; + + free(dl_config_req_tx_req); + dl_config_req_tx_req = NULL; + } + + if (ul_config_req != NULL) { + if (ul_config_req->ul_config_request_body.ul_config_pdu_list != NULL) { + free(ul_config_req->ul_config_request_body.ul_config_pdu_list); + ul_config_req->ul_config_request_body.ul_config_pdu_list = NULL; + } + + free(ul_config_req); + ul_config_req = NULL; + } + + if (hi_dci0_req != NULL) { + if (hi_dci0_req->hi_dci0_request_body.hi_dci0_pdu_list != NULL) { + free(hi_dci0_req->hi_dci0_request_body.hi_dci0_pdu_list); + hi_dci0_req->hi_dci0_request_body.hi_dci0_pdu_list = NULL; + } + + free(hi_dci0_req); + hi_dci0_req = NULL; + } + if (!sent_any) + { + send_standalone_dummy(); + } + } + + // Free UL_INFO messages + free(UL_INFO->cqi_ind.cqi_indication_body.cqi_raw_pdu_list); + UL_INFO->cqi_ind.cqi_indication_body.cqi_raw_pdu_list = NULL; + free(UL_INFO->cqi_ind.cqi_indication_body.cqi_pdu_list); + UL_INFO->cqi_ind.cqi_indication_body.cqi_pdu_list = NULL; + free(UL_INFO->sr_ind.sr_indication_body.sr_pdu_list); + UL_INFO->sr_ind.sr_indication_body.sr_pdu_list = NULL; + free(UL_INFO->harq_ind.harq_indication_body.harq_pdu_list); + UL_INFO->harq_ind.harq_indication_body.harq_pdu_list = NULL; + free(UL_INFO->crc_ind.crc_indication_body.crc_pdu_list); + UL_INFO->crc_ind.crc_indication_body.crc_pdu_list = NULL; + free(UL_INFO->rx_ind.rx_indication_body.rx_pdu_list); + UL_INFO->rx_ind.rx_indication_body.rx_pdu_list = NULL; + free(UL_INFO); + UL_INFO = NULL; + + // thread finished + free(arg); + return NULL; +} /*! * \brief This is the UE thread for RX subframe n and TX subframe n+4. @@ -967,6 +1364,7 @@ void ue_stub_rx_handler(unsigned int num_bytes, static void *UE_phy_stub_single_thread_rxn_txnp4(void *arg) { +#if 0 // TODO: doesn't currently compile, obviated by multi-ue proxy thread_top_init("UE_phy_stub_thread_rxn_txnp4",1,870000L,1000000L,1000000L); // for multipule UE's L2-emulator //module_id_t Mod_id = 0; @@ -1012,7 +1410,7 @@ static void *UE_phy_stub_single_thread_rxn_txnp4(void *arg) dl_config_req = NULL; ul_config_req = NULL; hi_dci0_req = NULL; - tx_request_pdu_list = NULL; + tx_req_pdu_list = NULL; // waiting for all UE's threads set phy_stub_ticking->num_single_thread[ue_thread_id] = -1. do { @@ -1108,7 +1506,7 @@ static void *UE_phy_stub_single_thread_rxn_txnp4(void *arg) } } - if (dl_config_req && tx_request_pdu_list) { + if (dl_config_req && tx_req_pdu_list) { nfapi_dl_config_request_body_t* dl_config_req_body = &dl_config_req->dl_config_request_body; for (int i = 0; i < dl_config_req_body->number_pdu; ++i) { nfapi_dl_config_request_pdu_t* pdu = &dl_config_req_body->dl_config_pdu_list[i]; @@ -1322,16 +1720,16 @@ static void *UE_phy_stub_single_thread_rxn_txnp4(void *arg) dl_config_req = NULL; } - if(tx_request_pdu_list!=NULL) { + if(tx_req_pdu_list!=NULL) { for (int i = 0; i < tx_req_num_elems; i++) { - for (int j = 0; j < tx_request_pdu_list[i].num_segments; j++) { - free(tx_request_pdu_list[i].segments[j].segment_data); - tx_request_pdu_list[i].segments[j].segment_data = NULL; + for (int j = 0; j < tx_req_pdu_list[i].num_segments; j++) { + free(tx_req_pdu_list[i].segments[j].segment_data); + tx_req_pdu_list[i].segments[j].segment_data = NULL; } } tx_req_num_elems = 0; - free(tx_request_pdu_list); - tx_request_pdu_list = NULL; + free(tx_req_pdu_list); + tx_req_pdu_list = NULL; } if(ul_config_req!=NULL) { @@ -1371,10 +1769,11 @@ static void *UE_phy_stub_single_thread_rxn_txnp4(void *arg) UL_INFO->rx_ind.rx_indication_body.rx_pdu_list = NULL; free(UL_INFO); UL_INFO = NULL; +#endif // disabled UE_phy_stub_single_thread_rxn_txnp4 // thread finished free(arg); - return &UE_thread_rxtx_retval; + return NULL; } @@ -1388,6 +1787,7 @@ static void *UE_phy_stub_single_thread_rxn_txnp4(void *arg) static void *UE_phy_stub_thread_rxn_txnp4(void *arg) { + #if 0 thread_top_init("UE_phy_stub_thread_rxn_txnp4",1,870000L,1000000L,1000000L); module_id_t Mod_id = 0; static __thread int UE_thread_rxtx_retval; @@ -1536,10 +1936,10 @@ static void *UE_phy_stub_thread_rxn_txnp4(void *arg) phy_procedures_UE_SL_RX(UE,proc); } - + #endif // disabled // thread finished free(arg); - return &UE_thread_rxtx_retval; + return NULL; //return &UE_thread_rxtx_retval; } @@ -1607,6 +2007,8 @@ void *UE_thread(void *arg) oai_exit=1; } + log_scheduler(__func__); + while (!oai_exit) { if (IS_SOFTMODEM_BASICSIM) while (!(UE->proc.instance_cnt_synch < 0)) { @@ -1973,7 +2375,7 @@ void init_UE_single_thread_stub(int nb_inst) AssertFatal(PHY_vars_UE_g[i]!=NULL,"PHY_vars_UE_g[inst] is NULL\n"); AssertFatal(PHY_vars_UE_g[i][0]!=NULL,"PHY_vars_UE_g[inst][0] is NULL\n"); - if(NFAPI_MODE==NFAPI_UE_STUB_PNF) { + if(NFAPI_MODE==NFAPI_UE_STUB_PNF || NFAPI_MODE==NFAPI_MODE_STANDALONE_PNF) { #ifdef NAS_UE MessageDef *message_p; message_p = itti_alloc_new_message(TASK_NAS_UE, 0, INITIALIZE_MESSAGE); @@ -1993,6 +2395,13 @@ void init_UE_single_thread_stub(int nb_inst) //int nb_threads=RX_NB_TH; int nb_threads=1; + void* (*task_func)(void*); + if (NFAPI_MODE == NFAPI_MODE_STANDALONE_PNF) { + task_func = UE_phy_stub_standalone_pnf_task; + } else { + task_func = UE_phy_stub_single_thread_rxn_txnp4; + } + for(uint16_t ue_thread_id = 0; ue_thread_id < NB_THREAD_INST; ue_thread_id++) { UE = PHY_vars_UE_g[ue_thread_id][0]; @@ -2009,7 +2418,8 @@ void init_UE_single_thread_stub(int nb_inst) UE->proc.proc_rxtx[i].sub_frame_start=i; UE->proc.proc_rxtx[i].sub_frame_step=nb_threads; printf("Init_UE_threads rtd %d proc %d nb_threads %d i %d\n",rtd->proc->sub_frame_start, UE->proc.proc_rxtx[i].sub_frame_start,nb_threads, i); - pthread_create(&UE->proc.proc_rxtx[i].pthread_rxtx, NULL, UE_phy_stub_single_thread_rxn_txnp4, rtd); + pthread_create(&UE->proc.proc_rxtx[i].pthread_rxtx, NULL, task_func, rtd); + pthread_setname_np(UE->proc.proc_rxtx[i].pthread_rxtx, "oai:ue-phy"); } } @@ -2239,7 +2649,7 @@ static void *timer_thread( void *param ) pdu.header.packet_type = TTI_SYNC; pdu.header.absSF = (timer_frame*10)+timer_subframe; - if (NFAPI_MODE != NFAPI_UE_STUB_PNF) { + if (NFAPI_MODE != NFAPI_UE_STUB_PNF && NFAPI_MODE != NFAPI_MODE_STANDALONE_PNF) { multicast_link_write_sock(0, (char *)&pdu, sizeof(UE_tport_header_t)); diff --git a/targets/RT/USER/lte-uesoftmodem.c b/targets/RT/USER/lte-uesoftmodem.c index da9b0fdfbacecaedef66ffbed1c99e6c54fc4275..4395694bf40823415794a57a8ca4d7d01fbc7b0c 100644 --- a/targets/RT/USER/lte-uesoftmodem.c +++ b/targets/RT/USER/lte-uesoftmodem.c @@ -34,9 +34,6 @@ #define _GNU_SOURCE /* See feature_test_macros(7) */ #include <sched.h> -#include "rt_wrapper.h" - - #undef MALLOC //there are two conflicting definitions, so we better make sure we don't use it at all #include "assertions.h" @@ -66,6 +63,7 @@ #include "LAYER2/MAC/mac_proto.h" #include "RRC/LTE/rrc_vars.h" #include "PHY_INTERFACE/phy_interface_vars.h" +#include "PHY_INTERFACE/phy_stub_UE.h" #include "PHY/TOOLS/phy_scope_interface.h" #include "common/utils/LOG/log.h" #include "nfapi/oai_integration/vendor_ext.h" @@ -78,12 +76,10 @@ #include "create_tasks.h" #include "system.h" - #include "lte-softmodem.h" - +#include "executables/softmodem-common.h" /* temporary compilation wokaround (UE/eNB split */ -uint16_t sf_ahead; pthread_cond_t nfapi_sync_cond; @@ -91,7 +87,7 @@ pthread_mutex_t nfapi_sync_mutex; int nfapi_sync_var=-1; //!< protected by mutex \ref nfapi_sync_mutex -uint16_t sf_ahead=2; +uint16_t sf_ahead=4; int tddflag; char *emul_iface; @@ -188,9 +184,10 @@ int oaisim_flag=0; */ uint8_t abstraction_flag=0; +bler_struct bler_data[NUM_MCS]; // needed for pdcp.c RAN_CONTEXT_t RC; - +instance_t CUuniqInstance=0; /* forward declarations */ void set_default_frame_parms(LTE_DL_FRAME_PARMS *frame_parms[MAX_NUM_CCs]); @@ -276,7 +273,7 @@ void exit_function(const char *file, const char *function, const int line, const } extern int16_t dlsch_demod_shift; - +uint16_t node_number; static void get_options(void) { int CC_id=0; int tddflag=0; @@ -520,7 +517,7 @@ int restart_L1L2(module_id_t enb_id) { return 0; } -void init_pdcp(void) { +static void init_pdcp(int ue_id) { uint32_t pdcp_initmask = (!IS_SOFTMODEM_NOS1) ? LINK_ENB_PDCP_TO_GTPV1U_BIT : (LINK_ENB_PDCP_TO_GTPV1U_BIT | PDCP_USE_NETLINK_BIT | LINK_ENB_PDCP_TO_IP_DRIVER_BIT); if (IS_SOFTMODEM_BASICSIM || IS_SOFTMODEM_RFSIM || (nfapi_getmode()==NFAPI_UE_STUB_PNF)) { @@ -530,7 +527,7 @@ void init_pdcp(void) { if (IS_SOFTMODEM_NOKRNMOD) pdcp_initmask = pdcp_initmask | UE_NAS_USE_TUN_BIT; - pdcp_module_init(pdcp_initmask); + pdcp_module_init(pdcp_initmask, ue_id); pdcp_set_rlc_data_req_func((send_rlc_data_req_func_t) rlc_data_req); pdcp_set_pdcp_data_ind_func((pdcp_data_ind_func_t) pdcp_data_ind); } @@ -542,6 +539,7 @@ AssertFatal(false,""); } int main( int argc, char **argv ) { + int CC_id; uint8_t abstraction_flag=0; // Default value for the number of UEs. It will hold, @@ -558,14 +556,19 @@ int main( int argc, char **argv ) { mode = normal_txrx; memset(&openair0_cfg[0],0,sizeof(openair0_config_t)*MAX_CARDS); - set_latency_target(); logInit(); + set_latency_target(); printf("Reading in command-line options\n"); for (int i=0; i<MAX_NUM_CCs; i++) tx_max_power[i]=23; get_options (); + if (NFAPI_MODE == NFAPI_MODE_STANDALONE_PNF) { + sf_ahead = 1; + } + printf("sf_ahead = %d\n", sf_ahead); + EPC_MODE_ENABLED = !IS_SOFTMODEM_NOS1; printf("Running with %d UE instances\n",NB_UE_INST); @@ -600,7 +603,16 @@ int main( int argc, char **argv ) { MSC_INIT(MSC_E_UTRAN, ADDED_QUEUES_MAX+TASK_MAX); init_opt(); - init_pdcp(); + ue_id_g = (node_number == 0) ? 0 : node_number-2; //ue_id_g = 0, 1, ..., + if(node_number == 0) + { + init_pdcp(0); + } + else + { + init_pdcp(node_number-1); + } + //TTN for D2D printf ("RRC control socket\n"); rrc_control_socket_init(); @@ -608,7 +620,6 @@ int main( int argc, char **argv ) { pdcp_pc5_socket_init(); // to make a graceful exit when ctrl-c is pressed set_softmodem_sighandler(); - check_clock(); #ifndef PACKAGE_VERSION # define PACKAGE_VERSION "UNKNOWN-EXPERIMENTAL" #endif @@ -623,7 +634,7 @@ int main( int argc, char **argv ) { NB_INST=1; - if(NFAPI_MODE==NFAPI_UE_STUB_PNF) { + if(NFAPI_MODE==NFAPI_UE_STUB_PNF || NFAPI_MODE==NFAPI_MODE_STANDALONE_PNF) { PHY_vars_UE_g = malloc(sizeof(PHY_VARS_UE **)*NB_UE_INST); for (int i=0; i<NB_UE_INST; i++) { @@ -641,59 +652,13 @@ int main( int argc, char **argv ) { cpuf=get_cpu_freq_GHz(); - - -#if 0 // #ifndef DEADLINE_SCHEDULER - - printf("NO deadline scheduler\n"); - /* Currently we set affinity for UHD to CPU 0 for eNB/UE and only if number of CPUS >2 */ - cpu_set_t cpuset; - int s; - char cpu_affinity[1024]; - CPU_ZERO(&cpuset); -#ifdef CPU_AFFINITY - int j; - if (get_nprocs() > 2) { - for (j = 2; j < get_nprocs(); j++) - CPU_SET(j, &cpuset); - - s = pthread_setaffinity_np(pthread_self(), sizeof(cpu_set_t), &cpuset); - - if (s != 0) { - perror( "pthread_setaffinity_np"); - exit_fun("Error setting processor affinity"); - } - LOG_I(HW, "Setting the affinity of main function to all CPUs, for device library to use CPU 0 only!\n"); - } - -#endif - /* Check the actual affinity mask assigned to the thread */ - s = pthread_getaffinity_np(pthread_self(), sizeof(cpu_set_t), &cpuset); - - if (s != 0) { - perror( "pthread_getaffinity_np"); - exit_fun("Error getting processor affinity "); - } - - memset(cpu_affinity, 0, sizeof(cpu_affinity)); - - for (int j = 0; j < CPU_SETSIZE; j++) { - if (CPU_ISSET(j, &cpuset)) { - char temp[1024]; - sprintf(temp, " CPU_%d ", j); - strcat(cpu_affinity, temp); - } - } - - LOG_I(HW, "CPU Affinity of main() function is... %s\n", cpu_affinity); -#endif if (create_tasks_ue(NB_UE_INST) < 0) { printf("cannot create ITTI tasks\n"); exit(-1); // need a softer mode } - if (NFAPI_MODE==NFAPI_UE_STUB_PNF) { // UE-STUB-PNF + if (NFAPI_MODE==NFAPI_UE_STUB_PNF || NFAPI_MODE==NFAPI_MODE_STANDALONE_PNF) { // UE-STUB-PNF UE_config_stub_pnf(); } @@ -708,6 +673,21 @@ int main( int argc, char **argv ) { //Panos: Temporarily we will be using single set of threads for multiple UEs. //init_UE_stub(1,eMBMS_active,uecap_xer_in,emul_iface); init_UE_stub_single_thread(NB_UE_INST,eMBMS_active,uecap_xer_in,emul_iface); + } else if (NFAPI_MODE==NFAPI_MODE_STANDALONE_PNF) { + init_queue(&dl_config_req_tx_req_queue); + init_queue(&hi_dci0_req_queue); + init_queue(&ul_config_req_queue); + + init_bler_table(); + + config_sync_var=0; + if (sem_init(&sfn_semaphore, 0, 0) != 0) + { + LOG_E(MAC, "sem_init() error\n"); + abort(); + } + init_UE_stub_single_thread(NB_UE_INST,eMBMS_active,uecap_xer_in,emul_iface); + init_UE_standalone_thread(ue_id_g); } else { init_UE(NB_UE_INST,eMBMS_active,uecap_xer_in,0,get_softmodem_params()->phy_test,UE_scan,UE_scan_carrier,mode,(int)rx_gain[0][0],tx_max_power[0], frame_parms[0]); @@ -780,8 +760,73 @@ int main( int argc, char **argv ) { if (PHY_vars_UE_g[0][0]->rfdevice.trx_end_func) PHY_vars_UE_g[0][0]->rfdevice.trx_end_func(&PHY_vars_UE_g[0][0]->rfdevice); + pdcp_module_cleanup(); terminate_opt(); logClean(); printf("Bye.\n"); return 0; } + + +// Read in each MCS file and build BLER-SINR-TB table +void init_bler_table(void) +{ + size_t bufSize = 1024; + char * line = NULL; + char * token; + char * temp = NULL; + const char *openair_dir = getenv("OPENAIR_DIR"); + if (!openair_dir) + { + LOG_E(MAC, "No $OPENAIR_DIR\n"); + abort(); + } + + // Maybe not needed... and may not work. + memset(bler_data, 0, sizeof(bler_data)); + + for (unsigned int i = 0; i < NUM_MCS; i++) + { + char fName[1024]; + snprintf(fName, sizeof(fName), "%s/openair1/SIMULATION/LTE_PHY/BLER_SIMULATIONS/AWGN/AWGN_results/bler_tx1_chan18_nrx1_mcs%d.csv", openair_dir, i); + FILE *pFile = fopen(fName, "r"); + if (!pFile) + { + LOG_E(MAC, "Bler File ERROR! - fopen(), file: %s\n", fName); + abort(); + } + int nlines = 0; + while (getline(&line, &bufSize, pFile) > 0) + { + if (!strncmp(line,"SNR",3)) + { + continue; + } + + if (nlines > NUM_SINR) + { + LOG_E(MAC, "BLER FILE ERROR - num lines greater than expected - file: %s\n", fName); + abort(); + } + + token = strtok_r(line, ";", &temp); + int ncols = 0; + while (token != NULL) + { + if (ncols > NUM_BLER_COL) + { + LOG_E(MAC, "BLER FILE ERROR - num of cols greater than expected\n"); + abort(); + } + + bler_data[i].bler_table[nlines][ncols] = strtof(token, NULL); + ncols++; + + token = strtok_r(NULL, ";", &temp); + } + nlines++; + } + bler_data[i].length = nlines; + fclose(pFile); + } +} diff --git a/targets/RT/USER/rt_wrapper.c b/targets/RT/USER/rt_wrapper.c deleted file mode 100644 index da3a2d3cfe2ea9456b409ee992db3fda92ee2c8f..0000000000000000000000000000000000000000 --- a/targets/RT/USER/rt_wrapper.c +++ /dev/null @@ -1,383 +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 - */ - -/*! \file rt_wrapper.h -* \brief provides a wrapper for the timing function, runtime calculations for real-time opeartions depending on weather RTAI or DEADLINE_SCHEDULER kernels are used or not -* \author F. Kaltenberger and Navid Nikaein -* \date 2013 -* \version 0.1 -* \company Eurecom -* \email: florian.kaltenberger@eurecom.fr, navid.nikaein@eurecom.fr -* \note -* \warning -*/ -#define _GNU_SOURCE -#include <stdio.h> -#include <string.h> -#include <unistd.h> -#include <sys/ioctl.h> -#include <sys/types.h> -#include <sys/mman.h> -#include <sched.h> -#include <linux/sched.h> -#include <signal.h> -#include <execinfo.h> -#include <getopt.h> -#include <sys/sysinfo.h> -#include "rt_wrapper.h" -#include "system.h" -#include <errno.h> -#include <common/utils/msc/msc.h> - -#include "openair1/PHY/defs_common.h" - -static int latency_target_fd = -1; -static int32_t latency_target_value = 0; -/* Latency trick - taken from cyclictest.c - * if the file /dev/cpu_dma_latency exists, - * open it and write a zero into it. This will tell - * the power management system not to transition to - * a high cstate (in fact, the system acts like idle=poll) - * When the fd to /dev/cpu_dma_latency is closed, the behavior - * goes back to the system default. - * - * Documentation/power/pm_qos_interface.txt - */ -void set_latency_target(void) { - struct stat s; - int ret; - - if (stat("/dev/cpu_dma_latency", &s) == 0) { - latency_target_fd = open("/dev/cpu_dma_latency", O_RDWR); - - if (latency_target_fd == -1) - return; - - ret = write(latency_target_fd, &latency_target_value, 4); - - if (ret == 0) { - printf("# error setting cpu_dma_latency to %d!: %s\n", latency_target_value, strerror(errno)); - close(latency_target_fd); - return; - } - - printf("# /dev/cpu_dma_latency set to %dus\n", latency_target_value); - } -} - - -struct timespec interval, next, now, res; -clockid_t clock_id = CLOCK_MONOTONIC; //other options are CLOCK_MONOTONIC, CLOCK_REALTIME, CLOCK_PROCESS_CPUTIME_ID, CLOCK_THREAD_CPUTIME_ID -RTIME rt_get_time_ns (void) -{ - clock_gettime(clock_id, &now); - return(now.tv_sec*1e9+now.tv_nsec); -} - -int rt_sleep_ns (RTIME x) -{ - int ret; - clock_gettime(clock_id, &now); - interval.tv_sec = x/((RTIME)1000000000); - interval.tv_nsec = x%((RTIME)1000000000); - //rt_printk("sleeping for %d sec and %d ns\n",interval.tv_sec,interval.tv_nsec); - next = now; - next.tv_sec += interval.tv_sec; - next.tv_nsec += interval.tv_nsec; - - if (next.tv_nsec>=1000000000) { - next.tv_nsec -= 1000000000; - next.tv_sec++; - } - - ret = clock_nanosleep(clock_id, TIMER_ABSTIME, &next, NULL); - - /* - if (ret==EFAULT) - rt_printk("rt_sleep_ns returned EFAULT (%d), reqested %d sec and %d ns\n",ret,next.tv_sec,next.tv_nsec); - if (ret==EINVAL) - rt_printk("rt_sleep_ns returned EINVAL (%d), reqested %d sec and %d ns\n",ret,next.tv_sec,next.tv_nsec); - if (ret==EINTR) - rt_printk("rt_sleep_ns returned EINTR (%d), reqested %d sec and %d ns\n",ret,next.tv_sec,next.tv_nsec); - */ - - return(ret); -} - -void check_clock(void) -{ - if (clock_getres(clock_id, &res)) { - printf("clock_getres failed"); - } else { - printf("reported resolution = %lld ns\n", (long long int) ((int) 1e9 * res.tv_sec) + (long long int) res.tv_nsec); - } -} - -uint16_t cell_processing_dl[6]={10,15,24,42,80,112}; -uint16_t platform_processing_dl=20; // upperbound for GPP, LXC, DOCKER and KVM -uint16_t user_processing_dl_a[6]={2,4,5,7,10,12}; -uint16_t user_processing_dl_b[6]={10, 15, 25, 70, 110, 150}; -uint16_t user_processing_dl_err[6]={20, 40, 60, 90, 120, 160}; -uint16_t protocol_processing_dl[6]={150, 250, 350, 450, 650, 800}; // assumption: max MCS 27 --> gives an upper bound for the transport block size : to be measured - -uint16_t cell_processing_ul[6]={10,15,24,42,80,112}; -uint16_t platform_processing_ul=30; // upperbound for GPP, LXC, DOCKER and KVM -uint16_t user_processing_ul_a[6]={5, 9, 12, 24, 33, 42}; -uint16_t user_processing_ul_b[6]={20, 30, 40, 76, 140, 200}; -uint16_t user_processing_ul_err[6]={15, 25, 32, 60, 80, 95}; -uint16_t protocol_processing_ul[6]={100, 200, 300, 400, 550, 700}; // assumption: max MCS 16 --> gives an upper bound for the transport block size - -int fill_modeled_runtime_table(uint16_t runtime_phy_rx[29][6], - uint16_t runtime_phy_tx[29][6]){ - //double cpu_freq; - //cpu_freq = get_cpu_freq_GHz(); - // target_dl_mcs - // target_ul_mcs - // frame_parms[0]->N_RB_DL - int i,j; - memset(runtime_phy_rx,0,sizeof(uint16_t)*29*6); - memset(runtime_phy_tx,0,sizeof(uint16_t)*29*6); - /* only the BBU/PHY procesing time */ - for (i=0;i<29;i++){ - for (j=0;j<6;j++){ - runtime_phy_rx[i][j] = cell_processing_ul[j] + platform_processing_ul + user_processing_ul_err[j] + user_processing_ul_a[j]*i+ user_processing_ul_b[j]; - runtime_phy_tx[i][j] = cell_processing_dl[j] + platform_processing_dl + user_processing_dl_err[j] + user_processing_dl_a[j]*i+ user_processing_dl_b[j]; - } - } - return 0; -} - -// int runtime_upper_layers[6]; // values for different RBs -// int runtime_phy_rx[29][6]; // SISO [MCS 0-28][RBs 0-5 : 6, 15, 25, 50, 75, 100] -// int runtime_phy_tx[29][6]; // SISO [MCS 0-28][RBs 0-5 : 6, 15, 25, 50, 75, 100] - -// target_dl_mcs - // target_ul_mcs - // frame_parms[0]->N_RB_DL - //runtime_upper_layers[6]; // values for different RBs - // int runtime_phy_rx[29][6]; // SISO [MCS 0-28][RBs 0-5 : 6, 15, 25, 50, 75, 100] - // int runtime_phy_tx[29][6] - -double get_runtime_tx(int tx_subframe, uint16_t runtime_phy_tx[29][6], uint32_t mcs, int N_RB_DL,double cpuf,int nb_tx_antenna){ - int i; - double runtime; - //printf("cpuf =%lf \n",cpuf); - switch(N_RB_DL){ - case 6: - i = 0; - break; - case 15: - i = 1; - break; - case 25: - i = 2; - break; - case 50: - i = 3; - break; - case 75: - i = 4; - break; - case 100: - i = 5; - break; - default: - i = 3; - break; - } - - runtime = ( (3.2/cpuf)*(double)runtime_phy_tx[mcs][i] + (3.2/cpuf)*(double)protocol_processing_dl[i])/1000 ; - printf("Setting tx %d runtime value (ms) = %lf\n",tx_subframe,runtime); - - return runtime; - } - -double get_runtime_rx(int rx_subframe, uint16_t runtime_phy_rx[29][6], uint32_t mcs, int N_RB_DL,double cpuf,int nb_rx_antenna){ - int i; - double runtime; - - //printf("N_RB_DL=%d cpuf =%lf \n",N_RB_DL, cpuf); - switch(N_RB_DL){ - case 6: - i = 0; - break; - case 15: - i = 1; - break; - case 25: - i = 2; - break; - case 50: - i = 3; - break; - case 75: - i = 4; - break; - case 100: - i = 5; - break; - default: - i = 3; - break; - } - - runtime = ((3.2/cpuf)*(double)runtime_phy_rx[mcs][i] + (3.2/cpuf)*(double)protocol_processing_ul[i])/1000 ; - printf("Setting rx %d runtime value (ms) = %lf \n",rx_subframe, runtime); - - return runtime; -} - -#ifdef DEADLINE_SCHEDULER -int sched_setattr(pid_t pid, const struct sched_attr *attr, unsigned int flags) -{ - - return syscall(__NR_sched_setattr, pid, attr, flags); -} - - -int sched_getattr(pid_t pid,struct sched_attr *attr,unsigned int size, unsigned int flags) -{ - - return syscall(__NR_sched_getattr, pid, attr, size, flags); -} - -#endif - -void thread_top_init(char *thread_name, - int affinity, - uint64_t runtime, - uint64_t deadline, - uint64_t period) { - - MSC_START_USE(); - -#ifdef DEADLINE_SCHEDULER - struct sched_attr attr; - - unsigned int flags = 0; - - attr.size = sizeof(attr); - attr.sched_flags = 0; - attr.sched_nice = 0; - attr.sched_priority = 0; - - attr.sched_policy = SCHED_DEADLINE; - attr.sched_runtime = runtime; - attr.sched_deadline = deadline; - attr.sched_period = period; - - if (sched_setattr(0, &attr, flags) < 0 ) { - perror("[SCHED] eNB tx thread: sched_setattr failed\n"); - fprintf(stderr,"sched_setattr Error = %s",strerror(errno)); - exit(1); - } - -#else //LOW_LATENCY - int policy, s, j; - struct sched_param sparam; - char cpu_affinity[1024]; - cpu_set_t cpuset; - int settingPriority = 1; - - /* Set affinity mask to include CPUs 2 to MAX_CPUS */ - /* CPU 0 is reserved for UHD threads */ - /* CPU 1 is reserved for all RX_TX threads */ - /* Enable CPU Affinity only if number of CPUs > 2 */ - CPU_ZERO(&cpuset); - -#ifdef CPU_AFFINITY - if (affinity == 0) { - LOG_W(HW,"thread_top_init() called with affinity==0, but overruled by #ifdef CPU_AFFINITY\n"); - } - else if (get_nprocs() > 2) - { - for (j = 2; j < get_nprocs(); j++) - CPU_SET(j, &cpuset); - s = pthread_setaffinity_np(pthread_self(), sizeof(cpu_set_t), &cpuset); - if (s != 0) - { - perror( "pthread_setaffinity_np"); - exit_fun("Error setting processor affinity"); - } - } -#else //CPU_AFFINITY - if (affinity) { - LOG_W(HW,"thread_top_init() called with affinity>0, but overruled by #ifndef CPU_AFFINITY.\n"); - } -#endif //CPU_AFFINITY - - /* Check the actual affinity mask assigned to the thread */ - s = pthread_getaffinity_np(pthread_self(), sizeof(cpu_set_t), &cpuset); - if (s != 0) - { - perror( "pthread_getaffinity_np"); - exit_fun("Error getting processor affinity "); - } - memset(cpu_affinity,0,sizeof(cpu_affinity)); - for (j = 0; j < 1024; j++) - { - if (CPU_ISSET(j, &cpuset)) - { - char temp[1024]; - sprintf (temp, " CPU_%d", j); - strcat(cpu_affinity, temp); - } - } - - if (checkIfFedoraDistribution()) - if (checkIfGenericKernelOnFedora()) - if (checkIfInsideContainer()) - settingPriority = 0; - - if (settingPriority) { - memset(&sparam, 0, sizeof(sparam)); - sparam.sched_priority = sched_get_priority_max(SCHED_FIFO); - policy = SCHED_FIFO; - - s = pthread_setschedparam(pthread_self(), policy, &sparam); - if (s != 0) { - perror("pthread_setschedparam : "); - exit_fun("Error setting thread priority"); - } - - s = pthread_getschedparam(pthread_self(), &policy, &sparam); - if (s != 0) { - perror("pthread_getschedparam : "); - exit_fun("Error getting thread priority"); - } - - pthread_setname_np(pthread_self(), thread_name); - - LOG_I(HW, "[SCHED][eNB] %s started on CPU %d, sched_policy = %s , priority = %d, CPU Affinity=%s \n",thread_name,sched_getcpu(), - (policy == SCHED_FIFO) ? "SCHED_FIFO" : - (policy == SCHED_RR) ? "SCHED_RR" : - (policy == SCHED_OTHER) ? "SCHED_OTHER" : - "???", - sparam.sched_priority, cpu_affinity ); - } - -#endif //LOW_LATENCY - - mlockall(MCL_CURRENT | MCL_FUTURE); - -} - - diff --git a/targets/RT/USER/rt_wrapper.h b/targets/RT/USER/rt_wrapper.h deleted file mode 100644 index 32554d9e17990a2de5f532834a292368ca03429b..0000000000000000000000000000000000000000 --- a/targets/RT/USER/rt_wrapper.h +++ /dev/null @@ -1,132 +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 - */ - -/*! \file rt_wrapper.h -* \brief provides a wrapper for the timing function for real-time opeartions. It also implements an API for the SCHED_DEADLINE kernel scheduler. -* \author F. Kaltenberger and Navid Nikaein -* \date 2013 -* \version 0.1 -* \company Eurecom -* \email: florian.kaltenberger@eurecom.fr, navid.nikaein@eurecom.fr -* \note -* \warning This code will be removed when a legacy libc API becomes available. -*/ - -#ifndef _RT_WRAPPER_H_ -#define _RT_WRAPPER_H_ - -#define _GNU_SOURCE -#include <time.h> -#include <errno.h> -#include <stdint.h> -#include <sys/stat.h> -#include <fcntl.h> -#include <pthread.h> -#include <linux/kernel.h> -#include <linux/types.h> -#include <syscall.h> -#include <math.h> -#include <sched.h> -#include <sys/ioctl.h> -#include <sys/types.h> -#include <sys/mman.h> -#include <sched.h> -#include <linux/sched.h> -#include <signal.h> -#include <execinfo.h> -#include <getopt.h> -#include <sys/sysinfo.h> - -#include "common/utils/LOG/log_extern.h" -#include "msc.h" - -#define RTIME long long int - -#define rt_printk printf - -void set_latency_target(void); - -RTIME rt_get_time_ns (void); - -int rt_sleep_ns (RTIME x); - -void check_clock(void); - -int fill_modeled_runtime_table(uint16_t runtime_phy_rx[29][6],uint16_t runtime_phy_tx[29][6]); - -double get_runtime_tx(int tx_subframe, uint16_t runtime_phy_tx[29][6],uint32_t mcs, int N_RB_DL,double cpuf,int nb_tx_antenna); - -double get_runtime_rx(int rx_subframe, uint16_t runtime_phy_rx[29][6], uint32_t mcs, int N_RB_DL,double cpuf,int nb_rx_antenna); -/** - * see https://www.kernel.org/doc/Documentation/scheduler/sched-deadline.txt or - * http://www.blaess.fr/christophe/2014/04/05/utiliser-un-appel-systeme-inconnu-de-la-libc/ - */ -#ifdef DEADLINE_SCHEDULER - -#define gettid() syscall(__NR_gettid) - -#define SCHED_DEADLINE 6 - -/* XXX use the proper syscall numbers */ -#ifdef __x86_64__ -#define __NR_sched_setattr 314 -#define __NR_sched_getattr 315 -#endif - -#ifdef __i386__ -#define __NR_sched_setattr 351 -#define __NR_sched_getattr 352 -#endif - -struct sched_attr { - __u32 size; - - __u32 sched_policy; - __u64 sched_flags; - - /* SCHED_NORMAL, SCHED_BATCH */ - __s32 sched_nice; - - /* SCHED_FIFO, SCHED_RR */ - __u32 sched_priority; - - /* SCHED_DEADLINE (nsec) */ - __u64 sched_runtime; - __u64 sched_deadline; - __u64 sched_period; -}; - -int sched_setattr(pid_t pid, const struct sched_attr *attr, unsigned int flags); - -int sched_getattr(pid_t pid,struct sched_attr *attr,unsigned int size, unsigned int flags); - -#endif - -#define gettid() syscall(__NR_gettid) // for gettid - - -void thread_top_init(char *thread_name, - int affinity, - uint64_t runtime, - uint64_t deadline, - uint64_t period); - -#endif diff --git a/targets/RT/USER/ru_control.c b/targets/RT/USER/ru_control.c index 95b5ce6155bec826e009b221ad2881359349e496..7280c785232af9346402aa07e37ca6861ed16a1e 100644 --- a/targets/RT/USER/ru_control.c +++ b/targets/RT/USER/ru_control.c @@ -42,7 +42,6 @@ #include <execinfo.h> #include <getopt.h> #include <sys/sysinfo.h> -#include "rt_wrapper.h" #undef MALLOC //there are two conflicting definitions, so we better make sure we don't use it at all diff --git a/targets/build_helper.bash b/targets/build_helper.bash deleted file mode 100755 index 9c98ef85b0173ce4f9bac95a529d0363f727f8c1..0000000000000000000000000000000000000000 --- a/targets/build_helper.bash +++ /dev/null @@ -1,1315 +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 -# */ -################################################################################ -# file build_helper.bash -# brief -# author Lionel Gauthier and Navid Nikaein -# company Eurecom -# email: lionel.gauthier@eurecom.fr and navid.nikaein@eurecom.fr -# -####################################### -# Helper Func -###################################### - -declare ROOT_UID=0 -declare E_NOTROOT=67 -declare NUM_CPU=`cat /proc/cpuinfo | grep processor | wc -l` -declare OAI_INSTALLED=1 -declare PWD=`pwd` -declare USER=`whoami` -declare BUILD_FROM_MAKEFILE=0 -declare SUDO='' -declare PW='' -declare UBUNTU_REL=`lsb_release -r | cut -f2` -declare UBUNTU_REL_NAME=`lsb_release -cs` - -set_build_from_makefile(){ - BUILD_FROM_MAKEFILE=$1 -} - -check_for_root_rights() { - - # if [[ $EUID -ne $ROOT_EUID ]]; then - if [ $USER != "root" ]; then - SUDO="sudo -E " - echo "Run as a sudoers" - return 1 - else - echo "Run as a root" - return 0 - fi -} - -test_install_package() { - # usage: test_install_package package_name - - if [ $# -eq 1 ]; then - dpkg -s "$1" > /dev/null 2>&1 && { - echo "$1 is installed." - } || { - echo "$1 is not installed." - OAI_INSTALLED=0 - $SUDO apt-get install -y $@ - } - fi -} - -test_uninstall_package() { - - if [ $# -eq 1 ]; then - dpkg -s "$1" > /dev/null 2>&1 && { - $SUDO apt-get remove --assume-yes $1 - echo "$1 is uninstalled." - } || { - echo "$1 is not installed." - } - fi -} -test_command_install_script() { - # usage: test_command_install_script searched_binary script_to_be_invoked_if_binary_not_found - command -v $1 >/dev/null 2>&1 || { echo_warning "Program $1 is not installed. Trying installing it." >&2; bash $2; command -v $1 >/dev/null 2>&1 || { echo_fatal "Program $1 is not installed. Aborting." >&2; };} - echo_success "$1 available" -} - - -check_for_machine_type(){ - MACHINE_TYPE=`uname -m` - if [ ${MACHINE_TYPE} = "x86_64" ]; then - return 64 # 64-bit stuff here - else - if [ ${MACHINE_TYPE} = "i686" ]; then - return 32 # 32-bit stuff here - else - return -1 - fi - fi -} - -#################################################### -## OAI related functions -##################################################### - -#################################################### -# 1. install the required packages -#################################################### - -make_certs(){ - - # for certtificate generation - rm -rf demoCA - mkdir -m 777 -p demoCA - echo 01 > demoCA/serial - touch demoCA/index.txt - - echo "creating the certificate" - - user=$(whoami) - HOSTNAME=$(hostname -f) - - echo "Creating certificate for user '$HOSTNAME'" - -# CA self certificate - openssl req -new -batch -x509 -days 3650 -nodes -newkey rsa:1024 -out cacert.pem -keyout cakey.pem -subj /CN=eur/C=FR/ST=PACA/L=Aix/O=Eurecom/OU=CM - - # openssl genrsa -out user.key.pem 1024 - openssl genrsa -out hss.key.pem 1024 - #openssl req -new -batch -out user.csr.pem -key user.key.pem -subj /CN=$HOSTNAME.eur/C=FR/ST=PACA/L=Aix/O=Eurecom/OU=CM - openssl req -new -batch -out hss.csr.pem -key hss.key.pem -subj /CN=hss.eur/C=FR/ST=PACA/L=Aix/O=Eurecom/OU=CM - openssl ca -cert cacert.pem -keyfile cakey.pem -in hss.csr.pem -out hss.cert.pem -outdir . -batch - - if [ ! -d /usr/local/etc/freeDiameter ]; then - echo "Creating non existing directory: /usr/local/etc/freeDiameter/" - $SUDO mkdir /usr/local/etc/freeDiameter/ - fi - - echo "Copying *.pem to /usr/local/etc/freeDiameter/" - $SUDO cp *.pem /usr/local/etc/freeDiameter/ - mv *.pem bin/ - -# openssl genrsa -out ubuntu.key.pem 1024 -# openssl req -new -batch -x509 -out ubuntu.csr.pem -key ubuntu.key.pem -subj /CN=ubuntu.localdomain/C=FR/ST=BdR/L=Aix/O=fD/OU=Tests -# openssl ca -cert cacert.pem -keyfile cakey.pem -in ubuntu.csr.pem -out ubuntu.cert.pem -outdir . -batch - -} - -check_install_nettle(){ - if [ ! -f ./.lock_oaibuild ]; then - if [ $UBUNTU_REL = "12.04" ]; then - test_uninstall_package nettle-dev - test_uninstall_package nettle-bin - - if [ ! -d /usr/local/src/ ]; then - echo "/usr/local/src/ doesn't exist please create one" - exit -1 - fi - - if [ ! -w /usr/local/src/ ]; then - echo "You don't have permissions to write to /usr/local/src/, installing as a sudoer" - # exit -1 - fi - - cd /usr/local/src/ - - echo "Downloading nettle archive" - - if [ -f nettle-2.5.tar.gz ]; then - $SUDO rm -f nettle-2.5.tar.gz - fi - if [ -f nettle-2.5.tar ]; then - $SUDO rm -f nettle-2.5.tar - fi - if [ -d nettle-2.5 ]; then - $SUDO rm -rf nettle-2.5/ - fi - - - $SUDO wget ftp://ftp.lysator.liu.se/pub/security/lsh/nettle-2.5.tar.gz - $SUDO gunzip nettle-2.5.tar.gz - $SUDO echo "Uncompressing nettle archive" - $SUDO tar -xf nettle-2.5.tar - cd nettle-2.5/ - $SUDO ./configure --disable-openssl --enable-shared --prefix=/usr - if [ $? -ne 0 ]; then - exit -1 - fi - echo "Compiling nettle" - $SUDO make -j $NUM_CPU - $SUDO make check - $SUDO make install - cd ../ - fi - fi -} - -check_install_freediamter(){ - - if [ $UBUNTU_REL = "12.04" ]; then - - if [ ! -d /usr/local/src/ ]; then - echo "/usr/local/src/ doesn't exist please create one" - exit -1 - fi - - if [ ! -w /usr/local/src/ ]; then - echo "You don't have permissions to write to /usr/local/src/, installing as a sudoer" -# exit -1 - fi - - cd /usr/local/src/ - - echo "Downloading nettle archive" - - if [ -f nettle-2.5.tar.gz ]; then - $SUDO rm -f nettle-2.5.tar.gz - fi - if [ -f nettle-2.5.tar ]; then - $SUDO rm -f nettle-2.5.tar - fi - if [ -d nettle-2.5 ]; then - $SUDO rm -rf nettle-2.5/ - fi - - - $SUDO wget ftp://ftp.lysator.liu.se/pub/security/lsh/nettle-2.5.tar.gz - $SUDO gunzip nettle-2.5.tar.gz - $SUDO echo "Uncompressing nettle archive" - $SUDO tar -xf nettle-2.5.tar - cd nettle-2.5/ - $SUDO ./configure --disable-openssl --enable-shared --prefix=/usr - if [ $? -ne 0 ]; then - exit -1 - fi - echo "Compiling nettle" - $SUDO make -j $NUM_CPU - $SUDO make check - $SUDO make install - cd ../ - fi - - echo "Downloading gnutls archive" - - if [ -f gnutls-3.1.23.tar.xz ]; then - $SUDO rm -f gnutls-3.1.23.tar.xz - fi - if [ -d gnutls-3.1.23/ ]; then - $SUDO rm -rf gnutls-3.1.23/ - fi - - test_uninstall_package libgnutls-dev - - $SUDO wget ftp://ftp.gnutls.org/gcrypt/gnutls/v3.1/gnutls-3.1.23.tar.xz - $SUDO tar -xf gnutls-3.1.23.tar.xz - echo "Uncompressing gnutls archive ($PWD)" - cd gnutls-3.1.23/ - $SUDO ./configure --prefix=/usr - if [ $? -ne 0 ]; then - exit -1 - fi - echo "Compiling gnutls" - $SUDO make -j $NUM_CPU - $SUDO make install - cd ../ - - echo "Downloading freeDiameter archive" - - if [ -f 1.1.5.tar.gz ]; then - $SUDO rm -f 1.1.5.tar.gz - fi - if [ -d freeDiameter-1.1.5/ ]; then - $SUDO rm -rf freeDiameter-1.1.5/ - fi - - $SUDO wget http://www.freediameter.net/hg/freeDiameter/archive/1.1.5.tar.gz - $SUDO tar -xzf 1.1.5.tar.gz - echo "Uncompressing freeDiameter archive" - cd freeDiameter-1.1.5 - $SUDO patch -p1 < $OPENAIR3_DIR/S6A/freediameter/freediameter-1.1.5.patch - $SUDO mkdir build - cd build - $SUDO cmake -DCMAKE_INSTALL_PREFIX:PATH=/usr ../ - if [ $? -ne 0 ]; then - exit -1 - fi - echo "Compiling freeDiameter" - $SUDO make -j $NUM_CPU -#make help - $SUDO make test - $SUDO sudo make install - -# make_certs - -} - - -test_is_host_reachable() { - ping -c 1 $1 > /dev/null || { echo_fatal "$2 host $1 does not respond to ping" >&2 ; } - echo_success "$2 host $1 is reachable" -} - - -check_epc_s6a_certificate() { - if [ -d /usr/local/etc/freeDiameter ] - then - if [ -f /usr/local/etc/freeDiameter/user.cert.pem ] - then - full_hostname=`cat /usr/local/etc/freeDiameter/user.cert.pem | grep "Subject" | grep "CN" | cut -d '=' -f6` - if [ a$full_hostname == a`hostname`.${1:-'eur'} ] - then - echo_success "EPC S6A: Found valid certificate in /usr/local/etc/freeDiameter" - return 0 - fi - fi - fi - echo_error "EPC S6A: Did not find valid certificate in /usr/local/etc/freeDiameter" - echo_warning "EPC S6A: generatting new certificate in /usr/local/etc/freeDiameter..." - cd $OPENAIR3_DIR/S6A/freediameter - ./make_certs.sh ${1:-'eur'} - if [ $# -lt 2 ] ; then - check_epc_s6a_certificate ${1:-'eur'} 2 - return $? - else - exit 1 - fi -} - - -check_hss_s6a_certificate() { - if [ -d /usr/local/etc/freeDiameter ]; then - if [ -f /usr/local/etc/freeDiameter/hss.cert.pem ]; then - full_hostname=`cat /usr/local/etc/freeDiameter/hss.cert.pem | grep "Subject" | grep "CN" | cut -d '=' -f6` - if [ a$full_hostname == a`hostname`.${1:-'eur'} ] - then - echo_success "HSS S6A: Found valid certificate in /usr/local/etc/freeDiameter" - return 0 - else - echo_error "Bad hss hostname found in cert file: "$full_hostname " hostname is "`hostname` - fi - fi - fi - echo_error "S6A: Did not find valid certificate in /usr/local/etc/freeDiameter" - echo_warning "S6A: generatting new certificate in /usr/local/etc/freeDiameter..." - cd $OPENAIR3_DIR/OPENAIRHSS/conf - ./make_certs.sh ${1:-'eur'} - if [ $# -lt 2 ] ; then - check_hss_s6a_certificate ${1:-'eur'} 2 - return $? - else - exit 1 - fi -} - -check_install_usrp_uhd_driver(){ - if [ ! -f /etc/apt/sources.list.d/ettus.list ] ; then - $SUDO bash -c 'echo "deb http://files.ettus.com/binaries/uhd/repo/uhd/ubuntu/`lsb_release -cs` `lsb_release -cs` main" >> /etc/apt/sources.list.d/ettus.list' - $SUDO apt-get update - fi - $SUDO apt-get install -t $UBUNTU_REL_NAME uhd - test_install_package python - test_install_package libboost-all-dev - test_install_package libusb-1.0-0-dev - #test_install_package uhd -} - -check_install_oai_software() { - - if [ ! -f ./.lock_oaibuild ]; then - $SUDO apt-get update - if [ $UBUNTU_REL = "12.04" ]; then - test_uninstall_package nettle-dev - test_uninstall_package nettle-bin - else - test_install_package nettle-dev - test_install_package nettle-bin - fi - test_install_package autoconf - test_install_package automake - test_install_package bison - test_install_package build-essential - test_install_package dialog - test_install_package flex - test_install_package gawk - test_install_package gcc - test_install_package gdb - test_install_package make - test_install_package cmake - test_install_package openssh-client - test_install_package openssh-server - sudo service ssh start - test_install_package unzip - test_install_package autoconf - test_install_package automake - test_install_package bison - test_install_package build-essential - test_install_package check - test_install_package ethtool - test_install_package flex - test_install_package g++ - test_install_package gawk - test_install_package gcc - test_install_package gccxml - test_install_package gdb - test_install_package guile-2.0-dev - test_install_package iperf - test_install_package iproute - test_install_package iptables - test_install_package libatlas-base-dev - test_install_package libatlas-dev - test_install_package libblas3gf - test_install_package libblas-dev - test_install_package liblapack-dev - test_install_package liblapack-dev -# if [ $MACHINE_ARCH = 64 ]; then - test_install_package libconfig8-dev -# else -# test_install_package libconfig-dev -# fi - test_install_package libforms-bin - test_install_package libforms-dev - test_install_package libgcrypt11-dev - test_install_package libgmp-dev - test_install_package libgtk-3-dev - test_install_package libidn11-dev - test_install_package libidn2-0-dev - test_install_package libpgm-dev - test_install_package libpgm-5.1-0 - test_install_package libpthread-stubs0-dev - test_install_package libsctp1 - test_install_package libsctp-dev - test_install_package libtasn1-3-dev - test_install_package libxml2 - test_install_package libxml2-dev -# test_install_package linux-headers-`uname -r` - test_install_package openssl - test_install_package libssl-dev - test_install_package pkg-config - test_install_package python-dev - test_install_package python-pexpect - test_install_package sshfs - test_install_package subversion - test_install_package valgrind - test_install_package doxygen - test_install_package graphviz - -# test_install_package libboost-all-dev - - if [ $OAI_INSTALLED = 1 ]; then - touch ./.lock_oaibuild - fi - - else - echo_info "All the required packages installed: skip" - fi - -} - -check_install_hss_software() { - if [ ! -f ./.lock_oaibuild ]; then - $SUDO apt-get update - if [ $UBUNTU_REL = "12.04" ]; then - test_uninstall_package nettle-dev - test_uninstall_package nettle-bin - else - test_install_package nettle-dev - test_install_package nettle-bin - fi - test_install_package autoconf - test_install_package automake - test_install_package bison - test_install_package build-essential - test_install_package cmake - test_install_package cmake-curses-gui - test_install_package dialog - test_install_package dkms - test_install_package flex - test_install_package gawk - test_install_package gcc - test_install_package gdb - test_install_package guile-2.0-dev - test_install_package g++ - test_install_package libgmp-dev - test_install_package libgcrypt11-dev - test_install_package libidn11-dev - test_install_package libidn2-0-dev - test_install_package libmysqlclient-dev - test_install_package libtasn1-3-dev - test_install_package libsctp1 - test_install_package libsctp-dev - test_install_package libxml2-dev -# test_install_package linux-headers-`uname -r` - test_install_package make - test_install_package mysql-client - test_install_package mysql-server-core-5.5 - test_install_package mysql-server - test_install_package openssh-client - test_install_package openssh-server - sudo service ssh start - test_install_package phpmyadmin - test_install_package python-dev - test_install_package sshfs - test_install_package swig - test_install_package unzip -# test_install_package nettle-bin -# test_install_package nettle-dev - test_install_package valgrind - - if [ $OAI_INSTALLED = 1 ]; then - touch ./.lock_oaibuild - fi - - else - echo_info "All the required packages installed: skip" - fi - -} - -check_install_epc_software() { - - if [ ! -f ./.lock_oaibuild ]; then - $SUDO apt-get update - if [ $UBUNTU_REL = "12.04" ]; then - test_uninstall_package nettle-dev - test_uninstall_package nettle-bin - else - test_install_package nettle-dev - test_install_package nettle-bin - fi - test_install_package autoconf - test_install_package automake - test_install_package bison - test_install_package build-essential - test_install_package check - test_install_package cmake - test_install_package cmake-curses-gui - test_install_package dialog - test_install_package ethtool - test_install_package flex - test_install_package g++ - test_install_package gawk - test_install_package gcc - test_install_package gccxml - test_install_package gdb - test_install_package guile-2.0-dev - test_install_package gtkwave - test_install_package iperf - test_install_package iproute - test_install_package iptables - test_install_package iptables-dev - test_install_package libatlas-base-dev - test_install_package libatlas-dev - test_install_package libblas - test_install_package libblas-dev -# if [ $MACHINE_ARCH = 64 ]; then - test_install_package libconfig8-dev -# else -# test_install_package libconfig-dev -# fi - test_install_package libforms-bin - test_install_package libforms-dev - test_install_package libgcrypt11-dev - test_install_package libgmp-dev - test_install_package libgtk-3-dev - test_install_package libidn11-dev - test_install_package libidn2-0-dev - test_install_package libmysqlclient-dev - test_install_package libpgm-dev - test_install_package libpthread-stubs0-dev - test_install_package libsctp1 - test_install_package libsctp-dev - test_install_package libssl-dev - test_install_package libtasn1-3-dev - test_install_package libtool - test_install_package libxml2 - test_install_package libxml2-dev -# test_install_package linux-headers-`uname -r` - test_install_package make - test_install_package openssh-client - test_install_package openssh-server - $SUDO service ssh start - test_install_package openssl - test_install_package openvpn - test_install_package pkg-config - test_install_package python-dev - test_install_package sshfs - test_install_package subversion - test_install_package swig - test_install_package tshark - test_install_package uml-utilities - test_install_package unzip - test_install_package valgrind - test_install_package vlan - - if [ $OAI_INSTALLED = 1 ]; then - touch ./.lock_oaibuild - fi - - else - echo_info "All the required packages installed: skip" - fi - -} - -check_install_asn1c(){ - - test_command_install_script "asn1c" "$OPENAIR_TARGETS/SCRIPTS/install_asn1c_0.9.24.modified.bash $SUDO" - - # One mor check about version of asn1c - ASN1C_COMPILER_REQUIRED_VERSION_MESSAGE="ASN.1 Compiler, v0.9.24" - ASN1C_COMPILER_VERSION_MESSAGE=`asn1c -h 2>&1 | grep -i ASN\.1\ Compiler` - ##ASN1C_COMPILER_VERSION_MESSAGE=`trim $ASN1C_COMPILER_VERSION_MESSAGE` - if [ "$ASN1C_COMPILER_VERSION_MESSAGE" != "$ASN1C_COMPILER_REQUIRED_VERSION_MESSAGE" ]; then - # diff <(echo -n "$ASN1C_COMPILER_VERSION_MESSAGE") <(echo -n "$ASN1C_COMPILER_REQUIRED_VERSION_MESSAGE") - echo_error "Version of asn1c is not the required one, do you want to install the required one (overwrite installation) ? (Y/n)" - echo_error "$ASN1C_COMPILER_VERSION_MESSAGE" - while read -r -n 1 -s answer; do - if [[ $answer = [YyNn] ]]; then - [[ $answer = [Yy] ]] && $OPENAIR_TARGETS/SCRIPTS/install_asn1c_0.9.24.modified.bash $SUDO - [[ $answer = [Nn] ]] && echo_error "Version of asn1c is not the required one, exiting." && exit 1 - break - fi - done - fi - -} - -################################################# -# 2. compile -################################################ -compile_hss() { - cd $OPENAIR3_DIR/OPENAIRHSS - - if [ "$1" -eq 1 ]; then - echo_info "build a clean HSS" - rm -rfv obj* - rm -rfv m4 - rm -rfv .autom4* - rm -fv configure - fi - - OBJ_DIR=`find . -maxdepth 1 -type d -iname obj*` - - if [ ! -n "$OBJ_DIR" ]; then - OBJ_DIR="objs" - mkdir --verbose -m 777 ./$OBJ_DIR - else - OBJ_DIR=`basename $OBJ_DIR` - fi - - if [ ! -f "$OBJ_DIR"/Makefile ]; then - if [ ! -d m4 ]; then - mkdir --verbose -m 777 m4 - fi - echo_success "Invoking autogen" - ./autogen.sh - if [ $? -ne 0 ]; then - return 1 - fi - cd $OBJ_DIR - echo_success "Invoking configure" - ../configure - if [ $? -ne 0 ]; then - return 1 - fi - else - cd $OBJ_DIR - fi - - if [ -f Makefile ]; then - echo_success "Compiling..." - make ; #-j $NUM_CPU - if [ $? -ne 0 ]; then - echo_error "Build failed, exiting" - return 1 - else - return 0 - fi - else - echo_error "Configure failed, aborting" - fi - return 1 -} - - -compile_epc() { - cd $OPENAIR3_DIR - if [ $1 = 1 ]; then - echo_info "build a clean EPC" - bash_exec "rm -rf objs" - fi - OBJ_DIR=`find . -maxdepth 1 -type d -iname obj*` - if [ ! -n "$OBJ_DIR" ]; then - OBJ_DIR="objs" - bash_exec "mkdir -m 777 ./$OBJ_DIR" - echo_success "Created $OBJ_DIR directory" - else - OBJ_DIR=`basename $OBJ_DIR` - fi - if [ ! -f $OBJ_DIR/Makefile ]; then - if [ ! -n "m4" ]; then - mkdir -m 777 m4 - fi - bash_exec "autoreconf -i -f" - echo_success "Invoking autogen" - bash_exec "libtoolize" - bash_exec "./autogen.sh" - cd ./$OBJ_DIR - echo_success "Invoking configure" - if [ $DEBUG -ne 0 ]; then - ../configure --enable-debug --enable-standalone-epc --enable-gtp1u-in-kernel LDFLAGS=-L/usr/local/lib - else - ../configure --enable-standalone-epc --enable-gtp1u-in-kernel LDFLAGS=-L/usr/local/lib - fi - else - cd ./$OBJ_DIR - fi - -# pkill oai_epc -# pkill tshark - - if [ -f Makefile ]; then - echo_success "Compiling..." - make -j $NUM_CPU - if [ $? -ne 0 ]; then - echo_error "Build failed, exiting" - return 1 - else - cp -pf ./OAI_EPC/oai_epc $OPENAIR_TARGETS/bin - fi - else - echo_error "Configure failed, exiting" - return 1 - fi - - cd $OPENAIR3_DIR/GTPV1-U/GTPUAH; - make - if [ $? -ne 0 ]; then - echo_error "Build GTPUAH module failed, exiting" - return 1 - else - $SUDO cp -pfv ./Bin/libxt_*.so /lib/xtables - $SUDO cp -pfv ./Bin/*.ko $OPENAIR_TARGETS/bin - fi - - cd $OPENAIR3_DIR/GTPV1-U/GTPURH; - make - if [ $? -ne 0 ]; then - echo_error "Build GTPURH module failed, exiting" - return 1 - else - $SUDO cp -pfv ./Bin/libxt_*.so /lib/xtables - $SUDO cp -pfv ./Bin/*.ko $OPENAIR_TARGETS/bin - fi - return 0 -} - -compile_exmimo2_driver() { - cd $OPENAIR_TARGETS/ARCH/EXMIMO/DRIVER/eurecom && make clean && make || exit 1 - cd $OPENAIR_TARGETS/ARCH/EXMIMO/USERSPACE/OAI_FW_INIT && make clean && make || exit 1 - # TO DO CHECKS... -} - - -compile_ltesoftmodem() { - cd $OPENAIR_TARGETS/RT/USER - if [ -f Makefile ]; then - rm -f ./lte-softmodem - echo "LTE softmodem compiling directives: $SOFTMODEM_DIRECTIVES" - if [ $OAI_CLEAN -ne 0 ]; then - echo "Cleaning LTE softmodem" - make cleanall > /dev/null 2>&1 - fi - make -j $NUM_CPU $SOFTMODEM_DIRECTIVES - if [ $? -ne 0 ]; then - # to locate easily compilation error in log file - make $SOFTMODEM_DIRECTIVES - fi - if [ $? -ne 0 ]; then - if [ ! -f ./lte-softmodem ]; then - echo_error "Build lte-softmodem failed, returning" - return 1 - else - cp -pf ./lte-softmodem $OPENAIR_TARGETS/bin - return 0 - fi - else - cp -pf ./lte-softmodem $OPENAIR_TARGETS/bin - return 0 - fi - else - echo_error "make file for oai softmodem not found, returning" - return 1 - fi -} - -compile_oaisim() { - cd $OPENAIR_TARGETS/SIMU/USER - if [ -f Makefile ]; then - echo "Compiling for oaisim target ($OAISIM_DIRECTIVES)" - make cleanall > /dev/null - make -j $NUM_CPU $OAISIM_DIRECTIVES - if [ $? -ne 0 ]; then - echo_error "Build oaisim failed, returning" - return 1 - else - cp -pf ./oaisim $OPENAIR_TARGETS/bin - return 0 - fi - else - echo_error "Makefile not found for oaisim target, returning" - return 1 - fi -} - -compile_unisim() { - cd $OPENAIR1_DIR/SIMULATION/LTE_PHY - if [ -f Makefile ]; then - echo "Compiling for UNISIM target ..." - make cleanall - make -j $NUM_CPU all - if [ $? -ne 0 ]; then - echo_error "Build unisim failed, returning" - return 1 - else - cp -pf ./dlsim $OPENAIR_TARGETS/bin - cp -pf ./ulsim $OPENAIR_TARGETS/bin - cp -pf ./pucchsim $OPENAIR_TARGETS/bin - cp -pf ./prachsim $OPENAIR_TARGETS/bin - cp -pf ./pdcchsim $OPENAIR_TARGETS/bin - cp -pf ./pbchsim $OPENAIR_TARGETS/bin - cp -pf ./mbmssim $OPENAIR_TARGETS/bin - return 0 - fi - else - echo_error "Configure failed, exiting" - return 1 - fi -} - -compile_nas_tools() { - - export NVRAM_DIR=$OPENAIR_TARGETS/bin - - cd $NVRAM_DIR - - if [ ! -f /tmp/nas_cleaned ]; then - echo_success "make --directory=$OPENAIR3_DIR/NAS/EURECOM-NAS/tools veryveryclean" - make --directory=$OPENAIR3_DIR/NAS/EURECOM-NAS/tools veryveryclean - fi - echo_success "make --directory=$OPENAIR3_DIR/NAS/EURECOM-NAS/tools all" - make --directory=$OPENAIR3_DIR/NAS/EURECOM-NAS/tools all - rm .ue.nvram0 - rm .usim.nvram0 - touch /tmp/nas_cleaned -} - - -compile_ue_ip_nw_driver() { - cd $OPENAIR2_DIR && make ue_ip.ko -} - -################################################ -# 1. check if the executable functions exist -############################################### - -check_for_ltesoftmodem_executable() { - if [ ! -f $OPENAIR_TARGETS/RT/USER/lte-softmodem ]; then - echo_error "Cannot find lte-softmodem executable object in directory $OPENAIR_TARGETS/RT/USER" - echo_error "Check the compilation logs in bin/install_log.txt" - exit 1 - fi -} - -check_for_epc_executable() { - if [ ! -f $OPENAIR3_DIR/objs/OAI_EPC/oai_epc ]; then - echo_error "Cannot find oai_epc executable object in directory $OPENAIR3_DIR/objs/OAI_EPC/" - echo_fatal "Please make sure you have compiled OAI EPC with --enable-standalone-epc option" - fi -} - -check_for_hss_executable() { - if [ ! -f $OPENAIR3_DIR/OPENAIRHSS/objs/openair-hss ]; then - echo_error "Cannot find openair-hss executable object in directory $OPENAIR3_DIR/OPENAIRHSS/objs/" - echo_fatal "Please make sure you have compiled OAI HSS" - fi -} - -check_for_sgw_executable() { - if [ ! -f $OPENAIR3_DIR/objs/OAI_SGW/oai_sgw ]; then - echo_error "Cannot find oai_sgw executable object in directory $OPENAIR3_DIR/OPENAIRMME/objs/OAI_SGW/" - echo_fatal "Please make sure you have compiled OAI EPC without --enable-standalone-epc option" - fi -} - -check_for_oaisim_executable() { - if [ ! -f $OPENAIR_TARGETS/SIMU/USER/oaisim ]; then - echo_error "Cannot find oaisim executable object in directory $OPENAIR_TARGETS/SIMU/USER" - echo_error "Check the compilation logs in bin/install_log.txt" - fi -} - -check_for_dlsim_executable() { - if [ ! -f $OPENAIR1_DIR/SIMULATION/LTE_PHY/dlsim ]; then - echo_error "Cannot find dlsim executable object in directory $OPENAIR1_DIR/SIMULATION/LTE_PHY" - echo_error "Check the compilation logs in bin/install_log.txt" - fi -} - -check_for_ulsim_executable() { - if [ ! -f $OPENAIR1_DIR/SIMULATION/LTE_PHY/ulsim ]; then - echo_error "Cannot find ulsim executable object in directory $OPENAIR1_DIR/SIMULATION/LTE_PHY" - echo_error "Check the compilation logs in bin/install_log.txt" - fi -} - -check_for_pucchsim_executable() { - if [ ! -f $OPENAIR1_DIR/SIMULATION/LTE_PHY/pucchsim ]; then - echo_error "Cannot find pucchsim executable object in directory $OPENAIR1_DIR/SIMULATION/LTE_PHY" - echo_error "Check the compilation logs in bin/install_log.txt" - fi -} - -check_for_prachsim_executable() { - if [ ! -f $OPENAIR1_DIR/SIMULATION/LTE_PHY/prachsim ]; then - echo_error "Cannot find prachsim executable object in directory $OPENAIR1_DIR/SIMULATION/LTE_PHY" - echo_error "Check the compilation logs in bin/install_log.txt" - fi -} - -check_for_pdcchsim_executable() { - if [ ! -f $OPENAIR1_DIR/SIMULATION/LTE_PHY/pdcchsim ]; then - echo_error "Cannot find pdcchsim executable object in directory $OPENAIR1_DIR/SIMULATION/LTE_PHY" - echo_error "Check the compilation logs in bin/install_log.txt" - fi -} - -check_for_pbchsim_executable() { - if [ ! -f $OPENAIR1_DIR/SIMULATION/LTE_PHY/pbchsim ]; then - echo_error "Cannot find pbchsim executable object in directory $OPENAIR1_DIR/SIMULATION/LTE_PHY" - echo_error "Check the compilation logs in bin/install_log.txt" - fi -} - -check_for_mbmssim_executable() { - if [ ! -f $OPENAIR1_DIR/SIMULATION/LTE_PHY/mbmssim ]; then - echo_error "Cannot find mbmssim executable object in directory $OPENAIR1_DIR/SIMULATION/LTE_PHY" - echo_error "Check the compilation logs in bin/install_log.txt" - fi -} - -check_for_nas_ue_executable() { - if [ ! -f $OPENAIR3_DIR/NAS/EURECOM-NAS/bin/UserProcess ]; then - echo_error "Cannot find UserProcess executable object in directory $OPENAIR3_DIR/NAS/EURECOM-NAS/bin" - echo_fatal "Check the compilation logs in bin/install_log.txt" - fi -} - -################################################ -# 1. check if the executable functions exist -############################################### - -# arg1 is RT -# arg2 is HW -# arg3 is ENB_S1 -install_ltesoftmodem() { - # RT - if [ $1 = "RTAI" ]; then - if [ ! -f /tmp/init_rt_done.tmp ]; then - echo_info " 8.1 Insert RTAI modules" - $SUDO insmod /usr/realtime/modules/rtai_hal.ko > /dev/null 2>&1 - $SUDO insmod /usr/realtime/modules/rtai_sched.ko > /dev/null 2>&1 - $SUDO insmod /usr/realtime/modules/rtai_sem.ko > /dev/null 2>&1 - $SUDO insmod /usr/realtime/modules/rtai_fifos.ko > /dev/null 2>&1 - $SUDO insmod /usr/realtime/modules/rtai_mbx.ko > /dev/null 2>&1 - $SUDO touch /tmp/init_rt_done.tmp - $SUDO chmod 666 /tmp/init_rt_done.tmp - else - echo_warning " 8.1 RTAI modules already inserted" - fi - fi - #HW - if [ $2 = "EXMIMO" ]; then - echo_info " 8.2 [EXMIMO] creating RTAI fifos" - for i in `seq 0 64`; do - have_rtfX=`ls /dev/ |grep -c rtf$i`; - if [ "$have_rtfX" -eq 0 ] ; then - $SUDO mknod -m 666 /dev/rtf$i c 150 $i; - fi; - done - echo_info " 8.3 [EXMIMO] Build lte-softmodemdrivers" - cd $OPENAIR_TARGETS/ARCH/EXMIMO/DRIVER/eurecom && make clean && make # || exit 1 - cd $OPENAIR_TARGETS/ARCH/EXMIMO/USERSPACE/OAI_FW_INIT && make clean && make # || exit 1 - - echo_info " 8.4 [EXMIMO] Setup RF card" - cd $OPENAIR_TARGETS/RT/USER - . ./init_exmimo2.sh - else - if [ $2 = "USRP" ]; then - echo_info " 8.2 [USRP] " - fi - - fi - - # ENB_S1 - if [ $3 = 0 ]; then - cd $OPENAIR2_DIR && make clean && make nasmesh_netlink.ko #|| exit 1 - cd $OPENAIR2_DIR/NAS/DRIVER/MESH/RB_TOOL && make clean && make # || exit 1 - fi - -} - -# arg1 is ENB_S1 'boolean' -install_oaisim() { - if [ $1 = 0 ]; then - cd $OPENAIR2_DIR && make clean && make nasmesh_netlink.ko #|| exit 1 - cd $OPENAIR2_DIR/NAS/DRIVER/MESH/RB_TOOL && make clean && make # || exit 1 - else - compile_ue_ip_nw_driver - install_nas_tools - fi - -} - - -install_nas_tools() { - cd $OPENAIR_TARGETS/bin - if [ ! -f .ue.nvram0 ]; then - echo_success "generate .ue_emm.nvram0 .ue.nvram0" - $OPENAIR3_DIR/NAS/EURECOM-NAS/bin/ue_data --gen - fi - - if [ ! -f .usim.nvram0 ]; then - echo_success "generate .usim.nvram0" - $OPENAIR3_DIR/NAS/EURECOM-NAS/bin/usim_data --gen - fi - $OPENAIR3_DIR/NAS/EURECOM-NAS/bin/ue_data --print - $OPENAIR3_DIR/NAS/EURECOM-NAS/bin/usim_data --print -} - -install_nasmesh(){ - echo_success "LOAD NASMESH IP DRIVER FOR UE AND eNB" - (cd $OPENAIR2_DIR/NAS/DRIVER/MESH/RB_TOOL && make clean && make) - (cd $OPENAIR2_DIR && make clean && make nasmesh_netlink_address_fix.ko) - $SUDO rmmod nasmesh - $SUDO insmod $OPENAIR2_DIR/NAS/DRIVER/MESH/nasmesh.ko -} - -################################## -# create HSS DB -################################ - -# arg 1 is mysql user (root) -# arg 2 is mysql password (linux) -# arg 3 is hss username (hssadmin) -# arg 4 is hss password (admin) -# arg 5 is database name (oai_db) -create_hss_database(){ - EXPECTED_ARGS=5 - E_BADARGS=65 - MYSQL=`which mysql` - rv=0 - if [ $# -ne $EXPECTED_ARGS ] - then - echo_fatal "Usage: $0 dbuser dbpass hssuser hsspass databasename" - rv=1 - fi - - set_openair_env - - # removed % - #Q1="GRANT ALL PRIVILEGES ON *.* TO '$3'@'%' IDENTIFIED BY '$4' WITH GRANT OPTION;" - Q1="GRANT ALL PRIVILEGES ON *.* TO '$3'@'localhost' IDENTIFIED BY '$4' WITH GRANT OPTION;" - Q2="FLUSH PRIVILEGES;" - SQL="${Q1}${Q2}" - $MYSQL -u $1 --password=$2 -e "$SQL" - if [ $? -ne 0 ]; then - echo_error "$3 permissions failed" - return 1 - else - echo_success "$3 permissions succeeded" - fi - - - Q1="CREATE DATABASE IF NOT EXISTS ${BTICK}$5${BTICK};" - SQL="${Q1}" - $MYSQL -u $3 --password=$4 -e "$SQL" - if [ $? -ne 0 ]; then - echo_error "$5 creation failed" - return 1 - else - echo_success "$5 creation succeeded" - fi - - - # test if tables have been created - mysql -u $3 --password=$4 -e "desc $5.users" > /dev/null 2>&1 - - if [ $? -eq 1 ]; then - $MYSQL -u $3 --password=$4 $5 < $OPENAIR3_DIR/OPENAIRHSS/db/oai_db.sql - if [ $? -ne 0 ]; then - echo_error "$5 tables creation failed" - return 1 - else - echo_success "$5 tables creation succeeded" - fi - fi - - return 0 -} - -################################ -# set_openair_env -############################### -set_openair_env(){ - - fullpath=`readlink -f $BASH_SOURCE` - [ -f "/.$fullpath" ] || fullpath=`readlink -f $PWD/$fullpath` - openair_path=${fullpath%/targets/*} - openair_path=${openair_path%/openair3/*} - openair_path=${openair_path%/openair[123]/*} - - export OPENAIR_DIR=$openair_path - export OPENAIR_HOME=$openair_path - export OPENAIR1_DIR=$openair_path/openair1 - export OPENAIR2_DIR=$openair_path/openair2 - export OPENAIR3_DIR=$openair_path/openair3 - export OPENAIR3_DIR=$openair_path/openair3 - export OPENAIR_TARGETS=$openair_path/targets - -} - -######################################## -### print help -###################################### - -print_help(){ - echo_success "Name : build_oai - install and build OAI" - echo_success "Usage: build_oai.bash -a -b -c -d -e RTAI -m -r REL8 -s -t OAISIM -w EXMIMO -x" - echo_success "-a | --doxygen : Enable doxygen for documentation (default disabled)" - echo_success "-b | --disable-s1 : Disable S1 interface for eNB (default enabled)" - echo_success "-c | --clean : Enable clean OAI build (default disabled)" - echo_success "-C | --config-file : Set the config file local path" - echo_success "-d | --debug : Enable debug mode (default disabled)" - echo_success "-D | --disable-check-installed-software : Disable the checking of installed software (default is check)" - echo_success "-e | --realtime : Set realtime mode: RTAI, NONE (default NONE)" - echo_success "-g | --run-with-gdb : Run the executable built by this script with gdb" - echo_success "-K | --itti-dump-file : Set the execution events trace file" - echo_success "-l | --build-target : Set the LTE build target: ENB,EPC,HSS,NONE (default ENB)" - echo_success "-m | --build-from-makefile : Enable build from the makefile (default disabled)" - echo_success "-r | --3gpp-release : Set the release: REL8, REL10 (default REL8)" - echo_success "-p | --wireshark : enable wireshark interface for L2 pdus" - echo_success "-R | --run : Run the executable built by this script" - echo_success "-s | --check : Enable OAI testing and sanity check (default disabled)" - echo_success "-t | --enb-build-target : Set the eNB build target: ALL, SOFTMODEM,OAISIM,UNISIM (default ALL)" - echo_success "-V | --vcd : Log vcd events" - echo_success "-w | --hardware : Set the hardware platform: EXMIMO, USRP (also installs UHD driver), ETHERNET, NONE, (default EXMIMO)" - echo_success "-x | --xforms : Enable xforms (default disabled)" - echo_success "-z | --defaults : Set the default build options" -} - -print_help_perf(){ - echo_success "Name : perf_oai generate traffic and evaluate the performance " - echo_success "Usage: perf_oai.bash -l ITG " - echo_success "-l | --perf-app : Set Performance evaluation app: ITGS, ITGD,PING, OTG-OAISIM, OTG-CBA, (default PING)" - echo_success "-m | --owd : enable D-ITG one-way-delay meter (default disabled)" - echo_success "-e | --duration : set the duration of the experiment (default 60000ms)" - echo_success "-i | --idt-dist : set the distribution of the inter-departure time: CONSTANT, UNIFORM,EXPONENTIAL (default CONSTANT)" - echo_success "-s | --ps-dist : set the distribution of the inter-departure time (default CONSTANT, available options: UNIFORM,EXPONENTIAL)" - echo_success "-d | --dst : set the destination address (default 127.0.0.1)" - echo_success "-p | --dst-port : set the destination address (default NONE)" - echo_success "-t | --test : enable test mode to validate the functionality (default disabled)" - echo_success "-k | --keep-log-file : keep the log files (default disabled)" - -} -############################### -## echo and family -############################### -black='\E[30m' -red='\E[31m' -green='\E[32m' -yellow='\E[33m' -blue='\E[34m' -magenta='\E[35m' -cyan='\E[36m' -white='\E[37m' -reset_color='\E[00m' - - -cecho() # Color-echo -# arg1 = message -# arg2 = color -{ - local default_msg="No Message." - message=${1:-$default_msg} - color=${2:-$green} - if [ $BUILD_FROM_MAKEFILE = 0 ]; then - echo -e -n "$color$message$reset_color" - echo - else - echo "$message" - fi - return -} - -echo_error() { - local my_string="" - until [ -z "$1" ] - do - my_string="$my_string$1" - shift - done - cecho "$my_string" $red -} - -echo_fatal() { - local my_string="" - until [ -z "$1" ] - do - my_string="$my_string$1" - shift - done - echo_error "$my_string" - exit -1 -} - -echo_warning() { - local my_string="" - until [ -z "$1" ] - do - my_string="$my_string$1" - shift - done - cecho "$my_string" $yellow -} - -echo_success() { - local my_string="" - until [ -z "$1" ] - do - my_string="$my_string$1" - shift - done - cecho "$my_string" $green -} -echo_info() { - local my_string="" - until [ -z "$1" ] - do - my_string="$my_string$1" - shift - done - cecho "$my_string" $blue -} - -bash_exec() { - output=$($1 2>&1) - result=$? - if [ $result -eq 0 ]; then - echo_success "$1" - else - echo_error "$1: $output" - fi -} - - -wait_process_started () { - if [ -z "$1" ]; then - echo_error "WAITING FOR PROCESS START: NO PROCESS" - return 1 - fi - ps -C $1 > /dev/null 2>&1 - while [ $? -ne 0 ]; do - echo_warning "WAITING FOR $1 START" - sleep 2 - ps -C $1 > /dev/null 2>&1 - done - echo_success "PROCESS $1 STARTED" - return 0 -} - -is_process_started () { - if [ -z "$1" ]; then - echo_error "WAITING FOR PROCESS START: NO PROCESS" - return 1 - fi - ps -C $1 > /dev/null 2>&1 - if [ $? -ne 0 ]; then - echo_success "PROCESS $1 NOT STARTED" - return 1 - fi - echo_success "PROCESS $1 STARTED" - return 0 -} - -assert() { - # If condition false - # exit from script with error message - E_PARAM_ERR=98 - E_PARAM_FAILED=99 - - if [ -z "$2" ] ; then # Not enought parameters passed. - return $E_PARAM_ERR - fi - - lineno=$2 - if [ ! $1 ]; then - echo_error "Assertion failed: \"$1\"" - echo_fatal "File \"$0\", line $lineno" - fi -} diff --git a/targets/build_oai.bash b/targets/build_oai.bash deleted file mode 100755 index 05b14a541b10a14dc6c4dfc72a939cbb1f37b8c0..0000000000000000000000000000000000000000 --- a/targets/build_oai.bash +++ /dev/null @@ -1,840 +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 -# */ -################################################################################ -# file build_oai.bash -# brief OAI automated build tool that can be used to install, compile, run OAI. -# author Navid Nikaein, Lionel GAUTHIER -# company Eurecom -# email: navid.nikaein@eurecom.fr, lionel.gauthier@eurecom.fr -# - -#!/bin/bash -################################ -# include helper functions -################################ -THIS_SCRIPT_PATH=$(dirname $(readlink -f $0)) -. $THIS_SCRIPT_PATH/build_helper.bash - -check_for_root_rights - -####################################### -# Default PARAMETERS -###################################### -declare OAI_DB_ADMIN_USER_NAME="root" -declare OAI_DB_ADMIN_USER_PASSWORD="linux" - -#only one could be set at the time -declare BUILD_LTE="NONE" # ENB, EPC, HSS - -declare HW="EXMIMO" # EXMIMO, USRP, ETHERNET, NONE -declare TARGET="ALL" # ALL, SOFTMODEM, OAISIM, UNISIM, NONE -declare ENB_S1=1 -declare REL="REL8" # REL8, REL10 -declare RT="NONE" # RTAI, RT_PREMPT, NONE -declare DEBUG=0 -declare CONFIG_FILE=" " -declare CONFIG_FILE_ACCESS_OK=0 -declare EXE_ARGUMENTS=" " -declare RUN_GDB=0 -declare RUN=0 -declare DISABLE_CHECK_INSTALLED_SOFTWARE=0 -declare OAI_CLEAN=0 -declare CLEAN_IPTABLES=0 -declare CLEAN_HSS=0 - -declare OAI_TEST=0 -declare XFORMS=0 - -# script is not currently handling these params -declare EPC=0 # flag to build EPC - -declare ITTI_ANALYZER=0 -declare VCD_TIMING=0 -declare WIRESHARK=0 -declare TIME_MEAS=0 -declare DOXYGEN=0 -declare DEV=0 - -#EMULATION_DEV_INTERFACE="eth0" -#EMULATION_MULTICAST_GROUP=1 -#EMULATION_DEV_ADDRESS=`ifconfig $EMULATION_DEV_INTERFACE | grep 'inet addr:'| grep -v '127.0.0.1' | cut -d: -f2 | awk '{ print $1}'` - -############## script params ##################### - -if [ -f ./.lock_oaibuild ]; then - OAI_CLEAN=0 -else - OAI_CLEAN=1 -fi - -#for i in "$@" -#do -# echo "i is : $i" -# case $i in - - - until [ -z "$1" ] - do - case "$1" in - -a | --doxygen) - DOXYGEN=1 - echo "setting doxygen flag to: $DOXYGEN" - shift; - ;; - -b | --disable-s1) - ENB_S1=0 - echo "disable eNB S1 flag" - shift; - ;; - -c | --clean) - rm -rf ./.lock_oaibuild - OAI_CLEAN=1 - CLEAN_HSS=1 - echo "setting clean flag to: $OAI_CLEAN" - echo "may check package installation, and recompile OAI" - shift; - ;; - --clean-iptables) - CLEAN_IPTABLES=1; - shift; - ;; - -C | --config-file) - CONFIG_FILE=$2 - # may be relative path - if [ -f $(dirname $(readlink -f $0))/$CONFIG_FILE ]; then - CONFIG_FILE=$(dirname $(readlink -f $0))/$CONFIG_FILE - echo "setting config file to: $CONFIG_FILE" - CONFIG_FILE_ACCESS_OK=1 - else - # may be absolute path - if [ -f $CONFIG_FILE ]; then - echo "setting config file to: $CONFIG_FILE" - CONFIG_FILE_ACCESS_OK=1 - else - echo "config file not found" - exit 1 - fi - fi - EXE_ARGUMENTS="$EXE_ARGUMENTS -O $CONFIG_FILE" - shift 2; - ;; - -d | --debug) - DEBUG=1 - echo "setting debug flag to: $DEBUG" - shift; - ;; - -D | --disable-check-installed-software) - DISABLE_CHECK_INSTALLED_SOFTWARE=1 - echo "disable check installed software" - shift; - ;; - -e | --realtime) - RT=$2 - echo "setting realtime flag to: $RT" - shift 2 ; - ;; - -g | --run-with-gdb) - DEBUG=1 - RUN=1 - RUN_GDB=1 - echo "Running with gdb" - shift; - ;; - -K | --itti-dump-file) - ITTI_ANALYZER=1 - ITTI_DUMP_FILE=$2 - echo "setting ITTI dump file to: $ITTI_DUMP_FILE" - EXE_ARGUMENTS="$EXE_ARGUMENTS -K $ITTI_DUMP_FILE" - shift 2; - ;; - -l | --build-target) - BUILD_LTE=$2 - echo "setting top-level build target to: $2" - shift 2; - ;; - -h | --help) - print_help - exit -1 - ;; - -m | --build-from-makefile) - BUILD_FROM_MAKEFILE=1 - set_build_from_makefile $BUILD_FROM_MAKEFILE - echo "setting a flag to build from makefile to: $BUILD_FROM_MAKEFILE" - shift; - ;; - -r | --3gpp-release) - REL=$2 - echo "setting release to: $REL" - shift 2 ; - ;; - -R | --run) - RUN=1 - echo "setting run to $RUN" - shift; - ;; - -s | --check) - OAI_TEST=1 - echo "setting sanity check to: $OAI_TEST" - shift; - ;; - -t | --enb-build-target) - TARGET=$2 - echo "setting enb build target to: $TARGET" - shift 2; - ;; - -V | --vcd) - echo "setting gtk-wave output" - VCD_TIMING=1 - EXE_ARGUMENTS="$EXE_ARGUMENTS -V" - shift ; - ;; - -w | --hardware) - HW="$2" #"${i#*=}" - echo "setting hardware to: $HW" - shift 2 ; - ;; - -x | --xforms) - XFORMS=1 - EXE_ARGUMENTS="$EXE_ARGUMENTS -d" - echo "setting xforms to: $XFORMS" - shift; - ;; - -p | --wireshark) - WIRESHARK=1 - echo "enabling Wireshark interface to $WIRESHARK" - shift; - ;; - -z | --defaults) - echo "setting all parameters to: default" - rm -rf ./.lock_oaibuild - OAI_CLEAN=1 - HW="EXMIMO" - TARGET="ALL" - ENB_S1=1 - REL="REL8" - RT="NONE" - DEBUG=0 - ENB_CONFIG_FILE=$OPENAIR_TARGETS/"PROJECTS/GENERIC-LTE-EPC/CONF/enb.band7.conf" - OAI_TEST=0 - shift ; - ;; - *) - echo "Unknown option $1" - break ; - # unknown option - ;; - esac -done - -##################### -# create a bin dir -##################### -echo_info "1. Creating the bin dir ..." -mkdir -m 777 bin - -build_date=`date +%Y_%m_%d` -oai_build_date="oai_built_${build_date}" -touch bin/${oai_build_date} -chmod -f 777 bin/${oai_build_date} - -touch bin/install_log.txt -chmod -f 777 bin/install_log.txt -################################ -# cleanup first -################################ -#echo_info "3. Cleaning ..." - -#$SUDO kill -9 `ps -ef | grep oaisim | awk '{print $2}'` 2>&1 -#$SUDO kill -9 `ps -ef | grep lte-softmodem | awk '{print $2}'` 2>&1 -#$SUDO kill -9 `ps -ef | grep dlsim | awk '{print $2}'` 2>&1 -#$SUDO kill -9 `ps -ef | grep ulsim | awk '{print $2}'` 2>&1 - -if [ $CLEAN_IPTABLES -eq 1 ]; then - echo_info "Flushing iptables..." - $SUDO modprobe ip_tables - $SUDO modprobe x_tables - $SUDO iptables -P INPUT ACCEPT - $SUDO iptables -F INPUT - $SUDO iptables -P OUTPUT ACCEPT - $SUDO iptables -F OUTPUT - $SUDO iptables -P FORWARD ACCEPT - $SUDO iptables -F FORWARD - $SUDO iptables -t nat -F - $SUDO iptables -t mangle -F - $SUDO iptables -t filter -F - $SUDO iptables -t raw -F - echo_info "Flushed iptables" -fi -############################################ -# setting and printing OAI envs, we should check here -############################################ - -echo_info "2. Setting the OAI PATHS ..." - -set_openair_env -cecho "OPENAIR_HOME = $OPENAIR_HOME" $green -cecho "OPENAIR1_DIR = $OPENAIR1_DIR" $green -cecho "OPENAIR2_DIR = $OPENAIR2_DIR" $green -cecho "OPENAIR3_DIR = $OPENAIR3_DIR" $green -cecho "OPENAIR3_DIR = $OPENAIR3_DIR" $green -cecho "OPENAIR_TARGETS = $OPENAIR_TARGETS" $green - - -echo "OPENAIR_HOME = $OPENAIR_HOME" >> bin/${oai_build_date} -echo "OPENAIR1_DIR = $OPENAIR1_DIR" >> bin/${oai_build_date} -echo "OPENAIR2_DIR = $OPENAIR2_DIR" >> bin/${oai_build_date} -echo "OPENAIR3_DIR = $OPENAIR3_DIR" >> bin/${oai_build_date} -echo "OPENAIR3_DIR = $OPENAIR3_DIR" >> bin/${oai_build_date} -echo "OPENAIR_TARGETS = $OPENAIR_TARGETS" >> bin/${oai_build_date} - - -build_enb(){ - -########################################## -# process parameters -######################################### - - echo_info "4. Process the parameters" - - echo_info "User-defined Parameters : HW=$HW, TARGET=$TARGET, ENB_S1=$ENB_S1, REL=$REL, RT=$RT, DEBUG=$DEBUG XFORMS=$XFORMS" - - echo "User-defined Parameters : HW=$HW, TARGET=$TARGET, ENB_S1=$ENB_S1, REL=$REL, RT=$RT, DEBUG=$DEBUG XFORMS=$XFORMS" >> bin/${oai_build_date} - - -############################################ -# compilation directives -############################################ - - echo_info "5. building the compilation directives ..." - - - SOFTMODEM_DIRECTIVES="DEBUG=$DEBUG XFORMS=$XFORMS " - OAISIM_DIRECTIVES="DEBUG=$DEBUG XFORMS=$XFORMS " - - if [ $ENB_S1 -eq 1 ]; then - SOFTMODEM_DIRECTIVES="$SOFTMODEM_DIRECTIVES USE_MME=R10 ENABLE_ITTI=1 LINK_ENB_PDCP_TO_GTPV1U=1 SECU=1 " - #OAISIM_DIRECTIVES="$OAISIM_DIRECTIVES USE_MME=R10 ENABLE_ITTI=1 LINK_ENB_PDCP_TO_GTPV1U=1 SECU=1 " - OAISIM_DIRECTIVES="$OAISIM_DIRECTIVES ENABLE_ITTI=1 LINK_ENB_PDCP_TO_GTPV1U=1 SECU=1 " - fi - - if [ $DEBUG -eq 0 ]; then - SOFTMODEM_DIRECTIVES="$SOFTMODEM_DIRECTIVES DISABLE_XER_PRINT=1 " - OAISIM_DIRECTIVES="$OAISIM_DIRECTIVES DISABLE_XER_PRINT=1 " - fi - - if [ $HW = "USRP" ]; then - SOFTMODEM_DIRECTIVES="$SOFTMODEM_DIRECTIVES USRP=1 " - fi - - if [ $HW = "ADRV9371_ZC706" ]; then - SOFTMODEM_DIRECTIVES="$SOFTMODEM_DIRECTIVES ADRV9371_ZC706=1 " - fi - - if [ $HW = "EXMIMO" ]; then - SOFTMODEM_DIRECTIVES="$SOFTMODEM_DIRECTIVES EXMIMO=1 " - fi - - if [ $HW = "ETHERNET" ]; then - SOFTMODEM_DIRECTIVES="$SOFTMODEM_DIRECTIVES ETHERNET=1 " - fi - - if [ $ENB_S1 -eq 0 ]; then - SOFTMODEM_DIRECTIVES="$SOFTMODEM_DIRECTIVES NAS=1 " - OAISIM_DIRECTIVES="$OAISIM_DIRECTIVES NAS=1 " - fi - - if [ $REL = "REL8" ]; then - SOFTMODEM_DIRECTIVES="$SOFTMODEM_DIRECTIVES Rel8=1 " - OAISIM_DIRECTIVES="$OAISIM_DIRECTIVES Rel8=1 " - else - SOFTMODEM_DIRECTIVES="$SOFTMODEM_DIRECTIVES Rel10=1 " - OAISIM_DIRECTIVES="$OAISIM_DIRECTIVES Rel10=1 " - fi - - if [ $RT = "RTAI" ]; then - if [ ! -f /usr/realtime/modules/rtai_hal.ko ]; then - echo_warning "RTAI doesn't seem to be installed" - RT="NONE" - SOFTMODEM_DIRECTIVES="$SOFTMODEM_DIRECTIVES RTAI=0 " - else - SOFTMODEM_DIRECTIVES="$SOFTMODEM_DIRECTIVES HARD_RT=1 " - fi - else - SOFTMODEM_DIRECTIVES="$SOFTMODEM_DIRECTIVES RTAI=0 " - RT="NONE" - fi - - if [ $TARGET != "ALL" ]; then - if [ $TARGET != "SOFTMODEM" ]; then - HW="NONE" - fi - fi - - if [ $UBUNTU_REL = "12.04" ]; then - output=$(check_for_machine_type 2>&1) - MACHINE_ARCH=$? - if [ $MACHINE_ARCH -eq 64 ]; then - SOFTMODEM_DIRECTIVES="$SOFTMODEM_DIRECTIVES LIBCONFIG_LONG=1 " - OAISIM_DIRECTIVES="$OASIM_DIRECTIVES LIBCONFIG_LONG=1 " - fi - fi - - echo_success "SOFTMODEM Compilation directives: $SOFTMODEM_DIRECTIVES" - echo_success "OAISIM Compilation directives: $OAISIM_DIRECTIVES" - - echo "SOFTMODEM Compilation directives: $SOFTMODEM_DIRECTIVES" >> bin/${oai_build_date} - echo "OAISIM Compilation directive: $OAISIM_DIRECTIVES" >> bin/${oai_build_date} - - -############################################ -# check the installation -############################################ - if [ $DISABLE_CHECK_INSTALLED_SOFTWARE -eq 0 ]; then - echo_info "6. Checking the the required softwares/packages ..." - - check_install_oai_software - if [ $HW = "USRP" ]; then - check_install_usrp_uhd_driver - fi - check_install_asn1c - check_install_nettle - else - echo_info "6. Not checking the required softwares/packages ..." - touch ./.lock_oaibuild - fi - -############################################ -# compile -############################################ - - echo_info "7. compiling and installing the OAI binaries ..." - - softmodem_compiled=1 - oaisim_compiled=1 - unisim_compiled=1 - - if [ $TARGET = "ALL" ]; then - echo "############# compile_ltesoftmodem #############" >> bin/install_log.txt - output=$(compile_ltesoftmodem >> bin/install_log.txt 2>&1 ) - softmodem_compiled=$? - check_for_ltesoftmodem_executable - echo_info "7.1 finished ltesoftmodem target : check the installation log file bin/install_log.txt" - - echo "################ compile_oaisim #################" >> bin/install_log.txt - output=$(compile_oaisim >> bin/install_log.txt 2>&1 ) - oaisim_compiled=$? - check_for_oaisim_executable - echo_info "7.2 finished oaisim target : check the installation log file bin/install_log.txt" - - echo "################## compile_unisim ##################" >> bin/install_log.txt - output=$(compile_unisim >> bin/install_log.txt 2>&1 ) - unisim_compiled=$? - check_for_dlsim_executable - check_for_ulsim_executable - check_for_pucchsim_executable - check_for_prachsim_executable - check_for_pdcchsim_executable - check_for_pbchsim_executable - check_for_mbmssim_executable - echo_info "7.3 finished unisim target : check the installation log file bin/install_log.txt" - - - else - if [ $TARGET == "SOFTMODEM" ]; then - echo "############# compile_ltesoftmodem #############" >> bin/install_log.txt - output=$(compile_ltesoftmodem >> bin/install_log.txt 2>&1 ) - softmodem_compiled=$? - check_for_ltesoftmodem_executable - echo_info "7.1 finished ltesoftmodem target: check the installation log file bin/install_log.txt" - - if [ $HW == "EXMIMO" ]; then - output=$(compile_exmimo2_driver >> bin/install_log.txt 2>&1) - fi - fi - if [ $TARGET = "OAISIM" ]; then - echo "################ compile_oaisim #################" >> bin/install_log.txt - output=$(compile_oaisim >> bin/install_log.txt 2>&1 ) - oaisim_compiled=$? - check_for_oaisim_executable - echo_info "7.2 finished oaisim target: check the installation log file bin/install_log.txt" - - if [ $ENB_S1 -eq 1 ]; then - compile_nas_tools 2>&1 - nas_tools_compiled=$? - check_for_nas_tools_executable - echo_info "7.2.1 finished nas ue target: check the installation log file bin/install_log.txt" - fi - fi - if [ $TARGET = "UNISIM" ]; then - echo "################## compile_unisim ##################" >> bin/install_log.txt - output=$(compile_unisim >> bin/install_log.txt 2>&1 ) - unisim_compiled=$? - check_for_dlsim_executable - check_for_ulsim_executable - check_for_pucchsim_executable - check_for_prachsim_executable - check_for_pdcchsim_executable - check_for_pbchsim_executable - check_for_mbmssim_executable - echo_info "7.3 finished unisim target: check the installation log file bin/install_log.txt" - fi - fi - - -############################################ -# install -############################################ - - echo_info "8. Installing ..." - - if [ $softmodem_compiled -eq 0 ]; then - echo_success "target lte-softmodem built and installed in the bin directory" - echo "target lte-softmodem built and installed in the bin directory" >> bin/${oai_build_date} - output=$(install_ltesoftmodem $RT $HW $ENB_S1 ) - fi - if [ $oaisim_compiled -eq 0 ]; then - echo_success "target oaisim built and installed in the bin directory" - echo "target oaisim built and installed in the bin directory" >> bin/${oai_build_date} - output=$(install_oaisim $ENB_S1 ) - fi - if [ $unisim_compiled -eq 0 ]; then - echo_success "target unisim built and installed in the bin directory" - echo "target unisim built and installed in the bin directory" >> bin/${oai_build_date} - fi - - echo_info "build terminated, binaries are located in bin/" - echo_info "build terminated, logs are located in bin/${oai_build_date} and bin/install_log.txt" - - - -} -build_epc(){ - - epc_compiled=1 - - echo_info "Note: this scripts tested only on Ubuntu 14.04x64" - -###################################### -# CHECK MISC SOFTWARES AND LIBS # -###################################### - if [ $DISABLE_CHECK_INSTALLED_SOFTWARE -eq 0 ]; then - echo_info "4. Checking the the required softwares/packages for EPC..." - - check_install_epc_software - check_install_asn1c - if [ $OAI_CLEAN -eq 1 ]; then - check_install_freediamter - else - if [ ! -d /usr/local/etc/freeDiameter ]; then - check_install_freediamter - fi - fi - else - echo_info "4. Not checking the required softwares/packages for EPC" - fi - -########################################### -# configure and compile -########################################## - - echo_info "5. configure and compile epc" - - output=$(compile_epc $OAI_CLEAN >> $OPENAIR_TARGETS/bin/install_log.txt 2>&1 ) - epc_compiled=$? - if [ $epc_compiled -ne 0 ]; then - echo_error "EPC compilation failed : check the installation log file bin/install_log.txt" - exit 1 - fi - check_for_epc_executable - echo_info "finished epc target: check the installation log file bin/install_log.txt" - - if [ $CONFIG_FILE_ACCESS_OK -eq 0 ]; then - echo_error "You have to provide a EPC config file" - exit 1 - fi - - TEMP_FILE=`tempfile` - VARIABLES=" S6A_CONF\|\ - HSS_HOSTNAME\|\ - REALM" - - VARIABLES=$(echo $VARIABLES | sed -e 's/\\r//g') - VARIABLES=$(echo $VARIABLES | tr -d ' ') - cat $CONFIG_FILE | grep -w "$VARIABLES"| tr -d " " | tr -d ";" > $TEMP_FILE - source $TEMP_FILE - rm -f $TEMP_FILE - - if [ x"$REALM" == "x" ]; then - echo_error "Your config file do not contain a REALM for S6A configuration" - exit 1 - fi - if [ x"$S6A_CONF" != "x./epc_s6a.conf" ]; then - echo_error "Your config file do not contain the good path for the S6A config file," - echo_error "accordingly to what is done in this script, it should be set to epc_s6a.conf" - exit 1 - fi - - check_epc_s6a_certificate $REALM - -########################################### -# install the binary in bin -########################################## - - echo_info "6. install the binary file" - - if [ $epc_compiled -eq 0 ]; then - echo_success "target epc built and installed in the bin directory" - echo "target epc built and installed in the bin directory" >> bin/${oai_build_date} - cp -f $CONFIG_FILE $OPENAIR_TARGETS/bin - cp -f $OPENAIR3_DIR/objs/UTILS/CONF/s6a.conf $OPENAIR_TARGETS/bin/epc_s6a.conf - fi -} - -build_hss(){ - echo_info "Note: this script tested only for Ubuntu 12.04 x64 -> 14.04 x64" - -###################################### -# CHECK MISC SOFTWARES AND LIBS # -###################################### - if [ $DISABLE_CHECK_INSTALLED_SOFTWARE -eq 0 ]; then - echo_info "4. check the required packages for HSS" - check_install_hss_software - if [ $OAI_CLEAN -eq 1 ]; then - check_install_freediamter - else - if [ ! -d /usr/local/etc/freeDiameter ]; then - check_install_freediamter - fi - fi - else - echo_info "4. Not checking the required packages for HSS" - fi - - -###################################### -# compile HSS # -###################################### - echo_info "5. compile HSS" - - # Bad behaviour of $OAI_CLEAN with ./.lock_oaibuild ... - compile_hss $CLEAN_HSS - hss_compiled=$? - check_for_hss_executable - echo_info "finished hss target" - -###################################### -# Check certificates # -###################################### - - TEMP_FILE=`tempfile` - cat $OPENAIR3_DIR/OPENAIRHSS/conf/hss_fd.conf | grep -w "Identity" | tr -d " " | tr -d ";" > $TEMP_FILE - cat $OPENAIR3_DIR/OPENAIRHSS/conf/hss.conf | grep -w "MYSQL_user" | tr -d " " | tr -d ";" >> $TEMP_FILE - cat $OPENAIR3_DIR/OPENAIRHSS/conf/hss.conf | grep -w "MYSQL_pass" | tr -d " " | tr -d ";" >> $TEMP_FILE - cat $OPENAIR3_DIR/OPENAIRHSS/conf/hss.conf | grep -w "MYSQL_db" | tr -d " " | tr -d ";" >> $TEMP_FILE - source $TEMP_FILE - rm -f $TEMP_FILE - - if [ x"$Identity" == "x" ]; then - echo_error "Your config file do not contain a host identity for S6A configuration" - exit 1 - fi - HSS_REALM=$(echo $Identity | sed 's/.*\.//') - HSS_HOSTNAME=${Identity%.$HSS_REALM} - NEW_HOSTNAME=`hostname -s` - if [ "x$HSS_HOSTNAME" != "x$NEW_HOSTNAME" ]; then - echo_warning "Changing identity of HSS from <$HSS_HOSTNAME.$HSS_REALM> to <$NEW_HOSTNAME.$HSS_REALM>" - sed -ibak "s/$HSS_HOSTNAME/$NEW_HOSTNAME/" $OPENAIR3_DIR/OPENAIRHSS/conf/hss_fd.conf - fi - check_hss_s6a_certificate $HSS_REALM - -###################################### -# fill the HSS DB -###################################### - echo_info "6. create HSS database (for EURECOM SIM CARDS)" - hss_db_created=1 - create_hss_database $OAI_DB_ADMIN_USER_NAME $OAI_DB_ADMIN_USER_PASSWORD $MYSQL_user $MYSQL_pass $MYSQL_db - if [ $? -eq 1 ]; then - echo_fatal "hss DB not created" - fi -} - - - - -echo_info "3. set the top-level build target" -case "$BUILD_LTE" in - 'ENB') - echo_success "build LTE eNB" - build_enb - ;; - 'EPC') - echo_success "build EPC(MME and xGW)" - build_epc - ;; - 'HSS') - echo_success "build HSS" - build_hss - ;; - 'NONE') - ;; - *) - ;; -esac - -# Additional operation - -############################################ -# Generate doxygen documentation -############################################ - -if [ $DOXYGEN = 1 ]; then - echo_info "9. Generate doxygen documentation ..." - doxygen $OPENAIR_TARGETS/DOCS/Doxyfile - echo_info "9.1 use your navigator to open $OPENAIR_TARGETS/DOCS/html/index.html " -else - echo_info "9. Bypassing doxygen documentation ..." -fi - - -############################################ -# testing -############################################ - -if [ $OAI_TEST -eq 1 ]; then - echo_info "10. Running OAI pre commit tests (pre-ci) ..." - python $OPENAIR_TARGETS/TEST/OAI/test01.py -l -else - echo_info "10. Bypassing the Tests ..." -fi - -############################################ -# run -############################################ - -if [ $RUN -ne 0 ]; then - echo_info "11. Running ..." - cd $OPENAIR_TARGETS/bin - case "$BUILD_LTE" in - 'ENB') - if [ $TARGET == "SOFTMODEM" ]; then - if [ $HW == "EXMIMO" ]; then - $SUDO chmod 777 $OPENAIR_TARGETS/RT/USER/init_exmimo2.sh - $SUDO $OPENAIR_TARGETS/RT/USER/init_exmimo2.sh - fi - if [ $WIRESHARK -eq 1 ]; then - EXE_ARGUMENTS="$EXE_ARGUMENTS -W" - fi - echo "############# running ltesoftmodem #############" - if [ $RUN_GDB -eq 0 ]; then - $SUDO $OPENAIR_TARGETS/bin/lte-softmodem `echo $EXE_ARGUMENTS` - else - $SUDO setenv MALLOC_CHECK_ 2 - $SUDO touch ~/.gdb_lte_softmodem - $SUDO echo "file $OPENAIR_TARGETS/bin/lte-softmodem" > ~/.gdb_lte_softmodem - $SUDO echo "set args $EXE_ARGUMENTS" >> ~/.gdb_lte_softmodem - $SUDO echo "run" >> ~/.gdb_lte_softmodem - $SUDO gdb -nh -x ~/.gdb_lte_softmodem 2>&1 - fi - - elif [ $TARGET == "OAISIM" ]; then - - if [ $ENB_S1 -eq 0 ]; then - install_nasmesh - else - # prepare NAS for UE - if [ ! -f .ue.nvram0 ]; then - echo_success "generate .ue_emm.nvram0 .ue.nvram0" - $OPENAIR3_DIR/NAS/EURECOM-NAS/bin/ue_data --gen - fi - - if [ ! -f .usim.nvram0 ]; then - echo_success "generate .usim.nvram0" - $OPENAIR3_DIR/NAS/EURECOM-NAS/bin/usim_data --gen - fi - $OPENAIR3_DIR/NAS/EURECOM-NAS/bin/ue_data --print - $OPENAIR3_DIR/NAS/EURECOM-NAS/bin/usim_data --print - - insmod $OPENAIR2_DIR/NETWORK_DRIVER/UE_IP/ue_ip.ko - - fi - if [ $WIRESHARK -eq 1 ]; then - EXE_ARGUMENTS="$EXE_ARGUMENTS -P wireshark" - fi - if [ $RUN_GDB -eq 0 ]; then - $SUDO exec $OPENAIR_TARGETS/bin/oaisim `echo $EXE_ARGUMENTS` - else - $SUDO setenv MALLOC_CHECK_ 2 - $SUDO touch ~/.gdb_oaisim - $SUDO echo "file $OPENAIR_TARGETS/bin/lte-oaisim" > ~/.gdb_oaisim - $SUDO echo "set args $EXE_ARGUMENTS" >> ~/.gdb_oaisim - $SUDO echo "run" >> ~/.gdb_oaisim - $SUDO gdb -nh -x ~/.gdb_oaisim 2>&1 - fi - fi - ;; - - - 'EPC') - echo "############# running EPC #############" - test_is_host_reachable $HSS_HOSTNAME.$REALM HSS - if [ $RUN_GDB -eq 0 ]; then - $SUDO $OPENAIR_TARGETS/bin/oai_epc `echo $EXE_ARGUMENTS` - else - touch ~/.gdb_epc - chmod 777 ~/.gdb_epc - echo "file $OPENAIR_TARGETS/bin/oai_epc" > ~/.gdb_epc - echo "set args $EXE_ARGUMENTS" >> ~/.gdb_epc - echo "run" >> ~/.gdb_epc - $SUDO gdb -nh -x ~/.gdb_epc 2>&1 - fi - ;; - - - 'HSS') - echo "############# running HSS #############" - cd $OPENAIR3_DIR/OPENAIRHSS/objs - if [ $RUN_GDB -eq 0 ]; then - $SUDO exec ./openair-hss -c ./conf/hss.conf - else - touch ~/.gdb_hss - chmod 777 ~/.gdb_hss - echo "file ./openair-hss" > ~/.gdb_hss - echo "set args -c ./conf/hss.conf" >> ~/.gdb_hss - echo "run" >> ~/.gdb_hss - $SUDO gdb -nh -x ~/.gdb_hss 2>&1 - fi - ;; - - - 'NONE') - ;; - - - *) - echo_error "Unknown option $BUILD_LTE: do not execute" - ;; - esac -else - echo_info "11. No run requested, end of script" - exit 0 -fi - -