diff --git a/CMakeLists.txt b/CMakeLists.txt index 1de118a383..e9455ec2e9 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -772,7 +772,7 @@ set(PHY_TURBOSRC ${OPENAIR1_DIR}/PHY/CODING/3gpplte_turbo_decoder.c ) set(PHY_POLARSRC - ${OPENAIR1_DIR}/PHY/CODING/nr_polar_init.c + ${OPENAIR1_DIR}/PHY/CODING/nrPolar_tools/nr_polar_init.c ${OPENAIR1_DIR}/PHY/CODING/nrPolar_tools/nr_bitwise_operations.c ${OPENAIR1_DIR}/PHY/CODING/nrPolar_tools/nr_crc_byte.c ${OPENAIR1_DIR}/PHY/CODING/nrPolar_tools/nr_polar_decoder.c diff --git a/ci-scripts/Jenkinsfile-GitLab-Container b/ci-scripts/Jenkinsfile-GitLab-Container index f5b83ec071..5a4e27ed19 100644 --- a/ci-scripts/Jenkinsfile-GitLab-Container +++ b/ci-scripts/Jenkinsfile-GitLab-Container @@ -493,29 +493,6 @@ pipeline { } } } - stage ("Interop-F1") { - when { expression {do5Gtest} } - steps { - script { - triggerSlaveJob ('RAN-Interop-F1', 'Interop-F1') - } - } - post { - always { - script { - // Using a unique variable name for each test stage to avoid overwriting on a global variable - // due to parallel-time concurrency - f1InteropStatus = finalizeSlaveJob('RAN-Interop-F1') - } - } - failure { - script { - currentBuild.result = 'FAILURE' - failingStages += f1InteropStatus - } - } - } - } stage ("Sanity-Check OAI-CN5G") { when { expression {do5Gtest} } steps { diff --git a/ci-scripts/args_parse.py b/ci-scripts/args_parse.py index 8bac1f6a92..7d753d21c7 100644 --- a/ci-scripts/args_parse.py +++ b/ci-scripts/args_parse.py @@ -41,7 +41,7 @@ import constants as CONST #----------------------------------------------------------- -def ArgsParse(argvs,CiTestObj,RAN,HTML,EPC,ldpc,CONTAINERS,HELP,SCA,PHYSIM,CLUSTER): +def ArgsParse(argvs,CiTestObj,RAN,HTML,EPC,CONTAINERS,HELP,SCA,PHYSIM,CLUSTER): py_param_file_present = False @@ -78,7 +78,6 @@ def ArgsParse(argvs,CiTestObj,RAN,HTML,EPC,ldpc,CONTAINERS,HELP,SCA,PHYSIM,CLUST CiTestObj.ranRepository = matchReg.group(1) RAN.ranRepository=matchReg.group(1) HTML.ranRepository=matchReg.group(1) - ldpc.ranRepository=matchReg.group(1) CONTAINERS.ranRepository=matchReg.group(1) SCA.ranRepository=matchReg.group(1) PHYSIM.ranRepository=matchReg.group(1) @@ -89,7 +88,6 @@ def ArgsParse(argvs,CiTestObj,RAN,HTML,EPC,ldpc,CONTAINERS,HELP,SCA,PHYSIM,CLUST else: matchReg = re.match('^\-\-ranAllowMerge=(.+)$', myArgv, re.IGNORECASE) doMerge = matchReg.group(1) - ldpc.ranAllowMerge=matchReg.group(1) if ((doMerge == 'true') or (doMerge == 'True')): CiTestObj.ranAllowMerge = True RAN.ranAllowMerge=True @@ -106,7 +104,6 @@ def ArgsParse(argvs,CiTestObj,RAN,HTML,EPC,ldpc,CONTAINERS,HELP,SCA,PHYSIM,CLUST CiTestObj.ranBranch = matchReg.group(1) RAN.ranBranch=matchReg.group(1) HTML.ranBranch=matchReg.group(1) - ldpc.ranBranch=matchReg.group(1) CONTAINERS.ranBranch=matchReg.group(1) SCA.ranBranch=matchReg.group(1) PHYSIM.ranBranch=matchReg.group(1) @@ -119,7 +116,6 @@ def ArgsParse(argvs,CiTestObj,RAN,HTML,EPC,ldpc,CONTAINERS,HELP,SCA,PHYSIM,CLUST CiTestObj.ranCommitID = matchReg.group(1) RAN.ranCommitID=matchReg.group(1) HTML.ranCommitID=matchReg.group(1) - ldpc.ranCommitID=matchReg.group(1) CONTAINERS.ranCommitID=matchReg.group(1) SCA.ranCommitID=matchReg.group(1) PHYSIM.ranCommitID=matchReg.group(1) @@ -132,7 +128,6 @@ def ArgsParse(argvs,CiTestObj,RAN,HTML,EPC,ldpc,CONTAINERS,HELP,SCA,PHYSIM,CLUST CiTestObj.ranTargetBranch = matchReg.group(1) RAN.ranTargetBranch=matchReg.group(1) HTML.ranTargetBranch=matchReg.group(1) - ldpc.ranTargetBranch=matchReg.group(1) CONTAINERS.ranTargetBranch=matchReg.group(1) SCA.ranTargetBranch=matchReg.group(1) PHYSIM.ranTargetBranch=matchReg.group(1) @@ -141,7 +136,6 @@ def ArgsParse(argvs,CiTestObj,RAN,HTML,EPC,ldpc,CONTAINERS,HELP,SCA,PHYSIM,CLUST if re.match('^\-\-eNBIPAddress=(.+)$', myArgv, re.IGNORECASE): matchReg = re.match('^\-\-eNBIPAddress=(.+)$', myArgv, re.IGNORECASE) RAN.eNBIPAddress=matchReg.group(1) - ldpc.eNBIpAddr=matchReg.group(1) CONTAINERS.eNBIPAddress=matchReg.group(1) SCA.eNBIPAddress=matchReg.group(1) PHYSIM.eNBIPAddress=matchReg.group(1) @@ -158,7 +152,6 @@ def ArgsParse(argvs,CiTestObj,RAN,HTML,EPC,ldpc,CONTAINERS,HELP,SCA,PHYSIM,CLUST if re.match('^\-\-eNBUserName=(.+)$', myArgv, re.IGNORECASE): matchReg = re.match('^\-\-eNBUserName=(.+)$', myArgv, re.IGNORECASE) RAN.eNBUserName=matchReg.group(1) - ldpc.eNBUserName=matchReg.group(1) CONTAINERS.eNBUserName=matchReg.group(1) SCA.eNBUserName=matchReg.group(1) PHYSIM.eNBUserName=matchReg.group(1) @@ -175,7 +168,6 @@ def ArgsParse(argvs,CiTestObj,RAN,HTML,EPC,ldpc,CONTAINERS,HELP,SCA,PHYSIM,CLUST if re.match('^\-\-eNBPassword=(.+)$', myArgv, re.IGNORECASE): matchReg = re.match('^\-\-eNBPassword=(.+)$', myArgv, re.IGNORECASE) RAN.eNBPassword=matchReg.group(1) - ldpc.eNBPassWord=matchReg.group(1) CONTAINERS.eNBPassword=matchReg.group(1) SCA.eNBPassword=matchReg.group(1) PHYSIM.eNBPassword=matchReg.group(1) @@ -192,7 +184,6 @@ def ArgsParse(argvs,CiTestObj,RAN,HTML,EPC,ldpc,CONTAINERS,HELP,SCA,PHYSIM,CLUST if re.match('^\-\-eNBSourceCodePath=(.+)$', myArgv, re.IGNORECASE): matchReg = re.match('^\-\-eNBSourceCodePath=(.+)$', myArgv, re.IGNORECASE) RAN.eNBSourceCodePath=matchReg.group(1) - ldpc.eNBSourceCodePath=matchReg.group(1) CONTAINERS.eNBSourceCodePath=matchReg.group(1) SCA.eNBSourceCodePath=matchReg.group(1) PHYSIM.eNBSourceCodePath=matchReg.group(1) diff --git a/ci-scripts/ci_infra.yaml b/ci-scripts/ci_infra.yaml index 65c7c464b6..cf6e0cad11 100644 --- a/ci-scripts/ci_infra.yaml +++ b/ci-scripts/ci_infra.yaml @@ -382,20 +382,6 @@ rfsim4g_ue_fembms: CmdPrefix: docker exec rfsim4g-oai-lte-ue0 IF: oaitun_uem1 -l2sim5g_ue: - Host: "%%current_host%%" - AttachScript: docker start l2sim-oai-nr-ue0 - DetachScript: docker stop l2sim-oai-nr-ue0 - NetworkScript: docker exec l2sim-oai-nr-ue0 ip a show dev oaitun_ue1 - CmdPrefix: docker exec l2sim-oai-nr-ue0 - IF: oaitun_ue1 - MTU: 1500 - -l2sim5g_ext_dn: - Host: "%%current_host%%" - NetworkScript: docker exec l2sim-oai-ext-dn ip a show dev eth0 - CmdPrefix: docker exec l2sim-oai-ext-dn - l2sim4g_ue: Host: "%%current_host%%" AttachScript: docker start l2sim4g-oai-lte-ue1 diff --git a/ci-scripts/cls_analysis.py b/ci-scripts/cls_analysis.py new file mode 100644 index 0000000000..25d9b0c659 --- /dev/null +++ b/ci-scripts/cls_analysis.py @@ -0,0 +1,82 @@ +#/* +# * 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 +# */ +#--------------------------------------------------------------------- + +import logging +import re + +# Define the mapping of physim_test values to search patterns +PHYSIM_PATTERN_MAPPING = { + 'nr_ulsim': [ + r'(Total PHY proc rx)\s+(\d+\.\d+)\s+us', # Pattern for RX PHY processing time + r'(ULSCH total decoding time)\s+(\d+\.\d+)\s+us', # Pattern for ULSCH decoding time + ], + 'nr_dlsim': [ + r'(PHY proc tx)\s+(\d+\.\d+)\s+us', # Pattern for TX PHY processing time + r'(DLSCH encoding time)\s+(\d+\.\d+)\s+us', # Pattern for DLSCH encoding time + ], + 'ldpctest': [ + r'(Encoding time mean):\s+(\d+\.\d+)\s+us', # Pattern for encoding time mean + r'(Decoding time mean):\s+(\d+\.\d+)\s+us', # Pattern for decoding time mean + ], +} +# Define test conditions based on the simulation type +PHYSIM_TEST_CONDITION = { + 'nr_ulsim': 'test OK', # For nr_ulsim, check if 'test OK' is present + 'nr_dlsim': 'test OK', # For nr_dlsim, check if 'test OK' is present + 'ldpctest': None, # No condition for ldpctest, just process the patterns +} + +class Analysis(): + + def analyze_physim(log, physim_test, options, threshold): + search_patterns = PHYSIM_PATTERN_MAPPING.get(physim_test) + test_condition = PHYSIM_TEST_CONDITION.get(physim_test) + success = False + msg = '' + + try: + with open(log, 'r') as f: + log_content = f.read() + except FileNotFoundError as e: + msg = f'{log} file not found, exception: {e}' + return False, msg + except Exception as e: + msg = f'Error while parsing log file {log}: exception: {e}' + return False, msg + + if test_condition and test_condition not in log_content: + msg = f"Test did not succeed, '{test_condition}' not found in log file {log}." + return False, msg + + time1_match = re.search(search_patterns[0], log_content) + time2_match = re.search(search_patterns[1], log_content) + if not(time1_match and time2_match): + msg = f"Processing time not found in log file {log}." + return False, msg + + success = float(time2_match.group(2)) < float(threshold) + if success: + msg = f'{time1_match.group(1)}: {time1_match.group(2)} us\n{time2_match.group(1)}: {time2_match.group(2)} us' + else: + msg = f'{time1_match.group(1)}: {time1_match.group(2)} us\n{time2_match.group(1)}: {time2_match.group(2)} us exceeds a limit of {threshold} us' + + return success,msg diff --git a/ci-scripts/cls_containerize.py b/ci-scripts/cls_containerize.py index 029a970acd..28f1abbfac 100644 --- a/ci-scripts/cls_containerize.py +++ b/ci-scripts/cls_containerize.py @@ -43,7 +43,6 @@ from zipfile import ZipFile # OAI Testing modules #----------------------------------------------------------- import cls_cmd -import sshconnection as SSH import helpreadme as HELP import constants as CONST import cls_oaicitest @@ -144,17 +143,6 @@ def AnalyzeBuildLogs(buildRoot, images, globalStatus): collectInfo[image] = files return collectInfo -def GetCredentials(instance): - server_id = instance.eNB_serverId[instance.eNB_instance] - if server_id == '0': - return (instance.eNBIPAddress, instance.eNBUserName, instance.eNBPassword, instance.eNBSourceCodePath) - elif server_id == '1': - return (instance.eNB1IPAddress, instance.eNB1UserName, instance.eNB1Password, instance.eNB1SourceCodePath) - elif server_id == '2': - return (instance.eNB2IPAddress, instance.eNB2UserName, instance.eNB2Password, instance.eNB2SourceCodePath) - else: - raise Exception ("Only supports maximum of 3 servers") - def GetContainerName(ssh, svcName, file): ret = ssh.run(f"docker compose -f {file} config --format json {svcName} | jq -r '.services.\"{svcName}\".container_name'", silent=True) return ret.stdout @@ -356,28 +344,23 @@ class Containerize(): # Container management functions #----------------------------------------------------------- + def GetCredentials(self, server_id): + if server_id == '0': + ip, path = self.eNBIPAddress, self.eNBSourceCodePath + elif server_id == '1': + ip, path = self.eNB1IPAddress, self.eNB1SourceCodePath + elif server_id == '2': + ip, path = self.eNB2IPAddress, self.eNB2SourceCodePath + else: + raise ValueError(f"unknown server ID '{server_id}'") + if ip == '' or path == '': + HELP.GenericHelp(CONST.Version) + raise ValueError(f'Insufficient Parameter: IP/node {ip}, path {path}') + return (ip, path) + def BuildImage(self, HTML): - if self.ranRepository == '' or self.ranBranch == '' or self.ranCommitID == '': - HELP.GenericHelp(CONST.Version) - sys.exit('Insufficient Parameter') - if self.eNB_serverId[self.eNB_instance] == '0': - lIpAddr = self.eNBIPAddress - lUserName = self.eNBUserName - lPassWord = self.eNBPassword - lSourcePath = self.eNBSourceCodePath - elif self.eNB_serverId[self.eNB_instance] == '1': - lIpAddr = self.eNB1IPAddress - lUserName = self.eNB1UserName - lPassWord = self.eNB1Password - lSourcePath = self.eNB1SourceCodePath - elif self.eNB_serverId[self.eNB_instance] == '2': - lIpAddr = self.eNB2IPAddress - lUserName = self.eNB2UserName - lPassWord = self.eNB2Password - lSourcePath = self.eNB2SourceCodePath - if lIpAddr == '' or lUserName == '' or lPassWord == '' or lSourcePath == '': - HELP.GenericHelp(CONST.Version) - sys.exit('Insufficient Parameter') + svr = self.eNB_serverId[self.eNB_instance] + lIpAddr, lSourcePath = self.GetCredentials(svr) logging.debug('Building on server: ' + lIpAddr) cmd = cls_cmd.RemoteCmd(lIpAddr) @@ -575,50 +558,12 @@ class Containerize(): return False def BuildProxy(self, HTML): - if self.ranRepository == '' or self.ranBranch == '' or self.ranCommitID == '': - HELP.GenericHelp(CONST.Version) - sys.exit('Insufficient Parameter') - if self.eNB_serverId[self.eNB_instance] == '0': - lIpAddr = self.eNBIPAddress - lUserName = self.eNBUserName - lPassWord = self.eNBPassword - lSourcePath = self.eNBSourceCodePath - elif self.eNB_serverId[self.eNB_instance] == '1': - lIpAddr = self.eNB1IPAddress - lUserName = self.eNB1UserName - lPassWord = self.eNB1Password - lSourcePath = self.eNB1SourceCodePath - elif self.eNB_serverId[self.eNB_instance] == '2': - lIpAddr = self.eNB2IPAddress - lUserName = self.eNB2UserName - lPassWord = self.eNB2Password - lSourcePath = self.eNB2SourceCodePath - if lIpAddr == '' or lUserName == '' or lPassWord == '' or lSourcePath == '': - HELP.GenericHelp(CONST.Version) - sys.exit('Insufficient Parameter') - if self.proxyCommit is None: - HELP.GenericHelp(CONST.Version) - sys.exit('Insufficient Parameter (need proxyCommit for proxy build)') + svr = self.eNB_serverId[self.eNB_instance] + lIpAddr, lSourcePath = self.GetCredentials(svr) logging.debug('Building on server: ' + lIpAddr) - mySSH = SSH.SSHConnection() - mySSH.open(lIpAddr, lUserName, lPassWord) - - # Check that we are on Ubuntu - mySSH.command('hostnamectl', '\$', 5) - result = re.search('Ubuntu', mySSH.getBefore()) - self.host = result.group(0) - if self.host != 'Ubuntu': - logging.error('\u001B[1m Can build proxy only on Ubuntu server\u001B[0m') - mySSH.close() - sys.exit(1) - - self.cli = 'docker' - self.cliBuildOptions = '' - - # Workaround for some servers, we need to erase completely the workspace - if self.forcedWorkspaceCleanup: - mySSH.command('echo ' + lPassWord + ' | sudo -S rm -Rf ' + lSourcePath, '\$', 15) + ssh = cls_cmd.getConnection(lIpAddr) + self.testCase_id = HTML.testCase_id oldRanCommidID = self.ranCommitID oldRanRepository = self.ranRepository oldRanAllowMerge = self.ranAllowMerge @@ -627,30 +572,38 @@ class Containerize(): self.ranRepository = 'https://github.com/EpiSci/oai-lte-5g-multi-ue-proxy.git' self.ranAllowMerge = False self.ranTargetBranch = 'master' - mySSH.command('cd ' +lSourcePath, '\$', 3) - # to prevent accidentally overwriting data that might be used later - self.ranCommitID = oldRanCommidID - self.ranRepository = oldRanRepository - self.ranAllowMerge = oldRanAllowMerge - self.ranTargetBranch = oldRanTargetBranch # Let's remove any previous run artifacts if still there - mySSH.command(self.cli + ' image prune --force', '\$', 30) + ssh.run('docker image prune --force') # Remove any previous proxy image - mySSH.command(self.cli + ' image rm oai-lte-multi-ue-proxy:latest || true', '\$', 30) + ssh.run('docker image rm oai-lte-multi-ue-proxy:latest') tag = self.proxyCommit logging.debug('building L2sim proxy image for tag ' + tag) # check if the corresponding proxy image with tag exists. If not, build it - mySSH.command(self.cli + ' image inspect --format=\'Size = {{.Size}} bytes\' proxy:' + tag, '\$', 5) - buildProxy = mySSH.getBefore().count('o such image') != 0 + ret = ssh.run(f'docker image inspect --format=\'Size = {{{{.Size}}}} bytes\' proxy:{tag}') + buildProxy = ret.returncode != 0 # if no image, build new proxy if buildProxy: - mySSH.command(self.cli + ' build ' + self.cliBuildOptions + ' --target oai-lte-multi-ue-proxy --tag proxy:' + tag + ' --file docker/Dockerfile.ubuntu18.04 . > cmake_targets/log/proxy-build.log 2>&1', '\$', 180) - mySSH.command(self.cli + ' image inspect --format=\'Size = {{.Size}} bytes\' proxy:' + tag, '\$', 5) - mySSH.command(self.cli + ' image prune --force || true','\$', 15) - if mySSH.getBefore().count('o such image') != 0: + ssh.run(f'rm -Rf {lSourcePath}') + success = CreateWorkspace(lIpAddr, lSourcePath, self.ranRepository, self.ranCommitID, self.ranTargetBranch, self.ranAllowMerge) + if not success: + raise Exception("could not clone proxy repository") + + filename = f'build_log_{self.testCase_id}' + fullpath = f'{lSourcePath}/{filename}' + + ssh.run(f'docker build --target oai-lte-multi-ue-proxy --tag proxy:{tag} --file {lSourcePath}/docker/Dockerfile.ubuntu18.04 {lSourcePath} > {fullpath} 2>&1') + ssh.run(f'zip -r -qq {fullpath}.zip {fullpath}') + local_file = f"{os.getcwd()}/../cmake_targets/log/{filename}.zip" + ssh.copyin(f'{fullpath}.zip', local_file) + # don't delete such that we might recover the zips + #ssh.run(f'rm -f {fullpath}.zip') + + ssh.run('docker image prune --force') + ret = ssh.run(f'docker image inspect --format=\'Size = {{{{.Size}}}} bytes\' proxy:{tag}') + if ret.returncode != 0: logging.error('\u001B[1m Build of L2sim proxy failed\u001B[0m') - mySSH.close() + ssh.close() HTML.CreateHtmlTestRow('commit ' + tag, 'KO', CONST.ALL_PROCESSES_OK) HTML.CreateHtmlTabFooter(False) return False @@ -658,33 +611,20 @@ class Containerize(): logging.debug('L2sim proxy image for tag ' + tag + ' already exists, skipping build') # retag the build images to that we pick it up later - mySSH.command('docker image tag proxy:' + tag + ' oai-lte-multi-ue-proxy:latest', '\$', 5) - - # no merge: is a push to develop, tag the image so we can push it to the registry - if not self.ranAllowMerge: - mySSH.command('docker image tag proxy:' + tag + ' proxy:develop', '\$', 5) + ssh.run(f'docker image tag proxy:{tag} oai-lte-multi-ue-proxy:latest') # we assume that the host on which this is built will also run the proxy. The proxy # currently requires the following command, and the docker-compose up mechanism of # the CI does not allow to run arbitrary commands. Note that the following actually # belongs to the deployment, not the build of the proxy... logging.warning('the following command belongs to deployment, but no mechanism exists to exec it there!') - mySSH.command('sudo ifconfig lo: 127.0.0.2 netmask 255.0.0.0 up', '\$', 5) + ssh.run('sudo ifconfig lo: 127.0.0.2 netmask 255.0.0.0 up') - # Analyzing the logs - if buildProxy: - self.testCase_id = HTML.testCase_id - mySSH.command('cd ' + lSourcePath + '/cmake_targets', '\$', 5) - mySSH.command('mkdir -p proxy_build_log_' + self.testCase_id, '\$', 5) - mySSH.command('mv log/* ' + 'proxy_build_log_' + self.testCase_id, '\$', 5) - if (os.path.isfile('./proxy_build_log_' + self.testCase_id + '.zip')): - os.remove('./proxy_build_log_' + self.testCase_id + '.zip') - if (os.path.isdir('./proxy_build_log_' + self.testCase_id)): - shutil.rmtree('./proxy_build_log_' + self.testCase_id) - mySSH.command('zip -r -qq proxy_build_log_' + self.testCase_id + '.zip proxy_build_log_' + self.testCase_id, '\$', 5) - mySSH.copyin(lIpAddr, lUserName, lPassWord, lSourcePath + '/cmake_targets/build_log_' + self.testCase_id + '.zip', '.') - # don't delete such that we might recover the zips - #mySSH.command('rm -f build_log_' + self.testCase_id + '.zip','\$', 5) + # to prevent accidentally overwriting data that might be used later + self.ranCommitID = oldRanCommidID + self.ranRepository = oldRanRepository + self.ranAllowMerge = oldRanAllowMerge + self.ranTargetBranch = oldRanTargetBranch # we do not analyze the logs (we assume the proxy builds fine at this stage), # but need to have the following information to correctly display the HTML @@ -696,11 +636,11 @@ class Containerize(): files['Target Image Creation'] = errorandwarnings collectInfo = {} collectInfo['proxy'] = files - mySSH.command('docker image inspect --format=\'Size = {{.Size}} bytes\' proxy:' + tag, '\$', 5) - result = re.search('Size *= *(?P[0-9\-]+) *bytes', mySSH.getBefore()) + ret = ssh.run(f'docker image inspect --format=\'Size = {{{{.Size}}}} bytes\' proxy:{tag}') + result = re.search('Size *= *(?P[0-9\-]+) *bytes', ret.stdout) # Cleaning any created tmp volume - mySSH.command(self.cli + ' volume prune --force || true','\$', 15) - mySSH.close() + ssh.run('docker volume prune --force') + ssh.close() allImagesSize = {} if result is not None: @@ -720,27 +660,8 @@ class Containerize(): return False def BuildRunTests(self, HTML): - if self.ranRepository == '' or self.ranBranch == '' or self.ranCommitID == '': - HELP.GenericHelp(CONST.Version) - sys.exit('Insufficient Parameter') - if self.eNB_serverId[self.eNB_instance] == '0': - lIpAddr = self.eNBIPAddress - lUserName = self.eNBUserName - lPassWord = self.eNBPassword - lSourcePath = self.eNBSourceCodePath - elif self.eNB_serverId[self.eNB_instance] == '1': - lIpAddr = self.eNB1IPAddress - lUserName = self.eNB1UserName - lPassWord = self.eNB1Password - lSourcePath = self.eNB1SourceCodePath - elif self.eNB_serverId[self.eNB_instance] == '2': - lIpAddr = self.eNB2IPAddress - lUserName = self.eNB2UserName - lPassWord = self.eNB2Password - lSourcePath = self.eNB2SourceCodePath - if lIpAddr == '' or lUserName == '' or lPassWord == '' or lSourcePath == '': - HELP.GenericHelp(CONST.Version) - sys.exit('Insufficient Parameter') + svr = self.eNB_serverId[self.eNB_instance] + lIpAddr, lSourcePath = self.GetCredentials(svr) logging.debug('Building on server: ' + lIpAddr) cmd = cls_cmd.RemoteCmd(lIpAddr) cmd.cd(lSourcePath) @@ -803,33 +724,15 @@ class Containerize(): return False def Push_Image_to_Local_Registry(self, HTML): - if self.registrySvrId == '0': - lIpAddr = self.eNBIPAddress - lUserName = self.eNBUserName - lPassWord = self.eNBPassword - lSourcePath = self.eNBSourceCodePath - elif self.registrySvrId == '1': - lIpAddr = self.eNB1IPAddress - lUserName = self.eNB1UserName - lPassWord = self.eNB1Password - lSourcePath = self.eNB1SourceCodePath - elif self.registrySvrId == '2': - lIpAddr = self.eNB2IPAddress - lUserName = self.eNB2UserName - lPassWord = self.eNB2Password - lSourcePath = self.eNB2SourceCodePath - if lIpAddr == '' or lUserName == '' or lPassWord == '' or lSourcePath == '': - HELP.GenericHelp(CONST.Version) - sys.exit('Insufficient Parameter') + lIpAddr, lSourcePath = self.GetCredentials(self.registrySvrId) logging.debug('Pushing images from server: ' + lIpAddr) - mySSH = SSH.SSHConnection() - mySSH.open(lIpAddr, lUserName, lPassWord) + ssh = cls_cmd.getConnection(lIpAddr) imagePrefix = 'porcepix.sboai.cs.eurecom.fr' - mySSH.command(f'docker login -u oaicicd -p oaicicd {imagePrefix}', '\$', 5) - if re.search('Login Succeeded', mySSH.getBefore()) is None: + ret = ssh.run(f'docker login -u oaicicd -p oaicicd {imagePrefix}') + if ret.returncode != 0: msg = 'Could not log into local registry' logging.error(msg) - mySSH.close() + ssh.close() HTML.CreateHtmlTestRow(msg, 'KO', CONST.ALL_PROCESSES_OK) return False @@ -839,57 +742,37 @@ class Containerize(): for image in IMAGES: tagToUse = CreateTag(self.ranCommitID, self.ranBranch, self.ranAllowMerge) imageTag = f"{image}:{tagToUse}" - mySSH.command(f'docker image tag {image}:{orgTag} {imagePrefix}/{imageTag}', '\$', 5) - if re.search('Error response from daemon: No such image:', mySSH.getBefore()) is not None: + ret = ssh.run(f'docker image tag {image}:{orgTag} {imagePrefix}/{imageTag}') + if ret.returncode != 0: continue - mySSH.command(f'docker push {imagePrefix}/{imageTag}', '\$', 120) - if re.search(': digest:', mySSH.getBefore()) is None: - logging.debug(mySSH.getBefore()) + ret = ssh.run(f'docker push {imagePrefix}/{imageTag}') + if ret.returncode != 0: msg = f'Could not push {image} to local registry : {imageTag}' logging.error(msg) - mySSH.close() + ssh.close() HTML.CreateHtmlTestRow(msg, 'KO', CONST.ALL_PROCESSES_OK) return False # Creating a develop tag on the local private registry if not self.ranAllowMerge: - mySSH.command(f'docker image tag {image}:{orgTag} {imagePrefix}/{image}:develop', '\$', 5) - mySSH.command(f'docker push {imagePrefix}/{image}:develop', '\$', 120) - mySSH.command(f'docker rmi {imagePrefix}/{image}:develop', '\$', 120) - mySSH.command(f'docker rmi {imagePrefix}/{imageTag} {image}:{orgTag}', '\$', 30) + ssh.run(f'docker image tag {image}:{orgTag} {imagePrefix}/{image}:develop') + ssh.run(f'docker push {imagePrefix}/{image}:develop') + ssh.run(f'docker rmi {imagePrefix}/{image}:develop') + ssh.run(f'docker rmi {imagePrefix}/{imageTag} {image}:{orgTag}') - mySSH.command(f'docker logout {imagePrefix}', '\$', 5) - if re.search('Removing login credentials', mySSH.getBefore()) is None: + ret = ssh.run(f'docker logout {imagePrefix}') + if ret.returncode != 0: msg = 'Could not log off from local registry' logging.error(msg) - mySSH.close() + ssh.close() HTML.CreateHtmlTestRow(msg, 'KO', CONST.ALL_PROCESSES_OK) return False - mySSH.close() + ssh.close() HTML.CreateHtmlTestRow('N/A', 'OK', CONST.ALL_PROCESSES_OK) return True def Pull_Image_from_Local_Registry(self, HTML): - # This method can be called either onto a remote server (different from python executor) - # or directly on the python executor (ie lIpAddr == 'none') - if self.testSvrId == '0': - lIpAddr = self.eNBIPAddress - lUserName = self.eNBUserName - lPassWord = self.eNBPassword - lSourcePath = self.eNBSourceCodePath - elif self.testSvrId == '1': - lIpAddr = self.eNB1IPAddress - lUserName = self.eNB1UserName - lPassWord = self.eNB1Password - lSourcePath = self.eNB1SourceCodePath - elif self.testSvrId == '2': - lIpAddr = self.eNB2IPAddress - lUserName = self.eNB2UserName - lPassWord = self.eNB2Password - lSourcePath = self.eNB2SourceCodePath - if lIpAddr == '' or lUserName == '' or lPassWord == '' or lSourcePath == '': - HELP.GenericHelp(CONST.Version) - sys.exit('Insufficient Parameter') + lIpAddr, lSourcePath = self.GetCredentials(self.testSvrId) logging.debug('\u001B[1m Pulling image(s) on server: ' + lIpAddr + '\u001B[0m') myCmd = cls_cmd.getConnection(lIpAddr) imagePrefix = 'porcepix.sboai.cs.eurecom.fr' @@ -929,26 +812,7 @@ class Containerize(): return True def Clean_Test_Server_Images(self, HTML): - # This method can be called either onto a remote server (different from python executor) - # or directly on the python executor (ie lIpAddr == 'none') - if self.testSvrId == '0': - lIpAddr = self.eNBIPAddress - lUserName = self.eNBUserName - lPassWord = self.eNBPassword - lSourcePath = self.eNBSourceCodePath - elif self.testSvrId == '1': - lIpAddr = self.eNB1IPAddress - lUserName = self.eNB1UserName - lPassWord = self.eNB1Password - lSourcePath = self.eNB1SourceCodePath - elif self.testSvrId == '2': - lIpAddr = self.eNB2IPAddress - lUserName = self.eNB2UserName - lPassWord = self.eNB2Password - lSourcePath = self.eNB2SourceCodePath - if lIpAddr == '' or lUserName == '' or lPassWord == '' or lSourcePath == '': - HELP.GenericHelp(CONST.Version) - sys.exit('Insufficient Parameter') + lIpAddr, lSourcePath = self.GetCredentials(self.testSvrId) if lIpAddr != 'none': logging.debug('Removing test images from server: ' + lIpAddr) myCmd = cls_cmd.RemoteCmd(lIpAddr) @@ -967,25 +831,8 @@ class Containerize(): return True def Create_Workspace(self,HTML): - if self.eNB_serverId[self.eNB_instance] == '0': - lIpAddr = self.eNBIPAddress - lUserName = self.eNBUserName - lPassWord = self.eNBPassword - lSourcePath = self.eNBSourceCodePath - elif self.eNB_serverId[self.eNB_instance] == '1': - lIpAddr = self.eNB1IPAddress - lUserName = self.eNB1UserName - lPassWord = self.eNB1Password - lSourcePath = self.eNB1SourceCodePath - elif self.eNB_serverId[self.eNB_instance] == '2': - lIpAddr = self.eNB2IPAddress - lUserName = self.eNB2UserName - lPassWord = self.eNB2Password - lSourcePath = self.eNB2SourceCodePath - if lIpAddr == '' or lUserName == '' or lPassWord == '' or lSourcePath == '': - HELP.GenericHelp(CONST.Version) - sys.exit('Insufficient Parameter') - + svr = self.eNB_serverId[self.eNB_instance] + lIpAddr, lSourcePath = self.GetCredentials(svr) success = CreateWorkspace(lIpAddr, lSourcePath, self.ranRepository, self.ranCommitID, self.ranTargetBranch, self.ranAllowMerge) if success: HTML.CreateHtmlTestRowQueue('N/A', 'OK', [f"created workspace {lSourcePath}"]) @@ -994,10 +841,8 @@ class Containerize(): return success def DeployObject(self, HTML): - lIpAddr, lUserName, lPassWord, lSourcePath = GetCredentials(self) - if lIpAddr == '' or lUserName == '' or lPassWord == '' or lSourcePath == '': - HELP.GenericHelp(CONST.Version) - sys.exit('Insufficient Parameter') + svr = self.eNB_serverId[self.eNB_instance] + lIpAddr, lSourcePath = self.GetCredentials(svr) logging.debug('\u001B[1m Deploying OAI Object on server: ' + lIpAddr + '\u001B[0m') yaml = self.yamlPath[self.eNB_instance].strip('/') wd = f'{lSourcePath}/{yaml}' @@ -1027,10 +872,6 @@ class Containerize(): containerName = GetContainerName(ssh, svc, f"{wd}/docker-compose.y*ml") healthy = GetContainerHealth(ssh, containerName) if not healthy: - tgtlogfile = f'{svc}-{HTML.testCase_id}.log' - logging.warning(f"Deployment Failed: Trying to copy container logs to {tgtlogfile}") - yaml_dir = yaml.split('/')[-1] - CopyinContainerLog(ssh, lSourcePath, yaml_dir, containerName, tgtlogfile) imagesInfo += [f"Failed to deploy: service {svc}"] fstatus = False else: @@ -1044,10 +885,8 @@ class Containerize(): return fstatus def UndeployObject(self, HTML, RAN): - lIpAddr, lUserName, lPassWord, lSourcePath = GetCredentials(self) - if lIpAddr == '' or lUserName == '' or lPassWord == '' or lSourcePath == '': - HELP.GenericHelp(CONST.Version) - sys.exit('Insufficient Parameter') + svr = self.eNB_serverId[self.eNB_instance] + lIpAddr, lSourcePath = self.GetCredentials(svr) logging.debug(f'\u001B[1m Undeploying OAI Object from server: {lIpAddr}\u001B[0m') yaml = self.yamlPath[self.eNB_instance].strip('/') wd = f'{lSourcePath}/{yaml}' @@ -1075,121 +914,3 @@ class Containerize(): else: logging.error('\u001B[1m Undeploying OAI Object Failed\u001B[0m') return success - - def CheckAndAddRoute(self, svrName, ipAddr, userName, password): - logging.debug('Checking IP routing on ' + svrName) - mySSH = SSH.SSHConnection() - if svrName == 'porcepix': - mySSH.open(ipAddr, userName, password) - # Check if route to asterix gnb exists - mySSH.command('ip route | grep --colour=never "192.168.68.64/26"', '\$', 10) - result = re.search('172.21.16.127', mySSH.getBefore()) - if result is None: - mySSH.command('echo ' + password + ' | sudo -S ip route add 192.168.68.64/26 via 172.21.16.127 dev eno1', '\$', 10) - # Check if route to obelix enb exists - mySSH.command('ip route | grep --colour=never "192.168.68.128/26"', '\$', 10) - result = re.search('172.21.16.128', mySSH.getBefore()) - if result is None: - mySSH.command('echo ' + password + ' | sudo -S ip route add 192.168.68.128/26 via 172.21.16.128 dev eno1', '\$', 10) - # Check if forwarding is enabled - mySSH.command('sysctl net.ipv4.conf.all.forwarding', '\$', 10) - result = re.search('net.ipv4.conf.all.forwarding = 1', mySSH.getBefore()) - if result is None: - mySSH.command('echo ' + password + ' | sudo -S sysctl net.ipv4.conf.all.forwarding=1', '\$', 10) - # Check if iptables forwarding is accepted - mySSH.command('echo ' + password + ' | sudo -S iptables -L FORWARD', '\$', 10) - result = re.search('Chain FORWARD .*policy ACCEPT', mySSH.getBefore()) - if result is None: - mySSH.command('echo ' + password + ' | sudo -S iptables -P FORWARD ACCEPT', '\$', 10) - mySSH.close() - if svrName == 'asterix': - mySSH.open(ipAddr, userName, password) - # Check if route to porcepix epc exists - mySSH.command('ip route | grep --colour=never "192.168.61.192/26"', '\$', 10) - result = re.search('172.21.16.136', mySSH.getBefore()) - if result is None: - mySSH.command('echo ' + password + ' | sudo -S ip route add 192.168.61.192/26 via 172.21.16.136 dev em1', '\$', 10) - # Check if route to porcepix cn5g exists - mySSH.command('ip route | grep --colour=never "192.168.70.128/26"', '\$', 10) - result = re.search('172.21.16.136', mySSH.getBefore()) - if result is None: - mySSH.command('echo ' + password + ' | sudo -S ip route add 192.168.70.128/26 via 172.21.16.136 dev em1', '\$', 10) - # Check if X2 route to obelix enb exists - mySSH.command('ip route | grep --colour=never "192.168.68.128/26"', '\$', 10) - result = re.search('172.21.16.128', mySSH.getBefore()) - if result is None: - mySSH.command('echo ' + password + ' | sudo -S ip route add 192.168.68.128/26 via 172.21.16.128 dev em1', '\$', 10) - # Check if forwarding is enabled - mySSH.command('sysctl net.ipv4.conf.all.forwarding', '\$', 10) - result = re.search('net.ipv4.conf.all.forwarding = 1', mySSH.getBefore()) - if result is None: - mySSH.command('echo ' + password + ' | sudo -S sysctl net.ipv4.conf.all.forwarding=1', '\$', 10) - # Check if iptables forwarding is accepted - mySSH.command('echo ' + password + ' | sudo -S iptables -L FORWARD', '\$', 10) - result = re.search('Chain FORWARD .*policy ACCEPT', mySSH.getBefore()) - if result is None: - mySSH.command('echo ' + password + ' | sudo -S iptables -P FORWARD ACCEPT', '\$', 10) - mySSH.close() - if svrName == 'obelix': - mySSH.open(ipAddr, userName, password) - # Check if route to porcepix epc exists - mySSH.command('ip route | grep --colour=never "192.168.61.192/26"', '\$', 10) - result = re.search('172.21.16.136', mySSH.getBefore()) - if result is None: - mySSH.command('echo ' + password + ' | sudo -S ip route add 192.168.61.192/26 via 172.21.16.136 dev eno1', '\$', 10) - # Check if X2 route to asterix gnb exists - mySSH.command('ip route | grep --colour=never "192.168.68.64/26"', '\$', 10) - result = re.search('172.21.16.127', mySSH.getBefore()) - if result is None: - mySSH.command('echo ' + password + ' | sudo -S ip route add 192.168.68.64/26 via 172.21.16.127 dev eno1', '\$', 10) - # Check if X2 route to nepes gnb exists - mySSH.command('ip route | grep --colour=never "192.168.68.192/26"', '\$', 10) - result = re.search('172.21.16.137', mySSH.getBefore()) - if result is None: - mySSH.command('echo ' + password + ' | sudo -S ip route add 192.168.68.192/26 via 172.21.16.137 dev eno1', '\$', 10) - # Check if forwarding is enabled - mySSH.command('sysctl net.ipv4.conf.all.forwarding', '\$', 10) - result = re.search('net.ipv4.conf.all.forwarding = 1', mySSH.getBefore()) - if result is None: - mySSH.command('echo ' + password + ' | sudo -S sysctl net.ipv4.conf.all.forwarding=1', '\$', 10) - # Check if iptables forwarding is accepted - mySSH.command('echo ' + password + ' | sudo -S iptables -L FORWARD', '\$', 10) - result = re.search('Chain FORWARD .*policy ACCEPT', mySSH.getBefore()) - if result is None: - mySSH.command('echo ' + password + ' | sudo -S iptables -P FORWARD ACCEPT', '\$', 10) - mySSH.close() - if svrName == 'nepes': - mySSH.open(ipAddr, userName, password) - # Check if route to ofqot gnb exists - mySSH.command('ip route | grep --colour=never "192.168.68.192/26"', '\$', 10) - result = re.search('172.21.16.109', mySSH.getBefore()) - if result is None: - mySSH.command('echo ' + password + ' | sudo -S ip route add 192.168.68.192/26 via 172.21.16.109 dev enp0s31f6', '\$', 10) - mySSH.command('sysctl net.ipv4.conf.all.forwarding', '\$', 10) - result = re.search('net.ipv4.conf.all.forwarding = 1', mySSH.getBefore()) - if result is None: - mySSH.command('echo ' + password + ' | sudo -S sysctl net.ipv4.conf.all.forwarding=1', '\$', 10) - # Check if iptables forwarding is accepted - mySSH.command('echo ' + password + ' | sudo -S iptables -L FORWARD', '\$', 10) - result = re.search('Chain FORWARD .*policy ACCEPT', mySSH.getBefore()) - if result is None: - mySSH.command('echo ' + password + ' | sudo -S iptables -P FORWARD ACCEPT', '\$', 10) - mySSH.close() - if svrName == 'ofqot': - mySSH.open(ipAddr, userName, password) - # Check if X2 route to nepes enb/epc exists - mySSH.command('ip route | grep --colour=never "192.168.68.128/26"', '\$', 10) - result = re.search('172.21.16.137', mySSH.getBefore()) - if result is None: - mySSH.command('echo ' + password + ' | sudo -S ip route add 192.168.68.128/26 via 172.21.16.137 dev enp2s0', '\$', 10) - # Check if forwarding is enabled - mySSH.command('sysctl net.ipv4.conf.all.forwarding', '\$', 10) - result = re.search('net.ipv4.conf.all.forwarding = 1', mySSH.getBefore()) - if result is None: - mySSH.command('echo ' + password + ' | sudo -S sysctl net.ipv4.conf.all.forwarding=1', '\$', 10) - # Check if iptables forwarding is accepted - mySSH.command('echo ' + password + ' | sudo -S iptables -L FORWARD', '\$', 10) - result = re.search('Chain FORWARD .*policy ACCEPT', mySSH.getBefore()) - if result is None: - mySSH.command('echo ' + password + ' | sudo -S iptables -P FORWARD ACCEPT', '\$', 10) - mySSH.close() diff --git a/ci-scripts/cls_native.py b/ci-scripts/cls_native.py index d9c281907a..8f4d90ea84 100644 --- a/ci-scripts/cls_native.py +++ b/ci-scripts/cls_native.py @@ -22,11 +22,15 @@ import logging import re +import os import cls_cmd import cls_oai_html +import cls_analysis import constants as CONST +LOG_PATH_PHYSIM = 'phy_sim_logs' + class Native(): def Build(test_case, HTML, host, directory, options): @@ -62,3 +66,19 @@ class Native(): logging.error('\u001B[1m Building OAI Failed\u001B[0m') HTML.CreateHtmlTestRow(options, 'KO', CONST.ALL_PROCESSES_OK) return success + + def Run_Physim(HTML, host, directory, options, physim_test, threshold): + logging.debug(f'Runnin {physim_test} on server: {host}') + workSpacePath = f'{directory}/cmake_targets' + os.system(f'mkdir -p ./{LOG_PATH_PHYSIM}') + runLogFile=f'physim_{HTML.testCase_id}.log' + with cls_cmd.getConnection(host) as cmd: + cmd.run(f'sudo {workSpacePath}/ran_build/build/{physim_test} {options} >> {workSpacePath}/{runLogFile}') + cmd.copyin(src=f'{workSpacePath}/{runLogFile}', tgt=f'{LOG_PATH_PHYSIM}/{runLogFile}') + success, msg = cls_analysis.Analysis.analyze_physim(f'{LOG_PATH_PHYSIM}/{runLogFile}', physim_test, options, threshold) + if success: + HTML.CreateHtmlTestRowQueue(options, 'OK', [msg]) + else: + logging.error(msg) + HTML.CreateHtmlTestRowQueue(options, 'KO', [msg]) + return success diff --git a/ci-scripts/cls_oaicitest.py b/ci-scripts/cls_oaicitest.py index f286aa9558..5268a73e9a 100644 --- a/ci-scripts/cls_oaicitest.py +++ b/ci-scripts/cls_oaicitest.py @@ -43,7 +43,6 @@ import json #import our libs import helpreadme as HELP import constants as CONST -import sshconnection import cls_module import cls_cmd @@ -649,7 +648,7 @@ class OaiCiTest(): result = re.search('warning: discard PDU, sn out of window', str(line)) if result is not None: nbPduDiscard += 1 - result = re.search('--nfapi STANDALONE_PNF --node-number 2 --sa', str(line)) + result = re.search('--nfapi STANDALONE_PNF --node-number 2', str(line)) if result is not None: frequency_found = True result = re.search('Exiting OAI softmodem', str(line)) @@ -895,55 +894,43 @@ class OaiCiTest(): SourceCodePath = self.UESourceCodePath else: sys.exit('Insufficient Parameter') - SSH = sshconnection.SSHConnection() - SSH.open(IPAddress, UserName, Password) - SSH.command(f'cd {SourceCodePath}', '\$', 5) - SSH.command('cd cmake_targets', '\$', 5) - SSH.command('rm -f build.log.zip', '\$', 5) - SSH.command('zip -r build.log.zip build_log_*/*', '\$', 60) - SSH.close() + with cls_cmd.getConnection(IPAddress) as cmd: + d = f'{SourceCodePath}/cmake_targets' + cmd.run(f'rm -f {d}/build.log.zip') + cmd.run(f'cd {d} && zip -r build.log.zip build_log_*/*') def LogCollectPing(self,EPC): # Some pipelines are using "none" IP / Credentials # In that case, just forget about it if EPC.IPAddress == 'none': sys.exit(0) - SSH = sshconnection.SSHConnection() - SSH.open(EPC.IPAddress, EPC.UserName, EPC.Password) - SSH.command(f'cd {EPC.SourceCodePath}', '\$', 5) - SSH.command('cd scripts', '\$', 5) - SSH.command('rm -f ping.log.zip', '\$', 5) - SSH.command('zip ping.log.zip ping*.log', '\$', 60) - SSH.command('rm ping*.log', '\$', 5) - SSH.close() + with cls_cmd.getConnection(EPC.IPAddress) as cmd: + d = f"{EPC.SourceCodePath}/scripts" + cmd.run(f'rm -f {d}/ping.log.zip') + cmd.run(f'cd {d} && zip ping.log.zip ping*.log') + cmd.run(f'rm {d}/ping*.log') def LogCollectIperf(self,EPC): # Some pipelines are using "none" IP / Credentials # In that case, just forget about it if EPC.IPAddress == 'none': sys.exit(0) - SSH = sshconnection.SSHConnection() - SSH.open(EPC.IPAddress, EPC.UserName, EPC.Password) - SSH.command(f'cd {EPC.SourceCodePath}', '\$', 5) - SSH.command('cd scripts', '\$', 5) - SSH.command('rm -f iperf.log.zip', '\$', 5) - SSH.command('zip iperf.log.zip iperf*.log', '\$', 60) - SSH.command('rm iperf*.log', '\$', 5) - SSH.close() + with cls_cmd.getConnection(EPC.IPAddress) as cmd: + d = f"{EPC.SourceCodePath}/scripts" + cmd.run(f'rm -f {d}/iperf.log.zip') + cmd.run(f'cd {d} && zip iperf.log.zip iperf*.log') + cmd.run(f'rm {d}/iperf*.log') def LogCollectOAIUE(self): # Some pipelines are using "none" IP / Credentials # In that case, just forget about it if self.UEIPAddress == 'none': sys.exit(0) - SSH = sshconnection.SSHConnection() - SSH.open(self.UEIPAddress, self.UEUserName, self.UEPassword) - SSH.command(f'cd {self.UESourceCodePath}', '\$', 5) - SSH.command(f'cd cmake_targets', '\$', 5) - SSH.command(f'echo {self.UEPassword} | sudo -S rm -f ue.log.zip', '\$', 5) - SSH.command(f'echo {self.UEPassword} | sudo -S zip ue.log.zip ue*.log core* ue_*record.raw ue_*.pcap ue_*txt', '\$', 60) - SSH.command(f'echo {self.UEPassword} | sudo -S rm ue*.log core* ue_*record.raw ue_*.pcap ue_*txt', '\$', 5) - SSH.close() + with cls_cmd.getConnection(self.UEIPAddress) as cmd: + d = f'{self.UESourceCodePath}/cmake_targets' + cmd.run(f'echo {self.UEPassword} | sudo -S rm -f {d}/ue.log.zip') + cmd.run(f'cd {d} && echo {self.UEPassword} | sudo -S zip ue.log.zip ue*.log core* ue_*record.raw ue_*.pcap ue_*txt') + cmd.run(f'echo {self.UEPassword} | sudo -S rm {d}/ue*.log {d}/core* {d}/ue_*record.raw {d}/ue_*.pcap {d}/ue_*txt') def ShowTestID(self): logging.info(f'\u001B[1m----------------------------------------\u001B[0m') diff --git a/ci-scripts/cls_physim.py b/ci-scripts/cls_physim.py deleted file mode 100644 index ccdd34e9a9..0000000000 --- a/ci-scripts/cls_physim.py +++ /dev/null @@ -1,262 +0,0 @@ -# * Licensed to the OpenAirInterface (OAI) Software Alliance under one or more -# * contributor license agreements. See the NOTICE file distributed with -# * this work for additional information regarding copyright ownership. -# * The OpenAirInterface Software Alliance licenses this file to You under -# * the OAI Public License, Version 1.1 (the "License"); you may not use this file -# * except in compliance with the License. -# * You may obtain a copy of the License at -# * -# * http://www.openairinterface.org/?page_id=698 -# * -# * Unless required by applicable law or agreed to in writing, software -# * distributed under the License is distributed on an "AS IS" BASIS, -# * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# * See the License for the specific language governing permissions and -# * limitations under the License. -# *------------------------------------------------------------------------------- -# * For more information about the OpenAirInterface (OAI) Software Alliance: -# * contact@openairinterface.org -# */ -#--------------------------------------------------------------------- -# Python for CI of OAI-eNB + COTS-UE -# -# Required Python Version -# Python 3.x -# -# Required Python Package -# pexpect -#--------------------------------------------------------------------- - -#to use logging.info() -import logging -#to create a SSH object locally in the methods -import sshconnection -#to update the HTML object -import cls_oai_html -import cls_cmd -#for log folder maintenance -import os -import re - -class PhySim: - def __init__(self): - self.buildargs = "" - self.runargs = "" - self.eNBIpAddr = "" - self.eNBUserName = "" - self.eNBPassWord = "" - self.eNBSourceCodePath = "" - self.ranRepository = "" - self.ranBranch = "" - self.ranCommitID= "" - self.ranAllowMerge= "" - self.ranTargetBranch= "" - self.forced_workspace_cleanup=False - #private attributes - self.__workSpacePath='' - self.__buildLogFile='compile_phy_sim.log' - self.__runLogFile='' - self.__runLogPath='phy_sim_logs' - - -#----------------- -#PRIVATE Methods -#----------------- - - def __CheckResults_LDPCcudaTest(self,HTML,CONST,testcase_id): - mySSH = sshconnection.SSHConnection() - mySSH.open(self.eNBIpAddr, self.eNBUserName, self.eNBPassWord) - #retrieve run log file and store it locally$ - mySSH.copyin(self.eNBIpAddr, self.eNBUserName, self.eNBPassWord, self.__workSpacePath+self.__runLogFile, '.') - mySSH.close() - #parse results looking for Encoding and Decoding mean values - runResults=[] - with open(self.__runLogFile) as f: - for line in f: - if 'mean' in line: - runResults.append(line) - #the values are appended for each mean value (2), so we take these 2 values from the list - info = runResults[0] + runResults[1] - - #once parsed move the local logfile to its folder for tidiness - os.system('mv '+self.__runLogFile+' '+ self.__runLogPath+'/.') - - HTML.CreateHtmlTestRowQueue(self.runargs, 'OK', [info]) - return True - - def __CheckResults_LDPCt2Test(self,HTML,CONST,testcase_id): - thrs_KO = int(self.timethrs) - mySSH = cls_cmd.getConnection(self.eNBIpAddr) - #retrieve run log file and store it locally$ - mySSH.copyin(f'{self.__workSpacePath}{self.__runLogFile}', f'{self.__runLogFile}') - mySSH.close() - #parse results looking for encoder/decoder processing time values - - with open(self.__runLogFile) as g: - for line in g: - res_enc = re.search(r"DLSCH encoding time\s+(\d+\.\d+)\s+us",line) - res_dec = re.search(r'ULSCH total decoding time\s+(\d+\.\d+)\s+us',line) - if res_dec is not None: - time = res_dec.group(1) - info = res_dec.group(0) - break - if res_enc is not None: - time = res_enc.group(1) - info = res_enc.group(0) - break - - # In case the T2 board does work properly, there is no statistics - if res_enc is None and res_dec is None: - logging.error(f'no statistics: res_enc {res_enc} res_dec {res_dec}') - HTML.CreateHtmlTestRowQueue(self.runargs, 'KO', ['no statistics']) - os.system(f'mv {self.__runLogFile} {self.__runLogPath}/.') - return False - - #once parsed move the local logfile to its folder - os.system(f'mv {self.__runLogFile} {self.__runLogPath}/.') - success = float(time) < thrs_KO - if success: - HTML.CreateHtmlTestRowQueue(self.runargs, 'OK', [info]) - else: - error_msg = f'Processing time exceeds a limit of {thrs_KO} us' - logging.error(error_msg) - HTML.CreateHtmlTestRowQueue(self.runargs, 'KO', [info + '\n' + error_msg]) - return success - - def __CheckResults_NRulsimTest(self, HTML, CONST, testcase_id): - #retrieve run log file and store it locally - mySSH = sshconnection.SSHConnection() - filename = self.__workSpacePath + self.__runLogFile - ret = mySSH.copyin(self.eNBIpAddr, self.eNBUserName, self.eNBPassWord, filename, '.') - if ret != 0: - error_msg = f'could not recover test result file {filename}' - logging.error(error_msg) - HTML.CreateHtmlTestRowQueue("could not recover results", 'KO', [error_msg]) - return False - - PUSCH_OK = False - with open(self.__runLogFile) as f: - PUSCH_OK = 'PUSCH test OK' in f.read() - - # once parsed move the local logfile to its folder for tidiness - os.system(f'mv {self.__runLogFile} {self.__runLogPath}/.') - - #updating the HTML with results - if PUSCH_OK: - HTML.CreateHtmlTestRowQueue(self.runargs, 'OK', 1, ["succeeded"]) - else: - error_msg = 'error: no "PUSCH test OK"' - logging.error(error_msg) - HTML.CreateHtmlTestRowQueue(self.runargs, 'KO', 1, [error_msg]) - return PUSCH_OK - - def __CheckBuild_PhySim(self, HTML, CONST): - self.__workSpacePath=self.eNBSourceCodePath+'/cmake_targets/' - mySSH = sshconnection.SSHConnection() - mySSH.open(self.eNBIpAddr, self.eNBUserName, self.eNBPassWord) - #retrieve compile log file and store it locally - mySSH.copyin(self.eNBIpAddr, self.eNBUserName, self.eNBPassWord, self.__workSpacePath+self.__buildLogFile, '.') - #delete older run log file - mySSH.command('rm ' + self.__workSpacePath+self.__runLogFile, '\$', 5) - mySSH.close() - #check build result from local compile log file - with open(self.__buildLogFile) as f: - if 'BUILD SHOULD BE SUCCESSFUL' in f.read(): - HTML.CreateHtmlTestRow(self.buildargs, 'OK', CONST.ALL_PROCESSES_OK, 'PhySim') - return True - logging.error('\u001B[1m Building Physical Simulators Failed\u001B[0m') - HTML.CreateHtmlTestRow(self.buildargs, 'KO', CONST.ALL_PROCESSES_OK, 'LDPC') - HTML.CreateHtmlTabFooter(False) - return False - - -#-----------------$ -#PUBLIC Methods$ -#-----------------$ - - def Build_PhySim(self,htmlObj,constObj): - mySSH = sshconnection.SSHConnection() - mySSH.open(self.eNBIpAddr, self.eNBUserName, self.eNBPassWord) - - #create working dir - mySSH.command('mkdir -p ' + self.eNBSourceCodePath, '\$', 5) - mySSH.command('cd ' + self.eNBSourceCodePath, '\$', 5) - - if not self.ranRepository.lower().endswith('.git'): - self.ranRepository+='.git' - - #git clone - mySSH.command('if [ ! -e .git ]; then stdbuf -o0 git clone ' + self.ranRepository + ' .; else stdbuf -o0 git fetch --prune; fi', '\$', 600) - #git config - mySSH.command('git config user.email "jenkins@openairinterface.org"', '\$', 5) - mySSH.command('git config user.name "OAI Jenkins"', '\$', 5) - - #git clean depending on self.forced_workspace_cleanup captured in xml - if self.forced_workspace_cleanup==True: - logging.info('Cleaning workspace ...') - mySSH.command('echo ' + self.eNBPassWord + ' | sudo -S git clean -x -d -ff', '\$', 30) - else: - logging.info('Workspace cleaning was disabled') - - # if the commit ID is provided, use it to point to it - if self.ranCommitID != '': - mySSH.command('git checkout -f ' + self.ranCommitID, '\$', 30) - # if the branch is not develop, then it is a merge request and we need to do - # the potential merge. Note that merge conflicts should have already been checked earlier - if (self.ranAllowMerge): - if self.ranTargetBranch == '': - if (self.ranBranch != 'develop') and (self.ranBranch != 'origin/develop'): - mySSH.command('git merge --ff origin/develop -m "Temporary merge for CI"', '\$', 30) - else: - logging.info('Merging with the target branch: ' + self.ranTargetBranch) - mySSH.command('git merge --ff origin/' + self.ranTargetBranch + ' -m "Temporary merge for CI"', '\$', 30) - - #build - mySSH.command('source oaienv', '\$', 5) - mySSH.command('cd cmake_targets', '\$', 5) - mySSH.command('mkdir -p log', '\$', 5) - mySSH.command(f'./build_oai {self.buildargs} 2>&1 | tee {self.__buildLogFile}', '\$', 1500) - - mySSH.close() - return __CheckBuild_PhySim(htmlObj,constObj) - - - def Run_CUDATest(self,htmlObj,constObj,testcase_id): - self.__workSpacePath = self.eNBSourceCodePath+'/cmake_targets/' - #create run logs folder locally - os.system('mkdir -p ./'+self.__runLogPath) - #log file is tc_.log remotely - self.__runLogFile='physim_'+str(testcase_id)+'.log' - #open a session for test run - mySSH = sshconnection.SSHConnection() - mySSH.open(self.eNBIpAddr, self.eNBUserName, self.eNBPassWord) - mySSH.command('cd '+self.__workSpacePath,'\$',5) - #run and redirect the results to a log file - mySSH.command(self.__workSpacePath+'ran_build/build/ldpctest ' + self.runargs + ' >> '+self.__runLogFile, '\$', 30) - mySSH.close() - return self.__CheckResults_LDPCcudaTest(htmlObj,constObj,testcase_id) - - def Run_T2Test(self,htmlObj,constObj,testcase_id): - self.__workSpacePath = f'{self.eNBSourceCodePath}/cmake_targets/' - #create run logs folder locally - os.system(f'mkdir -p ./{self.__runLogPath}') - #log file is tc_.log remotely - self.__runLogFile=f'physim_{str(testcase_id)}.log' - #open a session for test run - mySSH = cls_cmd.getConnection(self.eNBIpAddr) - mySSH.run(f'cd {self.__workSpacePath}') - #run and redirect the results to a log file - mySSH.run(f'sudo {self.__workSpacePath}ran_build/build/{self.runsim} {self.runargs} > {self.__workSpacePath}{self.__runLogFile} 2>&1') - mySSH.close() - return self.__CheckResults_LDPCt2Test(htmlObj,constObj,testcase_id) - - def Run_NRulsimTest(self, htmlObj, constObj, testcase_id): - self.__workSpacePath=self.eNBSourceCodePath+'/cmake_targets/' - os.system(f'mkdir -p ./{self.__runLogPath}') - self.__runLogFile = f'physim_{testcase_id}.log' - mySSH = sshconnection.SSHConnection() - mySSH.open(self.eNBIpAddr, self.eNBUserName, self.eNBPassWord) - mySSH.command(f'cd {self.__workSpacePath}', '\$', 5) - mySSH.command(f'sudo {self.__workSpacePath}ran_build/build/nr_ulsim {self.runargs} > {self.__runLogFile} 2>&1', '\$', 30) - mySSH.close() - return self.__CheckResults_NRulsimTest(htmlObj, constObj, testcase_id) diff --git a/ci-scripts/conf_files/gnb-cu.sa.band78.106prb.conf b/ci-scripts/conf_files/gnb-cu.sa.band78.106prb.conf index e828389ca8..311c8551fd 100644 --- a/ci-scripts/conf_files/gnb-cu.sa.band78.106prb.conf +++ b/ci-scripts/conf_files/gnb-cu.sa.band78.106prb.conf @@ -1,7 +1,6 @@ Active_gNBs = ( "cu-rfsim"); # Asn1_verbosity, choice in: none, info, annoying Asn1_verbosity = "none"; -Num_Threads_PUSCH = 8; gNBs = ( diff --git a/ci-scripts/conf_files/gnb-cu.sa.f1.conf b/ci-scripts/conf_files/gnb-cu.sa.f1.conf index 2126aac17f..84e5dbadb0 100644 --- a/ci-scripts/conf_files/gnb-cu.sa.f1.conf +++ b/ci-scripts/conf_files/gnb-cu.sa.f1.conf @@ -1,7 +1,6 @@ Active_gNBs = ( "gNB-Eurecom-CU"); # Asn1_verbosity, choice in: none, info, annoying Asn1_verbosity = "none"; -Num_Threads_PUSCH = 8; gNBs = ( diff --git a/ci-scripts/conf_files/gnb-cucp.sa.f1.conf b/ci-scripts/conf_files/gnb-cucp.sa.f1.conf index 66e3522181..28bb7cfc33 100644 --- a/ci-scripts/conf_files/gnb-cucp.sa.f1.conf +++ b/ci-scripts/conf_files/gnb-cucp.sa.f1.conf @@ -1,8 +1,6 @@ Active_gNBs = ( "gNB-OAI"); # Asn1_verbosity, choice in: none, info, annoying Asn1_verbosity = "none"; -Num_Threads_PUSCH = 8; -sa = 1; gNBs = ( diff --git a/ci-scripts/conf_files/gnb-cucp.sa.f1.quectel.conf b/ci-scripts/conf_files/gnb-cucp.sa.f1.quectel.conf index 153e7f77a3..99a530ca39 100644 --- a/ci-scripts/conf_files/gnb-cucp.sa.f1.quectel.conf +++ b/ci-scripts/conf_files/gnb-cucp.sa.f1.quectel.conf @@ -1,8 +1,6 @@ Active_gNBs = ( "gNB-OAI"); # Asn1_verbosity, choice in: none, info, annoying Asn1_verbosity = "none"; -Num_Threads_PUSCH = 8; -sa = 1; gNBs = ( diff --git a/ci-scripts/conf_files/gnb-cuup.sa.f1.conf b/ci-scripts/conf_files/gnb-cuup.sa.f1.conf index a7e2daa298..5dd6c77a9c 100644 --- a/ci-scripts/conf_files/gnb-cuup.sa.f1.conf +++ b/ci-scripts/conf_files/gnb-cuup.sa.f1.conf @@ -1,7 +1,6 @@ Active_gNBs = ( "gNB-OAI"); # Asn1_verbosity, choice in: none, info, annoying Asn1_verbosity = "none"; -sa = 1; gNBs = ( diff --git a/ci-scripts/conf_files/gnb-cuup.sa.f1.quectel.conf b/ci-scripts/conf_files/gnb-cuup.sa.f1.quectel.conf index fa6532be7b..b9f65cdf53 100644 --- a/ci-scripts/conf_files/gnb-cuup.sa.f1.quectel.conf +++ b/ci-scripts/conf_files/gnb-cuup.sa.f1.quectel.conf @@ -1,7 +1,6 @@ Active_gNBs = ( "gNB-OAI"); # Asn1_verbosity, choice in: none, info, annoying Asn1_verbosity = "none"; -sa = 1; gNBs = ( diff --git a/ci-scripts/conf_files/gnb-du.band78.106prb.rfsim.conf b/ci-scripts/conf_files/gnb-du.band78.106prb.rfsim.conf deleted file mode 100644 index 3ee42b4510..0000000000 --- a/ci-scripts/conf_files/gnb-du.band78.106prb.rfsim.conf +++ /dev/null @@ -1,225 +0,0 @@ -Active_gNBs = ( "du-rfsim"); -# Asn1_verbosity, choice in: none, info, annoying -Asn1_verbosity = "none"; - -gNBs = -( - { - ////////// Identification parameters: - gNB_ID = 0xe00; - gNB_DU_ID = 0xe00; - -# cell_type = "CELL_MACRO_GNB"; - - gNB_name = "du-rfsim"; - - // Tracking area code, 0x0000 and 0xfffe are reserved values - tracking_area_code = 1; - plmn_list = ({ mcc = 208; mnc = 99; mnc_length = 2; snssaiList = ({ sst = 1, sd = 0xffffff }) }); - - - nr_cellid = 12345678L; - - ////////// Physical parameters: - - min_rxtxtime = 6; - - servingCellConfigCommon = ( - { - #spCellConfigCommon - - physCellId = 0; - -# downlinkConfigCommon - #frequencyInfoDL - # this is 3600 MHz + 43 PRBs@30kHz SCS (same as initial BWP) - absoluteFrequencySSB = 641280; - dl_frequencyBand = 78; - # this is 3600 MHz - dl_absoluteFrequencyPointA = 640008; - #scs-SpecificCarrierList - dl_offstToCarrier = 0; -# subcarrierSpacing -# 0=kHz15, 1=kHz30, 2=kHz60, 3=kHz120 - dl_subcarrierSpacing = 1; - dl_carrierBandwidth = 106; - #initialDownlinkBWP - #genericParameters - # this is RBstart=27,L=48 (275*(L-1))+RBstart - initialDLBWPlocationAndBandwidth = 28875; # 6366 12925 12956 28875 12952 -# subcarrierSpacing -# 0=kHz15, 1=kHz30, 2=kHz60, 3=kHz120 - initialDLBWPsubcarrierSpacing = 1; - #pdcch-ConfigCommon - initialDLBWPcontrolResourceSetZero = 12; - initialDLBWPsearchSpaceZero = 0; - - #uplinkConfigCommon - #frequencyInfoUL - ul_frequencyBand = 78; - #scs-SpecificCarrierList - ul_offstToCarrier = 0; -# subcarrierSpacing -# 0=kHz15, 1=kHz30, 2=kHz60, 3=kHz120 - ul_subcarrierSpacing = 1; - ul_carrierBandwidth = 106; - pMax = 20; - #initialUplinkBWP - #genericParameters - initialULBWPlocationAndBandwidth = 28875; -# subcarrierSpacing -# 0=kHz15, 1=kHz30, 2=kHz60, 3=kHz120 - initialULBWPsubcarrierSpacing = 1; - #rach-ConfigCommon - #rach-ConfigGeneric - prach_ConfigurationIndex = 98; -#prach_msg1_FDM -#0 = one, 1=two, 2=four, 3=eight - prach_msg1_FDM = 0; - prach_msg1_FrequencyStart = 0; - zeroCorrelationZoneConfig = 13; - preambleReceivedTargetPower = -96; -#preamblTransMax (0...10) = (3,4,5,6,7,8,10,20,50,100,200) - preambleTransMax = 6; -#powerRampingStep -# 0=dB0,1=dB2,2=dB4,3=dB6 - powerRampingStep = 1; -#ra_ReponseWindow -#1,2,4,8,10,20,40,80 - ra_ResponseWindow = 4; -#ssb_perRACH_OccasionAndCB_PreamblesPerSSB_PR -#1=oneeighth,2=onefourth,3=half,4=one,5=two,6=four,7=eight,8=sixteen - ssb_perRACH_OccasionAndCB_PreamblesPerSSB_PR = 4; -#oneHalf (0..15) 4,8,12,16,...60,64 - ssb_perRACH_OccasionAndCB_PreamblesPerSSB = 14; -#ra_ContentionResolutionTimer -#(0..7) 8,16,24,32,40,48,56,64 - ra_ContentionResolutionTimer = 7; - rsrp_ThresholdSSB = 19; -#prach-RootSequenceIndex_PR -#1 = 839, 2 = 139 - prach_RootSequenceIndex_PR = 2; - prach_RootSequenceIndex = 1; - # SCS for msg1, can only be 15 for 30 kHz < 6 GHz, takes precendence over the one derived from prach-ConfigIndex - # - msg1_SubcarrierSpacing = 1, -# restrictedSetConfig -# 0=unrestricted, 1=restricted type A, 2=restricted type B - restrictedSetConfig = 0, - - msg3_DeltaPreamble = 1; - p0_NominalWithGrant =-90; - -# pucch-ConfigCommon setup : -# pucchGroupHopping -# 0 = neither, 1= group hopping, 2=sequence hopping - pucchGroupHopping = 0; - hoppingId = 40; - p0_nominal = -90; - - ssb_PositionsInBurst_Bitmap = 1; - -# ssb_periodicityServingCell -# 0 = ms5, 1=ms10, 2=ms20, 3=ms40, 4=ms80, 5=ms160, 6=spare2, 7=spare1 - ssb_periodicityServingCell = 2; - -# dmrs_TypeA_position -# 0 = pos2, 1 = pos3 - dmrs_TypeA_Position = 0; - -# subcarrierSpacing -# 0=kHz15, 1=kHz30, 2=kHz60, 3=kHz120 - subcarrierSpacing = 1; - - - #tdd-UL-DL-ConfigurationCommon -# subcarrierSpacing -# 0=kHz15, 1=kHz30, 2=kHz60, 3=kHz120 - referenceSubcarrierSpacing = 1; - # pattern1 - # dl_UL_TransmissionPeriodicity - # 0=ms0p5, 1=ms0p625, 2=ms1, 3=ms1p25, 4=ms2, 5=ms2p5, 6=ms5, 7=ms10 - dl_UL_TransmissionPeriodicity = 6; - nrofDownlinkSlots = 7; - nrofDownlinkSymbols = 6; - nrofUplinkSlots = 2; - nrofUplinkSymbols = 4; - - ssPBCH_BlockPower = -25; - } - - ); - - - # ------- SCTP definitions - SCTP : - { - # Number of streams to use in input/output - SCTP_INSTREAMS = 2; - SCTP_OUTSTREAMS = 2; - }; - } -); - -MACRLCs = ( - { - num_cc = 1; - tr_s_preference = "local_L1"; - tr_n_preference = "f1"; - local_n_address = "192.168.72.142"; - remote_n_address = "192.168.72.140"; - local_n_portc = 500; - local_n_portd = 2152; - remote_n_portc = 501; - remote_n_portd = 2152; - pusch_TargetSNRx10 = 200; - pucch_TargetSNRx10 = 200; - } -); - -L1s = ( -{ - num_cc = 1; - tr_n_preference = "local_mac"; - prach_dtx_threshold = 200; - pucch0_dtx_threshold = 150; - ofdm_offset_divisor = 8; #set this to UINT_MAX for offset 0 -} -); - -RUs = ( - { - local_rf = "yes" - nb_tx = 1 - nb_rx = 1 - att_tx = 0 - att_rx = 0; - bands = [78]; - max_pdschReferenceSignalPower = -27; - max_rxgain = 114; - eNB_instances = [0]; - clock_src = "internal"; - } -); - - -rfsimulator: { - serveraddr = "server"; - serverport = 4043; - options = (); #("saviq"); or/and "chanmod" - modelname = "AWGN"; - IQfile = "/tmp/rfsimulator.iqs" -} - -log_config : -{ - global_log_level = "info"; - hw_log_level = "info"; - nr_phy_log_level = "info"; - nr_mac_log_level = "info"; - rlc_log_level = "info"; - pdcp_log_level = "info"; - rrc_log_level = "info"; - f1ap_log_level = "info"; - ngap_log_level = "debug"; -}; diff --git a/ci-scripts/conf_files/gnb-vnf.sa.band78.273prb.aerial.conf b/ci-scripts/conf_files/gnb-vnf.sa.band78.273prb.aerial.conf index 4250ec5571..c035882d36 100644 --- a/ci-scripts/conf_files/gnb-vnf.sa.band78.273prb.aerial.conf +++ b/ci-scripts/conf_files/gnb-vnf.sa.band78.273prb.aerial.conf @@ -2,7 +2,6 @@ Active_gNBs = ( "gNB-OAI"); # Asn1_verbosity, choice in: none, info, annoying Asn1_verbosity = "none"; -sa = 1; nfapi = "AERIAL"; gNBs = diff --git a/ci-scripts/conf_files/gnb.sa.band261.u3.32prb.rfsim.conf b/ci-scripts/conf_files/gnb.sa.band261.u3.32prb.rfsim.conf index 2e707d9765..ee34e315bb 100644 --- a/ci-scripts/conf_files/gnb.sa.band261.u3.32prb.rfsim.conf +++ b/ci-scripts/conf_files/gnb.sa.band261.u3.32prb.rfsim.conf @@ -2,8 +2,6 @@ Active_gNBs = ( "gNB-OAI"); # Asn1_verbosity, choice in: none, info, annoying Asn1_verbosity = "none"; -sa = 1; - gNBs = ( { diff --git a/ci-scripts/conf_files/gnb.sa.band77.162prb.usrpn310.2x2.conf b/ci-scripts/conf_files/gnb.sa.band77.162prb.usrpn310.2x2.conf index 1612b12ebd..fa1625fcf2 100644 --- a/ci-scripts/conf_files/gnb.sa.band77.162prb.usrpn310.2x2.conf +++ b/ci-scripts/conf_files/gnb.sa.band77.162prb.usrpn310.2x2.conf @@ -2,7 +2,6 @@ Active_gNBs = ( "gNB-OAI"); # Asn1_verbosity, choice in: none, info, annoying Asn1_verbosity = "none"; -sa = 1; usrp-tx-thread-config = 1; tune-offset = 30720000; @@ -21,7 +20,6 @@ gNBs = ////////// Physical parameters: - ssb_SubcarrierOffset = 0; pdsch_AntennaPorts_XP = 2; pusch_AntennaPorts = 2; do_CSIRS = 1; @@ -35,9 +33,9 @@ gNBs = # downlinkConfigCommon #frequencyInfoDL - # this is 3300.60 MHz + 81*12*30e-3 MHz = 3329.76 + # this is 4100.16 MHz absoluteFrequencySSB = 673344; - # this is 3300.60 MHz + # this is 4071 MHz dl_absoluteFrequencyPointA = 671400; dl_frequencyBand = 77; #scs-SpecificCarrierList diff --git a/ci-scripts/conf_files/gnb.sa.band78.106prb.l2sim.conf b/ci-scripts/conf_files/gnb.sa.band77.162prb.usrpn310.4x4.conf similarity index 69% rename from ci-scripts/conf_files/gnb.sa.band78.106prb.l2sim.conf rename to ci-scripts/conf_files/gnb.sa.band77.162prb.usrpn310.4x4.conf index 6b3f490a82..d9aec14092 100644 --- a/ci-scripts/conf_files/gnb.sa.band78.106prb.l2sim.conf +++ b/ci-scripts/conf_files/gnb.sa.band77.162prb.usrpn310.4x4.conf @@ -1,23 +1,31 @@ -Active_gNBs = ( "gnb-l2sim-vnf"); +Active_gNBs = ( "gNB-OAI"); # Asn1_verbosity, choice in: none, info, annoying Asn1_verbosity = "none"; +usrp-tx-thread-config = 1; +tune-offset = 30720000; + gNBs = ( { ////////// Identification parameters: gNB_ID = 0xe00; - gNB_name = "gnb-l2sim-vnf"; + gNB_name = "gNB-OAI"; // Tracking area code, 0x0000 and 0xfffe are reserved values tracking_area_code = 1; - plmn_list = ({ mcc = 208; mnc = 99; mnc_length = 2; snssaiList = ({ sst = 1, sd = 0xffffff }) }); + plmn_list = ({ mcc = 208; mnc = 97; mnc_length = 2; snssaiList = ({ sst = 1; }) }); nr_cellid = 12345678L; ////////// Physical parameters: - min_rxtxtime = 6; + pdsch_AntennaPorts_XP = 2; + pusch_AntennaPorts = 4; + pdsch_AntennaPorts_N1 = 2; + maxMIMO_layers = 4; + do_CSIRS = 1; + do_SRS = 1; servingCellConfigCommon = ( { @@ -27,44 +35,45 @@ gNBs = # downlinkConfigCommon #frequencyInfoDL - # this is 3600 MHz + 43 PRBs@30kHz SCS (same as initial BWP) - absoluteFrequencySSB = 641280; - dl_frequencyBand = 78; - # this is 3600 MHz - dl_absoluteFrequencyPointA = 640008; + # this is 4100.16 MHz + absoluteFrequencySSB = 673344; + # this is 4071 MHz + dl_absoluteFrequencyPointA = 671400; + dl_frequencyBand = 77; #scs-SpecificCarrierList dl_offstToCarrier = 0; # subcarrierSpacing # 0=kHz15, 1=kHz30, 2=kHz60, 3=kHz120 dl_subcarrierSpacing = 1; - dl_carrierBandwidth = 106; + dl_carrierBandwidth = 162; #initialDownlinkBWP #genericParameters - # this is RBstart=27,L=48 (275*(L-1))+RBstart - initialDLBWPlocationAndBandwidth = 12952; # 6366 12925 12956 28875 12952 + # this is RBstart=0,L=162 (275*(275-L+1))+(274-RBstart)) + initialDLBWPlocationAndBandwidth = 31624; + # # subcarrierSpacing # 0=kHz15, 1=kHz30, 2=kHz60, 3=kHz120 - initialDLBWPsubcarrierSpacing = 1; + initialDLBWPsubcarrierSpacing = 1; #pdcch-ConfigCommon - initialDLBWPcontrolResourceSetZero = 12; - initialDLBWPsearchSpaceZero = 0; + initialDLBWPcontrolResourceSetZero = 12; + initialDLBWPsearchSpaceZero = 0; #uplinkConfigCommon #frequencyInfoUL - ul_frequencyBand = 78; + ul_frequencyBand = 77; #scs-SpecificCarrierList - ul_offstToCarrier = 0; + ul_offstToCarrier = 0; # subcarrierSpacing # 0=kHz15, 1=kHz30, 2=kHz60, 3=kHz120 - ul_subcarrierSpacing = 1; - ul_carrierBandwidth = 106; + ul_subcarrierSpacing = 1; + ul_carrierBandwidth = 162; pMax = 20; #initialUplinkBWP - #genericParameters - initialULBWPlocationAndBandwidth = 12952; + #genericParameters + initialULBWPlocationAndBandwidth = 31624; # subcarrierSpacing # 0=kHz15, 1=kHz30, 2=kHz60, 3=kHz120 - initialULBWPsubcarrierSpacing = 1; + initialULBWPsubcarrierSpacing = 1; #rach-ConfigCommon #rach-ConfigGeneric prach_ConfigurationIndex = 98; @@ -72,7 +81,7 @@ gNBs = #0 = one, 1=two, 2=four, 3=eight prach_msg1_FDM = 0; prach_msg1_FrequencyStart = 0; - zeroCorrelationZoneConfig = 13; + zeroCorrelationZoneConfig = 12; preambleReceivedTargetPower = -96; #preamblTransMax (0...10) = (3,4,5,6,7,8,10,20,50,100,200) preambleTransMax = 6; @@ -84,9 +93,9 @@ gNBs = ra_ResponseWindow = 4; #ssb_perRACH_OccasionAndCB_PreamblesPerSSB_PR #1=oneeighth,2=onefourth,3=half,4=one,5=two,6=four,7=eight,8=sixteen - ssb_perRACH_OccasionAndCB_PreamblesPerSSB_PR = 4; + ssb_perRACH_OccasionAndCB_PreamblesPerSSB_PR = 3; #oneHalf (0..15) 4,8,12,16,...60,64 - ssb_perRACH_OccasionAndCB_PreamblesPerSSB = 14; + ssb_perRACH_OccasionAndCB_PreamblesPerSSB = 15; #ra_ContentionResolutionTimer #(0..7) 8,16,24,32,40,48,56,64 ra_ContentionResolutionTimer = 7; @@ -110,7 +119,7 @@ gNBs = # 0 = neither, 1= group hopping, 2=sequence hopping pucchGroupHopping = 0; hoppingId = 40; - p0_nominal = -90; + p0_nominal = -70; ssb_PositionsInBurst_Bitmap = 1; @@ -134,13 +143,13 @@ gNBs = # pattern1 # dl_UL_TransmissionPeriodicity # 0=ms0p5, 1=ms0p625, 2=ms1, 3=ms1p25, 4=ms2, 5=ms2p5, 6=ms5, 7=ms10 - dl_UL_TransmissionPeriodicity = 6; - nrofDownlinkSlots = 7; + dl_UL_TransmissionPeriodicity = 5; + nrofDownlinkSlots = 3; nrofDownlinkSymbols = 6; - nrofUplinkSlots = 2; + nrofUplinkSlots = 1; nrofUplinkSymbols = 4; - ssPBCH_BlockPower = -25; + ssPBCH_BlockPower = -25; } ); @@ -156,58 +165,85 @@ gNBs = ////////// AMF parameters: - amf_ip_address = ({ ipv4 = "192.168.71.132"; }); - + amf_ip_address = ({ ipv4 = "192.168.61.132"; }); NETWORK_INTERFACES : { - GNB_IPV4_ADDRESS_FOR_NG_AMF = "172.21.16.128"; - GNB_IPV4_ADDRESS_FOR_NGU = "172.21.16.128"; - GNB_PORT_FOR_NGU = 2152; # Spec 2152 + GNB_IPV4_ADDRESS_FOR_NG_AMF = "192.168.61.129/26"; + GNB_IPV4_ADDRESS_FOR_NGU = "192.168.61.129/26"; + GNB_PORT_FOR_S1U = 2152; # Spec 2152 }; } ); MACRLCs = ( - { - num_cc = 1; - remote_s_address = "127.0.0.1"; // pnf addr [!] - local_s_address = "127.0.0.2"; // vnf addr - local_s_portc = 50601; // vnf p5 port - remote_s_portc = 50600; // pnf p5 port [!] - local_s_portd = 50611; // vnf p7 port [!] - remote_s_portd = 50610; // pnf p7 port [!] - tr_s_preference = "nfapi"; - tr_n_preference = "local_RRC"; - } +{ + num_cc = 1; + tr_s_preference = "local_L1"; + tr_n_preference = "local_RRC"; + pusch_TargetSNRx10 = 250; + pucch_TargetSNRx10 = 250; + pusch_FailureThres = 100; + ul_max_mcs = 28; +} +); + +L1s = ( +{ + num_cc = 1; + tr_n_preference = "local_mac"; + prach_dtx_threshold = 120; + pusch_dtx_threshold = 20; + max_ldpc_iterations = 10; +} +); + +RUs = ( +{ + local_rf = "yes" + nb_tx = 4; + nb_rx = 4; + att_tx = 0; + att_rx = 0; + bands = [77]; + max_pdschReferenceSignalPower = -27; + max_rxgain = 75; + eNB_instances = [0]; + ##beamforming 1x2 matrix: 1 layer x 2 antennas + bf_weights = [0x00007fff, 0x0000, 0x00007fff, 0x0000]; + #clock_src = "internal"; + sdr_addrs = "addr=192.168.80.53, clock_source=internal,time_source=internal" + +} ); security = { # preferred ciphering algorithms # the first one of the list that an UE supports in chosen # valid values: nea0, nea1, nea2, nea3 - ciphering_algorithms = ( "nea0" ); + ciphering_algorithms = ( "nea1", "nea0" ); # preferred integrity algorithms # the first one of the list that an UE supports in chosen # valid values: nia0, nia1, nia2, nia3 - integrity_algorithms = ( "nia2", "nia0" ); + integrity_algorithms = ( "nia1", "nia0" ); # setting 'drb_ciphering' to "no" disables ciphering for DRBs, no matter # what 'ciphering_algorithms' configures; same thing for 'drb_integrity' drb_ciphering = "yes"; - drb_integrity = "no"; + drb_integrity = "yes"; }; - log_config : - { - global_log_level ="info"; - hw_log_level ="info"; - phy_log_level ="info"; - mac_log_level ="info"; - rlc_log_level ="info"; - pdcp_log_level ="info"; - rrc_log_level ="info"; - ngap_log_level ="debug"; - }; +log_config : +{ + global_log_level ="info"; + hw_log_level ="info"; + phy_log_level ="info"; + mac_log_level ="info"; + rlc_log_level ="info"; + pdcp_log_level ="info"; + rrc_log_level ="info"; + ngap_log_level ="debug"; + f1ap_log_level ="debug"; +}; diff --git a/ci-scripts/conf_files/gnb.sa.band77.273prb.usrpn310.2x2.conf b/ci-scripts/conf_files/gnb.sa.band77.273prb.usrpn310.2x2.conf index f993f225c9..7cc6a172aa 100644 --- a/ci-scripts/conf_files/gnb.sa.band77.273prb.usrpn310.2x2.conf +++ b/ci-scripts/conf_files/gnb.sa.band77.273prb.usrpn310.2x2.conf @@ -2,7 +2,6 @@ Active_gNBs = ( "gNB-OAI"); # Asn1_verbosity, choice in: none, info, annoying Asn1_verbosity = "none"; -sa = 1; usrp-tx-thread-config = 1; gNBs = ( @@ -32,10 +31,10 @@ gNBs = ( # downlinkConfigCommon # frequencyInfoDL - # this is 3900.60 MHz + (134 PRBs + 4 SCs)@30kHz SCS (GSCN: 8158) + # this is 4100.16 MHz absoluteFrequencySSB = 673344; dl_frequencyBand = 77; - # this is 3900.60 MHz + # this is 4051.02 MHz dl_absoluteFrequencyPointA = 670068; # scs-SpecificCarrierList diff --git a/ci-scripts/conf_files/untested/gNB_SA_n78_133PRB.2x2_usrpn310.conf b/ci-scripts/conf_files/untested/gNB_SA_n78_133PRB.2x2_usrpn310.conf index 6fe39879de..4e8c55851e 100644 --- a/ci-scripts/conf_files/untested/gNB_SA_n78_133PRB.2x2_usrpn310.conf +++ b/ci-scripts/conf_files/untested/gNB_SA_n78_133PRB.2x2_usrpn310.conf @@ -1,7 +1,6 @@ Active_gNBs = ( "gNB-OAI"); # Asn1_verbosity, choice in: none, info, annoying Asn1_verbosity = "none"; -Num_Threads_PUSCH = 8; gNBs = ( diff --git a/ci-scripts/main.py b/ci-scripts/main.py index 3904ac908d..2e595aa834 100644 --- a/ci-scripts/main.py +++ b/ci-scripts/main.py @@ -39,14 +39,12 @@ import constants as CONST import cls_oaicitest #main class for OAI CI test framework -import cls_physim #class PhySim for physical simulators build and test import cls_containerize #class Containerize for all container-based operations on RAN/UE objects import cls_static_code_analysis #class for static code analysis import cls_physim1 #class PhySim for physical simulators deploy and run import cls_cluster # class for building/deploying on cluster import cls_native # class for all native/source-based operations -import sshconnection import epc import ran import cls_oai_html @@ -87,7 +85,6 @@ def CheckClassValidity(xml_class_list,action,id): resp=True return resp - #assigning parameters to object instance attributes (even if the attributes do not exist !!) def AssignParams(params_dict): @@ -95,12 +92,8 @@ def AssignParams(params_dict): setattr(CiTestObj, key, value) setattr(RAN, key, value) setattr(HTML, key, value) - setattr(ldpc, key, value) - - def ExecuteActionWithParam(action): - global SSH global EPC global RAN global HTML @@ -108,7 +101,6 @@ def ExecuteActionWithParam(action): global SCA global PHYSIM global CLUSTER - global ldpc if action == 'Build_eNB' or action == 'Build_Image' or action == 'Build_Proxy' or action == "Build_Cluster_Image" or action == "Build_Run_Tests": RAN.Build_eNB_args=test.findtext('Build_eNB_args') CONTAINERS.imageKind=test.findtext('kind') @@ -289,18 +281,6 @@ def ExecuteActionWithParam(action): st = test.findtext('idle_sleep_time_in_sec') or "5" success = cls_oaicitest.IdleSleep(HTML, int(st)) - elif action == 'Build_PhySim': - ldpc.buildargs = test.findtext('physim_build_args') - forced_workspace_cleanup = test.findtext('forced_workspace_cleanup') - if (forced_workspace_cleanup is None): - ldpc.forced_workspace_cleanup=False - else: - if re.match('true', forced_workspace_cleanup, re.IGNORECASE): - ldpc.forced_workspace_cleanup=True - else: - ldpc.forced_workspace_cleanup=False - success = ldpc.Build_PhySim(HTML,CONST) - elif action == 'Deploy_Run_PhySim': success = PHYSIM.Deploy_PhySim(HTML) @@ -377,16 +357,11 @@ def ExecuteActionWithParam(action): elif action == 'Create_Workspace': success = CONTAINERS.Create_Workspace(HTML) - elif action == 'Run_CUDATest' or action == 'Run_NRulsimTest' or action == 'Run_T2Test': - ldpc.runargs = test.findtext('physim_run_args') - ldpc.runsim = test.findtext('physim_run') - ldpc.timethrs = test.findtext('physim_time_threshold') - if action == 'Run_CUDATest': - success = ldpc.Run_CUDATest(HTML,CONST,id) - elif action == 'Run_NRulsimTest': - success = ldpc.Run_NRulsimTest(HTML,CONST,id) - elif action == 'Run_T2Test': - success = ldpc.Run_T2Test(HTML,CONST,id) + elif action == 'Run_Physim': + physim_options = test.findtext('physim_run_args') + physim_test = test.findtext('physim_test') + physim_threshold = test.findtext('physim_time_threshold') or 'inf' + success = cls_native.Native.Run_Physim(HTML, RAN.eNBIPAddress, RAN.eNBSourceCodePath, physim_options, physim_test, physim_threshold) elif action == 'LicenceAndFormattingCheck': success = SCA.LicenceAndFormattingCheck(HTML) @@ -484,7 +459,6 @@ mode = '' CiTestObj = cls_oaicitest.OaiCiTest() -SSH = sshconnection.SSHConnection() EPC = epc.EPCManagement() RAN = ran.RANManagement() HTML = cls_oai_html.HTMLManagement() @@ -493,15 +467,12 @@ SCA = cls_static_code_analysis.StaticCodeAnalysis() PHYSIM = cls_physim1.PhySim() CLUSTER = cls_cluster.Cluster() -ldpc=cls_physim.PhySim() #create an instance for LDPC test using GPU or CPU build - - #----------------------------------------------------------- # Parsing Command Line Arguments #----------------------------------------------------------- import args_parse -py_param_file_present, py_params, mode = args_parse.ArgsParse(sys.argv,CiTestObj,RAN,HTML,EPC,ldpc,CONTAINERS,HELP,SCA,PHYSIM,CLUSTER) +py_param_file_present, py_params, mode = args_parse.ArgsParse(sys.argv,CiTestObj,RAN,HTML,EPC,CONTAINERS,HELP,SCA,PHYSIM,CLUSTER) @@ -696,26 +667,6 @@ elif re.match('^TesteNB$', mode, re.IGNORECASE) or re.match('^TestUE$', mode, re HTML.CreateHtmlTabHeader() - # On CI bench w/ containers, we need to validate if IP routes are set - if EPC.IPAddress == '172.21.16.136': - CONTAINERS.CheckAndAddRoute('porcepix', EPC.IPAddress, EPC.UserName, EPC.Password) - if EPC.IPAddress == '172.21.16.137': - CONTAINERS.CheckAndAddRoute('nepes', EPC.IPAddress, EPC.UserName, EPC.Password) - if CONTAINERS.eNBIPAddress == '172.21.16.127': - CONTAINERS.CheckAndAddRoute('asterix', CONTAINERS.eNBIPAddress, CONTAINERS.eNBUserName, CONTAINERS.eNBPassword) - if CONTAINERS.eNB1IPAddress == '172.21.16.127': - CONTAINERS.CheckAndAddRoute('asterix', CONTAINERS.eNB1IPAddress, CONTAINERS.eNB1UserName, CONTAINERS.eNB1Password) - if CONTAINERS.eNBIPAddress == '172.21.16.128': - CONTAINERS.CheckAndAddRoute('obelix', CONTAINERS.eNBIPAddress, CONTAINERS.eNBUserName, CONTAINERS.eNBPassword) - if CONTAINERS.eNB1IPAddress == '172.21.16.128': - CONTAINERS.CheckAndAddRoute('obelix', CONTAINERS.eNB1IPAddress, CONTAINERS.eNB1UserName, CONTAINERS.eNB1Password) - if CONTAINERS.eNBIPAddress == '172.21.16.109' or CONTAINERS.eNBIPAddress == 'ofqot': - CONTAINERS.CheckAndAddRoute('ofqot', CONTAINERS.eNBIPAddress, CONTAINERS.eNBUserName, CONTAINERS.eNBPassword) - if CONTAINERS.eNBIPAddress == '172.21.16.137': - CONTAINERS.CheckAndAddRoute('nepes', CONTAINERS.eNBIPAddress, CONTAINERS.eNBUserName, CONTAINERS.eNBPassword) - if CONTAINERS.eNB1IPAddress == '172.21.16.137': - CONTAINERS.CheckAndAddRoute('nepes', CONTAINERS.eNB1IPAddress, CONTAINERS.eNB1UserName, CONTAINERS.eNB1Password) - task_set_succeeded = True HTML.startTime=int(round(time.time() * 1000)) diff --git a/ci-scripts/scripts/create_workspace.sh b/ci-scripts/scripts/create_workspace.sh index 925f606b16..c8410802db 100755 --- a/ci-scripts/scripts/create_workspace.sh +++ b/ci-scripts/scripts/create_workspace.sh @@ -15,7 +15,7 @@ ref=$3 merge=$4 rm -rf ${dir} -git clone --filter=blob:none -n -b develop ${repo} ${dir} +git clone --filter=blob:none -n ${repo} ${dir} cd ${dir} git config user.email "jenkins@openairinterface.org" git config user.name "OAI Jenkins" diff --git a/ci-scripts/tests/README.md b/ci-scripts/tests/README.md index f926ea4ac5..364cf031d3 100644 --- a/ci-scripts/tests/README.md +++ b/ci-scripts/tests/README.md @@ -3,18 +3,28 @@ scripts. # Unit test -There are some unit tests. From the parent directory, i.e., `ci-scripts/`, -start with +This repository contains unit tests. To run them, switch to the parent +directory, i.e., `ci-scripts/`, and run + python3 -m unittest tests/*.py + +To run individual unit tests, start them like so: + + python tests/build.py -v + python tests/cmd.py -v python tests/deployment.py -v - python tests/ping-iperf.py -v python tests/iperf-analysis.py -v + python tests/ping-iperf.py -v -It will indicate if all tests passed. It assumes that these images are present: +The logs will indicate if all tests passed. `tests/deployment.py` requires +these images to be present: - `oai-ci/oai-nr-ue:develop-12345678` - `oai-ci/oai-gnb:develop-12345678` +It will try to download `oaisoftwarealliance/oai-{gnb,nr-ue}:develop` +automatically and retag the images. + # test-runner test This is not a true test, because the results need to be manually inspected. To diff --git a/ci-scripts/tests/build.py b/ci-scripts/tests/build.py new file mode 100644 index 0000000000..669e6711b4 --- /dev/null +++ b/ci-scripts/tests/build.py @@ -0,0 +1,40 @@ +import sys +import logging +logging.basicConfig( + level=logging.DEBUG, + stream=sys.stdout, + format="[%(asctime)s] %(levelname)8s: %(message)s" +) +import unittest +import tempfile + +sys.path.append('./') # to find OAI imports below +import cls_oai_html +import cls_containerize +import cls_cmd + +class TestBuild(unittest.TestCase): + def setUp(self): + self.html = cls_oai_html.HTMLManagement() + self.html.testCase_id = "000000" + self.cont = cls_containerize.Containerize() + self.cont.eNB_serverId[0] = '0' + self.cont.eNBIPAddress = 'localhost' + self.cont.eNBUserName = None + self.cont.eNBPassword = None + self._d = tempfile.mkdtemp() + logging.warning(f"temporary directory: {self._d}") + self.cont.eNBSourceCodePath = self._d + + def tearDown(self): + logging.warning(f"removing directory contents") + with cls_cmd.getConnection(None) as cmd: + cmd.run(f"rm -rf {self._d}") + + def test_build_proxy(self): + self.cont.proxyCommit = "b64d9bce986b38ca59e8582864ade3fcdd05c0dc" + success = self.cont.BuildProxy(self.html) + self.assertTrue(success) + +if __name__ == '__main__': + unittest.main() diff --git a/ci-scripts/tests/deployment.py b/ci-scripts/tests/deployment.py index a6cf8e06b0..47e459d6a4 100644 --- a/ci-scripts/tests/deployment.py +++ b/ci-scripts/tests/deployment.py @@ -15,9 +15,24 @@ import cls_oai_html import cls_oaicitest import cls_containerize import ran +import cls_cmd class TestDeploymentMethods(unittest.TestCase): + def _pull_image(self, cmd, image): + ret = cmd.run(f"docker inspect oai-ci/{image}:develop-12345678") + if ret.returncode == 0: # exists + return + ret = cmd.run(f"docker pull oaisoftwarealliance/{image}:develop") + self.assertEqual(ret.returncode, 0) + ret = cmd.run(f"docker tag oaisoftwarealliance/{image}:develop oai-ci/{image}:develop-12345678") + self.assertEqual(ret.returncode, 0) + ret = cmd.run(f"docker rmi oaisoftwarealliance/{image}:develop") + self.assertEqual(ret.returncode, 0) + def setUp(self): + with cls_cmd.getConnection("localhost") as cmd: + self._pull_image(cmd, "oai-gnb") + self._pull_image(cmd, "oai-nr-ue") self.html = cls_oai_html.HTMLManagement() self.html.testCaseId = "000000" self.ci = cls_oaicitest.OaiCiTest() diff --git a/ci-scripts/xml_class_list.yml b/ci-scripts/xml_class_list.yml index 325797c29e..a526058af0 100755 --- a/ci-scripts/xml_class_list.yml +++ b/ci-scripts/xml_class_list.yml @@ -1,10 +1,7 @@ - Build_Proxy - Build_Cluster_Image - Pull_Cluster_Image - - Build_PhySim - - Run_CUDATest - - Run_T2Test - - Run_NRulsimTest + - Run_Physim - Build_eNB - Initialize_eNB - Terminate_eNB diff --git a/ci-scripts/xml_files/container_5g_l2sim_tdd.xml b/ci-scripts/xml_files/container_5g_l2sim_tdd.xml deleted file mode 100644 index c3e4662294..0000000000 --- a/ci-scripts/xml_files/container_5g_l2sim_tdd.xml +++ /dev/null @@ -1,133 +0,0 @@ - - - l2sim-5gnr-tdd - Testing 5G NR L2 sim - TDD gNB - wrench - - 111111 - 800813 - 000000 - 000001 - 000002 - 000003 - 000004 - 020001 - 020002 - 100001 - 222222 - - - - - Pull_Local_Registry - Pull Images from Local Registry - 0 - oai-gnb-asan oai-nr-ue-asan - - - Create_Workspace - Create new Workspace - 0 - 0 - - - Deploy_Object - Deploy MySql Database - ci-scripts/yaml_files/5g_l2sim_tdd - mysql - 0 - 0 - - - - Deploy_Object - Deploy OAI 5G CoreNetwork - ci-scripts/yaml_files/5g_l2sim_tdd - oai-amf oai-smf oai-upf oai-ext-dn - 0 - 0 - - - - Deploy_Object - Deploy OAI 5G gNB L2 sim SA - ci-scripts/yaml_files/5g_l2sim_tdd - oai-gnb - 0 - 0 - - - - Deploy_Object - Deploy OAI 5G NR-UE L2 sim SA and Proxy - ci-scripts/yaml_files/5g_l2sim_tdd - proxy oai-nr-ue0 - 0 - 0 - - - - Attach_UE - Attach OAI UE - l2sim5g_ue - localhost - - - - Ping - Ping ext-dn from NR-UE - l2sim5g_ue - localhost - -c 20 192.168.72.135 - 5 - - - - Ping - Ping NR-UE from ext-dn - l2sim5g_ext_dn - localhost - -c 20 12.1.1.2 - 5 - - - - Undeploy_Object - true - Undeploy all OAI 5G stack - ci-scripts/yaml_files/5g_l2sim_tdd - 20,50,100,100 - 0,0,0,0 - 0 - 0 - - - - Clean_Test_Server_Images - true - Clean Test Images on Test Server - 0 - - - diff --git a/ci-scripts/xml_files/container_5g_rfsim_f1_accelleran.xml b/ci-scripts/xml_files/container_5g_rfsim_f1_accelleran.xml deleted file mode 100644 index c8dc1cf9b2..0000000000 --- a/ci-scripts/xml_files/container_5g_rfsim_f1_accelleran.xml +++ /dev/null @@ -1,92 +0,0 @@ - - - rfsim-5gnr-f1-accelleran - F1 DU Interop Accelleran CU - wrench - - 111111 - 800813 - 000020 - 000021 - 020021 - 100021 - 100022 - 222222 - - - - - Pull_Local_Registry - Pull Images from Local Registry - 0 - oai-gnb oai-nr-ue - - - Create_Workspace - Create new Workspace - 0 - 0 - - - Deploy_Object - Deploy OAI-DU+nrUE - ci-scripts/yaml_files/5g_rfsimulator_accelleran - oai-du oai-nr-ue - 0 - 0 - - - - Attach_UE - Attach OAI UE (Wait for IP) - rfsim5g_ue - ofqot - - - - Ping - Test Connectivity (ping) - rfsim5g_ue - ofqot - -c 20 12.1.1.1 - 0 - - - - Undeploy_Object - true - Undeploy all OAI 5G stack - ci-scripts/yaml_files/5g_rfsimulator_accelleran - 0 - 0 - - - - Clean_Test_Server_Images - true - Clean Test Images on Test Server - 0 - - - diff --git a/ci-scripts/xml_files/container_l2sim_proxy.xml b/ci-scripts/xml_files/container_l2sim_proxy.xml index ead040de82..197baf429b 100644 --- a/ci-scripts/xml_files/container_l2sim_proxy.xml +++ b/ci-scripts/xml_files/container_l2sim_proxy.xml @@ -25,17 +25,10 @@ Build L2sim proxy image wrench - 100001 000001 - - Create_Workspace - Create new Workspace - 1 - 1 - Build_Proxy Build L2sim Proxy Image diff --git a/ci-scripts/xml_files/container_sa_n310_4X4_60MHz_quectel.xml b/ci-scripts/xml_files/container_sa_n310_4X4_60MHz_quectel.xml new file mode 100644 index 0000000000..0ffe3044b6 --- /dev/null +++ b/ci-scripts/xml_files/container_sa_n310_4X4_60MHz_quectel.xml @@ -0,0 +1,163 @@ + + + TEST-SA-FR1-N310-4x4-60MHz + 60 MHz 4x4 TDD SA + tasks + + 100000 + 111111 + 010010 + 800813 + 030101 + 010001 + 050001 + 071000 + 071001 + 070002 + 010010 + 000001 + 030201 + 200000 + 333333 + + + + + Pull_Cluster_Image + Pull Images from Cluster + oai-gnb + matix + + + + Custom_Command + Disable Sleep States + matix + sudo cpupower idle-set -D 0 + + + + Custom_Command + true + Enable Sleep States + matix + sudo cpupower idle-set -E + + + + Attach_UE + Attach UE + up2 + + + + Detach_UE + true + Detach UE + up2 + + + Create_Workspace + Create new Workspace + 0 + 0 + + + Deploy_Object + Deploy gNB (TDD/Band77/60MHz/N310) in a container + ci-scripts/yaml_files/5g_sa_n310_4x4_60MHz + 0 + 0 + + + + IdleSleep + Sleep + 5 + + + + IdleSleep + Sleep + 10 + + + + Ping + Ping: 100pings in 20sec + up2 + -c 100 -i 0.2 %cn_ip% + 1 + 15 + + + + Iperf + iperf (DL/480Mbps/UDP)(30 sec)(single-ue profile) + -u -b 480M -t 30 -R + matix-cn5g + up2 + 25 + 80 + + + + Iperf + iperf (UL/120Mbps/UDP)(30 sec)(single-ue profile) + -u -b 120M -t 30 + matix-cn5g + up2 + 10 + 70 + + + + Iperf + iperf (BIDIR TCP)(30 sec)(single-ue profile) + -t 30 --bidir + matix-cn5g + up2 + + + + Undeploy_Object + true + Undeploy gNB + ci-scripts/yaml_files/5g_sa_n310_4x4_60MHz + 0 + 0 + oai-gnb + 10,100,100,100 + 10,100,100,100 + + + + Clean_Test_Server_Images + true + Clean Test Images on Test Server + 0 + + + + diff --git a/ci-scripts/xml_files/fr1_nsa_2x2_quectel.xml b/ci-scripts/xml_files/fr1_nsa_2x2_quectel.xml index 4cf8973581..adef26b7c6 100644 --- a/ci-scripts/xml_files/fr1_nsa_2x2_quectel.xml +++ b/ci-scripts/xml_files/fr1_nsa_2x2_quectel.xml @@ -114,7 +114,7 @@ Initialize_eNB Initialize gNB - -O ci-scripts/conf_files/gnb.nsa.band78.106prb.usrpn310.2x2.conf -q --usrp-tx-thread-config 1 --T_stdout 2 --log_config.global_log_options level,nocolor,time,line_num,function + -O ci-scripts/conf_files/gnb.nsa.band78.106prb.usrpn310.2x2.conf --nsa -q --usrp-tx-thread-config 1 --T_stdout 2 --log_config.global_log_options level,nocolor,time,line_num,function 1 1 nr diff --git a/ci-scripts/xml_files/fr1_nsa_2x2_quectel_attach_detach.xml b/ci-scripts/xml_files/fr1_nsa_2x2_quectel_attach_detach.xml index 2aadb391bc..f59f883319 100644 --- a/ci-scripts/xml_files/fr1_nsa_2x2_quectel_attach_detach.xml +++ b/ci-scripts/xml_files/fr1_nsa_2x2_quectel_attach_detach.xml @@ -118,7 +118,7 @@ Initialize_eNB Initialize gNB - -O ci-scripts/conf_files/gnb.nsa.band78.106prb.usrpn310.2x2.conf -q --usrp-tx-thread-config 1 --log_config.global_log_options level,nocolor,time,line_num,function + -O ci-scripts/conf_files/gnb.nsa.band78.106prb.usrpn310.2x2.conf --nsa -q --usrp-tx-thread-config 1 --log_config.global_log_options level,nocolor,time,line_num,function 1 1 nr diff --git a/ci-scripts/xml_files/ldpc_gpu_test.xml b/ci-scripts/xml_files/ldpc_gpu_test.xml index d50a841b16..f129d6bd2b 100644 --- a/ci-scripts/xml_files/ldpc_gpu_test.xml +++ b/ci-scripts/xml_files/ldpc_gpu_test.xml @@ -29,122 +29,162 @@ - Run_CUDATest + Run_Physim Run LDPC Test with CPU + true + ldpctest -l 3872 -s10 -n100 - Run_CUDATest + Run_Physim Run LDPC Test with GPU + true + ldpctest -l 3872 -s10 -n100 -G 1 - Run_CUDATest + Run_Physim Run LDPC Test with CPU + true + ldpctest -l 4224 -s10 -n100 - Run_CUDATest + Run_Physim Run LDPC Test with GPU + true + ldpctest -l 4224 -s10 -n100 -G 1 - Run_CUDATest + Run_Physim Run LDPC Test with CPU + true + ldpctest -l 4576 -s10 -n100 - Run_CUDATest + Run_Physim Run LDPC Test with GPU + true + ldpctest -l 4576 -s10 -n100 -G 1 - Run_CUDATest + Run_Physim Run LDPC Test with CPU + true + ldpctest -l 4928 -s10 -n100 - Run_CUDATest + Run_Physim Run LDPC Test with GPU + true + ldpctest -l 4928 -s10 -n100 -G 1 - Run_CUDATest + Run_Physim Run LDPC Test with CPU + true + ldpctest -l 5280 -s10 -n100 - Run_CUDATest + Run_Physim Run LDPC Test with GPU + true + ldpctest -l 5280 -s10 -n100 -G 1 - Run_CUDATest + Run_Physim Run LDPC Test with CPU + true + ldpctest -l 5632 -s10 -n100 - Run_CUDATest + Run_Physim Run LDPC Test with GPU + true + ldpctest -l 5632 -s10 -n100 -G 1 - Run_CUDATest + Run_Physim Run LDPC Test with CPU + true + ldpctest -l 6336 -s10 -n100 - Run_CUDATest + Run_Physim Run LDPC Test with GPU + true + ldpctest -l 6336 -s10 -n100 -G 1 - Run_CUDATest + Run_Physim Run LDPC Test with CPU + true + ldpctest -l 7040 -s10 -n100 - Run_CUDATest + Run_Physim Run LDPC Test with GPU + true + ldpctest -l 7040 -s10 -n100 -G 1 - Run_CUDATest + Run_Physim Run LDPC Test with CPU + true + ldpctest -l 7744 -s10 -n100 - Run_CUDATest + Run_Physim Run LDPC Test with GPU + true + ldpctest -l 7744 -s10 -n100 -G 1 - Run_CUDATest + Run_Physim Run LDPC Test with CPU + true + ldpctest -l 8448 -s10 -n100 - Run_CUDATest + Run_Physim Run LDPC Test with GPU + true + ldpctest -l 8448 -s10 -n100 -G 1 diff --git a/ci-scripts/xml_files/physim_build_source.xml b/ci-scripts/xml_files/physim_build_source.xml deleted file mode 100644 index 7ba2a06800..0000000000 --- a/ci-scripts/xml_files/physim_build_source.xml +++ /dev/null @@ -1,35 +0,0 @@ - - - - build-offload - Build physical simulators - tasks - 000001 - - - - Build_PhySim - Build physical simulators - --phy_simulators --ninja --noavx512 - FALSE - - diff --git a/ci-scripts/xml_files/t2_offload_dec_nr_ulsim.xml b/ci-scripts/xml_files/t2_offload_dec_nr_ulsim.xml index 4e44f7f853..7cbbbcaf14 100644 --- a/ci-scripts/xml_files/t2_offload_dec_nr_ulsim.xml +++ b/ci-scripts/xml_files/t2_offload_dec_nr_ulsim.xml @@ -31,165 +31,165 @@ - Run_T2Test + Run_Physim Run nr_ulsim with CPU: SNR = 30, MCS = 5, 106 PRBs, 1 layer true - nr_ulsim + nr_ulsim 300 -n100 -s30 -S30.2 -m5 -r106 -R106 -C10 -P - Run_T2Test + Run_Physim Run nr_ulsim with T2 LDPC offload: SNR = 30, MCS = 5, 106 PRBs, 1 layer true - nr_ulsim + nr_ulsim 100 - -n100 -s30 -S30.2 -m5 -r106 -R106 -o -P --ldpc_offload.dpdk_dev d8:00.0 + -n100 -s30 -S30.2 -m5 -r106 -R106 -C10 -o -P --ldpc_offload.dpdk_dev d8:00.0 - Run_T2Test + Run_Physim Run nr_ulsim with CPU: SNR = 30, MCS = 15, 106 PRBs, 1 layer true - nr_ulsim + nr_ulsim 300 -n100 -s30 -S30.2 -m15 -r106 -R106 -C10 -P - Run_T2Test + Run_Physim Run nr_ulsim with T2 LDPC offload: SNR = 30, MCS = 15, 106 PRBs, 1 layer true - nr_ulsim + nr_ulsim 150 - -n100 -s30 -S30.2 -m15 -r106 -R106 -o -P --ldpc_offload.dpdk_dev d8:00.0 + -n100 -s30 -S30.2 -m15 -r106 -R106 -C10 -o -P --ldpc_offload.dpdk_dev d8:00.0 - Run_T2Test + Run_Physim Run nr_ulsim with CPU: SNR = 30, MCS = 25, 106 PRBs, 1 layer true - nr_ulsim + nr_ulsim 250 -n100 -s30 -S30.2 -m25 -r106 -R106 -C10 -P - Run_T2Test + Run_Physim Run nr_ulsim with T2 LDPC offload: SNR = 30, MCS = 25, 106 PRBs, 1 layer true - nr_ulsim + nr_ulsim 250 - -n100 -s30 -S30.2 -m25 -r106 -R106 -o -P --ldpc_offload.dpdk_dev d8:00.0 + -n100 -s30 -S30.2 -m25 -r106 -R106 -C10 -o -P --ldpc_offload.dpdk_dev d8:00.0 - Run_T2Test + Run_Physim Run nr_ulsim with CPU: SNR = 30, MCS = 5, 273 PRBs, 1 layer true - nr_ulsim + nr_ulsim 300 -n100 -s30 -S30.2 -m5 -r273 -R273 -C10 -P - Run_T2Test + Run_Physim Run nr_ulsim with T2 LDPC offload: SNR = 30, MCS = 5, 273 PRBs, 1 layer true - nr_ulsim + nr_ulsim 150 - -n100 -s30 -S30.2 -m5 -r273 -R273 -o -P --ldpc_offload.dpdk_dev d8:00.0 + -n100 -s30 -S30.2 -m5 -r273 -R273 -C10 -o -P --ldpc_offload.dpdk_dev d8:00.0 - Run_T2Test + Run_Physim Run nr_ulsim with CPU: SNR = 30, MCS = 15, 273 PRBs, 1 layer true - nr_ulsim + nr_ulsim 400 -n100 -s30 -S30.2 -m15 -r273 -R273 -C10 -P - Run_T2Test + Run_Physim Run nr_ulsim with T2 LDPC offload: SNR = 30, MCS = 15, 273 PRBs, 1 layer true - nr_ulsim + nr_ulsim 350 - -n100 -s30 -S30.2 -m15 -r273 -R273 -o -P --ldpc_offload.dpdk_dev d8:00.0 + -n100 -s30 -S30.2 -m15 -r273 -R273 -C10 -o -P --ldpc_offload.dpdk_dev d8:00.0 - Run_T2Test + Run_Physim Run nr_ulsim with CPU: SNR = 30, MCS = 25, 273 PRBs, 1 layer true - nr_ulsim + nr_ulsim 400 -n100 -s30 -S30.2 -m25 -r273 -R273 -C10 -P - Run_T2Test + Run_Physim Run nr_ulsim with T2 LDPC offload: SNR = 30, MCS = 25, 273 PRBs, 1 layer true - nr_ulsim + nr_ulsim 550 - -n100 -s30 -S30.2 -m25 -r273 -R273 -o -P --ldpc_offload.dpdk_dev d8:00.0 + -n100 -s30 -S30.2 -m25 -r273 -R273 -C10 -o -P --ldpc_offload.dpdk_dev d8:00.0 - Run_T2Test + Run_Physim Run nr_ulsim with CPU: SNR = 30, MCS = 5, 273 PRBs, 2 layers true - nr_ulsim + nr_ulsim 300 -n100 -s30 -S30.2 -m5 -r273 -R273 -C10 -W2 -z2 -y2 -P - Run_T2Test + Run_Physim Run nr_ulsim with T2 LDPC offload: SNR = 30, MCS = 5, 273 PRBs, 2 layers true - nr_ulsim + nr_ulsim 250 - -n100 -s30 -S30.2 -m5 -r273 -R273 -o -W2 -z2 -y2 -P --ldpc_offload.dpdk_dev d8:00.0 + -n100 -s30 -S30.2 -m5 -r273 -R273 -C10 -o -W2 -z2 -y2 -P --ldpc_offload.dpdk_dev d8:00.0 - Run_T2Test + Run_Physim Run nr_ulsim with CPU: SNR = 30, MCS = 15, 273 PRBs, 2 layers true - nr_ulsim + nr_ulsim 600 -n100 -s30 -S30.2 -m15 -r273 -R273 -C10 -W2 -z2 -y2 -P - Run_T2Test + Run_Physim Run nr_ulsim with T2 LDPC offload: SNR = 30, MCS = 15, 273 PRBs, 2 layers true - nr_ulsim + nr_ulsim 650 - -n100 -s30 -S30.2 -m15 -r273 -R273 -o -W2 -z2 -y2 -P --ldpc_offload.dpdk_dev d8:00.0 + -n100 -s30 -S30.2 -m15 -r273 -R273 -C10 -o -W2 -z2 -y2 -P --ldpc_offload.dpdk_dev d8:00.0 - Run_T2Test + Run_Physim Run nr_ulsim with CPU: SNR = 30, MCS = 25, 273 PRBs, 2 layers true - nr_ulsim + nr_ulsim 650 -n100 -s30 -S30.2 -m25 -r273 -R273 -C10 -W2 -z2 -y2 -P - Run_T2Test + Run_Physim Run nr_ulsim with T2 LDPC offload: SNR = 30, MCS = 25, 273 PRBs, 2 layers true - nr_ulsim + nr_ulsim 1100 - -n100 -s30 -S30.2 -m25 -r273 -R273 -o -W2 -z2 -y2 -P --ldpc_offload.dpdk_dev d8:00.0 + -n100 -s30 -S30.2 -m25 -r273 -R273 -C10 -o -W2 -z2 -y2 -P --ldpc_offload.dpdk_dev d8:00.0 diff --git a/ci-scripts/xml_files/t2_offload_enc_nr_dlsim.xml b/ci-scripts/xml_files/t2_offload_enc_nr_dlsim.xml index cff66b56a4..c4dba5db6c 100644 --- a/ci-scripts/xml_files/t2_offload_enc_nr_dlsim.xml +++ b/ci-scripts/xml_files/t2_offload_enc_nr_dlsim.xml @@ -32,218 +32,218 @@ - Run_T2Test + Run_Physim Run nr_dlsim with CPU: SNR = 30, MCS = 5, 106 PRBs, 1 layer true - nr_dlsim + nr_dlsim 230 -n100 -s30 -S30.2 -e5 -b106 -R106 -X 8,9,10,11,12 -P - Run_T2Test + Run_Physim Run nr_dlsim with T2 LDPC offload: SNR = 30, MCS = 5, 106 PRBs, 1 layer true - nr_dlsim + nr_dlsim 100 - -n100 -s30 -S30.2 -e5 -b106 -R106 -c -P --ldpc_offload.dpdk_dev d8:00.0 + -n100 -s30 -S30.2 -e5 -b106 -R106 -c -X4,5,6,7,8,9 -P --ldpc_offload.dpdk_dev d8:00.0 - Run_T2Test + Run_Physim Run nr_dlsim with CPU: SNR = 30, MCS = 15, 106 PRBs, 1 layer true - nr_dlsim + nr_dlsim 300 -n100 -s30 -S30.2 -e15 -b106 -R106 -X 8,9,10,11,12 -P - Run_T2Test + Run_Physim Run nr_dlsim with T2 LDPC offload: SNR = 30, MCS = 15, 106 PRBs, 1 layer true - nr_dlsim + nr_dlsim 100 - -n100 -s30 -S30.2 -e15 -b106 -R106 -c -P --ldpc_offload.dpdk_dev d8:00.0 + -n100 -s30 -S30.2 -e15 -b106 -R106 -c -X4,5,6,7,8,9 -P --ldpc_offload.dpdk_dev d8:00.0 - Run_T2Test + Run_Physim Run nr_dlsim with CPU: SNR = 30, MCS = 25, 106 PRBs, 1 layer true - nr_dlsim + nr_dlsim 350 -n100 -s30 -S30.2 -e25 -b106 -R106 -X 8,9,10,11,12 -P - Run_T2Test + Run_Physim Run nr_dlsim with T2 LDPC offload: SNR = 30, MCS = 25, 106 PRBs, 1 layer true - nr_dlsim + nr_dlsim 200 - -n100 -s30 -S30.2 -e25 -b106 -R106 -c -P --ldpc_offload.dpdk_dev d8:00.0 + -n100 -s30 -S30.2 -e25 -b106 -R106 -c -X4,5,6,7,8,9 -P --ldpc_offload.dpdk_dev d8:00.0 - Run_T2Test + Run_Physim Run nr_dlsim with CPU: SNR = 30, MCS = 5, 273 PRBs, 1 layer true - nr_dlsim + nr_dlsim 300 -n100 -s30 -S30.2 -e5 -b273 -R273 -X 8,9,10,11,12 -P - Run_T2Test + Run_Physim Run nr_dlsim with T2 LDPC offload: SNR = 30, MCS = 5, 273 PRBs, 1 layer true - nr_dlsim + nr_dlsim 150 - -n100 -s30 -S30.2 -e5 -b273 -R273 -c -P --ldpc_offload.dpdk_dev d8:00.0 + -n100 -s30 -S30.2 -e5 -b273 -R273 -c -X4,5,6,7,8,9 -P --ldpc_offload.dpdk_dev d8:00.0 - Run_T2Test + Run_Physim Run nr_dlsim with CPU: SNR = 30, MCS = 15, 273 PRBs, 1 layer true - nr_dlsim + nr_dlsim 350 -n100 -s30 -S30.2 -e15 -b273 -R273 -X 8,9,10,11,12 -P - Run_T2Test + Run_Physim Run nr_dlsim with T2 LDPC offload: SNR = 30, MCS = 15, 273 PRBs, 1 layer true - nr_dlsim + nr_dlsim 250 - -n100 -s30 -S30.2 -e15 -b273 -R273 -c -P --ldpc_offload.dpdk_dev d8:00.0 + -n100 -s30 -S30.2 -e15 -b273 -R273 -c -X4,5,6,7,8,9 -P --ldpc_offload.dpdk_dev d8:00.0 - Run_T2Test + Run_Physim Run nr_dlsim with CPU: SNR = 30, MCS = 25, 273 PRBs, 1 layer true - nr_dlsim + nr_dlsim 400 -n100 -s30 -S30.2 -e25 -b273 -R273 -X 8,9,10,11,12 -P - Run_T2Test + Run_Physim Run nr_dlsim with T2 LDPC offload: SNR = 30, MCS = 25, 273 PRBs, 1 layer true - nr_dlsim + nr_dlsim 400 - -n100 -s30 -S30.2 -e25 -b273 -R273 -c -P --ldpc_offload.dpdk_dev d8:00.0 + -n100 -s30 -S30.2 -e25 -b273 -R273 -c -X4,5,6,7,8,9 -P --ldpc_offload.dpdk_dev d8:00.0 - Run_T2Test + Run_Physim Run nr_dlsim with CPU: SNR = 30, MCS = 5, 273 PRBs, 2 layers true - nr_dlsim + nr_dlsim 400 -n100 -s30 -S30.2 -e5 -b273 -R273 -X 8,9,10,11,12 -x2 -z2 -y2 -P - Run_T2Test + Run_Physim Run nr_dlsim with T2 LDPC offload: SNR = 30, MCS = 5, 273 PRBs, 2 layers true - nr_dlsim + nr_dlsim 200 - -n100 -s30 -S30.2 -e5 -b273 -R273 -c -x2 -z2 -y2 -P --ldpc_offload.dpdk_dev d8:00.0 + -n100 -s30 -S30.2 -e5 -b273 -R273 -c -X4,5,6,7,8,9 -x2 -z2 -y2 -P --ldpc_offload.dpdk_dev d8:00.0 - Run_T2Test + Run_Physim Run nr_dlsim with CPU: SNR = 30, MCS = 15, 273 PRBs, 2 layers true - nr_dlsim + nr_dlsim 450 -n100 -s30 -S30.2 -e15 -b273 -R273 -X 8,9,10,11,12 -x2 -z2 -y2 -P - Run_T2Test + Run_Physim Run nr_dlsim with T2 LDPC offload: SNR = 30, MCS = 15, 273 PRBs, 2 layers true - nr_dlsim + nr_dlsim 500 - -n100 -s30 -S30.2 -e15 -b273 -R273 -c -x2 -z2 -y2 -P --ldpc_offload.dpdk_dev d8:00.0 + -n100 -s30 -S30.2 -e15 -b273 -R273 -c -X4,5,6,7,8,9 -x2 -z2 -y2 -P --ldpc_offload.dpdk_dev d8:00.0 - Run_T2Test + Run_Physim Run nr_dlsim with CPU: SNR = 30, MCS = 25, 273 PRBs, 2 layers true - nr_dlsim + nr_dlsim 500 -n100 -s30 -S30.2 -e25 -b273 -R273 -X 8,9,10,11,12 -x2 -z2 -y2 -P - Run_T2Test + Run_Physim Run nr_dlsim with T2 LDPC offload: SNR = 30, MCS = 25, 273 PRBs, 2 layers true - nr_dlsim + nr_dlsim 500 - -n100 -s30 -S30.2 -e25 -b273 -R273 -c -x2 -z2 -y2 -P --ldpc_offload.dpdk_dev d8:00.0 + -n100 -s30 -S30.2 -e25 -b273 -R273 -c -X4,5,6,7,8,9 -x2 -z2 -y2 -P --ldpc_offload.dpdk_dev d8:00.0 - Run_T2Test + Run_Physim Run nr_dlsim with CPU: SNR = 30, MCS = 5, 273 PRBs, 2 layers, 4 antennas true - nr_dlsim + nr_dlsim 400 -n100 -s30 -S30.2 -e5 -b273 -R273 -X8,9,10,11,12 -x2 -z4 -y4 -P - Run_T2Test + Run_Physim Run nr_dlsim with T2 LDPC offload: SNR = 30, MCS = 5, 273 PRBs, 2 layers, 4 antennas true - nr_dlsim - 150 - -n100 -s30 -S30.2 -e5 -b273 -R273 -c -x2 -z4 -y4 -P --ldpc_offload.dpdk_dev d8:00.0 + nr_dlsim + 200 + -n100 -s30 -S30.2 -e5 -b273 -R273 -c -X4,5,6,7,8,9 -x2 -z4 -y4 -P --ldpc_offload.dpdk_dev d8:00.0 - Run_T2Test + Run_Physim Run nr_dlsim with CPU: SNR = 30, MCS = 20, 273 PRBs, 2 layers, 4 antennas true - nr_dlsim + nr_dlsim 400 -n100 -s30 -S30.2 -e15 -b273 -R273 -X8,9,10,11,12 -x2 -z4 -y4 -P - Run_T2Test + Run_Physim Run nr_dlsim with T2 LDPC offload: SNR = 30, MCS = 20, 273 PRBs, 2 layers, 4 antennas true - nr_dlsim + nr_dlsim 300 - -n100 -s30 -S30.2 -e15 -b273 -R273 -c -x2 -z4 -y4 -P --ldpc_offload.dpdk_dev d8:00.0 + -n100 -s30 -S30.2 -e15 -b273 -R273 -c -X4,5,6,7,8,9 -x2 -z4 -y4 -P --ldpc_offload.dpdk_dev d8:00.0 - Run_T2Test + Run_Physim Run nr_dlsim with CPU: SNR = 30, MCS = 27, 273 PRBs, 2 layers, 4 antennas true - nr_dlsim + nr_dlsim 450 -n100 -s30 -S30.2 -e25 -b273 -R273 -X8,9,10,11,12 -x2 -z4 -y4 -P - Run_T2Test + Run_Physim Run nr_dlsim with T2 LDPC offload: SNR = 30, MCS = 27, 273 PRBs, 2 layers, 4 antennas true - nr_dlsim + nr_dlsim 450 - -n100 -s30 -S30.2 -e25 -b273 -R273 -c -x2 -z4 -y4 -P --ldpc_offload.dpdk_dev d8:00.0 + -n100 -s30 -S30.2 -e25 -b273 -R273 -c -X4,5,6,7,8,9 -x2 -z4 -y4 -P --ldpc_offload.dpdk_dev d8:00.0 diff --git a/ci-scripts/yaml_files/5g_f1_rfsimulator/docker-compose.yaml b/ci-scripts/yaml_files/5g_f1_rfsimulator/docker-compose.yaml index 16d78139b1..c925af1adb 100644 --- a/ci-scripts/yaml_files/5g_f1_rfsimulator/docker-compose.yaml +++ b/ci-scripts/yaml_files/5g_f1_rfsimulator/docker-compose.yaml @@ -87,8 +87,8 @@ services: container_name: rfsim5g-oai-cu cap_drop: - ALL - environment: - USE_ADDITIONAL_OPTIONS: --sa --log_config.global_log_options level,nocolor,time + environment: + USE_ADDITIONAL_OPTIONS: --log_config.global_log_options level,nocolor,time ASAN_OPTIONS: detect_leaks=0 depends_on: - oai-ext-dn @@ -109,7 +109,7 @@ services: cap_drop: - ALL environment: - USE_ADDITIONAL_OPTIONS: --sa --rfsim + USE_ADDITIONAL_OPTIONS: --rfsim --log_config.global_log_options level,nocolor,time --rfsimulator.options chanmod --telnetsrv --telnetsrv.listenaddr 192.168.71.171 @@ -121,7 +121,6 @@ services: ipv4_address: 192.168.71.171 volumes: - ../../conf_files/gnb-du.sa.band78.106prb.rfsim.conf:/opt/oai-gnb/etc/gnb.conf - - ../../conf_files/rfsim_channel_ci.conf:/opt/oai-gnb/etc/rfsim_channel_ci.conf healthcheck: test: /bin/bash -c "pgrep nr-softmodem" interval: 10s @@ -137,7 +136,7 @@ services: - NET_ADMIN # for interface bringup - NET_RAW # for ping environment: - USE_ADDITIONAL_OPTIONS: --sa --rfsim --log_config.global_log_options level,nocolor,time + USE_ADDITIONAL_OPTIONS: --rfsim --log_config.global_log_options level,nocolor,time -r 106 --numerology 1 -C 3619200000 --uicc0.imsi 208990100001100 --rfsimulator.serveraddr 192.168.71.171 @@ -153,7 +152,6 @@ services: - /dev/net/tun:/dev/net/tun volumes: - ../../conf_files/nrue.uicc.conf:/opt/oai-nr-ue/etc/nr-ue.conf - - ../../conf_files/rfsim_channel_ci.conf:/opt/oai-nr-ue/etc/rfsim_channel_ci.conf healthcheck: test: /bin/bash -c "pgrep nr-uesoftmodem" interval: 10s diff --git a/ci-scripts/yaml_files/5g_fdd_rfsimulator/docker-compose.yaml b/ci-scripts/yaml_files/5g_fdd_rfsimulator/docker-compose.yaml index d284312482..a6103a3815 100644 --- a/ci-scripts/yaml_files/5g_fdd_rfsimulator/docker-compose.yaml +++ b/ci-scripts/yaml_files/5g_fdd_rfsimulator/docker-compose.yaml @@ -86,7 +86,7 @@ services: cap_drop: - ALL environment: - USE_ADDITIONAL_OPTIONS: --sa -E --rfsim --log_config.global_log_options level,nocolor,time + USE_ADDITIONAL_OPTIONS: -E --rfsim --log_config.global_log_options level,nocolor,time ASAN_OPTIONS: detect_leaks=0 depends_on: - oai-ext-dn @@ -108,8 +108,8 @@ services: cap_add: - NET_ADMIN # for interface bringup - NET_RAW # for ping - environment: - USE_ADDITIONAL_OPTIONS: -E --sa --rfsim -r 106 --numerology 1 --uicc0.imsi 208990100001100 --band 66 -C 2169090000 --CO -400000000 --ssb 378 --rfsimulator.serveraddr 192.168.71.140 --log_config.global_log_options level,nocolor,time + environment: + USE_ADDITIONAL_OPTIONS: -E --rfsim -r 106 --numerology 1 --uicc0.imsi 208990100001100 --band 66 -C 2169090000 --CO -400000000 --ssb 378 --rfsimulator.serveraddr 192.168.71.140 --log_config.global_log_options level,nocolor,time depends_on: - oai-gnb networks: diff --git a/ci-scripts/yaml_files/5g_l2sim_tdd/README.md b/ci-scripts/yaml_files/5g_l2sim_tdd/README.md deleted file mode 100644 index 6579fcac5f..0000000000 --- a/ci-scripts/yaml_files/5g_l2sim_tdd/README.md +++ /dev/null @@ -1,396 +0,0 @@ - - - - - -
- - - - - - OAI Full Stack 5G-NR L2 simulation with containers and a proxy -
- -It is also valid for `Ubuntu 22.04`. - -# 1. Adapt the `docker-compose` to your environment # -The yaml file is in the following directory: `ci-scripts/yaml_files/5g_l2sim_tdd` - -In the `SMF` section, provide your own DNS IP address: - -```yaml - DEFAULT_DNS_IPV4_ADDRESS=172.21.3.100 -``` -gNB section: - -All the parameter values will be taken from the mounted config file: - -```yaml -oai-gnb: - [...] - volumes: - - ../../conf_files/gnb.sa.band78.106prb.l2sim.conf:/opt/oai-gnb/etc/gnb.conf -``` - -You need to provide your docker-host primary IP address and interface name: in our case `172.21.16.128` and `eno1`. -The following refers to the contents of the previously mentioned .conf file - -```yaml - GNB_NGA_IF_NAME: eno1 - GNB_NGA_IP_ADDRESS: 172.21.16.128 - GNB_NGU_IF_NAME: eno1 - GNB_NGU_IP_ADDRESS: 172.21.16.128 -``` - -For the UE, all the parameter values will be taken from the mounted config -file, in the section `oai-nr-ue0`: - -```yaml - oai-nr-ue0: - [...] - volumes: - - ../../conf_files/nrue.band78.106prb.l2sim.conf:/opt/oai-nr-ue/etc/nr-ue.conf - - ../../../openair1/SIMULATION/LTE_PHY/BLER_SIMULATIONS/AWGN/AWGN_results:/opt/oai-nr-ue/openair1/SIMULATION/LTE_PHY/BLER_SIMULATIONS/AWGN/AWGN_results -``` - -In this section, you need to set the proper value `remote_n_address` -where the UE configuration (mounted to `/opt/oai-nr-ue/etc/nr-ue.conf`) reads: - -```libconfig -MACRLCs = ( - { - num_cc = 1; - tr_n_preference = "nfapi"; - remote_n_address = "127.0.0.1"; //Proxy IP - local_n_address = "127.0.0.1"; - ... -``` - -This tutorial is a first draft. This nFAPI feature and the proxy are still under development. - -At time of writing, we were able to run in `host-mode`, 1 `NR-UE` and just ping traffic. - - - - -# 2. Retrieving the images on Docker-Hub # - -Currently the images are hosted under the team account `oaisoftwarealliance`. They were previously hosted under the user account `rdefosseoai`. - -Once again you may need to log on [docker-hub](https://hub.docker.com/) if your organization has reached pulling limit as `anonymous`. - -```bash -docker login -``` -```bash -Login with your Docker ID to push and pull images from Docker Hub. If you don't have a Docker ID, head over to https://hub.docker.com to create one. -Username: -Password: -``` - -Now pull images. - -```bash -docker pull mysql:8.0 -docker pull oaisoftwarealliance/oai-amf:v2.0.0 -docker pull oaisoftwarealliance/oai-smf:v2.0.0 -docker pull oaisoftwarealliance/oai-upf:v2.0.0 -docker pull oaisoftwarealliance/trf-gen-cn5g:focal - -docker pull oaisoftwarealliance/oai-gnb:develop -docker pull oaisoftwarealliance/oai-nr-ue:develop -docker pull oaisoftwarealliance/proxy:develop -``` - -And **re-tag** them for tutorials' docker-compose file to work. - -```bash -docker image tag oaisoftwarealliance/proxy:develop oai-lte-multi-ue-proxy:latest -``` - -```bash -docker logout -``` - -Note that the proxy image is based on the source available at [https://github.com/EpiSci/oai-lte-5g-multi-ue-proxy](https://github.com/EpiSci/oai-lte-5g-multi-ue-proxy). - -At time of writing, the `latest` tag corresponded to `56cfdc046a5f96d5e67d42a2fc2bf6ba2fe58b41` commit. - -# 3. Deploy containers # - -**CAUTION: this SHALL be done in multiple steps.** - -**Just `docker-compose up -d` WILL NOT WORK!** - -All the following commands **SHALL** be run from the `ci-scripts/yaml_files/5g_l2sim_tdd` folder. - -The `gNB`, `proxy` and `NR-UE` containers will be deployed in `host`-mode. It will use the host loopback interface to connect. - -```bash -sudo ifconfig lo: 127.0.0.2 netmask 255.0.0.0 up -``` - -## 3.1. Deploy OAI 5G Core Network ## - -```bash -cd ci-scripts/yaml_files/5g_l2sim_tdd -docker-compose up -d mysql oai-amf oai-smf oai-upf oai-ext-dn -``` -```bash -Creating network "l2sim-oai-public-net" with driver "bridge" -Creating network "l2sim-oai-traffic_net-net" with driver "bridge" -Creating l2sim-mysql ... done -Creating l2sim-oai-upf ... done -Creating l2sim-oai-amf ... done -Creating l2sim-oai-smf ... done -Creating l2sim-oai-ext-dn ... done -``` - -Wait for a bit. - -```bash -docker-compose ps -a -``` -```bash - Name Command State Ports -------------------------------------------------------------------------------------------------- -l2sim-mysql docker-entrypoint.sh mysqld Up (healthy) 3306/tcp, 33060/tcp -l2sim-oai-amf /bin/bash /openair-amf/bin ... Up (healthy) 38412/sctp, 80/tcp, 9090/tcp -l2sim-oai-ext-dn /bin/bash -c apt update; ... Up (healthy) -l2sim-oai-smf /bin/bash /openair-smf/bin ... Up (healthy) 80/tcp, 8805/udp, 9090/tcp -l2sim-oai-upf /bin/bash /openair-upf/bin ... Up (healthy) 2152/udp, 8805/udp -``` - -At this point, you can prepare a capture on the newly-created public docker bridges: - -```bash -ifconfig -``` -```bash -... -l2sim-public: flags=4163 mtu 1500 - inet 192.168.71.129 netmask 255.255.255.192 broadcast 192.168.71.191 - inet6 fe80::42:c4ff:fe2b:3d38 prefixlen 64 scopeid 0x20 - ether 02:42:c4:2b:3d:38 txqueuelen 0 (Ethernet) - RX packets 4 bytes 112 (112.0 B) - RX errors 0 dropped 0 overruns 0 frame 0 - TX packets 7 bytes 626 (626.0 B) - TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0 - -l2sim-traffic: flags=4163 mtu 1500 - inet 192.168.72.129 netmask 255.255.255.192 broadcast 192.168.72.191 - inet6 fe80::42:b5ff:fed3:e732 prefixlen 64 scopeid 0x20 - ether 02:42:b5:d3:e7:32 txqueuelen 0 (Ethernet) - RX packets 2652 bytes 142335 (142.3 KB) - RX errors 0 dropped 0 overruns 0 frame 0 - TX packets 3999 bytes 23367972 (23.3 MB) - TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0 -... -``` -```bash -sudo nohup tshark -f "(host 192.168.72.135 and icmp) or (not host 192.168.72.135 and not arp and not port 53 and not port 2152 and not port 2153)" -i l2sim-public -i l2sim-traffic -w /tmp/capture_5g_l2sim_tdd.pcap > /tmp/tshark.log 2>&1 & -``` - -## 3.2. Deploy OAI gNB in Standalone Mode as a VNF ## - -**CAUTION: To execute this 2nd step, the whole `CN5G` SHALL be in `healthy` state (especially the `mysql` container).** - -```bash -docker-compose up -d oai-gnb -``` -```bash -l2sim-oai-upf is up-to-date -l2sim-oai-ext-dn is up-to-date -Creating l2sim-oai-gnb ... done -``` - -Wait for a bit. - -```bash -$ docker-compose ps -a -``` -```bash - Name Command State Ports -------------------------------------------------------------------------------------------------- -l2sim-mysql docker-entrypoint.sh mysqld Up (healthy) 3306/tcp, 33060/tcp -l2sim-oai-amf /bin/bash /openair-amf/bin ... Up (healthy) 38412/sctp, 80/tcp, 9090/tcp -l2sim-oai-ext-dn /bin/bash -c apt update; ... Up (healthy) -l2sim-oai-gnb /opt/oai-gnb/bin/entrypoin ... Up (healthy) -l2sim-oai-smf /bin/bash /openair-smf/bin ... Up (healthy) 80/tcp, 8805/udp, 9090/tcp -l2sim-oai-upf /bin/bash /openair-upf/bin ... Up (healthy) 2152/udp, 8805/udp -``` - -You can verify that the `gNB` is connected with the `AMF`: - -```bash -docker logs l2sim-oai-amf -``` -```bash -... -[AMF] [amf_app] [info ] |----------------------------------------------------gNBs' information-------------------------------------------| -[AMF] [amf_app] [info ] | Index | Status | Global ID | gNB Name | PLMN | -[AMF] [amf_app] [info ] | 1 | Connected | 0x0 | gnb-l2sim-vnf | 208, 99 | -[AMF] [amf_app] [info ] |----------------------------------------------------------------------------------------------------------------| -... -``` - -## 3.3. Deploy OAI NR-UE and proxy - -```bash -docker-compose up -d proxy oai-nr-ue -``` -```bash -l2sim-mysql is up-to-date -l2sim-oai-amf is up-to-date -l2sim-oai-smf is up-to-date -l2sim-oai-upf is up-to-date -l2sim-oai-ext-dn is up-to-date -l2sim-oai-gnb is up-to-date -Creating l2sim-oai-nr-ue ... done -Creating l2sim-proxy ... done -``` - -Wait for a bit. - -```bash -docker-compose ps -a -``` -```bash - Name Command State Ports -------------------------------------------------------------------------------------------------- -l2sim-mysql docker-entrypoint.sh mysqld Up (healthy) 3306/tcp, 33060/tcp -l2sim-oai-amf /bin/bash /openair-amf/bin ... Up (healthy) 38412/sctp, 80/tcp, 9090/tcp -l2sim-oai-ext-dn /bin/bash -c apt update; ... Up (healthy) -l2sim-oai-gnb /opt/oai-gnb/bin/entrypoin ... Up (healthy) -l2sim-oai-nr-ue0 /opt/oai-nr-ue/bin/entrypo ... Up (healthy) -l2sim-oai-smf /bin/bash /openair-smf/bin ... Up (healthy) 80/tcp, 8805/udp, 9090/tcp -l2sim-oai-upf /bin/bash /openair-upf/bin ... Up (healthy) 2152/udp, 8805/udp -l2sim-proxy /oai-lte-multi-ue-proxy/bi ... Up (healthy) -``` -```bash -docker stats --no-stream --format "table {{.Container}}\t{{.CPUPerc}} {{.MemUsage}}\t{{.MemPerc}}" l2sim-mysql l2sim-oai-amf l2sim-oai-ext-dn l2sim-oai-gnb l2sim-oai-nr-ue0 l2sim-oai-smf l2sim-oai-upf l2sim-proxy -``` -```bash -CONTAINER CPU % MEM USAGE / LIMIT MEM % -l2sim-mysql 0.03% 206.7MiB / 62.54GiB 0.32% -l2sim-oai-amf 4.05% 29.49MiB / 62.54GiB 0.05% -l2sim-oai-ext-dn 0.00% 31.27MiB / 62.54GiB 0.05% -l2sim-oai-gnb 1.29% 1.853GiB / 62.54GiB 2.96% -l2sim-oai-nr-ue0 1.43% 350.8MiB / 62.54GiB 0.55% -l2sim-oai-smf 3.24% 30.23MiB / 62.54GiB 0.05% -l2sim-oai-upf 0.00% 11.78MiB / 62.54GiB 0.02% -l2sim-proxy 6.97% 290.4MiB / 62.54GiB 0.45% -``` - -**CAUTION: As you can see the CPU usage is not that important compared to a 5G RF simulator equivalent.** - -But the CPU speed matters; I am running on a fast server: - -```bash -lscpu -``` -```bash -Architecture: x86_64 -CPU(s): 16 -... -Model name: Intel(R) Xeon(R) Silver 4215R CPU @ 3.20GHz -``` - -I tried on a slower server with more CPUs and it did not work: - -```bash -oaici@orion:~$ lscpu -Architecture: x86_64 -CPU(s): 48 -... -Model name: Intel(R) Xeon(R) CPU E5-2658 v3 @ 2.20GHz -``` - -We will work on this issue. - - -Making sure the OAI UE is connected: - -```bash -docker exec -it l2sim-oai-nr-ue0 /bin/bash -``` -```bash -root@bb4d400a832d:/opt/oai-nr-ue# ifconfig -eth0: flags=4163 mtu 1500 - inet 192.168.71.137 netmask 255.255.255.192 broadcast 192.168.71.191 - ether 02:42:c0:a8:47:89 txqueuelen 0 (Ethernet) - RX packets 224259 bytes 5821372018 (5.8 GB) - RX errors 0 dropped 0 overruns 0 frame 0 - TX packets 235916 bytes 7848786376 (7.8 GB) - TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0 - -lo: flags=73 mtu 65536 - inet 127.0.0.1 netmask 255.0.0.0 - loop txqueuelen 1000 (Local Loopback) - RX packets 0 bytes 0 (0.0 B) - RX errors 0 dropped 0 overruns 0 frame 0 - TX packets 0 bytes 0 (0.0 B) - TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0 - -oaitun_ue1: flags=4305 mtu 1500 - inet 12.1.1.2 netmask 255.255.255.0 destination 12.1.1.2 - unspec 00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00 txqueuelen 500 (UNSPEC) - RX packets 0 bytes 0 (0.0 B) - RX errors 0 dropped 0 overruns 0 frame 0 - TX packets 0 bytes 0 (0.0 B) - TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0 -``` - -# 4. Check traffic # - -## 4.1. Check your Internet connectivity ## - -You can also check with the `ext-dn` container (IP address is `192.168.72.135` in docker-compose) - -```bash -docker exec -it l2sim-oai-nr-ue0 /bin/bash -``` -```bash -ping -I oaitun_ue1 -c 20 192.168.72.135 -``` -```bash -root@bb4d400a832d# ping -I oaitun_ue1 -c 20 192.168.72.135 -PING 192.168.72.135 (192.168.72.135) from 12.1.1.2 oaitun_ue1: 56(84) bytes of data. -64 bytes from 192.168.72.135: icmp_seq=1 ttl=63 time=65.1 ms -64 bytes from 192.168.72.135: icmp_seq=2 ttl=63 time=74.2 ms -... -64 bytes from 192.168.72.135: icmp_seq=19 ttl=63 time=25.0 ms -64 bytes from 192.168.72.135: icmp_seq=20 ttl=63 time=34.7 ms - ---- 192.168.72.135 ping statistics --- -20 packets transmitted, 20 received, 0% packet loss, time 19025ms -rtt min/avg/max/mdev = 16.413/120.639/209.673/57.159 ms -``` - -# 5. Un-deployment # - -```bash -docker-compose down -``` -```bash -Stopping l2sim-oai-nr-ue2 ... done -Stopping l2sim-oai-nr-ue ... done -Stopping l2sim-oai-gnb ... done -Stopping l2sim-oai-ext-dn ... done -Stopping l2sim-oai-upf ... done -Stopping l2sim-oai-smf ... done -Stopping l2sim-oai-amf ... done -Stopping l2sim-mysql ... done -Removing l2sim-oai-nr-ue2 ... done -Removing l2sim-oai-nr-ue ... done -Removing l2sim-oai-gnb ... done -Removing l2sim-oai-ext-dn ... done -Removing l2sim-oai-upf ... done -Removing l2sim-oai-smf ... done -Removing l2sim-oai-amf ... done -Removing l2sim-mysql ... done -Removing network l2sim-oai-public-net -Removing network l2sim-oai-traffic-net -``` - diff --git a/ci-scripts/yaml_files/5g_l2sim_tdd/docker-compose.yaml b/ci-scripts/yaml_files/5g_l2sim_tdd/docker-compose.yaml deleted file mode 100644 index 67f64983d2..0000000000 --- a/ci-scripts/yaml_files/5g_l2sim_tdd/docker-compose.yaml +++ /dev/null @@ -1,165 +0,0 @@ -services: - mysql: - container_name: "l2sim-mysql" - image: mysql:8.0 - volumes: - - ../5g_rfsimulator/oai_db.sql:/docker-entrypoint-initdb.d/oai_db.sql - - ../5g_rfsimulator/mysql-healthcheck.sh:/tmp/mysql-healthcheck.sh - environment: - - TZ=Europe/Paris - - MYSQL_DATABASE=oai_db - - MYSQL_USER=test - - MYSQL_PASSWORD=test - - MYSQL_ROOT_PASSWORD=linux - healthcheck: - test: /bin/bash -c "/tmp/mysql-healthcheck.sh" - interval: 10s - timeout: 5s - retries: 30 - networks: - public_net: - ipv4_address: 192.168.71.131 - oai-amf: - container_name: "l2sim-oai-amf" - image: oaisoftwarealliance/oai-amf:v2.0.0 - environment: - - TZ=Europe/paris - volumes: - - ../5g_rfsimulator/mini_nonrf_config.yaml:/openair-amf/etc/config.yaml - depends_on: - - mysql - networks: - public_net: - ipv4_address: 192.168.71.132 - oai-smf: - container_name: "l2sim-oai-smf" - image: oaisoftwarealliance/oai-smf:v2.0.0 - environment: - - TZ=Europe/Paris - volumes: - - ../5g_rfsimulator/mini_nonrf_config.yaml:/openair-smf/etc/config.yaml - depends_on: - - oai-amf - networks: - public_net: - ipv4_address: 192.168.71.133 - oai-upf: - container_name: "l2sim-oai-upf" - image: oaisoftwarealliance/oai-upf:v2.0.0 - environment: - - TZ=Europe/Paris - volumes: - - ../5g_rfsimulator/mini_nonrf_config.yaml:/openair-upf/etc/config.yaml - depends_on: - - oai-smf - cap_add: - - NET_ADMIN - - SYS_ADMIN - cap_drop: - - ALL - privileged: true - networks: - public_net: - ipv4_address: 192.168.71.134 - traffic_net: - ipv4_address: 192.168.72.134 - oai-ext-dn: - privileged: true - container_name: "l2sim-oai-ext-dn" - image: oaisoftwarealliance/trf-gen-cn5g:focal - entrypoint: /bin/bash -c \ - "iptables -t nat -A POSTROUTING -o eth0 -j MASQUERADE;"\ - "ip route add 12.1.1.0/24 via 192.168.72.134 dev eth0; sleep infinity" - depends_on: - - oai-upf - networks: - traffic_net: - ipv4_address: 192.168.72.135 - healthcheck: - test: /bin/bash -c "ping -c 2 192.168.72.134" - interval: 10s - timeout: 5s - retries: 5 - oai-gnb: - image: ${REGISTRY:-oaisoftwarealliance}/${GNB_IMG:-oai-gnb}:${TAG:-develop} - container_name: "l2sim-oai-gnb" - cap_drop: - - ALL - network_mode: "host" - environment: - TZ: Europe/Paris - USE_ADDITIONAL_OPTIONS: --sa --nfapi VNF --emulate-l1 --log_config.global_log_options level,time,thread_id,nocolor - ASAN_OPTIONS: detect_leaks=0 - depends_on: - - oai-upf - - oai-amf - volumes: - - ../../conf_files/gnb.sa.band78.106prb.l2sim.conf:/opt/oai-gnb/etc/gnb.conf - healthcheck: - test: /bin/bash -c "pgrep nr-softmodem" - interval: 10s - timeout: 5s - retries: 5 - - proxy: - image: oai-lte-multi-ue-proxy:latest - container_name: "l2sim-proxy" - cap_drop: - - ALL - network_mode: "host" - environment: - TZ: Europe/Paris - command: "/oai-lte-multi-ue-proxy/bin/proxy 1 --nr" - depends_on: - - oai-gnb - healthcheck: - test: /bin/bash -c "pgrep proxy" - interval: 10s - timeout: 5s - retries: 5 - - oai-nr-ue0: - image: ${REGISTRY:-oaisoftwarealliance}/${NRUE_IMG:-oai-nr-ue}:${TAG:-develop} - container_name: "l2sim-oai-nr-ue0" - cap_drop: - - ALL - cap_add: - - NET_ADMIN # for interface bringup - - NET_RAW # for ping - network_mode: "host" - environment: - TZ: Europe/Paris - OPENAIR_DIR: /opt/oai-nr-ue - USE_ADDITIONAL_OPTIONS: --nfapi STANDALONE_PNF --node-number 2 --sa --emulate-l1 --log_config.global_log_options level,time,thread_id,nocolor - ASAN_OPTIONS: detect_leaks=0 - devices: - - /dev/net/tun:/dev/net/tun - volumes: - - ../../conf_files/nrue.band78.106prb.l2sim.conf:/opt/oai-nr-ue/etc/nr-ue.conf - - ../../../openair1/SIMULATION/LTE_PHY/BLER_SIMULATIONS/AWGN/AWGN_results:/opt/oai-nr-ue/openair1/SIMULATION/LTE_PHY/BLER_SIMULATIONS/AWGN/AWGN_results - depends_on: - - oai-gnb - - proxy - healthcheck: - test: /bin/bash -c "pgrep nr-uesoftmodem" - interval: 10s - timeout: 5s - retries: 5 - -networks: - public_net: - driver: bridge - name: l2sim-oai-public-net - ipam: - config: - - subnet: 192.168.71.128/26 - driver_opts: - com.docker.network.bridge.name: "l2sim-public" - traffic_net: - driver: bridge - name: l2sim-oai-traffic-net - ipam: - config: - - subnet: 192.168.72.128/26 - driver_opts: - com.docker.network.bridge.name: "l2sim-traffic" diff --git a/ci-scripts/yaml_files/5g_rfsimulator/README.md b/ci-scripts/yaml_files/5g_rfsimulator/README.md index e815047bda..0f71ce2780 100644 --- a/ci-scripts/yaml_files/5g_rfsimulator/README.md +++ b/ci-scripts/yaml_files/5g_rfsimulator/README.md @@ -244,7 +244,7 @@ Create the entry for the second UE in `docker-compose.yaml` file as follows: - NET_ADMIN # for interface bringup - NET_RAW # for ping environment: - USE_ADDITIONAL_OPTIONS: -E --sa --rfsim -r 106 --numerology 1 -C 3619200000 --rfsimulator.serveraddr 192.168.71.140 --log_config.global_log_options level,nocolor,time + USE_ADDITIONAL_OPTIONS: -E --rfsim -r 106 --numerology 1 -C 3619200000 --rfsimulator.serveraddr 192.168.71.140 --log_config.global_log_options level,nocolor,time depends_on: - oai-gnb devices: diff --git a/ci-scripts/yaml_files/5g_rfsimulator/docker-compose.yaml b/ci-scripts/yaml_files/5g_rfsimulator/docker-compose.yaml index 448bf45dc4..c563461af8 100644 --- a/ci-scripts/yaml_files/5g_rfsimulator/docker-compose.yaml +++ b/ci-scripts/yaml_files/5g_rfsimulator/docker-compose.yaml @@ -86,7 +86,7 @@ services: cap_drop: - ALL environment: - USE_ADDITIONAL_OPTIONS: --sa -E --rfsim --log_config.global_log_options level,nocolor,time + USE_ADDITIONAL_OPTIONS: -E --rfsim --log_config.global_log_options level,nocolor,time ASAN_OPTIONS: detect_leaks=0 depends_on: - oai-ext-dn @@ -109,7 +109,7 @@ services: - NET_ADMIN # for interface bringup - NET_RAW # for ping environment: - USE_ADDITIONAL_OPTIONS: -E --sa --rfsim -r 106 --numerology 1 --uicc0.imsi 208990100001100 -C 3319680000 --rfsimulator.serveraddr 192.168.71.140 --log_config.global_log_options level,nocolor,time + USE_ADDITIONAL_OPTIONS: -E --rfsim -r 106 --numerology 1 --uicc0.imsi 208990100001100 -C 3319680000 --rfsimulator.serveraddr 192.168.71.140 --log_config.global_log_options level,nocolor,time depends_on: - oai-gnb networks: @@ -133,7 +133,7 @@ services: - NET_ADMIN # for interface bringup - NET_RAW # for ping environment: - USE_ADDITIONAL_OPTIONS: -E --sa --rfsim -r 106 --numerology 1 --uicc0.imsi 208990100001101 -C 3319680000 --rfsimulator.serveraddr 192.168.71.140 --log_config.global_log_options level,nocolor,time + USE_ADDITIONAL_OPTIONS: -E --rfsim -r 106 --numerology 1 --uicc0.imsi 208990100001101 -C 3319680000 --rfsimulator.serveraddr 192.168.71.140 --log_config.global_log_options level,nocolor,time depends_on: - oai-gnb networks: @@ -157,7 +157,7 @@ services: - NET_ADMIN # for interface bringup - NET_RAW # for ping environment: - USE_ADDITIONAL_OPTIONS: -E --sa --rfsim -r 106 --numerology 1 --uicc0.imsi 208990100001102 -C 3319680000 --rfsimulator.serveraddr 192.168.71.140 --log_config.global_log_options level,nocolor,time + USE_ADDITIONAL_OPTIONS: -E --rfsim -r 106 --numerology 1 --uicc0.imsi 208990100001102 -C 3319680000 --rfsimulator.serveraddr 192.168.71.140 --log_config.global_log_options level,nocolor,time depends_on: - oai-gnb networks: @@ -181,7 +181,7 @@ services: - NET_ADMIN # for interface bringup - NET_RAW # for ping environment: - USE_ADDITIONAL_OPTIONS: -E --sa --rfsim -r 106 --numerology 1 --uicc0.imsi 208990100001103 -C 3319680000 --rfsimulator.serveraddr 192.168.71.140 --log_config.global_log_options level,nocolor,time + USE_ADDITIONAL_OPTIONS: -E --rfsim -r 106 --numerology 1 --uicc0.imsi 208990100001103 -C 3319680000 --rfsimulator.serveraddr 192.168.71.140 --log_config.global_log_options level,nocolor,time depends_on: - oai-gnb networks: @@ -205,7 +205,7 @@ services: - NET_ADMIN # for interface bringup - NET_RAW # for ping environment: - USE_ADDITIONAL_OPTIONS: -E --sa --rfsim -r 106 --numerology 1 --uicc0.imsi 208990100001104 -C 3319680000 --rfsimulator.serveraddr 192.168.71.140 --log_config.global_log_options level,nocolor,time + USE_ADDITIONAL_OPTIONS: -E --rfsim -r 106 --numerology 1 --uicc0.imsi 208990100001104 -C 3319680000 --rfsimulator.serveraddr 192.168.71.140 --log_config.global_log_options level,nocolor,time depends_on: - oai-gnb networks: @@ -229,7 +229,7 @@ services: - NET_ADMIN # for interface bringup - NET_RAW # for ping environment: - USE_ADDITIONAL_OPTIONS: -E --sa --rfsim -r 106 --numerology 1 --uicc0.imsi 208990100001105 -C 3319680000 --rfsimulator.serveraddr 192.168.71.140 --log_config.global_log_options level,nocolor,time + USE_ADDITIONAL_OPTIONS: -E --rfsim -r 106 --numerology 1 --uicc0.imsi 208990100001105 -C 3319680000 --rfsimulator.serveraddr 192.168.71.140 --log_config.global_log_options level,nocolor,time depends_on: - oai-gnb networks: @@ -253,7 +253,7 @@ services: - NET_ADMIN # for interface bringup - NET_RAW # for ping environment: - USE_ADDITIONAL_OPTIONS: -E --sa --rfsim -r 106 --numerology 1 --uicc0.imsi 208990100001106 -C 3319680000 --rfsimulator.serveraddr 192.168.71.140 --log_config.global_log_options level,nocolor,time + USE_ADDITIONAL_OPTIONS: -E --rfsim -r 106 --numerology 1 --uicc0.imsi 208990100001106 -C 3319680000 --rfsimulator.serveraddr 192.168.71.140 --log_config.global_log_options level,nocolor,time depends_on: - oai-gnb networks: @@ -277,7 +277,7 @@ services: - NET_ADMIN # for interface bringup - NET_RAW # for ping environment: - USE_ADDITIONAL_OPTIONS: -E --sa --rfsim -r 106 --numerology 1 --uicc0.imsi 208990100001107 -C 3319680000 --rfsimulator.serveraddr 192.168.71.140 --log_config.global_log_options level,nocolor,time + USE_ADDITIONAL_OPTIONS: -E --rfsim -r 106 --numerology 1 --uicc0.imsi 208990100001107 -C 3319680000 --rfsimulator.serveraddr 192.168.71.140 --log_config.global_log_options level,nocolor,time depends_on: - oai-gnb networks: @@ -301,7 +301,7 @@ services: - NET_ADMIN # for interface bringup - NET_RAW # for ping environment: - USE_ADDITIONAL_OPTIONS: -E --sa --rfsim -r 106 --numerology 1 --uicc0.imsi 208990100001108 -C 3319680000 --rfsimulator.serveraddr 192.168.71.140 --log_config.global_log_options level,nocolor,time + USE_ADDITIONAL_OPTIONS: -E --rfsim -r 106 --numerology 1 --uicc0.imsi 208990100001108 -C 3319680000 --rfsimulator.serveraddr 192.168.71.140 --log_config.global_log_options level,nocolor,time depends_on: - oai-gnb networks: @@ -325,7 +325,7 @@ services: - NET_ADMIN # for interface bringup - NET_RAW # for ping environment: - USE_ADDITIONAL_OPTIONS: -E --sa --rfsim -r 106 --numerology 1 --uicc0.imsi 208990100001109 -C 3319680000 --rfsimulator.serveraddr 192.168.71.140 --log_config.global_log_options level,nocolor,time + USE_ADDITIONAL_OPTIONS: -E --rfsim -r 106 --numerology 1 --uicc0.imsi 208990100001109 -C 3319680000 --rfsimulator.serveraddr 192.168.71.140 --log_config.global_log_options level,nocolor,time depends_on: - oai-gnb networks: diff --git a/ci-scripts/yaml_files/5g_rfsimulator/local-override-ue-gdb.yaml b/ci-scripts/yaml_files/5g_rfsimulator/local-override-ue-gdb.yaml index 83498e44f7..0b2b60210a 100644 --- a/ci-scripts/yaml_files/5g_rfsimulator/local-override-ue-gdb.yaml +++ b/ci-scripts/yaml_files/5g_rfsimulator/local-override-ue-gdb.yaml @@ -3,4 +3,4 @@ services: privileged: true stdin_open: true tty: true - command: gdb --args /opt/oai-nr-ue/bin/nr-uesoftmodem -O /opt/oai-nr-ue/etc/nr-ue.conf -E --sa --rfsim -r 106 --numerology 1 --uicc0.imsi 208990100001100 -C 3619200000 --rfsimulator.serveraddr 192.168.71.140 --log_config.global_log_options level,nocolor,time + command: gdb --args /opt/oai-nr-ue/bin/nr-uesoftmodem -O /opt/oai-nr-ue/etc/nr-ue.conf -E --rfsim -r 106 --numerology 1 --uicc0.imsi 208990100001100 -C 3619200000 --rfsimulator.serveraddr 192.168.71.140 --log_config.global_log_options level,nocolor,time diff --git a/ci-scripts/yaml_files/5g_rfsimulator_24prb/docker-compose.yaml b/ci-scripts/yaml_files/5g_rfsimulator_24prb/docker-compose.yaml index 29f2618365..ae74649a83 100644 --- a/ci-scripts/yaml_files/5g_rfsimulator_24prb/docker-compose.yaml +++ b/ci-scripts/yaml_files/5g_rfsimulator_24prb/docker-compose.yaml @@ -86,7 +86,7 @@ services: cap_drop: - ALL environment: - USE_ADDITIONAL_OPTIONS: --sa --rfsim --log_config.global_log_options level,nocolor,time + USE_ADDITIONAL_OPTIONS: --rfsim --log_config.global_log_options level,nocolor,time ASAN_OPTIONS: detect_leaks=0 depends_on: - oai-ext-dn @@ -109,7 +109,7 @@ services: - NET_ADMIN # for interface bringup - NET_RAW # for ping environment: - USE_ADDITIONAL_OPTIONS: --sa --rfsim -r 24 --ssb 24 --numerology 1 -C 3604800000 --uicc0.imsi 208990100001100 --rfsimulator.serveraddr 192.168.71.140 --log_config.global_log_options level,nocolor,time + USE_ADDITIONAL_OPTIONS: --rfsim -r 24 --ssb 24 --numerology 1 -C 3604800000 --uicc0.imsi 208990100001100 --rfsimulator.serveraddr 192.168.71.140 --log_config.global_log_options level,nocolor,time depends_on: - oai-gnb networks: diff --git a/ci-scripts/yaml_files/5g_rfsimulator_2x2/docker-compose.yaml b/ci-scripts/yaml_files/5g_rfsimulator_2x2/docker-compose.yaml index e611ec3a1a..a291046b47 100644 --- a/ci-scripts/yaml_files/5g_rfsimulator_2x2/docker-compose.yaml +++ b/ci-scripts/yaml_files/5g_rfsimulator_2x2/docker-compose.yaml @@ -86,7 +86,7 @@ services: cap_drop: - ALL environment: - USE_ADDITIONAL_OPTIONS: --sa --rfsim --log_config.global_log_options level,nocolor,time + USE_ADDITIONAL_OPTIONS: --rfsim --log_config.global_log_options level,nocolor,time ASAN_OPTIONS: detect_leaks=0 depends_on: - oai-ext-dn @@ -110,7 +110,7 @@ services: - NET_ADMIN # for interface bringup - NET_RAW # for ping environment: - USE_ADDITIONAL_OPTIONS: --sa --rfsim -r 273 --numerology 1 --band 78 -C 3450720000 --ssb 1518 --ue-nb-ant-tx 2 --uicc0.imsi 208990100001100 --ue-nb-ant-rx 2 --uecap_file /opt/oai-nr-ue/etc/uecap.xml --rfsimulator.serveraddr 192.168.71.140 --log_config.global_log_options level,nocolor,time + USE_ADDITIONAL_OPTIONS: --rfsim -r 273 --numerology 1 --band 78 -C 3450720000 --ssb 1518 --ue-nb-ant-tx 2 --uicc0.imsi 208990100001100 --ue-nb-ant-rx 2 --uecap_file /opt/oai-nr-ue/etc/uecap.xml --rfsimulator.serveraddr 192.168.71.140 --log_config.global_log_options level,nocolor,time depends_on: - oai-gnb networks: diff --git a/ci-scripts/yaml_files/5g_rfsimulator_accelleran/docker-compose.yaml b/ci-scripts/yaml_files/5g_rfsimulator_accelleran/docker-compose.yaml deleted file mode 100644 index 8ecb2f9c91..0000000000 --- a/ci-scripts/yaml_files/5g_rfsimulator_accelleran/docker-compose.yaml +++ /dev/null @@ -1,38 +0,0 @@ -services: - oai-du: - image: ${REGISTRY:-oaisoftwarealliance}/${GNB_IMG:-oai-gnb}:${TAG:-develop} - container_name: rfsim5g-oai-du - cap_drop: - - ALL - network_mode: "host" - environment: - USE_ADDITIONAL_OPTIONS: --sa --rfsim --MACRLCs.[0].local_n_address 172.21.16.109 --MACRLCs.[0].remote_n_address 172.21.6.22 --log_config.global_log_options level,nocolor,time - volumes: - - ../../conf_files/gnb-du.band78.106prb.rfsim.conf:/opt/oai-gnb/etc/gnb.conf - healthcheck: - test: /bin/bash -c "pgrep nr-softmodem" - interval: 10s - timeout: 5s - retries: 5 - oai-nr-ue: - image: ${REGISTRY:-oaisoftwarealliance}/${NRUE_IMG:-oai-nr-ue}:${TAG:-develop} - container_name: rfsim5g-oai-nr-ue - cap_drop: - - ALL - cap_add: - - NET_ADMIN # for interface bringup - - NET_RAW # for ping - network_mode: "host" - environment: - USE_ADDITIONAL_OPTIONS: --sa --rfsim -r 106 --numerology 1 -C 3619200000 --uicc0.imsi 208990100001140 --rfsimulator.serveraddr 127.0.0.1 --log_config.global_log_options level,nocolor,time - depends_on: - - oai-du - devices: - - /dev/net/tun:/dev/net/tun - volumes: - - ../../conf_files/nrue.uicc.conf:/opt/oai-nr-ue/etc/nr-ue.conf - healthcheck: - test: /bin/bash -c "pgrep nr-uesoftmodem" - interval: 10s - timeout: 5s - retries: 5 diff --git a/ci-scripts/yaml_files/5g_rfsimulator_e1/docker-compose.yaml b/ci-scripts/yaml_files/5g_rfsimulator_e1/docker-compose.yaml index c5d4d3aa61..b74aace725 100644 --- a/ci-scripts/yaml_files/5g_rfsimulator_e1/docker-compose.yaml +++ b/ci-scripts/yaml_files/5g_rfsimulator_e1/docker-compose.yaml @@ -70,7 +70,7 @@ services: cap_drop: - ALL environment: - USE_ADDITIONAL_OPTIONS: --sa --log_config.global_log_options level,nocolor,time + USE_ADDITIONAL_OPTIONS: --log_config.global_log_options level,nocolor,time --gNBs.[0].E1_INTERFACE.[0].ipv4_cucp 192.168.77.2 --gNBs.[0].local_s_address 192.168.72.2 ASAN_OPTIONS: detect_leaks=0 @@ -97,7 +97,7 @@ services: cap_drop: - ALL environment: - USE_ADDITIONAL_OPTIONS: --sa --log_config.global_log_options level,nocolor,time + USE_ADDITIONAL_OPTIONS: --log_config.global_log_options level,nocolor,time --gNBs.[0].E1_INTERFACE.[0].ipv4_cucp 192.168.77.2 --gNBs.[0].E1_INTERFACE.[0].ipv4_cuup 192.168.77.3 --gNBs.[0].local_s_address 192.168.73.2 @@ -126,7 +126,7 @@ services: cap_drop: - ALL environment: - USE_ADDITIONAL_OPTIONS: --sa --log_config.global_log_options level,nocolor,time + USE_ADDITIONAL_OPTIONS: --log_config.global_log_options level,nocolor,time --gNBs.[0].gNB_CU_UP_ID 0xe01 --gNBs.[0].E1_INTERFACE.[0].ipv4_cucp 192.168.77.2 --gNBs.[0].E1_INTERFACE.[0].ipv4_cuup 192.168.77.4 @@ -158,7 +158,7 @@ services: cap_drop: - ALL environment: - USE_ADDITIONAL_OPTIONS: --sa --log_config.global_log_options level,nocolor,time + USE_ADDITIONAL_OPTIONS: --log_config.global_log_options level,nocolor,time --gNBs.[0].gNB_CU_UP_ID 0xe02 --gNBs.[0].E1_INTERFACE.[0].ipv4_cucp 192.168.77.2 --gNBs.[0].E1_INTERFACE.[0].ipv4_cuup 192.168.77.5 @@ -190,7 +190,7 @@ services: cap_drop: - ALL environment: - USE_ADDITIONAL_OPTIONS: --sa --rfsim --log_config.global_log_options level,nocolor,time + USE_ADDITIONAL_OPTIONS: --rfsim --log_config.global_log_options level,nocolor,time --MACRLCs.[0].local_n_address 192.168.72.3 --MACRLCs.[0].remote_n_address oai-cucp --MACRLCs.[0].local_n_address_f1u 192.168.73.3 @@ -219,7 +219,7 @@ services: cap_drop: - ALL environment: - USE_ADDITIONAL_OPTIONS: --sa --rfsim --log_config.global_log_options level,nocolor,time + USE_ADDITIONAL_OPTIONS: --rfsim --log_config.global_log_options level,nocolor,time --gNBs.[0].gNB_DU_ID 0xe01 --gNBs.[0].nr_cellid 87654321 --gNBs.[0].servingCellConfigCommon.[0].physCellId 1 @@ -251,7 +251,7 @@ services: cap_drop: - ALL environment: - USE_ADDITIONAL_OPTIONS: --sa --rfsim --log_config.global_log_options level,nocolor,time + USE_ADDITIONAL_OPTIONS: --rfsim --log_config.global_log_options level,nocolor,time --gNBs.[0].gNB_DU_ID 0xe02 --gNBs.[0].nr_cellid 11111111 --gNBs.[0].servingCellConfigCommon.[0].physCellId 2 @@ -286,7 +286,7 @@ services: - NET_ADMIN # for interface bringup - NET_RAW # for ping environment: - USE_ADDITIONAL_OPTIONS: --sa --rfsim --log_config.global_log_options level,nocolor,time + USE_ADDITIONAL_OPTIONS: --rfsim --log_config.global_log_options level,nocolor,time -r 106 --numerology 1 -C 3619200000 --uicc0.imsi 208990100001100 --rfsimulator.serveraddr oai-du @@ -314,7 +314,7 @@ services: - NET_ADMIN # for interface bringup - NET_RAW # for ping environment: - USE_ADDITIONAL_OPTIONS: --sa --rfsim --log_config.global_log_options level,nocolor,time + USE_ADDITIONAL_OPTIONS: --rfsim --log_config.global_log_options level,nocolor,time -r 106 --numerology 1 -C 3619200000 --uicc0.imsi 208990100001101 --uicc0.nssai_sst 2 --rfsimulator.serveraddr 192.168.78.3 @@ -342,7 +342,7 @@ services: - NET_ADMIN # for interface bringup - NET_RAW # for ping environment: - USE_ADDITIONAL_OPTIONS: --sa --rfsim --log_config.global_log_options level,nocolor,time + USE_ADDITIONAL_OPTIONS: --rfsim --log_config.global_log_options level,nocolor,time -r 106 --numerology 1 -C 3619200000 --uicc0.imsi 208990100001102 --uicc0.nssai_sst 3 --rfsimulator.serveraddr 192.168.78.4 diff --git a/ci-scripts/yaml_files/5g_rfsimulator_fr2_32prb/docker-compose.yaml b/ci-scripts/yaml_files/5g_rfsimulator_fr2_32prb/docker-compose.yaml index de43f8742e..91d7b7c246 100644 --- a/ci-scripts/yaml_files/5g_rfsimulator_fr2_32prb/docker-compose.yaml +++ b/ci-scripts/yaml_files/5g_rfsimulator_fr2_32prb/docker-compose.yaml @@ -87,7 +87,7 @@ services: cap_drop: - ALL environment: - USE_ADDITIONAL_OPTIONS: --sa --rfsim --log_config.global_log_options level,nocolor,time + USE_ADDITIONAL_OPTIONS: --rfsim --log_config.global_log_options level,nocolor,time ASAN_OPTIONS: detect_leaks=0 networks: public_net: @@ -109,7 +109,7 @@ services: - NET_ADMIN # for interface bringup - NET_RAW # for ping environment: - USE_ADDITIONAL_OPTIONS: --sa --rfsim + USE_ADDITIONAL_OPTIONS: --rfsim --rfsimulator.serveraddr 192.168.71.140 --log_config.global_log_options level,nocolor,time -r 32 --numerology 3 --band 261 -C 27533160000 --ssb 73 ASAN_OPTIONS: detect_leaks=0 diff --git a/ci-scripts/yaml_files/5g_rfsimulator_ntn_geo/docker-compose.yaml b/ci-scripts/yaml_files/5g_rfsimulator_ntn_geo/docker-compose.yaml index 581dd266c0..5876f5683c 100644 --- a/ci-scripts/yaml_files/5g_rfsimulator_ntn_geo/docker-compose.yaml +++ b/ci-scripts/yaml_files/5g_rfsimulator_ntn_geo/docker-compose.yaml @@ -86,7 +86,7 @@ services: cap_drop: - ALL environment: - USE_ADDITIONAL_OPTIONS: --sa --rfsim --rfsimulator.prop_delay 238.74 --log_config.global_log_options level,nocolor,time + USE_ADDITIONAL_OPTIONS: --rfsim --rfsimulator.prop_delay 238.74 --log_config.global_log_options level,nocolor,time ASAN_OPTIONS: detect_leaks=0 depends_on: - oai-ext-dn @@ -110,7 +110,7 @@ services: - NET_ADMIN # for interface bringup - NET_RAW # for ping environment: - USE_ADDITIONAL_OPTIONS: --band 66 -C 2152680000 --CO -400000000 -r 25 --numerology 0 --ssb 48 --sa --rfsim --rfsimulator.prop_delay 238.74 --ntn-koffset 478 --ntn-ta-common 477.48 --rfsimulator.serveraddr 192.168.71.140 --log_config.global_log_options level,nocolor,time + USE_ADDITIONAL_OPTIONS: --band 66 -C 2152680000 --CO -400000000 -r 25 --numerology 0 --ssb 48 --rfsim --rfsimulator.prop_delay 238.74 --ntn-koffset 478 --ntn-ta-common 477.48 --rfsimulator.serveraddr 192.168.71.140 --log_config.global_log_options level,nocolor,time depends_on: - oai-gnb networks: diff --git a/ci-scripts/yaml_files/5g_rfsimulator_u0_25prb/docker-compose.yaml b/ci-scripts/yaml_files/5g_rfsimulator_u0_25prb/docker-compose.yaml index 197c43a476..50871c5131 100644 --- a/ci-scripts/yaml_files/5g_rfsimulator_u0_25prb/docker-compose.yaml +++ b/ci-scripts/yaml_files/5g_rfsimulator_u0_25prb/docker-compose.yaml @@ -86,7 +86,7 @@ services: cap_drop: - ALL environment: - USE_ADDITIONAL_OPTIONS: --sa --rfsim --log_config.global_log_options level,nocolor,time + USE_ADDITIONAL_OPTIONS: --rfsim --log_config.global_log_options level,nocolor,time ASAN_OPTIONS: detect_leaks=0 depends_on: - oai-ext-dn @@ -110,7 +110,7 @@ services: - NET_ADMIN # for interface bringup - NET_RAW # for ping environment: - USE_ADDITIONAL_OPTIONS: --sa --rfsim -r 25 --numerology 0 --uicc0.imsi 208990100001100 --band 66 -C 2152680000 --CO -400000000 --ssb 48 --rfsimulator.serveraddr 192.168.71.140 --log_config.global_log_options level,nocolor,time + USE_ADDITIONAL_OPTIONS: --rfsim -r 25 --numerology 0 --uicc0.imsi 208990100001100 --band 66 -C 2152680000 --CO -400000000 --ssb 48 --rfsimulator.serveraddr 192.168.71.140 --log_config.global_log_options level,nocolor,time depends_on: - oai-gnb networks: diff --git a/ci-scripts/yaml_files/5g_sa_n310_4x4_60MHz/docker-compose.yml b/ci-scripts/yaml_files/5g_sa_n310_4x4_60MHz/docker-compose.yml new file mode 100644 index 0000000000..ed6c76ae78 --- /dev/null +++ b/ci-scripts/yaml_files/5g_sa_n310_4x4_60MHz/docker-compose.yml @@ -0,0 +1,20 @@ +services: + oai-gnb: + image: ${REGISTRY:-oaisoftwarealliance}/${GNB_IMG:-oai-gnb}:${TAG:-develop} + network_mode: "host" + container_name: oai-gnb + cap_drop: + - ALL + cap_add: + - SYS_NICE + - IPC_LOCK + environment: + TZ: Europe/Paris + USE_ADDITIONAL_OPTIONS: --log_config.global_log_options level,nocolor,time + volumes: + - ../../conf_files/gnb.sa.band77.162prb.usrpn310.4x4.conf:/opt/oai-gnb/etc/gnb.conf + healthcheck: + test: /bin/bash -c "pgrep nr-softmodem" + interval: 10s + timeout: 5s + retries: 5 diff --git a/ci-scripts/yaml_files/5g_sa_n310_gnb/docker-compose.yml b/ci-scripts/yaml_files/5g_sa_n310_gnb/docker-compose.yml index 330b4b022b..e93152bd37 100644 --- a/ci-scripts/yaml_files/5g_sa_n310_gnb/docker-compose.yml +++ b/ci-scripts/yaml_files/5g_sa_n310_gnb/docker-compose.yml @@ -12,7 +12,7 @@ services: core: -1 # for core dumps environment: TZ: Europe/Paris - USE_ADDITIONAL_OPTIONS: --sa --tune-offset 20000000 -A 90 --log_config.global_log_options level,nocolor,time + USE_ADDITIONAL_OPTIONS: --tune-offset 20000000 -A 90 --log_config.global_log_options level,nocolor,time volumes: - ../../conf_files/gnb.sa.band78.106prb.n310.7ds2u.conf:/opt/oai-gnb/etc/gnb.conf healthcheck: diff --git a/ci-scripts/yaml_files/5g_sa_n310_nrue/docker-compose.yml b/ci-scripts/yaml_files/5g_sa_n310_nrue/docker-compose.yml index 0cf5db7dc4..a0a15ac11e 100644 --- a/ci-scripts/yaml_files/5g_sa_n310_nrue/docker-compose.yml +++ b/ci-scripts/yaml_files/5g_sa_n310_nrue/docker-compose.yml @@ -17,7 +17,7 @@ services: #entrypoint: /bin/bash -c "sleep infinity" environment: TZ: Europe/Paris - USE_ADDITIONAL_OPTIONS: --usrp-args type=n3xx,name=ni-n3xx-31641B9,addr=192.168.10.2 -r 106 --numerology 1 --band 78 -C 3511200000 --sa --ue-fo-compensation --ue-rxgain 65 --tune-offset 20000000 -A 90 --log_config.global_log_options level,nocolor,time --uicc0.imsi 001020000000111 --uicc0.nssai_sd 16777215 + USE_ADDITIONAL_OPTIONS: --usrp-args type=n3xx,name=ni-n3xx-31641B9,addr=192.168.10.2 -r 106 --numerology 1 --band 78 -C 3511200000 --ue-fo-compensation --ue-rxgain 65 --tune-offset 20000000 -A 90 --log_config.global_log_options level,nocolor,time --uicc0.imsi 001020000000111 --uicc0.nssai_sd 16777215 volumes: - ../../conf_files/ue.sa.conf:/opt/oai-nr-ue/etc/nr-ue.conf healthcheck: diff --git a/ci-scripts/yaml_files/nsa_b200_gnb/docker-compose.yml b/ci-scripts/yaml_files/nsa_b200_gnb/docker-compose.yml index 28bf0bc1f3..3bd90a3fff 100644 --- a/ci-scripts/yaml_files/nsa_b200_gnb/docker-compose.yml +++ b/ci-scripts/yaml_files/nsa_b200_gnb/docker-compose.yml @@ -11,7 +11,7 @@ services: core: -1 # for core dumps environment: USE_B2XX: 'yes' - USE_ADDITIONAL_OPTIONS: -E -q --RUs.[0].sdr_addrs serial=30C51D4 --continuous-tx --log_config.global_log_options level,nocolor,time,line_num,function + USE_ADDITIONAL_OPTIONS: --nsa -E -q --RUs.[0].sdr_addrs serial=30C51D4 --continuous-tx --log_config.global_log_options level,nocolor,time,line_num,function devices: - /dev/bus/usb/:/dev/bus/usb/ volumes: diff --git a/ci-scripts/yaml_files/sa_aw2s_2x2_gnb/docker-compose.yml b/ci-scripts/yaml_files/sa_aw2s_2x2_gnb/docker-compose.yml index d1f5ae2475..a1baef974a 100644 --- a/ci-scripts/yaml_files/sa_aw2s_2x2_gnb/docker-compose.yml +++ b/ci-scripts/yaml_files/sa_aw2s_2x2_gnb/docker-compose.yml @@ -12,7 +12,6 @@ services: core: -1 # for core dumps environment: TZ: Europe/Paris - USE_ADDITIONAL_OPTIONS: --sa volumes: - ../../conf_files/gnb.sa.band78.51prb.aw2s.ddsuu.2x2.conf:/opt/oai-gnb-aw2s/etc/gnb.conf healthcheck: diff --git a/ci-scripts/yaml_files/sa_aw2s_gnb/docker-compose.yml b/ci-scripts/yaml_files/sa_aw2s_gnb/docker-compose.yml index 03b9914404..9530b3cd5c 100644 --- a/ci-scripts/yaml_files/sa_aw2s_gnb/docker-compose.yml +++ b/ci-scripts/yaml_files/sa_aw2s_gnb/docker-compose.yml @@ -12,7 +12,6 @@ services: core: -1 # for core dumps environment: TZ: Europe/Paris - USE_ADDITIONAL_OPTIONS: --sa volumes: - ../../conf_files/gnb.sa.band78.51prb.aw2s.ddsuu.conf:/opt/oai-gnb-aw2s/etc/gnb.conf healthcheck: diff --git a/ci-scripts/yaml_files/sa_b200_gnb/docker-compose.yml b/ci-scripts/yaml_files/sa_b200_gnb/docker-compose.yml index b11fc2d7fa..7fe7db5317 100644 --- a/ci-scripts/yaml_files/sa_b200_gnb/docker-compose.yml +++ b/ci-scripts/yaml_files/sa_b200_gnb/docker-compose.yml @@ -11,7 +11,7 @@ services: core: -1 # for core dumps environment: USE_B2XX: 'yes' - USE_ADDITIONAL_OPTIONS: --sa --RUs.[0].sdr_addrs serial=30C51D4 --telnetsrv --telnetsrv.shrmod ci --continuous-tx --log_config.global_log_options level,nocolor,time,line_num,function + USE_ADDITIONAL_OPTIONS: --RUs.[0].sdr_addrs serial=30C51D4 --telnetsrv --telnetsrv.shrmod ci --continuous-tx --log_config.global_log_options level,nocolor,time,line_num,function devices: - /dev/bus/usb/:/dev/bus/usb/ volumes: diff --git a/ci-scripts/yaml_files/sa_e1_b200_gnb/docker-compose.yml b/ci-scripts/yaml_files/sa_e1_b200_gnb/docker-compose.yml index e1893765d1..6c3940d306 100644 --- a/ci-scripts/yaml_files/sa_e1_b200_gnb/docker-compose.yml +++ b/ci-scripts/yaml_files/sa_e1_b200_gnb/docker-compose.yml @@ -7,8 +7,7 @@ services: ulimits: core: -1 # for core dumps environment: - USE_ADDITIONAL_OPTIONS: --sa - --telnetsrv --telnetsrv.listenport 9090 --telnetsrv.shrmod ci + USE_ADDITIONAL_OPTIONS: --telnetsrv --telnetsrv.listenport 9090 --telnetsrv.shrmod ci --log_config.global_log_options level,nocolor,time,line_num,function volumes: - ../../conf_files/gnb-cucp.sa.f1.quectel.conf:/opt/oai-gnb/etc/gnb.conf @@ -35,8 +34,7 @@ services: ulimits: core: -1 # for core dumps environment: - USE_ADDITIONAL_OPTIONS: --sa - --log_config.global_log_options level,nocolor,time,line_num,function + USE_ADDITIONAL_OPTIONS: --log_config.global_log_options level,nocolor,time,line_num,function volumes: - ../../conf_files/gnb-cuup.sa.f1.quectel.conf:/opt/oai-gnb/etc/gnb.conf # for performance reasons, we use host mode: in bridge mode, we have @@ -63,8 +61,7 @@ services: core: -1 # for core dumps environment: USE_B2XX: 'yes' - USE_ADDITIONAL_OPTIONS: --sa - --RUs.[0].sdr_addrs serial=30C51D4 + USE_ADDITIONAL_OPTIONS: --RUs.[0].sdr_addrs serial=30C51D4 --continuous-tx -E --telnetsrv --telnetsrv.listenport 9091 --telnetsrv.shrmod ci --log_config.global_log_options level,nocolor,time,line_num,function diff --git a/ci-scripts/yaml_files/sa_f1_b200_gnb/docker-compose.yml b/ci-scripts/yaml_files/sa_f1_b200_gnb/docker-compose.yml index 4965111c32..2c1ab75e92 100644 --- a/ci-scripts/yaml_files/sa_f1_b200_gnb/docker-compose.yml +++ b/ci-scripts/yaml_files/sa_f1_b200_gnb/docker-compose.yml @@ -7,8 +7,7 @@ services: ulimits: core: -1 # for core dumps environment: - USE_ADDITIONAL_OPTIONS: --sa - --telnetsrv --telnetsrv.listenport 9090 --telnetsrv.shrmod ci + USE_ADDITIONAL_OPTIONS: --telnetsrv --telnetsrv.listenport 9090 --telnetsrv.shrmod ci --log_config.global_log_options level,nocolor,time,line_num,function volumes: - ../../conf_files/gnb-cu.sa.f1.conf:/opt/oai-gnb/etc/gnb.conf @@ -37,7 +36,7 @@ services: core: -1 # for core dumps environment: USE_B2XX: 'yes' - USE_ADDITIONAL_OPTIONS: --sa --RUs.[0].sdr_addrs serial=30C51D4 --continuous-tx + USE_ADDITIONAL_OPTIONS: --RUs.[0].sdr_addrs serial=30C51D4 --continuous-tx --telnetsrv --telnetsrv.listenport 9091 --telnetsrv.shrmod ci --gNBs.[0].min_rxtxtime 2 --gNBs.[0].do_CSIRS 1 --gNBs.[0].do_SRS 0 --L1s.[0].max_ldpc_iterations 20 --log_config.global_log_options level,nocolor,time,line_num,function diff --git a/ci-scripts/yaml_files/sa_fhi_7.2_benetel550_gnb/docker-compose.yml b/ci-scripts/yaml_files/sa_fhi_7.2_benetel550_gnb/docker-compose.yml index 1228160fbb..a0bc415730 100644 --- a/ci-scripts/yaml_files/sa_fhi_7.2_benetel550_gnb/docker-compose.yml +++ b/ci-scripts/yaml_files/sa_fhi_7.2_benetel550_gnb/docker-compose.yml @@ -10,7 +10,7 @@ services: container_name: oai-gnb environment: TZ: Europe/Paris - USE_ADDITIONAL_OPTIONS: --sa --thread-pool 6,7,8,9 + USE_ADDITIONAL_OPTIONS: --thread-pool 6,7,8,9 devices: - /dev/vfio:/dev/vfio/ volumes: diff --git a/ci-scripts/yaml_files/sa_fhi_7.2_vvdn_gnb/docker-compose.yml b/ci-scripts/yaml_files/sa_fhi_7.2_vvdn_gnb/docker-compose.yml index 4ea7498639..7ea8b576d4 100644 --- a/ci-scripts/yaml_files/sa_fhi_7.2_vvdn_gnb/docker-compose.yml +++ b/ci-scripts/yaml_files/sa_fhi_7.2_vvdn_gnb/docker-compose.yml @@ -10,7 +10,7 @@ services: container_name: oai-gnb environment: TZ: Europe/Paris - USE_ADDITIONAL_OPTIONS: --sa --thread-pool 6,7,8,9 + USE_ADDITIONAL_OPTIONS: --thread-pool 6,7,8,9 devices: - /dev/vfio:/dev/vfio/ volumes: diff --git a/ci-scripts/yaml_files/sa_sc_b200_gnb/docker-compose.yml b/ci-scripts/yaml_files/sa_sc_b200_gnb/docker-compose.yml index 70773fd1a9..f0b86f4c33 100644 --- a/ci-scripts/yaml_files/sa_sc_b200_gnb/docker-compose.yml +++ b/ci-scripts/yaml_files/sa_sc_b200_gnb/docker-compose.yml @@ -11,7 +11,7 @@ services: core: -1 # for core dumps environment: USE_B2XX: 'yes' - USE_ADDITIONAL_OPTIONS: --sa --RUs.[0].sdr_addrs serial=30C51D4 --telnetsrv --telnetsrv.shrmod ci --continuous-tx --log_config.global_log_options level,nocolor,time,line_num,function -E + USE_ADDITIONAL_OPTIONS: --RUs.[0].sdr_addrs serial=30C51D4 --telnetsrv --telnetsrv.shrmod ci --continuous-tx --log_config.global_log_options level,nocolor,time,line_num,function -E devices: - /dev/bus/usb/:/dev/bus/usb/ volumes: diff --git a/common/utils/LOG/DOC/lttng_logs.md b/common/utils/LOG/DOC/lttng_logs.md index 4b4eda43f5..8918cbffe4 100644 --- a/common/utils/LOG/DOC/lttng_logs.md +++ b/common/utils/LOG/DOC/lttng_logs.md @@ -65,7 +65,7 @@ Note: only LTTng 2.3.8 is supported. 1. **Run gNB:** ```bash - ./$binary_path -O $configuration_file PARALLEL_SINGLE_THREAD --rfsimulator.serveraddr server --rfsim --sa -E + ./$binary_path -O $configuration_file PARALLEL_SINGLE_THREAD --rfsimulator.serveraddr server --rfsim -E ``` ## Verifying Tracepoints diff --git a/common/utils/telnetsrv/telnetsrv_proccmd.c b/common/utils/telnetsrv/telnetsrv_proccmd.c index 4255b20956..f081bb66a1 100644 --- a/common/utils/telnetsrv/telnetsrv_proccmd.c +++ b/common/utils/telnetsrv/telnetsrv_proccmd.c @@ -32,6 +32,7 @@ #define _GNU_SOURCE #include #include +#include #include #include #include @@ -222,11 +223,8 @@ char aname[256]; tdata->numlines = 0; } - unsigned int eax = 11, ebx = 0, ecx = 1, edx = 0; - - asm volatile("cpuid" : "=a"(eax), "=b"(ebx), "=c"(ecx), "=d"(edx) : "0"(eax), "2"(ecx) :); - - prnt("System has %d cores %d threads %d Actual threads", eax, ebx, edx); + int nprocs = get_nprocs(); + prnt("System has %d cores", nprocs); prnt("\n id name state USRmod KRNmod prio nice vsize proc pol \n\n"); snprintf(aname, sizeof(aname), "/proc/%d/stat", getpid()); diff --git a/common/utils/telnetsrv/telnetsrv_rrc.c b/common/utils/telnetsrv/telnetsrv_rrc.c index 1c5e3765cb..d7e72983f7 100644 --- a/common/utils/telnetsrv/telnetsrv_rrc.c +++ b/common/utils/telnetsrv/telnetsrv_rrc.c @@ -49,7 +49,7 @@ * ./build_oai --build-lib telnetsrv * * Loading the module: - * sudo ./nr-softmodem --sa -E --rfsim --log_config.global_log_options level,nocolor,time -O ~/gnb.sa.band78.106prb.rfsim.conf --telnetsrv --telnetsrv.shrmod rrc + * sudo ./nr-softmodem -E --rfsim --log_config.global_log_options level,nocolor,time -O ~/gnb.sa.band78.106prb.rfsim.conf --telnetsrv --telnetsrv.shrmod rrc */ static int get_single_ue_id(void) diff --git a/common/utils/websrv/DOC/websrvuse.md b/common/utils/websrv/DOC/websrvuse.md index 23a59065f0..5e3b4dac21 100644 --- a/common/utils/websrv/DOC/websrvuse.md +++ b/common/utils/websrv/DOC/websrvuse.md @@ -277,7 +277,7 @@ To trigger the back-end use the `--websrv` option, possibly modifying the parame `./nr-softmodem -O /usr/local/oai/conf/gnb.band78.sa.fr1.106PRB.usrpb210.conf --rfsim --rfsimulator.serveraddr server --telnetsrv --telnetsrv.listenstdin --websrv --rfsimulator.options chanmod` -.`/nr-uesoftmodem -O /usr/local/oai/conf/nrue_sim.conf --sa --numerology 1 -r 106 -C 3649440000 --rfsim --rfsimulator.serveraddr 127.0.0.1 --websrv --telnetsrv --websrv.listenport 8092 --telnetsrv.listenport 8091` +`./nr-uesoftmodem -O /usr/local/oai/conf/nrue_sim.conf --numerology 1 -r 106 -C 3649440000 --rfsim --rfsimulator.serveraddr 127.0.0.1 --websrv --telnetsrv --websrv.listenport 8092 --telnetsrv.listenport 8091` diff --git a/doc/E1AP/E1-design.md b/doc/E1AP/E1-design.md index 4dd042f87d..e98c0ac581 100644 --- a/doc/E1AP/E1-design.md +++ b/doc/E1AP/E1-design.md @@ -139,7 +139,7 @@ Note: A 5G core must be running at this point. Steps to start the OAI 5G core ca 1. Start the CUCP first by running the following command ``` -sudo ./nr-softmodem -O ../../../ci-scripts/conf_files/gnb-cucp.sa.f1.conf --gNBs.[0].min_rxtxtime 6 --sa +sudo ./nr-softmodem -O ../../../ci-scripts/conf_files/gnb-cucp.sa.f1.conf --gNBs.[0].min_rxtxtime 6 ``` Note that `min_rxtxtime` should be set to `6` only when you are connecting an OAI UE to the gNB. @@ -148,12 +148,12 @@ Note that `min_rxtxtime` should be set to `6` only when you are connecting an OA CUUP (has its own executable): ``` -sudo ./nr-cuup -O ../../../ci-scripts/conf_files/gnb-cuup.sa.f1.conf --sa +sudo ./nr-cuup -O ../../../ci-scripts/conf_files/gnb-cuup.sa.f1.conf ``` DU: ``` -sudo ./nr-softmodem -O ../../../ci-scripts/conf_files/gNB_SA_DU.conf --rfsim --sa +sudo ./nr-softmodem -O ../../../ci-scripts/conf_files/gNB_SA_DU.conf --rfsim ``` You need to use `--rfsim` if you are running the test with rfsimulator. @@ -162,7 +162,7 @@ You need to use `--rfsim` if you are running the test with rfsimulator. OAI UE: ``` -sudo ./nr-uesoftmodem -r 106 --numerology 1 --band 78 -C 3619200000 --rfsim --sa --rfsimulator.serveraddr 127.0.0.1 +sudo ./nr-uesoftmodem -r 106 --numerology 1 --band 78 -C 3619200000 --rfsim --rfsimulator.serveraddr 127.0.0.1 ``` # 3. Configuration file IP addresses of network functions diff --git a/doc/F1AP/F1-design.md b/doc/F1AP/F1-design.md index 06f8a3115b..762eb67903 100644 --- a/doc/F1AP/F1-design.md +++ b/doc/F1AP/F1-design.md @@ -185,8 +185,8 @@ To start CU/DU, you use `./nr-softmodem` with the appropriate configuration files, for instance: ``` -sudo cmake_targets/ran_build/build/nr-softmodem --sa -O ci-scripts/conf_files/gnb-cu.sa.band78.106prb.conf -sudo cmake_targets/ran_build/build/nr-softmodem --sa -O ci-scripts/conf_files/gnb-du.sa.band78.106prb.rfsim.conf +sudo cmake_targets/ran_build/build/nr-softmodem -O ci-scripts/conf_files/gnb-cu.sa.band78.106prb.conf +sudo cmake_targets/ran_build/build/nr-softmodem -O ci-scripts/conf_files/gnb-du.sa.band78.106prb.rfsim.conf ``` These files are tested in the CI, and are configured for use in docker, diff --git a/doc/L2NFAPI.md b/doc/L2NFAPI.md index d7bba0bfeb..d9f0ad0435 100644 --- a/doc/L2NFAPI.md +++ b/doc/L2NFAPI.md @@ -42,6 +42,8 @@ Normally it should be fine to run both executables on the same host using the `l ## 5G L2 nFAPI simulator +**Note: L2 simulator does not work anymore.** + ### Download and Build the Proxy Server (from EpiSci) ```bash @@ -60,11 +62,11 @@ $ sudo -E ./build/proxy $number_of_ues --nr ### Start gNB ```bash -$ sudo -E ./nr-softmodem -O ../ci-scripts/conf_files/episci/proxy_rcc.band78.tm1.106PRB.nfapi.conf --nfapi VNF --noS1 --sa --emulate-l1 +$ sudo -E ./nr-softmodem -O ../ci-scripts/conf_files/episci/proxy_rcc.band78.tm1.106PRB.nfapi.conf --nfapi VNF --noS1 --emulate-l1 ``` ### Start UE ```bash -$ sudo -E ./nr-uesoftmodem -O ../ci-scripts/conf_files/nrue.uicc.conf --nfapi STANDALONE_PNF --node-number 2 --sa --emulate-l1 +$ sudo -E ./nr-uesoftmodem -O ../ci-scripts/conf_files/nrue.uicc.conf --nfapi STANDALONE_PNF --node-number 2 --emulate-l1 ``` ### EpiSci's Documentation A more detailed tutorial is available on the [EpiSci GitHub Repository](https://github.com/EpiSci/oai-lte-5g-multi-ue-proxy#readme). @@ -76,13 +78,10 @@ This proxy allows to perform L2 nFAPI simulator for: * 5G-SA ### L2 Simulator as Docker Containers -Another tutorial for 5G SA mode with 1 User is available [here](../ci-scripts/yaml_files/5g_l2sim_tdd/README.md). - ----- - -[oai wiki home](https://gitlab.eurecom.fr/oai/openairinterface5g/wikis/home) - -[oai softmodem features](FEATURE_SET.md) - -[oai softmodem build procedure](BUILD.md) +There used to be docker deployment with L2sim that was run in the CI. Since L2 +simulator does not work anymore, it has been removed. However, you can see the +old `README.md` from tag `2024.w44` +[here](https://gitlab.eurecom.fr/oai/openairinterface5g/-/blob/2024.w44/ci-scripts/yaml_files/5g_l2sim_tdd/README.md). +In the same directory is a `docker-compose.yaml` file that can be used to run +L2sim. diff --git a/doc/LDPC_T2_OFFLOAD_SETUP.md b/doc/LDPC_T2_OFFLOAD_SETUP.md index df78590b5d..93d72284f9 100644 --- a/doc/LDPC_T2_OFFLOAD_SETUP.md +++ b/doc/LDPC_T2_OFFLOAD_SETUP.md @@ -132,7 +132,7 @@ Offload of the channel encoding and decoding to the AMD Xilinx T2 card is enable cd ~/openairinterface5g source oaienv cd cmake_targets/ran_build/build -sudo ./nr-softmodem --sa -O ../../../targets/PROJECTS/GENERIC-NR-5GC/CONF/gnb.sa.band78.fr1.106PRB.usrpb210.conf --ldpc-offload-enable --ldpc_offload.dpdk_dev 01:00.0 +sudo ./nr-softmodem -O ../../../targets/PROJECTS/GENERIC-NR-5GC/CONF/gnb.sa.band78.fr1.106PRB.usrpb210.conf --ldpc-offload-enable --ldpc_offload.dpdk_dev 01:00.0 ``` # Limitations diff --git a/doc/NR_SA_Tutorial_COTS_UE.md b/doc/NR_SA_Tutorial_COTS_UE.md index 7fc8b27a9a..41bce3ecf2 100644 --- a/doc/NR_SA_Tutorial_COTS_UE.md +++ b/doc/NR_SA_Tutorial_COTS_UE.md @@ -106,18 +106,18 @@ docker compose up -d ### USRP B210 ```bash cd ~/openairinterface5g/cmake_targets/ran_build/build -sudo ./nr-softmodem -O ../../../targets/PROJECTS/GENERIC-NR-5GC/CONF/gnb.sa.band78.fr1.106PRB.usrpb210.conf --sa -E --continuous-tx +sudo ./nr-softmodem -O ../../../targets/PROJECTS/GENERIC-NR-5GC/CONF/gnb.sa.band78.fr1.106PRB.usrpb210.conf -E --continuous-tx ``` ### USRP N300 ```bash cd ~/openairinterface5g/cmake_targets/ran_build/build -sudo ./nr-softmodem -O ../../../targets/PROJECTS/GENERIC-NR-5GC/CONF/gnb.sa.band77.fr1.273PRB.2x2.usrpn300.conf --sa --usrp-tx-thread-config 1 +sudo ./nr-softmodem -O ../../../targets/PROJECTS/GENERIC-NR-5GC/CONF/gnb.sa.band77.fr1.273PRB.2x2.usrpn300.conf --usrp-tx-thread-config 1 ``` ### USRP X300 ```bash cd ~/openairinterface5g/cmake_targets/ran_build/build -sudo ./nr-softmodem -O ../../../targets/PROJECTS/GENERIC-NR-5GC/CONF/gnb.sa.band77.fr1.273PRB.2x2.usrpn300.conf --sa --usrp-tx-thread-config 1 -E --continuous-tx +sudo ./nr-softmodem -O ../../../targets/PROJECTS/GENERIC-NR-5GC/CONF/gnb.sa.band77.fr1.273PRB.2x2.usrpn300.conf --usrp-tx-thread-config 1 -E --continuous-tx ``` # 5. Run UE @@ -193,7 +193,39 @@ sudo ethtool -G enp1s0f0 tx 4096 rx 4096 - You can also reduce the number of LDPC decoder iterations, which will make the LDPC decoder take less time: `--L1s.[0].max_ldpc_iterations 4`. ## 6.3 Uplink issues related with noise on the DC carriers -- There is noise on the DC carriers on N300 and especially the X300 in UL. To avoid their use or shift them away from the center to use more UL spectrum, use the `--tune-offset ` command line switch, where `` is ideally half the bandwidth, or possibly less. + +With devices like the USRP N300 and especially the X300, there is noise in the DC carriers: this can cause uplink PRBs that overlap with the DC carrier to experience interference and increased noise. + +There are two possible solution that can be enabled in OAI: + +* `--tune-offset`: it consists in shifting away the operational bandwidth to avoid the center frequency +* `ul_prbblacklist`: can be used to define specific PRBs that should not be used for uplink scheduling + +A spectrum clean from the noisy PRBs will eventually result in an enhanced UL throughput. + +Using `--tune-offset`, `ul_prbblacklist` or none at all is depending on the combination of the USRP model, the operational bandwidth configuration and the bandwidth of the daughterboard. + +There are two main points to keep in mind: + +- USRPs come with various daughterboards, each with its own specific bandwidth (see datasheets). +- Using `--tune-offset` to shift the entire operational bandwidth to avoid the center frequency could exceed the device capabilities: if the shifted operational bandwidth falls entirely within the bandwidth of the daughterboard, than `--tune-offset` is sufficient, otherwise `--tune-offset` is ineffective and `ul_prbblacklist` is needed. + +The option `ul_prbblacklist` is more relevant when using high-bandwidth configurations (e.g., 100 MHz) with devices like the USRP N310 or X310: in this scenarios, `--tune-offset` could not be sufficient to get rid of the noisy PRBs in the center frequency entirely, because it is not possible to shift the DC carriers out of the bandwidth (tune offset shall be smaller than half the bandwidth of the board). + +## 6.3.1 Tune offset + +The value passed to the command line option `--tune-offset ` will be calling an UHD API. It represents the LO offset frequency in Hz. +The API (tune_request_t class) will send a frequency tuning request (`tx_tune_req`, `rx_tune_req`) to the USRP device, in order to configure the target baseband tx/rx frequency, therefore shifting the tx/rx signal spectrum. + +The value passed to this option should be ideally equal to half the operational bandwidth, or possibly less, depending on the bandwidth configuration, and also it shall be lower or equal than half the bandwidth of the board. + +A visual representation of the impact of tune-offset with a 120 MHz bandwidth daughterboard: + +![Tune_Offset](./images/USRP_tune_offset.png) + +## 6.3.2 UL PRBs Blacklist + +To use this option, in the configuration file, e.g. 100 MHz bandwidth setup: `ul_prbblacklist = "135,136,137,138"`. ## 6.4 Lower latency on user plane - To lower latency on the user plane, you can force the UE to be scheduled constantly in uplink: `--MACRLCs.[0].ulsch_max_frame_inactivity 0` . diff --git a/doc/NR_SA_Tutorial_OAI_nrUE.md b/doc/NR_SA_Tutorial_OAI_nrUE.md index 23b50c4ab4..34f36c6bf6 100644 --- a/doc/NR_SA_Tutorial_OAI_nrUE.md +++ b/doc/NR_SA_Tutorial_OAI_nrUE.md @@ -97,24 +97,24 @@ docker compose up -d ### USRP B210 ```bash cd ~/openairinterface5g/cmake_targets/ran_build/build -sudo ./nr-softmodem -O ../../../targets/PROJECTS/GENERIC-NR-5GC/CONF/gnb.sa.band78.fr1.106PRB.usrpb210.conf --gNBs.[0].min_rxtxtime 6 --sa -E --continuous-tx +sudo ./nr-softmodem -O ../../../targets/PROJECTS/GENERIC-NR-5GC/CONF/gnb.sa.band78.fr1.106PRB.usrpb210.conf --gNBs.[0].min_rxtxtime 6 -E --continuous-tx ``` ### USRP N300 ```bash cd ~/openairinterface5g/cmake_targets/ran_build/build -sudo ./nr-softmodem -O ../../../targets/PROJECTS/GENERIC-NR-5GC/CONF/gnb.sa.band77.fr1.273PRB.2x2.usrpn300.conf --gNBs.[0].min_rxtxtime 6 --sa --usrp-tx-thread-config 1 +sudo ./nr-softmodem -O ../../../targets/PROJECTS/GENERIC-NR-5GC/CONF/gnb.sa.band77.fr1.273PRB.2x2.usrpn300.conf --gNBs.[0].min_rxtxtime 6 --usrp-tx-thread-config 1 ``` ### USRP X300 ```bash cd ~/openairinterface5g/cmake_targets/ran_build/build -sudo ./nr-softmodem -O ../../../targets/PROJECTS/GENERIC-NR-5GC/CONF/gnb.sa.band77.fr1.273PRB.2x2.usrpn300.conf --gNBs.[0].min_rxtxtime 6 --sa --usrp-tx-thread-config 1 -E --continuous-tx +sudo ./nr-softmodem -O ../../../targets/PROJECTS/GENERIC-NR-5GC/CONF/gnb.sa.band77.fr1.273PRB.2x2.usrpn300.conf --gNBs.[0].min_rxtxtime 6 --usrp-tx-thread-config 1 -E --continuous-tx ``` ### RFsimulator ```bash cd ~/openairinterface5g/cmake_targets/ran_build/build -sudo ./nr-softmodem -O ../../../targets/PROJECTS/GENERIC-NR-5GC/CONF/gnb.sa.band78.fr1.106PRB.usrpb210.conf --gNBs.[0].min_rxtxtime 6 --rfsim --sa +sudo ./nr-softmodem -O ../../../targets/PROJECTS/GENERIC-NR-5GC/CONF/gnb.sa.band78.fr1.106PRB.usrpb210.conf --gNBs.[0].min_rxtxtime 6 --rfsim ``` ### RFsimulator in FR2 @@ -134,7 +134,7 @@ Important notes: Run OAI nrUE with USRP B210 ```bash cd ~/openairinterface5g/cmake_targets/ran_build/build -sudo ./nr-uesoftmodem -r 106 --numerology 1 --band 78 -C 3619200000 --ue-fo-compensation --sa -E --uicc0.imsi 001010000000001 +sudo ./nr-uesoftmodem -r 106 --numerology 1 --band 78 -C 3619200000 --ue-fo-compensation -E --uicc0.imsi 001010000000001 ``` ### RFsimulator @@ -145,7 +145,7 @@ Important notes: Run OAI nrUE with RFsimulator ```bash cd ~/openairinterface5g/cmake_targets/ran_build/build -sudo ./nr-uesoftmodem -r 106 --numerology 1 --band 78 -C 3619200000 --sa --uicc0.imsi 001010000000001 --rfsim +sudo ./nr-uesoftmodem -r 106 --numerology 1 --band 78 -C 3619200000 --uicc0.imsi 001010000000001 --rfsim ``` ### RFsimulator in FR2 @@ -156,7 +156,7 @@ Important notes: Run OAI nrUE with RFsimulator in FR2 ```bash cd ~/openairinterface5g/cmake_targets/ran_build/build -sudo ./nr-uesoftmodem -r 32 --numerology 3 --band 257 -C 27533280000 --sa --uicc0.imsi 001010000000001 --ssb 72 --rfsim +sudo ./nr-uesoftmodem -r 32 --numerology 3 --band 257 -C 27533280000 --uicc0.imsi 001010000000001 --ssb 72 --rfsim ``` ### Connection to an NG-Core @@ -188,7 +188,7 @@ The UE configuration must match the one of the network's AMF. The nrUE can conne When running the `nr-uesoftmodem`, one can specify the nrUE configuration file using the `-O` option. E.g.: ```bash -sudo ./nr-uesoftmodem --rfsim --rfsimulator.serveraddr 127.0.0.1 --sa -r 106 --numerology 1 --band 78 -C 3619200000 -O ~/nrue.uicc.conf +sudo ./nr-uesoftmodem --rfsim --rfsimulator.serveraddr 127.0.0.1 -r 106 --numerology 1 --band 78 -C 3619200000 -O ~/nrue.uicc.conf ``` The CL option `--uicc0.imsi` can override the IMSI value in the configuration file if necessary (e.g. when running multiple UEs): `--uicc0.imsi 001010000000001`. diff --git a/doc/ORAN_FHI7.2_Tutorial.md b/doc/ORAN_FHI7.2_Tutorial.md index 1b74e6cdd3..a077778162 100644 --- a/doc/ORAN_FHI7.2_Tutorial.md +++ b/doc/ORAN_FHI7.2_Tutorial.md @@ -821,13 +821,13 @@ xRAN SRS reception is not supported. Run the `nr-softmodem` from the build directory: ```bash cd ~/openairinterface5g/cmake_targets/ran_build/build -sudo ./nr-softmodem -O --sa --thread-pool +sudo ./nr-softmodem -O --thread-pool ``` **Warning**: Make sure that the configuration file you add after the `-O` option is adapted to your machine, especially to its isolated cores. **Note**: You may run OAI with O-RAN 7.2 Fronthaul without a RU attached (e.g. for benchmarking). -In such case, you would generate artificial traffic by replacing the `--sa` option by the `--phy-test` option. +In such case, you would generate artificial traffic by adding the `--phy-test` option. You have to set the thread pool option to non-isolated CPUs, since the thread pool is used for L1 processing which should not interfere with DPDK threads. diff --git a/doc/README.md b/doc/README.md index 7fc28f061a..3219c849cb 100644 --- a/doc/README.md +++ b/doc/README.md @@ -80,7 +80,6 @@ Legacy unmaintained files: - [How to build images](../docker/README.md) - [How to run 5G with the RFsimulator from images](../ci-scripts/yaml_files/5g_rfsimulator/README.md) - [How to run 4G with the RFsimulator from images](../ci-scripts/yaml_files/4g_rfsimulator_fdd_05MHz/README.md) -- [How to run 5G with the L2simulator from images](../ci-scripts/yaml_files/5g_l2sim_tdd/README.md) - [How to run physical simulators in OpenShift](../openshift/README.md) # Libraries diff --git a/doc/RUNMODEM.md b/doc/RUNMODEM.md index fef128e2f7..f20e5829dc 100644 --- a/doc/RUNMODEM.md +++ b/doc/RUNMODEM.md @@ -62,6 +62,8 @@ OAI supports different radio heads, the following are tested in the CI: ## NSA setup with COTS UE This setup requires an EPC, an OAI eNB and gNB, and a COTS Phone. A dedicated page describe the setup can be found [here](https://gitlab.eurecom.fr/oai/openairinterface5g/wikis/home/gNB-COTS-UE-testing). +The `--nsa` flag must be used to run gNB in non-standalone mode. + ### Launch eNB @@ -72,29 +74,30 @@ sudo ./lte-softmodem -O ../../../targets/PROJECTS/GENERIC-LTE-EPC/CONF/enb.band7 ### Launch gNB ```bash -sudo ./nr-softmodem -O ../../../targets/PROJECTS/GENERIC-LTE-EPC/CONF/gnb.band78.tm1.106PRB.usrpn300.conf +sudo ./nr-softmodem -O ../../../targets/PROJECTS/GENERIC-LTE-EPC/CONF/gnb.band78.tm1.106PRB.usrpn300.conf --nsa ``` You should see the X2 messages in Wireshark and at the eNB. ## SA setup with OAI NR-UE -The sa flag is used to run gNB in standalone mode. +The standalone mode is the default mode. -In order to run gNB and UE in standalone mode, the `--sa` flag is needed. +It is not necessary to run either the gNB or the UE using the `--sa` flag in the command line for standalone mode. -At the gNB the `--sa` flag does the following: -- The RRC encodes SIB1 according to the configuration file and transmits it through NR-BCCH-DL-SCH. +The default (SA) mode does the following: +- At the gNB: +* The RRC encodes SIB1 according to the configuration file and transmits it through NR-BCCH-DL-SCH. -At the UE the --sa flag will: -- Decode SIB1 and starts the 5G NR Initial Access Procedure for SA: +- At the UE: +* Decode SIB1 and starts the 5G NR Initial Access Procedure for SA: 1) 5G-NR RRC Connection Setup 2) NAS Authentication and Security 3) 5G-NR AS Security Procedure 4) 5G-NR RRC Reconfiguration 5) Start Downlink and Uplink Data Transfer -Command line parameters for UE in `--sa` mode: +Command line parameters for UE in standalone mode: - `-C` : downlink carrier frequency in Hz (default value 0) - `--CO` : uplink frequency offset for FDD in Hz (default value 0) - `--numerology` : numerology index (default value 1) @@ -111,8 +114,8 @@ To simplify the configuration for the user testing OAI UE with OAI gNB, the latt You can run this, using USRPs, on two separate machines: ```shell -sudo ./nr-softmodem -O ../../../targets/PROJECTS/GENERIC-NR-5GC/CONF/gnb.sa.band78.fr1.106PRB.usrpb210.conf --gNBs.[0].min_rxtxtime 6 --sa -sudo ./nr-uesoftmodem -r 106 --numerology 1 --band 78 -C 3619200000 --ssb 516 --sa +sudo ./nr-softmodem -O ../../../targets/PROJECTS/GENERIC-NR-5GC/CONF/gnb.sa.band78.fr1.106PRB.usrpb210.conf --gNBs.[0].min_rxtxtime 6 +sudo ./nr-uesoftmodem -r 106 --numerology 1 --band 78 -C 3619200000 --ssb 516 ``` With the **RFsimulator** (on the same machine), just add the option `--rfsim` to both gNB and NR UE command lines. @@ -159,7 +162,7 @@ This option is available for the following combinations of operation modes and g e.g. ```shell -sudo ./nr-uesoftmodem --sa -r 106 --numerology 1 --band 78 -C 3319680000 --ue-nb-ant-tx 2 --ue-nb-ant-rx 2 --uecap_file /opt/oai-nr-ue/etc/uecap.xml +sudo ./nr-uesoftmodem -r 106 --numerology 1 --band 78 -C 3319680000 --ue-nb-ant-tx 2 --ue-nb-ant-rx 2 --uecap_file /opt/oai-nr-ue/etc/uecap.xml ``` ## How to run a NTN configuration @@ -257,7 +260,7 @@ To enable this feature, the `disable_harq` flag has to be added to the gNB conf So with these modifications to the file `targets/PROJECTS/GENERIC-NR-5GC/CONF/gnb.sa.band66.fr1.25PRB.usrpx300.conf` an example gNB command for FDD, 5 MHz BW, 15 kHz SCS, transparent GEO satellite 5G NR NTN is this: ``` cd cmake_targets -sudo ./ran_build/build/nr-softmodem -O ../targets/PROJECTS/GENERIC-NR-5GC/CONF/gnb.sa.band66.fr1.25PRB.usrpx300.conf --sa --rfsim --rfsimulator.prop_delay 238.74 +sudo ./ran_build/build/nr-softmodem -O ../targets/PROJECTS/GENERIC-NR-5GC/CONF/gnb.sa.band66.fr1.25PRB.usrpx300.conf --rfsim --rfsimulator.prop_delay 238.74 ``` To configure NTN gNB with 32 HARQ processes in downlink and uplink, add these settings in conf files under section `gNBs.[0]` @@ -276,7 +279,7 @@ To simulate a LEO satellite channel model with rfsimulator in UL (DL is simulate So with these modifications to the file `targets/PROJECTS/GENERIC-NR-5GC/CONF/gnb.sa.band66.fr1.25PRB.usrpx300.conf` an example gNB command for FDD, 5 MHz BW, 15 kHz SCS, trasparent LEO satellite 5G NR NTN is this: ``` cd cmake_targets -sudo ./ran_build/build/nr-softmodem -O ../targets/PROJECTS/GENERIC-NR-5GC/CONF/gnb.sa.band66.fr1.25PRB.usrpx300.conf --sa --rfsim --rfsimulator.prop_delay 20 +sudo ./ran_build/build/nr-softmodem -O ../targets/PROJECTS/GENERIC-NR-5GC/CONF/gnb.sa.band66.fr1.25PRB.usrpx300.conf --rfsim --rfsimulator.prop_delay 20 ``` ### NR UE @@ -288,7 +291,7 @@ At UE side, there are two main parameters to cope with the large NTN propagation So an example NR UE command for FDD, 5MHz BW, 15 kHz SCS, transparent GEO satellite 5G NR NTN is this: ``` cd cmake_targets -sudo ./ran_build/build/nr-uesoftmodem --band 66 -C 2152680000 --CO -400000000 -r 25 --numerology 0 --ssb 48 --sa --rfsim --rfsimulator.prop_delay 238.74 --ntn-koffset 478 --ntn-ta-common 477.48 +sudo ./ran_build/build/nr-uesoftmodem --band 66 -C 2152680000 --CO -400000000 -r 25 --numerology 0 --ssb 48 --rfsim --rfsimulator.prop_delay 238.74 --ntn-koffset 478 --ntn-ta-common 477.48 ``` For LEO satellites a third parameter specifying the NTN propagation delay drift has ben added, ta-CommonDrift. @@ -298,7 +301,7 @@ Also, to perform an autonomous TA update based on the DL drift, the boolean para So an example NR UE command for FDD, 5MHz BW, 15 kHz SCS, transparent LEO satellite 5G NR NTN is this: ``` cd cmake_targets -sudo ./ran_build/build/nr-uesoftmodem --band 66 -C 2152680000 --CO -400000000 -r 25 --numerology 0 --ssb 48 --sa --rfsim --rfsimulator.prop_delay 20 --rfsimulator.options chanmod -O ../targets/PROJECTS/GENERIC-NR-5GC/CONF/channelmod_rfsimu_LEO_satellite.conf --time-sync-I 0.2 --ntn-koffset 40 --ntn-ta-common 37.74 --ntn-ta-commondrift -50 --autonomous-ta +sudo ./ran_build/build/nr-uesoftmodem --band 66 -C 2152680000 --CO -400000000 -r 25 --numerology 0 --ssb 48 --rfsim --rfsimulator.prop_delay 20 --rfsimulator.options chanmod -O ../targets/PROJECTS/GENERIC-NR-5GC/CONF/channelmod_rfsimu_LEO_satellite.conf --time-sync-I 0.2 --ntn-koffset 40 --ntn-ta-common 37.74 --ntn-ta-commondrift -50 --autonomous-ta ``` # Specific OAI modes diff --git a/doc/RUN_NR_multiple_BWPs.md b/doc/RUN_NR_multiple_BWPs.md index c6b497043a..7b79374fd7 100644 --- a/doc/RUN_NR_multiple_BWPs.md +++ b/doc/RUN_NR_multiple_BWPs.md @@ -42,10 +42,10 @@ Each dedicated BWP must have: ## gNB command: ``` - sudo ./nr-softmodem -O ../../../targets/PROJECTS/GENERIC-NR-5GC/CONF/gnb.sa.band78.fr1.106PRB.usrpb210.conf --gNBs.[0].min_rxtxtime 6 --rfsim --sa + sudo ./nr-softmodem -O ../../../targets/PROJECTS/GENERIC-NR-5GC/CONF/gnb.sa.band78.fr1.106PRB.usrpb210.conf --gNBs.[0].min_rxtxtime 6 --rfsim ``` ## UE command: ``` - sudo ./nr-uesoftmodem -r 106 --numerology 1 --band 78 -C 3619200000 --rfsim --sa --uicc0.imsi 208990000000001 --rfsimulator.serveraddr 127.0.0.1 + sudo ./nr-uesoftmodem -r 106 --numerology 1 --band 78 -C 3619200000 --rfsim --uicc0.imsi 208990000000001 --rfsimulator.serveraddr 127.0.0.1 ``` diff --git a/doc/TESTBenches.md b/doc/TESTBenches.md index 7e67e78d41..c41657538f 100644 --- a/doc/TESTBenches.md +++ b/doc/TESTBenches.md @@ -132,11 +132,6 @@ information on how the images are built. ~5G-NR - caracal + N310 - pure performance test through phy-test scheduler, see command line for more details -- [RAN-Interop-F1](https://jenkins-oai.eurecom.fr/job/RAN-Interop-F1/) - ~5G-NR - - ofqot (DU, 1x UE) - - F1 interoperability: set up connection between Accelleran CU and OAI DU and pass all traffic over F1 - - 3rd-party gNB/CU interoperability: set up connection between Accelleran CU and OAI UE and test connectivity - [RAN-L2-Sim-Test-4G](https://jenkins-oai.eurecom.fr/job/RAN-L2-Sim-Test-4G/) ~4G-LTE - obelix (eNB, 1x UE, OAI EPC) @@ -244,10 +239,10 @@ steps look like this: `ci-scripts/conf_files/gnb.sa.band78.106prb.rfsim.conf` (note that the path is relative to the directory in which the docker-compose file is located). Further, an environment variable `USE_ADDITIONAL_OPTIONS` is declared, - referencing the relevant options `--sa -E --rfsim` (you can ignore logging + referencing the relevant options `-E --rfsim` (you can ignore logging options). You would therefore run the gNB from source like this: ``` - sudo ./cmake_targets/ran_build/build/nr-softmodem -O ci-scripts/conf_files/gnb.sa.band78.106prb.rfsim.conf --sa -E --rfsim + sudo ./cmake_targets/ran_build/build/nr-softmodem -O ci-scripts/conf_files/gnb.sa.band78.106prb.rfsim.conf -E --rfsim ``` To run this on your local machine, assuming you have a 5GC installed, you might need to change IP information in the config to match your core. diff --git a/doc/TESTING_GNB_W_COTS_UE.md b/doc/TESTING_GNB_W_COTS_UE.md index be53cb371c..f44e140e22 100644 --- a/doc/TESTING_GNB_W_COTS_UE.md +++ b/doc/TESTING_GNB_W_COTS_UE.md @@ -220,7 +220,7 @@ The **-E** option is **NOT supported** when using a a N300 USRP Execute: ``` -~/openairinterface5g/cmake_targets/ran_build/build$ sudo ./nr-softmodem -O **YOUR_GNB_CONF_FILE** -E | tee **YOUR_LOG_FILE** +~/openairinterface5g/cmake_targets/ran_build/build$ sudo ./nr-softmodem -O **YOUR_GNB_CONF_FILE** -E --nsa | tee **YOUR_LOG_FILE** ``` diff --git a/doc/cross-compile.md b/doc/cross-compile.md index ce61ce2e40..0a0ce3b1ba 100644 --- a/doc/cross-compile.md +++ b/doc/cross-compile.md @@ -1,15 +1,23 @@ +OpenAirInterface Cross-Compiler User Guide: explains how to build OAI for ARM64 +(using the instruction set aarch64). + [[_TOC_]] +# Environment -# OpenAirInterface Cross-Compiler User Guide +Tested on Ubuntu 22. Newer version of Ubuntu should work as well, please file a +bug report if not (Gitlab Issues page). -## Environment +You should be able to compile OAI on the host (i.e., for x86). To do so, +install the dependencies, if not done already: -- OS: ubuntu 22.04 +```shell +cmake_targets/build_oai -I +``` -### Set up the environment +# Install ARM64 dependencies -Set up for install the package for aarch64. +Set up for install the package for ARM64. ```shell sudo dpkg --add-architecture arm64 @@ -32,7 +40,6 @@ sudo apt install -y gcc-11-aarch64-linux-gnu \ g++-11-aarch64-linux-gnu sudo apt-get install -y \ - libatlas-base-dev:arm64 \ libblas-dev:arm64 \ libc6-dev-i386 \ liblapack-dev:arm64 \ @@ -47,21 +54,12 @@ sudo apt-get install -y \ ``` The above enables apt to download packages for arm64. It also installs -gcc cross-compilers for aarch64 in version 11. This version needs to match the +gcc cross-compilers for ARM64 in version 11. This version needs to match the versions of gcc defined in the cmake cross-compilation file (`cross-arm.cmake`). -## Install and Build +# Build for ARM64 -### Install required packages - -Use the host compiler to install its dependencies. - -```shell -cd cmake_targets -./build_oai -I -``` - -### Build the LDPC generators +## Build code generation tools for host Use the x86 compiler to build the `ldpc_generators` and generate the header file in the `ran_build/build` folder. They are necessary during a build for @@ -78,7 +76,7 @@ cmake ../../.. make -j`nproc` ldpc_generators generate_T ``` -### Build the Other Executables for aarch64 +## Build executables for ARM64 Switch to the `ran_build/build-cross` folder to build the target executables for ARM. The `cross-arm.cmake` file defines some ARM-specific build tools @@ -91,7 +89,13 @@ be defined in order to tell cmake where the host tools have been built. cd ../build-cross cmake ../../.. -GNinja -DCMAKE_TOOLCHAIN_FILE=../../../cmake_targets/cross-arm.cmake -DNATIVE_DIR=../build -ninja -j`nproc` dlsim ulsim ldpctest polartest smallblocktest nr_pbchsim nr_dlschsim nr_ulschsim nr_dlsim nr_ulsim nr_pucchsim nr_prachsim -ninja -j`nproc` lte-softmodem nr-softmodem nr-cuup oairu lte-uesoftmodem nr-uesoftmodem -ninja -j`nproc` params_libconfig coding rfsimulator +ninja dlsim ulsim ldpctest polartest smallblocktest nr_pbchsim nr_dlschsim nr_ulschsim nr_dlsim nr_ulsim nr_pucchsim nr_prachsim +ninja lte-softmodem nr-softmodem nr-cuup oairu lte-uesoftmodem nr-uesoftmodem +ninja params_libconfig coding rfsimulator ``` + +# Further information + +You can do the above steps using docker, see dockerfiles +`docker/Dockerfile.base.ubuntu22.cross-arm64` and +`docker/Dockerfile.build.ubuntu22.cross-arm64` for more information. diff --git a/doc/handover-tutorial.md b/doc/handover-tutorial.md index 8595fe05d4..a367de868a 100644 --- a/doc/handover-tutorial.md +++ b/doc/handover-tutorial.md @@ -48,15 +48,15 @@ done, follow below steps to trigger a handover: Start the CU including telnet support: - sudo ./nr-softmodem --sa -O ../../../targets/PROJECTS/GENERIC-NR-5GC/CONF/gnb-cu.sa.f1.conf --telnetsrv --telnetsrv.shrmod ci + sudo ./nr-softmodem -O ../../../targets/PROJECTS/GENERIC-NR-5GC/CONF/gnb-cu.sa.f1.conf --telnetsrv --telnetsrv.shrmod ci Start DU0: - sudo ./nr-softmodem --sa --rfsim -O ../../../targets/PROJECTS/GENERIC-NR-5GC/CONF/gnb-du.sa.band78.106prb.rfsim.pci0.conf --rfsimulator.serveraddr 127.0.0.1 + sudo ./nr-softmodem --rfsim -O ../../../targets/PROJECTS/GENERIC-NR-5GC/CONF/gnb-du.sa.band78.106prb.rfsim.pci0.conf --rfsimulator.serveraddr 127.0.0.1 Start the UE, and let it connect completely: - sudo ./nr-uesoftmodem --sa -C 3450720000 -r 106 --numerology 1 --ssb 516 -O --rfsim --rfsimulator.serveraddr server + sudo ./nr-uesoftmodem -C 3450720000 -r 106 --numerology 1 --ssb 516 -O --rfsim --rfsimulator.serveraddr server Note how the RFsimulator roles have been switched, and RFsim server is at the UE side; _this is important_. Replace `` with the UE configuration @@ -65,7 +65,7 @@ matching your core. If you followed the CN and oaiUE tutorials, you can remove Once the UE is connected, start DU1: - sudo ./nr-softmodem --sa --rfsim -O ../../../targets/PROJECTS/GENERIC-NR-5GC/CONF/gnb-du.sa.band78.106prb.rfsim.pci1.conf --rfsimulator.serveraddr 127.0.0.1 + sudo ./nr-softmodem --rfsim -O ../../../targets/PROJECTS/GENERIC-NR-5GC/CONF/gnb-du.sa.band78.106prb.rfsim.pci1.conf --rfsimulator.serveraddr 127.0.0.1 Once DU1 is online, you can trigger a handover by issuing this command diff --git a/doc/images/USRP_tune_offset.png b/doc/images/USRP_tune_offset.png new file mode 100644 index 0000000000..1372373503 Binary files /dev/null and b/doc/images/USRP_tune_offset.png differ diff --git a/doc/iqrecordplayer_usage.md b/doc/iqrecordplayer_usage.md index 69c675c996..2806db07f8 100644 --- a/doc/iqrecordplayer_usage.md +++ b/doc/iqrecordplayer_usage.md @@ -33,7 +33,7 @@ than the value of `--subframes-max` parameter. >Recording session example: ```bash -./nr-uesoftmodem -O /home/oaitests/mediatek_sim.conf --sa --numerology 1 -r 106 -C 3649440000 --band 78 -E --ue-fo-compensation --device.recplay.subframes-record 1 --device.recplay.subframes-file /home/iqs/oai-nrUE-17042023.dat --device.recplay.use-mmap 1 --device.recplay.subframes-max 30000 +./nr-uesoftmodem -O /home/oaitests/mediatek_sim.conf --numerology 1 -r 106 -C 3649440000 --band 78 -E --ue-fo-compensation --device.recplay.subframes-record 1 --device.recplay.subframes-file /home/iqs/oai-nrUE-17042023.dat --device.recplay.use-mmap 1 --device.recplay.subframes-max 30000 ............................................ ............................................ ............................................ @@ -54,7 +54,7 @@ options for replay mode are: >Replay mode session example: ```bash -./nr-uesoftmodem -O /home/oaitests/mediatek_sim.conf --sa --numerology 1 -r 106 -C 3649440000 --band 78 -E --ue-fo-compensation --device.recplay.subframes-replay 1 --device.recplay.subframes-file /home/iqs/oai-nrUE-17042023.dat --device.recplay.use-mmap 1 --device.recplay.subframes-loops 1 +./nr-uesoftmodem -O /home/oaitests/mediatek_sim.conf --numerology 1 -r 106 -C 3649440000 --band 78 -E --ue-fo-compensation --device.recplay.subframes-replay 1 --device.recplay.subframes-file /home/iqs/oai-nrUE-17042023.dat --device.recplay.use-mmap 1 --device.recplay.subframes-loops 1 .................................. .................................. [HW] Replay iqs from USRP B200 device, bandwidth 4.000000e+07 diff --git a/docker/Dockerfile.build.ubuntu22.cross-arm64 b/docker/Dockerfile.build.ubuntu22.cross-arm64 index 7b145fdc5b..91b53ff6b4 100644 --- a/docker/Dockerfile.build.ubuntu22.cross-arm64 +++ b/docker/Dockerfile.build.ubuntu22.cross-arm64 @@ -43,12 +43,12 @@ RUN /bin/sh oaienv && \ cd ../build-cross/ && \ # install missing libyaml-cpp-dev for arm64 apt install -y libyaml-cpp-dev:arm64 && \ - cmake ../../.. -GNinja \ + cmake ../../.. -GNinja -DENABLE_TELNETSRV=ON \ -DCMAKE_TOOLCHAIN_FILE=../../../cmake_targets/cross-arm.cmake -DNATIVE_DIR=../build \ -DCMAKE_C_FLAGS="-Werror" -DCMAKE_CXX_FLAGS="-Werror" && \ echo "====== Start of log for cross-build executables ======" && \ # making always passing so we can analyze the all.txt file - ninja dlsim ulsim ldpctest polartest smallblocktest nr_pbchsim nr_dlschsim nr_ulschsim nr_dlsim nr_ulsim nr_pucchsim nr_prachsim lte-softmodem nr-softmodem nr-cuup oairu lte-uesoftmodem nr-uesoftmodem params_libconfig coding rfsimulator > ../../log/all.txt 2>&1; \ + ninja dlsim ulsim ldpctest polartest smallblocktest nr_pbchsim nr_dlschsim nr_ulschsim nr_dlsim nr_ulsim nr_pucchsim nr_prachsim lte-softmodem nr-softmodem nr-cuup oairu lte-uesoftmodem nr-uesoftmodem params_libconfig coding rfsimulator telnetsrv > ../../log/all.txt 2>&1; \ # displaying errors and warnings grep -E -A3 "warning:|error:" ../../log/all.txt || true && \ # will fail only if string "errors:" is found diff --git a/docker/README.md b/docker/README.md index 7ec63aacae..36ec65698a 100644 --- a/docker/README.md +++ b/docker/README.md @@ -243,7 +243,7 @@ services: core: -1 # for core dumps environment: USE_B2XX: 'yes' - USE_ADDITIONAL_OPTIONS: --sa --RUs.[0].sdr_addrs serial=30C51D4 --telnetsrv --telnetsrv.shrmod ci --continuous-tx --log_config.global_log_options level,nocolor,time,line_num,function + USE_ADDITIONAL_OPTIONS: --RUs.[0].sdr_addrs serial=30C51D4 --telnetsrv --telnetsrv.shrmod ci --continuous-tx --log_config.global_log_options level,nocolor,time,line_num,function devices: - /dev/bus/usb/:/dev/bus/usb/ volumes: diff --git a/executables/lte-enb.c b/executables/lte-enb.c index 24d24da9ea..42c97e8913 100644 --- a/executables/lte-enb.c +++ b/executables/lte-enb.c @@ -131,7 +131,7 @@ static struct { extern double cpuf; -void init_eNB(int); +void init_eNB(); void stop_eNB(int nb_inst); int wakeup_tx(PHY_VARS_eNB *eNB, int frame_rx, int subframe_rx, int frame_tx, int subframe_tx, uint64_t timestamp_tx); @@ -1219,7 +1219,8 @@ void init_eNB_afterRU(void) { } -void init_eNB(int wait_for_sync) { +void init_eNB() +{ int CC_id; int inst; PHY_VARS_eNB *eNB; diff --git a/executables/lte-softmodem.c b/executables/lte-softmodem.c index 9d42adeb73..552de278d1 100644 --- a/executables/lte-softmodem.c +++ b/executables/lte-softmodem.c @@ -532,8 +532,8 @@ int main ( int argc, char **argv ) printf("RC.nb_L1_inst:%d\n", RC.nb_L1_inst); if (RC.nb_L1_inst > 0) { - printf("Initializing eNB threads wait_for_sync:%d\n", get_softmodem_params()->wait_for_sync); - init_eNB(get_softmodem_params()->wait_for_sync); + printf("Initializing eNB threads\n"); + init_eNB(); } for (int x=0; x < RC.nb_L1_inst; x++) for (int CC_id=0; CC_idldpc_offload_flag = get_softmodem_params()->ldpc_offload_flag; @@ -415,7 +410,7 @@ void init_eNB_afterRU(void) { // map antennas and PRACH signals to gNB RX if (0) AssertFatal(gNB->num_RU>0,"Number of RU attached to gNB %d is zero\n",gNB->Mod_id); - LOG_D(PHY, "Mapping RX ports from %d RUs to gNB %d\n", gNB->num_RU, gNB->Mod_id); + LOG_D(NR_PHY, "Mapping RX ports from %d RUs to gNB %d\n", gNB->num_RU, gNB->Mod_id); for (ru_id=0,aa=0; ru_idnum_RU; ru_id++) { AssertFatal(gNB->RU_list[ru_id]->common.rxdataF != NULL, "RU %d : common.rxdataF is NULL\n", gNB->RU_list[ru_id]->idx); @@ -439,39 +434,41 @@ void init_eNB_afterRU(void) { } -void init_gNB(int wait_for_sync) { - - int inst; - PHY_VARS_gNB *gNB; - +/** + * @brief Initialize gNB struct in RAN context + */ +void init_gNB() +{ + LOG_I(NR_PHY, "Initializing gNB RAN context: RC.nb_nr_L1_inst = %d \n", RC.nb_nr_L1_inst); if (RC.gNB == NULL) { - RC.gNB = (PHY_VARS_gNB **) calloc(1+RC.nb_nr_L1_inst, sizeof(PHY_VARS_gNB *)); - LOG_D(PHY, "gNB L1 structure RC.gNB allocated @ %p\n", RC.gNB); + RC.gNB = (PHY_VARS_gNB **)calloc_or_fail(RC.nb_nr_L1_inst, sizeof(PHY_VARS_gNB *)); + LOG_D(NR_PHY, "gNB L1 structure RC.gNB allocated @ %p\n", RC.gNB); } - for (inst=0; instnrPolar_params, - NR_POLAR_PBCH_MESSAGE_TYPE, - NR_POLAR_PBCH_PAYLOAD_BITS, - NR_POLAR_PBCH_AGGREGATION_LEVEL);*/ + PHY_VARS_gNB *gNB = RC.gNB[inst]; + LOG_D(NR_PHY, "Initializing gNB %d\n", inst); + // Init module ID + gNB->Mod_id = inst; + + // Register MAC interface module AssertFatal((gNB->if_inst = NR_IF_Module_init(inst)) != NULL, "Cannot register interface"); - gNB->if_inst->NR_Schedule_response = nr_schedule_response; - gNB->if_inst->NR_PHY_config_req = nr_phy_config_request; - memset(&gNB->UL_INFO, 0, sizeof(gNB->UL_INFO)); + LOG_I(NR_PHY, "Registered with MAC interface module (%p)\n", gNB->if_inst); + // Set function pointers in MAC IF module + gNB->if_inst->NR_Schedule_response = nr_schedule_response; + gNB->if_inst->NR_PHY_config_req = nr_phy_config_request; + + // Clear UL_INFO and set rx/crc indication lists + memset((void *)&gNB->UL_INFO, 0, sizeof(gNB->UL_INFO)); gNB->UL_INFO.rx_ind.pdu_list = gNB->rx_pdu_list; gNB->UL_INFO.crc_ind.crc_list = gNB->crc_pdu_list; - /*gNB->UL_INFO.sr_ind.sr_indication_body.sr_pdu_list = gNB->sr_pdu_list; - gNB->UL_INFO.harq_ind.harq_indication_body.harq_pdu_list = gNB->harq_pdu_list; - gNB->UL_INFO.cqi_ind.cqi_pdu_list = gNB->cqi_pdu_list; - gNB->UL_INFO.cqi_ind.cqi_raw_pdu_list = gNB->cqi_raw_pdu_list;*/ gNB->prach_energy_counter = 0; gNB->chest_time = get_softmodem_params()->chest_time; @@ -479,7 +476,6 @@ void init_gNB(int wait_for_sync) { } } - void stop_gNB(int nb_inst) { for (int inst=0; inst 0) { RC.ru = (RU_t **)malloc(RC.nb_RU*sizeof(RU_t *)); - RC.ru_mask = (1 << NB_RU) - 1; + RC.ru_mask = (1 << RC.nb_RU) - 1; for (int j = 0; j < RC.nb_RU; j++) { RC.ru[j] = calloc(1, sizeof(*RC.ru[j])); diff --git a/executables/nr-softmodem.c b/executables/nr-softmodem.c index 47548239b9..e449e6c33e 100644 --- a/executables/nr-softmodem.c +++ b/executables/nr-softmodem.c @@ -92,28 +92,17 @@ unsigned short config_frames[4] = {2,9,11,13}; pthread_cond_t nfapi_sync_cond; pthread_mutex_t nfapi_sync_mutex; int nfapi_sync_var=-1; //!< protected by mutex \ref nfapi_sync_mutex - -extern uint8_t nfapi_mode; // Default to monolithic mode THREAD_STRUCT thread_struct; pthread_cond_t sync_cond; pthread_mutex_t sync_mutex; int sync_var=-1; //!< protected by mutex \ref sync_mutex. int config_sync_var=-1; - -volatile int start_gNB = 0; int oai_exit = 0; -int NB_UE_INST = 0; - -static int wait_for_sync = 0; - unsigned int mmapped_dma=0; uint64_t downlink_frequency[MAX_NUM_CCs][4]; int32_t uplink_frequency_offset[MAX_NUM_CCs][4]; - -//Temp fix for inexistent NR upper layer -unsigned char NB_gNB_INST = 1; char *uecap_file; runmode_t mode = normal_txrx; @@ -131,26 +120,10 @@ double rx_gain[MAX_NUM_CCs][4] = {{110,0,0,0},{20,0,0,0}}; double rx_gain_off = 0.0; static int tx_max_power[MAX_NUM_CCs]; /* = {0,0}*/; - - int chain_offset=0; - -uint8_t dci_Format = 0; -uint8_t nb_antenna_tx = 1; -uint8_t nb_antenna_rx = 1; - -int otg_enabled; - extern void *udp_eNB_task(void *args_p); - -int transmission_mode=1; int emulate_rf = 0; int numerology = 0; - - -/* struct for ethernet specific parameters given in eNB conf file */ -eth_params_t *eth_params; - double cpuf; /* hack: pdcp_run() is required by 4G scheduler which is compiled into @@ -160,9 +133,6 @@ void pdcp_run(const protocol_ctxt_t *const ctxt_pP) abort(); } -/* forward declarations */ -void set_default_frame_parms(nfapi_nr_config_request_scf_t *config[MAX_NUM_CCs], NR_DL_FRAME_PARMS *frame_parms[MAX_NUM_CCs]); - /*---------------------BMC: timespec helpers -----------------------------*/ struct timespec min_diff_time = { .tv_sec = 0, .tv_nsec = 0 }; @@ -273,46 +243,32 @@ static int create_gNB_tasks(ngran_node_t node_type, configmodule_interface_t *cf RCconfig_verify(cfg, node_type); - if(NFAPI_MODE != NFAPI_MODE_AERIAL){ - RCconfig_nr_prs(); - } - if (RC.nb_nr_macrlc_inst > 0) RCconfig_nr_macrlc(cfg); - LOG_D(PHY, "%s() RC.nb_nr_L1_inst:%d\n", __FUNCTION__, RC.nb_nr_L1_inst); - if (RC.nb_nr_L1_inst>0) AssertFatal(l1_north_init_gNB()==0,"could not initialize L1 north interface\n"); AssertFatal (gnb_nb <= RC.nb_nr_inst, "Number of gNB is greater than gNB defined in configuration file (%d/%d)!", gnb_nb, RC.nb_nr_inst); - LOG_D(GNB_APP, "Allocating gNB_RRC_INST for %d instances\n", RC.nb_nr_inst); + LOG_D(GNB_APP, "Allocating gNB_RRC_INST\n"); + RC.nrrrc = calloc(1, sizeof(*RC.nrrrc)); + RC.nrrrc[0] = RCconfig_NRRRC(); - if (RC.nb_nr_inst > 0) { - AssertFatal(RC.nb_nr_inst == 1, "multiple RRC instances are not supported\n"); - RC.nrrrc = calloc(1, sizeof(*RC.nrrrc)); - RC.nrrrc[0] = calloc(1,sizeof(gNB_RRC_INST)); - RCconfig_NRRRC(RC.nrrrc[0]); - } - - if (RC.nb_nr_inst > 0 && - !get_softmodem_params()->nsa && - !(node_type == ngran_gNB_DU)) { + if (!get_softmodem_params()->nsa && !(node_type == ngran_gNB_DU)) { // we start pdcp in both cuup (for drb) and cucp (for srb) init_pdcp(); } - if (is_x2ap_enabled() ) { //&& !NODE_IS_DU(node_type) + if (get_softmodem_params()->nsa) { //&& !NODE_IS_DU(node_type) LOG_I(X2AP, "X2AP enabled \n"); __attribute__((unused)) uint32_t x2_register_gnb_pending = gNB_app_register_x2 (gnb_id_start, gnb_id_end); } /* For the CU case the gNB registration with the AMF might have to take place after the F1 setup, as the PLMN info * can originate from the DU. Add check on whether x2ap is enabled to account for ENDC NSA scenario.*/ - if ((get_softmodem_params()->sa || is_x2ap_enabled()) && - !NODE_IS_DU(node_type)) { + if (IS_SA_MODE(get_softmodem_params()) && !NODE_IS_DU(node_type)) { /* Try to register each gNB */ //registered_gnb = 0; __attribute__((unused)) uint32_t register_gnb_pending = gNB_app_register (gnb_id_start, gnb_id_end); @@ -324,7 +280,7 @@ static int create_gNB_tasks(ngran_node_t node_type, configmodule_interface_t *cf return -1; } - if (is_x2ap_enabled()) { + if (get_softmodem_params()->nsa) { if(itti_create_task(TASK_X2AP, x2ap_task, NULL) < 0) { LOG_E(X2AP, "Create task for X2AP failed\n"); } @@ -333,8 +289,7 @@ static int create_gNB_tasks(ngran_node_t node_type, configmodule_interface_t *cf } } - if (get_softmodem_params()->sa && - !NODE_IS_DU(node_type)) { + if (IS_SA_MODE(get_softmodem_params()) && !NODE_IS_DU(node_type)) { char* gnb_ipv4_address_for_NGU = NULL; uint32_t gnb_port_for_NGU = 0; @@ -383,7 +338,7 @@ static int create_gNB_tasks(ngran_node_t node_type, configmodule_interface_t *cf } //Use check on x2ap to consider the NSA scenario - if((is_x2ap_enabled() || get_softmodem_params()->sa) && (node_type != ngran_gNB_CUCP)) { + if((is_x2ap_enabled() || IS_SA_MODE(get_softmodem_params())) && (node_type != ngran_gNB_CUCP)) { if (itti_create_task (TASK_GTPV1_U, >pv1uTask, NULL) < 0) { LOG_E(GTPU, "Create task for GTPV1U failed\n"); return -1; @@ -401,65 +356,6 @@ static void get_options(configmodule_interface_t *cfg) get_common_options(cfg, SOFTMODEM_GNB_BIT); config_process_cmdline(cfg, cmdline_params, sizeofArray(cmdline_params), NULL); CONFIG_CLEARRTFLAG(CONFIG_NOEXITONHELP); - - if ( !(CONFIG_ISFLAGSET(CONFIG_ABORT)) ) { - memset((void *)&RC,0,sizeof(RC)); - /* Read RC configuration file */ - NRRCConfig(); - NB_gNB_INST = RC.nb_nr_inst; - NB_RU = RC.nb_RU; - } -} - -void set_default_frame_parms(nfapi_nr_config_request_scf_t *config[MAX_NUM_CCs], - NR_DL_FRAME_PARMS *frame_parms[MAX_NUM_CCs]) { - for (int CC_id=0; CC_idssb_config.scs_common.value = 1; - config[CC_id]->cell_config.frame_duplex_type.value = 1; //FDD - //config[CC_id]->subframe_config.dl_cyclic_prefix_type.value = 0; //NORMAL - config[CC_id]->carrier_config.dl_grid_size[1].value = 106; - config[CC_id]->carrier_config.ul_grid_size[1].value = 106; - config[CC_id]->cell_config.phy_cell_id.value = 0; - ///dl frequency to be filled in - /* //Set some default values that may be overwritten while reading options - frame_parms[CC_id]->frame_type = FDD; - frame_parms[CC_id]->tdd_config = 3; - frame_parms[CC_id]->tdd_config_S = 0; - frame_parms[CC_id]->N_RB_DL = 100; - frame_parms[CC_id]->N_RB_UL = 100; - frame_parms[CC_id]->Ncp = NORMAL; - frame_parms[CC_id]->Ncp_UL = NORMAL; - frame_parms[CC_id]->Nid_cell = 0; - frame_parms[CC_id]->num_MBSFN_config = 0; - frame_parms[CC_id]->nb_antenna_ports_gNB = 1; - frame_parms[CC_id]->nb_antennas_tx = 1; - frame_parms[CC_id]->nb_antennas_rx = 1; - - frame_parms[CC_id]->nushift = 0; - - frame_parms[CC_id]->phich_config_common.phich_resource = oneSixth; - frame_parms[CC_id]->phich_config_common.phich_duration = normal; - // UL RS Config - frame_parms[CC_id]->pusch_config_common.ul_ReferenceSignalsPUSCH.cyclicShift = 0;//n_DMRS1 set to 0 - frame_parms[CC_id]->pusch_config_common.ul_ReferenceSignalsPUSCH.groupHoppingEnabled = 0; - frame_parms[CC_id]->pusch_config_common.ul_ReferenceSignalsPUSCH.sequenceHoppingEnabled = 0; - frame_parms[CC_id]->pusch_config_common.ul_ReferenceSignalsPUSCH.groupAssignmentPUSCH = 0; - - frame_parms[CC_id]->prach_config_common.rootSequenceIndex=22; - frame_parms[CC_id]->prach_config_common.prach_ConfigInfo.zeroCorrelationZoneConfig=1; - frame_parms[CC_id]->prach_config_common.prach_ConfigInfo.prach_ConfigIndex=0; - frame_parms[CC_id]->prach_config_common.prach_ConfigInfo.highSpeedFlag=0; - frame_parms[CC_id]->prach_config_common.prach_ConfigInfo.prach_FreqOffset=0; - - // downlink_frequency[CC_id][0] = 2680000000; // Use float to avoid issue with frequency over 2^31. - // downlink_frequency[CC_id][1] = downlink_frequency[CC_id][0]; - // downlink_frequency[CC_id][2] = downlink_frequency[CC_id][0]; - // downlink_frequency[CC_id][3] = downlink_frequency[CC_id][0]; - frame_parms[CC_id]->dl_CarrierFreq=downlink_frequency[CC_id][0]; - */ - } } void wait_RUs(void) { @@ -596,6 +492,7 @@ int main( int argc, char **argv ) { lock_memory_to_ram(); get_options(uniqCfg); + EPC_MODE_ENABLED = !IS_SOFTMODEM_NOS1; if (CONFIG_ISFLAGSET(CONFIG_ABORT) ) { @@ -607,11 +504,7 @@ int main( int argc, char **argv ) { LOG_W(UTIL, "no SYS_NICE capability: cannot set thread priority and affinity, consider running with sudo for optimum performance\n"); - if (get_softmodem_params()->do_ra) - AssertFatal(get_softmodem_params()->phy_test == 0,"RA and phy_test are mutually exclusive\n"); - - if (get_softmodem_params()->sa) - AssertFatal(get_softmodem_params()->phy_test == 0,"Standalone mode and phy_test are mutually exclusive\n"); + softmodem_verify_mode(get_softmodem_params()); #if T_TRACER T_Config_Init(); @@ -630,9 +523,19 @@ int main( int argc, char **argv ) { // don't create if node doesn't connect to RRC/S1/GTP const ngran_node_t node_type = get_node_type(); + // Init RAN context + if (!(CONFIG_ISFLAGSET(CONFIG_ABORT))) + NRRCConfig(); - if (RC.nb_nr_L1_inst > 0) + if (RC.nb_nr_L1_inst > 0) { + // Initialize gNB structure in RAN context + init_gNB(); + // Initialize L1 RCconfig_NR_L1(); + // Initialize Positioning Reference Signal configuration + if(NFAPI_MODE != NFAPI_MODE_PNF && NFAPI_MODE != NFAPI_MODE_AERIAL) + RCconfig_nr_prs(); + } if (NFAPI_MODE != NFAPI_MODE_PNF) { int ret = create_gNB_tasks(node_type, uniqCfg); @@ -651,10 +554,6 @@ int main( int argc, char **argv ) { // start the main threads number_of_cards = 1; - if (RC.nb_nr_L1_inst > 0) { - init_gNB(wait_for_sync); - } - wait_gNBs(); int sl_ahead = NFAPI_MODE == NFAPI_MODE_AERIAL ? 0 : 6; if (RC.nb_RU >0) { diff --git a/executables/nr-softmodem.h b/executables/nr-softmodem.h index a17201d329..4311777f6c 100644 --- a/executables/nr-softmodem.h +++ b/executables/nr-softmodem.h @@ -41,7 +41,7 @@ extern uint64_t ulsch_slot_bitmap; extern char *uecap_file; // In nr-gnb.c -extern void init_gNB(int wait_for_sync); +extern void init_gNB(); extern void stop_gNB(int); // In nr-ru.c diff --git a/executables/nr-ue.c b/executables/nr-ue.c index a06c13a59a..bd64a9d361 100644 --- a/executables/nr-ue.c +++ b/executables/nr-ue.c @@ -286,7 +286,7 @@ static void *NRUE_phy_stub_standalone_pnf_task(void *arg) LOG_D(NR_MAC, "The received sfn/slot [%d %d] from proxy\n", frame, slot); - if (get_softmodem_params()->sa && mac->mib == NULL) { + if (IS_SA_MODE(get_softmodem_params()) && mac->mib == NULL) { LOG_D(NR_MAC, "We haven't gotten MIB. Lets see if we received it\n"); nr_ue_dl_indication(&mac->dl_info); process_queued_nr_nfapi_msgs(mac, sfn_slot); @@ -392,7 +392,7 @@ static void UE_synch(void *arg) { ret = sl_nr_slss_search(UE, &syncD->proc, SL_NR_SSB_REPETITION_IN_FRAMES); } else { nr_get_carrier_frequencies(UE, &dl_carrier, &ul_carrier); - ret = nr_initial_sync(&syncD->proc, UE, 2, get_softmodem_params()->sa, syncD->gscnInfo, syncD->numGscn); + ret = nr_initial_sync(&syncD->proc, UE, 2, IS_SA_MODE(get_softmodem_params()), syncD->gscnInfo, syncD->numGscn); } if (ret.cell_detected) { @@ -601,7 +601,7 @@ static int UE_dl_preprocessing(PHY_VARS_NR_UE *UE, const UE_nr_rxtx_proc_t *proc if (UE->sl_mode == 2) fp = &UE->SL_UE_PHY_PARAMS.sl_frame_params; - if (IS_SOFTMODEM_NOS1 || get_softmodem_params()->sa) { + if (IS_SOFTMODEM_NOS1 || IS_SA_MODE(get_softmodem_params())) { // Start synchronization with a target gNB if (UE->synch_request.received_synch_request == 1) { @@ -1056,7 +1056,7 @@ void init_NR_UE(int nb_inst, char *uecap_file, char *reconfig_file, char *rbconf NR_UE_MAC_INST_t *mac = get_mac_inst(i); mac->if_module = nr_ue_if_module_init(i); AssertFatal(mac->if_module, "can not initialize IF module\n"); - if (!get_softmodem_params()->sa || !get_softmodem_params()->sl_mode) { + if (!IS_SA_MODE(get_softmodem_params()) || !get_softmodem_params()->sl_mode) { init_nsa_message(&rrc_inst[i], reconfig_file, rbconfig_file); nr_rlc_activate_srb0(mac_inst[i].crnti, NULL, send_srb0_rrc); } diff --git a/executables/nr-uesoftmodem.c b/executables/nr-uesoftmodem.c index 4e5e1a19f9..ac5235b108 100644 --- a/executables/nr-uesoftmodem.c +++ b/executables/nr-uesoftmodem.c @@ -407,6 +407,9 @@ int main(int argc, char **argv) get_common_options(uniqCfg, SOFTMODEM_5GUE_BIT); CONFIG_CLEARRTFLAG(CONFIG_NOEXITONHELP); + + softmodem_verify_mode(get_softmodem_params()); + #if T_TRACER T_Config_Init(); #endif @@ -453,6 +456,7 @@ int main(int argc, char **argv) init_pdcp(0); else init_pdcp(mode_offset + ue_id_g); + nas_init_nrue(NB_UE_INST); init_NR_UE(NB_UE_INST, get_nrUE_params()->uecap_file, get_nrUE_params()->reconfig_file, get_nrUE_params()->rbconfig_file); @@ -461,12 +465,6 @@ int main(int argc, char **argv) get_channel_model_mode(uniqCfg); } - if (get_softmodem_params()->do_ra) - AssertFatal(get_softmodem_params()->phy_test == 0,"RA and phy_test are mutually exclusive\n"); - - if (get_softmodem_params()->sa) - AssertFatal(get_softmodem_params()->phy_test == 0,"Standalone mode and phy_test are mutually exclusive\n"); - if (!get_softmodem_params()->nsa && get_softmodem_params()->emulate_l1) start_oai_nrue_threads(); @@ -480,7 +478,7 @@ int main(int argc, char **argv) NR_UE_MAC_INST_t *mac = get_mac_inst(inst); init_nr_ue_phy_cpu_stats(&UE[CC_id]->phy_cpu_stats); - if (get_softmodem_params()->sa || get_softmodem_params()->sl_mode) { // set frame config to initial values from command line + if (IS_SA_MODE(get_softmodem_params()) || get_softmodem_params()->sl_mode) { // set frame config to initial values from command line // and assume that the SSB is centered on the grid uint16_t nr_band = get_softmodem_params()->band; mac->nr_band = nr_band; diff --git a/executables/softmodem-common.c b/executables/softmodem-common.c index d566767902..394235e8f0 100644 --- a/executables/softmodem-common.c +++ b/executables/softmodem-common.c @@ -174,6 +174,24 @@ void get_common_options(configmodule_interface_t *cfg, uint32_t execmask) if (stats_disabled) set_softmodem_optmask(SOFTMODEM_NOSTATS_BIT); } + +void softmodem_verify_mode(const softmodem_params_t *p) +{ + if (IS_SA_MODE(p)) { + LOG_I(UTIL, "running in SA mode (no --phy-test, --do-ra, --nsa option present)\n"); + return; + } + + if (p->phy_test) + LOG_I(UTIL, "running in phy-test mode (--phy-test)\n"); + if (p->do_ra) + LOG_I(UTIL, "running in do-ra mode (--do-ra)\n"); + if (p->nsa) + LOG_I(UTIL, "running in NSA mode (--nsa)\n"); + int num_modes = p->phy_test + p->do_ra + p->nsa; + AssertFatal(num_modes == 1, "--phy-test, --do-ra, and --nsa are mutually exclusive\n"); +} + void softmodem_printresources(int sig, telnet_printfunc_t pf) { struct rusage usage; struct timespec stop; diff --git a/executables/softmodem-common.h b/executables/softmodem-common.h index b6bbc11a2e..fac59693fd 100644 --- a/executables/softmodem-common.h +++ b/executables/softmodem-common.h @@ -123,9 +123,7 @@ extern "C" #define CONTINUOUS_TX softmodem_params.continuous_tx #define PHY_TEST softmodem_params.phy_test #define DO_RA softmodem_params.do_ra -#define SA softmodem_params.sa #define SL_MODE softmodem_params.sl_mode -#define WAIT_FOR_SYNC softmodem_params.wait_for_sync #define CHAIN_OFFSET softmodem_params.chain_offset #define NUMEROLOGY softmodem_params.numerology #define BAND softmodem_params.band @@ -155,13 +153,11 @@ extern int usrp_tx_thread; {"thread-pool", CONFIG_HLP_TPOOL, 0, .strptr=&TP_CONFIG, .defstrval="-1,-1,-1,-1,-1,-1,-1,-1", TYPE_STRING, 0}, \ {"phy-test", CONFIG_HLP_PHYTST, PARAMFLAG_BOOL, .iptr=&PHY_TEST, .defintval=0, TYPE_INT, 0}, \ {"do-ra", CONFIG_HLP_DORA, PARAMFLAG_BOOL, .iptr=&DO_RA, .defintval=0, TYPE_INT, 0}, \ - {"sa", CONFIG_HLP_SA, PARAMFLAG_BOOL, .iptr=&SA, .defintval=0, TYPE_INT, 0}, \ {"sl-mode", CONFIG_HLP_SL_MODE, 0, .u8ptr=&SL_MODE, .defintval=0, TYPE_UINT8, 0}, \ {"usim-test", CONFIG_HLP_USIM, PARAMFLAG_BOOL, .u8ptr=&USIM_TEST, .defintval=0, TYPE_UINT8, 0}, \ {"clock-source", CONFIG_HLP_CLK, 0, .uptr=&CLOCK_SOURCE, .defintval=0, TYPE_UINT, 0}, \ {"time-source", CONFIG_HLP_TME, 0, .uptr=&TIMING_SOURCE, .defintval=0, TYPE_UINT, 0}, \ {"tune-offset", CONFIG_HLP_TUNE_OFFSET, 0, .dblptr=&TUNE_OFFSET, .defintval=0, TYPE_DOUBLE, 0}, \ - {"wait-for-sync", NULL, PARAMFLAG_BOOL, .iptr=&WAIT_FOR_SYNC, .defintval=0, TYPE_INT, 0}, \ {"C" , CONFIG_HLP_DLF, 0, .u64ptr=&(downlink_frequency[0][0]), .defuintval=0, TYPE_UINT64, 0}, \ {"CO" , CONFIG_HLP_ULF, 0, .iptr=&(uplink_frequency_offset[0][0]), .defintval=0, TYPE_INT, 0}, \ {"a" , CONFIG_HLP_CHOFF, 0, .iptr=&CHAIN_OFFSET, .defintval=0, TYPE_INT, 0}, \ @@ -223,8 +219,6 @@ extern int usrp_tx_thread; { .s5 = { NULL } }, \ { .s5 = { NULL } }, \ { .s5 = { NULL } }, \ - { .s5 = { NULL } }, \ - { .s5 = { NULL } }, \ { .s3a = { config_checkstr_assign_integer, \ {"MONOLITHIC", "PNF", "VNF", "AERIAL","UE_STUB_PNF","UE_STUB_OFFNET","STANDALONE_PNF"}, \ {NFAPI_MONOLITHIC, NFAPI_MODE_PNF, NFAPI_MODE_VNF, NFAPI_MODE_AERIAL,NFAPI_UE_STUB_PNF,NFAPI_UE_STUB_OFFNET,NFAPI_MODE_STANDALONE_PNF}, \ @@ -305,11 +299,9 @@ typedef struct { char *threadPoolConfig; int phy_test; int do_ra; - int sa; uint8_t sl_mode; uint8_t usim_test; int emulate_rf; - int wait_for_sync; //eNodeB only int chain_offset; int numerology; int band; @@ -333,6 +325,9 @@ typedef struct { int threequarter_fs; } softmodem_params_t; +#define IS_SA_MODE(sM_params) (!(sM_params)->phy_test && !(sM_params)->do_ra && !(sM_params)->nsa) +void softmodem_verify_mode(const softmodem_params_t *p); + uint64_t get_softmodem_optmask(void); uint64_t set_softmodem_optmask(uint64_t bitmask); uint64_t clear_softmodem_optmask(uint64_t bitmask); diff --git a/openair1/PHY/CODING/DOC/LDPCImplementation.md b/openair1/PHY/CODING/DOC/LDPCImplementation.md index d280106c76..758f918963 100644 --- a/openair1/PHY/CODING/DOC/LDPCImplementation.md +++ b/openair1/PHY/CODING/DOC/LDPCImplementation.md @@ -46,7 +46,7 @@ Built target ldpc_cl At runtime, to successfully use hardware acceleration via OpenCL, you need to install vendor specific packages which deliver the required drivers and tools to make use of their GPU (Nvidia, Intel...) , fpga (Xilinx, Intel) or CPU (Intel, AMD, ARM...) through OpenCL. -`./nr-softmodem -O libconfig:gnb.band78.sa.fr1.106PRB.usrpb210.conf:dbgl5 --rfsim --rfsimulator.serveraddr server --sa --log_config.gtpu_log_level info --loader.ldpc.shlibversion _cl` +`./nr-softmodem -O libconfig:gnb.band78.sa.fr1.106PRB.usrpb210.conf:dbgl5 --rfsim --rfsimulator.serveraddr server --log_config.gtpu_log_level info --loader.ldpc.shlibversion _cl` ``` ------------------------------------------------ @@ -81,7 +81,7 @@ At runtime, to successfully use hardware acceleration via OpenCL, you need to in ----------------------------------------------------------------- ``` -`./nr-uesoftmodem -r 106 --numerology 1 --band 78 -C 3619200000 --rfsim --sa -O libconfig:/usr/local/oai/conf/nrue_sim.conf:dbgl5 --loader.ldpc.shlibversion _cl --log_config.hw_log_level info` +`./nr-uesoftmodem -r 106 --numerology 1 --band 78 -C 3619200000 --rfsim -O libconfig:/usr/local/oai/conf/nrue_sim.conf:dbgl5 --loader.ldpc.shlibversion _cl --log_config.hw_log_level info` ``` ............................................................ diff --git a/openair1/PHY/CODING/TESTBENCH/polartest.c b/openair1/PHY/CODING/TESTBENCH/polartest.c index cd280c236e..beab44c689 100644 --- a/openair1/PHY/CODING/TESTBENCH/polartest.c +++ b/openair1/PHY/CODING/TESTBENCH/polartest.c @@ -12,159 +12,162 @@ #include "PHY/CODING/coding_defs.h" #include "SIMULATION/TOOLS/sim.h" #include "common/config/config_userapi.h" -//#include "common/utils/LOG/log.h" +// #include "common/utils/LOG/log.h" #include "coding_unitary_defs.h" -//#define DEBUG_DCI_POLAR_PARAMS -//#define DEBUG_POLAR_TIMING -//#define DEBUG_POLARTEST +// #define DEBUG_DCI_POLAR_PARAMS +// #define DEBUG_POLAR_TIMING +// #define DEBUG_POLARTEST configmodule_interface_t *uniqCfg = NULL; 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, 2=UCI - double SNRstart = -20.0, SNRstop = 0.0, SNRinc= 0.5; //dB + // Default simulation values (Aim for iterations = 1000000.) + int decoder_int16 = 0; + int itr, iterations = 1000, arguments, polarMessageType = 0; // 0=PBCH, 1=DCI, 2=UCI + double SNRstart = -20.0, SNRstop = 0.0, SNRinc = 0.5; // dB double SNR, SNR_lin; int16_t nBitError = 0; // -1 = Decoding failed (All list entries have failed the CRC checks). - uint32_t decoderState=0, blockErrorState=0; //0 = Success, -1 = Decoding failed, 1 = Block Error. + uint32_t decoderState = 0, blockErrorState = 0; // 0 = Success, -1 = Decoding failed, 1 = Block Error. uint16_t testLength = NR_POLAR_PBCH_PAYLOAD_BITS, coderLength = NR_POLAR_PBCH_E; - uint16_t blockErrorCumulative=0, bitErrorCumulative=0; + uint16_t blockErrorCumulative = 0, bitErrorCumulative = 0; uint8_t aggregation_level = 8, decoderListSize = 8, logFlag = 0; - uint16_t rnti=0; + uint16_t rnti = 0; if ((uniqCfg = load_configmodule(argc, argv, CONFIG_ENABLECMDLINEONLY)) == 0) { exit_fun("[POLARTEST] Error, configuration module init failed\n"); } logInit(); - while ((arguments = getopt (argc, argv, "--:O:s:d:f:m:i:l:a:p:hqgFL:k:")) != -1) { - + while ((arguments = getopt(argc, argv, "--:O:s:d:f:m:i:l:a:p:hqgFL:k:")) != -1) { /* ignore long options starting with '--', option '-O' and their arguments that are handled by configmodule */ /* with this opstring getopt returns 1 for non-option arguments, refer to 'man 3 getopt' */ if (arguments == 1 || arguments == '-' || arguments == 'O') continue; - printf("handling optarg %c\n",arguments); + printf("handling optarg %c\n", arguments); switch (arguments) { - case 's': - SNRstart = atof(optarg); - SNRstop = SNRstart + 2; - break; + case 's': + SNRstart = atof(optarg); + SNRstop = SNRstart + 2; + break; - case 'd': - SNRinc = atof(optarg); - break; + case 'd': + SNRinc = atof(optarg); + break; - case 'f': - SNRstop = atof(optarg); - break; + case 'f': + SNRstop = atof(optarg); + break; - case 'm': - polarMessageType = atoi(optarg); - if (polarMessageType!=0 && polarMessageType!=1 && polarMessageType!=2) - printf("Illegal polar message type %d (should be 0,1 or 2)\n", polarMessageType); - break; + case 'm': + polarMessageType = atoi(optarg); + if (polarMessageType != 0 && polarMessageType != 1 && polarMessageType != 2) + printf("Illegal polar message type %d (should be 0,1 or 2)\n", polarMessageType); + break; - case 'i': - iterations = atoi(optarg); - break; + case 'i': + iterations = atoi(optarg); + break; - case 'l': - decoderListSize = (uint8_t) atoi(optarg); - break; + case 'l': + decoderListSize = (uint8_t)atoi(optarg); + break; - case 'q': - decoder_int16 = 1; - break; + case 'q': + decoder_int16 = 1; + break; - case 'g': - iterations = 1; - SNRstart = -6.0; - SNRstop = -6.0; - decoder_int16 = 1; - break; + case 'g': + iterations = 1; + SNRstart = -6.0; + SNRstop = -6.0; + decoder_int16 = 1; + break; - case 'F': - logFlag = 1; - break; + case 'F': + logFlag = 1; + break; - case 'L': - aggregation_level=atoi(optarg); - if (aggregation_level != 1 && aggregation_level != 2 && aggregation_level != 4 && aggregation_level != 8 && aggregation_level != 16) { - printf("Illegal aggregation level %d \n",aggregation_level); - exit(-1); - } - break; + case 'L': + aggregation_level = atoi(optarg); + if (aggregation_level != 1 && aggregation_level != 2 && aggregation_level != 4 && aggregation_level != 8 + && aggregation_level != 16) { + printf("Illegal aggregation level %d \n", aggregation_level); + exit(-1); + } + break; - case 'k': - testLength=atoi(optarg); - if (testLength < 12 || testLength > 127) { - printf("Illegal packet bitlength %d \n",testLength); - exit(-1); - } - break; + case 'k': + testLength = atoi(optarg); + if (testLength < 12 || testLength > 127) { + printf("Illegal packet bitlength %d \n", testLength); + exit(-1); + } + break; - case 'h': - printf("./polartest\nOptions\n-h Print this help\n-s SNRstart (dB)\n-d SNRinc (dB)\n-f SNRstop (dB)\n-m [0=PBCH|1=DCI|2=UCI]\n" - "-i Number of iterations\n-l decoderListSize\n-q Flag for optimized coders usage\n-F Flag for test results logging\n" - "-L aggregation level (for DCI)\n-k packet_length (bits) for DCI/UCI\n"); - exit(-1); - break; + case 'h': + printf( + "./polartest\nOptions\n-h Print this help\n-s SNRstart (dB)\n-d SNRinc (dB)\n-f SNRstop (dB)\n-m [0=PBCH|1=DCI|2=UCI]\n" + "-i Number of iterations\n-l decoderListSize\n-q Flag for optimized coders usage\n-F Flag for test results logging\n" + "-L aggregation level (for DCI)\n-k packet_length (bits) for DCI/UCI\n"); + exit(-1); + break; - default: - perror("[polartest.c] Problem at argument parsing with getopt"); - exit(-1); - break; + default: + perror("[polartest.c] Problem at argument parsing with getopt"); + exit(-1); + break; } } - //Initiate timing. (Results depend on CPU Frequency. Therefore, might change due to performance variances during simulation.) - time_stats_t timeEncoder,timeDecoder; + // Initiate timing. (Results depend on CPU Frequency. Therefore, might change due to performance variances during simulation.) + time_stats_t timeEncoder, timeDecoder; cpu_meas_enabled = 1; reset_meas(&timeEncoder); reset_meas(&timeDecoder); randominit(0); crcTableInit(); - if (polarMessageType == 0) { //PBCH + if (polarMessageType == 0) { // PBCH aggregation_level = NR_POLAR_PBCH_AGGREGATION_LEVEL; - } else if (polarMessageType == 1) { //DCI - coderLength = 108*aggregation_level; - } else if (polarMessageType == 2) { //UCI - //pucch2 parameters, 1 symbol, aggregation_level = NPRB - AssertFatal(aggregation_level>2,"For UCI formats, aggregation (N_RB) should be > 2\n"); - coderLength = 16*aggregation_level; + } else if (polarMessageType == 1) { // DCI + coderLength = 108 * aggregation_level; + } else if (polarMessageType == 2) { // UCI + // pucch2 parameters, 1 symbol, aggregation_level = NPRB + AssertFatal(aggregation_level > 2, "For UCI formats, aggregation (N_RB) should be > 2\n"); + coderLength = 16 * aggregation_level; } - //Logging + // Logging time_t currentTime; char fileName[512], currentTimeInfo[25]; char folderName[] = "."; FILE *logFile = NULL; - if (logFlag){ - time (¤tTime); + if (logFlag) { + time(¤tTime); #ifdef DEBUG_POLAR_TIMING - sprintf(fileName,"%s/TIMING_ListSize_%d_Payload_%d_Itr_%d", folderName, decoderListSize, testLength, iterations); + sprintf(fileName, "%s/TIMING_ListSize_%d_Payload_%d_Itr_%d", folderName, decoderListSize, testLength, iterations); #else - sprintf(fileName,"%s/_ListSize_%d_Payload_%d_Itr_%d", folderName, decoderListSize, testLength, iterations); + sprintf(fileName, "%s/_ListSize_%d_Payload_%d_Itr_%d", folderName, decoderListSize, testLength, iterations); #endif strftime(currentTimeInfo, 25, "_%Y-%m-%d-%H-%M-%S.csv", localtime(¤tTime)); - strcat(fileName,currentTimeInfo); - //Create "~/Desktop/polartestResults" folder if it doesn't already exist. + strcat(fileName, currentTimeInfo); + // Create "~/Desktop/polartestResults" folder if it doesn't already exist. /*struct stat folder = {0}; - if (stat(folderName, &folder) == -1) mkdir(folderName, S_IRWXU | S_IRWXG | S_IRWXO);*/ + if (stat(folderName, &folder) == -1) mkdir(folderName, S_IRWXU | S_IRWXG | S_IRWXO);*/ logFile = fopen(fileName, "w"); - if (logFile==NULL) { - fprintf(stderr,"[polartest.c] Problem creating file %s with fopen\n",fileName); + if (logFile == NULL) { + fprintf(stderr, "[polartest.c] Problem creating file %s with fopen\n", fileName); exit(-1); } #ifdef DEBUG_POLAR_TIMING - fprintf(logFile,",timeEncoderCRCByte[us],timeEncoderCRCBit[us],timeEncoderInterleaver[us],timeEncoderBitInsertion[us],timeEncoder1[us],timeEncoder2[us],timeEncoderRateMatching[us],timeEncoderByte2Bit[us]\n"); + fprintf(logFile, + ",timeEncoderCRCByte[us],timeEncoderCRCBit[us],timeEncoderInterleaver[us],timeEncoderBitInsertion[us],timeEncoder1[us]," + "timeEncoder2[us],timeEncoderRateMatching[us],timeEncoderByte2Bit[us]\n"); #else - fprintf(logFile,",SNR,nBitError,blockErrorState,t_encoder[us],t_decoder[us]\n"); + fprintf(logFile, ",SNR,nBitError,blockErrorState,t_encoder[us],t_decoder[us]\n"); #endif } @@ -175,54 +178,55 @@ int main(int argc, char *argv[]) // satisfies uint64_t array length const uint8_t realArrayLength = ((testArrayLength + 1) / 2) * 2; printf("testArrayLength %d realArrayLength %d\n", testArrayLength, realArrayLength); - uint32_t testInput[realArrayLength]; //generate randomly + uint32_t testInput[realArrayLength]; // generate randomly uint32_t encoderOutput[coderArrayLength]; - uint32_t estimatedOutput[realArrayLength]; //decoder output - memset(testInput,0,sizeof(uint32_t) * realArrayLength); // does not reset all - memset(encoderOutput,0,sizeof(uint32_t) * coderArrayLength); - memset(estimatedOutput,0,sizeof(uint32_t) * realArrayLength); + uint32_t estimatedOutput[realArrayLength]; // decoder output + memset(testInput, 0, sizeof(uint32_t) * realArrayLength); // does not reset all + memset(encoderOutput, 0, sizeof(uint32_t) * coderArrayLength); + memset(estimatedOutput, 0, sizeof(uint32_t) * realArrayLength); uint8_t encoderOutputByte[coderLength]; - double modulatedInput[coderLength]; //channel input - double channelOutput[coderLength]; //add noise + double modulatedInput[coderLength]; // channel input + double channelOutput[coderLength]; // add noise int16_t channelOutput_int16[coderLength]; - t_nrPolar_params *currentPtr = nr_polar_params(polarMessageType, testLength, aggregation_level, true); + t_nrPolar_params *currentPtr = nr_polar_params(polarMessageType, testLength, aggregation_level); #ifdef DEBUG_DCI_POLAR_PARAMS uint32_t dci_pdu[4]; - memset(dci_pdu,0,sizeof(uint32_t)*4); - dci_pdu[0]=0x01189400; + memset(dci_pdu, 0, sizeof(uint32_t) * 4); + dci_pdu[0] = 0x01189400; printf("dci_pdu: [0]->0x%08x \t [1]->0x%08x \t [2]->0x%08x \t [3]->0x%08x\n", dci_pdu[0], dci_pdu[1], dci_pdu[2], dci_pdu[3]); - uint16_t size=41; - rnti=3; - aggregation_level=8; + uint16_t size = 41; + rnti = 3; + aggregation_level = 8; uint32_t encoder_output[54]; - memset(encoder_output,0,sizeof(uint32_t)*54); - t_nrPolar_params *currentPtrDCI=nr_polar_params(1, size, aggregation_level); + memset(encoder_output, 0, sizeof(uint32_t) * 54); + t_nrPolar_params *currentPtrDCI = nr_polar_params(1, size, aggregation_level); polar_encoder_dci(dci_pdu, encoder_output, currentPtrDCI, rnti); - for (int i=0; i<54; i++) printf("encoder_output: [%2d]->0x%08x \n", i, encoder_output[i]); + for (int i = 0; i < 54; i++) + printf("encoder_output: [%2d]->0x%08x \n", i, encoder_output[i]); uint8_t *encoder_outputByte = malloc(sizeof(uint8_t) * currentPtrDCI->encoderLength); - double *modulated_input = malloc (sizeof(double) * currentPtrDCI->encoderLength); - double *channel_output = malloc (sizeof(double) * currentPtrDCI->encoderLength); + double *modulated_input = malloc(sizeof(double) * currentPtrDCI->encoderLength); + double *channel_output = malloc(sizeof(double) * currentPtrDCI->encoderLength); uint32_t dci_est[4]; - memset(dci_est,0,sizeof(uint32_t)*4); - printf("dci_est: [0]->0x%08x \t [1]->0x%08x \t [2]->0x%08x \t [3]->0x%08x\n", dci_est[0], dci_est[1], dci_est[2], dci_est[3]); + memset(dci_est, 0, sizeof(dci_est)); nr_bit2byte_uint32_8(encoder_output, currentPtrDCI->encoderLength, encoder_outputByte); printf("[polartest] encoder_outputByte: "); - for (int i = 0; i < currentPtrDCI->encoderLength; i++) printf("%d-", encoder_outputByte[i]); printf("\n"); + for (int i = 0; i < currentPtrDCI->encoderLength; i++) + printf("%d-", encoder_outputByte[i]); + printf("\n"); - SNR_lin = pow(10, 0/10); //SNR = 0 dB - for(int i=0; iencoderLength; i++) { - if (encoder_outputByte[i] == 0) - modulated_input[i]=1/sqrt(2); - else - modulated_input[i]=(-1)/sqrt(2); - channel_output[i] = modulated_input[i] + (gaussdouble(0.0,1.0) * (1/sqrt(2*SNR_lin))); + SNR_lin = pow(10, 0 / 10); // SNR = 0 dB + for (int i = 0; i < currentPtrDCI->encoderLength; i++) { + if (encoder_outputByte[i] == 0) + modulated_input[i] = 1 / sqrt(2); + else + modulated_input[i] = (-1) / sqrt(2); + channel_output[i] = modulated_input[i] + (gaussdouble(0.0, 1.0) * (1 / sqrt(2 * SNR_lin))); } - decoderState = polar_decoder_dci(channel_output, dci_est, NR_POLAR_DECODER_LISTSIZE, rnti, - 1, size, aggregation_level); + decoderState = polar_decoder_dci(channel_output, dci_est, NR_POLAR_DECODER_LISTSIZE, rnti, 1, size, aggregation_level); printf("dci_est: [0]->0x%08x \t [1]->0x%08x \t [2]->0x%08x \t [3]->0x%08x\n", dci_est[0], dci_est[1], dci_est[2], dci_est[3]); free(encoder_outputByte); free(channel_output); @@ -233,141 +237,166 @@ int main(int argc, char *argv[]) #endif for (SNR = SNRstart; SNR <= SNRstop; SNR += SNRinc) { - printf("SNR %f\n",SNR); - SNR_lin = pow(10, SNR/10); + printf("SNR %f\n", SNR); + SNR_lin = pow(10, SNR / 10); - for (itr = 1; itr <= iterations; itr++) { - //Generate random values for all the bits of "testInput", not just as much as "currentPtr->payloadBits". - for (int i = 0; i < testArrayLength; i++) { - for (int j = 0; j < (sizeof(testInput[0])*8)-1; j++) { - testInput[i] |= ( ((uint32_t) (rand()%2)) &1); - testInput[i]<<=1; - } - testInput[i] |= ( ((uint32_t) (rand()%2)) &1); - } + for (itr = 1; itr <= iterations; itr++) { + // Generate random values for all the bits of "testInput", not just as much as "currentPtr->payloadBits". + for (int i = 0; i < testArrayLength; i++) { + for (int j = 0; j < (sizeof(testInput[0]) * 8) - 1; j++) { + testInput[i] |= (((uint32_t)(rand() % 2)) & 1); + testInput[i] <<= 1; + } + testInput[i] |= (((uint32_t)(rand() % 2)) & 1); + } #ifdef DEBUG_POLARTEST - //testInput[0] = 0x360f8a5c; - printf("testInput: [0]->0x%08x\n", testInput[0]); + // testInput[0] = 0x360f8a5c; + printf("testInput: [0]->0x%08x\n", testInput[0]); #endif - int len_mod64=currentPtr->payloadBits&63; - ((uint64_t *)testInput)[currentPtr->payloadBits/64]&=((((uint64_t)1)<payloadBits & 63; + ((uint64_t *)testInput)[currentPtr->payloadBits / 64] &= ((((uint64_t)1) << len_mod64) - 1); - start_meas(&timeEncoder); - if (decoder_int16==1) { - polar_encoder_fast((uint64_t *)testInput, encoderOutput, 0, 0, polarMessageType, testLength, aggregation_level); - //polar_encoder_fast((uint64_t*)testInput, (uint64_t*)encoderOutput,0,0,currentPtr); - } else { //0 --> PBCH, 1 --> DCI, -1 --> UCI - if (polarMessageType == 0) - polar_encoder(testInput, encoderOutput, polarMessageType, testLength, aggregation_level); - else if (polarMessageType == 1) - polar_encoder_dci(testInput, encoderOutput, rnti, polarMessageType, testLength, aggregation_level); - } - stop_meas(&timeEncoder); + start_meas(&timeEncoder); + if (decoder_int16 == 1) { + polar_encoder_fast((uint64_t *)testInput, encoderOutput, 0, 0, polarMessageType, testLength, aggregation_level); + // polar_encoder_fast((uint64_t*)testInput, (uint64_t*)encoderOutput,0,0,currentPtr); + } else { // 0 --> PBCH, 1 --> DCI, -1 --> UCI + if (polarMessageType == 0) + polar_encoder(testInput, encoderOutput, polarMessageType, testLength, aggregation_level); + else if (polarMessageType == 1) + polar_encoder_dci(testInput, encoderOutput, rnti, polarMessageType, testLength, aggregation_level); + } + stop_meas(&timeEncoder); #ifdef DEBUG_POLARTEST - printf("encoderOutput: [0]->0x%08x\n", encoderOutput[0]); - //for (int i=1;i0x%08x\n", i, encoderOutput[1]); + printf("encoderOutput: [0]->0x%08x\n", encoderOutput[0]); + // for (int i=1;i0x%08x\n", i, encoderOutput[1]); #endif - //Bit-to-byte: + // Bit-to-byte: nr_bit2byte_uint32_8(encoderOutput, coderLength, encoderOutputByte); - //BPSK modulation - for(int i=0; i 15) channelOutput_int16[i] = 127; - else if (channelOutput[i] < -16) channelOutput_int16[i] = -128; - else channelOutput_int16[i] = (int16_t) (8*channelOutput[i]); - } + if (decoder_int16 == 1) { + if (channelOutput[i] > 15) + channelOutput_int16[i] = 127; + else if (channelOutput[i] < -16) + channelOutput_int16[i] = -128; + else + channelOutput_int16[i] = (int16_t)(8 * channelOutput[i]); + } } start_meas(&timeDecoder); - if (decoder_int16==1) { - decoderState = polar_decoder_int16(channelOutput_int16, (uint64_t *)estimatedOutput, 0, - polarMessageType, testLength, aggregation_level); - } else { //0 --> PBCH, 1 --> DCI, -1 --> UCI - if (polarMessageType == 0) { - decoderState = polar_decoder(channelOutput, - estimatedOutput, - decoderListSize, - polarMessageType, testLength, aggregation_level); - } else if (polarMessageType == 1) { - decoderState = polar_decoder_dci(channelOutput, - estimatedOutput, - decoderListSize, - rnti, - polarMessageType, testLength, aggregation_level); - } + if (decoder_int16 == 1) { + decoderState = polar_decoder_int16(channelOutput_int16, + (uint64_t *)estimatedOutput, + 0, + polarMessageType, + testLength, + aggregation_level); + } else { // 0 --> PBCH, 1 --> DCI, -1 --> UCI + if (polarMessageType == 0) { + decoderState = + polar_decoder(channelOutput, estimatedOutput, decoderListSize, polarMessageType, testLength, aggregation_level); + } else if (polarMessageType == 1) { + decoderState = polar_decoder_dci(channelOutput, + estimatedOutput, + decoderListSize, + rnti, + polarMessageType, + testLength, + aggregation_level); + } } stop_meas(&timeDecoder); - + #ifdef DEBUG_POLARTEST printf("estimatedOutput: [0]->0x%08x\n", estimatedOutput[0]); #endif - //calculate errors - if (decoderState!=0) { - blockErrorState=-1; - nBitError=-1; + // calculate errors + if (decoderState != 0) { + blockErrorState = -1; + nBitError = -1; } else { - for (int i = 0; i < (testArrayLength-1); i++) { - for (int j = 0; j < 32; j++) { - if ( ((estimatedOutput[i]>>j) & 1) != ((testInput[i]>>j) & 1) ) - nBitError++; - } - } - for (int j = 0; j < testLength - ((testArrayLength-1) * 32); j++) - if ( ((estimatedOutput[(testArrayLength-1)]>>j) & 1) != ((testInput[(testArrayLength-1)]>>j) & 1) ) - nBitError++; + for (int i = 0; i < (testArrayLength - 1); i++) { + for (int j = 0; j < 32; j++) { + if (((estimatedOutput[i] >> j) & 1) != ((testInput[i] >> j) & 1)) + nBitError++; + } + } + for (int j = 0; j < testLength - ((testArrayLength - 1) * 32); j++) + if (((estimatedOutput[(testArrayLength - 1)] >> j) & 1) != ((testInput[(testArrayLength - 1)] >> j) & 1)) + nBitError++; } - if (nBitError>0) blockErrorState=1; + if (nBitError > 0) + blockErrorState = 1; #ifdef DEBUG_POLARTEST - for (int i = 0; i < testArrayLength; i++) - printf("[polartest/decoderState=%u] testInput[%d]=0x%08x, estimatedOutput[%d]=0x%08x\n",decoderState, i, testInput[i], i, estimatedOutput[i]); + for (int i = 0; i < testArrayLength; i++) + printf("[polartest/decoderState=%u] testInput[%d]=0x%08x, estimatedOutput[%d]=0x%08x\n", + decoderState, + i, + testInput[i], + i, + estimatedOutput[i]); #endif - //Iteration times are in microseconds. - if (logFlag) fprintf(logFile,",%f,%d,%u,%f,%f\n", SNR, nBitError, blockErrorState, (timeEncoder.diff/(get_cpu_freq_GHz()*1000.0)), (timeDecoder.diff/(get_cpu_freq_GHz()*1000.0))); + // Iteration times are in microseconds. + if (logFlag) + fprintf(logFile, + ",%f,%d,%u,%f,%f\n", + SNR, + nBitError, + blockErrorState, + (timeEncoder.diff / (get_cpu_freq_GHz() * 1000.0)), + (timeDecoder.diff / (get_cpu_freq_GHz() * 1000.0))); - if (nBitError<0) { + if (nBitError < 0) { blockErrorCumulative++; - bitErrorCumulative+=testLength; + bitErrorCumulative += testLength; } else { - blockErrorCumulative+=blockErrorState; - bitErrorCumulative+=nBitError; + blockErrorCumulative += blockErrorState; + bitErrorCumulative += nBitError; } - decoderState=0; - nBitError=0; - blockErrorState=0; - memset(testInput,0,sizeof(uint32_t) * realArrayLength); - memset(encoderOutput,0,sizeof(uint32_t) * coderArrayLength); - memset(estimatedOutput,0,sizeof(uint32_t) * realArrayLength); + decoderState = 0; + nBitError = 0; + blockErrorState = 0; + memset(testInput, 0, sizeof(uint32_t) * realArrayLength); + memset(encoderOutput, 0, sizeof(uint32_t) * coderArrayLength); + memset(estimatedOutput, 0, sizeof(uint32_t) * realArrayLength); } - //Calculate error statistics for the SNR. + // Calculate error statistics for the SNR. printf("[ListSize=%d] SNR=%+8.3f, BLER=%9.6f, BER=%12.9f, t_Encoder=%9.3fus, t_Decoder=%9.3fus\n", - decoderListSize, SNR, ((double)blockErrorCumulative/iterations), - ((double)bitErrorCumulative / (iterations*testLength)), - (double)timeEncoder.diff/timeEncoder.trials/(get_cpu_freq_GHz()*1000.0),(double)timeDecoder.diff/timeDecoder.trials/(get_cpu_freq_GHz()*1000.0)); + decoderListSize, + SNR, + ((double)blockErrorCumulative / iterations), + ((double)bitErrorCumulative / (iterations * testLength)), + (double)timeEncoder.diff / timeEncoder.trials / (get_cpu_freq_GHz() * 1000.0), + (double)timeDecoder.diff / timeDecoder.trials / (get_cpu_freq_GHz() * 1000.0)); - if (blockErrorCumulative==0 && bitErrorCumulative==0) break; + if (blockErrorCumulative == 0 && bitErrorCumulative == 0) + break; blockErrorCumulative = 0; bitErrorCumulative = 0; } - print_meas(&timeEncoder,"polar_encoder",NULL,NULL); - print_meas(&timeDecoder,"polar_decoder",NULL,NULL); - if (logFlag) fclose(logFile); + print_meas(&timeEncoder, "polar_encoder", NULL, NULL); + print_meas(&timeDecoder, "polar_decoder", NULL, NULL); + if (logFlag) + fclose(logFile); return (0); } diff --git a/openair1/PHY/CODING/nrPolar_tools/nr_bitwise_operations.c b/openair1/PHY/CODING/nrPolar_tools/nr_bitwise_operations.c index d489183d9a..205c94f748 100644 --- a/openair1/PHY/CODING/nrPolar_tools/nr_bitwise_operations.c +++ b/openair1/PHY/CODING/nrPolar_tools/nr_bitwise_operations.c @@ -28,11 +28,12 @@ * \email turker.yilmaz@eurecom.fr * \note * \warning -*/ + */ #include "PHY/CODING/nrPolar_tools/nr_polar_defs.h" -void nr_bit2byte_uint32_8(uint32_t *in, uint16_t arraySize, uint8_t *out) { +void nr_bit2byte_uint32_8(uint32_t *in, uint16_t arraySize, uint8_t *out) +{ const uint arrayInd = ceil(arraySize / 32.0); for (int i = 0; i < (arrayInd - 1); i++) { for (int j = 0; j < 32; j++) { @@ -44,7 +45,8 @@ void nr_bit2byte_uint32_8(uint32_t *in, uint16_t arraySize, uint8_t *out) { out[j + ((arrayInd - 1) * 32)] = (in[(arrayInd - 1)] >> j) & 1; } -void nr_byte2bit_uint8_32(uint8_t *in, uint16_t arraySize, uint32_t *out) { +void nr_byte2bit_uint8_32(uint8_t *in, uint16_t arraySize, uint32_t *out) +{ const uint arrayInd = ceil(arraySize / 32.0); for (int i = 0; i < arrayInd; i++) { out[i] = 0; diff --git a/openair1/PHY/CODING/nrPolar_tools/nr_crc_byte.c b/openair1/PHY/CODING/nrPolar_tools/nr_crc_byte.c index d04dde62e7..1908aa654c 100644 --- a/openair1/PHY/CODING/nrPolar_tools/nr_crc_byte.c +++ b/openair1/PHY/CODING/nrPolar_tools/nr_crc_byte.c @@ -29,7 +29,8 @@ const uint8_t **crc24c_generator_matrix(uint16_t payloadSizeBits) uint8_t crcPolynomialSize = 24; uint8_t temp1[crcPolynomialSize], temp2[crcPolynomialSize]; - uint8_t **crc_generator_matrix = malloc(payloadSizeBits*sizeof(uint8_t *) + payloadSizeBits*crcPolynomialSize*sizeof(uint8_t)); + uint8_t **crc_generator_matrix = + malloc(payloadSizeBits * sizeof(uint8_t *) + payloadSizeBits * crcPolynomialSize * sizeof(uint8_t)); if (crc_generator_matrix) for (int i = 0; i < payloadSizeBits; i++) crc_generator_matrix[i] = ((uint8_t *)&crc_generator_matrix[payloadSizeBits]) + i * crcPolynomialSize; @@ -38,7 +39,8 @@ const uint8_t **crc24c_generator_matrix(uint16_t payloadSizeBits) crc_generator_matrix[payloadSizeBits - 1][i] = crcPolynomialPattern[i + 1]; for (int i = payloadSizeBits - 2; i >= 0; i--) { - for (int j = 0; j < crcPolynomialSize-1; j++) temp1[j]=crc_generator_matrix[i+1][j+1]; + for (int j = 0; j < crcPolynomialSize - 1; j++) + temp1[j] = crc_generator_matrix[i + 1][j + 1]; temp1[crcPolynomialSize - 1] = 0; @@ -46,10 +48,10 @@ const uint8_t **crc24c_generator_matrix(uint16_t payloadSizeBits) temp2[j] = crc_generator_matrix[i + 1][0] * crcPolynomialPattern[j + 1]; for (int j = 0; j < crcPolynomialSize; j++) { - if(temp1[j]+temp2[j] == 1) - crc_generator_matrix[i][j]=1; - else - crc_generator_matrix[i][j]=0; + if (temp1[j] + temp2[j] == 1) + crc_generator_matrix[i][j] = 1; + else + crc_generator_matrix[i][j] = 0; } } return (const uint8_t **)crc_generator_matrix; diff --git a/openair1/PHY/CODING/nrPolar_tools/nr_polar_dci_defs.h b/openair1/PHY/CODING/nrPolar_tools/nr_polar_dci_defs.h index 842088b26c..871f4f57b0 100644 --- a/openair1/PHY/CODING/nrPolar_tools/nr_polar_dci_defs.h +++ b/openair1/PHY/CODING/nrPolar_tools/nr_polar_dci_defs.h @@ -20,31 +20,31 @@ */ /*! \file PHY/CODING/nrPolar_tools/nr_polar_dci_defs.h -* \brief Defines the constant variables for polar coding of the DCI from 38-212, V15.1.1 2018-04. -* \author -* \date 2018 -* \version 0.1 -* \company Eurecom -* \email: -* \note -* \warning -*/ + * \brief Defines the constant variables for polar coding of the DCI from 38-212, V15.1.1 2018-04. + * \author + * \date 2018 + * \version 0.1 + * \company Eurecom + * \email: + * \note + * \warning + */ #ifndef __NR_POLAR_DCI_DEFS__H__ #define __NR_POLAR_DCI_DEFS__H__ -#define NR_POLAR_DCI_MESSAGE_TYPE 1 //int8_t +#define NR_POLAR_DCI_MESSAGE_TYPE 1 // int8_t #define NR_POLAR_DCI_CRC_PARITY_BITS 24 #define NR_POLAR_DCI_CRC_ERROR_CORRECTION_BITS 3 -//Sec. 7.3.3: Channel Coding -#define NR_POLAR_DCI_N_MAX 9 //uint8_t -#define NR_POLAR_DCI_I_IL 1 //uint8_t -#define NR_POLAR_DCI_I_SEG 0 //uint8_t -#define NR_POLAR_DCI_N_PC 0 //uint8_t -#define NR_POLAR_DCI_N_PC_WM 0 //uint8_t +// Sec. 7.3.3: Channel Coding +#define NR_POLAR_DCI_N_MAX 9 // uint8_t +#define NR_POLAR_DCI_I_IL 1 // uint8_t +#define NR_POLAR_DCI_I_SEG 0 // uint8_t +#define NR_POLAR_DCI_N_PC 0 // uint8_t +#define NR_POLAR_DCI_N_PC_WM 0 // uint8_t -//Sec. 7.3.4: Rate Matching -#define NR_POLAR_DCI_I_BIL 0 //uint8_t +// Sec. 7.3.4: Rate Matching +#define NR_POLAR_DCI_I_BIL 0 // uint8_t #endif diff --git a/openair1/PHY/CODING/nrPolar_tools/nr_polar_decoder.c b/openair1/PHY/CODING/nrPolar_tools/nr_polar_decoder.c index 5704a9e0d4..14013681b0 100644 --- a/openair1/PHY/CODING/nrPolar_tools/nr_polar_decoder.c +++ b/openair1/PHY/CODING/nrPolar_tools/nr_polar_decoder.c @@ -39,17 +39,17 @@ #include "PHY/CODING/nrPolar_tools/nr_polar_defs.h" #include "assertions.h" -//#define POLAR_CODING_DEBUG +// #define POLAR_CODING_DEBUG static inline void updateCrcChecksum2(int xlen, - int ylen, - uint8_t crcChecksum[xlen][ylen], - int gxlen, - int gylen, - uint8_t crcGen[gxlen][gylen], - uint8_t listSize, - uint32_t i2, - uint8_t len) + int ylen, + uint8_t crcChecksum[xlen][ylen], + int gxlen, + int gylen, + uint8_t crcGen[gxlen][gylen], + uint8_t listSize, + uint32_t i2, + uint8_t len) { for (uint i = 0; i < listSize; i++) { for (uint j = 0; j < len; j++) { @@ -63,67 +63,71 @@ int8_t polar_decoder(double *input, uint8_t listSize, int8_t messageType, uint16_t messageLength, - uint8_t aggregation_level - ) + uint8_t aggregation_level) { - t_nrPolar_params *polarParams=nr_polar_params(messageType, messageLength, aggregation_level, true); - //Assumes no a priori knowledge. + t_nrPolar_params *polarParams = nr_polar_params(messageType, messageLength, aggregation_level); + // Assumes no a priori knowledge. uint8_t bit[polarParams->N][polarParams->n + 1][2 * listSize]; memset(bit, 0, sizeof bit); - uint8_t bitUpdated[polarParams->N][polarParams->n+1]; //0=False, 1=True - memset(bitUpdated,0,sizeof bitUpdated); - uint8_t llrUpdated[polarParams->N][polarParams->n+1]; //0=False, 1=True - memset(llrUpdated,0,sizeof llrUpdated); + uint8_t bitUpdated[polarParams->N][polarParams->n + 1]; // 0=False, 1=True + memset(bitUpdated, 0, sizeof bitUpdated); + uint8_t llrUpdated[polarParams->N][polarParams->n + 1]; // 0=False, 1=True + memset(llrUpdated, 0, sizeof llrUpdated); double llr[polarParams->N][polarParams->n + 1][2 * listSize]; - uint8_t crcChecksum[polarParams->crcParityBits][2*listSize]; - memset(crcChecksum,0,sizeof crcChecksum); - double pathMetric[2*listSize]; - uint8_t crcState[2*listSize]; //0=False, 1=True + uint8_t crcChecksum[polarParams->crcParityBits][2 * listSize]; + memset(crcChecksum, 0, sizeof crcChecksum); + double pathMetric[2 * listSize]; + uint8_t crcState[2 * listSize]; // 0=False, 1=True - for (int i=0; i<(2*listSize); i++) { + for (int i = 0; i < (2 * listSize); i++) { pathMetric[i] = 0; - crcState[i]=1; + crcState[i] = 1; } - for (int i=0; iN; i++) { - llrUpdated[i][polarParams->n]=1; + for (int i = 0; i < polarParams->N; i++) { + llrUpdated[i][polarParams->n] = 1; bitUpdated[i][0] = (polarParams->information_bit_pattern[i] + 1) % 2; } - uint8_t extended_crc_generator_matrix[polarParams->K][polarParams->crcParityBits]; //G_P3 - uint8_t tempECGM[polarParams->K][polarParams->crcParityBits]; //G_P2 + uint8_t extended_crc_generator_matrix[polarParams->K][polarParams->crcParityBits]; // G_P3 + uint8_t tempECGM[polarParams->K][polarParams->crcParityBits]; // G_P2 - for (int i=0; ipayloadBits; i++) { - for (int j=0; jcrcParityBits; j++) { - tempECGM[i][j]=polarParams->crc_generator_matrix[i][j]; + for (int i = 0; i < polarParams->payloadBits; i++) { + for (int j = 0; j < polarParams->crcParityBits; j++) { + tempECGM[i][j] = polarParams->crc_generator_matrix[i][j]; } } - for (int i=polarParams->payloadBits; iK; i++) { - for (int j=0; jcrcParityBits; j++) { + for (int i = polarParams->payloadBits; i < polarParams->K; i++) { + for (int j = 0; j < polarParams->crcParityBits; j++) { tempECGM[i][j] = (i - polarParams->payloadBits) == j; } } - for (int i=0; iK; i++) { - for (int j=0; jcrcParityBits; j++) { - extended_crc_generator_matrix[i][j]=tempECGM[polarParams->interleaving_pattern[i]][j]; + for (int i = 0; i < polarParams->K; i++) { + for (int j = 0; j < polarParams->crcParityBits; j++) { + extended_crc_generator_matrix[i][j] = tempECGM[polarParams->interleaving_pattern[i]][j]; } } - //The index of the last 1-valued bit that appears in each column. - AssertFatal(polarParams->crcParityBits > 0, "UB for VLA. crcParityBits negative\n"); + // The index of the last 1-valued bit that appears in each column. + AssertFatal(polarParams->crcParityBits > 0, "UB for VLA. crcParityBits negative\n"); uint16_t last1ind[polarParams->crcParityBits]; - for (int j=0; jcrcParityBits; j++) { - for (int i=0; iK; i++) { + for (int j = 0; j < polarParams->crcParityBits; j++) { + for (int i = 0; i < polarParams->K; i++) { if (extended_crc_generator_matrix[i][j] == 1) last1ind[j] = i; } } double d_tilde[polarParams->N]; - nr_polar_rate_matching(input, d_tilde, polarParams->rate_matching_pattern, polarParams->K, polarParams->N, polarParams->encoderLength); + nr_polar_rate_matching(input, + d_tilde, + polarParams->rate_matching_pattern, + polarParams->K, + polarParams->N, + polarParams->encoderLength); for (int j = 0; j < polarParams->N; j++) llr[j][polarParams->n][0] = d_tilde[j]; @@ -131,18 +135,18 @@ int8_t polar_decoder(double *input, /* * SCL polar decoder. */ - uint32_t nonFrozenBit=0; + uint32_t nonFrozenBit = 0; uint currentListSize = 1; uint decoderIterationCheck = 0; int checkCrcBits = -1; - uint8_t listIndex[2*listSize], copyIndex; + uint8_t listIndex[2 * listSize], copyIndex; for (uint currentBit = 0; currentBit < polarParams->N; currentBit++) { updateLLR(currentListSize, currentBit, 0, polarParams->N, polarParams->n + 1, 2 * listSize, llr, llrUpdated, bit, bitUpdated); - if (polarParams->information_bit_pattern[currentBit]==0) { //Frozen bit. + if (polarParams->information_bit_pattern[currentBit] == 0) { // Frozen bit. updatePathMetric(pathMetric, currentListSize, 0, currentBit, polarParams->N, polarParams->n + 1, 2 * listSize, llr); - } else { //Information or CRC bit. + } else { // Information or CRC bit. updatePathMetric2(pathMetric, currentListSize, currentBit, polarParams->N, polarParams->n + 1, 2 * listSize, llr); for (int i = 0; i < currentListSize; i++) { @@ -198,30 +202,30 @@ int8_t polar_decoder(double *input, break; } - //First, backup the best "listSize" number of entries. - for (int k=(listSize-1); k>0; k--) { - for (int i=0; iN; i++) { - for (int j=0; j<(polarParams->n+1); j++) { + // First, backup the best "listSize" number of entries. + for (int k = (listSize - 1); k > 0; k--) { + for (int i = 0; i < polarParams->N; i++) { + for (int j = 0; j < (polarParams->n + 1); j++) { bit[i][j][listIndex[(2 * listSize - 1) - k]] = bit[i][j][listIndex[k]]; llr[i][j][listIndex[(2 * listSize - 1) - k]] = llr[i][j][listIndex[k]]; } } } - for (int k=(listSize-1); k>0; k--) { + for (int k = (listSize - 1); k > 0; k--) { for (int i = 0; i < polarParams->crcParityBits; i++) { - crcChecksum[i][listIndex[(2*listSize-1)-k]] = crcChecksum[i][listIndex[k]]; + crcChecksum[i][listIndex[(2 * listSize - 1) - k]] = crcChecksum[i][listIndex[k]]; } } for (int k = (listSize - 1); k > 0; k--) crcState[listIndex[(2 * listSize - 1) - k]] = crcState[listIndex[k]]; - //Copy the best "listSize" number of entries to the first indices. + // Copy the best "listSize" number of entries to the first indices. for (int k = 0; k < listSize; k++) { if (k > listIndex[k]) { - copyIndex = listIndex[(2*listSize-1)-k]; - } else { //Use the backup. + copyIndex = listIndex[(2 * listSize - 1) - k]; + } else { // Use the backup. copyIndex = listIndex[k]; } @@ -235,40 +239,40 @@ int8_t polar_decoder(double *input, for (int k = 0; k < listSize; k++) { if (k > listIndex[k]) { - copyIndex = listIndex[(2*listSize-1)-k]; - } else { //Use the backup. + copyIndex = listIndex[(2 * listSize - 1) - k]; + } else { // Use the backup. copyIndex = listIndex[k]; } for (int i = 0; i < polarParams->crcParityBits; i++) { - crcChecksum[i][k]=crcChecksum[i][copyIndex]; + crcChecksum[i][k] = crcChecksum[i][copyIndex]; } } for (int k = 0; k < listSize; k++) { if (k > listIndex[k]) { - copyIndex = listIndex[(2*listSize-1)-k]; - } else { //Use the backup. + copyIndex = listIndex[(2 * listSize - 1) - k]; + } else { // Use the backup. copyIndex = listIndex[k]; } - crcState[k]=crcState[copyIndex]; + crcState[k] = crcState[copyIndex]; } currentListSize = listSize; } - for (int i=0; icrcParityBits; i++) { - if (last1ind[i]==nonFrozenBit) { - checkCrcBits=i; + for (int i = 0; i < polarParams->crcParityBits; i++) { + if (last1ind[i] == nonFrozenBit) { + checkCrcBits = i; break; } } - if ( checkCrcBits > (-1) ) { + if (checkCrcBits > (-1)) { for (uint i = 0; i < currentListSize; i++) { - if (crcChecksum[checkCrcBits][i]==1) { - crcState[i]=0; //0=False, 1=True + if (crcChecksum[checkCrcBits][i] == 1) { + crcState[i] = 0; // 0=False, 1=True } } } @@ -276,15 +280,15 @@ int8_t polar_decoder(double *input, for (uint i = 0; i < currentListSize; i++) decoderIterationCheck += crcState[i]; - if (decoderIterationCheck==0) { - //perror("[SCL polar decoder] All list entries have failed the CRC checks."); + if (decoderIterationCheck == 0) { + // perror("[SCL polar decoder] All list entries have failed the CRC checks."); polarReturn(polarParams); return -1; } nonFrozenBit++; - decoderIterationCheck=0; - checkCrcBits=-1; + decoderIterationCheck = 0; + checkCrcBits = -1; } } @@ -294,19 +298,19 @@ int8_t polar_decoder(double *input, nr_sort_asc_double_1D_array_ind(pathMetric, listIndex, currentListSize); uint8_t nr_polar_A[polarParams->payloadBits]; for (uint i = 0; i < fmin(listSize, (pow(2, polarParams->crcCorrectionBits))); i++) { - if ( crcState[listIndex[i]] == 1 ) { + if (crcState[listIndex[i]] == 1) { uint8_t nr_polar_U[polarParams->N]; for (int j = 0; j < polarParams->N; j++) nr_polar_U[j] = bit[j][0][listIndex[i]]; - //Extract the information bits (û to ĉ) + // Extract the information bits (û to ĉ) uint8_t nr_polar_CPrime[polarParams->N]; nr_polar_info_bit_extraction(nr_polar_U, nr_polar_CPrime, polarParams->information_bit_pattern, polarParams->N); - //Deinterleaving (ĉ to b) + // Deinterleaving (ĉ to b) uint8_t nr_polar_B[polarParams->K]; nr_polar_deinterleaver(nr_polar_CPrime, nr_polar_B, polarParams->interleaving_pattern, polarParams->K); - //Remove the CRC (â) + // Remove the CRC (â) memcpy(nr_polar_A, nr_polar_B, polarParams->payloadBits); break; @@ -328,123 +332,137 @@ int8_t polar_decoder_dci(double *input, uint16_t n_RNTI, int8_t messageType, uint16_t messageLength, - uint8_t aggregation_level ) { - t_nrPolar_params *polarParams=nr_polar_params(messageType, messageLength, aggregation_level, true); + uint8_t aggregation_level) +{ + t_nrPolar_params *polarParams = nr_polar_params(messageType, messageLength, aggregation_level); - uint8_t bit[polarParams->N][polarParams->n+1][2*listSize]; - memset(bit,0,sizeof bit); - uint8_t bitUpdated[polarParams->N][polarParams->n+1]; //0=False, 1=True - memset(bitUpdated,0,sizeof bitUpdated); - uint8_t llrUpdated[polarParams->N][polarParams->n+1]; //0=False, 1=True - memset(llrUpdated,0,sizeof llrUpdated); - double llr[polarParams->N][polarParams->n+1][2*listSize]; - uint8_t crcChecksum[polarParams->crcParityBits][2*listSize]; - memset(crcChecksum,0,sizeof crcChecksum); - double pathMetric[2*listSize]; - uint8_t crcState[2*listSize]; //0=False, 1=True + uint8_t bit[polarParams->N][polarParams->n + 1][2 * listSize]; + memset(bit, 0, sizeof bit); + uint8_t bitUpdated[polarParams->N][polarParams->n + 1]; // 0=False, 1=True + memset(bitUpdated, 0, sizeof bitUpdated); + uint8_t llrUpdated[polarParams->N][polarParams->n + 1]; // 0=False, 1=True + memset(llrUpdated, 0, sizeof llrUpdated); + double llr[polarParams->N][polarParams->n + 1][2 * listSize]; + uint8_t crcChecksum[polarParams->crcParityBits][2 * listSize]; + memset(crcChecksum, 0, sizeof crcChecksum); + double pathMetric[2 * listSize]; + uint8_t crcState[2 * listSize]; // 0=False, 1=True uint8_t extended_crc_scrambling_pattern[polarParams->crcParityBits]; - for (int i=0; i<(2*listSize); i++) { + for (int i = 0; i < (2 * listSize); i++) { pathMetric[i] = 0; - crcState[i]=1; + crcState[i] = 1; } - for (int i=0; iN; i++) { - llrUpdated[i][polarParams->n]=1; + for (int i = 0; i < polarParams->N; i++) { + llrUpdated[i][polarParams->n] = 1; bitUpdated[i][0] = (polarParams->information_bit_pattern[i] + 1) % 2; } - uint8_t extended_crc_generator_matrix[polarParams->K][polarParams->crcParityBits]; //G_P3: K-by-P - uint8_t tempECGM[polarParams->K][polarParams->crcParityBits]; //G_P2: K-by-P + uint8_t extended_crc_generator_matrix[polarParams->K][polarParams->crcParityBits]; // G_P3: K-by-P + uint8_t tempECGM[polarParams->K][polarParams->crcParityBits]; // G_P2: K-by-P - for (int i=0; ipayloadBits; i++) { - for (int j=0; jcrcParityBits; j++) { - tempECGM[i][j]=polarParams->crc_generator_matrix[i+polarParams->crcParityBits][j]; + for (int i = 0; i < polarParams->payloadBits; i++) { + for (int j = 0; j < polarParams->crcParityBits; j++) { + tempECGM[i][j] = polarParams->crc_generator_matrix[i + polarParams->crcParityBits][j]; } } - for (int i=polarParams->payloadBits; iK; i++) { - for (int j=0; jcrcParityBits; j++) { + for (int i = polarParams->payloadBits; i < polarParams->K; i++) { + for (int j = 0; j < polarParams->crcParityBits; j++) { tempECGM[i][j] = (i - polarParams->payloadBits) == j; } } - for (int i=0; iK; i++) { - for (int j=0; jcrcParityBits; j++) { - extended_crc_generator_matrix[i][j]=tempECGM[polarParams->interleaving_pattern[i]][j]; + for (int i = 0; i < polarParams->K; i++) { + for (int j = 0; j < polarParams->crcParityBits; j++) { + extended_crc_generator_matrix[i][j] = tempECGM[polarParams->interleaving_pattern[i]][j]; } } - //The index of the last 1-valued bit that appears in each column. + // The index of the last 1-valued bit that appears in each column. uint16_t last1ind[polarParams->crcParityBits]; - for (int j=0; jcrcParityBits; j++) { - for (int i=0; iK; i++) { - if (extended_crc_generator_matrix[i][j]==1) last1ind[j]=i; + for (int j = 0; j < polarParams->crcParityBits; j++) { + for (int i = 0; i < polarParams->K; i++) { + if (extended_crc_generator_matrix[i][j] == 1) + last1ind[j] = i; } } for (int i = 0; i < 8; i++) extended_crc_scrambling_pattern[i] = 0; - for (int i=8; icrcParityBits; i++) { - extended_crc_scrambling_pattern[i]=(n_RNTI>>(23-i))&1; + for (int i = 8; i < polarParams->crcParityBits; i++) { + extended_crc_scrambling_pattern[i] = (n_RNTI >> (23 - i)) & 1; } double d_tilde[polarParams->N]; - nr_polar_rate_matching(input, d_tilde, polarParams->rate_matching_pattern, polarParams->K, polarParams->N, polarParams->encoderLength); + nr_polar_rate_matching(input, + d_tilde, + polarParams->rate_matching_pattern, + polarParams->K, + polarParams->N, + polarParams->encoderLength); for (int j = 0; j < polarParams->N; j++) - llr[j][polarParams->n][0]=d_tilde[j]; + llr[j][polarParams->n][0] = d_tilde[j]; /* * SCL polar decoder. */ - for (int i=0; icrcParityBits; i++) { - for (int j=0; jcrcParityBits; j++) - crcChecksum[i][0]=crcChecksum[i][0]+polarParams->crc_generator_matrix[j][i]; + for (int i = 0; i < polarParams->crcParityBits; i++) { + for (int j = 0; j < polarParams->crcParityBits; j++) + crcChecksum[i][0] = crcChecksum[i][0] + polarParams->crc_generator_matrix[j][i]; - crcChecksum[i][0]=(crcChecksum[i][0]%2); + crcChecksum[i][0] = (crcChecksum[i][0] % 2); } - uint32_t nonFrozenBit=0; + uint32_t nonFrozenBit = 0; uint currentListSize = 1; uint decoderIterationCheck = 0; int checkCrcBits = -1; - uint8_t listIndex[2*listSize], copyIndex; + uint8_t listIndex[2 * listSize], copyIndex; for (uint currentBit = 0; currentBit < polarParams->N; currentBit++) { - updateLLR(currentListSize, currentBit, 0, polarParams->N, polarParams->n+1, 2*listSize, llr, llrUpdated, bit, bitUpdated); + updateLLR(currentListSize, currentBit, 0, polarParams->N, polarParams->n + 1, 2 * listSize, llr, llrUpdated, bit, bitUpdated); - if (polarParams->information_bit_pattern[currentBit]==0) { //Frozen bit. - updatePathMetric(pathMetric, currentListSize, 0, currentBit,polarParams->N, polarParams->n+1, 2*listSize, llr); - } else { //Information or CRC bit. - updatePathMetric2(pathMetric, currentListSize, currentBit, polarParams->N, polarParams->n+1, 2*listSize, llr); + if (polarParams->information_bit_pattern[currentBit] == 0) { // Frozen bit. + updatePathMetric(pathMetric, currentListSize, 0, currentBit, polarParams->N, polarParams->n + 1, 2 * listSize, llr); + } else { // Information or CRC bit. + updatePathMetric2(pathMetric, currentListSize, currentBit, polarParams->N, polarParams->n + 1, 2 * listSize, llr); for (int i = 0; i < currentListSize; i++) { for (int j = 0; j < polarParams->N; j++) { - for (int k = 0; k < (polarParams->n+1); k++) { - bit[j][k][i+currentListSize]=bit[j][k][i]; - llr[j][k][i+currentListSize]=llr[j][k][i]; + for (int k = 0; k < (polarParams->n + 1); k++) { + bit[j][k][i + currentListSize] = bit[j][k][i]; + llr[j][k][i + currentListSize] = llr[j][k][i]; } } } for (int i = 0; i < currentListSize; i++) { - bit[currentBit][0][i]=0; - crcState[i+currentListSize]=crcState[i]; + bit[currentBit][0][i] = 0; + crcState[i + currentListSize] = crcState[i]; } - for (int i = currentListSize; i < 2*currentListSize; i++) bit[currentBit][0][i]=1; + for (int i = currentListSize; i < 2 * currentListSize; i++) + bit[currentBit][0][i] = 1; - bitUpdated[currentBit][0]=1; - updateCrcChecksum2(polarParams->crcParityBits, 2*listSize, crcChecksum, - polarParams->K, polarParams->crcParityBits, extended_crc_generator_matrix, - currentListSize, nonFrozenBit, polarParams->crcParityBits); - currentListSize*=2; + bitUpdated[currentBit][0] = 1; + updateCrcChecksum2(polarParams->crcParityBits, + 2 * listSize, + crcChecksum, + polarParams->K, + polarParams->crcParityBits, + extended_crc_generator_matrix, + currentListSize, + nonFrozenBit, + polarParams->crcParityBits); + currentListSize *= 2; - //Keep only the best "listSize" number of entries. + // Keep only the best "listSize" number of entries. if (currentListSize > listSize) { for (uint i = 0; i < 2 * listSize; i++) listIndex[i] = i; @@ -456,7 +474,7 @@ int8_t polar_decoder_dci(double *input, int swaps = 0; for (uint j = listSize; j < (2 * listSize - i) - 1; j++) { - if (listIndex[j+1] > listIndex[j]) { + if (listIndex[j + 1] > listIndex[j]) { int tempInd = listIndex[j]; listIndex[j] = listIndex[j + 1]; listIndex[j + 1] = tempInd; @@ -468,30 +486,30 @@ int8_t polar_decoder_dci(double *input, break; } - //First, backup the best "listSize" number of entries. - for (int k=(listSize-1); k>0; k--) { - for (int i=0; iN; i++) { - for (int j=0; j<(polarParams->n+1); j++) { - bit[i][j][listIndex[(2*listSize-1)-k]]=bit[i][j][listIndex[k]]; - llr[i][j][listIndex[(2*listSize-1)-k]]=llr[i][j][listIndex[k]]; + // First, backup the best "listSize" number of entries. + for (int k = (listSize - 1); k > 0; k--) { + for (int i = 0; i < polarParams->N; i++) { + for (int j = 0; j < (polarParams->n + 1); j++) { + bit[i][j][listIndex[(2 * listSize - 1) - k]] = bit[i][j][listIndex[k]]; + llr[i][j][listIndex[(2 * listSize - 1) - k]] = llr[i][j][listIndex[k]]; } } } - for (int k=(listSize-1); k>0; k--) { + for (int k = (listSize - 1); k > 0; k--) { for (int i = 0; i < polarParams->crcParityBits; i++) { - crcChecksum[i][listIndex[(2*listSize-1)-k]] = crcChecksum[i][listIndex[k]]; + crcChecksum[i][listIndex[(2 * listSize - 1) - k]] = crcChecksum[i][listIndex[k]]; } } for (int k = (listSize - 1); k > 0; k--) crcState[listIndex[(2 * listSize - 1) - k]] = crcState[listIndex[k]]; - //Copy the best "listSize" number of entries to the first indices. + // Copy the best "listSize" number of entries to the first indices. for (int k = 0; k < listSize; k++) { if (k > listIndex[k]) { - copyIndex = listIndex[(2*listSize-1)-k]; - } else { //Use the backup. + copyIndex = listIndex[(2 * listSize - 1) - k]; + } else { // Use the backup. copyIndex = listIndex[k]; } @@ -505,40 +523,40 @@ int8_t polar_decoder_dci(double *input, for (int k = 0; k < listSize; k++) { if (k > listIndex[k]) { - copyIndex = listIndex[(2*listSize-1)-k]; - } else { //Use the backup. + copyIndex = listIndex[(2 * listSize - 1) - k]; + } else { // Use the backup. copyIndex = listIndex[k]; } for (int i = 0; i < polarParams->crcParityBits; i++) { - crcChecksum[i][k]=crcChecksum[i][copyIndex]; + crcChecksum[i][k] = crcChecksum[i][copyIndex]; } } for (int k = 0; k < listSize; k++) { if (k > listIndex[k]) { - copyIndex = listIndex[(2*listSize-1)-k]; - } else { //Use the backup. + copyIndex = listIndex[(2 * listSize - 1) - k]; + } else { // Use the backup. copyIndex = listIndex[k]; } - crcState[k]=crcState[copyIndex]; + crcState[k] = crcState[copyIndex]; } currentListSize = listSize; } - for (int i=0; icrcParityBits; i++) { - if (last1ind[i]==nonFrozenBit) { - checkCrcBits=i; + for (int i = 0; i < polarParams->crcParityBits; i++) { + if (last1ind[i] == nonFrozenBit) { + checkCrcBits = i; break; } } - if ( checkCrcBits > (-1) ) { + if (checkCrcBits > (-1)) { for (uint i = 0; i < currentListSize; i++) { - if (crcChecksum[checkCrcBits][i]!=extended_crc_scrambling_pattern[checkCrcBits]) { - crcState[i]=0; //0=False, 1=True + if (crcChecksum[checkCrcBits][i] != extended_crc_scrambling_pattern[checkCrcBits]) { + crcState[i] = 0; // 0=False, 1=True } } } @@ -546,15 +564,15 @@ int8_t polar_decoder_dci(double *input, for (uint i = 0; i < currentListSize; i++) decoderIterationCheck += crcState[i]; - if (decoderIterationCheck==0) { - //perror("[SCL polar decoder] All list entries have failed the CRC checks."); + if (decoderIterationCheck == 0) { + // perror("[SCL polar decoder] All list entries have failed the CRC checks."); polarReturn(polarParams); return -1; } nonFrozenBit++; - decoderIterationCheck=0; - checkCrcBits=-1; + decoderIterationCheck = 0; + checkCrcBits = -1; } } @@ -565,19 +583,19 @@ int8_t polar_decoder_dci(double *input, uint8_t nr_polar_A[polarParams->payloadBits]; for (uint i = 0; i < fmin(listSize, (pow(2, polarParams->crcCorrectionBits))); i++) { - if ( crcState[listIndex[i]] == 1 ) { + if (crcState[listIndex[i]] == 1) { uint8_t nr_polar_U[polarParams->N]; for (int j = 0; j < polarParams->N; j++) nr_polar_U[j] = bit[j][0][listIndex[i]]; - //Extract the information bits (û to ĉ) + // Extract the information bits (û to ĉ) uint8_t nr_polar_CPrime[polarParams->N]; nr_polar_info_bit_extraction(nr_polar_U, nr_polar_CPrime, polarParams->information_bit_pattern, polarParams->N); - //Deinterleaving (ĉ to b) + // Deinterleaving (ĉ to b) uint8_t nr_polar_B[polarParams->K]; nr_polar_deinterleaver(nr_polar_CPrime, nr_polar_B, polarParams->interleaving_pattern, polarParams->K); - //Remove the CRC (â) + // Remove the CRC (â) memcpy(nr_polar_A, nr_polar_B, polarParams->payloadBits); break; } @@ -592,32 +610,60 @@ int8_t polar_decoder_dci(double *input, return 0; } -void init_polar_deinterleaver_table(t_nrPolar_params *polarParams) { - AssertFatal(polarParams->K > 17, "K = %d < 18, is not allowed\n",polarParams->K); - AssertFatal(polarParams->K < 129, "K = %d > 128, is not supported yet\n",polarParams->K); - int bit_i,ip,ipmod64; - int numbytes = polarParams->K>>3; - int residue = polarParams->K & 7; +static inline void nr_polar_rate_matching_int16(int16_t *input, + int16_t *output, + const uint16_t *rmp, + const uint16_t K, + const uint16_t N, + const uint16_t E, + const uint8_t i_bil) +{ + if (E >= N) { // repetition + memset(output, 0, N * sizeof(*output)); + for (int i = 0; i <= E - 1; i++) + output[rmp[i]] += input[i]; + } else { + if ((K / (double)E) <= (7.0 / 16)) + memset(output, 0, N * sizeof(*output)); // puncturing + else { // shortening + for (int i = 0; i <= N - 1; i++) + output[i] = 32767; // instead of INFINITY, to prevent [-Woverflow] + } - if (residue > 0) - numbytes++; + for (int i = 0; i <= E - 1; i++) + output[rmp[i]] = input[i]; + } +} - for (int byte=0; byteK >> 3) ? 8 : residue; +static inline void nr_polar_info_extraction_from_u(uint64_t *Cprime, + const uint8_t *u, + const uint8_t *information_bit_pattern, + const uint8_t *parity_check_bit_pattern, + const uint16_t *interleaving_pattern, + uint16_t N, + uint8_t n_pc, + int K) +{ + int k = 0; - for (int i=0; iK - 1 - polarParams->interleaving_pattern[(8 * byte) + i]; - ipmod64 = ip&63; - AssertFatal(ip<128,"ip = %d\n",ip); - - for (int val=0; val<256; val++) { - bit_i=(val>>i)&1; - - if (ip < 64) - polarParams->B_tab0[byte][val] |= ((uint64_t)bit_i) << ipmod64; - else - polarParams->B_tab1[byte][val] |= ((uint64_t)bit_i) << ipmod64; + if (n_pc > 0) { + for (int n = 0; n < N; n++) { + if (information_bit_pattern[n] == 1 && parity_check_bit_pattern[n] == 0) { + int targetBit = K - 1 - interleaving_pattern[k]; + int k1 = targetBit >> 6; + int k2 = targetBit & 63; + Cprime[k1] |= (uint64_t)u[n] << k2; + k++; + } + } + } else { + for (int n = 0; n < N; n++) { + if (information_bit_pattern[n] == 1) { + int targetBit = K - 1 - interleaving_pattern[k]; + int k1 = targetBit >> 6; + int k2 = targetBit & 63; + Cprime[k1] |= (uint64_t)u[n] << k2; + k++; } } } @@ -630,12 +676,12 @@ uint32_t polar_decoder_int16(int16_t *input, uint16_t messageLength, uint8_t aggregation_level) { - t_nrPolar_params *polarParams=nr_polar_params(messageType, messageLength, aggregation_level, true); - + t_nrPolar_params *polarParams = nr_polar_params(messageType, messageLength, aggregation_level); + const uint N = polarParams->N; #ifdef POLAR_CODING_DEBUG printf("\nRX\n"); printf("rm:"); - for (int i = 0; i < polarParams->N; i++) { + for (int i = 0; i < N; i++) { if (i % 4 == 0) { printf(" "); } @@ -644,25 +690,28 @@ uint32_t polar_decoder_int16(int16_t *input, printf("\n"); #endif - int16_t d_tilde[polarParams->N]; - nr_polar_rate_matching_int16(input, + int16_t d_tilde[N]; + const uint E = polarParams->encoderLength; + int16_t inbis[E]; + int16_t *input_deinterleaved; + if (polarParams->i_bil) { + for (int i = 0; i < E; i++) + inbis[i] = input[polarParams->i_bil_pattern[i]]; + input_deinterleaved = inbis; + } else { + input_deinterleaved = input; + } + + nr_polar_rate_matching_int16(input_deinterleaved, d_tilde, polarParams->rate_matching_pattern, polarParams->K, - polarParams->N, - polarParams->encoderLength, + N, + E, polarParams->i_bil); - - for (int i=0; iN; i++) { - if (d_tilde[i] < -128) - d_tilde[i] = -128; - else if (d_tilde[i] > 127) - d_tilde[i] = 128; - } - #ifdef POLAR_CODING_DEBUG printf("d: "); - for (int i = 0; i < polarParams->N; i++) { + for (int i = 0; i < N; i++) { if (i % 4 == 0) { printf(" "); } @@ -670,15 +719,13 @@ uint32_t polar_decoder_int16(int16_t *input, } printf("\n"); #endif - - memcpy(polarParams->tree.root->alpha, d_tilde, sizeof(d_tilde)); - uint8_t nr_polar_U[polarParams->N]; + uint8_t nr_polar_U[N]; memset(nr_polar_U, 0, sizeof(nr_polar_U)); - generic_polar_decoder(polarParams, polarParams->tree.root, nr_polar_U); - + memcpy(treeAlpha(polarParams->decoder.root), d_tilde, sizeof(d_tilde)); + generic_polar_decoder(polarParams, polarParams->decoder.root, nr_polar_U); #ifdef POLAR_CODING_DEBUG printf("u: "); - for (int i = 0; i < polarParams->N; i++) { + for (int i = 0; i < N; i++) { if (i % 4 == 0) { printf(" "); } @@ -688,13 +735,15 @@ uint32_t polar_decoder_int16(int16_t *input, #endif // Extract the information bits (û to ĉ) - uint64_t Cprime[4]= {0}; - nr_polar_info_extraction_from_u(Cprime, + uint64_t B[4] = {0}; + nr_polar_info_extraction_from_u(B, nr_polar_U, polarParams->information_bit_pattern, polarParams->parity_check_bit_pattern, - polarParams->N, - polarParams->n_pc); + polarParams->interleaving_pattern, + N, + polarParams->n_pc, + polarParams->K); #ifdef POLAR_CODING_DEBUG printf("c: "); @@ -704,95 +753,66 @@ uint32_t polar_decoder_int16(int16_t *input, } int n1 = n >> 6; int n2 = n - (n1 << 6); - printf("%lu", (Cprime[n1] >> n2) & 1); + printf("%lu", (B[n1] >> n2) & 1); } printf("\n"); #endif - //Deinterleaving (ĉ to b) - uint8_t *Cprimebyte = (uint8_t *)Cprime; - uint64_t B[4] = {0}; - - if (polarParams->K<65) { - B[0] = polarParams->B_tab0[0][Cprimebyte[0]] | polarParams->B_tab0[1][Cprimebyte[1]] | polarParams->B_tab0[2][Cprimebyte[2]] - | polarParams->B_tab0[3][Cprimebyte[3]] | polarParams->B_tab0[4][Cprimebyte[4]] | polarParams->B_tab0[5][Cprimebyte[5]] - | polarParams->B_tab0[6][Cprimebyte[6]] | polarParams->B_tab0[7][Cprimebyte[7]]; - } else if (polarParams->K<129) { - int len = polarParams->K/8; - - if ((polarParams->K & 7) > 0) - len++; - - for (int k=0; kB_tab0[k][Cprimebyte[k]]; - B[1] |= polarParams->B_tab1[k][Cprimebyte[k]]; - } - } - -#ifdef POLAR_CODING_DEBUG - int B_array = (polarParams->K + 63) >> 6; - int n_start = (B_array << 6) - polarParams->K; - printf("b: "); - for (int n = 0; n < polarParams->K; n++) { - if (n % 4 == 0) { - printf(" "); - } - int n1 = (n + n_start) >> 6; - int n2 = (n + n_start) - (n1 << 6); - printf("%lu", (B[B_array - 1 - n1] >> (63 - n2)) & 1); - } - printf("\n"); -#endif - - int len=polarParams->payloadBits; - //int len_mod64=len&63; + int len = polarParams->payloadBits; + // int len_mod64=len&63; int crclen = polarParams->crcParityBits; - uint64_t rxcrc=B[0]&((1<>crclen); - uint8_t A32_flip[4+offset]; + if (len <= 32) { + Ar = (uint32_t)(B[0] >> crclen); + uint8_t A32_flip[4 + offset]; if (ones_flag) { A32_flip[0] = 0xff; A32_flip[1] = 0xff; A32_flip[2] = 0xff; } - uint32_t Aprime= (uint32_t)(Ar<<(32-len)); - A32_flip[0+offset]=((uint8_t *)&Aprime)[3]; - A32_flip[1+offset]=((uint8_t *)&Aprime)[2]; - A32_flip[2+offset]=((uint8_t *)&Aprime)[1]; - A32_flip[3+offset]=((uint8_t *)&Aprime)[0]; - if (crclen == 24) crc = (uint64_t)((crc24c(A32_flip,8*offset+len)>>8)&0xffffff); - else if (crclen == 11) crc = (uint64_t)((crc11(A32_flip,8*offset+len)>>21)&0x7ff); - else if (crclen == 6) crc = (uint64_t)((crc6(A32_flip,8*offset+len)>>26)&0x3f); - } else if (len<=64) { + uint32_t Aprime = (uint32_t)(Ar << (32 - len)); + A32_flip[0 + offset] = ((uint8_t *)&Aprime)[3]; + A32_flip[1 + offset] = ((uint8_t *)&Aprime)[2]; + A32_flip[2 + offset] = ((uint8_t *)&Aprime)[1]; + A32_flip[3 + offset] = ((uint8_t *)&Aprime)[0]; + if (crclen == 24) + crc = (uint64_t)((crc24c(A32_flip, 8 * offset + len) >> 8) & 0xffffff); + else if (crclen == 11) + crc = (uint64_t)((crc11(A32_flip, 8 * offset + len) >> 21) & 0x7ff); + else if (crclen == 6) + crc = (uint64_t)((crc6(A32_flip, 8 * offset + len) >> 26) & 0x3f); + } else if (len <= 64) { Ar = (B[0] >> crclen) | (B[1] << (64 - crclen)); - uint8_t A64_flip[8+offset]; + uint8_t A64_flip[8 + offset]; if (ones_flag) { A64_flip[0] = 0xff; A64_flip[1] = 0xff; A64_flip[2] = 0xff; } - uint64_t Aprime= (uint64_t)(Ar<<(64-len)); - A64_flip[0+offset]=((uint8_t *)&Aprime)[7]; - A64_flip[1+offset]=((uint8_t *)&Aprime)[6]; - A64_flip[2+offset]=((uint8_t *)&Aprime)[5]; - A64_flip[3+offset]=((uint8_t *)&Aprime)[4]; - A64_flip[4+offset]=((uint8_t *)&Aprime)[3]; - A64_flip[5+offset]=((uint8_t *)&Aprime)[2]; - A64_flip[6+offset]=((uint8_t *)&Aprime)[1]; - A64_flip[7+offset]=((uint8_t *)&Aprime)[0]; - if (crclen==24) crc = (uint64_t)(crc24c(A64_flip,8*offset+len)>>8)&0xffffff; - else if (crclen==11) crc = (uint64_t)(crc11(A64_flip,8*offset+len)>>21)&0x7ff; - else if (crclen==6) crc = (uint64_t)(crc6(A64_flip,8*offset+len)>>26)&0x3f; + uint64_t Aprime = (uint64_t)(Ar << (64 - len)); + A64_flip[0 + offset] = ((uint8_t *)&Aprime)[7]; + A64_flip[1 + offset] = ((uint8_t *)&Aprime)[6]; + A64_flip[2 + offset] = ((uint8_t *)&Aprime)[5]; + A64_flip[3 + offset] = ((uint8_t *)&Aprime)[4]; + A64_flip[4 + offset] = ((uint8_t *)&Aprime)[3]; + A64_flip[5 + offset] = ((uint8_t *)&Aprime)[2]; + A64_flip[6 + offset] = ((uint8_t *)&Aprime)[1]; + A64_flip[7 + offset] = ((uint8_t *)&Aprime)[0]; + if (crclen == 24) + crc = (uint64_t)(crc24c(A64_flip, 8 * offset + len) >> 8) & 0xffffff; + else if (crclen == 11) + crc = (uint64_t)(crc11(A64_flip, 8 * offset + len) >> 21) & 0x7ff; + else if (crclen == 6) + crc = (uint64_t)(crc6(A64_flip, 8 * offset + len) >> 26) & 0x3f; } #ifdef POLAR_CODING_DEBUG @@ -819,7 +839,7 @@ uint32_t polar_decoder_int16(int16_t *input, Cprime[0], crc, rxcrc, - crc^rxcrc, + crc ^ rxcrc, polarParams->payloadBits); #endif diff --git a/openair1/PHY/CODING/nrPolar_tools/nr_polar_decoding_tools.c b/openair1/PHY/CODING/nrPolar_tools/nr_polar_decoding_tools.c index 8180f5ebeb..cc0f31f1de 100644 --- a/openair1/PHY/CODING/nrPolar_tools/nr_polar_decoding_tools.c +++ b/openair1/PHY/CODING/nrPolar_tools/nr_polar_decoding_tools.c @@ -28,22 +28,22 @@ * \email turker.yilmaz@eurecom.fr * \note * \warning -*/ + */ #include "PHY/CODING/nrPolar_tools/nr_polar_defs.h" #include "PHY/sse_intrin.h" #include "PHY/impl_defs_top.h" -//#define DEBUG_NEW_IMPL 1 +// #define DEBUG_NEW_IMPL 1 static inline void updateBit(uint8_t listSize, - uint16_t row, - uint16_t col, - uint16_t xlen, - uint8_t ylen, - int zlen, - uint8_t bit[xlen][ylen][zlen], - uint8_t bitU[xlen][ylen]) + uint16_t row, + uint16_t col, + uint16_t xlen, + uint8_t ylen, + int zlen, + uint8_t bit[xlen][ylen][zlen], + uint8_t bitU[xlen][ylen]) { const uint offset = (xlen / (pow(2, (ylen - col)))); @@ -64,18 +64,12 @@ static inline void updateBit(uint8_t listSize, bitU[row][col] = 1; } -static inline void computeLLR(uint16_t row, - uint16_t col, - uint8_t i, - uint16_t offset, - int xlen, - int ylen, - int zlen, - double llr[xlen][ylen][zlen]) +static inline void +computeLLR(uint16_t row, uint16_t col, uint8_t i, uint16_t offset, int xlen, int ylen, int zlen, double llr[xlen][ylen][zlen]) { double a = llr[row][col + 1][i]; double b = llr[row + offset][col + 1][i]; - llr[row][col][i] = log((exp(a + b) + 1) / (exp(a) + exp(b))); //eq. (8a) + llr[row][col][i] = log((exp(a + b) + 1) / (exp(a) + exp(b))); // eq. (8a) } void updateLLR(uint8_t listSize, @@ -113,14 +107,13 @@ void updateLLR(uint8_t listSize, } void updatePathMetric(double *pathMetric, - uint8_t listSize, - uint8_t bitValue, - uint16_t row, - int xlen, - int ylen, - int zlen, - double llr[xlen][ylen][zlen] - ) + uint8_t listSize, + uint8_t bitValue, + uint16_t row, + int xlen, + int ylen, + int zlen, + double llr[xlen][ylen][zlen]) { const int multiplier = (2 * bitValue) - 1; for (uint i = 0; i < listSize; i++) @@ -128,12 +121,12 @@ void updatePathMetric(double *pathMetric, } void updatePathMetric2(double *pathMetric, - uint8_t listSize, - uint16_t row, - int xlen, - int ylen, - int zlen, - double llr[xlen][ylen][zlen]) + uint8_t listSize, + uint16_t row, + int xlen, + int ylen, + int zlen, + double llr[xlen][ylen][zlen]) { double tempPM[listSize]; memcpy(tempPM, pathMetric, (sizeof(double) * listSize)); @@ -149,271 +142,308 @@ void updatePathMetric2(double *pathMetric, pathMetric[i] = tempPM[(i - listSize)] + log(1 + exp(multiplier * llr[row][0][(i - listSize)])); // eq. (11b) } -decoder_node_t *new_decoder_node(int first_leaf_index, int level) { - - decoder_node_t *node=(decoder_node_t *)malloc(sizeof(decoder_node_t)); - - node->first_leaf_index=first_leaf_index; - node->level=level; - node->Nv = 1<leaf = 0; - node->left=(decoder_node_t *)NULL; - node->right=(decoder_node_t *)NULL; - node->all_frozen=0; - node->alpha = (int16_t*)malloc16(node->Nv*sizeof(int16_t)); - node->beta = (int16_t*)malloc16(node->Nv*sizeof(int16_t)); - memset((void*)node->beta,-1,node->Nv*sizeof(int16_t)); - - return(node); -} - -decoder_node_t *add_nodes(int level, int first_leaf_index, t_nrPolar_params *polarParams) { - - int all_frozen_below = 1; - int Nv = 1<tree.num_nodes,Nv,level); -#endif - polarParams->tree.num_nodes++; - if (level==0) { -#ifdef DEBUG_NEW_IMPL - printf("leaf %d (%s)\n", first_leaf_index, polarParams->information_bit_pattern[first_leaf_index]==1 ? "information or crc" : "frozen"); -#endif - new_node->leaf=1; - new_node->all_frozen = polarParams->information_bit_pattern[first_leaf_index]==0 ? 1 : 0; - return new_node; // this is a leaf node - } - - for (int i=0;iinformation_bit_pattern[i+first_leaf_index]>0) { - all_frozen_below = 0; - break; - } - } - - if (all_frozen_below==0) - new_node->left = add_nodes(level - 1, first_leaf_index, polarParams); - else { -#ifdef DEBUG_NEW_IMPL - printf("aggregating frozen bits %d ... %d at level %d (%s)\n",first_leaf_index,first_leaf_index+Nv-1,level,((first_leaf_index/Nv)&1)==0?"left":"right"); -#endif - new_node->leaf=1; - new_node->all_frozen=1; - } - if (all_frozen_below==0) - new_node->right = add_nodes(level - 1, first_leaf_index + (Nv / 2), polarParams); - -#ifdef DEBUG_NEW_IMPL - printf("new_node (%d): first_leaf_index %d, left %p, right %p\n",Nv,first_leaf_index,new_node->left,new_node->right); -#endif - - return(new_node); -} - -void delete_nodes(decoder_node_t * n) { - if (n) { - if(n->left) - delete_nodes(n->left); - if(n->right) - delete_nodes(n->right); - free(n->alpha); - free(n->beta); - free(n); - } -} - -void delete_decoder_tree(t_nrPolar_params *polarParams) { - if (polarParams->tree.root) - delete_nodes(polarParams->tree.root); -} - -void build_decoder_tree(t_nrPolar_params *polarParams) +static inline decoder_node_t *new_decoder_node(simde__m256i **buffer, + const int level, + const int first_leaf_index, + const bool leaf, + const bool frozen) { - polarParams->tree.num_nodes=0; - polarParams->tree.root = add_nodes(polarParams->n,0,polarParams); -#ifdef DEBUG_NEW_IMPL - printf("root : left %p, right %p\n",polarParams->tree.root->left,polarParams->tree.root->right); -#endif + int leaf_sz = 1 << level; + // we will use SIMD128 minimum + leaf_sz = (leaf_sz + 7) & ~7; + if (leaf_sz > 15) // we will use SIMD256 + leaf_sz = (leaf_sz + 15) & ~15; + const int tree_sz = (sizeof(decoder_node_t) + 31) & ~31; + uintptr_t tmp = (uintptr_t)*buffer; + tmp = (tmp + sizeof(**buffer) - 1) & ~(sizeof(**buffer) - 1); + decoder_node_t *node = (decoder_node_t *)tmp; + *buffer = (simde__m256i *)(tmp + tree_sz + leaf_sz * sizeof(int16_t) + leaf_sz); + *node = (decoder_node_t){.first_leaf_index = first_leaf_index, + .level = level, + .leaf = leaf, + .all_frozen = frozen, + .alpha = tree_sz, + .beta = tree_sz + leaf_sz * sizeof(int16_t), + .betaInit = false}; + return (node); } -static void applyFtoleft(const t_nrPolar_params *pp, decoder_node_t *node, uint8_t *output) +static inline decoder_node_t *add_nodes(decoder_tree_t *tree, + int level, + int first_leaf_index, + const uint8_t *information_bit_pattern, + simde__m256i **buffer) { - int16_t *alpha_v=node->alpha; - int16_t *alpha_l=node->left->alpha; - int16_t *betal = node->left->beta; - int16_t a,b,absa,absb,maska,maskb,minabs; + if (level == 0) { +#ifdef DEBUG_NEW_IMPL + printf("leaf %d (%s)\n", first_leaf_index, information_bit_pattern[first_leaf_index] == 1 ? "information or crc" : "frozen"); +#endif + return new_decoder_node(buffer, level, first_leaf_index, true, information_bit_pattern[first_leaf_index] == 0); + } + + int Nv = 1 << level; + const uint8_t *ptr = information_bit_pattern + first_leaf_index; + const uint8_t *end = ptr + Nv; + bool all_frozen_below = true; + while (ptr < end && all_frozen_below) { + all_frozen_below = *ptr++ <= 0; + } + + if (all_frozen_below) { + return new_decoder_node(buffer, level, first_leaf_index, true, true); + } + + decoder_node_t *new_node = new_decoder_node(buffer, level, first_leaf_index, false, false); + new_node->left = add_nodes(tree, level - 1, first_leaf_index, information_bit_pattern, buffer); + new_node->right = add_nodes(tree, level - 1, first_leaf_index + (Nv / 2), information_bit_pattern, buffer); + return (new_node); +} + +void build_decoder_tree(t_nrPolar_params *pp) +{ + uintptr_t tmp = (uintptr_t)pp->decoder.buffer; + tmp = (tmp + sizeof(*pp->decoder.buffer) - 1) & ~(sizeof(*pp->decoder.buffer) - 1); + simde__m256i *buffer = (simde__m256i *)tmp; + pp->decoder.root = add_nodes(&pp->decoder, pp->n, 0, pp->information_bit_pattern, &buffer); + AssertFatal(buffer < pp->decoder.buffer + sizeofArray(pp->decoder.buffer), + "Arbitrary size too small (also check arbitrary max size of the entire polar decoder) %ld instead of max %ld\n", + buffer - pp->decoder.buffer, + sizeofArray(pp->decoder.buffer)); +} + +static inline void applyFtoleft(const t_nrPolar_params *pp, decoder_node_t *node, uint8_t *output) +{ + int16_t *alpha_v = treeAlpha(node); + int16_t *alpha_l = treeAlpha(node->left); + int8_t *betal = treeBeta(node->left); #ifdef DEBUG_NEW_IMPL - printf("applyFtoleft %d, Nv %d (level %d,node->left (leaf %d, AF %d))\n",node->first_leaf_index,node->Nv,node->level,node->left->leaf,node->left->all_frozen); + printf("applyFtoleft %d, Nv %d (level %d,node->left (leaf %d, AF %d))\n", + node->first_leaf_index, + node->Nv, + node->level, + node->left->leaf, + node->left->all_frozen); for (int i = 0; i < node->Nv; i++) printf("i%d (frozen %d): alpha_v[i] = %d\n", i, 1 - pp->information_bit_pattern[node->first_leaf_index + i], alpha_v[i]); #endif - + assert(node->level); + const int sz = 1 << (node->level - 1); if (node->left->all_frozen == 0) { - int avx2mod = (node->Nv/2)&15; + int avx2mod = sz & 15; if (avx2mod == 0) { - simde__m256i a256,b256,absa256,absb256,minabs256; - int avx2len = node->Nv/2/16; + int avx2len = sz / 16; // printf("avx2len %d\n",avx2len); - for (int i=0;i> 15; + int16_t maskb = b >> 15; + int16_t absa = (a + maska) ^ maska; + int16_t absb = (b + maskb) ^ maskb; + int16_t minabs = absa < absb ? absa : absb; + alpha_l[i] = (maska ^ maskb) == 0 ? minabs : -minabs; + // printf("alphal[%d] %d (%d,%d)\n",i,alpha_l[i],a,b); } } - else if (avx2mod == 8) { - simde__m128i a128,b128,absa128,absb128,minabs128; - a128 =*((simde__m128i*)alpha_v); - b128 =((simde__m128i*)alpha_v)[1]; - absa128 =simde_mm_abs_epi16(a128); - absb128 =simde_mm_abs_epi16(b128); - minabs128 =simde_mm_min_epi16(absa128,absb128); - *((simde__m128i*)alpha_l) =simde_mm_sign_epi16(minabs128,simde_mm_sign_epi16(a128,b128)); - } - else if (avx2mod == 4) { - simde__m64 a64,b64,absa64,absb64,minabs64; - a64 =*((simde__m64*)alpha_v); - b64 =((simde__m64*)alpha_v)[1]; - absa64 =simde_mm_abs_pi16(a64); - absb64 =simde_mm_abs_pi16(b64); - minabs64 =simde_mm_min_pi16(absa64,absb64); - *((simde__m64*)alpha_l) =simde_mm_sign_pi16(minabs64,simde_mm_sign_pi16(a64,b64)); - } - else - { // equivalent scalar code to above, activated only on non x86/ARM architectures - for (int i=0;iNv/2;i++) { - a=alpha_v[i]; - b=alpha_v[i+(node->Nv/2)]; - maska=a>>15; - maskb=b>>15; - absa=(a+maska)^maska; - absb=(b+maskb)^maskb; - minabs = absaNv == 2) { // apply hard decision on left node - betal[0] = (alpha_l[0]>0) ? -1 : 1; + if (sz == 1) { // apply hard decision on left node + const int tmp = alpha_l[0] <= 0; + betal[0] = tmp * 2 - 1; + node->left->betaInit = true; #ifdef DEBUG_NEW_IMPL - printf("betal[0] %d (%p)\n",betal[0],&betal[0]); + printf("betal[0] %d (%p)\n", betal[0], &betal[0]); #endif - output[node->first_leaf_index] = (1 + betal[0]) >> 1; + output[node->first_leaf_index] = tmp; #ifdef DEBUG_NEW_IMPL - printf("Setting bit %d to %d (LLR %d)\n",node->first_leaf_index,(betal[0]+1)>>1,alpha_l[0]); + printf("Setting bit %d to %d (LLR %d)\n", node->first_leaf_index, (betal[0] + 1) >> 1, alpha_l[0]); #endif } } } -static void applyGtoright(const t_nrPolar_params *pp, decoder_node_t *node, uint8_t *output) +static inline void applyGtoright(const t_nrPolar_params *pp, decoder_node_t *node, uint8_t *output) { - int16_t *alpha_v=node->alpha; - int16_t *alpha_r=node->right->alpha; - int16_t *betal = node->left->beta; - int16_t *betar = node->right->beta; + int16_t *alpha_v = treeAlpha(node); + int16_t *alpha_r = treeAlpha(node->right); + int8_t *betal = treeBeta(node->left); + int8_t *betar = treeBeta(node->right); #ifdef DEBUG_NEW_IMPL - printf("applyGtoright %d, Nv %d (level %d), (leaf %d, AF %d)\n",node->first_leaf_index,node->Nv,node->level,node->right->leaf,node->right->all_frozen); + printf("applyGtoright %d, Nv %d (level %d), (leaf %d, AF %d)\n", + node->first_leaf_index, + node->Nv, + node->level, + node->right->leaf, + node->right->all_frozen); #endif - - if (node->right->all_frozen == 0) { - int avx2mod = (node->Nv/2)&15; - if (avx2mod == 0) { - int avx2len = node->Nv/2/16; - - for (int i=0;ilevel); + const int sz = 1 << (node->level - 1); + if (node->right->all_frozen == 0) { + if (!node->left->betaInit) { + for (int i = 0; i < sz; i++) { + int temp_alpha_r = alpha_v[i + sz] + alpha_v[i]; + if (temp_alpha_r > SHRT_MAX) { + alpha_r[i] = SHRT_MAX; + } else if (temp_alpha_r < -SHRT_MAX) { + alpha_r[i] = -SHRT_MAX; + } else { + alpha_r[i] = temp_alpha_r; + } + } + } else { + int avx2mod = sz & 15; + if (avx2mod == 0) { + int avx2len = sz / 16; + + for (int i = 0; i < avx2len; i++) { + simde__m256i tmp = + simde_mm256_sign_epi16(((simde__m256i *)alpha_v)[i], simde_mm256_cvtepi8_epi16(((simde__m128i *)betal)[i])); + ((simde__m256i *)alpha_r)[i] = simde_mm256_subs_epi16(((simde__m256i *)alpha_v)[i + avx2len], tmp); + } + } else if (avx2mod == 8) { + simde__m128i tmp = simde_mm_sign_epi16(((simde__m128i *)alpha_v)[0], simde_mm_cvtepi8_epi16(((simde__m128i *)betal)[0])); + ((simde__m128i *)alpha_r)[0] = simde_mm_subs_epi16(((simde__m128i *)alpha_v)[1], tmp); + } else { + simde__m128i tmp = simde_mm_sign_epi16(*(simde__m128i *)alpha_v, simde_mm_cvtepi8_epi16(*(simde__m128i *)betal)); + simde__m128i tmp2 = simde_mm_loadu_si128((simde__m128i *)(alpha_v + sz)); + simde__m128i res = simde_mm_subs_epi16(tmp2, tmp); + simde_mm_storeu_si128(alpha_r, res); } } - else if (avx2mod == 8) { - ((simde__m128i *)alpha_r)[0] = simde_mm_subs_epi16(((simde__m128i *)alpha_v)[1],simde_mm_sign_epi16(((simde__m128i *)alpha_v)[0],((simde__m128i *)betal)[0])); - } - else if (avx2mod == 4) { - ((simde__m64 *)alpha_r)[0] = simde_mm_subs_pi16(((simde__m64 *)alpha_v)[1],simde_mm_sign_pi16(((simde__m64 *)alpha_v)[0],((simde__m64 *)betal)[0])); - } - else - { - int temp_alpha_r; - for (int i = 0; i < node->Nv / 2; i++) { - temp_alpha_r = alpha_v[i + (node->Nv / 2)] - (betal[i] * alpha_v[i]); - if (temp_alpha_r > SHRT_MAX) { - alpha_r[i] = SHRT_MAX; - } else if (temp_alpha_r < -SHRT_MAX) { - alpha_r[i] = -SHRT_MAX; - } else { - alpha_r[i] = temp_alpha_r; - } - } - } - if (node->Nv == 2) { // apply hard decision on right node - betar[0] = (alpha_r[0]>0) ? -1 : 1; - output[node->first_leaf_index + 1] = (1 + betar[0]) >> 1; + if (sz == 1) { // apply hard decision on right node + int tmp = alpha_r[0] <= 0; + betar[0] = tmp * 2 - 1; + node->right->betaInit = true; + output[node->first_leaf_index + 1] = tmp; + #ifdef DEBUG_NEW_IMPL - printf("Setting bit %d to %d (LLR %d)\n",node->first_leaf_index+1,(betar[0]+1)>>1,alpha_r[0]); + printf("Setting bit %d to %d (LLR %d)\n", node->first_leaf_index + 1, (betar[0] + 1) >> 1, alpha_r[0]); #endif - } + } } } -static const int16_t all1[16] = {1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1}; +static const int64_t all11[4] = {-1, -1, -1, -1}; -void computeBeta(const t_nrPolar_params *pp,decoder_node_t *node) { - - int16_t *betav = node->beta; - int16_t *betal = node->left->beta; - int16_t *betar = node->right->beta; +static inline void computeBeta(decoder_node_t *node) +{ + int8_t *betav = treeBeta(node); + int8_t *betal = treeBeta(node->left); + int8_t *betar = treeBeta(node->right); #ifdef DEBUG_NEW_IMPL - printf("Computing beta @ level %d first_leaf_index %d (all_frozen %d)\n",node->level,node->first_leaf_index,node->left->all_frozen); + printf("Computing beta @ level %d first_leaf_index %d (all_frozen %d)\n", + node->level, + node->first_leaf_index, + node->left->all_frozen); #endif - if (node->left->all_frozen==0) { // if left node is not aggregation of frozen bits - int avx2mod = (node->Nv/2)&15; - register simde__m256i allones=*((simde__m256i*)all1); + assert(node->level); + const int sz = 1 << (node->level - 1); + if (node->left->all_frozen == 0) { // if left node is not aggregation of frozen bits + if (!node->left->betaInit) { + memset(betal, -1, sz); + node->left->betaInit = true; + } + if (!node->right->betaInit) { + memset(betar, -1, sz); + node->right->betaInit = true; + } + int avx2mod = sz & 31; if (avx2mod == 0) { - int avx2len = node->Nv/2/16; - for (int i=0;iNv/2;i++) { - betav[i] = (betal[i] != betar[i]) ? 1 : -1; - } - } + } else { + assert(node->right->betaInit); + memcpy(betav, betar, sz * sizeof(*betav)); + node->betaInit = true; } - else memcpy((void*)&betav[0],betar,(node->Nv/2)*sizeof(int16_t)); - memcpy((void*)&betav[node->Nv/2],betar,(node->Nv/2)*sizeof(int16_t)); + assert(node->right->betaInit); + memcpy(&betav[sz], betar, sz * sizeof(*betav)); + node->betaInit = true; } -void generic_polar_decoder(const t_nrPolar_params *pp, decoder_node_t *node, uint8_t *nr_polar_U) +void generic_polar_decoder_recursive(t_nrPolar_params *pp, decoder_node_t *node, uint8_t *nr_polar_U) { // Apply F to left applyFtoleft(pp, node, nr_polar_U); + int iter = pp->tree_linearization.iter++; + pp->tree_linearization.op_list[iter].op_code = POLAR_OP_CODE_LEFT; + pp->tree_linearization.op_list[iter].node = node; + // if left is not a leaf recurse down to the left - if (node->left->leaf==0) - generic_polar_decoder(pp, node->left, nr_polar_U); + if (node->left->leaf == 0) + generic_polar_decoder_recursive(pp, node->left, nr_polar_U); applyGtoright(pp, node, nr_polar_U); - if (node->right->leaf == 0) - generic_polar_decoder(pp, node->right, nr_polar_U); + iter = pp->tree_linearization.iter++; + pp->tree_linearization.op_list[iter].op_code = POLAR_OP_CODE_RIGHT; + pp->tree_linearization.op_list[iter].node = node; - computeBeta(pp, node); + if (node->right->leaf == 0) + generic_polar_decoder_recursive(pp, node->right, nr_polar_U); + + computeBeta(node); + + iter = pp->tree_linearization.iter++; + pp->tree_linearization.op_list[iter].op_code = POLAR_OP_CODE_BETA; + pp->tree_linearization.op_list[iter].node = node; +} + +void generic_polar_decoder(t_nrPolar_params *pp, decoder_node_t *node, uint8_t *nr_polar_U) +{ + if (pp->tree_linearization.is_initialized == false) { + pp->tree_linearization.iter = 0; + generic_polar_decoder_recursive(pp, node, nr_polar_U); + pp->tree_linearization.is_initialized = true; + AssertFatal(pp->tree_linearization.iter < sizeofArray(pp->tree_linearization.op_list), + "Arbitrary size %lu is too small, number of operations is %d", + sizeofArray(pp->tree_linearization.op_list), + pp->tree_linearization.iter); + } else { + for (int i = 0; i < pp->tree_linearization.iter; i++) { + decoder_node_t *n = pp->tree_linearization.op_list[i].node; + switch (pp->tree_linearization.op_list[i].op_code) { + case POLAR_OP_CODE_LEFT: + applyFtoleft(pp, n, nr_polar_U); + break; + case POLAR_OP_CODE_RIGHT: + applyGtoright(pp, n, nr_polar_U); + break; + case POLAR_OP_CODE_BETA: + computeBeta(n); + } + } + } } diff --git a/openair1/PHY/CODING/nrPolar_tools/nr_polar_defs.h b/openair1/PHY/CODING/nrPolar_tools/nr_polar_defs.h index 84b3241e68..5210dbec6d 100644 --- a/openair1/PHY/CODING/nrPolar_tools/nr_polar_defs.h +++ b/openair1/PHY/CODING/nrPolar_tools/nr_polar_defs.h @@ -28,7 +28,7 @@ * \email raymond.knopp@eurecom.fr, turker.yilmaz@eurecom.fr * \note * \warning -*/ + */ #ifndef __NR_POLAR_DEFS__H__ #define __NR_POLAR_DEFS__H__ @@ -43,42 +43,47 @@ #include "PHY/CODING/nrPolar_tools/nr_polar_uci_defs.h" #include "PHY/CODING/nrPolar_tools/nr_polar_pbch_defs.h" #include "PHY/CODING/coding_defs.h" -//#include "SIMULATION/TOOLS/sim.h" +// #include "SIMULATION/TOOLS/sim.h" -#define NR_POLAR_DECODER_LISTSIZE 8 //uint8_t +#define NR_POLAR_DECODER_LISTSIZE 8 // uint8_t -#define NR_POLAR_AGGREGATION_LEVEL_1_PRIME 149 //uint16_t -#define NR_POLAR_AGGREGATION_LEVEL_2_PRIME 151 //uint16_t -#define NR_POLAR_AGGREGATION_LEVEL_4_PRIME 157 //uint16_t -#define NR_POLAR_AGGREGATION_LEVEL_8_PRIME 163 //uint16_t -#define NR_POLAR_AGGREGATION_LEVEL_16_PRIME 167 //uint16_t +#define NR_POLAR_AGGREGATION_LEVEL_1_PRIME 149 // uint16_t +#define NR_POLAR_AGGREGATION_LEVEL_2_PRIME 151 // uint16_t +#define NR_POLAR_AGGREGATION_LEVEL_4_PRIME 157 // uint16_t +#define NR_POLAR_AGGREGATION_LEVEL_8_PRIME 163 // uint16_t +#define NR_POLAR_AGGREGATION_LEVEL_16_PRIME 167 // uint16_t -static const uint8_t nr_polar_subblock_interleaver_pattern[32] = {0,1,2,4,3,5,6,7,8,16,9,17,10,18,11,19,12,20,13,21,14,22,15,23,24,25,26,28,27,29,30,31}; +static const uint8_t nr_polar_subblock_interleaver_pattern[32] = {0, 1, 2, 4, 3, 5, 6, 7, 8, 16, 9, 17, 10, 18, 11, 19, + 12, 20, 13, 21, 14, 22, 15, 23, 24, 25, 26, 28, 27, 29, 30, 31}; #define Nmax 1024 #define nmax 10 #define uint128_t __uint128_t +#define POLAR_OP_CODE_LEFT 0 +#define POLAR_OP_CODE_RIGHT 1 +#define POLAR_OP_CODE_BETA 2 + typedef struct decoder_node_t_s { struct decoder_node_t_s *left; struct decoder_node_t_s *right; - int level; - int leaf; - int Nv; - int first_leaf_index; - int all_frozen; - int16_t *alpha; - int16_t *beta; + uint64_t level: 16; + uint64_t leaf: 16; + uint64_t first_leaf_index: 16; + uint64_t all_frozen: 1; + uint64_t betaInit: 1; + uint32_t alpha; + uint32_t beta; } decoder_node_t; typedef struct decoder_tree_t_s { decoder_node_t *root; - int num_nodes; + simde__m256i buffer[1024]; // seems enough but to be refined } decoder_tree_t; typedef struct nrPolar_params { - //messageType: 0=PBCH, 1=DCI, -1=UCI + // messageType: 0=PBCH, 1=DCI, -1=UCI struct nrPolar_params *nextPtr __attribute__((aligned(16))); bool busy; @@ -100,6 +105,7 @@ typedef struct nrPolar_params { uint16_t *interleaving_pattern; uint16_t *rate_matching_pattern; + uint16_t *i_bil_pattern; const uint16_t *Q_0_Nminus1; int16_t *Q_I_N; int16_t *Q_F_N; @@ -110,20 +116,20 @@ typedef struct nrPolar_params { const uint8_t **G_N; int groupsize; int *rm_tab; - uint64_t cprime_tab0[32][256]; - uint64_t cprime_tab1[32][256]; - uint64_t B_tab0[32][256]; - uint64_t B_tab1[32][256]; - // lowercase: bits, Uppercase: Bits stored in bytes - // polar_encoder vectors - decoder_tree_t tree; + uint64_t cprime_tab0[16][256]; + uint64_t cprime_tab1[16][256]; + decoder_tree_t decoder; + struct { + int iter; + bool is_initialized; + struct { + int op_code; + decoder_node_t *node; + } op_list[600]; + } tree_linearization; } t_nrPolar_params; -void polar_encoder(uint32_t *input, - uint32_t *output, - int8_t messageType, - uint16_t messageLength, - uint8_t aggregation_level); +void polar_encoder(uint32_t *input, uint32_t *output, int8_t messageType, uint16_t messageLength, uint8_t aggregation_level); void polar_encoder_dci(uint32_t *in, uint32_t *out, @@ -162,23 +168,26 @@ int8_t polar_decoder_dci(double *input, uint16_t messageLength, uint8_t aggregation_level); -void generic_polar_decoder(const t_nrPolar_params *pp, decoder_node_t *node, uint8_t *nr_polar_U); +void generic_polar_decoder(t_nrPolar_params *pp, decoder_node_t *node, uint8_t *nr_polar_U); -void computeBeta(const t_nrPolar_params *pp, - decoder_node_t *node); +static inline int16_t *treeAlpha(decoder_node_t *node) +{ + return (int16_t *)((uint8_t *)node + node->alpha); +} + +static inline int8_t *treeBeta(decoder_node_t *node) +{ + return (int8_t *)node + node->beta; +} void build_decoder_tree(t_nrPolar_params *pp); void build_polar_tables(t_nrPolar_params *polarParams); -void init_polar_deinterleaver_table(t_nrPolar_params *polarParams); void nr_polar_print_polarParams(void); -t_nrPolar_params *nr_polar_params (int8_t messageType, - uint16_t messageLength, - uint8_t aggregation_level, - int decoder_flag); +t_nrPolar_params *nr_polar_params(int8_t messageType, uint16_t messageLength, uint8_t aggregation_level); -uint16_t nr_polar_aggregation_prime (uint8_t aggregation_level); +uint16_t nr_polar_aggregation_prime(uint8_t aggregation_level); const uint8_t **nr_polar_kronecker_power_matrices(uint8_t n); @@ -189,35 +198,13 @@ const uint16_t *nr_polar_sequence_pattern(uint8_t n); * @param K Number of bits to encode (=payloadBits+crcParityBits) * @param E * @param n_max */ -uint32_t nr_polar_output_length(uint16_t K, - uint16_t E, - uint8_t n_max); +uint32_t nr_polar_output_length(uint16_t K, uint16_t E, uint8_t n_max); -void nr_polar_rate_matching_pattern(uint16_t *rmp, - uint16_t *J, - const uint8_t *P_i_, - uint16_t K, - uint16_t N, - uint16_t E); +void nr_polar_rate_matching_pattern(uint16_t *rmp, uint16_t *J, const uint8_t *P_i_, uint16_t K, uint16_t N, uint16_t E); -void nr_polar_rate_matching(double *input, - double *output, - uint16_t *rmp, - uint16_t K, - uint16_t N, - uint16_t E); +void nr_polar_rate_matching(double *input, double *output, uint16_t *rmp, uint16_t K, uint16_t N, uint16_t E); -void nr_polar_rate_matching_int16(int16_t *input, - int16_t *output, - const uint16_t *rmp, - const uint16_t K, - const uint16_t N, - const uint16_t E, - const uint8_t i_bil); - -void nr_polar_interleaving_pattern(uint16_t K, - uint8_t I_IL, - uint16_t *PI_k_); +void nr_polar_interleaving_pattern(uint16_t K, uint8_t I_IL, uint16_t *PI_k_); void nr_polar_info_bit_pattern(uint8_t *ibp, uint8_t *pcbp, @@ -232,18 +219,11 @@ void nr_polar_info_bit_pattern(uint8_t *ibp, const uint8_t n_PC, const uint8_t n_pc_wm); -void nr_polar_info_bit_extraction(uint8_t *input, - uint8_t *output, - uint8_t *pattern, - uint16_t size); +void nr_polar_info_bit_extraction(uint8_t *input, uint8_t *output, uint8_t *pattern, uint16_t size); -void nr_bit2byte_uint32_8(uint32_t *in, - uint16_t arraySize, - uint8_t *out); +void nr_bit2byte_uint32_8(uint32_t *in, uint16_t arraySize, uint8_t *out); -void nr_byte2bit_uint8_32(uint8_t *in, - uint16_t arraySize, - uint32_t *out); +void nr_byte2bit_uint8_32(uint8_t *in, uint16_t arraySize, uint32_t *out); const uint8_t **crc24c_generator_matrix(uint16_t payloadSizeBits); @@ -254,22 +234,9 @@ void nr_polar_generate_u(uint64_t *u, uint16_t N, uint8_t n_pc); -void nr_polar_uxG(uint8_t const* u, size_t N, uint8_t* D); +void nr_polar_uxG(uint8_t const *u, size_t N, uint8_t *D); -void nr_polar_info_extraction_from_u(uint64_t *Cprime, - const uint8_t *u, - const uint8_t *information_bit_pattern, - const uint8_t *parity_check_bit_pattern, - uint16_t N, - uint8_t n_pc); - -void nr_polar_bit_insertion(uint8_t *input, - uint8_t *output, - uint16_t N, - uint16_t K, - int16_t *Q_I_N, - int16_t *Q_PC_N, - uint8_t n_PC); +void nr_polar_bit_insertion(uint8_t *input, uint8_t *output, uint16_t N, uint16_t K, int16_t *Q_I_N, int16_t *Q_PC_N, uint8_t n_PC); void nr_matrix_multiplication_uint8_1D_uint8_2D(const uint8_t *matrix1, const uint8_t **matrix2, @@ -277,46 +244,39 @@ void nr_matrix_multiplication_uint8_1D_uint8_2D(const uint8_t *matrix1, uint16_t row, uint16_t col); -void nr_sort_asc_double_1D_array_ind(double *matrix, - uint8_t *ind, - uint8_t len); +void nr_sort_asc_double_1D_array_ind(double *matrix, uint8_t *ind, uint8_t len); void nr_free_double_2D_array(double **input, uint16_t xlen); #ifndef __cplusplus void updateLLR(uint8_t listSize, - uint16_t row, - uint16_t col, - uint16_t xlen, - uint8_t ylen, - int zlen, - double llr[xlen][ylen][zlen], - uint8_t llrU[xlen][ylen], - uint8_t bit[xlen][ylen][zlen], - uint8_t bitU[xlen][ylen] - ); + uint16_t row, + uint16_t col, + uint16_t xlen, + uint8_t ylen, + int zlen, + double llr[xlen][ylen][zlen], + uint8_t llrU[xlen][ylen], + uint8_t bit[xlen][ylen][zlen], + uint8_t bitU[xlen][ylen]); void updatePathMetric(double *pathMetric, - uint8_t listSize, - uint8_t bitValue, - uint16_t row, - int xlen, - int ylen, - int zlen, - double llr[xlen][ylen][zlen] - ); + uint8_t listSize, + uint8_t bitValue, + uint16_t row, + int xlen, + int ylen, + int zlen, + double llr[xlen][ylen][zlen]); void updatePathMetric2(double *pathMetric, - uint8_t listSize, - uint16_t row, - int xlen, - int ylen, - int zlen, - double llr[xlen][ylen][zlen]); + uint8_t listSize, + uint16_t row, + int xlen, + int ylen, + int zlen, + double llr[xlen][ylen][zlen]); #endif -//Also nr_polar_rate_matcher -static inline void nr_polar_interleaver(uint8_t *input, - uint8_t *output, - uint16_t *pattern, - uint16_t size) +// Also nr_polar_rate_matcher +static inline void nr_polar_interleaver(uint8_t *input, uint8_t *output, uint16_t *pattern, uint16_t size) { for (int i = 0; i < size; i++) output[i] = input[pattern[i]]; @@ -328,7 +288,52 @@ static inline void nr_polar_deinterleaver(uint8_t *input, uint8_t *output, uint1 output[pattern[i]] = input[i]; } -void delete_decoder_tree(t_nrPolar_params *); +/* + * De-interleaving of coded bits implementation + * TS 138.212: Section 5.4.1.3 - Interleaving of coded bits + */ +static inline void nr_polar_rm_deinterleaving_lut(uint16_t *out, const uint E) +{ + int16_t in[E]; + for (int i = 0; i < E; i++) + in[i] = i; + int T = ceil((sqrt(8 * E + 1) - 1) / 2); + int v_tab[T][T]; + memset(v_tab, 0, sizeof(v_tab)); + int k = 0; + for (int i = 0; i < T; i++) { + for (int j = 0; j < T - i; j++) { + if (k < E) { + v_tab[i][j] = k + 1; + } + k++; + } + } + + int v[T][T]; + k = 0; + for (int j = 0; j < T; j++) { + for (int i = 0; i < T - j; i++) { + if (k < E && v_tab[i][j] != 0) { + v[i][j] = in[k]; + k++; + } else { + v[i][j] = INT_MAX; + } + } + } + + k = 0; + memset(out, 0, E * sizeof(*out)); + for (int i = 0; i < T; i++) { + for (int j = 0; j < T - i; j++) { + if (v[i][j] != INT_MAX) { + out[k] = v[i][j]; + k++; + } + } + } +} extern pthread_mutex_t PolarListMutex; static inline void polarReturn(t_nrPolar_params *polarParams) diff --git a/openair1/PHY/CODING/nrPolar_tools/nr_polar_encoder.c b/openair1/PHY/CODING/nrPolar_tools/nr_polar_encoder.c index c23513bdf6..0f22900d72 100644 --- a/openair1/PHY/CODING/nrPolar_tools/nr_polar_encoder.c +++ b/openair1/PHY/CODING/nrPolar_tools/nr_polar_encoder.c @@ -30,24 +30,21 @@ * \warning */ -//#define DEBUG_POLAR_ENCODER -//#define DEBUG_POLAR_ENCODER_DCI -//#define DEBUG_POLAR_MATLAB -//#define POLAR_CODING_DEBUG +// #define DEBUG_POLAR_ENCODER +// #define DEBUG_POLAR_ENCODER_DCI +// #define DEBUG_POLAR_MATLAB +// #define POLAR_CODING_DEBUG #include "PHY/CODING/nrPolar_tools/nr_polar_defs.h" #include "assertions.h" #include -//input [a_31 a_30 ... a_0] -//output [f_31 f_30 ... f_0] [f_63 f_62 ... f_32] ... +// input [a_31 a_30 ... a_0] +// output [f_31 f_30 ... f_0] [f_63 f_62 ... f_32] ... -void polar_encoder(uint32_t *in, - uint32_t *out, - int8_t messageType, - uint16_t messageLength, - uint8_t aggregation_level) { - t_nrPolar_params *polarParams=nr_polar_params(messageType, messageLength, aggregation_level, false); +void polar_encoder(uint32_t *in, uint32_t *out, int8_t messageType, uint16_t messageLength, uint8_t aggregation_level) +{ + t_nrPolar_params *polarParams = nr_polar_params(messageType, messageLength, aggregation_level); uint8_t nr_polar_A[polarParams->payloadBits]; nr_bit2byte_uint32_8(in, polarParams->payloadBits, nr_polar_A); /* @@ -83,21 +80,21 @@ void polar_encoder(uint32_t *in, printf("b[%d]=%d\n", i, nr_polar_B[i]); #endif - //Interleaving (c to c') + // Interleaving (c to c') uint8_t nr_polar_CPrime[polarParams->K]; nr_polar_interleaver(nr_polar_B, nr_polar_CPrime, polarParams->interleaving_pattern, polarParams->K); #ifdef DEBUG_POLAR_ENCODER - uint64_t Cprime=0; + uint64_t Cprime = 0; - for (int i = 0; iK; i++) { + for (int i = 0; i < polarParams->K; i++) { Cprime = Cprime | ((uint64_t)nr_polar_CPrime[i] << i); if (nr_polar_CPrime[i] == 1) printf("pos %d : %lx\n", i, Cprime); } - printf("polar_Cprime %lx\n",Cprime); + printf("polar_Cprime %lx\n", Cprime); #endif - //Bit insertion (c' to u) + // Bit insertion (c' to u) uint8_t nr_polar_U[polarParams->N]; nr_polar_bit_insertion(nr_polar_CPrime, nr_polar_U, @@ -119,11 +116,10 @@ void polar_encoder(uint32_t *in, for (int i = 0; i < polarParams->N; i++) D[i / 64] |= ((uint64_t)nr_polar_D[i]) << (i & 63); - printf("D %llx,%llx,%llx,%llx,%llx,%llx,%llx,%llx\n", - D[0],D[1],D[2],D[3],D[4],D[5],D[6],D[7]); + printf("D %llx,%llx,%llx,%llx,%llx,%llx,%llx,%llx\n", D[0], D[1], D[2], D[3], D[4], D[5], D[6], D[7]); #endif - //Rate matching - //Sub-block interleaving (d to y) and Bit selection (y to e) + // Rate matching + // Sub-block interleaving (d to y) and Bit selection (y to e) uint8_t nr_polar_E[polarParams->encoderLength]; nr_polar_interleaver(nr_polar_D, nr_polar_E, polarParams->rate_matching_pattern, polarParams->encoderLength); /* @@ -145,8 +141,9 @@ void polar_encoder_dci(uint32_t *in, uint16_t n_RNTI, int8_t messageType, uint16_t messageLength, - uint8_t aggregation_level) { - t_nrPolar_params *polarParams=nr_polar_params(messageType, messageLength, aggregation_level, false); + uint8_t aggregation_level) +{ + t_nrPolar_params *polarParams = nr_polar_params(messageType, messageLength, aggregation_level); #ifdef DEBUG_POLAR_ENCODER_DCI printf("[polar_encoder_dci] in: [0]->0x%08x \t [1]->0x%08x \t [2]->0x%08x \t [3]->0x%08x\n", in[0], in[1], in[2], in[3]); @@ -176,10 +173,11 @@ void polar_encoder_dci(uint32_t *in, printf("\n"); printf("[polar_encoder_dci] GP: "); - for (int i=0; icrcParityBits; i++) printf("%d-", polarParams->crc_generator_matrix[0][i]); + for (int i = 0; i < polarParams->crcParityBits; i++) + printf("%d-", polarParams->crc_generator_matrix[0][i]); printf("\n"); #endif - //Calculate CRC. + // Calculate CRC. uint8_t nr_polar_crc[polarParams->crcParityBits]; nr_matrix_multiplication_uint8_1D_uint8_2D(nr_polar_APrime, polarParams->crc_generator_matrix, @@ -197,14 +195,14 @@ void polar_encoder_dci(uint32_t *in, printf("\n"); #endif uint8_t nr_polar_B[polarParams->payloadBits + 8 + 16]; - //Attach CRC to the Transport Block. (a to b) + // Attach CRC to the Transport Block. (a to b) memcpy(nr_polar_B, nr_polar_A, polarParams->payloadBits); for (uint i = polarParams->payloadBits; i < polarParams->K; i++) nr_polar_B[i] = nr_polar_crc[i - polarParams->payloadBits]; - //Scrambling (b to c) - for (int i=0; i<16; i++) + // Scrambling (b to c) + for (int i = 0; i < 16; i++) nr_polar_B[polarParams->payloadBits + 8 + i] = (nr_polar_B[polarParams->payloadBits + 8 + i] + ((n_RNTI >> (15 - i)) & 1)) % 2; #ifdef DEBUG_POLAR_ENCODER_DCI @@ -213,10 +211,10 @@ void polar_encoder_dci(uint32_t *in, printf("%d-", nr_polar_B[i]); printf("\n"); #endif - //Interleaving (c to c') + // Interleaving (c to c') uint8_t nr_polar_CPrime[polarParams->K]; nr_polar_interleaver(nr_polar_B, nr_polar_CPrime, polarParams->interleaving_pattern, polarParams->K); - //Bit insertion (c' to u) + // Bit insertion (c' to u) uint8_t nr_polar_U[polarParams->N]; nr_polar_bit_insertion(nr_polar_CPrime, nr_polar_U, @@ -225,14 +223,14 @@ void polar_encoder_dci(uint32_t *in, polarParams->Q_I_N, polarParams->Q_PC_N, polarParams->n_pc); - //Encoding (u to d) + // Encoding (u to d) uint8_t nr_polar_D[polarParams->N]; nr_matrix_multiplication_uint8_1D_uint8_2D(nr_polar_U, polarParams->G_N, nr_polar_D, polarParams->N, polarParams->N); for (uint i = 0; i < polarParams->N; i++) nr_polar_D[i] %= 2; - //Rate matching - //Sub-block interleaving (d to y) and Bit selection (y to e) + // Rate matching + // Sub-block interleaving (d to y) and Bit selection (y to e) uint8_t nr_polar_E[polarParams->encoderLength]; nr_polar_interleaver(nr_polar_D, nr_polar_E, polarParams->rate_matching_pattern, polarParams->encoderLength); /* @@ -294,44 +292,50 @@ __attribute__((always_inline)) static inline void polar_rate_matching(const t_nr { // handle rate matching with a single 128 bit word using bit shuffling // can be done with SIMD intrisics if needed - if (polarParams->groupsize < 8) { - AssertFatal(polarParams->encoderLength<=512,"Need to handle groupsize(%d)<8 and N(%d)>512\n",polarParams->groupsize,polarParams->encoderLength); - uint128_t *out128=(uint128_t*)out; - uint128_t *in128=(uint128_t*)in; - for (int i=0;iencoderLength>>7;i++) + if (polarParams->groupsize < 8) { + AssertFatal(polarParams->encoderLength <= 512, + "Need to handle groupsize(%d)<8 and N(%d)>512\n", + polarParams->groupsize, + polarParams->encoderLength); + uint128_t *out128 = (uint128_t *)out; + uint128_t *in128 = (uint128_t *)in; + for (int i = 0; i < polarParams->encoderLength >> 7; i++) out128[i] = 0; #ifdef DEBUG_POLAR_ENCODER uint128_t tmp1; #endif - for (int i=0; iencoderLength; i++) { + for (int i = 0; i < polarParams->encoderLength; i++) { #ifdef DEBUG_POLAR_ENCODER - printf("%d<-%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 - uint8_t pi=polarParams->rate_matching_pattern[i]; - uint8_t pi7=pi>>7; - uint8_t pimod128=pi&127; - uint8_t imod128=i&127; - uint8_t i7=i>>7; + uint8_t pi = polarParams->rate_matching_pattern[i]; + uint8_t pi7 = pi >> 7; + uint8_t pimod128 = pi & 127; + uint8_t imod128 = i & 127; + uint8_t i7 = i >> 7; uint128_t tmp0 = (in128[pi7] & (((uint128_t)1) << (pimod128))); - if (tmp0!=0) { - out128[i7] = out128[i7] | ((uint128_t)1)<%llx.%llx => %llx.%llx\n", - ((uint64_t *)&tmp0)[1],((uint64_t *)&tmp0)[0], - ((uint64_t *)&tmp1)[1],((uint64_t *)&tmp1)[0], - ((uint64_t *)out)[1],((uint64_t *)out)[0]); + ((uint64_t *)&tmp0)[1], + ((uint64_t *)&tmp0)[0], + ((uint64_t *)&tmp1)[1], + ((uint64_t *)&tmp1)[0], + ((uint64_t *)out)[1], + ((uint64_t *)out)[0]); #endif } } - } + } // These are based on LUTs for byte and short word groups else if (polarParams->groupsize == 8) for (int i = 0; i < polarParams->encoderLength >> 3; i++) ((uint8_t *)out)[i] = ((uint8_t *)in)[polarParams->rm_tab[i]]; else // groupsize==16 - for (int i=0; iencoderLength>>4; i++) { + for (int i = 0; i < polarParams->encoderLength >> 4; i++) { ((uint16_t *)out)[i] = ((uint16_t *)in)[polarParams->rm_tab[i]]; } @@ -340,19 +344,20 @@ __attribute__((always_inline)) static inline void polar_rate_matching(const t_nr } } -void build_polar_tables(t_nrPolar_params *polarParams) { +void build_polar_tables(t_nrPolar_params *polarParams) +{ // build table b -> c' - AssertFatal(polarParams->K > 17, "K = %d < 18, is not possible\n",polarParams->K); + AssertFatal(polarParams->K > 17, "K = %d < 18, is not possible\n", polarParams->K); AssertFatal(polarParams->K < 129, "K = %d > 128, is not supported yet\n", polarParams->K); - const int numbytes = (polarParams->K+7)/8; - const int residue = polarParams->K&7; + const int numbytes = (polarParams->K + 7) / 8; + const int residue = polarParams->K & 7; uint deinterleaving_pattern[polarParams->K]; for (int i = 0; i < polarParams->K; i++) deinterleaving_pattern[polarParams->interleaving_pattern[i]] = i; - for (int byte=0; byteK>>3) ? 8 : residue; + for (int byte = 0; byte < numbytes; byte++) { + int numbits = byte < (polarParams->K >> 3) ? 8 : residue; for (uint64_t val = 0; val < 256LU; val++) { // uint16_t * tmp=polarParams->deinterleaving_pattern+polarParams->K - 1 - 8 * byte; union { @@ -360,10 +365,10 @@ void build_polar_tables(t_nrPolar_params *polarParams) { uint64_t pieces[2]; } tab = {0}; uint *tmp = deinterleaving_pattern + polarParams->K - 8 * byte - 1; - for (int i=0; i> i) & 1; tab.full |= bit_i << ip; } @@ -372,50 +377,57 @@ void build_polar_tables(t_nrPolar_params *polarParams) { } } - AssertFatal(polarParams->N == 512 || polarParams->N == 256 || polarParams->N == 128 || polarParams->N == 64, "N = %d, not done yet\n", polarParams->N); + AssertFatal(polarParams->N == 512 || polarParams->N == 256 || polarParams->N == 128 || polarParams->N == 64, + "N = %d, not done yet\n", + polarParams->N); // rate matching table - int iplast=polarParams->rate_matching_pattern[0]; - int ccnt=0; + int iplast = polarParams->rate_matching_pattern[0]; + int ccnt = 0; #ifdef DEBUG_POLAR_ENCODER - int groupcnt=0; - int firstingroup_out=0; - int firstingroup_in=iplast; + int groupcnt = 0; + int firstingroup_out = 0; + int firstingroup_in = iplast; #endif int mingroupsize = 1024; // compute minimum group size of rate-matching pattern - for (int outpos=1; outposencoderLength; outpos++) { + for (int outpos = 1; outpos < polarParams->encoderLength; outpos++) { int ip = polarParams->rate_matching_pattern[outpos]; #ifdef DEBUG_POLAR_ENCODER - printf("rm: outpos %d, inpos %d\n",outpos,ip); + printf("rm: outpos %d, inpos %d\n", outpos, ip); #endif if ((ip - iplast) == 1) ccnt++; else { #ifdef DEBUG_POLAR_ENCODER groupcnt++; - printf("group %d (size %d): (%d:%d) => (%d:%d)\n",groupcnt,ccnt+1, - firstingroup_in,firstingroup_in+ccnt, - firstingroup_out,firstingroup_out+ccnt); + printf("group %d (size %d): (%d:%d) => (%d:%d)\n", + groupcnt, + ccnt + 1, + firstingroup_in, + firstingroup_in + ccnt, + firstingroup_out, + firstingroup_out + ccnt); #endif if ((ccnt + 1) < mingroupsize) mingroupsize = ccnt + 1; - ccnt=0; + ccnt = 0; #ifdef DEBUG_POLAR_ENCODER - firstingroup_out=outpos; - firstingroup_in=ip; + firstingroup_out = outpos; + firstingroup_in = ip; #endif } - iplast=ip; + iplast = ip; } #ifdef DEBUG_POLAR_ENCODER groupcnt++; #endif - if ((ccnt+1) (%d:%d)\n", groupcnt, @@ -452,8 +464,9 @@ void build_polar_tables(t_nrPolar_params *polarParams) { // rerun again to create groups for (int outpos = 0, tcnt = 0; outpos < polarParams->encoderLength; outpos += mingroupsize, tcnt++) polarParams->rm_tab[tcnt] = polarParams->rate_matching_pattern[outpos] >> shift; -} + build_decoder_tree(polarParams); +} void polar_encoder_fast(uint64_t *A, void *out, @@ -463,7 +476,7 @@ void polar_encoder_fast(uint64_t *A, uint16_t messageLength, uint8_t aggregation_level) { - t_nrPolar_params *polarParams=nr_polar_params(messageType, messageLength, aggregation_level, false); + t_nrPolar_params *polarParams = nr_polar_params(messageType, messageLength, aggregation_level); #ifdef POLAR_CODING_DEBUG printf("polarParams->payloadBits = %i\n", polarParams->payloadBits); @@ -480,27 +493,27 @@ void polar_encoder_fast(uint64_t *A, #endif // AssertFatal(polarParams->K > 32, "K = %d < 33, is not supported yet\n",polarParams->K); - AssertFatal(polarParams->K < 129, "K = %d > 128, is not supported yet\n",polarParams->K); - AssertFatal(polarParams->payloadBits < 65, "payload bits = %d > 64, is not supported yet\n",polarParams->payloadBits); + AssertFatal(polarParams->K < 129, "K = %d > 128, is not supported yet\n", polarParams->K); + AssertFatal(polarParams->payloadBits < 65, "payload bits = %d > 64, is not supported yet\n", polarParams->payloadBits); int bitlen = polarParams->payloadBits; // append crc - AssertFatal(bitlen<129,"support for payloads <= 128 bits\n"); + AssertFatal(bitlen < 129, "support for payloads <= 128 bits\n"); // AssertFatal(polarParams->crcParityBits == 24,"support for 24-bit crc only for now\n"); - //int bitlen0=bitlen; + // int bitlen0=bitlen; #ifdef POLAR_CODING_DEBUG printf("\nTX\n"); printf("a: "); - for (int n = (bitlen + 63)/64 ; n >=0; n--) { - if (n % 4 == 0) - printf(" "); - if (n < bitlen) - printf("%lu", (A[n/64] >> (n%64)) & 1); + for (int n = (bitlen + 63) / 64; n >= 0; n--) { + if (n % 4 == 0) + printf(" "); + if (n < bitlen) + printf("%lu", (A[n / 64] >> (n % 64)) & 1); } printf("\n"); #endif - uint64_t tcrc=0; + uint64_t tcrc = 0; uint offset = 0; // appending 24 ones before a0 for DCI as stated in 38.212 7.3.2 @@ -511,76 +524,76 @@ void polar_encoder_fast(uint64_t *A, //???a'_{N-1} a'_{N-2} ... a'_{N-A} 0 .... 0, where N=64,128,192,..., N is smallest multiple of 64 greater than or equal to A // First flip A bitstring byte endian for CRC routines (optimized for DLSCH/ULSCH, not PBCH/PDCCH) - // CRC reads in each byte in bit positions 7 down to 0, for PBCH/PDCCH we need to read in a_{A-1} down to a_{0}, A = length of bit string (e.g. 32 for PBCH) - if (bitlen<=32) { - uint8_t A32_flip[4+offset]; + // CRC reads in each byte in bit positions 7 down to 0, for PBCH/PDCCH we need to read in a_{A-1} down to a_{0}, A = length of bit + // string (e.g. 32 for PBCH) + if (bitlen <= 32) { + uint8_t A32_flip[4 + offset]; if (ones_flag) { A32_flip[0] = 0xff; A32_flip[1] = 0xff; A32_flip[2] = 0xff; } - uint32_t Aprime= (uint32_t)(((uint32_t)*A)<<(32-bitlen)); - A32_flip[0+offset]=((uint8_t *)&Aprime)[3]; - A32_flip[1+offset]=((uint8_t *)&Aprime)[2]; - A32_flip[2+offset]=((uint8_t *)&Aprime)[1]; - A32_flip[3+offset]=((uint8_t *)&Aprime)[0]; - if (polarParams->crcParityBits == 24) - tcrc = (uint64_t)(((crcmask^(crc24c(A32_flip,8*offset+bitlen)>>8)))&0xffffff); + uint32_t Aprime = (uint32_t)(((uint32_t)*A) << (32 - bitlen)); + A32_flip[0 + offset] = ((uint8_t *)&Aprime)[3]; + A32_flip[1 + offset] = ((uint8_t *)&Aprime)[2]; + A32_flip[2 + offset] = ((uint8_t *)&Aprime)[1]; + A32_flip[3 + offset] = ((uint8_t *)&Aprime)[0]; + if (polarParams->crcParityBits == 24) + tcrc = (uint64_t)(((crcmask ^ (crc24c(A32_flip, 8 * offset + bitlen) >> 8))) & 0xffffff); else if (polarParams->crcParityBits == 11) - tcrc = (uint64_t)(((crcmask^(crc11(A32_flip,bitlen)>>21)))&0x7ff); + tcrc = (uint64_t)(((crcmask ^ (crc11(A32_flip, bitlen) >> 21))) & 0x7ff); else if (polarParams->crcParityBits == 6) - tcrc = (uint64_t)(((crcmask^(crc6(A32_flip,bitlen)>>26)))&0x3f); - } else if (bitlen<=64) { - uint8_t A64_flip[8+offset]; + tcrc = (uint64_t)(((crcmask ^ (crc6(A32_flip, bitlen) >> 26))) & 0x3f); + } else if (bitlen <= 64) { + uint8_t A64_flip[8 + offset]; if (ones_flag) { A64_flip[0] = 0xff; A64_flip[1] = 0xff; A64_flip[2] = 0xff; } - uint64_t Aprime= (uint64_t)(((uint64_t)*A)<<(64-bitlen)); - A64_flip[0+offset]=((uint8_t *)&Aprime)[7]; - A64_flip[1+offset]=((uint8_t *)&Aprime)[6]; - A64_flip[2+offset]=((uint8_t *)&Aprime)[5]; - A64_flip[3+offset]=((uint8_t *)&Aprime)[4]; - A64_flip[4+offset]=((uint8_t *)&Aprime)[3]; - A64_flip[5+offset]=((uint8_t *)&Aprime)[2]; - A64_flip[6+offset]=((uint8_t *)&Aprime)[1]; - A64_flip[7+offset]=((uint8_t *)&Aprime)[0]; + uint64_t Aprime = (uint64_t)(((uint64_t)*A) << (64 - bitlen)); + A64_flip[0 + offset] = ((uint8_t *)&Aprime)[7]; + A64_flip[1 + offset] = ((uint8_t *)&Aprime)[6]; + A64_flip[2 + offset] = ((uint8_t *)&Aprime)[5]; + A64_flip[3 + offset] = ((uint8_t *)&Aprime)[4]; + A64_flip[4 + offset] = ((uint8_t *)&Aprime)[3]; + A64_flip[5 + offset] = ((uint8_t *)&Aprime)[2]; + A64_flip[6 + offset] = ((uint8_t *)&Aprime)[1]; + A64_flip[7 + offset] = ((uint8_t *)&Aprime)[0]; if (polarParams->crcParityBits == 24) - tcrc = (uint64_t)((crcmask^(crc24c(A64_flip,8*offset+bitlen)>>8)))&0xffffff; + tcrc = (uint64_t)((crcmask ^ (crc24c(A64_flip, 8 * offset + bitlen) >> 8))) & 0xffffff; else if (polarParams->crcParityBits == 11) - tcrc = (uint64_t)((crcmask^(crc11(A64_flip,bitlen)>>21)))&0x7ff; - } - else if (bitlen<=128) { - uint8_t A128_flip[16+offset]; + tcrc = (uint64_t)((crcmask ^ (crc11(A64_flip, bitlen) >> 21))) & 0x7ff; + } else if (bitlen <= 128) { + uint8_t A128_flip[16 + offset]; if (ones_flag) { A128_flip[0] = 0xff; A128_flip[1] = 0xff; A128_flip[2] = 0xff; } - uint128_t Aprime= (uint128_t)(((uint128_t)*A)<<(128-bitlen)); - for (int i=0; i<16 ; i++) - A128_flip[i+offset]=((uint8_t*)&Aprime)[15-i]; + uint128_t Aprime = (uint128_t)(((uint128_t)*A) << (128 - bitlen)); + for (int i = 0; i < 16; i++) + A128_flip[i + offset] = ((uint8_t *)&Aprime)[15 - i]; if (polarParams->crcParityBits == 24) - tcrc = (uint64_t)((crcmask^(crc24c(A128_flip,8*offset+bitlen)>>8)))&0xffffff; + tcrc = (uint64_t)((crcmask ^ (crc24c(A128_flip, 8 * offset + bitlen) >> 8))) & 0xffffff; else if (polarParams->crcParityBits == 11) - tcrc = (uint64_t)((crcmask^(crc11(A128_flip,bitlen)>>21)))&0x7ff; + tcrc = (uint64_t)((crcmask ^ (crc11(A128_flip, bitlen) >> 21))) & 0x7ff; } // this is number of quadwords in the bit string - int quadwlen = (polarParams->K+63)/64; + int quadwlen = (polarParams->K + 63) / 64; // Create the B bit string as // 0, 0, ..., 0, a'_0, a'_1, ..., a'_A-1, p_0, p_1, ..., p_{N_parity-1} //??? b_{N'-1} b_{N'-2} ... b_{N'-A} b_{N'-A-1} ... b_{N'-A-Nparity} = a_{N-1} a_{N-2} ... a_{N-A} p_{N_parity-1} ... p_0 - uint64_t B[4]= {0}; + uint64_t B[4] = {0}; B[0] = (A[0] << polarParams->crcParityBits) | tcrc; for (int n = 1; n < quadwlen; n++) - if ((bitlen+63)/64 > n) - B[n] = (A[n] << polarParams->crcParityBits) | (A[n-1]>>(64-polarParams->crcParityBits)); + if ((bitlen + 63) / 64 > n) + B[n] = (A[n] << polarParams->crcParityBits) | (A[n - 1] >> (64 - polarParams->crcParityBits)); else - B[n] = (A[n-1]>>(64-polarParams->crcParityBits)); + B[n] = (A[n - 1] >> (64 - polarParams->crcParityBits)); #ifdef POLAR_CODING_DEBUG int bitlen_B = bitlen + polarParams->crcParityBits; @@ -600,17 +613,13 @@ void polar_encoder_fast(uint64_t *A, // TS 38.212 - Section 5.3.1.1 Interleaving // For each byte of B, lookup in corresponding table for 64-bit word corresponding to that byte and its position - uint64_t Cprime[4]= {0}; + uint64_t Cprime[4] = {0}; uint8_t *Bbyte = (uint8_t *)B; if (polarParams->K < 65) { - Cprime[0] = polarParams->cprime_tab0[0][Bbyte[0]] | - polarParams->cprime_tab0[1][Bbyte[1]] | - polarParams->cprime_tab0[2][Bbyte[2]] | - polarParams->cprime_tab0[3][Bbyte[3]] | - polarParams->cprime_tab0[4][Bbyte[4]] | - polarParams->cprime_tab0[5][Bbyte[5]] | - polarParams->cprime_tab0[6][Bbyte[6]] | - polarParams->cprime_tab0[7][Bbyte[7]]; + Cprime[0] = polarParams->cprime_tab0[0][Bbyte[0]] | polarParams->cprime_tab0[1][Bbyte[1]] + | polarParams->cprime_tab0[2][Bbyte[2]] | polarParams->cprime_tab0[3][Bbyte[3]] + | polarParams->cprime_tab0[4][Bbyte[4]] | polarParams->cprime_tab0[5][Bbyte[5]] + | polarParams->cprime_tab0[6][Bbyte[6]] | polarParams->cprime_tab0[7][Bbyte[7]]; } else if (polarParams->K < 129) { for (int i = 0; i < 1 + (polarParams->K / 8); i++) { Cprime[0] |= polarParams->cprime_tab0[i][Bbyte[i]]; @@ -620,7 +629,8 @@ void polar_encoder_fast(uint64_t *A, #ifdef DEBUG_POLAR_MATLAB // Cprime = pbchCprime - for (int i = 0; i < quadwlen; i++) printf("[polar_encoder_fast]C'[%d]= 0x%llx\n", i, (unsigned long long)(Cprime[i])); + for (int i = 0; i < quadwlen; i++) + printf("[polar_encoder_fast]C'[%d]= 0x%llx\n", i, (unsigned long long)(Cprime[i])); #endif #ifdef POLAR_CODING_DEBUG @@ -675,8 +685,8 @@ void polar_encoder_fast(uint64_t *A, fflush(stdout); #endif - memset((void*)out,0,polarParams->encoderLength>>3); - polar_rate_matching(polarParams,(void *)D, out); + memset((void *)out, 0, polarParams->encoderLength >> 3); + polar_rate_matching(polarParams, (void *)D, out); #ifdef POLAR_CODING_DEBUG uint64_t *out64 = (uint64_t *)out; diff --git a/openair1/PHY/CODING/nr_polar_init.c b/openair1/PHY/CODING/nrPolar_tools/nr_polar_init.c similarity index 70% rename from openair1/PHY/CODING/nr_polar_init.c rename to openair1/PHY/CODING/nrPolar_tools/nr_polar_init.c index 1d12aae23e..609f4b4a8f 100644 --- a/openair1/PHY/CODING/nr_polar_init.c +++ b/openair1/PHY/CODING/nrPolar_tools/nr_polar_init.c @@ -30,25 +30,26 @@ * \warning */ -#include "PHY/CODING/nrPolar_tools/nr_polar_defs.h" +#include "nr_polar_defs.h" +#include "nr_polar_psbch_defs.h" #include "PHY/NR_TRANSPORT/nr_dci.h" -#include "nrPolar_tools/nr_polar_psbch_defs.h" -#define PolarKey ((messageType<<24)|(messageLength<<8)|aggregation_level) -static t_nrPolar_params * PolarList=NULL; -pthread_mutex_t PolarListMutex=PTHREAD_MUTEX_INITIALIZER; +#define PolarKey ((messageType << 24) | (messageLength << 8) | aggregation_level) +static t_nrPolar_params *PolarList = NULL; +pthread_mutex_t PolarListMutex = PTHREAD_MUTEX_INITIALIZER; -static int intcmp(const void *p1,const void *p2) { - return(*(int16_t *)p1 > *(int16_t *)p2); +static int intcmp(const void *p1, const void *p2) +{ + return (*(int16_t *)p1 > *(int16_t *)p2); } -static void nr_polar_delete_list(t_nrPolar_params * polarParams) { +static void nr_polar_delete_list(t_nrPolar_params *polarParams) +{ if (!polarParams) return; if (polarParams->nextPtr) nr_polar_delete_list(polarParams->nextPtr); - - delete_decoder_tree(polarParams); + // From build_polar_tables() free(polarParams->rm_tab); if (polarParams->crc_generator_matrix) @@ -58,55 +59,55 @@ static void nr_polar_delete_list(t_nrPolar_params * polarParams) { free(polarParams->rate_matching_pattern); free(polarParams->information_bit_pattern); free(polarParams->parity_check_bit_pattern); + free(polarParams->i_bil_pattern); free(polarParams->Q_I_N); free(polarParams->Q_F_N); free(polarParams->Q_PC_N); free(polarParams); } -static void nr_polar_delete(void) { +static void nr_polar_delete(void) +{ pthread_mutex_lock(&PolarListMutex); nr_polar_delete_list(PolarList); - PolarList=NULL; - pthread_mutex_unlock(&PolarListMutex); + PolarList = NULL; + pthread_mutex_unlock(&PolarListMutex); } -t_nrPolar_params *nr_polar_params(int8_t messageType, uint16_t messageLength, uint8_t aggregation_level, int decoder_flag) +t_nrPolar_params *nr_polar_params(int8_t messageType, uint16_t messageLength, uint8_t aggregation_level) { // The lock is weak, because we never delete in the list, only at exit time // therefore, returning t_nrPolar_params * from the list is safe for future usage pthread_mutex_lock(&PolarListMutex); - if(!PolarList) + if (!PolarList) atexit(nr_polar_delete); - + t_nrPolar_params *currentPtr = PolarList; - //Parse the list. If the node is already created, return without initialization. + // Parse the list. If the node is already created, return without initialization. while (currentPtr != NULL) { - //printf("currentPtr->idx %d, (%d,%d)\n",currentPtr->idx,currentPtr->payloadBits,currentPtr->encoderLength); - //LOG_D(PHY,"Looking for index %d\n",(messageType * messageLength * aggregation_prime)); - if (currentPtr->busy == false && currentPtr->idx == PolarKey ) { - currentPtr->busy=true; + // printf("currentPtr->idx %d, (%d,%d)\n",currentPtr->idx,currentPtr->payloadBits,currentPtr->encoderLength); + // LOG_D(PHY,"Looking for index %d\n",(messageType * messageLength * aggregation_prime)); + if (currentPtr->busy == false && currentPtr->idx == PolarKey) { + currentPtr->busy = true; pthread_mutex_unlock(&PolarListMutex); - if (decoder_flag && !currentPtr->tree.root) - build_decoder_tree(currentPtr); - return currentPtr ; - } - else + return currentPtr; + } else currentPtr = currentPtr->nextPtr; } // printf("currentPtr %p (polarParams %p)\n",currentPtr,polarParams); - //Else, initialize and add node to the end of the linked list. - t_nrPolar_params *newPolarInitNode = calloc(sizeof(t_nrPolar_params),1); + // Else, initialize and add node to the end of the linked list. + t_nrPolar_params *newPolarInitNode = malloc(sizeof(t_nrPolar_params)); + AssertFatal(newPolarInitNode, "[nr_polar_init] New t_nrPolar_params * could not be created"); - newPolarInitNode->busy = true; - newPolarInitNode->nextPtr = NULL; - newPolarInitNode->nextPtr = PolarList; + *newPolarInitNode = (t_nrPolar_params){.busy = true, .nextPtr = PolarList, .tree_linearization.is_initialized = false}; PolarList = newPolarInitNode; pthread_mutex_unlock(&PolarListMutex); - // LOG_D(PHY,"Setting new polarParams index %d, messageType %d, messageLength %d, aggregation_prime %d\n",(messageType * messageLength * aggregation_prime),messageType,messageLength,aggregation_prime); + // LOG_D(PHY,"Setting new polarParams index %d, messageType %d, messageLength %d, aggregation_prime %d\n",(messageType * + // messageLength * aggregation_prime),messageType,messageLength,aggregation_prime); newPolarInitNode->idx = PolarKey; - //printf("newPolarInitNode->idx %d, (%d,%d,%d:%d)\n",newPolarInitNode->idx,messageType,messageLength,aggregation_prime,aggregation_level); + // printf("newPolarInitNode->idx %d, + // (%d,%d,%d:%d)\n",newPolarInitNode->idx,messageType,messageLength,aggregation_prime,aggregation_level); if (messageType == NR_POLAR_PBCH_MESSAGE_TYPE) { newPolarInitNode->n_max = NR_POLAR_PBCH_N_MAX; @@ -120,7 +121,8 @@ t_nrPolar_params *nr_polar_params(int8_t messageType, uint16_t messageLength, ui newPolarInitNode->encoderLength = NR_POLAR_PBCH_E; newPolarInitNode->crcCorrectionBits = NR_POLAR_PBCH_CRC_ERROR_CORRECTION_BITS; newPolarInitNode->crc_generator_matrix = crc24c_generator_matrix(newPolarInitNode->payloadBits); // G_P - //printf("Initializing polar parameters for PBCH (K %d, E %d)\n",newPolarInitNode->payloadBits,newPolarInitNode->encoderLength); + // printf("Initializing polar parameters for PBCH (K %d, E + // %d)\n",newPolarInitNode->payloadBits,newPolarInitNode->encoderLength); } else if (messageType == NR_POLAR_DCI_MESSAGE_TYPE) { newPolarInitNode->n_max = NR_POLAR_DCI_N_MAX; @@ -133,11 +135,15 @@ t_nrPolar_params *nr_polar_params(int8_t messageType, uint16_t messageLength, ui newPolarInitNode->payloadBits = messageLength; newPolarInitNode->encoderLength = aggregation_level * 108; newPolarInitNode->crcCorrectionBits = NR_POLAR_DCI_CRC_ERROR_CORRECTION_BITS; - newPolarInitNode->crc_generator_matrix = crc24c_generator_matrix(newPolarInitNode->payloadBits + newPolarInitNode->crcParityBits); // G_P - //printf("Initializing polar parameters for DCI (K %d, E %d, L %d)\n",newPolarInitNode->payloadBits,newPolarInitNode->encoderLength,aggregation_level); + newPolarInitNode->crc_generator_matrix = + crc24c_generator_matrix(newPolarInitNode->payloadBits + newPolarInitNode->crcParityBits); // G_P + // printf("Initializing polar parameters for DCI (K %d, E %d, L + // %d)\n",newPolarInitNode->payloadBits,newPolarInitNode->encoderLength,aggregation_level); } else if (messageType == NR_POLAR_UCI_PUCCH_MESSAGE_TYPE) { - AssertFatal(aggregation_level > 2, "Aggregation level (%d) for PUCCH 2 encoding is NPRB and should be > 2\n", aggregation_level); + AssertFatal(aggregation_level > 2, + "Aggregation level (%d) for PUCCH 2 encoding is NPRB and should be > 2\n", + aggregation_level); AssertFatal(messageLength > 11, "Message length %d is too short for polar encoding of UCI\n", messageLength); // TS 38.212 - Section 6.3.1.2.1 UCI encoded by Polar code @@ -178,7 +184,7 @@ t_nrPolar_params *nr_polar_params(int8_t messageType, uint16_t messageLength, ui newPolarInitNode->i_bil = NR_POLAR_PUCCH_I_BIL; newPolarInitNode->payloadBits = messageLength; newPolarInitNode->crcCorrectionBits = NR_POLAR_PUCCH_CRC_ERROR_CORRECTION_BITS; - //LOG_D(PHY,"New polar node, encoderLength %d, aggregation_level %d\n",newPolarInitNode->encoderLength,aggregation_level); + // LOG_D(PHY,"New polar node, encoderLength %d, aggregation_level %d\n",newPolarInitNode->encoderLength,aggregation_level); } else if (messageType == SL_NR_POLAR_PSBCH_MESSAGE_TYPE) { // PSBCH newPolarInitNode->n_max = SL_NR_POLAR_PSBCH_N_MAX; newPolarInitNode->i_il = SL_NR_POLAR_PSBCH_I_IL; @@ -200,17 +206,13 @@ t_nrPolar_params *nr_polar_params(int8_t messageType, uint16_t messageLength, ui } newPolarInitNode->K = newPolarInitNode->payloadBits + newPolarInitNode->crcParityBits; // Number of bits to encode. - newPolarInitNode->N = nr_polar_output_length(newPolarInitNode->K, - newPolarInitNode->encoderLength, - newPolarInitNode->n_max); + newPolarInitNode->N = nr_polar_output_length(newPolarInitNode->K, newPolarInitNode->encoderLength, newPolarInitNode->n_max); newPolarInitNode->n = log2(newPolarInitNode->N); newPolarInitNode->G_N = nr_polar_kronecker_power_matrices(newPolarInitNode->n); // polar_encoder vectors: newPolarInitNode->Q_0_Nminus1 = nr_polar_sequence_pattern(newPolarInitNode->n); newPolarInitNode->interleaving_pattern = malloc(sizeof(uint16_t) * newPolarInitNode->K); - nr_polar_interleaving_pattern(newPolarInitNode->K, - newPolarInitNode->i_il, - newPolarInitNode->interleaving_pattern); + nr_polar_interleaving_pattern(newPolarInitNode->K, newPolarInitNode->i_il, newPolarInitNode->interleaving_pattern); newPolarInitNode->rate_matching_pattern = malloc(sizeof(uint16_t) * newPolarInitNode->encoderLength); uint16_t J[newPolarInitNode->N]; @@ -220,11 +222,16 @@ t_nrPolar_params *nr_polar_params(int8_t messageType, uint16_t messageLength, ui newPolarInitNode->K, newPolarInitNode->N, newPolarInitNode->encoderLength); + if (newPolarInitNode->i_bil) { + newPolarInitNode->i_bil_pattern = malloc(sizeof(uint16_t) * newPolarInitNode->encoderLength); + nr_polar_rm_deinterleaving_lut(newPolarInitNode->i_bil_pattern, newPolarInitNode->encoderLength); + } newPolarInitNode->information_bit_pattern = malloc(sizeof(uint8_t) * newPolarInitNode->N); newPolarInitNode->parity_check_bit_pattern = malloc(sizeof(uint8_t) * newPolarInitNode->N); newPolarInitNode->Q_I_N = malloc(sizeof(int16_t) * (newPolarInitNode->K + newPolarInitNode->n_pc)); - newPolarInitNode->Q_F_N = malloc( sizeof(int16_t) * (newPolarInitNode->N + 1)); // Last element shows the final array index assigned a value. - newPolarInitNode->Q_PC_N = malloc( sizeof(int16_t) * (newPolarInitNode->n_pc)); + newPolarInitNode->Q_F_N = + malloc(sizeof(int16_t) * (newPolarInitNode->N + 1)); // Last element shows the final array index assigned a value. + newPolarInitNode->Q_PC_N = malloc(sizeof(int16_t) * (newPolarInitNode->n_pc)); for (int i = 0; i <= newPolarInitNode->N; i++) newPolarInitNode->Q_F_N[i] = -1; // Empty array. @@ -243,26 +250,26 @@ t_nrPolar_params *nr_polar_params(int8_t messageType, uint16_t messageLength, ui newPolarInitNode->n_pc_wm); // sort the Q_I_N array in ascending order (first K positions) - qsort((void *)newPolarInitNode->Q_I_N,newPolarInitNode->K,sizeof(int16_t),intcmp); + qsort((void *)newPolarInitNode->Q_I_N, newPolarInitNode->K, sizeof(int16_t), intcmp); - if (decoder_flag == 1) - build_decoder_tree(newPolarInitNode); build_polar_tables(newPolarInitNode); - - init_polar_deinterleaver_table(newPolarInitNode); return newPolarInitNode; } -void nr_polar_print_polarParams() { +void nr_polar_print_polarParams() +{ uint8_t i = 0; if (PolarList == NULL) { printf("polarParams is empty.\n"); } else { - t_nrPolar_params * polarParams=PolarList; + t_nrPolar_params *polarParams = PolarList; while (polarParams != NULL) { - printf("polarParams[%d] = %d, %d, %d\n", i, - polarParams->idx>>24, (polarParams->idx>>8)&0xFFFF, polarParams->idx&0xFF); + printf("polarParams[%d] = %d, %d, %d\n", + i, + polarParams->idx >> 24, + (polarParams->idx >> 8) & 0xFFFF, + polarParams->idx & 0xFF); polarParams = polarParams->nextPtr; i++; } @@ -271,11 +278,18 @@ void nr_polar_print_polarParams() { return; } -uint16_t nr_polar_aggregation_prime (uint8_t aggregation_level) { - if (aggregation_level == 0) return 0; - else if (aggregation_level == 1) return NR_POLAR_AGGREGATION_LEVEL_1_PRIME; - else if (aggregation_level == 2) return NR_POLAR_AGGREGATION_LEVEL_2_PRIME; - else if (aggregation_level == 4) return NR_POLAR_AGGREGATION_LEVEL_4_PRIME; - else if (aggregation_level == 8) return NR_POLAR_AGGREGATION_LEVEL_8_PRIME; - else return NR_POLAR_AGGREGATION_LEVEL_16_PRIME; //aggregation_level == 16 +uint16_t nr_polar_aggregation_prime(uint8_t aggregation_level) +{ + if (aggregation_level == 0) + return 0; + else if (aggregation_level == 1) + return NR_POLAR_AGGREGATION_LEVEL_1_PRIME; + else if (aggregation_level == 2) + return NR_POLAR_AGGREGATION_LEVEL_2_PRIME; + else if (aggregation_level == 4) + return NR_POLAR_AGGREGATION_LEVEL_4_PRIME; + else if (aggregation_level == 8) + return NR_POLAR_AGGREGATION_LEVEL_8_PRIME; + else + return NR_POLAR_AGGREGATION_LEVEL_16_PRIME; // aggregation_level == 16 } diff --git a/openair1/PHY/CODING/nrPolar_tools/nr_polar_interleaving_pattern.c b/openair1/PHY/CODING/nrPolar_tools/nr_polar_interleaving_pattern.c index 264ef9731d..6002c1ed82 100644 --- a/openair1/PHY/CODING/nrPolar_tools/nr_polar_interleaving_pattern.c +++ b/openair1/PHY/CODING/nrPolar_tools/nr_polar_interleaving_pattern.c @@ -28,12 +28,13 @@ * \email turker.yilmaz@eurecom.fr * \note * \warning -*/ + */ #include "PHY/CODING/nrPolar_tools/nr_polar_defs.h" -void nr_polar_interleaving_pattern(uint16_t K, uint8_t I_IL, uint16_t *PI_k_){ - uint K_IL_max = 164, k = 0; +void nr_polar_interleaving_pattern(uint16_t K, uint8_t I_IL, uint16_t *PI_k_) +{ + uint K_IL_max = 164; uint8_t interleaving_pattern_table[164] = { 0, 2, 4, 7, 9, 14, 19, 20, 24, 25, 26, 28, 31, 34, 42, 45, 49, 50, 51, 53, 54, 56, 58, 59, 61, 62, 65, 66, 67, 69, 70, 71, 72, 76, 77, 81, 82, 83, 87, 88, 89, 91, 93, 95, 98, 101, 104, 106, @@ -44,10 +45,10 @@ void nr_polar_interleaving_pattern(uint16_t K, uint8_t I_IL, uint16_t *PI_k_){ 40, 146, 41, 147, 148, 149, 150, 151, 152, 153, 154, 155, 156, 157, 158, 159, 160, 161, 162, 163}; if (I_IL == 0) { - for (; k <= K - 1; k++) + for (int k = 0; k < K; k++) PI_k_[k] = k; } else { - for (int m = 0; m <= (K_IL_max - 1); m++) { + for (int m = 0, k = 0; m < K_IL_max; m++) { if (interleaving_pattern_table[m] >= (K_IL_max - K)) { PI_k_[k] = interleaving_pattern_table[m] - (K_IL_max - K); k++; diff --git a/openair1/PHY/CODING/nrPolar_tools/nr_polar_kernal_operation.c b/openair1/PHY/CODING/nrPolar_tools/nr_polar_kernal_operation.c index 81e7bb99f7..03f546a6e9 100644 --- a/openair1/PHY/CODING/nrPolar_tools/nr_polar_kernal_operation.c +++ b/openair1/PHY/CODING/nrPolar_tools/nr_polar_kernal_operation.c @@ -7,53 +7,48 @@ void nr_polar_kernal_operation(uint8_t *u, uint8_t *d, uint16_t N) { - // Martino's algorithm to avoid multiplication for the generating matrix of polar codes - - uint32_t i,j; + // Martino's algorithm to avoid multiplication for the generating matrix of polar codes - simde__m256i A,B,C,D,E,U,zerosOnly, OUT; - simde__m256i inc; - uint32_t dTest[8]; - uint32_t uArray[8]; - uint32_t k; - uint32_t incArray[8]; - - //initialisation - for(k=0; k<8; k++) - incArray[k]=k; - inc=simde_mm256_loadu_si256((simde__m256i const*)incArray); // 0, 1, ..., 7 to increase - - zerosOnly=simde_mm256_setzero_si256(); // for comparison + uint32_t i, j; - for(i=0; i If zero, then XOR with the u(j) - D=simde_mm256_cmpeq_epi32(C, zerosOnly); // compare with zero and use the result as mask - - E=simde_mm256_maskload_epi32((int const*)uArray, D); // load only some u(j)s for the XOR - OUT=simde_mm256_xor_si256(OUT, E); //32 bit x 8 + // initialisation + for (k = 0; k < 8; k++) + incArray[k] = k; + inc = simde_mm256_loadu_si256((simde__m256i const *)incArray); // 0, 1, ..., 7 to increase - } - simde_mm256_storeu_si256((simde__m256i*)dTest, OUT); + zerosOnly = simde_mm256_setzero_si256(); // for comparison - for(k=0; k<8; k++) // Conversion from 32 bits to 8 bits - { - d[i+k]=(uint8_t)dTest[k]; // With AVX512 there is an intrinsic to do it - } + for (i = 0; i < N; i += 8) { + B = simde_mm256_set1_epi32((int)i); // i, ..., i + B = simde_mm256_add_epi32(B, inc); // i, i+1, ..., i+7 - } + OUT = simde_mm256_setzero_si256(); // it will contain the result of all the XORs for the d(i)s + for (j = 0; j < N; j++) { + A = simde_mm256_set1_epi32((int)(j)); // j, j, ..., j + A = simde_mm256_sub_epi32(A, B); //(j-i), (j-(i+1)), ... (j-(i+7)) + + U = simde_mm256_set1_epi32((int)u[j]); + simde_mm256_storeu_si256((simde__m256i *)uArray, U); // u(j) ... u(j) for the maskload + + C = simde_mm256_and_si256(A, B); //(j-i)&i -> If zero, then XOR with the u(j) + D = simde_mm256_cmpeq_epi32(C, zerosOnly); // compare with zero and use the result as mask + + E = simde_mm256_maskload_epi32((int const *)uArray, D); // load only some u(j)s for the XOR + OUT = simde_mm256_xor_si256(OUT, E); // 32 bit x 8 + } + simde_mm256_storeu_si256((simde__m256i *)dTest, OUT); + + for (k = 0; k < 8; k++) // Conversion from 32 bits to 8 bits + { + d[i + k] = (uint8_t)dTest[k]; // With AVX512 there is an intrinsic to do it + } + } } diff --git a/openair1/PHY/CODING/nrPolar_tools/nr_polar_matrix_and_array.c b/openair1/PHY/CODING/nrPolar_tools/nr_polar_matrix_and_array.c index 0db423260f..d96be2ec25 100644 --- a/openair1/PHY/CODING/nrPolar_tools/nr_polar_matrix_and_array.c +++ b/openair1/PHY/CODING/nrPolar_tools/nr_polar_matrix_and_array.c @@ -28,7 +28,7 @@ * \email turker.yilmaz@eurecom.fr * \note * \warning -*/ + */ #include "PHY/CODING/nrPolar_tools/nr_polar_defs.h" @@ -47,7 +47,8 @@ void nr_matrix_multiplication_uint8_1D_uint8_2D(const uint8_t *matrix1, } // Modified Bubble Sort. -void nr_sort_asc_double_1D_array_ind(double *matrix, uint8_t *ind, uint8_t len) { +void nr_sort_asc_double_1D_array_ind(double *matrix, uint8_t *ind, uint8_t len) +{ for (int i = 0; i < len; i++) { int swaps = 0; for (int j = 0; j < (len - i) - 1; j++) { diff --git a/openair1/PHY/CODING/nrPolar_tools/nr_polar_pbch_defs.h b/openair1/PHY/CODING/nrPolar_tools/nr_polar_pbch_defs.h index 1904d1bd83..a9e59556bd 100644 --- a/openair1/PHY/CODING/nrPolar_tools/nr_polar_pbch_defs.h +++ b/openair1/PHY/CODING/nrPolar_tools/nr_polar_pbch_defs.h @@ -28,46 +28,70 @@ * \email turker.yilmaz@eurecom.fr * \note * \warning -*/ + */ #ifndef __NR_POLAR_PBCH_DEFS__H__ #define __NR_POLAR_PBCH_DEFS__H__ -#define NR_POLAR_PBCH_AGGREGATION_LEVEL 0 //uint8_t -#define NR_POLAR_PBCH_MESSAGE_TYPE 0 //int8_t -#define NR_POLAR_PSBCH_MESSAGE_TYPE 3 //int8_t -#define NR_POLAR_PBCH_PAYLOAD_BITS 32 //uint16_t +#define NR_POLAR_PBCH_AGGREGATION_LEVEL 0 // uint8_t +#define NR_POLAR_PBCH_MESSAGE_TYPE 0 // int8_t +#define NR_POLAR_PSBCH_MESSAGE_TYPE 3 // int8_t +#define NR_POLAR_PBCH_PAYLOAD_BITS 32 // uint16_t #define NR_POLAR_PBCH_CRC_PARITY_BITS 24 #define NR_POLAR_PBCH_CRC_ERROR_CORRECTION_BITS 3 -//Assumed 3 by 3GPP when NR_POLAR_PBCH_L>8 to meet false alarm rate requirements. +// Assumed 3 by 3GPP when NR_POLAR_PBCH_L>8 to meet false alarm rate requirements. -//Sec. 7.1.4: Channel Coding -#define NR_POLAR_PBCH_N_MAX 9 //uint8_t -#define NR_POLAR_PBCH_I_IL 1 //uint8_t -#define NR_POLAR_PBCH_I_SEG 0 //uint8_t -#define NR_POLAR_PBCH_N_PC 0 //uint8_t -#define NR_POLAR_PBCH_N_PC_WM 0 //uint8_t -//#define NR_POLAR_PBCH_N 512 //uint16_t +// Sec. 7.1.4: Channel Coding +#define NR_POLAR_PBCH_N_MAX 9 // uint8_t +#define NR_POLAR_PBCH_I_IL 1 // uint8_t +#define NR_POLAR_PBCH_I_SEG 0 // uint8_t +#define NR_POLAR_PBCH_N_PC 0 // uint8_t +#define NR_POLAR_PBCH_N_PC_WM 0 // uint8_t +// #define NR_POLAR_PBCH_N 512 //uint16_t -//Sec. 7.1.5: Rate Matching -#define NR_POLAR_PBCH_I_BIL 0 //uint8_t -#define NR_POLAR_PBCH_E 864 //uint16_t +// Sec. 7.1.5: Rate Matching +#define NR_POLAR_PBCH_I_BIL 0 // uint8_t +#define NR_POLAR_PBCH_E 864 // uint16_t #define NR_POLAR_PBCH_E_DWORD 27 // NR_POLAR_PBCH_E/32 -#define NR_POLAR_PSBCH_E 1792 //uint16_t +#define NR_POLAR_PSBCH_E 1792 // uint16_t #define NR_POLAR_PSBCH_E_DWORD 56 // NR_POLAR_PSBCH_E/32 /* * TEST CODE */ -//#define DEBUG_POLAR -// Usage in code: -//#ifdef DEBUG_POLAR +// #define DEBUG_POLAR +// Usage in code: +// #ifdef DEBUG_POLAR //... -//#endif +// #endif -//unsigned int testPayload0=0x00000000, testPayload1=0xffffffff; //payload1=~payload0; -//unsigned int testPayload2=0xa5a5a5a5; //testPayload3=0xb3f02c82; +// unsigned int testPayload0=0x00000000, testPayload1=0xffffffff; //payload1=~payload0; +// unsigned int testPayload2=0xa5a5a5a5; //testPayload3=0xb3f02c82; -//double testReceivedPayload3[NR_POLAR_PBCH_E] = {-1, 1, 1, 1, 1, -1, -1, -1, -1, -1, -1, 1, 1, 1, 1, -1, -1, -1, 1, 1, 1, 1, -1, -1, -1, 1, -1, 1, -1, 1, -1, 1, 1, -1, 1, 1, 1, -1, -1, -1, 1, 1, 1, -1, 1, 1, -1, 1, 1, -1, 1, -1, -1, 1, 1, -1, 1, 1, -1, -1, -1, -1, -1, -1, 1, 1, 1, 1, 1, 1, -1, -1, 1, -1, 1, -1, -1, 1, 1, -1, -1, -1, -1, 1, 1, 1, -1, 1, -1, 1, 1, 1, -1, 1, -1, -1, 1, -1, -1, 1, 1, -1, -1, 1, 1, 1, -1, -1, 1, 1, -1, -1, -1, -1, 1, -1, -1, -1, 1, -1, -1, 1, 1, 1, 1, -1, -1, -1, -1, 1, -1, -1, 1, -1, 1, 1, 1, 1, -1, 1, -1, -1, 1, -1, 1, -1, -1, -1, -1, 1, 1, 1, -1, -1, -1, 1, 1, 1, 1, -1, -1, -1, -1, -1, 1, 1, 1, 1, 1, -1, -1, 1, 1, -1, -1, 1, 1, 1, -1, -1, -1, -1, 1, 1, -1, 1, -1, 1, -1, 1, -1, 1, 1, -1, -1, -1, 1, -1, 1, 1, -1, -1, 1, -1, -1, -1, -1, 1, -1, 1, -1, -1, -1, 1, 1, 1, 1, 1, 1, -1, 1, 1, -1, 1, 1, 1, -1, -1, 1, 1, 1, 1, -1, 1, 1, -1, 1, -1, 1, -1, -1, -1, -1, -1, -1, -1, 1, 1, 1, -1, 1, -1, -1, 1, 1, -1, 1, -1, -1, 1, -1, 1, -1, 1, -1, -1, -1, -1, 1, 1, -1, -1, -1, 1, -1, 1, 1, -1, -1, 1, 1, 1, -1, -1, -1, -1, -1, -1, -1, -1, 1, -1, 1, 1, 1, -1, 1, -1, 1, 1, 1, -1, -1, -1, 1, 1, 1, -1, -1, -1, 1, -1, -1, 1, 1, 1, -1, 1, -1, -1, 1, -1, 1, -1, 1, -1, 1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 1, 1, -1, -1, 1, 1, -1, 1, 1, -1, -1, 1, 1, -1, -1, -1, -1, -1, 1, -1, -1, -1, 1, 1, -1, 1, 1, -1, 1, -1, -1, 1, 1, -1, 1, 1, 1, -1, 1, -1, 1, 1, 1, 1, -1, -1, -1, 1, -1, 1, 1, -1, 1, -1, -1, 1, 1, -1, 1, -1, -1, 1, -1, 1, 1, 1, 1, -1, -1, -1, -1, 1, -1, -1, 1, 1, -1, -1, 1, -1, 1, 1, 1, -1, 1, -1, -1, -1, -1, 1, -1, -1, -1, -1, 1, -1, 1, 1, -1, 1, -1, 1, -1, -1, -1, -1, -1, 1, 1, -1, -1, -1, -1, 1, 1, -1, -1, -1, -1, -1, 1, 1, -1, 1, -1, 1, -1, 1, 1, -1, 1, -1, -1, -1, 1, 1, -1, 1, 1, 1, -1, -1, -1, -1, 1, -1, 1, -1, 1, -1, 1, -1, -1, -1, -1, -1, -1, -1, -1, 1, 1, 1, -1, 1, 1, 1, -1, 1, -1, 1, 1, -1, 1, -1, -1, -1, 1, 1, 1, 1, -1, -1, -1, -1, -1, -1, 1, 1, 1, 1, -1, -1, -1, 1, 1, 1, 1, -1, -1, -1, 1, -1, 1, -1, 1, -1, 1, 1, -1, 1, 1, 1, -1, -1, -1, 1, 1, 1, -1, 1, 1, -1, 1, 1, -1, 1, -1, -1, 1, 1, -1, 1, 1, -1, -1, -1, -1, -1, -1, 1, 1, 1, 1, 1, 1, -1, -1, 1, -1, 1, -1, -1, 1, 1, -1, -1, -1, -1, 1, 1, 1, -1, 1, -1, 1, 1, 1, -1, 1, -1, -1, 1, -1, -1, 1, 1, -1, -1, 1, 1, 1, -1, -1, 1, 1, -1, -1, -1, -1, 1, -1, -1, -1, 1, -1, -1, 1, 1, 1, 1, -1, -1, -1, -1, 1, -1, -1, 1, -1, 1, 1, 1, 1, -1, 1, -1, -1, 1, -1, 1, -1, -1, -1, -1, 1, 1, 1, -1, -1, -1, 1, 1, 1, 1, -1, -1, -1, -1, -1, 1, 1, 1, 1, 1, -1, -1, 1, 1, -1, -1, 1, 1, 1, -1, -1, -1, -1, 1, 1, -1, 1, -1, 1, -1, 1, -1, 1, 1, -1, -1, -1, 1, -1, 1, 1, -1, -1, 1, -1, -1, -1, -1, 1, -1, 1, -1, -1, -1, 1, 1, 1, 1, 1, 1, -1, 1, 1, -1, 1, 1, 1, -1, -1, 1, 1, 1, 1, -1, 1, 1, -1, 1, -1, 1, -1, -1, -1, -1, -1, -1, -1, 1, 1, 1, -1, 1, -1, -1, 1, 1, -1, 1, -1, -1, 1, -1, 1, -1, 1, -1, -1, -1, -1, 1, 1, -1, -1, -1, 1, -1, 1, 1, -1, -1, 1, 1, 1, -1, -1, -1, -1, -1, -1, -1, -1, 1, -1, 1, 1, 1, -1, 1, -1, 1, 1, 1, -1, -1, -1, 1, 1, 1, -1, -1, -1, 1, -1, -1, 1, 1, 1, -1, 1, -1, -1, 1, -1, 1, -1, 1, -1, 1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 1, 1, -1, -1, 1, 1, -1, 1, 1, -1, -1, 1, 1, -1, -1}; +// double testReceivedPayload3[NR_POLAR_PBCH_E] = {-1, 1, 1, 1, 1, -1, -1, -1, -1, -1, -1, 1, 1, 1, 1, -1, -1, -1, 1, 1, 1, 1, -1, +// -1, -1, 1, -1, 1, -1, 1, -1, 1, 1, -1, 1, 1, 1, -1, -1, -1, 1, 1, 1, -1, 1, 1, -1, 1, 1, -1, 1, -1, -1, 1, 1, -1, 1, 1, -1, -1, +// -1, -1, -1, -1, 1, 1, 1, 1, 1, 1, -1, -1, 1, -1, 1, -1, -1, 1, 1, -1, -1, -1, -1, 1, 1, 1, -1, 1, -1, 1, 1, 1, -1, 1, -1, -1, 1, +// -1, -1, 1, 1, -1, -1, 1, 1, 1, -1, -1, 1, 1, -1, -1, -1, -1, 1, -1, -1, -1, 1, -1, -1, 1, 1, 1, 1, -1, -1, -1, -1, 1, -1, -1, 1, +// -1, 1, 1, 1, 1, -1, 1, -1, -1, 1, -1, 1, -1, -1, -1, -1, 1, 1, 1, -1, -1, -1, 1, 1, 1, 1, -1, -1, -1, -1, -1, 1, 1, 1, 1, 1, -1, +// -1, 1, 1, -1, -1, 1, 1, 1, -1, -1, -1, -1, 1, 1, -1, 1, -1, 1, -1, 1, -1, 1, 1, -1, -1, -1, 1, -1, 1, 1, -1, -1, 1, -1, -1, -1, +// -1, 1, -1, 1, -1, -1, -1, 1, 1, 1, 1, 1, 1, -1, 1, 1, -1, 1, 1, 1, -1, -1, 1, 1, 1, 1, -1, 1, 1, -1, 1, -1, 1, -1, -1, -1, -1, +// -1, -1, -1, 1, 1, 1, -1, 1, -1, -1, 1, 1, -1, 1, -1, -1, 1, -1, 1, -1, 1, -1, -1, -1, -1, 1, 1, -1, -1, -1, 1, -1, 1, 1, -1, -1, +// 1, 1, 1, -1, -1, -1, -1, -1, -1, -1, -1, 1, -1, 1, 1, 1, -1, 1, -1, 1, 1, 1, -1, -1, -1, 1, 1, 1, -1, -1, -1, 1, -1, -1, 1, 1, 1, +// -1, 1, -1, -1, 1, -1, 1, -1, 1, -1, 1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 1, 1, -1, -1, 1, 1, -1, 1, 1, -1, -1, 1, 1, -1, +// -1, -1, -1, -1, 1, -1, -1, -1, 1, 1, -1, 1, 1, -1, 1, -1, -1, 1, 1, -1, 1, 1, 1, -1, 1, -1, 1, 1, 1, 1, -1, -1, -1, 1, -1, 1, 1, +// -1, 1, -1, -1, 1, 1, -1, 1, -1, -1, 1, -1, 1, 1, 1, 1, -1, -1, -1, -1, 1, -1, -1, 1, 1, -1, -1, 1, -1, 1, 1, 1, -1, 1, -1, -1, +// -1, -1, 1, -1, -1, -1, -1, 1, -1, 1, 1, -1, 1, -1, 1, -1, -1, -1, -1, -1, 1, 1, -1, -1, -1, -1, 1, 1, -1, -1, -1, -1, -1, 1, 1, +// -1, 1, -1, 1, -1, 1, 1, -1, 1, -1, -1, -1, 1, 1, -1, 1, 1, 1, -1, -1, -1, -1, 1, -1, 1, -1, 1, -1, 1, -1, -1, -1, -1, -1, -1, -1, +// -1, 1, 1, 1, -1, 1, 1, 1, -1, 1, -1, 1, 1, -1, 1, -1, -1, -1, 1, 1, 1, 1, -1, -1, -1, -1, -1, -1, 1, 1, 1, 1, -1, -1, -1, 1, 1, +// 1, 1, -1, -1, -1, 1, -1, 1, -1, 1, -1, 1, 1, -1, 1, 1, 1, -1, -1, -1, 1, 1, 1, -1, 1, 1, -1, 1, 1, -1, 1, -1, -1, 1, 1, -1, 1, 1, +// -1, -1, -1, -1, -1, -1, 1, 1, 1, 1, 1, 1, -1, -1, 1, -1, 1, -1, -1, 1, 1, -1, -1, -1, -1, 1, 1, 1, -1, 1, -1, 1, 1, 1, -1, 1, -1, +// -1, 1, -1, -1, 1, 1, -1, -1, 1, 1, 1, -1, -1, 1, 1, -1, -1, -1, -1, 1, -1, -1, -1, 1, -1, -1, 1, 1, 1, 1, -1, -1, -1, -1, 1, -1, +// -1, 1, -1, 1, 1, 1, 1, -1, 1, -1, -1, 1, -1, 1, -1, -1, -1, -1, 1, 1, 1, -1, -1, -1, 1, 1, 1, 1, -1, -1, -1, -1, -1, 1, 1, 1, 1, +// 1, -1, -1, 1, 1, -1, -1, 1, 1, 1, -1, -1, -1, -1, 1, 1, -1, 1, -1, 1, -1, 1, -1, 1, 1, -1, -1, -1, 1, -1, 1, 1, -1, -1, 1, -1, +// -1, -1, -1, 1, -1, 1, -1, -1, -1, 1, 1, 1, 1, 1, 1, -1, 1, 1, -1, 1, 1, 1, -1, -1, 1, 1, 1, 1, -1, 1, 1, -1, 1, -1, 1, -1, -1, +// -1, -1, -1, -1, -1, 1, 1, 1, -1, 1, -1, -1, 1, 1, -1, 1, -1, -1, 1, -1, 1, -1, 1, -1, -1, -1, -1, 1, 1, -1, -1, -1, 1, -1, 1, 1, +// -1, -1, 1, 1, 1, -1, -1, -1, -1, -1, -1, -1, -1, 1, -1, 1, 1, 1, -1, 1, -1, 1, 1, 1, -1, -1, -1, 1, 1, 1, -1, -1, -1, 1, -1, -1, +// 1, 1, 1, -1, 1, -1, -1, 1, -1, 1, -1, 1, -1, 1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 1, 1, -1, -1, 1, 1, -1, 1, 1, -1, -1, 1, +// 1, -1, -1}; #endif diff --git a/openair1/PHY/CODING/nrPolar_tools/nr_polar_procedures.c b/openair1/PHY/CODING/nrPolar_tools/nr_polar_procedures.c index a4d3bb301e..cf1df52ac0 100644 --- a/openair1/PHY/CODING/nrPolar_tools/nr_polar_procedures.c +++ b/openair1/PHY/CODING/nrPolar_tools/nr_polar_procedures.c @@ -89,42 +89,7 @@ void nr_polar_generate_u(uint64_t *u, } } -void nr_polar_info_extraction_from_u(uint64_t *Cprime, - const uint8_t *u, - const uint8_t *information_bit_pattern, - const uint8_t *parity_check_bit_pattern, - uint16_t N, - uint8_t n_pc) -{ - int k = 0; - - if (n_pc > 0) { - for (int n = 0; n < N; n++) { - if (information_bit_pattern[n] == 1) { - if (parity_check_bit_pattern[n] == 0) { - int k1 = k >> 6; - int k2 = k - (k1 << 6); - Cprime[k1] |= (uint64_t)u[n] << k2; - k++; - } - } - } - - } else { - for (int n = 0; n < N; n++) { - if (information_bit_pattern[n] == 1) { - int k1 = k >> 6; - int k2 = k - (k1 << 6); - Cprime[k1] |= (uint64_t)u[n] << k2; - k++; - } - } - } -} - - -static -void encode_packed_byte(uint8_t* in_out) +static void encode_packed_byte(uint8_t *in_out) { // *in_out ^= 0xAA & (*in_out << 1); // *in_out ^= 0xCC & (*in_out << 2); @@ -135,36 +100,33 @@ void encode_packed_byte(uint8_t* in_out) *in_out ^= *in_out >> 4; } -static -void polar_encode_bits(uint8_t* in_out, size_t N) +static void polar_encode_bits(uint8_t *in_out, size_t N) { size_t const num_bytes_per_block = N >> 3; - for(size_t i = 0; i < num_bytes_per_block; ++i){ + for (size_t i = 0; i < num_bytes_per_block; ++i) { encode_packed_byte(&in_out[i]); } } -static -uint32_t log2_floor(uint32_t x) +static uint32_t log2_floor(uint32_t x) { - if(x == 0) - return 0; + if (x == 0) + return 0; uint32_t clz = __builtin_clz(x); return 31U - clz; } -static -void polar_encode_bytes(uint8_t* in_out, size_t N) +static void polar_encode_bytes(uint8_t *in_out, size_t N) { size_t brnch_sz = 1; size_t n_brnch = N >> 4; - size_t const blck_pwr = log2_floor(N); + size_t const blck_pwr = log2_floor(N); for (size_t stage = 3; stage < blck_pwr; ++stage) { for (size_t brnch = 0; brnch < n_brnch; ++brnch) { - for(size_t byte = 0; byte < brnch_sz; ++byte){ - size_t const dst = 2*brnch_sz*brnch + byte; - in_out[dst] ^= in_out[dst + brnch_sz]; - } + for (size_t byte = 0; byte < brnch_sz; ++byte) { + size_t const dst = 2 * brnch_sz * brnch + byte; + in_out[dst] ^= in_out[dst + brnch_sz]; + } } n_brnch >>= 1; brnch_sz <<= 1; @@ -173,12 +135,12 @@ void polar_encode_bytes(uint8_t* in_out, size_t N) void nr_polar_uxG(uint8_t const *u, size_t N, uint8_t *D2) { - assert(N > 7); - uint8_t tmp[N/8]; - for(int i = 0; i < N/8; ++i) - tmp[i] = u[N/8 - 1 - i]; + assert(N > 7); + uint8_t tmp[N / 8]; + for (int i = 0; i < N / 8; ++i) + tmp[i] = u[N / 8 - 1 - i]; - reverse_bits_u8(tmp, N/8, D2); + reverse_bits_u8(tmp, N / 8, D2); // Do the encoding/xor for the bottom 3 levels of the tree. // Thus, data remaining to encode, is in 2^3 type. @@ -187,49 +149,40 @@ void nr_polar_uxG(uint8_t const *u, size_t N, uint8_t *D2) polar_encode_bytes(D2, N); } -void nr_polar_bit_insertion(uint8_t *input, - uint8_t *output, - uint16_t N, - uint16_t K, - int16_t *Q_I_N, - int16_t *Q_PC_N, - uint8_t n_PC) +void nr_polar_bit_insertion(uint8_t *input, uint8_t *output, uint16_t N, uint16_t K, int16_t *Q_I_N, int16_t *Q_PC_N, uint8_t n_PC) { int k = 0; - if (n_PC>0) { + if (n_PC > 0) { /* * */ } else { - for (int n=0; n<=N-1; n++) { + for (int n = 0; n <= N - 1; n++) { output[n] = 0; - for (int m=0; m<=(K+n_PC)-1; m++) { - if ( n == Q_I_N[m]) { + for (int m = 0; m <= (K + n_PC) - 1; m++) { + if (n == Q_I_N[m]) { output[n] = input[k]; k++; break; - } + } } } } } - -uint32_t nr_polar_output_length(uint16_t K, - uint16_t E, - uint8_t n_max) +uint32_t nr_polar_output_length(uint16_t K, uint16_t E, uint8_t n_max) { int n_1, n_2, n_min = 5; - double R_min=1.0/8; - - if ( (E <= (9.0/8)*pow(2,ceil(log2(E))-1)) && (K/E < 9.0/16) ) { - n_1 = ceil(log2(E))-1; + double R_min = 1.0 / 8; + + if ((E <= (9.0 / 8) * pow(2, ceil(log2(E)) - 1)) && (K / E < 9.0 / 16)) { + n_1 = ceil(log2(E)) - 1; } else { n_1 = ceil(log2(E)); } - - n_2 = ceil(log2(K/R_min)); + + n_2 = ceil(log2(K / R_min)); int n = n_max; if (n > n_1) @@ -240,9 +193,9 @@ uint32_t nr_polar_output_length(uint16_t K, n = n_min; /*printf("nr_polar_output_length: K %d, E %d, n %d (n_max %d,n_min %d, n_1 %d,n_2 %d)\n", - K,E,n,n_max,n_min,n_1,n_2); - exit(-1);*/ - return ((uint32_t) pow(2.0,n)); //=polar_code_output_length + K,E,n,n_max,n_min,n_1,n_2); + exit(-1);*/ + return ((uint32_t)pow(2.0, n)); //=polar_code_output_length } void nr_polar_info_bit_pattern(uint8_t *ibp, @@ -303,7 +256,7 @@ void nr_polar_info_bit_pattern(uint8_t *ibp, const int end = Q_Ftmp_N[N]; int m; for (m = 0; m <= end; m++) { - AssertFatal(m < N+1, "Buffer boundary overflow"); + AssertFatal(m < N + 1, "Buffer boundary overflow"); if (Q_0_Nminus1[n] == Q_Ftmp_N[m]) { break; } @@ -343,7 +296,6 @@ void nr_polar_info_bit_pattern(uint8_t *ibp, // Information and Parity Chack Bit Pattern for (int n = 0; n <= N - 1; n++) { - ibp[n] = 0; for (int m = 0; m <= (K + n_PC) - 1; m++) { if (n == Q_I_N[m]) { @@ -362,11 +314,7 @@ void nr_polar_info_bit_pattern(uint8_t *ibp, } } - -void nr_polar_info_bit_extraction(uint8_t *input, - uint8_t *output, - uint8_t *pattern, - uint16_t size) +void nr_polar_info_bit_extraction(uint8_t *input, uint8_t *output, uint8_t *pattern, uint16_t size) { uint16_t j = 0; for (int i = 0; i < size; i++) { @@ -377,13 +325,7 @@ void nr_polar_info_bit_extraction(uint8_t *input, } } - -void nr_polar_rate_matching_pattern(uint16_t *rmp, - uint16_t *J, - const uint8_t *P_i_, - uint16_t K, - uint16_t N, - uint16_t E) +void nr_polar_rate_matching_pattern(uint16_t *rmp, uint16_t *J, const uint8_t *P_i_, uint16_t K, uint16_t N, uint16_t E) { uint16_t d[N]; for (int m = 0; m < N; m++) @@ -391,127 +333,49 @@ void nr_polar_rate_matching_pattern(uint16_t *rmp, uint16_t y[N]; memset(y, 0, sizeof(y)); - for (int m=0; m<=N-1; m++){ + for (int m = 0; m <= N - 1; m++) { int i = floor((32 * m) / N); - J[m] = (P_i_[i]*(N/32)) + (m%(N/32)); + J[m] = (P_i_[i] * (N / 32)) + (m % (N / 32)); y[m] = d[J[m]]; } - if (E>=N) { //repetition - for (int k=0; k<=E-1; k++) { + if (E >= N) { // repetition + for (int k = 0; k <= E - 1; k++) { int ind = (k % N); - rmp[k]=y[ind]; + rmp[k] = y[ind]; } } else { - if ( (K/(double)E) <= (7.0/16) ) { //puncturing - for (int k=0; k<=E-1; k++) { - rmp[k]=y[k+N-E]; + if ((K / (double)E) <= (7.0 / 16)) { // puncturing + for (int k = 0; k <= E - 1; k++) { + rmp[k] = y[k + N - E]; } - } else { //shortening - for (int k=0; k<=E-1; k++) { - rmp[k]=y[k]; + } else { // shortening + for (int k = 0; k <= E - 1; k++) { + rmp[k] = y[k]; } } } } - -void nr_polar_rate_matching(double *input, - double *output, - uint16_t *rmp, - uint16_t K, - uint16_t N, - uint16_t E) +void nr_polar_rate_matching(double *input, double *output, uint16_t *rmp, uint16_t K, uint16_t N, uint16_t E) { - if (E>=N) { //repetition - for (int i=0; i<=N-1; i++) output[i]=0; - for (int i=0; i<=E-1; i++){ - output[rmp[i]]+=input[i]; + if (E >= N) { // repetition + for (int i = 0; i <= N - 1; i++) + output[i] = 0; + for (int i = 0; i <= E - 1; i++) { + output[rmp[i]] += input[i]; } } else { - if ( (K/(double)E) <= (7.0/16) ) { //puncturing + if ((K / (double)E) <= (7.0 / 16)) { // puncturing for (int i = 0; i <= N - 1; i++) output[i] = 0; - } else { //shortening + } else { // shortening for (int i = 0; i <= N - 1; i++) output[i] = INFINITY; } - for (int i=0; i<=E-1; i++){ - output[rmp[i]]=input[i]; - } - } -} - -/* - * De-interleaving of coded bits implementation - * TS 138.212: Section 5.4.1.3 - Interleaving of coded bits - */ -void nr_polar_rm_deinterleaving_cb(const int16_t *in, int16_t *out, const uint16_t E) -{ - int T = ceil((sqrt(8 * E + 1) - 1) / 2); - int v_tab[T][T]; - memset(v_tab, 0, sizeof(v_tab)); - int k = 0; - for (int i = 0; i < T; i++) { - for (int j = 0; j < T - i; j++) { - if (k < E) { - v_tab[i][j] = k + 1; - } - k++; - } - } - - int v[T][T]; - k = 0; - for (int j = 0; j < T; j++) { - for (int i = 0; i < T - j; i++) { - if (k < E && v_tab[i][j] != 0) { - v[i][j] = in[k]; - k++; - } else { - v[i][j] = INT_MAX; - } - } - } - - k = 0; - memset(out, 0, E * sizeof(*out)); - for (int i = 0; i < T; i++) { - for (int j = 0; j < T - i; j++) { - if (v[i][j] != INT_MAX) { - out[k] = v[i][j]; - k++; - } - } - } -} - -void nr_polar_rate_matching_int16(int16_t *input, - int16_t *output, - const uint16_t *rmp, - const uint16_t K, - const uint16_t N, - const uint16_t E, - const uint8_t i_bil) -{ - if (i_bil == 1) { - nr_polar_rm_deinterleaving_cb(input, input, E); - } - - if (E >= N) { // repetition - memset(output, 0, N * sizeof(*output)); - for (int i = 0; i <= E - 1; i++) - output[rmp[i]] += input[i]; - } else { - if ((K / (double)E) <= (7.0 / 16)) - memset(output, 0, N * sizeof(*output)); // puncturing - else { // shortening - for (int i = 0; i <= N - 1; i++) - output[i] = 32767; // instead of INFINITY, to prevent [-Woverflow] - } - - for (int i = 0; i <= E - 1; i++) + for (int i = 0; i <= E - 1; i++) { output[rmp[i]] = input[i]; + } } } diff --git a/openair1/PHY/CODING/nrPolar_tools/nr_polar_pucch_defs.h b/openair1/PHY/CODING/nrPolar_tools/nr_polar_pucch_defs.h index cf23982752..2b1fa8c6a7 100644 --- a/openair1/PHY/CODING/nrPolar_tools/nr_polar_pucch_defs.h +++ b/openair1/PHY/CODING/nrPolar_tools/nr_polar_pucch_defs.h @@ -7,22 +7,21 @@ #define NR_POLAR_PUCCH_PAYLOAD_BITS 16 -//Ref. 38-212 v15.0.1 -#define NR_POLAR_PUCCH_N_MAX 10 //uint8_t <------ -#define NR_POLAR_PUCCH_I_IL 1 //uint8_t <--- interleaving: if 0 no interleaving -#define NR_POLAR_PUCCH_N_PC 3 //uint8_t <-- or zero ?? -#define NR_POLAR_PUCCH_N_PC_WM 0 //uint8_t -//#define NR_POLAR_PUCCH_N 512 //uint16_t - -//Ref. 38-212 v15.0.1, Section 7.1.5: Rate Matching -#define NR_POLAR_PUCCH_I_BIL 0 //uint8_t -#define NR_POLAR_PUCCH_E 864 //uint16_t +// Ref. 38-212 v15.0.1 +#define NR_POLAR_PUCCH_N_MAX 10 // uint8_t <------ +#define NR_POLAR_PUCCH_I_IL 1 // uint8_t <--- interleaving: if 0 no interleaving +#define NR_POLAR_PUCCH_N_PC 3 // uint8_t <-- or zero ?? +#define NR_POLAR_PUCCH_N_PC_WM 0 // uint8_t +// #define NR_POLAR_PUCCH_N 512 //uint16_t +// Ref. 38-212 v15.0.1, Section 7.1.5: Rate Matching +#define NR_POLAR_PUCCH_I_BIL 0 // uint8_t +#define NR_POLAR_PUCCH_E 864 // uint16_t /* * TEST CODE */ -//unsigned int testPayload0=0x00000000, testPayload1=0xffffffff; //payload1=~payload0; -//unsigned int testPayload2=0xa5a5a5a5, testPayload3=0xb3f02c82; +// unsigned int testPayload0=0x00000000, testPayload1=0xffffffff; //payload1=~payload0; +// unsigned int testPayload2=0xa5a5a5a5, testPayload3=0xb3f02c82; #endif diff --git a/openair1/PHY/CODING/nrPolar_tools/nr_polar_rate_match.c b/openair1/PHY/CODING/nrPolar_tools/nr_polar_rate_match.c index ffa37c9549..f5bca4a9b7 100644 --- a/openair1/PHY/CODING/nrPolar_tools/nr_polar_rate_match.c +++ b/openair1/PHY/CODING/nrPolar_tools/nr_polar_rate_match.c @@ -22,7 +22,8 @@ #include #include "PHY/CODING/nrPolar_tools/nr_polar_defs.h" -void nr_polar_rate_matching_pattern(uint16_t *rmp, uint16_t *J, const uint8_t *P_i_, uint16_t K, uint16_t N, uint16_t E){ +void nr_polar_rate_matching_pattern(uint16_t *rmp, uint16_t *J, const uint8_t *P_i_, uint16_t K, uint16_t N, uint16_t E) +{ int d[N]; int y[N]; @@ -53,8 +54,8 @@ void nr_polar_rate_matching_pattern(uint16_t *rmp, uint16_t *J, const uint8_t *P } } - -void nr_polar_rate_matching(double *input, double *output, uint16_t *rmp, uint16_t K, uint16_t N, uint16_t E){ +void nr_polar_rate_matching(double *input, double *output, uint16_t *rmp, uint16_t K, uint16_t N, uint16_t E) +{ if (E >= N) { // repetition for (int i = 0; i <= N - 1; i++) output[i] = 0; diff --git a/openair1/PHY/CODING/nrPolar_tools/nr_polar_sequence_pattern.c b/openair1/PHY/CODING/nrPolar_tools/nr_polar_sequence_pattern.c index 2a64925fde..e4633c91a3 100644 --- a/openair1/PHY/CODING/nrPolar_tools/nr_polar_sequence_pattern.c +++ b/openair1/PHY/CODING/nrPolar_tools/nr_polar_sequence_pattern.c @@ -21,16 +21,103 @@ #include "PHY/CODING/nrPolar_tools/nr_polar_defs.h" -static const uint16_t Q_0_Nminus1_1[2] = { 0, 1 }; -static const uint16_t Q_0_Nminus1_2[4] = { 0, 1, 2, 3 }; -static const uint16_t Q_0_Nminus1_3[8] = { 0, 1, 2, 4, 3, 5, 6, 7 }; -static const uint16_t Q_0_Nminus1_4[16] = { 0, 1, 2, 4, 8, 3, 5, 9, 6, 10, 12, 7, 11, 13, 14, 15 }; -static const uint16_t Q_0_Nminus1_5[32] = { 0, 1, 2, 4, 8, 16, 3, 5, 9, 6, 17, 10, 18, 12, 20, 24, 7, 11, 19, 13, 14, 21, 26, 25, 22, 28, 15, 23, 27, 29, 30, 31 }; -static const uint16_t Q_0_Nminus1_6[64] = { 0, 1, 2, 4, 8, 16, 32, 3, 5, 9, 6, 17, 10, 18, 12, 33, 20, 34, 24, 36, 7, 11, 40, 19, 13, 48, 14, 21, 35, 26, 37, 25, 22, 38, 41, 28, 42, 49, 44, 50, 15, 52, 23, 56, 27, 39, 29, 43, 30, 45, 51, 46, 53, 54, 57, 58, 60, 31, 47, 55, 59, 61, 62, 63 }; -static const uint16_t Q_0_Nminus1_7[128] = { 0, 1, 2, 4, 8, 16, 32, 3, 5, 64, 9, 6, 17, 10, 18, 12, 33, 65, 20, 34, 24, 36, 7, 66, 11, 40, 68, 19, 13, 48, 14, 72, 21, 35, 26, 80, 37, 25, 22, 38, 96, 67, 41, 28, 69, 42, 49, 74, 70, 44, 81, 50, 73, 15, 52, 23, 76, 82, 56, 27, 97, 39, 84, 29, 43, 98, 88, 30, 71, 45, 100, 51, 46, 75, 104, 53, 77, 54, 83, 57, 112, 78, 85, 58, 99, 86, 60, 89, 101, 31, 90, 102, 105, 92, 47, 106, 55, 113, 79, 108, 59, 114, 87, 116, 61, 91, 120, 62, 103, 93, 107, 94, 109, 115, 110, 117, 118, 121, 122, 63, 124, 95, 111, 119, 123, 125, 126, 127 }; -static const uint16_t Q_0_Nminus1_8[256] = { 0, 1, 2, 4, 8, 16, 32, 3, 5, 64, 9, 6, 17, 10, 18, 128, 12, 33, 65, 20, 34, 24, 36, 7, 129, 66, 11, 40, 68, 130, 19, 13, 48, 14, 72, 21, 132, 35, 26, 80, 37, 25, 22, 136, 38, 96, 67, 41, 144, 28, 69, 42, 49, 74, 160, 192, 70, 44, 131, 81, 50, 73, 15, 133, 52, 23, 134, 76, 137, 82, 56, 27, 97, 39, 84, 138, 145, 29, 43, 98, 88, 140, 30, 146, 71, 161, 45, 100, 51, 148, 46, 75, 104, 162, 53, 193, 152, 77, 164, 54, 83, 57, 112, 135, 78, 194, 85, 58, 168, 139, 99, 86, 60, 89, 196, 141, 101, 147, 176, 142, 31, 200, 90, 149, 102, 105, 163, 92, 47, 208, 150, 153, 165, 106, 55, 113, 154, 79, 108, 224, 166, 195, 59, 169, 114, 156, 87, 197, 116, 170, 61, 177, 91, 198, 172, 120, 201, 62, 143, 103, 178, 93, 202, 107, 180, 151, 209, 94, 204, 155, 210, 109, 184, 115, 167, 225, 157, 110, 117, 212, 171, 226, 216, 158, 118, 173, 121, 199, 179, 228, 174, 122, 203, 63, 181, 232, 124, 205, 182, 211, 185, 240, 206, 95, 213, 186, 227, 111, 214, 188, 217, 229, 159, 119, 218, 230, 233, 175, 123, 220, 183, 234, 125, 241, 207, 187, 236, 126, 242, 244, 189, 215, 219, 231, 248, 190, 221, 235, 222, 237, 243, 238, 245, 127, 191, 246, 249, 250, 252, 223, 239, 251, 247, 253, 254, 255 }; -static const uint16_t Q_0_Nminus1_9[512] = { 0, 1, 2, 4, 8, 16, 32, 3, 5, 64, 9, 6, 17, 10, 18, 128, 12, 33, 65, 20, 256, 34, 24, 36, 7, 129, 66, 11, 40, 68, 130, 19, 13, 48, 14, 72, 257, 21, 132, 35, 258, 26, 80, 37, 25, 22, 136, 260, 264, 38, 96, 67, 41, 144, 28, 69, 42, 49, 74, 272, 160, 288, 192, 70, 44, 131, 81, 50, 73, 15, 320, 133, 52, 23, 134, 384, 76, 137, 82, 56, 27, 97, 39, 259, 84, 138, 145, 261, 29, 43, 98, 88, 140, 30, 146, 71, 262, 265, 161, 45, 100, 51, 148, 46, 75, 266, 273, 104, 162, 53, 193, 152, 77, 164, 268, 274, 54, 83, 57, 112, 135, 78, 289, 194, 85, 276, 58, 168, 139, 99, 86, 60, 280, 89, 290, 196, 141, 101, 147, 176, 142, 321, 31, 200, 90, 292, 322, 263, 149, 102, 105, 304, 296, 163, 92, 47, 267, 385, 324, 208, 386, 150, 153, 165, 106, 55, 328, 113, 154, 79, 269, 108, 224, 166, 195, 270, 275, 291, 59, 169, 114, 277, 156, 87, 197, 116, 170, 61, 281, 278, 177, 293, 388, 91, 198, 172, 120, 201, 336, 62, 282, 143, 103, 178, 294, 93, 202, 323, 392, 297, 107, 180, 151, 209, 284, 94, 204, 298, 400, 352, 325, 155, 210, 305, 300, 109, 184, 115, 167, 225, 326, 306, 157, 329, 110, 117, 212, 171, 330, 226, 387, 308, 216, 416, 271, 279, 158, 337, 118, 332, 389, 173, 121, 199, 179, 228, 338, 312, 390, 174, 393, 283, 122, 448, 353, 203, 63, 340, 394, 181, 295, 285, 232, 124, 205, 182, 286, 299, 354, 211, 401, 185, 396, 344, 240, 206, 95, 327, 402, 356, 307, 301, 417, 213, 186, 404, 227, 418, 302, 360, 111, 331, 214, 309, 188, 449, 217, 408, 229, 159, 420, 310, 333, 119, 339, 218, 368, 230, 391, 313, 450, 334, 233, 175, 123, 341, 220, 314, 424, 395, 355, 287, 183, 234, 125, 342, 316, 241, 345, 452, 397, 403, 207, 432, 357, 187, 236, 126, 242, 398, 346, 456, 358, 405, 303, 244, 189, 361, 215, 348, 419, 406, 464, 362, 409, 219, 311, 421, 410, 231, 248, 369, 190, 364, 335, 480, 315, 221, 370, 422, 425, 451, 235, 412, 343, 372, 317, 222, 426, 453, 237, 433, 347, 243, 454, 318, 376, 428, 238, 359, 457, 399, 434, 349, 245, 458, 363, 127, 191, 407, 436, 465, 246, 350, 460, 249, 411, 365, 440, 374, 423, 466, 250, 371, 481, 413, 366, 468, 429, 252, 373, 482, 427, 414, 223, 472, 455, 377, 435, 319, 484, 430, 488, 239, 378, 459, 437, 380, 461, 496, 351, 467, 438, 251, 462, 442, 441, 469, 247, 367, 253, 375, 444, 470, 483, 415, 485, 473, 474, 254, 379, 431, 489, 486, 476, 439, 490, 463, 381, 497, 492, 443, 382, 498, 445, 471, 500, 446, 475, 487, 504, 255, 477, 491, 478, 383, 493, 499, 502, 494, 501, 447, 505, 506, 479, 508, 495, 503, 507, 509, 510, 511 }; -static const uint16_t Q_0_Nminus1_10[1024] = { 0, 1, 2, 4, 8, 16, 32, 3, 5, 64, 9, 6, 17, 10, 18, 128, 12, 33, 65, 20, 256, 34, 24, 36, 7, 129, 66, 512, 11, 40, 68, 130, 19, 13, 48, 14, 72, 257, 21, 132, 35, 258, 26, 513, 80, 37, 25, 22, 136, 260, 264, 38, 514, 96, 67, 41, 144, 28, 69, 42, 516, 49, 74, 272, 160, 520, 288, 528, 192, 544, 70, 44, 131, 81, 50, 73, 15, 320, 133, 52, 23, 134, 384, 76, 137, 82, 56, 27, 97, 39, 259, 84, 138, 145, 261, 29, 43, 98, 515, 88, 140, 30, 146, 71, 262, 265, 161, 576, 45, 100, 640, 51, 148, 46, 75, 266, 273, 517, 104, 162, 53, 193, 152, 77, 164, 768, 268, 274, 518, 54, 83, 57, 521, 112, 135, 78, 289, 194, 85, 276, 522, 58, 168, 139, 99, 86, 60, 280, 89, 290, 529, 524, 196, 141, 101, 147, 176, 142, 530, 321, 31, 200, 90, 545, 292, 322, 532, 263, 149, 102, 105, 304, 296, 163, 92, 47, 267, 385, 546, 324, 208, 386, 150, 153, 165, 106, 55, 328, 536, 577, 548, 113, 154, 79, 269, 108, 578, 224, 166, 519, 552, 195, 270, 641, 523, 275, 580, 291, 59, 169, 560, 114, 277, 156, 87, 197, 116, 170, 61, 531, 525, 642, 281, 278, 526, 177, 293, 388, 91, 584, 769, 198, 172, 120, 201, 336, 62, 282, 143, 103, 178, 294, 93, 644, 202, 592, 323, 392, 297, 770, 107, 180, 151, 209, 284, 648, 94, 204, 298, 400, 608, 352, 325, 533, 155, 210, 305, 547, 300, 109, 184, 534, 537, 115, 167, 225, 326, 306, 772, 157, 656, 329, 110, 117, 212, 171, 776, 330, 226, 549, 538, 387, 308, 216, 416, 271, 279, 158, 337, 550, 672, 118, 332, 579, 540, 389, 173, 121, 553, 199, 784, 179, 228, 338, 312, 704, 390, 174, 554, 581, 393, 283, 122, 448, 353, 561, 203, 63, 340, 394, 527, 582, 556, 181, 295, 285, 232, 124, 205, 182, 643, 562, 286, 585, 299, 354, 211, 401, 185, 396, 344, 586, 645, 593, 535, 240, 206, 95, 327, 564, 800, 402, 356, 307, 301, 417, 213, 568, 832, 588, 186, 646, 404, 227, 896, 594, 418, 302, 649, 771, 360, 539, 111, 331, 214, 309, 188, 449, 217, 408, 609, 596, 551, 650, 229, 159, 420, 310, 541, 773, 610, 657, 333, 119, 600, 339, 218, 368, 652, 230, 391, 313, 450, 542, 334, 233, 555, 774, 175, 123, 658, 612, 341, 777, 220, 314, 424, 395, 673, 583, 355, 287, 183, 234, 125, 557, 660, 616, 342, 316, 241, 778, 563, 345, 452, 397, 403, 207, 674, 558, 785, 432, 357, 187, 236, 664, 624, 587, 780, 705, 126, 242, 565, 398, 346, 456, 358, 405, 303, 569, 244, 595, 189, 566, 676, 361, 706, 589, 215, 786, 647, 348, 419, 406, 464, 680, 801, 362, 590, 409, 570, 788, 597, 572, 219, 311, 708, 598, 601, 651, 421, 792, 802, 611, 602, 410, 231, 688, 653, 248, 369, 190, 364, 654, 659, 335, 480, 315, 221, 370, 613, 422, 425, 451, 614, 543, 235, 412, 343, 372, 775, 317, 222, 426, 453, 237, 559, 833, 804, 712, 834, 661, 808, 779, 617, 604, 433, 720, 816, 836, 347, 897, 243, 662, 454, 318, 675, 618, 898, 781, 376, 428, 665, 736, 567, 840, 625, 238, 359, 457, 399, 787, 591, 678, 434, 677, 349, 245, 458, 666, 620, 363, 127, 191, 782, 407, 436, 626, 571, 465, 681, 246, 707, 350, 599, 668, 790, 460, 249, 682, 573, 411, 803, 789, 709, 365, 440, 628, 689, 374, 423, 466, 793, 250, 371, 481, 574, 413, 603, 366, 468, 655, 900, 805, 615, 684, 710, 429, 794, 252, 373, 605, 848, 690, 713, 632, 482, 806, 427, 904, 414, 223, 663, 692, 835, 619, 472, 455, 796, 809, 714, 721, 837, 716, 864, 810, 606, 912, 722, 696, 377, 435, 817, 319, 621, 812, 484, 430, 838, 667, 488, 239, 378, 459, 622, 627, 437, 380, 818, 461, 496, 669, 679, 724, 841, 629, 351, 467, 438, 737, 251, 462, 442, 441, 469, 247, 683, 842, 738, 899, 670, 783, 849, 820, 728, 928, 791, 367, 901, 630, 685, 844, 633, 711, 253, 691, 824, 902, 686, 740, 850, 375, 444, 470, 483, 415, 485, 905, 795, 473, 634, 744, 852, 960, 865, 693, 797, 906, 715, 807, 474, 636, 694, 254, 717, 575, 913, 798, 811, 379, 697, 431, 607, 489, 866, 723, 486, 908, 718, 813, 476, 856, 839, 725, 698, 914, 752, 868, 819, 814, 439, 929, 490, 623, 671, 739, 916, 463, 843, 381, 497, 930, 821, 726, 961, 872, 492, 631, 729, 700, 443, 741, 845, 920, 382, 822, 851, 730, 498, 880, 742, 445, 471, 635, 932, 687, 903, 825, 500, 846, 745, 826, 732, 446, 962, 936, 475, 853, 867, 637, 907, 487, 695, 746, 828, 753, 854, 857, 504, 799, 255, 964, 909, 719, 477, 915, 638, 748, 944, 869, 491, 699, 754, 858, 478, 968, 383, 910, 815, 976, 870, 917, 727, 493, 873, 701, 931, 756, 860, 499, 731, 823, 922, 874, 918, 502, 933, 743, 760, 881, 494, 702, 921, 501, 876, 847, 992, 447, 733, 827, 934, 882, 937, 963, 747, 505, 855, 924, 734, 829, 965, 938, 884, 506, 749, 945, 966, 755, 859, 940, 830, 911, 871, 639, 888, 479, 946, 750, 969, 508, 861, 757, 970, 919, 875, 862, 758, 948, 977, 923, 972, 761, 877, 952, 495, 703, 935, 978, 883, 762, 503, 925, 878, 735, 993, 885, 939, 994, 980, 926, 764, 941, 967, 886, 831, 947, 507, 889, 984, 751, 942, 996, 971, 890, 509, 949, 973, 1000, 892, 950, 863, 759, 1008, 510, 979, 953, 763, 974, 954, 879, 981, 982, 927, 995, 765, 956, 887, 985, 997, 986, 943, 891, 998, 766, 511, 988, 1001, 951, 1002, 893, 975, 894, 1009, 955, 1004, 1010, 957, 983, 958, 987, 1012, 999, 1016, 767, 989, 1003, 990, 1005, 959, 1011, 1013, 895, 1006, 1014, 1017, 1018, 991, 1020, 1007, 1015, 1019, 1021, 1022, 1023 }; +static const uint16_t Q_0_Nminus1_1[2] = {0, 1}; +static const uint16_t Q_0_Nminus1_2[4] = {0, 1, 2, 3}; +static const uint16_t Q_0_Nminus1_3[8] = {0, 1, 2, 4, 3, 5, 6, 7}; +static const uint16_t Q_0_Nminus1_4[16] = {0, 1, 2, 4, 8, 3, 5, 9, 6, 10, 12, 7, 11, 13, 14, 15}; +static const uint16_t Q_0_Nminus1_5[32] = {0, 1, 2, 4, 8, 16, 3, 5, 9, 6, 17, 10, 18, 12, 20, 24, + 7, 11, 19, 13, 14, 21, 26, 25, 22, 28, 15, 23, 27, 29, 30, 31}; +static const uint16_t Q_0_Nminus1_6[64] = {0, 1, 2, 4, 8, 16, 32, 3, 5, 9, 6, 17, 10, 18, 12, 33, 20, 34, 24, 36, 7, 11, + 40, 19, 13, 48, 14, 21, 35, 26, 37, 25, 22, 38, 41, 28, 42, 49, 44, 50, 15, 52, 23, 56, + 27, 39, 29, 43, 30, 45, 51, 46, 53, 54, 57, 58, 60, 31, 47, 55, 59, 61, 62, 63}; +static const uint16_t Q_0_Nminus1_7[128] = { + 0, 1, 2, 4, 8, 16, 32, 3, 5, 64, 9, 6, 17, 10, 18, 12, 33, 65, 20, 34, 24, 36, 7, 66, 11, 40, + 68, 19, 13, 48, 14, 72, 21, 35, 26, 80, 37, 25, 22, 38, 96, 67, 41, 28, 69, 42, 49, 74, 70, 44, 81, 50, + 73, 15, 52, 23, 76, 82, 56, 27, 97, 39, 84, 29, 43, 98, 88, 30, 71, 45, 100, 51, 46, 75, 104, 53, 77, 54, + 83, 57, 112, 78, 85, 58, 99, 86, 60, 89, 101, 31, 90, 102, 105, 92, 47, 106, 55, 113, 79, 108, 59, 114, 87, 116, + 61, 91, 120, 62, 103, 93, 107, 94, 109, 115, 110, 117, 118, 121, 122, 63, 124, 95, 111, 119, 123, 125, 126, 127}; +static const uint16_t Q_0_Nminus1_8[256] = { + 0, 1, 2, 4, 8, 16, 32, 3, 5, 64, 9, 6, 17, 10, 18, 128, 12, 33, 65, 20, 34, 24, 36, 7, + 129, 66, 11, 40, 68, 130, 19, 13, 48, 14, 72, 21, 132, 35, 26, 80, 37, 25, 22, 136, 38, 96, 67, 41, + 144, 28, 69, 42, 49, 74, 160, 192, 70, 44, 131, 81, 50, 73, 15, 133, 52, 23, 134, 76, 137, 82, 56, 27, + 97, 39, 84, 138, 145, 29, 43, 98, 88, 140, 30, 146, 71, 161, 45, 100, 51, 148, 46, 75, 104, 162, 53, 193, + 152, 77, 164, 54, 83, 57, 112, 135, 78, 194, 85, 58, 168, 139, 99, 86, 60, 89, 196, 141, 101, 147, 176, 142, + 31, 200, 90, 149, 102, 105, 163, 92, 47, 208, 150, 153, 165, 106, 55, 113, 154, 79, 108, 224, 166, 195, 59, 169, + 114, 156, 87, 197, 116, 170, 61, 177, 91, 198, 172, 120, 201, 62, 143, 103, 178, 93, 202, 107, 180, 151, 209, 94, + 204, 155, 210, 109, 184, 115, 167, 225, 157, 110, 117, 212, 171, 226, 216, 158, 118, 173, 121, 199, 179, 228, 174, 122, + 203, 63, 181, 232, 124, 205, 182, 211, 185, 240, 206, 95, 213, 186, 227, 111, 214, 188, 217, 229, 159, 119, 218, 230, + 233, 175, 123, 220, 183, 234, 125, 241, 207, 187, 236, 126, 242, 244, 189, 215, 219, 231, 248, 190, 221, 235, 222, 237, + 243, 238, 245, 127, 191, 246, 249, 250, 252, 223, 239, 251, 247, 253, 254, 255}; +static const uint16_t Q_0_Nminus1_9[512] = { + 0, 1, 2, 4, 8, 16, 32, 3, 5, 64, 9, 6, 17, 10, 18, 128, 12, 33, 65, 20, 256, 34, 24, 36, 7, + 129, 66, 11, 40, 68, 130, 19, 13, 48, 14, 72, 257, 21, 132, 35, 258, 26, 80, 37, 25, 22, 136, 260, 264, 38, + 96, 67, 41, 144, 28, 69, 42, 49, 74, 272, 160, 288, 192, 70, 44, 131, 81, 50, 73, 15, 320, 133, 52, 23, 134, + 384, 76, 137, 82, 56, 27, 97, 39, 259, 84, 138, 145, 261, 29, 43, 98, 88, 140, 30, 146, 71, 262, 265, 161, 45, + 100, 51, 148, 46, 75, 266, 273, 104, 162, 53, 193, 152, 77, 164, 268, 274, 54, 83, 57, 112, 135, 78, 289, 194, 85, + 276, 58, 168, 139, 99, 86, 60, 280, 89, 290, 196, 141, 101, 147, 176, 142, 321, 31, 200, 90, 292, 322, 263, 149, 102, + 105, 304, 296, 163, 92, 47, 267, 385, 324, 208, 386, 150, 153, 165, 106, 55, 328, 113, 154, 79, 269, 108, 224, 166, 195, + 270, 275, 291, 59, 169, 114, 277, 156, 87, 197, 116, 170, 61, 281, 278, 177, 293, 388, 91, 198, 172, 120, 201, 336, 62, + 282, 143, 103, 178, 294, 93, 202, 323, 392, 297, 107, 180, 151, 209, 284, 94, 204, 298, 400, 352, 325, 155, 210, 305, 300, + 109, 184, 115, 167, 225, 326, 306, 157, 329, 110, 117, 212, 171, 330, 226, 387, 308, 216, 416, 271, 279, 158, 337, 118, 332, + 389, 173, 121, 199, 179, 228, 338, 312, 390, 174, 393, 283, 122, 448, 353, 203, 63, 340, 394, 181, 295, 285, 232, 124, 205, + 182, 286, 299, 354, 211, 401, 185, 396, 344, 240, 206, 95, 327, 402, 356, 307, 301, 417, 213, 186, 404, 227, 418, 302, 360, + 111, 331, 214, 309, 188, 449, 217, 408, 229, 159, 420, 310, 333, 119, 339, 218, 368, 230, 391, 313, 450, 334, 233, 175, 123, + 341, 220, 314, 424, 395, 355, 287, 183, 234, 125, 342, 316, 241, 345, 452, 397, 403, 207, 432, 357, 187, 236, 126, 242, 398, + 346, 456, 358, 405, 303, 244, 189, 361, 215, 348, 419, 406, 464, 362, 409, 219, 311, 421, 410, 231, 248, 369, 190, 364, 335, + 480, 315, 221, 370, 422, 425, 451, 235, 412, 343, 372, 317, 222, 426, 453, 237, 433, 347, 243, 454, 318, 376, 428, 238, 359, + 457, 399, 434, 349, 245, 458, 363, 127, 191, 407, 436, 465, 246, 350, 460, 249, 411, 365, 440, 374, 423, 466, 250, 371, 481, + 413, 366, 468, 429, 252, 373, 482, 427, 414, 223, 472, 455, 377, 435, 319, 484, 430, 488, 239, 378, 459, 437, 380, 461, 496, + 351, 467, 438, 251, 462, 442, 441, 469, 247, 367, 253, 375, 444, 470, 483, 415, 485, 473, 474, 254, 379, 431, 489, 486, 476, + 439, 490, 463, 381, 497, 492, 443, 382, 498, 445, 471, 500, 446, 475, 487, 504, 255, 477, 491, 478, 383, 493, 499, 502, 494, + 501, 447, 505, 506, 479, 508, 495, 503, 507, 509, 510, 511}; +static const uint16_t Q_0_Nminus1_10[1024] = { + 0, 1, 2, 4, 8, 16, 32, 3, 5, 64, 9, 6, 17, 10, 18, 128, 12, 33, 65, 20, 256, 34, + 24, 36, 7, 129, 66, 512, 11, 40, 68, 130, 19, 13, 48, 14, 72, 257, 21, 132, 35, 258, 26, 513, + 80, 37, 25, 22, 136, 260, 264, 38, 514, 96, 67, 41, 144, 28, 69, 42, 516, 49, 74, 272, 160, 520, + 288, 528, 192, 544, 70, 44, 131, 81, 50, 73, 15, 320, 133, 52, 23, 134, 384, 76, 137, 82, 56, 27, + 97, 39, 259, 84, 138, 145, 261, 29, 43, 98, 515, 88, 140, 30, 146, 71, 262, 265, 161, 576, 45, 100, + 640, 51, 148, 46, 75, 266, 273, 517, 104, 162, 53, 193, 152, 77, 164, 768, 268, 274, 518, 54, 83, 57, + 521, 112, 135, 78, 289, 194, 85, 276, 522, 58, 168, 139, 99, 86, 60, 280, 89, 290, 529, 524, 196, 141, + 101, 147, 176, 142, 530, 321, 31, 200, 90, 545, 292, 322, 532, 263, 149, 102, 105, 304, 296, 163, 92, 47, + 267, 385, 546, 324, 208, 386, 150, 153, 165, 106, 55, 328, 536, 577, 548, 113, 154, 79, 269, 108, 578, 224, + 166, 519, 552, 195, 270, 641, 523, 275, 580, 291, 59, 169, 560, 114, 277, 156, 87, 197, 116, 170, 61, 531, + 525, 642, 281, 278, 526, 177, 293, 388, 91, 584, 769, 198, 172, 120, 201, 336, 62, 282, 143, 103, 178, 294, + 93, 644, 202, 592, 323, 392, 297, 770, 107, 180, 151, 209, 284, 648, 94, 204, 298, 400, 608, 352, 325, 533, + 155, 210, 305, 547, 300, 109, 184, 534, 537, 115, 167, 225, 326, 306, 772, 157, 656, 329, 110, 117, 212, 171, + 776, 330, 226, 549, 538, 387, 308, 216, 416, 271, 279, 158, 337, 550, 672, 118, 332, 579, 540, 389, 173, 121, + 553, 199, 784, 179, 228, 338, 312, 704, 390, 174, 554, 581, 393, 283, 122, 448, 353, 561, 203, 63, 340, 394, + 527, 582, 556, 181, 295, 285, 232, 124, 205, 182, 643, 562, 286, 585, 299, 354, 211, 401, 185, 396, 344, 586, + 645, 593, 535, 240, 206, 95, 327, 564, 800, 402, 356, 307, 301, 417, 213, 568, 832, 588, 186, 646, 404, 227, + 896, 594, 418, 302, 649, 771, 360, 539, 111, 331, 214, 309, 188, 449, 217, 408, 609, 596, 551, 650, 229, 159, + 420, 310, 541, 773, 610, 657, 333, 119, 600, 339, 218, 368, 652, 230, 391, 313, 450, 542, 334, 233, 555, 774, + 175, 123, 658, 612, 341, 777, 220, 314, 424, 395, 673, 583, 355, 287, 183, 234, 125, 557, 660, 616, 342, 316, + 241, 778, 563, 345, 452, 397, 403, 207, 674, 558, 785, 432, 357, 187, 236, 664, 624, 587, 780, 705, 126, 242, + 565, 398, 346, 456, 358, 405, 303, 569, 244, 595, 189, 566, 676, 361, 706, 589, 215, 786, 647, 348, 419, 406, + 464, 680, 801, 362, 590, 409, 570, 788, 597, 572, 219, 311, 708, 598, 601, 651, 421, 792, 802, 611, 602, 410, + 231, 688, 653, 248, 369, 190, 364, 654, 659, 335, 480, 315, 221, 370, 613, 422, 425, 451, 614, 543, 235, 412, + 343, 372, 775, 317, 222, 426, 453, 237, 559, 833, 804, 712, 834, 661, 808, 779, 617, 604, 433, 720, 816, 836, + 347, 897, 243, 662, 454, 318, 675, 618, 898, 781, 376, 428, 665, 736, 567, 840, 625, 238, 359, 457, 399, 787, + 591, 678, 434, 677, 349, 245, 458, 666, 620, 363, 127, 191, 782, 407, 436, 626, 571, 465, 681, 246, 707, 350, + 599, 668, 790, 460, 249, 682, 573, 411, 803, 789, 709, 365, 440, 628, 689, 374, 423, 466, 793, 250, 371, 481, + 574, 413, 603, 366, 468, 655, 900, 805, 615, 684, 710, 429, 794, 252, 373, 605, 848, 690, 713, 632, 482, 806, + 427, 904, 414, 223, 663, 692, 835, 619, 472, 455, 796, 809, 714, 721, 837, 716, 864, 810, 606, 912, 722, 696, + 377, 435, 817, 319, 621, 812, 484, 430, 838, 667, 488, 239, 378, 459, 622, 627, 437, 380, 818, 461, 496, 669, + 679, 724, 841, 629, 351, 467, 438, 737, 251, 462, 442, 441, 469, 247, 683, 842, 738, 899, 670, 783, 849, 820, + 728, 928, 791, 367, 901, 630, 685, 844, 633, 711, 253, 691, 824, 902, 686, 740, 850, 375, 444, 470, 483, 415, + 485, 905, 795, 473, 634, 744, 852, 960, 865, 693, 797, 906, 715, 807, 474, 636, 694, 254, 717, 575, 913, 798, + 811, 379, 697, 431, 607, 489, 866, 723, 486, 908, 718, 813, 476, 856, 839, 725, 698, 914, 752, 868, 819, 814, + 439, 929, 490, 623, 671, 739, 916, 463, 843, 381, 497, 930, 821, 726, 961, 872, 492, 631, 729, 700, 443, 741, + 845, 920, 382, 822, 851, 730, 498, 880, 742, 445, 471, 635, 932, 687, 903, 825, 500, 846, 745, 826, 732, 446, + 962, 936, 475, 853, 867, 637, 907, 487, 695, 746, 828, 753, 854, 857, 504, 799, 255, 964, 909, 719, 477, 915, + 638, 748, 944, 869, 491, 699, 754, 858, 478, 968, 383, 910, 815, 976, 870, 917, 727, 493, 873, 701, 931, 756, + 860, 499, 731, 823, 922, 874, 918, 502, 933, 743, 760, 881, 494, 702, 921, 501, 876, 847, 992, 447, 733, 827, + 934, 882, 937, 963, 747, 505, 855, 924, 734, 829, 965, 938, 884, 506, 749, 945, 966, 755, 859, 940, 830, 911, + 871, 639, 888, 479, 946, 750, 969, 508, 861, 757, 970, 919, 875, 862, 758, 948, 977, 923, 972, 761, 877, 952, + 495, 703, 935, 978, 883, 762, 503, 925, 878, 735, 993, 885, 939, 994, 980, 926, 764, 941, 967, 886, 831, 947, + 507, 889, 984, 751, 942, 996, 971, 890, 509, 949, 973, 1000, 892, 950, 863, 759, 1008, 510, 979, 953, 763, 974, + 954, 879, 981, 982, 927, 995, 765, 956, 887, 985, 997, 986, 943, 891, 998, 766, 511, 988, 1001, 951, 1002, 893, + 975, 894, 1009, 955, 1004, 1010, 957, 983, 958, 987, 1012, 999, 1016, 767, 989, 1003, 990, 1005, 959, 1011, 1013, 895, + 1006, 1014, 1017, 1018, 991, 1020, 1007, 1015, 1019, 1021, 1022, 1023}; static const uint16_t* const Q_0_Nminus1[11] = {NULL, Q_0_Nminus1_1, @@ -44,6 +131,7 @@ static const uint16_t* const Q_0_Nminus1[11] = {NULL, Q_0_Nminus1_9, Q_0_Nminus1_10}; -const uint16_t* nr_polar_sequence_pattern(uint8_t n){ - return Q_0_Nminus1[n]; +const uint16_t* nr_polar_sequence_pattern(uint8_t n) +{ + return Q_0_Nminus1[n]; } diff --git a/openair1/PHY/CODING/nrPolar_tools/nr_polar_uci_defs.h b/openair1/PHY/CODING/nrPolar_tools/nr_polar_uci_defs.h index 1ab664e5a2..d08862bb13 100644 --- a/openair1/PHY/CODING/nrPolar_tools/nr_polar_uci_defs.h +++ b/openair1/PHY/CODING/nrPolar_tools/nr_polar_uci_defs.h @@ -20,32 +20,32 @@ */ /*! \file PHY/CODING/nrPolar_tools/nr_polar_uci_defs.h -* \brief Defines the constant variables for polar coding of the UCI from 38-212, V15.1.1 2018-04. -* \author -* \date 2018 -* \version 0.1 -* \company Eurecom -* \email: -* \note -* \warning -*/ + * \brief Defines the constant variables for polar coding of the UCI from 38-212, V15.1.1 2018-04. + * \author + * \date 2018 + * \version 0.1 + * \company Eurecom + * \email: + * \note + * \warning + */ #ifndef __NR_POLAR_UCI_DEFS__H__ #define __NR_POLAR_UCI_DEFS__H__ -#define NR_POLAR_UCI_PUCCH_MESSAGE_TYPE 2 //int8_t +#define NR_POLAR_UCI_PUCCH_MESSAGE_TYPE 2 // int8_t #define NR_POLAR_PUCCH_CRC_ERROR_CORRECTION_BITS 3 #define NR_POLAR_PUCCH_PAYLOAD_BITS 32 #define NR_POLAR_PUCCH_E 32 -//Ref. 38-212, Section 6.3.1.2.1 +// Ref. 38-212, Section 6.3.1.2.1 #define NR_POLAR_PUCCH_CRC_PARITY_BITS_SHORT 6 #define NR_POLAR_PUCCH_CRC_PARITY_BITS_LONG 11 #define NR_POLAR_PUCCH_I_SEG_LONG 1 #define NR_POLAR_PUCCH_I_SEG_SHORT 0 -//Ref. 38-212, Section 6.3.1.3.1 +// Ref. 38-212, Section 6.3.1.3.1 #define NR_POLAR_PUCCH_N_MAX 10 #define NR_POLAR_PUCCH_I_IL 0 #define NR_POLAR_PUCCH_N_PC_SHORT 3 @@ -53,9 +53,7 @@ #define NR_POLAR_PUCCH_N_PC_WM_LONG 0 #define NR_POLAR_PUCCH_N_PC_WM_SHORT 1 -//Ref. 38-212, Section 6.3.1.4.1 +// Ref. 38-212, Section 6.3.1.4.1 #define NR_POLAR_PUCCH_I_BIL 1 - - #endif diff --git a/openair1/PHY/INIT/nr_init.c b/openair1/PHY/INIT/nr_init.c index 708f23e01a..e723b3a330 100644 --- a/openair1/PHY/INIT/nr_init.c +++ b/openair1/PHY/INIT/nr_init.c @@ -41,28 +41,24 @@ #include "SCHED_NR/fapi_nr_l1.h" #include "PHY/NR_REFSIG/ul_ref_seq_nr.h" -int l1_north_init_gNB() { +int l1_north_init_gNB() +{ + AssertFatal(RC.nb_nr_L1_inst > 0, "Failed to init PHY callbacks: nb_nr_L1_inst = %d\n", RC.nb_nr_L1_inst); + AssertFatal(RC.gNB != NULL, "Failed to init PHY callbacks: RC.gNB is null\n"); - if (RC.nb_nr_L1_inst > 0 && RC.gNB != NULL) { + for (uint8_t i = 0; i < RC.nb_nr_L1_inst; i++) { - AssertFatal(RC.nb_nr_L1_inst>0,"nb_nr_L1_inst=%d\n",RC.nb_nr_L1_inst); - AssertFatal(RC.gNB!=NULL,"RC.gNB is null\n"); - LOG_D(PHY, "%s() RC.nb_nr_L1_inst:%d\n", __FUNCTION__, RC.nb_nr_L1_inst); - - for (int i=0; iif_inst = NR_IF_Module_init(i))<0) return(-1); - - LOG_D(PHY, "%s() RC.gNB[%d] installing callbacks\n", __FUNCTION__, i); - RC.gNB[i]->if_inst->NR_PHY_config_req = nr_phy_config_request; - RC.gNB[i]->if_inst->NR_Schedule_response = nr_schedule_response; + if ((RC.gNB[i]->if_inst = NR_IF_Module_init(i)) < 0) { + LOG_E(NR_PHY, "Error: Failed to initialize NR_IF_Module for gNB[%d]\n", i); + return -1; } - } else { - LOG_D(PHY, "%s() Not installing PHY callbacks - RC.nb_nr_L1_inst:%d RC.gNB:%p\n", __FUNCTION__, RC.nb_nr_L1_inst, RC.gNB); + + LOG_D(NR_PHY, "RC.gNB[%d]: installing callbacks\n", i); + RC.gNB[i]->if_inst->NR_PHY_config_req = nr_phy_config_request; + RC.gNB[i]->if_inst->NR_Schedule_response = nr_schedule_response; } - return(0); + return 0; } NR_gNB_PHY_STATS_t *get_phy_stats(PHY_VARS_gNB *gNB, uint16_t rnti) @@ -312,15 +308,6 @@ void install_nr_schedule_handlers(NR_IF_Module_t *if_inst) if_inst->NR_PHY_config_req = nr_phy_config_request; if_inst->NR_Schedule_response = nr_schedule_response; } -/* -void install_schedule_handlers(IF_Module_t *if_inst) -{ - if_inst->PHY_config_req = phy_config_request; - if_inst->schedule_response = schedule_response; -}*/ - -/// this function is a temporary addition for NR configuration - void nr_phy_config_request_sim(PHY_VARS_gNB *gNB, int N_RB_DL, diff --git a/openair1/PHY/INIT/nr_init_ue.c b/openair1/PHY/INIT/nr_init_ue.c index 577f7a44d8..a240f3ecde 100644 --- a/openair1/PHY/INIT/nr_init_ue.c +++ b/openair1/PHY/INIT/nr_init_ue.c @@ -171,8 +171,6 @@ int init_nr_ue_signal(PHY_VARS_NR_UE *ue, int nb_connected_gNB) NR_DL_FRAME_PARMS *const fp = &ue->frame_parms; NR_UE_COMMON *const common_vars = &ue->common_vars; NR_UE_PRACH **const prach_vars = ue->prach_vars; - NR_UE_CSI_IM **const csiim_vars = ue->csiim_vars; - NR_UE_CSI_RS **const csirs_vars = ue->csirs_vars; NR_UE_SRS **const srs_vars = ue->srs_vars; LOG_I(PHY, "Initializing UE vars for gNB TXant %u, UE RXant %u\n", fp->nb_antennas_tx, fp->nb_antennas_rx); @@ -259,12 +257,7 @@ int init_nr_ue_signal(PHY_VARS_NR_UE *ue, int nb_connected_gNB) // DLSCH for (int gNB_id = 0; gNB_id < ue->n_connected_gNB; gNB_id++) { prach_vars[gNB_id] = malloc16_clear(sizeof(NR_UE_PRACH)); - csiim_vars[gNB_id] = malloc16_clear(sizeof(NR_UE_CSI_IM)); - csirs_vars[gNB_id] = malloc16_clear(sizeof(NR_UE_CSI_RS)); srs_vars[gNB_id] = malloc16_clear(sizeof(NR_UE_SRS)); - - csiim_vars[gNB_id]->active = false; - csirs_vars[gNB_id]->active = false; srs_vars[gNB_id]->active = false; // ceil((NB_RB*8(max allocation per RB)*2(QPSK))/32) @@ -283,7 +276,7 @@ int init_nr_ue_signal(PHY_VARS_NR_UE *ue, int nb_connected_gNB) init_timeshift_rotation(fp); // initialize to false only for SA since in do-ra and phy-test it is already set to true before getting here - if (get_softmodem_params()->sa) + if (IS_SA_MODE(get_softmodem_params())) ue->received_config_request = false; return 0; @@ -326,8 +319,6 @@ void term_nr_ue_signal(PHY_VARS_NR_UE *ue, int nb_connected_gNB) free_and_zero(ue->nr_srs_info); - free_and_zero(ue->csiim_vars[gNB_id]); - free_and_zero(ue->csirs_vars[gNB_id]); free_and_zero(ue->srs_vars[gNB_id]); free_and_zero(ue->prach_vars[gNB_id]); diff --git a/openair1/PHY/LTE_UE_TRANSPORT/ulsch_modulation.c b/openair1/PHY/LTE_UE_TRANSPORT/ulsch_modulation.c index 9d555c62fe..9c4ccf0679 100644 --- a/openair1/PHY/LTE_UE_TRANSPORT/ulsch_modulation.c +++ b/openair1/PHY/LTE_UE_TRANSPORT/ulsch_modulation.c @@ -93,6 +93,11 @@ void dft_lte(int32_t *z,struct complex16 *input, int32_t Msc_PUSCH, uint8_t Nsym // printf("\n"); dft_size_idx_t dftsize = get_dft(Msc_PUSCH); + if (dftsize == DFT_SIZE_IDXTABLESIZE) { + LOG_E(PHY, "Internal error, not modulating the slot, Msc_PUSCH = %d\n", Msc_PUSCH); + return; + } + switch (Msc_PUSCH) { case 12: dft(dftsize, (int16_t *)dft_in0, (int16_t *)dft_out0, 0); diff --git a/openair1/PHY/NR_TRANSPORT/nr_pbch.c b/openair1/PHY/NR_TRANSPORT/nr_pbch.c index a7507c2679..4cc55c1345 100644 --- a/openair1/PHY/NR_TRANSPORT/nr_pbch.c +++ b/openair1/PHY/NR_TRANSPORT/nr_pbch.c @@ -271,7 +271,7 @@ void nr_generate_pbch(PHY_VARS_gNB *gNB, pbch_a |= ((pbch_pdu[i >> 3] >> (7 - (i & 7))) & 1) << i; // NSA to signal no coreset0 - const int ssb_sc_offset = get_softmodem_params()->sa ? config->ssb_table.ssb_subcarrier_offset.value : 31; + const int ssb_sc_offset = IS_SA_MODE(get_softmodem_params()) ? config->ssb_table.ssb_subcarrier_offset.value : 31; #ifdef DEBUG_PBCH_ENCODING for (int i = 0; i < 3; i++) diff --git a/openair1/PHY/NR_TRANSPORT/nr_prach_common.c b/openair1/PHY/NR_TRANSPORT/nr_prach_common.c index 5933e84cbb..95d312293a 100644 --- a/openair1/PHY/NR_TRANSPORT/nr_prach_common.c +++ b/openair1/PHY/NR_TRANSPORT/nr_prach_common.c @@ -42,42 +42,6 @@ c16_t nr_ru[839]; // quantized roots of unity static uint32_t nr_ZC_inv[839]; // multiplicative inverse for roots u uint16_t nr_du[838]; -/*void dump_nr_prach_config(NR_DL_FRAME_PARMS *frame_parms,uint8_t subframe) { - - FILE *fd; - - fd = fopen("prach_config.txt","w"); - fprintf(fd,"prach_config: subframe = %d\n",subframe); - fprintf(fd,"prach_config: N_RB_UL = %d\n",frame_parms->N_RB_UL); - fprintf(fd,"prach_config: frame_type = %s\n",(frame_parms->frame_type==1) ? "TDD":"FDD"); - - if (frame_parms->frame_type==TDD) { - fprintf(fd,"prach_config: p_tdd_UL_DL_Configuration.referenceSCS = %d\n",frame_parms->p_tdd_UL_DL_Configuration->referenceSubcarrierSpacing); - fprintf(fd,"prach_config: p_tdd_UL_DL_Configuration.dl_UL_TransmissionPeriodicity = %d\n",frame_parms->p_tdd_UL_DL_Configuration->dl_UL_TransmissionPeriodicity); - fprintf(fd,"prach_config: p_tdd_UL_DL_Configuration.nrofDownlinkSlots = %d\n",frame_parms->p_tdd_UL_DL_Configuration->nrofDownlinkSlots); - fprintf(fd,"prach_config: p_tdd_UL_DL_Configuration.nrofDownlinkSymbols = %d\n",frame_parms->p_tdd_UL_DL_Configuration->nrofDownlinkSymbols); - fprintf(fd,"prach_config: p_tdd_UL_DL_Configuration.nrofUownlinkSlots = %d\n",frame_parms->p_tdd_UL_DL_Configuration->nrofDownlinkSlots); - fprintf(fd,"prach_config: p_tdd_UL_DL_Configuration.nrofUownlinkSymbols = %d\n",frame_parms->p_tdd_UL_DL_Configuration->nrofDownlinkSymbols); - if (frame_parms->p_tdd_UL_DL_Configuration->p_next) { - fprintf(fd,"prach_config: p_tdd_UL_DL_Configuration.referenceSCS2 = %d\n",frame_parms->p_tdd_UL_DL_Configuration->p_next->referenceSubcarrierSpacing); - fprintf(fd,"prach_config: p_tdd_UL_DL_Configuration.dl_UL_TransmissionPeriodicity2 = %d\n",frame_parms->p_tdd_UL_DL_Configuration->p_next->dl_UL_TransmissionPeriodicity); - fprintf(fd,"prach_config: p_tdd_UL_DL_Configuration.nrofDownlinkSlots2 = %d\n",frame_parms->p_tdd_UL_DL_Configuration->p_next->nrofDownlinkSlots); - fprintf(fd,"prach_config: p_tdd_UL_DL_Configuration.nrofDownlinkSymbols2 = %d\n",frame_parms->p_tdd_UL_DL_Configuration->p_next->nrofDownlinkSymbols); - fprintf(fd,"prach_config: p_tdd_UL_DL_Configuration.nrofUownlinkSlots2 = %d\n",frame_parms->p_tdd_UL_DL_Configuration->p_next->nrofDownlinkSlots); - fprintf(fd,"prach_config: p_tdd_UL_DL_Configuration.nrofUownlinkSymbols2 = %d\n",frame_parms->p_tdd_UL_DL_Configuration->p_next->nrofDownlinkSymbols); - - } - } - - fprintf(fd,"prach_config: rootSequenceIndex = %d\n",frame_parms->prach_config_common.rootSequenceIndex); - fprintf(fd,"prach_config: prach_ConfigIndex = %d\n",frame_parms->prach_config_common.prach_ConfigInfo.prach_ConfigIndex); - fprintf(fd,"prach_config: Ncs_config = %d\n",frame_parms->prach_config_common.prach_ConfigInfo.zeroCorrelationZoneConfig); - fprintf(fd,"prach_config: highSpeedFlag = %d\n",frame_parms->prach_config_common.prach_ConfigInfo.highSpeedFlag); - fprintf(fd,"prach_config: n_ra_prboffset = %d\n",frame_parms->prach_config_common.prach_ConfigInfo.msg1_frequencystart); - fclose(fd); - -}*/ - // This function computes the du void nr_fill_du(uint16_t N_ZC, const uint16_t *prach_root_sequence_map) { diff --git a/openair1/PHY/NR_UE_TRANSPORT/csi_rx.c b/openair1/PHY/NR_UE_TRANSPORT/csi_rx.c index eed7da6556..bcd24fef4a 100644 --- a/openair1/PHY/NR_UE_TRANSPORT/csi_rx.c +++ b/openair1/PHY/NR_UE_TRANSPORT/csi_rx.c @@ -793,13 +793,9 @@ static void nr_csi_im_power_estimation(const PHY_VARS_NR_UE *ue, void nr_ue_csi_im_procedures(PHY_VARS_NR_UE *ue, const UE_nr_rxtx_proc_t *proc, - c16_t rxdataF[][ue->frame_parms.samples_per_slot_wCP]) + c16_t rxdataF[][ue->frame_parms.samples_per_slot_wCP], + const fapi_nr_dl_config_csiim_pdu_rel15_t *csiim_config_pdu) { - int gNB_id = proc->gNB_id; - if(!ue->csiim_vars[gNB_id]->active) - LOG_E(NR_PHY, "Scheduling reception of CSI-IM that is not active\n"); - - const fapi_nr_dl_config_csiim_pdu_rel15_t *csiim_config_pdu = (fapi_nr_dl_config_csiim_pdu_rel15_t*)&ue->csiim_vars[gNB_id]->csiim_config_pdu; #ifdef NR_CSIIM_DEBUG LOG_I(NR_PHY, "csiim_config_pdu->bwp_size = %i\n", csiim_config_pdu->bwp_size); @@ -877,17 +873,10 @@ static void nr_ue_generate_csi_rs(const fapi_nr_dl_config_csirs_pdu_rel15_t *csi void nr_ue_csi_rs_procedures(PHY_VARS_NR_UE *ue, const UE_nr_rxtx_proc_t *proc, - c16_t rxdataF[][ue->frame_parms.samples_per_slot_wCP]) + c16_t rxdataF[][ue->frame_parms.samples_per_slot_wCP], + fapi_nr_dl_config_csirs_pdu_rel15_t *csirs_config_pdu) { - int gNB_id = proc->gNB_id; - if(!ue->csirs_vars[gNB_id]->active) { - return; - } - ue->csirs_vars[gNB_id]->active = 0; - - const fapi_nr_dl_config_csirs_pdu_rel15_t *csirs_config_pdu = &ue->csirs_vars[gNB_id]->csirs_config_pdu; - #ifdef NR_CSIRS_DEBUG LOG_I(NR_PHY, "csirs_config_pdu->subcarrier_spacing = %i\n", csirs_config_pdu->subcarrier_spacing); LOG_I(NR_PHY, "csirs_config_pdu->cyclic_prefix = %i\n", csirs_config_pdu->cyclic_prefix); diff --git a/openair1/PHY/NR_UE_TRANSPORT/nr_dlsch_demodulation.c b/openair1/PHY/NR_UE_TRANSPORT/nr_dlsch_demodulation.c index f17e309a6d..9bc764fa35 100644 --- a/openair1/PHY/NR_UE_TRANSPORT/nr_dlsch_demodulation.c +++ b/openair1/PHY/NR_UE_TRANSPORT/nr_dlsch_demodulation.c @@ -589,20 +589,21 @@ int nr_rx_pdsch(PHY_VARS_NR_UE *ue, symbol, nb_re_pdsch); if (nl >= 2) // Apply MMSE for 2, 3, and 4 Tx layers - nr_dlsch_mmse(rx_size_symbol, - n_rx, - nl, - rxdataF_comp, - dl_ch_mag, - dl_ch_magb, - dl_ch_magr, - dl_ch_estimates_ext, - nb_rb_pdsch, - dlsch_config->qamModOrder, - *log2_maxh, - symbol, - nb_re_pdsch, - nvar); + if (nb_re_pdsch) + nr_dlsch_mmse(rx_size_symbol, + n_rx, + nl, + rxdataF_comp, + dl_ch_mag, + dl_ch_magb, + dl_ch_magr, + dl_ch_estimates_ext, + nb_rb_pdsch, + dlsch_config->qamModOrder, + *log2_maxh, + symbol, + nb_re_pdsch, + nvar); } stop_meas_nr_ue_phy(ue, DLSCH_MRC_MMSE_STATS); @@ -1333,50 +1334,6 @@ void nr_a_sum_b(c16_t *input_x, c16_t *input_y, unsigned short nb_rb) } } -/* Zero Forcing Rx function: nr_a_mult_b() - * Compute the complex Multiplication c=a*b - * - * */ -void nr_a_mult_b(c16_t *a, c16_t *b, c16_t *c, unsigned short nb_rb, unsigned char output_shift0) -{ - //This function is used to compute complex multiplications - short nr_conjugate[8]__attribute__((aligned(16))) = {1,-1,1,-1,1,-1,1,-1}; - unsigned short rb; - simde__m128i *a_128,*b_128, *c_128, mmtmpD0,mmtmpD1,mmtmpD2,mmtmpD3; - - a_128 = (simde__m128i *)a; - b_128 = (simde__m128i *)b; - - c_128 = (simde__m128i *)c; - - for (rb=0; rb<3*nb_rb; rb++) { - // the real part - mmtmpD0 = simde_mm_sign_epi16(a_128[0],*(simde__m128i*)&nr_conjugate[0]); - mmtmpD0 = simde_mm_madd_epi16(mmtmpD0,b_128[0]); //Re: (a_re*b_re - a_im*b_im) - - // the imag part - mmtmpD1 = simde_mm_shufflelo_epi16(a_128[0],SIMDE_MM_SHUFFLE(2,3,0,1)); - mmtmpD1 = simde_mm_shufflehi_epi16(mmtmpD1,SIMDE_MM_SHUFFLE(2,3,0,1)); - mmtmpD1 = simde_mm_madd_epi16(mmtmpD1,b_128[0]);//Im: (x_im*y_re + x_re*y_im) - - mmtmpD0 = simde_mm_srai_epi32(mmtmpD0,output_shift0); - mmtmpD1 = simde_mm_srai_epi32(mmtmpD1,output_shift0); - mmtmpD2 = simde_mm_unpacklo_epi32(mmtmpD0,mmtmpD1); - mmtmpD3 = simde_mm_unpackhi_epi32(mmtmpD0,mmtmpD1); - - c_128[0] = simde_mm_packs_epi32(mmtmpD2,mmtmpD3); - - /*printf("\n Computing mult \n"); - print_shorts("a:",(int16_t*)&a_128[0]); - print_shorts("b:",(int16_t*)&b_128[0]); - print_shorts("pack:",(int16_t*)&c_128[0]);*/ - - a_128+=1; - b_128+=1; - c_128+=1; - } -} - /* Zero Forcing Rx function: nr_element_sign() * Compute b=sign*a * @@ -1448,7 +1405,7 @@ static void nr_determin(int size, nb_rb, ((rtx & 1) == 1 ? -1 : 1) * ((ctx & 1) == 1 ? -1 : 1) * sign, shift0); - nr_a_mult_b(a44[ctx][rtx], outtemp, rtx == 0 ? ad_bc : outtemp1, nb_rb, shift0); + mult_complex_vectors(a44[ctx][rtx], outtemp, rtx == 0 ? ad_bc : outtemp1, sizeofArray(outtemp1), shift0); if (rtx != 0) nr_a_sum_b(ad_bc, outtemp1, nb_rb); @@ -1759,11 +1716,11 @@ static void nr_dlsch_mmse(uint32_t rx_size_symbol, // printf("Computing r_%d c_%d\n",rtx,ctx); // print_shorts(" H_h_H=",(int16_t*)&conjH_H_elements[ctx*nl+rtx][0][0]); // print_shorts(" Inv_H_h_H=",(int16_t*)&inv_H_h_H[ctx*nl+rtx][0]); - nr_a_mult_b(inv_H_h_H[ctx][rtx], - (c16_t *)(rxdataF_comp[ctx][0] + symbol * rx_size_symbol), - outtemp, - nb_rb_0, - shift - (fp_flag == 1 ? 2 : 0)); + mult_complex_vectors(inv_H_h_H[ctx][rtx], + (c16_t *)(rxdataF_comp[ctx][0] + symbol * rx_size_symbol), + outtemp, + sizeofArray(outtemp), + shift - (fp_flag == 1 ? 2 : 0)); nr_a_sum_b(rxdataF_zforcing[rtx], outtemp, nb_rb_0); // a = a + b } #ifdef DEBUG_DLSCH_DEMOD diff --git a/openair1/PHY/TOOLS/tests/CMakeLists.txt b/openair1/PHY/TOOLS/tests/CMakeLists.txt index 9480af781f..f5bdf24421 100644 --- a/openair1/PHY/TOOLS/tests/CMakeLists.txt +++ b/openair1/PHY/TOOLS/tests/CMakeLists.txt @@ -16,8 +16,15 @@ add_dependencies(tests test_log2_approx) add_test(NAME test_log2_approx COMMAND ./test_log2_approx --gtest_filter=-log2_approx.complete) + add_executable(dft_test test_dft.c ../dfts_load.c) target_link_libraries(dft_test minimal_lib shlib_loader SIMU m) add_dependencies(tests dft_test) add_dependencies(dft_test dfts) # trigger build of dfts (shared lib for DFT) add_test(NAME dft_test COMMAND ./dft_test) + +add_executable(test_vector_op test_vector_op.cpp) +target_link_libraries(test_vector_op PRIVATE LOG minimal_lib) +add_dependencies(tests test_vector_op) +add_test(NAME test_vector_op + COMMAND test_vector_op) diff --git a/openair1/PHY/TOOLS/tests/benchmark_rotate_vector.cpp b/openair1/PHY/TOOLS/tests/benchmark_rotate_vector.cpp index 6f4ea89643..25f1756e76 100644 --- a/openair1/PHY/TOOLS/tests/benchmark_rotate_vector.cpp +++ b/openair1/PHY/TOOLS/tests/benchmark_rotate_vector.cpp @@ -45,7 +45,7 @@ static void BM_rotate_cpx_vector(benchmark::State &state) { int vector_size = state.range(0); auto input_complex_16 = generate_random_c16(vector_size); - auto input_alpha = generate_random_c16(vector_size); + auto input_alpha = generate_random_c16(1); AlignedVector512 output; output.resize(vector_size); int shift = 2; diff --git a/openair1/PHY/TOOLS/tests/test_vector_op.cpp b/openair1/PHY/TOOLS/tests/test_vector_op.cpp new file mode 100644 index 0000000000..6173c40e7e --- /dev/null +++ b/openair1/PHY/TOOLS/tests/test_vector_op.cpp @@ -0,0 +1,70 @@ +/* + * Licensed to the OpenAirInterface (OAI) Software Alliance under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The OpenAirInterface Software Alliance licenses this file to You under + * the OAI Public License, Version 1.1 (the "License"); you may not use this file + * except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.openairinterface.org/?page_id=698 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + *------------------------------------------------------------------------------- + * For more information about the OpenAirInterface (OAI) Software Alliance: + * contact@openairinterface.org + */ + +#include +#include +#include +#include +extern "C" { +#include "openair1/PHY/TOOLS/tools_defs.h" +struct configmodule_interface_s; +struct configmodule_interface_s *uniqCfg = NULL; +void exit_function(const char *file, const char *function, const int line, const char *s, const int assert) +{ + if (assert) { + abort(); + } else { + exit(EXIT_SUCCESS); + } +} +} +#include +#include "common/utils/LOG/log.h" +#include "openair1/PHY/TOOLS/phy_test_tools.hpp" + +int main() +{ + const int shift = 15; // it should always be 15 to keep int16 in same range + for (int vector_size = 1237; vector_size < 1237 + 8; vector_size++) { + auto input1 = generate_random_c16(vector_size); + auto input2 = generate_random_c16(vector_size); + AlignedVector512 output; + output.resize(vector_size); + mult_complex_vectors(input1.data(), input2.data(), output.data(), vector_size, shift); + for (int i = 0; i < vector_size; i++) { + c16_t res = c16mulShift(input1[i], input2[i], shift); + if (output[i].r != res.r || output[i].i != res.i) { + printf("Error at %d: (%d,%d) * (%d,%d) = (%d,%d) (should be (%d,%d))\n", + i, + input1[i].r, + input1[i].i, + input2[i].r, + input2[i].i, + output[i].r, + output[i].i, + res.r, + res.i); + return 1; + } + } + } + return 0; +} diff --git a/openair1/PHY/TOOLS/tools_defs.h b/openair1/PHY/TOOLS/tools_defs.h index 58af33020a..41af6ba0a9 100644 --- a/openair1/PHY/TOOLS/tools_defs.h +++ b/openair1/PHY/TOOLS/tools_defs.h @@ -38,6 +38,7 @@ #include #include #include +#include "common/utils/LOG/log.h" #define simd_q15_t simde__m128i #define simdshort_q15_t simde__m64 @@ -90,7 +91,7 @@ extern "C" { int dim2; int dim3; int dim4; - uint8_t data[]; + uint8_t data[] __attribute__((aligned(32))); } fourDimArray_t; static inline fourDimArray_t *allocateFourDimArray(int elmtSz, int dim1, int dim2, int dim3, int dim4) @@ -357,6 +358,74 @@ static __attribute__((always_inline)) inline void multadd_real_four_symbols_vect simde_mm_storeu_si128((simd_q15_t *)y, y_128); } +// Multiply two vectors of complex int16 and take the most significant bits (shift by 15 in normal case) +// works only with little endian storage (for big endian, modify the srai/ssli at the end) +static __attribute__((always_inline)) inline void mult_complex_vectors(const c16_t *in1, + const c16_t *in2, + c16_t *out, + const int size, + const int shift) +{ + const simde__m256i complex_shuffle256 = simde_mm256_set_epi8(29, + 28, + 31, + 30, + 25, + 24, + 27, + 26, + 21, + 20, + 23, + 22, + 17, + 16, + 19, + 18, + 13, + 12, + 15, + 14, + 9, + 8, + 11, + 10, + 5, + 4, + 7, + 6, + 1, + 0, + 3, + 2); + const simde__m256i conj256 = simde_mm256_set_epi16(-1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1); + int i; + // do 8 multiplications at a time + for (i = 0; i < size - 7; i += 8) { + const simde__m256i i1 = simde_mm256_loadu_epi32((simde__m256i *)(in1 + i)); + const simde__m256i i2 = simde_mm256_loadu_epi32((simde__m256i *)(in2 + i)); + const simde__m256i i2swap = simde_mm256_shuffle_epi8(i2, complex_shuffle256); + const simde__m256i i2conj = simde_mm256_sign_epi16(i2, conj256); + const simde__m256i re = simde_mm256_madd_epi16(i1, i2conj); + const simde__m256i im = simde_mm256_madd_epi16(i1, i2swap); + simde_mm256_storeu_si256( + (simde__m256i *)(out + i), + simde_mm256_blend_epi16(simde_mm256_srai_epi32(re, shift), simde_mm256_slli_epi32(im, 16 - shift), 0xAA)); + } + if (size - i > 4) { + const simde__m128i i1 = simde_mm_loadu_epi32((simde__m128i *)(in1 + i)); + const simde__m128i i2 = simde_mm_loadu_epi32((simde__m128i *)(in2 + i)); + const simde__m128i i2swap = simde_mm_shuffle_epi8(i2, *(simde__m128i *)&complex_shuffle256); + const simde__m128i i2conj = simde_mm_sign_epi16(i2, *(simde__m128i *)&conj256); + const simde__m128i re = simde_mm_madd_epi16(i1, i2conj); + const simde__m128i im = simde_mm_madd_epi16(i1, i2swap); + simde_mm_storeu_si128((simde__m128i *)(out + i), + simde_mm_blend_epi16(simde_mm_srai_epi32(re, shift), simde_mm_slli_epi32(im, 16 - shift), 0xAA)); + i += 4; + } + for (; i < size; i++) + out[i] = c16mulShift(in1[i], in2[i], shift); +} /*!\fn void multadd_complex_vector_real_scalar(int16_t *x,int16_t alpha,int16_t *y,uint8_t zero_flag,uint32_t N) This function performs componentwise multiplication and accumulation of a real scalar and a complex vector. @param x Vector input (Q1.15) in the format |Re0 Im0|Re1 Im 1| ... @@ -550,17 +619,15 @@ typedef enum dft_size_idx { case Sz: \ return DFT_##Sz; \ break; -static inline -dft_size_idx_t get_dft(int ofdm_symbol_size) +static inline dft_size_idx_t get_dft(int size) { - switch (ofdm_symbol_size) { + switch (size) { FOREACH_DFTSZ(FIND_ENUM) default: - printf("function get_dft : unsupported ofdm symbol size \n"); - assert(0); + LOG_E(UTIL, "function get_dft : unsupported DFT size %d\n", size); break; } - return DFT_SIZE_IDXTABLESIZE; // never reached and will trigger assertion in idft function; + return DFT_SIZE_IDXTABLESIZE; } #define SZ_iENUM(Sz) IDFT_##Sz, @@ -610,14 +677,12 @@ struct { return IDFT_##iSz; \ break; -static inline -idft_size_idx_t get_idft(int ofdm_symbol_size) +static inline idft_size_idx_t get_idft(int size) { - switch (ofdm_symbol_size) { + switch (size) { FOREACH_IDFTSZ(FIND_iENUM) default: - printf("function get_idft : unsupported ofdm symbol size \n"); - assert(0); + AssertFatal(false, "function get_idft : unsupported iDFT size %d\n", size); break; } return IDFT_SIZE_IDXTABLESIZE; // never reached and will trigger assertion in idft function diff --git a/openair1/PHY/TOOLS/tools_extern.h b/openair1/PHY/TOOLS/tools_extern.h deleted file mode 100644 index 4690bba42e..0000000000 --- a/openair1/PHY/TOOLS/tools_extern.h +++ /dev/null @@ -1,21 +0,0 @@ -/* - * Licensed to the OpenAirInterface (OAI) Software Alliance under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The OpenAirInterface Software Alliance licenses this file to You under - * the OAI Public License, Version 1.1 (the "License"); you may not use this file - * except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.openairinterface.org/?page_id=698 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - *------------------------------------------------------------------------------- - * For more information about the OpenAirInterface (OAI) Software Alliance: - * contact@openairinterface.org - */ - diff --git a/openair1/PHY/defs_gNB.h b/openair1/PHY/defs_gNB.h index da316de8aa..7022ad8b23 100644 --- a/openair1/PHY/defs_gNB.h +++ b/openair1/PHY/defs_gNB.h @@ -514,7 +514,7 @@ typedef struct PHY_VARS_gNB_s { int srs_thres; uint64_t bad_pucch; int num_ulprbbl; - int ulprbbl[275]; + uint16_t ulprbbl [MAX_BWP_SIZE]; time_stats_t phy_proc_tx; time_stats_t phy_proc_rx; diff --git a/openair1/PHY/defs_nr_UE.h b/openair1/PHY/defs_nr_UE.h index 4def69049e..12b10e4b96 100644 --- a/openair1/PHY/defs_nr_UE.h +++ b/openair1/PHY/defs_nr_UE.h @@ -396,8 +396,6 @@ typedef struct PHY_VARS_NR_UE_s { nr_synch_request_t synch_request; NR_UE_PRACH *prach_vars[NUMBER_OF_CONNECTED_gNB_MAX]; - NR_UE_CSI_IM *csiim_vars[NUMBER_OF_CONNECTED_gNB_MAX]; - NR_UE_CSI_RS *csirs_vars[NUMBER_OF_CONNECTED_gNB_MAX]; NR_UE_SRS *srs_vars[NUMBER_OF_CONNECTED_gNB_MAX]; NR_UE_PRS *prs_vars[NR_MAX_PRS_COMB_SIZE]; uint8_t prs_active_gNBs; @@ -603,7 +601,8 @@ typedef struct nr_phy_data_s { // Sidelink Rx action decided by MAC sl_nr_rx_config_type_enum_t sl_rx_action; - + NR_UE_CSI_RS csirs_vars; + NR_UE_CSI_IM csiim_vars; } nr_phy_data_t; enum stream_status_e { STREAM_STATUS_UNSYNC, STREAM_STATUS_SYNCING, STREAM_STATUS_SYNCED}; diff --git a/openair1/PHY/nr_phy_common/src/nr_phy_common.c b/openair1/PHY/nr_phy_common/src/nr_phy_common.c index ef10837d2d..11a40fd69e 100644 --- a/openair1/PHY/nr_phy_common/src/nr_phy_common.c +++ b/openair1/PHY/nr_phy_common/src/nr_phy_common.c @@ -141,14 +141,13 @@ void nr_64qam_llr(int32_t *rxdataF_comp, int32_t *ch_mag, int32_t *ch_mag2, int1 int32_t *llr_32 = (int32_t *)llr; #ifndef USE_128BIT - simde__m256i xmm0, xmm1, xmm2; for (int i = 0; i < (nb_re >> 3); i++) { - xmm0 = *rxF; + simde__m256i xmm0 = simde_mm256_loadu_si256(rxF); // registers of even index in xmm0-> |y_R|, registers of odd index in xmm0-> |y_I| - xmm1 = simde_mm256_abs_epi16(xmm0); + simde__m256i xmm1 = simde_mm256_abs_epi16(xmm0); // registers of even index in xmm0-> |y_R|-|h|^2, registers of odd index in xmm0-> |y_I|-|h|^2 xmm1 = simde_mm256_subs_epi16(*ch_maga, xmm1); - xmm2 = simde_mm256_abs_epi16(xmm1); + simde__m256i xmm2 = simde_mm256_abs_epi16(xmm1); xmm2 = simde_mm256_subs_epi16(*ch_magb, xmm2); // xmm0 |1st 4th 7th 10th 13th 16th 19th 22ed| // xmm1 |2ed 5th 8th 11th 14th 17th 20th 23rd| diff --git a/openair1/PHY/phy_extern.h b/openair1/PHY/phy_extern.h index 8584bf351e..f1e4bb5bcd 100644 --- a/openair1/PHY/phy_extern.h +++ b/openair1/PHY/phy_extern.h @@ -63,9 +63,6 @@ static const short primary_synch2[144] = { -13477, 29867, -7292, -31946, -29523, -14218, 25100, -21063, -16384, -28378, 27073, -18459, -26120, -19785, 2448, -32676, -24020, 22287, -31754, 8085, 32767, -1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}; -extern unsigned char NB_RU; - - static const char NB_functions[7][20] = { "eNodeB_3GPP", "eNodeB_3GPP_BBU", diff --git a/openair1/PHY/phy_vars.h b/openair1/PHY/phy_vars.h index 85d2d2a59f..61b8361d21 100644 --- a/openair1/PHY/phy_vars.h +++ b/openair1/PHY/phy_vars.h @@ -30,7 +30,6 @@ PHY_VARS_UE ***PHY_vars_UE_g; UL_RCC_IND_t UL_RCC_INFO; -unsigned char NB_RU=0; int number_of_cards; uint8_t max_turbo_iterations=4; diff --git a/openair1/SCHED_NR/phy_procedures_nr_gNB.c b/openair1/SCHED_NR/phy_procedures_nr_gNB.c index 7148b28fe7..a56c01ce99 100644 --- a/openair1/SCHED_NR/phy_procedures_nr_gNB.c +++ b/openair1/SCHED_NR/phy_procedures_nr_gNB.c @@ -95,7 +95,7 @@ void nr_common_signal_procedures(PHY_VARS_gNB *gNB, int frame, int slot, nfapi_n const int sc_offset = (fp->freq_range == FR1) ? pdu->SsbSubcarrierOffset >> scs : pdu->SsbSubcarrierOffset; fp->ssb_start_subcarrier = (12 * prb_offset + sc_offset); - if (fp->print_ue_help_cmdline_log && get_softmodem_params()->sa) { + if (fp->print_ue_help_cmdline_log && IS_SA_MODE(get_softmodem_params())) { fp->print_ue_help_cmdline_log = false; if (fp->dl_CarrierFreq != fp->ul_CarrierFreq) LOG_A(PHY, diff --git a/openair1/SCHED_NR_UE/defs.h b/openair1/SCHED_NR_UE/defs.h index 4174e44238..7ae4bb6a70 100644 --- a/openair1/SCHED_NR_UE/defs.h +++ b/openair1/SCHED_NR_UE/defs.h @@ -151,11 +151,13 @@ int nr_ue_pdcch_procedures(PHY_VARS_NR_UE *ue, void nr_ue_csi_im_procedures(PHY_VARS_NR_UE *ue, const UE_nr_rxtx_proc_t *proc, - c16_t rxdataF[][ue->frame_parms.samples_per_slot_wCP]); + c16_t rxdataF[][ue->frame_parms.samples_per_slot_wCP], + const fapi_nr_dl_config_csiim_pdu_rel15_t *csiim_config_pdu); void nr_ue_csi_rs_procedures(PHY_VARS_NR_UE *ue, const UE_nr_rxtx_proc_t *proc, - c16_t rxdataF[][ue->frame_parms.samples_per_slot_wCP]); + c16_t rxdataF[][ue->frame_parms.samples_per_slot_wCP], + fapi_nr_dl_config_csirs_pdu_rel15_t *csirs_config_pdu); int psbch_pscch_processing(PHY_VARS_NR_UE *ue, const UE_nr_rxtx_proc_t *proc, nr_phy_data_t *phy_data); void phy_procedures_nrUE_SL_TX(PHY_VARS_NR_UE *ue, const UE_nr_rxtx_proc_t *proc, nr_phy_data_tx_t *phy_data); diff --git a/openair1/SCHED_NR_UE/fapi_nr_ue_l1.c b/openair1/SCHED_NR_UE/fapi_nr_ue_l1.c index 32fa53cc60..dc2db2d2ea 100644 --- a/openair1/SCHED_NR_UE/fapi_nr_ue_l1.c +++ b/openair1/SCHED_NR_UE/fapi_nr_ue_l1.c @@ -420,12 +420,12 @@ static void nr_ue_scheduled_response_dl(NR_UE_MAC_INST_t *mac, LOG_D(PHY, "Number of DCI SearchSpaces %d\n", phy_data->phy_pdcch_config.nb_search_space); break; case FAPI_NR_DL_CONFIG_TYPE_CSI_IM: - phy->csiim_vars[0]->csiim_config_pdu = pdu->csiim_config_pdu.csiim_config_rel15; - phy->csiim_vars[0]->active = true; + phy_data->csiim_vars.csiim_config_pdu = pdu->csiim_config_pdu.csiim_config_rel15; + phy_data->csiim_vars.active = true; break; case FAPI_NR_DL_CONFIG_TYPE_CSI_RS: - phy->csirs_vars[0]->csirs_config_pdu = pdu->csirs_config_pdu.csirs_config_rel15; - phy->csirs_vars[0]->active = true; + phy_data->csirs_vars.csirs_config_pdu = pdu->csirs_config_pdu.csirs_config_rel15; + phy_data->csirs_vars.active = true; break; case FAPI_NR_DL_CONFIG_TYPE_RA_DLSCH: { fapi_nr_dl_config_dlsch_pdu_rel15_t *dlsch_config_pdu = &pdu->dlsch_config_pdu.dlsch_config_rel15; diff --git a/openair1/SCHED_NR_UE/phy_procedures_nr_ue.c b/openair1/SCHED_NR_UE/phy_procedures_nr_ue.c index cf1ebf8319..085317b0df 100644 --- a/openair1/SCHED_NR_UE/phy_procedures_nr_ue.c +++ b/openair1/SCHED_NR_UE/phy_procedures_nr_ue.c @@ -505,8 +505,8 @@ static int nr_ue_pdsch_procedures(PHY_VARS_NR_UE *ue, dlsch0->Nl); const uint32_t pdsch_est_size = ((ue->frame_parms.symbols_per_slot * ue->frame_parms.ofdm_symbol_size + 15) / 16) * 16; - __attribute__((aligned(32))) int32_t pdsch_dl_ch_estimates[ue->frame_parms.nb_antennas_rx * dlsch0->Nl][pdsch_est_size]; - memset(pdsch_dl_ch_estimates, 0, sizeof(int32_t) * ue->frame_parms.nb_antennas_rx * dlsch0->Nl * pdsch_est_size); + fourDimArray_t *toFree = NULL; + allocCast2D(pdsch_dl_ch_estimates, int32_t, toFree, ue->frame_parms.nb_antennas_rx * dlsch0->Nl, pdsch_est_size, false); c16_t ptrs_phase_per_slot[ue->frame_parms.nb_antennas_rx][NR_SYMBOLS_PER_SLOT]; memset(ptrs_phase_per_slot, 0, sizeof(ptrs_phase_per_slot)); @@ -515,8 +515,14 @@ static int nr_ue_pdsch_procedures(PHY_VARS_NR_UE *ue, memset(ptrs_re_per_slot, 0, sizeof(ptrs_re_per_slot)); const uint32_t rx_size_symbol = (dlsch[0].dlsch_config.number_rbs * NR_NB_SC_PER_RB + 15) & ~15; - __attribute__((aligned(32))) int32_t rxdataF_comp[dlsch[0].Nl][ue->frame_parms.nb_antennas_rx][rx_size_symbol * NR_SYMBOLS_PER_SLOT]; - memset(rxdataF_comp, 0, sizeof(rxdataF_comp)); + fourDimArray_t *toFree2 = NULL; + allocCast3D(rxdataF_comp, + int32_t, + toFree2, + dlsch[0].Nl, + ue->frame_parms.nb_antennas_rx, + rx_size_symbol * NR_SYMBOLS_PER_SLOT, + false); uint32_t nvar = 0; @@ -620,6 +626,8 @@ static int nr_ue_pdsch_procedures(PHY_VARS_NR_UE *ue, return -1; } // CRNTI active stop_meas_nr_ue_phy(ue, RX_PDSCH_STATS); + free(toFree); + free(toFree2); } return 0; } @@ -1058,29 +1066,28 @@ void pdsch_processing(PHY_VARS_NR_UE *ue, const UE_nr_rxtx_proc_t *proc, nr_phy_ __attribute__ ((aligned(32))) c16_t rxdataF[ue->frame_parms.nb_antennas_rx][rxdataF_sz]; // do procedures for CSI-IM - if ((ue->csiim_vars[gNB_id]) && (ue->csiim_vars[gNB_id]->active == 1)) { + if (phy_data->csiim_vars.active == 1) { for(int symb_idx = 0; symb_idx < 4; symb_idx++) { - int symb = ue->csiim_vars[gNB_id]->csiim_config_pdu.l_csiim[symb_idx]; + int symb = phy_data->csiim_vars.csiim_config_pdu.l_csiim[symb_idx]; if (!slot_fep_map[symb]) { nr_slot_fep(ue, &ue->frame_parms, proc->nr_slot_rx, symb, rxdataF, link_type_dl, 0, ue->common_vars.rxdata); slot_fep_map[symb] = true; } } - nr_ue_csi_im_procedures(ue, proc, rxdataF); - ue->csiim_vars[gNB_id]->active = 0; + nr_ue_csi_im_procedures(ue, proc, rxdataF, &phy_data->csiim_vars.csiim_config_pdu); } // do procedures for CSI-RS - if ((ue->csirs_vars[gNB_id]) && (ue->csirs_vars[gNB_id]->active == 1)) { + if (phy_data->csirs_vars.active == 1) { for(int symb = 0; symb < NR_SYMBOLS_PER_SLOT; symb++) { - if(is_csi_rs_in_symbol(ue->csirs_vars[gNB_id]->csirs_config_pdu, symb)) { + if(is_csi_rs_in_symbol(phy_data->csirs_vars.csirs_config_pdu, symb)) { if (!slot_fep_map[symb]) { nr_slot_fep(ue, &ue->frame_parms, proc->nr_slot_rx, symb, rxdataF, link_type_dl, 0, ue->common_vars.rxdata); slot_fep_map[symb] = true; } } } - nr_ue_csi_rs_procedures(ue, proc, rxdataF); + nr_ue_csi_rs_procedures(ue, proc, rxdataF, &phy_data->csirs_vars.csirs_config_pdu); } if (dlsch[0].active) { diff --git a/openair1/SIMULATION/NR_PHY/dlsim.c b/openair1/SIMULATION/NR_PHY/dlsim.c index 9ab2de4215..a67c5be9da 100644 --- a/openair1/SIMULATION/NR_PHY/dlsim.c +++ b/openair1/SIMULATION/NR_PHY/dlsim.c @@ -858,15 +858,12 @@ int main(int argc, char **argv) UE_mac->if_module = nr_ue_if_module_init(0); unsigned int available_bits=0; - unsigned char *estimated_output_bit; - unsigned char *test_input_bit; + unsigned char *estimated_output_bit=NULL; + unsigned char *test_input_bit=NULL; unsigned int errors_bit = 0; initFloatingCoresTpool(dlsch_threads, &nrUE_params.Tpool, false, "UE-tpool"); - test_input_bit = (unsigned char *) malloc16(sizeof(unsigned char) * 16 * 68 * 384); - estimated_output_bit = (unsigned char *) malloc16(sizeof(unsigned char) * 16 * 68 * 384); - // generate signal AssertFatal(input_fd==NULL,"Not ready for input signal file\n"); @@ -905,13 +902,14 @@ int main(int argc, char **argv) gNB->msgDataTx = msgDataTx; // Buffers to store internal memory of slot process - int rx_size = (((14 * frame_parms->N_RB_DL * 12 * sizeof(int32_t)) + 15) >> 4) << 4; - UE->phy_sim_rxdataF = calloc(sizeof(int32_t *) * frame_parms->nb_antennas_rx * g_nrOfLayers, frame_parms->samples_per_slot_wCP * sizeof(int32_t)); + int rx_size = (((14 * UE->frame_parms.N_RB_DL * 12 * sizeof(int32_t)) + 15) >> 4) << 4; + UE->phy_sim_rxdataF = calloc(sizeof(int32_t *) * UE->frame_parms.nb_antennas_rx * g_nrOfLayers, + UE->frame_parms.samples_per_slot_wCP * sizeof(int32_t)); UE->phy_sim_pdsch_llr = calloc(1, (8 * (3 * 8 * 8448)) * sizeof(int16_t)); // Max length - UE->phy_sim_pdsch_rxdataF_ext = calloc(sizeof(int32_t *) * frame_parms->nb_antennas_rx * g_nrOfLayers, rx_size); - UE->phy_sim_pdsch_rxdataF_comp = calloc(sizeof(int32_t *) * frame_parms->nb_antennas_rx * g_nrOfLayers, rx_size); - UE->phy_sim_pdsch_dl_ch_estimates = calloc(sizeof(int32_t *) * frame_parms->nb_antennas_rx * g_nrOfLayers, rx_size); - UE->phy_sim_pdsch_dl_ch_estimates_ext = calloc(sizeof(int32_t *) * frame_parms->nb_antennas_rx * g_nrOfLayers, rx_size); + UE->phy_sim_pdsch_rxdataF_ext = calloc(sizeof(int32_t *) * UE->frame_parms.nb_antennas_rx * g_nrOfLayers, rx_size); + UE->phy_sim_pdsch_rxdataF_comp = calloc(sizeof(int32_t *) * UE->frame_parms.nb_antennas_rx * g_nrOfLayers, rx_size); + UE->phy_sim_pdsch_dl_ch_estimates = calloc(sizeof(int32_t *) * UE->frame_parms.nb_antennas_rx * g_nrOfLayers, rx_size); + UE->phy_sim_pdsch_dl_ch_estimates_ext = calloc(sizeof(int32_t *) * UE->frame_parms.nb_antennas_rx * g_nrOfLayers, rx_size); int a_segments = MAX_NUM_NR_DLSCH_SEGMENTS_PER_LAYER*NR_MAX_NB_LAYERS; //number of segments to be allocated if (g_rbSize != 273) { a_segments = a_segments*g_rbSize; @@ -942,6 +940,7 @@ int main(int argc, char **argv) for (SNR = snr0; SNR < snr1; SNR += .2) { varArray_t *table_tx=initVarArray(1000,sizeof(double)); + reset_meas(&gNB->phy_proc_tx); reset_meas(&gNB->dlsch_scrambling_stats); reset_meas(&gNB->dlsch_interleaving_stats); reset_meas(&gNB->dlsch_rate_matching_stats); @@ -1035,11 +1034,13 @@ int main(int argc, char **argv) msgDataTx->ssb[0].ssb_pdu.ssb_pdu_rel15.bchPayload=0x001234; msgDataTx->ssb[0].ssb_pdu.ssb_pdu_rel15.SsbBlockIndex = 0; msgDataTx->gNB = gNB; - if (run_initial_sync) + if (run_initial_sync) { nr_common_signal_procedures(gNB,frame,slot,msgDataTx->ssb[0].ssb_pdu); - else + } else { + start_meas(&gNB->phy_proc_tx); phy_procedures_gNB_TX(msgDataTx,frame,slot,1); - + stop_meas(&gNB->phy_proc_tx); + } int txdataF_offset = slot * frame_parms->samples_per_slot_wCP; if (n_trials==1) { @@ -1118,7 +1119,17 @@ int main(int argc, char **argv) // Apply MIMO Channel multipath_channel(gNB2UE, s_re, s_im, r_re, r_im, slot_length, 0, (n_trials == 1) ? 1 : 0); - add_noise(UE->common_vars.rxdata, (const double **) r_re, (const double **) r_im, sigma2, slot_length, slot_offset, ts, delay, pdu_bit_map, 0x1, frame_parms->nb_antennas_rx); + add_noise(UE->common_vars.rxdata, + (const double **)r_re, + (const double **)r_im, + sigma2, + slot_length, + slot_offset, + ts, + delay, + pdu_bit_map, + 0x1, + UE->frame_parms.nb_antennas_rx); dl_config.sfn = frame; dl_config.slot = slot; ue_dci_configuration(UE_mac, &dl_config, frame, slot); @@ -1168,6 +1179,10 @@ int main(int argc, char **argv) round++; } // round + if (test_input_bit == NULL) { + test_input_bit = (unsigned char *)malloc16(sizeof(unsigned char) * TBS); + estimated_output_bit = (unsigned char *)malloc16(sizeof(unsigned char) * TBS); + } for (i = 0; i < TBS; i++) { estimated_output_bit[i] = (UE->phy_sim_dlsch_b[i/8] & (1 << (i & 7))) >> (i & 7); @@ -1226,10 +1241,11 @@ int main(int argc, char **argv) fprintf(csv_file,"%.2f,%.4f,%.2f,%u\n", roundStats, effRate, effRate / TBS * 100, TBS); } if (print_perf==1) { - printf("\ngNB TX function statistics (per %d us slot, NPRB %d, mcs %d, block %d)\n", + printf("\ngNB TX function statistics (per %d us slot, NPRB %d, mcs %d, C %d, block %d)\n", 1000 >> *scc->ssbSubcarrierSpacing, g_rbSize, g_mcsIndex, + UE->dl_harq_processes[0][slot].C, msgDataTx->dlsch[0][0].harq_process.pdsch_pdu.pdsch_pdu_rel15.TBSize[0] << 3); printDistribution(&gNB->phy_proc_tx,table_tx,"PHY proc tx"); printStatIndent2(&gNB->dlsch_encoding_stats,"DLSCH encoding time"); diff --git a/openair1/SIMULATION/NR_PHY/pbchsim.c b/openair1/SIMULATION/NR_PHY/pbchsim.c index c0b1cbf5bb..4489c3e7bb 100644 --- a/openair1/SIMULATION/NR_PHY/pbchsim.c +++ b/openair1/SIMULATION/NR_PHY/pbchsim.c @@ -153,7 +153,6 @@ int main(int argc, char **argv) int ssb_scan_threads = 0; channel_desc_t *gNB2UE; - get_softmodem_params()->sa = 1; get_softmodem_params()->usim_test = 1; //uint8_t extended_prefix_flag=0; diff --git a/openair1/SIMULATION/NR_PHY/prachsim.c b/openair1/SIMULATION/NR_PHY/prachsim.c index 4ccf0317e9..76b5d979b3 100644 --- a/openair1/SIMULATION/NR_PHY/prachsim.c +++ b/openair1/SIMULATION/NR_PHY/prachsim.c @@ -662,9 +662,6 @@ int main(int argc, char **argv){ LOG_M("txsig0_frame.m","txs0", txdata[0],frame_parms->samples_per_frame,1,1); #endif - // multipath channel - // dump_nr_prach_config(&gNB->frame_parms,subframe); - for (i = 0; i < frame_parms->samples_per_subframe; i++) { for (aa=0; aa<1; aa++) { if (awgn_flag == 0) { diff --git a/openair1/SIMULATION/TOOLS/DOC/channel_simulation.md b/openair1/SIMULATION/TOOLS/DOC/channel_simulation.md index 6d1546b484..347f575bfb 100644 --- a/openair1/SIMULATION/TOOLS/DOC/channel_simulation.md +++ b/openair1/SIMULATION/TOOLS/DOC/channel_simulation.md @@ -86,11 +86,11 @@ When the `chanmod` option is enabled, the RF channel simulator with a channel mo Example run of OAI RFSIM on the same machine with activation of the channel model via command line: gNB: ```bash -sudo ./nr-softmodem -O ../../../targets/PROJECTS/GENERIC-NR-5GC/CONF/gnb.sa.band78.fr1.106PRB.usrpb210.conf --gNBs.[0].min_rxtxtime 6 --rfsim --sa --rfsimulator.options chanmod --telnetsrv +sudo ./nr-softmodem -O ../../../targets/PROJECTS/GENERIC-NR-5GC/CONF/gnb.sa.band78.fr1.106PRB.usrpb210.conf --gNBs.[0].min_rxtxtime 6 --rfsim --rfsimulator.options chanmod --telnetsrv ``` UE: ```bash -sudo ./nr-uesoftmodem -r 106 --numerology 1 --band 78 -C 3619200000 --rfsim --sa --rfsimulator.serveraddr 127.0.0.1 --uicc0.imsi 001010000000001 -O ../../../ci-scripts/conf_files/nrue.uicc.conf --rfsimulator.options chanmod +sudo ./nr-uesoftmodem -r 106 --numerology 1 --band 78 -C 3619200000 --rfsim --rfsimulator.serveraddr 127.0.0.1 --uicc0.imsi 001010000000001 -O ../../../ci-scripts/conf_files/nrue.uicc.conf --rfsimulator.options chanmod ``` where `@include "channelmod_rfsimu.conf"` has been added at the end of `ci-scripts/conf_files/channelmod_rfsimu.conf` which has been copied to `targets/PROJECTS/GENERIC-LTE-EPC/CONF/`. @@ -131,7 +131,7 @@ Example usage, set the offset for the selected model of the selected `modellist` e.g. with the softmodem: ```bash -sudo ./nr-softmodem -O ../../../targets/PROJECTS/GENERIC-NR-5GC/CONF/gnb.sa.band78.fr1.106PRB.usrpb210.conf --gNBs.[0].min_rxtxtime 6 --rfsim --sa --rfsimulator.options chanmod --telnetsrv --channelmod.modellist modellist_rfsimu_2 --channelmod.modellist_rfsimu_2.[1].offset 120 +sudo ./nr-softmodem -O ../../../targets/PROJECTS/GENERIC-NR-5GC/CONF/gnb.sa.band78.fr1.106PRB.usrpb210.conf --gNBs.[0].min_rxtxtime 6 --rfsim --rfsimulator.options chanmod --telnetsrv --channelmod.modellist modellist_rfsimu_2 --channelmod.modellist_rfsimu_2.[1].offset 120 ``` ## Real time control and monitoring with telnet server diff --git a/openair2/E2AP/README.md b/openair2/E2AP/README.md index 924977af36..abcfaa1ac0 100644 --- a/openair2/E2AP/README.md +++ b/openair2/E2AP/README.md @@ -179,26 +179,26 @@ e2_agent = { * start the gNB-mono ```bash cd oai/cmake_targets/ran_build/build - sudo ./nr-softmodem -O ../../../targets/PROJECTS/GENERIC-NR-5GC/CONF/gnb.sa.band78.fr1.106PRB.usrpb210.conf --rfsim --sa -E + sudo ./nr-softmodem -O ../../../targets/PROJECTS/GENERIC-NR-5GC/CONF/gnb.sa.band78.fr1.106PRB.usrpb210.conf --rfsim -E ``` * if CU/DU split is used, start the gNB as follows ```bash - sudo ./nr-softmodem -O --rfsim --sa -E - sudo ./nr-softmodem -O --sa + sudo ./nr-softmodem -O --rfsim -E + sudo ./nr-softmodem -O ``` * if CU-CP/CU-UP/DU split is used, start the gNB as follows ```bash - sudo ./nr-softmodem -O --rfsim --sa -E - sudo ./nr-softmodem -O --sa - sudo ./nr-cuup -O --sa + sudo ./nr-softmodem -O --rfsim -E + sudo ./nr-softmodem -O + sudo ./nr-cuup -O ``` * start the nrUE ```bash cd oai/cmake_targets/ran_build/build - sudo ./nr-uesoftmodem -r 106 --numerology 1 --band 78 -C 3619200000 --rfsim --sa --uicc0.imsi 001010000000001 --rfsimulator.serveraddr 127.0.0.1 + sudo ./nr-uesoftmodem -r 106 --numerology 1 --band 78 -C 3619200000 --rfsim --uicc0.imsi 001010000000001 --rfsimulator.serveraddr 127.0.0.1 ``` * start the nearRT-RIC diff --git a/openair2/GNB_APP/gnb_app.c b/openair2/GNB_APP/gnb_app.c index 49b53aa572..354ed2e415 100644 --- a/openair2/GNB_APP/gnb_app.c +++ b/openair2/GNB_APP/gnb_app.c @@ -54,8 +54,6 @@ #include "gnb_config.h" #include "openair2/LAYER2/NR_MAC_gNB/mac_proto.h" -extern unsigned char NB_gNB_INST; - extern RAN_CONTEXT_t RC; #define GNB_REGISTER_RETRY_DELAY 10 @@ -71,7 +69,8 @@ uint32_t gNB_app_register(uint32_t gnb_id_start, uint32_t gnb_id_end)//, const E for (gnb_id = gnb_id_start; (gnb_id < gnb_id_end) ; gnb_id++) { { - if(get_softmodem_params()->sa){ + if (IS_SA_MODE(get_softmodem_params())) { + // note: there is an implicit relationship between the data structure and the message name msg_p = itti_alloc_new_message (TASK_GNB_APP, 0, NGAP_REGISTER_GNB_REQ); //Message Temporarily reuse diff --git a/openair2/GNB_APP/gnb_config.c b/openair2/GNB_APP/gnb_config.c index 08e4d97a31..44c402fb8a 100644 --- a/openair2/GNB_APP/gnb_config.c +++ b/openair2/GNB_APP/gnb_config.c @@ -746,25 +746,15 @@ void RCconfig_nr_prs(void) prs_config_t *prs_config = NULL; char str[7][100] = {0}; + AssertFatal(RC.gNB != NULL, "gNB context is null, cannot complete PRS configuration\n"); + paramdef_t PRS_Params[] = PRS_PARAMS_DESC; paramlist_def_t PRS_ParamList = {CONFIG_STRING_PRS_CONFIG,NULL,0}; - if (RC.gNB == NULL) { - RC.gNB = (PHY_VARS_gNB **)malloc((1+NUMBER_OF_gNB_MAX)*sizeof(PHY_VARS_gNB*)); - LOG_I(NR_PHY,"RC.gNB = %p\n",RC.gNB); - memset(RC.gNB,0,(1+NUMBER_OF_gNB_MAX)*sizeof(PHY_VARS_gNB*)); - } - config_getlist(config_get_if(), &PRS_ParamList, PRS_Params, sizeofArray(PRS_Params), NULL); if (PRS_ParamList.numelt > 0) { for (j = 0; j < RC.nb_nr_L1_inst; j++) { - - if (RC.gNB[j] == NULL) { - RC.gNB[j] = (PHY_VARS_gNB *)malloc(sizeof(PHY_VARS_gNB)); - LOG_I(NR_PHY,"RC.gNB[%d] = %p\n",j,RC.gNB[j]); - memset(RC.gNB[j],0,sizeof(PHY_VARS_gNB)); - RC.gNB[j]->Mod_id = j; - } + AssertFatal(RC.gNB[j] != NULL, "gNB L1 instance is null at index %d, cannot complete L1 configuration\n", j); RC.gNB[j]->prs_vars.NumPRSResources = *(PRS_ParamList.paramarray[j][NUM_PRS_RESOURCES].uptr); for (k = 0; k < RC.gNB[j]->prs_vars.NumPRSResources; k++) @@ -834,135 +824,122 @@ void RCconfig_nr_prs(void) } } +#define ALL_SYMBOLS_TAKEN 0x3FFF + +/** + * @brief Get number or blacklisted UL PRBs and their mapping from gNB config + */ +static int get_prb_blacklist(uint8_t instance, uint16_t *prbbl) +{ + paramdef_t GNBSParams[] = GNBSPARAMS_DESC; + paramlist_def_t GNBParamList = {GNB_CONFIG_STRING_GNB_LIST, NULL, 0}; + config_get(config_get_if(), GNBSParams, sizeofArray(GNBSParams), NULL); + int num_gnbs = GNBSParams[GNB_ACTIVE_GNBS_IDX].numelt; + AssertFatal(num_gnbs > 0, "Failed to parse config file, no GNBs found in field %s \n", GNB_CONFIG_STRING_ACTIVE_GNBS); + paramdef_t GNBParams[] = GNBPARAMS_DESC; + config_getlist(config_get_if(), &GNBParamList, GNBParams, sizeofArray(GNBParams), NULL); + + int num_prbbl = 0; + char *ulprbbl = *GNBParamList.paramarray[0][GNB_ULPRBBLACKLIST_IDX].strptr; + + if (!ulprbbl) + return -1; + + LOG_D(NR_PHY, "PRB blacklist found: %s\n", ulprbbl); + char *save = NULL; + char *pt = strtok_r(ulprbbl, ",", &save); + + while (pt) { + const int rb = atoi(pt); + AssertFatal(rb < MAX_BWP_SIZE, "RB %d out of bounds (max 275 PRBs)\n", rb); + prbbl[rb] = ALL_SYMBOLS_TAKEN; + LOG_D(NR_PHY, "Blacklisting prb %d\n", rb); + pt = strtok_r(NULL, ",", &save); + num_prbbl++; + } + return num_prbbl; +} + void RCconfig_NR_L1(void) { - int j = 0; - if (RC.gNB == NULL) { - RC.gNB = (PHY_VARS_gNB **)malloc((1 + NUMBER_OF_gNB_MAX) * sizeof(PHY_VARS_gNB *)); - LOG_I(NR_PHY, "RC.gNB = %p\n", RC.gNB); - memset(RC.gNB, 0, (1 + NUMBER_OF_gNB_MAX) * sizeof(PHY_VARS_gNB *)); + LOG_I(NR_PHY, "Initializing NR L1: RC.nb_nr_L1_inst = %d\n", RC.nb_nr_L1_inst); - if (RC.gNB[j] == NULL) { - RC.gNB[j] = calloc(1, sizeof(PHY_VARS_gNB)); - } - } - if (NFAPI_MODE != NFAPI_MODE_PNF) { - paramdef_t GNBSParams[] = GNBSPARAMS_DESC; - ////////// Identification parameters - paramdef_t GNBParams[] = GNBPARAMS_DESC; + for (int j = 0; j < RC.nb_nr_L1_inst; j++) { + PHY_VARS_gNB *gNB = RC.gNB[j]; + AssertFatal(RC.gNB[j] != NULL, "gNB L1 instance is null at index %d, cannot complete L1 configuration\n", j); + // gNB params + if (NFAPI_MODE != NFAPI_MODE_PNF) { + paramdef_t GNBSParams[] = GNBSPARAMS_DESC; + paramlist_def_t GNBParamList = {GNB_CONFIG_STRING_GNB_LIST, NULL, 0}; + config_get(config_get_if(), GNBSParams, sizeofArray(GNBSParams), NULL); + int num_gnbs = GNBSParams[GNB_ACTIVE_GNBS_IDX].numelt; + AssertFatal(num_gnbs > 0, "Failed to parse config file, no GNBs found in field %s \n", GNB_CONFIG_STRING_ACTIVE_GNBS); - paramlist_def_t GNBParamList = {GNB_CONFIG_STRING_GNB_LIST, NULL, 0}; + paramdef_t GNBParams[] = GNBPARAMS_DESC; + config_getlist(config_get_if(), &GNBParamList, GNBParams, sizeofArray(GNBParams), NULL); + int N1 = *GNBParamList.paramarray[0][GNB_PDSCH_ANTENNAPORTS_N1_IDX].iptr; + int N2 = *GNBParamList.paramarray[0][GNB_PDSCH_ANTENNAPORTS_N2_IDX].iptr; + int XP = *GNBParamList.paramarray[0][GNB_PDSCH_ANTENNAPORTS_XP_IDX].iptr; - config_get(config_get_if(), GNBSParams, sizeofArray(GNBSParams), NULL); - int num_gnbs = GNBSParams[GNB_ACTIVE_GNBS_IDX].numelt; - AssertFatal(num_gnbs > 0, "Failed to parse config file no gnbs %s \n", GNB_CONFIG_STRING_ACTIVE_GNBS); - - config_getlist(config_get_if(), &GNBParamList, GNBParams, sizeofArray(GNBParams), NULL); - int N1 = *GNBParamList.paramarray[0][GNB_PDSCH_ANTENNAPORTS_N1_IDX].iptr; - int N2 = *GNBParamList.paramarray[0][GNB_PDSCH_ANTENNAPORTS_N2_IDX].iptr; - int XP = *GNBParamList.paramarray[0][GNB_PDSCH_ANTENNAPORTS_XP_IDX].iptr; - char *ulprbbl = *GNBParamList.paramarray[0][GNB_ULPRBBLACKLIST_IDX].strptr; - if (ulprbbl) - LOG_D(NR_PHY, "PRB blacklist %s\n", ulprbbl); - char *save = NULL; - char *pt = strtok_r(ulprbbl, ",", &save); - int prbbl[275]; - int num_prbbl = 0; - memset(prbbl, 0, 275 * sizeof(int)); - - while (pt) { - const int rb = atoi(pt); - AssertFatal(rb < 275, "RB %d out of bounds (max 275)\n", rb); - prbbl[rb] = 0x3FFF; // all symbols taken - LOG_D(NR_PHY, "Blacklisting prb %d\n", atoi(pt)); - pt = strtok_r(NULL, ",", &save); - num_prbbl++; - } - - RC.gNB[j]->num_ulprbbl = num_prbbl; - LOG_D(NR_PHY, "Copying %d blacklisted PRB to L1 context\n", num_prbbl); - memcpy(RC.gNB[j]->ulprbbl, prbbl, 275 * sizeof(int)); - - RC.gNB[j]->ap_N1 = N1; - RC.gNB[j]->ap_N2 = N2; - RC.gNB[j]->ap_XP = XP; - } - - paramdef_t L1_Params[] = L1PARAMS_DESC; - paramlist_def_t L1_ParamList = {CONFIG_STRING_L1_LIST, NULL, 0}; - - config_getlist(config_get_if(), &L1_ParamList, L1_Params, sizeofArray(L1_Params), NULL); - - if (L1_ParamList.numelt > 0) { - for (j = 0; j < RC.nb_nr_L1_inst; j++) { - if (RC.gNB[j] == NULL) { - RC.gNB[j] = (PHY_VARS_gNB *)malloc(sizeof(PHY_VARS_gNB)); - memset(RC.gNB[j], 0, sizeof(PHY_VARS_gNB)); - RC.gNB[j]->Mod_id = j; + // PRB Blacklist + uint16_t prbbl[MAX_BWP_SIZE] = {0}; + int num_ulprbbl = get_prb_blacklist(j, prbbl); + if (num_ulprbbl != -1) { + RC.gNB[j]->num_ulprbbl = num_ulprbbl; + LOG_D(NR_PHY, "Copying %d blacklisted PRB to L1 context\n", RC.gNB[j]->num_ulprbbl); + memcpy(RC.gNB[j]->ulprbbl, prbbl, MAX_BWP_SIZE * sizeof(prbbl[0])); } - AssertFatal(*L1_ParamList.paramarray[j][L1_THREAD_POOL_SIZE].uptr == 2022, "thread_pool_size removed, please use --thread-pool\n"); - RC.gNB[j]->ofdm_offset_divisor = *(L1_ParamList.paramarray[j][L1_OFDM_OFFSET_DIVISOR].uptr); - RC.gNB[j]->pucch0_thres = *(L1_ParamList.paramarray[j][L1_PUCCH0_DTX_THRESHOLD].uptr); - RC.gNB[j]->prach_thres = *(L1_ParamList.paramarray[j][L1_PRACH_DTX_THRESHOLD].uptr); - RC.gNB[j]->pusch_thres = *(L1_ParamList.paramarray[j][L1_PUSCH_DTX_THRESHOLD].uptr); - RC.gNB[j]->srs_thres = *(L1_ParamList.paramarray[j][L1_SRS_DTX_THRESHOLD].uptr); - RC.gNB[j]->max_ldpc_iterations = *(L1_ParamList.paramarray[j][L1_MAX_LDPC_ITERATIONS].uptr); - RC.gNB[j]->L1_rx_thread_core = *(L1_ParamList.paramarray[j][L1_RX_THREAD_CORE].iptr); - RC.gNB[j]->L1_tx_thread_core = *(L1_ParamList.paramarray[j][L1_TX_THREAD_CORE].iptr); - LOG_I(PHY,"L1_RX_THREAD_CORE %d (%d)\n",*(L1_ParamList.paramarray[j][L1_RX_THREAD_CORE].iptr),L1_RX_THREAD_CORE); - RC.gNB[j]->TX_AMP = (int16_t)(32767.0 / pow(10.0, .05 * (double)(*L1_ParamList.paramarray[j][L1_TX_AMP_BACKOFF_dB].uptr))); - RC.gNB[j]->phase_comp = *L1_ParamList.paramarray[j][L1_PHASE_COMP].uptr; - LOG_I(PHY, "TX_AMP = %d (-%d dBFS)\n", RC.gNB[j]->TX_AMP, *L1_ParamList.paramarray[j][L1_TX_AMP_BACKOFF_dB].uptr); - AssertFatal(RC.gNB[j]->TX_AMP > 300, "TX_AMP is too small, must be larger than 300 (is %d)\n", RC.gNB[j]->TX_AMP); + + // Antenna ports + gNB->ap_N1 = N1; + gNB->ap_N2 = N2; + gNB->ap_XP = XP; + } + + // L1 params + paramdef_t L1_Params[] = L1PARAMS_DESC; + paramlist_def_t L1_ParamList = {CONFIG_STRING_L1_LIST, NULL, 0}; + config_getlist(config_get_if(), &L1_ParamList, L1_Params, sizeofArray(L1_Params), NULL); + if (L1_ParamList.numelt > 0) { + AssertFatal(*L1_ParamList.paramarray[j][L1_THREAD_POOL_SIZE].uptr == 2022, + "thread_pool_size removed, please use --thread-pool\n"); + gNB->ofdm_offset_divisor = *(L1_ParamList.paramarray[j][L1_OFDM_OFFSET_DIVISOR].uptr); + gNB->pucch0_thres = *(L1_ParamList.paramarray[j][L1_PUCCH0_DTX_THRESHOLD].uptr); + gNB->prach_thres = *(L1_ParamList.paramarray[j][L1_PRACH_DTX_THRESHOLD].uptr); + gNB->pusch_thres = *(L1_ParamList.paramarray[j][L1_PUSCH_DTX_THRESHOLD].uptr); + gNB->srs_thres = *(L1_ParamList.paramarray[j][L1_SRS_DTX_THRESHOLD].uptr); + gNB->max_ldpc_iterations = *(L1_ParamList.paramarray[j][L1_MAX_LDPC_ITERATIONS].uptr); + gNB->L1_rx_thread_core = *(L1_ParamList.paramarray[j][L1_RX_THREAD_CORE].iptr); + gNB->L1_tx_thread_core = *(L1_ParamList.paramarray[j][L1_TX_THREAD_CORE].iptr); + LOG_I(NR_PHY, "L1_RX_THREAD_CORE %d (%d)\n", *(L1_ParamList.paramarray[j][L1_RX_THREAD_CORE].iptr), L1_RX_THREAD_CORE); + gNB->TX_AMP = (int16_t)(32767.0 / pow(10.0, .05 * (double)(*L1_ParamList.paramarray[j][L1_TX_AMP_BACKOFF_dB].uptr))); + gNB->phase_comp = *L1_ParamList.paramarray[j][L1_PHASE_COMP].uptr; + LOG_I(NR_PHY, "TX_AMP = %d (-%d dBFS)\n", gNB->TX_AMP, *L1_ParamList.paramarray[j][L1_TX_AMP_BACKOFF_dB].uptr); + AssertFatal(gNB->TX_AMP > 300, "TX_AMP is too small, must be larger than 300 (is %d)\n", gNB->TX_AMP); + // Midhaul configuration if (strcmp(*(L1_ParamList.paramarray[j][L1_TRANSPORT_N_PREFERENCE_IDX].strptr), "local_mac") == 0) { - // sf_ahead = 2; // Need 4 subframe gap between RX and TX + // do nothing } else if (strcmp(*(L1_ParamList.paramarray[j][L1_TRANSPORT_N_PREFERENCE_IDX].strptr), "nfapi") == 0) { - RC.gNB[j]->eth_params_n.my_addr = strdup(*(L1_ParamList.paramarray[j][L1_LOCAL_N_ADDRESS_IDX].strptr)); - RC.gNB[j]->eth_params_n.remote_addr = strdup(*(L1_ParamList.paramarray[j][L1_REMOTE_N_ADDRESS_IDX].strptr)); - RC.gNB[j]->eth_params_n.my_portc = *(L1_ParamList.paramarray[j][L1_LOCAL_N_PORTC_IDX].iptr); - RC.gNB[j]->eth_params_n.remote_portc = *(L1_ParamList.paramarray[j][L1_REMOTE_N_PORTC_IDX].iptr); - RC.gNB[j]->eth_params_n.my_portd = *(L1_ParamList.paramarray[j][L1_LOCAL_N_PORTD_IDX].iptr); - RC.gNB[j]->eth_params_n.remote_portd = *(L1_ParamList.paramarray[j][L1_REMOTE_N_PORTD_IDX].iptr); - RC.gNB[j]->eth_params_n.transp_preference = ETH_UDP_MODE; + gNB->eth_params_n.my_addr = strdup(*(L1_ParamList.paramarray[j][L1_LOCAL_N_ADDRESS_IDX].strptr)); + gNB->eth_params_n.remote_addr = strdup(*(L1_ParamList.paramarray[j][L1_REMOTE_N_ADDRESS_IDX].strptr)); + gNB->eth_params_n.my_portc = *(L1_ParamList.paramarray[j][L1_LOCAL_N_PORTC_IDX].iptr); + gNB->eth_params_n.remote_portc = *(L1_ParamList.paramarray[j][L1_REMOTE_N_PORTC_IDX].iptr); + gNB->eth_params_n.my_portd = *(L1_ParamList.paramarray[j][L1_LOCAL_N_PORTD_IDX].iptr); + gNB->eth_params_n.remote_portd = *(L1_ParamList.paramarray[j][L1_REMOTE_N_PORTD_IDX].iptr); + gNB->eth_params_n.transp_preference = ETH_UDP_MODE; - // sf_ahead = 2; // Cannot cope with 4 subframes betweem RX and TX - set it to 2 - - RC.nb_nr_macrlc_inst = 1; // This is used by mac_top_init_gNB() - - // This is used by init_gNB_afterRU() - RC.nb_nr_CC = (int *)malloc((1 + RC.nb_nr_inst) * sizeof(int)); - RC.nb_nr_CC[0] = 1; - - LOG_D(PHY, - "%s() NFAPI PNF mode - RC.nb_nr_inst=1 this is because phy_init_RU() uses that to index and not RC.num_gNB - why the " - "2 similar variables?\n", - __FUNCTION__); - LOG_D(PHY, "%s() NFAPI PNF mode - RC.nb_nr_CC[0]=%d for init_gNB_afterRU()\n", __FUNCTION__, RC.nb_nr_CC[0]); - LOG_D(PHY, - "%s() NFAPI PNF mode - RC.nb_nr_macrlc_inst:%d because used by mac_top_init_gNB()\n", - __FUNCTION__, - RC.nb_nr_macrlc_inst); - - configure_nr_nfapi_pnf(RC.gNB[j]->eth_params_n.remote_addr, - RC.gNB[j]->eth_params_n.remote_portc, - RC.gNB[j]->eth_params_n.my_addr, - RC.gNB[j]->eth_params_n.my_portd, - RC.gNB[j]->eth_params_n.remote_portd); - } else { // other midhaul + configure_nr_nfapi_pnf(gNB->eth_params_n.remote_addr, + gNB->eth_params_n.remote_portc, + gNB->eth_params_n.my_addr, + gNB->eth_params_n.my_portd, + gNB->eth_params_n.remote_portd); + } else { + // other midhaul, do nothing } - } // for (j = 0; j < RC.nb_nr_L1_inst; j++) - l1_north_init_gNB(); - } else { - LOG_E(PHY, "No " CONFIG_STRING_L1_LIST " configuration found"); - - // need to create some structures for VNF - - j = 0; - - if (RC.gNB[j] == NULL) { - RC.gNB[j] = (PHY_VARS_gNB *)malloc(sizeof(PHY_VARS_gNB)); - memset((void *)RC.gNB[j], 0, sizeof(PHY_VARS_gNB)); - RC.gNB[j]->Mod_id = j; + LOG_D(NR_PHY, "Initializing northbound interface for L1\n"); + l1_north_init_gNB(); + } else { + LOG_E(NR_PHY, "No " CONFIG_STRING_L1_LIST " configuration found"); } } } @@ -1003,7 +980,7 @@ static NR_ServingCellConfigCommon_t *get_scc_config(configmodule_interface_t *cf *scc->ssbSubcarrierSpacing, *frequencyInfoDL->absoluteFrequencySSB); LOG_I(RRC, "absoluteFrequencySSB %ld corresponds to %lu Hz\n", *frequencyInfoDL->absoluteFrequencySSB, ssb_freq); - if (get_softmodem_params()->sa) + if (IS_SA_MODE(get_softmodem_params())) check_ssb_raster(ssb_freq, *frequencyInfoDL->frequencyBandList.list.array[0], *scc->ssbSubcarrierSpacing); fix_scc(scc, ssb_bitmap); } @@ -1226,7 +1203,7 @@ static f1ap_setup_req_t *RC_read_F1Setup(uint64_t id, req->cell[0].info.measurement_timing_config = mtc_buf; req->cell[0].info.measurement_timing_config_len = len; - if (get_softmodem_params()->sa) { + if (IS_SA_MODE(get_softmodem_params())) { // in NSA we don't transmit SIB1, so cannot fill DU system information // so cannot send MIB either @@ -1258,8 +1235,6 @@ static f1ap_setup_req_t *RC_read_F1Setup(uint64_t id, void RCconfig_nr_macrlc(configmodule_interface_t *cfg) { int j = 0; - uint16_t prbbl[275] = {0}; - int num_prbbl = 0; paramlist_def_t GNBParamList = {GNB_CONFIG_STRING_GNB_LIST, NULL, 0}; paramdef_t GNBSParams[] = GNBSPARAMS_DESC; @@ -1276,21 +1251,6 @@ void RCconfig_nr_macrlc(configmodule_interface_t *cfg) GNBParams[i].chkPptr = &(config_check_GNBParams[i]); config_getlist(cfg, &GNBParamList, GNBParams, sizeofArray(GNBParams), NULL); - if (NFAPI_MODE != NFAPI_MODE_PNF) { - ////////// Identification parameters - - char *ulprbbl = *GNBParamList.paramarray[0][GNB_ULPRBBLACKLIST_IDX].strptr; - char *save = NULL; - char *pt = strtok_r(ulprbbl, ",", &save); - memset(prbbl, 0, sizeof(prbbl)); - while (pt) { - const int prb = atoi(pt); - AssertFatal(prb < 275, "RB %d out of bounds (max 275)\n", prb); - prbbl[prb] = 0x3FFF; // all symbols taken - pt = strtok_r(NULL, ",", &save); - num_prbbl++; - } - } paramdef_t MacRLC_Params[] = MACRLCPARAMS_DESC; paramlist_def_t MacRLC_ParamList = {CONFIG_STRING_MACRLC_LIST, NULL, 0}; /* map parameter checking array instances to parameter definition array instances */ @@ -1401,7 +1361,6 @@ void RCconfig_nr_macrlc(configmodule_interface_t *cfg) NR_ServingCellConfig_t *scd = get_scd_config(cfg); if (MacRLC_ParamList.numelt > 0) { - RC.nb_nr_macrlc_inst = MacRLC_ParamList.numelt; ngran_node_t node_type = get_node_type(); mac_top_init_gNB(node_type, scc, scd, &config); RC.nb_nr_mac_CC = (int *)malloc(RC.nb_nr_macrlc_inst * sizeof(int)); @@ -1482,8 +1441,13 @@ void RCconfig_nr_macrlc(configmodule_interface_t *cfg) RC.nrmac[j]->min_grant_prb = *(MacRLC_ParamList.paramarray[j][MACRLC_MIN_GRANT_PRB_IDX].u8ptr); RC.nrmac[j]->min_grant_mcs = *(MacRLC_ParamList.paramarray[j][MACRLC_MIN_GRANT_MCS_IDX].u8ptr); RC.nrmac[j]->identity_pm = *(MacRLC_ParamList.paramarray[j][MACRLC_IDENTITY_PM_IDX].u8ptr); - RC.nrmac[j]->num_ulprbbl = num_prbbl; - memcpy(RC.nrmac[j]->ulprbbl, prbbl, 275 * sizeof(prbbl[0])); + // PRB Blacklist + uint16_t prbbl[MAX_BWP_SIZE] = {0}; + int num_ulprbbl = get_prb_blacklist(j, prbbl); + if (num_ulprbbl != -1) { + LOG_I(NR_PHY, "Copying %d blacklisted PRB to L1 context\n", num_ulprbbl); + memcpy(RC.nrmac[j]->ulprbbl, prbbl, MAX_BWP_SIZE * sizeof(prbbl[0])); + } bool ab = *MacRLC_ParamList.paramarray[j][MACRLC_ANALOG_BEAMFORMING_IDX].u8ptr; if (ab) { NR_beam_info_t *beam_info = &RC.nrmac[j]->beam_info; @@ -1503,7 +1467,7 @@ void RCconfig_nr_macrlc(configmodule_interface_t *cfg) f1ap_served_cell_info_t info; read_du_cell_info(cfg, NODE_IS_DU(node_type), &gnb_id, &gnb_du_id, &name, &info, 1); - if (get_softmodem_params()->sa) { + if (IS_SA_MODE(get_softmodem_params())) { nr_mac_configure_sib1(RC.nrmac[0], &info.plmn, info.nr_cellid, *info.tac); if (scc->ext2 && scc->ext2->ntn_Config_r17) nr_mac_configure_sib19(RC.nrmac[0]); @@ -1797,8 +1761,14 @@ static void fill_measurement_configuration(uint8_t gnb_idx, gNB_RRC_INST *rrc) } } -void RCconfig_NRRRC(gNB_RRC_INST *rrc) +/** + * @brief Allocates and initializes RRC instances + * Currently assuming 1 instance + */ +gNB_RRC_INST *RCconfig_NRRRC() { + // Allocate memory for 1 RRC instance + gNB_RRC_INST *rrc = calloc(1, sizeof(*rrc)); int num_gnbs = 0; char aprefix[MAX_OPTNAME_SIZE*2 + 8]; @@ -1826,7 +1796,7 @@ void RCconfig_NRRRC(gNB_RRC_INST *rrc) config_getlist(config_get_if(), &GNBParamList, GNBParams, sizeofArray(GNBParams), NULL); if (GNBParamList.paramarray[i][GNB_GNB_ID_IDX].uptr == NULL) { // Calculate a default gNB ID - if (get_softmodem_params()->sa) { + if (IS_SA_MODE(get_softmodem_params())) { uint32_t hash; hash = ngap_generate_gNB_id (); gnb_id = i + (hash & 0xFFFFFF8); @@ -1938,7 +1908,9 @@ void RCconfig_NRRRC(gNB_RRC_INST *rrc) }//End if (num_gnbs>0) config_security(rrc); -}//End RCconfig_NRRRC function + + return rrc; +} int RCconfig_NR_NG(MessageDef *msg_p, uint32_t i) { @@ -1978,7 +1950,7 @@ int RCconfig_NR_NG(MessageDef *msg_p, uint32_t i) { for (k = 0; k < GNBParamList.numelt; k++) { if (GNBParamList.paramarray[k][GNB_GNB_ID_IDX].uptr == NULL) { // Calculate a default gNB ID - if (get_softmodem_params()->sa) { + if (IS_SA_MODE(get_softmodem_params())) { uint32_t hash; hash = ngap_generate_gNB_id (); @@ -2119,7 +2091,7 @@ int RCconfig_NR_NG(MessageDef *msg_p, uint32_t i) { // SCTP SETTING NGAP_REGISTER_GNB_REQ (msg_p).sctp_out_streams = SCTP_OUT_STREAMS; NGAP_REGISTER_GNB_REQ (msg_p).sctp_in_streams = SCTP_IN_STREAMS; - if (get_softmodem_params()->sa) { + if (IS_SA_MODE(get_softmodem_params())) { sprintf(aprefix,"%s.[%i].%s",GNB_CONFIG_STRING_GNB_LIST,k,GNB_CONFIG_STRING_SCTP_CONFIG); config_get(config_get_if(), SCTPParams, sizeofArray(SCTPParams), aprefix); NGAP_REGISTER_GNB_REQ (msg_p).sctp_in_streams = (uint16_t)*(SCTPParams[GNB_SCTP_INSTREAMS_IDX].uptr); @@ -2149,30 +2121,68 @@ int RCconfig_NR_NG(MessageDef *msg_p, uint32_t i) { return 0; } -void NRRCConfig(void) { +static pthread_mutex_t rc_mutex = PTHREAD_MUTEX_INITIALIZER; +static bool rc_done = false; + +/** + * @brief This function is initializing the RAN context + * the its various layer instances + */ +void NRRCConfig(void) +{ + // Call NRRCConfig only once + pthread_mutex_lock(&rc_mutex); + if (rc_done) { + LOG_E(GNB_APP, "RAN Context has been already initialized\n"); + pthread_mutex_unlock(&rc_mutex); + return; + } + + memset((void *)&RC, 0, sizeof(RC)); - paramlist_def_t MACRLCParamList = {CONFIG_STRING_MACRLC_LIST,NULL,0}; - paramlist_def_t L1ParamList = {CONFIG_STRING_L1_LIST,NULL,0}; - paramlist_def_t RUParamList = {CONFIG_STRING_RU_LIST,NULL,0}; paramdef_t GNBSParams[] = GNBSPARAMS_DESC; - -/* get global parameters, defined outside any section in the config file */ - config_get(config_get_if(), GNBSParams, sizeofArray(GNBSParams), NULL); - RC.nb_nr_inst = GNBSParams[GNB_ACTIVE_GNBS_IDX].numelt; - // Get num MACRLC instances + // Set num of gNBs instances + RC.nb_nr_inst = GNBSParams[GNB_ACTIVE_GNBS_IDX].numelt; + AssertFatal(RC.nb_nr_inst == NUMBER_OF_gNB_MAX, + "Configuration error: RC.nb_nr_inst (%d) must equal NUMBER_OF_gNB_MAX (%d).\n" + "Currently, only one instance of each layer (L1, L2, L3) is supported.\n" + "Ensure that nb_nr_inst matches the maximum allowed gNB instances in this configuration.", + RC.nb_nr_inst, NUMBER_OF_gNB_MAX); + + // Set num MACRLC instances + paramlist_def_t MACRLCParamList = {CONFIG_STRING_MACRLC_LIST, NULL, 0}; config_getlist(config_get_if(), &MACRLCParamList, NULL, 0, NULL); - RC.nb_nr_macrlc_inst = MACRLCParamList.numelt; - // Get num L1 instances + RC.nb_nr_macrlc_inst = MACRLCParamList.numelt; + + // Set num L1 instances + paramlist_def_t L1ParamList = {CONFIG_STRING_L1_LIST, NULL, 0}; config_getlist(config_get_if(), &L1ParamList, NULL, 0, NULL); RC.nb_nr_L1_inst = L1ParamList.numelt; - - // Get num RU instances - config_getlist(config_get_if(), &RUParamList, NULL, 0, NULL); - RC.nb_RU = RUParamList.numelt; -} + // Set num RU instances + paramlist_def_t RUParamList = {CONFIG_STRING_RU_LIST, NULL, 0}; + config_getlist(config_get_if(), &RUParamList, NULL, 0, NULL); + RC.nb_RU = RUParamList.numelt; + + // Set num component carriers + RC.nb_nr_CC = calloc_or_fail(1, sizeof(*RC.nb_nr_CC)); + *RC.nb_nr_CC = RC.nb_nr_L1_inst; + AssertFatal(*RC.nb_nr_CC <= MAX_NUM_CCs, "Configured number of CCs (%d) not supported\n", *RC.nb_nr_CC); + + LOG_I(GNB_APP, + "Initialized RAN Context: RC.nb_nr_inst = %d, RC.nb_nr_macrlc_inst = %d, RC.nb_nr_L1_inst = %d, RC.nb_RU = %d, " + "RC.nb_nr_CC[0] = %d\n", + RC.nb_nr_inst, + RC.nb_nr_macrlc_inst, + RC.nb_nr_L1_inst, + RC.nb_RU, + *RC.nb_nr_CC); + + rc_done = true; + pthread_mutex_unlock(&rc_mutex); +} int RCconfig_NR_X2(MessageDef *msg_p, uint32_t i) { int J, l; @@ -2208,7 +2218,7 @@ int RCconfig_NR_X2(MessageDef *msg_p, uint32_t i) { for (k = 0; k < GNBParamList.numelt; k++) { if (GNBParamList.paramarray[k][GNB_GNB_ID_IDX].uptr == NULL) { // Calculate a default eNB ID - if (get_softmodem_params()->sa) { + if (IS_SA_MODE(get_softmodem_params())) { uint32_t hash; hash = ngap_generate_gNB_id (); gnb_id = k + (hash & 0xFFFFFF8); @@ -2343,7 +2353,7 @@ int RCconfig_NR_X2(MessageDef *msg_p, uint32_t i) { X2AP_REGISTER_ENB_REQ (msg_p).sctp_out_streams = SCTP_OUT_STREAMS; X2AP_REGISTER_ENB_REQ (msg_p).sctp_in_streams = SCTP_IN_STREAMS; - if (get_softmodem_params()->sa) { + if (IS_SA_MODE(get_softmodem_params())) { sprintf(aprefix,"%s.[%i].%s",GNB_CONFIG_STRING_GNB_LIST,k,GNB_CONFIG_STRING_SCTP_CONFIG); config_get(config_get_if(), SCTPParams, sizeofArray(SCTPParams), aprefix); X2AP_REGISTER_ENB_REQ (msg_p).sctp_in_streams = (uint16_t)*(SCTPParams[GNB_SCTP_INSTREAMS_IDX].uptr); @@ -2407,7 +2417,6 @@ int gNB_app_handle_f1ap_gnb_cu_configuration_update(f1ap_gnb_cu_configuration_up gnb_cu_cfg_update->num_cells_to_activate, RC.nb_nr_inst); AssertFatal(gnb_cu_cfg_update->num_cells_to_activate == 1, "only one cell supported at the moment\n"); - AssertFatal(RC.nb_nr_inst == 1, "expected one instance\n"); gNB_MAC_INST *mac = RC.nrmac[0]; NR_SCHED_LOCK(&mac->sched_lock); for (j = 0; j < gnb_cu_cfg_update->num_cells_to_activate; j++) { @@ -2477,12 +2486,9 @@ ngran_node_t get_node_type(void) char aprefix[MAX_OPTNAME_SIZE*2 + 8]; sprintf(aprefix, "%s.[%i]", GNB_CONFIG_STRING_GNB_LIST, 0); config_getlist(config_get_if(), &GNBE1ParamList, GNBE1Params, sizeofArray(GNBE1Params), aprefix); - if (MacRLC_ParamList.numelt > 0) { - RC.nb_nr_macrlc_inst = MacRLC_ParamList.numelt; - for (int j = 0; j < RC.nb_nr_macrlc_inst; j++) { - if (strcmp(*(MacRLC_ParamList.paramarray[j][MACRLC_TRANSPORT_N_PREFERENCE_IDX].strptr), "f1") == 0) { - return ngran_gNB_DU; // MACRLCs present in config: it must be a DU - } + for (int j = 0; j < MacRLC_ParamList.numelt; j++) { + if (strcmp(*(MacRLC_ParamList.paramarray[j][MACRLC_TRANSPORT_N_PREFERENCE_IDX].strptr), "f1") == 0) { + return ngran_gNB_DU; // MACRLCs present in config: it must be a DU } } diff --git a/openair2/GNB_APP/gnb_config.h b/openair2/GNB_APP/gnb_config.h index e406a1ad7f..0a52684612 100644 --- a/openair2/GNB_APP/gnb_config.h +++ b/openair2/GNB_APP/gnb_config.h @@ -101,7 +101,7 @@ extern void NRRCConfig(void); //void enb_config_display(void); //void ru_config_display(void); -void RCconfig_NRRRC(gNB_RRC_INST *rrc); +gNB_RRC_INST *RCconfig_NRRRC(); int RCconfig_NR_NG(MessageDef *msg_p, uint32_t i); int RCconfig_NR_X2(MessageDef *msg_p, uint32_t i); void wait_f1_setup_response(void); diff --git a/openair2/LAYER2/NR_MAC_UE/config_ue.c b/openair2/LAYER2/NR_MAC_UE/config_ue.c index 19a799dab6..3c66515eef 100644 --- a/openair2/LAYER2/NR_MAC_UE/config_ue.c +++ b/openair2/LAYER2/NR_MAC_UE/config_ue.c @@ -872,6 +872,8 @@ void nr_rrc_mac_config_req_mib(module_id_t module_id, int sched_sib) { NR_UE_MAC_INST_t *mac = get_mac_inst(module_id); + int ret = pthread_mutex_lock(&mac->if_mutex); + AssertFatal(!ret, "mutex failed %d\n", ret); AssertFatal(mib, "MIB should not be NULL\n"); if (!mac->mib) mac->mib = calloc(1, sizeof(*mac->mib)); @@ -883,6 +885,8 @@ void nr_rrc_mac_config_req_mib(module_id_t module_id, else if (sched_sib == 2) mac->get_otherSI = true; nr_ue_decode_mib(mac, cc_idP); + ret = pthread_mutex_unlock(&mac->if_mutex); + AssertFatal(!ret, "mutex failed %d\n", ret); } static void setup_puschpowercontrol(NR_UE_MAC_INST_t *mac, NR_PUSCH_PowerControl_t *source, NR_PUSCH_PowerControl_t *target) @@ -1611,6 +1615,8 @@ void nr_rrc_mac_config_req_reset(module_id_t module_id, NR_UE_MAC_reset_cause_t cause) { NR_UE_MAC_INST_t *mac = get_mac_inst(module_id); + int ret = pthread_mutex_lock(&mac->if_mutex); + AssertFatal(!ret, "mutex failed %d\n", ret); fapi_nr_synch_request_t sync_req = {.target_Nid_cell = -1, .ssb_bw_scan = true}; switch (cause) { case GO_TO_IDLE: @@ -1649,6 +1655,8 @@ void nr_rrc_mac_config_req_reset(module_id_t module_id, default: AssertFatal(false, "Invalid MAC reset cause %d\n", cause); } + ret = pthread_mutex_unlock(&mac->if_mutex); + AssertFatal(!ret, "mutex failed %d\n", ret); } static int get_ta_offset(long *n_TimingAdvanceOffset) @@ -1676,6 +1684,8 @@ void nr_rrc_mac_config_req_sib1(module_id_t module_id, NR_ServingCellConfigCommonSIB_t *scc) { NR_UE_MAC_INST_t *mac = get_mac_inst(module_id); + int ret = pthread_mutex_lock(&mac->if_mutex); + AssertFatal(!ret, "mutex failed %d\n", ret); AssertFatal(scc, "SIB1 SCC should not be NULL\n"); UPDATE_IE(mac->tdd_UL_DL_ConfigurationCommon, scc->tdd_UL_DL_ConfigurationCommon, NR_TDD_UL_DL_ConfigCommon_t); @@ -1708,6 +1718,8 @@ void nr_rrc_mac_config_req_sib1(module_id_t module_id, if (!get_softmodem_params()->emulate_l1) mac->if_module->phy_config_request(&mac->phy_config); + ret = pthread_mutex_unlock(&mac->if_mutex); + AssertFatal(!ret, "mutex failed %d\n", ret); } void nr_rrc_mac_config_req_sib19_r17(module_id_t module_id, @@ -2518,8 +2530,10 @@ void nr_rrc_mac_config_req_cg(module_id_t module_id, NR_UE_NR_Capability_t *ue_Capability) { LOG_I(MAC,"[UE %d] Applying CellGroupConfig from gNodeB\n", module_id); - AssertFatal(cell_group_config, "CellGroupConfig should not be NULL\n"); NR_UE_MAC_INST_t *mac = get_mac_inst(module_id); + int ret = pthread_mutex_lock(&mac->if_mutex); + AssertFatal(!ret, "mutex failed %d\n", ret); + AssertFatal(cell_group_config, "CellGroupConfig should not be NULL\n"); if (cell_group_config->physicalCellGroupConfig) configure_physicalcellgroup(mac, cell_group_config->physicalCellGroupConfig); @@ -2562,4 +2576,6 @@ void nr_rrc_mac_config_req_cg(module_id_t module_id, if (!mac->dl_config_request || !mac->ul_config_request) ue_init_config_request(mac, mac->current_DL_BWP->scs); + ret = pthread_mutex_unlock(&mac->if_mutex); + AssertFatal(!ret, "mutex failed %d\n", ret); } diff --git a/openair2/LAYER2/NR_MAC_UE/mac_defs.h b/openair2/LAYER2/NR_MAC_UE/mac_defs.h index ffa09ccb25..426d8f88d1 100644 --- a/openair2/LAYER2/NR_MAC_UE/mac_defs.h +++ b/openair2/LAYER2/NR_MAC_UE/mac_defs.h @@ -617,6 +617,7 @@ typedef struct NR_UE_MAC_INST_s { int f_b_f_c; bool pusch_power_control_initialized; int delta_msg2; + pthread_mutex_t if_mutex; } NR_UE_MAC_INST_t; /*@}*/ diff --git a/openair2/LAYER2/NR_MAC_UE/main_ue_nr.c b/openair2/LAYER2/NR_MAC_UE/main_ue_nr.c index a60d8d2c43..f535d7f3b8 100644 --- a/openair2/LAYER2/NR_MAC_UE/main_ue_nr.c +++ b/openair2/LAYER2/NR_MAC_UE/main_ue_nr.c @@ -70,6 +70,7 @@ void nr_ue_init_mac(NR_UE_MAC_INST_t *mac) mac->p_Max = INT_MIN; mac->p_Max_alt = INT_MIN; mac->n_ta_offset = -1; + pthread_mutex_init(&mac->if_mutex, NULL); reset_mac_inst(mac); // need to inizialize because might not been setup (optional timer) @@ -160,7 +161,7 @@ NR_UE_MAC_INST_t *nr_l2_init_ue(int nb_inst) mac->ue_id = j; nr_ue_init_mac(mac); nr_ue_mac_default_configs(mac); - if (get_softmodem_params()->sa) + if (IS_SA_MODE(get_softmodem_params())) ue_init_config_request(mac, get_softmodem_params()->numerology); } diff --git a/openair2/LAYER2/NR_MAC_UE/nr_ra_procedures.c b/openair2/LAYER2/NR_MAC_UE/nr_ra_procedures.c index da183b3b14..493d90eaf6 100644 --- a/openair2/LAYER2/NR_MAC_UE/nr_ra_procedures.c +++ b/openair2/LAYER2/NR_MAC_UE/nr_ra_procedures.c @@ -783,7 +783,7 @@ void nr_ue_get_rach(NR_UE_MAC_INST_t *mac, int CC_id, frame_t frame, uint8_t gNB ra->Msg3_size = size_sdu + sizeof(NR_MAC_SUBHEADER_SHORT) + sizeof(NR_MAC_SUBHEADER_SHORT); } - } else if (!get_softmodem_params()->sa) { + } else if (!IS_SA_MODE(get_softmodem_params())) { uint8_t temp_pdu[16] = {0}; size_sdu = nr_write_ce_ulsch_pdu(temp_pdu, mac, 0, &(mac->crnti), NULL, NULL, NULL); ra->Msg3_size = size_sdu; diff --git a/openair2/LAYER2/NR_MAC_UE/nr_ue_procedures.c b/openair2/LAYER2/NR_MAC_UE/nr_ue_procedures.c index d61cbef202..bd233f2163 100644 --- a/openair2/LAYER2/NR_MAC_UE/nr_ue_procedures.c +++ b/openair2/LAYER2/NR_MAC_UE/nr_ue_procedures.c @@ -3810,7 +3810,7 @@ int nr_write_ce_ulsch_pdu(uint8_t *mac_ce, pdu, mac_ce); } - if (crnti && (!get_softmodem_params()->sa && get_softmodem_params()->do_ra && mac->ra.ra_state != nrRA_SUCCEEDED)) { + if (crnti && (!IS_SA_MODE(get_softmodem_params()) && get_softmodem_params()->do_ra && mac->ra.ra_state != nrRA_SUCCEEDED)) { LOG_D(NR_MAC, "In %s: generating C-RNTI MAC CE with C-RNTI %x\n", __FUNCTION__, (*crnti)); // MAC CE fixed subheader diff --git a/openair2/LAYER2/NR_MAC_gNB/config.c b/openair2/LAYER2/NR_MAC_gNB/config.c index 7baca618d1..bed7f2c961 100644 --- a/openair2/LAYER2/NR_MAC_gNB/config.c +++ b/openair2/LAYER2/NR_MAC_gNB/config.c @@ -437,7 +437,7 @@ static void config_common(gNB_MAC_INST *nrmac, + (get_N_RA_RB(cfg->prach_config.prach_sub_c_spacing.value, frequencyInfoUL->scs_SpecificCarrierList.list.array[0]->subcarrierSpacing) * i); - if (get_softmodem_params()->sa) { + if (IS_SA_MODE(get_softmodem_params())) { prach_fd_occasion->k1.value = NRRIV2PRBOFFSET(scc->uplinkConfigCommon->initialUplinkBWP->genericParameters.locationAndBandwidth, MAX_BWP_SIZE) + rach_ConfigCommon->rach_ConfigGeneric.msg1_FrequencyStart @@ -712,14 +712,6 @@ void nr_mac_config_scc(gNB_MAC_INST *nrmac, NR_ServingCellConfigCommon_t *scc, c (nrmac->ulsch_slot_bitmap[slot / 64] & ((uint64_t)1 << (slot % 64))) != 0); } - if (get_softmodem_params()->phy_test) { - nrmac->pre_processor_dl = nr_preprocessor_phytest; - nrmac->pre_processor_ul = nr_ul_preprocessor_phytest; - } else { - nrmac->pre_processor_dl = nr_init_fr1_dlsch_preprocessor(0); - nrmac->pre_processor_ul = nr_init_fr1_ulsch_preprocessor(0); - } - NR_COMMON_channels_t *cc = &nrmac->common_channels[0]; NR_SCHED_LOCK(&nrmac->sched_lock); for (int n = 0; n < NR_NB_RA_PROC_MAX; n++) { @@ -751,7 +743,7 @@ void nr_fill_sched_osi(gNB_MAC_INST *nrmac, const struct NR_SetupRelease_PDCCH_C void nr_mac_configure_sib1(gNB_MAC_INST *nrmac, const f1ap_plmn_t *plmn, uint64_t cellID, int tac) { - AssertFatal(get_softmodem_params()->sa > 0, "error: SIB1 only applicable for SA\n"); + AssertFatal(IS_SA_MODE(get_softmodem_params()), "error: SIB1 only applicable for SA\n"); NR_COMMON_channels_t *cc = &nrmac->common_channels[0]; NR_ServingCellConfigCommon_t *scc = cc->ServingCellConfigCommon; @@ -763,7 +755,7 @@ void nr_mac_configure_sib1(gNB_MAC_INST *nrmac, const f1ap_plmn_t *plmn, uint64_ void nr_mac_configure_sib19(gNB_MAC_INST *nrmac) { - AssertFatal(get_softmodem_params()->sa > 0, "error: SIB19 only applicable for SA\n"); + AssertFatal(IS_SA_MODE(get_softmodem_params()), "error: SIB19 only applicable for SA\n"); NR_COMMON_channels_t *cc = &nrmac->common_channels[0]; NR_ServingCellConfigCommon_t *scc = cc->ServingCellConfigCommon; NR_BCCH_DL_SCH_Message_t *sib19 = get_SIB19_NR(scc); diff --git a/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler.c b/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler.c index af07ecfb54..bcd5cfb26c 100644 --- a/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler.c +++ b/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler.c @@ -221,7 +221,7 @@ void gNB_dlsch_ulsch_scheduler(module_id_t module_idP, frame_t frame, sub_frame_ // This schedules SIB1 // SIB19 will be scheduled if ntn_Config_r17 is initialized - if (get_softmodem_params()->sa == 1) { + if (IS_SA_MODE(get_softmodem_params())) { schedule_nr_sib1(module_idP, frame, slot, &sched_info->DL_req, &sched_info->TX_req); if (cc->sib19) schedule_nr_sib19(module_idP, frame, slot, &sched_info->DL_req, &sched_info->TX_req, cc->sib19_bcch_length, cc->sib19_bcch_pdu); diff --git a/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_RA.c b/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_RA.c index 9dd76099d9..0a51c9c803 100644 --- a/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_RA.c +++ b/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_RA.c @@ -2291,7 +2291,7 @@ void nr_clear_ra_proc(NR_RA_t *ra) NR_SCHED_ENSURE_LOCKED(&RC.nrmac[0]->sched_lock); memset(ra, 0, sizeof(*ra)); ra->ra_state = nrRA_gNB_IDLE; - if (get_softmodem_params()->sa) { // in SA, prefill with allowed preambles + if (IS_SA_MODE(get_softmodem_params())) { // in SA, prefill with allowed preambles ra->preambles.num_preambles = MAX_NUM_NR_PRACH_PREAMBLES; for (int i = 0; i < MAX_NUM_NR_PRACH_PREAMBLES; i++) ra->preambles.preamble_list[i] = i; diff --git a/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_bch.c b/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_bch.c index 60e3fb00a1..9c69c2660c 100644 --- a/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_bch.c +++ b/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_bch.c @@ -187,7 +187,7 @@ void schedule_nr_mib(module_id_t module_idP, frame_t frameP, sub_frame_t slotP, const int prb_offset = offset_pointa >> scs; schedule_ssb(frameP, slotP, scc, dl_req, i_ssb, beam_index, ssbSubcarrierOffset, offset_pointa, mib_pdu); fill_ssb_vrb_map(cc, prb_offset, ssbSubcarrierOffset, ssb_start_symbol, CC_id, beam.idx); - if (get_softmodem_params()->sa == 1) { + if (IS_SA_MODE(get_softmodem_params())) { get_type0_PDCCH_CSS_config_parameters(&gNB->type0_PDCCH_CSS_config[i_ssb], frameP, mib, @@ -219,7 +219,7 @@ void schedule_nr_mib(module_id_t module_idP, frame_t frameP, sub_frame_t slotP, const int prb_offset = offset_pointa >> scs; schedule_ssb(frameP, slotP, scc, dl_req, i_ssb, beam_index, ssbSubcarrierOffset, offset_pointa, mib_pdu); fill_ssb_vrb_map(cc, prb_offset, ssbSubcarrierOffset, ssb_start_symbol, CC_id, beam.idx); - if (get_softmodem_params()->sa == 1) { + if (IS_SA_MODE(get_softmodem_params())) { get_type0_PDCCH_CSS_config_parameters(&gNB->type0_PDCCH_CSS_config[i_ssb], frameP, mib, @@ -251,7 +251,7 @@ void schedule_nr_mib(module_id_t module_idP, frame_t frameP, sub_frame_t slotP, const int prb_offset = offset_pointa >> (scs-2); // reference 60kHz schedule_ssb(frameP, slotP, scc, dl_req, i_ssb, beam_index, ssbSubcarrierOffset, offset_pointa, mib_pdu); fill_ssb_vrb_map(cc, prb_offset, ssbSubcarrierOffset >> (scs - 2), ssb_start_symbol, CC_id, beam.idx); - if (get_softmodem_params()->sa == 1) { + if (IS_SA_MODE(get_softmodem_params())) { get_type0_PDCCH_CSS_config_parameters(&gNB->type0_PDCCH_CSS_config[i_ssb], frameP, mib, diff --git a/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_primitives.c b/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_primitives.c index 5930ef7f44..dc442bedd0 100644 --- a/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_primitives.c +++ b/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_primitives.c @@ -3004,7 +3004,7 @@ static void nr_mac_apply_cellgroup(gNB_MAC_INST *mac, NR_UE_info_t *UE, frame_t reset_srs_stats(UE); - if (get_softmodem_params()->sa) { + if (IS_SA_MODE(get_softmodem_params())) { // add all available DL,UL HARQ processes for this UE in SA create_dl_harq_list(sched_ctrl, &UE->sc_info); create_ul_harq_list(sched_ctrl, &UE->sc_info); diff --git a/openair2/LAYER2/NR_MAC_gNB/nr_mac_gNB.h b/openair2/LAYER2/NR_MAC_gNB/nr_mac_gNB.h index e0cf53c5a0..420445076f 100644 --- a/openair2/LAYER2/NR_MAC_gNB/nr_mac_gNB.h +++ b/openair2/LAYER2/NR_MAC_gNB/nr_mac_gNB.h @@ -842,7 +842,7 @@ typedef struct gNB_MAC_INST_s { NR_COMMON_channels_t common_channels[NFAPI_CC_MAX]; /// current PDU index (BCH,DLSCH) uint16_t pdu_index[NFAPI_CC_MAX]; - int num_ulprbbl; + /// UL PRBs blacklist uint16_t ulprbbl[MAX_BWP_SIZE]; /// NFAPI Config Request Structure nfapi_nr_config_request_scf_t config[NFAPI_CC_MAX]; diff --git a/openair2/LAYER2/nr_rlc/nr_rlc_sdu.c b/openair2/LAYER2/nr_rlc/nr_rlc_sdu.c index a5c722a036..60f50d0afd 100644 --- a/openair2/LAYER2/nr_rlc/nr_rlc_sdu.c +++ b/openair2/LAYER2/nr_rlc/nr_rlc_sdu.c @@ -32,13 +32,14 @@ nr_rlc_sdu_segment_t *nr_rlc_new_sdu( { /* allocate sdu header and data together */ nr_rlc_sdu_t *sdu = malloc(sizeof(nr_rlc_sdu_t) + size); + nr_rlc_sdu_segment_t *ret = calloc(1, sizeof(nr_rlc_sdu_segment_t)); + + DevAssert(sdu != NULL); + DevAssert(ret != NULL); + /* only memset the header */ memset(sdu, 0 , sizeof(*sdu)); - nr_rlc_sdu_segment_t *ret = calloc(1, sizeof(nr_rlc_sdu_segment_t)); - if (sdu == NULL || ret == NULL) - goto oom; - sdu->ref_count = 1; sdu->sn = -1; /* set later */ sdu->upper_layer_id = upper_layer_id; @@ -54,10 +55,6 @@ nr_rlc_sdu_segment_t *nr_rlc_new_sdu( ret->is_last = 1; return ret; - -oom: - LOG_E(RLC, "%s:%d:%s: out of memory\n", __FILE__, __LINE__, __FUNCTION__); - exit(1); } int nr_rlc_free_sdu_segment(nr_rlc_sdu_segment_t *sdu) diff --git a/openair2/NR_UE_PHY_INTERFACE/NR_IF_Module.c b/openair2/NR_UE_PHY_INTERFACE/NR_IF_Module.c index c4faefa0fa..10faa6cc65 100644 --- a/openair2/NR_UE_PHY_INTERFACE/NR_IF_Module.c +++ b/openair2/NR_UE_PHY_INTERFACE/NR_IF_Module.c @@ -65,7 +65,6 @@ queue_t nr_dl_tti_req_queue; queue_t nr_tx_req_queue; queue_t nr_ul_dci_req_queue; queue_t nr_ul_tti_req_queue; -pthread_mutex_t mac_IF_mutex; static void save_pdsch_pdu_for_crnti(nfapi_nr_dl_tti_request_t *dl_tti_request); void nrue_init_standalone_socket(int tx_port, int rx_port) @@ -343,7 +342,7 @@ static bool is_my_dci(NR_UE_MAC_INST_t *mac, nfapi_nr_dl_dci_pdu_t *received_pdu (received_pdu->RNTI != mac->ra.ra_rnti || mac->ra.RA_RAPID_found)) return false; } - if (get_softmodem_params()->sa) { + if (IS_SA_MODE(get_softmodem_params())) { if (mac->state == UE_NOT_SYNC) return false; if (received_pdu->RNTI == 0xFFFF) @@ -1141,19 +1140,18 @@ void update_harq_status(NR_UE_MAC_INST_t *mac, uint8_t harq_pid, uint8_t ack_nac int nr_ue_ul_indication(nr_uplink_indication_t *ul_info) { - int ret = pthread_mutex_lock(&mac_IF_mutex); - AssertFatal(!ret, "mutex failed %d\n", ret); - LOG_D(PHY, "Locked in ul, slot %d\n", ul_info->slot); - module_id_t module_id = ul_info->module_id; NR_UE_MAC_INST_t *mac = get_mac_inst(module_id); + int ret = pthread_mutex_lock(&mac->if_mutex); + AssertFatal(!ret, "mutex failed %d\n", ret); + LOG_D(PHY, "Locked in ul, slot %d\n", ul_info->slot); LOG_T(NR_MAC, "Not calling scheduler mac->ra.ra_state = %d\n", mac->ra.ra_state); if (is_nr_UL_slot(mac->tdd_UL_DL_ConfigurationCommon, ul_info->slot, mac->frame_type)) nr_ue_ul_scheduler(mac, ul_info); - pthread_mutex_unlock(&mac_IF_mutex); - + ret = pthread_mutex_unlock(&mac->if_mutex); + AssertFatal(!ret, "mutex failed %d\n", ret); return 0; } @@ -1264,26 +1262,29 @@ static uint32_t nr_ue_dl_processing(nr_downlink_indication_t *dl_info) int nr_ue_dl_indication(nr_downlink_indication_t *dl_info) { - int ret = pthread_mutex_lock(&mac_IF_mutex); - AssertFatal(!ret, "mutex failed %d\n", ret); uint32_t ret2 = 0; NR_UE_MAC_INST_t *mac = get_mac_inst(dl_info->module_id); + int ret = pthread_mutex_lock(&mac->if_mutex); + AssertFatal(!ret, "mutex failed %d\n", ret); if (!dl_info->dci_ind && !dl_info->rx_ind) // DL indication to process DCI reception nr_ue_dl_scheduler(mac, dl_info); else // DL indication to process data channels ret2 = nr_ue_dl_processing(dl_info); - pthread_mutex_unlock(&mac_IF_mutex); + ret = pthread_mutex_unlock(&mac->if_mutex); + AssertFatal(!ret, "mutex failed %d\n", ret); return ret2; } void nr_ue_slot_indication(uint8_t mod_id) { - pthread_mutex_lock(&mac_IF_mutex); NR_UE_MAC_INST_t *mac = get_mac_inst(mod_id); + int ret = pthread_mutex_lock(&mac->if_mutex); + AssertFatal(!ret, "mutex failed %d\n", ret); update_mac_timers(mac); - pthread_mutex_unlock(&mac_IF_mutex); + ret = pthread_mutex_unlock(&mac->if_mutex); + AssertFatal(!ret, "mutex failed %d\n", ret); } nr_ue_if_module_t *nr_ue_if_module_init(uint32_t module_id) @@ -1309,7 +1310,6 @@ nr_ue_if_module_t *nr_ue_if_module_init(uint32_t module_id) nr_ue_if_module_inst[module_id]->ul_indication = nr_ue_ul_indication; nr_ue_if_module_inst[module_id]->slot_indication = nr_ue_slot_indication; } - pthread_mutex_init(&mac_IF_mutex, NULL); return nr_ue_if_module_inst[module_id]; } diff --git a/openair2/RRC/NR/nr_rrc_config.c b/openair2/RRC/NR/nr_rrc_config.c index cae49d3f53..6966394667 100644 --- a/openair2/RRC/NR/nr_rrc_config.c +++ b/openair2/RRC/NR/nr_rrc_config.c @@ -1835,7 +1835,7 @@ NR_BCCH_BCH_Message_t *get_new_MIB_NR(const NR_ServingCellConfigCommon_t *scc) AssertFatal(scc->ssbSubcarrierSpacing != NULL, "scc->ssbSubcarrierSpacing is null\n"); int ssb_subcarrier_offset = 31; // default value for NSA - if (get_softmodem_params()->sa) { + if (IS_SA_MODE(get_softmodem_params())) { ssb_subcarrier_offset = get_ssb_subcarrier_offset(*scc->downlinkConfigCommon->frequencyInfoDL->absoluteFrequencySSB, scc->downlinkConfigCommon->frequencyInfoDL->absoluteFrequencyPointA, *scc->ssbSubcarrierSpacing); diff --git a/openair2/RRC/NR/rrc_gNB.c b/openair2/RRC/NR/rrc_gNB.c index ce42a7be3f..c018b8030a 100644 --- a/openair2/RRC/NR/rrc_gNB.c +++ b/openair2/RRC/NR/rrc_gNB.c @@ -219,7 +219,7 @@ static void init_NR_SI(gNB_RRC_INST *rrc) AssertFatal(NODE_IS_MONOLITHIC(rrc->node_type), "phy_test and do_ra only work in monolithic\n"); rrc_gNB_ue_context_t *ue_context_p = rrc_gNB_allocate_new_ue_context(rrc); LOG_I(NR_RRC,"Adding new user (%p)\n",ue_context_p); - if (!NODE_IS_CU(RC.nrrrc[0]->node_type)) { + if (!NODE_IS_CU(rrc->node_type)) { rrc_add_nsa_user(rrc,ue_context_p,NULL); } } diff --git a/openair2/RRC/NR/rrc_gNB_du.c b/openair2/RRC/NR/rrc_gNB_du.c index 82b18f124b..98cdb313df 100644 --- a/openair2/RRC/NR/rrc_gNB_du.c +++ b/openair2/RRC/NR/rrc_gNB_du.c @@ -340,7 +340,7 @@ void rrc_gNB_process_f1_setup_req(f1ap_setup_req_t *req, sctp_assoc_t assoc_id) NR_MIB_t *mib = NULL; NR_SIB1_t *sib1 = NULL; - if (sys_info != NULL && sys_info->mib != NULL && !(sys_info->sib1 == NULL && get_softmodem_params()->sa)) { + if (sys_info != NULL && sys_info->mib != NULL && !(sys_info->sib1 == NULL && IS_SA_MODE(get_softmodem_params()))) { if (!extract_sys_info(sys_info, &mib, &sib1)) { LOG_W(RRC, "rejecting DU ID %ld\n", req->gNB_DU_id); fail.cause = F1AP_CauseProtocol_semantic_error; @@ -491,7 +491,7 @@ void rrc_gNB_process_f1_du_configuration_update(f1ap_gnb_du_configuration_update const f1ap_gnb_du_system_info_t *sys_info = conf_up->cell_to_modify[0].sys_info; - if (sys_info != NULL && sys_info->mib != NULL && !(sys_info->sib1 == NULL && get_softmodem_params()->sa)) { + if (sys_info != NULL && sys_info->mib != NULL && !(sys_info->sib1 == NULL && IS_SA_MODE(get_softmodem_params()))) { // MIB is mandatory, so will be overwritten. SIB1 is optional, so will // only be overwritten if present in sys_info ASN_STRUCT_FREE(asn_DEF_NR_MIB, du->mib); diff --git a/openair2/RRC/NR/rrc_gNB_internode.c b/openair2/RRC/NR/rrc_gNB_internode.c index add6823e15..6b001e16fd 100644 --- a/openair2/RRC/NR/rrc_gNB_internode.c +++ b/openair2/RRC/NR/rrc_gNB_internode.c @@ -96,7 +96,7 @@ NR_CG_Config_t *generate_CG_Config(const NR_RRCReconfiguration_t *reconfig, cons (enc_rval.encoded+7)>>3); FILE *fd; // file to be generated for nr-ue - if (get_softmodem_params()->phy_test==1 || get_softmodem_params()->do_ra > 0 || get_softmodem_params()->sa == 1) { + if (get_softmodem_params()->phy_test==1 || get_softmodem_params()->do_ra > 0) { // This is for phytest only, emulate first X2 message if uecap.raw file is present LOG_I(RRC,"Dumping NR_RRCReconfiguration message (%jd bytes)\n",(enc_rval.encoded+7)>>3); for (int i=0; i<(enc_rval.encoded+7)>>3; i++) { @@ -121,7 +121,7 @@ NR_CG_Config_t *generate_CG_Config(const NR_RRCReconfiguration_t *reconfig, cons - if (get_softmodem_params()->phy_test==1 || get_softmodem_params()->do_ra > 0 || get_softmodem_params()->sa == 1) { + if (get_softmodem_params()->phy_test==1 || get_softmodem_params()->do_ra > 0) { LOG_I(RRC,"Dumping scg_RB_Config message (%jd bytes)\n",(enc_rval.encoded+7)>>3); for (int i=0; i<(enc_rval.encoded+7)>>3; i++) { diff --git a/openair2/RRC/NR/rrc_gNB_nsa.c b/openair2/RRC/NR/rrc_gNB_nsa.c index ceae4703f6..73509f6d72 100644 --- a/openair2/RRC/NR/rrc_gNB_nsa.c +++ b/openair2/RRC/NR/rrc_gNB_nsa.c @@ -116,7 +116,7 @@ RB_PROTOTYPE(rrc_nr_ue_tree_s, rrc_gNB_ue_context_s, entries, void rrc_add_nsa_user(gNB_RRC_INST *rrc, rrc_gNB_ue_context_t *ue_context_p, x2ap_ENDC_sgnb_addition_req_t *m) { - AssertFatal(!get_softmodem_params()->sa, "%s() cannot be called in SA mode, it is intrinsically for NSA\n", __func__); + AssertFatal(!IS_SA_MODE(get_softmodem_params()), "%s() cannot be called in SA mode, it is intrinsically for NSA\n", __func__); // generate nr-Config-r15 containers for LTE RRC : inside message for X2 EN-DC (CG-Config Message from 38.331) const nr_mac_config_t *configuration = &RC.nrmac[0]->radio_config; MessageDef *msg; @@ -153,7 +153,7 @@ void rrc_add_nsa_user(gNB_RRC_INST *rrc, rrc_gNB_ue_context_t *ue_context_p, x2a } // NR RRCReconfiguration - if (get_softmodem_params()->phy_test == 1 || get_softmodem_params()->do_ra == 1 || get_softmodem_params()->sa == 1){ + if (get_softmodem_params()->phy_test == 1 || get_softmodem_params()->do_ra == 1) { UE->rb_config = get_default_rbconfig(10 /* EPS bearer ID */, 1 /* drb ID */, NR_CipheringAlgorithm_nea0, NR_SecurityConfig__keyToUse_master); } else { /* TODO: handle more than one bearer */ diff --git a/openair2/RRC/NR_UE/rrc_UE.c b/openair2/RRC/NR_UE/rrc_UE.c index 61f8391586..53364b0768 100644 --- a/openair2/RRC/NR_UE/rrc_UE.c +++ b/openair2/RRC/NR_UE/rrc_UE.c @@ -223,7 +223,7 @@ static void nr_rrc_ue_process_rrcReconfiguration(NR_UE_RRC_INST_t *rrc, nr_rrc_cellgroup_configuration(rrc, cellGroupConfig); - AssertFatal(!get_softmodem_params()->sa, "secondaryCellGroup only used in NSA for now\n"); + AssertFatal(!IS_SA_MODE(get_softmodem_params()), "secondaryCellGroup only used in NSA for now\n"); nr_rrc_mac_config_req_cg(rrc->ue_id, 0, cellGroupConfig, rrc->UECap.UE_NR_Capability); asn1cFreeStruc(asn_DEF_NR_CellGroupConfig, cellGroupConfig); } @@ -551,7 +551,7 @@ static void nr_rrc_ue_decode_NR_BCCH_BCH_Message(NR_UE_RRC_INST_t *rrc, } int get_sib = 0; - if (get_softmodem_params()->sa && bcch_message->message.present == NR_BCCH_BCH_MessageType_PR_mib + if (IS_SA_MODE(get_softmodem_params()) && bcch_message->message.present == NR_BCCH_BCH_MessageType_PR_mib && bcch_message->message.choice.mib->cellBarred == NR_MIB__cellBarred_notBarred && rrc->nrRrcState != RRC_STATE_DETACH_NR) { NR_UE_RRC_SI_INFO *SI_info = &rrc->perNB[gNB_index].SInfo; // to schedule MAC to get SI if required @@ -994,7 +994,7 @@ static void rrc_ue_generate_RRCSetupComplete(const NR_UE_RRC_INST_t *rrc, const const char *nas_msg; int nas_msg_length; - if (get_softmodem_params()->sa) { + if (IS_SA_MODE(get_softmodem_params())) { as_nas_info_t initialNasMsg; nr_ue_nas_t *nas = get_ue_nas_info(rrc->ue_id); generateRegistrationRequest(&initialNasMsg, nas); diff --git a/openair3/NAS/NR_UE/nr_nas_msg.c b/openair3/NAS/NR_UE/nr_nas_msg.c index 59d646e3df..1199aad94b 100644 --- a/openair3/NAS/NR_UE/nr_nas_msg.c +++ b/openair3/NAS/NR_UE/nr_nas_msg.c @@ -1210,11 +1210,6 @@ static int get_user_nssai_idx(const nr_nas_msg_snssai_t allowed_nssai[8], const void *nas_nrue_task(void *args_p) { - for (int UE_id = 0; UE_id < NB_UE_INST; UE_id++) { - // This sets UE uicc from command line. Needs to be called 2 seconds into nr-ue runtime, otherwise the unused command line - // arguments will be reported as unused and the modem asserts. - (void)get_ue_nas_info(UE_id); - } while (1) { nas_nrue(NULL); } @@ -1453,3 +1448,9 @@ void *nas_nrue(void *args_p) } return NULL; } + +void nas_init_nrue(int num_ues) { + for (int i = 0; i < num_ues; i++) { + (void)get_ue_nas_info(i); + } +} diff --git a/openair3/NAS/NR_UE/nr_nas_msg.h b/openair3/NAS/NR_UE/nr_nas_msg.h index 2e687baf8f..e10ac54b0f 100644 --- a/openair3/NAS/NR_UE/nr_nas_msg.h +++ b/openair3/NAS/NR_UE/nr_nas_msg.h @@ -160,5 +160,6 @@ nr_ue_nas_t *get_ue_nas_info(module_id_t module_id); void generateRegistrationRequest(as_nas_info_t *initialNasMsg, nr_ue_nas_t *nas); void *nas_nrue_task(void *args_p); void *nas_nrue(void *args_p); +void nas_init_nrue(int num_ues); #endif /* __NR_NAS_MSG_SIM_H__*/ diff --git a/radio/rfsimulator/README.md b/radio/rfsimulator/README.md index c86724fa0d..39e34ce651 100644 --- a/radio/rfsimulator/README.md +++ b/radio/rfsimulator/README.md @@ -133,7 +133,7 @@ Notes: 1. This starts the gNB and UE in the `phy-test` UP-only mode where the gNB is started as if a UE had already connected. See [`RUNMODEM.md`](../../doc/RUNMODEM.md) for more details. 2. `` should be the IP interface address of the remote host running the gNB executable, if the gNB and nrUE run on separate hosts, or be omitted if they are on the same host. 3. To enable the noS1 mode, `--noS1` option should be added to the command line, see again [`RUNMODEM.md`](../../doc/RUNMODEM.md). -4. To operate the gNB/UE with a 5GC, start them using the `--sa` option. More information can be found [here](../../../doc/NR_SA_Tutorial_OAI_CN5G.md). +4. Information on operating the gNB/UE with a 5GC can be found here. [here](../../../doc/NR_SA_Tutorial_OAI_CN5G.md). ## Store and replay diff --git a/targets/PROJECTS/GENERIC-NR-5GC/CONF/cu_gnb.conf b/targets/PROJECTS/GENERIC-NR-5GC/CONF/cu_gnb.conf index 6730f22b41..1666ea4a70 100644 --- a/targets/PROJECTS/GENERIC-NR-5GC/CONF/cu_gnb.conf +++ b/targets/PROJECTS/GENERIC-NR-5GC/CONF/cu_gnb.conf @@ -1,7 +1,6 @@ Active_gNBs = ( "gNB-Eurecom-CU"); # Asn1_verbosity, choice in: none, info, annoying Asn1_verbosity = "none"; -Num_Threads_PUSCH = 8; gNBs = ( diff --git a/targets/PROJECTS/GENERIC-NR-5GC/CONF/gnb-vnf.sa.band78.273prb.aerial.conf b/targets/PROJECTS/GENERIC-NR-5GC/CONF/gnb-vnf.sa.band78.273prb.aerial.conf index 20ba798023..b149913224 100644 --- a/targets/PROJECTS/GENERIC-NR-5GC/CONF/gnb-vnf.sa.band78.273prb.aerial.conf +++ b/targets/PROJECTS/GENERIC-NR-5GC/CONF/gnb-vnf.sa.band78.273prb.aerial.conf @@ -2,7 +2,6 @@ Active_gNBs = ( "gNB-OAI"); # Asn1_verbosity, choice in: none, info, annoying Asn1_verbosity = "none"; -sa = 1; nfapi = "AERIAL"; pdcp-drop = 1; diff --git a/targets/PROJECTS/GENERIC-NR-5GC/CONF/gnb-vnf.sa.cbrs.aerial.conf b/targets/PROJECTS/GENERIC-NR-5GC/CONF/gnb-vnf.sa.cbrs.aerial.conf index 5346a58aae..8a058b9f92 100644 --- a/targets/PROJECTS/GENERIC-NR-5GC/CONF/gnb-vnf.sa.cbrs.aerial.conf +++ b/targets/PROJECTS/GENERIC-NR-5GC/CONF/gnb-vnf.sa.cbrs.aerial.conf @@ -2,7 +2,6 @@ Active_gNBs = ( "gNB-OAI"); # Asn1_verbosity, choice in: none, info, annoying Asn1_verbosity = "none"; -sa = 1; nfapi = "AERIAL"; gNBs = diff --git a/targets/PROJECTS/GENERIC-NR-5GC/CONF/gnb.sa.band1.u0.52PRB.usrpb210.conf b/targets/PROJECTS/GENERIC-NR-5GC/CONF/gnb.sa.band1.u0.52PRB.usrpb210.conf index c5657670a8..1c15b40967 100644 --- a/targets/PROJECTS/GENERIC-NR-5GC/CONF/gnb.sa.band1.u0.52PRB.usrpb210.conf +++ b/targets/PROJECTS/GENERIC-NR-5GC/CONF/gnb.sa.band1.u0.52PRB.usrpb210.conf @@ -2,8 +2,6 @@ Active_gNBs = ( "gNB-OAI"); # Asn1_verbosity, choice in: none, info, annoying Asn1_verbosity = "none"; -sa = 1; - gNBs = ( { diff --git a/targets/PROJECTS/GENERIC-NR-5GC/CONF/gnb.sa.band257.u3.32prb.usrpx410.conf b/targets/PROJECTS/GENERIC-NR-5GC/CONF/gnb.sa.band257.u3.32prb.usrpx410.conf index 27f69605b2..d12752130f 100644 --- a/targets/PROJECTS/GENERIC-NR-5GC/CONF/gnb.sa.band257.u3.32prb.usrpx410.conf +++ b/targets/PROJECTS/GENERIC-NR-5GC/CONF/gnb.sa.band257.u3.32prb.usrpx410.conf @@ -2,8 +2,6 @@ Active_gNBs = ( "gNB-OAI"); # Asn1_verbosity, choice in: none, info, annoying Asn1_verbosity = "none"; -sa = 1; - gNBs = ( { diff --git a/targets/PROJECTS/GENERIC-NR-5GC/CONF/gnb.sa.band41.fr1.52PRB.usrpb210.conf b/targets/PROJECTS/GENERIC-NR-5GC/CONF/gnb.sa.band41.fr1.52PRB.usrpb210.conf index 9e6f84f37b..6ef35cb6c8 100644 --- a/targets/PROJECTS/GENERIC-NR-5GC/CONF/gnb.sa.band41.fr1.52PRB.usrpb210.conf +++ b/targets/PROJECTS/GENERIC-NR-5GC/CONF/gnb.sa.band41.fr1.52PRB.usrpb210.conf @@ -1,5 +1,5 @@ # This file is derived from ./phy-demo/oai/targets/PROJECTS/GENERIC-NR-5GC/CONF/gnb.sa.band78.fr1.24PRB.usrpb210.conf -# ./nr-uesoftmodem -r 24 --numerology 1 --band 41 -C 2593320000 --ssb 24 --rfsim --sa +# ./nr-uesoftmodem -r 24 --numerology 1 --band 41 -C 2593320000 --ssb 24 --rfsim Active_gNBs = ( "gNB-OAI"); # Asn1_verbosity, choice in: none, info, annoying