diff --git a/ci-scripts/Jenkinsfile-gitlab b/ci-scripts/Jenkinsfile-gitlab
index ff661543c0..de49275b7e 100644
--- a/ci-scripts/Jenkinsfile-gitlab
+++ b/ci-scripts/Jenkinsfile-gitlab
@@ -196,16 +196,6 @@ pipeline {
}
}
- stage ("Start VM -- enb-usrp") {
- steps {
- lock (vmResource) {
- 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 {
lock (vmResource) {
@@ -251,7 +241,7 @@ pipeline {
stage ("Analysis with cppcheck") {
steps {
gitlabCommitStatus(name: "Analysis with cppcheck") {
- timeout (time: 20, unit: 'MINUTES') {
+ timeout (time: 30, unit: 'MINUTES') {
sh "./ci-scripts/oai-ci-vm-tool wait --workspace $WORKSPACE --variant cppcheck --job-name ${JOB_NAME} --build-id ${BUILD_ID}"
}
}
@@ -260,7 +250,7 @@ pipeline {
stage ("Build basic simulator") {
steps {
gitlabCommitStatus(name: "Build basic-sim") {
- timeout (time: 20, unit: 'MINUTES') {
+ timeout (time: 30, 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"
}
}
@@ -269,7 +259,7 @@ pipeline {
stage ("Build 5G gNB-USRP") {
steps {
gitlabCommitStatus(name: "Build gNB-USRP") {
- timeout (time: 20, unit: 'MINUTES') {
+ timeout (time: 30, 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"
}
}
@@ -278,25 +268,16 @@ pipeline {
stage ("Build 5G NR-UE-USRP") {
steps {
gitlabCommitStatus(name: "Build nr-UE-USRP") {
- timeout (time: 20, unit: 'MINUTES') {
+ timeout (time: 30, 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') {
+ timeout (time: 30, 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"
}
}
@@ -305,7 +286,7 @@ pipeline {
stage ("Build eNB-ethernet") {
steps {
gitlabCommitStatus(name: "Build eNB-ethernet") {
- timeout (time: 20, unit: 'MINUTES') {
+ timeout (time: 30, 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"
}
}
@@ -316,7 +297,7 @@ pipeline {
// This is typically the last one to finish.
lock (vmResource) {
gitlabCommitStatus(name: "Build UE-ethernet") {
- timeout (time: 20, unit: 'MINUTES') {
+ timeout (time: 30, 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"
}
}
diff --git a/ci-scripts/buildOnVM.sh b/ci-scripts/buildOnVM.sh
index 861cab0782..2b1a5e0c71 100755
--- a/ci-scripts/buildOnVM.sh
+++ b/ci-scripts/buildOnVM.sh
@@ -62,6 +62,12 @@ function build_on_vm {
echo "ARCHIVES_LOC = $ARCHIVES_LOC"
echo "BUILD_OPTIONS = $BUILD_OPTIONS"
+ if [[ "$VM_NAME" == *"-enb-usrp"* ]]
+ then
+ echo "This VM type is no longer supported in the pipeline framework"
+ return
+ fi
+
IS_VM_ALIVE=`uvt-kvm list | grep -c $VM_NAME`
if [ $IS_VM_ALIVE -eq 0 ]
@@ -158,6 +164,9 @@ function build_on_vm {
echo "cd tmp" >> $VM_CMDS
echo "echo \"unzip -qq -DD ../localZip.zip\"" >> $VM_CMDS
echo "unzip -qq -DD ../localZip.zip" >> $VM_CMDS
+ # Trying to make some room on filesystem before building
+ echo "rm ../localZip.zip" >> $VM_CMDS
+ echo "export CI_ENV=True" >> $VM_CMDS
if [[ "$VM_NAME" == *"-cppcheck"* ]]
then
echo "mkdir cmake_targets/log" >> $VM_CMDS
@@ -208,7 +217,15 @@ function build_on_vm {
echo "echo \"./build_oai -I $BUILD_OPTIONS \"" >> $VM_CMDS
echo "./build_oai -I $BUILD_OPTIONS > log/install-build.txt 2>&1" >> $VM_CMDS
else
- echo "echo \"./build_oai -I $BUILD_OPTIONS\" > ./my-vm-build.sh" >> $VM_CMDS
+ if [[ "$VM_NAME" == *"-enb-ethernet"* ]]
+ then
+ echo "echo \"sleep 170 && ./build_oai -I $BUILD_OPTIONS\" > ./my-vm-build.sh" >> $VM_CMDS
+ elif [[ "$VM_NAME" == *"-ue-ethernet"* ]]
+ then
+ echo "echo \"sleep 60 && ./build_oai -I $BUILD_OPTIONS\" > ./my-vm-build.sh" >> $VM_CMDS
+ else
+ echo "echo \"./build_oai -I $BUILD_OPTIONS\" > ./my-vm-build.sh" >> $VM_CMDS
+ fi
echo "chmod 775 ./my-vm-build.sh " >> $VM_CMDS
echo "echo \"sudo -E daemon --inherit --unsafe --name=build_daemon --chdir=/home/ubuntu/tmp/cmake_targets -o /home/ubuntu/tmp/cmake_targets/log/install-build.txt ./my-vm-build.sh\"" >> $VM_CMDS
echo "sudo -E daemon --inherit --unsafe --name=build_daemon --chdir=/home/ubuntu/tmp/cmake_targets -o /home/ubuntu/tmp/cmake_targets/log/install-build.txt ./my-vm-build.sh" >> $VM_CMDS
diff --git a/ci-scripts/createVM.sh b/ci-scripts/createVM.sh
index 237a1a5d5e..b67668f0bc 100755
--- a/ci-scripts/createVM.sh
+++ b/ci-scripts/createVM.sh
@@ -87,6 +87,12 @@ function create_vm {
echo "VM_CPU = $VM_CPU"
echo "VM_DISK = $VM_DISK GBytes"
+ if [[ "$VM_NAME" == *"-enb-usrp"* ]]
+ then
+ echo "This VM type is no longer supported in the pipeline framework"
+ return
+ fi
+
echo "############################################################"
echo "Creating VM ($VM_NAME) on Ubuntu Cloud Image base"
echo "############################################################"
diff --git a/ci-scripts/oai-ci-vm-tool b/ci-scripts/oai-ci-vm-tool
index 9b9fe462f1..d8f088b707 100755
--- a/ci-scripts/oai-ci-vm-tool
+++ b/ci-scripts/oai-ci-vm-tool
@@ -172,6 +172,7 @@ function setvar_usage {
function variant__v1__enb_usrp {
NB_PATTERN_FILES=9
BUILD_OPTIONS="--eNB -w USRP --mu"
+ VM_MEMORY=3072
}
function variant__v2__basic_sim {
@@ -213,15 +214,15 @@ function variant__v6__nr_ue_usrp {
function variant__v7__enb_ethernet {
VM_MEMORY=4096
ARCHIVES_LOC=enb_eth
- NB_PATTERN_FILES=8
- BUILD_OPTIONS="--eNB"
+ NB_PATTERN_FILES=9
+ BUILD_OPTIONS="--eNB -w USRP"
}
function variant__v8__ue_ethernet {
VM_MEMORY=4096
ARCHIVES_LOC=ue_eth
- NB_PATTERN_FILES=12
- BUILD_OPTIONS="--UE"
+ NB_PATTERN_FILES=13
+ BUILD_OPTIONS="--UE -w USRP"
}
function variant__v10__flexran_rtc {
diff --git a/ci-scripts/reportBuildLocally.sh b/ci-scripts/reportBuildLocally.sh
index 44d200c3b6..19a486303f 100755
--- a/ci-scripts/reportBuildLocally.sh
+++ b/ci-scripts/reportBuildLocally.sh
@@ -580,16 +580,42 @@ function report_build {
sca_summary_table_row ./archives/cppcheck/cppcheck.xml "Expression depends on order of evaluation of side effects" unknownEvaluationOrder
sca_summary_table_footer ./archives/cppcheck/cppcheck.xml
- summary_table_header "OAI Build: 4G LTE eNB -- USRP option" ./archives/enb_usrp
- summary_table_row "LTE SoftModem - Release 15" ./archives/enb_usrp/lte-softmodem.Rel15.txt "Built target lte-softmodem" ./enb_usrp_row1.html
- summary_table_row "Coding - Release 15" ./archives/enb_usrp/coding.Rel15.txt "Built target coding" ./enb_usrp_row2.html
- summary_table_row "OAI USRP device if - Release 15" ./archives/enb_usrp/oai_usrpdevif.Rel15.txt "Built target oai_usrpdevif" ./enb_usrp_row3.html
- summary_table_row "OAI ETHERNET transport - Release 15" ./archives/enb_usrp/oai_eth_transpro.Rel15.txt "Built target oai_eth_transpro" ./enb_usrp_row4.html
- summary_table_row "Parameters Lib Config - Release 15" ./archives/enb_usrp/params_libconfig.Rel15.txt "Built target params_libconfig" ./enb_usrp_row5.html
- summary_table_row "NASMESH - Release 15" ./archives/enb_usrp/nasmesh.Rel15.txt "Built target nasmesh" ./enb_usrp_row6.html
- summary_table_row "RB Tool - Release 15" ./archives/enb_usrp/rb_tool.Rel15.txt "Built target rb_tool" ./enb_usrp_row7.html
- summary_table_row "RF Simulator - Release 15" ./archives/enb_usrp/rfsimulator.Rel15.txt "Built target rfsimulator" ./enb_usrp_row8.html
- summary_table_row "TCP Bridge - Release 15" ./archives/enb_usrp/tcp_bridge_oai.Rel15.txt "Built target tcp_bridge_oai" ./enb_usrp_row9.html
+# summary_table_header "OAI Build: 4G LTE eNB -- USRP option" ./archives/enb_usrp
+# summary_table_row "LTE SoftModem - Release 15" ./archives/enb_usrp/lte-softmodem.Rel15.txt "Built target lte-softmodem" ./enb_usrp_row1.html
+# summary_table_row "Coding - Release 15" ./archives/enb_usrp/coding.Rel15.txt "Built target coding" ./enb_usrp_row2.html
+# summary_table_row "OAI USRP device if - Release 15" ./archives/enb_usrp/oai_usrpdevif.Rel15.txt "Built target oai_usrpdevif" ./enb_usrp_row3.html
+# summary_table_row "OAI ETHERNET transport - Release 15" ./archives/enb_usrp/oai_eth_transpro.Rel15.txt "Built target oai_eth_transpro" ./enb_usrp_row4.html
+# summary_table_row "Parameters Lib Config - Release 15" ./archives/enb_usrp/params_libconfig.Rel15.txt "Built target params_libconfig" ./enb_usrp_row5.html
+# summary_table_row "NASMESH - Release 15" ./archives/enb_usrp/nasmesh.Rel15.txt "Built target nasmesh" ./enb_usrp_row6.html
+# summary_table_row "RB Tool - Release 15" ./archives/enb_usrp/rb_tool.Rel15.txt "Built target rb_tool" ./enb_usrp_row7.html
+# summary_table_row "RF Simulator - Release 15" ./archives/enb_usrp/rfsimulator.Rel15.txt "Built target rfsimulator" ./enb_usrp_row8.html
+# summary_table_row "TCP Bridge - Release 15" ./archives/enb_usrp/tcp_bridge_oai.Rel15.txt "Built target tcp_bridge_oai" ./enb_usrp_row9.html
+# summary_table_footer
+#
+ summary_table_header "OAI Build: 4G LTE eNB -- USRP option" ./archives/enb_eth
+ summary_table_row "LTE SoftModem - Release 15" ./archives/enb_eth/lte-softmodem.Rel15.txt "Built target lte-softmodem" ./enb_eth_row1.html
+ summary_table_row "Coding - Release 15" ./archives/enb_eth/coding.Rel15.txt "Built target coding" ./enb_eth_row2.html
+ summary_table_row "OAI ETHERNET transport - Release 15" ./archives/enb_eth/oai_eth_transpro.Rel15.txt "Built target oai_eth_transpro" ./enb_eth_row3.html
+ summary_table_row "Parameters Lib Config - Release 15" ./archives/enb_eth/params_libconfig.Rel15.txt "Built target params_libconfig" ./enb_eth_row4.html
+ summary_table_row "RF Simulator - Release 15" ./archives/enb_eth/rfsimulator.Rel15.txt "Built target rfsimulator" ./enb_eth_row5.html
+ summary_table_row "TCP OAI Bridge - Release 15" ./archives/enb_eth/tcp_bridge_oai.Rel15.txt "Built target tcp_bridge_oai" ./enb_eth_row6.html
+ summary_table_row "OAI USRP device if - Release 15" ./archives/enb_eth/oai_usrpdevif.Rel15.txt "Built target oai_usrpdevif" ./enb_eth_row7.html
+ summary_table_row "NASMESH - Release 15" ./archives/enb_eth/nasmesh.Rel15.txt "Built target nasmesh" ./enb_eth_row8.html
+ summary_table_row "RB Tool - Release 15" ./archives/enb_eth/rb_tool.Rel15.txt "Built target rb_tool" ./enb_eth_row9.html
+ summary_table_footer
+
+ summary_table_header "OAI Build: 4G LTE UE -- USRP option" ./archives/ue_eth
+ summary_table_row "LTE UE SoftModem - Release 15" ./archives/ue_eth/lte-uesoftmodem.Rel15.txt "Built target lte-uesoftmodem" ./ue_eth_row1.html
+ summary_table_row "Coding - Release 15" ./archives/ue_eth/coding.Rel15.txt "Built target coding" ./ue_eth_row2.html
+ summary_table_row "OAI ETHERNET transport - Release 15" ./archives/ue_eth/oai_eth_transpro.Rel15.txt "Built target oai_eth_transpro" ./ue_eth_row3.html
+ summary_table_row "Parameters Lib Config - Release 15" ./archives/ue_eth/params_libconfig.Rel15.txt "Built target params_libconfig" ./ue_eth_row4.html
+ summary_table_row "RF Simulator - Release 15" ./archives/ue_eth/rfsimulator.Rel15.txt "Built target rfsimulator" ./ue_eth_row5.html
+ summary_table_row "TCP OAI Bridge - Release 15" ./archives/ue_eth/tcp_bridge_oai.Rel15.txt "Built target tcp_bridge_oai" ./ue_eth_row6.html
+ summary_table_row "Conf 2 UE Data - Release 15" ./archives/ue_eth/conf2uedata.Rel15.txt "Built target conf2uedata" ./ue_eth_row7.html
+ summary_table_row "NVRAM - Release 15" ./archives/ue_eth/nvram.Rel15.txt "Built target nvram" ./ue_eth_row8.html
+ summary_table_row "UE IP - Release 15" ./archives/ue_eth/ue_ip.Rel15.txt "Built target ue_ip" ./ue_eth_row9.html
+ summary_table_row "USIM - Release 15" ./archives/ue_eth/usim.Rel15.txt "Built target usim" ./ue_eth_row9a.html
+ summary_table_row "OAI USRP device if - Release 15" ./archives/ue_eth/oai_usrpdevif.Rel15.txt "Built target oai_usrpdevif" ./ue_eth_row9b.html
summary_table_footer
summary_table_header "OAI Build: 4G LTE basic simulator option" ./archives/basic_sim
@@ -676,28 +702,6 @@ function report_build {
summary_table_footer
fi
- summary_table_header "OAI Build: 4G LTE eNB -- ETHERNET transport option" ./archives/enb_eth
- summary_table_row "LTE SoftModem - Release 15" ./archives/enb_eth/lte-softmodem.Rel15.txt "Built target lte-softmodem" ./enb_eth_row1.html
- summary_table_row "Coding - Release 15" ./archives/enb_eth/coding.Rel15.txt "Built target coding" ./enb_eth_row2.html
- summary_table_row "OAI ETHERNET transport - Release 15" ./archives/enb_eth/oai_eth_transpro.Rel15.txt "Built target oai_eth_transpro" ./enb_eth_row3.html
- summary_table_row "Parameters Lib Config - Release 15" ./archives/enb_eth/params_libconfig.Rel15.txt "Built target params_libconfig" ./enb_eth_row4.html
- summary_table_row "RF Simulator - Release 15" ./archives/enb_eth/rfsimulator.Rel15.txt "Built target rfsimulator" ./enb_eth_row5.html
- summary_table_row "TCP OAI Bridge - Release 15" ./archives/enb_eth/tcp_bridge_oai.Rel15.txt "Built target tcp_bridge_oai" ./enb_eth_row6.html
- summary_table_footer
-
- summary_table_header "OAI Build: 4G LTE UE -- ETHERNET transport option" ./archives/ue_eth
- summary_table_row "LTE UE SoftModem - Release 15" ./archives/ue_eth/lte-uesoftmodem.Rel15.txt "Built target lte-uesoftmodem" ./ue_eth_row1.html
- summary_table_row "Coding - Release 15" ./archives/ue_eth/coding.Rel15.txt "Built target coding" ./ue_eth_row2.html
- summary_table_row "OAI ETHERNET transport - Release 15" ./archives/ue_eth/oai_eth_transpro.Rel15.txt "Built target oai_eth_transpro" ./ue_eth_row3.html
- summary_table_row "Parameters Lib Config - Release 15" ./archives/ue_eth/params_libconfig.Rel15.txt "Built target params_libconfig" ./ue_eth_row4.html
- summary_table_row "RF Simulator - Release 15" ./archives/ue_eth/rfsimulator.Rel15.txt "Built target rfsimulator" ./ue_eth_row5.html
- summary_table_row "TCP OAI Bridge - Release 15" ./archives/ue_eth/tcp_bridge_oai.Rel15.txt "Built target tcp_bridge_oai" ./ue_eth_row6.html
- summary_table_row "Conf 2 UE Data - Release 15" ./archives/ue_eth/conf2uedata.Rel15.txt "Built target conf2uedata" ./ue_eth_row7.html
- summary_table_row "NVRAM - Release 15" ./archives/ue_eth/nvram.Rel15.txt "Built target nvram" ./ue_eth_row8.html
- summary_table_row "UE IP - Release 15" ./archives/ue_eth/ue_ip.Rel15.txt "Built target ue_ip" ./ue_eth_row9.html
- summary_table_row "USIM - Release 15" ./archives/ue_eth/usim.Rel15.txt "Built target usim" ./ue_eth_row9a.html
- summary_table_footer
-
if [ -e ./archives/red_hat ]
then
echo "
Red Hat Enterprise Linux Server release 7.6) -- Summary
" >> ./build_results.html
@@ -714,9 +718,23 @@ function report_build {
echo " " >> ./build_results.html
echo " " >> ./build_results.html
- if [ -f ./enb_usrp_row1.html ] || [ -f ./enb_usrp_row2.html ] || [ -f ./enb_usrp_row3.html ] || [ -f ./enb_usrp_row4.html ]
+# if [ -f ./enb_usrp_row1.html ] || [ -f ./enb_usrp_row2.html ] || [ -f ./enb_usrp_row3.html ] || [ -f ./enb_usrp_row4.html ]
+# then
+# for DETAILS_TABLE in `ls ./enb_usrp_row*.html`
+# do
+# cat $DETAILS_TABLE >> ./build_results.html
+# done
+# fi
+ if [ -f ./enb_eth_row1.html ] || [ -f ./enb_eth_row2.html ] || [ -f ./enb_eth_row3.html ] || [ -f ./enb_eth_row4.html ] || [ -f ./enb_eth_row5.html ] || [ -f ./enb_eth_row6.html ] || [ -f ./enb_eth_row7.html ] || [ -f ./enb_eth_row8.html ] || [ -f ./enb_eth_row9.html ]
then
- for DETAILS_TABLE in `ls ./enb_usrp_row*.html`
+ for DETAILS_TABLE in `ls ./enb_eth_row*.html`
+ do
+ cat $DETAILS_TABLE >> ./build_results.html
+ done
+ fi
+ if [ -f ./ue_eth_row1.html ] || [ -f ./ue_eth_row2.html ] || [ -f ./ue_eth_row3.html ] || [ -f ./ue_eth_row4.html ] || [ -f ./ue_eth_row5.html ] || [ -f ./ue_eth_row6.html ] || [ -f ./ue_eth_row7.html ] || [ -f ./ue_eth_row8.html ] || [ -f ./ue_eth_row9.html ] || [ -f ./ue_eth_row9a.html ] || [ -f ./ue_eth_row9b.html ]
+ then
+ for DETAILS_TABLE in `ls ./ue_eth_row*.html`
do
cat $DETAILS_TABLE >> ./build_results.html
done
@@ -749,20 +767,6 @@ function report_build {
cat $DETAILS_TABLE >> ./build_results.html
done
fi
- if [ -f ./enb_eth_row1.html ] || [ -f ./enb_eth_row2.html ] || [ -f ./enb_eth_row3.html ] || [ -f ./enb_eth_row4.html ] || [ -f ./enb_eth_row5.html ] || [ -f ./enb_eth_row6.html ]
- then
- for DETAILS_TABLE in `ls ./enb_eth_row*.html`
- do
- cat $DETAILS_TABLE >> ./build_results.html
- done
- fi
- if [ -f ./ue_eth_row1.html ] || [ -f ./ue_eth_row2.html ] || [ -f ./ue_eth_row3.html ] || [ -f ./ue_eth_row4.html ] || [ -f ./ue_eth_row5.html ] || [ -f ./ue_eth_row6.html ]
- then
- for DETAILS_TABLE in `ls ./ue_eth_row*.html`
- do
- cat $DETAILS_TABLE >> ./build_results.html
- done
- fi
if [ -f ./enb_usrp_rh_row1.html ] || [ -f ./enb_usrp_rh_row2.html ] || [ -f ./enb_usrp_rh_row3.html ] || [ -f ./enb_usrp_rh_row4.html ]
then
for DETAILS_TABLE in `ls ./enb_usrp_rh_row*.html`
diff --git a/ci-scripts/waitBuildOnVM.sh b/ci-scripts/waitBuildOnVM.sh
index f066dacd81..ff2129a187 100755
--- a/ci-scripts/waitBuildOnVM.sh
+++ b/ci-scripts/waitBuildOnVM.sh
@@ -47,6 +47,12 @@ function wait_on_vm_build {
echo "ARCHIVES_LOC = $ARCHIVES_LOC"
echo "BUILD_OPTIONS = $BUILD_OPTIONS"
+ if [[ "$VM_NAME" == *"-enb-usrp"* ]]
+ then
+ echo "This VM type is no longer supported in the pipeline framework"
+ return
+ fi
+
IS_VM_ALIVE=`uvt-kvm list | grep -c $VM_NAME`
if [ $IS_VM_ALIVE -eq 0 ]
@@ -84,6 +90,12 @@ function wait_on_vm_build {
}
function check_on_vm_build {
+ if [[ "$VM_NAME" == *"-enb-usrp"* ]]
+ then
+ echo "This VM type is no longer supported in the pipeline framework"
+ return
+ fi
+
echo "############################################################"
echo "Creating a tmp folder to store results and artifacts"
echo "############################################################"
diff --git a/cmake_targets/CMakeLists.txt b/cmake_targets/CMakeLists.txt
index cddac475a6..011cfdad8f 100644
--- a/cmake_targets/CMakeLists.txt
+++ b/cmake_targets/CMakeLists.txt
@@ -987,7 +987,7 @@ add_boolean_option(PHY_TX_THREAD False "enable UE_EXPANSION w
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")
-
+add_boolean_option(RFSIM_NAS False "enable rfsim nas")
########################
# Include order
##########################
@@ -2532,7 +2532,7 @@ if(NAS_UE)
endif()
-if(ITTI_SIM)
+if(ITTI_SIM OR RFSIM_NAS)
set(libnas_ue_api_OBJS
${NAS_SRC}UE/API/USER/at_command.c
${NAS_SRC}UE/API/USER/at_error.c
@@ -3142,9 +3142,7 @@ target_link_libraries (nr-uesoftmodem
-Wl,--start-group
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 MISC_NFAPI_NR_LIB S1AP_LIB S1AP_ENB ${PROTO_AGENT_LIB} ${FSPT_MSG_LIB}
- ${MSC_LIB} ${RAL_LIB} ${NAS_UE_LIB} ${ITTI_LIB} ${FLPT_MSG_LIB} ${ASYNC_IF_LIB} LFDS7 ${ATLAS_LIBRARIES}
- NFAPI_USER_LIB S1AP_LIB S1AP_ENB
+ NFAPI_USER_LIB MISC_NFAPI_NR_LIB S1AP_LIB S1AP_ENB ${PROTO_AGENT_LIB} ${FSPT_MSG_LIB} ${NAS_SIM_LIB}
${MSC_LIB} ${RAL_LIB} ${NAS_UE_LIB} ${ITTI_LIB} ${FLPT_MSG_LIB} ${ASYNC_IF_LIB} LFDS7 ${ATLAS_LIBRARIES} LIB_5GNAS_GNB
-Wl,--end-group z dl)
diff --git a/cmake_targets/build_oai b/cmake_targets/build_oai
index 960b241047..c81ec37712 100755
--- a/cmake_targets/build_oai
+++ b/cmake_targets/build_oai
@@ -67,6 +67,7 @@ USRP_REC_PLAY="False"
BUILD_ECLIPSE=0
NR="False"
ITTI_SIM="False"
+RFSIM_NAS="False"
OPTIONAL_LIBRARIES="telnetsrv enbscope uescope nrscope msc"
trap handle_ctrl_c INT
@@ -260,6 +261,8 @@ function main() {
--nrUE)
nrUE=1
NR="True"
+ rfsimNas=1
+ RFSIM_NAS="True"
echo_info "Will compile NR UE"
shift;;
--mu)
@@ -579,7 +582,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" -o "$ittiSIM" = "1" ] ; then
+ if [ "$eNB" = "1" -o "$eNBocp" = "1" -o "$UE" = "1" -o "$gNB" = "1" -o "$nrUE" = "1" -o "$HW" = "EXMIMO" -o "$ittiSIM" = "1" -o "$rfsimNas" = "1" ] ; then
# softmodem compilation
@@ -604,6 +607,7 @@ function main() {
echo "set ( USRP_REC_PLAY $USRP_REC_PLAY )" >> $cmake_file
echo "set ( SKIP_SHARED_LIB_FLAG $SKIP_SHARED_LIB_FLAG )" >> $cmake_file
echo "set ( ITTI_SIM $ITTI_SIM )" >> $cmake_file
+ echo "set ( RFSIM_NAS $RFSIM_NAS )" >> $cmake_file
echo 'include(${CMAKE_CURRENT_SOURCE_DIR}/../CMakeLists.txt)' >> $cmake_file
cd $DIR/$build_dir/build
eval $CMAKE_CMD
diff --git a/cmake_targets/tools/build_helper b/cmake_targets/tools/build_helper
index 674d4a0cac..977827b0c9 100755
--- a/cmake_targets/tools/build_helper
+++ b/cmake_targets/tools/build_helper
@@ -273,6 +273,10 @@ install_protobuf_from_source(){
make -j`nproc`
$SUDO make install
$SUDO ldconfig
+ if [[ -v CI_ENV ]]; then
+ cd /tmp
+ $SUDO rm -rf protobuf*
+ fi
) >& $protobuf_install_log
}
@@ -295,6 +299,10 @@ install_protobuf_c_from_source(){
make -j`nproc`
$SUDO make install
$SUDO ldconfig
+ if [[ -v CI_ENV ]]; then
+ cd /tmp
+ $SUDO rm -rf protobuf*
+ fi
) >& $protobuf_c_install_log
}
@@ -831,6 +839,9 @@ install_asn1c_from_source(){
$SUDO make install
cd -
$SUDO ldconfig
+ if [[ -v CI_ENV ]]; then
+ $SUDO rm -rf /tmp/asn1c
+ fi
) > $asn1_install_log 2>&1
}
diff --git a/common/utils/ocp_itti/intertask_interface.h b/common/utils/ocp_itti/intertask_interface.h
index 18a8f7868c..db4330d02e 100644
--- a/common/utils/ocp_itti/intertask_interface.h
+++ b/common/utils/ocp_itti/intertask_interface.h
@@ -345,6 +345,7 @@ void *rrc_enb_process_msg(void *);
TASK_DEF(TASK_DU_F1, TASK_PRIORITY_MED, 200, NULL, NULL) \
TASK_DEF(TASK_RRC_UE_SIM, TASK_PRIORITY_MED, 200, NULL, NULL) \
TASK_DEF(TASK_RRC_GNB_SIM, TASK_PRIORITY_MED, 200, NULL, NULL) \
+ TASK_DEF(TASK_NAS_NRUE, 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 d13b193ff9..20eae5d8d1 100644
--- a/doc/RUNMODEM.md
+++ b/doc/RUNMODEM.md
@@ -132,9 +132,9 @@ With the RF simulator (on the same machine):
`sudo RFSIMULATOR=127.0.0.1 ./nr-uesoftmodem --do-ra --rfsim --parallel-config PARALLEL_SINGLE_THREAD`
-## sa setup with OAI
+## SA setup with OAI
-The sa flag is used to run gNB in standalone mode. Currently OAI in NR standalone mode transmits and receives SIB1.
+The sa flag is used to run gNB in standalone mode. Currently OAI in NR standalone mode transmits and receives SIB1 and triggers the RA procedure for initial access.
In order to run gNB in standalone mode, the following flag is needed at gNB:
@@ -147,8 +147,9 @@ At the gNB the --sa flag does the following
- it encodes the RRCConfiguration and the RBconfig message and stores them in the binary files rbconfig.raw and reconfig.raw
- the RRC encodes SIB1 according the configuration file and transmits it through PDSCH
-At the UE the --sa flag will
-- read the binary files rbconfig.raw and reconfig.raw from the current directory (a different directory can be specified with the flag --rrc_config_path) and process them.
+At the UE the --sa flag will:
+- Read the binary files rbconfig.raw and reconfig.raw from the current directory (a different directory can be specified with the flag --rrc_config_path) and process them
+- After the successful decoding of a SIB1 at RRC, the UE will start the 5G NR Initial Access Procedure by triggering the RA procedure.
From the `cmake_targets/ran_build/build` folder:
diff --git a/executables/main-ocp.c b/executables/main-ocp.c
index 6a7b282ef5..ee95a96ce9 100644
--- a/executables/main-ocp.c
+++ b/executables/main-ocp.c
@@ -1319,7 +1319,7 @@ int main ( int argc, char **argv ) {
// end of CI modifications
//getchar();
- if(IS_SOFTMODEM_DOFORMS)
+ if(IS_SOFTMODEM_DOSCOPE)
load_softscope("enb", NULL);
itti_wait_tasks_end();
@@ -1328,7 +1328,7 @@ int main ( int argc, char **argv ) {
// stop threads
if (RC.nb_inst == 0 || !NODE_IS_CU(node_type)) {
- if(IS_SOFTMODEM_DOFORMS)
+ if(IS_SOFTMODEM_DOSCOPE)
end_forms();
LOG_I(ENB_APP,"stopping MODEM threads\n");
diff --git a/executables/nr-ru.c b/executables/nr-ru.c
index 73421d8ed7..9e9303e228 100644
--- a/executables/nr-ru.c
+++ b/executables/nr-ru.c
@@ -89,7 +89,7 @@ static int DEFBFW[] = {0x00007fff};
#include "s1ap_eNB.h"
#include "SIMULATION/ETH_TRANSPORT/proto.h"
-
+#include
#include "T.h"
@@ -1593,7 +1593,8 @@ void *ru_thread( void *param ) {
for (aa=0;aanb_rx;aa++)
memcpy((void*)RC.gNB[0]->common_vars.rxdataF[aa],
(void*)ru->common.rxdataF[aa], fp->symbols_per_slot*fp->ofdm_symbol_size*sizeof(int32_t));
-
+ if (IS_SOFTMODEM_DOSCOPE && RC.gNB[0]->scopeData)
+ ((scopeData_t*)RC.gNB[0]->scopeData)->slotFunc(ru->common.rxdataF[0],proc->tti_rx, RC.gNB[0]->scopeData);
// Do PRACH RU processing
int prach_id=find_nr_prach_ru(ru,proc->frame_rx,proc->tti_rx,SEARCH_EXIST);
diff --git a/executables/nr-softmodem.c b/executables/nr-softmodem.c
index ff5c79d490..051d6aeb38 100644
--- a/executables/nr-softmodem.c
+++ b/executables/nr-softmodem.c
@@ -378,6 +378,30 @@ int create_gNB_tasks(uint32_t gnb_nb) {
}
}
+ if (AMF_MODE_ENABLED && (get_softmodem_params()->phy_test==0 && get_softmodem_params()->do_ra==1)){
+ if (gnb_nb > 0) {
+ if(NGAP_CONF_MODE){
+ if (itti_create_task (TASK_NGAP, ngap_gNB_task, NULL) < 0) {
+ LOG_E(NGAP, "Create task for NGAP failed\n");
+ return -1;
+ }
+ } else {
+ LOG_E(NGAP, "Ngap task not created\n");
+ }
+
+ if(!emulate_rf){
+ if (itti_create_task (TASK_UDP, udp_eNB_task, NULL) < 0) {
+ LOG_E(UDP_, "Create task for UDP failed\n");
+ return -1;
+ }
+ }
+
+ if (itti_create_task (TASK_GTPV1_U, &nr_gtpv1u_gNB_task, NULL) < 0) {
+ LOG_E(GTPU, "Create task for GTPV1U failed\n");
+ return -1;
+ }
+ }
+ }
if (gnb_nb > 0) {
if (itti_create_task (TASK_GNB_APP, gNB_app_task, NULL) < 0) {
@@ -829,9 +853,6 @@ if(!IS_SOFTMODEM_NOS1)
#endif
LOG_I(HW, "Version: %s\n", PACKAGE_VERSION);
-// if(IS_SOFTMODEM_NOS1)
-// init_pdcp();
-
if (RC.nb_nr_inst > 0) {
nr_read_config_and_init();
} else {
@@ -840,9 +861,7 @@ if(!IS_SOFTMODEM_NOS1)
}
if (RC.nb_nr_inst > 0) {
-
- if(IS_SOFTMODEM_NOS1)
- init_pdcp();
+ init_pdcp();
// don't create if node doesn't connect to RRC/S1/GTP
AssertFatal(create_gNB_tasks(1) == 0,"cannot create ITTI tasks\n");
@@ -942,8 +961,8 @@ if(!IS_SOFTMODEM_NOS1)
printf("RC.nb_RU:%d\n", RC.nb_RU);
// once all RUs are ready initialize the rest of the gNBs ((dependence on final RU parameters after configuration)
printf("ALL RUs ready - init gNBs\n");
- if(IS_SOFTMODEM_DOFORMS) {
- sleep(1);
+ if(IS_SOFTMODEM_DOSCOPE) {
+ sleep(1);
scopeParms_t p;
p.argc=&argc;
p.argv=argv;
diff --git a/executables/nr-uesoftmodem.c b/executables/nr-uesoftmodem.c
index 1a6626e52d..e486853aeb 100644
--- a/executables/nr-uesoftmodem.c
+++ b/executables/nr-uesoftmodem.c
@@ -87,6 +87,10 @@ unsigned short config_frames[4] = {2,9,11,13};
#include "executables/softmodem-common.h"
#include "executables/thread-common.h"
+#if defined(ITTI_SIM) || defined(RFSIM_NAS)
+#include "nr_nas_msg_sim.h"
+#endif
+
extern const char *duplex_mode[];
// Thread variables
@@ -189,11 +193,17 @@ int create_tasks_nrue(uint32_t ue_nb) {
LOG_E(NR_RRC, "Create task for RRC UE failed\n");
return -1;
}
+
+ if (itti_create_task (TASK_NAS_NRUE, nas_nrue_task, NULL) < 0) {
+ LOG_E(NR_RRC, "Create task for NAS UE failed\n");
+ return -1;
+ }
}
itti_wait_ready(0);
return 0;
}
+
void exit_function(const char *file, const char *function, const int line, const char *s) {
int CC_id;
@@ -569,7 +579,7 @@ int main( int argc, char **argv ) {
configure_linux();
mlockall(MCL_CURRENT | MCL_FUTURE);
- if(IS_SOFTMODEM_DOFORMS) {
+ if(IS_SOFTMODEM_DOSCOPE) {
load_softscope("nr",PHY_vars_UE_g[0][0]);
}
@@ -584,7 +594,10 @@ int main( int argc, char **argv ) {
protocol_ctxt_t ctxt_pP = {0};
ctxt_pP.enb_flag = ENB_FLAG_NO;
ctxt_pP.rnti = 0x1234;
- rrc_ue_generate_RRCSetupRequest(&ctxt_pP, 0);
+ RC.nrrrc = (gNB_RRC_INST **)malloc(1*sizeof(gNB_RRC_INST *));
+ RC.nrrrc[0] = (gNB_RRC_INST*)malloc(sizeof(gNB_RRC_INST));
+ RC.nrrrc[0]->node_type = ngran_gNB;
+ nr_rrc_ue_generate_RRCSetupRequest(ctxt_pP.module_id, 0);
if (create_tasks_nrue(1) < 0) {
printf("cannot create ITTI tasks\n");
exit(-1); // need a softer mode
diff --git a/executables/ocp-gnb.c b/executables/ocp-gnb.c
index 4ddc7870d9..a468861533 100644
--- a/executables/ocp-gnb.c
+++ b/executables/ocp-gnb.c
@@ -996,7 +996,7 @@ int main( int argc, char **argv ) {
(void *)NULL, "time_meas", -1, OAI_PRIORITY_RT_LOW);
}
- if(IS_SOFTMODEM_DOFORMS) {
+ if(IS_SOFTMODEM_DOSCOPE) {
scopeParms_t tmp= {&argc, argv, &ru, RC.gNB[0]};
load_softscope("nr",&tmp);
}
diff --git a/executables/softmodem-common.c b/executables/softmodem-common.c
index 1077c0e1ac..72cf2e32c5 100644
--- a/executables/softmodem-common.c
+++ b/executables/softmodem-common.c
@@ -140,7 +140,7 @@ void get_common_options(uint32_t execmask) {
}
if (do_forms) {
- set_softmodem_optmask(SOFTMODEM_DOFORMS_BIT);
+ set_softmodem_optmask(SOFTMODEM_DOSCOPE_BIT);
}
if(parallel_config != NULL) set_parallel_conf(parallel_config);
diff --git a/executables/softmodem-common.h b/executables/softmodem-common.h
index 60a761c732..4bbeaff32b 100644
--- a/executables/softmodem-common.h
+++ b/executables/softmodem-common.h
@@ -188,7 +188,7 @@ extern "C"
#define SOFTMODEM_RFSIM_BIT (1<<10)
#define SOFTMODEM_BASICSIM_BIT (1<<11)
#define SOFTMODEM_SIML1_BIT (1<<12)
-#define SOFTMODEM_DOFORMS_BIT (1<<15)
+#define SOFTMODEM_DOSCOPE_BIT (1<<15)
#define SOFTMODEM_RECPLAY_BIT (1<<16)
#define SOFTMODEM_ENB_BIT (1<<20)
#define SOFTMODEM_GNB_BIT (1<<21)
@@ -204,7 +204,7 @@ extern "C"
#define IS_SOFTMODEM_RFSIM ( get_softmodem_optmask() & SOFTMODEM_RFSIM_BIT)
#define IS_SOFTMODEM_BASICSIM ( get_softmodem_optmask() & SOFTMODEM_BASICSIM_BIT)
#define IS_SOFTMODEM_SIML1 ( get_softmodem_optmask() & SOFTMODEM_SIML1_BIT)
-#define IS_SOFTMODEM_DOFORMS ( get_softmodem_optmask() & SOFTMODEM_DOFORMS_BIT)
+#define IS_SOFTMODEM_DOSCOPE ( get_softmodem_optmask() & SOFTMODEM_DOSCOPE_BIT)
#define IS_SOFTMODEM_IQPLAYER ( get_softmodem_optmask() & SOFTMODEM_RECPLAY_BIT)
#define IS_SOFTMODEM_ENB_BIT ( get_softmodem_optmask() & SOFTMODEM_ENB_BIT)
#define IS_SOFTMODEM_GNB_BIT ( get_softmodem_optmask() & SOFTMODEM_GNB_BIT)
diff --git a/openair1/PHY/NR_ESTIMATION/nr_ul_channel_estimation.c b/openair1/PHY/NR_ESTIMATION/nr_ul_channel_estimation.c
index 38b35dcf6d..f4a70b1323 100644
--- a/openair1/PHY/NR_ESTIMATION/nr_ul_channel_estimation.c
+++ b/openair1/PHY/NR_ESTIMATION/nr_ul_channel_estimation.c
@@ -124,9 +124,9 @@ int nr_pusch_channel_estimation(PHY_VARS_gNB *gNB,
//------------------generate DMRS------------------//
- if (pusch_pdu->transform_precoding == transform_precoder_disabled)
- nr_pusch_dmrs_rx(gNB, Ns, gNB->nr_gold_pusch_dmrs[pusch_pdu->scid][Ns][symbol], &pilot[0], 1000, 0, nb_rb_pusch, pusch_pdu->rb_start*NR_NB_SC_PER_RB, pusch_pdu->dmrs_config_type);
-
+ if (pusch_pdu->transform_precoding == transform_precoder_disabled)
+ nr_pusch_dmrs_rx(gNB, Ns, gNB->nr_gold_pusch_dmrs[pusch_pdu->scid][Ns][symbol], &pilot[0], 1000, 0, nb_rb_pusch, (pusch_pdu->bwp_start + pusch_pdu->rb_start)*NR_NB_SC_PER_RB, pusch_pdu->dmrs_config_type);
+
else { // if transform precoding or SC-FDMA is enabled in Uplink
// NR_SC_FDMA supports type1 DMRS so only 6 DMRS REs per RB possible
diff --git a/openair1/PHY/NR_REFSIG/nr_dmrs_rx.c b/openair1/PHY/NR_REFSIG/nr_dmrs_rx.c
index 5d62f9dbb9..5a4b1adbb8 100644
--- a/openair1/PHY/NR_REFSIG/nr_dmrs_rx.c
+++ b/openair1/PHY/NR_REFSIG/nr_dmrs_rx.c
@@ -40,9 +40,9 @@
#include "PHY/defs_gNB.h"
/*Table 7.4.1.1.2-1/2 from 38.211 */
-int wf1[8][2] = {{1,1},{1,-1},{1,1},{1,-1},{1,1},{1,-1},{1,1},{1,1}};
+int wf1[8][2] = {{1,1},{1,-1},{1,1},{1,-1},{1,1},{1,-1},{1,1},{1,-1}};
int wt1[8][2] = {{1,1},{1,1},{1,1},{1,1},{1,-1},{1,-1},{1,-1},{1,-1}};
-int wf2[12][2] = {{1,1},{1,-1},{1,1},{1,-1},{1,1},{1,-1},{1,1},{1,1},{1,1},{1,-1},{1,1},{1,1}};
+int wf2[12][2] = {{1,1},{1,-1},{1,1},{1,-1},{1,1},{1,-1},{1,1},{1,-1},{1,1},{1,-1},{1,1},{1,-1}};
int wt2[12][2] = {{1,1},{1,1},{1,1},{1,1},{1,1},{1,1},{1,-1},{1,-1},{1,-1},{1,-1},{1,-1},{1,-1}};
// complex conjugate of mod table
diff --git a/openair1/PHY/NR_TRANSPORT/nr_dci.c b/openair1/PHY/NR_TRANSPORT/nr_dci.c
index 469415908f..269ed3860d 100644
--- a/openair1/PHY/NR_TRANSPORT/nr_dci.c
+++ b/openair1/PHY/NR_TRANSPORT/nr_dci.c
@@ -85,10 +85,7 @@ void nr_generate_dci(PHY_VARS_gNB *gNB,
// compute rb_offset and n_prb based on frequency allocation
nr_fill_cce_list(gNB,0,pdcch_pdu_rel15);
get_coreset_rballoc(pdcch_pdu_rel15->FreqDomainResource,&n_rb,&rb_offset);
- cset_start_sc = frame_parms.first_carrier_offset + rb_offset*NR_NB_SC_PER_RB;
- if (pdcch_pdu_rel15->CoreSetType == NFAPI_NR_CSET_CONFIG_MIB_SIB1) {
- cset_start_sc = cset_start_sc + RC.nrmac[gNB->Mod_id]->type0_PDCCH_CSS_config.cset_start_rb*NR_NB_SC_PER_RB;
- }
+ cset_start_sc = frame_parms.first_carrier_offset + (pdcch_pdu_rel15->BWPStart + rb_offset) * NR_NB_SC_PER_RB;
for (int d=0;dnumDlDci;d++) {
/*The coreset is initialised
diff --git a/openair1/PHY/NR_TRANSPORT/nr_dlsch.c b/openair1/PHY/NR_TRANSPORT/nr_dlsch.c
index 1cce5e1174..a8ceb2aef3 100644
--- a/openair1/PHY/NR_TRANSPORT/nr_dlsch.c
+++ b/openair1/PHY/NR_TRANSPORT/nr_dlsch.c
@@ -147,19 +147,18 @@ uint8_t nr_generate_pdsch(PHY_VARS_gNB *gNB,
uint16_t n_dmrs;
if (rel15->dmrsConfigType==NFAPI_NR_DMRS_TYPE1) {
nb_re_dmrs = 6*rel15->numDmrsCdmGrpsNoData;
- n_dmrs = ((rel15->rbSize+rel15->rbStart)*6)<<1;
}
else {
nb_re_dmrs = 4*rel15->numDmrsCdmGrpsNoData;
- n_dmrs = ((rel15->rbSize+rel15->rbStart)*4)<<1;
}
+ n_dmrs = (rel15->BWPStart+rel15->rbStart+rel15->rbSize)*nb_re_dmrs;
uint16_t dmrs_symbol_map = rel15->dlDmrsSymbPos;//single DMRS: 010000100 Double DMRS 110001100
uint8_t dmrs_len = get_num_dmrs(rel15->dlDmrsSymbPos);
uint16_t nb_re = ((12*rel15->NrOfSymbols)-nb_re_dmrs*dmrs_len-xOverhead)*rel15->rbSize*rel15->nrOfLayers;
uint8_t Qm = rel15->qamModOrder[0];
uint32_t encoded_length = nb_re*Qm;
- int16_t mod_dmrs[14][n_dmrs] __attribute__ ((aligned(16)));
+ int16_t mod_dmrs[14][n_dmrs<<1] __attribute__ ((aligned(16)));
/* PTRS */
uint16_t beta_ptrs = 1;
@@ -269,12 +268,13 @@ uint8_t nr_generate_pdsch(PHY_VARS_gNB *gNB,
//to be moved to init phase potentially, for now tx_layers 1-8 are mapped on antenna ports 1000-1007
/// DMRS QPSK modulation
+ // TODO: performance improvement, we can skip the modulation of DMRS symbols outside the bandwidth part
for (int l=rel15->StartSymbolIndex; lStartSymbolIndex+rel15->NrOfSymbols; l++) {
if (rel15->dlDmrsSymbPos & (1 << l)) {
- nr_modulation(pdsch_dmrs[l][0], n_dmrs, DMRS_MOD_ORDER, mod_dmrs[l]); // currently only codeword 0 is modulated. Qm = 2 as DMRS is QPSK modulated
+ nr_modulation(pdsch_dmrs[l][0], n_dmrs*2, DMRS_MOD_ORDER, mod_dmrs[l]); // currently only codeword 0 is modulated. Qm = 2 as DMRS is QPSK modulated
#ifdef DEBUG_DLSCH
- printf("DMRS modulation (symbol %d, %d symbols, type %d):\n", l, n_dmrs>>1, dmrs_Type);
+ printf("DMRS modulation (symbol %d, %d symbols, type %d):\n", l, n_dmrs, dmrs_Type);
for (int i=0; i>4; i++) {
for (int j=0; j<8; j++) {
printf("%d %d\t", mod_dmrs[l][((i<<3)+j)<<1], mod_dmrs[l][(((i<<3)+j)<<1)+1]);
@@ -321,11 +321,24 @@ uint8_t nr_generate_pdsch(PHY_VARS_gNB *gNB,
/// DMRS QPSK modulation
uint8_t k_prime=0;
uint16_t n=0;
- if ((dmrs_symbol_map & (1 << l))){ //DMRS time occasion
- if (dmrs_Type == NFAPI_NR_DMRS_TYPE1) // another if condition to be included to check pdsch config type (reference of k)
- dmrs_idx = rel15->rbStart*6;
- else
- dmrs_idx = rel15->rbStart*4;
+
+ if ((dmrs_symbol_map & (1 << l))){ // DMRS time occasion
+ // The reference point for is subcarrier 0 of the lowest-numbered resource block in CORESET 0 if the corresponding
+ // PDCCH is associated with CORESET 0 and Type0-PDCCH common search space and is addressed to SI-RNTI
+ // 3GPP TS 38.211 V15.8.0 Section 7.4.1.1.2 Mapping to physical resources
+ if (rel15->rnti==SI_RNTI) {
+ if (dmrs_Type==NFAPI_NR_DMRS_TYPE1) {
+ dmrs_idx = rel15->rbStart*6;
+ } else {
+ dmrs_idx = rel15->rbStart*4;
+ }
+ } else {
+ if (dmrs_Type == NFAPI_NR_DMRS_TYPE1) {
+ dmrs_idx = (rel15->rbStart+rel15->BWPStart)*6;
+ } else {
+ dmrs_idx = (rel15->rbStart+rel15->BWPStart)*4;
+ }
+ }
}
// Update l_prime in the case of double DMRS config
diff --git a/openair1/PHY/NR_TRANSPORT/nr_prach.c b/openair1/PHY/NR_TRANSPORT/nr_prach.c
index b5a3c061e9..0c1fde07a2 100644
--- a/openair1/PHY/NR_TRANSPORT/nr_prach.c
+++ b/openair1/PHY/NR_TRANSPORT/nr_prach.c
@@ -679,9 +679,9 @@ void rx_nr_prach(PHY_VARS_gNB *gNB,
else {
preamble_shift -= NCS;
-
+
if (preamble_shift < 0)
- preamble_shift+=N_ZC;
+ preamble_shift+=((N_ZC/NCS)*NCS);
}
} else { // This is the high-speed case
new_dft = 0;
diff --git a/openair1/PHY/NR_TRANSPORT/nr_ulsch_demodulation.c b/openair1/PHY/NR_TRANSPORT/nr_ulsch_demodulation.c
index 42d6cfad7a..cc088a36d6 100644
--- a/openair1/PHY/NR_TRANSPORT/nr_ulsch_demodulation.c
+++ b/openair1/PHY/NR_TRANSPORT/nr_ulsch_demodulation.c
@@ -326,7 +326,7 @@ void nr_ulsch_extract_rbs_single(int32_t **rxdataF,
#endif
uint8_t is_dmrs_re;
- start_re = (frame_parms->first_carrier_offset + (pusch_pdu->rb_start * NR_NB_SC_PER_RB))%frame_parms->ofdm_symbol_size;
+ start_re = (frame_parms->first_carrier_offset + (pusch_pdu->rb_start + pusch_pdu->bwp_start) * NR_NB_SC_PER_RB)%frame_parms->ofdm_symbol_size;
nb_re_pusch = NR_NB_SC_PER_RB * pusch_pdu->rb_size;
#ifdef __AVX2__
int nb_re_pusch2 = nb_re_pusch + (nb_re_pusch&7);
@@ -1174,7 +1174,7 @@ int nr_rx_pusch(PHY_VARS_gNB *gNB,
}
- bwp_start_subcarrier = (rel15_ul->rb_start*NR_NB_SC_PER_RB + frame_parms->first_carrier_offset) % frame_parms->ofdm_symbol_size;
+ bwp_start_subcarrier = ((rel15_ul->rb_start + rel15_ul->bwp_start)*NR_NB_SC_PER_RB + frame_parms->first_carrier_offset) % frame_parms->ofdm_symbol_size;
dmrs_symbol_flag = ((rel15_ul->ul_dmrs_symb_pos)>>symbol)&0x01;
diff --git a/openair1/PHY/NR_UE_ESTIMATION/nr_dl_channel_estimation.c b/openair1/PHY/NR_UE_ESTIMATION/nr_dl_channel_estimation.c
index 6cb0a612e9..97613e5428 100644
--- a/openair1/PHY/NR_UE_ESTIMATION/nr_dl_channel_estimation.c
+++ b/openair1/PHY/NR_UE_ESTIMATION/nr_dl_channel_estimation.c
@@ -650,6 +650,7 @@ int nr_pdcch_channel_estimation(PHY_VARS_NR_UE *ue,
int nr_pdsch_channel_estimation(PHY_VARS_NR_UE *ue,
UE_nr_rxtx_proc_t *proc,
uint8_t eNB_offset,
+ bool is_SI,
unsigned char Ns,
unsigned short p,
unsigned char symbol,
@@ -687,7 +688,10 @@ int nr_pdsch_channel_estimation(PHY_VARS_NR_UE *ue,
#endif
// generate pilot for gNB port number 1000+p
- uint16_t rb_offset = (bwp_start_subcarrier - ue->frame_parms.first_carrier_offset) / 12 - BWPStart;
+ uint16_t rb_offset = (bwp_start_subcarrier - ue->frame_parms.first_carrier_offset) / 12;
+ if (is_SI) {
+ rb_offset -= BWPStart;
+ }
uint8_t config_type = ue->dmrs_DownlinkConfig.pdsch_dmrs_type;
int8_t delta = get_delta(p, config_type);
nr_pdsch_dmrs_rx(ue,Ns,ue->nr_gold_pdsch[eNB_offset][Ns][symbol][0], &pilot[0],1000,0,nb_rb_pdsch+rb_offset);
diff --git a/openair1/PHY/NR_UE_ESTIMATION/nr_estimation.h b/openair1/PHY/NR_UE_ESTIMATION/nr_estimation.h
index 6c461ef448..1466fabe5d 100644
--- a/openair1/PHY/NR_UE_ESTIMATION/nr_estimation.h
+++ b/openair1/PHY/NR_UE_ESTIMATION/nr_estimation.h
@@ -70,6 +70,7 @@ int nr_pbch_channel_estimation(PHY_VARS_NR_UE *ue,
int nr_pdsch_channel_estimation(PHY_VARS_NR_UE *ue,
UE_nr_rxtx_proc_t *proc,
uint8_t eNB_offset,
+ bool is_SI,
unsigned char Ns,
unsigned short p,
unsigned char symbol,
diff --git a/openair1/PHY/NR_UE_TRANSPORT/dci_nr.c b/openair1/PHY/NR_UE_TRANSPORT/dci_nr.c
index bfec64820b..abc944bc00 100644
--- a/openair1/PHY/NR_UE_TRANSPORT/dci_nr.c
+++ b/openair1/PHY/NR_UE_TRANSPORT/dci_nr.c
@@ -158,7 +158,6 @@ void nr_pdcch_demapping_deinterleaving(uint32_t *llr,
if ((reg % reg_bundle_size_L) == 0) r++;
}
-
// Get cce_list indices by reg_idx in ascending order
int f_bundle_j_list_id = 0;
int f_bundle_j_list_ord[NR_MAX_PDCCH_AGG_LEVEL] = {};
@@ -175,7 +174,6 @@ void nr_pdcch_demapping_deinterleaving(uint32_t *llr,
}
}
-
for(int reg=0; reg<((coreset_nbr_rb*coreset_time_dur)); reg++) {
f_reg = (f_bundle_j_list_ord[reg/6]*reg_bundle_size_L)+(reg%reg_bundle_size_L);
diff --git a/openair1/PHY/NR_UE_TRANSPORT/nr_ulsch_ue.c b/openair1/PHY/NR_UE_TRANSPORT/nr_ulsch_ue.c
index 503db64e2c..85d435efeb 100644
--- a/openair1/PHY/NR_UE_TRANSPORT/nr_ulsch_ue.c
+++ b/openair1/PHY/NR_UE_TRANSPORT/nr_ulsch_ue.c
@@ -137,7 +137,7 @@ void nr_ue_ulsch_procedures(PHY_VARS_NR_UE *UE,
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;
+ uint16_t start_sc = frame_parms->first_carrier_offset + (start_rb+pusch_pdu->bwp_start)*NR_NB_SC_PER_RB;
if (start_sc >= frame_parms->ofdm_symbol_size)
start_sc -= frame_parms->ofdm_symbol_size;
@@ -196,7 +196,7 @@ void nr_ue_ulsch_procedures(PHY_VARS_NR_UE *UE,
/////////////////////////DMRS Modulation/////////////////////////
///////////
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);
+ uint16_t n_dmrs = (pusch_pdu->bwp_start + start_rb + nb_rb)*((dmrs_type == pusch_dmrs_type1) ? 6:4);
int16_t mod_dmrs[n_dmrs<<1] __attribute((aligned(16)));
///////////
////////////////////////////////////////////////////////////////////////
@@ -356,16 +356,17 @@ void nr_ue_ulsch_procedures(PHY_VARS_NR_UE *UE,
if (pusch_pdu->transform_precoding == transform_precoder_disabled){
if (dmrs_type == pusch_dmrs_type1)
- dmrs_idx = start_rb*6;
+ dmrs_idx = (pusch_pdu->bwp_start + start_rb)*6;
else
- dmrs_idx = start_rb*4;
-
- // Perform this on gold sequence, not required when SC FDMA operation is done,
+ dmrs_idx = (pusch_pdu->bwp_start + start_rb)*4;
+
+ // TODO: performance improvement, we can skip the modulation of DMRS symbols outside the bandwidth part
+ // Perform this on gold sequence, not required when SC FDMA operation is done,
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 {
- dmrs_idx = 0;
- }
+ dmrs_idx = 0;
+ }
} else if (pusch_pdu->pdu_bit_map & PUSCH_PDU_BITMAP_PUSCH_PTRS) {
diff --git a/openair1/PHY/TOOLS/nr_phy_scope.c b/openair1/PHY/TOOLS/nr_phy_scope.c
index cb61523852..b42dcd11ee 100644
--- a/openair1/PHY/TOOLS/nr_phy_scope.c
+++ b/openair1/PHY/TOOLS/nr_phy_scope.c
@@ -38,10 +38,7 @@ int otg_enabled;
const FL_COLOR rx_antenna_colors[4] = {FL_RED,FL_BLUE,FL_GREEN,FL_YELLOW};
const FL_COLOR water_colors[4] = {FL_BLUE,FL_GREEN,FL_YELLOW,FL_RED};
-typedef struct {
- int16_t r;
- int16_t i;
-} scopeSample_t;
+typedef struct complex16 scopeSample_t;
#define SquaredNorm(VaR) ((VaR).r*(VaR).r+(VaR).i*(VaR).i)
typedef struct OAIgraph {
@@ -59,7 +56,7 @@ typedef struct OAIgraph {
double *waterFallAvg;
boolean_t initDone;
int iteration;
- void (*gNBfunct) (struct OAIgraph *graph, PHY_VARS_gNB *phy_vars_gnb, RU_t *phy_vars_ru, int UE_id);
+ void (*gNBfunct) (struct OAIgraph *graph, scopeData_t *p, int UE_id);
void (*nrUEfunct)(struct OAIgraph *graph, PHY_VARS_NR_UE *phy_vars_ue, int eNB_id, int UE_id);
} OAIgraph_t;
@@ -135,7 +132,7 @@ static void commonGraph(OAIgraph_t *graph, int type, FL_Coord x, FL_Coord y, FL_
graph->iteration=0;
}
-static OAIgraph_t gNBcommonGraph( void (*funct) (OAIgraph_t *graph, PHY_VARS_gNB *phy_vars_gnb, RU_t *phy_vars_ru, int UE_id),
+static OAIgraph_t gNBcommonGraph( void (*funct) (OAIgraph_t *graph, scopeData_t *p, int UE_id),
int type, FL_Coord x, FL_Coord y, FL_Coord w, FL_Coord h, const char *label, FL_COLOR pointColor) {
OAIgraph_t graph;
commonGraph(&graph, type, x, y, w, h, label, pointColor);
@@ -226,7 +223,8 @@ static void oai_xygraph(OAIgraph_t *graph, float *x, float *y, int len, int laye
static void genericWaterFall (OAIgraph_t *graph, scopeSample_t *values, const int datasize, const int divisions, const char *label) {
if ( values == NULL )
- return;
+ return;
+
fl_winset(FL_ObjWin(graph->graph));
const int samplesPerPixel=datasize/graph->w;
int displayPart=graph->waterFallh-ScaleZone;
@@ -321,10 +319,10 @@ static void genericPowerPerAntena(OAIgraph_t *graph, const int nb_ant, const sc
}
}
-static void gNBWaterFall (OAIgraph_t *graph, PHY_VARS_gNB *phy_vars_gnb, RU_t *phy_vars_ru, int nb_UEs) {
- NR_DL_FRAME_PARMS *frame_parms=&phy_vars_gnb->frame_parms;
+static void gNBWaterFall (OAIgraph_t *graph, scopeData_t *p, int nb_UEs) {
+ NR_DL_FRAME_PARMS *frame_parms=&p->gNB->frame_parms;
//use 1st antenna
- genericWaterFall(graph, (scopeSample_t *)phy_vars_ru->common.rxdata[0],
+ genericWaterFall(graph, (scopeSample_t *)p->ru->common.rxdata[0],
frame_parms->samples_per_frame, frame_parms->slots_per_frame,
"X axis:one frame in time");
}
@@ -342,31 +340,35 @@ static void timeSignal (OAIgraph_t *graph, PHY_VARS_gNB *phy_vars_gnb, RU_t *phy
}
*/
-static void timeResponse (OAIgraph_t *graph, PHY_VARS_gNB *phy_vars_gnb, RU_t *phy_vars_ru, int nb_UEs) {
- const int len=2*phy_vars_gnb->frame_parms.ofdm_symbol_size;
+static void timeResponse (OAIgraph_t *graph, scopeData_t *p, int nb_UEs) {
+ const int len=2*p->gNB->frame_parms.ofdm_symbol_size;
float *values, *time;
oai_xygraph_getbuff(graph, &time, &values, len, 0);
const int ant=0; // display antenna 0 for each UE
for (int ue=0; uepusch_vars[ue]->ul_ch_estimates_time[ant];
+ if ( p->gNB->pusch_vars && p->gNB->pusch_vars[ue] &&
+ p->gNB->pusch_vars[ue]->ul_ch_estimates_time &&
+ p->gNB->pusch_vars[ue]->ul_ch_estimates_time[ant] ) {
+ scopeSample_t *data= (scopeSample_t *)p->gNB->pusch_vars[ue]->ul_ch_estimates_time[ant];
- if (data != NULL) {
- for (int i=0; iframe_parms;
+static void gNBfreqWaterFall (OAIgraph_t *graph, scopeData_t *p, int nb_UEs) {
+ NR_DL_FRAME_PARMS *frame_parms=&p->gNB->frame_parms;
//use 1st antenna
- genericWaterFall(graph, (scopeSample_t *)phy_vars_ru->common.rxdataF[0], frame_parms->samples_per_frame_wCP,
+ genericWaterFall(graph, (scopeSample_t *)p->rxdataF, frame_parms->samples_per_frame_wCP,
frame_parms->slots_per_frame,
- "X axis: Frequency domain, one frame");
+ "X axis: Frequency domain, one subframe");
}
/*
@@ -378,16 +380,18 @@ static void frequencyResponse (OAIgraph_t *graph, PHY_VARS_gNB *phy_vars_gnb, RU
}
*/
-static void puschLLR (OAIgraph_t *graph, PHY_VARS_gNB *phy_vars_gnb, RU_t *phy_vars_ru, int nb_UEs) {
+static void puschLLR (OAIgraph_t *graph, scopeData_t *p, int nb_UEs) {
//int Qm = 2;
int coded_bits_per_codeword =3*8*6144+12; // (8*((3*8*6144)+12)); // frame_parms->N_RB_UL*12*Qm*frame_parms->symbols_per_tti;
for (int ue=0; uepusch_vars[ue]->llr;
- float *llr, *bit;
- oai_xygraph_getbuff(graph, &bit, &llr, coded_bits_per_codeword, ue);
+ if ( p->gNB->pusch_vars &&
+ p->gNB->pusch_vars[ue] &&
+ p->gNB->pusch_vars[ue]->llr ) {
+ int16_t *pusch_llr = (int16_t *)p->gNB->pusch_vars[ue]->llr;
+ float *llr, *bit;
+ oai_xygraph_getbuff(graph, &bit, &llr, coded_bits_per_codeword, ue);
- if (pusch_llr) {
for (int i=0; iframe_parms;
+static void puschIQ (OAIgraph_t *graph, scopeData_t *p, int nb_UEs) {
+ NR_DL_FRAME_PARMS *frame_parms=&p->gNB->frame_parms;
int sz=frame_parms->N_RB_UL*12*frame_parms->symbols_per_slot;
for (int ue=0; uepusch_vars[ue]->rxdataF_comp[0];
- float *I, *Q;
- oai_xygraph_getbuff(graph, &I, &Q, sz, ue);
+ if ( p->gNB->pusch_vars &&
+ p->gNB->pusch_vars[ue] &&
+ p->gNB->pusch_vars[ue]->rxdataF_comp &&
+ p->gNB->pusch_vars[ue]->rxdataF_comp[0] ) {
+ scopeSample_t *pusch_comp = (scopeSample_t *) p->gNB->pusch_vars[ue]->rxdataF_comp[0];
+ float *I, *Q;
+ oai_xygraph_getbuff(graph, &I, &Q, sz, ue);
- if (pusch_comp) {
for (int k=0; kpucch1ab_stats[UE_id];
@@ -443,10 +450,10 @@ static void pucchEnergy (OAIgraph_t *graph, PHY_VARS_gNB *phy_vars_gnb, RU_t *ph
*/
}
-static void pucchIQ (OAIgraph_t *graph, PHY_VARS_gNB *phy_vars_gnb, RU_t *phy_vars_ru, int nb_UEs) {
+static void pucchIQ (OAIgraph_t *graph, scopeData_t *p, int nb_UEs) {
}
-static void puschThroughtput (OAIgraph_t *graph, PHY_VARS_gNB *phy_vars_gnb, RU_t *phy_vars_ru, int nb_UEs) {
+static void puschThroughtput (OAIgraph_t *graph, scopeData_t *p, int nb_UEs) {
// PUSCH Throughput
/*
float tput_time_enb[NUMBER_OF_UE_MAX][TPUT_WINDOW_LENGTH] = {{0}};
@@ -513,8 +520,7 @@ static OAI_phy_scope_t *create_phy_scope_gnb(void) {
static const int scope_enb_num_ue = 1;
void phy_scope_gNB(OAI_phy_scope_t *form,
- PHY_VARS_gNB *phy_vars_gnb,
- RU_t *phy_vars_ru,
+ scopeData_t *p,
int UE_id) {
static OAI_phy_scope_t *rememberForm=NULL;
@@ -529,7 +535,7 @@ void phy_scope_gNB(OAI_phy_scope_t *form,
int i=0;
while (form->graph[i].graph) {
- form->graph[i].gNBfunct(form->graph+i, phy_vars_gnb, phy_vars_ru, UE_id);
+ form->graph[i].gNBfunct(form->graph+i, p, UE_id);
i++;
}
@@ -537,7 +543,7 @@ void phy_scope_gNB(OAI_phy_scope_t *form,
}
static void *scope_thread_gNB(void *arg) {
- scopeParms_t *p=(scopeParms_t *) arg;
+ scopeData_t *p=(scopeData_t *) arg;
//# ifdef ENABLE_XFORMS_WRITE_STATS
// FILE *gNB_stats = fopen("gNB_stats.txt", "w");
//#endif
@@ -554,18 +560,31 @@ static void *scope_thread_gNB(void *arg) {
OAI_phy_scope_t *form_gnb = create_phy_scope_gnb();
while (!oai_exit) {
- phy_scope_gNB(form_gnb, p->gNB, p->ru, nb_ue);
+ phy_scope_gNB(form_gnb, p, nb_ue);
usleep(99*1000);
}
return NULL;
}
+static void copyRxdataF(int32_t *data, int slot, void *scopeData) {
+ scopeData_t *scope=(scopeData_t *)scopeData;
+ memcpy(scope->rxdataF + slot*scope->gNB->frame_parms.samples_per_slot_wCP,
+ data,
+ scope->gNB->frame_parms.samples_per_slot_wCP);
+}
+
void gNBinitScope(scopeParms_t *p) {
- static scopeParms_t parms;
- memcpy(&parms,p,sizeof(parms));
+ AssertFatal(p->gNB->scopeData=malloc(sizeof(scopeData_t)),"");
+ scopeData_t *scope=(scopeData_t *) p->gNB->scopeData;
+ scope->argc=p->argc;
+ scope->argv=p->argv;
+ scope->ru=p->ru;
+ scope->gNB=p->gNB;
+ scope->slotFunc=copyRxdataF;
+ AssertFatal(scope->rxdataF=(int32_t *) calloc(p->gNB->frame_parms.samples_per_frame_wCP*sizeof(int32_t),1),"");
pthread_t forms_thread;
- threadCreate(&forms_thread, scope_thread_gNB, &parms, "scope", -1, OAI_PRIORITY_RT_LOW);
+ threadCreate(&forms_thread, scope_thread_gNB, p->gNB->scopeData, "scope", -1, OAI_PRIORITY_RT_LOW);
}
static void ueWaterFall (OAIgraph_t *graph, PHY_VARS_NR_UE *phy_vars_ue, int eNB_id, int UE_id) {
diff --git a/openair1/PHY/TOOLS/nr_phy_scope.h b/openair1/PHY/TOOLS/nr_phy_scope.h
index 84b9e66908..e34ddf2c20 100644
--- a/openair1/PHY/TOOLS/nr_phy_scope.h
+++ b/openair1/PHY/TOOLS/nr_phy_scope.h
@@ -33,13 +33,7 @@
//#include "PHY/impl_defs_top.h"
#include "PHY/defs_nr_UE.h"
-typedef struct {
- int *argc;
- char **argv;
- RU_t *ru;
- PHY_VARS_gNB *gNB;
-} scopeParms_t;
-
+#include
extern RAN_CONTEXT_t RC;
#endif
diff --git a/openair1/PHY/TOOLS/phy_scope_interface.c b/openair1/PHY/TOOLS/phy_scope_interface.c
index af237b2325..7cd68c53d2 100644
--- a/openair1/PHY/TOOLS/phy_scope_interface.c
+++ b/openair1/PHY/TOOLS/phy_scope_interface.c
@@ -35,6 +35,7 @@
#include "phy_scope_interface.h"
#define SOFTSCOPE_ENDFUNC_IDX 0
+
static loader_shlibfunc_t scope_fdesc[]= {{"end_forms",NULL}};
int load_softscope(char *exectype, void *initarg) {
diff --git a/openair1/PHY/TOOLS/phy_scope_interface.h b/openair1/PHY/TOOLS/phy_scope_interface.h
index adf04d5ea4..8b747d575d 100644
--- a/openair1/PHY/TOOLS/phy_scope_interface.h
+++ b/openair1/PHY/TOOLS/phy_scope_interface.h
@@ -29,7 +29,26 @@
* \note
* \warning
*/
+#ifndef __PHY_SCOPE_INTERFACE_H__
+#define __PHY_SCOPE_INTERFACE_H__
+#include
+typedef struct {
+ int *argc;
+ char **argv;
+ RU_t *ru;
+ PHY_VARS_gNB *gNB;
+} scopeParms_t;
+typedef struct scopeData_s {
+ int *argc;
+ char **argv;
+ RU_t *ru;
+ PHY_VARS_gNB *gNB;
+ int32_t * rxdataF;
+ void (*slotFunc)(int32_t* data, int slot, void * scopeData);
+} scopeData_t;
+
int load_softscope(char *exectype, void *initarg);
int end_forms(void) ;
+#endif
diff --git a/openair1/PHY/defs_common.h b/openair1/PHY/defs_common.h
index 27765a8548..1a8016054a 100644
--- a/openair1/PHY/defs_common.h
+++ b/openair1/PHY/defs_common.h
@@ -867,8 +867,9 @@ typedef enum {
NOT_SYNCHED=0,
PRACH=1,
RA_RESPONSE=2,
- PUSCH=3,
- RESYNCH=4
+ RA_WAIT_CR=3,
+ PUSCH=4,
+ RESYNCH=5
} UE_MODE_t;
#define FOREACH_PARALLEL(GEN) \
diff --git a/openair1/PHY/defs_gNB.h b/openair1/PHY/defs_gNB.h
index b7923adb0b..52abe9fddc 100644
--- a/openair1/PHY/defs_gNB.h
+++ b/openair1/PHY/defs_gNB.h
@@ -655,6 +655,7 @@ typedef struct {
int prach_I0;
} PHY_MEASUREMENTS_gNB;
+#define MAX_NUM_NR_PRACH_PREAMBLES 64
#define MAX_NUM_NR_RX_RACH_PDUS 4
#define MAX_NUM_NR_RX_PRACH_PREAMBLES 4
#define MAX_UL_PDUS_PER_SLOT 8
@@ -833,7 +834,7 @@ typedef struct PHY_VARS_gNB_s {
tpool_t *threadPool;
int nbDecode;
uint8_t pusch_proc_threads;
-
+ void * scopeData;
} PHY_VARS_gNB;
typedef struct LDPCDecode_s {
diff --git a/openair1/SCHED_NR_UE/phy_procedures_nr_ue.c b/openair1/SCHED_NR_UE/phy_procedures_nr_ue.c
index f516ad8639..c78632a5b4 100644
--- a/openair1/SCHED_NR_UE/phy_procedures_nr_ue.c
+++ b/openair1/SCHED_NR_UE/phy_procedures_nr_ue.c
@@ -132,6 +132,7 @@ void nr_fill_rx_indication(fapi_nr_rx_indication_t *rx_ind,
}
switch (pdu_type){
+ case FAPI_NR_RX_PDU_TYPE_SIB:
case FAPI_NR_RX_PDU_TYPE_DLSCH:
case FAPI_NR_RX_PDU_TYPE_RAR:
harq_pid = dlsch0->current_harq_pid;
@@ -795,6 +796,7 @@ int nr_ue_pdsch_procedures(PHY_VARS_NR_UE *ue, UE_nr_rxtx_proc_t *proc, int eNB_
uint16_t pdsch_nb_rb = dlsch0_harq->nb_rb;
uint16_t s0 = dlsch0_harq->start_symbol;
uint16_t s1 = dlsch0_harq->nb_symbols;
+ bool is_SI = dlsch0->rnti_type == _SI_RNTI_;
LOG_D(PHY,"[UE %d] PDSCH type %d active in nr_slot_rx %d, harq_pid %d (%d), rb_start %d, nb_rb %d, symbol_start %d, nb_symbols %d, DMRS mask %x\n",ue->Mod_id,pdsch,nr_slot_rx,harq_pid,dlsch0->harq_processes[harq_pid]->status,pdsch_start_rb,pdsch_nb_rb,s0,s1,dlsch0->harq_processes[harq_pid]->dlDmrsSymbPos);
@@ -804,6 +806,7 @@ int nr_ue_pdsch_procedures(PHY_VARS_NR_UE *ue, UE_nr_rxtx_proc_t *proc, int eNB_
nr_pdsch_channel_estimation(ue,
proc,
0 /*eNB_id*/,
+ is_SI,
nr_slot_rx,
aatx /*p*/,
m,
@@ -1208,7 +1211,8 @@ void nr_ue_dlsch_procedures(PHY_VARS_NR_UE *ue,
nr_fill_rx_indication(&rx_ind, FAPI_NR_RX_PDU_TYPE_DLSCH, eNB_id, ue, dlsch0, number_pdus);
break;
case SI_PDSCH:
- rx_ind.rx_indication_body[0].pdu_type = FAPI_NR_RX_PDU_TYPE_SIB;
+ nr_fill_dl_indication(&dl_indication, NULL, &rx_ind, proc, ue, eNB_id);
+ nr_fill_rx_indication(&rx_ind, FAPI_NR_RX_PDU_TYPE_SIB, eNB_id, ue, dlsch0, number_pdus);
break;
default:
break;
@@ -2160,7 +2164,7 @@ void nr_ue_prach_procedures(PHY_VARS_NR_UE *ue, UE_nr_rxtx_proc_t *proc, uint8_t
}
- if (nr_prach == 1) {
+ if (nr_prach == GENERATE_PREAMBLE) {
if (ue->mac_enabled == 1) {
int16_t pathloss = get_nr_PL(mod_id, ue->CC_id, gNB_id);
@@ -2206,18 +2210,15 @@ void nr_ue_prach_procedures(PHY_VARS_NR_UE *ue, UE_nr_rxtx_proc_t *proc, uint8_t
if (ue->mac_enabled == 1)
nr_Msg1_transmitted(mod_id, ue->CC_id, frame_tx, gNB_id);
- } else if (nr_prach == 2) {
-
+ } else if (nr_prach == WAIT_CONTENTION_RESOLUTION) {
+ LOG_D(PHY, "In %s: [UE %d] RA waiting contention resolution\n", __FUNCTION__, mod_id);
+ ue->UE_mode[gNB_id] = RA_WAIT_CR;
+ } else if (nr_prach == RA_SUCCEEDED) {
LOG_D(PHY, "In %s: [UE %d] RA completed, setting UE mode to PUSCH\n", __FUNCTION__, mod_id);
-
ue->UE_mode[gNB_id] = PUSCH;
-
- } else if(nr_prach == 3){
-
+ } else if(nr_prach == RA_FAILED){
LOG_D(PHY, "In %s: [UE %d] RA failed, setting UE mode to PRACH\n", __FUNCTION__, mod_id);
-
ue->UE_mode[gNB_id] = PRACH;
-
}
VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_PHY_PROCEDURES_UE_TX_PRACH, VCD_FUNCTION_OUT);
diff --git a/openair1/SIMULATION/NR_PHY/dlsim.c b/openair1/SIMULATION/NR_PHY/dlsim.c
index 6784535391..040f8c5a54 100644
--- a/openair1/SIMULATION/NR_PHY/dlsim.c
+++ b/openair1/SIMULATION/NR_PHY/dlsim.c
@@ -87,12 +87,30 @@ uint64_t downlink_frequency[MAX_NUM_CCs][4];
// dummy functions
int dummy_nr_ue_ul_indication(nr_uplink_indication_t *ul_info) { return(0); }
-int8_t nr_mac_rrc_data_ind_ue(const module_id_t module_id,
- const int CC_id,
- const uint8_t gNB_index,
- const int8_t channel,
- const uint8_t* pduP,
- const sdu_size_t pdu_len)
+int8_t nr_mac_rrc_data_ind_ue(const module_id_t module_id,
+ const int CC_id,
+ const uint8_t gNB_index,
+ const frame_t frame,
+ const sub_frame_t sub_frame,
+ const rnti_t rnti,
+ const channel_t channel,
+ const uint8_t* pduP,
+ const sdu_size_t pdu_len)
+{
+ return 0;
+}
+
+void nr_rrc_ue_generate_RRCSetupRequest(module_id_t module_id, const uint8_t gNB_index)
+{
+ return;
+}
+
+int8_t nr_mac_rrc_data_req_ue(const module_id_t Mod_idP,
+ const int CC_id,
+ const uint8_t gNB_id,
+ const frame_t frameP,
+ const rb_id_t Srb_id,
+ uint8_t *buffer_pP)
{
return 0;
}
@@ -185,10 +203,6 @@ int oai_nfapi_tx_data_req(nfapi_nr_tx_data_request_t *tx_data_req){ return(0);
int oai_nfapi_ul_dci_req(nfapi_nr_ul_dci_request_t *ul_dci_req){ return(0); }
int oai_nfapi_ul_tti_req(nfapi_nr_ul_tti_request_t *ul_tti_req){ return(0); }
-int8_t nr_rrc_ue_decode_NR_SIB1_Message(module_id_t module_id, uint8_t gNB_index, uint8_t *const bufferP, const uint8_t buffer_len) {
- return 0;
-}
-
// needed for some functions
openair0_config_t openair0_cfg[MAX_CARDS];
void update_ptrs_config(NR_CellGroupConfig_t *secondaryCellGroup, uint16_t *rbSize, uint8_t *mcsIndex,int8_t *ptrs_arg);
diff --git a/openair1/SIMULATION/NR_PHY/nr_unitary_defs.h b/openair1/SIMULATION/NR_PHY/nr_unitary_defs.h
index 8004fbb6b5..906636d56f 100644
--- a/openair1/SIMULATION/NR_PHY/nr_unitary_defs.h
+++ b/openair1/SIMULATION/NR_PHY/nr_unitary_defs.h
@@ -55,19 +55,6 @@ signed char quantize(double D, double x, unsigned char B) {
return ((char) qxd);
}
-
-int8_t
-mac_rrc_data_req_ue(
- const module_id_t Mod_idP,
- const int CC_id,
- const frame_t frameP,
- const rb_id_t Srb_id,
- const uint8_t Nb_tb,
- uint8_t *const buffer_pP,
- const mac_enb_index_t eNB_indexP,
- const uint8_t mbsfn_sync_area
- ) { return(0);}
-
int oai_nfapi_rach_ind(nfapi_rach_indication_t *rach_ind) {return(0);}
//NR_IF_Module_t *NR_IF_Module_init(int Mod_id){return(NULL);}
int oai_nfapi_ul_config_req(nfapi_ul_config_request_t *ul_config_req) { return(0); }
diff --git a/openair1/SIMULATION/NR_PHY/prachsim.c b/openair1/SIMULATION/NR_PHY/prachsim.c
index c90bcf1395..4b6e9993cc 100644
--- a/openair1/SIMULATION/NR_PHY/prachsim.c
+++ b/openair1/SIMULATION/NR_PHY/prachsim.c
@@ -47,6 +47,7 @@
#include "OCG_vars.h"
#include
#include
+#include
//#include "openair1/SIMULATION/NR_PHY/nr_dummy_functions.c"
@@ -130,15 +131,37 @@ nr_rrc_gNB_process_GTPV1U_CREATE_TUNNEL_RESP(
return 0;
}
-int8_t nr_mac_rrc_data_ind_ue(const module_id_t module_id, const int CC_id, const uint8_t gNB_index, const int8_t channel, const uint8_t* pduP, const sdu_size_t pdu_len) {return 0;}
-
-// Dummy function to avoid linking error at compilation of nr-prachsim
-int is_x2ap_enabled(void)
+int8_t nr_mac_rrc_data_ind_ue(const module_id_t module_id,
+ const int CC_id,
+ const uint8_t gNB_index,
+ const frame_t frame,
+ const sub_frame_t sub_frame,
+ const rnti_t rnti,
+ const channel_t channel,
+ const uint8_t* pduP,
+ const sdu_size_t pdu_len)
{
return 0;
}
-int8_t nr_rrc_ue_decode_NR_SIB1_Message(module_id_t module_id, uint8_t gNB_index, uint8_t *const bufferP, const uint8_t buffer_len) {
+void nr_rrc_ue_generate_RRCSetupRequest(module_id_t module_id, const uint8_t gNB_index)
+{
+ return;
+}
+
+int8_t nr_mac_rrc_data_req_ue(const module_id_t Mod_idP,
+ const int CC_id,
+ const uint8_t gNB_id,
+ const frame_t frameP,
+ const rb_id_t Srb_id,
+ uint8_t *buffer_pP)
+{
+ return 0;
+}
+
+// Dummy function to avoid linking error at compilation of nr-prachsim
+int is_x2ap_enabled(void)
+{
return 0;
}
diff --git a/openair1/SIMULATION/NR_PHY/ulsim.c b/openair1/SIMULATION/NR_PHY/ulsim.c
index 443ee6e1c0..fded8619f0 100644
--- a/openair1/SIMULATION/NR_PHY/ulsim.c
+++ b/openair1/SIMULATION/NR_PHY/ulsim.c
@@ -82,9 +82,19 @@ double cpuf;
//uint8_t nfapi_mode = 0;
uint64_t downlink_frequency[MAX_NUM_CCs][4];
+int8_t nr_mac_rrc_data_ind_ue(const module_id_t module_id,
+ const int CC_id,
+ const uint8_t gNB_index,
+ const frame_t frame,
+ const sub_frame_t sub_frame,
+ const rnti_t rnti,
+ const channel_t channel,
+ const uint8_t* pduP,
+ const sdu_size_t pdu_len)
+{
+ return 0;
+}
-int8_t nr_mac_rrc_data_ind_ue(const module_id_t module_id, const int CC_id, const uint8_t gNB_index,
- const int8_t channel, const uint8_t* pduP, const sdu_size_t pdu_len) { return 0; }
int generate_dlsch_header(unsigned char *mac_header,
unsigned char num_sdus,
unsigned short *sdu_lengths,
@@ -155,15 +165,27 @@ int is_x2ap_enabled(void)
return 0;
}
-//nFAPI P7 dummy functions
+void nr_rrc_ue_generate_RRCSetupRequest(module_id_t module_id, const uint8_t gNB_index)
+{
+ return;
+}
+
+int8_t nr_mac_rrc_data_req_ue(const module_id_t Mod_idP,
+ const int CC_id,
+ const uint8_t gNB_id,
+ const frame_t frameP,
+ const rb_id_t Srb_id,
+ uint8_t *buffer_pP)
+{
+ return 0;
+}
+
+//nFAPI P7 dummy functions
int oai_nfapi_dl_tti_req(nfapi_nr_dl_tti_request_t *dl_config_req) { return(0); }
int oai_nfapi_tx_data_req(nfapi_nr_tx_data_request_t *tx_data_req){ return(0); }
int oai_nfapi_ul_dci_req(nfapi_nr_ul_dci_request_t *ul_dci_req){ return(0); }
int oai_nfapi_ul_tti_req(nfapi_nr_ul_tti_request_t *ul_tti_req){ return(0); }
-int8_t nr_rrc_ue_decode_NR_SIB1_Message(module_id_t module_id, uint8_t gNB_index, uint8_t *const bufferP, const uint8_t buffer_len) {
- return 0;
-}
int nr_derive_key(int alg_type, uint8_t alg_id,
const uint8_t key[32], uint8_t **out)
diff --git a/openair2/COMMON/gtpv1_u_messages_def.h b/openair2/COMMON/gtpv1_u_messages_def.h
index 86103dd911..e5ce496701 100644
--- a/openair2/COMMON/gtpv1_u_messages_def.h
+++ b/openair2/COMMON/gtpv1_u_messages_def.h
@@ -33,4 +33,5 @@ MESSAGE_DEF(GTPV1U_ENB_S1_REQ, MESSAGE_PRIORITY_MED, Gtpv1uS1Req, gtpv
MESSAGE_DEF(GTPV1U_GNB_DELETE_TUNNEL_REQ, MESSAGE_PRIORITY_MED, gtpv1u_gnb_delete_tunnel_req_t, NRGtpv1uDeleteTunnelReq)
MESSAGE_DEF(GTPV1U_GNB_DELETE_TUNNEL_RESP, MESSAGE_PRIORITY_MED, gtpv1u_gnb_delete_tunnel_resp_t, NRGtpv1uDeleteTunnelResp)
-MESSAGE_DEF(GTPV1U_GNB_NG_REQ, MESSAGE_PRIORITY_MED, Gtpv1uNGReq, gtpv1uNGReq)
+MESSAGE_DEF(GTPV1U_GNB_NG_REQ, MESSAGE_PRIORITY_MED, Gtpv1uNGReq, gtpv1uNGReq)
+MESSAGE_DEF(GTPV1U_GNB_TUNNEL_DATA_REQ, MESSAGE_PRIORITY_MED, gtpv1u_gnb_tunnel_data_req_t, NRGtpv1uTunnelDataReq)
diff --git a/openair2/COMMON/gtpv1_u_messages_types.h b/openair2/COMMON/gtpv1_u_messages_types.h
index 8fde343000..b94997c90b 100644
--- a/openair2/COMMON/gtpv1_u_messages_types.h
+++ b/openair2/COMMON/gtpv1_u_messages_types.h
@@ -44,6 +44,7 @@
#define GTPV1U_GNB_DELETE_TUNNEL_REQ(mSGpTR) (mSGpTR)->ittiMsg.NRGtpv1uDeleteTunnelReq
#define GTPV1U_GNB_DELETE_TUNNEL_RESP(mSGpTR) (mSGpTR)->ittiMsg.NRGtpv1uDeleteTunnelResp
#define GTPV1U_GNB_NG_REQ(mSGpTR) (mSGpTR)->ittiMsg.gtpv1uNGReq
+#define GTPV1U_GNB_TUNNEL_DATA_REQ(mSGpTR) (mSGpTR)->ittiMsg.NRGtpv1uTunnelDataReq
#define GTPV1U_ALL_TUNNELS_TEID (teid_t)0xFFFFFFFF
@@ -210,4 +211,12 @@ typedef struct gtpv1u_gnb_delete_tunnel_resp_s {
teid_t gnb_NGu_teid; ///< local NGU Tunnel Endpoint Identifier to be deleted
} gtpv1u_gnb_delete_tunnel_resp_t;
+typedef struct gtpv1u_gnb_tunnel_data_req_s {
+ uint8_t *buffer;
+ uint32_t length;
+ uint32_t offset; ///< start of message offset in buffer
+ rnti_t rnti;
+ pdusessionid_t pdusession_id;
+} gtpv1u_gnb_tunnel_data_req_t;
+
#endif /* GTPV1_U_MESSAGES_TYPES_H_ */
diff --git a/openair2/F1AP/f1ap_cu_rrc_message_transfer.c b/openair2/F1AP/f1ap_cu_rrc_message_transfer.c
index d71dbc5844..e279804ada 100644
--- a/openair2/F1AP/f1ap_cu_rrc_message_transfer.c
+++ b/openair2/F1AP/f1ap_cu_rrc_message_transfer.c
@@ -130,11 +130,11 @@ int CU_handle_INITIAL_UL_RRC_MESSAGE_TRANSFER(instance_t instance,
ccch_sdu_len);
}
- //LOG_I(F1AP, "%s() RRCContainer (CCCH) size %ld: ", __func__,
- // ie->value.choice.RRCContainer.size);
- //for (int i = 0; i < ie->value.choice.RRCContainer.size; i++)
- // printf("%02x ", RRC_MAC_CCCH_DATA_IND (message_p).sdu[i]);
- //printf("\n");
+ LOG_I(F1AP, "%s() RRCContainer (CCCH) size %ld: ", __func__,
+ ie->value.choice.RRCContainer.size);
+ for (int i = 0; i < ie->value.choice.RRCContainer.size; i++)
+ printf("%02x ", RRC_MAC_CCCH_DATA_IND (message_p).sdu[i]);
+ printf("\n");
// Find instance from nr_cellid
int rrc_inst = -1;
@@ -169,39 +169,13 @@ int CU_handle_INITIAL_UL_RRC_MESSAGE_TRANSFER(instance_t instance,
f1ap_cu_inst[rrc_inst].f1ap_ue[f1ap_uid].du_ue_f1ap_id = du_ue_f1ap_id;
if (RC.nrrrc[GNB_INSTANCE_TO_MODULE_ID(instance)]->node_type == ngran_gNB_CU) {
- if(0) {
- NR_RRC_MAC_CCCH_DATA_IND (message_p).frame = 0;
- NR_RRC_MAC_CCCH_DATA_IND (message_p).sub_frame = 0;
- NR_RRC_MAC_CCCH_DATA_IND (message_p).sdu_size = ccch_sdu_len;
- NR_RRC_MAC_CCCH_DATA_IND (message_p).gnb_index = rrc_inst; // CU instance
- NR_RRC_MAC_CCCH_DATA_IND (message_p).rnti = rnti;
- NR_RRC_MAC_CCCH_DATA_IND (message_p).CC_id = CC_id;
- itti_send_msg_to_task (TASK_RRC_GNB, instance, message_p);
- }
-
- protocol_ctxt_t ctxt;
- ctxt.module_id = instance;
- ctxt.instance = instance;
- ctxt.rnti = 0x1234; //f1ap_get_rnti_by_cu_id(&f1ap_cu_inst[instance], cu_ue_f1ap_id);
- ctxt.enb_flag = 1;
- ctxt.eNB_index = 0;
- ctxt.configured = 1;
- mem_block_t *mb = get_free_mem_block(ie->value.choice.RRCContainer.size,__func__);
- memcpy((void*)mb->data,(void*)ie->value.choice.RRCContainer.buf,ie->value.choice.RRCContainer.size);
- LOG_I(F1AP, "Calling pdcp_data_ind for UE RNTI %x srb_id %d with size %ld (DCCH) \n", ctxt.rnti, 1, ie->value.choice.RRCContainer.size);
-
- LOG_I(F1AP, "%s() RRCContainer size %lu: ", __func__, ie->value.choice.RRCContainer.size);
- for (int i = 0; i < ie->value.choice.RRCContainer.size; i++)
- printf("%02x ", mb->data[i]);
- printf("\n");
-
- pdcp_data_ind (&ctxt,
- 1, // srb_flag
- 0, // embms_flag
- 1,
- ie->value.choice.RRCContainer.size,
- mb);
- return 0;
+ NR_RRC_MAC_CCCH_DATA_IND (message_p).frame = 0;
+ NR_RRC_MAC_CCCH_DATA_IND (message_p).sub_frame = 0;
+ NR_RRC_MAC_CCCH_DATA_IND (message_p).sdu_size = ccch_sdu_len;
+ NR_RRC_MAC_CCCH_DATA_IND (message_p).gnb_index = rrc_inst; // CU instance
+ NR_RRC_MAC_CCCH_DATA_IND (message_p).rnti = rnti;
+ NR_RRC_MAC_CCCH_DATA_IND (message_p).CC_id = CC_id;
+ itti_send_msg_to_task (TASK_RRC_GNB, instance, message_p);
} else {
RRC_MAC_CCCH_DATA_IND (message_p).frame = 0;
RRC_MAC_CCCH_DATA_IND (message_p).sub_frame = 0;
diff --git a/openair2/F1AP/f1ap_du_rrc_message_transfer.c b/openair2/F1AP/f1ap_du_rrc_message_transfer.c
index 017ed2d66a..19c5d5407e 100644
--- a/openair2/F1AP/f1ap_du_rrc_message_transfer.c
+++ b/openair2/F1AP/f1ap_du_rrc_message_transfer.c
@@ -1243,31 +1243,14 @@ int DU_handle_DL_NR_RRC_MESSAGE_TRANSFER(instance_t instance,
RC.nrrrc[ctxt.module_id],
ctxt.rnti);
- NR_DL_CCCH_Message_t* dl_ccch_msg=NULL;
- asn_dec_rval_t dec_rval;
- if (du_ccch_flag) {
- /* for rfsim */
- dec_rval = uper_decode(NULL,
- &asn_DEF_NR_DL_CCCH_Message,
- (void**)&dl_ccch_msg,
- &ie->value.choice.RRCContainer.buf[2],
- rrc_dl_sdu_len-6,0,0);
- if (dec_rval.code == RC_OK) {
- srb_id = 0;
- du_ccch_flag = 0;
- } else {
- srb_id = 1;
- }
- }
-
if (srb_id == 0) {
- // NR_DL_CCCH_Message_t* dl_ccch_msg=NULL;
- // asn_dec_rval_t dec_rval;
- // dec_rval = uper_decode(NULL,
- // &asn_DEF_NR_DL_CCCH_Message,
- // (void**)&dl_ccch_msg,
- // ie->value.choice.RRCContainer.buf,
- // rrc_dl_sdu_len,0,0);
+ NR_DL_CCCH_Message_t* dl_ccch_msg=NULL;
+ asn_dec_rval_t dec_rval;
+ dec_rval = uper_decode(NULL,
+ &asn_DEF_NR_DL_CCCH_Message,
+ (void**)&dl_ccch_msg,
+ ie->value.choice.RRCContainer.buf,
+ rrc_dl_sdu_len,0,0);
AssertFatal(dec_rval.code == RC_OK, "could not decode F1AP message\n");
switch (dl_ccch_msg->message.choice.c1->present) {
@@ -1349,7 +1332,7 @@ int DU_handle_DL_NR_RRC_MESSAGE_TRANSFER(instance_t instance,
"Unknown message\n");
break;
}// switch case
-
+ return(0);
} else if (srb_id == 1) {
NR_DL_DCCH_Message_t* dl_dcch_msg=NULL;
@@ -1480,6 +1463,7 @@ int DU_handle_DL_NR_RRC_MESSAGE_TRANSFER(instance_t instance,
LOG_I(F1AP, "Received DL RRC Transfer on srb_id %ld\n", srb_id);
+
// rlc_op_status_t rlc_status;
// boolean_t ret = TRUE;
mem_block_t *pdcp_pdu_p = NULL;
diff --git a/openair2/LAYER2/MAC/mac.h b/openair2/LAYER2/MAC/mac.h
index 1bae590a59..ae8522bc83 100644
--- a/openair2/LAYER2/MAC/mac.h
+++ b/openair2/LAYER2/MAC/mac.h
@@ -490,7 +490,7 @@ typedef struct {
/*! \brief Uplink SCH PDU Structure */
typedef struct {
- int8_t payload[SCH_PAYLOAD_SIZE_MAX]; /*!< \brief SACH payload */
+ uint8_t payload[SCH_PAYLOAD_SIZE_MAX]; /*!< \brief SACH payload */
uint16_t Pdu_size;
} __attribute__ ((__packed__)) ULSCH_PDU;
diff --git a/openair2/LAYER2/NR_MAC_COMMON/nr_compute_tbs_common.c b/openair2/LAYER2/NR_MAC_COMMON/nr_compute_tbs_common.c
index 452ed45b3a..996c2fbe27 100644
--- a/openair2/LAYER2/NR_MAC_COMMON/nr_compute_tbs_common.c
+++ b/openair2/LAYER2/NR_MAC_COMMON/nr_compute_tbs_common.c
@@ -51,6 +51,8 @@ uint32_t nr_compute_tbs(uint16_t Qm,
uint32_t Ninfo, Np_info, C;
uint8_t n, scale;
+ LOG_D(MAC,"nb_symb_sch %d, nb_dmrs_prb %d, nb_rb_oh %d\n",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;
diff --git a/openair2/LAYER2/NR_MAC_COMMON/nr_mac.h b/openair2/LAYER2/NR_MAC_COMMON/nr_mac.h
index 381dce11b2..fa4d8d48ea 100644
--- a/openair2/LAYER2/NR_MAC_COMMON/nr_mac.h
+++ b/openair2/LAYER2/NR_MAC_COMMON/nr_mac.h
@@ -339,7 +339,6 @@ typedef struct {
#define UL_SCH_LCID_SRB2 0x02
#define UL_SCH_LCID_SRB3 0x03
#define UL_SCH_LCID_DTCH 0x04
-#define UL_SCH_LCID_CCCH_MSG3 0x21
#define UL_SCH_LCID_RECOMMENDED_BITRATE_QUERY 0x35
#define UL_SCH_LCID_MULTI_ENTRY_PHR_4_OCT 0x36
#define UL_SCH_LCID_CONFIGURED_GRANT_CONFIRMATION 0x37
diff --git a/openair2/LAYER2/NR_MAC_COMMON/nr_mac_common.c b/openair2/LAYER2/NR_MAC_COMMON/nr_mac_common.c
index 5d1b08bcf6..ad68b3b950 100644
--- a/openair2/LAYER2/NR_MAC_COMMON/nr_mac_common.c
+++ b/openair2/LAYER2/NR_MAC_COMMON/nr_mac_common.c
@@ -2228,8 +2228,8 @@ int get_num_dmrs(uint16_t dmrs_mask ) {
return(num_dmrs);
}
/* returns the total DMRS symbols in a slot*/
-uint8_t get_num_dmrs_symbols(NR_PDSCH_Config_t *pdsch_Config,int dmrs_TypeA_Position,int NrOfSymbols){
- return get_num_dmrs(fill_dmrs_mask(pdsch_Config,dmrs_TypeA_Position,NrOfSymbols));
+uint8_t get_num_dmrs_symbols(NR_PDSCH_Config_t *pdsch_Config,int dmrs_TypeA_Position,int NrOfSymbols,int startSymbol){
+ return get_num_dmrs(fill_dmrs_mask(pdsch_Config,dmrs_TypeA_Position,NrOfSymbols,startSymbol));
}
// Table 5.1.2.2.1-1 38.214
@@ -2864,9 +2864,10 @@ int is_nr_UL_slot(NR_ServingCellConfigCommon_t *scc,slot_t slot) {
else return(slot_in_period >= slots1+scc->tdd_UL_DL_ConfigurationCommon->pattern2->nrofDownlinkSlots ? 1 : 0);
}
-int16_t fill_dmrs_mask(NR_PDSCH_Config_t *pdsch_Config,int dmrs_TypeA_Position,int NrOfSymbols) {
+int16_t fill_dmrs_mask(NR_PDSCH_Config_t *pdsch_Config,int dmrs_TypeA_Position,int NrOfSymbols,int startSymbol) {
int l0;
+ int ld = NrOfSymbols;
if (dmrs_TypeA_Position == NR_ServingCellConfigCommon__dmrs_TypeA_Position_pos2) l0=2;
else if (dmrs_TypeA_Position == NR_ServingCellConfigCommon__dmrs_TypeA_Position_pos3) l0=3;
else AssertFatal(1==0,"Illegal dmrs_TypeA_Position %d\n",(int)dmrs_TypeA_Position);
@@ -2877,8 +2878,9 @@ int16_t fill_dmrs_mask(NR_PDSCH_Config_t *pdsch_Config,int dmrs_TypeA_Position,i
if (pdsch_Config->dmrs_DownlinkForPDSCH_MappingTypeA &&
pdsch_Config->dmrs_DownlinkForPDSCH_MappingTypeA->present == NR_SetupRelease_DMRS_DownlinkConfig_PR_setup) {
// Relative to start of slot
+ ld += startSymbol;
NR_DMRS_DownlinkConfig_t *dmrs_config = (NR_DMRS_DownlinkConfig_t *)pdsch_Config->dmrs_DownlinkForPDSCH_MappingTypeA->choice.setup;
- AssertFatal(NrOfSymbols>1 && NrOfSymbols < 15,"Illegal NrOfSymbols %d\n",NrOfSymbols);
+ AssertFatal(ld>1 && ld < 15,"Illegal l_d %d\n",ld);
int pos2=0;
if (dmrs_config->maxLength == NULL) {
// this is Table 7.4.1.1.2-3: PDSCH DM-RS positions l for single-symbol DM-RS
@@ -2887,7 +2889,7 @@ int16_t fill_dmrs_mask(NR_PDSCH_Config_t *pdsch_Config,int dmrs_TypeA_Position,i
return(1<3,"Illegal NrOfSymbols %d for len2 DMRS\n",NrOfSymbols);
- if (NrOfSymbols < 10) return(1<dmrs_AdditionalPosition==NR_DMRS_DownlinkConfig__dmrs_AdditionalPosition_pos0) return(1<dmrs_AdditionalPosition!=NR_DMRS_DownlinkConfig__dmrs_AdditionalPosition_pos0) return(1<3,"Illegal l_d %d for len2 DMRS\n",ld);
+ if (ld < 10) return(1<dmrs_AdditionalPosition==NR_DMRS_DownlinkConfig__dmrs_AdditionalPosition_pos0) return(1<dmrs_AdditionalPosition!=NR_DMRS_DownlinkConfig__dmrs_AdditionalPosition_pos0) return(1<dmrs_AdditionalPosition!=NR_DMRS_DownlinkConfig__dmrs_AdditionalPosition_pos0) return(1<dmrs_AdditionalPosition!=NR_DMRS_DownlinkConfig__dmrs_AdditionalPosition_pos1) return(1<dmrs_AdditionalPosition==NR_DMRS_DownlinkConfig__dmrs_AdditionalPosition_pos0) return(1<servCellIndex = *cell_group_config->spCellConfig->servCellIndex;
config_control_ue(mac);
if (cell_group_config->spCellConfig->reconfigurationWithSync) {
- ra->rach_ConfigDedicated = cell_group_config->spCellConfig->reconfigurationWithSync->rach_ConfigDedicated->choice.uplink;
- mac->scc = cell_group_config->spCellConfig->reconfigurationWithSync->spCellConfigCommon;
- config_common_ue(mac,module_id,cc_idP);
- mac->crnti = cell_group_config->spCellConfig->reconfigurationWithSync->newUE_Identity;
- LOG_I(MAC,"Configuring CRNTI %x\n",mac->crnti);
+ if (cell_group_config->spCellConfig->reconfigurationWithSync->rach_ConfigDedicated) {
+ ra->rach_ConfigDedicated = cell_group_config->spCellConfig->reconfigurationWithSync->rach_ConfigDedicated->choice.uplink;
+ }
+ mac->scc = cell_group_config->spCellConfig->reconfigurationWithSync->spCellConfigCommon;
+ config_common_ue(mac,module_id,cc_idP);
+ mac->crnti = cell_group_config->spCellConfig->reconfigurationWithSync->newUE_Identity;
+ LOG_I(MAC,"Configuring CRNTI %x\n",mac->crnti);
}
// Setup the SSB to Rach Occasions mapping according to the config
diff --git a/openair2/LAYER2/NR_MAC_UE/mac_defs.h b/openair2/LAYER2/NR_MAC_UE/mac_defs.h
index dd0aa15c52..4c2f3f8a90 100755
--- a/openair2/LAYER2/NR_MAC_UE/mac_defs.h
+++ b/openair2/LAYER2/NR_MAC_UE/mac_defs.h
@@ -234,9 +234,12 @@ typedef struct {
typedef enum {
RA_UE_IDLE = 0,
- WAIT_RAR = 1,
- WAIT_CONTENTION_RESOLUTION = 2,
- RA_SUCCEEDED = 3
+ GENERATE_IDLE = 0,
+ GENERATE_PREAMBLE = 1,
+ WAIT_RAR = 2,
+ WAIT_CONTENTION_RESOLUTION = 3,
+ RA_SUCCEEDED = 4,
+ RA_FAILED = 5
} RA_state_t;
typedef struct {
@@ -257,8 +260,10 @@ typedef struct {
uint8_t RA_attempt_number;
/// Random-access procedure flag
uint8_t RA_active;
+ /// Random-access preamble index
+ int ra_PreambleIndex;
/// Flag for the Msg1 generation: enabled at every occurrence of nr prach slot
- uint8_t generate_nr_prach;
+ RA_state_t generate_nr_prach;
/// Random-access window counter
int16_t RA_window_cnt;
@@ -289,6 +294,8 @@ typedef struct {
uint8_t RA_contention_resolution_timer_active;
/// Random-access Contention Resolution Timer count value
uint8_t RA_contention_resolution_cnt;
+ /// Transmitted UE Contention Resolution Identifier
+ uint8_t cont_res_id[6];
/// BeamfailurerecoveryConfig
NR_BeamFailureRecoveryConfig_t RA_BeamFailureRecoveryConfig;
diff --git a/openair2/LAYER2/NR_MAC_UE/mac_proto.h b/openair2/LAYER2/NR_MAC_UE/mac_proto.h
index c4909c1384..14d1ea63fb 100755
--- a/openair2/LAYER2/NR_MAC_UE/mac_proto.h
+++ b/openair2/LAYER2/NR_MAC_UE/mac_proto.h
@@ -56,14 +56,14 @@ int8_t nr_ue_decode_mib(
void *pduP,
uint16_t cell_id );
-/**\brief decode sib1 pdu in NR_UE, from if_module dl_ind
+/**\brief decode SIB1 and other SIs pdus in NR_UE, from if_module dl_ind
\param module_id module id
\param cc_id component carrier id
\param gNB_index gNB index
\param sibs_mask sibs mask
\param pduP pointer to pdu
\param pdu_length length of pdu */
-int8_t nr_ue_decode_sib1(module_id_t module_id,
+int8_t nr_ue_decode_BCCH_DL_SCH(module_id_t module_id,
int cc_id,
unsigned int gNB_index,
uint32_t sibs_mask,
diff --git a/openair2/LAYER2/NR_MAC_UE/mac_vars.c b/openair2/LAYER2/NR_MAC_UE/mac_vars.c
index ecabdb870c..383267090f 100644
--- a/openair2/LAYER2/NR_MAC_UE/mac_vars.c
+++ b/openair2/LAYER2/NR_MAC_UE/mac_vars.c
@@ -32,7 +32,7 @@
#include
-const char *rnti_types[]={"RNTI_new", "RNTI_C", "RNTI_RA", "NR_RNTI_P", "NR_RNTI_CS", "NR_RNTI_TC"};
+const char *rnti_types[]={"RNTI_new", "RNTI_C", "RNTI_RA", "NR_RNTI_P", "NR_RNTI_CS", "NR_RNTI_TC", "NR_RNTI_SP_CSI", "NR_RNTI_SI"};
const char *dci_formats[]={"1_0", "1_1", "2_0", "2_1", "2_2", "2_3", "0_0", "0_1"};
// table_7_3_1_1_2_2_3_4_5 contains values for number of layers and precoding information for tables 7.3.1.1.2-2/3/4/5 from TS 38.212 subclause 7.3.1.1.2
diff --git a/openair2/LAYER2/NR_MAC_UE/nr_ra_procedures.c b/openair2/LAYER2/NR_MAC_UE/nr_ra_procedures.c
index 07c04987f7..fce2eeb0e1 100644
--- a/openair2/LAYER2/NR_MAC_UE/nr_ra_procedures.c
+++ b/openair2/LAYER2/NR_MAC_UE/nr_ra_procedures.c
@@ -35,6 +35,7 @@
/* RRC */
#include "NR_RACH-ConfigCommon.h"
+#include "RRC/NR_UE/rrc_proto.h"
/* PHY */
#include "PHY/NR_TRANSPORT/nr_transport_common_proto.h"
@@ -63,6 +64,8 @@ void init_RA(module_id_t mod_id,
RA_config_t *ra = &mac->ra;
ra->RA_active = 1;
+ ra->ra_PreambleIndex = -1;
+ ra->RA_usedGroupA = 1;
ra->RA_RAPID_found = 0;
ra->preambleTransMax = 0;
ra->first_Msg3 = 1;
@@ -78,8 +81,8 @@ void init_RA(module_id_t mod_id,
if (rach_ConfigDedicated) {
if (rach_ConfigDedicated->cfra){
- LOG_I(MAC, "Initialization of 4-step contention-free random access procedure\n");
- prach_resources->RA_TYPE = RA_4STEP;
+ LOG_I(MAC, "Initialization of 2-step contention-free random access procedure\n");
+ prach_resources->RA_TYPE = RA_2STEP;
ra->cfra = 1;
} else if (rach_ConfigDedicated->ext1){
if (rach_ConfigDedicated->ext1->cfra_TwoStep_r16){
@@ -92,6 +95,10 @@ void init_RA(module_id_t mod_id,
} else {
LOG_E(MAC, "In %s: config not handled\n", __FUNCTION__);
}
+ } else if (nr_rach_ConfigCommon){
+ LOG_I(MAC, "Initialization of 4-step contention-based random access procedure\n");
+ prach_resources->RA_TYPE = RA_4STEP;
+ ra->cfra = 0;
} else {
LOG_E(MAC, "In %s: config not handled\n", __FUNCTION__);
}
@@ -246,7 +253,7 @@ void ra_preambles_config(NR_PRACH_RESOURCES_t *prach_resources, NR_UE_MAC_INST_t
int messageSizeGroupA = 0;
int sizeOfRA_PreamblesGroupA = 0;
int messagePowerOffsetGroupB = 0;
- int PLThreshold;
+ int PLThreshold = 0;
long deltaPreamble_Msg3 = 0;
uint8_t noGroupB = 0;
RA_config_t *ra = &mac->ra;
@@ -349,31 +356,34 @@ void ra_preambles_config(NR_PRACH_RESOURCES_t *prach_resources, NR_UE_MAC_INST_t
}
/* Msg3 has not been transmitted yet */
if (ra->first_Msg3) {
- if (noGroupB) {
- // use Group A preamble
- prach_resources->ra_PreambleIndex = ra->starting_preamble_nb + ((taus()) % ra->cb_preambles_per_ssb);
- ra->RA_usedGroupA = 1;
- } else if ((ra->Msg3_size < messageSizeGroupA) && (dl_pathloss > PLThreshold)) {
- // Group B is configured and RA preamble Group A is used
- // - todo add condition on CCCH_sdu_size for initiation by CCCH
- prach_resources->ra_PreambleIndex = ra->starting_preamble_nb + ((taus()) % sizeOfRA_PreamblesGroupA);
- ra->RA_usedGroupA = 1;
- } else {
- // Group B preamble is configured and used
- // the first sizeOfRA_PreamblesGroupA RA preambles belong to RA Preambles Group A
- // the remaining belong to RA Preambles Group B
- prach_resources->ra_PreambleIndex = ra->starting_preamble_nb + sizeOfRA_PreamblesGroupA + ((taus()) % (ra->cb_preambles_per_ssb - sizeOfRA_PreamblesGroupA));
- ra->RA_usedGroupA = 0;
+ if(ra->ra_PreambleIndex < 0 || ra->ra_PreambleIndex > 63) {
+ if (noGroupB) {
+ // use Group A preamble
+ ra->ra_PreambleIndex = ra->starting_preamble_nb + ((taus()) % ra->cb_preambles_per_ssb);
+ ra->RA_usedGroupA = 1;
+ } else if ((ra->Msg3_size < messageSizeGroupA) && (dl_pathloss > PLThreshold)) {
+ // Group B is configured and RA preamble Group A is used
+ // - todo add condition on CCCH_sdu_size for initiation by CCCH
+ ra->ra_PreambleIndex = ra->starting_preamble_nb + ((taus()) % sizeOfRA_PreamblesGroupA);
+ ra->RA_usedGroupA = 1;
+ } else {
+ // Group B preamble is configured and used
+ // the first sizeOfRA_PreamblesGroupA RA preambles belong to RA Preambles Group A
+ // the remaining belong to RA Preambles Group B
+ ra->ra_PreambleIndex = ra->starting_preamble_nb + sizeOfRA_PreamblesGroupA + ((taus()) % (ra->cb_preambles_per_ssb - sizeOfRA_PreamblesGroupA));
+ ra->RA_usedGroupA = 0;
+ }
}
} else { // Msg3 is being retransmitted
if (ra->RA_usedGroupA && noGroupB) {
- prach_resources->ra_PreambleIndex = ra->starting_preamble_nb + ((taus()) % ra->cb_preambles_per_ssb);
+ ra->ra_PreambleIndex = ra->starting_preamble_nb + ((taus()) % ra->cb_preambles_per_ssb);
} else if (ra->RA_usedGroupA && !noGroupB){
- prach_resources->ra_PreambleIndex = ra->starting_preamble_nb + ((taus()) % sizeOfRA_PreamblesGroupA);
+ ra->ra_PreambleIndex = ra->starting_preamble_nb + ((taus()) % sizeOfRA_PreamblesGroupA);
} else {
- prach_resources->ra_PreambleIndex = ra->starting_preamble_nb + sizeOfRA_PreamblesGroupA + ((taus()) % (ra->cb_preambles_per_ssb - sizeOfRA_PreamblesGroupA));
+ ra->ra_PreambleIndex = ra->starting_preamble_nb + sizeOfRA_PreamblesGroupA + ((taus()) % (ra->cb_preambles_per_ssb - sizeOfRA_PreamblesGroupA));
}
}
+ prach_resources->ra_PreambleIndex = ra->ra_PreambleIndex;
}
// RA-RNTI computation (associated to PRACH occasion in which the RA Preamble is transmitted)
@@ -471,6 +481,7 @@ void nr_Msg3_transmitted(module_id_t mod_id, uint8_t CC_id, frame_t frameP, uint
// start contention resolution timer
ra->RA_contention_resolution_cnt = (nr_rach_ConfigCommon->ra_ContentionResolutionTimer + 1) * 8;
ra->RA_contention_resolution_timer_active = 1;
+ ra->ra_state = WAIT_CONTENTION_RESOLUTION;
}
@@ -502,7 +513,8 @@ uint8_t nr_ue_get_rach(NR_PRACH_RESOURCES_t *prach_resources,
NR_UE_MAC_INST_t *mac = get_mac_inst(mod_id);
RA_config_t *ra = &mac->ra;
uint8_t mac_sdus[MAX_NR_ULSCH_PAYLOAD_BYTES];
- uint8_t lcid = UL_SCH_LCID_CCCH_MSG3, *payload;
+ uint8_t lcid = UL_SCH_LCID_CCCH;
+ uint8_t *payload;
uint16_t size_sdu = 0;
unsigned short post_padding;
NR_ServingCellConfigCommon_t *scc = mac->scc;
@@ -513,12 +525,10 @@ uint8_t nr_ue_get_rach(NR_PRACH_RESOURCES_t *prach_resources,
//NR_FrequencyInfoDL_t *frequencyInfoDL = scc->downlinkConfigCommon->frequencyInfoDL;
NR_RACH_ConfigDedicated_t *rach_ConfigDedicated = ra->rach_ConfigDedicated;
- int prach_genarate = 0;
- // int32_t frame_diff = 0;
-
uint8_t sdu_lcids[NB_RB_MAX] = {0};
uint16_t sdu_lengths[NB_RB_MAX] = {0};
- int TBS_bytes = 848, header_length_total=0, num_sdus, offset, mac_ce_len;
+ int num_sdus = 0;
+ int offset = 0;
// Delay init RA procedure to allow the convergence of the IIR filter on PRACH noise measurements at gNB side
if (!prach_resources->init_msg1) {
@@ -529,45 +539,41 @@ uint8_t nr_ue_get_rach(NR_PRACH_RESOURCES_t *prach_resources,
}
}
- if (prach_resources->init_msg1) {
+ if (prach_resources->init_msg1 && ra->ra_state != RA_SUCCEEDED) {
if (ra->RA_active == 0) {
/* RA not active - checking if RRC is ready to initiate the RA procedure */
LOG_D(MAC, "RA not active. Checking for data to transmit from upper layers...\n");
- payload = (uint8_t*) &mac->CCCH_pdu.payload;
- mac_ce_len = 0;
+ uint8_t TBS_max = 8 + sizeof(NR_MAC_SUBHEADER_SHORT) + sizeof(NR_MAC_SUBHEADER_SHORT);
+ payload = (uint8_t*) mac->CCCH_pdu.payload;
+
num_sdus = 1;
post_padding = 1;
+ sdu_lcids[0] = lcid;
- if (0){
- // initialisation by RRC
- // CCCH PDU
- // size_sdu = (uint16_t) mac_rrc_data_req_ue(mod_id,
- // CC_id,
- // frame,
- // CCCH,
- // 1,
- // mac_sdus,
- // gNB_id,
- // 0);
- LOG_D(MAC,"[UE %d] Frame %d: Requested RRCConnectionRequest, got %d bytes\n", mod_id, frame, size_sdu);
- } else {
- // fill ulsch_buffer with random data
- for (int i = 0; i < TBS_bytes; i++){
- mac_sdus[i] = (unsigned char) (lrand48()&0xff);
- }
- //Sending SDUs with size 1
- //Initialize elements of sdu_lcids and sdu_lengths
- sdu_lcids[0] = lcid;
- sdu_lengths[0] = TBS_bytes - 3 - post_padding - mac_ce_len;
- header_length_total += 2 + (sdu_lengths[0] >= 128);
- size_sdu += sdu_lengths[0];
+ // initialisation by RRC
+
+ // TODO: To be removed after RA procedures fully implemented
+ if(get_softmodem_params()->do_ra) {
+ nr_rrc_ue_generate_RRCSetupRequest(mod_id,gNB_id);
}
+ // CCCH PDU
+ size_sdu = (uint16_t) nr_mac_rrc_data_req_ue(mod_id, CC_id, gNB_id, frame, CCCH, mac_sdus);
+
+ sdu_lengths[0] = size_sdu;
+
+ LOG_I(MAC,"[UE %d] Frame %d: Requested RRCConnectionRequest, got %d bytes\n", mod_id, frame, size_sdu);
+
if (size_sdu > 0) {
+ // UE Contention Resolution Identity
+ // Store the first 48 bits belonging to the uplink CCCH SDU within Msg3 to determine whether or not the
+ // Random Access Procedure has been successful after reception of Msg4
+ memcpy(ra->cont_res_id, mac_sdus, sizeof(uint8_t) * 6);
+
LOG_D(MAC, "[UE %d][%d.%d]: starting initialisation Random Access Procedure...\n", mod_id, frame, nr_slot_tx);
ra->Msg3_size = size_sdu + sizeof(NR_MAC_SUBHEADER_SHORT) + sizeof(NR_MAC_SUBHEADER_SHORT);
@@ -577,10 +583,8 @@ uint8_t nr_ue_get_rach(NR_PRACH_RESOURCES_t *prach_resources,
nr_get_RA_window(mac);
// Fill in preamble and PRACH resources
- if (ra->generate_nr_prach == 1)
- {
+ if (ra->generate_nr_prach == GENERATE_PREAMBLE) {
nr_get_prach_resources(mod_id, CC_id, gNB_id, prach_resources, prach_pdu, rach_ConfigDedicated);
- prach_genarate = 1;
}
offset = nr_generate_ulsch_pdu((uint8_t *) mac_sdus, // sdus buffer
(uint8_t *) payload, // UL MAC pdu pointer
@@ -595,12 +599,27 @@ uint8_t nr_ue_get_rach(NR_PRACH_RESOURCES_t *prach_resources,
post_padding,
0);
+ AssertFatal(TBS_max > offset, "Frequency resources are not enough for Msg3!\n");
+
// Padding: fill remainder with 0
if (post_padding > 0){
- for (int j = 0; j < (TBS_bytes - offset); j++)
- payload[offset + j] = 0; // mac_pdu[offset + j] = 0;
+ for (int j = 0; j < (TBS_max - offset); j++)
+ payload[offset + j] = 0;
}
- }
+ }
+
+ LOG_D(MAC,"size_sdu = %i\n", size_sdu);
+ LOG_D(MAC,"offset = %i\n", offset);
+ for(int k = 0; k < TBS_max; k++) {
+ LOG_D(MAC,"(%i): %i\n", k, prach_resources->Msg3[k]);
+ }
+
+ // Msg3 was initialized with TBS_max bytes because the RA_Msg3_size will only be known after
+ // receiving Msg2 (which contains the Msg3 resource reserve).
+ // Msg3 will be transmitted with RA_Msg3_size bytes, removing unnecessary 0s.
+ mac->ulsch_pdu.Pdu_size = TBS_max;
+ memcpy(mac->ulsch_pdu.payload, prach_resources->Msg3, TBS_max);
+
} else if (ra->RA_window_cnt != -1) { // RACH is active
LOG_D(MAC, "In %s [%d.%d] RA is active: RA window count %d, RA backoff count %d\n", __FUNCTION__, frame, nr_slot_tx, ra->RA_window_cnt, ra->RA_backoff_cnt);
@@ -612,9 +631,13 @@ uint8_t nr_ue_get_rach(NR_PRACH_RESOURCES_t *prach_resources,
}
if (ra->RA_window_cnt >= 0 && ra->RA_RAPID_found == 1) {
- // Reset RA_active flag: it disables Msg3 retransmission (8.3 of TS 38.213)
- nr_ra_succeeded(mod_id, frame, nr_slot_tx);
+ if(ra->cfra) {
+ // Reset RA_active flag: it disables Msg3 retransmission (8.3 of TS 38.213)
+ nr_ra_succeeded(mod_id, frame, nr_slot_tx);
+ } else {
+ ra->generate_nr_prach = GENERATE_IDLE;
+ }
} else if (ra->RA_window_cnt == 0 && !ra->RA_RAPID_found) {
LOG_I(MAC, "[UE %d][%d:%d] RAR reception failed \n", mod_id, frame, nr_slot_tx);
@@ -627,10 +650,8 @@ uint8_t nr_ue_get_rach(NR_PRACH_RESOURCES_t *prach_resources,
// Fill in preamble and PRACH resources
ra->RA_window_cnt--;
- if (ra->generate_nr_prach == 1)
- {
+ if (ra->generate_nr_prach == GENERATE_PREAMBLE) {
nr_get_prach_resources(mod_id, CC_id, gNB_id, prach_resources, prach_pdu, rach_ConfigDedicated);
- prach_genarate = 1;
}
} else if (ra->RA_backoff_cnt > 0) {
@@ -638,9 +659,8 @@ uint8_t nr_ue_get_rach(NR_PRACH_RESOURCES_t *prach_resources,
ra->RA_backoff_cnt--;
- if ((ra->RA_backoff_cnt > 0 && ra->generate_nr_prach == 1) || ra->RA_backoff_cnt == 0){
+ if ((ra->RA_backoff_cnt > 0 && ra->generate_nr_prach == GENERATE_PREAMBLE) || ra->RA_backoff_cnt == 0) {
nr_get_prach_resources(mod_id, CC_id, gNB_id, prach_resources, prach_pdu, rach_ConfigDedicated);
- prach_genarate = 1;
}
}
@@ -651,8 +671,12 @@ uint8_t nr_ue_get_rach(NR_PRACH_RESOURCES_t *prach_resources,
nr_ue_contention_resolution(mod_id, CC_id, frame, nr_slot_tx, prach_resources);
}
- // return ra->generate_nr_prach;
- return prach_genarate;
+ if(ra->generate_nr_prach != GENERATE_IDLE) {
+ return ra->generate_nr_prach;
+ } else {
+ return ra->ra_state;
+ }
+
}
void nr_get_RA_window(NR_UE_MAC_INST_t *mac){
@@ -745,6 +769,7 @@ void nr_ra_succeeded(module_id_t mod_id, frame_t frame, int slot){
LOG_I(MAC, "[UE %d][%d.%d][RAPROC] RA procedure succeeded. CF-RA: RAR successfully received.\n", mod_id, frame, slot);
ra->RA_window_cnt = -1;
+ mac->crnti = ra->t_crnti;
} else {
@@ -752,6 +777,7 @@ void nr_ra_succeeded(module_id_t mod_id, frame_t frame, int slot){
ra->RA_contention_resolution_cnt = -1;
ra->RA_contention_resolution_timer_active = 0;
+ mac->crnti = ra->t_crnti;
ra->t_crnti = 0;
LOG_D(MAC, "In %s: [UE %d][%d.%d] CB-RA: cleared contention resolution timer...\n", __FUNCTION__, mod_id, frame, slot);
@@ -760,7 +786,7 @@ void nr_ra_succeeded(module_id_t mod_id, frame_t frame, int slot){
LOG_D(MAC, "In %s: [UE %d] clearing RA_active flag...\n", __FUNCTION__, mod_id);
ra->RA_active = 0;
- ra->generate_nr_prach = 2;
+ ra->generate_nr_prach = GENERATE_IDLE;
ra->ra_state = RA_SUCCEEDED;
}
@@ -775,8 +801,9 @@ void nr_ra_failed(uint8_t mod_id, uint8_t CC_id, NR_PRACH_RESOURCES_t *prach_res
NR_UE_MAC_INST_t *mac = get_mac_inst(mod_id);
RA_config_t *ra = &mac->ra;
- ra->first_Msg3 = 0;
- ra->generate_nr_prach = 3;
+ ra->first_Msg3 = 1;
+ ra->ra_PreambleIndex = -1;
+ ra->generate_nr_prach = RA_FAILED;
ra->ra_state = RA_UE_IDLE;
prach_resources->RA_PREAMBLE_TRANSMISSION_COUNTER++;
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 11edc6c20d..f3b4acc9bd 100644
--- a/openair2/LAYER2/NR_MAC_UE/nr_ue_dci_configuration.c
+++ b/openair2/LAYER2/NR_MAC_UE/nr_ue_dci_configuration.c
@@ -88,7 +88,11 @@ void config_dci_pdu(NR_UE_MAC_INST_t *mac, fapi_nr_dl_config_dci_dl_pdu_rel15_t
} else {
ss = mac->search_space_zero;
coreset = mac->coreset0;
- rel15->coreset.CoreSetType = NFAPI_NR_CSET_CONFIG_MIB_SIB1;
+ if(rnti_type == NR_RNTI_SI) {
+ rel15->coreset.CoreSetType = NFAPI_NR_CSET_CONFIG_MIB_SIB1;
+ } else {
+ rel15->coreset.CoreSetType = NFAPI_NR_CSET_CONFIG_PDCCH_CONFIG_CSET_0;
+ }
}
rel15->coreset.duration = coreset->duration;
@@ -144,7 +148,7 @@ void config_dci_pdu(NR_UE_MAC_INST_t *mac, fapi_nr_dl_config_dci_dl_pdu_rel15_t
monitoringSymbolsWithinSlot = (ss->monitoringSymbolsWithinSlot->buf[0]<<(sps-8)) | (ss->monitoringSymbolsWithinSlot->buf[1]>>(16-sps));
rel15->rnti = ra->ra_rnti;
rel15->BWPSize = NRRIV2BW(initialDownlinkBWP->genericParameters.locationAndBandwidth, MAX_BWP_SIZE);
- rel15->BWPStart = NRRIV2PRBOFFSET(bwp_Common->genericParameters.locationAndBandwidth, MAX_BWP_SIZE); //NRRIV2PRBOFFSET(initialDownlinkBWP->genericParameters.locationAndBandwidth, 275);
+ rel15->BWPStart = NRRIV2PRBOFFSET(initialDownlinkBWP->genericParameters.locationAndBandwidth, MAX_BWP_SIZE);
rel15->SubcarrierSpacing = initialDownlinkBWP->genericParameters.subcarrierSpacing;
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;
@@ -153,6 +157,14 @@ void config_dci_pdu(NR_UE_MAC_INST_t *mac, fapi_nr_dl_config_dci_dl_pdu_rel15_t
case NR_RNTI_CS:
break;
case NR_RNTI_TC:
+ // we use the initial DL BWP
+ sps = initialDownlinkBWP->genericParameters.cyclicPrefix == NULL ? 14 : 12;
+ monitoringSymbolsWithinSlot = (ss->monitoringSymbolsWithinSlot->buf[0]<<(sps-8)) | (ss->monitoringSymbolsWithinSlot->buf[1]>>(16-sps));
+ rel15->rnti = ra->t_crnti;
+ rel15->BWPSize = NRRIV2BW(initialDownlinkBWP->genericParameters.locationAndBandwidth, MAX_BWP_SIZE);
+ rel15->BWPStart = NRRIV2PRBOFFSET(initialDownlinkBWP->genericParameters.locationAndBandwidth, MAX_BWP_SIZE);
+ rel15->SubcarrierSpacing = initialDownlinkBWP->genericParameters.subcarrierSpacing;
+ rel15->dci_length_options[0] = nr_dci_size(scc, mac->scg, def_dci_pdu_rel15, rel15->dci_format_options[0], NR_RNTI_TC, rel15->BWPSize, bwp_id);
break;
case NR_RNTI_SP_CSI:
break;
@@ -245,14 +257,18 @@ void ue_dci_configuration(NR_UE_MAC_INST_t *mac, fapi_nr_dl_config_request_t *dl
if (ss->searchSpaceId == *pdcch_ConfigCommon->choice.setup->ra_SearchSpace){
switch(ra->ra_state){
case WAIT_RAR:
- LOG_D(MAC, "[DCI_CONFIG] Configure monitoring of PDCCH candidates in Type1-PDCCH common random access search space\n");
- 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;
+ LOG_D(NR_MAC, "[DCI_CONFIG] Configure monitoring of PDCCH candidates in Type1-PDCCH common random access search space (RA-Msg2)\n");
+ 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, -1);
+ fill_dci_search_candidates(ss, rel15);
+ break;
case WAIT_CONTENTION_RESOLUTION:
- LOG_E(MAC, "In %s: CB-RA not implemented yet. Should not have fallen in this case.\n", __FUNCTION__);
+ LOG_D(NR_MAC, "[DCI_CONFIG] Configure monitoring of PDCCH candidates in Type1-PDCCH common random access search space (RA-Msg4)\n");
+ 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_TC, -1);
+ fill_dci_search_candidates(ss, rel15);
break;
default:
break;
diff --git a/openair2/LAYER2/NR_MAC_UE/nr_ue_procedures.c b/openair2/LAYER2/NR_MAC_UE/nr_ue_procedures.c
index 89416266d5..e251cef2ad 100644
--- a/openair2/LAYER2/NR_MAC_UE/nr_ue_procedures.c
+++ b/openair2/LAYER2/NR_MAC_UE/nr_ue_procedures.c
@@ -73,10 +73,10 @@ int get_rnti_type(NR_UE_MAC_INST_t *mac, uint16_t rnti){
if (rnti == ra->ra_rnti) {
rnti_type = NR_RNTI_RA;
+ } else if (rnti == ra->t_crnti && (ra->ra_state == WAIT_RAR || ra->ra_state == WAIT_CONTENTION_RESOLUTION) ) {
+ rnti_type = NR_RNTI_TC;
} else if (rnti == mac->crnti) {
rnti_type = NR_RNTI_C;
- } else if (rnti == ra->t_crnti) {
- rnti_type = NR_RNTI_TC;
} else if (rnti == 0xFFFE) {
rnti_type = NR_RNTI_P;
} else if (rnti == 0xFFFF) {
@@ -105,7 +105,7 @@ int8_t nr_ue_decode_mib(module_id_t module_id,
NR_UE_MAC_INST_t *mac = get_mac_inst(module_id);
- nr_mac_rrc_data_ind_ue( module_id, cc_id, gNB_index, NR_BCCH_BCH, (uint8_t *) pduP, 3 ); // fixed 3 bytes MIB PDU
+ nr_mac_rrc_data_ind_ue( module_id, cc_id, gNB_index, 0, 0, 0, NR_BCCH_BCH, (uint8_t *) pduP, 3 ); // fixed 3 bytes MIB PDU
AssertFatal(mac->mib != NULL, "nr_ue_decode_mib() mac->mib == NULL\n");
//if(mac->mib != NULL){
@@ -154,14 +154,14 @@ int8_t nr_ue_decode_mib(module_id_t module_id,
return 0;
}
-int8_t nr_ue_decode_sib1(module_id_t module_id,
- int cc_id,
- unsigned int gNB_index,
- uint32_t sibs_mask,
- uint8_t *pduP,
- uint32_t pdu_len) {
- LOG_D(MAC, "Decode sib1\n");
- nr_mac_rrc_data_ind_ue(module_id, cc_id, gNB_index, NR_BCCH_DL_SCH, (uint8_t *) pduP, pdu_len);
+int8_t nr_ue_decode_BCCH_DL_SCH(module_id_t module_id,
+ int cc_id,
+ unsigned int gNB_index,
+ uint32_t sibs_mask,
+ uint8_t *pduP,
+ uint32_t pdu_len) {
+ LOG_D(NR_MAC, "Decoding NR-BCCH-DL-SCH-Message (SIB1 or SI)\n");
+ nr_mac_rrc_data_ind_ue(module_id, cc_id, gNB_index, 0, 0, 0, NR_BCCH_DL_SCH, (uint8_t *) pduP, pdu_len);
return 0;
}
@@ -469,7 +469,7 @@ int8_t nr_ue_process_dci(module_id_t module_id, int cc_id, uint8_t gNB_index, fr
AssertFatal(mac->DLbwp[0]!=NULL,"DLbwp[0] should not be zero here!\n");
AssertFatal(mac->ULbwp[0]!=NULL,"DLbwp[0] should not be zero here!\n");
- const uint16_t n_RB_DLBWP = (ra->ra_state == WAIT_RAR) ? NRRIV2BW(mac->scc->downlinkConfigCommon->initialDownlinkBWP->genericParameters.locationAndBandwidth, MAX_BWP_SIZE) : NRRIV2BW(mac->DLbwp[0]->bwp_Common->genericParameters.locationAndBandwidth, MAX_BWP_SIZE);
+ const uint16_t n_RB_DLBWP = (ra->ra_state == WAIT_RAR || ra->ra_state == WAIT_CONTENTION_RESOLUTION) ? NRRIV2BW(mac->scc->downlinkConfigCommon->initialDownlinkBWP->genericParameters.locationAndBandwidth, MAX_BWP_SIZE) : NRRIV2BW(mac->DLbwp[0]->bwp_Common->genericParameters.locationAndBandwidth, MAX_BWP_SIZE);
LOG_D(MAC, "In %s: Processing received DCI format %s (DL BWP %d)\n", __FUNCTION__, dci_formats[dci_format], n_RB_DLBWP);
@@ -515,10 +515,6 @@ int8_t nr_ue_process_dci(module_id_t module_id, int cc_id, uint8_t gNB_index, fr
// Config PUSCH PDU
ret = nr_config_pusch_pdu(mac, pusch_config_pdu, dci, NULL, rnti, &dci_format);
- if (ret != -1 && ra->RA_active && mac->crnti){
- nr_ra_succeeded(module_id, frame, slot);
- }
-
}
break;
@@ -578,10 +574,6 @@ int8_t nr_ue_process_dci(module_id_t module_id, int cc_id, uint8_t gNB_index, fr
// Config PUSCH PDU
ret = nr_config_pusch_pdu(mac, pusch_config_pdu, dci, NULL, rnti, &dci_format);
- if (ret != -1 && ra->RA_active && mac->crnti){
- nr_ra_succeeded(module_id, frame, slot);
- }
-
}
break;
@@ -657,9 +649,19 @@ int8_t nr_ue_process_dci(module_id_t module_id, int cc_id, uint8_t gNB_index, fr
} else {
dl_config->dl_config_list[dl_config->number_pdus].pdu_type = FAPI_NR_DL_CONFIG_TYPE_DLSCH;
}
- dlsch_config_pdu_1_0->BWPSize = NRRIV2BW(mac->DLbwp[0]->bwp_Common->genericParameters.locationAndBandwidth, MAX_BWP_SIZE);
- dlsch_config_pdu_1_0->BWPStart = NRRIV2PRBOFFSET(mac->DLbwp[0]->bwp_Common->genericParameters.locationAndBandwidth, MAX_BWP_SIZE);
- dlsch_config_pdu_1_0->SubcarrierSpacing = mac->DLbwp[0]->bwp_Common->genericParameters.subcarrierSpacing;
+
+ if( (ra->RA_window_cnt >= 0 && rnti == ra->ra_rnti) || (rnti == ra->t_crnti) ) {
+ dlsch_config_pdu_1_0->BWPSize = NRRIV2BW(mac->scc->downlinkConfigCommon->initialDownlinkBWP->genericParameters.locationAndBandwidth, MAX_BWP_SIZE);
+ dlsch_config_pdu_1_0->BWPStart = NRRIV2PRBOFFSET(mac->scc->downlinkConfigCommon->initialDownlinkBWP->genericParameters.locationAndBandwidth, MAX_BWP_SIZE);
+ pdsch_config->dmrs_DownlinkForPDSCH_MappingTypeA->choice.setup->dmrs_AdditionalPosition = NULL;
+ } else {
+ dlsch_config_pdu_1_0->BWPSize = NRRIV2BW(mac->DLbwp[0]->bwp_Common->genericParameters.locationAndBandwidth, MAX_BWP_SIZE);
+ dlsch_config_pdu_1_0->BWPStart = NRRIV2PRBOFFSET(mac->DLbwp[0]->bwp_Common->genericParameters.locationAndBandwidth, MAX_BWP_SIZE);
+ dlsch_config_pdu_1_0->SubcarrierSpacing = mac->DLbwp[0]->bwp_Common->genericParameters.subcarrierSpacing;
+ if(pdsch_config->dmrs_DownlinkForPDSCH_MappingTypeA->choice.setup->dmrs_AdditionalPosition == NULL)
+ pdsch_config->dmrs_DownlinkForPDSCH_MappingTypeA->choice.setup->dmrs_AdditionalPosition=calloc(1,sizeof(*pdsch_config->dmrs_DownlinkForPDSCH_MappingTypeA->choice.setup->dmrs_AdditionalPosition));
+ }
+
BWPSize = n_RB_DLBWP;
}
@@ -677,7 +679,8 @@ int8_t nr_ue_process_dci(module_id_t module_id, int cc_id, uint8_t gNB_index, fr
/* dmrs symbol positions*/
dlsch_config_pdu_1_0->dlDmrsSymbPos = fill_dmrs_mask(pdsch_config,
mac->scc->dmrs_TypeA_Position,
- dlsch_config_pdu_1_0->start_symbol+dlsch_config_pdu_1_0->number_symbols);
+ dlsch_config_pdu_1_0->number_symbols,
+ dlsch_config_pdu_1_0->start_symbol);
dlsch_config_pdu_1_0->dmrsConfigType = mac->DLbwp[0]->bwp_Dedicated->pdsch_Config->choice.setup->dmrs_DownlinkForPDSCH_MappingTypeA->choice.setup->dmrs_Type == NULL ? 0 : 1;
/* number of DM-RS CDM groups without data according to subclause 5.1.6.2 of 3GPP TS 38.214 version 15.9.0 Release 15 */
if (dlsch_config_pdu_1_0->number_symbols == 2)
@@ -770,6 +773,7 @@ int8_t nr_ue_process_dci(module_id_t module_id, int cc_id, uint8_t gNB_index, fr
LOG_D(MAC,"(nr_ue_procedures.c) pdu_type=%d\n\n",dl_config->dl_config_list[dl_config->number_pdus].pdu_type);
dl_config->number_pdus = dl_config->number_pdus + 1;
+
break;
}
@@ -814,7 +818,17 @@ int8_t nr_ue_process_dci(module_id_t module_id, int cc_id, uint8_t gNB_index, fr
dl_config->dl_config_list[dl_config->number_pdus].pdu_type = FAPI_NR_DL_CONFIG_TYPE_DLSCH;
dl_config->dl_config_list[dl_config->number_pdus].dlsch_config_pdu.rnti = rnti;
+
+ // FIXME: fix number of additional dmrs
+ if(pdsch_config->dmrs_DownlinkForPDSCH_MappingTypeA->choice.setup->dmrs_AdditionalPosition == NULL)
+ pdsch_config->dmrs_DownlinkForPDSCH_MappingTypeA->choice.setup->dmrs_AdditionalPosition=calloc(1,sizeof(*pdsch_config->dmrs_DownlinkForPDSCH_MappingTypeA->choice.setup->dmrs_AdditionalPosition));
+
fapi_nr_dl_config_dlsch_pdu_rel15_t *dlsch_config_pdu_1_1 = &dl_config->dl_config_list[dl_config->number_pdus].dlsch_config_pdu.dlsch_config_rel15;
+
+ dlsch_config_pdu_1_1->BWPSize = NRRIV2BW(mac->DLbwp[0]->bwp_Common->genericParameters.locationAndBandwidth, MAX_BWP_SIZE);
+ dlsch_config_pdu_1_1->BWPStart = NRRIV2PRBOFFSET(mac->DLbwp[0]->bwp_Common->genericParameters.locationAndBandwidth, MAX_BWP_SIZE);
+ dlsch_config_pdu_1_1->SubcarrierSpacing = mac->DLbwp[0]->bwp_Common->genericParameters.subcarrierSpacing;
+
/* IDENTIFIER_DCI_FORMATS */
/* CARRIER_IND */
/* BANDWIDTH_PART_IND */
@@ -832,7 +846,8 @@ int8_t nr_ue_process_dci(module_id_t module_id, int cc_id, uint8_t gNB_index, fr
/* dmrs symbol positions*/
dlsch_config_pdu_1_1->dlDmrsSymbPos = fill_dmrs_mask(pdsch_config,
mac->scc->dmrs_TypeA_Position,
- dlsch_config_pdu_1_1->number_symbols);
+ dlsch_config_pdu_1_1->number_symbols,
+ dlsch_config_pdu_1_1->start_symbol);
dlsch_config_pdu_1_1->dmrsConfigType = mac->DLbwp[dl_bwp_id-1]->bwp_Dedicated->pdsch_Config->choice.setup->dmrs_DownlinkForPDSCH_MappingTypeA->choice.setup->dmrs_Type == NULL ? 0 : 1;
/* TODO: fix number of DM-RS CDM groups without data according to subclause 5.1.6.2 of 3GPP TS 38.214,
using tables 7.3.1.2.2-1, 7.3.1.2.2-2, 7.3.1.2.2-3, 7.3.1.2.2-4 of 3GPP TS 38.212 */
@@ -1382,39 +1397,71 @@ uint8_t nr_extract_dci_info(NR_UE_MAC_INST_t *mac,
break;
case NR_RNTI_TC:
- // indicating a DL DCI format 1bit
+
+ // indicating a DL DCI format - 1 bit
pos++;
dci_pdu_rel15->format_indicator = (*dci_pdu>>(dci_size-pos))&1;
+
// Freq domain assignment 0-16 bit
fsize = (int)ceil( log2( (N_RB*(N_RB+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;
- // VRB to PRB mapping 1 bit
+
+ // VRB to PRB mapping - 1 bit
+ pos++;
dci_pdu_rel15->vrb_to_prb_mapping.val = (*dci_pdu>>(dci_size-pos))&1;
+
// MCS 5bit //bit over 32, so dci_pdu ++
pos+=5;
dci_pdu_rel15->mcs = (*dci_pdu>>(dci_size-pos))&0x1f;
- // New data indicator 1bit
+
+ // New data indicator - 1 bit
+ pos++;
dci_pdu_rel15->ndi = (*dci_pdu>>(dci_size-pos))&1;
- // Redundancy version 2bit
+
+ // Redundancy version - 2 bits
pos+=2;
dci_pdu_rel15->rv = (*dci_pdu>>(dci_size-pos))&3;
- // HARQ process number 4bit
+
+ // HARQ process number - 4 bits
pos+=4;
dci_pdu_rel15->harq_pid = (*dci_pdu>>(dci_size-pos))&0xf;
- // Downlink assignment index E2 bits
+
+ // Downlink assignment index - 2 bits
pos+=2;
dci_pdu_rel15->dai[0].val = (*dci_pdu>>(dci_size-pos))&3;
- // TPC command for scheduled PUCCH E2 bits
+
+ // TPC command for scheduled PUCCH - 2 bits
pos+=2;
dci_pdu_rel15->tpc = (*dci_pdu>>(dci_size-pos))&3;
- // PDSCH-to-HARQ_feedback timing indicator E3 bits
+
+ // PUCCH resource indicator - 3 bits
+ pos+=3;
+ dci_pdu_rel15->pucch_resource_indicator = (*dci_pdu>>(dci_size-pos))&7;
+
+ // PDSCH-to-HARQ_feedback timing indicator - 3 bits
pos+=3;
dci_pdu_rel15->pdsch_to_harq_feedback_timing_indicator.val = (*dci_pdu>>(dci_size-pos))&7;
-
+
+ LOG_D(NR_MAC,"N_RB = %i\n", N_RB);
+ LOG_D(NR_MAC,"dci_size = %i\n", dci_size);
+ LOG_D(NR_MAC,"fsize = %i\n", fsize);
+ LOG_D(NR_MAC,"dci_pdu_rel15->format_indicator = %i\n", dci_pdu_rel15->format_indicator);
+ LOG_D(NR_MAC,"dci_pdu_rel15->frequency_domain_assignment.val = %i\n", dci_pdu_rel15->frequency_domain_assignment.val);
+ LOG_D(NR_MAC,"dci_pdu_rel15->time_domain_assignment.val = %i\n", dci_pdu_rel15->time_domain_assignment.val);
+ LOG_D(NR_MAC,"dci_pdu_rel15->vrb_to_prb_mapping.val = %i\n", dci_pdu_rel15->vrb_to_prb_mapping.val);
+ LOG_D(NR_MAC,"dci_pdu_rel15->mcs = %i\n", dci_pdu_rel15->mcs);
+ LOG_D(NR_MAC,"dci_pdu_rel15->rv = %i\n", dci_pdu_rel15->rv);
+ LOG_D(NR_MAC,"dci_pdu_rel15->harq_pid = %i\n", dci_pdu_rel15->harq_pid);
+ LOG_D(NR_MAC,"dci_pdu_rel15->dai[0].val = %i\n", dci_pdu_rel15->dai[0].val);
+ LOG_D(NR_MAC,"dci_pdu_rel15->tpc = %i\n", dci_pdu_rel15->tpc);
+ LOG_D(NR_MAC,"dci_pdu_rel15->pucch_resource_indicator = %i\n", dci_pdu_rel15->pucch_resource_indicator);
+ LOG_D(NR_MAC,"dci_pdu_rel15->pdsch_to_harq_feedback_timing_indicator.val = %i\n", dci_pdu_rel15->pdsch_to_harq_feedback_timing_indicator.val);
+
break;
}
break;
@@ -1736,7 +1783,7 @@ void nr_ue_process_mac_pdu(nr_downlink_indication_t *dl_info,
frame_t frameP = dl_info->frame;
int slot = dl_info->slot;
uint8_t *pduP = (dl_info->rx_ind->rx_indication_body + pdu_id)->pdsch_pdu.pdu;
- uint16_t pdu_len = (dl_info->rx_ind->rx_indication_body + pdu_id)->pdsch_pdu.pdu_length;
+ int16_t pdu_len = (int16_t)(dl_info->rx_ind->rx_indication_body + pdu_id)->pdsch_pdu.pdu_length;
uint8_t gNB_index = dl_info->gNB_index;
uint8_t CC_id = dl_info->cc_id;
uint8_t done = 0;
@@ -1754,25 +1801,39 @@ void nr_ue_process_mac_pdu(nr_downlink_indication_t *dl_info,
mac_subheader_len = 0x0001; // default to fixed-length subheader = 1-oct
mac_sdu_len = 0x0000;
rx_lcid = ((NR_MAC_SUBHEADER_FIXED *)pduP)->LCID;
- //#ifdef DEBUG_HEADER_PARSING
- LOG_D(MAC, "[UE] LCID %d, PDU length %d\n", ((NR_MAC_SUBHEADER_FIXED *)pduP)->LCID, pdu_len);
- //#endif
LOG_D(MAC, "[UE] LCID %d, PDU length %d\n", rx_lcid, pdu_len);
switch(rx_lcid){
// MAC CE
case DL_SCH_LCID_CCCH:
- // MSG4 RRC Connection Setup 38.331
- // varialbe length
- mac_ce_len |= (uint16_t)((NR_MAC_SUBHEADER_SHORT *)pduP)->L;
+ // MSG4 RRC Connection Setup 38.331
+ // variable length
+
+ if(((NR_MAC_SUBHEADER_SHORT *)pduP)->F){
+ mac_sdu_len = ((uint16_t)(((NR_MAC_SUBHEADER_LONG *) pduP)->L1 & 0x7f) << 8)
+ | ((uint16_t)((NR_MAC_SUBHEADER_LONG *) pduP)->L2 & 0xff);
+ mac_subheader_len = 3;
+ } else {
+ mac_sdu_len = ((NR_MAC_SUBHEADER_LONG *) pduP)->L1;
mac_subheader_len = 2;
- if(((NR_MAC_SUBHEADER_SHORT *)pduP)->F){
- mac_ce_len |= (uint16_t)(((NR_MAC_SUBHEADER_LONG *)pduP)->L2)<<8;
- mac_subheader_len = 3;
+ }
+
+ if ( mac_sdu_len > 0) {
+
+ LOG_D(NR_MAC,"DL_SCH_LCID_CCCH with payload len %d\n", mac_sdu_len);
+
+ LOG_D(NR_MAC,"RRCSetup received at nr_ue_process_mac_pdu with payload len %d \n", mac_sdu_len);
+ for (int i = 0; i < mac_subheader_len; i++) {
+ LOG_D(NR_MAC, "MAC header %d: 0x%x\n", i, pduP[i]);
+ }
+ for (int i = 0; i < mac_sdu_len; i++) {
+ LOG_D(NR_MAC, "%d: 0x%x\n", i, pduP[mac_subheader_len + i]);
}
- break;
+ nr_mac_rrc_data_ind_ue(module_idP, CC_id, gNB_index, frameP, 0, mac->crnti, CCCH, pduP+mac_subheader_len, mac_sdu_len);
+ }
+ break;
case DL_SCH_LCID_TCI_STATE_ACT_UE_SPEC_PDSCH:
@@ -1879,17 +1940,34 @@ void nr_ue_process_mac_pdu(nr_downlink_indication_t *dl_info,
break;
case DL_SCH_LCID_CON_RES_ID:
- // Clause 5.1.5 and 6.1.3.3 of 3GPP TS 38.321 version 16.2.1 Release 16
- // WIP todo: handle CCCH_pdu
- mac_ce_len = 6;
-
- LOG_I(MAC, "[UE %d][RAPROC] Frame %d : received contention resolution msg: %x.%x.%x.%x.%x.%x, Terminating RA procedure\n", module_idP, frameP, pduP[0], pduP[1], pduP[2], pduP[3], pduP[4], pduP[5]);
+ // Clause 5.1.5 and 6.1.3.3 of 3GPP TS 38.321 version 16.2.1 Release 16
+ // MAC Header: 1 byte (R/R/LCID)
+ // MAC SDU: 6 bytes (UE Contention Resolution Identity)
+ mac_ce_len = 6;
- if (ra->RA_active == 1) {
- nr_ra_succeeded(module_idP, frameP, slot);
+ if(ra->ra_state == WAIT_CONTENTION_RESOLUTION) {
+ LOG_I(MAC, "[UE %d][RAPROC] Frame %d : received contention resolution identity: 0x%02x%02x%02x%02x%02x%02x Terminating RA procedure\n",
+ module_idP, frameP, pduP[1], pduP[2], pduP[3], pduP[4], pduP[5], pduP[6]);
+
+ bool ra_success = true;
+ for(int i = 0; icont_res_id[i] != pduP[i+1]) {
+ ra_success = false;
+ break;
+ }
}
- break;
+ if ( (ra->RA_active == 1) && ra_success) {
+ nr_ra_succeeded(module_idP, frameP, slot);
+ } else if (!ra_success){
+ // TODO: Handle failure of RA procedure @ MAC layer
+ // nr_ra_failed(module_idP, CC_id, prach_resources, frameP, slot); // prach_resources is a PHY structure
+ ra->ra_state = RA_UE_IDLE;
+ ra->RA_active = 0;
+ }
+ }
+
+ break;
case DL_SCH_LCID_PADDING:
done = 1;
// end of MAC PDU, can ignore the rest.
@@ -2007,8 +2085,9 @@ uint16_t nr_generate_ulsch_pdu(uint8_t *sdus_payload,
last_size = 3;
}
} else { // UL CCCH SDU
- mac_pdu_ptr->R = 0;
- mac_pdu_ptr->LCID = sdu_lcids[i];
+ ((NR_MAC_SUBHEADER_FIXED *) mac_pdu_ptr)->R = 0;
+ ((NR_MAC_SUBHEADER_FIXED *) mac_pdu_ptr)->LCID = sdu_lcids[i];
+ last_size = 1;
}
mac_pdu_ptr += last_size;
@@ -2184,27 +2263,32 @@ int nr_ue_process_rar(nr_downlink_indication_t *dl_info, NR_UL_TIME_ALIGNMENT_t
NR_MAC_RAR *rar = (NR_MAC_RAR *) (dlsch_buffer + 1); // RAR subPDU pointer
uint8_t preamble_index = get_ra_PreambleIndex(mod_id, cc_id, gNB_id); //prach_resources->ra_PreambleIndex;
- LOG_D(MAC, "In %s:[%d.%d]: [UE %d][RAPROC] invoking MAC for received RAR (current preamble %d)\n", __FUNCTION__, frame, slot, mod_id, preamble_index);
+ LOG_D(NR_MAC, "In %s:[%d.%d]: [UE %d][RAPROC] invoking MAC for received RAR (current preamble %d)\n", __FUNCTION__, frame, slot, mod_id, preamble_index);
while (1) {
n_subheaders++;
if (rarh->T == 1) {
n_subPDUs++;
- LOG_D(MAC, "[UE %d][RAPROC] Got RAPID RAR subPDU\n", mod_id);
+ LOG_I(NR_MAC, "[UE %d][RAPROC] Got RAPID RAR subPDU\n", mod_id);
} else {
- n_subPDUs++;
ra->RA_backoff_indicator = table_7_2_1[((NR_RA_HEADER_BI *)rarh)->BI];
ra->RA_BI_found = 1;
- LOG_D(MAC, "[UE %d][RAPROC] Got BI RAR subPDU %d\n", mod_id, ra->RA_backoff_indicator);
+ LOG_I(NR_MAC, "[UE %d][RAPROC] Got BI RAR subPDU %d ms\n", mod_id, ra->RA_backoff_indicator);
+ if ( ((NR_RA_HEADER_BI *)rarh)->E == 1) {
+ rarh += sizeof(NR_RA_HEADER_BI);
+ continue;
+ } else {
+ break;
+ }
}
if (rarh->RAPID == preamble_index) {
- LOG_I(MAC, "[UE %d][RAPROC][%d.%d] Found RAR with the intended RAPID %d\n", mod_id, frame, slot, rarh->RAPID);
+ LOG_I(NR_MAC, "[UE %d][RAPROC][%d.%d] Found RAR with the intended RAPID %d\n", mod_id, frame, slot, rarh->RAPID);
rar = (NR_MAC_RAR *) (dlsch_buffer + n_subheaders + (n_subPDUs - 1) * sizeof(NR_MAC_RAR));
ra->RA_RAPID_found = 1;
break;
}
if (rarh->E == 0) {
- LOG_W(PHY,"[UE %d][RAPROC] Received RAR preamble (%d) doesn't match the intended RAPID...\n", mod_id, preamble_index);
+ LOG_W(NR_MAC,"[UE %d][RAPROC][%d.%d] Received RAR preamble (%d) doesn't match the intended RAPID (%d)\n", mod_id, frame, slot, rarh->RAPID, preamble_index);
break;
} else {
rarh += sizeof(NR_MAC_RAR) + 1;
@@ -2280,8 +2364,26 @@ int nr_ue_process_rar(nr_downlink_indication_t *dl_info, NR_UL_TIME_ALIGNMENT_t
rnti = mac->crnti;
}
- #ifdef DEBUG_RAR
- LOG_D(MAC, "In %s:[%d.%d]: [UE %d] 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",
+ // FIXME: To be removed
+ LOG_I(NR_MAC, "rarh->E = 0x%x\n", rarh->E);
+ LOG_I(NR_MAC, "rarh->T = 0x%x\n", rarh->T);
+ LOG_I(NR_MAC, "rarh->RAPID = 0x%x (%i)\n", rarh->RAPID, rarh->RAPID);
+
+ LOG_I(NR_MAC, "rar->R = 0x%x\n", rar->R);
+ LOG_I(NR_MAC, "rar->TA1 = 0x%x\n", rar->TA1);
+
+ LOG_I(NR_MAC, "rar->TA2 = 0x%x\n", rar->TA2);
+ LOG_I(NR_MAC, "rar->UL_GRANT_1 = 0x%x\n", rar->UL_GRANT_1);
+
+ LOG_I(NR_MAC, "rar->UL_GRANT_2 = 0x%x\n", rar->UL_GRANT_2);
+ LOG_I(NR_MAC, "rar->UL_GRANT_3 = 0x%x\n", rar->UL_GRANT_3);
+ LOG_I(NR_MAC, "rar->UL_GRANT_4 = 0x%x\n", rar->UL_GRANT_4);
+
+ LOG_I(NR_MAC, "rar->TCRNTI_1 = 0x%x\n", rar->TCRNTI_1);
+ LOG_I(NR_MAC, "rar->TCRNTI_2 = 0x%x\n", rar->TCRNTI_2);
+
+ //#ifdef DEBUG_RAR
+ LOG_I(NR_MAC, "In %s:[%d.%d]: [UE %d] Received RAR with t_alloc %d f_alloc %d ta_command %d mcs %d freq_hopping %d tpc_command %d t_crnti %x \n",
__FUNCTION__,
frame,
slot,
@@ -2292,9 +2394,8 @@ int nr_ue_process_rar(nr_downlink_indication_t *dl_info, NR_UL_TIME_ALIGNMENT_t
rar_grant.mcs,
rar_grant.freq_hopping,
tpc_command,
- csi_req,
ra->t_crnti);
- #endif
+ //#endif
// Schedule Msg3
ret = nr_ue_pusch_scheduler(mac, is_Msg3, frame, slot, &frame_tx, &slot_tx, rar_grant.Msg3_t_alloc);
diff --git a/openair2/LAYER2/NR_MAC_UE/nr_ue_scheduler.c b/openair2/LAYER2/NR_MAC_UE/nr_ue_scheduler.c
index d6e1cba6df..0c2504149c 100644
--- a/openair2/LAYER2/NR_MAC_UE/nr_ue_scheduler.c
+++ b/openair2/LAYER2/NR_MAC_UE/nr_ue_scheduler.c
@@ -495,11 +495,13 @@ int nr_config_pusch_pdu(NR_UE_MAC_INST_t *mac,
int ibwp_size = NRRIV2BW(scc->uplinkConfigCommon->initialUplinkBWP->genericParameters.locationAndBandwidth, MAX_BWP_SIZE);
// 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))
+ if ((ibwp_start < abwp_start) || (ibwp_size > abwp_size)) {
pusch_config_pdu->bwp_start = abwp_start;
- else
+ pusch_config_pdu->bwp_size = abwp_size;
+ } else {
pusch_config_pdu->bwp_start = ibwp_start;
+ pusch_config_pdu->bwp_size = ibwp_size;
+ }
//// Resource assignment from RAR
// Frequency domain allocation according to 8.3 of TS 38.213
@@ -513,7 +515,7 @@ int nr_config_pusch_pdu(NR_UE_MAC_INST_t *mac,
return -1;
// 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;
+ //pusch_config_pdu->rb_start += ibwp_start - abwp_start;
// Time domain allocation
SLIV2SL(startSymbolAndLength, &StartSymbolIndex, &NrOfSymbols);
@@ -889,34 +891,41 @@ NR_UE_L2_STATE_t nr_ue_scheduler(nr_downlink_indication_t *dl_info, nr_uplink_in
uint16_t TBS_bytes = ulcfg_pdu->pusch_config_pdu.pusch_data.tb_size;
- // Push data from MAC to PHY only when NDI toggles
- if (IS_SOFTMODEM_NOS1 && (mac->UL_ndi[ulcfg_pdu->pusch_config_pdu.pusch_data.harq_process_id] != ulcfg_pdu->pusch_config_pdu.pusch_data.new_data_indicator)){
- // 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);
- }
+ if (ra->ra_state == WAIT_RAR){
+ memcpy(ulsch_input_buffer, mac->ulsch_pdu.payload, TBS_bytes);
+ LOG_D(NR_MAC,"[RAPROC] Msg3 to be transmitted:\n");
+ for (int k = 0; k < TBS_bytes; k++) {
+ LOG_D(NR_MAC,"(%i): 0x%x\n",k,mac->ulsch_pdu.payload[k]);
+ }
+ LOG_I(NR_MAC,"[RAPROC] RA-Msg3 transmitted\n");
+ } else {
+ if (IS_SOFTMODEM_NOS1 && (mac->UL_ndi[ulcfg_pdu->pusch_config_pdu.pusch_data.harq_process_id] != ulcfg_pdu->pusch_config_pdu.pusch_data.new_data_indicator)){
+ // 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);
+ }
- mac->UL_ndi[ulcfg_pdu->pusch_config_pdu.pusch_data.harq_process_id] = ulcfg_pdu->pusch_config_pdu.pusch_data.new_data_indicator;
- //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(PHY, "In %s: Random data to be transmitted: TBS_bytes %d \n", __FUNCTION__, TBS_bytes);
+ mac->UL_ndi[ulcfg_pdu->pusch_config_pdu.pusch_data.harq_process_id] = ulcfg_pdu->pusch_config_pdu.pusch_data.new_data_indicator;
+ //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(PHY, "In %s: Random data to be transmitted: TBS_bytes %d \n", __FUNCTION__, 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;
+ //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]);
+ for (int i = 1; i < TBS_bytes; i++) {
+ ulsch_input_buffer[i] = (unsigned char) rand();
+ }
}
}
@@ -1660,7 +1669,7 @@ void nr_ue_prach_scheduler(module_id_t module_idP, frame_t frameP, sub_frame_t s
NR_RACH_ConfigGeneric_t *rach_ConfigGeneric = &setup->rach_ConfigGeneric;
ra->RA_offset = 2; // to compensate the rx frame offset at the gNB
- ra->generate_nr_prach = 0; // Reset flag for PRACH generation
+ ra->generate_nr_prach = GENERATE_IDLE; // Reset flag for PRACH generation
if (is_nr_UL_slot(scc, slotP)) {
@@ -1677,7 +1686,7 @@ void nr_ue_prach_scheduler(module_id_t module_idP, frame_t frameP, sub_frame_t s
if (is_nr_prach_slot && ra->ra_state == RA_UE_IDLE) {
AssertFatal(NULL != prach_occasion_info_p,"PRACH Occasion Info not returned in a valid NR Prach Slot\n");
- ra->generate_nr_prach = 1;
+ ra->generate_nr_prach = GENERATE_PREAMBLE;
format = prach_occasion_info_p->format;
format0 = format & 0xff; // single PRACH format
diff --git a/openair2/LAYER2/NR_MAC_gNB/config.c b/openair2/LAYER2/NR_MAC_gNB/config.c
index bce0719556..41317f8bbc 100644
--- a/openair2/LAYER2/NR_MAC_gNB/config.c
+++ b/openair2/LAYER2/NR_MAC_gNB/config.c
@@ -433,6 +433,13 @@ int rrc_mac_config_req_gNB(module_id_t Mod_idP,
}
}
}
+ } else {
+ ra->cfra = false;
+ ra->rnti = rnti;
+ ra->preambles.num_preambles = MAX_NUM_NR_PRACH_PREAMBLES;
+ ra->preambles.preamble_list = (uint8_t *) malloc(MAX_NUM_NR_PRACH_PREAMBLES*sizeof(uint8_t));
+ for (int i = 0; i < MAX_NUM_NR_PRACH_PREAMBLES; i++)
+ ra->preambles.preamble_list[i] = i;
}
LOG_I(PHY,"Added new RA process for UE RNTI %04x with initial secondaryCellGroup\n", rnti);
} else { // secondaryCellGroup has been updated
diff --git a/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_RA.c b/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_RA.c
index ac3a4e77d2..da7f4c660c 100644
--- a/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_RA.c
+++ b/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_RA.c
@@ -65,7 +65,7 @@ int16_t ssb_index_from_prach(module_id_t module_idP,
uint8_t config_index = scc->uplinkConfigCommon->initialUplinkBWP->rach_ConfigCommon->choice.setup->rach_ConfigGeneric.prach_ConfigurationIndex;
uint8_t fdm = cfg->prach_config.num_prach_fd_occasions.value;
- uint8_t total_RApreambles = 64;
+ uint8_t total_RApreambles = MAX_NUM_NR_PRACH_PREAMBLES;
if( scc->uplinkConfigCommon->initialUplinkBWP->rach_ConfigCommon->choice.setup->totalNumberOfRA_Preambles != NULL)
total_RApreambles = *scc->uplinkConfigCommon->initialUplinkBWP->rach_ConfigCommon->choice.setup->totalNumberOfRA_Preambles;
@@ -475,13 +475,13 @@ void nr_initiate_ra_proc(module_id_t module_idP,
NR_COMMON_channels_t *cc = &nr_mac->common_channels[CC_id];
NR_ServingCellConfigCommon_t *scc = cc->ServingCellConfigCommon;
- uint8_t total_RApreambles = 64;
- uint8_t num_ssb_per_RO = scc->uplinkConfigCommon->initialUplinkBWP->rach_ConfigCommon->choice.setup->ssb_perRACH_OccasionAndCB_PreamblesPerSSB->present;
+ uint8_t total_RApreambles = MAX_NUM_NR_PRACH_PREAMBLES;
+ uint8_t num_ssb_per_RO = scc->uplinkConfigCommon->initialUplinkBWP->rach_ConfigCommon->choice.setup->ssb_perRACH_OccasionAndCB_PreamblesPerSSB->present;
int pr_found;
if( scc->uplinkConfigCommon->initialUplinkBWP->rach_ConfigCommon->choice.setup->totalNumberOfRA_Preambles != NULL)
- total_RApreambles = *scc->uplinkConfigCommon->initialUplinkBWP->rach_ConfigCommon->choice.setup->totalNumberOfRA_Preambles;
-
+ total_RApreambles = *scc->uplinkConfigCommon->initialUplinkBWP->rach_ConfigCommon->choice.setup->totalNumberOfRA_Preambles;
+
if(num_ssb_per_RO > 3) { /*num of ssb per RO >= 1*/
num_ssb_per_RO -= 3;
total_RApreambles = total_RApreambles/num_ssb_per_RO ;
@@ -520,7 +520,7 @@ void nr_initiate_ra_proc(module_id_t module_idP,
VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_INITIATE_RA_PROC, 1);
- LOG_I(MAC,
+ LOG_D(MAC,
"[gNB %d][RAPROC] CC_id %d Frame %d, Slot %d Initiating RA procedure for preamble index %d\n",
module_idP,
CC_id,
@@ -542,7 +542,6 @@ void nr_initiate_ra_proc(module_id_t module_idP,
continue; // if the PRACH preamble does not correspond to any of the ones sent through RRC abort RA proc
}
}
- int loop = 0;
LOG_D(MAC, "Frame %d, Slot %d: Activating RA process \n", frameP, slotP);
ra->state = Msg2;
ra->timing_offset = timing_offset;
@@ -574,7 +573,11 @@ void nr_initiate_ra_proc(module_id_t module_idP,
ra->Msg2_frame = msg2_frame;
ra->Msg2_slot = msg2_slot;
- LOG_I(MAC, "%s() Msg2[%04d%d] SFN/SF:%04d%d\n", __FUNCTION__, ra->Msg2_frame, ra->Msg2_slot, frameP, slotP);
+ LOG_D(MAC, "%s() Msg2[%04d%d] SFN/SF:%04d%d\n", __FUNCTION__, ra->Msg2_frame, ra->Msg2_slot, frameP, slotP);
+
+ // TODO: Configure RRC with the new RNTI of the following commented lines
+ /*
+ int loop = 0;
if (!ra->cfra) {
do {
ra->rnti = (taus() % 65518) + 1;
@@ -587,11 +590,13 @@ void nr_initiate_ra_proc(module_id_t module_idP,
abort();
}
}
+ */
+
ra->RA_rnti = ra_rnti;
ra->preamble_index = preamble_index;
ra->beam_id = beam_index;
- LOG_I(MAC,
+ LOG_D(MAC,
"[gNB %d][RAPROC] CC_id %d Frame %d Activating Msg2 generation in frame %d, slot %d using RA rnti %x SSB "
"index %u\n",
module_idP,
@@ -610,88 +615,90 @@ void nr_initiate_ra_proc(module_id_t module_idP,
VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_INITIATE_RA_PROC, 0);
}
-void nr_schedule_RA(module_id_t module_idP, frame_t frameP, sub_frame_t slotP)
-{
- gNB_MAC_INST *mac = RC.nrmac[module_idP];
+ void nr_schedule_RA(module_id_t module_idP, frame_t frameP, sub_frame_t slotP)
+ {
+ gNB_MAC_INST *mac = RC.nrmac[module_idP];
- start_meas(&mac->schedule_ra);
- for (int CC_id = 0; CC_id < MAX_NUM_CCs; CC_id++) {
- NR_COMMON_channels_t *cc = &mac->common_channels[CC_id];
- for (int i = 0; i < NR_NB_RA_PROC_MAX; i++) {
- NR_RA_t *ra = &cc->ra[i];
- LOG_D(MAC, "RA[state:%d]\n", ra->state);
- switch (ra->state) {
- case Msg2:
- nr_generate_Msg2(module_idP, CC_id, frameP, slotP, ra);
- break;
- case Msg4:
- // generate_Msg4(module_idP, CC_id, frameP, slotP);
- break;
- case WAIT_Msg4_ACK:
- // check_Msg4_retransmission(module_idP, CC_id, frameP, slotP);
- break;
- default:
- break;
+ start_meas(&mac->schedule_ra);
+ for (int CC_id = 0; CC_id < MAX_NUM_CCs; CC_id++) {
+ NR_COMMON_channels_t *cc = &mac->common_channels[CC_id];
+ for (int i = 0; i < NR_NB_RA_PROC_MAX; i++) {
+ NR_RA_t *ra = &cc->ra[i];
+ LOG_D(NR_MAC, "RA[state:%d]\n", ra->state);
+ switch (ra->state) {
+ case Msg2:
+ nr_generate_Msg2(module_idP, CC_id, frameP, slotP, ra);
+ break;
+ case Msg4:
+ nr_generate_Msg4(module_idP, CC_id, frameP, slotP, ra);
+ break;
+ case WAIT_Msg4_ACK:
+ nr_check_Msg4_Ack(module_idP, CC_id, frameP, slotP, ra);
+ break;
+ default:
+ break;
+ }
}
}
+ stop_meas(&mac->schedule_ra);
}
- stop_meas(&mac->schedule_ra);
-}
-void nr_get_Msg3alloc(module_id_t module_id,
- int CC_id,
- NR_ServingCellConfigCommon_t *scc,
- NR_BWP_Uplink_t *ubwp,
- sub_frame_t current_slot,
- frame_t current_frame,
- NR_RA_t *ra) {
+ void nr_get_Msg3alloc(module_id_t module_id,
+ int CC_id,
+ NR_ServingCellConfigCommon_t *scc,
+ NR_BWP_Uplink_t *ubwp,
+ sub_frame_t current_slot,
+ frame_t current_frame,
+ NR_RA_t *ra) {
- // msg3 is schedulend in mixed slot in the following TDD period
- // for now we consider a TBS of 18 bytes
+ // msg3 is schedulend in mixed slot in the following TDD period
- int mu = ubwp->bwp_Common->genericParameters.subcarrierSpacing;
- int StartSymbolIndex, NrOfSymbols, startSymbolAndLength, temp_slot;
- ra->Msg3_tda_id = 16; // initialization to a value above limit
+ uint16_t msg3_nb_rb = 8 + sizeof(NR_MAC_SUBHEADER_SHORT) + sizeof(NR_MAC_SUBHEADER_SHORT); // sdu has 6 or 8 bytes
- for (int i=0; ibwp_Common->pusch_ConfigCommon->choice.setup->pusch_TimeDomainAllocationList->list.count; i++) {
- startSymbolAndLength = ubwp->bwp_Common->pusch_ConfigCommon->choice.setup->pusch_TimeDomainAllocationList->list.array[i]->startSymbolAndLength;
- SLIV2SL(startSymbolAndLength, &StartSymbolIndex, &NrOfSymbols);
- // we want to transmit in the uplink symbols of mixed slot
- if (NrOfSymbols == scc->tdd_UL_DL_ConfigurationCommon->pattern1.nrofUplinkSymbols) {
- ra->Msg3_tda_id = i;
- break;
+ int mu = ubwp->bwp_Common->genericParameters.subcarrierSpacing;
+ int StartSymbolIndex, NrOfSymbols, startSymbolAndLength, temp_slot;
+ ra->Msg3_tda_id = 16; // initialization to a value above limit
+
+ for (int i=0; ibwp_Common->pusch_ConfigCommon->choice.setup->pusch_TimeDomainAllocationList->list.count; i++) {
+ startSymbolAndLength = ubwp->bwp_Common->pusch_ConfigCommon->choice.setup->pusch_TimeDomainAllocationList->list.array[i]->startSymbolAndLength;
+ SLIV2SL(startSymbolAndLength, &StartSymbolIndex, &NrOfSymbols);
+ // we want to transmit in the uplink symbols of mixed slot
+ if (NrOfSymbols == scc->tdd_UL_DL_ConfigurationCommon->pattern1.nrofUplinkSymbols) {
+ ra->Msg3_tda_id = i;
+ break;
+ }
}
- }
- AssertFatal(ra->Msg3_tda_id<16,"Unable to find Msg3 time domain allocation in list\n");
+ AssertFatal(ra->Msg3_tda_id<16,"Unable to find Msg3 time domain allocation in list\n");
- uint8_t k2 = *ubwp->bwp_Common->pusch_ConfigCommon->choice.setup->pusch_TimeDomainAllocationList->list.array[ra->Msg3_tda_id]->k2;
+ uint8_t k2 = *ubwp->bwp_Common->pusch_ConfigCommon->choice.setup->pusch_TimeDomainAllocationList->list.array[ra->Msg3_tda_id]->k2;
- temp_slot = current_slot + k2 + DELTA[mu]; // msg3 slot according to 8.3 in 38.213
- ra->Msg3_slot = temp_slot%nr_slots_per_frame[mu];
- if (nr_slots_per_frame[mu]>temp_slot)
- ra->Msg3_frame = current_frame;
- else
- ra->Msg3_frame = current_frame + (temp_slot/nr_slots_per_frame[mu]);
+ temp_slot = current_slot + k2 + DELTA[mu]; // msg3 slot according to 8.3 in 38.213
+ ra->Msg3_slot = temp_slot%nr_slots_per_frame[mu];
+ if (nr_slots_per_frame[mu]>temp_slot)
+ ra->Msg3_frame = current_frame;
+ else
+ ra->Msg3_frame = current_frame + (temp_slot/nr_slots_per_frame[mu]);
- LOG_I(MAC, "[RAPROC] Msg3 slot %d: current slot %u Msg3 frame %u k2 %u Msg3_tda_id %u start symbol index %u\n", ra->Msg3_slot, current_slot, ra->Msg3_frame, k2,ra->Msg3_tda_id, StartSymbolIndex);
- uint16_t *vrb_map_UL =
- &RC.nrmac[module_id]->common_channels[CC_id].vrb_map_UL[ra->Msg3_slot * MAX_BWP_SIZE];
- const uint16_t bwpSize = NRRIV2BW(ubwp->bwp_Common->genericParameters.locationAndBandwidth, MAX_BWP_SIZE);
- /* search 18 free RBs */
+ LOG_D(MAC, "[RAPROC] Msg3 slot %d: current slot %u Msg3 frame %u k2 %u Msg3_tda_id %u start symbol index %u\n", ra->Msg3_slot, current_slot, ra->Msg3_frame, k2,ra->Msg3_tda_id, StartSymbolIndex);
+ uint16_t *vrb_map_UL =
+ &RC.nrmac[module_id]->common_channels[CC_id].vrb_map_UL[ra->Msg3_slot * MAX_BWP_SIZE];
+ const uint16_t bwpSize = NRRIV2BW(ubwp->bwp_Common->genericParameters.locationAndBandwidth, MAX_BWP_SIZE);
+
+ /* search msg3_nb_rb free RBs */
int rbSize = 0;
int rbStart = 0;
- while (rbSize < 18) {
+ while (rbSize < msg3_nb_rb) {
rbStart += rbSize; /* last iteration rbSize was not enough, skip it */
rbSize = 0;
while (rbStart < bwpSize && vrb_map_UL[rbStart])
rbStart++;
- AssertFatal(rbStart < bwpSize - 18, "no space to allocate Msg 3 for RA!\n");
+ AssertFatal(rbStart < bwpSize - msg3_nb_rb, "no space to allocate Msg 3 for RA!\n");
while (rbStart + rbSize < bwpSize
&& !vrb_map_UL[rbStart + rbSize]
- && rbSize < 18)
+ && rbSize < msg3_nb_rb)
rbSize++;
}
- ra->msg3_nb_rb = 18;
+ ra->msg3_nb_rb = msg3_nb_rb;
ra->msg3_first_rb = rbStart;
}
@@ -717,7 +724,7 @@ void nr_add_msg3(module_id_t module_idP, int CC_id, frame_t frameP, sub_frame_t
vrb_map_UL[i + ra->msg3_first_rb] = 1;
}
- LOG_I(MAC, "[gNB %d][RAPROC] Frame %d, Subframe %d : CC_id %d RA is active, Msg3 in (%d,%d)\n", module_idP, frameP, slotP, CC_id, ra->Msg3_frame, ra->Msg3_slot);
+ LOG_D(MAC, "[gNB %d][RAPROC] Frame %d, Subframe %d : CC_id %d RA is active, Msg3 in (%d,%d)\n", module_idP, frameP, slotP, CC_id, ra->Msg3_frame, ra->Msg3_slot);
nfapi_nr_ul_tti_request_t *future_ul_tti_req = &RC.nrmac[module_idP]->UL_tti_req_ahead[CC_id][ra->Msg3_slot];
AssertFatal(future_ul_tti_req->SFN == ra->Msg3_frame
@@ -784,7 +791,8 @@ void nr_add_msg3(module_id_t module_idP, int CC_id, frame_t frameP, sub_frame_t
pusch_pdu->dmrs_ports = 1; // 6.2.2 in 38.214 only port 0 to be used
pusch_pdu->num_dmrs_cdm_grps_no_data = 2; // no data in dmrs symbols as in 6.2.2 in 38.214
pusch_pdu->resource_alloc = 1; //type 1
- pusch_pdu->rb_start = ra->msg3_first_rb + ibwp_start - abwp_start; // as for 6.3.1.7 in 38.211
+ //pusch_pdu->rb_start = ra->msg3_first_rb + ibwp_start - abwp_start; // as for 6.3.1.7 in 38.211
+ pusch_pdu->rb_start = ra->msg3_first_rb;
if (ra->msg3_nb_rb > pusch_pdu->bwp_size)
AssertFatal(1==0,"MSG3 allocated number of RBs exceed the BWP size\n");
else
@@ -819,82 +827,79 @@ void nr_add_msg3(module_id_t module_idP, int CC_id, frame_t frameP, sub_frame_t
void nr_generate_Msg2(module_id_t module_idP, int CC_id, frame_t frameP, sub_frame_t slotP, NR_RA_t *ra)
{
- int 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[CC_id];
- NR_SearchSpace_t *ss = ra->ra_ss;
- // 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");
-
- 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);
-
- uint16_t RA_rnti = ra->RA_rnti;
- long locationAndBandwidth;
-
- // 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
-
- NR_ServingCellConfigCommon_t *scc = cc->ServingCellConfigCommon;
- int dci10_bw = 0;
-
- if (ra->coreset0_configured == 1) {
- AssertFatal(1==0,"This is a standalone condition\n");
- }
- else { // on configured BWP or initial LDBWP, bandwidth parameters in DCI correspond size of initialBWP
- locationAndBandwidth = scc->downlinkConfigCommon->initialDownlinkBWP->genericParameters.locationAndBandwidth;
- dci10_bw = NRRIV2BW(locationAndBandwidth, MAX_BWP_SIZE);
- }
+ gNB_MAC_INST *nr_mac = RC.nrmac[module_idP];
+ NR_COMMON_channels_t *cc = &nr_mac->common_channels[CC_id];
if ((ra->Msg2_frame == frameP) && (ra->Msg2_slot == slotP)) {
+ uint8_t time_domain_assignment = 3;
+ uint8_t mcsIndex = 0;
+ int rbStart = 0;
+ int rbSize = 8;
+
+ if (nr_mac->sched_ctrlCommon == NULL){
+ LOG_D(MAC,"generate_Msg2: Filling nr_mac->sched_ctrlCommon\n");
+ nr_mac->sched_ctrlCommon = calloc(1,sizeof(*nr_mac->sched_ctrlCommon));
+ nr_mac->sched_ctrlCommon->search_space = calloc(1,sizeof(*nr_mac->sched_ctrlCommon->search_space));
+ nr_mac->sched_ctrlCommon->coreset = calloc(1,sizeof(*nr_mac->sched_ctrlCommon->coreset));
+ nr_mac->sched_ctrlCommon->active_bwp = calloc(1,sizeof(*nr_mac->sched_ctrlCommon->active_bwp));
+ fill_default_searchSpaceZero(nr_mac->sched_ctrlCommon->search_space);
+ fill_default_coresetZero(nr_mac->sched_ctrlCommon->coreset,cc->ServingCellConfigCommon);
+ fill_default_initialDownlinkBWP(nr_mac->sched_ctrlCommon->active_bwp,cc->ServingCellConfigCommon);
+ }
+ nr_mac->sched_ctrlCommon->active_bwp->bwp_Dedicated->pdsch_Config->choice.setup->dmrs_DownlinkForPDSCH_MappingTypeA->choice.setup->dmrs_AdditionalPosition = NULL;
+
+ NR_SearchSpace_t *ss = nr_mac->sched_ctrlCommon->search_space;
+ NR_BWP_Downlink_t *bwp = nr_mac->sched_ctrlCommon->active_bwp;
+ NR_ControlResourceSet_t *coreset = nr_mac->sched_ctrlCommon->coreset;
+ NR_ServingCellConfigCommon_t *scc = cc->ServingCellConfigCommon;
+
+ long BWPSize = NRRIV2BW(scc->downlinkConfigCommon->initialDownlinkBWP->genericParameters.locationAndBandwidth, MAX_BWP_SIZE);
+ long BWPStart = NRRIV2PRBOFFSET(scc->downlinkConfigCommon->initialDownlinkBWP->genericParameters.locationAndBandwidth, MAX_BWP_SIZE);
+
uint16_t *vrb_map = cc[CC_id].vrb_map;
- int rbStart = 0, rbSize = 6;
- for (int i = 0; (i < rbSize) && (rbStart <= (dci10_bw - rbSize)); i++) {
+ for (int i = 0; (i < rbSize) && (rbStart <= (BWPSize - rbSize)); i++) {
if (vrb_map[rbStart + i]) {
rbStart += i;
i = 0;
}
}
- if (rbStart > (dci10_bw - rbSize)) {
- LOG_E(MAC, "%s(): cannot find free vrb_map for RA RNTI %04x!\n", __func__, ra->RA_rnti);
+
+ if (rbStart > (BWPSize - rbSize)) {
+ LOG_E(NR_MAC, "%s(): cannot find free vrb_map for RA RNTI %04x!\n", __func__, ra->RA_rnti);
return;
}
+ // Checking if the DCI allocation is feasible in current subframe
nfapi_nr_dl_tti_request_body_t *dl_req = &nr_mac->DL_req[CC_id].dl_tti_request_body;
- // Checking if the DCI allocation is feasible in current subframe: we might
- // need to need up to two (PDCCH + PDSCH) messages, so check that we can
- // always allocate both (this might be an overestimation, since the PDCCH
- // message might already exist)
if (dl_req->nPDUs > NFAPI_NR_MAX_DL_TTI_PDUS - 2) {
- LOG_I(MAC, "[RAPROC] Subframe %d: FAPI DL structure is full, skip scheduling UE %d\n", slotP, RA_rnti);
+ LOG_I(MAC, "[RAPROC] Subframe %d: FAPI DL structure is full, skip scheduling UE %d\n", slotP, ra->RA_rnti);
return;
}
- uint8_t nr_of_candidates, aggregation_level;
+ uint8_t aggregation_level;
+ uint8_t nr_of_candidates;
find_aggregation_candidates(&aggregation_level, &nr_of_candidates, ss);
- NR_BWP_Downlink_t *bwp = ra->secondaryCellGroup->spCellConfig->spCellConfigDedicated->downlinkBWP_ToAddModList->list.array[ra->bwp_id - 1];
- NR_ControlResourceSet_t *coreset = get_coreset(bwp, ss, 0 /* common */);
- int CCEIndex = allocate_nr_CCEs(nr_mac,
- bwp,
- coreset,
- aggregation_level,
- 0, // Y
- 0, // m
- nr_of_candidates);
-
+ int CCEIndex = allocate_nr_CCEs(nr_mac, bwp, coreset, aggregation_level,0,0,nr_of_candidates);
if (CCEIndex < 0) {
LOG_E(MAC, "%s(): cannot find free CCE for RA RNTI %04x!\n", __func__, ra->rnti);
return;
}
- /* look up the PDCCH PDU for this CC, BWP, and CORESET. If it does not
- * exist, create it. This is especially important if we have multiple RAs,
- * and the DLSCH has to reuse them, so we need to mark them */
+ // Calculate number of symbols
+ int startSymbolIndex, nrOfSymbols;
+ const int startSymbolAndLength = bwp->bwp_Common->pdsch_ConfigCommon->choice.setup->pdsch_TimeDomainAllocationList->list.array[time_domain_assignment]->startSymbolAndLength;
+ SLIV2SL(startSymbolAndLength, &startSymbolIndex, &nrOfSymbols);
+ AssertFatal(startSymbolIndex >= 0, "StartSymbolIndex is negative\n");
+
+ if (nrOfSymbols == 2) {
+ nr_mac->sched_ctrlCommon->numDmrsCdmGrpsNoData = 1;
+ } else {
+ nr_mac->sched_ctrlCommon->numDmrsCdmGrpsNoData = 2;
+ }
+ // look up the PDCCH PDU for this CC, BWP, and CORESET. If it does not exist, create it. This is especially
+ // important if we have multiple RAs, and the DLSCH has to reuse them, so we need to mark them
const int bwpid = bwp->bwp_Id;
const int coresetid = coreset->controlResourceSetId;
nfapi_nr_dl_tti_pdcch_pdu_rel15_t *pdcch_pdu_rel15 = nr_mac->pdcch_pdu_idx[CC_id][bwpid][coresetid];
@@ -909,6 +914,9 @@ void nr_generate_Msg2(module_id_t module_idP, int CC_id, frame_t frameP, sub_fra
nr_mac->pdcch_pdu_idx[CC_id][bwpid][coresetid] = pdcch_pdu_rel15;
}
+ // TODO: This assignment should be done in function nr_configure_pdcch()
+ pdcch_pdu_rel15->CoreSetType = NFAPI_NR_CSET_CONFIG_PDCCH_CONFIG_CSET_0;
+
nfapi_nr_dl_tti_request_pdu_t *dl_tti_pdsch_pdu = &dl_req->dl_tti_pdu_list[dl_req->nPDUs];
memset((void *)dl_tti_pdsch_pdu,0,sizeof(nfapi_nr_dl_tti_request_pdu_t));
dl_tti_pdsch_pdu->PDUType = NFAPI_NR_DL_TTI_PDSCH_PDU_TYPE;
@@ -916,81 +924,76 @@ void nr_generate_Msg2(module_id_t module_idP, int CC_id, frame_t frameP, sub_fra
dl_req->nPDUs+=1;
nfapi_nr_dl_tti_pdsch_pdu_rel15_t *pdsch_pdu_rel15 = &dl_tti_pdsch_pdu->pdsch_pdu.pdsch_pdu_rel15;
- LOG_I(MAC,"[gNB %d] [RAPROC] CC_id %d Frame %d, slotP %d: Generating RAR DCI, state %d\n", module_idP, CC_id, frameP, slotP, ra->state);
+ LOG_I(NR_MAC,"[gNB %d][RAPROC] CC_id %d Frame %d, slotP %d: Generating RA-Msg2 DCI, rnti 0x%x, state %d\n",
+ module_idP, CC_id, frameP, slotP, ra->RA_rnti, ra->state);
- NR_BWP_Uplink_t *ubwp=ra->secondaryCellGroup->spCellConfig->spCellConfigDedicated->uplinkConfig->uplinkBWP_ToAddModList->list.array[ra->bwp_id-1];
+ AssertFatal(ra->secondaryCellGroup, "no secondaryCellGroup for RNTI %04x\n", ra->RA_rnti);
- LOG_I(MAC, "[RAPROC] Scheduling common search space DCI type 1 dlBWP BW %d\n", dci10_bw);
+ AssertFatal(ra->secondaryCellGroup->spCellConfig->spCellConfigDedicated->downlinkBWP_ToAddModList->list.count == 1,
+ "downlinkBWP_ToAddModList has %d BWP!\n",
+ ra->secondaryCellGroup->spCellConfig->spCellConfigDedicated->downlinkBWP_ToAddModList->list.count);
+
+ // SCF222: PDU index incremented for each PDSCH PDU sent in TX control message. This is used to associate control
+ // information to data and is reset every slot.
+ const int pduindex = nr_mac->pdu_index[CC_id]++;
+
+ uint8_t mcsTableIdx = 0;
+ if (bwp->bwp_Dedicated->pdsch_Config->choice.setup->mcs_Table == NULL)
+ mcsTableIdx = 0;
+ else{
+ if (*bwp->bwp_Dedicated->pdsch_Config->choice.setup->mcs_Table == 0)
+ mcsTableIdx = 1;
+ else
+ mcsTableIdx = 2;
+ }
+
+ AssertFatal(nr_mac->sched_ctrlCommon->numDmrsCdmGrpsNoData == 1 ||
+ nr_mac->sched_ctrlCommon->numDmrsCdmGrpsNoData == 2,
+ "nr_mac->schedCtrlCommon->numDmrsCdmGrpsNoData %d is not possible",
+ nr_mac->sched_ctrlCommon->numDmrsCdmGrpsNoData);
- // Qm>2 not allowed for RAR
- if (get_softmodem_params()->do_ra)
- mcsIndex = 9;
- else
- mcsIndex = 0;
pdsch_pdu_rel15->pduBitmap = 0;
- pdsch_pdu_rel15->rnti = RA_rnti;
- /* SCF222: PDU index incremented for each PDSCH PDU sent in TX control
- * message. This is used to associate control information to data and is
- * reset every slot. */
- const int pduindex = nr_mac->pdu_index[CC_id]++;
+ pdsch_pdu_rel15->rnti = ra->RA_rnti;
pdsch_pdu_rel15->pduIndex = pduindex;
-
-
- pdsch_pdu_rel15->BWPSize = NRRIV2BW(bwp->bwp_Common->genericParameters.locationAndBandwidth, MAX_BWP_SIZE);
- pdsch_pdu_rel15->BWPStart = NRRIV2PRBOFFSET(bwp->bwp_Common->genericParameters.locationAndBandwidth, MAX_BWP_SIZE);
+ pdsch_pdu_rel15->BWPSize = BWPSize;
+ pdsch_pdu_rel15->BWPStart = BWPStart;
pdsch_pdu_rel15->SubcarrierSpacing = bwp->bwp_Common->genericParameters.subcarrierSpacing;
pdsch_pdu_rel15->CyclicPrefix = 0;
pdsch_pdu_rel15->NrOfCodewords = 1;
- pdsch_pdu_rel15->targetCodeRate[0] = nr_get_code_rate_dl(mcsIndex,0);
+ pdsch_pdu_rel15->targetCodeRate[0] = nr_get_code_rate_dl(mcsIndex,mcsTableIdx);
pdsch_pdu_rel15->qamModOrder[0] = 2;
pdsch_pdu_rel15->mcsIndex[0] = mcsIndex;
- if (bwp->bwp_Dedicated->pdsch_Config->choice.setup->mcs_Table == NULL)
- pdsch_pdu_rel15->mcsTable[0] = 0;
- else{
- if (*bwp->bwp_Dedicated->pdsch_Config->choice.setup->mcs_Table == 0)
- pdsch_pdu_rel15->mcsTable[0] = 1;
- else
- pdsch_pdu_rel15->mcsTable[0] = 2;
- }
+ pdsch_pdu_rel15->mcsTable[0] = mcsTableIdx;
pdsch_pdu_rel15->rvIndex[0] = 0;
pdsch_pdu_rel15->dataScramblingId = *scc->physCellId;
pdsch_pdu_rel15->nrOfLayers = 1;
pdsch_pdu_rel15->transmissionScheme = 0;
pdsch_pdu_rel15->refPoint = 0;
- pdsch_pdu_rel15->dmrsConfigType = 0;
+ 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;
- pdsch_pdu_rel15->numDmrsCdmGrpsNoData = 2;
+ pdsch_pdu_rel15->numDmrsCdmGrpsNoData = nr_mac->sched_ctrlCommon->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 = 0; // non interleaved
+ pdsch_pdu_rel15->VRBtoPRBMapping = 0;
+ pdsch_pdu_rel15->StartSymbolIndex = startSymbolIndex;
+ pdsch_pdu_rel15->NrOfSymbols = nrOfSymbols;
+ pdsch_pdu_rel15->dlDmrsSymbPos = fill_dmrs_mask(nr_mac->sched_ctrlCommon->active_bwp->bwp_Dedicated->pdsch_Config->choice.setup,
+ nr_mac->common_channels->ServingCellConfigCommon->dmrs_TypeA_Position,
+ nrOfSymbols,
+ startSymbolIndex);
- for (int i=0; ibwp_Common->pdsch_ConfigCommon->choice.setup->pdsch_TimeDomainAllocationList->list.count; i++) {
- startSymbolAndLength = bwp->bwp_Common->pdsch_ConfigCommon->choice.setup->pdsch_TimeDomainAllocationList->list.array[i]->startSymbolAndLength;
- SLIV2SL(startSymbolAndLength, &StartSymbolIndex_tmp, &NrOfSymbols_tmp);
- if (NrOfSymbols_tmp < NrOfSymbols) {
- NrOfSymbols = NrOfSymbols_tmp;
- StartSymbolIndex = StartSymbolIndex_tmp;
- time_domain_assignment = i; // this is short PDSCH added to the config to fit mixed slot
- }
- }
+ int x_Overhead = 0;
+ uint8_t tb_scaling = 0;
+ nr_get_tbs_dl(&dl_tti_pdsch_pdu->pdsch_pdu, x_Overhead, pdsch_pdu_rel15->numDmrsCdmGrpsNoData, tb_scaling);
- AssertFatal(StartSymbolIndex >= 0, "StartSymbolIndex is negative\n");
-
- pdsch_pdu_rel15->StartSymbolIndex = StartSymbolIndex;
- pdsch_pdu_rel15->NrOfSymbols = NrOfSymbols;
- pdsch_pdu_rel15->dlDmrsSymbPos = fill_dmrs_mask(NULL, scc->dmrs_TypeA_Position, NrOfSymbols);
-
- /* Fill PDCCH DL DCI PDU */
+ // Fill PDCCH DL DCI PDU
nfapi_nr_dl_dci_pdu_t *dci_pdu = &pdcch_pdu_rel15->dci_pdu[pdcch_pdu_rel15->numDlDci];
pdcch_pdu_rel15->numDlDci++;
- dci_pdu->RNTI = RA_rnti;
- /* TODO: remove next line */
- AssertFatal(ss->searchSpaceType->present != NR_SearchSpace__searchSpaceType_PR_ue_Specific,
- "shouldn't the RA SS be common?\n");
+ dci_pdu->RNTI = ra->RA_rnti;
dci_pdu->ScramblingId = *scc->physCellId;
dci_pdu->ScramblingRNTI = 0;
dci_pdu->AggregationLevel = aggregation_level;
@@ -1000,81 +1003,405 @@ void nr_generate_Msg2(module_id_t module_idP, int CC_id, frame_t frameP, sub_fra
dci_pdu_rel15_t dci_payload;
dci_payload.frequency_domain_assignment.val = PRBalloc_to_locationandbandwidth0(pdsch_pdu_rel15->rbSize,
- pdsch_pdu_rel15->rbStart,dci10_bw);
+ pdsch_pdu_rel15->rbStart,
+ pdsch_pdu_rel15->BWPSize);
+
dci_payload.time_domain_assignment.val = time_domain_assignment;
dci_payload.vrb_to_prb_mapping.val = 0;
dci_payload.mcs = pdsch_pdu_rel15->mcsIndex[0];
- dci_payload.tb_scaling = 0;
+ dci_payload.tb_scaling = tb_scaling;
- LOG_I(MAC,
+ LOG_D(NR_MAC,
"[RAPROC] DCI type 1 payload: freq_alloc %d (%d,%d,%d), time_alloc %d, vrb to prb %d, mcs %d tb_scaling %d \n",
dci_payload.frequency_domain_assignment.val,
pdsch_pdu_rel15->rbStart,
pdsch_pdu_rel15->rbSize,
- dci10_bw,
+ pdsch_pdu_rel15->BWPSize,
dci_payload.time_domain_assignment.val,
dci_payload.vrb_to_prb_mapping.val,
dci_payload.mcs,
dci_payload.tb_scaling);
- LOG_I(MAC, "Frame %d: Subframe %d : Adding common DL DCI for RA_RNTI %x\n", frameP, slotP, RA_rnti);
-
- const int dci_format = NR_DL_DCI_FORMAT_1_0;
- const int rnti_type = NR_RNTI_RA;
-
- LOG_I(MAC,
- "[RAPROC] DCI params: rnti %d, rnti_type %d, dci_format %d coreset params: FreqDomainResource %llx, start_symbol %d n_symb %d\n",
+ LOG_D(NR_MAC,
+ "[RAPROC] DCI params: rnti 0x%x, rnti_type %d, dci_format %d coreset params: FreqDomainResource %llx, start_symbol %d n_symb %d\n",
pdcch_pdu_rel15->dci_pdu[0].RNTI,
- rnti_type,
- dci_format,
+ NR_RNTI_RA,
+ NR_DL_DCI_FORMAT_1_0,
(unsigned long long)pdcch_pdu_rel15->FreqDomainResource,
pdcch_pdu_rel15->StartSymbolIndex,
pdcch_pdu_rel15->DurationSymbols);
fill_dci_pdu_rel15(scc,
- ra->secondaryCellGroup,
- dci_pdu,
+ nr_mac->secondaryCellGroupCommon,
+ &pdcch_pdu_rel15->dci_pdu[pdcch_pdu_rel15->numDlDci - 1],
&dci_payload,
- dci_format,
- rnti_type,
- dci10_bw,
- ra->bwp_id);
+ NR_DL_DCI_FORMAT_1_0,
+ NR_RNTI_RA,
+ pdsch_pdu_rel15->BWPSize,
+ nr_mac->sched_ctrlCommon->active_bwp->bwp_Id);
// DL TX request
nfapi_nr_pdu_t *tx_req = &nr_mac->TX_req[CC_id].pdu_list[nr_mac->TX_req[CC_id].Number_of_PDUs];
+
+ // Program UL processing for Msg3
+ NR_BWP_Uplink_t *ubwp = ra->secondaryCellGroup->spCellConfig->spCellConfigDedicated->uplinkConfig->uplinkBWP_ToAddModList->list.array[ra->bwp_id-1];
+ nr_get_Msg3alloc(module_idP, CC_id, scc, ubwp, slotP, frameP, ra);
+ nr_add_msg3(module_idP, CC_id, frameP, slotP, ra, (uint8_t *) &tx_req->TLVs[0].value.direct[0]);
+
+ LOG_I(MAC, "Frame %d, Subframe %d: Setting RA-Msg3 reception for Frame %d Subframe %d\n", frameP, slotP, ra->Msg3_frame, ra->Msg3_slot);
+
+ T(T_GNB_MAC_DL_RAR_PDU_WITH_DATA, T_INT(module_idP), T_INT(CC_id), T_INT(ra->RA_rnti), T_INT(frameP),
+ T_INT(slotP), T_INT(0), T_BUFFER(&tx_req->TLVs[0].value.direct[0], tx_req->TLVs[0].length));
+
tx_req->PDU_length = pdsch_pdu_rel15->TBSize[0];
tx_req->PDU_index = pduindex;
tx_req->num_TLV = 1;
- tx_req->TLVs[0].length = 8;
+ tx_req->TLVs[0].length = tx_req->PDU_length + 2;
nr_mac->TX_req[CC_id].SFN = frameP;
nr_mac->TX_req[CC_id].Number_of_PDUs++;
nr_mac->TX_req[CC_id].Slot = slotP;
- // Program UL processing for Msg3
- nr_get_Msg3alloc(module_idP, CC_id, scc, ubwp, slotP, frameP, ra);
- LOG_I(MAC, "Frame %d, Subframe %d: Setting Msg3 reception for Frame %d Subframe %d\n", frameP, slotP, ra->Msg3_frame, ra->Msg3_slot);
- nr_add_msg3(module_idP, CC_id, frameP, slotP, ra, (uint8_t *) &tx_req->TLVs[0].value.direct[0]);
+ // Mark the corresponding RBs as used
+ for (int rb = 0; rb < rbSize; rb++) {
+ vrb_map[rb + rbStart] = 1;
+ }
+
ra->state = WAIT_Msg3;
LOG_I(MAC,"[gNB %d][RAPROC] Frame %d, Subframe %d: RA state %d\n", module_idP, frameP, slotP, ra->state);
-
- x_Overhead = 0;
- nr_get_tbs_dl(&dl_tti_pdsch_pdu->pdsch_pdu, x_Overhead, pdsch_pdu_rel15->numDmrsCdmGrpsNoData, dci_payload.tb_scaling);
-
- T(T_GNB_MAC_DL_RAR_PDU_WITH_DATA, T_INT(module_idP), T_INT(CC_id),
- T_INT(RA_rnti), T_INT(frameP), T_INT(slotP), T_INT(0) /* harq pid, meaningful? */,
- T_BUFFER(&tx_req->TLVs[0].value.direct[0], tx_req->TLVs[0].length));
-
- /* mark the corresponding RBs as used */
- for (int rb = 0; rb < rbSize; rb++)
- vrb_map[rb + rbStart] = 1;
}
}
+void nr_generate_Msg4(module_id_t module_idP, int CC_id, frame_t frameP, sub_frame_t slotP, NR_RA_t *ra) {
+
+ gNB_MAC_INST *nr_mac = RC.nrmac[module_idP];
+ NR_COMMON_channels_t *cc = &nr_mac->common_channels[CC_id];
+
+ if (ra->Msg4_frame == frameP && ra->Msg4_slot == slotP ) {
+
+ uint8_t time_domain_assignment = 0;
+ uint8_t mcsIndex = 0;
+
+ NR_SearchSpace_t *ss = nr_mac->sched_ctrlCommon->search_space;
+ NR_BWP_Downlink_t *bwp = nr_mac->sched_ctrlCommon->active_bwp;
+ NR_ControlResourceSet_t *coreset = nr_mac->sched_ctrlCommon->coreset;
+ NR_ServingCellConfigCommon_t *scc = cc->ServingCellConfigCommon;
+ NR_TDD_UL_DL_Pattern_t *tdd = &scc->tdd_UL_DL_ConfigurationCommon->pattern1;
+
+ int UE_id = find_nr_UE_id(module_idP, ra->rnti);
+ NR_UE_info_t *UE_info = &nr_mac->UE_info;
+ NR_UE_sched_ctrl_t *sched_ctrl = &UE_info->UE_sched_ctrl[UE_id];
+
+ long BWPSize = NRRIV2BW(scc->downlinkConfigCommon->initialDownlinkBWP->genericParameters.locationAndBandwidth, MAX_BWP_SIZE);
+ long BWPStart = NRRIV2PRBOFFSET(scc->downlinkConfigCommon->initialDownlinkBWP->genericParameters.locationAndBandwidth, MAX_BWP_SIZE);
+
+ int nr_mix_slots = tdd->nrofDownlinkSymbols != 0 || tdd->nrofUplinkSymbols != 0;
+ int nr_slots_period = tdd->nrofDownlinkSlots + tdd->nrofUplinkSlots + nr_mix_slots;
+ int first_ul_slot_tdd = tdd->nrofDownlinkSlots + nr_slots_period * (slotP / nr_slots_period);
+
+ // HARQ management
+ int8_t current_harq_pid = sched_ctrl->dl_harq_pid;
+ if (current_harq_pid < 0) {
+ current_harq_pid = sched_ctrl->available_dl_harq.head;
+ remove_front_nr_list(&sched_ctrl->available_dl_harq);
+ sched_ctrl->dl_harq_pid = current_harq_pid;
+ } else {
+ if (sched_ctrl->harq_processes[current_harq_pid].round == 0)
+ remove_nr_list(&sched_ctrl->available_dl_harq, current_harq_pid);
+ else
+ remove_nr_list(&sched_ctrl->retrans_dl_harq, current_harq_pid);
+ }
+ NR_UE_harq_t *harq = &sched_ctrl->harq_processes[current_harq_pid];
+ DevAssert(!harq->is_waiting);
+ add_tail_nr_list(&sched_ctrl->feedback_dl_harq, current_harq_pid);
+ harq->is_waiting = true;
+ harq->feedback_slot = first_ul_slot_tdd;
+ ra->harq_pid = current_harq_pid;
+
+ // Bytes to be transmitted
+ uint8_t *buf = (uint8_t *) harq->tb;
+ uint16_t mac_pdu_length = nr_write_ce_dlsch_pdu(module_idP, nr_mac->sched_ctrlCommon, buf, 255, ra->cont_res_id);
+ LOG_D(MAC,"Encoded Cont Res mac_pdu_length now %d\n",mac_pdu_length);
+ uint16_t mac_sdu_length = mac_rrc_nr_data_req(module_idP, CC_id, frameP, CCCH, ra->rnti, 1, &buf[mac_pdu_length+2]);
+ ((NR_MAC_SUBHEADER_SHORT *) &buf[mac_pdu_length])->R = 0;
+ ((NR_MAC_SUBHEADER_SHORT *) &buf[mac_pdu_length])->F = 0;
+ ((NR_MAC_SUBHEADER_SHORT *) &buf[mac_pdu_length])->LCID = DL_SCH_LCID_CCCH;
+ ((NR_MAC_SUBHEADER_SHORT *) &buf[mac_pdu_length])->L = mac_sdu_length /* * 8*/;
+ mac_pdu_length = mac_pdu_length + mac_sdu_length + 2;
+ LOG_D(MAC,"Encoded RRCSetup Piggyback (%d + 2 bytes), mac_pdu_length now %d\n",mac_sdu_length,mac_pdu_length);
+ // Calculate number of symbols
+ int startSymbolIndex, nrOfSymbols;
+ const int startSymbolAndLength = bwp->bwp_Common->pdsch_ConfigCommon->choice.setup->pdsch_TimeDomainAllocationList->list.array[time_domain_assignment]->startSymbolAndLength;
+ SLIV2SL(startSymbolAndLength, &startSymbolIndex, &nrOfSymbols);
+ AssertFatal(startSymbolIndex >= 0, "StartSymbolIndex is negative\n");
+
+ uint16_t dlDmrsSymbPos = fill_dmrs_mask(nr_mac->sched_ctrlCommon->active_bwp->bwp_Dedicated->pdsch_Config->choice.setup,
+ nr_mac->common_channels->ServingCellConfigCommon->dmrs_TypeA_Position,
+ nrOfSymbols,
+ startSymbolIndex);
+
+ uint16_t N_DMRS_SLOT = get_num_dmrs(dlDmrsSymbPos);
+
+ long dmrsConfigType = bwp->bwp_Dedicated->pdsch_Config->choice.setup->dmrs_DownlinkForPDSCH_MappingTypeA->choice.setup->dmrs_Type == NULL ? 0 : 1;
+ uint8_t N_PRB_DMRS = 0;
+ AssertFatal(nr_mac->sched_ctrlCommon->numDmrsCdmGrpsNoData == 1 ||
+ nr_mac->sched_ctrlCommon->numDmrsCdmGrpsNoData == 2,
+ "nr_mac->schedCtrlCommon->numDmrsCdmGrpsNoData %d is not possible",
+ nr_mac->sched_ctrlCommon->numDmrsCdmGrpsNoData);
+
+ if (dmrsConfigType==NFAPI_NR_DMRS_TYPE1) {
+ N_PRB_DMRS = nr_mac->sched_ctrlCommon->numDmrsCdmGrpsNoData * 6;
+ }
+ else {
+ N_PRB_DMRS = nr_mac->sched_ctrlCommon->numDmrsCdmGrpsNoData * 4;
+ }
+
+ uint8_t mcsTableIdx = 0;
+ if (bwp->bwp_Dedicated->pdsch_Config->choice.setup->mcs_Table == NULL)
+ mcsTableIdx = 0;
+ else{
+ if (*bwp->bwp_Dedicated->pdsch_Config->choice.setup->mcs_Table == 0)
+ mcsTableIdx = 1;
+ else
+ mcsTableIdx = 2;
+ }
+
+ int rbStart = 0;
+ int rbSize = 0;
+ uint8_t tb_scaling = 0;
+ uint16_t *vrb_map = cc[CC_id].vrb_map;
+ do {
+ rbSize++;
+ LOG_D(MAC,"Calling nr_compute_tbs with N_PRB_DMRS %d, N_DMRS_SLOT %d\n",N_PRB_DMRS,N_DMRS_SLOT);
+ harq->tb_size = nr_compute_tbs(nr_get_Qm_dl(mcsIndex, mcsTableIdx),
+ nr_get_code_rate_dl(mcsIndex, mcsTableIdx),
+ rbSize, nrOfSymbols, N_PRB_DMRS * N_DMRS_SLOT, 0, tb_scaling,1) >> 3;
+ } while (rbStart + rbSize < BWPSize && !vrb_map[rbStart + rbSize] && harq->tb_size < mac_pdu_length);
+
+ for (int i = 0; (i < rbSize) && (rbStart <= (BWPSize - rbSize)); i++) {
+ if (vrb_map[rbStart + i]) {
+ rbStart += i;
+ i = 0;
+ }
+ }
+
+ if (rbStart > (BWPSize - rbSize)) {
+ LOG_E(NR_MAC, "%s(): cannot find free vrb_map for RNTI %04x!\n", __func__, ra->rnti);
+ return;
+ }
+
+ // Checking if the DCI allocation is feasible in current subframe
+ nfapi_nr_dl_tti_request_body_t *dl_req = &nr_mac->DL_req[CC_id].dl_tti_request_body;
+ if (dl_req->nPDUs > NFAPI_NR_MAX_DL_TTI_PDUS - 2) {
+ LOG_I(NR_MAC, "[RAPROC] Subframe %d: FAPI DL structure is full, skip scheduling UE %d\n", slotP, ra->rnti);
+ return;
+ }
+
+ uint8_t aggregation_level;
+ uint8_t nr_of_candidates;
+ find_aggregation_candidates(&aggregation_level, &nr_of_candidates, ss);
+ int CCEIndex = allocate_nr_CCEs(nr_mac, bwp, coreset, aggregation_level,0,0,nr_of_candidates);
+ if (CCEIndex < 0) {
+ LOG_E(MAC, "%s(): cannot find free CCE for RA RNTI %04x!\n", __func__, ra->rnti);
+ return;
+ }
+
+ // look up the PDCCH PDU for this CC, BWP, and CORESET. If it does not exist, create it. This is especially
+ // important if we have multiple RAs, and the DLSCH has to reuse them, so we need to mark them
+ const int bwpid = bwp->bwp_Id;
+ const int coresetid = coreset->controlResourceSetId;
+ nfapi_nr_dl_tti_pdcch_pdu_rel15_t *pdcch_pdu_rel15 = nr_mac->pdcch_pdu_idx[CC_id][bwpid][coresetid];
+ if (!pdcch_pdu_rel15) {
+ nfapi_nr_dl_tti_request_pdu_t *dl_tti_pdcch_pdu = &dl_req->dl_tti_pdu_list[dl_req->nPDUs];
+ memset(dl_tti_pdcch_pdu, 0, sizeof(nfapi_nr_dl_tti_request_pdu_t));
+ 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));
+ dl_req->nPDUs += 1;
+ pdcch_pdu_rel15 = &dl_tti_pdcch_pdu->pdcch_pdu.pdcch_pdu_rel15;
+ nr_configure_pdcch(pdcch_pdu_rel15, ss, coreset, scc, bwp);
+ nr_mac->pdcch_pdu_idx[CC_id][bwpid][coresetid] = pdcch_pdu_rel15;
+ }
+
+ // TODO: This assignment should be done in function nr_configure_pdcch()
+ pdcch_pdu_rel15->CoreSetType = NFAPI_NR_CSET_CONFIG_PDCCH_CONFIG_CSET_0;
+
+ nfapi_nr_dl_tti_request_pdu_t *dl_tti_pdsch_pdu = &dl_req->dl_tti_pdu_list[dl_req->nPDUs];
+ memset((void *)dl_tti_pdsch_pdu,0,sizeof(nfapi_nr_dl_tti_request_pdu_t));
+ 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));
+ dl_req->nPDUs+=1;
+ nfapi_nr_dl_tti_pdsch_pdu_rel15_t *pdsch_pdu_rel15 = &dl_tti_pdsch_pdu->pdsch_pdu.pdsch_pdu_rel15;
+
+ LOG_I(NR_MAC,"[gNB %d] [RAPROC] CC_id %d Frame %d, slotP %d: Generating RA-Msg4 DCI, state %d\n", module_idP, CC_id, frameP, slotP, ra->state);
+
+ AssertFatal(ra->secondaryCellGroup, "no secondaryCellGroup for RNTI %04x\n", ra->rnti);
+
+ AssertFatal(ra->secondaryCellGroup->spCellConfig->spCellConfigDedicated->downlinkBWP_ToAddModList->list.count == 1,
+ "downlinkBWP_ToAddModList has %d BWP!\n",
+ ra->secondaryCellGroup->spCellConfig->spCellConfigDedicated->downlinkBWP_ToAddModList->list.count);
+
+ // SCF222: PDU index incremented for each PDSCH PDU sent in TX control message. This is used to associate control
+ // information to data and is reset every slot.
+ const int pduindex = nr_mac->pdu_index[CC_id]++;
+
+ pdsch_pdu_rel15->pduBitmap = 0;
+ pdsch_pdu_rel15->rnti = ra->rnti;
+ pdsch_pdu_rel15->pduIndex = pduindex;
+ pdsch_pdu_rel15->BWPSize = BWPSize;
+ pdsch_pdu_rel15->BWPStart = BWPStart;
+ pdsch_pdu_rel15->SubcarrierSpacing = bwp->bwp_Common->genericParameters.subcarrierSpacing;
+ pdsch_pdu_rel15->CyclicPrefix = 0;
+ pdsch_pdu_rel15->NrOfCodewords = 1;
+ pdsch_pdu_rel15->targetCodeRate[0] = nr_get_code_rate_dl(mcsIndex,mcsTableIdx);
+ pdsch_pdu_rel15->qamModOrder[0] = 2;
+ pdsch_pdu_rel15->mcsIndex[0] = mcsIndex;
+ pdsch_pdu_rel15->mcsTable[0] = mcsTableIdx;
+ pdsch_pdu_rel15->rvIndex[0] = nr_rv_round_map[harq->round];
+ pdsch_pdu_rel15->dataScramblingId = *scc->physCellId;
+ pdsch_pdu_rel15->nrOfLayers = 1;
+ pdsch_pdu_rel15->transmissionScheme = 0;
+ pdsch_pdu_rel15->refPoint = 0;
+ pdsch_pdu_rel15->dmrsConfigType = dmrsConfigType;
+ pdsch_pdu_rel15->dlDmrsScramblingId = *scc->physCellId;
+ pdsch_pdu_rel15->SCID = 0;
+ pdsch_pdu_rel15->numDmrsCdmGrpsNoData = 2;
+ pdsch_pdu_rel15->dmrsPorts = 1;
+ pdsch_pdu_rel15->resourceAlloc = 1;
+ pdsch_pdu_rel15->rbStart = rbStart;
+ pdsch_pdu_rel15->rbSize = rbSize;
+ pdsch_pdu_rel15->VRBtoPRBMapping = 0;
+ pdsch_pdu_rel15->StartSymbolIndex = startSymbolIndex;
+ pdsch_pdu_rel15->NrOfSymbols = nrOfSymbols;
+ pdsch_pdu_rel15->dlDmrsSymbPos = dlDmrsSymbPos;
+
+
+ int x_Overhead = 0;
+ nr_get_tbs_dl(&dl_tti_pdsch_pdu->pdsch_pdu, x_Overhead, pdsch_pdu_rel15->numDmrsCdmGrpsNoData, tb_scaling);
+
+ // Fill PDCCH DL DCI PDU
+ nfapi_nr_dl_dci_pdu_t *dci_pdu = &pdcch_pdu_rel15->dci_pdu[pdcch_pdu_rel15->numDlDci];
+ pdcch_pdu_rel15->numDlDci++;
+ dci_pdu->RNTI = ra->rnti;
+ dci_pdu->ScramblingId = *scc->physCellId;
+ dci_pdu->ScramblingRNTI = 0;
+ dci_pdu->AggregationLevel = aggregation_level;
+ dci_pdu->CceIndex = CCEIndex;
+ dci_pdu->beta_PDCCH_1_0 = 0;
+ dci_pdu->powerControlOffsetSS = 1;
+
+ dci_pdu_rel15_t dci_payload;
+ dci_payload.frequency_domain_assignment.val = PRBalloc_to_locationandbandwidth0(pdsch_pdu_rel15->rbSize,
+ pdsch_pdu_rel15->rbStart,
+ pdsch_pdu_rel15->BWPSize);
+
+ dci_payload.time_domain_assignment.val = time_domain_assignment;
+ dci_payload.vrb_to_prb_mapping.val = 0;
+ dci_payload.mcs = pdsch_pdu_rel15->mcsIndex[0];
+ dci_payload.tb_scaling = tb_scaling;
+ dci_payload.rv = pdsch_pdu_rel15->rvIndex[0];
+ dci_payload.harq_pid = current_harq_pid;
+ dci_payload.ndi = harq->ndi;
+ dci_payload.dai[0].val = (sched_ctrl->sched_pucch->dai_c-1)&3;
+ dci_payload.tpc = sched_ctrl->tpc1; // TPC for PUCCH: table 7.2.1-1 in 38.213
+ dci_payload.pucch_resource_indicator = sched_ctrl->sched_pucch->resource_indicator;
+ dci_payload.pdsch_to_harq_feedback_timing_indicator.val = sched_ctrl->sched_pucch->timing_indicator;
+
+ LOG_D(NR_MAC,
+ "[RAPROC] DCI type 1 payload: freq_alloc %d (%d,%d,%d), time_alloc %d, vrb to prb %d, mcs %d tb_scaling %d \n",
+ dci_payload.frequency_domain_assignment.val,
+ pdsch_pdu_rel15->rbStart,
+ pdsch_pdu_rel15->rbSize,
+ pdsch_pdu_rel15->BWPSize,
+ dci_payload.time_domain_assignment.val,
+ dci_payload.vrb_to_prb_mapping.val,
+ dci_payload.mcs,
+ dci_payload.tb_scaling);
+
+ LOG_D(NR_MAC,
+ "[RAPROC] DCI params: rnti 0x%x, rnti_type %d, dci_format %d coreset params: FreqDomainResource %llx, start_symbol %d n_symb %d\n",
+ pdcch_pdu_rel15->dci_pdu[0].RNTI,
+ NR_RNTI_TC,
+ NR_DL_DCI_FORMAT_1_0,
+ (unsigned long long)pdcch_pdu_rel15->FreqDomainResource,
+ pdcch_pdu_rel15->StartSymbolIndex,
+ pdcch_pdu_rel15->DurationSymbols);
+
+ fill_dci_pdu_rel15(scc,
+ nr_mac->secondaryCellGroupCommon,
+ &pdcch_pdu_rel15->dci_pdu[pdcch_pdu_rel15->numDlDci - 1],
+ &dci_payload,
+ NR_DL_DCI_FORMAT_1_0,
+ NR_RNTI_TC,
+ pdsch_pdu_rel15->BWPSize,
+ nr_mac->sched_ctrlCommon->active_bwp->bwp_Id);
+
+ // DL TX request
+ nfapi_nr_pdu_t *tx_req = &nr_mac->TX_req[CC_id].pdu_list[nr_mac->TX_req[CC_id].Number_of_PDUs];
+ memcpy(tx_req->TLVs[0].value.direct, harq->tb, sizeof(uint8_t) * harq->tb_size);
+ tx_req->PDU_length = harq->tb_size;
+ tx_req->PDU_index = pduindex;
+ tx_req->num_TLV = 1;
+ tx_req->TLVs[0].length = harq->tb_size + 2;
+ nr_mac->TX_req[CC_id].SFN = frameP;
+ nr_mac->TX_req[CC_id].Number_of_PDUs++;
+ nr_mac->TX_req[CC_id].Slot = slotP;
+
+ // Mark the corresponding RBs as used
+ for (int rb = 0; rb < pdsch_pdu_rel15->rbSize; rb++) {
+ vrb_map[rb + pdsch_pdu_rel15->rbStart] = 1;
+ }
+
+ LOG_D(NR_MAC,"BWPSize: %i\n", pdcch_pdu_rel15->BWPSize);
+ LOG_D(NR_MAC,"BWPStart: %i\n", pdcch_pdu_rel15->BWPStart);
+ LOG_D(NR_MAC,"SubcarrierSpacing: %i\n", pdcch_pdu_rel15->SubcarrierSpacing);
+ LOG_D(NR_MAC,"CyclicPrefix: %i\n", pdcch_pdu_rel15->CyclicPrefix);
+ LOG_D(NR_MAC,"StartSymbolIndex: %i\n", pdcch_pdu_rel15->StartSymbolIndex);
+ LOG_D(NR_MAC,"DurationSymbols: %i\n", pdcch_pdu_rel15->DurationSymbols);
+ for(int n=0;n<6;n++) LOG_D(NR_MAC,"FreqDomainResource[%i]: %x\n",n, pdcch_pdu_rel15->FreqDomainResource[n]);
+ LOG_D(NR_MAC,"CceRegMappingType: %i\n", pdcch_pdu_rel15->CceRegMappingType);
+ LOG_D(NR_MAC,"RegBundleSize: %i\n", pdcch_pdu_rel15->RegBundleSize);
+ LOG_D(NR_MAC,"InterleaverSize: %i\n", pdcch_pdu_rel15->InterleaverSize);
+ LOG_D(NR_MAC,"CoreSetType: %i\n", pdcch_pdu_rel15->CoreSetType);
+ LOG_D(NR_MAC,"ShiftIndex: %i\n", pdcch_pdu_rel15->ShiftIndex);
+ LOG_D(NR_MAC,"precoderGranularity: %i\n", pdcch_pdu_rel15->precoderGranularity);
+ LOG_D(NR_MAC,"numDlDci: %i\n", pdcch_pdu_rel15->numDlDci);
+
+ ra->state = WAIT_Msg4_ACK;
+ LOG_I(MAC,"[gNB %d][RAPROC] Frame %d, Subframe %d: RA state %d\n", module_idP, frameP, slotP, ra->state);
+ }
+}
+
+void nr_check_Msg4_Ack(module_id_t module_id, int CC_id, frame_t frame, sub_frame_t slot, NR_RA_t *ra) {
+
+ int UE_id = find_nr_UE_id(module_id, ra->rnti);
+ const int current_harq_pid = ra->harq_pid;
+
+ NR_UE_info_t *UE_info = &RC.nrmac[module_id]->UE_info;
+ NR_UE_harq_t *harq = &UE_info->UE_sched_ctrl[UE_id].harq_processes[current_harq_pid];
+
+ LOG_D(MAC, "ue %d, rnti %d, harq is waiting %d, round %d, frame %d %d, harq id %d\n", UE_id, ra->rnti, harq->is_waiting, harq->round, frame, slot, current_harq_pid);
+
+ if (harq->is_waiting == 0)
+ {
+ if (harq->round == 0)
+ {
+ ra->state = RA_IDLE;
+ UE_info->active[UE_id] = true;
+ free(ra->preambles.preamble_list);
+ LOG_I(NR_MAC, "(ue %i, rnti 0x%04x) Received Ack of RA-Msg4. RA procedure succeeded!\n", UE_id, ra->rnti);
+ }
+ else
+ {
+ ra->state = Msg4;
+ }
+ }
+
+}
+
void nr_clear_ra_proc(module_id_t module_idP, int CC_id, frame_t frameP){
NR_RA_t *ra = &RC.nrmac[module_idP]->common_channels[CC_id].ra[0];
LOG_D(MAC,"[gNB %d][RAPROC] CC_id %d Frame %d Clear Random access information rnti %x\n", module_idP, CC_id, frameP, ra->rnti);
- ra->state = IDLE;
+ ra->state = RA_IDLE;
ra->timing_offset = 0;
ra->RRC_timer = 20;
ra->rnti = 0;
@@ -1118,8 +1445,9 @@ void nr_fill_rar(uint8_t Mod_idP,
nfapi_nr_pusch_pdu_t *pusch_pdu){
LOG_I(MAC, "[gNB] Generate RAR MAC PDU frame %d slot %d preamble index %u TA command %d \n", ra->Msg2_frame, ra-> Msg2_slot, ra->preamble_index, ra->timing_offset);
- NR_RA_HEADER_RAPID *rarh = (NR_RA_HEADER_RAPID *) dlsch_buffer;
- NR_MAC_RAR *rar = (NR_MAC_RAR *) (dlsch_buffer + 1);
+ NR_RA_HEADER_BI *rarbi = (NR_RA_HEADER_BI *) dlsch_buffer;
+ NR_RA_HEADER_RAPID *rarh = (NR_RA_HEADER_RAPID *) (dlsch_buffer + 1);
+ NR_MAC_RAR *rar = (NR_MAC_RAR *) (dlsch_buffer + 2);
unsigned char csi_req = 0, tpc_command;
//uint8_t N_UL_Hop;
uint8_t valid_bits;
@@ -1128,6 +1456,16 @@ void nr_fill_rar(uint8_t Mod_idP,
tpc_command = 3; // this is 0 dB
+ /// E/T/R/R/BI subheader ///
+ // E = 1, MAC PDU includes another MAC sub-PDU (RAPID)
+ // T = 0, Back-off indicator subheader
+ // R = 2, Reserved
+ // BI = 0, 5ms
+ rarbi->E = 1;
+ rarbi->T = 0;
+ rarbi->R = 0;
+ rarbi->BI = 0;
+
/// E/T/RAPID subheader ///
// E = 0, one only RAR, first and last
// T = 1, RAPID
@@ -1174,4 +1512,49 @@ void nr_fill_rar(uint8_t Mod_idP,
rar->UL_GRANT_3 = (uint8_t) (ul_grant >> 8) & 0xff;
rar->UL_GRANT_4 = (uint8_t) ul_grant & 0xff;
+ // FIXME: To be removed
+ //LOG_I(NR_MAC, "rarbi->E = 0x%x\n", rarbi->E);
+ //LOG_I(NR_MAC, "rarbi->T = 0x%x\n", rarbi->T);
+ //LOG_I(NR_MAC, "rarbi->R = 0x%x\n", rarbi->R);
+ //LOG_I(NR_MAC, "rarbi->BI = 0x%x\n", rarbi->BI);
+
+ LOG_I(NR_MAC, "rarh->E = 0x%x\n", rarh->E);
+ LOG_I(NR_MAC, "rarh->T = 0x%x\n", rarh->T);
+ LOG_I(NR_MAC, "rarh->RAPID = 0x%x (%i)\n", rarh->RAPID, rarh->RAPID);
+
+ LOG_I(NR_MAC, "rar->R = 0x%x\n", rar->R);
+ LOG_I(NR_MAC, "rar->TA1 = 0x%x\n", rar->TA1);
+
+ LOG_I(NR_MAC, "rar->TA2 = 0x%x\n", rar->TA2);
+ LOG_I(NR_MAC, "rar->UL_GRANT_1 = 0x%x\n", rar->UL_GRANT_1);
+
+ LOG_I(NR_MAC, "rar->UL_GRANT_2 = 0x%x\n", rar->UL_GRANT_2);
+ LOG_I(NR_MAC, "rar->UL_GRANT_3 = 0x%x\n", rar->UL_GRANT_3);
+ LOG_I(NR_MAC, "rar->UL_GRANT_4 = 0x%x\n", rar->UL_GRANT_4);
+
+ LOG_I(NR_MAC, "rar->TCRNTI_1 = 0x%x\n", rar->TCRNTI_1);
+ LOG_I(NR_MAC, "rar->TCRNTI_2 = 0x%x\n", rar->TCRNTI_2);
+
+ int mcs = (unsigned char) (rar->UL_GRANT_4 >> 4);
+ // time alloc
+ int Msg3_t_alloc = (unsigned char) (rar->UL_GRANT_3 & 0x07);
+ // frequency alloc
+ int Msg3_f_alloc = (uint16_t) ((rar->UL_GRANT_3 >> 4) | (rar->UL_GRANT_2 << 4) | ((rar->UL_GRANT_1 & 0x03) << 12));
+ // frequency hopping
+ int freq_hopping = (unsigned char) (rar->UL_GRANT_1 >> 2);
+ // TA command
+ int ta_command = rar->TA2 + (rar->TA1 << 5);
+ // TC-RNTI
+ int t_crnti = rar->TCRNTI_2 + (rar->TCRNTI_1 << 8);
+
+ LOG_I(NR_MAC, "In %s: Transmitted 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",
+ __FUNCTION__,
+ Msg3_t_alloc,
+ Msg3_f_alloc,
+ ta_command,
+ mcs,
+ freq_hopping,
+ tpc_command,
+ csi_req,
+ t_crnti);
}
diff --git a/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_bch.c b/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_bch.c
index 1de46aaea4..51df483995 100644
--- a/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_bch.c
+++ b/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_bch.c
@@ -113,7 +113,7 @@ void schedule_nr_mib(module_id_t module_idP, frame_t frameP, sub_frame_t slotP,
dl_tti_request = &gNB->DL_req[CC_id];
dl_req = &dl_tti_request->dl_tti_request_body;
- mib_sdu_length = mac_rrc_nr_data_req(module_idP, CC_id, frameP, MIBCH, 1, &cc->MIB_pdu.payload[0]);
+ mib_sdu_length = mac_rrc_nr_data_req(module_idP, CC_id, frameP, MIBCH, 0, 1, &cc->MIB_pdu.payload[0]);
LOG_D(MAC, "Frame %d, slot %d: BCH PDU length %d\n", frameP, slotP, mib_sdu_length);
@@ -235,6 +235,7 @@ void schedule_control_sib1(module_id_t module_id,
int time_domain_allocation,
uint8_t mcsTableIdx,
uint8_t mcs,
+ uint8_t candidate_idx,
int num_total_bytes) {
gNB_MAC_INST *gNB_mac = RC.nrmac[module_id];
@@ -242,9 +243,9 @@ void schedule_control_sib1(module_id_t module_id,
uint16_t *vrb_map = RC.nrmac[module_id]->common_channels[CC_id].vrb_map;
if (gNB_mac->sched_ctrlCommon == NULL){
+ LOG_D(MAC,"schedule_control_common: Filling nr_mca->sched_ctrlCommon\n");
gNB_mac->sched_ctrlCommon = calloc(1,sizeof(*gNB_mac->sched_ctrlCommon));
gNB_mac->sched_ctrlCommon->search_space = calloc(1,sizeof(*gNB_mac->sched_ctrlCommon->search_space));
- gNB_mac->sched_ctrlCommon->active_bwp = calloc(1,sizeof(*gNB_mac->sched_ctrlCommon->active_bwp));
gNB_mac->sched_ctrlCommon->coreset = calloc(1,sizeof(*gNB_mac->sched_ctrlCommon->coreset));
gNB_mac->sched_ctrlCommon->active_bwp = calloc(1,sizeof(*gNB_mac->sched_ctrlCommon->active_bwp));
fill_default_searchSpaceZero(gNB_mac->sched_ctrlCommon->search_space);
@@ -266,13 +267,10 @@ void schedule_control_sib1(module_id_t module_id,
gNB_mac->sched_ctrlCommon->coreset,
gNB_mac->sched_ctrlCommon->aggregation_level,
0,
- 0,
+ candidate_idx,
nr_of_candidates);
- if (gNB_mac->sched_ctrlCommon->cce_index < 0) {
- LOG_E(MAC, "%s(): could not find CCE for coreset0\n", __func__);
- return;
- }
+ AssertFatal(gNB_mac->sched_ctrlCommon->cce_index >= 0, "Could not find CCE for coreset0\n");
const uint16_t bwpSize = gNB_mac->type0_PDCCH_CSS_config.num_rbs;
int rbStart = gNB_mac->type0_PDCCH_CSS_config.cset_start_rb;
@@ -291,7 +289,7 @@ void schedule_control_sib1(module_id_t module_id,
// Calculate number of PRB_DMRS
uint8_t N_PRB_DMRS = gNB_mac->sched_ctrlCommon->numDmrsCdmGrpsNoData * 6;
- uint16_t dlDmrsSymbPos = fill_dmrs_mask(gNB_mac->sched_ctrlCommon->active_bwp->bwp_Dedicated->pdsch_Config->choice.setup, gNB_mac->common_channels->ServingCellConfigCommon->dmrs_TypeA_Position, startSymbolIndex+nrOfSymbols);
+ uint16_t dlDmrsSymbPos = fill_dmrs_mask(gNB_mac->sched_ctrlCommon->active_bwp->bwp_Dedicated->pdsch_Config->choice.setup, gNB_mac->common_channels->ServingCellConfigCommon->dmrs_TypeA_Position, nrOfSymbols, startSymbolIndex);
uint16_t dmrs_length = get_num_dmrs(dlDmrsSymbPos);
int rbSize = 0;
@@ -301,9 +299,7 @@ void schedule_control_sib1(module_id_t module_id,
TBS = nr_compute_tbs(nr_get_Qm_dl(gNB_mac->sched_ctrlCommon->mcs, gNB_mac->sched_ctrlCommon->mcsTableIdx),
nr_get_code_rate_dl(gNB_mac->sched_ctrlCommon->mcs, gNB_mac->sched_ctrlCommon->mcsTableIdx),
rbSize, nrOfSymbols, N_PRB_DMRS * dmrs_length,0, 0,1) >> 3;
-
- // FIXME: Something is not working in nr_modulation() for TBS = 84, so we need to skip it
- } while ( (rbStart + rbSize < bwpSize && !vrb_map[rbStart + rbSize] && TBS < gNB_mac->sched_ctrlCommon->num_total_bytes) || (TBS==84) );
+ } while (rbStart + rbSize < bwpSize && !vrb_map[rbStart + rbSize] && TBS < gNB_mac->sched_ctrlCommon->num_total_bytes);
gNB_mac->sched_ctrlCommon->rbSize = rbSize;
gNB_mac->sched_ctrlCommon->rbStart = 0;
@@ -344,6 +340,10 @@ void nr_fill_nfapi_dl_sib1_pdu(int Mod_idP,
scc,
bwp);
+ // TODO: This assignment should be done in function nr_configure_pdcch()
+ pdcch_pdu_rel15->BWPSize = gNB_mac->type0_PDCCH_CSS_config.num_rbs;
+ pdcch_pdu_rel15->BWPStart = gNB_mac->type0_PDCCH_CSS_config.cset_start_rb;
+
nfapi_nr_dl_tti_request_pdu_t *dl_tti_pdsch_pdu = &dl_req->dl_tti_pdu_list[dl_req->nPDUs];
memset((void*)dl_tti_pdsch_pdu,0,sizeof(nfapi_nr_dl_tti_request_pdu_t));
dl_tti_pdsch_pdu->PDUType = NFAPI_NR_DL_TTI_PDSCH_PDU_TYPE;
@@ -392,7 +392,7 @@ void nr_fill_nfapi_dl_sib1_pdu(int Mod_idP,
pdsch_pdu_rel15->StartSymbolIndex = StartSymbolIndex;
pdsch_pdu_rel15->NrOfSymbols = NrOfSymbols;
- pdsch_pdu_rel15->dlDmrsSymbPos = fill_dmrs_mask(bwp->bwp_Dedicated->pdsch_Config->choice.setup, scc->dmrs_TypeA_Position, pdsch_pdu_rel15->StartSymbolIndex+pdsch_pdu_rel15->NrOfSymbols);
+ pdsch_pdu_rel15->dlDmrsSymbPos = fill_dmrs_mask(bwp->bwp_Dedicated->pdsch_Config->choice.setup, scc->dmrs_TypeA_Position, pdsch_pdu_rel15->NrOfSymbols, pdsch_pdu_rel15->StartSymbolIndex);
LOG_D(MAC,"dlDmrsSymbPos = 0x%x\n", pdsch_pdu_rel15->dlDmrsSymbPos);
@@ -467,6 +467,7 @@ void schedule_nr_sib1(module_id_t module_idP, frame_t frameP, sub_frame_t slotP)
int time_domain_allocation = 0;
uint8_t mcsTableIdx = 0;
uint8_t mcs = 6;
+ uint8_t candidate_idx = 0;
gNB_MAC_INST *gNB_mac = RC.nrmac[module_idP];
@@ -476,13 +477,13 @@ void schedule_nr_sib1(module_id_t module_idP, frame_t frameP, sub_frame_t slotP)
// Get SIB1
uint8_t sib1_payload[NR_MAX_SIB_LENGTH/8];
- uint8_t sib1_sdu_length = mac_rrc_nr_data_req(module_idP, CC_id, frameP, BCCH, 1, sib1_payload);
+ uint8_t sib1_sdu_length = mac_rrc_nr_data_req(module_idP, CC_id, frameP, BCCH, 0, 1, sib1_payload);
LOG_D(MAC,"sib1_sdu_length = %i\n", sib1_sdu_length);
LOG_D(MAC,"SIB1: \n");
for (int i=0;isched_ctrlCommon->numDmrsCdmGrpsNoData * 6;
- uint16_t dlDmrsSymbPos = fill_dmrs_mask(gNB_mac->sched_ctrlCommon->active_bwp->bwp_Dedicated->pdsch_Config->choice.setup, gNB_mac->common_channels->ServingCellConfigCommon->dmrs_TypeA_Position, startSymbolIndex+nrOfSymbols);
+ uint16_t dlDmrsSymbPos = fill_dmrs_mask(gNB_mac->sched_ctrlCommon->active_bwp->bwp_Dedicated->pdsch_Config->choice.setup, gNB_mac->common_channels->ServingCellConfigCommon->dmrs_TypeA_Position, nrOfSymbols, startSymbolIndex);
uint16_t dmrs_length = get_num_dmrs(dlDmrsSymbPos);
const uint32_t TBS = nr_compute_tbs(nr_get_Qm_dl(gNB_mac->sched_ctrlCommon->mcs, gNB_mac->sched_ctrlCommon->mcsTableIdx),
diff --git a/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_dlsch.c b/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_dlsch.c
index f4d5c5d2b3..372062f59e 100644
--- a/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_dlsch.c
+++ b/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_dlsch.c
@@ -302,7 +302,7 @@ int nr_write_ce_dlsch_pdu(module_id_t module_idP,
return offset;
}
-int getNrOfSymbols(NR_BWP_Downlink_t *bwp, int tda) {
+void getStartNrOfSymbols(NR_BWP_Downlink_t *bwp, int tda, int *startSymbol, int *nrOfSymbols) {
struct NR_PDSCH_TimeDomainResourceAllocationList *tdaList =
bwp->bwp_Common->pdsch_ConfigCommon->choice.setup->pdsch_TimeDomainAllocationList;
AssertFatal(tda < tdaList->list.count,
@@ -311,9 +311,7 @@ int getNrOfSymbols(NR_BWP_Downlink_t *bwp, int tda) {
tdaList->list.count);
const int startSymbolAndLength = tdaList->list.array[tda]->startSymbolAndLength;
- int startSymbolIndex, nrOfSymbols;
- SLIV2SL(startSymbolAndLength, &startSymbolIndex, &nrOfSymbols);
- return nrOfSymbols;
+ SLIV2SL(startSymbolAndLength, startSymbol, nrOfSymbols);
}
nfapi_nr_dmrs_type_e getDmrsConfigType(NR_BWP_Downlink_t *bwp) {
@@ -500,8 +498,12 @@ void pf_dl(module_id_t module_id,
sched_ctrl->numDmrsCdmGrpsNoData = 1;
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 startSymbol;
+ int nrOfSymbols;
+ getStartNrOfSymbols(sched_ctrl->active_bwp,
+ sched_ctrl->time_domain_allocation,
+ &startSymbol,
+ &nrOfSymbols);
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),
1, // rbSize
@@ -587,13 +589,18 @@ void pf_dl(module_id_t module_id,
const uint8_t N_PRB_DMRS =
getN_PRB_DMRS(sched_ctrl->active_bwp, sched_ctrl->numDmrsCdmGrpsNoData);
- const int nrOfSymbols = getNrOfSymbols(sched_ctrl->active_bwp,
- sched_ctrl->time_domain_allocation);
+ int startSymbol;
+ int nrOfSymbols;
+ getStartNrOfSymbols(sched_ctrl->active_bwp,
+ sched_ctrl->time_domain_allocation,
+ &startSymbol,
+ &nrOfSymbols);
const NR_ServingCellConfigCommon_t *scc = RC.nrmac[module_id]->common_channels->ServingCellConfigCommon;
const uint8_t N_DMRS_SLOT = get_num_dmrs_symbols(
sched_ctrl->active_bwp->bwp_Dedicated->pdsch_Config->choice.setup,
scc->dmrs_TypeA_Position,
- nrOfSymbols);
+ nrOfSymbols,
+ startSymbol);
int rbSize = 0;
uint32_t TBS = 0;
@@ -710,7 +717,8 @@ void nr_schedule_ue_spec(module_id_t module_id,
getN_PRB_DMRS(sched_ctrl->active_bwp, sched_ctrl->numDmrsCdmGrpsNoData);
uint8_t N_DMRS_SLOT = get_num_dmrs_symbols(sched_ctrl->active_bwp->bwp_Dedicated->pdsch_Config->choice.setup,
RC.nrmac[module_id]->common_channels->ServingCellConfigCommon->dmrs_TypeA_Position ,
- nrOfSymbols);
+ nrOfSymbols,
+ startSymbolIndex);
const nfapi_nr_dmrs_type_e dmrsConfigType = getDmrsConfigType(sched_ctrl->active_bwp);
const int nrOfLayers = 1;
const uint16_t R = nr_get_code_rate_dl(sched_ctrl->mcs, sched_ctrl->mcsTableIdx);
@@ -831,7 +839,8 @@ void nr_schedule_ue_spec(module_id_t module_id,
pdsch_pdu->dlDmrsSymbPos =
fill_dmrs_mask(bwp->bwp_Dedicated->pdsch_Config->choice.setup,
scc->dmrs_TypeA_Position,
- nrOfSymbols);
+ nrOfSymbols,
+ startSymbolIndex);
pdsch_pdu->dmrsConfigType = dmrsConfigType;
pdsch_pdu->dlDmrsScramblingId = *scc->physCellId;
pdsch_pdu->SCID = 0;
@@ -1058,7 +1067,7 @@ void nr_schedule_ue_spec(module_id_t module_id,
size += 3;
}
}
- else if (get_softmodem_params()->phy_test || get_softmodem_params()->do_ra) {
+ else if (get_softmodem_params()->phy_test || get_softmodem_params()->do_ra || get_softmodem_params()->sa) {
/* we will need the large header, phy-test typically allocates all
* resources and fills to the last byte below */
NR_MAC_SUBHEADER_LONG *header = (NR_MAC_SUBHEADER_LONG *) buf;
diff --git a/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_phytest.c b/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_phytest.c
index 6487f391b9..bf8269132a 100644
--- a/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_phytest.c
+++ b/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_phytest.c
@@ -164,7 +164,8 @@ void nr_schedule_css_dlsch_phytest(module_id_t module_idP,
pdsch_pdu_rel15->NrOfSymbols = NrOfSymbols;
pdsch_pdu_rel15->dlDmrsSymbPos = fill_dmrs_mask(NULL,
scc->dmrs_TypeA_Position,
- NrOfSymbols);
+ NrOfSymbols,
+ StartSymbolIndex);
/*
AssertFatal(k0==0,"k0 is not zero for Initial DL BWP TimeDomain Alloc\n");
diff --git a/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_primitives.c b/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_primitives.c
index 20da8fa30a..d9948b64b8 100644
--- a/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_primitives.c
+++ b/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_primitives.c
@@ -1131,6 +1131,7 @@ void fill_dci_pdu_rel15(const NR_ServingCellConfigCommon_t *scc,
break;
case NR_RNTI_TC:
+ pos = 1;
// indicating a DL DCI format 1bit
*dci_pdu |= ((uint64_t)dci_pdu_rel15->format_indicator & 1) << (dci_size - pos++);
// Freq domain assignment 0-16 bit
@@ -1159,9 +1160,27 @@ void fill_dci_pdu_rel15(const NR_ServingCellConfigCommon_t *scc,
// TPC command for scheduled PUCCH – 2 bits
for (int i = 0; i < 2; i++)
*dci_pdu |= (((uint64_t)dci_pdu_rel15->tpc >> (1 - i)) & 1) << (dci_size - pos++);
+ // PUCCH resource indicator – 3 bits
+ for (int i = 0; i < 3; i++)
+ *dci_pdu |= (((uint64_t)dci_pdu_rel15->pucch_resource_indicator >> (2 - i)) & 1) << (dci_size - pos++);
// PDSCH-to-HARQ_feedback timing indicator – 3 bits
for (int i = 0; i < 3; i++)
*dci_pdu |= (((uint64_t)dci_pdu_rel15->pdsch_to_harq_feedback_timing_indicator.val >> (2 - i)) & 1) << (dci_size - pos++);
+
+ LOG_D(NR_MAC,"N_RB = %i\n", N_RB);
+ LOG_D(NR_MAC,"dci_size = %i\n", dci_size);
+ LOG_D(NR_MAC,"fsize = %i\n", fsize);
+ LOG_D(NR_MAC,"dci_pdu_rel15->format_indicator = %i\n", dci_pdu_rel15->format_indicator);
+ LOG_D(NR_MAC,"dci_pdu_rel15->frequency_domain_assignment.val = %i\n", dci_pdu_rel15->frequency_domain_assignment.val);
+ LOG_D(NR_MAC,"dci_pdu_rel15->time_domain_assignment.val = %i\n", dci_pdu_rel15->time_domain_assignment.val);
+ LOG_D(NR_MAC,"dci_pdu_rel15->vrb_to_prb_mapping.val = %i\n", dci_pdu_rel15->vrb_to_prb_mapping.val);
+ LOG_D(NR_MAC,"dci_pdu_rel15->mcs = %i\n", dci_pdu_rel15->mcs);
+ LOG_D(NR_MAC,"dci_pdu_rel15->rv = %i\n", dci_pdu_rel15->rv);
+ LOG_D(NR_MAC,"dci_pdu_rel15->harq_pid = %i\n", dci_pdu_rel15->harq_pid);
+ LOG_D(NR_MAC,"dci_pdu_rel15->dai[0].val = %i\n", dci_pdu_rel15->dai[0].val);
+ LOG_D(NR_MAC,"dci_pdu_rel15->tpc = %i\n", dci_pdu_rel15->tpc);
+ LOG_D(NR_MAC,"dci_pdu_rel15->pdsch_to_harq_feedback_timing_indicator.val = %i\n", dci_pdu_rel15->pdsch_to_harq_feedback_timing_indicator.val);
+
break;
}
break;
@@ -1679,7 +1698,7 @@ int add_new_nr_ue(module_id_t mod_idP, rnti_t rntiP, NR_CellGroupConfig_t *secon
add_tail_nr_list(&sched_ctrl->available_ul_harq, harq);
create_nr_list(&sched_ctrl->feedback_ul_harq, 16);
create_nr_list(&sched_ctrl->retrans_ul_harq, 16);
- LOG_I(MAC, "gNB %d] Add NR UE_id %d : rnti %x\n",
+ LOG_I(MAC, "[gNB %d] Add NR UE_id %d : rnti %x\n",
mod_idP,
UE_id,
rntiP);
diff --git a/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_uci.c b/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_uci.c
index 629b4dc7b0..4c7e063a0f 100644
--- a/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_uci.c
+++ b/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_uci.c
@@ -164,7 +164,7 @@ void compute_csi_bitlen (NR_CellGroupConfig_t *secondaryCellGroup, NR_UE_info_t
UE_info->csi_report_template[UE_id][csi_report_id].CSI_report_bitlen[0].diff_rsrp_bitlen =0;
}
- LOG_I (MAC, "UCI: CSI_bit len : ssbri %d, rsrp: %d, diff_rsrp: %d\n",
+ LOG_D (MAC, "UCI: CSI_bit len : ssbri %d, rsrp: %d, diff_rsrp: %d\n",
UE_info->csi_report_template[UE_id][csi_report_id].CSI_report_bitlen[0].cri_ssbri_bitlen,
UE_info->csi_report_template[UE_id][csi_report_id].CSI_report_bitlen[0].rsrp_bitlen,
UE_info->csi_report_template[UE_id][csi_report_id].CSI_report_bitlen[0].diff_rsrp_bitlen);
diff --git a/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_ulsch.c b/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_ulsch.c
index b2a69db179..298f1253d3 100644
--- a/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_ulsch.c
+++ b/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_ulsch.c
@@ -255,13 +255,20 @@ void nr_process_mac_pdu(
case UL_SCH_LCID_SRB3:
// todo
break;
- case UL_SCH_LCID_CCCH_MSG3:
- // todo
- break;
case UL_SCH_LCID_CCCH:
- // todo
- mac_subheader_len = 2;
- break;
+ mac_subheader_len = 1;
+ nr_mac_rrc_data_ind(module_idP,
+ CC_id,
+ frameP,
+ 0,
+ 0,
+ rnti,
+ CCCH,
+ pdu_ptr+mac_subheader_len,
+ pdu_len-mac_subheader_len,
+ 0);
+ break;
+
case UL_SCH_LCID_DTCH:
// check if LCID is valid at current time.
if(((NR_MAC_SUBHEADER_SHORT *)pdu_ptr)->F){
@@ -346,8 +353,16 @@ void handle_nr_ul_harq(module_id_t mod_id,
return;
remove_front_nr_list(&sched_ctrl->feedback_ul_harq);
- sched_ctrl->ul_harq_processes[harq_pid].round++;
- add_tail_nr_list(&sched_ctrl->retrans_ul_harq, harq_pid);
+ sched_ctrl->ul_harq_processes[harq_pid].is_waiting = false;
+ if(sched_ctrl->ul_harq_processes[harq_pid].round == MAX_HARQ_ROUNDS) {
+ sched_ctrl->ul_harq_processes[harq_pid].ndi ^= 1;
+ sched_ctrl->ul_harq_processes[harq_pid].round = 0;
+ UE_info->mac_stats[UE_id].ulsch_errors++;
+ add_tail_nr_list(&sched_ctrl->available_ul_harq, harq_pid);
+ } else {
+ sched_ctrl->ul_harq_processes[harq_pid].round++;
+ add_tail_nr_list(&sched_ctrl->retrans_ul_harq, harq_pid);
+ }
harq_pid = sched_ctrl->feedback_ul_harq.head;
}
remove_front_nr_list(&sched_ctrl->feedback_ul_harq);
@@ -412,7 +427,7 @@ void nr_rx_sdu(const module_id_t gnb_mod_idP,
T_BUFFER(sduP, 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 sduP %p\n",
+ LOG_D(NR_MAC, "[gNB %d][PUSCH %d] CC_id %d %d.%d Received ULSCH sdu from PHY (rnti %x, UE_id %d) ul_cqi %d sduP %p\n",
gnb_mod_idP,
harq_pid,
CC_idP,
@@ -429,7 +444,7 @@ void nr_rx_sdu(const module_id_t gnb_mod_idP,
if (timing_advance != 0xffff)
UE_scheduling_control->ta_update = timing_advance;
UE_scheduling_control->ul_rssi = rssi;
- LOG_D(MAC, "[UE %d] PUSCH TPC %d and TA %d\n",UE_id,UE_scheduling_control->tpc0,UE_scheduling_control->ta_update);
+ LOG_D(NR_MAC, "[UE %d] PUSCH TPC %d and TA %d\n",UE_id,UE_scheduling_control->tpc0,UE_scheduling_control->ta_update);
}
else{
UE_scheduling_control->tpc0 = 1;
@@ -448,7 +463,7 @@ void nr_rx_sdu(const module_id_t gnb_mod_idP,
#endif
if (sduP != NULL){
- LOG_D(MAC, "Received PDU at MAC gNB \n");
+ LOG_D(NR_MAC, "Received PDU at MAC gNB \n");
const uint32_t tb_size = UE_scheduling_control->ul_harq_processes[harq_pid].sched_pusch.tb_size;
UE_scheduling_control->sched_ul_bytes -= tb_size;
@@ -467,9 +482,19 @@ void nr_rx_sdu(const module_id_t gnb_mod_idP,
UE_scheduling_control->sched_ul_bytes = 0;
}
}
- } else {
- if (!sduP) // check that CRC passed
- return;
+ } else if(sduP) {
+
+ bool no_sig = true;
+ for (int k = 0; k < sdu_lenP; k++) {
+ if(sduP[k]!=0) {
+ no_sig = false;
+ break;
+ }
+ }
+
+ if(no_sig) {
+ LOG_W(NR_MAC, "No signal\n");
+ }
T(T_GNB_MAC_UL_PDU_WITH_DATA, T_INT(gnb_mod_idP), T_INT(CC_idP),
T_INT(rntiP), T_INT(frameP), T_INT(slotP), T_INT(-1) /* harq_pid */,
@@ -483,34 +508,67 @@ void nr_rx_sdu(const module_id_t gnb_mod_idP,
if (ra->state != WAIT_Msg3)
continue;
- // random access pusch with TC-RNTI
- if (ra->rnti != current_rnti) {
- LOG_W(MAC,
- "expected TC-RNTI %04x to match current RNTI %04x\n",
- ra->rnti,
- current_rnti);
- continue;
+ if(no_sig) {
+ LOG_W(NR_MAC, "Random Access %i failed at state %i\n", i, ra->state);
+ ra->state = RA_IDLE;
+ ra->timing_offset = 0;
+ ra->RRC_timer = 20;
+ ra->msg3_round = 0;
+ } else {
+
+ // random access pusch with TC-RNTI
+ if (ra->rnti != current_rnti) {
+ LOG_W(NR_MAC,
+ "expected TC-RNTI %04x to match current RNTI %04x\n",
+ ra->rnti,
+ current_rnti);
+ continue;
+ }
+ const int UE_id = add_new_nr_ue(gnb_mod_idP, ra->rnti, ra->secondaryCellGroup);
+ UE_info->UE_beam_index[UE_id] = ra->beam_id;
+ LOG_I(NR_MAC,
+ "[gNB %d][RAPROC] PUSCH with TC-RNTI %x received correctly, "
+ "adding UE MAC Context UE_id %d/RNTI %04x\n",
+ gnb_mod_idP,
+ current_rnti,
+ UE_id,
+ ra->rnti);
+
+ LOG_I(NR_MAC,"[RAPROC] RA-Msg3 received (len sdu_lenP %d)\n",sdu_lenP);
+ LOG_D(NR_MAC,"[RAPROC] Received Msg3:\n");
+ for (int k = 0; k < sdu_lenP; k++) {
+ LOG_I(NR_MAC,"(%i): 0x%x\n",k,sduP[k]);
+ }
+
+ // UE Contention Resolution Identity
+ // Store the first 48 bits belonging to the uplink CCCH SDU within Msg3 to fill in Msg4
+ // First byte corresponds to R/LCID MAC sub-header
+ memcpy(ra->cont_res_id, &sduP[1], sizeof(uint8_t) * 6);
+
+ // re-initialize ta update variables afrer RA procedure completion
+ UE_info->UE_sched_ctrl[UE_id].ta_frame = frameP;
+
+ nr_process_mac_pdu(gnb_mod_idP, current_rnti, CC_idP, frameP, sduP, sdu_lenP);
+
+ ra->state = Msg4;
+ ra->Msg4_frame = ( frameP +2 ) % 1024;
+ ra->Msg4_slot = 1;
+ LOG_I(MAC, "Scheduling RA-Msg4 for TC-RNTI %04x (state %d, frame %d, slot %d)\n", ra->rnti, ra->state, ra->Msg4_frame, ra->Msg4_slot);
+ return;
+
}
- const int UE_id = add_new_nr_ue(gnb_mod_idP, ra->rnti, ra->secondaryCellGroup);
- UE_info->UE_beam_index[UE_id] = ra->beam_id;
- LOG_I(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->rnti);
- // re-initialize ta update variables afrer RA procedure completion
- UE_info->UE_sched_ctrl[UE_id].ta_frame = frameP;
+ }
+ } else {
+ for (int i = 0; i < NR_NB_RA_PROC_MAX; ++i) {
+ NR_RA_t *ra = &gNB_mac->common_channels[CC_idP].ra[i];
+ if (ra->state != WAIT_Msg3)
+ continue;
- free(ra->preambles.preamble_list);
+ LOG_W(NR_MAC, "Random Access %i failed at state %i\n", i, ra->state);
ra->state = RA_IDLE;
- LOG_I(MAC,
- "reset RA state information for RA-RNTI %04x/index %d\n",
- ra->rnti,
- i);
-
- return;
+ ra->timing_offset = 0;
+ ra->RRC_timer = 20;
+ ra->msg3_round = 0;
}
}
}
diff --git a/openair2/LAYER2/NR_MAC_gNB/mac_proto.h b/openair2/LAYER2/NR_MAC_gNB/mac_proto.h
index 3502a11580..823e374ceb 100644
--- a/openair2/LAYER2/NR_MAC_gNB/mac_proto.h
+++ b/openair2/LAYER2/NR_MAC_gNB/mac_proto.h
@@ -73,6 +73,7 @@ void schedule_control_sib1(module_id_t module_id,
int time_domain_allocation,
uint8_t mcsTableIdx,
uint8_t mcs,
+ uint8_t candidate_idx,
int num_total_bytes);
void schedule_nr_sib1(module_id_t module_idP, frame_t frameP, sub_frame_t subframeP);
@@ -346,8 +347,18 @@ void config_nr_mib(int Mod_idP,
int cellBarred,
int intraFreqReselection);
+int nr_write_ce_dlsch_pdu(module_id_t module_idP,
+ const NR_UE_sched_ctrl_t *ue_sched_ctl,
+ unsigned char *mac_pdu,
+ unsigned char drx_cmd,
+ unsigned char *ue_cont_res_id);
+
void nr_generate_Msg2(module_id_t module_idP, int CC_id, frame_t frameP, sub_frame_t slotP, NR_RA_t *ra);
+void nr_generate_Msg4(module_id_t module_idP, int CC_id, frame_t frameP, sub_frame_t slotP, NR_RA_t *ra);
+
+void nr_check_Msg4_Ack(module_id_t module_id, int CC_id, frame_t frame, sub_frame_t slot, NR_RA_t *ra);
+
void nr_process_mac_pdu(
module_id_t module_idP,
rnti_t rnti,
diff --git a/openair2/LAYER2/NR_MAC_gNB/main.c b/openair2/LAYER2/NR_MAC_gNB/main.c
index 2c156bb571..33e575d2b9 100644
--- a/openair2/LAYER2/NR_MAC_gNB/main.c
+++ b/openair2/LAYER2/NR_MAC_gNB/main.c
@@ -96,7 +96,7 @@ void mac_top_init_gNB(void)
// These should be out of here later
pdcp_layer_init();
- // if(IS_SOFTMODEM_NOS1 && !get_softmodem_params()->do_ra)
+ if(IS_SOFTMODEM_NOS1 && !(get_softmodem_params()->do_ra || get_softmodem_params()->sa) )
nr_DRB_preconfiguration(0x1234);
rrc_init_nr_global_param();
diff --git a/openair2/LAYER2/NR_MAC_gNB/nr_mac_gNB.h b/openair2/LAYER2/NR_MAC_gNB/nr_mac_gNB.h
index 63587d58a4..cc8a48313a 100644
--- a/openair2/LAYER2/NR_MAC_gNB/nr_mac_gNB.h
+++ b/openair2/LAYER2/NR_MAC_gNB/nr_mac_gNB.h
@@ -80,6 +80,7 @@
#define NR_NB_RA_PROC_MAX 4
#define MAX_NUM_OF_SSB 64
+
/*! \brief NR_list_t is a "list" (of users, HARQ processes, slices, ...).
* Especially useful in the scheduler and to keep "classes" of users. */
typedef struct {
diff --git a/openair2/LAYER2/nr_pdcp/nr_pdcp_oai_api.c b/openair2/LAYER2/nr_pdcp/nr_pdcp_oai_api.c
index d7ee5292d0..194004ab8b 100644
--- a/openair2/LAYER2/nr_pdcp/nr_pdcp_oai_api.c
+++ b/openair2/LAYER2/nr_pdcp/nr_pdcp_oai_api.c
@@ -114,7 +114,7 @@ nr_rrc_data_ind(
//------------------------------------------------------------------------------
{
rb_id_t DCCH_index = Srb_id;
- LOG_I(RRC, "[UE %x] Frame %d: received a DCCH %ld message on SRB %ld with Size %d from eNB %d\n",
+ LOG_I(NR_RRC, "[UE %x] Frame %d: received a DCCH %ld message on SRB %ld with Size %d from gNB %d\n",
ctxt_pP->module_id, ctxt_pP->frame, DCCH_index,Srb_id,sdu_sizeP, ctxt_pP->eNB_index);
{
MessageDef *message_p;
@@ -509,12 +509,12 @@ uint64_t pdcp_module_init(uint64_t _pdcp_optmask)
netlink_init_tun("ue",num_if);
//Add --nr-ip-over-lte option check for next line
if (IS_SOFTMODEM_NOS1)
- nas_config(1, 1, 2, "ue");
+ nas_config(1, 0, 1, "ue");
LOG_I(PDCP, "UE pdcp will use tun interface\n");
start_pdcp_tun_ue();
} else if(ENB_NAS_USE_TUN) {
netlink_init_tun("enb",1);
- nas_config(1, 1, 1, "enb");
+ nas_config(1, 0, 2, "enb");// set the node IP to X.X.0.2 because UE's IP is X.X.0.1
LOG_I(PDCP, "ENB pdcp will use tun interface\n");
start_pdcp_tun_enb();
} else {
@@ -537,7 +537,7 @@ static void deliver_sdu_drb(void *_ue, nr_pdcp_entity_t *entity,
int rb_id = 0;
int i;
- if (ENB_NAS_USE_TUN_BIT || UE_NAS_USE_TUN_BIT){
+ if (IS_SOFTMODEM_NOS1) {
len = write(nas_sock_fd[0], buf, size);
if (len != size) {
LOG_E(PDCP, "%s:%d:%s: fatal\n", __FILE__, __LINE__, __FUNCTION__);
@@ -560,18 +560,28 @@ static void deliver_sdu_drb(void *_ue, nr_pdcp_entity_t *entity,
size + GTPU_HEADER_OVERHEAD_MAX);
AssertFatal(gtpu_buffer_p != NULL, "OUT OF MEMORY");
memcpy(>pu_buffer_p[GTPU_HEADER_OVERHEAD_MAX], buf, size);
- message_p = itti_alloc_new_message(TASK_PDCP_ENB, 0, GTPV1U_ENB_TUNNEL_DATA_REQ);
- AssertFatal(message_p != NULL, "OUT OF MEMORY");
- GTPV1U_ENB_TUNNEL_DATA_REQ(message_p).buffer = gtpu_buffer_p;
- GTPV1U_ENB_TUNNEL_DATA_REQ(message_p).length = size;
- 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;
- 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);
-
+ if (NODE_IS_CU(RC.nrrrc[0]->node_type) || (RC.nrrrc[0]->node_type == ngran_gNB)) {
+ message_p = itti_alloc_new_message(TASK_PDCP_ENB, 0, GTPV1U_GNB_TUNNEL_DATA_REQ);
+ GTPV1U_GNB_TUNNEL_DATA_REQ(message_p).buffer = gtpu_buffer_p;
+ GTPV1U_GNB_TUNNEL_DATA_REQ(message_p).length = size;
+ GTPV1U_GNB_TUNNEL_DATA_REQ(message_p).offset = GTPU_HEADER_OVERHEAD_MAX;
+ GTPV1U_GNB_TUNNEL_DATA_REQ(message_p).rnti = ue->rnti;
+ GTPV1U_GNB_TUNNEL_DATA_REQ(message_p).pdusession_id = 10;
+ LOG_D(PDCP, "%s() (drb %d) sending message to gtp size %d, rnti %d \n", __func__, rb_id, size, ue->rnti);
+ itti_send_msg_to_task(TASK_GTPV1_U, INSTANCE_DEFAULT, message_p);
+ } else {
+ message_p = itti_alloc_new_message(TASK_PDCP_ENB, 0, GTPV1U_ENB_TUNNEL_DATA_REQ);
+ AssertFatal(message_p != NULL, "OUT OF MEMORY");
+ GTPV1U_ENB_TUNNEL_DATA_REQ(message_p).buffer = gtpu_buffer_p;
+ GTPV1U_ENB_TUNNEL_DATA_REQ(message_p).length = size;
+ 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;
+ 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);
+ }
}
}
diff --git a/openair2/NR_PHY_INTERFACE/NR_IF_Module.c b/openair2/NR_PHY_INTERFACE/NR_IF_Module.c
index b183b32aab..63cc0cf0de 100644
--- a/openair2/NR_PHY_INTERFACE/NR_IF_Module.c
+++ b/openair2/NR_PHY_INTERFACE/NR_IF_Module.c
@@ -56,7 +56,7 @@ extern uint16_t sl_ahead;
void handle_nr_rach(NR_UL_IND_t *UL_info) {
if (UL_info->rach_ind.number_of_pdus>0) {
- LOG_I(MAC,"UL_info[Frame %d, Slot %d] Calling initiate_ra_proc RACH:SFN/SLOT:%d/%d\n",UL_info->frame,UL_info->slot, UL_info->rach_ind.sfn,UL_info->rach_ind.slot);
+ LOG_D(MAC,"UL_info[Frame %d, Slot %d] Calling initiate_ra_proc RACH:SFN/SLOT:%d/%d\n",UL_info->frame,UL_info->slot, UL_info->rach_ind.sfn,UL_info->rach_ind.slot);
int npdus = UL_info->rach_ind.number_of_pdus;
for(int i = 0; i < npdus; i++) {
UL_info->rach_ind.number_of_pdus--;
diff --git a/openair2/NR_UE_PHY_INTERFACE/NR_IF_Module.c b/openair2/NR_UE_PHY_INTERFACE/NR_IF_Module.c
index edaef6d1ce..dfbbd0db6b 100644
--- a/openair2/NR_UE_PHY_INTERFACE/NR_IF_Module.c
+++ b/openair2/NR_UE_PHY_INTERFACE/NR_IF_Module.c
@@ -62,7 +62,7 @@ int handle_bcch_bch(module_id_t module_id, int cc_id, unsigned int gNB_index, ui
// L2 Abstraction Layer
int handle_bcch_dlsch(module_id_t module_id, int cc_id, unsigned int gNB_index, uint32_t sibs_mask, uint8_t *pduP, uint32_t pdu_len){
- return nr_ue_decode_sib1(module_id, cc_id, gNB_index, sibs_mask, pduP, pdu_len);
+ return nr_ue_decode_BCCH_DL_SCH(module_id, cc_id, gNB_index, sibs_mask, pduP, pdu_len);
}
// L2 Abstraction Layer
diff --git a/openair2/RRC/NAS/nas_config.c b/openair2/RRC/NAS/nas_config.c
index 2eb439b9e9..dc12e96830 100644
--- a/openair2/RRC/NAS/nas_config.c
+++ b/openair2/RRC/NAS/nas_config.c
@@ -61,9 +61,9 @@ void nas_getparams(void) {
/* configuration parameters for netlink, includes network parameters when running in noS1 mode */
/* optname helpstr paramflags XXXptr defXXXval type numelt */
/*--------------------------------------------------------------------------------------------------------------------------------------------------------------------*/
- {"NetworkPrefix", NASHLP_NETPREFIX, 0, strptr:&baseNetAddress, defstrval:"10.0", TYPE_STRING, 0 },
+ {"NetworkPrefix", NASHLP_NETPREFIX, 0, strptr:&baseNetAddress, defstrval:"60.60", TYPE_STRING, 0 },
{"NetworkMask", NASHLP_NETMASK, 0, strptr:&netMask, defstrval:"255.255.255.0", TYPE_STRING, 0 },
- {"BroadcastAddr", NASHLP_BROADCASTADDR, 0, strptr:&broadcastAddr, defstrval:"10.0.255.255", TYPE_STRING, 0 },
+ {"BroadcastAddr", NASHLP_BROADCASTADDR, 0, strptr:&broadcastAddr, defstrval:"60.60.255.255", TYPE_STRING, 0 },
};
config_get( nasoptions,sizeof(nasoptions)/sizeof(paramdef_t),"nas.noS1");
}
diff --git a/openair2/RRC/NR/L2_nr_interface.c b/openair2/RRC/NR/L2_nr_interface.c
index ec249293eb..ef8ba267d5 100644
--- a/openair2/RRC/NR/L2_nr_interface.c
+++ b/openair2/RRC/NR/L2_nr_interface.c
@@ -42,6 +42,7 @@
#include "NR_MIB.h"
#include "NR_BCCH-BCH-Message.h"
+#include "rrc_gNB_UE_context.h"
extern RAN_CONTEXT_t RC;
@@ -217,29 +218,22 @@ int8_t mac_rrc_nr_data_req(const module_id_t Mod_idP,
const int CC_id,
const frame_t frameP,
const rb_id_t Srb_id,
+ const rnti_t rnti,
const uint8_t Nb_tb,
uint8_t *const buffer_pP ){
- asn_enc_rval_t enc_rval;
- uint8_t Sdu_size = 0;
- uint8_t sfn_msb = (uint8_t)((frameP>>4)&0x3f);
-
#ifdef DEBUG_RRC
LOG_D(RRC,"[eNB %d] mac_rrc_data_req to SRB ID=%ld\n",Mod_idP,Srb_id);
#endif
- rrc_gNB_carrier_data_t *carrier;
- NR_BCCH_BCH_Message_t *mib;
- NR_SRB_INFO *srb_info;
- char payload_size, *payload_pP;
-
- carrier = &RC.nrrrc[Mod_idP]->carrier;
- mib = &carrier->mib;
- srb_info = &carrier->Srb0;
-
- /* MIBCH */
+ // MIBCH
if ((Srb_id & RAB_OFFSET) == MIBCH) {
+ asn_enc_rval_t enc_rval;
+ uint8_t sfn_msb = (uint8_t)((frameP>>4)&0x3f);
+ rrc_gNB_carrier_data_t *carrier = &RC.nrrrc[Mod_idP]->carrier;
+ NR_BCCH_BCH_Message_t *mib = &carrier->mib;
+
// Currently we are getting the pdcch_ConfigSIB1 from the configuration file.
// Uncomment this function for a dynamic pdcch_ConfigSIB1.
//channel_bandwidth_t min_channel_bw = bw_10MHz; // Must be obtained based on TS 38.101-1 Table 5.3.5-1
@@ -269,7 +263,7 @@ int8_t mac_rrc_nr_data_req(const module_id_t Mod_idP,
return (3);
}
- /* TODO BCCH SIB1 SIBs */
+ // TODO BCCH SIB1 SIBs
if ((Srb_id & RAB_OFFSET ) == BCCH) {
memcpy(&buffer_pP[0],
RC.nrrrc[Mod_idP]->carrier.SIB1,
@@ -278,25 +272,25 @@ int8_t mac_rrc_nr_data_req(const module_id_t Mod_idP,
return RC.nrrrc[Mod_idP]->carrier.sizeof_SIB1;
}
- /* CCCH */
+ // CCCH
if( (Srb_id & RAB_OFFSET ) == CCCH) {
- //struct rrc_eNB_ue_context_s *ue_context_p = rrc_eNB_get_ue_context(RC.rrc[Mod_idP],rnti);
- //if (ue_context_p == NULL) return(0);
- //eNB_RRC_UE_t *ue_p = &ue_context_p->ue_context;
- LOG_D(RRC,"[gNB %d] Frame %d CCCH request (Srb_id %ld)\n", Mod_idP, frameP, Srb_id);
- // srb_info=&ue_p->Srb0;
+ char *payload_pP;
+ uint8_t Sdu_size = 0;
+ struct rrc_gNB_ue_context_s *ue_context_p = rrc_gNB_get_ue_context(RC.nrrrc[Mod_idP], rnti);
- payload_size = srb_info->Tx_buffer.payload_size;
+ LOG_D(NR_RRC,"[gNB %d] Frame %d CCCH request (Srb_id %ld)\n", Mod_idP, frameP, Srb_id);
+
+ char payload_size = ue_context_p->ue_context.Srb0.Tx_buffer.payload_size;
// check if data is there for MAC
if (payload_size > 0) {
- payload_pP = srb_info->Tx_buffer.Payload;
- LOG_D(RRC,"[gNB %d] CCCH (%p) has %d bytes (dest: %p, src %p)\n", Mod_idP, srb_info, payload_size, buffer_pP, payload_pP);
+ payload_pP = ue_context_p->ue_context.Srb0.Tx_buffer.Payload;
+ LOG_D(NR_RRC,"[gNB %d] CCCH has %d bytes (dest: %p, src %p)\n", Mod_idP, payload_size, buffer_pP, payload_pP);
// Fill buffer
memcpy((void *)buffer_pP, (void*)payload_pP, payload_size);
Sdu_size = payload_size;
- srb_info->Tx_buffer.payload_size = 0;
+ ue_context_p->ue_context.Srb0.Tx_buffer.payload_size = 0;
}
return Sdu_size;
}
@@ -304,3 +298,43 @@ int8_t mac_rrc_nr_data_req(const module_id_t Mod_idP,
return(0);
}
+
+int8_t nr_mac_rrc_data_ind(const module_id_t module_idP,
+ const int CC_id,
+ const frame_t frameP,
+ const sub_frame_t sub_frameP,
+ const int UE_id,
+ const rnti_t rntiP,
+ const rb_id_t srb_idP,
+ const uint8_t *sduP,
+ const sdu_size_t sdu_lenP,
+ const boolean_t brOption) {
+
+ if (NODE_IS_DU(RC.nrrrc[module_idP]->node_type)) {
+ LOG_W(RRC,"[DU %d][RAPROC] Received SDU for CCCH on SRB %ld length %d for UE id %d RNTI %x \n",
+ module_idP, srb_idP, sdu_lenP, UE_id, rntiP);
+ /* do ITTI message */
+ DU_send_INITIAL_UL_RRC_MESSAGE_TRANSFER(
+ module_idP,
+ CC_id,
+ UE_id,
+ rntiP,
+ sduP,
+ sdu_lenP
+ );
+ return(0);
+ }
+
+ protocol_ctxt_t ctxt;
+ PROTOCOL_CTXT_SET_BY_MODULE_ID(&ctxt, module_idP, GNB_FLAG_YES, rntiP, frameP, sub_frameP,0);
+
+ if((srb_idP & RAB_OFFSET) == CCCH) {
+ LOG_D(NR_RRC, "[gNB %d] Received SDU for CCCH on SRB %ld\n", module_idP, srb_idP);
+ ctxt.brOption = brOption;
+ if (sdu_lenP > 0) {
+ nr_rrc_gNB_decode_ccch(&ctxt, sduP, sdu_lenP, CC_id);
+ }
+ }
+
+ return 0;
+}
diff --git a/openair2/RRC/NR/MESSAGES/asn1_msg.c b/openair2/RRC/NR/MESSAGES/asn1_msg.c
index 68b490d997..63bf1c320d 100644
--- a/openair2/RRC/NR/MESSAGES/asn1_msg.c
+++ b/openair2/RRC/NR/MESSAGES/asn1_msg.c
@@ -326,7 +326,7 @@ uint8_t do_SIB1_NR(rrc_gNB_carrier_data_t *carrier,
// cellSelectionInfo
sib1->cellSelectionInfo = CALLOC(1,sizeof(struct NR_SIB1__cellSelectionInfo));
- sib1->cellSelectionInfo->q_RxLevMin = -50;
+ sib1->cellSelectionInfo->q_RxLevMin = -65;
// cellAccessRelatedInfo
struct NR_PLMN_IdentityInfo *nr_plmn_info=CALLOC(1,sizeof(struct NR_PLMN_IdentityInfo));
@@ -418,7 +418,8 @@ uint8_t do_SIB1_NR(rrc_gNB_carrier_data_t *carrier,
nrMultiBandInfo->freqBandIndicatorNR = configuration->scc->downlinkConfigCommon->frequencyInfoDL->frequencyBandList.list.array[i];
ASN_SEQUENCE_ADD(&sib1->servingCellConfigCommon->downlinkConfigCommon.frequencyInfoDL.frequencyBandList.list,nrMultiBandInfo);
}
- sib1->servingCellConfigCommon->downlinkConfigCommon.frequencyInfoDL.offsetToPointA = configuration->scc->downlinkConfigCommon->frequencyInfoDL->scs_SpecificCarrierList.list.array[0]->offsetToCarrier;
+ //sib1->servingCellConfigCommon->downlinkConfigCommon.frequencyInfoDL.offsetToPointA = configuration->scc->downlinkConfigCommon->frequencyInfoDL->scs_SpecificCarrierList.list.array[0]->offsetToCarrier;
+ sib1->servingCellConfigCommon->downlinkConfigCommon.frequencyInfoDL.offsetToPointA = 86;
for(int i = 0; i< configuration->scc->downlinkConfigCommon->frequencyInfoDL->scs_SpecificCarrierList.list.count; i++) {
ASN_SEQUENCE_ADD(&sib1->servingCellConfigCommon->downlinkConfigCommon.frequencyInfoDL.scs_SpecificCarrierList.list,configuration->scc->downlinkConfigCommon->frequencyInfoDL->scs_SpecificCarrierList.list.array[i]);
}
diff --git a/openair2/RRC/NR/nr_rrc_proto.h b/openair2/RRC/NR/nr_rrc_proto.h
index 6d876a0eef..7c08d59e67 100644
--- a/openair2/RRC/NR/nr_rrc_proto.h
+++ b/openair2/RRC/NR/nr_rrc_proto.h
@@ -51,6 +51,7 @@ int8_t mac_rrc_nr_data_req(const module_id_t Mod_idP,
const int CC_id,
const frame_t frameP,
const rb_id_t Srb_id,
+ const rnti_t rnti,
const uint8_t Nb_tb,
uint8_t *const buffer_pP );
@@ -156,6 +157,24 @@ int
nr_rrc_mac_remove_ue(module_id_t mod_idP,
rnti_t rntiP);
+int8_t nr_mac_rrc_data_ind(
+ const module_id_t module_idP,
+ const int CC_id,
+ const frame_t frameP,
+ const sub_frame_t sub_frameP,
+ const int UE_id,
+ const rnti_t rntiP,
+ const rb_id_t srb_idP,
+ const uint8_t *sduP,
+ const sdu_size_t sdu_lenP,
+ const boolean_t brOption
+);
+
+int nr_rrc_gNB_decode_ccch(protocol_ctxt_t *const ctxt_pP,
+ const uint8_t *buffer,
+ int buffer_length,
+ const int CC_id);
+
void
rrc_gNB_generate_dedicatedRRCReconfiguration_release(
const protocol_ctxt_t *const ctxt_pP,
diff --git a/openair2/RRC/NR/nr_rrc_types.h b/openair2/RRC/NR/nr_rrc_types.h
index 02495591a9..61f90e3572 100644
--- a/openair2/RRC/NR/nr_rrc_types.h
+++ b/openair2/RRC/NR/nr_rrc_types.h
@@ -32,11 +32,11 @@
#define RRC_TYPES_NR_H_
typedef enum Rrc_State_NR_e {
- RRC_STATE_INACTIVE_NR=0,
- RRC_STATE_IDLE_NR,
+ RRC_STATE_IDLE_NR=0,
+ RRC_STATE_INACTIVE_NR,
RRC_STATE_CONNECTED_NR,
- RRC_STATE_FIRST_NR = RRC_STATE_INACTIVE_NR,
+ RRC_STATE_FIRST_NR = RRC_STATE_IDLE_NR,
RRC_STATE_LAST_NR = RRC_STATE_CONNECTED_NR,
} Rrc_State_NR_t;
diff --git a/openair2/RRC/NR/rrc_gNB.c b/openair2/RRC/NR/rrc_gNB.c
index 69750eee7b..78dfa3f5ee 100755
--- a/openair2/RRC/NR/rrc_gNB.c
+++ b/openair2/RRC/NR/rrc_gNB.c
@@ -414,29 +414,20 @@ rrc_gNB_generate_RRCSetup(
case ngran_gNB_CU:
// create an ITTI message
/* TODO: F1 IDs ar missing in RRC */
- if(0) {
- message_p = itti_alloc_new_message (TASK_RRC_GNB, 0, F1AP_DL_RRC_MESSAGE);
- F1AP_DL_RRC_MESSAGE (message_p).rrc_container = (uint8_t *)ue_p->Srb0.Tx_buffer.Payload;
- F1AP_DL_RRC_MESSAGE (message_p).rrc_container_length = ue_p->Srb0.Tx_buffer.payload_size;
- F1AP_DL_RRC_MESSAGE (message_p).gNB_CU_ue_id = 0;
- F1AP_DL_RRC_MESSAGE (message_p).gNB_DU_ue_id = 0;
- F1AP_DL_RRC_MESSAGE (message_p).old_gNB_DU_ue_id = 0xFFFFFFFF; // unknown
- F1AP_DL_RRC_MESSAGE (message_p).rnti = ue_p->rnti;
- F1AP_DL_RRC_MESSAGE (message_p).srb_id = CCCH;
- F1AP_DL_RRC_MESSAGE (message_p).execute_duplication = 1;
- F1AP_DL_RRC_MESSAGE (message_p).RAT_frequency_priority_information.en_dc = 0;
- itti_send_msg_to_task (TASK_CU_F1, ctxt_pP->module_id, message_p);
- LOG_D(NR_RRC, "Send F1AP_DL_RRC_MESSAGE with ITTI\n");
- }
- // for rfsim, send RRCSetup messgae in SRB1
- nr_rrc_data_req(ctxt_pP,
- DCCH,
- rrc_gNB_mui++,
- SDU_CONFIRM_NO,
- ue_p->Srb0.Tx_buffer.payload_size,
- (uint8_t *)ue_p->Srb0.Tx_buffer.Payload,
- PDCP_TRANSMISSION_MODE_CONTROL);
- break;
+ message_p = itti_alloc_new_message (TASK_RRC_GNB, 0, F1AP_DL_RRC_MESSAGE);
+ F1AP_DL_RRC_MESSAGE (message_p).rrc_container = (uint8_t *)ue_p->Srb0.Tx_buffer.Payload;
+ F1AP_DL_RRC_MESSAGE (message_p).rrc_container_length = ue_p->Srb0.Tx_buffer.payload_size;
+ F1AP_DL_RRC_MESSAGE (message_p).gNB_CU_ue_id = 0;
+ F1AP_DL_RRC_MESSAGE (message_p).gNB_DU_ue_id = 0;
+ F1AP_DL_RRC_MESSAGE (message_p).old_gNB_DU_ue_id = 0xFFFFFFFF; // unknown
+ F1AP_DL_RRC_MESSAGE (message_p).rnti = ue_p->rnti;
+ F1AP_DL_RRC_MESSAGE (message_p).srb_id = CCCH;
+ F1AP_DL_RRC_MESSAGE (message_p).execute_duplication = 1;
+ F1AP_DL_RRC_MESSAGE (message_p).RAT_frequency_priority_information.en_dc = 0;
+ itti_send_msg_to_task (TASK_CU_F1, ctxt_pP->module_id, message_p);
+ LOG_D(NR_RRC, "Send F1AP_DL_RRC_MESSAGE with ITTI\n");
+
+ break;
case ngran_gNB_DU:
// nothing to do for DU
@@ -1521,7 +1512,7 @@ int nr_rrc_gNB_decode_ccch(protocol_ctxt_t *const ctxt_pP,
break;
case NR_UL_CCCH_MessageType__c1_PR_rrcSetupRequest:
- LOG_I(NR_RRC, "Received RRCSetupRequest on UL-CCCH-Message (UE rnti %x)\n", ctxt_pP->rnti);
+ LOG_D(NR_RRC, "Received RRCSetupRequest on UL-CCCH-Message (UE rnti %x)\n", ctxt_pP->rnti);
ue_context_p = rrc_gNB_get_ue_context(gnb_rrc_inst, ctxt_pP->rnti);
if (ue_context_p != NULL) {
rrc_gNB_free_mem_UE_context(ctxt_pP, ue_context_p);
@@ -1628,15 +1619,13 @@ int nr_rrc_gNB_decode_ccch(protocol_ctxt_t *const ctxt_pP,
CC_id);
break;
}
- }
- if (ue_context_p != NULL) {
ue_context_p->ue_context.establishment_cause = rrcSetupRequest->establishmentCause;
- }
- rrc_gNB_generate_RRCSetup(ctxt_pP,
- rrc_gNB_get_ue_context(gnb_rrc_inst, ctxt_pP->rnti),
- CC_id);
+ rrc_gNB_generate_RRCSetup(ctxt_pP,
+ rrc_gNB_get_ue_context(gnb_rrc_inst, ctxt_pP->rnti),
+ CC_id);
+ }
break;
case NR_UL_CCCH_MessageType__c1_PR_rrcResumeRequest:
diff --git a/openair2/RRC/NR/rrc_gNB_NGAP.c b/openair2/RRC/NR/rrc_gNB_NGAP.c
index 9ebbc6991a..4b9f507f59 100644
--- a/openair2/RRC/NR/rrc_gNB_NGAP.c
+++ b/openair2/RRC/NR/rrc_gNB_NGAP.c
@@ -576,19 +576,6 @@ rrc_gNB_process_NGAP_INITIAL_CONTEXT_SETUP_REQ(
rrc_gNB_send_NGAP_INITIAL_CONTEXT_SETUP_RESP(&ctxt,ue_context_p);
}
-if (RC.nrrrc[ctxt.module_id]->node_type == ngran_gNB_CU) {
- MessageDef *message_p;
- message_p = itti_alloc_new_message (TASK_RRC_GNB, 0, F1AP_UE_CONTEXT_SETUP_REQ);
- F1AP_UE_CONTEXT_SETUP_REQ (message_p).rrc_container = (uint8_t *)ue_context_p->ue_context.Srb1.Srb_info.Tx_buffer.Payload;
- F1AP_UE_CONTEXT_SETUP_REQ (message_p).rrc_container_length = ue_context_p->ue_context.Srb1.Srb_info.Tx_buffer.payload_size;
- F1AP_UE_CONTEXT_SETUP_REQ (message_p).gNB_CU_ue_id = 0;
- F1AP_UE_CONTEXT_SETUP_REQ (message_p).gNB_DU_ue_id = 0;
- F1AP_UE_CONTEXT_SETUP_REQ (message_p).rnti = ue_context_p->ue_context.rnti;
-
- itti_send_msg_to_task (TASK_CU_F1, ctxt.module_id, message_p);
- LOG_D(NR_RRC, "Send F1AP_UE_CONTEXT_SETUP_REQ with ITTI\n");
- }
-
return 0;
}
}
@@ -803,25 +790,10 @@ rrc_gNB_process_NGAP_DOWNLINK_NAS(
*/
switch (RC.nrrrc[ctxt.module_id]->node_type) {
case ngran_gNB_CU:
- // create an ITTI message
- // F1AP_DL_RRC_MESSAGE
- message_p = itti_alloc_new_message (TASK_RRC_GNB, 0, F1AP_DL_RRC_MESSAGE);
- F1AP_DL_RRC_MESSAGE (message_p).rrc_container = buffer;
- F1AP_DL_RRC_MESSAGE (message_p).rrc_container_length = length;
- F1AP_DL_RRC_MESSAGE (message_p).gNB_CU_ue_id = 0;
- F1AP_DL_RRC_MESSAGE (message_p).gNB_DU_ue_id = 0;
- F1AP_DL_RRC_MESSAGE (message_p).old_gNB_DU_ue_id = 0xFFFFFFFF; // unknown
- F1AP_DL_RRC_MESSAGE (message_p).rnti = ue_context_p->ue_context.rnti;
- F1AP_DL_RRC_MESSAGE (message_p).srb_id = DCCH;
- F1AP_DL_RRC_MESSAGE (message_p).execute_duplication = 1;
- F1AP_DL_RRC_MESSAGE (message_p).RAT_frequency_priority_information.en_dc = 0;
- itti_send_msg_to_task (TASK_CU_F1, ctxt.module_id, message_p);
- LOG_D(NR_RRC, "Send F1AP_DL_RRC_MESSAGE with ITTI\n");
-
/* Transfer data to PDCP */
nr_rrc_data_req (
&ctxt,
- ue_context_p->ue_context.Srb2.Srb_info.Srb_id,
+ DCCH, // ue_context_p->ue_context.Srb2.Srb_info.Srb_id,
(*rrc_gNB_mui)++,
SDU_CONFIRM_NO,
length,
@@ -848,17 +820,15 @@ rrc_gNB_process_NGAP_DOWNLINK_NAS(
itti_send_msg_to_task (TASK_RRC_UE_SIM, instance, message_p);
LOG_I(NR_RRC, "Send DL NAS message \n");
#else
-#if(0)
/* Transfer data to PDCP */
nr_rrc_data_req (
&ctxt,
- ue_context_p->ue_context.Srb2.Srb_info.Srb_id,
+ DCCH,
(*rrc_gNB_mui)++,
SDU_CONFIRM_NO,
length,
buffer,
PDCP_TRANSMISSION_MODE_CONTROL);
-#endif
#endif
}
break;
diff --git a/openair2/RRC/NR/rrc_gNB_nsa.c b/openair2/RRC/NR/rrc_gNB_nsa.c
index 790028cd53..2f4d074707 100644
--- a/openair2/RRC/NR/rrc_gNB_nsa.c
+++ b/openair2/RRC/NR/rrc_gNB_nsa.c
@@ -328,7 +328,7 @@ void rrc_add_nsa_user(gNB_RRC_INST *rrc,struct rrc_gNB_ue_context_s *ue_context_
1024);
X2AP_ENDC_SGNB_ADDITION_REQ_ACK(msg).rrc_buffer_size = (enc_rval.encoded+7)>>3;
itti_send_msg_to_task(TASK_X2AP, ENB_MODULE_ID_TO_INSTANCE(0), msg); //Check right id instead of hardcoding
- } else if (get_softmodem_params()->do_ra) {
+ } else if (get_softmodem_params()->do_ra || get_softmodem_params()->sa) {
PROTOCOL_CTXT_SET_BY_MODULE_ID(&ctxt, rrc->module_id, GNB_FLAG_YES, ue_context_p->ue_id_rnti, 0, 0,rrc->module_id);
}
diff --git a/openair2/RRC/NR/rrc_gNB_reconfig.c b/openair2/RRC/NR/rrc_gNB_reconfig.c
index c1556751fa..68be3dd3bd 100644
--- a/openair2/RRC/NR/rrc_gNB_reconfig.c
+++ b/openair2/RRC/NR/rrc_gNB_reconfig.c
@@ -135,7 +135,7 @@ void fill_default_searchSpaceZero(NR_SearchSpace_t *ss0) {
// FIXME: update values from TS38.213 Section 10.1 Table 10.1-1: CCE aggregation levels and maximum number of PDCCH candidates per CCE aggregation level for CSS sets configured by searchSpaceSIB1
ss0->nrofCandidates->aggregationLevel1 = NR_SearchSpace__nrofCandidates__aggregationLevel1_n0;
ss0->nrofCandidates->aggregationLevel2 = NR_SearchSpace__nrofCandidates__aggregationLevel2_n0;
- ss0->nrofCandidates->aggregationLevel4 = NR_SearchSpace__nrofCandidates__aggregationLevel4_n1;
+ ss0->nrofCandidates->aggregationLevel4 = NR_SearchSpace__nrofCandidates__aggregationLevel4_n2;
ss0->nrofCandidates->aggregationLevel8 = NR_SearchSpace__nrofCandidates__aggregationLevel8_n0;
ss0->nrofCandidates->aggregationLevel16 = NR_SearchSpace__nrofCandidates__aggregationLevel16_n0;
@@ -172,7 +172,7 @@ void fill_default_secondaryCellGroup(NR_ServingCellConfigCommon_t *servingcellco
secondaryCellGroup->cellGroupId = scg_id;
NR_RLC_BearerConfig_t *RLC_BearerConfig = calloc(1,sizeof(*RLC_BearerConfig));
nr_rlc_bearer_init(RLC_BearerConfig, NR_RLC_BearerConfig__servedRadioBearer_PR_drb_Identity);
- if (get_softmodem_params()->do_ra)
+ if (get_softmodem_params()->do_ra || get_softmodem_params()->sa)
nr_drb_config(RLC_BearerConfig->rlc_Config, NR_RLC_Config_PR_um_Bi_Directional);
else
nr_drb_config(RLC_BearerConfig->rlc_Config, NR_RLC_Config_PR_am);
@@ -226,7 +226,9 @@ void fill_default_secondaryCellGroup(NR_ServingCellConfigCommon_t *servingcellco
secondaryCellGroup->spCellConfig->reconfigurationWithSync->t304=NR_ReconfigurationWithSync__t304_ms2000;
secondaryCellGroup->spCellConfig->reconfigurationWithSync->rach_ConfigDedicated = NULL;
secondaryCellGroup->spCellConfig->reconfigurationWithSync->ext1 = NULL;
- /* contention free ra */
+
+ // For 2-step contention-free random access procedure
+#if 0
secondaryCellGroup->spCellConfig->reconfigurationWithSync->rach_ConfigDedicated = calloc(1,sizeof(struct NR_ReconfigurationWithSync__rach_ConfigDedicated));
secondaryCellGroup->spCellConfig->reconfigurationWithSync->rach_ConfigDedicated->present= NR_ReconfigurationWithSync__rach_ConfigDedicated_PR_uplink;
secondaryCellGroup->spCellConfig->reconfigurationWithSync->rach_ConfigDedicated->choice.uplink= calloc(1,sizeof(struct NR_RACH_ConfigDedicated));
@@ -240,12 +242,13 @@ void fill_default_secondaryCellGroup(NR_ServingCellConfigCommon_t *servingcellco
secondaryCellGroup->spCellConfig->reconfigurationWithSync->rach_ConfigDedicated->choice.uplink->cfra->resources.present = NR_CFRA__resources_PR_ssb;
secondaryCellGroup->spCellConfig->reconfigurationWithSync->rach_ConfigDedicated->choice.uplink->cfra->resources.choice.ssb = calloc(1,sizeof(struct NR_CFRA__resources__ssb));
secondaryCellGroup->spCellConfig->reconfigurationWithSync->rach_ConfigDedicated->choice.uplink->cfra->resources.choice.ssb->ra_ssb_OccasionMaskIndex = 0;
+
struct NR_CFRA_SSB_Resource *ssbElem[8];
+
ssbElem[0] = calloc(1,sizeof(struct NR_CFRA_SSB_Resource));
ssbElem[0]->ssb = 0;
ssbElem[0]->ra_PreambleIndex = 63;
ASN_SEQUENCE_ADD(&secondaryCellGroup->spCellConfig->reconfigurationWithSync->rach_ConfigDedicated->choice.uplink->cfra->resources.choice.ssb->ssb_ResourceList.list,ssbElem[0]);
-#if 0
ssbElem[1] = calloc(1,sizeof(struct NR_CFRA_SSB_Resource));
ssbElem[1]->ssb = 1;
ssbElem[1]->ra_PreambleIndex = 62;
@@ -274,8 +277,10 @@ void fill_default_secondaryCellGroup(NR_ServingCellConfigCommon_t *servingcellco
ssbElem[7]->ssb = 7;
ssbElem[7]->ra_PreambleIndex = 63;
ASN_SEQUENCE_ADD(&secondaryCellGroup->spCellConfig->reconfigurationWithSync->rach_ConfigDedicated->choice.uplink->cfra->resources.choice.ssb->ssb_ResourceList.list,ssbElem[7]);
-#endif
+
secondaryCellGroup->spCellConfig->reconfigurationWithSync->rach_ConfigDedicated->choice.uplink->cfra->ext1 = NULL;
+#endif
+
secondaryCellGroup->spCellConfig->rlf_TimersAndConstants = calloc(1,sizeof(*secondaryCellGroup->spCellConfig->rlf_TimersAndConstants));
secondaryCellGroup->spCellConfig->rlf_TimersAndConstants->present = NR_SetupRelease_RLF_TimersAndConstants_PR_setup;
secondaryCellGroup->spCellConfig->rlf_TimersAndConstants->choice.setup=calloc(1,sizeof(*secondaryCellGroup->spCellConfig->rlf_TimersAndConstants->choice.setup));
@@ -1312,7 +1317,7 @@ void fill_default_reconfig(NR_ServingCellConfigCommon_t *servingcellconfigcommon
reconfig->radioBearerConfig=NULL;
// secondaryCellGroup
fill_default_secondaryCellGroup(servingcellconfigcommon,secondaryCellGroup,1,1,n_physical_antenna_ports,initial_csi_index);
- // xer_fprint(stdout, &asn_DEF_NR_CellGroupConfig, (const void*)secondaryCellGroup);
+ xer_fprint(stdout, &asn_DEF_NR_CellGroupConfig, (const void*)secondaryCellGroup);
char scg_buffer[1024];
asn_enc_rval_t enc_rval = uper_encode_to_buffer(&asn_DEF_NR_CellGroupConfig, NULL, (void *)secondaryCellGroup, scg_buffer, 1024);
diff --git a/openair2/RRC/NR_UE/L2_interface_ue.c b/openair2/RRC/NR_UE/L2_interface_ue.c
index e3fc6813f4..6fd0b9feca 100644
--- a/openair2/RRC/NR_UE/L2_interface_ue.c
+++ b/openair2/RRC/NR_UE/L2_interface_ue.c
@@ -33,6 +33,7 @@
#include "rrc_defs.h"
#include "rrc_proto.h"
#include "assertions.h"
+#include "rrc_vars.h"
typedef uint32_t channel_t;
@@ -41,17 +42,47 @@ nr_mac_rrc_data_ind_ue(
const module_id_t module_id,
const int CC_id,
const uint8_t gNB_index,
+ const frame_t frame,
+ const sub_frame_t sub_frame,
+ const rnti_t rnti,
const channel_t channel,
const uint8_t* pduP,
const sdu_size_t pdu_len){
+ sdu_size_t sdu_size = 0;
switch(channel){
case NR_BCCH_BCH:
AssertFatal( nr_rrc_ue_decode_NR_BCCH_BCH_Message(module_id, gNB_index, (uint8_t*)pduP, pdu_len) == 0, "UE decode BCCH-BCH error!\n");
break;
+
case NR_BCCH_DL_SCH:
- AssertFatal( nr_rrc_ue_decode_NR_SIB1_Message(module_id, gNB_index, (uint8_t*)pduP, pdu_len) == 0, "UE decode BCCH-DLSCH error!\n");
+ AssertFatal( nr_rrc_ue_decode_NR_BCCH_DL_SCH_Message(module_id, gNB_index, (uint8_t*)pduP, pdu_len, 0, 0) == 0, "UE decode BCCH-DL-SCH error!\n");
break;
+
+ case CCCH:
+ if (pdu_len>0) {
+ LOG_I(NR_RRC,"[UE %d] Received SDU for CCCH on SRB %u from gNB %d\n",module_id,channel & RAB_OFFSET,gNB_index);
+
+ MessageDef *message_p;
+ int msg_sdu_size = CCCH_SDU_SIZE;
+
+ if (pdu_len > msg_sdu_size) {
+ LOG_E(NR_RRC, "SDU larger than CCCH SDU buffer size (%d, %d)", sdu_size, msg_sdu_size);
+ sdu_size = msg_sdu_size;
+ } else {
+ sdu_size = pdu_len;
+ }
+
+ message_p = itti_alloc_new_message (TASK_MAC_UE, 0, NR_RRC_MAC_CCCH_DATA_IND);
+ memset (NR_RRC_MAC_CCCH_DATA_IND (message_p).sdu, 0, CCCH_SDU_SIZE);
+ memcpy (NR_RRC_MAC_CCCH_DATA_IND (message_p).sdu, pduP, sdu_size);
+ NR_RRC_MAC_CCCH_DATA_IND (message_p).frame = frame; //frameP
+ NR_RRC_MAC_CCCH_DATA_IND (message_p).sub_frame = sub_frame; //sub_frameP
+ NR_RRC_MAC_CCCH_DATA_IND (message_p).sdu_size = sdu_size;
+ NR_RRC_MAC_CCCH_DATA_IND (message_p).gnb_index = gNB_index;
+ NR_RRC_MAC_CCCH_DATA_IND (message_p).rnti = rnti; //rntiP
+ itti_send_msg_to_task (TASK_RRC_NRUE, GNB_MODULE_ID_TO_INSTANCE( module_id ), message_p);
+ }
default:
break;
}
@@ -59,13 +90,37 @@ nr_mac_rrc_data_ind_ue(
return(0);
}
-int8_t mac_rrc_nr_data_req_ue(const module_id_t Mod_idP,
+int8_t nr_mac_rrc_data_req_ue(const module_id_t Mod_idP,
const int CC_id,
+ const uint8_t gNB_id,
const frame_t frameP,
const rb_id_t Srb_id,
- uint8_t *const buffer_pP ){
+ uint8_t *buffer_pP){
- // todo
+ switch(Srb_id){
+
+ case CCCH:
+
+ // TODO: Enable timer T300
+ //NR_UE_rrc_inst[Mod_idP].Info[gNB_id].T300_active = 1;
+ //NR_UE_rrc_inst[Mod_idP].Info[gNB_id].T300_cnt = 0;
+
+ LOG_I(NR_RRC, "nr_mac_rrc_data_req_ue: Payload size = %i\n", NR_UE_rrc_inst[Mod_idP].Srb0[gNB_id].Tx_buffer.payload_size);
+ memcpy(buffer_pP, (uint8_t*)NR_UE_rrc_inst[Mod_idP].Srb0[gNB_id].Tx_buffer.Payload, NR_UE_rrc_inst[Mod_idP].Srb0[gNB_id].Tx_buffer.payload_size);
+ for(int i = 0; imodule_id].MBMS_flag < 3) // see -Q option
if (AMF_MODE_ENABLED) {
- rrc_ue_generate_RRCSetupRequest( ctxt_pP, gNB_index );
+ nr_rrc_ue_generate_RRCSetupRequest( ctxt_pP->module_id, gNB_index );
}
if (NR_UE_rrc_inst[ctxt_pP->module_id].Info[gNB_index].State == NR_RRC_IDLE) {
@@ -1030,205 +1041,120 @@ int nr_decode_SI( const protocol_ctxt_t *const ctxt_pP, const uint8_t gNB_index
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;
+int8_t check_requested_SI_List(module_id_t module_id, BIT_STRING_t requested_SI_List, NR_SIB1_t sib1) {
- 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];
+ if(sib1.si_SchedulingInfo) {
+
+ bool SIB_to_request[32] = {};
+
+ LOG_D(RRC, "SIBs broadcasting: ");
+ for(int i = 0; i < sib1.si_SchedulingInfo->schedulingInfoList.list.array[0]->sib_MappingInfo.list.count; i++) {
+ printf("SIB%li ", sib1.si_SchedulingInfo->schedulingInfoList.list.array[0]->sib_MappingInfo.list.array[i]->type + 2);
}
+ printf("\n");
- 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_D(RRC, "SIBs needed by UE: ");
+ for(int j = 0; j < 8*requested_SI_List.size; j++) {
+ if( ((requested_SI_List.buf[j/8]>>(j%8))&1) == 1) {
- 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;
+ printf("SIB%i ", j + 2);
- 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)] );
+ SIB_to_request[j] = true;
+ for(int i = 0; i < sib1.si_SchedulingInfo->schedulingInfoList.list.array[0]->sib_MappingInfo.list.count; i++) {
+ if(sib1.si_SchedulingInfo->schedulingInfoList.list.array[0]->sib_MappingInfo.list.array[i]->type == j) {
+ SIB_to_request[j] = false;
+ break;
+ }
}
- LOG_I( RRC, "siSchedulingInfoSIBType[%d] : %s\n", i, temp );
+ }
+ }
+ printf("\n");
+
+ LOG_D(RRC, "SIBs to request by UE: ");
+ bool do_ra = false;
+ for(int j = 0; j < 8*requested_SI_List.size; j++) {
+ if(SIB_to_request[j]) {
+ printf("SIB%i ", j + 2);
+ do_ra = true;
+ }
+ }
+ printf("\n");
+
+ if(do_ra) {
+
+ NR_UE_rrc_inst[module_id].ra_trigger = REQUEST_FOR_OTHER_SI;
+ get_softmodem_params()->do_ra = 1;
+
+ if(sib1.si_SchedulingInfo->si_RequestConfig) {
+ LOG_D(RRC, "Trigger contention-free RA procedure (ra_trigger = %i)\n", NR_UE_rrc_inst[module_id].ra_trigger);
} else {
- LOG_I( RRC, "mapping list %d is null\n", i );
+ LOG_D(RRC, "Trigger contention-based RA procedure (ra_trigger = %i)\n", NR_UE_rrc_inst[module_id].ra_trigger);
}
+
}
- } 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_NRUE, 0, 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_NRUE, 0, 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 %ld), 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 ) {
+int8_t nr_rrc_ue_generate_ra_msg(module_id_t module_id, uint8_t gNB_index) {
+
+ switch(NR_UE_rrc_inst[module_id].ra_trigger){
+ case INITIAL_ACCESS_FROM_RRC_IDLE:
+ // After SIB1 is received, prepare RRCConnectionRequest
+ nr_rrc_ue_generate_RRCSetupRequest(module_id,gNB_index);
+ break;
+ case RRC_CONNECTION_REESTABLISHMENT:
+ AssertFatal(1==0, "ra_trigger not implemented yet!\n");
+ break;
+ case DURING_HANDOVER:
+ AssertFatal(1==0, "ra_trigger not implemented yet!\n");
+ break;
+ case NON_SYNCHRONISED:
+ AssertFatal(1==0, "ra_trigger not implemented yet!\n");
+ break;
+ case TRANSITION_FROM_RRC_INACTIVE:
+ AssertFatal(1==0, "ra_trigger not implemented yet!\n");
+ break;
+ case TO_ESTABLISH_TA:
+ AssertFatal(1==0, "ra_trigger not implemented yet!\n");
+ break;
+ case REQUEST_FOR_OTHER_SI:
+ AssertFatal(1==0, "ra_trigger not implemented yet!\n");
+ break;
+ case BEAM_FAILURE_RECOVERY:
+ AssertFatal(1==0, "ra_trigger not implemented yet!\n");
+ break;
+ default:
+ AssertFatal(1==0, "Invalid ra_trigger value!\n");
+ break;
+ }
+
+ return 0;
+}
+
+int8_t nr_rrc_ue_decode_NR_BCCH_DL_SCH_Message(
+ module_id_t module_id,
+ 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];
+ NR_SIB1_t *sib1 = NR_UE_rrc_inst[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)) {
+ if (((NR_UE_rrc_inst[module_id].Info[gNB_index].SIStatus&1) == 1) && // SIB1 received
+ (NR_UE_rrc_inst[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 );
- }
+ nr_rrc_set_sub_state( module_id, RRC_SUB_STATE_IDLE_RECEIVING_SIB_NR );
asn_dec_rval_t dec_rval = uper_decode_complete( NULL,
&asn_DEF_NR_BCCH_DL_SCH_Message,
@@ -1236,11 +1162,15 @@ int nr_decode_BCCH_DLSCH_Message(
(const void *)Sdu,
Sdu_len );
+ if ( LOG_DEBUGFLAG(DEBUG_ASN1) ) {
+ xer_fprint(stdout, &asn_DEF_NR_BCCH_DL_SCH_Message,(void *)bcch_message );
+ }
+
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,
+ LOG_E( NR_RRC, "[UE %"PRIu8"] Failed to decode BCCH_DLSCH_MESSAGE (%zu bits)\n",
+ module_id,
dec_rval.consumed );
- log_dump(RRC, Sdu, Sdu_len, LOG_DUMP_CHAR," Received bytes:\n" );
+ log_dump(NR_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 );
@@ -1250,35 +1180,53 @@ int nr_decode_BCCH_DLSCH_Message(
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 );
+ if ((NR_UE_rrc_inst[module_id].Info[gNB_index].SIStatus&1) == 0) {
+ NR_SIB1_t *sib1 = NR_UE_rrc_inst[module_id].sib1[gNB_index];
+ if(sib1 != NULL){
+ SEQUENCE_free(&asn_DEF_NR_SIB1, (void *)sib1, 1 );
+ }
+
+ sib1 = bcch_message->message.choice.c1->choice.systemInformationBlockType1;
+ if (*(int64_t*)sib1 != 1) {
+ NR_UE_rrc_inst[module_id].sib1[gNB_index] = sib1;
+ if( g_log->log_component[NR_RRC].level >= OAILOG_DEBUG ) {
+ xer_fprint(stdout, &asn_DEF_NR_SIB1, (const void *) NR_UE_rrc_inst[module_id].sib1[gNB_index]);
+ }
+ LOG_I(NR_RRC, "SIB1 decoded\n");
+
+ // FIXME: improve condition for the RA trigger
+ // Check for on-demand not broadcasted SI
+ check_requested_SI_List(module_id, NR_UE_rrc_inst[module_id].requested_SI_List, *sib1);
+ if( nr_rrc_get_state(module_id) == RRC_STATE_IDLE_NR ) {
+ NR_UE_rrc_inst[module_id].ra_trigger = INITIAL_ACCESS_FROM_RRC_IDLE;
+ // TODO: remove flag after full RA procedures implemented
+ get_softmodem_params()->do_ra = 1;
+ }
+ nr_rrc_ue_generate_ra_msg(module_id,gNB_index);
+ } else {
+ LOG_E(NR_RRC, "SIB1 not decoded\n");
}
}
-
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) {
+ if ((NR_UE_rrc_inst[module_id].Info[gNB_index].SIStatus&1) == 1) {
+ LOG_W(NR_RRC, "Decoding SI not implemented yet\n");
+ // TODO: Decode SI
+ /*
// SIB1 with schedulingInfoList is available
- NR_SystemInformation_t *si = NR_UE_rrc_inst[ctxt_pP->module_id].si[gNB_index];
+ NR_SystemInformation_t *si = NR_UE_rrc_inst[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 );
+ LOG_I(NR_RRC, "[UE %"PRIu8"] Decoding SI\n", module_id);
nr_decode_SI( ctxt_pP, gNB_index );
- //if (nfapi_mode == 3)
- //UE_mac_inst[ctxt_pP->module_id].SI_Decoded = 1;
- }
+ if (nfapi_mode == 3)
+ UE_mac_inst[ctxt_pP->module_id].SI_Decoded = 1;
+ */
+ }
break;
case NR_BCCH_DL_SCH_MessageType__c1_PR_NOTHING:
@@ -1287,10 +1235,10 @@ int nr_decode_BCCH_DLSCH_Message(
}
}
- if (nr_rrc_get_sub_state(ctxt_pP->module_id) == RRC_SUB_STATE_IDLE_SIB_COMPLETE_NR) {
+ if (nr_rrc_get_sub_state(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 );
+ nr_rrc_ue_generate_RRCSetupRequest(module_id, 0);
+ nr_rrc_set_sub_state( module_id, RRC_SUB_STATE_IDLE_CONNECTING );
//}
}
@@ -1364,7 +1312,7 @@ static void rrc_ue_generate_RRCSetupComplete(
const char *nas_msg;
int nas_msg_length;
if (AMF_MODE_ENABLED) {
-#if ITTI_SIM
+#if defined(ITTI_SIM) || defined(RFSIM_NAS)
as_nas_info_t initialNasMsg;
generateRegistrationRequest(&initialNasMsg);
nas_msg = (char*)initialNasMsg.data;
@@ -1417,17 +1365,17 @@ int8_t nr_rrc_ue_decode_ccch( const protocol_ctxt_t *const ctxt_pP, const NR_SRB
(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;
}
-
+
NR_UE_rrc_inst[ctxt_pP->module_id].Info[gNB_index].State = NR_RRC_SI_RECEIVED;
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 == NR_RRC_SI_RECEIVED) {
@@ -1438,7 +1386,7 @@ int8_t nr_rrc_ue_decode_ccch( const protocol_ctxt_t *const ctxt_pP, const NR_SRB
ctxt_pP->frame);
rval = 0;
break;
-
+
case NR_DL_CCCH_MessageType__c1_PR_rrcReject:
LOG_I(NR_RRC,
"[UE%d] Frame %d : Logical Channel DL-CCCH (SRB0), Received RRCConnectionReject \n",
@@ -1446,7 +1394,7 @@ int8_t nr_rrc_ue_decode_ccch( const protocol_ctxt_t *const ctxt_pP, const NR_SRB
ctxt_pP->frame);
rval = 0;
break;
-
+
case NR_DL_CCCH_MessageType__c1_PR_rrcSetup:
LOG_I(NR_RRC,
"[UE%d][RAPROC] Frame %d : Logical Channel DL-CCCH (SRB0), Received NR_RRCSetup RNTI %x\n",
@@ -1456,7 +1404,7 @@ int8_t nr_rrc_ue_decode_ccch( const protocol_ctxt_t *const ctxt_pP, const NR_SRB
// 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,
@@ -1475,7 +1423,7 @@ int8_t nr_rrc_ue_decode_ccch( const protocol_ctxt_t *const ctxt_pP, const NR_SRB
NR_UE_rrc_inst[ctxt_pP->module_id].selected_plmn_identity);
rval = 0;
break;
-
+
default:
LOG_E(NR_RRC, "[UE%d] Frame %d : Unknown message\n",
ctxt_pP->module_id,
@@ -1489,41 +1437,6 @@ int8_t nr_rrc_ue_decode_ccch( const protocol_ctxt_t *const ctxt_pP, const NR_SRB
return rval;
}
-/*brief decode SIB1 message*/
-int8_t nr_rrc_ue_decode_NR_SIB1_Message(module_id_t module_id, uint8_t gNB_index, uint8_t *const bufferP, const uint8_t buffer_len) {
-
- NR_BCCH_DL_SCH_Message_t *bcch_message = NULL;
-
- asn_dec_rval_t dec_rval = uper_decode_complete(NULL,
- &asn_DEF_NR_BCCH_DL_SCH_Message,
- (void **)&bcch_message,
- (const void *)bufferP,
- buffer_len);
-
- if ((dec_rval.code != RC_OK) || (dec_rval.consumed == 0)) {
- LOG_D(RRC,"NR_BCCH_DL_SCH decode error\n");
- SEQUENCE_free( &asn_DEF_NR_BCCH_DL_SCH_Message, (void *)bcch_message, 1 );
- return -1;
- }
- else {
- NR_SIB1_t *sib1 = NR_UE_rrc_inst[module_id].sib1[gNB_index];
- if(sib1 != NULL){
- SEQUENCE_free(&asn_DEF_NR_BCCH_BCH_Message, (void *)sib1, 1 );
- }
- sib1 = bcch_message->message.choice.c1->choice.systemInformationBlockType1;
- if (*(int64_t*)sib1 != 1) {
- LOG_I(RRC, "SIB1 decoded\n");
- if( g_log->log_component[RRC].level >= OAILOG_DEBUG )
- xer_fprint(stdout, &asn_DEF_NR_SIB1, (const void*)sib1);
- }
- else
- LOG_E(PHY, "sib1 is starting by 8 times 0\n");
- }
-
- return 0;
-}
-
-
// from NR SRB3
int8_t nr_rrc_ue_decode_NR_DL_DCCH_Message(
const module_id_t module_id,
@@ -1668,7 +1581,7 @@ nr_rrc_ue_process_securityModeCommand(
securityMode |= 0x70 ;
break;
}
-
+
NR_UE_rrc_inst[ctxt_pP->module_id].integrityProtAlgorithm =
*securityModeCommand->criticalExtensions.choice.securityModeCommand->securityConfigSMC.securityAlgorithmConfig.integrityProtAlgorithm;
@@ -1751,9 +1664,9 @@ nr_rrc_ue_process_securityModeCommand(
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);
- // }
+ if ( LOG_DEBUGFLAG(DEBUG_ASN1) ) {
+ xer_fprint(stdout, &asn_DEF_NR_UL_DCCH_Message, (void *)&ul_dcch_msg);
+ }
log_dump(MAC, buffer, 16, LOG_DUMP_CHAR, "securityModeComplete payload: ");
LOG_D(NR_RRC, "securityModeComplete Encoded %zd bits (%zd bytes)\n", enc_rval.encoded, (enc_rval.encoded+7)/8);
@@ -1790,10 +1703,13 @@ nr_rrc_ue_process_securityModeCommand(
}
//-----------------------------------------------------------------------------
-void rrc_ue_generate_RRCSetupRequest( const protocol_ctxt_t *const ctxt_pP, const uint8_t gNB_index ) {
+void nr_rrc_ue_generate_RRCSetupRequest(module_id_t module_id, 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) {
+ if(IS_SOFTMODEM_NOS1) {
+ AMF_MODE_ENABLED = 1;
+ }
+ if(NR_UE_rrc_inst[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++) {
@@ -1807,22 +1723,26 @@ void rrc_ue_generate_RRCSetupRequest( const protocol_ctxt_t *const ctxt_pP, cons
}
LOG_T(NR_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(NR_RRC,"[UE %d] : Frame %d, Logical Channel UL-CCCH (SRB0), Generating RRCSetupRequest (bytes %d, eNB %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);
+ NR_UE_rrc_inst[module_id].Srb0[gNB_index].Tx_buffer.payload_size =
+ do_RRCSetupRequest(
+ module_id,
+ (uint8_t *)NR_UE_rrc_inst[module_id].Srb0[gNB_index].Tx_buffer.Payload,
+ rv);
+ LOG_I(NR_RRC,"[UE %d] : Logical Channel UL-CCCH (SRB0), Generating RRCSetupRequest (bytes %d, gNB %d)\n",
+ module_id, NR_UE_rrc_inst[module_id].Srb0[gNB_index].Tx_buffer.payload_size, gNB_index);
+
+ for (i=0; imodule_id].Srb0[gNB_index].Tx_buffer.payload_size; i++) {
- LOG_T(NR_RRC,"%x.",NR_UE_rrc_inst[ctxt_pP->module_id].Srb0[gNB_index].Tx_buffer.Payload[i]);
}
- LOG_T(NR_RRC,"\n");
+// LOG_T(NR_RRC,"\n");
+ printf("\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; */
+ /*
log_dump(RRC,NR_UE_rrc_inst[ctxt_pP->module_id].Srb0[gNB_index].Tx_buffer.Payload,NR_UE_rrc_inst[ctxt_pP->module_id].Srb0[gNB_index].Tx_buffer.payload_size,
LOG_DUMP_CHAR,"RRCSetupRequest :\n");
rrc_data_req_ue (
@@ -1833,6 +1753,7 @@ void rrc_ue_generate_RRCSetupRequest( const protocol_ctxt_t *const ctxt_pP, cons
NR_UE_rrc_inst[ctxt_pP->module_id].Srb0[gNB_index].Tx_buffer.payload_size,
(uint8_t *)NR_UE_rrc_inst[ctxt_pP->module_id].Srb0[gNB_index].Tx_buffer.Payload,
PDCP_TRANSMISSION_MODE_CONTROL);
+ */
#ifdef ITTI_SIM
MessageDef *message_p;
@@ -2256,34 +2177,11 @@ rrc_ue_process_rrcReconfiguration(
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;
-#ifdef ITTI_SIM
- uint8_t msg_type = 0;
- if((pdu_buffer + 1) != NULL){
- if (*(pdu_buffer + 1) > 0 ) {
- if((pdu_buffer + 9) != NULL){
- msg_type = *(pdu_buffer + 9);
- } else {
- LOG_W(NR_RRC, "[UE] Received invalid downlink message\n");
- return;
- }
- } else {
- if((pdu_buffer + 2) != NULL){
- msg_type = *(pdu_buffer + 2);
- } else {
- LOG_W(NR_RRC, "[UE] Received invalid downlink message\n");
- return;
- }
- }
- }
- if(msg_type == REGISTRATION_ACCEPT){
- LOG_I(NR_RRC, "[UE] Received REGISTRATION ACCEPT message\n");
- }
-#endif
msg_p = itti_alloc_new_message(TASK_RRC_NRUE, 0, NAS_CONN_ESTABLI_CNF);
NAS_CONN_ESTABLI_CNF(msg_p).errCode = AS_SUCCESS;
NAS_CONN_ESTABLI_CNF(msg_p).nasMsg.length = pdu_length;
NAS_CONN_ESTABLI_CNF(msg_p).nasMsg.data = pdu_buffer;
- itti_send_msg_to_task(TASK_NAS_UE, ctxt_pP->instance, msg_p);
+ itti_send_msg_to_task(TASK_NAS_NRUE, ctxt_pP->instance, msg_p);
}
free (ie->nonCriticalExtension->dedicatedNAS_MessageList);
@@ -2380,46 +2278,14 @@ nr_rrc_ue_decode_dcch(
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);
-
- if (first_rrcreconfigurationcomplete == 0) {
- first_rrcreconfigurationcomplete = 1;
-#ifdef ITTI_SIM
- if (AMF_MODE_ENABLED) {
- as_nas_info_t initialNasMsg;
- memset(&initialNasMsg, 0, sizeof(as_nas_info_t));
- generateRegistrationComplete(&initialNasMsg, NULL);
- if(initialNasMsg.length > 0){
- MessageDef *message_p;
- message_p = itti_alloc_new_message(TASK_RRC_NRUE, 0, NAS_UPLINK_DATA_REQ);
- NAS_UPLINK_DATA_REQ(message_p).UEid = ctxt_pP->module_id;
- NAS_UPLINK_DATA_REQ(message_p).nasMsg.data = (uint8_t *)initialNasMsg.data;
- NAS_UPLINK_DATA_REQ(message_p).nasMsg.length = initialNasMsg.length;
- itti_send_msg_to_task(TASK_RRC_NRUE, ctxt_pP->instance, message_p);
- LOG_I(NR_RRC, " Send NAS_UPLINK_DATA_REQ message(RegistrationComplete)\n");
- }
- as_nas_info_t pduEstablishMsg;
- memset(&pduEstablishMsg, 0, sizeof(as_nas_info_t));
- generatePduSessionEstablishRequest(&pduEstablishMsg);
- if(initialNasMsg.length > 0){
- MessageDef *message_p;
- message_p = itti_alloc_new_message(TASK_RRC_NRUE, 0, NAS_UPLINK_DATA_REQ);
- NAS_UPLINK_DATA_REQ(message_p).UEid = ctxt_pP->module_id;
- NAS_UPLINK_DATA_REQ(message_p).nasMsg.data = (uint8_t *)pduEstablishMsg.data;
- NAS_UPLINK_DATA_REQ(message_p).nasMsg.length = pduEstablishMsg.length;
- itti_send_msg_to_task(TASK_RRC_NRUE, ctxt_pP->instance, message_p);
- LOG_I(NR_RRC, " Send NAS_UPLINK_DATA_REQ message(PduSessionEstablishRequest)\n");
- }
- }
-#endif
- }
+ 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;
}
- break;
case NR_DL_DCCH_MessageType__c1_PR_rrcResume:
case NR_DL_DCCH_MessageType__c1_PR_rrcRelease:
@@ -2465,59 +2331,13 @@ nr_rrc_ue_decode_dcch(
/* This message hold a dedicated info NAS payload, forward it to NAS */
NR_DedicatedNAS_Message_t *dedicatedNAS_Message =
dlInformationTransfer->criticalExtensions.choice.dlInformationTransfer->dedicatedNAS_Message;
- uint32_t pdu_length;
- uint8_t *pdu_buffer;
- pdu_length = dedicatedNAS_Message->size;
- pdu_buffer = dedicatedNAS_Message->buf;
-#ifdef ITTI_SIM
- LOG_I(NR_RRC, "[UE %d] Received %s: UEid %u, length %u , buffer %p\n", ctxt_pP->module_id, messages_info[NAS_DOWNLINK_DATA_IND].name,
- ctxt_pP->module_id, pdu_length, pdu_buffer);
- as_nas_info_t initialNasMsg;
- uint8_t msg_type = 0;
- memset(&initialNasMsg, 0, sizeof(as_nas_info_t));
- if((pdu_buffer + 1) != NULL){
- if (*(pdu_buffer + 1) > 0 ) {
- msg_type = *(pdu_buffer + 9);
- } else {
- msg_type = *(pdu_buffer + 2);
- }
- }
- if((pdu_buffer + 2) == NULL){
- LOG_W(NR_RRC, "[UE] Received invalid downlink message\n");
- return 0;
- }
- switch(msg_type){
- case FGS_IDENTITY_REQUEST:
- generateIdentityResponse(&initialNasMsg,*(pdu_buffer+3));
- break;
- case FGS_AUTHENTICATION_REQUEST:
- generateAuthenticationResp(&initialNasMsg, pdu_buffer);
- break;
- case FGS_SECURITY_MODE_COMMAND:
- generateSecurityModeComplete(&initialNasMsg);
- break;
- default:
- LOG_W(NR_RRC,"unknow message type %d\n",msg_type);
- break;
- }
- if(initialNasMsg.length > 0){
- MessageDef *message_p;
- message_p = itti_alloc_new_message(TASK_RRC_NRUE, 0, NAS_UPLINK_DATA_REQ);
- NAS_UPLINK_DATA_REQ(message_p).UEid = ctxt_pP->module_id;
- NAS_UPLINK_DATA_REQ(message_p).nasMsg.data = (uint8_t *)initialNasMsg.data;
- NAS_UPLINK_DATA_REQ(message_p).nasMsg.length = initialNasMsg.length;
- itti_send_msg_to_task(TASK_RRC_NRUE, ctxt_pP->instance, message_p);
- LOG_I(NR_RRC, " Send NAS_UPLINK_DATA_REQ message\n");
- }
-#else
MessageDef *msg_p;
msg_p = itti_alloc_new_message(TASK_RRC_NRUE, 0, NAS_DOWNLINK_DATA_IND);
NAS_DOWNLINK_DATA_IND(msg_p).UEid = ctxt_pP->module_id; // TODO set the UEid to something else ?
- NAS_DOWNLINK_DATA_IND(msg_p).nasMsg.length = pdu_length;
- NAS_DOWNLINK_DATA_IND(msg_p).nasMsg.data = pdu_buffer;
- itti_send_msg_to_task(TASK_NAS_UE, ctxt_pP->instance, msg_p);
-#endif
+ NAS_DOWNLINK_DATA_IND(msg_p).nasMsg.length = dedicatedNAS_Message->size;
+ NAS_DOWNLINK_DATA_IND(msg_p).nasMsg.data = dedicatedNAS_Message->buf;
+ itti_send_msg_to_task(TASK_NAS_NRUE, ctxt_pP->instance, msg_p);
}
}
@@ -2577,7 +2397,7 @@ void *rrc_nrue_task( void *args_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_ue_decode_NR_BCCH_DL_SCH_Message (ctxt.module_id,
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,
diff --git a/openair2/RRC/NR_UE/rrc_defs.h b/openair2/RRC/NR_UE/rrc_defs.h
index 52bd6c564a..f4ce474657 100644
--- a/openair2/RRC/NR_UE/rrc_defs.h
+++ b/openair2/RRC/NR_UE/rrc_defs.h
@@ -77,6 +77,30 @@ typedef struct OAI_NR_UECapability_s {
NR_UE_NR_Capability_t *UE_NR_Capability;
} OAI_NR_UECapability_t;
+typedef enum requested_SI_List_e {
+ SIB2 = 1,
+ SIB3 = 2,
+ SIB4 = 4,
+ SIB5 = 8,
+ SIB6 = 16,
+ SIB7 = 32,
+ SIB8 = 64,
+ SIB9 = 128
+} requested_SI_List_t;
+
+// 3GPP TS 38.300 Section 9.2.6
+typedef enum RA_trigger_e {
+ RA_NOT_RUNNING,
+ INITIAL_ACCESS_FROM_RRC_IDLE,
+ RRC_CONNECTION_REESTABLISHMENT,
+ DURING_HANDOVER,
+ NON_SYNCHRONISED,
+ TRANSITION_FROM_RRC_INACTIVE,
+ TO_ESTABLISH_TA,
+ REQUEST_FOR_OTHER_SI,
+ BEAM_FAILURE_RECOVERY,
+} RA_trigger_t;
+
typedef struct NR_UE_RRC_INST_s {
NR_MeasConfig_t *meas_config;
@@ -99,10 +123,13 @@ typedef struct NR_UE_RRC_INST_s {
NR_SRB_INFO_TABLE_ENTRY Srb2[NB_CNX_UE];
uint8_t MBMS_flag;
- OAI_NR_UECapability_t *UECap;
- uint8_t *UECapability;
+ OAI_NR_UECapability_t *UECap;
+ uint8_t *UECapability;
uint8_t UECapability_size;
+ RA_trigger_t ra_trigger;
+ BIT_STRING_t requested_SI_List;
+
NR_SystemInformation_t *si[NB_CNX_UE];
NR_SIB1_t *sib1[NB_CNX_UE];
NR_SIB2_t *sib2[NB_CNX_UE];
diff --git a/openair2/RRC/NR_UE/rrc_proto.h b/openair2/RRC/NR_UE/rrc_proto.h
index 4019248441..534da0112b 100644
--- a/openair2/RRC/NR_UE/rrc_proto.h
+++ b/openair2/RRC/NR_UE/rrc_proto.h
@@ -86,12 +86,14 @@ int8_t nr_rrc_ue_process_radio_bearer_config(NR_RadioBearerConfig_t *radio_beare
\param sdu_len length of buffer*/
int8_t nr_rrc_ue_decode_NR_BCCH_BCH_Message(const module_id_t module_id, const uint8_t gNB_index, uint8_t *const bufferP, const uint8_t buffer_len);
-/**\brief decode NR SIB1 message
+/**\brief decode NR BCCH-DLSCH (SI) messages
\param module_idP module id
\param gNB_index gNB index
- \param sduP pointer to buffer of ASN message
- \param sdu_len length of buffer*/
-int8_t nr_rrc_ue_decode_NR_SIB1_Message(module_id_t module_id, uint8_t gNB_index, uint8_t *const bufferP, const uint8_t buffer_len);
+ \param sduP pointer to buffer of ASN message BCCH-DLSCH
+ \param sdu_len length of buffer
+ \param rsrq RSRQ
+ \param rsrp RSRP*/
+int8_t nr_rrc_ue_decode_NR_BCCH_DL_SCH_Message(const module_id_t module_id, const uint8_t gNB_index, uint8_t *const bufferP, const uint8_t buffer_len, const uint8_t rsrq, const uint8_t rsrp);
/**\brief Decode NR DCCH from gNB, sent from lower layer through SRB3
\param module_id module id
@@ -107,29 +109,38 @@ int8_t nr_rrc_ue_decode_NR_DL_DCCH_Message(const module_id_t module_id, const ui
\param channel indicator for channel of the pdu
\param pduP pointer to pdu
\param pdu_len data length of pdu*/
-int8_t nr_mac_rrc_data_ind_ue(const module_id_t module_id, const int CC_id, const uint8_t gNB_index, const channel_t channel, const uint8_t* pduP, const sdu_size_t pdu_len);
+int8_t nr_mac_rrc_data_ind_ue(const module_id_t module_id,
+ const int CC_id,
+ const uint8_t gNB_index,
+ const frame_t frame,
+ const sub_frame_t sub_frame,
+ const rnti_t rnti,
+ const channel_t channel,
+ const uint8_t* pduP,
+ const sdu_size_t pdu_len);
/**\brief
\param module_id module id
\param CC_id component carrier id
+ \param gNB_index gNB index
\param frame_t frameP
\param rb_id_t SRB id
\param buffer_pP pointer to buffer*/
-int8_t mac_rrc_nr_data_req_ue(const module_id_t Mod_idP,
+int8_t nr_mac_rrc_data_req_ue(const module_id_t Mod_idP,
const int CC_id,
+ const uint8_t gNB_id,
const frame_t frameP,
const rb_id_t Srb_id,
- uint8_t *const buffer_pP);
-
+ uint8_t *buffer_pP);
/**\brief RRC UE task.
\param void *args_p Pointer on arguments to start the task. */
void *rrc_nrue_task(void *args_p);
/**\brief RRC UE generate RRCSetupRequest message.
- \param ctxt_pP protocol context
+ \param module_id module id
\param gNB_index gNB index */
-void rrc_ue_generate_RRCSetupRequest( const protocol_ctxt_t *const ctxt_pP, const uint8_t gNB_index );
+void nr_rrc_ue_generate_RRCSetupRequest(module_id_t module_id, const uint8_t gNB_index);
/** @}*/
#endif
diff --git a/openair2/SIMULATION/NR_RRC/itti_sim.c b/openair2/SIMULATION/NR_RRC/itti_sim.c
index 1ec3a6bf3d..ee1eda4267 100644
--- a/openair2/SIMULATION/NR_RRC/itti_sim.c
+++ b/openair2/SIMULATION/NR_RRC/itti_sim.c
@@ -81,6 +81,9 @@ unsigned short config_frames[4] = {2,9,11,13};
#include "RRC/NR_UE/rrc_proto.h"
#include "RRC/NR_UE/rrc_vars.h"
#include "openair3/NAS/UE/nas_ue_task.h"
+#if ITTI_SIM
+#include "nr_nas_msg_sim.h"
+#endif
pthread_cond_t nfapi_sync_cond;
pthread_mutex_t nfapi_sync_mutex;
@@ -404,6 +407,12 @@ int create_tasks_nrue(uint32_t ue_nb) {
LOG_E(NR_RRC, "Create task for RRC UE failed\n");
return -1;
}
+
+ printf("create TASK_NAS_NRUE\n");
+ if (itti_create_task (TASK_NAS_NRUE, nas_nrue_task, NULL) < 0) {
+ LOG_E(NR_RRC, "Create task for NAS UE failed\n");
+ return -1;
+ }
}
@@ -571,8 +580,14 @@ int main( int argc, char **argv )
init_pdcp();
if (RC.nb_nr_inst > 0) {
+ nr_read_config_and_init();
// don't create if node doesn't connect to RRC/S1/GTP
AssertFatal(create_gNB_tasks(1) == 0,"cannot create ITTI tasks\n");
+ for (int gnb_id = 0; gnb_id < RC.nb_nr_inst; gnb_id++) {
+ MessageDef *msg_p = itti_alloc_new_message (TASK_GNB_APP, 0, NRRRC_CONFIGURATION_REQ);
+ NRRRC_CONFIGURATION_REQ(msg_p) = RC.nrrrc[gnb_id]->configuration;
+ itti_send_msg_to_task (TASK_RRC_GNB, GNB_MODULE_ID_TO_INSTANCE(gnb_id), msg_p);
+ }
} else {
printf("No ITTI, Initializing L1\n");
return 0;
@@ -624,7 +639,7 @@ int main( int argc, char **argv )
0);
NR_UE_rrc_inst[ctxt.module_id].Info[0].State = RRC_SI_RECEIVED;
- rrc_ue_generate_RRCSetupRequest(&ctxt, 0);
+ nr_rrc_ue_generate_RRCSetupRequest(ctxt.module_id, 0);
printf("Entering ITTI signals handler\n");
itti_wait_tasks_end();
diff --git a/openair3/GTPV1-U/gtpv1u_gNB.c b/openair3/GTPV1-U/gtpv1u_gNB.c
index 19d2440a95..956ab0a4b3 100644
--- a/openair3/GTPV1-U/gtpv1u_gNB.c
+++ b/openair3/GTPV1-U/gtpv1u_gNB.c
@@ -309,6 +309,106 @@ void *gtpv1u_gNB_task(void *args) {
return NULL;
}
+/* Callback called when a gtpv1u message arrived on UDP interface */
+NwGtpv1uRcT nr_gtpv1u_gNB_process_stack_req(
+ NwGtpv1uUlpHandleT hUlp,
+ NwGtpv1uUlpApiT *pUlpApi) {
+ boolean_t result = FALSE;
+ teid_t teid = 0;
+ hashtable_rc_t hash_rc = HASH_TABLE_KEY_NOT_EXISTS;
+ nr_gtpv1u_teid_data_t *gtpv1u_teid_data_p = NULL;
+ protocol_ctxt_t ctxt;
+ NwGtpv1uRcT rc;
+
+ switch(pUlpApi->apiType) {
+ /* Here there are two type of messages handled:
+ * - T-PDU
+ * - END-MARKER
+ */
+ case NW_GTPV1U_ULP_API_RECV_TPDU: {
+ uint8_t buffer[4096];
+ uint32_t buffer_len;
+ //uint16_t msgType = NW_GTP_GPDU;
+ //NwGtpv1uMsgT *pMsg = NULL;
+ /* Nw-gptv1u stack has processed a PDU. we can schedule it to PDCP
+ * for transmission.
+ */
+ teid = pUlpApi->apiInfo.recvMsgInfo.teid;
+ //pMsg = (NwGtpv1uMsgT *) pUlpApi->apiInfo.recvMsgInfo.hMsg;
+ //msgType = pMsg->msgType;
+
+ if (NW_GTPV1U_OK != nwGtpv1uMsgGetTpdu(pUlpApi->apiInfo.recvMsgInfo.hMsg,
+ buffer, &buffer_len)) {
+ LOG_E(GTPU, "Error while retrieving T-PDU");
+ }
+
+ itti_free(TASK_UDP, ((NwGtpv1uMsgT *)pUlpApi->apiInfo.recvMsgInfo.hMsg)->msgBuf);
+#if defined(GTP_DUMP_SOCKET) && GTP_DUMP_SOCKET > 0
+ gtpv1u_eNB_write_dump_socket(buffer,buffer_len);
+#endif
+ rc = nwGtpv1uMsgDelete(RC.nr_gtpv1u_data_g->gtpv1u_stack,
+ pUlpApi->apiInfo.recvMsgInfo.hMsg);
+
+ if (rc != NW_GTPV1U_OK) {
+ LOG_E(GTPU, "nwGtpv1uMsgDelete failed: 0x%x\n", rc);
+ }
+
+ hash_rc = hashtable_get(RC.nr_gtpv1u_data_g->teid_mapping, teid, (void **)>pv1u_teid_data_p);
+
+ if (hash_rc == HASH_TABLE_OK) {
+// #if defined(LOG_GTPU) && LOG_GTPU > 0
+ LOG_D(GTPU, "Received T-PDU from gtpv1u stack teid %u size %d -> gnb module id %u ue module id %u pdu session id %u\n",
+ teid,
+ buffer_len,
+ gtpv1u_teid_data_p->gnb_id,
+ gtpv1u_teid_data_p->ue_id,
+ gtpv1u_teid_data_p->pdu_session_id);
+// #endif
+ //warning "LG eps bearer mapping to DRB id to do (offset -4)"
+ PROTOCOL_CTXT_SET_BY_MODULE_ID(&ctxt, gtpv1u_teid_data_p->gnb_id, GNB_FLAG_YES, gtpv1u_teid_data_p->ue_id, 0, 0,gtpv1u_teid_data_p->gnb_id);
+ // MSC_LOG_TX_MESSAGE(
+ // MSC_GTPU_ENB,
+ // MSC_PDCP_ENB,
+ // NULL,0,
+ // MSC_AS_TIME_FMT" DATA-REQ rb %u size %u",
+ // 0,0,
+ // (gtpv1u_teid_data_p->eps_bearer_id) ? gtpv1u_teid_data_p->eps_bearer_id - 4: 5-4,
+ // buffer_len);
+
+ result = pdcp_data_req(
+ &ctxt,
+ SRB_FLAG_NO,
+ 1,
+ 0, // mui
+ SDU_CONFIRM_NO, // confirm
+ buffer_len,
+ buffer,
+ PDCP_TRANSMISSION_MODE_DATA,NULL, NULL
+ );
+
+ if ( result == FALSE ) {
+ if (ctxt.configured == FALSE )
+ LOG_W(GTPU, "gNB node PDCP data request failed, cause: [UE:%x]RB is not configured!\n", ctxt.rnti) ;
+ else
+ LOG_W(GTPU, "PDCP data request failed\n");
+
+ return NW_GTPV1U_FAILURE;
+ }
+ } else {
+ LOG_W(GTPU, "Received T-PDU from gtpv1u stack teid %u unknown size %u", teid, buffer_len);
+ }
+ }
+ break;
+
+ default: {
+ LOG_E(GTPU, "Received undefined UlpApi (%02x) from gtpv1u stack!\n",
+ pUlpApi->apiType);
+ }
+ } // end of switch
+
+ return NW_GTPV1U_OK;
+}
+
int nr_gtpv1u_gNB_init(void) {
NwGtpv1uRcT rc = NW_GTPV1U_FAILURE;
NwGtpv1uUlpEntityT ulp;
@@ -344,7 +444,7 @@ int nr_gtpv1u_gNB_init(void) {
/* Set the ULP API callback. Called once message have been processed by the
* nw-gtpv1u stack.
*/
- ulp.ulpReqCallback = gtpv1u_gNB_process_stack_req;
+ ulp.ulpReqCallback = nr_gtpv1u_gNB_process_stack_req;
memset((void *)&(ulp.hUlp), 0, sizeof(NwGtpv1uUlpHandleT));
if ((rc = nwGtpv1uSetUlpEntity(RC.nr_gtpv1u_data_g->gtpv1u_stack, &ulp)) != NW_GTPV1U_OK) {
@@ -751,6 +851,79 @@ static int gtpv1u_ng_req(
return 0;
}
+static int gtpv1u_gnb_tunnel_data_req(gtpv1u_gnb_tunnel_data_req_t *gnb_tunnel_data_req) {
+ gtpv1u_gnb_tunnel_data_req_t *data_req_p = NULL;
+ NwGtpv1uUlpApiT stack_req;
+ NwGtpv1uRcT rc = NW_GTPV1U_FAILURE;
+ hashtable_rc_t hash_rc = HASH_TABLE_KEY_NOT_EXISTS;
+ nr_gtpv1u_ue_data_t *gtpv1u_ue_data_p = NULL;
+ teid_t gnb_ngu_teid = 0;
+ teid_t upf_ngu_teid = 0;
+ VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_GTPV1U_PROCESS_TUNNEL_DATA_REQ, VCD_FUNCTION_IN);
+ data_req_p = gnb_tunnel_data_req;
+
+ memset(&stack_req, 0, sizeof(NwGtpv1uUlpApiT));
+ hash_rc = hashtable_get(RC.nr_gtpv1u_data_g->ue_mapping, (uint64_t)data_req_p->rnti, (void **)>pv1u_ue_data_p);
+
+ if (hash_rc == HASH_TABLE_KEY_NOT_EXISTS) {
+ LOG_E(GTPU, "nwGtpv1uProcessUlpReq failed: while getting ue rnti %x in hashtable ue_mapping\n", data_req_p->rnti);
+ } else {
+ if ((data_req_p->pdusession_id >= GTPV1U_BEARER_OFFSET) && (data_req_p->pdusession_id < max_val_NR_DRB_Identity)) {
+ gnb_ngu_teid = gtpv1u_ue_data_p->bearers[data_req_p->pdusession_id - GTPV1U_BEARER_OFFSET].teid_gNB;
+ upf_ngu_teid = gtpv1u_ue_data_p->bearers[data_req_p->pdusession_id - GTPV1U_BEARER_OFFSET].teid_upf;
+ stack_req.apiType = NW_GTPV1U_ULP_API_SEND_TPDU;
+ stack_req.apiInfo.sendtoInfo.teid = upf_ngu_teid;
+ stack_req.apiInfo.sendtoInfo.ipAddr = gtpv1u_ue_data_p->bearers[data_req_p->pdusession_id - GTPV1U_BEARER_OFFSET].upf_ip_addr;
+ rc = nwGtpv1uGpduMsgNew(
+ RC.nr_gtpv1u_data_g->gtpv1u_stack,
+ upf_ngu_teid,
+ NW_FALSE,
+ RC.nr_gtpv1u_data_g->seq_num++,
+ data_req_p->buffer,
+ data_req_p->length,
+ data_req_p->offset,
+ &(stack_req.apiInfo.sendtoInfo.hMsg));
+
+ if (rc != NW_GTPV1U_OK) {
+ LOG_E(GTPU, "nwGtpv1uGpduMsgNew failed: 0x%x\n", rc);
+ MSC_LOG_EVENT(MSC_GTPU_GNB,"0 Failed send G-PDU ltid %u rtid %u size %u",
+ gnb_ngu_teid,upf_ngu_teid,data_req_p->length);
+ (void)gnb_ngu_teid; /* avoid gcc warning "set but not used" */
+ } else {
+ rc = nwGtpv1uProcessUlpReq(RC.nr_gtpv1u_data_g->gtpv1u_stack, &stack_req);
+
+ if (rc != NW_GTPV1U_OK) {
+ LOG_E(GTPU, "nwGtpv1uProcessUlpReq failed: 0x%x\n", rc);
+ MSC_LOG_EVENT(MSC_GTPU_GNB,"0 Failed send G-PDU ltid %u rtid %u size %u",
+ gnb_ngu_teid,upf_ngu_teid,data_req_p->length);
+ } else {
+ MSC_LOG_TX_MESSAGE(
+ MSC_GTPU_GNB,
+ MSC_GTPU_SGW,
+ NULL,
+ 0,
+ MSC_AS_TIME_FMT" G-PDU ltid %u rtid %u size %u",
+ 0,0,
+ gnb_ngu_teid,
+ upf_ngu_teid,
+ data_req_p->length);
+ }
+
+ rc = nwGtpv1uMsgDelete(RC.nr_gtpv1u_data_g->gtpv1u_stack,
+ stack_req.apiInfo.sendtoInfo.hMsg);
+
+ if (rc != NW_GTPV1U_OK) {
+ LOG_E(GTPU, "nwGtpv1uMsgDelete failed: 0x%x\n", rc);
+ }
+ }
+ }
+ }
+
+ VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_GTPV1U_PROCESS_TUNNEL_DATA_REQ, VCD_FUNCTION_OUT);
+ /* Buffer still needed, do not free it */
+ //itti_free(ITTI_MSG_ORIGIN_ID(received_message_p), data_req_p->buffer);
+}
+
//-----------------------------------------------------------------------------
void *gtpv1u_gNB_process_itti_msg(void *notUsed) {
/* Trying to fetch a message from the message queue.
@@ -774,6 +947,24 @@ void *gtpv1u_gNB_process_itti_msg(void *notUsed) {
gtpv1u_delete_ngu_tunnel(instance, &received_message_p->ittiMsg.NRGtpv1uDeleteTunnelReq);
break;
+ // DATA COMING FROM UDP
+ case UDP_DATA_IND: {
+ udp_data_ind_t *udp_data_ind_p;
+ udp_data_ind_p = &received_message_p->ittiMsg.udp_data_ind;
+ nwGtpv1uProcessUdpReq(RC.nr_gtpv1u_data_g->gtpv1u_stack,
+ udp_data_ind_p->buffer,
+ udp_data_ind_p->buffer_length,
+ udp_data_ind_p->peer_port,
+ udp_data_ind_p->peer_address);
+ }
+ break;
+
+ // DATA TO BE SENT TO UDP
+ case GTPV1U_GNB_TUNNEL_DATA_REQ:
+ LOG_I(GTPU, "Received message %s\n", ITTI_MSG_NAME(received_message_p));
+ gtpv1u_gnb_tunnel_data_req(>PV1U_GNB_TUNNEL_DATA_REQ(received_message_p));
+ break;
+
case TERMINATE_MESSAGE: {
if (RC.nr_gtpv1u_data_g->ue_mapping != NULL) {
hashtable_destroy (&(RC.nr_gtpv1u_data_g->ue_mapping));
diff --git a/openair3/NAS/NR_UE/nr_nas_msg_sim.c b/openair3/NAS/NR_UE/nr_nas_msg_sim.c
index 2c07de8dd5..008ecc8e36 100644
--- a/openair3/NAS/NR_UE/nr_nas_msg_sim.c
+++ b/openair3/NAS/NR_UE/nr_nas_msg_sim.c
@@ -38,6 +38,8 @@
#include "aka_functions.h"
#include "secu_defs.h"
#include "PduSessionEstablishRequest.h"
+# include "intertask_interface.h"
+
char netName[] = "5G:mnc093.mcc208.3gppnetwork.org";
char imsi[] = "2089300007487";
// USIM_API_K: 5122250214c33e723a5dd523fc145fc0
@@ -690,3 +692,199 @@ void generatePduSessionEstablishRequest(as_nas_info_t *initialNasMsg){
initialNasMsg->data[2+i] = mac[i];
}
}
+
+void *nas_nrue_task(void *args_p)
+{
+ MessageDef *msg_p;
+ instance_t instance;
+ unsigned int Mod_id;
+ int result;
+ uint8_t msg_type = 0;
+ uint8_t *pdu_buffer = NULL;
+
+ itti_mark_task_ready (TASK_NAS_NRUE);
+ MSC_START_USE();
+
+ while(1) {
+ // Wait for a message or an event
+ itti_receive_msg (TASK_NAS_NRUE, &msg_p);
+
+ if (msg_p != NULL) {
+ instance = msg_p->ittiMsgHeader.originInstance;
+ Mod_id = instance ;
+ if (instance == INSTANCE_DEFAULT) {
+ printf("%s:%d: FATAL: instance is INSTANCE_DEFAULT, should not happen.\n",
+ __FILE__, __LINE__);
+ exit_fun("exit... \n");
+ }
+
+ switch (ITTI_MSG_ID(msg_p)) {
+ case INITIALIZE_MESSAGE:
+ LOG_I(NAS, "[UE %d] Received %s\n", Mod_id, ITTI_MSG_NAME (msg_p));
+
+ break;
+
+ case TERMINATE_MESSAGE:
+ itti_exit_task ();
+ break;
+
+ case MESSAGE_TEST:
+ LOG_I(NAS, "[UE %d] Received %s\n", Mod_id, ITTI_MSG_NAME (msg_p));
+ break;
+
+ case NAS_CELL_SELECTION_CNF:
+ LOG_I(NAS, "[UE %d] Received %s: errCode %u, cellID %u, tac %u\n", Mod_id, ITTI_MSG_NAME (msg_p),
+ NAS_CELL_SELECTION_CNF (msg_p).errCode, NAS_CELL_SELECTION_CNF (msg_p).cellID, NAS_CELL_SELECTION_CNF (msg_p).tac);
+ // as_stmsi_t s_tmsi={0, 0};
+ // as_nas_info_t nas_info;
+ // plmn_t plmnID={0, 0, 0, 0};
+ // generateRegistrationRequest(&nas_info);
+ // nr_nas_itti_nas_establish_req(0, AS_TYPE_ORIGINATING_SIGNAL, s_tmsi, plmnID, nas_info.data, nas_info.length, 0);
+ break;
+
+ case NAS_CELL_SELECTION_IND:
+ LOG_I(NAS, "[UE %d] Received %s: cellID %u, tac %u\n", Mod_id, ITTI_MSG_NAME (msg_p),
+ NAS_CELL_SELECTION_IND (msg_p).cellID, NAS_CELL_SELECTION_IND (msg_p).tac);
+
+ /* TODO not processed by NAS currently */
+ break;
+
+ case NAS_PAGING_IND:
+ LOG_I(NAS, "[UE %d] Received %s: cause %u\n", Mod_id, ITTI_MSG_NAME (msg_p),
+ NAS_PAGING_IND (msg_p).cause);
+
+ /* TODO not processed by NAS currently */
+ break;
+
+ case NAS_CONN_ESTABLI_CNF:
+ {
+ LOG_I(NAS, "[UE %d] Received %s: errCode %u, length %u\n", Mod_id, ITTI_MSG_NAME (msg_p),
+ NAS_CONN_ESTABLI_CNF (msg_p).errCode, NAS_CONN_ESTABLI_CNF (msg_p).nasMsg.length);
+
+ pdu_buffer = NAS_CONN_ESTABLI_CNF (msg_p).nasMsg.data;
+ if((pdu_buffer + 1) != NULL){
+ if (*(pdu_buffer + 1) > 0 ) {
+ if((pdu_buffer + 9) != NULL){
+ msg_type = *(pdu_buffer + 9);
+ } else {
+ LOG_W(NAS, "[UE] Received invalid downlink message\n");
+ break;
+ }
+ } else {
+ if((pdu_buffer + 2) != NULL){
+ msg_type = *(pdu_buffer + 2);
+ } else {
+ LOG_W(NAS, "[UE] Received invalid downlink message\n");
+ break;
+ }
+ }
+ }
+ if(msg_type == REGISTRATION_ACCEPT){
+ LOG_I(NAS, "[UE] Received REGISTRATION ACCEPT message\n");
+
+ as_nas_info_t initialNasMsg;
+ memset(&initialNasMsg, 0, sizeof(as_nas_info_t));
+ generateRegistrationComplete(&initialNasMsg, NULL);
+ if(initialNasMsg.length > 0){
+ MessageDef *message_p;
+ message_p = itti_alloc_new_message(TASK_NAS_NRUE, 0, NAS_UPLINK_DATA_REQ);
+ NAS_UPLINK_DATA_REQ(message_p).UEid = Mod_id;
+ NAS_UPLINK_DATA_REQ(message_p).nasMsg.data = (uint8_t *)initialNasMsg.data;
+ NAS_UPLINK_DATA_REQ(message_p).nasMsg.length = initialNasMsg.length;
+ itti_send_msg_to_task(TASK_RRC_NRUE, instance, message_p);
+ LOG_I(NAS, "Send NAS_UPLINK_DATA_REQ message(RegistrationComplete)\n");
+ }
+
+ as_nas_info_t pduEstablishMsg;
+ memset(&pduEstablishMsg, 0, sizeof(as_nas_info_t));
+ generatePduSessionEstablishRequest(&pduEstablishMsg);
+ if(pduEstablishMsg.length > 0){
+ MessageDef *message_p;
+ message_p = itti_alloc_new_message(TASK_NAS_NRUE, 0, NAS_UPLINK_DATA_REQ);
+ NAS_UPLINK_DATA_REQ(message_p).UEid = Mod_id;
+ NAS_UPLINK_DATA_REQ(message_p).nasMsg.data = (uint8_t *)pduEstablishMsg.data;
+ NAS_UPLINK_DATA_REQ(message_p).nasMsg.length = pduEstablishMsg.length;
+ itti_send_msg_to_task(TASK_RRC_NRUE, instance, message_p);
+ LOG_I(NAS, "Send NAS_UPLINK_DATA_REQ message(PduSessionEstablishRequest)\n");
+ }
+ }
+
+ break;
+ }
+
+ case NAS_CONN_RELEASE_IND:
+ LOG_I(NAS, "[UE %d] Received %s: cause %u\n", Mod_id, ITTI_MSG_NAME (msg_p),
+ NAS_CONN_RELEASE_IND (msg_p).cause);
+
+ break;
+
+ case NAS_UPLINK_DATA_CNF:
+ LOG_I(NAS, "[UE %d] Received %s: UEid %u, errCode %u\n", Mod_id, ITTI_MSG_NAME (msg_p),
+ NAS_UPLINK_DATA_CNF (msg_p).UEid, NAS_UPLINK_DATA_CNF (msg_p).errCode);
+
+ break;
+
+ case NAS_DOWNLINK_DATA_IND:
+ {
+ LOG_I(NAS, "[UE %d] Received %s: UEid %u, length %u , buffer %p\n", Mod_id,
+ ITTI_MSG_NAME (msg_p),
+ Mod_id,
+ NAS_DOWNLINK_DATA_IND(msg_p).nasMsg.length,
+ NAS_DOWNLINK_DATA_IND(msg_p).nasMsg.data);
+ as_nas_info_t initialNasMsg;
+ memset(&initialNasMsg, 0, sizeof(as_nas_info_t));
+
+ pdu_buffer = NAS_DOWNLINK_DATA_IND(msg_p).nasMsg.data;
+ if((pdu_buffer + 1) != NULL){
+ if (*(pdu_buffer + 1) > 0 ) {
+ msg_type = *(pdu_buffer + 9);
+ } else {
+ msg_type = *(pdu_buffer + 2);
+ }
+ }
+ if((pdu_buffer + 2) == NULL){
+ LOG_W(NAS, "[UE] Received invalid downlink message\n");
+ return 0;
+ }
+
+ switch(msg_type){
+ case FGS_IDENTITY_REQUEST:
+ generateIdentityResponse(&initialNasMsg,*(pdu_buffer+3));
+ break;
+ case FGS_AUTHENTICATION_REQUEST:
+ generateAuthenticationResp(&initialNasMsg, pdu_buffer);
+ break;
+ case FGS_SECURITY_MODE_COMMAND:
+ generateSecurityModeComplete(&initialNasMsg);
+ break;
+ default:
+ LOG_W(NR_RRC,"unknow message type %d\n",msg_type);
+ break;
+ }
+
+ if(initialNasMsg.length > 0){
+ MessageDef *message_p;
+ message_p = itti_alloc_new_message(TASK_NAS_NRUE, 0, NAS_UPLINK_DATA_REQ);
+ NAS_UPLINK_DATA_REQ(message_p).UEid = Mod_id;
+ NAS_UPLINK_DATA_REQ(message_p).nasMsg.data = (uint8_t *)initialNasMsg.data;
+ NAS_UPLINK_DATA_REQ(message_p).nasMsg.length = initialNasMsg.length;
+ itti_send_msg_to_task(TASK_RRC_NRUE, instance, message_p);
+ LOG_I(NAS, "Send NAS_UPLINK_DATA_REQ message\n");
+ }
+
+ break;
+ }
+
+ default:
+ LOG_E(NAS, "[UE %d] Received unexpected message %s\n", 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;
+ }
+ }
+
+ return NULL;
+}
diff --git a/openair3/NAS/NR_UE/nr_nas_msg_sim.h b/openair3/NAS/NR_UE/nr_nas_msg_sim.h
index fef4671f43..2f123a6f04 100644
--- a/openair3/NAS/NR_UE/nr_nas_msg_sim.h
+++ b/openair3/NAS/NR_UE/nr_nas_msg_sim.h
@@ -120,6 +120,7 @@ void generateAuthenticationResp(as_nas_info_t *initialNasMsg, uint8_t *buf);
void generateSecurityModeComplete(as_nas_info_t *initialNasMsg);
void generateRegistrationComplete(as_nas_info_t *initialNasMsg, SORTransparentContainer *sortransparentcontainer);
void generatePduSessionEstablishRequest(as_nas_info_t *initialNasMsg);
+void *nas_nrue_task(void *args_p);
#endif /* __NR_NAS_MSG_SIM_H__*/
diff --git a/targets/ARCH/COMMON/record_player.c b/targets/ARCH/COMMON/record_player.c
index 2dcd61e479..522f6b6d16 100644
--- a/targets/ARCH/COMMON/record_player.c
+++ b/targets/ARCH/COMMON/record_player.c
@@ -68,8 +68,10 @@ int read_recplayconfig(recplay_conf_t **recplay_conf, recplay_state_t **recplay_
*recplay_conf=NULL;
}
- if (u_sf_replay == 1) return RECPLAY_REPLAYMODE;
- else if (u_sf_record == 1) return RECPLAY_RECORDMODE;
+ if (u_sf_replay == 1)
+ return RECPLAY_REPLAYMODE;
+ else if (u_sf_record == 1)
+ return RECPLAY_RECORDMODE;
return 0;
}
@@ -80,7 +82,7 @@ int read_recplayconfig(recplay_conf_t **recplay_conf, recplay_state_t **recplay_
*/
void iqrecorder_end(openair0_device *device) {
if (device->recplay_state != NULL) { // subframes store
- iqfile_header_t fh = {device->type,device->openair0_cfg->tx_sample_advance, device->openair0_cfg->rx_bw,OAIIQFILE_ID};
+ iqfile_header_t fh = {device->type,device->openair0_cfg->tx_sample_advance, device->openair0_cfg->rx_bw,0,OAIIQFILE_ID};
recplay_state_t *rs = device->recplay_state;
recplay_conf_t *rc = device->openair0_cfg[0].recplay_conf;
rs->pFile = fopen (rc->u_sf_filename,"wb+");
@@ -91,16 +93,20 @@ void iqrecorder_end(openair0_device *device) {
unsigned int i = 0;
unsigned int modu = 0;
- if ((modu = rs->nb_samples % 10) != 0) {
- rs->nb_samples -= modu; // store entire number of frames
+ if ((modu = rs->nbSamplesBlocks % 10) != 0) {
+ rs->nbSamplesBlocks -= modu; // store entire number of frames
}
+ fh.nbSamplesBlocks=rs->nbSamplesBlocks;
LOG_I(HW,"Writing file header to %s \n", rc->u_sf_filename );
fwrite(&fh, sizeof(fh), 1, rs->pFile);
- LOG_UI(HW,"Writing %u subframes to %s \n",rs->nb_samples, rc->u_sf_filename );
+ LOG_UI(HW,"Writing %u subframes to %s \n",rs->nbSamplesBlocks, rc->u_sf_filename );
+ uint8_t *ptr=(uint8_t *)rs->ms_sample;
- for (i = 0; i < rs->nb_samples; i++) {
- fwrite(rs->ms_sample+i, sizeof(unsigned char), sizeof(iqrec_t), rs->pFile);
+ for (i = 0; i < rs->nbSamplesBlocks; i++) {
+ int blockBytes=sizeof(iqrec_t)+((iqrec_t *)ptr)->nbBytes;
+ fwrite(ptr, sizeof(unsigned char), blockBytes, rs->pFile);
+ ptr+=blockBytes;
}
fclose (rs->pFile);
@@ -112,4 +118,4 @@ void iqrecorder_end(openair0_device *device) {
rs->ms_sample = NULL;
}
}
-}
\ No newline at end of file
+}
diff --git a/targets/ARCH/COMMON/record_player.h b/targets/ARCH/COMMON/record_player.h
index 500acdd709..d91da68323 100644
--- a/targets/ARCH/COMMON/record_player.h
+++ b/targets/ARCH/COMMON/record_player.h
@@ -46,21 +46,22 @@ extern "C"
#define BELL_LABS_IQ_HEADER 0xabababababababab
#define BELL_LABS_IQ_PER_SF 7680 // Up to 5MHz bw for now
#define BELL_LABS_IQ_BYTES_PER_SF (BELL_LABS_IQ_PER_SF * 4)
+#define MAX_BELL_LABS_IQ_BYTES_PER_SF BELL_LABS_IQ_BYTES_PER_SF*10
-#define OAIIQFILE_ID "OIQF"
+#define OAIIQFILE_ID {'O', 'I','Q','F'}
typedef struct {
uint64_t devtype;
uint64_t tx_sample_advance;
double bw;
+ unsigned int nbSamplesBlocks;
char oaiid[4];
} iqfile_header_t;
typedef struct {
int64_t header;
int64_t ts;
- int64_t rfu1;
+ int64_t nbBytes;
int64_t rfu2; // pad for 256 bits alignement required by AVX2
- unsigned char samples[BELL_LABS_IQ_BYTES_PER_SF]; // iq's for one subframe
} iqrec_t;
#define DEF_NB_SF 120000 // default nb of sf or ms to capture (2 minutes at 5MHz)
#define DEF_SF_FILE "/tmp/iqfile" // default subframes file name
@@ -114,14 +115,16 @@ typedef struct {
int use_mmap; // default is to use mmap
size_t mapsize;
FILE *pFile;
- int mmapfd;
- int iqfd;
+ int fd;
iqrec_t *ms_sample; // memory for all subframes
- unsigned int nb_samples;
+ unsigned int nbSamplesBlocks;
+ uint8_t *currentPtr;
+ uint64_t currentTs;
+ unsigned int curSamplesBlock;
+ int64_t wrap_count;
+ size_t maxSizeBytes;
} recplay_state_t;
-
-
#ifdef __cplusplus
}
#endif
diff --git a/targets/ARCH/USRP/USERSPACE/LIB/usrp_lib.cpp b/targets/ARCH/USRP/USERSPACE/LIB/usrp_lib.cpp
index dd29d01fae..d6ee1b340a 100644
--- a/targets/ARCH/USRP/USERSPACE/LIB/usrp_lib.cpp
+++ b/targets/ARCH/USRP/USERSPACE/LIB/usrp_lib.cpp
@@ -272,11 +272,10 @@ static int sync_to_gps(openair0_device *device) {
*/
static int trx_usrp_start(openair0_device *device) {
usrp_state_t *s = (usrp_state_t *)device->priv;
-
// setup GPIO for TDD, GPIO(4) = ATR_RX
//set data direction register (DDR) to output
s->usrp->set_gpio_attr("FP0", "DDR", 0xfff, 0xfff);
- //set lower 7 bits to be controlled automatically by ATR (the rest 5 bits are controlled manually)
+ //set lower 7 bits to be controlled automatically by ATR (the rest 5 bits are controlled manually)
s->usrp->set_gpio_attr("FP0", "CTRL", 0x7f,0xfff);
//set pins 4 (RX_TX_Switch) and 6 (Shutdown PA) to 1 when the radio is only receiving (ATR_RX)
s->usrp->set_gpio_attr("FP0", "ATR_RX", (1<<4)|(1<<6), 0x7f);
@@ -285,26 +284,24 @@ static int trx_usrp_start(openair0_device *device) {
s->usrp->set_gpio_attr("FP0", "ATR_XX", (1<<5), 0x7f);
// set the output pins to 1
s->usrp->set_gpio_attr("FP0", "OUT", 7<<7, 0xf80);
-
s->wait_for_first_pps = 1;
s->rx_count = 0;
s->tx_count = 0;
//s->first_tx = 1;
//s->first_rx = 1;
s->rx_timestamp = 0;
-
s->usrp->set_time_next_pps(uhd::time_spec_t(0.0));
// wait for the pps to change
uhd::time_spec_t time_last_pps = s->usrp->get_time_last_pps();
+
while (time_last_pps == s->usrp->get_time_last_pps()) {
boost::this_thread::sleep(boost::posix_time::milliseconds(1));
}
uhd::stream_cmd_t cmd(uhd::stream_cmd_t::STREAM_MODE_START_CONTINUOUS);
- cmd.time_spec = uhd::time_spec_t(1.0);
+ cmd.time_spec = uhd::time_spec_t(1.0);
cmd.stream_now = false; // start at constant delay
s->rx_stream->issue_stream_cmd(cmd);
-
return 0;
}
/*! \brief Terminate operation of the USRP transceiver -- free all associated resources
@@ -315,12 +312,11 @@ static void trx_usrp_end(openair0_device *device) {
return;
usrp_state_t *s = (usrp_state_t *)device->priv;
-
+
if (s == NULL)
return;
+
iqrecorder_end(device);
-
-
}
/*! \brief Called to send samples to the USRP RF target
@@ -332,64 +328,59 @@ static void trx_usrp_end(openair0_device *device) {
@param flags flags must be set to TRUE if timestamp parameter needs to be applied
*/
static int trx_usrp_write(openair0_device *device,
- openair0_timestamp timestamp,
- void **buff,
- int nsamps,
- int cc,
- int flags) {
+ openair0_timestamp timestamp,
+ void **buff,
+ int nsamps,
+ int cc,
+ int flags) {
int ret=0;
usrp_state_t *s = (usrp_state_t *)device->priv;
int nsamps2; // aligned to upper 32 or 16 byte boundary
-
int flags_lsb = flags&0xff;
int flags_msb = (flags>>8)&0xff;
-
int end;
openair0_thread_t *write_thread = &device->write_thread;
openair0_write_package_t *write_package = write_thread->write_package;
-
AssertFatal( MAX_WRITE_THREAD_BUFFER_SIZE >= cc,"Do not support more than %d cc number\n", MAX_WRITE_THREAD_BUFFER_SIZE);
+ boolean_t first_packet_state=false,last_packet_state=false;
- boolean_t first_packet_state=false,last_packet_state=false;
-
- if (flags_lsb == 2) { // start of burst
- // s->tx_md.start_of_burst = true;
- // s->tx_md.end_of_burst = false;
- first_packet_state = true;
- last_packet_state = false;
- } else if (flags_lsb == 3) { // end of burst
- //s->tx_md.start_of_burst = false;
- //s->tx_md.end_of_burst = true;
- first_packet_state = false;
- last_packet_state = true;
- } else if (flags_lsb == 4) { // start and end
+ if (flags_lsb == 2) { // start of burst
+ // s->tx_md.start_of_burst = true;
+ // s->tx_md.end_of_burst = false;
+ first_packet_state = true;
+ last_packet_state = false;
+ } else if (flags_lsb == 3) { // end of burst
+ //s->tx_md.start_of_burst = false;
+ //s->tx_md.end_of_burst = true;
+ first_packet_state = false;
+ last_packet_state = true;
+ } else if (flags_lsb == 4) { // start and end
// s->tx_md.start_of_burst = true;
// s->tx_md.end_of_burst = true;
- first_packet_state = true;
- last_packet_state = true;
- } else if (flags_lsb==1) { // middle of burst
+ first_packet_state = true;
+ last_packet_state = true;
+ } else if (flags_lsb==1) { // middle of burst
// s->tx_md.start_of_burst = false;
// s->tx_md.end_of_burst = false;
- first_packet_state = false;
- last_packet_state = false;
- }
- else if (flags_lsb==10) { // fail safe mode
- // s->tx_md.has_time_spec = false;
- // s->tx_md.start_of_burst = false;
- // s->tx_md.end_of_burst = true;
- first_packet_state = false;
- last_packet_state = true;
- }
+ first_packet_state = false;
+ last_packet_state = false;
+ } else if (flags_lsb==10) { // fail safe mode
+ // s->tx_md.has_time_spec = false;
+ // s->tx_md.start_of_burst = false;
+ // s->tx_md.end_of_burst = true;
+ first_packet_state = false;
+ last_packet_state = true;
+ }
- if(usrp_tx_thread == 0){
+ if(usrp_tx_thread == 0) {
#if defined(__x86_64) || defined(__i386__)
- #ifdef __AVX2__
- nsamps2 = (nsamps+7)>>3;
- __m256i buff_tx[8][nsamps2];
- #else
+#ifdef __AVX2__
+ nsamps2 = (nsamps+7)>>3;
+ __m256i buff_tx[8][nsamps2];
+#else
nsamps2 = (nsamps+3)>>2;
__m128i buff_tx[8][nsamps2];
- #endif
+#endif
#elif defined(__arm__)
nsamps2 = (nsamps+3)>>2;
int16x8_t buff_tx[8][nsamps2];
@@ -417,8 +408,8 @@ static int trx_usrp_write(openair0_device *device,
s->tx_md.end_of_burst = last_packet_state;
s->tx_md.time_spec = uhd::time_spec_t::from_ticks(timestamp, s->sample_rate);
s->tx_count++;
+ VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_BEAM_SWITCHING_GPIO,1);
-VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_BEAM_SWITCHING_GPIO,1);
// bit 3 enables gpio (for backward compatibility)
if (flags_msb&8) {
// push GPIO bits 7-9 from flags_msb
@@ -427,7 +418,8 @@ VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_BEAM_SWITCHI
s->usrp->set_gpio_attr("FP0", "OUT", gpio789, 0x380);
s->usrp->clear_command_time();
}
-VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_BEAM_SWITCHING_GPIO,0);
+
+ VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_BEAM_SWITCHING_GPIO,0);
if (cc>1) {
std::vector buff_ptrs;
@@ -436,18 +428,18 @@ VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_BEAM_SWITCHI
buff_ptrs.push_back(&(((int16_t *)buff_tx[i])[0]));
ret = (int)s->tx_stream->send(buff_ptrs, nsamps, s->tx_md);
- }
- else {
+ } else {
ret = (int)s->tx_stream->send(&(((int16_t *)buff_tx[0])[0]), nsamps, s->tx_md);
}
- if (ret != nsamps) LOG_E(HW,"[xmit] tx samples %d != %d\n",ret,nsamps);
+ if (ret != nsamps)
+ LOG_E(HW,"[xmit] tx samples %d != %d\n",ret,nsamps);
+
return ret;
- }
- else{
+ } else {
pthread_mutex_lock(&write_thread->mutex_write);
- if(write_thread->count_write >= MAX_WRITE_THREAD_PACKAGE){
+ if(write_thread->count_write >= MAX_WRITE_THREAD_PACKAGE) {
LOG_W(HW,"Buffer overflow, count_write = %d, start = %d end = %d, resetting write package\n", write_thread->count_write, write_thread->start, write_thread->end);
write_thread->end = write_thread->start;
write_thread->count_write = 0;
@@ -460,15 +452,16 @@ VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_BEAM_SWITCHI
write_package[end].first_packet = first_packet_state;
write_package[end].last_packet = last_packet_state;
write_package[end].flags_msb = flags_msb;
+
for (int i = 0; i < cc; i++)
write_package[end].buff[i] = buff[i];
+
write_thread->count_write++;
write_thread->end = (write_thread->end + 1)% MAX_WRITE_THREAD_PACKAGE;
pthread_cond_signal(&write_thread->cond_write);
pthread_mutex_unlock(&write_thread->mutex_write);
return 0;
}
-
}
//-----------------------start--------------------------
@@ -480,12 +473,11 @@ VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_BEAM_SWITCHI
@param antenna_id index of the antenna if the device has multiple antennas
@param flags flags must be set to TRUE if timestamp parameter needs to be applied
*/
-void *trx_usrp_write_thread(void * arg){
+void *trx_usrp_write_thread(void *arg) {
int ret=0;
openair0_device *device=(openair0_device *)arg;
openair0_thread_t *write_thread = &device->write_thread;
openair0_write_package_t *write_package = write_thread->write_package;
-
usrp_state_t *s;
int nsamps2; // aligned to upper 32 or 16 byte boundary
int start;
@@ -497,11 +489,13 @@ void *trx_usrp_write_thread(void * arg){
signed char last_packet;
int flags_msb;
- while(1){
+ while(1) {
pthread_mutex_lock(&write_thread->mutex_write);
+
while (write_thread->count_write == 0) {
pthread_cond_wait(&write_thread->cond_write,&write_thread->mutex_write); // this unlocks mutex_rxtx while waiting and then locks it again
}
+
VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME( VCD_SIGNAL_DUMPER_FUNCTIONS_TRX_WRITE_THREAD, 1 );
s = (usrp_state_t *)device->priv;
start = write_thread->start;
@@ -518,38 +512,36 @@ void *trx_usrp_write_thread(void * arg){
/*if(write_thread->count_write != 0){
LOG_W(HW,"count write = %d, start = %d, end = %d\n", write_thread->count_write, write_thread->start, write_thread->end);
}*/
-
- #if defined(__x86_64) || defined(__i386__)
- #ifdef __AVX2__
- nsamps2 = (nsamps+7)>>3;
- __m256i buff_tx[8][nsamps2];
- #else
- nsamps2 = (nsamps+3)>>2;
- __m128i buff_tx[8][nsamps2];
- #endif
- #elif defined(__arm__)
- nsamps2 = (nsamps+3)>>2;
- int16x8_t buff_tx[8][nsamps2];
- #else
- #error Unsupported CPU architecture, USRP device cannot be built
- #endif
+#if defined(__x86_64) || defined(__i386__)
+#ifdef __AVX2__
+ nsamps2 = (nsamps+7)>>3;
+ __m256i buff_tx[8][nsamps2];
+#else
+ nsamps2 = (nsamps+3)>>2;
+ __m128i buff_tx[8][nsamps2];
+#endif
+#elif defined(__arm__)
+ nsamps2 = (nsamps+3)>>2;
+ int16x8_t buff_tx[8][nsamps2];
+#else
+#error Unsupported CPU architecture, USRP device cannot be built
+#endif
// bring RX data into 12 LSBs for softmodem RX
for (int i=0; itx_md.has_time_spec = true;
s->tx_md.start_of_burst = (s->tx_count==0) ? true : first_packet;
s->tx_md.end_of_burst = last_packet;
@@ -572,34 +564,32 @@ void *trx_usrp_write_thread(void * arg){
buff_ptrs.push_back(&(((int16_t *)buff_tx[i])[0]));
ret = (int)s->tx_stream->send(buff_ptrs, nsamps, s->tx_md);
- }
- else {
+ } else {
ret = (int)s->tx_stream->send(&(((int16_t *)buff_tx[0])[0]), nsamps, s->tx_md);
}
- if (ret != nsamps) LOG_E(HW,"[xmit] tx samples %d != %d\n",ret,nsamps);
+ if (ret != nsamps)
+ LOG_E(HW,"[xmit] tx samples %d != %d\n",ret,nsamps);
+
VCD_SIGNAL_DUMPER_DUMP_VARIABLE_BY_NAME( VCD_SIGNAL_DUMPER_VARIABLES_USRP_SEND_RETURN, ret );
VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME( VCD_SIGNAL_DUMPER_FUNCTIONS_TRX_WRITE_THREAD, 0 );
- if(0) break;
+ if(0)
+ break;
}
return NULL;
}
-int trx_usrp_write_init(openair0_device *device){
-
+int trx_usrp_write_init(openair0_device *device) {
uhd::set_thread_priority_safe(1.0);
openair0_thread_t *write_thread = &device->write_thread;
printf("initializing tx write thread\n");
-
write_thread->start = 0;
write_thread->end = 0;
write_thread->count_write = 0;
printf("end of tx write thread\n");
-
pthread_create(&write_thread->pthread_write,NULL,trx_usrp_write_thread,(void *)device);
-
return(0);
}
@@ -633,57 +623,60 @@ static int trx_usrp_read(openair0_device *device, openair0_timestamp *ptimestamp
int16x8_t buff_tmp[2][nsamps2];
#endif
- if (cc>1) {
- // receive multiple channels (e.g. RF A and RF B)
- std::vector buff_ptrs;
+ if (cc>1) {
+ // receive multiple channels (e.g. RF A and RF B)
+ std::vector buff_ptrs;
- for (int i=0; irx_stream->recv(buff_ptrs, nsamps, s->rx_md);
- } else {
- // receive a single channel (e.g. from connector RF A)
- samples_received=0;
+ samples_received = s->rx_stream->recv(buff_ptrs, nsamps, s->rx_md);
+ } else {
+ // receive a single channel (e.g. from connector RF A)
+ samples_received=0;
- while (samples_received != nsamps) {
- samples_received += s->rx_stream->recv((void*)((int32_t*)buff_tmp[0]+samples_received),
- nsamps-samples_received, s->rx_md);
+ while (samples_received != nsamps) {
+ samples_received += s->rx_stream->recv((void *)((int32_t *)buff_tmp[0]+samples_received),
+ nsamps-samples_received, s->rx_md);
- if ((s->wait_for_first_pps == 0) && (s->rx_md.error_code!=uhd::rx_metadata_t::ERROR_CODE_NONE))
- break;
+ if ((s->wait_for_first_pps == 0) && (s->rx_md.error_code!=uhd::rx_metadata_t::ERROR_CODE_NONE))
+ break;
- if ((s->wait_for_first_pps == 1) && (samples_received != nsamps)) {
- printf("sleep...\n"); //usleep(100);
- }
+ if ((s->wait_for_first_pps == 1) && (samples_received != nsamps)) {
+ printf("sleep...\n"); //usleep(100);
}
- if (samples_received == nsamps) s->wait_for_first_pps=0;
}
- // bring RX data into 12 LSBs for softmodem RX
- for (int i=0; iwait_for_first_pps=0;
+ }
+
+ // bring RX data into 12 LSBs for softmodem RX
+ for (int i=0; irx_md.error_code != uhd::rx_metadata_t::ERROR_CODE_NONE)
LOG_E(HW, "%s\n", s->rx_md.to_pp_string(true).c_str());
@@ -691,21 +684,28 @@ static int trx_usrp_read(openair0_device *device, openair0_timestamp *ptimestamp
s->rx_count += nsamps;
s->rx_timestamp = s->rx_md.time_spec.to_ticks(s->sample_rate);
*ptimestamp = s->rx_timestamp;
-
// push GPIO bits 7-9 from flags_msb
- /*s->usrp->set_command_time(uhd::time_spec_t::from_ticks((s->rx_timestamp+(2*nsamps)),s->sample_rate));
- s->usrp->set_gpio_attr("FP0", "OUT", gpio789<<7, 0x380);
- s->usrp->clear_command_time();
- gpio789 = (gpio789+1)&7;*/
+ /*s->usrp->set_command_time(uhd::time_spec_t::from_ticks((s->rx_timestamp+(2*nsamps)),s->sample_rate));
+ s->usrp->set_gpio_attr("FP0", "OUT", gpio789<<7, 0x380);
+ s->usrp->clear_command_time();
+ gpio789 = (gpio789+1)&7;*/
+ recplay_state_t *recPlay=device->recplay_state;
- if (device->recplay_state != NULL) { // record mode
+ if ( recPlay != NULL) { // record mode
// Copy subframes to memory (later dump on a file)
- if (device->recplay_state->nb_samples < device->openair0_cfg->recplay_conf->u_sf_max) {
- (device->recplay_state->ms_sample+device->recplay_state->nb_samples)->header = BELL_LABS_IQ_HEADER;
- (device->recplay_state->ms_sample+device->recplay_state->nb_samples)->ts = *ptimestamp;
- memcpy((device->recplay_state->ms_sample+device->recplay_state->nb_samples)->samples, buff[0], nsamps*4);
- device->recplay_state->nb_samples++;
- } else exit_function(__FILE__, __FUNCTION__, __LINE__,"Recording reaches max iq limit\n");
+ if (recPlay->nbSamplesBlocks < device->openair0_cfg->recplay_conf->u_sf_max &&
+ recPlay->maxSizeBytes > (recPlay->currentPtr-(uint8_t *)recPlay->ms_sample) +
+ sizeof(iqrec_t) + nsamps*4 ) {
+ iqrec_t *hdr=(iqrec_t *)recPlay->currentPtr;
+ hdr->header = BELL_LABS_IQ_HEADER;
+ hdr->ts = *ptimestamp;
+ hdr->nbBytes=nsamps*4;
+ memcpy(hdr+1, buff[0], nsamps*4);
+ recPlay->currentPtr+=sizeof(iqrec_t)+nsamps*4;
+ recPlay->nbSamplesBlocks++;
+ LOG_D(HW,"recorded %d samples, for TS %lu, shift in buffer %ld\n", nsamps, hdr->ts, recPlay->currentPtr-(uint8_t *)recPlay->ms_sample);
+ } else
+ exit_function(__FILE__, __FUNCTION__, __LINE__,"Recording reaches max iq limit\n");
}
return samples_received;
@@ -937,32 +937,30 @@ extern "C" {
device->trx_set_freq_func = trx_usrp_set_freq;
device->trx_set_gains_func = trx_usrp_set_gains;
device->trx_write_init = trx_usrp_write_init;
-
-
// hotfix! to be checked later
uhd::set_thread_priority_safe(1.0);
// Initialize USRP device
int vers=0,subvers=0,subsubvers=0;
int bw_gain_adjust=0;
-
+
if (device->openair0_cfg->recplay_mode == RECPLAY_RECORDMODE) {
std::cerr << "USRP device initialized in subframes record mode" << std::endl;
}
-
+
sscanf(uhd::get_version_string().c_str(),"%d.%d.%d",&vers,&subvers,&subsubvers);
LOG_I(HW,"UHD version %s (%d.%d.%d)\n",
uhd::get_version_string().c_str(),vers,subvers,subsubvers);
std::string args;
-
+
if (openair0_cfg[0].sdr_addrs == NULL) {
args = "type=b200";
} else {
args = openair0_cfg[0].sdr_addrs;
LOG_I(HW,"Checking for USRP with args %s\n",openair0_cfg[0].sdr_addrs);
}
-
+
uhd::device_addrs_t device_adds = uhd::device::find(args);
-
+
if (device_adds.size() == 0) {
LOG_E(HW,"No USRP Device Found.\n ");
free(s);
@@ -972,375 +970,367 @@ extern "C" {
free(s);
return -1;
}
-
+
LOG_I(HW,"Found USRP %s\n", device_adds[0].get("type").c_str());
double usrp_master_clock;
-
+
if (device_adds[0].get("type") == "b200") {
device->type = USRP_B200_DEV;
usrp_master_clock = 30.72e6;
args += boost::str(boost::format(",master_clock_rate=%f") % usrp_master_clock);
args += ",num_send_frames=256,num_recv_frames=256, send_frame_size=7680, recv_frame_size=7680" ;
}
-
+
if (device_adds[0].get("type") == "n3xx") {
printf("Found USRP n300\n");
- device->type=USRP_N300_DEV;
+ device->type=USRP_N300_DEV;
usrp_master_clock = 122.88e6;
args += boost::str(boost::format(",master_clock_rate=%f") % usrp_master_clock);
//args += ", send_buff_size=33554432";
}
-
+
if (device_adds[0].get("type") == "x300") {
printf("Found USRP x300\n");
device->type=USRP_X300_DEV;
usrp_master_clock = 184.32e6;
args += boost::str(boost::format(",master_clock_rate=%f") % usrp_master_clock);
-
+
// USRP recommended: https://files.ettus.com/manual/page_usrp_x3x0_config.html
if ( 0 != system("sysctl -w net.core.rmem_max=33554432 net.core.wmem_max=33554432") )
LOG_W(HW,"Can't set kernel parameters for X3xx\n");
}
-
+
s->usrp = uhd::usrp::multi_usrp::make(args);
-
+
if (args.find("clock_source")==std::string::npos) {
- if (openair0_cfg[0].clock_source == internal) {
- s->usrp->set_clock_source("internal");
- LOG_D(HW,"Setting clock source to internal\n");
- }
- else if (openair0_cfg[0].clock_source == external ) {
- s->usrp->set_clock_source("external");
- LOG_D(HW,"Setting clock source to external\n");
- }
- else if (openair0_cfg[0].clock_source==gpsdo) {
- s->usrp->set_clock_source("gpsdo");
- LOG_D(HW,"Setting clock source to gpsdo\n");
- }
- else {
- LOG_W(HW,"Clock source set neither in usrp_args nor on command line, using default!\n");
- }
+ if (openair0_cfg[0].clock_source == internal) {
+ s->usrp->set_clock_source("internal");
+ LOG_D(HW,"Setting clock source to internal\n");
+ } else if (openair0_cfg[0].clock_source == external ) {
+ s->usrp->set_clock_source("external");
+ LOG_D(HW,"Setting clock source to external\n");
+ } else if (openair0_cfg[0].clock_source==gpsdo) {
+ s->usrp->set_clock_source("gpsdo");
+ LOG_D(HW,"Setting clock source to gpsdo\n");
+ } else {
+ LOG_W(HW,"Clock source set neither in usrp_args nor on command line, using default!\n");
+ }
+ } else {
+ if (openair0_cfg[0].clock_source != unset) {
+ LOG_W(HW,"Clock source set in both usrp_args and in clock_source, ingnoring the latter!\n");
+ }
}
- else {
- if (openair0_cfg[0].clock_source != unset) {
- LOG_W(HW,"Clock source set in both usrp_args and in clock_source, ingnoring the latter!\n");
- }
- }
if (args.find("time_source")==std::string::npos) {
- if (openair0_cfg[0].time_source == internal) {
- s->usrp->set_time_source("internal");
- LOG_D(HW,"Setting time source to internal\n");
- }
- else if (openair0_cfg[0].time_source == external ) {
- s->usrp->set_time_source("external");
- LOG_D(HW,"Setting time source to external\n");
- }
- else if (openair0_cfg[0].time_source==gpsdo) {
- s->usrp->set_time_source("gpsdo");
- LOG_D(HW,"Setting time source to gpsdo\n");
- }
- else {
- LOG_W(HW,"Time source set neither in usrp_args nor on command line, using default!\n");
- }
- }
- else {
- if (openair0_cfg[0].clock_source != unset) {
- LOG_W(HW,"Time source set in both usrp_args and in time_source, ingnoring the latter!\n");
- }
- }
-
-
- if (s->usrp->get_clock_source(0) == "gpsdo") {
- s->use_gps = 1;
-
- if (sync_to_gps(device)==EXIT_SUCCESS) {
- LOG_I(HW,"USRP synced with GPS!\n");
+ if (openair0_cfg[0].time_source == internal) {
+ s->usrp->set_time_source("internal");
+ LOG_D(HW,"Setting time source to internal\n");
+ } else if (openair0_cfg[0].time_source == external ) {
+ s->usrp->set_time_source("external");
+ LOG_D(HW,"Setting time source to external\n");
+ } else if (openair0_cfg[0].time_source==gpsdo) {
+ s->usrp->set_time_source("gpsdo");
+ LOG_D(HW,"Setting time source to gpsdo\n");
+ } else {
+ LOG_W(HW,"Time source set neither in usrp_args nor on command line, using default!\n");
+ }
} else {
- LOG_I(HW,"USRP fails to sync with GPS. Exiting.\n");
- exit(EXIT_FAILURE);
+ if (openair0_cfg[0].clock_source != unset) {
+ LOG_W(HW,"Time source set in both usrp_args and in time_source, ingnoring the latter!\n");
+ }
}
- } else if (s->usrp->get_clock_source(0) == "external") {
- if (check_ref_locked(s,0)) {
- LOG_I(HW,"USRP locked to external reference!\n");
- } else {
- LOG_I(HW,"Failed to lock to external reference. Exiting.\n");
- exit(EXIT_FAILURE);
+
+ if (s->usrp->get_clock_source(0) == "gpsdo") {
+ s->use_gps = 1;
+
+ if (sync_to_gps(device)==EXIT_SUCCESS) {
+ LOG_I(HW,"USRP synced with GPS!\n");
+ } else {
+ LOG_I(HW,"USRP fails to sync with GPS. Exiting.\n");
+ exit(EXIT_FAILURE);
+ }
+ } else if (s->usrp->get_clock_source(0) == "external") {
+ if (check_ref_locked(s,0)) {
+ LOG_I(HW,"USRP locked to external reference!\n");
+ } else {
+ LOG_I(HW,"Failed to lock to external reference. Exiting.\n");
+ exit(EXIT_FAILURE);
+ }
}
- }
-
- if (device->type==USRP_X300_DEV) {
- openair0_cfg[0].rx_gain_calib_table = calib_table_x310;
- std::cerr << "-- Using calibration table: calib_table_x310" << std::endl;
- }
- if (device->type==USRP_N300_DEV) {
- openair0_cfg[0].rx_gain_calib_table = calib_table_n310;
- std::cerr << "-- Using calibration table: calib_table_n310" << std::endl;
- }
+ if (device->type==USRP_X300_DEV) {
+ openair0_cfg[0].rx_gain_calib_table = calib_table_x310;
+ std::cerr << "-- Using calibration table: calib_table_x310" << std::endl;
+ }
+ if (device->type==USRP_N300_DEV) {
+ openair0_cfg[0].rx_gain_calib_table = calib_table_n310;
+ std::cerr << "-- Using calibration table: calib_table_n310" << std::endl;
+ }
- if (device->type==USRP_N300_DEV || device->type==USRP_X300_DEV) {
- LOG_I(HW,"%s() sample_rate:%u\n", __FUNCTION__, (int)openair0_cfg[0].sample_rate);
+ if (device->type==USRP_N300_DEV || device->type==USRP_X300_DEV) {
+ LOG_I(HW,"%s() sample_rate:%u\n", __FUNCTION__, (int)openair0_cfg[0].sample_rate);
- switch ((int)openair0_cfg[0].sample_rate) {
- case 122880000:
- // from usrp_time_offset
- //openair0_cfg[0].samples_per_packet = 2048;
- openair0_cfg[0].tx_sample_advance = 15; //to be checked
- openair0_cfg[0].tx_bw = 80e6;
- openair0_cfg[0].rx_bw = 80e6;
- break;
-
- case 92160000:
- // from usrp_time_offset
- //openair0_cfg[0].samples_per_packet = 2048;
- openair0_cfg[0].tx_sample_advance = 15; //to be checked
- openair0_cfg[0].tx_bw = 80e6;
- openair0_cfg[0].rx_bw = 80e6;
- break;
-
- case 61440000:
- // from usrp_time_offset
- //openair0_cfg[0].samples_per_packet = 2048;
- openair0_cfg[0].tx_sample_advance = 15;
- openair0_cfg[0].tx_bw = 40e6;
- openair0_cfg[0].rx_bw = 40e6;
- break;
-
- case 46080000:
- //openair0_cfg[0].samples_per_packet = 2048;
- openair0_cfg[0].tx_sample_advance = 15;
- openair0_cfg[0].tx_bw = 40e6;
- openair0_cfg[0].rx_bw = 40e6;
- break;
-
- case 30720000:
- // from usrp_time_offset
- //openair0_cfg[0].samples_per_packet = 2048;
- openair0_cfg[0].tx_sample_advance = 15;
- openair0_cfg[0].tx_bw = 20e6;
- openair0_cfg[0].rx_bw = 20e6;
- break;
-
- case 15360000:
- //openair0_cfg[0].samples_per_packet = 2048;
- openair0_cfg[0].tx_sample_advance = 45;
- openair0_cfg[0].tx_bw = 10e6;
- openair0_cfg[0].rx_bw = 10e6;
- break;
-
- case 7680000:
- //openair0_cfg[0].samples_per_packet = 2048;
- openair0_cfg[0].tx_sample_advance = 50;
- openair0_cfg[0].tx_bw = 5e6;
- openair0_cfg[0].rx_bw = 5e6;
- break;
-
- case 1920000:
- //openair0_cfg[0].samples_per_packet = 2048;
- openair0_cfg[0].tx_sample_advance = 50;
- openair0_cfg[0].tx_bw = 1.25e6;
- openair0_cfg[0].rx_bw = 1.25e6;
- break;
-
- default:
- LOG_E(HW,"Error: unknown sampling rate %f\n",openair0_cfg[0].sample_rate);
+ switch ((int)openair0_cfg[0].sample_rate) {
+ case 122880000:
+ // from usrp_time_offset
+ //openair0_cfg[0].samples_per_packet = 2048;
+ openair0_cfg[0].tx_sample_advance = 15; //to be checked
+ openair0_cfg[0].tx_bw = 80e6;
+ openair0_cfg[0].rx_bw = 80e6;
+ break;
+
+ case 92160000:
+ // from usrp_time_offset
+ //openair0_cfg[0].samples_per_packet = 2048;
+ openair0_cfg[0].tx_sample_advance = 15; //to be checked
+ openair0_cfg[0].tx_bw = 80e6;
+ openair0_cfg[0].rx_bw = 80e6;
+ break;
+
+ case 61440000:
+ // from usrp_time_offset
+ //openair0_cfg[0].samples_per_packet = 2048;
+ openair0_cfg[0].tx_sample_advance = 15;
+ openair0_cfg[0].tx_bw = 40e6;
+ openair0_cfg[0].rx_bw = 40e6;
+ break;
+
+ case 46080000:
+ //openair0_cfg[0].samples_per_packet = 2048;
+ openair0_cfg[0].tx_sample_advance = 15;
+ openair0_cfg[0].tx_bw = 40e6;
+ openair0_cfg[0].rx_bw = 40e6;
+ break;
+
+ case 30720000:
+ // from usrp_time_offset
+ //openair0_cfg[0].samples_per_packet = 2048;
+ openair0_cfg[0].tx_sample_advance = 15;
+ openair0_cfg[0].tx_bw = 20e6;
+ openair0_cfg[0].rx_bw = 20e6;
+ break;
+
+ case 15360000:
+ //openair0_cfg[0].samples_per_packet = 2048;
+ openair0_cfg[0].tx_sample_advance = 45;
+ openair0_cfg[0].tx_bw = 10e6;
+ openair0_cfg[0].rx_bw = 10e6;
+ break;
+
+ case 7680000:
+ //openair0_cfg[0].samples_per_packet = 2048;
+ openair0_cfg[0].tx_sample_advance = 50;
+ openair0_cfg[0].tx_bw = 5e6;
+ openair0_cfg[0].rx_bw = 5e6;
+ break;
+
+ case 1920000:
+ //openair0_cfg[0].samples_per_packet = 2048;
+ openair0_cfg[0].tx_sample_advance = 50;
+ openair0_cfg[0].tx_bw = 1.25e6;
+ openair0_cfg[0].rx_bw = 1.25e6;
+ break;
+
+ default:
+ LOG_E(HW,"Error: unknown sampling rate %f\n",openair0_cfg[0].sample_rate);
+ exit(-1);
+ break;
+ }
+ }
+
+ if (device->type == USRP_B200_DEV) {
+ if ((vers == 3) && (subvers == 9) && (subsubvers>=2)) {
+ openair0_cfg[0].rx_gain_calib_table = calib_table_b210;
+ bw_gain_adjust=0;
+ std::cerr << "-- Using calibration table: calib_table_b210" << std::endl; // Bell Labs info
+ } else {
+ openair0_cfg[0].rx_gain_calib_table = calib_table_b210_38;
+ bw_gain_adjust=1;
+ std::cerr << "-- Using calibration table: calib_table_b210_38" << std::endl; // Bell Labs info
+ }
+
+ switch ((int)openair0_cfg[0].sample_rate) {
+ case 46080000:
+ s->usrp->set_master_clock_rate(46.08e6);
+ //openair0_cfg[0].samples_per_packet = 1024;
+ openair0_cfg[0].tx_sample_advance = 115;
+ openair0_cfg[0].tx_bw = 40e6;
+ openair0_cfg[0].rx_bw = 40e6;
+ break;
+
+ case 30720000:
+ s->usrp->set_master_clock_rate(30.72e6);
+ //openair0_cfg[0].samples_per_packet = 1024;
+ openair0_cfg[0].tx_sample_advance = 115;
+ openair0_cfg[0].tx_bw = 20e6;
+ openair0_cfg[0].rx_bw = 20e6;
+ break;
+
+ case 23040000:
+ s->usrp->set_master_clock_rate(23.04e6); //to be checked
+ //openair0_cfg[0].samples_per_packet = 1024;
+ openair0_cfg[0].tx_sample_advance = 113;
+ openair0_cfg[0].tx_bw = 20e6;
+ openair0_cfg[0].rx_bw = 20e6;
+ break;
+
+ case 15360000:
+ s->usrp->set_master_clock_rate(30.72e06);
+ //openair0_cfg[0].samples_per_packet = 1024;
+ openair0_cfg[0].tx_sample_advance = 103;
+ openair0_cfg[0].tx_bw = 20e6;
+ openair0_cfg[0].rx_bw = 20e6;
+ break;
+
+ case 7680000:
+ s->usrp->set_master_clock_rate(30.72e6);
+ //openair0_cfg[0].samples_per_packet = 1024;
+ openair0_cfg[0].tx_sample_advance = 80;
+ openair0_cfg[0].tx_bw = 20e6;
+ openair0_cfg[0].rx_bw = 20e6;
+ break;
+
+ case 1920000:
+ s->usrp->set_master_clock_rate(30.72e6);
+ //openair0_cfg[0].samples_per_packet = 1024;
+ openair0_cfg[0].tx_sample_advance = 40;
+ openair0_cfg[0].tx_bw = 20e6;
+ openair0_cfg[0].rx_bw = 20e6;
+ break;
+
+ default:
+ LOG_E(HW,"Error: unknown sampling rate %f\n",openair0_cfg[0].sample_rate);
+ exit(-1);
+ break;
+ }
+ }
+
+ /* device specific */
+ //openair0_cfg[0].txlaunch_wait = 1;//manage when TX processing is triggered
+ //openair0_cfg[0].txlaunch_wait_slotcount = 1; //manage when TX processing is triggered
+ openair0_cfg[0].iq_txshift = 4;//shift
+ openair0_cfg[0].iq_rxrescale = 15;//rescale iqs
+
+ for(int i=0; i<((int) s->usrp->get_rx_num_channels()); i++) {
+ if (iusrp->set_rx_rate(openair0_cfg[0].sample_rate,i);
+ s->usrp->set_rx_freq(openair0_cfg[0].rx_freq[i],i);
+ set_rx_gain_offset(&openair0_cfg[0],i,bw_gain_adjust);
+ ::uhd::gain_range_t gain_range = s->usrp->get_rx_gain_range(i);
+ // limit to maximum gain
+ AssertFatal( openair0_cfg[0].rx_gain[i]-openair0_cfg[0].rx_gain_offset[i] <= gain_range.stop(),
+ "RX Gain too high, lower by %f dB\n",
+ openair0_cfg[0].rx_gain[i]-openair0_cfg[0].rx_gain_offset[i] - gain_range.stop());
+ s->usrp->set_rx_gain(openair0_cfg[0].rx_gain[i]-openair0_cfg[0].rx_gain_offset[i],i);
+ LOG_I(HW,"RX Gain %d %f (%f) => %f (max %f)\n",i,
+ openair0_cfg[0].rx_gain[i],openair0_cfg[0].rx_gain_offset[i],
+ openair0_cfg[0].rx_gain[i]-openair0_cfg[0].rx_gain_offset[i],gain_range.stop());
+ }
+ }
+
+ LOG_D(HW, "usrp->get_tx_num_channels() == %zd\n", s->usrp->get_tx_num_channels());
+ LOG_D(HW, "openair0_cfg[0].tx_num_channels == %d\n", openair0_cfg[0].tx_num_channels);
+
+ for(int i=0; i<((int) s->usrp->get_tx_num_channels()); i++) {
+ ::uhd::gain_range_t gain_range_tx = s->usrp->get_tx_gain_range(i);
+
+ if (iusrp->set_tx_rate(openair0_cfg[0].sample_rate,i);
+ s->usrp->set_tx_freq(openair0_cfg[0].tx_freq[i],i);
+ s->usrp->set_tx_gain(gain_range_tx.stop()-openair0_cfg[0].tx_gain[i],i);
+ LOG_I(HW,"USRP TX_GAIN:%3.2lf gain_range:%3.2lf tx_gain:%3.2lf\n", gain_range_tx.stop()-openair0_cfg[0].tx_gain[i], gain_range_tx.stop(), openair0_cfg[0].tx_gain[i]);
+ }
+ }
+
+ //s->usrp->set_clock_source("external");
+ //s->usrp->set_time_source("external");
+ // display USRP settings
+ LOG_I(HW,"Actual master clock: %fMHz...\n",s->usrp->get_master_clock_rate()/1e6);
+ LOG_I(HW,"Actual clock source %s...\n",s->usrp->get_clock_source(0).c_str());
+ LOG_I(HW,"Actual time source %s...\n",s->usrp->get_time_source(0).c_str());
+ sleep(1);
+ // create tx & rx streamer
+ uhd::stream_args_t stream_args_rx("sc16", "sc16");
+ int samples=openair0_cfg[0].sample_rate;
+ int max=s->usrp->get_rx_stream(stream_args_rx)->get_max_num_samps();
+ samples/=10000;
+ LOG_I(HW,"RF board max packet size %u, size for 100µs jitter %d \n", max, samples);
+
+ if ( samples < max ) {
+ stream_args_rx.args["spp"] = str(boost::format("%d") % samples );
+ }
+
+ LOG_I(HW,"rx_max_num_samps %zu\n",
+ s->usrp->get_rx_stream(stream_args_rx)->get_max_num_samps());
+
+ for (int i = 0; irx_stream = s->usrp->get_rx_stream(stream_args_rx);
+ uhd::stream_args_t stream_args_tx("sc16", "sc16");
+
+ for (int i = 0; itx_stream = s->usrp->get_tx_stream(stream_args_tx);
+
+ /* Setting TX/RX BW after streamers are created due to USRP calibration issue */
+ for(int i=0; i<((int) s->usrp->get_tx_num_channels()) && iusrp->set_tx_bandwidth(openair0_cfg[0].tx_bw,i);
+
+ for(int i=0; i<((int) s->usrp->get_rx_num_channels()) && iusrp->set_rx_bandwidth(openair0_cfg[0].rx_bw,i);
+
+ for (int i=0; iusrp->get_rx_rate(i)/1e6);
+ LOG_I(HW," Actual RX frequency: %fGHz...\n", s->usrp->get_rx_freq(i)/1e9);
+ LOG_I(HW," Actual RX gain: %f...\n", s->usrp->get_rx_gain(i));
+ LOG_I(HW," Actual RX bandwidth: %fM...\n", s->usrp->get_rx_bandwidth(i)/1e6);
+ LOG_I(HW," Actual RX antenna: %s...\n", s->usrp->get_rx_antenna(i).c_str());
+ }
+
+ for (int i=0; iusrp->get_tx_rate(i)/1e6);
+ LOG_I(HW," Actual TX frequency: %fGHz...\n", s->usrp->get_tx_freq(i)/1e9);
+ LOG_I(HW," Actual TX gain: %f...\n", s->usrp->get_tx_gain(i));
+ LOG_I(HW," Actual TX bandwidth: %fM...\n", s->usrp->get_tx_bandwidth(i)/1e6);
+ LOG_I(HW," Actual TX antenna: %s...\n", s->usrp->get_tx_antenna(i).c_str());
+ LOG_I(HW," Actual TX packet size: %lu\n",s->tx_stream->get_max_num_samps());
+ }
+
+ LOG_I(HW,"Device timestamp: %f...\n", s->usrp->get_time_now().get_real_secs());
+ device->trx_write_func = trx_usrp_write;
+ device->trx_read_func = trx_usrp_read;
+ s->sample_rate = openair0_cfg[0].sample_rate;
+
+ // TODO:
+ // init tx_forward_nsamps based usrp_time_offset ex
+ if(is_equal(s->sample_rate, (double)30.72e6))
+ s->tx_forward_nsamps = 176;
+
+ if(is_equal(s->sample_rate, (double)15.36e6))
+ s->tx_forward_nsamps = 90;
+
+ if(is_equal(s->sample_rate, (double)7.68e6))
+ s->tx_forward_nsamps = 50;
+
+ recplay_state_t *recPlay=device->recplay_state;
+
+ if (recPlay != NULL) { // record mode
+ recPlay->maxSizeBytes=openair0_cfg[0].recplay_conf->u_sf_max *
+ (sizeof(iqrec_t)+BELL_LABS_IQ_BYTES_PER_SF);
+ recPlay->ms_sample = (iqrec_t *) malloc(recPlay->maxSizeBytes);
+ recPlay->currentPtr= (uint8_t *)recPlay->ms_sample;
+
+ if (recPlay->ms_sample == NULL) {
+ std::cerr<< "Memory allocation failed for subframe record or replay mode." << std::endl;
exit(-1);
- break;
+ }
}
+ return 0;
}
-
- if (device->type == USRP_B200_DEV) {
- if ((vers == 3) && (subvers == 9) && (subsubvers>=2)) {
- openair0_cfg[0].rx_gain_calib_table = calib_table_b210;
- bw_gain_adjust=0;
- std::cerr << "-- Using calibration table: calib_table_b210" << std::endl; // Bell Labs info
- } else {
- openair0_cfg[0].rx_gain_calib_table = calib_table_b210_38;
- bw_gain_adjust=1;
- std::cerr << "-- Using calibration table: calib_table_b210_38" << std::endl; // Bell Labs info
- }
-
- switch ((int)openair0_cfg[0].sample_rate) {
- case 46080000:
- s->usrp->set_master_clock_rate(46.08e6);
- //openair0_cfg[0].samples_per_packet = 1024;
- openair0_cfg[0].tx_sample_advance = 115;
- openair0_cfg[0].tx_bw = 40e6;
- openair0_cfg[0].rx_bw = 40e6;
- break;
-
- case 30720000:
- s->usrp->set_master_clock_rate(30.72e6);
- //openair0_cfg[0].samples_per_packet = 1024;
- openair0_cfg[0].tx_sample_advance = 115;
- openair0_cfg[0].tx_bw = 20e6;
- openair0_cfg[0].rx_bw = 20e6;
- break;
-
- case 23040000:
- s->usrp->set_master_clock_rate(23.04e6); //to be checked
- //openair0_cfg[0].samples_per_packet = 1024;
- openair0_cfg[0].tx_sample_advance = 113;
- openair0_cfg[0].tx_bw = 20e6;
- openair0_cfg[0].rx_bw = 20e6;
- break;
-
- case 15360000:
- s->usrp->set_master_clock_rate(30.72e06);
- //openair0_cfg[0].samples_per_packet = 1024;
- openair0_cfg[0].tx_sample_advance = 103;
- openair0_cfg[0].tx_bw = 20e6;
- openair0_cfg[0].rx_bw = 20e6;
- break;
-
- case 7680000:
- s->usrp->set_master_clock_rate(30.72e6);
- //openair0_cfg[0].samples_per_packet = 1024;
- openair0_cfg[0].tx_sample_advance = 80;
- openair0_cfg[0].tx_bw = 20e6;
- openair0_cfg[0].rx_bw = 20e6;
- break;
-
- case 1920000:
- s->usrp->set_master_clock_rate(30.72e6);
- //openair0_cfg[0].samples_per_packet = 1024;
- openair0_cfg[0].tx_sample_advance = 40;
- openair0_cfg[0].tx_bw = 20e6;
- openair0_cfg[0].rx_bw = 20e6;
- break;
-
- default:
- LOG_E(HW,"Error: unknown sampling rate %f\n",openair0_cfg[0].sample_rate);
- exit(-1);
- break;
- }
- }
-
- /* device specific */
- //openair0_cfg[0].txlaunch_wait = 1;//manage when TX processing is triggered
- //openair0_cfg[0].txlaunch_wait_slotcount = 1; //manage when TX processing is triggered
- openair0_cfg[0].iq_txshift = 4;//shift
- openair0_cfg[0].iq_rxrescale = 15;//rescale iqs
-
- for(int i=0; i<((int) s->usrp->get_rx_num_channels()); i++) {
- if (iusrp->set_rx_rate(openair0_cfg[0].sample_rate,i);
- s->usrp->set_rx_freq(openair0_cfg[0].rx_freq[i],i);
- set_rx_gain_offset(&openair0_cfg[0],i,bw_gain_adjust);
- ::uhd::gain_range_t gain_range = s->usrp->get_rx_gain_range(i);
- // limit to maximum gain
- AssertFatal( openair0_cfg[0].rx_gain[i]-openair0_cfg[0].rx_gain_offset[i] <= gain_range.stop(),
- "RX Gain too high, lower by %f dB\n",
- openair0_cfg[0].rx_gain[i]-openair0_cfg[0].rx_gain_offset[i] - gain_range.stop());
- s->usrp->set_rx_gain(openair0_cfg[0].rx_gain[i]-openair0_cfg[0].rx_gain_offset[i],i);
- LOG_I(HW,"RX Gain %d %f (%f) => %f (max %f)\n",i,
- openair0_cfg[0].rx_gain[i],openair0_cfg[0].rx_gain_offset[i],
- openair0_cfg[0].rx_gain[i]-openair0_cfg[0].rx_gain_offset[i],gain_range.stop());
- }
- }
-
- LOG_D(HW, "usrp->get_tx_num_channels() == %zd\n", s->usrp->get_tx_num_channels());
- LOG_D(HW, "openair0_cfg[0].tx_num_channels == %d\n", openair0_cfg[0].tx_num_channels);
-
- for(int i=0; i<((int) s->usrp->get_tx_num_channels()); i++) {
- ::uhd::gain_range_t gain_range_tx = s->usrp->get_tx_gain_range(i);
-
- if (iusrp->set_tx_rate(openair0_cfg[0].sample_rate,i);
- s->usrp->set_tx_freq(openair0_cfg[0].tx_freq[i],i);
- s->usrp->set_tx_gain(gain_range_tx.stop()-openair0_cfg[0].tx_gain[i],i);
- LOG_I(HW,"USRP TX_GAIN:%3.2lf gain_range:%3.2lf tx_gain:%3.2lf\n", gain_range_tx.stop()-openair0_cfg[0].tx_gain[i], gain_range_tx.stop(), openair0_cfg[0].tx_gain[i]);
- }
- }
-
- //s->usrp->set_clock_source("external");
- //s->usrp->set_time_source("external");
- // display USRP settings
- LOG_I(HW,"Actual master clock: %fMHz...\n",s->usrp->get_master_clock_rate()/1e6);
- LOG_I(HW,"Actual clock source %s...\n",s->usrp->get_clock_source(0).c_str());
- LOG_I(HW,"Actual time source %s...\n",s->usrp->get_time_source(0).c_str());
- sleep(1);
- // create tx & rx streamer
- uhd::stream_args_t stream_args_rx("sc16", "sc16");
- int samples=openair0_cfg[0].sample_rate;
- int max=s->usrp->get_rx_stream(stream_args_rx)->get_max_num_samps();
- samples/=10000;
- LOG_I(HW,"RF board max packet size %u, size for 100µs jitter %d \n", max, samples);
-
- if ( samples < max ) {
- stream_args_rx.args["spp"] = str(boost::format("%d") % samples );
- }
-
- LOG_I(HW,"rx_max_num_samps %zu\n",
- s->usrp->get_rx_stream(stream_args_rx)->get_max_num_samps());
-
- for (int i = 0; irx_stream = s->usrp->get_rx_stream(stream_args_rx);
- uhd::stream_args_t stream_args_tx("sc16", "sc16");
-
- for (int i = 0; itx_stream = s->usrp->get_tx_stream(stream_args_tx);
-
- /* Setting TX/RX BW after streamers are created due to USRP calibration issue */
- for(int i=0; i<((int) s->usrp->get_tx_num_channels()) && iusrp->set_tx_bandwidth(openair0_cfg[0].tx_bw,i);
-
- for(int i=0; i<((int) s->usrp->get_rx_num_channels()) && iusrp->set_rx_bandwidth(openair0_cfg[0].rx_bw,i);
-
- for (int i=0; iusrp->get_rx_rate(i)/1e6);
- LOG_I(HW," Actual RX frequency: %fGHz...\n", s->usrp->get_rx_freq(i)/1e9);
- LOG_I(HW," Actual RX gain: %f...\n", s->usrp->get_rx_gain(i));
- LOG_I(HW," Actual RX bandwidth: %fM...\n", s->usrp->get_rx_bandwidth(i)/1e6);
- LOG_I(HW," Actual RX antenna: %s...\n", s->usrp->get_rx_antenna(i).c_str());
- }
-
- for (int i=0; iusrp->get_tx_rate(i)/1e6);
- LOG_I(HW," Actual TX frequency: %fGHz...\n", s->usrp->get_tx_freq(i)/1e9);
- LOG_I(HW," Actual TX gain: %f...\n", s->usrp->get_tx_gain(i));
- LOG_I(HW," Actual TX bandwidth: %fM...\n", s->usrp->get_tx_bandwidth(i)/1e6);
- LOG_I(HW," Actual TX antenna: %s...\n", s->usrp->get_tx_antenna(i).c_str());
- LOG_I(HW," Actual TX packet size: %lu\n",s->tx_stream->get_max_num_samps());
- }
-
- LOG_I(HW,"Device timestamp: %f...\n", s->usrp->get_time_now().get_real_secs());
- device->trx_write_func = trx_usrp_write;
- device->trx_read_func = trx_usrp_read;
- s->sample_rate = openair0_cfg[0].sample_rate;
-
- // TODO:
- // init tx_forward_nsamps based usrp_time_offset ex
- if(is_equal(s->sample_rate, (double)30.72e6))
- s->tx_forward_nsamps = 176;
-
- if(is_equal(s->sample_rate, (double)15.36e6))
- s->tx_forward_nsamps = 90;
-
- if(is_equal(s->sample_rate, (double)7.68e6))
- s->tx_forward_nsamps = 50;
-
-
- if (device->recplay_state != NULL) { // record mode
- device->recplay_state->ms_sample = (iqrec_t *) malloc(openair0_cfg[0].recplay_conf->u_sf_max * sizeof(iqrec_t));
-
- if (device->recplay_state->ms_sample == NULL) {
- std::cerr<< "Memory allocation failed for subframe record or replay mode." << std::endl;
- exit(-1);
- }
-
- memset(device->recplay_state->ms_sample, 0, openair0_cfg[0].recplay_conf->u_sf_max * BELL_LABS_IQ_BYTES_PER_SF);
- }
- return 0;
-}
-/*@}*/
+ /*@}*/
}/* extern c */
diff --git a/targets/ARCH/iqplayer/iqplayer_lib.c b/targets/ARCH/iqplayer/iqplayer_lib.c
index c4133d1b11..f634a4dbc5 100644
--- a/targets/ARCH/iqplayer/iqplayer_lib.c
+++ b/targets/ARCH/iqplayer/iqplayer_lib.c
@@ -40,18 +40,15 @@
#include "assertions.h"
#include "common/utils/LOG/log.h"
-
-
-
-
-
static void parse_iqfile_header(openair0_device *device, iqfile_header_t *iq_fh) {
- AssertFatal((memcmp(iq_fh->oaiid,OAIIQFILE_ID,sizeof(OAIIQFILE_ID)) == 0),
- "iqfile doesn't seem to be compatible with oai (invalid id %.4s in header)\n",
- iq_fh->oaiid);
+ char tmp[4]=OAIIQFILE_ID;
+ AssertFatal((memcmp(iq_fh->oaiid,tmp,sizeof(iq_fh->oaiid)) == 0),
+ "iqfile doesn't seem to be compatible with oai (invalid id %.4s in header)\n",
+ iq_fh->oaiid);
device->type = iq_fh->devtype;
device->openair0_cfg[0].tx_sample_advance=iq_fh->tx_sample_advance;
device->openair0_cfg[0].tx_bw = device->openair0_cfg[0].rx_bw = iq_fh->bw;
+ device->recplay_state->nbSamplesBlocks=iq_fh->nbSamplesBlocks;
LOG_UI(HW,"Replay iqs from %s device, bandwidth %e\n",get_devname(iq_fh->devtype),iq_fh->bw);
}
@@ -63,89 +60,73 @@ static int iqplayer_loadfile(openair0_device *device, openair0_config_t *openair
recplay_state_t *s = device->recplay_state;
recplay_conf_t *c = openair0_cfg->recplay_conf;
+ struct stat sb;
+ s->fd = open(c->u_sf_filename, O_RDONLY );
+ if (s->fd >= 0 ) {
+ fstat(s->fd, &sb);
+ } else {
+ LOG_E( HW,"Cannot open %s exiting.\n", c->u_sf_filename );
+ exit(-1);
+ }
+
if (s->use_mmap) {
// use mmap
- s->mmapfd = open(c->u_sf_filename, O_RDONLY );
-
- if (s->mmapfd != 0) {
- struct stat sb;
- fstat(s->mmapfd, &sb);
s->mapsize=sb.st_size;
LOG_I(HW,"Loading subframes using mmap() from %s size=%lu bytes ...\n",c->u_sf_filename, (uint64_t)sb.st_size );
- void *mptr = mmap(NULL, sb.st_size, PROT_WRITE, MAP_PRIVATE, s->mmapfd, 0) ;
- s->ms_sample = (iqrec_t *) ( mmap(NULL, sb.st_size, PROT_WRITE, MAP_PRIVATE, s->mmapfd, 0) + sizeof(iqfile_header_t));
+ void *mptr = mmap(NULL, sb.st_size, PROT_WRITE, MAP_PRIVATE, s->fd, 0) ;
+ s->ms_sample = (iqrec_t *) ( mmap(NULL, sb.st_size, PROT_WRITE, MAP_PRIVATE, s->fd, 0) + sizeof(iqfile_header_t));
if (mptr != MAP_FAILED) {
parse_iqfile_header(device, (iqfile_header_t *)mptr);
s->ms_sample = (iqrec_t *)((char *)mptr + sizeof(iqfile_header_t));
- s->nb_samples = ((sb.st_size-sizeof(iqfile_header_t)) / sizeof(iqrec_t));
- int aligned = (((unsigned long)s->ms_sample & 31) == 0)? 1:0;
- LOG_I(HW,"Loaded %u subframes.\n",s->nb_samples );
-
- if (aligned == 0) {
- LOG_E(HW, "mmap address is not 32 bytes aligned, exiting.\n" );
- close(s->mmapfd);
- exit(-1);
- }
+ LOG_I(HW,"Loaded %u subframes.\n",s->nbSamplesBlocks );
} else {
LOG_E(HW,"Cannot mmap file, exiting.\n");
- close(s->mmapfd);
+ close(s->fd);
exit(-1);
}
- } else {
- LOG_E( HW,"Cannot open %s exiting.\n", c->u_sf_filename );
- exit(-1);
- }
} else {
- s->iqfd = open(c->u_sf_filename, O_RDONLY);
+ iqfile_header_t fh;
+ size_t hs = read(s->fd,&fh,sizeof(fh));
- if (s->iqfd != 0) {
- struct stat sb;
- iqfile_header_t fh;
- size_t hs = read(s->iqfd,&fh,sizeof(fh));
-
- if (hs == sizeof(fh)) {
- parse_iqfile_header(device, &fh);
- fstat(s->iqfd, &sb);
+ if (hs == sizeof(fh)) {
+ parse_iqfile_header(device, &fh);
+ fstat(s->fd, &sb);
s->mapsize=sb.st_size;
- s->nb_samples = ((sb.st_size-sizeof(iqfile_header_t))/ sizeof(iqrec_t));
- LOG_I(HW, "Loading %u subframes from %s,size=%lu bytes ...\n",s->nb_samples, c->u_sf_filename,(uint64_t)sb.st_size);
+ LOG_I(HW, "Loading %u subframes from %s,size=%lu bytes ...\n",s->nbSamplesBlocks, c->u_sf_filename,(uint64_t)sb.st_size);
// allocate buffer for 1 sample at a time
- s->ms_sample = (iqrec_t *) malloc(sizeof(iqrec_t));
+ s->ms_sample = (iqrec_t *) malloc(sizeof(iqrec_t)+MAX_BELL_LABS_IQ_BYTES_PER_SF*4);
if (s->ms_sample == NULL) {
LOG_E(HW,"Memory allocation failed for individual subframe replay mode.\n" );
- close(s->iqfd);
+ close(s->fd);
exit(-1);
}
memset(s->ms_sample, 0, sizeof(iqrec_t));
// point at beginning of iqs in file
- if (lseek(s->iqfd,sizeof(iqfile_header_t), SEEK_SET) == 0) {
+ if (lseek(s->fd,sizeof(iqfile_header_t), SEEK_SET) == 0) {
LOG_I(HW,"Initial seek at beginning of the file\n" );
} else {
LOG_I(HW,"Problem initial seek at beginning of the file\n");
}
} else {
LOG_E(HW,"Cannot read header in %s exiting.\n",c->u_sf_filename );
- close(s->iqfd);
+ close(s->fd);
exit(-1);
}
- } else {
- LOG_E(HW,"Cannot open %s exiting.\n",c->u_sf_filename );
- exit(-1);
- }
}
+ s->currentPtr=(uint8_t *)s->ms_sample;
return 0;
}
/*! \brief start the oai iq player
* \param device, the hardware used
*/
-static int trx_iqplayer_start(openair0_device *device){
- return 0;
+static int trx_iqplayer_start(openair0_device *device) {
+ return 0;
}
/*! \brief Terminate operation of the oai iq player
@@ -157,28 +138,22 @@ static void trx_iqplayer_end(openair0_device *device) {
if (device->recplay_state == NULL)
return;
-
+
if (device->recplay_state->use_mmap) {
if (device->recplay_state->ms_sample != MAP_FAILED) {
munmap(device->recplay_state->ms_sample, device->recplay_state->mapsize);
- device->recplay_state->ms_sample = NULL;
- }
-
- if (device->recplay_state->mmapfd != 0) {
- close(device->recplay_state->mmapfd);
- device->recplay_state->mmapfd = 0;
- }
+ }
} else {
if (device->recplay_state->ms_sample != NULL) {
free(device->recplay_state->ms_sample);
- device->recplay_state->ms_sample = NULL;
- }
-
- if (device->recplay_state->iqfd != 0) {
- close(device->recplay_state->iqfd);
- device->recplay_state->iqfd = 0;
- }
+ }
}
+ device->recplay_state->ms_sample = NULL;
+ if (device->recplay_state->fd >= 0) {
+ close(device->recplay_state->fd);
+ device->recplay_state->fd = -1;
+ }
+
}
/*! \brief Write iqs function when in replay mode, just introduce a delay, as configured at init time,
@param device pointer to the device structure specific to the RF hardware target
@@ -208,93 +183,68 @@ static int trx_iqplayer_write(openair0_device *device, openair0_timestamp timest
* \returns the number of sample read
*/
static int trx_iqplayer_read(openair0_device *device, openair0_timestamp *ptimestamp, void **buff, int nsamps, int cc) {
- int samples_received=0;
- static unsigned int cur_samples;
- static int64_t wrap_count;
- static int64_t wrap_ts;
recplay_state_t *s = device->recplay_state;
- if (cur_samples == s->nb_samples) {
- cur_samples = 0;
- wrap_count++;
+ if (s->curSamplesBlock==0 && s->wrap_count==0 )
+ s->currentTs=s->ms_sample->ts;
+
+ if (s->curSamplesBlock == s->nbSamplesBlocks) {
+ LOG_I(HW, "wrapping on iq file (%ld)\n", s->wrap_count);
+ s->curSamplesBlock = 0;
+ s->wrap_count++;
- if (wrap_count == device->openair0_cfg->recplay_conf->u_sf_loops) {
- LOG_W(HW, "iqplayer device terminating subframes replay after %u iteration\n",device->openair0_cfg->recplay_conf->u_sf_loops);
+ if (s->wrap_count == device->openair0_cfg->recplay_conf->u_sf_loops) {
+ LOG_W(HW, "iqplayer device terminating subframes replay after %u iteration\n",
+ device->openair0_cfg->recplay_conf->u_sf_loops);
exit_function(__FILE__, __FUNCTION__, __LINE__,"replay ended, triggering process termination\n");
}
- wrap_ts = wrap_count * (s->nb_samples * (((int)(device->openair0_cfg[0].sample_rate)) / 1000));
+ LOG_I(HW,"go back at the beginning of IQ file");
+ device->recplay_state->currentPtr=(uint8_t *)device->recplay_state->ms_sample;
- if (!device->recplay_state->use_mmap) {
- if (lseek(device->recplay_state->iqfd, 0, SEEK_SET) == 0) {
- LOG_I(HW,"Seeking at the beginning of IQ file");
- } else {
- LOG_I(HW, "Problem seeking at the beginning of IQ file");
+ if (!s->use_mmap) {
+ if (lseek(device->recplay_state->fd, 0, SEEK_SET) != 0) {
+ LOG_E(HW, "Problem seeking at the beginning of IQ file");
}
}
}
- if (s->use_mmap) {
- if (cur_samples < s->nb_samples) {
- *ptimestamp = (s->ms_sample[0].ts + (cur_samples * (((int)(device->openair0_cfg[0].sample_rate)) / 1000))) + wrap_ts;
-
- if (cur_samples == 0) {
- LOG_I(HW,"starting subframes file with wrap_count=%lu wrap_ts=%lu ts=%lu\n", wrap_count,wrap_ts,*ptimestamp);
- }
-
- memcpy(buff[0], &s->ms_sample[cur_samples].samples[0], nsamps*4);
- cur_samples++;
- }
- } else {
+ if (!s->use_mmap) {
// read sample from file
- if (read(s->iqfd, s->ms_sample, sizeof(iqrec_t)) != sizeof(iqrec_t)) {
- LOG_E(HW,"pb reading iqfile at index %lu\n",sizeof(iqrec_t)*cur_samples );
- close(s->iqfd);
- free(s->ms_sample);
- s->ms_sample = NULL;
- s->iqfd = 0;
+ if (read(s->fd, s->ms_sample, sizeof(iqrec_t)) != sizeof(iqrec_t)) {
+ LOG_E(HW,"pb reading iqfile at index %lu\n",sizeof(iqrec_t)*s->curSamplesBlock );
exit(-1);
- }
-
- if (cur_samples < s->nb_samples) {
- static int64_t ts0 = 0;
-
- if ((cur_samples == 0) && (wrap_count == 0)) {
- ts0 = s->ms_sample->ts;
- }
-
- *ptimestamp = ts0 + (cur_samples * (((int)(device->openair0_cfg[0].sample_rate)) / 1000)) + wrap_ts;
-
- if (cur_samples == 0) {
- LOG_I(HW, "starting subframes file with wrap_count=%lu wrap_ts=%lu ts=%lu ",wrap_count,wrap_ts, *ptimestamp);
- }
-
- memcpy(buff[0], &s->ms_sample->samples[0], nsamps*4);
- cur_samples++;
- // Prepare for next read
- off_t where = lseek(s->iqfd, cur_samples * sizeof(iqrec_t), SEEK_SET);
-
- if (where < 0) {
- LOG_E(HW,"Cannot lseek in iqfile: %s\n",strerror(errno));
+ } else {
+ if (read(s->fd, s->ms_sample+1, s->ms_sample->nbBytes) != s->ms_sample->nbBytes) {
+ LOG_E(HW,"pb reading iqfile at index %lu\n",sizeof(iqrec_t)*s->curSamplesBlock );
exit(-1);
}
}
}
+ iqrec_t *curHeader=(iqrec_t *)s->currentPtr;
+ AssertFatal(curHeader->header==BELL_LABS_IQ_HEADER,"" );
+ // the current timestamp is the stored timestamp until we wrap on input
+ // USRP shifts 1 sample time to time
+ AssertFatal(s->wrap_count !=0 || abs(curHeader->ts-s->currentTs) < 5 ,"");
+ AssertFatal(nsamps*4==curHeader->nbBytes,"");
+ *ptimestamp = s->currentTs;
+ memcpy(buff[0], curHeader+1, nsamps*4);
+ s->curSamplesBlock++;
+ // Prepare for next read
+ s->currentTs+=nsamps;
+
+ if (s->use_mmap)
+ s->currentPtr+=sizeof(iqrec_t)+s->ms_sample->nbBytes;
+
struct timespec req;
-
req.tv_sec = 0;
-
req.tv_nsec = (device->openair0_cfg[0].recplay_conf->u_sf_read_delay) * 1000;
-
nanosleep(&req, NULL);
-
+ LOG_D(HW, "returning %d samples at ts %lu\n", nsamps, *ptimestamp);
return nsamps;
-
- return samples_received;
}
-
int device_init(openair0_device *device, openair0_config_t *openair0_cfg) {
device->openair0_cfg = openair0_cfg;
device->trx_start_func = trx_iqplayer_start;
@@ -313,5 +263,4 @@ int device_init(openair0_device *device, openair0_config_t *openair0_cfg) {
LOG_UI(HW,"iqplayer device initialized, replay %s for %i iterations",openair0_cfg->recplay_conf->u_sf_filename,openair0_cfg->recplay_conf->u_sf_loops);
return 0;
}
-
/*@}*/
diff --git a/targets/ARCH/rfsimulator/stored_node.c b/targets/ARCH/rfsimulator/stored_node.c
index daf0133af2..8b0b397995 100644
--- a/targets/ARCH/rfsimulator/stored_node.c
+++ b/targets/ARCH/rfsimulator/stored_node.c
@@ -186,21 +186,24 @@ int main(int argc, char *argv[]) {
serviceSock=client_start(argv[2],atoi(argv[3]));
}
- uint64_t typeStamp=ENB_MAGICDL_FDD;
+ uint64_t typeStamp=ENB_MAGICDL;
boolean_t raw=false;
if ( argc == 5 ) {
raw=true;
if (strcmp(argv[4],"UL") == 0 )
- typeStamp=UE_MAGICDL_FDD;
+ typeStamp=UE_MAGICDL;
}
samplesBlockHeader_t header;
int bufSize=100000;
void *buff=malloc(bufSize);
uint64_t timestamp=0;
- const int blockSize=1000;
+ const int blockSize=1920;
+
+ // If fileSize is not multiple of blockSize*4 then discard remaining samples
+ fileSize = (fileSize/(blockSize<<2))*(blockSize<<2);
while (1) {
//Rewind the file to loop on the samples
diff --git a/targets/PROJECTS/GENERIC-NR-5GC/CONF/gnb.sa.band41.fr1.106PRB.usrpb210.conf b/targets/PROJECTS/GENERIC-NR-5GC/CONF/gnb.sa.band41.fr1.106PRB.usrpb210.conf
index 108cf06033..cbdd205d30 100644
--- a/targets/PROJECTS/GENERIC-NR-5GC/CONF/gnb.sa.band41.fr1.106PRB.usrpb210.conf
+++ b/targets/PROJECTS/GENERIC-NR-5GC/CONF/gnb.sa.band41.fr1.106PRB.usrpb210.conf
@@ -13,7 +13,7 @@ gNBs =
// Tracking area code, 0x0000 and 0xfffe are reserved values
tracking_area_code = 1;
- plmn_list = ({mcc = 222; mnc = 93; mnc_length = 2;});
+ plmn_list = ({mcc = 208; mnc = 92; mnc_length = 2;});
tr_s_preference = "local_mac"
@@ -51,7 +51,7 @@ gNBs =
#initialDownlinkBWP
#genericParameters
# this is RBstart=41,L=24 (275*(L-1))+RBstart
- initialDLBWPlocationAndBandwidth = 6366; # 6366 12925 12956 28875
+ initialDLBWPlocationAndBandwidth = 12952; # 6366 12925 12956 28875
# subcarrierSpacing
# 0=kHz15, 1=kHz30, 2=kHz60, 3=kHz120
initialDLBWPsubcarrierSpacing = 1;
@@ -75,17 +75,12 @@ gNBs =
initialDLBWPk0_2 = 0;
initialDLBWPmappingType_2 = 0;
#this is SS=1,L=12
- initialDLBWPstartSymbolAndLength_2 = 95;
+ initialDLBWPstartSymbolAndLength_2 = 54;
initialDLBWPk0_3 = 0;
initialDLBWPmappingType_3 = 0;
- #this is SS=2,L=7
- initialDLBWPstartSymbolAndLength_3 = 86;
-
- initialDLBWPk0_4 = 0;
- initialDLBWPmappingType_4 = 0;
- #this is SS=2,L=5
- initialDLBWPstartSymbolAndLength_4 = 58;
+ #this is SS=1,L=5
+ initialDLBWPstartSymbolAndLength_3 = 57;
#uplinkConfigCommon
#frequencyInfoUL
@@ -99,7 +94,7 @@ gNBs =
pMax = 20;
#initialUplinkBWP
#genericParameters
- initialULBWPlocationAndBandwidth = 6366;
+ initialULBWPlocationAndBandwidth = 12952;
# subcarrierSpacing
# 0=kHz15, 1=kHz30, 2=kHz60, 3=kHz120
initialULBWPsubcarrierSpacing = 1;
@@ -111,7 +106,7 @@ gNBs =
prach_msg1_FDM = 0;
prach_msg1_FrequencyStart = 0;
zeroCorrelationZoneConfig = 13;
- preambleReceivedTargetPower = -100;
+ preambleReceivedTargetPower = -96;
#preamblTransMax (0...10) = (3,4,5,6,7,8,10,20,50,100,200)
preambleTransMax = 6;
#powerRampingStep
diff --git a/targets/PROJECTS/GENERIC-NR-5GC/CONF/gnb.sa.band78.fr1.106PRB.usrpb210.conf b/targets/PROJECTS/GENERIC-NR-5GC/CONF/gnb.sa.band78.fr1.106PRB.usrpb210.conf
index 4373f38e7b..35eb694c2b 100644
--- a/targets/PROJECTS/GENERIC-NR-5GC/CONF/gnb.sa.band78.fr1.106PRB.usrpb210.conf
+++ b/targets/PROJECTS/GENERIC-NR-5GC/CONF/gnb.sa.band78.fr1.106PRB.usrpb210.conf
@@ -13,7 +13,7 @@ gNBs =
// Tracking area code, 0x0000 and 0xfffe are reserved values
tracking_area_code = 1;
- plmn_list = ({mcc = 222; mnc = 93; mnc_length = 2;});
+ plmn_list = ({mcc = 208; mnc = 92; mnc_length = 2;});
tr_s_preference = "local_mac"
@@ -50,8 +50,8 @@ gNBs =
dl_carrierBandwidth = 106;
#initialDownlinkBWP
#genericParameters
- # this is RBstart=41,L=24 (275*(L-1))+RBstart
- initialDLBWPlocationAndBandwidth = 6366; # 6366 12925 12956 28875
+ # this is RBstart=27,L=48 (275*(L-1))+RBstart
+ initialDLBWPlocationAndBandwidth = 12952; # 6366 12925 12956 28875 12952
# subcarrierSpacing
# 0=kHz15, 1=kHz30, 2=kHz60, 3=kHz120
initialDLBWPsubcarrierSpacing = 1;
@@ -75,17 +75,12 @@ gNBs =
initialDLBWPk0_2 = 0;
initialDLBWPmappingType_2 = 0;
#this is SS=1,L=12
- initialDLBWPstartSymbolAndLength_2 = 95;
+ initialDLBWPstartSymbolAndLength_2 = 54;
initialDLBWPk0_3 = 0;
initialDLBWPmappingType_3 = 0;
- #this is SS=2,L=7
- initialDLBWPstartSymbolAndLength_3 = 86;
-
- initialDLBWPk0_4 = 0;
- initialDLBWPmappingType_4 = 0;
- #this is SS=2,L=5
- initialDLBWPstartSymbolAndLength_4 = 58;
+ #this is SS=1,L=5
+ initialDLBWPstartSymbolAndLength_3 = 57;
#uplinkConfigCommon
#frequencyInfoUL
@@ -99,7 +94,7 @@ gNBs =
pMax = 20;
#initialUplinkBWP
#genericParameters
- initialULBWPlocationAndBandwidth = 6366;
+ initialULBWPlocationAndBandwidth = 12952;
# subcarrierSpacing
# 0=kHz15, 1=kHz30, 2=kHz60, 3=kHz120
initialULBWPsubcarrierSpacing = 1;
@@ -111,7 +106,7 @@ gNBs =
prach_msg1_FDM = 0;
prach_msg1_FrequencyStart = 0;
zeroCorrelationZoneConfig = 13;
- preambleReceivedTargetPower = -100;
+ preambleReceivedTargetPower = -96;
#preamblTransMax (0...10) = (3,4,5,6,7,8,10,20,50,100,200)
preambleTransMax = 6;
#powerRampingStep
diff --git a/targets/RT/USER/lte-softmodem.c b/targets/RT/USER/lte-softmodem.c
index 841bab67dc..675d1df42e 100644
--- a/targets/RT/USER/lte-softmodem.c
+++ b/targets/RT/USER/lte-softmodem.c
@@ -728,7 +728,7 @@ int main ( int argc, char **argv )
fflush(stderr);
// end of CI modifications
//getchar();
- if(IS_SOFTMODEM_DOFORMS)
+ if(IS_SOFTMODEM_DOSCOPE)
load_softscope("enb",NULL);
itti_wait_tasks_end();
oai_exit=1;
@@ -736,7 +736,7 @@ int main ( int argc, char **argv )
// stop threads
if (RC.nb_inst == 0 || !NODE_IS_CU(node_type)) {
- if(IS_SOFTMODEM_DOFORMS)
+ if(IS_SOFTMODEM_DOSCOPE)
end_forms();
LOG_I(ENB_APP,"stopping MODEM threads\n");
diff --git a/targets/RT/USER/lte-uesoftmodem.c b/targets/RT/USER/lte-uesoftmodem.c
index 9bf179efb9..15b97df3ed 100644
--- a/targets/RT/USER/lte-uesoftmodem.c
+++ b/targets/RT/USER/lte-uesoftmodem.c
@@ -758,7 +758,7 @@ int main( int argc, char **argv ) {
PHY_vars_UE_g[0][0]->no_timing_correction = 1;
}
- if(IS_SOFTMODEM_DOFORMS)
+ if(IS_SOFTMODEM_DOSCOPE)
load_softscope("ue",NULL);
config_check_unknown_cmdlineopt(CONFIG_CHECKALLSECTIONS);
@@ -783,7 +783,7 @@ int main( int argc, char **argv ) {
printf("oai_exit=%d\n",oai_exit);
// stop threads
- if(IS_SOFTMODEM_DOFORMS)
+ if(IS_SOFTMODEM_DOSCOPE)
end_forms();
printf("stopping MODEM threads\n");