diff --git a/.gitignore b/.gitignore index 06a51f1b64..73e0407c4b 100644 --- a/.gitignore +++ b/.gitignore @@ -4,6 +4,7 @@ # log and exec file cmake_targets/log/ cmake_targets/*/build/ +cmake_targets/ran_build/ log/ lte_build_oai/ -targets/bin/ \ No newline at end of file +targets/bin/ diff --git a/ci-scripts/Jenkinsfile-gitlab b/ci-scripts/Jenkinsfile-gitlab index 2f736c5dbd..86e9cdf74b 100644 --- a/ci-scripts/Jenkinsfile-gitlab +++ b/ci-scripts/Jenkinsfile-gitlab @@ -57,6 +57,9 @@ pipeline { echo '\u2705 \u001B[32mVerify Parameters\u001B[0m' def allParametersPresent = true + if (env.TESTPLATFORM_OWNER) { + echo "Platform is ${env.TESTPLATFORM_OWNER}" + } if (params.RedHatRemoteServer == null) { allParametersPresent = false @@ -362,7 +365,7 @@ pipeline { stage ("Test physical simulators") { steps { script { - timeout (time: 45, unit: 'MINUTES') { + timeout (time: 90, unit: 'MINUTES') { try { gitlabCommitStatus(name: "Test phy-sim") { sh "./ci-scripts/oai-ci-vm-tool test --workspace $WORKSPACE --variant phy-sim --job-name ${JOB_NAME} --build-id ${BUILD_ID}" diff --git a/ci-scripts/buildOnVM.sh b/ci-scripts/buildOnVM.sh index ae6b48cd51..076e90fc2d 100755 --- a/ci-scripts/buildOnVM.sh +++ b/ci-scripts/buildOnVM.sh @@ -44,7 +44,7 @@ function build_on_vm { STATUS=1 return fi - if [ ! -f /etc/apt/apt.conf.d/01proxy ] + if [[ ! -f /etc/apt/apt.conf.d/01proxy ]] && [[ "$OPTIONAL_APTCACHER" != "true" ]] then echo "Missing /etc/apt/apt.conf.d/01proxy file!" echo "Is apt-cacher installed and configured?" @@ -96,12 +96,12 @@ function build_on_vm { else scp -o StrictHostKeyChecking=no $JENKINS_WKSP/localZip.zip ubuntu@$VM_IP_ADDR:/home/ubuntu fi - scp -o StrictHostKeyChecking=no /etc/apt/apt.conf.d/01proxy ubuntu@$VM_IP_ADDR:/home/ubuntu + [ -f /etc/apt/apt.conf.d/01proxy ] && scp -o StrictHostKeyChecking=no /etc/apt/apt.conf.d/01proxy ubuntu@$VM_IP_ADDR:/home/ubuntu echo "############################################################" echo "Running install and build script on VM ($VM_NAME)" echo "############################################################" - echo "sudo cp 01proxy /etc/apt/apt.conf.d/" > $VM_CMDS + echo "[ -f 01proxy ] && sudo cp 01proxy /etc/apt/apt.conf.d/" > $VM_CMDS echo "touch /home/ubuntu/.hushlogin" >> $VM_CMDS echo "git config --global https.postBuffer 123289600" >> $VM_CMDS if [[ "$VM_NAME" == *"-cppcheck"* ]] diff --git a/ci-scripts/conf_files/enb.band13.tm1.50PRB.emtc.conf b/ci-scripts/conf_files/enb.band13.tm1.50PRB.emtc.conf index eff8b68857..ab89d13193 100644 --- a/ci-scripts/conf_files/enb.band13.tm1.50PRB.emtc.conf +++ b/ci-scripts/conf_files/enb.band13.tm1.50PRB.emtc.conf @@ -233,6 +233,7 @@ eNBs = #pdsch_maxNumRepetitionCEmodeB_r13 = "r384"; # NULL - 2 pusch_maxNumRepetitionCEmodeA_r13 = "r8"; #0 + pusch_repetitionLevelCEmodeA_r13 = "l1"; #pusch_maxNumRepetitionCEmodeB_r13 = "r768"; #4 #NULL #pusch_HoppingOffset_v1310 = 5; #NULL diff --git a/ci-scripts/main.py b/ci-scripts/main.py index 5a86702cc2..fc7d2090db 100644 --- a/ci-scripts/main.py +++ b/ci-scripts/main.py @@ -542,8 +542,37 @@ class SSHConnection(): self.command('git config user.email "jenkins@openairinterface.org"', '\$', 5) self.command('git config user.name "OAI Jenkins"', '\$', 5) if self.clean_repository: - pass + self.command('ls *.txt', '\$', 5) + result = re.search('LAST_BUILD_INFO', str(self.ssh.before)) + if result is not None: + mismatch = False + self.command('grep SRC_COMMIT LAST_BUILD_INFO.txt', '\$', 2) + result = re.search(self.ranCommitID, str(self.ssh.before)) + if result is None: + mismatch = True + self.command('grep MERGED_W_TGT_BRANCH LAST_BUILD_INFO.txt', '\$', 2) + if (self.ranAllowMerge): + result = re.search('YES', str(self.ssh.before)) + if result is None: + mismatch = True + self.command('grep TGT_BRANCH LAST_BUILD_INFO.txt', '\$', 2) + if self.ranTargetBranch == '': + result = re.search('develop', str(self.ssh.before)) + else: + result = re.search(self.ranTargetBranch, str(self.ssh.before)) + if result is None: + mismatch = True + else: + result = re.search('NO', str(self.ssh.before)) + if result is None: + mismatch = True + if not mismatch: + self.close() + self.CreateHtmlTestRow(self.Build_eNB_args, 'OK', ALL_PROCESSES_OK) + return + self.command('echo ' + self.UEPassword + ' | sudo -S git clean -x -d -ff', '\$', 30) + # if the commit ID is provided use it to point to it if self.ranCommitID != '': self.command('git checkout -f ' + self.ranCommitID, '\$', 5) @@ -571,12 +600,23 @@ class SSHConnection(): self.command('mkdir -p build_log_' + self.testCase_id, '\$', 5) self.command('mv log/* ' + 'build_log_' + self.testCase_id, '\$', 5) self.command('mv compile_oai_ue.log ' + 'build_log_' + self.testCase_id, '\$', 5) - self.close() if buildStatus: - logging.info('\u001B[1m Building OAI ' + ue_prefix + 'UE Pass\u001B[0m') + # Generating a BUILD INFO file + self.command('echo "SRC_BRANCH: ' + self.ranBranch + '" > ../LAST_BUILD_INFO.txt', '\$', 2) + self.command('echo "SRC_COMMIT: ' + self.ranCommitID + '" >> ../LAST_BUILD_INFO.txt', '\$', 2) + if (self.ranAllowMerge): + self.command('echo "MERGED_W_TGT_BRANCH: YES" >> ../LAST_BUILD_INFO.txt', '\$', 2) + if self.ranTargetBranch == '': + self.command('echo "TGT_BRANCH: develop" >> ../LAST_BUILD_INFO.txt', '\$', 2) + else: + self.command('echo "TGT_BRANCH: ' + self.ranTargetBranch + '" >> ../LAST_BUILD_INFO.txt', '\$', 2) + else: + self.command('echo "MERGED_W_TGT_BRANCH: NO" >> ../LAST_BUILD_INFO.txt', '\$', 2) + self.close() self.CreateHtmlTestRow(self.Build_OAI_UE_args, 'OK', ALL_PROCESSES_OK, 'OAI UE') else: - logging.error('\u001B[1m Building OAI ' + ue_prefix + 'UE Failed\u001B[0m') + self.close() + logging.error('\u001B[1m Building OAI UE Failed\u001B[0m') self.CreateHtmlTestRow(self.Build_OAI_UE_args, 'KO', ALL_PROCESSES_OK, 'OAI UE') self.CreateHtmlTabFooter(False) sys.exit(1) @@ -738,13 +778,13 @@ class SSHConnection(): # do not reset board twice in IF4.5 case result = re.search('^rru|^enb|^du.band', str(config_file)) if result is not None: - self.command('echo ' + lPassWord + ' | sudo -S uhd_find_devices', '\$', 10) + self.command('echo ' + lPassWord + ' | sudo -S uhd_find_devices', '\$', 30) result = re.search('type: b200', str(self.ssh.before)) if result is not None: logging.debug('Found a B2xx device --> resetting it') self.command('echo ' + lPassWord + ' | sudo -S b2xx_fx3_utils --reset-device', '\$', 10) # Reloading FGPA bin firmware - self.command('echo ' + lPassWord + ' | sudo -S uhd_find_devices', '\$', 15) + self.command('echo ' + lPassWord + ' | sudo -S uhd_find_devices', '\$', 30) # Make a copy and adapt to EPC / eNB IP addresses self.command('cp ' + full_config_file + ' ' + ci_full_config_file, '\$', 5) self.command('sed -i -e \'s/CI_MME_IP_ADDR/' + self.EPCIPAddress + '/\' ' + ci_full_config_file, '\$', 2); @@ -1138,7 +1178,7 @@ class SSHConnection(): html_queue = SimpleQueue() self.checkDevTTYisUnlocked() if attach_status: - html_cell = '
CAT-M module\nAttachment Completed in ' + str(attach_cnt+4) + ' seconds'
+			html_cell = '
CAT-M module Attachment Completed in ' + str(attach_cnt+4) + ' seconds'
 			if (nRSRQ is not None) and (nRSRP is not None):
 				html_cell += '\n   RSRQ = ' + str(-20+(nRSRQ/2)) + ' dB'
 				html_cell += '\n   RSRP = ' + str(-140+nRSRP) + ' dBm
' @@ -1147,9 +1187,11 @@ class SSHConnection(): html_queue.put(html_cell) self.CreateHtmlTestRowQueue('N/A', 'OK', 1, html_queue) else: - html_cell = '
CAT-M module\nAttachment Failed
' + logging.error('\u001B[1m CAT-M module Attachment Failed\u001B[0m') + html_cell = '
CAT-M module Attachment Failed
' html_queue.put(html_cell) self.CreateHtmlTestRowQueue('N/A', 'KO', 1, html_queue) + self.AutoTerminateUEandeNB() def PingCatM(self): if self.EPCIPAddress == '' or self.EPCUserName == '' or self.EPCPassword == '' or self.EPCSourceCodePath == '': @@ -1160,7 +1202,7 @@ class SSHConnection(): pStatus = self.CheckProcessExist(check_eNB, check_OAI_UE) if (pStatus < 0): self.CreateHtmlTestRow(self.ping_args, 'KO', pStatus) - self.prematureExit = True + self.AutoTerminateUEandeNB() return try: statusQueue = SimpleQueue() @@ -1179,6 +1221,8 @@ class SSHConnection(): if result is not None: moduleIPAddr = result.group('ipaddr') else: + self.CreateHtmlTestRow(self.ping_args, 'KO', pStatus) + self.AutoTerminateUEandeNB() return ping_time = re.findall("-c (\d+)",str(self.ping_args)) device_id = 'catm' @@ -2409,15 +2453,16 @@ class SSHConnection(): os.kill(os.getppid(),signal.SIGUSR1) def IperfNoS1(self): + if self.eNBIPAddress == '' or self.eNBUserName == '' or self.eNBPassword == '' or self.UEIPAddress == '' or self.UEUserName == '' or self.UEPassword == '': + Usage() + sys.exit('Insufficient Parameter') check_eNB = True check_OAI_UE = True pStatus = self.CheckProcessExist(check_eNB, check_OAI_UE) if (pStatus < 0): self.CreateHtmlTestRow(self.iperf_args, 'KO', pStatus) self.AutoTerminateUEandeNB() - if self.eNBIPAddress == '' or self.eNBUserName == '' or self.eNBPassword == '' or self.UEIPAddress == '' or self.UEUserName == '' or self.UEPassword == '': - Usage() - sys.exit('Insufficient Parameter') + return server_on_enb = re.search('-R', str(self.iperf_args)) if server_on_enb is not None: iServerIPAddr = self.eNBIPAddress @@ -3447,6 +3492,11 @@ class SSHConnection(): self.ShowTestID() self.eNB_instance = '0' self.TerminateeNB() + if self.flexranCtrlInstalled and self.flexranCtrlStarted: + self.testCase_id = 'AUTO-KILL-flexran-ctl' + self.desc = 'Automatic Termination of FlexRan CTL' + self.ShowTestID() + self.TerminateFlexranCtrl() self.prematureExit = True def IdleSleep(self): @@ -3716,7 +3766,7 @@ class SSHConnection(): if result is not None: self.UhdVersion = result.group('uhd_version') logging.debug('UHD Version is: ' + self.UhdVersion) - self.command('echo ' + Password + ' | sudo -S uhd_find_devices', '\$', 12) + self.command('echo ' + Password + ' | sudo -S uhd_find_devices', '\$', 30) usrp_boards = re.findall('product: ([0-9A-Za-z]+)\\\\r\\\\n', str(self.ssh.before)) count = 0 for board in usrp_boards: @@ -4564,7 +4614,11 @@ elif re.match('^TesteNB$', mode, re.IGNORECASE) or re.match('^TestUE$', mode, re while cnt < SSH.repeatCounts[0] and SSH.prematureExit: SSH.prematureExit = False for test_case_id in todo_tests: + if SSH.prematureExit: + break for test in all_tests: + if SSH.prematureExit: + break id = test.get('id') if test_case_id != id: continue @@ -4645,10 +4699,6 @@ elif re.match('^TesteNB$', mode, re.IGNORECASE) or re.match('^TestUE$', mode, re SSH.Perform_X2_Handover() else: sys.exit('Invalid action') - if SSH.prematureExit: - break - if SSH.prematureExit: - break cnt += 1 if cnt == SSH.repeatCounts[0] and SSH.prematureExit: logging.debug('Testsuite failed ' + str(cnt) + ' time(s)') diff --git a/ci-scripts/oai-ci-vm-tool b/ci-scripts/oai-ci-vm-tool index 7fba7bac79..bbea199ca1 100755 --- a/ci-scripts/oai-ci-vm-tool +++ b/ci-scripts/oai-ci-vm-tool @@ -140,10 +140,25 @@ function command_options_usage { echo "" } +# function to set specific behavior depending on the TESTPLATFORM_OWNER variable +# which may be set by a jenkins server for exemple +function platform_set { + if [ "$TESTPLATFORM_OWNER" != "" ] + then + echo "Running on $TESTPLATFORM_OWNER platform" + if [ -x "/usr/local/bin/oai_${TESTPLATFORM_OWNER}_setenv.sh" ] + then + . /usr/local/bin/oai_${TESTPLATFORM_OWNER}_setenv.sh + fi + fi +} + function setvar_usage { declare -A HELP_VAR HELP_VAR["VM_OSREL"]="OS release to use in virtual machines" HELP_VAR["RUN_EXPERIMENTAL"]="Enforce execution of variants with EXPERIMENTAL variable set to \"true\"" + HELP_VAR["OPTIONAL_APTCACHER"]="build and Run tests will fail if apt-cacher not installed and this variable not set to \"true\"" + HELP_VAR["TESTPLATFORM_OWNER"]="Allow pipeline customization via execution of an externel scripts residing on the jenkins server" echo "--setvar_ where varname is one of:" for i in ${AUTHORIZED_VAR[@]}; do printf "%20s : %s\n" "$i" "${HELP_VAR[$i]}" ;done } @@ -170,14 +185,14 @@ function variant__v3__phy_sim { NB_PATTERN_FILES=12 BUILD_OPTIONS="--phy_simulators" VM_MEMORY=8192 - RUN_OPTIONS="./run_exec_autotests.bash -g \"01510*\" -q -np -b" + RUN_OPTIONS="./run_exec_autotests.bash -g \"01510* 015111\" -q -np -b" } function variant__v4__cppcheck { VM_MEMORY=4096 LOG_PATTERN=cppcheck.xml NB_PATTERN_FILES=1 - BUILD_OPTIONS="--enable=warning --force --xml --xml-version=2 --suppressions-list=ci-scripts/cppcheck_suppressions.list -I common/utils -I openair3/NAS/COMMON/UTIL -j4" + BUILD_OPTIONS="--enable=warning --force --xml --xml-version=2 -i openair1/PHY/CODING/nrLDPC_decoder/nrLDPC_decoder.c --suppressions-list=ci-scripts/cppcheck_suppressions.list -I common/utils -I openair3/NAS/COMMON/UTIL -j4" } function variant__v5__gnb_usrp { @@ -328,6 +343,7 @@ function check_setvar { exit 1 } +platform_set MY_DIR=$(dirname $(readlink -f $0)) . $MY_DIR/createVM.sh . $MY_DIR/buildOnVM.sh @@ -337,6 +353,7 @@ MY_DIR=$(dirname $(readlink -f $0)) . $MY_DIR/reportBuildLocally.sh . $MY_DIR/reportTestLocally.sh + if [ $# -lt 1 ] then echo "Syntax Error: too few arguments" @@ -454,7 +471,7 @@ RUN_OPTIONS="none" # list of variables that can be set via the --setvar option -AUTHORIZED_VAR=("VM_OSREL RUN_EXPERIMENTAL") +AUTHORIZED_VAR=("VM_OSREL RUN_EXPERIMENTAL OPTIONAL_APTCACHER TESTPLATFORM_OWNER") #variables to set which OS VM should use diff --git a/ci-scripts/runTestOnVM.sh b/ci-scripts/runTestOnVM.sh index e93f23120c..9e69145a8f 100755 --- a/ci-scripts/runTestOnVM.sh +++ b/ci-scripts/runTestOnVM.sh @@ -476,7 +476,7 @@ function install_epc_on_vm { local LOC_EPC_VM_IP_ADDR=`uvt-kvm ip $LOC_EPC_VM_NAME` echo "$LOC_EPC_VM_NAME has for IP addr = $LOC_EPC_VM_IP_ADDR" - scp -o StrictHostKeyChecking=no /etc/apt/apt.conf.d/01proxy ubuntu@$LOC_EPC_VM_IP_ADDR:/home/ubuntu + [ -f /etc/apt/apt.conf.d/01proxy ] && scp -o StrictHostKeyChecking=no /etc/apt/apt.conf.d/01proxy ubuntu@$LOC_EPC_VM_IP_ADDR:/home/ubuntu # ltebox specific actions (install and start) LTE_BOX_TO_INSTALL=1 @@ -500,7 +500,7 @@ function install_epc_on_vm { echo "############################################################" echo "Install EPC on EPC VM ($LOC_EPC_VM_NAME)" echo "############################################################" - echo "sudo cp 01proxy /etc/apt/apt.conf.d/" > $LOC_EPC_VM_CMDS + echo "sudo [ -f 01proxy ] && cp 01proxy /etc/apt/apt.conf.d/" > $LOC_EPC_VM_CMDS echo "touch /home/ubuntu/.hushlogin" >> $LOC_EPC_VM_CMDS echo "echo \"sudo apt-get --yes --quiet install zip openjdk-8-jre libconfuse-dev libreadline-dev liblog4c-dev libgcrypt-dev libsctp-dev python2.7 python2.7-dev daemon iperf\"" >> $LOC_EPC_VM_CMDS echo "sudo apt-get update > zip-install.txt 2>&1" >> $LOC_EPC_VM_CMDS diff --git a/ci-scripts/xml_files/enb_ue_usrp210_band7_epc_start.xml b/ci-scripts/xml_files/enb_ue_usrp210_band7_epc_start.xml index aac71198f1..4dbfe00821 100644 --- a/ci-scripts/xml_files/enb_ue_usrp210_band7_epc_start.xml +++ b/ci-scripts/xml_files/enb_ue_usrp210_band7_epc_start.xml @@ -25,10 +25,23 @@ EPC-Start log-in + 010101 090101 050101 060101 070101 + + Build_eNB + Build eNB (USRP) + -w USRP -c --eNB + + + + Build_OAI_UE + Build OAI UE + -w USRP --UE + + Initialize_HSS Initialize HSS diff --git a/ci-scripts/xml_files/enb_ue_usrp210_band7_test_05mhz_tm1.xml b/ci-scripts/xml_files/enb_ue_usrp210_band7_test_05mhz_tm1.xml index a2e74c6de9..3eca883aa6 100644 --- a/ci-scripts/xml_files/enb_ue_usrp210_band7_test_05mhz_tm1.xml +++ b/ci-scripts/xml_files/enb_ue_usrp210_band7_test_05mhz_tm1.xml @@ -24,7 +24,7 @@ test-05-tm1-nos1-tunnel Test-05MHz-TM1-noS1-tunnel tasks - 2 + 4 030201 090109 030101 000001 090101 000002 040501 040502 000001 040601 040602 040641 040642 000001 090109 030201 diff --git a/ci-scripts/xml_files/enb_usrp210_band13_epc_closure.xml b/ci-scripts/xml_files/enb_usrp210_band13_epc_closure.xml index 07fb6951f8..e52faa7a31 100644 --- a/ci-scripts/xml_files/enb_usrp210_band13_epc_closure.xml +++ b/ci-scripts/xml_files/enb_usrp210_band13_epc_closure.xml @@ -25,10 +25,16 @@ EPC-Closure log-out + 040202 050201 060201 070201 + + Terminate_CatM_module + Terminate CAT-M Module + + Terminate_HSS Terminate HSS diff --git a/ci-scripts/xml_files/x2ho_enb_usrp210_band13_full_terminate.xml b/ci-scripts/xml_files/x2ho_enb_usrp210_band13_full_terminate.xml index 91280462b7..f8aaafd9a0 100644 --- a/ci-scripts/xml_files/x2ho_enb_usrp210_band13_full_terminate.xml +++ b/ci-scripts/xml_files/x2ho_enb_usrp210_band13_full_terminate.xml @@ -26,6 +26,7 @@ tasks 030201 030202 + 050202 @@ -43,4 +44,9 @@ 1 + + Terminate_FlexranCtrl + Stopping Flexran Controller + + diff --git a/cmake_targets/CMakeLists.txt b/cmake_targets/CMakeLists.txt index 47b9aa7ab9..c9b998fdb1 100644 --- a/cmake_targets/CMakeLists.txt +++ b/cmake_targets/CMakeLists.txt @@ -1340,7 +1340,11 @@ set(PHY_SRC_UE ${OPENAIR1_DIR}/PHY/NR_TRANSPORT/nr_prach.c ${OPENAIR1_DIR}/PHY/NR_TRANSPORT/nr_ulsch_llr_computation.c ${OPENAIR1_DIR}/PHY/NR_TRANSPORT/nr_ulsch_demodulation.c + ${OPENAIR1_DIR}/PHY/NR_REFSIG/nr_dmrs_rx.c ${OPENAIR1_DIR}/PHY/NR_REFSIG/nr_gold.c + ${OPENAIR1_DIR}/PHY/NR_UE_ESTIMATION/filt16a_32.c + ${OPENAIR1_DIR}/PHY/NR_ESTIMATION/nr_ul_channel_estimation.c + ${OPENAIR1_DIR}/PHY/NR_ESTIMATION/nr_adjust_sync_gNB.c ${OPENAIR1_DIR}/PHY/TOOLS/file_output.c ${OPENAIR1_DIR}/PHY/TOOLS/cadd_vv.c #${OPENAIR1_DIR}/PHY/TOOLS/lte_dfts.c @@ -1386,6 +1390,7 @@ set(PHY_SRC_UE ${OPENAIR1_DIR}/PHY/NR_REFSIG/ul_ref_seq_nr.c ${OPENAIR1_DIR}/PHY/NR_REFSIG/nr_dmrs_rx.c ${OPENAIR1_DIR}/PHY/NR_REFSIG/nr_gold_ue.c + ${OPENAIR1_DIR}/PHY/NR_UE_ESTIMATION/filt16a_32.c ${OPENAIR1_DIR}/PHY/NR_UE_ESTIMATION/nr_dl_channel_estimation.c ${OPENAIR1_DIR}/PHY/NR_UE_ESTIMATION/nr_adjust_synch_ue.c ${OPENAIR1_DIR}/PHY/NR_UE_ESTIMATION/nr_ue_measurements.c @@ -1575,6 +1580,44 @@ set(L2_SRC_UE ${RRC_DIR}/L2_interface_common.c ${RRC_DIR}/L2_interface_ue.c ) + + set(LTE_NR_L2_SRC_UE + ${PDCP_DIR}/pdcp.c + ${PDCP_DIR}/pdcp_fifo.c + ${PDCP_DIR}/pdcp_sequence_manager.c + ${PDCP_DIR}/pdcp_primitives.c + ${PDCP_DIR}/pdcp_util.c + ${PDCP_DIR}/pdcp_security.c + ${PDCP_DIR}/pdcp_netlink.c + ${RLC_AM_DIR}/rlc_am.c + ${RLC_AM_DIR}/rlc_am_init.c + ${RLC_AM_DIR}/rlc_am_timer_poll_retransmit.c + ${RLC_AM_DIR}/rlc_am_timer_reordering.c + ${RLC_AM_DIR}/rlc_am_timer_status_prohibit.c + ${RLC_AM_DIR}/rlc_am_segment.c + ${RLC_AM_DIR}/rlc_am_segments_holes.c + ${RLC_AM_DIR}/rlc_am_in_sdu.c + ${RLC_AM_DIR}/rlc_am_receiver.c + ${RLC_AM_DIR}/rlc_am_retransmit.c + ${RLC_AM_DIR}/rlc_am_windows.c + ${RLC_AM_DIR}/rlc_am_rx_list.c + ${RLC_AM_DIR}/rlc_am_reassembly.c + ${RLC_AM_DIR}/rlc_am_status_report.c + ${RLC_TM_DIR}/rlc_tm.c + ${RLC_TM_DIR}/rlc_tm_init.c + ${RLC_UM_DIR}/rlc_um.c + ${RLC_UM_DIR}/rlc_um_fsm.c + ${RLC_UM_DIR}/rlc_um_control_primitives.c + ${RLC_UM_DIR}/rlc_um_segment.c + ${RLC_UM_DIR}/rlc_um_reassembly.c + ${RLC_UM_DIR}/rlc_um_receiver.c + ${RLC_UM_DIR}/rlc_um_dar.c + ${RLC_DIR}/rlc_mac.c + ${RLC_DIR}/rlc.c + ${RLC_DIR}/rlc_rrc.c + ${RLC_DIR}/rlc_mpls.c + ${RRC_DIR}/L2_interface_common.c + ) set(NR_L2_SRC_UE ${NR_UE_RRC_DIR}/L2_interface_ue.c @@ -1627,7 +1670,7 @@ set (MAC_SRC_UE ${MAC_DIR}/config_ue.c ) - + set (MAC_NR_SRC_UE ${NR_UE_PHY_INTERFACE_DIR}/NR_IF_Module.c ${NR_UE_MAC_DIR}/config_ue.c @@ -1683,6 +1726,10 @@ endif() add_dependencies(L2_UE rrc_flag s1ap_flag x2_flag) add_library( NR_L2_UE ${NR_L2_SRC_UE} ${MAC_NR_SRC_UE} ) + +add_library ( LTE_NR_L2_UE + ${LTE_NR_L2_SRC_UE} + ) add_library( MAC_NR_COMMON ${OPENAIR2_DIR}/LAYER2/NR_MAC_gNB/nr_mac_common.c ) @@ -2037,7 +2084,7 @@ add_library(LFDS7 # Simulation library ########################## -add_library(SIMU +set (SIMUSRC ${OPENAIR1_DIR}/SIMULATION/TOOLS/random_channel.c ${OPENAIR1_DIR}/SIMULATION/TOOLS/rangen_double.c ${OPENAIR1_DIR}/SIMULATION/TOOLS/taus.c @@ -2048,9 +2095,13 @@ ${OPENAIR1_DIR}/SIMULATION/TOOLS/channel_sim.c ${OPENAIR1_DIR}/SIMULATION/RF/rf.c ${OPENAIR1_DIR}/SIMULATION/RF/dac.c ${OPENAIR1_DIR}/SIMULATION/RF/adc.c -${OPENAIR1_DIR}/SIMULATION/ETH_TRANSPORT/netlink_init.c +${OPENAIR_DIR}/targets/ARCH/rfsimulator/apply_channelmod.c +#${OPENAIR1_DIR}/SIMULATION/ETH_TRANSPORT/netlink_init.c ) +# Simulation library +########################## +add_library( SIMU SHARED ${SIMUSRC} ) add_library(SIMU_ETH ${OPENAIR1_DIR}/SIMULATION/ETH_TRANSPORT/netlink_init.c @@ -2356,7 +2407,6 @@ add_executable(lte-uesoftmodem ${OPENAIR_TARGETS}/RT/USER/lte-ru.c ${OPENAIR_TARGETS}/RT/USER/ru_control.c ${OPENAIR_TARGETS}/RT/USER/rfsim.c - ${OPENAIR1_DIR}/SIMULATION/TOOLS/taus.c ${OPENAIR_TARGETS}/COMMON/create_tasks_ue.c ${OPENAIR_TARGETS}/ARCH/COMMON/common_lib.c ${OPENAIR2_DIR}/RRC/NAS/nas_config.c @@ -2513,6 +2563,8 @@ add_executable(nr-uesoftmodem-nos1 ${rrc_h} ${s1ap_h} # ${OPENAIR_BIN_DIR}/messages_xml.h + ${OPENAIR_TARGETS}/RT/USER/rt_wrapper.c + ${OPENAIR_DIR}/common/utils/threadPool/thread-pool.c ${OPENAIR_DIR}/executables/nr-ue.c ${OPENAIR_DIR}/executables/nr-uesoftmodem.c ${OPENAIR1_DIR}/SIMULATION/TOOLS/taus.c @@ -2527,9 +2579,10 @@ add_executable(nr-uesoftmodem-nos1 ${SHLIB_LOADER_SOURCES} ) + target_link_libraries (nr-uesoftmodem-nos1 -Wl,--start-group - RRC_LIB NR_RRC_LIB S1AP_LIB S1AP_ENB GTPV1U 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_NR_UE PHY_UE PHY_RU LFDS NR_L2_UE MAC_NR_COMMON + RRC_LIB NR_RRC_LIB S1AP_LIB S1AP_ENB GTPV1U 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_NR_UE PHY_RU LFDS LTE_NR_L2 NR_L2_UE MAC_NR_COMMON ${MSC_LIB} ${RAL_LIB} ${ITTI_LIB} ${FLPT_MSG_LIB} ${ASYNC_IF_LIB} LFDS7 ${ATLAS_LIBRARIES} -Wl,--end-group z dl) @@ -2586,36 +2639,58 @@ add_executable(polartest ${OPENAIR1_DIR}/PHY/CODING/TESTBENCH/polartest.c ${OPENAIR_DIR}/common/utils/backtrace.c ${OPENAIR_DIR}/common/utils/nr/nr_common.c) -target_link_libraries(polartest SIMU PHY PHY_NR PHY_COMMON PHY_NR_COMMON m ${ATLAS_LIBRARIES}) + ${OPENAIR_DIR}/common/utils/system.c + ${T_SOURCE} + ${SHLIB_LOADER_SOURCES} + ) +target_link_libraries(polartest + -Wl,--start-group UTIL SIMU PHY_COMMON PHY_NR PHY_NR_COMMON PHY_NR_UE CONFIG_LIB -Wl,--end-group + m pthread ${ATLAS_LIBRARIES} dl + ) - -add_executable(smallblocktest +add_executable(smallblocktest ${OPENAIR1_DIR}/PHY/CODING/TESTBENCH/smallblocktest.c - ${OPENAIR_DIR}/common/utils/backtrace.c ${OPENAIR_DIR}/common/utils/nr/nr_common.c) -target_link_libraries(smallblocktest SIMU PHY PHY_NR PHY_COMMON PHY_NR_COMMON m ${ATLAS_LIBRARIES}) + + +target_link_libraries(smallblocktest + -Wl,--start-group UTIL SIMU PHY_NR PHY_COMMON PHY_NR_COMMON CONFIG_LIB -Wl,--end-group + m pthread ${ATLAS_LIBRARIES} dl + ) add_executable(ldpctest ${OPENAIR1_DIR}/PHY/CODING/TESTBENCH/ldpctest.c - ${OPENAIR_DIR}/common/utils/backtrace.c - ${OPENAIR_DIR}/common/utils/nr/nr_common.c) -target_link_libraries(ldpctest SIMU PHY PHY_NR m ${ATLAS_LIBRARIES}) + ${T_SOURCE} + ${SHLIB_LOADER_SOURCES} + ) +target_link_libraries(ldpctest + -Wl,--start-group UTIL SIMU PHY_NR PHY_COMMON PHY_NR_COMMON CONFIG_LIB -Wl,--end-group + m pthread ${ATLAS_LIBRARIES} dl + ) add_executable(nr_dlschsim ${OPENAIR1_DIR}/SIMULATION/NR_PHY/dlschsim.c - ${OPENAIR_DIR}/common/utils/backtrace.c ${OPENAIR_DIR}/common/utils/system.c - ${OPENAIR_DIR}/common/utils/nr/nr_common.c - ${T_SOURCE}) - target_link_libraries(nr_dlschsim -Wl,--start-group UTIL SIMU PHY_COMMON PHY_NR_COMMON PHY_NR PHY_NR_UE SCHED_NR_LIB CONFIG_LIB MAC_NR_COMMON -Wl,--end-group m pthread ${ATLAS_LIBRARIES} ${T_LIB} dl) + ${UTIL_SRC} + ${T_SOURCE} + ${SHLIB_LOADER_SOURCES} + ) +target_link_libraries(nr_dlschsim + -Wl,--start-group UTIL SIMU PHY_COMMON PHY_NR_COMMON PHY_NR PHY_NR_UE SCHED_NR_LIB CONFIG_LIB MAC_NR_COMMON -Wl,--end-group + m pthread ${ATLAS_LIBRARIES} ${T_LIB} ${ITTI_LIB} dl + ) add_executable(nr_pbchsim ${OPENAIR1_DIR}/SIMULATION/NR_PHY/pbchsim.c - ${OPENAIR_DIR}/common/utils/backtrace.c ${OPENAIR_DIR}/common/utils/system.c - ${OPENAIR_DIR}/common/utils/nr/nr_common.c - ${T_SOURCE}) -target_link_libraries(nr_pbchsim -Wl,--start-group UTIL SIMU PHY_COMMON PHY_NR_COMMON PHY_NR PHY_NR_UE SCHED_NR_LIB CONFIG_LIB MAC_NR_COMMON -Wl,--end-group m pthread ${ATLAS_LIBRARIES} ${T_LIB} $(ITTI_LIB) dl) + ${UTIL_SRC} + ${T_SOURCE} + ${SHLIB_LOADER_SOURCES} + ) +target_link_libraries(nr_pbchsim + -Wl,--start-group UTIL SIMU PHY_COMMON PHY_NR_COMMON PHY_NR PHY_NR_UE SCHED_NR_LIB CONFIG_LIB MAC_NR_COMMON -Wl,--end-group + m pthread ${ATLAS_LIBRARIES} ${T_LIB} ${ITTI_LIB} dl + ) #PUCCH ---> Prashanth add_executable(nr_pucchsim @@ -2624,18 +2699,27 @@ add_executable(nr_pucchsim ${OPENAIR_DIR}/common/utils/nr/nr_common.c ${OPENAIR_DIR}/common/utils/system.c ${UTIL_SRC} - ${T_SOURCE}) -target_link_libraries(nr_pucchsim -Wl,--start-group UTIL SIMU PHY_COMMON PHY_NR PHY_NR_UE SCHED_NR_LIB CONFIG_LIB MAC_NR_COMMON -Wl,--end-group m pthread ${ATLAS_LIBRARIES} ${T_LIB} ${ITTI_LIB} dl) + ${T_SOURCE} + ${SHLIB_LOADER_SOURCES} + ) +target_link_libraries(nr_pucchsim + -Wl,--start-group UTIL SIMU PHY_COMMON PHY_NR_COMMON PHY_NR PHY_NR_UE SCHED_NR_LIB CONFIG_LIB MAC_NR_COMMON -Wl,--end-group + m pthread ${ATLAS_LIBRARIES} ${T_LIB} ${ITTI_LIB} dl + ) #PUCCH ---> Prashanth add_executable(nr_dlsim - ${OPENAIR1_DIR}/SIMULATION/NR_PHY/dlsim.c - ${OPENAIR_DIR}/common/utils/backtrace.c + ${OPENAIR1_DIR}/SIMULATION/NR_PHY/dlsim.c ${OPENAIR_DIR}/common/utils/system.c ${OPENAIR_DIR}/common/utils/nr/nr_common.c ${UTIL_SRC} - ${T_SOURCE}) -target_link_libraries(nr_dlsim -Wl,--start-group UTIL SIMU PHY_COMMON PHY_NR PHY_NR_UE SCHED_NR_LIB SCHED_NR_UE_LIB MAC_NR MAC_UE_NR MAC_NR_COMMON RRC_LIB NR_RRC_LIB CONFIG_LIB L2_NR -Wl,--end-group m pthread ${ATLAS_LIBRARIES} ${T_LIB} ${ITTI_LIB} dl) + ${T_SOURCE} + ${SHLIB_LOADER_SOURCES} + ) +target_link_libraries(nr_dlsim + -Wl,--start-group UTIL SIMU PHY_COMMON PHY_NR_COMMON PHY_NR PHY_NR_UE SCHED_NR_LIB SCHED_NR_UE_LIB MAC_NR MAC_UE_NR MAC_NR_COMMON RRC_LIB NR_RRC_LIB CONFIG_LIB L2_NR -Wl,--end-group + m pthread ${ATLAS_LIBRARIES} ${T_LIB} ${ITTI_LIB} dl + ) add_executable(nr_prachsim ${OPENAIR1_DIR}/SIMULATION/NR_PHY/prachsim.c @@ -2648,21 +2732,27 @@ target_link_libraries(nr_prachsim -Wl,--start-group UTIL SIMU PHY_COMMON PHY_NR add_executable(nr_ulschsim ${OPENAIR1_DIR}/SIMULATION/NR_PHY/ulschsim.c - ${OPENAIR_DIR}/common/utils/backtrace.c ${OPENAIR_DIR}/common/utils/system.c ${UTIL_SRC} - ${OPENAIR_DIR}/common/utils/nr/nr_common.c - ${T_SOURCE}) -target_link_libraries(nr_ulschsim -Wl,--start-group UTIL SIMU PHY_COMMON PHY_NR PHY_NR_UE SCHED_NR_LIB CONFIG_LIB MAC_NR_COMMON -Wl,--end-group m pthread ${ATLAS_LIBRARIES} ${T_LIB} ${ITTI_LIB} dl) + ${T_SOURCE} + ${SHLIB_LOADER_SOURCES} + ) +target_link_libraries(nr_ulschsim + -Wl,--start-group UTIL SIMU PHY_COMMON PHY_NR_COMMON PHY_NR PHY_NR_UE SCHED_NR_LIB CONFIG_LIB MAC_NR_COMMON -Wl,--end-group + m pthread ${ATLAS_LIBRARIES} ${T_LIB} ${ITTI_LIB} dl + ) add_executable(nr_ulsim ${OPENAIR1_DIR}/SIMULATION/NR_PHY/ulsim.c - ${OPENAIR_DIR}/common/utils/backtrace.c - ${OPENAIR_DIR}/common/utils/nr/nr_common.c ${OPENAIR_DIR}/common/utils/system.c ${UTIL_SRC} - ${T_SOURCE}) -target_link_libraries(nr_ulsim -Wl,--start-group UTIL SIMU PHY_COMMON PHY_NR PHY_NR_UE SCHED_NR_LIB SCHED_NR_UE_LIB MAC_NR MAC_UE_NR MAC_NR_COMMON RRC_LIB NR_RRC_LIB CONFIG_LIB L2_NR -Wl,--end-group m pthread ${ATLAS_LIBRARIES} ${T_LIB} ${ITTI_LIB} dl) + ${T_SOURCE} + ${SHLIB_LOADER_SOURCES} + ) +target_link_libraries(nr_ulsim + -Wl,--start-group UTIL SIMU PHY_COMMON PHY_NR PHY_NR_UE SCHED_NR_LIB SCHED_NR_UE_LIB MAC_NR MAC_UE_NR MAC_NR_COMMON RRC_LIB NR_RRC_LIB CONFIG_LIB L2_NR -Wl,--end-group + m pthread ${ATLAS_LIBRARIES} ${T_LIB} ${ITTI_LIB} dl + ) foreach(myExe dlsim dlsim_tm7 ulsim pbchsim scansim mbmssim pdcchsim pucchsim prachsim syncsim) diff --git a/cmake_targets/autotests/README.txt b/cmake_targets/autotests/README.txt index b94d99bff7..10c14fd59a 100644 --- a/cmake_targets/autotests/README.txt +++ b/cmake_targets/autotests/README.txt @@ -96,11 +96,41 @@ Obj.# Case# Test# Description (Test 4, 10 MHz, R3-1.FDD (MCS 16), AWGN, 12dB (70%)), (Test 5, 20 MHz, FDD (MCS 5), AWGN, 6dB (70%)), (Test 6, 20 MHz, FDD (MCS 16), AWGN, 12 dB (70%)) -01 51 02 pucchsim (TBD) -01 51 03 prachsim (TBD) -01 51 04 pdcchsim (TBD) -01 51 05 pbchsim (TBD) -01 51 06 mbmssim (TBD) +01 51 02 ldpc Test cases. (Test1: block length = 3872), + (Test2: block length = 4224), + (Test3: block length = 4576), + (Test4: block length = 4928), + (Test5: block length = 5280), + (Test6: block length = 5632), + (Test7: block length = 6336), + (Test8: block length = 7040), + (Test9: block length = 7744), + (Test10: block length = 8448) +01 51 03 polartest Test cases. (Test1: PBCH polar test), + (Test2: DCI polar test) +01 51 04 nr_pbchsim Test cases. (Test1: PBCH-only, 106 PRB), + (Test2: PBCH and synchronization, 106PBR), + (Test3: PBCH-only, 217 PRB), + (Test4: PBCH and synchronization, 217 RPB), + (Test5: PBCH-only, 273 PRB), + (Test6: PBCH and synchronization, 273 PRB) +01 51 05 nr_dlsim Test cases. (Test1: 106 PRB), + (Test2: 217 PRB), + (Test3: 273 PRB) +01 51 06 nr_dlschsim Test cases. (Test1: 106 PRB), + (Test2: 217 PRB), + (Test3: 273 PRB) +01 51 07 shortblocktest Test cases. (Test1: 3 bits), + (Test2: 6 bits), + (Test3: 7 bits), + (Test4: 11 bits) +01 51 08 nr_ulschsim Test cases. (Test1: 106 PRB), + (Test2: 217 PRB), + (Test3: 273 PRB) +01 51 09 nr_pucchsim Test cases. (Test1: Format 0 ACK miss 106 PRB), + (Test2: Format 1 ACK miss 106 PRB), + (Test3: Format 1 ACK miss 273 PRB), + (Test4: Format 1 NACKtoACK 106 PRB) 01 51 10 dlsim_tm4 test cases (Test 1: 10 MHz, R2.FDD (MCS 5), EVA5, -1dB), (Test 5: 1.4 MHz, R4.FDD (MCS 4), EVA5, 0dB (70%)), (Test 6: 10 MHz, R3.FDD (MCS 15), EVA5, 6.7dB (70%)), @@ -110,8 +140,11 @@ Obj.# Case# Test# Description (Test 10: 5 MHz, R6.FDD (MCS 25), EVA5, 17.4 dB (70%)), (Test 10b: 5 MHz, R6-1.FDD (MCS 24,18 PRB), EVA5, 17.5dB (70%)), (Test 11: 10 MHz, R7.FDD (MCS 25), EVA5, 17.7dB (70%)) - (TM2 Test 1 10 MHz, R.11 FDD (MCS 14), EVA5, 6.8 dB (70%)), - (TM2 Test 1b 20 MHz, R.11-2 FDD (MCS 13), EVA5, 5.9 dB (70%)), + (TM2 Test 1 10 MHz, R.11 FDD (MCS 14), EVA5, 6.8 dB (70%)), + (TM2 Test 1b 20 MHz, R.11-2 FDD (MCS 13), EVA5, 5.9 dB (70%)), +01 51 11 nr_ulsim Test cases. (Test1: MCS 9), + (Test2: MCS 16), + (Test3: MCS 28) diff --git a/cmake_targets/autotests/test_case_list.xml b/cmake_targets/autotests/test_case_list.xml index d30537424b..9cfaa2b21d 100644 --- a/cmake_targets/autotests/test_case_list.xml +++ b/cmake_targets/autotests/test_case_list.xml @@ -1081,7 +1081,16 @@ execution nr_dlsim Test cases. (Test1: 106 PRB), (Test2: 217 PRB), - (Test3: 273 PRB) + (Test3: 273 PRB), + (Test4: 106 PRB 12 CSET-Offset), + (Test5: 217 PRB 48 CSET-Offset), + + (Test7: 273 PRB 28 MCS) $OPENAIR_DIR/cmake_targets/build_oai --phy_simulators -c @@ -1090,9 +1099,18 @@ $OPENAIR_DIR/targets/bin/nr_dlsim.Rel15 -n100 -R106 -n100 -R217 - -n100 -R273 - nr_dlsim.test1 nr_dlsim.test2 nr_dlsim.test3 - PDCCH test OK + -n100 -R273 + -n100 -R106 -o12 + -n100 -R217 -o48 + + -n100 -R273 -e28 + nr_dlsim.test1 nr_dlsim.test2 nr_dlsim.test3 nr_dlsim.test4 nr_dlsim.test5 nr_dlsim.test6 nr_dlsim.test7 + "PDCCH test OK" "PDSCH test OK" segmentation fault|assertion|exiting|fatal 3 @@ -1220,6 +1238,26 @@ 3 + + execution + nr_ulsim Test cases. (Test1: MCS 9), + (Test2: MCS 16), + (Test3: MCS 28) + + $OPENAIR_DIR/cmake_targets/build_oai + --phy_simulators -c + $OPENAIR_DIR/cmake_targets/autotests/tools/free_mem.bash + + $OPENAIR_DIR/targets/bin/nr_ulsim.Rel15 + -f100 -m9 -s10 + -f100 -m16 -s20 + -f100 -m28 -s30 + nr_ulsim.test1 nr_ulsim.test2 nr_ulsim.test3 + PUSCH test OK + segmentation fault|assertion|exiting|fatal + 3 + + lte-softmodem diff --git a/cmake_targets/build_oai b/cmake_targets/build_oai index 220cd40c93..677095d43a 100755 --- a/cmake_targets/build_oai +++ b/cmake_targets/build_oai @@ -149,7 +149,7 @@ Options --build-eclipse Build eclipse project files. Paths are auto corrected by fixprj.sh --build-lib - Build optional shared library, can be one or several of $OPTIONAL_LIBRARIES + Build optional shared library, can be one or several of $OPTIONAL_LIBRARIES or \"all\" --usrp-recplay Build for I/Q record-playback modes -h | --help @@ -346,16 +346,21 @@ function main() { shift 1;; --build-lib) BUILD_OPTLIB="" - for alib in $2 ; do + if [ "$2" == "all" ] ; then + BUILD_OPTLIB="$OPTIONAL_LIBRARIES" + echo_info "Enabling build of all optional shared libraries ($OPTIONAL_LIBRARIES)" + else + for alib in $2 ; do for oklib in $OPTIONAL_LIBRARIES ; do - if [ "$alib" = "$oklib" ] ; then - BUILD_OPTLIB="$BUILD_OPTLIB $alib" - echo_info "Enabling build of lib${alib}.so" - fi + if [ "$alib" = "$oklib" ] ; then + BUILD_OPTLIB="$BUILD_OPTLIB $alib" + echo_info "Enabling build of lib${alib}.so" + fi + done done - done - if [ "${BUILD_OPTLIB## }" != "$2" ] ; then - echo_fatal "Unknown optional library in $2, valid libraries are $OPTIONAL_LIBRARIES" + if [ "${BUILD_OPTLIB## }" != "$2" ] ; then + echo_fatal "Unknown optional library in $2, valid libraries are $OPTIONAL_LIBRARIES" + fi fi shift 2;; --usrp-recplay) @@ -580,7 +585,8 @@ function main() { nr-uesoftmodem $dbin/nr-uesoftmodem.$REL fi -# mandatory shared lib +# mandatory shared libraries common to UE and (e/g)NB + compilations \ $build_dir $config_libconfig_shlib \ lib$config_libconfig_shlib.so $dbin/lib$config_libconfig_shlib.so @@ -864,7 +870,6 @@ function main() { ln -sf $dbin/liboai_eth_transpro.so.$REL $dbin/liboai_transpro.so echo_info "liboai_transpro.so is linked to ETHERNET transport" fi - ################### # Doxygen Support # diff --git a/common/config/DOC/config/devusage/api.md b/common/config/DOC/config/devusage/api.md index 06c22dba6f..376e59abaf 100644 --- a/common/config/DOC/config/devusage/api.md +++ b/common/config/DOC/config/devusage/api.md @@ -1,3 +1,5 @@ +## config module management + ```c configmodule_interface_t *load_configmodule(int argc, char **argv, uint32_t initflags) ``` @@ -14,23 +16,17 @@ void End_configmodule(void) * Free memory which has been allocated by the configuration module since its initialization. * Possibly calls the `config__end` function +## Retrieving parameter's values + ```c int config_get(paramdef_t *params,int numparams, char *prefix) ``` * Reads as many parameters as described in params, they must all be in the same configuration file section * Calls the `config__get` function * Calls the `config_process_cmdline` function -* `params` points to an array of `paramdef_t` structures which describes the parameters to be read, possibly including a pointer to a checking function. The following bits can possibly be set in the `paramflags` mask before calling - - `PARAMFLAG_MANDATORY`: -1 is returned if the parameter is not explicitly defined in the config source. - - `PARAMFLAG_DISABLECMDLINE`: parameter cannot be modified via the command line - - `PARAMFLAG_DONOTREAD`: ignore the parameter, can be used at run-time, to alter a pre-defined `paramdef_t` array which is used in several `config_get` or/and `config_getlist` calls. - - `PARAMFLAG_NOFREE`: do not free the memory possibly allocated by the config module to store the value of the parameter. Default behavior is for the config module to free the memory it has allocated when the `config_end` function is called. - - `PARAMFLAG_BOOL`: Only relevant for integer types. tell the config module that when processing the command line, the corresponding option can be specified without any arggument and that in this case it must set the value to 1. +* `params` points to an array of `paramdef_t` structures which describes the parameters to be read, possibly including a pointer to a checking function.The `paramflags` bit mask can be used to modify how a specific parameter is processed and the same mask is also used by the configuration module to return information about how the parameter has been processed. Bits definitions are described in the [`paramdef_t` structure description](./struct.md) + -* `params` is also used as an output parameter, `< XXX >ptr >` field is used by the config module to store the value it has read. The following bits can possibly be set in the `paramflags` mask after the call: - - `PARAMFLAG_MALLOCINCONFIG`: memory has been allocated for the ` < XXX >ptr > ` field - - `PARAMFLAG_PARAMSET`: parameter has been found in the config source, it is not set to default value. - - `PARAMFLAG_PARAMSET`: parameter has been set to its default value * `numparams` is the number of entries in the params array * `prefix` is a character string to be appended to the parameters name, it defines the parameters position in the configuration file hierarchy (the section name in libconfig terminology). * The returned value is the number of parameters which have been assigned a value or -1 if a severe error occured @@ -44,6 +40,9 @@ int config_libconfig_getlist(paramlist_def_t *ParamList, paramdef_t *params, int * `ParamList` points to a structure, where `paramarray` field points to an array of `paramdef_t` structure, allocated by the function. It is used to return the values of the parameters. * The returned value is the number of occurrences in the list or -1 in case of severe error +## utility functions and macros + +The configuration module also defines APIs to access the `paramdef_t` and `configmodule_interface_t` fields. They are listed in the configuration module [include file `common/config/config_userapi.h`](https://gitlab.eurecom.fr/oai/openairinterface5g/blob/develop/common/config/config_userapi.h) [Configuration module developer main page](../../config/devusage.md) [Configuration module home](../../config.md) diff --git a/common/config/DOC/config/devusage/struct.md b/common/config/DOC/config/devusage/struct.md index e8b15fc0f1..4c9cd15785 100644 --- a/common/config/DOC/config/devusage/struct.md +++ b/common/config/DOC/config/devusage/struct.md @@ -5,6 +5,7 @@ It is defined in include file [ common/config/config_paramdesc.h ](https://gitla |:-----------|:------------------------------------------------------------------|----:| | `optname` | parameter name, as used when looking for it in the config source, 63 bytes max (64 with trailing \0) | I | | `helstr` | pointer to a C string printed when using --help on the command line | I | +| `paramflags` | bit mask, used to modify how the parameter is processed, or to return to the API caller how the parameter has been set, see list in the next table | IO | | `strptr` `strlistptr` `u8ptr` `i8ptr` `u16ptr` `i16ptr` `uptr` `iptr` `u64ptr` `i64ptr` `dblptr` `voidptr` | a pointer to a variable where the parameter value(s) will be returned. This field is an anonymous union, the supported pointer types have been built to avoid type mismatch warnings at compile time. | O | | `defstrval` `defstrlistval` `defuintval` `defintval` `defint64val` `defintarrayval` `defdblval` | this field is an anonymous union, it can be used to define the default value for the parameter. It is ignored if `PARAMFLAG_MANDATORY` is set in the `paramflags` field.| I | | `type` | Supported parameter types are defined as integer macros. Supported simple types are `TYPE_STRING`, parameter value is returned in `strptr` field, `TYPE_INT8` `TYPE_UINT8` `TYPE_INT16` `TYPE_UINT16` `TYPE_INT32` `TYPE_UINT32` `TYPE_INT64` `TYPE_UINT64`, parameter value is returned in the corresponding uXptr or iXptr, `TYPE_MASK`, value is returned in `u32ptr`, `TYPE_DOUBLE` value is returned in `dblptr`, `TYPE_IPV4ADDR` value is returned in binary, network bytes order in `u32ptr` field. `TYPE_STRINGLIST`, `TYPE_INTARRAY` and `TYPE_UINTARRAY` are multiple values types. Multiple values are returned in respectively, `strlistptr`, `iptr` and `uptr` fields which then point to arrays. The `numelt` field gives the number of item in the array. | I | @@ -12,6 +13,22 @@ It is defined in include file [ common/config/config_paramdesc.h ](https://gitla | `chkPptr` | possible pointer to the structure containing the info used to check parameter values | I | | `processedvalue` | When `chkPptr` is not `ǸULL`, is used to return a value, computed from the original parameter, as read from the configuration source. | O | +## `paramflags` bits definition + + +| C macro bit definition | usage | I/O | +|:-------------------------------------|:---------------------------------------------------------------------------------------------------------------------|----:| +| `PARAMFLAG_MANDATORY` | parameter is mandatory, comfiguration module will stop the process if it is not specified. Default value is ignored | I | +| `PARAMFLAG_DISABLECMDLINE` | parameter cannot be specified on the command line | I | +| `PARAMFLAG_DONOTREAD` | ignore the parameter, usefull when a parameter group is used in different context | I | +| `PARAMFLAG_NOFREE` | The end_configmodule API won't free the memory which has been possibly allocated to store the value of the parameter.| I | +| `PARAMFLAG_BOOL` | Parameter is a boolean, it can be specified without a value to set it to true | I | +| `PARAMFLAG_CMDLINE_NOPREFIXENABLED` | parameter can be specified without the prefix on the command line. Must be used with care, carefuly checking unicity, especially for short parameter names | I | +| `PARAMFLAG_MALLOCINCONFIG` | Memory for the parameter value has been allocated by the configuration module |O | +| `PARAMFLAG_PARAMSET` | Parameter value has been explicitely set, as the parameter was specified either on the command line or the config source | O | +| `PARAMFLAG_PARAMSETDEF` | Parameter value has been set to it's default | O | + + # `paramlist_def_t`structure It is defined in include file [ common/config/config_paramdesc.h ](https://gitlab.eurecom.fr/oai/openairinterface5g/blob/develop/common/config/config_paramdesc.h#L160). It is used as an argument to `config_getlist` calls, to get values of multiple occurrences of group of parameters. diff --git a/common/config/config_cmdline.c b/common/config/config_cmdline.c index 249765a46e..6d01d98c65 100644 --- a/common/config/config_cmdline.c +++ b/common/config/config_cmdline.c @@ -167,8 +167,8 @@ int config_check_unknown_cmdlineopt(char *prefix) { char testprefix[CONFIG_MAXOPTLENGTH]; int finalcheck = 0; memset(testprefix,0,sizeof(testprefix)); - memset(testprefix,0,sizeof(testprefix)); + if (prefix != NULL) { if (strcmp(prefix,CONFIG_CHECKALLSECTIONS) == 0) finalcheck = 1; @@ -253,7 +253,9 @@ int config_process_cmdline(paramdef_t *cfgoptions,int numoptions, char *prefix) } if ( ((strlen(oneargv) == 2) && (strcmp(oneargv + 1,cfgpath) == 0)) || /* short option, one "-" */ - ((strlen(oneargv) > 2) && (strcmp(oneargv + 2,cfgpath ) == 0 )) ) { + ((strlen(oneargv) > 2) && (strcmp(oneargv + 2,cfgpath ) == 0 )) || /* long option beginning with "--" */ + ((strlen(oneargv) == 2) && (strcmp(oneargv + 1,cfgoptions[n].optname) == 0) && (cfgoptions[n].paramflags & PARAMFLAG_CMDLINE_NOPREFIXENABLED )) || + ((strlen(oneargv) > 2) && (strcmp(oneargv + 2,cfgpath ) == 0 ) && (cfgoptions[n].paramflags & PARAMFLAG_CMDLINE_NOPREFIXENABLED )) ) { char *valptr=NULL; int ret; config_get_if()->argv_info[i] |= CONFIG_CMDLINEOPT_PROCESSED; diff --git a/common/config/config_paramdesc.h b/common/config/config_paramdesc.h index 9aad79960d..86fc993a08 100644 --- a/common/config/config_paramdesc.h +++ b/common/config/config_paramdesc.h @@ -45,7 +45,7 @@ #define PARAMFLAG_DONOTREAD (1 << 2) // parameter must be ignored in get function #define PARAMFLAG_NOFREE (1 << 3) // don't free parameter in end function #define PARAMFLAG_BOOL (1 << 4) // integer param can be 0 or 1 - +#define PARAMFLAG_CMDLINE_NOPREFIXENABLED (1 << 5) // on the command line, allow a parameter to be specified without the prefix /* Flags used by config modules to return info to calling modules and/or to for internal usage*/ #define PARAMFLAG_MALLOCINCONFIG (1 << 15) // parameter allocated in config module diff --git a/common/config/config_userapi.c b/common/config/config_userapi.c index 13dd6730eb..e14f28f829 100644 --- a/common/config/config_userapi.c +++ b/common/config/config_userapi.c @@ -172,7 +172,7 @@ int config_get_processedint(paramdef_t *cfgoption) { return ret; } void config_printhelp(paramdef_t *params,int numparams, char *prefix) { - printf("\n-----Help for section %-26s: %03i entries------\n",(prefix==NULL)?"(root section)":prefix ,numparams); + printf("\n-----Help for section %-26s: %03i entries------\n",(prefix==NULL)?"(root section)":prefix,numparams); for (int i=0 ; inumelt ; j++) { - printf_params("[CONFIG] %s[%i] set to default value %i\n",cfgoptions->optname ,j,(int)cfgoptions->iptr[j]); + printf_params("[CONFIG] %s[%i] set to default value %i\n",cfgoptions->optname,j,(int)cfgoptions->iptr[j]); } } @@ -452,7 +462,7 @@ int config_setdefault_double(paramdef_t *cfgoptions, char *prefix) { if( ((cfgoptions->paramflags & PARAMFLAG_MANDATORY) == 0)) { *(cfgoptions->dblptr)=cfgoptions->defdblval; status=1; - printf_params("[CONFIG] %s set to default value %lf\n",cfgoptions->optname , *(cfgoptions->dblptr)); + printf_params("[CONFIG] %s set to default value %lf\n",cfgoptions->optname, *(cfgoptions->dblptr)); } return status; @@ -460,7 +470,7 @@ int config_setdefault_double(paramdef_t *cfgoptions, char *prefix) { int config_assign_ipv4addr(paramdef_t *cfgoptions, char *ipv4addr) { config_check_valptr(cfgoptions,(char **)&(cfgoptions->uptr), sizeof(int)); - int rst=inet_pton(AF_INET, ipv4addr ,cfgoptions->uptr ); + int rst=inet_pton(AF_INET, ipv4addr,cfgoptions->uptr ); if (rst == 1 && *(cfgoptions->uptr) > 0) { printf_params("[CONFIG] %s: %s\n",cfgoptions->optname, ipv4addr); diff --git a/common/config/config_userapi.h b/common/config/config_userapi.h index cc07b1af5f..c00526aa4c 100644 --- a/common/config/config_userapi.h +++ b/common/config/config_userapi.h @@ -39,6 +39,7 @@ extern "C" { #endif +/* utility functions to ease usage of config module structures */ #define CONFIG_GETSOURCE ( (config_get_if()==NULL) ? NULL : config_get_if()->cfgmode ) #define CONFIG_GETNUMP ( (config_get_if()==NULL) ? 0 : config_get_if()->num_cfgP ) #define CONFIG_GETP(P) ( (config_get_if()==NULL) ? NULL : config_get_if()->cfgP[P] ) @@ -46,6 +47,8 @@ extern "C" #define CONFIG_SETRTFLAG(P) if (config_get_if()) { config_get_if()->rtflags |= P; } #define CONFIG_CLEARRTFLAG(P) if (config_get_if()) { config_get_if()->rtflags &= (~P); } #define CONFIG_ISPARAMFLAGSET(P,F) ( !!(P.paramflags & F)) +extern int config_paramidx_fromname(paramdef_t *params,int numparams, char *name); + /* utility functions, to be used by configuration module and/or configuration libraries */ extern configmodule_interface_t *config_get_if(void); extern char *config_check_valptr(paramdef_t *cfgoptions, char **ptr, int length) ; diff --git a/common/utils/LOG/log.c b/common/utils/LOG/log.c index 1108eb46da..8d46f72f9c 100644 --- a/common/utils/LOG/log.c +++ b/common/utils/LOG/log.c @@ -232,7 +232,7 @@ int write_file_matlab(const char *fname, void log_getconfig(log_t *g_log) { char *gloglevel = NULL; - int consolelog ; + int consolelog = 0; paramdef_t logparams_defaults[] = LOG_GLOBALPARAMS_DESC; paramdef_t logparams_level[MAX_LOG_PREDEF_COMPONENTS]; paramdef_t logparams_logfile[MAX_LOG_PREDEF_COMPONENTS]; diff --git a/common/utils/LOG/log.h b/common/utils/LOG/log.h index cee14a27af..111f2c58ce 100644 --- a/common/utils/LOG/log.h +++ b/common/utils/LOG/log.h @@ -25,7 +25,6 @@ * \date 2009 - 2014 * \version 0.5 * @ingroup util - */ #ifndef __LOG_H__ @@ -297,7 +296,7 @@ extern "C" { # include "log_if.h" /*----------------------------------------------------------------------------*/ int logInit (void); -int isLogInitDone (void); +int isLogInitDone (void); void logRecord_mt(const char *file, const char *func, int line,int comp, int level, const char *format, ...) __attribute__ ((format (printf, 6, 7))); void vlogRecord_mt(const char *file, const char *func, int line, int comp, int level, const char *format, va_list args ); void log_dump(int component, void *buffer, int buffsize,int datatype, const char *format, ... ); @@ -363,14 +362,14 @@ int32_t write_file_matlab(const char *fname, const char *vname, void *data, int -/*------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------*/ -/* LOG globalconfiguration parameters */ -/* optname help paramflags XXXptr defXXXval type numelt */ -/*------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------*/ +/*-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------*/ +/* LOG globalconfiguration parameters */ +/* optname help paramflags XXXptr defXXXval type numelt */ +/*-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------*/ #define LOG_GLOBALPARAMS_DESC { \ - {LOG_CONFIG_STRING_GLOBAL_LOG_LEVEL, "Default log level for all componemts\n", 0, strptr:(char **)&gloglevel, defstrval:log_level_names[2].name, TYPE_STRING, 0}, \ - {LOG_CONFIG_STRING_GLOBAL_LOG_ONLINE, "Default console output option, for all components\n", 0, iptr:&(consolelog), defintval:1, TYPE_INT, 0}, \ - {LOG_CONFIG_STRING_GLOBAL_LOG_OPTIONS, LOG_CONFIG_HELP_OPTIONS, 0, strlistptr:NULL, defstrlistval:NULL, TYPE_STRINGLIST,0} \ + {LOG_CONFIG_STRING_GLOBAL_LOG_LEVEL, "Default log level for all componemts\n", 0, strptr:(char **)&gloglevel, defstrval:log_level_names[2].name, TYPE_STRING, 0}, \ + {LOG_CONFIG_STRING_GLOBAL_LOG_ONLINE, "Default console output option, for all components\n", 0, iptr:&(consolelog), defintval:1, TYPE_INT, 0}, \ + {LOG_CONFIG_STRING_GLOBAL_LOG_OPTIONS, LOG_CONFIG_HELP_OPTIONS, 0, strlistptr:NULL, defstrlistval:NULL, TYPE_STRINGLIST, 0} \ } #define LOG_OPTIONS_IDX 2 diff --git a/common/utils/LOG/vcd_signal_dumper.c b/common/utils/LOG/vcd_signal_dumper.c index b3a1aaad07..7ea15cf9db 100644 --- a/common/utils/LOG/vcd_signal_dumper.c +++ b/common/utils/LOG/vcd_signal_dumper.c @@ -634,7 +634,7 @@ void *vcd_dumper_thread_rt(void *args) uint32_t data_ready_wait; # if defined(ENABLE_ITTI) - signal_mask(); + return 0; //signal_mask(); //function defined at common/utils/ocp_itti/intertask_interface.cpp # endif sched_param.sched_priority = sched_get_priority_min(SCHED_FIFO) + 1; diff --git a/common/utils/ocp_itti/intertask_interface.cpp b/common/utils/ocp_itti/intertask_interface.cpp index e8b12fcd4d..89e19074bf 100644 --- a/common/utils/ocp_itti/intertask_interface.cpp +++ b/common/utils/ocp_itti/intertask_interface.cpp @@ -11,11 +11,11 @@ #include typedef struct timer_elm_s { - timer_type_t type; ///< Timer type - long instance; + timer_type_t type; ///< Timer type + long instance; long duration; uint64_t timeout; - void *timer_arg; ///< Optional argument that will be passed when timer expires + void *timer_arg; ///< Optional argument that will be passed when timer expires } timer_elm_t ; typedef struct task_list_s { diff --git a/common/utils/ocp_itti/intertask_interface.h b/common/utils/ocp_itti/intertask_interface.h index 868a9ba245..80493dc816 100644 --- a/common/utils/ocp_itti/intertask_interface.h +++ b/common/utils/ocp_itti/intertask_interface.h @@ -25,7 +25,7 @@ typedef struct { typedef struct { uint32_t interval_sec; uint32_t interval_us; - long task_id; + long task_id; int32_t instance; timer_type_t type; void *timer_arg; @@ -33,7 +33,7 @@ typedef struct { } timer_create_t; typedef struct { - long task_id; + long task_id; long timer_id; } timer_delete_t; @@ -536,6 +536,7 @@ int timer_setup( int timer_remove(long timer_id); #define timer_stop timer_remove int signal_handle(int *end); +int signal_mask(void); #ifdef __cplusplus } diff --git a/common/utils/telnetsrv/telnetsrv.c b/common/utils/telnetsrv/telnetsrv.c index 7f8645be02..44ab07a49b 100644 --- a/common/utils/telnetsrv/telnetsrv.c +++ b/common/utils/telnetsrv/telnetsrv.c @@ -123,7 +123,7 @@ void client_printf(const char *message, ...) { if (telnetparams.new_socket > 0) { vsnprintf(telnetparams.msgbuff,sizeof(telnetparams.msgbuff)-1,message, va_args); - send(telnetparams.new_socket,telnetparams.msgbuff , strlen(telnetparams.msgbuff), MSG_NOSIGNAL); + send(telnetparams.new_socket,telnetparams.msgbuff, strlen(telnetparams.msgbuff), MSG_NOSIGNAL); } else { vprintf(message, va_args); } @@ -475,7 +475,7 @@ int process_command(char *buf) { memset(cmdb,0,sizeof(cmdb)); bufbck=strdup(buf); rt=CMDSTATUS_NOTFOUND; - j = sscanf(buf,"%9s %9s %9[^\t\n]",modulename,cmd,cmdb); + j = sscanf(buf,"%19s %19s %19[^\t\n]",modulename,cmd,cmdb); if (telnetparams.telnetdbg > 0) printf("process_command: %i words, module=%s cmd=%s, parameters= %s\n",j,modulename,cmd,cmdb); @@ -543,7 +543,7 @@ void run_telnetsrv(void) { char buf[TELNET_MAX_MSGLENGTH]; struct sockaddr cli_addr; unsigned int cli_len = sizeof(cli_addr); - int readc , filled; + int readc, filled; int status; int optval = 1; pthread_setname_np(pthread_self(), "telnet"); @@ -604,7 +604,7 @@ void run_telnetsrv(void) { } if (telnetparams.telnetdbg > 0) - printf("[TELNETSRV] Command received: readc %i filled %i \"%s\"\n", readc, filled ,buf); + printf("[TELNETSRV] Command received: readc %i filled %i \"%s\"\n", readc, filled,buf); if (buf[0] == '!') { if (buf[1] == '!') { diff --git a/doc/BUILD.md b/doc/BUILD.md index 65567cefa4..388f9f2658 100644 --- a/doc/BUILD.md +++ b/doc/BUILD.md @@ -54,7 +54,7 @@ cd cmake_targets/ ``` - The `-I` option is to install pre-requisites, you only need it the first time you build the softmodem or when some oai dependencies have changed. -- The `-w` option is to select the radio head support you want to include in your build. Radio head support is provided via a shared library, which is called the "oai device" The build script creates a soft link from `liboai_device.so` to the true device which will be used at run-time (here the USRP one,`liboai_usrpdevif.so` . USRP is the only hardware tested today in the Continuous Integration process. +- The `-w` option is to select the radio head support you want to include in your build. Radio head support is provided via a shared library, which is called the "oai device" The build script creates a soft link from `liboai_device.so` to the true device which will be used at run-time (here the USRP one,`liboai_usrpdevif.so` . USRP is the only hardware tested today in the Continuous Integration process. The RF simulator[RF simulator](../targets/ARCH/rfsimulator/README.md) is implemented as a specific device replacing RF hardware, it can be build using `-w SIMU` option. - `--eNB` is to build the `lte-softmodem` executable and all required shared libraries - `--UE` is to build the `lte-uesoftmodem` executable and all required shared libraries diff --git a/executables/nr-gnb.c b/executables/nr-gnb.c index 6ece377293..ed95bf1829 100644 --- a/executables/nr-gnb.c +++ b/executables/nr-gnb.c @@ -99,17 +99,17 @@ #if defined(ENABLE_ITTI) - extern volatile int start_gNB; - extern volatile int start_UE; + extern volatile int start_gNB; + extern volatile int start_UE; #endif -extern volatile int oai_exit; +extern volatile int oai_exit; extern openair0_config_t openair0_cfg[MAX_CARDS]; extern int transmission_mode; -uint16_t sl_ahead=4; -uint16_t sf_ahead=4; +uint16_t sl_ahead=6; +uint16_t sf_ahead=6; //pthread_t main_gNB_thread; time_stats_t softmodem_stats_mt; // main thread @@ -133,13 +133,14 @@ extern double cpuf; void init_gNB(int,int); void stop_gNB(int nb_inst); -int wakeup_txfh(PHY_VARS_gNB *gNB,gNB_L1_rxtx_proc_t *proc,int frame_tx,int slot_tx,uint64_t timestamp_tx); -int wakeup_tx(PHY_VARS_gNB *gNB,int frame_rx,int slot_rx,int frame_tx,int slot_tx,uint64_t timestamp_tx); -extern PARALLEL_CONF_t get_thread_parallel_conf(void); -extern WORKER_CONF_t get_thread_worker_conf(void); +int wakeup_txfh(PHY_VARS_gNB *gNB, gNB_L1_rxtx_proc_t *proc, int frame_tx, int slot_tx, uint64_t timestamp_tx); +int wakeup_tx(PHY_VARS_gNB *gNB, int frame_rx, int slot_rx, int frame_tx, int slot_tx, uint64_t timestamp_tx); +#include "executables/thread-common.h" +//extern PARALLEL_CONF_t get_thread_parallel_conf(void); +//extern WORKER_CONF_t get_thread_worker_conf(void); -void wakeup_prach_gNB(PHY_VARS_gNB *gNB,RU_t *ru,int frame,int subframe); +void wakeup_prach_gNB(PHY_VARS_gNB *gNB, RU_t *ru, int frame, int subframe); extern uint8_t nfapi_mode; extern void oai_subframe_ind(uint16_t sfn, uint16_t sf); @@ -149,7 +150,7 @@ extern void add_subframe(uint16_t *frameP, uint16_t *subframeP, int offset); #define TICK_TO_US(ts) (ts.trials==0?0:ts.diff/ts.trials) -static inline int rxtx(PHY_VARS_gNB *gNB,int frame_rx, int slot_rx, int frame_tx, int slot_tx, char *thread_name) { +static inline int rxtx(PHY_VARS_gNB *gNB, int frame_rx, int slot_rx, int frame_tx, int slot_tx, char *thread_name) { start_meas(&softmodem_stats_rxtx_sf); // ******************************************************************* @@ -184,17 +185,20 @@ static inline int rxtx(PHY_VARS_gNB *gNB,int frame_rx, int slot_rx, int frame_tx // **************************************** // Common RX procedures subframe n T(T_GNB_PHY_DL_TICK, T_INT(gNB->Mod_id), T_INT(frame_tx), T_INT(slot_tx)); - /* - // if this is IF5 or 3GPP_gNB - if (gNB && gNB->RU_list && gNB->RU_list[0] && gNB->RU_list[0]->function < NGFI_RAU_IF4p5) { - wakeup_prach_gNB(gNB,NULL,proc->frame_rx,proc->slot_rx); - } +/* + // if this is IF5 or 3GPP_gNB + if (gNB && gNB->RU_list && gNB->RU_list[0] && gNB->RU_list[0]->function < NGFI_RAU_IF4p5) { + wakeup_prach_gNB(gNB,NULL,proc->frame_rx,proc->slot_rx); + } + + // UE-specific RX processing for subframe n + if (nfapi_mode == 0 || nfapi_mode == 1) */ + + if (slot_rx == NR_UPLINK_SLOT || gNB->frame_parms.frame_type == FDD) { + nfapi_nr_ul_config_ulsch_pdu_rel15_t *ulsch_pdu_rel15 = &gNB->ulsch[1][0]->harq_processes[0]->ulsch_pdu.ulsch_pdu_rel15; + phy_procedures_gNB_uespec_RX(gNB, frame_rx, slot_rx, ulsch_pdu_rel15->start_symbol, ulsch_pdu_rel15->start_symbol + ulsch_pdu_rel15->number_symbols); + } - // UE-specific RX processing for subframe n - if (nfapi_mode == 0 || nfapi_mode == 1) { - phy_procedures_gNB_uespec_RX(gNB, proc, no_relay ); - } - */ pthread_mutex_lock(&gNB->UL_INFO_mutex); gNB->UL_INFO.frame = frame_rx; gNB->UL_INFO.slot = slot_rx; diff --git a/executables/nr-ru.c b/executables/nr-ru.c index 5bf7ef24ce..4094a748ca 100644 --- a/executables/nr-ru.c +++ b/executables/nr-ru.c @@ -114,27 +114,22 @@ static int DEFENBS[] = {0}; #include "T.h" #include "nfapi_interface.h" -extern volatile int oai_exit; +extern volatile int oai_exit; extern void nr_phy_free_RU(RU_t *); extern void nr_phy_config_request(NR_PHY_Config_t *gNB); - -extern PARALLEL_CONF_t get_thread_parallel_conf(void); -extern WORKER_CONF_t get_thread_worker_conf(void); +#include "executables/thread-common.h" +//extern PARALLEL_CONF_t get_thread_parallel_conf(void); +//extern WORKER_CONF_t get_thread_worker_conf(void); void init_NR_RU(char *); void stop_RU(int nb_ru); void do_ru_sync(RU_t *ru); -void configure_ru(int idx, - void *arg); - -void configure_rru(int idx, - void *arg); - +void configure_ru(int idx, void *arg); +void configure_rru(int idx, void *arg); int attach_rru(RU_t *ru); - int connect_rau(RU_t *ru); extern uint16_t sl_ahead; @@ -653,6 +648,7 @@ void rx_rf(RU_t *ru,int *frame,int *slot) { ru->nb_rx); } + VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME( VCD_SIGNAL_DUMPER_FUNCTIONS_TRX_READ, 0 ); proc->timestamp_rx = ts-ru->ts_offset; @@ -718,14 +714,26 @@ void rx_rf(RU_t *ru,int *frame,int *slot) { void tx_rf(RU_t *ru,int frame,int slot, uint64_t timestamp) { RU_proc_t *proc = &ru->proc; NR_DL_FRAME_PARMS *fp = ru->nr_frame_parms; - nfapi_nr_config_request_t *cfg = &ru->gNB_list[0]->gNB_config; + //nfapi_nr_config_request_t *cfg = &ru->gNB_list[0]->gNB_config; void *txp[ru->nb_tx]; unsigned int txs; int i; T(T_ENB_PHY_OUTPUT_SIGNAL, T_INT(0), T_INT(0), T_INT(frame), T_INT(slot), T_INT(0), T_BUFFER(&ru->common.txdata[0][slot * fp->samples_per_slot], fp->samples_per_slot * 4)); + int slot_type = nr_slot_select(ru->nr_frame_parms,frame,slot%fp->slots_per_frame); int sf_extension = 0; + //nr_subframe_t SF_type = nr_slot_select(cfg,slot%fp->slots_per_frame); + + if ((slot == 0) || + (slot == 1)) { + int siglen=fp->samples_per_slot; + int flags; + if (slot==0) + flags = 2; + else if (slot==1) + flags=3; + if ((slot_type & NR_UPLINK_SLOT) == 0) { @@ -768,7 +776,7 @@ void tx_rf(RU_t *ru,int frame,int slot, uint64_t timestamp) { LOG_D(PHY,"[TXPATH] RU %d tx_rf, writing to TS %llu, frame %d, unwrapped_frame %d, subframe %d\n",ru->idx, (long long unsigned int)timestamp,frame,proc->frame_tx_unwrap,slot); VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME( VCD_SIGNAL_DUMPER_FUNCTIONS_TRX_WRITE, 0 ); - AssertFatal(txs == siglen+sf_extension,"TX : Timeout (sent %d/%d)\n",txs, siglen); + AssertFatal(txs == siglen+sf_extension,"TX : Timeout (sent %u/%d)\n", txs, siglen); } } @@ -1214,12 +1222,12 @@ static void *ru_stats_thread(void *param) { } static void *ru_thread_tx( void *param ) { - RU_t *ru = (RU_t *)param; - RU_proc_t *proc = &ru->proc; - PHY_VARS_gNB *gNB; - gNB_L1_proc_t *gNB_proc; + RU_t *ru = (RU_t *)param; + RU_proc_t *proc = &ru->proc; + NR_DL_FRAME_PARMS *fp = ru->nr_frame_parms; + PHY_VARS_gNB *gNB; + gNB_L1_proc_t *gNB_proc; gNB_L1_rxtx_proc_t *L1_proc; - NR_DL_FRAME_PARMS *fp = ru->nr_frame_parms; char filename[40]; int print_frame = 8; int i = 0; @@ -1243,12 +1251,14 @@ static void *ru_thread_tx( void *param ) { // wait until eNBs are finished subframe RX n and TX n+4 wait_on_condition(&proc->mutex_gNBs,&proc->cond_gNBs,&proc->instance_cnt_gNBs,"ru_thread_tx"); - AssertFatal((ret=pthread_mutex_lock(&proc->mutex_gNBs))==0,"mutex_lock return %d\n",ret); + ret = pthread_mutex_lock(&proc->mutex_gNBs); + AssertFatal(ret == 0,"mutex_lock return %d\n",ret); int frame_tx=proc->frame_tx; int tti_tx =proc->tti_tx; uint64_t timestamp_tx = proc->timestamp_tx; - AssertFatal((ret=pthread_mutex_unlock(&proc->mutex_gNBs))==0,"mutex_lock returns %d\n",ret); + ret = pthread_mutex_unlock(&proc->mutex_gNBs); + AssertFatal(ret == 0,"mutex_lock returns %d\n",ret); if (oai_exit) break; @@ -1299,7 +1309,8 @@ static void *ru_thread_tx( void *param ) { gNB = ru->gNB_list[i]; gNB_proc = &gNB->proc; L1_proc = (get_thread_parallel_conf() == PARALLEL_RU_L1_TRX_SPLIT)? &gNB_proc->L1_proc_tx : &gNB_proc->L1_proc; - AssertFatal((ret=pthread_mutex_lock(&gNB_proc->mutex_RU_tx))==0,"mutex_lock returns %d\n",ret); + ret = pthread_mutex_lock(&gNB_proc->mutex_RU_tx); + AssertFatal(ret == 0,"mutex_lock returns %d\n",ret); for (int j=0; jnum_RU; j++) { if (ru == gNB->RU_list[j]) { @@ -1312,12 +1323,15 @@ static void *ru_thread_tx( void *param ) { } if (gNB_proc->RU_mask_tx != (1<num_RU)-1) { // not all RUs have provided their information so return - AssertFatal((ret=pthread_mutex_unlock(&gNB_proc->mutex_RU_tx))==0,"mutex_unlock returns %d\n",ret); + ret = pthread_mutex_unlock(&gNB_proc->mutex_RU_tx); + AssertFatal(ret == 0,"mutex_unlock returns %d\n",ret); } else { // all RUs TX are finished so send the ready signal to gNB processing gNB_proc->RU_mask_tx = 0; - AssertFatal((ret=pthread_mutex_unlock(&gNB_proc->mutex_RU_tx))==0,"mutex_unlock returns %d\n",ret); + ret = pthread_mutex_unlock(&gNB_proc->mutex_RU_tx); + AssertFatal(ret == 0,"mutex_unlock returns %d\n",ret); - AssertFatal((ret=pthread_mutex_lock(&L1_proc->mutex_RUs_tx))==0,"mutex_lock returns %d\n",ret); + ret = pthread_mutex_lock(&L1_proc->mutex_RUs_tx); + AssertFatal(ret == 0,"mutex_lock returns %d\n",ret); // the thread can now be woken up if (L1_proc->instance_cnt_RUs==-1) { AssertFatal(pthread_cond_signal(&L1_proc->cond_RUs) == 0, @@ -1325,8 +1339,8 @@ static void *ru_thread_tx( void *param ) { } //else AssertFatal(1==0,"gNB TX thread is not ready\n"); L1_proc->instance_cnt_RUs = 0; VCD_SIGNAL_DUMPER_DUMP_VARIABLE_BY_NAME(VCD_SIGNAL_DUMPER_VARIABLES_FRAME_NUMBER_RX0_UE,L1_proc->instance_cnt_RUs); - AssertFatal((ret=pthread_mutex_unlock(&L1_proc->mutex_RUs_tx))==0,"mutex_unlock returns %d\n",ret); - + ret = pthread_mutex_unlock(&L1_proc->mutex_RUs_tx); + AssertFatal(ret == 0,"mutex_unlock returns %d\n",ret); } } } @@ -1339,13 +1353,15 @@ static void *ru_thread( void *param ) { static int ru_thread_status; RU_t *ru = (RU_t *)param; RU_proc_t *proc = &ru->proc; - NR_DL_FRAME_PARMS *fp = ru->nr_frame_parms; + NR_DL_FRAME_PARMS *fp = ru->nr_frame_parms; int ret; - int slot = fp->slots_per_frame-1; - int frame =1023; - char filename[40],threadname[40]; + int slot = fp->slots_per_frame-1; + int frame = 1023; + char filename[40], threadname[40]; int print_frame = 8; int i = 0; + int aa; + // set default return value ru_thread_status = 0; // set default return value @@ -1377,9 +1393,9 @@ static void *ru_thread( void *param ) { } if (ru->if_south == LOCAL_RF) { // configure RF parameters only - fill_rf_config(ru,ru->rf_config_file); nr_init_frame_parms(&ru->gNB_list[0]->gNB_config, fp); nr_dump_frame_parms(fp); + fill_rf_config(ru,ru->rf_config_file); nr_phy_init_RU(ru); ret = openair0_device_load(&ru->rfdevice,&ru->openair0_cfg); AssertFatal(ret==0,"Cannot connect to local radio\n"); @@ -1438,6 +1454,7 @@ static void *ru_thread( void *param ) { } // synchronization on input FH interface, acquire signals/data and block + LOG_D(PHY,"[RU_thread] read data: frame_rx = %d, tti_rx = %d\n", frame, slot); if (ru->fh_south_in) ru->fh_south_in(ru,&frame,&slot); else AssertFatal(1==0, "No fronthaul interface at south port"); @@ -1462,7 +1479,19 @@ static void *ru_thread( void *param ) { if (ru->idx!=0) proc->frame_tx = (proc->frame_tx+proc->frame_offset)&1023; // do RX front-end processing (frequency-shift, dft) if needed - if (ru->feprx) ru->feprx(ru,proc->tti_rx); + + if (proc->tti_rx == NR_UPLINK_SLOT || fp->frame_type == FDD) { + + if (ru->feprx) ru->feprx(ru,proc->tti_rx); + + } + + LOG_D(PHY,"RU proc: frame_rx = %d, tti_rx = %d\n", proc->frame_rx, proc->tti_rx); + LOG_D(PHY,"Copying rxdataF from RU to gNB\n"); + + for (aa=0;aanb_rx;aa++) + memcpy((void*)RC.gNB[0][0]->common_vars.rxdataF[aa], + (void*)ru->common.rxdataF[aa], fp->symbols_per_slot*fp->ofdm_symbol_size*sizeof(int32_t)); // At this point, all information for subframe has been received on FH interface @@ -1612,14 +1641,6 @@ int stop_rf(RU_t *ru) { return 0; } -extern void fep_full(RU_t *ru,int slot); -extern void ru_fep_full_2thread(RU_t *ru,int slot); -extern void nr_feptx_ofdm(RU_t *ru,int frame_tx,int tti_tx); -extern void nr_feptx_ofdm_2thread(RU_t *ru,int frame_tx,int tti_tx); -extern void feptx_prec(RU_t *ru, int frame_tx,int tti_tx); -extern void init_fep_thread(RU_t *ru); -extern void nr_init_feptx_thread(RU_t *ru); - void init_RU_proc(RU_t *ru) { int i=0; RU_proc_t *proc; @@ -1631,7 +1652,7 @@ void init_RU_proc(RU_t *ru) { memset((void *)proc,0,sizeof(RU_proc_t)); proc->ru = ru; proc->instance_cnt_prach = -1; - proc->instance_cnt_synch = -1; ; + proc->instance_cnt_synch = -1; proc->instance_cnt_FH = -1; proc->instance_cnt_FH1 = -1; proc->instance_cnt_gNBs = -1; @@ -1684,7 +1705,7 @@ void init_RU_proc(RU_t *ru) { } if (get_thread_worker_conf() == WORKER_ENABLE) { - if (ru->feprx) init_fep_thread(ru); + if (ru->feprx) nr_init_feprx_thread(ru); if (ru->feptx_ofdm) nr_init_feptx_thread(ru); } @@ -1844,8 +1865,8 @@ void configure_ru(int idx, if (capabilities->FH_fmt < MAX_FH_FMTs) LOG_I(PHY, "RU FH options %s\n",rru_format_options[capabilities->FH_fmt]); - AssertFatal((ret=check_capabilities(ru,capabilities)) == 0, - "Cannot configure RRU %d, check_capabilities returned %d\n", idx,ret); + ret = check_capabilities(ru,capabilities); + AssertFatal(ret == 0, "Cannot configure RRU %d, check_capabilities returned %d\n", idx, ret); // take antenna capabilities of RRU ru->nb_tx = capabilities->nb_tx[0]; ru->nb_rx = capabilities->nb_rx[0]; @@ -1977,8 +1998,8 @@ void set_function_spec_param(RU_t *ru) { ru->fh_north_out = fh_if4p5_north_out; // send_IF4p5 on reception ru->fh_south_out = tx_rf; // send output to RF ru->fh_north_asynch_in = fh_if4p5_north_asynch_in; // TX packets come asynchronously - ru->feprx = (get_thread_worker_conf() == WORKER_ENABLE) ? ru_fep_full_2thread : fep_full; // RX DFTs - ru->feptx_ofdm = (get_thread_worker_conf() == WORKER_ENABLE) ? nr_feptx_ofdm_2thread : nr_feptx_ofdm; // this is fep with idft only (no precoding in RRU) + ru->feprx = (get_thread_worker_conf() == WORKER_ENABLE) ? nr_fep_full_2thread : nr_fep_full; // RX DFTs + ru->feptx_ofdm = (get_thread_worker_conf() == WORKER_ENABLE) ? nr_feptx_ofdm_2thread : nr_feptx_ofdm; // this is fep with idft only (no precoding in RRU) ru->feptx_prec = NULL; ru->nr_start_if = nr_start_if; // need to start the if interface for if4p5 ru->ifdevice.host_type = RRU_HOST; @@ -1999,8 +2020,8 @@ void set_function_spec_param(RU_t *ru) { malloc_IF4p5_buffer(ru); } else if (ru->function == gNodeB_3GPP) { ru->do_prach = 0; // no prach processing in RU - ru->feprx = (get_thread_worker_conf() == WORKER_ENABLE) ? ru_fep_full_2thread : fep_full; // RX DFTs - ru->feptx_ofdm = (get_thread_worker_conf() == WORKER_ENABLE) ? nr_feptx_ofdm_2thread : nr_feptx_ofdm; // this is fep with idft and precoding + ru->feprx = (get_thread_worker_conf() == WORKER_ENABLE) ? nr_fep_full_2thread : nr_fep_full; // RX DFTs + ru->feptx_ofdm = (get_thread_worker_conf() == WORKER_ENABLE) ? nr_feptx_ofdm_2thread : nr_feptx_ofdm; // this is fep with idft and precoding ru->feptx_prec = NULL; // this is fep with idft and precoding ru->fh_north_in = NULL; // no incoming fronthaul from north ru->fh_north_out = NULL; // no outgoing fronthaul to north @@ -2029,13 +2050,13 @@ void set_function_spec_param(RU_t *ru) { case REMOTE_IF5: // the remote unit is IF5 RRU ru->do_prach = 0; - ru->feprx = fep_full; // this is frequency-shift + DFTs - ru->feptx_prec = feptx_prec; // need to do transmit Precoding + IDFTs - ru->feptx_ofdm = (get_thread_worker_conf() == WORKER_ENABLE) ? nr_feptx_ofdm_2thread : nr_feptx_ofdm; // need to do transmit Precoding + IDFTs - ru->fh_south_in = fh_if5_south_in; // synchronous IF5 reception - ru->fh_south_out = fh_if5_south_out; // synchronous IF5 transmission - ru->fh_south_asynch_in = NULL; // no asynchronous UL - ru->start_rf = NULL; // no local RF + ru->feprx = (get_thread_worker_conf() == WORKER_ENABLE) ? nr_fep_full_2thread : nr_fep_full; // this is frequency-shift + DFTs + ru->feptx_prec = feptx_prec; // need to do transmit Precoding + IDFTs + ru->feptx_ofdm = (get_thread_worker_conf() == WORKER_ENABLE) ? nr_feptx_ofdm_2thread : nr_feptx_ofdm; // need to do transmit Precoding + IDFTs + ru->fh_south_in = fh_if5_south_in; // synchronous IF5 reception + ru->fh_south_out = fh_if5_south_out; // synchronous IF5 transmission + ru->fh_south_asynch_in = NULL; // no asynchronous UL + ru->start_rf = NULL; // no local RF ru->stop_rf = NULL; ru->nr_start_if = nr_start_if; // need to start if interface for IF5 ru->ifdevice.host_type = RAU_HOST; @@ -2090,6 +2111,7 @@ void init_NR_RU(char *rf_config_file) { int ru_id; RU_t *ru; + PHY_VARS_gNB *gNB_RC; PHY_VARS_gNB *gNB0= (PHY_VARS_gNB *)NULL; NR_DL_FRAME_PARMS *fp = (NR_DL_FRAME_PARMS *)NULL; int i; @@ -2129,6 +2151,7 @@ void init_NR_RU(char *rf_config_file) } } + gNB_RC = RC.gNB[0][0]; gNB0 = ru->gNB_list[0]; fp = ru->nr_frame_parms; LOG_D(PHY, "RU FUnction:%d ru->if_south:%d\n", ru->function, ru->if_south); @@ -2137,10 +2160,11 @@ void init_NR_RU(char *rf_config_file) if ((ru->function != NGFI_RRU_IF5) && (ru->function != NGFI_RRU_IF4p5)) AssertFatal(gNB0!=NULL,"gNB0 is null!\n"); - if (gNB0) { - LOG_I(PHY,"Copying frame parms from gNB %d to ru %d\n",gNB0->Mod_id,ru->idx); - memcpy((void *)fp,(void *)&gNB0->frame_parms,sizeof(NR_DL_FRAME_PARMS)); - memset((void *)ru->frame_parms, 0, sizeof(LTE_DL_FRAME_PARMS)); + if (gNB0 && gNB_RC) { + LOG_I(PHY,"Copying frame parms from gNB in RC to gNB %d in ru %d and frame_parms in ru\n",gNB0->Mod_id,ru->idx); + memset((void *)fp, 0, sizeof(NR_DL_FRAME_PARMS)); + memcpy((void *)fp,&gNB_RC->frame_parms,sizeof(NR_DL_FRAME_PARMS)); + memcpy((void *)&gNB0->frame_parms,(void *)&gNB_RC->frame_parms,sizeof(NR_DL_FRAME_PARMS)); // attach all RU to all gNBs in its list/ LOG_D(PHY,"ru->num_gNB:%d gNB0->num_RU:%d\n", ru->num_gNB, gNB0->num_RU); diff --git a/executables/nr-softmodem-common.h b/executables/nr-softmodem-common.h index 0fec975e6f..a288dbebde 100644 --- a/executables/nr-softmodem-common.h +++ b/executables/nr-softmodem-common.h @@ -1,7 +1,7 @@ #ifndef NR_SOFTMODEM_COMMON_H #define NR_SOFTMODEM_COMMON_H -#ifndef _GNU_SOURCE +#ifndef _GNU_SOURCE #define _GNU_SOURCE #endif @@ -98,6 +98,8 @@ #define CONFIG_HLP_TELN "Start embedded telnet server \n" #define CONFIG_HLP_MSC "Enable the MSC tracing utility \n" #define CONFIG_HLP_SNR "Set average SNR in dB (for --siml1 option)\n" +#define CONFIG_HLP_NOS1 "Disable s1 interface\n" +#define CONFIG_HLP_NOKRNMOD "(noS1 only): Use tun instead of namesh module \n" /*--------------------------------------------------------------------------------------------------------------------------------*/ /* command line parameters for LOG utility */ /* optname helpstr paramflags XXXptr defXXXval type numelt */ diff --git a/executables/nr-softmodem.c b/executables/nr-softmodem.c index cd7c623d6b..f121df3337 100644 --- a/executables/nr-softmodem.c +++ b/executables/nr-softmodem.c @@ -83,6 +83,8 @@ unsigned short config_frames[4] = {2,9,11,13}; #include "PHY/TOOLS/nr_phy_scope.h" #include "stats.h" #include "nr-softmodem.h" +#include "executables/softmodem-common.h" +#include "executables/thread-common.h" #include "NB_IoT_interface.h" short nr_mod_table[NR_MOD_TABLE_SIZE_SHORT] = {0,0,16384,16384,-16384,-16384,16384,16384,16384,-16384,-16384,16384,-16384,-16384,7327,7327,7327,21981,21981,7327,21981,21981,7327,-7327,7327,-21981,21981,-7327,21981,-21981,-7327,7327,-7327,21981,-21981,7327,-21981,21981,-7327,-7327,-7327,-21981,-21981,-7327,-21981,-21981,10726,10726,10726,3576,3576,10726,3576,3576,10726,17876,10726,25027,3576,17876,3576,25027,17876,10726,17876,3576,25027,10726,25027,3576,17876,17876,17876,25027,25027,17876,25027,25027,10726,-10726,10726,-3576,3576,-10726,3576,-3576,10726,-17876,10726,-25027,3576,-17876,3576,-25027,17876,-10726,17876,-3576,25027,-10726,25027,-3576,17876,-17876,17876,-25027,25027,-17876,25027,-25027,-10726,10726,-10726,3576,-3576,10726,-3576,3576,-10726,17876,-10726,25027,-3576,17876,-3576,25027,-17876,10726,-17876,3576,-25027,10726,-25027,3576,-17876,17876,-17876,25027,-25027,17876,-25027,25027,-10726,-10726,-10726,-3576,-3576,-10726,-3576,-3576,-10726,-17876,-10726,-25027,-3576,-17876,-3576,-25027,-17876,-10726,-17876,-3576,-25027,-10726,-25027,-3576,-17876,-17876,-17876,-25027,-25027,-17876,-25027,-25027,8886,8886,8886,12439,12439,8886,12439,12439,8886,5332,8886,1778,12439,5332,12439,1778,5332,8886,5332,12439,1778,8886,1778,12439,5332,5332,5332,1778,1778,5332,1778,1778,8886,19547,8886,15993,12439,19547,12439,15993,8886,23101,8886,26655,12439,23101,12439,26655,5332,19547,5332,15993,1778,19547,1778,15993,5332,23101,5332,26655,1778,23101,1778,26655,19547,8886,19547,12439,15993,8886,15993,12439,19547,5332,19547,1778,15993,5332,15993,1778,23101,8886,23101,12439,26655,8886,26655,12439,23101,5332,23101,1778,26655,5332,26655,1778,19547,19547,19547,15993,15993,19547,15993,15993,19547,23101,19547,26655,15993,23101,15993,26655,23101,19547,23101,15993,26655,19547,26655,15993,23101,23101,23101,26655,26655,23101,26655,26655,8886,-8886,8886,-12439,12439,-8886,12439,-12439,8886,-5332,8886,-1778,12439,-5332,12439,-1778,5332,-8886,5332,-12439,1778,-8886,1778,-12439,5332,-5332,5332,-1778,1778,-5332,1778,-1778,8886,-19547,8886,-15993,12439,-19547,12439,-15993,8886,-23101,8886,-26655,12439,-23101,12439,-26655,5332,-19547,5332,-15993,1778,-19547,1778,-15993,5332,-23101,5332,-26655,1778,-23101,1778,-26655,19547,-8886,19547,-12439,15993,-8886,15993,-12439,19547,-5332,19547,-1778,15993,-5332,15993,-1778,23101,-8886,23101,-12439,26655,-8886,26655,-12439,23101,-5332,23101,-1778,26655,-5332,26655,-1778,19547,-19547,19547,-15993,15993,-19547,15993,-15993,19547,-23101,19547,-26655,15993,-23101,15993,-26655,23101,-19547,23101,-15993,26655,-19547,26655,-15993,23101,-23101,23101,-26655,26655,-23101,26655,-26655,-8886,8886,-8886,12439,-12439,8886,-12439,12439,-8886,5332,-8886,1778,-12439,5332,-12439,1778,-5332,8886,-5332,12439,-1778,8886,-1778,12439,-5332,5332,-5332,1778,-1778,5332,-1778,1778,-8886,19547,-8886,15993,-12439,19547,-12439,15993,-8886,23101,-8886,26655,-12439,23101,-12439,26655,-5332,19547,-5332,15993,-1778,19547,-1778,15993,-5332,23101,-5332,26655,-1778,23101,-1778,26655,-19547,8886,-19547,12439,-15993,8886,-15993,12439,-19547,5332,-19547,1778,-15993,5332,-15993,1778,-23101,8886,-23101,12439,-26655,8886,-26655,12439,-23101,5332,-23101,1778,-26655,5332,-26655,1778,-19547,19547,-19547,15993,-15993,19547,-15993,15993,-19547,23101,-19547,26655,-15993,23101,-15993,26655,-23101,19547,-23101,15993,-26655,19547,-26655,15993,-23101,23101,-23101,26655,-26655,23101,-26655,26655,-8886,-8886,-8886,-12439,-12439,-8886,-12439,-12439,-8886,-5332,-8886,-1778,-12439,-5332,-12439,-1778,-5332,-8886,-5332,-12439,-1778,-8886,-1778,-12439,-5332,-5332,-5332,-1778,-1778,-5332,-1778,-1778,-8886,-19547,-8886,-15993,-12439,-19547,-12439,-15993,-8886,-23101,-8886,-26655,-12439,-23101,-12439,-26655,-5332,-19547,-5332,-15993,-1778,-19547,-1778,-15993,-5332,-23101,-5332,-26655,-1778,-23101,-1778,-26655,-19547,-8886,-19547,-12439,-15993,-8886,-15993,-12439,-19547,-5332,-19547,-1778,-15993,-5332,-15993,-1778,-23101,-8886,-23101,-12439,-26655,-8886,-26655,-12439,-23101,-5332,-23101,-1778,-26655,-5332,-26655,-1778,-19547,-19547,-19547,-15993,-15993,-19547,-15993,-15993,-19547,-23101,-19547,-26655,-15993,-23101,-15993,-26655,-23101,-19547,-23101,-15993,-26655,-19547,-26655,-15993,-23101,-23101,-23101,-26655,-26655,-23101,-26655,-26655}; @@ -167,7 +169,7 @@ int rx_input_level_dBm; uint32_t do_forms=0; int otg_enabled; -//int number_of_cards = 1; +//int number_of_cards = 1; //static NR_DL_FRAME_PARMS *frame_parms[MAX_NUM_CCs]; @@ -188,46 +190,10 @@ int transmission_mode=1; int emulate_rf = 0; int numerology = 0; -typedef struct { - uint64_t optmask; - THREAD_STRUCT thread_struct; - char rf_config_file[1024]; - int phy_test; - uint8_t usim_test; - int emulate_rf; - int wait_for_sync; //eNodeB only - int single_thread_flag; //eNodeB only - int chain_offset; - int numerology; - unsigned int start_msc; - uint32_t clock_source; - int hw_timing_advance; -} softmodem_params_t; static softmodem_params_t softmodem_params; static char *parallel_config = NULL; static char *worker_config = NULL; -static THREAD_STRUCT thread_struct; - -void set_parallel_conf(char *parallel_conf) { - if(strcmp(parallel_conf,"PARALLEL_SINGLE_THREAD")==0) thread_struct.parallel_conf = PARALLEL_SINGLE_THREAD; - else if(strcmp(parallel_conf,"PARALLEL_RU_L1_SPLIT")==0) thread_struct.parallel_conf = PARALLEL_RU_L1_SPLIT; - else if(strcmp(parallel_conf,"PARALLEL_RU_L1_TRX_SPLIT")==0) thread_struct.parallel_conf = PARALLEL_RU_L1_TRX_SPLIT; - - printf("[CONFIG] parallel conf is set to %d\n",thread_struct.parallel_conf); -} -void set_worker_conf(char *worker_conf) { - if(strcmp(worker_conf,"WORKER_DISABLE")==0) thread_struct.worker_conf = WORKER_DISABLE; - else if(strcmp(worker_conf,"WORKER_ENABLE")==0) thread_struct.worker_conf = WORKER_ENABLE; - - printf("[CONFIG] worker conf is set to %d\n",thread_struct.worker_conf); -} -PARALLEL_CONF_t get_thread_parallel_conf(void) { - return thread_struct.parallel_conf; -} -WORKER_CONF_t get_thread_worker_conf(void) { - return thread_struct.worker_conf; -} /* struct for ethernet specific parameters given in eNB conf file */ eth_params_t *eth_params; @@ -507,7 +473,9 @@ static void get_options(void) { int tddflag, nonbiotflag; uint32_t online_log_messages; uint32_t glog_level, glog_verbosity; - uint32_t start_telnetsrv; + uint32_t start_telnetsrv = 0; + uint32_t noS1; + uint32_t nokrnmod; paramdef_t cmdline_params[] = CMDLINE_PARAMS_DESC_GNB ; paramdef_t cmdline_logparams[] = CMDLINE_LOGPARAMS_DESC_NR ; config_process_cmdline( cmdline_params,sizeof(cmdline_params)/sizeof(paramdef_t),NULL); @@ -545,6 +513,7 @@ static void get_options(void) { if(parallel_config != NULL) set_parallel_conf(parallel_config); if(worker_config != NULL) set_worker_conf(worker_config); + } @@ -860,6 +829,30 @@ static void wait_nfapi_init(char *thread_name) { printf( "NFAPI: got sync (%s)\n", thread_name); } +void init_pdcp(void) { + //if (!NODE_IS_DU(RC.rrc[0]->node_type)) { + pdcp_layer_init(); + uint32_t pdcp_initmask = (IS_SOFTMODEM_NOS1) ? + (PDCP_USE_NETLINK_BIT | LINK_ENB_PDCP_TO_IP_DRIVER_BIT) : LINK_ENB_PDCP_TO_GTPV1U_BIT; + + if (IS_SOFTMODEM_NOS1){ + printf("IS_SOFTMODEM_NOS1 option enabled \n"); + pdcp_initmask = pdcp_initmask | ENB_NAS_USE_TUN_BIT | SOFTMODEM_NOKRNMOD_BIT ; + } + + pdcp_module_init(pdcp_initmask); + + /*if (NODE_IS_CU(RC.rrc[0]->node_type)) { + pdcp_set_rlc_data_req_func((send_rlc_data_req_func_t)proto_agent_send_rlc_data_req); + } else {*/ + pdcp_set_rlc_data_req_func((send_rlc_data_req_func_t) rlc_data_req); + pdcp_set_pdcp_data_ind_func((pdcp_data_ind_func_t) pdcp_data_ind); + //} + /*} else { + pdcp_set_pdcp_data_ind_func((pdcp_data_ind_func_t) proto_agent_send_pdcp_data_ind); + }*/ +} + int main( int argc, char **argv ) { int i, ru_id, CC_id = 0; @@ -881,6 +874,7 @@ int main( int argc, char **argv ) configure_linux(); printf("Reading in command-line options\n"); get_options (); + get_common_options(); if (CONFIG_ISFLAGSET(CONFIG_ABORT) ) { fprintf(stderr,"Getting configuration failed\n"); @@ -945,6 +939,10 @@ init_opt(); flexran_agent_start(i); } */ + + if(IS_SOFTMODEM_NOS1) + init_pdcp(); + // init UE_PF_PO and mutex lock pthread_mutex_init(&ue_pf_po_mutex, NULL); memset (&UE_PF_PO[0][0], 0, sizeof(UE_PF_PO_t)*NUMBER_OF_UE_MAX*MAX_NUM_CCs); diff --git a/executables/nr-softmodem.h b/executables/nr-softmodem.h index 50e0c5469f..57d7377134 100644 --- a/executables/nr-softmodem.h +++ b/executables/nr-softmodem.h @@ -5,18 +5,18 @@ #include "flexran_agent.h" #include "PHY/defs_gNB.h" +#include "proto_agent.h" #define DEFAULT_DLF 2680000000 - /***************************************************************************************************************************************/ /* command line options definitions, CMDLINE_XXXX_DESC macros are used to initialize paramdef_t arrays which are then used as argument when calling config_get or config_getlist functions */ -/*---------------------------------------------------------------------------------------------------------------------------------------------------------------------------*/ -/* command line parameters common to eNodeB and UE */ -/* optname helpstr paramflags XXXptr defXXXval type numelt */ -/*---------------------------------------------------------------------------------------------------------------------------------------------------------------------------*/ +/*----------------------------------------------------------------------------------------------------------------------------------------------------------------------*/ +/* command line parameters common to eNodeB and UE */ +/* optname helpstr paramflags XXXptr defXXXval type numelt */ +/*----------------------------------------------------------------------------------------------------------------------------------------------------------------------*/ #define CMDLINE_PARAMS_DESC_GNB { \ {"rf-config-file", CONFIG_HLP_RFCFGF, 0, strptr:(char **)&rf_config_file, defstrval:NULL, TYPE_STRING, sizeof(rf_config_file)},\ {"ulsch-max-errors", CONFIG_HLP_ULMAXE, 0, uptr:&ULSCH_max_consecutive_errors, defuintval:0, TYPE_UINT, 0}, \ @@ -42,14 +42,19 @@ {"parallel-config", CONFIG_HLP_PARALLEL_CMD,0, strptr:(char **)¶llel_config, defstrval:NULL, TYPE_STRING, 0}, \ {"worker-config", CONFIG_HLP_WORKER_CMD, 0, strptr:(char **)&worker_config, defstrval:NULL, TYPE_STRING, 0}, \ {"s" , CONFIG_HLP_SNR, 0, dblptr:&snr_dB, defdblval:25, TYPE_DOUBLE, 0}, \ - {"nbiot-disable", CONFIG_HLP_DISABLNBIOT, PARAMFLAG_BOOL, iptr:&nonbiotflag, defintval:0, TYPE_INT, 0} \ + {"nbiot-disable", CONFIG_HLP_DISABLNBIOT, PARAMFLAG_BOOL, iptr:&nonbiotflag, defintval:0, TYPE_INT, 0}, \ + {"noS1", CONFIG_HLP_NOS1, PARAMFLAG_BOOL, uptr:&noS1, defintval:0, TYPE_INT, 0}, \ + {"nokrnmod", CONFIG_HLP_NOKRNMOD, PARAMFLAG_BOOL, uptr:&nokrnmod, defintval:0, TYPE_INT, 0} \ } +#define SOFTMODEM_NOS1_BIT (1<<0) +#define SOFTMODEM_NOKRNMOD_BIT (1<<1) -typedef struct { - int *argc; - char **argv; -} scopeParms_t; +#define IS_SOFTMODEM_NOS1 ( get_softmodem_optmask() & SOFTMODEM_NOS1_BIT) +#define IS_SOFTMODEM_NOKRNMOD ( get_softmodem_optmask() & SOFTMODEM_NOKRNMOD_BIT) + +extern uint64_t get_softmodem_optmask(void); +extern void get_common_options(void); extern int T_port; extern int T_nowait; diff --git a/executables/nr-ue.c b/executables/nr-ue.c index f2115fc6ea..c52fc5138e 100644 --- a/executables/nr-ue.c +++ b/executables/nr-ue.c @@ -45,6 +45,7 @@ #include "common/utils/LOG/log.h" #include "common/utils/system.h" #include "common/utils/LOG/vcd_signal_dumper.h" +#include "executables/nr-softmodem.h" #include "T.h" @@ -141,8 +142,10 @@ PHY_VARS_NR_UE *init_nr_ue_vars(NR_DL_FRAME_PARMS *frame_parms, ue = (PHY_VARS_NR_UE *)malloc(sizeof(PHY_VARS_NR_UE)); memset(ue,0,sizeof(PHY_VARS_NR_UE)); memcpy(&(ue->frame_parms), frame_parms, sizeof(NR_DL_FRAME_PARMS)); + ue->Mod_id = UE_id; ue->mac_enabled = 1; + // initialize all signal buffers init_nr_ue_signal(ue,1,abstraction_flag); // intialize transport @@ -353,6 +356,9 @@ void processSlotRX( PHY_VARS_NR_UE *UE, UE_nr_rxtx_proc_t *proc) { nr_dcireq_t dcireq; nr_scheduled_response_t scheduled_response; + uint32_t nb_rb, start_rb; + uint8_t nb_symb_sch, start_symbol, mcs, precod_nbr_layers, harq_pid, rvidx; + uint16_t n_rnti; // Process Rx data for one sub-frame if (nr_slot_select(&UE->frame_parms, proc->frame_tx, proc->nr_tti_tx) & NR_DOWNLINK_SLOT) { @@ -365,12 +371,38 @@ void processSlotRX( PHY_VARS_NR_UE *UE, UE_nr_rxtx_proc_t *proc) { nr_ue_dcireq(&dcireq); //to be replaced with function pointer later scheduled_response.dl_config = &dcireq.dl_config_req; - scheduled_response.ul_config = NULL; + scheduled_response.ul_config = &dcireq.ul_config_req; scheduled_response.tx_request = NULL; scheduled_response.module_id = UE->Mod_id; scheduled_response.CC_id = 0; scheduled_response.frame = proc->frame_rx; scheduled_response.slot = proc->nr_tti_rx; + + //--------------------------Temporary configuration-----------------------------// + n_rnti = 0x1234; + nb_rb = 50; + start_rb = 0; + nb_symb_sch = 12; + start_symbol = 2; + precod_nbr_layers = 1; + mcs = 9; + harq_pid = 0; + rvidx = 0; + //------------------------------------------------------------------------------// + + scheduled_response.ul_config->sfn_slot = NR_UPLINK_SLOT; + scheduled_response.ul_config->number_pdus = 1; + scheduled_response.ul_config->ul_config_list[0].pdu_type = FAPI_NR_UL_CONFIG_TYPE_PUSCH; + scheduled_response.ul_config->ul_config_list[0].ulsch_config_pdu.rnti = n_rnti; + scheduled_response.ul_config->ul_config_list[0].ulsch_config_pdu.ulsch_pdu_rel15.number_rbs = nb_rb; + scheduled_response.ul_config->ul_config_list[0].ulsch_config_pdu.ulsch_pdu_rel15.start_rb = start_rb; + scheduled_response.ul_config->ul_config_list[0].ulsch_config_pdu.ulsch_pdu_rel15.number_symbols = nb_symb_sch; + scheduled_response.ul_config->ul_config_list[0].ulsch_config_pdu.ulsch_pdu_rel15.start_symbol = start_symbol; + scheduled_response.ul_config->ul_config_list[0].ulsch_config_pdu.ulsch_pdu_rel15.mcs = mcs; + scheduled_response.ul_config->ul_config_list[0].ulsch_config_pdu.ulsch_pdu_rel15.ndi = 0; + scheduled_response.ul_config->ul_config_list[0].ulsch_config_pdu.ulsch_pdu_rel15.rv = rvidx; + scheduled_response.ul_config->ul_config_list[0].ulsch_config_pdu.ulsch_pdu_rel15.n_layers = precod_nbr_layers; + scheduled_response.ul_config->ul_config_list[0].ulsch_config_pdu.ulsch_pdu_rel15.harq_process_nbr = harq_pid; nr_ue_scheduled_response(&scheduled_response); #ifdef UE_SLOT_PARALLELISATION @@ -381,6 +413,15 @@ void processSlotRX( PHY_VARS_NR_UE *UE, UE_nr_rxtx_proc_t *proc) { LOG_D(PHY,"phy_procedures_nrUE_RX: slot:%d, time %lu\n", proc->nr_tti_rx, (rdtsc()-a)/3500); //printf(">>> nr_ue_pdcch_procedures ended\n"); #endif + if(IS_SOFTMODEM_NOS1){ //&& proc->nr_tti_rx==1 + //Hardcoded rnti value + protocol_ctxt_t ctxt; + PROTOCOL_CTXT_SET_BY_MODULE_ID(&ctxt, UE->Mod_id, ENB_FLAG_NO, + 0x1234, proc->frame_rx, + proc->nr_tti_rx, 0); + //pdcp_run(&ctxt); + pdcp_fifo_flush_sdus(&ctxt); + } } @@ -415,13 +456,14 @@ typedef struct processingData_s { } processingData_t; void UE_processing(void *arg) { + uint8_t thread_id; processingData_t *rxtxD=(processingData_t *) arg; UE_nr_rxtx_proc_t *proc = &rxtxD->proc; PHY_VARS_NR_UE *UE = rxtxD->UE; processSlotRX(UE, proc); //printf(">>> mac ended\n"); // Prepare the future Tx data -#if 0 +/* #ifndef NO_RAT_NR if (slot_select_nr(&UE->frame_parms, proc->frame_tx, proc->nr_tti_tx) & NR_UPLINK_SLOT) @@ -429,11 +471,21 @@ void UE_processing(void *arg) { if ((subframe_select( &UE->frame_parms, proc->subframe_tx) == SF_UL) || (UE->frame_parms.frame_type == FDD) ) #endif +*/ + + + if (proc->nr_tti_tx == NR_UPLINK_SLOT || UE->frame_parms.frame_type == FDD){ + + thread_id = PHY_vars_UE_g[UE->Mod_id][0]->current_thread_id[proc->nr_tti_tx]; + + if (UE->mode != loop_through_memory) - phy_procedures_nrUE_TX(UE,proc,0,0,UE->mode,no_relay); + phy_procedures_nrUE_TX(UE,proc,0,thread_id); + + } //phy_procedures_UE_TX(UE,proc,0,0,UE->mode,no_relay); -#endif + #if 0 if ((subframe_select( &UE->frame_parms, proc->subframe_tx) == SF_S) && @@ -643,12 +695,12 @@ void *UE_thread(void *arg) { //LOG_I(PHY,"Process slot %d thread Idx %d total gain %d\n", slot_nr, thread_idx, UE->rx_total_gain_dB); #ifdef OAI_ADRV9371_ZC706 - uint32_t total_gain_dB_prev = 0; + /*uint32_t total_gain_dB_prev = 0; if (total_gain_dB_prev != UE->rx_total_gain_dB) { total_gain_dB_prev = UE->rx_total_gain_dB; - openair0_cfg[0].rx_gain[0] = UE->rx_total_gain_dB-20; + openair0_cfg[0].rx_gain[0] = UE->rx_total_gain_dB; UE->rfdevice.trx_set_gains_func(&UE->rfdevice,&openair0_cfg[0]); - } + }*/ #endif for (int i=0; iframe_parms.nb_antennas_rx; i++) @@ -657,7 +709,7 @@ void *UE_thread(void *arg) { slot_nr*UE->frame_parms.samples_per_slot]; for (int i=0; iframe_parms.nb_antennas_tx; i++) - txp[i] = (void *)&UE->common_vars.txdata[i][curMsg->proc.nr_tti_tx*UE->frame_parms.samples_per_slot]; + txp[i] = (void *)&UE->common_vars.txdata[i][((curMsg->proc.nr_tti_rx + DURATION_RX_TO_TX)%nb_slot_frame)*UE->frame_parms.samples_per_slot]; int readBlockSize, writeBlockSize; @@ -680,16 +732,18 @@ void *UE_thread(void *arg) { rxp, readBlockSize, UE->frame_parms.nb_antennas_rx),""); + +if (slot_nr==18) AssertFatal( writeBlockSize == UE->rfdevice.trx_write_func(&UE->rfdevice, timestamp+ - (2*UE->frame_parms.samples_per_slot) - + (DURATION_RX_TO_TX*UE->frame_parms.samples_per_slot) - UE->frame_parms.ofdm_symbol_size-UE->frame_parms.nb_prefix_samples0 - openair0_cfg[0].tx_sample_advance, txp, writeBlockSize, UE->frame_parms.nb_antennas_tx, - 1),""); + 4),""); if( slot_nr==(nb_slot_frame-1)) { // read in first symbol of next frame and adjust for timing drift @@ -734,7 +788,7 @@ void *UE_thread(void *arg) { msgToPush->key=slot_nr; pushTpool(Tpool, msgToPush); - if (getenv("RFSIMULATOR")) { + if (getenv("RFSIMULATOR") || IS_SOFTMODEM_NOS1) { //getenv("RFSIMULATOR") // FixMe: Wait previous thread is done, because race conditions seems too bad // in case of actual RF board, the overlap between threads mitigate the issue // We must receive one message, that proves the slot processing is done diff --git a/executables/nr-uesoftmodem.c b/executables/nr-uesoftmodem.c index 9a4a0cdf70..7881783651 100644 --- a/executables/nr-uesoftmodem.c +++ b/executables/nr-uesoftmodem.c @@ -29,6 +29,7 @@ #include "PHY/defs_nr_UE.h" #include "common/ran_context.h" #include "common/config/config_userapi.h" +//#include "common/utils/threadPool/thread-pool.h" #include "common/utils/load_module_shlib.h" //#undef FRAME_LENGTH_COMPLEX_SAMPLES //there are two conflicting definitions, so we better make sure we don't use it at all @@ -77,9 +78,11 @@ unsigned short config_frames[4] = {2,9,11,13}; #include + /* Callbacks, globals and object handlers */ extern void reset_stats( FL_OBJECT *, long ); +//extern void initTpool(char *params,tpool_t *pool, bool performanceMeas); /* Forms and Objects */ @@ -102,9 +105,11 @@ FD_phy_scope_nrue *form_nrue[NUMBER_OF_UE_MAX]; //FD_lte_phy_scope_enb *form_enb[MAX_NUM_CCs][NUMBER_OF_UE_MAX]; //FD_stats_form *form_stats=NULL,*form_stats_l2=NULL; char title[255]; -static pthread_t forms_thread; //xforms +static pthread_t forms_thread; //xforms #include +#include "executables/softmodem-common.h" +#include "executables/thread-common.h" RAN_CONTEXT_t RC; volatile int start_eNB = 0; @@ -147,7 +152,7 @@ double bw = 10.0e6; static int tx_max_power[MAX_NUM_CCs] = {0}; -char rf_config_file[1024]; +char rf_config_file[1024]; int chain_offset=0; int phy_test = 0; @@ -162,53 +167,18 @@ uint8_t nb_antenna_rx = 1; char ref[128] = "internal"; char channels[128] = "0"; -typedef struct { - uint64_t optmask; - THREAD_STRUCT thread_struct; - char rf_config_file[1024]; - int phy_test; - uint8_t usim_test; - int emulate_rf; - int wait_for_sync; //eNodeB only - int single_thread_flag; //eNodeB only - int chain_offset; - int numerology; - unsigned int start_msc; - uint32_t clock_source; - int hw_timing_advance; -} softmodem_params_t; static softmodem_params_t softmodem_params; static char *parallel_config = NULL; static char *worker_config = NULL; -static THREAD_STRUCT thread_struct; -void set_parallel_conf(char *parallel_conf) { - if(strcmp(parallel_conf,"PARALLEL_SINGLE_THREAD")==0) thread_struct.parallel_conf = PARALLEL_SINGLE_THREAD; - else if(strcmp(parallel_conf,"PARALLEL_RU_L1_SPLIT")==0) thread_struct.parallel_conf = PARALLEL_RU_L1_SPLIT; - else if(strcmp(parallel_conf,"PARALLEL_RU_L1_TRX_SPLIT")==0) thread_struct.parallel_conf = PARALLEL_RU_L1_TRX_SPLIT; - - printf("[CONFIG] parallel conf is set to %d\n",thread_struct.parallel_conf); -} -void set_worker_conf(char *worker_conf) { - if(strcmp(worker_conf,"WORKER_DISABLE")==0) thread_struct.worker_conf = WORKER_DISABLE; - else if(strcmp(worker_conf,"WORKER_ENABLE")==0) thread_struct.worker_conf = WORKER_ENABLE; - - printf("[CONFIG] worker conf is set to %d\n",thread_struct.worker_conf); -} -PARALLEL_CONF_t get_thread_parallel_conf(void) { - return thread_struct.parallel_conf; -} -WORKER_CONF_t get_thread_worker_conf(void) { - return thread_struct.worker_conf; -} int rx_input_level_dBm; //static int online_log_messages=0; uint32_t do_forms=0; int otg_enabled; -//int number_of_cards = 1; +//int number_of_cards = 1; static NR_DL_FRAME_PARMS *frame_parms[MAX_NUM_CCs]; int16_t node_synch_ref[MAX_NUM_CCs]; @@ -404,6 +374,8 @@ static void get_options(void) { uint32_t online_log_messages; uint32_t glog_level, glog_verbosity; uint32_t start_telnetsrv=0; + //uint32_t noS1; + //uint32_t nokrnmod; paramdef_t cmdline_params[] =CMDLINE_PARAMS_DESC_UE ; paramdef_t cmdline_logparams[] =CMDLINE_LOGPARAMS_DESC_NR ; config_process_cmdline( cmdline_params,sizeof(cmdline_params)/sizeof(paramdef_t),NULL); @@ -659,6 +631,27 @@ void init_openair0(void) { } } +void init_pdcp(void) { + uint32_t pdcp_initmask = (!IS_SOFTMODEM_NOS1) ? LINK_ENB_PDCP_TO_GTPV1U_BIT : (LINK_ENB_PDCP_TO_GTPV1U_BIT | PDCP_USE_NETLINK_BIT | LINK_ENB_PDCP_TO_IP_DRIVER_BIT); + + /*if (IS_SOFTMODEM_BASICSIM || IS_SOFTMODEM_RFSIM || (nfapi_getmode()==NFAPI_UE_STUB_PNF)) { + pdcp_initmask = pdcp_initmask | UE_NAS_USE_TUN_BIT; + }*/ + + if (IS_SOFTMODEM_NOKRNMOD) + pdcp_initmask = pdcp_initmask | UE_NAS_USE_TUN_BIT; + + /*if (rlc_module_init() != 0) { + LOG_I(RLC, "Problem at RLC initiation \n"); + } + pdcp_layer_init(); + nr_ip_over_LTE_DRB_preconfiguration();*/ + pdcp_module_init(pdcp_initmask); + pdcp_set_rlc_data_req_func((send_rlc_data_req_func_t) rlc_data_req); + pdcp_set_pdcp_data_ind_func((pdcp_data_ind_func_t) pdcp_data_ind); + LOG_I(PDCP, "Before getting out from init_pdcp() \n"); +} + int main( int argc, char **argv ) { //uint8_t beta_ACK=0,beta_RI=0,beta_CQI=2; @@ -678,6 +671,7 @@ int main( int argc, char **argv ) { logInit(); // get options and fill parameters from configuration file get_options (); //Command-line options, enb_properties + get_common_options(); #if T_TRACER T_Config_Init(); #endif @@ -691,18 +685,22 @@ int main( int argc, char **argv ) { itti_init(TASK_MAX, THREAD_MAX, MESSAGES_ID_MAX, tasks_info, messages_info); init_opt() ; + if(IS_SOFTMODEM_NOS1) + init_pdcp(); if (ouput_vcd) { vcd_signal_dumper_init("/tmp/openair_dump_nrUE.vcd"); } +/* #ifdef PDCP_USE_NETLINK netlink_init(); #if defined(PDCP_USE_NETLINK_QUEUES) pdcp_netlink_init(); #endif #endif -#ifndef PACKAGE_VERSION +*/ + #ifndef PACKAGE_VERSION # define PACKAGE_VERSION "UNKNOWN-EXPERIMENTAL" #endif LOG_I(HW, "Version: %s\n", PACKAGE_VERSION); @@ -728,6 +726,7 @@ int main( int argc, char **argv ) { PHY_vars_UE_g[0][CC_id] = init_nr_ue_vars(frame_parms[CC_id], 0,abstraction_flag); UE[CC_id] = PHY_vars_UE_g[0][CC_id]; + if (phy_test==1) UE[CC_id]->mac_enabled = 0; else @@ -777,6 +776,7 @@ int main( int argc, char **argv ) { PHY_vars_UE_g[0][CC_id]->rf_map.chain=CC_id+chain_offset; #if defined(OAI_USRP) || defined(OAI_ADRV9371_ZC706) PHY_vars_UE_g[0][CC_id]->hw_timing_advance = timing_advance; + PHY_vars_UE_g[0][CC_id]->timing_advance = timing_advance; #else PHY_vars_UE_g[0][CC_id]->hw_timing_advance = 160; #endif diff --git a/executables/nr-uesoftmodem.h b/executables/nr-uesoftmodem.h index 6dd00276ed..717924e191 100644 --- a/executables/nr-uesoftmodem.h +++ b/executables/nr-uesoftmodem.h @@ -1,6 +1,7 @@ #ifndef NR_UESOFTMODEM_H #define NR_UESOFTMODEM_H #include +#include #include "PHY/defs_nr_UE.h" #include "SIMULATION/ETH_TRANSPORT/proto.h" #include @@ -50,41 +51,41 @@ {"ue-max-power", NULL, 0, iptr:&(tx_max_power[0]), defintval:90, TYPE_INT, 0}, \ {"r" , CONFIG_HLP_PRB, 0, iptr:&(frame_parms[0]->N_RB_DL), defintval:25, TYPE_UINT, 0}, \ {"dlsch-demod-shift", CONFIG_HLP_DLSHIFT, 0, iptr:(int32_t *)&dlsch_demod_shift, defintval:0, TYPE_INT, 0}, \ - {"usrp-args", CONFIG_HLP_USRP_ARGS, 0, strptr:(char **)&usrp_args, defstrval:"type=b200", TYPE_STRING, 0} \ + {"usrp-args", CONFIG_HLP_USRP_ARGS, 0, strptr:(char **)&usrp_args, defstrval:"type=b200", TYPE_STRING, 0} \ } #define DEFAULT_DLF 2680000000 -/*---------------------------------------------------------------------------------------------------------------------------------------------------------------------------*/ -/* command line parameters common to eNodeB and UE */ -/* optname helpstr paramflags XXXptr defXXXval type numelt */ -/*---------------------------------------------------------------------------------------------------------------------------------------------------------------------------*/ +/*----------------------------------------------------------------------------------------------------------------------------------------------------*/ +/* command line parameters common to eNodeB and UE */ +/* optname helpstr paramflags XXXptr defXXXval type numelt */ +/*----------------------------------------------------------------------------------------------------------------------------------------------------*/ #define CMDLINE_PARAMS_DESC_UE { \ - {"rf-config-file", CONFIG_HLP_RFCFGF, 0, strptr:(char **)&rf_config_file, defstrval:NULL, TYPE_STRING, sizeof(rf_config_file)},\ - {"ulsch-max-errors", CONFIG_HLP_ULMAXE, 0, uptr:&ULSCH_max_consecutive_errors, defuintval:0, TYPE_UINT, 0}, \ - {"phy-test", CONFIG_HLP_PHYTST, PARAMFLAG_BOOL, iptr:&phy_test, defintval:0, TYPE_INT, 0}, \ - {"usim-test", CONFIG_HLP_USIM, PARAMFLAG_BOOL, u8ptr:&usim_test, defintval:0, TYPE_UINT8, 0}, \ - {"external-clock", CONFIG_HLP_EXCCLK, PARAMFLAG_BOOL, uptr:&clock_source, defintval:0, TYPE_INT, 0}, \ - {"single-thread-disable", CONFIG_HLP_NOSNGLT, PARAMFLAG_BOOL, iptr:&single_thread_flag, defintval:1, TYPE_INT, 0}, \ - {"nr-dlsch-demod-shift", CONFIG_HLP_DLSHIFT, 0, iptr:(int32_t *)&nr_dlsch_demod_shift, defintval:0, TYPE_INT, 0}, \ - {"A" , CONFIG_HLP_TADV, 0, uptr:&timing_advance, defintval:0, TYPE_UINT, 0}, \ - {"C" , CONFIG_HLP_DLF, 0, uptr:&(downlink_frequency[0][0]), defuintval:2680000000, TYPE_UINT, 0}, \ - {"a" , CONFIG_HLP_CHOFF, 0, iptr:&chain_offset, defintval:0, TYPE_INT, 0}, \ - {"d" , CONFIG_HLP_SOFTS, PARAMFLAG_BOOL, uptr:&do_forms, defintval:0, TYPE_INT, 0}, \ - {"E" , CONFIG_HLP_TQFS, PARAMFLAG_BOOL, iptr:&threequarter_fs, defintval:0, TYPE_INT, 0}, \ - {"m" , CONFIG_HLP_DLMCS, 0, uptr:&target_dl_mcs, defintval:0, TYPE_UINT, 0}, \ - {"t" , CONFIG_HLP_ULMCS, 0, uptr:&target_ul_mcs, defintval:0, TYPE_UINT, 0}, \ - {"q" , CONFIG_HLP_STMON, PARAMFLAG_BOOL, iptr:&opp_enabled, defintval:0, TYPE_INT, 0}, \ - {"S" , CONFIG_HLP_MSLOTS, PARAMFLAG_BOOL, u8ptr:&exit_missed_slots, defintval:1, TYPE_UINT8, 0}, \ - {"T" , CONFIG_HLP_TDD, PARAMFLAG_BOOL, iptr:&tddflag, defintval:0, TYPE_INT, 0}, \ - {"V" , CONFIG_HLP_VCD, PARAMFLAG_BOOL, iptr:&vcdflag, defintval:0, TYPE_INT, 0}, \ - {"numerology" , CONFIG_HLP_NUMEROLOGY, PARAMFLAG_BOOL, iptr:&numerology, defintval:0, TYPE_INT, 0}, \ - {"emulate-rf" , CONFIG_HLP_EMULATE_RF, PARAMFLAG_BOOL, iptr:&emulate_rf, defintval:0, TYPE_INT, 0}, \ - {"parallel-config", CONFIG_HLP_PARALLEL_CMD,0, strptr:(char **)¶llel_config, defstrval:NULL, TYPE_STRING, 0}, \ - {"worker-config", CONFIG_HLP_WORKER_CMD, 0, strptr:(char **)&worker_config, defstrval:NULL, TYPE_STRING, 0}, \ - {"s" , CONFIG_HLP_SNR, 0, dblptr:&snr_dB, defdblval:25, TYPE_DOUBLE, 0}, \ - {"nbiot-disable", CONFIG_HLP_DISABLNBIOT, PARAMFLAG_BOOL, iptr:&nonbiotflag, defintval:0, TYPE_INT, 0}, \ - {"ue-timing-correction-disable", CONFIG_HLP_DISABLETIMECORR, PARAMFLAG_BOOL, iptr:&UE_no_timing_correction, defintval:0, TYPE_INT, 0} \ + {"rf-config-file", CONFIG_HLP_RFCFGF, 0, strptr:(char **)&rf_config_file, defstrval:NULL, TYPE_STRING, sizeof(rf_config_file)},\ + {"ulsch-max-errors", CONFIG_HLP_ULMAXE, 0, uptr:&ULSCH_max_consecutive_errors, defuintval:0, TYPE_UINT, 0}, \ + {"phy-test", CONFIG_HLP_PHYTST, PARAMFLAG_BOOL, iptr:&phy_test, defintval:0, TYPE_INT, 0}, \ + {"usim-test", CONFIG_HLP_USIM, PARAMFLAG_BOOL, u8ptr:&usim_test, defintval:0, TYPE_UINT8, 0}, \ + {"external-clock", CONFIG_HLP_EXCCLK, PARAMFLAG_BOOL, uptr:&clock_source, defintval:0, TYPE_INT, 0}, \ + {"single-thread-disable", CONFIG_HLP_NOSNGLT, PARAMFLAG_BOOL, iptr:&single_thread_flag, defintval:1, TYPE_INT, 0}, \ + {"nr-dlsch-demod-shift", CONFIG_HLP_DLSHIFT, 0, iptr:(int32_t *)&nr_dlsch_demod_shift, defintval:0, TYPE_INT, 0}, \ + {"A" , CONFIG_HLP_TADV, 0, uptr:&timing_advance, defintval:0, TYPE_UINT, 0}, \ + {"C" , CONFIG_HLP_DLF, 0, uptr:&(downlink_frequency[0][0]), defuintval:2680000000, TYPE_UINT, 0}, \ + {"a" , CONFIG_HLP_CHOFF, 0, iptr:&chain_offset, defintval:0, TYPE_INT, 0}, \ + {"d" , CONFIG_HLP_SOFTS, PARAMFLAG_BOOL, uptr:&do_forms, defintval:0, TYPE_INT, 0}, \ + {"E" , CONFIG_HLP_TQFS, PARAMFLAG_BOOL, iptr:&threequarter_fs, defintval:0, TYPE_INT, 0}, \ + {"m" , CONFIG_HLP_DLMCS, 0, uptr:&target_dl_mcs, defintval:0, TYPE_UINT, 0}, \ + {"t" , CONFIG_HLP_ULMCS, 0, uptr:&target_ul_mcs, defintval:0, TYPE_UINT, 0}, \ + {"q" , CONFIG_HLP_STMON, PARAMFLAG_BOOL, iptr:&opp_enabled, defintval:0, TYPE_INT, 0}, \ + {"S" , CONFIG_HLP_MSLOTS, PARAMFLAG_BOOL, u8ptr:&exit_missed_slots, defintval:1, TYPE_UINT8, 0}, \ + {"T" , CONFIG_HLP_TDD, PARAMFLAG_BOOL, iptr:&tddflag, defintval:0, TYPE_INT, 0}, \ + {"V" , CONFIG_HLP_VCD, PARAMFLAG_BOOL, iptr:&vcdflag, defintval:0, TYPE_INT, 0}, \ + {"numerology" , CONFIG_HLP_NUMEROLOGY, PARAMFLAG_BOOL, iptr:&numerology, defintval:0, TYPE_INT, 0}, \ + {"emulate-rf" , CONFIG_HLP_EMULATE_RF, PARAMFLAG_BOOL, iptr:&emulate_rf, defintval:0, TYPE_INT, 0}, \ + {"parallel-config", CONFIG_HLP_PARALLEL_CMD,0, strptr:(char **)¶llel_config, defstrval:NULL, TYPE_STRING, 0}, \ + {"worker-config", CONFIG_HLP_WORKER_CMD, 0, strptr:(char **)&worker_config, defstrval:NULL, TYPE_STRING, 0}, \ + {"s" , CONFIG_HLP_SNR, 0, dblptr:&snr_dB, defdblval:25, TYPE_DOUBLE, 0}, \ + {"nbiot-disable", CONFIG_HLP_DISABLNBIOT, PARAMFLAG_BOOL, iptr:&nonbiotflag, defintval:0, TYPE_INT, 0}, \ + {"ue-timing-correction-disable", CONFIG_HLP_DISABLETIMECORR, PARAMFLAG_BOOL, iptr:&UE_no_timing_correction, defintval:0, TYPE_INT, 0} \ } @@ -94,15 +95,12 @@ extern int T_dont_fork; // In nr-ue.c -extern int setup_nr_ue_buffers(PHY_VARS_NR_UE **phy_vars_ue, - openair0_config_t *openair0_cfg); +extern int setup_nr_ue_buffers(PHY_VARS_NR_UE **phy_vars_ue, openair0_config_t *openair0_cfg); extern void fill_ue_band_info(void); extern void init_NR_UE(int); extern void reset_opp_meas(void); extern void print_opp_meas(void); void *UE_thread(void *arg); -PHY_VARS_NR_UE *init_nr_ue_vars(NR_DL_FRAME_PARMS *frame_parms, - uint8_t UE_id, - uint8_t abstraction_flag); +PHY_VARS_NR_UE *init_nr_ue_vars(NR_DL_FRAME_PARMS *frame_parms, uint8_t UE_id, uint8_t abstraction_flag); extern tpool_t *Tpool; #endif diff --git a/executables/softmodem-common.h b/executables/softmodem-common.h new file mode 100644 index 0000000000..f6ba3a6beb --- /dev/null +++ b/executables/softmodem-common.h @@ -0,0 +1,22 @@ +#ifndef SOFTMODEM_COMMON_H +#define SOFTMODEM_COMMON_H + +typedef struct { + uint64_t optmask; + THREAD_STRUCT thread_struct; + char rf_config_file[1024]; + int phy_test; + uint8_t usim_test; + int emulate_rf; + int wait_for_sync; //eNodeB only + int single_thread_flag; //eNodeB only + int chain_offset; + int numerology; + unsigned int start_msc; + uint32_t clock_source; + uint32_t timing_source; + int hw_timing_advance; + uint32_t send_dmrs_sync; +} softmodem_params_t; + +#endif diff --git a/executables/thread-common.h b/executables/thread-common.h new file mode 100644 index 0000000000..6f3af3cfc0 --- /dev/null +++ b/executables/thread-common.h @@ -0,0 +1,42 @@ +#ifndef THREAD_COMMON_H +#define THREAD_COMMON_H + +#include "PHY/defs_common.h" + +THREAD_STRUCT thread_struct; + +static inline void set_parallel_conf(char *parallel_conf) { + mapping config[]= { + FOREACH_PARALLEL(GENERATE_ENUMTXT) + {NULL,-1} + }; + thread_struct.parallel_conf = (PARALLEL_CONF_t)map_str_to_int(config, parallel_conf); + if (thread_struct.parallel_conf == -1 ) { + LOG_E(ENB_APP,"Impossible value: %s\n", parallel_conf); + thread_struct.parallel_conf = PARALLEL_SINGLE_THREAD; + } + printf("[CONFIG] parallel_conf is set to %d\n", thread_struct.parallel_conf); +} + +static inline void set_worker_conf(char *worker_conf) { + mapping config[]={ + FOREACH_WORKER(GENERATE_ENUMTXT) + {NULL, -1} + }; + thread_struct.worker_conf = (WORKER_CONF_t)map_str_to_int(config, worker_conf); + if (thread_struct.worker_conf == -1 ) { + LOG_E(ENB_APP,"Impossible value: %s\n", worker_conf); + thread_struct.worker_conf = WORKER_DISABLE ; + } + printf("[CONFIG] worker_conf is set to %d\n", thread_struct.worker_conf); +} + +static inline PARALLEL_CONF_t get_thread_parallel_conf(void) { + return thread_struct.parallel_conf; +} + +static inline WORKER_CONF_t get_thread_worker_conf(void) { + return thread_struct.worker_conf; +} + +#endif diff --git a/nfapi/open-nFAPI/nfapi/public_inc/nfapi_nr_interface.h b/nfapi/open-nFAPI/nfapi/public_inc/nfapi_nr_interface.h index 525baef291..8c556ca8ca 100644 --- a/nfapi/open-nFAPI/nfapi/public_inc/nfapi_nr_interface.h +++ b/nfapi/open-nFAPI/nfapi/public_inc/nfapi_nr_interface.h @@ -617,13 +617,14 @@ typedef struct { uint8_t start_symbol; uint8_t nb_symbols; uint8_t mcs_idx; + uint8_t mcs_table; uint8_t ndi; uint8_t nb_codewords; uint8_t nb_layers; uint16_t coding_rate; uint8_t modulation; uint8_t modulation_order; - uint16_t transport_block_size; + uint32_t transport_block_size; uint8_t dmrs_Type; uint8_t dmrs_TypeA_Position; uint8_t dmrs_maxLength; @@ -716,6 +717,7 @@ typedef struct { nr_pusch_freq_hopping_t pusch_freq_hopping; uint8_t mcs; uint8_t Qm; + uint16_t R; uint8_t ndi; uint8_t rv; int8_t accumulated_delta_PUSCH; diff --git a/openair1/PHY/CODING/TESTBENCH/ldpctest.c b/openair1/PHY/CODING/TESTBENCH/ldpctest.c index 6db9548dbe..ed8dd3b49a 100644 --- a/openair1/PHY/CODING/TESTBENCH/ldpctest.c +++ b/openair1/PHY/CODING/TESTBENCH/ldpctest.c @@ -23,13 +23,14 @@ #include #include #include - #include "assertions.h" #include "SIMULATION/TOOLS/sim.h" #include "PHY/CODING/nrLDPC_encoder/defs.h" #include "PHY/CODING/nrLDPC_decoder/nrLDPC_decoder.h" +#include "openair1/SIMULATION/NR_PHY/nr_unitary_defs.h" #define MAX_NUM_DLSCH_SEGMENTS 16 +#define MAX_BLOCK_LENGTH 8448 #ifndef malloc16 # ifdef __AVX2__ @@ -42,7 +43,6 @@ #define NR_LDPC_PROFILER_DETAIL #define NR_LDPC_ENABLE_PARITY_CHECK - // 4-bit quantizer char quantize4bit(double D,double x) { @@ -76,31 +76,15 @@ char quantize8bit(double D,double x) return((char)qxd); } -char quantize(double D,double x,unsigned char B) -{ - double qxd; - short maxlev; - qxd = floor(x/D); - - maxlev = 1<<(B-1);//(char)(pow(2,B-1)); - - //printf("x=%f,qxd=%f,maxlev=%d\n",x,qxd, maxlev); - - if (qxd <= -maxlev) - qxd = -maxlev; - else if (qxd >= maxlev) - qxd = maxlev-1; - - return((char)qxd); -} - typedef struct { -double n_iter_mean; -double n_iter_std; -int n_iter_max; + double n_iter_mean; + double n_iter_std; + int n_iter_max; } n_iter_stats_t; -#define MAX_BLOCK_LENGTH 8448 +RAN_CONTEXT_t RC; +PHY_VARS_UE ***PHY_vars_UE_g; +uint16_t NB_UE_INST = 1; short lift_size[51]= {2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,18,20,22,24,26,28,30,32,36,40,44,48,52,56,60,64,72,80,88,96,104,112,120,128,144,160,176,192,208,224,240,256,288,320,352,384}; @@ -118,7 +102,7 @@ int test_ldpc(short No_iteration, unsigned int *crc_misses, time_stats_t *time_optim, time_stats_t *time_decoder, - n_iter_stats_t * dec_iter) + n_iter_stats_t *dec_iter) { //clock initiate //time_stats_t time,time_optim,tinput,tprep,tparity,toutput, time_decoder; @@ -146,12 +130,12 @@ int test_ldpc(short No_iteration, double *modulated_input[MAX_NUM_DLSCH_SEGMENTS]; char *channel_output_fixed[MAX_NUM_DLSCH_SEGMENTS]; unsigned int i,j,trial=0; - short BG,Zc,Kb,nrows;//,ncols; + short BG=0,nrows=0;//,ncols; int no_punctured_columns,removed_bit; - int i1; + int i1,Zc,Kb=0; int R_ind = 0; //Table of possible lifting sizes -//short lift_size[51]= {2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,18,20,22,24,26,28,30,32,36,40,44,48,52,56,60,64,72,80,88,96,104,112,120,128,144,160,176,192,208,224,240,256,288,320,352,384}; + //short lift_size[51]= {2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,18,20,22,24,26,28,30,32,36,40,44,48,52,56,60,64,72,80,88,96,104,112,120,128,144,160,176,192,208,224,240,256,288,320,352,384}; //int n_segments=1; int code_rate_vec[8] = {15, 13, 25, 12, 23, 34, 56, 89}; //double code_rate_actual_vec[8] = {0.2, 0.33333, 0.4, 0.5, 0.66667, 0.73333, 0.81481, 0.88}; @@ -227,15 +211,15 @@ int test_ldpc(short No_iteration, //determine number of bits in codeword if (block_length>3840) { - BG=1; + BG = 1; Kb = 22; - nrows=46; //parity check bits + nrows = 46; //parity check bits //ncols=22; //info bits } else if (block_length<=3840) { - BG=2; - nrows=42; //parity check bits + BG = 2; + nrows = 42; //parity check bits //ncols=10; // info bits if (block_length>640) @@ -246,7 +230,7 @@ int test_ldpc(short No_iteration, Kb = 8; else Kb = 6; - } + } if (nom_rate == 1) if (denom_rate == 5) @@ -298,12 +282,12 @@ int test_ldpc(short No_iteration, } } - printf("ldpc_test: codeword_length %d, n_segments %d, block_length %d, BG %d, Zc %d, Kb %d\n",n_segments *block_length, n_segments, block_length,BG, Zc, Kb); + printf("ldpc_test: codeword_length %d, n_segments %d, block_length %d, BG %d, Zc %d, Kb %d\n",n_segments *block_length, n_segments, block_length, BG, Zc, Kb); no_punctured_columns=(int)((nrows-2)*Zc+block_length-block_length*(1/((float)nom_rate/(float)denom_rate)))/Zc; // printf("puncture:%d\n",no_punctured_columns); removed_bit=(nrows-no_punctured_columns-2) * Zc+block_length-(int)(block_length/((float)nom_rate/(float)denom_rate)); if (ntrials==0) - ldpc_encoder_orig(test_input[0],channel_input[0], block_length, BG, 1); + ldpc_encoder_orig(test_input[0],channel_input[0], Zc, BG, block_length, BG, 1); for (trial=0; trial < ntrials; trial++) { @@ -311,30 +295,30 @@ int test_ldpc(short No_iteration, //// encoder start_meas(&time); for(j=0;j3840) { - BG=1; + BG = 1; Kb = 22; //nrows=46; //parity check bits //ncols=22; //info bits } else if (block_length<=3840) { - BG=2; + BG = 2; //nrows=42; //parity check bits //ncols=10; // info bits @@ -663,8 +646,7 @@ int main(int argc, char *argv[]) fprintf(fd,"SNR BLER BER UNCODED_BER ENCODER_MEAN ENCODER_STD ENCODER_MAX DECODER_TIME_MEAN DECODER_TIME_STD DECODER_TIME_MAX DECODER_ITER_MEAN DECODER_ITER_STD DECODER_ITER_MAX\n"); - for (SNR=SNR0;SNRn_iter_mean); printf("SNR %f, Std iterations: %f\n",SNR, dec_iter->n_iter_std); printf("SNR %f, Max iterations: %d\n",SNR, dec_iter->n_iter_max); @@ -720,23 +702,11 @@ int main(int argc, char *argv[]) dec_iter->n_iter_max ); - if (decoded_errors[i] == 0) - break; + if (decoded_errors[i] == 0) break; + i=i+1; - - } fclose(fd); return(0); } - - - - - - - - - - diff --git a/openair1/PHY/CODING/TESTBENCH/polartest.c b/openair1/PHY/CODING/TESTBENCH/polartest.c index 76cde6c3be..051e098187 100644 --- a/openair1/PHY/CODING/TESTBENCH/polartest.c +++ b/openair1/PHY/CODING/TESTBENCH/polartest.c @@ -11,6 +11,7 @@ #include "PHY/CODING/nrPolar_tools/nr_polar_uci_defs.h" #include "PHY/CODING/coding_defs.h" #include "SIMULATION/TOOLS/sim.h" +#include "openair1/SIMULATION/NR_PHY/nr_unitary_defs.h" //#include "PHY/NR_TRANSPORT/nr_transport.h" //#include "common/utils/LOG/log.h" @@ -18,7 +19,12 @@ //#define DEBUG_POLAR_TIMING //#define DEBUG_POLARTEST -int main(int argc, char *argv[]) { +RAN_CONTEXT_t RC; +PHY_VARS_UE ***PHY_vars_UE_g; +uint16_t NB_UE_INST = 1; + +int main(int argc, char *argv[]) +{ //Default simulation values (Aim for iterations = 1000000.) int decoder_int16=0; int itr, iterations = 1000, arguments, polarMessageType = 0; //0=PBCH, 1=DCI, -1=UCI diff --git a/openair1/PHY/CODING/TESTBENCH/smallblocktest.c b/openair1/PHY/CODING/TESTBENCH/smallblocktest.c index ee1a228ab8..02d5dc64e0 100644 --- a/openair1/PHY/CODING/TESTBENCH/smallblocktest.c +++ b/openair1/PHY/CODING/TESTBENCH/smallblocktest.c @@ -1,27 +1,16 @@ -#include "PHY/CODING/nrSmallBlock/nr_small_block_defs.h" -#include "SIMULATION/TOOLS/sim.h" #include +#include "SIMULATION/TOOLS/sim.h" +#include "PHY/CODING/nrSmallBlock/nr_small_block_defs.h" +#include "openair1/SIMULATION/NR_PHY/nr_unitary_defs.h" //#define DEBUG_SMALLBLOCKTEST -signed char quantize(double D, double x, unsigned char B) +RAN_CONTEXT_t RC; +PHY_VARS_UE ***PHY_vars_UE_g; +uint16_t NB_UE_INST = 1; + +int main(int argc, char *argv[]) { - double qxd; - short maxlev; - qxd = floor(x/D); - - maxlev = 1<<(B-1);//(char)(pow(2,B-1)); - - if (qxd <= -maxlev) - qxd = -maxlev; - else if (qxd >= maxlev) - qxd = maxlev-1; - - return((char)qxd); -} - -int main(int argc, char *argv[]) { - time_stats_t timeEncoder,timeDecoder; opp_enabled=1; cpu_freq_GHz = get_cpu_freq_GHz(); diff --git a/openair1/PHY/CODING/coding_defs.h b/openair1/PHY/CODING/coding_defs.h index 3e6222c341..540fd3b263 100644 --- a/openair1/PHY/CODING/coding_defs.h +++ b/openair1/PHY/CODING/coding_defs.h @@ -454,14 +454,21 @@ int32_t nr_segmentation(unsigned char *input_buffer, unsigned int *C, unsigned int *K, unsigned int *Zout, - unsigned int *F); + unsigned int *F, + uint8_t BG); -uint32_t nr_compute_tbs(uint8_t mcs, - uint16_t nb_rb, - uint16_t nb_symb_sch, - uint8_t nb_re_dmrs, - uint16_t length_dmrs, - uint8_t Nl); +uint32_t nr_compute_tbs(uint16_t Qm, + uint16_t R, + uint16_t nb_rb, + uint16_t nb_symb_sch, + uint16_t nb_dmrs_prb, + uint16_t nb_rb_oh, + uint8_t Nl); + +uint32_t nr_compute_tbslbrm(uint16_t table, + uint16_t nb_rb, + uint8_t Nl, + uint8_t C); void nr_interleaving_ldpc(uint32_t E, uint8_t Qm, uint8_t *e,uint8_t *f); diff --git a/openair1/PHY/CODING/nrLDPC_decoder/nrLDPC_bnProc.h b/openair1/PHY/CODING/nrLDPC_decoder/nrLDPC_bnProc.h index 00e8fd98d5..878150a9a8 100644 --- a/openair1/PHY/CODING/nrLDPC_decoder/nrLDPC_bnProc.h +++ b/openair1/PHY/CODING/nrLDPC_decoder/nrLDPC_bnProc.h @@ -47,7 +47,7 @@ static inline void nrLDPC_bnProcPc(t_nrLDPC_lut* p_lut, t_nrLDPC_procBuf* p_proc int8_t* bnProcBufRes = p_procBuf->bnProcBufRes; int8_t* llrRes = p_procBuf->llrRes; int8_t* llrProcBuf = p_procBuf->llrProcBuf; - + __m128i* p_bnProcBuf; __m256i* p_bnProcBufRes; __m128i* p_llrProcBuf; @@ -1693,7 +1693,7 @@ static inline void nrLDPC_bnProc(t_nrLDPC_lut* p_lut, t_nrLDPC_procBuf* p_procBu int8_t* bnProcBuf = p_procBuf->bnProcBuf; int8_t* bnProcBufRes = p_procBuf->bnProcBufRes; int8_t* llrRes = p_procBuf->llrRes; - + __m256i* p_bnProcBuf; __m256i* p_bnProcBufRes; __m256i* p_llrRes; @@ -2775,24 +2775,35 @@ static inline void nrLDPC_llr2bit(int8_t* out, int8_t* llrOut, uint16_t numLLR) } /** - \brief Performs hard-decision on output LLRs and packs the output in 32 bit values. + \brief Performs hard-decision on output LLRs and packs the output in byte aligned output according to TS 38.321 Section 6.1.1. + i = 0,1,2,... + IN[i] : a0, a1, a2, ..., a_{A-1} + OUT[i]: a7,a6,a5,a4,a3,a2,a1,a0|a15,14,...,a8|a23,a22,...,a16|a31,a30,...,a24|... \param out Pointer hard-decision output, every int8_t contains 8 bits \param llrOut Pointer to output LLRs \param numLLR Number of LLRs */ static inline void nrLDPC_llr2bitPacked(int8_t* out, int8_t* llrOut, uint16_t numLLR) { + /** Vector of indices for shuffling input */ + const uint8_t constShuffle_256_epi8[32] __attribute__ ((aligned(32))) = {7,6,5,4,3,2,1,0,15,14,13,12,11,10,9,8,7,6,5,4,3,2,1,0,15,14,13,12,11,10,9,8}; + __m256i* p_llrOut = (__m256i*) llrOut; uint32_t* p_bits = (uint32_t*) out; + __m256i inPerm; int8_t* p_llrOut8; uint32_t bitsTmp = 0; uint32_t i; uint32_t M = numLLR>>5; uint32_t Mr = numLLR&31; + const __m256i* p_shuffle = (__m256i*) constShuffle_256_epi8; for (i=0; i640) - Kb = 10; - else if (block_length>560) - Kb = 9; - else if (block_length>192) - Kb = 8; - else - Kb = 6; } - //find minimum value in all sets of lifting size - Zc=0; - for (i1=0; i1 < 51; i1++) - { - if (lift_size[i1] >= (double) block_length/Kb) - { - Zc = lift_size[i1]; - //printf("%d\n",Zc); - break; - } - } - AssertFatal(Zc>0,"no valid Zc found for block length %d\n",block_length); #ifdef DEBUG_LDPC LOG_D(PHY,"ldpc_encoder_optim_8seg: BG %d, Zc %d, Kb %d, block_length %d\n",BG,Zc,Kb,block_length); @@ -273,7 +249,7 @@ int ldpc_encoder_optim(unsigned char *test_input,unsigned char *channel_input,sh if(tinput != NULL) start_meas(tinput); for (i=0; i>(i&7); + c[i] = (test_input[i/8]&(128>>(i&7)))>>(7-(i&7)); //printf("c(%d,%d)=%d\n",j,i,temp); } @@ -317,20 +293,18 @@ int ldpc_encoder_optim(unsigned char *test_input,unsigned char *channel_input,sh return 0; } -int ldpc_encoder_optim_8seg(unsigned char **test_input,unsigned char **channel_input,short block_length,short BG,int n_segments,time_stats_t *tinput,time_stats_t *tprep,time_stats_t *tparity,time_stats_t *toutput) +int ldpc_encoder_optim_8seg(unsigned char **test_input,unsigned char **channel_input,int Zc,int Kb,short block_length,short BG,int n_segments,time_stats_t *tinput,time_stats_t *tprep,time_stats_t *tparity,time_stats_t *toutput) { - short Zc,Kb=0,nrows=0,ncols=0; + short nrows=0,ncols=0; int i,i1,j; int no_punctured_columns,removed_bit; - //Table of possible lifting sizes - short lift_size[51]= {2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,18,20,22,24,26,28,30,32,36,40,44,48,52,56,60,64,72,80,88,96,104,112,120,128,144,160,176,192,208,224,240,256,288,320,352,384}; char temp; int simd_size; #ifdef __AVX2__ __m256i shufmask = _mm256_set_epi64x(0x0303030303030303, 0x0202020202020202,0x0101010101010101, 0x0000000000000000); - __m256i andmask = _mm256_set1_epi64x(0x8040201008040201); // every 8 bits -> 8 bytes, pattern repeats. + __m256i andmask = _mm256_set1_epi64x(0x0102040810204080); // every 8 bits -> 8 bytes, pattern repeats. __m256i zero256 = _mm256_setzero_si256(); __m256i masks[8]; register __m256i c256; @@ -350,8 +324,6 @@ int ldpc_encoder_optim_8seg(unsigned char **test_input,unsigned char **channel_i //if (block_length>3840) if (BG==1) { - //BG=1; - Kb = 22; nrows=46; //parity check bits ncols=22; //info bits } @@ -362,28 +334,8 @@ int ldpc_encoder_optim_8seg(unsigned char **test_input,unsigned char **channel_i nrows=42; //parity check bits ncols=10; // info bits - if (block_length>640) - Kb = 10; - else if (block_length>560) - Kb = 9; - else if (block_length>192) - Kb = 8; - else - Kb = 6; } - //find minimum value in all sets of lifting size - Zc=0; - for (i1=0; i1 < 51; i1++) - { - if (lift_size[i1] >= (double) block_length/Kb) - { - Zc = lift_size[i1]; - //printf("%d\n",Zc); - break; - } - } - #ifdef DEBUG_LDPC LOG_D(PHY,"ldpc_encoder_optim_8seg: BG %d, Zc %d, Kb %d, block_length %d, segments %d\n",BG,Zc,Kb,block_length,n_segments); LOG_D(PHY,"ldpc_encoder_optim_8seg: PDU (seg 0) %x %x %x %x\n",test_input[0][0],test_input[0][1],test_input[0][2],test_input[0][3]); @@ -413,7 +365,7 @@ int ldpc_encoder_optim_8seg(unsigned char **test_input,unsigned char **channel_i for (i=0; i>(i&7); + temp = (test_input[j][i/8]&(128>>(i&7)))>>(7-(i&7)); //printf("c(%d,%d)=%d\n",j,i,temp); c[i] |= (temp << j); } @@ -431,7 +383,7 @@ int ldpc_encoder_optim_8seg(unsigned char **test_input,unsigned char **channel_i for (i=(block_length>>5)<<5;i>(i&7); + temp = (test_input[j][i/8]&(128>>(i&7)))>>(7-(i&7)); //printf("c(%d,%d)=%d\n",j,i,temp); c[i] |= (temp << j); } @@ -517,14 +469,13 @@ int ldpc_encoder_optim_8seg(unsigned char **test_input,unsigned char **channel_i return 0; } -int ldpc_encoder_optim_8seg_multi(unsigned char **test_input,unsigned char **channel_input,short block_length, short BG, int n_segments,unsigned int macro_num, time_stats_t *tinput,time_stats_t *tprep,time_stats_t *tparity,time_stats_t *toutput) +int ldpc_encoder_optim_8seg_multi(unsigned char **test_input,unsigned char **channel_input,int Zc,int Kb,short block_length, short BG, int n_segments,unsigned int macro_num, time_stats_t *tinput,time_stats_t *tprep,time_stats_t *tparity,time_stats_t *toutput) { - short Zc,Kb=0,nrows=0,ncols=0; + short nrows=0,ncols=0; int i,i1,j; int no_punctured_columns,removed_bit; //Table of possible lifting sizes - short lift_size[51]= {2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,18,20,22,24,26,28,30,32,36,40,44,48,52,56,60,64,72,80,88,96,104,112,120,128,144,160,176,192,208,224,240,256,288,320,352,384}; char temp; int simd_size; int macro_segment, macro_segment_end; @@ -537,7 +488,7 @@ int ldpc_encoder_optim_8seg_multi(unsigned char **test_input,unsigned char **cha #ifdef __AVX2__ __m256i shufmask = _mm256_set_epi64x(0x0303030303030303, 0x0202020202020202,0x0101010101010101, 0x0000000000000000); - __m256i andmask = _mm256_set1_epi64x(0x8040201008040201); // every 8 bits -> 8 bytes, pattern repeats. + __m256i andmask = _mm256_set1_epi64x(0x0102040810204080); // every 8 bits -> 8 bytes, pattern repeats. __m256i zero256 = _mm256_setzero_si256(); __m256i masks[8]; register __m256i c256; @@ -556,38 +507,14 @@ int ldpc_encoder_optim_8seg_multi(unsigned char **test_input,unsigned char **cha //determine number of bits in codeword if (BG==1) { - BG=1; - Kb = 22; nrows=46; //parity check bits ncols=22; //info bits } else if (BG==2) { - BG=2; nrows=42; //parity check bits ncols=10; // info bits - - if (block_length>640) - Kb = 10; - else if (block_length>560) - Kb = 9; - else if (block_length>192) - Kb = 8; - else - Kb = 6; - } - - //find minimum value in all sets of lifting size - Zc=0; - for (i1=0; i1 < 51; i1++) - { - if (lift_size[i1] >= (double) block_length/Kb) - { - Zc = lift_size[i1]; - //printf("%d\n",Zc); - break; } - } #ifdef DEBUG_LDPC LOG_D(PHY,"ldpc_encoder_optim_8seg: BG %d, Zc %d, Kb %d, block_length %d, segments %d\n",BG,Zc,Kb,block_length,n_segments); @@ -639,7 +566,7 @@ int ldpc_encoder_optim_8seg_multi(unsigned char **test_input,unsigned char **cha //for (j=0; j>(i&7); + temp = (test_input[j][i/8]&(128>>(i&7)))>>(7-(i&7)); //printf("c(%d,%d)=%d\n",j,i,temp); c[i] |= (temp << (j-macro_segment)); } diff --git a/openair1/PHY/CODING/nrLDPC_encoder/ldpc_generate_coefficient.c b/openair1/PHY/CODING/nrLDPC_encoder/ldpc_generate_coefficient.c index 13318c9d5d..235badc2e0 100644 --- a/openair1/PHY/CODING/nrLDPC_encoder/ldpc_generate_coefficient.c +++ b/openair1/PHY/CODING/nrLDPC_encoder/ldpc_generate_coefficient.c @@ -361,24 +361,19 @@ short *choose_generator_matrix(short BG,short Zc) return Gen_shift_values; } -int ldpc_encoder_orig(unsigned char *test_input,unsigned char *channel_input,short block_length, short BG,unsigned char gen_code) +int ldpc_encoder_orig(unsigned char *test_input,unsigned char *channel_input,int Zc,int Kb,short block_length, short BG,unsigned char gen_code) { unsigned char c[22*384]; //padded input, unpacked, max size unsigned char d[68*384]; //coded output, unpacked, max size unsigned char channel_temp,temp; short *Gen_shift_values, *no_shift_values, *pointer_shift_values; - short Zc; - //initialize for BG == 1 - short Kb = 22; + short nrows = 46;//parity check bits short ncols = 22;//info bits int i,i1,i2,i3,i4,i5,temp_prime,var; int no_punctured_columns,removed_bit; - //Table of possible lifting sizes - short lift_size[51]= {2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,18,20,22,24,26,28,30,32,36,40,44,48,52,56,60,64,72,80,88,96,104,112,120,128,144,160,176,192,208,224,240,256,288,320,352,384}; - int nind=0; int indlist[1000]; int indlist2[1000]; @@ -387,8 +382,6 @@ int ldpc_encoder_orig(unsigned char *test_input,unsigned char *channel_input,sho //if (block_length>3840) if (BG==1) { - //BG=1; - Kb = 22; nrows=46; //parity check bits ncols=22; //info bits } @@ -399,32 +392,8 @@ int ldpc_encoder_orig(unsigned char *test_input,unsigned char *channel_input,sho nrows=42; //parity check bits ncols=10; // info bits - if (block_length>640) - Kb = 10; - else if (block_length>560) - Kb = 9; - else if (block_length>192) - Kb = 8; - else - Kb = 6; } - //find minimum value in all sets of lifting size - Zc=0; - for (i1=0; i1 < 51; i1++) - { - if (lift_size[i1] >= (double) block_length/Kb) - { - Zc = lift_size[i1]; - //printf("%d\n",Zc); - break; - } - } - if (Zc==0) { - printf("ldpc_encoder_orig: could not determine lifting size\n"); - return(-1); - } - Gen_shift_values=choose_generator_matrix(BG,Zc); if (Gen_shift_values==NULL) { printf("ldpc_encoder_orig: could not find generator matrix\n"); @@ -445,7 +414,7 @@ int ldpc_encoder_orig(unsigned char *test_input,unsigned char *channel_input,sho pointer_shift_values=(short *) pointer_shift_values_BG2; } else { - AssertFatal(0,"BG %d is not supported yet\n",BG); + AssertFatal(0,"BG %d is not supported yet\n",BG); } no_punctured_columns=(int)((nrows-2)*Zc+block_length-block_length*3)/Zc; @@ -460,7 +429,7 @@ int ldpc_encoder_orig(unsigned char *test_input,unsigned char *channel_input,sho { //c[i] = test_input[i/8]<<(i%8); //c[i]=c[i]>>7&1; - c[i]=(test_input[i/8]&(1<<(i&7)))>>(i&7); + c[i]=(test_input[i/8]&(128>>(i&7)))>>(7-(i&7)); } // parity check part diff --git a/openair1/PHY/CODING/nrPolar_tools/nr_polar_decoder.c b/openair1/PHY/CODING/nrPolar_tools/nr_polar_decoder.c index 66d0fc481c..a847072a4c 100644 --- a/openair1/PHY/CODING/nrPolar_tools/nr_polar_decoder.c +++ b/openair1/PHY/CODING/nrPolar_tools/nr_polar_decoder.c @@ -601,7 +601,8 @@ void init_polar_deinterleaver_table(t_nrPolar_params *polarParams) { uint32_t polar_decoder_int16(int16_t *input, uint64_t *out, - const t_nrPolar_params *polarParams) { + const t_nrPolar_params *polarParams) +{ int16_t d_tilde[polarParams->N];// = malloc(sizeof(double) * polarParams->N); nr_polar_rate_matching_int16(input, d_tilde, polarParams->rate_matching_pattern, polarParams->K, polarParams->N, polarParams->encoderLength); @@ -645,8 +646,8 @@ uint32_t polar_decoder_int16(int16_t *input, //int len_mod64=len&63; int crclen = polarParams->crcParityBits; uint64_t rxcrc=B[0]&((1<encoderLength; i++) { #ifdef DEBUG_POLAR_ENCODER - printf("%u<-%u : %llx.%llx =>",i,polarParams->rate_matching_pattern[i],((uint64_t *)out)[1],((uint64_t *)out)[0]); + printf("%d<-%u : %llx.%llx =>",i,polarParams->rate_matching_pattern[i],((uint64_t *)out)[1],((uint64_t *)out)[0]); #endif tmp0 = (*in128&(((uint128_t)1)<rate_matching_pattern[i])); if (tmp0!=0) { diff --git a/openair1/PHY/CODING/nr_compute_tbs.c b/openair1/PHY/CODING/nr_compute_tbs.c index e1c15d4a86..055f697f41 100644 --- a/openair1/PHY/CODING/nr_compute_tbs.c +++ b/openair1/PHY/CODING/nr_compute_tbs.c @@ -24,73 +24,128 @@ author: Hongzhi WANG (TCL) */ #include "PHY/defs_nr_UE.h" -//#include "SCHED/extern.h" - #define INDEX_MAX_TBS_TABLE (93) -//Table 5.1.3.1-1 -uint16_t Mcsindextable1[29][2] = {{2,120},{2,157},{2,193},{2,251},{2,308},{2,379},{2,449},{2,526},{2,602},{2,679},{4,340},{4,378},{4,434},{4,490},{4,553},{4,616}, - {4,658},{6,438},{6,466},{6,517},{6,567},{6,616},{6,666},{6,719},{6,772},{6,822},{6,873}, {6,910}, {6,948}}; + //Table 5.1.2.2-2 uint16_t Tbstable_nr[INDEX_MAX_TBS_TABLE] = {24,32,40,48,56,64,72,80,88,96,104,112,120,128,136,144,152,160,168,176,184,192,208,224,240,256,272,288,304,320,336,352,368,384,408,432,456,480,504,528,552,576,608,640,672,704,736,768,808,848,888,928,984,1032,1064,1128,1160,1192,1224,1256,1288,1320,1352,1416,1480,1544,1608,1672,1736,1800,1864,1928,2024,2088,2152,2216,2280,2408,2472,2536,2600,2664,2728,2792,2856,2976,3104,3240,3368,3496,3624,3752,3824}; -uint32_t nr_compute_tbs(uint8_t mcs, - uint16_t nb_rb, - uint16_t nb_symb_sch, - uint8_t nb_re_dmrs, - uint16_t length_dmrs, - uint8_t Nl) +uint16_t NPRB_LBRM[7] = {32,66,107,135,162,217,273}; + +uint32_t nr_compute_tbs(uint16_t Qm, + uint16_t R, + uint16_t nb_rb, + uint16_t nb_symb_sch, + uint16_t nb_dmrs_prb, + uint16_t nb_rb_oh, + uint8_t Nl) { - uint16_t nbp_re, nb_re, nb_dmrs_prb, nb_rb_oh,Qm,R; - uint32_t nr_tbs=0; - double Ninfo,Np_info,n,C; - nb_rb_oh = 0; //set to 0 if not configured by higher layer - Qm = Mcsindextable1[mcs][0]; - R = Mcsindextable1[mcs][1]; - nb_dmrs_prb = nb_re_dmrs*length_dmrs; + uint16_t nbp_re, nb_re; + uint32_t nr_tbs=0; + uint32_t Ninfo, Np_info, C; + uint8_t n, scale; - nbp_re = 12 * nb_symb_sch - nb_dmrs_prb - nb_rb_oh; + nbp_re = NR_NB_SC_PER_RB * nb_symb_sch - nb_dmrs_prb - nb_rb_oh; - nb_re = min(156, nbp_re) * nb_rb; + nb_re = min(156, nbp_re) * nb_rb; + + scale = (R>1024)?11:10; // Intermediate number of information bits - Ninfo = (double)((nb_re * R * Qm * Nl)/1024); - - //printf("Ninfo %lf nbp_re %d nb_re %d mcs %d Qm %d, R %d\n", Ninfo, nbp_re, nb_re,mcs, Qm, R); + Ninfo = (nb_re * R * Qm * Nl)>>scale; if (Ninfo <=3824) { - n = max(3, floor(log2(Ninfo)) - 6); - Np_info = max(24, pow(2,n) * floor(Ninfo/pow(2,n))); - + Np_info = max(24, (Ninfo>>n)<= Np_info){ + if (Tbstable_nr[i] >= Np_info){ nr_tbs = Tbstable_nr[i]; break; } } } else { - n = floor(log2(Ninfo-24)) - 5; - Np_info = max(3840, pow(2,n) * round((Ninfo - 24)/pow(2,n))); + n = log2(Ninfo-24)-5; + Np_info = max(3840, (ROUNDIDIV((Ninfo-24),(1< 8424){ - C = ceil( (Np_info + 24)/8424 ); - nr_tbs = (uint32_t)(8 * C * ceil( (Np_info + 24)/(8*C) ) - 24); + C = CEILIDIV((Np_info+24),8424); + nr_tbs = (C<<3)*CEILIDIV((Np_info+24),(C<<3)) - 24; } else { - nr_tbs = (uint32_t)(8 * ceil( (Np_info + 24)/8 ) - 24); - //printf("n %lf Np_info %f pow %f ceil %f \n",n, Np_info,pow(2,6),ceil( (Np_info + 24)/8 )); + nr_tbs = ((CEILIDIV((Np_info+24),8))<<3) - 24; } } } + //printf("Ninfo %d nbp_re %d nb_re %d Qm %d, R %d, tbs %d\n", Ninfo, nbp_re, nb_re, Qm, R, nr_tbs); + return nr_tbs; +} - return nr_tbs; + +//tbslbrm calculation according to 5.4.2.1 of 38.212 +uint32_t nr_compute_tbslbrm(uint16_t table, + uint16_t nb_rb, + uint8_t Nl, + uint8_t C) +{ + + uint16_t R, nb_re; + uint16_t nb_rb_lbrm=0; + uint8_t Qm; + int i; + uint32_t nr_tbs=0; + uint32_t Ninfo, Np_info; + uint8_t n; + + for (i=0; i<7; i++) { + if (NPRB_LBRM[i] >= nb_rb){ + nb_rb_lbrm = NPRB_LBRM[i]; + break; + } + } + + Qm = ((table == 1)? 8 : 6); + R = 948; + nb_re = 156 * nb_rb_lbrm; + + // Intermediate number of information bits + Ninfo = (nb_re * R * Qm * Nl)>>10; + + if (Ninfo <=3824) { + n = max(3, floor(log2(Ninfo)) - 6); + Np_info = max(24, (Ninfo>>n)<= Np_info){ + nr_tbs = Tbstable_nr[i]; + break; + } + } + } + else { + n = log2(Ninfo-24)-5; + Np_info = max(3840, (ROUNDIDIV((Ninfo-24),(1< 8424){ + nr_tbs = (C<<3)*CEILIDIV((Np_info+24),(C<<3)) - 24; + } + else { + nr_tbs = ((CEILIDIV((Np_info+24),8))<<3) - 24; + } + + } + + } + return nr_tbs; + } diff --git a/openair1/PHY/CODING/nr_rate_matching.c b/openair1/PHY/CODING/nr_rate_matching.c index 0954939a58..9d50b4678b 100644 --- a/openair1/PHY/CODING/nr_rate_matching.c +++ b/openair1/PHY/CODING/nr_rate_matching.c @@ -206,3 +206,4 @@ int nr_rate_matching_ldpc_rx(uint8_t Ilbrm, return 0; } + diff --git a/openair1/PHY/CODING/nr_segmentation.c b/openair1/PHY/CODING/nr_segmentation.c index 421f440ec2..90586e24d4 100644 --- a/openair1/PHY/CODING/nr_segmentation.c +++ b/openair1/PHY/CODING/nr_segmentation.c @@ -35,55 +35,65 @@ int32_t nr_segmentation(unsigned char *input_buffer, unsigned int *C, unsigned int *K, unsigned int *Zout, // [hna] Zout is Zc - unsigned int *F) + unsigned int *F, + uint8_t BG) { - unsigned int L,Bprime,Bprime_by_C,Z,r,Kb,k,s,crc,Kprime; + unsigned int L,Bprime,Z,r,Kcb,Kb,k,s,crc,Kprime; - if (B<=8448) { + if (BG==1) + Kcb=8448; + else + Kcb=3840; + + if (B<=Kcb) { L=0; *C=1; Bprime=B; } else { L=24; - *C = B/(8448-L); + *C = B/(Kcb-L); - if ((8448-L)*(*C) < B) + if ((Kcb-L)*(*C) < B) *C=*C+1; Bprime = B+((*C)*L); #ifdef DEBUG_SEGMENTATION - printf("Bprime %d\n",Bprime); + printf("Bprime %u\n",Bprime); #endif } if ((*C)>MAX_NUM_DLSCH_SEGMENTS) { - LOG_E(PHY,"nr_segmentation.c: too many segments %d, B %d, L %d, Bprime %d\n",*C,B,L,Bprime); + LOG_E(PHY,"nr_segmentation.c: too many segments %d, B %d, L %d, Bprime %d\n",*C,B,L,Bprime); return(-1); } // Find K+ - Bprime_by_C = Bprime/(*C); - if (Bprime <=192) { - Kb = 6; - } else if (Bprime <=560) { - Kb = 8; - } else if (Bprime <=640) { - Kb = 9; - } else if (Bprime <=3840) { - Kb = 10;; - } else { - Kb = 22; + Kprime = Bprime/(*C); + + if (BG==1) + Kb = 22; + else { + if (B > 640) { + Kb = 10; + } else if (B > 560) { + Kb = 9; + } else if (B > 192) { + Kb = 8; + } + else { + Kb = 6; + } } -if ((Bprime_by_C%Kb) > 0) - Z = (Bprime_by_C/Kb)+1; +if ((Kprime%Kb) > 0) + Z = (Kprime/Kb)+1; else - Z = (Bprime_by_C/Kb); + Z = (Kprime/Kb); #ifdef DEBUG_SEGMENTATION - printf("nr segmetation B %d Bprime %d Bprime_by_C %d z %d \n", B, Bprime, Bprime_by_C, Z); + printf("nr segmetation B %u Bprime %u Kprime %u z %u \n", B, Bprime, Kprime, Z); #endif if (Z <= 2) { @@ -110,7 +120,7 @@ else *K = *K + 8; #ifdef DEBUG_SEGMENTATION - printf("Z_by_C %d , K2 %d\n",Z,*K); + printf("Z_by_C %u , K2 %u\n",Z,*K); #endif } else if (Z <= 256) { // increase by 4 bytes til here *K = (Z>>4)<<4; @@ -128,14 +138,19 @@ else //msg("nr_segmentation.c: Illegal codeword size !!!\n"); return -1; } - *Zout = *K; - *K = *K*Kb; - *F = ((*K) - Bprime_by_C); + *Zout = *K; + + if(BG==1) + *K = *K*22; + else + *K = *K*10; + + *F = ((*K) - Kprime); #ifdef DEBUG_SEGMENTATION - printf("final nr seg output Z %d K %d F %d \n", *Zout, *K, *F); - printf("C %d, K %d, Bprime_bytes %d, Bprime %d, F %d\n",*C,*K,Bprime>>3,Bprime,*F); + printf("final nr seg output Z %u K %u F %u \n", *Zout, *K, *F); + printf("C %u, K %u, Bprime_bytes %u, Bprime %u, F %u\n",*C,*K,Bprime>>3,Bprime,*F); #endif if ((input_buffer) && (output_buffers)) { @@ -145,7 +160,6 @@ else for (r=0; r<*C; r++) { k = 0; - Kprime = Bprime_by_C; while (k<((Kprime - L)>>3)) { output_buffers[r][k] = input_buffer[s]; @@ -154,6 +168,13 @@ else s++; } + if (*C > 1) { // add CRC + crc = crc24b(output_buffers[r],Kprime-L)>>8; + output_buffers[r][(Kprime-L)>>3] = ((uint8_t*)&crc)[2]; + output_buffers[r][1+((Kprime-L)>>3)] = ((uint8_t*)&crc)[1]; + output_buffers[r][2+((Kprime-L)>>3)] = ((uint8_t*)&crc)[0]; + } + if (*F>0) { for (k=Kprime>>3; k<(*K)>>3; k++) { output_buffers[r][k] = 0; @@ -161,16 +182,10 @@ else } } - if (*C > 1) { // add CRC - crc = crc24b(output_buffers[r],Kprime-L)>>8; - output_buffers[r][(Kprime-L)>>3] = ((uint8_t*)&crc)[2]; - output_buffers[r][1+((Kprime-L)>>3)] = ((uint8_t*)&crc)[1]; - output_buffers[r][2+((Kprime-L)>>3)] = ((uint8_t*)&crc)[0]; - } } } - return 0; + return Kb; } diff --git a/openair1/PHY/INIT/nr_init.c b/openair1/PHY/INIT/nr_init.c index b1711acc58..b6603ca349 100644 --- a/openair1/PHY/INIT/nr_init.c +++ b/openair1/PHY/INIT/nr_init.c @@ -19,6 +19,7 @@ * contact@openairinterface.org */ +#include "executables/nr-softmodem-common.h" #include "PHY/defs_gNB.h" #include "PHY/phy_extern.h" #include "PHY/NR_REFSIG/nr_refsig.h" @@ -30,7 +31,7 @@ #include "TDD-Config.h" #include "MBSFN-SubframeConfigList.h"*/ #include "openair1/PHY/defs_RU.h" -#include "LAYER2/MAC/mac_extern.h" +#include "LAYER2/NR_MAC_gNB/mac_proto.h" #include "assertions.h" #include @@ -38,6 +39,7 @@ #include "PHY/NR_REFSIG/nr_refsig.h" #include "SCHED_NR/fapi_nr_l1.h" #include "openair2/LAYER2/NR_MAC_gNB/mac_proto.h" +#include "nfapi_nr_interface.h" /* extern uint32_t from_nrarfcn(int nr_bandP,uint32_t dl_nrarfcn); @@ -200,6 +202,7 @@ int phy_init_nr_gNB(PHY_VARS_gNB *gNB, for (int ulsch_id=0; ulsch_idrxdataF_ext = (int32_t **)malloc16( 2*sizeof(int32_t *) ); pusch_vars[ulsch_id]->rxdataF_ext2 = (int32_t **)malloc16( 2*sizeof(int32_t *) ); @@ -219,6 +222,35 @@ int phy_init_nr_gNB(PHY_VARS_gNB *gNB, pusch_vars[ulsch_id]->rxdataF_comp[i] = (int32_t *)malloc16_clear( sizeof(int32_t)*cfg->rf_config.ul_carrier_bandwidth.value*12*fp->symbols_per_slot ); pusch_vars[ulsch_id]->ul_ch_mag[i] = (int32_t *)malloc16_clear( fp->symbols_per_slot*sizeof(int32_t)*cfg->rf_config.ul_carrier_bandwidth.value*12 ); pusch_vars[ulsch_id]->ul_ch_magb[i] = (int32_t *)malloc16_clear( fp->symbols_per_slot*sizeof(int32_t)*cfg->rf_config.ul_carrier_bandwidth.value*12 ); +======= + pusch_vars[UE_id] = (NR_gNB_PUSCH *)malloc16_clear( sizeof(NR_gNB_PUSCH) ); + pusch_vars[UE_id]->rxdataF_ext = (int32_t **)malloc16( fp->nb_antennas_rx*sizeof(int32_t *) ); + pusch_vars[UE_id]->rxdataF_ext2 = (int32_t **)malloc16( fp->nb_antennas_rx*sizeof(int32_t *) ); + pusch_vars[UE_id]->ul_ch_estimates = (int32_t **)malloc16( fp->nb_antennas_rx*sizeof(int32_t *) ); + pusch_vars[UE_id]->ul_ch_estimates_ext = (int32_t **)malloc16( fp->nb_antennas_rx*sizeof(int32_t *) ); + pusch_vars[UE_id]->ul_ch_estimates_time = (int32_t **)malloc16( fp->nb_antennas_rx*sizeof(int32_t *) ); + pusch_vars[UE_id]->rxdataF_comp = (int32_t **)malloc16( fp->nb_antennas_rx*sizeof(int32_t *) ); + pusch_vars[UE_id]->ul_ch_mag0 = (int32_t **)malloc16( fp->nb_antennas_rx*sizeof(int32_t *) ); + pusch_vars[UE_id]->ul_ch_magb0 = (int32_t **)malloc16( fp->nb_antennas_rx*sizeof(int32_t *) ); + pusch_vars[UE_id]->ul_ch_mag = (int32_t **)malloc16( fp->nb_antennas_rx*sizeof(int32_t *) ); + pusch_vars[UE_id]->ul_ch_magb = (int32_t **)malloc16( fp->nb_antennas_rx*sizeof(int32_t *) ); + pusch_vars[UE_id]->rho = (int32_t **)malloc16_clear( fp->nb_antennas_rx*sizeof(int32_t*) ); + + for (i=0; inb_antennas_rx; i++) { + // RK 2 times because of output format of FFT! + // FIXME We should get rid of this + pusch_vars[UE_id]->rxdataF_ext[i] = (int32_t *)malloc16_clear( sizeof(int32_t)*cfg->rf_config.ul_carrier_bandwidth.value*12*fp->symbols_per_slot ); + pusch_vars[UE_id]->rxdataF_ext2[i] = (int32_t *)malloc16_clear( sizeof(int32_t)*cfg->rf_config.ul_carrier_bandwidth.value*12*fp->symbols_per_slot ); + pusch_vars[UE_id]->ul_ch_estimates[i] = (int32_t *)malloc16_clear( sizeof(int32_t)*cfg->rf_config.ul_carrier_bandwidth.value*12*fp->symbols_per_slot ); + pusch_vars[UE_id]->ul_ch_estimates_ext[i] = (int32_t *)malloc16_clear( sizeof(int32_t)*cfg->rf_config.ul_carrier_bandwidth.value*12*fp->symbols_per_slot ); + pusch_vars[UE_id]->ul_ch_estimates_time[i] = (int32_t *)malloc16_clear( 2*sizeof(int32_t)*fp->ofdm_symbol_size ); + pusch_vars[UE_id]->rxdataF_comp[i] = (int32_t *)malloc16_clear( sizeof(int32_t)*cfg->rf_config.ul_carrier_bandwidth.value*12*fp->symbols_per_slot ); + pusch_vars[UE_id]->ul_ch_mag0[i] = (int32_t *)malloc16_clear( fp->symbols_per_slot*sizeof(int32_t)*cfg->rf_config.ul_carrier_bandwidth.value*12 ); + pusch_vars[UE_id]->ul_ch_magb0[i] = (int32_t *)malloc16_clear( fp->symbols_per_slot*sizeof(int32_t)*cfg->rf_config.ul_carrier_bandwidth.value*12 ); + pusch_vars[UE_id]->ul_ch_mag[i] = (int32_t *)malloc16_clear( fp->symbols_per_slot*sizeof(int32_t)*cfg->rf_config.ul_carrier_bandwidth.value*12 ); + pusch_vars[UE_id]->ul_ch_magb[i] = (int32_t *)malloc16_clear( fp->symbols_per_slot*sizeof(int32_t)*cfg->rf_config.ul_carrier_bandwidth.value*12 ); + pusch_vars[UE_id]->rho[i] = (int32_t *)malloc16_clear( sizeof(int32_t)*(fp->N_RB_UL*12*7*2) ); +>>>>>>> origin/develop-nr } pusch_vars[ulsch_id]->llr = (int16_t *)malloc16_clear( (8*((3*8*6144)+12))*sizeof(int16_t) ); // [hna] 6144 is LTE and (8*((3*8*6144)+12)) is not clear @@ -279,7 +311,7 @@ void phy_free_nr_gNB(PHY_VARS_gNB *gNB) //NR_DL_FRAME_PARMS* const fp = &gNB->frame_parms; //nfapi_nr_config_request_t *cfg = &gNB->gNB_config; NR_gNB_COMMON *const common_vars = &gNB->common_vars; - //NR_gNB_PUSCH **const pusch_vars = gNB->pusch_vars; + NR_gNB_PUSCH **const pusch_vars = gNB->pusch_vars; /*LTE_eNB_SRS *const srs_vars = gNB->srs_vars; LTE_eNB_PRACH *const prach_vars = &gNB->prach_vars;*/ uint32_t ***pdcch_dmrs = gNB->nr_gold_pdcch_dmrs; @@ -315,29 +347,38 @@ void phy_free_nr_gNB(PHY_VARS_gNB *gNB) free_and_zero(prach_vars->prach_ifft[0]); free_and_zero(prach_vars->rxsigF[0]); - - for (UE_id=0; UE_idrxdataF_ext[i]); free_and_zero(pusch_vars[UE_id]->rxdataF_ext2[i]); - free_and_zero(pusch_vars[UE_id]->drs_ch_estimates[i]); - free_and_zero(pusch_vars[UE_id]->drs_ch_estimates_time[i]); + free_and_zero(pusch_vars[UE_id]->ul_ch_estimates[i]); + free_and_zero(pusch_vars[UE_id]->ul_ch_estimates_ext[i]); + free_and_zero(pusch_vars[UE_id]->ul_ch_estimates_time[i]); free_and_zero(pusch_vars[UE_id]->rxdataF_comp[i]); + free_and_zero(pusch_vars[UE_id]->ul_ch_mag0[i]); + free_and_zero(pusch_vars[UE_id]->ul_ch_magb0[i]); free_and_zero(pusch_vars[UE_id]->ul_ch_mag[i]); free_and_zero(pusch_vars[UE_id]->ul_ch_magb[i]); + free_and_zero(pusch_vars[UE_id]->rho[i]); } free_and_zero(pusch_vars[UE_id]->rxdataF_ext); free_and_zero(pusch_vars[UE_id]->rxdataF_ext2); - free_and_zero(pusch_vars[UE_id]->drs_ch_estimates); - free_and_zero(pusch_vars[UE_id]->drs_ch_estimates_time); + free_and_zero(pusch_vars[UE_id]->ul_ch_estimates); + free_and_zero(pusch_vars[UE_id]->ul_ch_estimates_ext); + free_and_zero(pusch_vars[UE_id]->ul_ch_estimates_time); free_and_zero(pusch_vars[UE_id]->rxdataF_comp); + free_and_zero(pusch_vars[UE_id]->ul_ch_mag0); + free_and_zero(pusch_vars[UE_id]->ul_ch_magb0); free_and_zero(pusch_vars[UE_id]->ul_ch_mag); free_and_zero(pusch_vars[UE_id]->ul_ch_magb); + free_and_zero(pusch_vars[UE_id]->rho); + free_and_zero(pusch_vars[UE_id]->llr); free_and_zero(pusch_vars[UE_id]); } //UE_id - +/* for (UE_id = 0; UE_id < NUMBER_OF_UE_MAX; UE_id++) gNB->UE_stats_ptr[UE_id] = NULL; */ } @@ -402,23 +443,31 @@ void nr_phy_config_request(NR_PHY_Config_t *phy_config) { gNB_config->sch_config.ssb_periodicity.value = phy_config->cfg->sch_config.ssb_periodicity.value; if (phy_config->cfg->subframe_config.duplex_mode.value == 0) { - gNB_config->subframe_config.duplex_mode.value = TDD; - } else { gNB_config->subframe_config.duplex_mode.value = FDD; + } else { + gNB_config->subframe_config.duplex_mode.value = TDD; } memcpy((void*)&gNB_config->rach_config,(void*)&phy_config->cfg->rach_config,sizeof(phy_config->cfg->rach_config)); RC.gNB[Mod_id]->mac_enabled = 1; fp->dl_CarrierFreq = from_nrarfcn(gNB_config->nfapi_config.rf_bands.rf_band[0],gNB_config->nfapi_config.nrarfcn.value); +<<<<<<< HEAD fp->ul_CarrierFreq = fp->dl_CarrierFreq - (get_nr_uldl_offset(gNB_config->nfapi_config.rf_bands.rf_band[0])*100000); LOG_I(PHY,"Configuring MIB for instance %d, : (band %d,N_RB_DL %d, N_RB_UL %d, Nid_cell %d,DL freq %u)\n", +======= + get_band(fp->dl_CarrierFreq, &gNB_config->nfapi_config.rf_bands.rf_band[0], &uplink_frequency_offset[CC_id][0], &fp->frame_type); + fp->ul_CarrierFreq = fp->dl_CarrierFreq + uplink_frequency_offset[CC_id][0]; + fp->threequarter_fs = openair0_cfg[0].threequarter_fs; + LOG_I(PHY,"Configuring MIB for instance %d, CCid %d : (band %d,N_RB_DL %d, N_RB_UL %d, Nid_cell %d,DL freq %u, UL freq %u)\n", +>>>>>>> origin/develop-nr Mod_id, gNB_config->nfapi_config.rf_bands.rf_band[0], gNB_config->rf_config.dl_carrier_bandwidth.value, gNB_config->rf_config.ul_carrier_bandwidth.value, gNB_config->sch_config.physical_cell_id.value, - fp->dl_CarrierFreq ); + fp->dl_CarrierFreq, + fp->ul_CarrierFreq); nr_init_frame_parms(gNB_config, fp); @@ -478,6 +527,27 @@ void init_nr_transport(PHY_VARS_gNB *gNB) { LOG_E(PHY,"Can't get gNB ulsch structures\n"); exit(-1); } + + LOG_I(PHY,"Initializing nFAPI for ULSCH, UE %d\n",i); + // [hna] added here for RT implementation + uint8_t harq_pid = 0; + nfapi_nr_ul_config_ulsch_pdu *rel15_ul = &gNB->ulsch[i+1][j]->harq_processes[harq_pid]->ulsch_pdu; + + // --------- setting rel15_ul parameters ---------- + rel15_ul->rnti = 0x1234; + rel15_ul->ulsch_pdu_rel15.start_rb = 0; + rel15_ul->ulsch_pdu_rel15.number_rbs = 50; + rel15_ul->ulsch_pdu_rel15.start_symbol = 2; + rel15_ul->ulsch_pdu_rel15.number_symbols = 12; + rel15_ul->ulsch_pdu_rel15.nb_re_dmrs = 6; + rel15_ul->ulsch_pdu_rel15.length_dmrs = 1; + rel15_ul->ulsch_pdu_rel15.Qm = 2; + rel15_ul->ulsch_pdu_rel15.R = 679; + rel15_ul->ulsch_pdu_rel15.mcs = 9; + rel15_ul->ulsch_pdu_rel15.rv = 0; + rel15_ul->ulsch_pdu_rel15.n_layers = 1; + /////////////////////////////////////////////////// + ////////////////////////////////////////////////////////////////////////// } diff --git a/openair1/PHY/INIT/nr_init_ue.c b/openair1/PHY/INIT/nr_init_ue.c index cd0620012f..ffc852d86b 100644 --- a/openair1/PHY/INIT/nr_init_ue.c +++ b/openair1/PHY/INIT/nr_init_ue.c @@ -877,6 +877,7 @@ int init_nr_ue_signal(PHY_VARS_NR_UE *ue, pbch_vars[eNB_id]->rxdataF_comp = (int32_t **)malloc16_clear( 8*sizeof(int32_t *) ); pbch_vars[eNB_id]->dl_ch_estimates = (int32_t **)malloc16_clear( 8*sizeof(int32_t *) ); pbch_vars[eNB_id]->dl_ch_estimates_ext = (int32_t **)malloc16_clear( 8*sizeof(int32_t *) ); + pbch_vars[eNB_id]->dl_ch_estimates_time = (int32_t **)malloc16_clear( 8*sizeof(int32_t *) ); pbch_vars[eNB_id]->llr = (int16_t *)malloc16_clear( 1920 ); // prach_vars[eNB_id]->prachF = (int16_t *)malloc16_clear( sizeof(int)*(7*2*sizeof(int)*(fp->ofdm_symbol_size*12)) ); prach_vars[eNB_id]->prach = (int16_t *)malloc16_clear( sizeof(int)*(7*2*sizeof(int)*(fp->ofdm_symbol_size*12)) ); @@ -888,6 +889,7 @@ int init_nr_ue_signal(PHY_VARS_NR_UE *ue, int idx = (j<<1)+i; pbch_vars[eNB_id]->rxdataF_comp[idx] = (int32_t *)malloc16_clear( sizeof(int32_t)*20*12*4 ); pbch_vars[eNB_id]->dl_ch_estimates[idx] = (int32_t *)malloc16_clear( sizeof(int32_t)*7*2*sizeof(int)*(fp->ofdm_symbol_size) ); + pbch_vars[eNB_id]->dl_ch_estimates_time[idx]= (int32_t *)malloc16_clear( sizeof(int32_t)*7*2*sizeof(int)*(fp->ofdm_symbol_size) ); pbch_vars[eNB_id]->dl_ch_estimates_ext[idx] = (int32_t *)malloc16_clear( sizeof(int32_t)*20*12*4 ); } } diff --git a/openair1/PHY/INIT/nr_parms.c b/openair1/PHY/INIT/nr_parms.c index 00b2b6a7da..81785872f9 100644 --- a/openair1/PHY/INIT/nr_parms.c +++ b/openair1/PHY/INIT/nr_parms.c @@ -79,6 +79,32 @@ int nr_get_ssb_start_symbol(NR_DL_FRAME_PARMS *fp, uint8_t i_ssb, uint8_t half_f return symbol; } +int nr_is_ssb_slot(nfapi_nr_config_request_t *cfg, int slot) +{ + + uint8_t n_hf; + int rel_slot; + + n_hf = cfg->sch_config.half_frame_index.value; + + // if SSB periodicity is 5ms, they are transmitted in both half frames + if ( cfg->sch_config.ssb_periodicity.value == 5) { + if (slot<10) + n_hf=0; + else + n_hf=1; + } + + // to set a effective slot number between 0 to 9 in the half frame where the SSB is supposed to be + rel_slot = (n_hf)? (slot-10) : slot; + + if(rel_slot<10 && rel_slot>=0) + return 1; + else + return 0; + +} + int nr_init_frame_parms0(NR_DL_FRAME_PARMS *fp, int mu, @@ -224,6 +250,8 @@ int nr_init_frame_parms0(NR_DL_FRAME_PARMS *fp, fp->slots_per_frame = 10* fp->slots_per_subframe; fp->nb_antenna_ports_eNB = 1; // default value until overwritten by RRCConnectionReconfiguration + fp->nb_antennas_rx = 1; // default value until overwritten by RRCConnectionReconfiguration + fp->nb_antennas_tx = 1; // default value until overwritten by RRCConnectionReconfiguration fp->symbols_per_slot = ((Ncp == NORMAL)? 14 : 12); // to redefine for different slot formats fp->samples_per_subframe_wCP = fp->ofdm_symbol_size * fp->symbols_per_slot * fp->slots_per_subframe; @@ -254,7 +282,7 @@ int nr_init_frame_parms(nfapi_nr_config_request_t* config, { fp->eutra_band = config->nfapi_config.rf_bands.rf_band[0]; - fp->frame_type = !(config->subframe_config.duplex_mode.value); + fp->frame_type = config->subframe_config.duplex_mode.value; fp->L_ssb = config->sch_config.ssb_scg_position_in_burst.value; return nr_init_frame_parms0(fp, config->subframe_config.numerology_index_mu.value, @@ -286,6 +314,8 @@ void nr_dump_frame_parms(NR_DL_FRAME_PARMS *fp) LOG_I(PHY,"fp->samples_per_frame_wCP=%d\n",fp->samples_per_frame_wCP); LOG_I(PHY,"fp->samples_per_subframe=%d\n",fp->samples_per_subframe); LOG_I(PHY,"fp->samples_per_frame=%d\n",fp->samples_per_frame); + LOG_I(PHY,"fp->dl_CarrierFreq=%u\n",fp->dl_CarrierFreq); + LOG_I(PHY,"fp->ul_CarrierFreq=%u\n",fp->ul_CarrierFreq); } diff --git a/openair1/PHY/INIT/phy_init.h b/openair1/PHY/INIT/phy_init.h index e136e8a770..7e0500b56c 100644 --- a/openair1/PHY/INIT/phy_init.h +++ b/openair1/PHY/INIT/phy_init.h @@ -378,6 +378,7 @@ void phy_config_request(PHY_Config_t *phy_config); int init_frame_parms(LTE_DL_FRAME_PARMS *frame_parms,uint8_t osf); void dump_frame_parms(LTE_DL_FRAME_PARMS *frame_parms); int nr_get_ssb_start_symbol(NR_DL_FRAME_PARMS *fp, uint8_t i_ssb, uint8_t half_frame_index); +int nr_is_ssb_slot(nfapi_nr_config_request_t *cfg, int slot); int nr_init_frame_parms(nfapi_nr_config_request_t *config, NR_DL_FRAME_PARMS *frame_parms); int nr_init_frame_parms_ue(NR_DL_FRAME_PARMS *frame_parms,int mu,int Ncp,int N_RB_DL,int n_ssb_crb,int ssb_subcarrier_offset); int init_nr_ue_signal(PHY_VARS_NR_UE *ue,int nb_connected_eNB,uint8_t abstraction_flag); diff --git a/openair1/PHY/LTE_ESTIMATION/lte_ul_channel_estimation.c b/openair1/PHY/LTE_ESTIMATION/lte_ul_channel_estimation.c index 3c54e0bd28..cb001f9dc4 100644 --- a/openair1/PHY/LTE_ESTIMATION/lte_ul_channel_estimation.c +++ b/openair1/PHY/LTE_ESTIMATION/lte_ul_channel_estimation.c @@ -788,8 +788,9 @@ int16_t lte_ul_freq_offset_estimation(LTE_DL_FRAME_PARMS *frame_parms, int16_t Ravg[2]; Ravg[0]=0; Ravg[1]=0; - int16_t iv, rv, phase_idx; - __m128i avg128U1, avg128U2, R[3], mmtmpD0,mmtmpD1,mmtmpD2,mmtmpD3; + int16_t iv, rv, phase_idx = 0; + __m128i avg128U1, avg128U2, R[3], mmtmpD0, mmtmpD1, mmtmpD2, mmtmpD3; + // round(tan((pi/4)*[1:1:N]/N)*pow2(15)) int16_t alpha[128] = {201, 402, 603, 804, 1006, 1207, 1408, 1610, 1811, 2013, 2215, 2417, 2619, 2822, 3024, 3227, 3431, 3634, 3838, 4042, 4246, 4450, 4655, 4861, 5066, 5272, 5479, 5686, 5893, 6101, 6309, 6518, 6727, 6937, 7147, 7358, 7570, 7782, 7995, 8208, 8422, 8637, 8852, 9068, 9285, 9503, 9721, 9940, 10160, 10381, 10603, 10825, 11049, 11273, 11498, 11725, 11952, 12180, 12410, 12640, 12872, 13104, 13338, 13573, 13809, 14046, 14285, 14525, 14766, 15009, 15253, 15498, 15745, 15993, 16243, 16494, 16747, 17001, 17257, 17515, 17774, 18035, 18298, 18563, 18829, 19098, 19368, 19640, 19915, 20191, 20470, 20750, 21033, 21318, 21605, 21895, 22187, 22481, 22778, 23078, 23380, 23685, 23992, 24302, 24615, 24931, 25250, 25572, 25897, 26226, 26557, 26892, 27230, 27572, 27917, 28266, 28618, 28975, 29335, 29699, 30067, 30440, 30817, 31198, 31583, 31973, 32368, 32767}; // compute log2_maxh (output_shift) diff --git a/openair1/PHY/LTE_TRANSPORT/dci_tools.c b/openair1/PHY/LTE_TRANSPORT/dci_tools.c index 4d296a7872..2b6d998b73 100644 --- a/openair1/PHY/LTE_TRANSPORT/dci_tools.c +++ b/openair1/PHY/LTE_TRANSPORT/dci_tools.c @@ -2001,6 +2001,11 @@ void fill_ulsch(PHY_VARS_eNB *eNB,int UE_id,nfapi_ul_config_ulsch_pdu *ulsch_pdu ulsch->ue_type = ulsch_pdu->ulsch_pdu_rel13.ue_type; AssertFatal(harq_pid ==0 || ulsch->ue_type == NOCE, "Harq PID is not zero for BL/CE UE\n"); + if(ulsch_pdu->ulsch_pdu_rel13.repetition_number >1) // Fill the Harq process parameters in the first Rep only + { + return; + } + //AssertFatal(ulsch->harq_processes[harq_pid]->nb_rb>0,"nb_rb = 0\n"); if(ulsch->harq_processes[harq_pid]->nb_rb == 0) { LOG_E(PHY, "fill_ulsch UE_id %d nb_rb = 0\n", UE_id); @@ -2009,6 +2014,10 @@ void fill_ulsch(PHY_VARS_eNB *eNB,int UE_id,nfapi_ul_config_ulsch_pdu *ulsch_pdu ulsch->harq_processes[harq_pid]->frame = frame; ulsch->harq_processes[harq_pid]->subframe = subframe; ulsch->harq_processes[harq_pid]->handled = 0; +#if (LTE_RRC_VERSION >= MAKE_VERSION(14, 0, 0)) + ulsch->harq_processes[harq_pid]->repetition_number = ulsch_pdu->ulsch_pdu_rel13.repetition_number ; + ulsch->harq_processes[harq_pid]->total_number_of_repetitions = ulsch_pdu->ulsch_pdu_rel13.total_number_of_repetitions ; +#endif ulsch->harq_processes[harq_pid]->first_rb = ulsch_pdu->ulsch_pdu_rel8.resource_block_start; ulsch->harq_processes[harq_pid]->nb_rb = ulsch_pdu->ulsch_pdu_rel8.number_of_resource_blocks; ulsch->harq_processes[harq_pid]->dci_alloc = 1; diff --git a/openair1/PHY/LTE_TRANSPORT/dlsch_coding.c b/openair1/PHY/LTE_TRANSPORT/dlsch_coding.c index 80e7b6f8cd..6595158f1a 100644 --- a/openair1/PHY/LTE_TRANSPORT/dlsch_coding.c +++ b/openair1/PHY/LTE_TRANSPORT/dlsch_coding.c @@ -42,6 +42,7 @@ #include "common/utils/LOG/log.h" #include "targets/RT/USER/lte-softmodem.h" #include +#include "executables/thread-common.h" //#define DEBUG_DLSCH_CODING //#define DEBUG_DLSCH_FREE 1 @@ -57,9 +58,8 @@ uint64_t runtime, uint64_t deadline, uint64_t period);*/ -extern WORKER_CONF_t get_thread_worker_conf(void); -extern volatile int oai_exit; +extern volatile int oai_exit; void free_eNB_dlsch(LTE_eNB_DLSCH_t *dlsch) { int i, r, aa, layer; @@ -99,7 +99,14 @@ void free_eNB_dlsch(LTE_eNB_DLSCH_t *dlsch) { } } -LTE_eNB_DLSCH_t *new_eNB_dlsch(unsigned char Kmimo,unsigned char Mdlharq,uint32_t Nsoft,unsigned char N_RB_DL, uint8_t abstraction_flag, LTE_DL_FRAME_PARMS *frame_parms) { + +LTE_eNB_DLSCH_t *new_eNB_dlsch(unsigned char Kmimo, + unsigned char Mdlharq, + uint32_t Nsoft, + unsigned char N_RB_DL, + uint8_t abstraction_flag, + LTE_DL_FRAME_PARMS *frame_parms) +{ LTE_eNB_DLSCH_t *dlsch; unsigned char exit_flag = 0,i,j,r,aa,layer; int re; @@ -221,6 +228,7 @@ LTE_eNB_DLSCH_t *new_eNB_dlsch(unsigned char Kmimo,unsigned char Mdlharq,uint32_ return(NULL); } + void clean_eNb_dlsch(LTE_eNB_DLSCH_t *dlsch) { unsigned char Mdlharq; unsigned char i,j,r; @@ -257,8 +265,6 @@ void clean_eNb_dlsch(LTE_eNB_DLSCH_t *dlsch) { } - - int dlsch_encoding_2threads0(te_params *tep) { LTE_eNB_DLSCH_t *dlsch = tep->dlsch; unsigned int G = tep->G; @@ -358,7 +364,6 @@ void *te_thread(void *param) { } - int dlsch_encoding_2threads(PHY_VARS_eNB *eNB, unsigned char *a, uint8_t num_pdcch_symbols, @@ -548,6 +553,8 @@ int dlsch_encoding_2threads(PHY_VARS_eNB *eNB, VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_ENB_DLSCH_ENCODING, VCD_FUNCTION_OUT); return(0); } + + int dlsch_encoding_all(PHY_VARS_eNB *eNB, unsigned char *a, uint8_t num_pdcch_symbols, @@ -812,10 +819,3 @@ int dlsch_encoding(PHY_VARS_eNB *eNB, VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_ENB_DLSCH_ENCODING, VCD_FUNCTION_OUT); return(0); } - - - - - - - diff --git a/openair1/PHY/LTE_TRANSPORT/lte_mcs.c b/openair1/PHY/LTE_TRANSPORT/lte_mcs.c index 48951ffdd0..c13876f29a 100644 --- a/openair1/PHY/LTE_TRANSPORT/lte_mcs.c +++ b/openair1/PHY/LTE_TRANSPORT/lte_mcs.c @@ -118,8 +118,7 @@ uint32_t get_TBS_UL(uint8_t mcs, uint16_t nb_rb) { } } - -int adjust_G2(LTE_DL_FRAME_PARMS *frame_parms,uint32_t *rb_alloc,uint8_t mod_order,uint8_t subframe,uint8_t symbol) { +int adjust_G2(LTE_DL_FRAME_PARMS *frame_parms, uint32_t *rb_alloc, uint8_t mod_order, uint8_t subframe, uint8_t symbol) { int rb,re_pbch_sss=0; int rb_alloc_ind,nsymb; nsymb = (frame_parms->Ncp==NORMAL) ? 14 : 12; @@ -205,7 +204,7 @@ int adjust_G2(LTE_DL_FRAME_PARMS *frame_parms,uint32_t *rb_alloc,uint8_t mod_ord return(re_pbch_sss); } -int adjust_G(LTE_DL_FRAME_PARMS *frame_parms,uint32_t *rb_alloc,uint8_t mod_order,uint8_t subframe) { +int adjust_G(LTE_DL_FRAME_PARMS *frame_parms, uint32_t *rb_alloc, uint8_t mod_order, uint8_t subframe) { int rb,re_pbch_sss=0; uint8_t rb_alloc_ind; @@ -286,7 +285,16 @@ int adjust_G(LTE_DL_FRAME_PARMS *frame_parms,uint32_t *rb_alloc,uint8_t mod_orde return(0); } -int get_G(LTE_DL_FRAME_PARMS *frame_parms,uint16_t nb_rb,uint32_t *rb_alloc,uint8_t mod_order,uint8_t Nl,uint8_t num_pdcch_symbols,int frame,uint8_t subframe,uint8_t beamforming_mode) { +int get_G(LTE_DL_FRAME_PARMS *frame_parms, + uint16_t nb_rb, + uint32_t *rb_alloc, + uint8_t mod_order, + uint8_t Nl, + uint8_t num_pdcch_symbols, + int frame, + uint8_t subframe, + uint8_t beamforming_mode) +{ int G_adj; if (is_pmch_subframe(frame,subframe,frame_parms) == 0) { @@ -319,8 +327,16 @@ int get_G(LTE_DL_FRAME_PARMS *frame_parms,uint16_t nb_rb,uint32_t *rb_alloc,uint } } - -int get_G_khz_1dot25(LTE_DL_FRAME_PARMS *frame_parms,uint16_t nb_rb,uint32_t *rb_alloc,uint8_t mod_order,uint8_t Nl,uint8_t num_pdcch_symbols,int frame,uint8_t subframe,uint8_t beamforming_mode) { +int get_G_khz_1dot25(LTE_DL_FRAME_PARMS *frame_parms, + uint16_t nb_rb, + uint32_t *rb_alloc, + uint8_t mod_order, + uint8_t Nl, + uint8_t num_pdcch_symbols, + int frame, + uint8_t subframe, + uint8_t beamforming_mode) +{ //int G_adj; /*if (is_pmch_subframe(frame,subframe,frame_parms) == 0) { G_adj= adjust_G(frame_parms,rb_alloc,mod_order,subframe); @@ -353,13 +369,10 @@ int get_G_khz_1dot25(LTE_DL_FRAME_PARMS *frame_parms,uint16_t nb_rb,uint32_t *rb return((int)frame_parms->N_RB_DL * mod_order * 120); } - // following function requires dlsch_tbs_full.h #include "PHY/LTE_TRANSPORT/dlsch_tbs_full.h" -unsigned char SE2I_TBS(float SE, - unsigned char N_PRB, - unsigned char symbPerRB) { +unsigned char SE2I_TBS(float SE, unsigned char N_PRB, unsigned char symbPerRB) { unsigned char I_TBS= -1; int throughPutGoal = 0; short diffOld = TBStable[0][N_PRB-1] - throughPutGoal; // always positive because of unsigned arithmetic @@ -393,7 +406,6 @@ unsigned char SE2I_TBS(float SE, } //added for ALU icic purpose - uint8_t Get_SB_size(uint8_t n_rb_dl) { if(n_rb_dl<27) return 4; @@ -402,6 +414,4 @@ uint8_t Get_SB_size(uint8_t n_rb_dl) { else return 8; } - - //end ALU's algo diff --git a/openair1/PHY/LTE_TRANSPORT/transport_eNB.h b/openair1/PHY/LTE_TRANSPORT/transport_eNB.h index 67c627ca00..a80023c744 100644 --- a/openair1/PHY/LTE_TRANSPORT/transport_eNB.h +++ b/openair1/PHY/LTE_TRANSPORT/transport_eNB.h @@ -314,6 +314,12 @@ typedef struct { // int calibration_flag; /// delta_TF for power control int32_t delta_TF; +#if (LTE_RRC_VERSION >= MAKE_VERSION(14, 0, 0)) + // PUSCH Repetition Number for the current SF + uint32_t repetition_number ; + // PUSCH Total number of repetitions + uint32_t total_number_of_repetitions; +#endif } LTE_UL_eNB_HARQ_t; typedef struct { diff --git a/openair1/PHY/LTE_TRANSPORT/ulsch_decoding.c b/openair1/PHY/LTE_TRANSPORT/ulsch_decoding.c index e324f76c2b..59fa853c4d 100644 --- a/openair1/PHY/LTE_TRANSPORT/ulsch_decoding.c +++ b/openair1/PHY/LTE_TRANSPORT/ulsch_decoding.c @@ -553,12 +553,18 @@ int ulsch_decoding_data(PHY_VARS_eNB *eNB,int UE_id,int harq_pid,int llr8_flag) int G = ulsch_harq->G; unsigned int E; decoder_if_t *tc; + static int32_t pusch_rep_buffer[3*(6144+64)]; + int max_Ncb; if (llr8_flag == 0) tc = *decoder16; else tc = *decoder8; + if(ulsch_harq->repetition_number == 1){ + memset(pusch_rep_buffer,0,(sizeof(int32_t)*3*(6144+64))) ; // reset the buffer every new repetitions + } + for (r=0; rC; r++) { // printf("before subblock deinterleaving c[%d] = %p\n",r,ulsch_harq->c[r]); // Get Turbo interleaver parameters @@ -592,7 +598,7 @@ int ulsch_decoding_data(PHY_VARS_eNB *eNB,int UE_id,int harq_pid,int llr8_flag) 0, //Uplink 1, ulsch_harq->rvidx, - (ulsch_harq->round==0)?1:0, // clear + (ulsch_harq->rvidx==0)?1:0, // clear ulsch_harq->Qm, 1, r, @@ -602,6 +608,27 @@ int ulsch_decoding_data(PHY_VARS_eNB *eNB,int UE_id,int harq_pid,int llr8_flag) } stop_meas(&eNB->ulsch_rate_unmatching_stats); + + max_Ncb = 3*ulsch_harq->RTC[r]*32 ; + + if(ulsch_harq->total_number_of_repetitions > 1) + { + if (ulsch_harq->rvidx==1) + { // Store the result of HARQ combining in the last emtc repetitions of sequence 0,2,3,1 + for (int nn=0;nnw[r][nn] ; + } + } + if (ulsch_harq->repetition_number == ulsch_harq->total_number_of_repetitions) + { + for (int nn=0;nnw[r][nn] = pusch_rep_buffer[nn] ; + } + } + } + r_offset += E; start_meas(&eNB->ulsch_deinterleaving_stats); sub_block_deinterleaving_turbo(4+Kr, diff --git a/openair1/PHY/MODULATION/nr_modulation.c b/openair1/PHY/MODULATION/nr_modulation.c index 40099f4739..57bca9e2ec 100644 --- a/openair1/PHY/MODULATION/nr_modulation.c +++ b/openair1/PHY/MODULATION/nr_modulation.c @@ -24,7 +24,7 @@ extern short nr_mod_table[NR_MOD_TABLE_SIZE_SHORT]; void nr_modulation(uint32_t *in, - uint16_t length, + uint32_t length, uint16_t mod_order, int16_t *out) { @@ -120,6 +120,103 @@ void nr_layer_mapping(int16_t **mod_symbs, } } +void nr_ue_layer_mapping(NR_UE_ULSCH_t **ulsch_ue, + uint8_t n_layers, + uint16_t n_symbs, + int16_t **tx_layers) { + + int16_t *mod_symbs; + + switch (n_layers) { + + case 1: + mod_symbs = (int16_t *)ulsch_ue[0]->d_mod; + for (int i=0; i>15; + tx_layers[0][(i<<1)+1] = (mod_symbs[(i<<1)+1]*AMP)>>15; + } + break; + + case 2: + case 3: + case 4: + mod_symbs = (int16_t *)ulsch_ue[0]->d_mod; + + for (int i=0; i>15; + tx_layers[l][(i<<1)+1] = (mod_symbs[((n_layers*i+l)<<1)+1]*AMP)>>15; + } + } + break; + + case 5: + mod_symbs = (int16_t *)ulsch_ue[0]->d_mod; + + for (int i=0; i>1; i++) + for (int l=0; l<2; l++) { + tx_layers[l][i<<1] = (mod_symbs[((i<<1)+l)<<1]*AMP)>>15; + tx_layers[l][(i<<1)+1] = (mod_symbs[(((i<<1)+l)<<1)+1]*AMP)>>15; + } + + mod_symbs = (int16_t *)ulsch_ue[1]->d_mod; + + for (int i=0; i>15; + tx_layers[l][(i<<1)+1] = (mod_symbs[((3*i+l)<<1)+1]*AMP)>>15; + } + break; + + case 6: + for (int q=0; q<2; q++){ + + mod_symbs = (int16_t *)ulsch_ue[q]->d_mod; + + for (int i=0; i>15; + tx_layers[l][(i<<1)+1] = (mod_symbs[((3*i+l)<<1)+1]*AMP)>>15; + } + } + break; + + case 7: + mod_symbs = (int16_t *)ulsch_ue[1]->d_mod; + + for (int i=0; i>15; + tx_layers[l][(i<<1)+1] = (mod_symbs[((3*i+l)<<1)+1]*AMP)>>15; + } + + mod_symbs = (int16_t *)ulsch_ue[0]->d_mod; + + for (int i=0; i>15; + tx_layers[l][(i<<1)+1] = (mod_symbs[(((i<<2)+l)<<1)+1]*AMP)>>15; + } + break; + + case 8: + for (int q=0; q<2; q++){ + + mod_symbs = (int16_t *)ulsch_ue[q]->d_mod; + + for (int i=0; i>2; i++) + for (int l=0; l<3; l++) { + tx_layers[l][i<<1] = (mod_symbs[((i<<2)+l)<<1]*AMP)>>15; + tx_layers[l][(i<<1)+1] = (mod_symbs[(((i<<2)+l)<<1)+1]*AMP)>>15; + } + } + break; + + default: + AssertFatal(0, "Invalid number of layers %d\n", n_layers); + } +} + void nr_dft(int32_t *z, int32_t *d, uint32_t Msc_PUSCH) { diff --git a/openair1/PHY/MODULATION/nr_modulation.h b/openair1/PHY/MODULATION/nr_modulation.h index 249a92e8e3..8a6abd5de5 100644 --- a/openair1/PHY/MODULATION/nr_modulation.h +++ b/openair1/PHY/MODULATION/nr_modulation.h @@ -25,6 +25,7 @@ #include #include "PHY/defs_nr_common.h" #include "PHY/defs_gNB.h" +#include "PHY/NR_UE_TRANSPORT/nr_transport_ue.h" #define DMRS_MOD_ORDER 2 @@ -36,7 +37,7 @@ */ void nr_modulation(uint32_t *in, - uint16_t length, + uint32_t length, uint16_t mod_order, int16_t *out); @@ -52,6 +53,18 @@ void nr_layer_mapping(int16_t **mod_symbs, uint16_t n_symbs, int16_t **tx_layers); +/*! \brief Perform NR layer mapping. TS 38.211 V15.4.0 subclause 7.3.1.3 + @param[in] ulsch_ue, double Pointer to NR_UE_ULSCH_t struct + @param[in] n_layers, number of layers + @param[in] n_symbs, number of modulated symbols + @param[out] tx_layers, modulated symbols for each layer +*/ + +void nr_ue_layer_mapping(NR_UE_ULSCH_t **ulsch_ue, + uint8_t n_layers, + uint16_t n_symbs, + int16_t **tx_layers); + /*! \brief This function implements the OFDM front end processor on reception (FEP) @@ -80,4 +93,4 @@ int nr_slot_fep_ul(NR_DL_FRAME_PARMS *frame_parms, */ void nr_dft(int32_t *z,int32_t *d, uint32_t Msc_PUSCH); -#endif \ No newline at end of file +#endif diff --git a/openair1/PHY/MODULATION/slot_fep_nr.c b/openair1/PHY/MODULATION/slot_fep_nr.c index c00fef5929..11aaf1f78e 100644 --- a/openair1/PHY/MODULATION/slot_fep_nr.c +++ b/openair1/PHY/MODULATION/slot_fep_nr.c @@ -36,10 +36,10 @@ #endif*/ int nr_slot_fep(PHY_VARS_NR_UE *ue, - unsigned char symbol, - unsigned char Ns, - int sample_offset, - int no_prefix) + unsigned char symbol, + unsigned char Ns, + int sample_offset, + int no_prefix) { NR_DL_FRAME_PARMS *frame_parms = &ue->frame_parms; NR_UE_COMMON *common_vars = &ue->common_vars; @@ -131,8 +131,8 @@ int nr_slot_fep(PHY_VARS_NR_UE *ue, #ifdef DEBUG_FEP // if (ue->frame <100) - /*LOG_I(PHY,*/printf("slot_fep: frame %d: slot %d, symbol %d, nb_prefix_samples %d, nb_prefix_samples0 %d, slot_offset %d, sample_offset %d,rx_offset %d, frame_length_samples %d\n", ue->proc.proc_rxtx[(Ns)&1].frame_rx,Ns, symbol, - nb_prefix_samples,nb_prefix_samples0,slot_offset,sample_offset,rx_offset,frame_length_samples); + /*LOG_I(PHY,*/printf("slot_fep: frame %d: slot %d, symbol %d, nb_prefix_samples %u, nb_prefix_samples0 %u, slot_offset %u, sample_offset %d,rx_offset %u, frame_length_samples %u\n", + ue->proc.proc_rxtx[(Ns)&1].frame_rx, Ns, symbol, nb_prefix_samples, nb_prefix_samples0, slot_offset, sample_offset, rx_offset, frame_length_samples); #endif if (symbol==0) { @@ -192,7 +192,7 @@ int nr_slot_fep(PHY_VARS_NR_UE *ue, #ifdef DEBUG_FEP // if (ue->frame <100) - printf("slot_fep: frame %d: symbol %d rx_offset %d\n", ue->proc.proc_rxtx[(Ns)&1].frame_rx, symbol,rx_offset); + printf("slot_fep: frame %d: symbol %d rx_offset %u\n", ue->proc.proc_rxtx[(Ns)&1].frame_rx, symbol, rx_offset); #endif } diff --git a/openair1/PHY/NR_ESTIMATION/nr_adjust_sync_gNB.c b/openair1/PHY/NR_ESTIMATION/nr_adjust_sync_gNB.c new file mode 100644 index 0000000000..9c4d1fcc93 --- /dev/null +++ b/openair1/PHY/NR_ESTIMATION/nr_adjust_sync_gNB.c @@ -0,0 +1,71 @@ +/* + * Licensed to the OpenAirInterface (OAI) Software Alliance under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The OpenAirInterface Software Alliance licenses this file to You under + * the OAI Public License, Version 1.1 (the "License"); you may not use this file + * except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.openairinterface.org/?page_id=698 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + *------------------------------------------------------------------------------- + * For more information about the OpenAirInterface (OAI) Software Alliance: + * contact@openairinterface.org + */ + +/*! \file PHY/NR_ESTIMATION/nr_adjust_sync_gNB.c +* \brief TA estimation for TA updates +* \author Ahmed Hussein +* \date 2019 +* \version 0.1 +* \company Fraunhofer IIS +* \email: ahmed.hussein@iis.fraunhofer.de +* \note +* \warning +*/ + +#include "PHY/types.h" +#include "PHY/defs_gNB.h" +#include "PHY/phy_extern.h" +#include "nr_ul_estimation.h" + +int nr_est_timing_advance_pusch(PHY_VARS_gNB* gNB, int UE_id) +{ + int temp, i, aa, max_pos = 0, max_val = 0; + short Re, Im; + uint8_t cyclic_shift = 0; + + NR_DL_FRAME_PARMS *frame_parms = &gNB->frame_parms; + NR_gNB_PUSCH *gNB_pusch_vars = gNB->pusch_vars[UE_id]; + int32_t **ul_ch_estimates_time = gNB_pusch_vars->ul_ch_estimates_time; + + int sync_pos = (frame_parms->ofdm_symbol_size - cyclic_shift*frame_parms->ofdm_symbol_size/12) % (frame_parms->ofdm_symbol_size); + + for (i = 0; i < frame_parms->ofdm_symbol_size; i++) { + temp = 0; + + for (aa = 0; aa < frame_parms->nb_antennas_rx; aa++) { + Re = ((int16_t*)ul_ch_estimates_time[aa])[(i<<1)]; + Im = ((int16_t*)ul_ch_estimates_time[aa])[1+(i<<1)]; + temp += (Re*Re/2) + (Im*Im/2); + } + + if (temp > max_val) { + max_pos = i; + max_val = temp; + } + } + + if (max_pos > frame_parms->ofdm_symbol_size/2) + max_pos = max_pos - frame_parms->ofdm_symbol_size; + + + return max_pos - sync_pos; +} + diff --git a/openair1/PHY/NR_ESTIMATION/nr_ul_channel_estimation.c b/openair1/PHY/NR_ESTIMATION/nr_ul_channel_estimation.c new file mode 100644 index 0000000000..0656091c78 --- /dev/null +++ b/openair1/PHY/NR_ESTIMATION/nr_ul_channel_estimation.c @@ -0,0 +1,325 @@ +/* + * Licensed to the OpenAirInterface (OAI) Software Alliance under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The OpenAirInterface Software Alliance licenses this file to You under + * the OAI Public License, Version 1.0 (the "License"); you may not use this file + * except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.openairinterface.org/?page_id=698 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + *------------------------------------------------------------------------------- + * For more information about the OpenAirInterface (OAI) Software Alliance: + * contact@openairinterface.org + */ + + +#include + +#include "nr_ul_estimation.h" +#include "PHY/NR_REFSIG/nr_refsig.h" +#include "PHY/NR_UE_ESTIMATION/filt16a_32.h" + +//#define DEBUG_CH + + +int nr_pusch_channel_estimation(PHY_VARS_gNB *gNB, + uint8_t gNB_offset, + unsigned char Ns, + unsigned short p, + unsigned char symbol, + unsigned short bwp_start_subcarrier, + unsigned short nb_rb_pusch) +{ + int pilot[1320] __attribute__((aligned(16))); + unsigned char aarx; + unsigned short k; + unsigned int pilot_cnt; + int16_t ch[2],*pil,*rxF,*ul_ch,*fl,*fm,*fr,*fml,*fmr,*fmm; + int ch_offset,symbol_offset, length_dmrs, UE_id = 0; + unsigned short n_idDMRS[2] = {0,1}; //to update from pusch config + int32_t temp_in_ifft_0[8192*2] __attribute__((aligned(16))); + int32_t **ul_ch_estimates_time = gNB->pusch_vars[UE_id]->ul_ch_estimates_time; + +#ifdef DEBUG_CH + FILE *debug_ch_est; + debug_ch_est = fopen("debug_ch_est.txt","w"); +#endif + + //uint16_t Nid_cell = (eNB_offset == 0) ? gNB->frame_parms.Nid_cell : gNB->measurements.adj_cell_id[eNB_offset-1]; + + uint8_t nushift; + int **ul_ch_estimates = gNB->pusch_vars[UE_id]->ul_ch_estimates; + int **rxdataF = gNB->common_vars.rxdataF; + + nushift = (p>>1)&1; + gNB->frame_parms.nushift = nushift; + + ch_offset = gNB->frame_parms.ofdm_symbol_size*symbol; + + symbol_offset = gNB->frame_parms.ofdm_symbol_size*symbol; + + k = bwp_start_subcarrier; + int re_offset = k; + +/* +#ifdef DEBUG_CH + printf("PUSCH Channel Estimation : gNB_offset %d ch_offset %d, symbol_offset %d OFDM size %d, Ncp=%d, l=%d, Ns=%d, k=%d symbol %d\n", gNB_offset,ch_offset,symbol_offset,gNB->frame_parms.ofdm_symbol_size, + gNB->frame_parms.Ncp,l,Ns,k, symbol); +#endif +*/ + switch (nushift) { + case 0: + fl = filt8_l0; + fm = filt8_m0; + fr = filt8_r0; + fmm = filt8_mm0; + fml = filt8_m0; + fmr = filt8_mr0; + break; + + case 1: + fl = filt8_l1; + fm = filt8_m1; + fr = filt8_r1; + fmm = filt8_mm1; + fml = filt8_ml1; + fmr = filt8_m1; + break; + + default: + printf("pusch_channel_estimation: nushift=%d -> ERROR\n",nushift); + return(-1); + break; + } + + + //------------------generate DMRS------------------// + + length_dmrs = 1; //to update from pusch config + + nr_gold_pusch(gNB, symbol, n_idDMRS, length_dmrs); + + nr_pusch_dmrs_rx(gNB, Ns, gNB->nr_gold_pusch[gNB_offset][Ns][0], &pilot[0], 1000, 0, nb_rb_pusch); + + //------------------------------------------------// + + for (aarx=0; aarxframe_parms.nb_antennas_rx; aarx++) { + + pil = (int16_t *)&pilot[0]; + rxF = (int16_t *)&rxdataF[aarx][(symbol_offset+k+nushift)]; + ul_ch = (int16_t *)&ul_ch_estimates[aarx][ch_offset]; + + memset(ul_ch,0,4*(gNB->frame_parms.ofdm_symbol_size)); + +#ifdef DEBUG_PUSCH + printf("ch est pilot addr %p RB_DL %d\n",&pilot[0], gNB->frame_parms.N_RB_DL); + printf("k %d, first_carrier %d\n",k,gNB->frame_parms.first_carrier_offset); + printf("rxF addr %p p %d\n", rxF,p); + printf("ul_ch addr %p nushift %d\n",ul_ch,nushift); +#endif + //if ((gNB->frame_parms.N_RB_DL&1)==0) { + + // Treat first 2 pilots specially (left edge) + ch[0] = (int16_t)(((int32_t)pil[0]*rxF[0] - (int32_t)pil[1]*rxF[1])>>15); + ch[1] = (int16_t)(((int32_t)pil[0]*rxF[1] + (int32_t)pil[1]*rxF[0])>>15); + +#ifdef DEBUG_PUSCH + printf("ch 0 %d\n",((int32_t)pil[0]*rxF[0] - (int32_t)pil[1]*rxF[1])); + printf("pilot 0 : rxF - > (%d,%d) addr %p ch -> (%d,%d), pil -> (%d,%d) \n",rxF[0],rxF[1],&rxF[0],ch[0],ch[1],pil[0],pil[1]); + printf("data 0 : rxF - > (%d,%d) addr %p ch -> (%d,%d), pil -> (%d,%d) \n",rxF[2],rxF[3],&rxF[2],ch[0],ch[1],pil[0],pil[1]); +#endif + multadd_real_vector_complex_scalar(fl, + ch, + ul_ch, + 8); + pil+=2; + re_offset = (re_offset+2)&(gNB->frame_parms.ofdm_symbol_size-1); + rxF = (int16_t *)&rxdataF[aarx][(symbol_offset+nushift+re_offset)]; + //for (int i= 0; i<8; i++) + //printf("ul_ch addr %p %d\n", ul_ch+i, *(ul_ch+i)); + + ch[0] = (int16_t)(((int32_t)pil[0]*rxF[0] - (int32_t)pil[1]*rxF[1])>>15); + ch[1] = (int16_t)(((int32_t)pil[0]*rxF[1] + (int32_t)pil[1]*rxF[0])>>15); + +#ifdef DEBUG_PUSCH + printf("pilot 1 : rxF - > (%d,%d) ch -> (%d,%d), pil -> (%d,%d) \n",rxF[0],rxF[1],ch[0],ch[1],pil[0],pil[1]); +#endif + multadd_real_vector_complex_scalar(fml, + ch, + ul_ch, + 8); + pil+=2; + re_offset = (re_offset+2)&(gNB->frame_parms.ofdm_symbol_size-1); + rxF = (int16_t *)&rxdataF[aarx][(symbol_offset+nushift+re_offset)]; + //printf("ul_ch addr %p\n",ul_ch); + + ch[0] = (int16_t)(((int32_t)pil[0]*rxF[0] - (int32_t)pil[1]*rxF[1])>>15); + ch[1] = (int16_t)(((int32_t)pil[0]*rxF[1] + (int32_t)pil[1]*rxF[0])>>15); + +#ifdef DEBUG_PUSCH + printf("pilot 2 : rxF - > (%d,%d) ch -> (%d,%d), pil -> (%d,%d) \n",rxF[0],rxF[1],ch[0],ch[1],pil[0],pil[1]); +#endif + multadd_real_vector_complex_scalar(fmm, + ch, + ul_ch, + 8); + + //for (int i= 0; i<16; i++) + //printf("ul_ch addr %p %d\n", ul_ch+i, *(ul_ch+i)); + + pil+=2; + re_offset = (re_offset+2)&(gNB->frame_parms.ofdm_symbol_size-1); + rxF = (int16_t *)&rxdataF[aarx][(symbol_offset+nushift+re_offset)]; + ul_ch+=8; + + for (pilot_cnt=3; pilot_cnt<(6*nb_rb_pusch-3); pilot_cnt+=2) { + + ch[0] = (int16_t)(((int32_t)pil[0]*rxF[0] - (int32_t)pil[1]*rxF[1])>>15); + ch[1] = (int16_t)(((int32_t)pil[0]*rxF[1] + (int32_t)pil[1]*rxF[0])>>15); +#ifdef DEBUG_CH + fprintf(debug_ch_est, "pilot %d : rxF - > (%d,%d) ch -> (%d,%d), pil -> (%d,%d) \n",pilot_cnt,rxF[0],rxF[1],ch[0],ch[1],pil[0],pil[1]); + //printf("pilot %d : rxF - > (%d,%d) ch -> (%d,%d), pil -> (%d,%d) \n",pilot_cnt,rxF[0],rxF[1],ch[0],ch[1],pil[0],pil[1]); +#endif + multadd_real_vector_complex_scalar(fm, + ch, + ul_ch, + 8); + + pil+=2; + re_offset = (re_offset+2)&(gNB->frame_parms.ofdm_symbol_size-1); + rxF = (int16_t *)&rxdataF[aarx][(symbol_offset+nushift+re_offset)]; + + ch[0] = (int16_t)(((int32_t)pil[0]*rxF[0] - (int32_t)pil[1]*rxF[1])>>15); + ch[1] = (int16_t)(((int32_t)pil[0]*rxF[1] + (int32_t)pil[1]*rxF[0])>>15); +#ifdef DEBUG_PUSCH + printf("pilot %d : rxF - > (%d,%d) ch -> (%d,%d), pil -> (%d,%d) \n",pilot_cnt+1,rxF[0],rxF[1],ch[0],ch[1],pil[0],pil[1]); +#endif + multadd_real_vector_complex_scalar(fmm, + ch, + ul_ch, + 8); + pil+=2; + re_offset = (re_offset+2)&(gNB->frame_parms.ofdm_symbol_size-1); + rxF = (int16_t *)&rxdataF[aarx][(symbol_offset+nushift+re_offset)]; + ul_ch+=8; + + } + + // Treat first 2 pilots specially (right edge) + ch[0] = (int16_t)(((int32_t)pil[0]*rxF[0] - (int32_t)pil[1]*rxF[1])>>15); + ch[1] = (int16_t)(((int32_t)pil[0]*rxF[1] + (int32_t)pil[1]*rxF[0])>>15); +#ifdef DEBUG_PUSCH + printf("pilot %d : rxF - > (%d,%d) ch -> (%d,%d), pil -> (%d,%d) \n",pilot_cnt,rxF[0],rxF[1],ch[0],ch[1],pil[0],pil[1]); +#endif + multadd_real_vector_complex_scalar(fm, + ch, + ul_ch, + 8); + + //for (int i= 0; i<8; i++) + //printf("ul_ch addr %p %d\n", ul_ch+i, *(ul_ch+i)); + + pil+=2; + re_offset = (re_offset+2)&(gNB->frame_parms.ofdm_symbol_size-1); + rxF = (int16_t *)&rxdataF[aarx][(symbol_offset+nushift+re_offset)]; + + ch[0] = (int16_t)(((int32_t)pil[0]*rxF[0] - (int32_t)pil[1]*rxF[1])>>15); + ch[1] = (int16_t)(((int32_t)pil[0]*rxF[1] + (int32_t)pil[1]*rxF[0])>>15); +#ifdef DEBUG_PUSCH + printf("ch 0 %d\n",((int32_t)pil[0]*rxF[0] - (int32_t)pil[1]*rxF[1])); + printf("pilot %d: rxF - > (%d,%d) addr %p ch -> (%d,%d), pil -> (%d,%d) \n",pilot_cnt+1,rxF[0],rxF[1],&rxF[0],ch[0],ch[1],pil[0],pil[1]); +#endif + multadd_real_vector_complex_scalar(fmr, + ch, + ul_ch, + 8); + + pil+=2; + re_offset = (re_offset+2)&(gNB->frame_parms.ofdm_symbol_size-1); + rxF = (int16_t *)&rxdataF[aarx][(symbol_offset+nushift+re_offset)]; + ul_ch+=8; + + ch[0] = (int16_t)(((int32_t)pil[0]*rxF[0] - (int32_t)pil[1]*rxF[1])>>15); + ch[1] = (int16_t)(((int32_t)pil[0]*rxF[1] + (int32_t)pil[1]*rxF[0])>>15); +#ifdef DEBUG_PUSCH + printf("pilot %d: rxF - > (%d,%d) ch -> (%d,%d), pil -> (%d,%d) \n",pilot_cnt+2,rxF[0],rxF[1],ch[0],ch[1],pil[0],pil[1]); +#endif + multadd_real_vector_complex_scalar(fr, + ch, + ul_ch, + 8); + + // Convert to time domain + memset(temp_in_ifft_0, 0, gNB->frame_parms.ofdm_symbol_size*sizeof(int32_t)); + memcpy(temp_in_ifft_0, &ul_ch_estimates[aarx][symbol_offset], nb_rb_pusch * NR_NB_SC_PER_RB * sizeof(int32_t)); + + switch (gNB->frame_parms.ofdm_symbol_size) { + case 128: + idft128((int16_t*) temp_in_ifft_0, + (int16_t*) ul_ch_estimates_time[aarx], + 1); + break; + + case 256: + idft256((int16_t*) temp_in_ifft_0, + (int16_t*) ul_ch_estimates_time[aarx], + 1); + break; + + case 512: + idft512((int16_t*) temp_in_ifft_0, + (int16_t*) ul_ch_estimates_time[aarx], + 1); + break; + + case 1024: + idft1024((int16_t*) temp_in_ifft_0, + (int16_t*) ul_ch_estimates_time[aarx], + 1); + break; + + case 1536: + idft1536((int16_t*) temp_in_ifft_0, + (int16_t*) ul_ch_estimates_time[aarx], + 1); + break; + + case 2048: + idft2048((int16_t*) temp_in_ifft_0, + (int16_t*) ul_ch_estimates_time[aarx], + 1); + break; + + case 4096: + idft4096((int16_t*) temp_in_ifft_0, + (int16_t*) ul_ch_estimates_time[aarx], + 1); + break; + + case 8192: + idft8192((int16_t*) temp_in_ifft_0, + (int16_t*) ul_ch_estimates_time[aarx], + 1); + break; + + default: + idft512((int16_t*) temp_in_ifft_0, + (int16_t*) ul_ch_estimates_time[aarx], + 1); + break; + } + } + +#ifdef DEBUG_CH + fclose(debug_ch_est); +#endif + + return(0); +} \ No newline at end of file diff --git a/openair1/PHY/NR_ESTIMATION/nr_ul_estimation.h b/openair1/PHY/NR_ESTIMATION/nr_ul_estimation.h new file mode 100644 index 0000000000..125c166f7d --- /dev/null +++ b/openair1/PHY/NR_ESTIMATION/nr_ul_estimation.h @@ -0,0 +1,52 @@ +/* + * Licensed to the OpenAirInterface (OAI) Software Alliance under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The OpenAirInterface Software Alliance licenses this file to You under + * the OAI Public License, Version 1.1 (the "License"); you may not use this file + * except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.openairinterface.org/?page_id=698 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + *------------------------------------------------------------------------------- + * For more information about the OpenAirInterface (OAI) Software Alliance: + * contact@openairinterface.org + */ + +#ifndef __NR_UL_ESTIMATION_DEFS__H__ +#define __NR_UL_ESTIMATION_DEFS__H__ + + +#include "PHY/defs_gNB.h" +/** @addtogroup _PHY_PARAMETER_ESTIMATION_BLOCKS_ + * @{ + */ + + +/*! +\brief This function performs channel estimation including frequency interpolation +\param gNB Pointer to gNB PHY variables +\param Ns slot number (0..19) +\param p +\param symbol symbol within slot +\param bwp_start_subcarrier, first allocated subcarrier +\param nb_rb_pusch, number of allocated RBs for this UE +*/ + + int32_t nr_pusch_channel_estimation(PHY_VARS_gNB *gNB, + uint8_t gNB_offset, + unsigned char Ns, + unsigned short p, + unsigned char symbol, + unsigned short bwp_start_subcarrier, + unsigned short nb_rb_pusch); + +int nr_est_timing_advance_pusch(PHY_VARS_gNB* phy_vars_gNB, int UE_id); + +#endif diff --git a/openair1/PHY/NR_REFSIG/nr_dmrs_rx.c b/openair1/PHY/NR_REFSIG/nr_dmrs_rx.c index e0c17bfb75..182f8b6215 100644 --- a/openair1/PHY/NR_REFSIG/nr_dmrs_rx.c +++ b/openair1/PHY/NR_REFSIG/nr_dmrs_rx.c @@ -36,6 +36,8 @@ #include "refsig_defs_ue.h" #include "PHY/defs_nr_UE.h" +#include "nr_refsig.h" +#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}}; @@ -48,14 +50,67 @@ short nr_rx_mod_table[14] = {0,0,23170,-23170,-23170,23170,23170,-23170,23170,2 short nr_rx_nmod_table[14] = {0,0,-23170,23170,23170,-23170,-23170,23170,-23170,-23170,23170,23170,23170,-23170}; +int nr_pusch_dmrs_rx(PHY_VARS_gNB *gNB, + unsigned int Ns, + unsigned int *nr_gold_pusch, + int32_t *output, + unsigned short p, + unsigned char lp, + unsigned short nb_pusch_rb) +{ + int8_t w,config_type; + short *mod_table; + unsigned char idx=0; + + typedef int array_of_w[2]; + array_of_w *wf; + array_of_w *wt; + + config_type = 0; //to be updated by higher layer + + wf = (config_type==0) ? wf1 : wf2; + wt = (config_type==0) ? wt1 : wt2; + + if (config_type > 1) + LOG_E(PHY,"Bad PUSCH DMRS config type %d\n", config_type); + + if ((p>=1000) && (p<((config_type==0) ? 1008 : 1012))) { + if (gNB->frame_parms.Ncp == NORMAL) { + + for (int i=0; i>5])>>((i<<1)&0x1f))&1)<<1) ^ (((nr_gold_pusch[((i<<1)+1)>>5])>>(((i<<1)+1)&0x1f))&1); + ((int16_t*)output)[i<<1] = mod_table[(NR_MOD_TABLE_QPSK_OFFSET + idx)<<1]; + ((int16_t*)output)[(i<<1)+1] = mod_table[((NR_MOD_TABLE_QPSK_OFFSET + idx)<<1) + 1]; +#ifdef DEBUG_PUSCH + printf("nr_pusch_dmrs_rx dmrs config type %d port %d nb_pusch_rb %d\n", config_type, p, nb_pusch_rb); + printf("wf[%d] = %d wt[%d]= %d\n", i&1, wf[p-1000][i&1], lp, wt[p-1000][lp]); + printf("i %d idx %d pusch gold %u b0-b1 %d-%d mod_dmrs %d %d\n", i, idx, nr_gold_pusch[(i<<1)>>5], (((nr_gold_pusch[(i<<1)>>5])>>((i<<1)&0x1f))&1), + (((nr_gold_pusch[((i<<1)+1)>>5])>>(((i<<1)+1)&0x1f))&1), ((int16_t*)output)[i<<1], ((int16_t*)output)[(i<<1)+1]); +#endif + } + } else { + LOG_E(PHY,"extended cp not supported for PUSCH DMRS yet\n"); + } + } else { + LOG_E(PHY,"Illegal p %d PUSCH DMRS port\n",p); + } + + return(0); +} + + int nr_pdsch_dmrs_rx(PHY_VARS_NR_UE *ue, - unsigned int Ns, - unsigned int *nr_gold_pdsch, - int32_t *output, - unsigned short p, - unsigned char lp, - unsigned short nb_pdsch_rb) + unsigned int Ns, + unsigned int *nr_gold_pdsch, + int32_t *output, + unsigned short p, + unsigned char lp, + unsigned short nb_pdsch_rb) { int8_t w,config_type; short *mod_table; @@ -101,15 +156,15 @@ int nr_pdsch_dmrs_rx(PHY_VARS_NR_UE *ue, return(0); } -int nr_pdcch_dmrs_rx(PHY_VARS_NR_UE *ue, - uint8_t eNB_offset, - unsigned int Ns, - unsigned int *nr_gold_pdcch, - int32_t *output, - unsigned short p, - unsigned short nb_rb_coreset) -{ +int nr_pdcch_dmrs_rx(PHY_VARS_NR_UE *ue, + uint8_t eNB_offset, + unsigned int Ns, + unsigned int *nr_gold_pdcch, + int32_t *output, + unsigned short p, + unsigned short nb_rb_coreset) +{ uint8_t idx=0; //uint8_t pdcch_rb_offset =0; //nr_gold_pdcch += ((int)floor(ue->frame_parms.ssb_start_subcarrier/12)+pdcch_rb_offset)*3/32; @@ -121,8 +176,8 @@ int nr_pdcch_dmrs_rx(PHY_VARS_NR_UE *ue, ((int16_t*)output)[(i<<1)+1] = nr_rx_mod_table[((NR_MOD_TABLE_QPSK_OFFSET + idx)<<1) + 1]; #ifdef DEBUG_PDCCH if (i<8) - printf("i %d idx %d pdcch gold %u b0-b1 %d-%d mod_dmrs %d %d\n", i, idx, nr_gold_pdcch[(i<<1)>>5], (((nr_gold_pdcch[(i<<1)>>5])>>((i<<1)&0x1f))&1), - (((nr_gold_pdcch[((i<<1)+1)>>5])>>(((i<<1)+1)&0x1f))&1), ((int16_t*)output)[i<<1], ((int16_t*)output)[(i<<1)+1],&output[0]); + printf("i %d idx %d pdcch gold %u b0-b1 %d-%d mod_dmrs %d %d addr %p\n", i, idx, nr_gold_pdcch[(i<<1)>>5], (((nr_gold_pdcch[(i<<1)>>5])>>((i<<1)&0x1f))&1), + (((nr_gold_pdcch[((i<<1)+1)>>5])>>(((i<<1)+1)&0x1f))&1), ((int16_t*)output)[i<<1], ((int16_t*)output)[(i<<1)+1],&output[0]); #endif } } @@ -130,7 +185,10 @@ int nr_pdcch_dmrs_rx(PHY_VARS_NR_UE *ue, return(0); } -int nr_pbch_dmrs_rx(int symbol,unsigned int *nr_gold_pbch,int32_t *output ) + +int nr_pbch_dmrs_rx(int symbol, + unsigned int *nr_gold_pbch, + int32_t *output) { int m,m0,m1; uint8_t idx=0; @@ -164,6 +222,3 @@ int nr_pbch_dmrs_rx(int symbol,unsigned int *nr_gold_pbch,int32_t *output ) return(0); } - - - diff --git a/openair1/PHY/NR_REFSIG/nr_gold.c b/openair1/PHY/NR_REFSIG/nr_gold.c index 1492d7f03f..48fcd04a0f 100644 --- a/openair1/PHY/NR_REFSIG/nr_gold.c +++ b/openair1/PHY/NR_REFSIG/nr_gold.c @@ -101,3 +101,59 @@ void nr_init_pdsch_dmrs(PHY_VARS_gNB* gNB, uint32_t Nid) } } } + + +void nr_gold_pusch(PHY_VARS_gNB* gNB, unsigned short lbar,unsigned short *n_idDMRS, unsigned short length_dmrs) +{ + + unsigned char ns,l; + unsigned int n,x1,x2,x2tmp0; + int nscid; + unsigned int nid; + + /// to be updated from higher layer + //unsigned short lbar = 0; + + for (nscid=0; nscid<2; nscid++) { + if (n_idDMRS) + nid = n_idDMRS[nscid]; + else + nid = gNB->frame_parms.Nid_cell; + + //printf("gold pdsch nid %d lbar %d\n",nid,lbar); + + for (ns=0; ns<20; ns++) { + + for (l=0; l>1) ^ (x2>>2) ^ (x2>>3))<<31); + + // skip first 50 double words (1600 bits) + for (n=1; n<50; n++) { + x1 = (x1>>1) ^ (x1>>4); + x1 = x1 ^ (x1<<31) ^ (x1<<28); + x2 = (x2>>1) ^ (x2>>2) ^ (x2>>3) ^ (x2>>4); + x2 = x2 ^ (x2<<31) ^ (x2<<30) ^ (x2<<29) ^ (x2<<28); + //printf("x1 : %x, x2 : %x\n",x1,x2); + } + + for (n=0; n>1) ^ (x1>>4); + x1 = x1 ^ (x1<<31) ^ (x1<<28); + x2 = (x2>>1) ^ (x2>>2) ^ (x2>>3) ^ (x2>>4); + x2 = x2 ^ (x2<<31) ^ (x2<<30) ^ (x2<<29) ^ (x2<<28); + gNB->nr_gold_pusch[nscid][ns][l][n] = x1^x2; + // if ((ns==2)&&(l==0)) + //printf("n=%d : c %x\n",n,x1^x2); + } + + } + } + } +} \ No newline at end of file diff --git a/openair1/PHY/NR_REFSIG/nr_refsig.h b/openair1/PHY/NR_REFSIG/nr_refsig.h index cb165eed5e..e1bfa1420d 100644 --- a/openair1/PHY/NR_REFSIG/nr_refsig.h +++ b/openair1/PHY/NR_REFSIG/nr_refsig.h @@ -39,4 +39,13 @@ void nr_init_pbch_dmrs(PHY_VARS_gNB* gNB); void nr_init_pdcch_dmrs(PHY_VARS_gNB* gNB, uint32_t Nid); void nr_init_pdsch_dmrs(PHY_VARS_gNB* gNB, uint32_t Nid); +void nr_gold_pusch(PHY_VARS_gNB* gNB, unsigned short lbar,unsigned short *n_idDMRS, unsigned short length_dmrs); + +int nr_pusch_dmrs_rx(PHY_VARS_gNB *gNB, + unsigned int Ns, + unsigned int *nr_gold_pusch, + int32_t *output, + unsigned short p, + unsigned char lp, + unsigned short nb_pusch_rb); #endif diff --git a/openair1/PHY/NR_REFSIG/ul_ref_seq_nr.c b/openair1/PHY/NR_REFSIG/ul_ref_seq_nr.c index 1a64c8902c..8521a2618f 100644 --- a/openair1/PHY/NR_REFSIG/ul_ref_seq_nr.c +++ b/openair1/PHY/NR_REFSIG/ul_ref_seq_nr.c @@ -54,7 +54,9 @@ * *********************************************************************/ -int16_t *base_sequence_less_than_36(unsigned int M_ZC, unsigned int u, unsigned int scaling) +int16_t *base_sequence_less_than_36(unsigned int M_ZC, + unsigned int u, + unsigned int scaling) { char *phi_table; int16_t *rv_overbar; @@ -77,7 +79,7 @@ int16_t *base_sequence_less_than_36(unsigned int M_ZC, unsigned int u, unsigned case 30: break; default: - printf("function base_sequence_less_than 36_: unsupported base sequence size : %d \n", M_ZC); + printf("function base_sequence_less_than 36_: unsupported base sequence size : %u \n", M_ZC); assert(0); break; } @@ -121,7 +123,10 @@ int16_t *base_sequence_less_than_36(unsigned int M_ZC, unsigned int u, unsigned * *********************************************************************/ -int16_t *base_sequence_36_or_larger(unsigned int Msc_RS, unsigned int u, unsigned int v, unsigned int scaling) +int16_t *base_sequence_36_or_larger(unsigned int Msc_RS, + unsigned int u, + unsigned int v, + unsigned int scaling) { int16_t *rv_overbar; unsigned int N_ZC; diff --git a/openair1/PHY/NR_TRANSPORT/nr_dci.c b/openair1/PHY/NR_TRANSPORT/nr_dci.c index a48ed7e37b..d00e66f041 100644 --- a/openair1/PHY/NR_TRANSPORT/nr_dci.c +++ b/openair1/PHY/NR_TRANSPORT/nr_dci.c @@ -130,7 +130,7 @@ uint16_t nr_get_dci_size(nfapi_nr_dci_format_e format, } void nr_pdcch_scrambling(uint32_t *in, - uint16_t size, + uint32_t size, uint32_t Nid, uint32_t n_RNTI, uint32_t *out) { @@ -162,8 +162,6 @@ uint8_t nr_generate_dci_top(NR_gNB_PDCCH pdcch_vars, NR_DL_FRAME_PARMS frame_parms, nfapi_nr_config_request_t config) { int16_t mod_dmrs[NR_MAX_CSET_DURATION][NR_MAX_PDCCH_DMRS_LENGTH>>1]; // 3 for the max coreset duration - uint32_t dmrs_seq[NR_MAX_PDCCH_DMRS_INIT_LENGTH_DWORD]; - uint16_t dmrs_offset=0; uint16_t cset_start_sc; uint8_t cset_start_symb, cset_nsymb; int k,l,k_prime,dci_idx, dmrs_idx; @@ -190,45 +188,20 @@ uint8_t nr_generate_dci_top(NR_gNB_PDCCH pdcch_vars, LOG_D(PHY, "Coreset rb_offset %d\n",pdcch_params.rb_offset); LOG_D(PHY, "Coreset starting subcarrier %d on symbol %d (%d symbols)\n", cset_start_sc, cset_start_symb, cset_nsymb); // DMRS length is per OFDM symbol - uint16_t dmrs_length = (pdcch_params.precoder_granularity == NFAPI_NR_CSET_ALL_CONTIGUOUS_RBS)? + uint32_t dmrs_length = (pdcch_params.precoder_granularity == NFAPI_NR_CSET_ALL_CONTIGUOUS_RBS)? (pdcch_params.n_rb*6) : (dci_alloc.L*36/cset_nsymb); //2(QPSK)*3(per RB)*6(REG per CCE) - uint16_t encoded_length = dci_alloc.L*108; //2(QPSK)*9(per RB)*6(REG per CCE) + uint32_t encoded_length = dci_alloc.L*108; //2(QPSK)*9(per RB)*6(REG per CCE) LOG_D(PHY, "DMRS length per symbol %d\t DCI encoded length %d\n", dmrs_length, encoded_length); + dmrs_length += pdcch_params.rb_offset*6; // To accommodate more DMRS symbols in case of rb offset /// DMRS QPSK modulation - /*There is a need to shift from which index the pregenerated DMRS sequence is used - * see 38211 r15.2.0 section 7.4.1.3.2: assumption is the reference point for k refers to the DMRS sequence*/ - if (pdcch_params.config_type == NFAPI_NR_CSET_CONFIG_PDCCH_CONFIG) { - for (int symb=cset_start_symb; symb>5; - - dmrs_offset = (pdcch_params.rb_offset*3)&0x1f; - LOG_D(PHY, "PDCCH DMRS offset %d\n", dmrs_offset); - } - for (int symb=cset_start_symb; symb>5)] |= ((gold_pdcch_dmrs[symb][(i+dmrs_offset)>>5]>>((i+dmrs_offset)&0x1f))&1)<<(i&0x1f); -#ifdef DEBUG_PDCCH_DMRS - //printf("out 0x%08x in 0x%08x \n", dmrs_seq[(i>>5)], gold_pdcch_dmrs[symb][(i+dmrs_offset)>>5]); -#endif - } - - nr_modulation(dmrs_seq, dmrs_length, DMRS_MOD_ORDER, mod_dmrs[symb]); //Qm = 2 as DMRS is QPSK modulated - } else - nr_modulation(gold_pdcch_dmrs[symb], dmrs_length, DMRS_MOD_ORDER, mod_dmrs[symb]); //Qm = 2 as DMRS is QPSK modulated + + nr_modulation(gold_pdcch_dmrs[symb], dmrs_length, DMRS_MOD_ORDER, mod_dmrs[symb]); //Qm = 2 as DMRS is QPSK modulated #ifdef DEBUG_PDCCH_DMRS for (int i=0; i>1; i++) - if (dmrs_offset) - printf("symb %d i %d gold seq 0x%08x mod_dmrs %d %d\n", symb, i, dmrs_seq[i>>5], - mod_dmrs[symb][i<<1], mod_dmrs[symb][(i<<1)+1] ); - else printf("symb %d i %d gold seq 0x%08x mod_dmrs %d %d\n", symb, i, gold_pdcch_dmrs[symb][i>>5], mod_dmrs[symb][i<<1], mod_dmrs[symb][(i<<1)+1] ); @@ -279,32 +252,28 @@ uint8_t nr_generate_dci_top(NR_gNB_PDCCH pdcch_vars, cset_start_sc -= frame_parms.ofdm_symbol_size; /*Reorder REG list for a freq first mapping*/ - uint8_t symb_idx[NR_MAX_CSET_DURATION] = {0,0,0}; uint8_t nb_regs = dci_alloc.L*NR_NB_REG_PER_CCE; - uint8_t regs_per_symb = nb_regs/cset_nsymb; for (int cce_idx=0; cce_idxgNB_config; NR_gNB_DLSCH_t *dlsch; + uint16_t N_RB = params_rel15->n_RB_BWP; uint8_t fsize=0, pos=0, cand_idx=0; @@ -182,12 +183,12 @@ void nr_fill_dci(PHY_VARS_gNB *gNB, // Freq domain assignment fsize = (int)ceil( log2( (N_RB*(N_RB+1))>>1 ) ); pos=fsize; - *dci_pdu |= ((pdu_rel15->frequency_domain_assignment&((1<size-pos)); + *dci_pdu |= ((pdu_rel15->frequency_domain_assignment&((1<size-pos)); #ifdef DEBUG_FILL_DCI LOG_D(PHY,"frequency-domain assignment %d (%d bits) N_RB_BWP %d=> %d (0x%lx)\n",pdu_rel15->frequency_domain_assignment,fsize,N_RB,dci_alloc->size-pos,*dci_pdu); #endif // Time domain assignment - pos+=4; + pos+=4; *dci_pdu |= (((uint64_t)pdu_rel15->time_domain_assignment&0xf) << (dci_alloc->size-pos)); #ifdef DEBUG_FILL_DCI LOG_D(PHY,"time-domain assignment %d (3 bits)=> %d (0x%lx)\n",pdu_rel15->time_domain_assignment,dci_alloc->size-pos,*dci_pdu); @@ -246,22 +247,22 @@ void nr_fill_dci(PHY_VARS_gNB *gNB, // UL/SUL indicator 1 bit pos++; *dci_pdu |= (pdu_rel15->ul_sul_indicator&1)<<(dci_alloc->size-pos); - + // SS/PBCH index 6 bits pos+=6; *dci_pdu |= ((pdu_rel15->ss_pbch_index&0x3f)<<(dci_alloc->size-pos)); - + // prach_mask_index 4 bits pos+=4; *dci_pdu |= ((pdu_rel15->prach_mask_index&0xf)<<(dci_alloc->size-pos)); - + } //end if else { // Time domain assignment 4bit - pos+=4; + pos+=4; *dci_pdu |= ((pdu_rel15->time_domain_assignment&0xf) << (dci_alloc->size-pos)); #ifdef DEBUG_FILL_DCI LOG_D(PHY,"Time domain assignment %d (%d bits)=> %d (0x%lx)\n",pdu_rel15->time_domain_assignment,4,dci_alloc->size-pos,*dci_pdu); @@ -334,7 +335,7 @@ void nr_fill_dci(PHY_VARS_gNB *gNB, break; case NFAPI_NR_RNTI_P: - + // Short Messages Indicator – 2 bits for (int i=0; i<2; i++) *dci_pdu |= (((uint64_t)pdu_rel15->short_messages_indicator>>(1-i))&1)<<(dci_alloc->size-pos++); @@ -351,7 +352,7 @@ void nr_fill_dci(PHY_VARS_gNB *gNB, // VRB to PRB mapping 1 bit *dci_pdu |= ((uint64_t)pdu_rel15->vrb_to_prb_mapping&1)<<(dci_alloc->size-pos++); // MCS 5 bit - for (int i=0; i<5; i++) + for (int i=0; i<5; i++) *dci_pdu |= (((uint64_t)pdu_rel15->mcs>>(4-i))&1)<<(dci_alloc->size-pos++); // TB scaling 2 bit @@ -360,7 +361,7 @@ void nr_fill_dci(PHY_VARS_gNB *gNB, break; - + case NFAPI_NR_RNTI_SI: // Freq domain assignment 0-16 bit fsize = (int)ceil( log2( (N_RB*(N_RB+1))>>1 ) ); @@ -377,9 +378,9 @@ void nr_fill_dci(PHY_VARS_gNB *gNB, // Redundancy version 2bit for (int i=0; i<2; i++) *dci_pdu |= (((uint64_t)pdu_rel15->rv>>(1-i))&1)<<(dci_alloc->size-pos++); - + break; - + case NFAPI_NR_RNTI_TC: // indicating a DL DCI format 1bit *dci_pdu |= ((uint64_t)pdu_rel15->format_indicator&1)<<(dci_alloc->size-pos++); @@ -400,14 +401,14 @@ void nr_fill_dci(PHY_VARS_gNB *gNB, // Redundancy version 2bit for (int i=0; i<2; i++) *dci_pdu |= (((uint64_t)pdu_rel15->rv>>(1-i))&1)<<(dci_alloc->size-pos++); - // HARQ process number 4bit + // HARQ process number 4bit for (int i=0; i<4; i++) *dci_pdu |= (((uint64_t)pdu_rel15->harq_pid>>(3-i))&1)<<(dci_alloc->size-pos++); - + // Downlink assignment index – 2 bits for (int i=0; i<2; i++) *dci_pdu |= (((uint64_t)pdu_rel15->dai>>(1-i))&1)<<(dci_alloc->size-pos++); - + // TPC command for scheduled PUCCH – 2 bits for (int i=0; i<2; i++) *dci_pdu |= (((uint64_t)pdu_rel15->tpc>>(1-i))&1)<<(dci_alloc->size-pos++); @@ -420,7 +421,7 @@ void nr_fill_dci(PHY_VARS_gNB *gNB, // PDSCH-to-HARQ_feedback timing indicator – 3 bits for (int i=0; i<3; i++) *dci_pdu |= (((uint64_t)pdu_rel15->pdsch_to_harq_feedback_timing_indicator>>(2-i))&1)<<(dci_alloc->size-pos++); - + break; } break; @@ -448,10 +449,10 @@ void nr_fill_dci(PHY_VARS_gNB *gNB, // Redundancy version 2bit for (int i=0; i<2; i++) *dci_pdu |= (((uint64_t)pdu_rel15->rv>>(1-i))&1)<<(dci_alloc->size-pos++); - // HARQ process number 4bit + // HARQ process number 4bit for (int i=0; i<4; i++) *dci_pdu |= (((uint64_t)pdu_rel15->harq_pid>>(3-i))&1)<<(dci_alloc->size-pos++); - + // TPC command for scheduled PUSCH – 2 bits for (int i=0; i<2; i++) *dci_pdu |= (((uint64_t)pdu_rel15->tpc>>(1-i))&1)<<(dci_alloc->size-pos++); @@ -463,11 +464,11 @@ void nr_fill_dci(PHY_VARS_gNB *gNB, // UL/SUL indicator – 1 bit if (cfg->pucch_config.pucch_GroupHopping.value) *dci_pdu |= ((uint64_t)pdu_rel15->ul_sul_indicator&1)<<(dci_alloc->size-pos++); - + break; - + case NFAPI_NR_RNTI_TC: - + // indicating a DL DCI format 1bit *dci_pdu |= (pdu_rel15->format_indicator&1)<<(dci_alloc->size-pos++); // Freq domain assignment max 16 bit @@ -487,7 +488,7 @@ void nr_fill_dci(PHY_VARS_gNB *gNB, // Redundancy version 2bit for (int i=0; i<2; i++) *dci_pdu |= (((uint64_t)pdu_rel15->rv>>(1-i))&1)<<(dci_alloc->size-pos++); - // HARQ process number 4bit + // HARQ process number 4bit for (int i=0; i<4; i++) *dci_pdu |= (((uint64_t)pdu_rel15->harq_pid>>(3-i))&1)<<(dci_alloc->size-pos++); @@ -504,7 +505,7 @@ void nr_fill_dci(PHY_VARS_gNB *gNB, *dci_pdu |= ((uint64_t)pdu_rel15->ul_sul_indicator&1)<<(dci_alloc->size-pos++); break; - } + } break; } diff --git a/openair1/PHY/NR_TRANSPORT/nr_dlsch.c b/openair1/PHY/NR_TRANSPORT/nr_dlsch.c index 31d321f01c..60767526a2 100644 --- a/openair1/PHY/NR_TRANSPORT/nr_dlsch.c +++ b/openair1/PHY/NR_TRANSPORT/nr_dlsch.c @@ -39,11 +39,11 @@ //#define DEBUG_DLSCH_MAPPING void nr_pdsch_codeword_scrambling(uint8_t *in, - uint16_t size, - uint8_t q, - uint32_t Nid, - uint32_t n_RNTI, - uint32_t* out) { + uint32_t size, + uint8_t q, + uint32_t Nid, + uint32_t n_RNTI, + uint32_t* out) { uint8_t reset, b_idx; uint32_t x1, x2, s=0; @@ -88,7 +88,7 @@ uint8_t nr_generate_pdsch(NR_gNB_DLSCH_t *dlsch, int8_t Wf[2], Wt[2], l0, l_prime[2], delta; uint16_t nb_symbols = rel15->nb_mod_symbols; uint8_t Qm = rel15->modulation_order; - uint16_t encoded_length = nb_symbols*Qm; + uint32_t encoded_length = nb_symbols*Qm; /// CRC, coding, interleaving and rate matching AssertFatal(harq->pdu!=NULL,"harq->pdu is null\n"); @@ -121,11 +121,12 @@ printf("\n"); pdcch_params.scrambling_id : config->sch_config.physical_cell_id.value; for (int q=0; qnb_codewords; q++) nr_pdsch_codeword_scrambling(harq->f, - encoded_length, - q, - Nid, - n_RNTI, - scrambled_output[q]); + encoded_length, + q, + Nid, + n_RNTI, + scrambled_output[q]); + stop_meas(dlsch_scrambling_stats); #ifdef DEBUG_DLSCH printf("PDSCH scrambling:\n"); @@ -175,13 +176,12 @@ for (int l=0; lnb_layers; l++) //to be moved to init phase potentially, for now tx_layers 1-8 are mapped on antenna ports 1000-1007 /// DMRS QPSK modulation - - int nb_re_dmrs = rel15->dmrs_Type==1?6:4; - uint16_t n_dmrs = (rel15->n_prb*nb_re_dmrs)<<1; + uint16_t n_dmrs = ((rel15->n_prb+rel15->start_prb)*rel15->nb_re_dmrs)<<1; int16_t mod_dmrs[n_dmrs<<1]; uint8_t dmrs_type = rel15->dmrs_Type; uint8_t mapping_type = rel15->mapping_type; + l0 = get_l0(mapping_type, 2);//config->pdsch_config.dmrs_typeA_position.value); nr_modulation(pdsch_dmrs[l0][0], n_dmrs, DMRS_MOD_ORDER, mod_dmrs); // currently only codeword 0 is modulated. Qm = 2 as DMRS is QPSK modulated @@ -222,6 +222,10 @@ ap, Wt[0], Wt[1], Wf[0], Wf[1], delta, l_prime[0], l0, dmrs_symbol); #endif uint8_t k_prime=0; uint16_t m=0, n=0, dmrs_idx=0, k=0; + if (dmrs_type == NFAPI_NR_DMRS_TYPE1) // another if condition to be included to check pdsch config type (reference of k) + dmrs_idx = rel15->start_prb*6; + else + dmrs_idx = rel15->start_prb*4; for (int l=rel15->start_symbol; lstart_symbol+rel15->nb_symbols; l++) { k = start_sc; diff --git a/openair1/PHY/NR_TRANSPORT/nr_dlsch.h b/openair1/PHY/NR_TRANSPORT/nr_dlsch.h index d4a08c5719..24695cab8a 100644 --- a/openair1/PHY/NR_TRANSPORT/nr_dlsch.h +++ b/openair1/PHY/NR_TRANSPORT/nr_dlsch.h @@ -59,11 +59,11 @@ uint8_t nr_get_Qm(uint8_t Imcs, uint8_t table_idx); uint32_t nr_get_code_rate(uint8_t Imcs, uint8_t table_idx); void nr_pdsch_codeword_scrambling(uint8_t *in, - uint16_t size, - uint8_t q, - uint32_t Nid, - uint32_t n_RNTI, - uint32_t* out); + uint32_t size, + uint8_t q, + uint32_t Nid, + uint32_t n_RNTI, + uint32_t* out); void nr_fill_dlsch(PHY_VARS_gNB *gNB, int frame, diff --git a/openair1/PHY/NR_TRANSPORT/nr_dlsch_coding.c b/openair1/PHY/NR_TRANSPORT/nr_dlsch_coding.c index 7fd68d5fa9..8c2464e5ff 100644 --- a/openair1/PHY/NR_TRANSPORT/nr_dlsch_coding.c +++ b/openair1/PHY/NR_TRANSPORT/nr_dlsch_coding.c @@ -95,7 +95,7 @@ void free_gNB_dlsch(NR_gNB_DLSCH_t *dlsch) dlsch->harq_processes[i]->d[r] = NULL; } - } + } free16(dlsch->harq_processes[i],sizeof(NR_DL_gNB_HARQ_t)); dlsch->harq_processes[i] = NULL; } @@ -103,7 +103,7 @@ void free_gNB_dlsch(NR_gNB_DLSCH_t *dlsch) free16(dlsch,sizeof(NR_gNB_DLSCH_t)); dlsch = NULL; - } + } } @@ -269,10 +269,11 @@ void clean_gNB_dlsch(NR_gNB_DLSCH_t *dlsch) } } -int nr_dlsch_encoding(unsigned char *a,int frame, - uint8_t slot, - NR_gNB_DLSCH_t *dlsch, - NR_DL_FRAME_PARMS* frame_parms) +int nr_dlsch_encoding(unsigned char *a, + int frame, + uint8_t slot, + NR_gNB_DLSCH_t *dlsch, + NR_DL_FRAME_PARMS* frame_parms) { unsigned int G; @@ -282,18 +283,21 @@ int nr_dlsch_encoding(unsigned char *a,int frame, nfapi_nr_dl_config_dlsch_pdu_rel15_t *rel15 = &dlsch->harq_processes[harq_pid]->dlsch_pdu.dlsch_pdu_rel15; uint16_t nb_rb = rel15->n_prb; uint8_t nb_symb_sch = rel15->nb_symbols; - uint32_t A, Z, F=0; - uint32_t *pz = &Z; + uint32_t A, Z, Kb, F=0; + uint32_t *Zc = &Z; uint8_t mod_order = rel15->modulation_order; - uint16_t Kr=0,r,r_offset=0; + uint16_t Kr=0,r; + uint32_t r_offset=0; //uint8_t *d_tmp[MAX_NUM_DLSCH_SEGMENTS]; uint8_t BG=1; uint32_t E; - uint8_t Ilbrm = 0; + uint8_t Ilbrm = 1; uint32_t Tbslbrm = 950984; //max tbs uint8_t nb_re_dmrs = rel15->dmrs_Type==1 ? 6:4; uint16_t length_dmrs = rel15->dmrs_maxLength; + uint16_t R=rel15->coding_rate; float Coderate = 0.0; + uint8_t Nl = 4; /* uint8_t *channel_input[MAX_NUM_DLSCH_SEGMENTS]; //unsigned char @@ -309,9 +313,6 @@ int nr_dlsch_encoding(unsigned char *a,int frame, G = nr_get_G(nb_rb, nb_symb_sch, nb_re_dmrs, length_dmrs,mod_order,rel15->nb_layers); LOG_D(PHY,"dlsch coding A %d G %d mod_order %d\n", A,G, mod_order); - - - Tbslbrm = nr_compute_tbs(28,nb_rb,frame_parms->symbols_per_slot,0,0, rel15->nb_layers); // if (dlsch->harq_processes[harq_pid]->Ndi == 1) { // this is a new packet if (dlsch->harq_processes[harq_pid]->round == 0) { // this is a new packet @@ -325,38 +326,58 @@ int nr_dlsch_encoding(unsigned char *a,int frame, LOG_D(PHY,"%02x.",a[i]); LOG_D(PHY,"\n"); */ - // Add 24-bit crc (polynomial A) to payload - crc = crc24a(a,A)>>8; - a[A>>3] = ((uint8_t*)&crc)[2]; - a[1+(A>>3)] = ((uint8_t*)&crc)[1]; - a[2+(A>>3)] = ((uint8_t*)&crc)[0]; - //LOG_D(PHY,"CRC %x (A %d)\n",crc,A); - //LOG_D(PHY,"a0 %d a1 %d a2 %d\n", a[A>>3], a[1+(A>>3)], a[2+(A>>3)]); - dlsch->harq_processes[harq_pid]->B = A+24; - // dlsch->harq_processes[harq_pid]->b = a; + if (A > 3824) { + // Add 24-bit crc (polynomial A) to payload + crc = crc24a(a,A)>>8; + a[A>>3] = ((uint8_t*)&crc)[2]; + a[1+(A>>3)] = ((uint8_t*)&crc)[1]; + a[2+(A>>3)] = ((uint8_t*)&crc)[0]; + //printf("CRC %x (A %d)\n",crc,A); + //printf("a0 %d a1 %d a2 %d\n", a[A>>3], a[1+(A>>3)], a[2+(A>>3)]); + + dlsch->harq_processes[harq_pid]->B = A+24; + // dlsch->harq_processes[harq_pid]->b = a; - AssertFatal((A/8)+4 <= MAX_DLSCH_PAYLOAD_BYTES,"A %d is too big (A/8+4 = %d > %d)\n",A,(A/8)+4,MAX_DLSCH_PAYLOAD_BYTES); + AssertFatal((A/8)+4 <= MAX_DLSCH_PAYLOAD_BYTES,"A %d is too big (A/8+4 = %d > %d)\n",A,(A/8)+4,MAX_DLSCH_PAYLOAD_BYTES); - memcpy(dlsch->harq_processes[harq_pid]->b,a,(A/8)+4); + memcpy(dlsch->harq_processes[harq_pid]->b,a,(A/8)+4); // why is this +4 if the CRC is only 3 bytes? + } + else { + // Add 16-bit crc (polynomial A) to payload + crc = crc16(a,A)>>16; + a[A>>3] = ((uint8_t*)&crc)[1]; + a[1+(A>>3)] = ((uint8_t*)&crc)[0]; + //printf("CRC %x (A %d)\n",crc,A); + //printf("a0 %d a1 %d \n", a[A>>3], a[1+(A>>3)]); + + dlsch->harq_processes[harq_pid]->B = A+16; + // dlsch->harq_processes[harq_pid]->b = a; + + AssertFatal((A/8)+3 <= MAX_DLSCH_PAYLOAD_BYTES,"A %d is too big (A/8+3 = %d > %d)\n",A,(A/8)+3,MAX_DLSCH_PAYLOAD_BYTES); - nr_segmentation(dlsch->harq_processes[harq_pid]->b, - dlsch->harq_processes[harq_pid]->c, - dlsch->harq_processes[harq_pid]->B, - &dlsch->harq_processes[harq_pid]->C, - &dlsch->harq_processes[harq_pid]->K, - pz, // [hna] pz is Zc - &dlsch->harq_processes[harq_pid]->F); + memcpy(dlsch->harq_processes[harq_pid]->b,a,(A/8)+3); // using 3 bytes to mimic the case of 24 bit crc + } + if (R<1000) + Coderate = (float) R /(float) 1024; + else // to scale for mcs 20 and 26 in table 5.1.3.1-2 which are decimal and input 2* in nr_tbs_tools + Coderate = (float) R /(float) 2048; + + if ((A <=292) || ((A<=3824) && (Coderate <= 0.6667)) || Coderate <= 0.25) + BG = 2; + else + BG = 1; + + Kb = nr_segmentation(dlsch->harq_processes[harq_pid]->b, + dlsch->harq_processes[harq_pid]->c, + dlsch->harq_processes[harq_pid]->B, + &dlsch->harq_processes[harq_pid]->C, + &dlsch->harq_processes[harq_pid]->K, + Zc, + &dlsch->harq_processes[harq_pid]->F, + BG); F = dlsch->harq_processes[harq_pid]->F; - Coderate = (float) A /(float) G; - - if ((A <=292) || ((A<=3824) && (Coderate <= 0.6667)) || Coderate <= 0.25){ - BG = 2; - } - else{ - BG = 1; - } Kr = dlsch->harq_processes[harq_pid]->K; #ifdef DEBUG_DLSCH_CODING @@ -364,7 +385,7 @@ int nr_dlsch_encoding(unsigned char *a,int frame, Kr_bytes = Kr>>3; #endif - //LOG_D(PHY,"segment Z %d k %d Kr %d BG %d\n", *pz,dlsch->harq_processes[harq_pid]->K,Kr,BG); + //printf("segment Z %d k %d Kr %d BG %d C %d\n", *Zc,dlsch->harq_processes[harq_pid]->K,Kr,BG,dlsch->harq_processes[harq_pid]->C); for (r=0; rharq_processes[harq_pid]->C; r++) { //d_tmp[r] = &dlsch->harq_processes[harq_pid]->d[r][0]; @@ -379,24 +400,15 @@ int nr_dlsch_encoding(unsigned char *a,int frame, LOG_D(PHY,"\n"); #endif - //ldpc_encoder_orig((unsigned char*)dlsch->harq_processes[harq_pid]->c[r],dlsch->harq_processes[harq_pid]->d[r],Kr,BG,0); - //ldpc_encoder_optim((unsigned char*)dlsch->harq_processes[harq_pid]->c[r],(unsigned char*)&dlsch->harq_processes[harq_pid]->d[r][0],Kr,BG,NULL,NULL,NULL,NULL); + //ldpc_encoder_orig((unsigned char*)dlsch->harq_processes[harq_pid]->c[r],dlsch->harq_processes[harq_pid]->d[r],*Zc,Kb,Kr,BG,0); + //ldpc_encoder_optim((unsigned char*)dlsch->harq_processes[harq_pid]->c[r],(unsigned char*)&dlsch->harq_processes[harq_pid]->d[r][0],*Zc,Kb,Kr,BG,NULL,NULL,NULL,NULL); } - //for (int i=0;i<68*384;i++) - // LOG_D(PHY,"channel_input[%d]=%d\n",i,channel_input[i]); + for(int j=0;j<(dlsch->harq_processes[harq_pid]->C/8+1);j++) { + ldpc_encoder_optim_8seg_multi(dlsch->harq_processes[harq_pid]->c,dlsch->harq_processes[harq_pid]->d,*Zc,Kb,Kr,BG,dlsch->harq_processes[harq_pid]->C,j,NULL,NULL,NULL,NULL); + } - - /*LOG_D(PHY,"output %d %d %d %d %d \n", dlsch->harq_processes[harq_pid]->d[0][0], dlsch->harq_processes[harq_pid]->d[0][1], dlsch->harq_processes[harq_pid]->d[r][2],dlsch->harq_processes[harq_pid]->d[0][3], dlsch->harq_processes[harq_pid]->d[0][4]); - for (int cnt =0 ; cnt < 66*(*pz); cnt ++){ - LOG_D(PHY,"%d \n", dlsch->harq_processes[harq_pid]->d[0][cnt]); - } - LOG_D(PHY,"\n");*/ - - //ldpc_encoder_optim_8seg(dlsch->harq_processes[harq_pid]->c,d_tmp,Kr,BG,dlsch->harq_processes[harq_pid]->C,NULL,NULL,NULL,NULL); - ldpc_encoder_optim_8seg(dlsch->harq_processes[harq_pid]->c,dlsch->harq_processes[harq_pid]->d,Kr,BG,dlsch->harq_processes[harq_pid]->C,NULL,NULL,NULL,NULL); - #ifdef DEBUG_DLSCH_CODING write_output("enc_input0.m","enc_in0",&dlsch->harq_processes[harq_pid]->c[0][0],Kr_bytes,1,4); write_output("enc_output0.m","enc0",&dlsch->harq_processes[harq_pid]->d[0][0],(3*8*Kr_bytes)+12,1,4); @@ -406,15 +418,16 @@ int nr_dlsch_encoding(unsigned char *a,int frame, for (r=0; rharq_processes[harq_pid]->C; r++) { - if (dlsch->harq_processes[harq_pid]->F>0) { - for (int k=(Kr-F-2*(*pz)); kharq_processes[harq_pid]->d[r][k] = NR_NULL; - //if (k<(Kr-F+8)) - //LOG_D(PHY,"r %d filler bits [%d] = %d \n", r,k, dlsch->harq_processes[harq_pid]->d[r][k]); - } - } + if (dlsch->harq_processes[harq_pid]->F>0) { + for (int k=(Kr-F-2*(*Zc)); kharq_processes[harq_pid]->d[r][k] = NR_NULL; + //if (k<(Kr-F+8)) + //printf("r %d filler bits [%d] = %d \n", r,k, dlsch->harq_processes[harq_pid]->d[r][k]); + } + } + #ifdef DEBUG_DLSCH_CODING - LOG_D(PHY,"Rate Matching, Code segment %d (coded bits (G) %d,unpunctured/repeated bits per code segment %d,mod_order %d, nb_rb %d)...\n", + printf("Rate Matching, Code segment %d (coded bits (G) %u, unpunctured/repeated bits per code segment %d, mod_order %d, nb_rb %d)...\n", r, G, Kr*3, @@ -427,26 +440,31 @@ int nr_dlsch_encoding(unsigned char *a,int frame, E = nr_get_E(G, dlsch->harq_processes[harq_pid]->C, mod_order, rel15->nb_layers, r); + // for tbslbrm calculation according to 5.4.2.1 of 38.212 + if (rel15.nb_layers < Nl) + Nl = rel15.nb_layers; + + Tbslbrm = nr_compute_tbslbrm(rel15.mcs_table,nb_rb,Nl,dlsch->harq_processes[harq_pid]->C); + nr_rate_matching_ldpc(Ilbrm, Tbslbrm, BG, - *pz, + *Zc, dlsch->harq_processes[harq_pid]->d[r], dlsch->harq_processes[harq_pid]->e+r_offset, dlsch->harq_processes[harq_pid]->C, rel15->redundancy_version, E); - #ifdef DEBUG_DLSCH_CODING for (int i =0; i<16; i++) LOG_D(PHY,"output ratematching e[%d]= %d r_offset %d\n", i,dlsch->harq_processes[harq_pid]->e[i+r_offset], r_offset); #endif nr_interleaving_ldpc(E, - mod_order, - dlsch->harq_processes[harq_pid]->e+r_offset, - dlsch->harq_processes[harq_pid]->f+r_offset); + mod_order, + dlsch->harq_processes[harq_pid]->e+r_offset, + dlsch->harq_processes[harq_pid]->f+r_offset); #ifdef DEBUG_DLSCH_CODING diff --git a/openair1/PHY/NR_TRANSPORT/nr_sch_dmrs.c b/openair1/PHY/NR_TRANSPORT/nr_sch_dmrs.c index 8d9bf00639..303282929f 100644 --- a/openair1/PHY/NR_TRANSPORT/nr_sch_dmrs.c +++ b/openair1/PHY/NR_TRANSPORT/nr_sch_dmrs.c @@ -85,7 +85,7 @@ uint8_t get_delta(uint8_t ap, uint8_t config) { return ((config==NFAPI_NR_DMRS_TYPE1)?(pdsch_dmrs_1[ap][2]):(pdsch_dmrs_2[ap][2])); } -uint16_t get_dmrs_freq_idx(uint8_t n, uint8_t k_prime, uint8_t delta, uint8_t dmrs_type) { +uint16_t get_dmrs_freq_idx(uint16_t n, uint8_t k_prime, uint8_t delta, uint8_t dmrs_type) { uint16_t dmrs_idx = (dmrs_type)? (6*n+k_prime+delta):((n<<2)+(k_prime<<1)+delta); return dmrs_idx; } diff --git a/openair1/PHY/NR_TRANSPORT/nr_sch_dmrs.h b/openair1/PHY/NR_TRANSPORT/nr_sch_dmrs.h index 02f454b7d0..6f07874ca0 100644 --- a/openair1/PHY/NR_TRANSPORT/nr_sch_dmrs.h +++ b/openair1/PHY/NR_TRANSPORT/nr_sch_dmrs.h @@ -45,6 +45,6 @@ void get_Wf(int8_t *Wf, uint8_t ap, uint8_t config); uint8_t get_delta(uint8_t ap, uint8_t config); -uint16_t get_dmrs_freq_idx(uint8_t n, uint8_t k_prime, uint8_t delta, uint8_t dmrs_type); +uint16_t get_dmrs_freq_idx(uint16_t n, uint8_t k_prime, uint8_t delta, uint8_t dmrs_type); uint8_t get_l0(uint8_t mapping_type, uint8_t dmrs_typeA_position); diff --git a/openair1/PHY/NR_TRANSPORT/nr_tbs_tools.c b/openair1/PHY/NR_TRANSPORT/nr_tbs_tools.c index 6060a04658..7777521c8b 100644 --- a/openair1/PHY/NR_TRANSPORT/nr_tbs_tools.c +++ b/openair1/PHY/NR_TRANSPORT/nr_tbs_tools.c @@ -31,7 +31,99 @@ */ #include "nr_transport_common_proto.h" +#include "PHY/CODING/coding_defs.h" +uint8_t nr_get_Qm_dl(uint8_t Imcs, uint8_t table_idx) { + switch(table_idx) { + case 0: + return (Table_51311[Imcs][0]); + break; + + case 1: + return (Table_51312[Imcs][0]); + break; + + case 2: + return (Table_51313[Imcs][0]); + break; + + default: + AssertFatal(0, "Invalid MCS table index %d (expected in range [1,3])\n", table_idx); + } +} + +uint32_t nr_get_code_rate_dl(uint8_t Imcs, uint8_t table_idx) { + switch(table_idx) { + case 0: + return (Table_51311[Imcs][1]); + break; + + case 1: + return (Table_51312[Imcs][1]); + break; + + case 2: + return (Table_51313[Imcs][1]); + break; + + default: + AssertFatal(0, "Invalid MCS table index %d (expected in range [1,3])\n", table_idx); + } +} + +uint8_t nr_get_Qm_ul(uint8_t Imcs, uint8_t table_idx) { + switch(table_idx) { + case 0: + return (Table_51311[Imcs][0]); + break; + + case 1: + return (Table_51312[Imcs][0]); + break; + + case 2: + return (Table_51313[Imcs][0]); + break; + + case 3: + return (Table_61411[Imcs][0]); + break; + + case 4: + return (Table_61412[Imcs][0]); + break; + + default: + AssertFatal(0, "Invalid MCS table index %d (expected in range [1,2])\n", table_idx); + } +} + +uint32_t nr_get_code_rate_ul(uint8_t Imcs, uint8_t table_idx) { + switch(table_idx) { + case 0: + return (Table_51311[Imcs][1]); + break; + + case 1: + return (Table_51312[Imcs][1]); + break; + + case 2: + return (Table_51313[Imcs][1]); + break; + + case 3: + return (Table_61411[Imcs][1]); + break; + + case 4: + return (Table_61412[Imcs][1]); + break; + + default: + AssertFatal(0, "Invalid MCS table index %d (expected in range [1,2])\n", table_idx); + } +} static inline uint8_t is_codeword_disabled(uint8_t format, uint8_t Imcs, uint8_t rv) { return ((format==NFAPI_NR_DL_DCI_FORMAT_1_1)&&(Imcs==26)&&(rv==1)); @@ -53,6 +145,53 @@ static inline uint8_t get_table_idx(uint8_t mcs_table, uint8_t dci_format, uint8 return 1; } +void nr_get_tbs_dl(nfapi_nr_dl_config_dlsch_pdu *dlsch_pdu, + nfapi_nr_dl_config_dci_dl_pdu dci_pdu, + nfapi_nr_config_request_t config) { + + LOG_D(MAC, "TBS calculation\n"); + + nfapi_nr_dl_config_pdcch_parameters_rel15_t params_rel15 = dci_pdu.pdcch_params_rel15; + nfapi_nr_dl_config_dlsch_pdu_rel15_t *dlsch_rel15 = &dlsch_pdu->dlsch_pdu_rel15; + uint8_t rnti_type = params_rel15.rnti_type; + uint16_t N_PRB_oh = ((rnti_type==NFAPI_NR_RNTI_SI)||(rnti_type==NFAPI_NR_RNTI_RA)||(rnti_type==NFAPI_NR_RNTI_P))? 0 : \ + (config.pdsch_config.x_overhead.value); + uint8_t N_PRB_DMRS = (config.pdsch_config.dmrs_type.value == NFAPI_NR_DMRS_TYPE1)?6:4; //This only works for antenna port 1000 + uint8_t N_sh_symb = dlsch_rel15->nb_symbols; + uint8_t Imcs = dlsch_rel15->mcs_idx; + uint16_t N_RE_prime = NR_NB_SC_PER_RB*N_sh_symb - N_PRB_DMRS - N_PRB_oh; + LOG_D(MAC, "N_RE_prime %d for %d symbols %d DMRS per PRB and %d overhead\n", N_RE_prime, N_sh_symb, N_PRB_DMRS, N_PRB_oh); + + uint16_t R; + uint32_t TBS=0; + uint8_t table_idx, Qm; + + /*uint8_t mcs_table = config.pdsch_config.mcs_table.value; + uint8_t ss_type = params_rel15.search_space_type; + uint8_t dci_format = params_rel15.dci_format; + get_table_idx(mcs_table, dci_format, rnti_type, ss_type);*/ + table_idx = 0; + R = nr_get_code_rate_dl(Imcs, table_idx); + Qm = nr_get_Qm_dl(Imcs, table_idx); + + TBS = nr_compute_tbs(Qm, + R, + dlsch_rel15->n_prb, + N_sh_symb, + N_PRB_DMRS, + N_PRB_oh, + dlsch_rel15->nb_layers); + + dlsch_rel15->coding_rate = R; + dlsch_rel15->modulation_order = Qm; + dlsch_rel15->transport_block_size = TBS; + dlsch_rel15->nb_re_dmrs = N_PRB_DMRS; + dlsch_rel15->nb_mod_symbols = N_RE_prime*dlsch_rel15->n_prb*dlsch_rel15->nb_codewords; + dlsch_rel15->mcs_table = table_idx; + + LOG_D(MAC, "TBS %d : N_PRB_DMRS %d N_sh_symb %d N_PRB_oh %d R %d Qm %d table %d nb_symbols %d\n", + TBS, N_PRB_DMRS, N_sh_symb, N_PRB_oh, R, Qm, table_idx, dlsch_rel15->nb_mod_symbols); +} uint32_t nr_get_G(uint16_t nb_rb, uint16_t nb_symb_sch,uint8_t nb_re_dmrs,uint16_t length_dmrs, uint8_t Qm, uint8_t Nl) { uint32_t G; diff --git a/openair1/PHY/NR_TRANSPORT/nr_transport_common_proto.h b/openair1/PHY/NR_TRANSPORT/nr_transport_common_proto.h index 018e36ce4e..909a01bfa1 100644 --- a/openair1/PHY/NR_TRANSPORT/nr_transport_common_proto.h +++ b/openair1/PHY/NR_TRANSPORT/nr_transport_common_proto.h @@ -43,13 +43,17 @@ #define NR_PUSCH_x 2 // UCI placeholder bit TS 38.212 V15.4.0 subclause 5.3.3.1 #define NR_PUSCH_y 3 // UCI placeholder bit -/** \brief Computes Q based on I_MCS PDSCH and table_idx. Implements Table 5.1.3.1-2 from 38.214. */ -uint8_t nr_get_Qm(uint8_t Imcs, uint8_t table_idx); +/** \brief Computes Q based on I_MCS PDSCH and table_idx for downlink. Implements MCS Tables from 38.214. */ +uint8_t nr_get_Qm_dl(uint8_t Imcs, uint8_t table_idx); +uint32_t nr_get_code_rate_dl(uint8_t Imcs, uint8_t table_idx); -uint32_t nr_get_code_rate(uint8_t Imcs, uint8_t table_idx); +/** \brief Computes Q based on I_MCS PDSCH and table_idx for uplink. Implements MCS Tables from 38.214. */ +uint8_t nr_get_Qm_ul(uint8_t Imcs, uint8_t table_idx); +uint32_t nr_get_code_rate_ul(uint8_t Imcs, uint8_t table_idx); -void nr_get_tbs(nfapi_nr_dl_config_dlsch_pdu *dlsch_pdu, - nfapi_nr_dl_config_dci_dl_pdu dci_pdu); +void nr_get_tbs_dl(nfapi_nr_dl_config_dlsch_pdu *dlsch_pdu, + nfapi_nr_dl_config_dci_dl_pdu dci_pdu, + nfapi_nr_config_request_t config); /** \brief Computes available bits G. */ uint32_t nr_get_G(uint16_t nb_rb, uint16_t nb_symb_sch, uint8_t nb_re_dmrs, uint16_t length_dmrs, uint8_t Qm, uint8_t Nl); diff --git a/openair1/PHY/NR_TRANSPORT/nr_transport_proto.h b/openair1/PHY/NR_TRANSPORT/nr_transport_proto.h index 2dbef1d733..aa5d16f613 100644 --- a/openair1/PHY/NR_TRANSPORT/nr_transport_proto.h +++ b/openair1/PHY/NR_TRANSPORT/nr_transport_proto.h @@ -65,7 +65,9 @@ void nr_rx_pusch(PHY_VARS_gNB *gNB, */ void nr_ulsch_extract_rbs_single(int **rxdataF, + int **ul_ch_estimates, int **rxdataF_ext, + int **ul_ch_estimates_ext, uint32_t rxdataF_ext_offset, // unsigned int *rb_alloc, [hna] Resource Allocation Type 1 is assumed only for the moment unsigned char symbol, @@ -73,6 +75,54 @@ void nr_ulsch_extract_rbs_single(int **rxdataF, unsigned short nb_rb_pusch, NR_DL_FRAME_PARMS *frame_parms); +void nr_ulsch_scale_channel(int32_t **ul_ch_estimates_ext, + NR_DL_FRAME_PARMS *frame_parms, + NR_gNB_ULSCH_t **ulsch_gNB, + uint8_t symbol, + uint8_t start_symbol, + uint16_t nb_rb); + + +/** \brief This function computes the average channel level over all allocated RBs and antennas (TX/RX) in order to compute output shift for compensated signal + @param ul_ch_estimates_ext Channel estimates in allocated RBs + @param frame_parms Pointer to frame descriptor + @param avg Pointer to average signal strength + @param pilots_flag Flag to indicate pilots in symbol + @param nb_rb Number of allocated RBs +*/ +void nr_ulsch_channel_level(int **ul_ch_estimates_ext, + NR_DL_FRAME_PARMS *frame_parms, + int32_t *avg, + uint8_t symbol, + uint32_t len, + unsigned short nb_rb); + + +/** \brief This function performs channel compensation (matched filtering) on the received RBs for this allocation. In addition, it computes the squared-magnitude of the channel with weightings for 16QAM/64QAM detection as well as dual-stream detection (cross-correlation) + @param rxdataF_ext Frequency-domain received signal in RBs to be demodulated + @param ul_ch_estimates_ext Frequency-domain channel estimates in RBs to be demodulated + @param ul_ch_mag First Channel magnitudes (16QAM/64QAM) + @param ul_ch_magb Second weighted Channel magnitudes (64QAM) + @param rxdataF_comp Compensated received waveform + @param frame_parms Pointer to frame descriptor + @param symbol Symbol on which to operate + @param Qm Modulation order of allocation + @param nb_rb Number of RBs in allocation + @param output_shift Rescaling for compensated output (should be energy-normalizing) +*/ +void nr_ulsch_channel_compensation(int **rxdataF_ext, + int **ul_ch_estimates_ext, + int **ul_ch_mag, + int **ul_ch_magb, + int **rxdataF_comp, + int **rho, + NR_DL_FRAME_PARMS *frame_parms, + unsigned char symbol, + uint8_t pilots, + unsigned char mod_order, + unsigned short nb_rb, + unsigned char output_shift); + /*! \brief This function implements the idft transform precoding in PUSCH \param z Pointer to input in frequnecy domain, and it is also the output in time domain @@ -102,6 +152,7 @@ void nr_ulsch_qpsk_llr(int32_t *rxdataF_comp, void nr_ulsch_16qam_llr(int32_t *rxdataF_comp, int32_t **ul_ch_mag, int16_t *ulsch_llr, + uint32_t nb_rb, uint32_t nb_re, uint8_t symbol); @@ -118,6 +169,7 @@ void nr_ulsch_64qam_llr(int32_t *rxdataF_comp, int32_t **ul_ch_mag, int32_t **ul_ch_magb, int16_t *ulsch_llr, + uint32_t nb_rb, uint32_t nb_re, uint8_t symbol); @@ -135,6 +187,7 @@ void nr_ulsch_compute_llr(int32_t *rxdataF_comp, int32_t **ul_ch_mag, int32_t **ul_ch_magb, int16_t *ulsch_llr, + uint32_t nb_rb, uint32_t nb_re, uint8_t symbol, uint8_t mod_order); \ No newline at end of file diff --git a/openair1/PHY/NR_TRANSPORT/nr_ulsch.h b/openair1/PHY/NR_TRANSPORT/nr_ulsch.h index 11521563e4..4942ffe2f4 100644 --- a/openair1/PHY/NR_TRANSPORT/nr_ulsch.h +++ b/openair1/PHY/NR_TRANSPORT/nr_ulsch.h @@ -75,7 +75,8 @@ void nr_ulsch_unscrambling(int16_t* llr, void nr_ulsch_procedures(PHY_VARS_gNB *gNB, - gNB_L1_rxtx_proc_t *proc, + int frame_rx, + int slot_rx, int UE_id, uint8_t harq_pid); diff --git a/openair1/PHY/NR_TRANSPORT/nr_ulsch_decoding.c b/openair1/PHY/NR_TRANSPORT/nr_ulsch_decoding.c index 6ca2733120..3b79d425ad 100644 --- a/openair1/PHY/NR_TRANSPORT/nr_ulsch_decoding.c +++ b/openair1/PHY/NR_TRANSPORT/nr_ulsch_decoding.c @@ -50,6 +50,7 @@ //#define DEBUG_ULSCH_DECODING #define OAI_UL_LDPC_MAX_NUM_LLR 27000//26112 // NR_LDPC_NCOL_BG1*NR_LDPC_ZMAX = 68*384 +#define PRINT_CRC_CHECK static uint64_t nb_total_decod =0; static uint64_t nb_error_decod =0; @@ -176,96 +177,96 @@ void clean_gNB_ulsch(NR_gNB_ULSCH_t *ulsch) unsigned char i, j; if (ulsch) { - ulsch->harq_mask = 0; - ulsch->bundling = 0; - ulsch->beta_offset_cqi_times8 = 0; - ulsch->beta_offset_ri_times8 = 0; - ulsch->beta_offset_harqack_times8 = 0; - ulsch->Msg3_active = 0; - ulsch->Msg3_flag = 0; - ulsch->Msg3_subframe = 0; - ulsch->Msg3_frame = 0; - ulsch->rnti = 0; - ulsch->rnti_type = 0; - ulsch->cyclicShift = 0; - ulsch->cooperation_flag = 0; - ulsch->Mlimit = 0; - ulsch->max_ldpc_iterations = 0; - ulsch->last_iteration_cnt = 0; - ulsch->num_active_cba_groups = 0; - for (i=0;icba_rnti[i] = 0; - for (i=0;iharq_process_id[i] = 0; + ulsch->harq_mask = 0; + ulsch->bundling = 0; + ulsch->beta_offset_cqi_times8 = 0; + ulsch->beta_offset_ri_times8 = 0; + ulsch->beta_offset_harqack_times8 = 0; + ulsch->Msg3_active = 0; + ulsch->Msg3_flag = 0; + ulsch->Msg3_subframe = 0; + ulsch->Msg3_frame = 0; + ulsch->rnti = 0; + ulsch->rnti_type = 0; + ulsch->cyclicShift = 0; + ulsch->cooperation_flag = 0; + ulsch->Mlimit = 0; + ulsch->max_ldpc_iterations = 0; + ulsch->last_iteration_cnt = 0; + ulsch->num_active_cba_groups = 0; + for (i=0;icba_rnti[i] = 0; + for (i=0;iharq_process_id[i] = 0; - for (i=0; iharq_processes[i]){ - /// Nfapi ULSCH PDU - //nfapi_nr_ul_config_ulsch_pdu ulsch_pdu; - ulsch->harq_processes[i]->frame=0; - ulsch->harq_processes[i]->subframe=0; - ulsch->harq_processes[i]->round=0; - ulsch->harq_processes[i]->TPC=0; - ulsch->harq_processes[i]->mimo_mode=0; - ulsch->harq_processes[i]->dci_alloc=0; - ulsch->harq_processes[i]->rar_alloc=0; - ulsch->harq_processes[i]->status=0; - ulsch->harq_processes[i]->subframe_scheduling_flag=0; - ulsch->harq_processes[i]->subframe_cba_scheduling_flag=0; - ulsch->harq_processes[i]->phich_active=0; - ulsch->harq_processes[i]->phich_ACK=0; - ulsch->harq_processes[i]->previous_first_rb=0; - ulsch->harq_processes[i]->handled=0; - ulsch->harq_processes[i]->delta_TF=0; + for (i=0; iharq_processes[i]){ + /// Nfapi ULSCH PDU + //nfapi_nr_ul_config_ulsch_pdu ulsch_pdu; + ulsch->harq_processes[i]->frame=0; + ulsch->harq_processes[i]->subframe=0; + ulsch->harq_processes[i]->round=0; + ulsch->harq_processes[i]->TPC=0; + ulsch->harq_processes[i]->mimo_mode=0; + ulsch->harq_processes[i]->dci_alloc=0; + ulsch->harq_processes[i]->rar_alloc=0; + ulsch->harq_processes[i]->status=0; + ulsch->harq_processes[i]->subframe_scheduling_flag=0; + ulsch->harq_processes[i]->subframe_cba_scheduling_flag=0; + ulsch->harq_processes[i]->phich_active=0; + ulsch->harq_processes[i]->phich_ACK=0; + ulsch->harq_processes[i]->previous_first_rb=0; + ulsch->harq_processes[i]->handled=0; + ulsch->harq_processes[i]->delta_TF=0; - ulsch->harq_processes[i]->TBS=0; - /// Pointer to the payload (38.212 V15.4.0 section 5.1) - //uint8_t *b; - ulsch->harq_processes[i]->B=0; - /// Pointers to code blocks after code block segmentation and CRC attachment (38.212 V15.4.0 section 5.2.2) - //uint8_t *c[MAX_NUM_NR_ULSCH_SEGMENTS]; - ulsch->harq_processes[i]->K=0; - ulsch->harq_processes[i]->F=0; - ulsch->harq_processes[i]->C=0; - /// Pointers to code blocks after LDPC coding (38.212 V15.4.0 section 5.3.2) - //int16_t *d[MAX_NUM_NR_ULSCH_SEGMENTS]; - /// LDPC processing buffer - //t_nrLDPC_procBuf* p_nrLDPC_procBuf[MAX_NUM_NR_ULSCH_SEGMENTS]; - ulsch->harq_processes[i]->Z=0; - /// code blocks after bit selection in rate matching for LDPC code (38.212 V15.4.0 section 5.4.2.1) - //int16_t e[MAX_NUM_NR_DLSCH_SEGMENTS][3*8448]; - ulsch->harq_processes[i]->E=0; + ulsch->harq_processes[i]->TBS=0; + /// Pointer to the payload (38.212 V15.4.0 section 5.1) + //uint8_t *b; + ulsch->harq_processes[i]->B=0; + /// Pointers to code blocks after code block segmentation and CRC attachment (38.212 V15.4.0 section 5.2.2) + //uint8_t *c[MAX_NUM_NR_ULSCH_SEGMENTS]; + ulsch->harq_processes[i]->K=0; + ulsch->harq_processes[i]->F=0; + ulsch->harq_processes[i]->C=0; + /// Pointers to code blocks after LDPC coding (38.212 V15.4.0 section 5.3.2) + //int16_t *d[MAX_NUM_NR_ULSCH_SEGMENTS]; + /// LDPC processing buffer + //t_nrLDPC_procBuf* p_nrLDPC_procBuf[MAX_NUM_NR_ULSCH_SEGMENTS]; + ulsch->harq_processes[i]->Z=0; + /// code blocks after bit selection in rate matching for LDPC code (38.212 V15.4.0 section 5.4.2.1) + //int16_t e[MAX_NUM_NR_DLSCH_SEGMENTS][3*8448]; + ulsch->harq_processes[i]->E=0; - ulsch->harq_processes[i]->n_DMRS=0; - ulsch->harq_processes[i]->n_DMRS2=0; - ulsch->harq_processes[i]->previous_n_DMRS=0; + ulsch->harq_processes[i]->n_DMRS=0; + ulsch->harq_processes[i]->n_DMRS2=0; + ulsch->harq_processes[i]->previous_n_DMRS=0; - ulsch->harq_processes[i]->cqi_crc_status=0; - for (j=0;jharq_processes[i]->o[j]=0; - ulsch->harq_processes[i]->uci_format=0; - ulsch->harq_processes[i]->Or1=0; - ulsch->harq_processes[i]->Or2=0; - ulsch->harq_processes[i]->o_RI[0]=0; ulsch->harq_processes[i]->o_RI[1]=0; - ulsch->harq_processes[i]->O_RI=0; - ulsch->harq_processes[i]->o_ACK[0]=0; ulsch->harq_processes[i]->o_ACK[1]=0; - ulsch->harq_processes[i]->o_ACK[2]=0; ulsch->harq_processes[i]->o_ACK[3]=0; - ulsch->harq_processes[i]->O_ACK=0; - ulsch->harq_processes[i]->V_UL_DAI=0; - /// "q" sequences for CQI/PMI (for definition see 36-212 V8.6 2009-03, p.27) - //int8_t q[MAX_CQI_PAYLOAD]; - ulsch->harq_processes[i]->o_RCC=0; - /// coded and interleaved CQI bits - //int8_t o_w[(MAX_CQI_BITS+8)*3]; - /// coded CQI bits - //int8_t o_d[96+((MAX_CQI_BITS+8)*3)]; - for (j=0;jharq_processes[i]->q_ACK[j]=0; - for (j=0;jharq_processes[i]->q_RI[j]=0; - /// Temporary h sequence to flag PUSCH_x/PUSCH_y symbols which are not scrambled - //uint8_t h[MAX_NUM_CHANNEL_BITS]; - /// soft bits for each received segment ("w"-sequence)(for definition see 36-212 V8.6 2009-03, p.15) - //int16_t w[MAX_NUM_ULSCH_SEGMENTS][3*(6144+64)]; - } - } + ulsch->harq_processes[i]->cqi_crc_status=0; + for (j=0;jharq_processes[i]->o[j]=0; + ulsch->harq_processes[i]->uci_format=0; + ulsch->harq_processes[i]->Or1=0; + ulsch->harq_processes[i]->Or2=0; + ulsch->harq_processes[i]->o_RI[0]=0; ulsch->harq_processes[i]->o_RI[1]=0; + ulsch->harq_processes[i]->O_RI=0; + ulsch->harq_processes[i]->o_ACK[0]=0; ulsch->harq_processes[i]->o_ACK[1]=0; + ulsch->harq_processes[i]->o_ACK[2]=0; ulsch->harq_processes[i]->o_ACK[3]=0; + ulsch->harq_processes[i]->O_ACK=0; + ulsch->harq_processes[i]->V_UL_DAI=0; + /// "q" sequences for CQI/PMI (for definition see 36-212 V8.6 2009-03, p.27) + //int8_t q[MAX_CQI_PAYLOAD]; + ulsch->harq_processes[i]->o_RCC=0; + /// coded and interleaved CQI bits + //int8_t o_w[(MAX_CQI_BITS+8)*3]; + /// coded CQI bits + //int8_t o_d[96+((MAX_CQI_BITS+8)*3)]; + for (j=0;jharq_processes[i]->q_ACK[j]=0; + for (j=0;jharq_processes[i]->q_RI[j]=0; + /// Temporary h sequence to flag PUSCH_x/PUSCH_y symbols which are not scrambled + //uint8_t h[MAX_NUM_CHANNEL_BITS]; + /// soft bits for each received segment ("w"-sequence)(for definition see 36-212 V8.6 2009-03, p.15) + //int16_t w[MAX_NUM_ULSCH_SEGMENTS][3*(6144+64)]; + } + } } } @@ -287,7 +288,6 @@ uint32_t nr_ulsch_decoding(PHY_VARS_gNB *phy_vars_gNB, uint32_t r,r_offset=0,Kr=8424,Kr_bytes,K_bytes_F,err_flag=0; uint8_t crc_type; int8_t llrProcBuf[OAI_UL_LDPC_MAX_NUM_LLR] __attribute__ ((aligned(32))); - NR_gNB_ULSCH_t *ulsch = phy_vars_gNB->ulsch[UE_id+1][0]; NR_UL_gNB_HARQ_t *harq_process = ulsch->harq_processes[harq_pid]; @@ -310,6 +310,7 @@ uint32_t nr_ulsch_decoding(PHY_VARS_gNB *phy_vars_gNB, uint16_t nb_rb = nfapi_ulsch_pdu_rel15->number_rbs; uint16_t number_symbols = nfapi_ulsch_pdu_rel15->number_symbols; uint8_t Qm = nfapi_ulsch_pdu_rel15->Qm; + uint16_t R = nfapi_ulsch_pdu_rel15->R; uint8_t mcs = nfapi_ulsch_pdu_rel15->mcs; uint8_t n_layers = nfapi_ulsch_pdu_rel15->n_layers; uint8_t nb_re_dmrs = nfapi_ulsch_pdu_rel15->nb_re_dmrs; @@ -324,60 +325,42 @@ uint32_t nr_ulsch_decoding(PHY_VARS_gNB *phy_vars_gNB, if (!ulsch_llr) { printf("ulsch_decoding.c: NULL ulsch_llr pointer\n"); - return(ulsch->max_ldpc_iterations); + return (ulsch->max_ldpc_iterations + 1); } if (!harq_process) { printf("ulsch_decoding.c: NULL harq_process pointer\n"); - return(ulsch->max_ldpc_iterations); + return (ulsch->max_ldpc_iterations + 1); } if (!frame_parms) { printf("ulsch_decoding.c: NULL frame_parms pointer\n"); - return(ulsch->max_ldpc_iterations); + return (ulsch->max_ldpc_iterations + 1); } // harq_process->trials[nfapi_ulsch_pdu_rel15->round]++; - - harq_process->TBS = nr_compute_tbs(mcs, nb_rb, number_symbols, nb_re_dmrs, length_dmrs, n_layers); + harq_process->TBS = nr_compute_tbs(Qm, R, nb_rb, number_symbols, nb_re_dmrs*length_dmrs, 0, n_layers); A = harq_process->TBS; - ret = ulsch->max_ldpc_iterations; - - G = nr_get_G(nb_rb, number_symbols, nb_re_dmrs, length_dmrs, Qm, n_layers); - // G = 0; - // G = nr_get_G(nb_rb, nb_symb_sch, nb_re_dmrs, length_dmrs, nfapi_ulsch_pdu_rel15->Qm, nfapi_ulsch_pdu_rel15->n_layers); + ret = ulsch->max_ldpc_iterations + 1; - LOG_I(PHY,"ULSCH Decoding, harq_pid %d TBS %d G %d mcs %d Nl %d nb_symb_sch %d nb_rb %d\n",harq_pid,A,G, mcs, n_layers, nb_symb_sch,nb_rb); + G = nr_get_G(nb_rb, number_symbols, nb_re_dmrs, length_dmrs, Qm, n_layers); + + LOG_D(PHY,"ULSCH Decoding, harq_pid %d TBS %d G %d mcs %d Nl %d nb_symb_sch %d nb_rb %d\n",harq_pid,A,G, mcs, n_layers, nb_symb_sch,nb_rb); if (harq_process->round == 0) { // This is a new packet, so compute quantities regarding segmentation harq_process->B = A+24; - // [hna] Perform nr_segmenation with input and output set to NULL to calculate only (B, C, K, Z, F) - nr_segmentation(NULL, - NULL, - harq_process->B, - &harq_process->C, - &harq_process->K, - &harq_process->Z, // [hna] Z is Zc - &harq_process->F); + if (R<1024) + Coderate = (float) R /(float) 1024; + else + Coderate = (float) R /(float) 2048; - p_decParams->Z = harq_process->Z; - -#ifdef DEBUG_ULSCH_DECODING - printf("ulsch decoding nr segmentation Z %d\n", p_decParams->Z); - if (!frame%100) - printf("K %d C %d Z %d nl %d \n", harq_process->K, harq_process->C, p_decParams->Z, harq_process->Nl); -#endif - } - - Coderate = (float) A /(float) G; - - if ((A <=292) || ((A<=3824) && (Coderate <= 0.6667)) || Coderate <= 0.25){ - p_decParams->BG = 2; - if (Coderate < 0.3333) { + if ((A <=292) || ((A<=3824) && (Coderate <= 0.6667)) || Coderate <= 0.25){ + p_decParams->BG = 2; + if (Coderate < 0.3333) { p_decParams->R = 15; kc = 52; } @@ -405,8 +388,23 @@ uint32_t nr_ulsch_decoding(PHY_VARS_gNB *phy_vars_gNB, } } - //printf("coderate %f kc %d \n", Coderate, kc); + // [hna] Perform nr_segmenation with input and output set to NULL to calculate only (B, C, K, Z, F) + nr_segmentation(NULL, + NULL, + harq_process->B, + &harq_process->C, + &harq_process->K, + &harq_process->Z, // [hna] Z is Zc + &harq_process->F, + p_decParams->BG); +#ifdef DEBUG_ULSCH_DECODING + printf("ulsch decoding nr segmentation Z %d\n", harq_process->Z); + if (!frame%100) + printf("K %d C %d Z %d nl %d \n", harq_process->K, harq_process->C, harq_process->Z, harq_process->Nl); +#endif + } + p_decParams->Z = harq_process->Z; p_decParams->numMaxIter = ulsch->max_ldpc_iterations; @@ -430,21 +428,19 @@ uint32_t nr_ulsch_decoding(PHY_VARS_gNB *phy_vars_gNB, if (harq_process->C > MAX_NUM_NR_ULSCH_SEGMENTS/bw_scaling) { LOG_E(PHY,"Illegal harq_process->C %d > %d\n",harq_process->C,MAX_NUM_NR_ULSCH_SEGMENTS/bw_scaling); - return((1+ulsch->max_ldpc_iterations)); + return (ulsch->max_ldpc_iterations + 1); } #ifdef DEBUG_ULSCH_DECODING printf("Segmentation: C %d, K %d\n",harq_process->C,harq_process->K); #endif - opp_enabled=1; + //opp_enabled=1; - Kr = harq_process->K; // [hna] overwrites this line "Kr = p_decParams->Z*kb" + Kr = harq_process->K; Kr_bytes = Kr>>3; K_bytes_F = Kr_bytes-(harq_process->F>>3); - Tbslbrm = nr_compute_tbs(28,nb_rb,frame_parms->symbols_per_slot,0,0, nfapi_ulsch_pdu_rel15->n_layers); - for (r=0; rC; r++) { E = nr_get_E(G, harq_process->C, nfapi_ulsch_pdu_rel15->Qm, nfapi_ulsch_pdu_rel15->n_layers, r); @@ -494,6 +490,8 @@ uint32_t nr_ulsch_decoding(PHY_VARS_gNB *phy_vars_gNB, ///////////////////////// harq_process->e =====> harq_process->d ///////////////////////// + Tbslbrm = nr_compute_tbslbrm(0,nb_rb,nfapi_ulsch_pdu_rel15->n_layers,harq_process->C); + if (nr_rate_matching_ldpc_rx(Ilbrm, Tbslbrm, p_decParams->BG, @@ -508,7 +506,7 @@ uint32_t nr_ulsch_decoding(PHY_VARS_gNB *phy_vars_gNB, stop_meas(ulsch_rate_unmatching_stats); #endif LOG_E(PHY,"ulsch_decoding.c: Problem in rate_matching\n"); - return(ulsch->max_ldpc_iterations); + return (ulsch->max_ldpc_iterations + 1); } else { #if gNB_TIMING_TRACE stop_meas(ulsch_rate_unmatching_stats); @@ -584,19 +582,22 @@ uint32_t nr_ulsch_decoding(PHY_VARS_gNB *phy_vars_gNB, p_procTime); if (check_crc((uint8_t*)llrProcBuf,length_dec,harq_process->F,crc_type)) { + #ifdef PRINT_CRC_CHECK LOG_I(PHY, "Segment %d CRC OK\n",r); - ret = 2; + #endif + ret = no_iteration_ldpc; } else { + #ifdef PRINT_CRC_CHECK LOG_I(PHY, "CRC NOK\n"); - ret = 1+ulsch->max_ldpc_iterations; + #endif + ret = ulsch->max_ldpc_iterations + 1; } - + nb_total_decod++; + if (no_iteration_ldpc > ulsch->max_ldpc_iterations){ nb_error_decod++; } - - ret=no_iteration_ldpc; for (int m=0; m < Kr>>3; m ++) { harq_process->c[r][m]= (uint8_t) llrProcBuf[m]; @@ -615,7 +616,7 @@ uint32_t nr_ulsch_decoding(PHY_VARS_gNB *phy_vars_gNB, #endif } - if ((err_flag == 0) && (ret>=(1+ulsch->max_ldpc_iterations))) { + if ((err_flag == 0) && (ret >= (ulsch->max_ldpc_iterations + 1))) { // a Code segment is in error so break; LOG_D(PHY,"AbsSubframe %d.%d CRC failed, segment %d/%d \n",frame%1024,nr_tti_rx,r,harq_process->C-1); err_flag = 1; @@ -642,7 +643,7 @@ uint32_t nr_ulsch_decoding(PHY_VARS_gNB *phy_vars_gNB, // harq_process->harq_ack.harq_id = harq_pid; // harq_process->harq_ack.send_harq_status = 1; // harq_process->errors[harq_process->round]++; - harq_process->round++; + //harq_process->round++; if (harq_process->round >= ulsch->Mlimit) { harq_process->status = SCH_IDLE; @@ -657,7 +658,7 @@ uint32_t nr_ulsch_decoding(PHY_VARS_gNB *phy_vars_gNB, } harq_process->handled = 1; - return((1+ulsch->max_ldpc_iterations)); + return (ulsch->max_ldpc_iterations + 1); } else { diff --git a/openair1/PHY/NR_TRANSPORT/nr_ulsch_demodulation.c b/openair1/PHY/NR_TRANSPORT/nr_ulsch_demodulation.c index d70e61e358..e1b3c5cec9 100644 --- a/openair1/PHY/NR_TRANSPORT/nr_ulsch_demodulation.c +++ b/openair1/PHY/NR_TRANSPORT/nr_ulsch_demodulation.c @@ -3,8 +3,13 @@ #include "nr_transport_proto.h" #include "PHY/impl_defs_top.h" #include "PHY/NR_TRANSPORT/nr_sch_dmrs.h" +#include "PHY/NR_ESTIMATION/nr_ul_estimation.h" #include "PHY/defs_nr_common.h" +//#define DEBUG_CH_COMP +//#define DEBUG_RB_EXT +//#define DEBUG_CH_MAG + void nr_idft(uint32_t *z, uint32_t Msc_PUSCH) { @@ -216,7 +221,9 @@ void nr_idft(uint32_t *z, uint32_t Msc_PUSCH) } void nr_ulsch_extract_rbs_single(int **rxdataF, + int **ul_ch_estimates, int **rxdataF_ext, + int **ul_ch_estimates_ext, uint32_t rxdataF_ext_offset, // unsigned int *rb_alloc, [hna] Resource Allocation Type 1 is assumed only for the moment unsigned char symbol, @@ -227,12 +234,22 @@ void nr_ulsch_extract_rbs_single(int **rxdataF, unsigned short start_re, re, nb_re_pusch; unsigned char aarx, is_dmrs_symbol = 0; uint32_t rxF_ext_index = 0; + uint32_t ul_ch0_ext_index = 0; + uint32_t ul_ch0_index = 0; int16_t *rxF,*rxF_ext; + int *ul_ch0,*ul_ch0_ext; + +#ifdef DEBUG_RB_EXT + + printf("--------------------symbol = %d-----------------------\n", symbol); + printf("--------------------ch_ext_index = %d-----------------------\n", symbol*NR_NB_SC_PER_RB * nb_rb_pusch); + +#endif is_dmrs_symbol = (symbol == 2) ? 1 : 0; //to be updated from config - start_re = frame_parms->first_carrier_offset + (start_rb * NR_NB_SC_PER_RB); + start_re = (frame_parms->first_carrier_offset + (start_rb * NR_NB_SC_PER_RB))%frame_parms->ofdm_symbol_size; nb_re_pusch = NR_NB_SC_PER_RB * nb_rb_pusch; @@ -241,19 +258,710 @@ void nr_ulsch_extract_rbs_single(int **rxdataF, rxF = (int16_t *)&rxdataF[aarx][symbol * frame_parms->ofdm_symbol_size]; rxF_ext = (int16_t *)&rxdataF_ext[aarx][symbol * nb_re_pusch]; // [hna] rxdataF_ext isn't contiguous in order to solve an alignment problem ib llr computation in case of mod_order = 4, 6 + ul_ch0 = &ul_ch_estimates[aarx][(2*(frame_parms->ofdm_symbol_size))]; // DMRS REs are only in symbol 2 (to be updated from config) + ul_ch0_ext = &ul_ch_estimates_ext[aarx][symbol*nb_re_pusch]; + for (re = 0; re < nb_re_pusch; re++) { if ( (is_dmrs_symbol && ((re&1) != 0)) || (is_dmrs_symbol == 0) ) { // [hna] (re&1) != frame_parms->nushift) assuming only dmrs type 1 and mapping type A // frame_parms->nushift should be initialized with 0 rxF_ext[rxF_ext_index] = (rxF[ ((start_re + re)*2) % (frame_parms->ofdm_symbol_size*2)]); rxF_ext[rxF_ext_index + 1] = (rxF[(((start_re + re)*2) + 1) % (frame_parms->ofdm_symbol_size*2)]); + ul_ch0_ext[ul_ch0_ext_index] = ul_ch0[ul_ch0_index]; + + #ifdef DEBUG_RB_EXT + printf("rxF_ext[%d] = %d\n", rxF_ext_index, rxF_ext[rxF_ext_index]); + printf("rxF_ext[%d] = %d\n", rxF_ext_index+1, rxF_ext[rxF_ext_index+1]); + printf("ul_ch0_ext[%d] = %d\n", 2*ul_ch0_ext_index, ((int16_t *)ul_ch0_ext)[2*ul_ch0_ext_index]); + printf("ul_ch0_ext[%d] = %d\n", 2*ul_ch0_ext_index + 1, ((int16_t *)ul_ch0_ext)[2*ul_ch0_ext_index + 1]); + #endif + rxF_ext_index = rxF_ext_index + 2; + ul_ch0_ext_index++; } + ul_ch0_index++; } } } +void nr_ulsch_scale_channel(int **ul_ch_estimates_ext, + NR_DL_FRAME_PARMS *frame_parms, + NR_gNB_ULSCH_t **ulsch_gNB, + uint8_t symbol, + uint8_t pilots, + unsigned short nb_rb) +{ +#if defined(__x86_64__)||defined(__i386__) + + short rb, ch_amp; + unsigned char aatx,aarx; + __m128i *ul_ch128, ch_amp128; + + // Determine scaling amplitude based the symbol + + ch_amp = 1024*8; //((pilots) ? (ulsch_gNB[0]->sqrt_rho_b) : (ulsch_gNB[0]->sqrt_rho_a)); + + LOG_D(PHY,"Scaling PUSCH Chest in OFDM symbol %d by %d, pilots %d nb_rb %d NCP %d symbol %d\n", symbol, ch_amp, pilots, nb_rb, frame_parms->Ncp, symbol); + // printf("Scaling PUSCH Chest in OFDM symbol %d by %d\n",symbol_mod,ch_amp); + + ch_amp128 = _mm_set1_epi16(ch_amp); // Q3.13 + + for (aatx=0; aatx < frame_parms->nb_antenna_ports_eNB; aatx++) { + for (aarx=0; aarx < frame_parms->nb_antennas_rx; aarx++) { + + ul_ch128 = (__m128i *)&ul_ch_estimates_ext[aarx][symbol*nb_rb*NR_NB_SC_PER_RB]; + + if (pilots==1){ + nb_rb = nb_rb>>1; + } + + + for (rb=0;rb>x; + + for (aatx = 0; aatx < frame_parms->nb_antennas_tx; aatx++) + for (aarx = 0; aarx < frame_parms->nb_antennas_rx; aarx++) { + //clear average level + avg128U = _mm_setzero_si128(); + + ul_ch128=(__m128i *)&ul_ch_estimates_ext[(aatx<<1)+aarx][symbol*nb_rb*12]; + + for (rb = 0; rb < nb_rb; rb++) { + avg128U = _mm_add_epi32(avg128U, _mm_srai_epi32(_mm_madd_epi16(ul_ch128[0], ul_ch128[0]), x)); + avg128U = _mm_add_epi32(avg128U, _mm_srai_epi32(_mm_madd_epi16(ul_ch128[1], ul_ch128[1]), x)); + avg128U = _mm_add_epi32(avg128U, _mm_srai_epi32(_mm_madd_epi16(ul_ch128[2], ul_ch128[2]), x)); + ul_ch128+=3; + } + + avg[(aatx<<1)+aarx] = (((int32_t*)&avg128U)[0] + + ((int32_t*)&avg128U)[1] + + ((int32_t*)&avg128U)[2] + + ((int32_t*)&avg128U)[3] ) / y; + + } + + _mm_empty(); + _m_empty(); + +#elif defined(__arm__) + + short rb; + unsigned char aatx, aarx, nre = 12, symbol_mod; + int32x4_t avg128U; + int16x4_t *ul_ch128; + + symbol_mod = (symbol>=(7-frame_parms->Ncp)) ? symbol-(7-frame_parms->Ncp) : symbol; + + for (aatx=0; aatxnb_antenna_ports_eNB; aatx++) + for (aarx=0; aarxnb_antennas_rx; aarx++) { + //clear average level + avg128U = vdupq_n_s32(0); + // 5 is always a symbol with no pilots for both normal and extended prefix + + ul_ch128 = (int16x4_t *)&ul_ch_estimates_ext[(aatx<<1)+aarx][symbol*frame_parms->N_RB_UL*12]; + + for (rb = 0; rb < nb_rb; rb++) { + // printf("rb %d : ",rb); + // print_shorts("ch",&ul_ch128[0]); + avg128U = vqaddq_s32(avg128U, vmull_s16(ul_ch128[0], ul_ch128[0])); + avg128U = vqaddq_s32(avg128U, vmull_s16(ul_ch128[1], ul_ch128[1])); + avg128U = vqaddq_s32(avg128U, vmull_s16(ul_ch128[2], ul_ch128[2])); + avg128U = vqaddq_s32(avg128U, vmull_s16(ul_ch128[3], ul_ch128[3])); + + if (((symbol_mod == 0) || (symbol_mod == (frame_parms->Ncp-1)))&&(frame_parms->nb_antenna_ports_eNB!=1)) { + ul_ch128+=4; + } else { + avg128U = vqaddq_s32(avg128U, vmull_s16(ul_ch128[4], ul_ch128[4])); + avg128U = vqaddq_s32(avg128U, vmull_s16(ul_ch128[5], ul_ch128[5])); + ul_ch128+=6; + } + + /* + if (rb==0) { + print_shorts("ul_ch128",&ul_ch128[0]); + print_shorts("ul_ch128",&ul_ch128[1]); + print_shorts("ul_ch128",&ul_ch128[2]); + } + */ + } + + if (symbol==2) //assume start symbol 2 + nre=6; + else + nre=12; + + avg[(aatx<<1)+aarx] = (((int32_t*)&avg128U)[0] + + ((int32_t*)&avg128U)[1] + + ((int32_t*)&avg128U)[2] + + ((int32_t*)&avg128U)[3] ) / (nb_rb*nre); + } + + +#endif +} + +void nr_ulsch_channel_compensation(int **rxdataF_ext, + int **ul_ch_estimates_ext, + int **ul_ch_mag, + int **ul_ch_magb, + int **rxdataF_comp, + int **rho, + NR_DL_FRAME_PARMS *frame_parms, + unsigned char symbol, + uint8_t pilots, + unsigned char mod_order, + unsigned short nb_rb, + unsigned char output_shift) +{ + +#ifdef DEBUG_CH_COMP + int16_t *rxF, *ul_ch; + int prnt_idx; + + + rxF = (int16_t *)&rxdataF_ext[0][(symbol*nb_rb*12)]; + ul_ch = (int16_t *)&ul_ch_estimates_ext[0][symbol*nb_rb*12]; + + printf("--------------------symbol = %d, mod_order = %d, output_shift = %d-----------------------\n", symbol, mod_order, output_shift); + printf("----------------Before compansation------------------\n"); + + for (prnt_idx=0;prnt_idx<12*nb_rb*2;prnt_idx++){ + + printf("rxF[%d] = %d\n", prnt_idx, rxF[prnt_idx]); + printf("ul_ch[%d] = %d\n", prnt_idx, ul_ch[prnt_idx]); + + } + +#endif + +#ifdef DEBUG_CH_MAG + int16_t *ch_mag; + int print_idx; + + + ch_mag = (int16_t *)&ul_ch_mag[0][(symbol*nb_rb*12)]; + + printf("--------------------symbol = %d, mod_order = %d-----------------------\n", symbol, mod_order); + printf("----------------Before computation------------------\n"); + + for (print_idx=0;print_idx<50;print_idx++){ + + printf("ch_mag[%d] = %d\n", print_idx, ch_mag[print_idx]); + + } + +#endif + +#if defined(__i386) || defined(__x86_64) + + unsigned short rb; + unsigned char aatx,aarx; + __m128i *ul_ch128,*ul_ch128_2,*ul_ch_mag128,*ul_ch_mag128b,*rxdataF128,*rxdataF_comp128,*rho128; + __m128i mmtmpD0,mmtmpD1,mmtmpD2,mmtmpD3,QAM_amp128,QAM_amp128b; + QAM_amp128b = _mm_setzero_si128(); + + for (aatx=0; aatxnb_antennas_tx; aatx++) { + + if (mod_order == 4) { + QAM_amp128 = _mm_set1_epi16(QAM16_n1); // 2/sqrt(10) + QAM_amp128b = _mm_setzero_si128(); + } else if (mod_order == 6) { + QAM_amp128 = _mm_set1_epi16(QAM64_n1); // + QAM_amp128b = _mm_set1_epi16(QAM64_n2); + } + + // printf("comp: rxdataF_comp %p, symbol %d\n",rxdataF_comp[0],symbol); + + for (aarx=0; aarxnb_antennas_rx; aarx++) { + + ul_ch128 = (__m128i *)&ul_ch_estimates_ext[(aatx<<1)+aarx][symbol*nb_rb*12]; + ul_ch_mag128 = (__m128i *)&ul_ch_mag[(aatx<<1)+aarx][symbol*nb_rb*12]; + ul_ch_mag128b = (__m128i *)&ul_ch_magb[(aatx<<1)+aarx][symbol*nb_rb*12]; + rxdataF128 = (__m128i *)&rxdataF_ext[aarx][symbol*nb_rb*12]; + rxdataF_comp128 = (__m128i *)&rxdataF_comp[(aatx<<1)+aarx][symbol*nb_rb*12]; + + + for (rb=0; rb2) { + // get channel amplitude if not QPSK + + //print_shorts("ch:",(int16_t*)&ul_ch128[0]); + + mmtmpD0 = _mm_madd_epi16(ul_ch128[0],ul_ch128[0]); + mmtmpD0 = _mm_srai_epi32(mmtmpD0,output_shift); + + mmtmpD1 = _mm_madd_epi16(ul_ch128[1],ul_ch128[1]); + mmtmpD1 = _mm_srai_epi32(mmtmpD1,output_shift); + + mmtmpD0 = _mm_packs_epi32(mmtmpD0,mmtmpD1); + + // store channel magnitude here in a new field of ulsch + + ul_ch_mag128[0] = _mm_unpacklo_epi16(mmtmpD0,mmtmpD0); + ul_ch_mag128b[0] = ul_ch_mag128[0]; + ul_ch_mag128[0] = _mm_mulhi_epi16(ul_ch_mag128[0],QAM_amp128); + ul_ch_mag128[0] = _mm_slli_epi16(ul_ch_mag128[0],1); + + // print_ints("ch: = ",(int32_t*)&mmtmpD0); + // print_shorts("QAM_amp:",(int16_t*)&QAM_amp128); + // print_shorts("mag:",(int16_t*)&ul_ch_mag128[0]); + + ul_ch_mag128[1] = _mm_unpackhi_epi16(mmtmpD0,mmtmpD0); + ul_ch_mag128b[1] = ul_ch_mag128[1]; + ul_ch_mag128[1] = _mm_mulhi_epi16(ul_ch_mag128[1],QAM_amp128); + ul_ch_mag128[1] = _mm_slli_epi16(ul_ch_mag128[1],1); + + if (pilots==0) { + mmtmpD0 = _mm_madd_epi16(ul_ch128[2],ul_ch128[2]); + mmtmpD0 = _mm_srai_epi32(mmtmpD0,output_shift); + mmtmpD1 = _mm_packs_epi32(mmtmpD0,mmtmpD0); + + ul_ch_mag128[2] = _mm_unpacklo_epi16(mmtmpD1,mmtmpD1); + ul_ch_mag128b[2] = ul_ch_mag128[2]; + + ul_ch_mag128[2] = _mm_mulhi_epi16(ul_ch_mag128[2],QAM_amp128); + ul_ch_mag128[2] = _mm_slli_epi16(ul_ch_mag128[2],1); + } + + ul_ch_mag128b[0] = _mm_mulhi_epi16(ul_ch_mag128b[0],QAM_amp128b); + ul_ch_mag128b[0] = _mm_slli_epi16(ul_ch_mag128b[0],1); + + + ul_ch_mag128b[1] = _mm_mulhi_epi16(ul_ch_mag128b[1],QAM_amp128b); + ul_ch_mag128b[1] = _mm_slli_epi16(ul_ch_mag128b[1],1); + + if (pilots==0) { + ul_ch_mag128b[2] = _mm_mulhi_epi16(ul_ch_mag128b[2],QAM_amp128b); + ul_ch_mag128b[2] = _mm_slli_epi16(ul_ch_mag128b[2],1); + } + } + + // multiply by conjugated channel + mmtmpD0 = _mm_madd_epi16(ul_ch128[0],rxdataF128[0]); + // print_ints("re",&mmtmpD0); + + // mmtmpD0 contains real part of 4 consecutive outputs (32-bit) + mmtmpD1 = _mm_shufflelo_epi16(ul_ch128[0],_MM_SHUFFLE(2,3,0,1)); + mmtmpD1 = _mm_shufflehi_epi16(mmtmpD1,_MM_SHUFFLE(2,3,0,1)); + mmtmpD1 = _mm_sign_epi16(mmtmpD1,*(__m128i*)&conjugate[0]); + // print_ints("im",&mmtmpD1); + mmtmpD1 = _mm_madd_epi16(mmtmpD1,rxdataF128[0]); + // mmtmpD1 contains imag part of 4 consecutive outputs (32-bit) + mmtmpD0 = _mm_srai_epi32(mmtmpD0,output_shift); + // print_ints("re(shift)",&mmtmpD0); + mmtmpD1 = _mm_srai_epi32(mmtmpD1,output_shift); + // print_ints("im(shift)",&mmtmpD1); + mmtmpD2 = _mm_unpacklo_epi32(mmtmpD0,mmtmpD1); + mmtmpD3 = _mm_unpackhi_epi32(mmtmpD0,mmtmpD1); + // print_ints("c0",&mmtmpD2); + // print_ints("c1",&mmtmpD3); + rxdataF_comp128[0] = _mm_packs_epi32(mmtmpD2,mmtmpD3); + // print_shorts("rx:",rxdataF128); + // print_shorts("ch:",ul_ch128); + // print_shorts("pack:",rxdataF_comp128); + + // multiply by conjugated channel + mmtmpD0 = _mm_madd_epi16(ul_ch128[1],rxdataF128[1]); + // mmtmpD0 contains real part of 4 consecutive outputs (32-bit) + mmtmpD1 = _mm_shufflelo_epi16(ul_ch128[1],_MM_SHUFFLE(2,3,0,1)); + mmtmpD1 = _mm_shufflehi_epi16(mmtmpD1,_MM_SHUFFLE(2,3,0,1)); + mmtmpD1 = _mm_sign_epi16(mmtmpD1,*(__m128i*)conjugate); + mmtmpD1 = _mm_madd_epi16(mmtmpD1,rxdataF128[1]); + // mmtmpD1 contains imag part of 4 consecutive outputs (32-bit) + mmtmpD0 = _mm_srai_epi32(mmtmpD0,output_shift); + mmtmpD1 = _mm_srai_epi32(mmtmpD1,output_shift); + mmtmpD2 = _mm_unpacklo_epi32(mmtmpD0,mmtmpD1); + mmtmpD3 = _mm_unpackhi_epi32(mmtmpD0,mmtmpD1); + + rxdataF_comp128[1] = _mm_packs_epi32(mmtmpD2,mmtmpD3); + // print_shorts("rx:",rxdataF128+1); + // print_shorts("ch:",ul_ch128+1); + // print_shorts("pack:",rxdataF_comp128+1); + + if (pilots==0) { + // multiply by conjugated channel + mmtmpD0 = _mm_madd_epi16(ul_ch128[2],rxdataF128[2]); + // mmtmpD0 contains real part of 4 consecutive outputs (32-bit) + mmtmpD1 = _mm_shufflelo_epi16(ul_ch128[2],_MM_SHUFFLE(2,3,0,1)); + mmtmpD1 = _mm_shufflehi_epi16(mmtmpD1,_MM_SHUFFLE(2,3,0,1)); + mmtmpD1 = _mm_sign_epi16(mmtmpD1,*(__m128i*)conjugate); + mmtmpD1 = _mm_madd_epi16(mmtmpD1,rxdataF128[2]); + // mmtmpD1 contains imag part of 4 consecutive outputs (32-bit) + mmtmpD0 = _mm_srai_epi32(mmtmpD0,output_shift); + mmtmpD1 = _mm_srai_epi32(mmtmpD1,output_shift); + mmtmpD2 = _mm_unpacklo_epi32(mmtmpD0,mmtmpD1); + mmtmpD3 = _mm_unpackhi_epi32(mmtmpD0,mmtmpD1); + + rxdataF_comp128[2] = _mm_packs_epi32(mmtmpD2,mmtmpD3); + // print_shorts("rx:",rxdataF128+2); + // print_shorts("ch:",ul_ch128+2); + // print_shorts("pack:",rxdataF_comp128+2); + + ul_ch128+=3; + ul_ch_mag128+=3; + ul_ch_mag128b+=3; + rxdataF128+=3; + rxdataF_comp128+=3; + } else { // we have a smaller PUSCH in symbols with pilots so skip last group of 4 REs and increment less + ul_ch128+=2; + ul_ch_mag128+=2; + ul_ch_mag128b+=2; + rxdataF128+=2; + rxdataF_comp128+=2; + } + + } + } + } + + if (rho) { + + + for (aarx=0; aarxnb_antennas_rx; aarx++) { + rho128 = (__m128i *)&rho[aarx][symbol*frame_parms->N_RB_UL*12]; + ul_ch128 = (__m128i *)&ul_ch_estimates_ext[aarx][symbol*frame_parms->N_RB_UL*12]; + ul_ch128_2 = (__m128i *)&ul_ch_estimates_ext[2+aarx][symbol*frame_parms->N_RB_UL*12]; + + for (rb=0; rb=(7-frame_parms->Ncp)) ? symbol-(7-frame_parms->Ncp) : symbol; + + if ((symbol_mod == 0) || (symbol_mod == (4-frame_parms->Ncp))) { + if (frame_parms->nb_antenna_ports_eNB==1) { // 10 out of 12 so don't reduce size + nb_rb=1+(5*nb_rb/6); + } + else { + pilots=1; + } + } + + for (aatx=0; aatxnb_antenna_ports_eNB; aatx++) { + if (mod_order == 4) { + QAM_amp128 = vmovq_n_s16(QAM16_n1); // 2/sqrt(10) + QAM_amp128b = vmovq_n_s16(0); + } else if (mod_order == 6) { + QAM_amp128 = vmovq_n_s16(QAM64_n1); // + QAM_amp128b = vmovq_n_s16(QAM64_n2); + } + // printf("comp: rxdataF_comp %p, symbol %d\n",rxdataF_comp[0],symbol); + + for (aarx=0; aarxnb_antennas_rx; aarx++) { + ul_ch128 = (int16x4_t*)&ul_ch_estimates_ext[(aatx<<1)+aarx][symbol*frame_parms->N_RB_UL*12]; + ul_ch_mag128 = (int16x8_t*)&ul_ch_mag[(aatx<<1)+aarx][symbol*frame_parms->N_RB_UL*12]; + ul_ch_mag128b = (int16x8_t*)&ul_ch_magb[(aatx<<1)+aarx][symbol*frame_parms->N_RB_UL*12]; + rxdataF128 = (int16x4_t*)&rxdataF_ext[aarx][symbol*frame_parms->N_RB_UL*12]; + rxdataF_comp128 = (int16x4x2_t*)&rxdataF_comp[(aatx<<1)+aarx][symbol*frame_parms->N_RB_UL*12]; + + for (rb=0; rb2) { + // get channel amplitude if not QPSK + mmtmpD0 = vmull_s16(ul_ch128[0], ul_ch128[0]); + // mmtmpD0 = [ch0*ch0,ch1*ch1,ch2*ch2,ch3*ch3]; + mmtmpD0 = vqshlq_s32(vqaddq_s32(mmtmpD0,vrev64q_s32(mmtmpD0)),output_shift128); + // mmtmpD0 = [ch0*ch0 + ch1*ch1,ch0*ch0 + ch1*ch1,ch2*ch2 + ch3*ch3,ch2*ch2 + ch3*ch3]>>output_shift128 on 32-bits + mmtmpD1 = vmull_s16(ul_ch128[1], ul_ch128[1]); + mmtmpD1 = vqshlq_s32(vqaddq_s32(mmtmpD1,vrev64q_s32(mmtmpD1)),output_shift128); + mmtmpD2 = vcombine_s16(vmovn_s32(mmtmpD0),vmovn_s32(mmtmpD1)); + // mmtmpD2 = [ch0*ch0 + ch1*ch1,ch0*ch0 + ch1*ch1,ch2*ch2 + ch3*ch3,ch2*ch2 + ch3*ch3,ch4*ch4 + ch5*ch5,ch4*ch4 + ch5*ch5,ch6*ch6 + ch7*ch7,ch6*ch6 + ch7*ch7]>>output_shift128 on 16-bits + mmtmpD0 = vmull_s16(ul_ch128[2], ul_ch128[2]); + mmtmpD0 = vqshlq_s32(vqaddq_s32(mmtmpD0,vrev64q_s32(mmtmpD0)),output_shift128); + mmtmpD1 = vmull_s16(ul_ch128[3], ul_ch128[3]); + mmtmpD1 = vqshlq_s32(vqaddq_s32(mmtmpD1,vrev64q_s32(mmtmpD1)),output_shift128); + mmtmpD3 = vcombine_s16(vmovn_s32(mmtmpD0),vmovn_s32(mmtmpD1)); + if (pilots==0) { + mmtmpD0 = vmull_s16(ul_ch128[4], ul_ch128[4]); + mmtmpD0 = vqshlq_s32(vqaddq_s32(mmtmpD0,vrev64q_s32(mmtmpD0)),output_shift128); + mmtmpD1 = vmull_s16(ul_ch128[5], ul_ch128[5]); + mmtmpD1 = vqshlq_s32(vqaddq_s32(mmtmpD1,vrev64q_s32(mmtmpD1)),output_shift128); + mmtmpD4 = vcombine_s16(vmovn_s32(mmtmpD0),vmovn_s32(mmtmpD1)); + } + + ul_ch_mag128b[0] = vqdmulhq_s16(mmtmpD2,QAM_amp128b); + ul_ch_mag128b[1] = vqdmulhq_s16(mmtmpD3,QAM_amp128b); + ul_ch_mag128[0] = vqdmulhq_s16(mmtmpD2,QAM_amp128); + ul_ch_mag128[1] = vqdmulhq_s16(mmtmpD3,QAM_amp128); + + if (pilots==0) { + ul_ch_mag128b[2] = vqdmulhq_s16(mmtmpD4,QAM_amp128b); + ul_ch_mag128[2] = vqdmulhq_s16(mmtmpD4,QAM_amp128); + } + } + + mmtmpD0 = vmull_s16(ul_ch128[0], rxdataF128[0]); + //mmtmpD0 = [Re(ch[0])Re(rx[0]) Im(ch[0])Im(ch[0]) Re(ch[1])Re(rx[1]) Im(ch[1])Im(ch[1])] + mmtmpD1 = vmull_s16(ul_ch128[1], rxdataF128[1]); + //mmtmpD1 = [Re(ch[2])Re(rx[2]) Im(ch[2])Im(ch[2]) Re(ch[3])Re(rx[3]) Im(ch[3])Im(ch[3])] + mmtmpD0 = vcombine_s32(vpadd_s32(vget_low_s32(mmtmpD0),vget_high_s32(mmtmpD0)), + vpadd_s32(vget_low_s32(mmtmpD1),vget_high_s32(mmtmpD1))); + //mmtmpD0 = [Re(ch[0])Re(rx[0])+Im(ch[0])Im(ch[0]) Re(ch[1])Re(rx[1])+Im(ch[1])Im(ch[1]) Re(ch[2])Re(rx[2])+Im(ch[2])Im(ch[2]) Re(ch[3])Re(rx[3])+Im(ch[3])Im(ch[3])] + + mmtmpD0b = vmull_s16(vrev32_s16(vmul_s16(ul_ch128[0],*(int16x4_t*)conj)), rxdataF128[0]); + //mmtmpD0 = [-Im(ch[0])Re(rx[0]) Re(ch[0])Im(rx[0]) -Im(ch[1])Re(rx[1]) Re(ch[1])Im(rx[1])] + mmtmpD1b = vmull_s16(vrev32_s16(vmul_s16(ul_ch128[1],*(int16x4_t*)conj)), rxdataF128[1]); + //mmtmpD0 = [-Im(ch[2])Re(rx[2]) Re(ch[2])Im(rx[2]) -Im(ch[3])Re(rx[3]) Re(ch[3])Im(rx[3])] + mmtmpD1 = vcombine_s32(vpadd_s32(vget_low_s32(mmtmpD0b),vget_high_s32(mmtmpD0b)), + vpadd_s32(vget_low_s32(mmtmpD1b),vget_high_s32(mmtmpD1b))); + //mmtmpD1 = [-Im(ch[0])Re(rx[0])+Re(ch[0])Im(rx[0]) -Im(ch[1])Re(rx[1])+Re(ch[1])Im(rx[1]) -Im(ch[2])Re(rx[2])+Re(ch[2])Im(rx[2]) -Im(ch[3])Re(rx[3])+Re(ch[3])Im(rx[3])] + + mmtmpD0 = vqshlq_s32(mmtmpD0,output_shift128); + mmtmpD1 = vqshlq_s32(mmtmpD1,output_shift128); + rxdataF_comp128[0] = vzip_s16(vmovn_s32(mmtmpD0),vmovn_s32(mmtmpD1)); + mmtmpD0 = vmull_s16(ul_ch128[2], rxdataF128[2]); + mmtmpD1 = vmull_s16(ul_ch128[3], rxdataF128[3]); + mmtmpD0 = vcombine_s32(vpadd_s32(vget_low_s32(mmtmpD0),vget_high_s32(mmtmpD0)), + vpadd_s32(vget_low_s32(mmtmpD1),vget_high_s32(mmtmpD1))); + mmtmpD0b = vmull_s16(vrev32_s16(vmul_s16(ul_ch128[2],*(int16x4_t*)conj)), rxdataF128[2]); + mmtmpD1b = vmull_s16(vrev32_s16(vmul_s16(ul_ch128[3],*(int16x4_t*)conj)), rxdataF128[3]); + mmtmpD1 = vcombine_s32(vpadd_s32(vget_low_s32(mmtmpD0b),vget_high_s32(mmtmpD0b)), + vpadd_s32(vget_low_s32(mmtmpD1b),vget_high_s32(mmtmpD1b))); + mmtmpD0 = vqshlq_s32(mmtmpD0,output_shift128); + mmtmpD1 = vqshlq_s32(mmtmpD1,output_shift128); + rxdataF_comp128[1] = vzip_s16(vmovn_s32(mmtmpD0),vmovn_s32(mmtmpD1)); + + if (pilots==0) { + mmtmpD0 = vmull_s16(ul_ch128[4], rxdataF128[4]); + mmtmpD1 = vmull_s16(ul_ch128[5], rxdataF128[5]); + mmtmpD0 = vcombine_s32(vpadd_s32(vget_low_s32(mmtmpD0),vget_high_s32(mmtmpD0)), + vpadd_s32(vget_low_s32(mmtmpD1),vget_high_s32(mmtmpD1))); + + mmtmpD0b = vmull_s16(vrev32_s16(vmul_s16(ul_ch128[4],*(int16x4_t*)conj)), rxdataF128[4]); + mmtmpD1b = vmull_s16(vrev32_s16(vmul_s16(ul_ch128[5],*(int16x4_t*)conj)), rxdataF128[5]); + mmtmpD1 = vcombine_s32(vpadd_s32(vget_low_s32(mmtmpD0b),vget_high_s32(mmtmpD0b)), + vpadd_s32(vget_low_s32(mmtmpD1b),vget_high_s32(mmtmpD1b))); + + + mmtmpD0 = vqshlq_s32(mmtmpD0,output_shift128); + mmtmpD1 = vqshlq_s32(mmtmpD1,output_shift128); + rxdataF_comp128[2] = vzip_s16(vmovn_s32(mmtmpD0),vmovn_s32(mmtmpD1)); + + + ul_ch128+=6; + ul_ch_mag128+=3; + ul_ch_mag128b+=3; + rxdataF128+=6; + rxdataF_comp128+=3; + + } else { // we have a smaller PUSCH in symbols with pilots so skip last group of 4 REs and increment less + ul_ch128+=4; + ul_ch_mag128+=2; + ul_ch_mag128b+=2; + rxdataF128+=4; + rxdataF_comp128+=2; + } + } + } + } + + if (rho) { + for (aarx=0; aarxnb_antennas_rx; aarx++) { + rho128 = (int16x4x2_t*)&rho[aarx][symbol*frame_parms->N_RB_UL*12]; + ul_ch128 = (int16x4_t*)&ul_ch_estimates_ext[aarx][symbol*frame_parms->N_RB_UL*12]; + ul_ch128_2 = (int16x4_t*)&ul_ch_estimates_ext[2+aarx][symbol*frame_parms->N_RB_UL*12]; + for (rb=0; rbframe_parms; nfapi_nr_ul_config_ulsch_pdu_rel15_t *rel15_ul = &gNB->ulsch[UE_id+1][0]->harq_processes[harq_pid]->ulsch_pdu.ulsch_pdu_rel15; - uint32_t nb_re_pusch; - - if(symbol == rel15_ul->start_symbol) - gNB->pusch_vars[UE_id]->rxdataF_ext_offset = 0; + uint32_t nb_re_pusch, bwp_start_subcarrier; + int avgs; + int avg[4]; - if (symbol == 2) // [hna] here it is assumed that symbol 2 carries 6 DMRS REs (dmrs-type 1) + pilots = 0; + first_symbol_flag = 0; + + if(symbol == rel15_ul->start_symbol){ + gNB->pusch_vars[UE_id]->rxdataF_ext_offset = 0; + first_symbol_flag = 1; + } + + if (symbol == 2){ // [hna] here it is assumed that symbol 2 carries 6 DMRS REs (dmrs-type 1) nb_re_pusch = rel15_ul->number_rbs * 6; - else + pilots = 1; + } else { nb_re_pusch = rel15_ul->number_rbs * NR_NB_SC_PER_RB; + pilots = 0; + } + + bwp_start_subcarrier = (rel15_ul->start_rb*NR_NB_SC_PER_RB + frame_parms->first_carrier_offset) % frame_parms->ofdm_symbol_size; + + //---------------------------------------------------------- + //--------------------- Channel estimation --------------------- + //---------------------------------------------------------- + + if (pilots == 1) + nr_pusch_channel_estimation(gNB, + 0, + nr_tti_rx, + 0, // p + symbol, + bwp_start_subcarrier, + rel15_ul->number_rbs); //---------------------------------------------------------- //--------------------- RBs extraction --------------------- //---------------------------------------------------------- nr_ulsch_extract_rbs_single(gNB->common_vars.rxdataF, + gNB->pusch_vars[UE_id]->ul_ch_estimates, gNB->pusch_vars[UE_id]->rxdataF_ext, + gNB->pusch_vars[UE_id]->ul_ch_estimates_ext, gNB->pusch_vars[UE_id]->rxdataF_ext_offset, // rb_alloc, [hna] Resource Allocation Type 1 is assumed only for the moment symbol, @@ -288,6 +1024,44 @@ void nr_rx_pusch(PHY_VARS_gNB *gNB, rel15_ul->number_rbs, frame_parms); + nr_ulsch_scale_channel(gNB->pusch_vars[UE_id]->ul_ch_estimates_ext, + frame_parms, + gNB->ulsch[UE_id+1], + symbol, + pilots, + rel15_ul->number_rbs); + + if (first_symbol_flag==1) { + + nr_ulsch_channel_level(gNB->pusch_vars[UE_id]->ul_ch_estimates_ext, + frame_parms, + avg, + symbol, + nb_re_pusch, + rel15_ul->number_rbs); + avgs = 0; + + for (aatx=0;aatxnb_antennas_tx;aatx++) + for (aarx=0;aarxnb_antennas_rx;aarx++) + avgs = cmax(avgs,avg[(aatx<<1)+aarx]); + + gNB->pusch_vars[UE_id]->log2_maxh = (log2_approx(avgs)/2)+1; + + } + + nr_ulsch_channel_compensation(gNB->pusch_vars[UE_id]->rxdataF_ext, + gNB->pusch_vars[UE_id]->ul_ch_estimates_ext, + gNB->pusch_vars[UE_id]->ul_ch_mag0, + gNB->pusch_vars[UE_id]->ul_ch_magb0, + gNB->pusch_vars[UE_id]->rxdataF_comp, + (frame_parms->nb_antennas_tx>1) ? gNB->pusch_vars[UE_id]->rho : NULL, + frame_parms, + symbol, + pilots, + rel15_ul->Qm, + rel15_ul->number_rbs, + gNB->pusch_vars[UE_id]->log2_maxh); + #ifdef NR_SC_FDMA nr_idft(&((uint32_t*)gNB->pusch_vars[UE_id]->rxdataF_ext[0])[symbol * rel15_ul->number_rbs * NR_NB_SC_PER_RB], nb_re_pusch); #endif @@ -296,14 +1070,15 @@ void nr_rx_pusch(PHY_VARS_gNB *gNB, //-------------------- LLRs computation -------------------- //---------------------------------------------------------- - nr_ulsch_compute_llr(&gNB->pusch_vars[UE_id]->rxdataF_ext[0][symbol * rel15_ul->number_rbs * NR_NB_SC_PER_RB], - gNB->pusch_vars[UE_id]->ul_ch_mag, - gNB->pusch_vars[UE_id]->ul_ch_magb, + nr_ulsch_compute_llr(&gNB->pusch_vars[UE_id]->rxdataF_comp[0][symbol * rel15_ul->number_rbs * NR_NB_SC_PER_RB], + gNB->pusch_vars[UE_id]->ul_ch_mag0, + gNB->pusch_vars[UE_id]->ul_ch_magb0, &gNB->pusch_vars[UE_id]->llr[gNB->pusch_vars[UE_id]->rxdataF_ext_offset * rel15_ul->Qm], + rel15_ul->number_rbs, nb_re_pusch, symbol, rel15_ul->Qm); - + gNB->pusch_vars[UE_id]->rxdataF_ext_offset = gNB->pusch_vars[UE_id]->rxdataF_ext_offset + nb_re_pusch; } diff --git a/openair1/PHY/NR_TRANSPORT/nr_ulsch_llr_computation.c b/openair1/PHY/NR_TRANSPORT/nr_ulsch_llr_computation.c index d2d8cdd927..233ecd8de7 100644 --- a/openair1/PHY/NR_TRANSPORT/nr_ulsch_llr_computation.c +++ b/openair1/PHY/NR_TRANSPORT/nr_ulsch_llr_computation.c @@ -30,7 +30,6 @@ * \warning */ - #include "PHY/defs_nr_common.h" #include "PHY/sse_intrin.h" #include "PHY/impl_defs_top.h" @@ -71,23 +70,20 @@ void nr_ulsch_qpsk_llr(int32_t *rxdataF_comp, void nr_ulsch_16qam_llr(int32_t *rxdataF_comp, int32_t **ul_ch_mag, int16_t *ulsch_llr, + uint32_t nb_rb, uint32_t nb_re, uint8_t symbol) { + #if defined(__x86_64__) || defined(__i386__) __m128i *rxF = (__m128i*)rxdataF_comp; - // __m128i *ch_mag; // [hna] This should be uncommented once channel estimation is implemented + __m128i *ch_mag; __m128i llr128[2]; uint32_t *llr32; - // [hna] temp_channel and one_over_sqrt_2 are for temporary use until channel estimation is implemented - // else ul_ch_mag and ul_ch_magb should be used after channel estimation has benn implemented - __m128i temp_channel; - int16_t one_over_sqrt_2 = 23170; - #elif defined(__arm__) int16x8_t *rxF = (int16x8_t*)&rxdataF_comp; - // int16x8_t *ch_mag; // [hna] This should be uncommented once channel estimation is implemented + int16x8_t *ch_mag; int16x8_t xmm0; int16_t *llr16; #endif @@ -103,21 +99,16 @@ void nr_ulsch_16qam_llr(int32_t *rxdataF_comp, llr16 = (int16_t*)ulsch_llr; #endif -// [hna] This should be uncommented once channel estimation is implemented -// ------------------------------------------------------------ -// #if defined(__x86_64__) || defined(__i386__) -// ch_mag = (__m128i*)&ul_ch_mag[0][(symbol*nb_rb*12)]; -// #elif defined(__arm__) -// ch_mag = (int16x8_t*)&ul_ch_mag[0][(symbol*nb_rb*12)]; -// #endif -// ------------------------------------------------------------ +#if defined(__x86_64__) || defined(__i386__) + ch_mag = (__m128i*)&ul_ch_mag[0][(symbol*nb_rb*12)]; +#elif defined(__arm__) + ch_mag = (int16x8_t*)&ul_ch_mag[0][(symbol*nb_rb*12)]; +#endif len_mod4 = nb_re&3; nb_re >>= 2; // length in quad words (4 REs) nb_re += (len_mod4 == 0 ? 0 : 1); - temp_channel = _mm_set1_epi16((QAM16_n1 * one_over_sqrt_2)>>(2*15-AMP_SHIFT)); - for (i=0; i |y_R|, registers of odd index in xmm0-> |y_I| - xmm0 = _mm_subs_epi16(temp_channel,xmm0); // registers of even index in xmm0-> |y_R|-|h|^2, registers of odd index in xmm0-> |y_I|-|h|^2 + xmm0 = _mm_subs_epi16(ch_mag[i],xmm0); // registers of even index in xmm0-> |y_R|-|h|^2, registers of odd index in xmm0-> |y_I|-|h|^2 llr128[0] = _mm_unpacklo_epi32(rxF[i],xmm0); // llr128[0] contains the llrs of the 1st and 2nd REs llr128[1] = _mm_unpackhi_epi32(rxF[i],xmm0); // llr128[1] contains the llrs of the 3rd and 4th REs @@ -186,52 +177,43 @@ void nr_ulsch_64qam_llr(int32_t *rxdataF_comp, int32_t **ul_ch_mag, int32_t **ul_ch_magb, int16_t *ulsch_llr, + uint32_t nb_rb, uint32_t nb_re, uint8_t symbol) { + #if defined(__x86_64__) || defined(__i386__) __m128i *rxF = (__m128i*)rxdataF_comp; - // __m128i *ch_mag,*ch_magb; // [hna] This should be uncommented once channel estimation is implemented - - // [hna] temp_channel and one_over_sqrt_2 are for temporary use until channel estimation is implemented - // else ul_ch_mag and ul_ch_magb should be used after channel estimation has been implemented - __m128i temp_channel[2]; - int16_t one_over_sqrt_2 = 23170; - + __m128i *ch_mag,*ch_magb; #elif defined(__arm__) int16x8_t *rxF = (int16x8_t*)&rxdataF_comp; - // int16x8_t *ch_mag,*ch_magb; // [hna] This should be uncommented once channel estimation is implemented + int16x8_t *ch_mag,*ch_magb; // [hna] This should be uncommented once channel estimation is implemented int16x8_t xmm1,xmm2; #endif int i; unsigned char len_mod4; -// [hna] This should be uncommented once channel estimation is implemented -// ------------------------------------------------------------------------- -// #if defined(__x86_64__) || defined(__i386__) -// ch_mag = (__m128i*)&ul_ch_mag[0][(symbol*frame_parms->N_RB_UL*12)]; -// ch_magb = (__m128i*)&ul_ch_magb[0][(symbol*frame_parms->N_RB_UL*12)]; -// #elif defined(__arm__) -// ch_mag = (int16x8_t*)&ul_ch_mag[0][(symbol*frame_parms->N_RB_UL*12)]; -// ch_magb = (int16x8_t*)&ul_ch_magb[0][(symbol*frame_parms->N_RB_UL*12)]; -// #endif -// ------------------------------------------------------------------------- +#if defined(__x86_64__) || defined(__i386__) + ch_mag = (__m128i*)&ul_ch_mag[0][(symbol*nb_rb*12)]; + ch_magb = (__m128i*)&ul_ch_magb[0][(symbol*nb_rb*12)]; +#elif defined(__arm__) + ch_mag = (int16x8_t*)&ul_ch_mag[0][(symbol*nb_rb*12)]; + ch_magb = (int16x8_t*)&ul_ch_magb[0][(symbol*nb_rb*12)]; +#endif len_mod4 = nb_re&3; nb_re = nb_re>>2; // length in quad words (4 REs) nb_re += ((len_mod4 == 0) ? 0 : 1); - - temp_channel[0] = _mm_set1_epi16((QAM64_n1 * one_over_sqrt_2)>>(2*15-AMP_SHIFT)); - temp_channel[1] = _mm_set1_epi16((QAM64_n2 * one_over_sqrt_2)>>(2*15-AMP_SHIFT)); + for (i=0; inb_antennas_rx; aa++) { - Re = ((int16_t*)ue->pdcch_vars[ue->current_thread_id[subframe]][eNB_id]->dl_ch_estimates_time[aa])[(i<<1)]; - Im = ((int16_t*)ue->pdcch_vars[ue->current_thread_id[subframe]][eNB_id]->dl_ch_estimates_time[aa])[1+(i<<1)]; + Re = ((int16_t*)ue->pbch_vars[eNB_id]->dl_ch_estimates_time[aa])[(i<<1)]; + Im = ((int16_t*)ue->pbch_vars[eNB_id]->dl_ch_estimates_time[aa])[1+(i<<1)]; temp += (Re*Re/2) + (Im*Im/2); } @@ -80,7 +80,7 @@ void nr_adjust_synch_ue(NR_DL_FRAME_PARMS *frame_parms, // do not filter to have proactive timing adjustment //max_pos_fil = max_pos; - if(subframe == 1) + if(subframe == 0) { diff = max_pos_fil - (frame_parms->nb_prefix_samples>>3); 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 6df9e0c20e..e9b93719c1 100644 --- a/openair1/PHY/NR_UE_ESTIMATION/nr_dl_channel_estimation.c +++ b/openair1/PHY/NR_UE_ESTIMATION/nr_dl_channel_estimation.c @@ -21,7 +21,7 @@ #include - +#include "SCHED_NR_UE/defs.h" #include "nr_estimation.h" #include "PHY/NR_REFSIG/refsig_defs_ue.h" #include "filt16a_32.h" @@ -31,11 +31,11 @@ int nr_pbch_dmrs_correlation(PHY_VARS_NR_UE *ue, - uint8_t eNB_offset, - unsigned char Ns, - unsigned char symbol, - int dmrss, - NR_UE_SSB *current_ssb) + uint8_t eNB_offset, + unsigned char Ns, + unsigned char symbol, + int dmrss, + NR_UE_SSB *current_ssb) { int pilot[200] __attribute__((aligned(16))); unsigned char aarx; @@ -149,7 +149,7 @@ int nr_pbch_dmrs_correlation(PHY_VARS_NR_UE *ue, current_ssb->c_im +=ch[1]; #ifdef DEBUG_CH - printf("pilot %d : rxF - > (%d,%d) ch -> (%d,%d), pil -> (%d,%d) \n",pilot_cnt,rxF[0],rxF[1],ch[0],ch[1],pil[0],pil[1]); + printf("pilot %u : rxF - > (%d,%d) ch -> (%d,%d), pil -> (%d,%d) \n",pilot_cnt,rxF[0],rxF[1],ch[0],ch[1],pil[0],pil[1]); #endif pil+=2; @@ -165,7 +165,7 @@ int nr_pbch_dmrs_correlation(PHY_VARS_NR_UE *ue, current_ssb->c_im +=ch[1]; #ifdef DEBUG_CH - printf("pilot %d : rxF - > (%d,%d) ch -> (%d,%d), pil -> (%d,%d) \n",pilot_cnt+1,rxF[0],rxF[1],ch[0],ch[1],pil[0],pil[1]); + printf("pilot %u : rxF - > (%d,%d) ch -> (%d,%d), pil -> (%d,%d) \n",pilot_cnt+1,rxF[0],rxF[1],ch[0],ch[1],pil[0],pil[1]); #endif pil+=2; //re_offset = (re_offset+4)&(ue->frame_parms.ofdm_symbol_size-1); @@ -180,7 +180,7 @@ int nr_pbch_dmrs_correlation(PHY_VARS_NR_UE *ue, current_ssb->c_im +=ch[1]; #ifdef DEBUG_CH - printf("pilot %d : rxF - > (%d,%d) ch -> (%d,%d), pil -> (%d,%d) \n",pilot_cnt+2,rxF[0],rxF[1],ch[0],ch[1],pil[0],pil[1]); + printf("pilot %u : rxF - > (%d,%d) ch -> (%d,%d), pil -> (%d,%d) \n",pilot_cnt+2,rxF[0],rxF[1],ch[0],ch[1],pil[0],pil[1]); #endif pil+=2; @@ -207,11 +207,15 @@ int nr_pbch_channel_estimation(PHY_VARS_NR_UE *ue, uint8_t n_hf) { int pilot[200] __attribute__((aligned(16))); - unsigned char aarx; + unsigned char aarx,p; unsigned short k; unsigned int pilot_cnt; int16_t ch[2],*pil,*rxF,*dl_ch,*fl,*fm,*fr; int ch_offset,symbol_offset; + int slot_pbch; + fapi_nr_pbch_config_t *pbch_config = &ue->nrUE_config.pbch_config; + // initialized to 5ms in nr_init_ue for scenarios where UE is not configured (otherwise acquired by cell configuration from gNB or LTE) + uint8_t ssb_periodicity = 10;// ue->ssb_periodicity; //uint16_t Nid_cell = (eNB_offset == 0) ? ue->frame_parms.Nid_cell : ue->measurements.adj_cell_id[eNB_offset-1]; @@ -367,7 +371,7 @@ int nr_pbch_channel_estimation(PHY_VARS_NR_UE *ue, ch[1] = (int16_t)(((int32_t)pil[0]*rxF[1] + (int32_t)pil[1]*rxF[0])>>15); #ifdef DEBUG_CH - printf("pilot %d : rxF - > (%d,%d) ch -> (%d,%d), pil -> (%d,%d) \n",pilot_cnt,rxF[0],rxF[1],ch[0],ch[1],pil[0],pil[1]); + printf("pilot %u : rxF - > (%d,%d) ch -> (%d,%d), pil -> (%d,%d) \n",pilot_cnt,rxF[0],rxF[1],ch[0],ch[1],pil[0],pil[1]); #endif multadd_real_vector_complex_scalar(fl, ch, @@ -387,7 +391,7 @@ int nr_pbch_channel_estimation(PHY_VARS_NR_UE *ue, ch[1] = (int16_t)(((int32_t)pil[0]*rxF[1] + (int32_t)pil[1]*rxF[0])>>15); #ifdef DEBUG_CH - printf("pilot %d : rxF - > (%d,%d) ch -> (%d,%d), pil -> (%d,%d) \n",pilot_cnt+1,rxF[0],rxF[1],ch[0],ch[1],pil[0],pil[1]); + printf("pilot %u : rxF - > (%d,%d) ch -> (%d,%d), pil -> (%d,%d) \n",pilot_cnt+1,rxF[0],rxF[1],ch[0],ch[1],pil[0],pil[1]); #endif multadd_real_vector_complex_scalar(fm, ch, @@ -403,7 +407,7 @@ int nr_pbch_channel_estimation(PHY_VARS_NR_UE *ue, ch[1] = (int16_t)(((int32_t)pil[0]*rxF[1] + (int32_t)pil[1]*rxF[0])>>15); #ifdef DEBUG_CH - printf("pilot %d : rxF - > (%d,%d) ch -> (%d,%d), pil -> (%d,%d) \n",pilot_cnt+2,rxF[0],rxF[1],ch[0],ch[1],pil[0],pil[1]); + printf("pilot %u : rxF - > (%d,%d) ch -> (%d,%d), pil -> (%d,%d) \n",pilot_cnt+2,rxF[0],rxF[1],ch[0],ch[1],pil[0],pil[1]); #endif multadd_real_vector_complex_scalar(fr, @@ -418,6 +422,59 @@ int nr_pbch_channel_estimation(PHY_VARS_NR_UE *ue, } + void (*idft)(int16_t *,int16_t *, int); + + switch (ue->frame_parms.ofdm_symbol_size) { + case 128: + idft = idft128; + break; + + case 256: + idft = idft256; + break; + + case 512: + idft = idft512; + break; + + case 1024: + idft = idft1024; + break; + + case 1536: + idft = idft1536; + break; + + case 2048: + idft = idft2048; + break; + + case 3072: + idft = idft3072; + break; + + case 4096: + idft = idft4096; + break; + + default: + printf("unsupported ofdm symbol size \n"); + assert(0); + } + + if( symbol == 3) + { + // do ifft of channel estimate + for (aarx=0; aarxframe_parms.nb_antennas_rx; aarx++) + for (p=0; pframe_parms.nb_antenna_ports_eNB; p++) { + if (ue->pbch_vars[eNB_offset]->dl_ch_estimates[(p<<1)+aarx]) + { + LOG_D(PHY,"Channel Impulse Computation Slot %d ThreadId %d Symbol %d ch_offset %d\n", Ns, ue->current_thread_id[Ns], symbol, ch_offset); + idft((int16_t*) &ue->pbch_vars[eNB_offset]->dl_ch_estimates[(p<<1)+aarx][ch_offset], + (int16_t*) ue->pbch_vars[eNB_offset]->dl_ch_estimates_time[(p<<1)+aarx],1); + } + } + } //} @@ -426,14 +483,14 @@ int nr_pbch_channel_estimation(PHY_VARS_NR_UE *ue, } int nr_pdcch_channel_estimation(PHY_VARS_NR_UE *ue, - uint8_t eNB_offset, - unsigned char Ns, - unsigned char symbol, - unsigned short coreset_start_subcarrier, - unsigned short nb_rb_coreset) + uint8_t eNB_offset, + unsigned char Ns, + unsigned char symbol, + unsigned short coreset_start_subcarrier, + unsigned short nb_rb_coreset) { int pilot[200] __attribute__((aligned(16))); - unsigned char aarx,p; + unsigned char aarx; unsigned short k; unsigned int pilot_cnt; int16_t ch[2],*pil,*rxF,*dl_ch,*fl,*fm,*fr; @@ -550,7 +607,7 @@ int nr_pdcch_channel_estimation(PHY_VARS_NR_UE *ue, ch[0] = (int16_t)(((int32_t)pil[0]*rxF[0] - (int32_t)pil[1]*rxF[1])>>15); ch[1] = (int16_t)(((int32_t)pil[0]*rxF[1] + (int32_t)pil[1]*rxF[0])>>15); #ifdef DEBUG_PDCCH - printf("pilot %d : rxF - > (%d,%d) ch -> (%d,%d), pil -> (%d,%d) \n",pilot_cnt,rxF[0],rxF[1],ch[0],ch[1],pil[0],pil[1]); + printf("pilot %u : rxF - > (%d,%d) ch -> (%d,%d), pil -> (%d,%d) \n",pilot_cnt,rxF[0],rxF[1],ch[0],ch[1],pil[0],pil[1]); #endif multadd_real_vector_complex_scalar(fl, ch, @@ -566,7 +623,7 @@ int nr_pdcch_channel_estimation(PHY_VARS_NR_UE *ue, ch[0] = (int16_t)(((int32_t)pil[0]*rxF[0] - (int32_t)pil[1]*rxF[1])>>15); ch[1] = (int16_t)(((int32_t)pil[0]*rxF[1] + (int32_t)pil[1]*rxF[0])>>15); #ifdef DEBUG_PDCCH - printf("pilot %d : rxF - > (%d,%d) ch -> (%d,%d), pil -> (%d,%d) \n",pilot_cnt+1,rxF[0],rxF[1],ch[0],ch[1],pil[0],pil[1]); + printf("pilot %u : rxF - > (%d,%d) ch -> (%d,%d), pil -> (%d,%d) \n",pilot_cnt+1,rxF[0],rxF[1],ch[0],ch[1],pil[0],pil[1]); #endif multadd_real_vector_complex_scalar(fm, ch, @@ -597,73 +654,18 @@ int nr_pdcch_channel_estimation(PHY_VARS_NR_UE *ue, //} } - - void (*idft)(int16_t *,int16_t *, int); - - switch (ue->frame_parms.ofdm_symbol_size) { - case 128: - idft = idft128; - break; - - case 256: - idft = idft256; - break; - - case 512: - idft = idft512; - break; - - case 1024: - idft = idft1024; - break; - - case 1536: - idft = idft1536; - break; - - case 2048: - idft = idft2048; - break; - - case 3072: - idft = idft3072; - break; - - case 4096: - idft = idft4096; - break; - - default: - printf("unsupported ofdm symbol size \n"); - assert(0); - } - - if( (Ns== 1) && (symbol == 0)) - { - // do ifft of channel estimate - for (aarx=0; aarxframe_parms.nb_antennas_rx; aarx++) - for (p=0; pframe_parms.nb_antenna_ports_eNB; p++) { - if (ue->pdcch_vars[ue->current_thread_id[Ns]][eNB_offset]->dl_ch_estimates[(p<<1)+aarx]) - { - LOG_I(PHY,"Channel Impulse Computation Slot %d ThreadId %d Symbol %d \n", Ns, ue->current_thread_id[Ns], symbol); - idft((int16_t*) &ue->pdcch_vars[ue->current_thread_id[Ns]][eNB_offset]->dl_ch_estimates[(p<<1)+aarx][0], - (int16_t*) ue->pdcch_vars[ue->current_thread_id[Ns]][eNB_offset]->dl_ch_estimates_time[(p<<1)+aarx],1); - } - } - } return(0); } int nr_pdsch_channel_estimation(PHY_VARS_NR_UE *ue, - uint8_t eNB_offset, - unsigned char Ns, - unsigned short p, - unsigned char symbol, - unsigned short bwp_start_subcarrier, - unsigned short nb_rb_pdsch) + uint8_t eNB_offset, + unsigned char Ns, + unsigned short p, + unsigned char symbol, + unsigned short bwp_start_subcarrier, + unsigned short nb_rb_pdsch) { - int pilot[1320] __attribute__((aligned(16))); unsigned char aarx; unsigned short k; @@ -722,11 +724,14 @@ int nr_pdsch_channel_estimation(PHY_VARS_NR_UE *ue, // generate pilot - nr_pdsch_dmrs_rx(ue,Ns,ue->nr_gold_pdsch[eNB_offset][Ns][0], &pilot[0],1000,0,nb_rb_pdsch); + uint16_t rb_offset = (bwp_start_subcarrier - ue->frame_parms.first_carrier_offset) / 12; + int config_type = 0; // needs to be updated from higher layer + nr_pdsch_dmrs_rx(ue,Ns,ue->nr_gold_pdsch[eNB_offset][Ns][0], &pilot[0],1000,0,nb_rb_pdsch+rb_offset); for (aarx=0; aarxframe_parms.nb_antennas_rx; aarx++) { - pil = (int16_t *)&pilot[0]; + pil = (int16_t *)&pilot[rb_offset*((config_type==0) ? 6:4)]; + k = k&(ue->frame_parms.ofdm_symbol_size-1); rxF = (int16_t *)&rxdataF[aarx][(symbol_offset+k+nushift)]; dl_ch = (int16_t *)&dl_ch_estimates[aarx][ch_offset]; @@ -756,8 +761,8 @@ int nr_pdsch_channel_estimation(PHY_VARS_NR_UE *ue, dl_ch, 8); pil+=2; - //re_offset = (re_offset+2)&(ue->frame_parms.ofdm_symbol_size-1); - re_offset = (re_offset >= ue->frame_parms.ofdm_symbol_size) ? (re_offset - ue->frame_parms.ofdm_symbol_size + 2) : (re_offset+2); + re_offset = (re_offset+2)&(ue->frame_parms.ofdm_symbol_size-1); + //re_offset = (re_offset >= ue->frame_parms.ofdm_symbol_size) ? (re_offset - ue->frame_parms.ofdm_symbol_size + 2) : (re_offset+2); rxF = (int16_t *)&rxdataF[aarx][(symbol_offset+nushift+re_offset)]; //for (int i= 0; i<8; i++) //printf("dl_ch addr %p %d\n", dl_ch+i, *(dl_ch+i)); @@ -772,8 +777,8 @@ int nr_pdsch_channel_estimation(PHY_VARS_NR_UE *ue, dl_ch, 8); pil+=2; - //re_offset = (re_offset+2)&(ue->frame_parms.ofdm_symbol_size-1); - re_offset = (re_offset >= ue->frame_parms.ofdm_symbol_size) ? (re_offset - ue->frame_parms.ofdm_symbol_size + 2) : (re_offset+2); + re_offset = (re_offset+2)&(ue->frame_parms.ofdm_symbol_size-1); + //re_offset = (re_offset >= ue->frame_parms.ofdm_symbol_size) ? (re_offset - ue->frame_parms.ofdm_symbol_size + 2) : (re_offset+2); rxF = (int16_t *)&rxdataF[aarx][(symbol_offset+nushift+re_offset)]; //printf("dl_ch addr %p\n",dl_ch); @@ -791,8 +796,8 @@ int nr_pdsch_channel_estimation(PHY_VARS_NR_UE *ue, //printf("dl_ch addr %p %d\n", dl_ch+i, *(dl_ch+i)); pil+=2; - //re_offset = (re_offset+2)&(ue->frame_parms.ofdm_symbol_size-1); - re_offset = (re_offset >= ue->frame_parms.ofdm_symbol_size) ? (re_offset - ue->frame_parms.ofdm_symbol_size + 2) : (re_offset+2); + re_offset = (re_offset+2)&(ue->frame_parms.ofdm_symbol_size-1); + //re_offset = (re_offset >= ue->frame_parms.ofdm_symbol_size) ? (re_offset - ue->frame_parms.ofdm_symbol_size + 2) : (re_offset+2); rxF = (int16_t *)&rxdataF[aarx][(symbol_offset+nushift+re_offset)]; dl_ch+=8; @@ -804,7 +809,7 @@ int nr_pdsch_channel_estimation(PHY_VARS_NR_UE *ue, ch[0] = (int16_t)(((int32_t)pil[0]*rxF[0] - (int32_t)pil[1]*rxF[1])>>15); ch[1] = (int16_t)(((int32_t)pil[0]*rxF[1] + (int32_t)pil[1]*rxF[0])>>15); #ifdef DEBUG_PDSCH - printf("pilot %d : rxF - > (%d,%d) ch -> (%d,%d), pil -> (%d,%d) \n",pilot_cnt,rxF[0],rxF[1],ch[0],ch[1],pil[0],pil[1]); + printf("pilot %u : rxF - > (%d,%d) ch -> (%d,%d), pil -> (%d,%d) \n",pilot_cnt,rxF[0],rxF[1],ch[0],ch[1],pil[0],pil[1]); #endif multadd_real_vector_complex_scalar(fm, ch, @@ -812,22 +817,22 @@ int nr_pdsch_channel_estimation(PHY_VARS_NR_UE *ue, 8); pil+=2; - //re_offset = (re_offset+2)&(ue->frame_parms.ofdm_symbol_size-1); - re_offset = (re_offset >= ue->frame_parms.ofdm_symbol_size) ? (re_offset - ue->frame_parms.ofdm_symbol_size + 2) : (re_offset+2); + re_offset = (re_offset+2)&(ue->frame_parms.ofdm_symbol_size-1); + //re_offset = (re_offset >= ue->frame_parms.ofdm_symbol_size) ? (re_offset - ue->frame_parms.ofdm_symbol_size + 2) : (re_offset+2); rxF = (int16_t *)&rxdataF[aarx][(symbol_offset+nushift+re_offset)]; ch[0] = (int16_t)(((int32_t)pil[0]*rxF[0] - (int32_t)pil[1]*rxF[1])>>15); ch[1] = (int16_t)(((int32_t)pil[0]*rxF[1] + (int32_t)pil[1]*rxF[0])>>15); #ifdef DEBUG_PDSCH - printf("pilot %d : rxF - > (%d,%d) ch -> (%d,%d), pil -> (%d,%d) \n",pilot_cnt+1,rxF[0],rxF[1],ch[0],ch[1],pil[0],pil[1]); + printf("pilot %u : rxF - > (%d,%d) ch -> (%d,%d), pil -> (%d,%d) \n",pilot_cnt+1,rxF[0],rxF[1],ch[0],ch[1],pil[0],pil[1]); #endif multadd_real_vector_complex_scalar(fmm, ch, dl_ch, 8); pil+=2; - //re_offset = (re_offset+2)&(ue->frame_parms.ofdm_symbol_size-1); - re_offset = (re_offset >= ue->frame_parms.ofdm_symbol_size) ? (re_offset - ue->frame_parms.ofdm_symbol_size + 2) : (re_offset+2); + re_offset = (re_offset+2)&(ue->frame_parms.ofdm_symbol_size-1); + //re_offset = (re_offset >= ue->frame_parms.ofdm_symbol_size) ? (re_offset - ue->frame_parms.ofdm_symbol_size + 2) : (re_offset+2); rxF = (int16_t *)&rxdataF[aarx][(symbol_offset+nushift+re_offset)]; dl_ch+=8; @@ -837,7 +842,7 @@ int nr_pdsch_channel_estimation(PHY_VARS_NR_UE *ue, ch[0] = (int16_t)(((int32_t)pil[0]*rxF[0] - (int32_t)pil[1]*rxF[1])>>15); ch[1] = (int16_t)(((int32_t)pil[0]*rxF[1] + (int32_t)pil[1]*rxF[0])>>15); #ifdef DEBUG_PDSCH - printf("pilot %d : rxF - > (%d,%d) ch -> (%d,%d), pil -> (%d,%d) \n",pilot_cnt,rxF[0],rxF[1],ch[0],ch[1],pil[0],pil[1]); + printf("pilot %u : rxF - > (%d,%d) ch -> (%d,%d), pil -> (%d,%d) \n",pilot_cnt,rxF[0],rxF[1],ch[0],ch[1],pil[0],pil[1]); #endif multadd_real_vector_complex_scalar(fm, ch, @@ -848,15 +853,15 @@ int nr_pdsch_channel_estimation(PHY_VARS_NR_UE *ue, //printf("dl_ch addr %p %d\n", dl_ch+i, *(dl_ch+i)); pil+=2; - //re_offset = (re_offset+2)&(ue->frame_parms.ofdm_symbol_size-1); - re_offset = (re_offset >= ue->frame_parms.ofdm_symbol_size) ? (re_offset - ue->frame_parms.ofdm_symbol_size + 2) : (re_offset+2); + re_offset = (re_offset+2)&(ue->frame_parms.ofdm_symbol_size-1); + //re_offset = (re_offset >= ue->frame_parms.ofdm_symbol_size) ? (re_offset - ue->frame_parms.ofdm_symbol_size + 2) : (re_offset+2); rxF = (int16_t *)&rxdataF[aarx][(symbol_offset+nushift+re_offset)]; ch[0] = (int16_t)(((int32_t)pil[0]*rxF[0] - (int32_t)pil[1]*rxF[1])>>15); ch[1] = (int16_t)(((int32_t)pil[0]*rxF[1] + (int32_t)pil[1]*rxF[0])>>15); #ifdef DEBUG_PDSCH printf("ch 0 %d\n",((int32_t)pil[0]*rxF[0] - (int32_t)pil[1]*rxF[1])); - printf("pilot %d: rxF - > (%d,%d) addr %p ch -> (%d,%d), pil -> (%d,%d) \n",pilot_cnt+1,rxF[0],rxF[1],&rxF[0],ch[0],ch[1],pil[0],pil[1]); + printf("pilot %u: rxF - > (%d,%d) addr %p ch -> (%d,%d), pil -> (%d,%d) \n",pilot_cnt+1,rxF[0],rxF[1],&rxF[0],ch[0],ch[1],pil[0],pil[1]); #endif multadd_real_vector_complex_scalar(fmr, ch, @@ -864,15 +869,15 @@ int nr_pdsch_channel_estimation(PHY_VARS_NR_UE *ue, 8); pil+=2; - //re_offset = (re_offset+2)&(ue->frame_parms.ofdm_symbol_size-1); - re_offset = (re_offset >= ue->frame_parms.ofdm_symbol_size) ? (re_offset - ue->frame_parms.ofdm_symbol_size + 2) : (re_offset+2); + re_offset = (re_offset+2)&(ue->frame_parms.ofdm_symbol_size-1); + //re_offset = (re_offset >= ue->frame_parms.ofdm_symbol_size) ? (re_offset - ue->frame_parms.ofdm_symbol_size + 2) : (re_offset+2); rxF = (int16_t *)&rxdataF[aarx][(symbol_offset+nushift+re_offset)]; dl_ch+=8; ch[0] = (int16_t)(((int32_t)pil[0]*rxF[0] - (int32_t)pil[1]*rxF[1])>>15); ch[1] = (int16_t)(((int32_t)pil[0]*rxF[1] + (int32_t)pil[1]*rxF[0])>>15); #ifdef DEBUG_PDSCH - printf("pilot %d: rxF - > (%d,%d) ch -> (%d,%d), pil -> (%d,%d) \n",pilot_cnt+2,rxF[0],rxF[1],ch[0],ch[1],pil[0],pil[1]); + printf("pilot %u: rxF - > (%d,%d) ch -> (%d,%d), pil -> (%d,%d) \n",pilot_cnt+2,rxF[0],rxF[1],ch[0],ch[1],pil[0],pil[1]); #endif multadd_real_vector_complex_scalar(fr, ch, diff --git a/openair1/PHY/NR_UE_ESTIMATION/nr_ue_measurements.c b/openair1/PHY/NR_UE_ESTIMATION/nr_ue_measurements.c index 7a437c9d3f..90c221931f 100644 --- a/openair1/PHY/NR_UE_ESTIMATION/nr_ue_measurements.c +++ b/openair1/PHY/NR_UE_ESTIMATION/nr_ue_measurements.c @@ -35,5 +35,5 @@ int16_t get_nr_PL(PHY_VARS_NR_UE *ue,uint8_t gNB_index) dB_fixed_times10(ue->measurements.rsrp[gNB_index])+ // dB_fixed_times10(RSoffset*12*ue_g[Mod_id][CC_id]->frame_parms.N_RB_DL) + (ue->frame_parms.ss_PBCH_BlockPower*10))/10)); - } + diff --git a/openair1/PHY/NR_UE_TRANSPORT/dci_nr.c b/openair1/PHY/NR_UE_TRANSPORT/dci_nr.c index 7d383a7aef..5c624da96d 100644 --- a/openair1/PHY/NR_UE_TRANSPORT/dci_nr.c +++ b/openair1/PHY/NR_UE_TRANSPORT/dci_nr.c @@ -137,9 +137,7 @@ void nr_pdcch_demapping_deinterleaving(uint32_t *llr, } f_reg = (f_bundle_j*reg_bundle_size_L)+(reg%reg_bundle_size_L); - //index_z = 9*reg; - index_z = 9*(uint16_t)floor(reg/coreset_time_dur) + (9*coreset_nbr_rb)*(reg%coreset_time_dur); - //index_llr = 9*(((uint16_t)floor(f_reg/reg_bundle_size_L)+(f_reg)%coreset_time_dur))*(coreset_nbr_rb); + index_z = 9*reg; index_llr = 9*((uint16_t)floor(f_reg/coreset_time_dur)+((f_reg%coreset_time_dur)*(coreset_nbr_rb))); for (int i=0; i<9; i++) { @@ -392,7 +390,7 @@ void nr_pdcch_extract_rbs_single(int32_t **rxdataF, if (((c_rb - n_BWP_start) % BIT_TO_NBR_RB_CORESET_FREQ_DOMAIN)==0) { bitcnt_coreset_freq_dom ++; - while ((((coreset_freq_dom & 0x1FFFFFFFFFFF) >> (CORESET_FREQ_DOMAIN_BITMAP_SIZE - bitcnt_coreset_freq_dom)) & 0x1)== 0) { // 46 -> 45 is number of bits in coreset_freq_dom + while ((((coreset_freq_dom & 0x1FFFFFFFFFFF) >> (CORESET_FREQ_DOMAIN_BITMAP_SIZE - (n_BWP_start/BIT_TO_NBR_RB_CORESET_FREQ_DOMAIN) - bitcnt_coreset_freq_dom)) & 0x1)== 0) { // 46 -> 45 is number of bits in coreset_freq_dom // next 6 RB are not part of the CORESET within the BWP as bit in coreset_freq_dom is set to 0 bitcnt_coreset_freq_dom ++; //c_rb_tmp = c_rb_tmp + 6; @@ -1172,7 +1170,7 @@ void nr_dci_decoding_procedure0(int s, } else { nb_candidates = (L2 == 4) ? 4 : ((L2 == 8)? 2 : 1); // according to Table 10.1-1 (38.213 section 10.1) #ifdef NR_PDCCH_DCI_DEBUG - printf("\t\t<-NR_PDCCH_DCI_DEBUG (nr_dci_decoding_procedure0)-> we are in common searchSpace and nb_candidates=%d for L2=%d\n",nb_candidates,L2); + printf("\t\t<-NR_PDCCH_DCI_DEBUG (nr_dci_decoding_procedure0)-> we are in common searchSpace and nb_candidates=%u for L2=%d\n", nb_candidates, L2); #endif } } else { @@ -1211,7 +1209,7 @@ void nr_dci_decoding_procedure0(int s, } #ifdef NR_PDCCH_DCI_DEBUG - printf("\t\t<-NR_PDCCH_DCI_DEBUG (nr_dci_decoding_procedure0)-> L2(%d) | nCCE[%d](%d) | Yk(%d) | nb_candidates(%d)\n",L2,p,nCCE[p],Yk,nb_candidates); + printf("\t\t<-NR_PDCCH_DCI_DEBUG (nr_dci_decoding_procedure0)-> L2(%d) | nCCE[%d](%d) | Yk(%u) | nb_candidates(%u)\n", L2, p, nCCE[p], Yk, nb_candidates); #endif /* for (CCEind=0; CCEind m_max_slot_pdcch_Table10_1_2(%d)=%d\n",L,m_max_slot_pdcch_Table10_1_2[L]); + if(0 <= L && L < 4) printf("\t\t<-NR_PDCCH_DCI_DEBUG (nr_dci_decoding_procedure0)-> m_max_slot_pdcch_Table10_1_2(%d)=%d\n",L,m_max_slot_pdcch_Table10_1_2[L]); #endif for (m = 0; m < nb_candidates; m++) { @@ -1233,16 +1231,16 @@ void nr_dci_decoding_procedure0(int s, if (nCCE[p] < L2) return; #ifdef NR_PDCCH_DCI_DEBUG - int debug1 = nCCE[p] / L2; - int debug2 = L2*m_p_s_L_max; - printf("\t\t<-NR_PDCCH_DCI_DEBUG (nr_dci_decoding_procedure0)-> debug1(%d)=nCCE[p]/L2 | nCCE[%d](%d) | L2(%d)\n",debug1,p,nCCE[p],L2); - printf("\t\t<-NR_PDCCH_DCI_DEBUG (nr_dci_decoding_procedure0)-> debug2(%d)=L2*m_p_s_L_max | L2(%d) | m_p_s_L_max(%d)\n",debug2,L2,m_p_s_L_max); + int debug1 = nCCE[p] / L2; + int debug2 = L2*m_p_s_L_max; + printf("\t\t<-NR_PDCCH_DCI_DEBUG (nr_dci_decoding_procedure0)-> debug1(%d)=nCCE[p]/L2 | nCCE[%d](%d) | L2(%d)\n",debug1,p,nCCE[p],L2); + printf("\t\t<-NR_PDCCH_DCI_DEBUG (nr_dci_decoding_procedure0)-> debug2(%d)=L2*m_p_s_L_max | L2(%d) | m_p_s_L_max(%d)\n",debug2,L2,m_p_s_L_max); #endif - CCEind = (((Yk + (uint16_t)(floor((m*nCCE[p])/(L2*m_p_s_L_max))) + n_ci) % (uint16_t)(floor(nCCE[p] / L2))) * L2); + CCEind = (((Yk + (uint16_t)(floor((m*nCCE[p])/(L2*m_p_s_L_max))) + n_ci) % (uint16_t)(floor(nCCE[p] / L2))) * L2); #ifdef NR_PDCCH_DCI_DEBUG - printf ("\t\t<-NR_PDCCH_DCI_DEBUG (nr_dci_decoding_procedure0)-> CCEind(%d) = (((Yk(%d) + ((m(%d)*nCCE[p](%d))/(L2(%d)*m_p_s_L_max(%d)))) % (nCCE[p] / L2)) * L2)\n", + printf("\t\t<-NR_PDCCH_DCI_DEBUG (nr_dci_decoding_procedure0)-> CCEind(%d) = (((Yk(%u) + ((m(%u)*nCCE[p](%d))/(L2(%d)*m_p_s_L_max(%d)))) %% (nCCE[p] / L2)) * L2)\n", CCEind,Yk,m,nCCE[p],L2,m_p_s_L_max); - printf ("\t\t<-NR_PDCCH_DCI_DEBUG (nr_dci_decoding_procedure0)-> n_candidate(m)=%d | CCEind=%d |",m,CCEind); + printf("\t\t<-NR_PDCCH_DCI_DEBUG (nr_dci_decoding_procedure0)-> n_candidate(m)=%u | CCEind=%d |",m,CCEind); #endif if (CCEind < 32) @@ -1251,7 +1249,7 @@ void nr_dci_decoding_procedure0(int s, CCEmap = CCEmap1; else if (CCEind < 96) CCEmap = CCEmap2; - else AssertFatal(1==0,"Illegal CCEind %d (Yk %d, m %d, nCCE %d, L2 %d\n",CCEind, Yk, m, nCCE[p], L2); + else AssertFatal(1==0,"Illegal CCEind %d (Yk %u, m %u, nCCE %d, L2 %d\n", CCEind, Yk, m, nCCE[p], L2); switch (L2) { case 1: @@ -1283,7 +1281,7 @@ void nr_dci_decoding_procedure0(int s, CCEmap_cand = (*CCEmap) & CCEmap_mask; // CCE is not allocated yet #ifdef NR_PDCCH_DCI_DEBUG - printf ("\t\t<-NR_PDCCH_DCI_DEBUG (nr_dci_decoding_procedure0)-> CCEmap_cand=%d \n",CCEmap_cand); + printf ("\t\t<-NR_PDCCH_DCI_DEBUG (nr_dci_decoding_procedure0)-> CCEmap_cand=%u \n",CCEmap_cand); #endif if (CCEmap_cand == 0) { diff --git a/openair1/PHY/NR_UE_TRANSPORT/nr_dlsch_decoding.c b/openair1/PHY/NR_UE_TRANSPORT/nr_dlsch_decoding.c index bff8a90b16..8ccede36af 100644 --- a/openair1/PHY/NR_UE_TRANSPORT/nr_dlsch_decoding.c +++ b/openair1/PHY/NR_UE_TRANSPORT/nr_dlsch_decoding.c @@ -44,6 +44,7 @@ #include "PHY/CODING/nrLDPC_decoder/nrLDPC_decoder.h" #include "PHY/CODING/nrLDPC_decoder/nrLDPC_types.h" //#define DEBUG_DLSCH_DECODING +//#define ENABLE_PHY_PAYLOAD_DEBUG 1 #define OAI_LDPC_MAX_NUM_LLR 27000//26112 // NR_LDPC_NCOL_BG1*NR_LDPC_ZMAX @@ -308,41 +309,26 @@ uint32_t nr_dlsch_decoding(PHY_VARS_NR_UE *phy_vars_ue, harq_process->trials[harq_process->round]++; - harq_process->TBS = nr_compute_tbs(harq_process->mcs,nb_rb,nb_symb_sch,nb_re_dmrs,dmrs_maxLength, harq_process->Nl); + uint16_t nb_rb_oh = 0; // it was not computed at UE side even before and set to 0 in nr_compute_tbs + + harq_process->TBS = nr_compute_tbs(harq_process->Qm,harq_process->R,nb_rb,nb_symb_sch,nb_re_dmrs*length_dmrs, nb_rb_oh, harq_process->Nl); A = harq_process->TBS; ret = dlsch->max_ldpc_iterations + 1; - - harq_process->G = nr_get_G(nb_rb, nb_symb_sch, nb_re_dmrs, dmrs_maxLength, harq_process->Qm,harq_process->Nl); + dlsch->last_iteration_cnt = ret; + + harq_process->G = nr_get_G(nb_rb, nb_symb_sch, nb_re_dmrs, length_dmrs, harq_process->Qm,harq_process->Nl); G = harq_process->G; LOG_I(PHY,"DLSCH Decoding, harq_pid %d TBS %d G %d mcs %d Nl %d nb_symb_sch %d nb_rb %d\n",harq_pid,A,G, harq_process->mcs, harq_process->Nl, nb_symb_sch,nb_rb); vcd_signal_dumper_dump_function_by_name(VCD_SIGNAL_DUMPER_FUNCTIONS_DLSCH_SEGMENTATION, VCD_FUNCTION_IN); - if (harq_process->round == 0) { - // This is a new packet, so compute quantities regarding segmentation - harq_process->B = A+24; - nr_segmentation(NULL, - NULL, - harq_process->B, - &harq_process->C, - &harq_process->K, - &harq_process->Z, // [hna] Z is Zc - &harq_process->F); + if ((harq_process->R)<1024) + Coderate = (float) (harq_process->R) /(float) 1024; + else + Coderate = (float) (harq_process->R) /(float) 2048; -#ifdef DEBUG_DLSCH_DECODING - if (!frame%100) - printf("K %d C %d Z %d nl %d \n", harq_process->K, harq_process->C, p_decParams->Z, harq_process->Nl); -#endif - } - - vcd_signal_dumper_dump_function_by_name(VCD_SIGNAL_DUMPER_FUNCTIONS_DLSCH_SEGMENTATION, VCD_FUNCTION_OUT); - - p_decParams->Z = harq_process->Z; - //printf("dlsch decoding nr segmentation Z %d\n", p_decParams->Z); - - Coderate = (float) A /(float) G; if ((A <=292) || ((A<=3824) && (Coderate <= 0.6667)) || Coderate <= 0.25) { p_decParams->BG = 2; @@ -375,6 +361,34 @@ uint32_t nr_dlsch_decoding(PHY_VARS_NR_UE *phy_vars_ue, } } + + if (harq_process->round == 0) { + // This is a new packet, so compute quantities regarding segmentation + if (A > 3824) + harq_process->B = A+24; + else + harq_process->B = A+16; + + nr_segmentation(NULL, + NULL, + harq_process->B, + &harq_process->C, + &harq_process->K, + &harq_process->Z, // [hna] Z is Zc + &harq_process->F, + p_decParams->BG); + +#ifdef DEBUG_DLSCH_DECODING + if (!frame%100) + printf("K %d C %d Z %d nl %d \n", harq_process->K, harq_process->C, p_decParams->Z, harq_process->Nl); +#endif + } + + vcd_signal_dumper_dump_function_by_name(VCD_SIGNAL_DUMPER_FUNCTIONS_DLSCH_SEGMENTATION, VCD_FUNCTION_OUT); + + p_decParams->Z = harq_process->Z; + //printf("dlsch decoding nr segmentation Z %d\n", p_decParams->Z); + //printf("coderate %f kc %d \n", Coderate, kc); p_decParams->numMaxIter = dlsch->max_ldpc_iterations; @@ -411,8 +425,6 @@ uint32_t nr_dlsch_decoding(PHY_VARS_NR_UE *phy_vars_ue, K_bytes_F = Kr_bytes-(harq_process->F>>3); - Tbslbrm = nr_compute_tbs(28,nb_rb,frame_parms->symbols_per_slot,0,0, harq_process->Nl); - for (r=0; rC; r++) { //printf("start rx segment %d\n",r); @@ -456,6 +468,11 @@ uint32_t nr_dlsch_decoding(PHY_VARS_NR_UE *phy_vars_ue, vcd_signal_dumper_dump_function_by_name(VCD_SIGNAL_DUMPER_FUNCTIONS_DLSCH_RATE_MATCHING, VCD_FUNCTION_IN); + if ((harq_process->Nl)<4) + Tbslbrm = nr_compute_tbslbrm(harq_process->mcs_table,nb_rb,harq_process->Nl,harq_process->C); + else + Tbslbrm = nr_compute_tbslbrm(harq_process->mcs_table,nb_rb,4,harq_process->C); + if (nr_rate_matching_ldpc_rx(Ilbrm, Tbslbrm, p_decParams->BG, @@ -503,8 +520,13 @@ uint32_t nr_dlsch_decoding(PHY_VARS_NR_UE *phy_vars_ue, // printf("done\n"); if (harq_process->C == 1){ - crc_type = CRC24_A; - length_dec = harq_process->B; + if (A > 3824) + crc_type = CRC24_A; + else + crc_type = CRC16; + + length_dec = harq_process->B; + } else{ crc_type = CRC24_B; @@ -553,6 +575,8 @@ uint32_t nr_dlsch_decoding(PHY_VARS_NR_UE *phy_vars_ue, // Fixme: correct type is unsigned, but nrLDPC_decoder and all called behind use signed int if (check_crc((uint8_t*)llrProcBuf,length_dec,harq_process->F,crc_type)) { printf("\x1B[34m" "Segment %d CRC OK\n",r); + //Temporary hack + no_iteration_ldpc = dlsch->max_ldpc_iterations; ret = no_iteration_ldpc; } else { @@ -601,7 +625,7 @@ uint32_t nr_dlsch_decoding(PHY_VARS_NR_UE *phy_vars_ue, if ((err_flag == 0) && (ret>=(1+dlsch->max_ldpc_iterations))) {// a Code segment is in error so break; - LOG_D(PHY,"AbsSubframe %d.%d CRC failed, segment %d/%d \n",frame%1024,nr_tti_rx,r,harq_process->C-1); + LOG_I(PHY,"AbsSubframe %d.%d CRC failed, segment %d/%d \n",frame%1024,nr_tti_rx,r,harq_process->C-1); err_flag = 1; } } @@ -615,10 +639,10 @@ uint32_t nr_dlsch_decoding(PHY_VARS_NR_UE *phy_vars_ue, frame_rx_prev = frame_rx_prev%1024; if (err_flag == 1) { -#if UE_DEBUG_TRACE +//#if UE_DEBUG_TRACE LOG_I(PHY,"[UE %d] DLSCH: Setting NAK for SFN/SF %d/%d (pid %d, status %d, round %d, TBS %d, mcs %d) Kr %d r %d harq_process->round %d\n", phy_vars_ue->Mod_id, frame, nr_tti_rx, harq_pid,harq_process->status, harq_process->round,harq_process->TBS,harq_process->mcs,Kr,r,harq_process->round); -#endif +//#endif harq_process->harq_ack.ack = 0; harq_process->harq_ack.harq_id = harq_pid; harq_process->harq_ack.send_harq_status = 1; @@ -633,16 +657,16 @@ uint32_t nr_dlsch_decoding(PHY_VARS_NR_UE *phy_vars_ue, if(is_crnti) { - LOG_D(PHY,"[UE %d] DLSCH: Setting NACK for nr_tti_rx %d (pid %d, pid status %d, round %d/Max %d, TBS %d)\n", + LOG_I(PHY,"[UE %d] DLSCH: Setting NACK for nr_tti_rx %d (pid %d, pid status %d, round %d/Max %d, TBS %d)\n", phy_vars_ue->Mod_id,nr_tti_rx,harq_pid,harq_process->status,harq_process->round,dlsch->Mdlharq,harq_process->TBS); } return((1 + dlsch->max_ldpc_iterations)); } else { -#if UE_DEBUG_TRACE +//#if UE_DEBUG_TRACE LOG_I(PHY,"[UE %d] DLSCH: Setting ACK for nr_tti_rx %d TBS %d mcs %d nb_rb %d harq_process->round %d\n", phy_vars_ue->Mod_id,nr_tti_rx,harq_process->TBS,harq_process->mcs,harq_process->nb_rb, harq_process->round); -#endif +//#endif harq_process->status = SCH_IDLE; harq_process->round = 0; @@ -655,7 +679,7 @@ uint32_t nr_dlsch_decoding(PHY_VARS_NR_UE *phy_vars_ue, if(is_crnti) { - LOG_D(PHY,"[UE %d] DLSCH: Setting ACK for nr_tti_rx %d (pid %d, round %d, TBS %d)\n",phy_vars_ue->Mod_id,nr_tti_rx,harq_pid,harq_process->round,harq_process->TBS); + LOG_I(PHY,"[UE %d] DLSCH: Setting ACK for nr_tti_rx %d (pid %d, round %d, TBS %d)\n",phy_vars_ue->Mod_id,nr_tti_rx,harq_pid,harq_process->round,harq_process->TBS); } //LOG_D(PHY,"[UE %d] DLSCH: Setting ACK for subframe %d (pid %d, round %d)\n",phy_vars_ue->Mod_id,subframe,harq_pid,harq_process->round); @@ -689,6 +713,20 @@ uint32_t nr_dlsch_decoding(PHY_VARS_NR_UE *phy_vars_ue, harq_process->b[offset], harq_process->F>>3, harq_process->c[r]); + + /*printf ("Printing payload bytes:"); + for (int i = 0; i < Kr_bytes; i++){ + printf("%d : %d \n", i, harq_process->b[i]); + }*/ +#endif + +#if defined(ENABLE_PHY_PAYLOAD_DEBUG) + if (frame%100 == 0){ + LOG_I (PHY, "Printing 10 first payload bytes at frame: %d ", frame); + for (int i = 0; i <10 ; i++){ //Kr_bytes + LOG_I(PHY, "[%d] : %x ", i, harq_process->b[i]); + } + } #endif } @@ -731,7 +769,6 @@ uint32_t nr_dlsch_decoding_mthread(PHY_VARS_NR_UE *phy_vars_ue, int32_t no_iteration_ldpc,length_dec; /*uint8_t C; uint8_t Qm; - uint8_t Nl; uint8_t r_thread; uint32_t Er, Gp,GpmodC;*/ t_nrLDPC_dec_params decParams; @@ -740,14 +777,14 @@ uint32_t nr_dlsch_decoding_mthread(PHY_VARS_NR_UE *phy_vars_ue, t_nrLDPC_time_stats* p_procTime =&procTime ; int8_t llrProcBuf[OAI_LDPC_MAX_NUM_LLR] __attribute__ ((aligned(32))); t_nrLDPC_procBuf* p_nrLDPC_procBuf = harq_process->p_nrLDPC_procBuf[0]; - + uint8_t Nl=4; int16_t z [68*384]; int8_t l [68*384]; //__m128i l; int16_t inv_d [68*384]; //int16_t *p_invd =&inv_d; uint8_t kb, kc; - uint8_t Ilbrm = 0; + uint8_t Ilbrm = 1; uint32_t Tbslbrm = 950984; uint16_t nb_rb = 30; double Coderate = 0.0; @@ -805,7 +842,9 @@ uint32_t nr_dlsch_decoding_mthread(PHY_VARS_NR_UE *phy_vars_ue, nb_rb = harq_process->nb_rb; harq_process->trials[harq_process->round]++; - harq_process->TBS = nr_compute_tbs(harq_process->mcs,nb_rb,nb_symb_sch,nb_re_dmrs,length_dmrs, harq_process->Nl); + uint16_t nb_rb_oh = 0; // it was not computed at UE side even before and set to 0 in nr_compute_tbs + + harq_process->TBS = nr_compute_tbs(harq_process->Qm,harq_process->R,nb_rb,nb_symb_sch,nb_re_dmrs*length_dmrs, nb_rb_oh, harq_process->Nl); A = harq_process->TBS; @@ -825,22 +864,11 @@ uint32_t nr_dlsch_decoding_mthread(PHY_VARS_NR_UE *phy_vars_ue, // printf("DLSCH Decoding, harq_pid %d Ndi %d\n",harq_pid,harq_process->Ndi); - if (harq_process->round == 0) { - // This is a new packet, so compute quantities regarding segmentation - harq_process->B = A+24; - nr_segmentation(NULL, - NULL, - harq_process->B, - &harq_process->C, - &harq_process->K, - &harq_process->Z, - &harq_process->F); + if ((harq_process->R)<1024) + Coderate = (float) (harq_process->R) /(float) 1024; + else + Coderate = (float) (harq_process->R) /(float) 2048; - p_decParams->Z = harq_process->Z; - - } - - Coderate = (float) A /(float) G; if ((A <=292) || ((A<=3824) && (Coderate <= 0.6667)) || Coderate <= 0.25) { p_decParams->BG = 2; @@ -873,6 +901,26 @@ uint32_t nr_dlsch_decoding_mthread(PHY_VARS_NR_UE *phy_vars_ue, } } + if (harq_process->round == 0) { + // This is a new packet, so compute quantities regarding segmentation + if (A > 3824) + harq_process->B = A+24; + else + harq_process->B = A+16; + + nr_segmentation(NULL, + NULL, + harq_process->B, + &harq_process->C, + &harq_process->K, + &harq_process->Z, + &harq_process->F, + p_decParams->BG); + + p_decParams->Z = harq_process->Z; + + } + //printf("coderate %f kc %d \n", Coderate, kc); p_decParams->numMaxIter = dlsch->max_ldpc_iterations; p_decParams->outMode= 0; @@ -951,8 +999,6 @@ uint32_t nr_dlsch_decoding_mthread(PHY_VARS_NR_UE *phy_vars_ue, Kr_bytes = Kr>>3; K_bytes_F = Kr_bytes-(harq_process->F>>3); - Tbslbrm = nr_compute_tbs(28,nb_rb,frame_parms->symbols_per_slot,0,0, harq_process->Nl); - E = nr_get_E(G, harq_process->C, harq_process->Qm, harq_process->Nl, r); /* @@ -993,6 +1039,12 @@ uint32_t nr_dlsch_decoding_mthread(PHY_VARS_NR_UE *phy_vars_ue, harq_process->round); #endif + // for tbslbrm calculation according to 5.4.2.1 of 38.212 + if (harq_process->Nl < Nl) + Nl = harq_process->Nl; + + Tbslbrm = nr_compute_tbslbrm(rel15.mcs_table,nb_rb,Nl,dlsch->harq_processes[harq_pid]->C); + if (nr_rate_matching_ldpc_rx(Ilbrm, Tbslbrm, p_decParams->BG, @@ -1045,7 +1097,11 @@ uint32_t nr_dlsch_decoding_mthread(PHY_VARS_NR_UE *phy_vars_ue, // printf("done\n"); if (harq_process->C == 1){ - crc_type = CRC24_A; + if (A > 3824) + crc_type = CRC24_A; + else + crc_type = CRC16; + length_dec = harq_process->B; } else{ @@ -1296,7 +1352,7 @@ void *nr_dlsch_decoding_process(void *arg) int16_t inv_d [68*384]; int16_t *p_invd =&inv_d; uint8_t kb, kc; - uint8_t Ilbrm = 0; + uint8_t Ilbrm = 1; uint32_t Tbslbrm = 950984; uint16_t nb_rb = 30; //to update double Coderate = 0.0; @@ -1336,8 +1392,8 @@ void *nr_dlsch_decoding_process(void *arg) int harq_pid = proc->harq_pid; llr8_flag1 = proc->llr8_flag; int frame = proc->frame_rx; - int slot = proc->nr_tti_rx; - r = proc->num_seg; + int slot = proc->nr_tti_rx; + r = proc->num_seg; NR_UE_DLSCH_t *dlsch = phy_vars_ue->dlsch[phy_vars_ue->current_thread_id[slot]][eNB_id][0]; NR_DL_UE_HARQ_t *harq_process = dlsch->harq_processes[harq_pid]; @@ -1365,7 +1421,9 @@ void *nr_dlsch_decoding_process(void *arg) harq_process->trials[harq_process->round]++; - harq_process->TBS = nr_compute_tbs(harq_process->mcs,nb_rb,nb_symb_sch,nb_re_dmrs,length_dmrs, harq_process->Nl); + uint16_t nb_rb_oh = 0; // it was not computed at UE side even before and set to 0 in nr_compute_tbs + + harq_process->TBS = nr_compute_tbs(harq_process->Qm,harq_process->R,nb_rb,nb_symb_sch,nb_re_dmrs*length_dmrs, nb_rb_oh, harq_process->Nl); A = harq_process->TBS; //2072 for QPSK 1/3 @@ -1377,23 +1435,11 @@ void *nr_dlsch_decoding_process(void *arg) LOG_I(PHY,"DLSCH Decoding process, harq_pid %d TBS %d G %d mcs %d Nl %d nb_symb_sch %d nb_rb %d\n",harq_pid,A,G, harq_process->mcs, harq_process->Nl, nb_symb_sch,nb_rb); - - if (harq_process->round == 0) { - // This is a new packet, so compute quantities regarding segmentation - harq_process->B = A+24; + if ((harq_process->R)<1024) + Coderate = (float) (harq_process->R) /(float) 1024; + else + Coderate = (float) (harq_process->R) /(float) 2048; - nr_segmentation(NULL, - NULL, - harq_process->B, - &harq_process->C, - &harq_process->K, - &harq_process->Z, - &harq_process->F); - p_decParams->Z = harq_process->Z; - - } - - Coderate = (float) A /(float) G; if ((A <=292) || ((A<=3824) && (Coderate <= 0.6667)) || Coderate <= 0.25) { p_decParams->BG = 2; @@ -1424,7 +1470,29 @@ void *nr_dlsch_decoding_process(void *arg) p_decParams->R = 89; kc = 27; } - } + } + + if (harq_process->round == 0) { + // This is a new packet, so compute quantities regarding segmentation + if (A > 3824) + harq_process->B = A+24; + else + harq_process->B = A+16; + + nr_segmentation(NULL, + NULL, + harq_process->B, + &harq_process->C, + &harq_process->K, + &harq_process->Z, + &harq_process->F, + p_decParams->BG); + + p_decParams->Z = harq_process->Z; + + } + + p_decParams->numMaxIter = dlsch->max_ldpc_iterations; p_decParams->outMode= 0; @@ -1484,9 +1552,7 @@ void *nr_dlsch_decoding_process(void *arg) Kr_bytes = Kr>>3; K_bytes_F = Kr_bytes-(harq_process->F>>3); - Tbslbrm = nr_compute_tbs(28,nb_rb,frame_parms->symbols_per_slot,0,0, harq_process->Nl); - - E = nr_get_E(G, harq_process->C, harq_process->Qm, harq_process->Nl, r); + E = nr_get_E(G, harq_process->C, harq_process->Qm, harq_process->Nl, r); #if UE_TIMING_TRACE start_meas(dlsch_deinterleaving_stats); @@ -1521,6 +1587,11 @@ void *nr_dlsch_decoding_process(void *arg) harq_process->round); #endif + if (Nl<4) + Tbslbrm = nr_compute_tbslbrm(harq_process->mcs_table,nb_rb,Nl,harq_process->C); + else + Tbslbrm = nr_compute_tbslbrm(harq_process->mcs_table,nb_rb,4,harq_process->C); + if (nr_rate_matching_ldpc_rx(Ilbrm, Tbslbrm, p_decParams->BG, @@ -1565,7 +1636,11 @@ void *nr_dlsch_decoding_process(void *arg) memset(harq_process->c[r],0,Kr_bytes); if (harq_process->C == 1){ - crc_type = CRC24_A; + if (A > 3824) + crc_type = CRC24_A; + else + crc_type = CRC16; + length_dec = harq_process->B; } else{ diff --git a/openair1/PHY/NR_UE_TRANSPORT/nr_dlsch_demodulation.c b/openair1/PHY/NR_UE_TRANSPORT/nr_dlsch_demodulation.c index 53c6615dbd..8f810d36d3 100644 --- a/openair1/PHY/NR_UE_TRANSPORT/nr_dlsch_demodulation.c +++ b/openair1/PHY/NR_UE_TRANSPORT/nr_dlsch_demodulation.c @@ -176,7 +176,8 @@ int nr_rx_pdsch(PHY_VARS_NR_UE *ue, dlsch = ue->dlsch[ue->current_thread_id[nr_tti_rx]][eNB_id]; - dlsch[0]->harq_processes[harq_pid]->Qm = nr_get_Qm(dlsch[0]->harq_processes[harq_pid]->mcs, 1);; + dlsch[0]->harq_processes[harq_pid]->Qm = nr_get_Qm_dl(dlsch[0]->harq_processes[harq_pid]->mcs, dlsch[0]->harq_processes[harq_pid]->mcs_table); + dlsch[0]->harq_processes[harq_pid]->R = nr_get_code_rate_dl(dlsch[0]->harq_processes[harq_pid]->mcs, dlsch[0]->harq_processes[harq_pid]->mcs_table); //printf("status TB0 = %d, status TB1 = %d \n", dlsch[0]->harq_processes[harq_pid]->status, dlsch[1]->harq_processes[harq_pid]->status); LOG_D(PHY,"AbsSubframe %d.%d / Sym %d harq_pid %d, harq status %d.%d \n", @@ -275,7 +276,7 @@ int nr_rx_pdsch(PHY_VARS_NR_UE *ue, } #if UE_TIMING_TRACE - if(symbol > ue->frame_parms.symbols_per_tti>>1) + if(symbol > ue->frame_parms.symbols_per_slot>>1) { slot = 1; } @@ -379,11 +380,11 @@ int nr_rx_pdsch(PHY_VARS_NR_UE *ue, #if UE_TIMING_TRACE stop_meas(&ue->generic_stat_bis[ue->current_thread_id[nr_tti_rx]][slot]); #if DISABLE_LOG_X - printf("[AbsSFN %d.%d] Slot%d Symbol %d Flag %d type %d: Pilot/Data extraction %5.2f \n",frame,nr_tti_rx,slot, - symbol,ue->high_speed_flag,type,symbol,ue->generic_stat_bis[ue->current_thread_id[nr_tti_rx]][slot].p_time/(cpuf*1000.0)); + printf("[AbsSFN %d.%d] Slot%d Symbol %d Flag %d type %d: Pilot/Data extraction %5.2f \n", + frame,nr_tti_rx,slot,symbol,ue->high_speed_flag,type,ue->generic_stat_bis[ue->current_thread_id[nr_tti_rx]][slot].p_time/(cpuf*1000.0)); #else - LOG_I(PHY, "[AbsSFN %d.%d] Slot%d Symbol %d Flag %d type %d: Pilot/Data extraction %5.2f \n",frame,nr_tti_rx,slot,symbol, - ue->high_speed_flag,type,ue->generic_stat_bis[ue->current_thread_id[nr_tti_rx]][slot].p_time/(cpuf*1000.0)); + LOG_I(PHY, "[AbsSFN %d.%d] Slot%d Symbol %d Flag %d type %d: Pilot/Data extraction %5.2f \n", + frame,nr_tti_rx,slot,symbol,ue->high_speed_flag,type,ue->generic_stat_bis[ue->current_thread_id[nr_tti_rx]][slot].p_time/(cpuf*1000.0)); #endif #endif @@ -964,7 +965,7 @@ int nr_rx_pdsch(PHY_VARS_NR_UE *ue, break; } if (dlsch1_harq) { - switch (nr_get_Qm(dlsch1_harq->mcs, 1)) { + switch (nr_get_Qm_dl(dlsch1_harq->mcs,dlsch1_harq->mcs_table)) { case 2 : if (rx_type==rx_standard) { nr_dlsch_qpsk_llr(frame_parms, @@ -1064,9 +1065,9 @@ int nr_rx_pdsch(PHY_VARS_NR_UE *ue, #if T_TRACER T(T_UE_PHY_PDSCH_IQ, T_INT(eNB_id), T_INT(ue->Mod_id), T_INT(frame%1024), T_INT(nr_tti_rx), T_INT(nb_rb), - T_INT(frame_parms->N_RB_UL), T_INT(frame_parms->symbols_per_tti), + T_INT(frame_parms->N_RB_UL), T_INT(frame_parms->symbols_per_slot), T_BUFFER(&pdsch_vars[eNB_id]->rxdataF_comp0[eNB_id][0], - 2 * /* ulsch[UE_id]->harq_processes[harq_pid]->nb_rb */ frame_parms->N_RB_UL *12*frame_parms->symbols_per_tti*2)); + 2 * /* ulsch[UE_id]->harq_processes[harq_pid]->nb_rb */ frame_parms->N_RB_UL *12*frame_parms->symbols_per_slot*2)); #endif return(0); @@ -2379,10 +2380,13 @@ unsigned short nr_dlsch_extract_rbs_single(int **rxdataF, unsigned char j=0; - k = frame_parms->first_carrier_offset + 12*start_rb; + AssertFatal(frame_parms->nushift ==0 || frame_parms->nushift == 1, + "nushift %d is illegal\n",frame_parms->nushift); for (aarx=0; aarxnb_antennas_rx; aarx++) { + k = frame_parms->first_carrier_offset + 12*start_rb; + if (high_speed_flag == 1) dl_ch0 = &dl_ch_estimates[aarx][(2*(frame_parms->ofdm_symbol_size))]; else @@ -2393,65 +2397,43 @@ unsigned short nr_dlsch_extract_rbs_single(int **rxdataF, rxF_ext = &rxdataF_ext[aarx][symbol*(nb_rb_pdsch*12)]; rxF = &rxdataF[aarx][(k+(symbol*(frame_parms->ofdm_symbol_size)))]; - //printf("extract single addr %p pilots %d symbol %d, l %d RB_DL %d nushift %d k %d\n", rxF, pilots, symbol, l, frame_parms->N_RB_DL,frame_parms->nushift,k); - - //if ((frame_parms->N_RB_DL&1) == 0){ // even number of RBs - - for (rb = start_rb; rb < nb_rb_pdsch + start_rb; rb++) { - - // For second half of RBs skip DC carrier - if (k>=frame_parms->ofdm_symbol_size) { - rxF = &rxdataF[aarx][(symbol*(frame_parms->ofdm_symbol_size))]; - k=k-(frame_parms->ofdm_symbol_size); + for (rb = 0; rb < nb_rb_pdsch; rb++) { + if (k>frame_parms->ofdm_symbol_size) { + k = k-frame_parms->ofdm_symbol_size; + rxF = &rxdataF[aarx][(k+(symbol*(frame_parms->ofdm_symbol_size)))]; } - - //*pmi_ext = (pmi>>((rb>>2)<<1))&3; - //memcpy(dl_ch0_ext,dl_ch0,12*sizeof(int)); - - /* - printf("rb %d\n",rb); - for (i=0;i<12;i++) - printf("(%d %d)",((short *)dl_ch0)[i<<1],((short*)dl_ch0)[1+(i<<1)]); - printf("\n"); - */ - if (pilots==0) { - for (i=0; i<12; i++) { - rxF_ext[i]=rxF[i]; - dl_ch0_ext[i]=dl_ch0[i]; - /*printf("rb %ld %p: (%d,%d)\n",(rxF+i-&rxdataF[aarx][( (symbol*(frame_parms->ofdm_symbol_size)))]),rxF, - ((short*)&rxF[i])[0],((short*)&rxF[i])[1]); - printf("rb %ld %p: dl_ch (%d,%d)\n",(rxF+i-&rxdataF[aarx][( (symbol*(frame_parms->ofdm_symbol_size)))]),rxF, - ((short*)&dl_ch0[i])[0],((short*)&dl_ch0[i])[1]); - printf("re count %d\n",rb*12+i);*/ - } - - dl_ch0_ext+=12; - rxF_ext+=12; - } else { - j=0; - - for (i=0; i<12; i++) { - if ((i&1)!=frame_parms->nushift){ - rxF_ext[j]=rxF[i]; - //printf("extract rb %d, re %d => rxF (%d,%d) rxF ext (%d,%d) addr %p\n",rb,i,*(short *)&rxF[i],*(1+(short*)&rxF[i]),*(short *)&rxF_ext[j],*(1+(short*)&rxF_ext[j]),rxF_ext); - dl_ch0_ext[j]=dl_ch0[i]; - //printf("rb %ld %p: dl_ch (%d,%d)\n",(rxF+i-&rxdataF[aarx][( (symbol*(frame_parms->ofdm_symbol_size)))]),rxF, - //((short*)&dl_ch0[i])[0],((short*)&dl_ch0[i])[1]); - j++; - } - } - - dl_ch0_ext+=6; - rxF_ext+=6; - } - - dl_ch0+=12; - rxF+=12; - k+=12; + if (pilots==0) { + memcpy((void*)rxF_ext,(void*)rxF,12*sizeof(*rxF_ext)); + memcpy((void*)dl_ch0_ext,(void*)dl_ch0,12*sizeof(*dl_ch0_ext)); + dl_ch0_ext+=12; + rxF_ext+=12; + } else { + j=0; + + for (i = (1-frame_parms->nushift); + i<12; + i+=2) { + rxF_ext[j]=rxF[i]; + dl_ch0_ext[j]=dl_ch0[i]; + j++; + } + + + dl_ch0_ext+=6; + rxF_ext+=6; } + + dl_ch0+=12; + rxF+=12; + k+=12; + if (k>=frame_parms->ofdm_symbol_size) { + k=k-(frame_parms->ofdm_symbol_size); + rxF = &rxdataF[aarx][k+(symbol*(frame_parms->ofdm_symbol_size))]; + } + } } - - + + return(nb_rb_pdsch/frame_parms->nb_antennas_rx); } diff --git a/openair1/PHY/NR_UE_TRANSPORT/nr_pbch.c b/openair1/PHY/NR_UE_TRANSPORT/nr_pbch.c index cac9ae92ac..3d8ec866c6 100644 --- a/openair1/PHY/NR_UE_TRANSPORT/nr_pbch.c +++ b/openair1/PHY/NR_UE_TRANSPORT/nr_pbch.c @@ -93,7 +93,7 @@ uint16_t nr_pbch_extract(int **rxdataF, (i!=(nushiftmod4+8))) { rxF_ext[j]=rxF[rx_offset]; #ifdef DEBUG_PBCH - printf("rxF ext[%d] = (%d,%d) rxF [%d]= (%d,%d)\n",(9*rb) + j, + printf("rxF ext[%d] = (%d,%d) rxF [%u]= (%d,%d)\n",(9*rb) + j, ((int16_t *)&rxF_ext[j])[0], ((int16_t *)&rxF_ext[j])[1], rx_offset, @@ -116,7 +116,7 @@ uint16_t nr_pbch_extract(int **rxdataF, (i!=(nushiftmod4+8))) { rxF_ext[j]=rxF[rx_offset]; #ifdef DEBUG_PBCH - printf("rxF ext[%d] = (%d,%d) rxF [%d]= (%d,%d)\n",(rb<4) ? (9*rb) + j : (9*(rb-12))+j, + printf("rxF ext[%d] = (%d,%d) rxF [%u]= (%d,%d)\n",(rb<4) ? (9*rb) + j : (9*(rb-12))+j, ((int16_t *)&rxF_ext[j])[0], ((int16_t *)&rxF_ext[j])[1], rx_offset, @@ -611,7 +611,7 @@ int nr_rx_pbch( PHY_VARS_NR_UE *ue, rx_ind.rx_indication_body[0].mib_pdu.ssb_index = i_ssb; // confirm with TCL rx_ind.rx_indication_body[0].mib_pdu.ssb_length = Lmax; // confirm with TCL rx_ind.rx_indication_body[0].mib_pdu.cell_id = frame_parms->Nid_cell; // confirm with TCL - rx_ind.number_pdus = 1; + rx_ind.number_pdus = 1; //rx_ind.number_pdus++; if (ue->if_inst && ue->if_inst->dl_indication) ue->if_inst->dl_indication(&dl_indication); diff --git a/openair1/PHY/NR_UE_TRANSPORT/nr_transport_proto_ue.h b/openair1/PHY/NR_UE_TRANSPORT/nr_transport_proto_ue.h index e0119ea7ea..35d70546c5 100644 --- a/openair1/PHY/NR_UE_TRANSPORT/nr_transport_proto_ue.h +++ b/openair1/PHY/NR_UE_TRANSPORT/nr_transport_proto_ue.h @@ -1055,18 +1055,6 @@ int nr_ulsch_encoding(NR_UE_ULSCH_t *ulsch, NR_DL_FRAME_PARMS* frame_parms, uint8_t harq_pid); -/*! \brief Fill up NR_UE_ULSCH_t and NR_UL_UE_HARQ_t structs - @param[in] UE, Pointer to PHY_VARS_NR_UE struct - @param[in] thread_id, thread id - @param[in] gNB_id, gNB id - @param[in] harq_pid, harq id -*/ - -int generate_ue_ulsch_params(PHY_VARS_NR_UE *UE, - uint8_t thread_id, - int gNB_id, - unsigned char harq_pid); - /*! \brief Perform PUSCH scrambling. TS 38.211 V15.4.0 subclause 6.3.1.1 @param[in] in, Pointer to input bits @param[in] size, of input bits @@ -1076,7 +1064,7 @@ int generate_ue_ulsch_params(PHY_VARS_NR_UE *UE, */ void nr_pusch_codeword_scrambling(uint8_t *in, - uint16_t size, + uint32_t size, uint32_t Nid, uint32_t n_RNTI, uint32_t* out); @@ -1088,19 +1076,21 @@ void nr_pusch_codeword_scrambling(uint8_t *in, - transform precoding */ -uint8_t nr_ue_ulsch_procedures(PHY_VARS_NR_UE *UE, +void nr_ue_ulsch_procedures(PHY_VARS_NR_UE *UE, unsigned char harq_pid, uint8_t slot, uint8_t thread_id, - int eNB_id); + int gNB_id); /** \brief This function does IFFT for PUSCH */ uint8_t nr_ue_pusch_common_procedures(PHY_VARS_NR_UE *UE, + uint8_t harq_pid, uint8_t slot, - uint8_t Nl, + uint8_t thread_id, + uint8_t gNB_id, NR_DL_FRAME_PARMS *frame_parms); diff --git a/openair1/PHY/NR_UE_TRANSPORT/nr_transport_ue.h b/openair1/PHY/NR_UE_TRANSPORT/nr_transport_ue.h index 7b65140612..6ed28a9b36 100644 --- a/openair1/PHY/NR_UE_TRANSPORT/nr_transport_ue.h +++ b/openair1/PHY/NR_UE_TRANSPORT/nr_transport_ue.h @@ -159,10 +159,6 @@ typedef struct { } NR_UL_UE_HARQ_t; typedef struct { - /// Current Number of Symbols - uint8_t Nsymb_pusch; - /// Nsc_pusch, number of allocated subcarriers for ULSCH - uint16_t Nsc_pusch; /// number of DMRS resource elements uint8_t nb_re_dmrs; /// DMRS length @@ -271,10 +267,14 @@ typedef struct { uint8_t *c[MAX_NUM_NR_DLSCH_SEGMENTS]; /// Index of current HARQ round for this DLSCH uint8_t round; + /// MCS table for this DLSCH + uint8_t mcs_table; /// MCS format for this DLSCH uint8_t mcs; /// Qm (modulation order) for this DLSCH uint8_t Qm; + /// target code rate R x 1024 + uint16_t R; /// Redundancy-version of the current sub-frame uint8_t rvidx; /// MIMO mode for this DLSCH diff --git a/openair1/PHY/NR_UE_TRANSPORT/nr_ulsch_coding.c b/openair1/PHY/NR_UE_TRANSPORT/nr_ulsch_coding.c index 5c8493c370..cbe0a816ff 100644 --- a/openair1/PHY/NR_UE_TRANSPORT/nr_ulsch_coding.c +++ b/openair1/PHY/NR_UE_TRANSPORT/nr_ulsch_coding.c @@ -44,8 +44,7 @@ void free_nr_ue_ulsch(NR_UE_ULSCH_t *ulsch) { - int i; - int r; + int i, r; if (ulsch) { #ifdef DEBUG_ULSCH_FREE @@ -87,10 +86,10 @@ void free_nr_ue_ulsch(NR_UE_ULSCH_t *ulsch) } - -NR_UE_ULSCH_t *new_nr_ue_ulsch(unsigned char N_RB_UL, int number_of_harq_pids, uint8_t abstraction_flag) +NR_UE_ULSCH_t *new_nr_ue_ulsch(unsigned char N_RB_UL, + int number_of_harq_pids, + uint8_t abstraction_flag) { - NR_UE_ULSCH_t *ulsch; unsigned char exit_flag = 0,i,r; unsigned char bw_scaling =1; @@ -187,12 +186,10 @@ NR_UE_ULSCH_t *new_nr_ue_ulsch(unsigned char N_RB_UL, int number_of_harq_pids, u } - int nr_ulsch_encoding(NR_UE_ULSCH_t *ulsch, - NR_DL_FRAME_PARMS* frame_parms, - uint8_t harq_pid) + NR_DL_FRAME_PARMS* frame_parms, + uint8_t harq_pid) { - /////////////////////////parameters and variables declaration///////////////////////// /////////// @@ -205,11 +202,12 @@ int nr_ulsch_encoding(NR_UE_ULSCH_t *ulsch, uint8_t mod_order; uint16_t Kr,r,r_offset; uint8_t BG; - uint32_t E; + uint32_t E,Kb; uint8_t Ilbrm; uint32_t Tbslbrm; uint8_t nb_re_dmrs; uint16_t length_dmrs; + uint16_t R; float Coderate; /////////// @@ -225,7 +223,8 @@ int nr_ulsch_encoding(NR_UE_ULSCH_t *ulsch, nb_symb_sch = harq_process->number_of_symbols; A = harq_process->TBS; pz = &Z; - mod_order = nr_get_Qm(harq_process->mcs,1); + mod_order = nr_get_Qm_ul(harq_process->mcs,0); + R = nr_get_code_rate_ul(harq_process->mcs, 0); Kr=0; r_offset=0; BG = 1; @@ -253,9 +252,6 @@ int nr_ulsch_encoding(NR_UE_ULSCH_t *ulsch, G = nr_get_G(nb_rb, nb_symb_sch, nb_re_dmrs, length_dmrs,mod_order,harq_process->Nl); LOG_D(PHY,"ulsch coding A %d G %d mod_order %d\n", A,G, mod_order); - - - Tbslbrm = nr_compute_tbs(28,nb_rb,frame_parms->symbols_per_slot,0,0, harq_process->Nl); // if (harq_process->Ndi == 1) { // this is a new packet if (harq_process->round == 0) { // this is a new packet @@ -290,16 +286,10 @@ int nr_ulsch_encoding(NR_UE_ULSCH_t *ulsch, ///////////////////////// b---->| block segmentation |---->c ///////////////////////// /////////// - nr_segmentation(harq_process->b, - harq_process->c, - harq_process->B, - &harq_process->C, - &harq_process->K, - pz, - &harq_process->F); - - F = harq_process->F; - Coderate = (float) A /(float) G; + if (R<1024) + Coderate = (float) R /(float) 1024; + else + Coderate = (float) R /(float) 2048; if ((A <=292) || ((A<=3824) && (Coderate <= 0.6667)) || Coderate <= 0.25){ BG = 2; @@ -308,6 +298,16 @@ int nr_ulsch_encoding(NR_UE_ULSCH_t *ulsch, BG = 1; } + Kb=nr_segmentation(harq_process->b, + harq_process->c, + harq_process->B, + &harq_process->C, + &harq_process->K, + pz, + &harq_process->F, + BG); + + F = harq_process->F; Kr = harq_process->K; #ifdef DEBUG_DLSCH_CODING uint16_t Kr_bytes; @@ -317,6 +317,7 @@ int nr_ulsch_encoding(NR_UE_ULSCH_t *ulsch, /////////// ///////////////////////////////////////////////////////////////////////////////////// +opp_enabled=0; ///////////////////////// c---->| LDCP coding |---->d ///////////////////////// /////////// @@ -351,7 +352,7 @@ int nr_ulsch_encoding(NR_UE_ULSCH_t *ulsch, } printf("\n");*/ - ldpc_encoder_optim_8seg(harq_process->c,harq_process->d,Kr,BG,harq_process->C,NULL,NULL,NULL,NULL); + ldpc_encoder_optim_8seg(harq_process->c,harq_process->d,*pz,Kb,Kr,BG,harq_process->C,NULL,NULL,NULL,NULL); //stop_meas(te_stats); //printf("end ldpc encoder -- output\n"); @@ -376,7 +377,7 @@ int nr_ulsch_encoding(NR_UE_ULSCH_t *ulsch, } #ifdef DEBUG_DLSCH_CODING - printf("Rate Matching, Code segment %d (coded bits (G) %d,unpunctured/repeated bits per code segment %d,mod_order %d, nb_rb %d)...\n", + printf("Rate Matching, Code segment %d (coded bits (G) %u, unpunctured/repeated bits per code segment %d, mod_order %d, nb_rb %d)...\n", r, G, Kr*3, @@ -393,6 +394,8 @@ int nr_ulsch_encoding(NR_UE_ULSCH_t *ulsch, E = nr_get_E(G, harq_process->C, mod_order, harq_process->Nl, r); + Tbslbrm = nr_compute_tbslbrm(0,nb_rb,harq_process->Nl,harq_process->C); + nr_rate_matching_ldpc(Ilbrm, Tbslbrm, BG, diff --git a/openair1/PHY/NR_UE_TRANSPORT/nr_ulsch_ue.c b/openair1/PHY/NR_UE_TRANSPORT/nr_ulsch_ue.c index 2b59f93160..f8c9c83e78 100644 --- a/openair1/PHY/NR_UE_TRANSPORT/nr_ulsch_ue.c +++ b/openair1/PHY/NR_UE_TRANSPORT/nr_ulsch_ue.c @@ -43,77 +43,10 @@ #include "PHY/TOOLS/tools_defs.h" //#define DEBUG_SCFDMA - - -int generate_ue_ulsch_params(PHY_VARS_NR_UE *UE, - uint8_t thread_id, - int gNB_id, - unsigned char harq_pid){ - - int N_PRB_oh, N_RE_prime, cwd_idx, length_dmrs, Nid_cell; - int nb_rb, Nsymb_pusch, first_rb, nb_codewords,mcs,rvidx; - uint16_t n_rnti; - - NR_UE_ULSCH_t *ulsch_ue; - NR_UL_UE_HARQ_t *harq_process_ul_ue; - - LOG_W(PHY,"This function should not be used. Use FAPI interfaces instead\n"); - - //--------------------------Temporary configuration-----------------------------// - length_dmrs = 1; - n_rnti = 0x1234; - Nid_cell = 0; - nb_rb = 50; - first_rb = 30; - Nsymb_pusch = 12; - nb_codewords = 1; - mcs = 9; - rvidx = 0; - //------------------------------------------------------------------------------// - - for (cwd_idx = 0; cwd_idx < nb_codewords; cwd_idx++) { - - ulsch_ue = UE->ulsch[thread_id][gNB_id][cwd_idx]; - harq_process_ul_ue = ulsch_ue->harq_processes[harq_pid]; - - ulsch_ue->length_dmrs = length_dmrs; - ulsch_ue->rnti = n_rnti; - ulsch_ue->Nid_cell = Nid_cell; - ulsch_ue->Nsc_pusch = nb_rb*NR_NB_SC_PER_RB; - ulsch_ue->Nsymb_pusch = Nsymb_pusch; - ulsch_ue->nb_re_dmrs = UE->dmrs_UplinkConfig.pusch_maxLength*(UE->dmrs_UplinkConfig.pusch_dmrs_type == pusch_dmrs_type1)?6:4; - - - N_PRB_oh = 0; // higher layer (RRC) parameter xOverhead in PUSCH-ServingCellConfig - N_RE_prime = NR_NB_SC_PER_RB*Nsymb_pusch - ulsch_ue->nb_re_dmrs - N_PRB_oh; - - if (harq_process_ul_ue) { - - harq_process_ul_ue->mcs = mcs; - harq_process_ul_ue->Nl = nb_codewords; - harq_process_ul_ue->nb_rb = nb_rb; - harq_process_ul_ue->first_rb = first_rb; - harq_process_ul_ue->number_of_symbols = Nsymb_pusch; - harq_process_ul_ue->num_of_mod_symbols = N_RE_prime*nb_rb*nb_codewords; - harq_process_ul_ue->rvidx = rvidx; - harq_process_ul_ue->TBS = nr_compute_tbs(harq_process_ul_ue->mcs, - nb_rb, - Nsymb_pusch, - ulsch_ue->nb_re_dmrs, - length_dmrs, - harq_process_ul_ue->Nl); - - } - - } - - return 0; -} - - +//#define DEBUG_PUSCH_MAPPING void nr_pusch_codeword_scrambling(uint8_t *in, - uint16_t size, + uint32_t size, uint32_t Nid, uint32_t n_RNTI, uint32_t* out) { @@ -151,39 +84,76 @@ void nr_pusch_codeword_scrambling(uint8_t *in, } -uint8_t nr_ue_ulsch_procedures(PHY_VARS_NR_UE *UE, +void nr_ue_ulsch_procedures(PHY_VARS_NR_UE *UE, unsigned char harq_pid, uint8_t slot, uint8_t thread_id, - int eNB_id) { + int gNB_id) { - unsigned int available_bits; + uint32_t available_bits; uint8_t mod_order, cwd_index, num_of_codewords; uint32_t scrambled_output[NR_MAX_NB_CODEWORDS][NR_MAX_PDSCH_ENCODED_LENGTH>>5]; - int32_t *mod_symbols[MAX_NUM_NR_RE]; uint32_t ***pusch_dmrs; int16_t **tx_layers; int32_t **txdataF; uint16_t start_sc, start_rb; int8_t Wf[2], Wt[2], l0, l_prime[2], delta; - uint16_t n_dmrs; - uint8_t dmrs_type; + uint16_t n_dmrs,code_rate; + uint8_t dmrs_type, length_dmrs; uint8_t mapping_type; - int ap, start_symbol, i; - int sample_offsetF; + int ap, start_symbol, Nid_cell, i; + int sample_offsetF, N_RE_prime, N_PRB_oh; + uint16_t n_rnti; NR_UE_ULSCH_t *ulsch_ue; NR_UL_UE_HARQ_t *harq_process_ul_ue; NR_DL_FRAME_PARMS *frame_parms = &UE->frame_parms; - NR_UE_PUSCH *pusch_ue = UE->pusch_vars[thread_id][eNB_id]; + NR_UE_PUSCH *pusch_ue = UE->pusch_vars[thread_id][gNB_id]; num_of_codewords = 1; // tmp assumption + length_dmrs = 1; + n_rnti = 0x1234; + Nid_cell = 0; + N_PRB_oh = 0; // higher layer (RRC) parameter xOverhead in PUSCH-ServingCellConfig for (cwd_index = 0;cwd_index < num_of_codewords; cwd_index++) { - ulsch_ue = UE->ulsch[thread_id][eNB_id][cwd_index]; + ulsch_ue = UE->ulsch[thread_id][gNB_id][cwd_index]; harq_process_ul_ue = ulsch_ue->harq_processes[harq_pid]; + ulsch_ue->length_dmrs = length_dmrs; + ulsch_ue->rnti = n_rnti; + ulsch_ue->Nid_cell = Nid_cell; + ulsch_ue->nb_re_dmrs = UE->dmrs_UplinkConfig.pusch_maxLength*(UE->dmrs_UplinkConfig.pusch_dmrs_type == pusch_dmrs_type1)?6:4; + + N_RE_prime = NR_NB_SC_PER_RB*harq_process_ul_ue->number_of_symbols - ulsch_ue->nb_re_dmrs - N_PRB_oh; + + harq_process_ul_ue->num_of_mod_symbols = N_RE_prime*harq_process_ul_ue->nb_rb*num_of_codewords; + + mod_order = nr_get_Qm_ul(harq_process_ul_ue->mcs, 0); + code_rate = nr_get_code_rate_ul(harq_process_ul_ue->mcs, 0); + + harq_process_ul_ue->TBS = nr_compute_tbs(mod_order, + code_rate, + harq_process_ul_ue->nb_rb, + harq_process_ul_ue->number_of_symbols, + ulsch_ue->nb_re_dmrs*ulsch_ue->length_dmrs, + 0, + harq_process_ul_ue->Nl); + + //-----------------------------------------------------// + // to be removed later when MAC is ready + + if (harq_process_ul_ue != NULL){ + for (i = 0; i < harq_process_ul_ue->TBS / 8; i++) + harq_process_ul_ue->a[i] = (unsigned char) rand(); + } else { + LOG_E(PHY, "[phy_procedures_nrUE_TX] harq_process_ul_ue is NULL !!\n"); + return; + } + + //-----------------------------------------------------// + /////////////////////////ULSCH coding///////////////////////// /////////// @@ -195,10 +165,10 @@ uint8_t nr_ue_ulsch_procedures(PHY_VARS_NR_UE *UE, /////////////////////////ULSCH scrambling///////////////////////// /////////// - mod_order = nr_get_Qm(harq_process_ul_ue->mcs, 1); + mod_order = nr_get_Qm_ul(harq_process_ul_ue->mcs, 0); available_bits = nr_get_G(harq_process_ul_ue->nb_rb, - ulsch_ue->Nsymb_pusch, + harq_process_ul_ue->number_of_symbols, ulsch_ue->nb_re_dmrs, ulsch_ue->length_dmrs, mod_order, @@ -224,22 +194,19 @@ uint8_t nr_ue_ulsch_procedures(PHY_VARS_NR_UE *UE, mod_order, (int16_t *)ulsch_ue->d_mod); + // pusch_transform_precoding(ulsch_ue, frame_parms, harq_pid); /////////// //////////////////////////////////////////////////////////////////////// - mod_symbols[cwd_index] = (int32_t *)malloc16((NR_MAX_PUSCH_ENCODED_LENGTH)*sizeof(int32_t*)); - - memcpy(mod_symbols[cwd_index],ulsch_ue->d_mod,(available_bits/mod_order)*sizeof(int32_t)); } - start_symbol = 14 - ulsch_ue->Nsymb_pusch; + start_symbol = 14 - harq_process_ul_ue->number_of_symbols; /////////////////////////DMRS Modulation///////////////////////// /////////// - pusch_dmrs = UE->nr_gold_pusch_dmrs[slot]; n_dmrs = (harq_process_ul_ue->nb_rb*ulsch_ue->nb_re_dmrs); int16_t mod_dmrs[n_dmrs<<1]; @@ -249,7 +216,6 @@ uint8_t nr_ue_ulsch_procedures(PHY_VARS_NR_UE *UE, l0 = get_l0_ul(mapping_type, 2); nr_modulation(pusch_dmrs[l0][0], n_dmrs*2, DMRS_MOD_ORDER, mod_dmrs); // currently only codeword 0 is modulated. Qm = 2 as DMRS is QPSK modulated - /////////// //////////////////////////////////////////////////////////////////////// @@ -258,13 +224,10 @@ uint8_t nr_ue_ulsch_procedures(PHY_VARS_NR_UE *UE, tx_layers = (int16_t **)pusch_ue->txdataF_layers; - nr_layer_mapping((int16_t **)mod_symbols, + nr_ue_layer_mapping(UE->ulsch[thread_id][gNB_id], harq_process_ul_ue->Nl, available_bits/mod_order, tx_layers); - - for (uint32_t i = 0; i < 2*available_bits/mod_order; i++) - tx_layers[0][i] = (tx_layers[0][i] * AMP) >> 15; /////////// //////////////////////////////////////////////////////////////////////// @@ -280,7 +243,7 @@ uint8_t nr_ue_ulsch_procedures(PHY_VARS_NR_UE *UE, uint32_t nb_re_pusch, nb_re_dmrs_per_rb; uint32_t y_offset = 0; - for (l = start_symbol; l < start_symbol + ulsch_ue->Nsymb_pusch; l++) { + for (l = start_symbol; l < start_symbol + harq_process_ul_ue->number_of_symbols; l++) { if(l == dmrs_symbol) nb_re_dmrs_per_rb = ulsch_ue->nb_re_dmrs; // [hna] ulsch_ue->nb_re_dmrs = 6 in this configuration @@ -324,7 +287,7 @@ uint8_t nr_ue_ulsch_procedures(PHY_VARS_NR_UE *UE, uint8_t k_prime=0; uint16_t m=0, n=0, dmrs_idx=0, k=0; - for (l=start_symbol; lNsymb_pusch; l++) { + for (l=start_symbol; lnumber_of_symbols; l++) { k = start_sc; @@ -338,11 +301,12 @@ uint8_t nr_ue_ulsch_procedures(PHY_VARS_NR_UE *UE, ((int16_t*)txdataF[ap])[((sample_offsetF)<<1) + 1] = (Wt[l_prime[0]]*Wf[k_prime]*AMP*mod_dmrs[(dmrs_idx<<1) + 1]) >> 15; #ifdef DEBUG_PUSCH_MAPPING - printf("dmrs_idx %d\t l %d \t k %d \t k_prime %d \t n %d \t txdataF: %d %d\n", + printf("dmrs_idx %d\t l %d \t k %d \t k_prime %d \t n %d \t dmrs: %d %d\n", dmrs_idx, l, k, k_prime, n, ((int16_t*)txdataF[ap])[(sample_offsetF)<<1], ((int16_t*)txdataF[ap])[((sample_offsetF)<<1) + 1]); #endif + dmrs_idx++; k_prime++; k_prime&=1; @@ -372,23 +336,37 @@ uint8_t nr_ue_ulsch_procedures(PHY_VARS_NR_UE *UE, /////////// //////////////////////////////////////////////////////////////////////// - return 0; + return; } uint8_t nr_ue_pusch_common_procedures(PHY_VARS_NR_UE *UE, + uint8_t harq_pid, uint8_t slot, - uint8_t Nl, + uint8_t thread_id, + uint8_t gNB_id, NR_DL_FRAME_PARMS *frame_parms) { int tx_offset, ap; int32_t **txdata; int32_t **txdataF; + int timing_advance; + uint8_t Nl = UE->ulsch[thread_id][gNB_id][0]->harq_processes[harq_pid]->Nl; // cw 0 /////////////////////////IFFT/////////////////////// /////////// - tx_offset = slot*frame_parms->samples_per_slot; +#if defined(EXMIMO) || defined(OAI_USRP) || defined(OAI_BLADERF) || defined(OAI_LMSSDR) || defined(OAI_ADRV9371_ZC706) + timing_advance = UE->timing_advance; +#else + timing_advance = 0; +#endif + + tx_offset = slot*frame_parms->samples_per_slot - timing_advance; + + if (tx_offset < 0) + tx_offset += frame_parms->samples_per_frame; + txdata = UE->common_vars.txdata; txdataF = UE->common_vars.txdataF; @@ -407,7 +385,6 @@ uint8_t nr_ue_pusch_common_procedures(PHY_VARS_NR_UE *UE, frame_parms); } } - /////////// //////////////////////////////////////////////////// return 0; diff --git a/openair1/PHY/NR_UE_TRANSPORT/pss_nr.c b/openair1/PHY/NR_UE_TRANSPORT/pss_nr.c index c9fb300706..b13cd008b5 100644 --- a/openair1/PHY/NR_UE_TRANSPORT/pss_nr.c +++ b/openair1/PHY/NR_UE_TRANSPORT/pss_nr.c @@ -234,8 +234,8 @@ void generate_pss_nr(NR_DL_FRAME_PARMS *fp,int N_ID_2) if (N_ID_2 == 0) { char output_file[255]; char sequence_name[255]; - sprintf(output_file, "pss_seq_%d_%d.m", N_ID_2, length); - sprintf(sequence_name, "pss_seq_%d_%d", N_ID_2, length); + sprintf(output_file, "pss_seq_%d_%u.m", N_ID_2, length); + sprintf(sequence_name, "pss_seq_%d_%u", N_ID_2, length); printf("file %s sequence %s\n", output_file, sequence_name); LOG_M(output_file, sequence_name, primary_synchro, LENGTH_PSS_NR, 1, 1); @@ -298,14 +298,14 @@ void generate_pss_nr(NR_DL_FRAME_PARMS *fp,int N_ID_2) if (N_ID_2 == 0) { char output_file[255]; char sequence_name[255]; - sprintf(output_file, "%s%d_%d%s","pss_seq_t_", N_ID_2, length, ".m"); - sprintf(sequence_name, "%s%d_%d","pss_seq_t_", N_ID_2, length); + sprintf(output_file, "%s%d_%u%s","pss_seq_t_", N_ID_2, length, ".m"); + sprintf(sequence_name, "%s%d_%u","pss_seq_t_", N_ID_2, length); printf("file %s sequence %s\n", output_file, sequence_name); LOG_M(output_file, sequence_name, primary_synchro_time, length, 1, 1); - sprintf(output_file, "%s%d_%d%s","pss_seq_f_", N_ID_2, length, ".m"); - sprintf(sequence_name, "%s%d_%d","pss_seq_f_", N_ID_2, length); + sprintf(output_file, "%s%d_%u%s","pss_seq_f_", N_ID_2, length, ".m"); + sprintf(sequence_name, "%s%d_%u","pss_seq_f_", N_ID_2, length); LOG_M(output_file, sequence_name, synchroF_tmp, length, 1, 1); } @@ -900,7 +900,7 @@ int pss_search_time_nr(int **rxdata, ///rx data in time domain pss_source = pss_index; #ifdef DEBUG_PSS_NR - printf("pss_index %d: n %6d peak_value %15llu\n", pss_index, n, (unsigned long long)pss_corr_ue[pss_index][n]); + printf("pss_index %d: n %6u peak_value %15llu\n", pss_index, n, (unsigned long long)pss_corr_ue[pss_index][n]); #endif } } diff --git a/openair1/PHY/TOOLS/lte_phy_scope.c b/openair1/PHY/TOOLS/lte_phy_scope.c index 3ac1676983..dbcd9540be 100644 --- a/openair1/PHY/TOOLS/lte_phy_scope.c +++ b/openair1/PHY/TOOLS/lte_phy_scope.c @@ -559,7 +559,10 @@ void phy_scope_UE(FD_lte_phy_scope_ue *form, } chest_f_abs = (float*) calloc(nsymb_ce*nb_antennas_rx*nb_antennas_tx,sizeof(float)); - llr = (float*) calloc(coded_bits_per_codeword,sizeof(float)); // init to zero + //llr = (float*) calloc(coded_bits_per_codeword,sizeof(float)); // Cppcheck returns "invalidFunctionArg" error. + llr = (float*) malloc(coded_bits_per_codeword*sizeof(float)); + memset((void *)llr, 0,coded_bits_per_codeword*sizeof(float)); // init to zero + bit = malloc(coded_bits_per_codeword*sizeof(float)); llr_pdcch = (float*) calloc(12*frame_parms->N_RB_DL*num_pdcch_symbols*2,sizeof(float)); // init to zero bit_pdcch = (float*) calloc(12*frame_parms->N_RB_DL*num_pdcch_symbols*2,sizeof(float)); @@ -572,7 +575,7 @@ void phy_scope_UE(FD_lte_phy_scope_ue *form, pdcch_llr = (int8_t*) phy_vars_ue->pdcch_vars[phy_vars_ue->current_thread_id[subframe]][eNB_id]->llr; pdcch_comp = (int16_t*) phy_vars_ue->pdcch_vars[phy_vars_ue->current_thread_id[subframe]][eNB_id]->rxdataF_comp[0]; pdsch_llr = (int16_t*) phy_vars_ue->pdsch_vars[phy_vars_ue->current_thread_id[subframe]][eNB_id]->llr[0]; // stream 0 - // pdsch_llr = (int16_t*) phy_vars_ue->lte_ue_pdsch_vars_SI[eNB_id]->llr[0]; // stream 0 + //pdsch_llr = (int16_t*) phy_vars_ue->lte_ue_pdsch_vars_SI[eNB_id]->llr[0]; // stream 0 pdsch_comp = (int16_t*) phy_vars_ue->pdsch_vars[phy_vars_ue->current_thread_id[subframe]][eNB_id]->rxdataF_comp0[0]; pdsch_mag = (int16_t*) phy_vars_ue->pdsch_vars[phy_vars_ue->current_thread_id[subframe]][eNB_id]->dl_ch_mag0[0]; diff --git a/openair1/PHY/TOOLS/lte_phy_scope_tm4.c b/openair1/PHY/TOOLS/lte_phy_scope_tm4.c index 5c7322e2e9..d44f8e325b 100644 --- a/openair1/PHY/TOOLS/lte_phy_scope_tm4.c +++ b/openair1/PHY/TOOLS/lte_phy_scope_tm4.c @@ -31,6 +31,7 @@ float tput_enb[NUMBER_OF_UE_MAX][TPUT_WINDOW_LENGTH] = {{0}}; float tput_time_ue[NUMBER_OF_UE_MAX][TPUT_WINDOW_LENGTH] = {{0}}; float tput_ue[NUMBER_OF_UE_MAX][TPUT_WINDOW_LENGTH] = {{0}}; float tput_ue_max[NUMBER_OF_UE_MAX] = {0}; + static void ia_receiver_on_off( FL_OBJECT *button, long arg) { if (fl_get_button(button)) { @@ -43,6 +44,7 @@ static void ia_receiver_on_off( FL_OBJECT *button, long arg) fl_set_object_color(button, FL_RED, FL_RED); } } + static void dl_traffic_on_off( FL_OBJECT *button, long arg) { if (fl_get_button(button)) { @@ -140,6 +142,7 @@ FD_lte_phy_scope_enb *create_lte_phy_scope_enb( void ) fdui->lte_phy_scope_enb->fdui = fdui; return fdui; } + void phy_scope_eNB(FD_lte_phy_scope_enb *form, PHY_VARS_eNB *phy_vars_enb, int UE_id) @@ -325,7 +328,9 @@ void phy_scope_eNB(FD_lte_phy_scope_enb *form, free(bit); free(chest_f_abs); } -FD_lte_phy_scope_ue *create_lte_phy_scope_ue( void ) { + +FD_lte_phy_scope_ue *create_lte_phy_scope_ue( void ) +{ FL_OBJECT *obj; FD_lte_phy_scope_ue *fdui = fl_malloc( sizeof *fdui ); // Define form @@ -429,11 +434,13 @@ FD_lte_phy_scope_ue *create_lte_phy_scope_ue( void ) { fdui->lte_phy_scope_ue->fdui = fdui; return fdui; } + void phy_scope_UE(FD_lte_phy_scope_ue *form, PHY_VARS_UE *phy_vars_ue, int eNB_id, int UE_id, - uint8_t subframe){ + uint8_t subframe) +{ int i,arx,atx,ind,k; LTE_DL_FRAME_PARMS *frame_parms = &phy_vars_ue->frame_parms; int nsymb_ce = frame_parms->ofdm_symbol_size*frame_parms->symbols_per_tti; @@ -492,14 +499,14 @@ void phy_scope_UE(FD_lte_phy_scope_ue *form, if (phy_vars_ue->dlsch[phy_vars_ue->current_thread_id[subframe]][eNB_id][0]!=NULL) { mod0 = get_Qm(mcs0); coded_bits_per_codeword0 = get_G(frame_parms, - phy_vars_ue->dlsch[phy_vars_ue->current_thread_id[subframe]][eNB_id][0]->harq_processes[harq_pid]->nb_rb, - phy_vars_ue->dlsch[phy_vars_ue->current_thread_id[subframe]][eNB_id][0]->harq_processes[harq_pid]->rb_alloc_even, - get_Qm(mcs0), - phy_vars_ue->dlsch[phy_vars_ue->current_thread_id[subframe]][eNB_id][0]->harq_processes[harq_pid]->Nl, - num_pdcch_symbols, - frame, - subframe, - beamforming_mode); + phy_vars_ue->dlsch[phy_vars_ue->current_thread_id[subframe]][eNB_id][0]->harq_processes[harq_pid]->nb_rb, + phy_vars_ue->dlsch[phy_vars_ue->current_thread_id[subframe]][eNB_id][0]->harq_processes[harq_pid]->rb_alloc_even, + get_Qm(mcs0), + phy_vars_ue->dlsch[phy_vars_ue->current_thread_id[subframe]][eNB_id][0]->harq_processes[harq_pid]->Nl, + num_pdcch_symbols, + frame, + subframe, + beamforming_mode); } else { coded_bits_per_codeword0 = 0; //frame_parms->N_RB_DL*12*get_Qm(mcs)*(frame_parms->symbols_per_tti); mod0=0; @@ -507,14 +514,14 @@ void phy_scope_UE(FD_lte_phy_scope_ue *form, if (phy_vars_ue->dlsch[phy_vars_ue->current_thread_id[subframe]][eNB_id][1]!=NULL) { mod1 = get_Qm(mcs1); coded_bits_per_codeword1 = get_G(frame_parms, - phy_vars_ue->dlsch[phy_vars_ue->current_thread_id[subframe]][eNB_id][1]->harq_processes[harq_pid]->nb_rb, - phy_vars_ue->dlsch[phy_vars_ue->current_thread_id[subframe]][eNB_id][1]->harq_processes[harq_pid]->rb_alloc_even, - get_Qm(mcs1), - phy_vars_ue->dlsch[phy_vars_ue->current_thread_id[subframe]][eNB_id][1]->harq_processes[harq_pid]->Nl, - num_pdcch_symbols, - frame, - subframe, - beamforming_mode); + phy_vars_ue->dlsch[phy_vars_ue->current_thread_id[subframe]][eNB_id][1]->harq_processes[harq_pid]->nb_rb, + phy_vars_ue->dlsch[phy_vars_ue->current_thread_id[subframe]][eNB_id][1]->harq_processes[harq_pid]->rb_alloc_even, + get_Qm(mcs1), + phy_vars_ue->dlsch[phy_vars_ue->current_thread_id[subframe]][eNB_id][1]->harq_processes[harq_pid]->Nl, + num_pdcch_symbols, + frame, + subframe, + beamforming_mode); } else { coded_bits_per_codeword1 = 0; //frame_parms->N_RB_DL*12*get_Qm(mcs)*(frame_parms->symbols_per_tti); mod1=0; @@ -526,9 +533,14 @@ void phy_scope_UE(FD_lte_phy_scope_ue *form, chest_t_abs[arx] = (float*) calloc(frame_parms->ofdm_symbol_size,sizeof(float)); } chest_f_abs = (float*) calloc(nsymb_ce*nb_antennas_rx*nb_antennas_tx,sizeof(float)); - llr0 = (float*) calloc(coded_bits_per_codeword0,sizeof(float)); // init to zero + //llr0 = (float*) calloc(coded_bits_per_codeword0,sizeof(float)); // Cppcheck returns "invalidFunctionArg" error. + llr0 = (float*) malloc(coded_bits_per_codeword0*sizeof(float)); + memset((void *)llr0, 0,coded_bits_per_codeword0*sizeof(float)); // init to zero bit0 = malloc(coded_bits_per_codeword0*sizeof(float)); - llr1 = (float*) calloc(coded_bits_per_codeword1,sizeof(float)); // init to zero + + //llr1 = (float*) calloc(coded_bits_per_codeword1,sizeof(float)); // Cppcheck returns "invalidFunctionArg" error. + llr1 = (float*) malloc(coded_bits_per_codeword1*sizeof(float)); + memset((void *)llr1, 0,coded_bits_per_codeword1*sizeof(float)); // init to zero bit1 = malloc(coded_bits_per_codeword1*sizeof(float)); llr_pdcch = (float*) calloc(12*frame_parms->N_RB_DL*num_pdcch_symbols*2,sizeof(float)); // init to zero bit_pdcch = (float*) calloc(12*frame_parms->N_RB_DL*num_pdcch_symbols*2,sizeof(float)); @@ -822,6 +834,4 @@ void phy_scope_UE(FD_lte_phy_scope_ue *form, for (int m=0; mpdsch_vars[subframe&0x1][eNB_id]->llr[0][m]=0; }*/ - } - - +} diff --git a/openair1/PHY/TOOLS/nr_phy_scope.c b/openair1/PHY/TOOLS/nr_phy_scope.c index 8259f0d9c3..7e46b2600f 100644 --- a/openair1/PHY/TOOLS/nr_phy_scope.c +++ b/openair1/PHY/TOOLS/nr_phy_scope.c @@ -23,6 +23,7 @@ #include #include "nr_phy_scope.h" +#include "executables/nr-softmodem-common.h" #define TPUT_WINDOW_LENGTH 100 int otg_enabled; @@ -588,8 +589,8 @@ void phy_scope_nrUE(FD_phy_scope_nrue *form, time = calloc(samples_per_frame,sizeof(float)); corr = calloc(samples_per_frame,sizeof(float)); - chest_t = (int16_t**) phy_vars_ue->pdcch_vars[phy_vars_ue->current_thread_id[subframe]][eNB_id]->dl_ch_estimates_time; - chest_f = (int16_t**) phy_vars_ue->pdcch_vars[phy_vars_ue->current_thread_id[subframe]][eNB_id]->dl_ch_estimates; + chest_t = (int16_t**) phy_vars_ue->pbch_vars[eNB_id]->dl_ch_estimates_time; + chest_f = (int16_t**) phy_vars_ue->pbch_vars[eNB_id]->dl_ch_estimates; pbch_llr = (int16_t*) phy_vars_ue->pbch_vars[eNB_id]->llr; pbch_comp = (int16_t*) phy_vars_ue->pbch_vars[eNB_id]->rxdataF_comp[0]; @@ -696,8 +697,8 @@ void phy_scope_nrUE(FD_phy_scope_nrue *form, if (chest_f[(atx<<1)+arx] != NULL) { for (k=0; kofdm_symbol_size; k++) { freq[ind] = (float)ind; - Re = (float)(chest_f[(atx<<1)+arx][(2*k)]); - Im = (float)(chest_f[(atx<<1)+arx][(2*k)+1]); + Re = (float)(chest_f[(atx<<1)+arx][6144+(2*k)]); + Im = (float)(chest_f[(atx<<1)+arx][6144+(2*k)+1]); chest_f_abs[ind] = (short)10*log10(1.0+((double)Re*Re + (double)Im*Im)); ind++; diff --git a/openair1/PHY/TOOLS/nr_phy_scope.h b/openair1/PHY/TOOLS/nr_phy_scope.h index 37331b511d..770006d234 100644 --- a/openair1/PHY/TOOLS/nr_phy_scope.h +++ b/openair1/PHY/TOOLS/nr_phy_scope.h @@ -29,7 +29,6 @@ #include #include "common/ran_context.h" #include -#include #include #include "PHY/defs_gNB.h" //#include "PHY/defs_nrUE.h" @@ -67,6 +66,11 @@ typedef struct { FL_OBJECT * button_0; } FD_phy_scope_nrue; +typedef struct { + int *argc; + char **argv; +} scopeParms_t; + extern unsigned char scope_enb_num_ue; FD_phy_scope_gnb * create_phy_scope_gnb( void ); FD_phy_scope_nrue * create_phy_scope_nrue( void ); @@ -82,5 +86,10 @@ void phy_scope_nrUE(FD_phy_scope_nrue *form, int eNB_id, int UE_id, uint8_t subframe); + + +void startScope(scopeParms_t * p); + + extern RAN_CONTEXT_t RC; #endif diff --git a/openair1/PHY/defs_common.h b/openair1/PHY/defs_common.h index ce8533a6e8..b71e723740 100644 --- a/openair1/PHY/defs_common.h +++ b/openair1/PHY/defs_common.h @@ -902,39 +902,6 @@ typedef struct THREAD_STRUCT_s { PARALLEL_CONF_t parallel_conf; WORKER_CONF_t worker_conf; } THREAD_STRUCT; -/*extern THREAD_STRUCT thread_struct; - -static inline void set_parallel_conf(char *parallel_conf) { - mapping config[]= { - FOREACH_PARALLEL(GENERATE_ENUMTXT) - {NULL,-1} - }; - thread_struct.parallel_conf = (PARALLEL_CONF_t)map_str_to_int(config, parallel_conf); - if (thread_struct.parallel_conf == -1 ) { - LOG_E(ENB_APP,"Impossible value: %s\n", parallel_conf); - thread_struct.parallel_conf = PARALLEL_SINGLE_THREAD; - } -} - -static inline void set_worker_conf(char *worker_conf) { - mapping config[]={ - FOREACH_WORKER(GENERATE_ENUMTXT) - {NULL, -1} - }; - thread_struct.worker_conf = (WORKER_CONF_t)map_str_to_int(config, worker_conf); - if (thread_struct.worker_conf == -1 ) { - LOG_E(ENB_APP,"Impossible value: %s\n", worker_conf); - thread_struct.worker_conf = WORKER_DISABLE ; - } -} - -static inline PARALLEL_CONF_t get_thread_parallel_conf(void) { - return thread_struct.parallel_conf; -} - -static inline WORKER_CONF_t get_thread_worker_conf(void) { - return thread_struct.worker_conf; -}*/ typedef enum {SF_DL, SF_UL, SF_S} lte_subframe_t; diff --git a/openair1/PHY/defs_gNB.h b/openair1/PHY/defs_gNB.h index cae03f2763..373eca1b9e 100644 --- a/openair1/PHY/defs_gNB.h +++ b/openair1/PHY/defs_gNB.h @@ -377,11 +377,15 @@ typedef struct { /// \brief Hold the channel estimates in time domain based on DRS. /// - first index: rx antenna id [0..nb_antennas_rx[ /// - second index: ? [0..4*ofdm_symbol_size[ - int32_t **drs_ch_estimates_time; + int32_t **ul_ch_estimates_time; /// \brief Hold the channel estimates in frequency domain based on DRS. /// - first index: rx antenna id [0..nb_antennas_rx[ /// - second index: ? [0..12*N_RB_UL*frame_parms->symbols_per_tti[ - int32_t **drs_ch_estimates; + int32_t **ul_ch_estimates; + /// \brief Uplink channel estimates extracted in PRBS. + /// - first index: ? [0..7] (hard coded) FIXME! accessed via \c nb_antennas_rx + /// - second index: ? [0..12*N_RB_UL*frame_parms->symbols_per_tti[ + int32_t **ul_ch_estimates_ext; /// \brief Holds the compensated signal. /// - first index: rx antenna id [0..nb_antennas_rx[ /// - second index: ? [0..12*N_RB_UL*frame_parms->symbols_per_tti[ @@ -394,6 +398,28 @@ typedef struct { /// - first index: rx antenna id [0..nb_antennas_rx[ /// - second index: ? [0..12*N_RB_UL*frame_parms->symbols_per_tti[ int32_t **ul_ch_magb; + /// \brief Cross-correlation of two UE signals. + /// - first index: rx antenna [0..nb_antennas_rx[ + /// - second index: symbol [0..] + int32_t **rho; + /// \f$\log_2(\max|H_i|^2)\f$ + int16_t log2_maxh; + /// \brief Magnitude of Uplink Channel first layer (16QAM level/First 64QAM level). + /// - first index: ? [0..7] (hard coded) FIXME! accessed via \c nb_antennas_rx + /// - second index: ? [0..168*N_RB_UL[ + int32_t **ul_ch_mag0; + /// \brief Magnitude of Uplink Channel second layer (16QAM level/First 64QAM level). + /// - first index: ? [0..7] (hard coded) FIXME! accessed via \c nb_antennas_rx + /// - second index: ? [0..168*N_RB_UL[ + int32_t **ul_ch_mag1[8][8]; + /// \brief Magnitude of Uplink Channel, first layer (2nd 64QAM level). + /// - first index: ? [0..7] (hard coded) FIXME! accessed via \c nb_antennas_rx + /// - second index: ? [0..168*N_RB_UL[ + int32_t **ul_ch_magb0; + /// \brief Magnitude of Uplink Channel second layer (2nd 64QAM level). + /// - first index: ? [0..7] (hard coded) FIXME! accessed via \c nb_antennas_rx + /// - second index: ? [0..168*N_RB_UL[ + int32_t **ul_ch_magb1[8][8]; /// measured RX power based on DRS int ulsch_power[2]; /// \brief llr values. @@ -654,6 +680,9 @@ typedef struct PHY_VARS_gNB_s { /// PDSCH DMRS sequence uint32_t ****nr_gold_pdsch_dmrs; + + /// PUSCH DMRS + uint32_t nr_gold_pusch[2][20][2][NR_MAX_PUSCH_DMRS_INIT_LENGTH_DWORD]; /// Indicator set to 0 after first SR uint8_t first_sr[NUMBER_OF_UE_MAX]; diff --git a/openair1/PHY/defs_nr_UE.h b/openair1/PHY/defs_nr_UE.h index b4b9ff00c0..2d73aafa3c 100644 --- a/openair1/PHY/defs_nr_UE.h +++ b/openair1/PHY/defs_nr_UE.h @@ -810,6 +810,10 @@ typedef struct { /// - first index: ? [0..7] (hard coded) FIXME! accessed via \c nb_antennas_rx /// - second index: ? [0..287] (hard coded) int32_t **dl_ch_estimates_ext; + /// \brief Hold the channel estimates in time domain (used for tracking). + /// - first index: ? [0..7] (hard coded) FIXME! accessed via \c nb_antennas_rx + /// - second index: samples? [0..2*ofdm_symbol_size[ + int32_t **dl_ch_estimates_time; int log2_maxh; uint8_t pbch_a[NR_POLAR_PBCH_PAYLOAD_BITS>>3]; uint32_t pbch_a_interleaved; diff --git a/openair1/PHY/defs_nr_common.h b/openair1/PHY/defs_nr_common.h index 1cc8ccd69f..41509e65c1 100644 --- a/openair1/PHY/defs_nr_common.h +++ b/openair1/PHY/defs_nr_common.h @@ -239,7 +239,7 @@ typedef struct NR_DL_FRAME_PARMS { /// Total Number of Resource Block Groups SubSets: this is P uint8_t N_RBGS; /// EUTRA Band - uint8_t eutra_band; + uint16_t eutra_band; /// DL carrier frequency uint32_t dl_CarrierFreq; /// UL carrier frequency diff --git a/openair1/PHY/impl_defs_top.h b/openair1/PHY/impl_defs_top.h index 1f7eb2aa44..a4607d3106 100644 --- a/openair1/PHY/impl_defs_top.h +++ b/openair1/PHY/impl_defs_top.h @@ -208,6 +208,7 @@ /// First Amplitude for QAM16 (\f$ 2^{15} \times 2/\sqrt{10}\f$) #define QAM16_n1 20724 + /// Second Amplitude for QAM16 (\f$ 2^{15} \times 1/\sqrt{10}\f$) #define QAM16_n2 10362 diff --git a/openair1/SCHED/phy_procedures_lte_eNb.c b/openair1/SCHED/phy_procedures_lte_eNb.c index 12f7c856b4..c0afdf25d1 100644 --- a/openair1/SCHED/phy_procedures_lte_eNb.c +++ b/openair1/SCHED/phy_procedures_lte_eNb.c @@ -1134,6 +1134,7 @@ void pusch_procedures(PHY_VARS_eNB *eNB,L1_rxtx_proc_t *proc) { const int subframe = proc->subframe_rx; const int frame = proc->frame_rx; uint32_t harq_pid0 = subframe2harq_pid(&eNB->frame_parms,frame,subframe); + int rvidx_tab[4] = {0,2,3,1}; for (i = 0; i < NUMBER_OF_UE_MAX; i++) { ulsch = eNB->ulsch[i]; @@ -1150,8 +1151,8 @@ void pusch_procedures(PHY_VARS_eNB *eNB,L1_rxtx_proc_t *proc) { if ((ulsch) && (ulsch->rnti>0) && (ulsch_harq->status == ACTIVE) && - (ulsch_harq->frame == frame) && - (ulsch_harq->subframe == subframe) && + ((ulsch_harq->frame == frame) || (ulsch_harq->repetition_number >1) ) && + ((ulsch_harq->subframe == subframe) || (ulsch_harq->repetition_number >1) ) && (ulsch_harq->handled == 0)) { // UE has ULSCH scheduling for (int rb=0; @@ -1208,6 +1209,10 @@ void pusch_procedures(PHY_VARS_eNB *eNB,L1_rxtx_proc_t *proc) { ulsch_harq->cqi_crc_status, ulsch_harq->O_ACK, eNB->ulsch_decoding_stats.p_time, eNB->ulsch_decoding_stats.max); + if (ulsch_harq->repetition_number < ulsch_harq->total_number_of_repetitions){ + ulsch_harq->rvidx = rvidx_tab[(ulsch_harq->repetition_number%4)] ; // Set the correct rvidx for the next emtc repetitions + ulsch_harq->repetition_number +=1 ; // Increment repetition_number for the next ULSCH allocation + } //compute the expected ULSCH RX power (for the stats) ulsch_harq->delta_TF = get_hundred_times_delta_IF_eNB(eNB,i,harq_pid, 0); // 0 means bw_factor is not considered @@ -1263,7 +1268,7 @@ void pusch_procedures(PHY_VARS_eNB *eNB,L1_rxtx_proc_t *proc) { */ ulsch_harq->handled = 1; } // ulsch in error - else { + else if(ulsch_harq->repetition_number == ulsch_harq->total_number_of_repetitions){ fill_crc_indication(eNB,i,frame,subframe,0); // indicate ACK to MAC fill_rx_indication(eNB,i,frame,subframe); // indicate SDU to MAC ulsch_harq->status = SCH_IDLE; diff --git a/openair1/SCHED_NR/fapi_nr_l1.c b/openair1/SCHED_NR/fapi_nr_l1.c index dfe3527f9e..836a061356 100644 --- a/openair1/SCHED_NR/fapi_nr_l1.c +++ b/openair1/SCHED_NR/fapi_nr_l1.c @@ -54,6 +54,44 @@ void handle_nr_nfapi_bch_pdu(PHY_VARS_gNB *gNB, // adjust transmit amplitude here based on NFAPI info } +/*void handle_nr_nfapi_dlsch_pdu(PHY_VARS_gNB *gNB,int frame,int subframe,gNB_L1_rxtx_proc_t *proc, + uint8_t codeword_index, + uint8_t *sdu) +{ + + int UE_id = 0; //Hardcode UE_id for now + int harq_pid; + + NR_gNB_DLSCH_t *dlsch0=NULL, *dlsch1=NULL; + NR_DL_gNB_HARQ_t *dlsch0_harq=NULL,*dlsch1_harq=NULL; + + // Based on nr_fill_dci_and_dlsch only gNB->dlsch[0][0] gets filled now. So maybe we do not need dlsch1. + dlsch0 = gNB->dlsch[UE_id][0]; + dlsch1 = gNB->dlsch[UE_id][1]; + + harq_pid = dlsch0->harq_ids[subframe]; + dlsch0_harq = dlsch0->harq_processes[harq_pid]; + dlsch1_harq = dlsch1->harq_processes[harq_pid]; + + + //if (dlsch0_harq->round==0) { //get pointer to SDU if this a new SDU + if(sdu == NULL) { + LOG_E(PHY,"NFAPI: SFN/SF:%04d%d proc:TX:[frame %d subframe %d]: programming dlsch for round 0 \n", + frame,subframe, + proc->frame_tx,proc->slot_tx); + return; + } + //AssertFatal(sdu!=NULL,"NFAPI: SFN/SF:%04d%d proc:TX:[frame %d subframe %d]: programming dlsch for round 0, rnti %x, UE_id %d, harq_pid %d : sdu is null for pdu_index %d dlsch0_harq[round:%d SFN/SF:%d%d pdu:%p mcs:%d ndi:%d pdschstart:%d]\n", + // frame,subframe, + // proc->frame_tx,proc->subframe_tx,rel8->rnti,UE_id,harq_pid, + // dl_config_pdu->dlsch_pdu.dlsch_pdu_rel8.pdu_index,dlsch0_harq->round,dlsch0_harq->frame,dlsch0_harq->subframe,dlsch0_harq->pdu,dlsch0_harq->mcs,dlsch0_harq->ndi,dlsch0_harq->pdsch_start); + if (codeword_index == 0) dlsch0_harq->pdu = sdu; + else dlsch1_harq->pdu = sdu; + LOG_I(PHY, "SFN/SF: %d/%d DLSCH PDU filled \n",frame, subframe); +// } + +}*/ + void handle_nfapi_nr_dci_dl_pdu(PHY_VARS_gNB *gNB, int frame, int slot, @@ -155,7 +193,7 @@ void nr_schedule_response(NR_Sched_Rsp_t *Sched_INFO){ } } } - + if (nfapi_mode && do_oai && !dont_send) { oai_nfapi_tx_req(Sched_INFO->TX_req); diff --git a/openair1/SCHED_NR/fapi_nr_l1.h b/openair1/SCHED_NR/fapi_nr_l1.h index 9157ca1632..51169660bf 100644 --- a/openair1/SCHED_NR/fapi_nr_l1.h +++ b/openair1/SCHED_NR/fapi_nr_l1.h @@ -36,10 +36,13 @@ #include "nfapi_nr_interface.h" void nr_schedule_response(NR_Sched_Rsp_t *Sched_INFO); + void handle_nfapi_nr_dci_dl_pdu(PHY_VARS_gNB *gNB, int frame, int subframe, nfapi_nr_dl_config_dci_dl_pdu *dcl_dl_pdu); + void handle_nr_nfapi_dlsch_pdu(PHY_VARS_gNB *gNB,int frame,int slot, nfapi_nr_dl_config_dlsch_pdu *dlsch_pdu, uint8_t *sdu); +void nr_fill_rx_indication(PHY_VARS_gNB *gNB, int frame, int slot_rx, int UE_id, uint8_t harq_pid); diff --git a/openair1/SCHED_NR/nr_ru_procedures.c b/openair1/SCHED_NR/nr_ru_procedures.c index 0f348a9189..e8203c3c12 100644 --- a/openair1/SCHED_NR/nr_ru_procedures.c +++ b/openair1/SCHED_NR/nr_ru_procedures.c @@ -34,7 +34,7 @@ #include "PHY/phy_extern.h" #include "sched_nr.h" #include "PHY/MODULATION/modulation_common.h" - +#include "PHY/MODULATION/nr_modulation.h" #include "PHY/LTE_TRANSPORT/if4_tools.h" #include "PHY/LTE_TRANSPORT/if5_tools.h" @@ -249,12 +249,184 @@ void nr_feptx_ofdm(RU_t *ru,int frame_tx,int tti_tx) { } -void nr_feprx(RU_t *ru) { - +/* // PRACH component int frame=ru->proc.frame_rx, slot=ru->proc.tti_rx; if (do_prach_rx(ru->nr_frame_parms,frame,slot)) rx_nr_prach_ru(ru, frame, slot/ru->nr_frame_parms->slots_per_subframe); +*/ + +void nr_fep0(RU_t *ru, int first_half) { + + uint8_t start_symbol, end_symbol, l, aa; + RU_proc_t *proc = &ru->proc; + NR_DL_FRAME_PARMS *fp = ru->nr_frame_parms; + + if(first_half == 1) { + start_symbol = 0; + end_symbol = NR_SYMBOLS_PER_SLOT/2; + } else { + start_symbol = NR_SYMBOLS_PER_SLOT/2; + end_symbol = NR_SYMBOLS_PER_SLOT; + } + + LOG_D(PHY,"In fep0 for slot = %d, first_half = %d, start_symbol = %d, end_symbol = %d\n", proc->tti_rx, first_half, start_symbol, end_symbol); + // printf("fep0: slot %d\n",slot); + + VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_PHY_PROCEDURES_RU_FEPRX+proc->tti_rx, 1); + + // remove_7_5_kHz(ru,(slot&1)+(proc->tti_rx<<1)); + for (l = start_symbol; l < end_symbol; l++) { + for (aa = 0; aa < fp->nb_antennas_rx; aa++) { + nr_slot_fep_ul(fp, + ru->common.rxdata[aa], + ru->common.rxdataF[aa], + l, + proc->tti_rx, + 0, + 0); + } + } + VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_PHY_PROCEDURES_RU_FEPRX+proc->tti_rx, 0); +} + + +static void *nr_feprx_thread(void *param) { + + RU_t *ru = (RU_t *)param; + RU_proc_t *proc = &ru->proc; + + + while (!oai_exit) { + + if (wait_on_condition(&proc->mutex_fep,&proc->cond_fep,&proc->instance_cnt_fep,"NR feprx thread")<0) break; + + if (oai_exit) break; + + VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME( VCD_SIGNAL_DUMPER_FUNCTIONS_PHY_PROCEDURES_RU_FEPRX1, 1 ); + + nr_fep0(ru, 0); + + VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME( VCD_SIGNAL_DUMPER_FUNCTIONS_PHY_PROCEDURES_RU_FEPRX1, 0 ); + + if (release_thread(&proc->mutex_fep,&proc->instance_cnt_fep,"nr_feprx thread")<0) break; + + if (pthread_cond_signal(&proc->cond_fep) != 0) { + printf("[gNB] ERROR pthread_cond_signal for nr_feprx thread exit\n"); + exit_fun( "ERROR pthread_cond_signal" ); + return NULL; + } + } + + return NULL; +} + + +void nr_init_feprx_thread(RU_t *ru) { + + RU_proc_t *proc = &ru->proc; + + proc->instance_cnt_fep = -1; + + pthread_mutex_init( &proc->mutex_fep, NULL); + pthread_cond_init( &proc->cond_fep, NULL); + + threadCreate(&proc->pthread_fep, nr_feprx_thread, (void*)ru, "feprx", -1, OAI_PRIORITY_RT); +} + + +void nr_fep_full_2thread(RU_t *ru, int slot) { + + RU_proc_t *proc = &ru->proc; + + struct timespec wait; + + // NR_DL_FRAME_PARMS *fp = ru->nr_frame_parms; + + // if ((fp->frame_type == TDD) && + // (subframe_select(fp,proc->tti_rx) != SF_UL)) return; + + if (ru->idx == 0) VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME( VCD_SIGNAL_DUMPER_FUNCTIONS_PHY_PROCEDURES_RU_FEPRX, 1 ); + + wait.tv_sec=0; + wait.tv_nsec=5000000L; + + VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME( VCD_SIGNAL_DUMPER_FUNCTIONS_PHY_PROCEDURES_RU_FEPRX, 1 ); + start_meas(&ru->ofdm_demod_stats); + + if (pthread_mutex_timedlock(&proc->mutex_fep,&wait) != 0) { + printf("[RU] ERROR pthread_mutex_lock for nr_feprx thread (IC %d)\n", proc->instance_cnt_fep); + exit_fun( "error locking mutex_fep" ); + return; + } + + if (proc->instance_cnt_fep==0) { + printf("[RU] FEP thread busy\n"); + exit_fun("FEP thread busy"); + pthread_mutex_unlock( &proc->mutex_fep ); + return; + } + + ++proc->instance_cnt_fep; + + + if (pthread_cond_signal(&proc->cond_fep) != 0) { + printf("[RU] ERROR pthread_cond_signal for nr_feprx thread\n"); + exit_fun( "ERROR pthread_cond_signal" ); + return; + } + //start_meas(&ru->ofdm_demod_wakeup_stats); + + pthread_mutex_unlock( &proc->mutex_fep ); + + // call second slot in this symbol + nr_fep0(ru, 1); + + start_meas(&ru->ofdm_demod_wait_stats); + wait_on_busy_condition(&proc->mutex_fep,&proc->cond_fep,&proc->instance_cnt_fep,"nr_feprx thread"); + stop_meas(&ru->ofdm_demod_wait_stats); + if(opp_enabled == 1 && ru->ofdm_demod_wakeup_stats.p_time>30*3000){ + print_meas_now(&ru->ofdm_demod_wakeup_stats,"fep wakeup",stderr); + printf("delay in fep wait on codition in frame_rx: %d subframe_rx: %d \n",proc->frame_rx,proc->tti_rx); + } + + stop_meas(&ru->ofdm_demod_stats); + VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME( VCD_SIGNAL_DUMPER_FUNCTIONS_PHY_PROCEDURES_RU_FEPRX, 0 ); +} + + + +void nr_fep_full(RU_t *ru, int slot) { + + RU_proc_t *proc = &ru->proc; + int l, aa; + NR_DL_FRAME_PARMS *fp = ru->nr_frame_parms; + + // if ((fp->frame_type == TDD) && + // (subframe_select(fp,proc->tti_rx) != SF_UL)) return; + + start_meas(&ru->ofdm_demod_stats); + if (ru->idx == 0) VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME( VCD_SIGNAL_DUMPER_FUNCTIONS_PHY_PROCEDURES_RU_FEPRX, 1 ); + + // remove_7_5_kHz(ru,proc->tti_rx<<1); + // remove_7_5_kHz(ru,1+(proc->tti_rx<<1)); + + for (l = 0; l < fp->symbols_per_slot; l++) { + for (aa = 0; aa < fp->nb_antennas_rx; aa++) { + nr_slot_fep_ul(fp, + ru->common.rxdata[aa], + ru->common.rxdataF[aa], + l, + proc->tti_rx, + 0, + 0); + } + } + + if (ru->idx == 0) VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME( VCD_SIGNAL_DUMPER_FUNCTIONS_PHY_PROCEDURES_RU_FEPRX, 0 ); + stop_meas(&ru->ofdm_demod_stats); + + } diff --git a/openair1/SCHED_NR/phy_procedures_nr_common.c b/openair1/SCHED_NR/phy_procedures_nr_common.c index 97891f9db9..6ef1cff6f1 100755 --- a/openair1/SCHED_NR/phy_procedures_nr_common.c +++ b/openair1/SCHED_NR/phy_procedures_nr_common.c @@ -31,4 +31,6 @@ */ #include "sched_nr.h" +#include "PHY/INIT/phy_init.h" + diff --git a/openair1/SCHED_NR/phy_procedures_nr_gNB.c b/openair1/SCHED_NR/phy_procedures_nr_gNB.c index 79e27fdaec..55748b9cb6 100644 --- a/openair1/SCHED_NR/phy_procedures_nr_gNB.c +++ b/openair1/SCHED_NR/phy_procedures_nr_gNB.c @@ -26,10 +26,13 @@ #include "PHY/NR_TRANSPORT/nr_transport_proto.h" #include "PHY/NR_TRANSPORT/nr_dlsch.h" #include "PHY/NR_TRANSPORT/nr_ulsch.h" +#include "PHY/NR_ESTIMATION/nr_ul_estimation.h" #include "SCHED/sched_eNB.h" +#include "sched_nr.h" #include "SCHED/sched_common_extern.h" -#include "nfapi_interface.h" -#include "SCHED/fapi_l1.h" +#include "nfapi/open-nFAPI/nfapi/public_inc/nfapi_interface.h" +#include "nfapi/open-nFAPI/nfapi/public_inc/nfapi_nr_interface.h" +#include "fapi_nr_l1.h" #include "common/utils/LOG/log.h" #include "common/utils/LOG/vcd_signal_dumper.h" #include "PHY/INIT/phy_init.h" @@ -211,6 +214,7 @@ void phy_procedures_gNB_TX(PHY_VARS_gNB *gNB, } + /* if ((cfg->subframe_config.duplex_mode.value == TDD) && @@ -222,8 +226,8 @@ void phy_procedures_gNB_TX(PHY_VARS_gNB *gNB, if (do_prach_rx(fp,frame,slot)) L1_nr_prach_procedures(gNB,frame,slot/fp->slots_per_subframe); */ -void nr_ulsch_procedures(PHY_VARS_gNB *gNB, gNB_L1_rxtx_proc_t *proc, int ULSCH_id, uint8_t harq_pid) { - +void nr_ulsch_procedures(PHY_VARS_gNB *gNB, int frame_rx, int slot_rx, int UE_id, uint8_t harq_pid) +{ NR_DL_FRAME_PARMS *frame_parms = &gNB->frame_parms; nfapi_nr_ul_config_ulsch_pdu *rel15_ul = &gNB->ulsch[ULSCH_id+1][0]->harq_processes[harq_pid]->ulsch_pdu; nfapi_nr_ul_config_ulsch_pdu_rel15_t *nfapi_ulsch_pdu_rel15 = &rel15_ul->ulsch_pdu_rel15; @@ -258,9 +262,9 @@ void nr_ulsch_procedures(PHY_VARS_gNB *gNB, gNB_L1_rxtx_proc_t *proc, int ULSCH_ ULSCH_id, gNB->pusch_vars[ULSCH_id]->llr, frame_parms, - proc->frame_rx, + frame_rx, nfapi_ulsch_pdu_rel15->number_symbols, - proc->slot_rx, + slot_rx, harq_pid, 0); @@ -270,7 +274,74 @@ void nr_ulsch_procedures(PHY_VARS_gNB *gNB, gNB_L1_rxtx_proc_t *proc, int ULSCH_ } -void phy_procedures_gNB_common_RX(PHY_VARS_gNB *gNB, gNB_L1_rxtx_proc_t *proc) { +void nr_fill_rx_indication(PHY_VARS_gNB *gNB, int frame, int slot_rx, int UE_id, uint8_t harq_pid) +{ + // -------------------- + // [hna] TO BE CLEANED + // -------------------- + + // nfapi_rx_indication_pdu_t *pdu; + + int timing_advance_update; + int sync_pos; + + // pthread_mutex_lock(&gNB->UL_INFO_mutex); + + // gNB->UL_INFO.rx_ind.sfn_sf = frame<<4| slot_rx; + // gNB->UL_INFO.rx_ind.rx_indication_body.tl.tag = NFAPI_RX_INDICATION_BODY_TAG; + + // pdu = &gNB->UL_INFO.rx_ind.rx_indication_body.rx_pdu_list[gNB->UL_INFO.rx_ind.rx_indication_body.number_of_pdus]; + + // pdu->rx_ue_information.handle = gNB->ulsch[UE_id+1][0]->handle; + // pdu->rx_ue_information.tl.tag = NFAPI_RX_UE_INFORMATION_TAG; + // pdu->rx_ue_information.rnti = gNB->ulsch[UE_id+1][0]->rnti; + // pdu->rx_indication_rel8.tl.tag = NFAPI_RX_INDICATION_REL8_TAG; + // pdu->rx_indication_rel8.length = gNB->ulsch[UE_id+1][0]->harq_processes[harq_pid]->TBS>>3; + // pdu->rx_indication_rel8.offset = 1; // DJP - I dont understand - but broken unless 1 ???? 0; // filled in at the end of the UL_INFO formation + // pdu->data = gNB->ulsch[UE_id+1][0]->harq_processes[harq_pid]->b; + // estimate timing advance for MAC + sync_pos = nr_est_timing_advance_pusch(gNB, UE_id); + timing_advance_update = sync_pos; // - gNB->frame_parms.nb_prefix_samples/4; //to check + // printf("\x1B[33m" "timing_advance_update = %d\n" "\x1B[0m", timing_advance_update); + + switch (gNB->frame_parms.N_RB_DL) { + // case 6: /* nothing to do */ break; + // case 15: timing_advance_update /= 2; break; + // case 25: timing_advance_update /= 4; break; + // case 50: timing_advance_update /= 8; break; + // case 75: timing_advance_update /= 12; break; + case 106: timing_advance_update /= 16; break; + case 217: timing_advance_update /= 32; break; + default: abort(); + } + + // put timing advance command in 0..63 range + timing_advance_update += 31; + + if (timing_advance_update < 0) timing_advance_update = 0; + if (timing_advance_update > 63) timing_advance_update = 63; + + // pdu->rx_indication_rel8.timing_advance = timing_advance_update; + + // estimate UL_CQI for MAC (from antenna port 0 only) + // int SNRtimes10 = dB_fixed_times10(gNB->pusch_vars[UE_id]->ulsch_power[0]) - 300;//(10*gNB->measurements.n0_power_dB[0]); + + // if (SNRtimes10 < -640) pdu->rx_indication_rel8.ul_cqi=0; + // else if (SNRtimes10 > 635) pdu->rx_indication_rel8.ul_cqi=255; + // else pdu->rx_indication_rel8.ul_cqi=(640+SNRtimes10)/5; + + // LOG_D(PHY,"[PUSCH %d] Frame %d Subframe %d Filling RX_indication with SNR %d (%d), timing_advance %d (update %d)\n", + // harq_pid,frame,slot_rx,SNRtimes10,pdu->rx_indication_rel8.ul_cqi,pdu->rx_indication_rel8.timing_advance, + // timing_advance_update); + + // gNB->UL_INFO.rx_ind.rx_indication_body.number_of_pdus++; + // gNB->UL_INFO.rx_ind.sfn_sf = frame<<4 | slot_rx; + + // pthread_mutex_unlock(&gNB->UL_INFO_mutex); +} + + +void phy_procedures_gNB_common_RX(PHY_VARS_gNB *gNB, int frame_rx, int slot_rx) { uint8_t symbol; unsigned char aa; @@ -282,7 +353,7 @@ void phy_procedures_gNB_common_RX(PHY_VARS_gNB *gNB, gNB_L1_rxtx_proc_t *proc) { gNB->common_vars.rxdata[aa], gNB->common_vars.rxdataF[aa], symbol, - proc->slot_rx, + slot_rx, 0, 0); } @@ -291,24 +362,18 @@ void phy_procedures_gNB_common_RX(PHY_VARS_gNB *gNB, gNB_L1_rxtx_proc_t *proc) { } -void phy_procedures_gNB_uespec_RX(PHY_VARS_gNB *gNB, gNB_L1_rxtx_proc_t *proc, uint8_t symbol_start, uint8_t symbol_end) { +void phy_procedures_gNB_uespec_RX(PHY_VARS_gNB *gNB, int frame_rx, int slot_rx, uint8_t symbol_start, uint8_t symbol_end) { uint8_t ULSCH_id; uint8_t symbol; uint8_t harq_pid = 0; // [hna] Previously in LTE, the harq_pid was obtained from the subframe number (Synchronous HARQ) // In NR, this should be signaled through uplink scheduling dci (i.e, DCI 0_0, 0_1) (Asynchronous HARQ) - for (ULSCH_id = 0; ULSCH_id < NUMBER_OF_NR_ULSCH_MAX; ULSCH_id++) { - + for (ULSCH_id = 0; ULSCH_id < /*NUMBER_OF_NR_ULSCH_MAX*/1; ULSCH_id++) { // temporary set to 1 untill list of connected UEs is implemented for(symbol = symbol_start; symbol < symbol_end; symbol++) { - - nr_rx_pusch(gNB, ULSCH_id, proc->frame_rx, proc->slot_rx, symbol, harq_pid); - + nr_rx_pusch(gNB, UE_id, frame_rx, slot_rx, symbol, harq_pid); } - - nr_ulsch_procedures(gNB, proc, ULSCH_id, harq_pid); - + nr_ulsch_procedures(gNB, frame_rx, slot_rx, ULSCH_id, harq_pid); + nr_fill_rx_indication(gNB, frame_rx, slot_rx, ULSCH_id, harq_pid); // indicate SDU to MAC } - - } diff --git a/openair1/SCHED_NR/sched_nr.h b/openair1/SCHED_NR/sched_nr.h index 3f4c1b6f6d..f26890abb0 100644 --- a/openair1/SCHED_NR/sched_nr.h +++ b/openair1/SCHED_NR/sched_nr.h @@ -37,14 +37,16 @@ void nr_set_ssb_first_subcarrier(nfapi_nr_config_request_t *cfg, NR_DL_FRAME_PARMS *fp); void phy_procedures_gNB_TX(PHY_VARS_gNB *gNB, int frame_tx, int slot_tx, int do_meas); -void phy_procedures_gNB_common_RX(PHY_VARS_gNB *gNB, gNB_L1_rxtx_proc_t *proc); -void phy_procedures_gNB_uespec_RX(PHY_VARS_gNB *gNB, gNB_L1_rxtx_proc_t *proc, uint8_t symbol_start, uint8_t symbol_end); +void phy_procedures_gNB_common_RX(PHY_VARS_gNB *gNB, int frame_rx, int slot_rx); +void phy_procedures_gNB_uespec_RX(PHY_VARS_gNB *gNB, int frame_rx, int slot_rx, uint8_t symbol_start, uint8_t symbol_end); void nr_common_signal_procedures (PHY_VARS_gNB *gNB,int frame, int slot); void nr_feptx_ofdm(RU_t *ru,int frame_tx,int tti_tx); void nr_feptx_ofdm_2thread(RU_t *ru,int frame_tx,int tti_tx); void nr_feptx0(RU_t *ru,int tti_tx,int first_symbol, int num_symbols); void nr_init_feptx_thread(RU_t *ru); -void fep_full(RU_t *ru,int slot); +void nr_init_feprx_thread(RU_t *ru); +void nr_fep_full(RU_t *ru, int slot); +void nr_fep_full_2thread(RU_t *ru, int slot); void feptx_prec(RU_t *ru,int frame_tx,int tti_tx); int nr_phy_init_RU(RU_t *ru); diff --git a/openair1/SCHED_NR_UE/defs.h b/openair1/SCHED_NR_UE/defs.h index 7b6c16b97d..63fa1c2c3b 100644 --- a/openair1/SCHED_NR_UE/defs.h +++ b/openair1/SCHED_NR_UE/defs.h @@ -373,7 +373,7 @@ void nr_compute_srs_pos(lte_frame_type_t frameType,uint16_t isrs,uint16_t *psrsP void set_tx_harq_id(NR_UE_ULSCH_t *ulsch, int harq_pid, int slot_tx); int get_tx_harq_id(NR_UE_ULSCH_t *ulsch, int slot_tx); - +int is_pbch_in_slot(fapi_nr_pbch_config_t *pbch_config, int frame, int slot, int periodicity, uint16_t slots_per_frame); /*@}*/ diff --git a/openair1/SCHED_NR_UE/fapi_nr_ue_l1.c b/openair1/SCHED_NR_UE/fapi_nr_ue_l1.c index 120e26aa31..910718e081 100644 --- a/openair1/SCHED_NR_UE/fapi_nr_ue_l1.c +++ b/openair1/SCHED_NR_UE/fapi_nr_ue_l1.c @@ -123,6 +123,7 @@ int8_t nr_ue_scheduled_response(nr_scheduled_response_t *scheduled_response) dlsch0_harq->harq_ack.pucch_resource_indicator = dlsch_config_pdu->pucch_resource_id; dlsch0_harq->harq_ack.slot_for_feedback_ack = dlsch_config_pdu->pdsch_to_harq_feedback_time_ind; dlsch0_harq->Nl=1; + dlsch0_harq->mcs_table=0; dlsch0_harq->status = ACTIVE; LOG_D(MAC,">>>> \tdlsch0->g_pucch=%d\tdlsch0_harq.mcs=%d\n",dlsch0->g_pucch,dlsch0_harq->mcs); diff --git a/openair1/SCHED_NR_UE/phy_procedures_nr_ue.c b/openair1/SCHED_NR_UE/phy_procedures_nr_ue.c index 9758e1bc3e..0304515f4f 100644 --- a/openair1/SCHED_NR_UE/phy_procedures_nr_ue.c +++ b/openair1/SCHED_NR_UE/phy_procedures_nr_ue.c @@ -2464,53 +2464,28 @@ void ue_pucch_procedures(PHY_VARS_NR_UE *ue,UE_nr_rxtx_proc_t *proc,uint8_t eNB_ void phy_procedures_nrUE_TX(PHY_VARS_NR_UE *ue, - UE_nr_rxtx_proc_t *proc, - uint8_t gNB_id, - uint8_t thread_id) + UE_nr_rxtx_proc_t *proc, + uint8_t gNB_id, + uint8_t thread_id) { - //NR_DL_FRAME_PARMS *frame_parms=&ue->frame_parms; - NR_UE_ULSCH_t *ulsch_ue; - NR_UL_UE_HARQ_t *harq_process_ul_ue; //int32_t ulsch_start=0; int slot_tx = proc->nr_tti_tx; int frame_tx = proc->frame_tx; - int harq_pid, i, TBS; VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_PHY_PROCEDURES_UE_TX,VCD_FUNCTION_IN); - LOG_D(PHY,"****** start TX-Chain for AbsSubframe %d.%d ******\n", frame_tx, slot_tx); + LOG_I(PHY,"****** start TX-Chain for AbsSubframe %d.%d ******\n", frame_tx, slot_tx); #if UE_TIMING_TRACE start_meas(&ue->phy_proc_tx); #endif - - harq_pid = 0; //temporary implementation - - /* - generate_ue_ulsch_params(ue, - 0, - gNB_id, - harq_pid); - */ - - ulsch_ue = ue->ulsch[thread_id][gNB_id][0]; // cwd_index = 0 - harq_process_ul_ue = ulsch_ue->harq_processes[harq_pid]; - - TBS = nr_compute_tbs( harq_process_ul_ue->mcs, harq_process_ul_ue->nb_rb, ulsch_ue->Nsymb_pusch, ulsch_ue->nb_re_dmrs, ulsch_ue->length_dmrs, harq_process_ul_ue->Nl); - -//-----------------------------------------------------// - // to be removed later when MAC is ready - - for (i = 0; i < TBS / 8; i++) - harq_process_ul_ue->a[i] = (unsigned char) rand(); - -//-----------------------------------------------------// + uint8_t harq_pid = 0; //temporary implementation nr_ue_ulsch_procedures(ue, harq_pid, slot_tx, - 0, + thread_id, gNB_id); @@ -2525,11 +2500,14 @@ void phy_procedures_nrUE_TX(PHY_VARS_NR_UE *ue, nr_ue_pusch_common_procedures(ue, + harq_pid, slot_tx, - harq_process_ul_ue->Nl, + thread_id, + gNB_id, &ue->frame_parms); + /* if ((ue->UE_mode[eNB_id] == PRACH) && (ue->frame_parms.prach_config_common.prach_Config_enabled==1)) { @@ -2546,7 +2524,7 @@ void phy_procedures_nrUE_TX(PHY_VARS_NR_UE *ue, } */ - LOG_D(PHY,"****** end TX-Chain for AbsSubframe %d.%d ******\n", frame_tx, slot_tx); + LOG_I(PHY,"****** end TX-Chain for AbsSubframe %d.%d ******\n", frame_tx, slot_tx); VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_PHY_PROCEDURES_UE_TX, VCD_FUNCTION_OUT); #if UE_TIMING_TRACE @@ -3044,7 +3022,7 @@ int nr_ue_pdcch_procedures(uint8_t eNB_id, &format_found, crc_scrambled_values); #ifdef NR_PDCCH_SCHED_DEBUG - printf("<-NR_PDCCH_PHY_PROCEDURES_LTE_UE (nr_ue_pdcch_procedures)-> Ending function nr_dci_decoding_procedure() -> dci_cnt=%d\n",dci_cnt); + printf("<-NR_PDCCH_PHY_PROCEDURES_LTE_UE (nr_ue_pdcch_procedures)-> Ending function nr_dci_decoding_procedure() -> dci_cnt=%u\n",dci_cnt); #endif VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_DCI_DECODING, VCD_FUNCTION_OUT); @@ -3329,7 +3307,7 @@ void copy_harq_proc_struct(NR_DL_UE_HARQ_t *harq_processes_dest, NR_DL_UE_HARQ_t harq_processes_dest->B = current_harq_processes->B ; harq_processes_dest->C = current_harq_processes->C ; - harq_processes_dest->DCINdi = current_harq_processes->DCINdi ; + harq_processes_dest->DCINdi = current_harq_processes->DCINdi ; harq_processes_dest->F = current_harq_processes->F ; harq_processes_dest->G = current_harq_processes->G ; harq_processes_dest->K = current_harq_processes->K ; @@ -3342,6 +3320,7 @@ void copy_harq_proc_struct(NR_DL_UE_HARQ_t *harq_processes_dest, NR_DL_UE_HARQ_t harq_processes_dest->dl_power_off = current_harq_processes->dl_power_off ; harq_processes_dest->first_tx = current_harq_processes->first_tx ; harq_processes_dest->mcs = current_harq_processes->mcs ; + harq_processes_dest->mcs_table = current_harq_processes->mcs_table ; harq_processes_dest->mimo_mode = current_harq_processes->mimo_mode ; harq_processes_dest->nb_rb = current_harq_processes->nb_rb ; harq_processes_dest->pmi_alloc = current_harq_processes->pmi_alloc ; @@ -3406,7 +3385,7 @@ void nr_ue_pdsch_procedures(PHY_VARS_NR_UE *ue, UE_nr_rxtx_proc_t *proc, int eNB first_symbol_flag = 0; #if UE_TIMING_TRACE uint8_t slot = 0; - if(m >= ue->frame_parms.symbols_per_tti>>1) + if(m >= ue->frame_parms.symbols_per_slot>>1) slot = 1; start_meas(&ue->dlsch_llr_stats_parallelization[ue->current_thread_id[nr_tti_rx]][slot]); #endif @@ -3553,10 +3532,15 @@ void nr_ue_dlsch_procedures(PHY_VARS_NR_UE *ue, NR_UE_PDSCH *pdsch_vars; uint8_t is_cw0_active = 0; uint8_t is_cw1_active = 0; + uint8_t nb_re_dmrs = 6; //(dmrs_type==NFAPI_NR_DMRS_TYPE1)?6:4; + nr_downlink_indication_t dl_indication; + fapi_nr_rx_indication_t rx_ind; + if (dlsch0==NULL) AssertFatal(0,"dlsch0 should be defined at this level \n"); + harq_pid = dlsch0->current_harq_pid; is_cw0_active = dlsch0->harq_processes[harq_pid]->status; uint16_t nb_symb_sch = dlsch0->harq_processes[harq_pid]->nb_symbols; @@ -3574,6 +3558,8 @@ void nr_ue_dlsch_procedures(PHY_VARS_NR_UE *ue, // uint16_t nb_symb_sch = dl_config_pdu->nb_symbols; // AssertFatal(nb_symb_sch >= 1 && nb_symb_sch <= 14,"Illegal nb_symb_sch %d\n",nb_symb_sch); + + if(dlsch1) is_cw1_active = dlsch1->harq_processes[harq_pid]->status; @@ -3797,6 +3783,33 @@ void nr_ue_dlsch_procedures(PHY_VARS_NR_UE *ue, } LOG_D(PHY," ------ end ldpc decoder for AbsSubframe %d.%d ------ \n", frame_rx, nr_tti_rx); + + LOG_I(PHY, "harq_pid: %d, TBS expected dlsch0: %d, TBS expected dlsch1: %d \n",harq_pid, dlsch0->harq_processes[harq_pid]->TBS, dlsch1->harq_processes[harq_pid]->TBS); + + if(retmax_ldpc_iterations+1){ + // fill dl_indication message + dl_indication.module_id = ue->Mod_id; + dl_indication.cc_id = ue->CC_id; + dl_indication.gNB_index = eNB_id; + dl_indication.frame = frame_rx; + dl_indication.slot = nr_tti_rx; + + dl_indication.rx_ind = &rx_ind; // hang on rx_ind instance + dl_indication.proc=proc; + + //dl_indication.rx_ind->number_pdus + rx_ind.rx_indication_body[0].pdu_type = FAPI_NR_RX_PDU_TYPE_DLSCH; + rx_ind.rx_indication_body[0].pdsch_pdu.pdu = dlsch0->harq_processes[harq_pid]->b; + rx_ind.rx_indication_body[0].pdsch_pdu.pdu_length = dlsch0->harq_processes[harq_pid]->TBS>>3; + LOG_D(PHY, "PDU length in bits: %d, in bytes: %d \n", dlsch0->harq_processes[harq_pid]->TBS, rx_ind.rx_indication_body[0].pdsch_pdu.pdu_length); + rx_ind.number_pdus = 1; + + //ue->dl_indication.rx_ind = &dlsch1->harq_processes[harq_pid]->b; //no data, only dci for now + dl_indication.dci_ind = NULL; //&ue->dci_ind; + // send to mac + if (ue->if_inst && ue->if_inst->dl_indication) + ue->if_inst->dl_indication(&dl_indication); + } } @@ -3907,7 +3920,7 @@ void *UE_thread_slot1_dl_processing(void *arg) { 0); */ // 1- perform FFT - for (int l=1; lframe_parms.symbols_per_tti>>1; l++) + for (int l=1; lframe_parms.symbols_per_slot>>1; l++) { //if( (l != pilot0) && (l != pilot1)) { @@ -3939,7 +3952,7 @@ void *UE_thread_slot1_dl_processing(void *arg) { } // 2- perform Channel Estimation for slot1 - for (int l=1; lframe_parms.symbols_per_tti>>1; l++) + for (int l=1; lframe_parms.symbols_per_slot>>1; l++) { if(l == pilot1) { @@ -4029,8 +4042,8 @@ void *UE_thread_slot1_dl_processing(void *arg) { PDSCH, ue->dlsch[ue->current_thread_id[nr_tti_rx]][eNB_id][0], NULL, - (ue->frame_parms.symbols_per_tti>>1), - ue->frame_parms.symbols_per_tti-1, + (ue->frame_parms.symbols_per_slot>>1), + ue->frame_parms.symbols_per_slot-1, abstraction_flag); LOG_D(PHY," ------ end PDSCH ChannelComp/LLR slot 0: AbsSubframe %d.%d ------ \n", frame_rx%1024, nr_tti_rx); LOG_D(PHY," ------ --> PDSCH Turbo Decoder slot 0/1: AbsSubframe %d.%d ------ \n", frame_rx%1024, nr_tti_rx); @@ -4044,8 +4057,8 @@ void *UE_thread_slot1_dl_processing(void *arg) { SI_PDSCH, ue->dlsch_SI[eNB_id], NULL, - (ue->frame_parms.symbols_per_tti>>1), - ue->frame_parms.symbols_per_tti-1, + (ue->frame_parms.symbols_per_slot>>1), + ue->frame_parms.symbols_per_slot-1, abstraction_flag); } @@ -4057,8 +4070,8 @@ void *UE_thread_slot1_dl_processing(void *arg) { P_PDSCH, ue->dlsch_p[eNB_id], NULL, - (ue->frame_parms.symbols_per_tti>>1), - ue->frame_parms.symbols_per_tti-1, + (ue->frame_parms.symbols_per_slot>>1), + ue->frame_parms.symbols_per_slot-1, abstraction_flag); } // do procedures for RA-RNTI @@ -4069,8 +4082,8 @@ void *UE_thread_slot1_dl_processing(void *arg) { RA_PDSCH, ue->dlsch_ra[eNB_id], NULL, - (ue->frame_parms.symbols_per_tti>>1), - ue->frame_parms.symbols_per_tti-1, + (ue->frame_parms.symbols_per_slot>>1), + ue->frame_parms.symbols_per_slot-1, abstraction_flag); } @@ -4133,13 +4146,9 @@ fapi_nr_dl_config_bch_pdu *is_pbch_in_slot(fapi_nr_dl_config_request_t *DLconfig } - int phy_procedures_nrUE_RX(PHY_VARS_NR_UE *ue,UE_nr_rxtx_proc_t *proc,uint8_t eNB_id, uint8_t do_pdcch_flag,runmode_t mode, fapi_nr_dl_config_request_t *DLconfigreq) { - - - int frame_rx = proc->frame_rx; int nr_tti_rx = proc->nr_tti_rx; NR_UE_PDCCH *pdcch_vars = ue->pdcch_vars[ue->current_thread_id[nr_tti_rx]][0]; @@ -4147,6 +4156,7 @@ int phy_procedures_nrUE_RX(PHY_VARS_NR_UE *ue,UE_nr_rxtx_proc_t *proc,uint8_t eN uint8_t harq_pid = ue->dlsch[ue->current_thread_id[nr_tti_rx]][eNB_id][0]->current_harq_pid; NR_DL_UE_HARQ_t *dlsch0_harq = dlsch[0]->harq_processes[harq_pid]; uint16_t nb_symb_sch = dlsch0_harq->nb_symbols; + uint16_t start_symb_sch = dlsch0_harq->start_symbol; uint8_t nb_symb_pdcch = pdcch_vars->coreset[0].duration; uint8_t ssb_periodicity = 10;// ue->ssb_periodicity; // initialized to 5ms in nr_init_ue for scenarios where UE is not configured (otherwise acquired by cell configuration from gNB or LTE) uint8_t dci_cnt = 0; @@ -4173,6 +4183,43 @@ int phy_procedures_nrUE_RX(PHY_VARS_NR_UE *ue,UE_nr_rxtx_proc_t *proc,uint8_t eN } uint16_t coreset_nb_rb = 6 * coreset_count; uint16_t coreset_start_rb = 6 * coreset_start; + + slot_pbch = is_pbch_in_slot(pbch_config, frame_rx, nr_tti_rx, ssb_periodicity, ue->frame_parms.slots_per_frame); + + // looking for pbch only in slot where it is supposed to be + if ((ue->decode_MIB == 1) && slot_pbch) + { + LOG_I(PHY," ------ PBCH ChannelComp/LLR: frame.slot %d.%d ------ \n", frame_rx%1024, nr_tti_rx); + + for (int i=1; i<4; i++) { + + nr_slot_fep(ue, + (ue->symbol_offset+i)%(ue->frame_parms.symbols_per_slot), + nr_tti_rx, + 0, + 0); + +#if UE_TIMING_TRACE + start_meas(&ue->dlsch_channel_estimation_stats); +#endif + nr_pbch_channel_estimation(ue,0,nr_tti_rx,(ue->symbol_offset+i)%(ue->frame_parms.symbols_per_slot),i-1,(pbch_config->ssb_index)&7,pbch_config->half_frame_bit); +#if UE_TIMING_TRACE + stop_meas(&ue->dlsch_channel_estimation_stats); +#endif + + } + nr_ue_pbch_procedures(eNB_id,ue,proc,0); + + if (ue->no_timing_correction==0) { + LOG_I(PHY,"start adjust sync slot = %d no timing %d\n", nr_tti_rx, ue->no_timing_correction); + nr_adjust_synch_ue(&ue->frame_parms, + ue, + eNB_id, + nr_tti_rx, + 0, + 16384); + } + } #ifdef NR_PDCCH_SCHED nr_gold_pdcch(ue, 0, 2); @@ -4212,16 +4259,7 @@ int phy_procedures_nrUE_RX(PHY_VARS_NR_UE *ue,UE_nr_rxtx_proc_t *proc,uint8_t eN if (dci_cnt > 0) { LOG_I(PHY,"[UE %d] Frame %d, nr_tti_rx %d: found %d DCIs\n",ue->Mod_id,frame_rx,nr_tti_rx,dci_cnt); - - if (ue->no_timing_correction==0) { - LOG_D(PHY,"start adjust sync slot = %d no timing %d\n", nr_tti_rx, ue->no_timing_correction); - nr_adjust_synch_ue(&ue->frame_parms, - ue, - eNB_id, - nr_tti_rx, - 0, - 16384); - } + } else { LOG_D(PHY,"[UE %d] Frame %d, nr_tti_rx %d: No DCIs found\n",ue->Mod_id,frame_rx,nr_tti_rx); } @@ -4231,11 +4269,12 @@ int phy_procedures_nrUE_RX(PHY_VARS_NR_UE *ue,UE_nr_rxtx_proc_t *proc,uint8_t eN if (dci_cnt > 0){ LOG_D(PHY," ------ --> PDSCH ChannelComp/LLR Frame.slot %d.%d ------ \n", frame_rx%1024, nr_tti_rx); //to update from pdsch config - nr_gold_pdsch(ue,nb_symb_pdcch,0, 1); + start_symb_sch = dlsch0_harq->start_symbol; + nr_gold_pdsch(ue,start_symb_sch,0, 1); nb_symb_sch = dlsch0_harq->nb_symbols; - for (uint16_t m=nb_symb_pdcch;m<=(nb_symb_sch+nb_symb_pdcch-1) ; m++){ + for (uint16_t m=start_symb_sch;m<(nb_symb_sch+start_symb_sch) ; m++){ nr_slot_fep(ue, m, //to be updated from higher layer nr_tti_rx, @@ -4247,7 +4286,7 @@ int phy_procedures_nrUE_RX(PHY_VARS_NR_UE *ue,UE_nr_rxtx_proc_t *proc,uint8_t eN //set active for testing, to be removed ue->dlsch[ue->current_thread_id[nr_tti_rx]][eNB_id][0]->active = 1; } - else + else ue->dlsch[ue->current_thread_id[nr_tti_rx]][eNB_id][0]->active = 0; #if UE_TIMING_TRACE @@ -4347,6 +4386,7 @@ int phy_procedures_nrUE_RX(PHY_VARS_NR_UE *ue,UE_nr_rxtx_proc_t *proc,uint8_t eN // do procedures for C-RNTI if (ue->dlsch[ue->current_thread_id[nr_tti_rx]][eNB_id][0]->active == 1) { + LOG_I(PHY, "DLSCH data reception at nr_tti_rx: %d \n \n", nr_tti_rx); VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_PDSCH_PROC, VCD_FUNCTION_IN); #if UE_TIMING_TRACE diff --git a/openair1/SCHED_NR_UE/pucch_uci_ue_nr.c b/openair1/SCHED_NR_UE/pucch_uci_ue_nr.c index 93059c00e0..21886418b0 100644 --- a/openair1/SCHED_NR_UE/pucch_uci_ue_nr.c +++ b/openair1/SCHED_NR_UE/pucch_uci_ue_nr.c @@ -922,7 +922,7 @@ boolean_t select_pucch_resource(PHY_VARS_NR_UE *ue, uint8_t gNB_id, int uci_size /* a valid resource has already be found outside this function */ resource_set_found = TRUE; ready_pucch_resource_id = TRUE; - pucch_resource_indicator = pucch_resource_indicator; + //pucch_resource_indicator = pucch_resource_indicator; } if (resource_set_found == TRUE) { diff --git a/openair1/SIMULATION/LTE_PHY/dlsim.c b/openair1/SIMULATION/LTE_PHY/dlsim.c index d04403d43c..6706b0f912 100644 --- a/openair1/SIMULATION/LTE_PHY/dlsim.c +++ b/openair1/SIMULATION/LTE_PHY/dlsim.c @@ -35,38 +35,30 @@ #include #include #include - -#include "SIMULATION/TOOLS/sim.h" +#include "common/config/config_load_configmodule.h" +#include "common/utils/LOG/log.h" +#include "LAYER2/MAC/mac_vars.h" +#include "nfapi/oai_integration/vendor_ext.h" #include "PHY/types.h" #include "PHY/defs_eNB.h" #include "PHY/defs_UE.h" #include "PHY/phy_vars.h" - -#include "SCHED/sched_eNB.h" -#include "SCHED/sched_common_vars.h" -#include "LAYER2/MAC/mac_vars.h" - -#include "OCG_vars.h" -#include "common/utils/LOG/log.h" -#include "UTIL/LISTS/list.h" - -#include "unitary_defs.h" - - -#include "PHY/TOOLS/lte_phy_scope.h" - -#include "dummy_functions.c" - +#include "PHY/INIT/phy_init.h" +#include "PHY/LTE_TRANSPORT/transport_proto.h" +#include "PHY/LTE_UE_TRANSPORT/transport_proto_ue.h" #include "PHY/MODULATION/modulation_common.h" #include "PHY/MODULATION/modulation_eNB.h" #include "PHY/MODULATION/modulation_UE.h" -#include "PHY/LTE_TRANSPORT/transport_proto.h" -#include "PHY/LTE_UE_TRANSPORT/transport_proto_ue.h" +#include "PHY/TOOLS/lte_phy_scope.h" #include "SCHED/sched_eNB.h" +#include "SCHED/sched_common_vars.h" #include "SCHED_UE/sched_UE.h" -#include "common/config/config_load_configmodule.h" -#include "PHY/INIT/phy_init.h" -#include "nfapi/oai_integration/vendor_ext.h" +#include "SIMULATION/TOOLS/sim.h" +#include "UTIL/LISTS/list.h" +#include "OCG_vars.h" +#include "unitary_defs.h" +#include "dummy_functions.c" +#include "executables/thread-common.h" void feptx_ofdm(RU_t *ru, int frame, int subframe); void feptx_prec(RU_t *ru, int frame, int subframe); @@ -85,30 +77,6 @@ double t_rx_min = 1000000000; /*!< \brief initial min process time for rx */ int n_tx_dropped = 0; /*!< \brief initial max process time for tx */ int n_rx_dropped = 0; /*!< \brief initial max process time for rx */ -//THREAD_STRUCT thread_struct; -static THREAD_STRUCT thread_struct; - -void set_parallel_conf(char *parallel_conf) { - if(strcmp(parallel_conf,"PARALLEL_SINGLE_THREAD")==0) thread_struct.parallel_conf = PARALLEL_SINGLE_THREAD; - else if(strcmp(parallel_conf,"PARALLEL_RU_L1_SPLIT")==0) thread_struct.parallel_conf = PARALLEL_RU_L1_SPLIT; - else if(strcmp(parallel_conf,"PARALLEL_RU_L1_TRX_SPLIT")==0) thread_struct.parallel_conf = PARALLEL_RU_L1_TRX_SPLIT; - - printf("[CONFIG] parallel conf is set to %d\n",thread_struct.parallel_conf); -} -void set_worker_conf(char *worker_conf) { - if(strcmp(worker_conf,"WORKER_DISABLE")==0) thread_struct.worker_conf = WORKER_DISABLE; - else if(strcmp(worker_conf,"WORKER_ENABLE")==0) thread_struct.worker_conf = WORKER_ENABLE; - - printf("[CONFIG] worker conf is set to %d\n",thread_struct.worker_conf); -} -PARALLEL_CONF_t get_thread_parallel_conf(void) { - return thread_struct.parallel_conf; -} -WORKER_CONF_t get_thread_worker_conf(void) { - return thread_struct.worker_conf; -} - - int emulate_rf = 0; void handler(int sig) { @@ -122,8 +90,6 @@ void handler(int sig) { exit(1); } - - //DCI2_5MHz_2A_M10PRB_TDD_t DLSCH_alloc_pdu2_2A[2]; DCI1E_5MHz_2A_M10PRB_TDD_t DLSCH_alloc_pdu2_1E[2]; diff --git a/openair1/SIMULATION/LTE_PHY/syncsim.c b/openair1/SIMULATION/LTE_PHY/syncsim.c index 2c0385efbf..80598b37e4 100644 --- a/openair1/SIMULATION/LTE_PHY/syncsim.c +++ b/openair1/SIMULATION/LTE_PHY/syncsim.c @@ -58,7 +58,7 @@ #define BW 5.0 -PHY_VARS_eNB *PHY_vars_eNB,*PHY_vars_eNB1,*PHY_vars_eNB2; +PHY_VARS_eNB *PHY_vars_eNB, *PHY_vars_eNB1, *PHY_vars_eNB2; PHY_VARS_UE *PHY_vars_UE[2]; #define DLSCH_RB_ALLOC 0x1fff // igore DC component,RB13 @@ -699,7 +699,7 @@ int main(int argc, char **argv) { bzero(txdataF2[0],FRAME_LENGTH_BYTES_NO_PREFIX); bzero(txdataF2[1],FRAME_LENGTH_BYTES_NO_PREFIX); #else - txdata = PHY_vars_eNB->lte_eNB_common_vars.txdata[eNb_id]; + txdata = PHY_vars_eNB->common_vars.txdataF[eNb_id]; txdata1 = PHY_vars_eNB1->lte_eNB_common_vars.txdata[eNb_id]; txdata2 = PHY_vars_eNB2->lte_eNB_common_vars.txdata[eNb_id]; #endif diff --git a/openair1/SIMULATION/LTE_PHY/ulsim.c b/openair1/SIMULATION/LTE_PHY/ulsim.c index be69e96897..db97240ed5 100644 --- a/openair1/SIMULATION/LTE_PHY/ulsim.c +++ b/openair1/SIMULATION/LTE_PHY/ulsim.c @@ -33,30 +33,28 @@ #include #include #include -#include "SIMULATION/TOOLS/sim.h" +#include "LAYER2/MAC/mac_vars.h" #include "PHY/types.h" #include "PHY/defs_common.h" #include "PHY/defs_eNB.h" #include "PHY/defs_UE.h" #include "PHY/phy_vars.h" -#include "targets/RT/USER/lte-softmodem.h" - +#include "PHY/INIT/phy_init.h" +#include "PHY/LTE_TRANSPORT/transport_proto.h" +#include "PHY/LTE_UE_TRANSPORT/transport_proto_ue.h" +#include "PHY/TOOLS/lte_phy_scope.h" #include "SCHED/sched_common_vars.h" #include "SCHED/sched_eNB.h" #include "SCHED_UE/sched_UE.h" -#include "LAYER2/MAC/mac_vars.h" +#include "SIMULATION/TOOLS/sim.h" #include "OCG_vars.h" - -#include "PHY/LTE_TRANSPORT/transport_proto.h" -#include "PHY/LTE_UE_TRANSPORT/transport_proto_ue.h" -#include "PHY/INIT/phy_init.h" - #include "unitary_defs.h" - -#include "PHY/TOOLS/lte_phy_scope.h" #include "dummy_functions.c" #include "nfapi/oai_integration/vendor_ext.h" #include "common/config/config_load_configmodule.h" +#include "executables/thread-common.h" +#include "targets/RT/USER/lte-softmodem.h" + double cpuf; #define inMicroS(a) (((double)(a))/(cpu_freq_GHz*1000.0)) //#define MCS_COUNT 23//added for PHY abstraction @@ -96,7 +94,6 @@ nfapi_tx_request_pdu_t tx_pdu_list[MAX_NUM_TX_REQUEST_PDU]; nfapi_tx_request_t TX_req; Sched_Rsp_t sched_resp; -THREAD_STRUCT thread_struct; void fill_nfapi_ulsch_config_request(nfapi_ul_config_request_pdu_t *ul_config_pdu, diff --git a/openair1/SIMULATION/NR_PHY/dlschsim.c b/openair1/SIMULATION/NR_PHY/dlschsim.c index f4956529a8..e6fcaadef6 100644 --- a/openair1/SIMULATION/NR_PHY/dlschsim.c +++ b/openair1/SIMULATION/NR_PHY/dlschsim.c @@ -53,8 +53,11 @@ PHY_VARS_gNB *gNB; PHY_VARS_NR_UE *UE; RAN_CONTEXT_t RC; +int32_t uplink_frequency_offset[MAX_NUM_CCs][4]; + double cpuf; int nfapi_mode = 0; +uint16_t NB_UE_INST = 1; int oai_nfapi_hi_dci0_req(nfapi_hi_dci0_request_t *hi_dci0_req) { return (0); @@ -146,6 +149,7 @@ int main(int argc, char **argv) uint16_t nb_symb_sch = 12; uint16_t nb_rb = 50; uint8_t Imcs = 9; + uint8_t mcs_table = 0; cpuf = get_cpu_freq_GHz(); @@ -465,6 +469,7 @@ int main(int argc, char **argv) uint8_t nb_re_dmrs = 6; uint16_t length_dmrs = 1; unsigned char mod_order; + uint16_t rate; uint8_t Nl = 1; uint8_t rvidx = 0; dlsch->rnti = 1; @@ -472,16 +477,18 @@ int main(int argc, char **argv) dlsch->harq_processes[0]->rvidx = rvidx;*/ //printf("dlschsim harqid %d nb_rb %d, mscs %d\n",dlsch->harq_ids[subframe], // dlsch->harq_processes[0]->nb_rb,dlsch->harq_processes[0]->mcs,dlsch->harq_processes[0]->Nl); - mod_order = nr_get_Qm(Imcs, 1); + mod_order = nr_get_Qm_dl(Imcs, mcs_table); + rate = nr_get_code_rate_dl(Imcs, mcs_table); available_bits = nr_get_G(nb_rb, nb_symb_sch, nb_re_dmrs, length_dmrs, mod_order, 1); - TBS = nr_compute_tbs(Imcs, nb_rb, nb_symb_sch, nb_re_dmrs, length_dmrs, Nl); - printf("available bits %d TBS %d mod_order %d\n", available_bits, TBS, mod_order); + TBS = nr_compute_tbs(mod_order,rate, nb_rb, nb_symb_sch, nb_re_dmrs*length_dmrs, 0, Nl); + printf("available bits %u TBS %u mod_order %d\n", available_bits, TBS, mod_order); //dlsch->harq_ids[subframe]= 0; rel15->n_prb = nb_rb; rel15->nb_symbols = nb_symb_sch; rel15->modulation_order = mod_order; rel15->nb_layers = Nl; rel15->transport_block_size = TBS; + rel15->coding_rate = rate; double *modulated_input = malloc16(sizeof(double) * 16 * 68 * 384); // [hna] 16 segments, 68*Zc short *channel_output_fixed = malloc16(sizeof(short) * 16 * 68 * 384); short *channel_output_uncoded = malloc16(sizeof(unsigned short) * 16 * 68 * 384); @@ -496,10 +503,12 @@ int main(int argc, char **argv) NR_UE_DLSCH_t *dlsch0_ue = UE->dlsch[0][0][0]; NR_DL_UE_HARQ_t *harq_process = dlsch0_ue->harq_processes[harq_pid]; harq_process->mcs = Imcs; + harq_process->mcs_table = mcs_table; harq_process->Nl = Nl; harq_process->nb_rb = nb_rb; harq_process->Qm = mod_order; harq_process->rvidx = rvidx; + harq_process->R = rate; printf("harq process ue mcs = %d Qm = %d, symb %d\n", harq_process->mcs, harq_process->Qm, nb_symb_sch); unsigned char *test_input; test_input = (unsigned char *) malloc16(sizeof(unsigned char) * TBS / 8); @@ -510,7 +519,7 @@ int main(int argc, char **argv) //estimated_output = harq_process->b; #ifdef DEBUG_NR_DLSCHSIM - for (i = 0; i < TBS / 8; i++) printf("test_input[i]=%d \n",test_input[i]); + for (i = 0; i < TBS / 8; i++) printf("test_input[i]=%hhu \n",test_input[i]); #endif /*for (int i=0; i 0) { n_false_positive++; if (n_trials == 1) - printf("errors_bit %d (trial %d)\n", errors_bit, trial); + printf("errors_bit %u (trial %d)\n", errors_bit, trial); } } diff --git a/openair1/SIMULATION/NR_PHY/dlsim.c b/openair1/SIMULATION/NR_PHY/dlsim.c index 09f2034d10..88c0c33397 100644 --- a/openair1/SIMULATION/NR_PHY/dlsim.c +++ b/openair1/SIMULATION/NR_PHY/dlsim.c @@ -66,6 +66,8 @@ PHY_VARS_gNB *gNB; PHY_VARS_NR_UE *UE; RAN_CONTEXT_t RC; +int32_t uplink_frequency_offset[MAX_NUM_CCs][4]; + double cpuf; int sf_ahead=4; @@ -105,10 +107,13 @@ int8_t nr_mac_rrc_data_ind_ue(const module_id_t module_id, } +uint16_t NB_UE_INST = 1; + //Dummy Functions lte_subframe_t subframe_select(LTE_DL_FRAME_PARMS *frame_parms, unsigned char subframe) {return(SF_DL);} int rlc_module_init (void) {return(0);} + void pdcp_layer_init(void) {} int rrc_init_nr_global_param(void){return(0);} @@ -116,6 +121,59 @@ void config_common(int Mod_idP, NR_ServingCellConfigCommon_t *scc ); +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);} +uint64_t get_softmodem_optmask(void) {return 0;} +mac_rlc_status_resp_t mac_rlc_status_ind( const module_id_t module_idP, const rnti_t rntiP, + const eNB_index_t eNB_index, const frame_t frameP, + const sub_frame_t subframeP, const eNB_flag_t enb_flagP, + const MBMS_flag_t MBMS_flagP, const logical_chan_id_t channel_idP, + const tb_size_t tb_sizeP + #if (LTE_RRC_VERSION >= MAKE_VERSION(14, 0, 0)) + ,const uint32_t sourceL2Id + ,const uint32_t destinationL2Id + #endif + ){mac_rlc_status_resp_t mac_rlc_status_resp; return mac_rlc_status_resp;} +tbs_size_t mac_rlc_data_req( + const module_id_t module_idP, + const rnti_t rntiP, + const eNB_index_t eNB_index, + const frame_t frameP, + const eNB_flag_t enb_flagP, + const MBMS_flag_t MBMS_flagP, + const logical_chan_id_t channel_idP, + const tb_size_t tb_sizeP, + char *buffer_pP +#if (LTE_RRC_VERSION >= MAKE_VERSION(14, 0, 0)) + ,const uint32_t sourceL2Id + ,const uint32_t destinationL2Id +#endif + ) +{return 0;} +int generate_dlsch_header(unsigned char *mac_header, + unsigned char num_sdus, + unsigned short *sdu_lengths, + unsigned char *sdu_lcids, + unsigned char drx_cmd, + unsigned short timing_advance_cmd, + unsigned char *ue_cont_res_id, + unsigned char short_padding, + unsigned short post_padding){return 0;} +void nr_ip_over_LTE_DRB_preconfiguration(void){} +void mac_rlc_data_ind ( + const module_id_t module_idP, + const rnti_t rntiP, + const eNB_index_t eNB_index, + const frame_t frameP, + const eNB_flag_t enb_flagP, + const MBMS_flag_t MBMS_flagP, + const logical_chan_id_t channel_idP, + char *buffer_pP, + const tb_size_t tb_sizeP, + num_tb_t num_tbP, + crc_t *crcs_pP) +{} + // needed for some functions openair0_config_t openair0_cfg[MAX_CARDS]; @@ -305,7 +363,7 @@ int main(int argc, char **argv) { char c; int i,aa;//,l; - double sigma2, sigma2_dB=10,SNR,snr0=-2.0,snr1=2.0; + double sigma2, sigma2_dB=10, SNR, snr0=-2.0, snr1=2.0; uint8_t snr1set=0; int **txdata; double **s_re,**s_im,**r_re,**r_im; @@ -340,6 +398,12 @@ int main(int argc, char **argv) //double pbch_sinr; //int pbch_tx_ant; int N_RB_DL=106,mu=1; + nfapi_nr_dl_config_dlsch_pdu_rel15_t dlsch_config; + dlsch_config.start_prb = 0; + dlsch_config.n_prb = 50; + dlsch_config.start_symbol = 2; + dlsch_config.nb_symbols = 9; + dlsch_config.mcs_idx = 9; uint16_t ssb_periodicity = 10; @@ -361,6 +425,7 @@ int main(int argc, char **argv) int run_initial_sync=0; int do_pdcch_flag=1; + uint16_t cset_offset = 0; int loglvl=OAILOG_WARNING; float target_error_rate = 0.01; @@ -374,7 +439,10 @@ int main(int argc, char **argv) randominit(0); + while ((c = getopt (argc, argv, "f:hA:pf:g:i:j:n:s:S:t:x:y:z:M:N:F:GR:dP:IL:E")) != -1) { + + while ((c = getopt (argc, argv, "f:hA:pf:g:i:j:n:s:S:t:x:y:z:M:N:F:GR:dP:IL:Eo:a:b:c:j:e:")) != -1) { switch (c) { /*case 'f': write_output_file=1; @@ -539,9 +607,36 @@ int main(int argc, char **argv) loglvl = atoi(optarg); break; + case 'E': css_flag=1; break; + + case 'o': + cset_offset = atoi(optarg); + break; + + case 'a': + dlsch_config.start_prb = atoi(optarg); + break; + + case 'b': + dlsch_config.n_prb = atoi(optarg); + break; + + case 'c': + dlsch_config.start_symbol = atoi(optarg); + break; + + case 'j': + dlsch_config.nb_symbols = atoi(optarg); + break; + + case 'e': + dlsch_config.mcs_idx = atoi(optarg); + break; + + default: case 'h': printf("%s -h(elp) -p(extended_prefix) -N cell_id -f output_filename -F input_filename -g channel_model -n n_frames -t Delayspread -s snr0 -S snr1 -x transmission_mode -y TXant -z RXant -i Intefrence0 -j Interference1 -A interpolation_file -C(alibration offset dB) -N CellId\n", @@ -568,6 +663,12 @@ int main(int argc, char **argv) //printf("-f Output filename (.txt format) for Pe/SNR results\n"); printf("-F Input filename (.txt format) for RX conformance testing\n"); printf("-E used CSS scheduler\n"); + printf("-o CORESET offset\n"); + printf("-a Start PRB for PDSCH\n"); + printf("-b Number of PRB for PDSCH\n"); + printf("-c Start symbol for PDSCH (fixed for now)\n"); + printf("-j Number of symbols for PDSCH (fixed for now)\n"); + printf("-e MSC index\n"); exit (-1); break; } @@ -705,7 +806,7 @@ int main(int argc, char **argv) printf("Allocating %d samples for txdata\n",frame_length_complex_samples); txdata[i] = malloc(frame_length_complex_samples*sizeof(int)); - bzero(r_re[i],frame_length_complex_samples*sizeof(int)); + bzero(txdata[i],frame_length_complex_samples*sizeof(int)); } @@ -764,14 +865,17 @@ int main(int argc, char **argv) test_input_bit = (unsigned char *) malloc16(sizeof(unsigned char) * 16 * 68 * 384); estimated_output_bit = (unsigned char *) malloc16(sizeof(unsigned char) * 16 * 68 * 384); + uint16_t rb_offset_count = cset_offset/6; + set_cset_offset(rb_offset_count); // generate signal if (input_fd==NULL) { gNB->pbch_configured = 1; for (int i=0;i<4;i++) gNB->pbch_pdu[i]=i+1; - if (css_flag == 0) nr_schedule_uss_dlsch_phytest(0,frame,slot); + if (css_flag == 0) nr_schedule_uss_dlsch_phytest(0,frame,slot,&dlsch_config); else nr_schedule_css_dlsch_phytest(0,frame,slot); + Sched_INFO.module_id = 0; Sched_INFO.CC_id = 0; Sched_INFO.frame = frame; @@ -863,13 +967,15 @@ int main(int argc, char **argv) uint64_t mask = 0x0; uint16_t num_rbs=24; - uint16_t rb_offset=0; + uint16_t rb_offset=gNB->pdcch_vars.dci_alloc[0].pdcch_params.rb_offset; uint16_t cell_id=0; uint16_t num_symbols=2; for(i=0; i<(num_rbs/6); ++i){ // 38.331 Each bit corresponds a group of 6 RBs mask = mask >> 1; mask = mask | 0x100000000000; } + uint16_t UE_rb_offset_count = rb_offset/6; + mask = mask >> UE_rb_offset_count; dl_config->dl_config_list[0].dci_config_pdu.dci_config_rel15.coreset.frequency_domain_resource = mask; dl_config->dl_config_list[0].dci_config_pdu.dci_config_rel15.coreset.rb_offset = rb_offset; // additional parameter other than coreset @@ -880,8 +986,6 @@ int main(int argc, char **argv) dl_config->dl_config_list[0].dci_config_pdu.dci_config_rel15.coreset.cce_reg_interleaved_shift_index = cell_id; dl_config->dl_config_list[0].dci_config_pdu.dci_config_rel15.coreset.precoder_granularity = PRECODER_GRANULARITY_SAME_AS_REG_BUNDLE; dl_config->dl_config_list[0].dci_config_pdu.dci_config_rel15.coreset.pdcch_dmrs_scrambling_id = cell_id; - uint8_t gnb_start_symbol = Sched_INFO.DL_req->dl_config_request_body.dl_config_pdu_list[1].dlsch_pdu.dlsch_pdu_rel15.start_symbol; - dl_config->dl_config_list[0].dlsch_config_pdu.dlsch_config_rel15.start_symbol = gnb_start_symbol; uint32_t number_of_search_space_per_slot=1; uint32_t first_symbol_index=0; @@ -917,8 +1021,10 @@ int main(int argc, char **argv) //n_errors2 = 0; //n_alamouti = 0; + n_false_positive = 0; for (trial = 0; trial < n_trials; trial++) { + errors_bit = 0; //multipath channel //multipath_channel(gNB2UE,s_re,s_im,r_re,r_im,frame_length_complex_samples,0); @@ -1010,7 +1116,8 @@ int main(int argc, char **argv) } - if (UE_mac->dl_config_request.number_pdus == 0) + if (UE->dlsch[UE->current_thread_id[slot]][0][0]->last_iteration_cnt >= + UE->dlsch[UE->current_thread_id[slot]][0][0]->max_ldpc_iterations+1) n_errors++; //---------------------------------------------------------- @@ -1037,7 +1144,7 @@ int main(int argc, char **argv) available_bits = nr_get_G(nb_rb, nb_symb_sch, nb_re_dmrs, length_dmrs, mod_order, rel15.nb_layers); printf("\n"); - printf("available_bits = %d\n",available_bits); + printf("available_bits = %u\n", available_bits); for (i = 0; i < available_bits; i++) { @@ -1076,7 +1183,7 @@ int main(int argc, char **argv) if (errors_bit > 0) { n_false_positive++; if (n_trials == 1) - printf("errors_bit = %d (trial %d)\n", errors_bit, trial); + printf("errors_bit = %u (trial %d)\n", errors_bit, trial); } printf("\n"); diff --git a/openair1/SIMULATION/NR_PHY/nr_unitary_defs.h b/openair1/SIMULATION/NR_PHY/nr_unitary_defs.h index be04bc8213..78596cc792 100644 --- a/openair1/SIMULATION/NR_PHY/nr_unitary_defs.h +++ b/openair1/SIMULATION/NR_PHY/nr_unitary_defs.h @@ -41,7 +41,7 @@ void exit_function(const char* file, const char* function, const int line, const exit(-1); } -char quantize(double D, double x, unsigned char B) { +signed char quantize(double D, double x, unsigned char B) { double qxd; short maxlev; qxd = floor(x / D); diff --git a/openair1/SIMULATION/NR_PHY/pbchsim.c b/openair1/SIMULATION/NR_PHY/pbchsim.c index 6afdb3d4e3..58b1760884 100644 --- a/openair1/SIMULATION/NR_PHY/pbchsim.c +++ b/openair1/SIMULATION/NR_PHY/pbchsim.c @@ -52,8 +52,11 @@ PHY_VARS_gNB *gNB; PHY_VARS_NR_UE *UE; RAN_CONTEXT_t RC; +int32_t uplink_frequency_offset[MAX_NUM_CCs][4]; + double cpuf; int nfapi_mode=0; + int oai_nfapi_hi_dci0_req(nfapi_hi_dci0_request_t *hi_dci0_req) { return(0);} int oai_nfapi_tx_req(nfapi_tx_request_t *tx_req) { return(0); } @@ -74,6 +77,8 @@ void exit_function(const char* file, const char* function, const int line,const exit(-1); } +uint16_t NB_UE_INST = 1; + // needed for some functions openair0_config_t openair0_cfg[MAX_CARDS]; diff --git a/openair1/SIMULATION/NR_PHY/pucchsim.c b/openair1/SIMULATION/NR_PHY/pucchsim.c index fb4fb744a8..eabee28abf 100644 --- a/openair1/SIMULATION/NR_PHY/pucchsim.c +++ b/openair1/SIMULATION/NR_PHY/pucchsim.c @@ -50,8 +50,11 @@ PHY_VARS_gNB *gNB; PHY_VARS_NR_UE *UE; RAN_CONTEXT_t RC; openair0_config_t openair0_cfg[MAX_CARDS]; +int32_t uplink_frequency_offset[MAX_NUM_CCs][4]; + double cpuf; int nfapi_mode=0; +uint16_t NB_UE_INST = 1; int oai_nfapi_hi_dci0_req(nfapi_hi_dci0_request_t *hi_dci0_req) { return(0);} int oai_nfapi_tx_req(nfapi_tx_request_t *tx_req) { return(0); } diff --git a/openair1/SIMULATION/NR_PHY/ulschsim.c b/openair1/SIMULATION/NR_PHY/ulschsim.c index 7febb6cb28..3767e1fae0 100644 --- a/openair1/SIMULATION/NR_PHY/ulschsim.c +++ b/openair1/SIMULATION/NR_PHY/ulschsim.c @@ -52,8 +52,11 @@ PHY_VARS_gNB *gNB; PHY_VARS_NR_UE *UE; RAN_CONTEXT_t RC; +int32_t uplink_frequency_offset[MAX_NUM_CCs][4]; + double cpuf; int nfapi_mode = 0; +uint16_t NB_UE_INST = 1; int oai_nfapi_hi_dci0_req(nfapi_hi_dci0_request_t *hi_dci0_req) { return (0); @@ -101,7 +104,7 @@ int main(int argc, char **argv) { char c; int i,sf; - double SNR, snr0 = -2.0, snr1 = 2.0; //, SNR_lin; + double SNR, snr0 = -2.0, snr1 = 2.0, SNR_lin; double snr_step = 0.1; uint8_t snr1set = 0; FILE *output_fd = NULL; @@ -120,7 +123,7 @@ int main(int argc, char **argv) //unsigned char pbch_phase = 0; int frame = 0, subframe = 0; NR_DL_FRAME_PARMS *frame_parms; - //double sigma; + double sigma; unsigned char qbits = 8; int ret; int loglvl = OAILOG_WARNING; @@ -410,7 +413,7 @@ int main(int argc, char **argv) uint8_t nb_re_dmrs = 6; uint8_t length_dmrs = 1; uint8_t N_PRB_oh; - uint16_t N_RE_prime; + uint16_t N_RE_prime,code_rate; unsigned char mod_order; uint8_t Nl = 1; uint8_t rvidx = 0; @@ -421,11 +424,12 @@ int main(int argc, char **argv) NR_UE_ULSCH_t *ulsch_ue = UE->ulsch[0][0][0]; - mod_order = nr_get_Qm(Imcs, 1); + mod_order = nr_get_Qm_ul(Imcs, 0); + code_rate = nr_get_code_rate_ul(Imcs, 0); available_bits = nr_get_G(nb_rb, nb_symb_sch, nb_re_dmrs, length_dmrs, mod_order, 1); - TBS = nr_compute_tbs(Imcs, nb_rb, nb_symb_sch, nb_re_dmrs, length_dmrs, Nl); - printf("\n"); - printf("available bits %d TBS %d mod_order %d\n", available_bits, TBS, mod_order); + TBS = nr_compute_tbs(mod_order,code_rate, nb_rb, nb_symb_sch, nb_re_dmrs*length_dmrs, 0, Nl); + + printf("\nAvailable bits %u TBS %u mod_order %d\n", available_bits, TBS, mod_order); /////////// setting rel15_ul parameters /////////// rel15_ul->number_rbs = nb_rb; @@ -436,6 +440,7 @@ int main(int argc, char **argv) rel15_ul->n_layers = Nl; rel15_ul->nb_re_dmrs = nb_re_dmrs; rel15_ul->length_dmrs = length_dmrs; + rel15_ul->R = code_rate; /////////////////////////////////////////////////// double *modulated_input = malloc16(sizeof(double) * 16 * 68 * 384); // [hna] 16 segments, 68*Zc @@ -487,7 +492,7 @@ int main(int argc, char **argv) //////////////////////////////////////////////////////////////////////////////////////////// #ifdef DEBUG_NR_ULSCHSIM - for (i = 0; i < TBS / 8; i++) printf("test_input[i]=%d \n",test_input[i]); + for (i = 0; i < TBS / 8; i++) printf("test_input[i]=%hhu \n",test_input[i]); #endif /////////////////////////ULSCH coding///////////////////////// @@ -529,11 +534,15 @@ int main(int argc, char **argv) //if (i<16) printf("modulated_input[%d] = %d\n",i,modulated_input[i]); - //SNR_lin = pow(10, SNR / 10.0); - //sigma = 1.0 / sqrt(2 * SNR_lin); +#if 1 + SNR_lin = pow(10, SNR / 10.0); + sigma = 1.0 / sqrt(2 * SNR_lin); + channel_output_fixed[i] = (short) quantize(sigma / 4.0 / 4.0, + modulated_input[i] + sigma * gaussdouble(0.0, 1.0), + qbits); +#else channel_output_fixed[i] = (short) quantize(0.01, modulated_input[i], qbits); - //channel_output_fixed[i] = (short) quantize(sigma / 4.0 / 4.0, modulated_input[i] + sigma * gaussdouble(0.0, 1.0), qbits); - //channel_output_fixed[i] = (char)quantize8bit(sigma/4.0,(2.0*modulated_input[i]) - 1.0 + sigma*gaussdouble(0.0,1.0)); +#endif //printf("channel_output_fixed[%d]: %d\n",i,channel_output_fixed[i]); //Uncoded BER @@ -574,7 +583,7 @@ int main(int argc, char **argv) if (errors_bit > 0) { n_false_positive++; if (n_trials == 1) - printf("errors_bit %d (trial %d)\n", errors_bit, trial); + printf("errors_bit %u (trial %d)\n", errors_bit, trial); } printf("\n"); } diff --git a/openair1/SIMULATION/NR_PHY/ulsim.c b/openair1/SIMULATION/NR_PHY/ulsim.c index cbc073d26c..87360910b3 100644 --- a/openair1/SIMULATION/NR_PHY/ulsim.c +++ b/openair1/SIMULATION/NR_PHY/ulsim.c @@ -60,8 +60,11 @@ PHY_VARS_gNB *gNB; PHY_VARS_NR_UE *UE; RAN_CONTEXT_t RC; +int32_t uplink_frequency_offset[MAX_NUM_CCs][4]; + double cpuf; int nfapi_mode = 0; +uint16_t NB_UE_INST = 1; int oai_nfapi_hi_dci0_req(nfapi_hi_dci0_request_t *hi_dci0_req) { return (0); @@ -100,6 +103,23 @@ void exit_function(const char *file, const char *function, const int line, const // dummy functions 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; } +void mac_rlc_data_ind ( + const module_id_t module_idP, + const rnti_t rntiP, + const eNB_index_t eNB_index, + const frame_t frameP, + const eNB_flag_t enb_flagP, + const MBMS_flag_t MBMS_flagP, + const logical_chan_id_t channel_idP, + char *buffer_pP, + const tb_size_t tb_sizeP, + num_tb_t num_tbP, + crc_t *crcs_pP) +{} +uint64_t get_softmodem_optmask(void) {return 0;} +int rlc_module_init (void) {return(0);} +void pdcp_layer_init (void) {} +void nr_ip_over_LTE_DRB_preconfiguration(void){} // needed for some functions uint16_t n_rnti = 0x1234; @@ -116,7 +136,7 @@ int main(int argc, char **argv) int slot = 0; FILE *output_fd = NULL; //uint8_t write_output_file = 0; - int trial, n_trials = 1, n_errors = 0, n_false_positive = 0; + int trial, n_trials = 1, n_errors = 0, n_false_positive = 0, delay = 0; uint8_t n_tx = 1, n_rx = 1; //uint8_t transmission_mode = 1; uint16_t Nid_cell = 0; @@ -127,7 +147,7 @@ int main(int argc, char **argv) SCM_t channel_model = AWGN; //Rayleigh1_anticorr; uint16_t N_RB_DL = 106, N_RB_UL = 106, mu = 1; //unsigned char frame_type = 0; - int frame = 0; + int number_of_frames = 1; int frame_length_complex_samples; NR_DL_FRAME_PARMS *frame_parms; int loglvl = OAILOG_WARNING; @@ -142,10 +162,9 @@ int main(int argc, char **argv) int tx_offset; double txlev_float; int32_t txlev; - int start_rb = 30; + int start_rb = 0; int UE_id =0; // [hna] only works for UE_id = 0 because NUMBER_OF_NR_UE_MAX is set to 1 (phy_init_nr_gNB causes segmentation fault) - cpuf = get_cpu_freq_GHz(); @@ -159,8 +178,21 @@ int main(int argc, char **argv) //logInit(); randominit(0); - while ((c = getopt(argc, argv, "df:hpg:i:j:n:l:m:r:s:S:y:z:M:N:F:R:P:")) != -1) { + while ((c = getopt(argc, argv, "d:f:g:h:i:j:l:m:n:p:r:s:y:z:F:M:N:P:R:S:")) != -1) { switch (c) { + + /*case 'd': + frame_type = 1; + break;*/ + + case 'd': + delay = atoi(optarg); + break; + + case 'f': + number_of_frames = atoi(optarg); + break; + /*case 'f': write_output_file = 1; output_fd = fopen(optarg, "w"); @@ -172,10 +204,6 @@ int main(int argc, char **argv) break;*/ - /*case 'd': - frame_type = 1; - break;*/ - case 'g': switch ((char) *optarg) { case 'A': @@ -221,25 +249,31 @@ int main(int argc, char **argv) interf2 = atoi(optarg); break;*/ + case 'l': + nb_symb_sch = atoi(optarg); + break; + + case 'm': + Imcs = atoi(optarg); + break; + case 'n': n_trials = atoi(optarg); break; + case 'p': + extended_prefix_flag = 1; + break; + + case 'r': + nb_rb = atoi(optarg); + break; + case 's': snr0 = atof(optarg); printf("Setting SNR0 to %f\n", snr0); break; - case 'S': - snr1 = atof(optarg); - snr1set = 1; - printf("Setting SNR1 to %f\n", snr1); - break; - - case 'p': - extended_prefix_flag = 1; - break; - /* case 'r': ricean_factor = pow(10,-.1*atof(optarg)); @@ -250,6 +284,10 @@ int main(int argc, char **argv) break; */ + /*case 'x': + transmission_mode = atoi(optarg); + break;*/ + case 'y': n_tx = atoi(optarg); @@ -270,6 +308,16 @@ int main(int argc, char **argv) break; + case 'F': + input_fd = fopen(optarg, "r"); + + if (input_fd == NULL) { + printf("Problem with filename %s\n", optarg); + exit(-1); + } + + break; + case 'M': SSB_positions = atoi(optarg); break; @@ -283,56 +331,39 @@ int main(int argc, char **argv) N_RB_UL = N_RB_DL; break; - case 'F': - input_fd = fopen(optarg, "r"); - - if (input_fd == NULL) { - printf("Problem with filename %s\n", optarg); - exit(-1); - } - + case 'S': + snr1 = atof(optarg); + snr1set = 1; + printf("Setting SNR1 to %f\n", snr1); break; - case 'm': - Imcs = atoi(optarg); - break; - - case 'l': - nb_symb_sch = atoi(optarg); - break; - - case 'r': - nb_rb = atoi(optarg); - break; - - /*case 'x': - transmission_mode = atoi(optarg); - break;*/ - default: case 'h': printf("%s -h(elp) -p(extended_prefix) -N cell_id -f output_filename -F input_filename -g channel_model -n n_frames -t Delayspread -s snr0 -S snr1 -x transmission_mode -y TXant -z RXant -i Intefrence0 -j Interference1 -A interpolation_file -C(alibration offset dB) -N CellId\n", argv[0]); - printf("-h This message\n"); - printf("-p Use extended prefix mode\n"); //printf("-d Use TDD\n"); - printf("-n Number of frames to simulate\n"); - printf("-s Starting SNR, runs from SNR0 to SNR0 + 5 dB. If n_frames is 1 then just SNR is simulated\n"); - printf("-S Ending SNR, runs from SNR0 to SNR1\n"); - printf("-t Delay spread for multipath channel\n"); + printf("-d Introduce delay in terms of number of samples\n"); + printf("-f Number of frames to simulate\n"); printf("-g [A,B,C,D,E,F,G] Use 3GPP SCM (A,B,C,D) or 36-101 (E-EPA,F-EVA,G-ETU) models (ignores delay spread and Ricean factor)\n"); + printf("-h This message\n"); + //printf("-i Relative strength of first intefering eNB (in dB) - cell_id mod 3 = 1\n"); + //printf("-j Relative strength of second intefering eNB (in dB) - cell_id mod 3 = 2\n"); + printf("-s Starting SNR, runs from SNR0 to SNR0 + 10 dB if ending SNR isn't given\n"); + printf("-m MCS value\n"); + printf("-n Number of trials to simulate\n"); + printf("-p Use extended prefix mode\n"); + printf("-t Delay spread for multipath channel\n"); //printf("-x Transmission mode (1,2,6 for the moment)\n"); printf("-y Number of TX antennas used in eNB\n"); printf("-z Number of RX antennas used in UE\n"); - //printf("-i Relative strength of first intefering eNB (in dB) - cell_id mod 3 = 1\n"); - //printf("-j Relative strength of second intefering eNB (in dB) - cell_id mod 3 = 2\n"); - printf("-M Multiple SSB positions in burst\n"); - printf("-N Nid_cell\n"); - printf("-R N_RB_DL\n"); - printf("-O oversampling factor (1,2,4,8,16)\n"); + printf("-A Interpolation_filname Run with Abstraction to generate Scatter plot using interpolation polynomial in file\n"); //printf("-C Generate Calibration information for Abstraction (effective SNR adjustment to remove Pe bias w.r.t. AWGN)\n"); - //printf("-f Output filename (.txt format) for Pe/SNR results\n"); printf("-F Input filename (.txt format) for RX conformance testing\n"); + printf("-M Multiple SSB positions in burst\n"); + printf("-N Nid_cell\n"); + printf("-O oversampling factor (1,2,4,8,16)\n"); + printf("-R N_RB_DL\n"); + printf("-S Ending SNR, runs from SNR0 to SNR1\n"); exit(-1); break; } @@ -359,13 +390,6 @@ int main(int argc, char **argv) RC.gNB[0] = malloc(sizeof(PHY_VARS_gNB)); gNB = RC.gNB[0]; //gNB_config = &gNB->gNB_config; - gNB_L1_rxtx_proc_t gNB_proc; - - gNB_proc.frame_rx = frame; - gNB_proc.slot_rx = slot; - - UE_proc.nr_tti_tx = slot; - UE_proc.frame_tx = frame; frame_parms = &gNB->frame_parms; //to be initialized I suppose (maybe not necessary for PBCH) frame_parms->nb_antennas_tx = n_tx; @@ -376,7 +400,7 @@ int main(int argc, char **argv) crcTableInit(); - nr_phy_config_request_sim(gNB, N_RB_DL, N_RB_DL, mu, Nid_cell, SSB_positions); + nr_phy_config_request_sim(gNB, N_RB_DL, N_RB_UL, mu, Nid_cell, SSB_positions); phy_init_nr_gNB(gNB, 0, 0); //init_eNB_afterRU(); @@ -413,184 +437,198 @@ int main(int argc, char **argv) } } - unsigned char harq_pid = 0; - unsigned int TBS = 8424; + unsigned int TBS; unsigned int available_bits; uint8_t nb_re_dmrs = UE->dmrs_UplinkConfig.pusch_maxLength*(UE->dmrs_UplinkConfig.pusch_dmrs_type == pusch_dmrs_type1)?6:4; uint8_t length_dmrs = 1; unsigned char mod_order; + uint16_t code_rate; - mod_order = nr_get_Qm(Imcs, 1); + mod_order = nr_get_Qm_ul(Imcs, 0); + code_rate = nr_get_code_rate_ul(Imcs, 0); available_bits = nr_get_G(nb_rb, nb_symb_sch, nb_re_dmrs, length_dmrs, mod_order, 1); - TBS = nr_compute_tbs(Imcs, nb_rb, nb_symb_sch, nb_re_dmrs, length_dmrs, precod_nbr_layers); + TBS = nr_compute_tbs(mod_order, code_rate, nb_rb, nb_symb_sch, nb_re_dmrs*length_dmrs, 0, precod_nbr_layers); NR_gNB_ULSCH_t *ulsch_gNB = gNB->ulsch[UE_id+1][0]; nfapi_nr_ul_config_ulsch_pdu *rel15_ul = &ulsch_gNB->harq_processes[harq_pid]->ulsch_pdu; NR_UE_ULSCH_t **ulsch_ue = UE->ulsch[0][0]; - - // --------- setting rel15_ul parameters for gNB -------- - rel15_ul->rnti = n_rnti; - rel15_ul->ulsch_pdu_rel15.start_rb = start_rb; - rel15_ul->ulsch_pdu_rel15.number_rbs = nb_rb; - rel15_ul->ulsch_pdu_rel15.start_symbol = start_symbol; - rel15_ul->ulsch_pdu_rel15.number_symbols = nb_symb_sch; - rel15_ul->ulsch_pdu_rel15.nb_re_dmrs = nb_re_dmrs; - rel15_ul->ulsch_pdu_rel15.length_dmrs = length_dmrs; - rel15_ul->ulsch_pdu_rel15.Qm = mod_order; - rel15_ul->ulsch_pdu_rel15.mcs = Imcs; - rel15_ul->ulsch_pdu_rel15.rv = 0; - rel15_ul->ulsch_pdu_rel15.ndi = 0; - rel15_ul->ulsch_pdu_rel15.n_layers = precod_nbr_layers; - /////////////////////////////////////////////////// - - nr_scheduled_response_t scheduled_response; - fapi_nr_ul_config_request_t ul_config; - //fapi_nr_tx_request_t tx_request; - - scheduled_response.module_id = 0; - scheduled_response.CC_id = 0; - scheduled_response.frame = frame; - scheduled_response.slot = slot; - scheduled_response.dl_config = NULL; - scheduled_response.ul_config = &ul_config; - scheduled_response.dl_config = NULL; - - ul_config.sfn_slot = slot; - ul_config.number_pdus = 1; - ul_config.ul_config_list[0].pdu_type = FAPI_NR_UL_CONFIG_TYPE_ULSCH; - ul_config.ul_config_list[0].ulsch_config_pdu.rnti = n_rnti; - ul_config.ul_config_list[0].ulsch_config_pdu.ulsch_pdu_rel15.number_rbs = nb_rb; - ul_config.ul_config_list[0].ulsch_config_pdu.ulsch_pdu_rel15.start_rb = start_rb; - ul_config.ul_config_list[0].ulsch_config_pdu.ulsch_pdu_rel15.number_symbols = nb_symb_sch; - ul_config.ul_config_list[0].ulsch_config_pdu.ulsch_pdu_rel15.start_symbol = start_symbol; - ul_config.ul_config_list[0].ulsch_config_pdu.ulsch_pdu_rel15.mcs = Imcs; - ul_config.ul_config_list[0].ulsch_config_pdu.ulsch_pdu_rel15.ndi = 0; - ul_config.ul_config_list[0].ulsch_config_pdu.ulsch_pdu_rel15.rv = 0; - ul_config.ul_config_list[0].ulsch_config_pdu.ulsch_pdu_rel15.n_layers = precod_nbr_layers; - ul_config.ul_config_list[0].ulsch_config_pdu.ulsch_pdu_rel15.harq_process_nbr = harq_pid; - //there are plenty of other parameters that we don't seem to be using for now. e.g. - //ul_config.ul_config_list[0].ulsch_config_pdu.ulsch_pdu_rel15.absolute_delta_PUSCH = 0; - - // set FAPI parameters for UE, put them in the scheduled response and call - nr_ue_scheduled_response(&scheduled_response); - unsigned char *estimated_output_bit; unsigned char *test_input_bit; - unsigned int errors_bit = 0; + uint32_t errors_decoding = 0; uint32_t errors_scrambling = 0; + uint32_t is_frame_in_error = 0; test_input_bit = (unsigned char *) malloc16(sizeof(unsigned char) * 16 * 68 * 384); estimated_output_bit = (unsigned char *) malloc16(sizeof(unsigned char) * 16 * 68 * 384); - /////////////////////////phy_procedures_nr_ue_TX/////////////////////// - /////////// - - phy_procedures_nrUE_TX(UE, &UE_proc, gNB_id, 0); - - /////////// - //////////////////////////////////////////////////// - tx_offset = slot*frame_parms->samples_per_slot; - - txlev = signal_energy_amp_shift(&UE->common_vars.txdata[0][tx_offset + 5*frame_parms->ofdm_symbol_size + 4*frame_parms->nb_prefix_samples + frame_parms->nb_prefix_samples0], - frame_parms->ofdm_symbol_size + frame_parms->nb_prefix_samples); - - txlev_float = (double)txlev/(double)AMP; // output of signal_energy is fixed point representation - - + nr_scheduled_response_t scheduled_response; + fapi_nr_ul_config_request_t ul_config; printf("\n"); for (SNR = snr0; SNR < snr1; SNR += snr_step) { - n_errors = 0; - n_false_positive = 0; + printf("-------------------\n"); + printf("SNR %f\n", SNR); + printf("-------------------\n"); - //AWGN - sigma_dB = 10*log10(txlev_float)-SNR; - sigma = pow(10,sigma_dB/10); + is_frame_in_error = 0; + for (int frame = 0; frame < number_of_frames; frame++) { - for (trial = 0; trial < n_trials; trial++) { + UE_proc.nr_tti_tx = slot; + UE_proc.frame_tx = frame; - errors_scrambling = 0; - errors_bit = 0; + // --------- setting rel15_ul parameters for gNB -------- + rel15_ul->rnti = n_rnti; + rel15_ul->ulsch_pdu_rel15.start_rb = start_rb; + rel15_ul->ulsch_pdu_rel15.number_rbs = nb_rb; + rel15_ul->ulsch_pdu_rel15.start_symbol = start_symbol; + rel15_ul->ulsch_pdu_rel15.number_symbols = nb_symb_sch; + rel15_ul->ulsch_pdu_rel15.nb_re_dmrs = nb_re_dmrs; + rel15_ul->ulsch_pdu_rel15.length_dmrs = length_dmrs; + rel15_ul->ulsch_pdu_rel15.Qm = mod_order; + rel15_ul->ulsch_pdu_rel15.mcs = Imcs; + rel15_ul->ulsch_pdu_rel15.rv = 0; + rel15_ul->ulsch_pdu_rel15.ndi = 0; + rel15_ul->ulsch_pdu_rel15.n_layers = precod_nbr_layers; + rel15_ul->ulsch_pdu_rel15.R = code_rate; + /////////////////////////////////////////////////// - for (i=0; inb_antennas_rx; ap++) { - // [hna] doesn't work with noise in case of mod_order = 6 - ((short*) gNB->common_vars.rxdata[ap])[2*i] = (((int16_t *)UE->common_vars.txdata[ap])[(i<<1)])+ (int16_t)(sqrt(sigma/2)*gaussdouble(0.0,1.0)*(double)AMP); // convert to fixed point - ((short*) gNB->common_vars.rxdata[ap])[2*i+1] = (((int16_t *)UE->common_vars.txdata[ap])[(i<<1)+1])+ (int16_t)(sqrt(sigma/2)*gaussdouble(0.0,1.0)*(double)AMP); - } - } + //fapi_nr_tx_request_t tx_request; - - phy_procedures_gNB_common_RX(gNB, &gNB_proc); + scheduled_response.module_id = 0; + scheduled_response.CC_id = 0; + scheduled_response.frame = frame; + scheduled_response.slot = slot; + scheduled_response.dl_config = NULL; + scheduled_response.ul_config = &ul_config; + scheduled_response.dl_config = NULL; - phy_procedures_gNB_uespec_RX(gNB, &gNB_proc, rel15_ul->ulsch_pdu_rel15.start_symbol, rel15_ul->ulsch_pdu_rel15.start_symbol + rel15_ul->ulsch_pdu_rel15.number_symbols); + ul_config.sfn_slot = slot; + ul_config.number_pdus = 1; + ul_config.ul_config_list[0].pdu_type = FAPI_NR_UL_CONFIG_TYPE_PUSCH; + ul_config.ul_config_list[0].ulsch_config_pdu.rnti = n_rnti; + ul_config.ul_config_list[0].ulsch_config_pdu.ulsch_pdu_rel15.number_rbs = nb_rb; + ul_config.ul_config_list[0].ulsch_config_pdu.ulsch_pdu_rel15.start_rb = start_rb; + ul_config.ul_config_list[0].ulsch_config_pdu.ulsch_pdu_rel15.number_symbols = nb_symb_sch; + ul_config.ul_config_list[0].ulsch_config_pdu.ulsch_pdu_rel15.start_symbol = start_symbol; + ul_config.ul_config_list[0].ulsch_config_pdu.ulsch_pdu_rel15.mcs = Imcs; + ul_config.ul_config_list[0].ulsch_config_pdu.ulsch_pdu_rel15.ndi = 0; + ul_config.ul_config_list[0].ulsch_config_pdu.ulsch_pdu_rel15.rv = 0; + ul_config.ul_config_list[0].ulsch_config_pdu.ulsch_pdu_rel15.n_layers = precod_nbr_layers; + ul_config.ul_config_list[0].ulsch_config_pdu.ulsch_pdu_rel15.harq_process_nbr = harq_pid; + //there are plenty of other parameters that we don't seem to be using for now. e.g. + //ul_config.ul_config_list[0].ulsch_config_pdu.ulsch_pdu_rel15.absolute_delta_PUSCH = 0; + // set FAPI parameters for UE, put them in the scheduled response and call + nr_ue_scheduled_response(&scheduled_response); - //---------------------------------------------------------- - //---------------------- count errors ---------------------- - //---------------------------------------------------------- + /////////////////////////phy_procedures_nr_ue_TX/////////////////////// + /////////// - for (i = 0; i < available_bits; i++) { - - if(((ulsch_ue[0]->g[i] == 0) && (gNB->pusch_vars[UE_id]->llr[i] <= 0)) || - ((ulsch_ue[0]->g[i] == 1) && (gNB->pusch_vars[UE_id]->llr[i] >= 0))) - { - if(errors_scrambling == 0) { - printf("\n"); - printf("First bit in error in unscrambling = %d\n",i); + phy_procedures_nrUE_TX(UE, &UE_proc, gNB_id, 0); + + /////////// + //////////////////////////////////////////////////// + tx_offset = slot*frame_parms->samples_per_slot; + + txlev = signal_energy_amp_shift(&UE->common_vars.txdata[0][tx_offset + 5*frame_parms->ofdm_symbol_size + 4*frame_parms->nb_prefix_samples + frame_parms->nb_prefix_samples0], + frame_parms->ofdm_symbol_size + frame_parms->nb_prefix_samples); + + txlev_float = (double)txlev/(double)AMP; // output of signal_energy is fixed point representation + + n_errors = 0; + n_false_positive = 0; + + //AWGN + sigma_dB = 10*log10(txlev_float)-SNR; + sigma = pow(10,sigma_dB/10); + + for (trial = 0; trial < n_trials; trial++) { + + errors_scrambling = 0; + errors_decoding = 0; + + //---------------------------------------------------------- + //------------------------ add noise ----------------------- + //---------------------------------------------------------- + for (i=0; inb_antennas_rx; ap++) { + ((short*) gNB->common_vars.rxdata[ap])[(2*i) + (delay*2)] = (((int16_t *)UE->common_vars.txdata[ap])[(i<<1)]) + (int16_t)(sqrt(sigma/2)*gaussdouble(0.0,1.0)*(double)AMP); // convert to fixed point + ((short*) gNB->common_vars.rxdata[ap])[2*i+1 + (delay*2)] = (((int16_t *)UE->common_vars.txdata[ap])[(i<<1)+1]) + (int16_t)(sqrt(sigma/2)*gaussdouble(0.0,1.0)*(double)AMP); + } + } + //////////////////////////////////////////////////////////// + + //---------------------------------------------------------- + //------------------- gNB phy procedures ------------------- + //---------------------------------------------------------- + phy_procedures_gNB_common_RX(gNB, frame, slot); + + phy_procedures_gNB_uespec_RX(gNB, frame, slot, rel15_ul->ulsch_pdu_rel15.start_symbol, rel15_ul->ulsch_pdu_rel15.start_symbol + rel15_ul->ulsch_pdu_rel15.number_symbols); + //////////////////////////////////////////////////////////// + + //---------------------------------------------------------- + //----------------- count and print errors ----------------- + //---------------------------------------------------------- + + for (i = 0; i < available_bits; i++) { + + if(((ulsch_ue[0]->g[i] == 0) && (gNB->pusch_vars[UE_id]->llr[i] <= 0)) || + ((ulsch_ue[0]->g[i] == 1) && (gNB->pusch_vars[UE_id]->llr[i] >= 0))) + { + if(errors_scrambling == 0) + printf("\x1B[34m" "[frame %d][trial %d]\t1st bit in error in unscrambling = %d\n" "\x1B[0m", frame, trial, i); + errors_scrambling++; } - errors_scrambling++; } - } - - for (i = 0; i < TBS; i++) { - - estimated_output_bit[i] = (ulsch_gNB->harq_processes[harq_pid]->b[i/8] & (1 << (i & 7))) >> (i & 7); - test_input_bit[i] = (ulsch_ue[0]->harq_processes[harq_pid]->b[i / 8] & (1 << (i & 7))) >> (i & 7); // Further correct for multiple segments - - if (estimated_output_bit[i] != test_input_bit[i]) { - if(errors_bit == 0) - printf("First bit in error in decoding = %d\n",i); - errors_bit++; + if (errors_scrambling > 0) { + printf("\x1B[31m""[frame %d][trial %d]\tnumber of errors in unscrambling = %d\n" "\x1B[0m", frame, trial, errors_scrambling); } - - } - //////////////////////////////////////////////////////////// + for (i = 0; i < TBS; i++) { - if (errors_scrambling > 0) { - if (n_trials == 1) - printf("errors_scrambling = %d (trial %d)\n", errors_scrambling, trial); - } + estimated_output_bit[i] = (ulsch_gNB->harq_processes[harq_pid]->b[i/8] & (1 << (i & 7))) >> (i & 7); + test_input_bit[i] = (ulsch_ue[0]->harq_processes[harq_pid]->b[i / 8] & (1 << (i & 7))) >> (i & 7); - if (errors_bit > 0) { - n_false_positive++; - if (n_trials == 1) - printf("errors_bit = %d (trial %d)\n", errors_bit, trial); - } - printf("\n"); - } // [hna] for (trial = 0; trial < n_trials; trial++) - - printf("*****************************************\n"); - printf("SNR %f, (false positive %f)\n", SNR, - (float) n_false_positive / (float) n_trials); - printf("*****************************************\n"); - printf("\n"); + if (estimated_output_bit[i] != test_input_bit[i]) { + if(errors_decoding == 0) + printf("\x1B[34m""[frame %d][trial %d]\t1st bit in error in decoding = %d\n" "\x1B[0m", frame, trial, i); + errors_decoding++; + } + } - if (errors_bit == 0) { - printf("PUSCH test OK\n"); - printf("\n"); + if (errors_decoding > 0) { + is_frame_in_error = 1; + n_false_positive++; + printf("\x1B[31m""[frame %d][trial %d]\tnumber of errors in decoding = %d\n" "\x1B[0m", frame, trial, errors_decoding); + } else { + is_frame_in_error = 0; + break; + } + //////////////////////////////////////////////////////////// + } // trial loop + + if (is_frame_in_error == 1) + break; + } // frame loop + + if(is_frame_in_error == 0) break; - } - printf("\n"); - } // [hna] for (SNR = snr0; SNR < snr1; SNR += snr_step) + } // SNR loop + if(is_frame_in_error == 0) { + printf("\n"); + printf("*************\n"); + printf("PUSCH test OK\n"); + printf("*************\n"); + } + + printf("\n"); for (i = 0; i < 2; i++) { @@ -617,6 +655,9 @@ int main(int argc, char **argv) printf("\n"); } + free(test_input_bit); + free(estimated_output_bit); + if (output_fd) fclose(output_fd); diff --git a/openair1/SIMULATION/NR_UE_PHY/unit_tests/src/dummy_functions.c b/openair1/SIMULATION/NR_UE_PHY/unit_tests/src/dummy_functions.c index fa243d1eb0..a93f0d48f3 100644 --- a/openair1/SIMULATION/NR_UE_PHY/unit_tests/src/dummy_functions.c +++ b/openair1/SIMULATION/NR_UE_PHY/unit_tests/src/dummy_functions.c @@ -119,7 +119,7 @@ void dl_phy_sync_success(module_id_t module_idP, frame_t frameP, unsigned char eNB_index, uint8_t first_sync){} -uint32_t from_nrarfcn(int nr_bandP, uint32_t dl_nrarfcn) { return(0);} +uint64_t from_nrarfcn(int nr_bandP, uint32_t dl_nrarfcn) { return(0);} int32_t get_uldl_offset(int nr_bandP) { return(0);} diff --git a/openair1/SIMULATION/TOOLS/random_channel.c b/openair1/SIMULATION/TOOLS/random_channel.c index f056d51b5d..41d8551e75 100644 --- a/openair1/SIMULATION/TOOLS/random_channel.c +++ b/openair1/SIMULATION/TOOLS/random_channel.c @@ -30,11 +30,32 @@ #include "sim.h" #include "scm_corrmat.h" #include "common/utils/LOG/log.h" +#include "common/config/config_userapi.h" +#include "common/utils/telnetsrv/telnetsrv.h" +#include "common/utils/load_module_shlib.h" + + //#define DEBUG_CH #include "assertions.h" extern void print_shorts(char *s,__m128i *x); +static mapping channelmod_names[] = { + CHANNELMOD_MAP_INIT +}; + +static int channelmod_show_cmd(char *buff, int debug, telnet_printfunc_t prnt); +static telnetshell_cmddef_t channelmod_cmdarray[] = { + {"show","",channelmod_show_cmd}, + {"","",NULL}, +}; + +static telnetshell_vardef_t channelmod_vardef[] = { + {"",0,NULL} +}; + +static double snr_dB=25; +static double sinr_dB=0; void fill_channel_desc(channel_desc_t *chan_desc, uint8_t nb_tx, @@ -43,7 +64,7 @@ void fill_channel_desc(channel_desc_t *chan_desc, uint8_t channel_length, double *amps, double *delays, - struct complex** R_sqrt, + struct complex **R_sqrt, double Td, double sampling_rate, double channel_bandwidth, @@ -53,30 +74,27 @@ void fill_channel_desc(channel_desc_t *chan_desc, double max_Doppler, int32_t channel_offset, double path_loss_dB, - uint8_t random_aoa) -{ - - + uint8_t random_aoa) { uint16_t i,j; double delta_tau; - LOG_I(OCM,"[CHANNEL] Getting new channel descriptor, nb_tx %d, nb_rx %d, nb_taps %d, channel_length %d\n", - nb_tx,nb_rx,nb_taps,channel_length); - + nb_tx,nb_rx,nb_taps,channel_length); chan_desc->nb_tx = nb_tx; chan_desc->nb_rx = nb_rx; chan_desc->nb_taps = nb_taps; chan_desc->channel_length = channel_length; chan_desc->amps = amps; LOG_D(OCM,"[CHANNEL] Doing delays ...\n"); + if (delays==NULL) { - chan_desc->delays = (double*) malloc(nb_taps*sizeof(double)); + chan_desc->delays = (double *) malloc(nb_taps*sizeof(double)); delta_tau = Td/nb_taps; + for (i=0; idelays[i] = ((double)i)*delta_tau; - } - else - chan_desc->delays = delays; + } else + chan_desc->delays = delays; + chan_desc->Td = Td; chan_desc->sampling_rate = sampling_rate; chan_desc->channel_bandwidth = channel_bandwidth; @@ -89,43 +107,46 @@ void fill_channel_desc(channel_desc_t *chan_desc, chan_desc->first_run = 1; chan_desc->ip = 0.0; chan_desc->max_Doppler = max_Doppler; - chan_desc->ch = (struct complex**) malloc(nb_tx*nb_rx*sizeof(struct complex*)); - chan_desc->chF = (struct complex**) malloc(nb_tx*nb_rx*sizeof(struct complex*)); - chan_desc->a = (struct complex**) malloc(nb_taps*sizeof(struct complex*)); - + chan_desc->ch = (struct complex **) malloc(nb_tx*nb_rx*sizeof(struct complex *)); + chan_desc->chF = (struct complex **) malloc(nb_tx*nb_rx*sizeof(struct complex *)); + chan_desc->a = (struct complex **) malloc(nb_taps*sizeof(struct complex *)); LOG_D(OCM,"[CHANNEL] Filling ch \n"); for (i = 0; ich[i] = (struct complex*) malloc(channel_length * sizeof(struct complex)); + chan_desc->ch[i] = (struct complex *) malloc(channel_length * sizeof(struct complex)); for (i = 0; ichF[i] = (struct complex*) malloc(1200 * sizeof(struct complex)); // allocate for up to 100 RBs, 12 samples per RB + chan_desc->chF[i] = (struct complex *) malloc(1200 * sizeof(struct complex)); // allocate for up to 100 RBs, 12 samples per RB LOG_D(OCM,"[CHANNEL] Filling a (nb_taps %d)\n",nb_taps); + for (i = 0; ia[i],nb_tx*nb_rx * sizeof(struct complex)); - chan_desc->a[i] = (struct complex*) malloc(nb_tx*nb_rx * sizeof(struct complex)); + chan_desc->a[i] = (struct complex *) malloc(nb_tx*nb_rx * sizeof(struct complex)); } LOG_D(OCM,"[CHANNEL] Doing R_sqrt ...\n"); + if (R_sqrt == NULL) { - chan_desc->R_sqrt = (struct complex**) calloc(nb_taps,sizeof(struct complex*)); + chan_desc->R_sqrt = (struct complex **) calloc(nb_taps,sizeof(struct complex *)); + for (i = 0; iR_sqrt[i] = (struct complex*) calloc(nb_tx*nb_rx*nb_tx*nb_rx,sizeof(struct complex)); + chan_desc->R_sqrt[i] = (struct complex *) calloc(nb_tx*nb_rx*nb_tx*nb_rx,sizeof(struct complex)); + for (j = 0; jR_sqrt[i][j].x = 1.0; chan_desc->R_sqrt[i][j].y = 0.0; } } - } - else { - chan_desc->R_sqrt = (struct complex**) calloc(nb_taps,sizeof(struct complex*)); + } else { + chan_desc->R_sqrt = (struct complex **) calloc(nb_taps,sizeof(struct complex *)); + for (i = 0; iR_sqrt[i] = (struct complex*) calloc(nb_tx*nb_rx*nb_tx*nb_rx,sizeof(struct complex)); - //chan_desc->R_sqrt = (struct complex*)&R_sqrt[i][0]; - /* all chan_desc share the same R_sqrt, coming from caller */ - chan_desc->R_sqrt[i] = R_sqrt[0]; - } + //chan_desc->R_sqrt[i] = (struct complex*) calloc(nb_tx*nb_rx*nb_tx*nb_rx,sizeof(struct complex)); + //chan_desc->R_sqrt = (struct complex*)&R_sqrt[i][0]; + /* all chan_desc share the same R_sqrt, coming from caller */ + chan_desc->R_sqrt[i] = R_sqrt[0]; + } } for (i = 0; iricean_factor); - for (i=0;inb_taps;i++) + + for (i=0; inb_taps; i++) LOG_D(OCM,"[CHANNEL] tap %d: amp %f, delay %f\n",i,chan_desc->amps[i],chan_desc->delays[i]); chan_desc->nb_paths=10; - reset_meas(&chan_desc->random_channel); reset_meas(&chan_desc->interp_time); reset_meas(&chan_desc->interp_freq); reset_meas(&chan_desc->convolution); - } double mbsfn_delays[] = {0,.03,.15,.31,.37,1.09,12.490,12.52,12.64,12.80,12.86,13.58,27.49,27.52,27.64,27.80,27.86,28.58}; @@ -162,7 +182,7 @@ double eva_amps_dB[] = {0.0,-1.5,-1.4,-3.6,-0.6,-9.1,-7.0,-12.0,-16.9}; double etu_delays[] = { 0,.05,.12,.2,.23,.5,1.6,2.3,5.0}; double etu_amps_dB[] = {-1.0,-1.0,-1.0,0.0,0.0,0.0,-3.0,-5.0,-7.0}; -double default_amps_lin[] = {0.3868472 , 0.3094778 , 0.1547389 , 0.0773694 , 0.0386847 , 0.0193424 , 0.0096712 , 0.0038685}; +double default_amps_lin[] = {0.3868472, 0.3094778, 0.1547389, 0.0773694, 0.0386847, 0.0193424, 0.0096712, 0.0038685}; double default_amp_lin[] = {1}; double ts_shift_delays[] = {0, 1/7.68}; @@ -170,9 +190,10 @@ double ts_shift_amps[] = {0, 1}; //correlation matrix for a 2x2 channel with full Tx correlation struct complex R_sqrt_22_corr_tap[16] = {{0.70711,0}, {0.0, 0.0}, {0.70711,0}, {0.0, 0.0}, - {0.0, 0.0}, {0.70711,0}, {0.0, 0.0}, {0.70711,0}, - {0.70711,0}, {0.0, 0.0}, {0.70711,0}, {0.0, 0.0}, - {0.0, 0.0}, {0.70711,0}, {0.0, 0.0}, {0.70711,0}}; + {0.0, 0.0}, {0.70711,0}, {0.0, 0.0}, {0.70711,0}, + {0.70711,0}, {0.0, 0.0}, {0.70711,0}, {0.0, 0.0}, + {0.0, 0.0}, {0.70711,0}, {0.0, 0.0}, {0.70711,0} +}; struct complex *R_sqrt_22_corr[1] = {R_sqrt_22_corr_tap}; //correlation matrix for a fully correlated 2x1 channel (h1==h2) @@ -181,9 +202,10 @@ struct complex *R_sqrt_21_corr[1] = {R_sqrt_21_corr_tap}; //correlation matrix for a 2x2 channel with full Tx anti-correlation struct complex R_sqrt_22_anticorr_tap[16] = {{0.70711,0}, {0.0, 0.0}, {-0.70711,0}, {0.0, 0.0}, - {0.0, 0.0}, {0.70711,0}, {0.0, 0.0}, {-0.70711,0}, - {-0.70711,0}, {0.0, 0.0}, {0.70711,0}, {0.0, 0.0}, - {0.0, 0.0}, {-0.70711,0}, {0.0, 0.0}, {0.70711,0}}; + {0.0, 0.0}, {0.70711,0}, {0.0, 0.0}, {-0.70711,0}, + {-0.70711,0}, {0.0, 0.0}, {0.70711,0}, {0.0, 0.0}, + {0.0, 0.0}, {-0.70711,0}, {0.0, 0.0}, {0.70711,0} +}; struct complex *R_sqrt_22_anticorr[1] = {R_sqrt_22_anticorr_tap}; //correlation matrix for a fully anti-correlated 2x1 channel (h1==-h2) @@ -195,9 +217,10 @@ struct complex **R_sqrt_ptr2; // full correlation matrix in vectorized form for 2x2 channel, where h1 is perfectly orthogonal to h2 struct complex R_sqrt_22_orthogonal_tap[16] = {{0.70711,0.0}, {0.0, 0.0}, {0.0,0.0}, {0.0, 0.0}, - {0.0, 0.0}, {0.0,0.0}, {0.0, 0.0}, {0.0,0.0}, - {0.0,0.0}, {0.0, 0.0}, {0.0,0.0}, {0.0, 0.0}, - {0.0, 0.0}, {0.0,0.0}, {0.0, 0.0}, {0.70711,0.0}}; + {0.0, 0.0}, {0.0,0.0}, {0.0, 0.0}, {0.0,0.0}, + {0.0,0.0}, {0.0, 0.0}, {0.0,0.0}, {0.0, 0.0}, + {0.0, 0.0}, {0.0,0.0}, {0.0, 0.0}, {0.70711,0.0} +}; struct complex *R_sqrt_22_orthogonal[1] = {R_sqrt_22_orthogonal_tap}; // full correlation matrix for TM4 to make orthogonal effective channel @@ -206,37 +229,43 @@ struct complex *R_sqrt_22_orthogonal[1] = {R_sqrt_22_orthogonal_tap}; struct complex R_sqrt_22_orth_eff_ch_TM4_prec_real_tap[16] = {{0.70711,0.0}, {0.0, 0.0}, {0.70711,0.0}, {0.0, 0.0}, - {0.0, 0.0}, {0.70711,0.0}, {0.0, 0.0}, {-0.70711,0.0}, - {0.70711,0.0}, {0.0, 0.0}, {0.70711,0.0}, {0.0, 0.0}, - {0.0, 0.0}, {-0.70711,0.0}, {0.0, 0.0}, {0.70711,0.0}}; + {0.0, 0.0}, {0.70711,0.0}, {0.0, 0.0}, {-0.70711,0.0}, + {0.70711,0.0}, {0.0, 0.0}, {0.70711,0.0}, {0.0, 0.0}, + {0.0, 0.0}, {-0.70711,0.0}, {0.0, 0.0}, {0.70711,0.0} +}; struct complex *R_sqrt_22_orth_eff_ch_TM4_prec_real[1] = {R_sqrt_22_orth_eff_ch_TM4_prec_real_tap}; struct complex R_sqrt_22_orth_eff_ch_TM4_prec_imag_tap[16] = {{0.70711,0.0}, {0.0,0.0}, {0.0, -0.70711}, {0.0,0.0}, - {0.0, 0.0}, {0.70711,0.0}, {0.0, 0.0}, {0.0,0.70711}, - {0.0,-0.70711}, {0.0, 0.0}, {-0.70711,0.0}, {0.0, 0.0}, - {0.0, 0.0}, {0.0,0.70711}, {0.0, 0.0}, {-0.70711,0.0}}; + {0.0, 0.0}, {0.70711,0.0}, {0.0, 0.0}, {0.0,0.70711}, + {0.0,-0.70711}, {0.0, 0.0}, {-0.70711,0.0}, {0.0, 0.0}, + {0.0, 0.0}, {0.0,0.70711}, {0.0, 0.0}, {-0.70711,0.0} +}; struct complex *R_sqrt_22_orth_eff_ch_TM4_prec_imag[1] = {R_sqrt_22_orth_eff_ch_TM4_prec_imag_tap}; //Correlation matrix for EPA channel struct complex R_sqrt_22_EPA_low_tap[16] = {{1.0,0.0}, {0.0,0.0}, {0.0,0.0}, {0.0,0.0}, - {0.0,0.0}, {1.0,0.0}, {0.0,0.0}, {0.0,0.0}, - {0.0,0.0}, {0.0,0.0}, {1.0,0.0}, {0.0,0.0}, - {0.0,0.0}, {0.0,0.0}, {0.0,0.0}, {1.0,0.0}}; + {0.0,0.0}, {1.0,0.0}, {0.0,0.0}, {0.0,0.0}, + {0.0,0.0}, {0.0,0.0}, {1.0,0.0}, {0.0,0.0}, + {0.0,0.0}, {0.0,0.0}, {0.0,0.0}, {1.0,0.0} +}; struct complex *R_sqrt_22_EPA_low[1] = {R_sqrt_22_EPA_low_tap}; -struct complex R_sqrt_22_EPA_high_tap[16] = {{0.7179,0.0}, {0.4500,0.0}, {0.4500,0.0}, {0.2821,0.0}, - {0.4500,0.0}, {0.7179,0.0}, {0.2821,0.0}, {0.4500,0.0}, - {0.4500,0.0}, {0.2821,0.0}, {0.7179,0.0}, {0.4500,0.0}, - {0.2821,0.0}, {0.4500,0.0}, {0.4500,0.0}, {0.7179,0.0}}; +struct complex R_sqrt_22_EPA_high_tap[16] = { + {0.7179,0.0}, {0.4500,0.0}, {0.4500,0.0}, {0.2821,0.0}, + {0.4500,0.0}, {0.7179,0.0}, {0.2821,0.0}, {0.4500,0.0}, + {0.4500,0.0}, {0.2821,0.0}, {0.7179,0.0}, {0.4500,0.0}, + {0.2821,0.0}, {0.4500,0.0}, {0.4500,0.0}, {0.7179,0.0} +}; struct complex *R_sqrt_22_EPA_high[1] = {R_sqrt_22_EPA_high_tap}; struct complex R_sqrt_22_EPA_medium_tap[16] = {{0.8375,0.0}, {0.5249,0.0}, {0.1286,0.0}, {0.0806,0.0}, - {0.5249,0.0}, {0.8375,0.0}, {0.0806,0.0}, {0.1286,0.0}, - {0.1286,0.0}, {0.0806,0.0}, {0.8375,0.0}, {0.5249,0.0}, - {0.0806,0.0}, {0.1286,0.0}, {0.5249,0.0}, {0.8375,0.0}}; + {0.5249,0.0}, {0.8375,0.0}, {0.0806,0.0}, {0.1286,0.0}, + {0.1286,0.0}, {0.0806,0.0}, {0.8375,0.0}, {0.5249,0.0}, + {0.0806,0.0}, {0.1286,0.0}, {0.5249,0.0}, {0.8375,0.0} +}; struct complex *R_sqrt_22_EPA_medium[1] = {R_sqrt_22_EPA_medium_tap}; @@ -250,15 +279,12 @@ channel_desc_t *new_channel_desc_scm(uint8_t nb_tx, double channel_bandwidth, double forgetting_factor, int32_t channel_offset, - double path_loss_dB) -{ - + double path_loss_dB) { channel_desc_t *chan_desc = (channel_desc_t *)malloc(sizeof(channel_desc_t)); uint16_t i,j; double sum_amps; double aoa,ricean_factor,Td,maxDoppler; int channel_length,nb_taps; - chan_desc->nb_tx = nb_tx; chan_desc->nb_rx = nb_rx; chan_desc->sampling_rate = sampling_rate; @@ -268,424 +294,514 @@ channel_desc_t *new_channel_desc_scm(uint8_t nb_tx, chan_desc->path_loss_dB = path_loss_dB; chan_desc->first_run = 1; chan_desc->ip = 0.0; - LOG_I(OCM,"Channel Model (inside of new_channel_desc_scm)=%d\n\n", channel_model); switch (channel_model) { - case SCM_A: - LOG_W(OCM,"channel model not yet supported\n"); - free(chan_desc); - return(NULL); - case SCM_B: - LOG_W(OCM,"channel model not yet supported\n"); - free(chan_desc); - return(NULL); - case SCM_C: - chan_desc->nb_taps = 18; - chan_desc->Td = 4.625; - chan_desc->channel_length = (int) (2*chan_desc->sampling_rate*chan_desc->Td + 1 + 2/(M_PI*M_PI)*log(4*M_PI*chan_desc->sampling_rate*chan_desc->Td)); - sum_amps = 0; - chan_desc->amps = (double*) malloc(chan_desc->nb_taps*sizeof(double)); - for (i = 0; inb_taps; i++) { - chan_desc->amps[i] = pow(10,.1*scm_c_amps_dB[i]); - sum_amps += chan_desc->amps[i]; - } - for (i = 0; inb_taps; i++) - chan_desc->amps[i] /= sum_amps; - chan_desc->delays = scm_c_delays; - chan_desc->ricean_factor = 1; - chan_desc->aoa = 0; - chan_desc->random_aoa = 0; - chan_desc->ch = (struct complex**) malloc(nb_tx*nb_rx*sizeof(struct complex*)); - chan_desc->chF = (struct complex**) malloc(nb_tx*nb_rx*sizeof(struct complex*)); - chan_desc->a = (struct complex**) malloc(chan_desc->nb_taps*sizeof(struct complex*)); - for (i = 0; ich[i] = (struct complex*) malloc(chan_desc->channel_length * sizeof(struct complex)); - for (i = 0; ichF[i] = (struct complex*) malloc(1200 * sizeof(struct complex)); - for (i = 0; inb_taps; i++) - chan_desc->a[i] = (struct complex*) malloc(nb_tx*nb_rx * sizeof(struct complex)); + case SCM_A: + LOG_W(OCM,"channel model not yet supported\n"); + free(chan_desc); + return(NULL); - chan_desc->R_sqrt = (struct complex**) malloc(6*sizeof(struct complex**)); - if (nb_tx==2 && nb_rx==2) { - for (i = 0; i<6; i++) - chan_desc->R_sqrt[i] = (struct complex*) &R22_sqrt[i][0]; - } - else if (nb_tx==2 && nb_rx==1) { - for (i = 0; i<6; i++) - chan_desc->R_sqrt[i] = (struct complex*) &R21_sqrt[i][0]; - } - else if (nb_tx==1 && nb_rx==2) { - for (i = 0; i<6; i++) - chan_desc->R_sqrt[i] = (struct complex*) &R12_sqrt[i][0]; - } - else { - for (i = 0; i<6; i++) { - chan_desc->R_sqrt[i] = (struct complex*) malloc(nb_tx*nb_rx*nb_tx*nb_rx * sizeof(struct complex)); - for (j = 0; jR_sqrt[i][j].x = 1.0; - chan_desc->R_sqrt[i][j].y = 0.0; - } - LOG_W(OCM,"correlation matrix not implemented for nb_tx==%d and nb_rx==%d, using identity\n", nb_tx, nb_rx); - } - } - break; - case SCM_D: - LOG_W(OCM,"This is not the real SCM-D model! It is just SCM-C with an additional Rice factor!\n"); - chan_desc->nb_taps = 18; - chan_desc->Td = 4.625; - chan_desc->channel_length = (int) (2*chan_desc->sampling_rate*chan_desc->Td + 1 + 2/(M_PI*M_PI)*log(4*M_PI*chan_desc->sampling_rate*chan_desc->Td)); - sum_amps = 0; - chan_desc->amps = (double*) malloc(chan_desc->nb_taps*sizeof(double)); - for (i = 0; inb_taps; i++) { - chan_desc->amps[i] = pow(10,.1*scm_c_amps_dB[i]); - sum_amps += chan_desc->amps[i]; - } - for (i = 0; inb_taps; i++) - chan_desc->amps[i] /= sum_amps; - chan_desc->delays = scm_c_delays; - chan_desc->ricean_factor = 0.1; - chan_desc->aoa = 0; - chan_desc->random_aoa = 0; - chan_desc->ch = (struct complex**) malloc(nb_tx*nb_rx*sizeof(struct complex*)); - chan_desc->chF = (struct complex**) malloc(nb_tx*nb_rx*sizeof(struct complex*)); - chan_desc->a = (struct complex**) malloc(chan_desc->nb_taps*sizeof(struct complex*)); - for (i = 0; ich[i] = (struct complex*) malloc(chan_desc->channel_length * sizeof(struct complex)); - for (i = 0; ichF[i] = (struct complex*) malloc(1200 * sizeof(struct complex)); - for (i = 0; inb_taps; i++) - chan_desc->a[i] = (struct complex*) malloc(nb_tx*nb_rx * sizeof(struct complex)); + case SCM_B: + LOG_W(OCM,"channel model not yet supported\n"); + free(chan_desc); + return(NULL); - chan_desc->R_sqrt = (struct complex**) malloc(6*sizeof(struct complex**)); - if (nb_tx==2 && nb_rx==2) { - for (i = 0; i<6; i++) - chan_desc->R_sqrt[i] = (struct complex*) &R22_sqrt[i][0]; - } - else if (nb_tx==2 && nb_rx==1) { - for (i = 0; i<6; i++) - chan_desc->R_sqrt[i] = (struct complex*) &R21_sqrt[i][0]; - } - else if (nb_tx==1 && nb_rx==2) { - for (i = 0; i<6; i++) - chan_desc->R_sqrt[i] = (struct complex*) &R12_sqrt[i][0]; - } - else { - for (i = 0; i<6; i++) { - chan_desc->R_sqrt[i] = (struct complex*) malloc(nb_tx*nb_rx*nb_tx*nb_rx * sizeof(struct complex)); - for (j = 0; jR_sqrt[i][j].x = 1.0; - chan_desc->R_sqrt[i][j].y = 0.0; - } - LOG_W(OCM,"correlation matrix not implemented for nb_tx==%d and nb_rx==%d, using identity\n", nb_tx, nb_rx); + case SCM_C: + chan_desc->nb_taps = 18; + chan_desc->Td = 4.625; + chan_desc->channel_length = (int) (2*chan_desc->sampling_rate*chan_desc->Td + 1 + 2/(M_PI*M_PI)*log(4*M_PI*chan_desc->sampling_rate*chan_desc->Td)); + sum_amps = 0; + chan_desc->amps = (double *) malloc(chan_desc->nb_taps*sizeof(double)); + + for (i = 0; inb_taps; i++) { + chan_desc->amps[i] = pow(10,.1*scm_c_amps_dB[i]); + sum_amps += chan_desc->amps[i]; } - } - break; - case EPA: - chan_desc->nb_taps = 7; - chan_desc->Td = .410; - chan_desc->channel_length = (int) (2*chan_desc->sampling_rate*chan_desc->Td + 1 + 2/(M_PI*M_PI)*log(4*M_PI*chan_desc->sampling_rate*chan_desc->Td)); - sum_amps = 0; - chan_desc->amps = (double*) malloc(chan_desc->nb_taps*sizeof(double)); - for (i = 0; inb_taps; i++) { - chan_desc->amps[i] = pow(10,.1*epa_amps_dB[i]); - sum_amps += chan_desc->amps[i]; - } - for (i = 0; inb_taps; i++) - chan_desc->amps[i] /= sum_amps; - chan_desc->delays = epa_delays; - chan_desc->ricean_factor = 1; - chan_desc->aoa = 0; - chan_desc->random_aoa = 0; - chan_desc->ch = (struct complex**) malloc(nb_tx*nb_rx*sizeof(struct complex*)); - chan_desc->chF = (struct complex**) malloc(nb_tx*nb_rx*sizeof(struct complex*)); - chan_desc->a = (struct complex**) malloc(chan_desc->nb_taps*sizeof(struct complex*)); - for (i = 0; ich[i] = (struct complex*) malloc(chan_desc->channel_length * sizeof(struct complex)); - for (i = 0; ichF[i] = (struct complex*) malloc(1200 * sizeof(struct complex)); - for (i = 0; inb_taps; i++) - chan_desc->a[i] = (struct complex*) malloc(nb_tx*nb_rx * sizeof(struct complex)); - if (nb_tx==2 && nb_rx==2) { - chan_desc->R_sqrt = (struct complex**) malloc(6*sizeof(struct complex**)); - for (i = 0; i<6; i++) - chan_desc->R_sqrt[i] = (struct complex*) &R22_sqrt[i][0]; - } - else { - chan_desc->R_sqrt = (struct complex**) malloc(6*sizeof(struct complex**)); - for (i = 0; i<6; i++) { - chan_desc->R_sqrt[i] = (struct complex*) malloc(nb_tx*nb_rx*nb_tx*nb_rx * sizeof(struct complex)); - for (j = 0; jR_sqrt[i][j].x = 1.0; - chan_desc->R_sqrt[i][j].y = 0.0; - } - LOG_W(OCM,"correlation matrix only implemented for nb_tx==2 and nb_rx==2, using identity\n"); - } - } - break; - case EPA_low: - chan_desc->nb_taps = 7; - chan_desc->Td = .410; - chan_desc->channel_length = (int) (2*chan_desc->sampling_rate*chan_desc->Td + 1 + 2/(M_PI*M_PI)*log(4*M_PI*chan_desc->sampling_rate*chan_desc->Td)); - sum_amps = 0; - chan_desc->amps = (double*) malloc(chan_desc->nb_taps*sizeof(double)); - for (i = 0; inb_taps; i++) { - chan_desc->amps[i] = pow(10,.1*epa_amps_dB[i]); - sum_amps += chan_desc->amps[i]; - } - for (i = 0; inb_taps; i++) - chan_desc->amps[i] /= sum_amps; - chan_desc->delays = epa_delays; - chan_desc->ricean_factor = 1; - chan_desc->aoa = 0; - chan_desc->random_aoa = 0; - chan_desc->ch = (struct complex**) malloc(nb_tx*nb_rx*sizeof(struct complex*)); - chan_desc->chF = (struct complex**) malloc(nb_tx*nb_rx*sizeof(struct complex*)); - chan_desc->a = (struct complex**) malloc(chan_desc->nb_taps*sizeof(struct complex*)); - for (i = 0; ich[i] = (struct complex*) malloc(chan_desc->channel_length * sizeof(struct complex)); - for (i = 0; ichF[i] = (struct complex*) malloc(1200 * sizeof(struct complex)); - for (i = 0; inb_taps; i++) - chan_desc->a[i] = (struct complex*) malloc(nb_tx*nb_rx * sizeof(struct complex)); - if (nb_tx==2 && nb_rx==2) { - chan_desc->R_sqrt = (struct complex**) malloc(chan_desc->nb_taps*sizeof(struct complex**)); + for (i = 0; inb_taps; i++) - chan_desc->R_sqrt[i] = R_sqrt_22_EPA_low[0]; - } - else { - printf("Correlation matrices are implemented for 2 x 2 only"); - } - /*else { - chan_desc->R_sqrt = (struct complex**) malloc(6*sizeof(struct complex**)); - for (i = 0; i<6; i++) { - chan_desc->R_sqrt[i] = (struct complex*) malloc(nb_tx*nb_rx*nb_tx*nb_rx * sizeof(struct complex)); - for (j = 0; jR_sqrt[i][j].x = 1.0; - chan_desc->R_sqrt[i][j].y = 0.0; - } - LOG_W(OCM,"correlation matrix only implemented for nb_tx==2 and nb_rx==2, using identity\n"); - } - }*/ - break; - case EPA_high: - chan_desc->nb_taps = 7; - chan_desc->Td = .410; - chan_desc->channel_length = (int) (2*chan_desc->sampling_rate*chan_desc->Td + 1 + 2/(M_PI*M_PI)*log(4*M_PI*chan_desc->sampling_rate*chan_desc->Td)); - sum_amps = 0; - chan_desc->amps = (double*) malloc(chan_desc->nb_taps*sizeof(double)); - for (i = 0; inb_taps; i++) { - chan_desc->amps[i] = pow(10,.1*epa_amps_dB[i]); - sum_amps += chan_desc->amps[i]; - } - for (i = 0; inb_taps; i++) - chan_desc->amps[i] /= sum_amps; - chan_desc->delays = epa_delays; - chan_desc->ricean_factor = 1; - chan_desc->aoa = 0; - chan_desc->random_aoa = 0; - chan_desc->ch = (struct complex**) malloc(nb_tx*nb_rx*sizeof(struct complex*)); - chan_desc->chF = (struct complex**) malloc(nb_tx*nb_rx*sizeof(struct complex*)); - chan_desc->a = (struct complex**) malloc(chan_desc->nb_taps*sizeof(struct complex*)); - for (i = 0; ich[i] = (struct complex*) malloc(chan_desc->channel_length * sizeof(struct complex)); - for (i = 0; ichF[i] = (struct complex*) malloc(1200 * sizeof(struct complex)); - for (i = 0; inb_taps; i++) - chan_desc->a[i] = (struct complex*) malloc(nb_tx*nb_rx * sizeof(struct complex)); - if (nb_tx==2 && nb_rx==2) { - chan_desc->R_sqrt = (struct complex**) malloc(chan_desc->nb_taps*sizeof(struct complex**)); + chan_desc->amps[i] /= sum_amps; + + chan_desc->delays = scm_c_delays; + chan_desc->ricean_factor = 1; + chan_desc->aoa = 0; + chan_desc->random_aoa = 0; + chan_desc->ch = (struct complex **) malloc(nb_tx*nb_rx*sizeof(struct complex *)); + chan_desc->chF = (struct complex **) malloc(nb_tx*nb_rx*sizeof(struct complex *)); + chan_desc->a = (struct complex **) malloc(chan_desc->nb_taps*sizeof(struct complex *)); + + for (i = 0; ich[i] = (struct complex *) malloc(chan_desc->channel_length * sizeof(struct complex)); + + for (i = 0; ichF[i] = (struct complex *) malloc(1200 * sizeof(struct complex)); + for (i = 0; inb_taps; i++) - chan_desc->R_sqrt[i] = R_sqrt_22_EPA_high[0]; - } - else { - printf("Correlation matrices are implemented for 2 x 2 only"); - } - /*else { - chan_desc->R_sqrt = (struct complex**) malloc(6*sizeof(struct complex**)); - for (i = 0; i<6; i++) { - chan_desc->R_sqrt[i] = (struct complex*) malloc(nb_tx*nb_rx*nb_tx*nb_rx * sizeof(struct complex)); - for (j = 0; jR_sqrt[i][j].x = 1.0; - chan_desc->R_sqrt[i][j].y = 0.0; + chan_desc->a[i] = (struct complex *) malloc(nb_tx*nb_rx * sizeof(struct complex)); + + chan_desc->R_sqrt = (struct complex **) malloc(6*sizeof(struct complex **)); + + if (nb_tx==2 && nb_rx==2) { + for (i = 0; i<6; i++) + chan_desc->R_sqrt[i] = (struct complex *) &R22_sqrt[i][0]; + } else if (nb_tx==2 && nb_rx==1) { + for (i = 0; i<6; i++) + chan_desc->R_sqrt[i] = (struct complex *) &R21_sqrt[i][0]; + } else if (nb_tx==1 && nb_rx==2) { + for (i = 0; i<6; i++) + chan_desc->R_sqrt[i] = (struct complex *) &R12_sqrt[i][0]; + } else { + for (i = 0; i<6; i++) { + chan_desc->R_sqrt[i] = (struct complex *) malloc(nb_tx*nb_rx*nb_tx*nb_rx * sizeof(struct complex)); + + for (j = 0; jR_sqrt[i][j].x = 1.0; + chan_desc->R_sqrt[i][j].y = 0.0; + } + + LOG_W(OCM,"correlation matrix not implemented for nb_tx==%d and nb_rx==%d, using identity\n", nb_tx, nb_rx); } - LOG_W(OCM,"correlation matrix only implemented for nb_tx==2 and nb_rx==2, using identity\n"); } - }*/ - break; + + break; + + case SCM_D: + LOG_W(OCM,"This is not the real SCM-D model! It is just SCM-C with an additional Rice factor!\n"); + chan_desc->nb_taps = 18; + chan_desc->Td = 4.625; + chan_desc->channel_length = (int) (2*chan_desc->sampling_rate*chan_desc->Td + 1 + 2/(M_PI*M_PI)*log(4*M_PI*chan_desc->sampling_rate*chan_desc->Td)); + sum_amps = 0; + chan_desc->amps = (double *) malloc(chan_desc->nb_taps*sizeof(double)); + + for (i = 0; inb_taps; i++) { + chan_desc->amps[i] = pow(10,.1*scm_c_amps_dB[i]); + sum_amps += chan_desc->amps[i]; + } + + for (i = 0; inb_taps; i++) + chan_desc->amps[i] /= sum_amps; + + chan_desc->delays = scm_c_delays; + chan_desc->ricean_factor = 0.1; + chan_desc->aoa = 0; + chan_desc->random_aoa = 0; + chan_desc->ch = (struct complex **) malloc(nb_tx*nb_rx*sizeof(struct complex *)); + chan_desc->chF = (struct complex **) malloc(nb_tx*nb_rx*sizeof(struct complex *)); + chan_desc->a = (struct complex **) malloc(chan_desc->nb_taps*sizeof(struct complex *)); + + for (i = 0; ich[i] = (struct complex *) malloc(chan_desc->channel_length * sizeof(struct complex)); + + for (i = 0; ichF[i] = (struct complex *) malloc(1200 * sizeof(struct complex)); + + for (i = 0; inb_taps; i++) + chan_desc->a[i] = (struct complex *) malloc(nb_tx*nb_rx * sizeof(struct complex)); + + chan_desc->R_sqrt = (struct complex **) malloc(6*sizeof(struct complex **)); + + if (nb_tx==2 && nb_rx==2) { + for (i = 0; i<6; i++) + chan_desc->R_sqrt[i] = (struct complex *) &R22_sqrt[i][0]; + } else if (nb_tx==2 && nb_rx==1) { + for (i = 0; i<6; i++) + chan_desc->R_sqrt[i] = (struct complex *) &R21_sqrt[i][0]; + } else if (nb_tx==1 && nb_rx==2) { + for (i = 0; i<6; i++) + chan_desc->R_sqrt[i] = (struct complex *) &R12_sqrt[i][0]; + } else { + for (i = 0; i<6; i++) { + chan_desc->R_sqrt[i] = (struct complex *) malloc(nb_tx*nb_rx*nb_tx*nb_rx * sizeof(struct complex)); + + for (j = 0; jR_sqrt[i][j].x = 1.0; + chan_desc->R_sqrt[i][j].y = 0.0; + } + + LOG_W(OCM,"correlation matrix not implemented for nb_tx==%d and nb_rx==%d, using identity\n", nb_tx, nb_rx); + } + } + + break; + + case EPA: + chan_desc->nb_taps = 7; + chan_desc->Td = .410; + chan_desc->channel_length = (int) (2*chan_desc->sampling_rate*chan_desc->Td + 1 + 2/(M_PI*M_PI)*log(4*M_PI*chan_desc->sampling_rate*chan_desc->Td)); + sum_amps = 0; + chan_desc->amps = (double *) malloc(chan_desc->nb_taps*sizeof(double)); + + for (i = 0; inb_taps; i++) { + chan_desc->amps[i] = pow(10,.1*epa_amps_dB[i]); + sum_amps += chan_desc->amps[i]; + } + + for (i = 0; inb_taps; i++) + chan_desc->amps[i] /= sum_amps; + + chan_desc->delays = epa_delays; + chan_desc->ricean_factor = 1; + chan_desc->aoa = 0; + chan_desc->random_aoa = 0; + chan_desc->ch = (struct complex **) malloc(nb_tx*nb_rx*sizeof(struct complex *)); + chan_desc->chF = (struct complex **) malloc(nb_tx*nb_rx*sizeof(struct complex *)); + chan_desc->a = (struct complex **) malloc(chan_desc->nb_taps*sizeof(struct complex *)); + + for (i = 0; ich[i] = (struct complex *) malloc(chan_desc->channel_length * sizeof(struct complex)); + + for (i = 0; ichF[i] = (struct complex *) malloc(1200 * sizeof(struct complex)); + + for (i = 0; inb_taps; i++) + chan_desc->a[i] = (struct complex *) malloc(nb_tx*nb_rx * sizeof(struct complex)); + + if (nb_tx==2 && nb_rx==2) { + chan_desc->R_sqrt = (struct complex **) malloc(6*sizeof(struct complex **)); + + for (i = 0; i<6; i++) + chan_desc->R_sqrt[i] = (struct complex *) &R22_sqrt[i][0]; + } else { + chan_desc->R_sqrt = (struct complex **) malloc(6*sizeof(struct complex **)); + + for (i = 0; i<6; i++) { + chan_desc->R_sqrt[i] = (struct complex *) malloc(nb_tx*nb_rx*nb_tx*nb_rx * sizeof(struct complex)); + + for (j = 0; jR_sqrt[i][j].x = 1.0; + chan_desc->R_sqrt[i][j].y = 0.0; + } + + LOG_W(OCM,"correlation matrix only implemented for nb_tx==2 and nb_rx==2, using identity\n"); + } + } + + break; + + case EPA_low: + chan_desc->nb_taps = 7; + chan_desc->Td = .410; + chan_desc->channel_length = (int) (2*chan_desc->sampling_rate*chan_desc->Td + 1 + 2/(M_PI*M_PI)*log(4*M_PI*chan_desc->sampling_rate*chan_desc->Td)); + sum_amps = 0; + chan_desc->amps = (double *) malloc(chan_desc->nb_taps*sizeof(double)); + + for (i = 0; inb_taps; i++) { + chan_desc->amps[i] = pow(10,.1*epa_amps_dB[i]); + sum_amps += chan_desc->amps[i]; + } + + for (i = 0; inb_taps; i++) + chan_desc->amps[i] /= sum_amps; + + chan_desc->delays = epa_delays; + chan_desc->ricean_factor = 1; + chan_desc->aoa = 0; + chan_desc->random_aoa = 0; + chan_desc->ch = (struct complex **) malloc(nb_tx*nb_rx*sizeof(struct complex *)); + chan_desc->chF = (struct complex **) malloc(nb_tx*nb_rx*sizeof(struct complex *)); + chan_desc->a = (struct complex **) malloc(chan_desc->nb_taps*sizeof(struct complex *)); + + for (i = 0; ich[i] = (struct complex *) malloc(chan_desc->channel_length * sizeof(struct complex)); + + for (i = 0; ichF[i] = (struct complex *) malloc(1200 * sizeof(struct complex)); + + for (i = 0; inb_taps; i++) + chan_desc->a[i] = (struct complex *) malloc(nb_tx*nb_rx * sizeof(struct complex)); + + if (nb_tx==2 && nb_rx==2) { + chan_desc->R_sqrt = (struct complex **) malloc(chan_desc->nb_taps*sizeof(struct complex **)); + + for (i = 0; inb_taps; i++) + chan_desc->R_sqrt[i] = R_sqrt_22_EPA_low[0]; + } else { + printf("Correlation matrices are implemented for 2 x 2 only"); + } + + /*else { + chan_desc->R_sqrt = (struct complex**) malloc(6*sizeof(struct complex**)); + for (i = 0; i<6; i++) { + chan_desc->R_sqrt[i] = (struct complex*) malloc(nb_tx*nb_rx*nb_tx*nb_rx * sizeof(struct complex)); + for (j = 0; jR_sqrt[i][j].x = 1.0; + chan_desc->R_sqrt[i][j].y = 0.0; + } + LOG_W(OCM,"correlation matrix only implemented for nb_tx==2 and nb_rx==2, using identity\n"); + } + }*/ + break; + + case EPA_high: + chan_desc->nb_taps = 7; + chan_desc->Td = .410; + chan_desc->channel_length = (int) (2*chan_desc->sampling_rate*chan_desc->Td + 1 + 2/(M_PI*M_PI)*log(4*M_PI*chan_desc->sampling_rate*chan_desc->Td)); + sum_amps = 0; + chan_desc->amps = (double *) malloc(chan_desc->nb_taps*sizeof(double)); + + for (i = 0; inb_taps; i++) { + chan_desc->amps[i] = pow(10,.1*epa_amps_dB[i]); + sum_amps += chan_desc->amps[i]; + } + + for (i = 0; inb_taps; i++) + chan_desc->amps[i] /= sum_amps; + + chan_desc->delays = epa_delays; + chan_desc->ricean_factor = 1; + chan_desc->aoa = 0; + chan_desc->random_aoa = 0; + chan_desc->ch = (struct complex **) malloc(nb_tx*nb_rx*sizeof(struct complex *)); + chan_desc->chF = (struct complex **) malloc(nb_tx*nb_rx*sizeof(struct complex *)); + chan_desc->a = (struct complex **) malloc(chan_desc->nb_taps*sizeof(struct complex *)); + + for (i = 0; ich[i] = (struct complex *) malloc(chan_desc->channel_length * sizeof(struct complex)); + + for (i = 0; ichF[i] = (struct complex *) malloc(1200 * sizeof(struct complex)); + + for (i = 0; inb_taps; i++) + chan_desc->a[i] = (struct complex *) malloc(nb_tx*nb_rx * sizeof(struct complex)); + + if (nb_tx==2 && nb_rx==2) { + chan_desc->R_sqrt = (struct complex **) malloc(chan_desc->nb_taps*sizeof(struct complex **)); + + for (i = 0; inb_taps; i++) + chan_desc->R_sqrt[i] = R_sqrt_22_EPA_high[0]; + } else { + printf("Correlation matrices are implemented for 2 x 2 only"); + } + + /*else { + chan_desc->R_sqrt = (struct complex**) malloc(6*sizeof(struct complex**)); + for (i = 0; i<6; i++) { + chan_desc->R_sqrt[i] = (struct complex*) malloc(nb_tx*nb_rx*nb_tx*nb_rx * sizeof(struct complex)); + for (j = 0; jR_sqrt[i][j].x = 1.0; + chan_desc->R_sqrt[i][j].y = 0.0; + } + LOG_W(OCM,"correlation matrix only implemented for nb_tx==2 and nb_rx==2, using identity\n"); + } + }*/ + break; + case EPA_medium: - chan_desc->nb_taps = 7; - chan_desc->Td = .410; - chan_desc->channel_length = (int) (2*chan_desc->sampling_rate*chan_desc->Td + 1 + 2/(M_PI*M_PI)*log(4*M_PI*chan_desc->sampling_rate*chan_desc->Td)); - sum_amps = 0; - chan_desc->amps = (double*) malloc(chan_desc->nb_taps*sizeof(double)); - for (i = 0; inb_taps; i++) { - chan_desc->amps[i] = pow(10,.1*epa_amps_dB[i]); - sum_amps += chan_desc->amps[i]; - } - for (i = 0; inb_taps; i++) - chan_desc->amps[i] /= sum_amps; - chan_desc->delays = epa_delays; - chan_desc->ricean_factor = 1; - chan_desc->aoa = 0; - chan_desc->random_aoa = 0; - chan_desc->ch = (struct complex**) malloc(nb_tx*nb_rx*sizeof(struct complex*)); - chan_desc->chF = (struct complex**) malloc(nb_tx*nb_rx*sizeof(struct complex*)); - chan_desc->a = (struct complex**) malloc(chan_desc->nb_taps*sizeof(struct complex*)); - for (i = 0; ich[i] = (struct complex*) malloc(chan_desc->channel_length * sizeof(struct complex)); - for (i = 0; ichF[i] = (struct complex*) malloc(1200 * sizeof(struct complex)); - for (i = 0; inb_taps; i++) - chan_desc->a[i] = (struct complex*) malloc(nb_tx*nb_rx * sizeof(struct complex)); - if (nb_tx==2 && nb_rx==2) { - chan_desc->R_sqrt = (struct complex**) malloc(chan_desc->nb_taps*sizeof(struct complex**)); + chan_desc->nb_taps = 7; + chan_desc->Td = .410; + chan_desc->channel_length = (int) (2*chan_desc->sampling_rate*chan_desc->Td + 1 + 2/(M_PI*M_PI)*log(4*M_PI*chan_desc->sampling_rate*chan_desc->Td)); + sum_amps = 0; + chan_desc->amps = (double *) malloc(chan_desc->nb_taps*sizeof(double)); + + for (i = 0; inb_taps; i++) { + chan_desc->amps[i] = pow(10,.1*epa_amps_dB[i]); + sum_amps += chan_desc->amps[i]; + } + for (i = 0; inb_taps; i++) - chan_desc->R_sqrt[i] = R_sqrt_22_EPA_medium[0]; - } else { - printf("Correlation matrices are implemented for 2 x 2 only"); - } - /*else { - chan_desc->R_sqrt = (struct complex**) malloc(6*sizeof(struct complex**)); - for (i = 0; i<6; i++) { - chan_desc->R_sqrt[i] = (struct complex*) malloc(nb_tx*nb_rx*nb_tx*nb_rx * sizeof(struct complex)); - for (j = 0; jR_sqrt[i][j].x = 1.0; - chan_desc->R_sqrt[i][j].y = 0.0; - } - LOG_W(OCM,"correlation matrix only implemented for nb_tx==2 and nb_rx==2, using identity\n"); - } - }*/ - break; - case EVA: - chan_desc->nb_taps = 9; - chan_desc->Td = 2.51; - chan_desc->channel_length = (int) (2*chan_desc->sampling_rate*chan_desc->Td + 1 + 2/(M_PI*M_PI)*log(4*M_PI*chan_desc->sampling_rate*chan_desc->Td)); - sum_amps = 0; - chan_desc->amps = (double*) malloc(chan_desc->nb_taps*sizeof(double)); - for (i = 0; inb_taps; i++) { - chan_desc->amps[i] = pow(10,.1*eva_amps_dB[i]); - sum_amps += chan_desc->amps[i]; - } - for (i = 0; inb_taps; i++) - chan_desc->amps[i] /= sum_amps; - chan_desc->delays = eva_delays; - chan_desc->ricean_factor = 1; - chan_desc->aoa = 0; - chan_desc->random_aoa = 0; - chan_desc->ch = (struct complex**) malloc(nb_tx*nb_rx*sizeof(struct complex*)); - chan_desc->chF = (struct complex**) malloc(nb_tx*nb_rx*sizeof(struct complex*)); - chan_desc->a = (struct complex**) malloc(chan_desc->nb_taps*sizeof(struct complex*)); - for (i = 0; ich[i] = (struct complex*) malloc(chan_desc->channel_length * sizeof(struct complex)); - for (i = 0; ichF[i] = (struct complex*) malloc(1200 * sizeof(struct complex)); - for (i = 0; inb_taps; i++) - chan_desc->a[i] = (struct complex*) malloc(nb_tx*nb_rx * sizeof(struct complex)); - if (nb_tx==2 && nb_rx==2) { - chan_desc->R_sqrt = (struct complex**) malloc(6*sizeof(struct complex**)); - for (i = 0; i<6; i++) - chan_desc->R_sqrt[i] = (struct complex*) &R22_sqrt[i][0]; - } - else { - chan_desc->R_sqrt = (struct complex**) malloc(6*sizeof(struct complex**)); - for (i = 0; i<6; i++) { - chan_desc->R_sqrt[i] = (struct complex*) malloc(nb_tx*nb_rx*nb_tx*nb_rx * sizeof(struct complex)); - for (j = 0; jR_sqrt[i][j].x = 1.0; - chan_desc->R_sqrt[i][j].y = 0.0; - } - LOG_W(OCM,"correlation matrix only implemented for nb_tx==2 and nb_rx==2, using identity\n"); - } - } - break; - case ETU: - chan_desc->nb_taps = 9; - chan_desc->Td = 5.0; - chan_desc->channel_length = (int) (2*chan_desc->sampling_rate*chan_desc->Td + 1 + 2/(M_PI*M_PI)*log(4*M_PI*chan_desc->sampling_rate*chan_desc->Td)); - sum_amps = 0; - chan_desc->amps = (double*) malloc(chan_desc->nb_taps*sizeof(double)); - for (i = 0; inb_taps; i++) { - chan_desc->amps[i] = pow(10,.1*etu_amps_dB[i]); - sum_amps += chan_desc->amps[i]; - } - for (i = 0; inb_taps; i++) - chan_desc->amps[i] /= sum_amps; - chan_desc->delays = etu_delays; - chan_desc->ricean_factor = 1; - chan_desc->aoa = 0; - chan_desc->random_aoa = 0; - chan_desc->ch = (struct complex**) malloc(nb_tx*nb_rx*sizeof(struct complex*)); - chan_desc->chF = (struct complex**) malloc(nb_tx*nb_rx*sizeof(struct complex*)); - chan_desc->a = (struct complex**) malloc(chan_desc->nb_taps*sizeof(struct complex*)); - for (i = 0; ich[i] = (struct complex*) malloc(chan_desc->channel_length * sizeof(struct complex)); - for (i = 0; ichF[i] = (struct complex*) malloc(1200 * sizeof(struct complex)); - for (i = 0; inb_taps; i++) - chan_desc->a[i] = (struct complex*) malloc(nb_tx*nb_rx * sizeof(struct complex)); - if (nb_tx==2 && nb_rx==2) { - chan_desc->R_sqrt = (struct complex**) malloc(6*sizeof(struct complex**)); - for (i = 0; i<6; i++) - chan_desc->R_sqrt[i] = (struct complex*) &R22_sqrt[i][0]; - } - else { - chan_desc->R_sqrt = (struct complex**) malloc(6*sizeof(struct complex**)); - for (i = 0; i<6; i++) { - chan_desc->R_sqrt[i] = (struct complex*) malloc(nb_tx*nb_rx*nb_tx*nb_rx * sizeof(struct complex)); - for (j = 0; jR_sqrt[i][j].x = 1.0; - chan_desc->R_sqrt[i][j].y = 0.0; - } - LOG_W(OCM,"correlation matrix only implemented for nb_tx==2 and nb_rx==2, using identity\n"); - } - } - break; - case MBSFN: - chan_desc->nb_taps = 18; - chan_desc->Td = 28.58; - chan_desc->channel_length = (int) (2*chan_desc->sampling_rate*chan_desc->Td + 1 + 2/(M_PI*M_PI)*log(4*M_PI*chan_desc->sampling_rate*chan_desc->Td)); - sum_amps = 0; - chan_desc->amps = (double*) malloc(chan_desc->nb_taps*sizeof(double)); - for (i = 0; inb_taps; i++) { - chan_desc->amps[i] = pow(10,.1*mbsfn_amps_dB[i]); - sum_amps += chan_desc->amps[i]; - } - for (i = 0; inb_taps; i++) - chan_desc->amps[i] /= sum_amps; - chan_desc->delays = mbsfn_delays; - chan_desc->ricean_factor = 1; - chan_desc->aoa = 0; - chan_desc->random_aoa = 0; - chan_desc->ch = (struct complex**) malloc(nb_tx*nb_rx*sizeof(struct complex*)); - chan_desc->chF = (struct complex**) malloc(nb_tx*nb_rx*sizeof(struct complex*)); - chan_desc->a = (struct complex**) malloc(chan_desc->nb_taps*sizeof(struct complex*)); - for (i = 0; ich[i] = (struct complex*) malloc(chan_desc->channel_length * sizeof(struct complex)); - for (i = 0; ichF[i] = (struct complex*) malloc(1200 * sizeof(struct complex)); - for (i = 0; inb_taps; i++) - chan_desc->a[i] = (struct complex*) malloc(nb_tx*nb_rx * sizeof(struct complex)); + chan_desc->amps[i] /= sum_amps; - chan_desc->R_sqrt = (struct complex**) malloc(6*sizeof(struct complex*)); - for (i = 0; i<6; i++) { - chan_desc->R_sqrt[i] = (struct complex*) malloc(nb_tx*nb_rx*nb_tx*nb_rx * sizeof(struct complex)); - for (j = 0; jR_sqrt[i][j].x = 1.0; - chan_desc->R_sqrt[i][j].y = 0.0; - } - LOG_W(OCM,"correlation matrix only implemented for nb_tx==2 and nb_rx==2, using identity\n"); - } - break; - case Rayleigh8: + chan_desc->delays = epa_delays; + chan_desc->ricean_factor = 1; + chan_desc->aoa = 0; + chan_desc->random_aoa = 0; + chan_desc->ch = (struct complex **) malloc(nb_tx*nb_rx*sizeof(struct complex *)); + chan_desc->chF = (struct complex **) malloc(nb_tx*nb_rx*sizeof(struct complex *)); + chan_desc->a = (struct complex **) malloc(chan_desc->nb_taps*sizeof(struct complex *)); + for (i = 0; ich[i] = (struct complex *) malloc(chan_desc->channel_length * sizeof(struct complex)); + + for (i = 0; ichF[i] = (struct complex *) malloc(1200 * sizeof(struct complex)); + + for (i = 0; inb_taps; i++) + chan_desc->a[i] = (struct complex *) malloc(nb_tx*nb_rx * sizeof(struct complex)); + + if (nb_tx==2 && nb_rx==2) { + chan_desc->R_sqrt = (struct complex **) malloc(chan_desc->nb_taps*sizeof(struct complex **)); + + for (i = 0; inb_taps; i++) + chan_desc->R_sqrt[i] = R_sqrt_22_EPA_medium[0]; + } else { + printf("Correlation matrices are implemented for 2 x 2 only"); + } + + /*else { + chan_desc->R_sqrt = (struct complex**) malloc(6*sizeof(struct complex**)); + for (i = 0; i<6; i++) { + chan_desc->R_sqrt[i] = (struct complex*) malloc(nb_tx*nb_rx*nb_tx*nb_rx * sizeof(struct complex)); + for (j = 0; jR_sqrt[i][j].x = 1.0; + chan_desc->R_sqrt[i][j].y = 0.0; + } + LOG_W(OCM,"correlation matrix only implemented for nb_tx==2 and nb_rx==2, using identity\n"); + } + }*/ + break; + + case EVA: + chan_desc->nb_taps = 9; + chan_desc->Td = 2.51; + chan_desc->channel_length = (int) (2*chan_desc->sampling_rate*chan_desc->Td + 1 + 2/(M_PI*M_PI)*log(4*M_PI*chan_desc->sampling_rate*chan_desc->Td)); + sum_amps = 0; + chan_desc->amps = (double *) malloc(chan_desc->nb_taps*sizeof(double)); + + for (i = 0; inb_taps; i++) { + chan_desc->amps[i] = pow(10,.1*eva_amps_dB[i]); + sum_amps += chan_desc->amps[i]; + } + + for (i = 0; inb_taps; i++) + chan_desc->amps[i] /= sum_amps; + + chan_desc->delays = eva_delays; + chan_desc->ricean_factor = 1; + chan_desc->aoa = 0; + chan_desc->random_aoa = 0; + chan_desc->ch = (struct complex **) malloc(nb_tx*nb_rx*sizeof(struct complex *)); + chan_desc->chF = (struct complex **) malloc(nb_tx*nb_rx*sizeof(struct complex *)); + chan_desc->a = (struct complex **) malloc(chan_desc->nb_taps*sizeof(struct complex *)); + + for (i = 0; ich[i] = (struct complex *) malloc(chan_desc->channel_length * sizeof(struct complex)); + + for (i = 0; ichF[i] = (struct complex *) malloc(1200 * sizeof(struct complex)); + + for (i = 0; inb_taps; i++) + chan_desc->a[i] = (struct complex *) malloc(nb_tx*nb_rx * sizeof(struct complex)); + + if (nb_tx==2 && nb_rx==2) { + chan_desc->R_sqrt = (struct complex **) malloc(6*sizeof(struct complex **)); + + for (i = 0; i<6; i++) + chan_desc->R_sqrt[i] = (struct complex *) &R22_sqrt[i][0]; + } else { + chan_desc->R_sqrt = (struct complex **) malloc(6*sizeof(struct complex **)); + + for (i = 0; i<6; i++) { + chan_desc->R_sqrt[i] = (struct complex *) malloc(nb_tx*nb_rx*nb_tx*nb_rx * sizeof(struct complex)); + + for (j = 0; jR_sqrt[i][j].x = 1.0; + chan_desc->R_sqrt[i][j].y = 0.0; + } + + LOG_W(OCM,"correlation matrix only implemented for nb_tx==2 and nb_rx==2, using identity\n"); + } + } + + break; + + case ETU: + chan_desc->nb_taps = 9; + chan_desc->Td = 5.0; + chan_desc->channel_length = (int) (2*chan_desc->sampling_rate*chan_desc->Td + 1 + 2/(M_PI*M_PI)*log(4*M_PI*chan_desc->sampling_rate*chan_desc->Td)); + sum_amps = 0; + chan_desc->amps = (double *) malloc(chan_desc->nb_taps*sizeof(double)); + + for (i = 0; inb_taps; i++) { + chan_desc->amps[i] = pow(10,.1*etu_amps_dB[i]); + sum_amps += chan_desc->amps[i]; + } + + for (i = 0; inb_taps; i++) + chan_desc->amps[i] /= sum_amps; + + chan_desc->delays = etu_delays; + chan_desc->ricean_factor = 1; + chan_desc->aoa = 0; + chan_desc->random_aoa = 0; + chan_desc->ch = (struct complex **) malloc(nb_tx*nb_rx*sizeof(struct complex *)); + chan_desc->chF = (struct complex **) malloc(nb_tx*nb_rx*sizeof(struct complex *)); + chan_desc->a = (struct complex **) malloc(chan_desc->nb_taps*sizeof(struct complex *)); + + for (i = 0; ich[i] = (struct complex *) malloc(chan_desc->channel_length * sizeof(struct complex)); + + for (i = 0; ichF[i] = (struct complex *) malloc(1200 * sizeof(struct complex)); + + for (i = 0; inb_taps; i++) + chan_desc->a[i] = (struct complex *) malloc(nb_tx*nb_rx * sizeof(struct complex)); + + if (nb_tx==2 && nb_rx==2) { + chan_desc->R_sqrt = (struct complex **) malloc(6*sizeof(struct complex **)); + + for (i = 0; i<6; i++) + chan_desc->R_sqrt[i] = (struct complex *) &R22_sqrt[i][0]; + } else { + chan_desc->R_sqrt = (struct complex **) malloc(6*sizeof(struct complex **)); + + for (i = 0; i<6; i++) { + chan_desc->R_sqrt[i] = (struct complex *) malloc(nb_tx*nb_rx*nb_tx*nb_rx * sizeof(struct complex)); + + for (j = 0; jR_sqrt[i][j].x = 1.0; + chan_desc->R_sqrt[i][j].y = 0.0; + } + + LOG_W(OCM,"correlation matrix only implemented for nb_tx==2 and nb_rx==2, using identity\n"); + } + } + + break; + + case MBSFN: + chan_desc->nb_taps = 18; + chan_desc->Td = 28.58; + chan_desc->channel_length = (int) (2*chan_desc->sampling_rate*chan_desc->Td + 1 + 2/(M_PI*M_PI)*log(4*M_PI*chan_desc->sampling_rate*chan_desc->Td)); + sum_amps = 0; + chan_desc->amps = (double *) malloc(chan_desc->nb_taps*sizeof(double)); + + for (i = 0; inb_taps; i++) { + chan_desc->amps[i] = pow(10,.1*mbsfn_amps_dB[i]); + sum_amps += chan_desc->amps[i]; + } + + for (i = 0; inb_taps; i++) + chan_desc->amps[i] /= sum_amps; + + chan_desc->delays = mbsfn_delays; + chan_desc->ricean_factor = 1; + chan_desc->aoa = 0; + chan_desc->random_aoa = 0; + chan_desc->ch = (struct complex **) malloc(nb_tx*nb_rx*sizeof(struct complex *)); + chan_desc->chF = (struct complex **) malloc(nb_tx*nb_rx*sizeof(struct complex *)); + chan_desc->a = (struct complex **) malloc(chan_desc->nb_taps*sizeof(struct complex *)); + + for (i = 0; ich[i] = (struct complex *) malloc(chan_desc->channel_length * sizeof(struct complex)); + + for (i = 0; ichF[i] = (struct complex *) malloc(1200 * sizeof(struct complex)); + + for (i = 0; inb_taps; i++) + chan_desc->a[i] = (struct complex *) malloc(nb_tx*nb_rx * sizeof(struct complex)); + + chan_desc->R_sqrt = (struct complex **) malloc(6*sizeof(struct complex *)); + + for (i = 0; i<6; i++) { + chan_desc->R_sqrt[i] = (struct complex *) malloc(nb_tx*nb_rx*nb_tx*nb_rx * sizeof(struct complex)); + + for (j = 0; jR_sqrt[i][j].x = 1.0; + chan_desc->R_sqrt[i][j].y = 0.0; + } + + LOG_W(OCM,"correlation matrix only implemented for nb_tx==2 and nb_rx==2, using identity\n"); + } + + break; + + case Rayleigh8: nb_taps = 8; Td = 0.8; channel_length = (int)11+2*sampling_rate*Td; ricean_factor = 1; aoa = .03; maxDoppler = 0; - fill_channel_desc(chan_desc, nb_tx, nb_rx, @@ -706,88 +822,85 @@ channel_desc_t *new_channel_desc_scm(uint8_t nb_tx, 0); break; - case Rice8: + case Rice8: nb_taps = 8; Td = 0.8; channel_length = (int)11+2*sampling_rate*Td; ricean_factor = 0.1; aoa = 0.7854; maxDoppler = 0; - fill_channel_desc(chan_desc,nb_tx, - nb_rx, - nb_taps, - channel_length, - default_amps_lin, - NULL, - NULL, - Td, - sampling_rate, - channel_bandwidth, - ricean_factor, - aoa, - forgetting_factor, - maxDoppler, - channel_offset, - path_loss_dB, - 1); + nb_rx, + nb_taps, + channel_length, + default_amps_lin, + NULL, + NULL, + Td, + sampling_rate, + channel_bandwidth, + ricean_factor, + aoa, + forgetting_factor, + maxDoppler, + channel_offset, + path_loss_dB, + 1); break; - case Rayleigh1: + case Rayleigh1: nb_taps = 1; Td = 0; channel_length = 1; ricean_factor = 1; aoa = .03; maxDoppler = 0; - fill_channel_desc(chan_desc,nb_tx, - nb_rx, - nb_taps, - channel_length, - default_amp_lin, - NULL, - NULL, - Td, - sampling_rate, - channel_bandwidth, - ricean_factor, - aoa, - forgetting_factor, - maxDoppler, - channel_offset, - path_loss_dB, - 0); + nb_rx, + nb_taps, + channel_length, + default_amp_lin, + NULL, + NULL, + Td, + sampling_rate, + channel_bandwidth, + ricean_factor, + aoa, + forgetting_factor, + maxDoppler, + channel_offset, + path_loss_dB, + 0); break; - case Rayleigh1_800: + case Rayleigh1_800: nb_taps = 1; Td = 0; channel_length = 1; ricean_factor = 1; aoa = .03; maxDoppler = 800; - fill_channel_desc(chan_desc,nb_tx, - nb_rx, - nb_taps, - channel_length, - default_amp_lin, - NULL, - NULL, - Td, - sampling_rate, - channel_bandwidth, - ricean_factor, - aoa, - forgetting_factor, - maxDoppler, - channel_offset, - path_loss_dB, - 0); + nb_rx, + nb_taps, + channel_length, + default_amp_lin, + NULL, + NULL, + Td, + sampling_rate, + channel_bandwidth, + ricean_factor, + aoa, + forgetting_factor, + maxDoppler, + channel_offset, + path_loss_dB, + 0); break; - case Rayleigh1_corr: + case Rayleigh1_corr: nb_taps = 1; Td = 0; channel_length = 1; @@ -797,33 +910,31 @@ channel_desc_t *new_channel_desc_scm(uint8_t nb_tx, if ((nb_tx==2) && (nb_rx==1)) { R_sqrt_ptr2 = R_sqrt_21_corr; - } - else if ((nb_tx==2) && (nb_rx==2)) { + } else if ((nb_tx==2) && (nb_rx==2)) { R_sqrt_ptr2 = R_sqrt_22_corr; - } - else + } else R_sqrt_ptr2 = NULL; fill_channel_desc(chan_desc,nb_tx, - nb_rx, - nb_taps, - channel_length, - default_amp_lin, - NULL, - R_sqrt_ptr2, - Td, - sampling_rate, - channel_bandwidth, - ricean_factor, - aoa, - forgetting_factor, - maxDoppler, - channel_offset, - path_loss_dB, - 0); + nb_rx, + nb_taps, + channel_length, + default_amp_lin, + NULL, + R_sqrt_ptr2, + Td, + sampling_rate, + channel_bandwidth, + ricean_factor, + aoa, + forgetting_factor, + maxDoppler, + channel_offset, + path_loss_dB, + 0); break; - case Rayleigh1_anticorr: + case Rayleigh1_anticorr: nb_taps = 1; Td = 0; channel_length = 1; @@ -833,118 +944,111 @@ channel_desc_t *new_channel_desc_scm(uint8_t nb_tx, if ((nb_tx==2) && (nb_rx==1)) { //check this R_sqrt_ptr2 = R_sqrt_21_anticorr; - } - else if ((nb_tx==2) && (nb_rx==2)) { + } else if ((nb_tx==2) && (nb_rx==2)) { R_sqrt_ptr2 = R_sqrt_22_anticorr; - } - else + } else R_sqrt_ptr2 = NULL; fill_channel_desc(chan_desc,nb_tx, - nb_rx, - nb_taps, - channel_length, - default_amp_lin, - NULL, - R_sqrt_ptr2, - Td, - sampling_rate, - channel_bandwidth, - ricean_factor, - aoa, - forgetting_factor, - maxDoppler, - channel_offset, - path_loss_dB, - 0); + nb_rx, + nb_taps, + channel_length, + default_amp_lin, + NULL, + R_sqrt_ptr2, + Td, + sampling_rate, + channel_bandwidth, + ricean_factor, + aoa, + forgetting_factor, + maxDoppler, + channel_offset, + path_loss_dB, + 0); break; - case Rice1: + case Rice1: nb_taps = 1; Td = 0; channel_length = 1; ricean_factor = 0.1; aoa = 0.7854; maxDoppler = 0; - fill_channel_desc(chan_desc,nb_tx, - nb_rx, - nb_taps, - channel_length, - default_amp_lin, - NULL, - NULL, - Td, - sampling_rate, - channel_bandwidth, - ricean_factor, - aoa, - forgetting_factor, - maxDoppler, - channel_offset, - path_loss_dB, - 0); + nb_rx, + nb_taps, + channel_length, + default_amp_lin, + NULL, + NULL, + Td, + sampling_rate, + channel_bandwidth, + ricean_factor, + aoa, + forgetting_factor, + maxDoppler, + channel_offset, + path_loss_dB, + 0); break; - case AWGN: + case AWGN: nb_taps = 1; Td = 0; channel_length = 1; ricean_factor = 0.0; aoa = 0.0; maxDoppler = 0; - fill_channel_desc(chan_desc,nb_tx, - nb_rx, - nb_taps, - channel_length, - default_amp_lin, - NULL, - NULL, - Td, - sampling_rate, - channel_bandwidth, - ricean_factor, - aoa, - forgetting_factor, - maxDoppler, - channel_offset, - path_loss_dB, - 0); + nb_rx, + nb_taps, + channel_length, + default_amp_lin, + NULL, + NULL, + Td, + sampling_rate, + channel_bandwidth, + ricean_factor, + aoa, + forgetting_factor, + maxDoppler, + channel_offset, + path_loss_dB, + 0); printf("AWGN: ricean_factor %f\n",chan_desc->ricean_factor); - break; - case TS_SHIFT: + case TS_SHIFT: nb_taps = 2; Td = ts_shift_delays[1]; channel_length = 10; ricean_factor = 0.0; aoa = 0.0; maxDoppler = 0; - fill_channel_desc(chan_desc,nb_tx, - nb_rx, - nb_taps, - channel_length, - ts_shift_amps, - ts_shift_delays, - NULL, - Td, - sampling_rate, - channel_bandwidth, - ricean_factor, - aoa, - forgetting_factor, - maxDoppler, - channel_offset, - path_loss_dB, - 0); + nb_rx, + nb_taps, + channel_length, + ts_shift_amps, + ts_shift_delays, + NULL, + Td, + sampling_rate, + channel_bandwidth, + ricean_factor, + aoa, + forgetting_factor, + maxDoppler, + channel_offset, + path_loss_dB, + 0); printf("TS_SHIFT: ricean_factor %f\n",chan_desc->ricean_factor); - break; - case Rice1_corr: + case Rice1_corr: nb_taps = 1; Td = 0; channel_length = 1; @@ -954,33 +1058,31 @@ channel_desc_t *new_channel_desc_scm(uint8_t nb_tx, if ((nb_tx==2) && (nb_rx==1)) { R_sqrt_ptr2 = R_sqrt_21_corr; - } - else if ((nb_tx==2) && (nb_rx==2)) { + } else if ((nb_tx==2) && (nb_rx==2)) { R_sqrt_ptr2 = R_sqrt_22_corr; - } - else + } else R_sqrt_ptr2 = NULL; fill_channel_desc(chan_desc,nb_tx, - nb_rx, - nb_taps, - channel_length, - default_amp_lin, - NULL, - R_sqrt_ptr2, - Td, - sampling_rate, - channel_bandwidth, - ricean_factor, - aoa, - forgetting_factor, - maxDoppler, - channel_offset, - path_loss_dB, - 1); + nb_rx, + nb_taps, + channel_length, + default_amp_lin, + NULL, + R_sqrt_ptr2, + Td, + sampling_rate, + channel_bandwidth, + ricean_factor, + aoa, + forgetting_factor, + maxDoppler, + channel_offset, + path_loss_dB, + 1); break; - case Rice1_anticorr: + case Rice1_anticorr: nb_taps = 1; Td = 0; channel_length = 1; @@ -990,33 +1092,31 @@ channel_desc_t *new_channel_desc_scm(uint8_t nb_tx, if ((nb_tx==2) && (nb_rx==1)) { R_sqrt_ptr2 = R_sqrt_21_anticorr; - } - else if ((nb_tx==2) && (nb_rx==2)) { + } else if ((nb_tx==2) && (nb_rx==2)) { R_sqrt_ptr2 = R_sqrt_22_anticorr; - } - else + } else R_sqrt_ptr2 = NULL; fill_channel_desc(chan_desc,nb_tx, - nb_rx, - nb_taps, - channel_length, - default_amp_lin, - NULL, - R_sqrt_ptr2, - Td, - sampling_rate, - channel_bandwidth, - ricean_factor, - aoa, - forgetting_factor, - maxDoppler, - channel_offset, - path_loss_dB, - 1); + nb_rx, + nb_taps, + channel_length, + default_amp_lin, + NULL, + R_sqrt_ptr2, + Td, + sampling_rate, + channel_bandwidth, + ricean_factor, + aoa, + forgetting_factor, + maxDoppler, + channel_offset, + path_loss_dB, + 1); break; - case Rayleigh1_orthogonal: + case Rayleigh1_orthogonal: nb_taps = 1; Td = 0; channel_length = 1; @@ -1024,33 +1124,31 @@ channel_desc_t *new_channel_desc_scm(uint8_t nb_tx, aoa = 0.03; maxDoppler = 0; - if ((nb_tx==2) && (nb_rx==2)) { R_sqrt_ptr2 = R_sqrt_22_orthogonal; - } - else + } else R_sqrt_ptr2 = NULL; fill_channel_desc(chan_desc,nb_tx, - nb_rx, - nb_taps, - channel_length, - default_amp_lin, - NULL, - R_sqrt_ptr2, - Td, - sampling_rate, - channel_bandwidth, - ricean_factor, - aoa, - forgetting_factor, - maxDoppler, - channel_offset, - path_loss_dB, - 0); + nb_rx, + nb_taps, + channel_length, + default_amp_lin, + NULL, + R_sqrt_ptr2, + Td, + sampling_rate, + channel_bandwidth, + ricean_factor, + aoa, + forgetting_factor, + maxDoppler, + channel_offset, + path_loss_dB, + 0); break; - case Rayleigh1_orth_eff_ch_TM4_prec_real: + case Rayleigh1_orth_eff_ch_TM4_prec_real: nb_taps = 1; Td = 0; channel_length = 1; @@ -1058,33 +1156,31 @@ channel_desc_t *new_channel_desc_scm(uint8_t nb_tx, aoa = 0.03; maxDoppler = 0; - if ((nb_tx==2) && (nb_rx==2)) { R_sqrt_ptr2 = R_sqrt_22_orth_eff_ch_TM4_prec_real; - } - else + } else R_sqrt_ptr2 = NULL; fill_channel_desc(chan_desc,nb_tx, - nb_rx, - nb_taps, - channel_length, - default_amp_lin, - NULL, - R_sqrt_ptr2, - Td, - sampling_rate, - channel_bandwidth, - ricean_factor, - aoa, - forgetting_factor, - maxDoppler, - channel_offset, - path_loss_dB, - 1); + nb_rx, + nb_taps, + channel_length, + default_amp_lin, + NULL, + R_sqrt_ptr2, + Td, + sampling_rate, + channel_bandwidth, + ricean_factor, + aoa, + forgetting_factor, + maxDoppler, + channel_offset, + path_loss_dB, + 1); break; - case Rayleigh1_orth_eff_ch_TM4_prec_imag: + case Rayleigh1_orth_eff_ch_TM4_prec_imag: nb_taps = 1; Td = 0; channel_length = 1; @@ -1092,48 +1188,75 @@ channel_desc_t *new_channel_desc_scm(uint8_t nb_tx, aoa = 0.03; maxDoppler = 0; - if ((nb_tx==2) && (nb_rx==2)) { R_sqrt_ptr2 = R_sqrt_22_orth_eff_ch_TM4_prec_imag; - } - else + } else R_sqrt_ptr2 = NULL; fill_channel_desc(chan_desc,nb_tx, - nb_rx, - nb_taps, - channel_length, - default_amp_lin, - NULL, - R_sqrt_ptr2, - Td, - sampling_rate, - channel_bandwidth, - ricean_factor, - aoa, - forgetting_factor, - maxDoppler, - channel_offset, - path_loss_dB, - 0); + nb_rx, + nb_taps, + channel_length, + default_amp_lin, + NULL, + R_sqrt_ptr2, + Td, + sampling_rate, + channel_bandwidth, + ricean_factor, + aoa, + forgetting_factor, + maxDoppler, + channel_offset, + path_loss_dB, + 0); break; - case Rayleigh8_orth_eff_ch_TM4_prec_real: - - if ((nb_tx==2) && (nb_rx==2)) { + case Rayleigh8_orth_eff_ch_TM4_prec_real: + if ((nb_tx==2) && (nb_rx==2)) { R_sqrt_ptr2 = R_sqrt_22_orth_eff_ch_TM4_prec_real; //R_sqrt_ptr2 = NULL; - } - else + } else R_sqrt_ptr2 = NULL; - nb_taps = 8; Td = 0.8; channel_length = (int)11+2*sampling_rate*Td; ricean_factor = 1; aoa = .03; maxDoppler = 0; + fill_channel_desc(chan_desc, + nb_tx, + nb_rx, + nb_taps, + channel_length, + default_amps_lin, + NULL, + R_sqrt_ptr2, + Td, + sampling_rate, + channel_bandwidth, + ricean_factor, + aoa, + forgetting_factor, + maxDoppler, + channel_offset, + path_loss_dB, + 0); + break; + + case Rayleigh8_orth_eff_ch_TM4_prec_imag: + nb_taps = 8; + Td = 0.8; + channel_length = (int)11+2*sampling_rate*Td; + ricean_factor = 1; + aoa = .03; + maxDoppler = 0; + + if ((nb_tx==2) && (nb_rx==2)) { + R_sqrt_ptr2 = R_sqrt_22_orth_eff_ch_TM4_prec_imag; + } else + R_sqrt_ptr2 = NULL; fill_channel_desc(chan_desc, nb_tx, @@ -1153,77 +1276,40 @@ channel_desc_t *new_channel_desc_scm(uint8_t nb_tx, channel_offset, path_loss_dB, 0); - break; - case Rayleigh8_orth_eff_ch_TM4_prec_imag: - nb_taps = 8; - Td = 0.8; - channel_length = (int)11+2*sampling_rate*Td; - ricean_factor = 1; - aoa = .03; - maxDoppler = 0; - - if ((nb_tx==2) && (nb_rx==2)) { - R_sqrt_ptr2 = R_sqrt_22_orth_eff_ch_TM4_prec_imag; - } - else - R_sqrt_ptr2 = NULL; - - fill_channel_desc(chan_desc, - nb_tx, - nb_rx, - nb_taps, - channel_length, - default_amps_lin, - NULL, - R_sqrt_ptr2, - Td, - sampling_rate, - channel_bandwidth, - ricean_factor, - aoa, - forgetting_factor, - maxDoppler, - channel_offset, - path_loss_dB, - 0); - break; - - default: - LOG_W(OCM,"channel model not yet supported\n"); - free(chan_desc); - return(NULL); + default: + LOG_W(OCM,"channel model not yet supported\n"); + free(chan_desc); + return(NULL); } + LOG_D(OCM,"[CHANNEL] RF %f\n",chan_desc->ricean_factor); - for (i=0;inb_taps;i++) + + for (i=0; inb_taps; i++) LOG_D(OCM,"[CHANNEL] tap %d: amp %f, delay %f\n",i,chan_desc->amps[i],chan_desc->delays[i]); chan_desc->nb_paths = 10; - return(chan_desc); } -void free_channel_desc_scm(channel_desc_t * ch) { - // Must be made cleanly, a lot of leaks... - free(ch); +void free_channel_desc_scm(channel_desc_t *ch) { + // Must be made cleanly, a lot of leaks... + free(ch); } int random_channel(channel_desc_t *desc, uint8_t abstraction_flag) { - double s; int i,k,l,aarx,aatx; struct complex anew[NB_ANTENNAS_TX*NB_ANTENNAS_RX],acorr[NB_ANTENNAS_TX*NB_ANTENNAS_RX]; struct complex phase, alpha, beta; - AssertFatal(desc->nb_tx<=NB_ANTENNAS_TX && desc->nb_rx <= NB_ANTENNAS_RX, - "random_channel.c: Error: temporary buffer for channel not big enough (%d,%d)\n",desc->nb_tx,desc->nb_rx); - + "random_channel.c: Error: temporary buffer for channel not big enough (%d,%d)\n",desc->nb_tx,desc->nb_rx); start_meas(&desc->random_channel); - for (i=0;i<(int)desc->nb_taps;i++) { - for (aarx=0;aarxnb_rx;aarx++) { - for (aatx=0;aatxnb_tx;aatx++) { + for (i=0; i<(int)desc->nb_taps; i++) { + for (aarx=0; aarxnb_rx; aarx++) { + for (aatx=0; aatxnb_tx; aatx++) { anew[aarx+(aatx*desc->nb_rx)].x = sqrt(desc->ricean_factor*desc->amps[i]/2) * gaussdouble(0.0,1.0); anew[aarx+(aatx*desc->nb_rx)].y = sqrt(desc->ricean_factor*desc->amps[i]/2) * gaussdouble(0.0,1.0); @@ -1237,10 +1323,10 @@ int random_channel(channel_desc_t *desc, uint8_t abstraction_flag) { // that we can safely assume plane wave propagation. phase.x = cos(M_PI*((aarx-aatx)*sin(desc->aoa))); phase.y = sin(M_PI*((aarx-aatx)*sin(desc->aoa))); - anew[aarx+(aatx*desc->nb_rx)].x += phase.x * sqrt(1.0-desc->ricean_factor); anew[aarx+(aatx*desc->nb_rx)].y += phase.y * sqrt(1.0-desc->ricean_factor); } + #ifdef DEBUG_CH printf("(%d,%d,%d) %f->(%f,%f) (%f,%f) phase (%f,%f)\n",aarx,aatx,i,desc->amps[i],anew[aarx+(aatx*desc->nb_rx)].x,anew[aarx+(aatx*desc->nb_rx)].y,desc->aoa,desc->ricean_factor,phase.x,phase.y); #endif @@ -1263,10 +1349,9 @@ int random_channel(channel_desc_t *desc, uint8_t abstraction_flag) { alpha.y = 0.0; beta.x = 0.0; beta.y = 0.0; - cblas_zgemv(CblasRowMajor, CblasNoTrans, desc->nb_tx*desc->nb_rx, desc->nb_tx*desc->nb_rx, - (void*) &alpha, (void*) desc->R_sqrt[i/3], desc->nb_rx*desc->nb_tx, - (void*) anew, 1, (void*) &beta, (void*) acorr, 1); + (void *) &alpha, (void *) desc->R_sqrt[i/3], desc->nb_rx*desc->nb_tx, + (void *) anew, 1, (void *) &beta, (void *) acorr, 1); /* for (aarx=0;aarxnb_rx;aarx++) { @@ -1278,10 +1363,9 @@ int random_channel(channel_desc_t *desc, uint8_t abstraction_flag) { } */ - if (desc->first_run==1){ - cblas_zcopy(desc->nb_tx*desc->nb_rx, (void*) acorr, 1, (void*) desc->a[i], 1); - } - else { + if (desc->first_run==1) { + cblas_zcopy(desc->nb_tx*desc->nb_rx, (void *) acorr, 1, (void *) desc->a[i], 1); + } else { // a = alpha*acorr+beta*a // a = beta*a // a = a+alpha*acorr @@ -1289,9 +1373,8 @@ int random_channel(channel_desc_t *desc, uint8_t abstraction_flag) { alpha.y = 0; beta.x = sqrt(desc->forgetting_factor); beta.y = 0; - cblas_zscal(desc->nb_tx*desc->nb_rx, (void*) &beta, (void*) desc->a[i], 1); - cblas_zaxpy(desc->nb_tx*desc->nb_rx, (void*) &alpha, (void*) acorr, 1, (void*) desc->a[i], 1); - + cblas_zscal(desc->nb_tx*desc->nb_rx, (void *) &beta, (void *) desc->a[i], 1); + cblas_zaxpy(desc->nb_tx*desc->nb_rx, (void *) &alpha, (void *) acorr, 1, (void *) desc->a[i], 1); // desc->a[i][aarx+(aatx*desc->nb_rx)].x = (sqrt(desc->forgetting_factor)*desc->a[i][aarx+(aatx*desc->nb_rx)].x) + sqrt(1-desc->forgetting_factor)*anew.x; // desc->a[i][aarx+(aatx*desc->nb_rx)].y = (sqrt(desc->forgetting_factor)*desc->a[i][aarx+(aatx*desc->nb_rx)].y) + sqrt(1-desc->forgetting_factor)*anew.y; } @@ -1305,8 +1388,8 @@ int random_channel(channel_desc_t *desc, uint8_t abstraction_flag) { } } */ - } //nb_taps + stop_meas(&desc->random_channel); //memset((void *)desc->ch[aarx+(aatx*desc->nb_rx)],0,(int)(desc->channel_length)*sizeof(struct complex)); @@ -1320,7 +1403,6 @@ int random_channel(channel_desc_t *desc, uint8_t abstraction_flag) { desc->ch[aarx+(aatx*desc->nb_rx)][0].x = desc->a[0][aarx+(aatx*desc->nb_rx)].x; desc->ch[aarx+(aatx*desc->nb_rx)][0].y = desc->a[0][aarx+(aatx*desc->nb_rx)].y; } else { - for (k=0; k<(int)desc->channel_length; k++) { desc->ch[aarx+(aatx*desc->nb_rx)][k].x = 0.0; desc->ch[aarx+(aatx*desc->nb_rx)][k].y = 0.0; @@ -1335,18 +1417,18 @@ int random_channel(channel_desc_t *desc, uint8_t abstraction_flag) { desc->ch[aarx+(aatx*desc->nb_rx)][k].x += s*desc->a[l][aarx+(aatx*desc->nb_rx)].x; desc->ch[aarx+(aatx*desc->nb_rx)][k].y += s*desc->a[l][aarx+(aatx*desc->nb_rx)].y; // printf("l %d : desc->ch.x %f\n",l,desc->a[l][aarx+(aatx*desc->nb_rx)].x); - } //nb_taps #ifdef DEBUG_CH - k=0; - printf("(%d,%d,%d)->(%f,%f)\n",k,aarx,aatx,desc->ch[aarx+(aatx*desc->nb_rx)][k].x,desc->ch[aarx+(aatx*desc->nb_rx)][k].y); + k=0; + printf("(%d,%d,%d)->(%f,%f)\n",k,aarx,aatx,desc->ch[aarx+(aatx*desc->nb_rx)][k].x,desc->ch[aarx+(aatx*desc->nb_rx)][k].y); #endif - } - } //channel_length - } //aatx - } //aarx - stop_meas(&desc->interp_time); + } + } //channel_length + } //aatx + } //aarx + + stop_meas(&desc->interp_time); } if (desc->first_run==1) @@ -1355,69 +1437,103 @@ int random_channel(channel_desc_t *desc, uint8_t abstraction_flag) { return (0); } -double N_RB2sampling_rate(uint16_t N_RB) -{ +double N_RB2sampling_rate(uint16_t N_RB) { double sampling_rate; + switch (N_RB) { - case 6: - sampling_rate = 1.92; - break; + case 6: + sampling_rate = 1.92; + break; - case 25: - sampling_rate = 7.68; - break; + case 25: + sampling_rate = 7.68; + break; - case 50: - sampling_rate = 15.36; - break; + case 50: + sampling_rate = 15.36; + break; - case 100: - sampling_rate = 30.72; - break; + case 100: + sampling_rate = 30.72; + break; - default: - AssertFatal(1==0,"Unknown N_PRB %d",N_RB); + default: + AssertFatal(1==0,"Unknown N_PRB %d",N_RB); } return(sampling_rate); } -double N_RB2channel_bandwidth(uint16_t N_RB) -{ +double N_RB2channel_bandwidth(uint16_t N_RB) { double channel_bandwidth; + switch (N_RB) { - case 6: - channel_bandwidth = 1.25; - break; + case 6: + channel_bandwidth = 1.25; + break; - case 25: - channel_bandwidth = 5.00; - break; + case 25: + channel_bandwidth = 5.00; + break; - case 50: - channel_bandwidth = 10.00; - break; + case 50: + channel_bandwidth = 10.00; + break; - case 100: - channel_bandwidth = 20.00; - break; + case 100: + channel_bandwidth = 20.00; + break; - default: - LOG_E(PHY,"Unknown N_PRB\n"); - return(-1); + default: + LOG_E(PHY,"Unknown N_PRB\n"); + return(-1); } + return(channel_bandwidth); } +static int channelmod_show_cmd(char *buff, int debug, telnet_printfunc_t prnt) { + for(int i=0; channelmod_names[i].name != NULL ; i++) { + prnt(" %i %s\n", i, map_int_to_str(channelmod_names,i )); + } + + return 0; +} + +int modelid_fromname(char *modelname) { + int modelid=map_str_to_int(channelmod_names,modelname); + AssertFatal(modelid>0, + "random_channel.c: Error channel model %s unknown\n",modelname); + return modelid; +} + +double channelmod_get_snr_dB(void) { + return snr_dB; +} + +double channelmod_get_sinr_dB(void) { + return sinr_dB; +} + +void init_channelmod(void) { + paramdef_t channelmod_params[] = CHANNELMOD_PARAMS_DESC; + int ret = config_get( channelmod_params,sizeof(channelmod_params)/sizeof(paramdef_t),CHANNELMOD_SECTION); + AssertFatal(ret >= 0, "configuration couldn't be performed"); + /* look for telnet server, if it is loaded, add the channel modeling commands to it */ + add_telnetcmd_func_t addcmd = (add_telnetcmd_func_t)get_shlibmodule_fptr("telnetsrv", TELNET_ADDCMD_FNAME); + + if (addcmd != NULL) { + addcmd("channelmod",channelmod_vardef,channelmod_cmdarray); + } +} + #ifdef RANDOM_CHANNEL_MAIN #define sampling_rate 5.0 #define Td 2.0 main(int argc,char **argv) { - double amps[8] = {.8,.2,.1,.04,.02,.01,.005}; struct complex ch[(int)(1+2*sampling_rate*Td)],phase; int i; - randominit(); phase.x = 1.0; phase.y = 0; diff --git a/openair1/SIMULATION/TOOLS/sim.h b/openair1/SIMULATION/TOOLS/sim.h index 1d5c43232e..0bc5975d99 100644 --- a/openair1/SIMULATION/TOOLS/sim.h +++ b/openair1/SIMULATION/TOOLS/sim.h @@ -147,7 +147,7 @@ typedef struct { /// Rice factor??? /// Walls (penetration loss) /// Nodes in the scenario - node_desc_t* nodes; + node_desc_t *nodes; } scenario_desc_t; typedef enum { @@ -180,29 +180,66 @@ typedef enum { EPA_medium, EPA_high, } SCM_t; +#define CHANNELMOD_MAP_INIT \ + {"custom",custom},\ + {"SCM_A",SCM_A},\ + {"SCM_B",SCM_B},\ + {"SCM_C",SCM_C},\ + {"SCM_D",SCM_D},\ + {"EPA",EPA},\ + {"EVA",EVA},\ + {"ETU",ETU},\ + {"MBSFN",MBSFN},\ + {"Rayleigh8",Rayleigh8},\ + {"Rayleigh1",Rayleigh1},\ + {"Rayleigh1_800",Rayleigh1_800},\ + {"Rayleigh1_corr",Rayleigh1_corr},\ + {"Rayleigh1_anticorr",Rayleigh1_anticorr},\ + {"Rice8",Rice8},\ + {"Rice1",Rice1},\ + {"Rice1_corr",Rice1_corr},\ + {"Rice1_anticorr",Rice1_anticorr},\ + {"AWGN",AWGN},\ + {"Rayleigh1_orthogonal",Rayleigh1_orthogonal},\ + {"Rayleigh1_orth_eff_ch_TM4_prec_real",Rayleigh1_orth_eff_ch_TM4_prec_real},\ + {"Rayleigh1_orth_eff_ch_TM4_prec_imag",Rayleigh1_orth_eff_ch_TM4_prec_imag},\ + {"Rayleigh8_orth_eff_ch_TM4_prec_real",Rayleigh8_orth_eff_ch_TM4_prec_real},\ + {"Rayleigh8_orth_eff_ch_TM4_prec_imag",Rayleigh8_orth_eff_ch_TM4_prec_imag},\ + {"TS_SHIFT",TS_SHIFT},\ + {"EPA_low",EPA_low},\ + {"EPA_medium",EPA_medium},\ + {"EPA_high",EPA_high},\ + {NULL, -1} + +#define CONFIG_HLP_SNR "Set average SNR in dB (for --siml1 option)\n" +#define CHANNELMOD_SECTION "channelmod" +#define CHANNELMOD_PARAMS_DESC { \ + {"s" , CONFIG_HLP_SNR, PARAMFLAG_CMDLINE_NOPREFIXENABLED, dblptr:&snr_dB , defdblval:25, TYPE_DOUBLE, 0},\ + {"sinr_dB", NULL , 0 , dblptr:&sinr_dB, defdblval:0 , TYPE_DOUBLE, 0},\ + } #include "platform_constants.h" typedef struct { - channel_desc_t *RU2UE[NUMBER_OF_RU_MAX][NUMBER_OF_UE_MAX][MAX_NUM_CCs]; - channel_desc_t *UE2RU[NUMBER_OF_UE_MAX][NUMBER_OF_RU_MAX][MAX_NUM_CCs]; - double r_re_DL[NUMBER_OF_UE_MAX][2][30720]; - double r_im_DL[NUMBER_OF_UE_MAX][2][30720]; - double r_re_UL[NUMBER_OF_eNB_MAX][2][30720]; - double r_im_UL[NUMBER_OF_eNB_MAX][2][30720]; - int RU_output_mask[NUMBER_OF_UE_MAX]; - int UE_output_mask[NUMBER_OF_RU_MAX]; - pthread_mutex_t RU_output_mutex[NUMBER_OF_UE_MAX]; - pthread_mutex_t UE_output_mutex[NUMBER_OF_RU_MAX]; - pthread_mutex_t subframe_mutex; - int subframe_ru_mask; - int subframe_UE_mask; - openair0_timestamp current_ru_rx_timestamp[NUMBER_OF_RU_MAX][MAX_NUM_CCs]; - openair0_timestamp current_UE_rx_timestamp[MAX_MOBILES_PER_ENB][MAX_NUM_CCs]; - openair0_timestamp last_ru_rx_timestamp[NUMBER_OF_RU_MAX][MAX_NUM_CCs]; - openair0_timestamp last_UE_rx_timestamp[MAX_MOBILES_PER_ENB][MAX_NUM_CCs]; - double ru_amp[NUMBER_OF_RU_MAX]; - pthread_t rfsim_thread; + channel_desc_t *RU2UE[NUMBER_OF_RU_MAX][NUMBER_OF_UE_MAX][MAX_NUM_CCs]; + channel_desc_t *UE2RU[NUMBER_OF_UE_MAX][NUMBER_OF_RU_MAX][MAX_NUM_CCs]; + double r_re_DL[NUMBER_OF_UE_MAX][2][30720]; + double r_im_DL[NUMBER_OF_UE_MAX][2][30720]; + double r_re_UL[NUMBER_OF_eNB_MAX][2][30720]; + double r_im_UL[NUMBER_OF_eNB_MAX][2][30720]; + int RU_output_mask[NUMBER_OF_UE_MAX]; + int UE_output_mask[NUMBER_OF_RU_MAX]; + pthread_mutex_t RU_output_mutex[NUMBER_OF_UE_MAX]; + pthread_mutex_t UE_output_mutex[NUMBER_OF_RU_MAX]; + pthread_mutex_t subframe_mutex; + int subframe_ru_mask; + int subframe_UE_mask; + openair0_timestamp current_ru_rx_timestamp[NUMBER_OF_RU_MAX][MAX_NUM_CCs]; + openair0_timestamp current_UE_rx_timestamp[MAX_MOBILES_PER_ENB][MAX_NUM_CCs]; + openair0_timestamp last_ru_rx_timestamp[NUMBER_OF_RU_MAX][MAX_NUM_CCs]; + openair0_timestamp last_UE_rx_timestamp[MAX_MOBILES_PER_ENB][MAX_NUM_CCs]; + double ru_amp[NUMBER_OF_RU_MAX]; + pthread_t rfsim_thread; } sim_t; @@ -395,23 +432,40 @@ void multipath_tv_channel(channel_desc_t *desc, /**@} */ /**@} */ +void rxAddInput( struct complex16 *input_sig, + struct complex16 *after_channel_sig, + int rxAnt, + channel_desc_t *channelDesc, + int nbSamples, + uint64_t TS, + uint32_t CirSize + ); + +int modelid_fromname(char *modelname); +double channelmod_get_snr_dB(void); +double channelmod_get_sinr_dB(void); +void init_channelmod(void) ; + double N_RB2sampling_rate(uint16_t N_RB); double N_RB2channel_bandwidth(uint16_t N_RB); -//#include "targets/RT/USER/rfsim.h" +#include "targets/RT/USER/rfsim.h" void do_DL_sig(sim_t *sim, uint16_t subframe, uint32_t offset, uint32_t length, - uint8_t abstraction_flag,LTE_DL_FRAME_PARMS *ue_frame_parms, + uint8_t abstraction_flag, + LTE_DL_FRAME_PARMS *ue_frame_parms, uint8_t UE_id, int CC_id); void do_UL_sig(sim_t *sim, - uint16_t subframe,uint8_t abstraction_flag,LTE_DL_FRAME_PARMS *frame_parms, - uint32_t frame,int ru_id,uint8_t CC_id); + uint16_t subframe, + uint8_t abstraction_flag, + LTE_DL_FRAME_PARMS *frame_parms, + uint32_t frame, + int ru_id, + uint8_t CC_id); #endif - - diff --git a/openair2/COMMON/mac_rrc_primitives.h b/openair2/COMMON/mac_rrc_primitives.h index 8a58d07d65..4a0a6027bc 100644 --- a/openair2/COMMON/mac_rrc_primitives.h +++ b/openair2/COMMON/mac_rrc_primitives.h @@ -20,15 +20,14 @@ */ #ifndef __MAC_RRC_PRIMITIVES_H__ -# define __MAC_RRC_PRIMITIVES_H__ - - +#define __MAC_RRC_PRIMITIVES_H__ #ifndef OPENAIR2_IN #include "LAYER2/RLC/rlc.h" #endif #include "COMMON/platform_types.h" #include "COMMON/platform_constants.h" +#include "openair2/RRC/LTE/rrc_defs.h" #include "LTE_RadioResourceConfigCommonSIB.h" #include "LTE_RadioResourceConfigDedicated.h" @@ -398,5 +397,3 @@ typedef struct { #define REMOVE_LC 1 #endif - - diff --git a/openair2/COMMON/rrc_messages_types.h b/openair2/COMMON/rrc_messages_types.h index ad145f09f6..0432d7ab41 100644 --- a/openair2/COMMON/rrc_messages_types.h +++ b/openair2/COMMON/rrc_messages_types.h @@ -274,6 +274,7 @@ typedef struct RrcConfigurationReq_s { long *pdsch_maxNumRepetitionCEmodeB_r13 [MAX_NUM_CCs]; long *pusch_maxNumRepetitionCEmodeA_r13 [MAX_NUM_CCs]; long *pusch_maxNumRepetitionCEmodeB_r13 [MAX_NUM_CCs]; + long *pusch_repetitionLevelCEmodeA_r13 [MAX_NUM_CCs]; long *pusch_HoppingOffset_v1310 [MAX_NUM_CCs]; //SIB18 diff --git a/openair2/ENB_APP/enb_config.c b/openair2/ENB_APP/enb_config.c index 6174632fd6..2082663fce 100644 --- a/openair2/ENB_APP/enb_config.c +++ b/openair2/ENB_APP/enb_config.c @@ -55,11 +55,8 @@ #include "RRC_config_tools.h" #include "enb_paramdef.h" #include "proto_agent.h" +#include "executables/thread-common.h" -extern void set_parallel_conf(char *parallel_conf); -extern void set_worker_conf(char *worker_conf); -//extern PARALLEL_CONF_t get_thread_parallel_conf(void); -//extern WORKER_CONF_t get_thread_worker_conf(void); extern uint32_t to_earfcn_DL(int eutra_bandP, uint32_t dl_CarrierFreq, uint32_t bw); extern uint32_t to_earfcn_UL(int eutra_bandP, uint32_t ul_CarrierFreq, uint32_t bw); extern char *parallel_config; diff --git a/openair2/ENB_APP/enb_config_eMTC.c b/openair2/ENB_APP/enb_config_eMTC.c index 45d67120bd..cfd057bad8 100644 --- a/openair2/ENB_APP/enb_config_eMTC.c +++ b/openair2/ENB_APP/enb_config_eMTC.c @@ -859,6 +859,21 @@ void fill_eMTC_configuration(MessageDef *msg_p, ccparams_eMTC_t *eMTCconfig, in config_fname); } + RRC_CONFIGURATION_REQ(msg_p).pusch_repetitionLevelCEmodeA_r13[cc_idx] = CALLOC(1, sizeof(long)); + if (!strcmp(eMTCconfig->pusch_repetitionLevelCEmodeA_r13, "l1")) { + *RRC_CONFIGURATION_REQ(msg_p).pusch_repetitionLevelCEmodeA_r13[cc_idx] = 0; + } else if (!strcmp(eMTCconfig->pusch_repetitionLevelCEmodeA_r13, "l2")) { + *RRC_CONFIGURATION_REQ(msg_p).pusch_repetitionLevelCEmodeA_r13[cc_idx] = 1; + } else if (!strcmp(eMTCconfig->pusch_repetitionLevelCEmodeA_r13, "l3")) { + *RRC_CONFIGURATION_REQ(msg_p).pusch_repetitionLevelCEmodeA_r13[cc_idx] = 2; + } else if (!strcmp(eMTCconfig->pusch_repetitionLevelCEmodeA_r13, "l4")) { + *RRC_CONFIGURATION_REQ(msg_p).pusch_repetitionLevelCEmodeA_r13[cc_idx] = 3; + } else { + AssertFatal (0, + "Failed to parse eNB configuration file %s, pusch_repetitionLevelCEmodeA_r13 unknown value!\n", + config_fname); + } + char rachCELevelInfoListPath[MAX_OPTNAME_SIZE * 2]; config_getlist(&rachcelevellist, NULL, 0, brparamspath); RRC_CONFIGURATION_REQ (msg_p).rach_CE_LevelInfoList_r13_size[cc_idx] = rachcelevellist.numelt; diff --git a/openair2/ENB_APP/enb_paramdef.h b/openair2/ENB_APP/enb_paramdef.h index 165675ab12..106a9f297e 100644 --- a/openair2/ENB_APP/enb_paramdef.h +++ b/openair2/ENB_APP/enb_paramdef.h @@ -245,7 +245,7 @@ typedef enum { #define ENB_ENABLE_X2 17 #define TRACKING_AREA_CODE_OKRANGE {0x0001,0xFFFD} -#define ENBPARAMS_CHECK { \ +#define ENBPARAMS_CHECK { \ { .s5 = { NULL } }, \ { .s5 = { NULL } }, \ { .s5 = { NULL } }, \ @@ -394,6 +394,7 @@ typedef enum { #define ENB_CONFIG_STRING_PUSCH_MAX_NUM_REPETITION_CE_MODE_A_R13 "pusch_maxNumRepetitionCEmodeA_r13" #define ENB_CONFIG_STRING_PUSCH_MAX_NUM_REPETITION_CE_MODE_B_R13 "pusch_maxNumRepetitionCEmodeB_r13" +#define ENB_CONFIG_STRING_PUSCH_REPETITION_LEVEL_CE_MODE_A_R13 "pusch_repetitionLevelCEmodeA_r13" #define ENB_CONFIG_STRING_PUSCH_HOPPING_OFFSET_V1310 "pusch_HoppingOffset_v1310" @@ -536,289 +537,288 @@ typedef struct ccparams_lte_s { int32_t srb1_max_retx_threshold; } ccparams_lte_t; -#define CCPARAMS_CHECK { \ - { .s5= {NULL }} , \ - { .s5= {NULL }} , \ - { .s5= {NULL }} , \ - { .s5= {NULL }} , \ - { .s5= {NULL }} , \ - { .s5= {NULL }} , \ - { .s5= {NULL }} , \ - { .s5= {NULL }} , \ - { .s5= {NULL }} , \ - { .s5= {NULL }} , \ - { .s5= {NULL }} , \ - { .s5= {NULL }} , \ - { .s5= {NULL }} , \ - { .s5= {NULL }} , \ - { .s5= {NULL }} , \ - { .s5= {NULL }} , \ - { .s5= {NULL }} , \ - { .s5= {NULL }} , \ - { .s5= {NULL }} , \ - { .s5= {NULL }} , \ - { .s5= {NULL }} , \ - { .s5= {NULL }} , \ - { .s5= {NULL }} , \ - { .s5= {NULL }} , \ - { .s5= {NULL }} , \ - { .s5= {NULL }} , \ - { .s5= {NULL }} , \ - { .s5= {NULL }} , \ - { .s5= {NULL }} , \ - { .s5= {NULL }} , \ - { .s5= {NULL }} , \ - { .s5= {NULL }} , \ - { .s5= {NULL }} , \ - { .s5= {NULL }} , \ - { .s5= {NULL }} , \ - { .s5= {NULL }} , \ - { .s5= {NULL }} , \ - { .s5= {NULL }} , \ - { .s5= {NULL }} , \ - { .s5= {NULL }} , \ - { .s5= {NULL }} , \ - { .s5= {NULL }} , \ - { .s5= {NULL }} , \ - { .s5= {NULL }} , \ - { .s5= {NULL }} , \ - { .s5= {NULL }} , \ - { .s5= {NULL }} , \ - { .s5= {NULL }} , \ - { .s5= {NULL }} , \ - { .s5= {NULL }} , \ - { .s5= {NULL }} , \ - { .s5= {NULL }} , \ - { .s5= {NULL }} , \ - { .s5= {NULL }} , \ - { .s5= {NULL }} , \ - { .s5= {NULL }} , \ - { .s5= {NULL }} , \ - { .s5= {NULL }} , \ - { .s5= {NULL }} , \ - { .s5= {NULL }} , \ - { .s5= {NULL }} , \ - { .s5= {NULL }} , \ - { .s5= {NULL }} , \ - { .s5= {NULL }} , \ - { .s5= {NULL }} , \ - { .s5= {NULL }} , \ - { .s5= {NULL }} , \ - { .s5= {NULL }} , \ - { .s5= {NULL }} , \ - { .s1a= { config_check_modify_integer, UETIMER_T300_OKVALUES, UETIMER_T300_MODVALUES,8}} , \ - { .s1a= { config_check_modify_integer, UETIMER_T301_OKVALUES, UETIMER_T301_MODVALUES,8}} , \ - { .s1a= { config_check_modify_integer, UETIMER_T310_OKVALUES, UETIMER_T310_MODVALUES,7}} , \ - { .s1a= { config_check_modify_integer, UETIMER_T311_OKVALUES, UETIMER_T311_MODVALUES,7}} , \ - { .s1a= { config_check_modify_integer, UETIMER_N310_OKVALUES, UETIMER_N310_MODVALUES,8}} , \ - { .s1a= { config_check_modify_integer, UETIMER_N311_OKVALUES, UETIMER_N311_MODVALUES,8}} , \ - { .s5= {NULL }} , \ - { .s5= {NULL }} , \ - { .s5= {NULL }} , \ - { .s5= {NULL }} , \ - { .s5= {NULL }} , \ - { .s5= {NULL }} , \ - { .s5= {NULL }} , \ - { .s5= {NULL }} , \ - { .s5= {NULL }} , \ - { .s5= {NULL }} , \ - { .s5= {NULL }} , \ - { .s5= {NULL }} , \ - { .s5= {NULL }} , \ - { .s5= {NULL }} , \ - { .s5= {NULL }} , \ - { .s5= {NULL }} , \ - { .s5= {NULL }} , \ - { .s5= {NULL }} , \ - { .s5= {NULL }} , \ - { .s5= {NULL }} , \ - { .s5= {NULL }} , \ - { .s5= {NULL }} , \ - { .s5= {NULL }} , \ - { .s5= {NULL }} , \ - { .s5= {NULL }} , \ - { .s5= {NULL }} , \ - { .s5= {NULL }} , \ - { .s5= {NULL }} , \ - { .s5= {NULL }} , \ - { .s5= {NULL }} , \ - { .s5= {NULL }} , \ - { .s5= {NULL }} , \ - { .s5= {NULL }} , \ - { .s5= {NULL }} , \ - { .s5= {NULL }} , \ - { .s5= {NULL }} , \ - { .s5= {NULL }} , \ - { .s5= {NULL }} , \ - { .s5= {NULL }} , \ - { .s5= {NULL }} , \ - { .s5= {NULL }} \ - } -/*---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------*/ -/* component carriers configuration parameters */ -/* optname helpstr paramflags XXXptr defXXXval type numelt checked_param */ -/*---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------*/ +#define CCPARAMS_CHECK { \ + { .s5 = { NULL } } , \ + { .s5 = { NULL } } , \ + { .s5 = { NULL } } , \ + { .s5 = { NULL } } , \ + { .s5 = { NULL } } , \ + { .s5 = { NULL } } , \ + { .s5 = { NULL } } , \ + { .s5 = { NULL } } , \ + { .s5 = { NULL } } , \ + { .s5 = { NULL } } , \ + { .s5 = { NULL } } , \ + { .s5 = { NULL } } , \ + { .s5 = { NULL } } , \ + { .s5 = { NULL } } , \ + { .s5 = { NULL } } , \ + { .s5 = { NULL } } , \ + { .s5 = { NULL } } , \ + { .s5 = { NULL } } , \ + { .s5 = { NULL } } , \ + { .s5 = { NULL } } , \ + { .s5 = { NULL } } , \ + { .s5 = { NULL } } , \ + { .s5 = { NULL } } , \ + { .s5 = { NULL } } , \ + { .s5 = { NULL } } , \ + { .s5 = { NULL } } , \ + { .s5 = { NULL } } , \ + { .s5 = { NULL } } , \ + { .s5 = { NULL } } , \ + { .s5 = { NULL } } , \ + { .s5 = { NULL } } , \ + { .s5 = { NULL } } , \ + { .s5 = { NULL } } , \ + { .s5 = { NULL } } , \ + { .s5 = { NULL } } , \ + { .s5 = { NULL } } , \ + { .s5 = { NULL } } , \ + { .s5 = { NULL } } , \ + { .s5 = { NULL } } , \ + { .s5 = { NULL } } , \ + { .s5 = { NULL } } , \ + { .s5 = { NULL } } , \ + { .s5 = { NULL } } , \ + { .s5 = { NULL } } , \ + { .s5 = { NULL } } , \ + { .s5 = { NULL } } , \ + { .s5 = { NULL } } , \ + { .s5 = { NULL } } , \ + { .s5 = { NULL } } , \ + { .s5 = { NULL } } , \ + { .s5 = { NULL } } , \ + { .s5 = { NULL } } , \ + { .s5 = { NULL } } , \ + { .s5 = { NULL } } , \ + { .s5 = { NULL } } , \ + { .s5 = { NULL } } , \ + { .s5 = { NULL } } , \ + { .s5 = { NULL } } , \ + { .s5 = { NULL } } , \ + { .s5 = { NULL } } , \ + { .s5 = { NULL } } , \ + { .s5 = { NULL } } , \ + { .s5 = { NULL } } , \ + { .s5 = { NULL } } , \ + { .s5 = { NULL } } , \ + { .s5 = { NULL } } , \ + { .s5 = { NULL } } , \ + { .s5 = { NULL } } , \ + { .s5 = { NULL } } , \ + { .s1a= { config_check_modify_integer, UETIMER_T300_OKVALUES, UETIMER_T300_MODVALUES,8}} ,\ + { .s1a= { config_check_modify_integer, UETIMER_T301_OKVALUES, UETIMER_T301_MODVALUES,8}} ,\ + { .s1a= { config_check_modify_integer, UETIMER_T310_OKVALUES, UETIMER_T310_MODVALUES,7}} ,\ + { .s1a= { config_check_modify_integer, UETIMER_T311_OKVALUES, UETIMER_T311_MODVALUES,7}} ,\ + { .s1a= { config_check_modify_integer, UETIMER_N310_OKVALUES, UETIMER_N310_MODVALUES,8}} ,\ + { .s1a= { config_check_modify_integer, UETIMER_N311_OKVALUES, UETIMER_N311_MODVALUES,8}} ,\ + { .s5 = { NULL } } , \ + { .s5 = { NULL } } , \ + { .s5 = { NULL } } , \ + { .s5 = { NULL } } , \ + { .s5 = { NULL } } , \ + { .s5 = { NULL } } , \ + { .s5 = { NULL } } , \ + { .s5 = { NULL } } , \ + { .s5 = { NULL } } , \ + { .s5 = { NULL } } , \ + { .s5 = { NULL } } , \ + { .s5 = { NULL } } , \ + { .s5 = { NULL } } , \ + { .s5 = { NULL } } , \ + { .s5 = { NULL } } , \ + { .s5 = { NULL } } , \ + { .s5 = { NULL } } , \ + { .s5 = { NULL } } , \ + { .s5 = { NULL } } , \ + { .s5 = { NULL } } , \ + { .s5 = { NULL } } , \ + { .s5 = { NULL } } , \ + { .s5 = { NULL } } , \ + { .s5 = { NULL } } , \ + { .s5 = { NULL } } , \ + { .s5 = { NULL } } , \ + { .s5 = { NULL } } , \ + { .s5 = { NULL } } , \ + { .s5 = { NULL } } , \ + { .s5 = { NULL } } , \ + { .s5 = { NULL } } , \ + { .s5 = { NULL } } , \ + { .s5 = { NULL } } , \ + { .s5 = { NULL } } , \ + { .s5 = { NULL } } , \ + { .s5 = { NULL } } , \ + { .s5 = { NULL } } , \ + { .s5 = { NULL } } , \ + { .s5 = { NULL } } , \ + { .s5 = { NULL } } , \ + { .s5 = { NULL } } \ +} -#define CCPARAMS_DESC(ccparams) { \ - {ENB_CONFIG_STRING_FRAME_TYPE, NULL, 0, strptr:&ccparams.frame_type, defstrval:"FDD", TYPE_STRING, 0}, \ - {ENB_CONFIG_STRING_TDD_CONFIG, NULL, 0, iptr:&ccparams.tdd_config, defintval:3, TYPE_UINT, 0}, \ - {ENB_CONFIG_STRING_TDD_CONFIG_S, NULL, 0, iptr:&ccparams.tdd_config_s, defintval:0, TYPE_UINT, 0}, \ - {ENB_CONFIG_STRING_PREFIX_TYPE, NULL, 0, strptr:&ccparams.prefix_type, defstrval:"NORMAL", TYPE_STRING, 0}, \ - {ENB_CONFIG_STRING_PBCH_REPETITION, NULL, 0, strptr:&ccparams.pbch_repetition, defstrval:"FALSE", TYPE_STRING, 0}, \ - {ENB_CONFIG_STRING_EUTRA_BAND, NULL, 0, iptr:&ccparams.eutra_band, defintval:7, TYPE_UINT, 0}, \ - {ENB_CONFIG_STRING_DOWNLINK_FREQUENCY, NULL, 0, i64ptr:(int64_t *)&ccparams.downlink_frequency, defint64val:2680000000, TYPE_UINT64, 0}, \ - {ENB_CONFIG_STRING_UPLINK_FREQUENCY_OFFSET, NULL, 0, iptr:&ccparams.uplink_frequency_offset, defintval:-120000000, TYPE_INT, 0}, \ - {ENB_CONFIG_STRING_NID_CELL, NULL, 0, iptr:&ccparams.Nid_cell, defintval:0, TYPE_UINT, 0}, \ - {ENB_CONFIG_STRING_N_RB_DL, NULL, 0, iptr:&ccparams.N_RB_DL, defintval:25, TYPE_UINT, 0}, \ - {ENB_CONFIG_STRING_CELL_MBSFN, NULL, 0, iptr:&ccparams.Nid_cell_mbsfn, defintval:0, TYPE_INT, 0}, \ - {ENB_CONFIG_STRING_NB_ANT_PORTS, NULL, 0, iptr:&ccparams.nb_antenna_ports, defintval:1, TYPE_UINT, 0}, \ - {ENB_CONFIG_STRING_PRACH_ROOT, NULL, 0, iptr:&ccparams.prach_root, defintval:0, TYPE_UINT, 0}, \ - {ENB_CONFIG_STRING_PRACH_CONFIG_INDEX, NULL, 0, iptr:&ccparams.prach_config_index, defintval:0, TYPE_INT, 0}, \ - {ENB_CONFIG_STRING_PRACH_HIGH_SPEED, NULL, 0, strptr:&ccparams.prach_high_speed, defstrval:"DISABLE", TYPE_STRING, 0}, \ - {ENB_CONFIG_STRING_PRACH_ZERO_CORRELATION, NULL, 0, iptr:&ccparams.prach_zero_correlation, defintval:1, TYPE_UINT, 0}, \ - {ENB_CONFIG_STRING_PRACH_FREQ_OFFSET, NULL, 0, iptr:&ccparams.prach_freq_offset, defintval:2, TYPE_UINT, 0}, \ - {ENB_CONFIG_STRING_PUCCH_DELTA_SHIFT, NULL, 0, iptr:&ccparams.pucch_delta_shift, defintval:1, TYPE_UINT, 0}, \ - {ENB_CONFIG_STRING_PUCCH_NRB_CQI, NULL, 0, iptr:&ccparams.pucch_nRB_CQI, defintval:1, TYPE_UINT, 0}, \ - {ENB_CONFIG_STRING_PUCCH_NCS_AN, NULL, 0, iptr:&ccparams.pucch_nCS_AN, defintval:0, TYPE_UINT, 0}, \ - {ENB_CONFIG_STRING_PUCCH_N1_AN, NULL, 0, iptr:&ccparams.pucch_n1_AN, defintval:0, TYPE_UINT, 0}, \ - {ENB_CONFIG_STRING_PDSCH_RS_EPRE, NULL, 0, iptr:&ccparams.pdsch_referenceSignalPower, defintval:-29, TYPE_INT, 0}, \ - {ENB_CONFIG_STRING_PDSCH_PB, NULL, 0, iptr:&ccparams.pdsch_p_b, defintval:0, TYPE_INT, 0}, \ - {ENB_CONFIG_STRING_PUSCH_N_SB, NULL, 0, iptr:&ccparams.pusch_n_SB, defintval:1, TYPE_INT, 0}, \ - {ENB_CONFIG_STRING_PUSCH_HOPPINGMODE, NULL, 0, strptr:&ccparams.pusch_hoppingMode, defstrval:"interSubFrame", TYPE_STRING, 0}, \ - {ENB_CONFIG_STRING_PUSCH_HOPPINGOFFSET, NULL, 0, iptr:&ccparams.pusch_hoppingOffset, defintval:0, TYPE_UINT, 0}, \ - {ENB_CONFIG_STRING_PUSCH_ENABLE64QAM, NULL, 0, strptr:&ccparams.pusch_enable64QAM, defstrval:"DISABLE", TYPE_STRING, 0}, \ - {ENB_CONFIG_STRING_PUSCH_GROUP_HOPPING_EN, NULL, 0, strptr:&ccparams.pusch_groupHoppingEnabled, defstrval:"ENABLE", TYPE_STRING, 0}, \ - {ENB_CONFIG_STRING_PUSCH_GROUP_ASSIGNMENT, NULL, 0, iptr:&ccparams.pusch_groupAssignment, defintval:0, TYPE_INT, 0}, \ - {ENB_CONFIG_STRING_PUSCH_SEQUENCE_HOPPING_EN, NULL, 0, strptr:&ccparams.pusch_sequenceHoppingEnabled, defstrval:"DISABLE", TYPE_STRING, 0}, \ - {ENB_CONFIG_STRING_PUSCH_NDMRS1, NULL, 0, iptr:&ccparams.pusch_nDMRS1, defintval:0, TYPE_UINT, 0}, \ - {ENB_CONFIG_STRING_PHICH_DURATION, NULL, 0, strptr:&ccparams.phich_duration, defstrval:"NORMAL", TYPE_STRING, 0}, \ - {ENB_CONFIG_STRING_PHICH_RESOURCE, NULL, 0, strptr:&ccparams.phich_resource, defstrval:"ONESIXTH", TYPE_STRING, 0}, \ - {ENB_CONFIG_STRING_SRS_ENABLE, NULL, 0, strptr:&ccparams.srs_enable, defstrval:"DISABLE", TYPE_STRING, 0}, \ - {ENB_CONFIG_STRING_SRS_BANDWIDTH_CONFIG, NULL, 0, iptr:&ccparams.srs_BandwidthConfig, defintval:0, TYPE_UINT, 0}, \ - {ENB_CONFIG_STRING_SRS_SUBFRAME_CONFIG, NULL, 0, iptr:&ccparams.srs_SubframeConfig, defintval:0, TYPE_UINT, 0}, \ - {ENB_CONFIG_STRING_SRS_ACKNACKST_CONFIG, NULL, 0, strptr:&ccparams.srs_ackNackST, defstrval:"DISABLE", TYPE_STRING, 0}, \ - {ENB_CONFIG_STRING_SRS_MAXUPPTS, NULL, 0, strptr:&ccparams.srs_MaxUpPts, defstrval:"DISABLE", TYPE_STRING, 0}, \ - {ENB_CONFIG_STRING_PUSCH_PO_NOMINAL, NULL, 0, iptr:&ccparams.pusch_p0_Nominal, defintval:-90, TYPE_INT, 0}, \ - {ENB_CONFIG_STRING_PUSCH_ALPHA, NULL, 0, strptr:&ccparams.pusch_alpha, defstrval:"AL1", TYPE_STRING, 0}, \ - {ENB_CONFIG_STRING_PUCCH_PO_NOMINAL, NULL, 0, iptr:&ccparams.pucch_p0_Nominal, defintval:-96, TYPE_INT, 0}, \ - {ENB_CONFIG_STRING_MSG3_DELTA_PREAMBLE, NULL, 0, iptr:&ccparams.msg3_delta_Preamble, defintval:6, TYPE_UINT, 0}, \ - {ENB_CONFIG_STRING_PUCCH_DELTAF_FORMAT1, NULL, 0, strptr:&ccparams.pucch_deltaF_Format1, defstrval:"DELTAF2", TYPE_STRING, 0}, \ - {ENB_CONFIG_STRING_PUCCH_DELTAF_FORMAT1b, NULL, 0, strptr:&ccparams.pucch_deltaF_Format1b, defstrval:"deltaF3", TYPE_STRING, 0}, \ - {ENB_CONFIG_STRING_PUCCH_DELTAF_FORMAT2, NULL, 0, strptr:&ccparams.pucch_deltaF_Format2, defstrval:"deltaF0", TYPE_STRING, 0}, \ - {ENB_CONFIG_STRING_PUCCH_DELTAF_FORMAT2A, NULL, 0, strptr:&ccparams.pucch_deltaF_Format2a, defstrval:"deltaF0", TYPE_STRING, 0}, \ - {ENB_CONFIG_STRING_PUCCH_DELTAF_FORMAT2B, NULL, 0, strptr:&ccparams.pucch_deltaF_Format2b, defstrval:"deltaF0", TYPE_STRING, 0}, \ - {ENB_CONFIG_STRING_RACH_NUM_RA_PREAMBLES, NULL, 0, iptr:&ccparams.rach_numberOfRA_Preambles, defintval:4, TYPE_UINT, 0}, \ - {ENB_CONFIG_STRING_RACH_PREAMBLESGROUPACONFIG, NULL, 0, strptr:&ccparams.rach_preamblesGroupAConfig, defstrval:"DISABLE", TYPE_STRING, 0}, \ - {ENB_CONFIG_STRING_RACH_SIZEOFRA_PREAMBLESGROUPA, NULL, 0, iptr:&ccparams.rach_sizeOfRA_PreamblesGroupA, defintval:0, TYPE_UINT, 0}, \ - {ENB_CONFIG_STRING_RACH_MESSAGESIZEGROUPA, NULL, 0, iptr:&ccparams.rach_messageSizeGroupA, defintval:56, TYPE_UINT, 0}, \ - {ENB_CONFIG_STRING_RACH_MESSAGEPOWEROFFSETGROUPB, NULL, 0, strptr:&ccparams.rach_messagePowerOffsetGroupB, defstrval:"minusinfinity", TYPE_STRING, 0}, \ - {ENB_CONFIG_STRING_RACH_POWERRAMPINGSTEP, NULL, 0, iptr:&ccparams.rach_powerRampingStep, defintval:4, TYPE_INT, 0}, \ - {ENB_CONFIG_STRING_RACH_PREAMBLEINITIALRECEIVEDTARGETPOWER, NULL, 0, iptr:&ccparams.rach_preambleInitialReceivedTargetPower, defintval:-100, TYPE_INT, 0}, \ - {ENB_CONFIG_STRING_RACH_PREAMBLETRANSMAX, NULL, 0, iptr:&ccparams.rach_preambleTransMax, defintval:10, TYPE_INT, 0}, \ - {ENB_CONFIG_STRING_RACH_RARESPONSEWINDOWSIZE, NULL, 0, iptr:&ccparams.rach_raResponseWindowSize, defintval:10, TYPE_INT, 0}, \ - {ENB_CONFIG_STRING_RACH_MACCONTENTIONRESOLUTIONTIMER, NULL, 0, iptr:&ccparams.rach_macContentionResolutionTimer, defintval:48, TYPE_UINT, 0}, \ - {ENB_CONFIG_STRING_RACH_MAXHARQMSG3TX, NULL, 0, iptr:&ccparams.rach_maxHARQ_Msg3Tx, defintval:4, TYPE_UINT, 0}, \ - {ENB_CONFIG_STRING_PCCH_DEFAULT_PAGING_CYCLE, NULL, 0, iptr:&ccparams.pcch_defaultPagingCycle, defintval:128, TYPE_INT, 0}, \ - {ENB_CONFIG_STRING_PCCH_NB, NULL, 0, strptr:&ccparams.pcch_nB, defstrval:"oneT", TYPE_STRING, 0}, \ - {ENB_CONFIG_STRING_DRX_CONFIG_PRESENT, NULL, 0, strptr:&ccparams.drx_Config_present, defstrval:"prNothing", TYPE_STRING, 0}, \ - {ENB_CONFIG_STRING_DRX_ONDURATIONTIMER, NULL, 0, strptr:&ccparams.drx_onDurationTimer, defstrval:"psf10", TYPE_STRING, 0}, \ - {ENB_CONFIG_STRING_DRX_INACTIVITYTIMER, NULL, 0, strptr:&ccparams.drx_InactivityTimer, defstrval:"psf10", TYPE_STRING, 0}, \ - {ENB_CONFIG_STRING_DRX_RETRANSMISSIONTIMER, NULL, 0, strptr:&ccparams.drx_RetransmissionTimer, defstrval:"psf8", TYPE_STRING, 0}, \ - {ENB_CONFIG_STRING_DRX_LONGDRX_CYCLESTARTOFFSET_PRESENT, NULL, 0, strptr:&ccparams.drx_longDrx_CycleStartOffset_present, defstrval:"prSf128", TYPE_STRING, 0}, \ - {ENB_CONFIG_STRING_DRX_LONGDRX_CYCLESTARTOFFSET, NULL, 0, iptr:&ccparams.drx_longDrx_CycleStartOffset, defintval:0, TYPE_UINT, 0}, \ - {ENB_CONFIG_STRING_DRX_SHORTDRX_CYCLE, NULL, 0, strptr:&ccparams.drx_shortDrx_Cycle, defstrval:"sf32", TYPE_STRING, 0}, \ - {ENB_CONFIG_STRING_DRX_SHORTDRX_SHORTCYCLETIMER, NULL, 0, iptr:&ccparams.drx_shortDrx_ShortCycleTimer, defintval:3, TYPE_UINT, 0}, \ - {ENB_CONFIG_STRING_BCCH_MODIFICATIONPERIODCOEFF, NULL, 0, iptr:&ccparams.bcch_modificationPeriodCoeff, defintval:2, TYPE_UINT, 0}, \ - {ENB_CONFIG_STRING_UETIMERS_T300, NULL, 0, iptr:&ccparams.ue_TimersAndConstants_t300, defintval:1000, TYPE_UINT, 0}, \ - {ENB_CONFIG_STRING_UETIMERS_T301, NULL, 0, iptr:&ccparams.ue_TimersAndConstants_t301, defintval:1000, TYPE_UINT, 0}, \ - {ENB_CONFIG_STRING_UETIMERS_T310, NULL, 0, iptr:&ccparams.ue_TimersAndConstants_t310, defintval:1000, TYPE_UINT, 0}, \ - {ENB_CONFIG_STRING_UETIMERS_T311, NULL, 0, iptr:&ccparams.ue_TimersAndConstants_t311, defintval:10000, TYPE_UINT, 0}, \ - {ENB_CONFIG_STRING_UETIMERS_N310, NULL, 0, iptr:&ccparams.ue_TimersAndConstants_n310, defintval:20, TYPE_UINT, 0}, \ - {ENB_CONFIG_STRING_UETIMERS_N311, NULL, 0, iptr:&ccparams.ue_TimersAndConstants_n311, defintval:1, TYPE_UINT, 0}, \ - {ENB_CONFIG_STRING_UE_TRANSMISSION_MODE, NULL, 0, iptr:&ccparams.ue_TransmissionMode, defintval:1, TYPE_UINT, 0}, \ - {ENB_CONFIG_STRING_UE_MULTIPLE_MAX, NULL, 0, iptr:&ccparams.ue_multiple_max, defintval:4, TYPE_UINT, 0}, \ - {ENB_CONFIG_STRING_MBMS_DEDICATED_SERVING_CELL, NULL, 0, strptr:&ccparams.mbms_dedicated_serving_cell, defstrval:"DISABLE", TYPE_STRING, 0} \ - } +/*-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------*/ +/* component carriers configuration parameters */ +/* optname helpstr paramflags XXXptr defXXXval type numelt */ +/*-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------*/ +#define CCPARAMS_DESC(ccparams) { \ + {ENB_CONFIG_STRING_FRAME_TYPE, NULL, 0, strptr:&ccparams.frame_type, defstrval:"FDD", TYPE_STRING, 0}, \ + {ENB_CONFIG_STRING_TDD_CONFIG, NULL, 0, iptr:&ccparams.tdd_config, defintval:3, TYPE_UINT, 0}, \ + {ENB_CONFIG_STRING_TDD_CONFIG_S, NULL, 0, iptr:&ccparams.tdd_config_s, defintval:0, TYPE_UINT, 0}, \ + {ENB_CONFIG_STRING_PREFIX_TYPE, NULL, 0, strptr:&ccparams.prefix_type, defstrval:"NORMAL", TYPE_STRING, 0}, \ + {ENB_CONFIG_STRING_PBCH_REPETITION, NULL, 0, strptr:&ccparams.pbch_repetition, defstrval:"FALSE", TYPE_STRING, 0}, \ + {ENB_CONFIG_STRING_EUTRA_BAND, NULL, 0, iptr:&ccparams.eutra_band, defintval:7, TYPE_UINT, 0}, \ + {ENB_CONFIG_STRING_DOWNLINK_FREQUENCY, NULL, 0, i64ptr:(int64_t *)&ccparams.downlink_frequency, defint64val:2680000000, TYPE_UINT64, 0}, \ + {ENB_CONFIG_STRING_UPLINK_FREQUENCY_OFFSET, NULL, 0, iptr:&ccparams.uplink_frequency_offset, defintval:-120000000, TYPE_INT, 0}, \ + {ENB_CONFIG_STRING_NID_CELL, NULL, 0, iptr:&ccparams.Nid_cell, defintval:0, TYPE_UINT, 0}, \ + {ENB_CONFIG_STRING_N_RB_DL, NULL, 0, iptr:&ccparams.N_RB_DL, defintval:25, TYPE_UINT, 0}, \ + {ENB_CONFIG_STRING_CELL_MBSFN, NULL, 0, iptr:&ccparams.Nid_cell_mbsfn, defintval:0, TYPE_INT, 0}, \ + {ENB_CONFIG_STRING_NB_ANT_PORTS, NULL, 0, iptr:&ccparams.nb_antenna_ports, defintval:1, TYPE_UINT, 0}, \ + {ENB_CONFIG_STRING_PRACH_ROOT, NULL, 0, iptr:&ccparams.prach_root, defintval:0, TYPE_UINT, 0}, \ + {ENB_CONFIG_STRING_PRACH_CONFIG_INDEX, NULL, 0, iptr:&ccparams.prach_config_index, defintval:0, TYPE_INT, 0}, \ + {ENB_CONFIG_STRING_PRACH_HIGH_SPEED, NULL, 0, strptr:&ccparams.prach_high_speed, defstrval:"DISABLE", TYPE_STRING, 0}, \ + {ENB_CONFIG_STRING_PRACH_ZERO_CORRELATION, NULL, 0, iptr:&ccparams.prach_zero_correlation, defintval:1, TYPE_UINT, 0}, \ + {ENB_CONFIG_STRING_PRACH_FREQ_OFFSET, NULL, 0, iptr:&ccparams.prach_freq_offset, defintval:2, TYPE_UINT, 0}, \ + {ENB_CONFIG_STRING_PUCCH_DELTA_SHIFT, NULL, 0, iptr:&ccparams.pucch_delta_shift, defintval:1, TYPE_UINT, 0}, \ + {ENB_CONFIG_STRING_PUCCH_NRB_CQI, NULL, 0, iptr:&ccparams.pucch_nRB_CQI, defintval:1, TYPE_UINT, 0}, \ + {ENB_CONFIG_STRING_PUCCH_NCS_AN, NULL, 0, iptr:&ccparams.pucch_nCS_AN, defintval:0, TYPE_UINT, 0}, \ + {ENB_CONFIG_STRING_PUCCH_N1_AN, NULL, 0, iptr:&ccparams.pucch_n1_AN, defintval:0, TYPE_UINT, 0}, \ + {ENB_CONFIG_STRING_PDSCH_RS_EPRE, NULL, 0, iptr:&ccparams.pdsch_referenceSignalPower, defintval:-29, TYPE_INT, 0}, \ + {ENB_CONFIG_STRING_PDSCH_PB, NULL, 0, iptr:&ccparams.pdsch_p_b, defintval:0, TYPE_INT, 0}, \ + {ENB_CONFIG_STRING_PUSCH_N_SB, NULL, 0, iptr:&ccparams.pusch_n_SB, defintval:1, TYPE_INT, 0}, \ + {ENB_CONFIG_STRING_PUSCH_HOPPINGMODE, NULL, 0, strptr:&ccparams.pusch_hoppingMode, defstrval:"interSubFrame", TYPE_STRING, 0}, \ + {ENB_CONFIG_STRING_PUSCH_HOPPINGOFFSET, NULL, 0, iptr:&ccparams.pusch_hoppingOffset, defintval:0, TYPE_UINT, 0}, \ + {ENB_CONFIG_STRING_PUSCH_ENABLE64QAM, NULL, 0, strptr:&ccparams.pusch_enable64QAM, defstrval:"DISABLE", TYPE_STRING, 0}, \ + {ENB_CONFIG_STRING_PUSCH_GROUP_HOPPING_EN, NULL, 0, strptr:&ccparams.pusch_groupHoppingEnabled, defstrval:"ENABLE", TYPE_STRING, 0}, \ + {ENB_CONFIG_STRING_PUSCH_GROUP_ASSIGNMENT, NULL, 0, iptr:&ccparams.pusch_groupAssignment, defintval:0, TYPE_INT, 0}, \ + {ENB_CONFIG_STRING_PUSCH_SEQUENCE_HOPPING_EN, NULL, 0, strptr:&ccparams.pusch_sequenceHoppingEnabled, defstrval:"DISABLE", TYPE_STRING, 0}, \ + {ENB_CONFIG_STRING_PUSCH_NDMRS1, NULL, 0, iptr:&ccparams.pusch_nDMRS1, defintval:0, TYPE_UINT, 0}, \ + {ENB_CONFIG_STRING_PHICH_DURATION, NULL, 0, strptr:&ccparams.phich_duration, defstrval:"NORMAL", TYPE_STRING, 0}, \ + {ENB_CONFIG_STRING_PHICH_RESOURCE, NULL, 0, strptr:&ccparams.phich_resource, defstrval:"ONESIXTH", TYPE_STRING, 0}, \ + {ENB_CONFIG_STRING_SRS_ENABLE, NULL, 0, strptr:&ccparams.srs_enable, defstrval:"DISABLE", TYPE_STRING, 0}, \ + {ENB_CONFIG_STRING_SRS_BANDWIDTH_CONFIG, NULL, 0, iptr:&ccparams.srs_BandwidthConfig, defintval:0, TYPE_UINT, 0}, \ + {ENB_CONFIG_STRING_SRS_SUBFRAME_CONFIG, NULL, 0, iptr:&ccparams.srs_SubframeConfig, defintval:0, TYPE_UINT, 0}, \ + {ENB_CONFIG_STRING_SRS_ACKNACKST_CONFIG, NULL, 0, strptr:&ccparams.srs_ackNackST, defstrval:"DISABLE", TYPE_STRING, 0}, \ + {ENB_CONFIG_STRING_SRS_MAXUPPTS, NULL, 0, strptr:&ccparams.srs_MaxUpPts, defstrval:"DISABLE", TYPE_STRING, 0}, \ + {ENB_CONFIG_STRING_PUSCH_PO_NOMINAL, NULL, 0, iptr:&ccparams.pusch_p0_Nominal, defintval:-90, TYPE_INT, 0}, \ + {ENB_CONFIG_STRING_PUSCH_ALPHA, NULL, 0, strptr:&ccparams.pusch_alpha, defstrval:"AL1", TYPE_STRING, 0}, \ + {ENB_CONFIG_STRING_PUCCH_PO_NOMINAL, NULL, 0, iptr:&ccparams.pucch_p0_Nominal, defintval:-96, TYPE_INT, 0}, \ + {ENB_CONFIG_STRING_MSG3_DELTA_PREAMBLE, NULL, 0, iptr:&ccparams.msg3_delta_Preamble, defintval:6, TYPE_UINT, 0}, \ + {ENB_CONFIG_STRING_PUCCH_DELTAF_FORMAT1, NULL, 0, strptr:&ccparams.pucch_deltaF_Format1, defstrval:"DELTAF2", TYPE_STRING, 0}, \ + {ENB_CONFIG_STRING_PUCCH_DELTAF_FORMAT1b, NULL, 0, strptr:&ccparams.pucch_deltaF_Format1b, defstrval:"deltaF3", TYPE_STRING, 0}, \ + {ENB_CONFIG_STRING_PUCCH_DELTAF_FORMAT2, NULL, 0, strptr:&ccparams.pucch_deltaF_Format2, defstrval:"deltaF0", TYPE_STRING, 0}, \ + {ENB_CONFIG_STRING_PUCCH_DELTAF_FORMAT2A, NULL, 0, strptr:&ccparams.pucch_deltaF_Format2a, defstrval:"deltaF0", TYPE_STRING, 0}, \ + {ENB_CONFIG_STRING_PUCCH_DELTAF_FORMAT2B, NULL, 0, strptr:&ccparams.pucch_deltaF_Format2b, defstrval:"deltaF0", TYPE_STRING, 0}, \ + {ENB_CONFIG_STRING_RACH_NUM_RA_PREAMBLES, NULL, 0, iptr:&ccparams.rach_numberOfRA_Preambles, defintval:4, TYPE_UINT, 0}, \ + {ENB_CONFIG_STRING_RACH_PREAMBLESGROUPACONFIG, NULL, 0, strptr:&ccparams.rach_preamblesGroupAConfig, defstrval:"DISABLE", TYPE_STRING, 0}, \ + {ENB_CONFIG_STRING_RACH_SIZEOFRA_PREAMBLESGROUPA, NULL, 0, iptr:&ccparams.rach_sizeOfRA_PreamblesGroupA, defintval:0, TYPE_UINT, 0}, \ + {ENB_CONFIG_STRING_RACH_MESSAGESIZEGROUPA, NULL, 0, iptr:&ccparams.rach_messageSizeGroupA, defintval:56, TYPE_UINT, 0}, \ + {ENB_CONFIG_STRING_RACH_MESSAGEPOWEROFFSETGROUPB, NULL, 0, strptr:&ccparams.rach_messagePowerOffsetGroupB, defstrval:"minusinfinity", TYPE_STRING, 0}, \ + {ENB_CONFIG_STRING_RACH_POWERRAMPINGSTEP, NULL, 0, iptr:&ccparams.rach_powerRampingStep, defintval:4, TYPE_INT, 0}, \ + {ENB_CONFIG_STRING_RACH_PREAMBLEINITIALRECEIVEDTARGETPOWER, NULL, 0, iptr:&ccparams.rach_preambleInitialReceivedTargetPower, defintval:-100, TYPE_INT, 0}, \ + {ENB_CONFIG_STRING_RACH_PREAMBLETRANSMAX, NULL, 0, iptr:&ccparams.rach_preambleTransMax, defintval:10, TYPE_INT, 0}, \ + {ENB_CONFIG_STRING_RACH_RARESPONSEWINDOWSIZE, NULL, 0, iptr:&ccparams.rach_raResponseWindowSize, defintval:10, TYPE_INT, 0}, \ + {ENB_CONFIG_STRING_RACH_MACCONTENTIONRESOLUTIONTIMER, NULL, 0, iptr:&ccparams.rach_macContentionResolutionTimer, defintval:48, TYPE_UINT, 0}, \ + {ENB_CONFIG_STRING_RACH_MAXHARQMSG3TX, NULL, 0, iptr:&ccparams.rach_maxHARQ_Msg3Tx, defintval:4, TYPE_UINT, 0}, \ + {ENB_CONFIG_STRING_PCCH_DEFAULT_PAGING_CYCLE, NULL, 0, iptr:&ccparams.pcch_defaultPagingCycle, defintval:128, TYPE_INT, 0}, \ + {ENB_CONFIG_STRING_PCCH_NB, NULL, 0, strptr:&ccparams.pcch_nB, defstrval:"oneT", TYPE_STRING, 0}, \ + {ENB_CONFIG_STRING_DRX_CONFIG_PRESENT, NULL, 0, strptr:&ccparams.drx_Config_present, defstrval:"prNothing", TYPE_STRING, 0}, \ + {ENB_CONFIG_STRING_DRX_ONDURATIONTIMER, NULL, 0, strptr:&ccparams.drx_onDurationTimer, defstrval:"psf10", TYPE_STRING, 0}, \ + {ENB_CONFIG_STRING_DRX_INACTIVITYTIMER, NULL, 0, strptr:&ccparams.drx_InactivityTimer, defstrval:"psf10", TYPE_STRING, 0}, \ + {ENB_CONFIG_STRING_DRX_RETRANSMISSIONTIMER, NULL, 0, strptr:&ccparams.drx_RetransmissionTimer, defstrval:"psf8", TYPE_STRING, 0}, \ + {ENB_CONFIG_STRING_DRX_LONGDRX_CYCLESTARTOFFSET_PRESENT, NULL, 0, strptr:&ccparams.drx_longDrx_CycleStartOffset_present, defstrval:"prSf128", TYPE_STRING, 0}, \ + {ENB_CONFIG_STRING_DRX_LONGDRX_CYCLESTARTOFFSET, NULL, 0, iptr:&ccparams.drx_longDrx_CycleStartOffset, defintval:0, TYPE_UINT, 0}, \ + {ENB_CONFIG_STRING_DRX_SHORTDRX_CYCLE, NULL, 0, strptr:&ccparams.drx_shortDrx_Cycle, defstrval:"sf32", TYPE_STRING, 0}, \ + {ENB_CONFIG_STRING_DRX_SHORTDRX_SHORTCYCLETIMER, NULL, 0, iptr:&ccparams.drx_shortDrx_ShortCycleTimer, defintval:3, TYPE_UINT, 0}, \ + {ENB_CONFIG_STRING_BCCH_MODIFICATIONPERIODCOEFF, NULL, 0, iptr:&ccparams.bcch_modificationPeriodCoeff, defintval:2, TYPE_UINT, 0}, \ + {ENB_CONFIG_STRING_UETIMERS_T300, NULL, 0, iptr:&ccparams.ue_TimersAndConstants_t300, defintval:1000, TYPE_UINT, 0}, \ + {ENB_CONFIG_STRING_UETIMERS_T301, NULL, 0, iptr:&ccparams.ue_TimersAndConstants_t301, defintval:1000, TYPE_UINT, 0}, \ + {ENB_CONFIG_STRING_UETIMERS_T310, NULL, 0, iptr:&ccparams.ue_TimersAndConstants_t310, defintval:1000, TYPE_UINT, 0}, \ + {ENB_CONFIG_STRING_UETIMERS_T311, NULL, 0, iptr:&ccparams.ue_TimersAndConstants_t311, defintval:10000, TYPE_UINT, 0}, \ + {ENB_CONFIG_STRING_UETIMERS_N310, NULL, 0, iptr:&ccparams.ue_TimersAndConstants_n310, defintval:20, TYPE_UINT, 0}, \ + {ENB_CONFIG_STRING_UETIMERS_N311, NULL, 0, iptr:&ccparams.ue_TimersAndConstants_n311, defintval:1, TYPE_UINT, 0}, \ + {ENB_CONFIG_STRING_UE_TRANSMISSION_MODE, NULL, 0, iptr:&ccparams.ue_TransmissionMode, defintval:1, TYPE_UINT, 0}, \ + {ENB_CONFIG_STRING_UE_MULTIPLE_MAX, NULL, 0, iptr:&ccparams.ue_multiple_max, defintval:4, TYPE_UINT, 0}, \ + {ENB_CONFIG_STRING_MBMS_DEDICATED_SERVING_CELL, NULL, 0, strptr:&ccparams.mbms_dedicated_serving_cell, defstrval:"DISABLE", TYPE_STRING, 0} \ +} - -#define ENB_CONFIG_FRAME_TYPE_IDX 0 -#define ENB_CONFIG_TDD_CONFIG_IDX 1 -#define ENB_CONFIG_TDD_CONFIG_S_IDX 2 -#define ENB_CONFIG_PREFIX_TYPE_IDX 3 -#define ENB_CONFIG_PBCH_REPETITION_IDX 4 -#define ENB_CONFIG_EUTRA_BAND_IDX 5 -#define ENB_CONFIG_DOWNLINK_FREQUENCY_IDX 6 -#define ENB_CONFIG_UPLINK_FREQUENCY_OFFSET_IDX 7 -#define ENB_CONFIG_NID_CELL_IDX 8 -#define ENB_CONFIG_N_RB_DL_IDX 9 -#define ENB_CONFIG_CELL_MBSFN_IDX 10 -#define ENB_CONFIG_NB_ANT_PORTS_IDX 11 -#define ENB_CONFIG_PRACH_ROOT_IDX 12 -#define ENB_CONFIG_PRACH_CONFIG_INDEX_IDX 13 -#define ENB_CONFIG_PRACH_HIGH_SPEED_IDX 14 -#define ENB_CONFIG_PRACH_ZERO_CORRELATION_IDX 15 -#define ENB_CONFIG_PRACH_FREQ_OFFSET_IDX 16 -#define ENB_CONFIG_PUCCH_DELTA_SHIFT_IDX 17 -#define ENB_CONFIG_PUCCH_NRB_CQI_IDX 18 -#define ENB_CONFIG_PUCCH_NCS_AN_IDX 19 -#define ENB_CONFIG_PUCCH_N1_AN_IDX 20 -#define ENB_CONFIG_PDSCH_RS_EPRE_IDX 21 -#define ENB_CONFIG_PDSCH_PB_IDX 22 -#define ENB_CONFIG_PUSCH_N_SB_IDX 23 -#define ENB_CONFIG_PUSCH_HOPPINGMODE_IDX 24 -#define ENB_CONFIG_PUSCH_HOPPINGOFFSET_IDX 25 -#define ENB_CONFIG_PUSCH_ENABLE64QAM_IDX 26 -#define ENB_CONFIG_PUSCH_GROUP_HOPPING_EN_IDX 27 -#define ENB_CONFIG_PUSCH_GROUP_ASSIGNMENT_IDX 28 -#define ENB_CONFIG_PUSCH_SEQUENCE_HOPPING_EN_IDX 29 -#define ENB_CONFIG_PUSCH_NDMRS1_IDX 30 -#define ENB_CONFIG_PHICH_DURATION_IDX 31 -#define ENB_CONFIG_PHICH_RESOURCE_IDX 32 -#define ENB_CONFIG_SRS_ENABLE_IDX 33 -#define ENB_CONFIG_SRS_BANDWIDTH_CONFIG_IDX 34 -#define ENB_CONFIG_SRS_SUBFRAME_CONFIG_IDX 35 -#define ENB_CONFIG_SRS_ACKNACKST_CONFIG_IDX 36 -#define ENB_CONFIG_SRS_MAXUPPTS_IDX 37 -#define ENB_CONFIG_PUSCH_PO_NOMINAL_IDX 38 -#define ENB_CONFIG_PUSCH_ALPHA_IDX 39 -#define ENB_CONFIG_PUCCH_PO_NOMINAL_IDX 40 -#define ENB_CONFIG_MSG3_DELTA_PREAMBLE_IDX 41 -#define ENB_CONFIG_PUCCH_DELTAF_FORMAT1_IDX 42 -#define ENB_CONFIG_PUCCH_DELTAF_FORMAT1b_IDX 43 -#define ENB_CONFIG_PUCCH_DELTAF_FORMAT2_IDX 44 -#define ENB_CONFIG_PUCCH_DELTAF_FORMAT2A_IDX 45 -#define ENB_CONFIG_PUCCH_DELTAF_FORMAT2B_IDX 46 -#define ENB_CONFIG_RACH_NUM_RA_PREAMBLES_IDX 47 -#define ENB_CONFIG_RACH_PREAMBLESGROUPACONFIG_IDX 48 -#define ENB_CONFIG_RACH_SIZEOFRA_PREAMBLESGROUPA_IDX 49 -#define ENB_CONFIG_RACH_MESSAGESIZEGROUPA_IDX 50 -#define ENB_CONFIG_RACH_MESSAGEPOWEROFFSETGROUPB_IDX 51 -#define ENB_CONFIG_RACH_POWERRAMPINGSTEP_IDX 52 -#define ENB_CONFIG_RACH_PREAMBLEINITIALRECEIVEDTARGETPOWER_IDX 53 -#define ENB_CONFIG_RACH_PREAMBLETRANSMAX_IDX 54 -#define ENB_CONFIG_RACH_RARESPONSEWINDOWSIZE_IDX 55 -#define ENB_CONFIG_RACH_MACCONTENTIONRESOLUTIONTIMER_IDX 56 -#define ENB_CONFIG_RACH_MAXHARQMSG3TX_IDX 57 -#define ENB_CONFIG_PCCH_DEFAULT_PAGING_CYCLE_IDX 58 -#define ENB_CONFIG_PCCH_NB_IDX 59 -#define ENB_CONFIG_STRING_DRX_CONFIG_PRESENT_IDX 60 -#define ENB_CONFIG_STRING_DRX_ONDURATIONTIMER_IDX 61 -#define ENB_CONFIG_STRING_DRX_INACTIVITYTIMER_IDX 62 -#define ENB_CONFIG_STRING_DRX_RETRANSMISSIONTIMER_IDX 63 +#define ENB_CONFIG_FRAME_TYPE_IDX 0 +#define ENB_CONFIG_TDD_CONFIG_IDX 1 +#define ENB_CONFIG_TDD_CONFIG_S_IDX 2 +#define ENB_CONFIG_PREFIX_TYPE_IDX 3 +#define ENB_CONFIG_PBCH_REPETITION_IDX 4 +#define ENB_CONFIG_EUTRA_BAND_IDX 5 +#define ENB_CONFIG_DOWNLINK_FREQUENCY_IDX 6 +#define ENB_CONFIG_UPLINK_FREQUENCY_OFFSET_IDX 7 +#define ENB_CONFIG_NID_CELL_IDX 8 +#define ENB_CONFIG_N_RB_DL_IDX 9 +#define ENB_CONFIG_CELL_MBSFN_IDX 10 +#define ENB_CONFIG_NB_ANT_PORTS_IDX 11 +#define ENB_CONFIG_PRACH_ROOT_IDX 12 +#define ENB_CONFIG_PRACH_CONFIG_INDEX_IDX 13 +#define ENB_CONFIG_PRACH_HIGH_SPEED_IDX 14 +#define ENB_CONFIG_PRACH_ZERO_CORRELATION_IDX 15 +#define ENB_CONFIG_PRACH_FREQ_OFFSET_IDX 16 +#define ENB_CONFIG_PUCCH_DELTA_SHIFT_IDX 17 +#define ENB_CONFIG_PUCCH_NRB_CQI_IDX 18 +#define ENB_CONFIG_PUCCH_NCS_AN_IDX 19 +#define ENB_CONFIG_PUCCH_N1_AN_IDX 20 +#define ENB_CONFIG_PDSCH_RS_EPRE_IDX 21 +#define ENB_CONFIG_PDSCH_PB_IDX 22 +#define ENB_CONFIG_PUSCH_N_SB_IDX 23 +#define ENB_CONFIG_PUSCH_HOPPINGMODE_IDX 24 +#define ENB_CONFIG_PUSCH_HOPPINGOFFSET_IDX 25 +#define ENB_CONFIG_PUSCH_ENABLE64QAM_IDX 26 +#define ENB_CONFIG_PUSCH_GROUP_HOPPING_EN_IDX 27 +#define ENB_CONFIG_PUSCH_GROUP_ASSIGNMENT_IDX 28 +#define ENB_CONFIG_PUSCH_SEQUENCE_HOPPING_EN_IDX 29 +#define ENB_CONFIG_PUSCH_NDMRS1_IDX 30 +#define ENB_CONFIG_PHICH_DURATION_IDX 31 +#define ENB_CONFIG_PHICH_RESOURCE_IDX 32 +#define ENB_CONFIG_SRS_ENABLE_IDX 33 +#define ENB_CONFIG_SRS_BANDWIDTH_CONFIG_IDX 34 +#define ENB_CONFIG_SRS_SUBFRAME_CONFIG_IDX 35 +#define ENB_CONFIG_SRS_ACKNACKST_CONFIG_IDX 36 +#define ENB_CONFIG_SRS_MAXUPPTS_IDX 37 +#define ENB_CONFIG_PUSCH_PO_NOMINAL_IDX 38 +#define ENB_CONFIG_PUSCH_ALPHA_IDX 39 +#define ENB_CONFIG_PUCCH_PO_NOMINAL_IDX 40 +#define ENB_CONFIG_MSG3_DELTA_PREAMBLE_IDX 41 +#define ENB_CONFIG_PUCCH_DELTAF_FORMAT1_IDX 42 +#define ENB_CONFIG_PUCCH_DELTAF_FORMAT1b_IDX 43 +#define ENB_CONFIG_PUCCH_DELTAF_FORMAT2_IDX 44 +#define ENB_CONFIG_PUCCH_DELTAF_FORMAT2A_IDX 45 +#define ENB_CONFIG_PUCCH_DELTAF_FORMAT2B_IDX 46 +#define ENB_CONFIG_RACH_NUM_RA_PREAMBLES_IDX 47 +#define ENB_CONFIG_RACH_PREAMBLESGROUPACONFIG_IDX 48 +#define ENB_CONFIG_RACH_SIZEOFRA_PREAMBLESGROUPA_IDX 49 +#define ENB_CONFIG_RACH_MESSAGESIZEGROUPA_IDX 50 +#define ENB_CONFIG_RACH_MESSAGEPOWEROFFSETGROUPB_IDX 51 +#define ENB_CONFIG_RACH_POWERRAMPINGSTEP_IDX 52 +#define ENB_CONFIG_RACH_PREAMBLEINITIALRECEIVEDTARGETPOWER_IDX 53 +#define ENB_CONFIG_RACH_PREAMBLETRANSMAX_IDX 54 +#define ENB_CONFIG_RACH_RARESPONSEWINDOWSIZE_IDX 55 +#define ENB_CONFIG_RACH_MACCONTENTIONRESOLUTIONTIMER_IDX 56 +#define ENB_CONFIG_RACH_MAXHARQMSG3TX_IDX 57 +#define ENB_CONFIG_PCCH_DEFAULT_PAGING_CYCLE_IDX 58 +#define ENB_CONFIG_PCCH_NB_IDX 59 +#define ENB_CONFIG_STRING_DRX_CONFIG_PRESENT_IDX 60 +#define ENB_CONFIG_STRING_DRX_ONDURATIONTIMER_IDX 61 +#define ENB_CONFIG_STRING_DRX_INACTIVITYTIMER_IDX 62 +#define ENB_CONFIG_STRING_DRX_RETRANSMISSIONTIMER_IDX 63 #define ENB_CONFIG_STRING_DRX_LONGDRX_CYCLESTARTOFFSET_PRESENT_IDX 64 -#define ENB_CONFIG_STRING_DRX_LONGDRX_CYCLESTARTOFFSET_IDX 65 -#define ENB_CONFIG_STRING_DRX_SHORTDRX_CYCLE_IDX 66 -#define ENB_CONFIG_STRING_DRX_SHORTDRX_SHORTCYCLETIMER_IDX 67 -#define ENB_CONFIG_BCCH_MODIFICATIONPERIODCOEFF_IDX 68 -#define ENB_CONFIG_UETIMERS_T300_IDX 69 -#define ENB_CONFIG_UETIMERS_T301_IDX 70 -#define ENB_CONFIG_UETIMERS_T310_IDX 71 -#define ENB_CONFIG_UETIMERS_T311_IDX 72 -#define ENB_CONFIG_UETIMERS_N310_IDX 73 -#define ENB_CONFIG_UETIMERS_N311_IDX 74 -#define ENB_CONFIG_UE_TRANSMISSION_MODE_IDX 75 -#define ENB_CONFIG_MBMS_DEDICATED_SERVING_CELL_IDX 76 +#define ENB_CONFIG_STRING_DRX_LONGDRX_CYCLESTARTOFFSET_IDX 65 +#define ENB_CONFIG_STRING_DRX_SHORTDRX_CYCLE_IDX 66 +#define ENB_CONFIG_STRING_DRX_SHORTDRX_SHORTCYCLETIMER_IDX 67 +#define ENB_CONFIG_BCCH_MODIFICATIONPERIODCOEFF_IDX 68 +#define ENB_CONFIG_UETIMERS_T300_IDX 69 +#define ENB_CONFIG_UETIMERS_T301_IDX 70 +#define ENB_CONFIG_UETIMERS_T310_IDX 71 +#define ENB_CONFIG_UETIMERS_T311_IDX 72 +#define ENB_CONFIG_UETIMERS_N310_IDX 73 +#define ENB_CONFIG_UETIMERS_N311_IDX 74 +#define ENB_CONFIG_UE_TRANSMISSION_MODE_IDX 75 +#define ENB_CONFIG_MBMS_DEDICATED_SERVING_CELL_IDX 76 /*------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------*/ /* SRB1 configuration parameters section name */ @@ -867,15 +867,15 @@ typedef struct srb1_params_s { /*-------------------------------------------------------------------------------------------------------------------------------------*/ /* MME configuration parameters */ -/* optname helpstr paramflags XXXptr defXXXval type numelt */ +/* optname helpstr paramflags XXXptr defXXXval type numelt */ /*-------------------------------------------------------------------------------------------------------------------------------------*/ #define S1PARAMS_DESC { \ - {ENB_CONFIG_STRING_MME_IPV4_ADDRESS, NULL, 0, uptr:NULL, defstrval:NULL, TYPE_STRING, 0}, \ - {ENB_CONFIG_STRING_MME_IPV6_ADDRESS, NULL, 0, uptr:NULL, defstrval:NULL, TYPE_STRING, 0}, \ - {ENB_CONFIG_STRING_MME_IP_ADDRESS_ACTIVE, NULL, 0, uptr:NULL, defstrval:NULL, TYPE_STRING, 0}, \ - {ENB_CONFIG_STRING_MME_IP_ADDRESS_PREFERENCE, NULL, 0, uptr:NULL, defstrval:NULL, TYPE_STRING, 0}, \ - {ENB_CONFIG_STRING_MME_BROADCAST_PLMN_INDEX, NULL, 0, uptr:NULL, defintarrayval:NULL,TYPE_UINTARRAY, 6} \ - } + {ENB_CONFIG_STRING_MME_IPV4_ADDRESS, NULL, 0, uptr:NULL, defstrval:NULL, TYPE_STRING, 0}, \ + {ENB_CONFIG_STRING_MME_IPV6_ADDRESS, NULL, 0, uptr:NULL, defstrval:NULL, TYPE_STRING, 0}, \ + {ENB_CONFIG_STRING_MME_IP_ADDRESS_ACTIVE, NULL, 0, uptr:NULL, defstrval:NULL, TYPE_STRING, 0}, \ + {ENB_CONFIG_STRING_MME_IP_ADDRESS_PREFERENCE, NULL, 0, uptr:NULL, defstrval:NULL, TYPE_STRING, 0}, \ + {ENB_CONFIG_STRING_MME_BROADCAST_PLMN_INDEX, NULL, 0, uptr:NULL, defintarrayval:NULL, TYPE_UINTARRAY, 6} \ +} #define ENB_MME_IPV4_ADDRESS_IDX 0 #define ENB_MME_IPV6_ADDRESS_IDX 1 @@ -896,14 +896,14 @@ typedef struct srb1_params_s { /*-------------------------------------------------------------------------------------------------------------------------------------*/ -/* X2 configuration parameters */ +/* X2 configuration parameters */ /* optname helpstr paramflags XXXptr defXXXval type numelt */ /*-------------------------------------------------------------------------------------------------------------------------------------*/ #define X2PARAMS_DESC { \ - {ENB_CONFIG_STRING_TARGET_ENB_X2_IPV4_ADDRESS, NULL, 0, uptr:NULL, defstrval:NULL, TYPE_STRING, 0}, \ - {ENB_CONFIG_STRING_TARGET_ENB_X2_IPV6_ADDRESS, NULL, 0, uptr:NULL, defstrval:NULL, TYPE_STRING, 0}, \ - {ENB_CONFIG_STRING_TARGET_ENB_X2_IP_ADDRESS_PREFERENCE, NULL, 0, uptr:NULL, defstrval:NULL, TYPE_STRING, 0}, \ - } + {ENB_CONFIG_STRING_TARGET_ENB_X2_IPV4_ADDRESS, NULL, 0, uptr:NULL, defstrval:NULL, TYPE_STRING, 0}, \ + {ENB_CONFIG_STRING_TARGET_ENB_X2_IPV6_ADDRESS, NULL, 0, uptr:NULL, defstrval:NULL, TYPE_STRING, 0}, \ + {ENB_CONFIG_STRING_TARGET_ENB_X2_IP_ADDRESS_PREFERENCE, NULL, 0, uptr:NULL, defstrval:NULL, TYPE_STRING, 0}, \ +} #define ENB_X2_IPV4_ADDRESS_IDX 0 #define ENB_X2_IPV6_ADDRESS_IDX 1 @@ -939,8 +939,9 @@ typedef struct srb1_params_s { #define ENB_INTERFACE_NAME_FOR_S1U_IDX 2 #define ENB_IPV4_ADDR_FOR_S1U_IDX 3 #define ENB_PORT_FOR_S1U_IDX 4 -#define ENB_IPV4_ADDR_FOR_X2C_IDX 5 -#define ENB_PORT_FOR_X2C_IDX 6 +#define ENB_IPV4_ADDR_FOR_X2C_IDX 5 +#define ENB_PORT_FOR_X2C_IDX 6 + /* S1 interface configuration parameters names */ #define ENB_CONFIG_STRING_ENB_INTERFACE_NAME_FOR_S1_MME "ENB_INTERFACE_NAME_FOR_S1_MME" @@ -967,8 +968,6 @@ typedef struct srb1_params_s { {ENB_CONFIG_STRING_ENB_PORT_FOR_X2C, NULL, 0, uptr:NULL, defintval:0L, TYPE_UINT, 0}, \ } - - /*--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------*/ /* GTPU configuration parameters */ /* optname helpstr paramflags XXXptr defXXXval type numelt */ @@ -1018,54 +1017,53 @@ typedef struct srb1_params_s { /*----------------------------------------------------------------------------------------------------------------------------------------------------*/ /*----------------------------------------------------------------------------------------------------------------------------------------------------*/ /* CU/DU configuration section names*/ -#define CONFIG_STRING_DU_LIST "DU" -#define CONFIG_STRING_CU_LIST "CU" -#define DU_TYPE_LTE 0 -#define DU_TYPE_WIFI 1 -#define ENB_CONFIG_STRING_CU_INTERFACES_CONFIG "CU_INTERFACES" -#define ENB_CONFIG_STRING_CU_INTERFACE_NAME_FOR_F1U "CU_INTERFACE_NAME_FOR_F1U" -#define ENB_CONFIG_STRING_CU_IPV4_ADDRESS_FOR_F1U "CU_IPV4_ADDRESS_FOR_F1U" -#define ENB_CONFIG_STRING_CU_PORT_FOR_F1U "CU_PORT_FOR_F1U" -#define ENB_CONFIG_STRING_DU_TYPE "DU_TYPE" -#define ENB_CONFIG_STRING_F1_U_CU_TRANSPORT_TYPE "F1_U_CU_TRANSPORT_TYPE" - -#define ENB_CONFIG_STRING_DU_INTERFACES_CONFIG "DU_INTERFACES" -#define ENB_CONFIG_STRING_DU_INTERFACE_NAME_FOR_F1U "DU_INTERFACE_NAME_FOR_F1U" -#define ENB_CONFIG_STRING_DU_IPV4_ADDRESS_FOR_F1U "DU_IPV4_ADDRESS_FOR_F1U" -#define ENB_CONFIG_STRING_DU_PORT_FOR_F1U "DU_PORT_FOR_F1U" -#define ENB_CONFIG_STRING_F1_U_DU_TRANSPORT_TYPE "F1_U_DU_TRANSPORT_TYPE" +#define CONFIG_STRING_DU_LIST "DU" +#define CONFIG_STRING_CU_LIST "CU" +#define DU_TYPE_LTE 0 +#define DU_TYPE_WIFI 1 +#define ENB_CONFIG_STRING_CU_INTERFACES_CONFIG "CU_INTERFACES" +#define ENB_CONFIG_STRING_CU_INTERFACE_NAME_FOR_F1U "CU_INTERFACE_NAME_FOR_F1U" +#define ENB_CONFIG_STRING_CU_IPV4_ADDRESS_FOR_F1U "CU_IPV4_ADDRESS_FOR_F1U" +#define ENB_CONFIG_STRING_CU_PORT_FOR_F1U "CU_PORT_FOR_F1U" +#define ENB_CONFIG_STRING_DU_TYPE "DU_TYPE" +#define ENB_CONFIG_STRING_F1_U_CU_TRANSPORT_TYPE "F1_U_CU_TRANSPORT_TYPE" +#define ENB_CONFIG_STRING_DU_INTERFACES_CONFIG "DU_INTERFACES" +#define ENB_CONFIG_STRING_DU_INTERFACE_NAME_FOR_F1U "DU_INTERFACE_NAME_FOR_F1U" +#define ENB_CONFIG_STRING_DU_IPV4_ADDRESS_FOR_F1U "DU_IPV4_ADDRESS_FOR_F1U" +#define ENB_CONFIG_STRING_DU_PORT_FOR_F1U "DU_PORT_FOR_F1U" +#define ENB_CONFIG_STRING_F1_U_DU_TRANSPORT_TYPE "F1_U_DU_TRANSPORT_TYPE" #define CONFIG_STRING_CU_BALANCING "CU_BALANCING" #define CUPARAMS_DESC { \ - {ENB_CONFIG_STRING_CU_INTERFACE_NAME_FOR_F1U, NULL, 0, strptr:NULL, defstrval:"eth0", TYPE_STRING, 0}, \ - {ENB_CONFIG_STRING_CU_IPV4_ADDRESS_FOR_F1U, NULL, 0, strptr:NULL, defstrval:"127.0.0.1", TYPE_STRING, 0}, \ - {ENB_CONFIG_STRING_CU_PORT_FOR_F1U, NULL, 0, uptr:NULL, defintval:2210, TYPE_UINT, 0}, \ - {ENB_CONFIG_STRING_F1_U_CU_TRANSPORT_TYPE, NULL, 0, strptr:NULL, defstrval:"TCP", TYPE_STRING, 0}, \ - {ENB_CONFIG_STRING_DU_TYPE, NULL, 0, strptr:NULL, defstrval:"LTE", TYPE_STRING, 0}, \ - } + {ENB_CONFIG_STRING_CU_INTERFACE_NAME_FOR_F1U, NULL, 0, strptr:NULL, defstrval:"eth0", TYPE_STRING, 0}, \ + {ENB_CONFIG_STRING_CU_IPV4_ADDRESS_FOR_F1U, NULL, 0, strptr:NULL, defstrval:"127.0.0.1", TYPE_STRING, 0}, \ + {ENB_CONFIG_STRING_CU_PORT_FOR_F1U, NULL, 0, uptr:NULL, defintval:2210, TYPE_UINT, 0}, \ + {ENB_CONFIG_STRING_F1_U_CU_TRANSPORT_TYPE, NULL, 0, strptr:NULL, defstrval:"TCP", TYPE_STRING, 0}, \ + {ENB_CONFIG_STRING_DU_TYPE, NULL, 0, strptr:NULL, defstrval:"LTE", TYPE_STRING, 0}, \ +} #define DUPARAMS_DESC { \ - {ENB_CONFIG_STRING_DU_INTERFACE_NAME_FOR_F1U, NULL, 0, strptr:NULL, defstrval:"eth0", TYPE_STRING, 0}, \ - {ENB_CONFIG_STRING_DU_IPV4_ADDRESS_FOR_F1U, NULL, 0, strptr:NULL, defstrval:"127.0.0.1", TYPE_STRING, 0}, \ - {ENB_CONFIG_STRING_DU_PORT_FOR_F1U, NULL, 0, uptr:NULL, defintval:2210, TYPE_UINT, 0}, \ - {ENB_CONFIG_STRING_F1_U_DU_TRANSPORT_TYPE, NULL, 0, strptr:NULL, defstrval:"TCP", TYPE_STRING, 0}, \ - } + {ENB_CONFIG_STRING_DU_INTERFACE_NAME_FOR_F1U, NULL, 0, strptr:NULL, defstrval:"eth0", TYPE_STRING, 0}, \ + {ENB_CONFIG_STRING_DU_IPV4_ADDRESS_FOR_F1U, NULL, 0, strptr:NULL, defstrval:"127.0.0.1", TYPE_STRING, 0}, \ + {ENB_CONFIG_STRING_DU_PORT_FOR_F1U, NULL, 0, uptr:NULL, defintval:2210, TYPE_UINT, 0}, \ + {ENB_CONFIG_STRING_F1_U_DU_TRANSPORT_TYPE, NULL, 0, strptr:NULL, defstrval:"TCP", TYPE_STRING, 0}, \ +} #define CU_BAL_DESC { \ - {CONFIG_STRING_CU_BALANCING, NULL, 0, strptr:NULL, defstrval:"ALL", TYPE_STRING, 0}, \ - } + {CONFIG_STRING_CU_BALANCING, NULL, 0, strptr:NULL, defstrval:"ALL", TYPE_STRING, 0}, \ +} -#define CU_INTERFACE_F1U 0 -#define CU_ADDRESS_F1U 1 -#define CU_PORT_F1U 2 -#define CU_TYPE_F1U 3 +#define CU_INTERFACE_F1U 0 +#define CU_ADDRESS_F1U 1 +#define CU_PORT_F1U 2 +#define CU_TYPE_F1U 3 -#define DU_INTERFACE_F1U 0 -#define DU_ADDRESS_F1U 1 -#define DU_PORT_F1U 2 -#define DU_TYPE_F1U 3 -#define DU_TECH 4 +#define DU_INTERFACE_F1U 0 +#define DU_ADDRESS_F1U 1 +#define DU_PORT_F1U 2 +#define DU_TYPE_F1U 3 +#define DU_TECH 4 /*----------------------------------------------------------------------------------------------------------------------------------------------------*/ /*----------------------------------------------------------------------------------------------------------------------------------------------------*/ diff --git a/openair2/ENB_APP/enb_paramdef_emtc.h b/openair2/ENB_APP/enb_paramdef_emtc.h index 3c23b2a557..1e7705ed1a 100644 --- a/openair2/ENB_APP/enb_paramdef_emtc.h +++ b/openair2/ENB_APP/enb_paramdef_emtc.h @@ -64,6 +64,7 @@ #define ENB_CONFIG_STRING_PDSCH_MAX_NUM_REPETITION_CE_MODE_B_R13 "pdsch_maxNumRepetitionCEmodeB_r13" #define ENB_CONFIG_STRING_PUSCH_MAX_NUM_REPETITION_CE_MODE_A_R13 "pusch_maxNumRepetitionCEmodeA_r13" #define ENB_CONFIG_STRING_PUSCH_MAX_NUM_REPETITION_CE_MODE_B_R13 "pusch_maxNumRepetitionCEmodeB_r13" +#define ENB_CONFIG_STRING_PUSCH_REPETITION_LEVEL_CE_MODE_A_R13 "pusch_repetitionLevelCEmodeA_r13" #define ENB_CONFIG_STRING_PUSCH_HOPPING_OFFSET_V1310 "pusch_HoppingOffset_v1310" #define ENB_CONFIG_STRING_SYSTEM_INFO_VALUE_TAG_LIST "system_info_value_tag_SI" #define ENB_CONFIG_STRING_FIRST_PREAMBLE_R13 "firstPreamble_r13" @@ -161,6 +162,7 @@ typedef struct ccparams_eMTC_s { char *pdsch_maxNumRepetitionCEmodeB_r13; char *pusch_maxNumRepetitionCEmodeA_r13; char *pusch_maxNumRepetitionCEmodeB_r13; + char *pusch_repetitionLevelCEmodeA_r13; } ccparams_eMTC_t; @@ -230,6 +232,7 @@ typedef struct ccparams_eMTC_s { {ENB_CONFIG_STRING_PRACH_HOPPING_OFFSET_R13, NULL, 0, iptr:&eMTCconfig->prach_HoppingOffset_r13, defintval:0, TYPE_INT, 0}, \ {ENB_CONFIG_STRING_PDSCH_MAX_NUM_REPETITION_CE_MODE_A_R13, NULL, 0, strptr:&eMTCconfig->pdsch_maxNumRepetitionCEmodeA_r13, defstrval:"r16", TYPE_STRING, 0}, \ {ENB_CONFIG_STRING_PUSCH_MAX_NUM_REPETITION_CE_MODE_A_R13, NULL, 0, strptr:&eMTCconfig->pusch_maxNumRepetitionCEmodeA_r13, defstrval:"r8", TYPE_STRING, 0}, \ + {ENB_CONFIG_STRING_PUSCH_REPETITION_LEVEL_CE_MODE_A_R13, NULL, 0, strptr:&eMTCconfig->pusch_repetitionLevelCEmodeA_r13, defstrval:"l1", TYPE_STRING, 0}, \ {ENB_CONFIG_STRING_CELL_SELECTION_INFO_CE_R13, NULL, 0, strptr:&eMTCconfig->cellSelectionInfoCE_r13, defstrval:"ENABLE", TYPE_STRING, 0}, \ {ENB_CONFIG_STRING_Q_RX_LEV_MIN_CE_R13, NULL, 0, iptr:&eMTCconfig->q_RxLevMinCE_r13, defintval:-70, TYPE_INT, 0}, \ {ENB_CONFIG_STRING_BANDWIDTH_REDUCED_ACCESS_RELATED_INFO_R13, NULL, 0, strptr:&eMTCconfig->bandwidthReducedAccessRelatedInfo_r13, defstrval:"ENABLE", TYPE_STRING, 0}, \ diff --git a/openair2/GNB_APP/gnb_config.c b/openair2/GNB_APP/gnb_config.c index 2113517c7f..3e0be6fdee 100644 --- a/openair2/GNB_APP/gnb_config.c +++ b/openair2/GNB_APP/gnb_config.c @@ -59,8 +59,8 @@ //#include "RRC_config_tools.h" #include "gnb_paramdef.h" #include "LAYER2/NR_MAC_gNB/mac_proto.h" - #include "NR_asn_constant.h" +#include "executables/thread-common.h" #include "NR_SCS-SpecificCarrier.h" #include "NR_TDD-UL-DL-ConfigCommon.h" #include "NR_FrequencyInfoUL.h" @@ -78,10 +78,7 @@ #include "NR_EUTRA-MBSFN-SubframeConfig.h" extern uint16_t sf_ahead; -extern void set_parallel_conf(char *parallel_conf); -extern void set_worker_conf(char *worker_conf); -extern PARALLEL_CONF_t get_thread_parallel_conf(void); -extern WORKER_CONF_t get_thread_worker_conf(void); + extern int config_check_band_frequencies(int ind, int16_t band, uint32_t downlink_frequency, int32_t uplink_frequency_offset, uint32_t frame_type); @@ -647,11 +644,7 @@ void RCconfig_NRRRC(MessageDef *msg_p, uint32_t i, gNB_RRC_INST *rrc) { NRRRC_CONFIGURATION_REQ (msg_p).scc = scc; }// - - }//End for (k=0; k 0) diff --git a/openair2/LAYER2/MAC/eNB_scheduler_RA.c b/openair2/LAYER2/MAC/eNB_scheduler_RA.c index 879d0da6e0..0387d7a536 100644 --- a/openair2/LAYER2/MAC/eNB_scheduler_RA.c +++ b/openair2/LAYER2/MAC/eNB_scheduler_RA.c @@ -68,6 +68,7 @@ extern RAN_CONTEXT_t RC; +extern const uint8_t pusch_repetition_Table8_2_36213[3][4]; extern int oai_nfapi_hi_dci0_req(nfapi_hi_dci0_request_t *hi_dci0_req); @@ -98,6 +99,7 @@ void add_msg3(module_id_t module_idP, int CC_id, RA_t *ra, frame_t frameP, sub_frame_t subframeP) { eNB_MAC_INST *mac = RC.mac[module_idP]; + eNB_RRC_INST *rrc = RC.rrc[module_idP]; COMMON_channels_t *cc = &mac->common_channels[CC_id]; uint8_t j; nfapi_ul_config_request_t *ul_req; @@ -108,6 +110,7 @@ add_msg3(module_id_t module_idP, int CC_id, RA_t *ra, frame_t frameP, nfapi_hi_dci0_request_pdu_t *hi_dci0_pdu; uint8_t sf_ahead_dl; uint8_t rvseq[4] = {0, 2, 3, 1}; + uint8_t pusch_maxNumRepetitionCEmodeA_r13; ul_req = &mac->UL_req_tmp[CC_id][ra->Msg3_subframe]; ul_req_body = &ul_req->ul_config_request_body; AssertFatal(ra->state != IDLE, "RA is not active for RA %X\n", @@ -139,7 +142,13 @@ add_msg3(module_id_t module_idP, int CC_id, RA_t *ra, frame_t frameP, ul_config_pdu->ulsch_pdu.ulsch_pdu_rel8.size = get_TBS_UL (ra->msg3_mcs, ra->msg3_nb_rb); // Re13 fields ul_config_pdu->ulsch_pdu.ulsch_pdu_rel13.ue_type = ra->rach_resource_type > 2 ? 2 : 1; - ul_config_pdu->ulsch_pdu.ulsch_pdu_rel13.total_number_of_repetitions = 1; + if (ra->rach_resource_type > 0) { + pusch_maxNumRepetitionCEmodeA_r13= *(rrc->configuration.pusch_maxNumRepetitionCEmodeA_r13[CC_id]); + ul_config_pdu->ulsch_pdu.ulsch_pdu_rel13.total_number_of_repetitions= pusch_repetition_Table8_2_36213[pusch_maxNumRepetitionCEmodeA_r13][ra->pusch_repetition_levels]; + } + else{ + ul_config_pdu->ulsch_pdu.ulsch_pdu_rel13.total_number_of_repetitions=1; + } ul_config_pdu->ulsch_pdu.ulsch_pdu_rel13.repetition_number = 1; ul_config_pdu->ulsch_pdu.ulsch_pdu_rel13.initial_transmission_sf_io = (ra->Msg3_frame * 10) + ra->Msg3_subframe; ul_req_body->number_of_pdus++; @@ -235,6 +244,7 @@ void generate_Msg2(module_id_t module_idP, //------------------------------------------------------------------------------ { eNB_MAC_INST *mac = RC.mac[module_idP]; + eNB_RRC_INST *rrc = RC.rrc[module_idP]; COMMON_channels_t *cc = mac->common_channels; uint8_t *vrb_map = NULL; int first_rb = 0; @@ -246,6 +256,7 @@ void generate_Msg2(module_id_t module_idP, dl_req_body = &mac->DL_req[CC_idP].dl_config_request_body; dl_config_pdu = &dl_req_body->dl_config_pdu_list[dl_req_body->number_pdu]; N_RB_DL = to_prb(cc[CC_idP].mib->message.dl_Bandwidth); + uint8_t PUSCH_Rep_Level; int rmax = 0; int rep = 0; int reps = 0; @@ -257,6 +268,13 @@ void generate_Msg2(module_id_t module_idP, uint16_t absSF = (10 * frameP) + subframeP; uint16_t absSF_Msg2 = (10 * ra->Msg2_frame) + ra->Msg2_subframe; + if (ra->rach_resource_type > 0) { + PUSCH_Rep_Level= *(rrc->configuration.pusch_repetitionLevelCEmodeA_r13[CC_idP]); + } + else { + PUSCH_Rep_Level= 0; + } + if (absSF > absSF_Msg2) { return; // we're not ready yet } @@ -396,6 +414,8 @@ void generate_Msg2(module_id_t module_idP, ra->msg2_mpdcch_repetition_cnt++; } + ra->pusch_repetition_levels = PUSCH_Rep_Level; + if((ra->Msg2_frame == frameP) && (ra->Msg2_subframe == subframeP)) { /* Program PDSCH */ LOG_D(MAC, "[eNB %d][RAPROC] Frame %d, Subframe %d : In generate_Msg2, Programming PDSCH\n", @@ -1218,6 +1238,7 @@ check_Msg4_retransmission(module_id_t module_idP, int CC_idP, UE_id = find_UE_id(module_idP, ra->rnti); DevAssert(UE_id != -1); mac->UE_list.UE_template[UE_PCCID(module_idP, UE_id)][UE_id].configured = TRUE; + mac->UE_list.UE_template[UE_PCCID(module_idP, UE_id)][UE_id].pusch_repetition_levels=ra->pusch_repetition_levels; cancel_ra_proc(module_idP, CC_idP, frameP, ra->rnti); } } diff --git a/openair2/LAYER2/MAC/eNB_scheduler_bch.c b/openair2/LAYER2/MAC/eNB_scheduler_bch.c index c69d533558..469aade040 100644 --- a/openair2/LAYER2/MAC/eNB_scheduler_bch.c +++ b/openair2/LAYER2/MAC/eNB_scheduler_bch.c @@ -200,7 +200,8 @@ schedule_SIB1_MBMS(module_id_t module_idP, // Note: definition of k above and rvidx from 36.321 section 5.3.1 rvidx = (((3 * k) >> 1) + (k & 1)) & 3; i = cc->SIB1_BR_cnt & (m - 1); - n_NB = Sj[((cc->physCellId % N_S_NB) + (i * N_S_NB / m)) % N_S_NB]; + if(Sj) + n_NB = Sj[((cc->physCellId % N_S_NB) + (i * N_S_NB / m)) % N_S_NB]; bcch_sdu_length = mac_rrc_data_req(module_idP, CC_id, frameP, BCCH_SIB1_BR, 1, &cc->BCCH_BR_pdu[0].payload[0], 0); // not used in this case AssertFatal(cc->mib->message.schedulingInfoSIB1_BR_r13 < 19, "schedulingInfoSIB1_BR_r13 %d > 18\n", @@ -429,7 +430,8 @@ schedule_SIB1_BR(module_id_t module_idP, // Note: definition of k above and rvidx from 36.321 section 5.3.1 rvidx = (((3 * k) >> 1) + (k & 1)) & 3; i = cc->SIB1_BR_cnt & (m - 1); - n_NB = Sj[((cc->physCellId % N_S_NB) + (i * N_S_NB / m)) % N_S_NB]; + if(Sj) + n_NB = Sj[((cc->physCellId % N_S_NB) + (i * N_S_NB / m)) % N_S_NB]; bcch_sdu_length = mac_rrc_data_req(module_idP, CC_id, frameP, BCCH_SIB1_BR, 0xFFFF, 1, &cc->BCCH_BR_pdu[0].payload[0], 0); // not used in this case AssertFatal(cc->mib->message.schedulingInfoSIB1_BR_r13 < 19, "schedulingInfoSIB1_BR_r13 %d > 18\n", @@ -595,7 +597,7 @@ schedule_SI_BR(module_id_t module_idP, frame_t frameP, long si_Narrowband_r13 = schedulingInfoList_BR_r13->list.array[i]->si_Narrowband_r13; long si_TBS_r13 = si_TBS_r13tab[schedulingInfoList_BR_r13->list.array[i]->si_TBS_r13]; // check if the SI is to be scheduled now - int period_in_sf; + int period_in_sf = 0; if ((si_Periodicity >= 0) && (si_Periodicity < 25)) { // 2^i * 80 subframes, note: si_Periodicity is 2^i * 80ms diff --git a/openair2/LAYER2/MAC/eNB_scheduler_ulsch.c b/openair2/LAYER2/MAC/eNB_scheduler_ulsch.c index 6f712e63b8..e3b74d388c 100644 --- a/openair2/LAYER2/MAC/eNB_scheduler_ulsch.c +++ b/openair2/LAYER2/MAC/eNB_scheduler_ulsch.c @@ -84,6 +84,14 @@ uint8_t rb_table[34] = { 81, 90, 96, 100 // 30-33 }; +// This table hold the possible number of MTC repetition for CE ModeA +const uint8_t pusch_repetition_Table8_2_36213[3][4]= +{ + {1 , 2 , 4 , 8 }, + {1 , 4 , 8 , 16}, + {1 , 4 , 16, 32} +}; + extern mui_t rrc_eNB_mui; //----------------------------------------------------------------------------- @@ -293,16 +301,22 @@ rx_sdu(const module_id_t enb_mod_idP, if (ra->msg3_round >= mac->common_channels[CC_idP].radioResourceConfigCommon->rach_ConfigCommon.maxHARQ_Msg3Tx - 1) { cancel_ra_proc(enb_mod_idP, CC_idP, frameP, current_rnti); } else { - // first_rb = UE_template_ptr->first_rb_ul[harq_pid]; // UE_id = -1 !!!! - ra->msg3_round++; - /* Prepare handling of retransmission */ - get_Msg3allocret(&mac->common_channels[CC_idP], - ra->Msg3_subframe, - ra->Msg3_frame, - &ra->Msg3_frame, - &ra->Msg3_subframe); - // prepare handling of retransmission - add_msg3(enb_mod_idP, CC_idP, ra, frameP, subframeP); + if (ra->rach_resource_type > 0) { + cancel_ra_proc(enb_mod_idP, CC_idP, frameP, current_rnti); // TODO: Currently we don't support retransmission of Msg3 ( If in error Cancel RA procedure and reattach) + } + else + { + // first_rb = UE_template_ptr->first_rb_ul[harq_pid]; // UE_id = -1 !!!! + ra->msg3_round++; + /* Prepare handling of retransmission */ + get_Msg3allocret(&mac->common_channels[CC_idP], + ra->Msg3_subframe, + ra->Msg3_frame, + &ra->Msg3_frame, + &ra->Msg3_subframe); + // prepare handling of retransmission + add_msg3(enb_mod_idP, CC_idP, ra, frameP, subframeP); + } } /* TODO: program NACK for PHICH? */ @@ -1925,10 +1939,13 @@ void schedule_ulsch_rnti_emtc(module_id_t module_idP, int tpc = 0; int cqi_req = 0; eNB_MAC_INST *eNB = RC.mac[module_idP]; + eNB_RRC_INST *rrc = RC.rrc[module_idP]; COMMON_channels_t *cc = eNB->common_channels; UE_list_t *UE_list = &(eNB->UE_list); UE_TEMPLATE *UE_template = NULL; UE_sched_ctrl_t *UE_sched_ctrl = NULL; + uint8_t Total_Num_Rep_ULSCH,pusch_maxNumRepetitionCEmodeA_r13; + uint8_t UL_Scheduling_DCI_SF,UL_Scheduling_DCI_Frame_Even_Odd_Flag; //TODO: To be removed after scheduler relaxation Task if (sched_subframeP < subframeP) { sched_frame++; @@ -1937,11 +1954,9 @@ void schedule_ulsch_rnti_emtc(module_id_t module_idP, nfapi_hi_dci0_request_body_t *hi_dci0_req = &(eNB->HI_DCI0_req[CC_id][subframeP].hi_dci0_request_body); nfapi_hi_dci0_request_pdu_t *hi_dci0_pdu = NULL; nfapi_ul_config_request_body_t *ul_req_tmp = &(eNB->UL_req_tmp[CC_id][sched_subframeP].ul_config_request_body); - - /* If frameP odd don't schedule */ - if ((frameP & 1) == 1) { - return; - } + nfapi_ul_config_request_body_t *ul_req_body_Rep; + nfapi_ul_config_request_pdu_t *ul_config_pdu; + nfapi_ul_config_request_pdu_t *ul_config_pdu_Rep; /* Loop over all active UEs */ for (UE_id = UE_list->head_ul; UE_id >= 0; UE_id = UE_list->next_ul[UE_id]) { @@ -1999,8 +2014,18 @@ void schedule_ulsch_rnti_emtc(module_id_t module_idP, RC.eNB[module_idP][CC_id]->pusch_stats_BO[UE_id][(frameP*10)+subframeP] = UE_template->estimated_ul_buffer; VCD_SIGNAL_DUMPER_DUMP_VARIABLE_BY_NAME(VCD_SIGNAL_DUMPER_VARIABLES_UE0_BO, UE_template->estimated_ul_buffer); + pusch_maxNumRepetitionCEmodeA_r13= *(rrc->configuration.pusch_maxNumRepetitionCEmodeA_r13[CC_id]); + Total_Num_Rep_ULSCH = pusch_repetition_Table8_2_36213[pusch_maxNumRepetitionCEmodeA_r13][UE_template->pusch_repetition_levels]; + UL_Scheduling_DCI_SF = (40-4 - Total_Num_Rep_ULSCH)%10; //TODO: [eMTC Scheduler] To be removed after scheduler relaxation task + UL_Scheduling_DCI_Frame_Even_Odd_Flag= ! (((40-4 - Total_Num_Rep_ULSCH)/10 )%2); //TODO: [eMTC Scheduler] To be removed after scheduler relaxation task + + /* If frameP odd don't schedule */ + if ((frameP&1) == UL_Scheduling_DCI_Frame_Even_Odd_Flag) //TODO: [eMTC Scheduler] To be removed after scheduler relaxation task + { + + //if ((UE_is_to_be_scheduled(module_idP, CC_id, UE_id) > 0) && (subframeP == 5)) { - if ((UE_template->ul_SR > 0 || round_UL > 0 || status < RRC_CONNECTED) && (subframeP == 5)) { + if ((UE_template->ul_SR > 0 || round_UL > 0 || status < RRC_CONNECTED) && (subframeP == UL_Scheduling_DCI_SF)) { /* * if there is information on bsr of DCCH, DTCH, * or if there is UL_SR, @@ -2151,7 +2176,7 @@ void schedule_ulsch_rnti_emtc(module_id_t module_idP, hi_dci0_pdu->mpdcch_dci_pdu.mpdcch_dci_pdu_rel13.resource_block_start = UE_template->first_rb_ul[harq_pid]; hi_dci0_pdu->mpdcch_dci_pdu.mpdcch_dci_pdu_rel13.number_of_resource_blocks = 6; hi_dci0_pdu->mpdcch_dci_pdu.mpdcch_dci_pdu_rel13.mcs = 4; // adjust according to size of RAR, 208 bits with N1A_PRB = 3 - hi_dci0_pdu->mpdcch_dci_pdu.mpdcch_dci_pdu_rel13.pusch_repetition_levels = 0; + hi_dci0_pdu->mpdcch_dci_pdu.mpdcch_dci_pdu_rel13.pusch_repetition_levels = UE_template->pusch_repetition_levels; AssertFatal(epdcch_setconfig_r11->ext2->mpdcch_config_r13->choice.setup.mpdcch_pdsch_HoppingConfig_r13 == LTE_EPDCCH_SetConfig_r11__ext2__mpdcch_config_r13__setup__mpdcch_pdsch_HoppingConfig_r13_off, "epdcch_setconfig_r11->ext2->mpdcch_config_r13->mpdcch_pdsch_HoppingConfig_r13 is not off\n"); hi_dci0_pdu->mpdcch_dci_pdu.mpdcch_dci_pdu_rel13.frequency_hopping_flag = 1 - epdcch_setconfig_r11->ext2->mpdcch_config_r13->choice.setup.mpdcch_pdsch_HoppingConfig_r13; @@ -2201,7 +2226,7 @@ void schedule_ulsch_rnti_emtc(module_id_t module_idP, ); fill_nfapi_ulsch_config_request_emtc(&ul_req_tmp->ul_config_pdu_list[ul_req_tmp->number_of_pdus], UE_template->rach_resource_type > 2 ? 2 : 1, - 1, // total_number_of_repetitions + Total_Num_Rep_ULSCH, // total_number_of_repetitions 1, // repetition_number (frameP * 10) + subframeP); ul_req_tmp->number_of_pdus++; @@ -2330,5 +2355,24 @@ void schedule_ulsch_rnti_emtc(module_id_t module_idP, } } // UE_is_to_be_scheduled } // ULCCs - } // loop over UE_id + } // loop over UE_id + } // Schedule new ULSCH + + // This section is to repeat ULSCH PDU for a number of MTC repetitions + for(int i=0;inumber_of_pdus;i++) + { + ul_config_pdu = &ul_req_tmp->ul_config_pdu_list[i]; + if (ul_config_pdu->pdu_type!=NFAPI_UL_CONFIG_ULSCH_PDU_TYPE) // Repeat ULSCH PDUs only + continue ; + + if(ul_config_pdu->ulsch_pdu.ulsch_pdu_rel13.repetition_number < ul_config_pdu->ulsch_pdu.ulsch_pdu_rel13.total_number_of_repetitions) + { + ul_req_body_Rep = &eNB->UL_req_tmp[CC_id][(sched_subframeP+1)%10].ul_config_request_body; + ul_config_pdu_Rep = &ul_req_body_Rep->ul_config_pdu_list[ul_req_body_Rep->number_of_pdus]; + memcpy ((void *) ul_config_pdu_Rep, ul_config_pdu, sizeof (nfapi_ul_config_request_pdu_t)); + ul_config_pdu_Rep->ulsch_pdu.ulsch_pdu_rel8.handle = eNB->ul_handle++; + ul_config_pdu_Rep->ulsch_pdu.ulsch_pdu_rel13.repetition_number = ul_config_pdu->ulsch_pdu.ulsch_pdu_rel13.repetition_number +1; + ul_req_body_Rep->number_of_pdus++; + } //repetition_number < total_number_of_repetitions + } // For loop on PDUs } diff --git a/openair2/LAYER2/MAC/mac.h b/openair2/LAYER2/MAC/mac.h index 556bf2176f..979ec4dace 100644 --- a/openair2/LAYER2/MAC/mac.h +++ b/openair2/LAYER2/MAC/mac.h @@ -904,9 +904,11 @@ typedef struct { uint16_t mpdcch_repetition_cnt; frame_t Msg2_frame; sub_frame_t Msg2_subframe; - +#if (LTE_RRC_VERSION >= MAKE_VERSION(14, 0, 0)) + /// Repetition column in pusch_repetition Table 8.2.b in TS36.213 + uint8_t pusch_repetition_levels; +#endif LTE_PhysicalConfigDedicated_t *physicalConfigDedicated; - } UE_TEMPLATE; /*! \brief scheduling control information set through an API (not used)*/ @@ -1113,7 +1115,10 @@ typedef struct { uint8_t msg2_narrowband; uint8_t msg34_narrowband; int msg4_rrc_sdu_length; - +#if (LTE_RRC_VERSION >= MAKE_VERSION(14, 0, 0)) + /// Repetition column in pusch_repetition Table 8.2.b in TS36.213 + uint8_t pusch_repetition_levels; +#endif int32_t crnti_rrc_mui; int8_t crnti_harq_pid; } RA_t; diff --git a/openair2/LAYER2/MAC/mac_vars.h b/openair2/LAYER2/MAC/mac_vars.h index d9b4b9f907..bd25bd6047 100644 --- a/openair2/LAYER2/MAC/mac_vars.h +++ b/openair2/LAYER2/MAC/mac_vars.h @@ -26,7 +26,6 @@ * \version 1.0 * \email navid.nikaein@eurecom.fr * @ingroup _mac - */ @@ -102,7 +101,6 @@ MAC_RLC_XFACE *Mac_rlc_xface; int pCC_id[NUMBER_OF_eNB_MAX]; - eNB_ULSCH_INFO eNB_ulsch_info[NUMBER_OF_eNB_MAX][MAX_NUM_CCs][MAX_MOBILES_PER_ENB]; // eNBxUE = 8x8 eNB_DLSCH_INFO eNB_dlsch_info[NUMBER_OF_eNB_MAX][MAX_NUM_CCs][MAX_MOBILES_PER_ENB]; // eNBxUE = 8x8 @@ -126,7 +124,6 @@ DCI1A_5MHz_TDD_1_6_t CCCH_alloc_pdu; DCI1_5MHz_TDD_t DLSCH_alloc_pdu; DCI1C_5MHz_t MCCH_alloc_pdu; - DCI0_5MHz_FDD_t UL_alloc_pdu_fdd; DCI1A_5MHz_FDD_t DLSCH_alloc_pdu1A_fdd; diff --git a/openair2/LAYER2/MAC/rar_tools.c b/openair2/LAYER2/MAC/rar_tools.c index 44561a7011..6999e4ab5e 100644 --- a/openair2/LAYER2/MAC/rar_tools.c +++ b/openair2/LAYER2/MAC/rar_tools.c @@ -125,7 +125,6 @@ unsigned short fill_rar_br(eNB_MAC_INST *eNB, COMMON_channels_t *cc = &eNB->common_channels[CC_id]; uint8_t *rar = (uint8_t *)(dlsch_buffer + 1); uint32_t rballoc = 0; - uint32_t reps = 0; uint32_t ULdelay = 0; uint32_t cqireq = 0; uint32_t mpdcch_nb_index = 0; @@ -151,7 +150,6 @@ unsigned short fill_rar_br(eNB_MAC_INST *eNB, input_buffer_length = 6; N_NB_index = get_numnarrowbandbits(cc->mib->message.dl_Bandwidth); /* UL Grant */ - reps = 0; ra->msg3_mcs = 7; TPC = 3; // no power increase ULdelay = 0; @@ -161,7 +159,7 @@ unsigned short fill_rar_br(eNB_MAC_INST *eNB, uint32_t buffer = 0; buffer |= ra->msg34_narrowband << (16 + (4 - N_NB_index)); buffer |= ((rballoc & 0x0F) << (12 + (4 - N_NB_index))); - buffer |= ((reps & 0x03) << (10 + (4 - N_NB_index))); + buffer |= ((ra->pusch_repetition_levels & 0x03) << (10 + (4 - N_NB_index))); buffer |= ((ra->msg3_mcs & 0x07) << (7 + (4 - N_NB_index))); buffer |= ((TPC & 0x07) << (4 + (4 - N_NB_index))); buffer |= ((cqireq & 0x01) << (3 + (4 - N_NB_index))); diff --git a/openair2/LAYER2/NR_MAC_UE/mac_proto.h b/openair2/LAYER2/NR_MAC_UE/mac_proto.h index 5ab6080d79..aa469b84a9 100755 --- a/openair2/LAYER2/NR_MAC_UE/mac_proto.h +++ b/openair2/LAYER2/NR_MAC_UE/mac_proto.h @@ -136,5 +136,7 @@ void nr_ue_process_mac_pdu( int8_t nr_ue_process_dlsch(module_id_t module_id, int cc_id, uint8_t gNB_index, fapi_nr_dci_indication_t *dci_ind, void *pduP, uint32_t pdu_len); +void nr_ue_send_sdu(module_id_t module_idP, uint8_t CC_id, frame_t frameP, sub_frame_t subframeP, uint8_t * sdu, uint16_t sdu_len, uint8_t eNB_index); + #endif /** @}*/ diff --git a/openair2/LAYER2/NR_MAC_UE/main_ue_nr.c b/openair2/LAYER2/NR_MAC_UE/main_ue_nr.c index 3688514745..c96acccf9b 100644 --- a/openair2/LAYER2/NR_MAC_UE/main_ue_nr.c +++ b/openair2/LAYER2/NR_MAC_UE/main_ue_nr.c @@ -32,6 +32,7 @@ //#include "defs.h" #include "mac_proto.h" +#include "executables/nr-softmodem.h" static NR_UE_MAC_INST_t *nr_ue_mac_inst; @@ -45,6 +46,14 @@ nr_l2_init_ue(void) //init mac here nr_ue_mac_inst = (NR_UE_MAC_INST_t *)malloc(sizeof(NR_UE_MAC_INST_t)*NB_NR_UE_MAC_INST); + if (IS_SOFTMODEM_NOS1){ + if (rlc_module_init() != 0) { + LOG_I(RLC, "Problem at RLC initiation \n"); + } + pdcp_layer_init(); + nr_ip_over_LTE_DRB_preconfiguration(); + } + return (1); } diff --git a/openair2/LAYER2/NR_MAC_UE/nr_ue_procedures.c b/openair2/LAYER2/NR_MAC_UE/nr_ue_procedures.c index c573017140..5834dac0d6 100644 --- a/openair2/LAYER2/NR_MAC_UE/nr_ue_procedures.c +++ b/openair2/LAYER2/NR_MAC_UE/nr_ue_procedures.c @@ -36,10 +36,27 @@ #include "assertions.h" #include "PHY/defs_nr_UE.h" #include "common/utils/LOG/log.h" +#include "openair2/LAYER2/MAC/mac.h" #include #include +//#define ENABLE_MAC_PAYLOAD_DEBUG 1 + +extern void mac_rlc_data_ind ( + const module_id_t module_idP, + const rnti_t rntiP, + const eNB_index_t eNB_index, + const frame_t frameP, + const eNB_flag_t enb_flagP, + const MBMS_flag_t MBMS_flagP, + const logical_chan_id_t channel_idP, + char *buffer_pP, + const tb_size_t tb_sizeP, + num_tb_t num_tbP, + crc_t *crcs_pP); + + uint32_t get_ssb_slot(uint32_t ssb_index){ // this function now only support f <= 3GHz return ssb_index & 0x3 ; @@ -112,70 +129,11 @@ int8_t nr_ue_process_dlsch(module_id_t module_id, ul_config->ul_config_list[ul_config->number_pdus].ulsch_config_pdu.ulsch_pdu_rel15.beta_offset_ind = 0; } else { // If DCI ind is not format 0_0 or 0_1, we will handle a PUCCH in the UL_CONFIG_REQ ul_config->ul_config_list[ul_config->number_pdus].pdu_type = FAPI_NR_UL_CONFIG_TYPE_PUCCH; - // If we handle PUCCH common - ul_config->ul_config_list[ul_config->number_pdus].pucch_config_pdu.format = table_9_2_2_1[phy_config->config_req.pucch_config.pucch_resource_common][0]; // format 0 1 2 3 4 - ul_config->ul_config_list[ul_config->number_pdus].pucch_config_pdu.initialCyclicShift = table_9_2_2_1[phy_config->config_req.pucch_config.pucch_resource_common][4]; // x x - ul_config->ul_config_list[ul_config->number_pdus].pucch_config_pdu.nrofSymbols = table_9_2_2_1[phy_config->config_req.pucch_config.pucch_resource_common][2]; // x x x x x - ul_config->ul_config_list[ul_config->number_pdus].pucch_config_pdu.startingSymbolIndex = table_9_2_2_1[phy_config->config_req.pucch_config.pucch_resource_common][1]; // x x x x x - ul_config->ul_config_list[ul_config->number_pdus].pucch_config_pdu.timeDomainOCC = 0; // x - ul_config->ul_config_list[ul_config->number_pdus].pucch_config_pdu.nrofPRBs = 0; // x x - ul_config->ul_config_list[ul_config->number_pdus].pucch_config_pdu.startingPRB = table_9_2_2_1[phy_config->config_req.pucch_config.pucch_resource_common][3]; // maxNrofPhysicalResourceBlocks = 275 - ul_config->ul_config_list[ul_config->number_pdus].pucch_config_pdu.occ_length = 0; // x - ul_config->ul_config_list[ul_config->number_pdus].pucch_config_pdu.occ_Index = 0; // x - ul_config->ul_config_list[ul_config->number_pdus].pucch_config_pdu.intraSlotFrequencyHopping = 0; - ul_config->ul_config_list[ul_config->number_pdus].pucch_config_pdu.secondHopPRB = 0; - ul_config->ul_config_list[ul_config->number_pdus].pucch_config_pdu.interslotFrequencyHopping = 0; - ul_config->ul_config_list[ul_config->number_pdus].pucch_config_pdu.additionalDMRS = 0; - ul_config->ul_config_list[ul_config->number_pdus].pucch_config_pdu.maxCodeRate = 0; - ul_config->ul_config_list[ul_config->number_pdus].pucch_config_pdu.nrofSlots = 0; - ul_config->ul_config_list[ul_config->number_pdus].pucch_config_pdu.pi2PBSK = 0; - ul_config->ul_config_list[ul_config->number_pdus].pucch_config_pdu.simultaneousHARQ_ACK_CSI = 0; - ul_config->ul_config_list[ul_config->number_pdus].pucch_config_pdu.pucch_GroupHopping = phy_config->config_req.pucch_config.pucch_group_hopping; - ul_config->ul_config_list[ul_config->number_pdus].pucch_config_pdu.hoppingId = phy_config->config_req.pucch_config.hopping_id; - ul_config->ul_config_list[ul_config->number_pdus].pucch_config_pdu.p0_nominal = phy_config->config_req.pucch_config.p0_nominal; - for (int i=0;iul_config_list[ul_config->number_pdus].pucch_config_pdu.deltaF_PUCCH_f[i] = 0; - ul_config->ul_config_list[ul_config->number_pdus].pucch_config_pdu.p0_PUCCH_Id = 0; // INTEGER (1..8) - ul_config->ul_config_list[ul_config->number_pdus].pucch_config_pdu.p0_PUCCH_Value = 0; - ul_config->ul_config_list[ul_config->number_pdus].pucch_config_pdu.twoPUCCH_PC_AdjustmentStates = 0; - - // If we handle PUCCH dedicated - ul_config->ul_config_list[ul_config->number_pdus].pucch_config_pdu.format = phy_config->config_req.ul_bwp_dedicated.pucch_config_dedicated.multi_csi_pucch_resources[0].format; // format 0 1 2 3 4 - switch (ul_config->ul_config_list[ul_config->number_pdus].pucch_config_pdu.format){ - case pucch_format1_nr: - ul_config->ul_config_list[ul_config->number_pdus].pucch_config_pdu.interslotFrequencyHopping = phy_config->config_req.ul_bwp_dedicated.pucch_config_dedicated.format1.inter_slot_frequency_hopping; - ul_config->ul_config_list[ul_config->number_pdus].pucch_config_pdu.additionalDMRS = phy_config->config_req.ul_bwp_dedicated.pucch_config_dedicated.format1.additional_dmrs; - ul_config->ul_config_list[ul_config->number_pdus].pucch_config_pdu.maxCodeRate = phy_config->config_req.ul_bwp_dedicated.pucch_config_dedicated.format1.max_code_rate; - ul_config->ul_config_list[ul_config->number_pdus].pucch_config_pdu.nrofSlots = phy_config->config_req.ul_bwp_dedicated.pucch_config_dedicated.format1.number_of_slots; - ul_config->ul_config_list[ul_config->number_pdus].pucch_config_pdu.pi2PBSK = phy_config->config_req.ul_bwp_dedicated.pucch_config_dedicated.format1.pi2bpsk; - ul_config->ul_config_list[ul_config->number_pdus].pucch_config_pdu.simultaneousHARQ_ACK_CSI = phy_config->config_req.ul_bwp_dedicated.pucch_config_dedicated.format1.simultaneous_harq_ack_csi; - break; - case pucch_format2_nr: - ul_config->ul_config_list[ul_config->number_pdus].pucch_config_pdu.interslotFrequencyHopping = phy_config->config_req.ul_bwp_dedicated.pucch_config_dedicated.format2.inter_slot_frequency_hopping; - ul_config->ul_config_list[ul_config->number_pdus].pucch_config_pdu.additionalDMRS = phy_config->config_req.ul_bwp_dedicated.pucch_config_dedicated.format2.additional_dmrs; - ul_config->ul_config_list[ul_config->number_pdus].pucch_config_pdu.maxCodeRate = phy_config->config_req.ul_bwp_dedicated.pucch_config_dedicated.format2.max_code_rate; - ul_config->ul_config_list[ul_config->number_pdus].pucch_config_pdu.nrofSlots = phy_config->config_req.ul_bwp_dedicated.pucch_config_dedicated.format2.number_of_slots; - ul_config->ul_config_list[ul_config->number_pdus].pucch_config_pdu.pi2PBSK = phy_config->config_req.ul_bwp_dedicated.pucch_config_dedicated.format2.pi2bpsk; - ul_config->ul_config_list[ul_config->number_pdus].pucch_config_pdu.simultaneousHARQ_ACK_CSI = phy_config->config_req.ul_bwp_dedicated.pucch_config_dedicated.format2.simultaneous_harq_ack_csi; - break; - case pucch_format3_nr: - ul_config->ul_config_list[ul_config->number_pdus].pucch_config_pdu.interslotFrequencyHopping = phy_config->config_req.ul_bwp_dedicated.pucch_config_dedicated.format3.inter_slot_frequency_hopping; - ul_config->ul_config_list[ul_config->number_pdus].pucch_config_pdu.additionalDMRS = phy_config->config_req.ul_bwp_dedicated.pucch_config_dedicated.format3.additional_dmrs; - ul_config->ul_config_list[ul_config->number_pdus].pucch_config_pdu.maxCodeRate = phy_config->config_req.ul_bwp_dedicated.pucch_config_dedicated.format3.max_code_rate; - ul_config->ul_config_list[ul_config->number_pdus].pucch_config_pdu.nrofSlots = phy_config->config_req.ul_bwp_dedicated.pucch_config_dedicated.format3.number_of_slots; - ul_config->ul_config_list[ul_config->number_pdus].pucch_config_pdu.pi2PBSK = phy_config->config_req.ul_bwp_dedicated.pucch_config_dedicated.format3.pi2bpsk; - ul_config->ul_config_list[ul_config->number_pdus].pucch_config_pdu.simultaneousHARQ_ACK_CSI = phy_config->config_req.ul_bwp_dedicated.pucch_config_dedicated.format3.simultaneous_harq_ack_csi; - break; - case pucch_format4_nr: - ul_config->ul_config_list[ul_config->number_pdus].pucch_config_pdu.interslotFrequencyHopping = phy_config->config_req.ul_bwp_dedicated.pucch_config_dedicated.format4.inter_slot_frequency_hopping; - ul_config->ul_config_list[ul_config->number_pdus].pucch_config_pdu.additionalDMRS = phy_config->config_req.ul_bwp_dedicated.pucch_config_dedicated.format4.additional_dmrs; - ul_config->ul_config_list[ul_config->number_pdus].pucch_config_pdu.maxCodeRate = phy_config->config_req.ul_bwp_dedicated.pucch_config_dedicated.format4.max_code_rate; - ul_config->ul_config_list[ul_config->number_pdus].pucch_config_pdu.nrofSlots = phy_config->config_req.ul_bwp_dedicated.pucch_config_dedicated.format4.number_of_slots; - ul_config->ul_config_list[ul_config->number_pdus].pucch_config_pdu.pi2PBSK = phy_config->config_req.ul_bwp_dedicated.pucch_config_dedicated.format4.pi2bpsk; - ul_config->ul_config_list[ul_config->number_pdus].pucch_config_pdu.simultaneousHARQ_ACK_CSI = phy_config->config_req.ul_bwp_dedicated.pucch_config_dedicated.format4.simultaneous_harq_ack_csi; - break; - default: - break; + for (int i=0; i<10; i++) { + if(dci_ind!=NULL){ + if (dci_ind->dci_list[i].dci_format < 2) ul_config->ul_config_list[ul_config->number_pdus].pdu_type = FAPI_NR_UL_CONFIG_TYPE_PUSCH; + } } ul_config->ul_config_list[ul_config->number_pdus].pucch_config_pdu.initialCyclicShift = phy_config->config_req.ul_bwp_dedicated.pucch_config_dedicated.multi_csi_pucch_resources[0].initial_cyclic_shift; // x x ul_config->ul_config_list[ul_config->number_pdus].pucch_config_pdu.nrofSymbols = phy_config->config_req.ul_bwp_dedicated.pucch_config_dedicated.multi_csi_pucch_resources[0].number_of_symbols; // x x x x x @@ -270,7 +228,7 @@ int8_t nr_ue_decode_mib( scs_pdcch = scs_30kHz; } - channel_bandwidth_t min_channel_bw = bw_40MHz; // deafult for testing + channel_bandwidth_t min_channel_bw = bw_10MHz; // deafult for testing uint32_t is_condition_A = (ssb_subcarrier_offset == 0); // 38.213 ch.13 frequency_range_t frequency_range = FR1; @@ -2200,3 +2158,213 @@ void nr_ue_process_mac_pdu( AssertFatal(pdu_len >= 0, "[MAC] nr_ue_process_mac_pdu, residual mac pdu length < 0!\n"); } } + +//--------------------------------------------------------------------------------- + + +unsigned char *parse_header(unsigned char *mac_header, + unsigned char *num_ce, + unsigned char *num_sdu, + unsigned char *rx_ces, + unsigned char *rx_lcids, + unsigned short *rx_lengths, + unsigned short tb_length) +{ + + unsigned char not_done = 1, num_ces = 0, num_cont_res = + 0, num_padding = 0, num_sdus = 0, lcid, num_sdu_cnt; + unsigned char *mac_header_ptr = mac_header; + unsigned short length, ce_len = 0; + + while (not_done == 1) { + + if (((SCH_SUBHEADER_FIXED *) mac_header_ptr)->E == 0) { + // printf("E=0\n"); + not_done = 0; + } + + lcid = ((SCH_SUBHEADER_FIXED *) mac_header_ptr)->LCID; + + if (lcid < UE_CONT_RES) { + //printf("[MAC][UE] header %x.%x.%x\n",mac_header_ptr[0],mac_header_ptr[1],mac_header_ptr[2]); + if (not_done == 0) { // last MAC SDU, length is implicit + mac_header_ptr++; + length = + tb_length - (mac_header_ptr - mac_header) - ce_len; + + for (num_sdu_cnt = 0; num_sdu_cnt < num_sdus; + num_sdu_cnt++) { + length -= rx_lengths[num_sdu_cnt]; + } + } else { + if (((SCH_SUBHEADER_LONG *) mac_header_ptr)->F == 1) { + length = + ((((SCH_SUBHEADER_LONG *) mac_header_ptr)-> + L_MSB & 0x7f) + << 8) | (((SCH_SUBHEADER_LONG *) mac_header_ptr)-> + L_LSB & 0xff); + mac_header_ptr += 3; +#ifdef DEBUG_HEADER_PARSING + LOG_D(MAC, "[UE] parse long sdu, size %x \n", length); +#endif + + } else { //if (((SCH_SUBHEADER_SHORT *)mac_header_ptr)->F == 0) { + length = ((SCH_SUBHEADER_SHORT *) mac_header_ptr)->L; + mac_header_ptr += 2; + } + } + +#ifdef DEBUG_HEADER_PARSING + LOG_D(MAC, "[UE] sdu %d lcid %d length %d (offset now %ld)\n", + num_sdus, lcid, length, mac_header_ptr - mac_header); +#endif + rx_lcids[num_sdus] = lcid; + rx_lengths[num_sdus] = length; + num_sdus++; + } else { // This is a control element subheader + if (lcid == SHORT_PADDING) { + num_padding++; + mac_header_ptr++; + } else { + rx_ces[num_ces] = lcid; + num_ces++; + mac_header_ptr++; + + if (lcid == TIMING_ADV_CMD) { + ce_len++; + } else if (lcid == UE_CONT_RES) { + + // FNA: check MAC Header is one of thoses defined in Annex B of 36.321 + // Check there is only 1 Contention Resolution + if (num_cont_res) { + LOG_W(MAC, + "[UE] Msg4 Wrong received format: More than 1 Contention Resolution\n"); + // exit parsing + return NULL; + + } + // UE_CONT_RES shall never be the last subheader unless this is the only MAC subheader + if ((not_done == 0) + && ((num_sdus) || (num_ces > 1) || (num_padding))) { + LOG_W(MAC, + "[UE] Msg4 Wrong received format: Contention Resolution after num_ces=%d num_sdus=%d num_padding=%d\n", + num_ces, num_sdus, num_padding); + // exit parsing + return NULL; + } + num_cont_res++; + ce_len += 6; + } + } + +#ifdef DEBUG_HEADER_PARSING + LOG_D(MAC, "[UE] ce %d lcid %d (offset now %ld)\n", num_ces, + lcid, mac_header_ptr - mac_header); +#endif + } + } + + *num_ce = num_ces; + *num_sdu = num_sdus; + + return (mac_header_ptr); +} + + +//------------------------------------------------------------------------------ +void +nr_ue_send_sdu(module_id_t module_idP, + uint8_t CC_id, + frame_t frameP, + sub_frame_t subframeP, + uint8_t * sdu, uint16_t sdu_len, uint8_t eNB_index) +//------------------------------------------------------------------------------ +{ + + unsigned char rx_ces[MAX_NUM_CE], num_ce, num_sdu, i, *payload_ptr; + unsigned char rx_lcids[NB_RB_MAX]; + unsigned short rx_lengths[NB_RB_MAX]; + + + //LOG_D(MAC,"sdu: %x.%x.%x\n",sdu[0],sdu[1],sdu[2]); + + + payload_ptr = + parse_header(sdu, &num_ce, &num_sdu, rx_ces, rx_lcids, rx_lengths, + sdu_len); + +#ifdef DEBUG_HEADER_PARSING + LOG_D(MAC, + "[UE %d] ue_send_sdu : Frame %d eNB_index %d : num_ce %d num_sdu %d\n", + module_idP, frameP, eNB_index, num_ce, num_sdu); +#endif + +#if defined(ENABLE_MAC_PAYLOAD_DEBUG) + LOG_T(MAC, "[UE %d] First 32 bytes of DLSCH : \n", module_idP); + + for (i = 0; i < 32; i++) { + LOG_T(MAC, "%x.", sdu[i]); + } + + LOG_T(MAC, "\n"); +#endif + + if (payload_ptr != NULL) { + + for (i = 0; i < num_ce; i++) { + // printf("ce %d : %d\n",i,rx_ces[i]); + switch (rx_ces[i]) { + case UE_CONT_RES: + + break; + + case TIMING_ADV_CMD: + + break; + + case DRX_CMD: + + break; + } + } + + for (i = 0; i < num_sdu; i++) { +#ifdef DEBUG_HEADER_PARSING + LOG_I(MAC, "[UE] SDU %d : LCID %d, length %d\n", i, + rx_lcids[i], rx_lengths[i]); +#endif + if ((rx_lcids[i] < NB_RB_MAX) && (rx_lcids[i] > DCCH1)) { + + LOG_D(MAC, + "[UE %d] Frame %d : DLSCH -> DL-DTCH%d (eNB %d, %d bytes)\n", + module_idP, frameP, rx_lcids[i], eNB_index, + rx_lengths[i]); + +#if defined(ENABLE_MAC_PAYLOAD_DEBUG) + LOG_I(MAC, "Printing MAC PDU contents at slot: %d \n", subframeP); + int j; + for (j = 0; j < 20; j++) //rx_lengths[i] + LOG_I(MAC, "%x.", (unsigned char) payload_ptr[j]); + LOG_I(MAC, "\n"); +#endif + mac_rlc_data_ind(module_idP, + 4660, //UE_mac_inst[module_idP].crnti //hardcode value corresponding to the one from the eNB + eNB_index, + frameP, + ENB_FLAG_NO, + MBMS_FLAG_NO, + rx_lcids[i], + (char *) payload_ptr, rx_lengths[i], 1, + NULL); + } else { + LOG_E(MAC, "[UE %d] Frame %d : unknown LCID %d (eNB %d)\n", + module_idP, frameP, rx_lcids[i], eNB_index); + } + payload_ptr += rx_lengths[i]; + } + } // end if (payload_ptr != NULL) + +} + + + diff --git a/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler.c b/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler.c index 8ac85c64dd..f0de990442 100644 --- a/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler.c +++ b/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler.c @@ -70,9 +70,9 @@ extern uint8_t nfapi_mode; uint16_t nr_pdcch_order_table[6] = { 31, 31, 511, 2047, 2047, 8191 }; -void clear_nr_nfapi_information(gNB_MAC_INST * gNB, +void clear_nr_nfapi_information(gNB_MAC_INST * gNB, int CC_idP, - frame_t frameP, + frame_t frameP, sub_frame_t slotP){ nfapi_nr_dl_config_request_t *DL_req = &gNB->DL_req[0]; @@ -102,10 +102,10 @@ void clear_nr_nfapi_information(gNB_MAC_INST * gNB, } } /* -void check_nr_ul_failure(module_id_t module_idP, - int CC_id, +void check_nr_ul_failure(module_id_t module_idP, + int CC_id, int UE_id, - frame_t frameP, + frame_t frameP, sub_frame_t slotP) { UE_list_t *UE_list = &RC.nrmac[module_idP]->UE_list; @@ -191,13 +191,13 @@ void schedule_nr_SRS(module_id_t module_idP, frame_t frameP, sub_frame_t subfram uint8_t TSFC; uint16_t deltaTSFC; // bitmap uint8_t srs_SubframeConfig; - + // table for TSFC (Period) and deltaSFC (offset) const uint16_t deltaTSFCTabType1[15][2] = { {1, 1}, {1, 2}, {2, 2}, {1, 5}, {2, 5}, {4, 5}, {8, 5}, {3, 5}, {12, 5}, {1, 10}, {2, 10}, {4, 10}, {8, 10}, {351, 10}, {383, 10} }; // Table 5.5.3.3-2 3GPP 36.211 FDD const uint16_t deltaTSFCTabType2[14][2] = { {2, 5}, {6, 5}, {10, 5}, {18, 5}, {14, 5}, {22, 5}, {26, 5}, {30, 5}, {70, 10}, {74, 10}, {194, 10}, {326, 10}, {586, 10}, {210, 10} }; // Table 5.5.3.3-2 3GPP 36.211 TDD - + uint16_t srsPeriodicity, srsOffset; - + for (CC_id = 0; CC_id < MAX_NUM_CCs; CC_id++) { soundingRS_UL_ConfigCommon = &cc[CC_id].radioResourceConfigCommon->soundingRS_UL_ConfigCommon; // check if SRS is enabled in this frame/subframe @@ -212,7 +212,7 @@ void schedule_nr_SRS(module_id_t module_idP, frame_t frameP, sub_frame_t subfram } // Sounding reference signal subframes are the subframes satisfying ns/2 mod TSFC (- deltaTSFC uint16_t tmp = (subframeP % TSFC); - + if ((1 << tmp) & deltaTSFC) { // This is an SRS subframe, loop over UEs for (UE_id = 0; UE_id < MAX_MOBILES_PER_GNB; UE_id++) { @@ -220,11 +220,11 @@ void schedule_nr_SRS(module_id_t module_idP, frame_t frameP, sub_frame_t subfram ul_req = &RC.nrmac[module_idP]->UL_req[CC_id].ul_config_request_body; // drop the allocation if the UE hasn't send RRCConnectionSetupComplete yet if (mac_eNB_get_rrc_status(module_idP,UE_RNTI(module_idP, UE_id)) < RRC_CONNECTED) continue; - + AssertFatal(UE_list->UE_template[CC_id][UE_id].physicalConfigDedicated != NULL, "physicalConfigDedicated is null for UE %d\n", UE_id); - + if ((soundingRS_UL_ConfigDedicated = UE_list->UE_template[CC_id][UE_id].physicalConfigDedicated->soundingRS_UL_ConfigDedicated) != NULL) { if (soundingRS_UL_ConfigDedicated->present == SoundingRS_UL_ConfigDedicated_PR_setup) { get_srs_pos(&cc[CC_id], @@ -256,7 +256,7 @@ void schedule_nr_SRS(module_id_t module_idP, frame_t frameP, sub_frame_t subfram } // if ((soundingRS_UL_ConfigDedicated = UE_list->UE_template[CC_id][UE_id].physicalConfigDedicated->soundingRS_UL_ConfigDedicated)!=NULL) } // for (UE_id ... } // if((1<common_channels; + //nfapi_nr_dl_config_dlsch_pdu_rel15_t *dlsch_config = NULL; start_meas(&RC.nrmac[module_idP]->eNB_scheduler); VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_ENB_DLSCH_ULSCH_SCHEDULER,VCD_FUNCTION_IN); @@ -338,6 +339,7 @@ void gNB_dlsch_ulsch_scheduler(module_id_t module_idP, if (UE_list->active[i]) { nfapi_nr_config_request_t *cfg = &RC.nrmac[module_idP]->config[CC_id]; +<<<<<<< HEAD if (nr_is_dci_opportunity(UE_list->search_space[i][1], UE_list->coreset[i][1], @@ -356,7 +358,6 @@ void gNB_dlsch_ulsch_scheduler(module_id_t module_idP, PROTOCOL_CTXT_SET_BY_MODULE_ID(&ctxt, module_idP, ENB_FLAG_YES,NOT_A_RNTI, frameP, slotP,module_idP); // pdcp_run(&ctxt); - //rrc_rx_tx(&ctxt, CC_id); // This schedules MIB @@ -379,6 +380,6 @@ void gNB_dlsch_ulsch_scheduler(module_id_t module_idP, stop_meas(&RC.nrmac[module_idP]->eNB_scheduler); */ - + VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_ENB_DLSCH_ULSCH_SCHEDULER,VCD_FUNCTION_OUT); } diff --git a/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_phytest.c b/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_phytest.c index a17f73e2c8..8f647d5e30 100644 --- a/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_phytest.c +++ b/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_phytest.c @@ -33,7 +33,9 @@ #include "mac_proto.h" #include "PHY/NR_TRANSPORT/nr_dlsch.h" #include "PHY/NR_TRANSPORT/nr_dci.h" +#include "executables/nr-softmodem.h" extern RAN_CONTEXT_t RC; +//#define ENABLE_MAC_PAYLOAD_DEBUG 1 /*Scheduling of DLSCH with associated DCI in common search space * current version has only a DCI for type 1 PDCCH for C_RNTI*/ @@ -113,7 +115,7 @@ void nr_schedule_css_dlsch_phytest(module_id_t module_idP, pdu_rel15->vrb_to_prb_mapping = 1; pdu_rel15->mcs = 9; pdu_rel15->tb_scaling = 1; - + pdu_rel15->ra_preamble_index = 25; pdu_rel15->format_indicator = 1; pdu_rel15->ndi = 1; @@ -152,7 +154,7 @@ void nr_schedule_css_dlsch_phytest(module_id_t module_idP, params_rel15->nb_slots, params_rel15->sfn_mod2, params_rel15->first_slot); - nr_get_tbs(&dl_config_dlsch_pdu->dlsch_pdu, dl_config_dci_pdu->dci_dl_pdu); + nr_get_tbs_dl(&dl_config_dlsch_pdu->dlsch_pdu, dl_config_dci_pdu->dci_dl_pdu); LOG_D(MAC, "DLSCH PDU: start PRB %d n_PRB %d start symbol %d nb_symbols %d nb_layers %d nb_codewords %d mcs %d\n", dlsch_pdu_rel15->start_prb, dlsch_pdu_rel15->n_prb, @@ -177,147 +179,412 @@ void nr_schedule_css_dlsch_phytest(module_id_t module_idP, nr_mac->TX_req[CC_id].tx_request_body.tl.tag = NFAPI_TX_REQUEST_BODY_TAG; nr_mac->TX_req[CC_id].header.message_id = NFAPI_TX_REQUEST; - } } -/*Scheduling of DLSCH with associated DCI in user specific search space - * current version has only a DCI for type 1 PDCCH for C_RNTI*/ +int configure_fapi_dl_Tx(nfapi_nr_dl_config_request_body_t *dl_req, + nfapi_tx_request_pdu_t *TX_req, + nfapi_nr_config_request_t *cfg, + nfapi_nr_coreset_t* coreset, + nfapi_nr_search_space_t* search_space, + int16_t pdu_index, + nfapi_nr_dl_config_dlsch_pdu_rel15_t *dlsch_config){ + + nfapi_nr_dl_config_request_pdu_t *dl_config_dci_pdu; + nfapi_nr_dl_config_request_pdu_t *dl_config_dlsch_pdu; + int TBS; + uint16_t rnti = 0x1234; + int dl_carrier_bandwidth = cfg->rf_config.dl_carrier_bandwidth.value; + + + dl_config_dci_pdu = &dl_req->dl_config_pdu_list[dl_req->number_pdu]; + memset((void*)dl_config_dci_pdu,0,sizeof(nfapi_nr_dl_config_request_pdu_t)); + dl_config_dci_pdu->pdu_type = NFAPI_NR_DL_CONFIG_DCI_DL_PDU_TYPE; + dl_config_dci_pdu->pdu_size = (uint8_t)(2+sizeof(nfapi_nr_dl_config_dci_dl_pdu)); + + dl_config_dlsch_pdu = &dl_req->dl_config_pdu_list[dl_req->number_pdu+1]; + memset((void*)dl_config_dlsch_pdu,0,sizeof(nfapi_nr_dl_config_request_pdu_t)); + dl_config_dlsch_pdu->pdu_type = NFAPI_NR_DL_CONFIG_DLSCH_PDU_TYPE; + dl_config_dlsch_pdu->pdu_size = (uint8_t)(2+sizeof(nfapi_nr_dl_config_dlsch_pdu)); + + nfapi_nr_dl_config_dci_dl_pdu_rel15_t *pdu_rel15 = &dl_config_dci_pdu->dci_dl_pdu.dci_dl_pdu_rel15; + nfapi_nr_dl_config_pdcch_parameters_rel15_t *params_rel15 = &dl_config_dci_pdu->dci_dl_pdu.pdcch_params_rel15; + nfapi_nr_dl_config_dlsch_pdu_rel15_t *dlsch_pdu_rel15 = &dl_config_dlsch_pdu->dlsch_pdu.dlsch_pdu_rel15; + + dlsch_pdu_rel15->start_prb = 0; + dlsch_pdu_rel15->n_prb = 50; + dlsch_pdu_rel15->start_symbol = 2; + dlsch_pdu_rel15->nb_symbols = 9; + dlsch_pdu_rel15->rnti = rnti; + dlsch_pdu_rel15->nb_layers =1; + dlsch_pdu_rel15->nb_codewords = 1; + dlsch_pdu_rel15->mcs_idx = 9; + dlsch_pdu_rel15->ndi = 1; + dlsch_pdu_rel15->redundancy_version = 0; + + if (dlsch_config != NULL) { + dlsch_pdu_rel15->start_prb = dlsch_config->start_prb; + dlsch_pdu_rel15->n_prb = dlsch_config->n_prb; + dlsch_pdu_rel15->start_symbol = dlsch_config->start_symbol; + dlsch_pdu_rel15->nb_symbols = dlsch_config->nb_symbols; + dlsch_pdu_rel15->mcs_idx = dlsch_config->mcs_idx; + } + + nr_configure_dci_from_pdcch_config(params_rel15, + coreset, + search_space, + *cfg, + dl_carrier_bandwidth); + + pdu_rel15->frequency_domain_assignment = get_RIV(dlsch_pdu_rel15->start_prb, dlsch_pdu_rel15->n_prb, cfg->rf_config.dl_carrier_bandwidth.value); + pdu_rel15->time_domain_assignment = 3; // row index used here instead of SLIV; + pdu_rel15->vrb_to_prb_mapping = 1; + pdu_rel15->mcs = dlsch_pdu_rel15->mcs_idx; + pdu_rel15->tb_scaling = 1; + + pdu_rel15->ra_preamble_index = 25; + pdu_rel15->format_indicator = 1; + pdu_rel15->ndi = 1; + pdu_rel15->rv = 0; + pdu_rel15->harq_pid = 0; + pdu_rel15->dai = 2; + pdu_rel15->tpc = 2; + pdu_rel15->pucch_resource_indicator = 7; + pdu_rel15->pdsch_to_harq_feedback_timing_indicator = 7; + + LOG_D(MAC, "[gNB scheduler phytest] DCI type 1 payload: freq_alloc %d, time_alloc %d, vrb to prb %d, mcs %d tb_scaling %d ndi %d rv %d\n", + pdu_rel15->frequency_domain_assignment, + pdu_rel15->time_domain_assignment, + pdu_rel15->vrb_to_prb_mapping, + pdu_rel15->mcs, + pdu_rel15->tb_scaling, + pdu_rel15->ndi, + pdu_rel15->rv); + + params_rel15->rnti = rnti; + params_rel15->rnti_type = NFAPI_NR_RNTI_C; + params_rel15->dci_format = NFAPI_NR_DL_DCI_FORMAT_1_0; + + //params_rel15->aggregation_level = 1; + LOG_D(MAC, "DCI params: rnti %d, rnti_type %d, dci_format %d, config type %d\n \ + coreset params: mux_pattern %d, n_rb %d, n_symb %d, rb_offset %d \n \ + ss params : first symb %d, ss type %d\n", + params_rel15->rnti, + params_rel15->rnti_type, + params_rel15->config_type, + params_rel15->dci_format, + params_rel15->mux_pattern, + params_rel15->n_rb, + params_rel15->n_symb, + params_rel15->rb_offset, + params_rel15->first_symbol, + params_rel15->search_space_type); + nr_get_tbs_dl(&dl_config_dlsch_pdu->dlsch_pdu, dl_config_dci_pdu->dci_dl_pdu, *cfg); + // Hardcode it for now + TBS = dl_config_dlsch_pdu->dlsch_pdu.dlsch_pdu_rel15.transport_block_size; + LOG_D(MAC, "DLSCH PDU: start PRB %d n_PRB %d start symbol %d nb_symbols %d nb_layers %d nb_codewords %d mcs %d TBS: %d\n", + dlsch_pdu_rel15->start_prb, + dlsch_pdu_rel15->n_prb, + dlsch_pdu_rel15->start_symbol, + dlsch_pdu_rel15->nb_symbols, + dlsch_pdu_rel15->nb_layers, + dlsch_pdu_rel15->nb_codewords, + dlsch_pdu_rel15->mcs_idx, + TBS); + + dl_req->number_dci++; + dl_req->number_pdsch_rnti++; + dl_req->number_pdu+=2; + + TX_req->pdu_length = dlsch_pdu_rel15->transport_block_size/8; + TX_req->pdu_index = pdu_index++; + TX_req->num_segments = 1; + + return TBS/8; //Return TBS in bytes +} + + + + + + + void nr_schedule_uss_dlsch_phytest(module_id_t module_idP, frame_t frameP, - sub_frame_t slotP) + sub_frame_t slotP, + nfapi_nr_dl_config_dlsch_pdu_rel15_t *dlsch_config) { + LOG_D(MAC, "In nr_schedule_uss_dlsch_phytest \n"); uint8_t CC_id; gNB_MAC_INST *nr_mac = RC.nrmac[module_idP]; //NR_COMMON_channels_t *cc = nr_mac->common_channels; nfapi_nr_dl_config_request_body_t *dl_req; - nfapi_nr_dl_config_request_pdu_t *dl_config_dci_pdu; - nfapi_nr_dl_config_request_pdu_t *dl_config_dlsch_pdu; nfapi_tx_request_pdu_t *TX_req; - - nfapi_nr_config_request_t *cfg = &nr_mac->config[0]; uint16_t rnti = 0x1234; + nfapi_nr_config_request_t *cfg = &nr_mac->config[0]; + uint16_t sfn_sf = frameP << 7 | slotP; - int dl_carrier_bandwidth = cfg->rf_config.dl_carrier_bandwidth.value; // everything here is hard-coded to 30 kHz //int scs = get_dlscs(cfg); //int slots_per_frame = get_spf(cfg); - for (CC_id=0; CC_idUE_list.coreset[0][1]; - nfapi_nr_search_space_t* search_space = &nr_mac->UE_list.search_space[0][1]; + nfapi_nr_coreset_t* coreset = &nr_mac->UE_list.coreset[0][1]; + nfapi_nr_search_space_t* search_space = &nr_mac->UE_list.search_space[0][1]; + nfapi_nr_dl_config_dci_dl_pdu_rel15_t *pdu_rel15 = &dl_config_dci_pdu->dci_dl_pdu.dci_dl_pdu_rel15; + nfapi_nr_dl_config_pdcch_parameters_rel15_t *params_rel15 = &dl_config_dci_pdu->dci_dl_pdu.pdcch_params_rel15; + nfapi_nr_dl_config_dlsch_pdu_rel15_t *dlsch_pdu_rel15 = &dl_config_dlsch_pdu->dlsch_pdu.dlsch_pdu_rel15; + + dlsch_pdu_rel15->start_prb = 0; + dlsch_pdu_rel15->n_prb = 50; + dlsch_pdu_rel15->start_symbol = 2; + dlsch_pdu_rel15->nb_symbols = 9; + dlsch_pdu_rel15->rnti = rnti; + dlsch_pdu_rel15->nb_layers =1; + dlsch_pdu_rel15->nb_codewords = 1; + dlsch_pdu_rel15->mcs_idx = 9; + dlsch_pdu_rel15->ndi = 1; + dlsch_pdu_rel15->redundancy_version = 0; + + nr_configure_dci_from_pdcch_config(params_rel15, + coreset, + search_space, + *cfg, + dl_carrier_bandwidth); + + pdu_rel15->frequency_domain_assignment = get_RIV(dlsch_pdu_rel15->start_prb, dlsch_pdu_rel15->n_prb, cfg->rf_config.dl_carrier_bandwidth.value); + pdu_rel15->time_domain_assignment = 3; // row index used here instead of SLIV; + pdu_rel15->vrb_to_prb_mapping = 1; + pdu_rel15->mcs = 9; + pdu_rel15->tb_scaling = 1; + + pdu_rel15->ra_preamble_index = 25; + pdu_rel15->format_indicator = 1; + pdu_rel15->ndi = 1; + pdu_rel15->rv = 0; + pdu_rel15->harq_pid = 0; + pdu_rel15->dai = 2; + pdu_rel15->tpc = 2; + pdu_rel15->pucch_resource_indicator = 7; + pdu_rel15->pdsch_to_harq_feedback_timing_indicator = 7; + + LOG_D(MAC, "[gNB scheduler phytest] DCI type 1 payload: freq_alloc %d, time_alloc %d, vrb to prb %d, mcs %d tb_scaling %d ndi %d rv %d\n", + pdu_rel15->frequency_domain_assignment, + pdu_rel15->time_domain_assignment, + pdu_rel15->vrb_to_prb_mapping, + pdu_rel15->mcs, + pdu_rel15->tb_scaling, + pdu_rel15->ndi, + pdu_rel15->rv); + + params_rel15->rnti = rnti; + params_rel15->rnti_type = NFAPI_NR_RNTI_C; + params_rel15->dci_format = NFAPI_NR_DL_DCI_FORMAT_1_0; - dl_req = &nr_mac->DL_req[CC_id].dl_config_request_body; - dl_config_dci_pdu = &dl_req->dl_config_pdu_list[dl_req->number_pdu]; - memset((void*)dl_config_dci_pdu,0,sizeof(nfapi_nr_dl_config_request_pdu_t)); - dl_config_dci_pdu->pdu_type = NFAPI_NR_DL_CONFIG_DCI_DL_PDU_TYPE; - dl_config_dci_pdu->pdu_size = (uint8_t)(2+sizeof(nfapi_nr_dl_config_dci_dl_pdu)); - - dl_config_dlsch_pdu = &dl_req->dl_config_pdu_list[dl_req->number_pdu+1]; - memset((void*)dl_config_dlsch_pdu,0,sizeof(nfapi_nr_dl_config_request_pdu_t)); - dl_config_dlsch_pdu->pdu_type = NFAPI_NR_DL_CONFIG_DLSCH_PDU_TYPE; - dl_config_dlsch_pdu->pdu_size = (uint8_t)(2+sizeof(nfapi_nr_dl_config_dlsch_pdu)); - - nfapi_nr_dl_config_dci_dl_pdu_rel15_t *pdu_rel15 = &dl_config_dci_pdu->dci_dl_pdu.dci_dl_pdu_rel15; - nfapi_nr_dl_config_pdcch_parameters_rel15_t *params_rel15 = &dl_config_dci_pdu->dci_dl_pdu.pdcch_params_rel15; - nfapi_nr_dl_config_dlsch_pdu_rel15_t *dlsch_pdu_rel15 = &dl_config_dlsch_pdu->dlsch_pdu.dlsch_pdu_rel15; - - dlsch_pdu_rel15->start_prb = 0; - dlsch_pdu_rel15->n_prb = 50; - dlsch_pdu_rel15->start_symbol = 2; - dlsch_pdu_rel15->nb_symbols = 9; - dlsch_pdu_rel15->rnti = rnti; - dlsch_pdu_rel15->nb_layers =1; - dlsch_pdu_rel15->nb_codewords = 1; - dlsch_pdu_rel15->mcs_idx = 9; - dlsch_pdu_rel15->ndi = 1; - dlsch_pdu_rel15->redundancy_version = 0; - - nr_configure_dci_from_pdcch_config(params_rel15, - coreset, - search_space, - *cfg, - dl_carrier_bandwidth); - - pdu_rel15->frequency_domain_assignment = get_RIV(dlsch_pdu_rel15->start_prb, dlsch_pdu_rel15->n_prb, cfg->rf_config.dl_carrier_bandwidth.value); - pdu_rel15->time_domain_assignment = 3; // row index used here instead of SLIV; - pdu_rel15->vrb_to_prb_mapping = 1; - pdu_rel15->mcs = 9; - pdu_rel15->tb_scaling = 1; - - pdu_rel15->ra_preamble_index = 25; - pdu_rel15->format_indicator = 1; - pdu_rel15->ndi = 1; - pdu_rel15->rv = 0; - pdu_rel15->harq_pid = 0; - pdu_rel15->dai = 2; - pdu_rel15->tpc = 2; - pdu_rel15->pucch_resource_indicator = 7; - pdu_rel15->pdsch_to_harq_feedback_timing_indicator = 7; - - LOG_D(MAC, "[gNB scheduler phytest] DCI type 1 payload: freq_alloc %d, time_alloc %d, vrb to prb %d, mcs %d tb_scaling %d ndi %d rv %d\n", - pdu_rel15->frequency_domain_assignment, - pdu_rel15->time_domain_assignment, - pdu_rel15->vrb_to_prb_mapping, - pdu_rel15->mcs, - pdu_rel15->tb_scaling, - pdu_rel15->ndi, - pdu_rel15->rv); - - params_rel15->rnti = rnti; - params_rel15->rnti_type = NFAPI_NR_RNTI_C; - params_rel15->dci_format = NFAPI_NR_DL_DCI_FORMAT_1_0; - - //params_rel15->aggregation_level = 1; - LOG_D(MAC, "DCI params: rnti %d, rnti_type %d, dci_format %d, config type %d\n \ + //params_rel15->aggregation_level = 1; + LOG_D(MAC, "DCI params: rnti %d, rnti_type %d, dci_format %d, config type %d\n \ coreset params: mux_pattern %d, n_rb %d, n_symb %d, rb_offset %d \n \ ss params : first symb %d, ss type %d\n", - params_rel15->rnti, - params_rel15->rnti_type, - params_rel15->config_type, - params_rel15->dci_format, - params_rel15->mux_pattern, - params_rel15->n_rb, - params_rel15->n_symb, - params_rel15->rb_offset, - params_rel15->first_symbol, - params_rel15->search_space_type); + params_rel15->rnti, + params_rel15->rnti_type, + params_rel15->config_type, + params_rel15->dci_format, + params_rel15->mux_pattern, + params_rel15->n_rb, + params_rel15->n_symb, + params_rel15->rb_offset, + params_rel15->first_symbol, + params_rel15->search_space_type); nr_get_tbs(&dl_config_dlsch_pdu->dlsch_pdu, dl_config_dci_pdu->dci_dl_pdu); LOG_D(MAC, "DLSCH PDU: start PRB %d n_PRB %d start symbol %d nb_symbols %d nb_layers %d nb_codewords %d mcs %d\n", - dlsch_pdu_rel15->start_prb, - dlsch_pdu_rel15->n_prb, - dlsch_pdu_rel15->start_symbol, - dlsch_pdu_rel15->nb_symbols, - dlsch_pdu_rel15->nb_layers, - dlsch_pdu_rel15->nb_codewords, - dlsch_pdu_rel15->mcs_idx); - + dlsch_pdu_rel15->start_prb, + dlsch_pdu_rel15->n_prb, + dlsch_pdu_rel15->start_symbol, + dlsch_pdu_rel15->nb_symbols, + dlsch_pdu_rel15->nb_layers, + dlsch_pdu_rel15->nb_codewords, + dlsch_pdu_rel15->mcs_idx); + dl_req->number_dci++; dl_req->number_pdsch_rnti++; dl_req->number_pdu+=2; - + + LOG_D(MAC, "Scheduling UE specific search space DCI type 1 for CC_id %d\n",CC_id); + + dl_req = &nr_mac->DL_req[CC_id].dl_config_request_body; TX_req = &nr_mac->TX_req[CC_id].tx_request_body.tx_pdu_list[nr_mac->TX_req[CC_id].tx_request_body.number_of_pdus]; - TX_req->pdu_length = dlsch_pdu_rel15->transport_block_size; - TX_req->pdu_index = nr_mac->pdu_index[CC_id]++; - TX_req->num_segments = 1; - - // HOT FIX for all zero pdu problem - // ------------------------------------------------------------------------------------------------ - for(int i = 0; i < dlsch_pdu_rel15->transport_block_size/8; i++) { - ((uint8_t *)nr_mac->UE_list.DLSCH_pdu[0][0].payload[0])[i] = (unsigned char) rand(); + + //The --NOS1 use case currently schedules DLSCH transmissions only when there is IP traffic arriving + //through the LTE stack + if (IS_SOFTMODEM_NOS1){ + + memset(&DLSCH_pdu, 0, sizeof(DLSCH_pdu)); + int ta_update = 31; + ta_len = 0; + + // Hardcode it for now + TBS = 6784/8; //TBS in bytes + //nr_get_tbs_dl(&dl_config_dlsch_pdu->dlsch_pdu, dl_config_dci_pdu->dci_dl_pdu, *cfg); + //TBS = dl_config_dlsch_pdu->dlsch_pdu.dlsch_pdu_rel15.transport_block_size; + + for (lcid = NB_RB_MAX - 1; lcid >= DTCH; lcid--) { + // TODO: check if the lcid is active + + LOG_D(MAC, "[eNB %d], Frame %d, DTCH%d->DLSCH, Checking RLC status (tbs %d, len %d)\n", + module_idP, frameP, lcid, TBS, + TBS - ta_len - header_length_total - sdu_length_total - 3); + + if (TBS - ta_len - header_length_total - sdu_length_total - 3 > 0) { + rlc_status = mac_rlc_status_ind(module_idP, + rnti, + module_idP, + frameP, + slotP, + ENB_FLAG_YES, + MBMS_FLAG_NO, + lcid, + TBS - ta_len - header_length_total - sdu_length_total - 3 + //#if (RRC_VERSION >= MAKE_VERSION(14, 0, 0)) + ,0, 0 + //#endif + ); + + if (rlc_status.bytes_in_buffer > 0) { + LOG_D(MAC, + "[eNB %d][USER-PLANE DEFAULT DRB] Frame %d : DTCH->DLSCH, Requesting %d bytes from RLC (lcid %d total hdr len %d), TBS: %d \n \n", + module_idP, frameP, + TBS - ta_len - header_length_total - sdu_length_total - 3, + lcid, + header_length_total, + TBS); + + sdu_lengths[num_sdus] = mac_rlc_data_req(module_idP, rnti, module_idP, frameP, ENB_FLAG_YES, MBMS_FLAG_NO, lcid, + TBS, + (char *)&dlsch_buffer[sdu_length_total] + //#if (RRC_VERSION >= MAKE_VERSION(14, 0, 0)) + ,0, 0 + //#endif + ); + + + + LOG_D(MAC, + "[eNB %d][USER-PLANE DEFAULT DRB] Got %d bytes for DTCH %d \n", + module_idP, sdu_lengths[num_sdus], lcid); + + sdu_lcids[num_sdus] = lcid; + sdu_length_total += sdu_lengths[num_sdus]; + UE_list->eNB_UE_stats[CC_id][UE_id].num_pdu_tx[lcid]++; + UE_list->eNB_UE_stats[CC_id][UE_id].lcid_sdu[num_sdus] = lcid; + UE_list->eNB_UE_stats[CC_id][UE_id].sdu_length_tx[lcid] = sdu_lengths[num_sdus]; + UE_list->eNB_UE_stats[CC_id][UE_id].num_bytes_tx[lcid] += sdu_lengths[num_sdus]; + + header_length_last = 1 + 1 + (sdu_lengths[num_sdus] >= 128); + header_length_total += header_length_last; + + num_sdus++; + + UE_list->UE_sched_ctrl[UE_id].uplane_inactivity_timer = 0; + } + } else { + // no TBS left + break; + } + } + + // last header does not have length field + if (header_length_total) { + header_length_total -= header_length_last; + header_length_total++; + } + + + if (ta_len + sdu_length_total + header_length_total > 0) { + + + if (TBS - header_length_total - sdu_length_total - ta_len <= 2) { + padding = TBS - header_length_total - sdu_length_total - ta_len; + post_padding = 0; + } else { + padding = 0; + post_padding = 1; + } + + offset = generate_dlsch_header((unsigned char *)nr_mac->UE_list.DLSCH_pdu[CC_id][0][0].payload[0], //DLSCH_pdu.payload[0], + num_sdus, //num_sdus + sdu_lengths, // + sdu_lcids, 255, // no drx + ta_update, // timing advance + NULL, // contention res id + padding, post_padding); + LOG_D(MAC, "Offset bits: %d \n", offset); + + // Probably there should be other actions done before that + // cycle through SDUs and place in dlsch_buffer + + //memcpy(&UE_list->DLSCH_pdu[CC_id][0][UE_id].payload[0][offset], dlsch_buffer, sdu_length_total); + memcpy(&nr_mac->UE_list.DLSCH_pdu[CC_id][0][UE_id].payload[0][offset], dlsch_buffer, sdu_length_total); + + + // fill remainder of DLSCH with 0 + for (int j = 0; j < (TBS - sdu_length_total - offset); j++) { + //UE_list->DLSCH_pdu[CC_id][0][UE_id].payload[0][offset + sdu_length_total + j] = 0; + nr_mac->UE_list.DLSCH_pdu[CC_id][0][0].payload[0][offset + sdu_length_total + j] = 0; + } + + TBS_bytes = configure_fapi_dl_Tx(dl_req, TX_req, cfg, &nr_mac->coreset[CC_id][1], &nr_mac->search_space[CC_id][1], nr_mac->pdu_index[CC_id], dlsch_config); + +#if defined(ENABLE_MAC_PAYLOAD_DEBUG) + LOG_I(MAC, "Printing first 10 payload bytes at the gNB side, Frame: %d, slot: %d, , TBS size: %d \n \n", frameP, slotP, TBS_bytes); + for(int i = 0; i < 10; i++) { // TBS_bytes dlsch_pdu_rel15->transport_block_size/8 6784/8 + LOG_I(MAC, "%x. ", ((uint8_t *)nr_mac->UE_list.DLSCH_pdu[CC_id][0][0].payload[0])[i]); + } +#endif + + //TX_req->segments[0].segment_length = 8; + TX_req->segments[0].segment_length = TBS_bytes +2; + TX_req->segments[0].segment_data = nr_mac->UE_list.DLSCH_pdu[CC_id][0][0].payload[0]; + + + nr_mac->TX_req[CC_id].tx_request_body.number_of_pdus++; + nr_mac->TX_req[CC_id].sfn_sf = sfn_sf; + nr_mac->TX_req[CC_id].tx_request_body.tl.tag = NFAPI_TX_REQUEST_BODY_TAG; + nr_mac->TX_req[CC_id].header.message_id = NFAPI_TX_REQUEST; + } //if (ta_len + sdu_length_total + header_length_total > 0) + } //if (IS_SOFTMODEM_NOS1) + + //When the --NOS1 option is not enabled, DLSCH transmissions with random data + //occur every time that the current function is called (dlsch phytest mode) + else{ + TBS_bytes = configure_fapi_dl_Tx(dl_req, TX_req, cfg, &nr_mac->coreset[CC_id][1], &nr_mac->search_space[CC_id][1], nr_mac->pdu_index[CC_id], dlsch_config); + // HOT FIX for all zero pdu problem + // ------------------------------------------------------------------------------------------------ + + for(int i = 0; i < TBS_bytes; i++) { // + ((uint8_t *)nr_mac->UE_list.DLSCH_pdu[CC_id][0][0].payload[0])[i] = (unsigned char) rand(); + //LOG_I(MAC, "%x. ", ((uint8_t *)nr_mac->UE_list.DLSCH_pdu[CC_id][0][0].payload[0])[i]); + } +#if defined(ENABLE_MAC_PAYLOAD_DEBUG) + if (frameP%100 == 0){ + LOG_I(MAC, "Printing first 10 payload bytes at the gNB side, Frame: %d, slot: %d, TBS size: %d \n", frameP, slotP, TBS_bytes); + for(int i = 0; i < 10; i++) { + LOG_I(MAC, "%x. ", ((uint8_t *)nr_mac->UE_list.DLSCH_pdu[CC_id][0][0].payload[0])[i]); + } + } +#endif + + //TX_req->segments[0].segment_length = 8; + TX_req->segments[0].segment_length = TBS_bytes +2; + TX_req->segments[0].segment_data = nr_mac->UE_list.DLSCH_pdu[CC_id][0][0].payload[0]; + + nr_mac->TX_req[CC_id].tx_request_body.number_of_pdus++; + nr_mac->TX_req[CC_id].sfn_sf = sfn_sf; + nr_mac->TX_req[CC_id].tx_request_body.tl.tag = NFAPI_TX_REQUEST_BODY_TAG; + nr_mac->TX_req[CC_id].header.message_id = NFAPI_TX_REQUEST; + // ------------------------------------------------------------------------------------------------ } - // ------------------------------------------------------------------------------------------------ +} - TX_req->segments[0].segment_data = nr_mac->UE_list.DLSCH_pdu[0][0].payload[0]; - TX_req->segments[0].segment_length = dlsch_pdu_rel15->transport_block_size+2; - nr_mac->TX_req[CC_id].tx_request_body.number_of_pdus++; - nr_mac->TX_req[CC_id].sfn_sf = sfn_sf; - nr_mac->TX_req[CC_id].tx_request_body.tl.tag = NFAPI_TX_REQUEST_BODY_TAG; - nr_mac->TX_req[CC_id].header.message_id = NFAPI_TX_REQUEST; - } -} diff --git a/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_primitives.c b/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_primitives.c index 2aad88158b..812bc8d42d 100644 --- a/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_primitives.c +++ b/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_primitives.c @@ -403,8 +403,10 @@ void nr_configure_dci_from_pdcch_config(nfapi_nr_dl_config_pdcch_parameters_rel1 // first symbol //AssertFatal(pdcch_scs==kHz15, "PDCCH SCS above 15kHz not allowed if a symbol above 2 is monitored"); - for (int i=0; imonitoring_symbols_in_slot>>(31-i))&1) { + int sps = get_symbolsperslot(&cfg); + + for (int i=0; imonitoring_symbols_in_slot>>(sps-1-i))&1) { pdcch_params->first_symbol=i; break; } diff --git a/openair2/LAYER2/NR_MAC_gNB/mac_proto.h b/openair2/LAYER2/NR_MAC_gNB/mac_proto.h index d811484c16..91b670462a 100644 --- a/openair2/LAYER2/NR_MAC_gNB/mac_proto.h +++ b/openair2/LAYER2/NR_MAC_gNB/mac_proto.h @@ -34,6 +34,8 @@ #include "nr_mac_gNB.h" #include "PHY/defs_gNB.h" +void set_cset_offset(uint16_t); + void mac_top_init_gNB(void); void config_common(int Mod_idP, @@ -61,9 +63,18 @@ void nr_schedule_css_dlsch_phytest(module_id_t module_idP, frame_t frameP, sub_frame_t subframeP); +int configure_fapi_dl_Tx(nfapi_nr_dl_config_request_body_t *dl_req, + nfapi_tx_request_pdu_t *TX_req, + nfapi_nr_config_request_t *cfg, + nfapi_nr_coreset_t* coreset, + nfapi_nr_search_space_t* search_space, + int16_t pdu_index, + nfapi_nr_dl_config_dlsch_pdu_rel15_t *dlsch_config); + void nr_schedule_uss_dlsch_phytest(module_id_t module_idP, frame_t frameP, - sub_frame_t slotP); + sub_frame_t slotP, + nfapi_nr_dl_config_dlsch_pdu_rel15_t *dlsch_config); void nr_configure_css_dci_initial(nfapi_nr_dl_config_pdcch_parameters_rel15_t* pdcch_params, nr_scs_e scs_common, @@ -99,7 +110,7 @@ int to_absslot(nfapi_nr_config_request_t *cfg,int frame,int slot); int get_symbolsperslot(nfapi_nr_config_request_t *cfg); -void get_band(uint32_t downlink_frequency, uint8_t *current_band, int32_t *current_offset, lte_frame_type_t *current_type); +void get_band(uint32_t downlink_frequency, uint16_t *current_band, int32_t *current_offset, lte_frame_type_t *current_type); uint64_t from_nrarfcn(int nr_bandP, uint32_t dl_nrarfcn); diff --git a/openair2/LAYER2/NR_MAC_gNB/main.c b/openair2/LAYER2/NR_MAC_gNB/main.c index 0266e6617e..d110df18ad 100644 --- a/openair2/LAYER2/NR_MAC_gNB/main.c +++ b/openair2/LAYER2/NR_MAC_gNB/main.c @@ -40,9 +40,13 @@ //#include "RRC/L2_INTERFACE/openair_rrc_L2_interface.h" #include "common/ran_context.h" +#include "executables/nr-softmodem.h" extern RAN_CONTEXT_t RC; +void set_cset_offset(uint16_t offset_bits) { + RC.nrmac[0]->coreset[0][1].frequency_domain_resources >>= offset_bits; +} void mac_top_init_gNB(void) { @@ -54,7 +58,7 @@ void mac_top_init_gNB(void) LOG_I(MAC, "[MAIN] Init function start:nb_nr_macrlc_inst=%d\n",RC.nb_nr_macrlc_inst); if (RC.nb_nr_macrlc_inst > 0) { - + RC.nrmac = (gNB_MAC_INST **) malloc16(RC.nb_nr_macrlc_inst *sizeof(gNB_MAC_INST *)); AssertFatal(RC.nrmac != NULL,"can't ALLOCATE %zu Bytes for %d gNB_MAC_INST with size %zu \n", @@ -105,7 +109,7 @@ void mac_top_init_gNB(void) // Initialize Linked-List for Active UEs for (i = 0; i < RC.nb_nr_macrlc_inst; i++) { - + nrmac = RC.nrmac[i]; nrmac->if_inst = NR_IF_Module_init(i); diff --git a/openair2/LAYER2/NR_MAC_gNB/nr_mac_common.c b/openair2/LAYER2/NR_MAC_gNB/nr_mac_common.c index 9c1ebf2115..8082863d2e 100644 --- a/openair2/LAYER2/NR_MAC_gNB/nr_mac_common.c +++ b/openair2/LAYER2/NR_MAC_gNB/nr_mac_common.c @@ -70,35 +70,47 @@ nr_bandentry_t nr_bandtable[] = { #define NR_BANDTABLE_SIZE (sizeof(nr_bandtable)/sizeof(nr_bandentry_t)) void get_band(uint32_t downlink_frequency, - uint8_t *current_band, + uint16_t *current_band, int32_t *current_offset, lte_frame_type_t *current_type) { int ind; - int64_t dl_freq_khz = downlink_frequency/1000; + uint64_t center_frequency_khz; + uint64_t center_freq_diff_khz; + uint64_t dl_freq_khz = downlink_frequency/1000; + + center_freq_diff_khz = 999999999999999999; // 2^64 + *current_band = 0; + for ( ind=0; ind < sizeof(nr_bandtable) / sizeof(nr_bandtable[0]); ind++) { - *current_band = nr_bandtable[ind].band; - LOG_I(PHY, "Scanning band %d, dl_min %"PRIu64", ul_min %"PRIu64"\n", ind, nr_bandtable[ind].dl_min,nr_bandtable[ind].ul_min); + LOG_I(PHY, "Scanning band %d, dl_min %"PRIu64", ul_min %"PRIu64"\n", nr_bandtable[ind].band, nr_bandtable[ind].dl_min,nr_bandtable[ind].ul_min); if ( nr_bandtable[ind].dl_min <= dl_freq_khz && nr_bandtable[ind].dl_max >= dl_freq_khz ) { - *current_offset = (nr_bandtable[ind].ul_min - nr_bandtable[ind].dl_min)*1000; - if (*current_offset == 0) - *current_type = TDD; - else - *current_type = FDD; - LOG_I( PHY, "DL frequency %"PRIu32": band %d, frame_type %d, UL frequency %"PRIu32"\n", - downlink_frequency, *current_band, *current_type, downlink_frequency+*current_offset); - break; + center_frequency_khz = (nr_bandtable[ind].dl_max + nr_bandtable[ind].dl_min)/2; + + if (abs(dl_freq_khz - center_frequency_khz) < center_freq_diff_khz){ + + *current_band = nr_bandtable[ind].band; + *current_offset = (nr_bandtable[ind].ul_min - nr_bandtable[ind].dl_min)*1000; + center_freq_diff_khz = abs(dl_freq_khz - center_frequency_khz); + + if (*current_offset == 0) + *current_type = TDD; + else + *current_type = FDD; + } } } - AssertFatal(ind != (sizeof(nr_bandtable) / sizeof(nr_bandtable[0])), - "Can't find EUTRA band for frequency %d\n", downlink_frequency); + LOG_I( PHY, "DL frequency %"PRIu32": band %d, frame_type %d, UL frequency %"PRIu32"\n", + downlink_frequency, *current_band, *current_type, downlink_frequency+*current_offset); + AssertFatal(*current_band != 0, + "Can't find EUTRA band for frequency %u\n", downlink_frequency); } uint32_t to_nrarfcn(int nr_bandP, diff --git a/openair2/LAYER2/PDCP_v10.1.0/pdcp.c b/openair2/LAYER2/PDCP_v10.1.0/pdcp.c index b5a68069cc..d7cbb33c9e 100644 --- a/openair2/LAYER2/PDCP_v10.1.0/pdcp.c +++ b/openair2/LAYER2/PDCP_v10.1.0/pdcp.c @@ -358,7 +358,16 @@ boolean_t pdcp_data_req( LOG_D(PDCP, "pdcp data req on drb %d, size %d, rnti %x, node_type %d \n", rb_idP, pdcp_pdu_size, ctxt_pP->rnti, RC.rrc[ctxt_pP->module_id]->node_type); - if (ctxt_pP->enb_flag == ENB_FLAG_YES && NODE_IS_DU(RC.rrc[ctxt_pP->module_id]->node_type)) { + // The check on nos1 is done only for the use case of LTE stack running over 5g-nr PHY. This should be changed + // before future merge of develop with develop-nr and instead of a check of IS_SOFTMODEM_NOS1, we should use a check + // with a new execution option capturing the nr-ip-over-LTE-stack use case. + ngran_node_t node_type; + if (IS_SOFTMODEM_NOS1) + node_type = ngran_gNB; + else + node_type = RC.rrc[ctxt_pP->module_id]->node_type; + + if (ctxt_pP->enb_flag == ENB_FLAG_YES && NODE_IS_DU(node_type)) { //RC.rrc[ctxt_pP->module_id]->node_type LOG_E(PDCP, "Can't be DU, bad node type %d \n", RC.rrc[ctxt_pP->module_id]->node_type); ret=FALSE; } else { @@ -510,6 +519,7 @@ pdcp_data_ind( hashtable_rc_t h_rc; uint8_t rb_offset= (srb_flagP == 0) ? DTCH -1 :0; uint16_t pdcp_uid=0; + MessageDef *message_p = NULL; uint8_t *gtpu_buffer_p = NULL; uint32_t rx_hfn_for_count; @@ -518,6 +528,8 @@ pdcp_data_ind( VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_PDCP_DATA_IND,VCD_FUNCTION_IN); LOG_DUMPMSG(PDCP,DEBUG_PDCP,(char *)sdu_buffer_pP->data,sdu_buffer_sizeP, "[MSG] PDCP UL %s PDU on rb_id %d\n", (srb_flagP)? "CONTROL" : "DATA", rb_idP); + + #if T_TRACER if (ctxt_pP->enb_flag != ENB_FLAG_NO) @@ -1040,6 +1052,13 @@ pdcp_data_ind( memcpy(&new_sdu_p->data[sizeof (pdcp_data_ind_header_t)], &sdu_buffer_pP->data[payload_offset], sdu_buffer_sizeP - payload_offset); + + #if defined(ENABLE_PDCP_PAYLOAD_DEBUG) + LOG_I(PDCP, "Printing first bytes of PDCP SDU before adding it to the list: \n"); + for (int i=0; i<30; i++){ + LOG_I(PDCP, "%x", sdu_buffer_pP->data[i]); + } + #endif list_add_tail_eurecom (new_sdu_p, sdu_list_p); } @@ -1062,6 +1081,7 @@ pdcp_data_ind( Pdcp_stats_rx_tmp_w[ctxt_pP->module_id][pdcp_uid][rb_idP+rb_offset]++; Pdcp_stats_rx_bytes[ctxt_pP->module_id][pdcp_uid][rb_idP+rb_offset]+=(sdu_buffer_sizeP - payload_offset); Pdcp_stats_rx_bytes_tmp_w[ctxt_pP->module_id][pdcp_uid][rb_idP+rb_offset]+=(sdu_buffer_sizeP - payload_offset); + Pdcp_stats_rx_sn[ctxt_pP->module_id][pdcp_uid][rb_idP+rb_offset]=sequence_number; Pdcp_stats_rx_aiat[ctxt_pP->module_id][pdcp_uid][rb_idP+rb_offset]+= (pdcp_enb[ctxt_pP->module_id].sfn - Pdcp_stats_rx_iat[ctxt_pP->module_id][pdcp_uid][rb_idP+rb_offset]); Pdcp_stats_rx_aiat_tmp_w[ctxt_pP->module_id][pdcp_uid][rb_idP+rb_offset]+=(pdcp_enb[ctxt_pP->module_id].sfn - Pdcp_stats_rx_iat[ctxt_pP->module_id][pdcp_uid][rb_idP+rb_offset]); @@ -1772,6 +1792,7 @@ pdcp_config_req_asn1 ( uint8_t *const kUPenc_pP) //----------------------------------------------------------------------------- { + switch (actionP) { case CONFIG_ACTION_ADD: DevAssert(pdcp_pP != NULL); @@ -2170,6 +2191,9 @@ uint64_t pdcp_module_init( uint64_t pdcp_optmask ) { if(UE_NAS_USE_TUN) { int num_if = (NFAPI_MODE == NFAPI_UE_STUB_PNF || IS_SOFTMODEM_SIML1 )?MAX_NUMBER_NETIF:1; 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"); LOG_I(PDCP, "UE pdcp will use tun interface\n"); } else if(ENB_NAS_USE_TUN) { netlink_init_tun("enb",1); @@ -2217,6 +2241,103 @@ void pdcp_module_cleanup (void) { } +void nr_ip_over_LTE_DRB_preconfiguration(void){ + + // Addition for the use-case of 4G stack on top of 5G-NR. + // We need to configure pdcp and rlc instances without having an actual + // UE RRC Connection. In order to be able to test the NR PHY with some injected traffic + // on top of the LTE stack. + protocol_ctxt_t ctxt; + LTE_DRB_ToAddModList_t* DRB_configList=NULL; + DRB_configList = CALLOC(1, sizeof(LTE_DRB_ToAddModList_t)); + struct LTE_LogicalChannelConfig *DRB_lchan_config = NULL; + struct LTE_RLC_Config *DRB_rlc_config = NULL; + struct LTE_PDCP_Config *DRB_pdcp_config = NULL; + struct LTE_PDCP_Config__rlc_UM *PDCP_rlc_UM = NULL; + + struct LTE_DRB_ToAddMod *DRB_config = NULL; + struct LTE_LogicalChannelConfig__ul_SpecificParameters *DRB_ul_SpecificParameters = NULL; + long *logicalchannelgroup_drb; + + + //Static preconfiguration of DRB + DRB_config = CALLOC(1, sizeof(*DRB_config)); + + DRB_config->eps_BearerIdentity = CALLOC(1, sizeof(long)); + // allowed value 5..15, value : x+4 + *(DRB_config->eps_BearerIdentity) = 1; //ue_context_pP->ue_context.e_rab[i].param.e_rab_id;//+ 4; // especial case generation + // DRB_config->drb_Identity = 1 + drb_identity_index + e_rab_done;// + i ;// (DRB_Identity_t) ue_context_pP->ue_context.e_rab[i].param.e_rab_id; + // 1 + drb_identiy_index; + DRB_config->drb_Identity = 1; + DRB_config->logicalChannelIdentity = CALLOC(1, sizeof(long)); + *(DRB_config->logicalChannelIdentity) = DRB_config->drb_Identity + 2; //(long) (ue_context_pP->ue_context.e_rab[i].param.e_rab_id + 2); // value : x+2 + + DRB_rlc_config = CALLOC(1, sizeof(*DRB_rlc_config)); + DRB_config->rlc_Config = DRB_rlc_config; + + DRB_pdcp_config = CALLOC(1, sizeof(*DRB_pdcp_config)); + DRB_config->pdcp_Config = DRB_pdcp_config; + DRB_pdcp_config->discardTimer = CALLOC(1, sizeof(long)); + *DRB_pdcp_config->discardTimer = LTE_PDCP_Config__discardTimer_infinity; + DRB_pdcp_config->rlc_AM = NULL; + DRB_pdcp_config->rlc_UM = NULL; + + DRB_rlc_config->present = LTE_RLC_Config_PR_um_Bi_Directional; + DRB_rlc_config->choice.um_Bi_Directional.ul_UM_RLC.sn_FieldLength = LTE_SN_FieldLength_size10; + DRB_rlc_config->choice.um_Bi_Directional.dl_UM_RLC.sn_FieldLength = LTE_SN_FieldLength_size10; + DRB_rlc_config->choice.um_Bi_Directional.dl_UM_RLC.t_Reordering = LTE_T_Reordering_ms35; + // PDCP + PDCP_rlc_UM = CALLOC(1, sizeof(*PDCP_rlc_UM)); + DRB_pdcp_config->rlc_UM = PDCP_rlc_UM; + PDCP_rlc_UM->pdcp_SN_Size = LTE_PDCP_Config__rlc_UM__pdcp_SN_Size_len12bits; + + DRB_pdcp_config->headerCompression.present = LTE_PDCP_Config__headerCompression_PR_notUsed; + + DRB_lchan_config = CALLOC(1, sizeof(*DRB_lchan_config)); + DRB_config->logicalChannelConfig = DRB_lchan_config; + DRB_ul_SpecificParameters = CALLOC(1, sizeof(*DRB_ul_SpecificParameters)); + DRB_lchan_config->ul_SpecificParameters = DRB_ul_SpecificParameters; + + DRB_ul_SpecificParameters->priority= 4; + + DRB_ul_SpecificParameters->prioritisedBitRate = LTE_LogicalChannelConfig__ul_SpecificParameters__prioritisedBitRate_kBps8; + //LogicalChannelConfig__ul_SpecificParameters__prioritisedBitRate_infinity; + DRB_ul_SpecificParameters->bucketSizeDuration = + LTE_LogicalChannelConfig__ul_SpecificParameters__bucketSizeDuration_ms50; + + logicalchannelgroup_drb = CALLOC(1, sizeof(long)); + *logicalchannelgroup_drb = 1;//(i+1) % 3; + DRB_ul_SpecificParameters->logicalChannelGroup = logicalchannelgroup_drb; + + ASN_SEQUENCE_ADD(&DRB_configList->list,DRB_config); + + if (ENB_NAS_USE_TUN){ + PROTOCOL_CTXT_SET_BY_MODULE_ID(&ctxt, 0, ENB_FLAG_YES, 0x1234, 0, 0,0); + } + else{ + PROTOCOL_CTXT_SET_BY_MODULE_ID(&ctxt, 0, ENB_FLAG_NO, 0x1234, 0, 0,0); + } + + rrc_pdcp_config_asn1_req(&ctxt, + (LTE_SRB_ToAddModList_t *) NULL, + DRB_configList, + (LTE_DRB_ToReleaseList_t *) NULL, + 0xff, NULL, NULL, NULL + //#if (RRC_VERSION >= MAKE_VERSION(10, 0, 0)) + , (LTE_PMCH_InfoList_r9_t *) NULL + //#endif + ,NULL); + + rrc_rlc_config_asn1_req(&ctxt, + (LTE_SRB_ToAddModList_t*)NULL, + DRB_configList, + (LTE_DRB_ToReleaseList_t*)NULL + //#if (RRC_VERSION >= MAKE_VERSION(10, 0, 0)) + ,(LTE_PMCH_InfoList_r9_t *)NULL + , 0, 0 + //#endif + ); +} //----------------------------------------------------------------------------- void pdcp_layer_init(void) //----------------------------------------------------------------------------- diff --git a/openair2/LAYER2/PDCP_v10.1.0/pdcp.h b/openair2/LAYER2/PDCP_v10.1.0/pdcp.h index 8d741c1bb5..14507f2589 100644 --- a/openair2/LAYER2/PDCP_v10.1.0/pdcp.h +++ b/openair2/LAYER2/PDCP_v10.1.0/pdcp.h @@ -92,6 +92,8 @@ extern int pdcp_instance_cnt; #define PROTOCOL_PDCP_CTXT_ARGS(CTXT_Pp, pDCP_Pp) PROTOCOL_CTXT_ARGS(CTXT_Pp),\ (pDCP_Pp->is_srb) ? "SRB" : "DRB",\ pDCP_Pp->rb_id +//#define ENABLE_PDCP_PAYLOAD_DEBUG 1 + int init_pdcp_thread(void); void cleanup_pdcp_thread(void); @@ -397,6 +399,7 @@ void pdcp_run ( const protocol_ctxt_t *const ctxt_pP); uint64_t pdcp_module_init (uint64_t pdcp_optmask); void pdcp_module_cleanup (void); +void nr_ip_over_LTE_DRB_preconfiguration (void); void pdcp_layer_init (void); void pdcp_layer_cleanup (void); #define PDCP2NW_DRIVER_FIFO 21 diff --git a/openair2/LAYER2/PDCP_v10.1.0/pdcp_fifo.c b/openair2/LAYER2/PDCP_v10.1.0/pdcp_fifo.c index 3d8c42bc8c..bc3474a369 100644 --- a/openair2/LAYER2/PDCP_v10.1.0/pdcp_fifo.c +++ b/openair2/LAYER2/PDCP_v10.1.0/pdcp_fifo.c @@ -111,7 +111,7 @@ int pdcp_fifo_flush_sdus(const protocol_ctxt_t *const ctxt_pP) { int ret=0; while ((sdu_p = list_get_head (&pdcp_sdu_list)) != NULL && ((pdcp_data_ind_header_t *)(sdu_p->data))->inst == ctxt_pP->module_id) { - ((pdcp_data_ind_header_t *)(sdu_p->data))->inst = 0; + ((pdcp_data_ind_header_t *)(sdu_p->data))->inst = 0; int rb_id = ((pdcp_data_ind_header_t *)(sdu_p->data))->rb_id; int sizeToWrite= sizeof (pdcp_data_ind_header_t) + ((pdcp_data_ind_header_t *) sdu_p->data)->data_size; @@ -135,6 +135,13 @@ int pdcp_fifo_flush_sdus(const protocol_ctxt_t *const ctxt_pP) { } // PDCP_USE_NETLINK AssertFatal(ret >= 0,"[PDCP_FIFOS] pdcp_fifo_flush_sdus (errno: %d %s)\n", errno, strerror(errno)); + + #if defined(ENABLE_PDCP_PAYLOAD_DEBUG) + LOG_I(PDCP, "Printing first bytes of PDCP SDU before removing it from the list: \n"); + for (int i=0; i<30; i++){ + LOG_I(PDCP, "%x", sdu_p->data[i]); + } + #endif list_remove_head (&pdcp_sdu_list); free_mem_block (sdu_p, __func__); pdcp_nb_sdu_sent ++; @@ -166,7 +173,7 @@ int pdcp_fifo_read_input_sdus_fromtun (const protocol_ctxt_t *const ctxt_pP) { ctxt.rnti=pdcp_eNB_UE_instance_to_rnti[0]; ctxt.enb_flag=ENB_FLAG_YES; ctxt.module_id=0; - key = PDCP_COLL_KEY_VALUE(ctxt.module_id, ctxt.rnti, ctxt.enb_flag, rab_id, SRB_FLAG_YES); + key = PDCP_COLL_KEY_VALUE(ctxt.module_id, ctxt.rnti, ctxt.enb_flag, rab_id, SRB_FLAG_NO); h_rc = hashtable_get(pdcp_coll_p, key, (void **)&pdcp_p); } @@ -276,12 +283,13 @@ int pdcp_fifo_read_input_sdus_fromnetlinksock (const protocol_ctxt_t *const ctx h_rc = hashtable_get(pdcp_coll_p, key, (void **)&pdcp_p); if (h_rc == HASH_TABLE_OK) { - LOG_D(PDCP, "[FRAME %5u][eNB][NETLINK][IP->PDCP] INST %d: Received socket with length %d (nlmsg_len = %zu) on Rab %d \n", + LOG_D(PDCP, "[FRAME %5u][eNB][NETLINK][IP->PDCP] INST %d: Received socket with length %d (nlmsg_len = %zu) on Rab %d for rnti: %d \n", ctxt.frame, pdcp_read_header_g.inst, len, nas_nlh_rx->nlmsg_len-sizeof(struct nlmsghdr), - pdcp_read_header_g.rb_id); + pdcp_read_header_g.rb_id, + ctxt.rnti); MSC_LOG_RX_MESSAGE( (ctxt_pP->enb_flag == ENB_FLAG_YES) ? MSC_PDCP_ENB:MSC_PDCP_UE, (ctxt_pP->enb_flag == ENB_FLAG_YES) ? MSC_IP_ENB:MSC_IP_UE, diff --git a/openair2/LAYER2/RLC/UM_v9.3.0/rlc_um_dar.c b/openair2/LAYER2/RLC/UM_v9.3.0/rlc_um_dar.c index f37626ae4c..c8faa08358 100644 --- a/openair2/LAYER2/RLC/UM_v9.3.0/rlc_um_dar.c +++ b/openair2/LAYER2/RLC/UM_v9.3.0/rlc_um_dar.c @@ -723,7 +723,6 @@ void rlc_um_check_timer_dar_time_out( signed int in_window; rlc_usn_t old_vr_ur; - VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_RLC_UM_CHECK_TIMER_DAR_TIME_OUT,VCD_FUNCTION_IN); if ((rlc_pP->t_reordering.running)) { @@ -1130,12 +1129,12 @@ rlc_um_receive_process_dar ( if (in_window < 0) { in_window = in_window + rlc_pP->rx_sn_modulo; } - rlc_um_try_reassembly(ctxt_pP, rlc_pP, rlc_pP->vr_ur, in_window); } if (rlc_um_in_reordering_window(ctxt_pP, rlc_pP, rlc_pP->vr_ur) < 0) { + //LOG_I(RLC, "[rlc_um_receive_process_dar] Problematic case 4 \n"); #if TRACE_RLC_UM_DAR LOG_D(RLC, PROTOCOL_RLC_UM_CTXT_FMT" VR(UR) %d OUTSIDE REORDERING WINDOW SET TO VR(UH) – UM_Window_Size = %d\n", PROTOCOL_RLC_UM_CTXT_ARGS(ctxt_pP, rlc_pP), @@ -1158,9 +1157,8 @@ rlc_um_receive_process_dar ( do { rlc_pP->vr_ur = (rlc_pP->vr_ur+1) % rlc_pP->rx_sn_modulo; } while (rlc_um_get_pdu_from_dar_buffer(ctxt_pP, rlc_pP, rlc_pP->vr_ur) && (rlc_pP->vr_ur != rlc_pP->vr_uh)); - rlc_um_try_reassembly(ctxt_pP, rlc_pP, sn, rlc_pP->vr_ur); - } + } // -if t-Reordering is running: // -if VR(UX) <= VR(UR); or diff --git a/openair2/NETWORK_DRIVER/MESH/classifier.c b/openair2/NETWORK_DRIVER/MESH/classifier.c index 15ac51158c..32d60917f6 100644 --- a/openair2/NETWORK_DRIVER/MESH/classifier.c +++ b/openair2/NETWORK_DRIVER/MESH/classifier.c @@ -597,7 +597,7 @@ void nas_CLASS_send(struct sk_buff *skb,int inst) { #ifdef NAS_DEBUG_SEND printk("[NAS][CLASS][SEND] Got packet from kernel:\n"); - for (i=0; i<256; i++) + for (int i=0; i<256; i++) printk("%2x ",((unsigned char *)skb->data)[i]); printk("\n"); diff --git a/openair2/NETWORK_DRIVER/MESH/common.c b/openair2/NETWORK_DRIVER/MESH/common.c index 738f05ad99..493236cb30 100644 --- a/openair2/NETWORK_DRIVER/MESH/common.c +++ b/openair2/NETWORK_DRIVER/MESH/common.c @@ -110,13 +110,12 @@ void nas_COMMON_receive(uint16_t dlen, #ifdef NAS_ADDRESS_FIX // Make the third byte of both the source and destination equal to the fourth of the destination - unsigned char * ifaddr, *saddr, daddr; + uint32_t odaddr = 0, osaddr; daddr = (unsigned char *)&((struct iphdr *)skb->data)->daddr; odaddr = ((struct iphdr *)skb->data)->daddr; - // sn = addr[3]; + //sn = addr[3]; saddr = (unsigned char *)&((struct iphdr *)skb->data)->saddr; - uint32_t odaddr,osaddr; osaddr = ((struct iphdr *)skb->data)->saddr; if (daddr[0] == saddr[0]) {// same network @@ -387,6 +386,9 @@ void nas_COMMON_QOS_send(struct sk_buff *skb, struct cx_entity *cx, struct class pdcph.data_size = skb->len; pdcph.rb_id = (gc->rb)->rab_id; pdcph.inst = inst; + pdcph.sourceL2Id = 0; + pdcph.destinationL2Id = 0; + #ifdef PDCP_USE_NETLINK diff --git a/openair2/NETWORK_DRIVER/MESH/netlink.c b/openair2/NETWORK_DRIVER/MESH/netlink.c index 9ac44453a9..4908e00758 100644 --- a/openair2/NETWORK_DRIVER/MESH/netlink.c +++ b/openair2/NETWORK_DRIVER/MESH/netlink.c @@ -161,7 +161,7 @@ int nas_netlink_send(unsigned char *data,unsigned int len) int status; - // printk("[NAS][NETLINK] Sending %d bytes (%d)\n",len,NLMSG_SPACE(len)); + //printk("[NAS][NETLINK] Sending %d bytes (%d)\n",len,NLMSG_SPACE(len)); skb_put(nl_skb, NLMSG_SPACE(len)); memcpy(NLMSG_DATA(nlh),data,len); diff --git a/openair2/NR_UE_PHY_INTERFACE/NR_IF_Module.c b/openair2/NR_UE_PHY_INTERFACE/NR_IF_Module.c index 8feac5b029..eb7527ff44 100644 --- a/openair2/NR_UE_PHY_INTERFACE/NR_IF_Module.c +++ b/openair2/NR_UE_PHY_INTERFACE/NR_IF_Module.c @@ -35,6 +35,7 @@ #include "assertions.h" #include "LAYER2/NR_MAC_UE/mac_extern.h" #include "SCHED_NR_UE/fapi_nr_ue_l1.h" +#include "executables/nr-softmodem.h" #include @@ -70,8 +71,14 @@ int handle_dci(module_id_t module_id, int cc_id, unsigned int gNB_index, fapi_nr } // L2 Abstraction Layer -int8_t handle_dlsch (module_id_t module_id, int cc_id, uint8_t gNB_index, fapi_nr_dci_indication_t *dci_ind, uint8_t *pduP, uint32_t pdu_len){ +int8_t handle_dlsch (module_id_t module_id, int cc_id, uint8_t gNB_index, fapi_nr_dci_indication_t *dci_ind, uint8_t *pduP, uint32_t pdu_len, frame_t frame, int slot){ + LOG_I(MAC, "handle_dlsch at MAC layer \n"); + if (IS_SOFTMODEM_NOS1) + nr_ue_send_sdu(module_id, 0, frame, slot, + pduP, + pdu_len, + 0); return 0; /* return nr_ue_process_dlsch( module_id, @@ -209,7 +216,7 @@ int nr_ue_dl_indication(nr_downlink_indication_t *dl_info){ } if(dl_info->rx_ind != NULL){ - LOG_I(MAC,"[L2][IF MODULE][DL INDICATION][RX_IND]\n"); + LOG_I(MAC,"[L2][IF MODULE][DL INDICATION][RX_IND], Number of PDUs: %d \n", dl_info->rx_ind->number_pdus); for(i=0; irx_ind->number_pdus; ++i){ switch(dl_info->rx_ind->rx_indication_body[i].pdu_type){ case FAPI_NR_RX_PDU_TYPE_MIB: @@ -220,6 +227,14 @@ int nr_ue_dl_indication(nr_downlink_indication_t *dl_info){ (dl_info->rx_ind->rx_indication_body+i)->mib_pdu.ssb_index, (dl_info->rx_ind->rx_indication_body+i)->mib_pdu.ssb_length, (dl_info->rx_ind->rx_indication_body+i)->mib_pdu.cell_id )) << FAPI_NR_RX_PDU_TYPE_MIB; + LOG_I(MAC,"[L2][IF MODULE][DL INDICATION][RX_IND], MIB case Number of PDUs: %d \n", dl_info->rx_ind->number_pdus); + /*ret_mask |= (handle_bcch_bch( dl_info->proc, + dl_info->module_id, dl_info->cc_id, dl_info->gNB_index, + dl_info->rx_ind->rx_indication_body[i].mib_pdu.pdu, + dl_info->rx_ind->rx_indication_body[i].mib_pdu.additional_bits, + dl_info->rx_ind->rx_indication_body[i].mib_pdu.ssb_index, + dl_info->rx_ind->rx_indication_body[i].mib_pdu.ssb_length, + dl_info->rx_ind->rx_indication_body[i].mib_pdu.cell_id )) << FAPI_NR_RX_PDU_TYPE_MIB;*/ break; case FAPI_NR_RX_PDU_TYPE_SIB: ret_mask |= (handle_bcch_dlsch(dl_info->module_id, dl_info->cc_id, dl_info->gNB_index, @@ -231,8 +246,21 @@ int nr_ue_dl_indication(nr_downlink_indication_t *dl_info){ // ret_mask |= (0) << FAPI_NR_RX_PDU_TYPE_DLSCH; ret_mask |= (handle_dlsch(dl_info->module_id, dl_info->cc_id, dl_info->gNB_index, dl_info->dci_ind, (dl_info->rx_ind->rx_indication_body+i)->pdsch_pdu.pdu, - (dl_info->rx_ind->rx_indication_body+i)->pdsch_pdu.pdu_length)) << FAPI_NR_RX_PDU_TYPE_DLSCH; + (dl_info->rx_ind->rx_indication_body+i)->pdsch_pdu.pdu_length, dl_info->frame, dl_info->slot)) << FAPI_NR_RX_PDU_TYPE_DLSCH; + LOG_I(MAC,"[L2][IF MODULE][DL INDICATION][RX_IND], DLSCH case Number of PDUs: %d \n", dl_info->rx_ind->number_pdus); + + /* + // dl_config structure just stores what was received - not really needed + dl_config->dl_config_list[dl_config->number_pdus].pdu_type = FAPI_NR_DL_CONFIG_TYPE_DLSCH; + dl_config->number_pdus = dl_config->number_pdus + 1; + */ + + /*ret_mask |= (handle_dlsch(dl_info->module_id, dl_info->cc_id, dl_info->gNB_index, dl_info->dci_ind, + dl_info->rx_ind->rx_indication_body[i].pdsch_pdu.pdu, + dl_info->rx_ind->rx_indication_body[i].pdsch_pdu.pdu_length, dl_info->frame, dl_info->slot)) << FAPI_NR_RX_PDU_TYPE_DLSCH; + + */ break; default: diff --git a/openair2/NR_UE_PHY_INTERFACE/NR_IF_Module.h b/openair2/NR_UE_PHY_INTERFACE/NR_IF_Module.h index 3f642cac4b..5873c84d8f 100755 --- a/openair2/NR_UE_PHY_INTERFACE/NR_IF_Module.h +++ b/openair2/NR_UE_PHY_INTERFACE/NR_IF_Module.h @@ -52,6 +52,7 @@ typedef struct { int slot; fapi_nr_dl_config_request_t dl_config_req; + fapi_nr_ul_config_request_t ul_config_req; } nr_dcireq_t; typedef struct { @@ -91,6 +92,8 @@ typedef struct { uint32_t slot; /// ssb_index, if ssb is not present in current TTI, thie value set to -1 int ssb_index; + /// dci reception indication structure + fapi_nr_dci_indication_t *dci_ind; } nr_uplink_indication_t; // Downlink subframe P7 diff --git a/openair2/RRC/LTE/rrm_2_rrc_msg.c b/openair2/RRC/LTE/rrm_2_rrc_msg.c index 79cdc74e2b..84801a16be 100644 --- a/openair2/RRC/LTE/rrm_2_rrc_msg.c +++ b/openair2/RRC/LTE/rrm_2_rrc_msg.c @@ -117,7 +117,7 @@ void fn_rrc (void) { case RRCI_CX_ESTABLISH_RESP: { rrci_cx_establish_resp_t *p = (rrci_cx_establish_resp_t *) Data; - unsigned char CH_index,i; + unsigned char i, CH_index = 0; msg( "[RRCI]>[RRC][Inst %d]:RRCI_CX_ESTABLISH_RESP\n",Header->inst); for(i=0; i @@ -246,7 +246,6 @@ uint8_t do_MIB_NR(gNB_RRC_INST *rrc,uint32_t frame) { default: AssertFatal(1==0,"Unknown dmrs_TypeA_Position %d\n",(int)scc->dmrs_TypeA_Position); - } // assign_enum @@ -254,8 +253,6 @@ uint8_t do_MIB_NR(gNB_RRC_INST *rrc,uint32_t frame) { // assign_enum mib->message.choice.mib->intraFreqReselection = NR_MIB__intraFreqReselection_notAllowed; - - //encode MIB to data enc_rval = uper_encode_to_buffer(&asn_DEF_NR_BCCH_BCH_Message, NULL, @@ -265,7 +262,6 @@ uint8_t do_MIB_NR(gNB_RRC_INST *rrc,uint32_t frame) { AssertFatal (enc_rval.encoded > 0, "ASN1 message encoding failed (%s, %lu)!\n", enc_rval.failed_type->name, enc_rval.encoded); - if (enc_rval.encoded==-1) { return(-1); } @@ -276,8 +272,8 @@ uint8_t do_MIB_NR(gNB_RRC_INST *rrc,uint32_t frame) { void do_RLC_BEARER(uint8_t Mod_id, int CC_id, struct NR_CellGroupConfig__rlc_BearerToAddModList *rlc_BearerToAddModList, - rlc_bearer_config_t *rlc_config){ - + rlc_bearer_config_t *rlc_config) +{ struct NR_RLC_BearerConfig *rlc_bearer; rlc_bearer = CALLOC(1,sizeof(struct NR_RLC_BearerConfig)); @@ -372,11 +368,12 @@ void do_RLC_BEARER(uint8_t Mod_id, ASN_SEQUENCE_ADD(&(rlc_BearerToAddModList->list),&rlc_bearer); } -void do_MAC_CELLGROUP(uint8_t Mod_id, - int CC_id, - struct NR_MAC_CellGroupConfig *mac_CellGroupConfig, - mac_cellgroup_t *mac_cellgroup_config){ +void do_MAC_CELLGROUP(uint8_t Mod_id, + int CC_id, + NR_MAC_CellGroupConfig_t *mac_CellGroupConfig, + mac_cellgroup_t *mac_cellgroup_config) +{ mac_CellGroupConfig->drx_Config = CALLOC(1,sizeof(struct NR_SetupRelease_DRX_Config)); mac_CellGroupConfig->schedulingRequestConfig = CALLOC(1,sizeof(struct NR_SchedulingRequestConfig)); mac_CellGroupConfig->bsr_Config = CALLOC(1,sizeof(struct NR_BSR_Config)); @@ -486,11 +483,12 @@ void do_MAC_CELLGROUP(uint8_t Mod_id, } + void do_PHYSICALCELLGROUP(uint8_t Mod_id, int CC_id, - struct NR_PhysicalCellGroupConfig *physicalCellGroupConfig, - physicalcellgroup_t *physicalcellgroup_config){ - + NR_PhysicalCellGroupConfig_t *physicalCellGroupConfig, + physicalcellgroup_t *physicalcellgroup_config) +{ physicalCellGroupConfig->harq_ACK_SpatialBundlingPUCCH = CALLOC(1,sizeof(long)); physicalCellGroupConfig->harq_ACK_SpatialBundlingPUSCH = CALLOC(1,sizeof(long)); physicalCellGroupConfig->p_NR_FR1 = CALLOC(1,sizeof(NR_P_Max_t)); @@ -518,9 +516,9 @@ void do_PHYSICALCELLGROUP(uint8_t Mod_id, } -void do_SpCellConfig(gNB_RRC_INST *rrc, - struct NR_SpCellConfig *spconfig){ +void do_SpCellConfig(gNB_RRC_INST *rrc, + struct NR_SpCellConfig *spconfig){ gNB_RrcConfigurationReq *common_configuration; common_configuration = CALLOC(1,sizeof(gNB_RrcConfigurationReq)); //Fill servingcellconfigcommon config value diff --git a/openair2/RRC/NR/MESSAGES/asn1_msg.h b/openair2/RRC/NR/MESSAGES/asn1_msg.h index 2b16bd9828..5b102889cd 100644 --- a/openair2/RRC/NR/MESSAGES/asn1_msg.h +++ b/openair2/RRC/NR/MESSAGES/asn1_msg.h @@ -69,20 +69,20 @@ uint8_t do_SIB1_NR(rrc_gNB_carrier_data_t *carrier, int CC_id, gNB_RrcConfigurationReq *configuration); -void do_RLC_BEARER(uint8_t Mod_id, +void do_RLC_BEARER(uint8_t Mod_id, int CC_id, struct NR_CellGroupConfig__rlc_BearerToAddModList *rlc_BearerToAddModList, rlc_bearer_config_t *rlc_config); +void do_MAC_CELLGROUP(uint8_t Mod_id, + int CC_id, + NR_MAC_CellGroupConfig_t *mac_CellGroupConfig, + mac_cellgroup_t *mac_cellgroup_config); -void do_MAC_CELLGROUP(uint8_t Mod_id, - int CC_id, - struct NR_MAC_CellGroupConfig *mac_CellGroupConfig, - mac_cellgroup_t *mac_cellgroup_config); +void do_PHYSICALCELLGROUP(uint8_t Mod_id, + int CC_id, + NR_PhysicalCellGroupConfig_t *physicalCellGroupConfig, + physicalcellgroup_t *physicalcellgroup_config); -void do_PHYSICALCELLGROUP(uint8_t Mod_id, - int CC_id, - struct NR_PhysicalCellGroupConfig *physicalCellGroupConfig, - physicalcellgroup_t *physicalcellgroup_config); -void do_SpCellConfig(gNB_RRC_INST *rrc, +void do_SpCellConfig(gNB_RRC_INST *rrc, struct NR_SpCellConfig *spconfig); diff --git a/openair2/UTIL/OPT/opt.h b/openair2/UTIL/OPT/opt.h index 912d846723..38a834b73e 100644 --- a/openair2/UTIL/OPT/opt.h +++ b/openair2/UTIL/OPT/opt.h @@ -74,8 +74,8 @@ typedef guint8 gboolean; /*---------------------------------------------------------------------------------------------------------------------------------------------*/ #define OPT_PARAMS_DESC { \ {"type" , CONFIG_HLP_TYPEMON, 0, strptr:&in_type, defstrval:"none", TYPE_STRING, 0}, \ - {"ip" , CONFIG_HLP_L2MONIP, 0, strptr:&in_ip, defstrval:"127.0.0.1", TYPE_STRING, 0}, \ - {"path" , CONFIG_HLP_L2MONPATH, 0, strptr:&in_path, defstrval:"/tmp/oai_opt.pcap", TYPE_STRING, 0}, \ + {"ip" , CONFIG_HLP_L2MONIP, 0, strptr:(char**)&in_ip, defstrval:"127.0.0.1", TYPE_STRING, 0}, \ + {"path" , CONFIG_HLP_L2MONPATH, 0, strptr:(char**)&in_path,defstrval:"/tmp/oai_opt.pcap", TYPE_STRING, 0}, \ } #define OPTTYPE_IDX 0 diff --git a/openair2/UTIL/OTG/otg_tx.c b/openair2/UTIL/OTG/otg_tx.c index 02ee8ba391..a8ba83bc40 100644 --- a/openair2/UTIL/OTG/otg_tx.c +++ b/openair2/UTIL/OTG/otg_tx.c @@ -224,9 +224,9 @@ int size_dist( return size_data; } + int adjust_size(int size) { - if (sizeapplication_type[src_instance][dst][app]*/, - flag, 0, ctime, + flag, + 0, + ctime, seq_num, 0, HDR_IP_v4_MIN+HDR_UDP, diff --git a/openair3/SCTP/sctp_common.h b/openair3/SCTP/sctp_common.h index 265a13bec0..ecaeebd090 100644 --- a/openair3/SCTP/sctp_common.h +++ b/openair3/SCTP/sctp_common.h @@ -37,8 +37,8 @@ #if defined(ENB_MODE) # include "common/utils/LOG/log.h" # define SCTP_ERROR(x, args...) LOG_E(SCTP, x, ##args) -# define SCTP_WARN(x, args...) LOG_W(SCTP, x, ##args) # define SCTP_DEBUG(x, args...) LOG_I(SCTP, x, ##args) +# define SCTP_WARN(x, args...) LOG_W(SCTP, x, ##args) #else # define SCTP_ERROR(x, args...) do { fprintf(stderr, "[SCTP][E]"x, ##args); } while(0) # define SCTP_DEBUG(x, args...) do { fprintf(stdout, "[SCTP][D]"x, ##args); } while(0) diff --git a/openair3/SCTP/sctp_eNB_task.c b/openair3/SCTP/sctp_eNB_task.c index cec8802f25..972bef0a07 100644 --- a/openair3/SCTP/sctp_eNB_task.c +++ b/openair3/SCTP/sctp_eNB_task.c @@ -717,8 +717,7 @@ static int sctp_create_new_listener( SCTP_DEBUG("ipv4 addresses:\n"); for (i = 0; i < init_p->nb_ipv4_addr; i++) { - SCTP_DEBUG("\t- "IPV4_ADDR"\n", - IPV4_ADDR_FORMAT(init_p->ipv4_address[i])); + SCTP_DEBUG("\t- "IPV4_ADDR"\n", IPV4_ADDR_FORMAT(init_p->ipv4_address[i])); ip4_addr = (struct sockaddr_in *)&addr[i]; ip4_addr->sin_family = AF_INET; ip4_addr->sin_port = htons(init_p->port); diff --git a/targets/ARCH/COMMON/common_lib.h b/targets/ARCH/COMMON/common_lib.h index 603ee67ed3..9192020b40 100644 --- a/targets/ARCH/COMMON/common_lib.h +++ b/targets/ARCH/COMMON/common_lib.h @@ -41,9 +41,9 @@ /* name of shared library implementing the transport */ #define OAI_TP_LIBNAME "oai_transpro" /* name of shared library implementing the basic/rf simulator */ -#define OAI_RFSIM_LIBNAME "rfsimulator" +#define OAI_RFSIM_LIBNAME "rfsimulator" /* name of shared library implementing the basic/rf simulator */ -#define OAI_BASICSIM_LIBNAME "tcp_bridge_oai" +#define OAI_BASICSIM_LIBNAME "tcp_bridge_oai" /* flags for BBU to determine whether the attached radio head is local or remote */ #define RAU_LOCAL_RADIO_HEAD 0 #define RAU_REMOTE_RADIO_HEAD 1 @@ -420,7 +420,6 @@ typedef int(*oai_transport_initfunc_t)(openair0_device *device, openair0_config_ #define OPTION_LZ4 0x00000001 // LZ4 compression (option_value is set to compressed size) -#define sample_t struct complex16 // 2*16 bits complex number typedef struct { uint64_t magic; // Magic value (see defines above) @@ -446,8 +445,6 @@ typedef struct { #define OPTION_LZ4 0x00000001 // LZ4 compression (option_value is set to compressed size) -#define sample_t struct complex16 // 2*16 bits complex number - #ifdef __cplusplus extern "C" { diff --git a/targets/ARCH/ETHERNET/USERSPACE/LIB/ethernet_lib.h b/targets/ARCH/ETHERNET/USERSPACE/LIB/ethernet_lib.h index 8eb0e1651f..65b2def60d 100644 --- a/targets/ARCH/ETHERNET/USERSPACE/LIB/ethernet_lib.h +++ b/targets/ARCH/ETHERNET/USERSPACE/LIB/ethernet_lib.h @@ -42,11 +42,11 @@ #include #include -#define MAX_INST 4 -#define DEFAULT_IF "lo" +#define MAX_INST 4 +#define DEFAULT_IF "lo" -#define TX_FLAG 1 -#define RX_FLAG 0 +#define TX_FLAG 1 +#define RX_FLAG 0 #include "if_defs.h" #define APP_HEADER_SIZE_BYTES (sizeof(int32_t) + sizeof(openair0_timestamp)) diff --git a/targets/ARCH/USRP/USERSPACE/LIB/usrp_lib.cpp b/targets/ARCH/USRP/USERSPACE/LIB/usrp_lib.cpp index a608bbcc75..e0e10fd899 100644 --- a/targets/ARCH/USRP/USERSPACE/LIB/usrp_lib.cpp +++ b/targets/ARCH/USRP/USERSPACE/LIB/usrp_lib.cpp @@ -512,6 +512,7 @@ static int trx_usrp_write(openair0_device *device, openair0_timestamp timestamp, first_packet_state = false; last_packet_state = true; } + s->tx_md.has_time_spec = true; s->tx_md.start_of_burst = (s->tx_count==0) ? true : first_packet_state; s->tx_md.end_of_burst = last_packet_state; @@ -613,7 +614,7 @@ static int trx_usrp_read(openair0_device *device, openair0_timestamp *ptimestamp ((__m256i *)buff[i])[j] = _mm256_srai_epi16(buff_tmp[i][j],4); } else { - ((__m128i *)buff[i])[2*j] = _mm_srai_epi16(((__m128i*)buff_tmp[i])[j],4); + ((__m128i *)buff[i])[2*j] = _mm_srai_epi16(((__m128i*)buff_tmp[i])[2*j],4); ((__m128i *)buff[i])[2*j+1] = _mm_srai_epi16(((__m128i*)buff_tmp[i])[2*j+1],4); } #else diff --git a/targets/ARCH/rfsimulator/README.md b/targets/ARCH/rfsimulator/README.md index 510a54adb4..e3ce219d73 100644 --- a/targets/ARCH/rfsimulator/README.md +++ b/targets/ARCH/rfsimulator/README.md @@ -1,63 +1,81 @@ -#General -This is an RF simulator that allows to test OAI without an RF board. +# General +This is an RF simulator that allows to test OAI without an RF board. It replaces an actual RF board driver. -It replaces an actual RF board driver. +As much as possible, it works like an RF board, but not in real-time: It can run faster than real-time if there is enough CPU, or slower (it is CPU-bound instead of real-time RF sampling-bound). -As much as possible, it works like an RF board, but not in realtime: It can run faster than realtime if there is enough CPU or slower (it is CPU bound instead of real time RF sampling bound) +# build -#build +## From [build_oai](../../../doc/BUILD.md) script +The RF simulator is implemented as an OAI device and always built when you build the OAI eNB or the OAI UE. -## From build_oai -You can build it the same way, and together with actual RF driver +Using the `-w SIMU` option it is possible to just re-build the RF simulator device. Example: ```bash -./build_oai --ue-nas-use-tun --UE --eNB -w SIMU +./build_oai --UE --eNB +Will compile UE +Will compile eNB +CMAKE_CMD=cmake .. +No local radio head and no transport protocol selected +No radio head has been selected (HW set to None) +No transport protocol has been selected (TP set to None) +RF HW set to None +Flags for Deadline scheduler: False +...................... +...................... +Compiling rfsimulator +Log file for compilation has been written to: /usr/local/oai/rfsimu_config/openairinterface5g/cmake_targets/log/rfsimulator.Rel15.txt +rfsimulator compiled +...................... +...................... ``` -It is also possible to build actual RF and use choose on each run: -```bash -./build_oai --ue-nas-use-tun --UE --eNB -w USRP --rfsimulator -``` -Will build both the eNB (lte-softmodem) and the UE (lte-uesoftmodem) -We recommend using the option --ue-nas-use-tun that is much simpler to use than the OAI kernel driver. ## Add the rfsimulator after initial build -After any regular build, you can compile the driver - +After any regular build you can compile the device from the build directory: ```bash -cd /build +cd /openairinterface5g/cmake_targets/ran_build/build make rfsimulator ``` -Then, you can use it freely +This is equivalent to using `-w SIMU` when running the `build_oai` script. # Usage -Setting the env variable RFSIMULATOR enables the RF board simulator. It should be set to "server" in the eNB or gNB. +To use the RF simulator add the `--rfsim` option to the command line. By default the RF simulator device will try to connect to host 127.0.0.1, port 4043, which is usually the behavior for the UE. + +The RF simulator is using the configuration module, and its parameters are defined in a specific section called "rfsimulator". + +| parameter | usage | default | +|:---------------------|:------------------------------------------------------------------------------------------------------------------|----:| +| serveraddr | ip address to connect to, or "enb" to behave as a tcp server | 127.0.0.1 | +| serverport | port number to connect to or to listen on (eNB, which behaves as a tcp server) | 4043 | +| options | list of comma separated run-time options, two are supported: `chanmod` to enable channel modeling and `saviq` to write transmitted iqs to a file | all options disabled | +| modelname | Name of the channel model to apply on received iqs when the `chanmod` option is enabled | AWGN | +| IQfile | Path to the file to be used to store iqs, when the `saviq` option is enabled | /tmp/rfsimulator.iqs | + +Setting the env variable RFSIMULATOR can be used instead of using the serveraddr parameter; it is to preserve compatibility with previous version. ## 4G case -For the UE, it should be set to the IP address of the eNB -example: +For the UE, it should be set to the IP address of the eNB. For example: ```bash sudo RFSIMULATOR=192.168.2.200 ./lte-uesoftmodem -C 2685000000 -r 50 ``` -For the eNodeB, use a valid configuration file setup for USRP board tests and start the softmodem as usual, **but** adding the `--rfsim` option. - +For the eNB, use a valid configuration file setup for the USRP board tests and start the softmodem as usual, **but**, adding the `--rfsim` option. ```bash sudo RFSIMULATOR=enb ./lte-softmodem -O --rfsim ``` -Except this, the UE and the eNB can be used as if the RF is real - -If you reach 'RA not active' on UE, be careful to generate a valid SIM +Except this, the UE and the eNB can be used as if the RF is real. noS1 mode can also be used with the RF simulator. +If you reach 'RA not active' on UE, be careful to generate a valid SIM. ```bash $OPENAIR_DIR/targets/bin/conf2uedata -c $OPENAIR_DIR/openair3/NAS/TOOLS/ue_eurecom_test_sfr.conf -o . ``` ## 5G case -After regular build, add the simulation driver -(don't use ./build_oai -w SIMU until we merge 4G and 5G branches) +The 5G RF simulator will be aligned with the 4G as the efforts for merging the 5G specific branches into the develop make progresses. + +After regular build, add the simulation driver (do not use ./build_oai -w SIMU until 4G and 5G branches are merged). ```bash cd ran_build/build make rfsimulator @@ -77,46 +95,40 @@ sudo RFSIMULATOR=127.0.0.1 ./nr-uesoftmodem --numerology 1 -r 106 -C 3510000000 Of course, set the gNB machine IP address if the UE and the gNB are not on the same machine. -In UE, you can add "-d" to get the softscope +In the UE, you can add `-d` option to get the softscope. ### Store and replay -You can store emitted I/Q samples: +You can store emitted I/Q samples. If you set the option `saviq`, the simulator will write all the I/Q samples into this file. Then, you can replay with the executable `replay_node`. -If you set the environment variable: saveIQfile to a file name -The simulator will write all IQ samples into this file - -Then, you can replay with the executable "replay_node" - -First compile it, as the other binaries -``` +First compile it like other binaries: +```bash make replay_node ``` -You can use this binary as I/Q data source to feed whatever UE or NB with recorded I/Q samples. +You can use this binary as I/Q data source to feed whatever UE or gNB with recorded I/Q samples. -The file format is successive blocks of a header followed by the I/Q array. -If you have existing stored I/Q, you can adpat the tool "replay_node" to convert your format to the rfsimulator format. +The file format is successive blocks of a header followed by the I/Q array. If you have existing stored I/Q, you can adapt the tool `replay_node` to convert your format to the rfsimulator format. -The format intend to be compatible with the OAI store/replay feature on USRP +The format intends to be compatible with the OAI store/replay feature on USRP. ### Channel simulation -The RF channel simulator is called. -In current version all channel paramters are hard coded in the call to: +When the `chanmod` option is enabled, the RF channel simulator is called. + +In the current version all channel parameters are set depending on the model name via a call to: ```bash new_channel_desc_scm(bridge->tx_num_channels, bridge->rx_num_channels, - AWGN, + , bridge->sample_rate, bridge->tx_bw, 0.0, // forgetting_factor - 0, // maybe used for TA - 0); // path_loss in dB + 0, // maybe used for TA + 0); // path_loss in dB ``` +Only the input noise can be changed on command line with the `-s` parameter. -Only the input noise can be changed on command line with -s parameter. +With path loss = 0 set `-s 5` to see a little noise. `-s` is a shortcut to `channelmod.s`. It is expected to enhance the channel modelization flexibility by the addition of more parameters in the channelmod section. -With path loss = 0 set "-s 5" to see a little noise. - -## Caveats -Still issues in power control: txgain, rxgain are not used +# Caveats +Still issues in power control: txgain, rxgain are not used. diff --git a/targets/ARCH/rfsimulator/apply_channelmod.c b/targets/ARCH/rfsimulator/apply_channelmod.c new file mode 100644 index 0000000000..ef4e564343 --- /dev/null +++ b/targets/ARCH/rfsimulator/apply_channelmod.c @@ -0,0 +1,97 @@ +/* + Author: Laurent THOMAS, Open Cells for Nokia + copyleft: OpenAirInterface Software Alliance and it's licence + +*/ + + +#include +#include +#include +#include +#include +#include + + +#include +#include +#include +#include + +/* + Legacy study: + The parameters are: + gain&loss (decay, signal power, ...) + either a fixed gain in dB, a target power in dBm or ACG (automatic control gain) to a target average + => don't redo the AGC, as it was used in UE case, that must have a AGC inside the UE + will be better to handle the "set_gain()" called by UE to apply it's gain (enable test of UE power loop) + lin_amp = pow(10.0,.05*txpwr_dBm)/sqrt(nb_tx_antennas); + a lot of operations in legacy, grouped in one simulation signal decay: txgain*decay*rxgain + + multi_path (auto convolution, ISI, ...) + either we regenerate the channel (call again random_channel(desc,0)), or we keep it over subframes + legacy: we regenerate each sub frame in UL, and each frame only in DL +*/ +void rxAddInput( struct complex16 *input_sig, struct complex16 *after_channel_sig, + int rxAnt, + channel_desc_t *channelDesc, + int nbSamples, + uint64_t TS, + uint32_t CirSize + ) { + // channelDesc->path_loss_dB should contain the total path gain + // so, in actual RF: tx gain + path loss + rx gain (+antenna gain, ...) + // UE and NB gain control to be added + // Fixme: not sure when it is "volts" so dB is 20*log10(...) or "power", so dB is 10*log10(...) + const double pathLossLinear = pow(10,channelDesc->path_loss_dB/20.0); + // Energy in one sample to calibrate input noise + //Fixme: modified the N0W computation, not understand the origin value + const double KT=1.38e-23*290; //Boltzman*temperature + // sampling rate is linked to acquisition band (the input pass band filter) + const double noise_figure_watt = KT*channelDesc->sampling_rate; + // Fixme: how to convert a noise in Watt into a 12 bits value out of the RF ADC ? + // the parameter "-s" is declared as SNR, but the input power is not well defined + // −132.24 dBm is a LTE subcarrier noise, that was used in origin code (15KHz BW thermal noise) + const double rxGain= 132.24 - channelmod_get_snr_dB(); + // sqrt(4*noise_figure_watt) is the thermal noise factor (volts) + // fixme: the last constant is pure trial results to make decent noise + const double noise_per_sample = sqrt(4*noise_figure_watt) * pow(10,rxGain/20) *10; + // Fixme: we don't fill the offset length samples at begining ? + // anyway, in today code, channel_offset=0 + const int dd = abs(channelDesc->channel_offset); + const int nbTx=channelDesc->nb_tx; + + for (int i=0; i<((int)nbSamples-dd); i++) { + struct complex16 *out_ptr=after_channel_sig+dd+i; + struct complex rx_tmp= {0}; + + for (int txAnt=0; txAnt < nbTx; txAnt++) { + const struct complex *channelModel= channelDesc->ch[rxAnt+(txAnt*channelDesc->nb_rx)]; + + //const struct complex *channelModelEnd=channelModel+channelDesc->channel_length; + for (int l = 0; l<(int)channelDesc->channel_length; l++) { + // let's assume TS+i >= l + // fixme: the rfsimulator current structure is interleaved antennas + // this has been designed to not have to wait a full block transmission + // but it is not very usefull + // it would be better to split out each antenna in a separate flow + // that will allow to mix ru antennas freely + struct complex16 tx16=input_sig[((TS+i-l)*nbTx+txAnt)%CirSize]; + rx_tmp.x += tx16.r * channelModel[l].x - tx16.i * channelModel[l].y; + rx_tmp.y += tx16.i * channelModel[l].x + tx16.r * channelModel[l].y; + } //l + } + + out_ptr->r += round(rx_tmp.x*pathLossLinear + noise_per_sample*gaussdouble(0.0,1.0)); + out_ptr->i += round(rx_tmp.y*pathLossLinear + noise_per_sample*gaussdouble(0.0,1.0)); + out_ptr++; + } + + if ( (TS*nbTx)%CirSize+nbSamples <= CirSize ) + // Cast to a wrong type for compatibility ! + LOG_D(HW,"Input power %f, output power: %f, channel path loss %f, noise coeff: %f \n", + 10*log10((double)signal_energy((int32_t *)&input_sig[(TS*nbTx)%CirSize], nbSamples)), + 10*log10((double)signal_energy((int32_t *)after_channel_sig, nbSamples)), + channelDesc->path_loss_dB, + 10*log10(noise_per_sample)); +} diff --git a/targets/ARCH/rfsimulator/simulator.c b/targets/ARCH/rfsimulator/simulator.c index 1acaa69050..86d64a16b0 100644 --- a/targets/ARCH/rfsimulator/simulator.c +++ b/targets/ARCH/rfsimulator/simulator.c @@ -24,12 +24,15 @@ #include #include +#include +#include #include "common_lib.h" #include #include "openair1/PHY/defs_UE.h" +#define CHANNELMOD_DYNAMICLOAD #include -#define PORT 4043 //TCP port for this simulator +#define PORT 4043 //default TCP port for this simulator #define CirSize 3072000 // 100ms is enough #define sampleToByte(a,b) ((a)*(b)*sizeof(sample_t)) #define byteToSample(a,b) ((a)/(sizeof(sample_t)*(b))) @@ -39,12 +42,31 @@ // Fixme: datamodel, external variables in .h files, ... #include -extern double snr_dB; + extern RAN_CONTEXT_t RC; // +#define RFSIMU_SECTION "rfsimulator" +#define RFSIMU_OPTIONS_PARAMNAME "options" +# define RFSIM_CONFIG_HELP_OPTIONS " list of comma separated options to enable rf simulator functionalities. Available options: \n"\ + " chanmod: enable channel modelisation\n"\ + " saviq: enable saving written iqs to a file\n" +/*-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------*/ +/* configuration parameters for the rfsimulator device */ +/* optname helpstr paramflags XXXptr defXXXval type numelt */ +/*-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------*/ +#define RFSIMULATOR_PARAMS_DESC {\ + {"serveraddr", "\n", 0, strptr:&(rfsimulator->ip), defstrval:"127.0.0.1", TYPE_STRING, 0 },\ + {"serverport", "\n", 0, u16ptr:&(rfsimulator->port), defuintval:PORT, TYPE_UINT16, 0 },\ + {RFSIMU_OPTIONS_PARAMNAME, RFSIM_CONFIG_HELP_OPTIONS, 0, strlistptr:NULL, defstrlistval:NULL, TYPE_STRINGLIST,0},\ + {"IQfile", "\n", 0, strptr:&(saveF), defstrval:"/tmp/rfsimulator.iqs",TYPE_STRING, 0 },\ + {"modelname", "\n", 0, strptr:&(modelname), defstrval:"AWGN", TYPE_STRING, 0 }\ + }; + pthread_mutex_t Sockmutex; +typedef struct complex16 sample_t; // 2*16 bits complex number + typedef struct buffer_s { int conn_sock; openair0_timestamp lastReceivedTS; @@ -63,91 +85,16 @@ typedef struct { openair0_timestamp nextTimestamp; uint64_t typeStamp; char *ip; + uint16_t port; int saveIQfile; buffer_t buf[FD_SETSIZE]; int rx_num_channels; int tx_num_channels; double sample_rate; double tx_bw; + int channelmod; } rfsimulator_state_t; -/* - Legacy study: - The parameters are: - gain&loss (decay, signal power, ...) - either a fixed gain in dB, a target power in dBm or ACG (automatic control gain) to a target average - => don't redo the AGC, as it was used in UE case, that must have a AGC inside the UE - will be better to handle the "set_gain()" called by UE to apply it's gain (enable test of UE power loop) - lin_amp = pow(10.0,.05*txpwr_dBm)/sqrt(nb_tx_antennas); - a lot of operations in legacy, grouped in one simulation signal decay: txgain*decay*rxgain - - multi_path (auto convolution, ISI, ...) - either we regenerate the channel (call again random_channel(desc,0)), or we keep it over subframes - legacy: we regenerate each sub frame in UL, and each frame only in DL -*/ -void rxAddInput( struct complex16 *input_sig, - struct complex16 *after_channel_sig, - int rxAnt, - channel_desc_t *channelDesc, - int nbSamples, - uint64_t TS - ) { - // channelDesc->path_loss_dB should contain the total path gain - // so, in actual RF: tx gain + path loss + rx gain (+antenna gain, ...) - // UE and NB gain control to be added - // Fixme: not sure when it is "volts" so dB is 20*log10(...) or "power", so dB is 10*log10(...) - const double pathLossLinear = pow(10,channelDesc->path_loss_dB/20.0); - // Energy in one sample to calibrate input noise - //Fixme: modified the N0W computation, not understand the origin value - const double KT = 1.38e-23*290; //Boltzman*temperature - // sampling rate is linked to acquisition band (the input pass band filter) - const double noise_figure_watt = KT*channelDesc->sampling_rate; - // Fixme: how to convert a noise in Watt into a 12 bits value out of the RF ADC ? - // the parameter "-s" is declared as SNR, but the input power is not well defined - // −132.24 dBm is a LTE subcarrier noise, that was used in origin code (15KHz BW thermal noise) - const double rxGain = 132.24 - snr_dB; - // sqrt(4*noise_figure_watt) is the thermal noise factor (volts) - // fixme: the last constant is pure trial results to make decent noise - const double noise_per_sample = sqrt(4*noise_figure_watt) * pow(10,rxGain/20) *10; - // Fixme: we don't fill the offset length samples at begining ? - // anyway, in today code, channel_offset=0 - const int dd = abs(channelDesc->channel_offset); - const int nbTx = channelDesc->nb_tx; - - for (int i=0; i<((int)nbSamples-dd); i++) { - struct complex16 *out_ptr=after_channel_sig+dd+i; - struct complex rx_tmp= {0}; - - for (int txAnt=0; txAnt < nbTx; txAnt++) { - const struct complex *channelModel= channelDesc->ch[rxAnt+(txAnt*channelDesc->nb_rx)]; - - //const struct complex *channelModelEnd=channelModel+channelDesc->channel_length; - for (int l = 0; l<(int)channelDesc->channel_length; l++) { - // let's assume TS+i >= l - // fixme: the rfsimulator current structure is interleaved antennas - // this has been designed to not have to wait a full block transmission - // but it is not very usefull - // it would be better to split out each antenna in a separate flow - // that will allow to mix ru antennas freely - struct complex16 tx16=input_sig[((TS+i-l)*nbTx+txAnt)%CirSize]; - rx_tmp.x += tx16.r * channelModel[l].x - tx16.i * channelModel[l].y; - rx_tmp.y += tx16.i * channelModel[l].x + tx16.r * channelModel[l].y; - } //l - } - - out_ptr->r += round(rx_tmp.x*pathLossLinear + noise_per_sample*gaussdouble(0.0,1.0)); - out_ptr->i += round(rx_tmp.y*pathLossLinear + noise_per_sample*gaussdouble(0.0,1.0)); - out_ptr++; - } - - if ( (TS*nbTx)%CirSize+nbSamples <= CirSize ) - // Cast to a wrong type for compatibility ! - LOG_D(HW,"Input power %f, output power: %f, channel path loss %f, noise coeff: %f \n", - 10*log10((double)signal_energy((int32_t *)&input_sig[(TS*nbTx)%CirSize], nbSamples)), - 10*log10((double)signal_energy((int32_t *)after_channel_sig, nbSamples)), - channelDesc->path_loss_dB, - 10*log10(noise_per_sample)); -} void allocCirBuf(rfsimulator_state_t *bridge, int sock) { buffer_t *ptr=&bridge->buf[sock]; @@ -165,26 +112,29 @@ void allocCirBuf(rfsimulator_state_t *bridge, int sock) { ev.events = EPOLLIN | EPOLLRDHUP; ev.data.fd = sock; AssertFatal(epoll_ctl(bridge->epollfd, EPOLL_CTL_ADD, sock, &ev) != -1, ""); - // create channel simulation model for this mode reception - // snr_dB is pure global, coming from configuration paramter "-s" - // Fixme: referenceSignalPower should come from the right place - // but the datamodel is inconsistant - // legacy: RC.ru[ru_id]->frame_parms.pdsch_config_common.referenceSignalPower - // (must not come from ru[]->frame_parms as it doesn't belong to ru !!!) - // Legacy sets it as: - // ptr->channel_model->path_loss_dB = -132.24 + snr_dB - RC.ru[0]->frame_parms->pdsch_config_common.referenceSignalPower; - // we use directly the paramter passed on the command line ("-s") - // the value channel_model->path_loss_dB seems only a storage place (new_channel_desc_scm() only copy the passed value) - // Legacy changes directlty the variable channel_model->path_loss_dB place to place - // while calling new_channel_desc_scm() with path losses = 0 - ptr->channel_model=new_channel_desc_scm(bridge->tx_num_channels,bridge->rx_num_channels, - AWGN, - bridge->sample_rate, - bridge->tx_bw, - 0.0, // forgetting_factor - 0, // maybe used for TA - 0); // path_loss in dB - random_channel(ptr->channel_model,false); + + if ( bridge->channelmod > 0) { + // create channel simulation model for this mode reception + // snr_dB is pure global, coming from configuration paramter "-s" + // Fixme: referenceSignalPower should come from the right place + // but the datamodel is inconsistant + // legacy: RC.ru[ru_id]->frame_parms.pdsch_config_common.referenceSignalPower + // (must not come from ru[]->frame_parms as it doesn't belong to ru !!!) + // Legacy sets it as: + // ptr->channel_model->path_loss_dB = -132.24 + snr_dB - RC.ru[0]->frame_parms->pdsch_config_common.referenceSignalPower; + // we use directly the paramter passed on the command line ("-s") + // the value channel_model->path_loss_dB seems only a storage place (new_channel_desc_scm() only copy the passed value) + // Legacy changes directlty the variable channel_model->path_loss_dB place to place + // while calling new_channel_desc_scm() with path losses = 0 + ptr->channel_model=new_channel_desc_scm(bridge->tx_num_channels,bridge->rx_num_channels, + bridge->channelmod, + bridge->sample_rate, + bridge->tx_bw, + 0.0, // forgetting_factor + 0, // maybe used for TA + 0); // path_loss in dB + random_channel(ptr->channel_model,false); + } } void removeCirBuf(rfsimulator_state_t *bridge, int sock) { @@ -213,6 +163,7 @@ void socketError(rfsimulator_state_t *bridge, int sock) { rfsimulator: error: you have to run one UE and one eNB\n\ For this, export RFSIMULATOR=enb (eNB case) or \n\ RFSIMULATOR= (UE case)\n\ + or use rfsimulator.serveraddr configuration option\n\ \x1b[m" enum blocking_t { @@ -267,6 +218,48 @@ void fullwrite(int fd, void *_buf, ssize_t count, rfsimulator_state_t *t) { } } + + +void rfsimulator_readconfig(rfsimulator_state_t *rfsimulator) { + char *saveF=NULL; + char *modelname=NULL; + paramdef_t rfsimu_params[] = RFSIMULATOR_PARAMS_DESC; + int p = config_paramidx_fromname(rfsimu_params,sizeof(rfsimu_params)/sizeof(paramdef_t), RFSIMU_OPTIONS_PARAMNAME) ; + int ret = config_get( rfsimu_params,sizeof(rfsimu_params)/sizeof(paramdef_t),RFSIMU_SECTION); + AssertFatal(ret >= 0, "configuration couldn't be performed"); + rfsimulator->saveIQfile = -1; + + for(int i=0; isaveIQfile=open(saveF,O_APPEND| O_CREAT|O_TRUNC | O_WRONLY, 0666); + + if ( rfsimulator->saveIQfile != -1 ) + LOG_I(HW,"rfsimulator: will save written IQ samples in %s\n", saveF); + else + LOG_E(HW, "can't open %s for IQ saving (%s)\n", saveF, strerror(errno)); + + break; + } else if (strcmp(rfsimu_params[p].strlistptr[i],"chanmod") == 0) { + init_channelmod(); + rfsimulator->channelmod=modelid_fromname(modelname); + } else { + fprintf(stderr,"Unknown rfsimulator option: %s\n",rfsimu_params[p].strlistptr[i]); + exit(-1); + } + } + + /* for compatibility keep environment variable usage */ + if ( getenv("RFSIMULATOR") != NULL ) { + rfsimulator->ip=getenv("RFSIMULATOR"); + } + + if ( strncasecmp(rfsimulator->ip,"enb",3) == 0 || + strncasecmp(rfsimulator->ip,"server",3) == 0 ) + rfsimulator->typeStamp = ENB_MAGICDL_FDD; + else + rfsimulator->typeStamp = UE_MAGICDL_FDD; +} + int server_start(openair0_device *device) { rfsimulator_state_t *t = (rfsimulator_state_t *) device->priv; t->typeStamp=ENB_MAGICDL_FDD; @@ -277,7 +270,7 @@ int server_start(openair0_device *device) { sin_family: AF_INET, sin_port: - htons(PORT), + htons(t->port), sin_addr: { s_addr: INADDR_ANY } }; @@ -299,7 +292,7 @@ int start_ue(openair0_device *device) { sin_family: AF_INET, sin_port: - htons(PORT), + htons(t->port), sin_addr: { s_addr: INADDR_ANY } }; @@ -307,7 +300,7 @@ sin_addr: bool connected=false; while(!connected) { - LOG_I(HW,"rfsimulator: trying to connect to %s:%d\n", t->ip, PORT); + LOG_I(HW,"rfsimulator: trying to connect to %s:%d\n", t->ip, t->port); if (connect(sock, (struct sockaddr *)&addr, sizeof(addr)) == 0) { LOG_I(HW,"rfsimulator: connection established\n"); @@ -327,15 +320,15 @@ int rfsimulator_write(openair0_device *device, openair0_timestamp timestamp, voi rfsimulator_state_t *t = device->priv; LOG_D(HW,"sending %d samples at time: %ld\n", nsamps, timestamp); - for (int i=0; ibuf[i]; if (b->conn_sock >= 0 ) { - if ( abs((double)b->lastWroteTS-timestamp) > (double)CirSize) + if ( abs((double)b->lastWroteTS-timestamp) > (double)CirSize ) LOG_E(HW,"Tx/Rx shift too large Tx:%lu, Rx:%lu\n", b->lastWroteTS, b->lastReceivedTS); + samplesBlockHeader_t header= {t->typeStamp, nsamps, nbAnt, timestamp}; - fullwrite(b->conn_sock,&header, sizeof(header), t); + fullwrite(b->conn_sock, &header, sizeof(header), t); sample_t tmpSamples[nsamps][nbAnt]; for(int a=0; anextTimestamp == 0) + LOG_W(HW,"No connected device, generating void samples...\n"); + if (!flushInput(t, 10)) { for (int x=0; x < nbAnt; x++) memset(samplesVoid[x],0,sampleToByte(nsamps,1)); t->nextTimestamp+=nsamps; - LOG_W(HW,"Generated void samples for Rx: %ld\n", t->nextTimestamp); + LOG_D(HW,"Generated void samples for Rx: %ld\n", t->nextTimestamp); *ptimestamp = t->nextTimestamp-nsamps; pthread_mutex_unlock(&Sockmutex); return nsamps; } } else { - bool have_to_wait; do { have_to_wait=false; - for ( int sock=0; sockbuf[sock]; + if ( b->circularBuf) { LOG_D(HW,"sock: %d, lastWroteTS: %lu, lastRecvTS: %lu, TS must be avail: %lu\n", sock, b->lastWroteTS, b->lastReceivedTS, t->nextTimestamp+nsamps); + if ( b->lastReceivedTS > b->lastWroteTS ) { - // The caller momdem (NB, UE, ...) must send Tx in advance, so we fill TX if Rx is in advance - // This occurs for example when UE is in sync mode: it doesn't transmit - // with USRP, it seems ok: if "tx stream" is off, we may consider it actually cuts the Tx power - struct complex16 v={0}; - void *samplesVoid[b->th.nbAnt]; - for ( int i=0; i th.nbAnt; i++) - samplesVoid[i]=(void*)&v; - rfsimulator_write(device, b->lastReceivedTS, samplesVoid, 1, b->th.nbAnt, 0); + // The caller modem (NB, UE, ...) must send Tx in advance, so we fill TX if Rx is in advance + // This occurs for example when UE is in sync mode: it doesn't transmit + // with USRP, it seems ok: if "tx stream" is off, we may consider it actually cuts the Tx power + struct complex16 v = {0}; + void *samplesVoid[b->th.nbAnt]; + + for ( int i=0; i < b->th.nbAnt; i++) + samplesVoid[i]=(void *)&v; + + rfsimulator_write(device, b->lastReceivedTS, samplesVoid, 1, b->th.nbAnt, 0); } } @@ -556,13 +555,24 @@ int rfsimulator_read(openair0_device *device, openair0_timestamp *ptimestamp, vo if (reGenerateChannel) random_channel(ptr->channel_model,0); - for (int a=0; acircularBuf, (struct complex16 *) samplesVoid[a], - a, - ptr->channel_model, - nsamps, - t->nextTimestamp - ); + for (int a=0; achannel_model != NULL ) // apply a channel model + rxAddInput( ptr->circularBuf, (struct complex16 *) samplesVoid[a], + a, + ptr->channel_model, + nsamps, + t->nextTimestamp, + CirSize + ); + else { // no channel modeling + sample_t *out=(sample_t *)samplesVoid[a]; + + for ( int i=0; i < nsamps; i++ ) { + out[i].r+=ptr->circularBuf[((t->nextTimestamp+i)*nbAnt+a)%CirSize].r; + out[i].i+=ptr->circularBuf[((t->nextTimestamp+i)*nbAnt+a)%CirSize].i; + } + } // end of no channel modeling + } // end for a... } } @@ -605,33 +615,9 @@ int device_init(openair0_device *device, openair0_config_t *openair0_cfg) { // --log_config.hw_log_level debug // (for phy layer, replace "hw" by "phy") rfsimulator_state_t *rfsimulator = (rfsimulator_state_t *)calloc(sizeof(rfsimulator_state_t),1); - - if ((rfsimulator->ip=getenv("RFSIMULATOR")) == NULL ) { - LOG_E(HW,helpTxt); - exit(1); - } - + rfsimulator_readconfig(rfsimulator); pthread_mutex_init(&Sockmutex, NULL); - - if ( strncasecmp(rfsimulator->ip,"enb",3) == 0 || - strncasecmp(rfsimulator->ip,"server",3) == 0 ) - rfsimulator->typeStamp = ENB_MAGICDL_FDD; - else - rfsimulator->typeStamp = UE_MAGICDL_FDD; - LOG_I(HW,"rfsimulator: running as %s\n", rfsimulator-> typeStamp == ENB_MAGICDL_FDD ? "(eg)NB" : "UE"); - char *saveF; - - if ((saveF=getenv("saveIQfile")) != NULL) { - rfsimulator->saveIQfile=open(saveF,O_APPEND| O_CREAT|O_TRUNC | O_WRONLY, 0666); - - if ( rfsimulator->saveIQfile != -1 ) - LOG_I(HW,"rfsimulator: will save written IQ samples in %s\n", saveF); - else - LOG_E(HW, "can't open %s for IQ saving (%s)\n", saveF, strerror(errno)); - } else - rfsimulator->saveIQfile = -1; - device->trx_start_func = rfsimulator->typeStamp == ENB_MAGICDL_FDD ? server_start : start_ue; diff --git a/targets/ARCH/rfsimulator/stored_node.c b/targets/ARCH/rfsimulator/stored_node.c index 2d13f56a5e..1ddd853fc1 100644 --- a/targets/ARCH/rfsimulator/stored_node.c +++ b/targets/ARCH/rfsimulator/stored_node.c @@ -5,6 +5,7 @@ #include +volatile int oai_exit = 0; void fullwrite(int fd, void *_buf, int count) { char *buf = _buf; @@ -123,7 +124,7 @@ int main(int argc, char *argv[]) { setblocking(serviceSock, blocking); AssertFatal(read(fd,&header,sizeof(header)), ""); fullwrite(serviceSock, &header, sizeof(header)); - int dataSize=sizeof(sample_t)*header.size*header.nbAnt; + int dataSize=sizeof(int32_t)*header.size*header.nbAnt; if (dataSize>bufSize) { void * new_buff = realloc(buff, dataSize); diff --git a/targets/PROJECTS/GENERIC-LTE-EPC/CONF/enb.band13.tm1.50PRB.emtc.conf b/targets/PROJECTS/GENERIC-LTE-EPC/CONF/enb.band13.tm1.50PRB.emtc.conf index d79f5402d0..a761579018 100644 --- a/targets/PROJECTS/GENERIC-LTE-EPC/CONF/enb.band13.tm1.50PRB.emtc.conf +++ b/targets/PROJECTS/GENERIC-LTE-EPC/CONF/enb.band13.tm1.50PRB.emtc.conf @@ -230,6 +230,7 @@ eNBs = pdsch_maxNumRepetitionCEmodeA_r13 = "r16"; #0 + pusch_repetitionLevelCEmodeA_r13 = "l1"; #0 #pdsch_maxNumRepetitionCEmodeB_r13 = "r384"; # NULL - 2 pusch_maxNumRepetitionCEmodeA_r13 = "r8"; #0 diff --git a/targets/PROJECTS/GENERIC-LTE-EPC/CONF/enb.band7.tm1.50PRB.usrpb210.conf b/targets/PROJECTS/GENERIC-LTE-EPC/CONF/enb.band7.tm1.50PRB.usrpb210.conf index 3449479256..d6f44e2b96 100644 --- a/targets/PROJECTS/GENERIC-LTE-EPC/CONF/enb.band7.tm1.50PRB.usrpb210.conf +++ b/targets/PROJECTS/GENERIC-LTE-EPC/CONF/enb.band7.tm1.50PRB.usrpb210.conf @@ -275,12 +275,24 @@ NETWORK_CONTROLLER : THREAD_STRUCT = ( { #three config for level of parallelism "PARALLEL_SINGLE_THREAD", "PARALLEL_RU_L1_SPLIT", or "PARALLEL_RU_L1_TRX_SPLIT" - parallel_config = "PARALLEL_RU_L1_TRX_SPLIT"; + parallel_config = "PARALLEL_SINGLE_THREAD"; #two option for worker "WORKER_DISABLE" or "WORKER_ENABLE" worker_config = "WORKER_ENABLE"; } ); +/* +#example config for rfsimulator +rfsimulator : +{ + serveraddr = "enb"; + serverport = "4043"; + options = ("saviq"); + modelname = "AWGN"; + IQfile = "/tmp/rfsimulator.iqs"; +}; +*/ + log_config : { global_log_level ="info"; diff --git a/targets/PROJECTS/GENERIC-LTE-EPC/CONF/gnb.band78.tm1.106PRB.adrv9371zc706.conf b/targets/PROJECTS/GENERIC-LTE-EPC/CONF/gnb.band78.tm1.106PRB.adrv9371zc706.conf new file mode 100644 index 0000000000..5610694d7d --- /dev/null +++ b/targets/PROJECTS/GENERIC-LTE-EPC/CONF/gnb.band78.tm1.106PRB.adrv9371zc706.conf @@ -0,0 +1,288 @@ +Active_gNBs = ( "gNB-Eurecom-5GNRBox"); +# Asn1_verbosity, choice in: none, info, annoying +Asn1_verbosity = "none"; + +gNBs = +( + { + ////////// Identification parameters: + gNB_ID = 0xe00; + + cell_type = "CELL_MACRO_GNB"; + + gNB_name = "gNB-Eurecom-5GNRBox"; + + // Tracking area code, 0x0000 and 0xfffe are reserved values + tracking_area_code = 1; + + plmn_list = ({mcc = 208; mnc = 93; mnc_length = 2;}); + + tr_s_preference = "local_mac" + + ////////// Physical parameters: + + component_carriers = ( + { + node_function = "3GPP_gNODEB"; + node_timing = "synch_to_ext_device"; + node_synch_ref = 0; + frame_type = "TDD"; + DL_prefix_type = "NORMAL"; + UL_prefix_type = "NORMAL"; + eutra_band = 78; + downlink_frequency = 3510000000L; + uplink_frequency_offset = 0; + Nid_cell = 0; + N_RB_DL = 106; + nb_antenna_ports = 1; + nb_antennas_tx = 1; + nb_antennas_rx = 1; + tx_gain = 90; + rx_gain = 125; + MIB_subCarrierSpacingCommon = 30; + MIB_ssb_SubcarrierOffset = 0; + MIB_dmrs_TypeA_Position = 2; + pdcch_ConfigSIB1 = 0; + SIB1_frequencyOffsetSSB = "khz5"; + SIB1_ssb_PeriodicityServingCell = 5; + SIB1_ss_PBCH_BlockPower = -60; + absoluteFrequencySSB = 0; + DL_FreqBandIndicatorNR = 15; + DL_absoluteFrequencyPointA = 15; + DL_offsetToCarrier = 15; + DL_SCS_SubcarrierSpacing = "kHz30"; + DL_SCS_SpecificCarrier_k0 = 0; + DL_carrierBandwidth = 15; + DL_locationAndBandwidth = 15; + DL_BWP_SubcarrierSpacing = "kHz30"; + DL_BWP_prefix_type = "NORMAL"; + UL_FreqBandIndicatorNR = 15; + UL_absoluteFrequencyPointA = 13; + UL_additionalSpectrumEmission = 3; + UL_p_Max = -1; + UL_frequencyShift7p5khz = "TRUE"; + UL_offsetToCarrier = 10; + UL_SCS_SubcarrierSpacing = "kHz30"; + UL_SCS_SpecificCarrier_k0 = 0; + UL_carrierBandwidth = 15; + UL_locationAndBandwidth = 15; + UL_BWP_SubcarrierSpacing = "kHz30"; + UL_BWP_prefix_type = "NORMAL"; + UL_timeAlignmentTimerCommon = "infinity"; + ServingCellConfigCommon_n_TimingAdvanceOffset = "n0" + ServingCellConfigCommon_ssb_PositionsInBurst_PR = 0x01; + ServingCellConfigCommon_ssb_periodicityServingCell = 10; + ServingCellConfigCommon_dmrs_TypeA_Position = 2; + NIA_SubcarrierSpacing = "kHz15"; + ServingCellConfigCommon_ss_PBCH_BlockPower = -60; + referenceSubcarrierSpacing = "kHz15"; + dl_UL_TransmissionPeriodicity = "ms0p5"; + nrofDownlinkSlots = 10; + nrofDownlinkSymbols = 10; + nrofUplinkSlots = 10; + nrofUplinkSymbols = 10; + rach_totalNumberOfRA_Preambles = 63; + rach_ssb_perRACH_OccasionAndCB_PreamblesPerSSB_choice = "oneEighth"; + rach_ssb_perRACH_OccasionAndCB_PreamblesPerSSB_oneEighth = 4; + rach_ssb_perRACH_OccasionAndCB_PreamblesPerSSB_oneFourth = 8; + rach_ssb_perRACH_OccasionAndCB_PreamblesPerSSB_oneHalf = 16; + rach_ssb_perRACH_OccasionAndCB_PreamblesPerSSB_one = 24; + rach_ssb_perRACH_OccasionAndCB_PreamblesPerSSB_two = 32; + rach_ssb_perRACH_OccasionAndCB_PreamblesPerSSB_four = 8; + rach_ssb_perRACH_OccasionAndCB_PreamblesPerSSB_eight = 4; + rach_ssb_perRACH_OccasionAndCB_PreamblesPerSSB_sixteen = 2; + rach_groupBconfigured = "ENABLE"; + rach_ra_Msg3SizeGroupA = 56; + rach_messagePowerOffsetGroupB = "dB0"; + rach_numberOfRA_PreamblesGroupA = 32; + rach_ra_ContentionResolutionTimer = 8; + rsrp_ThresholdSSB = 64; + rsrp_ThresholdSSB_SUL = 64; + prach_RootSequenceIndex_choice = "l839"; + prach_RootSequenceIndex_l839 = 0; + prach_RootSequenceIndex_l139 = 0; + prach_msg1_SubcarrierSpacing = "kHz30"; + restrictedSetConfig = "unrestrictedSet"; + msg3_transformPrecoding = "ENABLE"; + prach_ConfigurationIndex = 10; + prach_msg1_FDM = "one"; + prach_msg1_FrequencyStart = 10; + zeroCorrelationZoneConfig = 10; + preambleReceivedTargetPower = -150; + preambleTransMax = 6; + powerRampingStep = "dB0"; + ra_ResponseWindow = 8; + groupHoppingEnabledTransformPrecoding = "ENABLE"; + msg3_DeltaPreamble = 0; + p0_NominalWithGrant = 0; + PUSCH_TimeDomainResourceAllocation_k2 = 0; + PUSCH_TimeDomainResourceAllocation_mappingType = "typeA"; + PUSCH_TimeDomainResourceAllocation_startSymbolAndLength = 0; + pucch_ResourceCommon = 0; + pucch_GroupHopping = "neither"; + hoppingId = 0; + p0_nominal = -30; + PDSCH_TimeDomainResourceAllocation_k0 = 2; + PDSCH_TimeDomainResourceAllocation_mappingType = "typeA"; + PDSCH_TimeDomainResourceAllocation_startSymbolAndLength = 0; + rateMatchPatternId = 0; + RateMatchPattern_patternType = "bitmaps"; + symbolsInResourceBlock = "oneSlot"; + periodicityAndPattern = 2; + RateMatchPattern_controlResourceSet = 5; + RateMatchPattern_subcarrierSpacing = "kHz30"; + RateMatchPattern_mode = "dynamic"; + controlResourceSetZero = 0; + searchSpaceZero = 0; + searchSpaceSIB1 = 10; + searchSpaceOtherSystemInformation = 10; + pagingSearchSpace = 10; + ra_SearchSpace = 10; + PDCCH_common_controlResourceSetId = 5; + PDCCH_common_ControlResourceSet_duration = 2; + PDCCH_cce_REG_MappingType = "nonInterleaved"; + PDCCH_reg_BundleSize = 3; + PDCCH_interleaverSize = 3; + PDCCH_shiftIndex = 10; + PDCCH_precoderGranularity = "sameAsREG-bundle"; + PDCCH_TCI_StateId = 32; + tci_PresentInDCI = "ENABLE"; + PDCCH_DMRS_ScramblingID = 0; + SearchSpaceId = 10; + commonSearchSpaces_controlResourceSetId = 5; + SearchSpace_monitoringSlotPeriodicityAndOffset_choice = "sl1"; + SearchSpace_monitoringSlotPeriodicityAndOffset_value = 0; + SearchSpace_duration = 2; + SearchSpace_nrofCandidates_aggregationLevel1 = 0; + SearchSpace_nrofCandidates_aggregationLevel2 = 0; + SearchSpace_nrofCandidates_aggregationLevel4 = 0; + SearchSpace_nrofCandidates_aggregationLevel8 = 0; + SearchSpace_nrofCandidates_aggregationLevel16 = 0; + SearchSpace_searchSpaceType = "common"; + Common_dci_Format2_0_nrofCandidates_SFI_aggregationLevel1 = 1; + Common_dci_Format2_0_nrofCandidates_SFI_aggregationLevel2 = 1; + Common_dci_Format2_0_nrofCandidates_SFI_aggregationLevel4 = 1; + Common_dci_Format2_0_nrofCandidates_SFI_aggregationLevel8 = 1; + Common_dci_Format2_0_nrofCandidates_SFI_aggregationLevel16 = 1; + Common_dci_Format2_3_monitoringPeriodicity = 1; + Common_dci_Format2_3_nrofPDCCH_Candidates = 1; + ue_Specific__dci_Formats = "formats0-0-And-1-0"; + RateMatchPatternLTE_CRS_carrierFreqDL = 6; + RateMatchPatternLTE_CRS_carrierBandwidthDL = 6; + RateMatchPatternLTE_CRS_nrofCRS_Ports = 1; + RateMatchPatternLTE_CRS_v_Shift = 0; + RateMatchPatternLTE_CRS_radioframeAllocationPeriod = 1; + RateMatchPatternLTE_CRS_radioframeAllocationOffset = 0; + RateMatchPatternLTE_CRS_subframeAllocation_choice = "oneFrame"; + } + ); + + + srb1_parameters : + { + # timer_poll_retransmit = (ms) [5, 10, 15, 20,... 250, 300, 350, ... 500] + timer_poll_retransmit = 80; + + # timer_reordering = (ms) [0,5, ... 100, 110, 120, ... ,200] + timer_reordering = 35; + + # timer_reordering = (ms) [0,5, ... 250, 300, 350, ... ,500] + timer_status_prohibit = 0; + + # poll_pdu = [4, 8, 16, 32 , 64, 128, 256, infinity(>10000)] + poll_pdu = 4; + + # poll_byte = (kB) [25,50,75,100,125,250,375,500,750,1000,1250,1500,2000,3000,infinity(>10000)] + poll_byte = 99999; + + # max_retx_threshold = [1, 2, 3, 4 , 6, 8, 16, 32] + max_retx_threshold = 4; + } + + # ------- SCTP definitions + SCTP : + { + # Number of streams to use in input/output + SCTP_INSTREAMS = 2; + SCTP_OUTSTREAMS = 2; + }; + + + ////////// MME parameters: + mme_ip_address = ( { ipv4 = "192.168.12.26"; + ipv6 = "192:168:30::17"; + active = "yes"; + preference = "ipv4"; + } + ); + + NETWORK_INTERFACES : + { + + GNB_INTERFACE_NAME_FOR_S1_MME = "eth0"; + GNB_IPV4_ADDRESS_FOR_S1_MME = "192.168.12.111/24"; + GNB_INTERFACE_NAME_FOR_S1U = "eth0"; + GNB_IPV4_ADDRESS_FOR_S1U = "192.168.12.111/24"; + GNB_PORT_FOR_S1U = 2152; # Spec 2152 + }; + } +); + +MACRLCs = ( + { + num_cc = 1; + tr_s_preference = "local_L1"; + tr_n_preference = "local_RRC"; + } +); + +L1s = ( + { + num_cc = 1; + tr_n_preference = "local_mac"; + } +); + +RUs = ( + { + local_rf = "yes" + nb_tx = 1 + nb_rx = 1 + att_tx = 0 + att_rx = 0; + bands = [7]; + max_pdschReferenceSignalPower = -27; + max_rxgain = 114; + eNB_instances = [0]; + sdr_addrs = "addr=192.168.10.2,second_addr=192.168.20.2,mgmt_addr=192.168.100.8"; + + } +); + +NETWORK_CONTROLLER : +{ + FLEXRAN_ENABLED = "no"; + FLEXRAN_INTERFACE_NAME = "lo"; + FLEXRAN_IPV4_ADDRESS = "127.0.0.1"; + FLEXRAN_PORT = 2210; + FLEXRAN_CACHE = "/mnt/oai_agent_cache"; + FLEXRAN_AWAIT_RECONF = "no"; +}; + + log_config : + { + global_log_level ="info"; + global_log_verbosity ="medium"; + hw_log_level ="info"; + hw_log_verbosity ="medium"; + phy_log_level ="info"; + phy_log_verbosity ="medium"; + mac_log_level ="info"; + mac_log_verbosity ="high"; + rlc_log_level ="info"; + rlc_log_verbosity ="medium"; + pdcp_log_level ="info"; + pdcp_log_verbosity ="medium"; + rrc_log_level ="info"; + rrc_log_verbosity ="medium"; + }; diff --git a/targets/PROJECTS/GENERIC-LTE-EPC/CONF/gnb.band78.tm1.106PRB.usrpx300.conf b/targets/PROJECTS/GENERIC-LTE-EPC/CONF/gnb.band78.tm1.106PRB.usrpx300.conf index 26f6eddf52..a11bf9d515 100644 --- a/targets/PROJECTS/GENERIC-LTE-EPC/CONF/gnb.band78.tm1.106PRB.usrpx300.conf +++ b/targets/PROJECTS/GENERIC-LTE-EPC/CONF/gnb.band78.tm1.106PRB.usrpx300.conf @@ -31,7 +31,7 @@ gNBs = UL_prefix_type = "NORMAL"; eutra_band = 78; downlink_frequency = 3510000000L; - uplink_frequency_offset = -120000000; + uplink_frequency_offset = 0; Nid_cell = 0; N_RB_DL = 106; nb_antenna_ports = 1; diff --git a/targets/RT/USER/lte-enb.c b/targets/RT/USER/lte-enb.c index b08f1a1611..87001d2fc6 100644 --- a/targets/RT/USER/lte-enb.c +++ b/targets/RT/USER/lte-enb.c @@ -64,7 +64,7 @@ #undef MALLOC //there are two conflicting definitions, so we better make sure we don't use it at all //#undef FRAME_LENGTH_COMPLEX_SAMPLES //there are two conflicting definitions, so we better make sure we don't use it at all -#include "../../ARCH/COMMON/common_lib.h" +#include "targets/ARCH/COMMON/common_lib.h" //#undef FRAME_LENGTH_COMPLEX_SAMPLES //there are two conflicting definitions, so we better make sure we don't use it at all @@ -73,7 +73,6 @@ #include "PHY/phy_extern.h" - #include "LAYER2/MAC/mac.h" #include "LAYER2/MAC/mac_extern.h" #include "LAYER2/MAC/mac_proto.h" @@ -118,9 +117,9 @@ extern int oaisim_flag; //uint16_t sf_ahead=4; extern uint16_t sf_ahead; - -extern PARALLEL_CONF_t get_thread_parallel_conf(void); -extern WORKER_CONF_t get_thread_worker_conf(void); +#include "executables/thread-common.h" +//extern PARALLEL_CONF_t get_thread_parallel_conf(void); +//extern WORKER_CONF_t get_thread_worker_conf(void); //pthread_t main_eNB_thread; diff --git a/targets/RT/USER/lte-hwlat.c b/targets/RT/USER/lte-hwlat.c index 3fb4b0e99e..20482adf87 100755 --- a/targets/RT/USER/lte-hwlat.c +++ b/targets/RT/USER/lte-hwlat.c @@ -187,7 +187,7 @@ int32_t **txdata; int setup_ue_buffers(PHY_VARS_UE **phy_vars_ue, openair0_config_t *openair0_cfg); -static inline void saif_meas(int frame_rx, int subframe_rx) { +static inline void saif_meas(unsigned int frame_rx, unsigned int subframe_rx) { static latency_stat_t __thread latency_stat; static struct timespec __thread last= {0}; struct timespec now; @@ -238,7 +238,7 @@ static inline void saif_meas(int frame_rx, int subframe_rx) { if ( (diffTime>=1500) || ( !(frame_rx%1024) && subframe_rx == 0 ) ) { time_t current=time(NULL); printf("\n"); - printf("%.2f Period stats cnt=%7.7ld 0.. 250=%7.7ld 250.. 500=%7.7ld 500.. 600=%7.7ld 600.. 700=%7.7ld 700.. 800=%7.7ld - (frame_rx=%d) - %s", + printf("%.2f Period stats cnt=%7.7ld 0.. 250=%7.7ld 250.. 500=%7.7ld 500.. 600=%7.7ld 600.. 700=%7.7ld 700.. 800=%7.7ld - (frame_rx=%u) - %s", now.tv_sec+(double)now.tv_nsec/1e9, latency_stat.counter, latency_stat.stat250, latency_stat.stat500, @@ -246,7 +246,7 @@ static inline void saif_meas(int frame_rx, int subframe_rx) { latency_stat.stat800, frame_rx, ctime(¤t)); - printf("%.2f Period stats cnt=%7.7ld 800.. 880=%7.7ld 880.. 960=%7.7ld 960..1040=%7.7ld 1040..1120=%7.7ld 1120..1200=%7.7ld - (frame_rx=%d) - %s", + printf("%.2f Period stats cnt=%7.7ld 800.. 880=%7.7ld 880.. 960=%7.7ld 960..1040=%7.7ld 1040..1120=%7.7ld 1120..1200=%7.7ld - (frame_rx=%u) - %s", now.tv_sec+(double)now.tv_nsec/1e9, latency_stat.counter, latency_stat.stat880, latency_stat.stat960, @@ -254,7 +254,7 @@ static inline void saif_meas(int frame_rx, int subframe_rx) { latency_stat.stat1200, frame_rx, ctime(¤t)); - printf("%.2f Period stats cnt=%7.7ld 1200..1300=%7.7ld 1300..1500=%7.7ld 1500..2000=%7.7ld 2000..2500=%7.7ld >3000=%7.7ld - (frame_rx=%d) - %s", + printf("%.2f Period stats cnt=%7.7ld 1200..1300=%7.7ld 1300..1500=%7.7ld 1500..2000=%7.7ld 2000..2500=%7.7ld >3000=%7.7ld - (frame_rx=%u) - %s", now.tv_sec+(double)now.tv_nsec/1e9, latency_stat.counter, latency_stat.stat1300, latency_stat.stat1500, @@ -326,7 +326,7 @@ int main(void) openair0_device rf_device; openair0_timestamp timestamp = 0; - int sub_frame = 0; + unsigned int sub_frame = 0; unsigned int frame_rx = 0; unsigned int nb_antennas_tx = 1; @@ -922,7 +922,7 @@ int main(void) rxp[0] = (void*)&rxdata[0][sub_frame*nb_sample_per_tti]; - readBlockSize = rf_device.trx_read_func( &rf_device, + readBlockSize = rf_device.trx_read_func(&rf_device, ×tamp, rxp, nb_sample_per_tti, diff --git a/targets/RT/USER/lte-hwlat2.c b/targets/RT/USER/lte-hwlat2.c index 67761be9a7..57d2dbaad1 100644 --- a/targets/RT/USER/lte-hwlat2.c +++ b/targets/RT/USER/lte-hwlat2.c @@ -670,7 +670,7 @@ void *UE_thread(void *arg) { { proc = rxtx_proc[i]; pthread_getname_np(proc->pthread_rxtx,threadname,128 ); - printf("RxTX Thread unlock latency on thread %s (it. %ld) (us) : max=%8.3f - mean=%8.3f - min=%8.3f\n", + printf("RxTX Thread unlock latency on thread %s (it. %lu) (us) : max=%8.3f - mean=%8.3f - min=%8.3f\n", threadname, proc->syr_rdtsc_rxtx_th_unlock_iteration, proc->syr_rdtsc_rxtx_th_unlock_max, @@ -1192,9 +1192,9 @@ void histogram_save_in_csv( histo_time_t *histo , char *file_sufix) for ( i = 0; i < HISTOGRAM_SIZE; i++ ) { if ( i + 1 == HISTOGRAM_SIZE ) - fprintf( fp, "%u+;%u\n", min_val, histo[i].count ); + fprintf( fp, "%d+;%u\n", min_val, histo[i].count ); else - fprintf( fp, "%u-%.0f;%u\n", min_val, histo[i].max, histo[i].count ); + fprintf( fp, "%d-%.0f;%u\n", min_val, histo[i].max, histo[i].count ); min_val = histo[i].max; } diff --git a/targets/RT/USER/lte-ru.c b/targets/RT/USER/lte-ru.c index 81c68ad92e..f81626f929 100644 --- a/targets/RT/USER/lte-ru.c +++ b/targets/RT/USER/lte-ru.c @@ -50,10 +50,6 @@ #include "assertions.h" #include "msc.h" - -#include "../../ARCH/COMMON/common_lib.h" -#include "../../ARCH/ETHERNET/USERSPACE/LIB/ethernet_lib.h" - #include "PHY/defs_common.h" #include "PHY/phy_extern.h" #include "PHY/types.h" @@ -64,7 +60,6 @@ #include "PHY/LTE_TRANSPORT/if5_tools.h" #include "PHY/LTE_TRANSPORT/transport_proto.h" #include "PHY_INTERFACE/phy_interface.h" -#include "LAYER2/MAC/mac_extern.h" #include "LAYER2/MAC/mac.h" #include "LAYER2/MAC/mac_extern.h" #include "LAYER2/MAC/mac_proto.h" @@ -78,6 +73,8 @@ #include "common/utils/LOG/vcd_signal_dumper.h" #include "nfapi/oai_integration/vendor_ext.h" #include "enb_config.h" +#include "targets/ARCH/COMMON/common_lib.h" +#include "targets/ARCH/ETHERNET/USERSPACE/LIB/ethernet_lib.h" #include "targets/RT/USER/lte-softmodem.h" //#include "PHY/TOOLS/time_meas.h" @@ -95,7 +92,6 @@ static int DEFENBS[] = {0}; #include "s1ap_eNB.h" #include "SIMULATION/ETH_TRANSPORT/proto.h" - #include "T.h" #include "pdcp.h" @@ -104,9 +100,9 @@ extern volatile int oai_exit; extern int emulate_rf; extern int numerology; extern clock_source_t clock_source; - -extern PARALLEL_CONF_t get_thread_parallel_conf(void); -extern WORKER_CONF_t get_thread_worker_conf(void); +#include "executables/thread-common.h" +//extern PARALLEL_CONF_t get_thread_parallel_conf(void); +//extern WORKER_CONF_t get_thread_worker_conf(void); extern void phy_init_RU(RU_t *); void stop_RU(int nb_ru); diff --git a/targets/RT/USER/lte-softmodem-common.c b/targets/RT/USER/lte-softmodem-common.c index a5fee5397f..6bd8835a92 100644 --- a/targets/RT/USER/lte-softmodem-common.c +++ b/targets/RT/USER/lte-softmodem-common.c @@ -34,11 +34,11 @@ #include "UTIL/OPT/opt.h" #include "common/config/config_userapi.h" #include "common/utils/load_module_shlib.h" +#include "executables/thread-common.h" #include static softmodem_params_t softmodem_params; char *parallel_config=NULL; char *worker_config=NULL; -double snr_dB=25; uint64_t get_softmodem_optmask(void) { return softmodem_params.optmask; @@ -56,14 +56,10 @@ softmodem_params_t *get_softmodem_params(void) { void get_common_options(void) { uint32_t online_log_messages; uint32_t glog_level ; - uint32_t start_telnetsrv; - uint32_t noS1; - uint32_t nokrnmod; - uint32_t nonbiot; - uint32_t rfsim; - uint32_t basicsim; + uint32_t start_telnetsrv = 0; + uint32_t noS1 = 0, nokrnmod = 0, nonbiot = 0; + uint32_t rfsim = 0, basicsim = 0, do_forms = 0; char *logmem_filename = NULL; - uint32_t do_forms; paramdef_t cmdline_params[] =CMDLINE_PARAMS_DESC ; paramdef_t cmdline_logparams[] =CMDLINE_LOGPARAMS_DESC ; checkedparam_t cmdline_log_CheckParams[] = CMDLINE_LOGPARAMS_CHECK_DESC; @@ -96,6 +92,7 @@ void get_common_options(void) { } if (nokrnmod) { + printf("nokrnmod bit enabled \n"); set_softmodem_optmask(SOFTMODEM_NOKRNMOD_BIT); } diff --git a/targets/RT/USER/lte-softmodem.h b/targets/RT/USER/lte-softmodem.h index 12f74e23bb..f0cbbeceed 100644 --- a/targets/RT/USER/lte-softmodem.h +++ b/targets/RT/USER/lte-softmodem.h @@ -20,8 +20,7 @@ #include #include #include - -#include +#include "threads_t.h" #include "rt_wrapper.h" #include "../../ARCH/COMMON/common_lib.h" //#undef MALLOC @@ -30,12 +29,11 @@ #include "PHY/types.h" #include "PHY/defs_eNB.h" #include "PHY/defs_UE.h" -#include "SIMULATION/ETH_TRANSPORT/proto.h" - #include "flexran_agent.h" #include "s1ap_eNB.h" #include "SIMULATION/ETH_TRANSPORT/proto.h" #include "proto_agent.h" +#include "executables/softmodem-common.h" /* help strings definition for command line options, used in CMDLINE_XXX_DESC macros and printed when -h option is used */ #define CONFIG_HLP_RFCFGF "Configuration file for front-end (e.g. LMS7002M)\n" @@ -78,7 +76,6 @@ #define CONFIG_HLP_MSLOTS "Skip the missed slots/subframes \n" #define CONFIG_HLP_ULMCS "Set the maximum uplink MCS\n" #define CONFIG_HLP_TDD "Set hardware to TDD mode (default: FDD). Used only with -U (otherwise set in config file).\n" -#define CONFIG_HLP_SNR "Set average SNR in dB (for --siml1 option)\n" #define CONFIG_HLP_UE "Set the lte softmodem as a UE\n" #define CONFIG_HLP_TQFS "Apply three-quarter of sampling frequency, 23.04 Msps to reduce the data rate on USB/PCIe transfers (only valid for 20 MHz)\n" #define CONFIG_HLP_TPORT "tracer port\n" @@ -169,10 +166,10 @@ #define DEFAULT_DLF 2680000000 -/*---------------------------------------------------------------------------------------------------------------------------------------------------------------------------*/ -/* command line parameters common to eNodeB and UE */ -/* optname helpstr paramflags XXXptr defXXXval type numelt */ -/*---------------------------------------------------------------------------------------------------------------------------------------------------------------------------*/ +/*-----------------------------------------------------------------------------------------------------------------------------------------------------*/ +/* command line parameters common to eNodeB and UE */ +/* optname helpstr paramflags XXXptr defXXXval type numelt */ +/*-----------------------------------------------------------------------------------------------------------------------------------------------------*/ #define RF_CONFIG_FILE softmodem_params.rf_config_file #define PHY_TEST softmodem_params.phy_test #define WAIT_FOR_SYNC softmodem_params.wait_for_sync @@ -185,28 +182,27 @@ #define SEND_DMRSSYNC softmodem_params.send_dmrs_sync #define USIM_TEST softmodem_params.usim_test #define CMDLINE_PARAMS_DESC { \ - {"rf-config-file", CONFIG_HLP_RFCFGF, 0, strptr:(char **)&RF_CONFIG_FILE, defstrval:NULL, TYPE_STRING, sizeof(RF_CONFIG_FILE)},\ - {"ulsch-max-errors", CONFIG_HLP_ULMAXE, 0, uptr:&ULSCH_max_consecutive_errors, defuintval:0, TYPE_UINT, 0}, \ - {"phy-test", CONFIG_HLP_PHYTST, PARAMFLAG_BOOL, iptr:&PHY_TEST, defintval:0, TYPE_INT, 0}, \ - {"usim-test", CONFIG_HLP_USIM, PARAMFLAG_BOOL, u8ptr:&USIM_TEST, defintval:0, TYPE_UINT8, 0}, \ - {"clock", CONFIG_HLP_CLK, 0, uptr:&CLOCK_SOURCE, defintval:0, TYPE_UINT, 0}, \ - {"wait-for-sync", NULL, PARAMFLAG_BOOL, iptr:&WAIT_FOR_SYNC, defintval:0, TYPE_INT, 0}, \ - {"single-thread-enable", CONFIG_HLP_NOSNGLT, PARAMFLAG_BOOL, iptr:&SINGLE_THREAD_FLAG, defintval:0, TYPE_INT, 0}, \ - {"C" , CONFIG_HLP_DLF, 0, uptr:&(downlink_frequency[0][0]), defuintval:2680000000, TYPE_UINT, 0}, \ - {"a" , CONFIG_HLP_CHOFF, 0, iptr:&CHAIN_OFFSET, defintval:0, TYPE_INT, 0}, \ - {"d" , CONFIG_HLP_SOFTS, PARAMFLAG_BOOL, uptr:(uint32_t *)&do_forms, defintval:0, TYPE_INT8, 0}, \ - {"q" , CONFIG_HLP_STMON, PARAMFLAG_BOOL, iptr:&opp_enabled, defintval:0, TYPE_INT, 0}, \ - {"S" , CONFIG_HLP_MSLOTS, PARAMFLAG_BOOL, u8ptr:&exit_missed_slots, defintval:1, TYPE_UINT8, 0}, \ - {"s" , CONFIG_HLP_SNR, 0, dblptr:&snr_dB, defdblval:25, TYPE_DOUBLE, 0}, \ - {"numerology" , CONFIG_HLP_NUMEROLOGY, PARAMFLAG_BOOL, iptr:&NUMEROLOGY, defintval:0, TYPE_INT, 0}, \ - {"emulate-rf" , CONFIG_HLP_EMULATE_RF, PARAMFLAG_BOOL, iptr:&EMULATE_RF, defintval:0, TYPE_INT, 0}, \ - {"parallel-config", CONFIG_HLP_PARALLEL_CMD,0, strptr:(char **)¶llel_config, defstrval:NULL, TYPE_STRING, 0}, \ - {"worker-config", CONFIG_HLP_WORKER_CMD, 0, strptr:(char **)&worker_config, defstrval:NULL, TYPE_STRING, 0}, \ - {"noS1", CONFIG_HLP_NOS1, PARAMFLAG_BOOL, uptr:&noS1, defintval:0, TYPE_INT, 0}, \ - {"rfsim", CONFIG_HLP_RFSIM, PARAMFLAG_BOOL, uptr:&rfsim, defintval:0, TYPE_INT, 0}, \ - {"basicsim", CONFIG_HLP_RFSIM, PARAMFLAG_BOOL, uptr:&basicsim, defintval:0, TYPE_INT, 0}, \ - {"nokrnmod", CONFIG_HLP_NOKRNMOD, PARAMFLAG_BOOL, uptr:&nokrnmod, defintval:0, TYPE_INT, 0}, \ - {"nbiot-disable", CONFIG_HLP_DISABLNBIOT, PARAMFLAG_BOOL, uptr:&nonbiot, defuintval:0, TYPE_INT, 0}, \ + {"rf-config-file", CONFIG_HLP_RFCFGF, 0, strptr:(char **)&RF_CONFIG_FILE, defstrval:NULL, TYPE_STRING, sizeof(RF_CONFIG_FILE)},\ + {"ulsch-max-errors", CONFIG_HLP_ULMAXE, 0, uptr:&ULSCH_max_consecutive_errors, defuintval:0, TYPE_UINT, 0}, \ + {"phy-test", CONFIG_HLP_PHYTST, PARAMFLAG_BOOL, iptr:&PHY_TEST, defintval:0, TYPE_INT, 0}, \ + {"usim-test", CONFIG_HLP_USIM, PARAMFLAG_BOOL, u8ptr:&USIM_TEST, defintval:0, TYPE_UINT8, 0}, \ + {"clock", CONFIG_HLP_CLK, 0, uptr:&CLOCK_SOURCE, defintval:0, TYPE_UINT, 0}, \ + {"wait-for-sync", NULL, PARAMFLAG_BOOL, iptr:&WAIT_FOR_SYNC, defintval:0, TYPE_INT, 0}, \ + {"single-thread-enable", CONFIG_HLP_NOSNGLT, PARAMFLAG_BOOL, iptr:&SINGLE_THREAD_FLAG, defintval:0, TYPE_INT, 0}, \ + {"C" , CONFIG_HLP_DLF, 0, uptr:&(downlink_frequency[0][0]), defuintval:2680000000, TYPE_UINT, 0}, \ + {"a" , CONFIG_HLP_CHOFF, 0, iptr:&CHAIN_OFFSET, defintval:0, TYPE_INT, 0}, \ + {"d" , CONFIG_HLP_SOFTS, PARAMFLAG_BOOL, uptr:(uint32_t *)&do_forms, defintval:0, TYPE_INT8, 0}, \ + {"q" , CONFIG_HLP_STMON, PARAMFLAG_BOOL, iptr:&opp_enabled, defintval:0, TYPE_INT, 0}, \ + {"S" , CONFIG_HLP_MSLOTS, PARAMFLAG_BOOL, u8ptr:&exit_missed_slots, defintval:1, TYPE_UINT8, 0}, \ + {"numerology" , CONFIG_HLP_NUMEROLOGY, PARAMFLAG_BOOL, iptr:&NUMEROLOGY, defintval:0, TYPE_INT, 0}, \ + {"emulate-rf" , CONFIG_HLP_EMULATE_RF, PARAMFLAG_BOOL, iptr:&EMULATE_RF, defintval:0, TYPE_INT, 0}, \ + {"parallel-config", CONFIG_HLP_PARALLEL_CMD, 0, strptr:(char **)¶llel_config, defstrval:NULL, TYPE_STRING, 0}, \ + {"worker-config", CONFIG_HLP_WORKER_CMD, 0, strptr:(char **)&worker_config, defstrval:NULL, TYPE_STRING, 0}, \ + {"noS1", CONFIG_HLP_NOS1, PARAMFLAG_BOOL, uptr:&noS1, defintval:0, TYPE_INT, 0}, \ + {"rfsim", CONFIG_HLP_RFSIM, PARAMFLAG_BOOL, uptr:&rfsim, defintval:0, TYPE_INT, 0}, \ + {"basicsim", CONFIG_HLP_RFSIM, PARAMFLAG_BOOL, uptr:&basicsim, defintval:0, TYPE_INT, 0}, \ + {"nokrnmod", CONFIG_HLP_NOKRNMOD, PARAMFLAG_BOOL, uptr:&nokrnmod, defintval:0, TYPE_INT, 0}, \ + {"nbiot-disable", CONFIG_HLP_DISABLNBIOT, PARAMFLAG_BOOL, uptr:&nonbiot, defuintval:0, TYPE_INT, 0}, \ } #define CONFIG_HLP_FLOG "Enable online log \n" @@ -242,51 +238,6 @@ } /***************************************************************************************************************************************/ -/* */ -#include "threads_t.h" -//extern threads_t threads; - -//extern THREAD_STRUCT thread_struct; -THREAD_STRUCT thread_struct; - -static inline void set_parallel_conf(char *parallel_conf) { - mapping config[]= { - FOREACH_PARALLEL(GENERATE_ENUMTXT) - {NULL,-1} - }; - thread_struct.parallel_conf = (PARALLEL_CONF_t)map_str_to_int(config, parallel_conf); - if (thread_struct.parallel_conf == -1 ) { - LOG_E(ENB_APP,"Impossible value: %s\n", parallel_conf); - thread_struct.parallel_conf = PARALLEL_SINGLE_THREAD; - } -} - -static inline void set_worker_conf(char *worker_conf) { - mapping config[]={ - FOREACH_WORKER(GENERATE_ENUMTXT) - {NULL, -1} - }; - thread_struct.worker_conf = (WORKER_CONF_t)map_str_to_int(config, worker_conf); - if (thread_struct.worker_conf == -1 ) { - LOG_E(ENB_APP,"Impossible value: %s\n", worker_conf); - thread_struct.worker_conf = WORKER_DISABLE ; - } -} - -static inline PARALLEL_CONF_t get_thread_parallel_conf(void) { - return thread_struct.parallel_conf; -} - -static inline WORKER_CONF_t get_thread_worker_conf(void) { - return thread_struct.worker_conf; -} - -/*PARALLEL_CONF_t get_thread_parallel_conf(void); -WORKER_CONF_t get_thread_worker_conf(void); -void set_parallel_conf(char *parallel_conf); -void set_worker_conf(char *worker_conf); -*/ - #define SOFTMODEM_NOS1_BIT (1<<0) #define SOFTMODEM_NOKRNMOD_BIT (1<<1) @@ -295,23 +246,6 @@ void set_worker_conf(char *worker_conf); #define SOFTMODEM_BASICSIM_BIT (1<<11) #define SOFTMODEM_SIML1_BIT (1<<12) #define SOFTMODEM_DOFORMS_BIT (1<<15) -typedef struct { - uint64_t optmask; - THREAD_STRUCT thread_struct; - char rf_config_file[1024]; - int phy_test; - uint8_t usim_test; - int emulate_rf; - int wait_for_sync; //eNodeB only - int single_thread_flag; //eNodeB only - int chain_offset; - int numerology; - unsigned int start_msc; - uint32_t clock_source; - uint32_t timing_source; - int hw_timing_advance; - uint32_t send_dmrs_sync; -} softmodem_params_t; #define IS_SOFTMODEM_NOS1 ( get_softmodem_optmask() & SOFTMODEM_NOS1_BIT) #define IS_SOFTMODEM_NOKRNMOD ( get_softmodem_optmask() & SOFTMODEM_NOKRNMOD_BIT) @@ -329,7 +263,6 @@ uint64_t get_pdcp_optmask(void); extern pthread_cond_t sync_cond; extern pthread_mutex_t sync_mutex; extern int sync_var; -extern double snr_dB; extern uint32_t downlink_frequency[MAX_NUM_CCs][4]; extern int32_t uplink_frequency_offset[MAX_NUM_CCs][4]; @@ -339,7 +272,7 @@ extern uint8_t exit_missed_slots; extern uint64_t num_missed_slots; // counter for the number of missed slots extern int oaisim_flag; -extern volatile int oai_exit; +extern volatile int oai_exit; extern openair0_config_t openair0_cfg[MAX_CARDS]; extern pthread_cond_t sync_cond; @@ -351,8 +284,7 @@ extern double cpuf; // In lte-enb.c extern void stop_eNB(int); extern void kill_eNB_proc(int inst); -extern void init_eNB(int single_thread_flag, - int wait_for_sync); +extern void init_eNB(int single_thread_flag, int wait_for_sync); // In lte-ru.c extern void stop_ru(RU_t *ru); @@ -361,15 +293,10 @@ extern void init_RU_proc(RU_t *ru); extern void stop_RU(int nb_ru); extern void kill_RU_proc(RU_t *ru); extern void set_function_spec_param(RU_t *ru); -extern void init_RU(char*, - clock_source_t clock_source, - clock_source_t time_source, - int send_dmrssync); +extern void init_RU(char *, clock_source_t clock_source, clock_source_t time_source, int send_dmrssync); // In lte-ue.c -extern int setup_ue_buffers(PHY_VARS_UE **phy_vars_ue, - openair0_config_t *openair0_cfg); - +extern int setup_ue_buffers(PHY_VARS_UE **phy_vars_ue, openair0_config_t *openair0_cfg); extern void fill_ue_band_info(void); extern void init_UE(int nb_inst, @@ -384,11 +311,7 @@ extern void init_UE(int nb_inst, int txpowermax, LTE_DL_FRAME_PARMS *fp); -extern void init_thread(int sched_runtime, - int sched_deadline, - int sched_fifo, - cpu_set_t *cpuset, - char *name); +extern void init_thread(int sched_runtime, int sched_deadline, int sched_fifo, cpu_set_t *cpuset, char *name); extern void reset_opp_meas(void); extern void print_opp_meas(void); @@ -399,24 +322,17 @@ extern void kill_td_thread(PHY_VARS_eNB *); extern void kill_te_thread(PHY_VARS_eNB *); extern void RCConfig_sim(void); -extern void init_ocm(double,double); +extern void init_ocm(void); extern void init_ue_devices(PHY_VARS_UE *); -PHY_VARS_UE *init_ue_vars(LTE_DL_FRAME_PARMS *frame_parms, - uint8_t UE_id, - uint8_t abstraction_flag); +PHY_VARS_UE *init_ue_vars(LTE_DL_FRAME_PARMS *frame_parms, uint8_t UE_id, uint8_t abstraction_flag); void init_eNB_afterRU(void); extern int stop_L1L2(module_id_t enb_id); extern int restart_L1L2(module_id_t enb_id); -extern void init_UE_stub_single_thread(int nb_inst, - int eMBMS_active, - int uecap_xer_in, - char *emul_iface); +extern void init_UE_stub_single_thread(int nb_inst, int eMBMS_active, int uecap_xer_in, char *emul_iface); -extern PHY_VARS_UE *init_ue_vars(LTE_DL_FRAME_PARMS *frame_parms, - uint8_t UE_id, - uint8_t abstraction_flag); +extern PHY_VARS_UE *init_ue_vars(LTE_DL_FRAME_PARMS *frame_parms, uint8_t UE_id, uint8_t abstraction_flag); #endif diff --git a/targets/RT/USER/lte-uesoftmodem.c b/targets/RT/USER/lte-uesoftmodem.c index 02a11602ad..cd96b8adf4 100644 --- a/targets/RT/USER/lte-uesoftmodem.c +++ b/targets/RT/USER/lte-uesoftmodem.c @@ -25,7 +25,7 @@ * \date 2012 * \version 0.1 * \company Eurecom - * \email: knopp@eurecom.fr,florian.kaltenberger@eurecom.fr, navid.nikaein@eurecom.fr + * \email: {knopp, florian.kaltenberger, navid.nikaein}@eurecom.fr * \note * \warning */ @@ -89,7 +89,6 @@ #include "lte-softmodem.h" - /* temporary compilation wokaround (UE/eNB split */ uint16_t sf_ahead; @@ -173,14 +172,9 @@ static LTE_DL_FRAME_PARMS *frame_parms[MAX_NUM_CCs]; uint8_t exit_missed_slots=1; uint64_t num_missed_slots=0; // counter for the number of missed slots -/* prototypes from function implemented in lte-ue.c, probably should be elsewhere in a include - file */ +// prototypes from function implemented in lte-ue.c, probably should be elsewhere in a include file. extern void init_UE_stub_single_thread(int nb_inst,int eMBMS_active, int uecap_xer_in, char *emul_iface); - -extern PHY_VARS_UE *init_ue_vars(LTE_DL_FRAME_PARMS *frame_parms, - uint8_t UE_id, - uint8_t abstraction_flag); - +extern PHY_VARS_UE *init_ue_vars(LTE_DL_FRAME_PARMS *frame_parms, uint8_t UE_id, uint8_t abstraction_flag); extern void get_uethreads_params(void); int transmission_mode=1; @@ -318,7 +312,6 @@ static void get_options(void) { int CC_id; int tddflag = 0; char *loopfile = NULL; - int dumpframe = 0; int timingadv = 0; uint8_t nfapi_mode = NFAPI_MONOLITHIC; @@ -592,7 +585,7 @@ int main( int argc, char **argv ) { if (config_mod == NULL) { exit_fun("[SOFTMODEM] Error, configuration module init failed\n"); } - + mode = normal_txrx; memset(&openair0_cfg[0],0,sizeof(openair0_config_t)*MAX_CARDS); set_latency_target(); @@ -792,7 +785,7 @@ int main( int argc, char **argv ) { //p_exmimo_config->framing.tdd_config = TXRXSWITCH_TESTRX; if (IS_SOFTMODEM_SIML1 ) { - init_ocm(snr_dB,0); + init_ocm(); PHY_vars_UE_g[0][0]->no_timing_correction = 1; } diff --git a/targets/RT/USER/rfsim.c b/targets/RT/USER/rfsim.c index 8b3ee97e50..bd8305682c 100644 --- a/targets/RT/USER/rfsim.c +++ b/targets/RT/USER/rfsim.c @@ -64,65 +64,52 @@ sim_t sim; void init_ru_devices(void); -void init_RU(char*,clock_source_t clock_source,clock_source_t time_source,int send_dmrssync); +void init_RU(char *,clock_source_t clock_source,clock_source_t time_source,int send_dmrssync); void *rfsim_top(void *n_frames); -void wait_RUs(void) -{ +void wait_RUs(void) { int i; - // wait for all RUs to be configured over fronthaul pthread_mutex_lock(&RC.ru_mutex); - + while (RC.ru_mask>0) { pthread_cond_wait(&RC.ru_cond,&RC.ru_mutex); } - + pthread_mutex_unlock(&RC.ru_mutex); // copy frame parameters from RU to UEs - for (i=0;iframe_parms->samples_per_tti + RC.ru[0]->frame_parms->ofdm_symbol_size + RC.ru[0]->frame_parms->nb_prefix_samples0; - } - for (int ru_id=0;ru_idframe_parms->samples_per_tti; + for (int ru_id=0; ru_idframe_parms->samples_per_tti; printf("RUs are ready, let's go\n"); } -void wait_eNBs(void) -{ +void wait_eNBs(void) { return; } void RCConfig_sim(void) { - paramlist_def_t RUParamList = {CONFIG_STRING_RU_LIST,NULL,0}; - // Get num RU instances config_getlist( &RUParamList,NULL,0, NULL); RC.nb_RU = RUParamList.numelt; - AssertFatal(RC.nb_RU>0,"we need at least 1 RU for simulation\n"); printf("returned with %d rus\n",RC.nb_RU); - init_RU(NULL,internal,internal,0); - - printf("Waiting for RUs to get set up\n"); + printf("Waiting for RUs to get set up\n"); wait_RUs(); - init_ru_devices(); - static int nframes = 100000; - AssertFatal(0 == pthread_create(&sim.rfsim_thread, NULL, rfsim_top, - (void*)&nframes), ""); - + (void *)&nframes), ""); } @@ -165,75 +152,65 @@ extern int subframe_ru_mask,subframe_UE_mask; int ru_trx_read(openair0_device *device, openair0_timestamp *ptimestamp, void **buff, int nsamps, int cc) { - int ru_id = device->Mod_id; int CC_id = device->CC_id; - int subframe; int sample_count=0; - *ptimestamp = sim.last_ru_rx_timestamp[ru_id][CC_id]; - - LOG_D(SIM,"RU_trx_read nsamps %d TS(%llu,%llu) => subframe %d\n",nsamps, (unsigned long long)sim.current_ru_rx_timestamp[ru_id][CC_id], (unsigned long long)sim.last_ru_rx_timestamp[ru_id][CC_id], - (int)((*ptimestamp/RC.ru[ru_id]->frame_parms->samples_per_tti)%10)); + (int)((*ptimestamp/RC.ru[ru_id]->frame_parms->samples_per_tti)%10)); + // if we're at a subframe boundary generate UL signals for this ru while (sample_countframe_parms->samples_per_tti)%10; + if (subframe_select(RC.ru[ru_id]->frame_parms,subframe) != SF_DL || RC.ru[ru_id]->frame_parms->frame_type == FDD) { LOG_D(SIM,"RU_trx_read generating UL subframe %d (Ts %llu, current TS %llu)\n", - subframe,(unsigned long long)*ptimestamp, - (unsigned long long)sim.current_ru_rx_timestamp[ru_id][CC_id]); - VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_SIM_DO_UL_SIGNAL,1); + subframe,(unsigned long long)*ptimestamp, + (unsigned long long)sim.current_ru_rx_timestamp[ru_id][CC_id]); + VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_SIM_DO_UL_SIGNAL,1); do_UL_sig(&sim, - subframe, - 0, // abstraction_flag - RC.ru[ru_id]->frame_parms, - 0, // frame is only used for abstraction - ru_id, - CC_id); + subframe, + 0, // abstraction_flag + RC.ru[ru_id]->frame_parms, + 0, // frame is only used for abstraction + ru_id, + CC_id); VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_SIM_DO_UL_SIGNAL,0); } + sim.last_ru_rx_timestamp[ru_id][CC_id] += RC.ru[ru_id]->frame_parms->samples_per_tti; sample_count += RC.ru[ru_id]->frame_parms->samples_per_tti; } - return(nsamps); } -int UE_trx_read(openair0_device *device, openair0_timestamp *ptimestamp, void **buff, int nsamps, int cc) -{ +int UE_trx_read(openair0_device *device, openair0_timestamp *ptimestamp, void **buff, int nsamps, int cc) { VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_SIM_UE_TRX_READ,1); int UE_id = device->Mod_id; int CC_id = device->CC_id; - int subframe; int sample_count=0; int read_size; int sptti = PHY_vars_UE_g[UE_id][CC_id]->frame_parms.samples_per_tti; - *ptimestamp = sim.last_UE_rx_timestamp[UE_id][CC_id]; - LOG_D(PHY,"UE %d DL simulation 0: UE_trx_read nsamps %d TS %llu (%llu, offset %d) antenna %d\n", UE_id, nsamps, (unsigned long long)sim.current_UE_rx_timestamp[UE_id][CC_id], (unsigned long long)sim.last_UE_rx_timestamp[UE_id][CC_id], (int)(sim.last_UE_rx_timestamp[UE_id][CC_id]%sptti), - cc); - + cc); if (nsamps < sptti) read_size = nsamps; @@ -242,49 +219,43 @@ int UE_trx_read(openair0_device *device, openair0_timestamp *ptimestamp, void ** while (sample_countframe_parms, - UE_id, - CC_id); + subframe, + sim.last_UE_rx_timestamp[UE_id][CC_id]%sptti, + sptti, + 0, //abstraction_flag, + &PHY_vars_UE_g[UE_id][CC_id]->frame_parms, + UE_id, + CC_id); VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_SIM_DO_DL_SIGNAL,0); LOG_D(PHY,"UE %d: DL simulation 6: UE_trx_read @ TS %"PRIi64" (%"PRIi64")=> frame %d, subframe %d\n", - UE_id, sim.current_UE_rx_timestamp[UE_id][CC_id], - sim.last_UE_rx_timestamp[UE_id][CC_id], - (int)((sim.last_UE_rx_timestamp[UE_id][CC_id]/(sptti*10))&1023), - subframe); - + UE_id, sim.current_UE_rx_timestamp[UE_id][CC_id], + sim.last_UE_rx_timestamp[UE_id][CC_id], + (int)((sim.last_UE_rx_timestamp[UE_id][CC_id]/(sptti*10))&1023), + subframe); sim.last_UE_rx_timestamp[UE_id][CC_id] += read_size; sample_count += read_size; } @@ -295,245 +266,222 @@ int UE_trx_read(openair0_device *device, openair0_timestamp *ptimestamp, void ** int ru_trx_write(openair0_device *device,openair0_timestamp timestamp, void **buff, int nsamps, int cc, int flags) { - int ru_id = device->Mod_id; - LTE_DL_FRAME_PARMS *frame_parms = RC.ru[ru_id]->frame_parms; - pthread_mutex_lock(&sim.subframe_mutex); LOG_D(SIM,"[TXPATH] ru_trx_write: RU %d mask %d\n",ru_id,sim.subframe_ru_mask); - pthread_mutex_unlock(&sim.subframe_mutex); - + pthread_mutex_unlock(&sim.subframe_mutex); // compute amplitude of TX signal from first symbol in subframe - // note: assumes that the packet is an entire subframe - + // note: assumes that the packet is an entire subframe sim.ru_amp[ru_id] = 0; - for (int aa=0; aanb_tx; aa++) { - sim.ru_amp[ru_id] += (double)signal_energy((int32_t*)buff[aa],frame_parms->ofdm_symbol_size)/(12*frame_parms->N_RB_DL); - } - sim.ru_amp[ru_id] = sqrt(sim.ru_amp[ru_id]); - LOG_D(PHY,"Setting amp for RU %d to %f (%d)\n",ru_id,sim.ru_amp[ru_id], dB_fixed((double)signal_energy((int32_t*)buff[0],frame_parms->ofdm_symbol_size))); + for (int aa=0; aanb_tx; aa++) { + sim.ru_amp[ru_id] += (double)signal_energy((int32_t *)buff[aa],frame_parms->ofdm_symbol_size)/(12*frame_parms->N_RB_DL); + } + + sim.ru_amp[ru_id] = sqrt(sim.ru_amp[ru_id]); + LOG_D(PHY,"Setting amp for RU %d to %f (%d)\n",ru_id,sim.ru_amp[ru_id], dB_fixed((double)signal_energy((int32_t *)buff[0],frame_parms->ofdm_symbol_size))); // tell top-level we are done pthread_mutex_lock(&sim.subframe_mutex); sim.subframe_ru_mask|=(1<rfdevice.Mod_id = ru_id; - ru->rfdevice.CC_id = 0; - ru->rfdevice.trx_start_func = ru_trx_start; - ru->rfdevice.trx_read_func = ru_trx_read; - ru->rfdevice.trx_write_func = ru_trx_write; - ru->rfdevice.trx_end_func = ru_trx_end; - ru->rfdevice.trx_stop_func = ru_trx_stop; - ru->rfdevice.trx_set_freq_func = ru_trx_set_freq; - ru->rfdevice.trx_set_gains_func = ru_trx_set_gains; - sim.last_ru_rx_timestamp[ru_id][0] = 0; + if (RC.ru[ru_id]==NULL) RC.ru[ru_id] = (RU_t *)malloc(sizeof(RU_t)); + + ru = RC.ru[ru_id]; + ru->rfdevice.Mod_id = ru_id; + ru->rfdevice.CC_id = 0; + ru->rfdevice.trx_start_func = ru_trx_start; + ru->rfdevice.trx_read_func = ru_trx_read; + ru->rfdevice.trx_write_func = ru_trx_write; + ru->rfdevice.trx_end_func = ru_trx_end; + ru->rfdevice.trx_stop_func = ru_trx_stop; + ru->rfdevice.trx_set_freq_func = ru_trx_set_freq; + ru->rfdevice.trx_set_gains_func = ru_trx_set_gains; + sim.last_ru_rx_timestamp[ru_id][0] = 0; } } void init_ue_devices(PHY_VARS_UE *UE) { - - AssertFatal(UE!=NULL,"UE context is not allocated\n"); - printf("Initializing UE %d.%d\n",UE->Mod_id,UE->CC_id); - UE->rfdevice.Mod_id = UE->Mod_id; - UE->rfdevice.CC_id = UE->CC_id; - UE->rfdevice.trx_start_func = UE_trx_start; - UE->rfdevice.trx_read_func = UE_trx_read; - UE->rfdevice.trx_write_func = UE_trx_write; - UE->rfdevice.trx_end_func = UE_trx_end; - UE->rfdevice.trx_stop_func = UE_trx_stop; - UE->rfdevice.trx_set_freq_func = UE_trx_set_freq; - UE->rfdevice.trx_set_gains_func = UE_trx_set_gains; - sim.last_UE_rx_timestamp[UE->Mod_id][UE->CC_id] = 0; + AssertFatal(UE!=NULL,"UE context is not allocated\n"); + printf("Initializing UE %d.%d\n",UE->Mod_id,UE->CC_id); + UE->rfdevice.Mod_id = UE->Mod_id; + UE->rfdevice.CC_id = UE->CC_id; + UE->rfdevice.trx_start_func = UE_trx_start; + UE->rfdevice.trx_read_func = UE_trx_read; + UE->rfdevice.trx_write_func = UE_trx_write; + UE->rfdevice.trx_end_func = UE_trx_end; + UE->rfdevice.trx_stop_func = UE_trx_stop; + UE->rfdevice.trx_set_freq_func = UE_trx_set_freq; + UE->rfdevice.trx_set_gains_func = UE_trx_set_gains; + sim.last_UE_rx_timestamp[UE->Mod_id][UE->CC_id] = 0; } -void init_ocm(double snr_dB,double sinr_dB) -{ +void init_ocm(void) { module_id_t UE_id, ru_id; int CC_id; - randominit(0); set_taus_seed(0); - - + init_channelmod(); + double snr_dB = channelmod_get_snr_dB(); + double sinr_dB = channelmod_get_sinr_dB(); init_channel_vars ();//fp, &s_re, &s_im, &r_re, &r_im, &r_re0, &r_im0); - // initialize channel descriptors LOG_I(PHY,"Initializing channel descriptors (nb_RU %d, nb_UE %d)\n",RC.nb_RU,NB_UE_INST); + for (ru_id = 0; ru_id < RC.nb_RU; ru_id++) { for (UE_id = 0; UE_id < NB_UE_INST; UE_id++) { for (CC_id=0; CC_idframe_parms->N_RB_DL); + LOG_I(PHY,"Initializing channel descriptors (RU %d, UE %d) for N_RB_DL %d\n",ru_id,UE_id, + RC.ru[ru_id]->frame_parms->N_RB_DL); sim.RU2UE[ru_id][UE_id][CC_id] = - new_channel_desc_scm(RC.ru[ru_id]->nb_tx, - PHY_vars_UE_g[UE_id][CC_id]->frame_parms.nb_antennas_rx, - AWGN, - N_RB2sampling_rate(RC.ru[ru_id]->frame_parms->N_RB_DL), - N_RB2channel_bandwidth(RC.ru[ru_id]->frame_parms->N_RB_DL), - 0.0, - 0, - 0); + new_channel_desc_scm(RC.ru[ru_id]->nb_tx, + PHY_vars_UE_g[UE_id][CC_id]->frame_parms.nb_antennas_rx, + AWGN, + N_RB2sampling_rate(RC.ru[ru_id]->frame_parms->N_RB_DL), + N_RB2channel_bandwidth(RC.ru[ru_id]->frame_parms->N_RB_DL), + 0.0, + 0, + 0); random_channel(sim.RU2UE[ru_id][UE_id][CC_id],0); - LOG_D(OCM,"[SIM] Initializing channel (%s) from UE %d to ru %d\n", "AWGN",UE_id, ru_id); - - - sim.UE2RU[UE_id][ru_id][CC_id] = - new_channel_desc_scm(PHY_vars_UE_g[UE_id][CC_id]->frame_parms.nb_antennas_tx, - RC.ru[ru_id]->nb_rx, - AWGN, - N_RB2sampling_rate(RC.ru[ru_id]->frame_parms->N_RB_UL), - N_RB2channel_bandwidth(RC.ru[ru_id]->frame_parms->N_RB_UL), - 0.0, - 0, - 0); + LOG_D(OCM,"[SIM] Initializing channel (%s) from UE %d to ru %d\n", "AWGN", UE_id, ru_id); + sim.UE2RU[UE_id][ru_id][CC_id] = + new_channel_desc_scm(PHY_vars_UE_g[UE_id][CC_id]->frame_parms.nb_antennas_tx, + RC.ru[ru_id]->nb_rx, + AWGN, + N_RB2sampling_rate(RC.ru[ru_id]->frame_parms->N_RB_UL), + N_RB2channel_bandwidth(RC.ru[ru_id]->frame_parms->N_RB_UL), + 0.0, + 0, + 0); random_channel(sim.UE2RU[UE_id][ru_id][CC_id],0); - // to make channel reciprocal uncomment following line instead of previous. However this only works for SISO at the moment. For MIMO the channel would need to be transposed. //UE2RU[UE_id][ru_id] = RU2UE[ru_id][UE_id]; + AssertFatal(sim.RU2UE[ru_id][UE_id][CC_id]!=NULL,"RU2UE[%d][%d][%d] is null\n",ru_id,UE_id,CC_id); + AssertFatal(sim.UE2RU[UE_id][ru_id][CC_id]!=NULL,"UE2RU[%d][%d][%d] is null\n",UE_id,ru_id,CC_id); - AssertFatal(sim.RU2UE[ru_id][UE_id][CC_id]!=NULL,"RU2UE[%d][%d][%d] is null\n",ru_id,UE_id,CC_id); - AssertFatal(sim.UE2RU[UE_id][ru_id][CC_id]!=NULL,"UE2RU[%d][%d][%d] is null\n",UE_id,ru_id,CC_id); - //pathloss: -132.24 dBm/15kHz RE + target SNR - eNB TX power per RE - if (ru_id == (UE_id % RC.nb_RU)) { - sim.RU2UE[ru_id][UE_id][CC_id]->path_loss_dB = -132.24 + snr_dB - RC.ru[ru_id]->frame_parms->pdsch_config_common.referenceSignalPower; - sim.UE2RU[UE_id][ru_id][CC_id]->path_loss_dB = -132.24 + snr_dB - RC.ru[ru_id]->frame_parms->pdsch_config_common.referenceSignalPower; - } else { - sim.RU2UE[ru_id][UE_id][CC_id]->path_loss_dB = -132.24 + sinr_dB - RC.ru[ru_id]->frame_parms->pdsch_config_common.referenceSignalPower; - sim.UE2RU[UE_id][ru_id][CC_id]->path_loss_dB = -132.24 + sinr_dB - RC.ru[ru_id]->frame_parms->pdsch_config_common.referenceSignalPower; - } - - LOG_I(OCM,"Path loss from eNB %d to UE %d (CCid %d)=> %f dB (eNB TX %d, SNR %f)\n",ru_id,UE_id,CC_id, - sim.RU2UE[ru_id][UE_id][CC_id]->path_loss_dB, - RC.ru[ru_id]->frame_parms->pdsch_config_common.referenceSignalPower,snr_dB); - + //pathloss: -132.24 dBm/15kHz RE + target SNR - eNB TX power per RE + if (ru_id == (UE_id % RC.nb_RU)) { + sim.RU2UE[ru_id][UE_id][CC_id]->path_loss_dB = -132.24 + snr_dB - RC.ru[ru_id]->frame_parms->pdsch_config_common.referenceSignalPower; + sim.UE2RU[UE_id][ru_id][CC_id]->path_loss_dB = -132.24 + snr_dB - RC.ru[ru_id]->frame_parms->pdsch_config_common.referenceSignalPower; + } else { + sim.RU2UE[ru_id][UE_id][CC_id]->path_loss_dB = -132.24 + sinr_dB - RC.ru[ru_id]->frame_parms->pdsch_config_common.referenceSignalPower; + sim.UE2RU[UE_id][ru_id][CC_id]->path_loss_dB = -132.24 + sinr_dB - RC.ru[ru_id]->frame_parms->pdsch_config_common.referenceSignalPower; + } + LOG_I(OCM,"Path loss from eNB %d to UE %d (CCid %d)=> %f dB (eNB TX %d, SNR %f)\n",ru_id,UE_id,CC_id, + sim.RU2UE[ru_id][UE_id][CC_id]->path_loss_dB, + RC.ru[ru_id]->frame_parms->pdsch_config_common.referenceSignalPower, + snr_dB); } } } } -void update_ocm(double snr_dB,double sinr_dB) -{ +void update_ocm(double snr_dB,double sinr_dB) { module_id_t UE_id, ru_id; int CC_id; + for (ru_id = 0; ru_id < RC.nb_RU; ru_id++) { + for (UE_id = 0; UE_id < NB_UE_INST; UE_id++) { + for (CC_id=0; CC_idpath_loss_dB = -132.24 + snr_dB - RC.ru[ru_id]->frame_parms->pdsch_config_common.referenceSignalPower; - sim.UE2RU[UE_id][ru_id][CC_id]->path_loss_dB = -132.24 + snr_dB - RC.ru[ru_id]->frame_parms->pdsch_config_common.referenceSignalPower; - } else { - sim.RU2UE[ru_id][UE_id][CC_id]->path_loss_dB = -132.24 + sinr_dB - RC.ru[ru_id]->frame_parms->pdsch_config_common.referenceSignalPower; - sim.UE2RU[UE_id][ru_id][CC_id]->path_loss_dB = -132.24 + sinr_dB - RC.ru[ru_id]->frame_parms->pdsch_config_common.referenceSignalPower; - } + //pathloss: -132.24 dBm/15kHz RE + target SNR - eNB TX power per RE + if (ru_id == (UE_id % RC.nb_RU)) { + sim.RU2UE[ru_id][UE_id][CC_id]->path_loss_dB = -132.24 + snr_dB - RC.ru[ru_id]->frame_parms->pdsch_config_common.referenceSignalPower; + sim.UE2RU[UE_id][ru_id][CC_id]->path_loss_dB = -132.24 + snr_dB - RC.ru[ru_id]->frame_parms->pdsch_config_common.referenceSignalPower; + } else { + sim.RU2UE[ru_id][UE_id][CC_id]->path_loss_dB = -132.24 + sinr_dB - RC.ru[ru_id]->frame_parms->pdsch_config_common.referenceSignalPower; + sim.UE2RU[UE_id][ru_id][CC_id]->path_loss_dB = -132.24 + sinr_dB - RC.ru[ru_id]->frame_parms->pdsch_config_common.referenceSignalPower; + } - LOG_D(OCM,"Path loss from eNB %d to UE %d (CCid %d)=> %f dB (eNB TX %d, SNR %f)\n",ru_id,UE_id,CC_id, - sim.RU2UE[ru_id][UE_id][CC_id]->path_loss_dB, - RC.ru[ru_id]->frame_parms->pdsch_config_common.referenceSignalPower,snr_dB); - - } - } - } + LOG_D(OCM,"Path loss from eNB %d to UE %d (CCid %d)=> %f dB (eNB TX %d, SNR %f)\n",ru_id,UE_id,CC_id, + sim.RU2UE[ru_id][UE_id][CC_id]->path_loss_dB, + RC.ru[ru_id]->frame_parms->pdsch_config_common.referenceSignalPower, + snr_dB); + } + } + } } -void init_channel_vars(void) -{ - +void init_channel_vars(void) { int i; - memset(sim.RU_output_mask,0,sizeof(int)*NUMBER_OF_UE_MAX); - for (i=0;iframe_parms,(sf+4)%10)!=SF_UL) ? sim.subframe_ru_mask : ((1<frame_parms->frame_type == FDD || subframe_select(RC.ru[0]->frame_parms,(sf+4)%10)!=SF_DL) ? sim.subframe_UE_mask : ((1<frame_parms,(sf+4)%10)!=SF_UL) ? sim.subframe_ru_mask : ((1<frame_parms->frame_type == FDD || subframe_select(RC.ru[0]->frame_parms,(sf+4)%10)!=SF_DL) ? sim.subframe_UE_mask : ((1<frame_parms->samples_per_tti; - LOG_D(SIM,"RU %d/%d: TS %"PRIi64"\n",ru_id,CC_id,sim.current_ru_rx_timestamp[ru_id][CC_id]); + + for (int ru_id=0; ru_idframe_parms->samples_per_tti; + LOG_D(SIM,"RU %d/%d: TS %"PRIi64"\n",ru_id,CC_id,sim.current_ru_rx_timestamp[ru_id][CC_id]); } - for (int UE_inst = 0; UE_instframe_parms.samples_per_tti; - LOG_D(SIM,"UE %d/%d: TS %"PRIi64"\n",UE_inst,CC_id,sim.current_UE_rx_timestamp[UE_inst][CC_id]); + + for (int UE_inst = 0; UE_instframe_parms.samples_per_tti; + LOG_D(SIM,"UE %d/%d: TS %"PRIi64"\n",UE_inst,CC_id,sim.current_UE_rx_timestamp[UE_inst][CC_id]); } - if (oai_exit == 1) return((void*)NULL); + + if (oai_exit == 1) return((void *)NULL); } } - return((void*)NULL); + return((void *)NULL); } diff --git a/targets/RT/USER/rfsim.h b/targets/RT/USER/rfsim.h index f263b1067c..801ab5eb56 100644 --- a/targets/RT/USER/rfsim.h +++ b/targets/RT/USER/rfsim.h @@ -27,7 +27,7 @@ #include "PHY/defs_UE.h" #include "PHY/defs_eNB.h" -void init_ocm(double snr_dB,double sinr_dB); +void init_ocm(void); void update_ocm(double snr_dB,double sinr_dB); @@ -37,4 +37,4 @@ void update_ocm(double snr_dB,double sinr_dB); void init_channel_vars(void); -#endif +#endif