diff --git a/ci-scripts/Jenkinsfile-gitlab b/ci-scripts/Jenkinsfile-gitlab
index 7e9e3800db..dcaf3b5ea4 100644
--- a/ci-scripts/Jenkinsfile-gitlab
+++ b/ci-scripts/Jenkinsfile-gitlab
@@ -37,36 +37,14 @@ def nodeExecutor = params.nodeExecutor
pipeline {
agent {
- label nodeExecutor
+ label 'paris2024'
}
options {
disableConcurrentBuilds()
timestamps()
gitLabConnection('OAI GitLab')
gitlabBuilds(builds: [
- "Build gNB-USRP",
- "Build nr-UE-USRP",
- "Build eNB-USRP",
- "Build basic-sim",
- "Build phy-sim",
- "Build eNB-ethernet",
- "Build UE-ethernet",
- "Analysis with cppcheck",
- "Test phy-sim",
- "Test basic-sim",
- "Test L1-sim",
- "Test RF-sim",
- "Test L2-sim",
- "Test-Mono-FDD-Band7",
- "Test-Mono-TDD-Band40",
- "Test-IF4p5-FDD-Band7",
- "Test-IF4p5-TDD-Band40",
- "Test-Mono-FDD-Band13-LTE-M",
- "Test-IF4p5-TDD-Band38-Multi-RRU",
- "Test-eNB-OAI-UE-FDD-Band7",
- "Test-Mono-FDD-Band13-X2-HO",
- "Test-TDD-Band78-gNB-NR-UE",
- "Test-OCP-FDD-Band7"
+ "Analysis with cppcheck"
])
ansiColor('xterm')
}
@@ -156,62 +134,6 @@ pipeline {
}
}
}
-
- stage ("Start VM -- basic-sim") {
- steps {
- timeout (time: 5, unit: 'MINUTES') {
- sh "./ci-scripts/oai-ci-vm-tool build --workspace $WORKSPACE --variant basic-sim --job-name ${JOB_NAME} --build-id ${BUILD_ID} --daemon"
- }
- }
- }
-
- stage ("Start VM -- gnb-usrp") {
- steps {
- timeout (time: 5, unit: 'MINUTES') {
- sh "./ci-scripts/oai-ci-vm-tool build --workspace $WORKSPACE --variant gnb-usrp --job-name ${JOB_NAME} --build-id ${BUILD_ID} --daemon"
- }
- }
- }
-
- stage ("Start VM -- nr-ue-usrp") {
- steps {
- timeout (time: 5, unit: 'MINUTES') {
- sh "./ci-scripts/oai-ci-vm-tool build --workspace $WORKSPACE --variant nr-ue-usrp --job-name ${JOB_NAME} --build-id ${BUILD_ID} --daemon"
- }
- }
- }
-
- stage ("Start VM -- enb-usrp") {
- steps {
- timeout (time: 5, unit: 'MINUTES') {
- sh "./ci-scripts/oai-ci-vm-tool build --workspace $WORKSPACE --variant enb-usrp --job-name ${JOB_NAME} --build-id ${BUILD_ID} --daemon"
- }
- }
- }
-
- stage ("Start VM -- phy-sim") {
- steps {
- timeout (time: 5, unit: 'MINUTES') {
- sh "./ci-scripts/oai-ci-vm-tool build --workspace $WORKSPACE --variant phy-sim --job-name ${JOB_NAME} --build-id ${BUILD_ID} --daemon"
- }
- }
- }
-
- stage ("Start VM -- enb-ethernet") {
- steps {
- timeout (time: 5, unit: 'MINUTES') {
- sh "./ci-scripts/oai-ci-vm-tool build --workspace $WORKSPACE --variant enb-ethernet --job-name ${JOB_NAME} --build-id ${BUILD_ID} --daemon"
- }
- }
- }
-
- stage ("Start VM -- ue-ethernet") {
- steps {
- timeout (time: 5, unit: 'MINUTES') {
- sh "./ci-scripts/oai-ci-vm-tool build --workspace $WORKSPACE --variant ue-ethernet --job-name ${JOB_NAME} --build-id ${BUILD_ID} --daemon"
- }
- }
- }
stage ("Start VM -- cppcheck") {
steps {
@@ -232,69 +154,6 @@ pipeline {
}
}
}
- stage ("Build basic simulator") {
- steps {
- gitlabCommitStatus(name: "Build basic-sim") {
- timeout (time: 20, unit: 'MINUTES') {
- sh "./ci-scripts/oai-ci-vm-tool wait --workspace $WORKSPACE --variant basic-sim --job-name ${JOB_NAME} --build-id ${BUILD_ID} --keep-vm-alive"
- }
- }
- }
- }
- stage ("Build 5G gNB-USRP") {
- steps {
- gitlabCommitStatus(name: "Build gNB-USRP") {
- timeout (time: 20, unit: 'MINUTES') {
- sh "./ci-scripts/oai-ci-vm-tool wait --workspace $WORKSPACE --variant gnb-usrp --job-name ${JOB_NAME} --build-id ${BUILD_ID} --keep-vm-alive"
- }
- }
- }
- }
- stage ("Build 5G NR-UE-USRP") {
- steps {
- gitlabCommitStatus(name: "Build nr-UE-USRP") {
- timeout (time: 20, unit: 'MINUTES') {
- sh "./ci-scripts/oai-ci-vm-tool wait --workspace $WORKSPACE --variant nr-ue-usrp --job-name ${JOB_NAME} --build-id ${BUILD_ID} --keep-vm-alive"
- }
- }
- }
- }
- stage ("Build eNB-USRP") {
- steps {
- gitlabCommitStatus(name: "Build eNB-USRP") {
- timeout (time: 20, unit: 'MINUTES') {
- sh "./ci-scripts/oai-ci-vm-tool wait --workspace $WORKSPACE --variant enb-usrp --job-name ${JOB_NAME} --build-id ${BUILD_ID}"
- }
- }
- }
- }
- stage ("Build physical simulators") {
- steps {
- gitlabCommitStatus(name: "Build phy-sim") {
- timeout (time: 20, unit: 'MINUTES') {
- sh "./ci-scripts/oai-ci-vm-tool wait --workspace $WORKSPACE --variant phy-sim --job-name ${JOB_NAME} --build-id ${BUILD_ID} --keep-vm-alive"
- }
- }
- }
- }
- stage ("Build eNB-ethernet") {
- steps {
- gitlabCommitStatus(name: "Build eNB-ethernet") {
- timeout (time: 20, unit: 'MINUTES') {
- sh "./ci-scripts/oai-ci-vm-tool wait --workspace $WORKSPACE --variant enb-ethernet --job-name ${JOB_NAME} --build-id ${BUILD_ID} --keep-vm-alive"
- }
- }
- }
- }
- stage ("Build UE-ethernet") {
- steps {
- gitlabCommitStatus(name: "Build UE-ethernet") {
- timeout (time: 20, unit: 'MINUTES') {
- sh "./ci-scripts/oai-ci-vm-tool wait --workspace $WORKSPACE --variant ue-ethernet --job-name ${JOB_NAME} --build-id ${BUILD_ID} --keep-vm-alive"
- }
- }
- }
- }
}
post {
failure {
@@ -347,345 +206,9 @@ pipeline {
}
}
}
-
- stage ("Variant Tests") {
- parallel {
- stage ("VM-based tests") {
- stages {
- stage ("Test physical simulators") {
- steps {
- script {
- timeout (time: 90, unit: 'MINUTES') {
- try {
- gitlabCommitStatus(name: "Test phy-sim") {
- sh "./ci-scripts/oai-ci-vm-tool test --workspace $WORKSPACE --variant phy-sim --job-name ${JOB_NAME} --build-id ${BUILD_ID}"
- }
- } catch (Exception e) {
- currentBuild.result = 'FAILURE'
- }
- }
- }
- }
- }
- stage ("Build Flexran Controller") {
- when {
- expression {doFlexranCtrlTest}
- }
- steps {
- script {
- timeout (time: 20, unit: 'MINUTES') {
- try {
- sh "./ci-scripts/oai-ci-vm-tool build --workspace $WORKSPACE --variant flexran-rtc --job-name ${JOB_NAME} --build-id ${BUILD_ID} --keep-vm-alive"
- } catch (Exception e) {
- currentBuild.result = 'FAILURE'
- }
- }
- }
- }
- }
- stage ("Test basic simulator") {
- steps {
- script {
- timeout (time: 30, unit: 'MINUTES') {
- try {
- gitlabCommitStatus(name: "Test basic-sim") {
- sh "./ci-scripts/oai-ci-vm-tool test --workspace $WORKSPACE --variant basic-sim --job-name ${JOB_NAME} --build-id ${BUILD_ID}"
- }
- } catch (Exception e) {
- currentBuild.result = 'FAILURE'
- }
- }
- }
- }
- }
- stage ("Test L1 simulator") {
- steps {
- script {
- timeout (time: 30, unit: 'MINUTES') {
- try {
- gitlabCommitStatus(name: "Test L1-sim") {
- sh "./ci-scripts/oai-ci-vm-tool test --workspace $WORKSPACE --variant l1-sim --job-name ${JOB_NAME} --build-id ${BUILD_ID} --keep-vm-alive"
- }
- } catch (Exception e) {
- currentBuild.result = 'FAILURE'
- }
- }
- }
- }
- }
- stage ("Test RF simulator") {
- steps {
- script {
- timeout (time: 30, unit: 'MINUTES') {
- try {
- gitlabCommitStatus(name: "Test RF-sim") {
- sh "./ci-scripts/oai-ci-vm-tool test --workspace $WORKSPACE --variant rf-sim --job-name ${JOB_NAME} --build-id ${BUILD_ID} --keep-vm-alive"
- }
- } catch (Exception e) {
- currentBuild.result = 'FAILURE'
- }
- }
- }
- }
- }
- stage ("Test L2 simulator") {
- steps {
- 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") {
- steps {
- sh "./ci-scripts/oai-ci-vm-tool destroy --job-name ${JOB_NAME} --build-id ${BUILD_ID}"
- }
- }
- }
- }
- stage ("Test MONOLITHIC - FDD - Band 7 - B210") {
- steps {
- script {
- triggerSlaveJob ('eNB-CI-FDD-Band7-B210', 'Test-Mono-FDD-Band7')
- }
- }
- post {
- always {
- script {
- finalizeSlaveJob('eNB-CI-FDD-Band7-B210')
- }
- }
- failure {
- script {
- currentBuild.result = 'FAILURE'
- }
- }
- }
- }
- stage ("Test MONOLITHIC - TDD - Band 40 - B210") {
- steps {
- script {
- triggerSlaveJob ('eNB-CI-TDD-Band40-B210', 'Test-Mono-TDD-Band40')
- }
- }
- post {
- always {
- script {
- finalizeSlaveJob('eNB-CI-TDD-Band40-B210')
- }
- }
- failure {
- script {
- currentBuild.result = 'FAILURE'
- }
- }
- }
- }
- stage ("Test IF4p5 - FDD - Band 7 - B210") {
- steps {
- script {
- sh "sleep 60"
- triggerSlaveJob ('eNB-CI-IF4p5-FDD-Band7-B210', 'Test-IF4p5-FDD-Band7')
- }
- }
- post {
- always {
- script {
- finalizeSlaveJob('eNB-CI-IF4p5-FDD-Band7-B210')
- }
- }
- failure {
- script {
- currentBuild.result = 'FAILURE'
- }
- }
- }
- }
- stage ("Test IF4p5 - TDD - Band 40 - B210") {
- steps {
- script {
- sh "sleep 60"
- triggerSlaveJob ('eNB-CI-IF4p5-TDD-Band40-B210', 'Test-IF4p5-TDD-Band40')
- }
- }
- post {
- always {
- script {
- finalizeSlaveJob('eNB-CI-IF4p5-TDD-Band40-B210')
- }
- }
- failure {
- script {
- currentBuild.result = 'FAILURE'
- }
- }
- }
- }
- stage ("Test MONOLITHIC - FDD - Band 13 - B210") {
- 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") {
- 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") {
- 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") {
- steps {
- script {
- triggerSlaveJobNoGitLab ('UE-CI-FDD-Band20-B200')
- }
- }
- post {
- always {
- script {
- finalizeSlaveJob('UE-CI-FDD-Band20-B200')
- }
- }
- failure {
- script {
- currentBuild.result = 'FAILURE'
- }
- }
- }
- }
- stage ("Test OAI UE - OAI eNB - FDD - Band 7 - B200") {
- steps {
- script {
- // Delayed trigger on slave job, so it is always the last one to run
- sh "sleep 240"
- triggerSlaveJob ('eNB-UE-CI-MONO-FDD-Band7-B200', 'Test-eNB-OAI-UE-FDD-Band7')
- }
- }
- post {
- always {
- script {
- finalizeSlaveJob('eNB-UE-CI-MONO-FDD-Band7-B200')
- }
- }
- failure {
- script {
- currentBuild.result = 'FAILURE'
- }
- }
- }
- }
- stage ("Test OAI NR UE - OAI gNB - TDD - Band 78 - N300") {
- 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") {
- 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 {
- script {
- dir ('archives') {
- sh "if [ -d basic_sim/test ] || [ -d phy_sim/test ] || [ -d l2_sim/test ]; then zip -r -qq vm_tests_logs.zip */test ; fi"
- }
- if(fileExists('archives/vm_tests_logs.zip')) {
- archiveArtifacts artifacts: 'archives/vm_tests_logs.zip'
- if ("MERGE".equals(env.gitlabActionType)) {
- sh "./ci-scripts/oai-ci-vm-tool report-test --workspace $WORKSPACE --git-url ${GIT_URL} --job-name ${JOB_NAME} --build-id ${BUILD_ID} --trigger merge-request --src-branch ${env.gitlabSourceBranch} --src-commit ${env.gitlabMergeRequestLastCommit} --target-branch ${env.gitlabTargetBranch} --target-commit ${GIT_COMMIT}"
- } else {
- sh "./ci-scripts/oai-ci-vm-tool report-test --workspace $WORKSPACE --git-url ${GIT_URL} --job-name ${JOB_NAME} --build-id ${BUILD_ID} --trigger push --branch ${GIT_BRANCH} --commit ${GIT_COMMIT}"
- }
- if(fileExists('test_simulator_results.html')) {
- sh "sed -i -e 's#Build-ID: ${BUILD_ID}#Build-ID: ${BUILD_ID}#' -e 's#TEMPLATE_BUILD_TIME#${JOB_TIMESTAMP}#' test_simulator_results.html"
- archiveArtifacts artifacts: 'test_simulator_results.html'
- }
- }
- }
- }
+ stage ("Destroy all Virtual Machines") {
+ steps {
+ sh "./ci-scripts/oai-ci-vm-tool destroy --job-name ${JOB_NAME} --build-id ${BUILD_ID}"
}
}
}
@@ -703,12 +226,14 @@ Regards,
OAI CI Team''',
replyTo: 'no-reply@openairinterface.org',
subject: '$PROJECT_NAME - Build # $BUILD_NUMBER - $BUILD_STATUS!',
- to: gitCommitAuthorEmailAddr
+ to: 'donganyuan@cn.fujitsu.com'
if (fileExists('.git/CI_COMMIT_MSG')) {
sh "rm -f .git/CI_COMMIT_MSG"
}
}
+ echo '\u2705 \u001B[32mClean Up WorkSpace\u001B[0m'
+ deleteDir()
}
success {
script {
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 36e93ba14e..aa03e91fd0 100644
--- a/ci-scripts/conf_files/gnb.band78.tm1.106PRB.usrpn300.conf
+++ b/ci-scripts/conf_files/gnb.band78.tm1.106PRB.usrpn300.conf
@@ -131,12 +131,12 @@ gNBs =
# 0=unrestricted, 1=restricted type A, 2=restricted type B
restrictedSetConfig = 0,
# pusch-ConfigCommon (up to 16 elements)
- initialULBWPk2_0 = 2;
+ initialULBWPk2_0 = 6;
initialULBWPmappingType_0 = 1
# this is SS=0 L=11
initialULBWPstartSymbolAndLength_0 = 55;
- initialULBWPk2_1 = 2;
+ initialULBWPk2_1 = 6;
initialULBWPmappingType_1 = 1;
# this is SS=0 L=12
initialULBWPstartSymbolAndLength_1 = 69;
diff --git a/ci-scripts/reportTestLocally.sh b/ci-scripts/reportTestLocally.sh
index b05ccf39db..5f5f5caa35 100755
--- a/ci-scripts/reportTestLocally.sh
+++ b/ci-scripts/reportTestLocally.sh
@@ -765,6 +765,59 @@ function report_test {
echo "
Test without EPC (aka noS1): ${TMODE} -- ${BW}PRB | " >> ./test_simulator_results.html
fi
echo " " >> ./test_simulator_results.html
+
+ #RA test (--do-ra option)
+
+ #build log files names
+ RA_ENB_LOG=$ARCHIVES_LOC/ra_check_${TMODE}_${BW}prb_${CN_CONFIG}_gnb.log
+ RA_UE_LOG=$ARCHIVES_LOC/ra_check_${TMODE}_${BW}prb_${CN_CONFIG}_ue.log
+ if [ -f $RA_ENB_LOG ] && [ -f $RA_UE_LOG ]
+ then
+ #get rid of full path
+ NAME_ENB=`echo $RA_ENB_LOG | sed -e "s#$ARCHIVES_LOC/##"`
+ NAME_UE=`echo $RA_UE_LOG | sed -e "s#$ARCHIVES_LOC/##"`
+ echo " " >> ./test_simulator_results.html
+ echo " | $NAME_ENB --- $NAME_UE | " >> ./test_simulator_results.html
+ echo " Check if RA proc succeeded | " >> ./test_simulator_results.html
+
+ #gNB RA check
+ GNB_RECEIVED=`egrep -c "received correctly" $RA_ENB_LOG`
+ GNB_CONNECTED=`egrep -c "now 5G connected" $RA_ENB_LOG`
+ #UE RA check
+ UE_RA_PROC_OK=`egrep -c "RA procedure succeeded" $RA_UE_LOG`
+
+
+ if [ $GNB_RECEIVED -gt 0 ] && [ $GNB_CONNECTED -gt 0 ] && [ $UE_RA_PROC_OK -gt 0 ]
+ then
+ echo " OK | " >> ./test_simulator_results.html
+ else
+ echo " KO | " >> ./test_simulator_results.html
+ fi
+
+ echo " " >> ./test_simulator_results.html
+ if [ $GNB_RECEIVED -gt 0 ]
+ then
+ echo "- gNB --> RA received" >> ./test_simulator_results.html
+ else
+ echo "- gNB RA NOT RECEIVED" >> ./test_simulator_results.html
+ fi
+ if [ $GNB_CONNECTED -gt 0 ]
+ then
+ echo "- gNB --> 5G connected" >> ./test_simulator_results.html
+ else
+ echo "- gNB NOT 5G CONNECTED" >> ./test_simulator_results.html
+ fi
+ if [ $UE_RA_PROC_OK -gt 0 ]
+ then
+ echo "- NR UE --> RA procedure succeded" >> ./test_simulator_results.html
+ else
+ echo "- NR UE RA procedure failed" >> ./test_simulator_results.html
+ fi
+ echo " | " >> ./test_simulator_results.html
+ echo "
" >> ./test_simulator_results.html
+ fi
+
+ #SYNC test
ENB_LOG=$ARCHIVES_LOC/${TMODE}_${BW}prb_${CN_CONFIG}_gnb.log
UE_LOG=`echo $ENB_LOG | sed -e "s#gnb#ue#"`
if [ -f $ENB_LOG ] && [ -f $UE_LOG ]
diff --git a/ci-scripts/runTestOnVM.sh b/ci-scripts/runTestOnVM.sh
index e6b93b5b4d..7f2ce6279d 100755
--- a/ci-scripts/runTestOnVM.sh
+++ b/ci-scripts/runTestOnVM.sh
@@ -276,6 +276,22 @@ function check_ping_result {
fi
}
+
+function check_ra_result {
+ local LOC_GNB_LOG=$1
+ local LOC_UE_LOG=$2
+
+ #gNB RA test
+ echo "Checking gNB Log for RA success"
+ egrep "received correctly" $1
+ egrep "now 5G connected" $1
+
+ #UE RA test
+ echo 'Checking UE Log for RA success'
+ egrep "RA procedure succeeded" $2
+
+}
+
# In DL: iperf server should be on UE side
# -B oaitun_ue{j}-IP-Addr
# iperf client should be on EPC (S1) or eNB (noS1) side
@@ -1172,6 +1188,8 @@ function start_rf_sim_gnb {
local LOC_CONF_FILE=$5
# 1 is with S1 and 0 without S1 aka noS1
local LOC_S1_CONFIGURATION=$6
+ #LOC_RA_TEST=1 will run the RA test check
+ local LOC_RA_TEST=$7
if [ -e rbconfig.raw ]; then rm -f rbconfig.raw; fi
if [ -e reconfig.raw ]; then rm -f reconfig.raw; fi
@@ -1192,7 +1210,12 @@ function start_rf_sim_gnb {
echo "sudo rm -f r*config.raw" >> $1
if [ $LOC_S1_CONFIGURATION -eq 0 ]
then
- echo "echo \"RFSIMULATOR=server ./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\" > ./my-nr-softmodem-run.sh " >> $1
+ if [ $LOC_RA_TEST -eq 0 ] #no RA test => use --phy-test option
+ then
+ echo "echo \"RFSIMULATOR=server ./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\" > ./my-nr-softmodem-run.sh " >> $1
+ else #RA test => use --do-ra option
+ echo "echo \"RFSIMULATOR=server ./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 --do-ra\" > ./my-nr-softmodem-run.sh " >> $1
+ fi
fi
echo "chmod 775 ./my-nr-softmodem-run.sh" >> $1
echo "cat ./my-nr-softmodem-run.sh" >> $1
@@ -1249,6 +1272,8 @@ function start_rf_sim_gnb {
echo "RF-SIM gNB oaitun_enb1 is UP and CONFIGURED"
fi
fi
+
+
sleep 10
echo "echo \"free -m\"" > $1
echo "free -m" >> $1
@@ -1267,6 +1292,8 @@ function start_rf_sim_nr_ue {
local LOC_FREQUENCY=$6
# 1 is with S1 and 0 without S1 aka noS1
local LOC_S1_CONFIGURATION=$7
+ #LOC_RA_TEST=1 will run the RA test check
+ local LOC_RA_TEST=$8
# Copy the RAW files from the gNB run
scp -o StrictHostKeyChecking=no rbconfig.raw ubuntu@$LOC_NR_UE_VM_IP_ADDR:/home/ubuntu/tmp
@@ -1281,7 +1308,12 @@ function start_rf_sim_nr_ue {
echo "cd /home/ubuntu/tmp/cmake_targets/ran_build/build/" >> $1
if [ $LOC_S1_CONFIGURATION -eq 0 ]
then
- echo "echo \"RFSIMULATOR=${LOC_GNB_VM_IP_ADDR} ./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
+ if [ $LOC_RA_TEST -eq 0 ] #no RA test => use --phy-test option
+ then
+ echo "echo \"RFSIMULATOR=${LOC_GNB_VM_IP_ADDR} ./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
+ else #RA test => use --do-ra option
+ echo "echo \"RFSIMULATOR=${LOC_GNB_VM_IP_ADDR} ./nr-uesoftmodem --nokrnmod 1 --rfsim --do-ra --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
+ fi
fi
echo "chmod 775 ./my-nr-softmodem-run.sh" >> $1
echo "cat ./my-nr-softmodem-run.sh" >> $1
@@ -1340,6 +1372,8 @@ function start_rf_sim_nr_ue {
echo "RF-SIM NR-UE oaitun_ue1 is UP and CONFIGURED"
fi
sleep 10
+
+
}
@@ -2138,6 +2172,8 @@ function run_test_on_vm {
######### start of loop
while [ $try_cnt -lt 4 ]
do
+
+ #start RA test
SYNC_STATUS=0
PING_STATUS=0
IPERF_STATUS=0
@@ -2146,13 +2182,69 @@ function run_test_on_vm {
echo "${CN_CONFIG} : Starting the gNB"
echo "############################################################"
CURRENT_GNB_LOG_FILE=tdd_${PRB}prb_${CN_CONFIG}_gnb.log
- start_rf_sim_gnb $GNB_VM_CMDS "$GNB_VM_IP_ADDR" $CURRENT_GNB_LOG_FILE $PRB $CONF_FILE $S1_NOS1_CFG
+ #last argument = 1 is to enable --do-ra for RA test
+ start_rf_sim_gnb $GNB_VM_CMDS "$GNB_VM_IP_ADDR" $CURRENT_GNB_LOG_FILE $PRB $CONF_FILE $S1_NOS1_CFG 1
echo "############################################################"
echo "${CN_CONFIG} : Starting the NR-UE"
echo "############################################################"
CURRENT_NR_UE_LOG_FILE=tdd_${PRB}prb_${CN_CONFIG}_ue.log
- start_rf_sim_nr_ue $NR_UE_VM_CMDS $NR_UE_VM_IP_ADDR $GNB_VM_IP_ADDR $CURRENT_NR_UE_LOG_FILE $PRB $FREQUENCY $S1_NOS1_CFG
+ #last argument = 1 is to enable --do-ra for RA test
+ start_rf_sim_nr_ue $NR_UE_VM_CMDS $NR_UE_VM_IP_ADDR $GNB_VM_IP_ADDR $CURRENT_NR_UE_LOG_FILE $PRB $FREQUENCY $S1_NOS1_CFG 1
+ if [ $NR_UE_SYNC -eq 0 ]
+ then
+ echo "Problem w/ gNB and NR-UE not syncing"
+ terminate_enb_ue_basic_sim $NR_UE_VM_CMDS $NR_UE_VM_IP_ADDR 2
+ terminate_enb_ue_basic_sim $GNB_VM_CMDS $GNB_VM_IP_ADDR 1
+ scp -o StrictHostKeyChecking=no ubuntu@$GNB_VM_IP_ADDR:/home/ubuntu/tmp/cmake_targets/log/$CURRENT_GNB_LOG_FILE $ARCHIVES_LOC
+ scp -o StrictHostKeyChecking=no ubuntu@$NR_UE_VM_IP_ADDR:/home/ubuntu/tmp/cmake_targets/log/$CURRENT_NR_UE_LOG_FILE $ARCHIVES_LOC
+ SYNC_STATUS=-1
+ try_cnt=$[$try_cnt+1]
+ continue
+ fi
+
+
+ echo "############################################################"
+ echo "${CN_CONFIG} : Terminate gNB/NR-UE simulators"
+ echo "############################################################"
+ sleep 20
+ terminate_enb_ue_basic_sim $NR_UE_VM_CMDS $NR_UE_VM_IP_ADDR 2
+ terminate_enb_ue_basic_sim $GNB_VM_CMDS $GNB_VM_IP_ADDR 1
+ scp -o StrictHostKeyChecking=no ubuntu@$GNB_VM_IP_ADDR:/home/ubuntu/tmp/cmake_targets/log/$CURRENT_GNB_LOG_FILE $ARCHIVES_LOC
+ scp -o StrictHostKeyChecking=no ubuntu@$NR_UE_VM_IP_ADDR:/home/ubuntu/tmp/cmake_targets/log/$CURRENT_NR_UE_LOG_FILE $ARCHIVES_LOC
+
+
+
+ #check RA markers in gNB and NR UE log files
+ echo "############################################################"
+ echo "${CN_CONFIG} : Checking RA on gNB / NR-UE"
+ echo "############################################################"
+
+ mv $ARCHIVES_LOC/$CURRENT_GNB_LOG_FILE $ARCHIVES_LOC/ra_check_$CURRENT_GNB_LOG_FILE
+ mv $ARCHIVES_LOC/$CURRENT_NR_UE_LOG_FILE $ARCHIVES_LOC/ra_check_$CURRENT_NR_UE_LOG_FILE
+ check_ra_result $ARCHIVES_LOC/ra_check_$CURRENT_GNB_LOG_FILE $ARCHIVES_LOC/ra_check_$CURRENT_NR_UE_LOG_FILE
+
+
+ #end RA test
+
+
+
+
+ SYNC_STATUS=0
+ PING_STATUS=0
+ IPERF_STATUS=0
+
+ echo "############################################################"
+ echo "${CN_CONFIG} : Starting the gNB"
+ echo "############################################################"
+ CURRENT_GNB_LOG_FILE=tdd_${PRB}prb_${CN_CONFIG}_gnb.log
+ start_rf_sim_gnb $GNB_VM_CMDS "$GNB_VM_IP_ADDR" $CURRENT_GNB_LOG_FILE $PRB $CONF_FILE $S1_NOS1_CFG 0
+
+ echo "############################################################"
+ echo "${CN_CONFIG} : Starting the NR-UE"
+ echo "############################################################"
+ CURRENT_NR_UE_LOG_FILE=tdd_${PRB}prb_${CN_CONFIG}_ue.log
+ start_rf_sim_nr_ue $NR_UE_VM_CMDS $NR_UE_VM_IP_ADDR $GNB_VM_IP_ADDR $CURRENT_NR_UE_LOG_FILE $PRB $FREQUENCY $S1_NOS1_CFG 0
if [ $NR_UE_SYNC -eq 0 ]
then
echo "Problem w/ gNB and NR-UE not syncing"
diff --git a/cmake_targets/CMakeLists.txt b/cmake_targets/CMakeLists.txt
index 02c391a878..33b5da8a73 100644
--- a/cmake_targets/CMakeLists.txt
+++ b/cmake_targets/CMakeLists.txt
@@ -879,6 +879,7 @@ add_boolean_option(UE_EXPANSION False "enable UE_EXPANSION w
add_boolean_option(PHY_TX_THREAD False "enable UE_EXPANSION with max 256 UE")
add_boolean_option(PRE_SCD_THREAD False "enable UE_EXPANSION with max 256 UE")
add_boolean_option(UESIM_EXPANSION False "enable UESIM_EXPANSION with max 256 UE")
+add_boolean_option(ITTI_SIM False "enable itti simulator")
########################
# Include order
@@ -2057,7 +2058,7 @@ add_dependencies(L2_UE rrc_flag s1ap_flag x2_flag)
add_library( NR_L2_UE ${NR_L2_SRC_UE} ${MAC_NR_SRC_UE} )
-add_library( MAC_NR_COMMON ${OPENAIR2_DIR}/LAYER2/NR_MAC_COMMON/nr_mac_common.c ${OPENAIR2_DIR}/LAYER2/NR_MAC_gNB/nr_compute_tbs_common.c)
+add_library( MAC_NR_COMMON ${OPENAIR2_DIR}/LAYER2/NR_MAC_COMMON/nr_mac_common.c ${OPENAIR2_DIR}/LAYER2/NR_MAC_COMMON/nr_compute_tbs_common.c)
include_directories("${OPENAIR2_DIR}/NR_UE_PHY_INTERFACE")
include_directories("${OPENAIR2_DIR}/LAYER2")
@@ -2846,6 +2847,7 @@ add_executable(nr-softmodem
${s1ap_h}
# ${OPENAIR_BIN_DIR}/messages_xml.h
${OPENAIR_DIR}/executables/nr-gnb.c
+ ${OPENAIR_DIR}/common/utils/threadPool/thread-pool.c
${OPENAIR_DIR}/executables/nr-ru.c
${OPENAIR_DIR}/executables/nr-softmodem.c
${OPENAIR_DIR}/executables/softmodem-common.c
@@ -2911,7 +2913,7 @@ add_executable(nr-uesoftmodem
target_link_libraries (nr-uesoftmodem
-Wl,--start-group
- RRC_LIB NR_RRC_LIB SECU_CN SECU_OSA UTIL HASHTABLE SCTP_CLIENT UDP SCHED_RU_LIB SCHED_UE_LIB SCHED_NR_UE_LIB
+ RRC_LIB NR_RRC_LIB NGAP_LIB NGAP_GNB SECU_CN SECU_OSA UTIL HASHTABLE SCTP_CLIENT UDP SCHED_RU_LIB SCHED_UE_LIB SCHED_NR_UE_LIB
PHY_COMMON PHY_NR_COMMON PHY_UE PHY_NR_UE PHY_RU LFDS NR_L2_UE L2_UE_LTE_NR MAC_NR_COMMON NFAPI_COMMON_LIB NFAPI_LIB NFAPI_PNF_LIB
NFAPI_USER_LIB S1AP_LIB S1AP_ENB
${MSC_LIB} ${RAL_LIB} ${NAS_UE_LIB} ${ITTI_LIB} ${FLPT_MSG_LIB} ${ASYNC_IF_LIB} LFDS7 ${ATLAS_LIBRARIES}
@@ -3107,6 +3109,7 @@ target_link_libraries(nr_prachsim
add_executable(nr_ulschsim
${OPENAIR1_DIR}/SIMULATION/NR_PHY/ulschsim.c
+ ${OPENAIR_DIR}/common/utils/threadPool/thread-pool.c
${OPENAIR_DIR}/common/utils/utils.c
${OPENAIR_DIR}/common/utils/system.c
${OPENAIR_DIR}/common/utils/nr/nr_common.c
@@ -3121,6 +3124,7 @@ target_link_libraries(nr_ulschsim
add_executable(nr_ulsim
${OPENAIR1_DIR}/SIMULATION/NR_PHY/ulsim.c
+ ${OPENAIR_DIR}/common/utils/threadPool/thread-pool.c
${OPENAIR_DIR}/common/utils/utils.c
${OPENAIR_DIR}/common/utils/system.c
${OPENAIR_DIR}/common/utils/nr/nr_common.c
@@ -3220,7 +3224,7 @@ if (${T_TRACER})
foreach(i
#all "add_executable" definitions (except tests, rb_tool, updatefw)
lte-softmodem lte-uesoftmodem nr-softmodem
- nr-uesoftmodem dlsim dlsim_tm4 dlsim_tm7
+ nr-uesoftmodem dlsim dlsim_tm4 dlsim_tm7 nr-ittisim
ulsim pbchsim scansim mbmssim pdcchsim pucchsim prachsim
syncsim nr_ulsim nr_dlsim nr_dlschsim nr_pbchsim nr_pucchsim
nr_ulschsim ldpctest polartest smallblocktest cu_test du_test
@@ -3307,6 +3311,60 @@ add_executable(rb_tool
)
target_include_directories(rb_tool PRIVATE ${OPENAIR2_DIR}/NETWORK_DRIVER/MESH/)
+# nr-ittisim
+###################################################
+
+add_executable(nr-ittisim
+ ${rrc_h}
+ ${nr_rrc_h}
+ ${OPENAIR2_DIR}/GNB_APP/gnb_app.c
+ ${OPENAIR2_DIR}/GNB_APP/gnb_config.c
+ ${OPENAIR_DIR}/executables/nr-gnb.c
+ ${OPENAIR_DIR}/executables/nr-ru.c
+ ${OPENAIR2_DIR}/SIMULATION/NR_RRC/itti_sim.c
+ ${OPENAIR_DIR}/executables/softmodem-common.c
+ ${OPENAIR1_DIR}/SIMULATION/TOOLS/taus.c
+ ${OPENAIR_TARGETS}/ARCH/COMMON/common_lib.c
+ ${OPENAIR_TARGETS}/ARCH/COMMON/record_player.c
+ ${OPENAIR2_DIR}/RRC/NAS/nas_config.c
+ ${OPENAIR2_DIR}/RRC/NAS/rb_config.c
+ ${OPENAIR3_DIR}/GTPV1-U/gtpv1u_gNB.c
+ ${OPENAIR1_DIR}/SIMULATION/ETH_TRANSPORT/netlink_init.c
+ ${OPENAIR3_DIR}/NAS/UE/nas_ue_task.c
+ ${OPENAIR_DIR}/common/utils/utils.c
+ ${OPENAIR_DIR}/common/utils/system.c
+ ${OPENAIR_DIR}/common/utils/nr/nr_common.c
+ ${GTPU_need_ITTI}
+ ${XFORMSINTERFACE_SOURCE}
+ ${T_SOURCE}
+ ${CONFIG_SOURCES}
+ ${SHLIB_LOADER_SOURCES}
+ )
+
+#target_link_libraries (nr-ittisim
+# -Wl,--start-group
+# UTIL HASHTABLE SCTP_CLIENT UDP LFDS NR_GTPV1U SECU_CN SECU_OSA
+# ${ITTI_LIB} ${FLPT_MSG_LIB} ${ASYNC_IF_LIB} ${FLEXRAN_AGENT_LIB} LFDS7 ${MSC_LIB} ${RAL_LIB} ${NAS_UE_LIB} RRC_LIB NR_RRC_LIB
+# NGAP_LIB NGAP_GNB S1AP_LIB S1AP_ENB
+# X2AP_LIB X2AP_ENB F1AP_LIB F1AP M2AP_LIB M2AP_ENB M3AP_LIB M3AP_ENB ${PROTO_AGENT_LIB} ${FSPT_MSG_LIB}
+# -Wl,--end-group z dl)
+
+target_link_libraries (nr-ittisim
+ -Wl,--start-group
+ UTIL HASHTABLE SCTP_CLIENT UDP SCHED_LIB SCHED_RU_LIB SCHED_NR_LIB PHY_NR PHY PHY_COMMON PHY_NR_COMMON PHY_RU LFDS NR_GTPV1U SECU_CN SECU_OSA
+ ${ITTI_LIB} ${FLPT_MSG_LIB} ${ASYNC_IF_LIB} ${FLEXRAN_AGENT_LIB} LFDS7 ${MSC_LIB} ${RAL_LIB} ${NAS_UE_LIB} RRC_LIB NR_RRC_LIB
+ NGAP_LIB NGAP_GNB S1AP_LIB S1AP_ENB L2_LTE_NR L2_NR MAC_NR_COMMON NFAPI_COMMON_LIB NFAPI_LIB NFAPI_VNF_LIB NFAPI_PNF_LIB NFAPI_USER_LIB
+ X2AP_LIB X2AP_ENB F1AP_LIB F1AP M2AP_LIB M2AP_ENB M3AP_LIB M3AP_ENB ${PROTO_AGENT_LIB} ${FSPT_MSG_LIB}
+ NR_L2_UE
+ -Wl,--end-group z dl)
+
+target_link_libraries (nr-ittisim ${LIBXML2_LIBRARIES})
+target_link_libraries (nr-ittisim pthread m ${CONFIG_LIB} rt crypt ${CRYPTO_LIBRARIES} ${OPENSSL_LIBRARIES} ${NETTLE_LIBRARIES} sctp ${XFORMS_LIBRARIES} ${PROTOBUF_LIB} ${CMAKE_DL_LIBS} ${LIBYAML_LIBRARIES} ${ATLAS_LIBRARIES})
+target_link_libraries (nr-ittisim ${LIB_LMS_LIBRARIES})
+target_link_libraries (nr-ittisim ${T_LIB})
+
+add_dependencies( nr-ittisim ldpc_orig ldpc_optim ldpc_optim8seg ldpc )
+
# ???
####################
list(APPEND oai_nw_drv_src device.c common.c ioctl.c classifier.c tool.c)
diff --git a/cmake_targets/build_oai b/cmake_targets/build_oai
index f301908495..0fff0b7806 100755
--- a/cmake_targets/build_oai
+++ b/cmake_targets/build_oai
@@ -67,6 +67,7 @@ UE_TIMING_TRACE="False"
USRP_REC_PLAY="False"
BUILD_ECLIPSE=0
NR="False"
+ITTI_SIM="False"
OPTIONAL_LIBRARIES="telnetsrv enbscope uescope nrscope msc"
trap handle_ctrl_c INT
@@ -160,6 +161,8 @@ 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
+--ittiSIM
+ Makes the itti simulator
-h | --help
Print this help
@@ -418,6 +421,11 @@ function main() {
CMAKE_CMD="$CMAKE_CMD -GNinja"
MAKE_CMD=ninja
shift;;
+ --ittiSIM)
+ ittiSIM=1
+ ITTI_SIM="True"
+ echo_info "Will compile itti simulator"
+ shift;;
-h | --help)
print_help
exit 1;;
@@ -580,7 +588,7 @@ 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 "$nrUE" = "1" -o "$HW" = "EXMIMO" ] ; then
+ if [ "$eNB" = "1" -o "$eNBocp" = "1" -o "$UE" = "1" -o "$gNB" = "1" -o "$nrUE" = "1" -o "$HW" = "EXMIMO" -o "$ittiSIM" = "1" ] ; then
# softmodem compilation
@@ -605,6 +613,7 @@ function main() {
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 'include(${CMAKE_CURRENT_SOURCE_DIR}/../CMakeLists.txt)' >> $cmake_file
cd $DIR/$build_dir/build
eval $CMAKE_CMD
@@ -626,6 +635,10 @@ function main() {
execlist="$execlist nr-uesoftmodem"
fi
+ if [ "$ittiSIM" = "1" ] ; then
+ execlist="$execlist nr-ittisim"
+ fi
+
for f in $execlist ; do
echo_info "Compiling $f..."
compilations \
diff --git a/cmake_targets/phy_simulators/CMakeLists.txt b/cmake_targets/phy_simulators/CMakeLists.txt
index 5f2d34883e..cf68ca4a9d 100644
--- a/cmake_targets/phy_simulators/CMakeLists.txt
+++ b/cmake_targets/phy_simulators/CMakeLists.txt
@@ -1,11 +1,12 @@
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 ( UESIM_EXPANSION False )
set ( ENABLE_VCD_FIFO False )
-set ( RF_BOARD "OAI_USRP")
+set ( RF_BOARD "None")
set ( TRANSP_PRO "None")
set ( PACKAGE_NAME "")
set ( DEADLINE_SCHEDULER "False" )
diff --git a/common/utils/ocp_itti/all_msg.h b/common/utils/ocp_itti/all_msg.h
index 11d1abc7d8..8f7f48ed5a 100644
--- a/common/utils/ocp_itti/all_msg.h
+++ b/common/utils/ocp_itti/all_msg.h
@@ -17,3 +17,7 @@
#include "openair2/COMMON/flexran_messages_def.h"
#include "openair2/COMMON/f1ap_messages_def.h"
#include "openair2/COMMON/ngap_messages_def.h"
+#if ITTI_SIM
+#include "openair2/COMMON/itti_sim_messages_def.h"
+#endif
+
diff --git a/common/utils/ocp_itti/intertask_interface.h b/common/utils/ocp_itti/intertask_interface.h
index 91cf2ce267..1e9472dc01 100644
--- a/common/utils/ocp_itti/intertask_interface.h
+++ b/common/utils/ocp_itti/intertask_interface.h
@@ -260,7 +260,11 @@ typedef struct IttiMsgText_s {
#include
void *rrc_enb_process_itti_msg(void *);
#include
-#include
+#include
+
+#ifdef ITTI_SIM
+#include
+#endif
/*
static const char *const messages_definition_xml = {
@@ -331,6 +335,7 @@ void * rrc_enb_process_msg(void*);
TASK_DEF(TASK_RLC_UE, TASK_PRIORITY_MED, 200, NULL, NULL) \
TASK_DEF(TASK_PDCP_UE, TASK_PRIORITY_MED, 200, NULL, NULL) \
TASK_DEF(TASK_RRC_UE, TASK_PRIORITY_MED, 200, NULL, NULL) \
+ TASK_DEF(TASK_RRC_NRUE, TASK_PRIORITY_MED, 200, NULL, NULL) \
TASK_DEF(TASK_NAS_UE, TASK_PRIORITY_MED, 200, NULL, NULL) \
TASK_DEF(TASK_RAL_UE, TASK_PRIORITY_MED, 200, NULL, NULL) \
TASK_DEF(TASK_MSC, TASK_PRIORITY_MED, 200, NULL, NULL)\
@@ -338,6 +343,8 @@ void * rrc_enb_process_msg(void*);
TASK_DEF(TASK_UDP, TASK_PRIORITY_MED, 1000, NULL, NULL)\
TASK_DEF(TASK_CU_F1, TASK_PRIORITY_MED, 200, NULL, NULL) \
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_MAX, TASK_PRIORITY_MED, 200, NULL, NULL)
#define TASK_DEF(TaskID, pRIO, qUEUEsIZE, FuNc, ThreadFunc) { pRIO, qUEUEsIZE, #TaskID, FuNc, ThreadFunc },
diff --git a/doc/RUNMODEM.md b/doc/RUNMODEM.md
index 37eadd92f3..5fb0824565 100644
--- a/doc/RUNMODEM.md
+++ b/doc/RUNMODEM.md
@@ -100,13 +100,37 @@ Some other useful paramters of the UE are
- --clock-source: sets the clock-source (internal or external).
- --time-source: sets the time-source (internal or external).
-
## noS1 setup with OAI UE
Instead of randomly generated payload, in the phy-test mode we can also inject/receive user-plane traffic over a TUN interface. This is the so-called noS1 mode.
This setup is described in the [rfsimulator page](../targets/ARCH/rfsimulator/README.md#5g-case). In theory this should also work with the real hardware target although this has yet to be tested.
+## do-ra setup with OAI
+
+The do-ra flag is used to ran the NR Random Access procedures in contention-free mode. Currently OAI implements the RACH process from Msg1 to Msg3.
+
+In order to run the RA, the following flag is needed for both the gNB and the UE:
+
+`--do-ra`
+
+### Run OAI in do-ra mode
+
+From the `cmake_targets/ran_build/build` folder:
+
+gNB on machine 1:
+
+`sudo ./nr-softmodem -O ../../../targets/PROJECTS/GENERIC-LTE-EPC/CONF/gnb.band78.tm1.106PRB.usrpn300.conf --do-ra`
+
+UE on machine 2:
+
+`sudo ./nr-uesoftmodem --do-ra`
+
+With the RF simulator (on the same machine):
+
+`sudo RFSIMULATOR=gnb ./nr-softmodem -O ../../../targets/PROJECTS/GENERIC-LTE-EPC/CONF/gnb.band78.tm1.106PRB.usrpn300.conf --do-ra --rfsim --parallel-config PARALLEL_SINGLE_THREAD`
+
+`sudo RFSIMULATOR=127.0.0.1 ./nr-uesoftmodem --do-ra --rfsim --parallel-config PARALLEL_SINGLE_THREAD`
[oai wiki home](https://gitlab.eurecom.fr/oai/openairinterface5g/wikis/home)
diff --git a/executables/nr-gnb.c b/executables/nr-gnb.c
index 2eb0b0692d..a48b237845 100644
--- a/executables/nr-gnb.c
+++ b/executables/nr-gnb.c
@@ -597,6 +597,8 @@ int wakeup_rxtx(PHY_VARS_gNB *gNB,RU_t *ru) {
int i;
struct timespec abstime;
int time_ns = 50000;
+ int wait_timer = 0;
+ bool do_last_check = 1;
AssertFatal((ret=pthread_mutex_lock(&proc->mutex_RU))==0,"mutex_lock returns %d\n",ret);
for (i=0; inum_RU; i++) {
@@ -617,22 +619,36 @@ int wakeup_rxtx(PHY_VARS_gNB *gNB,RU_t *ru) {
AssertFatal((ret=pthread_mutex_unlock(&proc->mutex_RU))==0,"muex_unlock returns %d\n",ret);
}
- clock_gettime(CLOCK_REALTIME, &abstime);
- abstime.tv_nsec = abstime.tv_nsec + time_ns;
-
- if (abstime.tv_nsec >= 1000*1000*1000) {
- abstime.tv_nsec -= 1000*1000*1000;
- abstime.tv_sec += 1;
- }
-
// wake up TX for subframe n+sf_ahead
// lock the TX mutex and make sure the thread is ready
- AssertFatal((ret=pthread_mutex_timedlock(&L1_proc->mutex, &abstime)) == 0,"mutex_lock returns %d\n", ret);
+ while (wait_timer < 200) {
+ clock_gettime(CLOCK_REALTIME, &abstime);
+ abstime.tv_nsec = abstime.tv_nsec + time_ns;
- if (L1_proc->instance_cnt == 0) { // L1_thread is busy so abort the subframe
- AssertFatal((ret=pthread_mutex_unlock( &L1_proc->mutex))==0,"muex_unlock return %d\n",ret);
- LOG_W(PHY,"L1_thread isn't ready in %d.%d, aborting RX processing\n",ru_proc->frame_rx,ru_proc->tti_rx);
- return(-1);
+ if (abstime.tv_nsec >= 1000*1000*1000) {
+ abstime.tv_nsec -= 1000*1000*1000;
+ abstime.tv_sec += 1;
+ }
+
+ AssertFatal((ret=pthread_mutex_timedlock(&L1_proc->mutex, &abstime)) == 0,"mutex_lock returns %d\n", ret);
+
+ if (L1_proc->instance_cnt == 0) { // L1_thread is busy so wait for a bit
+ AssertFatal((ret=pthread_mutex_unlock( &L1_proc->mutex))==0,"muex_unlock return %d\n",ret);
+ wait_timer += 50;
+ usleep(50);
+ }
+ else {
+ do_last_check = 0;
+ break;
+ }
+ }
+ if (do_last_check) {
+ AssertFatal((ret=pthread_mutex_timedlock(&L1_proc->mutex, &abstime)) == 0,"mutex_lock returns %d\n", ret);
+ if (L1_proc->instance_cnt == 0) { // L1_thread is busy so abort the subframe
+ AssertFatal((ret=pthread_mutex_unlock( &L1_proc->mutex))==0,"muex_unlock return %d\n",ret);
+ LOG_W(PHY,"L1_thread isn't ready in %d.%d, aborting RX processing\n",ru_proc->frame_rx,ru_proc->tti_rx);
+ return (-1);
+ }
}
++L1_proc->instance_cnt;
@@ -845,6 +861,12 @@ void init_gNB_proc(int inst) {
pthread_mutex_init(&sync_phy_proc.mutex_phy_proc_tx, NULL);
pthread_cond_init(&sync_phy_proc.cond_phy_proc_tx, NULL);
sync_phy_proc.phy_proc_CC_id = 0;
+
+ gNB->threadPool = (tpool_t*)malloc(sizeof(tpool_t));
+ gNB->respDecode = (notifiedFIFO_t*) malloc(sizeof(notifiedFIFO_t));
+ char ul_pool[] = "-1,-1";
+ initTpool(ul_pool, gNB->threadPool, false);
+ initNotifiedFIFO(gNB->respDecode);
}
diff --git a/executables/nr-softmodem.c b/executables/nr-softmodem.c
index 554bb0440e..30fe023544 100644
--- a/executables/nr-softmodem.c
+++ b/executables/nr-softmodem.c
@@ -401,7 +401,7 @@ int create_gNB_tasks(uint32_t gnb_nb) {
}
}
- if (EPC_MODE_ENABLED && (get_softmodem_params()->phy_test==0 && get_softmodem_params()->do_ra==0)) {
+ if (AMF_MODE_ENABLED && (get_softmodem_params()->phy_test==0 && get_softmodem_params()->do_ra==0)) {
if (gnb_nb > 0) {
/*
if (itti_create_task (TASK_SCTP, sctp_eNB_task, NULL) < 0) {
@@ -824,7 +824,7 @@ int main( int argc, char **argv )
}
openair0_cfg[0].threequarter_fs = threequarter_fs;
- EPC_MODE_ENABLED = !IS_SOFTMODEM_NOS1; //!get_softmodem_params()->phy_test;
+ AMF_MODE_ENABLED = !IS_SOFTMODEM_NOS1; //!get_softmodem_params()->phy_test;
if (get_softmodem_params()->do_ra)
AssertFatal(get_softmodem_params()->phy_test == 0,"RA and phy_test are mutually exclusive\n");
diff --git a/executables/nr-ue.c b/executables/nr-ue.c
index 1600d8add0..ee61df86e7 100644
--- a/executables/nr-ue.c
+++ b/executables/nr-ue.c
@@ -420,7 +420,7 @@ void processSlotRX( PHY_VARS_NR_UE *UE, UE_nr_rxtx_proc_t *proc) {
phy_procedures_slot_parallelization_nrUE_RX( UE, proc, 0, 0, 1, UE->mode, no_relay, NULL );
#else
uint64_t a=rdtsc();
- phy_procedures_nrUE_RX( UE, proc, 0, 1, UE->mode);
+ phy_procedures_nrUE_RX( UE, proc, 0, UE->mode);
LOG_D(PHY,"phy_procedures_nrUE_RX: slot:%d, time %lu\n", proc->nr_tti_rx, (rdtsc()-a)/3500);
//printf(">>> nr_ue_pdcch_procedures ended\n");
#endif
@@ -839,6 +839,23 @@ void init_NR_UE(int nb_inst, char* rrc_config_path) {
AssertFatal((rrc_inst = nr_l3_init_ue(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");
+
+ NR_PUSCH_TimeDomainResourceAllocationList_t *pusch_TimeDomainAllocationList = NULL;
+ if (mac_inst->ULbwp[0]->bwp_Dedicated->pusch_Config->choice.setup->pusch_TimeDomainAllocationList) {
+ pusch_TimeDomainAllocationList = mac_inst->ULbwp[0]->bwp_Dedicated->pusch_Config->choice.setup->pusch_TimeDomainAllocationList->choice.setup;
+ }
+ else if (mac_inst->ULbwp[0]->bwp_Common->pusch_ConfigCommon->choice.setup->pusch_TimeDomainAllocationList) {
+ pusch_TimeDomainAllocationList = mac_inst->ULbwp[0]->bwp_Common->pusch_ConfigCommon->choice.setup->pusch_TimeDomainAllocationList;
+ }
+
+ if (pusch_TimeDomainAllocationList) {
+ for(int i = 0; i < pusch_TimeDomainAllocationList->list.count; i++) {
+ AssertFatal(*pusch_TimeDomainAllocationList->list.array[i]->k2 >= DURATION_RX_TO_TX,
+ "Slot offset K2 (%ld) cannot be less than DURATION_RX_TO_TX (%d)\n",
+ *pusch_TimeDomainAllocationList->list.array[i]->k2,
+ DURATION_RX_TO_TX);
+ }
+ }
}
}
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 246ab13e86..10058c441e 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
@@ -415,8 +415,14 @@ typedef struct {
uint8_t number_of_candidates;
uint16_t CCE[64];
uint8_t L[64];
- uint8_t dci_length;
- uint8_t dci_format;
+ // 3GPP TS 38.212 Sec. 7.3.1.0, 3GPP TS 138.131 sec. 6.3.2 (SearchSpace)
+ // The maximum number of DCI lengths allowed by the spec are 4, with max 3 for C-RNTI.
+ // But a given search space may only support a maximum of 2 DCI formats at a time
+ // depending on its search space type configured by RRC. Hence for blind decoding, UE
+ // needs to monitor only upto 2 DCI lengths for a given search space.
+ uint8_t num_dci_options; // Num DCIs the UE actually needs to decode (1 or 2)
+ uint8_t dci_length_options[2];
+ uint8_t dci_format_options[2];
} fapi_nr_dl_config_dci_dl_pdu_rel15_t;
typedef struct {
diff --git a/openair1/PHY/CODING/coding_defs.h b/openair1/PHY/CODING/coding_defs.h
index 7f466c7097..8fe31f208e 100644
--- a/openair1/PHY/CODING/coding_defs.h
+++ b/openair1/PHY/CODING/coding_defs.h
@@ -469,6 +469,9 @@ int32_t nr_segmentation(unsigned char *input_buffer,
unsigned int *F,
uint8_t BG);
+/*!\fn uint32_t nr_compute_tbs
+\brief This function returns the TBS in bits as per 6.1.4.2 of TS 38.214
+*/
uint32_t nr_compute_tbs(uint16_t Qm,
uint16_t R,
uint16_t nb_rb,
@@ -480,8 +483,7 @@ uint32_t nr_compute_tbs(uint16_t Qm,
uint32_t nr_compute_tbslbrm(uint16_t table,
uint16_t nb_rb,
- uint8_t Nl,
- uint8_t C);
+ uint8_t Nl);
void nr_interleaving_ldpc(uint32_t E, uint8_t Qm, uint8_t *e,uint8_t *f);
diff --git a/openair1/PHY/CODING/nr_rate_matching.c b/openair1/PHY/CODING/nr_rate_matching.c
index a16a8d100f..efa5abdc90 100644
--- a/openair1/PHY/CODING/nr_rate_matching.c
+++ b/openair1/PHY/CODING/nr_rate_matching.c
@@ -425,7 +425,7 @@ int nr_rate_matching_ldpc(uint8_t Ilbrm,
}
}
else {
- if (E + F <= Ncb-ind) { //E+F doesn't contain all coded bits
+ if (E <= Ncb-ind) { //E+F doesn't contain all coded bits
memcpy((void*)(e),(void*)(w+ind),E);
k=E;
}
diff --git a/openair1/PHY/INIT/nr_init.c b/openair1/PHY/INIT/nr_init.c
index 057d259baa..a696059873 100644
--- a/openair1/PHY/INIT/nr_init.c
+++ b/openair1/PHY/INIT/nr_init.c
@@ -264,11 +264,11 @@ int phy_init_nr_gNB(PHY_VARS_gNB *gNB,
for (i=0; irxdataF_ext[i] = (int32_t *)malloc16_clear( sizeof(int32_t)*N_RB_UL*12*fp->symbols_per_slot );
pusch_vars[ULSCH_id]->rxdataF_ext2[i] = (int32_t *)malloc16_clear( sizeof(int32_t)*N_RB_UL*12*fp->symbols_per_slot );
- pusch_vars[ULSCH_id]->ul_ch_estimates[i] = (int32_t *)malloc16_clear( sizeof(int32_t)*N_RB_UL*12*fp->symbols_per_slot );
+ pusch_vars[ULSCH_id]->ul_ch_estimates[i] = (int32_t *)malloc16_clear( sizeof(int32_t)*fp->ofdm_symbol_size*2*fp->symbols_per_slot );
pusch_vars[ULSCH_id]->ul_ch_estimates_ext[i] = (int32_t *)malloc16_clear( sizeof(int32_t)*N_RB_UL*12*fp->symbols_per_slot );
pusch_vars[ULSCH_id]->ul_ch_estimates_time[i] = (int32_t *)malloc16_clear( 2*sizeof(int32_t)*fp->ofdm_symbol_size );
pusch_vars[ULSCH_id]->ul_ch_ptrs_estimates[i] = (int32_t *)malloc16_clear( sizeof(int32_t)*fp->ofdm_symbol_size*2*fp->symbols_per_slot ); // max intensity in freq is 1 sc every 2 RBs
- pusch_vars[ULSCH_id]->ul_ch_ptrs_estimates_ext[i] = (int32_t *)malloc16_clear( sizeof(int32_t)*fp->ofdm_symbol_size*2*fp->symbols_per_slot );
+ pusch_vars[ULSCH_id]->ul_ch_ptrs_estimates_ext[i] = (int32_t *)malloc16_clear( sizeof(int32_t)*N_RB_UL*12*fp->symbols_per_slot );
pusch_vars[ULSCH_id]->ptrs_phase_per_slot[i] = (int32_t *)malloc16_clear( sizeof(int32_t)*fp->symbols_per_slot); // symbols per slot
pusch_vars[ULSCH_id]->rxdataF_comp[i] = (int32_t *)malloc16_clear( sizeof(int32_t)*N_RB_UL*12*fp->symbols_per_slot );
pusch_vars[ULSCH_id]->ul_ch_mag0[i] = (int32_t *)malloc16_clear( fp->symbols_per_slot*sizeof(int32_t)*N_RB_UL*12 );
diff --git a/openair1/PHY/NR_TRANSPORT/nr_dci.c b/openair1/PHY/NR_TRANSPORT/nr_dci.c
index ebcf4116d2..2d79aa8fbd 100644
--- a/openair1/PHY/NR_TRANSPORT/nr_dci.c
+++ b/openair1/PHY/NR_TRANSPORT/nr_dci.c
@@ -39,95 +39,6 @@
//#define DEBUG_DCI
//#define DEBUG_CHANNEL_CODING
-
-uint16_t nr_get_dci_size(nfapi_nr_dci_format_e format,
- nfapi_nr_rnti_type_e rnti_type,
- uint16_t N_RB) {
- uint16_t size = 0;
-
- switch(format) {
- /*Only sizes for 0_0 and 1_0 are correct at the moment*/
- case NFAPI_NR_UL_DCI_FORMAT_0_0:
- /// fixed: Format identifier 1, Hop flag 1, MCS 5, NDI 1, RV 2, HARQ PID 4, PUSCH TPC 2 Time Domain assgnmt 4 --20
- size += 20;
- size += (uint8_t)ceil( log2( (N_RB*(N_RB+1))>>1 ) ); // Freq domain assignment -- hopping scenario to be updated
- size += nr_get_dci_size(NFAPI_NR_DL_DCI_FORMAT_1_0, rnti_type, N_RB) - size; // Padding to match 1_0 size
- // UL/SUL indicator assumed to be 0
- break;
-
- case NFAPI_NR_UL_DCI_FORMAT_0_1:
- /// fixed: Format identifier 1, MCS 5, NDI 1, RV 2, HARQ PID 4, PUSCH TPC 2, SRS request 2 --17
- size += 17;
- // Carrier indicator
- // UL/SUL indicator
- // BWP Indicator
- // Freq domain assignment
- // Time domain assignment
- // VRB to PRB mapping
- // Frequency Hopping flag
- // 1st DAI
- // 2nd DAI
- // SRS resource indicator
- // Precoding info and number of layers
- // Antenna ports
- // CSI request
- // CBGTI
- // PTRS - DMRS association
- // beta offset indicator
- // DMRS sequence init
- break;
-
- case NFAPI_NR_DL_DCI_FORMAT_1_0:
- /// fixed: Format identifier 1, VRB2PRB 1, MCS 5, NDI 1, RV 2, HARQ PID 4, DAI 2, PUCCH TPC 2, PUCCH RInd 3, PDSCH to HARQ TInd 3 Time Domain assgnmt 4 -- 28
- size += 28;
- size += (uint8_t)ceil( log2( (N_RB*(N_RB+1))>>1 ) ); // Freq domain assignment
- break;
-
- case NFAPI_NR_DL_DCI_FORMAT_1_1:
- // Carrier indicator
- size += 1; // Format identifier
- // BWP Indicator
- // Freq domain assignment
- // Time domain assignment
- // VRB to PRB mapping
- // PRB bundling size indicator
- // Rate matching indicator
- // ZP CSI-RS trigger
- /// TB1- MCS 5, NDI 1, RV 2
- size += 8;
- // TB2
- size += 4 ; // HARQ PID
- // DAI
- size += 2; // TPC PUCCH
- size += 3; // PUCCH resource indicator
- size += 3; // PDSCH to HARQ timing indicator
- // Antenna ports
- // Tx Config Indication
- size += 2; // SRS request
- // CBGTI
- // CBGFI
- size += 1; // DMRS sequence init
- break;
-
- case NFAPI_NR_DL_DCI_FORMAT_2_0:
- break;
-
- case NFAPI_NR_DL_DCI_FORMAT_2_1:
- break;
-
- case NFAPI_NR_DL_DCI_FORMAT_2_2:
- break;
-
- case NFAPI_NR_DL_DCI_FORMAT_2_3:
- break;
-
- default:
- AssertFatal(1==0, "Invalid NR DCI format %d\n", format);
- }
-
- return size;
-}
-
void nr_pdcch_scrambling(uint32_t *in,
uint32_t size,
uint32_t Nid,
diff --git a/openair1/PHY/NR_TRANSPORT/nr_dlsch_coding.c b/openair1/PHY/NR_TRANSPORT/nr_dlsch_coding.c
index e5841d3262..a4a684c4e4 100644
--- a/openair1/PHY/NR_TRANSPORT/nr_dlsch_coding.c
+++ b/openair1/PHY/NR_TRANSPORT/nr_dlsch_coding.c
@@ -527,7 +527,7 @@ int nr_dlsch_encoding(PHY_VARS_gNB *gNB,
if (rel15->nrOfLayers < Nl)
Nl = rel15->nrOfLayers;
- Tbslbrm = nr_compute_tbslbrm(rel15->mcsTable[0],nb_rb,Nl,dlsch->harq_processes[harq_pid]->C);
+ Tbslbrm = nr_compute_tbslbrm(rel15->mcsTable[0],nb_rb,Nl);
start_meas(dlsch_rate_matching_stats);
nr_rate_matching_ldpc(Ilbrm,
diff --git a/openair1/PHY/NR_TRANSPORT/nr_ulsch.h b/openair1/PHY/NR_TRANSPORT/nr_ulsch.h
index a9845b6bbb..de9b5f48c3 100644
--- a/openair1/PHY/NR_TRANSPORT/nr_ulsch.h
+++ b/openair1/PHY/NR_TRANSPORT/nr_ulsch.h
@@ -31,6 +31,7 @@
*/
#include "PHY/defs_gNB.h"
+#include "common/utils/threadPool/thread-pool.h"
void free_gNB_ulsch(NR_gNB_ULSCH_t **ulsch,uint8_t N_RB_UL);
diff --git a/openair1/PHY/NR_TRANSPORT/nr_ulsch_decoding.c b/openair1/PHY/NR_TRANSPORT/nr_ulsch_decoding.c
index 7980206eb4..42f88d16f4 100644
--- a/openair1/PHY/NR_TRANSPORT/nr_ulsch_decoding.c
+++ b/openair1/PHY/NR_TRANSPORT/nr_ulsch_decoding.c
@@ -52,9 +52,6 @@
#define OAI_UL_LDPC_MAX_NUM_LLR 27000//26112 // NR_LDPC_NCOL_BG1*NR_LDPC_ZMAX = 68*384
//#define PRINT_CRC_CHECK
-static uint64_t nb_total_decod =0;
-static uint64_t nb_error_decod =0;
-
//extern double cpuf;
void free_gNB_ulsch(NR_gNB_ULSCH_t **ulschptr,uint8_t N_RB_UL)
@@ -286,7 +283,177 @@ void clean_gNB_ulsch(NR_gNB_ULSCH_t *ulsch)
static uint32_t prnt_crc_cnt = 0;
#endif
-uint32_t nr_ulsch_decoding(PHY_VARS_gNB *gNB,
+void nr_processULSegment(void* arg) {
+ ldpcDecode_t *rdata = (ldpcDecode_t*) arg;
+ PHY_VARS_gNB *phy_vars_gNB = rdata->gNB;
+ NR_UL_gNB_HARQ_t *ulsch_harq = rdata->ulsch_harq;
+ t_nrLDPC_dec_params *p_decoderParms = &rdata->decoderParms;
+ int length_dec;
+ int no_iteration_ldpc;
+ int Kr;
+ int Kr_bytes;
+ int K_bytes_F;
+ uint8_t crc_type;
+ int i;
+ int j;
+ int r = rdata->segment_r;
+ int A = rdata->A;
+ int E = rdata->E;
+ int Qm = rdata->Qm;
+ int rv_index = rdata->rv_index;
+ int r_offset = rdata->r_offset;
+ uint8_t kc = rdata->Kc;
+ uint32_t Tbslbrm = rdata->Tbslbrm;
+ short* ulsch_llr = rdata->ulsch_llr;
+ int max_ldpc_iterations = p_decoderParms->numMaxIter;
+ int8_t llrProcBuf[OAI_UL_LDPC_MAX_NUM_LLR] __attribute__ ((aligned(32)));
+
+ int16_t z [68*384];
+ int8_t l [68*384];
+
+ __m128i *pv = (__m128i*)&z;
+ __m128i *pl = (__m128i*)&l;
+
+ uint8_t Ilbrm = 0;
+
+ Kr = ulsch_harq->K;
+ Kr_bytes = Kr>>3;
+
+ K_bytes_F = Kr_bytes-(ulsch_harq->F>>3);
+
+ t_nrLDPC_time_stats procTime;
+ t_nrLDPC_time_stats* p_procTime = &procTime ;
+
+ //start_meas(&phy_vars_gNB->ulsch_deinterleaving_stats);
+
+ ////////////////////////////////////////////////////////////////////////////////////////////
+ ///////////////////////////////// nr_deinterleaving_ldpc ///////////////////////////////////
+ //////////////////////////////////////////////////////////////////////////////////////////
+
+ //////////////////////////// ulsch_llr =====> ulsch_harq->e //////////////////////////////
+
+ nr_deinterleaving_ldpc(E,
+ Qm,
+ ulsch_harq->e[r],
+ ulsch_llr+r_offset);
+
+ //for (int i =0; i<16; i++)
+ // printf("rx output deinterleaving w[%d]= %d r_offset %d\n", i,ulsch_harq->w[r][i], r_offset);
+
+ stop_meas(&phy_vars_gNB->ulsch_deinterleaving_stats);
+
+
+ /*LOG_D(PHY,"HARQ_PID %d Rate Matching Segment %d (coded bits %d,unpunctured/repeated bits %d, TBS %d, mod_order %d, nb_rb %d, Nl %d, rv %d, round %d)...\n",
+ harq_pid,r, G,
+ Kr*3,
+ ulsch_harq->TBS,
+ Qm,
+ nb_rb,
+ n_layers,
+ pusch_pdu->pusch_data.rv_index,
+ ulsch_harq->round);*/
+ //////////////////////////////////////////////////////////////////////////////////////////
+
+
+ //////////////////////////////////////////////////////////////////////////////////////////
+ //////////////////////////////// nr_rate_matching_ldpc_rx ////////////////////////////////
+ //////////////////////////////////////////////////////////////////////////////////////////
+
+ ///////////////////////// ulsch_harq->e =====> ulsch_harq->d /////////////////////////
+
+ //start_meas(&phy_vars_gNB->ulsch_rate_unmatching_stats);
+
+ if (nr_rate_matching_ldpc_rx(Ilbrm,
+ Tbslbrm,
+ p_decoderParms->BG,
+ p_decoderParms->Z,
+ ulsch_harq->d[r],
+ ulsch_harq->e[r],
+ ulsch_harq->C,
+ rv_index,
+ (ulsch_harq->round==0)?1:0,
+ E,
+ ulsch_harq->F,
+ Kr-ulsch_harq->F-2*(p_decoderParms->Z))==-1) {
+
+ stop_meas(&phy_vars_gNB->ulsch_rate_unmatching_stats);
+
+ LOG_E(PHY,"ulsch_decoding.c: Problem in rate_matching\n");
+ rdata->decodeIterations = max_ldpc_iterations + 1;
+ return;
+ } else {
+ stop_meas(&phy_vars_gNB->ulsch_rate_unmatching_stats);
+ }
+
+ memset(ulsch_harq->c[r],0,Kr_bytes);
+
+ if (ulsch_harq->C == 1) {
+ if (A > 3824)
+ crc_type = CRC24_A;
+ else
+ crc_type = CRC16;
+
+ length_dec = ulsch_harq->B;
+ }
+ else {
+ crc_type = CRC24_B;
+ length_dec = (ulsch_harq->B+24*ulsch_harq->C)/ulsch_harq->C;
+ }
+
+ //start_meas(&phy_vars_gNB->ulsch_ldpc_decoding_stats);
+
+ memset(pv,0,2*ulsch_harq->Z*sizeof(int16_t));
+ memset((pv+K_bytes_F),127,ulsch_harq->F*sizeof(int16_t));
+
+ for (i=((2*p_decoderParms->Z)>>3), j = 0; i < K_bytes_F; i++, j++) {
+ pv[i]= _mm_loadu_si128((__m128i*)(&ulsch_harq->d[r][8*j]));
+ }
+
+ AssertFatal(kc!=255,"");
+ j+=(ulsch_harq->F>>3);
+ for (i=Kr_bytes; i < ((kc*p_decoderParms->Z)>>3); i++, j++) {
+ pv[i]= _mm_loadu_si128((__m128i*)(&ulsch_harq->d[r][8*j]));
+ }
+
+ for (i=0, j=0; j < ((kc*p_decoderParms->Z)>>4); i+=2, j++) {
+ pl[j] = _mm_packs_epi16(pv[i],pv[i+1]);
+ }
+
+ //////////////////////////////////////////////////////////////////////////////////////////
+
+
+ //////////////////////////////////////////////////////////////////////////////////////////
+ ///////////////////////////////////// nrLDPC_decoder /////////////////////////////////////
+ //////////////////////////////////////////////////////////////////////////////////////////
+
+ ////////////////////////////////// pl =====> llrProcBuf //////////////////////////////////
+
+ no_iteration_ldpc = nrLDPC_decoder(p_decoderParms,
+ (int8_t*)&pl[0],
+ llrProcBuf,
+ ulsch_harq->p_nrLDPC_procBuf[r],
+ p_procTime);
+
+ if (check_crc((uint8_t*)llrProcBuf,length_dec,ulsch_harq->F,crc_type)) {
+#ifdef PRINT_CRC_CHECK
+ LOG_I(PHY, "Segment %d CRC OK\n",r);
+#endif
+ rdata->decodeIterations = no_iteration_ldpc;
+ } else {
+#ifdef PRINT_CRC_CHECK
+ LOG_I(PHY, "CRC NOK\n");
+#endif
+ rdata->decodeIterations = max_ldpc_iterations + 1;
+ }
+
+ for (int m=0; m < Kr>>3; m ++) {
+ ulsch_harq->c[r][m]= (uint8_t) llrProcBuf[m];
+ }
+
+ //stop_meas(&phy_vars_gNB->ulsch_ldpc_decoding_stats);
+}
+
+uint32_t nr_ulsch_decoding(PHY_VARS_gNB *phy_vars_gNB,
uint8_t UE_id,
short *ulsch_llr,
NR_DL_FRAME_PARMS *frame_parms,
@@ -296,36 +463,36 @@ uint32_t nr_ulsch_decoding(PHY_VARS_gNB *gNB,
uint8_t harq_pid,
uint32_t G) {
- uint32_t A,E;
- uint32_t ret, offset;
- int32_t no_iteration_ldpc, length_dec;
- uint32_t r,r_offset=0,Kr=8424,Kr_bytes,K_bytes_F,err_flag=0;
- uint8_t crc_type;
- int8_t llrProcBuf[OAI_UL_LDPC_MAX_NUM_LLR] __attribute__ ((aligned(32)));
+ uint32_t A;
+ uint32_t r;
+ uint32_t r_offset;
+ uint32_t offset;
+ int kc;
+ int Tbslbrm;
+ int E;
#ifdef PRINT_CRC_CHECK
prnt_crc_cnt++;
#endif
- NR_gNB_ULSCH_t *ulsch = gNB->ulsch[UE_id][0];
+ NR_gNB_ULSCH_t *ulsch = phy_vars_gNB->ulsch[UE_id][0];
NR_UL_gNB_HARQ_t *harq_process = ulsch->harq_processes[harq_pid];
t_nrLDPC_dec_params decParams;
t_nrLDPC_dec_params* p_decParams = &decParams;
- t_nrLDPC_time_stats procTime;
- t_nrLDPC_time_stats* p_procTime = &procTime ;
- if (!harq_process) {
- printf("ulsch_decoding.c: NULL harq_process pointer\n");
- return (ulsch->max_ldpc_iterations + 1);
- }
- t_nrLDPC_procBuf** p_nrLDPC_procBuf = harq_process->p_nrLDPC_procBuf;
- int16_t z [68*384];
- int8_t l [68*384];
- uint8_t kc = 255;
- uint8_t Ilbrm = 0;
- uint32_t Tbslbrm = 950984;
+ int Kr;
+ int Kr_bytes;
+
+ phy_vars_gNB->nbDecode = 0;
+ harq_process->processedSegments = 0;
+
+ if (!harq_process) {
+ LOG_E(PHY,"ulsch_decoding.c: NULL harq_process pointer\n");
+ return 1;
+ }
+
double Coderate = 0.0;
// ------------------------------------------------------------------
@@ -336,30 +503,16 @@ uint32_t nr_ulsch_decoding(PHY_VARS_gNB *gNB,
uint8_t n_layers = pusch_pdu->nrOfLayers;
// ------------------------------------------------------------------
- uint32_t i,j;
-
- __m128i *pv = (__m128i*)&z;
- __m128i *pl = (__m128i*)&l;
-
-
if (!ulsch_llr) {
- printf("ulsch_decoding.c: NULL ulsch_llr pointer\n");
- return (ulsch->max_ldpc_iterations + 1);
+ LOG_E(PHY,"ulsch_decoding.c: NULL ulsch_llr pointer\n");
+ return 1;
}
- if (!frame_parms) {
- printf("ulsch_decoding.c: NULL frame_parms pointer\n");
- return (ulsch->max_ldpc_iterations + 1);
- }
-
- // harq_process->trials[nfapi_ulsch_pdu_rel15->round]++;
-
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];
A = (harq_process->TBS)<<3;
- ret = ulsch->max_ldpc_iterations + 1;
LOG_D(PHY,"ULSCH Decoding, harq_pid %d TBS %d G %d mcs %d Nl %d nb_rb %d, Qm %d, n_layers %d\n",harq_pid,A,G, mcs, n_layers, nb_rb, Qm, n_layers);
@@ -401,12 +554,12 @@ uint32_t nr_ulsch_decoding(PHY_VARS_gNB *gNB,
NR_gNB_SCH_STATS_t *stats=NULL;
int first_free=-1;
for (int i=0;iulsch_stats[i].rnti == 0 && first_free == -1) {
+ if (phy_vars_gNB->ulsch_stats[i].rnti == 0 && first_free == -1) {
first_free = i;
- stats=&gNB->ulsch_stats[i];
+ stats=&phy_vars_gNB->ulsch_stats[i];
}
- if (gNB->ulsch_stats[i].rnti == ulsch->rnti) {
- stats=&gNB->ulsch_stats[i];
+ if (phy_vars_gNB->ulsch_stats[i].rnti == ulsch->rnti) {
+ stats=&phy_vars_gNB->ulsch_stats[i];
break;
}
}
@@ -420,13 +573,13 @@ uint32_t nr_ulsch_decoding(PHY_VARS_gNB *gNB,
stats->current_RI = n_layers;
stats->total_bytes_tx += harq_process->TBS;
}
- // This is a new packet, so compute quantities regarding segmentation
- if (A > 3824)
- harq_process->B = A+24;
- else
- harq_process->B = A+16;
+ }
+ if (A > 3824)
+ harq_process->B = A+24;
+ else
+ harq_process->B = A+16;
- // [hna] Perform nr_segmenation with input and output set to NULL to calculate only (B, C, K, Z, F)
+// [hna] Perform nr_segmenation with input and output set to NULL to calculate only (B, C, K, Z, F)
nr_segmentation(NULL,
NULL,
harq_process->B,
@@ -437,18 +590,18 @@ uint32_t nr_ulsch_decoding(PHY_VARS_gNB *gNB,
p_decParams->BG);
#ifdef DEBUG_ULSCH_DECODING
- printf("ulsch decoding nr segmentation Z %d\n", harq_process->Z);
- if (!frame%100)
- printf("K %d C %d Z %d \n", harq_process->K, harq_process->C, harq_process->Z);
+ printf("ulsch decoding nr segmentation Z %d\n", harq_process->Z);
+ if (!frame%100)
+ printf("K %d C %d Z %d \n", harq_process->K, harq_process->C, harq_process->Z);
#endif
- }
+ Tbslbrm = nr_compute_tbslbrm(0,nb_rb,n_layers);
+
p_decParams->Z = harq_process->Z;
p_decParams->numMaxIter = ulsch->max_ldpc_iterations;
p_decParams->outMode= 0;
- err_flag = 0;
r_offset = 0;
uint16_t a_segments = MAX_NUM_NR_ULSCH_SEGMENTS; //number of segments to be allocated
@@ -460,284 +613,48 @@ uint32_t nr_ulsch_decoding(PHY_VARS_gNB *gNB,
if (harq_process->C > a_segments) {
LOG_E(PHY,"Illegal harq_process->C %d > %d\n",harq_process->C,a_segments);
- return (ulsch->max_ldpc_iterations + 1);
+ return 1;
}
#ifdef DEBUG_ULSCH_DECODING
printf("Segmentation: C %d, K %d\n",harq_process->C,harq_process->K);
#endif
-
- //opp_enabled=1;
-
Kr = harq_process->K;
Kr_bytes = Kr>>3;
-
- K_bytes_F = Kr_bytes-(harq_process->F>>3);
+ offset = 0;
+ void (*nr_processULSegment_ptr)(void*) = &nr_processULSegment;
for (r=0; rC; r++) {
+
E = nr_get_E(G, harq_process->C, Qm, n_layers, r);
+ union ldpcReqUnion id = {.s={ulsch->rnti,frame,nr_tti_rx,0,0}};
+ notifiedFIFO_elt_t *req=newNotifiedFIFO_elt(sizeof(ldpcDecode_t), id.p, phy_vars_gNB->respDecode, nr_processULSegment_ptr);
+ ldpcDecode_t * rdata=(ldpcDecode_t *) NotifiedFifoData(req);
- start_meas(&gNB->ulsch_deinterleaving_stats);
-
- ////////////////////////////////////////////////////////////////////////////////////////////
- ///////////////////////////////// nr_deinterleaving_ldpc ///////////////////////////////////
- //////////////////////////////////////////////////////////////////////////////////////////
-
- //////////////////////////// ulsch_llr =====> harq_process->e //////////////////////////////
-
- nr_deinterleaving_ldpc(E,
- Qm,
- harq_process->e[r],
- ulsch_llr+r_offset);
-
- //for (int i =0; i<16; i++)
- // printf("rx output deinterleaving w[%d]= %d r_offset %d\n", i,harq_process->w[r][i], r_offset);
-
- stop_meas(&gNB->ulsch_deinterleaving_stats);
-
-
- LOG_D(PHY,"HARQ_PID %d Rate Matching Segment %d (coded bits %d,unpunctured/repeated bits %d, TBS %d, mod_order %d, nb_rb %d, Nl %d, rvidx %d, round %d)...\n",
- harq_pid,r, G,
- Kr*3,
- harq_process->TBS,
- Qm,
- nb_rb,
- n_layers,
- pusch_pdu->pusch_data.rv_index,
- harq_process->round);
- //////////////////////////////////////////////////////////////////////////////////////////
-
-
- //////////////////////////////////////////////////////////////////////////////////////////
- //////////////////////////////// nr_rate_matching_ldpc_rx ////////////////////////////////
- //////////////////////////////////////////////////////////////////////////////////////////
-
- ///////////////////////// harq_process->e =====> harq_process->d /////////////////////////
-
- start_meas(&gNB->ulsch_rate_unmatching_stats);
-
- Tbslbrm = nr_compute_tbslbrm(0,nb_rb,n_layers,harq_process->C);
-
- if (nr_rate_matching_ldpc_rx(Ilbrm,
- Tbslbrm,
- p_decParams->BG,
- p_decParams->Z,
- harq_process->d[r],
- harq_process->e[r],
- harq_process->C,
- pusch_pdu->pusch_data.rv_index,
- (harq_process->round==0)?1:0,
- E,
- harq_process->F,
- Kr-harq_process->F-2*(p_decParams->Z))==-1) {
-
- stop_meas(&gNB->ulsch_rate_unmatching_stats);
-
- LOG_E(PHY,"ulsch_decoding.c: Problem in rate_matching\n");
- return (ulsch->max_ldpc_iterations + 1);
- } else {
- stop_meas(&gNB->ulsch_rate_unmatching_stats);
- }
-
+ rdata->gNB = phy_vars_gNB;
+ rdata->ulsch_harq = harq_process;
+ rdata->decoderParms = decParams;
+ rdata->ulsch_llr = ulsch_llr;
+ rdata->Kc = kc;
+ rdata->harq_pid = harq_pid;
+ rdata->segment_r = r;
+ rdata->nbSegments = harq_process->C;
+ rdata->E = E;
+ rdata->A = A;
+ rdata->Qm = Qm;
+ rdata->r_offset = r_offset;
+ rdata->Kr_bytes = Kr_bytes;
+ rdata->rv_index = pusch_pdu->pusch_data.rv_index;
+ rdata->Tbslbrm = Tbslbrm;
+ rdata->offset = offset;
+ rdata->ulsch = ulsch;
+ rdata->ulsch_id = UE_id;
+ pushTpool(phy_vars_gNB->threadPool,req);
+ phy_vars_gNB->nbDecode++;
+ LOG_D(PHY,"Added a block to decode, in pipe: %d\n",phy_vars_gNB->nbDecode);
r_offset += E;
-
-#ifdef DEBUG_ULSCH_DECODING
- if (r==0) {
- write_output("decoder_llr.m","decllr",ulsch_llr,G,1,0);
- write_output("decoder_in.m","dec",&harq_process->d[0][0],E,1,0);
- }
-
- printf("decoder input(segment %u) :", r);
- int i;
- for (i=0;i<(3*8*Kr_bytes)+12;i++)
- printf("%d : %d\n",i,harq_process->d[r][i]);
- printf("\n");
-#endif
-
-
- // printf("Clearing c, %p\n",harq_process->c[r]);
- memset(harq_process->c[r],0,Kr_bytes);
-
- // printf("done\n");
- if (harq_process->C == 1) {
- if (A > 3824)
- crc_type = CRC24_A;
- else
- crc_type = CRC16;
-
- length_dec = harq_process->B;
- }
- else {
- crc_type = CRC24_B;
- length_dec = (harq_process->B+24*harq_process->C)/harq_process->C;
- }
-
- if (err_flag == 0) {
-
- start_meas(&gNB->ulsch_ldpc_decoding_stats);
-
- //LOG_E(PHY,"AbsSubframe %d.%d Start LDPC segment %d/%d A %d ",frame%1024,nr_tti_rx,r,harq_process->C-1, A);
-
-
- memset(pv,0,2*harq_process->Z*sizeof(int16_t));
- memset((pv+K_bytes_F),127,harq_process->F*sizeof(int16_t));
-
- for (i=((2*p_decParams->Z)>>3), j = 0; i < K_bytes_F; i++, j++) {
- pv[i]= _mm_loadu_si128((__m128i*)(&harq_process->d[r][8*j]));
- }
-
- AssertFatal(kc!=255,"");
- j+=(harq_process->F>>3);
- for (i=Kr_bytes; i < ((kc*p_decParams->Z)>>3); i++, j++) {
- pv[i]= _mm_loadu_si128((__m128i*)(&harq_process->d[r][8*j]));
- }
-
- for (i=0, j=0; j < ((kc*p_decParams->Z)>>4); i+=2, j++) {
- pl[j] = _mm_packs_epi16(pv[i],pv[i+1]);
- }
-
- //////////////////////////////////////////////////////////////////////////////////////////
-
-
- //////////////////////////////////////////////////////////////////////////////////////////
- ///////////////////////////////////// nrLDPC_decoder /////////////////////////////////////
- //////////////////////////////////////////////////////////////////////////////////////////
-
- ////////////////////////////////// pl =====> llrProcBuf //////////////////////////////////
-
- no_iteration_ldpc = nrLDPC_decoder(p_decParams,
- (int8_t*)&pl[0],
- llrProcBuf,
- p_nrLDPC_procBuf[r],
- p_procTime);
-
- if (check_crc((uint8_t*)llrProcBuf,length_dec,harq_process->F,crc_type)) {
- #ifdef PRINT_CRC_CHECK
- //if (prnt_crc_cnt % 10 == 0)
- LOG_I(PHY, "Segment %d CRC OK\n",r);
- #endif
- ret = no_iteration_ldpc;
- } else {
- #ifdef PRINT_CRC_CHECK
- //if (prnt_crc_cnt%10 == 0)
- LOG_I(PHY, "CRC NOK\n");
- #endif
- ret = ulsch->max_ldpc_iterations + 1;
- }
- nb_total_decod++;
-
- if (no_iteration_ldpc > ulsch->max_ldpc_iterations){
- nb_error_decod++;
- }
-
- for (int m=0; m < Kr>>3; m ++) {
- harq_process->c[r][m]= (uint8_t) llrProcBuf[m];
- }
-
-#ifdef DEBUG_ULSCH_DECODING
- //printf("output decoder %d %d %d %d %d \n", harq_process->c[r][0], harq_process->c[r][1], harq_process->c[r][2],harq_process->c[r][3], harq_process->c[r][4]);
- for (int k=0;k>3;k++)
- printf("output decoder [%d] = 0x%02x \n", k, harq_process->c[r][k]);
- printf("no_iterations_ldpc %d (ret %u)\n",no_iteration_ldpc,ret);
- //write_output("dec_output.m","dec0",harq_process->c[0],Kr_bytes,1,4);
-#endif
-
- stop_meas(&gNB->ulsch_ldpc_decoding_stats);
- }
-
- if ((err_flag == 0) && (ret >= (ulsch->max_ldpc_iterations + 1))) {
- // a Code segment is in error so break;
- LOG_D(PHY,"AbsSubframe %d.%d CRC failed, segment %d/%d \n",frame%1024,nr_tti_rx,r,harq_process->C-1);
- err_flag = 1;
- }
+ offset += (Kr_bytes - (harq_process->F>>3) - ((harq_process->C>1)?3:0));
//////////////////////////////////////////////////////////////////////////////////////////
}
-
- int32_t frame_rx_prev = frame;
- int32_t tti_rx_prev = nr_tti_rx - 1;
- if (tti_rx_prev < 0) {
- frame_rx_prev--;
- tti_rx_prev += frame_parms->slots_per_frame;
- }
- frame_rx_prev = frame_rx_prev%1024;
-
- if (err_flag == 1) {
-
-#ifdef gNB_DEBUG_TRACE
- LOG_I(PHY,"[gNB %d] ULSCH: Setting NAK for SFN/SF %d/%d (pid %d, status %d, round %d, TBS %d) Kr %d r %d\n",
- gNB->Mod_id, frame, nr_tti_rx, harq_pid,harq_process->status, harq_process->round,harq_process->TBS,Kr,r);
-#endif
-
- // harq_process->harq_ack.ack = 0;
- // harq_process->harq_ack.harq_id = harq_pid;
- // harq_process->harq_ack.send_harq_status = 1;
- // harq_process->errors[harq_process->round]++;
- //harq_process->round++;
-
- if (harq_process->round >= ulsch->Mlimit) {
- harq_process->status = SCH_IDLE;
- harq_process->round = 0;
- harq_process->handled = 0;
- ulsch->harq_mask &= ~(1 << harq_pid);
- }
-
- // LOG_D(PHY,"[gNB %d] ULSCH: Setting NACK for nr_tti_rx %d (pid %d, pid status %d, round %d/Max %d, TBS %d)\n",
- // gNB->Mod_id,nr_tti_rx,harq_pid,harq_process->status,harq_process->round,ulsch->Mlimit,harq_process->TBS);
-
- harq_process->handled = 1;
- ret = ulsch->max_ldpc_iterations + 1;
-
- } else {
-
-#ifdef gNB_DEBUG_TRACE
- LOG_I(PHY,"[gNB %d] ULSCH: Setting ACK for nr_tti_rx %d TBS %d\n",
- gNB->Mod_id,nr_tti_rx,harq_process->TBS);
-#endif
-
- harq_process->status = SCH_IDLE;
- harq_process->round = 0;
- // harq_process->handled = 0;
- ulsch->harq_mask &= ~(1 << harq_pid);
- // harq_process->harq_ack.ack = 1;
- // harq_process->harq_ack.harq_id = harq_pid;
- // harq_process->harq_ack.send_harq_status = 1;
-
- // LOG_D(PHY,"[gNB %d] ULSCH: Setting ACK for nr_tti_rx %d (pid %d, round %d, TBS %d)\n",gNB->Mod_id,nr_tti_rx,harq_pid,harq_process->round,harq_process->TBS);
-
-
- // Reassembly of Transport block here
- offset = 0;
- Kr = harq_process->K;
- Kr_bytes = Kr>>3;
-
- for (r=0; rC; r++) {
-
- memcpy(harq_process->b+offset,
- harq_process->c[r],
- Kr_bytes- - (harq_process->F>>3) -((harq_process->C>1)?3:0));
-
- offset += (Kr_bytes - (harq_process->F>>3) - ((harq_process->C>1)?3:0));
-
-#ifdef DEBUG_ULSCH_DECODING
- printf("Segment %u : Kr = %u bytes\n", r, Kr_bytes);
- printf("copied %d bytes to b sequence (harq_pid %d)\n", (Kr_bytes - (harq_process->F>>3)-((harq_process->C>1)?3:0)), harq_pid);
- printf("b[0] = %x, c[%d] = %x\n", harq_process->b[offset], harq_process->F>>3, harq_process->c[r]);
-#endif
-
- }
- if (stats) stats->total_bytes_rx += harq_process->TBS;
- }
-
-#ifdef DEBUG_ULSCH_DECODING
- LOG_I(PHY, "Decoder output (payload) at SFN/SF: %d/%d TBS: %d\n", frame, nr_tti_rx,harq_process->TBS);
- for (i = 0; i < harq_process->TBS; i++) {
- //harq_process_ul_ue->a[i] = (unsigned char) rand();
- //printf("a[%d]=0x%02x\n",i,harq_process_ul_ue->a[i]);
- printf("%02x ",harq_process->b[i]);
- }
-#endif
-
- ulsch->last_iteration_cnt = ret;
- VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_PHY_gNB_ULSCH_DECODING,0);
- return(ret);
+ return 1;
}
diff --git a/openair1/PHY/NR_TRANSPORT/pucch_rx.c b/openair1/PHY/NR_TRANSPORT/pucch_rx.c
index e99219d35c..bee868b5a5 100644
--- a/openair1/PHY/NR_TRANSPORT/pucch_rx.c
+++ b/openair1/PHY/NR_TRANSPORT/pucch_rx.c
@@ -414,7 +414,7 @@ void nr_decode_pucch0(PHY_VARS_gNB *gNB,
uci_pdu->harq->harq_confidence_level = (no_conf) ? 1 : 0;
uci_pdu->harq->harq_list = (nfapi_nr_harq_t*)malloc(1);
uci_pdu->harq->harq_list[0].harq_value = index&0x01;
- LOG_I(PHY, "HARQ value %d with confidence level (0 is good, 1 is bad) %d\n",
+ LOG_D(PHY, "HARQ value %d with confidence level (0 is good, 1 is bad) %d\n",
uci_pdu->harq->harq_list[0].harq_value,uci_pdu->harq->harq_confidence_level);
if (pucch_pdu->sr_flag == 1) {
uci_pdu->sr = calloc(1,sizeof(*uci_pdu->sr));
@@ -429,7 +429,7 @@ void nr_decode_pucch0(PHY_VARS_gNB *gNB,
uci_pdu->harq->harq_list = (nfapi_nr_harq_t*)malloc(2);
uci_pdu->harq->harq_list[1].harq_value = index&0x01;
uci_pdu->harq->harq_list[0].harq_value = (index>>1)&0x01;
- LOG_I(PHY, "HARQ values %d and %d with confidence level (0 is good, 1 is bad) %d\n",
+ LOG_D(PHY, "HARQ values %d and %d with confidence level (0 is good, 1 is bad) %d\n",
uci_pdu->harq->harq_list[1].harq_value,uci_pdu->harq->harq_list[0].harq_value,uci_pdu->harq->harq_confidence_level);
if (pucch_pdu->sr_flag == 1) {
uci_pdu->sr = calloc(1,sizeof(*uci_pdu->sr));
diff --git a/openair1/PHY/NR_UE_TRANSPORT/dci_nr.c b/openair1/PHY/NR_UE_TRANSPORT/dci_nr.c
index 7cde6e31c1..53456bb691 100644
--- a/openair1/PHY/NR_UE_TRANSPORT/dci_nr.c
+++ b/openair1/PHY/NR_UE_TRANSPORT/dci_nr.c
@@ -845,7 +845,6 @@ uint8_t nr_dci_decoding_procedure(PHY_VARS_NR_UE *ue,
for (int i=0;inb_search_space;i++) {
rel15 = &pdcch_vars->pdcch_config[i];
- int dci_length = rel15->dci_length;
//int gNB_id = 0;
int16_t tmp_e[16*108];
rnti_t n_rnti;
@@ -853,41 +852,47 @@ uint8_t nr_dci_decoding_procedure(PHY_VARS_NR_UE *ue,
for (int j=0;jnumber_of_candidates;j++) {
int CCEind = rel15->CCE[j];
int L = rel15->L[j];
- uint64_t dci_estimation[2]= {0};
- const t_nrPolar_params *currentPtrDCI = nr_polar_params(NR_POLAR_DCI_MESSAGE_TYPE, dci_length, L, 1, &ue->polarList);
- LOG_D(PHY, "Trying DCI candidate %d of %d number of candidates, CCE %d (%d), L %d\n", j, rel15->number_of_candidates, CCEind, CCEind*9*6*2, L);
+ // Loop over possible DCI lengths
+ for (int k = 0; k < rel15->num_dci_options; k++) {
+ int dci_length = rel15->dci_length_options[k];
+ uint64_t dci_estimation[2]= {0};
+ const t_nrPolar_params *currentPtrDCI = nr_polar_params(NR_POLAR_DCI_MESSAGE_TYPE, dci_length, L, 1, &ue->polarList);
- nr_pdcch_unscrambling(&pdcch_vars->e_rx[CCEind*108], rel15->coreset.scrambling_rnti, L*108, rel15->coreset.pdcch_dmrs_scrambling_id, tmp_e);
+ LOG_D(PHY, "Trying DCI candidate %d of %d number of candidates, CCE %d (%d), L %d\n", j, rel15->number_of_candidates, CCEind, CCEind*9*6*2, L);
- #ifdef DEBUG_DCI_DECODING
- uint32_t * z = (uint32_t *) &pdcch_vars->e_rx[CCEind*108];
- for (int index_z = 0; index_z < 96; index_z++){
- for (int i=0; i<9; i++) {
- LOG_D(PHY,"z[%d]=(%d,%d) \n", (9*index_z + i), *(int16_t *) &z[index_z + i],*(1 + (int16_t *) &z[index_z + i]));
+ nr_pdcch_unscrambling(&pdcch_vars->e_rx[CCEind*108], rel15->coreset.scrambling_rnti, L*108, rel15->coreset.pdcch_dmrs_scrambling_id, tmp_e);
+
+ #ifdef DEBUG_DCI_DECODING
+ uint32_t * z = (uint32_t *) &pdcch_vars->e_rx[CCEind*108];
+ for (int index_z = 0; index_z < 96; index_z++){
+ for (int i=0; i<9; i++) {
+ LOG_D(PHY,"z[%d]=(%d,%d) \n", (9*index_z + i), *(int16_t *) &z[index_z + i],*(1 + (int16_t *) &z[index_z + i]));
+ }
}
+ #endif
+
+ uint16_t crc = polar_decoder_int16(tmp_e,
+ dci_estimation,
+ 1,
+ currentPtrDCI);
+
+ n_rnti = rel15->rnti;
+
+ if (crc == n_rnti) {
+ LOG_D(PHY,"Decoded crc %x matches rnti %x for DCI format %d\n", crc, n_rnti, rel15->dci_format_options[k]);
+ dci_ind->SFN = frame;
+ dci_ind->slot = slot;
+ dci_ind->dci_list[dci_ind->number_of_dcis].rnti = n_rnti;
+ dci_ind->dci_list[dci_ind->number_of_dcis].n_CCE = CCEind;
+ dci_ind->dci_list[dci_ind->number_of_dcis].dci_format = rel15->dci_format_options[k];
+ dci_ind->dci_list[dci_ind->number_of_dcis].payloadSize = dci_length;
+ memcpy((void*)dci_ind->dci_list[dci_ind->number_of_dcis].payloadBits,(void*)dci_estimation,8);
+ dci_ind->number_of_dcis++;
+ break; // If DCI is found, no need to check for remaining DCI lengths
+ } else {
+ LOG_D(PHY,"Decoded crc %x does not match rnti %x for DCI format %d\n", crc, n_rnti, rel15->dci_format_options[k]);
}
- #endif
-
- uint16_t crc = polar_decoder_int16(tmp_e,
- dci_estimation,
- 1,
- currentPtrDCI);
-
- n_rnti = rel15->rnti;
-
- if (crc == n_rnti) {
- LOG_D(PHY,"Decoded crc %x matches rnti %x for DCI format %d\n", crc, n_rnti, rel15->dci_format);
- dci_ind->SFN = frame;
- dci_ind->slot = slot;
- dci_ind->dci_list[dci_ind->number_of_dcis].rnti = n_rnti;
- dci_ind->dci_list[dci_ind->number_of_dcis].n_CCE = CCEind;
- dci_ind->dci_list[dci_ind->number_of_dcis].dci_format = rel15->dci_format;
- dci_ind->dci_list[dci_ind->number_of_dcis].payloadSize = dci_length;
- memcpy((void*)dci_ind->dci_list[dci_ind->number_of_dcis].payloadBits,(void*)dci_estimation,8);
- dci_ind->number_of_dcis++;
- } else {
- LOG_D(PHY,"Decoded crc %x does not match rnti %x for DCI format %d\n", crc, n_rnti, rel15->dci_format);
}
}
}
diff --git a/openair1/PHY/NR_UE_TRANSPORT/nr_dlsch_decoding.c b/openair1/PHY/NR_UE_TRANSPORT/nr_dlsch_decoding.c
index 36bcb2f379..7378f69c27 100644
--- a/openair1/PHY/NR_UE_TRANSPORT/nr_dlsch_decoding.c
+++ b/openair1/PHY/NR_UE_TRANSPORT/nr_dlsch_decoding.c
@@ -478,9 +478,9 @@ uint32_t nr_dlsch_decoding(PHY_VARS_NR_UE *phy_vars_ue,
VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_DLSCH_RATE_MATCHING, VCD_FUNCTION_IN);
if ((harq_process->Nl)<4)
- Tbslbrm = nr_compute_tbslbrm(harq_process->mcs_table,nb_rb,harq_process->Nl,harq_process->C);
+ Tbslbrm = nr_compute_tbslbrm(harq_process->mcs_table,nb_rb,harq_process->Nl);
else
- Tbslbrm = nr_compute_tbslbrm(harq_process->mcs_table,nb_rb,4,harq_process->C);
+ Tbslbrm = nr_compute_tbslbrm(harq_process->mcs_table,nb_rb,4);
if (nr_rate_matching_ldpc_rx(Ilbrm,
@@ -1069,7 +1069,7 @@ uint32_t nr_dlsch_decoding_mthread(PHY_VARS_NR_UE *phy_vars_ue,
if (harq_process->Nl < Nl)
Nl = harq_process->Nl;
- Tbslbrm = nr_compute_tbslbrm(harq_process->mcs_table,nb_rb,harq_process->Nl,harq_process->C);
+ Tbslbrm = nr_compute_tbslbrm(harq_process->mcs_table,nb_rb,harq_process->Nl);
if (nr_rate_matching_ldpc_rx(Ilbrm,
Tbslbrm,
@@ -1610,9 +1610,9 @@ void nr_dlsch_decoding_process(void *arg)
#endif
if (Nl<4)
- Tbslbrm = nr_compute_tbslbrm(harq_process->mcs_table,nb_rb,Nl,harq_process->C);
+ Tbslbrm = nr_compute_tbslbrm(harq_process->mcs_table,nb_rb,Nl);
else
- Tbslbrm = nr_compute_tbslbrm(harq_process->mcs_table,nb_rb,4,harq_process->C);
+ Tbslbrm = nr_compute_tbslbrm(harq_process->mcs_table,nb_rb,4);
if (nr_rate_matching_ldpc_rx(Ilbrm,
Tbslbrm,
diff --git a/openair1/PHY/NR_UE_TRANSPORT/nr_dlsch_demodulation.c b/openair1/PHY/NR_UE_TRANSPORT/nr_dlsch_demodulation.c
index 7aa0e357aa..e8204ad0b5 100644
--- a/openair1/PHY/NR_UE_TRANSPORT/nr_dlsch_demodulation.c
+++ b/openair1/PHY/NR_UE_TRANSPORT/nr_dlsch_demodulation.c
@@ -53,11 +53,9 @@ int16_t nr_dlsch_demod_shift = 0;
//int16_t interf_unaw_shift = 13;
//#define DEBUG_HARQ
-
-//#define DEBUG_PHY 1
-//#define DEBUG_DLSCH_DEMOD 1
-
-
+//#define DEBUG_PHY
+//#define DEBUG_DLSCH_DEMOD
+//#define DEBUG_PDSCH_RX
// [MCS][i_mod (0,1,2) = (2,4,6)]
//unsigned char offset_mumimo_llr_drange_fix=0;
@@ -188,7 +186,6 @@ int nr_rx_pdsch(PHY_VARS_NR_UE *ue,
if (dlsch0_harq && dlsch1_harq){
- //printf("status TB0 = %d, status TB1 = %d \n", dlsch[0]->harq_processes[harq_pid]->status, dlsch[1]->harq_processes[harq_pid]->status);
LOG_D(PHY,"AbsSubframe %d.%d / Sym %d harq_pid %d, harq status %d.%d \n", frame, nr_tti_rx, symbol, harq_pid, dlsch0_harq->status, dlsch1_harq->status);
if ((dlsch0_harq->status == ACTIVE) && (dlsch1_harq->status == ACTIVE)){
@@ -1042,42 +1039,30 @@ int nr_rx_pdsch(PHY_VARS_NR_UE *ue,
LOG_I(PHY, "[AbsSFN %u.%d] Slot%d Symbol %d: LLR Computation %5.2f \n",frame,nr_tti_rx,slot,symbol,ue->generic_stat_bis[ue->current_thread_id[nr_tti_rx]][slot].p_time/(cpuf*1000.0));
#endif
#endif
+
// Please keep it: useful for debugging
-#if 0
- if( (symbol == 13) && (nr_tti_rx==0) && (dlsch0_harq->Qm == 6) /*&& (nb_rb==25)*/)
- {
- LOG_E(PHY,"Dump Phy Chan Est \n");
- if(1)
- {
-#if 1
- write_output("rxdataF0.m" , "rxdataF0", &common_vars->common_vars_rx_data_per_thread[ue->current_thread_id[nr_tti_rx]].rxdataF[0][0],14*frame_parms->ofdm_symbol_size,1,1);
- //write_output("rxdataF1.m" , "rxdataF1", &common_vars->common_vars_rx_data_per_thread[ue->current_thread_id[nr_tti_rx]].rxdataF[0][0],14*frame_parms->ofdm_symbol_size,1,1);
- write_output("dl_ch_estimates00.m", "dl_ch_estimates00", &common_vars->common_vars_rx_data_per_thread[ue->current_thread_id[nr_tti_rx]].dl_ch_estimates[eNB_id][0][0],14*frame_parms->ofdm_symbol_size,1,1);
- //write_output("dl_ch_estimates01.m", "dl_ch_estimates01", &common_vars->common_vars_rx_data_per_thread[ue->current_thread_id[nr_tti_rx]].dl_ch_estimates[eNB_id][1][0],14*frame_parms->ofdm_symbol_size,1,1);
- //write_output("dl_ch_estimates10.m", "dl_ch_estimates10", &common_vars->common_vars_rx_data_per_thread[ue->current_thread_id[nr_tti_rx]].dl_ch_estimates[eNB_id][2][0],14*frame_parms->ofdm_symbol_size,1,1);
- //write_output("dl_ch_estimates11.m", "dl_ch_estimates11", &common_vars->common_vars_rx_data_per_thread[ue->current_thread_id[nr_tti_rx]].dl_ch_estimates[eNB_id][3][0],14*frame_parms->ofdm_symbol_size,1,1);
+#ifdef DEBUG_PDSCH_RX
+ char filename[40];
+ uint8_t aa = 0;
+ snprintf(filename, 40, "rxdataF0_symb_%d_nr_tti_rx_%d.m", symbol, nr_tti_rx);
+ write_output(filename, "rxdataF0", &common_vars->common_vars_rx_data_per_thread[ue->current_thread_id[nr_tti_rx]].rxdataF[0][0], NR_SYMBOLS_PER_SLOT*frame_parms->ofdm_symbol_size, 1, 1);
- //write_output("rxdataF_ext00.m" , "rxdataF_ext00", &pdsch_vars[eNB_id]->rxdataF_ext[0][0],14*frame_parms->N_RB_DL*12,1,1);
- //write_output("rxdataF_ext01.m" , "rxdataF_ext01", &pdsch_vars[eNB_id]->rxdataF_ext[1][0],14*frame_parms->N_RB_DL*12,1,1);
- //write_output("rxdataF_ext10.m" , "rxdataF_ext10", &pdsch_vars[eNB_id]->rxdataF_ext[2][0],14*frame_parms->N_RB_DL*12,1,1);
- //write_output("rxdataF_ext11.m" , "rxdataF_ext11", &pdsch_vars[eNB_id]->rxdataF_ext[3][0],14*frame_parms->N_RB_DL*12,1,1);
- write_output("dl_ch_estimates_ext00.m", "dl_ch_estimates_ext00", &pdsch_vars[eNB_id]->dl_ch_estimates_ext[0][0],14*frame_parms->N_RB_DL*12,1,1);
- //write_output("dl_ch_estimates_ext01.m", "dl_ch_estimates_ext01", &pdsch_vars[eNB_id]->dl_ch_estimates_ext[1][0],14*frame_parms->N_RB_DL*12,1,1);
- //write_output("dl_ch_estimates_ext10.m", "dl_ch_estimates_ext10", &pdsch_vars[eNB_id]->dl_ch_estimates_ext[2][0],14*frame_parms->N_RB_DL*12,1,1);
- //write_output("dl_ch_estimates_ext11.m", "dl_ch_estimates_ext11", &pdsch_vars[eNB_id]->dl_ch_estimates_ext[3][0],14*frame_parms->N_RB_DL*12,1,1);
- write_output("rxdataF_comp00.m","rxdataF_comp00", &pdsch_vars[eNB_id]->rxdataF_comp0[0][0],14*frame_parms->N_RB_DL*12,1,1);
- //write_output("rxdataF_comp01.m","rxdataF_comp01", &pdsch_vars[eNB_id]->rxdataF_comp0[1][0],14*frame_parms->N_RB_DL*12,1,1);
- //write_output("rxdataF_comp10.m","rxdataF_comp10", &pdsch_vars[eNB_id]->rxdataF_comp1[harq_pid][round][0][0],14*frame_parms->N_RB_DL*12,1,1);
- //write_output("rxdataF_comp11.m","rxdataF_comp11", &pdsch_vars[eNB_id]->rxdataF_comp1[harq_pid][round][1][0],14*frame_parms->N_RB_DL*12,1,1);
-#endif
- write_output("llr0.m","llr0", &pdsch_vars[eNB_id]->llr[0][0],(14*nb_rb*12*dlsch1_harq->Qm) - 4*(nb_rb*4*dlsch1_harq->Qm),1,0);
- //write_output("llr1.m","llr1", &pdsch_vars[eNB_id]->llr[1][0],(14*nb_rb*12*dlsch1_harq->Qm) - 4*(nb_rb*4*dlsch1_harq->Qm),1,0);
+ snprintf(filename, 40, "dl_ch_estimates0%d_symb_%d_nr_tti_rx_%d.m", aa, symbol, nr_tti_rx);
+ write_output(filename, "dl_ch_estimates", &pdsch_vars[eNB_id]->dl_ch_estimates[aa][0], NR_SYMBOLS_PER_SLOT*frame_parms->ofdm_symbol_size, 1, 1);
+ snprintf(filename, 40, "rxdataF_ext0%d_symb_%d_nr_tti_rx_%d.m", aa, symbol, nr_tti_rx);
+ write_output(filename, "rxdataF_ext", &pdsch_vars[eNB_id]->rxdataF_ext[aa][0], NR_SYMBOLS_PER_SLOT*frame_parms->N_RB_DL*NR_NB_SC_PER_RB, 1, 1);
- AssertFatal(0," ");
- }
+ snprintf(filename, 40, "dl_ch_estimates_ext0%d_symb_%d_nr_tti_rx_%d.m", aa, symbol, nr_tti_rx);
+ write_output(filename, "dl_ch_estimates_ext00", &pdsch_vars[eNB_id]->dl_ch_estimates_ext[aa][0], NR_SYMBOLS_PER_SLOT*frame_parms->N_RB_DL*NR_NB_SC_PER_RB, 1, 1);
+ snprintf(filename, 40, "rxdataF_comp0%d_symb_%d_nr_tti_rx_%d.m", aa, symbol, nr_tti_rx);
+ write_output(filename, "rxdataF_comp00", &pdsch_vars[eNB_id]->rxdataF_comp0[aa][0], NR_SYMBOLS_PER_SLOT*frame_parms->N_RB_DL*NR_NB_SC_PER_RB, 1, 1);
+
+ for (int i=0; i < 2; i++){
+ snprintf(filename, 40, "llr%d_symb_%d_nr_tti_rx_%d.m", i, symbol, nr_tti_rx);
+ write_output(filename,"llr", &pdsch_vars[eNB_id]->llr[i][0], (NR_SYMBOLS_PER_SLOT*nb_rb*NR_NB_SC_PER_RB*dlsch1_harq->Qm) - 4*(nb_rb*4*dlsch1_harq->Qm), 1, 0);
}
#endif
@@ -2572,51 +2557,51 @@ void dump_dlsch2(PHY_VARS_UE *ue,uint8_t eNB_id,uint8_t nr_tti_rx,unsigned int *
char fname[32],vname[32];
int N_RB_DL=ue->frame_parms.N_RB_DL;
- sprintf(fname,"dlsch%d_rxF_r%d_ext0.m",eNB_id,round);
- sprintf(vname,"dl%d_rxF_r%d_ext0",eNB_id,round);
+ snprintf(fname, 32, "dlsch%d_rxF_r%d_ext0.m",eNB_id,round);
+ snprintf(vname, 32, "dl%d_rxF_r%d_ext0",eNB_id,round);
write_output(fname,vname,ue->pdsch_vars[ue->current_thread_id[nr_tti_rx]][eNB_id]->rxdataF_ext[0],12*N_RB_DL*nsymb,1,1);
if (ue->frame_parms.nb_antennas_rx >1) {
- sprintf(fname,"dlsch%d_rxF_r%d_ext1.m",eNB_id,round);
- sprintf(vname,"dl%d_rxF_r%d_ext1",eNB_id,round);
+ snprintf(fname, 32, "dlsch%d_rxF_r%d_ext1.m",eNB_id,round);
+ snprintf(vname, 32, "dl%d_rxF_r%d_ext1",eNB_id,round);
write_output(fname,vname,ue->pdsch_vars[ue->current_thread_id[nr_tti_rx]][eNB_id]->rxdataF_ext[1],12*N_RB_DL*nsymb,1,1);
}
- sprintf(fname,"dlsch%d_ch_r%d_ext00.m",eNB_id,round);
- sprintf(vname,"dl%d_ch_r%d_ext00",eNB_id,round);
+ snprintf(fname, 32, "dlsch%d_ch_r%d_ext00.m",eNB_id,round);
+ snprintf(vname, 32, "dl%d_ch_r%d_ext00",eNB_id,round);
write_output(fname,vname,ue->pdsch_vars[ue->current_thread_id[nr_tti_rx]][eNB_id]->dl_ch_estimates_ext[0],12*N_RB_DL*nsymb,1,1);
if (ue->transmission_mode[eNB_id]==7){
- sprintf(fname,"dlsch%d_bf_ch_r%d.m",eNB_id,round);
- sprintf(vname,"dl%d_bf_ch_r%d",eNB_id,round);
+ snprintf(fname, 32, "dlsch%d_bf_ch_r%d.m",eNB_id,round);
+ snprintf(vname, 32, "dl%d_bf_ch_r%d",eNB_id,round);
write_output(fname,vname,ue->pdsch_vars[ue->current_thread_id[nr_tti_rx]][eNB_id]->dl_bf_ch_estimates[0],512*nsymb,1,1);
//write_output(fname,vname,phy_vars_ue->lte_ue_pdsch_vars[eNB_id]->dl_bf_ch_estimates[0],512,1,1);
- sprintf(fname,"dlsch%d_bf_ch_r%d_ext00.m",eNB_id,round);
- sprintf(vname,"dl%d_bf_ch_r%d_ext00",eNB_id,round);
+ snprintf(fname, 32, "dlsch%d_bf_ch_r%d_ext00.m",eNB_id,round);
+ snprintf(vname, 32, "dl%d_bf_ch_r%d_ext00",eNB_id,round);
write_output(fname,vname,ue->pdsch_vars[ue->current_thread_id[nr_tti_rx]][eNB_id]->dl_bf_ch_estimates_ext[0],12*N_RB_DL*nsymb,1,1);
}
if (ue->frame_parms.nb_antennas_rx == 2) {
- sprintf(fname,"dlsch%d_ch_r%d_ext01.m",eNB_id,round);
- sprintf(vname,"dl%d_ch_r%d_ext01",eNB_id,round);
+ snprintf(fname, 32, "dlsch%d_ch_r%d_ext01.m",eNB_id,round);
+ snprintf(vname, 32, "dl%d_ch_r%d_ext01",eNB_id,round);
write_output(fname,vname,ue->pdsch_vars[ue->current_thread_id[nr_tti_rx]][eNB_id]->dl_ch_estimates_ext[1],12*N_RB_DL*nsymb,1,1);
}
if (ue->frame_parms.nb_antenna_ports_gNB == 2) {
- sprintf(fname,"dlsch%d_ch_r%d_ext10.m",eNB_id,round);
- sprintf(vname,"dl%d_ch_r%d_ext10",eNB_id,round);
+ snprintf(fname, 32, "dlsch%d_ch_r%d_ext10.m",eNB_id,round);
+ snprintf(vname, 32, "dl%d_ch_r%d_ext10",eNB_id,round);
write_output(fname,vname,ue->pdsch_vars[ue->current_thread_id[nr_tti_rx]][eNB_id]->dl_ch_estimates_ext[2],12*N_RB_DL*nsymb,1,1);
if (ue->frame_parms.nb_antennas_rx == 2) {
- sprintf(fname,"dlsch%d_ch_r%d_ext11.m",eNB_id,round);
- sprintf(vname,"dl%d_ch_r%d_ext11",eNB_id,round);
+ snprintf(fname, 32, "dlsch%d_ch_r%d_ext11.m",eNB_id,round);
+ snprintf(vname, 32, "dl%d_ch_r%d_ext11",eNB_id,round);
write_output(fname,vname,ue->pdsch_vars[ue->current_thread_id[nr_tti_rx]][eNB_id]->dl_ch_estimates_ext[3],12*N_RB_DL*nsymb,1,1);
}
}
- sprintf(fname,"dlsch%d_rxF_r%d_uespec0.m",eNB_id,round);
- sprintf(vname,"dl%d_rxF_r%d_uespec0",eNB_id,round);
+ snprintf(fname, 32, "dlsch%d_rxF_r%d_uespec0.m",eNB_id,round);
+ snprintf(vname, 32, "dl%d_rxF_r%d_uespec0",eNB_id,round);
write_output(fname,vname,ue->pdsch_vars[ue->current_thread_id[nr_tti_rx]][eNB_id]->rxdataF_uespec_pilots[0],12*N_RB_DL,1,1);
/*
@@ -2624,33 +2609,33 @@ void dump_dlsch2(PHY_VARS_UE *ue,uint8_t eNB_id,uint8_t nr_tti_rx,unsigned int *
write_output("dlsch%d_ch_ext10.m","dl10_ch0_ext",pdsch_vars[eNB_id]->dl_ch_estimates_ext[2],12*N_RB_DL*nsymb,1,1);
write_output("dlsch%d_ch_ext11.m","dl11_ch0_ext",pdsch_vars[eNB_id]->dl_ch_estimates_ext[3],12*N_RB_DL*nsymb,1,1);
*/
- sprintf(fname,"dlsch%d_r%d_rho.m",eNB_id,round);
- sprintf(vname,"dl_rho_r%d_%d",eNB_id,round);
+ snprintf(fname, 32, "dlsch%d_r%d_rho.m",eNB_id,round);
+ snprintf(vname, 32, "dl_rho_r%d_%d",eNB_id,round);
write_output(fname,vname,ue->pdsch_vars[ue->current_thread_id[nr_tti_rx]][eNB_id]->dl_ch_rho_ext[harq_pid][round][0],12*N_RB_DL*nsymb,1,1);
- sprintf(fname,"dlsch%d_r%d_rho2.m",eNB_id,round);
- sprintf(vname,"dl_rho2_r%d_%d",eNB_id,round);
+ snprintf(fname, 32, "dlsch%d_r%d_rho2.m",eNB_id,round);
+ snprintf(vname, 32, "dl_rho2_r%d_%d",eNB_id,round);
write_output(fname,vname,ue->pdsch_vars[ue->current_thread_id[nr_tti_rx]][eNB_id]->dl_ch_rho2_ext[0],12*N_RB_DL*nsymb,1,1);
- sprintf(fname,"dlsch%d_rxF_r%d_comp0.m",eNB_id,round);
- sprintf(vname,"dl%d_rxF_r%d_comp0",eNB_id,round);
+ snprintf(fname, 32, "dlsch%d_rxF_r%d_comp0.m",eNB_id,round);
+ snprintf(vname, 32, "dl%d_rxF_r%d_comp0",eNB_id,round);
write_output(fname,vname,ue->pdsch_vars[ue->current_thread_id[nr_tti_rx]][eNB_id]->rxdataF_comp0[0],12*N_RB_DL*nsymb,1,1);
if (ue->frame_parms.nb_antenna_ports_gNB == 2) {
- sprintf(fname,"dlsch%d_rxF_r%d_comp1.m",eNB_id,round);
- sprintf(vname,"dl%d_rxF_r%d_comp1",eNB_id,round);
+ snprintf(fname, 32, "dlsch%d_rxF_r%d_comp1.m",eNB_id,round);
+ snprintf(vname, 32, "dl%d_rxF_r%d_comp1",eNB_id,round);
write_output(fname,vname,ue->pdsch_vars[ue->current_thread_id[nr_tti_rx]][eNB_id]->rxdataF_comp1[harq_pid][round][0],12*N_RB_DL*nsymb,1,1);
}
- sprintf(fname,"dlsch%d_rxF_r%d_llr.m",eNB_id,round);
- sprintf(vname,"dl%d_r%d_llr",eNB_id,round);
+ snprintf(fname, 32, "dlsch%d_rxF_r%d_llr.m",eNB_id,round);
+ snprintf(vname, 32, "dl%d_r%d_llr",eNB_id,round);
write_output(fname,vname, ue->pdsch_vars[ue->current_thread_id[nr_tti_rx]][eNB_id]->llr[0],coded_bits_per_codeword[0],1,0);
- sprintf(fname,"dlsch%d_r%d_mag1.m",eNB_id,round);
- sprintf(vname,"dl%d_r%d_mag1",eNB_id,round);
+ snprintf(fname, 32, "dlsch%d_r%d_mag1.m",eNB_id,round);
+ snprintf(vname, 32, "dl%d_r%d_mag1",eNB_id,round);
write_output(fname,vname,ue->pdsch_vars[ue->current_thread_id[nr_tti_rx]][eNB_id]->dl_ch_mag0[0],12*N_RB_DL*nsymb,1,1);
- sprintf(fname,"dlsch%d_r%d_mag2.m",eNB_id,round);
- sprintf(vname,"dl%d_r%d_mag2",eNB_id,round);
+ snprintf(fname, 32, "dlsch%d_r%d_mag2.m",eNB_id,round);
+ snprintf(vname, 32, "dl%d_r%d_mag2",eNB_id,round);
write_output(fname,vname,ue->pdsch_vars[ue->current_thread_id[nr_tti_rx]][eNB_id]->dl_ch_magb0[0],12*N_RB_DL*nsymb,1,1);
// printf("log2_maxh = %d\n",ue->pdsch_vars[eNB_id]->log2_maxh);
diff --git a/openair1/PHY/NR_UE_TRANSPORT/nr_ulsch_coding.c b/openair1/PHY/NR_UE_TRANSPORT/nr_ulsch_coding.c
index 6f5fba7812..ee10c96c20 100644
--- a/openair1/PHY/NR_UE_TRANSPORT/nr_ulsch_coding.c
+++ b/openair1/PHY/NR_UE_TRANSPORT/nr_ulsch_coding.c
@@ -41,6 +41,7 @@
#include "common/utils/LOG/vcd_signal_dumper.h"
#include "LAYER2/NR_MAC_gNB/mac_proto.h"
+//#define DEBUG_ULSCH_CODING
void free_nr_ue_ulsch(NR_UE_ULSCH_t **ulschptr,unsigned char N_RB_UL)
@@ -248,7 +249,7 @@ int nr_ulsch_encoding(NR_UE_ULSCH_t *ulsch,
crc = 1;
harq_process = ulsch->harq_processes[harq_pid];
nb_rb = harq_process->pusch_pdu.rb_size;
- A = harq_process->pusch_pdu.pusch_data.tb_size;
+ A = harq_process->pusch_pdu.pusch_data.tb_size*8;
pz = &Z;
mod_order = nr_get_Qm_ul(harq_process->pusch_pdu.mcs_index, harq_process->pusch_pdu.mcs_table);
R = nr_get_code_rate_ul(harq_process->pusch_pdu.mcs_index, harq_process->pusch_pdu.mcs_table);
@@ -271,7 +272,7 @@ int nr_ulsch_encoding(NR_UE_ULSCH_t *ulsch,
// if (harq_process->Ndi == 1) { // this is a new packet
if (harq_process->round == 0) { // this is a new packet
-#ifdef DEBUG_DLSCH_CODING
+#ifdef DEBUG_ULSCH_CODING
printf("encoding thinks this is a new packet \n");
#endif
@@ -345,7 +346,7 @@ int nr_ulsch_encoding(NR_UE_ULSCH_t *ulsch,
F = harq_process->F;
Kr = harq_process->K;
-#ifdef DEBUG_DLSCH_CODING
+#ifdef DEBUG_ULSCH_CODING
uint16_t Kr_bytes;
Kr_bytes = Kr>>3;
#endif
@@ -358,7 +359,7 @@ int nr_ulsch_encoding(NR_UE_ULSCH_t *ulsch,
//start_meas(te_stats);
for (r=0; rC; r++) {
//channel_input[r] = &harq_process->d[r][0];
-#ifdef DEBUG_DLSCH_CODING
+#ifdef DEBUG_ULSCH_CODING
printf("Encoder: B %d F %d \n",harq_process->B, harq_process->F);
printf("start ldpc encoder segment %d/%d\n",r,harq_process->C);
printf("input %d %d %d %d %d \n", harq_process->c[r][0], harq_process->c[r][1], harq_process->c[r][2],harq_process->c[r][3], harq_process->c[r][4]);
@@ -391,6 +392,10 @@ int nr_ulsch_encoding(NR_UE_ULSCH_t *ulsch,
encoder_implemparams_t impp;
impp.n_segments=harq_process->C;
impp.macro_num=0;
+ impp.tinput = NULL;
+ impp.tprep = NULL;
+ impp.tparity = NULL;
+ impp.toutput = NULL;
VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_LDPC_ENCODER_OPTIM, VCD_FUNCTION_IN);
@@ -400,7 +405,7 @@ int nr_ulsch_encoding(NR_UE_ULSCH_t *ulsch,
//stop_meas(te_stats);
//printf("end ldpc encoder -- output\n");
-#ifdef DEBUG_DLSCH_CODING
+#ifdef DEBUG_ULSCH_CODING
write_output("ulsch_enc_input0.m","enc_in0",&harq_process->c[0][0],Kr_bytes,1,4);
write_output("ulsch_enc_output0.m","enc0",&harq_process->d[0][0],(3*8*Kr_bytes)+12,1,4);
#endif
@@ -438,7 +443,7 @@ int nr_ulsch_encoding(NR_UE_ULSCH_t *ulsch,
E = nr_get_E(G, harq_process->C, mod_order, harq_process->pusch_pdu.nrOfLayers, r);
- Tbslbrm = nr_compute_tbslbrm(0,nb_rb,harq_process->pusch_pdu.nrOfLayers,harq_process->C);
+ Tbslbrm = nr_compute_tbslbrm(0,nb_rb,harq_process->pusch_pdu.nrOfLayers);
VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_NR_RATE_MATCHING_LDPC, VCD_FUNCTION_IN);
nr_rate_matching_ldpc(Ilbrm,
@@ -456,7 +461,7 @@ int nr_ulsch_encoding(NR_UE_ULSCH_t *ulsch,
-#ifdef DEBUG_DLSCH_CODING
+#ifdef DEBUG_ULSCH_CODING
for (int i =0; i<16; i++)
printf("output ratematching e[%d]= %d r_offset %d\n", i,harq_process->e[i+r_offset], r_offset);
#endif
@@ -482,7 +487,7 @@ int nr_ulsch_encoding(NR_UE_ULSCH_t *ulsch,
//stop_meas(i_stats);
-#ifdef DEBUG_DLSCH_CODING
+#ifdef DEBUG_ULSCH_CODING
for (int i =0; i<16; i++)
printf("output interleaving f[%d]= %d r_offset %d\n", i,harq_process->f[i+r_offset], r_offset);
diff --git a/openair1/PHY/NR_UE_TRANSPORT/nr_ulsch_ue.c b/openair1/PHY/NR_UE_TRANSPORT/nr_ulsch_ue.c
index c85a7691f6..ea79fd467f 100644
--- a/openair1/PHY/NR_UE_TRANSPORT/nr_ulsch_ue.c
+++ b/openair1/PHY/NR_UE_TRANSPORT/nr_ulsch_ue.c
@@ -101,74 +101,53 @@ void nr_ue_ulsch_procedures(PHY_VARS_NR_UE *UE,
LOG_D(PHY,"nr_ue_ulsch_procedures hard_id %d %d.%d\n",harq_pid,frame,slot);
uint32_t available_bits;
- uint8_t mod_order, cwd_index, num_of_codewords, l;
+ uint8_t cwd_index, l;
uint32_t scrambled_output[NR_MAX_NB_CODEWORDS][NR_MAX_PDSCH_ENCODED_LENGTH>>5];
- uint32_t ***pusch_dmrs;
int16_t **tx_layers;
int32_t **txdataF;
- uint16_t start_sc, start_rb;
int8_t Wf[2], Wt[2], l_prime[2], delta;
- uint16_t rnti, n_dmrs, code_rate, number_dmrs_symbols, nb_rb, k;
- uint8_t dmrs_type, nb_dmrs_re_per_rb, number_of_symbols, mcs, Nl;
- int ap, start_symbol, Nid_cell, i;
- int sample_offsetF, N_RE_prime, N_PRB_oh;
- uint16_t ul_dmrs_symb_pos;
- uint8_t L_ptrs, K_ptrs; // PTRS parameters
- uint16_t beta_ptrs; // PTRS parameter related to power control
+ uint8_t nb_dmrs_re_per_rb;
+ int ap, i;
+ int sample_offsetF, N_RE_prime;
- NR_UE_ULSCH_t *ulsch_ue;
- NR_UL_UE_HARQ_t *harq_process_ul_ue=NULL;
NR_DL_FRAME_PARMS *frame_parms = &UE->frame_parms;
NR_UE_PUSCH *pusch_ue = UE->pusch_vars[thread_id][gNB_id];
// ptrs_UplinkConfig_t *ptrs_Uplink_Config = &UE->pusch_config.dmrs_UplinkConfig.ptrs_UplinkConfig;
- num_of_codewords = 1; // tmp assumption
- Nid_cell = 0;
- N_PRB_oh = 0; // higher layer (RRC) parameter xOverhead in PUSCH-ServingCellConfig
- number_dmrs_symbols = 0;
+ uint8_t num_of_codewords = 1; // tmp assumption
+ int Nid_cell = 0;
+ int N_PRB_oh = 0; // higher layer (RRC) parameter xOverhead in PUSCH-ServingCellConfig
+ uint16_t number_dmrs_symbols = 0;
for (cwd_index = 0;cwd_index < num_of_codewords; cwd_index++) {
- ulsch_ue = UE->ulsch[thread_id][gNB_id][cwd_index];
- harq_process_ul_ue = ulsch_ue->harq_processes[harq_pid];
+ NR_UE_ULSCH_t *ulsch_ue = UE->ulsch[thread_id][gNB_id][cwd_index];
+ NR_UL_UE_HARQ_t *harq_process_ul_ue = ulsch_ue->harq_processes[harq_pid];
+ nfapi_nr_ue_pusch_pdu_t *pusch_pdu = &harq_process_ul_ue->pusch_pdu;
- start_symbol = harq_process_ul_ue->pusch_pdu.start_symbol_index;
- ul_dmrs_symb_pos = harq_process_ul_ue->pusch_pdu.ul_dmrs_symb_pos;
- number_of_symbols = harq_process_ul_ue->pusch_pdu.nr_of_symbols;
- dmrs_type = harq_process_ul_ue->pusch_pdu.dmrs_config_type;
+ int start_symbol = pusch_pdu->start_symbol_index;
+ uint16_t ul_dmrs_symb_pos = pusch_pdu->ul_dmrs_symb_pos;
+ uint8_t number_of_symbols = pusch_pdu->nr_of_symbols;
+ uint8_t dmrs_type = pusch_pdu->dmrs_config_type;
+ uint16_t start_rb = pusch_pdu->rb_start;
+ uint16_t nb_rb = pusch_pdu->rb_size;
+ uint8_t Nl = pusch_pdu->nrOfLayers;
+ uint8_t mod_order = pusch_pdu->qam_mod_order;
+ uint16_t rnti = pusch_pdu->rnti;
+ uint8_t cdm_grps_no_data = pusch_pdu->num_dmrs_cdm_grps_no_data;
+ uint16_t start_sc = frame_parms->first_carrier_offset + start_rb*NR_NB_SC_PER_RB;
- for (i = start_symbol; i < start_symbol + number_of_symbols; i++) {
+ if (start_sc >= frame_parms->ofdm_symbol_size)
+ start_sc -= frame_parms->ofdm_symbol_size;
- if((ul_dmrs_symb_pos >> i) & 0x01)
- number_dmrs_symbols += 1;
-
- }
-
- rnti = harq_process_ul_ue->pusch_pdu.rnti;
ulsch_ue->Nid_cell = Nid_cell;
- nb_dmrs_re_per_rb = ((dmrs_type == pusch_dmrs_type1) ? 6:4)*harq_process_ul_ue->pusch_pdu.num_dmrs_cdm_grps_no_data;
+ get_num_re_dmrs(pusch_pdu, &nb_dmrs_re_per_rb, &number_dmrs_symbols);
+ // TbD num_of_mod_symbols is set but never used
N_RE_prime = NR_NB_SC_PER_RB*number_of_symbols - nb_dmrs_re_per_rb*number_dmrs_symbols - N_PRB_oh;
-
- nb_rb = harq_process_ul_ue->pusch_pdu.rb_size;
-
harq_process_ul_ue->num_of_mod_symbols = N_RE_prime*nb_rb*num_of_codewords;
- mcs = harq_process_ul_ue->pusch_pdu.mcs_index;
- Nl = harq_process_ul_ue->pusch_pdu.nrOfLayers;
- mod_order = nr_get_Qm_ul(mcs, 0);
- code_rate = nr_get_code_rate_ul(mcs, 0);
-
- harq_process_ul_ue->pusch_pdu.pusch_data.tb_size = nr_compute_tbs(mod_order,
- code_rate,
- nb_rb,
- number_of_symbols,
- nb_dmrs_re_per_rb*number_dmrs_symbols,
- 0,
- 0,
- harq_process_ul_ue->pusch_pdu.nrOfLayers);
-
/////////////////////////ULSCH coding/////////////////////////
///////////
@@ -210,14 +189,10 @@ void nr_ue_ulsch_procedures(PHY_VARS_NR_UE *UE,
///////////
////////////////////////////////////////////////////////////////////////
-
- //}
- }
-
/////////////////////////DMRS Modulation/////////////////////////
///////////
- pusch_dmrs = UE->nr_gold_pusch_dmrs[slot];
- n_dmrs = (nb_rb*((dmrs_type == pusch_dmrs_type1) ? 6:4)*number_dmrs_symbols);
+ uint32_t ***pusch_dmrs = UE->nr_gold_pusch_dmrs[slot];
+ uint16_t n_dmrs = (start_rb+nb_rb)*((dmrs_type == pusch_dmrs_type1) ? 6:4);
int16_t mod_dmrs[n_dmrs<<1] __attribute((aligned(16)));
///////////
////////////////////////////////////////////////////////////////////////
@@ -227,9 +202,10 @@ void nr_ue_ulsch_procedures(PHY_VARS_NR_UE *UE,
///////////
int16_t mod_ptrs[nb_rb] __attribute((aligned(16))); // assume maximum number of PTRS per pusch allocation
- K_ptrs = 0; // just to avoid a warning
+ uint8_t L_ptrs, K_ptrs = 0;
+ uint16_t beta_ptrs = 1; // temp value until power control is implemented
- if (harq_process_ul_ue->pusch_pdu.pdu_bit_map & PUSCH_PDU_BITMAP_PUSCH_PTRS) {
+ if (pusch_pdu->pdu_bit_map & PUSCH_PDU_BITMAP_PUSCH_PTRS) {
K_ptrs = harq_process_ul_ue->pusch_pdu.pusch_ptrs.ptrs_freq_density;
L_ptrs = 1<pusch_pdu.pusch_ptrs.ptrs_time_density;
@@ -274,11 +250,6 @@ void nr_ue_ulsch_procedures(PHY_VARS_NR_UE *UE,
for (l = start_symbol; l < start_symbol + number_of_symbols; l++) {
if((ul_dmrs_symb_pos >> l) & 0x01)
- is_dmrs = 1;
- else
- is_dmrs = 0;
-
- if (is_dmrs == 1)
nb_re_dmrs_per_rb = nb_dmrs_re_per_rb;
else
nb_re_dmrs_per_rb = 0;
@@ -303,64 +274,70 @@ void nr_ue_ulsch_procedures(PHY_VARS_NR_UE *UE,
txdataF = UE->common_vars.txdataF;
- start_rb = harq_process_ul_ue->pusch_pdu.rb_start;
- start_sc = frame_parms->first_carrier_offset + start_rb*NR_NB_SC_PER_RB;
-
- if (start_sc >= frame_parms->ofdm_symbol_size)
- start_sc -= frame_parms->ofdm_symbol_size;
-
for (ap=0; ap< Nl; ap++) {
+ uint8_t k_prime = 0;
+ uint16_t m = 0;
+
// DMRS params for this ap
get_Wt(Wt, ap, dmrs_type);
get_Wf(Wf, ap, dmrs_type);
delta = get_delta(ap, dmrs_type);
-
-
- uint8_t k_prime=0;
- uint8_t is_dmrs, is_ptrs, is_dmrs_symbol;
- uint16_t m=0, n=0, dmrs_idx=0, ptrs_idx = 0;
for (l=start_symbol; l> l) & 0x01) {
+ is_dmrs_sym = 1;
+
+ if (pusch_pdu->transform_precoding == 1){ // if transform precoding is disabled
+ if (dmrs_type == pusch_dmrs_type1)
+ dmrs_idx = start_rb*6;
+ else
+ dmrs_idx = start_rb*4;
+ } else {
+ dmrs_idx = 0;
+ }
+
+ nr_modulation(pusch_dmrs[l][0], n_dmrs*2, DMRS_MOD_ORDER, mod_dmrs); // currently only codeword 0 is modulated. Qm = 2 as DMRS is QPSK modulated
+
+ } else if (pusch_pdu->pdu_bit_map & PUSCH_PDU_BITMAP_PUSCH_PTRS) {
+
+ if(is_ptrs_symbol(l, ulsch_ue->ptrs_symbols)) {
+ is_ptrs_sym = 1;
+ nr_modulation(pusch_dmrs[l][0], nb_rb, DMRS_MOD_ORDER, mod_ptrs);
+ }
+ }
for (i=0; i< nb_rb*NR_NB_SC_PER_RB; i++) {
+ uint8_t is_dmrs = 0;
+ uint8_t is_ptrs = 0;
+
sample_offsetF = l*frame_parms->ofdm_symbol_size + k;
- is_dmrs = 0;
- is_ptrs = 0;
- is_dmrs_symbol = 0;
-
- if((ul_dmrs_symb_pos >> l) & 0x01) {
- is_dmrs_symbol = 1;
+ if (is_dmrs_sym) {
if (k == ((start_sc+get_dmrs_freq_idx_ul(n, k_prime, delta, dmrs_type))%frame_parms->ofdm_symbol_size))
is_dmrs = 1;
- }
-
- if (harq_process_ul_ue->pusch_pdu.pdu_bit_map & PUSCH_PDU_BITMAP_PUSCH_PTRS){
-
- if(is_ptrs_symbol(l, ulsch_ue->ptrs_symbols))
+ } else if (is_ptrs_sym) {
is_ptrs = is_ptrs_subcarrier(k,
rnti,
ap,
dmrs_type,
K_ptrs,
nb_rb,
- harq_process_ul_ue->pusch_pdu.pusch_ptrs.ptrs_ports_list[0].ptrs_re_offset,
+ pusch_pdu->pusch_ptrs.ptrs_ports_list[0].ptrs_re_offset,
start_sc,
frame_parms->ofdm_symbol_size);
}
if (is_dmrs == 1) {
- if (k == start_sc){
- nr_modulation(pusch_dmrs[l][0], n_dmrs*2, DMRS_MOD_ORDER, mod_dmrs); // currently only codeword 0 is modulated. Qm = 2 as DMRS is QPSK modulated
- }
-
((int16_t*)txdataF[ap])[(sample_offsetF)<<1] = (Wt[l_prime[0]]*Wf[k_prime]*AMP*mod_dmrs[dmrs_idx<<1]) >> 15;
((int16_t*)txdataF[ap])[((sample_offsetF)<<1) + 1] = (Wt[l_prime[0]]*Wf[k_prime]*AMP*mod_dmrs[(dmrs_idx<<1) + 1]) >> 15;
@@ -378,16 +355,12 @@ void nr_ue_ulsch_procedures(PHY_VARS_NR_UE *UE,
} else if (is_ptrs == 1) {
- if (k == start_sc){
- nr_modulation(pusch_dmrs[l][0], nb_rb, DMRS_MOD_ORDER, mod_ptrs);
- }
-
((int16_t*)txdataF[ap])[(sample_offsetF)<<1] = (beta_ptrs*AMP*mod_ptrs[ptrs_idx<<1]) >> 15;
((int16_t*)txdataF[ap])[((sample_offsetF)<<1) + 1] = (beta_ptrs*AMP*mod_ptrs[(ptrs_idx<<1) + 1]) >> 15;
ptrs_idx++;
- } else if (!is_dmrs_symbol || allowed_xlsch_re_in_dmrs_symbol(k,start_sc,harq_process_ul_ue->pusch_pdu.num_dmrs_cdm_grps_no_data,dmrs_type)) {
+ } else if (!is_dmrs_sym || allowed_xlsch_re_in_dmrs_symbol(k, start_sc, cdm_grps_no_data, dmrs_type)) {
((int16_t*)txdataF[ap])[(sample_offsetF)<<1] = ((int16_t *) ulsch_ue->y)[m<<1];
((int16_t*)txdataF[ap])[((sample_offsetF)<<1) + 1] = ((int16_t *) ulsch_ue->y)[(m<<1) + 1];
@@ -412,8 +385,8 @@ void nr_ue_ulsch_procedures(PHY_VARS_NR_UE *UE,
}
}
}
+ }
- //}
NR_UL_UE_HARQ_t *harq_process_ulsch=NULL;
harq_process_ulsch = UE->ulsch[thread_id][gNB_id][0]->harq_processes[harq_pid];
harq_process_ulsch->status = SCH_IDLE;
diff --git a/openair1/PHY/defs_gNB.h b/openair1/PHY/defs_gNB.h
index 179ca0331f..4d5a46c4fd 100644
--- a/openair1/PHY/defs_gNB.h
+++ b/openair1/PHY/defs_gNB.h
@@ -263,6 +263,8 @@ typedef struct {
int16_t e[MAX_NUM_NR_DLSCH_SEGMENTS][3*8448];
/// Number of bits in each code block after rate matching for LDPC code (38.212 V15.4.0 section 5.4.2.1)
uint32_t E;
+ /// Number of segments processed so far
+ uint32_t processedSegments;
//////////////////////////////////////////////////////////////
@@ -475,7 +477,6 @@ typedef struct {
uint8_t cl_done;
} NR_gNB_PUSCH;
-
/// Context data structure for RX/TX portion of slot processing
typedef struct {
/// Component Carrier index
@@ -822,7 +823,45 @@ typedef struct PHY_VARS_gNB_s {
time_stats_t rx_dft_stats;
time_stats_t ulsch_freq_offset_estimation_stats;
*/
+ notifiedFIFO_t *respDecode;
+ tpool_t *threadPool;
+ int nbDecode;
} PHY_VARS_gNB;
+typedef struct LDPCDecode_s {
+ PHY_VARS_gNB *gNB;
+ NR_UL_gNB_HARQ_t *ulsch_harq;
+ t_nrLDPC_dec_params decoderParms;
+ NR_gNB_ULSCH_t *ulsch;
+ short* ulsch_llr;
+ int ulsch_id;
+ int harq_pid;
+ int rv_index;
+ int A;
+ int E;
+ int Kc;
+ int Qm;
+ int Kr_bytes;
+ int nbSegments;
+ int segment_r;
+ int r_offset;
+ int offset;
+ int Tbslbrm;
+ int decodeIterations;
+} ldpcDecode_t;
+
+struct ldpcReqId {
+ uint16_t rnti;
+ uint16_t frame;
+ uint8_t subframe;
+ uint8_t codeblock;
+ uint16_t spare;
+} __attribute__((packed));
+
+union ldpcReqUnion {
+ struct ldpcReqId s;
+ uint64_t p;
+};
+
#endif
diff --git a/openair1/PHY/defs_nr_UE.h b/openair1/PHY/defs_nr_UE.h
index 62ffeaaea8..fff6a82047 100644
--- a/openair1/PHY/defs_nr_UE.h
+++ b/openair1/PHY/defs_nr_UE.h
@@ -912,10 +912,6 @@ typedef struct {
char ulsch_no_allocation_counter[NUMBER_OF_CONNECTED_eNB_MAX];
unsigned char ulsch_Msg3_active[NUMBER_OF_CONNECTED_gNB_MAX];
- uint32_t ulsch_Msg3_frame[NUMBER_OF_CONNECTED_gNB_MAX];
- unsigned char ulsch_Msg3_subframe[NUMBER_OF_CONNECTED_gNB_MAX];
- uint8_t Msg3_startSymbol[NUMBER_OF_CONNECTED_gNB_MAX];
- uint8_t Msg3_Length[NUMBER_OF_CONNECTED_gNB_MAX];
NR_PRACH_RESOURCES_t *prach_resources[NUMBER_OF_CONNECTED_gNB_MAX];
int turbo_iterations, turbo_cntl_iterations;
diff --git a/openair1/SCHED_NR/phy_procedures_nr_gNB.c b/openair1/SCHED_NR/phy_procedures_nr_gNB.c
index 6dfe967edc..1024db3791 100644
--- a/openair1/SCHED_NR/phy_procedures_nr_gNB.c
+++ b/openair1/SCHED_NR/phy_procedures_nr_gNB.c
@@ -213,12 +213,74 @@ void phy_procedures_gNB_TX(PHY_VARS_gNB *gNB,
*/
+void nr_postDecode(PHY_VARS_gNB *gNB, notifiedFIFO_elt_t *req) {
+ ldpcDecode_t *rdata = (ldpcDecode_t*) NotifiedFifoData(req);
+ NR_UL_gNB_HARQ_t *ulsch_harq = rdata->ulsch_harq;
+ NR_gNB_ULSCH_t *ulsch = rdata->ulsch;
+ int r = rdata->segment_r;
+
+ bool decodeSuccess = (rdata->decodeIterations <= rdata->decoderParms.numMaxIter);
+ ulsch_harq->processedSegments++;
+ LOG_D(PHY, "processing result of segment: %d, processed %d/%d\n",
+ rdata->segment_r, ulsch_harq->processedSegments, rdata->nbSegments);
+ gNB->nbDecode--;
+ LOG_D(PHY,"remain to decoded in subframe: %d\n", gNB->nbDecode);
+
+ if (decodeSuccess) {
+ memcpy(ulsch_harq->b+rdata->offset,
+ ulsch_harq->c[r],
+ rdata->Kr_bytes- - (ulsch_harq->F>>3) -((ulsch_harq->C>1)?3:0));
+
+ } else {
+ if ( rdata->nbSegments != ulsch_harq->processedSegments ) {
+ int nb=abortTpool(gNB->threadPool, req->key);
+ nb+=abortNotifiedFIFO(gNB->respDecode, req->key);
+ gNB->nbDecode-=nb;
+ LOG_D(PHY,"uplink segment error %d/%d, aborted %d segments\n",rdata->segment_r,rdata->nbSegments, nb);
+ LOG_D(PHY, "ULSCH %d in error\n",rdata->ulsch_id);
+ AssertFatal(ulsch_harq->processedSegments+nb == rdata->nbSegments,"processed: %d, aborted: %d, total %d\n",
+ ulsch_harq->processedSegments, nb, rdata->nbSegments);
+ ulsch_harq->processedSegments=rdata->nbSegments;
+ }
+ }
+
+ // if all segments are done
+ if (rdata->nbSegments == ulsch_harq->processedSegments) {
+ if (decodeSuccess) {
+ LOG_D(PHY,"[gNB %d] ULSCH: Setting ACK for nr_tti_rx %d TBS %d\n",
+ gNB->Mod_id,ulsch_harq->slot,ulsch_harq->TBS);
+ ulsch_harq->status = SCH_IDLE;
+ ulsch_harq->round = 0;
+ ulsch->harq_mask &= ~(1 << rdata->harq_pid);
+
+ LOG_D(PHY, "ULSCH received ok \n");
+ nr_fill_indication(gNB,ulsch_harq->frame, ulsch_harq->slot, rdata->ulsch_id, rdata->harq_pid, 0);
+ } else {
+ LOG_D(PHY,"[gNB %d] ULSCH: Setting NAK for SFN/SF %d/%d (pid %d, status %d, round %d, TBS %d) r %d\n",
+ gNB->Mod_id, ulsch_harq->frame, ulsch_harq->slot,
+ rdata->harq_pid,ulsch_harq->status, ulsch_harq->round,ulsch_harq->TBS,r);
+ if (ulsch_harq->round >= ulsch->Mlimit) {
+ ulsch_harq->status = SCH_IDLE;
+ ulsch_harq->round = 0;
+ ulsch_harq->handled = 0;
+ ulsch->harq_mask &= ~(1 << rdata->harq_pid);
+ }
+ ulsch_harq->handled = 1;
+
+ LOG_D(PHY, "ULSCH %d in error\n",rdata->ulsch_id);
+ nr_fill_indication(gNB,ulsch_harq->frame, ulsch_harq->slot, rdata->ulsch_id, rdata->harq_pid, 1);
+ }
+ ulsch->last_iteration_cnt = rdata->decodeIterations;
+ VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_PHY_gNB_ULSCH_DECODING,0);
+ }
+}
+
+
void nr_ulsch_procedures(PHY_VARS_gNB *gNB, int frame_rx, int slot_rx, int ULSCH_id, uint8_t harq_pid)
{
NR_DL_FRAME_PARMS *frame_parms = &gNB->frame_parms;
nfapi_nr_pusch_pdu_t *pusch_pdu = &gNB->ulsch[ULSCH_id][0]->harq_processes[harq_pid]->ulsch_pdu;
- uint8_t ret;
uint8_t l, number_dmrs_symbols = 0;
uint32_t G;
uint16_t start_symbol, number_symbols, nb_re_dmrs;
@@ -270,25 +332,22 @@ void nr_ulsch_procedures(PHY_VARS_gNB *gNB, int frame_rx, int slot_rx, int ULSCH
//----------------------------------------------------------
start_meas(&gNB->ulsch_decoding_stats);
- ret = nr_ulsch_decoding(gNB,
- ULSCH_id,
- gNB->pusch_vars[ULSCH_id]->llr,
- frame_parms,
- pusch_pdu,
- frame_rx,
- slot_rx,
- harq_pid,
- G);
- stop_meas(&gNB->ulsch_decoding_stats);
+ nr_ulsch_decoding(gNB,
+ ULSCH_id,
+ gNB->pusch_vars[ULSCH_id]->llr,
+ frame_parms,
+ pusch_pdu,
+ frame_rx,
+ slot_rx,
+ harq_pid,
+ G);
- if (ret > gNB->ulsch[ULSCH_id][0]->max_ldpc_iterations){
- LOG_D(PHY, "ULSCH %d in error\n",ULSCH_id);
- nr_fill_indication(gNB,frame_rx, slot_rx, ULSCH_id, harq_pid, 1);
- }
- else if(gNB->ulsch[ULSCH_id][0]->harq_processes[harq_pid]->b!=NULL){
- LOG_D(PHY, "ULSCH received ok \n");
- nr_fill_indication(gNB,frame_rx, slot_rx, ULSCH_id, harq_pid, 0);
+ while (gNB->nbDecode > 0) {
+ notifiedFIFO_elt_t *req=pullTpool(gNB->respDecode, gNB->threadPool);
+ nr_postDecode(gNB, req);
+ delNotifiedFIFO_elt(req);
}
+ stop_meas(&gNB->ulsch_decoding_stats);
}
diff --git a/openair1/SCHED_NR_UE/defs.h b/openair1/SCHED_NR_UE/defs.h
index c6aea2ec08..3b60186fdb 100644
--- a/openair1/SCHED_NR_UE/defs.h
+++ b/openair1/SCHED_NR_UE/defs.h
@@ -111,17 +111,18 @@ int phy_procedures_RN_UE_RX(unsigned char last_slot, unsigned char next_slot, re
@param r_type indicates the relaying operation: 0: no_relaying, 1: unicast relaying type 1, 2: unicast relaying type 2, 3: multicast relaying
*/
void phy_procedures_nrUE_TX(PHY_VARS_NR_UE *ue,UE_nr_rxtx_proc_t *proc,uint8_t eNB_id, uint8_t thread_id);
+
/*! \brief Scheduling for UE RX procedures in normal subframes.
- @param last_slot Index of last slot (0-19)
- @param phy_vars_ue Pointer to UE variables on which to act
- @param proc Pointer to RXn_TXnp4 proc information
- @param eNB_id Local id of eNB on which to act
- @param abstraction_flag Indicator of PHY abstraction
- @param mode calibration/debug mode
- @param r_type indicates the relaying operation: 0: no_relaying, 1: unicast relaying type 1, 2: unicast relaying type 2, 3: multicast relaying
- @param phy_vars_rn pointer to RN variables
+ @param ue Pointer to UE variables on which to act
+ @param proc Pointer to proc information
+ @param gNB_id Local id of eNB on which to act
+ @param mode calibration/debug mode
*/
-int phy_procedures_nrUE_RX(PHY_VARS_NR_UE *ue,UE_nr_rxtx_proc_t *proc,uint8_t eNB_id,uint8_t do_pdcch_flag,runmode_t mode);
+int phy_procedures_nrUE_RX(PHY_VARS_NR_UE *ue,
+ UE_nr_rxtx_proc_t *proc,
+ uint8_t gNB_id,
+ runmode_t mode);
+
int phy_procedures_slot_parallelization_nrUE_RX(PHY_VARS_NR_UE *ue,UE_nr_rxtx_proc_t *proc,uint8_t eNB_id,uint8_t abstraction_flag,uint8_t do_pdcch_flag,runmode_t mode,relaying_type_t r_type);
diff --git a/openair1/SCHED_NR_UE/fapi_nr_ue_l1.c b/openair1/SCHED_NR_UE/fapi_nr_ue_l1.c
index 55c7cd0baf..2df917d676 100644
--- a/openair1/SCHED_NR_UE/fapi_nr_ue_l1.c
+++ b/openair1/SCHED_NR_UE/fapi_nr_ue_l1.c
@@ -57,10 +57,6 @@ int8_t nr_ue_scheduled_response(nr_scheduled_response_t *scheduled_response){
NR_UE_PDCCH *pdcch_vars = PHY_vars_UE_g[module_id][cc_id]->pdcch_vars[thread_id][0];
NR_UE_ULSCH_t *ulsch0 = PHY_vars_UE_g[module_id][cc_id]->ulsch[thread_id][0][0];
NR_DL_FRAME_PARMS frame_parms = PHY_vars_UE_g[module_id][cc_id]->frame_parms;
- //PRACH_RESOURCES_t *prach_resources = PHY_vars_UE_g[module_id][cc_id]->prach_resources[0];
-
- // PUCCH_ConfigCommon_nr_t *pucch_config_common = PHY_vars_UE_g[module_id][cc_id]->pucch_config_common_nr[0];
- // PUCCH_Config_t *pucch_config_dedicated = PHY_vars_UE_g[module_id][cc_id]->pucch_config_dedicated_nr[0];
if(scheduled_response->dl_config != NULL){
fapi_nr_dl_config_request_t *dl_config = scheduled_response->dl_config;
@@ -93,11 +89,11 @@ int8_t nr_ue_scheduled_response(nr_scheduled_response_t *scheduled_response){
dlsch0->current_harq_pid = current_harq_pid;
dlsch0->active = 1;
dlsch0->rnti = dl_config->dl_config_list[i].dlsch_config_pdu.rnti;
- //dlsch0->harq_processes[0]->mcs = &dlsch_config_pdu->mcs;
dlsch0_harq = dlsch0->harq_processes[current_harq_pid];
if (dlsch0_harq){
+ dlsch0_harq->status = ACTIVE;
dlsch0_harq->BWPStart = dlsch_config_pdu->BWPStart;
dlsch0_harq->BWPSize = dlsch_config_pdu->BWPSize;
dlsch0_harq->nb_rb = dlsch_config_pdu->number_rbs;
@@ -121,8 +117,7 @@ int8_t nr_ue_scheduled_response(nr_scheduled_response_t *scheduled_response){
}
}
}
- } else {
- pdcch_vars->nb_search_space = 0;
+ dl_config->number_pdus = 0;
}
if (scheduled_response->ul_config != NULL){
@@ -159,13 +154,14 @@ int8_t nr_ue_scheduled_response(nr_scheduled_response_t *scheduled_response){
ulsch0->f_pusch = pusch_config_pdu->absolute_delta_PUSCH;
- if (scheduled_response->tx_request){
+ if (scheduled_response->tx_request){ // TBR todo here it should loop through the number of tx pdus
fapi_nr_tx_request_body_t *tx_req_body = scheduled_response->tx_request->tx_request_body;
- //harq_process_ul_ue->a = (unsigned char*)calloc(TBS/8, sizeof(unsigned char));
memcpy(harq_process_ul_ue->a, tx_req_body->pdu, tx_req_body->pdu_length);
harq_process_ul_ue->status = ACTIVE;
+
+ scheduled_response->tx_request->number_of_pdus = 0;
}
} else {
@@ -223,7 +219,6 @@ int8_t nr_ue_scheduled_response(nr_scheduled_response_t *scheduled_response){
case (FAPI_NR_UL_CONFIG_TYPE_PRACH):
// prach config pdu
- //prach_resources = PHY_vars_UE_g[module_id][cc_id]->prach_resources[gNB_id];
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));
PHY_vars_UE_g[module_id][cc_id]->prach_vars[gNB_id]->prach_Config_enabled = 1;
@@ -233,11 +228,9 @@ int8_t nr_ue_scheduled_response(nr_scheduled_response_t *scheduled_response){
break;
}
}
- } else {
+ ul_config->number_pdus = 0;
}
-
}
-
return 0;
}
diff --git a/openair1/SCHED_NR_UE/phy_procedures_nr_ue.c b/openair1/SCHED_NR_UE/phy_procedures_nr_ue.c
index 691a231aba..d24c88fd1f 100644
--- a/openair1/SCHED_NR_UE/phy_procedures_nr_ue.c
+++ b/openair1/SCHED_NR_UE/phy_procedures_nr_ue.c
@@ -34,28 +34,22 @@
#include "assertions.h"
#include "defs.h"
-//#include "PHY/defs.h"
#include "PHY/defs_nr_UE.h"
-//#include "PHY/phy_vars_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 "PHY/extern.h"
#include "SCHED_NR_UE/defs.h"
#include "SCHED_NR_UE/pucch_uci_ue_nr.h"
#include "SCHED_NR/extern.h"
#include "SCHED_NR_UE/phy_sch_processing_time.h"
-//#include
-//#include "targets/RT/USER/nr-softmodem.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
#include "executables/softmodem-common.h"
-//#define DEBUG_PHY_PROC
#define NR_PDCCH_SCHED
//#define NR_PDCCH_SCHED_DEBUG
@@ -90,112 +84,10 @@ const uint8_t nr_rv_round_map_ue[4] = {0, 2, 1, 3};
extern double cpuf;
-/*
-int nr_generate_ue_ul_dlsch_params_from_dci(PHY_VARS_NR_UE *ue,
- uint8_t eNB_id,
- int frame,
- uint8_t nr_tti_rx,
- uint64_t dci_pdu[2],
- uint16_t rnti,
- uint8_t dci_length,
- NR_DCI_format_t dci_format,
- NR_UE_PDCCH *pdcch_vars,
- NR_UE_PDSCH *pdsch_vars,
- NR_UE_DLSCH_t **dlsch,
- NR_UE_ULSCH_t *ulsch,
- NR_DL_FRAME_PARMS *frame_parms,
- PDSCH_CONFIG_DEDICATED *pdsch_config_dedicated,
- uint8_t beamforming_mode,
- uint8_t dci_fields_sizes[NBR_NR_DCI_FIELDS][NBR_NR_FORMATS],
- uint16_t n_RB_ULBWP,
- uint16_t n_RB_DLBWP,
- uint16_t crc_scrambled_values[TOTAL_NBR_SCRAMBLED_VALUES],
- NR_DCI_INFO_EXTRACTED_t *nr_dci_info_extracted);
-*/
-
#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
-
-#if 0
-void nr_dump_dlsch(PHY_VARS_NR_UE *ue,UE_nr_rxtx_proc_t *proc,uint8_t eNB_id,uint8_t nr_tti_rx,uint8_t harq_pid)
-{
- unsigned int coded_bits_per_codeword;
- uint8_t nsymb = (ue->frame_parms.Ncp == 0) ? 14 : 12;
-
- coded_bits_per_codeword = get_G(&ue->frame_parms,
- ue->dlsch[ue->current_thread_id[nr_tti_rx]][eNB_id][0]->harq_processes[harq_pid]->nb_rb,
- ue->dlsch[ue->current_thread_id[nr_tti_rx]][eNB_id][0]->harq_processes[harq_pid]->rb_alloc_even,
- ue->dlsch[ue->current_thread_id[nr_tti_rx]][eNB_id][0]->harq_processes[harq_pid]->Qm,
- ue->dlsch[ue->current_thread_id[nr_tti_rx]][eNB_id][0]->harq_processes[harq_pid]->Nl,
- ue->pdcch_vars[0%RX_NB_TH][eNB_id]->num_pdcch_symbols,
- proc->frame_rx,
- nr_tti_rx,
- ue->transmission_mode[eNB_id]<7?0:ue->transmission_mode[eNB_id]);
-
- write_output("rxsigF0.m","rxsF0", ue->common_vars.common_vars_rx_data_per_thread[ue->current_thread_id[nr_tti_rx]].rxdataF[0],2*nsymb*ue->frame_parms.ofdm_symbol_size,2,1);
- write_output("rxsigF0_ext.m","rxsF0_ext", ue->pdsch_vars[ue->current_thread_id[nr_tti_rx]][0]->rxdataF_ext[0],2*nsymb*ue->frame_parms.ofdm_symbol_size,1,1);
- write_output("dlsch00_ch0_ext.m","dl00_ch0_ext", ue->pdsch_vars[ue->current_thread_id[nr_tti_rx]][0]->dl_ch_estimates_ext[0],300*nsymb,1,1);
- /*
- write_output("dlsch01_ch0_ext.m","dl01_ch0_ext",pdsch_vars[0]->dl_ch_estimates_ext[1],300*12,1,1);
- write_output("dlsch10_ch0_ext.m","dl10_ch0_ext",pdsch_vars[0]->dl_ch_estimates_ext[2],300*12,1,1);
- write_output("dlsch11_ch0_ext.m","dl11_ch0_ext",pdsch_vars[0]->dl_ch_estimates_ext[3],300*12,1,1);
- write_output("dlsch_rho.m","dl_rho",pdsch_vars[0]->rho[0],300*12,1,1);
- */
- write_output("dlsch_rxF_comp0.m","dlsch0_rxF_comp0", ue->pdsch_vars[ue->current_thread_id[nr_tti_rx]][0]->rxdataF_comp0[0],300*12,1,1);
- write_output("dlsch_rxF_llr.m","dlsch_llr", ue->pdsch_vars[ue->current_thread_id[nr_tti_rx]][0]->llr[0],coded_bits_per_codeword,1,0);
-
- write_output("dlsch_mag1.m","dlschmag1",ue->pdsch_vars[ue->current_thread_id[nr_tti_rx]][0]->dl_ch_mag0,300*12,1,1);
- write_output("dlsch_mag2.m","dlschmag2",ue->pdsch_vars[ue->current_thread_id[nr_tti_rx]][0]->dl_ch_magb0,300*12,1,1);
-}
-
-void nr_dump_dlsch_SI(PHY_VARS_NR_UE *ue,UE_nr_rxtx_proc_t *proc,uint8_t eNB_id,uint8_t nr_tti_rx)
-{
- unsigned int coded_bits_per_codeword;
- uint8_t nsymb = ((ue->frame_parms.Ncp == 0) ? 14 : 12);
-
- coded_bits_per_codeword = get_G(&ue->frame_parms,
- ue->dlsch_SI[eNB_id]->harq_processes[0]->nb_rb,
- ue->dlsch_SI[eNB_id]->harq_processes[0]->rb_alloc_even,
- 2,
- 1,
- ue->pdcch_vars[0%RX_NB_TH][eNB_id]->num_pdcch_symbols,
- proc->frame_rx,
- nr_tti_rx,
- 0);
- LOG_D(PHY,"[UE %d] Dumping dlsch_SI : ofdm_symbol_size %d, nsymb %d, nb_rb %d, mcs %d, nb_rb %d, num_pdcch_symbols %d,G %d\n",
- ue->Mod_id,
- ue->frame_parms.ofdm_symbol_size,
- nsymb,
- ue->dlsch_SI[eNB_id]->harq_processes[0]->nb_rb,
- ue->dlsch_SI[eNB_id]->harq_processes[0]->mcs,
- ue->dlsch_SI[eNB_id]->harq_processes[0]->nb_rb,
- ue->pdcch_vars[0%RX_NB_TH][eNB_id]->num_pdcch_symbols,
- coded_bits_per_codeword);
-
- write_output("rxsig0.m","rxs0", &ue->common_vars.rxdata[0][nr_tti_rx*ue->frame_parms.samples_per_tti],ue->frame_parms.samples_per_tti,1,1);
-
- write_output("rxsigF0.m","rxsF0", ue->common_vars.common_vars_rx_data_per_thread[ue->current_thread_id[nr_tti_rx]].rxdataF[0],nsymb*ue->frame_parms.ofdm_symbol_size,1,1);
- write_output("rxsigF0_ext.m","rxsF0_ext", ue->pdsch_vars_SI[0]->rxdataF_ext[0],2*nsymb*ue->frame_parms.ofdm_symbol_size,1,1);
- write_output("dlsch00_ch0_ext.m","dl00_ch0_ext", ue->pdsch_vars_SI[0]->dl_ch_estimates_ext[0],ue->frame_parms.N_RB_DL*12*nsymb,1,1);
- /*
- write_output("dlsch01_ch0_ext.m","dl01_ch0_ext",pdsch_vars[0]->dl_ch_estimates_ext[1],300*12,1,1);
- write_output("dlsch10_ch0_ext.m","dl10_ch0_ext",pdsch_vars[0]->dl_ch_estimates_ext[2],300*12,1,1);
- write_output("dlsch11_ch0_ext.m","dl11_ch0_ext",pdsch_vars[0]->dl_ch_estimates_ext[3],300*12,1,1);
- write_output("dlsch_rho.m","dl_rho",pdsch_vars[0]->rho[0],300*12,1,1);
- */
- write_output("dlsch_rxF_comp0.m","dlsch0_rxF_comp0", ue->pdsch_vars_SI[0]->rxdataF_comp0[0],ue->frame_parms.N_RB_DL*12*nsymb,1,1);
- write_output("dlsch_rxF_llr.m","dlsch_llr", ue->pdsch_vars_SI[0]->llr[0],coded_bits_per_codeword,1,0);
-
- write_output("dlsch_mag1.m","dlschmag1",ue->pdsch_vars_SI[0]->dl_ch_mag0,300*nsymb,1,1);
- write_output("dlsch_mag2.m","dlschmag2",ue->pdsch_vars_SI[0]->dl_ch_magb0,300*nsymb,1,1);
- sleep(1);
- exit(-1);
-}
-
-#endif
-
unsigned int gain_table[31] = {100,112,126,141,158,178,200,224,251,282,316,359,398,447,501,562,631,708,794,891,1000,1122,1258,1412,1585,1778,1995,2239,2512,2818,3162};
int get_tx_amp_prach(int power_dBm, int power_max_dBm, int N_RB_UL){
@@ -236,873 +128,6 @@ int get_tx_amp_prach(int power_dBm, int power_max_dBm, int N_RB_UL){
return (amp_x_100);
}
-#if 0
-
-void nr_dump_dlsch_ra(PHY_VARS_NR_UE *ue,UE_nr_rxtx_proc_t *proc,uint8_t eNB_id,uint8_t nr_tti_rx)
-{
- unsigned int coded_bits_per_codeword;
- uint8_t nsymb = ((ue->frame_parms.Ncp == 0) ? 14 : 12);
-
- coded_bits_per_codeword = get_G(&ue->frame_parms,
- ue->dlsch_ra[eNB_id]->harq_processes[0]->nb_rb,
- ue->dlsch_ra[eNB_id]->harq_processes[0]->rb_alloc_even,
- 2,
- 1,
- ue->pdcch_vars[0%RX_NB_TH][eNB_id]->num_pdcch_symbols,
- proc->frame_rx,
- nr_tti_rx,
- 0);
- LOG_D(PHY,"[UE %d] Dumping dlsch_ra : nb_rb %d, mcs %d, nb_rb %d, num_pdcch_symbols %d,G %d\n",
- ue->Mod_id,
- ue->dlsch_ra[eNB_id]->harq_processes[0]->nb_rb,
- ue->dlsch_ra[eNB_id]->harq_processes[0]->mcs,
- ue->dlsch_ra[eNB_id]->harq_processes[0]->nb_rb,
- ue->pdcch_vars[0%RX_NB_TH][eNB_id]->num_pdcch_symbols,
- coded_bits_per_codeword);
-
- write_output("rxsigF0.m","rxsF0", ue->common_vars.common_vars_rx_data_per_thread[ue->current_thread_id[nr_tti_rx]].rxdataF[0],2*12*ue->frame_parms.ofdm_symbol_size,2,1);
- write_output("rxsigF0_ext.m","rxsF0_ext", ue->pdsch_vars_ra[0]->rxdataF_ext[0],2*12*ue->frame_parms.ofdm_symbol_size,1,1);
- write_output("dlsch00_ch0_ext.m","dl00_ch0_ext", ue->pdsch_vars_ra[0]->dl_ch_estimates_ext[0],300*nsymb,1,1);
- /*
- write_output("dlsch01_ch0_ext.m","dl01_ch0_ext",pdsch_vars[0]->dl_ch_estimates_ext[1],300*12,1,1);
- write_output("dlsch10_ch0_ext.m","dl10_ch0_ext",pdsch_vars[0]->dl_ch_estimates_ext[2],300*12,1,1);
- write_output("dlsch11_ch0_ext.m","dl11_ch0_ext",pdsch_vars[0]->dl_ch_estimates_ext[3],300*12,1,1);
- write_output("dlsch_rho.m","dl_rho",pdsch_vars[0]->rho[0],300*12,1,1);
- */
- write_output("dlsch_rxF_comp0.m","dlsch0_rxF_comp0", ue->pdsch_vars_ra[0]->rxdataF_comp0[0],300*nsymb,1,1);
- write_output("dlsch_rxF_llr.m","dlsch_llr", ue->pdsch_vars_ra[0]->llr[0],coded_bits_per_codeword,1,0);
-
- write_output("dlsch_mag1.m","dlschmag1",ue->pdsch_vars_ra[0]->dl_ch_mag0,300*nsymb,1,1);
- write_output("dlsch_mag2.m","dlschmag2",ue->pdsch_vars_ra[0]->dl_ch_magb0,300*nsymb,1,1);
-}
-
-uint8_t nr_is_SR_TXOp(PHY_VARS_NR_UE *ue,UE_nr_rxtx_proc_t *proc,uint8_t eNB_id)
-{
-
- int nr_tti_tx=proc->nr_tti_tx;
-
- LOG_D(PHY,"[UE %d][SR %x] Frame %d nr_tti_tx %d Checking for SR TXOp (sr_ConfigIndex %d)\n",
- ue->Mod_id,ue->pdcch_vars[ue->current_thread_id[proc->nr_tti_rx]][eNB_id]->crnti,proc->frame_tx,nr_tti_tx,
- ue->scheduling_request_config[eNB_id].sr_ConfigIndex);
-
- if (ue->scheduling_request_config[eNB_id].sr_ConfigIndex <= 4) { // 5 ms SR period
- if ((nr_tti_tx%5) == ue->scheduling_request_config[eNB_id].sr_ConfigIndex)
- return(1);
- } else if (ue->scheduling_request_config[eNB_id].sr_ConfigIndex <= 14) { // 10 ms SR period
- if (nr_tti_tx==(ue->scheduling_request_config[eNB_id].sr_ConfigIndex-5))
- return(1);
- } else if (ue->scheduling_request_config[eNB_id].sr_ConfigIndex <= 34) { // 20 ms SR period
- if ((10*(proc->frame_tx&1)+nr_tti_tx) == (ue->scheduling_request_config[eNB_id].sr_ConfigIndex-15))
- return(1);
- } else if (ue->scheduling_request_config[eNB_id].sr_ConfigIndex <= 74) { // 40 ms SR period
- if ((10*(proc->frame_tx&3)+nr_tti_tx) == (ue->scheduling_request_config[eNB_id].sr_ConfigIndex-35))
- return(1);
- } else if (ue->scheduling_request_config[eNB_id].sr_ConfigIndex <= 154) { // 80 ms SR period
- if ((10*(proc->frame_tx&7)+nr_tti_tx) == (ue->scheduling_request_config[eNB_id].sr_ConfigIndex-75))
- return(1);
- }
-
- return(0);
-}
-
-uint8_t is_cqi_TXOp(PHY_VARS_NR_UE *ue,UE_nr_rxtx_proc_t *proc,uint8_t eNB_id)
-{
- int nr_tti_tx = proc->nr_tti_tx;
- int frame = proc->frame_tx;
- CQI_REPORTPERIODIC *cqirep = &ue->cqi_report_config[eNB_id].CQI_ReportPeriodic;
-
- //LOG_I(PHY,"[UE %d][CRNTI %x] AbsSubFrame %d.%d Checking for CQI TXOp (cqi_ConfigIndex %d) isCQIOp %d\n",
- // ue->Mod_id,ue->pdcch_vars[eNB_id]->crnti,frame,nr_tti_rx,
- // cqirep->cqi_PMI_ConfigIndex,
- // (((10*frame + nr_tti_tx) % cqirep->Npd) == cqirep->N_OFFSET_CQI));
-
- if (cqirep->cqi_PMI_ConfigIndex==-1)
- return(0);
- else if (((10*frame + nr_tti_tx) % cqirep->Npd) == cqirep->N_OFFSET_CQI)
- return(1);
- else
- return(0);
-}
-uint8_t is_ri_TXOp(PHY_VARS_NR_UE *ue,UE_nr_rxtx_proc_t *proc,uint8_t eNB_id)
-{
-
-
- int nr_tti_tx = proc->nr_tti_tx;
- int frame = proc->frame_tx;
- CQI_REPORTPERIODIC *cqirep = &ue->cqi_report_config[eNB_id].CQI_ReportPeriodic;
- int log2Mri = cqirep->ri_ConfigIndex/161;
- int N_OFFSET_RI = cqirep->ri_ConfigIndex % 161;
-
- //LOG_I(PHY,"[UE %d][CRNTI %x] AbsSubFrame %d.%d Checking for RI TXOp (ri_ConfigIndex %d) isRIOp %d\n",
- // ue->Mod_id,ue->pdcch_vars[eNB_id]->crnti,frame,nr_tti_tx,
- // cqirep->ri_ConfigIndex,
- // (((10*frame + nr_tti_tx + cqirep->N_OFFSET_CQI - N_OFFSET_RI) % (cqirep->Npd<ri_ConfigIndex==-1)
- return(0);
- else if (((10*frame + nr_tti_tx + cqirep->N_OFFSET_CQI - N_OFFSET_RI) % (cqirep->Npd<measurements;
- //uint8_t transmission_mode = ue->transmission_mode[eNB_id];
-
-
- //LOG_I(PHY,"compute_cqi_ri_resources O_RI %d O %d uci format %d \n",ulsch->O_RI,ulsch->O,ulsch->uci_format);
- if (cqi_status == 1 || ri_status == 1)
- {
- ulsch->O = 4;
- }
-}
-
-void ue_compute_srs_occasion(PHY_VARS_NR_UE *ue,UE_nr_rxtx_proc_t *proc,uint8_t eNB_id,uint8_t isSubframeSRS)
-{
-
- NR_DL_FRAME_PARMS *frame_parms = &ue->frame_parms;
- int frame_tx = proc->frame_tx;
- int nr_tti_tx = proc->nr_tti_tx;
- SOUNDINGRS_UL_CONFIG_DEDICATED *pSoundingrs_ul_config_dedicated=&ue->soundingrs_ul_config_dedicated[eNB_id];
- uint16_t srsPeriodicity;
- uint16_t srsOffset;
- uint8_t is_pucch2_subframe = 0;
- uint8_t is_sr_an_subframe = 0;
-
- // check for SRS opportunity
- pSoundingrs_ul_config_dedicated->srsUeSubframe = 0;
- pSoundingrs_ul_config_dedicated->srsCellSubframe = isSubframeSRS;
-
- if (isSubframeSRS) {
- LOG_D(PHY," SrsDedicatedSetup: %d \n",pSoundingrs_ul_config_dedicated->srsConfigDedicatedSetup);
- if(pSoundingrs_ul_config_dedicated->srsConfigDedicatedSetup)
- {
- nr_compute_srs_pos(frame_parms->frame_type, pSoundingrs_ul_config_dedicated->srs_ConfigIndex, &srsPeriodicity, &srsOffset);
-
- LOG_D(PHY," srsPeriodicity: %d srsOffset: %d isSubframeSRS %d \n",srsPeriodicity,srsOffset,isSubframeSRS);
-
- // transmit SRS if the four following constraints are respected:
- // - UE is configured to transmit SRS
- // - SRS are configured in current nr_tti_rx
- // - UE is configured to send SRS in this nr_tti_tx
-
- // 36.213 8.2
- // 1- A UE shall not transmit SRS whenever SRS and PUCCH format 2/2a/2b transmissions happen to coincide in the same nr_tti_rx
- // 2- A UE shall not transmit SRS whenever SRS transmit
- // on and PUCCH transmission carrying ACK/NACK and/or
- // positive SR happen to coincide in the same nr_tti_rx if the parameter
- // Simultaneous-AN-and-SRS is FALSE
-
- // check PUCCH format 2/2a/2b transmissions
- is_pucch2_subframe = nr_is_cqi_TXOp(ue,proc,eNB_id) && (ue->cqi_report_config[eNB_id].CQI_ReportPeriodic.cqi_PMI_ConfigIndex>0);
- is_pucch2_subframe = (nr_is_ri_TXOp(ue,proc,eNB_id) && (ue->cqi_report_config[eNB_id].CQI_ReportPeriodic.ri_ConfigIndex>0)) || is_pucch2_subframe;
-
- // check ACK/SR transmission
- if(frame_parms->soundingrs_ul_config_common.ackNackSRS_SimultaneousTransmission == FALSE)
- {
- if(nr_is_SR_TXOp(ue,proc,eNB_id))
- {
- uint32_t SR_payload = 0;
- if (ue->mac_enabled==1)
- {
- int Mod_id = ue->Mod_id;
- int CC_id = ue->CC_id;
- SR_payload = mac_xface->ue_get_SR(Mod_id,
- CC_id,
- frame_tx,
- eNB_id,
- ue->pdcch_vars[ue->current_thread_id[proc->nr_tti_rx]][eNB_id]->crnti,
- nr_tti_tx); // nr_tti_tx used for meas gap
-
- if (SR_payload > 0)
- is_sr_an_subframe = 1;
- }
- }
-
- uint8_t pucch_ack_payload[2];
- if (nr_get_ack(&ue->frame_parms,
- ue->dlsch[ue->current_thread_id[proc->nr_tti_rx]][eNB_id][0]->harq_ack,
- nr_tti_tx,proc->nr_tti_rx,pucch_ack_payload,0) > 0)
- {
- is_sr_an_subframe = 1;
- }
- }
-
- // check SRS UE opportunity
- if( isSubframeSRS &&
- (((10*frame_tx+nr_tti_tx) % srsPeriodicity) == srsOffset)
- )
- {
- if ((is_pucch2_subframe == 0) && (is_sr_an_subframe == 0))
- {
- pSoundingrs_ul_config_dedicated->srsUeSubframe = 1;
- ue->ulsch[eNB_id]->srs_active = 1;
- ue->ulsch[eNB_id]->Nsymb_pusch = 12-(frame_parms->Ncp<<1)- ue->ulsch[eNB_id]->srs_active;
- }
- else
- {
- LOG_I(PHY,"DROP UE-SRS-TX for this nr_tti_tx %d.%d: collision with PUCCH2 or SR/AN: PUCCH2-occasion: %d, SR-AN-occasion[simSRS-SR-AN %d]: %d \n", frame_tx, nr_tti_tx, is_pucch2_subframe, frame_parms->soundingrs_ul_config_common.ackNackSRS_SimultaneousTransmission, is_sr_an_subframe);
- }
- }
- }
- LOG_D(PHY," srsCellSubframe: %d, srsUeSubframe: %d, Nsymb-pusch: %d \n", pSoundingrs_ul_config_dedicated->srsCellSubframe, pSoundingrs_ul_config_dedicated->srsUeSubframe, ue->ulsch[eNB_id]->Nsymb_pusch);
- }
-}
-
-
-void nr_get_cqipmiri_params(PHY_VARS_NR_UE *ue,uint8_t eNB_id)
-{
-
- CQI_REPORTPERIODIC *cqirep = &ue->cqi_report_config[eNB_id].CQI_ReportPeriodic;
- int cqi_PMI_ConfigIndex = cqirep->cqi_PMI_ConfigIndex;
-
- if (ue->frame_parms.frame_type == FDD) {
- if (cqi_PMI_ConfigIndex <= 1) { // 2 ms CQI_PMI period
- cqirep->Npd = 2;
- cqirep->N_OFFSET_CQI = cqi_PMI_ConfigIndex;
- } else if (cqi_PMI_ConfigIndex <= 6) { // 5 ms CQI_PMI period
- cqirep->Npd = 5;
- cqirep->N_OFFSET_CQI = cqi_PMI_ConfigIndex-2;
- } else if (cqi_PMI_ConfigIndex <=16) { // 10ms CQI_PMI period
- cqirep->Npd = 10;
- cqirep->N_OFFSET_CQI = cqi_PMI_ConfigIndex-7;
- } else if (cqi_PMI_ConfigIndex <= 36) { // 20 ms CQI_PMI period
- cqirep->Npd = 20;
- cqirep->N_OFFSET_CQI = cqi_PMI_ConfigIndex-17;
- } else if (cqi_PMI_ConfigIndex <= 76) { // 40 ms CQI_PMI period
- cqirep->Npd = 40;
- cqirep->N_OFFSET_CQI = cqi_PMI_ConfigIndex-37;
- } else if (cqi_PMI_ConfigIndex <= 156) { // 80 ms CQI_PMI period
- cqirep->Npd = 80;
- cqirep->N_OFFSET_CQI = cqi_PMI_ConfigIndex-77;
- } else if (cqi_PMI_ConfigIndex <= 316) { // 160 ms CQI_PMI period
- cqirep->Npd = 160;
- cqirep->N_OFFSET_CQI = cqi_PMI_ConfigIndex-157;
- }
- else if (cqi_PMI_ConfigIndex > 317) {
-
- if (cqi_PMI_ConfigIndex <= 349) { // 32 ms CQI_PMI period
- cqirep->Npd = 32;
- cqirep->N_OFFSET_CQI = cqi_PMI_ConfigIndex-318;
- }
- else if (cqi_PMI_ConfigIndex <= 413) { // 64 ms CQI_PMI period
- cqirep->Npd = 64;
- cqirep->N_OFFSET_CQI = cqi_PMI_ConfigIndex-350;
- }
- else if (cqi_PMI_ConfigIndex <= 541) { // 128 ms CQI_PMI period
- cqirep->Npd = 128;
- cqirep->N_OFFSET_CQI = cqi_PMI_ConfigIndex-414;
- }
- }
- }
- else { // TDD
- if (cqi_PMI_ConfigIndex == 0) { // all UL subframes
- cqirep->Npd = 1;
- cqirep->N_OFFSET_CQI = 0;
- } else if (cqi_PMI_ConfigIndex <= 6) { // 5 ms CQI_PMI period
- cqirep->Npd = 5;
- cqirep->N_OFFSET_CQI = cqi_PMI_ConfigIndex-1;
- } else if (cqi_PMI_ConfigIndex <=16) { // 10ms CQI_PMI period
- cqirep->Npd = 10;
- cqirep->N_OFFSET_CQI = cqi_PMI_ConfigIndex-6;
- } else if (cqi_PMI_ConfigIndex <= 36) { // 20 ms CQI_PMI period
- cqirep->Npd = 20;
- cqirep->N_OFFSET_CQI = cqi_PMI_ConfigIndex-16;
- } else if (cqi_PMI_ConfigIndex <= 76) { // 40 ms CQI_PMI period
- cqirep->Npd = 40;
- cqirep->N_OFFSET_CQI = cqi_PMI_ConfigIndex-36;
- } else if (cqi_PMI_ConfigIndex <= 156) { // 80 ms CQI_PMI period
- cqirep->Npd = 80;
- cqirep->N_OFFSET_CQI = cqi_PMI_ConfigIndex-76;
- } else if (cqi_PMI_ConfigIndex <= 316) { // 160 ms CQI_PMI period
- cqirep->Npd = 160;
- cqirep->N_OFFSET_CQI = cqi_PMI_ConfigIndex-156;
- }
- }
-}
-
-PUCCH_FMT_t get_pucch_format(lte_frame_type_t frame_type,
- lte_prefix_type_t cyclic_prefix_type,
- uint8_t SR_payload,
- uint8_t nb_cw,
- uint8_t cqi_status,
- uint8_t ri_status,
- uint8_t bundling_flag)
-{
- if((cqi_status == 0) && (ri_status==0))
- {
- // PUCCH Format 1 1a 1b
- // 1- SR only ==> PUCCH format 1
- // 2- 1bit Ack/Nack with/without SR ==> PUCCH format 1a
- // 3- 2bits Ack/Nack with/without SR ==> PUCCH format 1b
- if((nb_cw == 1)&&(bundling_flag==bundling))
- {
- return pucch_format1a;
- }
- if((nb_cw == 1)&&(bundling_flag==multiplexing))
- {
- return pucch_format1b;
- }
- if(nb_cw == 2)
- {
- return pucch_format1b;
- }
- if(SR_payload == 1)
- {
- return pucch_format1;
- /*
- if (frame_type == FDD) {
- return pucch_format1;
- } else if (frame_type == TDD) {
- return pucch_format1b;
- } else {
- AssertFatal(1==0,"Unknown frame_type");
- }*/
- }
- }
- else
- {
- // PUCCH Format 2 2a 2b
- // 1- CQI only or RI only ==> PUCCH format 2
- // 2- CQI or RI + 1bit Ack/Nack for normal CP ==> PUCCH format 2a
- // 3- CQI or RI + 2bits Ack/Nack for normal CP ==> PUCCH format 2b
- // 4- CQI or RI + Ack/Nack for extended CP ==> PUCCH format 2
- if(nb_cw == 0)
- {
- return pucch_format2;
- }
- if(cyclic_prefix_type == NORMAL)
- {
- if(nb_cw == 1)
- {
- return pucch_format2a;
- }
- if(nb_cw == 2)
- {
- return pucch_format2b;
- }
- }
- else
- {
- return pucch_format2;
- }
- }
- return pucch_format1a;
-}
-
-uint16_t nr_get_n1_pucch(PHY_VARS_NR_UE *ue,
- UE_nr_rxtx_proc_t *proc,
- nr_harq_status_t *harq_ack,
- uint8_t eNB_id,
- uint8_t *b,
- uint8_t SR)
-{
-
- NR_DL_FRAME_PARMS *frame_parms=&ue->frame_parms;
- uint8_t nCCE0,nCCE1,nCCE2,nCCE3,harq_ack1,harq_ack0,harq_ack3,harq_ack2;
- ANFBmode_t bundling_flag;
- uint16_t n1_pucch0=0,n1_pucch1=0,n1_pucch2=0,n1_pucch3=0,n1_pucch_inter;
- static uint8_t candidate_dl[9]; // which downlink(s) the current ACK/NACK is associating to
- uint8_t last_dl=0xff; // the last downlink with valid DL-DCI. for calculating the PUCCH resource index
- int sf;
- int M;
- uint8_t ack_counter=0;
- // clear this, important for case where n1_pucch selection is not used
- int nr_tti_tx=proc->nr_tti_tx;
-
- ue->pucch_sel[nr_tti_tx] = 0;
-
- if (frame_parms->frame_type == FDD ) { // FDD
- sf = (nr_tti_tx<4)? nr_tti_tx+6 : nr_tti_tx-4;
- LOG_D(PHY,"n1_pucch_UE: nr_tti_tx %d, nCCE %d\n",sf,ue->pdcch_vars[ue->current_thread_id[proc->nr_tti_rx]][eNB_id]->nCCE[sf]);
-
- if (SR == 0)
- return(frame_parms->pucch_config_common.n1PUCCH_AN + ue->pdcch_vars[ue->current_thread_id[proc->nr_tti_rx]][eNB_id]->nCCE[sf]);
- else
- return(ue->scheduling_request_config[eNB_id].sr_PUCCH_ResourceIndex);
- } else {
-
- bundling_flag = ue->pucch_config_dedicated[eNB_id].tdd_AckNackFeedbackMode;
-#ifdef DEBUG_PHY_PROC
-
- if (bundling_flag==bundling) {
- LOG_D(PHY,"[UE%d] Frame %d nr_tti_tx %d : nr_get_n1_pucch, bundling, SR %d/%d\n",ue->Mod_id,proc->frame_tx,nr_tti_tx,SR,
- ue->scheduling_request_config[eNB_id].sr_PUCCH_ResourceIndex);
- } else {
- LOG_D(PHY,"[UE%d] Frame %d nr_tti_tx %d : nr_get_n1_pucch, multiplexing, SR %d/%d\n",ue->Mod_id,proc->frame_tx,nr_tti_tx,SR,
- ue->scheduling_request_config[eNB_id].sr_PUCCH_ResourceIndex);
- }
-
-#endif
-
- switch (frame_parms->tdd_config) {
- case 1: // DL:S:UL:UL:DL:DL:S:UL:UL:DL
-
- harq_ack0 = 2; // DTX
- M=1;
-
- // This is the offset for a particular nr_tti_tx (2,3,4) => (0,2,4)
- if (nr_tti_tx == 2) { // ACK nr_tti_txs 5,6
- candidate_dl[0] = 6;
- candidate_dl[1] = 5;
- M=2;
- } else if (nr_tti_tx == 3) { // ACK nr_tti_tx 9
- candidate_dl[0] = 9;
- } else if (nr_tti_tx == 7) { // ACK nr_tti_txs 0,1
- candidate_dl[0] = 1;
- candidate_dl[1] = 0;
- M=2;
- } else if (nr_tti_tx == 8) { // ACK nr_tti_txs 4
- candidate_dl[0] = 4;
- } else {
- LOG_E(PHY,"[UE%d] : Frame %d phy_procedures_lte.c: get_n1pucch, illegal tx-nr_tti_tx %d for tdd_config %d\n",
- ue->Mod_id,proc->frame_tx,nr_tti_tx,frame_parms->tdd_config);
- return(0);
- }
-
- // checking which downlink candidate is the last downlink with valid DL-DCI
- int k;
- for (k=0;k0) {
- last_dl = candidate_dl[k];
- break;
- }
- }
- if (last_dl >= 10) {
- LOG_E(PHY,"[UE%d] : Frame %d phy_procedures_lte.c: get_n1pucch, illegal rx-nr_tti_tx %d (tx-nr_tti_tx %d) for tdd_config %d\n",
- ue->Mod_id,proc->frame_tx,last_dl,nr_tti_tx,frame_parms->tdd_config);
- return (0);
- }
-
- LOG_D(PHY,"SFN/SF %d/%d calculating n1_pucch0 from last_dl=%d\n",
- proc->frame_tx%1024,
- proc->nr_tti_tx,
- last_dl);
-
- // i=0
- nCCE0 = ue->pdcch_vars[ue->current_thread_id[proc->nr_tti_rx]][eNB_id]->nCCE[last_dl];
- n1_pucch0 = nr_get_Np(frame_parms->N_RB_DL,nCCE0,0) + nCCE0+ frame_parms->pucch_config_common.n1PUCCH_AN;
-
- harq_ack0 = b[0];
-
- if (harq_ack0!=2) { // DTX
- if (frame_parms->frame_type == FDD ) {
- if (SR == 0) { // last paragraph pg 68 from 36.213 (v8.6), m=0
- b[0]=(M==2) ? 1-harq_ack0 : harq_ack0;
- b[1]=harq_ack0; // in case we use pucch format 1b (subframes 2,7)
- ue->pucch_sel[nr_tti_tx] = 0;
- return(n1_pucch0);
- } else { // SR and only 0 or 1 ACKs (first 2 entries in Table 7.3-1 of 36.213)
- b[0]=harq_ack0;
- return(ue->scheduling_request_config[eNB_id].sr_PUCCH_ResourceIndex);
- }
- } else {
- if (SR == 0) {
- b[0] = harq_ack0;
- b[1] = harq_ack0;
- ue->pucch_sel[nr_tti_tx] = 0;
- return(n1_pucch0);
- } else {
- b[0] = harq_ack0;
- b[1] = harq_ack0;
- return(ue->scheduling_request_config[eNB_id].sr_PUCCH_ResourceIndex);
- }
- }
- }
-
-
- break;
-
- case 3: // DL:S:UL:UL:UL:DL:DL:DL:DL:DL
- // in this configuration we have M=2 from pg 68 of 36.213 (v8.6)
- // Note: this doesn't allow using nr_tti_tx 1 for PDSCH transmission!!! (i.e. SF 1 cannot be acked in SF 2)
- // set ACK/NAKs to DTX
- harq_ack1 = 2; // DTX
- harq_ack0 = 2; // DTX
- // This is the offset for a particular nr_tti_rx (2,3,4) => (0,2,4)
- last_dl = (nr_tti_tx-2)<<1;
- // i=0
- nCCE0 = ue->pdcch_vars[ue->current_thread_id[proc->nr_tti_rx]][eNB_id]->nCCE[5+last_dl];
- n1_pucch0 = nr_get_Np(frame_parms->N_RB_DL,nCCE0,0) + nCCE0+ frame_parms->pucch_config_common.n1PUCCH_AN;
- // i=1
- nCCE1 = ue->pdcch_vars[ue->current_thread_id[proc->nr_tti_rx]][eNB_id]->nCCE[(6+last_dl)%10];
- n1_pucch1 = nr_get_Np(frame_parms->N_RB_DL,nCCE1,1) + nCCE1 + frame_parms->pucch_config_common.n1PUCCH_AN;
-
- // set ACK/NAK to values if not DTX
- if (ue->dlsch[ue->current_thread_id[proc->nr_tti_rx]][eNB_id][0]->harq_ack[(6+last_dl)%10].send_harq_status>0) // n-6 // nr_tti_tx 6 is to be ACK/NAKed
- harq_ack1 = ue->dlsch[ue->current_thread_id[proc->nr_tti_rx]][eNB_id][0]->harq_ack[(6+last_dl)%10].ack;
-
- if (ue->dlsch[ue->current_thread_id[proc->nr_tti_rx]][eNB_id][0]->harq_ack[5+last_dl].send_harq_status>0) // n-6 // nr_tti_tx 5 is to be ACK/NAKed
- harq_ack0 = ue->dlsch[ue->current_thread_id[proc->nr_tti_rx]][eNB_id][0]->harq_ack[5+last_dl].ack;
-
- LOG_D(PHY,"SFN/SF %d/%d calculating n1_pucch cce0=%d n1_pucch0=%d cce1=%d n1_pucch1=%d\n",
- proc->frame_tx%1024,
- proc->nr_tti_tx,
- nCCE0,n1_pucch0,
- nCCE1,n1_pucch1);
-
- if (harq_ack1!=2) { // n-6 // nr_tti_tx 6,8,0 and maybe 5,7,9 is to be ACK/NAKed
-
- if ((bundling_flag==bundling)&&(SR == 0)) { // This is for bundling without SR,
- // n1_pucch index takes value of smallest element in set {0,1}
- // i.e. 0 if harq_ack0 is not DTX, otherwise 1
- b[0] = harq_ack1;
-
- if (harq_ack0!=2)
- b[0]=b[0]&harq_ack0;
-
- ue->pucch_sel[nr_tti_tx] = 1;
- return(n1_pucch1);
-
- } else if ((bundling_flag==multiplexing)&&(SR==0)) { // Table 10.1
- if (harq_ack0 == 2)
- harq_ack0 = 0;
-
- b[1] = harq_ack0;
- b[0] = (harq_ack0!=harq_ack1)?0:1;
-
- if ((harq_ack0 == 1) && (harq_ack1 == 0)) {
- ue->pucch_sel[nr_tti_tx] = 0;
- return(n1_pucch0);
- } else {
- ue->pucch_sel[nr_tti_tx] = 1;
- return(n1_pucch1);
- }
- } else if (SR==1) { // SR and 0,1,or 2 ACKS, (first 3 entries in Table 7.3-1 of 36.213)
- // this should be number of ACKs (including
- if (harq_ack0 == 2)
- harq_ack0 = 0;
-
- b[0]= harq_ack1 | harq_ack0;
- b[1]= harq_ack1 ^ harq_ack0;
- return(ue->scheduling_request_config[eNB_id].sr_PUCCH_ResourceIndex);
- }
- } else if (harq_ack0!=2) { // n-7 // nr_tti_tx 5,7,9 only is to be ACK/NAKed
- if ((bundling_flag==bundling)&&(SR == 0)) { // last paragraph pg 68 from 36.213 (v8.6), m=0
- b[0]=harq_ack0;
- ue->pucch_sel[nr_tti_tx] = 0;
- return(n1_pucch0);
- } else if ((bundling_flag==multiplexing)&&(SR==0)) { // Table 10.1 with i=1 set to DTX
- b[0] = harq_ack0;
- b[1] = 1-b[0];
- ue->pucch_sel[nr_tti_tx] = 0;
- return(n1_pucch0);
- } else if (SR==1) { // SR and only 0 or 1 ACKs (first 2 entries in Table 7.3-1 of 36.213)
- b[0]=harq_ack0;
- b[1]=b[0];
- return(ue->scheduling_request_config[eNB_id].sr_PUCCH_ResourceIndex);
- }
- }
-
- break;
-
- case 4: // DL:S:UL:UL:DL:DL:DL:DL:DL:DL
- // in this configuration we have M=4 from pg 68 of 36.213 (v8.6)
- // Note: this doesn't allow using nr_tti_tx 1 for PDSCH transmission!!! (i.e. SF 1 cannot be acked in SF 2)
- // set ACK/NAKs to DTX
- harq_ack3 = 2; // DTX
- harq_ack2 = 2; // DTX
- harq_ack1 = 2; // DTX
- harq_ack0 = 2; // DTX
- // This is the offset for a particular nr_tti_tx (2,3,4) => (0,2,4)
- //last_dl = (nr_tti_tx-2)<<1;
- if (nr_tti_tx == 2) {
- // i=0
- //nCCE0 = ue->pdcch_vars[ue->current_thread_id[proc->nr_tti_rx]][eNB_id]->nCCE[2+nr_tti_tx];
- nCCE0 = ue->pdcch_vars[ue->current_thread_id[proc->nr_tti_rx]][eNB_id]->nCCE[(8+nr_tti_tx)%10];
- n1_pucch0 = 2*nr_get_Np(frame_parms->N_RB_DL,nCCE0,0) + nCCE0+ frame_parms->pucch_config_common.n1PUCCH_AN;
- // i=1
- nCCE1 = ue->pdcch_vars[ue->current_thread_id[proc->nr_tti_rx]][eNB_id]->nCCE[2+nr_tti_tx];
- n1_pucch1 = nr_get_Np(frame_parms->N_RB_DL,nCCE1,0) + nr_get_Np(frame_parms->N_RB_DL,nCCE1,1) + nCCE1 + frame_parms->pucch_config_common.n1PUCCH_AN;
- // i=2
- nCCE2 = ue->pdcch_vars[ue->current_thread_id[proc->nr_tti_rx]][eNB_id]->nCCE[(8+nr_tti_tx)%10];
-
- n1_pucch2 = 2*nr_get_Np(frame_parms->N_RB_DL,nCCE2,1) + nCCE2+ frame_parms->pucch_config_common.n1PUCCH_AN;
- // i=3
- //nCCE3 = ue->pdcch_vars[ue->current_thread_id[proc->nr_tti_rx]][eNB_id]->nCCE[(9+nr_tti_tx)%10];
- //n1_pucch3 = nr_get_Np(frame_parms->N_RB_DL,nCCE3,1) + nCCE3 + frame_parms->pucch_config_common.n1PUCCH_AN;
-
- // set ACK/NAK to values if not DTX
- if (ue->dlsch[ue->current_thread_id[proc->nr_tti_rx]][eNB_id][0]->harq_ack[(8+nr_tti_tx)%10].send_harq_status>0) // n-6 // nr_tti_tx 6 is to be ACK/NAKed
- harq_ack0 = ue->dlsch[ue->current_thread_id[proc->nr_tti_rx]][eNB_id][0]->harq_ack[(8+nr_tti_tx)%10].ack;
-
- if (ue->dlsch[ue->current_thread_id[proc->nr_tti_rx]][eNB_id][0]->harq_ack[2+nr_tti_tx].send_harq_status>0) // n-6 // nr_tti_tx 5 is to be ACK/NAKed
- harq_ack1 = ue->dlsch[ue->current_thread_id[proc->nr_tti_rx]][eNB_id][0]->harq_ack[2+nr_tti_tx].ack;
-
- if (ue->dlsch[ue->current_thread_id[proc->nr_tti_rx]][eNB_id][0]->harq_ack[3+nr_tti_tx].send_harq_status>0) // n-6 // nr_tti_tx 6 is to be ACK/NAKed
- harq_ack2 = ue->dlsch[ue->current_thread_id[proc->nr_tti_rx]][eNB_id][0]->harq_ack[3+nr_tti_tx].ack;
-
- //if (ue->dlsch[ue->current_thread_id[proc->nr_tti_rx]][eNB_id][0]->harq_ack[(9+nr_tti_tx)%10].send_harq_status>0) // n-6 // nr_tti_tx 5 is to be ACK/NAKed
- //harq_ack3 = ue->dlsch[ue->current_thread_id[proc->nr_tti_rx]][eNB_id][0]->harq_ack[(9+nr_tti_tx)%10].ack;
- //LOG_I(PHY,"SFN/SF %d/%d calculating n1_pucch cce0=%d n1_pucch0=%d cce1=%d n1_pucch1=%d cce2=%d n1_pucch2=%d\n",
- // proc->frame_tx%1024,
- // proc->nr_tti_tx_tx,
- // nCCE0,n1_pucch0,
- // nCCE1,n1_pucch1, nCCE2, n1_pucch2);
- }else if (nr_tti_tx == 3) {
- // i=0
-
- nCCE0 = ue->pdcch_vars[ue->current_thread_id[proc->nr_tti_rx]][eNB_id]->nCCE[4+nr_tti_tx];
- n1_pucch0 = 3*nr_get_Np(frame_parms->N_RB_DL,nCCE0,0) + nCCE0+ frame_parms->pucch_config_common.n1PUCCH_AN;
- // i=1
- nCCE1 = ue->pdcch_vars[ue->current_thread_id[proc->nr_tti_rx]][eNB_id]->nCCE[5+nr_tti_tx];
- n1_pucch1 = 2*nr_get_Np(frame_parms->N_RB_DL,nCCE1,0) + nr_get_Np(frame_parms->N_RB_DL,nCCE1,1) + nCCE1 + frame_parms->pucch_config_common.n1PUCCH_AN;
- // i=2
- nCCE2 = ue->pdcch_vars[ue->current_thread_id[proc->nr_tti_rx]][eNB_id]->nCCE[(6+nr_tti_tx)];
- n1_pucch2 = nr_get_Np(frame_parms->N_RB_DL,nCCE2,0) + 2*nr_get_Np(frame_parms->N_RB_DL,nCCE2,1) + nCCE2+ frame_parms->pucch_config_common.n1PUCCH_AN;
- // i=3
- nCCE3 = ue->pdcch_vars[ue->current_thread_id[proc->nr_tti_rx]][eNB_id]->nCCE[(3+nr_tti_tx)];
- n1_pucch3 = 3*nr_get_Np(frame_parms->N_RB_DL,nCCE3,1) + nCCE3 + frame_parms->pucch_config_common.n1PUCCH_AN;
-
- // set ACK/NAK to values if not DTX
- if (ue->dlsch[ue->current_thread_id[proc->nr_tti_rx]][eNB_id][0]->harq_ack[4+nr_tti_tx].send_harq_status>0) // n-6 // nr_tti_tx 6 is to be ACK/NAKed
- harq_ack0 = ue->dlsch[ue->current_thread_id[proc->nr_tti_rx]][eNB_id][0]->harq_ack[4+nr_tti_tx].ack;
-
- if (ue->dlsch[ue->current_thread_id[proc->nr_tti_rx]][eNB_id][0]->harq_ack[5+nr_tti_tx].send_harq_status>0) // n-6 // nr_tti_tx 5 is to be ACK/NAKed
- harq_ack1 = ue->dlsch[ue->current_thread_id[proc->nr_tti_rx]][eNB_id][0]->harq_ack[5+nr_tti_tx].ack;
-
- if (ue->dlsch[ue->current_thread_id[proc->nr_tti_rx]][eNB_id][0]->harq_ack[(6+nr_tti_tx)].send_harq_status>0) // n-6 // nr_tti_tx 6 is to be ACK/NAKed
- harq_ack2 = ue->dlsch[ue->current_thread_id[proc->nr_tti_rx]][eNB_id][0]->harq_ack[(6+nr_tti_tx)].ack;
-
- if (ue->dlsch[ue->current_thread_id[proc->nr_tti_rx]][eNB_id][0]->harq_ack[(3+nr_tti_tx)].send_harq_status>0) // n-6 // nr_tti_tx 5 is to be ACK/NAKed
- harq_ack3 = ue->dlsch[ue->current_thread_id[proc->nr_tti_rx]][eNB_id][0]->harq_ack[(3+nr_tti_tx)].ack;
- }
-
- //LOG_I(PHY,"SFN/SF %d/%d calculating n1_pucch cce0=%d n1_pucch0=%d harq_ack0=%d cce1=%d n1_pucch1=%d harq_ack1=%d cce2=%d n1_pucch2=%d harq_ack2=%d cce3=%d n1_pucch3=%d harq_ack3=%d bundling_flag=%d\n",
- // proc->frame_tx%1024,
- // proc->nr_tti_tx,
- // nCCE0,n1_pucch0,harq_ack0,
- // nCCE1,n1_pucch1,harq_ack1, nCCE2, n1_pucch2, harq_ack2,
- // nCCE3, n1_pucch3, harq_ack3, bundling_flag);
-
- if ((bundling_flag==bundling)&&(SR == 0)) { // This is for bundling without SR,
- b[0] = 1;
- ack_counter = 0;
-
- if ((harq_ack3!=2) ) {
- b[0] = b[0]&harq_ack3;
- n1_pucch_inter = n1_pucch3;
- ack_counter ++;
- }
- if ((harq_ack0!=2) ) {
- b[0] = b[0]&harq_ack0;
- n1_pucch_inter = n1_pucch0;
- ack_counter ++;
- }
- if ((harq_ack1!=2) ) {
- b[0] = b[0]&harq_ack1;
- n1_pucch_inter = n1_pucch1;
- ack_counter ++;
- }
- if ((harq_ack2!=2) ) {
- b[0] = b[0]&harq_ack2;
- n1_pucch_inter = n1_pucch2;
- ack_counter ++;
- }
-
- if (ack_counter == 0)
- b[0] = 0;
-
- /*if (nr_tti_tx == 3) {
- n1_pucch_inter = n1_pucch2;
- } else if (nr_tti_tx == 2) {
- n1_pucch_inter = n1_pucch1;
- }*/
-
- //LOG_I(PHY,"SFN/SF %d/%d calculating n1_pucch n1_pucch_inter=%d b[0]=%d b[1]=%d \n",
- // proc->frame_tx%1024,
- // proc->nr_tti_tx,n1_pucch_inter,
- // b[0],b[1]);
-
- return(n1_pucch_inter);
-
- } else if ((bundling_flag==multiplexing)&&(SR==0)) { // Table 10.1
-
- if (nr_tti_tx == 3) {
- LOG_I(PHY, "sbuframe=%d \n",nr_tti_tx);
- if ((harq_ack0 == 1) && (harq_ack1 == 1) && (harq_ack2 == 1) && (harq_ack3 == 1)) {
- b[0] = 1;
- b[1] = 1;
- return(n1_pucch1);
- } else if ((harq_ack0 == 1) && (harq_ack1 == 1) && (harq_ack2 == 1) && ((harq_ack3 == 2) || (harq_ack3 == 0))) {
- b[0] = 1;
- b[1] = 0;
- return(n1_pucch1);
- } else if (((harq_ack0 == 0) || (harq_ack0 == 2)) && ((harq_ack1 == 2) || (harq_ack1 == 0)) && (harq_ack2 == 0) && (harq_ack3 == 2)) {
- b[0] = 1;
- b[1] = 1;
- return(n1_pucch2);
- } else if ((harq_ack0 == 1) && (harq_ack1 == 1) && ((harq_ack2 == 2) || (harq_ack2 == 0)) && (harq_ack3 == 1)) {
- b[0] = 1;
- b[1] = 0;
- return(n1_pucch1);
- } else if ((harq_ack0 == 0) && (harq_ack1 == 2) && (harq_ack2 == 2) && (harq_ack3 == 2)) {
- b[0] = 1;
- b[1] = 0;
- return(n1_pucch0);
- } else if ((harq_ack0 == 1) && (harq_ack1 == 1) && ((harq_ack2 == 2) || (harq_ack2 == 0)) && ((harq_ack3 == 2) || (harq_ack3 == 0))) {
- b[0] = 1;
- b[1] = 0;
- return(n1_pucch1);
- } else if ((harq_ack0 == 1) && ((harq_ack1 == 2) || (harq_ack1 == 0)) && (harq_ack2 == 1) && (harq_ack3 == 1)) {
- b[0] = 0;
- b[1] = 1;
- return(n1_pucch3);
- } else if (((harq_ack0 == 0) || (harq_ack0 == 2)) && ((harq_ack1 == 2) || (harq_ack1 == 0)) && ((harq_ack2 == 2) || (harq_ack2 == 0)) && (harq_ack3 == 0)) {
- b[0] = 1;
- b[1] = 1;
- return(n1_pucch3);
- } else if ((harq_ack0 == 1) && ((harq_ack1 == 2) || (harq_ack1 == 0)) && (harq_ack2 == 1) && ((harq_ack3 == 2) || (harq_ack3 == 0))) {
- b[0] = 0;
- b[1] = 1;
- return(n1_pucch2);
- } else if ((harq_ack0 == 1) && ((harq_ack1 == 2) || (harq_ack1 == 0)) && ((harq_ack2 == 2) || (harq_ack2 == 0)) && (harq_ack3 == 1)) {
- b[0] = 0;
- b[1] = 1;
- return(n1_pucch0);
- } else if ((harq_ack0 == 1) && ((harq_ack1 == 2) || (harq_ack1 == 0)) && ((harq_ack2 == 2) || (harq_ack2 == 0)) && ((harq_ack3 == 2) || (harq_ack3 == 0))) {
- b[0] = 0;
- b[1] = 1;
- return(n1_pucch0);
- } else if (((harq_ack0 == 2) || (harq_ack0 == 0)) && (harq_ack1 == 1) && (harq_ack2 == 1) && (harq_ack3 == 1)) {
- b[0] = 0;
- b[1] = 1;
- return(n1_pucch3);
- } else if (((harq_ack0 == 2) || (harq_ack0 == 0)) && (harq_ack1 == 0) && (harq_ack2 == 2) && (harq_ack3 == 2)) {
- b[0] = 0;
- b[1] = 0;
- return(n1_pucch1);
- } else if (((harq_ack0 == 2) || (harq_ack0 == 0)) && (harq_ack1 == 1) && (harq_ack2 == 1) && ((harq_ack3 == 2) || (harq_ack3 == 0))) {
- b[0] = 1;
- b[1] = 0;
- return(n1_pucch2);
- } else if (((harq_ack0 == 2) || (harq_ack0 == 0)) && (harq_ack1 == 1) && ((harq_ack2 == 2) || (harq_ack2 == 0)) && (harq_ack3 == 1)) {
- b[0] = 1;
- b[1] = 0;
- return(n1_pucch3);
- } else if (((harq_ack0 == 2) || (harq_ack0 == 0)) && (harq_ack1 == 1) && ((harq_ack2 == 2) || (harq_ack2 == 0)) && ((harq_ack3 == 2) || (harq_ack3 == 0))) {
- b[0] = 0;
- b[1] = 1;
- return(n1_pucch1);
- } else if (((harq_ack0 == 2) || (harq_ack0 == 0)) && ((harq_ack1 == 2) || (harq_ack1 == 0)) && (harq_ack2 == 1) && (harq_ack3 == 1)) {
- b[0] = 0;
- b[1] = 1;
- return(n1_pucch3);
- } else if (((harq_ack0 == 2) || (harq_ack0 == 0)) && ((harq_ack1 == 2) || (harq_ack1 == 0)) && (harq_ack2 == 1) && ((harq_ack3 == 2) || (harq_ack3 == 0))) {
- b[0] = 0;
- b[1] = 0;
- return(n1_pucch2);
- } else if (((harq_ack0 == 2) || (harq_ack0 == 0)) && ((harq_ack1 == 2) || (harq_ack1 == 0)) && (harq_ack3 == 1) && ((harq_ack2 == 2) || (harq_ack2 == 0))) {
- b[0] = 0;
- b[1] = 0;
- return(n1_pucch3);
- }
- } else if (nr_tti_tx == 2) {
- if ((harq_ack0 == 1) && (harq_ack1 == 1) && (harq_ack2 == 1)) {
- b[0] = 1;
- b[1] = 1;
- return(n1_pucch2);
- } else if ((harq_ack0 == 1) && (harq_ack1 == 1) && ((harq_ack2 == 2) || (harq_ack2 == 0))) {
- b[0] = 1;
- b[1] = 1;
- return(n1_pucch1);
- } else if ((harq_ack0 == 1) && ((harq_ack1 == 2) || (harq_ack1 == 0)) && (harq_ack2 == 1)) {
- b[0] = 1;
- b[1] = 1;
- return(n1_pucch0);
- } else if ((harq_ack0 == 1) && ((harq_ack1 == 2) || (harq_ack1 == 0)) && ((harq_ack2 == 2) || (harq_ack2 == 0))) {
- b[0] = 0;
- b[1] = 1;
- return(n1_pucch0);
- } else if (((harq_ack0 == 2) || (harq_ack0 == 0)) && (harq_ack1 == 1) && (harq_ack2 == 1)) {
- b[0] = 1;
- b[1] = 0;
- return(n1_pucch2);
- } else if (((harq_ack0 == 2) || (harq_ack0 == 0)) && (harq_ack1 == 1) && ((harq_ack2 == 2) || (harq_ack2 == 0))) {
- b[1] = 0;
- b[0] = 0;
- return(n1_pucch1);
- } else if (((harq_ack0 == 2) || (harq_ack0 == 0)) && ((harq_ack1 == 2) || (harq_ack1 == 0)) && (harq_ack2 == 1)) {
- b[0] = 0;
- b[1] = 0;
- return(n1_pucch2);
- } else if ((harq_ack0 == 2) && (harq_ack1 == 2) && (harq_ack2 == 0)) {
- b[0] = 0;
- b[1] = 1;
- return(n1_pucch2);
- } else if ((harq_ack0 == 2) && (harq_ack1 == 0) && ((harq_ack2 == 2) || (harq_ack2 == 0))) {
- b[0] = 1;
- b[1] = 0;
- return(n1_pucch1);
- } else if ((harq_ack0 == 0) && ((harq_ack1 == 2) || (harq_ack1 == 0)) && ((harq_ack2 == 2) || (harq_ack2 == 0))) {
- b[0] = 1;
- b[1] = 0;
- return(n1_pucch0);
- }
-
- }
- } else if (SR==1) { // SR and 0,1,or 2 ACKS, (first 3 entries in Table 7.3-1 of 36.213)
- // this should be number of ACKs (including
- ack_counter = 0;
- if (harq_ack0==1)
- ack_counter ++;
- if (harq_ack1==1)
- ack_counter ++;
- if (harq_ack2==1)
- ack_counter ++;
- if (harq_ack3==1)
- ack_counter ++;
-
- switch (ack_counter) {
- case 0:
- b[0] = 0;
- b[1] = 0;
- break;
-
- case 1:
- b[0] = 1;
- b[1] = 1;
- break;
-
- case 2:
- b[0] = 1;
- b[1] = 0;
- break;
-
- case 3:
- b[0] = 0;
- b[1] = 1;
- break;
-
- case 4:
- b[0] = 1;
- b[1] = 1;
- break;
- }
-
- ack_counter = 0;
- return(ue->scheduling_request_config[eNB_id].sr_PUCCH_ResourceIndex);
- }
-
- break;
-
- } // switch tdd_config
- }
-
- LOG_E(PHY,"[UE%d] : Frame %d phy_procedures_lte.c: get_n1pucch, exit without proper return\n", ue->Mod_id, proc->frame_tx);
- return(-1);
-}
-
-#endif
-
UE_MODE_t get_nrUE_mode(uint8_t Mod_id,uint8_t CC_id,uint8_t gNB_id){
return(PHY_vars_UE_g[Mod_id][CC_id]->UE_mode[gNB_id]);
}
@@ -1148,912 +173,6 @@ void nr_process_timing_advance_rar(PHY_VARS_NR_UE *ue, UE_nr_rxtx_proc_t *proc,
LOG_D(PHY, "[UE %d] Frame %d Slot %d, Received (RAR) timing advance command %d new value is %u \n", ue->Mod_id, proc->frame_rx, proc->nr_tti_rx, ta_command, ue->timing_advance);
}
-#if 0
-
-void ue_ulsch_uespec_procedures(PHY_VARS_NR_UE *ue,
- UE_nr_rxtx_proc_t *proc,
- uint8_t eNB_id,
- uint8_t abstraction_flag)
-{
- int nr_tti_tx=proc->nr_tti_tx;
-
- VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_PHY_PROCEDURES_UE_TX_ULSCH_UESPEC,VCD_FUNCTION_IN);
-
- /* reset harq for tx of current rx slot because it is sure that transmission has already been achieved for this slot */
- set_tx_harq_id(ue->ulsch[ue->current_thread_id[nr_tti_tx]][eNB_id][0], NR_MAX_HARQ_PROCESSES, proc->nr_tti_rx);
-
-#if 0
- int frame_tx=proc->frame_tx;
- int harq_pid;
- /* get harq pid related to this next tx slot */
- harq_pid = get_tx_harq_id(ue->ulsch[ue->current_thread_id[nr_tti_tx]][eNB_id][0], nr_tti_tx);
-
- int tx_amp;
- unsigned int input_buffer_length;
- int Mod_id = ue->Mod_id;
- int CC_id = ue->CC_id;
- uint8_t Msg3_flag=0;
- uint16_t first_rb, nb_rb;
- uint8_t ulsch_input_buffer[5477] __attribute__ ((aligned(32)));
- uint8_t access_mode;
- uint8_t Nbundled=0;
- uint8_t NbundledCw1=0;
- uint8_t ack_status_cw0=0;
- uint8_t ack_status_cw1=0;
- uint8_t cqi_status = 0;
- uint8_t ri_status = 0;
- if (ue->mac_enabled == 1) {
- if ((ue->ulsch_Msg3_active[eNB_id] == 1) &&
- (ue->ulsch_Msg3_frame[eNB_id] == frame_tx) &&
- (ue->ulsch_Msg3_subframe[eNB_id] == nr_tti_tx)) { // Initial Transmission of Msg3
-
- ue->ulsch[eNB_id]->harq_processes[harq_pid]->subframe_scheduling_flag = 1;
-
- if (ue->ulsch[eNB_id]->harq_processes[harq_pid]->round==0)
- generate_ue_ulsch_params_from_rar(ue,
- proc,
- eNB_id);
-
- ue->ulsch[eNB_id]->power_offset = 14;
- LOG_D(PHY,"[UE %d][RAPROC] Frame %d: Setting Msg3_flag in nr_tti_rx %d, for harq_pid %d\n",
- Mod_id,
- frame_tx,
- nr_tti_tx,
- harq_pid);
- Msg3_flag = 1;
- } else {
-
- /* no pusch has been scheduled on this transmit slot */
- if (harq_pid == NR_MAX_HARQ_PROCESSES) {
- LOG_E(PHY,"[UE%d] Frame %d nr_tti_rx %d ulsch_decoding.c: FATAL ERROR: illegal harq_pid, returning\n",
- Mod_id,frame_tx, nr_tti_tx);
- //mac_xface->macphy_exit("Error in ulsch_decoding");
- VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_PHY_PROCEDURES_UE_TX, VCD_FUNCTION_OUT);
-#if UE_TIMING_TRACE
- stop_meas(&ue->phy_proc_tx);
-#endif
- return;
- }
-
- Msg3_flag=0;
- }
- }
-
- if (ue->ulsch[eNB_id]->harq_processes[harq_pid]->subframe_scheduling_flag == 1) {
-
- uint8_t isBad = 0;
- if (ue->frame_parms.N_RB_UL <= ue->ulsch[eNB_id]->harq_processes[harq_pid]->first_rb) {
- LOG_D(PHY,"Invalid PUSCH first_RB=%d for N_RB_UL=%d\n",
- ue->ulsch[eNB_id]->harq_processes[harq_pid]->first_rb,
- ue->frame_parms.N_RB_UL);
- isBad = 1;
- }
- if (ue->frame_parms.N_RB_UL < ue->ulsch[eNB_id]->harq_processes[harq_pid]->nb_rb) {
- LOG_D(PHY,"Invalid PUSCH num_RB=%d for N_RB_UL=%d\n",
- ue->ulsch[eNB_id]->harq_processes[harq_pid]->nb_rb,
- ue->frame_parms.N_RB_UL);
- isBad = 1;
- }
- if (0 > ue->ulsch[eNB_id]->harq_processes[harq_pid]->first_rb) {
- LOG_D(PHY,"Invalid PUSCH first_RB=%d\n",
- ue->ulsch[eNB_id]->harq_processes[harq_pid]->first_rb);
- isBad = 1;
- }
- if (0 >= ue->ulsch[eNB_id]->harq_processes[harq_pid]->nb_rb) {
- LOG_D(PHY,"Invalid PUSCH num_RB=%d\n",
- ue->ulsch[eNB_id]->harq_processes[harq_pid]->nb_rb);
- isBad = 1;
- }
- if (ue->frame_parms.N_RB_UL < (ue->ulsch[eNB_id]->harq_processes[harq_pid]->nb_rb + ue->ulsch[eNB_id]->harq_processes[harq_pid]->first_rb)) {
- LOG_D(PHY,"Invalid PUSCH num_RB=%d + first_RB=%d for N_RB_UL=%d\n",
- ue->ulsch[eNB_id]->harq_processes[harq_pid]->nb_rb,
- ue->ulsch[eNB_id]->harq_processes[harq_pid]->first_rb,
- ue->frame_parms.N_RB_UL);
- isBad = 1;
- }
- if ((0 > ue->ulsch[eNB_id]->harq_processes[harq_pid]->rvidx) ||
- (3 < ue->ulsch[eNB_id]->harq_processes[harq_pid]->rvidx)) {
- LOG_D(PHY,"Invalid PUSCH RV index=%d\n", ue->ulsch[eNB_id]->harq_processes[harq_pid]->rvidx);
- isBad = 1;
- }
-
- if (20 < ue->ulsch[eNB_id]->harq_processes[harq_pid]->mcs) {
- LOG_D(PHY,"Not supported MCS in OAI mcs=%d\n", ue->ulsch[eNB_id]->harq_processes[harq_pid]->mcs);
- isBad = 1;
- }
-
- if (isBad) {
- LOG_D(PHY,"Skip PUSCH generation!\n");
- ue->ulsch[eNB_id]->harq_processes[harq_pid]->subframe_scheduling_flag = 0;
- }
- }
- if (ue->ulsch[eNB_id]->harq_processes[harq_pid]->subframe_scheduling_flag == 1) {
-
- ue->generate_ul_signal[eNB_id] = 1;
-
- // deactivate service request
- // ue->ulsch[eNB_id]->harq_processes[harq_pid]->subframe_scheduling_flag = 0;
- LOG_D(PHY,"Generating PUSCH (Abssubframe: %d.%d): harq-Id: %d, round: %d, MaxReTrans: %d \n",frame_tx,nr_tti_tx,harq_pid,ue->ulsch[eNB_id]->harq_processes[harq_pid]->round,ue->ulsch[eNB_id]->Mlimit);
- if (ue->ulsch[eNB_id]->harq_processes[harq_pid]->round >= (ue->ulsch[eNB_id]->Mlimit - 1))
- {
- LOG_D(PHY,"PUSCH MAX Retransmission achieved ==> send last pusch\n");
- ue->ulsch[eNB_id]->harq_processes[harq_pid]->subframe_scheduling_flag = 0;
- ue->ulsch[eNB_id]->harq_processes[harq_pid]->round = 0;
- }
-
- ack_status_cw0 = nr_reset_ack(&ue->frame_parms,
- ue->dlsch[ue->current_thread_id[proc->nr_tti_rx]][eNB_id][0]->harq_ack,
- nr_tti_tx,
- proc->nr_tti_rx,
- ue->ulsch[eNB_id]->o_ACK,
- &Nbundled,
- 0);
- ack_status_cw1 = nr_reset_ack(&ue->frame_parms,
- ue->dlsch[ue->current_thread_id[proc->nr_tti_rx]][eNB_id][1]->harq_ack,
- nr_tti_tx,
- proc->nr_tti_rx,
- ue->ulsch[eNB_id]->o_ACK,
- &NbundledCw1,
- 1);
-
- //Nbundled = ue->dlsch[ue->current_thread_id[proc->nr_tti_rx]][eNB_id][0]->harq_ack;
- //ue->ulsch[eNB_id]->bundling = Nbundled;
-
- first_rb = ue->ulsch[eNB_id]->harq_processes[harq_pid]->first_rb;
- nb_rb = ue->ulsch[eNB_id]->harq_processes[harq_pid]->nb_rb;
-
-
- // check Periodic CQI/RI reporting
- cqi_status = ((ue->cqi_report_config[eNB_id].CQI_ReportPeriodic.cqi_PMI_ConfigIndex>0)&&
- (nr_is_cqi_TXOp(ue,proc,eNB_id)==1));
-
- ri_status = ((ue->cqi_report_config[eNB_id].CQI_ReportPeriodic.ri_ConfigIndex>0) &&
- (nr_is_ri_TXOp(ue,proc,eNB_id)==1));
-
- // compute CQI/RI resources
- compute_cqi_ri_resources(ue, ue->ulsch[eNB_id], eNB_id, ue->ulsch[eNB_id]->rnti, P_RNTI, CBA_RNTI, cqi_status, ri_status);
-
- if (ack_status_cw0 > 0) {
-
- // check if we received a PDSCH at nr_tti_tx - 4
- // ==> send ACK/NACK on PUSCH
- if (ue->frame_parms.frame_type == FDD)
- {
- ue->ulsch[eNB_id]->harq_processes[harq_pid]->O_ACK = ack_status_cw0 + ack_status_cw1;
- }
-
-
-#if T_TRACER
- if(ue->ulsch[eNB_id]->o_ACK[0])
- {
- LOG_I(PHY,"PUSCH ACK\n");
- T(T_UE_PHY_DLSCH_UE_ACK, T_INT(eNB_id), T_INT(frame_tx%1024), T_INT(nr_tti_tx), T_INT(Mod_id), T_INT(ue->dlsch[ue->current_thread_id[proc->nr_tti_rx]][eNB_id][0]->rnti),
- T_INT(ue->dlsch[ue->current_thread_id[proc->nr_tti_rx]][eNB_id][0]->current_harq_pid));
- }
- else
- {
- LOG_I(PHY,"PUSCH NACK\n");
- T(T_UE_PHY_DLSCH_UE_NACK, T_INT(eNB_id), T_INT(frame_tx%1024), T_INT(nr_tti_tx), T_INT(Mod_id), T_INT(ue->dlsch[ue->current_thread_id[proc->nr_tti_rx]][eNB_id][0]->rnti),
- T_INT(ue->dlsch[ue->current_thread_id[proc->nr_tti_rx]][eNB_id][0]->current_harq_pid));
- }
-#endif
-#ifdef UE_DEBUG_TRACE
- LOG_I(PHY,"[UE %d][PDSCH %x] AbsSubFrame %d.%d Generating ACK (%d,%d) for %d bits on PUSCH\n",
- Mod_id,
- ue->ulsch[eNB_id]->rnti,
- frame_tx%1024,nr_tti_tx,
- ue->ulsch[eNB_id]->o_ACK[0],ue->ulsch[eNB_id]->o_ACK[1],
- ue->ulsch[eNB_id]->harq_processes[harq_pid]->O_ACK);
-#endif
- }
-
- //#ifdef UE_DEBUG_TRACE
- LOG_I(PHY,
- "[UE %d][PUSCH %d] AbsSubframe %d.%d Generating PUSCH : first_rb %d, nb_rb %d, round %d, mcs %d, tbs %d, rv %d, "
- "cyclic_shift %d (cyclic_shift_common %d,n_DMRS2 %d,n_PRS %d), ACK (%d,%d), O_ACK %d, ack_status_cw0 %d ack_status_cw1 %d bundling %d, Nbundled %d, CQI %d, RI %d\n",
- Mod_id,harq_pid,frame_tx%1024,nr_tti_tx,
- first_rb,nb_rb,
- ue->ulsch[eNB_id]->harq_processes[harq_pid]->round,
- ue->ulsch[eNB_id]->harq_processes[harq_pid]->mcs,
- ue->ulsch[eNB_id]->harq_processes[harq_pid]->TBS,
- ue->ulsch[eNB_id]->harq_processes[harq_pid]->rvidx,
- (ue->frame_parms.pusch_config_common.ul_ReferenceSignalsPUSCH.cyclicShift+
- ue->ulsch[eNB_id]->harq_processes[harq_pid]->n_DMRS2+
- ue->frame_parms.pusch_config_common.ul_ReferenceSignalsPUSCH.nPRS[nr_tti_tx<<1])%12,
- ue->frame_parms.pusch_config_common.ul_ReferenceSignalsPUSCH.cyclicShift,
- ue->ulsch[eNB_id]->harq_processes[harq_pid]->n_DMRS2,
- ue->frame_parms.pusch_config_common.ul_ReferenceSignalsPUSCH.nPRS[nr_tti_tx<<1],
- ue->ulsch[eNB_id]->o_ACK[0],ue->ulsch[eNB_id]->o_ACK[1],
- ue->ulsch[eNB_id]->harq_processes[harq_pid]->O_ACK,
- ack_status_cw0,
- ack_status_cw1,
- ue->ulsch[eNB_id]->bundling, Nbundled,
- cqi_status,
- ri_status);
- //#endif
-
-
-
-
-
- if (Msg3_flag == 1) {
- LOG_I(PHY,"[UE %d][RAPROC] Frame %d, nr_tti_rx %d Generating (RRCConnectionRequest) Msg3 (nb_rb %d, first_rb %d, round %d, rvidx %d) Msg3: %x.%x.%x|%x.%x.%x.%x.%x.%x\n",Mod_id,frame_tx,
- nr_tti_tx,
- ue->ulsch[eNB_id]->harq_processes[harq_pid]->nb_rb,
- ue->ulsch[eNB_id]->harq_processes[harq_pid]->first_rb,
- ue->ulsch[eNB_id]->harq_processes[harq_pid]->round,
- ue->ulsch[eNB_id]->harq_processes[harq_pid]->rvidx,
- ue->prach_resources[eNB_id]->Msg3[0],
- ue->prach_resources[eNB_id]->Msg3[1],
- ue->prach_resources[eNB_id]->Msg3[2],
- ue->prach_resources[eNB_id]->Msg3[3],
- ue->prach_resources[eNB_id]->Msg3[4],
- ue->prach_resources[eNB_id]->Msg3[5],
- ue->prach_resources[eNB_id]->Msg3[6],
- ue->prach_resources[eNB_id]->Msg3[7],
- ue->prach_resources[eNB_id]->Msg3[8]);
-#if UE_TIMING_TRACE
- start_meas(&ue->ulsch_encoding_stats);
-#endif
-
- if (abstraction_flag==0) {
- if (ulsch_encoding(ue->prach_resources[eNB_id]->Msg3,
- ue,
- harq_pid,
- eNB_id,
- proc->nr_tti_rx,
- ue->transmission_mode[eNB_id],0,0)!=0) {
- LOG_E(PHY,"ulsch_coding.c: FATAL ERROR: returning\n");
- //mac_xface->macphy_exit("Error in ulsch_coding");
- VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_PHY_PROCEDURES_UE_TX, VCD_FUNCTION_OUT);
-#if UE_TIMING_TRACE
- stop_meas(&ue->phy_proc_tx);
- printf("------FULL TX PROC : %5.2f ------\n",ue->phy_proc_tx.p_time/(cpuf*1000.0));
-#endif
- return;
- }
- }
-
-#ifdef PHY_ABSTRACTION
- else {
- ulsch_encoding_emul(ue->prach_resources[eNB_id]->Msg3,ue,eNB_id,proc->nr_tti_rx,harq_pid,0);
- }
-
-#endif
-
-#if UE_TIMING_TRACE
- stop_meas(&ue->ulsch_encoding_stats);
-#endif
- if (ue->mac_enabled == 1) {
- // signal MAC that Msg3 was sent
- //mac_xface->Msg3_transmitted(Mod_id,
- CC_id,
- frame_tx,
- eNB_id);
- }
- } // Msg3_flag==1
- else {
- input_buffer_length = ue->ulsch[eNB_id]->harq_processes[harq_pid]->TBS/8;
-
- if (ue->mac_enabled==1) {
- // LOG_D(PHY,"[UE %d] ULSCH : Searching for MAC SDUs\n",Mod_id);
- if (ue->ulsch[eNB_id]->harq_processes[harq_pid]->round==0) {
- //if (ue->ulsch[eNB_id]->harq_processes[harq_pid]->calibration_flag == 0) {
- access_mode=SCHEDULED_ACCESS;
- //mac_xface->ue_get_sdu(Mod_id,
- CC_id,
- frame_tx,
- proc->subframe_tx,
- nr_tti_tx%(ue->frame_parms.ttis_per_subframe),
- eNB_id,
- ulsch_input_buffer,
- input_buffer_length,
- &access_mode);
- }
-
-#ifdef DEBUG_PHY_PROC
-#ifdef DEBUG_ULSCH
- LOG_D(PHY,"[UE] Frame %d, nr_tti_rx %d : ULSCH SDU (TX harq_pid %d) (%d bytes) : \n",frame_tx,nr_tti_tx,harq_pid, ue->ulsch[eNB_id]->harq_processes[harq_pid]->TBS>>3);
-
- for (int i=0; iulsch[eNB_id]->harq_processes[harq_pid]->TBS>>3; i++)
- LOG_T(PHY,"%x.",ulsch_input_buffer[i]);
-
- LOG_T(PHY,"\n");
-#endif
-#endif
- }
- else {
- unsigned int taus(void);
-
- for (int i=0; iulsch_encoding_stats);
-#endif
- if (abstraction_flag==0) {
-
- if (ulsch_encoding(ulsch_input_buffer,
- ue,
- harq_pid,
- eNB_id,
- proc->nr_tti_rx,
- ue->transmission_mode[eNB_id],0,
- Nbundled)!=0) {
- LOG_E(PHY,"ulsch_coding.c: FATAL ERROR: returning\n");
- VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_PHY_PROCEDURES_UE_TX, VCD_FUNCTION_OUT);
-#if UE_TIMING_TRACE
- stop_meas(&ue->phy_proc_tx);
-#endif
- return;
- }
- }
-
-#ifdef PHY_ABSTRACTION
- else {
- ulsch_encoding_emul(ulsch_input_buffer,ue,eNB_id,proc->nr_tti_rx,harq_pid,0);
- }
-
-#endif
-#if UE_TIMING_TRACE
- stop_meas(&ue->ulsch_encoding_stats);
-#endif
-}
-
-if (abstraction_flag == 0) {
- if (ue->mac_enabled==1) {
- nr_pusch_power_cntl(ue,proc,eNB_id,1, abstraction_flag);
- ue->tx_power_dBm[nr_tti_tx] = ue->ulsch[eNB_id]->Po_PUSCH;
- }
- else {
- ue->tx_power_dBm[nr_tti_tx] = ue->tx_power_max_dBm;
- }
- ue->tx_total_RE[nr_tti_tx] = nb_rb*12;
-
-#if defined(EXMIMO) || defined(OAI_USRP) || defined(OAI_BLADERF) || defined(OAI_LMSSDR) || defined(OAI_ADRV9371_ZC706)
- tx_amp = nr_get_tx_amp(ue->tx_power_dBm[nr_tti_tx],
- ue->tx_power_max_dBm,
- ue->frame_parms.N_RB_UL,
- nb_rb);
-#else
- tx_amp = AMP;
-#endif
-#if T_TRACER
- T(T_UE_PHY_PUSCH_TX_POWER, T_INT(eNB_id),T_INT(Mod_id), T_INT(frame_tx%1024), T_INT(nr_tti_tx),T_INT(ue->tx_power_dBm[nr_tti_tx]),
- T_INT(tx_amp),T_INT(ue->ulsch[eNB_id]->f_pusch),T_INT(get_nr_PL(Mod_id,0,eNB_id)),T_INT(nb_rb));
-#endif
-
-#ifdef UE_DEBUG_TRACE
- LOG_I(PHY,"[UE %d][PUSCH %d] AbsSubFrame %d.%d, generating PUSCH, Po_PUSCH: %d dBm (max %d dBm), amp %d\n",
- Mod_id,harq_pid,frame_tx%1024,nr_tti_tx,ue->tx_power_dBm[nr_tti_tx],ue->tx_power_max_dBm, tx_amp);
-#endif
-
- if (tx_amp>100)
- tx_amp =100;
-
- //LOG_I(PHY,"[UE %d][PUSCH %d] after AbsSubFrame %d.%d, generating PUSCH, Po_PUSCH: %d dBm (max %d dBm), amp %d\n",
- // Mod_id,harq_pid,frame_tx%1024,nr_tti_tx,ue->tx_power_dBm[nr_tti_tx],ue->tx_power_max_dBm, tx_amp);
-
-
-#if UE_TIMING_TRACE
-
- start_meas(&ue->ulsch_modulation_stats);
-#endif
- ulsch_modulation(ue->common_vars.txdataF,
- tx_amp,
- frame_tx,
- nr_tti_tx,
- &ue->frame_parms,
- ue->ulsch[eNB_id]);
- for (int aa=0; aa<1/*frame_parms->nb_antennas_tx*/; aa++)
- generate_drs_pusch(ue,
- proc,
- eNB_id,
- tx_amp,
- nr_tti_tx,
- first_rb,
- nb_rb,
- aa);
-#if UE_TIMING_TRACE
- stop_meas(&ue->ulsch_modulation_stats);
-#endif
- }
-
-if (abstraction_flag==1) {
- // clear SR
- ue->sr[nr_tti_tx]=0;
- }
-} // subframe_scheduling_flag==1
-
-VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_PHY_PROCEDURES_UE_TX_ULSCH_UESPEC,VCD_FUNCTION_OUT);
-
-#endif
-
-}
-#endif
-
-#if 0
-
-void ue_srs_procedures(PHY_VARS_NR_UE *ue,UE_nr_rxtx_proc_t *proc,uint8_t eNB_id,uint8_t abstraction_flag)
-{
-
- //NR_DL_FRAME_PARMS *frame_parms = &ue->frame_parms;
- //int8_t frame_tx = proc->frame_tx;
- int8_t nr_tti_tx = proc->nr_tti_tx;
- int16_t tx_amp;
- int16_t Po_SRS;
- uint8_t nb_rb_srs;
-
- SOUNDINGRS_UL_CONFIG_DEDICATED *pSoundingrs_ul_config_dedicated=&ue->soundingrs_ul_config_dedicated[eNB_id];
- uint8_t isSrsTxOccasion = pSoundingrs_ul_config_dedicated->srsUeSubframe;
-
- if(isSrsTxOccasion)
- {
- ue->generate_ul_signal[eNB_id] = 1;
- if (ue->mac_enabled==1)
- {
- srs_power_cntl(ue,proc,eNB_id, (uint8_t*)(&nb_rb_srs), abstraction_flag);
- Po_SRS = ue->ulsch[eNB_id]->Po_SRS;
- }
- else
- {
- Po_SRS = ue->tx_power_max_dBm;
- }
-
-#if defined(EXMIMO) || defined(OAI_USRP) || defined(OAI_BLADERF) || defined(OAI_LMSSDR) || defined(OAI_ADRV9371_ZC706)
- if (ue->mac_enabled==1)
- {
- tx_amp = nr_get_tx_amp(Po_SRS,
- ue->tx_power_max_dBm,
- ue->frame_parms.N_RB_UL,
- nb_rb_srs);
- }
- else
- {
- tx_amp = AMP;
- }
-#else
- tx_amp = AMP;
-#endif
- LOG_D(PHY,"SRS PROC; TX_MAX_POWER %d, Po_SRS %d, NB_RB_UL %d, NB_RB_SRS %d TX_AMPL %d\n",ue->tx_power_max_dBm,
- Po_SRS,
- ue->frame_parms.N_RB_UL,
- nb_rb_srs,
- tx_amp);
-
- uint16_t nsymb = (ue->frame_parms.Ncp==0) ? 14:12;
- uint16_t symbol_offset = (int)ue->frame_parms.ofdm_symbol_size*((nr_tti_tx*nsymb)+(nsymb-1));
- generate_srs(&ue->frame_parms,
- &ue->soundingrs_ul_config_dedicated[eNB_id],
- &ue->common_vars.txdataF[eNB_id][symbol_offset],
- tx_amp,
- nr_tti_tx);
- }
-}
-
-int16_t get_pucch2_cqi(PHY_VARS_NR_UE *ue,int eNB_id,int *len) {
-
- if ((ue->transmission_mode[eNB_id]<4)||
- (ue->transmission_mode[eNB_id]==7)) { // Mode 1-0 feedback
- // 4-bit CQI message
- /*LOG_I(PHY,"compute CQI value, TM %d, length 4, Cqi Avg %d, value %d \n", ue->transmission_mode[eNB_id],
- ue->measurements.wideband_cqi_avg[eNB_id],
- sinr2cqi((double)ue->measurements.wideband_cqi_avg[eNB_id],
- ue->transmission_mode[eNB_id]));*/
- *len=4;
- return(sinr2cqi((double)ue->measurements.wideband_cqi_avg[eNB_id],
- ue->transmission_mode[eNB_id]));
- }
- else { // Mode 1-1 feedback, later
- //LOG_I(PHY,"compute CQI value, TM %d, length 0, Cqi Avg 0 \n", ue->transmission_mode[eNB_id]);
- *len=0;
- // 2-antenna ports RI=1, 6 bits (2 PMI, 4 CQI)
-
- // 2-antenna ports RI=2, 8 bits (1 PMI, 7 CQI/DIFF CQI)
- return(0);
- }
-}
-
-
-int16_t get_pucch2_ri(PHY_VARS_NR_UE *ue,int eNB_id) {
-
- return(1);
-}
-
-
-void get_pucch_param(PHY_VARS_NR_UE *ue,
- UE_nr_rxtx_proc_t *proc,
- uint8_t *ack_payload,
- PUCCH_FMT_t format,
- uint8_t eNB_id,
- uint8_t SR,
- uint8_t cqi_report,
- uint16_t *pucch_resource,
- uint8_t *pucch_payload,
- uint16_t *plength)
-{
-
- switch (format) {
- case pucch_format1:
- {
- pucch_resource[0] = ue->scheduling_request_config[eNB_id].sr_PUCCH_ResourceIndex;
- pucch_payload[0] = 0; // payload is ignored in case of format1
- pucch_payload[1] = 0; // payload is ignored in case of format1
- }
- break;
-
- case pucch_format1a:
- case pucch_format1b:
- {
- pucch_resource[0] = nr_get_n1_pucch(ue,
- proc,
- ue->dlsch[ue->current_thread_id[proc->nr_tti_rx]][eNB_id][0]->harq_ack,
- eNB_id,
- ack_payload,
- SR);
- pucch_payload[0] = ack_payload[0];
- pucch_payload[1] = ack_payload[1];
- //pucch_payload[1] = 1;
- }
- break;
-
- case pucch_format2:
- {
- pucch_resource[0] = ue->cqi_report_config[eNB_id].CQI_ReportPeriodic.cqi_PUCCH_ResourceIndex;
- if(cqi_report)
- {
- pucch_payload[0] = get_pucch2_cqi(ue,eNB_id,(int*)plength);
- }
- else
- {
- *plength = 1;
- pucch_payload[0] = get_pucch2_ri(ue,eNB_id);
- }
- }
- break;
-
- case pucch_format2a:
- case pucch_format2b:
- LOG_E(PHY,"NO Resource available for PUCCH 2a/2b \n");
- break;
-
- case pucch_format3:
- fprintf(stderr, "PUCCH format 3 not handled\n");
- abort();
- }
-}
-
-#ifdef NR_PUCCH_SCHED
-void ue_nr_pucch_procedures(PHY_VARS_NR_UE *ue,UE_nr_rxtx_proc_t *proc,uint8_t eNB_id,uint8_t abstraction_flag) {
-}
-#endif
-
-void ue_pucch_procedures(PHY_VARS_NR_UE *ue,UE_nr_rxtx_proc_t *proc,uint8_t eNB_id,uint8_t abstraction_flag) {
-
-
- uint8_t pucch_ack_payload[2];
- uint16_t pucch_resource;
- ANFBmode_t bundling_flag;
- PUCCH_FMT_t format;
-
- uint8_t SR_payload;
- uint8_t pucch_payload[2];
- uint16_t len;
-
- NR_DL_FRAME_PARMS *frame_parms = &ue->frame_parms;
- int frame_tx=proc->frame_tx;
- int nr_tti_tx=proc->nr_tti_tx;
- int Mod_id = ue->Mod_id;
- int CC_id = ue->CC_id;
- int tx_amp;
- int16_t Po_PUCCH;
- uint8_t ack_status_cw0=0;
- uint8_t ack_status_cw1=0;
- uint8_t nb_cw=0;
- uint8_t cqi_status=0;
- uint8_t ri_status=0;
-
- VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_PHY_PROCEDURES_UE_TX_PUCCH,VCD_FUNCTION_IN);
-
- SOUNDINGRS_UL_CONFIG_DEDICATED *pSoundingrs_ul_config_dedicated=&ue->soundingrs_ul_config_dedicated[eNB_id];
-
- // 36.213 8.2
- /*if ackNackSRS_SimultaneousTransmission == TRUE and in the cell specific SRS subframes UE shall transmit
- ACK/NACK and SR using the shortened PUCCH format. This shortened PUCCH format shall be used in a cell
- specific SRS nr_tti_rx even if the UE does not transmit SRS in that nr_tti_rx
- */
-
- int harq_pid = nr_subframe2harq_pid(&ue->frame_parms,
- frame_tx,
- nr_tti_tx);
-
- if(ue->ulsch[eNB_id]->harq_processes[harq_pid]->subframe_scheduling_flag)
- {
- LOG_D(PHY,"PUSCH is programmed on this nr_tti_rx [pid %d] AbsSuframe %d.%d ==> Skip PUCCH transmission \n",harq_pid,frame_tx,nr_tti_tx);
- VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_PHY_PROCEDURES_UE_TX_PUCCH,VCD_FUNCTION_OUT);
- return;
- }
-
- uint8_t isShortenPucch = (pSoundingrs_ul_config_dedicated->srsCellSubframe && frame_parms->soundingrs_ul_config_common.ackNackSRS_SimultaneousTransmission);
-
- bundling_flag = ue->pucch_config_dedicated[eNB_id].tdd_AckNackFeedbackMode;
-
- if ((frame_parms->frame_type==FDD) ||
- (bundling_flag==bundling) ||
- ((frame_parms->frame_type==TDD)&&(frame_parms->tdd_config==1)&&((nr_tti_tx!=2)||(nr_tti_tx!=7)))) {
- format = pucch_format1a;
- LOG_D(PHY,"[UE] PUCCH 1a\n");
- } else {
- format = pucch_format1b;
- LOG_D(PHY,"[UE] PUCCH 1b\n");
- }
-
- // Part - I
- // Collect feedback that should be transmitted at this nr_tti_rx
- // - SR
- // - ACK/NACK
- // - CQI
- // - RI
-
- SR_payload = 0;
- if (nr_is_SR_TXOp(ue,proc,eNB_id)==1)
- {
- if (ue->mac_enabled==1) {
- SR_payload = mac_xface->ue_get_SR(Mod_id,
- CC_id,
- frame_tx,
- eNB_id,
- ue->pdcch_vars[ue->current_thread_id[proc->nr_tti_rx]][eNB_id]->crnti,
- nr_tti_tx); // nr_tti_rx used for meas gap
- }
- else {
- SR_payload = 1;
- }
- }
-
- ack_status_cw0 = nr_get_ack(&ue->frame_parms,
- ue->dlsch[ue->current_thread_id[proc->nr_tti_rx]][eNB_id][0]->harq_ack,
- nr_tti_tx,
- proc->nr_tti_rx,
- pucch_ack_payload,
- 0);
-
- ack_status_cw1 = nr_get_ack(&ue->frame_parms,
- ue->dlsch[ue->current_thread_id[proc->nr_tti_rx]][eNB_id][1]->harq_ack,
- nr_tti_tx,
- proc->nr_tti_rx,
- pucch_ack_payload,
- 1);
-
- nb_cw = ( (ack_status_cw0 != 0) ? 1:0) + ( (ack_status_cw1 != 0) ? 1:0);
-
- cqi_status = ((ue->cqi_report_config[eNB_id].CQI_ReportPeriodic.cqi_PMI_ConfigIndex>0)&&
- (nr_is_cqi_TXOp(ue,proc,eNB_id)==1));
-
- ri_status = ((ue->cqi_report_config[eNB_id].CQI_ReportPeriodic.ri_ConfigIndex>0) &&
- (nr_is_ri_TXOp(ue,proc,eNB_id)==1));
-
- // Part - II
- // if nothing to report ==> exit function
- if( (nb_cw==0) && (SR_payload==0) && (cqi_status==0) && (ri_status==0) )
- {
- LOG_D(PHY,"PUCCH No feedback AbsSubframe %d.%d SR_payload %d nb_cw %d pucch_ack_payload[0] %d pucch_ack_payload[1] %d cqi_status %d Return \n",
- frame_tx%1024, nr_tti_tx, SR_payload, nb_cw, pucch_ack_payload[0], pucch_ack_payload[1], cqi_status);
- return;
- }
-
- // Part - III
- // Decide which PUCCH format should be used if needed
- format = get_pucch_format(frame_parms->frame_type,
- frame_parms->Ncp,
- SR_payload,
- nb_cw,
- cqi_status,
- ri_status,
- bundling_flag);
- // Determine PUCCH resources and payload: mandatory for pucch encoding
- get_pucch_param(ue,
- proc,
- pucch_ack_payload,
- format,
- eNB_id,
- SR_payload,
- cqi_status,
- &pucch_resource,
- (uint8_t *)&pucch_payload,
- &len);
-
-
- LOG_D(PHY,"PUCCH feedback AbsSubframe %d.%d SR %d NbCW %d (%d %d) AckNack %d.%d CQI %d RI %d format %d pucch_resource %d pucch_payload %d %d \n",
- frame_tx%1024, nr_tti_tx, SR_payload, nb_cw, ack_status_cw0, ack_status_cw1, pucch_ack_payload[0], pucch_ack_payload[1], cqi_status, ri_status, format, pucch_resource,pucch_payload[0],pucch_payload[1]);
-
- // Part - IV
- // Generate PUCCH signal
- ue->generate_ul_signal[eNB_id] = 1;
-
- switch (format) {
- case pucch_format1:
- case pucch_format1a:
- case pucch_format1b:
- {
- if (ue->mac_enabled == 1) {
- Po_PUCCH = nr_pucch_power_cntl(ue,proc,nr_tti_tx,eNB_id,format);
- }
- else {
- Po_PUCCH = ue->tx_power_max_dBm;
- }
- ue->tx_power_dBm[nr_tti_tx] = Po_PUCCH;
- ue->tx_total_RE[nr_tti_tx] = 12;
-
-#if defined(EXMIMO) || defined(OAI_USRP) || defined(OAI_BLADERF) || defined(OAI_LMSSDR) || defined(OAI_ADRV9371_ZC706)
- tx_amp = nr_get_tx_amp(Po_PUCCH,
- ue->tx_power_max_dBm,
- ue->frame_parms.N_RB_UL,
- 1);
-#else
- tx_amp = AMP;
-#endif
-#if T_TRACER
- T(T_UE_PHY_PUCCH_TX_POWER, T_INT(eNB_id),T_INT(Mod_id), T_INT(frame_tx%1024), T_INT(nr_tti_tx),T_INT(ue->tx_power_dBm[nr_tti_tx]),
- T_INT(tx_amp),T_INT(ue->dlsch[ue->current_thread_id[proc->nr_tti_rx]][eNB_id][0]->g_pucch),T_INT(get_nr_PL(ue->Mod_id,ue->CC_id,eNB_id)));
-#endif
-
-#ifdef UE_DEBUG_TRACE
- if(format == pucch_format1)
- {
- LOG_I(PHY,"[UE %d][SR %x] AbsSubframe %d.%d Generating PUCCH 1 (SR for PUSCH), an_srs_simultanous %d, shorten_pucch %d, n1_pucch %d, Po_PUCCH %d\n",
- Mod_id,
- ue->dlsch[ue->current_thread_id[proc->nr_tti_rx]][eNB_id][0]->rnti,
- frame_tx%1024, nr_tti_tx,
- frame_parms->soundingrs_ul_config_common.ackNackSRS_SimultaneousTransmission,
- isShortenPucch,
- ue->scheduling_request_config[eNB_id].sr_PUCCH_ResourceIndex,
- Po_PUCCH);
- }
- else
- {
- if (SR_payload>0) {
- LOG_I(PHY,"[UE %d][SR %x] AbsSubFrame %d.%d Generating PUCCH %s payload %d,%d (with SR for PUSCH), an_srs_simultanous %d, shorten_pucch %d, n1_pucch %d, Po_PUCCH %d, amp %d\n",
- Mod_id,
- ue->dlsch[ue->current_thread_id[proc->nr_tti_rx]][eNB_id][0]->rnti,
- frame_tx % 1024, nr_tti_tx,
- (format == pucch_format1a? "1a": (
- format == pucch_format1b? "1b" : "??")),
- pucch_ack_payload[0],pucch_ack_payload[1],
- frame_parms->soundingrs_ul_config_common.ackNackSRS_SimultaneousTransmission,
- isShortenPucch,
- pucch_resource,
- Po_PUCCH,
- tx_amp);
- } else {
- LOG_I(PHY,"[UE %d][PDSCH %x] AbsSubFrame %d.%d rx_offset_diff: %d, Generating PUCCH %s, an_srs_simultanous %d, shorten_pucch %d, n1_pucch %d, b[0]=%d,b[1]=%d (SR_Payload %d), Po_PUCCH %d, amp %d\n",
- Mod_id,
- ue->dlsch[ue->current_thread_id[proc->nr_tti_rx]][eNB_id][0]->rnti,
- frame_tx%1024, nr_tti_tx,ue->rx_offset_diff,
- (format == pucch_format1a? "1a": (
- format == pucch_format1b? "1b" : "??")),
- frame_parms->soundingrs_ul_config_common.ackNackSRS_SimultaneousTransmission,
- isShortenPucch,
- pucch_resource,pucch_payload[0],pucch_payload[1],SR_payload,
- Po_PUCCH,
- tx_amp);
- }
- }
-#endif
-
-#if T_TRACER
- if(pucch_payload[0])
- {
- T(T_UE_PHY_DLSCH_UE_ACK, T_INT(eNB_id), T_INT(frame_tx%1024), T_INT(nr_tti_tx), T_INT(Mod_id), T_INT(ue->dlsch[ue->current_thread_id[proc->nr_tti_rx]][eNB_id][0]->rnti),
- T_INT(ue->dlsch[ue->current_thread_id[proc->nr_tti_rx]][eNB_id][0]->current_harq_pid));
- }
- else
- {
- T(T_UE_PHY_DLSCH_UE_NACK, T_INT(eNB_id), T_INT(frame_tx%1024), T_INT(nr_tti_tx), T_INT(Mod_id), T_INT(ue->dlsch[ue->current_thread_id[proc->nr_tti_rx]][eNB_id][0]->rnti),
- T_INT(ue->dlsch[ue->current_thread_id[proc->nr_tti_rx]][eNB_id][0]->current_harq_pid));
- }
-#endif
-
- if (abstraction_flag == 0) {
-
- generate_pucch1x(ue->common_vars.txdataF,
- &ue->frame_parms,
- ue->ncs_cell,
- format,
- &ue->pucch_config_dedicated[eNB_id],
- pucch_resource,
- isShortenPucch, // shortened format
- pucch_payload,
- tx_amp,
- nr_tti_tx);
-
- } else {
-#ifdef PHY_ABSTRACTION
- LOG_D(PHY,"Calling generate_pucch_emul ... (ACK %d %d, SR %d)\n",pucch_ack_payload[0],pucch_ack_payload[1],SR_payload);
- generate_pucch_emul(ue,
- proc,
- format,
- ue->frame_parms.pucch_config_common.nCS_AN,
- pucch_payload,
- SR_payload);
-#endif
- }
- }
- break;
-
-
- case pucch_format2:
- {
- if (ue->mac_enabled == 1) {
- Po_PUCCH = nr_pucch_power_cntl(ue,proc,nr_tti_tx,eNB_id,format);
- }
- else {
- Po_PUCCH = ue->tx_power_max_dBm;
- }
- ue->tx_power_dBm[nr_tti_tx] = Po_PUCCH;
- ue->tx_total_RE[nr_tti_tx] = 12;
-
-#if defined(EXMIMO) || defined(OAI_USRP) || defined(OAI_BLADERF) || defined(OAI_LMSSDR) || defined(OAI_ADRV9371_ZC706)
- tx_amp = nr_get_tx_amp(Po_PUCCH,
- ue->tx_power_max_dBm,
- ue->frame_parms.N_RB_UL,
- 1);
-#else
- tx_amp = AMP;
-#endif
-#if T_TRACER
- T(T_UE_PHY_PUCCH_TX_POWER, T_INT(eNB_id),T_INT(Mod_id), T_INT(frame_tx%1024), T_INT(nr_tti_tx),T_INT(ue->tx_power_dBm[nr_tti_tx]),
- T_INT(tx_amp),T_INT(ue->dlsch[ue->current_thread_id[proc->nr_tti_rx]][eNB_id][0]->g_pucch),T_INT(get_nr_PL(ue->Mod_id,ue->CC_id,eNB_id)));
-#endif
-#ifdef UE_DEBUG_TRACE
- LOG_I(PHY,"[UE %d][RNTI %x] AbsSubFrame %d.%d Generating PUCCH 2 (RI or CQI), Po_PUCCH %d, isShortenPucch %d, amp %d\n",
- Mod_id,
- ue->dlsch[ue->current_thread_id[proc->nr_tti_rx]][eNB_id][0]->rnti,
- frame_tx%1024, nr_tti_tx,
- Po_PUCCH,
- isShortenPucch,
- tx_amp);
-#endif
- generate_pucch2x(ue->common_vars.txdataF,
- &ue->frame_parms,
- ue->ncs_cell,
- format,
- &ue->pucch_config_dedicated[eNB_id],
- pucch_resource,
- pucch_payload,
- len, // A
- 0, // B2 not needed
- tx_amp,
- nr_tti_tx,
- ue->pdcch_vars[ue->current_thread_id[proc->nr_tti_rx]][eNB_id]->crnti);
- }
- break;
-
- case pucch_format2a:
- LOG_D(PHY,"[UE %d][RNTI %x] AbsSubFrame %d.%d Generating PUCCH 2a (RI or CQI) Ack/Nack 1bit \n",
- Mod_id,
- ue->dlsch[ue->current_thread_id[proc->nr_tti_rx]][eNB_id][0]->rnti,
- frame_tx%1024, nr_tti_tx);
- break;
- case pucch_format2b:
- LOG_D(PHY,"[UE %d][RNTI %x] AbsSubFrame %d.%d Generating PUCCH 2b (RI or CQI) Ack/Nack 2bits\n",
- Mod_id,
- ue->dlsch[ue->current_thread_id[proc->nr_tti_rx]][eNB_id][0]->rnti,
- frame_tx%1024, nr_tti_tx);
- break;
- default:
- break;
- }
-
- VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_PHY_PROCEDURES_UE_TX_PUCCH,VCD_FUNCTION_OUT);
-
-}
-
-#endif
-
-
void phy_procedures_nrUE_TX(PHY_VARS_NR_UE *ue,
UE_nr_rxtx_proc_t *proc,
uint8_t gNB_id,
@@ -2074,19 +193,10 @@ void phy_procedures_nrUE_TX(PHY_VARS_NR_UE *ue,
start_meas(&ue->phy_proc_tx);
#endif
- if (ue->UE_mode[gNB_id] == PUSCH || get_softmodem_params()->phy_test == 1){
- if (ue->ulsch[thread_id][gNB_id][0]->harq_processes[harq_pid]->status == ACTIVE)
- nr_ue_ulsch_procedures(ue, harq_pid, frame_tx, slot_tx, thread_id, gNB_id);
+ if (ue->UE_mode[gNB_id] <= PUSCH || get_softmodem_params()->phy_test == 1){
-
-/*
- if (ue->UE_mode[eNB_id] == PUSCH) {
- // check if we need to use PUCCH 1a/1b
- ue_pucch_procedures(ue,proc,eNB_id,abstraction_flag);
- // check if we need to use SRS
- ue_srs_procedures(ue,proc,eNB_id,abstraction_flag);
- } // UE_mode==PUSCH
-*/
+ if (ue->ulsch[thread_id][gNB_id][0]->harq_processes[harq_pid]->status == ACTIVE)
+ nr_ue_ulsch_procedures(ue, harq_pid, frame_tx, slot_tx, thread_id, gNB_id);
if (get_softmodem_params()->usim_test==0) {
LOG_D(PHY, "Generating PUCCH\n");
@@ -2119,32 +229,6 @@ void phy_procedures_nrUE_TX(PHY_VARS_NR_UE *ue,
}
-/*
-void phy_procedures_UE_S_TX(PHY_VARS_NR_UE *ue,uint8_t eNB_id,uint8_t abstraction_flag,relaying_type_t r_type)
-{
- int aa;//i,aa;
- NR_DL_FRAME_PARMS *frame_parms=&ue->frame_parms;
-
- if (abstraction_flag==0) {
-
- for (aa=0; aanb_antennas_tx; aa++) {
-#if defined(EXMIMO) //this is the EXPRESS MIMO case
- int i;
- // set the whole tx buffer to RX
- for (i=0; isamples_per_subframe; i++)
- ue->common_vars.txdata[aa][i] = 0x00010001;
-
-#else //this is the normal case
- memset(&ue->common_vars.txdata[aa][0],0,
- (LTE_NUMBER_OF_SUBFRAMES_PER_FRAME*frame_parms->samples_per_subframe)*sizeof(int32_t));
-#endif //else EXMIMO
-
- }
- }
-}
-
-*/
-
void nr_ue_measurement_procedures(uint16_t l, // symbol index of each slot [0..6]
PHY_VARS_NR_UE *ue,
UE_nr_rxtx_proc_t *proc,
@@ -2217,74 +301,6 @@ void nr_ue_measurement_procedures(uint16_t l, // symbol index of each slot [0
VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_UE_MEASUREMENT_PROCEDURES, VCD_FUNCTION_OUT);
}
-
-
-#if 0
-void restart_phy(PHY_VARS_NR_UE *ue,UE_nr_rxtx_proc_t *proc, uint8_t eNB_id,uint8_t abstraction_flag)
-{
-
- // uint8_t last_slot;
- uint8_t i;
- LOG_I(PHY,"[UE %d] frame %d, slot %d, restarting PHY!\n",ue->Mod_id,proc->frame_rx,proc->nr_tti_rx);
- //mac_xface->macphy_exit("restart_phy called");
- // first_run = 1;
-
- if (abstraction_flag ==0 ) {
- ue->UE_mode[eNB_id] = NOT_SYNCHED;
- } else {
- ue->UE_mode[eNB_id] = PRACH;
- ue->prach_resources[eNB_id]=NULL;
- }
-
- proc->frame_rx = -1;
- proc->frame_tx = -1;
- // ue->synch_wait_cnt=0;
- // ue->sched_cnt=-1;
-
- ue->pbch_vars[eNB_id]->pdu_errors_conseq=0;
- ue->pbch_vars[eNB_id]->pdu_errors=0;
-
- ue->pdcch_vars[0][eNB_id]->dci_errors = 0;
- ue->pdcch_vars[0][eNB_id]->dci_missed = 0;
- ue->pdcch_vars[0][eNB_id]->dci_false = 0;
- ue->pdcch_vars[0][eNB_id]->dci_received = 0;
-
- ue->pdcch_vars[1][eNB_id]->dci_errors = 0;
- ue->pdcch_vars[1][eNB_id]->dci_missed = 0;
- ue->pdcch_vars[1][eNB_id]->dci_false = 0;
- ue->pdcch_vars[1][eNB_id]->dci_received = 0;
-
- ue->dlsch_errors[eNB_id] = 0;
- ue->dlsch_errors_last[eNB_id] = 0;
- ue->dlsch_received[eNB_id] = 0;
- ue->dlsch_received_last[eNB_id] = 0;
- ue->dlsch_fer[eNB_id] = 0;
- ue->dlsch_SI_received[eNB_id] = 0;
- ue->dlsch_ra_received[eNB_id] = 0;
- ue->dlsch_p_received[eNB_id] = 0;
- ue->dlsch_SI_errors[eNB_id] = 0;
- ue->dlsch_ra_errors[eNB_id] = 0;
- ue->dlsch_p_errors[eNB_id] = 0;
-
- ue->dlsch_mch_received[eNB_id] = 0;
-
- for (i=0; i < MAX_MBSFN_AREA ; i ++) {
- ue->dlsch_mch_received_sf[i][eNB_id] = 0;
- ue->dlsch_mcch_received[i][eNB_id] = 0;
- ue->dlsch_mtch_received[i][eNB_id] = 0;
- ue->dlsch_mcch_errors[i][eNB_id] = 0;
- ue->dlsch_mtch_errors[i][eNB_id] = 0;
- ue->dlsch_mcch_trials[i][eNB_id] = 0;
- ue->dlsch_mtch_trials[i][eNB_id] = 0;
- }
-
- //ue->total_TBS[eNB_id] = 0;
- //ue->total_TBS_last[eNB_id] = 0;
- //ue->bitrate[eNB_id] = 0;
- //ue->total_received_bits[eNB_id] = 0;
-}
-#endif //(0)
-
void nr_ue_pbch_procedures(uint8_t gNB_id,
PHY_VARS_NR_UE *ue,
UE_nr_rxtx_proc_t *proc,
@@ -2684,185 +700,6 @@ int nr_ue_pdcch_procedures(uint8_t gNB_id,
}
#endif // NR_PDCCH_SCHED
-
-
-
-#if 0
-
- if (generate_ue_dlsch_params_from_dci(frame_rx,
- nr_tti_rx,
- (DCI1A_5MHz_TDD_1_6_t *)&dci_alloc_rx[i].dci_pdu,
- ue->prach_resources[eNB_id]->ra_RNTI,
- format1A,
- ue->pdcch_vars[ue->current_thread_id[nr_tti_rx]][eNB_id],
- ue->pdsch_vars_ra[eNB_id],
- &ue->dlsch_ra[eNB_id],
- &ue->frame_parms,
- ue->pdsch_config_dedicated,
- SI_RNTI,
- ue->prach_resources[eNB_id]->ra_RNTI,
- P_RNTI,
- ue->transmission_mode[eNB_id]<7?0:ue->transmission_mode[eNB_id],
- 0)==0) {
-
- ue->dlsch_ra_received[eNB_id]++;
-
- #ifdef DEBUG_PHY_PROC
- LOG_D(PHY,"[UE %d] Generate UE DLSCH RA_RNTI format 1A, rb_alloc %x, dlsch_ra[eNB_id] %p\n",
- ue->Mod_id,ue->dlsch_ra[eNB_id]->harq_processes[0]->rb_alloc_even[0],ue->dlsch_ra[eNB_id]);
- #endif
- }
- } else if( (dci_alloc_rx[i].rnti == ue->pdcch_vars[ue->current_thread_id[nr_tti_rx]][eNB_id]->crnti) &&
- (dci_alloc_rx[i].format == format0)) {
-
- #ifdef DEBUG_PHY_PROC
- LOG_D(PHY,"[UE %d][PUSCH] Frame %d nr_tti_rx %d: Found rnti %x, format 0, dci_cnt %d\n",
- ue->Mod_id,frame_rx,nr_tti_rx,dci_alloc_rx[i].rnti,i);
- #endif
-
- ue->ulsch_no_allocation_counter[eNB_id] = 0;
- //dump_dci(&ue->frame_parms,&dci_alloc_rx[i]);
-
- if ((ue->UE_mode[eNB_id] > PRACH) &&
- (generate_ue_ulsch_params_from_dci((void *)&dci_alloc_rx[i].dci_pdu,
- ue->pdcch_vars[ue->current_thread_id[nr_tti_rx]][eNB_id]->crnti,
- nr_tti_rx,
- format0,
- ue,
- proc,
- SI_RNTI,
- 0,
- P_RNTI,
- CBA_RNTI,
- eNB_id,
- 0)==0)) {
- #if T_TRACER
- NR_DL_FRAME_PARMS *frame_parms = &ue->frame_parms;
- uint8_t harq_pid = subframe2harq_pid(frame_parms,
- pdcch_alloc2ul_frame(frame_parms,proc->frame_rx,proc->nr_tti_rx),
- pdcch_alloc2ul_subframe(frame_parms,proc->nr_tti_rx));
-
- T(T_UE_PHY_ULSCH_UE_DCI, T_INT(eNB_id), T_INT(proc->frame_rx%1024), T_INT(proc->nr_tti_rx), T_INT(ue->Mod_id),
- T_INT(dci_alloc_rx[i].rnti), T_INT(harq_pid),
- T_INT(ue->ulsch[eNB_id]->harq_processes[harq_pid]->mcs),
- T_INT(ue->ulsch[eNB_id]->harq_processes[harq_pid]->round),
- T_INT(ue->ulsch[eNB_id]->harq_processes[harq_pid]->first_rb),
- T_INT(ue->ulsch[eNB_id]->harq_processes[harq_pid]->nb_rb),
- T_INT(ue->ulsch[eNB_id]->harq_processes[harq_pid]->TBS));
- #endif
- #ifdef DEBUG_PHY_PROC
- LOG_D(PHY,"[UE %d] Generate UE ULSCH C_RNTI format 0 (nr_tti_rx %d)\n",ue->Mod_id,nr_tti_rx);
- #endif
-
- }
- } else if( (dci_alloc_rx[i].rnti == ue->ulsch[eNB_id]->cba_rnti[0]) &&
- (dci_alloc_rx[i].format == format0)) {
- // UE could belong to more than one CBA group
- // ue->Mod_id%ue->ulsch[eNB_id]->num_active_cba_groups]
- #ifdef DEBUG_PHY_PROC
- LOG_D(PHY,"[UE %d][PUSCH] Frame %d nr_tti_rx %d: Found cba rnti %x, format 0, dci_cnt %d\n",
- ue->Mod_id,frame_rx,nr_tti_rx,dci_alloc_rx[i].rnti,i);
-
- if (((frame_rx%100) == 0) || (frame_rx < 20))
- dump_dci(&ue->frame_parms, &dci_alloc_rx[i]);
-
- #endif
-
- ue->ulsch_no_allocation_counter[eNB_id] = 0;
- //dump_dci(&ue->frame_parms,&dci_alloc_rx[i]);
-
- if ((ue->UE_mode[eNB_id] > PRACH) &&
- (generate_ue_ulsch_params_from_dci((void *)&dci_alloc_rx[i].dci_pdu,
- ue->ulsch[eNB_id]->cba_rnti[0],
- nr_tti_rx,
- format0,
- ue,
- proc,
- SI_RNTI,
- 0,
- P_RNTI,
- CBA_RNTI,
- eNB_id,
- 0)==0)) {
-
- #ifdef DEBUG_PHY_PROC
- LOG_D(PHY,"[UE %d] Generate UE ULSCH CBA_RNTI format 0 (nr_tti_rx %d)\n",ue->Mod_id,nr_tti_rx);
- #endif
- ue->ulsch[eNB_id]->num_cba_dci[(nr_tti_rx+4)%10]++;
- }
- }
-
- else {
- #ifdef DEBUG_PHY_PROC
- LOG_D(PHY,"[UE %d] frame %d, nr_tti_rx %d: received DCI %d with RNTI=%x (C-RNTI:%x, CBA_RNTI %x) and format %d!\n",ue->Mod_id,frame_rx,nr_tti_rx,i,dci_alloc_rx[i].rnti,
- ue->pdcch_vars[ue->current_thread_id[nr_tti_rx]][eNB_id]->crnti,
- ue->ulsch[eNB_id]->cba_rnti[0],
- dci_alloc_rx[i].format);
-
- // dump_dci(&ue->frame_parms, &dci_alloc_rx[i]);
- #endif
- }*/
-
- } // end for loop dci_cnt
-#if UE_TIMING_TRACE
- stop_meas(&ue->dlsch_rx_pdcch_stats);
-#endif
- VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_UE_PDCCH_PROCEDURES, VCD_FUNCTION_OUT);
-
- // } // end if do_pdcch_monitoring_current_slot
- } // end for loop nb_searchspace_active
- return(0);
-}
-
-
-
-#endif
-
-
-#if 0
-void copy_harq_proc_struct(NR_DL_UE_HARQ_t *harq_processes_dest, NR_DL_UE_HARQ_t *current_harq_processes)
-{
-
- harq_processes_dest->B = current_harq_processes->B ;
- harq_processes_dest->C = current_harq_processes->C ;
- harq_processes_dest->DCINdi = current_harq_processes->DCINdi ;
- harq_processes_dest->F = current_harq_processes->F ;
- harq_processes_dest->G = current_harq_processes->G ;
- harq_processes_dest->K = current_harq_processes->K ;
- harq_processes_dest->Nl = current_harq_processes->Nl ;
- harq_processes_dest->Qm = current_harq_processes->Qm ;
- harq_processes_dest->TBS = current_harq_processes->TBS ;
- harq_processes_dest->b = current_harq_processes->b ;
- harq_processes_dest->codeword = current_harq_processes->codeword ;
- harq_processes_dest->delta_PUCCH = current_harq_processes->delta_PUCCH ;
- harq_processes_dest->dl_power_off = current_harq_processes->dl_power_off ;
- harq_processes_dest->first_tx = current_harq_processes->first_tx ;
- harq_processes_dest->mcs = current_harq_processes->mcs ;
- harq_processes_dest->mcs_table = current_harq_processes->mcs_table ;
- harq_processes_dest->mimo_mode = current_harq_processes->mimo_mode ;
- harq_processes_dest->nb_rb = current_harq_processes->nb_rb ;
- harq_processes_dest->pmi_alloc = current_harq_processes->pmi_alloc ;
- harq_processes_dest->rb_alloc_even[0] = current_harq_processes->rb_alloc_even[0] ;
- harq_processes_dest->rb_alloc_even[1] = current_harq_processes->rb_alloc_even[1] ;
- harq_processes_dest->rb_alloc_even[2] = current_harq_processes->rb_alloc_even[2] ;
- harq_processes_dest->rb_alloc_even[3] = current_harq_processes->rb_alloc_even[3] ;
- harq_processes_dest->rb_alloc_odd[0] = current_harq_processes->rb_alloc_odd[0] ;
- harq_processes_dest->rb_alloc_odd[1] = current_harq_processes->rb_alloc_odd[1] ;
- harq_processes_dest->rb_alloc_odd[2] = current_harq_processes->rb_alloc_odd[2] ;
- harq_processes_dest->rb_alloc_odd[3] = current_harq_processes->rb_alloc_odd[3] ;
- harq_processes_dest->round = current_harq_processes->round ;
- harq_processes_dest->rvidx = current_harq_processes->rvidx ;
- harq_processes_dest->status = current_harq_processes->status ;
- harq_processes_dest->vrb_type = current_harq_processes->vrb_type ;
-
-}
-#endif
-
-/*void copy_ack_struct(nr_harq_status_t *harq_ack_dest, nr_harq_status_t *current_harq_ack)
- {
- memcpy(harq_ack_dest, current_harq_ack, sizeof(nr_harq_status_t));
- }*/
-
int nr_ue_pdsch_procedures(PHY_VARS_NR_UE *ue, UE_nr_rxtx_proc_t *proc, int eNB_id, PDSCH_t pdsch, NR_UE_DLSCH_t *dlsch0, NR_UE_DLSCH_t *dlsch1) {
int nr_tti_rx = proc->nr_tti_rx;
@@ -2980,36 +817,12 @@ int nr_ue_pdsch_procedures(PHY_VARS_NR_UE *ue, UE_nr_rxtx_proc_t *proc, int eNB_
void nr_process_rar(nr_downlink_indication_t *dl_info) {
module_id_t module_id = dl_info->module_id;
- int cc_id = dl_info->cc_id, frame_rx = dl_info->proc->frame_rx, nr_tti_rx = dl_info->proc->nr_tti_rx, ta_command, k2, delta;
+ int cc_id = dl_info->cc_id, frame_rx = dl_info->proc->frame_rx, nr_tti_rx = dl_info->proc->nr_tti_rx, ta_command;
uint8_t gNB_index = dl_info->gNB_index; // *rar;
- //fapi_nr_dci_indication_t *dci_ind = dl_info->dci_ind;
PHY_VARS_NR_UE *ue = PHY_vars_UE_g[module_id][cc_id];
NR_UE_DLSCH_t *dlsch0 = ue->dlsch_ra[gNB_index];
UE_MODE_t UE_mode = ue->UE_mode[gNB_index];
NR_PRACH_RESOURCES_t *prach_resources = ue->prach_resources[gNB_index];
- uint16_t slots_per_frame = ue->frame_parms.slots_per_frame;
-
- uint8_t mu_pusch = 1, sliv_S, sliv_L;
- // definition table j Table 6.1.2.1.1-4
- uint8_t j = (mu_pusch==3)?3:(mu_pusch==2)?2:1;
- uint8_t table_6_1_2_1_1_2_time_dom_res_alloc_A[16][3]={ // for PUSCH from TS 38.214 subclause 6.1.2.1.1
- {j, 0,14}, // row index 1
- {j, 0,12}, // row index 2
- {j, 0,10}, // row index 3
- {j, 2,10}, // row index 4
- {j, 4,10}, // row index 5
- {j, 4,8}, // row index 6
- {j, 4,6}, // row index 7
- {j+1,0,14}, // row index 8
- {j+1,0,12}, // row index 9
- {j+1,0,10}, // row index 10
- {j+2,0,14}, // row index 11
- {j+2,0,12}, // row index 12
- {j+2,0,10}, // row index 13
- {j, 8,6}, // row index 14
- {j+3,0,14}, // row index 15
- {j+3,0,10} // row index 16
- };
LOG_D(PHY,"[UE %d][RAPROC] Frame %d subframe %d Received RAR mode %d\n", module_id, frame_rx, nr_tti_rx, UE_mode);
@@ -3021,6 +834,7 @@ void nr_process_rar(nr_downlink_indication_t *dl_info) {
ta_command = nr_ue_process_rar(ue->Mod_id,
cc_id,
frame_rx,
+ nr_tti_rx,
dlsch0->harq_processes[0]->b,
&ue->pdcch_vars[ue->current_thread_id[nr_tti_rx]][gNB_index]->pdcch_config[0].rnti,
prach_resources->ra_PreambleIndex,
@@ -3036,54 +850,9 @@ void nr_process_rar(nr_downlink_indication_t *dl_info) {
nr_process_timing_advance_rar(ue, dl_info->proc, ta_command);
- if (ue->mode != debug_prach) {
- ue->ulsch_Msg3_active[gNB_index] = 1;
- // TS 38.213 ch 8.3 Msg3 PUSCH
- // PUSCH time domain resource allocation A for normal CP
- // TS 38.214 ch 6.1.2.1.1
- k2 = table_6_1_2_1_1_2_time_dom_res_alloc_A[0][0];
- sliv_S = table_6_1_2_1_1_2_time_dom_res_alloc_A[0][1];
- sliv_L = table_6_1_2_1_1_2_time_dom_res_alloc_A[0][2];
-
- switch (mu_pusch) {
- case 0:
- delta = 2;
- break;
- case 1:
- delta = 3;
- break;
- case 2:
- delta = 4;
- break;
- case 3:
- delta = 6;
- break;
- }
-
- ue->Msg3_startSymbol[gNB_index] = sliv_S;
- ue->Msg3_Length[gNB_index] = sliv_L;
- ue->ulsch_Msg3_subframe[gNB_index] = (nr_tti_rx + k2 + delta) % slots_per_frame;
- if (nr_tti_rx + k2 + delta > slots_per_frame){
- ue->ulsch_Msg3_frame[gNB_index] = (frame_rx + 1) % 1024;
- } else {
- ue->ulsch_Msg3_frame[gNB_index] = frame_rx;
- }
-
- LOG_D(PHY,"[UE %d][RAPROC] Got Msg3_alloc Frame %d subframe %d: Msg3_frame %d, Msg3_subframe %d\n",
- ue->Mod_id,
- frame_rx,
- nr_tti_rx,
- ue->ulsch_Msg3_frame[gNB_index],
- ue->ulsch_Msg3_subframe[gNB_index]);
- // harq_pid = subframe2harq_pid(&ue->frame_parms,
- // ue->ulsch_Msg3_frame[gNB_index],
- // ue->ulsch_Msg3_subframe[gNB_index]);
- // ue->ulsch[gNB_index]->harq_processes[harq_pid]->round = 0;
- // ue->Msg3_timer[gNB_index] = 10;
- // ue->ulsch[gNB_index].power_offset = 6;
- // ue->ulsch_no_allocation_counter[gNB_index] = 0;
+ if (ue->mode != debug_prach)
ue->UE_mode[gNB_index] = RA_RESPONSE;
- }
+
} else {
LOG_W(PHY,"[UE %d][RAPROC] Received RAR preamble (%d) doesn't match !!!\n", ue->Mod_id, prach_resources->ra_PreambleIndex);
}
@@ -3867,8 +1636,7 @@ int is_pbch_in_slot(fapi_nr_config_request_t *config, int frame, int slot, NR_DL
int phy_procedures_nrUE_RX(PHY_VARS_NR_UE *ue,
UE_nr_rxtx_proc_t *proc,
- uint8_t eNB_id,
- uint8_t do_pdcch_flag,
+ uint8_t gNB_id,
runmode_t mode)
{
int frame_rx = proc->frame_rx;
@@ -3901,7 +1669,7 @@ int phy_procedures_nrUE_RX(PHY_VARS_NR_UE *ue,
// looking for pbch only in slot where it is supposed to be
if ((ue->decode_MIB == 1) && slot_pbch)
{
- LOG_I(PHY," ------ PBCH ChannelComp/LLR: frame.slot %d.%d ------ \n", frame_rx%1024, nr_tti_rx);
+ LOG_D(PHY," ------ PBCH ChannelComp/LLR: frame.slot %d.%d ------ \n", frame_rx%1024, nr_tti_rx);
for (int i=1; i<4; i++) {
nr_slot_fep(ue,
@@ -3919,13 +1687,13 @@ int phy_procedures_nrUE_RX(PHY_VARS_NR_UE *ue,
#endif
}
- nr_ue_pbch_procedures(eNB_id,ue,proc,0);
+ nr_ue_pbch_procedures(gNB_id, ue, proc, 0);
if (ue->no_timing_correction==0) {
- LOG_I(PHY,"start adjust sync slot = %d no timing %d\n", nr_tti_rx, ue->no_timing_correction);
+ LOG_D(PHY,"start adjust sync slot = %d no timing %d\n", nr_tti_rx, ue->no_timing_correction);
nr_adjust_synch_ue(fp,
ue,
- eNB_id,
+ gNB_id,
frame_rx,
nr_tti_rx,
0,
@@ -3966,19 +1734,19 @@ int phy_procedures_nrUE_RX(PHY_VARS_NR_UE *ue,
#endif
//printf("phy procedure pdcch start measurement l =%d\n",l);
- //nr_ue_measurement_procedures(l,ue,proc,eNB_id,(nr_tti_rx),mode);
+ //nr_ue_measurement_procedures(l,ue,proc,gNB_id,(nr_tti_rx),mode);
}
- dci_cnt = nr_ue_pdcch_procedures(eNB_id, ue, proc);
+ dci_cnt = nr_ue_pdcch_procedures(gNB_id, ue, proc);
if (dci_cnt > 0) {
LOG_D(PHY,"[UE %d] Frame %d, nr_tti_rx %d: found %d DCIs\n", ue->Mod_id, frame_rx, nr_tti_rx, dci_cnt);
NR_UE_DLSCH_t *dlsch = NULL;
- if (ue->dlsch[ue->current_thread_id[nr_tti_rx]][eNB_id][0]->active == 1){
- dlsch = ue->dlsch[ue->current_thread_id[nr_tti_rx]][eNB_id][0];
+ if (ue->dlsch[ue->current_thread_id[nr_tti_rx]][gNB_id][0]->active == 1){
+ dlsch = ue->dlsch[ue->current_thread_id[nr_tti_rx]][gNB_id][0];
} else if (ue->dlsch_ra[0]->active == 1){
dlsch = ue->dlsch_ra[0];
}
@@ -4017,64 +1785,64 @@ int phy_procedures_nrUE_RX(PHY_VARS_NR_UE *ue,
#endif
// do procedures for C-RNTI
int ret_pdsch = 0;
- if (ue->dlsch[ue->current_thread_id[nr_tti_rx]][eNB_id][0]->active == 1) {
+ if (ue->dlsch[ue->current_thread_id[nr_tti_rx]][gNB_id][0]->active == 1) {
//VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_PDSCH_PROC, VCD_FUNCTION_IN);
ret_pdsch = nr_ue_pdsch_procedures(ue,
proc,
- eNB_id,
+ gNB_id,
PDSCH,
- ue->dlsch[ue->current_thread_id[nr_tti_rx]][eNB_id][0],
+ ue->dlsch[ue->current_thread_id[nr_tti_rx]][gNB_id][0],
NULL);
//printf("phy procedure pdsch start measurement\n");
- nr_ue_measurement_procedures(2,ue,proc,eNB_id,nr_tti_rx,mode);
+ nr_ue_measurement_procedures(2,ue,proc,gNB_id,nr_tti_rx,mode);
/*
write_output("rxF.m","rxF",&ue->common_vars.common_vars_rx_data_per_thread[ue->current_thread_id[nr_tti_rx]].rxdataF[0][0],fp->ofdm_symbol_size*14,1,1);
- write_output("rxF_ch.m","rxFch",&ue->pdsch_vars[ue->current_thread_id[nr_tti_rx]][eNB_id]->dl_ch_estimates[0][0],fp->ofdm_symbol_size*14,1,1);
- write_output("rxF_ch_ext.m","rxFche",&ue->pdsch_vars[ue->current_thread_id[nr_tti_rx]][eNB_id]->dl_ch_estimates_ext[0][2*50*12],50*12,1,1);
- write_output("rxF_ext.m","rxFe",&ue->pdsch_vars[ue->current_thread_id[nr_tti_rx]][eNB_id]->rxdataF_ext[0][0],50*12*14,1,1);
- write_output("rxF_comp.m","rxFc",&ue->pdsch_vars[ue->current_thread_id[nr_tti_rx]][eNB_id]->rxdataF_comp0[0][0],fp->N_RB_DL*12*14,1,1);
- write_output("rxF_llr.m","rxFllr",ue->pdsch_vars[ue->current_thread_id[nr_tti_rx]][eNB_id]->llr[0],(nb_symb_sch-1)*50*12+50*6,1,0);
+ write_output("rxF_ch.m","rxFch",&ue->pdsch_vars[ue->current_thread_id[nr_tti_rx]][gNB_id]->dl_ch_estimates[0][0],fp->ofdm_symbol_size*14,1,1);
+ write_output("rxF_ch_ext.m","rxFche",&ue->pdsch_vars[ue->current_thread_id[nr_tti_rx]][gNB_id]->dl_ch_estimates_ext[0][2*50*12],50*12,1,1);
+ write_output("rxF_ext.m","rxFe",&ue->pdsch_vars[ue->current_thread_id[nr_tti_rx]][gNB_id]->rxdataF_ext[0][0],50*12*14,1,1);
+ write_output("rxF_comp.m","rxFc",&ue->pdsch_vars[ue->current_thread_id[nr_tti_rx]][gNB_id]->rxdataF_comp0[0][0],fp->N_RB_DL*12*14,1,1);
+ write_output("rxF_llr.m","rxFllr",ue->pdsch_vars[ue->current_thread_id[nr_tti_rx]][gNB_id]->llr[0],(nb_symb_sch-1)*50*12+50*6,1,0);
*/
//VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_PDSCH_PROC, VCD_FUNCTION_OUT);
}
// do procedures for SI-RNTI
- if ((ue->dlsch_SI[eNB_id]) && (ue->dlsch_SI[eNB_id]->active == 1)) {
+ if ((ue->dlsch_SI[gNB_id]) && (ue->dlsch_SI[gNB_id]->active == 1)) {
VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_PDSCH_PROC_SI, VCD_FUNCTION_IN);
nr_ue_pdsch_procedures(ue,
proc,
- eNB_id,
+ gNB_id,
SI_PDSCH,
- ue->dlsch_SI[eNB_id],
+ ue->dlsch_SI[gNB_id],
NULL);
VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_PDSCH_PROC_SI, VCD_FUNCTION_OUT);
}
// do procedures for SI-RNTI
- if ((ue->dlsch_p[eNB_id]) && (ue->dlsch_p[eNB_id]->active == 1)) {
+ if ((ue->dlsch_p[gNB_id]) && (ue->dlsch_p[gNB_id]->active == 1)) {
VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_PDSCH_PROC_P, VCD_FUNCTION_IN);
nr_ue_pdsch_procedures(ue,
proc,
- eNB_id,
+ gNB_id,
P_PDSCH,
- ue->dlsch_p[eNB_id],
+ ue->dlsch_p[gNB_id],
NULL);
VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_PDSCH_PROC_P, VCD_FUNCTION_OUT);
}
// do procedures for RA-RNTI
- if ((ue->dlsch_ra[eNB_id]) && (ue->dlsch_ra[eNB_id]->active == 1)) {
+ if ((ue->dlsch_ra[gNB_id]) && (ue->dlsch_ra[gNB_id]->active == 1)) {
VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_PDSCH_PROC_RA, VCD_FUNCTION_IN);
nr_ue_pdsch_procedures(ue,
proc,
- eNB_id,
+ gNB_id,
RA_PDSCH,
- ue->dlsch_ra[eNB_id],
+ ue->dlsch_ra[gNB_id],
NULL);
// #if UE_TIMING_TRACE
@@ -4083,11 +1851,11 @@ int phy_procedures_nrUE_RX(PHY_VARS_NR_UE *ue,
nr_ue_dlsch_procedures(ue,
proc,
- eNB_id,
+ gNB_id,
RA_PDSCH,
- ue->dlsch_ra[eNB_id],
+ ue->dlsch_ra[gNB_id],
NULL,
- &ue->dlsch_ra_errors[eNB_id],
+ &ue->dlsch_ra_errors[gNB_id],
mode);
// #if UE_TIMING_TRACE
@@ -4105,7 +1873,7 @@ int phy_procedures_nrUE_RX(PHY_VARS_NR_UE *ue,
}
// do procedures for C-RNTI
- if (ue->dlsch[ue->current_thread_id[nr_tti_rx]][eNB_id][0]->active == 1) {
+ if (ue->dlsch[ue->current_thread_id[nr_tti_rx]][gNB_id][0]->active == 1) {
LOG_D(PHY, "DLSCH data reception at nr_tti_rx: %d \n \n", nr_tti_rx);
VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_PDSCH_PROC, VCD_FUNCTION_IN);
@@ -4117,11 +1885,11 @@ int phy_procedures_nrUE_RX(PHY_VARS_NR_UE *ue,
if (ret_pdsch >= 0)
nr_ue_dlsch_procedures(ue,
proc,
- eNB_id,
+ gNB_id,
PDSCH,
- ue->dlsch[ue->current_thread_id[nr_tti_rx]][eNB_id][0],
- ue->dlsch[ue->current_thread_id[nr_tti_rx]][eNB_id][1],
- &ue->dlsch_errors[eNB_id],
+ ue->dlsch[ue->current_thread_id[nr_tti_rx]][gNB_id][0],
+ ue->dlsch[ue->current_thread_id[nr_tti_rx]][gNB_id][1],
+ &ue->dlsch_errors[gNB_id],
mode);
@@ -4138,7 +1906,7 @@ int phy_procedures_nrUE_RX(PHY_VARS_NR_UE *ue,
#endif
// deactivate dlsch once dlsch proc is done
- ue->dlsch[ue->current_thread_id[nr_tti_rx]][eNB_id][0]->active = 0;
+ ue->dlsch[ue->current_thread_id[nr_tti_rx]][gNB_id][0]->active = 0;
VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_PDSCH_PROC, VCD_FUNCTION_OUT);
@@ -4149,9 +1917,9 @@ start_meas(&ue->generic_stat);
#if 0
- if(nr_tti_rx==5 && ue->dlsch[ue->current_thread_id[nr_tti_rx]][eNB_id][0]->harq_processes[ue->dlsch[ue->current_thread_id[nr_tti_rx]][eNB_id][0]->current_harq_pid]->nb_rb > 20){
+ if(nr_tti_rx==5 && ue->dlsch[ue->current_thread_id[nr_tti_rx]][gNB_id][0]->harq_processes[ue->dlsch[ue->current_thread_id[nr_tti_rx]][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[eNB_id]->llr[0][0],(14*nb_rb*12*dlsch1_harq->Qm) - 4*(nb_rb*4*dlsch1_harq->Qm),1,0);
+ //write_output("llr.m","llr", &ue->pdsch_vars[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[ue->current_thread_id[nr_tti_rx]].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);
@@ -4169,78 +1937,78 @@ start_meas(&ue->generic_stat);
#endif
// do procedures for SI-RNTI
- if ((ue->dlsch_SI[eNB_id]) && (ue->dlsch_SI[eNB_id]->active == 1)) {
+ if ((ue->dlsch_SI[gNB_id]) && (ue->dlsch_SI[gNB_id]->active == 1)) {
nr_ue_pdsch_procedures(ue,
proc,
- eNB_id,
+ gNB_id,
SI_PDSCH,
- ue->dlsch_SI[eNB_id],
+ ue->dlsch_SI[gNB_id],
NULL);
/*ue_dlsch_procedures(ue,
proc,
- eNB_id,
+ gNB_id,
SI_PDSCH,
- ue->dlsch_SI[eNB_id],
+ ue->dlsch_SI[gNB_id],
NULL,
- &ue->dlsch_SI_errors[eNB_id],
+ &ue->dlsch_SI_errors[gNB_id],
mode,
abstraction_flag);
- ue->dlsch_SI[eNB_id]->active = 0;*/
+ ue->dlsch_SI[gNB_id]->active = 0;*/
}
// do procedures for P-RNTI
- if ((ue->dlsch_p[eNB_id]) && (ue->dlsch_p[eNB_id]->active == 1)) {
+ if ((ue->dlsch_p[gNB_id]) && (ue->dlsch_p[gNB_id]->active == 1)) {
nr_ue_pdsch_procedures(ue,
proc,
- eNB_id,
+ gNB_id,
P_PDSCH,
- ue->dlsch_p[eNB_id],
+ ue->dlsch_p[gNB_id],
NULL);
/*ue_dlsch_procedures(ue,
proc,
- eNB_id,
+ gNB_id,
P_PDSCH,
- ue->dlsch_p[eNB_id],
+ ue->dlsch_p[gNB_id],
NULL,
- &ue->dlsch_p_errors[eNB_id],
+ &ue->dlsch_p_errors[gNB_id],
mode,
abstraction_flag);*/
- ue->dlsch_p[eNB_id]->active = 0;
+ ue->dlsch_p[gNB_id]->active = 0;
}
// do procedures for RA-RNTI
- if ((ue->dlsch_ra[eNB_id]) && (ue->dlsch_ra[eNB_id]->active == 1)) {
+ if ((ue->dlsch_ra[gNB_id]) && (ue->dlsch_ra[gNB_id]->active == 1)) {
nr_ue_pdsch_procedures(ue,
proc,
- eNB_id,
+ gNB_id,
RA_PDSCH,
- ue->dlsch_ra[eNB_id],
+ ue->dlsch_ra[gNB_id],
NULL);
/*ue_dlsch_procedures(ue,
proc,
- eNB_id,
+ gNB_id,
RA_PDSCH,
- ue->dlsch_ra[eNB_id],
+ ue->dlsch_ra[gNB_id],
NULL,
- &ue->dlsch_ra_errors[eNB_id],
+ &ue->dlsch_ra_errors[gNB_id],
mode,
abstraction_flag);*/
- ue->dlsch_ra[eNB_id]->active = 0;
+ ue->dlsch_ra[gNB_id]->active = 0;
}
// duplicate harq structure
/*
- uint8_t current_harq_pid = ue->dlsch[ue->current_thread_id[nr_tti_rx]][eNB_id][0]->current_harq_pid;
- NR_DL_UE_HARQ_t *current_harq_processes = ue->dlsch[ue->current_thread_id[nr_tti_rx]][eNB_id][0]->harq_processes[current_harq_pid];
- NR_DL_UE_HARQ_t *harq_processes_dest = ue->dlsch[next1_thread_id][eNB_id][0]->harq_processes[current_harq_pid];
- NR_DL_UE_HARQ_t *harq_processes_dest1 = ue->dlsch[next2_thread_id][eNB_id][0]->harq_processes[current_harq_pid];
+ uint8_t current_harq_pid = ue->dlsch[ue->current_thread_id[nr_tti_rx]][gNB_id][0]->current_harq_pid;
+ NR_DL_UE_HARQ_t *current_harq_processes = ue->dlsch[ue->current_thread_id[nr_tti_rx]][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[ue->current_thread_id[nr_tti_rx]][eNB_id][0]->harq_ack[nr_tti_rx];
- nr_harq_status_t *harq_ack_dest = &ue->dlsch[next1_thread_id][eNB_id][0]->harq_ack[nr_tti_rx];
- nr_harq_status_t *harq_ack_dest1 = &ue->dlsch[next2_thread_id][eNB_id][0]->harq_ack[nr_tti_rx];
+ /*nr_harq_status_t *current_harq_ack = &ue->dlsch[ue->current_thread_id[nr_tti_rx]][gNB_id][0]->harq_ack[nr_tti_rx];
+ nr_harq_status_t *harq_ack_dest = &ue->dlsch[next1_thread_id][gNB_id][0]->harq_ack[nr_tti_rx];
+ nr_harq_status_t *harq_ack_dest1 = &ue->dlsch[next2_thread_id][gNB_id][0]->harq_ack[nr_tti_rx];
*/
//copy_harq_proc_struct(harq_processes_dest, current_harq_processes);
@@ -4251,23 +2019,23 @@ start_meas(&ue->generic_stat);
if (nr_tti_rx==9) {
if (frame_rx % 10 == 0) {
- if ((ue->dlsch_received[eNB_id] - ue->dlsch_received_last[eNB_id]) != 0)
- ue->dlsch_fer[eNB_id] = (100*(ue->dlsch_errors[eNB_id] - ue->dlsch_errors_last[eNB_id]))/(ue->dlsch_received[eNB_id] - ue->dlsch_received_last[eNB_id]);
+ 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[eNB_id] = ue->dlsch_errors[eNB_id];
- ue->dlsch_received_last[eNB_id] = ue->dlsch_received[eNB_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[eNB_id] = (ue->total_TBS[eNB_id] - ue->total_TBS_last[eNB_id])*100;
- ue->total_TBS_last[eNB_id] = ue->total_TBS[eNB_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[eNB_id],
- ue->total_TBS_last[eNB_id],(float) ue->bitrate[eNB_id]/1000.0);
+ 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[eNB_id]/1000.0, frame_rx);
+ 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
@@ -4279,7 +2047,7 @@ printf("after tubo until end of Rx %5.2f \n",ue->generic_stat.p_time/(cpuf*1000.
#endif
#ifdef EMOS
-phy_procedures_emos_UE_RX(ue,slot,eNB_id);
+phy_procedures_emos_UE_RX(ue,slot,gNB_id);
#endif
diff --git a/openair1/SIMULATION/NR_PHY/dlsim.c b/openair1/SIMULATION/NR_PHY/dlsim.c
index 257fc56b85..0aaff7afed 100644
--- a/openair1/SIMULATION/NR_PHY/dlsim.c
+++ b/openair1/SIMULATION/NR_PHY/dlsim.c
@@ -198,7 +198,7 @@ int main(int argc, char **argv)
int frame=1,slot=1;
int frame_length_complex_samples;
- int frame_length_complex_samples_no_prefix;
+ //int frame_length_complex_samples_no_prefix;
NR_DL_FRAME_PARMS *frame_parms;
UE_nr_rxtx_proc_t UE_proc;
NR_Sched_Rsp_t Sched_INFO;
@@ -206,12 +206,11 @@ 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 do_pdcch_flag=1;
int pusch_tgt_snrx10 = 200;
int pucch_tgt_snrx10 = 200;
int loglvl=OAILOG_INFO;
- float target_error_rate = 0.01;
+ //float target_error_rate = 0.01;
int css_flag=0;
cpuf = get_cpu_freq_GHz();
@@ -373,7 +372,7 @@ int main(int argc, char **argv)
case 'I':
run_initial_sync=1;
- target_error_rate=0.1;
+ //target_error_rate=0.1;
slot = 0;
break;
@@ -599,7 +598,7 @@ int main(int argc, char **argv)
}
frame_length_complex_samples = frame_parms->samples_per_subframe*NR_NUMBER_OF_SUBFRAMES_PER_FRAME;
- frame_length_complex_samples_no_prefix = frame_parms->samples_per_subframe_wCP*NR_NUMBER_OF_SUBFRAMES_PER_FRAME;
+ //frame_length_complex_samples_no_prefix = frame_parms->samples_per_subframe_wCP*NR_NUMBER_OF_SUBFRAMES_PER_FRAME;
s_re = malloc(2*sizeof(double*));
s_im = malloc(2*sizeof(double*));
@@ -712,7 +711,7 @@ int main(int argc, char **argv)
nr_ue_phy_config_request(&UE_mac->phy_config);
- NR_UE_list_t *UE_list = &RC.nrmac[0]->UE_list;
+ NR_UE_info_t *UE_info = &RC.nrmac[0]->UE_info;
//NR_COMMON_channels_t *cc = RC.nrmac[0]->common_channels;
snrRun = 0;
@@ -773,11 +772,11 @@ int main(int argc, char **argv)
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_list->UE_sched_ctrl[0].harq_processes[harq_pid].ndi = !(trial&1);
+ UE_info->UE_sched_ctrl[0].harq_processes[harq_pid].ndi = !(trial&1);
- UE_list->UE_sched_ctrl[0].harq_processes[harq_pid].round = round;
- UE_list->UE_sched_ctrl[0].current_harq_pid = harq_pid;
+ UE_info->UE_sched_ctrl[0].harq_processes[harq_pid].round = round;
+ UE_info->UE_sched_ctrl[0].current_harq_pid = harq_pid;
gNB->dlsch[0][0]->harq_processes[harq_pid]->round = round;
if (css_flag == 0) nr_schedule_uss_dlsch_phytest(0,frame,slot,&pucch_sched,&dlsch_config);
@@ -897,7 +896,6 @@ int main(int argc, char **argv)
phy_procedures_nrUE_RX(UE,
&UE_proc,
0,
- do_pdcch_flag,
normal_txrx);
//printf("dlsim round %d ends\n",round);
diff --git a/openair1/SIMULATION/NR_PHY/nr_unitary_defs.h b/openair1/SIMULATION/NR_PHY/nr_unitary_defs.h
index 7a465e0ea3..a7150fb2f9 100644
--- a/openair1/SIMULATION/NR_PHY/nr_unitary_defs.h
+++ b/openair1/SIMULATION/NR_PHY/nr_unitary_defs.h
@@ -235,8 +235,8 @@ void fill_scc(NR_ServingCellConfigCommon_t *scc,uint64_t *ssb_bitmap,int N_RB_DL
void fix_scc(NR_ServingCellConfigCommon_t *scc,uint64_t ssbmap);
void prepare_scc(NR_ServingCellConfigCommon_t *scc);
-s1ap_eNB_config_t s1ap_config;
-uint32_t s1ap_generate_eNB_id(void) {return 0;}
+ngap_gNB_config_t ngap_config;
+uint32_t ngap_generate_gNB_id(void) {return 0;}
void configure_nfapi_pnf(char *vnf_ip_addr, int vnf_p5_port, char *pnf_ip_addr, int pnf_p7_port, int vnf_p7_port) { return;}
void configure_nfapi_vnf(char *vnf_addr, int vnf_p5_port) { return;}
diff --git a/openair1/SIMULATION/NR_PHY/ulschsim.c b/openair1/SIMULATION/NR_PHY/ulschsim.c
index f6d33c1d4b..f2662d9fe6 100644
--- a/openair1/SIMULATION/NR_PHY/ulschsim.c
+++ b/openair1/SIMULATION/NR_PHY/ulschsim.c
@@ -45,6 +45,7 @@
#include "openair1/SIMULATION/RF/rf.h"
#include "openair1/SIMULATION/NR_PHY/nr_unitary_defs.h"
#include "openair1/SIMULATION/NR_PHY/nr_dummy_functions.c"
+#include "common/utils/threadPool/thread-pool.h"
//#define DEBUG_NR_ULSCHSIM
@@ -67,6 +68,44 @@ PHY_VARS_NR_UE *PHY_vars_UE_g[1][1] = { { NULL } };
uint16_t n_rnti = 0x1234;
openair0_config_t openair0_cfg[MAX_CARDS];
+int nr_postDecode_sim(PHY_VARS_gNB *gNB, notifiedFIFO_elt_t *req) {
+ ldpcDecode_t *rdata = (ldpcDecode_t*) NotifiedFifoData(req);
+ NR_UL_gNB_HARQ_t *ulsch_harq = rdata->ulsch_harq;
+ NR_gNB_ULSCH_t *ulsch = rdata->ulsch;
+ int r = rdata->segment_r;
+
+ bool decodeSuccess = (rdata->decodeIterations <= rdata->decoderParms.numMaxIter);
+ ulsch_harq->processedSegments++;
+ gNB->nbDecode--;
+
+ if (decodeSuccess) {
+ memcpy(ulsch_harq->b+rdata->offset,
+ ulsch_harq->c[r],
+ rdata->Kr_bytes- - (ulsch_harq->F>>3) -((ulsch_harq->C>1)?3:0));
+ } else {
+ if ( rdata->nbSegments != ulsch_harq->processedSegments ) {
+ int nb=abortTpool(gNB->threadPool, req->key);
+ nb+=abortNotifiedFIFO(gNB->respDecode, req->key);
+ gNB->nbDecode-=nb;
+ AssertFatal(ulsch_harq->processedSegments+nb == rdata->nbSegments,"processed: %d, aborted: %d, total %d\n",
+ ulsch_harq->processedSegments, nb, rdata->nbSegments);
+ ulsch_harq->processedSegments=rdata->nbSegments;
+ return 1;
+ }
+ }
+
+ // if all segments are done
+ if (rdata->nbSegments == ulsch_harq->processedSegments) {
+ if (decodeSuccess) {
+ return 0;
+ } else {
+ return 1;
+ }
+
+ }
+ ulsch->last_iteration_cnt = rdata->decodeIterations;
+ return 0;
+}
int main(int argc, char **argv)
{
char c;
@@ -92,7 +131,7 @@ int main(int argc, char **argv)
NR_DL_FRAME_PARMS *frame_parms;
double sigma;
unsigned char qbits = 8;
- int ret;
+ int ret=0;
int loglvl = OAILOG_WARNING;
uint64_t SSB_positions=0x01;
uint16_t nb_symb_sch = 12;
@@ -338,6 +377,11 @@ int main(int argc, char **argv)
gNB = RC.gNB[0];
//gNB_config = &gNB->gNB_config;
+ gNB->threadPool = (tpool_t*)malloc(sizeof(tpool_t));
+ gNB->respDecode = (notifiedFIFO_t*) malloc(sizeof(notifiedFIFO_t));
+ char tp_param[] = "n";
+ initTpool(tp_param, gNB->threadPool, true);
+ initNotifiedFIFO(gNB->respDecode);
frame_parms = &gNB->frame_parms; //to be initialized I suppose (maybe not necessary for PBCH)
frame_parms->nb_antennas_tx = n_tx;
frame_parms->nb_antennas_rx = n_rx;
@@ -408,7 +452,7 @@ int main(int argc, char **argv)
rel15_ul->pusch_data.rv_index = rvidx;
rel15_ul->nrOfLayers = Nl;
rel15_ul->target_code_rate = code_rate;
- rel15_ul->pusch_data.tb_size = TBS>>3;
+ rel15_ul->pusch_data.tb_size = TBS/8;
///////////////////////////////////////////////////
double *modulated_input = malloc16(sizeof(double) * 16 * 68 * 384); // [hna] 16 segments, 68*Zc
@@ -444,7 +488,7 @@ int main(int argc, char **argv)
harq_process_ul_ue->pusch_pdu.nr_of_symbols = nb_symb_sch;
harq_process_ul_ue->num_of_mod_symbols = N_RE_prime*nb_rb*nb_codewords;
harq_process_ul_ue->pusch_pdu.pusch_data.rv_index = rvidx;
- harq_process_ul_ue->pusch_pdu.pusch_data.tb_size = TBS;
+ harq_process_ul_ue->pusch_pdu.pusch_data.tb_size = TBS/8;
harq_process_ul_ue->a = &test_input[0];
}
@@ -531,10 +575,15 @@ int main(int argc, char **argv)
rel15_ul->qam_mod_order,
rel15_ul->nrOfLayers);
- ret = nr_ulsch_decoding(gNB, UE_id, channel_output_fixed, frame_parms, rel15_ul,
+ nr_ulsch_decoding(gNB, UE_id, channel_output_fixed, frame_parms, rel15_ul,
frame, subframe, harq_pid, G);
+ while (gNB->nbDecode > 0) {
+ notifiedFIFO_elt_t *req=pullTpool(gNB->respDecode, gNB->threadPool);
+ ret = nr_postDecode_sim(gNB, req);
+ delNotifiedFIFO_elt(req);
+ }
- if (ret > ulsch_gNB->max_ldpc_iterations)
+ if (ret)
n_errors++;
//count errors
diff --git a/openair1/SIMULATION/NR_PHY/ulsim.c b/openair1/SIMULATION/NR_PHY/ulsim.c
index da8f19c61d..4be07e426d 100644
--- a/openair1/SIMULATION/NR_PHY/ulsim.c
+++ b/openair1/SIMULATION/NR_PHY/ulsim.c
@@ -55,6 +55,8 @@
//#include "openair1/SIMULATION/NR_PHY/nr_dummy_functions.c"
#include "openair2/LAYER2/NR_MAC_UE/mac_proto.h"
#include "openair2/LAYER2/NR_MAC_gNB/mac_proto.h"
+#include "common/utils/threadPool/thread-pool.h"
+
#define inMicroS(a) (((double)(a))/(cpu_freq_GHz*1000.0))
#include "SIMULATION/LTE_PHY/common_sim.h"
@@ -199,6 +201,7 @@ int main(int argc, char **argv)
int pucch_tgt_snrx10 = 200;
int ibwps=24;
int ibwp_rboffset=41;
+ int params_from_file = 0;
if ( load_configmodule(argc,argv,CONFIG_ENABLECMDLINEONLY) == 0 ) {
exit_fun("[NR_ULSIM] Error, configuration module init failed\n");
}
@@ -435,6 +438,10 @@ int main(int argc, char **argv)
}
break;
+ case 'Q':
+ params_from_file = 1;
+ break;
+
default:
case 'h':
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]);
@@ -456,7 +463,7 @@ int main(int argc, char **argv)
printf("-A Interpolation_filname Run with Abstraction to generate Scatter plot using interpolation polynomial in file\n");
//printf("-C Generate Calibration information for Abstraction (effective SNR adjustment to remove Pe bias w.r.t. AWGN)\n");
printf("-F Input filename (.txt format) for RX conformance testing\n");
- printf("-G raw file containing RRC configuration (generated by gNB)\n");
+ printf("-G Offset of samples to read from file (0 default)\n");
printf("-M Multiple SSB positions in burst\n");
printf("-N Nid_cell\n");
printf("-O oversampling factor (1,2,4,8,16)\n");
@@ -466,6 +473,7 @@ int main(int argc, char **argv)
printf("-P Print ULSCH performances\n");
printf("-T Enable PTRS, arguments list L_PTRS{0,1,2} K_PTRS{2,4}, e.g. -T 2 0 2 \n");
printf("-U Change DMRS Config, arguments list DMRS TYPE{0=A,1=B} DMRS AddPos{0:3}, e.g. -U 2 0 2 \n");
+ printf("-Q If -F used, read parameters from file\n");
exit(-1);
break;
@@ -512,6 +520,11 @@ int main(int argc, char **argv)
RC.gNB = (PHY_VARS_gNB **) malloc(sizeof(PHY_VARS_gNB *));
RC.gNB[0] = calloc(1,sizeof(PHY_VARS_gNB));
gNB = RC.gNB[0];
+ gNB->threadPool = (tpool_t*)malloc(sizeof(tpool_t));
+ gNB->respDecode = (notifiedFIFO_t*) malloc(sizeof(notifiedFIFO_t));
+ char tp_param[] = "n";
+ initTpool(tp_param, gNB->threadPool, true);
+ initNotifiedFIFO(gNB->respDecode);
//gNB_config = &gNB->gNB_config;
//memset((void *)&gNB->UL_INFO,0,sizeof(gNB->UL_INFO));
@@ -734,6 +747,7 @@ int main(int argc, char **argv)
//for (int i=0;i<16;i++) printf("%f\n",gaussdouble(0.0,1.0));
snrRun = 0;
int n_errs = 0;
+ int read_errors=0;
int slot_offset = frame_parms->get_samples_slot_timestamp(slot,frame_parms,0);
int slot_length = slot_offset - frame_parms->get_samples_slot_timestamp(slot-1,frame_parms,0);
@@ -743,35 +757,39 @@ int main(int argc, char **argv)
// 800 samples is N_TA_OFFSET for FR1 @ 30.72 Ms/s,
AssertFatal(frame_parms->subcarrier_spacing==30000,"only 30 kHz for file input for now (%d)\n",frame_parms->subcarrier_spacing);
- fseek(input_fd,file_offset*((slot_length<<2)+4000+16),SEEK_SET);
- fread((void*)&n_rnti,sizeof(int16_t),1,input_fd);
- printf("rnti %x\n",n_rnti);
- fread((void*)&nb_rb,sizeof(int16_t),1,input_fd);
- printf("nb_rb %d\n",nb_rb);
- int16_t dummy;
- fread((void*)&start_rb,sizeof(int16_t),1,input_fd);
- //fread((void*)&dummy,sizeof(int16_t),1,input_fd);
- printf("rb_start %d\n",start_rb);
- fread((void*)&nb_symb_sch,sizeof(int16_t),1,input_fd);
- //fread((void*)&dummy,sizeof(int16_t),1,input_fd);
- printf("nb_symb_sch %d\n",nb_symb_sch);
- fread((void*)&start_symbol,sizeof(int16_t),1,input_fd);
- printf("start_symbol %d\n",start_symbol);
- fread((void*)&Imcs,sizeof(int16_t),1,input_fd);
- printf("mcs %d\n",Imcs);
- fread((void*)&rv_index,sizeof(int16_t),1,input_fd);
- printf("rv_index %d\n",rv_index);
- // fread((void*)&harq_pid,sizeof(int16_t),1,input_fd);
- fread((void*)&dummy,sizeof(int16_t),1,input_fd);
- printf("harq_pid %d\n",harq_pid);
- fread((void*)&gNB->common_vars.rxdata[0][slot_offset-delay],
- sizeof(int16_t),
- slot_length<<1,
- input_fd);
+ if (params_from_file) {
+ fseek(input_fd,file_offset*((slot_length<<2)+4000+16),SEEK_SET);
+ read_errors+=fread((void*)&n_rnti,sizeof(int16_t),1,input_fd);
+ printf("rnti %x\n",n_rnti);
+ read_errors+=fread((void*)&nb_rb,sizeof(int16_t),1,input_fd);
+ printf("nb_rb %d\n",nb_rb);
+ int16_t dummy;
+ read_errors+=fread((void*)&start_rb,sizeof(int16_t),1,input_fd);
+ //fread((void*)&dummy,sizeof(int16_t),1,input_fd);
+ printf("rb_start %d\n",start_rb);
+ read_errors+=fread((void*)&nb_symb_sch,sizeof(int16_t),1,input_fd);
+ //fread((void*)&dummy,sizeof(int16_t),1,input_fd);
+ printf("nb_symb_sch %d\n",nb_symb_sch);
+ read_errors+=fread((void*)&start_symbol,sizeof(int16_t),1,input_fd);
+ printf("start_symbol %d\n",start_symbol);
+ read_errors+=fread((void*)&Imcs,sizeof(int16_t),1,input_fd);
+ printf("mcs %d\n",Imcs);
+ read_errors+=fread((void*)&rv_index,sizeof(int16_t),1,input_fd);
+ printf("rv_index %d\n",rv_index);
+ // fread((void*)&harq_pid,sizeof(int16_t),1,input_fd);
+ read_errors+=fread((void*)&dummy,sizeof(int16_t),1,input_fd);
+ printf("harq_pid %d\n",harq_pid);
+ }
+ fseek(input_fd,file_offset*sizeof(int16_t)*2,SEEK_SET);
+ read_errors+=fread((void*)&gNB->common_vars.rxdata[0][slot_offset-delay],
+ sizeof(int16_t),
+ slot_length<<1,
+ input_fd);
+ if (read_errors==0) exit(1);
for (int i=0;i<16;i+=2) printf("slot_offset %d : %d,%d\n",
- slot_offset,
- ((int16_t*)&gNB->common_vars.rxdata[0][slot_offset])[i],
- ((int16_t*)&gNB->common_vars.rxdata[0][slot_offset])[1+i]);
+ slot_offset,
+ ((int16_t*)&gNB->common_vars.rxdata[0][slot_offset])[i],
+ ((int16_t*)&gNB->common_vars.rxdata[0][slot_offset])[1+i]);
}
for (SNR = snr0; SNR < snr1; SNR += snr_step) {
@@ -782,6 +800,17 @@ int main(int argc, char **argv)
int n_errors[4] = {0,0,0,0};;
int round_trials[4]={0,0,0,0};
uint32_t errors_scrambling[4] = {0,0,0,0};
+ reset_meas(&gNB->phy_proc_rx);
+ reset_meas(&gNB->rx_pusch_stats);
+ reset_meas(&gNB->ulsch_decoding_stats);
+ reset_meas(&gNB->ulsch_deinterleaving_stats);
+ reset_meas(&gNB->ulsch_rate_unmatching_stats);
+ reset_meas(&gNB->ulsch_ldpc_decoding_stats);
+ reset_meas(&gNB->ulsch_unscrambling_stats);
+ reset_meas(&gNB->ulsch_channel_estimation_stats);
+ reset_meas(&gNB->ulsch_llr_stats);
+ reset_meas(&gNB->ulsch_channel_compensation_stats);
+ reset_meas(&gNB->ulsch_rbs_extraction_stats);
clear_pusch_stats(gNB);
for (trial = 0; trial < n_trials; trial++) {
@@ -795,19 +824,6 @@ int main(int argc, char **argv)
ulsch_ue[0]->harq_processes[harq_pid]->round = round;
gNB->ulsch[0][0]->harq_processes[harq_pid]->round = round;
rv_index = nr_rv_round_map[round];
- reset_meas(&gNB->phy_proc_rx);
- reset_meas(&gNB->rx_pusch_stats);
- reset_meas(&gNB->ulsch_decoding_stats);
- reset_meas(&gNB->ulsch_deinterleaving_stats);
- reset_meas(&gNB->ulsch_rate_unmatching_stats);
- reset_meas(&gNB->ulsch_ldpc_decoding_stats);
- reset_meas(&gNB->ulsch_unscrambling_stats);
- reset_meas(&gNB->ulsch_channel_estimation_stats);
- reset_meas(&gNB->ulsch_ptrs_processing_stats);
- reset_meas(&gNB->ulsch_llr_stats);
- reset_meas(&gNB->ulsch_mrc_stats);
- reset_meas(&gNB->ulsch_channel_compensation_stats);
- reset_meas(&gNB->ulsch_rbs_extraction_stats);
UE_proc.nr_tti_tx = slot;
UE_proc.frame_tx = frame;
@@ -899,6 +915,7 @@ int main(int argc, char **argv)
ul_config.ul_config_list[0].pdu_type = FAPI_NR_UL_CONFIG_TYPE_PUSCH;
ul_config.ul_config_list[0].pusch_config_pdu.rnti = n_rnti;
ul_config.ul_config_list[0].pusch_config_pdu.pdu_bit_map = pdu_bit_map;
+ ul_config.ul_config_list[0].pusch_config_pdu.qam_mod_order = mod_order;
ul_config.ul_config_list[0].pusch_config_pdu.rb_size = nb_rb;
ul_config.ul_config_list[0].pusch_config_pdu.rb_start = start_rb;
ul_config.ul_config_list[0].pusch_config_pdu.nr_of_symbols = nb_symb_sch;
@@ -911,7 +928,7 @@ int main(int argc, char **argv)
ul_config.ul_config_list[0].pusch_config_pdu.nrOfLayers = precod_nbr_layers;
ul_config.ul_config_list[0].pusch_config_pdu.absolute_delta_PUSCH = 0;
- ul_config.ul_config_list[0].pusch_config_pdu.pusch_data.tb_size = TBS;
+ ul_config.ul_config_list[0].pusch_config_pdu.pusch_data.tb_size = TBS/8;
ul_config.ul_config_list[0].pusch_config_pdu.pusch_data.new_data_indicator = trial & 0x1;
ul_config.ul_config_list[0].pusch_config_pdu.pusch_data.rv_index = rv_index;
ul_config.ul_config_list[0].pusch_config_pdu.pusch_data.harq_process_id = harq_pid;
@@ -923,7 +940,7 @@ int main(int argc, char **argv)
nr_fill_ulsch(gNB,frame,slot,pusch_pdu);
- for (int i=0;i<(TBS>>3);i++) ulsch_ue[0]->harq_processes[harq_pid]->a[i]=i&0xff;
+ for (int i=0;i<(TBS/8);i++) ulsch_ue[0]->harq_processes[harq_pid]->a[i]=i&0xff;
double scale = 1;
if (input_fd == NULL) {
@@ -1141,9 +1158,9 @@ int main(int argc, char **argv)
printStatIndent2(&gNB->ulsch_llr_stats,"ULSCH llr computation");
printStatIndent(&gNB->ulsch_unscrambling_stats,"ULSCH unscrambling");
printStatIndent(&gNB->ulsch_decoding_stats,"ULSCH total decoding time");
- printStatIndent2(&gNB->ulsch_deinterleaving_stats,"ULSCH deinterleaving");
- printStatIndent2(&gNB->ulsch_rate_unmatching_stats,"ULSCH rate matching rx");
- printStatIndent2(&gNB->ulsch_ldpc_decoding_stats,"ULSCH ldpc decoding");
+ //printStatIndent2(&gNB->ulsch_deinterleaving_stats,"ULSCH deinterleaving");
+ //printStatIndent2(&gNB->ulsch_rate_unmatching_stats,"ULSCH rate matching rx");
+ //printStatIndent2(&gNB->ulsch_ldpc_decoding_stats,"ULSCH ldpc decoding");
printf("\n");
}
diff --git a/openair2/COMMON/itti_sim_messages_def.h b/openair2/COMMON/itti_sim_messages_def.h
new file mode 100644
index 0000000000..13e170684f
--- /dev/null
+++ b/openair2/COMMON/itti_sim_messages_def.h
@@ -0,0 +1,17 @@
+/*!
+\file itti_sim_messages_def.h
+
+\brief itti message for itti simulator
+\author Yoshio INOUE, Masayuki HARADA
+\email: yoshio.inoue@fujitsu.com,masayuki.harada@fujitsu.com
+\date 2020
+\version 0.1
+*/
+
+
+
+MESSAGE_DEF(GNB_RRC_BCCH_DATA_IND, MESSAGE_PRIORITY_MED, itti_sim_rrc_ch_t, GNBBCCHind)
+MESSAGE_DEF(GNB_RRC_CCCH_DATA_IND, MESSAGE_PRIORITY_MED, itti_sim_rrc_ch_t, GNBCCCHind)
+MESSAGE_DEF(GNB_RRC_DCCH_DATA_IND, MESSAGE_PRIORITY_MED, itti_sim_rrc_ch_t, GNBDCCHind)
+MESSAGE_DEF(UE_RRC_CCCH_DATA_IND, MESSAGE_PRIORITY_MED, itti_sim_rrc_ch_t, UECCCHind)
+MESSAGE_DEF(UE_RRC_DCCH_DATA_IND, MESSAGE_PRIORITY_MED, itti_sim_rrc_ch_t, UEDCCHind)
diff --git a/openair2/COMMON/itti_sim_messages_types.h b/openair2/COMMON/itti_sim_messages_types.h
new file mode 100644
index 0000000000..4b06cc9dc8
--- /dev/null
+++ b/openair2/COMMON/itti_sim_messages_types.h
@@ -0,0 +1,32 @@
+/*!
+\file itti_sim_messages_types.h
+
+\brief itti message for itti simulator
+\author Yoshio INOUE, Masayuki HARADA
+\email: yoshio.inoue@fujitsu.com,masayuki.harada@fujitsu.com
+\date 2020
+\version 0.1
+*/
+
+#ifndef ITTI_SIM_MESSAGES_TYPES_H_
+#define ITTI_SIM_MESSAGES_TYPES_H_
+
+#include "LTE_asn_constant.h"
+
+
+
+#define GNB_RRC_BCCH_DATA_IND(mSGpTR) (mSGpTR)->ittiMsg.GNBBCCHind
+#define GNB_RRC_CCCH_DATA_IND(mSGpTR) (mSGpTR)->ittiMsg.GNBCCCHind
+#define GNB_RRC_DCCH_DATA_IND(mSGpTR) (mSGpTR)->ittiMsg.GNBDCCHind
+#define UE_RRC_CCCH_DATA_IND(mSGpTR) (mSGpTR)->ittiMsg.UECCCHind
+#define UE_RRC_DCCH_DATA_IND(mSGpTR) (mSGpTR)->ittiMsg.UEDCCHind
+
+
+
+typedef struct itti_sim_rrc_ch_s {
+ const rb_id_t rbid;
+ uint8_t *sdu;
+ int size;
+} itti_sim_rrc_ch_t;
+
+#endif /* ITTI_SIM_MESSAGES_TYPES_H_ */
diff --git a/openair2/COMMON/mac_messages_def.h b/openair2/COMMON/mac_messages_def.h
index f628d6655b..eeef0d4494 100644
--- a/openair2/COMMON/mac_messages_def.h
+++ b/openair2/COMMON/mac_messages_def.h
@@ -41,8 +41,6 @@ MESSAGE_DEF(RRC_MAC_CCCH_DATA_REQ, MESSAGE_PRIORITY_MED_PLUS, RrcMacCcchDat
MESSAGE_DEF(RRC_MAC_CCCH_DATA_CNF, MESSAGE_PRIORITY_MED_PLUS, RrcMacCcchDataCnf, rrc_mac_ccch_data_cnf)
MESSAGE_DEF(RRC_MAC_CCCH_DATA_IND, MESSAGE_PRIORITY_MED_PLUS, RrcMacCcchDataInd, rrc_mac_ccch_data_ind)
-// gNB
-MESSAGE_DEF(NR_RRC_MAC_CCCH_DATA_IND, MESSAGE_PRIORITY_MED_PLUS, NRRrcMacCcchDataInd, nr_rrc_mac_ccch_data_ind)
MESSAGE_DEF(RRC_MAC_MCCH_DATA_REQ, MESSAGE_PRIORITY_MED_PLUS, RrcMacMcchDataReq, rrc_mac_mcch_data_req)
MESSAGE_DEF(RRC_MAC_MCCH_DATA_IND, MESSAGE_PRIORITY_MED_PLUS, RrcMacMcchDataInd, rrc_mac_mcch_data_ind)
@@ -50,4 +48,9 @@ MESSAGE_DEF(RRC_MAC_MCCH_DATA_IND, MESSAGE_PRIORITY_MED_PLUS, RrcMacMcchDat
MESSAGE_DEF(RRC_MAC_PCCH_DATA_REQ, MESSAGE_PRIORITY_MED_PLUS, RrcMacPcchDataReq, rrc_mac_pcch_data_req)
/* RRC configures DRX context (MAC timers) of a UE */
-MESSAGE_DEF(RRC_MAC_DRX_CONFIG_REQ, MESSAGE_PRIORITY_MED, rrc_mac_drx_config_req_t, rrc_mac_drx_config_req)
\ No newline at end of file
+MESSAGE_DEF(RRC_MAC_DRX_CONFIG_REQ, MESSAGE_PRIORITY_MED, rrc_mac_drx_config_req_t, rrc_mac_drx_config_req)
+
+// gNB
+MESSAGE_DEF(NR_RRC_MAC_CCCH_DATA_IND, MESSAGE_PRIORITY_MED_PLUS, NRRrcMacCcchDataInd, nr_rrc_mac_ccch_data_ind)
+MESSAGE_DEF(NR_RRC_MAC_BCCH_DATA_IND, MESSAGE_PRIORITY_MED_PLUS, NRRrcMacBcchDataInd, nr_rrc_mac_bcch_data_ind)
+
diff --git a/openair2/COMMON/mac_messages_types.h b/openair2/COMMON/mac_messages_types.h
index cda6479bf9..f42813ecb0 100644
--- a/openair2/COMMON/mac_messages_types.h
+++ b/openair2/COMMON/mac_messages_types.h
@@ -38,6 +38,7 @@
#define RRC_MAC_BCCH_DATA_REQ(mSGpTR) (mSGpTR)->ittiMsg.rrc_mac_bcch_data_req
#define RRC_MAC_BCCH_DATA_IND(mSGpTR) (mSGpTR)->ittiMsg.rrc_mac_bcch_data_ind
+#define NR_RRC_MAC_BCCH_DATA_IND(mSGpTR) (mSGpTR)->ittiMsg.nr_rrc_mac_bcch_data_ind
#define RRC_MAC_BCCH_MBMS_DATA_REQ(mSGpTR) (mSGpTR)->ittiMsg.rrc_mac_bcch_mbms_data_req
#define RRC_MAC_BCCH_MBMS_DATA_IND(mSGpTR) (mSGpTR)->ittiMsg.rrc_mac_bcch_mbms_data_ind
@@ -87,6 +88,15 @@ typedef struct RrcMacBcchDataInd_s {
uint8_t rsrp;
} RrcMacBcchDataInd;
+typedef struct NRRrcMacBcchDataInd_s {
+ uint32_t frame;
+ uint8_t sub_frame;
+ uint32_t sdu_size;
+ uint8_t sdu[BCCH_SDU_SIZE];
+ uint8_t gnb_index;
+ uint8_t rsrq;
+ uint8_t rsrp;
+} NRRrcMacBcchDataInd;
typedef struct RrcMacBcchMbmsDataReq_s {
uint32_t frame;
diff --git a/openair2/COMMON/tasks_def.h b/openair2/COMMON/tasks_def.h
index 0fb1bd6b30..33b6d5f9d4 100644
--- a/openair2/COMMON/tasks_def.h
+++ b/openair2/COMMON/tasks_def.h
@@ -74,6 +74,7 @@ TASK_DEF(TASK_PROTO_AGENT, TASK_PRIORITY_MED, 200)
/// Radio Resource Control task
TASK_DEF(TASK_RRC_UE, TASK_PRIORITY_MED, 200)
+TASK_DEF(TASK_RRC_NRUE, TASK_PRIORITY_MED, 200)
/// Non Access Stratum task
TASK_DEF(TASK_NAS_UE, TASK_PRIORITY_MED, 200)
TASK_DEF(TASK_RAL_UE, TASK_PRIORITY_MED, 200)
@@ -81,3 +82,8 @@ TASK_DEF(TASK_RAL_UE, TASK_PRIORITY_MED, 200)
//MESSAGE GENERATOR TASK
TASK_DEF(TASK_MSC, TASK_PRIORITY_MED, 200)
+#ifdef ITTI_SIM
+TASK_DEF(TASK_RRC_GNB_SIM, TASK_PRIORITY_MED, 200)
+TASK_DEF(TASK_RRC_UE_SIM, TASK_PRIORITY_MED, 200)
+#endif
+
diff --git a/openair2/GNB_APP/gnb_app.c b/openair2/GNB_APP/gnb_app.c
index ab2fea0144..e4d3e53549 100644
--- a/openair2/GNB_APP/gnb_app.c
+++ b/openair2/GNB_APP/gnb_app.c
@@ -173,7 +173,7 @@ void *gNB_app_task(void *args_p)
__attribute__((unused)) uint32_t x2_register_gnb_pending = gNB_app_register_x2 (gnb_id_start, gnb_id_end);
}
- if (EPC_MODE_ENABLED) {
+ if (AMF_MODE_ENABLED) {
/* Try to register each gNB */
//registered_gnb = 0;
__attribute__((unused)) uint32_t register_gnb_pending = gNB_app_register (gnb_id_start, gnb_id_end);//, gnb_properties_p);
diff --git a/openair2/GNB_APP/gnb_config.c b/openair2/GNB_APP/gnb_config.c
index fec45dca9a..da19149605 100644
--- a/openair2/GNB_APP/gnb_config.c
+++ b/openair2/GNB_APP/gnb_config.c
@@ -342,7 +342,7 @@ void RCconfig_nr_flexran()
/* gNB ID from configuration, as read in by RCconfig_RRC() */
if (!GNBParamList.paramarray[i][GNB_GNB_ID_IDX].uptr) {
// Calculate a default gNB ID
- if (EPC_MODE_ENABLED)
+ if (AMF_MODE_ENABLED)
gnb_id = i + (ngap_generate_gNB_id () & 0xFFFFFF8);
else
gnb_id = i;
@@ -536,7 +536,7 @@ void RCconfig_NRRRC(MessageDef *msg_p, uint32_t i, gNB_RRC_INST *rrc) {
AssertFatal (i> msi_pos)) == (0x100>>msi_pos))
msi_pos++;
- mbms_mch_i=0;
+ mbms_mch_i=0;
if((subframeP==0)){
x=0;
diff --git a/openair2/LAYER2/NR_MAC_gNB/nr_compute_tbs_common.c b/openair2/LAYER2/NR_MAC_COMMON/nr_compute_tbs_common.c
similarity index 66%
rename from openair2/LAYER2/NR_MAC_gNB/nr_compute_tbs_common.c
rename to openair2/LAYER2/NR_MAC_COMMON/nr_compute_tbs_common.c
index df23b64e07..30dccea2a9 100644
--- a/openair2/LAYER2/NR_MAC_gNB/nr_compute_tbs_common.c
+++ b/openair2/LAYER2/NR_MAC_COMMON/nr_compute_tbs_common.c
@@ -27,76 +27,70 @@
#include "common/utils/nr/nr_common.h"
#include
+#include "PHY/defs_nr_common.h"
//Table 5.1.2.2-2
uint16_t Tbstable_nr[INDEX_MAX_TBS_TABLE] = {24,32,40,48,56,64,72,80,88,96,104,112,120,128,136,144,152,160,168,176,184,192,208,224,240,256,272,288,304,320,336,352,368,384,408,432,456,480,504,528,552,576,608,640,672,704,736,768,808,848,888,928,984,1032,1064,1128,1160,1192,1224,1256,1288,1320,1352,1416,1480,1544,1608,1672,1736,1800,1864,1928,2024,2088,2152,2216,2280,2408,2472,2536,2600,2664,2728,2792,2856,2976,3104,3240,3368,3496,3624,3752,3824};
uint16_t NPRB_LBRM[7] = {32,66,107,135,162,217,273};
+// Transport block size determination according to 6.1.4.2 of TS 38.214
+// returns the TBS in bits
uint32_t nr_compute_tbs(uint16_t Qm,
uint16_t R,
- uint16_t nb_rb,
- uint16_t nb_symb_sch,
- uint16_t nb_dmrs_prb,
+ uint16_t nb_rb,
+ uint16_t nb_symb_sch,
+ uint16_t nb_dmrs_prb,
uint16_t nb_rb_oh,
uint8_t tb_scaling,
- uint8_t Nl)
+ uint8_t Nl)
{
- uint16_t nbp_re, nb_re;
- uint32_t nr_tbs=0;
- uint32_t Ninfo, Np_info, C;
- uint8_t n, scale;
+ uint16_t nbp_re, nb_re;
+ uint32_t nr_tbs=0;
+ uint32_t Ninfo, Np_info, C;
+ uint8_t n, scale;
- nbp_re = 12 * nb_symb_sch - nb_dmrs_prb - nb_rb_oh;
+ nbp_re = NR_NB_SC_PER_RB * nb_symb_sch - nb_dmrs_prb - nb_rb_oh;
+ nb_re = min(156, nbp_re) * nb_rb;
+ scale = (R>1024)?11:10;
+ // Intermediate number of information bits
+ Ninfo = ((nb_re * R * Qm * Nl)>>scale)>>tb_scaling;
- nb_re = min(156, nbp_re) * nb_rb;
-
- scale = (R>1024)?11:10;
-
- // Intermediate number of information bits
- Ninfo = ((nb_re * R * Qm * Nl)>>scale)>>tb_scaling;
-
- if (Ninfo <=3824) {
- n = max(3, floor(log2(Ninfo)) - 6);
- Np_info = max(24, (Ninfo>>n)<= Np_info){
- nr_tbs = Tbstable_nr[i];
- break;
- }
+ if (Ninfo <=3824) {
+ n = max(3, floor(log2(Ninfo)) - 6);
+ Np_info = max(24, (Ninfo>>n)<= Np_info){
+ nr_tbs = Tbstable_nr[i];
+ break;
}
+ }
+ } else {
+ n = log2(Ninfo-24)-5;
+ Np_info = max(3840, (ROUNDIDIV((Ninfo-24),(1< 8424){
+ C = CEILIDIV((Np_info+24),8424);
+ nr_tbs = (C<<3)*CEILIDIV((Np_info+24),(C<<3)) - 24;
+ } else {
+ nr_tbs = ((CEILIDIV((Np_info+24),8))<<3) - 24;
+ }
}
- else {
- n = log2(Ninfo-24)-5;
- Np_info = max(3840, (ROUNDIDIV((Ninfo-24),(1< 8424){
- C = CEILIDIV((Np_info+24),8424);
- nr_tbs = (C<<3)*CEILIDIV((Np_info+24),(C<<3)) - 24;
- }
- else {
- nr_tbs = ((CEILIDIV((Np_info+24),8))<<3) - 24;
- }
-
- }
-
- }
- //printf("Ninfo %d nbp_re %d nb_re %d Qm %d, R %d, tbs %d\n", Ninfo, nbp_re, nb_re, Qm, R, nr_tbs);
- return nr_tbs;
+ }
+ //printf("Ninfo %d nbp_re %d nb_re %d Qm %d, R %d, tbs %d\n", Ninfo, nbp_re, nb_re, Qm, R, nr_tbs);
+ return nr_tbs;
}
//tbslbrm calculation according to 5.4.2.1 of 38.212
uint32_t nr_compute_tbslbrm(uint16_t table,
uint16_t nb_rb,
- uint8_t Nl,
- uint8_t C)
+ uint8_t Nl)
{
uint16_t R, nb_re;
@@ -104,14 +98,14 @@ uint32_t nr_compute_tbslbrm(uint16_t table,
uint8_t Qm;
int i;
uint32_t nr_tbs=0;
- uint32_t Ninfo, Np_info;
+ uint32_t Ninfo, Np_info, C;
uint8_t n;
for (i=0; i<7; i++) {
- if (NPRB_LBRM[i] >= nb_rb){
- nb_rb_lbrm = NPRB_LBRM[i];
- break;
- }
+ if (NPRB_LBRM[i] >= nb_rb){
+ nb_rb_lbrm = NPRB_LBRM[i];
+ break;
+ }
}
Qm = ((table == 1)? 8 : 6);
@@ -136,10 +130,12 @@ uint32_t nr_compute_tbslbrm(uint16_t table,
Np_info = max(3840, (ROUNDIDIV((Ninfo-24),(1< 8424){
+ C = CEILIDIV((Np_info+24),8424);
nr_tbs = (C<<3)*CEILIDIV((Np_info+24),(C<<3)) - 24;
}
else {
@@ -150,5 +146,4 @@ uint32_t nr_compute_tbslbrm(uint16_t table,
}
return nr_tbs;
-
}
diff --git a/openair2/LAYER2/NR_MAC_UE/mac_defs.h b/openair2/LAYER2/NR_MAC_UE/mac_defs.h
index e45f6a9b69..97c99b6050 100755
--- a/openair2/LAYER2/NR_MAC_UE/mac_defs.h
+++ b/openair2/LAYER2/NR_MAC_UE/mac_defs.h
@@ -221,6 +221,10 @@ typedef struct {
uint32_t RA_tx_frame;
/// Random-access variable for window calculation (subframe of last change in window counter)
uint8_t RA_tx_subframe;
+ /// Scheduled TX frame for RA Msg3
+ frame_t msg3_frame;
+ /// Scheduled TX slot for RA Msg3
+ slot_t msg3_slot;
/// Random-access variable for backoff (frame of last change in backoff counter)
uint32_t RA_backoff_frame;
/// Random-access variable for backoff (subframe of last change in backoff counter)
@@ -243,13 +247,11 @@ typedef struct {
uint8_t generate_nr_prach;
//// FAPI-like interface message
- fapi_nr_tx_request_t tx_request;
fapi_nr_ul_config_request_t ul_config_request;
fapi_nr_dl_config_request_t dl_config_request;
/// Interface module instances
nr_ue_if_module_t *if_module;
- nr_scheduled_response_t scheduled_response;
nr_phy_config_t phy_config;
/// BSR report flag management
diff --git a/openair2/LAYER2/NR_MAC_UE/mac_proto.h b/openair2/LAYER2/NR_MAC_UE/mac_proto.h
index e9d7a97a5d..4126b19b0b 100755
--- a/openair2/LAYER2/NR_MAC_UE/mac_proto.h
+++ b/openair2/LAYER2/NR_MAC_UE/mac_proto.h
@@ -88,6 +88,24 @@ NR_UE_MAC_INST_t *get_mac_inst(
\param ul_info UL indication*/
NR_UE_L2_STATE_t nr_ue_scheduler(nr_downlink_indication_t *dl_info, nr_uplink_indication_t *ul_info);
+/**\brief fill nr_scheduled_response struct instance
+ @param nr_scheduled_response_t * pointer to scheduled_response instance to fill
+ @param fapi_nr_dl_config_request_t* pointer to dl_config,
+ @param fapi_nr_ul_config_request_t* pointer to ul_config,
+ @param fapi_nr_tx_request_t* pointer to tx_request;
+ @param module_id_t mod_id module ID
+ @param int cc_id CC ID
+ @param frame_t frame frame number
+ @param int slot reference number */
+void fill_scheduled_response(nr_scheduled_response_t *scheduled_response,
+ fapi_nr_dl_config_request_t *dl_config,
+ fapi_nr_ul_config_request_t *ul_config,
+ fapi_nr_tx_request_t *tx_request,
+ module_id_t mod_id,
+ int cc_id,
+ frame_t frame,
+ int slot);
+
/* \brief Get SR payload (0,1) from UE MAC
@param Mod_id Instance id of UE in machine
@param CC_id Component Carrier index
@@ -156,7 +174,7 @@ int8_t nr_ue_process_dlsch(module_id_t module_id, int cc_id, uint8_t gNB_index,
void ue_dci_configuration(NR_UE_MAC_INST_t *mac, fapi_nr_dl_config_request_t *dl_config, frame_t frame, int slot);
-void nr_extract_dci_info(NR_UE_MAC_INST_t *mac,
+int nr_extract_dci_info(NR_UE_MAC_INST_t *mac,
int dci_format,
uint8_t dci_length,
uint16_t rnti,
@@ -197,6 +215,17 @@ and fills the PRACH PDU per each FD occasion.
*/
void nr_ue_prach_scheduler(module_id_t module_idP, frame_t frameP, sub_frame_t slotP);
+/* \brief This function schedules the Msg3 transmission
+@param
+@param
+@param
+@returns void
+*/
+void nr_ue_msg3_scheduler(NR_UE_MAC_INST_t *mac,
+ frame_t current_frame,
+ sub_frame_t current_slot,
+ uint8_t Msg3_tda_id);
+
/* \brief Function called by PHY to process the received RAR and check that the preamble matches what was sent by the gNB. It provides the timing advance and t-CRNTI.
@param Mod_id Index of UE instance
@param CC_id Index to a component carrier
@@ -212,6 +241,7 @@ random-access procedure
uint16_t nr_ue_process_rar(module_id_t mod_id,
int CC_id,
frame_t frameP,
+ sub_frame_t slotP,
uint8_t * dlsch_buffer,
rnti_t * t_crnti,
uint8_t preamble_index,
@@ -264,5 +294,16 @@ void nr_Msg1_transmitted(module_id_t mod_id, uint8_t CC_id, frame_t frameP, uint
void nr_Msg3_transmitted(module_id_t mod_id, uint8_t CC_id, frame_t frameP, uint8_t gNB_id);
void nr_ue_msg2_scheduler(module_id_t mod_id, uint16_t rach_frame, uint16_t rach_slot, uint16_t *msg2_frame, uint16_t *msg2_slot);
+
+int8_t nr_ue_process_dci_freq_dom_resource_assignment(nfapi_nr_ue_pusch_pdu_t *pusch_config_pdu,
+ fapi_nr_dl_config_dlsch_pdu_rel15_t *dlsch_config_pdu,
+ uint16_t n_RB_ULBWP,
+ uint16_t n_RB_DLBWP,
+ uint16_t riv);
+
+void get_num_re_dmrs(nfapi_nr_ue_pusch_pdu_t *pusch_pdu,
+ uint8_t *nb_dmrs_re_per_rb,
+ uint16_t *number_dmrs_symbols);
+
#endif
/** @}*/
diff --git a/openair2/LAYER2/NR_MAC_UE/nr_l1_helpers.c b/openair2/LAYER2/NR_MAC_UE/nr_l1_helpers.c
index f8bb1e5f8e..30e4acaf49 100644
--- a/openair2/LAYER2/NR_MAC_UE/nr_l1_helpers.c
+++ b/openair2/LAYER2/NR_MAC_UE/nr_l1_helpers.c
@@ -20,7 +20,7 @@
*/
/*! \file nr_l1_helper.c
-* \brief PHY helper functions for PRACH adapted to NR
+* \brief PHY/MAC helper functions
* \author Guido Casati
* \date 2019
* \version 2.0
@@ -151,3 +151,23 @@ int nr_get_Po_NOMINAL_PUSCH(NR_PRACH_RESOURCES_t *prach_resources, module_id_t m
return receivedTargerPower;
}
+
+void get_num_re_dmrs(nfapi_nr_ue_pusch_pdu_t *pusch_pdu,
+ uint8_t *nb_dmrs_re_per_rb,
+ uint16_t *number_dmrs_symbols){
+
+ int start_symbol = pusch_pdu->start_symbol_index;
+ uint8_t number_of_symbols = pusch_pdu->nr_of_symbols;
+ uint16_t ul_dmrs_symb_pos = pusch_pdu->ul_dmrs_symb_pos;
+ uint8_t dmrs_type = pusch_pdu->dmrs_config_type;
+ uint8_t cdm_grps_no_data = pusch_pdu->num_dmrs_cdm_grps_no_data;
+
+ *number_dmrs_symbols = 0;
+ for (int i = start_symbol; i < start_symbol + number_of_symbols; i++) {
+ if((ul_dmrs_symb_pos >> i) & 0x01)
+ *number_dmrs_symbols += 1;
+ }
+
+ *nb_dmrs_re_per_rb = ((dmrs_type == pusch_dmrs_type1) ? 6:4)*cdm_grps_no_data;
+
+}
diff --git a/openair2/LAYER2/NR_MAC_UE/nr_ra_procedures.c b/openair2/LAYER2/NR_MAC_UE/nr_ra_procedures.c
index 351bcc292f..117e5d2970 100644
--- a/openair2/LAYER2/NR_MAC_UE/nr_ra_procedures.c
+++ b/openair2/LAYER2/NR_MAC_UE/nr_ra_procedures.c
@@ -493,9 +493,13 @@ uint8_t nr_ue_get_rach(NR_PRACH_RESOURCES_t *prach_resources,
if (mac->RA_window_cnt >= 0 && mac->RA_RAPID_found == 1) {
+ // Reset RA_active flag: it disables Msg3 retransmission (8.3 of TS 38.213)
+ // TbD Msg3 Retransmissions to be scheduled by DCI 0_0
+ mac->RA_active = 0;
mac->RA_window_cnt = -1;
mac->ra_state = RA_SUCCEEDED;
- LOG_I(MAC, "[MAC][UE %d][RAPROC] Frame %d: nr_tti_tx %d: RAR successfully received \n", mod_id, frame, nr_tti_tx);
+ mac->generate_nr_prach = 2;
+ LOG_I(MAC, "[MAC][UE %d][RAPROC]: RAR successfully received \n", mod_id);
} else if (mac->RA_window_cnt == 0 && !mac->RA_RAPID_found) {
@@ -578,7 +582,7 @@ uint8_t nr_ue_get_rach(NR_PRACH_RESOURCES_t *prach_resources,
mac->RA_window_cnt--;
- LOG_I(MAC, "[MAC][UE %d][RAPROC] Frame %d: nr_tti_tx %d: RAR reception not successful, (RA window count %d) \n",
+ LOG_D(MAC, "[MAC][UE %d][RAPROC][%d.%d]: RAR not received yet (RA window count %d) \n",
mod_id,
frame,
nr_tti_tx,
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 2285fc5999..33aed06aec 100644
--- a/openair2/LAYER2/NR_MAC_UE/nr_ue_dci_configuration.c
+++ b/openair2/LAYER2/NR_MAC_UE/nr_ue_dci_configuration.c
@@ -64,11 +64,11 @@ void fill_dci_search_candidates(NR_SearchSpace_t *ss,fapi_nr_dl_config_dci_dl_pd
}
-void config_dci_pdu(NR_UE_MAC_INST_t *mac, fapi_nr_dl_config_dci_dl_pdu_rel15_t *rel15, fapi_nr_dl_config_request_t *dl_config, int rnti_type, int ss_id, uint8_t dci_format){
+void config_dci_pdu(NR_UE_MAC_INST_t *mac, fapi_nr_dl_config_dci_dl_pdu_rel15_t *rel15, fapi_nr_dl_config_request_t *dl_config, int rnti_type, int ss_id){
- uint16_t monitoringSymbolsWithinSlot;
+ uint16_t monitoringSymbolsWithinSlot = 0;
uint8_t bwp_id = 1, coreset_id = 1;
- int sps;
+ int sps = 0;
def_dci_pdu_rel15 = calloc(1,sizeof(dci_pdu_rel15_t));
AssertFatal(mac->scc != NULL, "scc is null\n");
NR_ServingCellConfigCommon_t *scc = mac->scc;
@@ -76,9 +76,6 @@ void config_dci_pdu(NR_UE_MAC_INST_t *mac, fapi_nr_dl_config_dci_dl_pdu_rel15_t
NR_BWP_DownlinkCommon_t *initialDownlinkBWP = scc->downlinkConfigCommon->initialDownlinkBWP;
NR_SearchSpace_t *ss = mac->SSpace[bwp_id - 1][coreset_id - 1][ss_id];
- // DCI format configuration
- rel15->dci_format = dci_format;
-
// CORESET configuration
NR_ControlResourceSet_t *coreset = mac->coreset[bwp_id - 1][coreset_id - 1];
rel15->coreset.duration = coreset->duration;
@@ -123,7 +120,9 @@ void config_dci_pdu(NR_UE_MAC_INST_t *mac, fapi_nr_dl_config_dci_dl_pdu_rel15_t
rel15->BWPSize = NRRIV2BW(bwp_Common->genericParameters.locationAndBandwidth, 275);
rel15->BWPStart = NRRIV2PRBOFFSET(bwp_Common->genericParameters.locationAndBandwidth, 275);
rel15->SubcarrierSpacing = bwp_Common->genericParameters.subcarrierSpacing;
- rel15->dci_length = nr_dci_size(scc, mac->scg, def_dci_pdu_rel15, rel15->dci_format, NR_RNTI_C, rel15->BWPSize, bwp_id);
+ for (int i = 0; i < rel15->num_dci_options; i++) {
+ rel15->dci_length_options[i] = nr_dci_size(scc, mac->scg, def_dci_pdu_rel15, rel15->dci_format_options[i], NR_RNTI_C, rel15->BWPSize, bwp_id);
+ }
break;
case NR_RNTI_RA:
// we use the initial DL BWP
@@ -133,7 +132,7 @@ void config_dci_pdu(NR_UE_MAC_INST_t *mac, fapi_nr_dl_config_dci_dl_pdu_rel15_t
rel15->BWPSize = NRRIV2BW(initialDownlinkBWP->genericParameters.locationAndBandwidth, 275);
rel15->BWPStart = NRRIV2PRBOFFSET(bwp_Common->genericParameters.locationAndBandwidth, 275); //NRRIV2PRBOFFSET(initialDownlinkBWP->genericParameters.locationAndBandwidth, 275);
rel15->SubcarrierSpacing = initialDownlinkBWP->genericParameters.subcarrierSpacing;
- rel15->dci_length = nr_dci_size(scc, mac->scg, def_dci_pdu_rel15, rel15->dci_format, NR_RNTI_RA, rel15->BWPSize, bwp_id);
+ rel15->dci_length_options[0] = nr_dci_size(scc, mac->scg, def_dci_pdu_rel15, rel15->dci_format_options[0], NR_RNTI_RA, rel15->BWPSize, bwp_id);
break;
case NR_RNTI_P:
break;
@@ -177,14 +176,13 @@ void config_dci_pdu(NR_UE_MAC_INST_t *mac, fapi_nr_dl_config_dci_dl_pdu_rel15_t
#endif
// add DCI
dl_config->dl_config_list[dl_config->number_pdus].pdu_type = FAPI_NR_DL_CONFIG_TYPE_DCI;
- dl_config->number_pdus = dl_config->number_pdus + 1;
+ dl_config->number_pdus += 1;
}
void ue_dci_configuration(NR_UE_MAC_INST_t *mac, fapi_nr_dl_config_request_t *dl_config, frame_t frame, int slot) {
int ss_id;
uint8_t bwp_id = 1, coreset_id = 1;
- NR_ServingCellConfig_t *scd = mac->scg->spCellConfig->spCellConfigDedicated;
NR_BWP_Downlink_t *bwp = mac->DLbwp[bwp_id - 1];
#ifdef DEBUG_DCI
@@ -215,7 +213,9 @@ void ue_dci_configuration(NR_UE_MAC_INST_t *mac, fapi_nr_dl_config_request_t *dl
LOG_D(MAC, "[DCI_CONFIG] Configure monitoring of PDCCH candidates in Type1-PDCCH common random access search space\n");
switch(mac->ra_state){
case WAIT_RAR:
- config_dci_pdu(mac, rel15, dl_config, NR_RNTI_RA, ss_id, NR_DL_DCI_FORMAT_1_0);
+ rel15->num_dci_options = 1;
+ rel15->dci_format_options[0] = NR_DL_DCI_FORMAT_1_0;
+ config_dci_pdu(mac, rel15, dl_config, NR_RNTI_RA, ss_id);
fill_dci_search_candidates(ss, rel15);
break;
case WAIT_CONTENTION_RESOLUTION:
@@ -286,7 +286,10 @@ void ue_dci_configuration(NR_UE_MAC_INST_t *mac, fapi_nr_dl_config_request_t *dl
// Monitors DCI 01 and 11 scrambled with C-RNTI, or CS-RNTI(s), or SP-CSI-RNTI
if (get_softmodem_params()->phy_test == 1 && mac->crnti > 0) {
LOG_D(MAC, "[DCI_CONFIG] Configure monitoring of PDCCH candidates in the user specific search space\n");
- config_dci_pdu(mac, rel15, dl_config, NR_RNTI_C, ss_id, NR_DL_DCI_FORMAT_1_1);
+ rel15->num_dci_options = 2;
+ rel15->dci_format_options[0] = NR_DL_DCI_FORMAT_1_1;
+ rel15->dci_format_options[1] = NR_UL_DCI_FORMAT_0_1;
+ config_dci_pdu(mac, rel15, dl_config, NR_RNTI_C, ss_id);
fill_dci_search_candidates(ss, rel15);
#ifdef DEBUG_DCI
diff --git a/openair2/LAYER2/NR_MAC_UE/nr_ue_procedures.c b/openair2/LAYER2/NR_MAC_UE/nr_ue_procedures.c
index ab533af941..e237a910c6 100644
--- a/openair2/LAYER2/NR_MAC_UE/nr_ue_procedures.c
+++ b/openair2/LAYER2/NR_MAC_UE/nr_ue_procedures.c
@@ -51,9 +51,10 @@
#include "NR_MAC_UE/mac_extern.h"
#include "common/utils/nr/nr_common.h"
-/* PHY UE */
+/* PHY */
#include "SCHED_NR_UE/defs.h"
#include "PHY/defs_nr_UE.h"
+#include "PHY/NR_TRANSPORT/nr_dci.h"
/*Openair Packet Tracer */
#include "UTIL/OPT/opt.h"
@@ -91,6 +92,24 @@ extern void mac_rlc_data_ind (
num_tb_t num_tbP,
crc_t *crcs_pP);
+void fill_scheduled_response(nr_scheduled_response_t *scheduled_response,
+ fapi_nr_dl_config_request_t *dl_config,
+ fapi_nr_ul_config_request_t *ul_config,
+ fapi_nr_tx_request_t *tx_request,
+ module_id_t mod_id,
+ int cc_id,
+ frame_t frame,
+ int slot){
+
+ scheduled_response->dl_config = dl_config;
+ scheduled_response->ul_config = ul_config;
+ scheduled_response->tx_request = tx_request;
+ scheduled_response->module_id = mod_id;
+ scheduled_response->CC_id = cc_id;
+ scheduled_response->frame = frame;
+ scheduled_response->slot = slot;
+
+}
uint32_t get_ssb_slot(uint32_t ssb_index){
// this function now only support f <= 3GHz
@@ -118,7 +137,7 @@ uint8_t table_9_2_2_1[16][8]={
{1,0, 14,26,0,3,0,0}
};
-
+#if 0 // Not in use. In case of use, please adapt the schedule_response (no longer in MAC)
int8_t nr_ue_process_dlsch(module_id_t module_id,
int cc_id,
uint8_t gNB_index,
@@ -252,6 +271,7 @@ int8_t nr_ue_process_dlsch(module_id_t module_id,
}
return 0;
}
+#endif
int8_t nr_ue_decode_mib(module_id_t module_id,
int cc_id,
@@ -719,7 +739,10 @@ NR_UE_L2_STATE_t nr_ue_scheduler(nr_downlink_indication_t *dl_info, nr_uplink_in
dl_config->dl_config_list[dl_config->number_pdus].dci_config_pdu.dci_config_rel15.N_RB_BWP);
*/
dl_config->number_pdus = dl_config->number_pdus + 1;
- mac->scheduled_response.dl_config = dl_config;
+
+ fill_scheduled_response(&scheduled_response, dl_config, NULL, NULL, mod_id, cc_id, rx_frame, rx_slot);
+ if(mac->if_module != NULL && mac->if_module->scheduled_response != NULL)
+ mac->if_module->scheduled_response(&scheduled_response);
}
} else { // we have an scg
@@ -728,17 +751,10 @@ NR_UE_L2_STATE_t nr_ue_scheduler(nr_downlink_indication_t *dl_info, nr_uplink_in
dcireq.cc_id = cc_id;
dcireq.frame = rx_frame;
dcireq.slot = rx_slot;
+ dcireq.dl_config_req.number_pdus = 0;
nr_ue_dcireq(&dcireq); //to be replaced with function pointer later
- // we should have received a DL DCI here, so configure DL accordingly
- scheduled_response.dl_config = &dcireq.dl_config_req;
- scheduled_response.ul_config = NULL;
- scheduled_response.tx_request = NULL;
- scheduled_response.module_id = mod_id;
- scheduled_response.CC_id = cc_id;
- scheduled_response.frame = rx_frame;
- scheduled_response.slot = rx_slot;
-
+ fill_scheduled_response(&scheduled_response, &dcireq.dl_config_req, NULL, NULL, mod_id, cc_id, rx_frame, rx_slot);
if(mac->if_module != NULL && mac->if_module->scheduled_response != NULL){
mac->if_module->scheduled_response(&scheduled_response);
}
@@ -766,7 +782,7 @@ NR_UE_L2_STATE_t nr_ue_scheduler(nr_downlink_indication_t *dl_info, nr_uplink_in
uint8_t data_existing = 0;
uint16_t TBS_bytes;
uint32_t TBS;
- int i;
+ int i, N_PRB_oh;
module_id_t mod_id = ul_info->module_id;
uint32_t gNB_index = ul_info->gNB_index;
@@ -778,57 +794,101 @@ NR_UE_L2_STATE_t nr_ue_scheduler(nr_downlink_indication_t *dl_info, nr_uplink_in
NR_UE_MAC_INST_t *mac = get_mac_inst(mod_id);
uint8_t access_mode = SCHEDULED_ACCESS;
- // program PUSCH. this should actually be done upon reception of an UL DCI
+ // program PUSCH with UL DCI parameters
nr_dcireq_t dcireq;
nr_scheduled_response_t scheduled_response;
fapi_nr_tx_request_t tx_req;
fapi_nr_tx_request_body_t tx_req_body;
+ fapi_nr_ul_config_request_t *ul_config = &dcireq.ul_config_req;
+ nfapi_nr_ue_ptrs_ports_t ptrs_ports_list;
- //--------------------------Temporary configuration-----------------------------//
- uint16_t rnti = 0x1234;
- uint32_t rb_size = 50;
- uint32_t rb_start = 0;
- uint8_t nr_of_symbols = 11;
- uint8_t start_symbol_index = 0;
+ fapi_nr_ul_config_request_pdu_t *ulcfg_pdu = &mac->ul_config_request.ul_config_list[0];
+
+ uint16_t rnti = ulcfg_pdu->pusch_config_pdu.rnti;
+ uint32_t rb_size = ulcfg_pdu->pusch_config_pdu.rb_size;
+ uint32_t rb_start = ulcfg_pdu->pusch_config_pdu.rb_start;
+ uint8_t nr_of_symbols = ulcfg_pdu->pusch_config_pdu.nr_of_symbols;
+ uint8_t start_symbol_index = ulcfg_pdu->pusch_config_pdu.start_symbol_index;
uint8_t nrOfLayers = 1;
- uint8_t mcs_index = 9;
- uint8_t mcs_table = 0;
- uint8_t harq_process_id = 0;
- uint8_t rv_index = 0;
+ uint8_t mcs_index = ulcfg_pdu->pusch_config_pdu.mcs_index;
+ uint8_t mcs_table = ulcfg_pdu->pusch_config_pdu.mcs_table;
+ uint8_t harq_process_id = ulcfg_pdu->pusch_config_pdu.pusch_data.harq_process_id;
+ uint8_t rv_index = ulcfg_pdu->pusch_config_pdu.pusch_data.rv_index;
uint16_t l_prime_mask = get_l_prime(nr_of_symbols, typeB, pusch_dmrs_pos0, pusch_len1);
uint8_t dmrs_config_type = 0;
+ uint16_t pdu_bit_map = PUSCH_PDU_BITMAP_PUSCH_DATA;
+ // These should come from RRC config!!!
uint8_t ptrs_mcs1 = 2;
uint8_t ptrs_mcs2 = 4;
uint8_t ptrs_mcs3 = 10;
uint16_t n_rb0 = 25;
uint16_t n_rb1 = 75;
- uint16_t pdu_bit_map = PUSCH_PDU_BITMAP_PUSCH_DATA;
uint8_t ptrs_time_density = get_L_ptrs(ptrs_mcs1, ptrs_mcs2, ptrs_mcs3, mcs_index, mcs_table);
uint8_t ptrs_freq_density = get_K_ptrs(n_rb0, n_rb1, rb_size);
- uint8_t no_data_in_dmrs = 1;
uint16_t number_dmrs_symbols = 0;
uint16_t ul_dmrs_symb_pos = l_prime_mask << start_symbol_index;
- //------------------------------------------------------------------------------//
- for (i = start_symbol_index; i < start_symbol_index + nr_of_symbols; i++) {
- if((ul_dmrs_symb_pos >> i) & 0x01)
- number_dmrs_symbols += 1;
- }
+#ifdef DEBUG_DCI
+ LOG_I(MAC, " UL config params \n rnti: %x \n rb_size: %d \n",
+ rnti, rb_size);
+ LOG_I(MAC, "rb_start: %x \n nr_of_symbols: %d \n start_symbol_index: %d \n nrOfLayers: %d \n mcs_index: %d \n \
+ mcs_table: %d \n harq_process_id: %d \n ndi: %d \n num_cb: %d \n rv_index: %d \n",
+ rb_start, nr_of_symbols, start_symbol_index, nrOfLayers, mcs_index,
+ mcs_table, harq_process_id, ndi, num_cb, rv_index);
+#endif
- if(no_data_in_dmrs)
- nb_dmrs_re_per_rb = 12;
- else
- nb_dmrs_re_per_rb = ((dmrs_config_type == pusch_dmrs_type1) ? 6:4);
+ // PTRS ports configuration
+ // TbD: ptrs_dmrs_port and ptrs_port_index are not initialised!
+ ptrs_ports_list.ptrs_re_offset = 0;
- TBS = nr_compute_tbs(nr_get_Qm_ul(mcs_index, 0),
- nr_get_code_rate_ul(mcs_index, 0),
- rb_size,
- nr_of_symbols,
- nb_dmrs_re_per_rb*number_dmrs_symbols,
- 0,
- 0,
- nrOfLayers);
- TBS_bytes = TBS/8;
+ // Num PRB Overhead from PUSCH-ServingCellConfig
+ if (mac->scg->spCellConfig->spCellConfigDedicated->uplinkConfig->pusch_ServingCellConfig->choice.setup->xOverhead == NULL)
+ N_PRB_oh = 0;
+ else
+ N_PRB_oh = *mac->scg->spCellConfig->spCellConfigDedicated->uplinkConfig->pusch_ServingCellConfig->choice.setup->xOverhead;
+
+ ul_config->slot = ul_info->slot_tx;
+ ul_config->number_pdus = 1;
+ ul_config->ul_config_list[0].pdu_type = FAPI_NR_UL_CONFIG_TYPE_PUSCH;
+ ul_config->ul_config_list[0].pusch_config_pdu.rnti = rnti;
+ ul_config->ul_config_list[0].pusch_config_pdu.rb_size = rb_size;
+ ul_config->ul_config_list[0].pusch_config_pdu.rb_start = rb_start;
+ ul_config->ul_config_list[0].pusch_config_pdu.nr_of_symbols = nr_of_symbols;
+ ul_config->ul_config_list[0].pusch_config_pdu.start_symbol_index = start_symbol_index;
+ ul_config->ul_config_list[0].pusch_config_pdu.ul_dmrs_symb_pos = ul_dmrs_symb_pos;
+ ul_config->ul_config_list[0].pusch_config_pdu.dmrs_config_type = dmrs_config_type;
+ ul_config->ul_config_list[0].pusch_config_pdu.mcs_index = mcs_index;
+ ul_config->ul_config_list[0].pusch_config_pdu.mcs_table = mcs_table;
+ ul_config->ul_config_list[0].pusch_config_pdu.num_dmrs_cdm_grps_no_data = 1;
+ ul_config->ul_config_list[0].pusch_config_pdu.pusch_data.new_data_indicator = 0;
+ ul_config->ul_config_list[0].pusch_config_pdu.pusch_data.rv_index = rv_index;
+ ul_config->ul_config_list[0].pusch_config_pdu.nrOfLayers = nrOfLayers;
+ ul_config->ul_config_list[0].pusch_config_pdu.pusch_data.harq_process_id = harq_process_id;
+ ul_config->ul_config_list[0].pusch_config_pdu.pdu_bit_map = pdu_bit_map;
+ ul_config->ul_config_list[0].pusch_config_pdu.pusch_ptrs.ptrs_time_density = ptrs_time_density;
+ ul_config->ul_config_list[0].pusch_config_pdu.pusch_ptrs.ptrs_freq_density = ptrs_freq_density;
+ ul_config->ul_config_list[0].pusch_config_pdu.pusch_ptrs.ptrs_ports_list = &ptrs_ports_list;
+ ul_config->ul_config_list[0].pusch_config_pdu.target_code_rate = nr_get_code_rate_ul(mcs_index, mcs_table);
+ ul_config->ul_config_list[0].pusch_config_pdu.qam_mod_order = nr_get_Qm_ul(mcs_index, mcs_table);
+
+ if (1 << ptrs_time_density >= nr_of_symbols) {
+ ul_config->ul_config_list[0].pusch_config_pdu.pdu_bit_map &= ~PUSCH_PDU_BITMAP_PUSCH_PTRS; // disable PUSCH PTRS
+ }
+
+ get_num_re_dmrs(&ul_config->ul_config_list[0].pusch_config_pdu,
+ &nb_dmrs_re_per_rb,
+ &number_dmrs_symbols);
+
+ TBS = nr_compute_tbs(ul_config->ul_config_list[0].pusch_config_pdu.qam_mod_order,
+ ul_config->ul_config_list[0].pusch_config_pdu.target_code_rate,
+ rb_size,
+ nr_of_symbols,
+ nb_dmrs_re_per_rb*number_dmrs_symbols,
+ N_PRB_oh,
+ 0,
+ nrOfLayers);
+ TBS_bytes = TBS/8;
+ ul_config->ul_config_list[0].pusch_config_pdu.pusch_data.tb_size = TBS_bytes;
if (IS_SOFTMODEM_NOS1){
// Getting IP traffic to be transmitted
@@ -876,8 +936,6 @@ NR_UE_L2_STATE_t nr_ue_scheduler(nr_downlink_indication_t *dl_info, nr_uplink_in
dcireq.frame = rx_frame;
dcireq.slot = rx_slot;
- scheduled_response.dl_config = NULL;
- scheduled_response.ul_config = &dcireq.ul_config_req;
// Config UL TX PDU
tx_req.slot = slot_tx;
tx_req.sfn = frame_tx;
@@ -886,41 +944,9 @@ NR_UE_L2_STATE_t nr_ue_scheduler(nr_downlink_indication_t *dl_info, nr_uplink_in
tx_req_body.pdu_length = TBS_bytes;
tx_req_body.pdu_index = 0;
tx_req_body.pdu = ulsch_input_buffer;
+ tx_req.tx_request_body = &tx_req_body;
- scheduled_response.tx_request = &tx_req;
- scheduled_response.tx_request->tx_request_body = &tx_req_body;
- scheduled_response.module_id = mod_id;
- scheduled_response.CC_id = cc_id;
- scheduled_response.frame = rx_frame;
- scheduled_response.slot = rx_slot;
-
- scheduled_response.ul_config->slot = ul_info->slot_tx;
- scheduled_response.ul_config->number_pdus = 1;
- scheduled_response.ul_config->ul_config_list[0].pdu_type = FAPI_NR_UL_CONFIG_TYPE_PUSCH;
- scheduled_response.ul_config->ul_config_list[0].pusch_config_pdu.rnti = rnti;
- scheduled_response.ul_config->ul_config_list[0].pusch_config_pdu.rb_size = rb_size;
- scheduled_response.ul_config->ul_config_list[0].pusch_config_pdu.rb_start = rb_start;
- scheduled_response.ul_config->ul_config_list[0].pusch_config_pdu.nr_of_symbols = nr_of_symbols;
- scheduled_response.ul_config->ul_config_list[0].pusch_config_pdu.start_symbol_index = start_symbol_index;
- scheduled_response.ul_config->ul_config_list[0].pusch_config_pdu.ul_dmrs_symb_pos = ul_dmrs_symb_pos;
- scheduled_response.ul_config->ul_config_list[0].pusch_config_pdu.dmrs_config_type = dmrs_config_type;
- scheduled_response.ul_config->ul_config_list[0].pusch_config_pdu.mcs_index = mcs_index;
- scheduled_response.ul_config->ul_config_list[0].pusch_config_pdu.mcs_table = mcs_table;
- scheduled_response.ul_config->ul_config_list[0].pusch_config_pdu.num_dmrs_cdm_grps_no_data = 1;
- scheduled_response.ul_config->ul_config_list[0].pusch_config_pdu.pusch_data.new_data_indicator = 0;
- scheduled_response.ul_config->ul_config_list[0].pusch_config_pdu.pusch_data.rv_index = rv_index;
- scheduled_response.ul_config->ul_config_list[0].pusch_config_pdu.nrOfLayers = nrOfLayers;
- scheduled_response.ul_config->ul_config_list[0].pusch_config_pdu.pusch_data.harq_process_id = harq_process_id;
- scheduled_response.ul_config->ul_config_list[0].pusch_config_pdu.pdu_bit_map = pdu_bit_map;
- scheduled_response.ul_config->ul_config_list[0].pusch_config_pdu.pusch_ptrs.ptrs_time_density = ptrs_time_density;
- scheduled_response.ul_config->ul_config_list[0].pusch_config_pdu.pusch_ptrs.ptrs_freq_density = ptrs_freq_density;
- scheduled_response.ul_config->ul_config_list[0].pusch_config_pdu.pusch_ptrs.ptrs_ports_list = (nfapi_nr_ue_ptrs_ports_t *) malloc(2*sizeof(nfapi_nr_ue_ptrs_ports_t));
- scheduled_response.ul_config->ul_config_list[0].pusch_config_pdu.pusch_ptrs.ptrs_ports_list[0].ptrs_re_offset = 0;
-
- if (1 << ptrs_time_density >= nr_of_symbols) {
- scheduled_response.ul_config->ul_config_list[0].pusch_config_pdu.pdu_bit_map &= ~PUSCH_PDU_BITMAP_PUSCH_PTRS; // disable PUSCH PTRS
- }
-
+ fill_scheduled_response(&scheduled_response, NULL, ul_config, &tx_req, mod_id, cc_id, rx_frame, rx_slot);
if(mac->if_module != NULL && mac->if_module->scheduled_response != NULL){
mac->if_module->scheduled_response(&scheduled_response);
}
@@ -929,11 +955,116 @@ NR_UE_L2_STATE_t nr_ue_scheduler(nr_downlink_indication_t *dl_info, nr_uplink_in
// Note: Contention resolution is currently not active
if (mac->RA_contention_resolution_timer_active == 1)
ue_contention_resolution(mod_id, gNB_index, cc_id, ul_info->frame_tx);
+
+ } else if (get_softmodem_params()->do_ra){
+
+ NR_UE_MAC_INST_t *mac = get_mac_inst(ul_info->module_id);
+
+ if (mac->RA_active && ul_info->slot_tx == mac->msg3_slot && ul_info->frame_tx == mac->msg3_frame){
+
+ uint8_t ulsch_input_buffer[MAX_ULSCH_PAYLOAD_BYTES];
+ nr_scheduled_response_t scheduled_response;
+ fapi_nr_tx_request_t tx_req;
+ fapi_nr_tx_request_body_t tx_req_body;
+ fapi_nr_ul_config_request_t *ul_config = &mac->ul_config_request;
+ fapi_nr_ul_config_request_pdu_t *ul_config_list = &ul_config->ul_config_list[ul_config->number_pdus];
+ uint16_t TBS_bytes = ul_config_list->pusch_config_pdu.pusch_data.tb_size;
+
+ //if (IS_SOFTMODEM_NOS1){
+ // // Getting IP traffic to be transmitted
+ // data_existing = nr_ue_get_sdu(mod_id,
+ // cc_id,
+ // frame_tx,
+ // slot_tx,
+ // 0,
+ // ulsch_input_buffer,
+ // TBS_bytes,
+ // &access_mode);
+ //}
+
+ //Random traffic to be transmitted if there is no IP traffic available for this Tx opportunity
+ //if (!IS_SOFTMODEM_NOS1 || !data_existing) {
+ //Use zeros for the header bytes in noS1 mode, in order to make sure that the LCID is not valid
+ //and block this traffic from being forwarded to the upper layers at the gNB
+ LOG_D(MAC, "Random data to be tranmsitted (TBS_bytes %d): \n", TBS_bytes);
+ //Give the first byte a dummy value (a value not corresponding to any valid LCID based on 38.321, Table 6.2.1-2)
+ //in order to distinguish the PHY random packets at the MAC layer of the gNB receiver from the normal packets that should
+ //have a valid LCID (nr_process_mac_pdu function)
+ ulsch_input_buffer[0] = 0x31;
+ for (int i = 1; i < TBS_bytes; i++) {
+ ulsch_input_buffer[i] = (unsigned char) rand();
+ //printf(" input encoder a[%d]=0x%02x\n",i,harq_process_ul_ue->a[i]);
+ }
+ //}
+
+ LOG_D(MAC, "[UE %d] Frame %d, Subframe %d Adding Msg3 UL Config Request for rnti: %x\n",
+ ul_info->module_id,
+ ul_info->frame_tx,
+ ul_info->slot_tx,
+ mac->t_crnti);
+
+ // Config UL TX PDU
+ tx_req.slot = ul_info->slot_tx;
+ tx_req.sfn = ul_info->frame_tx;
+ tx_req.number_of_pdus = 1;
+ tx_req_body.pdu_length = TBS_bytes;
+ tx_req_body.pdu_index = 0;
+ tx_req_body.pdu = ulsch_input_buffer;
+ tx_req.tx_request_body = &tx_req_body;
+ ul_config_list->pdu_type = FAPI_NR_UL_CONFIG_TYPE_PUSCH;
+ ul_config->number_pdus++;
+ // scheduled_response
+ fill_scheduled_response(&scheduled_response, NULL, ul_config, &tx_req, ul_info->module_id, ul_info->cc_id, ul_info->frame_rx, ul_info->slot_rx);
+ if(mac->if_module != NULL && mac->if_module->scheduled_response != NULL){
+ mac->if_module->scheduled_response(&scheduled_response);
+ }
+ }
}
}
return UE_CONNECTION_OK;
}
+// PUSCH Msg3 scheduled by RAR UL grant according to 8.3 of TS 38.213
+// Note: Msg3 tx in the uplink symbols of mixed slot
+void nr_ue_msg3_scheduler(NR_UE_MAC_INST_t *mac,
+ frame_t current_frame,
+ sub_frame_t current_slot,
+ uint8_t Msg3_tda_id){
+
+ int delta = 0;
+ NR_BWP_Uplink_t *ubwp = mac->ULbwp[0];
+ int mu = ubwp->bwp_Common->genericParameters.subcarrierSpacing;
+ struct NR_PUSCH_TimeDomainResourceAllocationList *pusch_TimeDomainAllocationList = ubwp->bwp_Common->pusch_ConfigCommon->choice.setup->pusch_TimeDomainAllocationList;
+ // k2 as per 3GPP TS 38.214 version 15.9.0 Release 15 ch 6.1.2.1.1
+ // PUSCH time domain resource allocation is higher layer configured from uschTimeDomainAllocationList in either pusch-ConfigCommon
+ uint8_t k2 = *pusch_TimeDomainAllocationList->list.array[Msg3_tda_id]->k2;
+
+ switch (mu) {
+ case 0:
+ delta = 2;
+ break;
+ case 1:
+ delta = 3;
+ break;
+ case 2:
+ delta = 4;
+ break;
+ case 3:
+ delta = 6;
+ break;
+ }
+
+ mac->msg3_slot = (current_slot + k2 + delta) % nr_slots_per_frame[mu];
+ if (current_slot + k2 + delta > nr_slots_per_frame[mu])
+ mac->msg3_frame = (current_frame + 1) % 1024;
+ else
+ mac->msg3_frame = current_frame;
+
+ #ifdef DEBUG_MSG3
+ LOG_D(MAC, "[DEBUG_MSG3] current_slot %d k2 %d delta %d temp_slot %d mac->msg3_frame %d mac->msg3_slot %d \n", current_slot, k2, delta, current_slot + k2 + delta, mac->msg3_frame, mac->msg3_slot);
+ #endif
+}
+
// This function schedules the PRACH according to prach_ConfigurationIndex and TS 38.211, tables 6.3.3.2.x
// It fills the PRACH PDU per each FD occasion.
// PRACH formats 9, 10, 11 are corresponding to dual PRACH format configurations A1/B1, A2/B2, A3/B3.
@@ -951,6 +1082,7 @@ void nr_ue_prach_scheduler(module_id_t module_idP, frame_t frameP, sub_frame_t s
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;
+ nr_scheduled_response_t scheduled_response;
NR_ServingCellConfigCommon_t *scc = mac->scc;
NR_RACH_ConfigCommon_t *setup = scc->uplinkConfigCommon->initialUplinkBWP->rach_ConfigCommon->choice.setup;
@@ -1081,10 +1213,11 @@ void nr_ue_prach_scheduler(module_id_t module_idP, frame_t frameP, sub_frame_t s
}
}
}
- } else if (mac->ra_state == RA_SUCCEEDED){
- mac->generate_nr_prach = 2;
}
- mac->scheduled_response.ul_config = ul_config;
+
+ fill_scheduled_response(&scheduled_response, NULL, ul_config, NULL, module_idP, 0 /*TBR fix*/, frameP, slotP);
+ if(mac->if_module != NULL && mac->if_module->scheduled_response != NULL)
+ mac->if_module->scheduled_response(&scheduled_response);
}
}
@@ -2261,13 +2394,22 @@ int8_t nr_ue_process_dci_time_dom_resource_assignment(NR_UE_MAC_INST_t *mac,
*/
if(pusch_config_pdu != NULL){
NR_PUSCH_TimeDomainResourceAllocationList_t *pusch_TimeDomainAllocationList = NULL;
- if (mac->ULbwp[0]->bwp_Dedicated->pusch_Config)
+ if (mac->ULbwp[0]->bwp_Dedicated->pusch_Config->choice.setup->pusch_TimeDomainAllocationList) {
pusch_TimeDomainAllocationList = mac->ULbwp[0]->bwp_Dedicated->pusch_Config->choice.setup->pusch_TimeDomainAllocationList->choice.setup;
-
+ }
+ else if (mac->ULbwp[0]->bwp_Common->pusch_ConfigCommon->choice.setup->pusch_TimeDomainAllocationList) {
+ pusch_TimeDomainAllocationList = mac->ULbwp[0]->bwp_Common->pusch_ConfigCommon->choice.setup->pusch_TimeDomainAllocationList;
+ }
+
if (pusch_TimeDomainAllocationList) {
- AssertFatal(pusch_TimeDomainAllocationList->list.count > time_domain_ind,
- "time_domain_ind %d >= pdsch->TimeDomainAllocationList->list.count %d\n",
- time_domain_ind,pusch_TimeDomainAllocationList->list.count);
+ if (time_domain_ind >= pusch_TimeDomainAllocationList->list.count) {
+ LOG_E(MAC, "time_domain_ind %d >= pusch->TimeDomainAllocationList->list.count %d\n",
+ time_domain_ind, pusch_TimeDomainAllocationList->list.count);
+ pusch_config_pdu->start_symbol_index=0;
+ pusch_config_pdu->nr_of_symbols=0;
+ return -1;
+ }
+
int startSymbolAndLength = pusch_TimeDomainAllocationList->list.array[time_domain_ind]->startSymbolAndLength;
int S,L;
SLIV2SL(startSymbolAndLength,&S,&L);
@@ -2295,8 +2437,8 @@ int nr_ue_process_dci_indication_pdu(module_id_t module_id,int cc_id, int gNB_in
LOG_D(MAC,"Received dci indication (rnti %x,dci format %d,n_CCE %d,payloadSize %d,payload %llx)\n",
dci->rnti,dci->dci_format,dci->n_CCE,dci->payloadSize,*(unsigned long long*)dci->payloadBits);
- nr_extract_dci_info(mac,dci->dci_format,dci->payloadSize,dci->rnti,(uint64_t *)dci->payloadBits,def_dci_pdu_rel15);
- return (nr_ue_process_dci(module_id, cc_id, gNB_index, def_dci_pdu_rel15, dci->rnti, dci->dci_format));
+ int dci_format = nr_extract_dci_info(mac,dci->dci_format,dci->payloadSize,dci->rnti,(uint64_t *)dci->payloadBits,def_dci_pdu_rel15);
+ return (nr_ue_process_dci(module_id, cc_id, gNB_index, def_dci_pdu_rel15, dci->rnti, dci_format));
}
int8_t nr_ue_process_dci(module_id_t module_id, int cc_id, uint8_t gNB_index, dci_pdu_rel15_t *dci, uint16_t rnti, uint32_t dci_format){
@@ -2317,6 +2459,7 @@ int8_t nr_ue_process_dci(module_id_t module_id, int cc_id, uint8_t gNB_index, dc
LOG_D(MAC,"nr_ue_process_dci at MAC layer with dci_format=%d (DL BWP %d, UL BWP %d)\n",dci_format,n_RB_DLBWP,n_RB_ULBWP);
NR_PDSCH_Config_t *pdsch_config=mac->DLbwp[0]->bwp_Dedicated->pdsch_Config->choice.setup;
+ NR_PUSCH_Config_t *pusch_config=mac->ULbwp[0]->bwp_Dedicated->pusch_Config->choice.setup;
switch(dci_format){
case NR_UL_DCI_FORMAT_0_0:
@@ -2423,6 +2566,23 @@ int8_t nr_ue_process_dci(module_id_t module_id, int cc_id, uint8_t gNB_index, dc
pusch_config_pdu_0_1->frequency_hopping = dci->frequency_hopping_flag.val;
/* MCS */
pusch_config_pdu_0_1->mcs_index = dci->mcs;
+ /* MCS TABLE */
+ if (pusch_config->transformPrecoder == NULL) {
+ if (mac->scc->uplinkConfigCommon->initialUplinkBWP->rach_ConfigCommon->choice.setup->msg3_transformPrecoder == NULL)
+ pusch_config_pdu_0_1->transform_precoding = 1;
+ else
+ pusch_config_pdu_0_1->transform_precoding = 0;
+ }
+ else
+ pusch_config_pdu_0_1->transform_precoding = *pusch_config->transformPrecoder;
+
+ if (pusch_config_pdu_0_1->transform_precoding == transform_precoder_disabled)
+ pusch_config_pdu_0_1->mcs_table = get_pusch_mcs_table(pusch_config->mcs_Table, 0,
+ dci_format, NR_RNTI_C, NR_SearchSpace__searchSpaceType_PR_ue_Specific, false);
+ else
+ pusch_config_pdu_0_1->mcs_table = get_pusch_mcs_table(pusch_config->mcs_TableTransformPrecoder, 1,
+ dci_format, NR_RNTI_C, NR_SearchSpace__searchSpaceType_PR_ue_Specific, false);
+
/* NDI */
pusch_config_pdu_0_1->pusch_data.new_data_indicator = dci->ndi;
/* RV */
@@ -3102,7 +3262,33 @@ void nr_ue_send_sdu(module_id_t module_idP,
}
-void nr_extract_dci_info(NR_UE_MAC_INST_t *mac,
+// N_RB configuration according to 7.3.1.0 (DCI size alignment) of TS 38.212
+int get_n_rb(NR_UE_MAC_INST_t *mac, int rnti_type){
+
+ int N_RB = 0, start_RB;
+ switch(rnti_type) {
+ case NR_RNTI_RA:
+ case NR_RNTI_TC:
+ case NR_RNTI_P:
+ case NR_RNTI_SI:
+ if (mac->DLbwp[0]->bwp_Common->pdcch_ConfigCommon->choice.setup->controlResourceSetZero) {
+ uint8_t bwp_id = 1;
+ uint8_t coreset_id = 0; // assuming controlResourceSetId is 0 for controlResourceSetZero
+ NR_ControlResourceSet_t *coreset = mac->coreset[bwp_id - 1][coreset_id];
+ get_coreset_rballoc(coreset->frequencyDomainResources.buf,&N_RB,&start_RB);
+ } else {
+ N_RB = NRRIV2BW(mac->scc->downlinkConfigCommon->initialDownlinkBWP->genericParameters.locationAndBandwidth, 275);
+ }
+ break;
+ case NR_RNTI_C:
+ N_RB = NRRIV2BW(mac->DLbwp[0]->bwp_Common->genericParameters.locationAndBandwidth, 275);
+ break;
+ }
+ return N_RB;
+
+}
+
+int nr_extract_dci_info(NR_UE_MAC_INST_t *mac,
int dci_format,
uint8_t dci_size,
uint16_t rnti,
@@ -3119,21 +3305,45 @@ void nr_extract_dci_info(NR_UE_MAC_INST_t *mac,
AssertFatal(rnti_type!=-1,"no identified/handled rnti\n");
AssertFatal(mac->DLbwp[0] != NULL, "DLbwp[0] shouldn't be null here!\n");
AssertFatal(mac->ULbwp[0] != NULL, "ULbwp[0] shouldn't be null here!\n");
- int N_RB = (mac->scg != NULL) ?
- NRRIV2BW(mac->DLbwp[0]->bwp_Common->genericParameters.locationAndBandwidth,275) :
- NRRIV2BW(mac->scc->downlinkConfigCommon->initialDownlinkBWP->genericParameters.locationAndBandwidth,275);
+ int N_RB = get_n_rb(mac, rnti_type);
int N_RB_UL = (mac->scg != NULL) ?
NRRIV2BW(mac->ULbwp[0]->bwp_Common->genericParameters.locationAndBandwidth,275) :
NRRIV2BW(mac->scc->uplinkConfigCommon->initialUplinkBWP->genericParameters.locationAndBandwidth,275);
int pos=0;
int fsize=0;
+
+ if (rnti_type == NR_RNTI_C) {
+ // First find out the DCI format from the first bit (UE performed blind decoding)
+ pos++;
+ dci_pdu_rel15->format_indicator = (*dci_pdu>>(dci_size-pos))&1;
+#ifdef DEBUG_EXTRACT_DCI
+ LOG_D(MAC,"Format indicator %d (%d bits) N_RB_BWP %d => %d (0x%lx)\n",dci_pdu_rel15->format_indicator,1,N_RB,dci_size-pos,*dci_pdu);
+#endif
+
+ if (dci_format == NR_UL_DCI_FORMAT_0_0 || dci_format == NR_DL_DCI_FORMAT_1_0) {
+ if (dci_pdu_rel15->format_indicator == 0)
+ dci_format = NR_UL_DCI_FORMAT_0_0;
+ else
+ dci_format = NR_DL_DCI_FORMAT_1_0;
+ }
+ else if (dci_format == NR_UL_DCI_FORMAT_0_1 || dci_format == NR_DL_DCI_FORMAT_1_1) {
+ // In case the sizes of formats 0_1 and 1_1 happen to be the same
+ if (dci_pdu_rel15->format_indicator == 0)
+ dci_format = NR_UL_DCI_FORMAT_0_1;
+ else
+ dci_format = NR_DL_DCI_FORMAT_1_1;
+ }
+ }
+#ifdef DEBUG_EXTRACT_DCI
+ LOG_D(MAC, "DCI format is %d\n", dci_format);
+#endif
+
switch(dci_format) {
case NR_DL_DCI_FORMAT_1_0:
switch(rnti_type) {
case NR_RNTI_RA:
- N_RB = NRRIV2BW(mac->scc->downlinkConfigCommon->initialDownlinkBWP->genericParameters.locationAndBandwidth, 275); // TBR hotfix
// Freq domain assignment
fsize = (int)ceil( log2( (N_RB*(N_RB+1))>>1 ) );
pos=fsize;
@@ -3170,13 +3380,6 @@ void nr_extract_dci_info(NR_UE_MAC_INST_t *mac,
case NR_RNTI_C:
- // indicating a DL DCI format 1bit
- pos++;
- dci_pdu_rel15->format_indicator = (*dci_pdu>>(dci_size-pos))&1;
-#ifdef DEBUG_EXTRACT_DCI
- LOG_D(MAC,"Format indicator %d (%d bits) N_RB_BWP %d => %d (0x%lx)\n",dci_pdu_rel15->format_indicator,1,N_RB,dci_size-pos,*dci_pdu);
-#endif
-
// Freq domain assignment (275rb >> fsize = 16)
fsize = (int)ceil( log2( (N_RB*(N_RB+1))>>1 ) );
pos+=fsize;
@@ -3377,18 +3580,16 @@ void nr_extract_dci_info(NR_UE_MAC_INST_t *mac,
switch(rnti_type)
{
case NR_RNTI_C:
- // indicating a DL DCI format 1bit
- dci_pdu_rel15->format_indicator = (*dci_pdu>>(dci_size-pos))&1;
- // Freq domain assignment max 16 bit
fsize = (int)ceil( log2( (N_RB_UL*(N_RB_UL+1))>>1 ) );
pos+=fsize;
dci_pdu_rel15->frequency_domain_assignment.val = (*dci_pdu>>(dci_size-pos))&((1<time_domain_assignment.val = (*dci_pdu>>(dci_size-pos))&0xf;
- // Frequency hopping flag – 1 bit
- pos++;
- dci_pdu_rel15->frequency_hopping_flag.val= (*dci_pdu>>(dci_size-pos))&1;
+ // This is not supported yet - Skip for now
+ // Frequency hopping flag – 1 bit
+ //pos++;
+ //dci_pdu_rel15->frequency_hopping_flag.val= (*dci_pdu>>(dci_size-pos))&1;
// MCS 5 bit
pos+=5;
dci_pdu_rel15->mcs= (*dci_pdu>>(dci_size-pos))&0x1f;
@@ -3452,89 +3653,203 @@ void nr_extract_dci_info(NR_UE_MAC_INST_t *mac,
break;
case NR_DL_DCI_FORMAT_1_1:
- // Format indicator
- pos=1;
- dci_pdu_rel15->format_indicator = (*dci_pdu>>(dci_size-pos))&1;
- // Carrier indicator
- pos+=dci_pdu_rel15->carrier_indicator.nbits;
- dci_pdu_rel15->carrier_indicator.val = (*dci_pdu>>(dci_size-pos))&((1<carrier_indicator.nbits)-1);
- // BWP Indicator
- pos+=dci_pdu_rel15->bwp_indicator.nbits;
- dci_pdu_rel15->bwp_indicator.val = (*dci_pdu>>(dci_size-pos))&((1<bwp_indicator.nbits)-1);
- // Frequency domain resource assignment
- pos+=dci_pdu_rel15->frequency_domain_assignment.nbits;
- dci_pdu_rel15->frequency_domain_assignment.val = (*dci_pdu>>(dci_size-pos))&((1<frequency_domain_assignment.nbits)-1);
- // Time domain resource assignment
- pos+=dci_pdu_rel15->time_domain_assignment.nbits;
- dci_pdu_rel15->time_domain_assignment.val = (*dci_pdu>>(dci_size-pos))&((1<time_domain_assignment.nbits)-1);
- // VRB-to-PRB mapping
- pos+=dci_pdu_rel15->vrb_to_prb_mapping.nbits;
- dci_pdu_rel15->vrb_to_prb_mapping.val = (*dci_pdu>>(dci_size-pos))&((1<vrb_to_prb_mapping.nbits)-1);
- // PRB bundling size indicator
- pos+=dci_pdu_rel15->prb_bundling_size_indicator.nbits;
- dci_pdu_rel15->prb_bundling_size_indicator.val = (*dci_pdu>>(dci_size-pos))&((1<prb_bundling_size_indicator.nbits)-1);
- // Rate matching indicator
- pos+=dci_pdu_rel15->rate_matching_indicator.nbits;
- dci_pdu_rel15->rate_matching_indicator.val = (*dci_pdu>>(dci_size-pos))&((1<rate_matching_indicator.nbits)-1);
- // ZP CSI-RS trigger
- pos+=dci_pdu_rel15->zp_csi_rs_trigger.nbits;
- dci_pdu_rel15->zp_csi_rs_trigger.val = (*dci_pdu>>(dci_size-pos))&((1<zp_csi_rs_trigger.nbits)-1);
- //TB1
- // MCS 5bit
- pos+=5;
- dci_pdu_rel15->mcs = (*dci_pdu>>(dci_size-pos))&0x1f;
- // New data indicator 1bit
- pos+=1;
- dci_pdu_rel15->ndi = (*dci_pdu>>(dci_size-pos))&0x1;
- // Redundancy version 2bit
- pos+=2;
- dci_pdu_rel15->rv = (*dci_pdu>>(dci_size-pos))&0x3;
- //TB2
- // MCS 5bit
- pos+=dci_pdu_rel15->mcs2.nbits;
- dci_pdu_rel15->mcs2.val = (*dci_pdu>>(dci_size-pos))&((1<mcs2.nbits)-1);
- // New data indicator 1bit
- pos+=dci_pdu_rel15->ndi2.nbits;
- dci_pdu_rel15->ndi2.val = (*dci_pdu>>(dci_size-pos))&((1<ndi2.nbits)-1);
- // Redundancy version 2bit
- pos+=dci_pdu_rel15->rv2.nbits;
- dci_pdu_rel15->rv2.val = (*dci_pdu>>(dci_size-pos))&((1<rv2.nbits)-1);
- // HARQ process number 4bit
- pos+=4;
- dci_pdu_rel15->harq_pid = (*dci_pdu>>(dci_size-pos))&0xf;
- // Downlink assignment index
- pos+=dci_pdu_rel15->dai[0].nbits;
- dci_pdu_rel15->dai[0].val = (*dci_pdu>>(dci_size-pos))&((1<dai[0].nbits)-1);
- // TPC command for scheduled PUCCH 2bit
- pos+=2;
- dci_pdu_rel15->tpc = (*dci_pdu>>(dci_size-pos))&0x3;
- // PUCCH resource indicator 3bit
- pos+=3;
- dci_pdu_rel15->pucch_resource_indicator = (*dci_pdu>>(dci_size-pos))&0x3;
- // PDSCH-to-HARQ_feedback timing indicator
- pos+=dci_pdu_rel15->pdsch_to_harq_feedback_timing_indicator.nbits;
- dci_pdu_rel15->pdsch_to_harq_feedback_timing_indicator.val = (*dci_pdu>>(dci_size-pos))&((1<pdsch_to_harq_feedback_timing_indicator.nbits)-1);
- // Antenna ports
- pos+=dci_pdu_rel15->antenna_ports.nbits;
- dci_pdu_rel15->antenna_ports.val = (*dci_pdu>>(dci_size-pos))&((1<antenna_ports.nbits)-1);
- // TCI
- pos+=dci_pdu_rel15->transmission_configuration_indication.nbits;
- dci_pdu_rel15->transmission_configuration_indication.val = (*dci_pdu>>(dci_size-pos))&((1<transmission_configuration_indication.nbits)-1);
- // SRS request
- pos+=dci_pdu_rel15->srs_request.nbits;
- dci_pdu_rel15->srs_request.val = (*dci_pdu>>(dci_size-pos))&((1<srs_request.nbits)-1);
- // CBG transmission information
- pos+=dci_pdu_rel15->cbgti.nbits;
- dci_pdu_rel15->cbgti.val = (*dci_pdu>>(dci_size-pos))&((1<cbgti.nbits)-1);
- // CBG flushing out information
- pos+=dci_pdu_rel15->cbgfi.nbits;
- dci_pdu_rel15->cbgfi.val = (*dci_pdu>>(dci_size-pos))&((1<cbgfi.nbits)-1);
- // DMRS sequence init
- pos+=1;
- dci_pdu_rel15->dmrs_sequence_initialization.val = (*dci_pdu>>(dci_size-pos))&0x1;
- break;
+ switch(rnti_type)
+ {
+ case NR_RNTI_C:
+ // Carrier indicator
+ pos+=dci_pdu_rel15->carrier_indicator.nbits;
+ dci_pdu_rel15->carrier_indicator.val = (*dci_pdu>>(dci_size-pos))&((1<carrier_indicator.nbits)-1);
+ // BWP Indicator
+ pos+=dci_pdu_rel15->bwp_indicator.nbits;
+ dci_pdu_rel15->bwp_indicator.val = (*dci_pdu>>(dci_size-pos))&((1<bwp_indicator.nbits)-1);
+ // Frequency domain resource assignment
+ pos+=dci_pdu_rel15->frequency_domain_assignment.nbits;
+ dci_pdu_rel15->frequency_domain_assignment.val = (*dci_pdu>>(dci_size-pos))&((1<frequency_domain_assignment.nbits)-1);
+ // Time domain resource assignment
+ pos+=dci_pdu_rel15->time_domain_assignment.nbits;
+ dci_pdu_rel15->time_domain_assignment.val = (*dci_pdu>>(dci_size-pos))&((1<time_domain_assignment.nbits)-1);
+ // VRB-to-PRB mapping
+ pos+=dci_pdu_rel15->vrb_to_prb_mapping.nbits;
+ dci_pdu_rel15->vrb_to_prb_mapping.val = (*dci_pdu>>(dci_size-pos))&((1<vrb_to_prb_mapping.nbits)-1);
+ // PRB bundling size indicator
+ pos+=dci_pdu_rel15->prb_bundling_size_indicator.nbits;
+ dci_pdu_rel15->prb_bundling_size_indicator.val = (*dci_pdu>>(dci_size-pos))&((1<prb_bundling_size_indicator.nbits)-1);
+ // Rate matching indicator
+ pos+=dci_pdu_rel15->rate_matching_indicator.nbits;
+ dci_pdu_rel15->rate_matching_indicator.val = (*dci_pdu>>(dci_size-pos))&((1<rate_matching_indicator.nbits)-1);
+ // ZP CSI-RS trigger
+ pos+=dci_pdu_rel15->zp_csi_rs_trigger.nbits;
+ dci_pdu_rel15->zp_csi_rs_trigger.val = (*dci_pdu>>(dci_size-pos))&((1<zp_csi_rs_trigger.nbits)-1);
+ //TB1
+ // MCS 5bit
+ pos+=5;
+ dci_pdu_rel15->mcs = (*dci_pdu>>(dci_size-pos))&0x1f;
+ // New data indicator 1bit
+ pos+=1;
+ dci_pdu_rel15->ndi = (*dci_pdu>>(dci_size-pos))&0x1;
+ // Redundancy version 2bit
+ pos+=2;
+ dci_pdu_rel15->rv = (*dci_pdu>>(dci_size-pos))&0x3;
+ //TB2
+ // MCS 5bit
+ pos+=dci_pdu_rel15->mcs2.nbits;
+ dci_pdu_rel15->mcs2.val = (*dci_pdu>>(dci_size-pos))&((1<mcs2.nbits)-1);
+ // New data indicator 1bit
+ pos+=dci_pdu_rel15->ndi2.nbits;
+ dci_pdu_rel15->ndi2.val = (*dci_pdu>>(dci_size-pos))&((1<ndi2.nbits)-1);
+ // Redundancy version 2bit
+ pos+=dci_pdu_rel15->rv2.nbits;
+ dci_pdu_rel15->rv2.val = (*dci_pdu>>(dci_size-pos))&((1<rv2.nbits)-1);
+ // HARQ process number 4bit
+ pos+=4;
+ dci_pdu_rel15->harq_pid = (*dci_pdu>>(dci_size-pos))&0xf;
+ // Downlink assignment index
+ pos+=dci_pdu_rel15->dai[0].nbits;
+ dci_pdu_rel15->dai[0].val = (*dci_pdu>>(dci_size-pos))&((1<dai[0].nbits)-1);
+ // TPC command for scheduled PUCCH 2bit
+ pos+=2;
+ dci_pdu_rel15->tpc = (*dci_pdu>>(dci_size-pos))&0x3;
+ // PUCCH resource indicator 3bit
+ pos+=3;
+ dci_pdu_rel15->pucch_resource_indicator = (*dci_pdu>>(dci_size-pos))&0x3;
+ // PDSCH-to-HARQ_feedback timing indicator
+ pos+=dci_pdu_rel15->pdsch_to_harq_feedback_timing_indicator.nbits;
+ dci_pdu_rel15->pdsch_to_harq_feedback_timing_indicator.val = (*dci_pdu>>(dci_size-pos))&((1<pdsch_to_harq_feedback_timing_indicator.nbits)-1);
+ // Antenna ports
+ pos+=dci_pdu_rel15->antenna_ports.nbits;
+ dci_pdu_rel15->antenna_ports.val = (*dci_pdu>>(dci_size-pos))&((1<antenna_ports.nbits)-1);
+ // TCI
+ pos+=dci_pdu_rel15->transmission_configuration_indication.nbits;
+ dci_pdu_rel15->transmission_configuration_indication.val = (*dci_pdu>>(dci_size-pos))&((1<transmission_configuration_indication.nbits)-1);
+ // SRS request
+ pos+=dci_pdu_rel15->srs_request.nbits;
+ dci_pdu_rel15->srs_request.val = (*dci_pdu>>(dci_size-pos))&((1<srs_request.nbits)-1);
+ // CBG transmission information
+ pos+=dci_pdu_rel15->cbgti.nbits;
+ dci_pdu_rel15->cbgti.val = (*dci_pdu>>(dci_size-pos))&((1<cbgti.nbits)-1);
+ // CBG flushing out information
+ pos+=dci_pdu_rel15->cbgfi.nbits;
+ dci_pdu_rel15->cbgfi.val = (*dci_pdu>>(dci_size-pos))&((1<cbgfi.nbits)-1);
+ // DMRS sequence init
+ pos+=1;
+ dci_pdu_rel15->dmrs_sequence_initialization.val = (*dci_pdu>>(dci_size-pos))&0x1;
+ break;
+ }
+ break;
- }
+ case NR_UL_DCI_FORMAT_0_1:
+ switch(rnti_type)
+ {
+ case NR_RNTI_C:
+ // Carrier indicator
+ pos+=dci_pdu_rel15->carrier_indicator.nbits;
+ dci_pdu_rel15->carrier_indicator.val = (*dci_pdu>>(dci_size-pos))&((1<carrier_indicator.nbits)-1);
+
+ // UL/SUL Indicator
+ pos+=dci_pdu_rel15->ul_sul_indicator.nbits;
+ dci_pdu_rel15->ul_sul_indicator.val = (*dci_pdu>>(dci_size-pos))&((1<ul_sul_indicator.nbits)-1);
+
+ // BWP Indicator
+ pos+=dci_pdu_rel15->bwp_indicator.nbits;
+ dci_pdu_rel15->bwp_indicator.val = (*dci_pdu>>(dci_size-pos))&((1<bwp_indicator.nbits)-1);
+
+ // Freq domain assignment max 16 bit
+ fsize = (int)ceil( log2( (N_RB_UL*(N_RB_UL+1))>>1 ) );
+ //pos+=dci_pdu_rel15->frequency_domain_assignment.nbits;
+ pos+=fsize;
+
+ //pos+=dci_pdu_rel15->frequency_domain_assignment.nbits;
+ dci_pdu_rel15->frequency_domain_assignment.val = (*dci_pdu>>(dci_size-pos))&((1<time_domain_assignment.nbits;
+ dci_pdu_rel15->time_domain_assignment.val = (*dci_pdu>>(dci_size-pos))&0x3;
+
+ // Not supported yet - skip for now
+ // Frequency hopping flag – 1 bit
+ //pos++;
+ //dci_pdu_rel15->frequency_hopping_flag.val= (*dci_pdu>>(dci_size-pos))&1;
+
+ // MCS 5 bit
+ pos+=5;
+ dci_pdu_rel15->mcs= (*dci_pdu>>(dci_size-pos))&0x1f;
+
+ // New data indicator 1bit
+ pos++;
+ dci_pdu_rel15->ndi= (*dci_pdu>>(dci_size-pos))&1;
+
+ // Redundancy version 2bit
+ pos+=2;
+ dci_pdu_rel15->rv= (*dci_pdu>>(dci_size-pos))&3;
+
+ // HARQ process number 4bit
+ pos+=4;
+ dci_pdu_rel15->harq_pid = (*dci_pdu>>(dci_size-pos))&0xf;
+
+ // 1st Downlink assignment index
+ pos+=dci_pdu_rel15->dai[0].nbits;
+ dci_pdu_rel15->dai[0].val = (*dci_pdu>>(dci_size-pos))&((1<dai[0].nbits)-1);
+
+ // 2nd Downlink assignment index
+ pos+=dci_pdu_rel15->dai[1].nbits;
+ dci_pdu_rel15->dai[1].val = (*dci_pdu>>(dci_size-pos))&((1<dai[1].nbits)-1);
+
+ // TPC command for scheduled PUSCH – 2 bits
+ pos+=2;
+ dci_pdu_rel15->tpc = (*dci_pdu>>(dci_size-pos))&3;
+
+ // SRS resource indicator
+ pos+=dci_pdu_rel15->srs_resource_indicator.nbits;
+ dci_pdu_rel15->srs_resource_indicator.val = (*dci_pdu>>(dci_size-pos))&((1<srs_resource_indicator.nbits)-1);
+
+ // Precoding info and n. of layers
+ pos+=dci_pdu_rel15->precoding_information.nbits;
+ dci_pdu_rel15->precoding_information.val = (*dci_pdu>>(dci_size-pos))&((1<precoding_information.nbits)-1);
+
+ // Antenna ports
+ pos+=dci_pdu_rel15->antenna_ports.nbits;
+ dci_pdu_rel15->antenna_ports.val = (*dci_pdu>>(dci_size-pos))&((1<antenna_ports.nbits)-1);
+
+ // SRS request
+ pos+=dci_pdu_rel15->srs_request.nbits;
+ dci_pdu_rel15->srs_request.val = (*dci_pdu>>(dci_size-pos))&((1<srs_request.nbits)-1);
+
+ // CSI request
+ pos+=dci_pdu_rel15->csi_request.nbits;
+ dci_pdu_rel15->csi_request.val = (*dci_pdu>>(dci_size-pos))&((1<csi_request.nbits)-1);
+
+ // CBG transmission information
+ pos+=dci_pdu_rel15->cbgti.nbits;
+ dci_pdu_rel15->cbgti.val = (*dci_pdu>>(dci_size-pos))&((1<cbgti.nbits)-1);
+
+ // PTRS DMRS association
+ pos+=dci_pdu_rel15->ptrs_dmrs_association.nbits;
+ dci_pdu_rel15->ptrs_dmrs_association.val = (*dci_pdu>>(dci_size-pos))&((1<ptrs_dmrs_association.nbits)-1);
+
+ // Beta offset indicator
+ pos+=dci_pdu_rel15->beta_offset_indicator.nbits;
+ dci_pdu_rel15->beta_offset_indicator.val = (*dci_pdu>>(dci_size-pos))&((1<beta_offset_indicator.nbits)-1);
+
+ // DMRS sequence initialization
+ pos+=dci_pdu_rel15->dmrs_sequence_initialization.nbits;
+ dci_pdu_rel15->dmrs_sequence_initialization.val = (*dci_pdu>>(dci_size-pos))&((1<dmrs_sequence_initialization.nbits)-1);
+
+ // UL-SCH indicator
+ pos+=1;
+ dci_pdu_rel15->ulsch_indicator = (*dci_pdu>>(dci_size-pos))&0x1;
+
+ // UL/SUL indicator – 1 bit
+ /* commented for now (RK): need to get this from BWP descriptor
+ if (cfg->pucch_config.pucch_GroupHopping.value)
+ dci_pdu->= ((uint64_t)*dci_pdu>>(dci_size-pos)ul_sul_indicator&1)<<(dci_size-pos++);
+ */
+ break;
+ }
+ break;
+ }
+
+ return dci_format;
}
diff --git a/openair2/LAYER2/NR_MAC_UE/rar_tools_nrUE.c b/openair2/LAYER2/NR_MAC_UE/rar_tools_nrUE.c
index 8d52db6747..06db41df9c 100644
--- a/openair2/LAYER2/NR_MAC_UE/rar_tools_nrUE.c
+++ b/openair2/LAYER2/NR_MAC_UE/rar_tools_nrUE.c
@@ -46,7 +46,8 @@
#include "NR_MAC_COMMON/nr_mac_extern.h"
#include
-#define DEBUG_RAR
+// #define DEBUG_RAR
+// #define DEBUG_MSG3
// table 7.2-1 TS 38.321
uint16_t table_7_2_1[16] = {
@@ -66,6 +67,135 @@ uint16_t table_7_2_1[16] = {
1920, // row index 13
};
+void nr_config_Msg3_pdu(NR_UE_MAC_INST_t *mac,
+ int Msg3_f_alloc,
+ uint8_t Msg3_t_alloc,
+ uint8_t mcs,
+ uint8_t freq_hopping){
+
+ int f_alloc, mask, StartSymbolIndex, NrOfSymbols;
+ uint8_t nb_dmrs_re_per_rb;
+ uint16_t number_dmrs_symbols = 0;
+ int N_PRB_oh;
+ fapi_nr_ul_config_request_t *ul_config = &mac->ul_config_request;
+ nfapi_nr_ue_pusch_pdu_t *pusch_config_pdu = &ul_config->ul_config_list[ul_config->number_pdus].pusch_config_pdu;
+ NR_ServingCellConfigCommon_t *scc = mac->scc;
+ NR_BWP_Uplink_t *ubwp = mac->ULbwp[0];
+ NR_BWP_UplinkDedicated_t *ibwp = mac->scg->spCellConfig->spCellConfigDedicated->uplinkConfig->initialUplinkBWP;
+ NR_PUSCH_Config_t *pusch_Config = ibwp->pusch_Config->choice.setup;
+ int startSymbolAndLength = ubwp->bwp_Common->pusch_ConfigCommon->choice.setup->pusch_TimeDomainAllocationList->list.array[Msg3_t_alloc]->startSymbolAndLength;
+
+ #ifdef DEBUG_MSG3
+ printf("[DEBUG_MSG3] Configuring 1 Msg3 PDU of %d UL pdus \n", ul_config->number_pdus);
+ #endif
+
+ // Num PRB Overhead from PUSCH-ServingCellConfig
+ if (mac->scg->spCellConfig->spCellConfigDedicated->uplinkConfig->pusch_ServingCellConfig->choice.setup->xOverhead == NULL)
+ N_PRB_oh = 0;
+ else
+ N_PRB_oh = *mac->scg->spCellConfig->spCellConfigDedicated->uplinkConfig->pusch_ServingCellConfig->choice.setup->xOverhead;
+
+ // active BWP start
+ int abwp_start = NRRIV2PRBOFFSET(ubwp->bwp_Common->genericParameters.locationAndBandwidth, 275);
+ int abwp_size = NRRIV2BW(ubwp->bwp_Common->genericParameters.locationAndBandwidth, 275);
+
+ // initial BWP start
+ int ibwp_start = NRRIV2PRBOFFSET(scc->uplinkConfigCommon->initialUplinkBWP->genericParameters.locationAndBandwidth, 275);
+ int ibwp_size = NRRIV2BW(scc->uplinkConfigCommon->initialUplinkBWP->genericParameters.locationAndBandwidth, 275);
+
+ // BWP start selection according to 8.3 of TS 38.213
+ pusch_config_pdu->bwp_size = ibwp_size;
+ if ((ibwp_start < abwp_start) || (ibwp_size > abwp_size))
+ pusch_config_pdu->bwp_start = abwp_start;
+ else
+ pusch_config_pdu->bwp_start = ibwp_start;
+
+ //// Resource assignment from RAR
+ // Frequency domain allocation according to 8.3 of TS 38.213
+ if (ibwp_size < 180)
+ mask = (1 << ((int) ceil(log2((ibwp_size*(ibwp_size+1))>>1)))) - 1;
+ else
+ mask = (1 << (28 - (int)(ceil(log2((ibwp_size*(ibwp_size+1))>>1))))) - 1;
+ f_alloc = Msg3_f_alloc & mask;
+ nr_ue_process_dci_freq_dom_resource_assignment(pusch_config_pdu, NULL, ibwp_size, 0, f_alloc);
+
+ // virtual resource block to physical resource mapping for Msg3 PUSCH (6.3.1.7 in 38.211)
+ pusch_config_pdu->rb_start += ibwp_start - abwp_start;
+
+ // Time domain allocation
+ SLIV2SL(startSymbolAndLength, &StartSymbolIndex, &NrOfSymbols);
+ pusch_config_pdu->ul_dmrs_symb_pos = 1<start_symbol_index = StartSymbolIndex;
+ pusch_config_pdu->nr_of_symbols = NrOfSymbols;
+
+ #ifdef DEBUG_MSG3
+ printf("[DEBUG_MSG3] Freq assignment (RB start %d size %d) BWP (start %d, size %d), Time assignment (sliv_S %d sliv_L %d) \n",
+ pusch_config_pdu->rb_start,
+ pusch_config_pdu->rb_size,
+ pusch_config_pdu->bwp_start,
+ pusch_config_pdu->bwp_size,
+ StartSymbolIndex,
+ NrOfSymbols);
+ #endif
+
+ // MCS
+ pusch_config_pdu->mcs_index = mcs;
+ // Frequency hopping
+ pusch_config_pdu->frequency_hopping = freq_hopping;
+ // TC-RNTI
+ pusch_config_pdu->rnti = mac->t_crnti;
+
+ // DM-RS configuration according to 6.2.2 UE DM-RS transmission procedure in 38.214
+ pusch_config_pdu->dmrs_config_type = pusch_dmrs_type1;
+ pusch_config_pdu->num_dmrs_cdm_grps_no_data = 2;
+ pusch_config_pdu->dmrs_ports = 1;
+ get_num_re_dmrs(pusch_config_pdu,
+ &nb_dmrs_re_per_rb,
+ &number_dmrs_symbols);
+
+ // DMRS sequence initialization [TS 38.211, sec 6.4.1.1.1].
+ // Should match what is sent in DCI 0_1, otherwise set to 0.
+ pusch_config_pdu->scid = 0;
+
+ // Transform precoding according to 6.1.3 UE procedure for applying transform precoding on PUSCH in 38.214
+ if (scc->uplinkConfigCommon->initialUplinkBWP->rach_ConfigCommon->choice.setup->msg3_transformPrecoder == NULL)
+ pusch_config_pdu->transform_precoding = 1;
+ else
+ pusch_config_pdu->transform_precoding = 0;
+
+ // Resource allocation in frequency domain according to 6.1.2.2 in TS 38.214
+ pusch_config_pdu->resource_alloc = pusch_Config->resourceAllocation;
+
+ //// Completing PUSCH PDU
+ pusch_config_pdu->pdu_bit_map = PUSCH_PDU_BITMAP_PUSCH_DATA;
+ pusch_config_pdu->mcs_table = 0;
+ pusch_config_pdu->nrOfLayers = 1;
+ pusch_config_pdu->cyclic_prefix = 0;
+ pusch_config_pdu->target_code_rate = nr_get_code_rate_ul(pusch_config_pdu->mcs_index, pusch_config_pdu->mcs_table);
+ pusch_config_pdu->qam_mod_order = nr_get_Qm_ul(pusch_config_pdu->mcs_index, pusch_config_pdu->mcs_table);
+ pusch_config_pdu->data_scrambling_id = *scc->physCellId;
+ pusch_config_pdu->ul_dmrs_scrambling_id = *scc->physCellId;
+ pusch_config_pdu->subcarrier_spacing = ubwp->bwp_Common->genericParameters.subcarrierSpacing;
+ pusch_config_pdu->vrb_to_prb_mapping = 0;
+ pusch_config_pdu->uplink_frequency_shift_7p5khz = 0;
+ //Optional Data only included if indicated in pduBitmap
+ pusch_config_pdu->pusch_data.rv_index = 0; // 8.3 in 38.213
+ pusch_config_pdu->pusch_data.harq_process_id = 0;
+ pusch_config_pdu->pusch_data.new_data_indicator = 1; // new data
+ pusch_config_pdu->pusch_data.num_cb = 0;
+
+ // Compute TBS
+ pusch_config_pdu->pusch_data.tb_size = nr_compute_tbs(pusch_config_pdu->qam_mod_order,
+ pusch_config_pdu->target_code_rate,
+ pusch_config_pdu->rb_size,
+ pusch_config_pdu->nr_of_symbols,
+ nb_dmrs_re_per_rb*number_dmrs_symbols,
+ N_PRB_oh,
+ 0, // TBR to verify tb scaling
+ pusch_config_pdu->nrOfLayers)/8;
+
+}
+
/////////////////////////////////////
// Random Access Response PDU //
// TS 38.213 ch 8.2 //
@@ -90,12 +220,13 @@ uint16_t table_7_2_1[16] = {
//| F_alloc |Time allocation|//
//| MCS | TPC |CSI|//
/////////////////////////////////////
-// WIP todo:
+// TbD WIP Msg3 development ongoing
// - apply UL grant freq alloc & time alloc as per 8.2 TS 38.213
-// - apply tpc command, csi req, mcs
+// - apply tpc command
uint16_t nr_ue_process_rar(module_id_t mod_id,
int CC_id,
- frame_t frameP,
+ frame_t frame,
+ sub_frame_t slot,
uint8_t * dlsch_buffer,
rnti_t * t_crnti,
uint8_t preamble_index,
@@ -106,11 +237,7 @@ uint16_t nr_ue_process_rar(module_id_t mod_id,
NR_MAC_RAR *rar = (NR_MAC_RAR *) (dlsch_buffer + 1); // RAR subPDU pointer
uint8_t n_subPDUs = 0; // number of RAR payloads
uint8_t n_subheaders = 0; // number of MAC RAR subheaders
- //uint8_t best_rx_rapid = -1; // the closest RAPID receive from all RARs
- //unsigned char freq_hopping, msg3_t_alloc, mcs, tpc_command, csi_req; // WIP
- //uint16_t ta_command = 0, msg3_f_alloc, bwp_size; // WIP
uint16_t ta_command = 0;
- //int f_alloc, mask; // WIP
AssertFatal(CC_id == 0, "RAR reception on secondary CCs is not supported yet\n");
@@ -126,7 +253,7 @@ uint16_t nr_ue_process_rar(module_id_t mod_id,
LOG_D(MAC, "[UE %d][RAPROC] Got BI RAR subPDU %d\n", mod_id, ue_mac->RA_backoff_indicator);
}
if (rarh->RAPID == preamble_index) {
- LOG_D(PHY, "[UE %d][RAPROC] Found RAR with the intended RAPID %d\n", mod_id, rarh->RAPID);
+ LOG_I(PHY, "[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));
ue_mac->RA_RAPID_found = 1;
break;
@@ -139,17 +266,19 @@ uint16_t nr_ue_process_rar(module_id_t mod_id,
}
};
- LOG_D(MAC, "number of RAR subheader %d; number of RAR pyloads %d\n", n_subheaders, n_subPDUs);
+ #ifdef DEBUG_RAR
+ LOG_D(MAC, "[DEBUG_RAR] (%d,%d) number of RAR subheader %d; number of RAR pyloads %d\n", frame, slot, n_subheaders, n_subPDUs);
+ LOG_D(MAC, "[DEBUG_RAR] Received RAR (%02x|%02x.%02x.%02x.%02x.%02x.%02x) for preamble %d/%d\n", *(uint8_t *) rarh, rar[0], rar[1], rar[2], rar[3], rar[4], rar[5], rarh->RAPID, preamble_index);
+ #endif
- // LOG_I(MAC, "[UE %d][RAPROC] Frame %d Received RAR (%02x|%02x.%02x.%02x.%02x.%02x.%02x) for preamble %d/%d\n",
- // mod_id, frameP, *(uint8_t *) rarh, rar[0], rar[1], rar[2], rar[3], rar[4], rar[5], rarh->RAPID, preamble_index);
-
- #if 0 // TbD WIP Msg3 development ongoing
if (ue_mac->RA_RAPID_found) {
+
+ uint8_t freq_hopping, mcs, Msg3_t_alloc, Msg3_f_alloc;
+ unsigned char tpc_command, csi_req;
+
// TC-RNTI
*t_crnti = rar->TCRNTI_2 + (rar->TCRNTI_1 << 8);
ue_mac->t_crnti = *t_crnti;
- ue_mac->rnti_type = NR_RNTI_TC;
// TA command
ta_command = rar->TA2 + (rar->TA1 << 5);
// CSI
@@ -182,27 +311,36 @@ uint16_t nr_ue_process_rar(module_id_t mod_id,
ue_mac->Msg3_TPC = 8;
break;
}
- //MCS
+ // MCS
mcs = (unsigned char) (rar->UL_GRANT_4 >> 4);
- // time and frequency alloc
- bwp_size = NRRIV2BW(ue_mac->ULbwp[0]->bwp_Common->genericParameters.locationAndBandwidth,275);
- msg3_t_alloc = (unsigned char) (rar->UL_GRANT_3 & 0x07);
- msg3_f_alloc = (uint16_t) ((rar->UL_GRANT_3 >> 4) | (rar->UL_GRANT_2 << 4) | ((rar->UL_GRANT_1 & 0x03) << 12));
-
- if (bwp_size < 180)
- mask = (1 << ((int) ceil(log2((bwp_size*(bwp_size+1))>>1)))) - 1;
- else
- mask = (1 << (28 - (int)(ceil(log2((bwp_size*(bwp_size+1))>>1))))) - 1;
-
- f_alloc = msg3_f_alloc & mask;
-
- // frequency hopping flag
+ // time alloc
+ Msg3_t_alloc = (unsigned char) (rar->UL_GRANT_3 & 0x07);
+ // frequency alloc
+ Msg3_f_alloc = (uint16_t) ((rar->UL_GRANT_3 >> 4) | (rar->UL_GRANT_2 << 4) | ((rar->UL_GRANT_1 & 0x03) << 12));
+ // frequency hopping
freq_hopping = (unsigned char) (rar->UL_GRANT_1 >> 2);
+
+ #ifdef DEBUG_RAR
+ LOG_D(MAC, "[DEBUG_RAR] Received RAR with t_alloc %d f_alloc %d ta_command %d mcs %d freq_hopping %d tpc_command %d csi_req %d t_crnti %x \n",
+ Msg3_t_alloc,
+ Msg3_f_alloc,
+ ta_command,
+ mcs,
+ freq_hopping,
+ tpc_command,
+ csi_req,
+ ue_mac->t_crnti);
+ #endif
+
+ // Config Msg3 PDU
+ nr_config_Msg3_pdu(ue_mac, Msg3_f_alloc, Msg3_t_alloc, mcs, freq_hopping);
+ // Schedule Msg3
+ nr_ue_msg3_scheduler(ue_mac, frame, slot, Msg3_t_alloc);
+
} else {
ue_mac->t_crnti = 0;
ta_command = (0xffff);
}
- #endif
// move the selected RAR to the front of the RA_PDSCH buffer
memcpy((void *) (selected_rar_buffer + 0), (void *) rarh, 1);
diff --git a/openair2/LAYER2/NR_MAC_gNB/config.c b/openair2/LAYER2/NR_MAC_gNB/config.c
index 4e46603dc9..ad8409de69 100644
--- a/openair2/LAYER2/NR_MAC_gNB/config.c
+++ b/openair2/LAYER2/NR_MAC_gNB/config.c
@@ -46,6 +46,9 @@
#include "NR_MIB.h"
#include "LAYER2/NR_MAC_COMMON/nr_mac_common.h"
+/* Softmodem params */
+#include "executables/softmodem-common.h"
+
extern RAN_CONTEXT_t RC;
//extern int l2_init_gNB(void);
extern void mac_top_init_gNB(void);
@@ -346,22 +349,34 @@ int rrc_mac_config_req_gNB(module_id_t Mod_idP,
if (secondaryCellGroup) {
- NR_UE_list_t *UE_list = &RC.nrmac[Mod_idP]->UE_list;
- int UE_id;
- if (add_ue == 1) {
- UE_id = add_new_nr_ue(Mod_idP,rnti);
- UE_list->secondaryCellGroup[UE_id] = secondaryCellGroup;
- uint8_t num_preamble = secondaryCellGroup->spCellConfig->reconfigurationWithSync->rach_ConfigDedicated->choice.uplink->cfra->resources.choice.ssb->ssb_ResourceList.list.count;
- UE_list->preambles[UE_id].num_preambles = num_preamble;
- UE_list->preambles[UE_id].preamble_list = (uint8_t *) malloc(num_preamble*sizeof(uint8_t));
- for (int i=0; ipreambles[UE_id].preamble_list[i] = secondaryCellGroup->spCellConfig->reconfigurationWithSync->rach_ConfigDedicated->choice.uplink->cfra->resources.choice.ssb->ssb_ResourceList.list.array[i]->ra_PreambleIndex;
- }
+ NR_UE_info_t *UE_info = &RC.nrmac[Mod_idP]->UE_info;
+ if (add_ue == 1 && get_softmodem_params()->phy_test) {
+ const int UE_id = add_new_nr_ue(Mod_idP,rnti);
+ UE_info->secondaryCellGroup[UE_id] = secondaryCellGroup;
+ struct NR_ServingCellConfig__downlinkBWP_ToAddModList *bwpList =
+ secondaryCellGroup->spCellConfig->spCellConfigDedicated->downlinkBWP_ToAddModList;
+ AssertFatal(bwpList->list.count == 1,
+ "downlinkBWP_ToAddModList has %d BWP!\n",
+ bwpList->list.count);
+ const int bwp_id = 1;
+ UE_info->UE_sched_ctrl[UE_id].active_bwp = bwpList->list.array[bwp_id - 1];
LOG_I(PHY,"Added new UE_id %d/%x with initial secondaryCellGroup\n",UE_id,rnti);
- }
- else { // secondaryCellGroup has been updated
- UE_id = find_nr_UE_id(Mod_idP,rnti);
- UE_list->secondaryCellGroup[UE_id] = secondaryCellGroup;
+ } else if (add_ue == 1 && !get_softmodem_params()->phy_test) {
+ /* TODO: should check for free RA process */
+ const int CC_id = 0;
+ NR_RA_t *ra = &RC.nrmac[Mod_idP]->common_channels[CC_id].ra[0];
+ ra->state = RA_IDLE;
+ ra->secondaryCellGroup = secondaryCellGroup;
+ ra->crnti = rnti;
+ uint8_t num_preamble = secondaryCellGroup->spCellConfig->reconfigurationWithSync->rach_ConfigDedicated->choice.uplink->cfra->resources.choice.ssb->ssb_ResourceList.list.count;
+ ra->preambles.num_preambles = num_preamble;
+ ra->preambles.preamble_list = (uint8_t *) malloc(num_preamble*sizeof(uint8_t));
+ for (int i = 0; i < num_preamble; i++)
+ ra->preambles.preamble_list[i] = secondaryCellGroup->spCellConfig->reconfigurationWithSync->rach_ConfigDedicated->choice.uplink->cfra->resources.choice.ssb->ssb_ResourceList.list.array[i]->ra_PreambleIndex;
+ LOG_I(PHY,"Added new RA process for UE RNTI %04x with initial secondaryCellGroup\n", rnti);
+ } else { // secondaryCellGroup has been updated
+ const int UE_id = find_nr_UE_id(Mod_idP,rnti);
+ UE_info->secondaryCellGroup[UE_id] = secondaryCellGroup;
LOG_I(PHY,"Modified UE_id %d/%x with secondaryCellGroup\n",UE_id,rnti);
}
}
diff --git a/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler.c b/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler.c
index 3e833db485..58de000ac5 100644
--- a/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler.c
+++ b/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler.c
@@ -63,19 +63,19 @@ const uint8_t slots_per_frame[5] = {10, 20, 40, 80, 160};
uint16_t nr_pdcch_order_table[6] = { 31, 31, 511, 2047, 2047, 8191 };
void clear_mac_stats(gNB_MAC_INST *gNB) {
- memset((void*)gNB->UE_list.mac_stats,0,MAX_MOBILES_PER_GNB*sizeof(NR_mac_stats_t));
+ memset((void*)gNB->UE_info.mac_stats,0,MAX_MOBILES_PER_GNB*sizeof(NR_mac_stats_t));
}
void dump_mac_stats(gNB_MAC_INST *gNB) {
- NR_UE_list_t *UE_list = &gNB->UE_list;
+ NR_UE_info_t *UE_info = &gNB->UE_info;
NR_mac_stats_t *stats;
int lc_id;
for (int UE_id=0;UE_idactive[UE_id] == TRUE) {
- LOG_I(MAC,"UE %x\n",UE_list->rnti[UE_id]);
- stats = &UE_list->mac_stats[UE_id];
+ if (UE_info->active[UE_id]) {
+ LOG_I(MAC, "UE %x\n", UE_info->rnti[UE_id]);
+ stats = &UE_info->mac_stats[UE_id];
LOG_I(MAC,"dlsch_rounds %d/%d/%d/%d, dlsch_errors %d\n",stats->dlsch_rounds[0],stats->dlsch_rounds[1],stats->dlsch_rounds[2],stats->dlsch_rounds[3],stats->dlsch_errors);
LOG_I(MAC,"dlsch_total_bytes %d\n",stats->dlsch_total_bytes);
LOG_I(MAC,"ulsch_rounds %d/%d/%d/%d, ulsch_errors %d\n",stats->ulsch_rounds[0],stats->ulsch_rounds[1],stats->ulsch_rounds[2],stats->ulsch_rounds[3],stats->ulsch_errors);
@@ -130,18 +130,18 @@ void check_nr_ul_failure(module_id_t module_idP,
frame_t frameP,
sub_frame_t slotP) {
- UE_list_t *UE_list = &RC.nrmac[module_idP]->UE_list;
+ NR_UE_info_t *UE_info = &RC.nrmac[module_idP]->UE_info;
nfapi_nr_dl_dci_request_t *DL_req = &RC.nrmac[module_idP]->DL_req[0];
uint16_t rnti = UE_RNTI(module_idP, UE_id);
NR_COMMON_channels_t *cc = RC.nrmac[module_idP]->common_channels;
// check uplink failure
- if ((UE_list->UE_sched_ctrl[UE_id].ul_failure_timer > 0) &&
- (UE_list->UE_sched_ctrl[UE_id].ul_out_of_sync == 0)) {
+ if ((UE_info->UE_sched_ctrl[UE_id].ul_failure_timer > 0) &&
+ (UE_info->UE_sched_ctrl[UE_id].ul_out_of_sync == 0)) {
LOG_I(MAC, "UE %d rnti %x: UL Failure timer %d \n", UE_id, rnti,
- UE_list->UE_sched_ctrl[UE_id].ul_failure_timer);
- if (UE_list->UE_sched_ctrl[UE_id].ra_pdcch_order_sent == 0) {
- UE_list->UE_sched_ctrl[UE_id].ra_pdcch_order_sent = 1;
+ UE_info->UE_sched_ctrl[UE_id].ul_failure_timer);
+ if (UE_info->UE_sched_ctrl[UE_id].ra_pdcch_order_sent == 0) {
+ UE_info->UE_sched_ctrl[UE_id].ra_pdcch_order_sent = 1;
// add a format 1A dci for this UE to request an RA procedure (only one UE per subframe)
nfapi_nr_dl_dci_request_pdu_t *dl_config_pdu = &DL_req[CC_id].dl_tti_request_body.dl_config_pdu_list[DL_req[CC_id].dl_tti_request_body.number_pdu];
@@ -151,7 +151,7 @@ void check_nr_ul_failure(module_id_t module_idP,
dl_config_pdu->dci_dl_pdu.dci_dl_pdu_rel8.tl.tag = NFAPI_DL_DCI_REQUEST_DCI_DL_PDU_REL8_TAG;
dl_config_pdu->dci_dl_pdu.dci_dl_pdu_rel8.dci_format = NFAPI_DL_DCI_FORMAT_1A;
dl_config_pdu->dci_dl_pdu.dci_dl_pdu_rel8.aggregation_level = get_aggregation(get_bw_index(module_idP, CC_id),
- UE_list->UE_sched_ctrl[UE_id].
+ UE_info->UE_sched_ctrl[UE_id].
dl_cqi[CC_id], format1A);
dl_config_pdu->dci_dl_pdu.dci_dl_pdu_rel8.rnti = rnti;
dl_config_pdu->dci_dl_pdu.dci_dl_pdu_rel8.rnti_type = 1; // CRNTI : see Table 4-10 from SCF082 - nFAPI specifications
@@ -167,27 +167,27 @@ void check_nr_ul_failure(module_id_t module_idP,
LOG_I(MAC,
"UE %d rnti %x: sending PDCCH order for RAPROC (failure timer %d), resource_block_coding %d \n",
UE_id, rnti,
- UE_list->UE_sched_ctrl[UE_id].ul_failure_timer,
+ UE_info->UE_sched_ctrl[UE_id].ul_failure_timer,
dl_config_pdu->dci_dl_pdu.
dci_dl_pdu_rel8.resource_block_coding);
} else { // ra_pdcch_sent==1
LOG_I(MAC,
"UE %d rnti %x: sent PDCCH order for RAPROC waiting (failure timer %d) \n",
UE_id, rnti,
- UE_list->UE_sched_ctrl[UE_id].ul_failure_timer);
- if ((UE_list->UE_sched_ctrl[UE_id].ul_failure_timer % 40) == 0) UE_list->UE_sched_ctrl[UE_id].ra_pdcch_order_sent = 0; // resend every 4 frames
+ UE_info->UE_sched_ctrl[UE_id].ul_failure_timer);
+ if ((UE_info->UE_sched_ctrl[UE_id].ul_failure_timer % 40) == 0) UE_info->UE_sched_ctrl[UE_id].ra_pdcch_order_sent = 0; // resend every 4 frames
}
- UE_list->UE_sched_ctrl[UE_id].ul_failure_timer++;
+ UE_info->UE_sched_ctrl[UE_id].ul_failure_timer++;
// check threshold
- if (UE_list->UE_sched_ctrl[UE_id].ul_failure_timer > 20000) {
+ if (UE_info->UE_sched_ctrl[UE_id].ul_failure_timer > 20000) {
// inform RRC of failure and clear timer
LOG_I(MAC,
"UE %d rnti %x: UL Failure after repeated PDCCH orders: Triggering RRC \n",
UE_id, rnti);
mac_eNB_rrc_ul_failure(module_idP, CC_id, frameP, subframeP,rnti);
- UE_list->UE_sched_ctrl[UE_id].ul_failure_timer = 0;
- UE_list->UE_sched_ctrl[UE_id].ul_out_of_sync = 1;
+ UE_info->UE_sched_ctrl[UE_id].ul_failure_timer = 0;
+ UE_info->UE_sched_ctrl[UE_id].ul_out_of_sync = 1;
//Inform the controller about the UE deactivation. Should be moved to RRC agent in the future
if (rrc_agent_registered[module_idP]) {
@@ -204,7 +204,7 @@ void check_nr_ul_failure(module_id_t module_idP,
void schedule_nr_SRS(module_id_t module_idP, frame_t frameP, sub_frame_t subframeP)
{
gNB_MAC_INST *gNB = RC.nrmac[module_idP];
- UE_list_t *UE_list = &gNB->UE_list;
+ NR_UE_info_t *UE_info = &gNB->UE_info;
nfapi_ul_config_request_body_t *ul_req;
int CC_id, UE_id;
NR_COMMON_channels_t *cc = RC.nrmac[module_idP]->common_channels;
@@ -238,16 +238,16 @@ void schedule_nr_SRS(module_id_t module_idP, frame_t frameP, sub_frame_t subfram
if ((1 << tmp) & deltaTSFC) {
// This is an SRS subframe, loop over UEs
for (UE_id = 0; UE_id < MAX_MOBILES_PER_GNB; UE_id++) {
- if (!RC.nrmac[module_idP]->UE_list.active[UE_id]) continue;
+ if (!RC.nrmac[module_idP]->UE_info.active[UE_id]) continue;
ul_req = &RC.nrmac[module_idP]->UL_req[CC_id].ul_config_request_body;
// drop the allocation if the UE hasn't send RRCConnectionSetupComplete yet
if (mac_eNB_get_rrc_status(module_idP,UE_RNTI(module_idP, UE_id)) < RRC_CONNECTED) continue;
- AssertFatal(UE_list->UE_template[CC_id][UE_id].physicalConfigDedicated != NULL,
+ AssertFatal(UE_info->UE_template[CC_id][UE_id].physicalConfigDedicated != NULL,
"physicalConfigDedicated is null for UE %d\n",
UE_id);
- if ((soundingRS_UL_ConfigDedicated = UE_list->UE_template[CC_id][UE_id].physicalConfigDedicated->soundingRS_UL_ConfigDedicated) != NULL) {
+ if ((soundingRS_UL_ConfigDedicated = UE_info->UE_template[CC_id][UE_id].physicalConfigDedicated->soundingRS_UL_ConfigDedicated) != NULL) {
if (soundingRS_UL_ConfigDedicated->present == SoundingRS_UL_ConfigDedicated_PR_setup) {
get_srs_pos(&cc[CC_id],
soundingRS_UL_ConfigDedicated->choice.
@@ -262,7 +262,7 @@ void schedule_nr_SRS(module_id_t module_idP, frame_t frameP, sub_frame_t subfram
ul_config_pdu->pdu_size = 2 + (uint8_t) (2 + sizeof(nfapi_ul_config_srs_pdu));
ul_config_pdu->srs_pdu.srs_pdu_rel8.tl.tag = NFAPI_UL_CONFIG_REQUEST_SRS_PDU_REL8_TAG;
ul_config_pdu->srs_pdu.srs_pdu_rel8.size = (uint8_t)sizeof(nfapi_ul_config_srs_pdu);
- ul_config_pdu->srs_pdu.srs_pdu_rel8.rnti = UE_list->UE_template[CC_id][UE_id].rnti;
+ ul_config_pdu->srs_pdu.srs_pdu_rel8.rnti = UE_info->UE_template[CC_id][UE_id].rnti;
ul_config_pdu->srs_pdu.srs_pdu_rel8.srs_bandwidth = soundingRS_UL_ConfigDedicated->choice.setup.srs_Bandwidth;
ul_config_pdu->srs_pdu.srs_pdu_rel8.frequency_domain_position = soundingRS_UL_ConfigDedicated->choice.setup.freqDomainPosition;
ul_config_pdu->srs_pdu.srs_pdu_rel8.srs_hopping_bandwidth = soundingRS_UL_ConfigDedicated->choice.setup.srs_HoppingBandwidth;;
@@ -275,7 +275,7 @@ void schedule_nr_SRS(module_id_t module_idP, frame_t frameP, sub_frame_t subfram
ul_req->number_of_pdus++;
} // if (((10*frameP+subframeP) % srsPeriodicity) == srsOffset)
} // if (soundingRS_UL_ConfigDedicated->present == SoundingRS_UL_ConfigDedicated_PR_setup)
- } // if ((soundingRS_UL_ConfigDedicated = UE_list->UE_template[CC_id][UE_id].physicalConfigDedicated->soundingRS_UL_ConfigDedicated)!=NULL)
+ } // if ((soundingRS_UL_ConfigDedicated = UE_info->UE_template[CC_id][UE_id].physicalConfigDedicated->soundingRS_UL_ConfigDedicated)!=NULL)
} // for (UE_id ...
} // if((1<UL_tti_req[0];
- NR_UE_list_t *UE_list = &RC.nrmac[Mod_idP]->UE_list;
+ NR_UE_info_t *UE_info = &RC.nrmac[Mod_idP]->UE_info;
int k = slotP + ul_slots - num_slots_per_tdd;
- NR_sched_pusch *pusch = &UE_list->UE_sched_ctrl[UE_id].sched_pusch[k];
+ NR_sched_pusch *pusch = &UE_info->UE_sched_ctrl[UE_id].sched_pusch[k];
if ((pusch->active == true) && (frameP == pusch->frame) && (slotP == pusch->slot)) {
UL_tti_req->SFN = pusch->frame;
UL_tti_req->Slot = pusch->slot;
@@ -332,7 +332,7 @@ void nr_schedule_pusch(int Mod_idP,
UL_tti_req->pdus_list[UL_tti_req->n_pdus].pdu_size = sizeof(nfapi_nr_pusch_pdu_t);
UL_tti_req->pdus_list[UL_tti_req->n_pdus].pusch_pdu = pusch->pusch_pdu;
UL_tti_req->n_pdus+=1;
- memset((void *) &UE_list->UE_sched_ctrl[UE_id].sched_pusch[k],
+ memset((void *) &UE_info->UE_sched_ctrl[UE_id].sched_pusch[k],
0, sizeof(NR_sched_pusch));
}
}
@@ -348,10 +348,10 @@ void nr_schedule_pucch(int Mod_idP,
uint16_t O_ack;
uint8_t SR_flag = 0; // no SR in PUCCH implemented for now
NR_ServingCellConfigCommon_t *scc = RC.nrmac[Mod_idP]->common_channels->ServingCellConfigCommon;
- NR_UE_list_t *UE_list = &RC.nrmac[Mod_idP]->UE_list;
- AssertFatal(UE_list->active[UE_id] >=0,"Cannot find UE_id %d is not active\n",UE_id);
+ NR_UE_info_t *UE_info = &RC.nrmac[Mod_idP]->UE_info;
+ AssertFatal(UE_info->active[UE_id],"Cannot find UE_id %d is not active\n",UE_id);
- NR_CellGroupConfig_t *secondaryCellGroup = UE_list->secondaryCellGroup[UE_id];
+ NR_CellGroupConfig_t *secondaryCellGroup = UE_info->secondaryCellGroup[UE_id];
int bwp_id=1;
NR_BWP_Uplink_t *ubwp=secondaryCellGroup->spCellConfig->spCellConfigDedicated->uplinkConfig->uplinkBWP_ToAddModList->list.array[bwp_id-1];
nfapi_nr_ul_tti_request_t *UL_tti_req = &RC.nrmac[Mod_idP]->UL_tti_req[0];
@@ -359,7 +359,7 @@ void nr_schedule_pucch(int Mod_idP,
NR_sched_pucch *curr_pucch;
for (int k=0; kUE_sched_ctrl[UE_id].sched_pucch[k];
+ curr_pucch = &UE_info->UE_sched_ctrl[UE_id].sched_pucch[k];
if ((curr_pucch->dai_c > 0) && (frameP == curr_pucch->frame) && (slotP == curr_pucch->ul_slot)) {
UL_tti_req->SFN = curr_pucch->frame;
UL_tti_req->Slot = curr_pucch->ul_slot;
@@ -381,59 +381,46 @@ void nr_schedule_pucch(int Mod_idP,
O_ack,
SR_flag);
- memset((void *) &UE_list->UE_sched_ctrl[UE_id].sched_pucch[k],
+ memset((void *) &UE_info->UE_sched_ctrl[UE_id].sched_pucch[k],
0,
sizeof(NR_sched_pucch));
}
}
}
-
-
-bool is_xlsch_in_slot(uint64_t bitmap, sub_frame_t slot){
-
- if((bitmap>>slot)&0x01)
- return true;
- else
- return false;
+bool is_xlsch_in_slot(uint64_t bitmap, sub_frame_t slot) {
+ return (bitmap >> slot) & 0x01;
}
void gNB_dlsch_ulsch_scheduler(module_id_t module_idP,
frame_t frame,
sub_frame_t slot){
-
-
protocol_ctxt_t ctxt;
PROTOCOL_CTXT_SET_BY_MODULE_ID(&ctxt, module_idP, ENB_FLAG_YES, NOT_A_RNTI, frame, slot,module_idP);
- int CC_id;
- int UE_id;
- uint64_t *dlsch_in_slot_bitmap=NULL;
- uint64_t *ulsch_in_slot_bitmap=NULL;
- int pucch_sched;
-
- UE_id=0;
- int bwp_id = 1;
+ const int UE_id = 0;
+ const int bwp_id = 1;
gNB_MAC_INST *gNB = RC.nrmac[module_idP];
- NR_UE_list_t *UE_list = &gNB->UE_list;
- NR_UE_sched_ctrl_t *ue_sched_ctl = &UE_list->UE_sched_ctrl[UE_id];
+ NR_UE_info_t *UE_info = &gNB->UE_info;
+ NR_UE_sched_ctrl_t *ue_sched_ctl = &UE_info->UE_sched_ctrl[UE_id];
NR_COMMON_channels_t *cc = gNB->common_channels;
NR_ServingCellConfigCommon_t *scc = cc->ServingCellConfigCommon;
- int num_slots_per_tdd = (slots_per_frame[*scc->ssbSubcarrierSpacing])>>(7-scc->tdd_UL_DL_ConfigurationCommon->pattern1.dl_UL_TransmissionPeriodicity);
- int nr_ulmix_slots = scc->tdd_UL_DL_ConfigurationCommon->pattern1.nrofUplinkSlots;
- if (scc->tdd_UL_DL_ConfigurationCommon->pattern1.nrofUplinkSymbols!=0)
- nr_ulmix_slots++;
+ NR_TDD_UL_DL_Pattern_t *tdd_pattern = &scc->tdd_UL_DL_ConfigurationCommon->pattern1;
+ const int num_slots_per_tdd = slots_per_frame[*scc->ssbSubcarrierSpacing] >> (7 - tdd_pattern->dl_UL_TransmissionPeriodicity);
+ const int nr_ulmix_slots = tdd_pattern->nrofUplinkSlots + (tdd_pattern->nrofUplinkSymbols!=0);
- if (slot== 0 && (UE_list->fiveG_connected[UE_id] || get_softmodem_params()->phy_test)) {
+ if (slot == 0 && UE_info->active[UE_id]) {
for (int k=0; kUE_sched_ctrl[UE_id].sched_pucch[k],
+ /* Seems to be covered 384? */
+ /*memset((void *) &UE_info->UE_sched_ctrl[UE_id].sched_pucch[k],
0,
- sizeof(NR_sched_pucch));
- memset((void *) &UE_list->UE_sched_ctrl[UE_id].sched_pusch[k],
+ sizeof(NR_sched_pucch));*/
+ /* Seems to be covered in line 335? */
+ /*memset((void *) &UE_info->UE_sched_ctrl[UE_id].sched_pusch[k],
0,
- sizeof(NR_sched_pusch));
+ sizeof(NR_sched_pusch));*/
}
}
@@ -448,47 +435,21 @@ void gNB_dlsch_ulsch_scheduler(module_id_t module_idP,
nr_rrc_trigger(&ctxt, 0 /*CC_id*/, frame, slot >> *scc->ssbSubcarrierSpacing);
}
- dlsch_in_slot_bitmap = &RC.nrmac[module_idP]->UE_list.UE_sched_ctrl[UE_id].dlsch_in_slot_bitmap; // static bitmap signaling which slot in a tdd period contains dlsch
- ulsch_in_slot_bitmap = &RC.nrmac[module_idP]->UE_list.UE_sched_ctrl[UE_id].ulsch_in_slot_bitmap; // static bitmap signaling which slot in a tdd period contains ulsch
-
- // hardcoding dlsch to be in slot 1
- if (!(slot%num_slots_per_tdd)) {
- if(slot==0) {
- *dlsch_in_slot_bitmap = 0x02;
- *ulsch_in_slot_bitmap = 0x100;
- }
- else {
- *dlsch_in_slot_bitmap = 0x00;
- *ulsch_in_slot_bitmap = 0x00;
- }
- }
+ const uint64_t dlsch_in_slot_bitmap = (1 << 1);
+ const uint64_t ulsch_in_slot_bitmap = (1 << 8);
memset(RC.nrmac[module_idP]->cce_list[bwp_id][0],0,MAX_NUM_CCE*sizeof(int)); // coreset0
memset(RC.nrmac[module_idP]->cce_list[bwp_id][1],0,MAX_NUM_CCE*sizeof(int)); // coresetid 1
- for (CC_id = 0; CC_id < MAX_NUM_CCs; CC_id++) {
+ for (int CC_id = 0; CC_id < MAX_NUM_CCs; CC_id++) {
//mbsfn_status[CC_id] = 0;
// clear vrb_maps
- memset(cc[CC_id].vrb_map, 0, 100);
- memset(cc[CC_id].vrb_map_UL, 0, 100);
+ memset(cc[CC_id].vrb_map, 0, 275);
+ memset(cc[CC_id].vrb_map_UL, 0, 275);
clear_nr_nfapi_information(RC.nrmac[module_idP], CC_id, frame, slot);
}
- // refresh UE list based on UEs dropped by PHY in previous subframe
- /*
- for (i = 0; i < MAX_MOBILES_PER_GNB; i++) {
- if (UE_list->active[i]) {
-
- nfapi_nr_config_request_t *cfg = &RC.nrmac[module_idP]->config[CC_id];
-
- rnti = 0;//UE_RNTI(module_idP, i);
- CC_id = 0;//UE_PCCID(module_idP, i);
-
- } //END if (UE_list->active[i])
- } //END for (i = 0; i < MAX_MOBILES_PER_GNB; i++)
- */
-
if ((slot == 0) && (frame & 127) == 0) dump_mac_stats(RC.nrmac[module_idP]);
// This schedules MIB
@@ -511,10 +472,9 @@ void gNB_dlsch_ulsch_scheduler(module_id_t module_idP,
if (get_softmodem_params()->phy_test == 0) {
nr_schedule_RA(module_idP, frame, slot);
nr_schedule_reception_msg3(module_idP, 0, frame, slot);
- } else
- UE_list->fiveG_connected[UE_id] = true;
+ }
- if (UE_list->fiveG_connected[UE_id]) {
+ if (UE_info->active[UE_id]) {
// TbD once RACH is available, start ta_timer when UE is connected
if (ue_sched_ctl->ta_timer)
ue_sched_ctl->ta_timer--;
@@ -527,28 +487,29 @@ void gNB_dlsch_ulsch_scheduler(module_id_t module_idP,
}
// This schedules the DCI for Uplink and subsequently PUSCH
- if (UE_list->fiveG_connected[UE_id]) {
+ // The decision about whether to schedule is done for each UE independently
+ // inside
+ if (UE_info->active[UE_id] && slot < 10) {
int tda = 1; // time domain assignment hardcoded for now
- schedule_fapi_ul_pdu(module_idP, frame, slot, num_slots_per_tdd, nr_ulmix_slots, tda);
+ schedule_fapi_ul_pdu(module_idP, frame, slot, num_slots_per_tdd, nr_ulmix_slots, tda, ulsch_in_slot_bitmap);
nr_schedule_pusch(module_idP, UE_id, num_slots_per_tdd, nr_ulmix_slots, frame, slot);
}
- if (UE_list->fiveG_connected[UE_id] && (is_xlsch_in_slot(*dlsch_in_slot_bitmap,slot%num_slots_per_tdd))) {
+ if (UE_info->active[UE_id]
+ && (is_xlsch_in_slot(dlsch_in_slot_bitmap, slot % num_slots_per_tdd))
+ && (!get_softmodem_params()->phy_test || slot == 1)
+ && slot < 10) {
ue_sched_ctl->current_harq_pid = slot % num_slots_per_tdd;
- nr_update_pucch_scheduling(module_idP, UE_id, frame, slot, num_slots_per_tdd,&pucch_sched);
- nr_schedule_uss_dlsch_phytest(module_idP, frame, slot, &UE_list->UE_sched_ctrl[UE_id].sched_pucch[pucch_sched], NULL);
+ //int pucch_sched;
+ //nr_update_pucch_scheduling(module_idP, UE_id, frame, slot, num_slots_per_tdd,&pucch_sched);
+ //nr_schedule_uss_dlsch_phytest(module_idP, frame, slot, &UE_info->UE_sched_ctrl[UE_id].sched_pucch[pucch_sched], NULL);
+ nr_schedule_ue_spec(module_idP, frame, slot, num_slots_per_tdd);
ue_sched_ctl->ta_apply = false;
}
- if (UE_list->fiveG_connected[UE_id])
+ if (UE_info->active[UE_id])
nr_schedule_pucch(module_idP, UE_id, nr_ulmix_slots, frame, slot);
- /*
- // Allocate CCEs for good after scheduling is done
- for (CC_id = 0; CC_id < MAX_NUM_CCs; CC_id++)
- allocate_CCEs(module_idP, CC_id, subframeP, 0);
- */
-
stop_meas(&RC.nrmac[module_idP]->eNB_scheduler);
VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_gNB_DLSCH_ULSCH_SCHEDULER,VCD_FUNCTION_OUT);
diff --git a/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_RA.c b/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_RA.c
index 4c17ee3a0f..413727b9cb 100644
--- a/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_RA.c
+++ b/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_RA.c
@@ -247,14 +247,11 @@ void nr_initiate_ra_proc(module_id_t module_idP,
uint8_t ul_carrier_id = 0; // 0 for NUL 1 for SUL
NR_SearchSpace_t *ss;
- int UE_id = 0;
// ra_rnti from 5.1.3 in 38.321
uint16_t ra_rnti=1+symbol+(slotP*14)+(freq_index*14*80)+(ul_carrier_id*14*80*8);
uint16_t msg2_frame, msg2_slot,monitoring_slot_period,monitoring_offset;
gNB_MAC_INST *nr_mac = RC.nrmac[module_idP];
- NR_UE_list_t *UE_list = &nr_mac->UE_list;
- NR_CellGroupConfig_t *secondaryCellGroup = UE_list->secondaryCellGroup[UE_id];
NR_COMMON_channels_t *cc = &nr_mac->common_channels[CC_id];
NR_ServingCellConfigCommon_t *scc = cc->ServingCellConfigCommon;
NR_RA_t *ra = &cc->ra[0];
@@ -262,23 +259,21 @@ void nr_initiate_ra_proc(module_id_t module_idP,
// if the preamble received correspond to one of the listed
// the UE sent a RACH either for starting RA procedure or RA procedure failed and UE retries
int pr_found=0;
- for (int i=0;ipreambles[UE_id].num_preambles;i++) {
- if (preamble_index == UE_list->preambles[UE_id].preamble_list[i]) {
+ for (int i = 0; i < ra->preambles.num_preambles; i++) {
+ if (preamble_index == ra->preambles.preamble_list[i]) {
pr_found=1;
break;
}
}
- if (pr_found)
- UE_list->fiveG_connected[UE_id] = false;
- else {
- LOG_E(MAC, "[gNB %d][RAPROC] FAILURE: preamble %d does not correspond to any of the ones in rach_ConfigDedicated for UE_id %d\n",
- module_idP, preamble_index, UE_id);
+ if (!pr_found) {
+ LOG_E(MAC, "[gNB %d][RAPROC] FAILURE: preamble %d does not correspond to any of the ones in rach_ConfigDedicated\n",
+ module_idP, preamble_index);
return; // if the PRACH preamble does not correspond to any of the ones sent through RRC abort RA proc
}
// This should be handled differently when we use the initialBWP for RA
ra->bwp_id=1;
- NR_BWP_Downlink_t *bwp=secondaryCellGroup->spCellConfig->spCellConfigDedicated->downlinkBWP_ToAddModList->list.array[ra->bwp_id-1];
+ NR_BWP_Downlink_t *bwp=ra->secondaryCellGroup->spCellConfig->spCellConfigDedicated->downlinkBWP_ToAddModList->list.array[ra->bwp_id-1];
VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_INITIATE_RA_PROC, 1);
@@ -325,7 +320,6 @@ void nr_initiate_ra_proc(module_id_t module_idP,
ra->RA_rnti = ra_rnti;
ra->preamble_index = preamble_index;
- UE_list->tc_rnti[UE_id] = ra->rnti;
LOG_I(MAC,"[gNB %d][RAPROC] CC_id %d Frame %d Activating Msg2 generation in frame %d, slot %d using RA rnti %x\n",
module_idP,
@@ -423,7 +417,6 @@ void nr_schedule_reception_msg3(module_id_t module_idP, int CC_id, frame_t frame
ul_req->pdus_list[ul_req->n_pdus].pdu_size = sizeof(nfapi_nr_pusch_pdu_t);
ul_req->pdus_list[ul_req->n_pdus].pusch_pdu = ra->pusch_pdu;
ul_req->n_pdus+=1;
- ra->state = RA_IDLE;
}
}
}
@@ -434,8 +427,6 @@ void nr_add_msg3(module_id_t module_idP, int CC_id, frame_t frameP, sub_frame_t
NR_COMMON_channels_t *cc = &mac->common_channels[CC_id];
NR_ServingCellConfigCommon_t *scc = cc->ServingCellConfigCommon;
NR_RA_t *ra = &cc->ra[0];
- NR_UE_list_t *UE_list = &mac->UE_list;
- int UE_id = 0;
if (ra->state == RA_IDLE) {
LOG_W(MAC,"RA is not active for RA %X. skipping msg3 scheduling\n", ra->rnti);
@@ -447,13 +438,12 @@ void nr_add_msg3(module_id_t module_idP, int CC_id, frame_t frameP, sub_frame_t
nfapi_nr_pusch_pdu_t *pusch_pdu = &ra->pusch_pdu;
memset(pusch_pdu, 0, sizeof(nfapi_nr_pusch_pdu_t));
-
- AssertFatal(UE_list->active[UE_id] >=0,"Cannot find UE_id %d is not active\n", UE_id);
-
- NR_CellGroupConfig_t *secondaryCellGroup = UE_list->secondaryCellGroup[UE_id];
- AssertFatal(secondaryCellGroup->spCellConfig->spCellConfigDedicated->downlinkBWP_ToAddModList->list.count == 1,
- "downlinkBWP_ToAddModList has %d BWP!\n", secondaryCellGroup->spCellConfig->spCellConfigDedicated->downlinkBWP_ToAddModList->list.count);
- NR_BWP_Uplink_t *ubwp=secondaryCellGroup->spCellConfig->spCellConfigDedicated->uplinkConfig->uplinkBWP_ToAddModList->list.array[ra->bwp_id-1];
+ AssertFatal(ra->secondaryCellGroup,
+ "no secondaryCellGroup for RNTI %04x\n",
+ ra->crnti);
+ AssertFatal(ra->secondaryCellGroup->spCellConfig->spCellConfigDedicated->downlinkBWP_ToAddModList->list.count == 1,
+ "downlinkBWP_ToAddModList has %d BWP!\n", ra->secondaryCellGroup->spCellConfig->spCellConfigDedicated->downlinkBWP_ToAddModList->list.count);
+ NR_BWP_Uplink_t *ubwp = ra->secondaryCellGroup->spCellConfig->spCellConfigDedicated->uplinkConfig->uplinkBWP_ToAddModList->list.array[ra->bwp_id - 1];
LOG_D(MAC, "Frame %d, Subframe %d Adding Msg3 UL Config Request for (%d,%d) : (%d,%d,%d) for rnti: %d\n",
frameP,
slotP,
@@ -542,17 +532,15 @@ void nr_generate_Msg2(module_id_t module_idP,
frame_t frameP,
sub_frame_t slotP){
- int UE_id = 0, dci_formats[2], rnti_types[2], mcsIndex;
+ int dci_formats[2], rnti_types[2], mcsIndex;
int startSymbolAndLength = 0, StartSymbolIndex = -1, NrOfSymbols = 14, StartSymbolIndex_tmp, NrOfSymbols_tmp, x_Overhead, time_domain_assignment = 0;
gNB_MAC_INST *nr_mac = RC.nrmac[module_idP];
NR_COMMON_channels_t *cc = &nr_mac->common_channels[0];
NR_RA_t *ra = &cc->ra[0];
- NR_UE_list_t *UE_list = &nr_mac->UE_list;
NR_SearchSpace_t *ss = ra->ra_ss;
uint16_t RA_rnti = ra->RA_rnti;
long locationAndBandwidth;
- // uint8_t *vrb_map = cc[CC_id].vrb_map, CC_id;
// check if UE is doing RA on CORESET0 , InitialBWP or configured BWP from SCD
// get the BW of the PDCCH for PDCCH size and RAR PDSCH size
@@ -597,11 +585,13 @@ void nr_generate_Msg2(module_id_t module_idP,
// This code from this point on will not work on initialBWP or CORESET0
AssertFatal(ra->bwp_id>0,"cannot work on initialBWP for now\n");
- NR_CellGroupConfig_t *secondaryCellGroup = UE_list->secondaryCellGroup[UE_id];
- AssertFatal(secondaryCellGroup->spCellConfig->spCellConfigDedicated->downlinkBWP_ToAddModList->list.count == 1,
- "downlinkBWP_ToAddModList has %d BWP!\n", secondaryCellGroup->spCellConfig->spCellConfigDedicated->downlinkBWP_ToAddModList->list.count);
- NR_BWP_Downlink_t *bwp = secondaryCellGroup->spCellConfig->spCellConfigDedicated->downlinkBWP_ToAddModList->list.array[ra->bwp_id - 1];
- NR_BWP_Uplink_t *ubwp=secondaryCellGroup->spCellConfig->spCellConfigDedicated->uplinkConfig->uplinkBWP_ToAddModList->list.array[ra->bwp_id-1];
+ AssertFatal(ra->secondaryCellGroup,
+ "no secondaryCellGroup for RNTI %04x\n",
+ ra->crnti);
+ AssertFatal(ra->secondaryCellGroup->spCellConfig->spCellConfigDedicated->downlinkBWP_ToAddModList->list.count == 1,
+ "downlinkBWP_ToAddModList has %d BWP!\n", ra->secondaryCellGroup->spCellConfig->spCellConfigDedicated->downlinkBWP_ToAddModList->list.count);
+ NR_BWP_Downlink_t *bwp = ra->secondaryCellGroup->spCellConfig->spCellConfigDedicated->downlinkBWP_ToAddModList->list.array[ra->bwp_id - 1];
+ NR_BWP_Uplink_t *ubwp=ra->secondaryCellGroup->spCellConfig->spCellConfigDedicated->uplinkConfig->uplinkBWP_ToAddModList->list.array[ra->bwp_id-1];
LOG_D(MAC, "[RAPROC] Scheduling common search space DCI type 1 dlBWP BW %d\n", dci10_bw);
@@ -681,7 +671,30 @@ void nr_generate_Msg2(module_id_t module_idP,
dci_pdu_rel15[0].mcs,
dci_pdu_rel15[0].tb_scaling);
- nr_configure_pdcch(nr_mac, pdcch_pdu_rel15, RA_rnti, 0, ss, scc, bwp);
+ uint8_t nr_of_candidates, aggregation_level;
+ find_aggregation_candidates(&aggregation_level, &nr_of_candidates, ss);
+ NR_ControlResourceSet_t *coreset = get_coreset(bwp, ss, 0 /* common */);
+ int CCEIndex = allocate_nr_CCEs(
+ nr_mac,
+ bwp,
+ coreset,
+ aggregation_level,
+ 0, /* n_RNTI 0: common search space */
+ 0); // m
+
+ if (CCEIndex < 0) {
+ LOG_E(MAC, "%s(): cannot find free CCE for RA RNTI %04x!\n", __func__, ra->rnti);
+ return;
+ }
+ nr_configure_pdcch(nr_mac,
+ pdcch_pdu_rel15,
+ RA_rnti,
+ ss,
+ coreset,
+ scc,
+ bwp,
+ aggregation_level,
+ CCEIndex);
LOG_I(MAC, "Frame %d: Subframe %d : Adding common DL DCI for RA_RNTI %x\n", frameP, slotP, RA_rnti);
@@ -696,7 +709,7 @@ void nr_generate_Msg2(module_id_t module_idP,
pdcch_pdu_rel15->StartSymbolIndex,
pdcch_pdu_rel15->DurationSymbols);
- fill_dci_pdu_rel15(scc,secondaryCellGroup,pdcch_pdu_rel15, &dci_pdu_rel15[0], dci_formats, rnti_types,dci10_bw,ra->bwp_id);
+ fill_dci_pdu_rel15(scc,ra->secondaryCellGroup,pdcch_pdu_rel15, &dci_pdu_rel15[0], dci_formats, rnti_types,dci10_bw,ra->bwp_id);
dl_req->nPDUs+=2;
@@ -719,6 +732,11 @@ void nr_generate_Msg2(module_id_t module_idP,
nr_mac->TX_req[CC_id].Number_of_PDUs++;
nr_mac->TX_req[CC_id].Slot = slotP;
memcpy((void*)&tx_req->TLVs[0].value.direct[0], (void*)&cc[CC_id].RAR_pdu.payload[0], tx_req->TLVs[0].length);
+
+ /* mark the corresponding RBs as used */
+ uint8_t *vrb_map = cc[CC_id].vrb_map;
+ for (int rb = 0; rb < pdsch_pdu_rel15->rbSize; rb++)
+ vrb_map[rb + pdsch_pdu_rel15->rbStart] = 1;
}
}
diff --git a/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_bch.c b/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_bch.c
index 5fa77c6ca7..989d6fb952 100644
--- a/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_bch.c
+++ b/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_bch.c
@@ -82,7 +82,7 @@ void schedule_nr_mib(module_id_t module_idP, frame_t frameP, sub_frame_t slotP){
if (mib_sdu_length > 0) {
- LOG_I(MAC, "Frame %d, slot %d: Adding BCH PDU in position %d (length %d)\n", frameP, slotP, dl_req->nPDUs, mib_sdu_length);
+ LOG_D(MAC, "Frame %d, slot %d: Adding BCH PDU in position %d (length %d)\n", frameP, slotP, dl_req->nPDUs, mib_sdu_length);
if ((frameP & 1023) < 80){
LOG_I(MAC,"[gNB %d] Frame %d : MIB->BCH CC_id %d, Received %d bytes\n",module_idP, frameP, CC_id, mib_sdu_length);
@@ -137,6 +137,11 @@ void schedule_nr_mib(module_id_t module_idP, frame_t frameP, sub_frame_t slotP){
dl_config_pdu->ssb_pdu.ssb_pdu_rel15.bchPayloadFlag = 1;
dl_config_pdu->ssb_pdu.ssb_pdu_rel15.bchPayload = (*(uint32_t*)cc->MIB_pdu.payload) & ((1<<24)-1);
dl_req->nPDUs++;
+
+ uint8_t *vrb_map = cc[CC_id].vrb_map;
+ const int rbStart = dl_config_pdu->ssb_pdu.ssb_pdu_rel15.ssbOffsetPointA;
+ for (int rb = 0; rb < 20; rb++)
+ vrb_map[rbStart + rb] = 1;
}
}
}
diff --git a/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_dlsch.c b/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_dlsch.c
index 86b35254a4..ed142a42c8 100644
--- a/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_dlsch.c
+++ b/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_dlsch.c
@@ -32,6 +32,7 @@
/*PHY*/
#include "PHY/CODING/coding_defs.h"
#include "PHY/defs_nr_common.h"
+#include "common/utils/nr/nr_common.h"
#include "PHY/NR_TRANSPORT/nr_transport_common_proto.h"
/*MAC*/
#include "NR_MAC_COMMON/nr_mac.h"
@@ -45,6 +46,9 @@
/*TAG*/
#include "NR_TAG-Id.h"
+/*Softmodem params*/
+#include "executables/softmodem-common.h"
+
////////////////////////////////////////////////////////
/////* DLSCH MAC PDU generation (6.1.2 TS 38.321) */////
////////////////////////////////////////////////////////
@@ -54,6 +58,7 @@
//#define SIZE_OF_POINTER sizeof (void *)
int nr_generate_dlsch_pdu(module_id_t module_idP,
+ NR_UE_sched_ctrl_t *ue_sched_ctl,
unsigned char *sdus_payload,
unsigned char *mac_pdu,
unsigned char num_sdus,
@@ -70,14 +75,6 @@ int nr_generate_dlsch_pdu(module_id_t module_idP,
// MAC CEs
uint8_t mac_header_control_elements[16], *ce_ptr;
ce_ptr = &mac_header_control_elements[0];
- uint16_t UE_id = 0; //TODO need to get as a function parameter or need to invoke api to UE_id using module Id and RNTI
- gNB_MAC_INST *gNB_mac = RC.nrmac[module_idP];
- NR_UE_list_t *UE_list = &gNB_mac->UE_list;
- NR_UE_sched_ctrl_t *ue_sched_ctl = NULL;
- //NR_CellGroupConfig_t *config = UE_list->secondaryCellGroup[UE_id];
- ue_sched_ctl = &(UE_list->UE_sched_ctrl[UE_id]);
-
- NR_mac_stats_t *mac_stats = &(UE_list->mac_stats[UE_id]);
// 1) Compute MAC CE and related subheaders
@@ -329,8 +326,6 @@ int nr_generate_dlsch_pdu(module_id_t module_idP,
memcpy((void *) mac_pdu_ptr, (void *) dlsch_buffer_ptr, sdu_lengths[i]);
dlsch_buffer_ptr += sdu_lengths[i];
mac_pdu_ptr += sdu_lengths[i];
-
- mac_stats->lc_bytes_tx[sdu_lcids[i]] += sdu_lengths[i];
}
// 4) Compute final offset for padding
@@ -412,6 +407,409 @@ void handle_nr_uci(NR_UL_IND_t *UL_info, NR_UE_sched_ctrl_t *sched_ctrl, NR_mac_
UL_info->uci_ind.num_ucis = 0;
}
-/* functionalities of this function have been moved to nr_schedule_uss_dlsch_phytest */
-void nr_schedule_ue_spec(module_id_t module_idP, frame_t frameP, sub_frame_t slotP) {
+int getNrOfSymbols(NR_BWP_Downlink_t *bwp, int tda) {
+ struct NR_PDSCH_TimeDomainResourceAllocationList *tdaList =
+ bwp->bwp_Common->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;
+ int startSymbolIndex, nrOfSymbols;
+ SLIV2SL(startSymbolAndLength, &startSymbolIndex, &nrOfSymbols);
+ return nrOfSymbols;
+}
+
+nfapi_nr_dmrs_type_e getDmrsConfigType(NR_BWP_Downlink_t *bwp) {
+ return bwp->bwp_Dedicated->pdsch_Config->choice.setup->dmrs_DownlinkForPDSCH_MappingTypeA->choice.setup->dmrs_Type == NULL ? 0 : 1;
+}
+
+uint8_t getN_PRB_DMRS(NR_BWP_Downlink_t *bwp, int numDmrsCdmGrpsNoData) {
+ const nfapi_nr_dmrs_type_e dmrsConfigType = getDmrsConfigType(bwp);
+ if (dmrsConfigType == NFAPI_NR_DMRS_TYPE1) {
+ // if no data in dmrs cdm group is 1 only even REs have no data
+ // if no data in dmrs cdm group is 2 both odd and even REs have no data
+ return numDmrsCdmGrpsNoData * 6;
+ } else {
+ return numDmrsCdmGrpsNoData * 4;
+ }
+}
+
+void nr_simple_dlsch_preprocessor(module_id_t module_id,
+ frame_t frame,
+ sub_frame_t slot,
+ int num_slots_per_tdd) {
+ NR_UE_info_t *UE_info = &RC.nrmac[module_id]->UE_info;
+
+ AssertFatal(UE_info->num_UEs <= 1,
+ "%s() cannot handle more than one UE, but found %d\n",
+ __func__,
+ UE_info->num_UEs);
+ if (UE_info->num_UEs == 0)
+ return;
+
+ const int UE_id = 0;
+ const int CC_id = 0;
+
+ NR_UE_sched_ctrl_t *sched_ctrl = &UE_info->UE_sched_ctrl[UE_id];
+ sched_ctrl->rbSize = 0;
+
+ /* Retrieve amount of data to send for this UE */
+ sched_ctrl->num_total_bytes = 0;
+ const int lcid = DL_SCH_LCID_DTCH;
+ const uint16_t rnti = UE_info->rnti[UE_id];
+ sched_ctrl->rlc_status[lcid] = mac_rlc_status_ind(module_id,
+ rnti,
+ module_id,
+ frame,
+ slot,
+ ENB_FLAG_YES,
+ MBMS_FLAG_NO,
+ lcid,
+ 0,
+ 0);
+ sched_ctrl->num_total_bytes += sched_ctrl->rlc_status[lcid].bytes_in_buffer;
+ if (sched_ctrl->num_total_bytes == 0 && !get_softmodem_params()->phy_test)
+ return;
+ LOG_D(MAC,
+ "%d.%d, DTCH%d->DLSCH, RLC status %d bytes\n",
+ frame,
+ slot,
+ lcid,
+ sched_ctrl->rlc_status[lcid].bytes_in_buffer);
+
+ /* Find a free CCE */
+ const int target_ss = NR_SearchSpace__searchSpaceType_PR_ue_Specific;
+ sched_ctrl->search_space = get_searchspace(sched_ctrl->active_bwp, target_ss);
+ uint8_t nr_of_candidates;
+ find_aggregation_candidates(&sched_ctrl->aggregation_level,
+ &nr_of_candidates,
+ sched_ctrl->search_space);
+ sched_ctrl->coreset = get_coreset(
+ sched_ctrl->active_bwp, sched_ctrl->search_space, 1 /* dedicated */);
+ sched_ctrl->cce_index = allocate_nr_CCEs(RC.nrmac[module_id],
+ sched_ctrl->active_bwp,
+ sched_ctrl->coreset,
+ sched_ctrl->aggregation_level,
+ UE_info->rnti[UE_id],
+ 0); // m
+ if (sched_ctrl->cce_index < 0) {
+ LOG_E(MAC, "%s(): could not find CCE for UE %d\n", __func__, UE_id);
+ return;
+ }
+
+ /* Find PUCCH occasion */
+ nr_update_pucch_scheduling(
+ module_id, UE_id, frame, slot, num_slots_per_tdd, &sched_ctrl->pucch_sched_idx);
+ AssertFatal(sched_ctrl->pucch_sched_idx >= 0, "no uplink slot for PUCCH found!\n");
+
+ uint8_t *vrb_map = RC.nrmac[module_id]->common_channels[CC_id].vrb_map;
+ const int current_harq_pid = sched_ctrl->current_harq_pid;
+ NR_UE_harq_t *harq = &sched_ctrl->harq_processes[current_harq_pid];
+ NR_UE_ret_info_t *retInfo = &sched_ctrl->retInfo[current_harq_pid];
+ const uint16_t bwpSize = NRRIV2BW(sched_ctrl->active_bwp->bwp_Common->genericParameters.locationAndBandwidth, 275);
+ int rbStart = NRRIV2PRBOFFSET(sched_ctrl->active_bwp->bwp_Common->genericParameters.locationAndBandwidth, 275);
+
+ if (harq->round != 0) { /* retransmission */
+ sched_ctrl->time_domain_allocation = retInfo->time_domain_allocation;
+
+ /* ensure that there is a free place for RB allocation */
+ int rbSize = 0;
+ while (rbSize < retInfo->rbSize) {
+ rbStart += rbSize; /* last iteration rbSize was not enough, skip it */
+ rbSize = 0;
+ while (rbStart < bwpSize && vrb_map[rbStart]) rbStart++;
+ if (rbStart >= bwpSize) {
+ LOG_E(MAC,
+ "cannot allocate retransmission for UE %d/RNTI %04x: no resources\n",
+ UE_id,
+ rnti);
+ return;
+ }
+ while (rbStart + rbSize < bwpSize
+ && !vrb_map[rbStart + rbSize]
+ && rbSize < retInfo->rbSize)
+ rbSize++;
+ }
+ sched_ctrl->rbSize = retInfo->rbSize;
+ sched_ctrl->rbStart = rbStart;
+
+ /* MCS etc: just reuse from previous scheduling opportunity */
+ sched_ctrl->mcsTableIdx = retInfo->mcsTableIdx;
+ sched_ctrl->mcs = retInfo->mcs;
+ sched_ctrl->numDmrsCdmGrpsNoData = retInfo->numDmrsCdmGrpsNoData;
+ } else {
+ // Time-domain allocation
+ sched_ctrl->time_domain_allocation = 2;
+
+ // modulation scheme
+ sched_ctrl->mcsTableIdx = 0;
+ sched_ctrl->mcs = 9;
+ sched_ctrl->numDmrsCdmGrpsNoData = 1;
+
+ // Freq-demain allocation
+ while (rbStart < bwpSize && vrb_map[rbStart]) rbStart++;
+
+ uint8_t N_PRB_DMRS =
+ getN_PRB_DMRS(sched_ctrl->active_bwp, sched_ctrl->numDmrsCdmGrpsNoData);
+ int nrOfSymbols = getNrOfSymbols(sched_ctrl->active_bwp,
+ sched_ctrl->time_domain_allocation);
+
+ int rbSize = 0;
+ uint32_t TBS = 0;
+ do {
+ rbSize++;
+ TBS = nr_compute_tbs(nr_get_Qm_dl(sched_ctrl->mcs, sched_ctrl->mcsTableIdx),
+ nr_get_code_rate_dl(sched_ctrl->mcs, sched_ctrl->mcsTableIdx),
+ rbSize,
+ nrOfSymbols,
+ N_PRB_DMRS, // FIXME // This should be multiplied by the
+ // number of dmrs symbols
+ 0 /* N_PRB_oh, 0 for initialBWP */,
+ 0 /* tb_scaling */,
+ 1 /* nrOfLayers */)
+ >> 3;
+ } while (rbStart + rbSize < bwpSize && !vrb_map[rbStart + rbSize] && TBS < sched_ctrl->num_total_bytes);
+ sched_ctrl->rbSize = rbSize;
+ sched_ctrl->rbStart = rbStart;
+ }
+
+ /* mark the corresponding RBs as used */
+ for (int rb = 0; rb < sched_ctrl->rbSize; rb++)
+ vrb_map[rb + sched_ctrl->rbStart] = 1;
+}
+
+void nr_schedule_ue_spec(module_id_t module_id,
+ frame_t frame,
+ sub_frame_t slot,
+ int num_slots_per_tdd) {
+ /* PREPROCESSOR */
+ nr_simple_dlsch_preprocessor(module_id, frame, slot, num_slots_per_tdd);
+
+ gNB_MAC_INST *gNB_mac = RC.nrmac[module_id];
+ NR_UE_info_t *UE_info = &gNB_mac->UE_info;
+
+ const int CC_id = 0;
+
+ NR_UE_list_t *UE_list = &UE_info->list;
+ 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->rbSize <= 0 && !get_softmodem_params()->phy_test)
+ continue;
+
+ const rnti_t rnti = UE_info->rnti[UE_id];
+
+ /* POST processing */
+ struct NR_PDSCH_TimeDomainResourceAllocationList *tdaList =
+ sched_ctrl->active_bwp->bwp_Common->pdsch_ConfigCommon->choice.setup->pdsch_TimeDomainAllocationList;
+ AssertFatal(sched_ctrl->time_domain_allocation < tdaList->list.count,
+ "time_domain_allocation %d>=%d\n",
+ sched_ctrl->time_domain_allocation,
+ tdaList->list.count);
+
+ const int startSymbolAndLength =
+ tdaList->list.array[sched_ctrl->time_domain_allocation]->startSymbolAndLength;
+ int startSymbolIndex, nrOfSymbols;
+ SLIV2SL(startSymbolAndLength, &startSymbolIndex, &nrOfSymbols);
+
+ uint8_t N_PRB_DMRS =
+ getN_PRB_DMRS(sched_ctrl->active_bwp, sched_ctrl->numDmrsCdmGrpsNoData);
+ const uint32_t TBS =
+ nr_compute_tbs(nr_get_Qm_dl(sched_ctrl->mcs, sched_ctrl->mcsTableIdx),
+ nr_get_code_rate_dl(sched_ctrl->mcs, sched_ctrl->mcsTableIdx),
+ sched_ctrl->rbSize,
+ nrOfSymbols,
+ N_PRB_DMRS, // FIXME // This should be multiplied by the
+ // number of dmrs symbols
+ 0 /* N_PRB_oh, 0 for initialBWP */,
+ 0 /* tb_scaling */,
+ 1 /* nrOfLayers */)
+ >> 3;
+
+ const int current_harq_pid = sched_ctrl->current_harq_pid;
+ NR_UE_harq_t *harq = &sched_ctrl->harq_processes[current_harq_pid];
+ NR_sched_pucch *pucch = &sched_ctrl->sched_pucch[sched_ctrl->pucch_sched_idx];
+ harq->feedback_slot = pucch->ul_slot;
+ harq->is_waiting = 1;
+ UE_info->mac_stats[UE_id].dlsch_rounds[harq->round]++;
+
+ nfapi_nr_dl_tti_request_body_t *dl_req = &gNB_mac->DL_req[CC_id].dl_tti_request_body;
+ nr_fill_nfapi_dl_pdu(module_id,
+ UE_id,
+ sched_ctrl->active_bwp->bwp_Id,
+ sched_ctrl->search_space,
+ sched_ctrl->coreset,
+ dl_req,
+ pucch,
+ 1 /* nrOfLayers */,
+ sched_ctrl->mcs,
+ sched_ctrl->rbSize,
+ sched_ctrl->rbStart,
+ sched_ctrl->numDmrsCdmGrpsNoData,
+ getDmrsConfigType(sched_ctrl->active_bwp),
+ sched_ctrl->mcsTableIdx,
+ nr_get_code_rate_dl(sched_ctrl->mcs, sched_ctrl->mcsTableIdx),
+ nr_get_Qm_dl(sched_ctrl->mcs, sched_ctrl->mcsTableIdx),
+ TBS,
+ sched_ctrl->time_domain_allocation,
+ startSymbolIndex,
+ nrOfSymbols,
+ sched_ctrl->aggregation_level,
+ sched_ctrl->cce_index,
+ current_harq_pid,
+ harq->ndi,
+ harq->round);
+
+ NR_UE_ret_info_t *retInfo = &sched_ctrl->retInfo[current_harq_pid];
+ if (harq->round != 0) { /* retransmission */
+ if (sched_ctrl->rbSize != retInfo->rbSize)
+ LOG_W(MAC,
+ "retransmission uses different rbSize (%d vs. orig %d)\n",
+ sched_ctrl->rbSize,
+ retInfo->rbSize);
+ if (sched_ctrl->time_domain_allocation != retInfo->time_domain_allocation)
+ LOG_W(MAC,
+ "retransmission uses different time_domain_allocation (%d vs. orig %d)\n",
+ sched_ctrl->time_domain_allocation,
+ retInfo->time_domain_allocation);
+ if (sched_ctrl->mcs != retInfo->mcs
+ || sched_ctrl->mcsTableIdx != retInfo->mcsTableIdx
+ || sched_ctrl->numDmrsCdmGrpsNoData != retInfo->numDmrsCdmGrpsNoData)
+ LOG_W(MAC,
+ "retransmission uses different table/MCS/numDmrsCdmGrpsNoData (%d/%d/%d vs. orig %d/%d/%d)\n",
+ sched_ctrl->mcsTableIdx,
+ sched_ctrl->mcs,
+ sched_ctrl->numDmrsCdmGrpsNoData,
+ retInfo->mcsTableIdx,
+ retInfo->mcs,
+ retInfo->numDmrsCdmGrpsNoData);
+ /* we do not have to do anything, since we do not require to get data
+ * from RLC, encode MAC CEs, or copy data to FAPI structures */
+ LOG_W(MAC, "%d.%2d retransmission UE %d/RNTI %04x\n", frame, slot, UE_id, rnti);
+ } else { /* initial transmission */
+
+ /* reserve space for timing advance of UE if necessary,
+ * nr_generate_dlsch_pdu() checks for ta_apply and add TA CE if necessary */
+ const int ta_len = (sched_ctrl->ta_apply) ? 2 : 0;
+
+ /* Get RLC data TODO: remove random data retrieval */
+ int header_length_total = 0;
+ int header_length_last = 0;
+ int sdu_length_total = 0;
+ int num_sdus = 0;
+ uint16_t sdu_lengths[NB_RB_MAX] = {0};
+ uint8_t mac_sdus[MAX_NR_DLSCH_PAYLOAD_BYTES];
+ unsigned char sdu_lcids[NB_RB_MAX] = {0};
+ const int lcid = DL_SCH_LCID_DTCH;
+ if (sched_ctrl->num_total_bytes > 0) {
+ LOG_D(MAC,
+ "[gNB %d][USER-PLANE DEFAULT DRB] Frame %d : DTCH->DLSCH, Requesting "
+ "%d bytes from RLC (lcid %d total hdr len %d), TBS: %d \n \n",
+ module_id,
+ frame,
+ TBS - ta_len - header_length_total - sdu_length_total - 3,
+ lcid,
+ header_length_total,
+ TBS);
+
+ sdu_lengths[num_sdus] = mac_rlc_data_req(module_id,
+ rnti,
+ module_id,
+ frame,
+ ENB_FLAG_YES,
+ MBMS_FLAG_NO,
+ lcid,
+ TBS - ta_len - header_length_total - sdu_length_total - 3,
+ (char *)&mac_sdus[sdu_length_total],
+ 0,
+ 0);
+
+ LOG_D(MAC,
+ "[gNB %d][USER-PLANE DEFAULT DRB] Got %d bytes for DTCH %d \n",
+ module_id,
+ sdu_lengths[num_sdus],
+ lcid);
+
+ sdu_lcids[num_sdus] = lcid;
+ sdu_length_total += sdu_lengths[num_sdus];
+ header_length_last = 1 + 1 + (sdu_lengths[num_sdus] >= 128);
+ header_length_total += header_length_last;
+
+ num_sdus++;
+
+ //ue_sched_ctl->uplane_inactivity_timer = 0;
+ }
+ else if (get_softmodem_params()->phy_test) {
+ LOG_D(MAC, "Configuring DL_TX in %d.%d: random data\n", frame, slot);
+ // fill dlsch_buffer with random data
+ for (int i = 0; i < TBS; i++)
+ mac_sdus[i] = (unsigned char) (lrand48()&0xff);
+ sdu_lcids[0] = 0x3f; // DRB
+ sdu_lengths[0] = TBS - ta_len - 3;
+ header_length_total += 2 + (sdu_lengths[0] >= 128);
+ sdu_length_total += sdu_lengths[0];
+ num_sdus +=1;
+ }
+
+ UE_info->mac_stats[UE_id].dlsch_total_bytes += TBS;
+ UE_info->mac_stats[UE_id].lc_bytes_tx[lcid] += sdu_length_total;
+
+ // Check if there is data from RLC or CE
+ const int post_padding = TBS >= 2 + header_length_total + sdu_length_total + ta_len;
+ // padding param currently not in use
+ //padding = TBS - header_length_total - sdu_length_total - ta_len - 1;
+
+ 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];
+ /* pointer to directly generate the PDU into the nFAPI structure */
+ uint32_t *buf = tx_req->TLVs[0].value.direct;
+
+ const int offset = nr_generate_dlsch_pdu(
+ module_id,
+ sched_ctrl,
+ (unsigned char *)mac_sdus,
+ (unsigned char *)buf,
+ num_sdus, // num_sdus
+ sdu_lengths,
+ sdu_lcids,
+ 255, // no drx
+ NULL, // contention res id
+ post_padding);
+
+ // Padding: fill remainder of DLSCH with 0
+ if (post_padding > 0) {
+ for (int j = 0; j < TBS - offset; j++)
+ buf[offset + j] = 0;
+ }
+
+ /* the buffer has been filled by nr_generate_dlsch_pdu(), below we simply
+ * fill the remaining information */
+ tx_req->PDU_length = TBS;
+ tx_req->PDU_index = gNB_mac->pdu_index[0]++;
+ tx_req->num_TLV = 1;
+ tx_req->TLVs[0].length = TBS + 2;
+ gNB_mac->TX_req[CC_id].Number_of_PDUs++;
+ gNB_mac->TX_req[CC_id].SFN = frame;
+ gNB_mac->TX_req[CC_id].Slot = slot;
+
+ retInfo->rbSize = sched_ctrl->rbSize;
+ retInfo->time_domain_allocation = sched_ctrl->time_domain_allocation;
+ retInfo->mcsTableIdx = sched_ctrl->mcsTableIdx;
+ retInfo->mcs = sched_ctrl->mcs;
+ retInfo->numDmrsCdmGrpsNoData = sched_ctrl->numDmrsCdmGrpsNoData;
+
+#if defined(ENABLE_MAC_PAYLOAD_DEBUG)
+ if (frame%100 == 0) {
+ LOG_I(MAC,
+ "%d.%d, first 10 payload bytes, TBS size: %d \n",
+ frame,
+ slot,
+ TBS);
+ for(int i = 0; i < 10; i++)
+ LOG_I(MAC, "byte %d: %x\n", i, ((uint8_t *) buf)[i]);
+ }
+#endif
+ }
+ }
}
diff --git a/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_phytest.c b/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_phytest.c
index 678547631f..5f9d5d8a10 100644
--- a/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_phytest.c
+++ b/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_phytest.c
@@ -252,14 +252,12 @@ void nr_schedule_css_dlsch_phytest(module_id_t module_idP,
}
}
-
-int configure_fapi_dl_pdu(int Mod_idP,
- nfapi_nr_dl_tti_request_body_t *dl_req,
- NR_sched_pucch *pucch_sched,
- uint8_t *mcsIndex,
- uint16_t *rbSize,
- uint16_t *rbStart) {
-
+int configure_fapi_dl_pdu_phytest(int Mod_idP,
+ nfapi_nr_dl_tti_request_body_t *dl_req,
+ NR_sched_pucch *pucch_sched,
+ uint8_t *mcsIndex,
+ uint16_t *rbSize,
+ uint16_t *rbStart) {
gNB_MAC_INST *nr_mac = RC.nrmac[Mod_idP];
NR_COMMON_channels_t *cc = nr_mac->common_channels;
NR_ServingCellConfigCommon_t *scc = cc->ServingCellConfigCommon;
@@ -271,9 +269,9 @@ int configure_fapi_dl_pdu(int Mod_idP,
int bwp_id=1;
int UE_id = 0;
- NR_UE_list_t *UE_list = &RC.nrmac[Mod_idP]->UE_list;
+ NR_UE_info_t *UE_info = &RC.nrmac[Mod_idP]->UE_info;
- NR_CellGroupConfig_t *secondaryCellGroup = UE_list->secondaryCellGroup[UE_id];
+ NR_CellGroupConfig_t *secondaryCellGroup = UE_info->secondaryCellGroup[UE_id];
AssertFatal(secondaryCellGroup->spCellConfig->spCellConfigDedicated->downlinkBWP_ToAddModList->list.count == 1,
"downlinkBWP_ToAddModList has %d BWP!\n",
secondaryCellGroup->spCellConfig->spCellConfigDedicated->downlinkBWP_ToAddModList->list.count);
@@ -298,7 +296,7 @@ int configure_fapi_dl_pdu(int Mod_idP,
pdsch_pdu_rel15->pduBitmap = 0;
- pdsch_pdu_rel15->rnti = UE_list->rnti[UE_id];
+ pdsch_pdu_rel15->rnti = UE_info->rnti[UE_id];
pdsch_pdu_rel15->pduIndex = 0;
// BWP
@@ -310,17 +308,17 @@ int configure_fapi_dl_pdu(int Mod_idP,
pdsch_pdu_rel15->NrOfCodewords = 1;
int mcs = (mcsIndex!=NULL) ? *mcsIndex : 9;
- int current_harq_pid = UE_list->UE_sched_ctrl[UE_id].current_harq_pid;
+ int current_harq_pid = UE_info->UE_sched_ctrl[UE_id].current_harq_pid;
pdsch_pdu_rel15->targetCodeRate[0] = nr_get_code_rate_dl(mcs,0);
pdsch_pdu_rel15->qamModOrder[0] = 2;
pdsch_pdu_rel15->mcsIndex[0] = mcs;
pdsch_pdu_rel15->mcsTable[0] = 0;
- pdsch_pdu_rel15->rvIndex[0] = nr_rv_round_map[UE_list->UE_sched_ctrl[UE_id].harq_processes[current_harq_pid].round];
+ pdsch_pdu_rel15->rvIndex[0] = nr_rv_round_map[UE_info->UE_sched_ctrl[UE_id].harq_processes[current_harq_pid].round];
pdsch_pdu_rel15->dataScramblingId = *scc->physCellId;
pdsch_pdu_rel15->nrOfLayers = 1;
pdsch_pdu_rel15->transmissionScheme = 0;
pdsch_pdu_rel15->refPoint = 0; // Point A
- UE_list->mac_stats[UE_id].dlsch_rounds[UE_list->UE_sched_ctrl[UE_id].harq_processes[current_harq_pid].round]++;
+ UE_info->mac_stats[UE_id].dlsch_rounds[UE_info->UE_sched_ctrl[UE_id].harq_processes[current_harq_pid].round]++;
pdsch_pdu_rel15->dmrsConfigType = bwp->bwp_Dedicated->pdsch_Config->choice.setup->dmrs_DownlinkForPDSCH_MappingTypeA->choice.setup->dmrs_Type == NULL ? 0 : 1;
pdsch_pdu_rel15->dlDmrsScramblingId = *scc->physCellId;
pdsch_pdu_rel15->SCID = 0;
@@ -368,18 +366,18 @@ int configure_fapi_dl_pdu(int Mod_idP,
dci_pdu_rel15[0].rv = pdsch_pdu_rel15->rvIndex[0];
// harq pid and ndi
dci_pdu_rel15[0].harq_pid = current_harq_pid;
- dci_pdu_rel15[0].ndi = UE_list->UE_sched_ctrl[UE_id].harq_processes[current_harq_pid].ndi;
+ dci_pdu_rel15[0].ndi = UE_info->UE_sched_ctrl[UE_id].harq_processes[current_harq_pid].ndi;
// DAI
dci_pdu_rel15[0].dai[0].val = (pucch_sched->dai_c-1)&3;
// TPC for PUCCH
- dci_pdu_rel15[0].tpc = UE_list->UE_sched_ctrl[UE_id].tpc1; // table 7.2.1-1 in 38.213
+ dci_pdu_rel15[0].tpc = UE_info->UE_sched_ctrl[UE_id].tpc1; // table 7.2.1-1 in 38.213
// PUCCH resource indicator
dci_pdu_rel15[0].pucch_resource_indicator = pucch_sched->resource_indicator;
// PDSCH to HARQ TI
dci_pdu_rel15[0].pdsch_to_harq_feedback_timing_indicator.val = pucch_sched->timing_indicator;
- UE_list->UE_sched_ctrl[UE_id].harq_processes[current_harq_pid].feedback_slot = pucch_sched->ul_slot;
- UE_list->UE_sched_ctrl[UE_id].harq_processes[current_harq_pid].is_waiting = 1;
+ UE_info->UE_sched_ctrl[UE_id].harq_processes[current_harq_pid].feedback_slot = pucch_sched->ul_slot;
+ UE_info->UE_sched_ctrl[UE_id].harq_processes[current_harq_pid].is_waiting = 1;
// antenna ports
dci_pdu_rel15[0].antenna_ports.val = 0; // nb of cdm groups w/o data 1 and dmrs port 0
// dmrs sequence initialization
@@ -416,18 +414,30 @@ int configure_fapi_dl_pdu(int Mod_idP,
}
AssertFatal(found==1,"Couldn't find an adequate searchspace\n");
- int ret = nr_configure_pdcch(nr_mac,
- pdcch_pdu_rel15,
- UE_list->rnti[UE_id],
- 1, // ue-specific
- ss,
- scc,
- bwp);
- if (ret < 0) {
- LOG_I(MAC,"CCE list not empty, couldn't schedule PDSCH\n");
- free(dci_pdu_rel15);
- return (0);
+ uint8_t nr_of_candidates, aggregation_level;
+ find_aggregation_candidates(&aggregation_level, &nr_of_candidates, ss);
+ NR_ControlResourceSet_t *coreset = get_coreset(bwp, ss, 1 /* dedicated */);
+ int CCEIndex = allocate_nr_CCEs(
+ nr_mac,
+ bwp,
+ coreset,
+ aggregation_level,
+ UE_info->rnti[UE_id],
+ 0); // m
+ if (CCEIndex < 0) {
+ LOG_E(MAC, "%s(): CCE list not empty, couldn't schedule PDSCH\n", __func__);
+ free(dci_pdu_rel15);
+ return 0;
}
+ nr_configure_pdcch(nr_mac,
+ pdcch_pdu_rel15,
+ UE_info->rnti[UE_id],
+ ss,
+ coreset,
+ scc,
+ bwp,
+ aggregation_level,
+ CCEIndex);
int dci_formats[2];
int rnti_types[2];
@@ -455,8 +465,8 @@ int configure_fapi_dl_pdu(int Mod_idP,
// Hardcode it for now
TBS = dl_tti_pdsch_pdu->pdsch_pdu.pdsch_pdu_rel15.TBSize[0];
- if (UE_list->UE_sched_ctrl[UE_id].harq_processes[current_harq_pid].round==0)
- UE_list->mac_stats[UE_id].dlsch_total_bytes += TBS;
+ if (UE_info->UE_sched_ctrl[UE_id].harq_processes[current_harq_pid].round==0)
+ UE_info->mac_stats[UE_id].dlsch_total_bytes += TBS;
LOG_D(MAC, "DLSCH PDU: start PRB %d n_PRB %d startSymbolAndLength %d start symbol %d nb_symbols %d nb_layers %d nb_codewords %d mcs %d TBS: %d\n",
pdsch_pdu_rel15->rbStart,
@@ -581,7 +591,7 @@ void configure_fapi_dl_Tx(module_id_t Mod_idP,
tx_req->num_TLV = 1;
tx_req->TLVs[0].length = tbs_bytes +2;
- memcpy((void*)&tx_req->TLVs[0].value.direct[0], (void*)&nr_mac->UE_list.DLSCH_pdu[0][0].payload[0], tbs_bytes);
+ memcpy((void*)&tx_req->TLVs[0].value.direct[0], (void*)&nr_mac->UE_info.DLSCH_pdu[0][0].payload[0], tbs_bytes);
nr_mac->TX_req[CC_id].Number_of_PDUs++;
nr_mac->TX_req[CC_id].SFN = frameP;
@@ -608,14 +618,14 @@ void nr_schedule_uss_dlsch_phytest(module_id_t module_idP,
mac_rlc_status_resp_t rlc_status;
- NR_UE_list_t *UE_list = &gNB_mac->UE_list;
+ NR_UE_info_t *UE_info = &gNB_mac->UE_info;
- if (UE_list->num_UEs ==0) return;
+ if (UE_info->num_UEs ==0) return;
unsigned char sdu_lcids[NB_RB_MAX] = {0};
uint16_t sdu_lengths[NB_RB_MAX] = {0};
- uint16_t rnti = UE_list->rnti[UE_id];
- NR_UE_sched_ctrl_t *ue_sched_ctl = &UE_list->UE_sched_ctrl[UE_id];
+ uint16_t rnti = UE_info->rnti[UE_id];
+ NR_UE_sched_ctrl_t *ue_sched_ctl = &UE_info->UE_sched_ctrl[UE_id];
uint8_t mac_sdus[MAX_NR_DLSCH_PAYLOAD_BYTES];
@@ -623,12 +633,13 @@ void nr_schedule_uss_dlsch_phytest(module_id_t module_idP,
int ta_len = (ue_sched_ctl->ta_apply)?2:0;
- TBS_bytes = configure_fapi_dl_pdu(module_idP,
- dl_req,
- pucch_sched,
- dlsch_config!=NULL ? dlsch_config->mcsIndex : NULL,
- dlsch_config!=NULL ? &dlsch_config->rbSize : NULL,
- dlsch_config!=NULL ? &dlsch_config->rbStart : NULL);
+ TBS_bytes = configure_fapi_dl_pdu_phytest(
+ module_idP,
+ dl_req,
+ pucch_sched,
+ dlsch_config != NULL ? dlsch_config->mcsIndex : NULL,
+ dlsch_config != NULL ? &dlsch_config->rbSize : NULL,
+ dlsch_config != NULL ? &dlsch_config->rbStart : NULL);
if (TBS_bytes == 0)
return;
@@ -693,7 +704,7 @@ void nr_schedule_uss_dlsch_phytest(module_id_t module_idP,
// fill dlsch_buffer with random data
for (i = 0; i < TBS_bytes; i++){
mac_sdus[i] = (unsigned char) (lrand48()&0xff);
- //((uint8_t *)gNB_mac->UE_list.DLSCH_pdu[0][0].payload[0])[i] = (unsigned char) (lrand48()&0xff);
+ //((uint8_t *)gNB_mac->UE_info.DLSCH_pdu[0][0].payload[0])[i] = (unsigned char) (lrand48()&0xff);
}
//Sending SDUs with size 1
//Initialize elements of sdu_lcids and sdu_lengths
@@ -707,13 +718,15 @@ void nr_schedule_uss_dlsch_phytest(module_id_t module_idP,
if (frameP%100 == 0){
LOG_I(MAC, "Printing first 10 payload bytes at the gNB side, Frame: %d, slot: %d, TBS size: %d \n", frameP, slotP, TBS_bytes);
for(int i = 0; i < 10; i++) {
- LOG_I(MAC, "%x. ", ((uint8_t *)gNB_mac->UE_list.DLSCH_pdu[CC_id][0][0].payload[0])[i]);
+ LOG_I(MAC, "%x. ", ((uint8_t *)gNB_mac->UE_info.DLSCH_pdu[CC_id][0][0].payload[0])[i]);
}
}
#endif
}
+ UE_info->mac_stats[UE_id].lc_bytes_tx[lcid] += sdu_length_total;
+
// there is at least one SDU or TA command
// if (num_sdus > 0 ){
if (ta_len + sdu_length_total + header_length_total > 0) {
@@ -730,8 +743,9 @@ void nr_schedule_uss_dlsch_phytest(module_id_t module_idP,
}
offset = nr_generate_dlsch_pdu(module_idP,
+ &UE_info->UE_sched_ctrl[UE_id],
(unsigned char *) mac_sdus,
- (unsigned char *) gNB_mac->UE_list.DLSCH_pdu[0][0].payload[0],
+ (unsigned char *) gNB_mac->UE_info.DLSCH_pdu[0][0].payload[0],
num_sdus, //num_sdus
sdu_lengths,
sdu_lcids,
@@ -742,7 +756,7 @@ void nr_schedule_uss_dlsch_phytest(module_id_t module_idP,
// Padding: fill remainder of DLSCH with 0
if (post_padding > 0){
for (int j = 0; j < (TBS_bytes - offset); j++)
- gNB_mac->UE_list.DLSCH_pdu[0][0].payload[0][offset + j] = 0; // mac_pdu[offset + j] = 0;
+ gNB_mac->UE_info.DLSCH_pdu[0][0].payload[0][offset + j] = 0; // mac_pdu[offset + j] = 0;
}
configure_fapi_dl_Tx(module_idP, frameP, slotP, dl_req, tx_req, TBS_bytes, gNB_mac->pdu_index[CC_id]);
@@ -759,7 +773,7 @@ void nr_schedule_uss_dlsch_phytest(module_id_t module_idP,
if (frameP%100 == 0){
LOG_I(MAC, "Printing first 10 payload bytes at the gNB side, Frame: %d, slot: %d, TBS size: %d \n", frameP, slotP, TBS_bytes);
for(int i = 0; i < 10; i++) {
- LOG_I(MAC, "byte %d : %x\n", i,((uint8_t *)gNB_mac->UE_list.DLSCH_pdu[0][0].payload[0])[i]); //LOG_I(MAC, "%x. ", mac_payload[i]);
+ LOG_I(MAC, "byte %d : %x\n", i,((uint8_t *)gNB_mac->UE_info.DLSCH_pdu[0][0].payload[0])[i]); //LOG_I(MAC, "%x. ", mac_payload[i]);
}
}
#endif
@@ -800,12 +814,26 @@ int8_t select_ul_harq_pid(NR_UE_sched_ctrl_t *sched_ctrl) {
return -1;
}
+long get_K2(NR_BWP_Uplink_t *ubwp, int time_domain_assignment, int mu) {
+ DevAssert(ubwp);
+ const NR_PUSCH_TimeDomainResourceAllocation_t *tda_list = ubwp->bwp_Common->pusch_ConfigCommon->choice.setup->pusch_TimeDomainAllocationList->list.array[time_domain_assignment];
+ if (tda_list->k2)
+ return *tda_list->k2;
+ else if (mu < 2)
+ return 1;
+ else if (mu == 2)
+ return 2;
+ else
+ return 3;
+}
+
void schedule_fapi_ul_pdu(int Mod_idP,
frame_t frameP,
sub_frame_t slotP,
int num_slots_per_tdd,
int ul_slots,
- int time_domain_assignment) {
+ int time_domain_assignment,
+ uint64_t ulsch_in_slot_bitmap) {
gNB_MAC_INST *nr_mac = RC.nrmac[Mod_idP];
NR_COMMON_channels_t *cc = nr_mac->common_channels;
@@ -814,10 +842,10 @@ void schedule_fapi_ul_pdu(int Mod_idP,
int bwp_id=1;
int mu = scc->uplinkConfigCommon->initialUplinkBWP->genericParameters.subcarrierSpacing;
int UE_id = 0;
- NR_UE_list_t *UE_list = &RC.nrmac[Mod_idP]->UE_list;
- AssertFatal(UE_list->active[UE_id] >=0,"Cannot find UE_id %d is not active\n",UE_id);
+ NR_UE_info_t *UE_info = &RC.nrmac[Mod_idP]->UE_info;
+ AssertFatal(UE_info->active[UE_id],"Cannot find UE_id %d is not active\n",UE_id);
- NR_CellGroupConfig_t *secondaryCellGroup = UE_list->secondaryCellGroup[UE_id];
+ NR_CellGroupConfig_t *secondaryCellGroup = UE_info->secondaryCellGroup[UE_id];
AssertFatal(secondaryCellGroup->spCellConfig->spCellConfigDedicated->downlinkBWP_ToAddModList->list.count == 1,
"downlinkBWP_ToAddModList has %d BWP!\n",
secondaryCellGroup->spCellConfig->spCellConfigDedicated->downlinkBWP_ToAddModList->list.count);
@@ -829,18 +857,14 @@ void schedule_fapi_ul_pdu(int Mod_idP,
AssertFatal(time_domain_assignmentbwp_Common->pusch_ConfigCommon->choice.setup->pusch_TimeDomainAllocationList->list.count,
"time_domain_assignment %d>=%d\n",time_domain_assignment,ubwp->bwp_Common->pusch_ConfigCommon->choice.setup->pusch_TimeDomainAllocationList->list.count);
- int K2;
- if (ubwp->bwp_Common->pusch_ConfigCommon->choice.setup->pusch_TimeDomainAllocationList->list.array[time_domain_assignment]->k2 != NULL)
- K2 = *ubwp->bwp_Common->pusch_ConfigCommon->choice.setup->pusch_TimeDomainAllocationList->list.array[time_domain_assignment]->k2;
- else {
- if (mu<2) K2=1;
- else if(mu==2) K2=2;
- else K2=3;
- }
-
- if (is_xlsch_in_slot(UE_list->UE_sched_ctrl[UE_id].ulsch_in_slot_bitmap,(slotP+K2)%num_slots_per_tdd)) {
-
- //nfapi_nr_ul_tti_request_t *UL_tti_req = &RC.nrmac[Mod_idP]->UL_tti_req[0];
+ int K2 = get_K2(ubwp, time_domain_assignment,mu);
+ /* check if slot is UL, and for phy test verify that it is in first TDD
+ * period, slot 8 (for K2=2, this is at slot 6 in the gNB; because of UE
+ * limitations). Note that if K2 or the TDD configuration is changed, below
+ * conditions might exclude each other and never be true */
+ const int slot_idx = (slotP + K2) % num_slots_per_tdd;
+ if (is_xlsch_in_slot(ulsch_in_slot_bitmap, slot_idx)
+ && (!get_softmodem_params()->phy_test || slot_idx == 8)) {
nfapi_nr_ul_dci_request_t *UL_dci_req = &RC.nrmac[Mod_idP]->UL_dci_req[0];
UL_dci_req->SFN = frameP;
UL_dci_req->Slot = slotP;
@@ -850,10 +874,10 @@ void schedule_fapi_ul_pdu(int Mod_idP,
AssertFatal(bwp->bwp_Dedicated->pdcch_Config->choice.setup->searchSpacesToAddModList->list.count>0,
"searchPsacesToAddModList is empty\n");
- uint16_t rnti = UE_list->rnti[UE_id];
+ uint16_t rnti = UE_info->rnti[UE_id];
int first_ul_slot = num_slots_per_tdd - ul_slots;
- NR_sched_pusch *pusch_sched = &UE_list->UE_sched_ctrl[UE_id].sched_pusch[slotP+K2-first_ul_slot];
+ NR_sched_pusch *pusch_sched = &UE_info->UE_sched_ctrl[UE_id].sched_pusch[slotP+K2-first_ul_slot];
pusch_sched->frame = frameP;
pusch_sched->slot = slotP + K2;
pusch_sched->active = true;
@@ -952,7 +976,7 @@ void schedule_fapi_ul_pdu(int Mod_idP,
if (get_softmodem_params()->phy_test==1)
pusch_pdu->rb_size = 50;
else
- pusch_pdu->rb_size = 5;
+ pusch_pdu->rb_size = pusch_pdu->bwp_size;
}
else
AssertFatal(1==0,"Only frequency resource allocation type 1 is currently supported\n");
@@ -1045,9 +1069,9 @@ void schedule_fapi_ul_pdu(int Mod_idP,
//Pusch Allocation in frequency domain [TS38.214, sec 6.1.2.2]
//Optional Data only included if indicated in pduBitmap
- int8_t harq_id = select_ul_harq_pid(&UE_list->UE_sched_ctrl[UE_id]);
+ int8_t harq_id = select_ul_harq_pid(&UE_info->UE_sched_ctrl[UE_id]);
if (harq_id < 0) return;
- NR_UE_ul_harq_t *cur_harq = &UE_list->UE_sched_ctrl[UE_id].ul_harq_processes[harq_id];
+ NR_UE_ul_harq_t *cur_harq = &UE_info->UE_sched_ctrl[UE_id].ul_harq_processes[harq_id];
pusch_pdu->pusch_data.harq_process_id = harq_id;
pusch_pdu->pusch_data.new_data_indicator = cur_harq->ndi;
pusch_pdu->pusch_data.rv_index = nr_rv_round_map[cur_harq->round];
@@ -1077,8 +1101,8 @@ void schedule_fapi_ul_pdu(int Mod_idP,
0,
pusch_pdu->nrOfLayers)>>3;
- UE_list->mac_stats[UE_id].ulsch_rounds[cur_harq->round]++;
- if (cur_harq->round == 0) UE_list->mac_stats[UE_id].ulsch_total_bytes_scheduled+=pusch_pdu->pusch_data.tb_size;
+ 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+=pusch_pdu->pusch_data.tb_size;
pusch_pdu->pusch_data.num_cb = 0; //CBG not supported
//pusch_pdu->pusch_data.cb_present_and_position;
@@ -1099,22 +1123,34 @@ void schedule_fapi_ul_pdu(int Mod_idP,
LOG_D(MAC,"Configuring ULDCI/PDCCH in %d.%d\n", frameP,slotP);
- int ret = nr_configure_pdcch(nr_mac,
- pdcch_pdu_rel15,
- UE_list->rnti[UE_id],
- 1, // ue-specific,
- ss,
- scc,
- bwp);
-
- if (ret < 0) {
- LOG_I(MAC,"CCE list not empty, couldn't schedule PUSCH\n");
+ uint8_t nr_of_candidates, aggregation_level;
+ find_aggregation_candidates(&aggregation_level, &nr_of_candidates, ss);
+ NR_ControlResourceSet_t *coreset = get_coreset(bwp, ss, 1 /* dedicated */);
+ int CCEIndex = allocate_nr_CCEs(
+ nr_mac,
+ bwp,
+ coreset,
+ aggregation_level,
+ UE_info->rnti[UE_id],
+ 0); // m
+ if (CCEIndex < 0) {
+ LOG_E(MAC, "%s(): CCE list not empty, couldn't schedule PUSCH\n", __func__);
pusch_sched->active = false;
return;
}
else {
+ nr_configure_pdcch(nr_mac,
+ pdcch_pdu_rel15,
+ UE_info->rnti[UE_id],
+ ss,
+ coreset,
+ scc,
+ bwp,
+ aggregation_level,
+ CCEIndex);
+
dci_pdu_rel15_t *dci_pdu_rel15 = calloc(MAX_DCI_CORESET,sizeof(dci_pdu_rel15_t));
- config_uldci(ubwp,pusch_pdu,pdcch_pdu_rel15,&dci_pdu_rel15[0],dci_formats,rnti_types,time_domain_assignment,UE_list->UE_sched_ctrl[UE_id].tpc0,n_ubwp,bwp_id);
+ config_uldci(ubwp,pusch_pdu,pdcch_pdu_rel15,&dci_pdu_rel15[0],dci_formats,rnti_types,time_domain_assignment,UE_info->UE_sched_ctrl[UE_id].tpc0,n_ubwp,bwp_id);
fill_dci_pdu_rel15(scc,secondaryCellGroup,pdcch_pdu_rel15,dci_pdu_rel15,dci_formats,rnti_types,pusch_pdu->bwp_size,bwp_id);
free(dci_pdu_rel15);
}
diff --git a/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_primitives.c b/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_primitives.c
index 1810b63f25..a0f4e6ad6c 100644
--- a/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_primitives.c
+++ b/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_primitives.c
@@ -63,7 +63,6 @@
#define ENABLE_MAC_PAYLOAD_DEBUG
#define DEBUG_gNB_SCHEDULER 1
-
#include "common/ran_context.h"
extern RAN_CONTEXT_t RC;
@@ -127,37 +126,60 @@ static inline uint8_t get_max_cces(uint8_t scs) {
return (nr_max_number_of_cces_per_slot[scs]);
}
+NR_ControlResourceSet_t *get_coreset(NR_BWP_Downlink_t *bwp,
+ NR_SearchSpace_t *ss,
+ int ss_type) {
+ NR_ControlResourceSetId_t coreset_id = *ss->controlResourceSetId;
+ if (ss_type == 0) { // common search space
+ AssertFatal(coreset_id != 0, "coreset0 currently not supported\n");
+ NR_ControlResourceSet_t *coreset = bwp->bwp_Common->pdcch_ConfigCommon->choice.setup->commonControlResourceSet;
+ AssertFatal(coreset_id == coreset->controlResourceSetId,
+ "ID of common ss coreset does not correspond to id set in the "
+ "search space\n");
+ return coreset;
+ } else {
+ const int n = bwp->bwp_Dedicated->pdcch_Config->choice.setup->controlResourceSetToAddModList->list.count;
+ for (int i = 0; i < n; i++) {
+ NR_ControlResourceSet_t *coreset =
+ bwp->bwp_Dedicated->pdcch_Config->choice.setup->controlResourceSetToAddModList->list.array[i];
+ if (coreset_id == coreset->controlResourceSetId) {
+ return coreset;
+ }
+ }
+ AssertFatal(0, "Couldn't find coreset with id %ld\n", coreset_id);
+ }
+}
+
+NR_SearchSpace_t *get_searchspace(
+ NR_BWP_Downlink_t *bwp,
+ NR_SearchSpace__searchSpaceType_PR target_ss) {
+ DevAssert(bwp->bwp_Dedicated->pdcch_Config->choice.setup->searchSpacesToAddModList);
+ DevAssert(bwp->bwp_Dedicated->pdcch_Config->choice.setup->searchSpacesToAddModList->list.count > 0);
+
+ const int n = bwp->bwp_Dedicated->pdcch_Config->choice.setup->searchSpacesToAddModList->list.count;
+ for (int i=0;ibwp_Dedicated->pdcch_Config->choice.setup->searchSpacesToAddModList->list.array[i];
+ AssertFatal(ss->controlResourceSetId != NULL, "ss->controlResourceSetId is null\n");
+ AssertFatal(ss->searchSpaceType != NULL, "ss->searchSpaceType is null\n");
+ if (ss->searchSpaceType->present == target_ss) {
+ return ss;
+ }
+ }
+ AssertFatal(0, "Couldn't find an adequate searchspace\n");
+}
+
int allocate_nr_CCEs(gNB_MAC_INST *nr_mac,
- int bwp_id,
- int list_id,
- int aggregation,
- int search_space, // 0 common, 1 ue-specific
- int UE_id,
- int m) {
+ NR_BWP_Downlink_t *bwp,
+ NR_ControlResourceSet_t *coreset,
+ int aggregation,
+ uint16_t n_RNTI,
+ int m) {
// uncomment these when we allocate for common search space
// NR_COMMON_channels_t *cc = nr_mac->common_channels;
// NR_ServingCellConfigCommon_t *scc = cc->ServingCellConfigCommon;
- NR_UE_list_t *UE_list = &nr_mac->UE_list;
-
- NR_BWP_Downlink_t *bwp;
- NR_CellGroupConfig_t *secondaryCellGroup;
-
- NR_ControlResourceSet_t *coreset;
-
- AssertFatal(UE_list->active[UE_id] >=0,"UE_id %d is not active\n",UE_id);
- secondaryCellGroup = UE_list->secondaryCellGroup[UE_id];
- bwp=secondaryCellGroup->spCellConfig->spCellConfigDedicated->downlinkBWP_ToAddModList->list.array[bwp_id-1];
-
- if (search_space == 1) {
- coreset = bwp->bwp_Dedicated->pdcch_Config->choice.setup->controlResourceSetToAddModList->list.array[list_id];
- }
- else {
- coreset = bwp->bwp_Common->pdcch_ConfigCommon->choice.setup->commonControlResourceSet;
- }
-
int coreset_id = coreset->controlResourceSetId;
- int *cce_list = nr_mac->cce_list[bwp_id][coreset_id];
+ int *cce_list = nr_mac->cce_list[bwp->bwp_Id][coreset_id];
int n_rb=0;
for (int i=0;i<6;i++)
@@ -167,17 +189,14 @@ int allocate_nr_CCEs(gNB_MAC_INST *nr_mac,
n_rb*=6;
uint16_t N_reg = n_rb * coreset->duration;
- uint16_t Y=0, N_cce, M_s_max, n_CI=0;
- uint16_t n_RNTI = search_space == 1 ? UE_list->rnti[UE_id]:0;
- uint32_t A[3]={39827,39829,39839};
+ uint16_t n_CI=0;
+ const uint32_t A[3]={39827,39829,39839};
+ /* if n_RNTI is zero, this results in zero, too! */
+ uint16_t Y = (A[0]*n_RNTI)%65537; // Candidate 0, antenna port 0
- N_cce = N_reg / NR_NB_REG_PER_CCE;
+ uint16_t N_cce = N_reg / NR_NB_REG_PER_CCE;
- M_s_max = (aggregation==4)?4:(aggregation==8)?2:1;
-
- if (search_space == 1) {
- Y = (A[0]*n_RNTI)%65537; // Candidate 0, antenna port 0
- }
+ uint16_t M_s_max = (aggregation==4)?4:(aggregation==8)?2:1;
int first_cce = aggregation * (( Y + (m*N_cce)/(aggregation*M_s_max) + n_CI ) % CEILIDIV(N_cce,aggregation));
for (int i=0;icommon_channels;
+ NR_ServingCellConfigCommon_t *scc = cc->ServingCellConfigCommon;
- int CCEIndex = -1;
- int cid = 0;
- NR_ControlResourceSet_t *coreset = NULL;
+ NR_UE_info_t *UE_info = &RC.nrmac[Mod_idP]->UE_info;
+ NR_CellGroupConfig_t *secondaryCellGroup = UE_info->secondaryCellGroup[UE_id];
+ AssertFatal(secondaryCellGroup->spCellConfig->spCellConfigDedicated->downlinkBWP_ToAddModList->list.count == 1,
+ "downlinkBWP_ToAddModList has %d BWP!\n",
+ secondaryCellGroup->spCellConfig->spCellConfigDedicated->downlinkBWP_ToAddModList->list.count);
+ NR_BWP_Downlink_t *bwp=secondaryCellGroup->spCellConfig->spCellConfigDedicated->downlinkBWP_ToAddModList->list.array[bwp_id-1];
+
+ AssertFatal(bwp->bwp_Dedicated->pdcch_Config->choice.setup->searchSpacesToAddModList!=NULL,"searchPsacesToAddModList is null\n");
+ AssertFatal(bwp->bwp_Dedicated->pdcch_Config->choice.setup->searchSpacesToAddModList->list.count>0,
+ "searchPsacesToAddModList is empty\n");
+
+ nfapi_nr_dl_tti_request_pdu_t *dl_tti_pdcch_pdu = &dl_req->dl_tti_pdu_list[dl_req->nPDUs];
+ memset((void*)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;
+ dl_tti_pdcch_pdu->PDUSize = (uint8_t)(2+sizeof(nfapi_nr_dl_tti_pdcch_pdu));
+
+ nfapi_nr_dl_tti_request_pdu_t *dl_tti_pdsch_pdu = &dl_req->dl_tti_pdu_list[dl_req->nPDUs+1];
+ memset((void*)dl_tti_pdsch_pdu,0,sizeof(nfapi_nr_dl_tti_request_pdu_t));
+ dl_tti_pdsch_pdu->PDUType = NFAPI_NR_DL_TTI_PDSCH_PDU_TYPE;
+ dl_tti_pdsch_pdu->PDUSize = (uint8_t)(2+sizeof(nfapi_nr_dl_tti_pdsch_pdu));
+
+ nfapi_nr_dl_tti_pdcch_pdu_rel15_t *pdcch_pdu_rel15 = &dl_tti_pdcch_pdu->pdcch_pdu.pdcch_pdu_rel15;
+ nfapi_nr_dl_tti_pdsch_pdu_rel15_t *pdsch_pdu_rel15 = &dl_tti_pdsch_pdu->pdsch_pdu.pdsch_pdu_rel15;
+
+
+ pdsch_pdu_rel15->pduBitmap = 0;
+ pdsch_pdu_rel15->rnti = UE_info->rnti[UE_id];
+ pdsch_pdu_rel15->pduIndex = nr_mac->pdu_index[0]++;
+
+ // BWP
+ pdsch_pdu_rel15->BWPSize = NRRIV2BW(bwp->bwp_Common->genericParameters.locationAndBandwidth,275);
+ pdsch_pdu_rel15->BWPStart = NRRIV2PRBOFFSET(bwp->bwp_Common->genericParameters.locationAndBandwidth,275);
+ pdsch_pdu_rel15->SubcarrierSpacing = bwp->bwp_Common->genericParameters.subcarrierSpacing;
+ if (bwp->bwp_Common->genericParameters.cyclicPrefix)
+ pdsch_pdu_rel15->CyclicPrefix = *bwp->bwp_Common->genericParameters.cyclicPrefix;
+ else
+ pdsch_pdu_rel15->CyclicPrefix = 0;
+
+ pdsch_pdu_rel15->NrOfCodewords = 1;
+ pdsch_pdu_rel15->targetCodeRate[0] = nr_get_code_rate_dl(mcs,0);
+ pdsch_pdu_rel15->qamModOrder[0] = 2;
+ pdsch_pdu_rel15->mcsIndex[0] = mcs;
+ pdsch_pdu_rel15->mcsTable[0] = 0;
+ pdsch_pdu_rel15->rvIndex[0] = nr_rv_round_map[round];
+ pdsch_pdu_rel15->dataScramblingId = *scc->physCellId;
+ pdsch_pdu_rel15->nrOfLayers = nrOfLayers;
+ pdsch_pdu_rel15->transmissionScheme = 0;
+ pdsch_pdu_rel15->refPoint = 0; // Point A
+ pdsch_pdu_rel15->dmrsConfigType = dmrsConfigType;
+ pdsch_pdu_rel15->dlDmrsScramblingId = *scc->physCellId;
+ pdsch_pdu_rel15->SCID = 0;
+ pdsch_pdu_rel15->numDmrsCdmGrpsNoData = numDmrsCdmGrpsNoData;
+ pdsch_pdu_rel15->dmrsPorts = 1;
+ pdsch_pdu_rel15->resourceAlloc = 1;
+ pdsch_pdu_rel15->rbStart = rbStart;
+ pdsch_pdu_rel15->rbSize = rbSize;
+ pdsch_pdu_rel15->VRBtoPRBMapping = 1; // non-interleaved, check if this is ok for initialBWP
+ pdsch_pdu_rel15->targetCodeRate[0] = R;
+ pdsch_pdu_rel15->qamModOrder[0] = Qm;
+ pdsch_pdu_rel15->TBSize[0] = TBS;
+ pdsch_pdu_rel15->mcsTable[0] = table_idx;
+ pdsch_pdu_rel15->StartSymbolIndex = StartSymbolIndex;
+ pdsch_pdu_rel15->NrOfSymbols = NrOfSymbols;
+
+ // k0 = *bwp->bwp_Common->pdsch_ConfigCommon->choice.setup->pdsch_TimeDomainAllocationList->list.array[i]->k0;
+ pdsch_pdu_rel15->dlDmrsSymbPos =
+ fill_dmrs_mask(bwp->bwp_Dedicated->pdsch_Config->choice.setup,
+ scc->dmrs_TypeA_Position,
+ pdsch_pdu_rel15->NrOfSymbols);
+
+ dci_pdu_rel15_t dci_pdu_rel15[MAX_DCI_CORESET];
+ memset(dci_pdu_rel15, 0, sizeof(dci_pdu_rel15_t) * MAX_DCI_CORESET);
+
+ // bwp indicator
+ int n_dl_bwp = secondaryCellGroup->spCellConfig->spCellConfigDedicated->downlinkBWP_ToAddModList->list.count;
+ if (n_dl_bwp < 4)
+ dci_pdu_rel15[0].bwp_indicator.val = bwp_id;
+ else
+ dci_pdu_rel15[0].bwp_indicator.val = bwp_id - 1; // as per table 7.3.1.1.2-1 in 38.212
+ // frequency domain assignment
+ if (bwp->bwp_Dedicated->pdsch_Config->choice.setup->resourceAllocation==NR_PDSCH_Config__resourceAllocation_resourceAllocationType1)
+ dci_pdu_rel15[0].frequency_domain_assignment.val =
+ PRBalloc_to_locationandbandwidth0(
+ pdsch_pdu_rel15->rbSize,
+ pdsch_pdu_rel15->rbStart,
+ NRRIV2BW(bwp->bwp_Common->genericParameters.locationAndBandwidth,
+ 275));
+ else
+ AssertFatal(1==0,"Only frequency resource allocation type 1 is currently supported\n");
+ // time domain assignment
+ dci_pdu_rel15[0].time_domain_assignment.val = time_domain_assignment; // row index used here instead of SLIV;
+ // mcs and rv
+ dci_pdu_rel15[0].mcs = mcs;
+ dci_pdu_rel15[0].rv = pdsch_pdu_rel15->rvIndex[0];
+ // harq pid and ndi
+ dci_pdu_rel15[0].harq_pid = harq_pid;
+ dci_pdu_rel15[0].ndi = ndi;
+ // DAI
+ dci_pdu_rel15[0].dai[0].val = (pucch_sched->dai_c-1)&3;
+
+ // TPC for PUCCH
+ dci_pdu_rel15[0].tpc = UE_info->UE_sched_ctrl[UE_id].tpc1; // table 7.2.1-1 in 38.213
+ // PUCCH resource indicator
+ dci_pdu_rel15[0].pucch_resource_indicator = pucch_sched->resource_indicator;
+ // PDSCH to HARQ TI
+ dci_pdu_rel15[0].pdsch_to_harq_feedback_timing_indicator.val = pucch_sched->timing_indicator;
+ // antenna ports
+ dci_pdu_rel15[0].antenna_ports.val = 0; // nb of cdm groups w/o data 1 and dmrs port 0
+ // dmrs sequence initialization
+ dci_pdu_rel15[0].dmrs_sequence_initialization.val = pdsch_pdu_rel15->SCID;
+ LOG_D(MAC,
+ "[gNB scheduler phytest] DCI type 1 payload: freq_alloc %d (%d,%d,%d), "
+ "time_alloc %d, vrb to prb %d, mcs %d tb_scaling %d ndi %d rv %d\n",
+ dci_pdu_rel15[0].frequency_domain_assignment.val,
+ pdsch_pdu_rel15->rbStart,
+ pdsch_pdu_rel15->rbSize,
+ NRRIV2BW(bwp->bwp_Common->genericParameters.locationAndBandwidth, 275),
+ dci_pdu_rel15[0].time_domain_assignment.val,
+ dci_pdu_rel15[0].vrb_to_prb_mapping.val,
+ dci_pdu_rel15[0].mcs,
+ dci_pdu_rel15[0].tb_scaling,
+ dci_pdu_rel15[0].ndi,
+ dci_pdu_rel15[0].rv);
+
+ nr_configure_pdcch(nr_mac,
+ pdcch_pdu_rel15,
+ UE_info->rnti[UE_id],
+ ss,
+ coreset,
+ scc,
+ bwp,
+ aggregation_level,
+ CCEIndex);
+
+ int dci_formats[2];
+ int rnti_types[2];
+
+ if (ss->searchSpaceType->choice.ue_Specific->dci_Formats)
+ dci_formats[0] = NR_DL_DCI_FORMAT_1_1;
+ else
+ dci_formats[0] = NR_DL_DCI_FORMAT_1_0;
+
+ rnti_types[0] = NR_RNTI_C;
+
+ fill_dci_pdu_rel15(scc,secondaryCellGroup,pdcch_pdu_rel15,dci_pdu_rel15,dci_formats,rnti_types,pdsch_pdu_rel15->BWPSize,bwp_id);
+
+ LOG_D(MAC,
+ "DCI params: rnti %x, rnti_type %d, dci_format %d\n",
+ pdcch_pdu_rel15->dci_pdu.RNTI[0],
+ rnti_types[0],
+ dci_formats[0]);
+ LOG_D(MAC,
+ "coreset params: FreqDomainResource %llx, start_symbol %d n_symb %d\n",
+ (unsigned long long)pdcch_pdu_rel15->FreqDomainResource,
+ pdcch_pdu_rel15->StartSymbolIndex,
+ pdcch_pdu_rel15->DurationSymbols);
+
+ // I don't know why the following is not needed, but in this case we don't
+ // need additional calculations:
+ //const uint16_t N_RE_prime = NR_NB_SC_PER_RB * N_sh_symb - N_PRB_DMRS - N_PRB_oh;
+ //LOG_D(MAC,
+ // "N_RE_prime %d for %d symbols %d DMRS per PRB and %d overhead\n",
+ // N_RE_prime,
+ // N_sh_symb,
+ // N_PRB_DMRS,
+ // N_PRB_oh);
+ //pdsch_pdu_rel15->nb_mod_symbols = N_RE_prime*pdsch_pdu_rel15->n_prb*pdsch_pdu_rel15->nb_codewords;
+
+ LOG_D(MAC,
+ "DLSCH PDU: start PRB %d n_PRB %d start symbol %d nb_symbols %d "
+ "nb_layers %d nb_codewords %d mcs %d TBS: %d\n",
+ pdsch_pdu_rel15->rbStart,
+ pdsch_pdu_rel15->rbSize,
+ pdsch_pdu_rel15->StartSymbolIndex,
+ pdsch_pdu_rel15->NrOfSymbols,
+ pdsch_pdu_rel15->nrOfLayers,
+ pdsch_pdu_rel15->NrOfCodewords,
+ pdsch_pdu_rel15->mcsIndex[0],
+ TBS);
+
+ dl_req->nPDUs += 2;
+}
+
+void nr_configure_pdcch(gNB_MAC_INST *nr_mac,
+ nfapi_nr_dl_tti_pdcch_pdu_rel15_t *pdcch_pdu,
+ uint16_t rnti,
+ NR_SearchSpace_t *ss,
+ NR_ControlResourceSet_t *coreset,
+ NR_ServingCellConfigCommon_t *scc,
+ NR_BWP_Downlink_t *bwp,
+ uint8_t aggregation_level,
+ int CCEIndex) {
if (bwp) { // This is not the InitialBWP
- NR_ControlResourceSet_t *temp_coreset;
- NR_ControlResourceSetId_t coresetid = *ss->controlResourceSetId;
- if (ss_type == 0) { // common search space
- if (coresetid == 0){
- AssertFatal(1==0,"coreset0 currently not supported\n");
- }
- else {
- coreset = bwp->bwp_Common->pdcch_ConfigCommon->choice.setup->commonControlResourceSet;
- AssertFatal(coresetid==coreset->controlResourceSetId,"ID of common ss coreset does not correspond to id set in the search space\n");
- }
- }
- else {
- int n_list = bwp->bwp_Dedicated->pdcch_Config->choice.setup->controlResourceSetToAddModList->list.count;
- for (int i=0; ibwp_Dedicated->pdcch_Config->choice.setup->controlResourceSetToAddModList->list.array[i];
- if (coresetid==temp_coreset->controlResourceSetId) {
- coreset = temp_coreset;
- cid = i;
- break;
- }
- }
- if(coreset==NULL)
- AssertFatal(1==0,"Couldn't find coreset with id %ld\n",coresetid);
- }
-
pdcch_pdu->BWPSize = NRRIV2BW(bwp->bwp_Common->genericParameters.locationAndBandwidth,275);
pdcch_pdu->BWPStart = NRRIV2PRBOFFSET(bwp->bwp_Common->genericParameters.locationAndBandwidth,275);
pdcch_pdu->SubcarrierSpacing = bwp->bwp_Common->genericParameters.subcarrierSpacing;
@@ -507,22 +711,6 @@ int nr_configure_pdcch(gNB_MAC_INST *nr_mac,
pdcch_pdu->dci_pdu.ScramblingRNTI[pdcch_pdu->numDlDci]=0;
}
- uint8_t nr_of_candidates,aggregation_level;
- find_aggregation_candidates(&aggregation_level,
- &nr_of_candidates,
- ss);
-
- CCEIndex = allocate_nr_CCEs(nr_mac,
- 1, // bwp_id
- cid,
- aggregation_level,
- ss->searchSpaceType->present-1, // search_space, 0 common, 1 ue-specific
- 0, // UE-id
- 0); // m
-
- if (CCEIndex<0)
- return (CCEIndex);
-
pdcch_pdu->dci_pdu.AggregationLevel[pdcch_pdu->numDlDci] = aggregation_level;
pdcch_pdu->dci_pdu.CceIndex[pdcch_pdu->numDlDci] = CCEIndex;
@@ -531,7 +719,6 @@ int nr_configure_pdcch(gNB_MAC_INST *nr_mac,
pdcch_pdu->dci_pdu.powerControlOffsetSS[pdcch_pdu->numDlDci]=1;
pdcch_pdu->numDlDci++;
- return (0);
}
else { // this is for InitialBWP
AssertFatal(1==0,"Fill in InitialBWP PDCCH configuration\n");
@@ -1396,39 +1583,34 @@ int extract_length(int startSymbolAndLength) {
}
/*
- * Dump the UL or DL UE_list into LOG_T(MAC)
+ * Dump the UL or DL UE_info into LOG_T(MAC)
*/
-void
-dump_nr_ue_list(NR_UE_list_t *listP,
- int ul_flag)
-//------------------------------------------------------------------------------
-{
- if (ul_flag == 0) {
- for (int j = listP->head; j >= 0; j = listP->next[j]) {
- LOG_T(MAC, "DL list node %d => %d\n",
- j,
- listP->next[j]);
- }
- } else {
- for (int j = listP->head_ul; j >= 0; j = listP->next_ul[j]) {
- LOG_T(MAC, "UL list node %d => %d\n",
- j,
- listP->next_ul[j]);
- }
- }
+void dump_nr_ue_list(NR_UE_list_t *listP) {
+ for (int j = listP->head; j >= 0; j = listP->next[j])
+ LOG_T(MAC, "DL list node %d => %d\n", j, listP->next[j]);
+}
- return;
+/*
+ * Add a UE to NR_UE_list listP
+ */
+inline void add_nr_ue_list(NR_UE_list_t *listP, int UE_id) {
+ int *cur = &listP->head;
+ while (*cur >= 0) {
+ AssertFatal(*cur != UE_id, "UE_id %d already in NR_UE_list!\n", UE_id);
+ cur = &listP->next[*cur];
+ }
+ *cur = UE_id;
}
int find_nr_UE_id(module_id_t mod_idP, rnti_t rntiP)
//------------------------------------------------------------------------------
{
int UE_id;
- NR_UE_list_t *UE_list = &RC.nrmac[mod_idP]->UE_list;
+ NR_UE_info_t *UE_info = &RC.nrmac[mod_idP]->UE_info;
for (UE_id = 0; UE_id < MAX_MOBILES_PER_GNB; UE_id++) {
- if (UE_list->active[UE_id] == TRUE) {
- if (UE_list->rnti[UE_id] == rntiP) {
+ if (UE_info->active[UE_id]) {
+ if (UE_info->rnti[UE_id] == rntiP) {
return UE_id;
}
}
@@ -1439,42 +1621,40 @@ int find_nr_UE_id(module_id_t mod_idP, rnti_t rntiP)
int add_new_nr_ue(module_id_t mod_idP, rnti_t rntiP){
- int UE_id;
- int i;
- NR_UE_list_t *UE_list = &RC.nrmac[mod_idP]->UE_list;
+ NR_UE_info_t *UE_info = &RC.nrmac[mod_idP]->UE_info;
NR_COMMON_channels_t *cc = RC.nrmac[mod_idP]->common_channels;
NR_ServingCellConfigCommon_t *scc = cc->ServingCellConfigCommon;
int num_slots_ul = scc->tdd_UL_DL_ConfigurationCommon->pattern1.nrofUplinkSlots;
if (scc->tdd_UL_DL_ConfigurationCommon->pattern1.nrofUplinkSymbols>0)
num_slots_ul++;
- LOG_I(MAC, "[gNB %d] Adding UE with rnti %x (next avail %d, num_UEs %d)\n",
+ LOG_W(MAC, "[gNB %d] Adding UE with rnti %x (num_UEs %d)\n",
mod_idP,
rntiP,
- UE_list->avail,
- UE_list->num_UEs);
- dump_nr_ue_list(UE_list, 0);
+ UE_info->num_UEs);
+ dump_nr_ue_list(&UE_info->list);
- for (i = 0; i < MAX_MOBILES_PER_GNB; i++) {
- if (UE_list->active[i] == TRUE)
+ for (int i = 0; i < MAX_MOBILES_PER_GNB; i++) {
+ if (UE_info->active[i])
continue;
- UE_id = i;
- UE_list->num_UEs++;
- UE_list->active[UE_id] = TRUE;
- UE_list->rnti[UE_id] = rntiP;
- memset((void *) &UE_list->UE_sched_ctrl[UE_id],
+ int UE_id = i;
+ UE_info->num_UEs++;
+ UE_info->active[UE_id] = true;
+ UE_info->rnti[UE_id] = rntiP;
+ add_nr_ue_list(&UE_info->list, UE_id);
+ memset((void *) &UE_info->UE_sched_ctrl[UE_id],
0,
sizeof(NR_UE_sched_ctrl_t));
- UE_list->UE_sched_ctrl[UE_id].ta_timer = 100;
- UE_list->UE_sched_ctrl[UE_id].ta_update = 31;
- UE_list->UE_sched_ctrl[UE_id].ul_rssi = 0;
- UE_list->UE_sched_ctrl[UE_id].sched_pucch = (NR_sched_pucch *)malloc(num_slots_ul*sizeof(NR_sched_pucch));
- UE_list->UE_sched_ctrl[UE_id].sched_pusch = (NR_sched_pusch *)malloc(num_slots_ul*sizeof(NR_sched_pusch));
+ UE_info->UE_sched_ctrl[UE_id].ta_timer = 100;
+ UE_info->UE_sched_ctrl[UE_id].ta_update = 31;
+ UE_info->UE_sched_ctrl[UE_id].ul_rssi = 0;
+ UE_info->UE_sched_ctrl[UE_id].sched_pucch = (NR_sched_pucch *)malloc(num_slots_ul*sizeof(NR_sched_pucch));
+ UE_info->UE_sched_ctrl[UE_id].sched_pusch = (NR_sched_pusch *)malloc(num_slots_ul*sizeof(NR_sched_pusch));
for (int k=0; kUE_sched_ctrl[UE_id].sched_pucch[k],
+ memset((void *) &UE_info->UE_sched_ctrl[UE_id].sched_pucch[k],
0,
sizeof(NR_sched_pucch));
- memset((void *) &UE_list->UE_sched_ctrl[UE_id].sched_pusch[k],
+ memset((void *) &UE_info->UE_sched_ctrl[UE_id].sched_pusch[k],
0,
sizeof(NR_sched_pusch));
}
@@ -1482,15 +1662,13 @@ int add_new_nr_ue(module_id_t mod_idP, rnti_t rntiP){
mod_idP,
UE_id,
rntiP);
- dump_nr_ue_list(UE_list,
- 0);
+ dump_nr_ue_list(&UE_info->list);
return (UE_id);
}
// printf("MAC: cannot add new UE for rnti %x\n", rntiP);
- LOG_E(MAC, "error in add_new_ue(), could not find space in UE_list, Dumping UE list\n");
- dump_nr_ue_list(UE_list,
- 0);
+ LOG_E(MAC, "error in add_new_ue(), could not find space in UE_info, Dumping UE list\n");
+ dump_nr_ue_list(&UE_info->list);
return -1;
}
@@ -1503,23 +1681,22 @@ void mac_remove_nr_ue(module_id_t mod_id, rnti_t rnti)
{
int UE_id;
int i;
- NR_UE_list_t *UE_list = &RC.nrmac[mod_id]->UE_list;
+ NR_UE_info_t *UE_info = &RC.nrmac[mod_id]->UE_info;
for (i = 0; i < MAX_MOBILES_PER_GNB; i++) {
- if (UE_list->active[i] != TRUE)
+ if (UE_info->active[i] != TRUE)
continue;
- if (UE_list->rnti[i] != rnti)
+ if (UE_info->rnti[i] != rnti)
continue;
/* UE found, remove it */
UE_id = i;
- UE_list->num_UEs--;
- UE_list->fiveG_connected[UE_id] = FALSE;
- UE_list->active[UE_id] = FALSE;
- UE_list->rnti[UE_id] = 0;
- free(UE_list->UE_sched_ctrl[UE_id].sched_pucch);
- free(UE_list->UE_sched_ctrl[UE_id].sched_pusch);
- memset((void *) &UE_list->UE_sched_ctrl[UE_id],
+ UE_info->num_UEs--;
+ UE_info->active[UE_id] = FALSE;
+ UE_info->rnti[UE_id] = 0;
+ free(UE_info->UE_sched_ctrl[UE_id].sched_pucch);
+ free(UE_info->UE_sched_ctrl[UE_id].sched_pusch);
+ memset((void *) &UE_info->UE_sched_ctrl[UE_id],
0,
sizeof(NR_UE_sched_ctrl_t));
LOG_I(MAC, "[gNB %d] Remove NR UE_id %d : rnti %x\n",
@@ -1554,8 +1731,8 @@ void get_pdsch_to_harq_feedback(int Mod_idP,
uint8_t *pdsch_to_harq_feedback) {
int bwp_id=1;
- NR_UE_list_t *UE_list = &RC.nrmac[Mod_idP]->UE_list;
- NR_CellGroupConfig_t *secondaryCellGroup = UE_list->secondaryCellGroup[UE_id];
+ NR_UE_info_t *UE_info = &RC.nrmac[Mod_idP]->UE_info;
+ NR_CellGroupConfig_t *secondaryCellGroup = UE_info->secondaryCellGroup[UE_id];
NR_BWP_Downlink_t *bwp=secondaryCellGroup->spCellConfig->spCellConfigDedicated->downlinkBWP_ToAddModList->list.array[bwp_id-1];
NR_BWP_Uplink_t *ubwp=secondaryCellGroup->spCellConfig->spCellConfigDedicated->uplinkConfig->uplinkBWP_ToAddModList->list.array[bwp_id-1];
@@ -1607,7 +1784,7 @@ void nr_update_pucch_scheduling(int Mod_idP,
int *pucch_id) {
NR_ServingCellConfigCommon_t *scc = RC.nrmac[Mod_idP]->common_channels->ServingCellConfigCommon;
- NR_UE_list_t *UE_list = &RC.nrmac[Mod_idP]->UE_list;
+ NR_UE_info_t *UE_info = &RC.nrmac[Mod_idP]->UE_info;
NR_sched_pucch *curr_pucch;
int first_ul_slot_tdd,k,i;
uint8_t pdsch_to_harq_feedback[8];
@@ -1622,7 +1799,7 @@ void nr_update_pucch_scheduling(int Mod_idP,
// for each possible ul or mixed slot
for (k=0; kUE_sched_ctrl[UE_id].sched_pucch[k];
+ curr_pucch = &UE_info->UE_sched_ctrl[UE_id].sched_pucch[k];
// if there is free room in current pucch structure
if (curr_pucch->dai_cframe = frameP;
diff --git a/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_ulsch.c b/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_ulsch.c
index d66ec9c52f..a3dc3872c4 100644
--- a/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_ulsch.c
+++ b/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_ulsch.c
@@ -212,7 +212,7 @@ void nr_process_mac_pdu(
LOG_D(MAC, "[UE %d] Frame %d : ULSCH -> UL-DTCH %d (gNB %d, %d bytes)\n", module_idP, frameP, rx_lcid, module_idP, mac_sdu_len);
int UE_id = find_nr_UE_id(module_idP, rnti);
- RC.nrmac[module_idP]->UE_list.mac_stats[UE_id].lc_bytes_rx[rx_lcid] += mac_sdu_len;
+ RC.nrmac[module_idP]->UE_info.mac_stats[UE_id].lc_bytes_rx[rx_lcid] += mac_sdu_len;
#if defined(ENABLE_MAC_PAYLOAD_DEBUG)
LOG_T(MAC, "[UE %d] First 32 bytes of DLSCH : \n", module_idP);
@@ -313,19 +313,19 @@ void nr_rx_sdu(const module_id_t gnb_mod_idP,
const uint16_t rssi){
int current_rnti = 0, UE_id = -1, harq_pid = 0;
gNB_MAC_INST *gNB_mac = NULL;
- NR_UE_list_t *UE_list = NULL;
+ NR_UE_info_t *UE_info = NULL;
NR_UE_sched_ctrl_t *UE_scheduling_control = NULL;
current_rnti = rntiP;
UE_id = find_nr_UE_id(gnb_mod_idP, current_rnti);
gNB_mac = RC.nrmac[gnb_mod_idP];
- UE_list = &gNB_mac->UE_list;
+ UE_info = &gNB_mac->UE_info;
int target_snrx10 = gNB_mac->pusch_target_snrx10;
if (UE_id != -1) {
- UE_scheduling_control = &(UE_list->UE_sched_ctrl[UE_id]);
+ UE_scheduling_control = &(UE_info->UE_sched_ctrl[UE_id]);
- UE_list->mac_stats[UE_id].ulsch_total_bytes_rx += sdu_lenP;
+ UE_info->mac_stats[UE_id].ulsch_total_bytes_rx += sdu_lenP;
LOG_D(MAC, "[gNB %d][PUSCH %d] CC_id %d %d.%d Received ULSCH sdu from PHY (rnti %x, UE_id %d) ul_cqi %d\n",
gnb_mod_idP,
harq_pid,
@@ -366,20 +366,44 @@ void nr_rx_sdu(const module_id_t gnb_mod_idP,
}
}
- else {
+ else if (sduP != NULL) { // if the CRC passed
// random access pusch with TC-RNTI
- if (sduP != NULL) { // if the CRC passed
- for (int i = 0; i < MAX_MOBILES_PER_GNB; i++) {
- if (UE_list->active[i] == TRUE) {
- if (UE_list->tc_rnti[i] == current_rnti) {
- // for now the only thing we are doing is set the UE as 5G connected
- UE_list->fiveG_connected[i] = true;
- LOG_I(MAC, "[gNB %d][RAPROC] PUSCH with TC_RNTI %x received correctly and UE_id %d is now 5G connected\n",
- gnb_mod_idP, current_rnti, i);
- }
- }
- }
+ NR_RA_t *ra = &gNB_mac->common_channels[CC_idP].ra[0];
+ if (ra->state != WAIT_Msg3) {
+ LOG_E(MAC,
+ "expected RA state WAIT_Msg3/%d (but is %d) for RA-RNTI %04x\n",
+ WAIT_Msg3,
+ ra->state,
+ ra->rnti);
+ return;
}
+ if (ra->rnti != current_rnti) {
+ LOG_E(MAC,
+ "expected RA-RNTI %04x (C-RNTI %04x) to match current RNTI %04x\n",
+ ra->rnti,
+ ra->crnti,
+ current_rnti);
+ return;
+ }
+ free(ra->preambles.preamble_list);
+ ra->state = RA_IDLE;
+ LOG_I(MAC, "reset RA state information for RA-RNTI %04x\n", ra->rnti);
+ const int UE_id = add_new_nr_ue(gnb_mod_idP, ra->crnti);
+ UE_info->secondaryCellGroup[UE_id] = ra->secondaryCellGroup;
+ struct NR_ServingCellConfig__downlinkBWP_ToAddModList *bwpList =
+ ra->secondaryCellGroup->spCellConfig->spCellConfigDedicated->downlinkBWP_ToAddModList;
+ AssertFatal(bwpList->list.count == 1,
+ "downlinkBWP_ToAddModList has %d BWP!\n",
+ bwpList->list.count);
+ const int bwp_id = 1;
+ UE_info->UE_sched_ctrl[UE_id].active_bwp = bwpList->list.array[bwp_id - 1];
+ LOG_W(MAC,
+ "[gNB %d][RAPROC] PUSCH with TC_RNTI %x received correctly, "
+ "adding UE MAC Context UE_id %d/RNTI %04x\n",
+ gnb_mod_idP,
+ current_rnti,
+ UE_id,
+ ra->crnti);
}
}
diff --git a/openair2/LAYER2/NR_MAC_gNB/mac_proto.h b/openair2/LAYER2/NR_MAC_gNB/mac_proto.h
index d83d544755..726615b6e3 100644
--- a/openair2/LAYER2/NR_MAC_gNB/mac_proto.h
+++ b/openair2/LAYER2/NR_MAC_gNB/mac_proto.h
@@ -67,6 +67,7 @@ void gNB_dlsch_ulsch_scheduler(module_id_t module_idP,
frame_t frame_rxP, sub_frame_t slot_rxP);
int nr_generate_dlsch_pdu(module_id_t Mod_idP,
+ NR_UE_sched_ctrl_t *ue_sched_ctl,
unsigned char *sdus_payload,
unsigned char *mac_pdu,
unsigned char num_sdus,
@@ -76,7 +77,10 @@ int nr_generate_dlsch_pdu(module_id_t Mod_idP,
unsigned char *ue_cont_res_id,
unsigned short post_padding);
-void nr_schedule_ue_spec(module_id_t module_idP, frame_t frameP, sub_frame_t slotP);
+void nr_schedule_ue_spec(module_id_t module_id,
+ frame_t frame,
+ sub_frame_t slot,
+ int num_slots_per_tdd);
void schedule_nr_mib(module_id_t module_idP, frame_t frameP, sub_frame_t subframeP);
@@ -126,12 +130,38 @@ void nr_schedule_css_dlsch_phytest(module_id_t module_idP,
frame_t frameP,
sub_frame_t subframeP);
-int configure_fapi_dl_pdu(int Mod_id,
- nfapi_nr_dl_tti_request_body_t *dl_req,
- NR_sched_pucch *pucch_sched,
- uint8_t *mcsIndex,
- uint16_t *rbSize,
- uint16_t *rbStart);
+void nr_fill_nfapi_dl_pdu(int Mod_id,
+ int UE_id,
+ int bwp_id,
+ NR_SearchSpace_t *ss,
+ NR_ControlResourceSet_t *coreset,
+ nfapi_nr_dl_tti_request_body_t *dl_req,
+ NR_sched_pucch *pucch_sched,
+ int nrOfLayers,
+ uint8_t mcs,
+ uint16_t rbSize,
+ uint16_t rbStart,
+ uint8_t numDmrsCdmGrpsNoData,
+ nfapi_nr_dmrs_type_e dmrsConfigType,
+ uint8_t table_idx,
+ uint16_t R,
+ uint8_t Qm,
+ uint32_t tbs,
+ int time_domain_assignment,
+ int StartSymbolIndex,
+ int NrOfSymbols,
+ uint8_t aggregation_level,
+ int CCEIndex,
+ int harq_pid,
+ int ndi,
+ int round);
+
+int configure_fapi_dl_pdu_phytest(int Mod_id,
+ nfapi_nr_dl_tti_request_body_t *dl_req,
+ NR_sched_pucch *pucch_sched,
+ uint8_t *mcsIndex,
+ uint16_t *rbSize,
+ uint16_t *rbStart);
void config_uldci(NR_BWP_Uplink_t *ubwp,
nfapi_nr_pusch_pdu_t *pusch_pdu,
@@ -211,13 +241,15 @@ void find_search_space(int ss_type,
NR_BWP_Downlink_t *bwp,
NR_SearchSpace_t *ss);
-int nr_configure_pdcch(gNB_MAC_INST *nr_mac,
- nfapi_nr_dl_tti_pdcch_pdu_rel15_t* pdcch_pdu,
- uint16_t rnti,
- int ss_type,
- NR_SearchSpace_t *ss,
- NR_ServingCellConfigCommon_t *scc,
- NR_BWP_Downlink_t *bwp);
+void nr_configure_pdcch(gNB_MAC_INST *nr_mac,
+ nfapi_nr_dl_tti_pdcch_pdu_rel15_t *pdcch_pdu,
+ uint16_t rnti,
+ NR_SearchSpace_t *ss,
+ NR_ControlResourceSet_t *coreset,
+ NR_ServingCellConfigCommon_t *scc,
+ NR_BWP_Downlink_t *bwp,
+ uint8_t aggregation_level,
+ int CCEIndex);
void fill_dci_pdu_rel15(NR_ServingCellConfigCommon_t *scc,
NR_CellGroupConfig_t *secondaryCellGroup,
@@ -233,6 +265,16 @@ void prepare_dci(NR_CellGroupConfig_t *secondaryCellGroup,
nr_dci_format_t format,
int bwp_id);
+/* find coreset within the search space */
+NR_ControlResourceSet_t *get_coreset(NR_BWP_Downlink_t *bwp,
+ NR_SearchSpace_t *ss,
+ int ss_type);
+
+/* find a search space within a BWP */
+NR_SearchSpace_t *get_searchspace(
+ NR_BWP_Downlink_t *bwp,
+ NR_SearchSpace__searchSpaceType_PR target_ss);
+
void find_aggregation_candidates(uint8_t *aggregation_level,
uint8_t *nr_of_candidates,
NR_SearchSpace_t *ss);
@@ -259,7 +301,8 @@ int NRRIV2BW(int locationAndBandwidth,int N_RB);
int NRRIV2PRBOFFSET(int locationAndBandwidth,int N_RB);
-void dump_nr_ue_list(NR_UE_list_t *listP, int ul_flag);
+void dump_nr_ue_list(NR_UE_list_t *listP);
+void add_nr_ue_list(NR_UE_list_t *listP, int UE_id);
int find_nr_UE_id(module_id_t mod_idP, rnti_t rntiP);
@@ -268,13 +311,11 @@ int add_new_nr_ue(module_id_t mod_idP, rnti_t rntiP);
void mac_remove_nr_ue(module_id_t mod_id, rnti_t rnti);
int allocate_nr_CCEs(gNB_MAC_INST *nr_mac,
- int bwp_id,
- int coreset_id,
+ NR_BWP_Downlink_t *bwp,
+ NR_ControlResourceSet_t *coreset,
int aggregation,
- int search_space, // 0 common, 1 ue-specific
- int UE_id,
- int m
- );
+ uint16_t n_RNTI,
+ int m);
int get_dlscs(nfapi_nr_config_request_t *cfg);
@@ -307,7 +348,8 @@ void schedule_fapi_ul_pdu(int Mod_idP,
sub_frame_t slotP,
int num_slots_per_tdd,
int ul_slots,
- int time_domain_assignment);
+ int time_domain_assignment,
+ uint64_t ulsch_in_slot_bitmap);
void nr_process_mac_pdu(
module_id_t module_idP,
diff --git a/openair2/LAYER2/NR_MAC_gNB/main.c b/openair2/LAYER2/NR_MAC_gNB/main.c
index bd0be8c409..7df00f15f1 100644
--- a/openair2/LAYER2/NR_MAC_gNB/main.c
+++ b/openair2/LAYER2/NR_MAC_gNB/main.c
@@ -50,7 +50,7 @@ void mac_top_init_gNB(void)
{
module_id_t i;
int list_el;
- NR_UE_list_t *UE_list;
+ NR_UE_info_t *UE_info;
gNB_MAC_INST *nrmac;
LOG_I(MAC, "[MAIN] Init function start:nb_nr_macrlc_inst=%d\n",RC.nb_nr_macrlc_inst);
@@ -104,29 +104,21 @@ void mac_top_init_gNB(void)
nrmac = RC.nrmac[i];
nrmac->if_inst = NR_IF_Module_init(i);
- UE_list = &nrmac->UE_list;
- UE_list->num_UEs = 0;
- UE_list->head = -1;
- UE_list->head_ul = -1;
- UE_list->avail = 0;
-
- for (list_el = 0; list_el < MAX_MOBILES_PER_GNB - 1; list_el++) {
- UE_list->next[list_el] = list_el + 1;
- UE_list->next_ul[list_el] = list_el + 1;
- UE_list->active[list_el] = FALSE;
+ UE_info = &nrmac->UE_info;
+ UE_info->num_UEs = 0;
+ UE_info->list.head = -1;
+ for (list_el = 0; list_el < MAX_MOBILES_PER_GNB; list_el++) {
+ UE_info->list.next[list_el] = -1;
+ UE_info->active[list_el] = false;
for (int list_harq = 0; list_harq < NR_MAX_NB_HARQ_PROCESSES; list_harq++) {
- UE_list->UE_sched_ctrl[list_el].harq_processes[list_harq].round = 0;
- UE_list->UE_sched_ctrl[list_el].harq_processes[list_harq].ndi = 0;
- UE_list->UE_sched_ctrl[list_el].harq_processes[list_harq].is_waiting = 0;
- UE_list->UE_sched_ctrl[list_el].ul_harq_processes[list_harq].round = 0;
- UE_list->UE_sched_ctrl[list_el].ul_harq_processes[list_harq].ndi = 0;
- UE_list->UE_sched_ctrl[list_el].ul_harq_processes[list_harq].state = 0;
+ UE_info->UE_sched_ctrl[list_el].harq_processes[list_harq].round = 0;
+ UE_info->UE_sched_ctrl[list_el].harq_processes[list_harq].ndi = 0;
+ UE_info->UE_sched_ctrl[list_el].harq_processes[list_harq].is_waiting = 0;
+ UE_info->UE_sched_ctrl[list_el].ul_harq_processes[list_harq].round = 0;
+ UE_info->UE_sched_ctrl[list_el].ul_harq_processes[list_harq].ndi = 0;
+ UE_info->UE_sched_ctrl[list_el].ul_harq_processes[list_harq].state = 0;
}
}
-
- UE_list->next[list_el] = -1;
- UE_list->next_ul[list_el] = -1;
- UE_list->active[list_el] = FALSE;
}
srand48(0);
diff --git a/openair2/LAYER2/NR_MAC_gNB/nr_mac_gNB.h b/openair2/LAYER2/NR_MAC_gNB/nr_mac_gNB.h
index 04fb0c6995..0ed64a9621 100644
--- a/openair2/LAYER2/NR_MAC_gNB/nr_mac_gNB.h
+++ b/openair2/LAYER2/NR_MAC_gNB/nr_mac_gNB.h
@@ -83,6 +83,11 @@ typedef enum {
WAIT_Msg4_ACK = 4
} RA_gNB_state_t;
+typedef struct NR_preamble_ue {
+ uint8_t num_preambles;
+ uint8_t *preamble_list;
+} NR_preamble_ue_t;
+
/*! \brief gNB template for the Random access information */
typedef struct {
/// Flag to indicate this process is active
@@ -141,6 +146,12 @@ typedef struct {
int msg4_mcs;
/// RA search space
NR_SearchSpace_t *ra_ss;
+ /// secondaryCellGroup for UE in NSA that is to come
+ NR_CellGroupConfig_t *secondaryCellGroup;
+ /// Preambles for contention-free access
+ NR_preamble_ue_t preambles;
+ /// NSA: the UEs C-RNTI to use
+ rnti_t crnti;
} NR_RA_t;
/*! \brief gNB common channels */
@@ -172,9 +183,9 @@ typedef struct {
/// Template for RA computations
NR_RA_t ra[NR_NB_RA_PROC_MAX];
/// VRB map for common channels
- uint8_t vrb_map[100];
+ uint8_t vrb_map[275];
/// VRB map for common channels and retransmissions by PHICH
- uint8_t vrb_map_UL[100];
+ uint8_t vrb_map_UL[275];
/// number of subframe allocation pattern available for MBSFN sync area
uint8_t num_sf_allocation_pattern;
} NR_COMMON_channels_t;
@@ -268,6 +279,14 @@ typedef struct NR_UE_harq {
uint16_t feedback_slot;
} NR_UE_harq_t;
+typedef struct NR_UE_old_sched {
+ uint16_t rbSize;
+ int time_domain_allocation;
+ uint8_t mcsTableIdx;
+ uint8_t mcs;
+ uint8_t numDmrsCdmGrpsNoData;
+} NR_UE_ret_info_t;
+
typedef enum {
INACTIVE = 0,
ACTIVE_NOT_SCHED,
@@ -283,10 +302,39 @@ typedef struct NR_UE_ul_harq {
/*! \brief scheduling control information set through an API */
typedef struct {
- uint64_t dlsch_in_slot_bitmap; // static bitmap signaling which slot in a tdd period contains dlsch
- uint64_t ulsch_in_slot_bitmap; // static bitmap signaling which slot in a tdd period contains ulsch
+ /// total amount of data awaiting for this UE
+ uint32_t num_total_bytes;
+ /// per-LC status data
+ mac_rlc_status_resp_t rlc_status[MAX_NUM_LCID];
+
+ /// the currently active BWP in DL
+ NR_BWP_Downlink_t *active_bwp;
NR_sched_pucch *sched_pucch;
+ /// selected PUCCH index, if scheduled
+ int pucch_sched_idx;
NR_sched_pusch *sched_pusch;
+
+ /// CCE index and aggregation, should be coherent with cce_list
+ NR_SearchSpace_t *search_space;
+ NR_ControlResourceSet_t *coreset;
+ int cce_index;
+ uint8_t aggregation_level;
+
+ /// RB allocation within active BWP
+ uint16_t rbSize;
+ uint16_t rbStart;
+
+ // time-domain allocation for scheduled RBs
+ int time_domain_allocation;
+
+ /// MCS-related infos
+ uint8_t mcsTableIdx;
+ uint8_t mcs;
+ uint8_t numDmrsCdmGrpsNoData;
+
+ /// Retransmission-related information
+ NR_UE_ret_info_t retInfo[NR_MAX_NB_HARQ_PROCESSES];
+
uint16_t ta_timer;
int16_t ta_update;
bool ta_apply;
@@ -300,11 +348,6 @@ typedef struct {
NR_UE_mac_ce_ctrl_t UE_mac_ce_ctrl;// MAC CE related information
} NR_UE_sched_ctrl_t;
-typedef struct NR_preamble_ue {
- uint8_t num_preambles;
- uint8_t *preamble_list;
-} NR_preamble_ue;
-
typedef struct {
int lc_bytes_tx[64];
@@ -318,25 +361,26 @@ typedef struct {
int ulsch_total_bytes_rx;
} NR_mac_stats_t;
+
+/*! \brief UNR_E_list_t is a "list" of users within UE_info_t. Especial useful in
+ * the scheduler and to keep "classes" of users. */
+typedef struct {
+ int head;
+ int next[MAX_MOBILES_PER_GNB];
+} NR_UE_list_t;
+
/*! \brief UE list used by gNB to order UEs/CC for scheduling*/
typedef struct {
DLSCH_PDU DLSCH_pdu[4][MAX_MOBILES_PER_GNB];
/// scheduling control info
NR_UE_sched_ctrl_t UE_sched_ctrl[MAX_MOBILES_PER_GNB];
NR_mac_stats_t mac_stats[MAX_MOBILES_PER_GNB];
- int next[MAX_MOBILES_PER_GNB];
- int head;
- int next_ul[MAX_MOBILES_PER_GNB];
- int head_ul;
- int avail;
+ NR_UE_list_t list;
int num_UEs;
- boolean_t active[MAX_MOBILES_PER_GNB];
- boolean_t fiveG_connected[MAX_MOBILES_PER_GNB];
+ bool active[MAX_MOBILES_PER_GNB];
rnti_t rnti[MAX_MOBILES_PER_GNB];
- rnti_t tc_rnti[MAX_MOBILES_PER_GNB];
- NR_preamble_ue preambles[MAX_MOBILES_PER_GNB];
NR_CellGroupConfig_t *secondaryCellGroup[MAX_MOBILES_PER_GNB];
-} NR_UE_list_t;
+} NR_UE_info_t;
/*! \brief top level eNB MAC structure */
typedef struct gNB_MAC_INST_s {
@@ -370,7 +414,7 @@ typedef struct gNB_MAC_INST_s {
/// NFAPI DL PDU structure
nfapi_nr_tx_data_request_t TX_req[NFAPI_CC_MAX];
- NR_UE_list_t UE_list;
+ NR_UE_info_t UE_info;
/// UL handle
uint32_t ul_handle;
diff --git a/openair2/LAYER2/nr_pdcp/nr_pdcp_oai_api.c b/openair2/LAYER2/nr_pdcp/nr_pdcp_oai_api.c
index 29605029d6..38b81e7aff 100644
--- a/openair2/LAYER2/nr_pdcp/nr_pdcp_oai_api.c
+++ b/openair2/LAYER2/nr_pdcp/nr_pdcp_oai_api.c
@@ -431,9 +431,9 @@ static void deliver_sdu_drb(void *_ue, nr_pdcp_entity_t *entity,
GTPV1U_ENB_TUNNEL_DATA_REQ(message_p).offset = GTPU_HEADER_OVERHEAD_MAX;
GTPV1U_ENB_TUNNEL_DATA_REQ(message_p).rnti = ue->rnti;
GTPV1U_ENB_TUNNEL_DATA_REQ(message_p).rab_id = rb_id + 4;
- printf("!!!!!!! deliver_sdu_drb (drb %d) sending message to gtp size %d: ", rb_id, size);
- //for (i = 0; i < size; i++) printf(" %2.2x", (unsigned char)buf[i]);
- printf("\n");
+ LOG_D(PDCP, "%s() (drb %d) sending message to gtp size %d\n", __func__, rb_id, size);
+ //for (i = 0; i < size; i++) printf(" %2.2x", (unsigned char)buf[i]);
+ //printf("\n");
itti_send_msg_to_task(TASK_GTPV1_U, INSTANCE_DEFAULT, message_p);
}
@@ -474,9 +474,9 @@ rb_found:
memblock = get_free_mem_block(size, __FUNCTION__);
memcpy(memblock->data, buf, size);
-printf("!!!!!!! deliver_pdu_drb (srb %d) calling rlc_data_req size %d: ", rb_id, size);
-//for (i = 0; i < size; i++) printf(" %2.2x", (unsigned char)memblock->data[i]);
-printf("\n");
+ 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);
}
@@ -863,10 +863,45 @@ boolean_t pdcp_remove_UE(
return 1;
}
-void pdcp_config_set_security(const protocol_ctxt_t* const ctxt_pP, pdcp_t *pdcp_pP, rb_id_t rb_id,
- uint16_t lc_idP, uint8_t security_modeP, uint8_t *kRRCenc_pP, uint8_t *kRRCint_pP, uint8_t *kUPenc_pP)
+void pdcp_config_set_security(
+ const protocol_ctxt_t* const ctxt_pP,
+ pdcp_t *const pdcp_pP,
+ const rb_id_t rb_id,
+ const uint16_t lc_idP,
+ const uint8_t security_modeP,
+ uint8_t *const kRRCenc_pP,
+ uint8_t *const kRRCint_pP,
+ uint8_t *const kUPenc_pP)
{
- TODO;
+ DevAssert(pdcp_pP != NULL);
+
+ if ((security_modeP >= 0) && (security_modeP <= 0x77)) {
+ pdcp_pP->cipheringAlgorithm = security_modeP & 0x0f;
+ pdcp_pP->integrityProtAlgorithm = (security_modeP>>4) & 0xf;
+ LOG_D(PDCP, PROTOCOL_PDCP_CTXT_FMT" CONFIG_ACTION_SET_SECURITY_MODE: cipheringAlgorithm %d integrityProtAlgorithm %d\n",
+ PROTOCOL_PDCP_CTXT_ARGS(ctxt_pP,pdcp_pP),
+ pdcp_pP->cipheringAlgorithm,
+ pdcp_pP->integrityProtAlgorithm);
+ pdcp_pP->kRRCenc = kRRCenc_pP;
+ pdcp_pP->kRRCint = kRRCint_pP;
+ pdcp_pP->kUPenc = kUPenc_pP;
+ /* Activate security */
+ pdcp_pP->security_activated = 1;
+ MSC_LOG_EVENT(
+ (ctxt_pP->enb_flag == ENB_FLAG_YES) ? MSC_PDCP_ENB:MSC_PDCP_UE,
+ "0 Set security ciph %X integ %x UE %"PRIx16" ",
+ pdcp_pP->cipheringAlgorithm,
+ pdcp_pP->integrityProtAlgorithm,
+ ctxt_pP->rnti);
+ } else {
+ MSC_LOG_EVENT(
+ (ctxt_pP->enb_flag == ENB_FLAG_YES) ? MSC_PDCP_ENB:MSC_PDCP_UE,
+ "0 Set security failed UE %"PRIx16" ",
+ ctxt_pP->rnti);
+ LOG_E(PDCP,PROTOCOL_PDCP_CTXT_FMT" bad security mode %d",
+ PROTOCOL_PDCP_CTXT_ARGS(ctxt_pP,pdcp_pP),
+ security_modeP);
+ }
}
static boolean_t pdcp_data_req_drb(
@@ -877,7 +912,7 @@ static boolean_t pdcp_data_req_drb(
const sdu_size_t sdu_buffer_size,
unsigned char *const sdu_buffer)
{
-printf("pdcp_data_req called size %d\n", sdu_buffer_size);
+ LOG_D(PDCP, "%s() called, size %d\n", __func__, sdu_buffer_size);
nr_pdcp_ue_t *ue;
nr_pdcp_entity_t *rb;
int rnti = ctxt_pP->rnti;
diff --git a/openair2/NR_PHY_INTERFACE/NR_IF_Module.c b/openair2/NR_PHY_INTERFACE/NR_IF_Module.c
index c5b90cf028..22c48d11eb 100644
--- a/openair2/NR_PHY_INTERFACE/NR_IF_Module.c
+++ b/openair2/NR_PHY_INTERFACE/NR_IF_Module.c
@@ -181,10 +181,10 @@ void NR_UL_indication(NR_UL_IND_t *UL_info) {
clear_nr_nfapi_information(mac,CC_id,UL_info->frame,UL_info->slot);
handle_nr_rach(UL_info);
- handle_nr_uci(UL_info,&mac->UE_list.UE_sched_ctrl[0],&mac->UE_list.mac_stats[0],mac->pucch_target_snrx10);
+ handle_nr_uci(UL_info,&mac->UE_info.UE_sched_ctrl[0],&mac->UE_info.mac_stats[0],mac->pucch_target_snrx10);
// clear HI prior to handling ULSCH
mac->UL_dci_req[CC_id].numPdus = 0;
- handle_nr_ulsch(UL_info, &mac->UE_list.UE_sched_ctrl[0],&mac->UE_list.mac_stats[0]);
+ handle_nr_ulsch(UL_info, &mac->UE_info.UE_sched_ctrl[0],&mac->UE_info.mac_stats[0]);
if (nfapi_mode != 1) {
if (ifi->CC_mask == ((1<module_id;
NR_UE_MAC_INST_t *mac = get_mac_inst(module_id);
- // clean previous FAPI messages
- mac->tx_request.number_of_pdus = 0;
- mac->ul_config_request.number_pdus = 0;
- mac->dl_config_request.number_pdus = 0;
- // clean previous FAPI messages
-
ret = nr_ue_scheduler(NULL, ul_info);
- if (is_nr_UL_slot(mac->scc, ul_info->slot_tx) && get_softmodem_params()->do_ra){
+ if (is_nr_UL_slot(mac->scc, ul_info->slot_tx) && get_softmodem_params()->do_ra)
nr_ue_prach_scheduler(module_id, ul_info->frame_tx, ul_info->slot_tx);
- }
switch(ret){
case UE_CONNECTION_OK:
@@ -132,8 +125,6 @@ int nr_ue_ul_indication(nr_uplink_indication_t *ul_info){
break;
}
- mac->if_module->scheduled_response(&mac->scheduled_response);
-
return 0;
}
@@ -151,22 +142,11 @@ int nr_ue_dl_indication(nr_downlink_indication_t *dl_info, NR_UL_TIME_ALIGNMENT_
nr_ue_scheduler(dl_info, NULL);
} else {
// UL indication after reception of DCI or DL PDU
- dl_config->number_pdus = 0;
- ul_config->number_pdus = 0;
- //hook up pointers
- mac->scheduled_response.dl_config = dl_config;
- mac->scheduled_response.ul_config = ul_config;
- mac->scheduled_response.tx_request = &mac->tx_request;
- mac->scheduled_response.module_id = dl_info->module_id;
- mac->scheduled_response.CC_id = dl_info->cc_id;
- mac->scheduled_response.frame = dl_info->frame;
- mac->scheduled_response.slot = dl_info->slot;
-
if(dl_info->dci_ind != NULL){
LOG_D(MAC,"[L2][IF MODULE][DL INDICATION][DCI_IND]\n");
for(i=0; idci_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,
dl_info->cc_id,
dl_info->gNB_index,
@@ -174,8 +154,10 @@ int nr_ue_dl_indication(nr_downlink_indication_t *dl_info, NR_UL_TIME_ALIGNMENT_
ret_mask |= (ret << FAPI_NR_DCI_IND);
if (ret >= 0) {
- AssertFatal( nr_ue_if_module_inst[module_id] != NULL, "IF module is void!\n" );
- nr_ue_if_module_inst[module_id]->scheduled_response(&mac->scheduled_response);
+ AssertFatal( nr_ue_if_module_inst[module_id] != NULL, "IF module is NULL!\n" );
+ AssertFatal( nr_ue_if_module_inst[module_id]->scheduled_response != NULL, "scheduled_response is NULL!\n" );
+ fill_scheduled_response(&scheduled_response, dl_config, ul_config, NULL, dl_info->module_id, dl_info->cc_id, dl_info->frame, dl_info->slot);
+ nr_ue_if_module_inst[module_id]->scheduled_response(&scheduled_response);
}
}
}
@@ -266,20 +248,16 @@ int nr_ue_if_module_kill(uint32_t module_id) {
if (nr_ue_if_module_inst[module_id] != NULL){
free(nr_ue_if_module_inst[module_id]);
- }
+ }
return 0;
}
int nr_ue_dcireq(nr_dcireq_t *dcireq) {
-
- fapi_nr_dl_config_request_t *dl_config=&dcireq->dl_config_req;
+
+ fapi_nr_dl_config_request_t *dl_config = &dcireq->dl_config_req;
NR_UE_MAC_INST_t *UE_mac = get_mac_inst(0);
-
- dl_config->sfn=UE_mac->dl_config_request.sfn;
- dl_config->slot=UE_mac->dl_config_request.slot;
- dl_config->number_pdus=0;
-
- //printf(" UE_mac->dl_config_request.slot %d VS dcireq->slot %d \n", UE_mac->dl_config_request.slot, dcireq->slot);
+ dl_config->sfn = UE_mac->dl_config_request.sfn;
+ dl_config->slot = UE_mac->dl_config_request.slot;
LOG_D(PHY, "Entering UE DCI configuration frame %d slot %d \n", dcireq->frame, dcireq->slot);
diff --git a/openair2/RRC/LTE/defs_NB_IoT.h b/openair2/RRC/LTE/defs_NB_IoT.h
index 06b150a673..91dc7aafd4 100644
--- a/openair2/RRC/LTE/defs_NB_IoT.h
+++ b/openair2/RRC/LTE/defs_NB_IoT.h
@@ -37,6 +37,9 @@
#include "COMMON/s1ap_messages_types.h"
#include "COMMON/rrc_messages_types.h"
+#if ITTI_SIM
+#include "COMMON/itti_sim_messages_types.h"
+#endif
#include "collection/tree.h"
#include "rrc_types_NB_IoT.h"
diff --git a/openair2/RRC/NR/MESSAGES/asn1_msg.c b/openair2/RRC/NR/MESSAGES/asn1_msg.c
index 75f6a20682..70029ed54c 100644
--- a/openair2/RRC/NR/MESSAGES/asn1_msg.c
+++ b/openair2/RRC/NR/MESSAGES/asn1_msg.c
@@ -41,8 +41,10 @@
#include
#include "asn1_msg.h"
+#include "../nr_rrc_proto.h"
#include "RRC/NR/nr_rrc_extern.h"
#include "NR_DL-CCCH-Message.h"
+#include "NR_UL-CCCH-Message.h"
#include "NR_DL-DCCH-Message.h"
#include "NR_RRCReject.h"
#include "NR_RejectWaitTime.h"
@@ -61,6 +63,8 @@
#include "NR_DRB-ToAddMod.h"
#include "NR_DRB-ToAddModList.h"
#include "NR_SecurityConfig.h"
+#include "NR_RRCReconfiguration-v1530-IEs.h"
+#include "NR_UL-DCCH-Message.h"
#if defined(NR_Rel16)
#include "NR_SCS-SpecificCarrier.h"
#include "NR_TDD-UL-DL-ConfigCommon.h"
@@ -659,17 +663,18 @@ uint8_t do_RRCSetup(const protocol_ctxt_t *const ctxt_pP,
NR_MAC_CellGroupConfig_t *mac_CellGroupConfig = NULL;
char masterCellGroup_buf[1000];
- int size = 0;
long *logicalChannelGroup = NULL;
memset((void *)&dl_ccch_msg, 0, sizeof(NR_DL_CCCH_Message_t));
dl_ccch_msg.message.present = NR_DL_CCCH_MessageType_PR_c1;
dl_ccch_msg.message.choice.c1 = CALLOC(1, sizeof(struct NR_DL_CCCH_MessageType__c1));
dl_ccch_msg.message.choice.c1->present = NR_DL_CCCH_MessageType__c1_PR_rrcSetup;
+ dl_ccch_msg.message.choice.c1->choice.rrcSetup = calloc(1, sizeof(NR_RRCSetup_t));
rrcSetup = dl_ccch_msg.message.choice.c1->choice.rrcSetup;
rrcSetup->criticalExtensions.present = NR_RRCSetup__criticalExtensions_PR_rrcSetup;
rrcSetup->rrc_TransactionIdentifier = transaction_id;
+ rrcSetup->criticalExtensions.choice.rrcSetup = calloc(1, sizeof(NR_RRCSetup_IEs_t));
ie = rrcSetup->criticalExtensions.choice.rrcSetup;
/****************************** radioBearerConfig ******************************/
@@ -703,14 +708,18 @@ uint8_t do_RRCSetup(const protocol_ctxt_t *const ctxt_pP,
cellGroupConfig->rlc_BearerToAddModList = calloc(1, sizeof(*cellGroupConfig->rlc_BearerToAddModList));
rlc_BearerConfig = calloc(1, sizeof(NR_RLC_BearerConfig_t));
rlc_BearerConfig->logicalChannelIdentity = 1;
+ rlc_BearerConfig->servedRadioBearer = calloc(1, sizeof(*rlc_BearerConfig->servedRadioBearer));
rlc_BearerConfig->servedRadioBearer->present = NR_RLC_BearerConfig__servedRadioBearer_PR_srb_Identity;
rlc_BearerConfig->servedRadioBearer->choice.srb_Identity = 1;
rlc_BearerConfig->reestablishRLC = NULL;
+ rlc_Config = calloc(1, sizeof(NR_RLC_Config_t));
rlc_Config->present = NR_RLC_Config_PR_am;
rlc_Config->choice.am = calloc(1, sizeof(*rlc_Config->choice.am));
+ rlc_Config->choice.am->dl_AM_RLC.sn_FieldLength = calloc(1, sizeof(NR_SN_FieldLengthAM_t));
*(rlc_Config->choice.am->dl_AM_RLC.sn_FieldLength) = NR_SN_FieldLengthAM_size12;
rlc_Config->choice.am->dl_AM_RLC.t_Reassembly = NR_T_Reassembly_ms35;
rlc_Config->choice.am->dl_AM_RLC.t_StatusProhibit = NR_T_StatusProhibit_ms0;
+ rlc_Config->choice.am->ul_AM_RLC.sn_FieldLength = calloc(1, sizeof(NR_SN_FieldLengthAM_t));
*(rlc_Config->choice.am->ul_AM_RLC.sn_FieldLength) = NR_SN_FieldLengthAM_size12;
rlc_Config->choice.am->ul_AM_RLC.t_PollRetransmit = NR_T_PollRetransmit_ms45;
rlc_Config->choice.am->ul_AM_RLC.pollPDU = NR_PollPDU_infinity;
@@ -718,6 +727,7 @@ uint8_t do_RRCSetup(const protocol_ctxt_t *const ctxt_pP,
rlc_Config->choice.am->ul_AM_RLC.maxRetxThreshold = NR_UL_AM_RLC__maxRetxThreshold_t8;
rlc_BearerConfig->rlc_Config = rlc_Config;
logicalChannelConfig = calloc(1, sizeof(NR_LogicalChannelConfig_t));
+ logicalChannelConfig->ul_SpecificParameters = calloc(1, sizeof(*logicalChannelConfig->ul_SpecificParameters));
logicalChannelConfig->ul_SpecificParameters->priority = 1;
logicalChannelConfig->ul_SpecificParameters->prioritisedBitRate = NR_LogicalChannelConfig__ul_SpecificParameters__prioritisedBitRate_infinity;
logicalChannelGroup = CALLOC(1, sizeof(long));
@@ -726,6 +736,10 @@ uint8_t do_RRCSetup(const protocol_ctxt_t *const ctxt_pP,
rlc_BearerConfig->mac_LogicalChannelConfig = logicalChannelConfig;
ASN_SEQUENCE_ADD(&cellGroupConfig->rlc_BearerToAddModList->list, rlc_BearerConfig);
+ cellGroupConfig->rlc_BearerToReleaseList = NULL;
+ cellGroupConfig->sCellToAddModList = NULL;
+ cellGroupConfig->sCellToReleaseList = NULL;
+
/* mac CellGroup Config */
mac_CellGroupConfig = calloc(1, sizeof(NR_MAC_CellGroupConfig_t));
mac_CellGroupConfig->bsr_Config = calloc(1, sizeof(*mac_CellGroupConfig->bsr_Config));
@@ -932,12 +946,13 @@ uint16_t do_RRCReconfiguration(
NR_DL_DCCH_Message_t dl_dcch_msg;
asn_enc_rval_t enc_rval;
NR_RRCReconfiguration_IEs_t *ie;
- NR_SRB_ToAddModList_t *SRB2_configList = NULL;
+ NR_SRB_ToAddModList_t *SRB_configList = NULL;
+ NR_SRB_ToAddModList_t *SRB_configList2 = NULL;
NR_SRB_ToAddMod_t *SRB2_config = NULL;
NR_DRB_ToAddModList_t *DRB_configList = NULL;
+ NR_DRB_ToAddModList_t *DRB_configList2 = NULL;
NR_DRB_ToAddMod_t *DRB_config = NULL;
NR_SecurityConfig_t *security_config = NULL;
- NR_CellGroupConfig_t *secondaryCellGroup = NULL;
NR_DedicatedNAS_Message_t *dedicatedNAS_Message = NULL;
memset(&dl_dcch_msg, 0, sizeof(NR_DL_DCCH_Message_t));
@@ -949,26 +964,40 @@ uint16_t do_RRCReconfiguration(
dl_dcch_msg.message.choice.c1->choice.rrcReconfiguration->rrc_TransactionIdentifier = Transaction_id;
dl_dcch_msg.message.choice.c1->choice.rrcReconfiguration->criticalExtensions.present = NR_RRCReconfiguration__criticalExtensions_PR_rrcReconfiguration;
- uint8_t xid = rrc_gNB_get_next_transaction_identifier(ctxt_pP->module_id);
/******************** Radio Bearer Config ********************/
- ie->radioBearerConfig = calloc(1, sizeof(NR_RadioBearerConfig_t));
-
/* Configure SRB2 */
- SRB2_configList = ue_context_pP->ue_context.SRB_configList2[xid];
+ SRB_configList2 = ue_context_pP->ue_context.SRB_configList2[Transaction_id];
+ SRB_configList = ue_context_pP->ue_context.SRB_configList;
+ SRB_configList = CALLOC(1, sizeof(*SRB_configList));
+ memset(SRB_configList, 0, sizeof(*SRB_configList));
- if (SRB2_configList) {
- free(SRB2_configList);
+ if (SRB_configList2) {
+ free(SRB_configList2);
}
- SRB2_configList = CALLOC(1, sizeof(*SRB2_configList));
- memset(SRB2_configList, 0, sizeof(*SRB2_configList));
+ SRB_configList2 = CALLOC(1, sizeof(*SRB_configList2));
+ memset(SRB_configList2, 0, sizeof(*SRB_configList2));
SRB2_config = CALLOC(1, sizeof(*SRB2_config));
SRB2_config->srb_Identity = 2;
- ASN_SEQUENCE_ADD(&SRB2_configList->list, SRB2_config);
+ ASN_SEQUENCE_ADD(&SRB_configList->list, SRB2_config);
+ ASN_SEQUENCE_ADD(&SRB_configList2->list, SRB2_config);
/* Configure DRB */
+ DRB_configList = ue_context_pP->ue_context.DRB_configList;
+ if (DRB_configList) {
+ free(DRB_configList);
+ }
+
DRB_configList = CALLOC(1, sizeof(*DRB_configList));
memset(DRB_configList, 0, sizeof(*DRB_configList));
+
+ DRB_configList2 = ue_context_pP->ue_context.DRB_configList2[Transaction_id];
+ if (DRB_configList2) {
+ free(DRB_configList2);
+ }
+ DRB_configList2 = CALLOC(1, sizeof(*DRB_configList2));
+ memset(DRB_configList2, 0, sizeof(*DRB_configList2));
+
DRB_config = CALLOC(1, sizeof(*DRB_config));
DRB_config->drb_Identity = 1;
DRB_config->cnAssociation = CALLOC(1, sizeof(*DRB_config->cnAssociation));
@@ -998,31 +1027,32 @@ uint16_t do_RRCReconfiguration(
DRB_config->pdcp_Config->ext1 = NULL;
ASN_SEQUENCE_ADD(&DRB_configList->list, DRB_config);
+ ASN_SEQUENCE_ADD(&DRB_configList2->list, DRB_config);
/* Configure Security */
- security_config = CALLOC(1, sizeof(NR_SecurityConfig_t));
- security_config->securityAlgorithmConfig = CALLOC(1, sizeof(*ie->radioBearerConfig->securityConfig->securityAlgorithmConfig));
- security_config->securityAlgorithmConfig->cipheringAlgorithm = NR_CipheringAlgorithm_nea0;
- security_config->securityAlgorithmConfig->integrityProtAlgorithm = NULL;
- security_config->keyToUse = CALLOC(1, sizeof(*ie->radioBearerConfig->securityConfig->keyToUse));
- *security_config->keyToUse = NR_SecurityConfig__keyToUse_master;
+ // security_config = CALLOC(1, sizeof(NR_SecurityConfig_t));
+ // security_config->securityAlgorithmConfig = CALLOC(1, sizeof(*ie->radioBearerConfig->securityConfig->securityAlgorithmConfig));
+ // security_config->securityAlgorithmConfig->cipheringAlgorithm = NR_CipheringAlgorithm_nea0;
+ // security_config->securityAlgorithmConfig->integrityProtAlgorithm = NULL;
+ // security_config->keyToUse = CALLOC(1, sizeof(*ie->radioBearerConfig->securityConfig->keyToUse));
+ // *security_config->keyToUse = NR_SecurityConfig__keyToUse_master;
ie = calloc(1, sizeof(NR_RRCReconfiguration_IEs_t));
ie->radioBearerConfig = calloc(1, sizeof(NR_RadioBearerConfig_t));
- ie->radioBearerConfig->srb_ToAddModList = SRB2_configList;
+ ie->radioBearerConfig->srb_ToAddModList = SRB_configList;
ie->radioBearerConfig->drb_ToAddModList = DRB_configList;
ie->radioBearerConfig->securityConfig = security_config;
ie->radioBearerConfig->srb3_ToRelease = NULL;
ie->radioBearerConfig->drb_ToReleaseList = NULL;
/******************** Secondary Cell Group ********************/
- rrc_gNB_carrier_data_t *carrier = &(gnb_rrc_inst->carrier);
- fill_default_secondaryCellGroup( carrier->ServingCellConfigCommon,
- ue_context_pP->ue_context.secondaryCellGroup,
- 1,
- 1,
- carrier->pdsch_AntennaPorts,
- carrier->initial_csi_index[gnb_rrc_inst->Nb_ue]);
+ // rrc_gNB_carrier_data_t *carrier = &(gnb_rrc_inst->carrier);
+ // fill_default_secondaryCellGroup( carrier->servingcellconfigcommon,
+ // ue_context_pP->ue_context.secondaryCellGroup,
+ // 1,
+ // 1,
+ // carrier->pdsch_AntennaPorts,
+ // carrier->initial_csi_index[gnb_rrc_inst->Nb_ue]);
/******************** Meas Config ********************/
// measConfig
@@ -1030,9 +1060,10 @@ uint16_t do_RRCReconfiguration(
// lateNonCriticalExtension
ie->lateNonCriticalExtension = NULL;
// nonCriticalExtension
+ ie->nonCriticalExtension = calloc(1, sizeof(NR_RRCReconfiguration_v1530_IEs_t));
+ dedicatedNAS_Message = calloc(1, sizeof(NR_DedicatedNAS_Message_t));
dedicatedNAS_Message->buf = ue_context_pP->ue_context.nas_pdu.buffer;
dedicatedNAS_Message->size = ue_context_pP->ue_context.nas_pdu.length;
- ie->nonCriticalExtension->dedicatedNAS_MessageList = CALLOC(1, sizeof(*ie->nonCriticalExtension->dedicatedNAS_MessageList));
ASN_SEQUENCE_ADD(&ie->nonCriticalExtension->dedicatedNAS_MessageList->list, dedicatedNAS_Message);
dl_dcch_msg.message.choice.c1->choice.rrcReconfiguration->criticalExtensions.choice.rrcReconfiguration = ie;
@@ -1064,3 +1095,125 @@ uint16_t do_RRCReconfiguration(
return((enc_rval.encoded+7)/8);
}
+
+
+uint8_t do_RRCSetupRequest(uint8_t Mod_id, uint8_t *buffer,uint8_t *rv) {
+ asn_enc_rval_t enc_rval;
+ uint8_t buf[5],buf2=0;
+ NR_UL_CCCH_Message_t ul_ccch_msg;
+ NR_RRCSetupRequest_t *rrcSetupRequest;
+ memset((void *)&ul_ccch_msg,0,sizeof(NR_UL_CCCH_Message_t));
+ ul_ccch_msg.message.present = NR_UL_CCCH_MessageType_PR_c1;
+ ul_ccch_msg.message.choice.c1 = CALLOC(1, sizeof(struct NR_UL_CCCH_MessageType__c1));
+ ul_ccch_msg.message.choice.c1->present = NR_UL_CCCH_MessageType__c1_PR_rrcSetupRequest;
+ rrcSetupRequest = ul_ccch_msg.message.choice.c1->choice.rrcSetupRequest;
+
+
+ if (1) {
+ rrcSetupRequest->rrcSetupRequest.ue_Identity.present = NR_InitialUE_Identity_PR_randomValue;
+ rrcSetupRequest->rrcSetupRequest.ue_Identity.choice.randomValue.size = 5;
+ rrcSetupRequest->rrcSetupRequest.ue_Identity.choice.randomValue.bits_unused = 0;
+ rrcSetupRequest->rrcSetupRequest.ue_Identity.choice.randomValue.buf = buf;
+ rrcSetupRequest->rrcSetupRequest.ue_Identity.choice.randomValue.buf[0] = rv[0];
+ rrcSetupRequest->rrcSetupRequest.ue_Identity.choice.randomValue.buf[1] = rv[1];
+ rrcSetupRequest->rrcSetupRequest.ue_Identity.choice.randomValue.buf[2] = rv[2];
+ rrcSetupRequest->rrcSetupRequest.ue_Identity.choice.randomValue.buf[3] = rv[3];
+ rrcSetupRequest->rrcSetupRequest.ue_Identity.choice.randomValue.buf[4] = rv[4];
+ } else {
+ rrcSetupRequest->rrcSetupRequest.ue_Identity.present = NR_InitialUE_Identity_PR_ng_5G_S_TMSI_Part1;
+ rrcSetupRequest->rrcSetupRequest.ue_Identity.choice.ng_5G_S_TMSI_Part1.size = 1;
+ rrcSetupRequest->rrcSetupRequest.ue_Identity.choice.ng_5G_S_TMSI_Part1.bits_unused = 0;
+ rrcSetupRequest->rrcSetupRequest.ue_Identity.choice.ng_5G_S_TMSI_Part1.buf = buf;
+ rrcSetupRequest->rrcSetupRequest.ue_Identity.choice.ng_5G_S_TMSI_Part1.buf[0] = 0x12;
+ }
+
+ rrcSetupRequest->rrcSetupRequest.establishmentCause = NR_EstablishmentCause_mo_Signalling; //EstablishmentCause_mo_Data;
+ rrcSetupRequest->rrcSetupRequest.spare.buf = &buf2;
+ rrcSetupRequest->rrcSetupRequest.spare.size=1;
+ rrcSetupRequest->rrcSetupRequest.spare.bits_unused = 7;
+
+ if ( LOG_DEBUGFLAG(DEBUG_ASN1) ) {
+ xer_fprint(stdout, &asn_DEF_NR_UL_CCCH_Message, (void *)&ul_ccch_msg);
+ }
+
+ enc_rval = uper_encode_to_buffer(&asn_DEF_NR_UL_CCCH_Message,
+ NULL,
+ (void *)&ul_ccch_msg,
+ buffer,
+ 100);
+ AssertFatal (enc_rval.encoded > 0, "ASN1 message encoding failed (%s, %lu)!\n", enc_rval.failed_type->name, enc_rval.encoded);
+ LOG_D(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(
+ const protocol_ctxt_t *const ctxt_pP,
+ uint8_t *buffer,
+ const uint8_t Transaction_id
+)
+//------------------------------------------------------------------------------
+{
+ asn_enc_rval_t enc_rval;
+ NR_UL_DCCH_Message_t ul_dcch_msg;
+ NR_RRCReconfigurationComplete_t *rrcReconfigurationComplete;
+ memset((void *)&ul_dcch_msg,0,sizeof(NR_UL_DCCH_Message_t));
+ ul_dcch_msg.message.present = NR_UL_DCCH_MessageType_PR_c1;
+ ul_dcch_msg.message.choice.c1 = CALLOC(1, sizeof(struct NR_UL_DCCH_MessageType__c1));
+ ul_dcch_msg.message.choice.c1->present = NR_UL_DCCH_MessageType__c1_PR_rrcReconfigurationComplete;
+ rrcReconfigurationComplete = ul_dcch_msg.message.choice.c1->choice.rrcReconfigurationComplete;
+ rrcReconfigurationComplete->rrc_TransactionIdentifier = Transaction_id;
+ rrcReconfigurationComplete->criticalExtensions.present =
+ NR_RRCReconfigurationComplete__criticalExtensions_PR_rrcReconfigurationComplete;
+ rrcReconfigurationComplete->criticalExtensions.choice.rrcReconfigurationComplete->nonCriticalExtension = NULL;
+ rrcReconfigurationComplete->criticalExtensions.choice.rrcReconfigurationComplete->lateNonCriticalExtension = NULL;
+ if ( LOG_DEBUGFLAG(DEBUG_ASN1) ) {
+ xer_fprint(stdout, &asn_DEF_NR_UL_DCCH_Message, (void *)&ul_dcch_msg);
+ }
+
+ enc_rval = uper_encode_to_buffer(&asn_DEF_NR_UL_DCCH_Message,
+ NULL,
+ (void *)&ul_dcch_msg,
+ buffer,
+ 100);
+ AssertFatal (enc_rval.encoded > 0, "ASN1 message encoding failed (%s, %lu)!\n",
+ enc_rval.failed_type->name, enc_rval.encoded);
+ LOG_D(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){
+ asn_enc_rval_t enc_rval;
+
+ NR_UL_DCCH_Message_t ul_dcch_msg;
+ NR_RRCSetupComplete_t *RrcSetupComplete;
+ memset((void *)&ul_dcch_msg,0,sizeof(NR_UL_DCCH_Message_t));
+ ul_dcch_msg.message.present = NR_UL_DCCH_MessageType_PR_c1;
+ ul_dcch_msg.message.choice.c1 = CALLOC(1,sizeof(struct NR_DL_DCCH_MessageType__c1));
+ ul_dcch_msg.message.choice.c1->present = NR_UL_DCCH_MessageType__c1_PR_rrcSetupComplete;
+ RrcSetupComplete = ul_dcch_msg.message.choice.c1->choice.rrcSetupComplete;
+ RrcSetupComplete->rrc_TransactionIdentifier = Transaction_id;
+ RrcSetupComplete->criticalExtensions.present = NR_RRCSetupComplete__criticalExtensions_PR_rrcSetupComplete;
+ RrcSetupComplete->criticalExtensions.choice.rrcSetupComplete->nonCriticalExtension = CALLOC(1,
+ sizeof(*RrcSetupComplete->criticalExtensions.choice.rrcSetupComplete->nonCriticalExtension));
+ RrcSetupComplete->criticalExtensions.choice.rrcSetupComplete->selectedPLMN_Identity = sel_plmn_id;
+ RrcSetupComplete->criticalExtensions.choice.rrcSetupComplete->registeredAMF = NULL;
+ memset(&RrcSetupComplete->criticalExtensions.choice.rrcSetupComplete->dedicatedNAS_Message,0,sizeof(OCTET_STRING_t));
+ OCTET_STRING_fromBuf(&RrcSetupComplete->criticalExtensions.choice.rrcSetupComplete->dedicatedNAS_Message,dedicatedInfoNAS,dedicatedInfoNASLength);
+if ( LOG_DEBUGFLAG(DEBUG_ASN1) ) {
+ xer_fprint(stdout, &asn_DEF_NR_DL_DCCH_Message, (void *)&ul_dcch_msg);
+}
+
+enc_rval = uper_encode_to_buffer(&asn_DEF_NR_DL_DCCH_Message,
+ NULL,
+ (void *)&ul_dcch_msg,
+ buffer,
+ 100);
+
+ AssertFatal(enc_rval.encoded > 0,"ASN1 message encoding failed (%s, %lu)!\n",
+ enc_rval.failed_type->name,enc_rval.encoded);
+ LOG_D(RRC,"RRCConnectionSetupComplete 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 2222f8a3f9..c55b8dd1ec 100644
--- a/openair2/RRC/NR/MESSAGES/asn1_msg.h
+++ b/openair2/RRC/NR/MESSAGES/asn1_msg.h
@@ -99,6 +99,10 @@ uint8_t do_NR_SecurityModeCommand(
const uint8_t cipheringAlgorithm,
NR_IntegrityProtAlgorithm_t *integrityProtAlgorithm);
+uint8_t do_NR_UECapabilityEnquiry_nr( const protocol_ctxt_t *const ctxt_pP,
+ uint8_t *const buffer,
+ const uint8_t Transaction_id);
+
uint8_t do_NR_RRCConnectionRelease(uint8_t *buffer,
uint8_t Transaction_id);
uint16_t do_RRCReconfiguration(
@@ -107,3 +111,10 @@ uint16_t do_RRCReconfiguration(
uint8_t *buffer,
uint8_t Transaction_id,
gNB_RRC_INST *gnb_rrc_inst);
+
+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);
\ No newline at end of file
diff --git a/openair2/RRC/NR/nr_rrc_defs.h b/openair2/RRC/NR/nr_rrc_defs.h
index 92c82ecc2c..a9a8c80ed1 100644
--- a/openair2/RRC/NR/nr_rrc_defs.h
+++ b/openair2/RRC/NR/nr_rrc_defs.h
@@ -134,8 +134,6 @@ typedef enum UE_STATE_NR_e {
/* TS 36.331: RRC-TransactionIdentifier ::= INTEGER (0..3) */
#define NR_RRC_TRANSACTION_IDENTIFIER_NUMBER 3
-#define ENABLE_SECURITY 1
-
typedef struct {
unsigned short transport_block_size; /*!< \brief Minimum PDU size in bytes provided by RLC to MAC layer interface */
unsigned short max_transport_blocks; /*!< \brief Maximum PDU size in bytes provided by RLC to MAC layer interface */
@@ -289,13 +287,12 @@ typedef struct gNB_RRC_UE_s {
ImsiMobileIdentity_t imsi;
-#if defined(ENABLE_SECURITY)
- /* KeNB as derived from KASME received from EPC */
- uint8_t kenb[32];
- int8_t kenb_ncc;
+ /* KgNB as derived from KASME received from EPC */
+ uint8_t kgnb[32];
+ int8_t kgnb_ncc;
uint8_t nh[32];
int8_t nh_ncc;
-#endif
+
/* Used integrity/ciphering algorithms */
NR_CipheringAlgorithm_t ciphering_algorithm;
e_NR_IntegrityProtAlgorithm integrity_algorithm;
@@ -322,7 +319,7 @@ typedef struct gNB_RRC_UE_s {
uint64_t amf_ue_ngap_id:40;
nr_rrc_guami_t ue_guami;
- security_capabilities_t security_capabilities;
+ ngap_security_capabilities_t security_capabilities;
/* Total number of e_rab already setup in the list */
uint8_t setup_e_rabs;
diff --git a/openair2/RRC/NR/rrc_gNB.c b/openair2/RRC/NR/rrc_gNB.c
index 75bbb9d686..edeaef4e55 100644
--- a/openair2/RRC/NR/rrc_gNB.c
+++ b/openair2/RRC/NR/rrc_gNB.c
@@ -68,9 +68,7 @@
#include "OCG.h"
#include "OCG_extern.h"
-#if defined(ENABLE_SECURITY)
- #include "UTIL/OSA/osa_defs.h"
-#endif
+#include "UTIL/OSA/osa_defs.h"
#include "rrc_eNB_S1AP.h"
#include "rrc_gNB_NGAP.h"
@@ -92,6 +90,28 @@
extern RAN_CONTEXT_t RC;
+extern boolean_t nr_rrc_pdcp_config_asn1_req(
+ const protocol_ctxt_t *const ctxt_pP,
+ NR_SRB_ToAddModList_t *const srb2add_list,
+ NR_DRB_ToAddModList_t *const drb2add_list,
+ NR_DRB_ToReleaseList_t *const drb2release_list,
+ const uint8_t security_modeP,
+ uint8_t *const kRRCenc,
+ uint8_t *const kRRCint,
+ uint8_t *const kUPenc
+ #if (LTE_RRC_VERSION >= MAKE_VERSION(9, 0, 0))
+ ,LTE_PMCH_InfoList_r9_t *pmch_InfoList_r9
+ #endif
+ ,rb_id_t *const defaultDRB,
+ struct NR_CellGroupConfig__rlc_BearerToAddModList *rlc_bearer2add_list);
+
+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_bearer2add_list);
+
mui_t rrc_gNB_mui = 0;
///---------------------------------------------------------------------------------------------------------------///
@@ -327,7 +347,7 @@ rrc_gNB_generate_RRCSetup(
)
//-----------------------------------------------------------------------------
{
- LOG_I(RRC, "rrc_gNB_generate_RRCSetup \n");
+ LOG_I(NR_RRC, "rrc_gNB_generate_RRCSetup \n");
NR_SRB_ToAddModList_t *SRB_configList = NULL;
// T(T_GNB_RRC_SETUP,
@@ -337,7 +357,7 @@ rrc_gNB_generate_RRCSetup(
// T_INT(ctxt_pP->rnti));
gNB_RRC_UE_t *ue_p = &ue_context_pP->ue_context;
SRB_configList = ue_p->SRB_configList;
- do_RRCSetup(ctxt_pP,
+ ue_p->Srb0.Tx_buffer.payload_size = do_RRCSetup(ctxt_pP,
ue_context_pP,
CC_id,
(uint8_t *) ue_p->Srb0.Tx_buffer.Payload,
@@ -400,6 +420,13 @@ rrc_gNB_generate_RRCSetup(
ue_context_pP->ue_context.ue_release_timer_thres = 1000;
/* init timers */
// ue_context_pP->ue_context.ue_rrc_inactivity_timer = 0;
+#ifdef ITTI_SIM
+ MessageDef *message_p;
+ message_p = itti_alloc_new_message (TASK_RRC_UE_SIM, GNB_RRC_CCCH_DATA_IND);
+ GNB_RRC_CCCH_DATA_IND (message_p).sdu = (uint8_t*)ue_p->Srb0.Tx_buffer.Payload;
+ GNB_RRC_CCCH_DATA_IND (message_p).size = ue_p->Srb0.Tx_buffer.payload_size;
+ itti_send_msg_to_task (TASK_RRC_UE_SIM, ctxt_pP->instance, message_p);
+#endif
}
void
@@ -542,18 +569,18 @@ rrc_gNB_process_RRCReconfigurationComplete(
return;
}
- /* Derive the keys from kenb */
+ /* Derive the keys from kgnb */
if (DRB_configList != NULL) {
derive_key_up_enc(ue_context_pP->ue_context.ciphering_algorithm,
- ue_context_pP->ue_context.kenb,
+ ue_context_pP->ue_context.kgnb,
&kUPenc);
}
derive_key_rrc_enc(ue_context_pP->ue_context.ciphering_algorithm,
- ue_context_pP->ue_context.kenb,
+ ue_context_pP->ue_context.kgnb,
&kRRCenc);
derive_key_rrc_int(ue_context_pP->ue_context.integrity_algorithm,
- ue_context_pP->ue_context.kenb,
+ ue_context_pP->ue_context.kgnb,
&kRRCint);
/* Refresh SRBs/DRBs */
@@ -570,6 +597,7 @@ rrc_gNB_process_RRCReconfigurationComplete(
kRRCint,
kUPenc,
NULL,
+ NULL,
NULL);
/* Refresh SRBs/DRBs */
nr_rrc_rlc_config_asn1_req(ctxt_pP,
@@ -577,9 +605,7 @@ rrc_gNB_process_RRCReconfigurationComplete(
DRB_configList,
DRB_Release_configList2,
NULL,
- 0,
- 0
- );
+ NULL);
/* Loop through DRBs and establish if necessary */
if (DRB_configList != NULL) {
@@ -1184,7 +1210,7 @@ void *rrc_gnb_task(void *args_p) {
/* RRC_SUBFRAME_PROCESS is sent every subframe, do not log it */
if (ITTI_MSG_ID(msg_p) != RRC_SUBFRAME_PROCESS)
- LOG_I(NR_RRC,"Received message %s\n",msg_name_p);
+ LOG_I(NR_RRC,"Received message %s\n",msg_name_p);
switch (ITTI_MSG_ID(msg_p)) {
case TERMINATE_MESSAGE:
@@ -1196,6 +1222,10 @@ void *rrc_gnb_task(void *args_p) {
LOG_I(NR_RRC, "[gNB %d] Received %s\n", instance, msg_name_p);
break;
+ case RRC_SUBFRAME_PROCESS:
+ nr_rrc_subframe_process(&RRC_SUBFRAME_PROCESS(msg_p).ctxt, RRC_SUBFRAME_PROCESS(msg_p).CC_id);
+ break;
+
/* Messages from MAC */
case NR_RRC_MAC_CCCH_DATA_IND:
// PROTOCOL_CTXT_SET_BY_INSTANCE(&ctxt,
@@ -1222,10 +1252,6 @@ void *rrc_gnb_task(void *args_p) {
NR_RRC_MAC_CCCH_DATA_IND(msg_p).CC_id);
break;
- case RRC_SUBFRAME_PROCESS:
- nr_rrc_subframe_process(&RRC_SUBFRAME_PROCESS(msg_p).ctxt, RRC_SUBFRAME_PROCESS(msg_p).CC_id);
- break;
-
/* Messages from PDCP */
case NR_RRC_DCCH_DATA_IND:
// PROTOCOL_CTXT_SET_BY_INSTANCE(&ctxt,
diff --git a/openair2/RRC/NR/rrc_gNB_NGAP.c b/openair2/RRC/NR/rrc_gNB_NGAP.c
index da10657552..b615cb833e 100644
--- a/openair2/RRC/NR/rrc_gNB_NGAP.c
+++ b/openair2/RRC/NR/rrc_gNB_NGAP.c
@@ -47,6 +47,7 @@
#include "S1AP_NAS-PDU.h"
#include "executables/softmodem-common.h"
+#include "UTIL/OSA/osa_defs.h"
extern RAN_CONTEXT_t RC;
@@ -115,6 +116,75 @@ rrc_gNB_get_ue_context_from_ngap_ids(
return NULL;
}
+//------------------------------------------------------------------------------
+void
+nr_rrc_pdcp_config_security(
+ const protocol_ctxt_t *const ctxt_pP,
+ rrc_gNB_ue_context_t *const ue_context_pP,
+ const uint8_t send_security_mode_command
+)
+//------------------------------------------------------------------------------
+{
+ NR_SRB_ToAddModList_t *SRB_configList = ue_context_pP->ue_context.SRB_configList;
+ uint8_t *kRRCenc = NULL;
+ uint8_t *kRRCint = NULL;
+ uint8_t *kUPenc = NULL;
+ pdcp_t *pdcp_p = NULL;
+ static int print_keys= 1;
+ hashtable_rc_t h_rc;
+ hash_key_t key;
+
+ /* Derive the keys from kgnb */
+ if (SRB_configList != NULL) {
+ derive_key_up_enc(ue_context_pP->ue_context.ciphering_algorithm,
+ ue_context_pP->ue_context.kgnb,
+ &kUPenc);
+ }
+
+ derive_key_rrc_enc(ue_context_pP->ue_context.ciphering_algorithm,
+ ue_context_pP->ue_context.kgnb,
+ &kRRCenc);
+ derive_key_rrc_int(ue_context_pP->ue_context.integrity_algorithm,
+ ue_context_pP->ue_context.kgnb,
+ &kRRCint);
+ if (!IS_SOFTMODEM_IQPLAYER) {
+ SET_LOG_DUMP(DEBUG_SECURITY) ;
+ }
+
+
+ if ( LOG_DUMPFLAG( DEBUG_SECURITY ) ) {
+ if (print_keys == 1 ) {
+ print_keys =0;
+ LOG_DUMPMSG(NR_RRC, DEBUG_SECURITY, ue_context_pP->ue_context.kgnb, 32,"\nKgNB:" );
+ LOG_DUMPMSG(NR_RRC, DEBUG_SECURITY, kRRCenc, 32,"\nKRRCenc:" );
+ LOG_DUMPMSG(NR_RRC, DEBUG_SECURITY, kRRCint, 32,"\nKRRCint:" );
+ }
+ }
+
+ key = PDCP_COLL_KEY_VALUE(ctxt_pP->module_id, ctxt_pP->rnti, ctxt_pP->enb_flag, DCCH, SRB_FLAG_YES);
+ h_rc = hashtable_get(pdcp_coll_p, key, (void **)&pdcp_p);
+
+ if (h_rc == HASH_TABLE_OK) {
+ pdcp_config_set_security(
+ ctxt_pP,
+ pdcp_p,
+ DCCH,
+ DCCH+2,
+ (send_security_mode_command == TRUE) ?
+ 0 | (ue_context_pP->ue_context.integrity_algorithm << 4) :
+ (ue_context_pP->ue_context.ciphering_algorithm ) |
+ (ue_context_pP->ue_context.integrity_algorithm << 4),
+ kRRCenc,
+ kRRCint,
+ kUPenc);
+ } else {
+ LOG_E(NR_RRC,
+ PROTOCOL_NR_RRC_CTXT_UE_FMT"Could not get PDCP instance for SRB DCCH %u\n",
+ PROTOCOL_NR_RRC_CTXT_UE_ARGS(ctxt_pP),
+ DCCH);
+ }
+}
+
//------------------------------------------------------------------------------
/*
* Initial UE NAS message on S1AP.
@@ -280,7 +350,7 @@ rrc_gNB_process_NGAP_INITIAL_CONTEXT_SETUP_REQ(
uint8_t send_security_mode_command = TRUE;
- rrc_pdcp_config_security(
+ nr_rrc_pdcp_config_security(
&ctxt,
ue_context_p,
send_security_mode_command);
@@ -289,7 +359,7 @@ rrc_gNB_process_NGAP_INITIAL_CONTEXT_SETUP_REQ(
rrc_gNB_generate_SecurityModeCommand (&ctxt, ue_context_p);
send_security_mode_command = FALSE;
- rrc_pdcp_config_security(
+ nr_rrc_pdcp_config_security(
&ctxt,
ue_context_p,
send_security_mode_command);
@@ -370,7 +440,7 @@ int
rrc_gNB_process_security(
const protocol_ctxt_t *const ctxt_pP,
rrc_gNB_ue_context_t *const ue_context_pP,
- security_capabilities_t *security_capabilities_pP
+ ngap_security_capabilities_t *security_capabilities_pP
) {
boolean_t changed = FALSE;
NR_CipheringAlgorithm_t cipheringAlgorithm;
@@ -381,19 +451,19 @@ rrc_gNB_process_security(
LOG_D(NR_RRC,
"[eNB %d] NAS security_capabilities.encryption_algorithms %u AS ciphering_algorithm %lu NAS security_capabilities.integrity_algorithms %u AS integrity_algorithm %u\n",
ctxt_pP->module_id,
- ue_context_pP->ue_context.security_capabilities.encryption_algorithms,
+ ue_context_pP->ue_context.security_capabilities.nRencryption_algorithms,
(unsigned long)ue_context_pP->ue_context.ciphering_algorithm,
- ue_context_pP->ue_context.security_capabilities.integrity_algorithms,
+ ue_context_pP->ue_context.security_capabilities.nRintegrity_algorithms,
ue_context_pP->ue_context.integrity_algorithm);
/* Select relevant algorithms */
- cipheringAlgorithm = rrc_gNB_select_ciphering (ue_context_pP->ue_context.security_capabilities.encryption_algorithms);
+ cipheringAlgorithm = rrc_gNB_select_ciphering (ue_context_pP->ue_context.security_capabilities.nRencryption_algorithms);
if (ue_context_pP->ue_context.ciphering_algorithm != cipheringAlgorithm) {
ue_context_pP->ue_context.ciphering_algorithm = cipheringAlgorithm;
changed = TRUE;
}
- integrityProtAlgorithm = rrc_gNB_select_integrity (ue_context_pP->ue_context.security_capabilities.integrity_algorithms);
+ integrityProtAlgorithm = rrc_gNB_select_integrity (ue_context_pP->ue_context.security_capabilities.nRintegrity_algorithms);
if (ue_context_pP->ue_context.integrity_algorithm != integrityProtAlgorithm) {
ue_context_pP->ue_context.integrity_algorithm = integrityProtAlgorithm;
diff --git a/openair2/RRC/NR/rrc_gNB_NGAP.h b/openair2/RRC/NR/rrc_gNB_NGAP.h
index 8da2f06c57..5fb1a9f0d9 100644
--- a/openair2/RRC/NR/rrc_gNB_NGAP.h
+++ b/openair2/RRC/NR/rrc_gNB_NGAP.h
@@ -74,7 +74,7 @@ int
rrc_gNB_process_security(
const protocol_ctxt_t *const ctxt_pP,
rrc_gNB_ue_context_t *const ue_context_pP,
- security_capabilities_t *security_capabilities_pP
+ ngap_security_capabilities_t *security_capabilities_pP
);
#endif
diff --git a/openair2/RRC/NR_UE/L2_interface_ue.c b/openair2/RRC/NR_UE/L2_interface_ue.c
index 08976522b0..44d50dd0ef 100644
--- a/openair2/RRC/NR_UE/L2_interface_ue.c
+++ b/openair2/RRC/NR_UE/L2_interface_ue.c
@@ -67,4 +67,43 @@ int8_t mac_rrc_nr_data_req_ue(const module_id_t Mod_idP,
// todo
return 0;
-}
\ No newline at end of file
+}
+
+uint8_t
+rrc_data_req_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
+)
+{
+ MessageDef *message_p;
+ // Uses a new buffer to avoid issue with PDCP buffer content that could be changed by PDCP (asynchronous message handling).
+ uint8_t *message_buffer;
+ message_buffer = itti_malloc (
+ ctxt_pP->enb_flag ? TASK_RRC_ENB : TASK_RRC_UE,
+ ctxt_pP->enb_flag ? TASK_PDCP_ENB : TASK_PDCP_UE,
+ sdu_sizeP);
+ memcpy (message_buffer, buffer_pP, sdu_sizeP);
+ message_p = itti_alloc_new_message (ctxt_pP->enb_flag ? TASK_RRC_ENB : TASK_RRC_UE, RRC_DCCH_DATA_REQ);
+ RRC_DCCH_DATA_REQ (message_p).frame = ctxt_pP->frame;
+ RRC_DCCH_DATA_REQ (message_p).enb_flag = ctxt_pP->enb_flag;
+ RRC_DCCH_DATA_REQ (message_p).rb_id = rb_idP;
+ RRC_DCCH_DATA_REQ (message_p).muip = muiP;
+ RRC_DCCH_DATA_REQ (message_p).confirmp = confirmP;
+ RRC_DCCH_DATA_REQ (message_p).sdu_size = sdu_sizeP;
+ RRC_DCCH_DATA_REQ (message_p).sdu_p = message_buffer;
+ RRC_DCCH_DATA_REQ (message_p).mode = modeP;
+ RRC_DCCH_DATA_REQ (message_p).module_id = ctxt_pP->module_id;
+ RRC_DCCH_DATA_REQ (message_p).rnti = ctxt_pP->rnti;
+ RRC_DCCH_DATA_REQ (message_p).eNB_index = ctxt_pP->eNB_index;
+ itti_send_msg_to_task (
+ TASK_PDCP_UE,
+ ctxt_pP->instance,
+ message_p);
+ return TRUE; // TODO should be changed to a CNF message later, currently RRC lite does not used the returned value anyway.
+
+}
diff --git a/openair2/RRC/NR_UE/rrc_UE.c b/openair2/RRC/NR_UE/rrc_UE.c
index 03e5b6b4f2..b1a36f703e 100755
--- a/openair2/RRC/NR_UE/rrc_UE.c
+++ b/openair2/RRC/NR_UE/rrc_UE.c
@@ -33,10 +33,17 @@
#define RRC_UE
#define RRC_UE_C
-#include "NR_DL-DCCH-Message.h" //asn_DEF_NR_DL_DCCH_Message
-#include "NR_BCCH-BCH-Message.h" //asn_DEF_NR_BCCH_BCH_Message
-#include "NR_CellGroupConfig.h" //asn_DEF_NR_CellGroupConfig
-#include "NR_BWP-Downlink.h" //asn_DEF_NR_BWP_Downlink
+#include "asn1_conversions.h"
+
+#include "NR_DL-DCCH-Message.h" //asn_DEF_NR_DL_DCCH_Message
+#include "NR_DL-CCCH-Message.h" //asn_DEF_NR_DL_CCCH_Message
+#include "NR_BCCH-BCH-Message.h" //asn_DEF_NR_BCCH_BCH_Message
+#include "NR_BCCH-DL-SCH-Message.h" //asn_DEF_NR_BCCH_DL_SCH_Message
+#include "NR_CellGroupConfig.h" //asn_DEF_NR_CellGroupConfig
+#include "NR_BWP-Downlink.h" //asn_DEF_NR_BWP_Downlink
+#include "NR_RRCReconfiguration.h"
+#include "NR_MeasConfig.h"
+#include "NR_UL-DCCH-Message.h"
#include "rrc_list.h"
#include "rrc_defs.h"
@@ -44,8 +51,87 @@
#include "rrc_vars.h"
#include "LAYER2/NR_MAC_UE/mac_proto.h"
-#include "executables/softmodem-common.h"
+#include "intertask_interface.h"
+#include "executables/softmodem-common.h"
+#include "plmn_data.h"
+#include "pdcp.h"
+#include "UTIL/OSA/osa_defs.h"
+#include "common/utils/LOG/log.h"
+#include "common/utils/LOG/vcd_signal_dumper.h"
+
+mui_t nr_rrc_mui=0;
+
+static Rrc_State_t nr_rrc_get_state (module_id_t ue_mod_idP) {
+ return NR_UE_rrc_inst[ue_mod_idP].nrRrcState;
+}
+
+
+static Rrc_Sub_State_t nr_rrc_get_sub_state (module_id_t ue_mod_idP) {
+ return NR_UE_rrc_inst[ue_mod_idP].nrRrcSubState;
+}
+
+static int nr_rrc_set_state (module_id_t ue_mod_idP, Rrc_State_t state) {
+ AssertFatal ((RRC_STATE_FIRST <= state) && (state <= RRC_STATE_LAST),
+ "Invalid state %d!\n", state);
+
+ if (NR_UE_rrc_inst[ue_mod_idP].nrRrcState != state) {
+ NR_UE_rrc_inst[ue_mod_idP].nrRrcState = state;
+ return (1);
+ }
+
+ return (0);
+}
+
+static int nr_rrc_set_sub_state( module_id_t ue_mod_idP, Rrc_Sub_State_NR_t subState ) {
+ if (AMF_MODE_ENABLED) {
+ switch (NR_UE_rrc_inst[ue_mod_idP].nrRrcState) {
+ case RRC_STATE_INACTIVE_NR:
+ AssertFatal ((RRC_SUB_STATE_INACTIVE_FIRST_NR <= subState) && (subState <= RRC_SUB_STATE_INACTIVE_LAST_NR),
+ "Invalid nr sub state %d for state %d!\n", subState, NR_UE_rrc_inst[ue_mod_idP].nrRrcState);
+ break;
+
+ case RRC_STATE_IDLE_NR:
+ AssertFatal ((RRC_SUB_STATE_IDLE_FIRST_NR <= subState) && (subState <= RRC_SUB_STATE_IDLE_LAST_NR),
+ "Invalid nr sub state %d for state %d!\n", subState, NR_UE_rrc_inst[ue_mod_idP].nrRrcState);
+ break;
+
+ case RRC_STATE_CONNECTED_NR:
+ AssertFatal ((RRC_SUB_STATE_CONNECTED_FIRST_NR <= subState) && (subState <= RRC_SUB_STATE_CONNECTED_LAST_NR),
+ "Invalid nr sub state %d for state %d!\n", subState, NR_UE_rrc_inst[ue_mod_idP].nrRrcState);
+ break;
+ }
+ }
+
+ if (NR_UE_rrc_inst[ue_mod_idP].nrRrcSubState != subState) {
+ NR_UE_rrc_inst[ue_mod_idP].nrRrcSubState = subState;
+ return (1);
+ }
+
+ return (0);
+}
+
+extern boolean_t nr_rrc_pdcp_config_asn1_req(
+ const protocol_ctxt_t *const ctxt_pP,
+ NR_SRB_ToAddModList_t *const srb2add_list,
+ NR_DRB_ToAddModList_t *const drb2add_list,
+ NR_DRB_ToReleaseList_t *const drb2release_list,
+ const uint8_t security_modeP,
+ uint8_t *const kRRCenc,
+ uint8_t *const kRRCint,
+ uint8_t *const kUPenc
+ #if (LTE_RRC_VERSION >= MAKE_VERSION(9, 0, 0))
+ ,LTE_PMCH_InfoList_r9_t *pmch_InfoList_r9
+ #endif
+ ,rb_id_t *const defaultDRB,
+ struct NR_CellGroupConfig__rlc_BearerToAddModList *rlc_bearer2add_list);
+
+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_bearer2add_list);
// from LTE-RRC DL-DCCH RRCConnectionReconfiguration nr-secondary-cell-group-config (encoded)
int8_t nr_rrc_ue_decode_secondary_cellgroup_config(
@@ -384,6 +470,42 @@ int8_t nr_ue_process_spcell_config(NR_SpCellConfig_t *spcell_config){
return 0;
}
+//-----------------------------------------------------------------------------
+void rrc_ue_generate_RRCSetupRequest( const protocol_ctxt_t *const ctxt_pP, const uint8_t gNB_index ) {
+ uint8_t i=0,rv[6];
+
+ if(NR_UE_rrc_inst[ctxt_pP->module_id].Srb0[gNB_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++) {
+#ifdef SMBV
+ // if SMBV is configured the contention resolution needs to be fix for the connection procedure to succeed
+ rv[i]=i;
+#else
+ rv[i]=taus()&0xff;
+#endif
+ LOG_T(RRC,"%x.",rv[i]);
+ }
+
+ LOG_T(RRC,"\n");
+ NR_UE_rrc_inst[ctxt_pP->module_id].Srb0[gNB_index].Tx_buffer.payload_size =
+ do_RRCSetupRequest(
+ ctxt_pP->module_id,
+ (uint8_t *)NR_UE_rrc_inst[ctxt_pP->module_id].Srb0[gNB_index].Tx_buffer.Payload,
+ rv);
+ LOG_I(RRC,"[UE %d] : Frame %d, Logical Channel UL-CCCH (SRB0), Generating RRCSetupRequest (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 (i=0; imodule_id].Srb0[gNB_index].Tx_buffer.payload_size; i++) {
+ LOG_T(RRC,"%x.",NR_UE_rrc_inst[ctxt_pP->module_id].Srb0[gNB_index].Tx_buffer.Payload[i]);
+ }
+
+ LOG_T(RRC,"\n");
+ /*UE_rrc_inst[ue_mod_idP].Srb0[Idx].Tx_buffer.Payload[i] = taus()&0xff;
+ UE_rrc_inst[ue_mod_idP].Srb0[Idx].Tx_buffer.payload_size =i; */
+ }
+}
+
/*brief decode BCCH-BCH (MIB) message*/
int8_t nr_rrc_ue_decode_NR_BCCH_BCH_Message(
const module_id_t module_id,
@@ -399,9 +521,9 @@ int8_t nr_rrc_ue_decode_NR_BCCH_BCH_Message(
}
- for(i=0; i 1)
+ return "ERR";
+
+ if (value)
+ return "notReserved";
+
+ return "reserved";
+}
+
+void nr_dump_sib2( NR_SIB2_t *sib2 ){
+//cellReselectionInfoCommon
+ //nrofSS_BlocksToAverage
+ if( sib2->cellReselectionInfoCommon.nrofSS_BlocksToAverage)
+ LOG_I( RRC, "cellReselectionInfoCommon.nrofSS_BlocksToAverage : %ld\n",
+ *sib2->cellReselectionInfoCommon.nrofSS_BlocksToAverage );
+ else
+ LOG_I( RRC, "cellReselectionInfoCommon->nrofSS_BlocksToAverage : not defined\n" );
+
+ //absThreshSS_BlocksConsolidation
+ if( sib2->cellReselectionInfoCommon.absThreshSS_BlocksConsolidation){
+ LOG_I( RRC, "absThreshSS_BlocksConsolidation.thresholdRSRP : %ld\n",
+ *sib2->cellReselectionInfoCommon.absThreshSS_BlocksConsolidation->thresholdRSRP );
+ LOG_I( RRC, "absThreshSS_BlocksConsolidation.thresholdRSRQ : %ld\n",
+ *sib2->cellReselectionInfoCommon.absThreshSS_BlocksConsolidation->thresholdRSRQ );
+ LOG_I( RRC, "absThreshSS_BlocksConsolidation.thresholdSINR : %ld\n",
+ *sib2->cellReselectionInfoCommon.absThreshSS_BlocksConsolidation->thresholdSINR );
+ } else
+ LOG_I( RRC, "cellReselectionInfoCommon->absThreshSS_BlocksConsolidation : not defined\n" );
+
+ //q_Hyst
+ LOG_I( RRC, "cellReselectionInfoCommon.q_Hyst : %ld\n",
+ sib2->cellReselectionInfoCommon.q_Hyst );
+
+ //speedStateReselectionPars
+ if( sib2->cellReselectionInfoCommon.speedStateReselectionPars){
+ LOG_I( RRC, "speedStateReselectionPars->mobilityStateParameters.t_Evaluation : %ld\n",
+ sib2->cellReselectionInfoCommon.speedStateReselectionPars->mobilityStateParameters.t_Evaluation);
+ LOG_I( RRC, "speedStateReselectionPars->mobilityStateParameters.t_HystNormal : %ld\n",
+ sib2->cellReselectionInfoCommon.speedStateReselectionPars->mobilityStateParameters.t_HystNormal);
+ LOG_I( RRC, "speedStateReselectionPars->mobilityStateParameters.n_CellChangeMedium : %ld\n",
+ sib2->cellReselectionInfoCommon.speedStateReselectionPars->mobilityStateParameters.n_CellChangeMedium);
+ LOG_I( RRC, "speedStateReselectionPars->mobilityStateParameters.n_CellChangeHigh : %ld\n",
+ sib2->cellReselectionInfoCommon.speedStateReselectionPars->mobilityStateParameters.n_CellChangeHigh);
+ LOG_I( RRC, "speedStateReselectionPars->q_HystSF.sf_Medium : %ld\n",
+ sib2->cellReselectionInfoCommon.speedStateReselectionPars->q_HystSF.sf_Medium);
+ LOG_I( RRC, "speedStateReselectionPars->q_HystSF.sf_High : %ld\n",
+ sib2->cellReselectionInfoCommon.speedStateReselectionPars->q_HystSF.sf_High);
+ } else
+ LOG_I( RRC, "cellReselectionInfoCommon->speedStateReselectionPars : not defined\n" );
+
+//cellReselectionServingFreqInfo
+ if( sib2->cellReselectionServingFreqInfo.s_NonIntraSearchP)
+ LOG_I( RRC, "cellReselectionServingFreqInfo.s_NonIntraSearchP : %ld\n",
+ *sib2->cellReselectionServingFreqInfo.s_NonIntraSearchP );
+ else
+ LOG_I( RRC, "cellReselectionServingFreqInfo->s_NonIntraSearchP : not defined\n" );
+
+ if( sib2->cellReselectionServingFreqInfo.s_NonIntraSearchQ)
+ LOG_I( RRC, "cellReselectionServingFreqInfo.s_NonIntraSearchQ : %ld\n",
+ *sib2->cellReselectionServingFreqInfo.s_NonIntraSearchQ );
+ else
+ LOG_I( RRC, "cellReselectionServingFreqInfo->s_NonIntraSearchQ : not defined\n" );
+
+ LOG_I( RRC, "cellReselectionServingFreqInfo.threshServingLowP : %ld\n",
+ sib2->cellReselectionServingFreqInfo.threshServingLowP );
+
+ if( sib2->cellReselectionServingFreqInfo.threshServingLowQ)
+ LOG_I( RRC, "cellReselectionServingFreqInfo.threshServingLowQ : %ld\n",
+ *sib2->cellReselectionServingFreqInfo.threshServingLowQ );
+ else
+ LOG_I( RRC, "cellReselectionServingFreqInfo->threshServingLowQ : not defined\n" );
+
+ LOG_I( RRC, "cellReselectionServingFreqInfo.cellReselectionPriority : %ld\n",
+ sib2->cellReselectionServingFreqInfo.cellReselectionPriority );
+ if( sib2->cellReselectionServingFreqInfo.cellReselectionSubPriority)
+ LOG_I( RRC, "cellReselectionServingFreqInfo.cellReselectionSubPriority : %ld\n",
+ *sib2->cellReselectionServingFreqInfo.cellReselectionSubPriority );
+ else
+ LOG_I( RRC, "cellReselectionServingFreqInfo->cellReselectionSubPriority : not defined\n" );
+
+//intraFreqCellReselectionInfo
+ LOG_I( RRC, "intraFreqCellReselectionInfo.q_RxLevMin : %ld\n",
+ sib2->intraFreqCellReselectionInfo.q_RxLevMin );
+
+ if( sib2->intraFreqCellReselectionInfo.q_RxLevMinSUL)
+ LOG_I( RRC, "intraFreqCellReselectionInfo.q_RxLevMinSUL : %ld\n",
+ *sib2->intraFreqCellReselectionInfo.q_RxLevMinSUL );
+ else
+ LOG_I( RRC, "intraFreqCellReselectionInfo->q_RxLevMinSUL : not defined\n" );
+
+ if( sib2->intraFreqCellReselectionInfo.q_QualMin)
+ LOG_I( RRC, "intraFreqCellReselectionInfo.q_QualMin : %ld\n",
+ *sib2->intraFreqCellReselectionInfo.q_QualMin );
+ else
+ LOG_I( RRC, "intraFreqCellReselectionInfo->q_QualMin : not defined\n" );
+
+ LOG_I( RRC, "intraFreqCellReselectionInfo.s_IntraSearchP : %ld\n",
+ sib2->intraFreqCellReselectionInfo.s_IntraSearchP );
+
+ if( sib2->intraFreqCellReselectionInfo.s_IntraSearchQ)
+ LOG_I( RRC, "intraFreqCellReselectionInfo.s_IntraSearchQ : %ld\n",
+ *sib2->intraFreqCellReselectionInfo.s_IntraSearchQ );
+ else
+ LOG_I( RRC, "intraFreqCellReselectionInfo->s_IntraSearchQ : not defined\n" );
+
+ LOG_I( RRC, "intraFreqCellReselectionInfo.t_ReselectionNR : %ld\n",
+ sib2->intraFreqCellReselectionInfo.t_ReselectionNR );
+
+ if( sib2->intraFreqCellReselectionInfo.frequencyBandList)
+ LOG_I( RRC, "intraFreqCellReselectionInfo.frequencyBandList : %p\n",
+ sib2->intraFreqCellReselectionInfo.frequencyBandList );
+ else
+ LOG_I( RRC, "intraFreqCellReselectionInfo->frequencyBandList : not defined\n" );
+
+ if( sib2->intraFreqCellReselectionInfo.frequencyBandListSUL)
+ LOG_I( RRC, "intraFreqCellReselectionInfo.frequencyBandListSUL : %p\n",
+ sib2->intraFreqCellReselectionInfo.frequencyBandListSUL );
+ else
+ LOG_I( RRC, "intraFreqCellReselectionInfo->frequencyBandListSUL : not defined\n" );
+
+ if( sib2->intraFreqCellReselectionInfo.p_Max)
+ LOG_I( RRC, "intraFreqCellReselectionInfo.p_Max : %ld\n",
+ *sib2->intraFreqCellReselectionInfo.p_Max );
+ else
+ LOG_I( RRC, "intraFreqCellReselectionInfo->p_Max : not defined\n" );
+
+ if( sib2->intraFreqCellReselectionInfo.smtc)
+ LOG_I( RRC, "intraFreqCellReselectionInfo.smtc : %p\n",
+ sib2->intraFreqCellReselectionInfo.smtc );
+ else
+ LOG_I( RRC, "intraFreqCellReselectionInfo->smtc : not defined\n" );
+
+ if( sib2->intraFreqCellReselectionInfo.ss_RSSI_Measurement)
+ LOG_I( RRC, "intraFreqCellReselectionInfo.ss_RSSI_Measurement : %p\n",
+ sib2->intraFreqCellReselectionInfo.ss_RSSI_Measurement );
+ else
+ LOG_I( RRC, "intraFreqCellReselectionInfo->ss_RSSI_Measurement : not defined\n" );
+
+ if( sib2->intraFreqCellReselectionInfo.ssb_ToMeasure)
+ LOG_I( RRC, "intraFreqCellReselectionInfo.ssb_ToMeasure : %p\n",
+ sib2->intraFreqCellReselectionInfo.ssb_ToMeasure );
+ else
+ LOG_I( RRC, "intraFreqCellReselectionInfo->ssb_ToMeasure : not defined\n" );
+
+ LOG_I( RRC, "intraFreqCellReselectionInfo.deriveSSB_IndexFromCell : %d\n",
+ sib2->intraFreqCellReselectionInfo.deriveSSB_IndexFromCell );
+
+}
+
+void nr_dump_sib3( NR_SIB3_t *sib3 ) {
+//intraFreqNeighCellList
+ if( sib3->intraFreqNeighCellList){
+ LOG_I( RRC, "intraFreqNeighCellList : %p\n",
+ sib3->intraFreqNeighCellList );
+ const int n = sib3->intraFreqNeighCellList->list.count;
+ for (int i = 0; i < n; ++i){
+ LOG_I( RRC, "intraFreqNeighCellList->physCellId : %ld\n",
+ sib3->intraFreqNeighCellList->list.array[i]->physCellId );
+ LOG_I( RRC, "intraFreqNeighCellList->q_OffsetCell : %ld\n",
+ sib3->intraFreqNeighCellList->list.array[i]->q_OffsetCell );
+
+ if( sib3->intraFreqNeighCellList->list.array[i]->q_RxLevMinOffsetCell)
+ LOG_I( RRC, "intraFreqNeighCellList->q_RxLevMinOffsetCell : %ld\n",
+ *sib3->intraFreqNeighCellList->list.array[i]->q_RxLevMinOffsetCell );
+ else
+ LOG_I( RRC, "intraFreqNeighCellList->q_RxLevMinOffsetCell : not defined\n" );
+
+ if( sib3->intraFreqNeighCellList->list.array[i]->q_RxLevMinOffsetCellSUL)
+ LOG_I( RRC, "intraFreqNeighCellList->q_RxLevMinOffsetCellSUL : %ld\n",
+ *sib3->intraFreqNeighCellList->list.array[i]->q_RxLevMinOffsetCellSUL );
+ else
+ LOG_I( RRC, "intraFreqNeighCellList->q_RxLevMinOffsetCellSUL : not defined\n" );
+
+ if( sib3->intraFreqNeighCellList->list.array[i]->q_QualMinOffsetCell)
+ LOG_I( RRC, "intraFreqNeighCellList->q_QualMinOffsetCell : %ld\n",
+ *sib3->intraFreqNeighCellList->list.array[i]->q_QualMinOffsetCell );
+ else
+ LOG_I( RRC, "intraFreqNeighCellList->q_QualMinOffsetCell : not defined\n" );
+ }
+ } else{
+ LOG_I( RRC, "intraFreqCellReselectionInfo : not defined\n" );
+ }
+
+//intraFreqBlackCellList
+ if( sib3->intraFreqBlackCellList){
+ LOG_I( RRC, "intraFreqBlackCellList : %p\n",
+ sib3->intraFreqBlackCellList );
+ const int n = sib3->intraFreqBlackCellList->list.count;
+ for (int i = 0; i < n; ++i){
+ LOG_I( RRC, "intraFreqBlackCellList->start : %ld\n",
+ sib3->intraFreqBlackCellList->list.array[i]->start );
+
+ if( sib3->intraFreqBlackCellList->list.array[i]->range)
+ LOG_I( RRC, "intraFreqBlackCellList->range : %ld\n",
+ *sib3->intraFreqBlackCellList->list.array[i]->range );
+ else
+ LOG_I( RRC, "intraFreqBlackCellList->range : not defined\n" );
+ }
+ } else{
+ LOG_I( RRC, "intraFreqBlackCellList : not defined\n" );
+ }
+
+//lateNonCriticalExtension
+ if( sib3->lateNonCriticalExtension)
+ LOG_I( RRC, "lateNonCriticalExtension : %p\n",
+ sib3->lateNonCriticalExtension );
+ else
+ LOG_I( RRC, "lateNonCriticalExtension : not defined\n" );
+}
+
+int nr_decode_SI( const protocol_ctxt_t *const ctxt_pP, const uint8_t gNB_index ) {
+ NR_SystemInformation_t **si = &NR_UE_rrc_inst[ctxt_pP->module_id].si[gNB_index];
+ int new_sib = 0;
+ NR_SIB1_t *sib1 = NR_UE_rrc_inst[ctxt_pP->module_id].sib1[gNB_index];
+ VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME( VCD_SIGNAL_DUMPER_FUNCTIONS_RRC_UE_DECODE_SI, VCD_FUNCTION_IN );
+
+ // Dump contents
+ if ((*si)->criticalExtensions.present == NR_SystemInformation__criticalExtensions_PR_systemInformation ||
+ (*si)->criticalExtensions.present == NR_SystemInformation__criticalExtensions_PR_criticalExtensionsFuture_r16) {
+ LOG_D( RRC, "[UE] (*si)->criticalExtensions.choice.NR_SystemInformation_t->sib_TypeAndInfo.list.count %d\n",
+ (*si)->criticalExtensions.choice.systemInformation->sib_TypeAndInfo.list.count );
+ } else {
+ LOG_D( RRC, "[UE] Unknown criticalExtension version (not Rel16)\n" );
+ return -1;
+ }
+
+ for (int i=0; i<(*si)->criticalExtensions.choice.systemInformation->sib_TypeAndInfo.list.count; i++) {
+ SystemInformation_IEs__sib_TypeAndInfo__Member *typeandinfo;
+ typeandinfo = (*si)->criticalExtensions.choice.systemInformation->sib_TypeAndInfo.list.array[i];
+
+ switch(typeandinfo->present) {
+ case NR_SystemInformation_IEs__sib_TypeAndInfo__Member_PR_sib2:
+ if ((NR_UE_rrc_inst[ctxt_pP->module_id].Info[gNB_index].SIStatus&2) == 0) {
+ NR_UE_rrc_inst[ctxt_pP->module_id].Info[gNB_index].SIStatus|=2;
+ //new_sib=1;
+ memcpy( NR_UE_rrc_inst[ctxt_pP->module_id].sib2[gNB_index], &typeandinfo->choice.sib2, sizeof(NR_SIB2_t) );
+ LOG_I( RRC, "[UE %"PRIu8"] Frame %"PRIu32" Found SIB2 from gNB %"PRIu8"\n", ctxt_pP->module_id, ctxt_pP->frame, gNB_index );
+ nr_dump_sib2( NR_UE_rrc_inst[ctxt_pP->module_id].sib2[gNB_index] );
+ LOG_I( RRC, "[FRAME %05"PRIu32"][RRC_UE][MOD %02"PRIu8"][][--- MAC_CONFIG_REQ (SIB2 params gNB %"PRIu8") --->][MAC_UE][MOD %02"PRIu8"][]\n",
+ ctxt_pP->frame, ctxt_pP->module_id, gNB_index, ctxt_pP->module_id );
+ //TODO rrc_mac_config_req_ue
+
+ // After SI is received, prepare RRCConnectionRequest
+ if (NR_UE_rrc_inst[ctxt_pP->module_id].MBMS_flag < 3) // see -Q option
+ if (AMF_MODE_ENABLED) {
+ rrc_ue_generate_RRCSetupRequest( ctxt_pP, gNB_index );
+ }
+
+ if (NR_UE_rrc_inst[ctxt_pP->module_id].Info[gNB_index].State == NR_RRC_IDLE) {
+ LOG_I( RRC, "[UE %d] Received SIB1/SIB2/SIB3 Switching to RRC_SI_RECEIVED\n", ctxt_pP->module_id );
+ NR_UE_rrc_inst[ctxt_pP->module_id].Info[gNB_index].State = NR_RRC_SI_RECEIVED;
+#if ENABLE_RAL
+ /* TODO {
+ MessageDef *message_ral_p = NULL;
+ rrc_ral_system_information_ind_t ral_si_ind;
+ message_ral_p = itti_alloc_new_message (TASK_RRC_UE, RRC_RAL_SYSTEM_INFORMATION_IND);
+ memset(&ral_si_ind, 0, sizeof(rrc_ral_system_information_ind_t));
+ ral_si_ind.plmn_id.MCCdigit2 = '0';
+ ral_si_ind.plmn_id.MCCdigit1 = '2';
+ ral_si_ind.plmn_id.MNCdigit3 = '0';
+ ral_si_ind.plmn_id.MCCdigit3 = '8';
+ ral_si_ind.plmn_id.MNCdigit2 = '9';
+ ral_si_ind.plmn_id.MNCdigit1 = '9';
+ ral_si_ind.cell_id = 1;
+ ral_si_ind.dbm = 0;
+ //ral_si_ind.dbm = fifo_dump_emos_UE.PHY_measurements->rx_rssi_dBm[gNB_index];
+ // TO DO
+ ral_si_ind.sinr = 0;
+ //ral_si_ind.sinr = fifo_dump_emos_UE.PHY_measurements->subband_cqi_dB[gNB_index][phy_vars_ue->lte_frame_parms.nb_antennas_rx][0];
+ // TO DO
+ ral_si_ind.link_data_rate = 0;
+ memcpy (&message_ral_p->ittiMsg, (void *) &ral_si_ind, sizeof(rrc_ral_system_information_ind_t));
+#warning "ue_mod_idP ? for instance ?"
+ itti_send_msg_to_task (TASK_RAL_UE, UE_MODULE_ID_TO_INSTANCE(ctxt_pP->module_id), message_ral_p);
+ }*/
+#endif
+ }
+ }
+
+ break; // case SystemInformation_r8_IEs__sib_TypeAndInfo__Member_PR_sib2
+
+ case NR_SystemInformation_IEs__sib_TypeAndInfo__Member_PR_sib3:
+ if ((NR_UE_rrc_inst[ctxt_pP->module_id].Info[gNB_index].SIStatus&4) == 0) {
+ NR_UE_rrc_inst[ctxt_pP->module_id].Info[gNB_index].SIStatus|=4;
+ new_sib=1;
+ memcpy( NR_UE_rrc_inst[ctxt_pP->module_id].sib3[gNB_index], &typeandinfo->choice.sib3, sizeof(LTE_SystemInformationBlockType3_t) );
+ LOG_I( RRC, "[UE %"PRIu8"] Frame %"PRIu32" Found SIB3 from gNB %"PRIu8"\n", ctxt_pP->module_id, ctxt_pP->frame, gNB_index );
+ nr_dump_sib3( NR_UE_rrc_inst[ctxt_pP->module_id].sib3[gNB_index] );
+ }
+
+ break;
+
+ case NR_SystemInformation_IEs__sib_TypeAndInfo__Member_PR_sib4:
+ if ((NR_UE_rrc_inst[ctxt_pP->module_id].Info[gNB_index].SIStatus&8) == 0) {
+ NR_UE_rrc_inst[ctxt_pP->module_id].Info[gNB_index].SIStatus|=8;
+ new_sib=1;
+ memcpy( NR_UE_rrc_inst[ctxt_pP->module_id].sib4[gNB_index], typeandinfo->choice.sib4, sizeof(NR_SIB4_t) );
+ LOG_I( RRC, "[UE %"PRIu8"] Frame %"PRIu32" Found SIB4 from gNB %"PRIu8"\n", ctxt_pP->module_id, ctxt_pP->frame, gNB_index );
+ }
+
+ break;
+
+ case NR_SystemInformation_IEs__sib_TypeAndInfo__Member_PR_sib5:
+ if ((NR_UE_rrc_inst[ctxt_pP->module_id].Info[gNB_index].SIStatus&16) == 0) {
+ NR_UE_rrc_inst[ctxt_pP->module_id].Info[gNB_index].SIStatus|=16;
+ new_sib=1;
+ memcpy( NR_UE_rrc_inst[ctxt_pP->module_id].sib5[gNB_index], typeandinfo->choice.sib5, sizeof(NR_SIB5_t) );
+ LOG_I( RRC, "[UE %"PRIu8"] Frame %"PRIu32" Found SIB5 from gNB %"PRIu8"\n", ctxt_pP->module_id, ctxt_pP->frame, gNB_index );
+ //dump_sib5(NR_UE_rrc_inst[ctxt_pP->module_id].sib5[gNB_index]);
+ }
+
+ break;
+
+ case NR_SystemInformation_IEs__sib_TypeAndInfo__Member_PR_sib6:
+ if ((NR_UE_rrc_inst[ctxt_pP->module_id].Info[gNB_index].SIStatus&32) == 0) {
+ NR_UE_rrc_inst[ctxt_pP->module_id].Info[gNB_index].SIStatus|=32;
+ new_sib=1;
+ memcpy( NR_UE_rrc_inst[ctxt_pP->module_id].sib6[gNB_index], typeandinfo->choice.sib6, sizeof(NR_SIB6_t) );
+ LOG_I( RRC, "[UE %"PRIu8"] Frame %"PRIu32" Found SIB6 from gNB %"PRIu8"\n", ctxt_pP->module_id, ctxt_pP->frame, gNB_index );
+ }
+
+ break;
+
+ case NR_SystemInformation_IEs__sib_TypeAndInfo__Member_PR_sib7:
+ if ((NR_UE_rrc_inst[ctxt_pP->module_id].Info[gNB_index].SIStatus&64) == 0) {
+ NR_UE_rrc_inst[ctxt_pP->module_id].Info[gNB_index].SIStatus|=64;
+ new_sib=1;
+ memcpy( NR_UE_rrc_inst[ctxt_pP->module_id].sib7[gNB_index], typeandinfo->choice.sib7, sizeof(NR_SIB7_t) );
+ LOG_I( RRC, "[UE %"PRIu8"] Frame %"PRIu32" Found SIB7 from gNB %"PRIu8"\n", ctxt_pP->module_id, ctxt_pP->frame, gNB_index );
+ }
+
+ break;
+
+ case NR_SystemInformation_IEs__sib_TypeAndInfo__Member_PR_sib8:
+ if ((NR_UE_rrc_inst[ctxt_pP->module_id].Info[gNB_index].SIStatus&128) == 0) {
+ NR_UE_rrc_inst[ctxt_pP->module_id].Info[gNB_index].SIStatus|=128;
+ new_sib=1;
+ memcpy( NR_UE_rrc_inst[ctxt_pP->module_id].sib8[gNB_index], typeandinfo->choice.sib8, sizeof(NR_SIB8_t) );
+ LOG_I( RRC, "[UE %"PRIu8"] Frame %"PRIu32" Found SIB8 from gNB %"PRIu8"\n", ctxt_pP->module_id, ctxt_pP->frame, gNB_index );
+ }
+
+ break;
+
+ case NR_SystemInformation_IEs__sib_TypeAndInfo__Member_PR_sib9:
+ if ((NR_UE_rrc_inst[ctxt_pP->module_id].Info[gNB_index].SIStatus&256) == 0) {
+ NR_UE_rrc_inst[ctxt_pP->module_id].Info[gNB_index].SIStatus|=256;
+ new_sib=1;
+ memcpy( NR_UE_rrc_inst[ctxt_pP->module_id].sib9[gNB_index], typeandinfo->choice.sib9, sizeof(NR_SIB9_t) );
+ LOG_I( RRC, "[UE %"PRIu8"] Frame %"PRIu32" Found SIB9 from gNB %"PRIu8"\n", ctxt_pP->module_id, ctxt_pP->frame, gNB_index );
+ }
+
+ break;
+
+ case NR_SystemInformation_IEs__sib_TypeAndInfo__Member_PR_sib10_v1610:
+ if ((NR_UE_rrc_inst[ctxt_pP->module_id].Info[gNB_index].SIStatus&512) == 0) {
+ NR_UE_rrc_inst[ctxt_pP->module_id].Info[gNB_index].SIStatus|=512;
+ new_sib=1;
+ memcpy( NR_UE_rrc_inst[ctxt_pP->module_id].sib10[gNB_index], typeandinfo->choice.sib10_v1610, sizeof(NR_SIB10_r16_t) );
+ LOG_I( RRC, "[UE %"PRIu8"] Frame %"PRIu32" Found SIB10 from gNB %"PRIu8"\n", ctxt_pP->module_id, ctxt_pP->frame, gNB_index );
+ }
+
+ break;
+
+ case NR_SystemInformation_IEs__sib_TypeAndInfo__Member_PR_sib11_v1610:
+ if ((NR_UE_rrc_inst[ctxt_pP->module_id].Info[gNB_index].SIStatus&1024) == 0) {
+ NR_UE_rrc_inst[ctxt_pP->module_id].Info[gNB_index].SIStatus|=1024;
+ new_sib=1;
+ memcpy( NR_UE_rrc_inst[ctxt_pP->module_id].sib11[gNB_index], typeandinfo->choice.sib11_v1610, sizeof(NR_SIB11_r16_t) );
+ LOG_I( RRC, "[UE %"PRIu8"] Frame %"PRIu32" Found SIB11 from gNB %"PRIu8"\n", ctxt_pP->module_id, ctxt_pP->frame, gNB_index );
+ }
+
+ break;
+
+ case NR_SystemInformation_IEs__sib_TypeAndInfo__Member_PR_sib12_v1610:
+ if ((NR_UE_rrc_inst[ctxt_pP->module_id].Info[gNB_index].SIStatus&2048) == 0) {
+ NR_UE_rrc_inst[ctxt_pP->module_id].Info[gNB_index].SIStatus|=2048;
+ new_sib=1;
+ memcpy( NR_UE_rrc_inst[ctxt_pP->module_id].sib12[gNB_index], typeandinfo->choice.sib12_v1610, sizeof(NR_SIB12_r16_t) );
+ LOG_I( RRC, "[UE %"PRIu8"] Frame %"PRIu32" Found SIB12 from gNB %"PRIu8"\n", ctxt_pP->module_id, ctxt_pP->frame, gNB_index );
+ }
+
+ break;
+
+ case NR_SystemInformation_IEs__sib_TypeAndInfo__Member_PR_sib13_v1610:
+ if ((NR_UE_rrc_inst[ctxt_pP->module_id].Info[gNB_index].SIStatus&4096) == 0) {
+ NR_UE_rrc_inst[ctxt_pP->module_id].Info[gNB_index].SIStatus|=4096;
+ new_sib=1;
+ memcpy( NR_UE_rrc_inst[ctxt_pP->module_id].sib13[gNB_index], typeandinfo->choice.sib13_v1610, sizeof(NR_SIB13_r16_t) );
+ LOG_I( RRC, "[UE %"PRIu8"] Frame %"PRIu32" Found SIB13 from gNB %"PRIu8"\n", ctxt_pP->module_id, ctxt_pP->frame, gNB_index );
+ //dump_sib13( NR_UE_rrc_inst[ctxt_pP->module_id].sib13[gNB_index] );
+ // adding here function to store necessary parameters for using in decode_MCCH_Message + maybe transfer to PHY layer
+ LOG_I( RRC, "[FRAME %05"PRIu32"][RRC_UE][MOD %02"PRIu8"][][--- MAC_CONFIG_REQ (SIB13 params gNB %"PRIu8") --->][MAC_UE][MOD %02"PRIu8"][]\n",
+ ctxt_pP->frame, ctxt_pP->module_id, gNB_index, ctxt_pP->module_id);
+ // TODO rrc_mac_config_req_ue
+ }
+ break;
+
+ case NR_SystemInformation_IEs__sib_TypeAndInfo__Member_PR_sib14_v1610:
+ if ((NR_UE_rrc_inst[ctxt_pP->module_id].Info[gNB_index].SIStatus&8192) == 0) {
+ NR_UE_rrc_inst[ctxt_pP->module_id].Info[gNB_index].SIStatus|=8192;
+ new_sib=1;
+ memcpy( NR_UE_rrc_inst[ctxt_pP->module_id].sib12[gNB_index], typeandinfo->choice.sib14_v1610, sizeof(NR_SIB14_r16_t) );
+ LOG_I( RRC, "[UE %"PRIu8"] Frame %"PRIu32" Found SIB14 from gNB %"PRIu8"\n", ctxt_pP->module_id, ctxt_pP->frame, gNB_index );
+ }
+
+ break;
+
+ default:
+ break;
+ }
+ if (new_sib == 1) {
+ NR_UE_rrc_inst[ctxt_pP->module_id].Info[gNB_index].SIcnt++;
+
+ if (NR_UE_rrc_inst[ctxt_pP->module_id].Info[gNB_index].SIcnt == sib1->si_SchedulingInfo->schedulingInfoList.list.count)
+ nr_rrc_set_sub_state( ctxt_pP->module_id, RRC_SUB_STATE_IDLE_SIB_COMPLETE );
+
+ LOG_I(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->si_SchedulingInfo->schedulingInfoList.list.count);
+ }
+ }
+
+ //if (new_sib == 1) {
+ // NR_UE_rrc_inst[ctxt_pP->module_id].Info[gNB_index].SIcnt++;
+
+ // 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",
+ // 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);
+ //}
+
+ VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_RRC_UE_DECODE_SI, VCD_FUNCTION_OUT);
+ return 0;
+}
+
+int nr_decode_SIB1( const protocol_ctxt_t *const ctxt_pP, const uint8_t gNB_index, const uint8_t rsrq, const uint8_t rsrp ) {
+ NR_SIB1_t *sib1 = NR_UE_rrc_inst[ctxt_pP->module_id].sib1[gNB_index];
+ VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME( VCD_SIGNAL_DUMPER_FUNCTIONS_RRC_UE_DECODE_SIB1, VCD_FUNCTION_IN );
+ LOG_I( RRC, "[UE %d] : Dumping SIB 1\n", ctxt_pP->module_id );
+ const int n = sib1->cellAccessRelatedInfo.plmn_IdentityList.list.count;
+ for (int i = 0; i < n; ++i) {
+ NR_PLMN_Identity_t *PLMN_identity = &sib1->cellAccessRelatedInfo.plmn_IdentityList.list.array[i]->plmn_IdentityList.list.array[0];
+ int mccdigits = PLMN_identity->mcc->list.count;
+ int mncdigits = PLMN_identity->mnc.list.count;
+
+ int mcc;
+ if (mccdigits == 2) {
+ mcc = *PLMN_identity->mcc->list.array[0]*10 + *PLMN_identity->mcc->list.array[1];
+ } else {
+ mcc = *PLMN_identity->mcc->list.array[0]*100 + *PLMN_identity->mcc->list.array[1]*10 + *PLMN_identity->mcc->list.array[2];
+ }
+
+ int mnc;
+ if (mncdigits == 2) {
+ mnc = *PLMN_identity->mnc.list.array[0]*10 + *PLMN_identity->mnc.list.array[1];
+ } else {
+ mnc = *PLMN_identity->mnc.list.array[0]*100 + *PLMN_identity->mnc.list.array[1]*10 + *PLMN_identity->mnc.list.array[2];
+ }
+
+ 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) {
+ 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",
+ ((sib1->cellAccessRelatedInfo.plmn_IdentityList.list.array[0]->trackingAreaCode->size == 2)?((sib1->cellAccessRelatedInfo.plmn_IdentityList.list.array[0]->trackingAreaCode->buf[0]<<8) + sib1->cellAccessRelatedInfo.plmn_IdentityList.list.array[0]->trackingAreaCode->buf[1]):0));
+ LOG_I( RRC, "cellReservedForOperatorUse : raw:%ld decoded:%s\n", sib1->cellAccessRelatedInfo.plmn_IdentityList.list.array[0]->cellReservedForOperatorUse,
+ nr_SIBreserved(sib1->cellAccessRelatedInfo.plmn_IdentityList.list.array[0]->cellReservedForOperatorUse) );
+
+ LOG_I( RRC, "cellAccessRelatedInfo.cellIdentity : raw:%"PRIu32" decoded:%02x.%02x.%02x.%02x\n",
+ BIT_STRING_to_uint32( &sib1->cellAccessRelatedInfo.plmn_IdentityList.list.array[0]->cellIdentity ),
+ sib1->cellAccessRelatedInfo.plmn_IdentityList.list.array[0]->cellIdentity.buf[0],
+ sib1->cellAccessRelatedInfo.plmn_IdentityList.list.array[0]->cellIdentity.buf[1],
+ sib1->cellAccessRelatedInfo.plmn_IdentityList.list.array[0]->cellIdentity.buf[2],
+ sib1->cellAccessRelatedInfo.plmn_IdentityList.list.array[0]->cellIdentity.buf[3] >> sib1->cellAccessRelatedInfo.plmn_IdentityList.list.array[0]->cellIdentity.bits_unused);
+ //LOG_I( RRC, "cellAccessRelatedInfo.cellBarred : raw:%ld decoded:%s\n", sib1->cellAccessRelatedInfo.cellBarred, SIBbarred(sib1->cellAccessRelatedInfo.cellBarred) );
+ //LOG_I( RRC, "cellAccessRelatedInfo.intraFreqReselection : raw:%ld decoded:%s\n", sib1->cellAccessRelatedInfo.intraFreqReselection, SIBallowed(sib1->cellAccessRelatedInfo.intraFreqReselection) );
+ //LOG_I( RRC, "cellAccessRelatedInfo.csg_Indication : %d\n", sib1->cellAccessRelatedInfo.csg_Indication );
+
+ //if (sib1->cellAccessRelatedInfo.csg_Identity)
+ // LOG_I( RRC, "cellAccessRelatedInfo.csg_Identity : %"PRIu32"\n", BIT_STRING_to_uint32(sib1->cellAccessRelatedInfo.csg_Identity) );
+ //else
+ // LOG_I( RRC, "cellAccessRelatedInfo.csg_Identity : not defined\n" );
+
+ LOG_I( RRC, "cellSelectionInfo.q_RxLevMin : %ld\n", sib1->cellSelectionInfo->q_RxLevMin );
+
+ if (sib1->cellSelectionInfo->q_RxLevMinOffset)
+ LOG_I( RRC, "cellSelectionInfo.q_RxLevMinOffset : %ld\n", *sib1->cellSelectionInfo->q_RxLevMinOffset );
+ else
+ LOG_I( RRC, "cellSelectionInfo.q_RxLevMinOffset : not defined\n" );
+
+ //if (sib1->p_Max)
+ // LOG_I( RRC, "p_Max : %ld\n", *sib1->p_Max );
+ //else
+ // LOG_I( RRC, "p_Max : not defined\n" );
+
+ //LOG_I( RRC, "freqBandIndicator : %ld\n", sib1->freqBandIndicator );
+
+ if (sib1->si_SchedulingInfo->schedulingInfoList.list.count > 0) {
+ for (int i=0; isi_SchedulingInfo->schedulingInfoList.list.count; i++) {
+ LOG_I( RRC, "si_Periodicity[%d] : %s\n", i, SIBPeriod[min(sib1->si_SchedulingInfo->schedulingInfoList.list.array[i]->si_Periodicity,7)]);
+
+ if (sib1->si_SchedulingInfo->schedulingInfoList.list.array[i]->sib_MappingInfo.list.count > 0) {
+ char temp[32 * sizeof(SIBType[0])] = {0}; // maxSIB==32
+
+ for (int j=0; jsi_SchedulingInfo->schedulingInfoList.list.array[i]->sib_MappingInfo.list.count; j++) {
+ sprintf( temp + j*sizeof(SIBType[0]), "%*s ", (int)sizeof(SIBType[0])-1, SIBType[min(sib1->si_SchedulingInfo->schedulingInfoList.list.array[i]->sib_MappingInfo.list.array[0]->type,11)] );
+ }
+
+ LOG_I( RRC, "siSchedulingInfoSIBType[%d] : %s\n", i, temp );
+ } else {
+ LOG_I( RRC, "mapping list %d is null\n", i );
+ }
+ }
+ } else {
+ LOG_E( RRC, "siSchedulingInfoPeriod[0] : PROBLEM!!!\n" );
+ return -1;
+ }
+
+ if (sib1->servingCellConfigCommon->tdd_UL_DL_ConfigurationCommon) {
+ //TODO
+ }
+
+ LOG_I( RRC, "siWindowLength : %s\n", siWindowLength[min(sib1->si_SchedulingInfo->si_WindowLength,8)] );
+ //LOG_I( RRC, "systemInfoValueTag : %ld\n", sib1->systemInfoValueTag );
+ NR_UE_rrc_inst[ctxt_pP->module_id].Info[gNB_index].SIperiod = siPeriod_int[sib1->si_SchedulingInfo->schedulingInfoList.list.array[0]->si_Periodicity];
+ NR_UE_rrc_inst[ctxt_pP->module_id].Info[gNB_index].SIwindowsize = siWindowLength_int[sib1->si_SchedulingInfo->si_WindowLength];
+ LOG_I( RRC, "[FRAME unknown][RRC_UE][MOD %02"PRIu8"][][--- MAC_CONFIG_REQ (SIB1 params gNB %"PRIu8") --->][MAC_UE][MOD %02"PRIu8"][]\n",
+ ctxt_pP->module_id, gNB_index, ctxt_pP->module_id );
+ //rrc_mac_config_req_ue
+ LOG_I(RRC,"Setting SIStatus bit 0 to 1\n");
+ NR_UE_rrc_inst[ctxt_pP->module_id].Info[gNB_index].SIStatus = 1;
+ //NR_UE_rrc_inst[ctxt_pP->module_id].Info[gNB_index].SIB1systemInfoValueTag = sib1->systemInfoValueTag;
+
+ if (AMF_MODE_ENABLED) {
+ int cell_valid = 0;
+
+ //if (sib1->cellAccessRelatedInfo.cellBarred == LTE_SystemInformationBlockType1__cellAccessRelatedInfo__cellBarred_notBarred) {
+ /* Cell is not barred */
+ int plmn;
+ int plmn_number;
+ plmn_number = sib1->cellAccessRelatedInfo.plmn_IdentityList.list.count;
+
+ /* Compare requested PLMN and PLMNs from SIB1*/
+ for (plmn = 0; plmn < plmn_number; plmn++) {
+ NR_PLMN_Identity_t *plmn_Identity;
+ plmn_Identity = sib1->cellAccessRelatedInfo.plmn_IdentityList.list.array[plmn]->plmn_IdentityList.list.array[0];
+
+ if (
+ (
+ (plmn_Identity->mcc == NULL)
+ ||
+ (
+ (NR_UE_rrc_inst[ctxt_pP->module_id].plmnID.MCCdigit1 == *(plmn_Identity->mcc->list.array[0])) &&
+ (NR_UE_rrc_inst[ctxt_pP->module_id].plmnID.MCCdigit2 == *(plmn_Identity->mcc->list.array[1])) &&
+ (NR_UE_rrc_inst[ctxt_pP->module_id].plmnID.MCCdigit3 == *(plmn_Identity->mcc->list.array[2]))
+ )
+ )
+ &&
+ (NR_UE_rrc_inst[ctxt_pP->module_id].plmnID.MNCdigit1 == *(plmn_Identity->mnc.list.array[0]))
+ &&
+ (NR_UE_rrc_inst[ctxt_pP->module_id].plmnID.MNCdigit2 == *(plmn_Identity->mnc.list.array[1]))
+ &&
+ (
+ ((NR_UE_rrc_inst[ctxt_pP->module_id].plmnID.MNCdigit3 == 0xf) && (plmn_Identity->mnc.list.count == 2))
+ ||
+ (NR_UE_rrc_inst[ctxt_pP->module_id].plmnID.MNCdigit3 == *(plmn_Identity->mnc.list.array[2]))
+ )
+ ) {
+ /* PLMN match, send a confirmation to NAS */
+ MessageDef *msg_p;
+ msg_p = itti_alloc_new_message(TASK_RRC_UE, NAS_CELL_SELECTION_CNF);
+ NAS_CELL_SELECTION_CNF (msg_p).errCode = AS_SUCCESS;
+ NAS_CELL_SELECTION_CNF (msg_p).cellID = BIT_STRING_to_uint32(&sib1->cellAccessRelatedInfo.plmn_IdentityList.list.array[0]->cellIdentity);
+ NAS_CELL_SELECTION_CNF (msg_p).tac = BIT_STRING_to_uint16(sib1->cellAccessRelatedInfo.plmn_IdentityList.list.array[0]->trackingAreaCode);
+ NAS_CELL_SELECTION_CNF (msg_p).rat = 0xFF;
+ NAS_CELL_SELECTION_CNF (msg_p).rsrq = rsrq;
+ NAS_CELL_SELECTION_CNF (msg_p).rsrp = rsrp;
+ itti_send_msg_to_task(TASK_NAS_UE, ctxt_pP->instance, msg_p);
+ cell_valid = 1;
+ NR_UE_rrc_inst[ctxt_pP->module_id].selected_plmn_identity = plmn + 1;
+ break;
+ }
+ }
+ //}
+
+ if (cell_valid == 0) {
+ /* Cell can not be used, ask PHY to try the next one */
+ MessageDef *msg_p;
+ msg_p = itti_alloc_new_message(TASK_RRC_UE, PHY_FIND_NEXT_CELL_REQ);
+ itti_send_msg_to_task(TASK_PHY_UE, ctxt_pP->instance, msg_p);
+ LOG_E(RRC,
+ "Synched with a cell, but PLMN doesn't match our SIM "
+ "(selected_plmn_identity %d), the message PHY_FIND_NEXT_CELL_REQ "
+ "is sent but lost in current UE implementation!\n",
+ NR_UE_rrc_inst[ctxt_pP->module_id].selected_plmn_identity);
+ }
+ }
+
+ VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME( VCD_SIGNAL_DUMPER_FUNCTIONS_RRC_UE_DECODE_SIB1, VCD_FUNCTION_OUT );
+ return 0;
+}
+int nr_decode_BCCH_DLSCH_Message(
+ const protocol_ctxt_t *const ctxt_pP,
+ const uint8_t gNB_index,
+ uint8_t *const Sdu,
+ const uint8_t Sdu_len,
+ const uint8_t rsrq,
+ const uint8_t rsrp ) {
+ NR_BCCH_DL_SCH_Message_t *bcch_message = NULL;
+ NR_SIB1_t *sib1 = NR_UE_rrc_inst[ctxt_pP->module_id].sib1[gNB_index];
+ VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME( VCD_SIGNAL_DUMPER_FUNCTIONS_UE_DECODE_BCCH, VCD_FUNCTION_IN );
+
+ if (((NR_UE_rrc_inst[ctxt_pP->module_id].Info[gNB_index].SIStatus&1) == 1) && // SIB1 received
+ (NR_UE_rrc_inst[ctxt_pP->module_id].Info[gNB_index].SIcnt == sib1->si_SchedulingInfo->schedulingInfoList.list.count)) {
+ // to prevent memory bloating
+ VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME( VCD_SIGNAL_DUMPER_FUNCTIONS_UE_DECODE_BCCH, VCD_FUNCTION_OUT );
+ return 0;
+ }
+
+ nr_rrc_set_sub_state( ctxt_pP->module_id, RRC_SUB_STATE_IDLE_RECEIVING_SIB_NR );
+
+ if ( LOG_DEBUGFLAG(DEBUG_ASN1) ) {
+ xer_fprint(stdout, &asn_DEF_NR_BCCH_DL_SCH_Message,(void *)bcch_message );
+ }
+
+ asn_dec_rval_t dec_rval = uper_decode_complete( NULL,
+ &asn_DEF_NR_BCCH_DL_SCH_Message,
+ (void **)&bcch_message,
+ (const void *)Sdu,
+ Sdu_len );
+
+ if ((dec_rval.code != RC_OK) && (dec_rval.consumed == 0)) {
+ LOG_E( RRC, "[UE %"PRIu8"] Failed to decode BCCH_DLSCH_MESSAGE (%zu bits)\n",
+ ctxt_pP->module_id,
+ dec_rval.consumed );
+ log_dump(RRC, Sdu, Sdu_len, LOG_DUMP_CHAR," Received bytes:\n" );
+ // free the memory
+ SEQUENCE_free( &asn_DEF_LTE_BCCH_DL_SCH_Message, (void *)bcch_message, 1 );
+ VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME( VCD_SIGNAL_DUMPER_FUNCTIONS_UE_DECODE_BCCH, VCD_FUNCTION_OUT );
+ return -1;
+ }
+
+ if (bcch_message->message.present == NR_BCCH_DL_SCH_MessageType_PR_c1) {
+ switch (bcch_message->message.choice.c1->present) {
+ case NR_BCCH_DL_SCH_MessageType__c1_PR_systemInformationBlockType1:
+ if ((ctxt_pP->frame % 2) == 0) {
+ // even frame
+ if ((NR_UE_rrc_inst[ctxt_pP->module_id].Info[gNB_index].SIStatus&1) == 0) {
+ NR_SIB1_t *sib1 = NR_UE_rrc_inst[ctxt_pP->module_id].sib1[gNB_index];
+ memcpy( (void *)sib1,
+ (void *)bcch_message->message.choice.c1->choice.systemInformationBlockType1,
+ sizeof(NR_SIB1_t) );
+ LOG_D( RRC, "[UE %"PRIu8"] Decoding First SIB1\n", ctxt_pP->module_id );
+ nr_decode_SIB1( ctxt_pP, gNB_index, rsrq, rsrp );
+ }
+ }
+
+ break;
+
+ case NR_BCCH_DL_SCH_MessageType__c1_PR_systemInformation:
+ if ((NR_UE_rrc_inst[ctxt_pP->module_id].Info[gNB_index].SIStatus&1) == 1) {
+ // SIB1 with schedulingInfoList is available
+ NR_SystemInformation_t *si = NR_UE_rrc_inst[ctxt_pP->module_id].si[gNB_index];
+ memcpy( si,
+ bcch_message->message.choice.c1->choice.systemInformation,
+ sizeof(NR_SystemInformation_t) );
+ LOG_I( RRC, "[UE %"PRIu8"] Decoding SI for frameP %"PRIu32"\n",
+ ctxt_pP->module_id,
+ ctxt_pP->frame );
+ nr_decode_SI( ctxt_pP, gNB_index );
+ //if (nfapi_mode == 3)
+ //UE_mac_inst[ctxt_pP->module_id].SI_Decoded = 1;
+ }
+
+ break;
+
+ case NR_BCCH_DL_SCH_MessageType__c1_PR_NOTHING:
+ default:
+ break;
+ }
+ }
+
+ if (nr_rrc_get_sub_state(ctxt_pP->module_id) == RRC_SUB_STATE_IDLE_SIB_COMPLETE_NR) {
+ //if ( (NR_UE_rrc_inst[ctxt_pP->module_id].initialNasMsg.data != NULL) || (!AMF_MODE_ENABLED)) {
+ rrc_ue_generate_RRCSetupRequest(ctxt_pP, 0);
+ nr_rrc_set_sub_state( ctxt_pP->module_id, RRC_SUB_STATE_IDLE_CONNECTING );
+ //}
+ }
+
+ VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME( VCD_SIGNAL_DUMPER_FUNCTIONS_UE_DECODE_BCCH, VCD_FUNCTION_OUT );
+ return 0;
+}
+
+//-----------------------------------------------------------------------------
+void
+nr_rrc_ue_process_masterCellGroup(
+ const protocol_ctxt_t *const ctxt_pP,
+ uint8_t gNB_index,
+ OCTET_STRING_t *masterCellGroup
+)
+//-----------------------------------------------------------------------------
+{
+ NR_CellGroupConfig_t *cellGroupConfig = (NR_CellGroupConfig_t *)masterCellGroup;
+ if( cellGroupConfig->spCellConfig != NULL && cellGroupConfig->spCellConfig->reconfigurationWithSync != NULL){
+ //TODO (perform Reconfiguration with sync according to 5.3.5.5.2)
+ //TODO (resume all suspended radio bearers and resume SCG transmission for all radio bearers, if suspended)
+ }
+
+ if( cellGroupConfig->rlc_BearerToReleaseList != NULL){
+ //TODO (perform RLC bearer release as specified in 5.3.5.5.3)
+ }
+
+ if( cellGroupConfig->rlc_BearerToAddModList != NULL){
+ //TODO (perform the RLC bearer addition/modification as specified in 5.3.5.5.4)
+ }
+
+ if( cellGroupConfig->mac_CellGroupConfig != NULL){
+ //TODO (configure the MAC entity of this cell group as specified in 5.3.5.5.5)
+ }
+
+ if( cellGroupConfig->sCellToReleaseList != NULL){
+ //TODO (perform SCell release as specified in 5.3.5.5.8)
+ }
+
+ if( cellGroupConfig->spCellConfig != NULL){
+ if (NR_UE_rrc_inst[ctxt_pP->module_id].cell_group_config->spCellConfig) {
+ memcpy(NR_UE_rrc_inst[ctxt_pP->module_id].cell_group_config->spCellConfig,cellGroupConfig->spCellConfig,
+ sizeof(struct NR_SpCellConfig));
+ } else {
+ NR_UE_rrc_inst[ctxt_pP->module_id].cell_group_config->spCellConfig = cellGroupConfig->spCellConfig;
+ }
+ //TODO (configure the SpCell as specified in 5.3.5.5.7)
+ }
+
+ if( cellGroupConfig->sCellToAddModList != NULL){
+ //TODO (perform SCell addition/modification as specified in 5.3.5.5.9)
+ }
+
+ if( cellGroupConfig->ext2->bh_RLC_ChannelToReleaseList_r16 != NULL){
+ //TODO (perform the BH RLC channel addition/modification as specified in 5.3.5.5.11)
+ }
+
+ if( cellGroupConfig->ext2->bh_RLC_ChannelToAddModList_r16 != NULL){
+ //TODO (perform the BH RLC channel addition/modification as specified in 5.3.5.5.11)
+ }
+
+}
+
+/*--------------------------------------------------*/
+static void rrc_ue_generate_RRCSetupComplete(
+ const protocol_ctxt_t *const ctxt_pP,
+ const uint8_t gNB_index,
+ const uint8_t Transaction_id,
+ uint8_t sel_plmn_id){
+ uint8_t buffer[100];
+ uint8_t size;
+ const char *nas_msg;
+ int nas_msg_length;
+ /*
+ if (EPC_MODE_ENABLED) {
+ nas_msg = (char *) UE_rrc_inst[ctxt_pP->module_id].initialNasMsg.data;
+ nas_msg_length = UE_rrc_inst[ctxt_pP->module_id].initialNasMsg.length;
+ } else {
+ nas_msg = nas_attach_req_imsi;
+ nas_msg_length = sizeof(nas_attach_req_imsi);
+ }
+ */
+ size = do_RRCSetupComplete(ctxt_pP->module_id,buffer,Transaction_id,sel_plmn_id,nas_msg_length,nas_msg);
+ LOG_I(RRC,"[UE %d][RAPROC] Frame %d : Logical Channel UL-DCCH (SRB1), Generating RRCConnectionSetupComplete (bytes%d, gNB %d)\n",
+ ctxt_pP->module_id,ctxt_pP->frame, size, gNB_index);
+ LOG_D(RLC,
+ "[FRAME %05d][RRC_UE][MOD %02d][][--- PDCP_DATA_REQ/%d Bytes (RRCConnectionSetupComplete to gNB %d MUI %d) --->][PDCP][MOD %02d][RB %02d]\n",
+ ctxt_pP->frame, ctxt_pP->module_id+NB_RN_INST, size, gNB_index, nr_rrc_mui, ctxt_pP->module_id+NB_eNB_INST, DCCH);
+ // ctxt_pP_local.rnti = ctxt_pP->rnti;
+ rrc_data_req_ue(
+ ctxt_pP,
+ DCCH,
+ nr_rrc_mui++,
+ SDU_CONFIRM_NO,
+ size,
+ buffer,
+ PDCP_TRANSMISSION_MODE_CONTROL);
+}
+
+int8_t nr_rrc_ue_decode_ccch( const protocol_ctxt_t *const ctxt_pP, const SRB_INFO *const Srb_info, const uint8_t gNB_index ){
+ NR_DL_CCCH_Message_t *dl_ccch_msg=NULL;
+ asn_dec_rval_t dec_rval;
+ int rval=0;
+ VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_UE_DECODE_CCCH, VCD_FUNCTION_IN);
+ // LOG_D(RRC,"[UE %d] Decoding DL-CCCH message (%d bytes), State %d\n",ue_mod_idP,Srb_info->Rx_buffer.payload_size,
+ // NR_UE_rrc_inst[ue_mod_idP].Info[gNB_index].State);
+ dec_rval = uper_decode(NULL,
+ &asn_DEF_NR_DL_CCCH_Message,
+ (void **)&dl_ccch_msg,
+ (uint8_t *)Srb_info->Rx_buffer.Payload,
+ 100,0,0);
+
+ if ( LOG_DEBUGFLAG(DEBUG_ASN1) ) {
+ xer_fprint(stdout,&asn_DEF_NR_DL_CCCH_Message,(void *)dl_ccch_msg);
+ }
+
+ if ((dec_rval.code != RC_OK) && (dec_rval.consumed==0)) {
+ LOG_E(RRC,"[UE %d] Frame %d : Failed to decode DL-CCCH-Message (%zu bytes)\n",ctxt_pP->module_id,ctxt_pP->frame,dec_rval.consumed);
+ VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_UE_DECODE_CCCH, VCD_FUNCTION_OUT);
+ return -1;
+ }
+
+ if (dl_ccch_msg->message.present == NR_DL_CCCH_MessageType_PR_c1) {
+ if (NR_UE_rrc_inst[ctxt_pP->module_id].Info[gNB_index].State == RRC_SI_RECEIVED) {
+ switch (dl_ccch_msg->message.choice.c1->present) {
+ case NR_DL_CCCH_MessageType__c1_PR_NOTHING:
+ LOG_I(RRC, "[UE%d] Frame %d : Received PR_NOTHING on DL-CCCH-Message\n",
+ ctxt_pP->module_id,
+ ctxt_pP->frame);
+ rval = 0;
+ break;
+
+ case NR_DL_CCCH_MessageType__c1_PR_rrcReject:
+ LOG_I(RRC,
+ "[UE%d] Frame %d : Logical Channel DL-CCCH (SRB0), Received RRCConnectionReject \n",
+ ctxt_pP->module_id,
+ ctxt_pP->frame);
+ rval = 0;
+ break;
+
+ case NR_DL_CCCH_MessageType__c1_PR_rrcSetup:
+ LOG_I(RRC,
+ "[UE%d][RAPROC] Frame %d : Logical Channel DL-CCCH (SRB0), Received NR_RRCSetup RNTI %x\n",
+ ctxt_pP->module_id,
+ ctxt_pP->frame,
+ ctxt_pP->rnti);
+ // Get configuration
+ // Release T300 timer
+ NR_UE_rrc_inst[ctxt_pP->module_id].Info[gNB_index].T300_active = 0;
+
+ nr_rrc_ue_process_masterCellGroup(
+ 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_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;
+ rrc_ue_generate_RRCSetupComplete(
+ ctxt_pP,
+ gNB_index,
+ dl_ccch_msg->message.choice.c1->choice.rrcSetup->rrc_TransactionIdentifier,
+ NR_UE_rrc_inst[ctxt_pP->module_id].selected_plmn_identity);
+ rval = 0;
+ break;
+
+ default:
+ LOG_E(RRC, "[UE%d] Frame %d : Unknown message\n",
+ ctxt_pP->module_id,
+ ctxt_pP->frame);
+ rval = -1;
+ break;
+ }
+ }
+ }
+
+ VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_UE_DECODE_CCCH, VCD_FUNCTION_OUT);
+ return rval;
+
+}
+
// from NR SRB3
int8_t nr_rrc_ue_decode_NR_DL_DCCH_Message(
@@ -507,3 +1519,807 @@ int8_t nr_rrc_ue_decode_NR_DL_DCCH_Message(
return 0;
}
+
+
+//-----------------------------------------------------------------------------
+void
+nr_rrc_ue_process_securityModeCommand(
+ const protocol_ctxt_t *const ctxt_pP,
+ NR_SecurityModeCommand_t *const securityModeCommand,
+ const uint8_t gNB_index
+)
+//-----------------------------------------------------------------------------
+{
+ asn_enc_rval_t enc_rval;
+ NR_UL_DCCH_Message_t ul_dcch_msg;
+ uint8_t buffer[200];
+ int i, securityMode;
+ LOG_I(RRC,"[UE %d] SFN/SF %d/%d: Receiving from SRB1 (DL-DCCH), Processing securityModeCommand (gNB %d)\n",
+ ctxt_pP->module_id,ctxt_pP->frame, ctxt_pP->subframe, gNB_index);
+
+ switch (securityModeCommand->criticalExtensions.choice.securityModeCommand->securityConfigSMC.securityAlgorithmConfig.cipheringAlgorithm) {
+ case NR_CipheringAlgorithm_nea0:
+ LOG_I(RRC,"[UE %d] Security algorithm is set to nea0\n",
+ ctxt_pP->module_id);
+ securityMode= NR_CipheringAlgorithm_nea0;
+ break;
+
+ case NR_CipheringAlgorithm_nea1:
+ LOG_I(RRC,"[UE %d] Security algorithm is set to nea1\n",ctxt_pP->module_id);
+ securityMode= NR_CipheringAlgorithm_nea1;
+ break;
+
+ case NR_CipheringAlgorithm_nea2:
+ LOG_I(RRC,"[UE %d] Security algorithm is set to nea2\n",
+ ctxt_pP->module_id);
+ securityMode = NR_CipheringAlgorithm_nea2;
+ break;
+
+ default:
+ LOG_I(RRC,"[UE %d] Security algorithm is set to none\n",ctxt_pP->module_id);
+ securityMode = NR_CipheringAlgorithm_spare1;
+ break;
+ }
+
+ switch (*securityModeCommand->criticalExtensions.choice.securityModeCommand->securityConfigSMC.securityAlgorithmConfig.integrityProtAlgorithm) {
+ case NR_IntegrityProtAlgorithm_nia1:
+ LOG_I(RRC,"[UE %d] Integrity protection algorithm is set to nia1\n",ctxt_pP->module_id);
+ securityMode |= 1 << 5;
+ break;
+
+ case NR_IntegrityProtAlgorithm_nia2:
+ LOG_I(RRC,"[UE %d] Integrity protection algorithm is set to nia2\n",ctxt_pP->module_id);
+ securityMode |= 1 << 6;
+ break;
+
+ default:
+ LOG_I(RRC,"[UE %d] Integrity protection algorithm is set to none\n",ctxt_pP->module_id);
+ securityMode |= 0x70 ;
+ break;
+ }
+
+ LOG_D(RRC,"[UE %d] security mode is %x \n",ctxt_pP->module_id, securityMode);
+ NR_UE_rrc_inst->cipheringAlgorithm =
+ securityModeCommand->criticalExtensions.choice.securityModeCommand->securityConfigSMC.securityAlgorithmConfig.cipheringAlgorithm;
+ NR_UE_rrc_inst->integrityProtAlgorithm =
+ *securityModeCommand->criticalExtensions.choice.securityModeCommand->securityConfigSMC.securityAlgorithmConfig.integrityProtAlgorithm;
+memset((void *)&ul_dcch_msg,0,sizeof(NR_UL_DCCH_Message_t));
+ //memset((void *)&SecurityModeCommand,0,sizeof(SecurityModeCommand_t));
+ ul_dcch_msg.message.present = NR_UL_DCCH_MessageType_PR_c1;
+ ul_dcch_msg.message.choice.c1 = calloc(1, sizeof(*ul_dcch_msg.message.choice.c1));
+
+ if (securityMode >= NO_SECURITY_MODE) {
+ LOG_I(RRC, "rrc_ue_process_securityModeCommand, security mode complete case \n");
+ ul_dcch_msg.message.choice.c1->present = NR_UL_DCCH_MessageType__c1_PR_securityModeComplete;
+ } else {
+ LOG_I(RRC, "rrc_ue_process_securityModeCommand, security mode failure case \n");
+ ul_dcch_msg.message.choice.c1->present = NR_UL_DCCH_MessageType__c1_PR_securityModeFailure;
+ }
+
+ uint8_t *kRRCenc = NULL;
+ uint8_t *kUPenc = NULL;
+ uint8_t *kRRCint = NULL;
+ pdcp_t *pdcp_p = NULL;
+ hash_key_t key = HASHTABLE_NOT_A_KEY_VALUE;
+ hashtable_rc_t h_rc;
+ key = PDCP_COLL_KEY_VALUE(ctxt_pP->module_id, ctxt_pP->rnti,
+ ctxt_pP->enb_flag, DCCH, SRB_FLAG_YES);
+ h_rc = hashtable_get(pdcp_coll_p, key, (void **) &pdcp_p);
+
+ if (h_rc == HASH_TABLE_OK) {
+ LOG_D(RRC, "PDCP_COLL_KEY_VALUE() returns valid key = %ld\n", key);
+ LOG_D(RRC, "driving kRRCenc, kRRCint and kUPenc from KgNB="
+ "%02x%02x%02x%02x"
+ "%02x%02x%02x%02x"
+ "%02x%02x%02x%02x"
+ "%02x%02x%02x%02x"
+ "%02x%02x%02x%02x"
+ "%02x%02x%02x%02x"
+ "%02x%02x%02x%02x"
+ "%02x%02x%02x%02x\n",
+ NR_UE_rrc_inst->kgnb[0], NR_UE_rrc_inst->kgnb[1], NR_UE_rrc_inst->kgnb[2], NR_UE_rrc_inst->kgnb[3],
+ NR_UE_rrc_inst->kgnb[4], NR_UE_rrc_inst->kgnb[5], NR_UE_rrc_inst->kgnb[6], NR_UE_rrc_inst->kgnb[7],
+ NR_UE_rrc_inst->kgnb[8], NR_UE_rrc_inst->kgnb[9], NR_UE_rrc_inst->kgnb[10], NR_UE_rrc_inst->kgnb[11],
+ NR_UE_rrc_inst->kgnb[12], NR_UE_rrc_inst->kgnb[13], NR_UE_rrc_inst->kgnb[14], NR_UE_rrc_inst->kgnb[15],
+ NR_UE_rrc_inst->kgnb[16], NR_UE_rrc_inst->kgnb[17], NR_UE_rrc_inst->kgnb[18], NR_UE_rrc_inst->kgnb[19],
+ NR_UE_rrc_inst->kgnb[20], NR_UE_rrc_inst->kgnb[21], NR_UE_rrc_inst->kgnb[22], NR_UE_rrc_inst->kgnb[23],
+ NR_UE_rrc_inst->kgnb[24], NR_UE_rrc_inst->kgnb[25], NR_UE_rrc_inst->kgnb[26], NR_UE_rrc_inst->kgnb[27],
+ NR_UE_rrc_inst->kgnb[28], NR_UE_rrc_inst->kgnb[29], NR_UE_rrc_inst->kgnb[30], NR_UE_rrc_inst->kgnb[31]);
+ derive_key_rrc_enc(NR_UE_rrc_inst->cipheringAlgorithm,NR_UE_rrc_inst->kgnb, &kRRCenc);
+ derive_key_rrc_int(NR_UE_rrc_inst->integrityProtAlgorithm,NR_UE_rrc_inst->kgnb, &kRRCint);
+ derive_key_up_enc(NR_UE_rrc_inst->cipheringAlgorithm,NR_UE_rrc_inst->kgnb, &kUPenc);
+
+ if (securityMode != 0xff) {
+ pdcp_config_set_security(ctxt_pP, pdcp_p, 0, 0,
+ NR_UE_rrc_inst->cipheringAlgorithm
+ | (NR_UE_rrc_inst->integrityProtAlgorithm << 4),
+ kRRCenc, kRRCint, kUPenc);
+ } else {
+ LOG_I(RRC, "skipped pdcp_config_set_security() as securityMode == 0x%02x",
+ securityMode);
+ }
+ } else {
+ LOG_I(RRC, "Could not get PDCP instance where key=0x%ld\n", key);
+ }
+
+ if (securityModeCommand->criticalExtensions.present == NR_SecurityModeCommand__criticalExtensions_PR_securityModeCommand) {
+
+ ul_dcch_msg.message.choice.c1->choice.securityModeComplete->rrc_TransactionIdentifier = securityModeCommand->rrc_TransactionIdentifier;
+ ul_dcch_msg.message.choice.c1->choice.securityModeComplete->criticalExtensions.present = NR_SecurityModeComplete__criticalExtensions_PR_securityModeComplete;
+ ul_dcch_msg.message.choice.c1->choice.securityModeComplete->criticalExtensions.choice.securityModeComplete->nonCriticalExtension =NULL;
+ LOG_I(RRC,"[UE %d] SFN/SF %d/%d: Receiving from SRB1 (DL-DCCH), encoding securityModeComplete (gNB %d), rrc_TransactionIdentifier: %ld\n",
+ ctxt_pP->module_id,ctxt_pP->frame, ctxt_pP->subframe, gNB_index, securityModeCommand->rrc_TransactionIdentifier);
+ enc_rval = uper_encode_to_buffer(&asn_DEF_NR_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_NR_UL_DCCH_Message, (void *)&ul_dcch_msg);
+ }
+
+ LOG_D(RRC, "securityModeComplete Encoded %zd bits (%zd bytes)\n", enc_rval.encoded, (enc_rval.encoded+7)/8);
+
+ for (i = 0; i < (enc_rval.encoded + 7) / 8; i++) {
+ LOG_T(RRC, "%02x.", buffer[i]);
+ }
+
+ LOG_T(RRC, "\n");
+ rrc_data_req (
+ ctxt_pP,
+ DCCH,
+ nr_rrc_mui++,
+ SDU_CONFIRM_NO,
+ (enc_rval.encoded + 7) / 8,
+ buffer,
+ PDCP_TRANSMISSION_MODE_CONTROL);
+ } else LOG_W(RRC,"securityModeCommand->criticalExtensions.present (%d) != NR_SecurityModeCommand__criticalExtensions_PR_securityModeCommand\n",
+ securityModeCommand->criticalExtensions.present);
+}
+
+//-----------------------------------------------------------------------------
+int32_t
+nr_rrc_ue_establish_srb1(
+ module_id_t ue_mod_idP,
+ frame_t frameP,
+ uint8_t gNB_index,
+ NR_SRB_ToAddMod_t *SRB_config
+)
+//-----------------------------------------------------------------------------
+{
+ // add descriptor from RRC PDU
+ NR_UE_rrc_inst[ue_mod_idP].Srb1[gNB_index].Active = 1;
+ NR_UE_rrc_inst[ue_mod_idP].Srb1[gNB_index].Status = RADIO_CONFIG_OK;//RADIO CFG
+ NR_UE_rrc_inst[ue_mod_idP].Srb1[gNB_index].Srb_info.Srb_id = 1;
+ LOG_I(NR_RRC, "[UE %d], CONFIG_SRB1 %d corresponding to gNB_index %d\n", ue_mod_idP, DCCH, gNB_index);
+ return(0);
+}
+
+//-----------------------------------------------------------------------------
+int32_t
+nr_rrc_ue_establish_srb2(
+ module_id_t ue_mod_idP,
+ frame_t frameP,
+ uint8_t gNB_index,
+ NR_SRB_ToAddMod_t *SRB_config
+)
+//-----------------------------------------------------------------------------
+{
+ // add descriptor from RRC PDU
+ NR_UE_rrc_inst[ue_mod_idP].Srb2[gNB_index].Active = 1;
+ NR_UE_rrc_inst[ue_mod_idP].Srb2[gNB_index].Status = RADIO_CONFIG_OK;//RADIO CFG
+ NR_UE_rrc_inst[ue_mod_idP].Srb2[gNB_index].Srb_info.Srb_id = 2;
+ LOG_I(NR_RRC, "[UE %d], CONFIG_SRB2 %d corresponding to gNB_index %d\n", ue_mod_idP, DCCH1, gNB_index);
+ return(0);
+}
+
+//-----------------------------------------------------------------------------
+int32_t
+nr_rrc_ue_establish_drb(
+ module_id_t ue_mod_idP,
+ frame_t frameP,
+ uint8_t gNB_index,
+ NR_DRB_ToAddMod_t *DRB_config
+)
+//-----------------------------------------------------------------------------
+{
+ // add descriptor from RRC PDU
+ int oip_ifup = 0, ip_addr_offset3 = 0, ip_addr_offset4 = 0;
+ /* avoid gcc warnings */
+ (void)oip_ifup;
+ (void)ip_addr_offset3;
+ (void)ip_addr_offset4;
+ LOG_I(NR_RRC,"[UE %d] Frame %d: processing RRCReconfiguration: reconfiguring DRB %ld\n",
+ ue_mod_idP, frameP, DRB_config->drb_Identity);
+
+ if(!AMF_MODE_ENABLED) {
+ ip_addr_offset3 = 0;
+ ip_addr_offset4 = 1;
+ LOG_I(OIP, "[UE %d] trying to bring up the OAI interface %d, IP X.Y.%d.%d\n", ue_mod_idP, ip_addr_offset3+ue_mod_idP,
+ ip_addr_offset3+ue_mod_idP+1, ip_addr_offset4+ue_mod_idP+1);
+ oip_ifup = nas_config(ip_addr_offset3+ue_mod_idP+1, // interface_id
+ UE_NAS_USE_TUN?1:(ip_addr_offset3+ue_mod_idP+1), // third_octet
+ ip_addr_offset4+ue_mod_idP+1, // fourth_octet
+ "oip"); // interface suffix (when using kernel module)
+
+ if (oip_ifup == 0 && (!UE_NAS_USE_TUN)) { // interface is up --> send a config the DRB
+ LOG_I(OIP, "[UE %d] Config the ue net interface %d to send/receive pkt on DRB %ld to/from the protocol stack\n",
+ ue_mod_idP,
+ ip_addr_offset3+ue_mod_idP,
+ (long int)((gNB_index * NR_maxDRB) + DRB_config->drb_Identity));
+ rb_conf_ipv4(0,//add
+ ue_mod_idP,//cx align with the UE index
+ ip_addr_offset3+ue_mod_idP,//inst num_enb+ue_index
+ (gNB_index * NR_maxDRB) + DRB_config->drb_Identity,//rb
+ 0,//dscp
+ ipv4_address(ip_addr_offset3+ue_mod_idP+1, ip_addr_offset4+ue_mod_idP+1),//saddr
+ ipv4_address(ip_addr_offset3+ue_mod_idP+1, gNB_index+1));//daddr
+ LOG_D(NR_RRC,"[UE %d] State = Attached (gNB %d)\n",ue_mod_idP,gNB_index);
+ }
+ }
+
+ return(0);
+}
+
+//-----------------------------------------------------------------------------
+void
+nr_rrc_ue_process_measConfig(
+ const protocol_ctxt_t *const ctxt_pP,
+ const uint8_t gNB_index,
+ NR_MeasConfig_t *const measConfig
+)
+//-----------------------------------------------------------------------------
+{
+ int i;
+ long ind;
+ NR_MeasObjectToAddMod_t *measObj = NULL;
+ NR_ReportConfigToAddMod_t *reportConfig = NULL;
+
+ if (measConfig->measObjectToRemoveList != NULL) {
+ for (i = 0; i < measConfig->measObjectToRemoveList->list.count; i++) {
+ ind = *measConfig->measObjectToRemoveList->list.array[i];
+ free(NR_UE_rrc_inst[ctxt_pP->module_id].MeasObj[gNB_index][ind-1]);
+ }
+ }
+
+ if (measConfig->measObjectToAddModList != NULL) {
+ LOG_I(NR_RRC, "Measurement Object List is present\n");
+ for (i = 0; i < measConfig->measObjectToAddModList->list.count; i++) {
+ measObj = measConfig->measObjectToAddModList->list.array[i];
+ ind = measConfig->measObjectToAddModList->list.array[i]->measObjectId;
+
+ if (NR_UE_rrc_inst[ctxt_pP->module_id].MeasObj[gNB_index][ind-1]) {
+ LOG_D(NR_RRC, "Modifying measurement object %ld\n",ind);
+ memcpy((char *)NR_UE_rrc_inst[ctxt_pP->module_id].MeasObj[gNB_index][ind-1],
+ (char *)measObj,
+ sizeof(NR_MeasObjectToAddMod_t));
+ } else {
+ LOG_I(NR_RRC, "Adding measurement object %ld\n", ind);
+
+ if (measObj->measObject.present == NR_MeasObjectToAddMod__measObject_PR_measObjectNR) {
+ NR_UE_rrc_inst[ctxt_pP->module_id].MeasObj[gNB_index][ind-1]=measObj;
+ }
+ }
+ }
+
+ LOG_I(NR_RRC, "call rrc_mac_config_req \n");
+ // rrc_mac_config_req_ue
+ }
+
+ if (measConfig->reportConfigToRemoveList != NULL) {
+ for (i = 0; i < measConfig->reportConfigToRemoveList->list.count; i++) {
+ ind = *measConfig->reportConfigToRemoveList->list.array[i];
+ free(NR_UE_rrc_inst[ctxt_pP->module_id].ReportConfig[gNB_index][ind-1]);
+ }
+ }
+
+ if (measConfig->reportConfigToAddModList != NULL) {
+ LOG_I(NR_RRC,"Report Configuration List is present\n");
+ for (i = 0; i < measConfig->reportConfigToAddModList->list.count; i++) {
+ ind = measConfig->reportConfigToAddModList->list.array[i]->reportConfigId;
+ reportConfig = measConfig->reportConfigToAddModList->list.array[i];
+
+ if (NR_UE_rrc_inst[ctxt_pP->module_id].ReportConfig[gNB_index][ind-1]) {
+ LOG_I(NR_RRC, "Modifying Report Configuration %ld\n", ind-1);
+ memcpy((char *)NR_UE_rrc_inst[ctxt_pP->module_id].ReportConfig[gNB_index][ind-1],
+ (char *)measConfig->reportConfigToAddModList->list.array[i],
+ sizeof(NR_ReportConfigToAddMod_t));
+ } else {
+ LOG_D(RRC,"Adding Report Configuration %ld %p \n", ind-1, measConfig->reportConfigToAddModList->list.array[i]);
+ if (reportConfig->reportConfig.present == NR_ReportConfigToAddMod__reportConfig_PR_reportConfigNR) {
+ NR_UE_rrc_inst[ctxt_pP->module_id].ReportConfig[gNB_index][ind-1] = measConfig->reportConfigToAddModList->list.array[i];
+ }
+ }
+ }
+ }
+
+ if (measConfig->measIdToRemoveList != NULL) {
+ for (i = 0; i < measConfig->measIdToRemoveList->list.count; i++) {
+ ind = *measConfig->measIdToRemoveList->list.array[i];
+ free(NR_UE_rrc_inst[ctxt_pP->module_id].MeasId[gNB_index][ind-1]);
+ }
+ }
+
+ if (measConfig->measIdToAddModList != NULL) {
+ for (i = 0; i < measConfig->measIdToAddModList->list.count; i++) {
+ ind = measConfig->measIdToAddModList->list.array[i]->measId;
+
+ if (NR_UE_rrc_inst[ctxt_pP->module_id].MeasId[gNB_index][ind-1]) {
+ LOG_D(NR_RRC, "Modifying Measurement ID %ld\n",ind-1);
+ memcpy((char *)NR_UE_rrc_inst[ctxt_pP->module_id].MeasId[gNB_index][ind-1],
+ (char *)measConfig->measIdToAddModList->list.array[i],
+ sizeof(NR_MeasIdToAddMod_t));
+ } else {
+ LOG_D(NR_RRC, "Adding Measurement ID %ld %p\n", ind-1, measConfig->measIdToAddModList->list.array[i]);
+ NR_UE_rrc_inst[ctxt_pP->module_id].MeasId[gNB_index][ind-1] = measConfig->measIdToAddModList->list.array[i];
+ }
+ }
+ }
+
+ if (measConfig->quantityConfig != NULL) {
+ if (NR_UE_rrc_inst[ctxt_pP->module_id].QuantityConfig[gNB_index]) {
+ LOG_D(RRC,"Modifying Quantity Configuration \n");
+ memcpy((char *)NR_UE_rrc_inst[ctxt_pP->module_id].QuantityConfig[gNB_index],
+ (char *)measConfig->quantityConfig,
+ sizeof(NR_QuantityConfig_t));
+ } else {
+ LOG_D(NR_RRC, "Adding Quantity configuration\n");
+ NR_UE_rrc_inst[ctxt_pP->module_id].QuantityConfig[gNB_index] = measConfig->quantityConfig;
+ }
+ }
+
+ if (measConfig->measGapConfig != NULL) {
+ if (NR_UE_rrc_inst[ctxt_pP->module_id].measGapConfig[gNB_index]) {
+ memcpy((char *)NR_UE_rrc_inst[ctxt_pP->module_id].measGapConfig[gNB_index],
+ (char *)measConfig->measGapConfig,
+ sizeof(NR_MeasGapConfig_t));
+ } else {
+ NR_UE_rrc_inst[ctxt_pP->module_id].measGapConfig[gNB_index] = measConfig->measGapConfig;
+ }
+ }
+
+ if (measConfig->s_MeasureConfig->present == NR_MeasConfig__s_MeasureConfig_PR_ssb_RSRP) {
+ NR_UE_rrc_inst[ctxt_pP->module_id].s_measure = measConfig->s_MeasureConfig->choice.ssb_RSRP;
+ } else if (measConfig->s_MeasureConfig->present == NR_MeasConfig__s_MeasureConfig_PR_csi_RSRP) {
+ NR_UE_rrc_inst[ctxt_pP->module_id].s_measure = measConfig->s_MeasureConfig->choice.csi_RSRP;
+ }
+}
+
+//-----------------------------------------------------------------------------
+void
+nr_sa_rrc_ue_process_radioBearerConfig(
+ const protocol_ctxt_t *const ctxt_pP,
+ const uint8_t gNB_index,
+ NR_RadioBearerConfig_t *const radioBearerConfig
+)
+//-----------------------------------------------------------------------------
+{
+ long SRB_id, DRB_id;
+ int i, cnt;
+
+ if( radioBearerConfig->srb3_ToRelease != NULL){
+ if( *radioBearerConfig->srb3_ToRelease == TRUE){
+ //TODO (release the PDCP entity and the srb-Identity of the SRB3.)
+ }
+ }
+
+ if (radioBearerConfig->srb_ToAddModList != NULL) {
+
+ if (radioBearerConfig->securityConfig != NULL) {
+ if (*radioBearerConfig->securityConfig->keyToUse == NR_SecurityConfig__keyToUse_master) {
+ NR_UE_rrc_inst[ctxt_pP->module_id].cipheringAlgorithm =
+ radioBearerConfig->securityConfig->securityAlgorithmConfig->cipheringAlgorithm;
+ NR_UE_rrc_inst[ctxt_pP->module_id].integrityProtAlgorithm =
+ *radioBearerConfig->securityConfig->securityAlgorithmConfig->integrityProtAlgorithm;
+ }
+ }
+
+ uint8_t *kRRCenc = NULL;
+ uint8_t *kRRCint = NULL;
+ derive_key_rrc_enc(NR_UE_rrc_inst[ctxt_pP->module_id].cipheringAlgorithm,
+ NR_UE_rrc_inst[ctxt_pP->module_id].kgnb, &kRRCenc);
+ derive_key_rrc_int(NR_UE_rrc_inst[ctxt_pP->module_id].integrityProtAlgorithm,
+ NR_UE_rrc_inst[ctxt_pP->module_id].kgnb, &kRRCint);
+ // Refresh SRBs
+ nr_rrc_pdcp_config_asn1_req(ctxt_pP,
+ radioBearerConfig->srb_ToAddModList,
+ NULL,
+ NULL,
+ NR_UE_rrc_inst[ctxt_pP->module_id].cipheringAlgorithm |
+ (NR_UE_rrc_inst[ctxt_pP->module_id].integrityProtAlgorithm << 4),
+ kRRCenc,
+ kRRCint,
+ NULL,
+ NULL,
+ NULL,
+ NULL);
+ // Refresh SRBs
+ nr_rrc_rlc_config_asn1_req(ctxt_pP,
+ radioBearerConfig->srb_ToAddModList,
+ NULL,
+ NULL,
+ NULL,
+ NULL
+ );
+
+ for (cnt = 0; cnt < radioBearerConfig->srb_ToAddModList->list.count; cnt++) {
+ SRB_id = radioBearerConfig->srb_ToAddModList->list.array[cnt]->srb_Identity;
+ LOG_D(NR_RRC,"[UE %d]: Frame %d SRB config cnt %d (SRB%ld)\n", ctxt_pP->module_id, ctxt_pP->frame, cnt, SRB_id);
+ if (SRB_id == 1) {
+ if (NR_UE_rrc_inst[ctxt_pP->module_id].SRB1_config[gNB_index]) {
+ memcpy(NR_UE_rrc_inst[ctxt_pP->module_id].SRB1_config[gNB_index],
+ radioBearerConfig->srb_ToAddModList->list.array[cnt], sizeof(NR_SRB_ToAddMod_t));
+ } else {
+ NR_UE_rrc_inst[ctxt_pP->module_id].SRB1_config[gNB_index] = radioBearerConfig->srb_ToAddModList->list.array[cnt];
+ nr_rrc_ue_establish_srb1(ctxt_pP->module_id,
+ ctxt_pP->frame,
+ gNB_index,
+ radioBearerConfig->srb_ToAddModList->list.array[cnt]);
+
+ LOG_I(NR_RRC, "[FRAME %05d][RRC_UE][MOD %02d][][--- MAC_CONFIG_REQ (SRB1 gNB %d) --->][MAC_UE][MOD %02d][]\n",
+ ctxt_pP->frame, ctxt_pP->module_id, gNB_index, ctxt_pP->module_id);
+ // rrc_mac_config_req_ue
+ }
+ } else {
+ if (NR_UE_rrc_inst[ctxt_pP->module_id].SRB2_config[gNB_index]) {
+ memcpy(NR_UE_rrc_inst[ctxt_pP->module_id].SRB2_config[gNB_index],
+ radioBearerConfig->srb_ToAddModList->list.array[cnt], sizeof(NR_SRB_ToAddMod_t));
+ } else {
+ NR_UE_rrc_inst[ctxt_pP->module_id].SRB2_config[gNB_index] = radioBearerConfig->srb_ToAddModList->list.array[cnt];
+ nr_rrc_ue_establish_srb2(ctxt_pP->module_id,
+ ctxt_pP->frame,
+ gNB_index,
+ radioBearerConfig->srb_ToAddModList->list.array[cnt]);
+
+ LOG_I(NR_RRC, "[FRAME %05d][RRC_UE][MOD %02d][][--- MAC_CONFIG_REQ (SRB2 gNB %d) --->][MAC_UE][MOD %02d][]\n",
+ ctxt_pP->frame, ctxt_pP->module_id, gNB_index, ctxt_pP->module_id);
+ // rrc_mac_config_req_ue
+ }
+ } // srb2
+ }
+ } // srb_ToAddModList
+
+ // Establish DRBs if present
+ if (radioBearerConfig->drb_ToAddModList != NULL) {
+ if ((NR_UE_rrc_inst[ctxt_pP->module_id].defaultDRB == NULL) &&
+ (radioBearerConfig->drb_ToAddModList->list.count >= 1)) {
+ NR_UE_rrc_inst[ctxt_pP->module_id].defaultDRB = malloc(sizeof(rb_id_t));
+ *NR_UE_rrc_inst[ctxt_pP->module_id].defaultDRB = radioBearerConfig->drb_ToAddModList->list.array[0]->drb_Identity;
+ }
+
+ for (cnt = 0; cnt < radioBearerConfig->drb_ToAddModList->list.count; cnt++) {
+ DRB_id = radioBearerConfig->drb_ToAddModList->list.array[cnt]->drb_Identity;
+ if (NR_UE_rrc_inst[ctxt_pP->module_id].DRB_config[gNB_index][DRB_id-1]) {
+ memcpy(NR_UE_rrc_inst[ctxt_pP->module_id].DRB_config[gNB_index][DRB_id-1],
+ radioBearerConfig->drb_ToAddModList->list.array[cnt], sizeof(NR_DRB_ToAddMod_t));
+ } else {
+ LOG_D(NR_RRC, "Adding DRB %ld %p\n", DRB_id-1, radioBearerConfig->drb_ToAddModList->list.array[cnt]);
+ NR_UE_rrc_inst[ctxt_pP->module_id].DRB_config[gNB_index][DRB_id-1] = radioBearerConfig->drb_ToAddModList->list.array[cnt];
+ }
+ }
+
+ uint8_t *kUPenc = NULL;
+ derive_key_up_enc(NR_UE_rrc_inst[ctxt_pP->module_id].cipheringAlgorithm,
+ NR_UE_rrc_inst[ctxt_pP->module_id].kgnb, &kUPenc);
+ MSC_LOG_TX_MESSAGE(
+ MSC_RRC_UE,
+ MSC_PDCP_UE,
+ NULL,
+ 0,
+ MSC_AS_TIME_FMT" CONFIG_REQ UE %x DRB (security %X)",
+ MSC_AS_TIME_ARGS(ctxt_pP),
+ ctxt_pP->rnti,
+ NR_UE_rrc_inst[ctxt_pP->module_id].cipheringAlgorithm |
+ (NR_UE_rrc_inst[ctxt_pP->module_id].integrityProtAlgorithm << 4));
+
+ // Refresh DRBs
+ nr_rrc_pdcp_config_asn1_req(ctxt_pP,
+ NULL,
+ radioBearerConfig->drb_ToAddModList,
+ NULL,
+ NR_UE_rrc_inst[ctxt_pP->module_id].cipheringAlgorithm |
+ (NR_UE_rrc_inst[ctxt_pP->module_id].integrityProtAlgorithm << 4),
+ NULL,
+ NULL,
+ kUPenc,
+ NULL,
+ NR_UE_rrc_inst[ctxt_pP->module_id].defaultDRB,
+ NULL);
+ // Refresh DRBs
+ nr_rrc_rlc_config_asn1_req(ctxt_pP,
+ NULL,
+ radioBearerConfig->drb_ToAddModList,
+ NULL,
+ NULL,
+ NULL
+ );
+ } // drb_ToAddModList
+
+ if (radioBearerConfig->drb_ToReleaseList != NULL) {
+ for (i = 0; i < radioBearerConfig->drb_ToReleaseList->list.count; i++) {
+ DRB_id = *radioBearerConfig->drb_ToReleaseList->list.array[i];
+ free(NR_UE_rrc_inst[ctxt_pP->module_id].DRB_config[gNB_index][DRB_id-1]);
+ }
+ }
+
+ NR_UE_rrc_inst[ctxt_pP->module_id].Info[gNB_index].State = NR_RRC_CONNECTED;
+ LOG_I(NR_RRC,"[UE %d] State = NR_RRC_CONNECTED (gNB %d)\n", ctxt_pP->module_id, gNB_index);
+}
+
+//-----------------------------------------------------------------------------
+void
+rrc_ue_process_rrcReconfiguration(
+ const protocol_ctxt_t *const ctxt_pP,
+ NR_RRCReconfiguration_t *rrcReconfiguration,
+ uint8_t gNB_index
+)
+//-----------------------------------------------------------------------------
+{
+ LOG_I(NR_RRC, "[UE %d] Frame %d: Receiving from SRB1 (DL-DCCH), Processing RRCReconfiguration (gNB %d)\n",
+ ctxt_pP->module_id, ctxt_pP->frame, gNB_index);
+
+ NR_RRCReconfiguration_IEs_t *ie = NULL;
+
+ if (rrcReconfiguration->criticalExtensions.present
+ == NR_RRCReconfiguration__criticalExtensions_PR_rrcReconfiguration) {
+ ie = rrcReconfiguration->criticalExtensions.choice.rrcReconfiguration;
+ if (ie->measConfig != NULL) {
+ LOG_I(NR_RRC, "Measurement Configuration is present\n");
+ nr_rrc_ue_process_measConfig(ctxt_pP, gNB_index, ie->measConfig);
+ }
+
+ 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);
+ }
+
+ /* Check if there is dedicated NAS information to forward to NAS */
+ if (ie->nonCriticalExtension->dedicatedNAS_MessageList != NULL) {
+ int list_count;
+ uint32_t pdu_length;
+ uint8_t *pdu_buffer;
+ MessageDef *msg_p;
+
+ for (list_count = 0; list_count < ie->nonCriticalExtension->dedicatedNAS_MessageList->list.count; list_count++) {
+ pdu_length = ie->nonCriticalExtension->dedicatedNAS_MessageList->list.array[list_count]->size;
+ pdu_buffer = ie->nonCriticalExtension->dedicatedNAS_MessageList->list.array[list_count]->buf;
+ msg_p = itti_alloc_new_message(TASK_RRC_UE, 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);
+ }
+
+ free (ie->nonCriticalExtension->dedicatedNAS_MessageList);
+ }
+ }
+}
+
+//-----------------------------------------------------------------------------
+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);
+ LOG_I(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,
+ "[FRAME %05d][RRC_UE][INST %02d][][--- PDCP_DATA_REQ/%d Bytes (RRCReconfigurationComplete to gNB %d MUI %d) --->][PDCP][INST %02d][RB %02d]\n",
+ ctxt_pP->frame,
+ UE_MODULE_ID_TO_INSTANCE(ctxt_pP->module_id),
+ size,
+ gNB_index,
+ nr_rrc_mui,
+ UE_MODULE_ID_TO_INSTANCE(ctxt_pP->module_id),
+ DCCH);
+ rrc_data_req_ue (
+ ctxt_pP,
+ DCCH,
+ nr_rrc_mui++,
+ SDU_CONFIRM_NO,
+ size,
+ buffer,
+ PDCP_TRANSMISSION_MODE_CONTROL);
+}
+
+// from NR SRB1
+//-----------------------------------------------------------------------------
+int
+nr_rrc_ue_decode_dcch(
+ const protocol_ctxt_t *const ctxt_pP,
+ const srb_id_t Srb_id,
+ const uint8_t *const Buffer,
+ const uint8_t gNB_indexP
+)
+//-----------------------------------------------------------------------------
+{
+ asn_dec_rval_t dec_rval;
+ NR_DL_DCCH_Message_t *dl_dcch_msg = NULL;
+ MessageDef *msg_p;
+
+ if (Srb_id != 1) {
+ LOG_E(NR_RRC,"[UE %d] Frame %d: Received message on DL-DCCH (SRB%ld), should not have ...\n",
+ ctxt_pP->module_id, ctxt_pP->frame, Srb_id);
+ return -1;
+ } else {
+ LOG_D(NR_RRC, "Received message on SRB%ld\n", Srb_id);
+ }
+
+ LOG_D(NR_RRC, "Decoding DL-DCCH Message\n");
+ dec_rval = uper_decode( NULL,
+ &asn_DEF_NR_DL_DCCH_Message,
+ (void **)&dl_dcch_msg,
+ Buffer,
+ RRC_BUF_SIZE,
+ 0,
+ 0);
+
+ if ((dec_rval.code != RC_OK) && (dec_rval.consumed == 0)) {
+ LOG_E(NR_RRC, "Failed to decode DL-DCCH (%zu bytes)\n", dec_rval.consumed);
+ return -1;
+ }
+
+ if ( LOG_DEBUGFLAG(DEBUG_ASN1) ) {
+ xer_fprint(stdout, &asn_DEF_NR_DL_DCCH_Message,(void *)dl_dcch_msg);
+ }
+
+ 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(NR_RRC, "Received PR_NOTHING on DL-DCCH-Message\n");
+ break;
+
+ case NR_DL_DCCH_MessageType__c1_PR_rrcReconfiguration:
+ rrc_ue_process_rrcReconfiguration(ctxt_pP,
+ dl_dcch_msg->message.choice.c1->choice.rrcReconfiguration,
+ gNB_indexP);
+ nr_rrc_ue_generate_RRCReconfigurationComplete(ctxt_pP,
+ gNB_indexP,
+ dl_dcch_msg->message.choice.c1->choice.rrcReconfiguration->rrc_TransactionIdentifier);
+ break;
+
+ case NR_DL_DCCH_MessageType__c1_PR_rrcResume:
+ case NR_DL_DCCH_MessageType__c1_PR_rrcRelease:
+ msg_p = itti_alloc_new_message(TASK_RRC_UE, NAS_CONN_RELEASE_IND);
+
+ if((dl_dcch_msg->message.choice.c1->choice.rrcRelease->criticalExtensions.present == NR_RRCRelease__criticalExtensions_PR_rrcRelease) &&
+ (dl_dcch_msg->message.choice.c1->present == NR_DL_DCCH_MessageType__c1_PR_rrcRelease)){
+ dl_dcch_msg->message.choice.c1->choice.rrcRelease->criticalExtensions.choice.rrcRelease->deprioritisationReq->deprioritisationTimer =
+ NR_RRCRelease_IEs__deprioritisationReq__deprioritisationTimer_min5;
+ dl_dcch_msg->message.choice.c1->choice.rrcRelease->criticalExtensions.choice.rrcRelease->deprioritisationReq->deprioritisationType =
+ NR_RRCRelease_IEs__deprioritisationReq__deprioritisationType_frequency;
+ }
+
+ itti_send_msg_to_task(TASK_NAS_UE, ctxt_pP->instance, msg_p);
+ break;
+ case NR_DL_DCCH_MessageType__c1_PR_rrcReestablishment:
+ case NR_DL_DCCH_MessageType__c1_PR_dlInformationTransfer:
+ case NR_DL_DCCH_MessageType__c1_PR_ueCapabilityEnquiry:
+ 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;
+ case NR_DL_DCCH_MessageType__c1_PR_securityModeCommand:
+ break;
+ }
+ }
+ return 0;
+}
+
+//-----------------------------------------------------------------------------
+void *rrc_nrue_task( void *args_p ) {
+ MessageDef *msg_p;
+ instance_t instance;
+ unsigned int ue_mod_id;
+ int result;
+ NR_SRB_INFO *srb_info_p;
+ protocol_ctxt_t ctxt;
+ itti_mark_task_ready (TASK_RRC_NRUE);
+
+ while(1) {
+ // Wait for a message
+ itti_receive_msg (TASK_RRC_NRUE, &msg_p);
+ instance = ITTI_MSG_INSTANCE (msg_p);
+ ue_mod_id = UE_INSTANCE_TO_MODULE_ID(instance);
+
+ switch (ITTI_MSG_ID(msg_p)) {
+ case TERMINATE_MESSAGE:
+ LOG_W(RRC, " *** Exiting RRC thread\n");
+ itti_exit_task ();
+ break;
+
+ case MESSAGE_TEST:
+ LOG_D(RRC, "[UE %d] Received %s\n", ue_mod_id, ITTI_MSG_NAME (msg_p));
+ break;
+
+ case NR_RRC_MAC_BCCH_DATA_IND:
+ LOG_D(RRC, "[UE %d] Received %s: frameP %d, gNB %d\n", ue_mod_id, ITTI_MSG_NAME (msg_p),
+ NR_RRC_MAC_BCCH_DATA_IND (msg_p).frame, NR_RRC_MAC_BCCH_DATA_IND (msg_p).gnb_index);
+ // PROTOCOL_CTXT_SET_BY_INSTANCE(&ctxt, instance, ENB_FLAG_NO, NOT_A_RNTI, RRC_MAC_BCCH_DATA_IND (msg_p).frame, 0);
+ PROTOCOL_CTXT_SET_BY_MODULE_ID(&ctxt, ue_mod_id, GNB_FLAG_NO, NOT_A_RNTI, NR_RRC_MAC_BCCH_DATA_IND (msg_p).frame, 0,NR_RRC_MAC_BCCH_DATA_IND (msg_p).gnb_index);
+ nr_decode_BCCH_DLSCH_Message (&ctxt,
+ NR_RRC_MAC_BCCH_DATA_IND (msg_p).gnb_index,
+ NR_RRC_MAC_BCCH_DATA_IND (msg_p).sdu,
+ NR_RRC_MAC_BCCH_DATA_IND (msg_p).sdu_size,
+ NR_RRC_MAC_BCCH_DATA_IND (msg_p).rsrq,
+ NR_RRC_MAC_BCCH_DATA_IND (msg_p).rsrp);
+
+ case NR_RRC_MAC_CCCH_DATA_IND:
+ LOG_D(RRC, "[UE %d] RNTI %x Received %s: frameP %d, gNB %d\n",
+ ue_mod_id,
+ NR_RRC_MAC_CCCH_DATA_IND (msg_p).rnti,
+ ITTI_MSG_NAME (msg_p),
+ NR_RRC_MAC_CCCH_DATA_IND (msg_p).frame,
+ NR_RRC_MAC_CCCH_DATA_IND (msg_p).gnb_index);
+ srb_info_p = &NR_UE_rrc_inst[ue_mod_id].Srb0[NR_RRC_MAC_CCCH_DATA_IND (msg_p).gnb_index];
+ memcpy (srb_info_p->Rx_buffer.Payload, NR_RRC_MAC_CCCH_DATA_IND (msg_p).sdu,
+ NR_RRC_MAC_CCCH_DATA_IND (msg_p).sdu_size);
+ srb_info_p->Rx_buffer.payload_size = NR_RRC_MAC_CCCH_DATA_IND (msg_p).sdu_size;
+ // PROTOCOL_CTXT_SET_BY_INSTANCE(&ctxt, instance, ENB_FLAG_NO, RRC_MAC_CCCH_DATA_IND (msg_p).rnti, RRC_MAC_CCCH_DATA_IND (msg_p).frame, 0);
+ PROTOCOL_CTXT_SET_BY_MODULE_ID(&ctxt, ue_mod_id, GNB_FLAG_NO, NR_RRC_MAC_CCCH_DATA_IND (msg_p).rnti, NR_RRC_MAC_CCCH_DATA_IND (msg_p).frame, 0, NR_RRC_MAC_CCCH_DATA_IND (msg_p).gnb_index);
+ nr_rrc_ue_decode_ccch (&ctxt,
+ srb_info_p,
+ NR_RRC_MAC_CCCH_DATA_IND (msg_p).gnb_index);
+ break;
+
+ /* PDCP messages */
+ case NR_RRC_DCCH_DATA_IND:
+ PROTOCOL_CTXT_SET_BY_MODULE_ID(&ctxt, NR_RRC_DCCH_DATA_IND (msg_p).module_id, GNB_FLAG_NO, NR_RRC_DCCH_DATA_IND (msg_p).rnti, NR_RRC_DCCH_DATA_IND (msg_p).frame, 0,NR_RRC_DCCH_DATA_IND (msg_p).gNB_index);
+ LOG_D(NR_RRC, "[UE %d] Received %s: frameP %d, DCCH %d, gNB %d\n",
+ NR_RRC_DCCH_DATA_IND (msg_p).module_id,
+ ITTI_MSG_NAME (msg_p),
+ NR_RRC_DCCH_DATA_IND (msg_p).frame,
+ NR_RRC_DCCH_DATA_IND (msg_p).dcch_index,
+ NR_RRC_DCCH_DATA_IND (msg_p).gNB_index);
+ LOG_D(NR_RRC, PROTOCOL_RRC_CTXT_UE_FMT"Received %s DCCH %d, gNB %d\n",
+ PROTOCOL_NR_RRC_CTXT_UE_ARGS(&ctxt),
+ ITTI_MSG_NAME (msg_p),
+ NR_RRC_DCCH_DATA_IND (msg_p).dcch_index,
+ NR_RRC_DCCH_DATA_IND (msg_p).gNB_index);
+ nr_rrc_ue_decode_dcch (
+ &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).gNB_index);
+ // Message buffer has been processed, free it now.
+ result = itti_free (ITTI_MSG_ORIGIN_ID(msg_p), NR_RRC_DCCH_DATA_IND (msg_p).sdu_p);
+ AssertFatal (result == EXIT_SUCCESS, "Failed to free memory (%d)!\n", result);
+ break;
+
+ default:
+ LOG_E(RRC, "[UE %d] Received unexpected message %s\n", ue_mod_id, ITTI_MSG_NAME (msg_p));
+ break;
+ }
+
+ result = itti_free (ITTI_MSG_ORIGIN_ID(msg_p), msg_p);
+ AssertFatal (result == EXIT_SUCCESS, "Failed to free memory (%d)!\n", result);
+ msg_p = NULL;
+ }
+}
+void *nr_rrc_ue_process_sidelink_radioResourceConfig(
+ module_id_t Mod_idP,
+ uint8_t gNB_index,
+ NR_SetupRelease_SL_ConfigDedicatedNR_r16_t *sl_ConfigDedicatedNR
+)
+{
+ //process sl_CommConfig, configure MAC/PHY for transmitting SL communication (RRC_CONNECTED)
+ if (sl_ConfigDedicatedNR != NULL) {
+ switch (sl_ConfigDedicatedNR->present){
+ case NR_SetupRelease_SL_ConfigDedicatedNR_r16_PR_setup:
+ //TODO
+ break;
+ case NR_SetupRelease_SL_ConfigDedicatedNR_r16_PR_release:
+ break;
+ case NR_SetupRelease_SL_ConfigDedicatedNR_r16_PR_NOTHING:
+ break;
+ default:
+ break;
+ }
+ }
+}
diff --git a/openair2/RRC/NR_UE/rrc_defs.h b/openair2/RRC/NR_UE/rrc_defs.h
index 6481fb0cea..92728eee98 100644
--- a/openair2/RRC/NR_UE/rrc_defs.h
+++ b/openair2/RRC/NR_UE/rrc_defs.h
@@ -53,8 +53,15 @@
#include "NR_MIB.h"
#include "NR_BCCH-BCH-Message.h"
#include "NR_DL-DCCH-Message.h"
+#include "../NR/nr_rrc_defs.h"
#define NB_NR_UE_INST 1
+#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
typedef uint32_t channel_t;
@@ -68,9 +75,53 @@ typedef struct NR_UE_RRC_INST_s {
NR_MeasConfig_t *meas_config;
NR_CellGroupConfig_t *cell_group_config;
NR_RadioBearerConfig_t *radio_bearer_config;
-
+
+ NR_MeasObjectToAddMod_t *MeasObj[NB_CNX_UE][MAX_MEAS_OBJ];
+ NR_ReportConfigToAddMod_t *ReportConfig[NB_CNX_UE][MAX_MEAS_CONFIG];
+ NR_QuantityConfig_t *QuantityConfig[NB_CNX_UE];
+ NR_MeasIdToAddMod_t *MeasId[NB_CNX_UE][MAX_MEAS_ID];
+ NR_MeasGapConfig_t *measGapConfig[NB_CNX_UE];
+ NR_RSRP_Range_t s_measure;
+ NR_SRB_ToAddMod_t *SRB1_config[NB_CNX_UE];
+ NR_SRB_ToAddMod_t *SRB2_config[NB_CNX_UE];
+ 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];
+ NR_SRB_INFO_TABLE_ENTRY Srb1[NB_CNX_UE];
+ NR_SRB_INFO_TABLE_ENTRY Srb2[NB_CNX_UE];
+
+ uint8_t MBMS_flag;
+
+ NR_SystemInformation_t *si[NB_CNX_UE];
+ NR_SIB1_t *sib1[NB_CNX_UE];
+ NR_SIB2_t *sib2[NB_CNX_UE];
+ NR_SIB3_t *sib3[NB_CNX_UE];
+ NR_SIB4_t *sib4[NB_CNX_UE];
+ NR_SIB5_t *sib5[NB_CNX_UE];
+ NR_SIB6_t *sib6[NB_CNX_UE];
+ NR_SIB7_t *sib7[NB_CNX_UE];
+ NR_SIB8_t *sib8[NB_CNX_UE];
+ NR_SIB9_t *sib9[NB_CNX_UE];
+ NR_SIB10_r16_t *sib10[NB_CNX_UE];
+ NR_SIB11_r16_t *sib11[NB_CNX_UE];
+ NR_SIB12_r16_t *sib12[NB_CNX_UE];
+ NR_SIB13_r16_t *sib13[NB_CNX_UE];
+ NR_SIB14_r16_t *sib14[NB_CNX_UE];
+ plmn_t plmnID;
+
+ NR_UE_RRC_INFO Info[NB_SIG_CNX_UE];
+
NR_MIB_t *mib;
+
+ /* KeNB as computed from parameters within USIM card */
+ uint8_t kgnb[32];
+ /* Used integrity/ciphering algorithms */
+ //RRC_LIST_TYPE(NR_SecurityAlgorithmConfig_t, NR_SecurityAlgorithmConfig) SecurityAlgorithmConfig_list;
+ NR_CipheringAlgorithm_t cipheringAlgorithm;
+ e_NR_IntegrityProtAlgorithm integrityProtAlgorithm;
+
// lists
// CellGroupConfig.rlc-BearerToAddModList
RRC_LIST_TYPE(NR_RLC_BearerConfig_t, NR_maxLC_ID) RLC_Bearer_Config_list;
@@ -118,7 +169,10 @@ typedef struct NR_UE_RRC_INST_s {
RRC_LIST_TYPE(NR_CSI_ResourceConfig_t, NR_maxNrofCSI_ResourceConfigurations) CSI_ResourceConfig_list;
// CellGroupConfig.spCellConfig.spCellConfigDedicated
RRC_LIST_TYPE(NR_CSI_ReportConfig_t, NR_maxNrofCSI_ReportConfigurations) CSI_ReportConfig_list;
-
+
+ long selected_plmn_identity;
+ Rrc_State_NR_t nrRrcState;
+ Rrc_Sub_State_NR_t nrRrcSubState;
} NR_UE_RRC_INST_t;
#endif
diff --git a/openair2/RRC/NR_UE/rrc_proto.h b/openair2/RRC/NR_UE/rrc_proto.h
index 7bc7e4b90c..5ec6c3f8e2 100644
--- a/openair2/RRC/NR_UE/rrc_proto.h
+++ b/openair2/RRC/NR_UE/rrc_proto.h
@@ -114,6 +114,10 @@ int8_t mac_rrc_nr_data_req_ue(const module_id_t Mod_idP,
const rb_id_t Srb_id,
uint8_t *const buffer_pP);
+
+/**\brief RRC UE task.
+ \param void *args_p Pointer on arguments to start the task. */
+void *rrc_nrue_task(void *args_p);
/** @}*/
#endif
diff --git a/openair2/SIMULATION/NR_RRC/itti_sim.c b/openair2/SIMULATION/NR_RRC/itti_sim.c
new file mode 100644
index 0000000000..19bc9c154a
--- /dev/null
+++ b/openair2/SIMULATION/NR_RRC/itti_sim.c
@@ -0,0 +1,635 @@
+/*!
+\file itti_sim.c
+
+\brief simulator for itti message from node to UE
+\author Yoshio INOUE, Masayuki HARADA
+\email: yoshio.inoue@fujitsu.com,masayuki.harada@fujitsu.com
+\date 2020
+\version 0.1
+*/
+
+#include
+
+
+#include "T.h"
+
+#undef MALLOC //there are two conflicting definitions, so we better make sure we don't use it at all
+#include
+
+#include "msc.h"
+
+#include "common/ran_context.h"
+
+#include "common/config/config_userapi.h"
+#include "common/utils/load_module_shlib.h"
+#undef MALLOC //there are two conflicting definitions, so we better make sure we don't use it at all
+
+#include "PHY/phy_vars.h"
+#include "SCHED/sched_common_vars.h"
+#include "LAYER2/MAC/mac_vars.h"
+#include "RRC/LTE/rrc_vars.h"
+#include "gnb_config.h"
+#include "SIMULATION/TOOLS/sim.h"
+
+#ifdef SMBV
+#include "PHY/TOOLS/smbv.h"
+unsigned short config_frames[4] = {2,9,11,13};
+#endif
+
+#include "common/utils/LOG/log.h"
+#include "common/utils/LOG/vcd_signal_dumper.h"
+#include "UTIL/OPT/opt.h"
+
+#ifndef OPENAIR2
+ #include "UTIL/OTG/otg_vars.h"
+#endif
+
+#include "intertask_interface.h"
+
+
+#include "system.h"
+#include
+#include "PHY/TOOLS/phy_scope_interface.h"
+#include "PHY/TOOLS/nr_phy_scope.h"
+#include "stats.h"
+#include "nr-softmodem.h"
+#include "executables/softmodem-common.h"
+#include "executables/thread-common.h"
+#include "NB_IoT_interface.h"
+#include "x2ap_eNB.h"
+#include "ngap_gNB.h"
+#include "RRC/NR_UE/rrc_proto.h"
+#include "openair3/NAS/UE/nas_ue_task.h"
+
+pthread_cond_t nfapi_sync_cond;
+pthread_mutex_t nfapi_sync_mutex;
+int nfapi_sync_var=-1; //!< protected by mutex \ref nfapi_sync_mutex
+
+uint8_t nfapi_mode = 0; // Default to monolithic mode
+uint32_t target_dl_mcs = 28;
+uint32_t target_ul_mcs = 20;
+uint32_t timing_advance = 0;
+uint64_t num_missed_slots=0;
+
+int split73=0;
+void sendFs6Ul(PHY_VARS_eNB *eNB, int UE_id, int harq_pid, int segmentID, int16_t *data, int dataLen, int r_offset) {
+ AssertFatal(false, "Must not be called in this context\n");
+}
+
+pthread_cond_t sync_cond;
+pthread_mutex_t sync_mutex;
+int sync_var=-1; //!< protected by mutex \ref sync_mutex.
+int config_sync_var=-1;
+
+openair0_config_t openair0_cfg[MAX_CARDS];
+
+volatile int start_gNB = 0;
+volatile int oai_exit = 0;
+
+//static int wait_for_sync = 0;
+
+unsigned int mmapped_dma=0;
+int single_thread_flag=1;
+
+int8_t threequarter_fs=0;
+
+uint64_t downlink_frequency[MAX_NUM_CCs][4];
+int32_t uplink_frequency_offset[MAX_NUM_CCs][4];
+
+//Temp fix for inexistent NR upper layer
+unsigned char NB_gNB_INST = 1;
+
+static char *itti_dump_file = NULL;
+
+int UE_scan = 1;
+int UE_scan_carrier = 0;
+runmode_t mode = normal_txrx;
+static double snr_dB=20;
+
+FILE *input_fd=NULL;
+
+int chain_offset=0;
+
+
+uint8_t dci_Format = 0;
+uint8_t agregation_Level =0xFF;
+
+uint8_t nb_antenna_tx = 1;
+uint8_t nb_antenna_rx = 1;
+
+char ref[128] = "internal";
+char channels[128] = "0";
+
+int otg_enabled;
+
+extern void *udp_eNB_task(void *args_p);
+
+int transmission_mode=1;
+int emulate_rf = 0;
+int numerology = 0;
+int usrp_tx_thread = 0;
+
+
+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
+ */
+uint8_t abstraction_flag=0;
+
+/* forward declarations */
+void set_default_frame_parms(nfapi_nr_config_request_scf_t *config[MAX_NUM_CCs], NR_DL_FRAME_PARMS *frame_parms[MAX_NUM_CCs]);
+
+/*---------------------BMC: timespec helpers -----------------------------*/
+
+struct timespec min_diff_time = { .tv_sec = 0, .tv_nsec = 0 };
+struct timespec max_diff_time = { .tv_sec = 0, .tv_nsec = 0 };
+
+struct timespec clock_difftime(struct timespec start, struct timespec end) {
+ struct timespec temp;
+
+ if ((end.tv_nsec-start.tv_nsec)<0) {
+ temp.tv_sec = end.tv_sec-start.tv_sec-1;
+ temp.tv_nsec = 1000000000+end.tv_nsec-start.tv_nsec;
+ } else {
+ temp.tv_sec = end.tv_sec-start.tv_sec;
+ temp.tv_nsec = end.tv_nsec-start.tv_nsec;
+ }
+
+ return temp;
+}
+
+
+
+#define KNRM "\x1B[0m"
+#define KRED "\x1B[31m"
+#define KGRN "\x1B[32m"
+#define KBLU "\x1B[34m"
+#define RESET "\033[0m"
+
+
+void exit_function(const char *file, const char *function, const int line, const char *s) {
+ int ru_id;
+
+ if (s != NULL) {
+ printf("%s:%d %s() Exiting OAI softmodem: %s\n",file,line, function, s);
+ }
+
+ oai_exit = 1;
+
+ if (RC.ru == NULL)
+ exit(-1); // likely init not completed, prevent crash or hang, exit now...
+
+ for (ru_id=0; ru_idrfdevice.trx_end_func) {
+ RC.ru[ru_id]->rfdevice.trx_end_func(&RC.ru[ru_id]->rfdevice);
+ RC.ru[ru_id]->rfdevice.trx_end_func = NULL;
+ }
+
+ if (RC.ru[ru_id] && RC.ru[ru_id]->ifdevice.trx_end_func) {
+ RC.ru[ru_id]->ifdevice.trx_end_func(&RC.ru[ru_id]->ifdevice);
+ RC.ru[ru_id]->ifdevice.trx_end_func = NULL;
+ }
+ }
+
+ sleep(1); //allow lte-softmodem threads to exit first
+ exit(1);
+}
+
+void wait_gNBs(void) {
+ int i;
+ int waiting=1;
+
+ while (waiting==1) {
+ printf("Waiting for gNB L1 instances to all get configured ... sleeping 50ms (nb_nr_sL1_inst %d)\n",RC.nb_nr_L1_inst);
+ usleep(50*1000);
+ waiting=0;
+
+ for (i=0; iconfigured==0) {
+ waiting=1;
+ break;
+ }
+ }
+ }
+
+ printf("gNB L1 are configured\n");
+}
+
+void wait_RUs(void) {
+ LOG_I(PHY,"Waiting for RUs to be configured ... RC.ru_mask:%02lx\n", RC.ru_mask);
+ // wait for all RUs to be configured over fronthaul
+ pthread_mutex_lock(&RC.ru_mutex);
+
+ while (RC.ru_mask>0) {
+ pthread_cond_wait(&RC.ru_cond,&RC.ru_mutex);
+ printf("RC.ru_mask:%02lx\n", RC.ru_mask);
+ }
+
+ pthread_mutex_unlock(&RC.ru_mutex);
+ LOG_I(PHY,"RUs configured\n");
+}
+
+
+int stop_L1L2(module_id_t gnb_id) {
+ return 0;
+}
+
+int restart_L1L2(module_id_t gnb_id) {
+ return 0;
+}
+
+int create_gNB_tasks(uint32_t gnb_nb) {
+ LOG_D(GNB_APP, "%s(gnb_nb:%d)\n", __FUNCTION__, gnb_nb);
+ itti_wait_ready(1);
+
+
+ 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 (is_x2ap_enabled()) {
+ if(itti_create_task(TASK_X2AP, x2ap_task, NULL) < 0){
+ LOG_E(X2AP, "Create task for X2AP failed\n");
+ }
+ }
+ else {
+ LOG_I(X2AP, "X2AP is disabled.\n");
+ }
+ }
+
+ if (AMF_MODE_ENABLED && (get_softmodem_params()->phy_test==0 && get_softmodem_params()->do_ra==0)) {
+ if (gnb_nb > 0) {
+ if (itti_create_task (TASK_NGAP, ngap_gNB_task, NULL) < 0) {
+ LOG_E(S1AP, "Create task for NGAP failed\n");
+ return -1;
+ }
+
+
+ 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, >pv1u_gNB_task, NULL) < 0) {
+ LOG_E(GTPU, "Create task for GTPV1U failed\n");
+ return -1;
+ }
+ }
+ }
+
+
+ if (gnb_nb > 0) {
+ if (itti_create_task (TASK_GNB_APP, gNB_app_task, NULL) < 0) {
+ LOG_E(GNB_APP, "Create task for gNB APP failed\n");
+ return -1;
+ }
+ LOG_I(NR_RRC,"Creating NR RRC gNB Task\n");
+
+ if (itti_create_task (TASK_RRC_GNB, rrc_gnb_task, NULL) < 0) {
+ LOG_E(NR_RRC, "Create task for NR RRC gNB failed\n");
+ return -1;
+ }
+ }
+
+ return 0;
+}
+
+
+static void get_options(void) {
+
+
+ paramdef_t cmdline_params[] = CMDLINE_PARAMS_DESC_GNB ;
+
+ CONFIG_SETRTFLAG(CONFIG_NOEXITONHELP);
+ get_common_options(SOFTMODEM_GNB_BIT );
+ config_process_cmdline( cmdline_params,sizeof(cmdline_params)/sizeof(paramdef_t),NULL);
+ CONFIG_CLEARRTFLAG(CONFIG_NOEXITONHELP);
+
+
+
+
+ if ( !(CONFIG_ISFLAGSET(CONFIG_ABORT)) ) {
+ memset((void *)&RC,0,sizeof(RC));
+ /* Read RC configuration file */
+ NRRCConfig();
+ NB_gNB_INST = RC.nb_nr_inst;
+ NB_RU = RC.nb_RU;
+ printf("Configuration: nb_rrc_inst %d, nb_nr_L1_inst %d, nb_ru %hhu\n",NB_gNB_INST,RC.nb_nr_L1_inst,NB_RU);
+ }
+
+}
+
+
+void set_default_frame_parms(nfapi_nr_config_request_scf_t *config[MAX_NUM_CCs],
+ NR_DL_FRAME_PARMS *frame_parms[MAX_NUM_CCs])
+{
+ for (int CC_id=0; CC_idssb_config.scs_common.value = 1;
+ config[CC_id]->cell_config.frame_duplex_type.value = 1; //FDD
+ config[CC_id]->carrier_config.dl_grid_size[1].value = 106;
+ config[CC_id]->carrier_config.ul_grid_size[1].value = 106;
+ config[CC_id]->cell_config.phy_cell_id.value = 0;
+ }
+}
+
+/*
+ * helper function to terminate a certain ITTI task
+ */
+void terminate_task(task_id_t task_id, module_id_t mod_id) {
+ LOG_I(GNB_APP, "sending TERMINATE_MESSAGE to task %s (%d)\n", itti_get_task_name(task_id), task_id);
+ MessageDef *msg;
+ msg = itti_alloc_new_message (ENB_APP, TERMINATE_MESSAGE);
+ itti_send_msg_to_task (task_id, ENB_MODULE_ID_TO_INSTANCE(mod_id), msg);
+}
+
+//extern void free_transport(PHY_VARS_gNB *);
+extern void nr_phy_free_RU(RU_t *);
+
+void init_pdcp(void) {
+ //if (!NODE_IS_DU(RC.rrc[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 ;
+ }
+
+ 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);
+}
+
+
+int create_tasks_nrue(uint32_t ue_nb) {
+ LOG_D(ENB_APP, "%s(ue_nb:%d)\n", __FUNCTION__, ue_nb);
+ itti_wait_ready(1);
+
+ if (ue_nb > 0) {
+ printf("create TASK_RRC_NRUE\n");
+ if (itti_create_task (TASK_RRC_NRUE, rrc_nrue_task, NULL) < 0) {
+ LOG_E(RRC, "Create task for RRC UE failed\n");
+ return -1;
+ }
+ }
+
+
+ itti_wait_ready(0);
+ return 0;
+}
+
+
+void *itti_sim_ue_rrc_task( void *args_p) {
+ MessageDef *msg_p, *message_p;
+ instance_t instance;
+ unsigned int ue_mod_id;
+ int result;
+ itti_mark_task_ready (TASK_RRC_UE_SIM);
+
+ while(1) {
+ // Wait for a message
+ itti_receive_msg (TASK_RRC_UE_SIM, &msg_p);
+ instance = ITTI_MSG_INSTANCE (msg_p);
+ ue_mod_id = UE_INSTANCE_TO_MODULE_ID(instance);
+
+ switch (ITTI_MSG_ID(msg_p)) {
+ case TERMINATE_MESSAGE:
+ LOG_W(RRC, " *** Exiting RRC thread\n");
+ itti_exit_task ();
+ break;
+
+ case MESSAGE_TEST:
+ LOG_D(RRC, "[UE %d] Received %s\n", ue_mod_id, ITTI_MSG_NAME (msg_p));
+ break;
+ case GNB_RRC_BCCH_DATA_IND:
+ message_p = itti_alloc_new_message (TASK_RRC_NRUE, NR_RRC_MAC_BCCH_DATA_IND);
+ memset (NR_RRC_MAC_BCCH_DATA_IND (message_p).sdu, 0, BCCH_SDU_SIZE);
+ NR_RRC_MAC_BCCH_DATA_IND (message_p).sdu_size = GNB_RRC_BCCH_DATA_IND(msg_p).size;
+ memcpy (NR_RRC_MAC_BCCH_DATA_IND (message_p).sdu, GNB_RRC_BCCH_DATA_IND(msg_p).sdu, GNB_RRC_BCCH_DATA_IND(msg_p).size);
+ itti_send_msg_to_task (TASK_RRC_NRUE, instance, message_p);
+ break;
+ case GNB_RRC_CCCH_DATA_IND:
+ message_p = itti_alloc_new_message (TASK_RRC_NRUE, NR_RRC_MAC_CCCH_DATA_IND);
+ printf("receive GNB_RRC_CCCH_DATA_IND\n");
+ memset (NR_RRC_MAC_CCCH_DATA_IND (message_p).sdu, 0, CCCH_SDU_SIZE);
+ memcpy (NR_RRC_MAC_CCCH_DATA_IND (message_p).sdu, GNB_RRC_CCCH_DATA_IND(msg_p).sdu, GNB_RRC_CCCH_DATA_IND(msg_p).size);
+ NR_RRC_MAC_CCCH_DATA_IND (message_p).sdu_size = GNB_RRC_CCCH_DATA_IND(msg_p).size;
+ itti_send_msg_to_task (TASK_RRC_NRUE, instance, message_p);
+ break;
+ case GNB_RRC_DCCH_DATA_IND:
+ printf("receive GNB_RRC_DCCH_DATA_IND\n");
+ message_p = itti_alloc_new_message (TASK_RRC_NRUE, NR_RRC_DCCH_DATA_IND);
+ NR_RRC_DCCH_DATA_IND (message_p).dcch_index = GNB_RRC_DCCH_DATA_IND(msg_p).rbid;
+ NR_RRC_DCCH_DATA_IND (message_p).sdu_size = GNB_RRC_DCCH_DATA_IND(msg_p).size;
+ memset(NR_RRC_DCCH_DATA_IND (message_p).sdu_p, 0, GNB_RRC_DCCH_DATA_IND(msg_p).size);
+ memcpy(NR_RRC_DCCH_DATA_IND (message_p).sdu_p, GNB_RRC_DCCH_DATA_IND(msg_p).sdu, GNB_RRC_DCCH_DATA_IND(msg_p).size);
+ itti_send_msg_to_task (TASK_RRC_NRUE, instance, message_p);
+ break;
+ default:
+ LOG_E(RRC, "[UE %d] Received unexpected message %s\n", ue_mod_id, ITTI_MSG_NAME (msg_p));
+ break;
+ }
+
+ result = itti_free (ITTI_MSG_ORIGIN_ID(msg_p), msg_p);
+ AssertFatal (result == EXIT_SUCCESS, "Failed to free memory (%d)!\n", result);
+ msg_p = NULL;
+ }
+}
+
+
+void *itti_sim_gnb_rrc_task( void *args_p) {
+ MessageDef *msg_p, *message_p;
+ instance_t instance;
+ unsigned int ue_mod_id;
+ int result;
+ itti_mark_task_ready (TASK_RRC_GNB_SIM);
+
+ while(1) {
+ // Wait for a message
+ itti_receive_msg (TASK_RRC_GNB_SIM, &msg_p);
+ instance = ITTI_MSG_INSTANCE (msg_p);
+ ue_mod_id = UE_INSTANCE_TO_MODULE_ID(instance);
+
+ switch (ITTI_MSG_ID(msg_p)) {
+ case TERMINATE_MESSAGE:
+ LOG_W(RRC, " *** Exiting RRC thread\n");
+ itti_exit_task ();
+ break;
+
+ case MESSAGE_TEST:
+ LOG_D(RRC, "[UE %d] Received %s\n", ue_mod_id, ITTI_MSG_NAME (msg_p));
+ break;
+ case UE_RRC_CCCH_DATA_IND:
+ message_p = itti_alloc_new_message (TASK_RRC_GNB, NR_RRC_MAC_CCCH_DATA_IND);
+ RRC_MAC_CCCH_DATA_IND (message_p).sdu_size = UE_RRC_CCCH_DATA_IND(msg_p).size;
+ memset (RRC_MAC_CCCH_DATA_IND (message_p).sdu, 0, CCCH_SDU_SIZE);
+ memcpy (RRC_MAC_CCCH_DATA_IND (message_p).sdu, UE_RRC_CCCH_DATA_IND(msg_p).sdu, UE_RRC_CCCH_DATA_IND(msg_p).size);
+ itti_send_msg_to_task (TASK_RRC_GNB, instance, message_p);
+ break;
+ case UE_RRC_DCCH_DATA_IND:
+ message_p = itti_alloc_new_message (TASK_RRC_GNB, NR_RRC_DCCH_DATA_IND);
+ RRC_DCCH_DATA_IND (message_p).sdu_size = UE_RRC_DCCH_DATA_IND(msg_p).size;
+ memset (RRC_MAC_CCCH_DATA_IND (message_p).sdu, 0, UE_RRC_DCCH_DATA_IND(msg_p).size);
+ memcpy (RRC_MAC_CCCH_DATA_IND (message_p).sdu, UE_RRC_DCCH_DATA_IND(msg_p).sdu, UE_RRC_DCCH_DATA_IND(msg_p).size);
+ itti_send_msg_to_task (TASK_RRC_GNB, instance, message_p);
+ break;
+
+ default:
+ LOG_E(RRC, "[UE %d] Received unexpected message %s\n", ue_mod_id, ITTI_MSG_NAME (msg_p));
+ break;
+ }
+
+ result = itti_free (ITTI_MSG_ORIGIN_ID(msg_p), msg_p);
+ AssertFatal (result == EXIT_SUCCESS, "Failed to free memory (%d)!\n", result);
+ msg_p = NULL;
+ }
+}
+
+
+int main( int argc, char **argv )
+{
+ start_background_system();
+
+ ///static configuration for NR at the moment
+ if ( load_configmodule(argc,argv,CONFIG_ENABLECMDLINEONLY) == NULL) {
+ exit_fun("[SOFTMODEM] Error, configuration module init failed\n");
+ }
+ set_softmodem_sighandler();
+#ifdef DEBUG_CONSOLE
+ setvbuf(stdout, NULL, _IONBF, 0);
+ setvbuf(stderr, NULL, _IONBF, 0);
+#endif
+
+ logInit();
+ //configure_linux();
+ printf("Reading in command-line options\n");
+ get_options ();
+
+ if (CONFIG_ISFLAGSET(CONFIG_ABORT) ) {
+ fprintf(stderr,"Getting configuration failed\n");
+ exit(-1);
+ }
+
+ AMF_MODE_ENABLED = !IS_SOFTMODEM_NOS1;
+
+#if T_TRACER
+ T_Config_Init();
+#endif
+ //randominit (0);
+ set_taus_seed (0);
+ printf("configuring for RAU/RRU\n");
+
+ if (opp_enabled ==1) {
+ reset_opp_meas();
+ }
+
+ cpuf=get_cpu_freq_GHz();
+ itti_init(TASK_MAX, THREAD_MAX, MESSAGES_ID_MAX, tasks_info, messages_info);
+ // initialize mscgen log after ITTI
+ MSC_INIT(MSC_E_UTRAN, THREAD_MAX+TASK_MAX);
+
+
+ init_opt();
+
+ LOG_I(HW, "Version: %s\n", PACKAGE_VERSION);
+
+ if(IS_SOFTMODEM_NOS1)
+ init_pdcp();
+
+ if (RC.nb_nr_inst > 0) {
+ // don't create if node doesn't connect to RRC/S1/GTP
+ AssertFatal(create_gNB_tasks(1) == 0,"cannot create ITTI tasks\n");
+ } else {
+ printf("No ITTI, Initializing L1\n");
+ return 0;
+ }
+
+ if(itti_create_task (TASK_RRC_GNB_SIM, itti_sim_gnb_rrc_task, NULL) < 0){
+ printf("cannot create ITTI tasks\n");
+ exit(-1); // need a softer mode
+ }
+
+ openair_rrc_top_init_ue_nr("./");
+
+ if (create_tasks_nrue(1) < 0) {
+ printf("cannot create ITTI tasks\n");
+ exit(-1); // need a softer mode
+ }
+
+ if(itti_create_task (TASK_RRC_UE_SIM, itti_sim_ue_rrc_task, NULL) < 0){
+ printf("cannot create ITTI tasks\n");
+ exit(-1); // need a softer mode
+ }
+
+ pthread_cond_init(&sync_cond,NULL);
+ pthread_mutex_init(&sync_mutex, NULL);
+
+ printf("Sending sync to all threads\n");
+ pthread_mutex_lock(&sync_mutex);
+ sync_var=0;
+ pthread_cond_broadcast(&sync_cond);
+ pthread_mutex_unlock(&sync_mutex);
+ // wait for end of program
+ printf("TYPE TO TERMINATE\n");
+
+
+
+#if 0
+ // test itti sim
+ usleep(10000);
+
+ protocol_ctxt_t ctxt;
+ struct rrc_gNB_ue_context_s *ue_context_p = NULL;
+
+
+ ue_context_p = rrc_gNB_allocate_new_UE_context(RC.nrrrc[0]);
+
+ if(ue_context_p == NULL){
+ printf("ue_context_p == NULL");
+ }
+ PROTOCOL_CTXT_SET_BY_INSTANCE(&ctxt,
+ 0,
+ ENB_FLAG_YES,
+ 0,
+ 0,
+ 0);
+ rrc_gNB_generate_RRCSetup(&ctxt,
+ ue_context_p,
+ 0);
+ // end test itti sim
+#endif
+
+ printf("Entering ITTI signals handler\n");
+ itti_wait_tasks_end();
+ printf("Returned from ITTI signal handler\n");
+ oai_exit=1;
+ printf("oai_exit=%d\n",oai_exit);
+
+ printf("stopping MODEM threads\n");
+
+
+ /* release memory used by the RU/gNB threads (incomplete), after all
+ * threads have been stopped (they partially use the same memory) */
+
+ pthread_cond_destroy(&sync_cond);
+ pthread_mutex_destroy(&sync_mutex);
+
+ logClean();
+ printf("Bye.\n");
+ return 0;
+}
+
+
+
diff --git a/openair3/NGAP/ngap_gNB.c b/openair3/NGAP/ngap_gNB.c
index f8c1b93075..d603229572 100644
--- a/openair3/NGAP/ngap_gNB.c
+++ b/openair3/NGAP/ngap_gNB.c
@@ -65,6 +65,7 @@
#include "oaisim_amf_test_s1c.h"
#endif
+ngap_gNB_config_t ngap_config;
static int ngap_gNB_generate_ng_setup_request(
ngap_gNB_instance_t *instance_p, ngap_gNB_amf_data_t *ngap_amf_data_p);
diff --git a/openair3/NGAP/ngap_gNB.h b/openair3/NGAP/ngap_gNB.h
index 2aa0080cd1..e011af0cf5 100644
--- a/openair3/NGAP/ngap_gNB.h
+++ b/openair3/NGAP/ngap_gNB.h
@@ -39,6 +39,16 @@
#ifndef NGAP_GNB_H_
#define NGAP_GNB_H_
+typedef struct ngap_gNB_config_s {
+ // MME related params
+ unsigned char amf_enabled; ///< AMF enabled ?
+} ngap_gNB_config_t;
+
+extern ngap_gNB_config_t ngap_config;
+
+#define AMF_MODE_ENABLED ngap_config.amf_enabled
+
+
void *ngap_gNB_process_itti_msg(void*);
void ngap_gNB_init(void);
void *ngap_gNB_task(void *arg);
diff --git a/openair3/NGAP/ngap_gNB_handlers.c b/openair3/NGAP/ngap_gNB_handlers.c
index 408957d899..b35741151f 100644
--- a/openair3/NGAP/ngap_gNB_handlers.c
+++ b/openair3/NGAP/ngap_gNB_handlers.c
@@ -1859,165 +1859,7 @@ static
int ngap_gNB_handle_ng_path_switch_request_ack(uint32_t assoc_id,
uint32_t stream,
NGAP_NGAP_PDU_t *pdu) {
-#if 0
- ngap_gNB_amf_data_t *amf_desc_p = NULL;
- ngap_gNB_ue_context_t *ue_desc_p = NULL;
- MessageDef *message_p = NULL;
- NGAP_PathSwitchRequestAcknowledge_t *pathSwitchRequestAcknowledge;
- NGAP_PathSwitchRequestAcknowledgeIEs_t *ie;
- NGAP_PDUSESSIONToBeSwitchedULItemIEs_t *ngap_PDUSESSIONToBeSwitchedULItemIEs;
- NGAP_PDUSESSIONToBeSwitchedULItem_t *ngap_PDUSESSIONToBeSwitchedULItem;
- NGAP_PDUSESSIONItemIEs_t *e_RABItemIEs;
- NGAP_PDUSESSIONItem_t *e_RABItem;
- DevAssert(pdu != NULL);
- pathSwitchRequestAcknowledge = &pdu->choice.successfulOutcome->value.choice.PathSwitchRequestAcknowledge;
-
- /* Path Switch request == UE-related procedure -> stream !=0 */
- if (stream == 0) {
- NGAP_ERROR("[SCTP %d] Received s1 path switch request ack on stream (%d)\n",
- assoc_id, stream);
- //return -1;
- }
-
- if ((amf_desc_p = ngap_gNB_get_AMF(NULL, assoc_id, 0)) == NULL) {
- NGAP_ERROR("[SCTP %d] Received S1 path switch request ack for non existing "
- "AMF context\n", assoc_id);
- return -1;
- }
-
- // send a message to RRC
- message_p = itti_alloc_new_message(TASK_NGAP, NGAP_PATH_SWITCH_REQ_ACK);
- /* mandatory */
- NGAP_FIND_PROTOCOLIE_BY_ID(NGAP_PathSwitchRequestAcknowledgeIEs_t, ie, pathSwitchRequestAcknowledge,
- NGAP_ProtocolIE_ID_id_gNB_UE_NGAP_ID, true);
- if (ie == NULL) {
- NGAP_ERROR("[SCTP %d] Received path switch request ack for non "
- "ie context is NULL\n", assoc_id);
- return -1;
- }
-
- NGAP_PATH_SWITCH_REQ_ACK(message_p).gNB_ue_ngap_id = ie->value.choice.GNB_UE_NGAP_ID;
-
- if ((ue_desc_p = ngap_gNB_get_ue_context(amf_desc_p->ngap_gNB_instance,
- ie->value.choice.GNB_UE_NGAP_ID)) == NULL) {
- NGAP_ERROR("[SCTP %d] Received path switch request ack for non "
- "existing UE context 0x%06lx\n", assoc_id,
- ie->value.choice.GNB_UE_NGAP_ID);
- itti_free(ITTI_MSG_ORIGIN_ID(message_p), message_p);
- return -1;
- }
-
- NGAP_PATH_SWITCH_REQ_ACK(message_p).ue_initial_id = ue_desc_p->ue_initial_id;
- /* mandatory */
- NGAP_FIND_PROTOCOLIE_BY_ID(NGAP_PathSwitchRequestAcknowledgeIEs_t, ie, pathSwitchRequestAcknowledge,
- NGAP_ProtocolIE_ID_id_AMF_UE_NGAP_ID, true);
-
- if (ie == NULL) {
- NGAP_ERROR("[SCTP %d] Received path switch request ack for non "
- "ie context is NULL\n", assoc_id);
- return -1;
- }
-
- NGAP_PATH_SWITCH_REQ_ACK(message_p).amf_ue_ngap_id = ie->value.choice.AMF_UE_NGAP_ID;
-
- if ( ue_desc_p->amf_ue_ngap_id != ie->value.choice.AMF_UE_NGAP_ID) {
- NGAP_WARN("UE context amf_ue_ngap_id is different form that of the message (%d != %ld)",
- ue_desc_p->amf_ue_ngap_id, ie->value.choice.AMF_UE_NGAP_ID);
- }
-
- /* mandatory */
- NGAP_FIND_PROTOCOLIE_BY_ID(NGAP_PathSwitchRequestAcknowledgeIEs_t, ie, pathSwitchRequestAcknowledge,
- NGAP_ProtocolIE_ID_id_SecurityContext, true);
-
- if (ie == NULL) {
- NGAP_ERROR("[SCTP %d] Received path switch request ack for non "
- "ie context is NULL\n", assoc_id);
- return -1;
- }
-
- NGAP_PATH_SWITCH_REQ_ACK(message_p).next_hop_chain_count =
- ie->value.choice.SecurityContext.nextHopChainingCount;
- memcpy(&NGAP_PATH_SWITCH_REQ_ACK(message_p).next_security_key,
- ie->value.choice.SecurityContext.nextHopParameter.buf,
- ie->value.choice.SecurityContext.nextHopParameter.size);
- /* optional */
- NGAP_FIND_PROTOCOLIE_BY_ID(NGAP_PathSwitchRequestAcknowledgeIEs_t, ie, pathSwitchRequestAcknowledge,
- NGAP_ProtocolIE_ID_id_uEaggregateMaximumBitrate, false);
-
- if (ie) {
- OCTET_STRING_TO_INT32 (
- &ie->value.choice.UEAggregateMaximumBitrate.uEaggregateMaximumBitRateUL,
- NGAP_PATH_SWITCH_REQ_ACK(message_p).ue_ambr.br_ul
- );
- OCTET_STRING_TO_INT32 (
- &ie->value.choice.UEAggregateMaximumBitrate.uEaggregateMaximumBitRateDL,
- NGAP_PATH_SWITCH_REQ_ACK(message_p).ue_ambr.br_dl
- );
- } else {
- NGAP_WARN("UEAggregateMaximumBitrate not supported\n");
- NGAP_PATH_SWITCH_REQ_ACK(message_p).ue_ambr.br_ul = 0;
- NGAP_PATH_SWITCH_REQ_ACK(message_p).ue_ambr.br_dl = 0;
- }
-
- /* optional */
- NGAP_FIND_PROTOCOLIE_BY_ID(NGAP_PathSwitchRequestAcknowledgeIEs_t, ie, pathSwitchRequestAcknowledge,
- NGAP_ProtocolIE_ID_id_PDUSESSIONToBeSwitchedULList, false);
-
- if (ie) {
- NGAP_PATH_SWITCH_REQ_ACK(message_p).nb_pdusessions_tobeswitched = ie->value.choice.PDUSESSIONToBeSwitchedULList.list.count;
-
- for (int i = 0; i < ie->value.choice.PDUSESSIONToBeSwitchedULList.list.count; i++) {
- ngap_PDUSESSIONToBeSwitchedULItemIEs = (NGAP_PDUSESSIONToBeSwitchedULItemIEs_t *)ie->value.choice.PDUSESSIONToBeSwitchedULList.list.array[i];
- ngap_PDUSESSIONToBeSwitchedULItem = &ngap_PDUSESSIONToBeSwitchedULItemIEs->value.choice.PDUSESSIONToBeSwitchedULItem;
- NGAP_PATH_SWITCH_REQ_ACK (message_p).pdusessions_tobeswitched[i].pdusession_id = ngap_PDUSESSIONToBeSwitchedULItem->e_RAB_ID;
- memcpy(NGAP_PATH_SWITCH_REQ_ACK (message_p).pdusessions_tobeswitched[i].sgw_addr.buffer,
- ngap_PDUSESSIONToBeSwitchedULItem->transportLayerAddress.buf, ngap_PDUSESSIONToBeSwitchedULItem->transportLayerAddress.size);
- NGAP_PATH_SWITCH_REQ_ACK (message_p).pdusessions_tobeswitched[i].sgw_addr.length =
- ngap_PDUSESSIONToBeSwitchedULItem->transportLayerAddress.size * 8 - ngap_PDUSESSIONToBeSwitchedULItem->transportLayerAddress.bits_unused;
- OCTET_STRING_TO_INT32(&ngap_PDUSESSIONToBeSwitchedULItem->gTP_TEID,
- NGAP_PATH_SWITCH_REQ_ACK (message_p).pdusessions_tobeswitched[i].gtp_teid);
- }
- } else {
- NGAP_WARN("PDUSESSIONToBeSwitchedULList not supported\n");
- NGAP_PATH_SWITCH_REQ_ACK(message_p).nb_pdusessions_tobeswitched = 0;
- }
-
- /* optional */
- NGAP_FIND_PROTOCOLIE_BY_ID(NGAP_PathSwitchRequestAcknowledgeIEs_t, ie, pathSwitchRequestAcknowledge,
- NGAP_ProtocolIE_ID_id_PDUSESSIONToBeReleasedList, false);
-
- if (ie) {
- NGAP_PATH_SWITCH_REQ_ACK(message_p).nb_pdusessions_tobereleased = ie->value.choice.PDUSESSIONList.list.count;
-
- for (int i = 0; i < ie->value.choice.PDUSESSIONList.list.count; i++) {
- e_RABItemIEs = (NGAP_PDUSESSIONItemIEs_t *)ie->value.choice.PDUSESSIONList.list.array[i];
- e_RABItem = &e_RABItemIEs->value.choice.PDUSESSIONItem;
- NGAP_PATH_SWITCH_REQ_ACK (message_p).pdusessions_tobereleased[i].pdusession_id = e_RABItem->e_RAB_ID;
- }
- } else {
- NGAP_WARN("PDUSESSIONToBeReleasedList not supported\n");
- NGAP_PATH_SWITCH_REQ_ACK(message_p).nb_pdusessions_tobereleased = 0;
- }
-
- /* optional */
- NGAP_FIND_PROTOCOLIE_BY_ID(NGAP_PathSwitchRequestAcknowledgeIEs_t, ie, pathSwitchRequestAcknowledge,
- NGAP_ProtocolIE_ID_id_CriticalityDiagnostics, false);
-
- if(!ie) {
- NGAP_WARN("Critical Diagnostic not supported\n");
- }
-
- /* optional */
- NGAP_FIND_PROTOCOLIE_BY_ID(NGAP_PathSwitchRequestAcknowledgeIEs_t, ie, pathSwitchRequestAcknowledge,
- NGAP_ProtocolIE_ID_id_AMF_UE_NGAP_ID_2, false);
-
- if(!ie) {
- NGAP_WARN("AMF_UE_NGAP_ID_2 flag not supported\n");
- }
-
- // TODO continue
- itti_send_msg_to_task(TASK_RRC_GNB, ue_desc_p->gNB_instance->instance, message_p);
-#endif
+ // TODO
return 0;
}
@@ -2025,68 +1867,8 @@ static
int ngap_gNB_handle_ng_path_switch_request_failure(uint32_t assoc_id,
uint32_t stream,
NGAP_NGAP_PDU_t *pdu) {
-#if 0
- ngap_gNB_amf_data_t *amf_desc_p = NULL;
- NGAP_PathSwitchRequestFailure_t *pathSwitchRequestFailure;
- NGAP_PathSwitchRequestFailureIEs_t *ie;
- DevAssert(pdu != NULL);
- pathSwitchRequestFailure = &pdu->choice.unsuccessfulOutcome->value.choice.PathSwitchRequestFailure;
- if (stream != 0) {
- NGAP_ERROR("[SCTP %d] Received s1 path switch request failure on stream != 0 (%d)\n",
- assoc_id, stream);
- return -1;
- }
-
- if ((amf_desc_p = ngap_gNB_get_AMF(NULL, assoc_id, 0)) == NULL) {
- NGAP_ERROR("[SCTP %d] Received S1 path switch request failure for non existing "
- "AMF context\n", assoc_id);
- return -1;
- }
-
- NGAP_FIND_PROTOCOLIE_BY_ID(NGAP_PathSwitchRequestFailureIEs_t, ie, pathSwitchRequestFailure,
- NGAP_ProtocolIE_ID_id_Cause, true);
-
- if (ie == NULL) {
- NGAP_ERROR("[SCTP %d] Received S1 path switch request failure for non existing "
- "ie context is NULL\n", assoc_id);
- return -1;
- }
-
- switch(ie->value.choice.Cause.present) {
- case NGAP_Cause_PR_NOTHING:
- NGAP_WARN("Received S1 Error indication cause NOTHING\n");
- break;
-
- case NGAP_Cause_PR_radioNetwork:
- NGAP_WARN("Radio Network Layer Cause Failure\n");
- break;
-
- case NGAP_Cause_PR_transport:
- NGAP_WARN("Transport Layer Cause Failure\n");
- break;
-
- case NGAP_Cause_PR_nas:
- NGAP_WARN("NAS Cause Failure\n");
- break;
-
- case NGAP_Cause_PR_misc:
- NGAP_WARN("Miscelaneous Cause Failure\n");
- break;
-
- default:
- NGAP_WARN("Received an unknown S1 Error indication cause\n");
- break;
- }
-
- NGAP_FIND_PROTOCOLIE_BY_ID(NGAP_PathSwitchRequestFailureIEs_t, ie, pathSwitchRequestFailure,
- NGAP_ProtocolIE_ID_id_CriticalityDiagnostics, false);
-
- if(!ie) {
- NGAP_WARN("Critical Diagnostic not supported\n");
- }
-#endif
- // TODO continue
+ // TODO
return 0;
}
@@ -2095,7 +1877,7 @@ int ngap_gNB_handle_ng_ENDC_pdusession_modification_confirm(uint32_t
uint32_t stream,
NGAP_NGAP_PDU_t *pdu){
- LOG_W(NGAP, "Implementation of NGAP E-RAB Modification confirm handler is pending...\n");
+ LOG_W(NGAP, "Implementation of NGAP Pdusession Modification confirm handler is pending...\n");
return 0;
}
diff --git a/openair3/NGAP/ngap_gNB_nas_procedures.c b/openair3/NGAP/ngap_gNB_nas_procedures.c
index ef8472dcc0..edf001ec61 100644
--- a/openair3/NGAP/ngap_gNB_nas_procedures.c
+++ b/openair3/NGAP/ngap_gNB_nas_procedures.c
@@ -76,6 +76,7 @@ int ngap_gNB_handle_nas_first_req(
out = &pdu.choice.initiatingMessage->value.choice.InitialUEMessage;
/* Select the AMF corresponding to the provided GUAMI. */
+ //TODO have not be test. it's should be test
if (ngap_nas_first_req_p->ue_identity.presenceMask & NGAP_UE_IDENTITIES_guami) {
amf_desc_p = ngap_gNB_nnsf_select_amf_by_guami(
instance_p,
@@ -97,6 +98,7 @@ int ngap_gNB_handle_nas_first_req(
if (amf_desc_p == NULL) {
/* Select the AMF corresponding to the provided s-TMSI. */
+ //TODO have not be test. it's should be test
if (ngap_nas_first_req_p->ue_identity.presenceMask & NGAP_UE_IDENTITIES_FiveG_s_tmsi) {
amf_desc_p = ngap_gNB_nnsf_select_amf_by_amf_setid(
instance_p,
@@ -120,6 +122,7 @@ int ngap_gNB_handle_nas_first_req(
if (amf_desc_p == NULL) {
/* Select AMF based on the selected PLMN identity, received through RRC
* Connection Setup Complete */
+ //TODO have not be test. it's should be test
amf_desc_p = ngap_gNB_nnsf_select_amf_by_plmn_id(
instance_p,
ngap_nas_first_req_p->establishment_cause,
@@ -141,6 +144,7 @@ int ngap_gNB_handle_nas_first_req(
* If no AMF corresponds to the GUAMI, the s-TMSI, or the selected PLMN
* identity, selects the AMF with the highest capacity.
*/
+ //TODO have not be test. it's should be test
amf_desc_p = ngap_gNB_nnsf_select_amf(
instance_p,
ngap_nas_first_req_p->establishment_cause);
@@ -1439,237 +1443,7 @@ int ngap_gNB_path_switch_req(instance_t instance,
ngap_path_switch_req_t *path_switch_req_p)
//------------------------------------------------------------------------------
{
-#if 0
- ngap_gNB_instance_t *ngap_gNB_instance_p = NULL;
- struct ngap_gNB_ue_context_s *ue_context_p = NULL;
- struct ngap_gNB_amf_data_s *amf_desc_p = NULL;
-
- NGAP_NGAP_PDU_t pdu;
- NGAP_PathSwitchRequest_t *out;
- NGAP_PathSwitchRequestIEs_t *ie;
-
- NGAP_PDUSESSIONToBeSwitchedDLItemIEs_t *e_RABToBeSwitchedDLItemIEs;
- NGAP_PDUSESSIONToBeSwitchedDLItem_t *e_RABToBeSwitchedDLItem;
-
- uint8_t *buffer = NULL;
- uint32_t length;
- int ret = 0;//-1;
-
- /* Retrieve the NGAP gNB instance associated with Mod_id */
- ngap_gNB_instance_p = ngap_gNB_get_instance(instance);
-
- DevAssert(path_switch_req_p != NULL);
- DevAssert(ngap_gNB_instance_p != NULL);
-
- //if ((ue_context_p = ngap_gNB_get_ue_context(ngap_gNB_instance_p,
- // path_switch_req_p->gNB_ue_ngap_id)) == NULL) {
- /* The context for this gNB ue ngap id doesn't exist in the map of gNB UEs */
- //NGAP_WARN("Failed to find ue context associated with gNB ue ngap id: 0x%06x\n",
- // path_switch_req_p->gNB_ue_ngap_id);
- //return -1;
- //}
-
- /* Uplink NAS transport can occur either during an ngap connected state
- * or during initial attach (for example: NAS authentication).
- */
- //if (!(ue_context_p->ue_state == NGAP_UE_CONNECTED ||
- // ue_context_p->ue_state == NGAP_UE_WAITING_CSR)) {
- //NGAP_WARN("You are attempting to send NAS data over non-connected "
- // "gNB ue ngap id: %06x, current state: %d\n",
- // path_switch_req_p->gNB_ue_ngap_id, ue_context_p->ue_state);
- //return -1;
- //}
-
- /* Select the AMF corresponding to the provided GUAMI. */
- amf_desc_p = ngap_gNB_nnsf_select_amf_by_guami_no_cause(ngap_gNB_instance_p, path_switch_req_p->ue_guami);
-
- if (amf_desc_p == NULL) {
- /*
- * In case gNB has no AMF associated, the gNB should inform RRC and discard
- * this request.
- */
-
- NGAP_WARN("No AMF is associated to the gNB\n");
- // TODO: Inform RRC
- return -1;
- }
-
- /* The gNB should allocate a unique gNB UE NGAP ID for this UE. The value
- * will be used for the duration of the connectivity.
- */
- ue_context_p = ngap_gNB_allocate_new_UE_context();
- DevAssert(ue_context_p != NULL);
-
- /* Keep a reference to the selected AMF */
- ue_context_p->amf_ref = amf_desc_p;
- ue_context_p->ue_initial_id = path_switch_req_p->ue_initial_id;
- ue_context_p->gNB_instance = ngap_gNB_instance_p;
-
- do {
- struct ngap_gNB_ue_context_s *collision_p;
-
- /* Peek a random value for the gNB_ue_ngap_id */
- ue_context_p->gNB_ue_ngap_id = (random() + random()) & 0x00ffffff;
-
- if ((collision_p = RB_INSERT(ngap_ue_map, &ngap_gNB_instance_p->ngap_ue_head, ue_context_p))
- == NULL) {
- NGAP_DEBUG("Found usable gNB_ue_ngap_id: 0x%06x %u(10)\n",
- ue_context_p->gNB_ue_ngap_id,
- ue_context_p->gNB_ue_ngap_id);
- /* Break the loop as the id is not already used by another UE */
- break;
- }
- } while(1);
-
- ue_context_p->amf_ue_ngap_id = path_switch_req_p->amf_ue_ngap_id;
-
- /* Prepare the NGAP message to encode */
- memset(&pdu, 0, sizeof(pdu));
- pdu.present = NGAP_NGAP_PDU_PR_initiatingMessage;
- pdu.choice.initiatingMessage->procedureCode = NGAP_ProcedureCode_id_PathSwitchRequest;
- pdu.choice.initiatingMessage->criticality = NGAP_Criticality_reject;
- pdu.choice.initiatingMessage->value.present = NGAP_InitiatingMessage__value_PR_PathSwitchRequest;
- out = &pdu.choice.initiatingMessage->value.choice.PathSwitchRequest;
-
- /* mandatory */
- ie = (NGAP_PathSwitchRequestIEs_t *)calloc(1, sizeof(NGAP_PathSwitchRequestIEs_t));
- ie->id = NGAP_ProtocolIE_ID_id_gNB_UE_NGAP_ID;
- ie->criticality = NGAP_Criticality_reject;
- ie->value.present = NGAP_PathSwitchRequestIEs__value_PR_GNB_UE_NGAP_ID;
- ie->value.choice.GNB_UE_NGAP_ID = ue_context_p->gNB_ue_ngap_id;
- ASN_SEQUENCE_ADD(&out->protocolIEs.list, ie);
-
- /* mandatory */
- if (path_switch_req_p->nb_of_pdusessions > 0) {
- ie = (NGAP_PathSwitchRequestIEs_t *)calloc(1, sizeof(NGAP_PathSwitchRequestIEs_t));
- ie->id = NGAP_ProtocolIE_ID_id_PDUSESSIONToBeSwitchedDLList;
- ie->criticality = NGAP_Criticality_reject;
- ie->value.present = NGAP_PathSwitchRequestIEs__value_PR_PDUSESSIONToBeSwitchedDLList;
-
- for (int i = 0; i < path_switch_req_p->nb_of_pdusessions; i++) {
- e_RABToBeSwitchedDLItemIEs = (NGAP_PDUSESSIONToBeSwitchedDLItemIEs_t *)calloc(1, sizeof(NGAP_PDUSESSIONToBeSwitchedDLItemIEs_t));
- e_RABToBeSwitchedDLItemIEs->id = NGAP_ProtocolIE_ID_id_PDUSESSIONToBeSwitchedDLItem;
- e_RABToBeSwitchedDLItemIEs->criticality = NGAP_Criticality_reject;
- e_RABToBeSwitchedDLItemIEs->value.present = NGAP_PDUSESSIONToBeSwitchedDLItemIEs__value_PR_PDUSESSIONToBeSwitchedDLItem;
-
- e_RABToBeSwitchedDLItem = &e_RABToBeSwitchedDLItemIEs->value.choice.PDUSESSIONToBeSwitchedDLItem;
- e_RABToBeSwitchedDLItem->e_RAB_ID = path_switch_req_p->pdusessions_tobeswitched[i].pdusession_id;
- INT32_TO_OCTET_STRING(path_switch_req_p->pdusessions_tobeswitched[i].gtp_teid, &e_RABToBeSwitchedDLItem->gTP_TEID);
-
- e_RABToBeSwitchedDLItem->transportLayerAddress.size = path_switch_req_p->pdusessions_tobeswitched[i].gNB_addr.length;
- e_RABToBeSwitchedDLItem->transportLayerAddress.bits_unused = 0;
-
- e_RABToBeSwitchedDLItem->transportLayerAddress.buf = calloc(1,e_RABToBeSwitchedDLItem->transportLayerAddress.size);
-
- memcpy (e_RABToBeSwitchedDLItem->transportLayerAddress.buf,
- path_switch_req_p->pdusessions_tobeswitched[i].gNB_addr.buffer,
- path_switch_req_p->pdusessions_tobeswitched[i].gNB_addr.length);
-
- NGAP_DEBUG("path_switch_req: pdusession ID %ld, teid %u, enb_addr %d.%d.%d.%d, SIZE %zu\n",
- e_RABToBeSwitchedDLItem->e_RAB_ID,
- path_switch_req_p->pdusessions_tobeswitched[i].gtp_teid,
- e_RABToBeSwitchedDLItem->transportLayerAddress.buf[0],
- e_RABToBeSwitchedDLItem->transportLayerAddress.buf[1],
- e_RABToBeSwitchedDLItem->transportLayerAddress.buf[2],
- e_RABToBeSwitchedDLItem->transportLayerAddress.buf[3],
- e_RABToBeSwitchedDLItem->transportLayerAddress.size);
-
- ASN_SEQUENCE_ADD(&ie->value.choice.PDUSESSIONToBeSwitchedDLList.list, e_RABToBeSwitchedDLItemIEs);
- }
-
- ASN_SEQUENCE_ADD(&out->protocolIEs.list, ie);
- }
-
- /* mandatory */
- ie = (NGAP_PathSwitchRequestIEs_t *)calloc(1, sizeof(NGAP_PathSwitchRequestIEs_t));
- ie->id = NGAP_ProtocolIE_ID_id_SourceAMF_UE_NGAP_ID;
- ie->criticality = NGAP_Criticality_reject;
- ie->value.present = NGAP_PathSwitchRequestIEs__value_PR_AMF_UE_NGAP_ID;
- ie->value.choice.AMF_UE_NGAP_ID = path_switch_req_p->amf_ue_ngap_id;
- ASN_SEQUENCE_ADD(&out->protocolIEs.list, ie);
-
- /* mandatory */
- ie = (NGAP_PathSwitchRequestIEs_t *)calloc(1, sizeof(NGAP_PathSwitchRequestIEs_t));
- ie->id = NGAP_ProtocolIE_ID_id_EUTRAN_CGI;
- ie->criticality = NGAP_Criticality_ignore;
- ie->value.present = NGAP_PathSwitchRequestIEs__value_PR_EUTRAN_CGI;
- MACRO_GNB_ID_TO_CELL_IDENTITY(ngap_gNB_instance_p->gNB_id,
- 0,
- &ie->value.choice.EUTRAN_CGI.cell_ID);
- MCC_MNC_TO_TBCD(ngap_gNB_instance_p->mcc[0],
- ngap_gNB_instance_p->mnc[0],
- ngap_gNB_instance_p->mnc_digit_length[0],
- &ie->value.choice.EUTRAN_CGI.pLMNidentity);
- ASN_SEQUENCE_ADD(&out->protocolIEs.list, ie);
-
- /* mandatory */
- ie = (NGAP_PathSwitchRequestIEs_t *)calloc(1, sizeof(NGAP_PathSwitchRequestIEs_t));
- ie->id = NGAP_ProtocolIE_ID_id_TAI;
- ie->criticality = NGAP_Criticality_ignore;
- ie->value.present = NGAP_PathSwitchRequestIEs__value_PR_TAI;
- /* Assuming TAI is the TAI from the cell */
- INT16_TO_OCTET_STRING(ngap_gNB_instance_p->tac, &ie->value.choice.TAI.tAC);
- MCC_MNC_TO_PLMNID(ngap_gNB_instance_p->mcc[0],
- ngap_gNB_instance_p->mnc[0],
- ngap_gNB_instance_p->mnc_digit_length[0],
- &ie->value.choice.TAI.pLMNidentity);
- ASN_SEQUENCE_ADD(&out->protocolIEs.list, ie);
-
- /* mandatory */
- ie = (NGAP_PathSwitchRequestIEs_t *)calloc(1, sizeof(NGAP_PathSwitchRequestIEs_t));
- ie->id = NGAP_ProtocolIE_ID_id_UESecurityCapabilities;
- ie->criticality = NGAP_Criticality_ignore;
- ie->value.present = NGAP_PathSwitchRequestIEs__value_PR_UESecurityCapabilities;
- ENCRALG_TO_BIT_STRING(path_switch_req_p->security_capabilities.encryption_algorithms,
- &ie->value.choice.UESecurityCapabilities.encryptionAlgorithms);
- INTPROTALG_TO_BIT_STRING(path_switch_req_p->security_capabilities.integrity_algorithms,
- &ie->value.choice.UESecurityCapabilities.integrityProtectionAlgorithms);
- ASN_SEQUENCE_ADD(&out->protocolIEs.list, ie);
-
- if (ngap_gNB_encode_pdu(&pdu, &buffer, &length) < 0) {
- NGAP_ERROR("Failed to encode Path Switch Req \n");
- /* Encode procedure has failed... */
- return -1;
- }
-
- /* Update the current NGAP UE state */
- ue_context_p->ue_state = NGAP_UE_WAITING_CSR;
-
- /* Assign a stream for this UE :
- * From 3GPP 36.412 7)Transport layers:
- * Within the SCTP association established between one AMF and gNB pair:
- * - a single pair of stream identifiers shall be reserved for the sole use
- * of NGAP elementary procedures that utilize non UE-associated signalling.
- * - At least one pair of stream identifiers shall be reserved for the sole use
- * of NGAP elementary procedures that utilize UE-associated signallings.
- * However a few pairs (i.e. more than one) should be reserved.
- * - A single UE-associated signalling shall use one SCTP stream and
- * the stream should not be changed during the communication of the
- * UE-associated signalling.
- */
- amf_desc_p->nextstream = (amf_desc_p->nextstream + 1) % amf_desc_p->out_streams;
-
- if ((amf_desc_p->nextstream == 0) && (amf_desc_p->out_streams > 1)) {
- amf_desc_p->nextstream += 1;
- }
-
- ue_context_p->tx_stream = amf_desc_p->nextstream;
-
- MSC_LOG_TX_MESSAGE(
- MSC_NGAP_GNB,
- MSC_NGAP_AMF,
- (const char *)buffer,
- length,
- MSC_AS_TIME_FMT" E_RAN Setup successfulOutcome gNB_ue_ngap_id %u amf_ue_ngap_id %u",
- 0,0,//MSC_AS_TIME_ARGS(ctxt_pP),
- ue_context_p->gNB_ue_ngap_id,
- path_switch_req_p->amf_ue_ngap_id);
-
- /* UE associated signalling -> use the allocated stream */
- ngap_gNB_itti_send_sctp_data_req(ngap_gNB_instance_p->instance,
- amf_desc_p->assoc_id, buffer,
- length, ue_context_p->tx_stream);
-#endif
+ //TODO
return 0;
}
@@ -1679,156 +1453,7 @@ int ngap_gNB_generate_PDUSESSION_Modification_Indication(
ngap_pdusession_modification_ind_t *pdusession_modification_ind)
//-----------------------------------------------------------------------------
{
-#if 0
- struct ngap_gNB_ue_context_s *ue_context_p = NULL;
- NGAP_NGAP_PDU_t pdu;
- NGAP_PDUSESSIONModificationIndication_t *out = NULL;
- NGAP_PDUSESSIONModificationIndicationIEs_t *ie = NULL;
- NGAP_PDUSESSIONToBeModifiedItemBearerModInd_t *PDUSESSION_ToBeModifiedItem_BearerModInd = NULL;
- NGAP_PDUSESSIONToBeModifiedItemBearerModIndIEs_t *PDUSESSION_ToBeModifiedItem_BearerModInd_IEs = NULL;
-
- //NGAP_PDUSESSIONNotToBeModifiedItemBearerModInd_t *PDUSESSION_NotToBeModifiedItem_BearerModInd = NULL;
- //NGAP_PDUSESSIONNotToBeModifiedItemBearerModIndIEs_t *PDUSESSION_NotToBeModifiedItem_BearerModInd_IEs = NULL;
-
-
- ngap_gNB_instance_t *ngap_gNB_instance_p = NULL;
- ngap_gNB_instance_p = ngap_gNB_get_instance(instance);
- uint8_t *buffer = NULL;
- uint32_t len = 0;
- int ret = 0;
- DevAssert(ngap_gNB_instance_p != NULL);
- DevAssert(pdusession_modification_ind != NULL);
-
- int num_pdusessions_tobemodified = pdusession_modification_ind->nb_of_pdusessions_tobemodified;
- //int num_pdusessions_nottobemodified = pdusession_modification_ind->nb_of_pdusessions_nottobemodified;
-
- //uint32_t CSG_id = 0;
- //uint32_t pseudo_gtp_teid = 10;
-
- if ((ue_context_p = ngap_gNB_get_ue_context(ngap_gNB_instance_p,
- pdusession_modification_ind->gNB_ue_ngap_id)) == NULL) {
- // The context for this gNB ue ngap id doesn't exist in the map of gNB UEs
- NGAP_WARN("Failed to find ue context associated with gNB ue ngap id: 0x%06x\n",
- pdusession_modification_ind->gNB_ue_ngap_id);
- return -1;
- }
-
- // Prepare the NGAP message to encode
- memset(&pdu, 0, sizeof(pdu));
- pdu.present = NGAP_NGAP_PDU_PR_initiatingMessage;
- pdu.choice.initiatingMessage->procedureCode = NGAP_ProcedureCode_id_PDUSESSIONModificationIndication;
- pdu.choice.initiatingMessage->criticality = NGAP_Criticality_reject;
- pdu.choice.initiatingMessage->value.present = NGAP_InitiatingMessage__value_PR_PDUSESSIONModificationIndication;
- out = &pdu.choice.initiatingMessage->value.choice.PDUSESSIONModificationIndication;
- /* mandatory */
- ie = (NGAP_PDUSESSIONModificationIndicationIEs_t *)calloc(1, sizeof(NGAP_PDUSESSIONModificationIndicationIEs_t));
- ie->id = NGAP_ProtocolIE_ID_id_AMF_UE_NGAP_ID;
- ie->criticality = NGAP_Criticality_reject;
- ie->value.present = NGAP_PDUSESSIONModificationIndicationIEs__value_PR_AMF_UE_NGAP_ID;
- ie->value.choice.AMF_UE_NGAP_ID = pdusession_modification_ind->amf_ue_ngap_id;
- ASN_SEQUENCE_ADD(&out->protocolIEs.list, ie);
-
- ie = (NGAP_PDUSESSIONModificationIndicationIEs_t *)calloc(1, sizeof(NGAP_PDUSESSIONModificationIndicationIEs_t));
- ie->id = NGAP_ProtocolIE_ID_id_gNB_UE_NGAP_ID;
- ie->criticality = NGAP_Criticality_reject;
- ie->value.present = NGAP_PDUSESSIONModificationIndicationIEs__value_PR_GNB_UE_NGAP_ID;
- ie->value.choice.GNB_UE_NGAP_ID = pdusession_modification_ind->gNB_ue_ngap_id;
- ASN_SEQUENCE_ADD(&out->protocolIEs.list, ie);
-
- //E-RABs to be modified list
- ie = (NGAP_PDUSESSIONModificationIndicationIEs_t *)calloc(1, sizeof(NGAP_PDUSESSIONModificationIndicationIEs_t));
- ie->id = NGAP_ProtocolIE_ID_id_PDUSESSIONToBeModifiedListBearerModInd;
- ie->criticality = NGAP_Criticality_reject;
- ie->value.present = NGAP_PDUSESSIONModificationIndicationIEs__value_PR_PDUSESSIONToBeModifiedListBearerModInd;
-
- //The following two for-loops here will probably need to change. We should do a different type of search
- for(int i=0; iid = NGAP_ProtocolIE_ID_id_PDUSESSIONToBeModifiedItemBearerModInd;
- PDUSESSION_ToBeModifiedItem_BearerModInd_IEs->criticality = NGAP_Criticality_reject;
- PDUSESSION_ToBeModifiedItem_BearerModInd_IEs->value.present = NGAP_PDUSESSIONToBeModifiedItemBearerModIndIEs__value_PR_PDUSESSIONToBeModifiedItemBearerModInd;
- PDUSESSION_ToBeModifiedItem_BearerModInd = &PDUSESSION_ToBeModifiedItem_BearerModInd_IEs->value.choice.PDUSESSIONToBeModifiedItemBearerModInd;
-
- {
- PDUSESSION_ToBeModifiedItem_BearerModInd->e_RAB_ID = pdusession_modification_ind->pdusessions_tobemodified[i].pdusession_id;
-
- PDUSESSION_ToBeModifiedItem_BearerModInd->transportLayerAddress.size = pdusession_modification_ind->pdusessions_tobemodified[i].gNB_addr.length/8;
- PDUSESSION_ToBeModifiedItem_BearerModInd->transportLayerAddress.bits_unused = pdusession_modification_ind->pdusessions_tobemodified[i].gNB_addr.length%8;
- PDUSESSION_ToBeModifiedItem_BearerModInd->transportLayerAddress.buf = calloc(1, PDUSESSION_ToBeModifiedItem_BearerModInd->transportLayerAddress.size);
- memcpy (PDUSESSION_ToBeModifiedItem_BearerModInd->transportLayerAddress.buf, pdusession_modification_ind->pdusessions_tobemodified[i].gNB_addr.buffer,
- PDUSESSION_ToBeModifiedItem_BearerModInd->transportLayerAddress.size);
-
- INT32_TO_OCTET_STRING(pdusession_modification_ind->pdusessions_tobemodified[i].gtp_teid, &PDUSESSION_ToBeModifiedItem_BearerModInd->dL_GTP_TEID);
-
- }
- ASN_SEQUENCE_ADD(&ie->value.choice.PDUSESSIONToBeModifiedListBearerModInd.list, PDUSESSION_ToBeModifiedItem_BearerModInd_IEs);
- }
-
- ASN_SEQUENCE_ADD(&out->protocolIEs.list, ie);
-
- //E-RABs NOT to be modified list
- /*ie = (NGAP_PDUSESSIONModificationIndicationIEs_t *)calloc(1, sizeof(NGAP_PDUSESSIONModificationIndicationIEs_t));
- ie->id = NGAP_ProtocolIE_ID_id_PDUSESSIONNotToBeModifiedListBearerModInd;
- ie->criticality = NGAP_Criticality_reject;
- //if(num_pdusessions_nottobemodified > 0) {
- ie->value.present = NGAP_PDUSESSIONModificationIndicationIEs__value_PR_PDUSESSIONNotToBeModifiedListBearerModInd;
-
- for(int i=0; iid = NGAP_ProtocolIE_ID_id_PDUSESSIONNotToBeModifiedItemBearerModInd;
- PDUSESSION_NotToBeModifiedItem_BearerModInd_IEs->criticality = NGAP_Criticality_reject;
- PDUSESSION_NotToBeModifiedItem_BearerModInd_IEs->value.present = NGAP_PDUSESSIONNotToBeModifiedItemBearerModIndIEs__value_PR_PDUSESSIONNotToBeModifiedItemBearerModInd;
- PDUSESSION_NotToBeModifiedItem_BearerModInd = &PDUSESSION_NotToBeModifiedItem_BearerModInd_IEs->value.choice.PDUSESSIONNotToBeModifiedItemBearerModInd;
-
- {
- PDUSESSION_NotToBeModifiedItem_BearerModInd->e_RAB_ID = 10; //pdusession_modification_ind->pdusessions_tobemodified[i].pdusession_id;
-
- PDUSESSION_NotToBeModifiedItem_BearerModInd->transportLayerAddress.size = pdusession_modification_ind->pdusessions_tobemodified[i].gNB_addr.length/8;
- PDUSESSION_NotToBeModifiedItem_BearerModInd->transportLayerAddress.bits_unused = pdusession_modification_ind->pdusessions_tobemodified[i].gNB_addr.length%8;
- PDUSESSION_NotToBeModifiedItem_BearerModInd->transportLayerAddress.buf =
- calloc(1, PDUSESSION_NotToBeModifiedItem_BearerModInd->transportLayerAddress.size);
- memcpy (PDUSESSION_NotToBeModifiedItem_BearerModInd->transportLayerAddress.buf, pdusession_modification_ind->pdusessions_tobemodified[i].gNB_addr.buffer,
- PDUSESSION_NotToBeModifiedItem_BearerModInd->transportLayerAddress.size);
-
- //INT32_TO_OCTET_STRING(pdusession_modification_ind->pdusessions_tobemodified[i].gtp_teid, &PDUSESSION_NotToBeModifiedItem_BearerModInd->dL_GTP_TEID);
- INT32_TO_OCTET_STRING(pseudo_gtp_teid, &PDUSESSION_NotToBeModifiedItem_BearerModInd->dL_GTP_TEID);
-
- }
- ASN_SEQUENCE_ADD(&ie->value.choice.PDUSESSIONNotToBeModifiedListBearerModInd.list, PDUSESSION_NotToBeModifiedItem_BearerModInd_IEs);
- }
- // }
- //else{
-// ie->value.present = NGAP_PDUSESSIONModificationIndicationIEs__value_PR_PDUSESSIONNotToBeModifiedListBearerModInd;
-// ie->value.choice.PDUSESSIONNotToBeModifiedListBearerModInd.list.size = 0;
-// } /
-
-
-
- ASN_SEQUENCE_ADD(&out->protocolIEs.list, ie);*/
-
- /*ie = (NGAP_PDUSESSIONModificationIndicationIEs_t *)calloc(1, sizeof(NGAP_PDUSESSIONModificationIndicationIEs_t));
- ie->id = NGAP_ProtocolIE_ID_id_CSGMembershipInfo;
- ie->criticality = NGAP_Criticality_reject;
- ie->value.present = NGAP_PDUSESSIONModificationIndicationIEs__value_PR_CSGMembershipInfo;
- ie->value.choice.CSGMembershipInfo.cSGMembershipStatus = NGAP_CSGMembershipStatus_member;
- INT32_TO_BIT_STRING(CSG_id, &ie->value.choice.CSGMembershipInfo.cSG_Id);
- ie->value.choice.CSGMembershipInfo.cSG_Id.bits_unused=5;
- ie->value.choice.CSGMembershipInfo.cellAccessMode = NGAP_CellAccessMode_hybrid;
- ASN_SEQUENCE_ADD(&out->protocolIEs.list, ie);*/
-
- if (ngap_gNB_encode_pdu(&pdu, &buffer, &len) < 0) {
- NGAP_ERROR("Failed to encode S1 E-RAB modification indication \n");
- return -1;
- }
-
- // Non UE-Associated signalling -> stream = 0
- NGAP_INFO("Size of encoded message: %d \n", len);
- ngap_gNB_itti_send_sctp_data_req(ngap_gNB_instance_p->instance,
- ue_context_p->amf_ref->assoc_id, buffer,
- len, ue_context_p->tx_stream);
-
-//ngap_gNB_itti_send_sctp_data_req(ngap_gNB_instance_p->instance, ue_context_p->amf_ref->assoc_id, buffer, len, 0);
-#endif
+ //TODO
return 0;
}
diff --git a/openair3/NGAP/ngap_gNB_overload.c b/openair3/NGAP/ngap_gNB_overload.c
index 669478bccb..318a2124bd 100644
--- a/openair3/NGAP/ngap_gNB_overload.c
+++ b/openair3/NGAP/ngap_gNB_overload.c
@@ -49,38 +49,7 @@ int ngap_gNB_handle_overload_start(uint32_t assoc_id,
uint32_t stream,
NGAP_NGAP_PDU_t *pdu)
{
-#if 0
- ngap_gNB_amf_data_t *amf_desc_p;
- NGAP_OverloadStart_t *container;
- NGAP_OverloadStartIEs_t *ie;
-
- DevAssert(pdu != NULL);
-
- container = &pdu->choice.initiatingMessage.value.choice.OverloadStart;
-
- NGAP_FIND_PROTOCOLIE_BY_ID(NGAP_OverloadStartIEs_t, ie, container,
- NGAP_ProtocolIE_ID_id_OverloadResponse, true);
- if (ie != NULL) {
- DevCheck(ie->value.choice.OverloadResponse.present ==
- NGAP_OverloadResponse_PR_overloadAction,
- NGAP_OverloadResponse_PR_overloadAction, 0, 0);
- }
- /* Non UE-associated signalling -> stream 0 */
- DevCheck(stream == 0, stream, 0, 0);
-
- if ((amf_desc_p = ngap_gNB_get_AMF(NULL, assoc_id, 0)) == NULL) {
- /* No AMF context associated */
- return -1;
- }
-
- /* Mark the AMF as overloaded and set the overload state according to
- * the value received.
- */
- amf_desc_p->state = NGAP_GNB_OVERLOAD;
- amf_desc_p->overload_state =
- ie->value.choice.OverloadResponse.choice.overloadAction;
-
-#endif
+ //TODO
return 0;
}
diff --git a/openair3/NGAP/ngap_gNB_trace.c b/openair3/NGAP/ngap_gNB_trace.c
index b070c5d050..f3e216988c 100644
--- a/openair3/NGAP/ngap_gNB_trace.c
+++ b/openair3/NGAP/ngap_gNB_trace.c
@@ -50,38 +50,7 @@ int ngap_gNB_handle_trace_start(uint32_t assoc_id,
uint32_t stream,
NGAP_NGAP_PDU_t *pdu)
{
-#if 0
- NGAP_TraceStart_t *container;
- NGAP_TraceStartIEs_t *ie;
- struct ngap_gNB_ue_context_s *ue_desc_p = NULL;
- struct ngap_gNB_amf_data_s *amf_ref_p;
-
- DevAssert(pdu != NULL);
-
- container = &pdu->choice.initiatingMessage.value.choice.TraceStart;
-
- NGAP_FIND_PROTOCOLIE_BY_ID(NGAP_TraceStartIEs_t, ie, container,
- NGAP_ProtocolIE_ID_id_gNB_UE_NGAP_ID, TRUE);
- amf_ref_p = ngap_gNB_get_AMF(NULL, assoc_id, 0);
- DevAssert(amf_ref_p != NULL);
- if (ie != NULL) {
- ue_desc_p = ngap_gNB_get_ue_context(amf_ref_p->ngap_gNB_instance,
- ie->value.choice.GNB_UE_NGAP_ID);
- }
- if (ue_desc_p == NULL) {
- /* Could not find context associated with this gNB_ue_ngap_id -> generate
- * trace failure indication.
- */
- NGAP_E_UTRAN_Trace_ID_t trace_id;
- NGAP_Cause_t cause;
- memset(&trace_id, 0, sizeof(NGAP_E_UTRAN_Trace_ID_t));
- memset(&cause, 0, sizeof(NGAP_Cause_t));
- cause.present = NGAP_Cause_PR_radioNetwork;
- cause.choice.radioNetwork = NGAP_CauseRadioNetwork_unknown_pair_ue_ngap_id;
- ngap_gNB_generate_trace_failure(NULL, &trace_id, &cause);
- }
-
-#endif
+ //TODO
return 0;
}
diff --git a/openair3/S1AP/s1ap_eNB_handlers.c b/openair3/S1AP/s1ap_eNB_handlers.c
index 28ee11187e..79501a1a09 100644
--- a/openair3/S1AP/s1ap_eNB_handlers.c
+++ b/openair3/S1AP/s1ap_eNB_handlers.c
@@ -1736,7 +1736,7 @@ int s1ap_eNB_handle_s1_ENDC_e_rab_modification_confirm(uint32_t as
uint32_t stream,
S1AP_S1AP_PDU_t *pdu){
- LOG_W(S1AP, "Implementation of S1AP E-RAB Modification confirm handler is pending...\n");
+ LOG_I(S1AP, "Received S1AP E-RAB Modification confirm message \n");
return 0;
}
diff --git a/targets/COMMON/create_nr_tasks.c b/targets/COMMON/create_nr_tasks.c
index 13f72b3876..94fc6140f6 100644
--- a/targets/COMMON/create_nr_tasks.c
+++ b/targets/COMMON/create_nr_tasks.c
@@ -26,7 +26,7 @@
# ifdef OPENAIR2
#include "sctp_eNB_task.h"
-#include "s1ap_eNB.h"
+#include "ngap_gNB.h"
#include "nas_ue_task.h"
#include "udp_eNB_task.h"
#include "gtpv1u_eNB_task.h"
@@ -59,7 +59,7 @@ int create_gNB_tasks(uint32_t gnb_nb)
}
- if (EPC_MODE_ENABLED) {
+ 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");