diff --git a/README.md b/README.md index 4f38f77e4e..2077b3d20b 100644 --- a/README.md +++ b/README.md @@ -21,28 +21,14 @@ # OpenAirInterface License # -### Included Fixes: ### -- Ease of use of gprof and address sanitizer for debugging purposes -- Updated json files to allow for GDB, real-time debugging capabilities -- Updated logging features to minimally log only key connection milestones. This imroves scalability of multiple UEs. -- Updated logging to include time stamp for timing analysis -- Updated memory allocation procedures to correct size requirements -- Added debugging features to handle signal terminations -- nfapi.c pullarray8 fix invalid pointer math -- Overlapping destination and source memory in memcpy, so updated to memmove to check for this bug -- Advanced error checking mechanisms in critical pack and unpack functions -- Created option for CPU assignment to UE to improve scalability -- Added EPC integration to allow multiple individual UE entities to each have their USIM information parced by the executables -- Updated random value seeds to minimize probability of error in generation of random values -- Enables capability round robin scheduler if desired -- Enables capability real time scheduler if desired -- Added new standalone functions to the UE phy-layer (phy_stub_ue.c) to incorporate individual UE entities -- Updated sending and packing functions in UE (lte_ue.c) to incorporate new standalone changes -- Incorporated semaphores to control timing of incoming downlink packets -- Implemented new queuing system to handle message exchange from UE to eNB and vice versa -- Updated global value in nFAPI for size of subframe -- Updated global value to increase scalability in system + * [OAI License Model](http://www.openairinterface.org/?page_id=101) + * [OAI License v1.1 on our website](http://www.openairinterface.org/?page_id=698) +It is distributed under **OAI Public License V1.1**. + +The license information is distributed under [LICENSE](LICENSE) file in the same directory. + +Please see [NOTICE](NOTICE.md) file for third party software that is included in the sources. # Where to Start # diff --git a/charts/physims/charts/dlsim/values.yaml b/charts/physims/charts/dlsim/values.yaml index d78fbb7409..7f45b42f72 100644 --- a/charts/physims/charts/dlsim/values.yaml +++ b/charts/physims/charts/dlsim/values.yaml @@ -4,11 +4,11 @@ replicaCount: 1 -namespace: "oaicicd-ran-tmp" +namespace: "OAICICD_PROJECT" image: registry: local - repository: image-registry.openshift-image-registry.svc:5000/oaicicd-ran-tmp/oai-physim + repository: image-registry.openshift-image-registry.svc:5000/OAICICD_PROJECT/oai-physim version: temp # pullPolicy: IfNotPresent or Never or Always pullPolicy: Always diff --git a/charts/physims/charts/ldpctest/values.yaml b/charts/physims/charts/ldpctest/values.yaml index e2e6467923..b3cc476cf8 100644 --- a/charts/physims/charts/ldpctest/values.yaml +++ b/charts/physims/charts/ldpctest/values.yaml @@ -4,11 +4,11 @@ replicaCount: 1 -namespace: "oaicicd-ran-tmp" +namespace: "OAICICD_PROJECT" image: registry: local - repository: image-registry.openshift-image-registry.svc:5000/oaicicd-ran-tmp/oai-physim + repository: image-registry.openshift-image-registry.svc:5000/OAICICD_PROJECT/oai-physim version: temp # pullPolicy: IfNotPresent or Never or Always pullPolicy: Always diff --git a/charts/physims/charts/nr-dlschsim/values.yaml b/charts/physims/charts/nr-dlschsim/values.yaml index 8944e7e724..b7ef28f47a 100644 --- a/charts/physims/charts/nr-dlschsim/values.yaml +++ b/charts/physims/charts/nr-dlschsim/values.yaml @@ -4,11 +4,11 @@ replicaCount: 1 -namespace: "oaicicd-ran-tmp" +namespace: "OAICICD_PROJECT" image: registry: local - repository: image-registry.openshift-image-registry.svc:5000/oaicicd-ran-tmp/oai-physim + repository: image-registry.openshift-image-registry.svc:5000/OAICICD_PROJECT/oai-physim version: temp # pullPolicy: IfNotPresent or Never or Always pullPolicy: Always diff --git a/charts/physims/charts/nr-dlsim/values.yaml b/charts/physims/charts/nr-dlsim/values.yaml index 573e8630de..2a35912fee 100644 --- a/charts/physims/charts/nr-dlsim/values.yaml +++ b/charts/physims/charts/nr-dlsim/values.yaml @@ -4,11 +4,11 @@ replicaCount: 1 -namespace: "oaicicd-ran-tmp" +namespace: "OAICICD_PROJECT" image: registry: local - repository: image-registry.openshift-image-registry.svc:5000/oaicicd-ran-tmp/oai-physim + repository: image-registry.openshift-image-registry.svc:5000/OAICICD_PROJECT/oai-physim version: temp # pullPolicy: IfNotPresent or Never or Always pullPolicy: Always diff --git a/charts/physims/charts/nr-pbchsim/values.yaml b/charts/physims/charts/nr-pbchsim/values.yaml index 28c4678334..9a25d2810d 100644 --- a/charts/physims/charts/nr-pbchsim/values.yaml +++ b/charts/physims/charts/nr-pbchsim/values.yaml @@ -4,11 +4,11 @@ replicaCount: 1 -namespace: "oaicicd-ran-tmp" +namespace: "OAICICD_PROJECT" image: registry: local - repository: image-registry.openshift-image-registry.svc:5000/oaicicd-ran-tmp/oai-physim + repository: image-registry.openshift-image-registry.svc:5000/OAICICD_PROJECT/oai-physim version: temp # pullPolicy: IfNotPresent or Never or Always pullPolicy: Always diff --git a/charts/physims/charts/nr-prachsim/values.yaml b/charts/physims/charts/nr-prachsim/values.yaml index 9e3c68b54d..dba6cc16c0 100644 --- a/charts/physims/charts/nr-prachsim/values.yaml +++ b/charts/physims/charts/nr-prachsim/values.yaml @@ -4,11 +4,11 @@ replicaCount: 1 -namespace: "oaicicd-ran-tmp" +namespace: "OAICICD_PROJECT" image: registry: local - repository: image-registry.openshift-image-registry.svc:5000/oaicicd-ran-tmp/oai-physim + repository: image-registry.openshift-image-registry.svc:5000/OAICICD_PROJECT/oai-physim version: temp # pullPolicy: IfNotPresent or Never or Always pullPolicy: Always diff --git a/charts/physims/charts/nr-pucchsim/values.yaml b/charts/physims/charts/nr-pucchsim/values.yaml index 449670f713..77fe0963ac 100644 --- a/charts/physims/charts/nr-pucchsim/values.yaml +++ b/charts/physims/charts/nr-pucchsim/values.yaml @@ -4,11 +4,11 @@ replicaCount: 1 -namespace: "oaicicd-ran-tmp" +namespace: "OAICICD_PROJECT" image: registry: local - repository: image-registry.openshift-image-registry.svc:5000/oaicicd-ran-tmp/oai-physim + repository: image-registry.openshift-image-registry.svc:5000/OAICICD_PROJECT/oai-physim version: temp # pullPolicy: IfNotPresent or Never or Always pullPolicy: Always diff --git a/charts/physims/charts/nr-ulschsim/values.yaml b/charts/physims/charts/nr-ulschsim/values.yaml index a3afc090e8..efb011a7f6 100644 --- a/charts/physims/charts/nr-ulschsim/values.yaml +++ b/charts/physims/charts/nr-ulschsim/values.yaml @@ -4,11 +4,11 @@ replicaCount: 1 -namespace: "oaicicd-ran-tmp" +namespace: "OAICICD_PROJECT" image: registry: local - repository: image-registry.openshift-image-registry.svc:5000/oaicicd-ran-tmp/oai-physim + repository: image-registry.openshift-image-registry.svc:5000/OAICICD_PROJECT/oai-physim version: temp # pullPolicy: IfNotPresent or Never or Always pullPolicy: Always diff --git a/charts/physims/charts/nr-ulsim/values.yaml b/charts/physims/charts/nr-ulsim/values.yaml index 2bf96498e8..71c455b69c 100644 --- a/charts/physims/charts/nr-ulsim/values.yaml +++ b/charts/physims/charts/nr-ulsim/values.yaml @@ -4,11 +4,11 @@ replicaCount: 1 -namespace: "oaicicd-ran-tmp" +namespace: "OAICICD_PROJECT" image: registry: local - repository: image-registry.openshift-image-registry.svc:5000/oaicicd-ran-tmp/oai-physim + repository: image-registry.openshift-image-registry.svc:5000/OAICICD_PROJECT/oai-physim version: temp # pullPolicy: IfNotPresent or Never or Always pullPolicy: Always diff --git a/charts/physims/charts/polartest/values.yaml b/charts/physims/charts/polartest/values.yaml index e0a532fdd8..e0751e8ec4 100644 --- a/charts/physims/charts/polartest/values.yaml +++ b/charts/physims/charts/polartest/values.yaml @@ -4,11 +4,11 @@ replicaCount: 1 -namespace: "oaicicd-ran-tmp" +namespace: "OAICICD_PROJECT" image: registry: local - repository: image-registry.openshift-image-registry.svc:5000/oaicicd-ran-tmp/oai-physim + repository: image-registry.openshift-image-registry.svc:5000/OAICICD_PROJECT/oai-physim version: temp # pullPolicy: IfNotPresent or Never or Always pullPolicy: Always diff --git a/charts/physims/charts/smallblocktest/values.yaml b/charts/physims/charts/smallblocktest/values.yaml index f2f113d9b6..f933a978fd 100644 --- a/charts/physims/charts/smallblocktest/values.yaml +++ b/charts/physims/charts/smallblocktest/values.yaml @@ -4,11 +4,11 @@ replicaCount: 1 -namespace: "oaicicd-ran-tmp" +namespace: "OAICICD_PROJECT" image: registry: local - repository: image-registry.openshift-image-registry.svc:5000/oaicicd-ran-tmp/oai-physim + repository: image-registry.openshift-image-registry.svc:5000/OAICICD_PROJECT/oai-physim version: temp # pullPolicy: IfNotPresent or Never or Always pullPolicy: Always diff --git a/charts/physims/charts/ulsim/values.yaml b/charts/physims/charts/ulsim/values.yaml index 35dc14d596..d25b6fc2a5 100644 --- a/charts/physims/charts/ulsim/values.yaml +++ b/charts/physims/charts/ulsim/values.yaml @@ -4,11 +4,11 @@ replicaCount: 1 -namespace: "oaicicd-ran-tmp" +namespace: "OAICICD_PROJECT" image: registry: local - repository: image-registry.openshift-image-registry.svc:5000/oaicicd-ran-tmp/oai-physim + repository: image-registry.openshift-image-registry.svc:5000/OAICICD_PROJECT/oai-physim version: temp # pullPolicy: IfNotPresent or Never or Always pullPolicy: Always diff --git a/charts/physims/templates/rbac.yaml b/charts/physims/templates/rbac.yaml index 35f956a203..b341744796 100644 --- a/charts/physims/templates/rbac.yaml +++ b/charts/physims/templates/rbac.yaml @@ -1,12 +1,26 @@ -apiVersion: rbac.authorization.k8s.io/v1beta1 -kind: ClusterRoleBinding +apiVersion: rbac.authorization.k8s.io/v1 +kind: Role metadata: - name: {{ .Chart.Name }}-{{ .Values.global.namespace }}-rbac -roleRef: - apiGroup: rbac.authorization.k8s.io - kind: ClusterRole - name: cluster-admin + name: {{ .Chart.Name }}-{{ .Release.Namespace }}-role +rules: +- apiGroups: + - security.openshift.io + resourceNames: + - privileged + resources: + - securitycontextconstraints + verbs: + - use +--- +apiVersion: rbac.authorization.k8s.io/v1 +kind: RoleBinding +metadata: + name: {{ .Chart.Name }}-{{ .Release.Namespace }}-binding subjects: - kind: ServiceAccount name: {{ .Values.global.serviceAccountName }} - namespace: {{ .Values.global.namespace }} + namespace: {{ .Release.Namespace }} +roleRef: + kind: Role + name: {{ .Chart.Name }}-{{ .Release.Namespace }}-role + apiGroup: rbac.authorization.k8s.io diff --git a/charts/physims/values.yaml b/charts/physims/values.yaml index b348e822bb..d5253c7812 100644 --- a/charts/physims/values.yaml +++ b/charts/physims/values.yaml @@ -4,9 +4,9 @@ global: serviceAccountName: oai-physim-sa - namespace: "oaicicd-ran-tmp" + namespace: "OAICICD_PROJECT" image: - repository: image-registry.openshift-image-registry.svc:5000/oaicicd-ran-tmp/oai-physim + repository: image-registry.openshift-image-registry.svc:5000/OAICICD_PROJECT/oai-physim version: TAG ## Declaring values specific to coressponding physim to overwrite diff --git a/ci-scripts/Jenkinsfile-GitLab-Container b/ci-scripts/Jenkinsfile-GitLab-Container index f5852bace5..c22e6fabec 100644 --- a/ci-scripts/Jenkinsfile-GitLab-Container +++ b/ci-scripts/Jenkinsfile-GitLab-Container @@ -222,7 +222,7 @@ pipeline { when { expression {doMandatoryTests} } steps { script { - triggerSlaveJob ('RAN-RF-Sim-Test-5G', 'Test-RF-Sim-Container-4G') + triggerSlaveJob ('RAN-RF-Sim-Test-5G', 'Test-RF-Sim-Container-5G') } } post { @@ -238,6 +238,26 @@ pipeline { } } } + stage ("5G L2 Simulators") { + when { expression {doMandatoryTests} } + steps { + script { + triggerSlaveJob ('RAN-L2-Sim-Test-5G', 'Test-L2-Sim-Container-5G') + } + } + post { + always { + script { + finalizeSlaveJob('RAN-L2-Sim-Test-5G') + } + } + failure { + script { + currentBuild.result = 'FAILURE' + } + } + } + } stage ("NSA B200 Sanity Check") { when { expression {doMandatoryTests} } steps { diff --git a/ci-scripts/Jenkinsfile-gitlab b/ci-scripts/Jenkinsfile-gitlab index 3042ada815..54be9b653d 100644 --- a/ci-scripts/Jenkinsfile-gitlab +++ b/ci-scripts/Jenkinsfile-gitlab @@ -136,16 +136,6 @@ pipeline { // For the moment, there is no fail criteria. Just a notification of number of files that do not follow sh "./ci-scripts/checkCodingFormattingRules.sh" } - // With Mosaic 5G being part of OSA and making all it's repositories public - // No need to pass credentials to clone flexran-rtc - if (doMandatoryTests) { - sh "mkdir flexran" - dir ('flexran') { - sh "git clone https://gitlab.eurecom.fr/flexran/flexran-rtc.git . > ../git_clone.log 2>&1" - sh "git checkout develop >> ../git_clone.log 2>&1" - sh "zip -r -qq flexran.zip ." - } - } } } post { @@ -159,16 +149,6 @@ pipeline { } } - stage ("Start VM -- basic-sim") { - steps { - lock (vmResource) { - timeout (time: 5, unit: 'MINUTES') { - sh "./ci-scripts/oai-ci-vm-tool build --workspace $WORKSPACE --variant basic-sim --job-name ${JOB_NAME} --build-id ${BUILD_ID} --daemon" - } - } - } - } - stage ("Start VM -- gnb-usrp") { steps { lock (vmResource) { @@ -211,15 +191,6 @@ pipeline { stage ("Variant Builds") { parallel { - stage ("Build basic simulator") { - steps { - gitlabCommitStatus(name: "Build basic-sim") { - timeout (time: 45, unit: 'MINUTES') { - sh "./ci-scripts/oai-ci-vm-tool wait --workspace $WORKSPACE --variant basic-sim --job-name ${JOB_NAME} --build-id ${BUILD_ID} --keep-vm-alive" - } - } - } - } stage ("Build 5G gNB-USRP") { steps { gitlabCommitStatus(name: "Build gNB-USRP") { @@ -270,9 +241,9 @@ pipeline { script { dir ('archives') { if (fileExists('red_hat')) { - sh "zip -r -qq vm_build_logs.zip basic_sim enb_eth ue_eth gnb_usrp nr_ue_usrp red_hat" + sh "zip -r -qq vm_build_logs.zip enb_eth ue_eth gnb_usrp nr_ue_usrp red_hat" } else { - sh "zip -r -qq vm_build_logs.zip basic_sim enb_eth ue_eth gnb_usrp nr_ue_usrp" + sh "zip -r -qq vm_build_logs.zip enb_eth ue_eth gnb_usrp nr_ue_usrp" } } if(fileExists('archives/vm_build_logs.zip')) { @@ -306,44 +277,6 @@ pipeline { parallel { stage ("VM-based tests") { stages { - stage ("Build Flexran Controller") { - when { - expression {doMandatoryTests} - } - steps { - lock (vmResource) { - script { - timeout (time: 20, unit: 'MINUTES') { - try { - sh "./ci-scripts/oai-ci-vm-tool build --workspace $WORKSPACE --variant flexran-rtc --job-name ${JOB_NAME} --build-id ${BUILD_ID} --keep-vm-alive" - } catch (Exception e) { - currentBuild.result = 'FAILURE' - } - } - } - } - } - } - stage ("Test basic simulator") { - when { - expression {doMandatoryTests} - } - steps { - lock (vmResource) { - script { - timeout (time: 30, unit: 'MINUTES') { - try { - gitlabCommitStatus(name: "Test basic-sim") { - sh "./ci-scripts/oai-ci-vm-tool test --workspace $WORKSPACE --variant basic-sim --job-name ${JOB_NAME} --build-id ${BUILD_ID}" - } - } catch (Exception e) { - currentBuild.result = 'FAILURE' - } - } - } - } - } - } stage ("Test L1 simulator") { when { expression {doMandatoryTests} @@ -581,7 +514,7 @@ pipeline { script { if (doMandatoryTests) { dir ('archives') { - sh "if [ -d basic_sim/test ] || [ -d rf_sim/test ] || [ -d l2_sim/test ]; then zip -r -qq vm_tests_logs.zip */test ; fi" + sh "if [ -d rf_sim/test ] || [ -d l2_sim/test ]; then zip -r -qq vm_tests_logs.zip */test ; fi" } if(fileExists('archives/vm_tests_logs.zip')) { archiveArtifacts artifacts: 'archives/vm_tests_logs.zip' diff --git a/ci-scripts/Jenkinsfile-push-registry b/ci-scripts/Jenkinsfile-push-registry index 91d6136e0a..bc1a80ba61 100644 --- a/ci-scripts/Jenkinsfile-push-registry +++ b/ci-scripts/Jenkinsfile-push-registry @@ -26,6 +26,9 @@ def nodeExecutor = params.nodeExecutor // Name of the phone resource def ciServerResource = params.serverResource +// Docker Hub account to push to +def DH_Account = "oaisoftwarealliance" + pipeline { agent { label nodeExecutor @@ -55,7 +58,9 @@ pipeline { stage ("Push to DockerHub") { steps { script { - WEEK_TAG = sh returnStdout: true, script: 'date +"%Y.w%U"' + WEEK_REF = sh returnStdout: true, script: 'date +"%Y.w%V"' + WEEK_REF = WEEK_REF.trim() + WEEK_TAG = sh returnStdout: true, script: 'python3 ./ci-scripts/provideUniqueImageTag.py --start_tag ' + WEEK_REF WEEK_TAG = WEEK_TAG.trim() withCredentials([ @@ -64,11 +69,11 @@ pipeline { def listOfImages = ["oai-enb", "oai-gnb", "oai-lte-ue", "oai-nr-ue"] sh "docker login -u ${DH_Username} -p ${DH_Password} > /dev/null 2>&1" listOfImages.eachWithIndex { item, iindex -> - sh "docker image tag ${item}:develop ${DH_Username}/${item}:develop" - sh "docker image tag ${item}:develop ${DH_Username}/${item}:${WEEK_TAG}" - sh "docker push --quiet ${DH_Username}/${item}:${WEEK_TAG}" - sh "docker push --quiet ${DH_Username}/${item}:develop" - sh "docker rmi ${DH_Username}/${item}:${WEEK_TAG} ${DH_Username}/${item}:develop" + sh "docker image tag ${item}:develop ${DH_Account}/${item}:develop" + sh "docker image tag ${item}:develop ${DH_Account}/${item}:${WEEK_TAG}" + sh "docker push --quiet ${DH_Account}/${item}:${WEEK_TAG}" + sh "docker push --quiet ${DH_Account}/${item}:develop" + sh "docker rmi ${DH_Account}/${item}:${WEEK_TAG} ${DH_Account}/${item}:develop" } sh "docker logout > /dev/null 2>&1" } diff --git a/ci-scripts/Jenkinsfile-trig-nsa b/ci-scripts/Jenkinsfile-trig-nsa index 772b34231a..3616b2c404 100644 --- a/ci-scripts/Jenkinsfile-trig-nsa +++ b/ci-scripts/Jenkinsfile-trig-nsa @@ -113,6 +113,21 @@ pipeline { GitPostArgs += jobName + ' ' + build_url + ' ' + build_id + ' ' + jobResult + ' ' echo GitPostArgs + //calling SA-AmariS + jobName = "RAN-SA-AmariS-CN5G" + jobStatus = build job: jobName, wait : true, propagate : false, parameters: [ + string(name: 'eNB_MR', value: String.valueOf(MR)), + string(name: 'eNB_Branch', value: String.valueOf(SRC_BRANCH)), + string(name: 'eNB_CommitID', value: String.valueOf(COMMIT_ID)), + string(name: 'eNB_TargetBranch', value: String.valueOf(TARGET_BRANCH)), + booleanParam(name: 'eNB_mergeRequest', value: Boolean.valueOf(ALLOW_MERGE)) + ] + jobResult = jobStatus.getResult() + build_url = jobStatus.getAbsoluteUrl() + build_id = jobStatus.getNumber().toString() + GitPostArgs += jobName + ' ' + build_url + ' ' + build_id + ' ' + jobResult + ' ' + echo GitPostArgs + //calling OAIUE N310-X300 jobName = "RAN-SA-OAIUE-N310-X300-CN5G" jobStatus = build job: jobName, wait : true, propagate : false, parameters: [ diff --git a/ci-scripts/as_ue/oai_ext_app.sh b/ci-scripts/as_ue/oai_ext_app.sh new file mode 100755 index 0000000000..727e2b5db2 --- /dev/null +++ b/ci-scripts/as_ue/oai_ext_app.sh @@ -0,0 +1,18 @@ +#!/bin/bash + +ue_id="$1" # UE id +duration="$2" # Sim duration + +shift +shift + +function end +{ + exit 0 +} +trap end INT TERM + +echo "ip netns exec $ue_id $@ > /tmp/test_${ue_id}.log" +ip netns exec $ue_id $@ > /tmp/test_$ue_id.log + + diff --git a/ci-scripts/as_ue/oaicicd-3xue-noPing-SATest.cfg b/ci-scripts/as_ue/oaicicd-3xue-noPing-SATest.cfg new file mode 100644 index 0000000000..a9299b67e3 --- /dev/null +++ b/ci-scripts/as_ue/oaicicd-3xue-noPing-SATest.cfg @@ -0,0 +1,172 @@ +/* UE simulator configuration */ + + +/* UE simulator configuration file version 2021-06-17 + * LTE / 5G Non StandAlone + * Copyright (C) 2019-2021 Amarisoft + */ +{ +#define N_ANTENNA_DL 1 +#define TDD 1 +#define CELL_BANDWIDTH 40 +#define UE_COUNT 3 // number of simulated UEs 208970100001127, 208970100001128, 208970100001129 + + +log_options: "all.level=error,all.max_size=0,nas.level=debug,nas.max_size=1,rrc.level=debug,rrc.max_size=1", +log_filename: "/tmp/ue0.log", + +/* Enable remote API and Web interface */ +com_addr: "0.0.0.0:9002", + +include "rf_driver/1chan.cfg", + +/* If true, allow the simulation of several UEs at the same time and allow dynamic UE creation from remote API */ + +cell_groups: [{ + group_type: "nr", + multi_ue: true, + cells: [{ + rf_port: 0, + bandwidth: CELL_BANDWIDTH, +#if TDD == 1 + band: 78, + dl_nr_arfcn:621312, + ssb_nr_arfcn:621312, + + //band: 41, + //dl_nr_arfcn:517020, + //ssb_nr_arfcn:516990, +#else + band: 7, + dl_nr_arfcn: 536020, + ssb_nr_arfcn: 535930, + ssb_subcarrier_spacing: 15, +#endif + subcarrier_spacing: 30, + n_antenna_dl: N_ANTENNA_DL, + n_antenna_ul: 1, + rx_to_tx_latency:2, + }], +}], + + +/* Enable it to allow sim_events to be handled remotely */ +//rue_bind_addr: "127.0.10.11", + + + +ue_list: [ + { + /* UE capabilities */ + /* USIM data */ + "ue_id" : 0, + "imsi": "208970100001127", + "K": "fec86ba6eb707ed08905757b1bb44b8f", + "sim_algo":"milenage", + "op": "1006020f0a478bf6b699f15c062e42b3", + as_release: 15, + ue_category: "nr", + apn:"oai", + attach_pdn_type:"ipv4", + default_nssai: [ + { + sst: 1, + sd: 66051, + }, + ], + default_pdu_session_snssai: { + sst: 1, + sd: 66051, + }, + /* Enable it to allow sim_events to be handled remotely */ + //rue_addr: "127.1.0.0", + /* Enable it to create a TUN interface for each UE PDN */ + tun_setup_script: "ue-ifup", + sim_events: [ + { + event: "power_on", + start_time: 5, + }, + { + event: "power_off", + start_time: 30, + } + ] /*end sim events */ + }, /*end UE object 0*/ + { + /* UE capabilities */ + /* USIM data */ + "ue_id" : 1, + "imsi": "208970100001128", + "K": "fec86ba6eb707ed08905757b1bb44b8f", + "sim_algo":"milenage", + "op": "1006020f0a478bf6b699f15c062e42b3", + as_release: 15, + ue_category: "nr", + apn:"oai", + attach_pdn_type:"ipv4", + default_nssai: [ + { + sst: 1, + sd: 66051, + }, + ], + default_pdu_session_snssai: { + sst: 1, + sd: 66051, + }, + /* Enable it to allow sim_events to be handled remotely */ + //rue_addr: "127.1.0.0", + /* Enable it to create a TUN interface for each UE PDN */ + tun_setup_script: "ue-ifup", + sim_events: [ + { + event: "power_on", + start_time: 5, + }, + { + event: "power_off", + start_time: 30, + } + ] /*end sim events */ + }, /*end UE object 1*/ + { + /* UE capabilities */ + /* USIM data */ + "ue_id" : 2, + "imsi": "208970100001129", + "K": "fec86ba6eb707ed08905757b1bb44b8f", + "sim_algo":"milenage", + "op": "1006020f0a478bf6b699f15c062e42b3", + as_release: 15, + ue_category: "nr", + apn:"oai", + attach_pdn_type:"ipv4", + default_nssai: [ + { + sst: 1, + sd: 66051, + }, + ], + default_pdu_session_snssai: { + sst: 1, + sd: 66051, + }, + /* Enable it to allow sim_events to be handled remotely */ + //rue_addr: "127.1.0.0", + /* Enable it to create a TUN interface for each UE PDN */ + tun_setup_script: "ue-ifup", + sim_events: [ + { + event: "power_on", + start_time: 5, + }, + { + event: "power_off", + start_time: 30, + } + ] /*end sim events */ + } /*end UE object 2*/ + ],/*end UE list*/ +}/*end json*/ + diff --git a/ci-scripts/as_ue/oaicicd-multi-ue-1xPing-SATest.cfg b/ci-scripts/as_ue/oaicicd-multi-ue-1xPing-SATest.cfg new file mode 100644 index 0000000000..3405f99a59 --- /dev/null +++ b/ci-scripts/as_ue/oaicicd-multi-ue-1xPing-SATest.cfg @@ -0,0 +1,142 @@ +/* UE simulator configuration */ + + +/* UE simulator configuration file version 2021-06-17 + * LTE / 5G Non StandAlone + * Copyright (C) 2019-2021 Amarisoft + */ +{ +#define N_ANTENNA_DL 1 +#define TDD 1 +#define CELL_BANDWIDTH 40 +#define UE_COUNT 2 // number of simulated UEs 208970100001127, 208970100001128, 208970100001129 + + +log_options: "all.level=error,all.max_size=0,nas.level=debug,nas.max_size=1,rrc.level=debug,rrc.max_size=1", +log_filename: "/tmp/ue0.log", + +/* Enable remote API and Web interface */ +com_addr: "0.0.0.0:9002", + +include "rf_driver/1chan.cfg", + +/* If true, allow the simulation of several UEs at the same time and allow dynamic UE creation from remote API */ + +cell_groups: [{ + group_type: "nr", + multi_ue: true, + cells: [{ + rf_port: 0, + bandwidth: CELL_BANDWIDTH, +#if TDD == 1 + band: 78, + dl_nr_arfcn:621312, + ssb_nr_arfcn:621312, + + //band: 41, + //dl_nr_arfcn:517020, + //ssb_nr_arfcn:516990, +#else + band: 7, + dl_nr_arfcn: 536020, + ssb_nr_arfcn: 535930, + ssb_subcarrier_spacing: 15, +#endif + subcarrier_spacing: 30, + n_antenna_dl: N_ANTENNA_DL, + n_antenna_ul: 1, + rx_to_tx_latency:2, + }], +}], + + +/* Enable it to allow sim_events to be handled remotely */ +//rue_bind_addr: "127.0.10.11", + + + +ue_list: [ + { + /* UE capabilities */ + /* USIM data */ + "ue_id" : 1, + "imsi": "208970100001127", + "K": "fec86ba6eb707ed08905757b1bb44b8f", + "sim_algo":"milenage", + "op": "1006020f0a478bf6b699f15c062e42b3", + as_release: 15, + ue_category: "nr", + apn:"oai", + attach_pdn_type:"ipv4", + default_nssai: [ + { + sst: 1, + sd: 66051, + }, + ], + default_pdu_session_snssai: { + sst: 1, + sd: 66051, + }, + /* Enable it to allow sim_events to be handled remotely */ + //rue_addr: "127.1.0.0", + /* Enable it to create a TUN interface for each UE PDN */ + tun_setup_script: "ue-ifup", + sim_events: [ + { + event: "power_on", + start_time: 5, + }, + { + event: "power_off", + start_time: 30, + } + ] /*end sim events */ + }, /*end UE object 0*/ + { + /* UE capabilities */ + /* USIM data */ + "ue_id" : 2, + "imsi": "208970100001128", + "K": "fec86ba6eb707ed08905757b1bb44b8f", + "sim_algo":"milenage", + "op": "1006020f0a478bf6b699f15c062e42b3", + as_release: 15, + ue_category: "nr", + apn:"oai", + attach_pdn_type:"ipv4", + default_nssai: [ + { + sst: 1, + sd: 66051, + }, + ], + default_pdu_session_snssai: { + sst: 1, + sd: 66051, + }, + /* Enable it to allow sim_events to be handled remotely */ + //rue_addr: "127.1.0.0", + /* Enable it to create a TUN interface for each UE PDN */ + tun_setup_script: "ue-ifup", + sim_events: [ + { + event: "power_on", + start_time: 5, + }, + { + "tag": "ping", + "prog":"oai_ext_app.sh", + start_time: 15, + end_time: 25, + "args":["ping 192.168.70.136"], + "event":"ext_app" + }, + { + event: "power_off", + start_time: 30, + } + ] /*end sim events */ + } /*end UE object 1*/ + ],/*end UE list*/ +}/*end json*/ diff --git a/ci-scripts/as_ue/oaicicd-multi-ue-2xPing-SATest.cfg b/ci-scripts/as_ue/oaicicd-multi-ue-2xPing-SATest.cfg new file mode 100644 index 0000000000..eaa9b894fc --- /dev/null +++ b/ci-scripts/as_ue/oaicicd-multi-ue-2xPing-SATest.cfg @@ -0,0 +1,150 @@ +/* UE simulator configuration */ + + +/* UE simulator configuration file version 2021-06-17 + * LTE / 5G Non StandAlone + * Copyright (C) 2019-2021 Amarisoft + */ +{ +#define N_ANTENNA_DL 1 +#define TDD 1 +#define CELL_BANDWIDTH 40 +#define UE_COUNT 2 // number of simulated UEs 208970100001127, 208970100001128, 208970100001129 + + +log_options: "all.level=error,all.max_size=0,nas.level=debug,nas.max_size=1,rrc.level=debug,rrc.max_size=1", +log_filename: "/tmp/ue0.log", + +/* Enable remote API and Web interface */ +com_addr: "0.0.0.0:9002", + +include "rf_driver/1chan.cfg", + +/* If true, allow the simulation of several UEs at the same time and allow dynamic UE creation from remote API */ + +cell_groups: [{ + group_type: "nr", + multi_ue: true, + cells: [{ + rf_port: 0, + bandwidth: CELL_BANDWIDTH, +#if TDD == 1 + band: 78, + dl_nr_arfcn:621312, + ssb_nr_arfcn:621312, + + //band: 41, + //dl_nr_arfcn:517020, + //ssb_nr_arfcn:516990, +#else + band: 7, + dl_nr_arfcn: 536020, + ssb_nr_arfcn: 535930, + ssb_subcarrier_spacing: 15, +#endif + subcarrier_spacing: 30, + n_antenna_dl: N_ANTENNA_DL, + n_antenna_ul: 1, + rx_to_tx_latency:2, + }], +}], + + +/* Enable it to allow sim_events to be handled remotely */ +//rue_bind_addr: "127.0.10.11", + + + +ue_list: [ + { + /* UE capabilities */ + /* USIM data */ + "ue_id" : 1, + "imsi": "208970100001127", + "K": "fec86ba6eb707ed08905757b1bb44b8f", + "sim_algo":"milenage", + "op": "1006020f0a478bf6b699f15c062e42b3", + as_release: 15, + ue_category: "nr", + apn:"oai", + attach_pdn_type:"ipv4", + default_nssai: [ + { + sst: 1, + sd: 66051, + }, + ], + default_pdu_session_snssai: { + sst: 1, + sd: 66051, + }, + /* Enable it to allow sim_events to be handled remotely */ + //rue_addr: "127.1.0.0", + /* Enable it to create a TUN interface for each UE PDN */ + tun_setup_script: "ue-ifup", + sim_events: [ + { + event: "power_on", + start_time: 5, + }, + { + "tag": "ping", + "prog":"oai_ext_app.sh", + start_time: 15, + end_time: 25, + "args":["ping 192.168.70.136"], + "event":"ext_app" + }, + { + event: "power_off", + start_time: 30, + } + ] /*end sim events */ + }, /*end UE object 0*/ + { + /* UE capabilities */ + /* USIM data */ + "ue_id" : 2, + "imsi": "208970100001128", + "K": "fec86ba6eb707ed08905757b1bb44b8f", + "sim_algo":"milenage", + "op": "1006020f0a478bf6b699f15c062e42b3", + as_release: 15, + ue_category: "nr", + apn:"oai", + attach_pdn_type:"ipv4", + default_nssai: [ + { + sst: 1, + sd: 66051, + }, + ], + default_pdu_session_snssai: { + sst: 1, + sd: 66051, + }, + /* Enable it to allow sim_events to be handled remotely */ + //rue_addr: "127.1.0.0", + /* Enable it to create a TUN interface for each UE PDN */ + tun_setup_script: "ue-ifup", + sim_events: [ + { + event: "power_on", + start_time: 5, + }, + { + "tag": "ping", + "prog":"oai_ext_app.sh", + start_time: 15, + end_time: 25, + "args":["ping 192.168.70.136"], + "event":"ext_app" + }, + { + event: "power_off", + start_time: 30, + } + ] /*end sim events */ + } /*end UE object 1*/ + ],/*end UE list*/ +}/*end json*/ diff --git a/ci-scripts/as_ue/oaicicd-multi-ue-2xPingSeq-SATest.cfg b/ci-scripts/as_ue/oaicicd-multi-ue-2xPingSeq-SATest.cfg new file mode 100644 index 0000000000..9ebb3e01c5 --- /dev/null +++ b/ci-scripts/as_ue/oaicicd-multi-ue-2xPingSeq-SATest.cfg @@ -0,0 +1,150 @@ +/* UE simulator configuration */ + + +/* UE simulator configuration file version 2021-06-17 + * LTE / 5G Non StandAlone + * Copyright (C) 2019-2021 Amarisoft + */ +{ +#define N_ANTENNA_DL 1 +#define TDD 1 +#define CELL_BANDWIDTH 40 +#define UE_COUNT 2 // number of simulated UEs 208970100001127, 208970100001128, 208970100001129 + + +log_options: "all.level=error,all.max_size=0,nas.level=debug,nas.max_size=1,rrc.level=debug,rrc.max_size=1", +log_filename: "/tmp/ue0.log", + +/* Enable remote API and Web interface */ +com_addr: "0.0.0.0:9002", + +include "rf_driver/1chan.cfg", + +/* If true, allow the simulation of several UEs at the same time and allow dynamic UE creation from remote API */ + +cell_groups: [{ + group_type: "nr", + multi_ue: true, + cells: [{ + rf_port: 0, + bandwidth: CELL_BANDWIDTH, +#if TDD == 1 + band: 78, + dl_nr_arfcn:621312, + ssb_nr_arfcn:621312, + + //band: 41, + //dl_nr_arfcn:517020, + //ssb_nr_arfcn:516990, +#else + band: 7, + dl_nr_arfcn: 536020, + ssb_nr_arfcn: 535930, + ssb_subcarrier_spacing: 15, +#endif + subcarrier_spacing: 30, + n_antenna_dl: N_ANTENNA_DL, + n_antenna_ul: 1, + rx_to_tx_latency:2, + }], +}], + + +/* Enable it to allow sim_events to be handled remotely */ +//rue_bind_addr: "127.0.10.11", + + + +ue_list: [ + { + /* UE capabilities */ + /* USIM data */ + "ue_id" : 1, + "imsi": "208970100001127", + "K": "fec86ba6eb707ed08905757b1bb44b8f", + "sim_algo":"milenage", + "op": "1006020f0a478bf6b699f15c062e42b3", + as_release: 15, + ue_category: "nr", + apn:"oai", + attach_pdn_type:"ipv4", + default_nssai: [ + { + sst: 1, + sd: 66051, + }, + ], + default_pdu_session_snssai: { + sst: 1, + sd: 66051, + }, + /* Enable it to allow sim_events to be handled remotely */ + //rue_addr: "127.1.0.0", + /* Enable it to create a TUN interface for each UE PDN */ + tun_setup_script: "ue-ifup", + sim_events: [ + { + event: "power_on", + start_time: 5, + }, + { + "tag": "ping", + "prog":"oai_ext_app.sh", + start_time: 20, + end_time: 30, + "args":["ping 192.168.70.136"], + "event":"ext_app" + }, + { + event: "power_off", + start_time: 60, + } + ] /*end sim events */ + }, /*end UE object 0*/ + { + /* UE capabilities */ + /* USIM data */ + "ue_id" : 2, + "imsi": "208970100001128", + "K": "fec86ba6eb707ed08905757b1bb44b8f", + "sim_algo":"milenage", + "op": "1006020f0a478bf6b699f15c062e42b3", + as_release: 15, + ue_category: "nr", + apn:"oai", + attach_pdn_type:"ipv4", + default_nssai: [ + { + sst: 1, + sd: 66051, + }, + ], + default_pdu_session_snssai: { + sst: 1, + sd: 66051, + }, + /* Enable it to allow sim_events to be handled remotely */ + //rue_addr: "127.1.0.0", + /* Enable it to create a TUN interface for each UE PDN */ + tun_setup_script: "ue-ifup", + sim_events: [ + { + event: "power_on", + start_time: 5, + }, + { + "tag": "ping", + "prog":"oai_ext_app.sh", + start_time: 40, + end_time: 50, + "args":["ping 192.168.70.136"], + "event":"ext_app" + }, + { + event: "power_off", + start_time: 60, + } + ] /*end sim events */ + } /*end UE object 1*/ + ],/*end UE list*/ +}/*end json*/ diff --git a/ci-scripts/as_ue/oaicicd-ue-Ping-SATest.cfg b/ci-scripts/as_ue/oaicicd-ue-Ping-SATest.cfg new file mode 100644 index 0000000000..ba22cbb233 --- /dev/null +++ b/ci-scripts/as_ue/oaicicd-ue-Ping-SATest.cfg @@ -0,0 +1,113 @@ +/* UE simulator configuration */ + + + +/* UE simulator configuration file version 2021-06-17 + * LTE / 5G Non StandAlone + * Copyright (C) 2019-2021 Amarisoft + */ +{ +#define N_ANTENNA_DL 1 +#define TDD 1 +#define CELL_BANDWIDTH 40 + + + log_options: "all.level=error,all.max_size=0,nas.level=debug,nas.max_size=1,rrc.level=debug,rrc.max_size=1", + log_filename: "/tmp/ue1.log", + + /* Enable remote API and Web interface */ + com_addr: "0.0.0.0:9002", + + include "rf_driver/1chan.cfg", + + /* If true, allow the simulation of several UEs at the same time and + allow dynamic UE creation from remote API */ + +cell_groups: [{ + group_type: "nr", + multi_ue: false, + cells: [{ + rf_port: 0, + bandwidth: CELL_BANDWIDTH, +#if TDD == 1 + band: 78, + dl_nr_arfcn:621312, + ssb_nr_arfcn:621312, + + //band: 41, + //dl_nr_arfcn:517020, + //ssb_nr_arfcn:516990, +#else + band: 7, + dl_nr_arfcn: 536020, + ssb_nr_arfcn: 535930, + ssb_subcarrier_spacing: 15, +#endif + subcarrier_spacing: 30, + n_antenna_dl: N_ANTENNA_DL, + n_antenna_ul: 1, + rx_to_tx_latency:2, + }], + }], + + + + + /* Enable it to allow sim_events to be handled remotely */ + //rue_bind_addr: "127.0.10.11", + + ue_list: [ + { + /* UE capabilities */ + + /* USIM data */ + + + "imsi": "208970100001127", + "K": "fec86ba6eb707ed08905757b1bb44b8f", + "sim_algo":"milenage", + "op": "1006020f0a478bf6b699f15c062e42b3", + + + as_release: 15, + ue_category: "nr", + apn:"oai", + attach_pdn_type:"ipv4", + default_nssai: [ + { + sst: 1, + sd: 66051, + }, + ], + + default_pdu_session_snssai: { + sst: 1, + sd: 66051, + }, + + + /* Enable it to allow sim_events to be handled remotely */ + //rue_addr: "127.1.0.0", + + /* Enable it to create a TUN interface for each UE PDN */ + tun_setup_script: "ue-ifup", + + sim_events: [{ + event: "power_on", + start_time: 5, + }, { + "tag": "ping", + "prog":"oai_ext_app.sh", + start_time: 15, + end_time: 25, + "args":["ping 192.168.70.136"], + "event":"ext_app" + + }, + { + event: "power_off", + start_time: 30, + }] + } + ], +} diff --git a/ci-scripts/as_ue/oaicicd-ue-iperf-SATest.cfg b/ci-scripts/as_ue/oaicicd-ue-iperf-SATest.cfg new file mode 100644 index 0000000000..841dafb746 --- /dev/null +++ b/ci-scripts/as_ue/oaicicd-ue-iperf-SATest.cfg @@ -0,0 +1,109 @@ +/* UE simulator configuration */ + + + +/* UE simulator configuration file version 2021-06-17 + * LTE / 5G Non StandAlone + * Copyright (C) 2019-2021 Amarisoft + */ +{ +#define N_ANTENNA_DL 1 +#define TDD 1 +#define CELL_BANDWIDTH 20 + + + log_options: "all.level=error,all.max_size=0,nas.level=debug,nas.max_size=1,rrc.level=debug,rrc.max_size=1", + log_filename: "/tmp/ue0.log", + + /* Enable remote API and Web interface */ + com_addr: "0.0.0.0:9002", + + include "rf_driver/1chan.cfg", + + /* If true, allow the simulation of several UEs at the same time and + allow dynamic UE creation from remote API */ + +cell_groups: [{ + group_type: "nr", + multi_ue: false, + cells: [{ + rf_port: 0, + bandwidth: CELL_BANDWIDTH, +#if TDD == 1 + // band: 78, + // dl_nr_arfcn:621312, + // ssb_nr_arfcn:621312,*/ + + band: 41, + dl_nr_arfcn:517020, + ssb_nr_arfcn:516990, +#else + band: 7, + dl_nr_arfcn: 536020, + ssb_nr_arfcn: 535930, + ssb_subcarrier_spacing: 15, +#endif + subcarrier_spacing: 30, + n_antenna_dl: N_ANTENNA_DL, + n_antenna_ul: 1, + rx_to_tx_latency:2, + }], + }], + + + + + /* Enable it to allow sim_events to be handled remotely */ + //rue_bind_addr: "127.0.10.11", + + ue_list: [ + { + /* UE capabilities */ + + /* USIM data */ + + "imsi": "208970100001127", + "K": "fec86ba6eb707ed08905757b1bb44b8f", + "sim_algo":"milenage", + "op": "1006020f0a478bf6b699f15c062e42b3", + + + as_release: 15, + ue_category: "nr", + apn:"oai", + attach_pdn_type:"ipv4", + default_nssai: [ + { + sst: 1, + sd: 1, + }, + ], + + default_pdu_session_snssai: { + sst: 1, + sd: 1, + }, + + + /* Enable it to allow sim_events to be handled remotely */ + //rue_addr: "127.1.0.0", + + /* Enable it to create a TUN interface for each UE PDN */ + tun_setup_script: "ue-ifup", + + sim_events: [{ + event: "power_on", + start_time: 5, + }, { + event: "ext_app", + start_time: 15, + end_time: 25, + prog: "ext_app.sh", + args: ["iperf", " -c 172.21.10.5", " -u"," -b 1M"," -i 1"," -t 10"] + }, { + event: "power_off", + start_time: 30, + }] + } + ], +} diff --git a/ci-scripts/buildOnVM.sh b/ci-scripts/buildOnVM.sh index f4cf3931dd..eaca22f550 100755 --- a/ci-scripts/buildOnVM.sh +++ b/ci-scripts/buildOnVM.sh @@ -62,7 +62,7 @@ function build_on_vm { echo "ARCHIVES_LOC = $ARCHIVES_LOC" echo "BUILD_OPTIONS = $BUILD_OPTIONS" - if [[ "$VM_NAME" == *"-enb-usrp"* ]] || [[ "$VM_NAME" == *"-cppcheck"* ]] || [[ "$VM_NAME" == *"-phy-sim"* ]] + if [[ "$VM_NAME" == *"-enb-usrp"* ]] || [[ "$VM_NAME" == *"-cppcheck"* ]] || [[ "$VM_NAME" == *"-phy-sim"* ]] || [[ "$VM_NAME" == *"-basic-sim"* ]] || [[ "$VM_NAME" == *"-flexran-rtc"* ]] then echo "This VM type is no longer supported in the pipeline framework" return diff --git a/ci-scripts/build_fr1_template.yaml b/ci-scripts/build_fr1_template.yaml index 02e49bc4b5..5c7b2fc6f4 100755 --- a/ci-scripts/build_fr1_template.yaml +++ b/ci-scripts/build_fr1_template.yaml @@ -14,7 +14,7 @@ steps: ADB: #on Caracal - ADBIPAddress : 192.168.18.196 + ADBIPAddress : 172.21.16.132 ADBUserName : oaici ADBPassword : KkexF6CErOi1fNuebCPsuIVK diff --git a/ci-scripts/checkCodingFormattingRules.sh b/ci-scripts/checkCodingFormattingRules.sh index a805f765df..c29941cade 100755 --- a/ci-scripts/checkCodingFormattingRules.sh +++ b/ci-scripts/checkCodingFormattingRules.sh @@ -59,7 +59,7 @@ if [ $# -eq 0 ] then echo " ---- Checking the whole repository ----" echo "" - NB_FILES_TO_FORMAT=`astyle --dry-run --options=ci-scripts/astyle-options.txt --recursive *.c *.h | grep -c Formatted || true` + NB_FILES_TO_FORMAT=`astyle --dry-run --options=ci-scripts/astyle-options.txt --recursive --exclude=ci-scripts --exclude=cmake_targets *.c *.h | grep -c Formatted || true` echo "Nb Files that do NOT follow OAI rules: $NB_FILES_TO_FORMAT" echo $NB_FILES_TO_FORMAT > ./oai_rules_result.txt @@ -136,7 +136,7 @@ fi # Merge request scenario MERGE_COMMMIT=`git log -n1 --pretty=format:%H` -TARGET_INIT_COMMIT=`cat .git/refs/remotes/origin/$TARGET_BRANCH` +TARGET_INIT_COMMIT=`git log -n1 --pretty=format:%H origin/$TARGET_BRANCH` echo " ---- Checking the modified files by the merge request ----" echo "" diff --git a/ci-scripts/ci_ueinfra.yaml b/ci-scripts/ci_ueinfra.yaml index 51acb75968..51fc4a264e 100644 --- a/ci-scripts/ci_ueinfra.yaml +++ b/ci-scripts/ci_ueinfra.yaml @@ -12,7 +12,7 @@ idefix: LogStore : /media/usb-drive/ci_qlogs PLMN : 22201 UENetwork : wwan0 - HostIPAddress : 192.168.18.188 + HostIPAddress : 172.21.16.135 HostUsername : oaicicd HostPassword : oaicicd HostSourceCodePath : none @@ -27,18 +27,66 @@ nrmodule2_quectel: Apn : OAICN5G : oai OAI-Rel14-Docker : oai.ipv4 - WakeupScript : ci_ctl_qtel.py /dev/ttyUSB7 wup - DetachScript : ci_ctl_qtel.py /dev/ttyUSB7 detach + WakeupScript : ci_ctl_qtel.py /dev/ttyUSB2 wup + DetachScript : ci_ctl_qtel.py /dev/ttyUSB2 detach LogStore : /media/ci_qlogs PLMN : 20897 - UENetwork : wwan1 - HostIPAddress : 192.168.18.189 + UENetwork : wwan0 + HostIPAddress : 172.21.16.139 HostUsername : nrmodule2 HostPassword : linux HostSourceCodePath : none StartCommands : - sudo -S ip link set dev wwan1 mtu 1500 MTU : 1500 + +# CAUTION: 192.168.18.89 address has to be changed when the server is moved +#single UE single ping +amarisoft_ue_1: + ID: amarisoft_ue_1 + State : enabled + Kind : amarisoft + #not required for AS config but needed for py script + WakeupScript : none + DetachScript : none + #end + Cmd : /root/NV17-12-21/ue/lteue + Config : /root/NV17-12-21/ue/config/oaicicd-ue-Ping-SATest.cfg + Duration : 60 + Ping : /tmp/test_ue1.log + UELog : /tmp/ue1.log + HostIPAddress : 172.21.16.144 + HostUsername : root + HostPassword : toor + HostSourceCodePath : /tmp + + +#an other scenario example +#notice : this will not work as such, only suggestion for multi ue scenario +amarisoft_ue_2: + ID: amarisoft_ue_2 + State : enabled + Kind : amarisoft + #not required for AS config but needed for py script + WakeupScript : none + DetachScript : none + #end + Cmd : /root/NV17-12-21/ue/lteue + Config : /root/NV17-12-21/ue/config/xxxxxxx.cfg #to be updated for an other scenario + Duration : 60 + Ping : + - /tmp/test_ue1.log #to be updated fo an other scenario + - /tmp/test_ue2.log #could be a list for a multi ue scenario + UELog : + - /tmp/ue1.log + - /tmp/ue1.log + HostIPAddress : 192.168.18.89 + HostUsername : root + HostPassword : toor + HostSourceCodePath : /tmp + + +#do not remove dummy: ID: '' State : '' @@ -50,7 +98,7 @@ dummy: DetachScript : '' PLMN : 22201 UENetwork : wwan0 - HostIPAddress : 192.168.18.188 + HostIPAddress : 172.21.16.135 HostUsername : oaicicd HostPassword : oaicicd HostSourceCodePath : none diff --git a/ci-scripts/cls_amarisoft_ue.py b/ci-scripts/cls_amarisoft_ue.py new file mode 100644 index 0000000000..367bfaac3f --- /dev/null +++ b/ci-scripts/cls_amarisoft_ue.py @@ -0,0 +1,81 @@ +# * 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 +# */ +#--------------------------------------------------------------------- +# +# Required Python Version +# Python 3.x +# +#--------------------------------------------------------------------- + +#to use isfile +import os +import sys +import logging +#to create a SSH object locally in the methods +import sshconnection +#time.sleep +import time + + +import re +import subprocess + +from datetime import datetime + + +class AS_UE: + + def __init__(self,Module): + #create attributes as in the UE dictionary + for k, v in Module.items(): + setattr(self, k, v) + + + + +#-----------------$ +#PUBLIC Methods$ +#-----------------$ + + def WaitEndScenario(self): + logging.debug('waiting for scenario duration') + time.sleep(int(self.Duration)) + + def KillASUE(self): + mySSH = sshconnection.SSHConnection() + mySSH.open(self.HostIPAddress, self.HostUsername, self.HostPassword) + mySSH.command('killall --signal SIGKILL lteue-avx2', '#', 5) + mySSH.close() + + def RunScenario(self): + mySSH = sshconnection.SSHConnection() + mySSH.open(self.HostIPAddress, self.HostUsername, self.HostPassword) + + logging.debug("Deleting old artifacts :") + cmd='rm -rf ' + self.Ping + ' ' + self.UELog + mySSH.command(cmd,'#',5) + logging.debug("Running scenario :") + cmd='echo $USER; nohup '+self.Cmd + ' ' + self.Config + ' &' + mySSH.command(cmd,'#',5) + + mySSH.close() + + + diff --git a/ci-scripts/cls_containerize.py b/ci-scripts/cls_containerize.py index fdc2bc1597..259db7bffe 100644 --- a/ci-scripts/cls_containerize.py +++ b/ci-scripts/cls_containerize.py @@ -93,6 +93,7 @@ class Containerize(): self.allImagesSize = {} self.collectInfo = {} + self.deployedContainers = [] self.tsharkStarted = False self.pingContName = '' self.pingOptions = '' @@ -242,7 +243,7 @@ class Containerize(): # Build the base image only on Push Events (not on Merge Requests) # On when the base image docker file is being modified. if forceBaseImageBuild: - mySSH.command(self.cli + ' build ' + self.cliBuildOptions + ' --target ' + baseImage + ' --tag ' + baseImage + ':' + baseTag + ' --file docker/Dockerfile.base' + self.dockerfileprefix + ' --build-arg NEEDED_GIT_PROXY="http://proxy.eurecom.fr:8080" . > cmake_targets/log/ran-base.log 2>&1', '\$', 1600) + mySSH.command(self.cli + ' build ' + self.cliBuildOptions + ' --target ' + baseImage + ' --tag ' + baseImage + ':' + baseTag + ' --file docker/Dockerfile.base' + self.dockerfileprefix + ' . > cmake_targets/log/ran-base.log 2>&1', '\$', 1600) # First verify if the base image was properly created. status = True mySSH.command(self.cli + ' image inspect --format=\'Size = {{.Size}} bytes\' ' + baseImage + ':' + baseTag, '\$', 5) @@ -293,6 +294,9 @@ class Containerize(): if image != 'ran-build': mySSH.command('sed -i -e "s#' + "ran-build" + ':latest#' + "ran-build" + ':' + imageTag + '#" docker/Dockerfile.' + pattern + self.dockerfileprefix, '\$', 5) mySSH.command(self.cli + ' build ' + self.cliBuildOptions + ' --target ' + image + ' --tag ' + image + ':' + imageTag + ' --file docker/Dockerfile.' + pattern + self.dockerfileprefix + ' . > cmake_targets/log/' + image + '.log 2>&1', '\$', 1200) + # Flatten Image + if image != 'ran-build': + mySSH.command('python3 ./ci-scripts/flatten_image.py --tag ' + image + ':' + imageTag, '\$', 300) # split the log mySSH.command('mkdir -p cmake_targets/log/' + image, '\$', 5) mySSH.command('python3 ci-scripts/docker_log_split.py --logfilename=cmake_targets/log/' + image + '.log', '\$', 5) @@ -606,6 +610,8 @@ class Containerize(): if containerToKill: mySSH.command('docker kill --signal INT ' + containerName, '\$', 30) time.sleep(5) + mySSH.command('docker kill --signal KILL ' + containerName, '\$', 30) + time.sleep(5) mySSH.command('docker logs ' + containerName + ' > ' + lSourcePath + '/cmake_targets/' + self.eNB_logFile[self.eNB_instance], '\$', 30) mySSH.command('docker rm -f ' + containerName, '\$', 30) # Forcing the down now to remove the networks and any artifacts @@ -680,12 +686,28 @@ class Containerize(): cmd = 'cd ' + self.yamlPath[0] + ' && docker-compose -f docker-compose-ci.yml ps -a' count = 0 healthy = 0 + newContainers = [] while (count < 10): count += 1 containerStatus = [] deployStatus = subprocess.check_output(cmd, shell=True, stderr=subprocess.STDOUT, universal_newlines=True, timeout=30) healthy = 0 for state in deployStatus.split('\n'): + res = re.search('Name|----------', state) + if res is not None: + continue + if len(state) == 0: + continue + res = re.search('^(?P[a-zA-Z0-9\-\_]+) ', state) + if res is not None: + cName = res.group('container_name') + found = False + for alreadyDeployed in self.deployedContainers: + if cName == alreadyDeployed: + found = True + if not found: + newContainers.append(cName) + self.deployedContainers.append(cName) if re.search('Up \(healthy\)', state) is not None: healthy += 1 if re.search('rfsim4g-db-init.*Exit 0', state) is not None: @@ -696,16 +718,33 @@ class Containerize(): else: time.sleep(10) + imagesInfo = '' + for newCont in newContainers: + cmd = 'docker inspect -f "{{.Config.Image}}" ' + newCont + imageName = subprocess.check_output(cmd, shell=True, stderr=subprocess.STDOUT, universal_newlines=True, timeout=30) + imageName = str(imageName).strip() + cmd = 'docker image inspect --format "{{.RepoTags}}\t{{.Size}}\t{{.Created}}" ' + imageName + imagesInfo += subprocess.check_output(cmd, shell=True, stderr=subprocess.STDOUT, universal_newlines=True, timeout=30) + + html_queue = SimpleQueue() + html_cell = '
\n'
+		for imageInfo in imagesInfo.split('\n'):
+			html_cell += imageInfo[:-11] + '\n'
+		html_cell += '\n'
+		for cState in containerStatus:
+			html_cell += cState + '\n'
+		html_cell += '
' + html_queue.put(html_cell) if count == 100 and healthy == self.nb_healthy[0]: if self.tsharkStarted == False: logging.debug('Starting tshark on public network') self.CaptureOnDockerNetworks() - HTML.CreateHtmlTestRow('n/a', 'OK', CONST.ALL_PROCESSES_OK) + HTML.CreateHtmlTestRowQueue('n/a', 'OK', 1, html_queue) for cState in containerStatus: logging.debug(cState) logging.info('\u001B[1m Deploying OAI Object(s) PASS\u001B[0m') else: - HTML.CreateHtmlTestRow('Could not deploy in time', 'KO', CONST.ALL_PROCESSES_OK) + HTML.CreateHtmlTestRowQueue('Could not deploy in time', 'KO', 1, html_queue) for cState in containerStatus: logging.debug(cState) logging.error('\u001B[1m Deploying OAI Object(s) FAILED\u001B[0m') @@ -721,13 +760,19 @@ class Containerize(): cmd = 'cd ' + self.yamlPath[0] + ' && docker-compose -f docker-compose-ci.yml config | grep com.docker.network.bridge.name | sed -e "s@^.*name: @@"' networkNames = subprocess.check_output(cmd, shell=True, stderr=subprocess.STDOUT, universal_newlines=True, timeout=10) if re.search('4g.*rfsimulator', self.yamlPath[0]) is not None: + # Excluding any traffic from LTE-UE container (192.168.61.30) + # From the trf-gen, keeping only PING traffic cmd = 'sudo nohup tshark -f "(host 192.168.61.11 and icmp) or (not host 192.168.61.11 and not host 192.168.61.30 and not arp and not port 53 and not port 2152)"' elif re.search('5g.*rfsimulator', self.yamlPath[0]) is not None: - cmd = 'sudo nohup tshark -f "(host 192.168.72.135 and icmp) or (not host 192.168.72.135 and not host 192.168.71.150 and not arp and not port 53 and not port 2152 and not port 2153)"' + # Excluding any traffic from NR-UE containers (192.168.71.150 and 192.168.71.151) + # From the ext-dn, keeping only PING traffic + cmd = 'sudo nohup tshark -f "(host 192.168.72.135 and icmp) or (not host 192.168.72.135 and not host 192.168.71.150 and not host 192.168.71.151 and not arp and not port 53 and not port 2152 and not port 2153)"' + elif re.search('5g_l2sim', self.yamlPath[0]) is not None: + cmd = '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)"' else: return for name in networkNames.split('\n'): - if re.search('rfsim', name) is not None: + if re.search('rfsim', name) is not None or re.search('l2sim', name) is not None: cmd += ' -i ' + name cmd += ' -w /tmp/capture_' ymlPath = self.yamlPath[0].split('/') @@ -779,46 +824,48 @@ class Containerize(): # Analyzing log file(s)! listOfPossibleRanContainers = ['enb', 'gnb', 'cu', 'du'] for container in listOfPossibleRanContainers: - filename = self.yamlPath[0] + '/rfsim?g-oai-' + container + '.log' - cmd = 'ls ' + filename + filenames = self.yamlPath[0] + '/*-oai-' + container + '.log' + cmd = 'ls ' + filenames containerStatus = True try: lsStatus = subprocess.check_output(cmd, shell=True, stderr=subprocess.STDOUT, universal_newlines=True, timeout=10) - filename = str(lsStatus).strip() + filenames = str(lsStatus).strip() except: containerStatus = False if not containerStatus: continue - logging.debug('\u001B[1m Analyzing xNB logfile ' + filename + ' \u001B[0m') - logStatus = RAN.AnalyzeLogFile_eNB(filename, HTML, self.ran_checkers) - if (logStatus < 0): - fullStatus = False - self.exitStatus = 1 - HTML.CreateHtmlTestRow(RAN.runtime_stats, 'KO', logStatus) - else: - HTML.CreateHtmlTestRow(RAN.runtime_stats, 'OK', CONST.ALL_PROCESSES_OK) + for filename in filenames.split('\n'): + logging.debug('\u001B[1m Analyzing xNB logfile ' + filename + ' \u001B[0m') + logStatus = RAN.AnalyzeLogFile_eNB(filename, HTML, self.ran_checkers) + if (logStatus < 0): + fullStatus = False + self.exitStatus = 1 + HTML.CreateHtmlTestRow(RAN.runtime_stats, 'KO', logStatus) + else: + HTML.CreateHtmlTestRow(RAN.runtime_stats, 'OK', CONST.ALL_PROCESSES_OK) listOfPossibleUeContainers = ['lte-ue*', 'nr-ue*'] for container in listOfPossibleUeContainers: - filename = self.yamlPath[0] + '/rfsim?g-oai-' + container + '.log' - cmd = 'ls ' + filename + filenames = self.yamlPath[0] + '/*-oai-' + container + '.log' + cmd = 'ls ' + filenames containerStatus = True try: lsStatus = subprocess.check_output(cmd, shell=True, stderr=subprocess.STDOUT, universal_newlines=True, timeout=10) - filename = str(lsStatus).strip() + filenames = str(lsStatus).strip() except: containerStatus = False if not containerStatus: continue - logging.debug('\u001B[1m Analyzing UE logfile ' + filename + ' \u001B[0m') - logStatus = UE.AnalyzeLogFile_UE(filename, HTML, RAN) - if (logStatus < 0): - fullStatus = False - HTML.CreateHtmlTestRow('UE log Analysis', 'KO', logStatus) - else: - HTML.CreateHtmlTestRow('UE log Analysis', 'OK', CONST.ALL_PROCESSES_OK) + for filename in filenames.split('\n'): + logging.debug('\u001B[1m Analyzing UE logfile ' + filename + ' \u001B[0m') + logStatus = UE.AnalyzeLogFile_UE(filename, HTML, RAN) + if (logStatus < 0): + fullStatus = False + HTML.CreateHtmlTestRow('UE log Analysis', 'KO', logStatus) + else: + HTML.CreateHtmlTestRow('UE log Analysis', 'OK', CONST.ALL_PROCESSES_OK) cmd = 'rm ' + self.yamlPath[0] + '/*.log' logging.debug(cmd) @@ -849,6 +896,7 @@ class Containerize(): logging.error('\u001B[1m Undeploying OAI Object(s) FAILED\u001B[0m') return + self.deployedContainers = [] # Cleaning any created tmp volume cmd = 'docker volume prune --force || true' logging.debug(cmd) @@ -861,6 +909,40 @@ class Containerize(): HTML.CreateHtmlTestRow('n/a', 'KO', CONST.ALL_PROCESSES_OK) logging.info('\u001B[1m Undeploying OAI Object(s) FAIL\u001B[0m') + def StatsFromGenObject(self, HTML): + self.exitStatus = 0 + ymlPath = self.yamlPath[0].split('/') + logPath = '../cmake_targets/log/' + ymlPath[1] + + # if the containers are running, recover the logs! + cmd = 'cd ' + self.yamlPath[0] + ' && docker-compose -f docker-compose-ci.yml ps --all' + logging.debug(cmd) + deployStatus = subprocess.check_output(cmd, shell=True, stderr=subprocess.STDOUT, universal_newlines=True, timeout=30) + cmd = 'docker stats --no-stream --format "table {{.Container}}\t{{.CPUPerc}}\t{{.MemUsage}}\t{{.MemPerc}}" ' + anyLogs = False + for state in deployStatus.split('\n'): + res = re.search('Name|----------', state) + if res is not None: + continue + if len(state) == 0: + continue + res = re.search('^(?P[a-zA-Z0-9\-\_]+) ', state) + if res is not None: + anyLogs = True + cmd += res.group('container_name') + ' ' + message = '' + if anyLogs: + logging.debug(cmd) + stats = subprocess.check_output(cmd, shell=True, stderr=subprocess.STDOUT, universal_newlines=True, timeout=30) + for statLine in stats.split('\n'): + logging.debug(statLine) + message += statLine + '\n' + + html_queue = SimpleQueue() + html_cell = '
\n' + message + '
' + html_queue.put(html_cell) + HTML.CreateHtmlTestRowQueue(self.pingOptions, 'OK', 1, html_queue) + def PingFromContainer(self, HTML, RAN, UE): self.exitStatus = 0 ymlPath = self.yamlPath[0].split('/') @@ -1067,19 +1149,19 @@ class Containerize(): 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('192.168.18.194', mySSH.getBefore()) + 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 192.168.18.194 dev eno1', '\$', 10) + 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('192.168.18.193', mySSH.getBefore()) + 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 192.168.18.193 dev eno1', '\$', 10) + mySSH.command('echo ' + password + ' | sudo -S ip route add 192.168.68.128/26 via 172.21.16.128 dev eno1', '\$', 10) # Check if route to nepes gnb exists mySSH.command('ip route | grep --colour=never "192.168.68.192/26"', '\$', 10) - result = re.search('192.168.18.209', mySSH.getBefore()) + 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 192.168.18.209 dev eno1', '\$', 10) + 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()) @@ -1095,19 +1177,19 @@ class Containerize(): 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('192.168.18.210', mySSH.getBefore()) + 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 192.168.18.210 dev em1', '\$', 10) + 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('192.168.18.210', mySSH.getBefore()) + 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 192.168.18.210 dev em1', '\$', 10) + 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('192.168.18.193', mySSH.getBefore()) + 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 192.168.18.193 dev em1', '\$', 10) + 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()) @@ -1123,19 +1205,19 @@ class Containerize(): 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('192.168.18.210', mySSH.getBefore()) + 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 192.168.18.210 dev eno1', '\$', 10) + 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('192.168.18.194', mySSH.getBefore()) + 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 192.168.18.194 dev eno1', '\$', 10) + 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('192.168.18.209', mySSH.getBefore()) + 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 192.168.18.209 dev eno1', '\$', 10) + 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()) @@ -1151,14 +1233,14 @@ class Containerize(): 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('192.168.18.210', mySSH.getBefore()) + 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 192.168.18.210 dev enp0s31f6', '\$', 10) + mySSH.command('echo ' + password + ' | sudo -S ip route add 192.168.61.192/26 via 172.21.16.136 dev enp0s31f6', '\$', 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('192.168.18.193', mySSH.getBefore()) + 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 192.168.18.193 dev enp0s31f6', '\$', 10) + mySSH.command('echo ' + password + ' | sudo -S ip route add 192.168.68.128/26 via 172.21.16.128 dev enp0s31f6', '\$', 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()) diff --git a/ci-scripts/cls_log_mgt.py b/ci-scripts/cls_log_mgt.py index 905a105512..f1dbf6b8ec 100644 --- a/ci-scripts/cls_log_mgt.py +++ b/ci-scripts/cls_log_mgt.py @@ -64,10 +64,10 @@ class Log_Mgt: if m is not None: return int(m.group(1)) - def __RemoveOldest(self): + def __RemoveOldest(self, days): mySSH = sshconnection.SSHConnection() mySSH.open(self.IPAddress, self.Username, self.Password) - COMMAND='echo ' + self.Password + ' | sudo -S find ' + self.path + ' -type f -mtime +14 -delete' + COMMAND='echo ' + self.Password + ' | sudo -S find ' + self.path + ' -type f -mtime +' + str(days) + ' -delete' mySSH.command(COMMAND,'\$',20) mySSH.close() @@ -79,13 +79,18 @@ class Log_Mgt: def LogRotation(self): - used_space = self.__CheckUsedSpace() #avail space in target folder - if used_space > 80 : - logging.debug('\u001B[1;37;41m Used Disk > 80%, on ' + self.Username+'@'+self.IPAddress + '\u001B[0m') - logging.debug('\u001B[1;37;41m Removing Artifacts older than 14 days \u001B[0m') - self.__RemoveOldest() - else: - logging.debug('Used Disk < 80%, on ' + self.Username+'@'+self.IPAddress +', no cleaning required') + doLoop = True + nbDays = 14 + while doLoop and nbDays > 1: + used_space = self.__CheckUsedSpace() #avail space in target folder + if used_space > 80 : + logging.debug('\u001B[1;37;41m Used Disk (' + str(used_space) + '%) > 80%, on ' + self.Username+'@'+self.IPAddress + '\u001B[0m') + logging.debug('\u001B[1;37;41m Removing Artifacts older than ' + str(nbDays) + ' days \u001B[0m') + self.__RemoveOldest(nbDays) + nbDays -= 1 + else: + logging.debug('Used Disk (' + str(used_space) + '%) < 80%, on ' + self.Username+'@'+self.IPAddress +', no cleaning required') + doLoop = False diff --git a/ci-scripts/cls_module_ue.py b/ci-scripts/cls_module_ue.py index cabd0a045d..dcf75a34fc 100644 --- a/ci-scripts/cls_module_ue.py +++ b/ci-scripts/cls_module_ue.py @@ -76,7 +76,8 @@ class Module_UE: logging.debug('Starting ' + self.Process['Name']) mySSH = sshconnection.SSHConnection() mySSH.open(self.HostIPAddress, self.HostUsername, self.HostPassword) - mySSH.command('echo $USER; echo ' + self.HostPassword + ' | nohup sudo -S ' + self.Process['Cmd'] + ' ' + self.Process['Apn'][CNType] + ' > /dev/null 2>&1 &','\$',5) + mySSH.command('echo ' + self.HostPassword + ' | sudo -S rm -f /tmp/quectel-cm.log','\$',5) + mySSH.command('echo $USER; echo ' + self.HostPassword + ' | nohup sudo -S stdbuf -o0 ' + self.Process['Cmd'] + ' ' + self.Process['Apn'][CNType] + ' > /tmp/quectel-cm.log 2>&1 &','\$',5) mySSH.close() #checking the process time.sleep(5) @@ -106,14 +107,15 @@ class Module_UE: def GetModuleIPAddress(self): HOST=self.HostUsername+'@'+self.HostIPAddress response= [] - tentative = 3 + tentative = 8 while (len(response)==0) and (tentative>0): COMMAND="ip a show dev " + self.UENetwork + " | grep --colour=never inet | grep " + self.UENetwork - logging.debug(COMMAND) + if tentative == 8: + logging.debug(COMMAND) ssh = subprocess.Popen(["ssh", "%s" % HOST, COMMAND],shell=False,stdout=subprocess.PIPE,stderr=subprocess.PIPE) response = ssh.stdout.readlines() tentative-=1 - time.sleep(10) + time.sleep(2) if (tentative==0) and (len(response)==0): logging.debug('\u001B[1;37;41m Module IP Address Not Found! Time expired \u001B[0m') return -1 diff --git a/ci-scripts/html.py b/ci-scripts/cls_oai_html.py similarity index 100% rename from ci-scripts/html.py rename to ci-scripts/cls_oai_html.py diff --git a/ci-scripts/cls_oaicitest.py b/ci-scripts/cls_oaicitest.py index 5d89a7b2e0..9d5ae84038 100644 --- a/ci-scripts/cls_oaicitest.py +++ b/ci-scripts/cls_oaicitest.py @@ -55,6 +55,7 @@ import constants as CONST import sshconnection import cls_module_ue +import cls_amarisoft_ue import cls_ci_ueinfra #class defining the multi Ue infrastrucure logging.getLogger("matplotlib").setLevel(logging.WARNING) @@ -122,6 +123,7 @@ def GetPingTimeAnalysis(RAN,ping_log_file,ping_rttavg_threshold): try: mySSH = sshconnection.SSHConnection() mySSH.copyout(RAN.eNBIPAddress, RAN.eNBUserName, RAN.eNBPassword, ping_log_file+'.png', RAN.eNBSourceCodePath + '/cmake_targets/') + mySSH.copyout(RAN.eNBIPAddress, RAN.eNBUserName, RAN.eNBPassword, ping_log_file, RAN.eNBSourceCodePath + '/cmake_targets/') except: logging.debug('\u001B[1;37;41m Ping PNG SCP to eNB FAILED\u001B[0m') @@ -418,49 +420,63 @@ class OaiCiTest(): for job in multi_jobs: job.join() HTML.CreateHtmlTestRow('N/A', 'OK', CONST.ALL_PROCESSES_OK) - else: #if an ID is specified, it is a module from the yaml infrastructure file - #RH - Module_UE = cls_module_ue.Module_UE(InfraUE.ci_ue_infra[self.ue_id]) - Module_UE.ue_trace=ue_trace - is_module=Module_UE.CheckCMProcess(EPC.Type) - if is_module: - Module_UE.EnableTrace() - time.sleep(5) + else: #if an ID is specified, it is a UE from the yaml infrastructure file + ue_kind = InfraUE.ci_ue_infra[self.ue_id]['Kind'] + logging.debug("Detected UE Kind : " + ue_kind) - # Looping attach / detach / wait to be successful at least once - cnt = 0 - status = -1 - while cnt < 4: - Module_UE.Command("wup") - logging.debug("Waiting for IP address to be assigned") - time.sleep(20) - logging.debug("Retrieve IP address") - status=Module_UE.GetModuleIPAddress() - if status==0: - cnt = 10 - else: - cnt += 1 - Module_UE.Command("detach") - time.sleep(20) + #case it is a quectel module (only 1 at a time supported at the moment) + if ue_kind == 'quectel': + Module_UE = cls_module_ue.Module_UE(InfraUE.ci_ue_infra[self.ue_id]) + Module_UE.ue_trace=ue_trace + is_module=Module_UE.CheckCMProcess(EPC.Type) + if is_module: + Module_UE.EnableTrace() + time.sleep(5) - if cnt == 10 and status == 0: - HTML.CreateHtmlTestRow(Module_UE.UEIPAddress, 'OK', CONST.ALL_PROCESSES_OK) - logging.debug('UE IP addresss : '+ Module_UE.UEIPAddress) - #execute additional commands from yaml file after UE attach - SSH = sshconnection.SSHConnection() - SSH.open(Module_UE.HostIPAddress, Module_UE.HostUsername, Module_UE.HostPassword) - if hasattr(Module_UE,'StartCommands'): - for startcommand in Module_UE.StartCommands: - cmd = 'echo ' + Module_UE.HostPassword + ' | ' + startcommand - SSH.command(cmd,'\$',5) - SSH.close() - #check that the MTU is as expected / requested - Module_UE.CheckModuleMTU() - else: #status==-1 failed to retrieve IP address - HTML.CreateHtmlTestRow('N/A', 'KO', CONST.UE_IP_ADDRESS_ISSUE) - self.AutoTerminateUEandeNB(HTML,RAN,COTS_UE,EPC,InfraUE,CONTAINERS) - return - + # Looping attach / detach / wait to be successful at least once + cnt = 0 + status = -1 + while cnt < 4: + Module_UE.Command("wup") + logging.debug("Waiting for IP address to be assigned") + time.sleep(5) + logging.debug("Retrieve IP address") + status=Module_UE.GetModuleIPAddress() + if status==0: + cnt = 10 + else: + cnt += 1 + Module_UE.Command("detach") + time.sleep(20) + + if cnt == 10 and status == 0: + HTML.CreateHtmlTestRow(Module_UE.UEIPAddress, 'OK', CONST.ALL_PROCESSES_OK) + logging.debug('UE IP addresss : '+ Module_UE.UEIPAddress) + #execute additional commands from yaml file after UE attach + SSH = sshconnection.SSHConnection() + SSH.open(Module_UE.HostIPAddress, Module_UE.HostUsername, Module_UE.HostPassword) + if hasattr(Module_UE,'StartCommands'): + for startcommand in Module_UE.StartCommands: + cmd = 'echo ' + Module_UE.HostPassword + ' | ' + startcommand + SSH.command(cmd,'\$',5) + SSH.close() + #check that the MTU is as expected / requested + Module_UE.CheckModuleMTU() + else: #status==-1 failed to retrieve IP address + HTML.CreateHtmlTestRow('N/A', 'KO', CONST.UE_IP_ADDRESS_ISSUE) + self.AutoTerminateUEandeNB(HTML,RAN,COTS_UE,EPC,InfraUE,CONTAINERS) + return + + #case it is a amarisoft ue (only 1 at a time supported at the moment) + elif ue_kind == 'amarisoft': + AS_UE = cls_amarisoft_ue.AS_UE(InfraUE.ci_ue_infra[self.ue_id]) + HTML.CreateHtmlTestRow(AS_UE.Config, 'OK', CONST.ALL_PROCESSES_OK) + AS_UE.RunScenario() + AS_UE.WaitEndScenario() + AS_UE.KillASUE() + + else: + logging.debug("Incorrect UE Kind was detected") def InitializeOAIUE(self,HTML,RAN,EPC,COTS_UE,InfraUE,CONTAINERS): @@ -534,7 +550,7 @@ class OaiCiTest(): while (doOutterLoop): SSH.command('cd ' + self.UESourceCodePath + '/cmake_targets/ran_build/build', '\$', 5) SSH.command('echo ' + self.UEPassword + ' | sudo -S rm -Rf ' + self.UESourceCodePath + '/cmake_targets/ue_' + self.testCase_id + '.log', '\$', 5) - SSH.command('echo $USER; nohup sudo -E ./my-lte-uesoftmodem-run' + str(self.UE_instance) + '.sh' + ' > ' + self.UESourceCodePath + '/cmake_targets/ue_' + self.testCase_id + '.log ' + ' 2>&1 &', self.UEUserName, 5) + SSH.command('echo $USER; nohup sudo -E stdbuf -o0 ./my-lte-uesoftmodem-run' + str(self.UE_instance) + '.sh' + ' > ' + self.UESourceCodePath + '/cmake_targets/ue_' + self.testCase_id + '.log ' + ' 2>&1 &', self.UEUserName, 5) time.sleep(6) SSH.command('cd ../..', '\$', 5) doLoop = True @@ -1095,7 +1111,7 @@ class OaiCiTest(): while cnt < 4: Module_UE.Command("wup") logging.debug("Waiting for IP address to be assigned") - time.sleep(20) + time.sleep(5) logging.debug("Retrieve IP address") status=Module_UE.GetModuleIPAddress() if status==0: @@ -1569,16 +1585,23 @@ class OaiCiTest(): SSH = sshconnection.SSHConnection() # Launch ping on the EPC side (true for ltebox and old open-air-cn) # But for OAI-Rel14-CUPS, we launch from python executor + ping_status = 0 launchFromEpc = True launchFromModule = False + launchFromASUE = False if re.match('OAI-Rel14-CUPS', EPC.Type, re.IGNORECASE): launchFromEpc = False #if module, ping from module to EPC if self.ue_id!='': - launchFromEpc = False - launchfromModule = True - - ping_time = re.findall("-c (\d+)",str(self.ping_args)) + if (re.match('amarisoft', self.ue_id, re.IGNORECASE)): + launchFromEpc = False + launchFromASUE = True + else: + launchFromEpc = False + launchFromModule = True + #no ping args for ASUE + if self.ping_args!='': + ping_time = re.findall("-c (\d+)",str(self.ping_args)) if launchFromEpc: SSH.open(EPC.IPAddress, EPC.UserName, EPC.Password) @@ -1596,14 +1619,14 @@ class OaiCiTest(): #copy the ping log file to have it locally for analysis (ping stats) SSH.copyin(EPC.IPAddress, EPC.UserName, EPC.Password, EPC.SourceCodePath + '/scripts/ping_' + self.testCase_id + '_' + device_id + '.log', '.') else: - if launchfromModule == False: + if (launchFromModule == False) and (launchFromASUE == False): #ping log file is on the python executor - cmd = 'ping ' + self.ping_args + ' ' + UE_IPAddress + ' 2>&1 > ping_' + self.testCase_id + '_' + device_id + '.log' + cmd = 'ping ' + self.ping_args + ' ' + UE_IPAddress + ' > ping_' + self.testCase_id + '_' + device_id + '.log 2>&1' message = cmd + '\n' logging.debug(cmd) ret = subprocess.run(cmd, shell=True) ping_status = ret.returncode - #copy the ping log file to an other folder for log collection (source and destination are EPC) + #copy the ping log file to an other folder for log collection (source and desti elif (launchfromModule == True) and (launchfromASUE == False): #launch from Modulenation are EPC) SSH.copyout(EPC.IPAddress, EPC.UserName, EPC.Password, 'ping_' + self.testCase_id + '_' + device_id + '.log', EPC.SourceCodePath + '/scripts') #copy the ping log file to have it locally for analysis (ping stats) logging.debug(EPC.SourceCodePath + 'ping_' + self.testCase_id + '_' + device_id + '.log') @@ -1613,7 +1636,8 @@ class OaiCiTest(): #cat is executed on EPC SSH.command('cat ' + EPC.SourceCodePath + '/scripts/ping_' + self.testCase_id + '_' + device_id + '.log', '\$', 5) ping_log_file='/scripts/ping_' + self.testCase_id + '_' + device_id + '.log' - else: #launch from Module + + elif (launchFromModule == True) and (launchFromASUE == False): #launch from Module SSH.open(Module_UE.HostIPAddress, Module_UE.HostUsername, Module_UE.HostPassword) #target address is different depending on EPC type if re.match('OAI-Rel14-Docker', EPC.Type, re.IGNORECASE): @@ -1623,15 +1647,29 @@ class OaiCiTest(): else: Target = EPC.IPAddress #ping from module NIC rather than IP address to make sure round trip is over the air - cmd = 'ping -I ' + Module_UE.UENetwork + ' ' + self.ping_args + ' ' + Target + ' 2>&1 > ping_' + self.testCase_id + '_' + self.ue_id + '.log' + cmd = 'ping -I ' + Module_UE.UENetwork + ' ' + self.ping_args + ' ' + Target + ' > ping_' + self.testCase_id + '_' + self.ue_id + '.log 2>&1' SSH.command(cmd,'\$',int(ping_time[0])*1.5) + #copy the ping log file to have it locally for analysis (ping stats) SSH.copyin(Module_UE.HostIPAddress, Module_UE.HostUsername, Module_UE.HostPassword, 'ping_' + self.testCase_id + '_' + self.ue_id + '.log', '.') #cat is executed locally SSH.command('cat ping_' + self.testCase_id + '_' + self.ue_id + '.log', '\$', 5) ping_log_file='ping_' + self.testCase_id + '_' + self.ue_id + '.log' - ping_status=0 + + elif (launchFromASUE == True): + #ping was already executed when running scenario + #we only need to retrieve ping log file, whose location is in the ci_ueinfra.yaml + logging.debug("Get logs from AS server : " + Module_UE.Ping + ", " + Module_UE.UELog) + SSH.copyin(Module_UE.HostIPAddress, Module_UE.HostUsername, Module_UE.HostPassword, Module_UE.Ping, '.') + SSH.copyin(Module_UE.HostIPAddress, Module_UE.HostUsername, Module_UE.HostPassword, Module_UE.UELog, '.') + logging.debug("Ping analysis from Amarisoft scenario") + path,ping_log_file = os.path.split(Module_UE.Ping) + SSH.open(Module_UE.HostIPAddress, Module_UE.HostUsername, Module_UE.HostPassword) + SSH.command('cat ' + Module_UE.Ping, '\#', 5) + + else: + ping_status=-1 # TIMEOUT CASE if ping_status < 0: @@ -1679,28 +1717,30 @@ class OaiCiTest(): #adding extra ping stats from local file #ping_log_file variable is defined above in this function, depending on device/ue - logging.debug('Analyzing Ping log file : ' + os.getcwd() + '/' + ping_log_file) - ping_stat=GetPingTimeAnalysis(RAN,ping_log_file,self.ping_rttavg_threshold) ping_stat_msg='' - if (ping_stat!=-1) and (len(ping_stat)!=0): - ping_stat_msg+='Ping stats before removing largest value : \n' - ping_stat_msg+='RTT(Min) : ' + str("{:.2f}".format(ping_stat['min_0'])) + 'ms \n' - ping_stat_msg+='RTT(Mean) : ' + str("{:.2f}".format(ping_stat['mean_0'])) + 'ms \n' - ping_stat_msg+='RTT(Median) : ' + str("{:.2f}".format(ping_stat['median_0'])) + 'ms \n' - ping_stat_msg+='RTT(Max) : ' + str("{:.2f}".format(ping_stat['max_0'])) + 'ms \n' - ping_stat_msg+='Max Index : ' + str(ping_stat['max_loc']) + '\n' - ping_stat_msg+='Ping stats after removing largest value : \n' - ping_stat_msg+='RTT(Min) : ' + str("{:.2f}".format(ping_stat['min_1'])) + 'ms \n' - ping_stat_msg+='RTT(Mean) : ' + str("{:.2f}".format(ping_stat['mean_1'])) + 'ms \n' - ping_stat_msg+='RTT(Median) : ' + str("{:.2f}".format(ping_stat['median_1'])) + 'ms \n' - ping_stat_msg+='RTT(Max) : ' + str("{:.2f}".format(ping_stat['max_1'])) + 'ms \n' + if launchFromASUE == False : #skip in case of AS UE (for the moment) + logging.debug('Analyzing Ping log file : ' + os.getcwd() + '/' + ping_log_file) + ping_stat=GetPingTimeAnalysis(RAN,ping_log_file,self.ping_rttavg_threshold) + + if (ping_stat!=-1) and (len(ping_stat)!=0): + ping_stat_msg+='Ping stats before removing largest value : \n' + ping_stat_msg+='RTT(Min) : ' + str("{:.2f}".format(ping_stat['min_0'])) + 'ms \n' + ping_stat_msg+='RTT(Mean) : ' + str("{:.2f}".format(ping_stat['mean_0'])) + 'ms \n' + ping_stat_msg+='RTT(Median) : ' + str("{:.2f}".format(ping_stat['median_0'])) + 'ms \n' + ping_stat_msg+='RTT(Max) : ' + str("{:.2f}".format(ping_stat['max_0'])) + 'ms \n' + ping_stat_msg+='Max Index : ' + str(ping_stat['max_loc']) + '\n' + ping_stat_msg+='Ping stats after removing largest value : \n' + ping_stat_msg+='RTT(Min) : ' + str("{:.2f}".format(ping_stat['min_1'])) + 'ms \n' + ping_stat_msg+='RTT(Mean) : ' + str("{:.2f}".format(ping_stat['mean_1'])) + 'ms \n' + ping_stat_msg+='RTT(Median) : ' + str("{:.2f}".format(ping_stat['median_1'])) + 'ms \n' + ping_stat_msg+='RTT(Max) : ' + str("{:.2f}".format(ping_stat['max_1'])) + 'ms \n' #building html message qMsg = pal_msg + '\n' + min_msg + '\n' + avg_msg + '\n' + max_msg + '\n' + ping_stat_msg #checking packet loss compliance packetLossOK = True - if packetloss is not None: + if (packetloss is not None) : if float(packetloss) > float(self.ping_packetloss_threshold): qMsg += '\nPacket Loss too high' logging.debug('\u001B[1;37;41m Packet Loss too high; Target: '+ self.ping_packetloss_threshold + '%\u001B[0m') @@ -1728,6 +1768,7 @@ class OaiCiTest(): lock.release() SSH.close() except: + logging.debug('exit from Ping_Common except') os.kill(os.getppid(),signal.SIGUSR1) def PingNoS1_wrong_exit(self, qMsg,HTML): @@ -1855,11 +1896,21 @@ class OaiCiTest(): HTML.CreateHtmlTestRow(self.ping_args, 'KO', CONST.UE_IP_ADDRESS_ISSUE) self.AutoTerminateUEandeNB(HTML,RAN,COTS_UE,EPC,InfraUE,CONTAINERS) return - else: - self.UEIPAddresses=[] - Module_UE = cls_module_ue.Module_UE(InfraUE.ci_ue_infra[self.ue_id]) - Module_UE.GetModuleIPAddress() - self.UEIPAddresses.append(Module_UE.UEIPAddress) + else: #if an ID is specified, it is a UE from the yaml infrastructure file + ue_kind = InfraUE.ci_ue_infra[self.ue_id]['Kind'] + logging.debug("Detected UE Kind : " + ue_kind) + + if ue_kind == 'quectel': + self.UEIPAddresses=[] + Module_UE = cls_module_ue.Module_UE(InfraUE.ci_ue_infra[self.ue_id]) + Module_UE.GetModuleIPAddress() + self.UEIPAddresses.append(Module_UE.UEIPAddress) + elif ue_kind == 'amarisoft': + self.UEIPAddresses=['AS UE IP'] + Module_UE = cls_module_ue.Module_UE(InfraUE.ci_ue_infra[self.ue_id]) + else: + logging.debug("Incorrect UE Kind was detected") + logging.debug(self.UEIPAddresses) multi_jobs = [] i = 0 @@ -1870,6 +1921,7 @@ class OaiCiTest(): device_id = self.UEDevices[i] else: device_id = Module_UE.ID + "-" + Module_UE.Kind + logging.debug(device_id) p = Process(target = self.Ping_common, args = (lock,UE_IPAddress,device_id,status_queue,EPC,Module_UE,RAN,)) p.daemon = True p.start() @@ -2084,7 +2136,8 @@ class OaiCiTest(): statusQueue.put(UE_IPAddress) statusQueue.put(report_msg) logging.debug('\u001B[1;37;45m TCP Bidir Iperf Result (' + UE_IPAddress + ') \u001B[0m') - logging.debug('\u001B[1;35m ' + report_msg + '\u001B[0m') + for rLine in report_msg.split('\n'): + logging.debug('\u001B[1;35m ' + rLine + '\u001B[0m') lock.release() else: self.ping_iperf_wrong_exit(lock, UE_IPAddress, device_id, statusQueue, 'Bidir TCP : Could not analyze from Log file') @@ -2379,10 +2432,12 @@ class OaiCiTest(): SSH.copyout(EPC.IPAddress, EPC.UserName, EPC.Password, 'iperf_' + self.testCase_id + '_' + device_id + '.log', EPC.SourceCodePath + '/scripts') - def Iperf_Module(self, lock, UE_IPAddress, device_id, idx, ue_num, statusQueue,EPC, Module_UE): + def Iperf_Module(self, lock, UE_IPAddress, device_id, idx, ue_num, statusQueue,EPC, Module_UE, RAN): + SSH = sshconnection.SSHConnection() + server_filename = 'iperf_server_' + self.testCase_id + '_' + self.ue_id + '.log' + client_filename = 'iperf_client_' + self.testCase_id + '_' + self.ue_id + '.log' if (re.match('OAI-Rel14-Docker', EPC.Type, re.IGNORECASE)) or (re.match('OAICN5G', EPC.Type, re.IGNORECASE)): #retrieve trf-gen container IP address - SSH = sshconnection.SSHConnection() SSH.open(EPC.IPAddress, EPC.UserName, EPC.Password) SSH.command('docker inspect --format="TRF_IP_ADDR = {{range .NetworkSettings.Networks}}{{.IPAddress}}{{end}}" prod-trf-gen', '\$', 5) result = re.search('TRF_IP_ADDR = (?P[0-9\.]+)', SSH.getBefore()) @@ -2404,20 +2459,18 @@ class OaiCiTest(): if self.iperf_direction=="DL": logging.debug("Iperf for Module in DL mode detected") ##server side UE - server_filename='iperf_server_' + self.testCase_id + '_' + self.ue_id + '.log' SSH.open(Module_UE.HostIPAddress, Module_UE.HostUsername, Module_UE.HostPassword) cmd = 'rm ' + server_filename SSH.command(cmd,'\$',5) - cmd = 'echo $USER; nohup iperf -s -B ' + UE_IPAddress + ' -u 2>&1 > ' + server_filename + ' &' + cmd = 'echo $USER; nohup iperf -s -B ' + UE_IPAddress + ' -u -i 1 > ' + server_filename + ' 2>&1 &' SSH.command(cmd,'\$',5) SSH.close() ##client side EPC SSH.open(EPC.IPAddress, EPC.UserName, EPC.Password) - client_filename = 'iperf_client_' + self.testCase_id + '_' + self.ue_id + '.log' #remove old client file in EPC.SourceCodePath cmd = 'rm ' + EPC.SourceCodePath + '/' + client_filename SSH.command(cmd,'\$',5) - iperf_cmd = 'bin/iperf -c ' + UE_IPAddress + ' ' + self.iperf_args + ' 2>&1 > ' + client_filename + iperf_cmd = 'bin/iperf -c ' + UE_IPAddress + ' ' + self.iperf_args + ' > ' + client_filename + ' 2>&1' cmd = 'docker exec -w /iperf-2.0.13 -it prod-trf-gen /bin/bash -c \"' + iperf_cmd + '\"' SSH.command(cmd,'\$',int(iperf_time)*5.0) SSH.command('docker cp prod-trf-gen:/iperf-2.0.13/'+ client_filename + ' ' + EPC.SourceCodePath, '\$', 5) @@ -2433,19 +2486,17 @@ class OaiCiTest(): logging.debug("Iperf for Module in UL mode detected") #server side EPC SSH.open(EPC.IPAddress, EPC.UserName, EPC.Password) - server_filename = 'iperf_server_' + self.testCase_id + '_' + self.ue_id + '.log' - iperf_cmd = 'echo $USER; nohup bin/iperf -s -u 2>&1 > ' + server_filename + iperf_cmd = 'echo $USER; nohup bin/iperf -s -u -i 1 > ' + server_filename + ' 2>&1' cmd = 'docker exec -d -w /iperf-2.0.13 prod-trf-gen /bin/bash -c \"' + iperf_cmd + '\"' SSH.command(cmd,'\$',5) SSH.close() #client side UE SSH.open(Module_UE.HostIPAddress, Module_UE.HostUsername, Module_UE.HostPassword) - client_filename = 'iperf_client_' + self.testCase_id + '_' + self.ue_id + '.log' cmd = 'rm '+ client_filename SSH.command(cmd,'\$',5) - SSH.command('iperf -B ' + UE_IPAddress + ' -c ' + trf_gen_IP + ' ' + self.iperf_args + ' 2>&1 > ' + client_filename, '\$', int(iperf_time)*5.0) + SSH.command('iperf -B ' + UE_IPAddress + ' -c ' + trf_gen_IP + ' ' + self.iperf_args + ' > ' + client_filename + ' 2>&1', '\$', int(iperf_time)*5.0) SSH.close() #once client is done, retrieve the server file from container to EPC Host @@ -2461,12 +2512,10 @@ class OaiCiTest(): elif self.iperf_direction=="BIDIR": logging.debug("Iperf for Module in BIDIR mode detected") - server_filename = 'iperf_server_' + self.testCase_id + '_' + self.ue_id + '.log' - client_filename = 'iperf_client_' + self.testCase_id + '_' + self.ue_id + '.log' #server side EPC SSH.open(EPC.IPAddress, EPC.UserName, EPC.Password) - iperf_cmd = 'echo $USER; nohup /usr/local/bin/iperf3 -s 2>&1 > ' + server_filename + iperf_cmd = 'echo $USER; nohup /usr/local/bin/iperf3 -s -i 1 > ' + server_filename + ' 2>&1' cmd = 'docker exec -d -w /iperf-2.0.13 prod-trf-gen /bin/bash -c \"' + iperf_cmd + '\"' SSH.command(cmd,'\$',5) SSH.close() @@ -2475,7 +2524,7 @@ class OaiCiTest(): SSH.open(Module_UE.HostIPAddress, Module_UE.HostUsername, Module_UE.HostPassword) cmd = 'rm '+ client_filename SSH.command(cmd,'\$',5) - SSH.command('iperf3 -B ' + UE_IPAddress + ' -c ' + trf_gen_IP + ' ' + self.iperf_args + ' 2>&1 > ' + client_filename, '\$', int(iperf_time)*5.0) + SSH.command('iperf3 -B ' + UE_IPAddress + ' -c ' + trf_gen_IP + ' ' + self.iperf_args + ' > ' + client_filename + ' 2>&1', '\$', int(iperf_time)*5.0) SSH.close() #once client is done, retrieve the server file from container to EPC Host @@ -2499,8 +2548,6 @@ class OaiCiTest(): else: #default is ltebox - SSH = sshconnection.SSHConnection() - #kill iperf processes before (in case there are still some remaining) SSH.open(Module_UE.HostIPAddress, Module_UE.HostUsername, Module_UE.HostPassword) cmd = 'killall --signal=SIGKILL iperf' @@ -2524,14 +2571,14 @@ class OaiCiTest(): SSH.open(Module_UE.HostIPAddress, Module_UE.HostUsername, Module_UE.HostPassword) cmd = 'rm iperf_server_' + self.testCase_id + '_' + self.ue_id + '.log' SSH.command(cmd,'\$',5) - cmd = 'echo $USER; nohup /opt/iperf-2.0.10/iperf -s -B ' + UE_IPAddress + ' -u 2>&1 > iperf_server_' + self.testCase_id + '_' + self.ue_id + '.log &' + cmd = 'echo $USER; nohup /opt/iperf-2.0.10/iperf -s -B ' + UE_IPAddress + ' -u -i 1 > iperf_server_' + self.testCase_id + '_' + self.ue_id + '.log 2>&1 &' SSH.command(cmd,'\$',5) SSH.close() #client side EPC SSH.open(EPC.IPAddress, EPC.UserName, EPC.Password) cmd = 'rm iperf_client_' + self.testCase_id + '_' + self.ue_id + '.log' SSH.command(cmd,'\$',5) - cmd = 'iperf -c ' + UE_IPAddress + ' ' + self.iperf_args + ' 2>&1 > iperf_client_' + self.testCase_id + '_' + self.ue_id + '.log' + cmd = 'iperf -c ' + UE_IPAddress + ' ' + self.iperf_args + ' > iperf_client_' + self.testCase_id + '_' + self.ue_id + '.log 2>&1' SSH.command(cmd,'\$',int(iperf_time)*5.0) SSH.close() #copy the 2 resulting files locally @@ -2547,7 +2594,7 @@ class OaiCiTest(): SSH.open(EPC.IPAddress, EPC.UserName, EPC.Password) cmd = 'rm iperf_server_' + self.testCase_id + '_' + self.ue_id + '.log' SSH.command(cmd,'\$',5) - cmd = 'echo $USER; nohup iperf -s -u 2>&1 > iperf_server_' + self.testCase_id + '_' + self.ue_id + '.log &' + cmd = 'echo $USER; nohup iperf -s -u -i 1 > iperf_server_' + self.testCase_id + '_' + self.ue_id + '.log 2>&1 &' SSH.command(cmd,'\$',5) SSH.close() @@ -2555,7 +2602,7 @@ class OaiCiTest(): SSH.open(Module_UE.HostIPAddress, Module_UE.HostUsername, Module_UE.HostPassword) cmd = 'rm iperf_client_' + self.testCase_id + '_' + self.ue_id + '.log' SSH.command(cmd,'\$',5) - SSH.command('/opt/iperf-2.0.10/iperf -c 192.172.0.1 ' + self.iperf_args + ' 2>&1 > iperf_client_' + self.testCase_id + '_' + self.ue_id + '.log', '\$', int(iperf_time)*5.0) + SSH.command('/opt/iperf-2.0.10/iperf -c 192.172.0.1 ' + self.iperf_args + ' > iperf_client_' + self.testCase_id + '_' + self.ue_id + '.log 2>&1', '\$', int(iperf_time)*5.0) SSH.close() #copy the 2 resulting files locally @@ -2566,15 +2613,13 @@ class OaiCiTest(): self.Iperf_analyzeV2Server(lock, UE_IPAddress, device_id, statusQueue, self.iperf_args,filename,1) elif self.iperf_direction=="BIDIR": logging.debug("Iperf for Module in BIDIR mode detected") - server_filename = 'iperf_server_' + self.testCase_id + '_' + self.ue_id + '.log' - client_filename = 'iperf_client_' + self.testCase_id + '_' + self.ue_id + '.log' #server side EPC SSH.open(EPC.IPAddress, EPC.UserName, EPC.Password) cmd = 'rm ' + server_filename SSH.command(cmd,'\$',5) - cmd = 'echo $USER; nohup iperf3 -s 2>&1 > '+server_filename+' &' + cmd = 'echo $USER; nohup iperf3 -s -i 1 > '+server_filename+' 2>&1 &' SSH.command(cmd,'\$',5) SSH.close() @@ -2582,7 +2627,7 @@ class OaiCiTest(): SSH.open(Module_UE.HostIPAddress, Module_UE.HostUsername, Module_UE.HostPassword) cmd = 'rm ' + client_filename SSH.command(cmd,'\$',5) - SSH.command('iperf3 -c 192.172.0.1 ' + self.iperf_args + ' 2>&1 > '+client_filename, '\$', int(iperf_time)*5.0) + SSH.command('iperf3 -c 192.172.0.1 ' + self.iperf_args + ' > '+client_filename + ' 2>&1', '\$', int(iperf_time)*5.0) SSH.close() #copy the 2 resulting files locally @@ -2593,6 +2638,7 @@ class OaiCiTest(): else : logging.debug("Incorrect or missing IPERF direction in XML") + #kill iperf processes after to be clean SSH.open(Module_UE.HostIPAddress, Module_UE.HostUsername, Module_UE.HostPassword) cmd = 'killall --signal=SIGKILL iperf' @@ -2606,7 +2652,12 @@ class OaiCiTest(): cmd = 'killall --signal=SIGKILL iperf3' SSH.command(cmd,'\$',5) SSH.close() - return + + # Copying to xNB server for Jenkins artifacting + if (os.path.isfile(server_filename)): + SSH.copyout(RAN.eNBIPAddress, RAN.eNBUserName, RAN.eNBPassword, server_filename, RAN.eNBSourceCodePath + '/cmake_targets/') + if (os.path.isfile(client_filename)): + SSH.copyout(RAN.eNBIPAddress, RAN.eNBUserName, RAN.eNBPassword, client_filename, RAN.eNBSourceCodePath + '/cmake_targets/') def Iperf_common(self, lock, UE_IPAddress, device_id, idx, ue_num, statusQueue,EPC): try: @@ -2804,12 +2855,12 @@ class OaiCiTest(): else: SSH.copyin(self.ADBIPAddress, self.ADBUserName, self.ADBPassword, EPC.SourceCodePath + '/scripts/iperf_server_' + self.testCase_id + '_' + device_id + '.log', '.') # fromdos has to be called on the python executor not on ADB server - cmd = 'fromdos -o iperf_server_' + self.testCase_id + '_' + device_id + '.log 2>&1 > /dev/null' + cmd = 'fromdos -o iperf_server_' + self.testCase_id + '_' + device_id + '.log > /dev/null 2>&1' try: subprocess.run(cmd, shell=True) except: pass - cmd = 'dos2unix -o iperf_server_' + self.testCase_id + '_' + device_id + '.log 2>&1 > /dev/null' + cmd = 'dos2unix -o iperf_server_' + self.testCase_id + '_' + device_id + '.log > /dev/null 2>&1' try: subprocess.run(cmd, shell=True) except: @@ -2995,7 +3046,7 @@ class OaiCiTest(): #special quick and dirty treatment for modules, iperf to be restructured if self.ue_id!="": #is module device_id = Module_UE.ID + "-" + Module_UE.Kind - p = Process(target = self.Iperf_Module ,args = (lock, UE_IPAddress, device_id, i, ue_num, status_queue, EPC, Module_UE,)) + p = Process(target = self.Iperf_Module ,args = (lock, UE_IPAddress, device_id, i, ue_num, status_queue, EPC, Module_UE, RAN, )) else: #legacy code p = Process(target = self.Iperf_common, args = (lock, UE_IPAddress, device_id, i, ue_num, status_queue, EPC, )) p.daemon = True @@ -3156,10 +3207,12 @@ class OaiCiTest(): nrFoundDCI = 0 nrCRCOK = 0 mbms_messages = 0 + nbPduSessAccept = 0 + nbPduDiscard = 0 HTML.htmlUEFailureMsg='' global_status = CONST.ALL_PROCESSES_OK for line in ue_log_file.readlines(): - result = re.search('nr_synchro_time', str(line)) + result = re.search('nr_synchro_time|Starting NR UE soft modem', str(line)) if result is not None: nrUEFlag = True if nrUEFlag: @@ -3172,6 +3225,15 @@ class OaiCiTest(): result = re.search('CRC OK', str(line)) if result is not None: nrCRCOK += 1 + result = re.search('Received PDU Session Establishment Accept', str(line)) + if result is not None: + nbPduSessAccept += 1 + result = re.search('warning: discard PDU, sn out of window', str(line)) + if result is not None: + nbPduDiscard += 1 + result = re.search('--nfapi 5 --node-number 2 --sa', str(line)) + if result is not None: + frequency_found = True result = re.search('Exiting OAI softmodem', str(line)) if result is not None: exitSignalReceived = True @@ -3302,21 +3364,29 @@ class OaiCiTest(): HTML.htmlUEFailureMsg=HTML.htmlUEFailureMsg + statMsg + '\n' if nrUEFlag: if nrDecodeMib > 0: - statMsg = 'UE showed ' + str(nrDecodeMib) + ' MIB decode message(s)' + statMsg = 'UE showed ' + str(nrDecodeMib) + ' "MIB decode" message(s)' logging.debug('\u001B[1;30;43m ' + statMsg + ' \u001B[0m') HTML.htmlUEFailureMsg=HTML.htmlUEFailureMsg + statMsg + '\n' if nrFoundDCI > 0: - statMsg = 'UE showed ' + str(nrFoundDCI) + ' DCI found message(s)' + statMsg = 'UE showed ' + str(nrFoundDCI) + ' "DCI found" message(s)' logging.debug('\u001B[1;30;43m ' + statMsg + ' \u001B[0m') HTML.htmlUEFailureMsg=HTML.htmlUEFailureMsg + statMsg + '\n' if nrCRCOK > 0: - statMsg = 'UE showed ' + str(nrCRCOK) + ' PDSCH decoding message(s)' + statMsg = 'UE showed ' + str(nrCRCOK) + ' "PDSCH decoding" message(s)' logging.debug('\u001B[1;30;43m ' + statMsg + ' \u001B[0m') HTML.htmlUEFailureMsg=HTML.htmlUEFailureMsg + statMsg + '\n' if not frequency_found: statMsg = 'NR-UE could NOT synch!' logging.error('\u001B[1;30;43m ' + statMsg + ' \u001B[0m') HTML.htmlUEFailureMsg=HTML.htmlUEFailureMsg + statMsg + '\n' + if nbPduSessAccept > 0: + statMsg = 'UE showed ' + str(nbPduSessAccept) + ' "Received PDU Session Establishment Accept" message(s)' + logging.debug('\u001B[1;30;43m ' + statMsg + ' \u001B[0m') + HTML.htmlUEFailureMsg=HTML.htmlUEFailureMsg + statMsg + '\n' + if nbPduDiscard > 0: + statMsg = 'UE showed ' + str(nbPduDiscard) + ' "warning: discard PDU, sn out of window" message(s)' + logging.debug('\u001B[1;30;43m ' + statMsg + ' \u001B[0m') + HTML.htmlUEFailureMsg=HTML.htmlUEFailureMsg + statMsg + '\n' if uciStatMsgCount > 0: statMsg = 'UE showed ' + str(uciStatMsgCount) + ' "uci->stat" message(s)' logging.debug('\u001B[1;30;43m ' + statMsg + ' \u001B[0m') @@ -3447,16 +3517,23 @@ class OaiCiTest(): job.join() HTML.CreateHtmlTestRow('N/A', 'OK', CONST.ALL_PROCESSES_OK) else: #if an ID is specified, it is a module from the yaml infrastructure file - Module_UE = cls_module_ue.Module_UE(InfraUE.ci_ue_infra[self.ue_id]) - Module_UE.ue_trace=ue_trace - Module_UE.Command("detach") - Module_UE.DisableTrace() - Module_UE.DisableCM() - archive_destination=Module_UE.LogCollect() - if Module_UE.ue_trace=='yes': - HTML.CreateHtmlTestRow('QLog at : '+archive_destination, 'OK', CONST.ALL_PROCESSES_OK) + ue_kind = InfraUE.ci_ue_infra[self.ue_id]['Kind'] + logging.debug("Detected UE Kind : " + ue_kind) + if ue_kind == 'quectel': + Module_UE = cls_module_ue.Module_UE(InfraUE.ci_ue_infra[self.ue_id]) + Module_UE.ue_trace=ue_trace + Module_UE.Command("detach") + Module_UE.DisableTrace() + Module_UE.DisableCM() + archive_destination=Module_UE.LogCollect() + if Module_UE.ue_trace=='yes': + HTML.CreateHtmlTestRow('QLog at : '+archive_destination, 'OK', CONST.ALL_PROCESSES_OK) + else: + HTML.CreateHtmlTestRow('QLog trace is disabled', 'OK', CONST.ALL_PROCESSES_OK) + elif ue_kind == 'amarisoft': + HTML.CreateHtmlTestRow('AS UE is already terminated', 'OK', CONST.ALL_PROCESSES_OK) else: - HTML.CreateHtmlTestRow('QLog trace is disabled', 'OK', CONST.ALL_PROCESSES_OK) + logging.debug("Incorrect UE Kind was detected") def TerminateOAIUE(self,HTML,RAN,COTS_UE,EPC,InfraUE,CONTAINERS): SSH = sshconnection.SSHConnection() diff --git a/ci-scripts/cls_physim.py b/ci-scripts/cls_physim.py index 33792f6ca4..0342333c06 100644 --- a/ci-scripts/cls_physim.py +++ b/ci-scripts/cls_physim.py @@ -32,7 +32,7 @@ import logging #to create a SSH object locally in the methods import sshconnection #to update the HTML object -import html +import cls_oai_html from multiprocessing import SimpleQueue #for log folder maintenance import os @@ -168,7 +168,7 @@ class PhySim: mySSH.close() #check build status and update HTML object - lHTML = html.HTMLManagement() + lHTML = cls_oai_html.HTMLManagement() lHTML=self.__CheckBuild_PhySim(htmlObj,constObj) return lHTML @@ -186,6 +186,6 @@ class PhySim: mySSH.command(self.__workSpacePath+'ran_build/build/ldpctest ' + self.runargs + ' >> '+self.__runLogFile, '\$', 30) mySSH.close() #return updated HTML to main - lHTML = html.HTMLManagement() + lHTML = cls_oai_html.HTMLManagement() lHTML=self.__CheckResults_PhySim(htmlObj,constObj,testcase_id) return lHTML diff --git a/ci-scripts/cls_physim1.py b/ci-scripts/cls_physim1.py index 83fb74b7cb..3907fc2a34 100644 --- a/ci-scripts/cls_physim1.py +++ b/ci-scripts/cls_physim1.py @@ -33,7 +33,7 @@ #----------------------------------------------------------- import logging import sshconnection as SSH -import html +import cls_oai_html import os import re import time @@ -153,6 +153,7 @@ class PhySim: mySSH.command(f'oc project {ocProjectName}', '\$', 30) if mySSH.getBefore().count(f'Already on project "{ocProjectName}"') == 0 and mySSH.getBefore().count(f'Now using project "{self.OCProjectName}"') == 0: logging.error(f'\u001B[1m Unable to access OC project {ocProjectName}\u001B[0m') + mySSH.command('oc logout', '\$', 30) mySSH.close() HTML.CreateHtmlTestRow('N/A', 'KO', CONST.OC_PROJECT_FAIL) RAN.prematureExit = True @@ -161,9 +162,10 @@ class PhySim: logging.debug(f'\u001B[1m Now using project {ocProjectName}\u001B[0m') # Tag the image and push to the OC cluster - mySSH.command('oc whoami -t | sudo podman login -u ' + ocUserName + ' --password-stdin https://default-route-openshift-image-registry.apps.5glab.nsa.eurecom.fr/ --tls-verify=false', '\$', 30) + mySSH.command('oc whoami -t | sudo podman login -u ' + ocUserName + ' --password-stdin https://default-route-openshift-image-registry.apps.oai.cs.eurecom.fr/ --tls-verify=false', '\$', 30) if mySSH.getBefore().count('Login Succeeded!') == 0: logging.error('\u001B[1m Podman Login to OC Cluster Registry Failed\u001B[0m') + mySSH.command('oc logout', '\$', 30) mySSH.close() HTML.CreateHtmlTestRow('N/A', 'KO', CONST.OC_LOGIN_FAIL) RAN.prematureExit = True @@ -171,9 +173,11 @@ class PhySim: else: logging.debug('\u001B[1m Podman Login to OC Cluster Registry Successfully\u001B[0m') time.sleep(2) - mySSH.command('oc create -f openshift/oai-physim-image-stream.yml', '\$', 30) + mySSH.command('oc create -f openshift/oai-physim-image-stream.yml || true', '\$', 30) if mySSH.getBefore().count('(AlreadyExists):') == 0 and mySSH.getBefore().count('created') == 0: logging.error(f'\u001B[1m Image Stream "oai-physim" Creation Failed on OC Cluster {ocProjectName}\u001B[0m') + mySSH.command('sudo podman logout https://default-route-openshift-image-registry.apps.oai.cs.eurecom.fr/', '\$', 6) + mySSH.command('oc logout', '\$', 30) mySSH.close() HTML.CreateHtmlTestRow('N/A', 'KO', CONST.OC_IS_FAIL) RAN.prematureExit = True @@ -181,11 +185,13 @@ class PhySim: else: logging.debug(f'\u001B[1m Image Stream "oai-physim" created on OC project {ocProjectName}\u001B[0m') time.sleep(2) - mySSH.command(f'sudo podman tag oai-physim:{imageTag} default-route-openshift-image-registry.apps.5glab.nsa.eurecom.fr/{self.OCProjectName}/oai-physim:{imageTag}', '\$', 30) + mySSH.command(f'sudo podman tag oai-physim:{imageTag} default-route-openshift-image-registry.apps.oai.cs.eurecom.fr/{self.OCProjectName}/oai-physim:{imageTag}', '\$', 30) time.sleep(2) - mySSH.command(f'sudo podman push default-route-openshift-image-registry.apps.5glab.nsa.eurecom.fr/{self.OCProjectName}/oai-physim:{imageTag} --tls-verify=false', '\$', 180) + mySSH.command(f'sudo podman push default-route-openshift-image-registry.apps.oai.cs.eurecom.fr/{self.OCProjectName}/oai-physim:{imageTag} --tls-verify=false', '\$', 180) if mySSH.getBefore().count('Storing signatures') == 0: logging.error('\u001B[1m Image "oai-physim" push to OC Cluster Registry Failed\u001B[0m') + mySSH.command('sudo podman logout https://default-route-openshift-image-registry.apps.oai.cs.eurecom.fr/', '\$', 6) + mySSH.command('oc logout', '\$', 30) mySSH.close() HTML.CreateHtmlTestRow('N/A', 'KO', CONST.OC_IS_FAIL) RAN.prematureExit = True @@ -195,8 +201,9 @@ class PhySim: # Using helm charts deployment time.sleep(5) + mySSH.command(f'grep -rl OAICICD_PROJECT ./charts/ | xargs sed -i -e "s#OAICICD_PROJECT#{ocProjectName}#"', '\$', 30) mySSH.command(f'sed -i -e "s#TAG#{imageTag}#g" ./charts/physims/values.yaml', '\$', 6) - mySSH.command('helm install physim ./charts/physims/ | tee -a cmake_targets/log/physim_helm_summary.txt 2>&1', '\$', 30) + mySSH.command('helm install physim ./charts/physims/ 2>&1 | tee -a cmake_targets/log/physim_helm_summary.txt', '\$', 30) if mySSH.getBefore().count('STATUS: deployed') == 0: logging.error('\u001B[1m Deploying PhySim Failed using helm chart on OC Cluster\u001B[0m') mySSH.command('helm uninstall physim >> cmake_targets/log/physim_helm_summary.txt 2>&1', '\$', 30) @@ -206,8 +213,10 @@ class PhySim: mySSH.command('oc get pods -l app.kubernetes.io/instance=physim', '\$', 6, resync=True) if re.search('No resources found', mySSH.getBefore()): isFinished1 = True - mySSH.command(f'sudo podman rmi default-route-openshift-image-registry.apps.5glab.nsa.eurecom.fr/{self.OCProjectName}/oai-physim:{imageTag}', '\$', 30) + mySSH.command(f'sudo podman rmi default-route-openshift-image-registry.apps.oai.cs.eurecom.fr/{self.OCProjectName}/oai-physim:{imageTag}', '\$', 30) mySSH.command('oc delete is oai-physim', '\$', 30) + mySSH.command('sudo podman logout https://default-route-openshift-image-registry.apps.oai.cs.eurecom.fr/', '\$', 6) + mySSH.command('oc logout', '\$', 30) mySSH.close() self.AnalyzeLogFile_phySim(HTML) RAN.prematureExit = True @@ -227,7 +236,7 @@ class PhySim: if isRunning == False: logging.error('\u001B[1m Some PODS Running FAILED \u001B[0m') mySSH.command('oc get pods -l app.kubernetes.io/instance=physim 2>&1 | tee -a cmake_targets/log/physim_pods_summary.txt', '\$', 6) - mySSH.command('helm uninstall physim >> cmake_targets/log/physim_helm_summary.txt 2>&1', '\$', 6) + mySSH.command('helm uninstall physim 2>&1 >> cmake_targets/log/physim_helm_summary.txt', '\$', 6) self.AnalyzeLogFile_phySim(HTML) isFinished1 = False while(isFinished1 == False): @@ -235,8 +244,10 @@ class PhySim: mySSH.command('oc get pods -l app.kubernetes.io/instance=physim', '\$', 6, resync=True) if re.search('No resources found', mySSH.getBefore()): isFinished1 = True - mySSH.command(f'sudo podman rmi default-route-openshift-image-registry.apps.5glab.nsa.eurecom.fr/{self.OCProjectName}/oai-physim:{imageTag}', '\$', 6) + mySSH.command(f'sudo podman rmi default-route-openshift-image-registry.apps.oai.cs.eurecom.fr/{self.OCProjectName}/oai-physim:{imageTag}', '\$', 6) mySSH.command('oc delete is oai-physim', '\$', 6) + mySSH.command('sudo podman logout https://default-route-openshift-image-registry.apps.oai.cs.eurecom.fr/', '\$', 6) + mySSH.command('oc logout', '\$', 30) HTML.CreateHtmlTestRow('N/A', 'KO', CONST.OC_PHYSIM_DEPLOY_FAIL) HTML.CreateHtmlTestRowPhySimTestResult(self.testSummary,self.testResult) RAN.prematureExit = True @@ -293,9 +304,10 @@ class PhySim: isFinished1 = True if isFinished1 == True: logging.debug('\u001B[1m UnDeployed PhySim Successfully on OC Cluster\u001B[0m') - mySSH.command(f'sudo podman rmi default-route-openshift-image-registry.apps.5glab.nsa.eurecom.fr/{self.OCProjectName}/oai-physim:{imageTag}', '\$', 6) + mySSH.command(f'sudo podman rmi default-route-openshift-image-registry.apps.oai.cs.eurecom.fr/{self.OCProjectName}/oai-physim:{imageTag}', '\$', 6) mySSH.command('oc delete is oai-physim', '\$', 6) logging.debug('\u001B[1m Deleted the Image and ImageStream\u001B[0m') + mySSH.command('sudo podman logout https://default-route-openshift-image-registry.apps.oai.cs.eurecom.fr/', '\$', 6) mySSH.command('oc logout', '\$', 6) mySSH.close() self.AnalyzeLogFile_phySim(HTML) diff --git a/ci-scripts/cls_static_code_analysis.py b/ci-scripts/cls_static_code_analysis.py index c899a9aabd..5b45b48ba6 100644 --- a/ci-scripts/cls_static_code_analysis.py +++ b/ci-scripts/cls_static_code_analysis.py @@ -35,7 +35,9 @@ import sys # arg import re # reg import logging import os +from pathlib import Path import time +from multiprocessing import Process, Lock, SimpleQueue #----------------------------------------------------------- # OAI Testing modules @@ -51,7 +53,7 @@ class CppCheckResults(): def __init__(self): - self.variants = ['xenial', 'bionic'] + self.variants = ['bionic', 'focal'] self.versions = ['',''] self.nbErrors = [0,0] self.nbWarnings = [0,0] @@ -116,12 +118,22 @@ class StaticCodeAnalysis(): # 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 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"', '\$', 5) + else: + logging.debug('Merging with the target branch: ' + self.ranTargetBranch) + mySSH.command('git merge --ff origin/' + self.ranTargetBranch + ' -m "Temporary merge for CI"', '\$', 5) - mySSH.command('docker image rm oai-cppcheck:bionic oai-cppcheck:xenial || true', '\$', 60) - mySSH.command('docker build --tag oai-cppcheck:xenial --file ci-scripts/docker/Dockerfile.cppcheck.xenial . > cmake_targets/log/cppcheck-xenial.txt 2>&1', '\$', 600) + mySSH.command('docker image rm oai-cppcheck:bionic oai-cppcheck:focal || true', '\$', 60) mySSH.command('sed -e "s@xenial@bionic@" ci-scripts/docker/Dockerfile.cppcheck.xenial > ci-scripts/docker/Dockerfile.cppcheck.bionic', '\$', 6) mySSH.command('docker build --tag oai-cppcheck:bionic --file ci-scripts/docker/Dockerfile.cppcheck.bionic . > cmake_targets/log/cppcheck-bionic.txt 2>&1', '\$', 600) - mySSH.command('docker image rm oai-cppcheck:bionic oai-cppcheck:xenial || true', '\$', 30) + mySSH.command('sed -e "s@xenial@focal@" ci-scripts/docker/Dockerfile.cppcheck.xenial > ci-scripts/docker/Dockerfile.cppcheck.focal', '\$', 6) + mySSH.command('docker build --tag oai-cppcheck:focal --file ci-scripts/docker/Dockerfile.cppcheck.focal . > cmake_targets/log/cppcheck-focal.txt 2>&1', '\$', 600) + mySSH.command('docker image rm oai-cppcheck:bionic oai-cppcheck:focal || true', '\$', 30) # Analyzing the logs mySSH.command('cd ' + lSourcePath + '/cmake_targets', '\$', 5) @@ -131,8 +143,22 @@ class StaticCodeAnalysis(): mySSH.copyin(lIpAddr, lUserName, lPassWord, lSourcePath + '/cmake_targets/build_log_' + self.testCase_id + '/*', '.') CCR = CppCheckResults() + CCR_ref = CppCheckResults() vId = 0 for variant in CCR.variants: + refAvailable = False + if self.ranAllowMerge: + refFolder = str(Path.home()) + '/cppcheck-references' + if (os.path.isfile(refFolder + '/cppcheck-'+ variant + '.txt')): + refAvailable = True + with open(refFolder + '/cppcheck-'+ variant + '.txt', 'r') as refFile: + for line in refFile: + ret = re.search(' (?P[0-9\.]+) errors', str(line)) + if ret is not None: + CCR_ref.nbErrors[vId] = int(ret.group('nb_errors')) + ret = re.search(' (?P[0-9\.]+) warnings', str(line)) + if ret is not None: + CCR_ref.nbWarnings[vId] = int(ret.group('nb_warnings')) if (os.path.isfile('./cppcheck-'+ variant + '.txt')): xmlStart = False with open('./cppcheck-'+ variant + '.txt', 'r') as logfile: @@ -167,21 +193,43 @@ class StaticCodeAnalysis(): CCR.nbPtrAddNotNull[vId] += 1 if re.search('id="oppositeInnerCondition"', str(line)) is not None: CCR.nbOppoInnerCondition[vId] += 1 - logging.debug('======== Variant ' + variant + ' - ' + CCR.versions[vId] + ' ========') - logging.debug(' ' + str(CCR.nbErrors[vId]) + ' errors') - logging.debug(' ' + str(CCR.nbWarnings[vId]) + ' warnings') - logging.debug(' -- Details --') - logging.debug(' Memory leak: ' + str(CCR.nbMemLeaks[vId])) - logging.debug(' Possible null pointer deference: ' + str(CCR.nbNullPtrs[vId])) - logging.debug(' Uninitialized variable: ' + str(CCR.nbUninitVars[vId])) - logging.debug(' Undefined behaviour shifting: ' + str(CCR.nbTooManyBitsShift[vId])) - logging.debug(' Signed integer overflow: ' + str(CCR.nbIntegerOverflow[vId])) - logging.debug('') - logging.debug(' Printf formatting issue: ' + str(CCR.nbInvalidPrintf[vId])) - logging.debug(' Modulo result is predetermined: ' + str(CCR.nbModuloAlways[vId])) - logging.debug(' Opposite Condition -> dead code: ' + str(CCR.nbOppoInnerCondition[vId])) - logging.debug(' Wrong Scanf Nb Args: ' + str(CCR.nbWrongScanfArg[vId])) - logging.debug('') + vMsg = '' + vMsg += '======== Variant ' + variant + ' - ' + CCR.versions[vId] + ' ========\n' + vMsg += ' ' + str(CCR.nbErrors[vId]) + ' errors\n' + vMsg += ' ' + str(CCR.nbWarnings[vId]) + ' warnings\n' + vMsg += ' -- Details --\n' + vMsg += ' Memory leak: ' + str(CCR.nbMemLeaks[vId]) + '\n' + vMsg += ' Possible null pointer deference: ' + str(CCR.nbNullPtrs[vId]) + '\n' + vMsg += ' Uninitialized variable: ' + str(CCR.nbUninitVars[vId]) + '\n' + vMsg += ' Undefined behaviour shifting: ' + str(CCR.nbTooManyBitsShift[vId]) + '\n' + vMsg += ' Signed integer overflow: ' + str(CCR.nbIntegerOverflow[vId]) + '\n' + vMsg += '\n' + vMsg += ' Printf formatting issue: ' + str(CCR.nbInvalidPrintf[vId]) + '\n' + vMsg += ' Modulo result is predetermined: ' + str(CCR.nbModuloAlways[vId]) + '\n' + vMsg += ' Opposite Condition -> dead code: ' + str(CCR.nbOppoInnerCondition[vId]) + '\n' + vMsg += ' Wrong Scanf Nb Args: ' + str(CCR.nbWrongScanfArg[vId]) + '\n' + for vLine in vMsg.split('\n'): + logging.debug(vLine) + if self.ranAllowMerge and refAvailable: + if CCR_ref.nbErrors[vId] == CCR.nbErrors[vId]: + logging.debug(' No change in number of errors') + elif CCR_ref.nbErrors[vId] > CCR.nbErrors[vId]: + logging.debug(' Good! Decrease in number of errors') + else: + logging.debug(' Bad! increase in number of errors') + if CCR_ref.nbWarnings[vId] == CCR.nbWarnings[vId]: + logging.debug(' No change in number of warnings') + elif CCR_ref.nbWarnings[vId] > CCR.nbWarnings[vId]: + logging.debug(' Good! Decrease in number of warnings') + else: + logging.debug(' Bad! increase in number of warnings') + # Create new reference file + if not self.ranAllowMerge: + refFolder = str(Path.home()) + '/cppcheck-references' + if not os.path.isdir(refFolder): + os.mkdir(refFolder) + with open(refFolder + '/cppcheck-'+ variant + '.txt', 'w') as refFile: + refFile.write(vMsg) vId += 1 HTML.CreateHtmlTestRow('N/A', 'OK', CONST.ALL_PROCESSES_OK) @@ -190,3 +238,205 @@ class StaticCodeAnalysis(): return 0 + def LicenceAndFormattingCheck(self, HTML): + if self.ranRepository == '' or self.ranBranch == '' or self.ranCommitID == '': + HELP.GenericHelp(CONST.Version) + sys.exit('Insufficient Parameter') + lIpAddr = self.eNBIPAddress + lUserName = self.eNBUserName + lPassWord = self.eNBPassword + lSourcePath = self.eNBSourceCodePath + + if lIpAddr == '' or lUserName == '' or lPassWord == '' or lSourcePath == '': + HELP.GenericHelp(CONST.Version) + sys.exit('Insufficient Parameter') + logging.debug('Building on server: ' + lIpAddr) + mySSH = SSH.SSHConnection() + mySSH.open(lIpAddr, lUserName, lPassWord) + + self.testCase_id = HTML.testCase_id + + # on RedHat/CentOS .git extension is mandatory + result = re.search('([a-zA-Z0-9\:\-\.\/])+\.git', self.ranRepository) + if result is not None: + full_ran_repo_name = self.ranRepository.replace('git/', 'git') + else: + full_ran_repo_name = self.ranRepository + '.git' + mySSH.command('mkdir -p ' + lSourcePath, '\$', 5) + mySSH.command('cd ' + lSourcePath, '\$', 5) + mySSH.command('if [ ! -e .git ]; then stdbuf -o0 git clone ' + full_ran_repo_name + ' .; else stdbuf -o0 git fetch --prune; fi', '\$', 600) + # Raphael: here add a check if git clone or git fetch went smoothly + mySSH.command('git config user.email "jenkins@openairinterface.org"', '\$', 5) + mySSH.command('git config user.name "OAI Jenkins"', '\$', 5) + + mySSH.command('echo ' + lPassWord + ' | sudo -S git clean -x -d -ff', '\$', 30) + mySSH.command('mkdir -p cmake_targets/log', '\$', 5) + # 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 already been checked earlier + argToPass = '' + if (self.ranAllowMerge): + argToPass = '--build-arg MERGE_REQUEST=true --build-arg SRC_BRANCH=' + self.ranBranch + if self.ranTargetBranch == '': + if (self.ranBranch != 'develop') and (self.ranBranch != 'origin/develop'): + mySSH.command('git merge --ff origin/develop -m "Temporary merge for CI"', '\$', 5) + argToPass += ' --build-arg TARGET_BRANCH=develop ' + else: + logging.debug('Merging with the target branch: ' + self.ranTargetBranch) + mySSH.command('git merge --ff origin/' + self.ranTargetBranch + ' -m "Temporary merge for CI"', '\$', 5) + argToPass += ' --build-arg TARGET_BRANCH=' + self.ranTargetBranch + ' ' + + mySSH.command('docker image rm oai-formatting-check:latest || true', '\$', 60) + mySSH.command('docker build --target oai-formatting-check --tag oai-formatting-check:latest ' + argToPass + '--file ci-scripts/docker/Dockerfile.formatting.bionic . > cmake_targets/log/oai-formatting-check.txt 2>&1', '\$', 600) + + mySSH.command('docker image rm oai-formatting-check:latest || true', '\$', 60) + mySSH.command('docker image prune --force', '\$', 60) + mySSH.command('docker volume prune --force', '\$', 60) + + # Analyzing the logs + mySSH.command('cd ' + lSourcePath + '/cmake_targets', '\$', 5) + mySSH.command('mkdir -p build_log_' + self.testCase_id, '\$', 5) + mySSH.command('mv log/* ' + 'build_log_' + self.testCase_id, '\$', 5) + mySSH.close() + + mySSH.copyin(lIpAddr, lUserName, lPassWord, lSourcePath + '/cmake_targets/build_log_' + self.testCase_id + '/*', '.') + + finalStatus = 0 + if (os.path.isfile('./oai-formatting-check.txt')): + analyzed = False + nbFilesNotFormatted = 0 + listFiles = False + listFilesNotFormatted = [] + circularHeaderDependency = False + circularHeaderDependencyFiles = [] + gnuGplLicence = False + gnuGplLicenceFiles = [] + suspectLicence = False + suspectLicenceFiles = [] + with open('./oai-formatting-check.txt', 'r') as logfile: + for line in logfile: + ret = re.search('./ci-scripts/checkCodingFormattingRules.sh', str(line)) + if ret is not None: + analyzed = True + if analyzed: + ret = re.search('Nb Files that do NOT follow OAI rules: (?P[0-9\.]+)', str(line)) + if ret is not None: + nbFilesNotFormatted = int(ret.group('nb_errors')) + + if re.search('=== Files not properly formatted ===', str(line)) is not None: + listFiles = True + if listFiles: + if re.search('Removing intermediate container', str(line)) is not None: + listFiles = False + elif re.search('Running in|Files not properly formatted', str(line)) is not None: + pass + else: + listFilesNotFormatted.append(str(line).strip()) + + if re.search('=== Files with incorrect define protection ===', str(line)) is not None: + circularHeaderDependency = True + if circularHeaderDependency: + if re.search('Removing intermediate container', str(line)) is not None: + circularHeaderDependency = False + elif re.search('Running in|Files with incorrect define protection', str(line)) is not None: + pass + else: + circularHeaderDependencyFiles.append(str(line).strip()) + + if re.search('=== Files with a GNU GPL licence Banner ===', str(line)) is not None: + gnuGplLicence = True + if gnuGplLicence: + if re.search('Removing intermediate container', str(line)) is not None: + gnuGplLicence = False + elif re.search('Running in|Files with a GNU GPL licence Banner', str(line)) is not None: + pass + else: + gnuGplLicenceFiles.append(str(line).strip()) + + if re.search('=== Files with a suspect Banner ===', str(line)) is not None: + suspectLicence = True + if suspectLicence: + if re.search('Removing intermediate container', str(line)) is not None: + suspectLicence = False + elif re.search('Running in|Files with a suspect Banner', str(line)) is not None: + pass + else: + suspectLicenceFiles.append(str(line).strip()) + + logfile.close() + if analyzed: + logging.debug('files not formatted properly: ' + str(nbFilesNotFormatted)) + if nbFilesNotFormatted == 0: + HTML.CreateHtmlTestRow('File(s) Format', 'OK', CONST.ALL_PROCESSES_OK) + else: + html_queue = SimpleQueue() + html_cell = '
\n'
+					html_cell += 'Number of files not following OAI Rules: ' + str(nbFilesNotFormatted) + '\n'
+					for nFile in listFilesNotFormatted:
+						html_cell += str(nFile).strip() + '\n'
+					html_cell += '
' + html_queue.put(html_cell) + HTML.CreateHtmlTestRowQueue('File(s) Format', 'KO', 1, html_queue) + del(html_cell) + del(html_queue) + + logging.debug('header files not respecting the circular dependency protection: ' + str(len(circularHeaderDependencyFiles))) + if len(circularHeaderDependencyFiles) == 0: + HTML.CreateHtmlTestRow('Header Circular Dependency', 'OK', CONST.ALL_PROCESSES_OK) + else: + html_queue = SimpleQueue() + html_cell = '
\n'
+					html_cell += 'Number of files not respecting: ' + str(len(circularHeaderDependencyFiles)) + '\n'
+					for nFile in circularHeaderDependencyFiles:
+						html_cell += str(nFile).strip() + '\n'
+					html_cell += '
' + html_queue.put(html_cell) + HTML.CreateHtmlTestRowQueue('Header Circular Dependency', 'KO', 1, html_queue) + del(html_cell) + del(html_queue) + finalStatus = -1 + + logging.debug('files with a GNU GPL license: ' + str(len(gnuGplLicenceFiles))) + if len(gnuGplLicenceFiles) == 0: + HTML.CreateHtmlTestRow('Files w/ GNU GPL License', 'OK', CONST.ALL_PROCESSES_OK) + else: + html_queue = SimpleQueue() + html_cell = '
\n'
+					html_cell += 'Number of files not respecting: ' + str(len(gnuGplLicenceFiles)) + '\n'
+					for nFile in gnuGplLicenceFiles:
+						html_cell += str(nFile).strip() + '\n'
+					html_cell += '
' + html_queue.put(html_cell) + HTML.CreateHtmlTestRowQueue('Files w/ GNU GPL License', 'KO', 1, html_queue) + del(html_cell) + del(html_queue) + finalStatus = -1 + + logging.debug('files with a suspect license: ' + str(len(suspectLicenceFiles))) + if len(suspectLicenceFiles) == 0: + HTML.CreateHtmlTestRow('Files with suspect license', 'OK', CONST.ALL_PROCESSES_OK) + else: + html_queue = SimpleQueue() + html_cell = '
\n'
+					html_cell += 'Number of files not respecting: ' + str(len(suspectLicenceFiles)) + '\n'
+					for nFile in suspectLicenceFiles:
+						html_cell += str(nFile).strip() + '\n'
+					html_cell += '
' + html_queue.put(html_cell) + HTML.CreateHtmlTestRowQueue('Files with suspect license', 'KO', 1, html_queue) + del(html_cell) + del(html_queue) + finalStatus = -1 + + else: + finalStatus = -1 + HTML.htmleNBFailureMsg = 'Could not fully analyze oai-formatting-check.txt file' + HTML.CreateHtmlTestRow('N/A', 'KO', CONST.ENB_PROCESS_NOLOGFILE_TO_ANALYZE) + else: + finalStatus = -1 + HTML.htmleNBFailureMsg = 'Could not access oai-formatting-check.txt file' + HTML.CreateHtmlTestRow('N/A', 'KO', CONST.ENB_PROCESS_NOLOGFILE_TO_ANALYZE) + + return finalStatus diff --git a/ci-scripts/conf_files/benetel-5g.conf b/ci-scripts/conf_files/benetel-5g.conf index bfe61188b6..8f3b03fddc 100644 --- a/ci-scripts/conf_files/benetel-5g.conf +++ b/ci-scripts/conf_files/benetel-5g.conf @@ -22,9 +22,7 @@ gNBs = ////////// Physical parameters: ssb_SubcarrierOffset = 31; //0; - pdsch_AntennaPorts = 1; - pusch_AntennaPorts = 1; - + servingCellConfigCommon = ( { #spCellConfigCommon diff --git a/ci-scripts/conf_files/enb.band38.lte_2x2.100PRB.usrpn310.conf b/ci-scripts/conf_files/enb.band38.lte_2x2.100PRB.usrpn310.conf index 24c35dedbf..a7100a97e3 100644 --- a/ci-scripts/conf_files/enb.band38.lte_2x2.100PRB.usrpn310.conf +++ b/ci-scripts/conf_files/enb.band38.lte_2x2.100PRB.usrpn310.conf @@ -211,8 +211,8 @@ MACRLCs = ( bler_target_upper = 20.0; bler_target_lower = 10.0; max_ul_rb_index = 27; - puSch10xSnr = 200; - puCch10xSnr = 150; + puSch10xSnr = 190; + puCch10xSnr = 160; } ); @@ -231,13 +231,13 @@ RUs = ( local_rf = "yes" nb_tx = 2 nb_rx = 2 - att_tx = 0 - att_rx = 0; + att_tx = 10 + att_rx = 5; bands = [38]; max_pdschReferenceSignalPower = -27; max_rxgain = 75; eNB_instances = [0]; - sdr_addrs = "mgmt_addr=192.168.18.241,addr=192.168.20.2,second_addr=192.168.10.2"; + sdr_addrs = "mgmt_addr=172.21.19.13,addr=192.168.20.2,second_addr=192.168.10.2"; } ); diff --git a/ci-scripts/conf_files/enb.band38.lte_2x2_tm2.100PRB.usrpn310.conf b/ci-scripts/conf_files/enb.band38.lte_2x2_tm2.100PRB.usrpn310.conf index 4a16a64105..1f358c1571 100644 --- a/ci-scripts/conf_files/enb.band38.lte_2x2_tm2.100PRB.usrpn310.conf +++ b/ci-scripts/conf_files/enb.band38.lte_2x2_tm2.100PRB.usrpn310.conf @@ -211,8 +211,8 @@ MACRLCs = ( bler_target_upper = 20.0; bler_target_lower = 10.0; max_ul_rb_index = 27; - puSch10xSnr = 200; - puCch10xSnr = 150; + puSch10xSnr = 190; + puCch10xSnr = 160; } ); @@ -231,13 +231,13 @@ RUs = ( local_rf = "yes" nb_tx = 2 nb_rx = 2 - att_tx = 0 - att_rx = 0; + att_tx = 10 + att_rx = 5; bands = [38]; max_pdschReferenceSignalPower = -27; max_rxgain = 75; eNB_instances = [0]; - sdr_addrs = "mgmt_addr=192.168.18.241,addr=192.168.20.2,second_addr=192.168.10.2"; + sdr_addrs = "mgmt_addr=172.21.19.13,addr=192.168.20.2,second_addr=192.168.10.2"; } ); diff --git a/ci-scripts/conf_files/enb.band38.nsa_2x2.100PRB.usrpn310.conf b/ci-scripts/conf_files/enb.band38.nsa_2x2.100PRB.usrpn310.conf index bccd37abe9..f7088aee52 100644 --- a/ci-scripts/conf_files/enb.band38.nsa_2x2.100PRB.usrpn310.conf +++ b/ci-scripts/conf_files/enb.band38.nsa_2x2.100PRB.usrpn310.conf @@ -211,8 +211,8 @@ MACRLCs = ( bler_target_upper = 20.0; bler_target_lower = 10.0; max_ul_rb_index = 27; - puSch10xSnr = 200; - puCch10xSnr = 150; + puSch10xSnr = 190; + puCch10xSnr = 160; } ); @@ -231,13 +231,13 @@ RUs = ( local_rf = "yes" nb_tx = 2 nb_rx = 2 - att_tx = 0 - att_rx = 0; + att_tx = 10 + att_rx = 5; bands = [38]; max_pdschReferenceSignalPower = -27; max_rxgain = 75; eNB_instances = [0]; - sdr_addrs = "mgmt_addr=192.168.18.241,addr=192.168.20.2,second_addr=192.168.10.2"; + sdr_addrs = "mgmt_addr=172.21.19.13,addr=192.168.20.2,second_addr=192.168.10.2"; } ); diff --git a/ci-scripts/conf_files/episci/episci_gnb.band78.sa.fr1.106PRB.usrpn310.conf b/ci-scripts/conf_files/episci/episci_gnb.band78.sa.fr1.106PRB.usrpn310.conf index a98179197f..51ffb1d5cd 100644 --- a/ci-scripts/conf_files/episci/episci_gnb.band78.sa.fr1.106PRB.usrpn310.conf +++ b/ci-scripts/conf_files/episci/episci_gnb.band78.sa.fr1.106PRB.usrpn310.conf @@ -33,9 +33,6 @@ gNBs = ////////// Physical parameters: ssb_SubcarrierOffset = 0; - pdsch_AntennaPorts = 1; - pusch_AntennaPorts = 1; - ul_prbblacklist = "51,52,53,54" min_rxtxtime = 6; pdcch_ConfigSIB1 = ( { @@ -73,15 +70,6 @@ gNBs = #pdcch-ConfigCommon initialDLBWPcontrolResourceSetZero = 12; initialDLBWPsearchSpaceZero = 0; - #pdsch-ConfigCommon - #pdschTimeDomainAllocationList (up to 16 entries) - initialDLBWPk0_0 = 0; #for DL slot - initialDLBWPmappingType_0 = 0; #0=typeA,1=typeB - initialDLBWPstartSymbolAndLength_0 = 40; #this is SS=1,L=13 - - initialDLBWPk0_1 = 0; #for mixed slot - initialDLBWPmappingType_1 = 0; - initialDLBWPstartSymbolAndLength_1 = 57; #this is SS=1,L=5 #uplinkConfigCommon #frequencyInfoUL @@ -136,19 +124,6 @@ gNBs = # 0=unrestricted, 1=restricted type A, 2=restricted type B restrictedSetConfig = 0, - # pusch-ConfigCommon (up to 16 elements) - initialULBWPk2_0 = 6; # used for UL slot - initialULBWPmappingType_0 = 1 - initialULBWPstartSymbolAndLength_0 = 41; # this is SS=0 L=13 - - initialULBWPk2_1 = 6; # used for mixed slot - initialULBWPmappingType_1 = 1; - initialULBWPstartSymbolAndLength_1 = 52; # this is SS=10 L=4 - - initialULBWPk2_2 = 7; # used for Msg.3 during RA - initialULBWPmappingType_2 = 1; - initialULBWPstartSymbolAndLength_2 = 52; # this is SS=10 L=4 - msg3_DeltaPreamble = 1; p0_NominalWithGrant =-90; @@ -264,7 +239,7 @@ RUs = ( #beamforming 1x4 matrix: bf_weights = [0x00007fff, 0x0000, 0x0000, 0x0000]; #clock_src = "external"; - sdr_addrs = "mgmt_addr=192.168.18.240,addr=192.168.10.2,second_addr=192.168.20.2,clock_source=internal,time_source=internal" + sdr_addrs = "mgmt_addr=172.21.19.14,addr=192.168.10.2,second_addr=192.168.20.2,clock_source=internal,time_source=internal" } ); diff --git a/ci-scripts/conf_files/episci/episci_nr-ue0.nfapi.conf b/ci-scripts/conf_files/episci/episci_nr-ue0.nfapi.conf deleted file mode 100644 index 22ffb4cd3d..0000000000 --- a/ci-scripts/conf_files/episci/episci_nr-ue0.nfapi.conf +++ /dev/null @@ -1,45 +0,0 @@ -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"; -}; - -uicc0 = { -imsi = "208950000000031"; -key = "0c0a34601d4f07677303652c0462535b"; -opc= "63bfa50ee6523365ff14c1f45f88737d"; -dnn= "oai"; -nssai_sst=222; -nssai_sd=123; -} - -L1s = ( - { - num_cc = 1; - tr_n_preference = "nfapi"; - local_n_if_name = "ens3"; - remote_n_address = "127.0.0.1"; //Proxy IP - local_n_address = "127.0.0.1"; - local_n_portc = 50600; - remote_n_portc = 50601; - local_n_portd = 50610; - remote_n_portd = 50611; - } -); - -RUs = ( - { - local_rf = "yes" - nb_tx = 1 - nb_rx = 1 - att_tx = 90 - att_rx = 0; - bands = [7,38,42,43]; - max_pdschReferenceSignalPower = -27; - max_rxgain = 125; - } -); diff --git a/ci-scripts/conf_files/episci/episci_nr-ue1.nfapi.conf b/ci-scripts/conf_files/episci/episci_nr-ue1.nfapi.conf deleted file mode 100644 index 3d1c008f23..0000000000 --- a/ci-scripts/conf_files/episci/episci_nr-ue1.nfapi.conf +++ /dev/null @@ -1,45 +0,0 @@ -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"; -}; - -uicc0 = { -imsi = "208950000000032"; -key = "0c0a34601d4f07677303652c0462535b"; -opc= "63bfa50ee6523365ff14c1f45f88737d"; -dnn= "oai"; -nssai_sst=222; -nssai_sd=123; -} - -L1s = ( - { - num_cc = 1; - tr_n_preference = "nfapi"; - local_n_if_name = "ens3"; - remote_n_address = "127.0.0.1"; //Proxy IP - local_n_address = "127.0.0.1"; - local_n_portc = 50600; - remote_n_portc = 50601; - local_n_portd = 50610; - remote_n_portd = 50611; - } -); - -RUs = ( - { - local_rf = "yes" - nb_tx = 1 - nb_rx = 1 - att_tx = 90 - att_rx = 0; - bands = [7,38,42,43]; - max_pdschReferenceSignalPower = -27; - max_rxgain = 125; - } -); diff --git a/ci-scripts/conf_files/episci/episci_nr-ue2.nfapi.conf b/ci-scripts/conf_files/episci/episci_nr-ue2.nfapi.conf deleted file mode 100644 index 73c3292809..0000000000 --- a/ci-scripts/conf_files/episci/episci_nr-ue2.nfapi.conf +++ /dev/null @@ -1,45 +0,0 @@ -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"; -}; - -uicc0 = { -imsi = "208950000000033"; -key = "0c0a34601d4f07677303652c0462535b"; -opc= "63bfa50ee6523365ff14c1f45f88737d"; -dnn= "oai"; -nssai_sst=222; -nssai_sd=123; -} - -L1s = ( - { - num_cc = 1; - tr_n_preference = "nfapi"; - local_n_if_name = "ens3"; - remote_n_address = "127.0.0.1"; //Proxy IP - local_n_address = "127.0.0.1"; - local_n_portc = 50600; - remote_n_portc = 50601; - local_n_portd = 50610; - remote_n_portd = 50611; - } -); - -RUs = ( - { - local_rf = "yes" - nb_tx = 1 - nb_rx = 1 - att_tx = 90 - att_rx = 0; - bands = [7,38,42,43]; - max_pdschReferenceSignalPower = -27; - max_rxgain = 125; - } -); diff --git a/ci-scripts/conf_files/episci/episci_nr-ue3.nfapi.conf b/ci-scripts/conf_files/episci/episci_nr-ue3.nfapi.conf deleted file mode 100644 index 1f8f7306c6..0000000000 --- a/ci-scripts/conf_files/episci/episci_nr-ue3.nfapi.conf +++ /dev/null @@ -1,45 +0,0 @@ -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"; -}; - -uicc0 = { -imsi = "208950000000034"; -key = "0c0a34601d4f07677303652c0462535b"; -opc= "63bfa50ee6523365ff14c1f45f88737d"; -dnn= "oai"; -nssai_sst=222; -nssai_sd=123; -} - -L1s = ( - { - num_cc = 1; - tr_n_preference = "nfapi"; - local_n_if_name = "ens3"; - remote_n_address = "127.0.0.1"; //Proxy IP - local_n_address = "127.0.0.1"; - local_n_portc = 50600; - remote_n_portc = 50601; - local_n_portd = 50610; - remote_n_portd = 50611; - } -); - -RUs = ( - { - local_rf = "yes" - nb_tx = 1 - nb_rx = 1 - att_tx = 90 - att_rx = 0; - bands = [7,38,42,43]; - max_pdschReferenceSignalPower = -27; - max_rxgain = 125; - } -); diff --git a/ci-scripts/conf_files/episci/episci_rcc.band78.tm1.106PRB.nfapi.conf b/ci-scripts/conf_files/episci/episci_rcc.band78.tm1.106PRB.nfapi.conf index 9b3f205a0f..eac0b74633 100644 --- a/ci-scripts/conf_files/episci/episci_rcc.band78.tm1.106PRB.nfapi.conf +++ b/ci-scripts/conf_files/episci/episci_rcc.band78.tm1.106PRB.nfapi.conf @@ -22,9 +22,14 @@ gNBs = ////////// Physical parameters: ssb_SubcarrierOffset = 31; //0; - pdsch_AntennaPorts = 1; - pusch_AntennaPorts = 1; - + min_rxtxtime = 6; + + pdcch_ConfigSIB1 = ( + { + controlResourceSetZero = 12; + searchSpaceZero = 0; + } + ); servingCellConfigCommon = ( { #spCellConfigCommon @@ -54,15 +59,6 @@ gNBs = #pdcch-ConfigCommon initialDLBWPcontrolResourceSetZero = 0; initialDLBWPsearchSpaceZero = 0; - #pdsch-ConfigCommon - #pdschTimeDomainAllocationList (up to 16 entries) - initialDLBWPk0_0 = 0; #for DL slot - initialDLBWPmappingType_0 = 0; #0=typeA,1=typeB - initialDLBWPstartSymbolAndLength_0 = 40; #this is SS=1,L=13 - - initialDLBWPk0_1 = 0; #for mixed slot - initialDLBWPmappingType_1 = 0; - initialDLBWPstartSymbolAndLength_1 = 57; #this is SS=1,L=5 #uplinkConfigCommon #frequencyInfoUL @@ -117,18 +113,6 @@ gNBs = # restrictedSetConfig # 0=unrestricted, 1=restricted type A, 2=restricted type B restrictedSetConfig = 0, - # pusch-ConfigCommon (up to 16 elements) - initialULBWPk2_0 = 6; # used for UL slot - initialULBWPmappingType_0 = 1 - initialULBWPstartSymbolAndLength_0 = 41; # this is SS=0 L=13 - - initialULBWPk2_1 = 6; # used for mixed slot - initialULBWPmappingType_1 = 1; - initialULBWPstartSymbolAndLength_1 = 52; # this is SS=10 L=4 - - initialULBWPk2_2 = 7; # used for Msg.3 during RA - initialULBWPmappingType_2 = 1; - initialULBWPstartSymbolAndLength_2 = 52; # this is SS=10 L=4 msg3_DeltaPreamble = 1; p0_NominalWithGrant =-90; diff --git a/ci-scripts/conf_files/episci/proxy_gnb.band78.sa.fr1.106PRB.usrpn310.conf b/ci-scripts/conf_files/episci/proxy_gnb.band78.sa.fr1.106PRB.usrpn310.conf index 0597e96245..f80ce3751a 100644 --- a/ci-scripts/conf_files/episci/proxy_gnb.band78.sa.fr1.106PRB.usrpn310.conf +++ b/ci-scripts/conf_files/episci/proxy_gnb.band78.sa.fr1.106PRB.usrpn310.conf @@ -33,9 +33,6 @@ gNBs = ////////// Physical parameters: ssb_SubcarrierOffset = 0; - pdsch_AntennaPorts = 1; - pusch_AntennaPorts = 1; - ul_prbblacklist = "51,52,53,54" min_rxtxtime = 6; pdcch_ConfigSIB1 = ( @@ -74,15 +71,6 @@ gNBs = #pdcch-ConfigCommon initialDLBWPcontrolResourceSetZero = 12; initialDLBWPsearchSpaceZero = 0; - #pdsch-ConfigCommon - #pdschTimeDomainAllocationList (up to 16 entries) - initialDLBWPk0_0 = 0; #for DL slot - initialDLBWPmappingType_0 = 0; #0=typeA,1=typeB - initialDLBWPstartSymbolAndLength_0 = 40; #this is SS=1,L=13 - - initialDLBWPk0_1 = 0; #for mixed slot - initialDLBWPmappingType_1 = 0; - initialDLBWPstartSymbolAndLength_1 = 57; #this is SS=1,L=5 #uplinkConfigCommon #frequencyInfoUL @@ -137,19 +125,6 @@ gNBs = # 0=unrestricted, 1=restricted type A, 2=restricted type B restrictedSetConfig = 0, - # pusch-ConfigCommon (up to 16 elements) - initialULBWPk2_0 = 6; # used for UL slot - initialULBWPmappingType_0 = 1 - initialULBWPstartSymbolAndLength_0 = 41; # this is SS=0 L=13 - - initialULBWPk2_1 = 6; # used for mixed slot - initialULBWPmappingType_1 = 1; - initialULBWPstartSymbolAndLength_1 = 52; # this is SS=10 L=4 - - initialULBWPk2_2 = 7; # used for Msg.3 during RA - initialULBWPmappingType_2 = 1; - initialULBWPstartSymbolAndLength_2 = 52; # this is SS=10 L=4 - msg3_DeltaPreamble = 1; p0_NominalWithGrant =-90; @@ -265,7 +240,7 @@ RUs = ( #beamforming 1x4 matrix: bf_weights = [0x00007fff, 0x0000, 0x0000, 0x0000]; #clock_src = "external"; - sdr_addrs = "mgmt_addr=192.168.18.240,addr=192.168.10.2,second_addr=192.168.20.2,clock_source=internal,time_source=internal" + sdr_addrs = "mgmt_addr=172.21.19.14,addr=192.168.10.2,second_addr=192.168.20.2,clock_source=internal,time_source=internal" } ); diff --git a/ci-scripts/conf_files/episci/proxy_rcc.band78.tm1.106PRB.nfapi.conf b/ci-scripts/conf_files/episci/proxy_rcc.band78.tm1.106PRB.nfapi.conf index 3410104199..f61039ff17 100644 --- a/ci-scripts/conf_files/episci/proxy_rcc.band78.tm1.106PRB.nfapi.conf +++ b/ci-scripts/conf_files/episci/proxy_rcc.band78.tm1.106PRB.nfapi.conf @@ -22,7 +22,7 @@ gNBs = ////////// Physical parameters: ssb_SubcarrierOffset = 0; - pdsch_AntennaPorts = 1; + min_rxtxtime = 6; servingCellConfigCommon = ( { @@ -53,29 +53,6 @@ gNBs = #pdcch-ConfigCommon initialDLBWPcontrolResourceSetZero = 12; initialDLBWPsearchSpaceZero = 0; - #pdsch-ConfigCommon - #pdschTimeDomainAllocationList (up to 16 entries) - initialDLBWPk0_0 = 0; - #initialULBWPmappingType - #0=typeA,1=typeB - initialDLBWPmappingType_0 = 0; - #this is SS=1,L=13 - initialDLBWPstartSymbolAndLength_0 = 40; - - initialDLBWPk0_1 = 0; - initialDLBWPmappingType_1 = 0; - #this is SS=2,L=12 - initialDLBWPstartSymbolAndLength_1 = 53; - - initialDLBWPk0_2 = 0; - initialDLBWPmappingType_2 = 0; - #this is SS=1,L=12 - initialDLBWPstartSymbolAndLength_2 = 54; - - initialDLBWPk0_3 = 0; - initialDLBWPmappingType_3 = 0; - #this is SS=1,L=5 - initialDLBWPstartSymbolAndLength_3 = 57; #uplinkConfigCommon #frequencyInfoUL @@ -130,22 +107,6 @@ gNBs = # 0=unrestricted, 1=restricted type A, 2=restricted type B restrictedSetConfig = 0, - # pusch-ConfigCommon (up to 16 elements) - initialULBWPk2_0 = 6; - initialULBWPmappingType_0 = 1 - # this is SS=0 L=11 - initialULBWPstartSymbolAndLength_0 = 55; - - initialULBWPk2_1 = 6; - initialULBWPmappingType_1 = 1; - # this is SS=0 L=12 - initialULBWPstartSymbolAndLength_1 = 69; - - initialULBWPk2_2 = 7; - initialULBWPmappingType_2 = 1; - # this is SS=10 L=4 - initialULBWPstartSymbolAndLength_2 = 52; - msg3_DeltaPreamble = 1; p0_NominalWithGrant =-90; diff --git a/ci-scripts/conf_files/gNB_SA_CU.conf b/ci-scripts/conf_files/gNB_SA_CU.conf index 1e84e479bc..9d64ae1976 100644 --- a/ci-scripts/conf_files/gNB_SA_CU.conf +++ b/ci-scripts/conf_files/gNB_SA_CU.conf @@ -45,10 +45,7 @@ gNBs = remote_s_portc = 500; remote_s_portd = 2152; ssb_SubcarrierOffset = 0; - pdsch_AntennaPorts = 1; - pusch_AntennaPorts = 1; min_rxtxtime = 6; - sib1_tda = 0; pdcch_ConfigSIB1 = ( { @@ -84,17 +81,8 @@ gNBs = # 0=kHz15, 1=kHz30, 2=kHz60, 3=kHz120 initialDLBWPsubcarrierSpacing = 1; #pdcch-ConfigCommon - initialDLBWPcontrolResourceSetZero = 12; + initialDLBWPcontrolResourceSetZero = 11; initialDLBWPsearchSpaceZero = 0; - #pdsch-ConfigCommon - #pdschTimeDomainAllocationList (up to 16 entries) - initialDLBWPk0_0 = 0; #for DL slot - initialDLBWPmappingType_0 = 0; #0=typeA,1=typeB - initialDLBWPstartSymbolAndLength_0 = 40; #this is SS=1,L=13 - - initialDLBWPk0_1 = 0; #for mixed slot - initialDLBWPmappingType_1 = 0; - initialDLBWPstartSymbolAndLength_1 = 57; #this is SS=1,L=5 #uplinkConfigCommon #frequencyInfoUL @@ -149,19 +137,6 @@ gNBs = # 0=unrestricted, 1=restricted type A, 2=restricted type B restrictedSetConfig = 0, - # pusch-ConfigCommon (up to 16 elements) - initialULBWPk2_0 = 6; # used for UL slot - initialULBWPmappingType_0 = 1 - initialULBWPstartSymbolAndLength_0 = 41; # this is SS=0 L=13 - - initialULBWPk2_1 = 6; # used for mixed slot - initialULBWPmappingType_1 = 1; - initialULBWPstartSymbolAndLength_1 = 52; # this is SS=10 L=4 - - initialULBWPk2_2 = 7; # used for Msg.3 during RA - initialULBWPmappingType_2 = 1; - initialULBWPstartSymbolAndLength_2 = 52; # this is SS=10 L=4 - msg3_DeltaPreamble = 1; p0_NominalWithGrant =-90; diff --git a/ci-scripts/conf_files/gNB_SA_DU.conf b/ci-scripts/conf_files/gNB_SA_DU.conf index 95fa75bc1d..f95bdf91ae 100644 --- a/ci-scripts/conf_files/gNB_SA_DU.conf +++ b/ci-scripts/conf_files/gNB_SA_DU.conf @@ -37,10 +37,7 @@ gNBs = ////////// Physical parameters: ssb_SubcarrierOffset = 0; - pdsch_AntennaPorts = 1; - pusch_AntennaPorts = 1; min_rxtxtime = 6; - sib1_tda = 0; pdcch_ConfigSIB1 = ( { @@ -76,17 +73,8 @@ gNBs = # 0=kHz15, 1=kHz30, 2=kHz60, 3=kHz120 initialDLBWPsubcarrierSpacing = 1; #pdcch-ConfigCommon - initialDLBWPcontrolResourceSetZero = 12; + initialDLBWPcontrolResourceSetZero = 11; initialDLBWPsearchSpaceZero = 0; - #pdsch-ConfigCommon - #pdschTimeDomainAllocationList (up to 16 entries) - initialDLBWPk0_0 = 0; #for DL slot - initialDLBWPmappingType_0 = 0; #0=typeA,1=typeB - initialDLBWPstartSymbolAndLength_0 = 40; #this is SS=1,L=13 - - initialDLBWPk0_1 = 0; #for mixed slot - initialDLBWPmappingType_1 = 0; - initialDLBWPstartSymbolAndLength_1 = 57; #this is SS=1,L=5 #uplinkConfigCommon #frequencyInfoUL @@ -141,19 +129,6 @@ gNBs = # 0=unrestricted, 1=restricted type A, 2=restricted type B restrictedSetConfig = 0, - # pusch-ConfigCommon (up to 16 elements) - initialULBWPk2_0 = 6; # used for UL slot - initialULBWPmappingType_0 = 1 - initialULBWPstartSymbolAndLength_0 = 41; # this is SS=0 L=13 - - initialULBWPk2_1 = 6; # used for mixed slot - initialULBWPmappingType_1 = 1; - initialULBWPstartSymbolAndLength_1 = 52; # this is SS=10 L=4 - - initialULBWPk2_2 = 7; # used for Msg.3 during RA - initialULBWPmappingType_2 = 1; - initialULBWPstartSymbolAndLength_2 = 52; # this is SS=10 L=4 - msg3_DeltaPreamble = 1; p0_NominalWithGrant =-90; diff --git a/ci-scripts/conf_files/gNB_SA_n78_106PRB.2x2_usrpn310.conf b/ci-scripts/conf_files/gNB_SA_n78_106PRB.2x2_usrpn310.conf index 082cc826f3..04dc1b1373 100644 --- a/ci-scripts/conf_files/gNB_SA_n78_106PRB.2x2_usrpn310.conf +++ b/ci-scripts/conf_files/gNB_SA_n78_106PRB.2x2_usrpn310.conf @@ -38,7 +38,7 @@ gNBs = ////////// Physical parameters: ssb_SubcarrierOffset = 0; - pdsch_AntennaPorts = 1; + pdsch_AntennaPorts_XP = 2; pusch_AntennaPorts = 2; pdcch_ConfigSIB1 = ( @@ -209,9 +209,9 @@ gNBs = { GNB_INTERFACE_NAME_FOR_NG_AMF = "em1"; - GNB_IPV4_ADDRESS_FOR_NG_AMF = "192.168.18.194/24"; + GNB_IPV4_ADDRESS_FOR_NG_AMF = "172.21.16.127/24"; GNB_INTERFACE_NAME_FOR_NGU = "em1"; - GNB_IPV4_ADDRESS_FOR_NGU = "192.168.18.194/24"; + GNB_IPV4_ADDRESS_FOR_NGU = "172.21.16.127/24"; GNB_PORT_FOR_S1U = 2152; # Spec 2152 }; @@ -258,7 +258,7 @@ RUs = ( ## beamforming 4x4 matrix: #bf_weights = [0x00007fff, 0x0000, 0x0000, 0x0000, 0x00000000, 0x00007fff, 0x0000, 0x0000, 0x0000, 0x0000, 0x00007fff, 0x0000, 0x0000, 0x0000, 0x0000, 0x00007fff]; - sdr_addrs = "mgmt_addr=192.168.18.240,addr=192.168.10.2,second_addr=192.168.20.2,clock_source=internal,time_source=internal" + sdr_addrs = "mgmt_addr=172.21.19.14,addr=192.168.10.2,second_addr=192.168.20.2,clock_source=internal,time_source=internal" } ); diff --git a/ci-scripts/conf_files/gNB_SA_n78_133PRB.2x2_usrpn310.conf b/ci-scripts/conf_files/gNB_SA_n78_133PRB.2x2_usrpn310.conf index 6af8a23407..fd52c7fed5 100644 --- a/ci-scripts/conf_files/gNB_SA_n78_133PRB.2x2_usrpn310.conf +++ b/ci-scripts/conf_files/gNB_SA_n78_133PRB.2x2_usrpn310.conf @@ -39,7 +39,7 @@ gNBs = ////////// Physical parameters: ssb_SubcarrierOffset = 0; - pdsch_AntennaPorts = 1; + pdsch_AntennaPorts_XP = 2; pusch_AntennaPorts = 2; pdcch_ConfigSIB1 = ( @@ -206,9 +206,9 @@ gNBs = { GNB_INTERFACE_NAME_FOR_NG_AMF = "em1"; - GNB_IPV4_ADDRESS_FOR_NG_AMF = "192.168.18.194/24"; + GNB_IPV4_ADDRESS_FOR_NG_AMF = "172.21.16.127/24"; GNB_INTERFACE_NAME_FOR_NGU = "em1"; - GNB_IPV4_ADDRESS_FOR_NGU = "192.168.18.194/24"; + GNB_IPV4_ADDRESS_FOR_NGU = "172.21.16.127/24"; GNB_PORT_FOR_S1U = 2152; # Spec 2152 }; @@ -254,7 +254,7 @@ RUs = ( ## beamforming 4x4 matrix: #bf_weights = [0x00007fff, 0x0000, 0x0000, 0x0000, 0x00000000, 0x00007fff, 0x0000, 0x0000, 0x0000, 0x0000, 0x00007fff, 0x0000, 0x0000, 0x0000, 0x0000, 0x00007fff]; - sdr_addrs = "mgmt_addr=192.168.18.240,addr=192.168.10.2,second_addr=192.168.20.2,clock_source=internal,time_source=internal" + sdr_addrs = "mgmt_addr=172.21.19.14,addr=192.168.10.2,second_addr=192.168.20.2,clock_source=internal,time_source=internal" } ); diff --git a/ci-scripts/conf_files/gnb.band261.tm1.32PRB.usrpn300.conf b/ci-scripts/conf_files/gnb.band261.tm1.32PRB.usrpn300.conf index e8c6cab1b4..dcb3dd89b7 100644 --- a/ci-scripts/conf_files/gnb.band261.tm1.32PRB.usrpn300.conf +++ b/ci-scripts/conf_files/gnb.band261.tm1.32PRB.usrpn300.conf @@ -22,8 +22,6 @@ gNBs = ////////// Physical parameters: ssb_SubcarrierOffset = 0; - pdsch_AntennaPorts = 1; - pusch_AntennaPorts = 1; min_rxtxtime = 6; servingCellConfigCommon = ( @@ -227,6 +225,7 @@ RUs = ( att_tx = 0; att_rx = 0; bands = [7]; + sl_ahead = 12; max_pdschReferenceSignalPower = -27; max_rxgain = 75; eNB_instances = [0]; diff --git a/ci-scripts/conf_files/gnb.band66.tm1.106PRB.usrpn300.conf b/ci-scripts/conf_files/gnb.band66.tm1.106PRB.usrpn300.conf index 7d3409d4d4..1019ec75ad 100644 --- a/ci-scripts/conf_files/gnb.band66.tm1.106PRB.usrpn300.conf +++ b/ci-scripts/conf_files/gnb.band66.tm1.106PRB.usrpn300.conf @@ -22,8 +22,6 @@ gNBs = ////////// Physical parameters: ssb_SubcarrierOffset = 0; - pdsch_AntennaPorts = 1; - pusch_AntennaPorts = 1; min_rxtxtime = 6; servingCellConfigCommon = ( diff --git a/ci-scripts/conf_files/gnb.band78.nsa_2x2.106PRB.usrpn310.conf b/ci-scripts/conf_files/gnb.band78.nsa_2x2.106PRB.usrpn310.conf index e798e40d64..03155b85d8 100644 --- a/ci-scripts/conf_files/gnb.band78.nsa_2x2.106PRB.usrpn310.conf +++ b/ci-scripts/conf_files/gnb.band78.nsa_2x2.106PRB.usrpn310.conf @@ -20,10 +20,8 @@ gNBs = ////////// Physical parameters: ssb_SubcarrierOffset = 31; //0; - pdsch_AntennaPorts = 1; + pdsch_AntennaPorts_XP = 2; pusch_AntennaPorts = 2; - pusch_TargetSNRx10 = 200; - pucch_TargetSNRx10 = 200; ul_prbblacklist = "51,52,53,54" servingCellConfigCommon = ( @@ -201,12 +199,12 @@ gNBs = ); MACRLCs = ( - { - num_cc = 1; - tr_s_preference = "local_L1"; - tr_n_preference = "local_RRC"; - ulsch_max_frame_inactivity = 1; - } +{ + num_cc = 1; + tr_s_preference = "local_L1"; + tr_n_preference = "local_RRC"; + ulsch_max_frame_inactivity = 0; +} ); L1s = ( @@ -215,6 +213,7 @@ L1s = ( tr_n_preference = "local_mac"; thread_pool_size = 8; prach_dtx_threshold = 120; + pucch0_dtx_threshold = 80; } ); @@ -232,15 +231,14 @@ RUs = ( bf_weights = [0x00007fff, 0x00007fff]; #clock_src = "external"; sf_extension = 0 - sdr_addrs = "mgmt_addr=192.168.18.240,addr=192.168.10.2,second_addr=192.168.20.2,clock_source=internal,time_source=internal" + sdr_addrs = "mgmt_addr=172.21.19.14,addr=192.168.10.2,second_addr=192.168.20.2,clock_source=internal,time_source=internal" } ); THREAD_STRUCT = ( { #three config for level of parallelism "PARALLEL_SINGLE_THREAD", "PARALLEL_RU_L1_SPLIT", or "PARALLEL_RU_L1_TRX_SPLIT" - parallel_config = "PARALLEL_RU_L1_TRX_SPLIT"; - //parallel_config = "PARALLEL_SINGLE_THREAD"; + parallel_config = "PARALLEL_SINGLE_THREAD"; #two option for worker "WORKER_DISABLE" or "WORKER_ENABLE" worker_config = "WORKER_ENABLE"; } diff --git a/ci-scripts/conf_files/gnb.band78.sa.fr1.106PRB.2x2.usrpn310.asue.conf b/ci-scripts/conf_files/gnb.band78.sa.fr1.106PRB.2x2.usrpn310.asue.conf new file mode 100644 index 0000000000..5e6b3fb217 --- /dev/null +++ b/ci-scripts/conf_files/gnb.band78.sa.fr1.106PRB.2x2.usrpn310.asue.conf @@ -0,0 +1,307 @@ +Active_gNBs = ( "gNB-OAI"); +# Asn1_verbosity, choice in: none, info, annoying +Asn1_verbosity = "none"; + +gNBs = +( + { + ////////// Identification parameters: + gNB_CU_ID = 0xe00; + +# cell_type = "CELL_MACRO_GNB"; + + gNB_name = "gNB-OAI"; + + // Tracking area code, 0x0000 and 0xfffe are reserved values + tracking_area_code = 1; + + plmn_list = ({ + mcc = 208; + mnc = 97; + mnc_length = 2; + snssaiList = ( + { + sst = 1; + sd = 0x1; // 0 false, else true + }, + { + sst = 1; + sd = 0x010203; // 0 false, else true + }, + { + sst = 1; + sd = 0x112233; // 0 false, else true + } + ); + }); + + nr_cellid = 12345678L + +# tr_s_preference = "local_mac" + + ////////// Physical parameters: + + ssb_SubcarrierOffset = 0; + pusch_AntennaPorts = 2; + ul_prbblacklist = "51,52,53,54" + do_SRS = 1; + + pdcch_ConfigSIB1 = ( + { + controlResourceSetZero = 11; + searchSpaceZero = 0; + } + ); + + servingCellConfigCommon = ( + { + #spCellConfigCommon + + physCellId = 0; + +# downlinkConfigCommon + #frequencyInfoDL + # this is 3301.68 MHz + 22*12*30e-3 MHz = 3309.6 + #absoluteFrequencySSB = 620640; + # this is 3300.60 MHz + 53*12*30e-3 MHz = 3319.68 + absoluteFrequencySSB = 621312; + # this is 3503.28 MHz + 22*12*30e-3 MHz = 3511.2 + #absoluteFrequencySSB = 634080; + # this is 3600.48 MHz + #absoluteFrequencySSB = 640032; + #dl_frequencyBand = 78; + # this is 3301.68 MHz + #dl_absoluteFrequencyPointA = 620112; + # this is 3300.60 MHz + dl_absoluteFrequencyPointA = 620040; + # this is 3502.56 MHz + #dl_absoluteFrequencyPointA = 633552; + # this is 3600.48 MHz + #dl_absoluteFrequencyPointA = 640032; + #scs-SpecificCarrierList + dl_offstToCarrier = 0; +# subcarrierSpacing +# 0=kHz15, 1=kHz30, 2=kHz60, 3=kHz120 + dl_subcarrierSpacing = 1; + dl_carrierBandwidth = 106; + #initialDownlinkBWP + #genericParameters + # this is RBstart=0,L=106 (275*(L-1))+RBstart + initialDLBWPlocationAndBandwidth = 28875; +# subcarrierSpacing +# 0=kHz15, 1=kHz30, 2=kHz60, 3=kHz120 + initialDLBWPsubcarrierSpacing = 1; + #pdcch-ConfigCommon + initialDLBWPcontrolResourceSetZero = 11; + initialDLBWPsearchSpaceZero = 0; + + #uplinkConfigCommon + #frequencyInfoUL + ul_frequencyBand = 78; + #scs-SpecificCarrierList + ul_offstToCarrier = 0; +# subcarrierSpacing +# 0=kHz15, 1=kHz30, 2=kHz60, 3=kHz120 + ul_subcarrierSpacing = 1; + ul_carrierBandwidth = 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 = 12; + preambleReceivedTargetPower = -104; +#preamblTransMax (0...10) = (3,4,5,6,7,8,10,20,50,100,200) + preambleTransMax = 6; +#powerRampingStep +# 0=dB0,1=dB2,2=dB4,3=dB6 + powerRampingStep = 1; +#ra_ReponseWindow +#1,2,4,8,10,20,40,80 + ra_ResponseWindow = 4; +#ssb_perRACH_OccasionAndCB_PreamblesPerSSB_PR +#1=oneeighth,2=onefourth,3=half,4=one,5=two,6=four,7=eight,8=sixteen + ssb_perRACH_OccasionAndCB_PreamblesPerSSB_PR = 3; +#oneHalf (0..15) 4,8,12,16,...60,64 + ssb_perRACH_OccasionAndCB_PreamblesPerSSB = 15; +#ra_ContentionResolutionTimer +#(0..7) 8,16,24,32,40,48,56,64 + ra_ContentionResolutionTimer = 7; + rsrp_ThresholdSSB = 19; +#prach-RootSequenceIndex_PR +#1 = 839, 2 = 139 + prach_RootSequenceIndex_PR = 2; + prach_RootSequenceIndex = 1; + # SCS for msg1, can only be 15 for 30 kHz < 6 GHz, takes precendence over the one derived from prach-ConfigIndex + # + msg1_SubcarrierSpacing = 1, +# restrictedSetConfig +# 0=unrestricted, 1=restricted type A, 2=restricted type B + restrictedSetConfig = 0, + + msg3_DeltaPreamble = 1; + p0_NominalWithGrant =-90; + +# pucch-ConfigCommon setup : +# pucchGroupHopping +# 0 = neither, 1= group hopping, 2=sequence hopping + pucchGroupHopping = 0; + hoppingId = 40; + p0_nominal = -90; +# ssb_PositionsInBurs_BitmapPR +# 1=short, 2=medium, 3=long + ssb_PositionsInBurst_PR = 2; + ssb_PositionsInBurst_Bitmap = 1; + +# ssb_periodicityServingCell +# 0 = ms5, 1=ms10, 2=ms20, 3=ms40, 4=ms80, 5=ms160, 6=spare2, 7=spare1 + ssb_periodicityServingCell = 2; + +# dmrs_TypeA_position +# 0 = pos2, 1 = pos3 + dmrs_TypeA_Position = 0; + +# subcarrierSpacing +# 0=kHz15, 1=kHz30, 2=kHz60, 3=kHz120 + subcarrierSpacing = 1; + + + #tdd-UL-DL-ConfigurationCommon +# subcarrierSpacing +# 0=kHz15, 1=kHz30, 2=kHz60, 3=kHz120 + referenceSubcarrierSpacing = 1; + # pattern1 + # dl_UL_TransmissionPeriodicity + # 0=ms0p5, 1=ms0p625, 2=ms1, 3=ms1p25, 4=ms2, 5=ms2p5, 6=ms5, 7=ms10 + dl_UL_TransmissionPeriodicity = 6; + nrofDownlinkSlots = 7; + nrofDownlinkSymbols = 6; + nrofUplinkSlots = 2; + nrofUplinkSymbols = 4; + + ssPBCH_BlockPower = -25; + } + + ); + + + # ------- SCTP definitions + SCTP : + { + # Number of streams to use in input/output + SCTP_INSTREAMS = 2; + SCTP_OUTSTREAMS = 2; + }; + + ////////// AMF parameters: + amf_ip_address = ( { ipv4 = "CI_MME_IP_ADDR"; + ipv6 = "192:168:30::17"; + active = "yes"; + preference = "ipv4"; + } + ); + + NETWORK_INTERFACES : + { + + GNB_INTERFACE_NAME_FOR_NG_AMF = "em1"; + GNB_IPV4_ADDRESS_FOR_NG_AMF = "CI_GNB_IP_ADDR"; + GNB_INTERFACE_NAME_FOR_NGU = "em1"; + GNB_IPV4_ADDRESS_FOR_NGU = "CI_GNB_IP_ADDR"; + GNB_PORT_FOR_S1U = 2152; # Spec 2152 + }; + + } +); + +MACRLCs = ( + { + num_cc = 1; + tr_s_preference = "local_L1"; + tr_n_preference = "local_RRC"; +# pusch_TargetSNRx10 = 200; +# pucch_TargetSNRx10 = 150; + ulsch_max_frame_inactivity = 0; + } +); + +L1s = ( +{ + num_cc = 1; + tr_n_preference = "local_mac"; + thread_pool_size = 8; + prach_dtx_threshold = 120; +# pucch0_dtx_threshold = 150; +} +); + +RUs = ( + { + local_rf = "yes" + nb_tx = 2 + nb_rx = 2 + att_tx = 0 + att_rx = 0; + bands = [78]; + max_pdschReferenceSignalPower = -27; + max_rxgain = 75; + eNB_instances = [0]; + ##beamforming 1x2 matrix: 1 layer x 2 antennas + bf_weights = [0x00007fff, 0x0000]; + ##beamforming 1x4 matrix: 1 layer x 4 antennas + #bf_weights = [0x00007fff, 0x0000,0x0000, 0x0000]; + ## beamforming 2x2 matrix: + # bf_weights = [0x00007fff, 0x00000000, 0x00000000, 0x00007fff]; + ## beamforming 4x4 matrix: + #bf_weights = [0x00007fff, 0x0000, 0x0000, 0x0000, 0x00000000, 0x00007fff, 0x0000, 0x0000, 0x0000, 0x0000, 0x00007fff, 0x0000, 0x0000, 0x0000, 0x0000, 0x00007fff]; + sf_extension = 0 + sdr_addrs = "mgmt_addr=172.21.19.14,addr=192.168.10.2,second_addr=192.168.20.2,clock_source=internal,time_source=internal" + } +); + +THREAD_STRUCT = ( + { + #three config for level of parallelism "PARALLEL_SINGLE_THREAD", "PARALLEL_RU_L1_SPLIT", or "PARALLEL_RU_L1_TRX_SPLIT" + parallel_config = "PARALLEL_SINGLE_THREAD"; + #two option for worker "WORKER_DISABLE" or "WORKER_ENABLE" + worker_config = "WORKER_ENABLE"; + } +); + +#security = { + # preferred ciphering algorithms + # the first one of the list that an UE supports in chosen + # valid values: nea0, nea1, nea2, nea3 +# ciphering_algorithms = ( "nea2" ); + + # preferred integrity algorithms + # the first one of the list that an UE supports in chosen + # valid values: nia0, nia1, nia2, nia3 +# integrity_algorithms = ( "nia2", "nia0" ); + + # setting 'drb_ciphering' to "no" disables ciphering for DRBs, no matter + # what 'ciphering_algorithms' configures; same thing for 'drb_integrity' +# drb_ciphering = "yes"; +# drb_integrity = "no"; +#}; + + log_config : + { + global_log_level ="info"; + hw_log_level ="info"; + phy_log_level ="info"; + mac_log_level ="info"; + rlc_log_level ="info"; + pdcp_log_level ="info"; + rrc_log_level ="info"; + f1ap_log_level ="debug"; + }; diff --git a/ci-scripts/conf_files/gnb.band78.sa.fr1.106PRB.2x2.usrpn310.conf b/ci-scripts/conf_files/gnb.band78.sa.fr1.106PRB.2x2.usrpn310.conf index b92c7df92d..09d9b50335 100644 --- a/ci-scripts/conf_files/gnb.band78.sa.fr1.106PRB.2x2.usrpn310.conf +++ b/ci-scripts/conf_files/gnb.band78.sa.fr1.106PRB.2x2.usrpn310.conf @@ -38,7 +38,7 @@ gNBs = ////////// Physical parameters: ssb_SubcarrierOffset = 0; - pdsch_AntennaPorts = 1; + pdsch_AntennaPorts_XP = 2; pusch_AntennaPorts = 2; ul_prbblacklist = "51,52,53,54" do_SRS = 1; @@ -261,7 +261,7 @@ RUs = ( ## beamforming 4x4 matrix: #bf_weights = [0x00007fff, 0x0000, 0x0000, 0x0000, 0x00000000, 0x00007fff, 0x0000, 0x0000, 0x0000, 0x0000, 0x00007fff, 0x0000, 0x0000, 0x0000, 0x0000, 0x00007fff]; sf_extension = 0 - sdr_addrs = "mgmt_addr=192.168.18.240,addr=192.168.10.2,second_addr=192.168.20.2,clock_source=internal,time_source=internal" + sdr_addrs = "mgmt_addr=172.21.19.14,addr=192.168.10.2,second_addr=192.168.20.2,clock_source=internal,time_source=internal" } ); diff --git a/ci-scripts/conf_files/gnb.band78.sa.fr1.106PRB.ddsuu.2x2.usrpn310.conf b/ci-scripts/conf_files/gnb.band78.sa.fr1.106PRB.ddsuu.2x2.usrpn310.conf new file mode 100644 index 0000000000..18ca7b5d1e --- /dev/null +++ b/ci-scripts/conf_files/gnb.band78.sa.fr1.106PRB.ddsuu.2x2.usrpn310.conf @@ -0,0 +1,304 @@ +Active_gNBs = ( "gNB-OAI"); +# Asn1_verbosity, choice in: none, info, annoying +Asn1_verbosity = "none"; + +gNBs = +( + { + ////////// Identification parameters: + gNB_CU_ID = 0xe00; + +# cell_type = "CELL_MACRO_GNB"; + + gNB_name = "gNB-OAI"; + + // Tracking area code, 0x0000 and 0xfffe are reserved values + tracking_area_code = 1; + + plmn_list = ({ + mcc = 208; + mnc = 97; + mnc_length = 2; + snssaiList = ( + { + sst = 1; + sd = 0x010203; // 0 false, else true + }, + { + sst = 1; + sd = 0x112233; // 0 false, else true + } + ); + }); + + nr_cellid = 12345678L + +# tr_s_preference = "local_mac" + + ////////// Physical parameters: + + ssb_SubcarrierOffset = 0; + pusch_AntennaPorts = 2; + ul_prbblacklist = "51,52,53,54" + do_SRS = 1; + + pdcch_ConfigSIB1 = ( + { + controlResourceSetZero = 11; + searchSpaceZero = 0; + } + ); + + servingCellConfigCommon = ( + { + #spCellConfigCommon + + physCellId = 0; + +# downlinkConfigCommon + #frequencyInfoDL + # this is 3301.68 MHz + 22*12*30e-3 MHz = 3309.6 + #absoluteFrequencySSB = 620640; + # this is 3300.60 MHz + 53*12*30e-3 MHz = 3319.68 + absoluteFrequencySSB = 621312; + # this is 3503.28 MHz + 22*12*30e-3 MHz = 3511.2 + #absoluteFrequencySSB = 634080; + # this is 3600.48 MHz + #absoluteFrequencySSB = 640032; + #dl_frequencyBand = 78; + # this is 3301.68 MHz + #dl_absoluteFrequencyPointA = 620112; + # this is 3300.60 MHz + dl_absoluteFrequencyPointA = 620040; + # this is 3502.56 MHz + #dl_absoluteFrequencyPointA = 633552; + # this is 3600.48 MHz + #dl_absoluteFrequencyPointA = 640032; + #scs-SpecificCarrierList + dl_offstToCarrier = 0; +# subcarrierSpacing +# 0=kHz15, 1=kHz30, 2=kHz60, 3=kHz120 + dl_subcarrierSpacing = 1; + dl_carrierBandwidth = 106; + #initialDownlinkBWP + #genericParameters + # this is RBstart=0,L=106 (275*(L-1))+RBstart + initialDLBWPlocationAndBandwidth = 28875; +# subcarrierSpacing +# 0=kHz15, 1=kHz30, 2=kHz60, 3=kHz120 + initialDLBWPsubcarrierSpacing = 1; + #pdcch-ConfigCommon + initialDLBWPcontrolResourceSetZero = 11; + initialDLBWPsearchSpaceZero = 0; + + #uplinkConfigCommon + #frequencyInfoUL + ul_frequencyBand = 78; + #scs-SpecificCarrierList + ul_offstToCarrier = 0; +# subcarrierSpacing +# 0=kHz15, 1=kHz30, 2=kHz60, 3=kHz120 + ul_subcarrierSpacing = 1; + ul_carrierBandwidth = 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 = 12; + preambleReceivedTargetPower = -104; +#preamblTransMax (0...10) = (3,4,5,6,7,8,10,20,50,100,200) + preambleTransMax = 6; +#powerRampingStep +# 0=dB0,1=dB2,2=dB4,3=dB6 + powerRampingStep = 1; +#ra_ReponseWindow +#1,2,4,8,10,20,40,80 + ra_ResponseWindow = 4; +#ssb_perRACH_OccasionAndCB_PreamblesPerSSB_PR +#1=oneeighth,2=onefourth,3=half,4=one,5=two,6=four,7=eight,8=sixteen + ssb_perRACH_OccasionAndCB_PreamblesPerSSB_PR = 3; +#oneHalf (0..15) 4,8,12,16,...60,64 + ssb_perRACH_OccasionAndCB_PreamblesPerSSB = 15; +#ra_ContentionResolutionTimer +#(0..7) 8,16,24,32,40,48,56,64 + ra_ContentionResolutionTimer = 7; + rsrp_ThresholdSSB = 19; +#prach-RootSequenceIndex_PR +#1 = 839, 2 = 139 + prach_RootSequenceIndex_PR = 2; + prach_RootSequenceIndex = 1; + # SCS for msg1, can only be 15 for 30 kHz < 6 GHz, takes precendence over the one derived from prach-ConfigIndex + # + msg1_SubcarrierSpacing = 1, +# restrictedSetConfig +# 0=unrestricted, 1=restricted type A, 2=restricted type B + restrictedSetConfig = 0, + + msg3_DeltaPreamble = 1; + p0_NominalWithGrant =-90; + +# pucch-ConfigCommon setup : +# pucchGroupHopping +# 0 = neither, 1= group hopping, 2=sequence hopping + pucchGroupHopping = 0; + hoppingId = 40; + p0_nominal = -90; +# ssb_PositionsInBurs_BitmapPR +# 1=short, 2=medium, 3=long + ssb_PositionsInBurst_PR = 2; + ssb_PositionsInBurst_Bitmap = 1; + +# ssb_periodicityServingCell +# 0 = ms5, 1=ms10, 2=ms20, 3=ms40, 4=ms80, 5=ms160, 6=spare2, 7=spare1 + ssb_periodicityServingCell = 2; + +# dmrs_TypeA_position +# 0 = pos2, 1 = pos3 + dmrs_TypeA_Position = 0; + +# subcarrierSpacing +# 0=kHz15, 1=kHz30, 2=kHz60, 3=kHz120 + subcarrierSpacing = 1; + + + #tdd-UL-DL-ConfigurationCommon +# subcarrierSpacing +# 0=kHz15, 1=kHz30, 2=kHz60, 3=kHz120 + referenceSubcarrierSpacing = 1; + # pattern1 + # dl_UL_TransmissionPeriodicity + # 0=ms0p5, 1=ms0p625, 2=ms1, 3=ms1p25, 4=ms2, 5=ms2p5, 6=ms5, 7=ms10 + dl_UL_TransmissionPeriodicity = 5; + nrofDownlinkSlots = 2; + nrofDownlinkSymbols = 6; + nrofUplinkSlots = 2; + nrofUplinkSymbols = 4; + + ssPBCH_BlockPower = -25; + } + + ); + + + # ------- SCTP definitions + SCTP : + { + # Number of streams to use in input/output + SCTP_INSTREAMS = 2; + SCTP_OUTSTREAMS = 2; + }; + + ////////// AMF parameters: + amf_ip_address = ( { ipv4 = "CI_MME_IP_ADDR"; + ipv6 = "192:168:30::17"; + active = "yes"; + preference = "ipv4"; + } + ); + + NETWORK_INTERFACES : + { + + GNB_INTERFACE_NAME_FOR_NG_AMF = "em1"; + GNB_IPV4_ADDRESS_FOR_NG_AMF = "CI_GNB_IP_ADDR"; + GNB_INTERFACE_NAME_FOR_NGU = "em1"; + GNB_IPV4_ADDRESS_FOR_NGU = "CI_GNB_IP_ADDR"; + GNB_PORT_FOR_S1U = 2152; # Spec 2152 + }; + + } +); + +MACRLCs = ( + { + num_cc = 1; + tr_s_preference = "local_L1"; + tr_n_preference = "local_RRC"; +# pusch_TargetSNRx10 = 200; +# pucch_TargetSNRx10 = 150; + ulsch_max_frame_inactivity = 0; + } +); + +L1s = ( +{ + num_cc = 1; + tr_n_preference = "local_mac"; + thread_pool_size = 8; + prach_dtx_threshold = 120; +# pucch0_dtx_threshold = 150; +} +); + +RUs = ( + { + local_rf = "yes" + nb_tx = 2 + nb_rx = 2 + att_tx = 0 + att_rx = 0; + bands = [78]; + max_pdschReferenceSignalPower = -27; + max_rxgain = 75; + eNB_instances = [0]; + ##beamforming 1x2 matrix: 1 layer x 2 antennas + bf_weights = [0x00007fff, 0x0000]; + ##beamforming 1x4 matrix: 1 layer x 4 antennas + #bf_weights = [0x00007fff, 0x0000,0x0000, 0x0000]; + ## beamforming 2x2 matrix: + # bf_weights = [0x00007fff, 0x00000000, 0x00000000, 0x00007fff]; + ## beamforming 4x4 matrix: + #bf_weights = [0x00007fff, 0x0000, 0x0000, 0x0000, 0x00000000, 0x00007fff, 0x0000, 0x0000, 0x0000, 0x0000, 0x00007fff, 0x0000, 0x0000, 0x0000, 0x0000, 0x00007fff]; + sf_extension = 0 + sdr_addrs = "mgmt_addr=172.21.19.14,addr=192.168.10.2,second_addr=192.168.20.2,clock_source=internal,time_source=internal" + sl_ahead = 5; + } +); + +THREAD_STRUCT = ( + { + #three config for level of parallelism "PARALLEL_SINGLE_THREAD", "PARALLEL_RU_L1_SPLIT", or "PARALLEL_RU_L1_TRX_SPLIT" + parallel_config = "PARALLEL_SINGLE_THREAD"; + #two option for worker "WORKER_DISABLE" or "WORKER_ENABLE" + worker_config = "WORKER_ENABLE"; + } +); + +security = { + # preferred ciphering algorithms + # the first one of the list that an UE supports in chosen + # valid values: nea0, nea1, nea2, nea3 + ciphering_algorithms = ( "nea0" ); + + # preferred integrity algorithms + # the first one of the list that an UE supports in chosen + # valid values: nia0, nia1, nia2, nia3 + integrity_algorithms = ( "nia2", "nia0" ); + + # setting 'drb_ciphering' to "no" disables ciphering for DRBs, no matter + # what 'ciphering_algorithms' configures; same thing for 'drb_integrity' + drb_ciphering = "yes"; + drb_integrity = "no"; +}; + + log_config : + { + global_log_level ="info"; + hw_log_level ="info"; + phy_log_level ="info"; + mac_log_level ="info"; + rlc_log_level ="info"; + pdcp_log_level ="info"; + rrc_log_level ="info"; + f1ap_log_level ="debug"; + }; diff --git a/ci-scripts/conf_files/gnb.band78.sa.fr1.106PRB.usrpn310.conf b/ci-scripts/conf_files/gnb.band78.sa.fr1.106PRB.usrpn310.conf index 6c778a7c31..9e1f499f03 100644 --- a/ci-scripts/conf_files/gnb.band78.sa.fr1.106PRB.usrpn310.conf +++ b/ci-scripts/conf_files/gnb.band78.sa.fr1.106PRB.usrpn310.conf @@ -38,8 +38,6 @@ gNBs = ////////// Physical parameters: ssb_SubcarrierOffset = 0; - pdsch_AntennaPorts = 1; - pusch_AntennaPorts = 1; #pusch_TargetSNRx10 = 200; #pucch_TargetSNRx10 = 200; ul_prbblacklist = "51,52,53,54" @@ -265,7 +263,7 @@ RUs = ( ## beamforming 4x4 matrix: #bf_weights = [0x00007fff, 0x0000, 0x0000, 0x0000, 0x00000000, 0x00007fff, 0x0000, 0x0000, 0x0000, 0x0000, 0x00007fff, 0x0000, 0x0000, 0x0000, 0x0000, 0x00007fff]; sf_extension = 0 - sdr_addrs = "mgmt_addr=192.168.18.240,addr=192.168.10.2,second_addr=192.168.20.2,clock_source=internal,time_source=internal" + sdr_addrs = "mgmt_addr=172.21.19.14,addr=192.168.10.2,second_addr=192.168.20.2,clock_source=internal,time_source=internal" } ); diff --git a/ci-scripts/conf_files/gnb.band78.sa.fr1.162PRB.2x2.usrpn310.conf b/ci-scripts/conf_files/gnb.band78.sa.fr1.162PRB.2x2.usrpn310.conf index 5c826ca862..42fc89b2ed 100644 --- a/ci-scripts/conf_files/gnb.band78.sa.fr1.162PRB.2x2.usrpn310.conf +++ b/ci-scripts/conf_files/gnb.band78.sa.fr1.162PRB.2x2.usrpn310.conf @@ -38,8 +38,10 @@ gNBs = ////////// Physical parameters: ssb_SubcarrierOffset = 0; - pdsch_AntennaPorts = 1; + pdsch_AntennaPorts_XP = 2; pusch_AntennaPorts = 2; + #pusch_TargetSNRx10 = 200; + #pucch_TargetSNRx10 = 200; ul_prbblacklist = "79,80,81,82" pdcch_ConfigSIB1 = ( @@ -83,7 +85,7 @@ gNBs = #initialDownlinkBWP #genericParameters # this is RBstart=0,L=106 (275*(L-1))+RBstart - initialDLBWPlocationAndBandwidth = 31899; + initialDLBWPlocationAndBandwidth = 31624; # subcarrierSpacing # 0=kHz15, 1=kHz30, 2=kHz60, 3=kHz120 initialDLBWPsubcarrierSpacing = 1; @@ -103,7 +105,7 @@ gNBs = pMax = 20; #initialUplinkBWP #genericParameters - initialULBWPlocationAndBandwidth = 31899; + initialULBWPlocationAndBandwidth = 31624; # subcarrierSpacing # 0=kHz15, 1=kHz30, 2=kHz60, 3=kHz120 initialULBWPsubcarrierSpacing = 1; @@ -260,7 +262,7 @@ RUs = ( ## beamforming 4x4 matrix: #bf_weights = [0x00007fff, 0x0000, 0x0000, 0x0000, 0x00000000, 0x00007fff, 0x0000, 0x0000, 0x0000, 0x0000, 0x00007fff, 0x0000, 0x0000, 0x0000, 0x0000, 0x00007fff]; sf_extension = 0 - sdr_addrs = "mgmt_addr=192.168.18.240,addr=192.168.10.2,second_addr=192.168.20.2,clock_source=internal,time_source=internal" + sdr_addrs = "mgmt_addr=172.21.19.14,addr=192.168.10.2,second_addr=192.168.20.2,clock_source=internal,time_source=internal" } ); diff --git a/ci-scripts/conf_files/gnb.band78.tm1.106PRB.usrpn300.conf b/ci-scripts/conf_files/gnb.band78.tm1.106PRB.usrpn300.conf index d21cf90cd9..835e334bbb 100644 --- a/ci-scripts/conf_files/gnb.band78.tm1.106PRB.usrpn300.conf +++ b/ci-scripts/conf_files/gnb.band78.tm1.106PRB.usrpn300.conf @@ -22,8 +22,6 @@ gNBs = ////////// Physical parameters: ssb_SubcarrierOffset = 0; - pdsch_AntennaPorts = 1; - pusch_AntennaPorts = 1; min_rxtxtime = 6; servingCellConfigCommon = ( @@ -221,8 +219,7 @@ RUs = ( ## beamforming 4x4 matrix: #bf_weights = [0x00007fff, 0x0000, 0x0000, 0x0000, 0x00000000, 0x00007fff, 0x0000, 0x0000, 0x0000, 0x0000, 0x00007fff, 0x0000, 0x0000, 0x0000, 0x0000, 0x00007fff]; - sdr_addrs = "addr=192.168.30.2,mgmt_addr=192.168.30.2,second_addr=192.168.50.2"; - clock_src = "external"; + sdr_addrs = "addr=192.168.10.2,second_addr=192.168.20.2"; } ); diff --git a/ci-scripts/conf_files/gnb.band78.tm1.fr1.106PRB.usrpb210.conf b/ci-scripts/conf_files/gnb.band78.tm1.fr1.106PRB.usrpb210.conf index 55cb7b36c4..f3515d3882 100644 --- a/ci-scripts/conf_files/gnb.band78.tm1.fr1.106PRB.usrpb210.conf +++ b/ci-scripts/conf_files/gnb.band78.tm1.fr1.106PRB.usrpb210.conf @@ -20,8 +20,6 @@ gNBs = ////////// Physical parameters: ssb_SubcarrierOffset = 31; //0; - pdsch_AntennaPorts = 1; - pusch_AntennaPorts = 1; servingCellConfigCommon = ( { @@ -205,7 +203,7 @@ MACRLCs = ( tr_n_preference = "local_RRC"; pusch_TargetSNRx10 = 200; pucch_TargetSNRx10 = 200; - ulsch_max_frame_inactivity = 1; + ulsch_max_frame_inactivity = 0; } ); @@ -223,11 +221,11 @@ RUs = ( local_rf = "yes" nb_tx = 1 nb_rx = 1 - att_tx = 3 - att_rx = 0; + att_tx = 12 + att_rx = 12; bands = [7]; max_pdschReferenceSignalPower = -27; - max_rxgain = 111; + max_rxgain = 114; eNB_instances = [0]; # sdr_addrs = "serial=30C51D4"; # clock_src = "external"; diff --git a/ci-scripts/conf_files/gnb.band78.tm1.fr1.106PRB.usrpn310.conf b/ci-scripts/conf_files/gnb.band78.tm1.fr1.106PRB.usrpn310.conf index 7c4bb9cc59..8f480d3757 100644 --- a/ci-scripts/conf_files/gnb.band78.tm1.fr1.106PRB.usrpn310.conf +++ b/ci-scripts/conf_files/gnb.band78.tm1.fr1.106PRB.usrpn310.conf @@ -21,8 +21,6 @@ gNBs = ////////// Physical parameters: ssb_SubcarrierOffset = 31; //0; - pdsch_AntennaPorts = 1; - pusch_AntennaPorts = 1; min_rxtxtime = 6; servingCellConfigCommon = ( diff --git a/ci-scripts/conf_files/gnb.sa.band66.fr1.106PRB.usrpn300.conf b/ci-scripts/conf_files/gnb.sa.band66.fr1.106PRB.usrpn300.conf index 7f5a9d4343..b78ca916f3 100644 --- a/ci-scripts/conf_files/gnb.sa.band66.fr1.106PRB.usrpn300.conf +++ b/ci-scripts/conf_files/gnb.sa.band66.fr1.106PRB.usrpn300.conf @@ -33,10 +33,7 @@ gNBs = ////////// Physical parameters: ssb_SubcarrierOffset = 0; - pdsch_AntennaPorts = 1; - pusch_AntennaPorts = 1; min_rxtxtime = 6; - sib1_tda = 0; pdcch_ConfigSIB1 = ( { @@ -66,8 +63,8 @@ gNBs = dl_carrierBandwidth = 106; #initialDownlinkBWP #genericParameters - # this is RBstart=27,L=48 (275*(L-1))+RBstart - initialDLBWPlocationAndBandwidth = 13475; # 6366 12925 12956 28875 12952 + # this is RBstart=0,L=106 (275*(L-1))+RBstart + initialDLBWPlocationAndBandwidth = 28875; # subcarrierSpacing # 0=kHz15, 1=kHz30, 2=kHz60, 3=kHz120 initialDLBWPsubcarrierSpacing = 1; @@ -88,7 +85,7 @@ gNBs = pMax = 20; #initialUplinkBWP #genericParameters - initialULBWPlocationAndBandwidth = 13475; + initialULBWPlocationAndBandwidth = 28875; # subcarrierSpacing # 0=kHz15, 1=kHz30, 2=kHz60, 3=kHz120 initialULBWPsubcarrierSpacing = 1; diff --git a/ci-scripts/datalog_rt_stats.2x2.yaml b/ci-scripts/datalog_rt_stats.2x2.yaml index a93ef6aa8c..eccde746cc 100644 --- a/ci-scripts/datalog_rt_stats.2x2.yaml +++ b/ci-scripts/datalog_rt_stats.2x2.yaml @@ -16,7 +16,7 @@ Ref : L1 Rx processing : 175.0 PUSCH inner-receiver : 100.0 PUSCH decoding : 180.0 - DL & UL scheduling timing stats : 37.0 + DL & UL scheduling timing : 37.0 UL Indication : 38.0 Threshold : feprx : 1.25 @@ -28,5 +28,5 @@ Threshold : L1 Rx processing : 1.25 PUSCH inner-receiver : 1.25 PUSCH decoding : 1.25 - DL & UL scheduling timing stats : 1.25 + DL & UL scheduling timing : 1.25 UL Indication : 1.25 diff --git a/ci-scripts/datalog_rt_stats.default.yaml b/ci-scripts/datalog_rt_stats.default.yaml index 02a90c86f4..97591a766d 100644 --- a/ci-scripts/datalog_rt_stats.default.yaml +++ b/ci-scripts/datalog_rt_stats.default.yaml @@ -15,8 +15,9 @@ Ref : DLSCH encoding : 230.0 L1 Rx processing : 175.0 PUSCH inner-receiver : 100.0 - PUSCH decoding : 180.0 - DL & UL scheduling timing stats : 37.0 + #PUSCH decoding : 180.0 + PUSCH decoding : 240.0 + DL & UL scheduling timing : 37.0 UL Indication : 38.0 Threshold : feprx : 1.25 @@ -28,5 +29,5 @@ Threshold : L1 Rx processing : 1.25 PUSCH inner-receiver : 1.25 PUSCH decoding : 1.25 - DL & UL scheduling timing stats : 1.25 + DL & UL scheduling timing : 1.25 UL Indication : 1.25 diff --git a/ci-scripts/doc/vm_based_simulator_build.md b/ci-scripts/doc/vm_based_simulator_build.md index 28fbc955d5..16faa3ce9b 100644 --- a/ci-scripts/doc/vm_based_simulator_build.md +++ b/ci-scripts/doc/vm_based_simulator_build.md @@ -52,7 +52,6 @@ Options: -------- # OpenAirInterface Build Variants --variant enb-usrp OR -v1 ( build and test ) - --variant basic-sim OR -v2 ( build and test ) --variant phy-sim OR -v3 ( build and test ) --variant cppcheck OR -v4 ( build and test ) --variant gnb-usrp OR -v5 ( build and test ) diff --git a/ci-scripts/doc/vm_based_simulator_create.md b/ci-scripts/doc/vm_based_simulator_create.md index 09ce26c553..4681738038 100644 --- a/ci-scripts/doc/vm_based_simulator_create.md +++ b/ci-scripts/doc/vm_based_simulator_create.md @@ -45,7 +45,6 @@ Mandatory Options: # OpenAirInterface Build Variants --variant enb-usrp OR -v1 ( build and test ) - --variant basic-sim OR -v2 ( build and test ) --variant phy-sim OR -v3 ( build and test ) --variant cppcheck OR -v4 ( build and test ) --variant gnb-usrp OR -v5 ( build and test ) diff --git a/ci-scripts/doc/vm_based_simulator_main_scripts.md b/ci-scripts/doc/vm_based_simulator_main_scripts.md index 000d89a1eb..0d54d03521 100644 --- a/ci-scripts/doc/vm_based_simulator_main_scripts.md +++ b/ci-scripts/doc/vm_based_simulator_main_scripts.md @@ -109,12 +109,6 @@ You can get the list of variant specific variables specifying the variant argume NB_PATTERN_FILES=9 BUILD_OPTIONS="" LOG_PATTERN=.Rel15.txt - --variant basic-sim OR -v2 ( build and test ) - VM_NAME=ci-basic-sim ARCHIVES_LOC=basic_sim - VM_MEMORY=8192 VM_CPU=4 - NB_PATTERN_FILES=13 BUILD_OPTIONS="--eNB --UE" - LOG_PATTERN=.Rel15.txt - --variant phy-sim OR -v3 ( build and test ) VM_NAME=ci-phy-sim ARCHIVES_LOC=phy_sim VM_MEMORY=2048 VM_CPU=4 diff --git a/ci-scripts/doc/vm_based_simulator_test.md b/ci-scripts/doc/vm_based_simulator_test.md index 73308b972e..ab28101543 100644 --- a/ci-scripts/doc/vm_based_simulator_test.md +++ b/ci-scripts/doc/vm_based_simulator_test.md @@ -18,16 +18,14 @@ 2. [Detailed Description](#2-detailed-description) 3. [Typical Usage](#3-typical-usage) 1. [Testing the physical simulators](#31-testing-the-physicals-simulators) - 2. [Testing the basic simulator](#32-testing-the-basic-simulator) - 3. [Testing the RF simulator](#33-testing-the-rf-simulator) - 4. [Testing the L2-nFAPI simulator](#33-testing-the-l2-nfapi-simulator) + 2. [Testing the RF simulator](#33-testing-the-rf-simulator) + 3. [Testing the L2-nFAPI simulator](#33-testing-the-l2-nfapi-simulator) # 1. Introduction # -Currently 2 build variants can be directly tested: +Currently 1 build variant can be directly tested: * Physical Simulators -* Basic Simulator In addition, 2 build variants are used: @@ -73,7 +71,6 @@ Options: # OpenAirInterface Build Variants --variant enb-usrp OR -v1 ( build and test ) - --variant basic-sim OR -v2 ( build and test ) --variant phy-sim OR -v3 ( build and test ) --variant cppcheck OR -v4 ( build and test ) --variant gnb-usrp OR -v5 ( build and test ) @@ -143,64 +140,7 @@ $ ./ci-scripts/oai-ci-vm-tool test --workspace /var/jenkins/workspace/RAN-CI-dev Note that the VM instance is destroyed. You do that when you are sure your test is passing. -## 3.2. Testing the basic simulator ## - -```bash -$ ./ci-scripts/oai-ci-vm-tool test --workspace /var/jenkins/workspace/RAN-CI-develop --variant basic-sim --job-name RAN-CI-develop --build-id 48 -15:11:13 ############################################################ -15:11:13 OAI CI VM script -15:11:13 ############################################################ -15:11:13 VM_NAME = RAN-CI-develop-b48-basic-sim -15:11:13 VM_CMD_FILE = RAN-CI-develop-b48-basic-sim_cmds.txt -15:11:13 JENKINS_WKSP = /var/jenkins/workspace/RAN-CI-develop -15:11:13 ARCHIVES_LOC = /var/jenkins/workspace/RAN-CI-develop/archives/basic_sim/test -15:11:13 ############################################################ -15:11:13 Waiting for VM to be started -15:11:13 ############################################################ -15:11:14 Warning: Permanently added '192.168.122.29' (ECDSA) to the list of known hosts. -15:11:15 RAN-CI-develop-b48-basic-sim has for IP addr = 192.168.122.29 -15:11:15 ############################################################ -15:11:15 Test EPC on VM (RAN-CI-develop-b48-epc) will be using ltebox -15:11:15 ############################################################ -15:11:15 EPC_VM_CMD_FILE = RAN-CI-develop-b48-epc_cmds.txt -15:11:15 ############################################################ -15:11:15 Creating test EPC VM (RAN-CI-develop-b48-epc) on Ubuntu Cloud Image base -15:11:15 ############################################################ -15:11:18 Waiting for VM to be started -15:13:25 Warning: Permanently added '192.168.122.156' (ECDSA) to the list of known hosts. -15:13:25 RAN-CI-develop-b48-epc has for IP addr = 192.168.122.156 -15:13:25 Warning: Permanently added '192.168.122.156' (ECDSA) to the list of known hosts. -15:13:25 ls: cannot access '/opt/ltebox/tools/start_ltebox': No such file or directory -15:13:25 ############################################################ -15:13:25 Copying ltebox archives into EPC VM (RAN-CI-develop-b48-epc) -15:13:25 ############################################################ -15:13:25 ############################################################ -15:13:25 Install EPC on EPC VM (RAN-CI-develop-b48-epc) -15:13:25 ############################################################ -.... -15:24:39 ############################################################ -15:24:39 Terminate EPC -15:24:39 ############################################################ -15:24:39 cd /opt/ltebox/tools -15:24:39 sudo ./stop_ltebox -15:24:40 sudo daemon --name=simulated_hss --stop -15:24:40 sudo killall --signal SIGKILL hss_sim -15:24:40 ############################################################ -15:24:40 Destroying VMs -15:24:40 ############################################################ -15:24:41 # Host 192.168.122.29 found: line 18 -15:24:41 /home/eurecom/.ssh/known_hosts updated. -15:24:41 Original contents retained as /home/eurecom/.ssh/known_hosts.old -15:24:43 # Host 192.168.122.60 found: line 20 -15:24:43 /home/eurecom/.ssh/known_hosts updated. -15:24:43 Original contents retained as /home/eurecom/.ssh/known_hosts.old -15:24:43 ############################################################ -15:24:43 Checking run status -15:24:43 ############################################################ -15:24:43 STATUS seems OK -``` - -## 3.3. Test the RF simulator ## +## 3.2. Test the RF simulator ## ```bash ./ci-scripts/oai-ci-vm-tool test --workspace /var/jenkins/workspace/RAN-CI-develop --variant rf-sim --job-name RAN-CI-develop --build-id 48 --keep-vm-alive @@ -209,7 +149,7 @@ $ ./ci-scripts/oai-ci-vm-tool test --workspace /var/jenkins/workspace/RAN-CI-dev 15:24:45 STATUS seems OK ``` -## 3.4. Testing the L2-nFAPI simulator +## 3.3. Testing the L2-nFAPI simulator ```bash ./ci-scripts/oai-ci-vm-tool test --workspace /var/jenkins/workspace/RAN-CI-develop --variant l2-sim --job-name RAN-CI-develop --build-id 48 diff --git a/ci-scripts/docker/Dockerfile.formatting.bionic b/ci-scripts/docker/Dockerfile.formatting.bionic new file mode 100644 index 0000000000..01417a3bdb --- /dev/null +++ b/ci-scripts/docker/Dockerfile.formatting.bionic @@ -0,0 +1,31 @@ +FROM ubuntu:bionic AS oai-formatting-check + +ARG MERGE_REQUEST +ARG SRC_BRANCH +ARG TARGET_BRANCH +ENV DEBIAN_FRONTEND=noninteractive + +RUN apt-get update && \ + DEBIAN_FRONTEND=noninteractive apt-get upgrade --yes && \ + DEBIAN_FRONTEND=noninteractive apt-get install --yes \ + astyle \ + gawk \ + git + +WORKDIR /oai-ran +COPY . . + +RUN /bin/bash -c "if [[ -v MERGE_REQUEST ]]; then echo 'Source Branch = $SRC_BRANCH'; echo 'Target Branch = $TARGET_BRANCH'; else echo 'Push to develop'; fi" +RUN /bin/bash -c "if [[ -v MERGE_REQUEST ]]; then ./ci-scripts/checkCodingFormattingRules.sh --src-branch $SRC_BRANCH --target-branch $TARGET_BRANCH; else ./ci-scripts/checkCodingFormattingRules.sh; fi" + +RUN echo "=== Files not properly formatted ===" && \ + /bin/bash -c "if [[ -f oai_rules_result_list.txt ]]; then cat oai_rules_result_list.txt; fi" + +RUN echo "=== Files with incorrect define protection ===" && \ + /bin/bash -c "if [[ -f header-files-w-incorrect-define.txt ]]; then cat header-files-w-incorrect-define.txt; fi" + +RUN echo "=== Files with a GNU GPL licence Banner ===" && \ + /bin/bash -c "if [[ -f files-w-gnu-gpl-license-banner.txt ]]; then cat files-w-gnu-gpl-license-banner.txt; fi" + +RUN echo "=== Files with a suspect Banner ===" && \ + /bin/bash -c "if [[ -f files-w-suspect-banner.txt ]]; then cat files-w-suspect-banner.txt; fi" diff --git a/ci-scripts/epc.py b/ci-scripts/epc.py index 9ed9f06d8e..0e0afefaaf 100644 --- a/ci-scripts/epc.py +++ b/ci-scripts/epc.py @@ -66,6 +66,8 @@ class EPCManagement(): self.mmeConfFile = 'mme.conf' self.yamlPath = '' self.isMagmaUsed = False + self.cfgDeploy = '--type start-mini --fqdn yes --scenario 1 --capture /tmp/oai-cn5g-v1.3.pcap' #from xml, 'mini' is default normal for docker-network.py + self.cfgUnDeploy = '--type stop-mini --fqdn yes --scenario 1' #from xml, 'mini' is default normal for docker-network.py #----------------------------------------------------------- @@ -251,18 +253,21 @@ class EPCManagement(): logging.debug('Starting OAI CN5G') mySSH.command('if [ -d ' + self.SourceCodePath + '/scripts ]; then echo ' + self.Password + ' | sudo -S rm -Rf ' + self.SourceCodePath + '/scripts ; fi', '\$', 5) mySSH.command('mkdir -p ' + self.SourceCodePath + '/scripts', '\$', 5) - mySSH.command('cd /opt/oai-cn5g-fed/docker-compose', '\$', 5) - mySSH.command('./core-network.sh start nrf spgwu', '\$', 60) - time.sleep(2) - mySSH.command('docker-compose -p 5gcn ps -a', '\$', 60) + mySSH.command('cd /opt/oai-cn5g-fed-v1.3/docker-compose', '\$', 5) + mySSH.command('python3 ./core-network.py '+self.cfgDeploy, '\$', 60) + if re.search('start-mini-as-ue', self.cfgDeploy): + dFile = 'docker-compose-mini-nrf-asue.yaml' + else: + dFile = 'docker-compose-mini-nrf.yaml' + mySSH.command('docker-compose -p 5gcn -f ' + dFile + ' ps -a', '\$', 60) if mySSH.getBefore().count('Up (healthy)') != 6: logging.error('Not all container healthy') else: - logging.debug('OK') - mySSH.command('docker-compose config | grep --colour=never image', '\$', 10) + logging.debug('OK --> all containers are healthy') + mySSH.command('docker-compose -p 5gcn -f ' + dFile + ' config | grep --colour=never image', '\$', 10) listOfImages = mySSH.getBefore() for imageLine in listOfImages.split('\\r\\n'): - res1 = re.search('image: (?P[a-zA-Z0-9\-]+):(?P[a-zA-Z0-9\-]+)', str(imageLine)) + res1 = re.search('image: (?P[a-zA-Z0-9\-/]+):(?P[a-zA-Z0-9\-]+)', str(imageLine)) res2 = re.search('mysql', str(imageLine)) if res1 is not None and res2 is None: html_cell += res1.group('name') + ':' + res1.group('tag') + ' ' @@ -530,11 +535,11 @@ class EPCManagement(): mySSH.command('docker logs ' + c + ' > ' + self.SourceCodePath + '/logs/' + c + '.log', '\$', 5) logging.debug('Terminating OAI CN5G') - mySSH.command('cd /opt/oai-cn5g-fed/docker-compose', '\$', 5) - mySSH.command('./core-network.sh stop nrf spgwu', '\$', 60) + mySSH.command('cd /opt/oai-cn5g-fed-v1.3/docker-compose', '\$', 5) + mySSH.command('python3 ./core-network.py '+self.cfgUnDeploy, '\$', 60) mySSH.command('docker volume prune --force || true', '\$', 60) time.sleep(2) - mySSH.command('tshark -r /tmp/oai-cn5g.pcap | egrep --colour=never "Tracking area update" ','\$', 30) + mySSH.command('tshark -r /tmp/oai-cn5g-v1.3.pcap | egrep --colour=never "Tracking area update" ','\$', 30) result = re.search('Tracking area update request', mySSH.getBefore()) if result is not None: message = 'UE requested ' + str(mySSH.getBefore().count('Tracking area update request')) + 'Tracking area update request(s)' @@ -828,8 +833,8 @@ class EPCManagement(): mySSH.command('zip mme.log.zip mme_check_run.*', '\$', 60) elif re.match('OAICN5G', self.Type, re.IGNORECASE): mySSH.command('cd ' + self.SourceCodePath + '/logs','\$', 5) - mySSH.command('cp -f /tmp/oai-cn5g.pcap .','\$', 30) - mySSH.command('zip mme.log.zip oai-amf.log oai-nrf.log oai-cn5g.pcap','\$', 30) + mySSH.command('cp -f /tmp/oai-cn5g-v1.3.pcap .','\$', 30) + mySSH.command('zip mme.log.zip oai-amf.log oai-nrf.log oai-cn5g*.pcap','\$', 30) mySSH.command('mv mme.log.zip ' + self.SourceCodePath + '/scripts','\$', 30) elif re.match('OAI', self.Type, re.IGNORECASE) or re.match('OAI-Rel14-CUPS', self.Type, re.IGNORECASE): mySSH.command('zip mme.log.zip mme*.log', '\$', 60) diff --git a/ci-scripts/flatten_image.py b/ci-scripts/flatten_image.py new file mode 100644 index 0000000000..aef5bfccad --- /dev/null +++ b/ci-scripts/flatten_image.py @@ -0,0 +1,116 @@ +""" + 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 argparse +import re +import subprocess +import sys + +def main() -> None: + args = _parse_args() + status = perform_flattening(args.tag) + sys.exit(status) + +def _parse_args() -> argparse.Namespace: + parser = argparse.ArgumentParser(description='Flattening Image') + + parser.add_argument( + '--tag', '-t', + action='store', + required=True, + help='Image Tag in image-name:image tag format', + ) + return parser.parse_args() + +def perform_flattening(tag): + # First detect which docker/podman command to use + cli = '' + image_prefix = '' + cmd = 'which podman || true' + podman_check = subprocess.check_output(cmd, shell=True, universal_newlines=True) + if re.search('podman', podman_check.strip()): + cli = 'sudo podman' + image_prefix = 'localhost/' + if cli == '': + cmd = 'which docker || true' + docker_check = subprocess.check_output(cmd, shell=True, universal_newlines=True) + if re.search('docker', docker_check.strip()): + cli = 'docker' + image_prefix = '' + if cli == '': + print ('No docker / podman installed: quitting') + return -1 + print (f'Flattening {tag}') + + # Creating a container + cmd = cli + ' run --name test-flatten --entrypoint /bin/true -d ' + tag + print (cmd) + subprocess.check_output(cmd, shell=True, universal_newlines=True) + + # Export / Import trick + cmd = cli + ' export test-flatten | ' + cli + ' import ' + # Bizarro syntax issue with podman + if cli == 'docker': + cmd += ' --change "ENV PATH /usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin" ' + else: + cmd += ' --change "ENV PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin" ' + if re.search('oai-enb', tag): + cmd += ' --change "WORKDIR /opt/oai-enb" ' + cmd += ' --change "EXPOSE 2152/udp" ' + cmd += ' --change "EXPOSE 36412/udp" ' + cmd += ' --change "EXPOSE 36422/udp" ' + cmd += ' --change "CMD [\\"/opt/oai-enb/bin/lte-softmodem.Rel15\\", \\"-O\\", \\"/opt/oai-enb/etc/enb.conf\\"]" ' + cmd += ' --change "ENTRYPOINT [\\"/opt/oai-enb/bin/entrypoint.sh\\"]" ' + if re.search('oai-gnb', tag): + cmd += ' --change "WORKDIR /opt/oai-gnb" ' + cmd += ' --change "EXPOSE 2152/udp" ' + cmd += ' --change "EXPOSE 36422/udp" ' + cmd += ' --change "CMD [\\"/opt/oai-gnb/bin/nr-softmodem.Rel15\\", \\"-O\\", \\"/opt/oai-gnb/etc/gnb.conf\\"]" ' + cmd += ' --change "ENTRYPOINT [\\"/opt/oai-gnb/bin/entrypoint.sh\\"]" ' + if re.search('oai-lte-ue', tag): + cmd += ' --change "WORKDIR /opt/oai-lte-ue" ' + cmd += ' --change "CMD [\\"/opt/oai-lte-ue/bin/lte-uesoftmodem.Rel15\\"]" ' + cmd += ' --change "ENTRYPOINT [\\"/opt/oai-lte-ue/bin/entrypoint.sh\\"]" ' + if re.search('oai-nr-ue', tag): + cmd += ' --change "WORKDIR /opt/oai-nr-ue" ' + cmd += ' --change "CMD [\\"/opt/oai-nr-ue/bin/nr-uesoftmodem.Rel15\\", \\"-O\\", \\"/opt/oai-nr-ue/etc/nr-ue.conf\\"]" ' + cmd += ' --change "ENTRYPOINT [\\"/opt/oai-nr-ue/bin/entrypoint.sh\\"]" ' + if re.search('oai-lte-ru', tag): + cmd += ' --change "WORKDIR /opt/oai-lte-ru" ' + cmd += ' --change "CMD [\\"/opt/oai-lte-ru/bin/oairu.Rel15\\", \\"-O\\", \\"/opt/oai-lte-ru/etc/rru.conf\\"]" ' + cmd += ' --change "ENTRYPOINT [\\"/opt/oai-lte-ru/bin/entrypoint.sh\\"]" ' + if re.search('oai-physim', tag): + cmd += ' --change "WORKDIR /opt/oai-physim" ' + cmd += ' - ' + image_prefix + tag + print (cmd) + subprocess.check_output(cmd, shell=True, universal_newlines=True) + + # Remove container + cmd = cli + ' rm -f test-flatten' + print (cmd) + subprocess.check_output(cmd, shell=True, universal_newlines=True) + + # At this point the original image is a dangling image. + # CI pipeline will clean up (`image prune --force`) + return 0 + +if __name__ == '__main__': + main() diff --git a/ci-scripts/main.py b/ci-scripts/main.py index aa7d512b3d..adef885942 100644 --- a/ci-scripts/main.py +++ b/ci-scripts/main.py @@ -49,7 +49,7 @@ import cls_physim1 #class PhySim for physical simulators deploy and run import sshconnection import epc import ran -import html +import cls_oai_html #----------------------------------------------------------- @@ -376,6 +376,16 @@ def GetParametersFromXML(action): if (string_field is not None): EPC.yamlPath = string_field + elif action == 'Initialize_5GCN': + string_field = test.findtext('args') + if (string_field is not None): + EPC.cfgDeploy = string_field + + elif action == 'Terminate_5GCN': + string_field = test.findtext('args') + if (string_field is not None): + EPC.cfgUnDeploy = string_field + elif action == 'Deploy_Object' or action == 'Undeploy_Object': eNB_instance=test.findtext('eNB_instance') if (eNB_instance is None): @@ -391,7 +401,7 @@ def GetParametersFromXML(action): if (string_field is not None): CONTAINERS.yamlPath[CONTAINERS.eNB_instance] = string_field - elif action == 'DeployGenObject' or action == 'UndeployGenObject': + elif action == 'DeployGenObject' or action == 'UndeployGenObject' or action == 'StatsFromGenObject': string_field=test.findtext('yaml_path') if (string_field is not None): CONTAINERS.yamlPath[0] = string_field @@ -508,7 +518,7 @@ CiTestObj = cls_oaicitest.OaiCiTest() SSH = sshconnection.SSHConnection() EPC = epc.EPCManagement() RAN = ran.RANManagement() -HTML = html.HTMLManagement() +HTML = cls_oai_html.HTMLManagement() CONTAINERS = cls_containerize.Containerize() SCA = cls_static_code_analysis.StaticCodeAnalysis() PHYSIM = cls_physim1.PhySim() @@ -769,19 +779,19 @@ 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 == '192.168.18.210': + if EPC.IPAddress == '172.21.16.136': CONTAINERS.CheckAndAddRoute('porcepix', EPC.IPAddress, EPC.UserName, EPC.Password) - if CONTAINERS.eNBIPAddress == '192.168.18.194': + if CONTAINERS.eNBIPAddress == '172.21.16.127': CONTAINERS.CheckAndAddRoute('asterix', CONTAINERS.eNBIPAddress, CONTAINERS.eNBUserName, CONTAINERS.eNBPassword) - if CONTAINERS.eNB1IPAddress == '192.168.18.194': + if CONTAINERS.eNB1IPAddress == '172.21.16.127': CONTAINERS.CheckAndAddRoute('asterix', CONTAINERS.eNB1IPAddress, CONTAINERS.eNB1UserName, CONTAINERS.eNB1Password) - if CONTAINERS.eNBIPAddress == '192.168.18.193': + if CONTAINERS.eNBIPAddress == '172.21.16.128': CONTAINERS.CheckAndAddRoute('obelix', CONTAINERS.eNBIPAddress, CONTAINERS.eNBUserName, CONTAINERS.eNBPassword) - if CONTAINERS.eNB1IPAddress == '192.168.18.193': + if CONTAINERS.eNB1IPAddress == '172.21.16.128': CONTAINERS.CheckAndAddRoute('obelix', CONTAINERS.eNB1IPAddress, CONTAINERS.eNB1UserName, CONTAINERS.eNB1Password) - if CONTAINERS.eNBIPAddress == '192.168.18.209': + if CONTAINERS.eNBIPAddress == '172.21.16.137': CONTAINERS.CheckAndAddRoute('nepes', CONTAINERS.eNBIPAddress, CONTAINERS.eNBUserName, CONTAINERS.eNBPassword) - if CONTAINERS.eNB1IPAddress == '192.168.18.209': + if CONTAINERS.eNB1IPAddress == '172.21.16.137': CONTAINERS.CheckAndAddRoute('nepes', CONTAINERS.eNB1IPAddress, CONTAINERS.eNB1UserName, CONTAINERS.eNB1Password) CiTestObj.FailReportCnt = 0 @@ -789,7 +799,7 @@ elif re.match('^TesteNB$', mode, re.IGNORECASE) or re.match('^TestUE$', mode, re HTML.startTime=int(round(time.time() * 1000)) while CiTestObj.FailReportCnt < CiTestObj.repeatCounts[0] and RAN.prematureExit: RAN.prematureExit=False - # At every iteratin of the retry loop, a separator will be added + # At every iteration of the retry loop, a separator will be added # pass CiTestObj.FailReportCnt as parameter of HTML.CreateHtmlRetrySeparator HTML.CreateHtmlRetrySeparator(CiTestObj.FailReportCnt) for test_case_id in todo_tests: @@ -913,6 +923,10 @@ elif re.match('^TesteNB$', mode, re.IGNORECASE) or re.match('^TestUE$', mode, re CONTAINERS.UndeployObject(HTML, RAN) elif action == 'Cppcheck_Analysis': SCA.CppCheckAnalysis(HTML) + elif action == 'LicenceAndFormattingCheck': + ret = SCA.LicenceAndFormattingCheck(HTML) + if ret != 0: + RAN.prematureExit = True elif action == 'Deploy_Run_PhySim': PHYSIM.Deploy_PhySim(HTML, RAN) elif action == 'DeployGenObject': @@ -931,6 +945,8 @@ elif re.match('^TesteNB$', mode, re.IGNORECASE) or re.match('^TestUE$', mode, re CONTAINERS.IperfFromContainer(HTML, RAN) if CONTAINERS.exitStatus==1: RAN.prematureExit = True + elif action == 'StatsFromGenObject': + CONTAINERS.StatsFromGenObject(HTML) else: sys.exit('Invalid class (action) from xml') if RAN.prematureExit: diff --git a/ci-scripts/oai-ci-vm-tool b/ci-scripts/oai-ci-vm-tool index 5ee653c8e1..8363c91461 100755 --- a/ci-scripts/oai-ci-vm-tool +++ b/ci-scripts/oai-ci-vm-tool @@ -174,7 +174,7 @@ function variant__v1__enb_usrp { BUILD_OPTIONS="--eNB -w USRP --mu" VM_MEMORY=3072 } - + function variant__v2__basic_sim { NB_PATTERN_FILES=11 BUILD_OPTIONS="--eNB --UE" @@ -200,28 +200,28 @@ function variant__v4__cppcheck { function variant__v5__gnb_usrp { VM_MEMORY=10240 VM_CPU=8 - NB_PATTERN_FILES=7 + NB_PATTERN_FILES=6 BUILD_OPTIONS="--gNB -w USRP" } function variant__v6__nr_ue_usrp { VM_MEMORY=4096 VM_CPU=4 - NB_PATTERN_FILES=7 + NB_PATTERN_FILES=6 BUILD_OPTIONS="--nrUE -w USRP" } function variant__v7__enb_ethernet { VM_MEMORY=4096 ARCHIVES_LOC=enb_eth - NB_PATTERN_FILES=7 + NB_PATTERN_FILES=6 BUILD_OPTIONS="--eNB -w USRP" } function variant__v8__ue_ethernet { VM_MEMORY=4096 ARCHIVES_LOC=ue_eth - NB_PATTERN_FILES=11 + NB_PATTERN_FILES=10 BUILD_OPTIONS="--UE -w USRP" } diff --git a/ci-scripts/provideUniqueImageTag.py b/ci-scripts/provideUniqueImageTag.py new file mode 100644 index 0000000000..88d51ca6f8 --- /dev/null +++ b/ci-scripts/provideUniqueImageTag.py @@ -0,0 +1,54 @@ +import argparse +import os +import re +import subprocess +import sys + +AUTH_SERVICE = 'registry.docker.io' +AUTH_SCOPE = 'repository:oaisoftwarealliance/oai-enb:pull' + +def main() -> None: + args = _parse_args() + + cmd = 'curl -fsSL "https://auth.docker.io/token?service=' + AUTH_SERVICE + '&scope=' + AUTH_SCOPE + '" 2>/dev/null | jq --raw-output ".token"' + token = subprocess.check_output(cmd, shell=True, universal_newlines=True) + token = str(token).strip() + cmd = 'curl -fsSL -H "Authorization: Bearer ' + token + '" "https://index.docker.io/v2/oaisoftwarealliance/oai-enb/tags/list" 2>/dev/null | jq .' + listOfTags = subprocess.check_output(cmd, shell=True, universal_newlines=True) + + foundTag = False + for tag in listOfTags.split('\n'): + if re.search('"' + args.start_tag + '"', tag) is not None: + foundTag = True + + if not foundTag: + print (args.start_tag) + sys.exit(0) + + proposedVariants = ['a', 'b', 'c', 'd'] + for variant in proposedVariants: + foundTag = False + currentVariant = variant + for tag in listOfTags.split('\n'): + if re.search('"' + args.start_tag + variant + '"', tag) is not None: + foundTag = True + break + if not foundTag: + break + + if not foundTag: + print (args.start_tag + currentVariant) + +def _parse_args() -> argparse.Namespace: + parser = argparse.ArgumentParser(description='Provides an unique new image tag for DockerHub') + + parser.add_argument( + '--start_tag', '-st', + action='store', + required=True, + help='Proposed Starting Tag', + ) + return parser.parse_args() + +if __name__ == '__main__': + main() diff --git a/ci-scripts/ran.py b/ci-scripts/ran.py index e5d0f10ee4..680763d247 100644 --- a/ci-scripts/ran.py +++ b/ci-scripts/ran.py @@ -372,36 +372,30 @@ class RANManagement(): else: pcapfile_prefix="gnb_" mySSH.open(lIpAddr, lUserName, lPassWord) - mySSH.command('ip addr show | awk -f /tmp/active_net_interfaces.awk | egrep -v "lo|tun"', '\$', 5) - result = re.search('interfaceToUse=(?P[a-zA-Z0-9\-\_]+)done', mySSH.getBefore()) - if result is not None: - eth_interface = result.group('eth_interface') - fltr = 'port 38412 or port 36412 or port 36422' # NGAP, S1AP, X2AP - logging.debug('\u001B[1m Launching tshark on interface ' + eth_interface + ' with filter "' + fltr + '"\u001B[0m') - pcapfile = pcapfile_prefix + self.testCase_id + '_log.pcap' - mySSH.command('echo ' + lPassWord + ' | sudo -S rm -f /tmp/' + pcapfile , '\$', 5) - mySSH.command('echo $USER; nohup sudo -E tshark -i ' + eth_interface + ' -f "' + fltr + '" -w /tmp/' + pcapfile + ' > /dev/null 2>&1 &','\$', 5) + eth_interface = 'any' + fltr = 'sctp' + logging.debug('\u001B[1m Launching tshark on interface ' + eth_interface + ' with filter "' + fltr + '"\u001B[0m') + pcapfile = pcapfile_prefix + self.testCase_id + '_log.pcap' + mySSH.command('echo ' + lPassWord + ' | sudo -S rm -f /tmp/' + pcapfile , '\$', 5) + mySSH.command('echo $USER; nohup sudo -E tshark -i ' + eth_interface + ' -f "' + fltr + '" -w /tmp/' + pcapfile + ' > /dev/null 2>&1 &','\$', 5) mySSH.close() # If tracer options is on, running tshark on EPC side and capture traffic b/ EPC and eNB - result = re.search('T_stdout', str(self.Initialize_eNB_args)) - if (result is not None): + if EPC.IPAddress != "none": localEpcIpAddr = EPC.IPAddress localEpcUserName = EPC.UserName localEpcPassword = EPC.Password mySSH.open(localEpcIpAddr, localEpcUserName, localEpcPassword) - mySSH.command('ip addr show | awk -f /tmp/active_net_interfaces.awk | egrep -v "lo|tun"', '\$', 5) - result = re.search('interfaceToUse=(?P[a-zA-Z0-9\-\_]+)done', mySSH.getBefore()) - if result is not None: - eth_interface = result.group('eth_interface') - fltr = 'port 38412 or port 36412 or port 36422' # NGAP, S1AP, X2AP - logging.debug('\u001B[1m Launching tshark on interface ' + eth_interface + ' with filter "' + fltr + '"\u001B[0m') - self.epcPcapFile = 'enb_' + self.testCase_id + '_s1log.pcap' - mySSH.command('echo ' + localEpcPassword + ' | sudo -S rm -f /tmp/' + self.epcPcapFile , '\$', 5) - mySSH.command('echo $USER; nohup sudo tshark -f "host ' + lIpAddr +'" -i ' + eth_interface + ' -f "' + fltr + '" -w /tmp/' + self.epcPcapFile + ' > /tmp/tshark.log 2>&1 &', localEpcUserName, 5) + eth_interface = 'any' + fltr = 'sctp' + logging.debug('\u001B[1m Launching tshark on interface ' + eth_interface + ' with filter "' + fltr + '"\u001B[0m') + self.epcPcapFile = 'enb_' + self.testCase_id + '_s1log.pcap' + mySSH.command('echo ' + localEpcPassword + ' | sudo -S rm -f /tmp/' + self.epcPcapFile , '\$', 5) + mySSH.command('echo $USER; nohup sudo tshark -f "host ' + lIpAddr +'" -i ' + eth_interface + ' -f "' + fltr + '" -w /tmp/' + self.epcPcapFile + ' > /tmp/tshark.log 2>&1 &', localEpcUserName, 5) mySSH.close() + mySSH.open(lIpAddr, lUserName, lPassWord) mySSH.command('cd ' + lSourcePath, '\$', 5) # Initialize_eNB_args usually start with -O and followed by the location in repository @@ -485,7 +479,7 @@ class RANManagement(): mySSH.command('chmod 775 ./my-lte-softmodem-run' + str(self.eNB_instance) + '.sh', '\$', 5) mySSH.command('echo ' + lPassWord + ' | sudo -S rm -Rf enb_' + self.testCase_id + '.log', '\$', 5) - mySSH.command('echo $USER; nohup sudo -E ./my-lte-softmodem-run' + str(self.eNB_instance) + '.sh > ' + lSourcePath + '/cmake_targets/enb_' + self.testCase_id + '.log 2>&1 &', lUserName, 10) + mySSH.command('echo $USER; nohup sudo -E stdbuf -o0 ./my-lte-softmodem-run' + str(self.eNB_instance) + '.sh > ' + lSourcePath + '/cmake_targets/enb_' + self.testCase_id + '.log 2>&1 &', lUserName, 10) #stats monitoring during runtime @@ -519,23 +513,19 @@ class RANManagement(): logging.error('\u001B[1;37;41m eNB/gNB/ocp-eNB logging system did not show got sync! \u001B[0m') HTML.CreateHtmlTestRow(self.air_interface[self.eNB_instance] + ' -O ' + config_file + extra_options, 'KO', CONST.ALL_PROCESSES_OK) # In case of T tracer recording, we need to kill tshark on EPC side - result = re.search('T_stdout', str(self.Initialize_eNB_args)) - if (result is not None): - localEpcIpAddr = EPC.IPAddress - localEpcUserName = EPC.UserName - localEpcPassword = EPC.Password - mySSH.open(localEpcIpAddr, localEpcUserName, localEpcPassword) - logging.debug('\u001B[1m Stopping tshark \u001B[0m') - mySSH.command('echo ' + localEpcPassword + ' | sudo -S killall --signal SIGKILL tshark', '\$', 5) - if self.epcPcapFile != '': - time.sleep(0.5) - mySSH.command('echo ' + localEpcPassword + ' | sudo -S chmod 666 /tmp/' + self.epcPcapFile, '\$', 5) - mySSH.close() - time.sleep(1) - if self.epcPcapFile != '': - copyin_res = mySSH.copyin(localEpcIpAddr, localEpcUserName, localEpcPassword, '/tmp/' + self.epcPcapFile, '.') - if (copyin_res == 0): - mySSH.copyout(lIpAddr, lUserName, lPassWord, self.epcPcapFile, lSourcePath + '/cmake_targets/.') + localEpcIpAddr = EPC.IPAddress + localEpcUserName = EPC.UserName + localEpcPassword = EPC.Password + mySSH.open(localEpcIpAddr, localEpcUserName, localEpcPassword) + logging.debug('\u001B[1m Stopping tshark \u001B[0m') + mySSH.command('echo ' + localEpcPassword + ' | sudo -S killall --signal SIGKILL tshark', '\$', 5) + if self.epcPcapFile != '': + mySSH.command('echo ' + localEpcPassword + ' | sudo -S chmod 666 /tmp/' + self.epcPcapFile, '\$', 5) + mySSH.close() + if self.epcPcapFile != '': + copyin_res = mySSH.copyin(localEpcIpAddr, localEpcUserName, localEpcPassword, '/tmp/' + self.epcPcapFile, '.') + if (copyin_res == 0): + mySSH.copyout(lIpAddr, lUserName, lPassWord, self.epcPcapFile, lSourcePath + '/cmake_targets/.') self.prematureExit = True return else: @@ -752,11 +742,11 @@ class RANManagement(): mySSH.command('echo ' + self.eNBPassword + ' | sudo -S mv /tmp/enb_*.pcap .','\$',20) mySSH.command('echo ' + self.eNBPassword + ' | sudo -S mv /tmp/gnb_*.pcap .','\$',20) mySSH.command('echo ' + self.eNBPassword + ' | sudo -S rm -f enb.log.zip', '\$', 5) - mySSH.command('echo ' + self.eNBPassword + ' | sudo -S zip enb.log.zip enb*.log enb_*record.raw enb_*.pcap gnb_*.pcap enb_*txt physim_*.log *stats.log *monitor.pickle *monitor*.png ping*.log.png log/*/*.log log/*/*.pcap', '\$', 60) + mySSH.command('echo ' + self.eNBPassword + ' | sudo -S zip enb.log.zip enb*.log enb_*record.raw enb_*.pcap gnb_*.pcap enb_*txt physim_*.log *stats.log *monitor.pickle *monitor*.png ping*.log* iperf*.log log/*/*.log log/*/*.pcap', '\$', 60) result = re.search('core.\d+', mySSH.getBefore()) if result is not None: mySSH.command('echo ' + self.eNBPassword + ' | sudo -S zip enb.log.zip core* ran_build/build/{lte,nr}-softmodem', '\$', 60) # add core and executable to zip - mySSH.command('echo ' + self.eNBPassword + ' | sudo -S rm enb*.log core* enb_*record.raw enb_*.pcap gnb_*.pcap enb_*txt physim_*.log *stats.log *monitor.pickle *monitor*.png ping*.log.png log/*/*.log log/*/*.pcap', '\$', 15) + mySSH.command('echo ' + self.eNBPassword + ' | sudo -S rm enb*.log core* enb_*record.raw enb_*.pcap gnb_*.pcap enb_*txt physim_*.log *stats.log *monitor.pickle *monitor*.png ping*.log* iperf*.log log/*/*.log log/*/*.pcap', '\$', 15) mySSH.close() def AnalyzeLogFile_eNB(self, eNBlogFile, HTML, checkers={}): @@ -822,6 +812,8 @@ class RANManagement(): RealTimeProcessingIssue = False DLRetxIssue = False ULRetxIssue = False + nrRrcRcfgComplete = 0 + harqFeedbackPast = 0 line_cnt=0 #log file line counter for line in enb_log_file.readlines(): @@ -995,8 +987,25 @@ class RANManagement(): for k in keys: result = re.search(k, line) if result is not None: + ue_prefix = 'ue0' + ue_res = re.search('UE ID 1|UE 1:', line) + if ue_res is not None: + ue_prefix = 'ue1' + ue_res = re.search('UE ID 2|UE 2:', line) + if ue_res is not None: + ue_prefix = 'ue2' + ue_res = re.search('UE ID 3|UE 3:', line) + if ue_res is not None: + ue_prefix = 'ue3' #remove 1- all useless char before relevant info (ulsch or dlsch) 2- trailing char - dlsch_ulsch_stats[k]=re.sub(r'^.*\]\s+', r'' , line.rstrip()) + dlsch_ulsch_stats[ue_prefix+k]=re.sub(r'^.*\]\s+', r'' , line.rstrip()) + + result = re.search('Received NR_RRCReconfigurationComplete from UE', str(line)) + if result is not None: + nrRrcRcfgComplete += 1 + result = re.search('HARQ feedback is in the past', str(line)) + if result is not None: + harqFeedbackPast += 1 #count "problem receiving samples" msg @@ -1085,6 +1094,14 @@ class RANManagement(): statMsg = nodeB_prefix + 'NB ran with TX Write thread enabled' logging.debug('\u001B[1;30;43m ' + statMsg + ' \u001B[0m') htmleNBFailureMsg += statMsg + '\n' + if nrRrcRcfgComplete > 0: + statMsg = nodeB_prefix + 'NB showed ' + str(nrRrcRcfgComplete) + ' "Received NR_RRCReconfigurationComplete from UE" message(s)' + logging.debug('\u001B[1;30;43m ' + statMsg + ' \u001B[0m') + htmleNBFailureMsg += statMsg + '\n' + if harqFeedbackPast > 0: + statMsg = nodeB_prefix + 'NB showed ' + str(harqFeedbackPast) + ' "HARQ feedback is in the past" message(s)' + logging.debug('\u001B[1;30;43m ' + statMsg + ' \u001B[0m') + htmleNBFailureMsg += statMsg + '\n' #FR1 NSA test : add new markers to make sure gNB is used if NSA_RAPROC_PUSCH_check: statMsg = '[RAPROC] PUSCH with TC_RNTI message check for ' + nodeB_prefix + 'NB : PASS ' diff --git a/ci-scripts/ran_dashboard/Hdashboard.py b/ci-scripts/ran_dashboard/Hdashboard.py index 1b65c7af4f..993d0dded8 100644 --- a/ci-scripts/ran_dashboard/Hdashboard.py +++ b/ci-scripts/ran_dashboard/Hdashboard.py @@ -528,15 +528,15 @@ class Dashboard: editable_mr = project.mergerequests.get(int(mr)) mr_notes = editable_mr.notes.list(all=True) - body = 'Consolidated Test Results
'+\ - 'Tested CommitID: ' + commit + '
' + body = '[Consolidated Test Results](https://oaitestdashboard.s3.eu-west-1.amazonaws.com/MR'+mr+'/index.html)\\\n' + body += 'Tested CommitID: ' + commit + '\\\n' for i in range(0,n_tests): jobname = args[4*i] buildurl = args[4*i+1] buildid = args[4*i+2] status = args[4*i+3] - body += jobname+', status is '+status+', ('+buildid+')
' + body += jobname+': **'+status+'** ([' + buildid + '](' + buildurl + '))\\\n' #create new note mr_note = editable_mr.notes.create({ diff --git a/ci-scripts/reportBuildLocally.sh b/ci-scripts/reportBuildLocally.sh index 8b6db9261a..bcd3e2f7fe 100755 --- a/ci-scripts/reportBuildLocally.sh +++ b/ci-scripts/reportBuildLocally.sh @@ -574,7 +574,6 @@ function report_build { summary_table_row "OAI ETHERNET transport - Release 15" ./archives/enb_eth/oai_eth_transpro.Rel15.txt "Built target oai_eth_transpro" ./enb_eth_row3.html summary_table_row "Parameters Lib Config - Release 15" ./archives/enb_eth/params_libconfig.Rel15.txt "Built target params_libconfig" ./enb_eth_row4.html summary_table_row "RF Simulator - Release 15" ./archives/enb_eth/rfsimulator.Rel15.txt "Built target rfsimulator" ./enb_eth_row5.html - summary_table_row "TCP OAI Bridge - Release 15" ./archives/enb_eth/tcp_bridge_oai.Rel15.txt "Built target tcp_bridge_oai" ./enb_eth_row6.html summary_table_row "OAI USRP device if - Release 15" ./archives/enb_eth/oai_usrpdevif.Rel15.txt "Built target oai_usrpdevif" ./enb_eth_row7.html summary_table_footer @@ -584,7 +583,6 @@ function report_build { summary_table_row "OAI ETHERNET transport - Release 15" ./archives/ue_eth/oai_eth_transpro.Rel15.txt "Built target oai_eth_transpro" ./ue_eth_row3.html summary_table_row "Parameters Lib Config - Release 15" ./archives/ue_eth/params_libconfig.Rel15.txt "Built target params_libconfig" ./ue_eth_row4.html summary_table_row "RF Simulator - Release 15" ./archives/ue_eth/rfsimulator.Rel15.txt "Built target rfsimulator" ./ue_eth_row5.html - summary_table_row "TCP OAI Bridge - Release 15" ./archives/ue_eth/tcp_bridge_oai.Rel15.txt "Built target tcp_bridge_oai" ./ue_eth_row6.html summary_table_row "Conf 2 UE Data - Release 15" ./archives/ue_eth/conf2uedata.Rel15.txt "Built target conf2uedata" ./ue_eth_row7.html summary_table_row "NVRAM - Release 15" ./archives/ue_eth/nvram.Rel15.txt "Built target nvram" ./ue_eth_row8.html summary_table_row "UE IP - Release 15" ./archives/ue_eth/ue_ip.Rel15.txt "Built target ue_ip" ./ue_eth_row9.html @@ -592,20 +590,6 @@ function report_build { summary_table_row "OAI USRP device if - Release 15" ./archives/ue_eth/oai_usrpdevif.Rel15.txt "Built target oai_usrpdevif" ./ue_eth_row9b.html summary_table_footer - summary_table_header "OAI Build: 4G LTE basic simulator option" ./archives/basic_sim - summary_table_row "LTE SoftModem - Release 15" ./archives/basic_sim/lte-softmodem.Rel15.txt "Built target lte-softmodem" ./basic_sim_row1.html - summary_table_row "LTE UE SoftModem - Release 15" ./archives/basic_sim/lte-uesoftmodem.Rel15.txt "Built target lte-uesoftmodem" ./basic_sim_row2.htm - summary_table_row "Coding - Release 15" ./archives/basic_sim/coding.Rel15.txt "Built target coding" ./basic_sim_row3.html - summary_table_row "Conf 2 UE data - Release 15" ./archives/basic_sim/conf2uedata.Rel15.txt "Built target conf2uedata" ./basic_sim_row4.html - summary_table_row "OAI ETHERNET transport - Release 15" ./archives/basic_sim/oai_eth_transpro.Rel15.txt "Built target oai_eth_transpro" ./basic_sim_row5.html - summary_table_row "Parameters Lib Config - Release 15" ./archives/basic_sim/params_libconfig.Rel15.txt "Built target params_libconfig" ./basic_sim_row7.html - summary_table_row "RF Simulator - Release 15" ./archives/basic_sim/rfsimulator.Rel15.txt "Built target rfsimulator" ./basic_sim_row9.html - summary_table_row "TCP Bridge - Release 15" ./archives/basic_sim/tcp_bridge_oai.Rel15.txt "Built target tcp_bridge_oai" ./basic_sim_row10.html - summary_table_row "UE IP - Release 15" ./archives/basic_sim/ue_ip.Rel15.txt "Built target ue_ip" ./basic_sim_row11.html - summary_table_row "USIM - Release 15" ./archives/basic_sim/usim.Rel15.txt "Built target usim" ./basic_sim_row12.html - summary_table_row "NVRAM - Release 15" ./archives/basic_sim/nvram.Rel15.txt "Built target nvram" ./basic_sim_row13.html - summary_table_footer - if [ -f archives/gnb_usrp/nr-softmodem.Rel15.txt ] then summary_table_header "OAI Build: 5G NR gNB -- USRP option" ./archives/gnb_usrp @@ -658,13 +642,6 @@ function report_build { cat $DETAILS_TABLE >> ./build_results.html done fi - if [ -f ./basic_sim_row1.html ] || [ -f ./basic_sim_row2.html ] || [ -f ./basic_sim_row3.html ] || [ -f ./basic_sim_row4.html ] || [ -f ./basic_sim_row5.html ] - then - for DETAILS_TABLE in `ls ./basic_sim_row*.html` - do - cat $DETAILS_TABLE >> ./build_results.html - done - fi if [ -f ./gnb_usrp_row1.html ] || [ -f ./gnb_usrp_row2.html ] || [ -f ./gnb_usrp_row3.html ] || [ -f ./gnb_usrp_row4.html ] then for DETAILS_TABLE in `ls ./gnb_usrp_row*.html` diff --git a/ci-scripts/reportTestLocally.sh b/ci-scripts/reportTestLocally.sh index d22bfe177a..c137fcdcbb 100755 --- a/ci-scripts/reportTestLocally.sh +++ b/ci-scripts/reportTestLocally.sh @@ -250,156 +250,6 @@ function report_test { echo " " >> ./test_simulator_results.html echo "

Test Summary

" >> ./test_simulator_results.html - ARCHIVES_LOC=archives/basic_sim/test - if [ -d $ARCHIVES_LOC ] - then - echo "

4G LTE Basic Simulator Check

" >> ./test_simulator_results.html - - if [ -f $ARCHIVES_LOC/test_final_status.log ] - then - if [ `grep -c TEST_OK $ARCHIVES_LOC/test_final_status.log` -eq 1 ] - then - echo "
" >> ./test_simulator_results.html - echo " TEST was SUCCESSFUL " >> ./test_simulator_results.html - echo "
" >> ./test_simulator_results.html - else - echo "
" >> ./test_simulator_results.html - echo " TEST was a FAILURE! " >> ./test_simulator_results.html - echo "
" >> ./test_simulator_results.html - fi - else - echo "
" >> ./test_simulator_results.html - echo " COULD NOT DETERMINE TEST FINAL STATUS! " >> ./test_simulator_results.html - echo "
" >> ./test_simulator_results.html - fi - - echo " " >> ./test_simulator_results.html - echo "
" >> ./test_simulator_results.html - echo " " >> ./test_simulator_results.html - echo " " >> ./test_simulator_results.html - echo " " >> ./test_simulator_results.html - echo " " >> ./test_simulator_results.html - echo " " >> ./test_simulator_results.html - echo " " >> ./test_simulator_results.html - echo " " >> ./test_simulator_results.html - - TRANS_MODES=("fdd" "tdd") - BW_CASES=(05 10 20) - for TMODE in ${TRANS_MODES[@]} - do - echo " " >> ./test_simulator_results.html - if [[ $TMODE =~ .*fdd.* ]] - then - echo " " >> ./test_simulator_results.html - else - echo " " >> ./test_simulator_results.html - fi - echo " " >> ./test_simulator_results.html - for BW in ${BW_CASES[@]} - do - ENB_LOG=$ARCHIVES_LOC/${TMODE}_${BW}MHz_enb.log - UE_LOG=`echo $ENB_LOG | sed -e "s#enb#ue#"` - if [ -f $ENB_LOG ] && [ -f $UE_LOG ] - then - NAME_ENB=`echo $ENB_LOG | sed -e "s#$ARCHIVES_LOC/##"` - NAME_UE=`echo $UE_LOG | sed -e "s#$ARCHIVES_LOC/##"` - echo " " >> ./test_simulator_results.html - echo " " >> ./test_simulator_results.html - echo " " >> ./test_simulator_results.html - NB_ENB_GOT_SYNC=`egrep -c "got sync" $ENB_LOG` - NB_UE_GOT_SYNC=`egrep -c "got sync" $UE_LOG` - NB_ENB_SYNCED_WITH_UE=`egrep -c "got UE capabilities for UE" $ENB_LOG` - if [ $NB_ENB_GOT_SYNC -gt 0 ] && [ $NB_UE_GOT_SYNC -eq 2 ] && [ $NB_ENB_SYNCED_WITH_UE -eq 1 ] - then - echo " " >> ./test_simulator_results.html - else - echo " " >> ./test_simulator_results.html - fi - echo " " >> ./test_simulator_results.html - echo " " >> ./test_simulator_results.html - fi - PING_LOGS=`ls $ARCHIVES_LOC/${TMODE}_${BW}MHz_ping_ue.txt 2> /dev/null` - analyzePingFiles - - IPERF_TESTS=`ls $ARCHIVES_LOC/${TMODE}_${BW}*iperf*client*txt 2> /dev/null` - analyzeIperfFiles - done - done - - echo "
Log File NameCommandStatusStatistics
Test in FDDTest in TDD
$NAME_ENB --- $NAME_UEN/AOKKO
" >> ./test_simulator_results.html
-                    if [ $NB_ENB_GOT_SYNC -gt 0 ]
-                    then
-                        echo "- eNB --> got sync" >> ./test_simulator_results.html
-                    else
-                        echo "- eNB NEVER got sync" >> ./test_simulator_results.html
-                    fi
-                    if [ $NB_UE_GOT_SYNC -eq 2 ]
-                    then
-                        echo "- UE --> got sync" >> ./test_simulator_results.html
-                    else
-                        echo "- UE NEVER got sync" >> ./test_simulator_results.html
-                    fi
-                    if [ $NB_ENB_SYNCED_WITH_UE -eq 1 ]
-                    then
-                        echo "- UE attached to eNB" >> ./test_simulator_results.html
-                    else
-                        echo "- UE NEVER attached to eNB" >> ./test_simulator_results.html
-                    fi
-                    NB_SEGFAULT_ENB=`egrep -i -c "Segmentation Fault" $ENB_LOG`
-                    if [ $NB_SEGFAULT_ENB -ne 0 ]
-                    then
-                        echo "- eNB --> Segmentation Fault" >> ./test_simulator_results.html
-                    fi
-                    NB_SEGFAULT_UE=`egrep -i -c "Segmentation Fault" $UE_LOG`
-                    if [ $NB_SEGFAULT_UE -ne 0 ]
-                    then
-                        echo "- UE --> Segmentation Fault" >> ./test_simulator_results.html
-                    fi
-                    NB_ASSERTION_ENB=`egrep -i -c "Assertion" $ENB_LOG`
-                    if [ $NB_ASSERTION_ENB -ne 0 ]
-                    then
-                        echo "- eNB --> Assertion" >> ./test_simulator_results.html
-                        awk 'BEGIN{assertion=10}{if(assertion < 3){print "    " $0; assertion++};if ($0 ~/Assertion/){print "    " $0;assertion=1}}END{}' $ENB_LOG >> ./test_simulator_results.html
-                    fi
-                    NB_ASSERTION_UE=`egrep -i -c "Assertion" $UE_LOG`
-                    if [ $NB_ASSERTION_UE -ne 0 ]
-                    then
-                        echo "- eNB --> Assertion" >> ./test_simulator_results.html
-                        awk 'BEGIN{assertion=10}{if(assertion < 3){print "    " $0; assertion++};if ($0 ~/Assertion/){print "    " $0;assertion=1}}END{}' $UE_LOG >> ./test_simulator_results.html
-                    fi
-                    echo "        
" >> ./test_simulator_results.html - echo "
" >> ./test_simulator_results.html - fi - - if [ -e $JENKINS_WKSP/flexran/flexran_build_complete.txt ] - then - echo "

4G LTE Basic Simulator + FlexRan Controller Check

" >> ./test_simulator_results.html - echo "
" >> ./test_simulator_results.html - echo " TEST was SUCCESSFUL " >> ./test_simulator_results.html - echo "
" >> ./test_simulator_results.html - echo " " >> ./test_simulator_results.html - echo "
" >> ./test_simulator_results.html - echo " " >> ./test_simulator_results.html - echo " " >> ./test_simulator_results.html - echo " " >> ./test_simulator_results.html - echo " " >> ./test_simulator_results.html - echo " " >> ./test_simulator_results.html - - FLEXRAN_QUERIES=`ls $ARCHIVES_LOC/flexran_ctl_query_*log` - for QUERY in $FLEXRAN_QUERIES - do - echo " " >> ./test_simulator_results.html - NAME=`echo $QUERY | sed -e "s#$ARCHIVES_LOC/##"` - echo " " >> ./test_simulator_results.html - echo " " >> ./test_simulator_results.html - echo " " >> ./test_simulator_results.html - done - echo "
Log File NameJSON Query Response
$NAME
" >> ./test_simulator_results.html
-            egrep -v "LOG_NAME|\-\-\-\-\-" $QUERY >> ./test_simulator_results.html
-            echo "        
" >> ./test_simulator_results.html - echo "
" >> ./test_simulator_results.html - fi - ARCHIVES_LOC=archives/rf_sim/test if [ -d $ARCHIVES_LOC ] then diff --git a/ci-scripts/runTestOnVM.sh b/ci-scripts/runTestOnVM.sh index b5abb5ff45..2472ffe3bc 100755 --- a/ci-scripts/runTestOnVM.sh +++ b/ci-scripts/runTestOnVM.sh @@ -36,137 +36,6 @@ function test_usage { command_options_usage } -function start_basic_sim_enb { - local LOC_VM_IP_ADDR=$2 - local LOC_EPC_IP_ADDR=$3 - local LOC_LOG_FILE=$4 - local LOC_NB_RBS=$5 - local LOC_CONF_FILE=$6 - local LOC_FLEXRAN_CTL_IP_ADRR=$7 - echo "cd /home/ubuntu/tmp" > $1 - echo "echo \"sudo apt-get --yes --quiet install daemon \"" >> $1 - echo "sudo apt-get --yes install daemon >> /home/ubuntu/tmp/cmake_targets/log/daemon-install.txt 2>&1" >> $1 - echo "echo \"export ENODEB=1\"" >> $1 - echo "export ENODEB=1" >> $1 - echo "echo \"source oaienv\"" >> $1 - echo "source oaienv" >> $1 - echo "cd ci-scripts/conf_files/" >> $1 - echo "cp $LOC_CONF_FILE ci-$LOC_CONF_FILE" >> $1 - echo "sed -i -e 's#N_RB_DL.*=.*;#N_RB_DL = $LOC_NB_RBS;#' -e 's#CI_MME_IP_ADDR#$LOC_EPC_IP_ADDR#' -e 's#CI_ENB_IP_ADDR#$LOC_VM_IP_ADDR#' ci-$LOC_CONF_FILE" >> $1 - if [[ $LOC_FLEXRAN_CTL_IP_ADRR =~ .*none.* ]] - then - echo "sed -i -e 's#CI_FLEXRAN_CTL_IP_ADDR#127.0.0.1#' ci-$LOC_CONF_FILE" >> $1 - else - echo "sed -i -e 's#FLEXRAN_ENABLED = .*no.*;#FLEXRAN_ENABLED = \"yes\";#' -e 's#CI_FLEXRAN_CTL_IP_ADDR#$LOC_FLEXRAN_CTL_IP_ADRR#' ci-$LOC_CONF_FILE" >> $1 - fi - echo "echo \"grep N_RB_DL ci-$LOC_CONF_FILE\"" >> $1 - echo "grep N_RB_DL ci-$LOC_CONF_FILE | sed -e 's#N_RB_DL.*=#N_RB_DL =#'" >> $1 - echo "echo \"cd /home/ubuntu/tmp/cmake_targets/ran_build/build/\"" >> $1 - echo "sudo chmod 777 /home/ubuntu/tmp/cmake_targets/ran_build/" >> $1 - echo "sudo chmod 777 /home/ubuntu/tmp/cmake_targets/ran_build/build/" >> $1 - echo "cd /home/ubuntu/tmp/cmake_targets/ran_build/build/" >> $1 - echo "echo \"ulimit -c unlimited && ./lte-softmodem -O /home/ubuntu/tmp/ci-scripts/conf_files/ci-$LOC_CONF_FILE --log_config.global_log_options level,nocolor,time --basicsim\" > ./my-lte-softmodem-run.sh " >> $1 - echo "chmod 775 ./my-lte-softmodem-run.sh" >> $1 - echo "cat ./my-lte-softmodem-run.sh" >> $1 - echo "if [ -e /home/ubuntu/tmp/cmake_targets/log/$LOC_LOG_FILE ]; then sudo sudo rm -f /home/ubuntu/tmp/cmake_targets/log/$LOC_LOG_FILE; fi" >> $1 - echo "sudo -E daemon --inherit --unsafe --name=enb_daemon --chdir=/home/ubuntu/tmp/cmake_targets/ran_build/build -o /home/ubuntu/tmp/cmake_targets/log/$LOC_LOG_FILE ./my-lte-softmodem-run.sh" >> $1 - - ssh -T -o StrictHostKeyChecking=no ubuntu@$LOC_VM_IP_ADDR < $1 - rm $1 - sleep 5 - - local i="0" - echo "egrep -c \"got sync\" /home/ubuntu/tmp/cmake_targets/log/$LOC_LOG_FILE" > $1 - while [ $i -lt 10 ] - do - CONNECTED=`ssh -T -o StrictHostKeyChecking=no ubuntu@$LOC_VM_IP_ADDR < $1` - if [ $CONNECTED -ne 0 ] - then - i="100" - else - sleep 5 - i=$[$i+1] - fi - done - ENB_SYNC=0 - echo "echo \"free -m\"" > $1 - echo "free -m" >> $1 - ssh -T -o StrictHostKeyChecking=no ubuntu@$LOC_VM_IP_ADDR < $1 - rm $1 - if [ $i -lt 50 ] - then - ENB_SYNC=0 - echo "Basic-Sim eNB: eNB did NOT got sync" - else - echo "Basic-Sim eNB: eNB GOT SYNC --> waiting for UE to connect" - fi - sleep 5 -} - -function start_basic_sim_ue { - local LOC_UE_LOG_FILE=$3 - local LOC_NB_RBS=$4 - local LOC_FREQUENCY=$5 - echo "echo \"cd /home/ubuntu/tmp/cmake_targets/ran_build/build/\"" > $1 - echo "sudo chmod 777 /home/ubuntu/tmp/cmake_targets/ran_build/build/" >> $1 - echo "cd /home/ubuntu/tmp/cmake_targets/ran_build/build" >> $1 - echo "echo \"./lte-uesoftmodem -C ${LOC_FREQUENCY}000000 -r $LOC_NB_RBS --log_config.global_log_options nocolor,line_num,level --basicsim\" > ./my-lte-uesoftmodem-run.sh" >> $1 - echo "chmod 775 ./my-lte-uesoftmodem-run.sh" >> $1 - echo "cat ./my-lte-uesoftmodem-run.sh" >> $1 - echo "if [ -e /home/ubuntu/tmp/cmake_targets/log/$LOC_UE_LOG_FILE ]; then sudo sudo rm -f /home/ubuntu/tmp/cmake_targets/log/$LOC_UE_LOG_FILE; fi" >> $1 - echo "sudo -E daemon --inherit --unsafe --name=ue_daemon --chdir=/home/ubuntu/tmp/cmake_targets/ran_build/build -o /home/ubuntu/tmp/cmake_targets/log/$LOC_UE_LOG_FILE ./my-lte-uesoftmodem-run.sh" >> $1 - - ssh -T -o StrictHostKeyChecking=no ubuntu@$2 < $1 - rm $1 - - local i="0" - echo "ifconfig oaitun_ue1 | egrep -c \"inet addr\"" > $1 - while [ $i -lt 10 ] - do - sleep 5 - CONNECTED=`ssh -T -o StrictHostKeyChecking=no ubuntu@$2 < $1` - if [ $CONNECTED -eq 1 ] - then - i="100" - else - i=$[$i+1] - fi - done - UE_SYNC=1 - rm $1 - if [ $i -lt 50 ] - then - UE_SYNC=0 - echo "Basic-Sim UE: oaitun_ue1 is DOWN and/or NOT CONFIGURED" - else - echo "Basic-Sim UE: oaitun_ue1 is UP and CONFIGURED" - fi - i="0" - echo "egrep -c \"Generating RRCConnectionReconfigurationComplete\" /home/ubuntu/tmp/cmake_targets/log/$LOC_UE_LOG_FILE" > $1 - while [ $i -lt 10 ] - do - CONNECTED=`ssh -T -o StrictHostKeyChecking=no ubuntu@$2 < $1` - if [ $CONNECTED -ne 0 ] - then - i="100" - else - sleep 5 - i=$[$i+1] - fi - done - echo "echo \"free -m\"" > $1 - echo "free -m" >> $1 - ssh -T -o StrictHostKeyChecking=no ubuntu@$2 < $1 - rm $1 - if [ $i -lt 50 ] - then - UE_SYNC=0 - echo "Basic-Sim UE: UE did NOT complete RRC Connection" - else - echo "Basic-Sim UE: UE did COMPLETE RRC Connection" - fi -} - function get_ue_ip_addr { local LOC_IF_ID=$3 echo "ifconfig oaitun_ue${LOC_IF_ID} | egrep \"inet addr\" | sed -e 's#^.*inet addr:##' -e 's# P-t-P:.*\$##'" > $1 @@ -417,7 +286,6 @@ function check_iperf { local LOC_REQ_BW_MINUS_TWO=`echo "$LOC_REQ_BW - 2" | bc -l` local LOC_REQ_BW_MINUS_THREE=`echo "$LOC_REQ_BW - 3" | bc -l` local LOC_IS_DL=`echo $LOC_BASE_LOG | grep -c _dl` - local LOC_IS_BASIC_SIM=`echo $LOC_BASE_LOG | grep -c basic_sim` local LOC_IS_RF_SIM=`echo $LOC_BASE_LOG | grep -c rf_sim` local LOC_IS_NR=`echo $LOC_BASE_LOG | grep -c _106prb` if [ -f ${LOC_BASE_LOG}_client.txt ] @@ -438,28 +306,17 @@ function check_iperf { local EFFECTIVE_BANDWIDTH=`tail -n3 ${LOC_BASE_LOG}_client.txt | egrep "Kbits/sec" | sed -e "s#^.*KBytes *##" -e "s#sec.*#sec#"` local BW_PREFIX="K" fi - if [ $LOC_IS_DL -eq 1 ] && [ $LOC_IS_BASIC_SIM -eq 1 ] + if [[ $EFFECTIVE_BANDWIDTH =~ .*${LOC_REQ_BW}.*${BW_PREFIX}bits.* ]] || [[ $EFFECTIVE_BANDWIDTH =~ .*${LOC_REQ_BW_MINUS_ONE}.*${BW_PREFIX}bits.* ]] then - if [[ $EFFECTIVE_BANDWIDTH =~ .*${LOC_REQ_BW}.*${BW_PREFIX}bits.* ]] || [[ $EFFECTIVE_BANDWIDTH =~ .*${LOC_REQ_BW_MINUS_ONE}.*${BW_PREFIX}bits.* ]] || [[ $EFFECTIVE_BANDWIDTH =~ .*${LOC_REQ_BW_MINUS_TWO}.*${BW_PREFIX}bits.* ]] || [[ $EFFECTIVE_BANDWIDTH =~ .*${LOC_REQ_BW_MINUS_THREE}.*${BW_PREFIX}bits.* ]] + if [ $LOC_IS_DL -eq 1 ] then echo "got requested DL bandwidth: $EFFECTIVE_BANDWIDTH" else - echo "got LESS than requested DL bandwidth: $EFFECTIVE_BANDWIDTH" - IPERF_STATUS=-1 + echo "got requested UL bandwidth: $EFFECTIVE_BANDWIDTH" fi else - if [[ $EFFECTIVE_BANDWIDTH =~ .*${LOC_REQ_BW}.*${BW_PREFIX}bits.* ]] || [[ $EFFECTIVE_BANDWIDTH =~ .*${LOC_REQ_BW_MINUS_ONE}.*${BW_PREFIX}bits.* ]] - then - if [ $LOC_IS_DL -eq 1 ] - then - echo "got requested DL bandwidth: $EFFECTIVE_BANDWIDTH" - else - echo "got requested UL bandwidth: $EFFECTIVE_BANDWIDTH" - fi - else - echo "got LESS than requested DL bandwidth: $EFFECTIVE_BANDWIDTH" - IPERF_STATUS=-1 - fi + echo "got LESS than requested DL bandwidth: $EFFECTIVE_BANDWIDTH" + IPERF_STATUS=-1 fi fi else @@ -526,22 +383,6 @@ function full_terminate { sleep 10 } -function full_basic_sim_destroy { - if [ $KEEP_VM_ALIVE -eq 0 ] - then - echo "############################################################" - echo "Destroying VMs" - echo "############################################################" - uvt-kvm destroy $VM_NAME - ssh-keygen -R $VM_IP_ADDR - if [ -e $JENKINS_WKSP/flexran/flexran_build_complete.txt ] - then - uvt-kvm destroy $FLEXRAN_CTL_VM_NAME - ssh-keygen -R $FLEXRAN_CTL_VM_IP_ADDR - fi - fi -} - function install_epc_on_vm { local LOC_EPC_VM_NAME=$1 local LOC_EPC_VM_CMDS=$2 @@ -744,35 +585,6 @@ function terminate_epc { fi } -function start_flexran_ctrl { - echo "cd /home/ubuntu/tmp" > $1 - echo "if [ -f cmake_targets/log/flexran_ctl_run.log ]; then rm -f cmake_targets/log/flexran_ctl_run.log cmake_targets/log/flexran_ctl_query*.log; fi" >> $1 - echo "echo \" sudo build/rt_controller -c log_config/basic_log\"" >> $1 - echo "nohup sudo build/rt_controller -c log_config/basic_log > cmake_targets/log/flexran_ctl_run.log 2>&1 &" >> $1 - ssh -T -o StrictHostKeyChecking=no ubuntu@$2 < $1 - rm $1 - sleep 10 -} - -function stop_flexran_ctrl { - echo "echo \"sudo killall --signal SIGKILL rt_controller\"" > $1 - echo "sudo killall --signal SIGKILL rt_controller" > $1 - ssh -T -o StrictHostKeyChecking=no ubuntu@$2 < $1 - rm $1 - sleep 2 -} - -function query_flexran_ctrl_status { - local LOC_MESSAGE=$3 - echo "cd /home/ubuntu/tmp" > $1 - echo "echo \"------------------------------------------------------------\" > cmake_targets/log/flexran_ctl_query_${LOC_MESSAGE}.log" >> $1 - echo "echo \"LOG_NAME: $LOC_MESSAGE\" >> cmake_targets/log/flexran_ctl_query_${LOC_MESSAGE}.log" >> $1 - echo "echo \"------------------------------------------------------------\" >> cmake_targets/log/flexran_ctl_query_${LOC_MESSAGE}.log" >> $1 - echo "curl http://localhost:9999/stats | jq '.' | tee -a cmake_targets/log/flexran_ctl_query_${LOC_MESSAGE}.log" >> $1 - ssh -T -o StrictHostKeyChecking=no ubuntu@$2 < $1 - rm $1 -} - function build_ue_on_separate_folder { echo "mkdir tmp-ue" > $1 echo "cd tmp-ue" >> $1 @@ -1480,6 +1292,11 @@ function run_test_on_vm { echo "This VM test type is no longer supported in the pipeline framework" return fi + if [[ (( "$RUN_OPTIONS" == "complex" ) && ( $VM_NAME =~ .*-basic-sim.* )) ]] + then + echo "This VM test type is no longer supported in the pipeline framework" + return + fi if [[ (( "$RUN_OPTIONS" == "complex" ) && ( $VM_NAME =~ .*-rf-sim.* )) ]] then ENB_VM_NAME=`echo $VM_NAME | sed -e "s#rf-sim#enb-ethernet#"` @@ -1667,234 +1484,6 @@ function run_test_on_vm { fi fi - if [[ "$RUN_OPTIONS" == "complex" ]] && [[ $VM_NAME =~ .*-basic-sim.* ]] - then - PING_STATUS=0 - IPERF_STATUS=0 - if [ -d $ARCHIVES_LOC ] - then - rm -Rf $ARCHIVES_LOC - fi - mkdir --parents $ARCHIVES_LOC - - # Creating a VM for EPC and installing SW - EPC_VM_NAME=`echo $VM_NAME | sed -e "s#basic-sim#epc#"` - EPC_VM_CMDS=${EPC_VM_NAME}_cmds.txt - LTEBOX=0 - if [[ "$EPC_IPADDR" == "" ]] - then - # Creating a VM for EPC and installing SW - install_epc_on_vm $EPC_VM_NAME $EPC_VM_CMDS - EPC_VM_IP_ADDR=`uvt-kvm ip $EPC_VM_NAME` - - # Starting EPC - start_epc $EPC_VM_NAME $EPC_VM_CMDS $EPC_VM_IP_ADDR - else - echo "We will use EPC on $EPC_IPADDR" - EPC_VM_IP_ADDR=$EPC_IPADDR - fi - - # Retrieve EPC real IP address - retrieve_real_epc_ip_addr $EPC_VM_NAME $EPC_VM_CMDS $EPC_VM_IP_ADDR - - TRANS_MODES=("fdd" "tdd") - BW_CASES=(05 10 20) - - for TMODE in ${TRANS_MODES[@]} - do - for BW in ${BW_CASES[@]} - do - # Not Running in TDD-20MHz : too unstable - if [[ $TMODE =~ .*tdd.* ]] && [[ $BW =~ .*20.* ]]; then continue; fi - - if [[ $BW =~ .*05.* ]]; then PRB=25; fi - if [[ $BW =~ .*10.* ]]; then PRB=50; fi - if [[ $BW =~ .*20.* ]]; then PRB=100; fi - if [[ $TMODE =~ .*fdd.* ]]; then FREQUENCY=2680; else FREQUENCY=2350; fi - - echo "############################################################" - echo "Starting the eNB in ${TMODE}-${BW}MHz mode" - echo "############################################################" - CURRENT_ENB_LOG_FILE=${TMODE}_${BW}MHz_enb.log - start_basic_sim_enb $VM_CMDS $VM_IP_ADDR $EPC_VM_IP_ADDR $CURRENT_ENB_LOG_FILE $PRB lte-${TMODE}-basic-sim.conf none - - echo "############################################################" - echo "Starting the UE in ${TMODE}-${BW}MHz mode" - echo "############################################################" - CURRENT_UE_LOG_FILE=${TMODE}_${BW}MHz_ue.log - start_basic_sim_ue $VM_CMDS $VM_IP_ADDR $CURRENT_UE_LOG_FILE $PRB $FREQUENCY - if [ $UE_SYNC -eq 0 ] - then - echo "Problem w/ eNB and UE not syncing" - full_terminate - STATUS=-1 - continue - fi - get_ue_ip_addr $VM_CMDS $VM_IP_ADDR 1 - - echo "############################################################" - echo "Pinging the UE" - echo "############################################################" - PING_LOG_FILE=${TMODE}_${BW}MHz_ping_ue.txt - ping_ue_ip_addr $EPC_VM_CMDS $EPC_VM_IP_ADDR $UE_IP_ADDR $PING_LOG_FILE 0 - scp -o StrictHostKeyChecking=no ubuntu@$EPC_VM_IP_ADDR:/home/ubuntu/$PING_LOG_FILE $ARCHIVES_LOC - check_ping_result $ARCHIVES_LOC/$PING_LOG_FILE 20 - - # Not more testing in any TDD : too unstable - if [[ $TMODE =~ .*tdd.* ]] && [[ $BW =~ .*05.* ]]; then full_terminate; continue; fi - if [[ $TMODE =~ .*tdd.* ]] && [[ $BW =~ .*10.* ]]; then full_terminate; continue; fi - if [[ $TMODE =~ .*tdd.* ]] && [[ $BW =~ .*20.* ]]; then full_terminate; continue; fi - echo "############################################################" - echo "Iperf DL" - echo "############################################################" - if [[ $TMODE =~ .*fdd.* ]] - then - if [[ $BW =~ .*20.* ]]; then THROUGHPUT=12; else THROUGHPUT=10; fi - else - THROUGHPUT=6 - fi - CURR_IPERF_LOG_BASE=${TMODE}_${BW}MHz_iperf_dl - generic_iperf $VM_CMDS $VM_IP_ADDR $UE_IP_ADDR $EPC_VM_CMDS $EPC_VM_IP_ADDR $REAL_EPC_IP_ADDR $THROUGHPUT $CURR_IPERF_LOG_BASE 0 0 - scp -o StrictHostKeyChecking=no ubuntu@$EPC_VM_IP_ADDR:/home/ubuntu/${CURR_IPERF_LOG_BASE}_client.txt $ARCHIVES_LOC - scp -o StrictHostKeyChecking=no ubuntu@$VM_IP_ADDR:/home/ubuntu/${CURR_IPERF_LOG_BASE}_server.txt $ARCHIVES_LOC - check_iperf $ARCHIVES_LOC/$CURR_IPERF_LOG_BASE $THROUGHPUT - - # Not more testing in FDD-20MHz : too unstable - if [[ $TMODE =~ .*fdd.* ]] && [[ $BW =~ .*20.* ]]; then full_terminate; continue; fi - echo "############################################################" - echo "Iperf UL" - echo "############################################################" - THROUGHPUT=2 - CURR_IPERF_LOG_BASE=${TMODE}_${BW}MHz_iperf_ul - generic_iperf $EPC_VM_CMDS $EPC_VM_IP_ADDR $REAL_EPC_IP_ADDR $VM_CMDS $VM_IP_ADDR $UE_IP_ADDR $THROUGHPUT $CURR_IPERF_LOG_BASE 0 0 - scp -o StrictHostKeyChecking=no ubuntu@$EPC_VM_IP_ADDR:/home/ubuntu/${CURR_IPERF_LOG_BASE}_server.txt $ARCHIVES_LOC - scp -o StrictHostKeyChecking=no ubuntu@$VM_IP_ADDR:/home/ubuntu/${CURR_IPERF_LOG_BASE}_client.txt $ARCHIVES_LOC - check_iperf $ARCHIVES_LOC/$CURR_IPERF_LOG_BASE $THROUGHPUT - - full_terminate - - done - done - - if [ -d $JENKINS_WKSP/flexran ] - then - echo "############################################################" - echo "Flexran testing is possible" - echo "############################################################" - local j="0" - while [ $j -lt 20 ] - do - if [ -e $JENKINS_WKSP/flexran/flexran_build_complete.txt ] - then - echo "Found an proper flexran controller vm build" - j="100" - else - j=$[$j+1] - sleep 30 - fi - done - if [ $j -lt 50 ] - then - echo "ERROR: compiling flexran controller on vm went wrong" - terminate_epc $EPC_VM_CMDS $EPC_VM_IP_ADDR - echo "TEST_KO" > $ARCHIVES_LOC/test_final_status.log - STATUS=-1 - return - fi - FLEXRAN_CTL_VM_NAME=`echo $VM_NAME | sed -e "s#basic-sim#flexran-rtc#"` - FLEXRAN_CTL_VM_CMDS=`echo $VM_CMDS | sed -e "s#cmds#flexran-rtc-cmds#"` - IS_FLEXRAN_VM_ALIVE=`uvt-kvm list | grep -c $FLEXRAN_CTL_VM_NAME` - if [ $IS_FLEXRAN_VM_ALIVE -eq 0 ] - then - echo "ERROR: Flexran Ctl VM is not alive" - terminate_epc $EPC_VM_CMDS $EPC_VM_IP_ADDR - full_basic_sim_destroy - echo "TEST_KO" > $ARCHIVES_LOC/test_final_status.log - STATUS=-1 - return - fi - uvt-kvm wait $FLEXRAN_CTL_VM_NAME --insecure - FLEXRAN_CTL_VM_IP_ADDR=`uvt-kvm ip $FLEXRAN_CTL_VM_NAME` - - echo "$FLEXRAN_CTL_VM_NAME has for IP addr = $FLEXRAN_CTL_VM_IP_ADDR" - echo "FLEXRAN_CTL_VM_CMDS = $FLEXRAN_CTL_VM_CMDS" - echo "############################################################" - echo "Starting the FLEXRAN CONTROLLER" - echo "############################################################" - start_flexran_ctrl $FLEXRAN_CTL_VM_CMDS $FLEXRAN_CTL_VM_IP_ADDR - query_flexran_ctrl_status $FLEXRAN_CTL_VM_CMDS $FLEXRAN_CTL_VM_IP_ADDR 01_no_enb_connected - - echo "############################################################" - echo "Starting the eNB in FDD-5MHz mode with Flexran ON" - echo "############################################################" - CURRENT_ENB_LOG_FILE=fdd_05fMHz_enb.log - start_basic_sim_enb $VM_CMDS $VM_IP_ADDR $EPC_VM_IP_ADDR $CURRENT_ENB_LOG_FILE 25 lte-fdd-basic-sim.conf $FLEXRAN_CTL_VM_IP_ADDR - query_flexran_ctrl_status $FLEXRAN_CTL_VM_CMDS $FLEXRAN_CTL_VM_IP_ADDR 02_enb_connected - - echo "############################################################" - echo "Starting the UE in FDD-5MHz mode" - echo "############################################################" - CURRENT_UE_LOG_FILE=fdd_05fMHz_ue.log - start_basic_sim_ue $VM_CMDS $VM_IP_ADDR $CURRENT_UE_LOG_FILE 25 2680 - if [ $UE_SYNC -eq 0 ] - then - echo "Problem w/ eNB and UE not syncing" - terminate_enb_ue_basic_sim $VM_CMDS $VM_IP_ADDR 0 - scp -o StrictHostKeyChecking=no ubuntu@$VM_IP_ADDR:/home/ubuntu/tmp/cmake_targets/log/$CURRENT_ENB_LOG_FILE $ARCHIVES_LOC - scp -o StrictHostKeyChecking=no ubuntu@$VM_IP_ADDR:/home/ubuntu/tmp/cmake_targets/log/$CURRENT_UE_LOG_FILE $ARCHIVES_LOC - recover_core_dump $VM_CMDS $VM_IP_ADDR $ARCHIVES_LOC/$CURRENT_ENB_LOG_FILE $ARCHIVES_LOC - terminate_epc $EPC_VM_CMDS $EPC_VM_IP_ADDR - stop_flexran_ctrl $FLEXRAN_CTL_VM_CMDS $FLEXRAN_CTL_VM_IP_ADDR - echo "TEST_KO" > $ARCHIVES_LOC/test_final_status.log - STATUS=-1 - return - fi - query_flexran_ctrl_status $FLEXRAN_CTL_VM_CMDS $FLEXRAN_CTL_VM_IP_ADDR 03_enb_ue_connected - get_ue_ip_addr $VM_CMDS $VM_IP_ADDR 1 - - sleep 30 - echo "############################################################" - echo "Terminate enb/ue simulators" - echo "############################################################" - terminate_enb_ue_basic_sim $VM_CMDS $VM_IP_ADDR 0 - scp -o StrictHostKeyChecking=no ubuntu@$VM_IP_ADDR:/home/ubuntu/tmp/cmake_targets/log/$CURRENT_ENB_LOG_FILE $ARCHIVES_LOC - scp -o StrictHostKeyChecking=no ubuntu@$VM_IP_ADDR:/home/ubuntu/tmp/cmake_targets/log/$CURRENT_UE_LOG_FILE $ARCHIVES_LOC - recover_core_dump $VM_CMDS $VM_IP_ADDR $ARCHIVES_LOC/$CURRENT_ENB_LOG_FILE $ARCHIVES_LOC - sleep 10 - - echo "############################################################" - echo "Stopping the FLEXRAN CONTROLLER" - echo "############################################################" - stop_flexran_ctrl $FLEXRAN_CTL_VM_CMDS $FLEXRAN_CTL_VM_IP_ADDR - scp -o StrictHostKeyChecking=no ubuntu@$FLEXRAN_CTL_VM_IP_ADDR:/home/ubuntu/tmp/cmake_targets/log/flexran_ctl_*.log $ARCHIVES_LOC - fi - - echo "############################################################" - echo "Terminate EPC" - echo "############################################################" - - if [[ "$EPC_IPADDR" == "" ]] - then - terminate_epc $EPC_VM_CMDS $EPC_VM_IP_ADDR - fi - - full_basic_sim_destroy - - echo "############################################################" - echo "Checking run status" - echo "############################################################" - - if [ $PING_STATUS -ne 0 ]; then STATUS=-1; fi - if [ $IPERF_STATUS -ne 0 ]; then STATUS=-1; fi - - if [ $STATUS -eq 0 ] - then - echo "TEST_OK" > $ARCHIVES_LOC/test_final_status.log - else - echo "TEST_KO" > $ARCHIVES_LOC/test_final_status.log - fi - fi - if [[ "$RUN_OPTIONS" == "complex" ]] && [[ $VM_NAME =~ .*-rf-sim.* ]] then PING_STATUS=0 @@ -2310,7 +1899,7 @@ function run_test_on_vm { CURRENT_NR_UE_LOG_FILE=tdd_${PRB}prb_${CN_CONFIG}_ue_sa_test.log #last argument = 2 is to enable --sa for SA test for 106PRB start_rf_sim_nr_ue $NR_UE_VM_CMDS $NR_UE_VM_IP_ADDR $GNB_VM_IP_ADDR $CURRENT_NR_UE_LOG_FILE $PRB $FREQUENCY $S1_NOS1_CFG 2 - if [ $NR_UE_SYNC -eq 0 ] + if [ $GNB_SYNC -eq 0 ] || [ $NR_UE_SYNC -eq 0 ] then echo "Problem w/ gNB and NR-UE not syncing" terminate_enb_ue_basic_sim $NR_UE_VM_CMDS $NR_UE_VM_IP_ADDR 2 @@ -2343,13 +1932,19 @@ function run_test_on_vm { echo "SA test NOT OK" echo "try_cnt = " $try_cnt try_cnt=$((try_cnt+1)) - SA_106PRB_STATUS = -1 + SA_106PRB_STATUS=-1 else echo "SA test OK" try_cnt=$((try_cnt+10)) - SA_106PRB_STATUS = 0 + SA_106PRB_STATUS=0 fi done + #manage SYNC issue after try_cnt + if [ $SYNC_STATUS -ne 0 ] + then + echo "SA 106PRB test NOT OK, NOT SYNC'ED" + SA_106PRB_STATUS=-1 + fi ########### end SA test sleep 30 @@ -2393,7 +1988,7 @@ function run_test_on_vm { CURRENT_NR_UE_LOG_FILE=tdd_${PRB}prb_${CN_CONFIG}_ue_sa_test.log #last argument = 3 is to enable --sa for SA test for 24PRB start_rf_sim_nr_ue $NR_UE_VM_CMDS $NR_UE_VM_IP_ADDR $GNB_VM_IP_ADDR $CURRENT_NR_UE_LOG_FILE $PRB $FREQUENCY $S1_NOS1_CFG 3 - if [ $NR_UE_SYNC -eq 0 ] + if [ $GNB_SYNC -eq 0 ] || [ $NR_UE_SYNC -eq 0 ] then echo "Problem w/ gNB and NR-UE not syncing" terminate_enb_ue_basic_sim $NR_UE_VM_CMDS $NR_UE_VM_IP_ADDR 2 @@ -2426,13 +2021,19 @@ function run_test_on_vm { echo "SA test NOT OK" echo "try_cnt = " $try_cnt try_cnt=$((try_cnt+1)) - SA_24PRB_STATUS = -1 + SA_24PRB_STATUS=-1 else echo "SA test OK" try_cnt=$((try_cnt+10)) - SA_24PRB_STATUS = 0 + SA_24PRB_STATUS=0 fi done + #manage SYNC issue after try_cnt + if [ $SYNC_STATUS -ne 0 ] + then + echo "SA 24PRB test NOT OK, NOT SYNC'ED" + SA_24PRB_STATUS=-1 + fi ########### end SA test sleep 30 @@ -2481,7 +2082,7 @@ function run_test_on_vm { CURRENT_NR_UE_LOG_FILE=tdd_${PRB}prb_${CN_CONFIG}_ue_ra_fr2_test.log #last argument = 1 is to enable --do-ra for RA test start_rf_sim_nr_ue $NR_UE_VM_CMDS $NR_UE_VM_IP_ADDR $GNB_VM_IP_ADDR $CURRENT_NR_UE_LOG_FILE $PRB $FREQUENCY $S1_NOS1_CFG 1 - if [ $NR_UE_SYNC -eq 0 ] + if [ $GNB_SYNC -eq 0 ] || [ $NR_UE_SYNC -eq 0 ] then echo "Problem w/ gNB and NR-UE not syncing" terminate_enb_ue_basic_sim $NR_UE_VM_CMDS $NR_UE_VM_IP_ADDR 2 @@ -2521,6 +2122,12 @@ function run_test_on_vm { try_cnt=$((try_cnt+10)) fi done + #manage SYNC issue after try_cnt + if [ $SYNC_STATUS -ne 0 ] + then + echo "RA FR2 test NOT OK, NOT SYNC'ED" + RA_FR2_STATUS=-1 + fi ########### end RA FR2 test sleep 30 @@ -2583,7 +2190,7 @@ function run_test_on_vm { CURRENT_NR_UE_LOG_FILE=${TMODE}_${PRB}prb_${CN_CONFIG}_ue_ra_test.log #last argument = 1 is to enable --do-ra for RA test start_rf_sim_nr_ue $NR_UE_VM_CMDS $NR_UE_VM_IP_ADDR $GNB_VM_IP_ADDR $CURRENT_NR_UE_LOG_FILE $PRB $FREQUENCY $S1_NOS1_CFG 1 - if [ $NR_UE_SYNC -eq 0 ] + if [ $GNB_SYNC -eq 0 ] || [ $NR_UE_SYNC -eq 0 ] then echo "Problem w/ gNB and NR-UE not syncing" terminate_enb_ue_basic_sim $NR_UE_VM_CMDS $NR_UE_VM_IP_ADDR 2 @@ -2623,6 +2230,13 @@ function run_test_on_vm { try_cnt=$((try_cnt+10)) fi done + #manage SYNC issue after try_cnt + if [ $SYNC_STATUS -ne 0 ] + then + echo "RA FR1 test NOT OK, NOT SYNC'ED" + RA_FR1_STATUS=-1 + fi + done ########### end RA test @@ -2664,7 +2278,7 @@ function run_test_on_vm { echo "############################################################" CURRENT_NR_UE_LOG_FILE=${TMODE}_${PRB}prb_${CN_CONFIG}_ue.log start_rf_sim_nr_ue $NR_UE_VM_CMDS $NR_UE_VM_IP_ADDR $GNB_VM_IP_ADDR $CURRENT_NR_UE_LOG_FILE $PRB $FREQUENCY $S1_NOS1_CFG 0 - if [ $NR_UE_SYNC -eq 0 ] + if [ $GNB_SYNC -eq 0 ] || [ $NR_UE_SYNC -eq 0 ] then echo "Problem w/ gNB and NR-UE not syncing" terminate_enb_ue_basic_sim $NR_UE_VM_CMDS $NR_UE_VM_IP_ADDR 2 @@ -2743,6 +2357,13 @@ function run_test_on_vm { try_cnt=$((try_cnt+10)) fi done + #manage SYNC issue after try_cnt + if [ $SYNC_STATUS -ne 0 ] + then + echo "PHY test NOT OK, NOT SYNC'ED" + IPERF_STATUS=-1 + fi + done ######### end of loop full_l2_sim_destroy @@ -2756,7 +2377,6 @@ function run_test_on_vm { if [ $SA_24PRB_STATUS -ne 0 ]; then NR_STATUS=-1; fi if [ $RA_FR2_STATUS -ne 0 ]; then NR_STATUS=-1; fi if [ $RA_FR1_STATUS -ne 0 ]; then NR_STATUS=-1; fi - if [ $SYNC_STATUS -ne 0 ]; then NR_STATUS=-1; fi if [ $PING_STATUS -ne 0 ]; then NR_STATUS=-1; fi if [ $IPERF_STATUS -ne 0 ]; then NR_STATUS=-1; fi if [ $NR_STATUS -eq 0 ] diff --git a/ci-scripts/sshconnection.py b/ci-scripts/sshconnection.py index d5b4a4c83e..dca3daa817 100644 --- a/ci-scripts/sshconnection.py +++ b/ci-scripts/sshconnection.py @@ -56,6 +56,7 @@ class SSHConnection(): self.picocom_closure = True def open(self, ipaddress, username, password): + prompt = "#" if username == "root" else "\$" count = 0 connect_status = False while count < 4: @@ -68,7 +69,7 @@ class SSHConnection(): self.sshresponse = self.ssh.expect(['password:', username + '@']) if self.sshresponse == 0: self.ssh.sendline(password) - self.sshresponse = self.ssh.expect(['\$', 'Permission denied', 'password:', pexpect.EOF, pexpect.TIMEOUT]) + self.sshresponse = self.ssh.expect([prompt, 'Permission denied', 'password:', pexpect.EOF, pexpect.TIMEOUT]) if self.sshresponse == 0: count = 10 connect_status = True @@ -76,7 +77,7 @@ class SSHConnection(): logging.debug('self.sshresponse = ' + str(self.sshresponse)) elif self.sshresponse == 1: self.ssh.sendline(password) - self.sshresponse = self.ssh.expect(['\$', 'Permission denied', 'password:', pexpect.EOF, pexpect.TIMEOUT]) + self.sshresponse = self.ssh.expect([prompt, 'Permission denied', 'password:', pexpect.EOF, pexpect.TIMEOUT]) if self.sshresponse == 0: count = 10 connect_status = True @@ -84,7 +85,7 @@ class SSHConnection(): logging.debug('self.sshresponse = ' + str(self.sshresponse)) elif self.sshresponse == 2: # Checking if we are really on the remote client defined by its IP address - self.command('stdbuf -o0 ifconfig | egrep --color=never "inet addr:|inet "', '\$', 5) + self.command('stdbuf -o0 ifconfig | egrep --color=never "inet addr:|inet "', prompt, 5) result = re.search(str(ipaddress), str(self.ssh.before)) if result is None: self.close() @@ -100,7 +101,7 @@ class SSHConnection(): time.sleep(1) count += 1 if connect_status: - self.command('unset HISTFILE', '\$', 5, silent=True) + self.command('unset HISTFILE', prompt, 5, silent=True) else: sys.exit('SSH Connection Failed') self.ipaddress = ipaddress diff --git a/ci-scripts/stats_monitor_conf.yaml b/ci-scripts/stats_monitor_conf.yaml index 9a2ececd18..4e1f87ed17 100644 --- a/ci-scripts/stats_monitor_conf.yaml +++ b/ci-scripts/stats_monitor_conf.yaml @@ -25,7 +25,7 @@ gnb : L1 Rx processing: PUSCH inner-receiver: PUSCH decoding: - DL & UL scheduling timing stats: + DL & UL scheduling timing: UL Indication: graph : page1: @@ -45,5 +45,5 @@ gnb : page4: rt.PUSCH inner-receiver: rt.PUSCH decoding: - rt.DL & UL scheduling timing stats: + rt.DL & UL scheduling timing: rt.UL Indication: diff --git a/ci-scripts/waitBuildOnVM.sh b/ci-scripts/waitBuildOnVM.sh index 4a604a1fe9..73a8b558fe 100755 --- a/ci-scripts/waitBuildOnVM.sh +++ b/ci-scripts/waitBuildOnVM.sh @@ -47,7 +47,7 @@ function wait_on_vm_build { echo "ARCHIVES_LOC = $ARCHIVES_LOC" echo "BUILD_OPTIONS = $BUILD_OPTIONS" - if [[ "$VM_NAME" == *"-enb-usrp"* ]] || [[ "$VM_NAME" == *"-cppcheck"* ]] || [[ "$VM_NAME" == *"-phy-sim"* ]] + if [[ "$VM_NAME" == *"-enb-usrp"* ]] || [[ "$VM_NAME" == *"-cppcheck"* ]] || [[ "$VM_NAME" == *"-phy-sim"* ]] || [[ "$VM_NAME" == *"-basic-sim"* ]] || [[ "$VM_NAME" == *"-flexran-rtc"* ]] then echo "This VM type is no longer supported in the pipeline framework" return @@ -93,7 +93,7 @@ function wait_on_vm_build { } function check_on_vm_build { - if [[ "$VM_NAME" == *"-enb-usrp"* ]] || [[ "$VM_NAME" == *"-cppcheck"* ]] || [[ "$VM_NAME" == *"-phy-sim"* ]] + if [[ "$VM_NAME" == *"-enb-usrp"* ]] || [[ "$VM_NAME" == *"-cppcheck"* ]] || [[ "$VM_NAME" == *"-phy-sim"* ]] || [[ "$VM_NAME" == *"-basic-sim"* ]] || [[ "$VM_NAME" == *"-flexran-rtc"* ]] then echo "This VM type is no longer supported in the pipeline framework" return @@ -174,13 +174,13 @@ function check_on_vm_build { fi # If we were building the FlexRan Controller, flag-touch for basic-simulator to continue - if [[ "$VM_NAME" == *"-flexran-rtc"* ]] - then - if [[ $STATUS -eq 0 ]] - then - touch $JENKINS_WKSP/flexran/flexran_build_complete.txt - fi - fi + #if [[ "$VM_NAME" == *"-flexran-rtc"* ]] + #then + # if [[ $STATUS -eq 0 ]] + # then + # touch $JENKINS_WKSP/flexran/flexran_build_complete.txt + # fi + #fi if [[ "$VM_NAME" == *"-cppcheck"* ]] then diff --git a/ci-scripts/xml_class_list.yml b/ci-scripts/xml_class_list.yml index 9e33ee468d..b305aff424 100755 --- a/ci-scripts/xml_class_list.yml +++ b/ci-scripts/xml_class_list.yml @@ -46,3 +46,5 @@ - UndeployGenObject - PingFromContainer - IperfFromContainer + - StatsFromGenObject + - LicenceAndFormattingCheck diff --git a/ci-scripts/xml_files/container_5g_fdd_rfsim.xml b/ci-scripts/xml_files/container_5g_fdd_rfsim.xml index 61a2af9e54..b41dafb767 100644 --- a/ci-scripts/xml_files/container_5g_fdd_rfsim.xml +++ b/ci-scripts/xml_files/container_5g_fdd_rfsim.xml @@ -33,12 +33,10 @@ 000013 020011 020012 - 100011 - - + 100011 + @@ -104,7 +102,7 @@ rfsim5g-oai-ext-dn rfsim5g-oai-nr-ue -u -i 1 -s - -B 12.1.1.2 -c 192.168.72.135 -u -i 1 -t 30 -b 1M + -B 12.1.1.2 -c 192.168.72.135 -u -i 1 -t 30 -b 3M diff --git a/ci-scripts/xml_files/container_5g_l2sim_tdd.xml b/ci-scripts/xml_files/container_5g_l2sim_tdd.xml new file mode 100644 index 0000000000..be6b789b6b --- /dev/null +++ b/ci-scripts/xml_files/container_5g_l2sim_tdd.xml @@ -0,0 +1,115 @@ + + + l2sim-5gnr-tdd + Testing 5G NR L2 sim - TDD gNB + wrench + 2 + + 100001 + 000000 + 000001 + 000002 + 000003 + 000011 + 200000 + 020001 + 020002 + 200001 + 100001 + + + + + DeployGenObject + Deploy MySql Database + yaml_files/5g_l2sim_tdd + mysql + 1 + + + + DeployGenObject + Deploy OAI 5G CoreNetwork + yaml_files/5g_l2sim_tdd + oai-nrf oai-amf oai-smf oai-spgwu oai-ext-dn + 6 + + + + DeployGenObject + Deploy OAI 5G gNB L2 sim SA + yaml_files/5g_l2sim_tdd + oai-gnb + 7 + + + + DeployGenObject + Deploy OAI 5G NR-UE L2 sim SA and Proxy + yaml_files/5g_l2sim_tdd + proxy oai-nr-ue0 + 9 + + + + IdleSleep + Sleep + 10 + + + + PingFromContainer + Ping ext-dn from NR-UE + l2sim-oai-nr-ue0 + -I oaitun_ue1 -c 20 192.168.72.135 + 5 + + + + PingFromContainer + Ping NR-UE from ext-dn + l2sim-oai-ext-dn + -c 20 12.1.1.2 + 5 + + + + UndeployGenObject + Undeploy all OAI 5G stack + yaml_files/5g_l2sim_tdd + + + + StatsFromGenObject + Statistics before Traffic Test + yaml_files/5g_l2sim_tdd + + + + StatsFromGenObject + Statistics after Traffic Test + yaml_files/5g_l2sim_tdd + + + diff --git a/ci-scripts/xml_files/container_5g_l2sim_tdd_down.xml b/ci-scripts/xml_files/container_5g_l2sim_tdd_down.xml new file mode 100644 index 0000000000..d3630cd905 --- /dev/null +++ b/ci-scripts/xml_files/container_5g_l2sim_tdd_down.xml @@ -0,0 +1,38 @@ + + + l2sim-5gnr-down + CleanUp 5G L2 sim - TDD gNB + trash + + 100002 + + + + + UndeployGenObject + Undeploy all OAI 5G stack + yaml_files/5g_l2sim_tdd + + + diff --git a/ci-scripts/xml_files/container_5g_rfsim.xml b/ci-scripts/xml_files/container_5g_rfsim.xml index bab7f9637a..a1f50948a5 100644 --- a/ci-scripts/xml_files/container_5g_rfsim.xml +++ b/ci-scripts/xml_files/container_5g_rfsim.xml @@ -31,8 +31,11 @@ 000001 000002 000003 + 000004 020001 020002 + 020003 + 020004 030001 030002 100001 @@ -71,6 +74,14 @@ 8 + + DeployGenObject + Deploy Second OAI 5G NR-UE RF sim SA + yaml_files/5g_rfsimulator + oai-nr-ue2 + 9 + + PingFromContainer Ping ext-dn from NR-UE @@ -87,6 +98,22 @@ 5 + + PingFromContainer + Ping ext-dn from Second NR-UE + rfsim5g-oai-nr-ue2 + -I oaitun_ue1 -c 20 192.168.72.135 + 5 + + + + PingFromContainer + Ping Second NR-UE from ext-dn + rfsim5g-oai-ext-dn + -c 20 12.1.1.3 + 5 + + IperfFromContainer Iperf UDP Downlink diff --git a/ci-scripts/xml_files/container_nsa_b200_quectel.xml b/ci-scripts/xml_files/container_nsa_b200_quectel.xml index 55f8b8638d..8d04be3efd 100644 --- a/ci-scripts/xml_files/container_nsa_b200_quectel.xml +++ b/ci-scripts/xml_files/container_nsa_b200_quectel.xml @@ -39,8 +39,9 @@ 050001 070001 070000 - 050000 - 050001 + 070002 + 050002 + 050003 010002 000001 030202 @@ -117,21 +118,39 @@ 15 + + Ping + Ping: 20pings in 20sec + idefix + -c 20 + 1 + 15 + + + + Ping + Ping: 100pings in 20sec + idefix + -c 100 -i 0.2 + 1 + 15 + + Iperf - iperf (DL/40Mbps/UDP)(60 sec)(single-ue profile) - -u -b 40M -t 60 + iperf (DL/125Mbps/UDP)(60 sec)(single-ue profile) + -u -b 125M -t 60 -i 1 -fm DL idefix - 20 - 85 + 25 + 80 single-ue Iperf - iperf (UL/3Mbps/UDP)(60 sec)(single-ue profile) - -u -b 3M -t 60 + iperf (UL/8Mbps/UDP)(60 sec)(single-ue profile) + -u -b 8M -t 60 -i 1 -fm UL idefix 1 @@ -139,6 +158,15 @@ single-ue + + Iperf + iperf (BIDIR TCP)(10 sec)(single-ue profile) + -t 10 --bidir + BIDIR + idefix + single-ue + + Undeploy_Object Undeploy eNB diff --git a/ci-scripts/xml_files/formatting_check.xml b/ci-scripts/xml_files/formatting_check.xml new file mode 100644 index 0000000000..bdf47af65d --- /dev/null +++ b/ci-scripts/xml_files/formatting_check.xml @@ -0,0 +1,37 @@ + + + formatting-tab + License and Formatting Checks + wrench + + 000002 + + + + + LicenceAndFormattingCheck + License and Formatting Checks + + + diff --git a/ci-scripts/xml_files/fr1_nsa_2x2_quectel.xml b/ci-scripts/xml_files/fr1_nsa_2x2_quectel.xml index 2476a75427..2ef2b7d7ce 100644 --- a/ci-scripts/xml_files/fr1_nsa_2x2_quectel.xml +++ b/ci-scripts/xml_files/fr1_nsa_2x2_quectel.xml @@ -68,20 +68,20 @@ lte yes yes - 192.168.18.241 + 172.21.19.13 Initialize_eNB Initialize gNB - -O ci-scripts/conf_files/gnb.band78.nsa_2x2.106PRB.usrpn310.conf -q --usrp-tx-thread-config 1 --log_config.global_log_options level,nocolor,time,line_num,function + -O ci-scripts/conf_files/gnb.band78.nsa_2x2.106PRB.usrpn310.conf -q --usrp-tx-thread-config 1 --T_stdout 2 --log_config.global_log_options level,nocolor,time,line_num,function 1 1 nr yes datalog_rt_stats.2x2.yaml - 192.168.18.240 + 172.21.19.14 @@ -115,11 +115,12 @@ Iperf - iperf (DL/60Mbps/UDP)(60 sec)(single-ue profile) - -u -b 60M -t 60 + iperf (DL/125Mbps/UDP)(60 sec)(single-ue profile) + -u -b 125M -t 60 DL nrmodule2_quectel - 5 + 15 + 85 single-ue 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 02544f273b..335fe873a1 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 @@ -87,7 +87,7 @@ lte yes yes - 192.168.18.241 + 172.21.19.13 @@ -100,7 +100,7 @@ nr yes datalog_rt_stats.2x2.yaml - 192.168.18.240 + 172.21.19.14 diff --git a/ci-scripts/xml_files/fr1_nsa_quectel.xml b/ci-scripts/xml_files/fr1_nsa_quectel.xml index 55f6f4376e..a7fd0fc0d7 100644 --- a/ci-scripts/xml_files/fr1_nsa_quectel.xml +++ b/ci-scripts/xml_files/fr1_nsa_quectel.xml @@ -34,8 +34,8 @@ 050000 050001 000001 - 070003 - 070002 + 070000 + 070001 000001 050000 050001 @@ -52,14 +52,12 @@ yes - Terminate_UE Terminate Quectel idefix - Initialize_eNB Initialize eNB @@ -70,11 +68,10 @@ yes - Initialize_eNB Initialize gNB - -O ci-scripts/conf_files/gnb.band78.tm1.fr1.106PRB.usrpb210.conf -E -q --RUs.[0].sdr_addrs "serial=30C51D4" --log_config.global_log_options level,nocolor,time,line_num,function + -O ci-scripts/conf_files/gnb.band78.tm1.fr1.106PRB.usrpb210.conf -E -q --RUs.[0].sdr_addrs "serial=30C51D4" --continuous-tx --log_config.global_log_options level,nocolor,time,line_num,function 1 1 nr @@ -92,7 +89,6 @@ 20 - Ping Ping: 20pings in 20sec @@ -113,41 +109,19 @@ Iperf - iperf (DL/30Mbps/UDP)(30 sec)(single-ue profile) - -u -b 30M -t 30 + iperf (DL/125Mbps/UDP)(60 sec)(single-ue profile) + -u -b 125M -t 60 DL idefix - 5 - 95 + 25 + 80 single-ue Iperf - iperf (DL/40Mbps/UDP)(30 sec)(single-ue profile) - -u -b 40M -t 30 - DL - idefix - 5 - 95 - single-ue - - - - Iperf - iperf (DL/60Mbps/UDP)(60 sec)(single-ue profile) - -u -b 60M -t 60 - DL - idefix - 5 - 95 - single-ue - - - - Iperf - iperf (UL/3Mbps/UDP)(60 sec)(single-ue profile) - -u -b 3M -t 60 + iperf (UL/8Mbps/UDP)(60 sec)(single-ue profile) + -u -b 8M -t 60 UL idefix 1 @@ -155,7 +129,6 @@ single-ue - Terminate_eNB Terminate eNB diff --git a/ci-scripts/xml_files/fr1_sa_amarisoft_ue_1x.xml b/ci-scripts/xml_files/fr1_sa_amarisoft_ue_1x.xml new file mode 100644 index 0000000000..ea031a0174 --- /dev/null +++ b/ci-scripts/xml_files/fr1_sa_amarisoft_ue_1x.xml @@ -0,0 +1,87 @@ + + + TEST-SA-FR1-Tab1 + SA Ping DL UL with 1 AS UE + tasks + 1 + + 040000 + 000001 + 010000 + 000002 + 050000 + 080000 + + + + + Initialize_UE + Run AS UE Scenario + amarisoft_ue_1 + + + + + Initialize_eNB + Initialize gNB + -O ci-scripts/conf_files/gnb.band78.sa.fr1.106PRB.2x2.usrpn310.asue.conf --sa -q --usrp-tx-thread-config 1 --T_stdout 2 --log_config.global_log_options level,nocolor,time + 0 + 0 + nr + yes + yes + datalog_rt_stats.2x2.yaml + 172.21.19.14 + + + + Ping + Ping Log Analysis + amarisoft_ue_1 + 1 + + + + IdleSleep + Sleep + 60 + + + + IdleSleep + Sleep + 20 + + + + + Terminate_eNB + Terminate gNB + 0 + 0 + nr + + + + diff --git a/ci-scripts/xml_files/fr1_sa_oaiue_b200.xml b/ci-scripts/xml_files/fr1_sa_oaiue_b200.xml index 774d5751c5..5995f75a64 100644 --- a/ci-scripts/xml_files/fr1_sa_oaiue_b200.xml +++ b/ci-scripts/xml_files/fr1_sa_oaiue_b200.xml @@ -60,7 +60,7 @@ nr yes yes - 192.168.18.240 + 172.21.19.14 diff --git a/ci-scripts/xml_files/fr1_sa_oaiue_n310.xml b/ci-scripts/xml_files/fr1_sa_oaiue_n310.xml index bfa2208d3d..468005f54f 100644 --- a/ci-scripts/xml_files/fr1_sa_oaiue_n310.xml +++ b/ci-scripts/xml_files/fr1_sa_oaiue_n310.xml @@ -42,7 +42,7 @@ Initialize_OAI_UE Initialize OAI UE (N310) nr - --sa -O ../../../ci-scripts/conf_files/ue.sa.conf --usrp-args "mgmt_addr=192.168.18.241,addr=192.168.10.2" --numerology 1 -r 106 --band 78 -C 3319680000 --nokrnmod 1 --ue-txgain 0 --ue-rxgain 70 --ue-fo-compensation --log_config.global_log_options level,nocolor,time + --sa -O ../../../ci-scripts/conf_files/ue.sa.conf --usrp-args "mgmt_addr=172.21.19.13,addr=192.168.10.2" --numerology 1 -r 106 --band 78 -C 3319680000 --nokrnmod 1 --ue-txgain 0 --ue-rxgain 70 --ue-fo-compensation --log_config.global_log_options level,nocolor,time @@ -60,7 +60,7 @@ nr yes yes - 192.168.18.240 + 172.21.19.14 diff --git a/ci-scripts/xml_files/fr1_sa_oaiue_x300.xml b/ci-scripts/xml_files/fr1_sa_oaiue_x300.xml index c43bdd2a7c..ef001a7518 100644 --- a/ci-scripts/xml_files/fr1_sa_oaiue_x300.xml +++ b/ci-scripts/xml_files/fr1_sa_oaiue_x300.xml @@ -60,7 +60,7 @@ nr yes yes - 192.168.18.240 + 172.21.19.14 diff --git a/ci-scripts/xml_files/fr1_sa_quectel.xml b/ci-scripts/xml_files/fr1_sa_quectel.xml index 8d15015c07..2b215479c2 100644 --- a/ci-scripts/xml_files/fr1_sa_quectel.xml +++ b/ci-scripts/xml_files/fr1_sa_quectel.xml @@ -22,7 +22,7 @@ --> TEST-SA-FR1-Tab1 - SA Ping DL UL with QUECTEL + SA Ping DL UL with Quectel, 2.5ms TDD tasks 1 @@ -63,14 +63,14 @@ Initialize_eNB Initialize gNB - -O ci-scripts/conf_files/gnb.band78.sa.fr1.106PRB.2x2.usrpn310.conf --sa -q --usrp-tx-thread-config 1 --T_stdout 2 --log_config.global_log_options level,nocolor,time + -O ci-scripts/conf_files/gnb.band78.sa.fr1.106PRB.ddsuu.2x2.usrpn310.conf --sa -q --usrp-tx-thread-config 1 --T_stdout 2 --log_config.global_log_options level,nocolor,time 0 0 nr yes yes datalog_rt_stats.2x2.yaml - 192.168.18.240 + 172.21.19.14 @@ -92,7 +92,7 @@ nrmodule2_quectel -c 40 1 - 20 + 10 @@ -101,7 +101,7 @@ nrmodule2_quectel -c 100 -i 0,2 1 - 20 + 10 diff --git a/ci-scripts/xml_files/fr1_sa_quectel_162prb.xml b/ci-scripts/xml_files/fr1_sa_quectel_162prb.xml index f756083ea6..23eaccfcfd 100644 --- a/ci-scripts/xml_files/fr1_sa_quectel_162prb.xml +++ b/ci-scripts/xml_files/fr1_sa_quectel_162prb.xml @@ -68,7 +68,7 @@ yes yes datalog_rt_stats.2x2.yaml - 192.168.18.240 + 172.21.19.14 diff --git a/ci-scripts/xml_files/fr1_sa_quectel_stages.xml b/ci-scripts/xml_files/fr1_sa_quectel_stages.xml index 0ab8bf6b08..603f3f919b 100644 --- a/ci-scripts/xml_files/fr1_sa_quectel_stages.xml +++ b/ci-scripts/xml_files/fr1_sa_quectel_stages.xml @@ -74,7 +74,7 @@ yes yes datalog_rt_stats.2x2.yaml - 192.168.18.240 + 172.21.19.14 diff --git a/ci-scripts/xml_files/fr1_sa_quectel_stages_162prb.xml b/ci-scripts/xml_files/fr1_sa_quectel_stages_162prb.xml index 5feed75586..9371e46ec9 100644 --- a/ci-scripts/xml_files/fr1_sa_quectel_stages_162prb.xml +++ b/ci-scripts/xml_files/fr1_sa_quectel_stages_162prb.xml @@ -74,7 +74,7 @@ yes yes datalog_rt_stats.2x2.yaml - 192.168.18.240 + 172.21.19.14 diff --git a/ci-scripts/xml_files/gnb_phytest_usrp_run.xml b/ci-scripts/xml_files/gnb_phytest_usrp_run.xml index f1185c08c9..e7eb651d50 100644 --- a/ci-scripts/xml_files/gnb_phytest_usrp_run.xml +++ b/ci-scripts/xml_files/gnb_phytest_usrp_run.xml @@ -24,7 +24,7 @@ gNB-PHY-Test Run-gNB-PHY-Test tasks - 3 + 1 090101 000001 090109 @@ -33,9 +33,9 @@ Initialize_eNB Initialize gNB USRP - -O ci-scripts/conf_files/gnb.band78.tm1.106PRB.usrpn300.conf --phy-test -q -U 787200 -T 106 -t 28 -D 130175 -m 28 -M 106 --log_config.global_log_options level,nocolor,time + -O ci-scripts/conf_files/gnb.band78.tm1.106PRB.usrpn300.conf --phy-test -q -U 787200 -T 106 -t 28 -D 130175 -m 28 -M 106 --usrp-tx-thread-config 1 --log_config.global_log_options level,nocolor,time NR - 192.168.30.2 + 192.168.20.2 diff --git a/ci-scripts/xml_files/gnb_usrp_build.xml b/ci-scripts/xml_files/gnb_usrp_build.xml index e2662180c5..97f85c6a33 100644 --- a/ci-scripts/xml_files/gnb_usrp_build.xml +++ b/ci-scripts/xml_files/gnb_usrp_build.xml @@ -34,7 +34,7 @@ TesteNB Build_eNB Build gNB (USRP) - --gNB -w USRP --ninja + --gNB -w USRP --ninja --cmake-opt -DBoost_INCLUDE_DIR=/usr/include/boost169 True diff --git a/ci-scripts/xml_files/lte_2x2_tm1_quectel.xml b/ci-scripts/xml_files/lte_2x2_tm1_quectel.xml index 11c4abce1b..0d18a52839 100644 --- a/ci-scripts/xml_files/lte_2x2_tm1_quectel.xml +++ b/ci-scripts/xml_files/lte_2x2_tm1_quectel.xml @@ -65,7 +65,7 @@ lte yes yes - 192.168.18.241 + 172.21.19.13 @@ -88,7 +88,7 @@ nrmodule2_quectel -c 20 1 - 40 + 60 Ping @@ -96,7 +96,7 @@ nrmodule2_quectel -c 100 -s 1024 -i 0,2 1 - 40 + 60 diff --git a/ci-scripts/xml_files/lte_2x2_tm2_quectel.xml b/ci-scripts/xml_files/lte_2x2_tm2_quectel.xml index 714cf51a9b..f84691ab48 100644 --- a/ci-scripts/xml_files/lte_2x2_tm2_quectel.xml +++ b/ci-scripts/xml_files/lte_2x2_tm2_quectel.xml @@ -65,7 +65,7 @@ lte yes yes - 192.168.18.241 + 172.21.19.13 @@ -88,7 +88,7 @@ nrmodule2_quectel -c 20 1 - 40 + 60 Ping @@ -96,7 +96,7 @@ nrmodule2_quectel -c 100 -s 1024 -i 0,2 1 - 40 + 60 diff --git a/ci-scripts/xml_files/sa_cn5g_asue_closure.xml b/ci-scripts/xml_files/sa_cn5g_asue_closure.xml new file mode 100644 index 0000000000..b856134e36 --- /dev/null +++ b/ci-scripts/xml_files/sa_cn5g_asue_closure.xml @@ -0,0 +1,38 @@ + + + cn5g-closure + CN5G-Closure + log-out + +060000 + + + + + Terminate_5GCN + Terminate 5G Core + --type stop-mini-as-ue --fqdn yes --scenario 1 + + + diff --git a/ci-scripts/xml_files/sa_cn5g_asue_start.xml b/ci-scripts/xml_files/sa_cn5g_asue_start.xml new file mode 100644 index 0000000000..740022b1c9 --- /dev/null +++ b/ci-scripts/xml_files/sa_cn5g_asue_start.xml @@ -0,0 +1,39 @@ + + + cn5g-start-tab + CN5G-Start + log-in + + 000100 + + + + + + Initialize_5GCN + Initialize 5G Core + --type start-mini-as-ue --fqdn yes --scenario 1 --capture /tmp/oai-cn5g-v1.3.pcap + + + diff --git a/ci-scripts/yaml_files/4g_rfsimulator_fdd_05MHz/README.md b/ci-scripts/yaml_files/4g_rfsimulator_fdd_05MHz/README.md index 400559d269..1a947d0389 100644 --- a/ci-scripts/yaml_files/4g_rfsimulator_fdd_05MHz/README.md +++ b/ci-scripts/yaml_files/4g_rfsimulator_fdd_05MHz/README.md @@ -31,9 +31,7 @@ This page is only valid for an `Ubuntu18` host. # 1. Retrieving the images on Docker-Hub # -Currently the images are hosted under the user account `rdefosseoai`. - -This may change in the future. +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`. @@ -49,13 +47,13 @@ Now pull images. ```bash $ docker pull cassandra:2.1 $ docker pull redis:6.0.5 -$ docker pull rdefosseoai/oai-hss:latest -$ docker pull rdefosseoai/magma-mme:latest -$ docker pull rdefosseoai/oai-spgwc:latest -$ docker pull rdefosseoai/oai-spgwu-tiny:latest +$ docker pull oaisoftwarealliance/oai-hss:latest +$ docker pull oaisoftwarealliance/magma-mme:latest +$ docker pull oaisoftwarealliance/oai-spgwc:latest +$ docker pull oaisoftwarealliance/oai-spgwu-tiny:latest -$ docker pull rdefosseoai/oai-enb:develop -$ docker pull rdefosseoai/oai-lte-ue:develop +$ docker pull oaisoftwarealliance/oai-enb:develop +$ docker pull oaisoftwarealliance/oai-lte-ue:develop ``` If the `redis` tag is not available, pick the newest available `6.0.x` tag at [Docker Hub Redis Tags](https://hub.docker.com/_/redis?tab=tags). @@ -63,13 +61,13 @@ If the `redis` tag is not available, pick the newest available `6.0.x` tag at [D And **re-tag** them for tutorials' docker-compose file to work. ```bash -$ docker image tag rdefosseoai/oai-spgwc:latest oai-spgwc:latest -$ docker image tag rdefosseoai/oai-hss:latest oai-hss:latest -$ docker image tag rdefosseoai/oai-spgwu-tiny:latest oai-spgwu-tiny:latest -$ docker image tag rdefosseoai/magma-mme:latest magma-mme:latest +$ docker image tag oaisoftwarealliance/oai-spgwc:latest oai-spgwc:latest +$ docker image tag oaisoftwarealliance/oai-hss:latest oai-hss:latest +$ docker image tag oaisoftwarealliance/oai-spgwu-tiny:latest oai-spgwu-tiny:latest +$ docker image tag oaisoftwarealliance/magma-mme:latest magma-mme:latest -$ docker image tag rdefosseoai/oai-enb:develop oai-enb:develop -$ docker image tag rdefosseoai/oai-lte-ue:develop oai-lte-ue:develop +$ docker image tag oaisoftwarealliance/oai-enb:develop oai-enb:develop +$ docker image tag oaisoftwarealliance/oai-lte-ue:develop oai-lte-ue:develop ``` ```bash @@ -505,7 +503,7 @@ In my traffic test, I was able to ping outside of my local network. in SPGW-C config: ```yaml - DEFAULT_DNS_IPV4_ADDRESS: 192.168.18.129 + DEFAULT_DNS_IPV4_ADDRESS: 172.21.3.100 DEFAULT_DNS_SEC_IPV4_ADDRESS: 8.8.4.4 PUSH_PROTOCOL_OPTION: 'true' ``` diff --git a/ci-scripts/yaml_files/4g_rfsimulator_fdd_05MHz/docker-compose.yml b/ci-scripts/yaml_files/4g_rfsimulator_fdd_05MHz/docker-compose.yml index b15e794c10..a260857a34 100644 --- a/ci-scripts/yaml_files/4g_rfsimulator_fdd_05MHz/docker-compose.yml +++ b/ci-scripts/yaml_files/4g_rfsimulator_fdd_05MHz/docker-compose.yml @@ -115,7 +115,7 @@ services: TZ: Europe/Paris SGW_INTERFACE_NAME_FOR_S11: eth0 PGW_INTERFACE_NAME_FOR_SX: eth0 - DEFAULT_DNS_IPV4_ADDRESS: 192.168.18.129 + DEFAULT_DNS_IPV4_ADDRESS: 172.21.3.100 DEFAULT_DNS_SEC_IPV4_ADDRESS: 8.8.4.4 PUSH_PROTOCOL_OPTION: 'true' APN_NI_1: oai.ipv4 diff --git a/ci-scripts/yaml_files/4g_rfsimulator_fdd_10MHz/docker-compose.yml b/ci-scripts/yaml_files/4g_rfsimulator_fdd_10MHz/docker-compose.yml index e1e992c94c..3f63953b0e 100644 --- a/ci-scripts/yaml_files/4g_rfsimulator_fdd_10MHz/docker-compose.yml +++ b/ci-scripts/yaml_files/4g_rfsimulator_fdd_10MHz/docker-compose.yml @@ -115,7 +115,7 @@ services: TZ: Europe/Paris SGW_INTERFACE_NAME_FOR_S11: eth0 PGW_INTERFACE_NAME_FOR_SX: eth0 - DEFAULT_DNS_IPV4_ADDRESS: 192.168.18.129 + DEFAULT_DNS_IPV4_ADDRESS: 172.21.3.100 DEFAULT_DNS_SEC_IPV4_ADDRESS: 8.8.4.4 PUSH_PROTOCOL_OPTION: 'true' APN_NI_1: oai.ipv4 diff --git a/ci-scripts/yaml_files/4g_rfsimulator_fdd_20MHz/docker-compose.yml b/ci-scripts/yaml_files/4g_rfsimulator_fdd_20MHz/docker-compose.yml index ad665813f2..1165400273 100644 --- a/ci-scripts/yaml_files/4g_rfsimulator_fdd_20MHz/docker-compose.yml +++ b/ci-scripts/yaml_files/4g_rfsimulator_fdd_20MHz/docker-compose.yml @@ -115,7 +115,7 @@ services: TZ: Europe/Paris SGW_INTERFACE_NAME_FOR_S11: eth0 PGW_INTERFACE_NAME_FOR_SX: eth0 - DEFAULT_DNS_IPV4_ADDRESS: 192.168.18.129 + DEFAULT_DNS_IPV4_ADDRESS: 172.21.3.100 DEFAULT_DNS_SEC_IPV4_ADDRESS: 8.8.4.4 PUSH_PROTOCOL_OPTION: 'true' APN_NI_1: oai.ipv4 diff --git a/ci-scripts/yaml_files/4g_rfsimulator_tdd_05MHz/docker-compose.yml b/ci-scripts/yaml_files/4g_rfsimulator_tdd_05MHz/docker-compose.yml index ffa92bac49..86f6c80b59 100644 --- a/ci-scripts/yaml_files/4g_rfsimulator_tdd_05MHz/docker-compose.yml +++ b/ci-scripts/yaml_files/4g_rfsimulator_tdd_05MHz/docker-compose.yml @@ -115,7 +115,7 @@ services: TZ: Europe/Paris SGW_INTERFACE_NAME_FOR_S11: eth0 PGW_INTERFACE_NAME_FOR_SX: eth0 - DEFAULT_DNS_IPV4_ADDRESS: 192.168.18.129 + DEFAULT_DNS_IPV4_ADDRESS: 172.21.3.100 DEFAULT_DNS_SEC_IPV4_ADDRESS: 8.8.4.4 PUSH_PROTOCOL_OPTION: 'true' APN_NI_1: oai.ipv4 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 74a23905f0..d52b228ec6 100644 --- a/ci-scripts/yaml_files/5g_f1_rfsimulator/docker-compose.yaml +++ b/ci-scripts/yaml_files/5g_f1_rfsimulator/docker-compose.yaml @@ -120,7 +120,7 @@ services: - SMF_INTERFACE_PORT_FOR_SBI=80 - SMF_INTERFACE_HTTP2_PORT_FOR_SBI=9090 - SMF_API_VERSION=v1 - - DEFAULT_DNS_IPV4_ADDRESS=192.168.18.129 + - DEFAULT_DNS_IPV4_ADDRESS=172.21.3.100 - DEFAULT_DNS_SEC_IPV4_ADDRESS=4.4.4.4 - AMF_IPV4_ADDRESS=0.0.0.0 - AMF_PORT=80 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 3e46adb9e7..7758c39592 100644 --- a/ci-scripts/yaml_files/5g_fdd_rfsimulator/docker-compose.yaml +++ b/ci-scripts/yaml_files/5g_fdd_rfsimulator/docker-compose.yaml @@ -120,7 +120,7 @@ services: - SMF_INTERFACE_PORT_FOR_SBI=80 - SMF_INTERFACE_HTTP2_PORT_FOR_SBI=9090 - SMF_API_VERSION=v1 - - DEFAULT_DNS_IPV4_ADDRESS=192.168.18.129 + - DEFAULT_DNS_IPV4_ADDRESS=172.21.3.100 - DEFAULT_DNS_SEC_IPV4_ADDRESS=4.4.4.4 - AMF_IPV4_ADDRESS=0.0.0.0 - AMF_PORT=80 diff --git a/ci-scripts/yaml_files/5g_l2sim_tdd/README.md b/ci-scripts/yaml_files/5g_l2sim_tdd/README.md new file mode 100644 index 0000000000..c3f631cf76 --- /dev/null +++ b/ci-scripts/yaml_files/5g_l2sim_tdd/README.md @@ -0,0 +1,353 @@ + + + + + +
+ + + + + + OAI Full Stack 5G-NR L2 simulation with containers and a proxy +
+ +This page is only valid for an `Ubuntu18` host. + +This tutorial is only valid once this file is merged into the `develop` branch. + +# 1. 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 +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:5.7 +$ docker pull oaisoftwarealliance/oai-amf:latest +$ docker pull oaisoftwarealliance/oai-nrf:latest +$ docker pull oaisoftwarealliance/oai-smf:latest +$ docker pull oaisoftwarealliance/oai-spgwu-tiny:latest + +$ docker pull oaisoftwarealliance/oai-gnb:develop +$ docker pull oaisoftwarealliance/oai-nr-ue:develop +$ docker pull oaisoftwarealliance/proxy:latest +``` + +And **re-tag** them for tutorials' docker-compose file to work. + +```bash +$ docker image tag oaisoftwarealliance/oai-amf:latest oai-amf:latest +$ docker image tag oaisoftwarealliance/oai-nrf:latest oai-nrf:latest +$ docker image tag oaisoftwarealliance/oai-smf:latest oai-smf:latest +$ docker image tag oaisoftwarealliance/oai-spgwu-tiny:latest oai-spgwu-tiny:latest + +$ docker image tag oaisoftwarealliance/oai-gnb:develop oai-gnb:develop +$ docker image tag oaisoftwarealliance/oai-nr-ue:develop oai-nr-ue:develop +$ docker image tag oaisoftwarealliance/proxy:latest 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. + +# 2. 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 +``` + +## 2.1. Deploy OAI 5G Core Network ## + +```bash +$ cd ci-scripts/yaml_files/5g_l2sim_tdd +$ docker-compose up -d mysql oai-nrf oai-amf oai-smf oai-spgwu oai-ext-dn +Creating network "l2sim-oai-public-net" with driver "bridge" +Creating network "l2sim-oai-traffic_net-net" with driver "bridge" +Creating l2sim-oai-nrf ... done +Creating l2sim-mysql ... done +Creating l2sim-oai-spgwu ... 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 + 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-nrf /bin/bash /openair-nrf/bin ... Up (healthy) 80/tcp, 9090/tcp +l2sim-oai-smf /bin/bash /openair-smf/bin ... Up (healthy) 80/tcp, 8805/udp, 9090/tcp +l2sim-oai-spgwu /openair-spgwu-tiny/bin/en ... Up (healthy) 2152/udp, 8805/udp +``` + +At this point, you can prepare a capture on the newly-created public docker bridges: + +```bash +$ ifconfig +... +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 +... + +$ 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 & +``` + +## 2.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 +l2sim-oai-nrf is up-to-date +l2sim-oai-spgwu 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 + 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-nrf /bin/bash /openair-nrf/bin ... Up (healthy) 80/tcp, 9090/tcp +l2sim-oai-smf /bin/bash /openair-smf/bin ... Up (healthy) 80/tcp, 8805/udp, 9090/tcp +l2sim-oai-spgwu /openair-spgwu-tiny/bin/en ... Up (healthy) 2152/udp, 8805/udp +``` + +You can verify that the `gNB` is connected with the `AMF`: + +```bagh +$ docker logs rfsim5g-oai-amf +... +[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 ] |----------------------------------------------------------------------------------------------------------------| +... +``` + +## 2.3. Deploy OAI NR-UE and proxy + +```bash +$ docker-compose up -d proxy oai-nr-ue0 +l2sim-mysql is up-to-date +l2sim-oai-nrf is up-to-date +l2sim-oai-amf is up-to-date +l2sim-oai-smf is up-to-date +l2sim-oai-spgwu 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 + 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-nrf /bin/bash /openair-nrf/bin ... Up (healthy) 80/tcp, 9090/tcp +l2sim-oai-smf /bin/bash /openair-smf/bin ... Up (healthy) 80/tcp, 8805/udp, 9090/tcp +l2sim-oai-spgwu /openair-spgwu-tiny/bin/en ... Up (healthy) 2152/udp, 8805/udp +l2sim-proxy /oai-lte-multi-ue-proxy/bi ... Up (healthy) + +$ 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-nrf l2sim-oai-smf l2sim-oai-spgwu l2sim-proxy +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-nrf 0.21% 9.105MiB / 62.54GiB 0.01% +l2sim-oai-smf 3.24% 30.23MiB / 62.54GiB 0.05% +l2sim-oai-spgwu 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 +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-ue /bin/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 +``` + +# 3. Check traffic # + +## 3.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-ue /bin/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 +``` + +# 4. Un-deployment # + +```bash +$ docker-compose down +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-spgwu ... done +Stopping l2sim-oai-smf ... done +Stopping l2sim-oai-amf ... done +Stopping l2sim-oai-nrf ... 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-spgwu ... done +Removing l2sim-oai-smf ... done +Removing l2sim-oai-amf ... done +Removing l2sim-oai-nrf ... done +Removing l2sim-mysql ... done +Removing network l2sim-oai-public-net +Removing network l2sim-oai-traffic-net +``` + +# 5. Adapt the `docker-compose` to your environment # + +In the `SMF` section, provide your own DNS IP address: + +```yaml + DEFAULT_DNS_IPV4_ADDRESS=172.21.3.100 +``` + +In the `gNB` section, provide your docker-host primary IP address and interface name: in our case `172.21.16.128` and `eno1`. + +```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 +``` + +Same thing in the `nr-ue` section: + +```yaml + NR_UE_NFAPI_IF_NAME: eno1 +``` + +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. + +Later development will include: + + - deploying `gNB-VNF`, `proxy` and `UE` in isolated containers (with their own IP address) + - more UEs + - more traffic (`UDP` and `TCP`) diff --git a/ci-scripts/yaml_files/5g_l2sim_tdd/docker-compose.yaml b/ci-scripts/yaml_files/5g_l2sim_tdd/docker-compose.yaml new file mode 100644 index 0000000000..a28b640e1a --- /dev/null +++ b/ci-scripts/yaml_files/5g_l2sim_tdd/docker-compose.yaml @@ -0,0 +1,322 @@ +version: '3.8' +services: + oai-nrf: + container_name: "l2sim-oai-nrf" + image: oai-nrf:latest + environment: + - NRF_INTERFACE_NAME_FOR_SBI=eth0 + - NRF_INTERFACE_PORT_FOR_SBI=80 + - NRF_INTERFACE_HTTP2_PORT_FOR_SBI=9090 + - NRF_API_VERSION=v1 + - INSTANCE=0 + - PID_DIRECTORY=/var/run + networks: + public_net: + ipv4_address: 192.168.71.130 + volumes: + - ../5g_rfsimulator/nrf-healthcheck.sh:/openair-nrf/bin/nrf-healthcheck.sh + healthcheck: + test: /bin/bash -c "/openair-nrf/bin/nrf-healthcheck.sh" + interval: 10s + timeout: 5s + retries: 5 + mysql: + container_name: "l2sim-mysql" + image: mysql:5.7 + 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: 5 + networks: + public_net: + ipv4_address: 192.168.71.131 + oai-amf: + container_name: "l2sim-oai-amf" + image: oai-amf:latest + environment: + - TZ=Europe/paris + - INSTANCE=0 + - PID_DIRECTORY=/var/run + - MCC=208 + - MNC=99 + - REGION_ID=128 + - AMF_SET_ID=1 + - SERVED_GUAMI_MCC_0=208 + - SERVED_GUAMI_MNC_0=99 + - SERVED_GUAMI_REGION_ID_0=128 + - SERVED_GUAMI_AMF_SET_ID_0=1 + - SERVED_GUAMI_MCC_1=460 + - SERVED_GUAMI_MNC_1=11 + - SERVED_GUAMI_REGION_ID_1=10 + - SERVED_GUAMI_AMF_SET_ID_1=1 + - PLMN_SUPPORT_MCC=208 + - PLMN_SUPPORT_MNC=99 + - PLMN_SUPPORT_TAC=0x0001 + - SST_0=1 + - SD_0=1 + - SST_1=1 + - SD_1=12 + - AMF_INTERFACE_NAME_FOR_NGAP=eth0 + - AMF_INTERFACE_NAME_FOR_N11=eth0 + - SMF_INSTANCE_ID_0=1 + - SMF_FQDN_0=oai-smf + - SMF_IPV4_ADDR_0=0.0.0.0 + - SMF_HTTP_VERSION_0=v1 + - SELECTED_0=true + - SMF_INSTANCE_ID_1=2 + - SMF_FQDN_1=oai-smf + - SMF_IPV4_ADDR_1=0.0.0.0 + - SMF_HTTP_VERSION_1=v1 + - SELECTED_1=false + - MYSQL_SERVER=192.168.71.131 + - MYSQL_USER=root + - MYSQL_PASS=linux + - MYSQL_DB=oai_db + - OPERATOR_KEY=c42449363bbad02b66d16bc975d77cc1 + - NRF_IPV4_ADDRESS=192.168.71.130 + - NRF_PORT=80 + - NF_REGISTRATION=yes + - SMF_SELECTION=yes + - USE_FQDN_DNS=yes + - NRF_API_VERSION=v1 + - NRF_FQDN=oai-nrf + - EXTERNAL_AUSF=no + - AUSF_IPV4_ADDRESS=0.0.0.0 + - AUSF_PORT=80 + - AUSF_API_VERSION=v1 + - AUSF_FQDN=localhost + depends_on: + - oai-nrf + - mysql + volumes: + - ../5g_rfsimulator/amf-healthcheck.sh:/openair-amf/bin/amf-healthcheck.sh + healthcheck: + test: /bin/bash -c "/openair-amf/bin/amf-healthcheck.sh" + interval: 10s + timeout: 15s + retries: 5 + networks: + public_net: + ipv4_address: 192.168.71.132 + oai-smf: + container_name: "l2sim-oai-smf" + image: oai-smf:latest + environment: + - TZ=Europe/Paris + - INSTANCE=0 + - PID_DIRECTORY=/var/run + - SMF_INTERFACE_NAME_FOR_N4=eth0 + - SMF_INTERFACE_NAME_FOR_SBI=eth0 + - SMF_INTERFACE_PORT_FOR_SBI=80 + - SMF_INTERFACE_HTTP2_PORT_FOR_SBI=9090 + - SMF_API_VERSION=v1 + - DEFAULT_DNS_IPV4_ADDRESS=172.21.3.100 + - DEFAULT_DNS_SEC_IPV4_ADDRESS=4.4.4.4 + - AMF_IPV4_ADDRESS=0.0.0.0 + - AMF_PORT=80 + - AMF_API_VERSION=v1 + - AMF_FQDN=oai-amf + - UDM_IPV4_ADDRESS=127.0.0.1 + - UDM_PORT=80 + - UDM_API_VERSION=v1 + - UDM_FQDN=localhost + - UPF_IPV4_ADDRESS=192.168.71.134 + - UPF_FQDN_0=oai-spgwu + - NRF_IPV4_ADDRESS=192.168.71.130 + - NRF_PORT=80 + - NRF_API_VERSION=v1 + - NRF_FQDN=oai-nrf + - REGISTER_NRF=yes + - DISCOVER_UPF=yes + - USE_FQDN_DNS=yes + - DNN_NI0=oai + - DNN_NI2=oai.ipv4 + depends_on: + - oai-nrf + - oai-amf + volumes: + - ../5g_rfsimulator/smf-healthcheck.sh:/openair-smf/bin/smf-healthcheck.sh + healthcheck: + test: /bin/bash -c "/openair-smf/bin/smf-healthcheck.sh" + interval: 10s + timeout: 5s + retries: 5 + networks: + public_net: + ipv4_address: 192.168.71.133 + oai-spgwu: + container_name: "l2sim-oai-spgwu" + image: oai-spgwu-tiny:latest + environment: + - TZ=Europe/Paris + - PID_DIRECTORY=/var/run + - SGW_INTERFACE_NAME_FOR_S1U_S12_S4_UP=eth0 + - SGW_INTERFACE_NAME_FOR_SX=eth0 + - PGW_INTERFACE_NAME_FOR_SGI=eth0 + - NETWORK_UE_NAT_OPTION=yes + - NETWORK_UE_IP=12.1.1.0/24 + - SPGWC0_IP_ADDRESS=192.168.71.133 + - BYPASS_UL_PFCP_RULES=no + - MCC=208 + - MNC=99 + - MNC03=099 + - TAC=1 + - GTP_EXTENSION_HEADER_PRESENT=yes + - GW_ID=1 + - REALM=openairinterface.org + - ENABLE_5G_FEATURES=yes + - REGISTER_NRF=yes + - USE_FQDN_NRF=yes + - UPF_FQDN_5G=oai-spgwu + - NRF_IPV4_ADDRESS=192.168.71.130 + - NRF_PORT=80 + - NRF_API_VERSION=v1 + - NRF_FQDN=oai-nrf + - NSSAI_SST_0=1 + - NSSAI_SD_0=1 + - DNN_0=oai + depends_on: + - oai-nrf + - oai-smf + cap_add: + - NET_ADMIN + - SYS_ADMIN + cap_drop: + - ALL + privileged: true + volumes: + - ../5g_rfsimulator/spgwu-healthcheck.sh:/openair-spgwu-tiny/bin/spgwu-healthcheck.sh + healthcheck: + test: /bin/bash -c "/openair-spgwu-tiny/bin/spgwu-healthcheck.sh" + interval: 10s + timeout: 5s + retries: 5 + networks: + public_net: + ipv4_address: 192.168.71.134 + traffic_net: + ipv4_address: 192.168.72.134 + oai-ext-dn: + image: ubuntu:bionic + privileged: true + container_name: "l2sim-oai-ext-dn" + entrypoint: /bin/bash -c \ + "apt update; apt install -y procps iptables iproute2 iperf iputils-ping;"\ + "ip route add 12.1.1.0/24 via 192.168.72.134 dev eth0; sleep infinity" + depends_on: + - oai-spgwu + networks: + traffic_net: + ipv4_address: 192.168.72.135 + healthcheck: + test: /bin/bash -c "ping -c 2 192.168.72.134" + interval: 10s + timeout: 5s + retries: 5 + oai-gnb: + image: oai-gnb:develop + privileged: true + container_name: "l2sim-oai-gnb" + network_mode: "host" + environment: + TZ: Europe/Paris + USE_SA_NFAPI_VNF: 'yes' + GNB_NAME: gnb-l2sim-vnf + TAC: 1 + MCC: '208' + MNC: '99' + MNC_LENGTH: 2 + NSSAI_SST: 1 + NSSAI_SD0: 1 + NSSAI_SD1: 112233 + AMF_IP_ADDRESS: 192.168.71.132 + GNB_NGA_IF_NAME: eno1 + GNB_NGA_IP_ADDRESS: 172.21.16.128 + GNB_NGU_IF_NAME: eno1 + GNB_NGU_IP_ADDRESS: 172.21.16.128 + LOCAL_S_IF_NAME: 'lo:' + REMOTE_S_ADDRESS: 127.0.0.1 + LOCAL_S_ADDRESS: 127.0.0.2 + USE_ADDITIONAL_OPTIONS: --sa --nfapi 2 --emulate-l1 --log_config.global_log_options level,time,thread_id,nocolor + depends_on: + - oai-spgwu + - oai-amf + healthcheck: + test: /bin/bash -c "pgrep nr-softmodem" + interval: 10s + timeout: 5s + retries: 5 + + proxy: + image: oai-lte-multi-ue-proxy:latest + privileged: true + container_name: "l2sim-proxy" + 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: oai-nr-ue:develop + privileged: true + container_name: "l2sim-oai-nr-ue0" + network_mode: "host" + environment: + TZ: Europe/Paris + USE_NFAPI: 'yes' + OPENAIR_DIR: /opt/oai-nr-ue + FULL_IMSI: '208990100001100' + FULL_KEY: 'fec86ba6eb707ed08905757b1bb44b8f' + OPC: 'C42449363BBAD02B66D16BC975D77CC1' + DNN: oai + NSSAI_SST: 1 + NSSAI_SD: 1 + NR_UE_NFAPI_IF_NAME: eno1 + GNB_IP_ADDRESS: 127.0.0.1 + NR_UE_IP_ADDRESS: 127.0.0.1 + USE_ADDITIONAL_OPTIONS: --nokrnmod 1 --nfapi 5 --node-number 2 --sa --emulate-l1 --log_config.global_log_options level,time,thread_id,nocolor + volumes: + - ../../../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 fc562dd1eb..aa18571776 100644 --- a/ci-scripts/yaml_files/5g_rfsimulator/README.md +++ b/ci-scripts/yaml_files/5g_rfsimulator/README.md @@ -23,6 +23,7 @@ This page is only valid for an `Ubuntu18` host. 1. [Deploy OAI 5G Core Network](#21-deploy-oai-5g-core-network) 2. [Deploy OAI gNB in RF simulator mode and in Standalone Mode](#22-deploy-oai-gnb-in-rf-simulator-mode-and-in-standalone-mode) 3. [Deploy OAI NR-UE in RF simulator mode and in Standalone Mode](#23-deploy-oai-nr-ue-in-rf-simulator-mode-and-in-standalone-mode) + 4. [Deploy Second OAI NR-UE in RF simulator mode and in Standalone Mode](#24-deploy-second-oai-nr-ue-in-rf-simulator-mode-and-in-standalone-mode) 3. [Check traffic](#3-check-traffic) 1. [Check your Internet connectivity](#31-check-your-internet-connectivity) 2. [Start the iperf server inside the NR-UE container](#32-start-the-iperf-server-inside-the-nr-ue-container) @@ -34,9 +35,7 @@ This page is only valid for an `Ubuntu18` host. # 1. Retrieving the images on Docker-Hub # -Currently the images are hosted under the user account `rdefosseoai`. - -This may change in the future. +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`. @@ -51,25 +50,25 @@ Now pull images. ```bash $ docker pull mysql:5.7 -$ docker pull rdefosseoai/oai-amf:latest -$ docker pull rdefosseoai/oai-nrf:latest -$ docker pull rdefosseoai/oai-smf:latest -$ docker pull rdefosseoai/oai-spgwu-tiny:latest +$ docker pull oaisoftwarealliance/oai-amf:latest +$ docker pull oaisoftwarealliance/oai-nrf:latest +$ docker pull oaisoftwarealliance/oai-smf:latest +$ docker pull oaisoftwarealliance/oai-spgwu-tiny:latest -$ docker pull rdefosseoai/oai-gnb:develop -$ docker pull rdefosseoai/oai-nr-ue:develop +$ docker pull oaisoftwarealliance/oai-gnb:develop +$ docker pull oaisoftwarealliance/oai-nr-ue:develop ``` And **re-tag** them for tutorials' docker-compose file to work. ```bash -$ docker image tag rdefosseoai/oai-amf:latest oai-amf:latest -$ docker image tag rdefosseoai/oai-nrf:latest oai-nrf:latest -$ docker image tag rdefosseoai/oai-smf:latest oai-smf:latest -$ docker image tag rdefosseoai/oai-spgwu-tiny:latest oai-spgwu-tiny:latest +$ docker image tag oaisoftwarealliance/oai-amf:latest oai-amf:latest +$ docker image tag oaisoftwarealliance/oai-nrf:latest oai-nrf:latest +$ docker image tag oaisoftwarealliance/oai-smf:latest oai-smf:latest +$ docker image tag oaisoftwarealliance/oai-spgwu-tiny:latest oai-spgwu-tiny:latest -$ docker image tag rdefosseoai/oai-gnb:develop oai-gnb:develop -$ docker image tag rdefosseoai/oai-nr-ue:develop oai-nr-ue:develop +$ docker image tag oaisoftwarealliance/oai-gnb:develop oai-gnb:develop +$ docker image tag oaisoftwarealliance/oai-nr-ue:develop oai-nr-ue:develop ``` ```bash @@ -203,6 +202,8 @@ $ docker logs rfsim5g-oai-amf $ docker-compose up -d oai-nr-ue rfsim5g-mysql is up-to-date rfsim5g-oai-nrf is up-to-date +rfsim5g-oai-amf is up-to-date +rfsim5g-oai-smf is up-to-date rfsim5g-oai-spgwu is up-to-date rfsim5g-oai-ext-dn is up-to-date rfsim5g-oai-gnb is up-to-date @@ -231,7 +232,7 @@ Making sure the OAI UE is connected: $ docker exec -it rfsim5g-oai-nr-ue /bin/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 + inet 192.168.71.150 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 @@ -255,6 +256,98 @@ oaitun_ue1: flags=4305 mtu 1500 TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0 ``` +## 2.4. Deploy Second OAI NR-UE in RF simulator mode and in Standalone Mode ## + +```bash +Create a entry for new IMSI (208990100001101) in oai_db.sql file +Refer Section - [Making the NR-UE connect to the core network](#51-making-the-nr-ue-connect-to-the-core-network) + +Create entry for Second UE in docker-compose.yaml file as follows: + oai-nr-ue2: + image: oai-nr-ue:develop + privileged: true + container_name: rfsim5g-oai-nr-ue2 + environment: + RFSIMULATOR: 192.168.71.140 + FULL_IMSI: '208990100001101' + FULL_KEY: 'fec86ba6eb707ed08905757b1bb44b8f' + OPC: 'C42449363BBAD02B66D16BC975D77CC1' + DNN: oai + NSSAI_SST: 1 + NSSAI_SD: 1 + USE_ADDITIONAL_OPTIONS: -E --sa --rfsim -r 106 --numerology 1 -C 3619200000 --nokrnmod --log_config.global_log_options level,nocolor,time + depends_on: + - oai-gnb + networks: + public_net: + ipv4_address: 192.168.71.151 + healthcheck: + test: /bin/bash -c "pgrep nr-uesoftmodem" + interval: 10s + timeout: 5s + retries: 5 +``` + + +```bash +$ docker-compose up -d oai-nr-ue2 +rfsim5g-mysql is up-to-date +rfsim5g-oai-nrf is up-to-date +rfsim5g-oai-amf is up-to-date +rfsim5g-oai-smf is up-to-date +rfsim5g-oai-spgwu is up-to-date +rfsim5g-oai-ext-dn is up-to-date +rfsim5g-oai-gnb is up-to-date +Creating rfsim5g-oai-nr-ue2 ... done +``` + +Wait for a bit. + +```bash +$ docker-compose ps -a + Name Command State Ports +------------------------------------------------------------------------------------------------- +rfsim5g-mysql docker-entrypoint.sh mysqld Up (healthy) 3306/tcp, 33060/tcp +rfsim5g-oai-amf /bin/bash /openair-amf/bin ... Up (healthy) 38412/sctp, 80/tcp, 9090/tcp +rfsim5g-oai-ext-dn /bin/bash -c apt update; ... Up (healthy) +rfsim5g-oai-gnb /opt/oai-gnb/bin/entrypoin ... Up (healthy) +rfsim5g-oai-nr-ue /opt/oai-nr-ue/bin/entrypo ... Up (healthy) +rfsim5g-oai-nr-ue2 /opt/oai-nr-ue/bin/entrypo ... Up (healthy) +rfsim5g-oai-nrf /bin/bash /openair-nrf/bin ... Up (healthy) 80/tcp, 9090/tcp +rfsim5g-oai-smf /bin/bash /openair-smf/bin ... Up (healthy) 80/tcp, 8805/udp, 9090/tcp +rfsim5g-oai-spgwu /openair-spgwu-tiny/bin/en ... Up (healthy) 2152/udp, 8805/udp +``` + +Making sure the Second OAI UE is connected: + +```bash +$ docker exec -it rfsim5g-oai-nr-ue2 /bin/bash +root@bb4d400a832d:/opt/oai-nr-ue# ifconfig +eth0: flags=4163 mtu 1500 + inet 192.168.71.151 netmask 255.255.255.192 broadcast 192.168.71.191 + ether 02:42:c0:a8:47:8a txqueuelen 0 (Ethernet) + RX packets 3192021 bytes 67784900946 (67.7 GB) + RX errors 0 dropped 0 overruns 0 frame 0 + TX packets 3397743 bytes 91320004542 (91.3 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.3 netmask 255.255.255.0 destination 12.1.1.3 + 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 +``` + # 3. Check traffic # ## 3.1. Check your Internet connectivity ## @@ -299,6 +392,9 @@ Let now try to check UDP traffic in Downlink. You will need 2 terminals: one in the NR-UE container, one in the ext-dn container. +Note: +Similarly, Second OAI UE Internet connectivity can be checked. + ## 3.2. Start the `iperf` server inside the NR-UE container ## ```bash @@ -384,24 +480,26 @@ The `500 Kbits/sec` value may change depending on your CPU power! ```bash $ docker-compose down +Stopping rfsim5g-oai-nr-ue2 ... done Stopping rfsim5g-oai-nr-ue ... done Stopping rfsim5g-oai-gnb ... done Stopping rfsim5g-oai-ext-dn ... done +Stopping rfsim5g-oai-spgwu ... done Stopping rfsim5g-oai-smf ... done Stopping rfsim5g-oai-amf ... done -Stopping rfsim5g-oai-spgwu ... done Stopping rfsim5g-oai-nrf ... done Stopping rfsim5g-mysql ... done +Removing rfsim5g-oai-nr-ue2 ... done Removing rfsim5g-oai-nr-ue ... done Removing rfsim5g-oai-gnb ... done Removing rfsim5g-oai-ext-dn ... done +Removing rfsim5g-oai-spgwu ... done Removing rfsim5g-oai-smf ... done Removing rfsim5g-oai-amf ... done -Removing rfsim5g-oai-spgwu ... done Removing rfsim5g-oai-nrf ... done Removing rfsim5g-mysql ... done Removing network rfsim5g-oai-public-net -Removing network rfsim5g-oai-traffic_net-net +Removing network rfsim5g-oai-traffic-net ``` # 5. Explanations on the configuration in the `docker-compose.yaml` # @@ -419,13 +517,19 @@ This value is also present in the `oai_db.sql` file: ```bash INSERT INTO `users` VALUES ('208990100001100','1','55000000000000',NULL,'PURGED',50,40000000,100000000,47,0000000000,1,0xfec86ba6eb707ed08905757b1bb44b8f,0,0,0x40,'ebd07771ace8677a',0xc42449363bbad02b66d16bc975d77cc1); +INSERT INTO `users` VALUES ('208990100001101','1','55000000000000',NULL,'PURGED',50,40000000,100000000,47,0000000000,1,0xfec86ba6eb707ed08905757b1bb44b8f,0,0,0x40,'ebd07771ace8677a',0xc42449363bbad02b66d16bc975d77cc1); ``` As you can see, 2 other values shall match in the NR-UE section of `docker-compose.yaml`: +OAI UE - 1 * `FULL_IMSI: '208990100001100'` * `FULL_KEY: 'fec86ba6eb707ed08905757b1bb44b8f'` +OAI UE - 2 +* `FULL_IMSI: '208990100001101'` +* `FULL_KEY: 'fec86ba6eb707ed08905757b1bb44b8f'` + We are also using a dedicated `oai-smf.conf` for the `SMF` container: the `oai` DNN shall match the one in the NR-UE section of `docker-compose.yaml` (`DNN: oai`). ## 5.2. Making the gNB connect to the core network ## diff --git a/ci-scripts/yaml_files/5g_rfsimulator/docker-compose.yaml b/ci-scripts/yaml_files/5g_rfsimulator/docker-compose.yaml index 808be7d83d..696d8c6698 100644 --- a/ci-scripts/yaml_files/5g_rfsimulator/docker-compose.yaml +++ b/ci-scripts/yaml_files/5g_rfsimulator/docker-compose.yaml @@ -120,7 +120,7 @@ services: - SMF_INTERFACE_PORT_FOR_SBI=80 - SMF_INTERFACE_HTTP2_PORT_FOR_SBI=9090 - SMF_API_VERSION=v1 - - DEFAULT_DNS_IPV4_ADDRESS=192.168.18.129 + - DEFAULT_DNS_IPV4_ADDRESS=172.21.3.100 - DEFAULT_DNS_SEC_IPV4_ADDRESS=4.4.4.4 - AMF_IPV4_ADDRESS=0.0.0.0 - AMF_PORT=80 @@ -279,6 +279,30 @@ services: timeout: 5s retries: 5 + oai-nr-ue2: + image: oai-nr-ue:develop + privileged: true + container_name: rfsim5g-oai-nr-ue2 + environment: + RFSIMULATOR: 192.168.71.140 + FULL_IMSI: '208990100001101' + FULL_KEY: 'fec86ba6eb707ed08905757b1bb44b8f' + OPC: 'C42449363BBAD02B66D16BC975D77CC1' + DNN: oai + NSSAI_SST: 1 + NSSAI_SD: 1 + USE_ADDITIONAL_OPTIONS: -E --sa --rfsim -r 106 --numerology 1 -C 3619200000 --nokrnmod --log_config.global_log_options level,nocolor,time + depends_on: + - oai-gnb + networks: + public_net: + ipv4_address: 192.168.71.151 + healthcheck: + test: /bin/bash -c "pgrep nr-uesoftmodem" + interval: 10s + timeout: 5s + retries: 5 + networks: public_net: driver: bridge diff --git a/ci-scripts/yaml_files/5g_rfsimulator/oai_db.sql b/ci-scripts/yaml_files/5g_rfsimulator/oai_db.sql index fbd7907a71..75f586c299 100755 --- a/ci-scripts/yaml_files/5g_rfsimulator/oai_db.sql +++ b/ci-scripts/yaml_files/5g_rfsimulator/oai_db.sql @@ -192,6 +192,7 @@ LOCK TABLES `users` WRITE; /*!40000 ALTER TABLE `users` DISABLE KEYS */; INSERT INTO `users` VALUES ('20834123456789','380561234567','35609204079300',NULL,'PURGED',50,40000000,100000000,47,0000000000,1,'+�E��ų\0�,IH��H',0,0,00000000000000000096,'Px�X \Z1��x��','^��K�����FeU���'),('20810000001234','33611123456','35609204079299',NULL,'PURGED',120,40000000,100000000,47,0000000000,1,'��G?/�Д���� |hb',1,0,00000281454575616225,'\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0','�4�s@���z��~�'),('31002890832150','33638060059','35611302209414',NULL,'PURGED',120,40000000,100000000,47,0000000000,1,'��G?/�Д���� |hb',1,0,00000000000000012416,'`�F�݆��D��ϛ���','�4�s@���z��~�'),('001010123456789','33600101789','35609204079298',NULL,'PURGED',120,50000000,100000000,47,0000000000,1,'\0 \n \r',1,0,00000000000000000351,'\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0','L�*\\�����^��]� '),('208930000000001','33638030001','35609204079301',NULL,'PURGED',120,50000000,100000000,47,0000000000,1,'��G?/�Д���� |hb',1,0,00000000000000006103,'��wq��gzW�Ё��Z]','�4�s@���z��~�'),('208950000000002','33638050002','35609204079502',NULL,'PURGED',120,50000000,100000000,47,0000000000,1,'��G?/�Д���� |hb',1,0,00000000000000020471,'\0 \n \r','�4�s@���z��~�'),('208950000000003','33638050003','35609204079503',NULL,'PURGED',120,50000000,100000000,47,0000000000,1,'��G?/�Д���� |hb',1,0,00000000000000012343,'\0 \n \r','�4�s@���z��~�'),('208950000000004','33638050004','35609204079504',NULL,'PURGED',120,50000000,100000000,47,0000000000,1,'��G?/�Д���� |hb',1,0,00000000000000012215,'56f0261d9d051063','�4�s@���z��~�'),('208950000000005','33638050005','35609204079505',NULL,'PURGED',120,50000000,100000000,47,0000000000,1,'��G?/�Д���� |hb',1,0,00000000000000012215,'56f0261d9d051063','�4�s@���z��~�'),('208950000000001','33638050001','35609204079501',NULL,'PURGED',120,50000000,100000000,47,0000000000,1,'��G?/�Д���� |hb',1,0,00000000000000006103,'��wq��gzW�Ё��Z]','�4�s@���z��~�'),('208950000000006','33638050006','35609204079506',NULL,'PURGED',120,50000000,100000000,47,0000000000,1,'��G?/�Д���� |hb',1,0,00000000000000012215,'56f0261d9d051063','�4�s@���z��~�'),('208950000000007','33638050007','35609204079507',NULL,'PURGED',120,50000000,100000000,47,0000000000,1,'��G?/�Д���� |hb',1,0,00000000000000012215,'56f0261d9d051063','�4�s@���z��~�'),('208930000000002','33638030002','35609204079302',NULL,'PURGED',120,50000000,100000000,47,0000000000,1,'��G?/�Д���� |hb',1,0,00000000000000006103,'��wq��gzW�Ё��Z]','�4�s@���z��~�'),('208930000000003','33638030003','35609204079303',NULL,'PURGED',120,50000000,100000000,47,0000000000,1,'��G?/�Д���� |hb',1,0,00000000000000006103,'��wq��gzW�Ё��Z]','�4�s@���z��~�'),('208930000000004','33638030004','35609204079304',NULL,'PURGED',120,50000000,100000000,47,0000000000,1,'��G?/�Д���� |hb',1,0,00000000000000006103,'��wq��gzW�Ё��Z]','�4�s@���z��~�'),('208930000000005','33638030005','35609204079305',NULL,'PURGED',120,50000000,100000000,47,0000000000,1,'��G?/�Д���� |hb',1,0,00000000000000006103,'��wq��gzW�Ё��Z]','�4�s@���z��~�'),('208930000000006','33638030006','35609204079306',NULL,'PURGED',120,50000000,100000000,47,0000000000,1,'��G?/�Д���� |hb',1,0,00000000000000006103,'��wq��gzW�Ё��Z]','�4�s@���z��~�'),('208930000000007','33638030007','35609204079307',NULL,'PURGED',120,50000000,100000000,47,0000000000,1,'��G?/�Д���� |hb',1,0,00000000000000006103,'��wq��gzW�Ё��Z]','�4�s@���z��~�'),('208940000000007','33638040007','35609204079407',NULL,'PURGED',120,50000000,100000000,47,0000000000,1,'��G?/�Д���� |hb',1,0,00000000000000006103,'��wq��gzW�Ё��Z]','�4�s@���z��~�'),('208940000000006','33638040006','35609204079406',NULL,'PURGED',120,50000000,100000000,47,0000000000,1,'��G?/�Д���� |hb',1,0,00000000000000006103,'��wq��gzW�Ё��Z]','�4�s@���z��~�'),('208940000000005','33638040005','35609204079405',NULL,'PURGED',120,50000000,100000000,47,0000000000,1,'��G?/�Д���� |hb',1,0,00000000000000006103,'��wq��gzW�Ё��Z]','�4�s@���z��~�'),('208940000000004','33638040004','35609204079404',NULL,'PURGED',120,50000000,100000000,47,0000000000,1,'��G?/�Д���� |hb',1,0,00000000000000006103,'��wq��gzW�Ё��Z]','�4�s@���z��~�'),('208940000000003','33638040003','35609204079403',NULL,'PURGED',120,50000000,100000000,47,0000000000,1,'��G?/�Д���� |hb',1,0,00000000000000006103,'��wq��gzW�Ё��Z]','�4�s@���z��~�'),('208940000000002','33638040002','35609204079402',NULL,'PURGED',120,50000000,100000000,47,0000000000,1,'��G?/�Д���� |hb',1,0,00000000000000006103,'��wq��gzW�Ё��Z]','�4�s@���z��~�'),('208940000000001','33638040001','35609204079401',NULL,'PURGED',120,50000000,100000000,47,0000000000,1,'��G?/�Д���� |hb',1,0,00000000000000006103,'��wq��gzW�Ё��Z]','�4�s@���z��~�'),('208920100001100','33638020001','35609204079201',NULL,'PURGED',120,50000000,100000000,47,0000000000,1,'��G?/�Д���� |hb',1,0,00000000000000006103,'ebd07771ace8677a','�4�s@���z��~�'),('208920100001101','33638020001','35609204079201',NULL,'NOT_PURGED',120,50000000,100000000,47,0000000000,1,'��k��p~Љu{�K�',1,0,00000281044204937234,'\0 \n \r','�$I6;��+f�k�u�|�'),('208920100001102','33638020002','35609204079202',NULL,'PURGED',120,50000000,100000000,47,0000000000,1,'��G?/�Д���� |hb',1,0,00000000000000006103,'ebd07771ace8677a','�4�s@���z��~�'),('208920100001103','33638020003','35609204079203',NULL,'PURGED',120,50000000,100000000,47,0000000000,1,'��G?/�Д���� |hb',1,0,00000000000000006103,'ebd07771ace8677a','�4�s@���z��~�'),('208920100001104','33638020004','35609204079204',NULL,'PURGED',120,50000000,100000000,47,0000000000,1,'��G?/�Д���� |hb',1,0,00000000000000006103,'ebd07771ace8677a','�4�s@���z��~�'),('208920100001105','33638020005','35609204079205',NULL,'PURGED',120,50000000,100000000,47,0000000000,1,'��G?/�Д���� |hb',1,0,00000000000000006103,'ebd07771ace8677a','�4�s@���z��~�'),('208920100001106','33638020006','35609204079206',NULL,'PURGED',120,50000000,100000000,47,0000000000,1,'��k��p~Љu{�K�',1,0,00000000000000006103,'ebd07771ace8677a','�$I6;��+f�k�u�|�'),('208920100001107','33638020007','35609204079207',NULL,'PURGED',120,50000000,100000000,47,0000000000,1,'��G?/�Д���� |hb',1,0,00000000000000006103,'ebd07771ace8677a','�4�s@���z��~�'),('208920100001108','33638020008','35609204079208',NULL,'PURGED',120,50000000,100000000,47,0000000000,1,'��G?/�Д���� |hb',1,0,00000000000000006103,'ebd07771ace8677a','�4�s@���z��~�'),('208920100001109','33638020009','35609204079209',NULL,'PURGED',120,50000000,100000000,47,0000000000,1,'��G?/�Д���� |hb',1,0,00000000000000006103,'ebd07771ace8677a','�4�s@���z��~�'),('208920100001110','33638020010','35609204079210',NULL,'PURGED',120,50000000,100000000,47,0000000000,1,'��G?/�Д���� |hb',1,0,00000000000000006103,'ebd07771ace8677a','�4�s@���z��~�'),('208930100001111','33638030011','35609304079211',NULL,'PURGED',120,50000000,100000000,47,0000000000,1,'��G?/�Д���� |hb',1,0,00000000000000006103,'ebd07771ace8677a','�4�s@���z��~�'),('208930100001112','33638030012','35609304079212',NULL,'PURGED',120,50000000,100000000,47,0000000000,1,'��G?/�Д���� |hb',1,0,00000000000000006103,'ebd07771ace8677a','�4�s@���z��~�'),('208930100001113','33638030013','35609304079213',NULL,'PURGED',120,50000000,100000000,47,0000000000,1,'��G?/�Д���� |hb',1,0,00000000000000006263,'�SNܒ�Iv��e�6','�4�s@���z��~�'),('208950000000008','33638050008','35609204079508',NULL,'PURGED',120,50000000,100000000,47,0000000000,1,'��G?/�Д���� |hb',1,0,00000000000000012215,'56f0261d9d051063','�4�s@���z��~�'),('208950000000009','33638050009','35609204079509',NULL,'PURGED',120,50000000,100000000,47,0000000000,1,'��G?/�Д���� |hb',1,0,00000000000000012215,'56f0261d9d051063','�4�s@���z��~�'),('208950000000010','33638050010','35609204079510',NULL,'PURGED',120,50000000,100000000,47,0000000000,1,'��G?/�Д���� |hb',1,0,00000000000000012215,'56f0261d9d051063','�4�s@���z��~�'),('208950000000011','33638050011','35609204079511',NULL,'PURGED',120,50000000,100000000,47,0000000000,1,'��G?/�Д���� |hb',1,0,00000000000000012215,'56f0261d9d051063','�4�s@���z��~�'),('208950000000012','33638050012','35609204079512',NULL,'PURGED',120,50000000,100000000,47,0000000000,1,'��G?/�Д���� |hb',1,0,00000000000000012215,'56f0261d9d051063','�4�s@���z��~�'),('208950000000013','33638050013','35609204079513',NULL,'PURGED',120,50000000,100000000,47,0000000000,1,'��G?/�Д���� |hb',1,0,00000000000000012215,'56f0261d9d051063','�4�s@���z��~�'),('208950000000014','33638050014','35609204079514',NULL,'PURGED',120,50000000,100000000,47,0000000000,1,'��G?/�Д���� |hb',1,0,00000000000000012215,'56f0261d9d051063','�4�s@���z��~�'),('208950000000015','33638050015','35609204079515',NULL,'PURGED',120,50000000,100000000,47,0000000000,1,'��G?/�Д���� |hb',1,0,00000000000000000000,'3536663032363164','�4�s@���z��~�'),('208920100001118','33638020010','35609204079210',NULL,'NOT_PURGED',120,50000000,100000000,47,0000000000,1,'��k��p~Љu{�K�',1,0,00000281044204934762,'~?03�u-%�ey�y�','�$I6;��+f�k�u�|�'),('208920100001121','33638020010','35609204079210',NULL,'NOT_PURGED',120,50000000,100000000,47,0000000000,1,'��k��p~Љu{�K�',1,0,00000281044204935293,'&��@xg�]���\n��Vp','�$I6;��+f�k�u�|�'),('208920100001119','33638020010','35609204079210',NULL,'NOT_PURGED',120,50000000,100000000,47,0000000000,1,'��k��p~Љu{�K�',1,0,00000281044204935293,'269482407867805d','�$I6;��+f�k�u�|�'),('208920100001120','33638020010','35609204079210',NULL,'NOT_PURGED',120,50000000,100000000,47,0000000000,1,'��k��p~Љu{�K�',1,0,00000281044204935293,'3236393438323430','�$I6;��+f�k�u�|�'); INSERT INTO `users` VALUES ('208990100001100','1','55000000000000',NULL,'PURGED',50,40000000,100000000,47,0000000000,1,0xfec86ba6eb707ed08905757b1bb44b8f,0,0,0x40,'ebd07771ace8677a',0xc42449363bbad02b66d16bc975d77cc1); +INSERT INTO `users` VALUES ('208990100001101','1','55000000000000',NULL,'PURGED',50,40000000,100000000,47,0000000000,1,0xfec86ba6eb707ed08905757b1bb44b8f,0,0,0x40,'ebd07771ace8677a',0xc42449363bbad02b66d16bc975d77cc1); INSERT INTO `users` VALUES ('208950000000031','380561234567','55000000000001',NULL,'PURGED',50,40000000,100000000,47,0000000000,1,0x0C0A34601D4F07677303652C0462535B,0,0,0x40,'ebd07771ace8677a',0x63bfa50ee6523365ff14c1f45f88737d); INSERT INTO `users` VALUES ('208950000000032','380561234567','55000000000001',NULL,'PURGED',50,40000000,100000000,47,0000000000,1,0x0C0A34601D4F07677303652C0462535B,0,0,0x40,'ebd07771ace8677a',0x63bfa50ee6523365ff14c1f45f88737d); INSERT INTO `users` VALUES ('208950000000033','380561234567','55000000000001',NULL,'PURGED',50,40000000,100000000,47,0000000000,1,0x0C0A34601D4F07677303652C0462535B,0,0,0x40,'ebd07771ace8677a',0x63bfa50ee6523365ff14c1f45f88737d); diff --git a/ci-scripts/yaml_files/fr1_epc_20897/docker-compose.yml b/ci-scripts/yaml_files/fr1_epc_20897/docker-compose.yml index a3675dc78e..91d15b5251 100644 --- a/ci-scripts/yaml_files/fr1_epc_20897/docker-compose.yml +++ b/ci-scripts/yaml_files/fr1_epc_20897/docker-compose.yml @@ -132,7 +132,7 @@ services: TZ: Europe/Paris SGW_INTERFACE_NAME_FOR_S11: eth0 PGW_INTERFACE_NAME_FOR_SX: eth0 - DEFAULT_DNS_IPV4_ADDRESS: 192.168.18.129 + DEFAULT_DNS_IPV4_ADDRESS: 172.21.3.100 DEFAULT_DNS_SEC_IPV4_ADDRESS: 8.8.4.4 PUSH_PROTOCOL_OPTION: 'true' APN_NI_1: oai.ipv4 diff --git a/ci-scripts/yaml_files/magma_nsa_20897/docker-compose.yml b/ci-scripts/yaml_files/magma_nsa_20897/docker-compose.yml index df14e900e7..f320e7e3df 100644 --- a/ci-scripts/yaml_files/magma_nsa_20897/docker-compose.yml +++ b/ci-scripts/yaml_files/magma_nsa_20897/docker-compose.yml @@ -116,7 +116,7 @@ services: TZ: Europe/Paris SGW_INTERFACE_NAME_FOR_S11: eth0 PGW_INTERFACE_NAME_FOR_SX: eth0 - DEFAULT_DNS_IPV4_ADDRESS: 192.168.18.129 + DEFAULT_DNS_IPV4_ADDRESS: 172.21.3.100 DEFAULT_DNS_SEC_IPV4_ADDRESS: 8.8.4.4 PUSH_PROTOCOL_OPTION: 'true' APN_NI_1: oai.ipv4 diff --git a/ci-scripts/yaml_files/nsa_b200_enb/docker-compose.yml b/ci-scripts/yaml_files/nsa_b200_enb/docker-compose.yml index 92ccdf8a0a..2df5eac61b 100644 --- a/ci-scripts/yaml_files/nsa_b200_enb/docker-compose.yml +++ b/ci-scripts/yaml_files/nsa_b200_enb/docker-compose.yml @@ -20,7 +20,7 @@ services: NB_PRB: 25 ENABLE_MEASUREMENT_REPORTS: 'yes' ENABLE_X2: 'yes' - MME_S1C_IP_ADDRESS: 192.168.18.210 + MME_S1C_IP_ADDRESS: 172.21.16.136 ENB_S1C_IF_NAME: eth0 ENB_S1C_IP_ADDRESS: 192.168.68.130 ENB_S1U_IF_NAME: eth0 @@ -29,7 +29,7 @@ services: RRC_INACTIVITY_THRESHOLD: 0 FLEXRAN_ENABLED: 'no' FLEXRAN_INTERFACE_NAME: eth0 - FLEXRAN_IPV4_ADDRESS: 192.168.18.210 + FLEXRAN_IPV4_ADDRESS: 172.21.16.136 THREAD_PARALLEL_CONFIG: PARALLEL_SINGLE_THREAD USE_ADDITIONAL_OPTIONS: --log_config.global_log_options level,nocolor,time,line_num,function volumes: 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 c6096956a8..208e1564cd 100644 --- a/ci-scripts/yaml_files/nsa_b200_gnb/docker-compose.yml +++ b/ci-scripts/yaml_files/nsa_b200_gnb/docker-compose.yml @@ -15,7 +15,7 @@ services: TAC: 1 ENABLE_X2: 'yes' ENB_X2_IP_ADDRESS: 192.168.68.130 - MME_S1C_IP_ADDRESS: 192.168.18.210 + MME_S1C_IP_ADDRESS: 172.21.16.136 GNB_S1C_IF_NAME: eth0 GNB_S1C_IP_ADDRESS: 192.168.68.194 GNB_S1U_IF_NAME: eth0 @@ -24,9 +24,9 @@ services: RRC_INACTIVITY_THRESHOLD: 0 FLEXRAN_ENABLED: 'no' FLEXRAN_INTERFACE_NAME: eth0 - FLEXRAN_IPV4_ADDRESS: 192.168.18.210 + FLEXRAN_IPV4_ADDRESS: 172.21.16.136 THREAD_PARALLEL_CONFIG: PARALLEL_RU_L1_TRX_SPLIT - USE_ADDITIONAL_OPTIONS: -E -q --RUs.[0].sdr_addrs serial=30C51D4 --log_config.global_log_options level,nocolor,time,line_num,function + USE_ADDITIONAL_OPTIONS: -E -q --RUs.[0].sdr_addrs serial=30C51D4 --continuous-tx --log_config.global_log_options level,nocolor,time,line_num,function volumes: - /dev:/dev networks: diff --git a/cmake_targets/CMakeLists.txt b/cmake_targets/CMakeLists.txt index 054e231857..ef7d6c4322 100644 --- a/cmake_targets/CMakeLists.txt +++ b/cmake_targets/CMakeLists.txt @@ -53,7 +53,6 @@ include_directories("/usr/local/include/") add_list2_option(RF_BOARD "None" "RF head type" "None" "OAI_USRP" "OAI_BLADERF" "OAI_LMSSDR" "OAI_SIMU" "EXMIMO") if (${RF_BOARD} STREQUAL "OAI_USRP") find_package(Boost REQUIRED) - include_directories(${LIBBOOST_INCLUDE_DIR}) elseif (${RF_BOARD} STREQUAL "OAI_IRIS") include_directories("${OPENAIR_TARGETS}/ARCH/IRIS/USERSPACE/LIB/") @@ -708,11 +707,14 @@ set (SHLIB_LOADER_SOURCES # include RF devices / transport protocols library modules ###################################################################### -include_directories("${OPENAIR_TARGETS}/ARCH/USRP/USERSPACE/LIB/") set(HWLIB_USRP_SOURCE ${OPENAIR_TARGETS}/ARCH/USRP/USERSPACE/LIB/usrp_lib.cpp ) add_library(oai_usrpdevif MODULE ${HWLIB_USRP_SOURCE} ) +target_include_directories(oai_usrpdevif PRIVATE + "${OPENAIR_TARGETS}/ARCH/USRP/USERSPACE/LIB/" + ${Boost_INCLUDE_DIR} +) target_link_libraries(oai_usrpdevif uhd) include_directories("${OPENAIR_TARGETS}/ARCH/BLADERF/USERSPACE/LIB/") @@ -758,27 +760,6 @@ add_library(oai_irisdevif MODULE ${HWLIB_IRIS_SOURCE}) target_include_directories(oai_irisdevif PRIVATE /usr/local/lib/SoapySDR/modules0.7/) target_link_libraries(oai_irisdevif SoapySDR) -# TCP bridge libraries -###################################################################### - -# this one is for internal use at Eurecom and is not documented -set(HWLIB_TCP_BRIDGE_SOURCE - ${OPENAIR_TARGETS}/ARCH/tcp_bridge/tcp_bridge.c - ) -add_library(tcp_bridge MODULE ${HWLIB_TCP_BRIDGE_SOURCE} ) - -#get_target_property(tcp_bridge_cflags tcp_bridge COMPILE_FLAGS) -#set_target_properties(tcp_bridge PROPERTIES COMPILE_FLAGS "${tcp_bridge_cflags} -fvisibility=hidden") -set_target_properties(tcp_bridge PROPERTIES COMPILE_FLAGS "-fvisibility=hidden") - -# this one is to connect OAI eNB and OAI UE in the basic simulator -# see targets/ARCH/tcp_bridge/README.tcp_bridge_oai for usage -set(HWLIB_TCP_BRIDGE_OAI_SOURCE - ${OPENAIR_TARGETS}/ARCH/tcp_bridge/tcp_bridge_oai.c - ) -add_library(tcp_bridge_oai MODULE ${HWLIB_TCP_BRIDGE_OAI_SOURCE} ) -set_target_properties(tcp_bridge_oai PROPERTIES COMPILE_FLAGS "-fvisibility=hidden") - # Benetel 4G library ###################################################################### @@ -1022,8 +1003,6 @@ include_directories("${OPENAIR2_DIR}/ENB_APP/CONTROL_MODULES/RRC") include_directories("${OPENAIR2_DIR}/ENB_APP/CONTROL_MODULES/PDCP") include_directories("${OPENAIR2_DIR}/ENB_APP/CONTROL_MODULES/S1AP") include_directories("${OPENAIR2_DIR}/UTIL/OSA") -include_directories("${OPENAIR2_DIR}/UTIL/LFDS/liblfds6.1.1/liblfds611/inc") -include_directories("${OPENAIR2_DIR}/UTIL/LFDS/liblfds7.0.0/liblfds700/inc") include_directories("${OPENAIR2_DIR}/UTIL/MEM") include_directories("${OPENAIR2_DIR}/UTIL/LISTS") include_directories("${OPENAIR2_DIR}/UTIL/FIFO") @@ -1038,8 +1017,29 @@ include_directories("${OPENAIR2_DIR}/UTIL/OMV") include_directories("${OPENAIR2_DIR}/RRC/LTE/MESSAGES") include_directories("${OPENAIR_DIR}") -# Utilities Library +# flexran ################ +# Make lfds as a own source code (even if it is a outside library) +# only user: Flexran, please don't use lfds in any other component +################################################################### + +set(lfds7 ${OPENAIR2_DIR}/UTIL/LFDS/liblfds7.0.0/liblfds700/src/) +file(GLOB lfds7_queue ${lfds7}/lfds700_queue/*.c) +file(GLOB lfds7_ring ${lfds7}/lfds700_ringbuffer/*.c) +file(GLOB lfds7_qbss ${lfds7}/lfds700_queue_bounded_singleconsumer_singleproducer/*.c) +file(GLOB lfds7_stack ${lfds7}/lfds700_stack/*.c) +file(GLOB lfds7_freelist ${lfds7}/lfds700_freelist/*.c) +file(GLOB lfds7_btree ${lfds7}/lfds700_btree_addonly_unbalanced/*.c) +file(GLOB lfds7_hash ${lfds7}/lfds700_hash_addonly/*.c) +file(GLOB lfds7_ordered_list ${lfds7}/lfds700_list_addonly_ordered_singlylinked/*.c) +file(GLOB lfds7_unordered_list ${lfds7}/lfds700_list_addonly_singlylinked_unordered/*.c) +file(GLOB lfds7_misc ${lfds7}/lfds700_misc/*.c) + +add_library(LFDS7 + ${lfds7_queue} ${lfds7_ring} ${lfds7_qbss} ${lfds7_stack} ${lfds7_freelist} ${lfds7_btree} ${lfds7_hash} ${lfds7_ordered_list} ${lfds7_unordered_list} ${lfds7_misc} +) + +target_include_directories(LFDS7 PRIVATE "${lfds7}") # set the version of protobuf messages, V3 not supported yet add_list1_option(FLPT_VERSION V2 "FLPT MSG protobuf grammar version" V2 V3) @@ -1087,6 +1087,9 @@ add_library(FLPT_MSG ${FLPT_OAI_generated} ${FLPT_source} ) +target_link_libraries(FLPT_MSG LFDS7) +add_dependencies(FLPT_MSG LFDS7) + set(FLPT_MSG_LIB FLPT_MSG) #message("prpt c dir is : ${FLPT_C_DIR}") include_directories (${FLPT_C_DIR}) @@ -1098,6 +1101,7 @@ add_library(ASYNC_IF ${OPENAIR2_DIR}/UTIL/ASYNC_IF/ringbuffer_queue.c ) set(ASYNC_IF_LIB ASYNC_IF) +target_include_directories(ASYNC_IF PRIVATE "${OPENAIR2_DIR}/UTIL/LFDS/liblfds7.0.0/liblfds700/inc") include_directories(${OPENAIR2_DIR}/UTIL/ASYNC_IF) add_library(FLEXRAN_AGENT @@ -1120,7 +1124,9 @@ add_library(FLEXRAN_AGENT ${OPENAIR2_DIR}/ENB_APP/CONTROL_MODULES/MAC/flexran_agent_mac_slice_verification.c ${OPENAIR2_DIR}/ENB_APP/flexran_agent_app.c ) -add_dependencies(FLEXRAN_AGENT rrc_flag) +add_dependencies(FLEXRAN_AGENT rrc_flag ASYNC_IF) +target_link_libraries(FLEXRAN_AGENT ASYNC_IF LFDS7) +target_include_directories(FLEXRAN_AGENT PRIVATE "${OPENAIR2_DIR}/UTIL/LFDS/liblfds7.0.0/liblfds700/inc") set(FLEXRAN_AGENT_LIB FLEXRAN_AGENT) add_library(flapp_sample SHARED ${OPENAIR2_DIR}/ENB_APP/flexran_apps/sample.c @@ -1184,6 +1190,10 @@ set(PROTOBUF_LIB "protobuf-c") #set(PROTOBUF_LIB "protobuf") #for Cpp +########### +# Utilities +############### + add_library(HASHTABLE ${OPENAIR_DIR}/common/utils/hashtable/hashtable.c ${OPENAIR_DIR}/common/utils/hashtable/obj_hashtable.c @@ -1557,9 +1567,10 @@ set(PHY_SRC_UE set(PHY_NR_SRC_COMMON ${OPENAIR1_DIR}/PHY/NR_TRANSPORT/nr_prach_common.c - ${OPENAIR1_DIR}/PHY/NR_UE_TRANSPORT/srs_modulation_nr.c + ${OPENAIR1_DIR}/PHY/NR_TRANSPORT/nr_csi_rs.c ${OPENAIR1_DIR}/PHY/NR_TRANSPORT/nr_scrambling.c ${OPENAIR1_DIR}/PHY/NR_REFSIG/scrambling_luts.c + ${OPENAIR1_DIR}/PHY/NR_UE_TRANSPORT/srs_modulation_nr.c ) set(PHY_NR_SRC @@ -1583,7 +1594,6 @@ set(PHY_SRC_UE ${OPENAIR1_DIR}/PHY/NR_TRANSPORT/nr_ulsch_demodulation.c ${OPENAIR1_DIR}/PHY/NR_REFSIG/ul_ref_seq_nr.c ${OPENAIR1_DIR}/PHY/NR_REFSIG/nr_dmrs_rx.c - ${OPENAIR1_DIR}/PHY/NR_TRANSPORT/nr_csi_rs.c ${OPENAIR1_DIR}/PHY/NR_REFSIG/nr_gold.c ${OPENAIR1_DIR}/PHY/NR_REFSIG/nr_gen_mod_table.c ${OPENAIR1_DIR}/PHY/NR_REFSIG/dmrs_nr.c @@ -1631,6 +1641,7 @@ set(PHY_SRC_UE ${OPENAIR1_DIR}/PHY/NR_UE_TRANSPORT/dci_nr.c ${OPENAIR1_DIR}/PHY/NR_UE_TRANSPORT/dci_tools_nr.c ${OPENAIR1_DIR}/PHY/NR_UE_TRANSPORT/pucch_nr.c + ${OPENAIR1_DIR}/PHY/NR_UE_TRANSPORT/csi_rx.c ${OPENAIR1_DIR}/PHY/NR_TRANSPORT/nr_uci_tools_common.c ${OPENAIR1_DIR}/PHY/NR_UE_TRANSPORT/nr_ulsch_ue.c ${OPENAIR1_DIR}/PHY/NR_REFSIG/ul_ref_seq_nr.c @@ -1796,7 +1807,8 @@ set(NR_PDCP_SRC ) set(NR_SDAP_SRC - ${OPENAIR2_DIR}/SDAP/nr_sdap/nr_sdap_gnb.c + ${OPENAIR2_DIR}/SDAP/nr_sdap/nr_sdap.c + ${OPENAIR2_DIR}/SDAP/nr_sdap/nr_sdap_entity.c ) set(L2_SRC @@ -1806,7 +1818,6 @@ set(L2_SRC ${PDCP_DIR}/pdcp_primitives.c ${PDCP_DIR}/pdcp_util.c ${PDCP_DIR}/pdcp_security.c - ${PDCP_DIR}/pdcp_netlink.c ${OPENAIR2_DIR}/LAYER2/openair2_proc.c # ${RRC_DIR}/rrc_UE.c ${RRC_DIR}/rrc_eNB.c @@ -1861,7 +1872,6 @@ set(L2_SRC_UE ${PDCP_DIR}/pdcp_primitives.c ${PDCP_DIR}/pdcp_util.c ${PDCP_DIR}/pdcp_security.c - ${PDCP_DIR}/pdcp_netlink.c ${RRC_DIR}/rrc_UE.c ${RRC_DIR}/rrc_common.c ${RRC_DIR}/L2_interface_common.c @@ -1884,6 +1894,7 @@ set(NR_L2_SRC_UE ${NR_RRC_DIR}/nr_rrc_config.c ${NR_UE_RRC_DIR}/rrc_UE.c ${NR_UE_RRC_DIR}/rrc_nsa.c + ${NR_RRC_DIR}/nr_rrc_config.c ) set (MAC_SRC @@ -2402,43 +2413,6 @@ add_library(LIB_5GNAS_GNB ) target_link_libraries(LIB_5GNAS_GNB SECU_CN ${CRYPTO_LIBRARIES}) -# Make lfds as a own source code (even if it is a outside library) -# For better intergration with compilation flags & structure of cmake -################################################################### -set(lfds ${OPENAIR2_DIR}/UTIL/LFDS/liblfds6.1.1/liblfds611/src/) -file(GLOB lfds_queue ${lfds}/lfds611_queue/*.c) -file(GLOB lfds_ring ${lfds}/lfds611_ringbuffer/*.c) -file(GLOB lfds_slist ${lfds}/lfds611_slist/*.c) -file(GLOB lfds_stack ${lfds}/lfds611_stack/*.c) -file(GLOB lfds_freelist ${lfds}/lfds611_freelist/*.c) - -include_directories(${lfds}) -add_library(LFDS - ${lfds_queue} ${lfds_ring} ${lfds_slist} ${lfds_stack} ${lfds_freelist} - ${lfds}/lfds611_liblfds/lfds611_liblfds_abstraction_test_helpers.c - ${lfds}/lfds611_liblfds/lfds611_liblfds_aligned_free.c - ${lfds}/lfds611_liblfds/lfds611_liblfds_aligned_malloc.c - ${lfds}/lfds611_abstraction/lfds611_abstraction_free.c - ${lfds}/lfds611_abstraction/lfds611_abstraction_malloc.c -) - -set(lfds7 ${OPENAIR2_DIR}/UTIL/LFDS/liblfds7.0.0/liblfds700/src/) -file(GLOB lfds7_queue ${lfds7}/lfds700_queue/*.c) -file(GLOB lfds7_ring ${lfds7}/lfds700_ringbuffer/*.c) -file(GLOB lfds7_qbss ${lfds7}/lfds700_queue_bounded_singleconsumer_singleproducer/*.c) -file(GLOB lfds7_stack ${lfds7}/lfds700_stack/*.c) -file(GLOB lfds7_freelist ${lfds7}/lfds700_freelist/*.c) -file(GLOB lfds7_btree ${lfds7}/lfds700_btree_addonly_unbalanced/*.c) -file(GLOB lfds7_hash ${lfds7}/lfds700_hash_addonly/*.c) -file(GLOB lfds7_ordered_list ${lfds7}/lfds700_list_addonly_ordered_singlylinked/*.c) -file(GLOB lfds7_unordered_list ${lfds7}/lfds700_list_addonly_singlylinked_unordered/*.c) -file(GLOB lfds7_misc ${lfds7}/lfds700_misc/*.c) - -include_directories(${lfds7}) -add_library(LFDS7 - ${lfds7_queue} ${lfds7_ring} ${lfds7_qbss} ${lfds7_stack} ${lfds7_freelist} ${lfds7_btree} ${lfds7_hash} ${lfds7_ordered_list} ${lfds7_unordered_list} ${lfds7_misc} -) - add_library(SIMU_COMMON ${OPENAIR1_DIR}/SIMULATION/TOOLS/random_channel.c ${OPENAIR1_DIR}/SIMULATION/TOOLS/rangen_double.c @@ -2628,8 +2602,8 @@ add_dependencies(lte-softmodem rrc_flag s1ap_flag x2_flag oai_iqplayer) target_link_libraries (lte-softmodem -Wl,--start-group RRC_LIB NR_RRC_LIB S1AP_LIB S1AP_ENB M2AP_LIB M2AP_ENB X2AP_LIB X2AP_ENB M3AP_LIB M3AP_ENB GTPV1U F1AP_LIB F1AP SECU_CN SECU_OSA UTIL HASHTABLE SCTP_CLIENT MME_APP SCHED_LIB SCHED_RU_LIB - PHY_COMMON PHY PHY_RU LFDS L2 L2_LTE NFAPI_COMMON_LIB NFAPI_LIB NFAPI_VNF_LIB NFAPI_PNF_LIB NFAPI_USER_LIB MISC_NFAPI_LTE_LIB LFDS7 - ${RAL_LIB} ${NAS_UE_LIB} ITTI ${FLPT_MSG_LIB} ${ASYNC_IF_LIB} ${FLEXRAN_AGENT_LIB} ${FSPT_MSG_LIB} + PHY_COMMON PHY PHY_RU L2 L2_LTE NFAPI_COMMON_LIB NFAPI_LIB NFAPI_VNF_LIB NFAPI_PNF_LIB NFAPI_USER_LIB MISC_NFAPI_LTE_LIB + ${RAL_LIB} ${NAS_UE_LIB} ITTI ${FLPT_MSG_LIB} ${FLEXRAN_AGENT_LIB} ${FSPT_MSG_LIB} -Wl,--end-group z dl) target_link_libraries (lte-softmodem ${LIBXML2_LIBRARIES}) @@ -2668,8 +2642,8 @@ target_link_libraries (ocp-enb -Wl,--start-group RRC_LIB NR_RRC_LIB S1AP_LIB S1AP_ENB F1AP_LIB F1AP M2AP_LIB M2AP_ENB X2AP_LIB X2AP_ENB M3AP_LIB M3AP_ENB GTPV1U SECU_CN SECU_OSA UTIL HASHTABLE SCTP_CLIENT MME_APP SCHED_LIB SCHED_RU_LIB - PHY_COMMON PHY PHY_RU LFDS L2 L2_LTE NFAPI_COMMON_LIB NFAPI_LIB MISC_NFAPI_LTE_LIB NFAPI_VNF_LIB NFAPI_PNF_LIB NFAPI_USER_LIB LFDS7 SIMU_COMMON - ${RAL_LIB} ${NAS_UE_LIB} ITTI ${FLPT_MSG_LIB} ${ASYNC_IF_LIB} ${FLEXRAN_AGENT_LIB} ${FSPT_MSG_LIB} + PHY_COMMON PHY PHY_RU L2 L2_LTE NFAPI_COMMON_LIB NFAPI_LIB MISC_NFAPI_LTE_LIB NFAPI_VNF_LIB NFAPI_PNF_LIB NFAPI_USER_LIB SIMU_COMMON + ${RAL_LIB} ${NAS_UE_LIB} ITTI ${FLPT_MSG_LIB} ${FLEXRAN_AGENT_LIB} ${FSPT_MSG_LIB} -Wl,--end-group z dl) target_link_libraries (ocp-enb ${LIBXML2_LIBRARIES} pthread m CONFIG_LIB rt crypt ${CRYPTO_LIBRARIES} ${OPENSSL_LIBRARIES} sctp ${PROTOBUF_LIB} ${CMAKE_DL_LIBS} ${LIBYAML_LIBRARIES} ${LIB_LMS_LIBRARIES} ${T_LIB}) @@ -2726,8 +2700,8 @@ target_link_libraries (lte-uesoftmodem -Wl,--start-group RRC_LIB NR_RRC_LIB S1AP_LIB S1AP_ENB X2AP_LIB X2AP_ENB M2AP_LIB M2AP_ENB M3AP_LIB M3AP_ENB SECU_CN SECU_OSA UTIL HASHTABLE SCTP_CLIENT MME_APP SCHED_RU_LIB SCHED_UE_LIB PHY_COMMON - PHY_UE PHY_RU LFDS L2_UE L2_LTE LFDS7 SIMU_COMMON SIMU NFAPI_COMMON_LIB NFAPI_LIB NFAPI_PNF_LIB NFAPI_USER_LIB MISC_NFAPI_LTE_LIB - ${RAL_LIB} ${NAS_UE_LIB} ITTI ${FLPT_MSG_LIB} ${ASYNC_IF_LIB} ${ATLAS_LIBRARIES} + PHY_UE PHY_RU L2_UE L2_LTE SIMU_COMMON SIMU NFAPI_COMMON_LIB NFAPI_LIB NFAPI_PNF_LIB NFAPI_USER_LIB MISC_NFAPI_LTE_LIB + ${RAL_LIB} ${NAS_UE_LIB} ITTI ${FLPT_MSG_LIB} ${ATLAS_LIBRARIES} -Wl,--end-group z dl) target_link_libraries (lte-uesoftmodem ${LIBXML2_LIBRARIES}) @@ -2765,8 +2739,8 @@ add_executable(nr-softmodem target_link_libraries (nr-softmodem -Wl,--start-group - UTIL HASHTABLE SCTP_CLIENT SCHED_LIB SCHED_RU_LIB SCHED_NR_LIB PHY_NR PHY PHY_COMMON PHY_NR_COMMON PHY_RU LFDS GTPV1U SECU_CN SECU_OSA - ITTI ${FLPT_MSG_LIB} ${ASYNC_IF_LIB} ${FLEXRAN_AGENT_LIB} LFDS7 ${RAL_LIB} ${NAS_UE_LIB} RRC_LIB NR_RRC_LIB + UTIL HASHTABLE SCTP_CLIENT SCHED_LIB SCHED_RU_LIB SCHED_NR_LIB PHY_NR PHY PHY_COMMON PHY_NR_COMMON PHY_RU GTPV1U SECU_CN SECU_OSA + ITTI ${FLPT_MSG_LIB} ${FLEXRAN_AGENT_LIB} ${RAL_LIB} ${NAS_UE_LIB} RRC_LIB NR_RRC_LIB NGAP_LIB NGAP_GNB S1AP_LIB S1AP_ENB L2_LTE_NR L2_NR MAC_NR_COMMON NFAPI_COMMON_LIB NFAPI_LIB NFAPI_VNF_LIB NFAPI_PNF_LIB NFAPI_USER_LIB X2AP_LIB X2AP_ENB F1AP_LIB F1AP M2AP_LIB M2AP_ENB M3AP_LIB M3AP_ENB ${FSPT_MSG_LIB} -Wl,--end-group z dl) @@ -2809,11 +2783,11 @@ add_executable(nr-uesoftmodem target_link_libraries (nr-uesoftmodem -Wl,--start-group RRC_LIB NR_RRC_LIB NGAP_LIB NGAP_GNB SECU_CN SECU_OSA UTIL HASHTABLE SCTP_CLIENT SCHED_RU_LIB SCHED_UE_LIB SCHED_NR_UE_LIB - PHY_COMMON PHY_NR_COMMON PHY_UE PHY_NR_UE PHY_RU LFDS NR_L2_UE L2_UE_LTE_NR MAC_NR_COMMON NFAPI_COMMON_LIB NFAPI_LIB NFAPI_PNF_LIB + PHY_COMMON PHY_NR_COMMON PHY_UE PHY_NR_UE PHY_RU NR_L2_UE L2_UE_LTE_NR MAC_NR_COMMON NFAPI_COMMON_LIB NFAPI_LIB NFAPI_PNF_LIB NFAPI_USER_LIB MISC_NFAPI_NR_LIB S1AP_LIB S1AP_ENB - ${RAL_LIB} ${NAS_UE_LIB} ITTI ${FLPT_MSG_LIB} ${ASYNC_IF_LIB} LFDS7 ${ATLAS_LIBRARIES} + ${RAL_LIB} ${NAS_UE_LIB} ITTI ${FLPT_MSG_LIB} ${ATLAS_LIBRARIES} NFAPI_USER_LIB S1AP_LIB S1AP_ENB - ${RAL_LIB} ${NAS_UE_LIB} ITTI ${FLPT_MSG_LIB} ${ASYNC_IF_LIB} LFDS7 ${ATLAS_LIBRARIES} LIB_5GNAS_GNB LIB_NAS_SIMUE ${NAS_SIM_LIB} + ${RAL_LIB} ${NAS_UE_LIB} ITTI ${FLPT_MSG_LIB} ${ATLAS_LIBRARIES} LIB_5GNAS_GNB LIB_NAS_SIMUE ${NAS_SIM_LIB} -Wl,--end-group z dl) target_link_libraries (nr-uesoftmodem ${LIBXML2_LIBRARIES}) @@ -2842,7 +2816,7 @@ add_executable(dlsim_tm4 ${T_SOURCE} ) target_link_libraries (dlsim_tm4 - -Wl,--start-group SIMU_COMMON SIMU UTIL SCHED_LIB SCHED_RU_LIB PHY LFDS ITTI -Wl,--end-group + -Wl,--start-group SIMU_COMMON SIMU UTIL SCHED_LIB SCHED_RU_LIB PHY ITTI -Wl,--end-group pthread m rt CONFIG_LIB ${ATLAS_LIBRARIES} ${T_LIB} ) @@ -2899,6 +2873,7 @@ target_link_libraries(ldpctest add_executable(nr_dlschsim ${OPENAIR1_DIR}/SIMULATION/NR_PHY/dlschsim.c ${OPENAIR_DIR}/common/utils/nr/nr_common.c + ${OPENAIR_DIR}/executables/softmodem-common.c ${T_SOURCE} ${SHLIB_LOADER_SOURCES} ) @@ -2922,6 +2897,7 @@ target_link_libraries(nr_pbchsim add_executable(nr_pucchsim ${OPENAIR1_DIR}/SIMULATION/NR_PHY/pucchsim.c ${OPENAIR_DIR}/common/utils/nr/nr_common.c + ${OPENAIR_DIR}/executables/softmodem-common.c ${T_SOURCE} ${SHLIB_LOADER_SOURCES} ) @@ -2966,6 +2942,7 @@ target_link_libraries(nr_prachsim add_executable(nr_ulschsim ${OPENAIR1_DIR}/SIMULATION/NR_PHY/ulschsim.c ${OPENAIR_DIR}/common/utils/nr/nr_common.c + ${OPENAIR_DIR}/executables/softmodem-common.c ${PHY_INTERFACE_DIR}/queue_t.c ${T_SOURCE} ${SHLIB_LOADER_SOURCES} @@ -3011,7 +2988,7 @@ foreach(myExe dlsim dlsim_tm7 ulsim pbchsim scansim mbmssim pdcchsim pucchsim pr ${NFAPI_USER_DIR}/nfapi.c ) target_link_libraries (${myExe} - -Wl,--start-group SIMU_COMMON SIMU UTIL SCHED_LIB SCHED_RU_LIB SCHED_UE_LIB PHY_COMMON PHY_NR_COMMON PHY PHY_UE PHY_RU LFDS ITTI LFDS7 -Wl,--end-group + -Wl,--start-group SIMU_COMMON SIMU UTIL SCHED_LIB SCHED_RU_LIB SCHED_UE_LIB PHY_COMMON PHY_NR_COMMON PHY PHY_UE PHY_RU ITTI -Wl,--end-group pthread m rt CONFIG_LIB ${ATLAS_LIBRARIES} ${XFORMS_LIBRARIES} ${T_LIB} dl ) @@ -3033,7 +3010,7 @@ foreach(myExe s1ap ${OPENAIR3_DIR}/TEST/test_${myExe}.c ) target_link_libraries (test_${myExe} - -Wl,--start-group SECU_CN UTIL LFDS -Wl,--end-group m rt crypt ${CRYPTO_LIBRARIES} ${OPENSSL_LIBRARIES} CONFIG_LIB + -Wl,--start-group SECU_CN UTIL -Wl,--end-group m rt crypt ${CRYPTO_LIBRARIES} ${OPENSSL_LIBRARIES} CONFIG_LIB ) endforeach(myExe) @@ -3053,13 +3030,12 @@ if (${T_TRACER}) #all "add_library" definitions ITTI RRC_LIB NR_RRC_LIB S1AP_LIB S1AP_ENB X2AP_LIB X2AP_ENB M2AP_LIB M2AP_ENB M3AP_LIB M3AP_ENB F1AP_LIB F1AP params_libconfig oai_exmimodevif oai_usrpdevif oai_bladerfdevif oai_lmssdrdevif oai_iqplayer - oai_eth_transpro oai_mobipass tcp_bridge tcp_bridge_oai - coding FLPT_MSG ASYNC_IF FLEXRAN_AGENT HASHTABLE UTIL OMG_SUMO + oai_eth_transpro oai_mobipass coding FLPT_MSG FLEXRAN_AGENT HASHTABLE UTIL OMG_SUMO SECU_OSA SECU_CN SCHED_LIB SCHED_NR_LIB SCHED_RU_LIB SCHED_UE_LIB SCHED_NR_UE_LIB default_sched remote_sched RAL NFAPI_COMMON_LIB NFAPI_LIB NFAPI_PNF_LIB NFAPI_VNF_LIB NFAPI_USER_LIB PHY_COMMON PHY PHY_UE PHY_NR PHY_NR_COMMON PHY_NR_UE PHY_RU PHY_MEX L2 L2_LTE L2_NR L2_LTE_NR L2_UE NR_L2_UE L2_UE_LTE_NR MAC_NR_COMMON MAC_NR MAC_UE_NR NGAP_GNB - CN_UTILS GTPV1U SCTP_CLIENT MME_APP LIB_NAS_UE NB_IoT LFDS LFDS7 SIMU_COMMON SIMU SIMU_ETH OPENAIR0_LIB + CN_UTILS GTPV1U SCTP_CLIENT MME_APP LIB_NAS_UE NB_IoT SIMU_COMMON SIMU SIMU_ETH OPENAIR0_LIB ldpc_orig ldpc_optim ldpc_optim8seg ldpc dfts) if (TARGET ${i}) add_dependencies(${i} generate_T) @@ -3163,8 +3139,8 @@ add_executable(nr-ittisim target_link_libraries (nr-ittisim -Wl,--start-group - UTIL HASHTABLE SCTP_CLIENT SCHED_LIB SCHED_RU_LIB SCHED_NR_LIB PHY_NR PHY PHY_COMMON PHY_NR_COMMON PHY_RU LFDS GTPV1U SECU_CN SECU_OSA - ITTI ${FLPT_MSG_LIB} ${ASYNC_IF_LIB} ${FLEXRAN_AGENT_LIB} LFDS7 ${RAL_LIB} ${NAS_SIM_LIB} RRC_LIB NR_RRC_LIB + UTIL HASHTABLE SCTP_CLIENT SCHED_LIB SCHED_RU_LIB SCHED_NR_LIB PHY_NR PHY PHY_COMMON PHY_NR_COMMON PHY_RU GTPV1U SECU_CN SECU_OSA + ITTI ${FLPT_MSG_LIB} ${FLEXRAN_AGENT_LIB} ${RAL_LIB} ${NAS_SIM_LIB} RRC_LIB NR_RRC_LIB NGAP_LIB NGAP_GNB S1AP_LIB S1AP_ENB L2_LTE_NR L2_NR MAC_NR_COMMON NFAPI_COMMON_LIB NFAPI_LIB NFAPI_VNF_LIB NFAPI_PNF_LIB NFAPI_USER_LIB X2AP_LIB X2AP_ENB F1AP_LIB F1AP M2AP_LIB M2AP_ENB M3AP_LIB M3AP_ENB ${FSPT_MSG_LIB} PHY_NR_UE SCHED_NR_UE_LIB NR_L2_UE diff --git a/cmake_targets/autotests/test_case_list.xml b/cmake_targets/autotests/test_case_list.xml index 7497fb419c..1fdc3446d9 100755 --- a/cmake_targets/autotests/test_case_list.xml +++ b/cmake_targets/autotests/test_case_list.xml @@ -1094,9 +1094,9 @@ (Test9: 106 PRBs 50 PDSCH-PRBs MCS Index 27), (Test10: 106 PRBs 50 PDSCH-PRBs MCS Index 16), (Test11: 106 MCS-TABLE 256 QAM MCS Index 26), - (Test12: HARQ test 25% TP (4 rounds), - (Test13: HARQ test 33% TP (3 rounds), - (Test14: HARQ test 50% TP (2 rounds), + (Test12: HARQ test 25% TP 4 rounds), + (Test13: HARQ test 33% TP 3 rounds), + (Test14: HARQ test 50% TP 2 rounds), (Test15: 3 PTRS, 8 Interpolated Symbols), (Test16: 6 PTRS, 5 Interpolated Symbols), (Test17: 11 PTRS, 0 Interpolated Symbols), @@ -1104,7 +1104,8 @@ (Test19: Mapping type A, 3 DMRS Symbols), (Test20: Mapping type B, 4 DMRS Symbols), (Test21: 4x4 MIMO, 1 Layer), - (Test22: 4x4 MIMO, 2 Layers) + (Test22: 4x4 MIMO, 2 Layers), + (Test23: 25 PRBs, 15 kHz SCS) $OPENAIR_DIR/cmake_targets/build_oai --phy_simulators -c @@ -1121,7 +1122,7 @@ -n100 -R217 -a110 -s5 -b100 -n100 -e27 -s30 -n100 -e16 -s10 - -n100 -q1 -e27 -s30 + -n100 -q1 -e26 -s30 -n100 -s1 -t25 -n100 -s1 -t33 -n100 -s1 -t50 @@ -1132,8 +1133,9 @@ -n100 -s2 -U 2 0 2 -n100 -s2 -U 2 1 3 -n10 -s20 -U 3 0 0 2 -gR -x1 -y4 -z4 - -n10 -s20 -U 3 0 0 2 -gR -x2 -y4 -z4 - nr_dlsim.test1 nr_dlsim.test2 nr_dlsim.test3 nr_dlsim.test4 nr_dlsim.test5 nr_dlsim.test6 nr_dlsim.test7 nr_dlsim.test8 nr_dlsim.test9 nr_dlsim.test10 nr_dlsim.test11 nr_dlsim.test12 nr_dlsim.test13 nr_dlsim.test14 nr_dlsim.test15 nr_dlsim.test16 nr_dlsim.test17 nr_dlsim.test18 nr_dlsim.test19 nr_dlsim.test20 nr_dlsim.test21 nr_dlsim.test22 + -n10 -s20 -U 3 0 0 2 -gR -x2 -y4 -z4 + -n100 -m0 -e0 -R25 -b25 -i 2 1 0 + nr_dlsim.test1 nr_dlsim.test2 nr_dlsim.test3 nr_dlsim.test4 nr_dlsim.test5 nr_dlsim.test6 nr_dlsim.test7 nr_dlsim.test8 nr_dlsim.test9 nr_dlsim.test10 nr_dlsim.test11 nr_dlsim.test12 nr_dlsim.test13 nr_dlsim.test14 nr_dlsim.test15 nr_dlsim.test16 nr_dlsim.test17 nr_dlsim.test18 nr_dlsim.test19 nr_dlsim.test20 nr_dlsim.test21 nr_dlsim.test22 nr_dlsim.test23 PDSCH test OK segmentation fault|assertion|exiting|fatal 3 @@ -1184,9 +1186,10 @@ execution - nr_ulschsim Test cases. (Test1: 106 PRB), - (Test2: 217 PRB), - (Test3: 273 PRB) + nr_ulschsim Test cases. (Test1: 106 PRBs), + (Test2: 217 PRBs), + (Test3: 273 PRBs) + (Test4: 106 PRBs 4-layer MIMO) $OPENAIR_DIR/cmake_targets/build_oai --phy_simulators -c @@ -1195,8 +1198,9 @@ $OPENAIR_DIR/targets/bin/nr_ulschsim.Rel15 -R 106 -m9 -s13 -n100 -R 217 -m15 -s15 -n100 - -R 273 -m19 -s20 -n100 - nr_ulschsim.test1 nr_ulschsim.test2 nr_ulschsim.test3 + -R 273 -m19 -s20 -n100 + -R 106 -m9 -s13 -n100 -y4 -z4 -W4 + nr_ulschsim.test1 nr_ulschsim.test2 nr_ulschsim.test3 nr_ulschsim.test4 PUSCH test OK segmentation fault|assertion|exiting|fatal 3 @@ -1304,7 +1308,13 @@ (Test12: SC-FDMA, 216 PRBs), (Test13: SC-FDMA, 273 PRBs), (Test14: SC-FDMA, 3 DMRS), - (Test15: MCS 16 50 PRBs 2 RX_Antenna) + (Test15: MCS 19 50 PRBs 2 RX_Antenna), + (Test16: MCS 9 106 PRBs MIMO 2 layers), + (Test17: MCS 9 106 PRBs MIMO 4 layers), + (Test18: 25 PRBs, 15 kHz SCS), + (Test19: 3GPP G-FR1-A4-13 2 RX Antennas Requirements Test), + (Test20: 3GPP G-FR1-A4-13 4 RX Antennas Requirements Test), + (Test21: 3GPP G-FR1-A4-13 8 RX Antennas Requirements Test) $OPENAIR_DIR/cmake_targets/build_oai --phy_simulators -c @@ -1316,18 +1326,24 @@ -n100 -m28 -s20 -n100 -m9 -R217 -r217 -s5 -n100 -m9 -R273 -r273 -s5 - -n100 -s5 -U 2 0 1 - -n100 -s5 -T 2 1 2 -U 2 0 2 - -n100 -s5 -T 2 2 2 -U 2 1 2 - -n100 -s5 -a4 -b8 -T 2 1 2 -U 2 1 3 + -n100 -s5 -U 4 0 1 1 1 + -n100 -s5 -T 2 1 2 -U 4 0 2 1 1 + -n100 -s5 -T 2 2 2 -U 4 1 2 1 1 + -n100 -s5 -a4 -b8 -T 2 1 2 -U 4 1 3 1 1 -n100 -s5 -Z -n100 -s5 -Z -r75 -n50 -s5 -Z -r216 -R217 -n50 -s5 -Z -r270 -R273 - -n100 -s5 -Z -U 2 0 2 - -n100 -m16 -s10 -z2 + -n100 -s5 -Z -U 4 0 2 1 2 + -n100 -m19 -s10 -S15 -z2 + -n100 -m9 -r106 -s10 -W2 -y2 -z2 + -n100 -m9 -r106 -s20 -W4 -y4 -z4 + -n100 -u0 -m0 -R25 -r25 -i 2 1 0 + -m16 -r106 -s8.8 -S9.4 -z2 -n200 -U 4 1 1 1 2 -gI -b14 -t70 -I15 -i 2 1 0 + -m16 -r106 -s5.4 -S6 -z4 -n200 -U 4 1 1 1 2 -gI -b14 -t70 -I15 -i 2 1 0 + -m16 -r106 -s3.4 -S3.8 -z8 -n200 -U 4 1 1 1 2 -gI -b14 -t70 -I15 -i 2 1 0 - nr_ulsim.test1 nr_ulsim.test2 nr_ulsim.test3 nr_ulsim.test4 nr_ulsim.test5 nr_ulsim.test6 nr_ulsim.test7 nr_ulsim.test8 nr_ulsim.test9 nr_ulsim.test10 nr_ulsim.test11 nr_ulsim.test12 nr_ulsim.test13 nr_ulsim.test14 nr_ulsim.test15 + nr_ulsim.test1 nr_ulsim.test2 nr_ulsim.test3 nr_ulsim.test4 nr_ulsim.test5 nr_ulsim.test6 nr_ulsim.test7 nr_ulsim.test8 nr_ulsim.test9 nr_ulsim.test10 nr_ulsim.test11 nr_ulsim.test12 nr_ulsim.test13 nr_ulsim.test14 nr_ulsim.test15 nr_ulsim.test16 nr_ulsim.test17 nr_ulsim.test18 nr_ulsim.test19 nr_ulsim.test20 nr_ulsim.test21 PUSCH test OK segmentation fault|assertion|exiting|fatal 3 @@ -1338,10 +1354,11 @@ nr_prachsim Test cases. (Test1: 30kHz SCS, 106 PRBs, Prach format A2), (Test2: 30kHz SCS, 217 PRBs, Prach format A2), (Test3: 30kHz SCS, 273 PRBs, Prach format A2), - (Test4: 30kHz SCS, 106 PRBs, Prach format 0), + (Test4: 30kHz SCS, 106 PRBs, Prach format 0), (Test5: 120kHz SCS, 32 PRBs, Prach format A2), (Test6: 120kHz SCS, 66 PRBs, Prach format A2), - (Test7: 120kHz SCS, 66 PRBs, High Speed Enabled) + (Test7: 120kHz SCS, 66 PRBs, High Speed Enabled), + (Test8: 15kHz SCS, 25 PRBs) $OPENAIR_DIR/cmake_targets/build_oai --phy_simulators -c @@ -1351,11 +1368,12 @@ -a -s -30 -n 100 -p 63 -R 106 -a -s -30 -n 100 -p 63 -R 217 -a -s -30 -n 100 -p 63 -R 273 - -a -s -30 -n 100 -p 63 -R 106 -c 4 - -a -s -30 -n 100 -p 32 -R 32 -m 3 -c52 - -a -s -30 -n 100 -p 32 -R 66 -m 3 -c52 - -a -s -30 -n 100 -R 66 -m 3 -c52 -H - nr_prachsim.test1 nr_prachsim.test2 nr_prachsim.test3 nr_prachsim.test4 nr_prachsim.test5 nr_prachsim.test6 nr_prachsim.test7 + -a -s -30 -n 100 -p 63 -R 106 -c 4 + -a -s -30 -n 100 -p 32 -R 32 -m 3 -c52 + -a -s -30 -n 100 -p 32 -R 66 -m 3 -c52 + -a -s -30 -n 100 -R 66 -m 3 -c52 -H + -a -s -30 -n 100 -p 99 -R 25 -m 0 + nr_prachsim.test1 nr_prachsim.test2 nr_prachsim.test3 nr_prachsim.test4 nr_prachsim.test5 nr_prachsim.test6 nr_prachsim.test7 nr_prachsim.test8 PRACH test OK segmentation fault|assertion|exiting|fatal 3 diff --git a/cmake_targets/build_oai b/cmake_targets/build_oai index 930f2a7f77..6e788c9676 100755 --- a/cmake_targets/build_oai +++ b/cmake_targets/build_oai @@ -59,19 +59,24 @@ BUILD_ECLIPSE=0 NR="False" OPTIONAL_LIBRARIES="telnetsrv enbscope uescope nrscope" RU=0 -trap handle_ctrl_c INT +CMAKE_C_FLAGS=() +CMAKE_CXX_FLAGS=() function print_help() { echo_info " -This program installs OpenAirInterface Software -You should have ubuntu 16.xx or 18.04 updated -Options +This script compiles OpenAirInterface Software, and can install dependencies +for a number of distributions (Ubuntu 18-22, Fedora, RHEL7/8). +Options: +--arch-native + Passes -march=native to the compiler. -c | --clean Erase all files to make a rebuild from start -C | --clean-all Erase all files made by previous compilations, installations --clean-kernel Erase previously installed features in kernel: iptables, drivers, ... +--cmake-opt + Pass the supplied option verbatim to cmake. -d | --build-dir Sets build directory (will be /cmake_targets//build) -I | --install-external-packages @@ -183,6 +188,10 @@ function main() { until [ -z "$1" ] do case "$1" in + --arch-native) + CMAKE_C_FLAGS+=("-march=native") + CMAKE_CXX_FLAGS+=("-march=native") + shift;; -c | --clean) CLEAN=1 shift;; @@ -193,9 +202,12 @@ function main() { clean_kernel echo_info "Erased iptables config and removed modules from kernel" shift;; + --cmake-opt) + CMAKE_CMD="$CMAKE_CMD $2" + shift 2;; -d | --build-dir) BUILD_DIR=$2 - shift;; + shift 2;; -I | --install-external-packages) INSTALL_EXTERNAL=1 echo_info "Will install external packages" @@ -565,8 +577,7 @@ function main() { #fi fi echo_info "Installing protobuf/protobuf-c for flexran agent support" - install_protobuf_from_source - install_protobuf_c_from_source + install_protobuf_c echo_success "protobuf/protobuf-c installation successful" fi @@ -575,19 +586,6 @@ function main() { check_install_additional_tools fi - - - echo_info "3. building the compilation directives ..." - - DIR=$OPENAIR_DIR/cmake_targets - - [ "$CLEAN" = "1" ] && rm -rf $DIR/$BUILD_DIR/build - mkdir -p $DIR/$BUILD_DIR/build - - cd $DIR/$BUILD_DIR/build - echo_info "running $CMAKE_CMD" - eval $CMAKE_CMD ../.. - execlist="" if [ "$eNB" = "1" ] ; then execlist="$execlist lte-softmodem" @@ -607,10 +605,27 @@ function main() { if [ "$nrUE" = 1 ] ; then execlist="$execlist nr-uesoftmodem" fi - if [ "$ittiSIM" = "1" ] ; then execlist="$execlist nr-ittisim" fi + + if [[ "$execlist" == "" && "$SIMUS_PHY" != "1" ]]; then + echo_success "installing dependencies successful" + exit + fi + + echo_info "3. building the compilation directives ..." + + DIR=$OPENAIR_DIR/cmake_targets + + [ "$CLEAN" = "1" ] && rm -rf $DIR/$BUILD_DIR/build + mkdir -p $DIR/$BUILD_DIR/build + + cd $DIR/$BUILD_DIR/build + if [[ ${#CMAKE_C_FLAGS[@]} > 0 ]]; then CMAKE_CMD="$CMAKE_CMD -DCMAKE_C_FLAGS=\"${CMAKE_C_FLAGS[*]}\""; fi + if [[ ${#CMAKE_CXX_FLAGS[@]} > 0 ]]; then CMAKE_CMD="$CMAKE_CMD -DCMAKE_CXX_FLAGS=\"${CMAKE_CXX_FLAGS[*]}\""; fi + echo_info "running $CMAKE_CMD" + eval $CMAKE_CMD ../.. for f in $execlist ; do echo_info "Compiling $f..." @@ -698,11 +713,11 @@ function main() { # simlist="ldpctest" for f in $simlist ; do compilations \ - ran_build $f \ + $BUILD_DIR $f \ $f $dbin/$f.$REL done compilations \ - ran_build coding \ + $BUILD_DIR coding \ libcoding.so $dbin/libcoding.so fi @@ -714,7 +729,7 @@ function main() { simlist="secu_knas_encrypt_eia1 secu_kenb aes128_ctr_encrypt aes128_ctr_decrypt secu_knas_encrypt_eea2 secu_knas secu_knas_encrypt_eea1 kdf aes128_cmac_encrypt secu_knas_encrypt_eia2" for f in $simlist ; do compilations \ - ran_build test_$f \ + $BUILD_DIR test_$f \ test_$f $dbin/test_$f.$REL done fi @@ -894,11 +909,6 @@ function main() { compilations \ $BUILD_DIR rfsimulator \ librfsimulator.so $dbin/librfsimulator.so.$REL - - echo_info "Compiling tcp_bridge_oai" - compilations \ - $BUILD_DIR tcp_bridge_oai \ - libtcp_bridge_oai.so $dbin/libtcp_bridge_oai.so.$REL fi #build transport protocol libraries (currently only ETHERNET is available) diff --git a/cmake_targets/install_external_packages.ubuntu20 b/cmake_targets/install_external_packages.ubuntu20 deleted file mode 100755 index a2f6a9709c..0000000000 --- a/cmake_targets/install_external_packages.ubuntu20 +++ /dev/null @@ -1,499 +0,0 @@ -#!/bin/bash -#/* -# * 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 -# */ - -# brief -# authors Laurent Thomas -# -####################################### - -if [ ! -f /etc/os-release ]; then - echo "No /etc/os-release file found. You're likely on an unsupported distro." - exit 1 -fi -OS_DISTRO=$(grep "^ID=" /etc/os-release | sed "s/ID=//" | sed "s/\"//g") -OS_RELEASE=$(grep "^VERSION_ID=" /etc/os-release | sed "s/VERSION_ID=//" | sed "s/\"//g") -case "$OS_DISTRO" in - ubuntu) OS_BASEDISTRO="debian"; INSTALLER="apt"; CMAKE="cmake" ;; -esac - -SUDO='sudo -E' - -############################### -## echo and family -############################### -black='\E[30m' -red='\E[31m' -green='\E[32m' -yellow='\E[33m' -blue='\E[1;34m' -magenta='\E[35m' -cyan='\E[36m' -white='\E[37m' -reset_color='\E[00m' -COLORIZE=1 - -cecho() { - # Color-echo - # arg1 = message - # arg2 = color - local default_msg="No Message." - message=${1:-$default_msg} - color=${2:-$green} - [ "$COLORIZE" = "1" ] && message="$color$message$reset_color" - echo -e "$message" - return -} - -echo_error() { cecho "$* $red" ;} -echo_fatal() { cecho "$* $red"; exit 1 ;} -echo_warning() { cecho "$* $yellow" ;} -echo_success() { cecho "$* $green" ;} -echo_info() { cecho "$* $blue" ;} - -######################## -# distribution helpers # -######################## - -# This function return a string to identify the distribution we are running -# Examples: -# ubuntu16.04 -# debian8.5 -get_distribution_release() { - echo "$OS_DISTRO$OS_RELEASE" -} - -check_supported_distribution() { - case $(get_distribution_release) in - "ubuntu20.04") return 0 ;; - "ubuntu20.10") return 0 ;; - "ubuntu21.04") return 0 ;; - "ubuntu21.10") return 0 ;; - esac - return 1 -} - -################## -# Error handlers # -################## - -handler_EXIT() { - local exit_code=$? - [ "$exit_code" -eq 0 ] || echo_error "build have failed" - exit $exit_code -} - -trap handler_EXIT EXIT - -########################### -# Cleaners -########################### - -clean_kernel() { - $SUDO modprobe ip_tables - $SUDO modprobe x_tables - $SUDO iptables -P INPUT ACCEPT - $SUDO iptables -F INPUT - $SUDO iptables -P OUTPUT ACCEPT - $SUDO iptables -F OUTPUT - $SUDO iptables -P FORWARD ACCEPT - $SUDO iptables -F FORWARD - $SUDO iptables -t nat -F - $SUDO iptables -t mangle -F - $SUDO iptables -t filter -F - $SUDO iptables -t raw -F - echo_info "Flushed iptables" - $SUDO rmmod nasmesh > /dev/null 2>&1 - $SUDO rmmod oai_nw_drv > /dev/null 2>&1 - $SUDO rmmod openair_rf > /dev/null 2>&1 - $SUDO rmmod ue_ip > /dev/null 2>&1 - echo_info "removed drivers from kernel" -} - -clean_all_files() { - set_openair_env - rm -rf "$OPENAIR_DIR"/targets/bin/* - dir="$OPENAIR_DIR/cmake_targets" - rm -rf "$dir"/log/* - rm -rf "$dir"/ran_build/build - rm -rf "$dir"/ran_build_noLOG/build - rm -rf "$dir"/lte-simulators/build - rm -rf "$dir"/nas_sim_tools/build - rm -rf "$dir"/oaisim_build_oai/build - rm -rf "$dir"/oaisim_build_oai/CMakeLists.txt - rm -rf "$dir"/autotests/bin - rm -rf "$dir"/autotests/log - rm -rf "$dir"/autotests/*/build -} - -############################################ -# External packages installers -############################################ - -install_protobuf_from_source(){ - protobuf_install_log=$OPENAIR_DIR/cmake_targets/log/protobuf_install_log.txt - echo_info "\nInstalling Google Protobuf from sources. The log file for Protobuf installation is here: $protobuf_install_log " - ( - cd /tmp || exit - echo "Downloading protobuf" - #rm -rf /tmp/protobuf-2.6.1.tar.gz* /tmp/protobuf-2.6.1 - #wget https://github.com/protocolbuffers/protobuf/releases/download/v2.6.1/protobuf-2.6.1.tar.gz - #tar -xzvf protobuf-2.6.1.tar.gz --owner $USER --group $USER --no-same-owner - #cd protobuf-2.6.1/ - rm -rf /tmp/protobuf-cpp-3.3.0.tar.gz* /tmp/protobuf-3.3.0 - wget --tries=3 --retry-connrefused https://github.com/protocolbuffers/protobuf/releases/download/v3.3.0/protobuf-cpp-3.3.0.tar.gz - tar -xzvf protobuf-cpp-3.3.0.tar.gz --owner "$USER" --group "$(groups | cut -d" " -f1)" --no-same-owner - cd protobuf-3.3.0/ || exit - ./configure - echo "Compiling protobuf" - make -j"$(nproc)" - $SUDO make install - $SUDO ldconfig - ) >& "$protobuf_install_log" -} - -install_protobuf_c_from_source(){ - protobuf_c_install_log=$OPENAIR_DIR/cmake_targets/log/protobuf_c_install_log.txt - echo_info "\nInstalling Google Protobuf_C from sources. The log file for Protobuf_C installation is here: $protobuf_c_install_log " - ( - if [[ "$OS_DISTRO" == "rhel" ]] || [[ "$OS_DISTRO" == "centos" ]]; then - export PKG_CONFIG_PATH=/usr/local/lib/pkgconfig - fi - cd /tmp || exit - echo "Downloading protobuf-c" - rm -rf /tmp/protobuf-c - git clone https://github.com/protobuf-c/protobuf-c.git - cd protobuf-c || exit - git checkout 2a46af42784abf86804d536f6e0122d47cfeea45 - ./autogen.sh - ./configure - echo "Compiling protobuf-c" - make -j"$(nproc)" - $SUDO make install - $SUDO ldconfig - ) >& "$protobuf_c_install_log" -} - -install_usrp_uhd_driver_from_source(){ - uhd_install_log=$OPENAIR_DIR/cmake_targets/log/uhd_install_log.txt - echo_info "\nInstalling UHD driver from sources. The log file for UHD driver installation is here: $uhd_install_log " - ( - cd /tmp || exit - echo "Downloading UHD driver" - rm -rf /tmp/uhd - git clone https://github.com/EttusResearch/uhd.git - cd uhd || exit - git checkout UHD-3.15.LTS - mkdir -p host/build - cd host/build || exit - $CMAKE ../ -GNinja - echo "Compiling UHD" - ninja - $SUDO ninja install - $SUDO ldconfig - $SUDO /usr/lib/uhd/utils/uhd_images_downloader.py - ) >& "$uhd_install_log" -} - -install_bladerf_driver_from_source(){ - bladerf_install_log=$OPENAIR_DIR/cmake_targets/log/bladerf_install_log.txt - echo_info "\nInstalling BladeRF driver from sources. The log file for BladeRF driver installation is here: $bladerf_install_log " - ( - cd /tmp || exit - echo "Downloading BladeRF driver" - rm -rf /tmp/bladeRF - git clone https://github.com/Nuand/bladeRF.git - cd bladeRF || exit - git checkout tags/2016.06 - mkdir -p build - cd build || exit - $CMAKE ../ - echo "Compiling BladeRF driver" - make -j"$(nproc)" - $SUDO make install - $SUDO ldconfig - echo "Downloading FPGA and firmware images" - cd /tmp/bladeRF || exit - wget --tries=3 --retry-connrefused https://www.nuand.com/fx3/bladeRF_fw_latest.img - wget --tries=3 --retry-connrefused https://www.nuand.com/fpga/hostedx40-latest.rbf - sudo mkdir -p /usr/share/Nuand/bladeRF - sudo mv bladeRF_fw_latest.img /usr/share/Nuand/bladeRF/bladeRF_fw.img - sudo mv hostedx40-latest.rbf /usr/share/Nuand/bladeRF/hostedx40.rbf - ) >& "$bladerf_install_log" -} - -check_install_bladerf_driver(){ - if [[ "$OS_DISTRO" == "ubuntu" ]]; then - $SUDO apt-get install -y bladerf libbladerf-dev - $SUDO apt-get install -y bladerf-firmware-fx3 - $SUDO apt-get install -y bladerf-fpga-hostedx40 - elif [[ "$OS_BASEDISTRO" == "fedora" ]]; then - install_bladerf_driver_from_source - else - echo_error "BladeRF Installer for OAI does not support automatic build. Install BladeRF compiling sources manually from BladeRF website" - fi -} - -flash_firmware_bladerf() { - $SUDO bladeRF-cli --flash-firmware /usr/share/Nuand/bladeRF/bladeRF_fw.img -} - -install_soapy_from_source(){ - soapy_install_log=$OPENAIR_DIR/cmake_targets/log/soapy_install_log.txt - echo_info "\nInstalling Soapy EcoSystem from source. The log file for Soapy installation is here: $soapy_install_log " - ( - cd /tmp || exit - echo "Downloading SoapySDR" - rm -rf /tmp/soapysdr - git clone -b soapy-sdr-0.7.0 --single-branch https://github.com/pothosware/SoapySDR.git - cd SoapySDR || exit - #git checkout tags/release_003_010_001_001 - mkdir -p build - cd build || exit - $CMAKE ../ - echo "Compiling SoapySDR" - make -j"$(nproc)" - $SUDO make install - $SUDO ldconfig - cd /tmp || exit - echo "Downloading SoapyRemote" - rm -rf /tmp/soapyremote - git clone -b soapy-remote-0.5.0 --single-branch https://github.com/pothosware/SoapyRemote.git - cd SoapyRemote || exit - #git checkout tags/release_003_010_001_001 - mkdir -p build - cd build || exit - cmake ../ - echo "Compiling SoapyRemote" - make -j"$(nproc)" - $SUDO make install - $SUDO ldconfig - ) >& "$soapy_install_log" -} - -install_soapy_iris_from_source(){ - iris_install_log=$OPENAIR_DIR/cmake_targets/log/iris_install_log.txt - echo_info "\nInstalling Iris driver from source. The log file for Iris driver installation is here: $iris_install_log " - ( - cd /tmp || exit - echo "Downloading SoapyIris" - rm -rf /tmp/sklk-soapyiris - git clone -b soapy-iris-2018.08.0.1 --single-branch https://github.com/skylarkwireless/sklk-soapyiris.git - cd sklk-soapyiris || exit - mkdir -p build - cd build ||exit - cmake ../ - echo "Compiling SoapyIris" - make -j"$(nproc)" - $SUDO make install - $SUDO ldconfig - ) >& "$iris_install_log" -} - -check_install_soapy () { - #if [[ "$OS_DISTRO" == "ubuntu" ]]; then - #first we remove old installation - $SUDO apt-get remove -y soapysdr soapysdr-server libsoapysdr-dev python-soapysdr python3-soapysdr soapysdr-module-remote || true - #$SUDO add-apt-repository -y ppa:myriadrf/drivers - #$SUDO apt-get update - #$SUDO apt-get install -y soapysdr soapysdr-server libsoapysdr-dev python-soapysdr python3-soapysdr soapysdr-module-remote - - #elif [[ "$OS_BASEDISTRO" == "fedora" ]]; then - # $SUDO $INSTALLER -y install software-properties-common python3-software-properties python-software-properties subversion git python3 python-numpy python3-numpy cmake swig python-dev - install_soapy_from_source - #fi - install_soapy_iris_from_source - -} - -check_install_ubuntu_packages() { - $SUDO $INSTALLER update -y - if [[ "$OS_DISTRO" == "ubuntu" ]]; then - local LAPACK_LIBNAME="liblapack.so" - local LAPACK_TARGET="/usr/lib/atlas-base/atlas/liblapack.so" - $SUDO apt install -y software-properties-common - case "$(get_distribution_release)" in - "ubuntu20.04") - specific_packages="libtasn1-6-dev libgnutls28-dev iproute2 libconfig-dev" - LAPACK_LIBNAME="liblapack.so-x86_64-linux-gnu" - LAPACK_TARGET="/usr/lib/x86_64-linux-gnu/atlas/liblapack.so" - ;; - "ubuntu21.04") - specific_packages="libtasn1-6-dev libgnutls28-dev iproute2 libconfig-dev" - LAPACK_LIBNAME="liblapack.so-x86_64-linux-gnu" - LAPACK_TARGET="/usr/lib/x86_64-linux-gnu/atlas/liblapack.so" - ;; - esac - $SUDO $INSTALLER install -y \ - $specific_packages \ - check \ - dialog \ - dkms \ - gawk \ - libboost-all-dev \ - libpthread-stubs0-dev \ - openvpn \ - pkg-config \ - python3-dev \ - sshfs \ - swig \ - tshark \ - uml-utilities \ - unzip \ - valgrind \ - vlan \ - exuberant-ctags \ - ntpdate \ - iperf3 \ - android-tools-adb \ - wvdial \ - sshpass \ - nscd \ - bc \ - ntp \ - python3-scipy \ - python3-matplotlib \ - bison \ - build-essential \ - cmake \ - cmake-curses-gui \ - ninja-build \ - doxygen \ - doxygen-gui \ - texlive-latex-base \ - ethtool \ - flex \ - gdb \ - git \ - graphviz \ - gtkwave \ - iperf \ - iptables \ - libxtables-dev \ - libatlas-base-dev \ - libblas-dev \ - liblapack-dev\ - liblapacke-dev\ - libffi-dev \ - libforms-bin \ - libforms-dev \ - libgcrypt20-dev \ - libgmp-dev \ - libgtk-3-dev \ - libidn2-0-dev \ - libidn11-dev \ - libmysqlclient-dev \ - libpython2.7-dev \ - libsctp1 \ - libsctp-dev \ - libssl-dev \ - libtool \ - libusb-1.0-0-dev \ - libxml2 \ - libxml2-dev \ - libxslt1-dev \ - octave-signal \ - openssh-client \ - openssh-server \ - openssl \ - python3 \ - subversion \ - xmlstarlet \ - python3-pip \ - libyaml-dev \ - wget \ - libxpm-dev \ - libboost-all-dev \ - nettle-dev \ - nettle-bin \ - libreadline-dev - fi - - $SUDO update-alternatives --set "$LAPACK_LIBNAME" "$LAPACK_TARGET" - -} - -install_asn1c_from_source(){ - asn1_install_log=$OPENAIR_DIR/cmake_targets/log/asn1c_install_log.txt - echo_info "\nInstalling ASN1. The log file for ASN1 installation is here: $asn1_install_log " - ( - $SUDO rm -rf /tmp/asn1c - # GIT_SSL_NO_VERIFY=true git clone https://gitlab.eurecom.fr/oai/asn1c.git /tmp/asn1c - git clone https://gitlab.eurecom.fr/oai/asn1c.git /tmp/asn1c - cd /tmp/asn1c || exit - # better to use a given commit than a branch in case the branch - # is updated and requires modifications in the source of OAI - #git checkout velichkov_s1ap_plus_option_group - git checkout f12568d617dbf48497588f8e227d70388fa217c9 - autoreconf -iv - ./configure - make -j"$(nproc)" - $SUDO make install - cd - || exit - $SUDO ldconfig - ) > "$asn1_install_log" 2>&1 -} - -################################ -# set_openair_env -############################### -set_openair_env(){ - fullpath=$(readlink -f "${BASH_SOURCE[0]}") - [ -f "/.$fullpath" ] || fullpath=$(readlink -f "$PWD/$fullpath") - openair_path=${fullpath%/cmake_targets/*} - openair_path=${openair_path%/targets/*} - openair_path=${openair_path%/openair[123]/*} - export OPENAIR_DIR=$openair_path - export OPENAIR1_DIR=$openair_path/openair1 - export OPENAIR2_DIR=$openair_path/openair2 - export OPENAIR3_DIR=$openair_path/openair3 - export OPENAIR_TARGETS=$openair_path/targets -} - -if ! check_supported_distribution; then - echo_error "Your distribution $(get_distribution_release) is not supported by oai !" - exit 1 -fi -set_openair_env -echo_info "Installing packages" -check_install_ubuntu_packages - -echo_info "installing ASN.1 compiler" -install_asn1c_from_source - -echo_info "installing protobuf/protobuf-c for flexran agent support" -install_protobuf_from_source -install_protobuf_c_from_source - -if [ "$1" == "USRP" ] ; then - echo_info "installing packages for USRP support" - install_usrp_uhd_driver -fi -if [ "$1" == "BLADERF" ] ; then - echo_info "installing packages for BLADERF support" - check_install_bladerf_driver - flash_firmware_bladerf -fi -if [ "$1" == "IRIS" ] ; then - echo_info "installing packages for IRIS support" - check_install_soapy - # flash_firmware_iris -fi diff --git a/cmake_targets/phy_simulators b/cmake_targets/phy_simulators deleted file mode 120000 index 2a12e92f3e..0000000000 --- a/cmake_targets/phy_simulators +++ /dev/null @@ -1 +0,0 @@ -ran_build/ \ No newline at end of file diff --git a/cmake_targets/tools/build_helper b/cmake_targets/tools/build_helper index 55a39c6b2b..179e2de428 100755 --- a/cmake_targets/tools/build_helper +++ b/cmake_targets/tools/build_helper @@ -103,12 +103,12 @@ get_distribution_release() { check_supported_distribution() { local distribution=$(get_distribution_release) case "$distribution" in + "ubuntu22.04") return 0 ;; + "ubuntu21.04") return 0 ;; + "ubuntu20.04") return 0 ;; "ubuntu18.04") return 0 ;; - "ubuntu17.10") return 0 ;; - "ubuntu17.04") return 0 ;; "ubuntu16.04") return 0 ;; - "ubuntu14.04") return 0 ;; - "fedora24") return 0 ;; + "fedora35") return 0 ;; "rhel7") return 0 ;; "rhel7.6") return 0 ;; "rhel7.7") return 0 ;; @@ -315,6 +315,26 @@ install_protobuf_c_from_source(){ ) >& $protobuf_c_install_log } +install_protobuf_c() { + local protobuf_packages="" + case "$(get_distribution_release)" in + "ubuntu18.04" | "ubuntu20.04" | "ubuntu21.04" | "ubuntu22.04") + protobuf_packages="protobuf-c-compiler libprotobuf-c1 libprotobuf-c-dev" + ;; + esac + case "$OS_DISTRO" in + "rhel" | "centos" | "fedora") # in EPEL and Fedora repos (at least as of 35) + protobuf_packages="protobuf-c-compiler protobuf-c protobuf-c-devel" + ;; + esac + if [[ "$protobuf_packages" == "" ]]; then + install_protobuf_from_source + install_protobuf_c_from_source + else + $SUDO $INSTALLER -y install $protobuf_packages + fi +} + install_usrp_uhd_driver_from_source(){ uhd_install_log=$OPENAIR_DIR/cmake_targets/log/uhd_install_log.txt echo_info "\nInstalling UHD driver from sources. The log file for UHD driver installation is here: $uhd_install_log " @@ -361,7 +381,7 @@ check_install_usrp_uhd_driver(){ $SUDO apt-get remove libuhd3.14.1 -y || true $SUDO apt-get remove libuhd3.15.0 -y || true local distribution=$(get_distribution_release) - if [[ "$distribution" == "ubuntu18.04" ]]; then + if [[ "$distribution" == "ubuntu18.04" || "$distribution" == "ubuntu20.04" || "$distribution" == "ubuntu22.04" ]]; then $SUDO apt-get remove libuhd4.0.0 -y || true $SUDO apt-get remove libuhd4.1.0 -y || true fi @@ -390,13 +410,15 @@ check_install_usrp_uhd_driver(){ x=$((x + 1)) done $SUDO apt-get update - $SUDO apt-get -y install python python-tk libboost-all-dev libusb-1.0-0-dev - if [[ "$distribution" == "ubuntu16.04" ]]; then + $SUDO apt-get -y install python-tk libboost-all-dev libusb-1.0-0-dev + case "$(get_distribution_release)" in + "ubuntu16.04") $SUDO apt-get -y install libuhd-dev libuhd3.15.0 uhd-host - fi - if [[ "$distribution" == "ubuntu18.04" ]]; then - $SUDO apt-get -y install libuhd-dev libuhd4.1.0 uhd-host - fi + ;; + "ubuntu18.04" | "ubuntu20.04" | "ubuntu22.04") + $SUDO apt-get -y install libuhd-dev libuhd4.2.0 uhd-host + ;; + esac elif [[ "$OS_BASEDISTRO" == "fedora" ]]; then if [ $IS_CONTAINER -eq 0 ] then @@ -471,10 +493,6 @@ install_bladerf_driver_from_source(){ check_install_bladerf_driver(){ if [[ "$OS_DISTRO" == "ubuntu" ]]; then - if [ "$(get_distribution_release)" == "ubuntu14.04" ] ; then - $SUDO add-apt-repository -y ppa:bladerf/bladerf - $SUDO apt-get update - fi $SUDO apt-get install -y bladerf libbladerf-dev $SUDO apt-get install -y bladerf-firmware-fx3 $SUDO apt-get install -y bladerf-fpga-hostedx40 @@ -574,7 +592,16 @@ check_install_soapy () { check_install_additional_tools (){ $SUDO $INSTALLER update -y + local optional_packages="" if [[ "$OS_DISTRO" == "ubuntu" ]]; then + case "$(get_distribution_release)" in + "ubuntu16.04"| "ubuntu18.04") + optional_packages="python-dev python-pexpect python-numpy python-scipy python-matplotlib ctags" + ;; + "ubuntu20.04" | "ubuntu21.04" | "ubuntu22.04" ) + optional_packages="python3 python3-pip python3-dev python3-scipy python3-matplotlib universal-ctags" + ;; + esac PACKAGE_LIST="\ check \ dialog \ @@ -584,8 +611,6 @@ check_install_additional_tools (){ libpthread-stubs0-dev \ openvpn \ pkg-config \ - python-dev \ - python-pexpect \ sshfs \ swig \ tshark \ @@ -593,18 +618,14 @@ check_install_additional_tools (){ unzip \ valgrind \ vlan \ - ctags \ ntpdate \ iperf3 \ android-tools-adb \ wvdial \ - python-numpy \ sshpass \ nscd \ bc \ - ntp \ - python-scipy \ - python-matplotlib" + ntp" elif [[ "$OS_DISTRO" == "rhel" ]] || [[ "$OS_DISTRO" == "centos" ]]; then PACKAGE_LIST="\ check \ @@ -650,22 +671,19 @@ check_install_additional_tools (){ valgrind \ vconfig \ ctags \ - ntpdate \ + ntpsec \ iperf3 \ wvdial \ python-numpy \ sshpass \ nscd \ - python2-paramiko \ + python-paramiko \ python-pyroute2 \ python-netifaces \ - python2-scipy \ - python2-matplotlib" + python-scipy \ + python-matplotlib" fi - $SUDO $INSTALLER install -y $PACKAGE_LIST - - $SUDO rm -fr /opt/ssh - $SUDO GIT_SSL_NO_VERIFY=true git clone https://gitlab.eurecom.fr/oai/ssh.git /opt/ssh + $SUDO $INSTALLER install -y $PACKAGE_LIST $optional_packages #The packages below are already installed for Redhat distros (RHEL, CentOS, Fedora) if [[ "$OS_DISTRO" == "ubuntu" ]]; then @@ -696,25 +714,26 @@ check_install_oai_software() { local LAPACK_TARGET="/usr/lib/atlas-base/atlas/liblapack.so" $SUDO apt install -y software-properties-common case "$(get_distribution_release)" in - "ubuntu14.04") - specific_packages="libtasn1-3-dev libgnutls-dev libatlas-dev iproute libconfig8-dev" - # For iperf3 - $SUDO add-apt-repository "deb http://archive.ubuntu.com/ubuntu trusty-backports universe" - $SUDO apt-get update - ;; "ubuntu16.04") - specific_packages="libtasn1-6-dev libgnutls-dev libatlas-dev iproute libconfig8-dev" + specific_packages="libtasn1-6-dev libgnutls-dev libatlas-dev iproute libconfig8-dev iptables-dev libgcrypt11-dev python-pip pydb python guile-2.0-dev" ;; - "ubuntu17.04") - specific_packages="libtasn1-6-dev libgnutls28-dev libatlas-dev iproute libconfig8-dev" - ;; - "ubuntu17.10") - specific_packages="libtasn1-6-dev libgnutls28-dev iproute libconfig8-dev" + "ubuntu18.04") + specific_packages="libtasn1-6-dev libgnutls28-dev iproute2 libconfig-dev iptables-dev libgcrypt11-dev python-pip pydb python guile-2.0-dev" LAPACK_LIBNAME="liblapack.so-x86_64-linux-gnu" LAPACK_TARGET="/usr/lib/x86_64-linux-gnu/atlas/liblapack.so" ;; - "ubuntu18.04") - specific_packages="libtasn1-6-dev libgnutls28-dev iproute2 libconfig-dev" + "ubuntu20.04") + specific_packages="libtasn1-6-dev libgnutls28-dev iproute2 libconfig-dev python guile-2.0-dev" + LAPACK_LIBNAME="liblapack.so-x86_64-linux-gnu" + LAPACK_TARGET="/usr/lib/x86_64-linux-gnu/atlas/liblapack.so" + ;; + "ubuntu21.04") + specific_packages="libtasn1-6-dev libgnutls28-dev iproute2 libconfig-dev python guile-2.0-dev" + LAPACK_LIBNAME="liblapack.so-x86_64-linux-gnu" + LAPACK_TARGET="/usr/lib/x86_64-linux-gnu/atlas/liblapack.so" + ;; + "ubuntu22.04") + specific_packages="libtasn1-6-dev libgnutls28-dev iproute2 libconfig-dev python2 guile-2.2-dev" LAPACK_LIBNAME="liblapack.so-x86_64-linux-gnu" LAPACK_TARGET="/usr/lib/x86_64-linux-gnu/atlas/liblapack.so" ;; @@ -734,22 +753,21 @@ check_install_oai_software() { texlive-latex-base \ ethtool \ flex \ + g++ \ + gcc \ gdb \ git \ graphviz \ gtkwave \ - guile-2.0-dev \ iperf \ iptables \ - iptables-dev \ libatlas-base-dev \ libblas-dev \ - liblapack-dev\ - liblapacke-dev\ + liblapack-dev \ + liblapacke-dev \ libffi-dev \ libforms-bin \ libforms-dev \ - libgcrypt11-dev \ libgmp-dev \ libgtk-3-dev \ libidn2-0-dev \ @@ -769,11 +787,8 @@ check_install_oai_software() { openssh-client \ openssh-server \ openssl \ - python \ subversion \ xmlstarlet \ - python-pip \ - pydb \ libyaml-dev \ wget \ libxpm-dev \ @@ -791,8 +806,6 @@ check_install_oai_software() { $SUDO $INSTALLER install -y https://dl.fedoraproject.org/pub/epel/epel-release-latest-7.noarch.rpm fi $SUDO $INSTALLER install -y python-epdb vim-common - else - $SUDO $INSTALLER install -y pydb fi $SUDO $INSTALLER install -y \ @@ -804,6 +817,8 @@ check_install_oai_software() { doxygen \ ethtool \ flex \ + g++ \ + gcc \ gdb \ git \ graphviz \ @@ -860,8 +875,6 @@ check_install_oai_software() { fi install_asn1c_from_source $1 - $SUDO rm -fr /opt/ssh - $SUDO git clone https://gist.github.com/2190472.git /opt/ssh } install_asn1c_from_source(){ @@ -955,23 +968,3 @@ do fi done } - - -# get from http://www.linuxjournal.com/content/validating-ip-address-bash-script -validate_ip() { - -local ip=$1 -local stat=1 - -if [[ $ip =~ ^[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}$ ]]; then - OIFS=$IFS - IFS='.' - ip=($ip) - IFS=$OIFS - [[ ${ip[0]} -le 255 && ${ip[1]} -le 255 \ - && ${ip[2]} -le 255 && ${ip[3]} -le 255 ]] - stat=$? -fi - -return $stat -} diff --git a/common/utils/LOG/log.c b/common/utils/LOG/log.c index 5b047c082d..8be3568034 100644 --- a/common/utils/LOG/log.c +++ b/common/utils/LOG/log.c @@ -478,6 +478,7 @@ int logInit (void) register_log_component("NAS","log",NAS); register_log_component("UDP","",UDP_); register_log_component("GTPU","",GTPU); + register_log_component("SDAP","",SDAP); register_log_component("S1AP","",S1AP); register_log_component("F1AP","",F1AP); register_log_component("M2AP","",M2AP); diff --git a/common/utils/LOG/log.h b/common/utils/LOG/log.h index 1f19d55878..89b9c5e94d 100644 --- a/common/utils/LOG/log.h +++ b/common/utils/LOG/log.h @@ -215,6 +215,7 @@ typedef enum { OCM, UDP_, GTPU, + SDAP, SPGW, S1AP, F1AP, @@ -346,7 +347,7 @@ typedef struct { @param format data format (0 = real 16-bit, 1 = complex 16-bit,2 real 32-bit, 3 complex 32-bit,4 = real 8-bit, 5 = complex 8-bit) @param multiVec create new file or append to existing (useful for writing multiple vectors to same file. Just call the function multiple times with same file name and with this parameter set to 1) */ -#define MATLAB_RAW (1<<31) +#define MATLAB_RAW (1U<<31) #define MATLAB_SHORT 0 #define MATLAB_CSHORT 1 #define MATLAB_INT 2 diff --git a/common/utils/T/T.c b/common/utils/T/T.c index 49742bf600..2d724ffd00 100644 --- a/common/utils/T/T.c +++ b/common/utils/T/T.c @@ -33,12 +33,6 @@ volatile int _T_freelist_head; volatile int *T_freelist_head = &_T_freelist_head; T_cache_t *T_cache; -#if BASIC_SIMULATOR - /* global variables used by T_GET_SLOT, see in T.h */ - volatile uint64_t T_next_id; - volatile uint64_t T_active_id; -#endif - static void get_message(int s) { char t; int l; diff --git a/common/utils/T/T.h b/common/utils/T/T.h index 0142945054..df1e95d2df 100644 --- a/common/utils/T/T.h +++ b/common/utils/T/T.h @@ -111,39 +111,8 @@ typedef struct { extern volatile int *T_freelist_head; extern T_cache_t *T_cache; extern int *T_active; -/* When running the basic simulator, we may fill the T cache too fast. - * Let's serialize write accesses to the T cache. For that, we use a - * 'ticket' mechanism. To acquire a T slot the caller needs to own the - * current active ticket. We also wait for the slot to be free if - * it is already in use. - */ -#if BASIC_SIMULATOR -# define T_GET_SLOT \ - do { \ - extern volatile uint64_t T_next_id; \ - extern volatile uint64_t T_active_id; \ - uint64_t id; \ - /* get a ticket */ \ - id = __sync_fetch_and_add(&T_next_id, 1); \ - /* wait for our turn */ \ - while (id != __sync_fetch_and_add(&T_active_id, 0)) /* busy wait */; \ - /* this is our turn, try to acquire the slot until it's free */ \ - do { \ - T_LOCAL_busy = __sync_fetch_and_or(&T_cache[T_LOCAL_slot].busy, 0x01); \ - if (T_LOCAL_busy & 0x01) usleep(100); \ - } while (T_LOCAL_busy & 0x01); \ - /* check that there are still some tickets */ \ - if (__sync_fetch_and_add(&T_active_id, 0) == 0xffffffffffffffff) { \ - printf("T: reached the end of times, bye...\n"); \ - abort(); \ - } \ - /* free our ticket, which signals the next waiter that it's its turn */ \ - (void)__sync_fetch_and_add(&T_active_id, 1); \ - } while (0) -#else -# define T_GET_SLOT \ +#define T_GET_SLOT \ T_LOCAL_busy = __sync_fetch_and_or(&T_cache[T_LOCAL_slot].busy, 0x01); -#endif /* used at header of Tn, allocates buffer */ #define T_LOCAL_DATA \ diff --git a/common/utils/T/T_defs.h b/common/utils/T/T_defs.h index b74c0567ce..00e0df4963 100644 --- a/common/utils/T/T_defs.h +++ b/common/utils/T/T_defs.h @@ -40,20 +40,10 @@ #define T_MAX_ARGS 16 /* maximum size of a message - increase if needed */ -#if BASIC_SIMULATOR - /* let's have 100 RBs functional for the basic simulator */ -# define T_BUFFER_MAX (1024*64*4) -#else -# define T_BUFFER_MAX (1024*64*4) -#endif +#define T_BUFFER_MAX (1024*64*4) /* size of the local cache for messages (must be pow(2,something)) */ -#if BASIC_SIMULATOR - /* we don't need much space for the basic simulator */ -# define T_CACHE_SIZE 1024 -#else -# define T_CACHE_SIZE (8192) -#endif +#define T_CACHE_SIZE (8192) /* maximum number of bytes a message can contain */ #ifdef T_SEND_TIME diff --git a/common/utils/T/T_messages.txt b/common/utils/T/T_messages.txt index a8b919e525..b3c06d6be8 100644 --- a/common/utils/T/T_messages.txt +++ b/common/utils/T/T_messages.txt @@ -944,6 +944,27 @@ ID = LEGACY_GTPU_TRACE GROUP = ALL:LEGACY_GTPU:LEGACY_GROUP_TRACE:LEGACY FORMAT = string,log +ID = LEGACY_SDAP_INFO + DESC = SDAP legacy logs - info level + GROUP = ALL:LEGACY_SDAP:LEGACY_GROUP_INFO:LEGACY + FORMAT = string,log +ID = LEGACY_SDAP_ERROR + DESC = SDAP legacy logs - error level + GROUP = ALL:LEGACY_SDAP:LEGACY_GROUP_ERROR:LEGACY + FORMAT = string,log +ID = LEGACY_SDAP_WARNING + DESC = SDAP legacy logs - warning level + GROUP = ALL:LEGACY_SDAP:LEGACY_GROUP_WARNING:LEGACY + FORMAT = string,log +ID = LEGACY_SDAP_DEBUG + DESC = SDAP legacy logs - debug level + GROUP = ALL:LEGACY_SDAP:LEGACY_GROUP_DEBUG:LEGACY + FORMAT = string,log +ID = LEGACY_SDAP_TRACE + DESC = SDAP legacy logs - trace level + GROUP = ALL:LEGACY_SDAP:LEGACY_GROUP_TRACE:LEGACY + FORMAT = string,log + ID = LEGACY_TMR_INFO DESC = TMR legacy logs - info level GROUP = ALL:LEGACY_TMR:LEGACY_GROUP_INFO:LEGACY diff --git a/common/utils/T/local_tracer.c b/common/utils/T/local_tracer.c index 539e72b223..b4f1804c41 100644 --- a/common/utils/T/local_tracer.c +++ b/common/utils/T/local_tracer.c @@ -357,22 +357,6 @@ static void forward(void *_forwarder, char *buf, int size) { if (f->tail != NULL) f->tail->next = new; f->tail = new; -#if BASIC_SIMULATOR - /* When runnng the basic simulator, the tracer may be too slow. - * Let's not take too much memory in the tracee and - * wait if there is too much data to send. 200MB is - * arbitrary. - */ - while (f->memusage > 200 * 1024 * 1024) { - if (pthread_cond_signal(&f->cond)) abort(); - - if (pthread_mutex_unlock(&f->lock)) abort(); - - usleep(1000); - - if (pthread_mutex_lock(&f->lock)) abort(); - } -#endif f->memusage += size+4; /* warn every 100MB */ diff --git a/common/utils/assertions.h b/common/utils/assertions.h index 573036b1d9..c8959d0adb 100644 --- a/common/utils/assertions.h +++ b/common/utils/assertions.h @@ -44,9 +44,9 @@ #define _Assert_(cOND, aCTION, fORMAT, aRGS...) \ do { \ if (!(cOND)) { \ - fprintf(stderr, "\nAssertion ("#cOND") failed!\n" \ + fprintf(stderr, "\nAssertion (%s) failed!\n" \ "In %s() %s:%d\n" fORMAT, \ - __FUNCTION__, __FILE__, __LINE__, ##aRGS); \ + #cOND, __FUNCTION__, __FILE__, __LINE__, ##aRGS); \ aCTION; \ } \ } while(0) diff --git a/common/utils/lte/ue_power.c b/common/utils/lte/ue_power.c index b377abf2ff..aaa2826275 100644 --- a/common/utils/lte/ue_power.c +++ b/common/utils/lte/ue_power.c @@ -33,10 +33,8 @@ #include #include #include "PHY/defs_eNB.h" -#include "PHY/TOOLS/dB_routines.h" - -extern int16_t hundred_times_delta_TF[100]; -extern uint16_t hundred_times_log10_NPRB[100]; +#include +#include int16_t estimate_ue_tx_power(int norm,uint32_t tbs, uint32_t nb_rb, uint8_t control_only, int ncp, uint8_t use_srs) { diff --git a/common/utils/nr/nr_common.c b/common/utils/nr/nr_common.c index febfe7db7d..6add03c324 100644 --- a/common/utils/nr/nr_common.c +++ b/common/utils/nr/nr_common.c @@ -191,65 +191,17 @@ int PRBalloc_to_locationandbandwidth(int NPRB,int RBstart) { return(PRBalloc_to_locationandbandwidth0(NPRB,RBstart,275)); } -/// Target code rate tables indexed by Imcs -/* TS 38.214 table 5.1.3.1-1 - MCS index table 1 for PDSCH */ -uint16_t nr_target_code_rate_table1[29] = {120, 157, 193, 251, 308, 379, 449, 526, 602, 679, 340, 378, 434, 490, 553, \ - 616, 658, 438, 466, 517, 567, 616, 666, 719, 772, 822, 873, 910, 948}; +int cce_to_reg_interleaving(const int R, int k, int n_shift, const int C, int L, const int N_regs) { -/* TS 38.214 table 5.1.3.1-2 - MCS index table 2 for PDSCH */ -// Imcs values 20 and 26 have been multiplied by 2 to avoid the floating point -uint16_t nr_target_code_rate_table2[28] = {120, 193, 308, 449, 602, 378, 434, 490, 553, 616, 658, 466, 517, 567, \ - 616, 666, 719, 772, 822, 873, 1365, 711, 754, 797, 841, 885, 1833, 948}; - -/* TS 38.214 table 5.1.3.1-3 - MCS index table 3 for PDSCH */ -uint16_t nr_target_code_rate_table3[29] = {30, 40, 50, 64, 78, 99, 120, 157, 193, 251, 308, 379, 449, 526, 602, 340, \ - 378, 434, 490, 553, 616, 438, 466, 517, 567, 616, 666, 719, 772}; - -uint16_t nr_tbs_table[93] = {24, 32, 40, 48, 56, 64, 72, 80, 88, 96, 104, 112, 120, 128, 136, 144, 152, 160, 168, 176, 184, 192, 208, 224, 240, 256, 272, 288, 304, 320, \ - 336, 352, 368, 384, 408, 432, 456, 480, 504, 528, 552, 576, 608, 640, 672, 704, 736, 768, 808, 848, 888, 928, 984, 1032, 1064, 1128, 1160, 1192, 1224, 1256, \ - 1288, 1320, 1352, 1416, 1480, 1544, 1608, 1672, 1736, 1800, 1864, 1928, 2024, 2088, 2152, 2216, 2280, 2408, 2472, 2536, 2600, 2664, 2728, 2792, 2856, 2976, \ - 3104, 3240, 3368, 3496, 3624, 3752, 3824}; - -uint8_t nr_get_Qm(uint8_t Imcs, uint8_t table_idx) { - switch(table_idx) { - case 1: - return (((Imcs<10)||(Imcs==29))?2:((Imcs<17)||(Imcs==30))?4:((Imcs<29)||(Imcs==31))?6:-1); - break; - - case 2: - return (((Imcs<5)||(Imcs==28))?2:((Imcs<11)||(Imcs==29))?4:((Imcs<20)||(Imcs==30))?6:((Imcs<28)||(Imcs==31))?8:-1); - break; - - case 3: - return (((Imcs<15)||(Imcs==29))?2:((Imcs<21)||(Imcs==30))?4:((Imcs<29)||(Imcs==31))?6:-1); - break; - - default: - AssertFatal(0, "Invalid MCS table index %d (expected in range [1,3])\n", table_idx); - return(0); - break; - } -} - -uint32_t nr_get_code_rate(uint8_t Imcs, uint8_t table_idx) { - switch(table_idx) { - case 1: - return (nr_target_code_rate_table1[Imcs]); - break; - - case 2: - return (nr_target_code_rate_table2[Imcs]); - break; - - case 3: - return (nr_target_code_rate_table3[Imcs]); - break; - - default: - AssertFatal(0, "Invalid MCS table index %d (expected in range [1,3])\n", table_idx); - return(0); - break; + int f; // interleaving function + if(R==0) + f = k; + else { + int c = k/R; + int r = k%R; + f = (r*C + c + n_shift)%(N_regs/L); } + return f; } void get_coreset_rballoc(uint8_t *FreqDomainResource,int *n_rb,int *rb_offset) { @@ -336,9 +288,9 @@ int get_dmrs_port(int nl, uint16_t dmrs_ports) { return p; } -lte_frame_type_t get_frame_type(uint16_t current_band, uint8_t scs_index) +frame_type_t get_frame_type(uint16_t current_band, uint8_t scs_index) { - lte_frame_type_t current_type; + frame_type_t current_type; int32_t delta_duplex = get_delta_duplex(current_band, scs_index); if (delta_duplex == 0) @@ -503,7 +455,6 @@ int get_nr_table_idx(int nr_bandP, uint8_t scs_index) { return i; } - int get_subband_size(int NPRB,int size) { // implements table 5.2.1.4-2 from 36.214 // @@ -521,7 +472,6 @@ int get_subband_size(int NPRB,int size) { } - // from start symbol index and nb or symbols to symbol occupation bitmap in a slot uint16_t SL_to_bitmap(int startSymbolIndex, int nrOfSymbols) { return ((1<next=NULL; ret->key=key; ret->reponseFifo=reponseFifo; diff --git a/common/utils/time_meas.c b/common/utils/time_meas.c index df2bfd64de..9d1215b5e5 100644 --- a/common/utils/time_meas.c +++ b/common/utils/time_meas.c @@ -111,13 +111,15 @@ void print_meas(time_stats_t *ts, } } -int print_meas_log(time_stats_t *ts, - const char *name, - time_stats_t *total_exec_time, - time_stats_t *sf_exec_time, - char *output) +size_t print_meas_log(time_stats_t *ts, + const char *name, + time_stats_t *total_exec_time, + time_stats_t *sf_exec_time, + char *output, + size_t outputlen) { - int stroff = 0; + const char *begin = output; + const char *end = output + outputlen; static int first_time = 0; static double cpu_freq_GHz = 0.0; @@ -128,30 +130,49 @@ int print_meas_log(time_stats_t *ts, first_time=1; if ((total_exec_time == NULL) || (sf_exec_time== NULL)) - stroff += sprintf(output, "%25s %25s %25s %25s %25s %6f\n","Name","Total","Per Trials", "Num Trials","CPU_F_GHz", cpu_freq_GHz); + output += snprintf(output, + end - output, + "%25s %25s %25s %25s %25s %6f\n", + "Name", + "Total", + "Per Trials", + "Num Trials", + "CPU_F_GHz", + cpu_freq_GHz); else - stroff += sprintf(output+stroff, "%25s %25s %25s %20s %15s %6f\n","Name","Total","Average/Frame","Trials", "CPU_F_GHz", cpu_freq_GHz); + output += snprintf(output, + end - output, + "%25s %25s %25s %20s %15s %6f\n", + "Name", + "Total", + "Average/Frame", + "Trials", + "CPU_F_GHz", + cpu_freq_GHz); } if (ts->trials>0) { - //printf("%20s: total: %10.3f ms, average: %10.3f us (%10d trials)\n", name, ts->diff/cpu_freq_GHz/1000000.0, ts->diff/ts->trials/cpu_freq_GHz/1000.0, ts->trials); if ((total_exec_time == NULL) || (sf_exec_time== NULL)) { - stroff += sprintf(output+stroff, "%25s: %15.3f us; %15d; %15.3f us;\n", - name, - (ts->diff/ts->trials/cpu_freq_GHz/1000.0), - ts->trials, - ts->max/cpu_freq_GHz/1000.0); + output += snprintf(output, + end - output, + "%25s: %15.3f us; %15d; %15.3f us;\n", + name, + ts->diff / ts->trials / cpu_freq_GHz / 1000.0, + ts->trials, + ts->max / cpu_freq_GHz / 1000.0); } else { - stroff += sprintf(output+stroff, "%25s: %15.3f ms (%5.2f%%); %15.3f us (%5.2f%%); %15d;\n", - name, - (ts->diff/cpu_freq_GHz/1000000.0), - ((ts->diff/cpu_freq_GHz/1000000.0)/(total_exec_time->diff/cpu_freq_GHz/1000000.0))*100, // percentage - (ts->diff/ts->trials/cpu_freq_GHz/1000.0), - ((ts->diff/ts->trials/cpu_freq_GHz/1000.0)/(sf_exec_time->diff/sf_exec_time->trials/cpu_freq_GHz/1000.0))*100, // percentage - ts->trials); + output += snprintf(output, + end - output, + "%25s: %15.3f ms (%5.2f%%); %15.3f us (%5.2f%%); %15d;\n", + name, + ts->diff / cpu_freq_GHz / 1000000.0, + ((ts->diff / cpu_freq_GHz / 1000000.0) / (total_exec_time->diff / cpu_freq_GHz / 1000000.0))*100, // percentage + ts->diff / ts->trials / cpu_freq_GHz / 1000.0, + ((ts->diff / ts->trials / cpu_freq_GHz / 1000.0) / (sf_exec_time->diff / sf_exec_time->trials / cpu_freq_GHz / 1000.0)) * 100, // percentage + ts->trials); } } - return stroff; + return output - begin; } double get_time_meas_us(time_stats_t *ts) diff --git a/common/utils/time_meas.h b/common/utils/time_meas.h index 382dd7455a..fded7f1a9c 100644 --- a/common/utils/time_meas.h +++ b/common/utils/time_meas.h @@ -83,7 +83,12 @@ static inline void stop_meas(time_stats_t *ts) __attribute__((always_inline)); void print_meas_now(time_stats_t *ts, const char *name, FILE *file_name); void print_meas(time_stats_t *ts, const char *name, time_stats_t *total_exec_time, time_stats_t *sf_exec_time); -int print_meas_log(time_stats_t *ts, const char *name, time_stats_t *total_exec_time, time_stats_t *sf_exec_time, char *output); +size_t print_meas_log(time_stats_t *ts, + const char *name, + time_stats_t *total_exec_time, + time_stats_t *sf_exec_time, + char *output, + size_t outputlen); double get_time_meas_us(time_stats_t *ts); double get_cpu_freq_GHz(void); diff --git a/doc/BASIC_SIM.md b/doc/BASIC_SIM.md deleted file mode 100644 index 1bfc6e76d2..0000000000 --- a/doc/BASIC_SIM.md +++ /dev/null @@ -1,191 +0,0 @@ - - - - - -
- - - - - - Running OAI Basic Simulator -
- -This page is valid on the following branches: - -- `master` starting from tag `v1.1.0` -- `develop` starting from tag `2019.w11` - -# 1. Building the basic-simulator. - -After the build simplification, the basic simulator is available directly from the standard build. - -```bash -$ source oaienv -$ cd cmake_targets -$ ./build_oai --eNB --UE -``` - -Both eNB (lte-softmodem) and UE (lte-uesoftmodem) are present on `cmake_targets/ran_build/build` folder. - -More details are available on the [build page](BUILD.md). - -# 2. Running the basic simulator. - -The basic simulator is a oai device replacing the radio heads (for example the USRP device). It allows connecting the oai UE and the oai eNodeB through a network interface carrying the time-domain samples, getting rid of over the air unpredictable perturbations. - -This is the ideal tool to check signal processing algorithms and protocols implementation and having debug sessions without any HW radio equipment. - -The main limitations are: - -- A single OAI UE will connect to the OAI eNB -- No channel noise - -## 2.1. Starting eNB - -The basic simulator is able to run with a connected EPC or without any (the so-called "noS1" mode). - -Example 1: running in FDD mode with EPC. - -```bash -$ source oaienv -$ cd cmake_targets/ran_build/build -$ ENODEB=1 sudo -E ./lte-softmodem -O $OPENAIR_HOME/ci-scripts/conf_files/lte-fdd-basic-sim.conf --basicsim -``` - -Edit previously the `ci-scripts/conf_files/lte-fdd-basic-sim.conf` file to modify: - -- `N_RB_DL` field to change the Bandwidth (25, 50, 100) -- `CI_MME_IP_ADDR` with the EPC IP address -- `CI_ENB_IP_ADDR` with the container (physical server, virtual machine, ...) on which you are executing the eNB soft-modem - -Example 2: running in TDD mode without any EPC. - -```bash -$ source oaienv -$ cd cmake_targets/ran_build/build -$ ENODEB=1 sudo -E ./lte-softmodem -O $OPENAIR_HOME/ci-scripts/conf_files/lte-tdd-basic-sim.conf --basicsim --noS1 -``` - -## 2.2. Starting UE - -Before starting the UE, you may need to edit the SIM parameters to adapt to your eNB configuration and HSS database. - -The file to use for conf2uedate is `openair3/NAS/TOOLS/ue_eurecom_test_sfr.conf` - -You need to set the correct OPC, USIM_API_K, MSIN (this is the end par of the IMSI), HPLMN (the front part of IMSI) to match values from HSS. - -```bash -$ source oaienv -# Edit openair3/NAS/TOOLS/ue_eurecom_test_sfr.conf -$ cd cmake_targets/ran_build/build -$ ../../nas_sim_tools/build/conf2uedata -c $OPENAIR_HOME/openair3/NAS/TOOLS/ue_eurecom_test_sfr.conf -o . -$ sudo -E ./lte-uesoftmodem -C 2625000000 -r 25 --ue-rxgain 140 --basicsim [--noS1] -``` - -The `-r 25` is to use if in the conf file of the eNB you use N_RB_DL=25. Use 50 if you have N_RB_DL=50 and 100 if you have N_RB_DL=100. - -The `-C 2625000000` is the downlink frequency. Use the same value as `downlink_frequency` in the eNB configuration file. - -The `--noS1` is mandatory if you started the eNB in that mode. - -# 3. Testing the data plane - -# 3.1. In S1 mode - -First we need to retrieve the IP address allocated to the OAI UE. - -On the server that runs the UE: - -```bash -$ ifconfig oaitun_ue1 -oaitun_ue1 Link encap:UNSPEC HWaddr 00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00 - inet addr:192.172.0.2 P-t-P:192.172.0.2 Mask:255.255.255.0 -... -``` - -`192.172.0.2` is the IP address that has been allocated by the SPGW in the EPC. - -On the server that runs the EPC: - -```bash -$ ping -c 20 192.172.0.2 - --- 192.172.0.2 ping statistics --- - 20 packets transmitted, 20 received, 0% packet loss, time 19020ms - rtt min/avg/max/mdev = 13.241/18.999/24.208/2.840 ms -``` - -You can ping the EPC from the UE: - -```bash -$ ping -I oaitun_ue1 -c 20 192.172.0.1 - --- 192.172.0.1 ping statistics --- -... - 20 packets transmitted, 20 received, 0% packet loss, time 19019ms - rtt min/avg/max/mdev = 13.015/18.674/23.738/2.917 ms -``` - -For DL iperf testing: - -On the server that runs the UE. - -```bash -$ iperf -B 192.172.0.2 -u -s -i 1 -fm -p 5001 -``` - -On the server that runs the EPC. - -```bash -$ iperf -c 192.172.0.2 -u -t 30 -b 10M -i 1 -fm -B 192.172.0.1 -p 5001 -``` - -For UL iperf testing: - -On the server that runs the EPC. - -```bash -$ iperf -B 192.172.0.1 -u -s -i 1 -fm -p 5001 -``` - -On the server that runs the UE. - -```bash -$ iperf -c 192.172.0.1 -u -t 30 -b 2M -i 1 -fm -B 192.172.0.2 -p 5001 -``` - -# 3.2. In noS1 mode - -The IP addresses are fixed. But we can still retrieve them programmatically. - -For the UE it is quite the same: - -```bash -$ ifconfig oaitun_ue1 -oaitun_ue1 Link encap:UNSPEC HWaddr 00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00 - inet addr:10.0.1.2 P-t-P:10.0.1.2 Mask:255.255.255.0 -... -``` - -For the eNB: - -```bash -$ ifconfig oaitun_enb1 -oaitun_enb1 Link encap:UNSPEC HWaddr 00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00 - inet addr:10.0.1.1 P-t-P:10.0.1.1 Mask:255.255.255.0 -... -``` - -Pinging like this: - -```bash -$ ping -I oaitun_ue1 -c 20 10.0.1.1 -$ ping -I oaitun_enb1 -c 20 10.0.1.2 -``` - -And the same for iperf: - -```bash -$ iperf -B 10.0.1.2 -u -s -i 1 -fm -$ iperf -c 10.0.1.2 -u -b 1.00M -t 30 -i 1 -fm -B 10.0.1.1 -``` diff --git a/doc/BUILD.md b/doc/BUILD.md index 852a248659..70d69f5afd 100644 --- a/doc/BUILD.md +++ b/doc/BUILD.md @@ -77,7 +77,7 @@ cd cmake_targets/ ./build_oai -I -w USRP --eNB --UE --nrUE --gNB ``` -- The `-I` option is to install pre-requisites, you only need it the first time you build the softmodem or when some oai dependencies have changed. Note: for Ubuntu 20 use cmake_targets/install_external_packages.ubuntu20 instead! +- The `-I` option is to install pre-requisites, you only need it the first time you build the softmodem or when some oai dependencies have changed. - The `-w` option is to select the radio head support you want to include in your build. Radio head support is provided via a shared library, which is called the "oai device" The build script creates a soft link from `liboai_device.so` to the true device which will be used at run-time (here the USRP one,`liboai_usrpdevif.so` . USRP is the only hardware tested today in the Continuous Integration process. The RF simulator[RF simulator](../targets/ARCH/rfsimulator/README.md) is implemented as a specific device replacing RF hardware, it can be specifically built using `-w SIMU` option, but is also built during any softmodem build. - `--eNB` is to build the `lte-softmodem` executable and all required shared libraries - `--gNB` is to build the `nr-softmodem` executable and all required shared libraries @@ -193,6 +193,7 @@ Using the help option of the build script you can get the list of available opti | --UE | maintained and tested in CI | build `lte-uesoftmodem` the LTE UE | | --gNB | maintained and tested in CI | build `nr-softmodem` the 5G gNodeB | | --nrUE | maintained and tested in CI | build `nr-uesoftmodem` the 5G UE | +| --arch-native | maintained | build with native architecture optimization | | --usrp-recplay | deprecated | use the USRP configuration parameters to use the record player. | | --build-lib | maintained | build optional shared library(ies), which can then be loaded at run time via command line option. Use the --help option to get the list of supported optional libraries. `all` can be used to build all available optional libraries. | | --UE-conf-nvram | maintained | Specifies the path to the input file used by the conf2uedata utility. defaults to [openair3/NAS/TOOLS/ue_eurecom_test_sfr.conf](../openair3/NAS/TOOLS/ue_eurecom_test_sfr.conf) | diff --git a/doc/FEATURE_SET.md b/doc/FEATURE_SET.md index eaa691d6ef..d0856b415d 100644 --- a/doc/FEATURE_SET.md +++ b/doc/FEATURE_SET.md @@ -332,6 +332,9 @@ The following features are valid for the gNB and the 5G-NR UE. - evalution of RSRP report - evaluation of CQI report - MAC scheduling of SR reception +- Bandwidth part (BWP) operation + - Handle multiple dedicated BWPs + - BWP switching through RRCReconfiguration method **gNB RLC** - Send/Receive operations according to 38.322 Rel.16 @@ -351,6 +354,14 @@ The following features are valid for the gNB and the 5G-NR UE. - Interfaces with RRC, RLC - Interfaces with gtp-u (data Tx/Rx over N3 and F1-U interfaces) +**gNB SDAP** +- Send/Receive operations according to 37.324 Rel.15 + - Establishment/Handling of SDAP entities. + - Transfer of User Plane Data + - Mapping between a QoS flow and a DRB for both DL and UL + - Marking QoS flow ID in both DL and UL packets + - Reflective QoS flow to DRB mapping for UL SDAP data PDUs + **gNB RRC** - NR RRC (38.331) Rel 16 messages using new asn1c - LTE RRC (36.331) also updated to Rel 15 @@ -400,6 +411,7 @@ The following features are valid for the gNB and the 5G-NR UE. - New gtp-u implementation supporting both N3 and F1-U interfaces according to 29.281 Rel.15 - Interfaces with RRC, F1AP for tunnel creation - Interfaces with PDCP and RLC for data send/receive at the CU and DU respectively (F1-U interface) + - Interface with SDAP for data send/receive, capture of GTP-U Optional Header, GTP-U Extension Header and PDU Session Container. # OpenAirInterface 5G-NR UE Feature Set # @@ -484,6 +496,8 @@ The following features are valid for the gNB and the 5G-NR UE. - Configuration of fapi PDU according to DCI * Scheduler procedures for SRS transmission - Periodic SRS transmission +* Bandwidth part (BWP) operation + - Operation in configured dedicated BWP through RRCSetup or RRCReconfiguration **UE RLC** @@ -502,6 +516,13 @@ The following features are valid for the gNB and the 5G-NR UE. - Radio bearer establishment/handling and association with PDCP entities - Interfaces with RRC, RLC +**UE SDAP** +* Tx/Rx operations operations according to 37.324 Rel.15 + - Establishment/Handling of SDAP entities. + - Transfer of User Plane Data + - Reflective Mapping + - RRC Signaling Mapping + **UE RRC** * Integration of RRC messages and procedures supporting UE 5G SA connection according to 38.331 Rel.16 - RRCSetupRequest/RRCSetup/RRCSetupComplete diff --git a/doc/L2NFAPI.md b/doc/L2NFAPI.md index 137e4847e4..77f9e5cb78 100644 --- a/doc/L2NFAPI.md +++ b/doc/L2NFAPI.md @@ -18,6 +18,10 @@ The UE executable is able to "simulate" multiple UEs in order to stimulate the s **This simulator is available starting the `v1.0.0` release on the `master` branch.** +**2022/03/08: CAUTION, THIS TUTORIAL IS NO LONGER VALID on the `develop` branch after the `2022.w01` tag.** + +**2022/03/08: CAUTION, THE LAST VALID TAG on `develop` branch is `2021.w51_c`.** + Currently the Continuous Integration process is validating this simulator the following way: * the LTE modem executable is run on one host (in our CI deployment it is a **Xenial Virtual Machine**) @@ -31,6 +35,19 @@ Normally it should be fine to run both executables on the same host using the `l 1. [With S1 -- eNB and UE on 2 hosts](L2NFAPI_S1.md) 2. [No S1 -- eNB and UE on 2 hosts](L2NFAPI_NOS1.md) + +**2022/03/08: Starting the `2022.w01` tag on the `develop` branch, the L2 nFAPI simulation is using a proxy.** + +A tutorial is available on the [EpiSci GitHub Repository](https://github.com/EpiSci/oai-lte-5g-multi-ue-proxy#readme). + +This proxy allows to perform L2 nFAPI simulator for: + +* LTE +* 5G-NSA +* 5G-SA + +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) diff --git a/doc/L2NFAPI_NOS1.md b/doc/L2NFAPI_NOS1.md index bb4c32ec08..4f56be3416 100644 --- a/doc/L2NFAPI_NOS1.md +++ b/doc/L2NFAPI_NOS1.md @@ -12,6 +12,10 @@ +**2022/03/08: CAUTION, THIS TUTORIAL IS NO LONGER VALID on the `develop` branch after the `2022.w01` tag.** + +**2022/03/08: CAUTION, THE LAST VALID TAG on `develop` branch is `2021.w51_c`.** + ## Table of Contents ## 1. [Environment](#1-environment) diff --git a/doc/L2NFAPI_S1.md b/doc/L2NFAPI_S1.md index 9fd6d51818..824e9e469a 100644 --- a/doc/L2NFAPI_S1.md +++ b/doc/L2NFAPI_S1.md @@ -12,6 +12,10 @@ +**2022/03/08: CAUTION, THIS TUTORIAL IS NO LONGER VALID on the `develop` branch after the `2022.w01` tag.** + +**2022/03/08: CAUTION, THE LAST VALID TAG on `develop` branch is `2021.w51_c`.** + ## Table of Contents ## 1. [Environment](#1-environment) diff --git a/doc/NR_SA_CN5G_gNB_B210_COTS_UE_Tutorial.md b/doc/NR_SA_CN5G_gNB_B210_COTS_UE_Tutorial.md new file mode 100644 index 0000000000..1110a5bc6c --- /dev/null +++ b/doc/NR_SA_CN5G_gNB_B210_COTS_UE_Tutorial.md @@ -0,0 +1,234 @@ + + + + + +
+ + + + + + OAI 5G SA tutorial +
+ +**TABLE OF CONTENTS** + +1. [Scenario](#1-scenario) +2. [OAI CN5G](#2-oai-cn5g) + 1. [OAI CN5G pre-requisites](#21-oai-cn5g-pre-requisites) + 2. [OAI CN5G Setup](#22-oai-cn5g-setup) + 3. [OAI CN5G Configuration files](#23-oai-cn5g-configuration-files) + 4. [SIM Card](#24-sim-card) +3. [OAI gNB](#3-oai-gnb) + 1. [OAI gNB pre-requisites](#31-oai-gnb-pre-requisites) + 2. [Build OAI gNB](#32-build-oai-gnb) +4. [Run OAI CN5G and OAI gNB with USRP B210](#4-run-oai-cn5g-and-oai-gnb-with-usrp-b210) + 1. [Run OAI CN5G](#41-run-oai-cn5g) + 2. [Run OAI gNB](#42-run-oai-gnb) +5. [Testing with QUECTEL RM500Q](#5-testing-with-quectel-rm500q) + 1. [Setup QUECTEL](#51-setup-quectel) + 2. [Ping test](#52-ping-test) + 3. [Downlink iPerf test](#53-downlink-iperf-test) + + +# 1. Scenario +In this tutorial we describe how to configure and run a 5G end-to-end setup with OAI CN5G, OAI gNB and COTS UE. + +Minimum hardware requirements: +- Laptop/Desktop/Server for OAI CN5G and OAI gNB + - Operating System: [Ubuntu 20.04.4 LTS](https://releases.ubuntu.com/20.04.4/ubuntu-20.04.4-desktop-amd64.iso) + - CPU: 8 cores x86_64 @ 3.5 GHz + - RAM: 32 GB +- Laptop for UE + - Operating System: Microsoft Windows 10 x64 + - CPU: 4 cores x86_64 + - RAM: 8 GB + - Windows driver for Quectel MUST be equal or higher than version **2.2.4** +- [USRP B210](https://www.ettus.com/all-products/ub210-kit/) +- Quectel RM500Q + - Module, M.2 to USB adapter, antennas and SIM card + - Firmware version of Quectel MUST be equal or higher than **RM500QGLABR11A06M4G** + + +# 2. OAI CN5G + +## 2.1 OAI CN5G pre-requisites + +```bash +sudo apt install -y git net-tools putty + +sudo apt install -y apt-transport-https ca-certificates curl software-properties-common +curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add - +sudo add-apt-repository "deb [arch=amd64] https://download.docker.com/linux/ubuntu $(lsb_release -cs) stable" +sudo apt update +sudo apt install -y docker docker-ce + +# Add your username to the docker group, otherwise you will have to run in sudo mode. +sudo usermod -a -G docker $(whoami) +reboot + +# https://docs.docker.com/compose/install/ +sudo curl -L "https://github.com/docker/compose/releases/download/1.29.2/docker-compose-$(uname -s)-$(uname -m)" -o /usr/local/bin/docker-compose +sudo chmod +x /usr/local/bin/docker-compose + +docker network create --driver=bridge --subnet=192.168.70.128/26 -o "com.docker.network.bridge.name"="demo-oai" demo-oai-public-net +sudo service docker restart + +``` + +## 2.2 OAI CN5G Setup + +```bash +# Git oai-cn5g-fed repository +git clone https://gitlab.eurecom.fr/oai/cn5g/oai-cn5g-fed.git ~/oai-cn5g-fed +cd ~/oai-cn5g-fed +git checkout master +./scripts/syncComponents.sh --nrf-branch develop --amf-branch develop --smf-branch develop --spgwu-tiny-branch develop --ausf-branch develop --udm-branch develop --udr-branch develop --upf-vpp-branch develop --nssf-branch develop + +docker pull oaisoftwarealliance/oai-amf:develop +docker pull oaisoftwarealliance/oai-nrf:develop +docker pull oaisoftwarealliance/oai-smf:develop +docker pull oaisoftwarealliance/oai-udr:develop +docker pull oaisoftwarealliance/oai-udm:develop +docker pull oaisoftwarealliance/oai-ausf:develop +docker pull oaisoftwarealliance/oai-upf-vpp:develop +docker pull oaisoftwarealliance/oai-spgwu-tiny:develop +docker pull oaisoftwarealliance/oai-nssf:develop + +docker image tag oaisoftwarealliance/oai-amf:develop oai-amf:develop +docker image tag oaisoftwarealliance/oai-nrf:develop oai-nrf:develop +docker image tag oaisoftwarealliance/oai-smf:develop oai-smf:develop +docker image tag oaisoftwarealliance/oai-udr:develop oai-udr:develop +docker image tag oaisoftwarealliance/oai-udm:develop oai-udm:develop +docker image tag oaisoftwarealliance/oai-ausf:develop oai-ausf:develop +docker image tag oaisoftwarealliance/oai-upf-vpp:develop oai-upf-vpp:develop +docker image tag oaisoftwarealliance/oai-spgwu-tiny:develop oai-spgwu-tiny:develop +docker image tag oaisoftwarealliance/oai-nssf:develop oai-nssf:develop +``` + +## 2.3 OAI CN5G Configuration files +Download and copy the configuration files to ~/oai-cn5g-fed/docker-compose: +- [docker-compose-basic-nrf.yaml](tutorial_resources/docker-compose-basic-nrf.yaml) +- [oai_db.sql](tutorial_resources/oai_db.sql) + +Change permissions on oai_db.sql to prevent mysql permission denied error: +```bash +chmod 644 ~/oai-cn5g-fed/docker-compose/oai_db.sql +``` + +## 2.4 SIM Card +Program SIM Card with [Open Cells Project](https://open-cells.com/) application [uicc-v2.6](https://open-cells.com/d5138782a8739209ec5760865b1e53b0/uicc-v2.6.tgz). + +```bash +sudo ./program_uicc --adm 12345678 --imsi 208990000000001 --isdn 00000001 --acc 0001 --key fec86ba6eb707ed08905757b1bb44b8f --opc C42449363BBAD02B66D16BC975D77CC1 -spn "OpenAirInterface" --authenticate +``` + + +# 3. OAI gNB + +## 3.1 OAI gNB pre-requisites + +### Build UHD from source +```bash +sudo apt install -y libboost-all-dev libusb-1.0-0-dev doxygen python3-docutils python3-mako python3-numpy python3-requests python3-ruamel.yaml python3-setuptools cmake build-essential + +git clone https://github.com/EttusResearch/uhd.git ~/uhd +cd ~/uhd +git checkout v4.0.0.0 +cd host +mkdir build +cd build +cmake ../ +make -j 4 +make test # This step is optional +sudo make install +sudo ldconfig +sudo uhd_images_downloader +``` + +## 3.2 Build OAI gNB + +```bash +# Get openairinterface5g source code +git clone https://gitlab.eurecom.fr/oai/openairinterface5g.git ~/openairinterface5g +cd ~/openairinterface5g +git checkout develop + +# Install dependencies in Ubuntu 20.04 +cd ~/openairinterface5g +source oaienv +cd cmake_targets +./build_oai -I + +# Build OAI gNB +cd ~/openairinterface5g +source oaienv +cd cmake_targets +./build_oai -w USRP --nrUE --gNB --build-lib all -c +``` + + +# 4. Run OAI CN5G and OAI gNB with USRP B210 + +## 4.1 Run OAI CN5G + +```bash +cd ~/oai-cn5g-fed/docker-compose +python3 core-network.py --type start-basic --fqdn yes --scenario 1 +``` + +## 4.2 Run OAI gNB + +```bash +cd ~/openairinterface5g +source oaienv +cd 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 +``` + +Make sure that during USRP initialization, it shows that USB 3 is used. + +# 5. Testing with Quectel RM500Q + +## 5.1 Setup Quectel +With [PuTTY](https://the.earth.li/~sgtatham/putty/latest/w64/putty.exe), send the following AT commands to the module using a serial interface (ex: COM2) at 115200 bps: +```bash +# MUST be sent at least once everytime there is a firmware upgrade! +AT+QMBNCFG="Select","ROW_Commercial" +AT+QMBNCFG="AutoSel",0 +AT+CFUN=1,1 +AT+CGDCONT=1 +AT+CGDCONT=2 +AT+CGDCONT=3 +AT+CGDCONT=1,"IP","oai" + +# (Optional, debug only, AT commands) Activate PDP context, retrieve IP address and test with ping +AT+CGACT=1,1 +AT+CGPADDR=1 +AT+QPING=1,"openairinterface.org" +``` + +## 5.2 Ping test +- UE host +```bash +ping 192.168.70.135 -n 1000 -S 12.1.1.2 +``` +- CN5G host +```bash +docker exec -it oai-ext-dn ping 12.1.1.2 +``` + +## 5.3 Downlink iPerf test +- UE host + - Download iPerf for Microsoft Windows from [here](https://iperf.fr/download/windows/iperf-2.0.9-win64.zip). + - Extract to Desktop and run with Command Prompt: +```bash +cd C:\Users\User\Desktop\iPerf\iperf-2.0.9-win64\iperf-2.0.9-win64 +iperf -s -u -i 1 -B 12.1.1.2 +``` + +- CN5G host +```bash +docker exec -it oai-ext-dn iperf -u -t 86400 -i 1 -fk -B 192.168.70.135 -b 125M -c 12.1.1.2 +``` diff --git a/doc/NR_SA_CN5G_gNB_N300_COTS_UE_Tutorial.md b/doc/NR_SA_CN5G_gNB_N300_COTS_UE_Tutorial.md new file mode 100644 index 0000000000..ed917e09ea --- /dev/null +++ b/doc/NR_SA_CN5G_gNB_N300_COTS_UE_Tutorial.md @@ -0,0 +1,251 @@ + + + + + +
+ + + + + + OAI 5G SA tutorial +
+ +**TABLE OF CONTENTS** + +1. [Scenario](#1-scenario) +2. [OAI CN5G](#2-oai-cn5g) + 1. [OAI CN5G pre-requisites](#21-oai-cn5g-pre-requisites) + 2. [OAI CN5G Setup](#22-oai-cn5g-setup) + 3. [OAI CN5G Configuration files](#23-oai-cn5g-configuration-files) + 4. [SIM Card](#24-sim-card) +3. [OAI gNB](#3-oai-gnb) + 1. [OAI gNB pre-requisites](#31-oai-gnb-pre-requisites) + 2. [Build OAI gNB](#32-build-oai-gnb) + 3. [N300 Ethernet Tuning](#33-n300-ethernet-tuning) +4. [Run OAI CN5G and OAI gNB with USRP N300](#4-run-oai-cn5g-and-oai-gnb-with-usrp-n300) + 1. [Run OAI CN5G](#41-run-oai-cn5g) + 2. [Run OAI gNB](#42-run-oai-gnb) +5. [Testing with QUECTEL RM500Q](#5-testing-with-quectel-rm500q) + 1. [Setup QUECTEL](#51-setup-quectel) + 2. [Ping test](#52-ping-test) + 3. [Downlink iPerf test](#53-downlink-iperf-test) + + +# 1. Scenario +In this tutorial we describe how to configure and run a 5G end-to-end setup with OAI CN5G, OAI gNB and COTS UE. + +Minimum hardware requirements: +- Laptop/Desktop/Server for OAI CN5G and OAI gNB + - Operating System: [Ubuntu 20.04.4 LTS](https://releases.ubuntu.com/20.04.4/ubuntu-20.04.4-desktop-amd64.iso) + - CPU: 8 cores x86_64 @ 3.5 GHz + - RAM: 32 GB +- Laptop for UE + - Operating System: Microsoft Windows 10 x64 + - CPU: 4 cores x86_64 + - RAM: 8 GB + - Windows driver for Quectel MUST be equal or higher than version **2.2.4** +- [USRP N300](https://www.ettus.com/all-products/USRP-N300/): Please identify the network interface(s) on which the N300 is connected. +- Quectel RM500Q + - Module, M.2 to USB adapter, antennas and SIM card + - Firmware version of Quectel MUST be equal or higher than **RM500QGLABR11A06M4G** + + +# 2. OAI CN5G + +## 2.1 OAI CN5G pre-requisites + +```bash +sudo apt install -y git net-tools putty + +sudo apt install -y apt-transport-https ca-certificates curl software-properties-common +curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add - +sudo add-apt-repository "deb [arch=amd64] https://download.docker.com/linux/ubuntu $(lsb_release -cs) stable" +sudo apt update +sudo apt install -y docker docker-ce + +# Add your username to the docker group, otherwise you will have to run in sudo mode. +sudo usermod -a -G docker $(whoami) +reboot + +# https://docs.docker.com/compose/install/ +sudo curl -L "https://github.com/docker/compose/releases/download/1.29.2/docker-compose-$(uname -s)-$(uname -m)" -o /usr/local/bin/docker-compose +sudo chmod +x /usr/local/bin/docker-compose + +docker network create --driver=bridge --subnet=192.168.70.128/26 -o "com.docker.network.bridge.name"="demo-oai" demo-oai-public-net +sudo service docker restart + +``` + +## 2.2 OAI CN5G Setup + +```bash +# Git oai-cn5g-fed repository +git clone https://gitlab.eurecom.fr/oai/cn5g/oai-cn5g-fed.git ~/oai-cn5g-fed +cd ~/oai-cn5g-fed +git checkout master +./scripts/syncComponents.sh --nrf-branch develop --amf-branch develop --smf-branch develop --spgwu-tiny-branch develop --ausf-branch develop --udm-branch develop --udr-branch develop --upf-vpp-branch develop --nssf-branch develop + +docker pull oaisoftwarealliance/oai-amf:develop +docker pull oaisoftwarealliance/oai-nrf:develop +docker pull oaisoftwarealliance/oai-smf:develop +docker pull oaisoftwarealliance/oai-udr:develop +docker pull oaisoftwarealliance/oai-udm:develop +docker pull oaisoftwarealliance/oai-ausf:develop +docker pull oaisoftwarealliance/oai-upf-vpp:develop +docker pull oaisoftwarealliance/oai-spgwu-tiny:develop +docker pull oaisoftwarealliance/oai-nssf:develop + +docker image tag oaisoftwarealliance/oai-amf:develop oai-amf:develop +docker image tag oaisoftwarealliance/oai-nrf:develop oai-nrf:develop +docker image tag oaisoftwarealliance/oai-smf:develop oai-smf:develop +docker image tag oaisoftwarealliance/oai-udr:develop oai-udr:develop +docker image tag oaisoftwarealliance/oai-udm:develop oai-udm:develop +docker image tag oaisoftwarealliance/oai-ausf:develop oai-ausf:develop +docker image tag oaisoftwarealliance/oai-upf-vpp:develop oai-upf-vpp:develop +docker image tag oaisoftwarealliance/oai-spgwu-tiny:develop oai-spgwu-tiny:develop +docker image tag oaisoftwarealliance/oai-nssf:develop oai-nssf:develop +``` + +## 2.3 OAI CN5G Configuration files +Download and copy the configuration files to ~/oai-cn5g-fed/docker-compose: +- [docker-compose-basic-nrf.yaml](tutorial_resources/docker-compose-basic-nrf.yaml) +- [oai_db.sql](tutorial_resources/oai_db.sql) + +Change permissions on oai_db.sql to prevent mysql permission denied error: +```bash +chmod 644 ~/oai-cn5g-fed/docker-compose/oai_db.sql +``` + +## 2.4 SIM Card +Program SIM Card with [Open Cells Project](https://open-cells.com/) application [uicc-v2.6](https://open-cells.com/d5138782a8739209ec5760865b1e53b0/uicc-v2.6.tgz). + +```bash +sudo ./program_uicc --adm 12345678 --imsi 208990000000001 --isdn 00000001 --acc 0001 --key fec86ba6eb707ed08905757b1bb44b8f --opc C42449363BBAD02B66D16BC975D77CC1 -spn "OpenAirInterface" --authenticate +``` + + +# 3. OAI gNB + +## 3.1 OAI gNB pre-requisites + +### Build UHD from source +```bash +sudo apt install -y libboost-all-dev libusb-1.0-0-dev doxygen python3-docutils python3-mako python3-numpy python3-requests python3-ruamel.yaml python3-setuptools cmake build-essential + +git clone https://github.com/EttusResearch/uhd.git ~/uhd +cd ~/uhd +git checkout v4.0.0.0 +cd host +mkdir build +cd build +cmake ../ +make -j 4 +make test # This step is optional +sudo make install +sudo ldconfig +sudo uhd_images_downloader +``` + +## 3.2 Build OAI gNB + +```bash +# Get openairinterface5g source code +git clone https://gitlab.eurecom.fr/oai/openairinterface5g.git ~/openairinterface5g +cd ~/openairinterface5g +git checkout develop + +# Install dependencies in Ubuntu 20.04 +cd ~/openairinterface5g +source oaienv +cd cmake_targets +./build_oai -I + +# Build OAI gNB +cd ~/openairinterface5g +source oaienv +cd cmake_targets +./build_oai -w USRP --nrUE --gNB --build-lib all -c +``` + +## 3.3 N300 Ethernet Tuning + +Please also refer to the official [USRP Host Performance Tuning Tips and Tricks](https://kb.ettus.com/USRP_Host_Performance_Tuning_Tips_and_Tricks) tuning guide. + +The following steps are recommended. Please change the network interface(s) as required. Also, you should have 10Gbps interface(s): if you use two cables, you should have the XG interface. Refer to the [N300 Getting Started Guide](https://kb.ettus.com/USRP_N300/N310/N320/N321_Getting_Started_Guide) for more information. + +* Use an MTU of 9000: how to change this depends on the network management tool. In the case of Network Manager, this can be done from the GUI. +* Increase the kernel socket buffer (also done by the USRP driver in OAI): + ``` + sysctl -w net.core.rmem_max=8388608 + sysctl -w net.core.wmem_max=8388608 + sysctl -w net.core.rmem_default=65536 + sysctl -w net.core.wmem_default=65536 + ``` +* Increase Ethernet Ring Buffers: `sudo ethtool -G rx 4096 tx 4096` +* Disable hyper-threading in the BIOS +* Disable KPTI Protections for Spectre/Meltdown for more performance. **This is a security risk.** Add `mitigations=off nosmt` in your grub config and update grub. + +# 4. Run OAI CN5G and OAI gNB with USRP N300 + +## 4.1 Run OAI CN5G + +```bash +cd ~/oai-cn5g-fed/docker-compose +python3 core-network.py --type start-basic --fqdn yes --scenario 1 +``` + +## 4.2 Run OAI gNB + +```bash +cd ~/openairinterface5g +source oaienv +cd cmake_targets/ran_build/build +sudo ./nr-softmodem -O ../../../targets/PROJECTS/GENERIC-NR-5GC/CONF/gnb.sa.band78.fr1.162PRB.2x2.usrpn300.conf --sa --usrp-tx-thread-config 1 +``` + + +# 5. Testing with Quectel RM500Q + +## 5.1 Setup Quectel +With [PuTTY](https://the.earth.li/~sgtatham/putty/latest/w64/putty.exe), send the following AT commands to the module using a serial interface (ex: COM2) at 115200 bps: +```bash +# MUST be sent at least once everytime there is a firmware upgrade! +AT+QMBNCFG="Select","ROW_Commercial" +AT+QMBNCFG="AutoSel",0 +AT+CFUN=1,1 +AT+CGDCONT=1 +AT+CGDCONT=2 +AT+CGDCONT=3 +AT+CGDCONT=1,"IP","oai" + +# (Optional, debug only, AT commands) Activate PDP context, retrieve IP address and test with ping +AT+CGACT=1,1 +AT+CGPADDR=1 +AT+QPING=1,"openairinterface.org" +``` + +## 5.2 Ping test +- UE host +```bash +ping 192.168.70.135 -n 1000 -S 12.1.1.2 +``` +- CN5G host +```bash +docker exec -it oai-ext-dn ping 12.1.1.2 +``` + +## 5.3 Downlink iPerf test +- UE host + - Download iPerf for Microsoft Windows from [here](https://iperf.fr/download/windows/iperf-2.0.9-win64.zip). + - Extract to Desktop and run with Command Prompt: +```bash +cd C:\Users\User\Desktop\iPerf\iperf-2.0.9-win64\iperf-2.0.9-win64 +iperf -s -u -i 1 -B 12.1.1.2 +``` + +- CN5G host +```bash +docker exec -it oai-ext-dn iperf -u -t 86400 -i 1 -fk -B 192.168.70.135 -b 200M -c 12.1.1.2 +``` diff --git a/doc/RUNMODEM.md b/doc/RUNMODEM.md index 449859b042..2dc4fd2ff5 100644 --- a/doc/RUNMODEM.md +++ b/doc/RUNMODEM.md @@ -14,10 +14,6 @@ After you have [built the softmodem executables](BUILD.md) you can set your default directory to the build directory `cmake_targets/ran_build/build/` and start testing some use cases. Below, the description of the different oai functionalities should help you choose the oai configuration that suits your need. -# Basic Simulator - -See the [dedicated page](BASIC_SIM.md). - # RF Simulator The rf simulator is a oai device replacing the radio heads (for example the USRP device). It allows connecting the oai UE (LTE or 5G) and respectively the oai eNodeB or gNodeB through a network interface carrying the time-domain samples, getting rid of over the air unpredictable perturbations. This is the ideal tool to check signal processing algorithms and protocols implementation. The rf simulator has some preliminary support for channel modeling. @@ -33,7 +29,7 @@ It is planned to enhance this simulator with the following functionalities: This simulator connects a eNodeB and UEs through a nfapi interface, short-cutting the L1 layer. The objective of this simulator is to allow multi UEs simulation, with a large number of UEs (ideally up to 255 ) .Here to ease the platform setup, UEs are simulated via a single `lte-uesoftmodem` instance. Today the CI tests just with one UE and architecture has to be reviewed to allow a number of UE above about 16. This work is on-going. -As for the rf simulator, no specific hardware is required. The [L2 nfapi simlator page](L2NFAPI.md) contains the detailed documentation. +As for the rf simulator, no specific hardware is required. The [L2 nfapi simulator page](L2NFAPI.md) contains the detailed documentation. # L1 Simulator @@ -169,7 +165,7 @@ From the `cmake_targets/ran_build/build` folder: gNB on machine 1: -`sudo ./nr-softmodem -O ../../../targets/PROJECTS/GENERIC-NR-5GC/CONF/gnb.sa.band78.fr1.106PRB.usrpb210.conf --sa` +`sudo ./nr-softmodem -O ../../../targets/PROJECTS/GENERIC-NR-5GC/CONF/gnb.sa.band78.fr1.106PRB.usrpb210.conf --gNBs.[0].min_rxtxtime 6 --sa` UE on machine 2: @@ -177,7 +173,7 @@ UE on machine 2: With the RF simulator (on the same machine): -`sudo ./nr-softmodem -O ../../../targets/PROJECTS/GENERIC-NR-5GC/CONF/gnb.sa.band78.fr1.106PRB.usrpb210.conf --rfsim --sa` +`sudo ./nr-softmodem -O ../../../targets/PROJECTS/GENERIC-NR-5GC/CONF/gnb.sa.band78.fr1.106PRB.usrpb210.conf --gNBs.[0].min_rxtxtime 6 --rfsim --sa` `sudo ./nr-uesoftmodem -r 106 --numerology 1 --band 78 -C 3619200000 -s 516 --rfsim --sa` @@ -211,7 +207,24 @@ UE on machine 2: `sudo ./nr-uesoftmodem --if_freq 2169080000 --if_freq_off -400000000` +# MIMO configuration + + + + +
+ + +
+ +This image shows an example of gNB 5G MIMO logical antenna port configuration. It has to be noted that logical antenna ports might not directly correspond to physical antenna ports and each logical antenna port might consist of a sub-array of antennas. + +The basic element is a dual-polarized antenna, therefore the minimal DL MIMO setup with two logical antenna ports would consist of two cross-polarized antenna elements. In a single panel configuration, as the one in the picture, this element can be repeated vertiacally and/or horizontally to form an equi-spaced 1D or 2D array. The values N1 and N2 represent the number of antenna ports in the two dimensions and the supported configurations are specified in Section 5.2.2.2.1 of TS 38.214. + +The DL logical antenna port configuration can be selected through configuration file. `pdsch_AntennaPorts_N1` can be used to set N1 parameter, `pdsch_AntennaPorts_N2` to set N2 and `pdsch_AntennaPorts_XP` to set the cross-polarization configuration (1 for single pol, 2 for cross-pol). To be noted that if XP is 1 but N1 and/or N2 are larger than 1, this would result in a non-standard configuration and the PMI selected would be the identity matrix regardless of CSI report. The default value for each of these parameters is 1. + +# Additional links [Selecting an alternative ldpc implementation at run time](../openair1/PHY/CODING/DOC/LDPCImplementation.md) diff --git a/doc/RUN_NR_multiple_BWPs.md b/doc/RUN_NR_multiple_BWPs.md new file mode 100644 index 0000000000..2c2c2fcf25 --- /dev/null +++ b/doc/RUN_NR_multiple_BWPs.md @@ -0,0 +1,51 @@ +# Procedure to add dedicated Bandwidth part (BWP) + +## Contributed by 5G Testbed IISc + +### Developers: Abhijith A, Shruthi S + +# Terminology # + +## Bandwidth part (BWP) ## +Bandwidth Part (BWP) is a set of contiguous Resource Blocks in the resource grid. + +Parameters of a BWP are communicated to UE using RRC parameters: BWP-Downlink and BWP-Uplink. + +A UE can be configured with a set of 4 BWPs in uplink (UL) and downlink (DL) direction (3GPP TS 38.331 Annex B.2 Description of BWP configuration options). But only 1 BWP can be active in UL and DL direction at a given time. + +# Procedure to run multiple dedicated BWPs # + +A maximum of 4 dedicated BWPs can be configured for a UE. + +To configure multiple BWPs, add the following parameters to the gNB configuration file under "servingCellConfigDedicated": + +## Setup of the Configuration files ## +``` + firstActiveDownlinkBWP-Id = 1; #BWP-Id + defaultDownlinkBWP-Id = 1; #BWP-Id + firstActiveUplinkBWP-Id = 1; #BWP-Id +``` + +Each dedicated BWP must have: +``` + # BWP 1 Configuration + dl_bwp-Id_1 = 1; + dl_bwp1_locationAndBandwidth = 28875; // RBstart=0, L=106 (40 MHz BW) + # subcarrierSpacing + # 0=kHz15, 1=kHz30, 2=kHz60, 3=kHz120 + dl_bwp1_subcarrierSpacing = 1; +``` + + Find these parameters in this configuration file: "targets/PROJECTS/GENERIC-NR-5GC/CONF/gnb.sa.band78.fr1.106PRB.usrpb210.conf" + +# Testing gNB and UE in RF simulator + +## 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 +``` + +## UE command: +``` + sudo RFSIMULATOR=127.0.0.1 ./nr-uesoftmodem -r 106 --numerology 1 --band 78 -C 3619200000 --nokrnmod --rfsim --sa --uicc0.imsi 208990000000001 +``` \ No newline at end of file diff --git a/doc/TESTBenches.md b/doc/TESTBenches.md index 7365bc0f4c..547fd5a23b 100644 --- a/doc/TESTBenches.md +++ b/doc/TESTBenches.md @@ -1,45 +1,164 @@ ## Table of Contents ## -1. [Legacy 1 Bench](#legacy-1-bench) -2. [Legacy 2 Bench](#legacy-2-bench) -3. [Next Bench for DEV](#next-bench-for-dev) -4. [Next Bench for CI](#next-bench-for-ci) -5. [Indoor Live Network Bench](#indoor-live-network-bench) -6. [Outdoor Live Network Bench](#outdoor-live-network-bench) +1. [Machines](#machines) +2. [Networked devices](#networked-devices) +3. [Testbenches](#testbenches) +4. [Pipelines](#pipelines) + +## Machines + +| Machine | IP address | Lockable Resource | Function | Connected devices | +| ------------- | --------------- | --------------------- | ------------------ | ----------------------------------------------------- | +| asterix | 172.21.16.127 | CI-Asterix-Usage | gNB | 173.21.19.14 | +| obelix | 172.21.16.128 | CI-Obelix-Usage | eNB, UE (5G) | 172.21.19.13, X300 (192.168.60.2), B200mini (30C51EB) | +| porcepix | 172.21.16.136 | CI-NSA-MiniBench | Executor, EPC, 5GC | -- | +| nrmodule2 | 172.21.16.139 | CI-NSA-MiniBench | Quectel | Quectel module | +| nepes | 172.21.16.137 | CI-NSA-MiniBench | gNB | B200mini (30C51D4) | +| caracal | 172.21.16.132 | CI-Caracal | gNB/phytest | N300 (192.168.10.2) | +| idefix | 172.21.16.135 | CI-NSA-MiniBench | Quectel | Quectel module | +| amariue | 172.21.16.144 | CI-Amarisoft-UE-Usage | TBD | Amarisoft UE simulator | +| bellatrix | 192.168.117.115 | CI-RAN-VM-Deployment | Executor | -- | +| nano | 192.168.12.62 | CI-Bench-1-Phones | EPC, adb | 2x COTS (adb) | +| hutch | 192.168.12.19 | CI-Bench-1-Phones | eNB (B7) | B200mini (30C5239) | +| starsky | 192.168.12.18 | CI-Bench-1-Phones | eNB (B40) | b200mini (30A3E3C) | +| carabe | 192.168.12.211 | CI-Bench-2-OAI-Phone | UE 4G (B) | B200mini (30AE8C9) | + +Note: The available resources, and their current usage, is indicated here: +- [Lockable resources of jenkins-oai](https://jenkins-oai.eurecom.fr/lockable-resources/): + "New" Jenkins, i.e., with RAN-Container-Parent +- [Lockable resources of open5glab jenkins](https://open5glab.eurecom.fr:8083/jenkins/lockable-resources/): + "Old" Jenkins, i.e., with RAN-CI-Develop + +## Networked devices + +| Type | IP address (mgmt) | +| ------------- | ----------------- | +| USRP N310 | 172.21.19.14 | +| USRP N310 | 172.21.19.13 | + +## Testbenches + +### OTA Testbench + +[Proper image to be followed up. TBD: add antennas/circulators] + +Note: obelix and porcepix are both used in the OTA testbench and the 5G +NSA/Faraday Cage testbench! + +![5G OTA Testbench](testbenches_doc_resources/5g-ota-bench.png) + +[PDF version](testbenches_doc_resources/5g-ota-bench.pdf) | [LaTeX/TikZ version](testbenches_doc_resources/5g-ota-bench.tex) if you want to modify to reflect your setup + +### 5G NSA/Faraday Cage Testbench + +**Purpose**: Faraday cage 5G tests + +Note: obelix and porcepix are both used in the OTA testbench and the 5G +NSA/Faraday Cage testbench! + +![5G NSA/Faraday Cage Testbench](testbenches_doc_resources/5g-nsa-faraday-bench.png) + +[PDF version](testbenches_doc_resources/5g-nsa-faraday-bench.pdf) | [LaTeX/TikZ version](testbenches_doc_resources/5g-nsa-faraday-bench.tex) if you want to modify to reflect your setup + +### 4G Testbench(es) + +**Purpose**: 4G/LTE testbenches -## Legacy 1 Bench +![4G Faraday Cage Testbench](testbenches_doc_resources/4g-faraday-bench.png) -**Purpose** : FDD Band 7 and Band 13, LTE-M -**Note** : Legacy1 and Legacy2 are duplicated so that they can run in parallel, thus avoiding a CI bottleneck -**Note** : Faraday Cages 1 and 2 are physically the same cage +[PDF version](testbenches_doc_resources/4g-faraday-bench.pdf) | [LaTeX/TikZ version](testbenches_doc_resources/4g-faraday-bench.tex) if you want to modify to reflect your setup -![image info](./testbenches_doc_resources/legacy1.jpg) +## Pipelines -## Legacy 2 Bench +### [RAN-Container-Parent](https://jenkins-oai.eurecom.fr/job/RAN-Container-Parent/) -**Purpose** : TDD Band 40, TM2 2xTX 2xRX -**Note** : CN can run in a container, could also run on Massive +**Purpose**: automatically triggered tests on MR creation or push, from Gitlab +Webhook -![image info](./testbenches_doc_resources/legacy2.jpg) +- [RAN-cppcheck](https://jenkins-oai.eurecom.fr/job/RAN-cppcheck/1664/) + - obelix + - performs static code analysis, currently not actively enforced +- [RAN-gNB-nrUE-MONO-TDD-Band78-N300](https://jenkins-oai.eurecom.fr/job/RAN-gNB-nrUE-MONO-TDD-Band78-N300/) + - caracal + N310 + - pure performance test through phy-test scheduler, see command line for more + details +- [RAN-L2-Sim-Test-5G](https://jenkins-oai.eurecom.fr/job/RAN-L2-Sim-Test-5G/) + - obelix (gNB, 1x UE, OAI 5GC) + - L2simulator: skips physical layer and uses proxy between gNB and UE, + currently only ping +- [RAN-NSA-B200-Module-LTEBOX-Container](https://jenkins-oai.eurecom.fr/job/RAN-NSA-B200-Module-LTEBOX-Container/) + - obelix + B200, nepes + B200, idefix + Quectel, porcepix w/ ltebox + - basic NSA test, known to be instable +- [RAN-PhySim-Cluster](https://jenkins-oai.eurecom.fr/job/RAN-PhySim-Cluster/) + - asterix (`Asterix-OC-oaicicd-session` resource), tests in OpenShift Cluster + - unitary simulators (`nr_dlsim`, etc.) +- [RAN-RF-Sim-Test-4G](https://jenkins-oai.eurecom.fr/job/RAN-RF-Sim-Test-4G/) + - obelix (eNB, 1x UE, OAI EPC) + - uses RFsimulator, for FDD 5, 10, 20MHz with core, 5MHz noS1 +- [RAN-RF-Sim-Test-5G](https://jenkins-oai.eurecom.fr/job/RAN-RF-Sim-Test-5G/) + - obelix (gNB, 2x UE, OAI 5GC) + - uses RFsimulator, TDD 40MHz, FDD 40MHz, F1 split +- [RAN-RHEL8-Image-Builder](https://jenkins-oai.eurecom.fr/job/RAN-RHEL8-Image-Builder/) + - asterix: RHEL 8 image build using podman +- [RAN-Ubuntu18-Image-Builder](https://jenkins-oai.eurecom.fr/job/RAN-Ubuntu18-Image-Builder/) + - obelix: Ubuntu 18 image build using docker -## Next Bench for DEV +### [RAN-CI-NSA-Trigger](https://jenkins-oai.eurecom.fr/view/RAN/job/RAN-CI-NSA-Trigger/) -**Note** : Benetel CI can also run on this bench at night +**Purpose**: longer-running over-the-air LTE, NSA, and SA tests, triggered +through cron job at midnight -![image info](./testbenches_doc_resources/next_dev.jpg) +- [RAN-LTE-2x2-Module-OAIEPC](https://jenkins-oai.eurecom.fr/job/RAN-LTE-2x2-Module-OAIEPC/) + - obelix + N310, nrmodule2 + Quectel, porcepix w/ Magma EPC + - LTE 2x2 test with TM1 and TM2 +- [RAN-NSA-B200-Module-LTEBOX](https://jenkins-oai.eurecom.fr/job/RAN-NSA-B200-Module-LTEBOX/) + - obelix + B200 (eNB), nepes + B200 (gNB), idefix + Quectel, porcepix w/ ltebox + - Note: like [RAN-NSA-B200-Module-LTEBOX-Container](https://jenkins-oai.eurecom.fr/job/RAN-NSA-B200-Module-LTEBOX-Container/) above, but compiled/run from source +- [RAN-NSA-2x2-Module-OAIEPC](https://jenkins-oai.eurecom.fr/job/RAN-NSA-2x2-Module-OAIEPC/) + - obelix + N310 (eNB), asterix + N310 (gNB), nrmodule2 + Quectel, porcepix w/ Magma EPC + - LTE 2x2 and NR 2x2 (non-standalone) +- [RAN-SA-Module-CN5G](https://jenkins-oai.eurecom.fr/view/RAN/job/RAN-SA-Module-CN5G/) + - asterix + N310 (gNB), nrmodule2 + Quectel, porcepix w/ OAI 5GC + - NR 2x2 (standalone) +- [RAN-SA-OAIUE-N310-X300-CN5G](https://jenkins-oai.eurecom.fr/job/RAN-SA-OAIUE-N310-X300-CN5G/) + - asterix + N310 (gNB), obelix + N310 or X300 (5G UE), porcepix w/ OAI 5GC + - OTA test with OAIUE using both N310 and X300 +- [RAN-SA-AmariS-CN5G](https://jenkins-oai.eurecom.fr/view/RAN/job/RAN-SA-AmariS-CN5G/) + - asterix + N310, amariue (1x UE), porcepix w/ OAI 5GC + - Amarisoft UE simulator: expected to be increased to more UEs +### [RAN-CI-develop](https://open5glab.eurecom.fr:8083/jenkins/job/RAN-CI-develop/) -## Next Bench for CI +**Purpose**: automatically triggered tests, mostly 4G, to be phased out and +integrated into RAN-Container-Parent -**Note** : The current test running on Caracal could run on this bench with a N300/N300 setup +runs tests: +- bellatrix: runs 4G/5G simulators directly (eNB + 1x UE + (opt.) OAI EPC, gNB + 1x UE in "noS1") -![image info](./testbenches_doc_resources/next_ci.jpg) - -## Indoor Live Network Bench - -![image info](./testbenches_doc_resources/indoor_live.jpg) - -## Outdoor Live Network Bench - -![image info](./testbenches_doc_resources/outdoor_live.jpg) +triggers pipelines: +- [eNB-CI-F1-FDD-Band7-B210](https://open5glab.eurecom.fr:8083/jenkins/job/eNB-CI-F1-FDD-Band7-B210/) + - hutch + B210, nano w/ ltebox + 2x UE + - tests 4G FDD with F1 split, 5MHz, 10MHz, 20MHz. 5MHz stable, rest known to + be unstable +- [eNB-CI-FDD-Band7-B210](https://open5glab.eurecom.fr:8083/jenkins/job/eNB-CI-FDD-Band7-B210/) + - hutch + B210, nano w/ ltebox + 2x UE + - tests T tracer, information through FlexRAN, RRC inactivity timers, + inactivity timers + FlexRAN, different bandwidths +- [eNB-CI-IF4p5-FDD-Band7-B210](https://open5glab.eurecom.fr:8083/jenkins/job/eNB-CI-IF4p5-FDD-Band7-B210/) + - hutch + B210, nano w/ ltebox + 2x UE + - tests IF4.5 split over bandwidths 5, 10, 20 MHz in Band 7 +- [eNB-CI-IF4p5-TDD-Band40-B210](https://open5glab.eurecom.fr:8083/jenkins/job/eNB-CI-IF4p5-TDD-Band40-B210/) + - starsky + B210, nano w/ ltebox + 2x UE + - tests IF4.5 split over bandwidths 5, 10, 20 MHz in Band 40 +- [eNB-CI-TDD-Band40-B210](https://open5glab.eurecom.fr:8083/jenkins/job/eNB-CI-TDD-Band40-B210/) + - starsky + B210, nano w/ ltebox + 2x UE + - T tracer, TM1 over bandwidths 5, 10, 20 MHz in Band 40, default scheduler + for 20 MHz +- [eNB-UE-CI-MONO-FDD-Band7-B200](https://open5glab.eurecom.fr:8083/jenkins/job/eNB-UE-CI-MONO-FDD-Band7-B200/) + - hutch + B210 (eNB), carabe + B210 (4G UE), nano w/ ltebox + - tests OAI 4G for 5 MHz/TM1 with both CN and in noS1 model, MBMS; known to + be unstable +- [UE-CI-FDD-Band20-B200](https://open5glab.eurecom.fr:8083/jenkins/job/UE-CI-FDD-Band20-B200/) + - starsky + B210 (sniffer) + - Sniff MIB + SIB1 of Orange, SFR diff --git a/doc/TESTING_5GSA_setup.md b/doc/TESTING_5GSA_setup.md index f8c85bf2ca..357c62c813 100644 --- a/doc/TESTING_5GSA_setup.md +++ b/doc/TESTING_5GSA_setup.md @@ -36,6 +36,8 @@ At the moment of writing this document interoperability with the following COTS - [Quectel RM500Q-GL](https://www.quectel.com/product/5g-rm500q-gl/) - [Simcom SIMCOM8200EA](https://www.simcom.com/product/SIM8200EA_M2.html) - Huawei Mate 30 Pro + - Oneplus 8 + - Google Pixel 5 End-to-end control plane signaling to achieve a 5G SA connection, UE registration and PDU session establishment with the CN, as well as some basic user-plane traffic tests have been validated so far using SIMCOM/Quectel modules and Huawei Mate 30 pro. In terms of interoperability with different 5G Core Networks, so far this setup has been tested with: @@ -48,7 +50,7 @@ At the moment of writing this document interoperability with the following COTS ## 1.1 gNB build and configuration To get the code and build the gNB executable: -### Ubuntu 18.04 +### Build gNB ```bash git clone https://gitlab.eurecom.fr/oai/openairinterface5g.git git checkout develop @@ -59,42 +61,6 @@ To get the code and build the gNB executable: ./build_oai --gNB -w USRP ``` -### Ubuntu 20.04 -```bash - # Build UHD from source - # https://files.ettus.com/manual/page_build_guide.html - sudo apt-get install libboost-all-dev libusb-1.0-0-dev doxygen python3-docutils python3-mako python3-numpy python3-requests python3-ruamel.yaml python3-setuptools cmake build-essential - - git clone https://github.com/EttusResearch/uhd.git - cd uhd/host - mkdir build - cd build - cmake ../ - make -j 4 - make test # This step is optional - sudo make install - sudo ldconfig - sudo uhd_images_downloader - - - git clone https://gitlab.eurecom.fr/oai/openairinterface5g.git - git checkout develop - - # Install dependencies in Ubuntu 20.04 - cd - cd openairinterface5g/ - source oaienv - cd cmake_targets/ - ./install_external_packages.ubuntu20 - - # Build OAI gNB - cd - cd openairinterface5g/ - source oaienv - cd cmake_targets/ - ./build_oai --gNB -w USRP -``` - A reference configuration file for the **monolithic** gNB is provided [here](https://gitlab.eurecom.fr/oai/openairinterface5g/-/blob/develop/targets/PROJECTS/GENERIC-NR-5GC/CONF/gnb.sa.band78.fr1.106PRB.usrpb210.conf). diff --git a/doc/UL_MIMO.txt b/doc/UL_MIMO.txt new file mode 100644 index 0000000000..c06bc78c4c --- /dev/null +++ b/doc/UL_MIMO.txt @@ -0,0 +1,31 @@ +# how to build phy sim +cd cmake_targets/ +sudo ./build_oai --phy_simulators -c + +cd phy_simulators/build/ +# ULSCH sim +# bit level validation +# PUSCH encoding and decoding for 4 layers 2 CMD without data +sudo ./nr_ulschsim -R 106 -m9 -s13 -n100 -y4 -z4 -W4 + +# UL sim +# Uplink chain validation +# PUSCH on UE side and gNB side,whole chain for PUSCH +# No channel model on data domain signal +# No cross-path connection +# PMI = 0 is only unitary prcoding matrix +sudo ./nr_ulsim -n100 -m9 -r106 -s13 -W4 -y4 -z4 + +# How to build rfsim +sudo ./build_oai -c --gNB --nrUE -w SIMU + +# How to run with rfsim +# 4x4 RANK 4 +sudo ./nr-softmodem -O ../../../targets/PROJECTS/GENERIC-NR-5GC/CONF/gnb.sa.band78.fr1.106PRB.usrpb210.4layer.conf --rfsim --phy-test --l 2 --L 4 +sudo ./nr-uesoftmodem --rfsim --phy-test --ue-nb-ant-rx 4 --ue-nb-ant-tx 4 +# 4x4 RANK 2 +sudo ./nr-softmodem -O ../../../targets/PROJECTS/GENERIC-NR-5GC/CONF/gnb.sa.band78.fr1.106PRB.usrpb210.4layer.conf --rfsim --phy-test --l 2 --L 2 +sudo ./nr-uesoftmodem --rfsim --phy-test --ue-nb-ant-rx 4 --ue-nb-ant-tx 4 + + + diff --git a/doc/images/mimo_antenna_ports.png b/doc/images/mimo_antenna_ports.png new file mode 100644 index 0000000000..ef91f4becc Binary files /dev/null and b/doc/images/mimo_antenna_ports.png differ diff --git a/doc/testbenches_doc_resources/4g-faraday-bench.pdf b/doc/testbenches_doc_resources/4g-faraday-bench.pdf new file mode 100644 index 0000000000..7e31789e9a Binary files /dev/null and b/doc/testbenches_doc_resources/4g-faraday-bench.pdf differ diff --git a/doc/testbenches_doc_resources/4g-faraday-bench.png b/doc/testbenches_doc_resources/4g-faraday-bench.png new file mode 100644 index 0000000000..c69065a369 Binary files /dev/null and b/doc/testbenches_doc_resources/4g-faraday-bench.png differ diff --git a/doc/testbenches_doc_resources/4g-faraday-bench.tex b/doc/testbenches_doc_resources/4g-faraday-bench.tex new file mode 100644 index 0000000000..6071c89947 --- /dev/null +++ b/doc/testbenches_doc_resources/4g-faraday-bench.tex @@ -0,0 +1,59 @@ +\documentclass{standalone} + +\usepackage{tikz} +\usetikzlibrary{backgrounds, positioning, shapes.symbols} +\usepackage{helvet} +\renewcommand*{\rmdefault}{\sfdefault} + +\begin{document} +\begin{tikzpicture} + [ + font=\footnotesize, + faraday/.style={minimum size=3cm, draw, dashed}, + duplexer/.style={draw,fill=white}, + ] + + \node[faraday, label={[anchor=south west]above left:Faraday cage}] (faraday) {}; + + \node[above left=0cm and 2.8cm of faraday, label=above:hutch] (hutch) + {\includegraphics[width=1.2cm]{server}}; + \node[right=0.3cm of hutch, label=above:B210] (b210h) + {\includegraphics[width=1.2cm]{b210}} edge (hutch); + \node[below left=0.35cm of faraday.north east] (anto) + {\includegraphics[width=0.3cm]{antenna}}; + \draw (b210h) -| node [pos=0.25, duplexer] {B7} (anto); + + \node[below left=0cm and 2.8cm of faraday, label=above:starsky] (starsky) + {\includegraphics[width=1.2cm]{server}}; + \node[right=0.3cm of starsky, label=above:B210] (b210s) + {\includegraphics[width=1.2cm]{b210}} edge (starsky); + \draw (hutch) -- (b210h); + \node[above left=0.35cm of faraday.south east] (antn) + {\includegraphics[width=0.3cm]{antenna}}; + \draw (b210s) -| node [pos=0.35, duplexer] {B40} (antn); + \node[below right=-0.2cm and 0.8cm of b210s] (antn2) + {\includegraphics[width=0.3cm]{antenna}}; + \draw (b210s) -| (antn2); + + \node[left=5cm of faraday, label=above:nano] (nano) + {\includegraphics[width=1.2cm]{server}}; + \draw (hutch) -- (nano); + \draw (starsky) -- (nano); + \node[above right=0.0cm and 0.35cm of faraday.west] (phone1) + {\includegraphics[height=0.5cm]{phone}}; + \node[below right=0.0cm and 0.35cm of faraday.west] (phone2) + {\includegraphics[height=0.5cm]{phone}}; + \draw (nano) -- node[above] {USB/adb} +(5cm,0) |- (phone1); + \draw (nano) -- +(5cm,0) |- (phone2); + + \node[right=1.5cm of faraday, label=above:B210] (b210c) + {\includegraphics[width=1.2cm]{b210}}; + \node[left=.5cm of faraday.east] (antc) + {\includegraphics[width=0.3cm]{antenna}}; + \draw (b210c) -- node [pos=0.35, duplexer] {B7UE} (antc); + \node[right=0.7cm of b210c, label=above:carabe] (carabe) + {\includegraphics[width=1.2cm]{server}} + edge (b210c); + +\end{tikzpicture} +\end{document} diff --git a/doc/testbenches_doc_resources/5g-nsa-faraday-bench.pdf b/doc/testbenches_doc_resources/5g-nsa-faraday-bench.pdf new file mode 100644 index 0000000000..f6d960c1a2 Binary files /dev/null and b/doc/testbenches_doc_resources/5g-nsa-faraday-bench.pdf differ diff --git a/doc/testbenches_doc_resources/5g-nsa-faraday-bench.png b/doc/testbenches_doc_resources/5g-nsa-faraday-bench.png new file mode 100644 index 0000000000..c677b598e9 Binary files /dev/null and b/doc/testbenches_doc_resources/5g-nsa-faraday-bench.png differ diff --git a/doc/testbenches_doc_resources/5g-nsa-faraday-bench.tex b/doc/testbenches_doc_resources/5g-nsa-faraday-bench.tex new file mode 100644 index 0000000000..66b52f7f69 --- /dev/null +++ b/doc/testbenches_doc_resources/5g-nsa-faraday-bench.tex @@ -0,0 +1,55 @@ +\documentclass{standalone} + +\usepackage{tikz} +\usetikzlibrary{backgrounds, positioning, shapes.symbols} +\usepackage{helvet} +\renewcommand*{\rmdefault}{\sfdefault} + +\begin{document} +\begin{tikzpicture} + [ + font=\footnotesize, + faraday/.style={minimum size=3cm, draw, dashed}, + duplexer/.style={draw,fill=white}, + ] + + \node[faraday, label={[anchor=south east]above right:Faraday cage}] (faraday) {}; + + \node[above left=0cm and 2.8cm of faraday, label=above:obelix] (obelix) + {\includegraphics[width=1.2cm]{server}}; + \node[right=0.3cm of obelix, label=above:B200-mini] (b210o) + {\includegraphics[width=1.2cm]{b200-mini}} edge (obelix); + \node[below right=0.35cm of faraday.north west] (anto) + {\includegraphics[width=0.3cm]{antenna}}; + \draw (b210o) -| node [pos=0.2, duplexer] {B7} (anto); + + \node[below left=0cm and 2.8cm of faraday, label=above:nepes] (nepes) + {\includegraphics[width=1.2cm]{server}}; + \node[right=0.3cm of nepes, label=above:B200-mini] (b210n) + {\includegraphics[width=1.2cm]{b200-mini}} edge (nepes); + \draw (obelix) -- (b210o); + \node[above right=0.35cm of faraday.south west] (antn) + {\includegraphics[width=0.3cm]{antenna}}; + \draw (b210n) -| node [pos=0.2, duplexer] {B78} (antn); + + \node[left=5cm of faraday, label=above:porcepix] (porcepix) + {\includegraphics[width=1.2cm]{server}}; + \draw (obelix) -- (porcepix); + \draw (nepes) -- (porcepix); + + \node[right=1.5cm of faraday, label=above:RM500Q-GL] (quectel) + {\includegraphics[height=1.2cm]{quectel}}; + \node[above left=-0.1cm and 0.2cm of faraday.east] (aq2) + {\includegraphics[width=0.3cm]{antenna}} edge (quectel); + \node[above=-0.2cm of aq2] (aq1) + {\includegraphics[width=0.3cm]{antenna}} edge (quectel); + \node[below=-0.2cm of aq2] (aq3) + {\includegraphics[width=0.3cm]{antenna}} edge (quectel); + \node[below=-0.2cm of aq3] + {\includegraphics[width=0.3cm]{antenna}} edge (quectel); + \node[right=1cm of quectel, label=above:idefix] (idefix) + {\includegraphics[width=1.2cm]{server}} + edge (quectel); + +\end{tikzpicture} +\end{document} diff --git a/doc/testbenches_doc_resources/5g-ota-bench.pdf b/doc/testbenches_doc_resources/5g-ota-bench.pdf new file mode 100644 index 0000000000..e4d4c15e39 Binary files /dev/null and b/doc/testbenches_doc_resources/5g-ota-bench.pdf differ diff --git a/doc/testbenches_doc_resources/5g-ota-bench.png b/doc/testbenches_doc_resources/5g-ota-bench.png new file mode 100644 index 0000000000..c93de7ec6f Binary files /dev/null and b/doc/testbenches_doc_resources/5g-ota-bench.png differ diff --git a/doc/testbenches_doc_resources/5g-ota-bench.tex b/doc/testbenches_doc_resources/5g-ota-bench.tex new file mode 100644 index 0000000000..cfd0bda22d --- /dev/null +++ b/doc/testbenches_doc_resources/5g-ota-bench.tex @@ -0,0 +1,63 @@ +\documentclass{standalone} + +\usepackage{tikz} +\usetikzlibrary{backgrounds, positioning, shapes.symbols} +\usepackage{helvet} +\renewcommand*{\rmdefault}{\sfdefault} + +\begin{document} +\begin{tikzpicture} + [ + font=\footnotesize, + faraday/.style={minimum size=3cm, draw, dashed}, + duplexer/.style={draw,fill=white}, + ] + + \node[label=above:porcepix] (porcepix) + {\includegraphics[width=1.2cm]{server}}; + + \node[above right=1cm and 2cm of porcepix, label=above:asterix] (asterix) + {\includegraphics[width=1.2cm]{server}} + edge (porcepix); + \node[right=0.3cm of asterix, label=above:N310] (n310a) + {\includegraphics[width=1.5cm]{n310}} edge (asterix); + \node[right=.2cm of n310a, duplexer] (b78o) {B78} edge (n310a); + \node[below right=-0.1cm and 0.35cm of b78o.east] (anto1) + {\includegraphics[width=0.3cm]{antenna}} edge (b78o); + \node[above right=-0.1cm and 0.35cm of b78o.east] (anto2) + {\includegraphics[width=0.3cm]{antenna}} edge (b78o); + + \node[right=2cm of porcepix, label=above:obelix] (obelix) + {\includegraphics[width=1.2cm]{server}} + edge (porcepix); + \node[above right=-0.5cm and 0.3cm of obelix, label=above:N310] (n310o) + {\includegraphics[width=1.5cm]{n310}} edge (obelix); + \node[right=.2cm of n310o, duplexer] (b78o) {B40} edge (n310o); + \node[below right=-0.1cm and 0.35cm of b78o.east] (anto1) + {\includegraphics[width=0.3cm]{antenna}} edge (b78o); + \node[above right=-0.1cm and 0.35cm of b78o.east] (anto2) + {\includegraphics[width=0.3cm]{antenna}} edge (b78o); + \node[below right=-0.5cm and 0.3cm of obelix, label=above:X310] (x310o) + {\includegraphics[width=1.5cm]{x310}} edge (obelix); + \node[right=.2cm of x310o, duplexer] (b78o) {B78} edge (x310o); + \node[below right=-0.1cm and 0.35cm of b78o.east] (anto1) + {\includegraphics[width=0.3cm]{antenna}} edge (b78o); + \node[above right=-0.1cm and 0.35cm of b78o.east] (anto2) + {\includegraphics[width=0.3cm]{antenna}} edge (b78o); + + \node[right=5.0cm of n310o, label=above:RM500Q-GL] (quectel) + {\includegraphics[height=1.2cm]{quectel}}; + \node[above left=-0.1cm and 0.8cm of quectel.west] (aq2) + {\includegraphics[width=0.3cm]{antenna}} edge (quectel); + \node[above=-0.2cm of aq2] (aq1) + {\includegraphics[width=0.3cm]{antenna}} edge (quectel); + \node[below=-0.2cm of aq2] (aq3) + {\includegraphics[width=0.3cm]{antenna}} edge (quectel); + \node[below=-0.2cm of aq3] + {\includegraphics[width=0.3cm]{antenna}} edge (quectel); + \node[right=1cm of quectel, label=above:nrmodule2] (nrmodule2) + {\includegraphics[width=1.2cm]{server}} + edge (quectel); + +\end{tikzpicture} +\end{document} diff --git a/doc/testbenches_doc_resources/antenna.pdf b/doc/testbenches_doc_resources/antenna.pdf new file mode 100644 index 0000000000..0d48aa8ab9 Binary files /dev/null and b/doc/testbenches_doc_resources/antenna.pdf differ diff --git a/doc/testbenches_doc_resources/b200-mini.png b/doc/testbenches_doc_resources/b200-mini.png new file mode 100644 index 0000000000..0355e45f18 Binary files /dev/null and b/doc/testbenches_doc_resources/b200-mini.png differ diff --git a/doc/testbenches_doc_resources/b210.jpg b/doc/testbenches_doc_resources/b210.jpg new file mode 100644 index 0000000000..23599b0b1f Binary files /dev/null and b/doc/testbenches_doc_resources/b210.jpg differ diff --git a/doc/testbenches_doc_resources/indoor_live.jpg b/doc/testbenches_doc_resources/indoor_live.jpg deleted file mode 100755 index ce8b9cda48..0000000000 Binary files a/doc/testbenches_doc_resources/indoor_live.jpg and /dev/null differ diff --git a/doc/testbenches_doc_resources/legacy1.jpg b/doc/testbenches_doc_resources/legacy1.jpg deleted file mode 100755 index c3579df3e4..0000000000 Binary files a/doc/testbenches_doc_resources/legacy1.jpg and /dev/null differ diff --git a/doc/testbenches_doc_resources/legacy2.jpg b/doc/testbenches_doc_resources/legacy2.jpg deleted file mode 100755 index f40d167a2d..0000000000 Binary files a/doc/testbenches_doc_resources/legacy2.jpg and /dev/null differ diff --git a/doc/testbenches_doc_resources/n310.png b/doc/testbenches_doc_resources/n310.png new file mode 100644 index 0000000000..7d6ead5718 Binary files /dev/null and b/doc/testbenches_doc_resources/n310.png differ diff --git a/doc/testbenches_doc_resources/next_ci.jpg b/doc/testbenches_doc_resources/next_ci.jpg deleted file mode 100755 index 2d4111510c..0000000000 Binary files a/doc/testbenches_doc_resources/next_ci.jpg and /dev/null differ diff --git a/doc/testbenches_doc_resources/next_dev.jpg b/doc/testbenches_doc_resources/next_dev.jpg deleted file mode 100755 index 72e9f63bf9..0000000000 Binary files a/doc/testbenches_doc_resources/next_dev.jpg and /dev/null differ diff --git a/doc/testbenches_doc_resources/outdoor_live.jpg b/doc/testbenches_doc_resources/outdoor_live.jpg deleted file mode 100755 index eba44a3c00..0000000000 Binary files a/doc/testbenches_doc_resources/outdoor_live.jpg and /dev/null differ diff --git a/doc/testbenches_doc_resources/phone.pdf b/doc/testbenches_doc_resources/phone.pdf new file mode 100644 index 0000000000..4451c7af1a Binary files /dev/null and b/doc/testbenches_doc_resources/phone.pdf differ diff --git a/doc/testbenches_doc_resources/quectel.png b/doc/testbenches_doc_resources/quectel.png new file mode 100644 index 0000000000..443e62dcb5 Binary files /dev/null and b/doc/testbenches_doc_resources/quectel.png differ diff --git a/doc/testbenches_doc_resources/server.pdf b/doc/testbenches_doc_resources/server.pdf new file mode 100644 index 0000000000..6034fcf667 Binary files /dev/null and b/doc/testbenches_doc_resources/server.pdf differ diff --git a/doc/testbenches_doc_resources/x310.jpg b/doc/testbenches_doc_resources/x310.jpg new file mode 100644 index 0000000000..3e14d30a15 Binary files /dev/null and b/doc/testbenches_doc_resources/x310.jpg differ diff --git a/doc/tutorial_resources/docker-compose-basic-nrf.yaml b/doc/tutorial_resources/docker-compose-basic-nrf.yaml new file mode 100644 index 0000000000..6750cb78be --- /dev/null +++ b/doc/tutorial_resources/docker-compose-basic-nrf.yaml @@ -0,0 +1,316 @@ +version: '3.8' +services: + mysql: + container_name: "mysql" + image: mysql:5.7 + volumes: + - ./oai_db.sql:/docker-entrypoint-initdb.d/oai_db.sql + - ./mysql-healthcheck2.sh:/tmp/mysql-healthcheck.sh + environment: + - TZ=Europe/Paris + - MYSQL_DATABASE=oai_db + - MYSQL_USER=test + - MYSQL_PASSWORD=test + - MYSQL_ROOT_PASSWORD=linux + healthcheck: + test: /bin/bash -c "/tmp/mysql-healthcheck.sh" + interval: 10s + timeout: 5s + retries: 5 + networks: + public_net: + ipv4_address: 192.168.70.131 + oai-udr: + container_name: oai-udr + image: oai-udr:develop + environment: + - TZ=Europe/Paris + - INSTANCE=0 + - PID_DIRECTORY=/var/run + - UDR_INTERFACE_NAME_FOR_NUDR=eth0 + - UDR_INTERFACE_PORT_FOR_NUDR=80 + - UDR_INTERFACE_HTTP2_PORT_FOR_NUDR=8080 + - UDR_API_VERSION=v1 + - MYSQL_IPV4_ADDRESS=192.168.70.131 + - MYSQL_USER=test + - MYSQL_PASS=test + - MYSQL_DB=oai_db + - WAIT_MYSQL=120 + depends_on: + - mysql + networks: + public_net: + ipv4_address: 192.168.70.136 + volumes: + - ./udr-healthcheck.sh:/openair-udr/bin/udr-healthcheck.sh + healthcheck: + test: /bin/bash -c "/openair-udr/bin/udr-healthcheck.sh" + interval: 10s + timeout: 5s + retries: 5 + oai-udm: + container_name: oai-udm + image: oai-udm:develop + environment: + - TZ=Europe/Paris + - INSTANCE=0 + - PID_DIRECTORY=/var/run + - UDM_NAME=OAI_UDM + - SBI_IF_NAME=eth0 + - SBI_PORT=80 + - UDM_VERSION_NB=v1 + - USE_FQDN_DNS=yes + - UDR_IP_ADDRESS=192.168.70.136 + - UDR_PORT=80 + - UDR_VERSION_NB=v1 + - UDR_FQDN=oai-udr + depends_on: + - oai-udr + networks: + public_net: + ipv4_address: 192.168.70.137 + volumes: + - ./udm-healthcheck.sh:/openair-udm/bin/udm-healthcheck.sh + healthcheck: + test: /bin/bash -c "/openair-udm/bin/udm-healthcheck.sh" + interval: 10s + timeout: 5s + retries: 5 + oai-ausf: + container_name: oai-ausf + image: oai-ausf:develop + environment: + - TZ=Europe/Paris + - INSTANCE_ID=0 + - PID_DIR=/var/run + - AUSF_NAME=OAI_AUSF + - SBI_IF_NAME=eth0 + - SBI_PORT=80 + - USE_FQDN_DNS=yes + - UDM_IP_ADDRESS=192.168.70.137 + - UDM_PORT=80 + - UDM_VERSION_NB=v1 + - UDM_FQDN=oai-udm + depends_on: + - oai-udm + networks: + public_net: + ipv4_address: 192.168.70.138 + volumes: + - ./ausf-healthcheck.sh:/openair-ausf/bin/ausf-healthcheck.sh + healthcheck: + test: /bin/bash -c "/openair-ausf/bin/ausf-healthcheck.sh" + interval: 10s + timeout: 5s + retries: 5 + oai-nrf: + container_name: "oai-nrf" + image: oai-nrf:develop + environment: + - NRF_INTERFACE_NAME_FOR_SBI=eth0 + - NRF_INTERFACE_PORT_FOR_SBI=80 + - NRF_INTERFACE_HTTP2_PORT_FOR_SBI=9090 + - NRF_API_VERSION=v1 + - INSTANCE=0 + - PID_DIRECTORY=/var/run + networks: + public_net: + ipv4_address: 192.168.70.130 + volumes: + - ./nrf-healthcheck.sh:/openair-nrf/bin/nrf-healthcheck.sh + healthcheck: + test: /bin/bash -c "/openair-nrf/bin/nrf-healthcheck.sh" + interval: 10s + timeout: 5s + retries: 5 + oai-amf: + container_name: "oai-amf" + image: oai-amf:develop + environment: + - TZ=Europe/paris + - INSTANCE=0 + - PID_DIRECTORY=/var/run + - MCC=208 + - MNC=99 + - REGION_ID=128 + - AMF_SET_ID=1 + - SERVED_GUAMI_MCC_0=208 + - SERVED_GUAMI_MNC_0=99 + - SERVED_GUAMI_REGION_ID_0=128 + - SERVED_GUAMI_AMF_SET_ID_0=1 + - SERVED_GUAMI_MCC_1=460 + - SERVED_GUAMI_MNC_1=11 + - SERVED_GUAMI_REGION_ID_1=10 + - SERVED_GUAMI_AMF_SET_ID_1=1 + - PLMN_SUPPORT_MCC=208 + - PLMN_SUPPORT_MNC=99 + - PLMN_SUPPORT_TAC=0x0001 + - SST_0=1 + - SD_0=1 + - SST_1=1 + - SD_1=12 + - AMF_INTERFACE_NAME_FOR_NGAP=eth0 + - AMF_INTERFACE_NAME_FOR_N11=eth0 + - SMF_INSTANCE_ID_0=1 + - SMF_FQDN_0=oai-smf + - SMF_IPV4_ADDR_0=192.168.70.133 + - SMF_HTTP_VERSION_0=v1 + - SELECTED_0=true + - SMF_INSTANCE_ID_1=2 + - SMF_FQDN_1=oai-smf + - SMF_IPV4_ADDR_1=0.0.0.0 + - SMF_HTTP_VERSION_1=v1 + - SELECTED_1=false + - MYSQL_SERVER=192.168.70.131 + - MYSQL_USER=root + - MYSQL_PASS=linux + - MYSQL_DB=oai_db + - OPERATOR_KEY=1006020f0a478bf6b699f15c062e42b3 + - NRF_IPV4_ADDRESS=192.168.70.130 + - NRF_PORT=80 + - NF_REGISTRATION=yes + - SMF_SELECTION=yes + - USE_FQDN_DNS=yes + - EXTERNAL_AUSF=yes + - NRF_API_VERSION=v1 + - NRF_FQDN=oai-nrf + - AUSF_IPV4_ADDRESS=192.168.70.138 + - AUSF_PORT=80 + - AUSF_API_VERSION=v1 + - AUSF_FQDN=oai-ausf + depends_on: + - mysql + - oai-nrf + - oai-ausf + volumes: + - ./amf-healthcheck.sh:/openair-amf/bin/amf-healthcheck.sh + healthcheck: + test: /bin/bash -c "/openair-amf/bin/amf-healthcheck.sh" + interval: 10s + timeout: 15s + retries: 5 + networks: + public_net: + ipv4_address: 192.168.70.132 + oai-smf: + container_name: "oai-smf" + image: oai-smf:develop + environment: + - TZ=Europe/Paris + - INSTANCE=0 + - PID_DIRECTORY=/var/run + - SMF_INTERFACE_NAME_FOR_N4=eth0 + - SMF_INTERFACE_NAME_FOR_SBI=eth0 + - SMF_INTERFACE_PORT_FOR_SBI=80 + - SMF_INTERFACE_HTTP2_PORT_FOR_SBI=9090 + - SMF_API_VERSION=v1 + - DEFAULT_DNS_IPV4_ADDRESS=8.8.8.8 + - DEFAULT_DNS_SEC_IPV4_ADDRESS=4.4.4.4 + - AMF_IPV4_ADDRESS=192.168.70.132 + - AMF_PORT=80 + - AMF_API_VERSION=v1 + - AMF_FQDN=oai-amf + - UDM_IPV4_ADDRESS=192.168.70.137 + - UDM_PORT=80 + - UDM_API_VERSION=v1 + - UDM_FQDN=oai-udm + - UPF_IPV4_ADDRESS=192.168.70.134 + - UPF_FQDN_0=oai-spgwu + - NRF_IPV4_ADDRESS=192.168.70.130 + - NRF_PORT=80 + - NRF_API_VERSION=v1 + - USE_LOCAL_SUBSCRIPTION_INFO=yes + - NRF_FQDN=oai-nrf + - REGISTER_NRF=yes + - DISCOVER_UPF=yes + - USE_FQDN_DNS=yes + - DNN_RANGE1=12.1.1.2 - 12.1.1.128 + - DNN_RANGE0=12.2.1.2 - 12.2.1.128 + - DNN_NI1=oai + depends_on: + - oai-nrf + - oai-amf + volumes: + - ./smf-healthcheck.sh:/openair-smf/bin/smf-healthcheck.sh + healthcheck: + test: /bin/bash -c "/openair-smf/bin/smf-healthcheck.sh" + interval: 10s + timeout: 5s + retries: 5 + networks: + public_net: + ipv4_address: 192.168.70.133 + oai-spgwu: + container_name: "oai-spgwu" + image: oai-spgwu-tiny:develop + environment: + - TZ=Europe/Paris + - PID_DIRECTORY=/var/run + - SGW_INTERFACE_NAME_FOR_S1U_S12_S4_UP=eth0 + - SGW_INTERFACE_NAME_FOR_SX=eth0 + - PGW_INTERFACE_NAME_FOR_SGI=eth0 + - NETWORK_UE_NAT_OPTION=yes + - NETWORK_UE_IP=12.1.1.0/24 + - SPGWC0_IP_ADDRESS=192.168.70.133 + - BYPASS_UL_PFCP_RULES=no + - MCC=208 + - MNC=99 + - MNC03=099 + - TAC=1 + - GW_ID=1 + - REALM=openairinterface.org + - ENABLE_5G_FEATURES=yes + - REGISTER_NRF=yes + - USE_FQDN_NRF=no + - UPF_FQDN_5G=oai-spgwu + - NRF_IPV4_ADDRESS=192.168.70.130 + - NRF_PORT=80 + - NRF_API_VERSION=v1 + - NRF_FQDN=oai-nrf + - NSSAI_SST_0=1 + - NSSAI_SD_0=1 + - DNN_0=oai + depends_on: + - oai-nrf + - oai-smf + cap_add: + - NET_ADMIN + - SYS_ADMIN + cap_drop: + - ALL + privileged: true + volumes: + - ./spgwu-healthcheck.sh:/openair-spgwu-tiny/bin/spgwu-healthcheck.sh + healthcheck: + test: /bin/bash -c "/openair-spgwu-tiny/bin/spgwu-healthcheck.sh" + interval: 10s + timeout: 5s + retries: 5 + networks: + public_net: + ipv4_address: 192.168.70.134 + oai-ext-dn: + image: ubuntu:bionic + privileged: true + container_name: oai-ext-dn + entrypoint: /bin/bash -c \ + "apt update; apt install -y iptables iproute2 iperf iperf3 iputils-ping;"\ + "iptables -t nat -A POSTROUTING -o eth0 -j MASQUERADE;"\ + "ip route add 12.1.1.0/24 via 192.168.70.134 dev eth0; sleep infinity" + depends_on: + - oai-spgwu + networks: + public_net: + ipv4_address: 192.168.70.135 +networks: + public_net: + external: + name: demo-oai-public-net +# public_net: +# driver: bridge +# name: demo-oai-public-net +# ipam: +# config: +# - subnet: 192.168.70.128/26 +# driver_opts: +# com.docker.network.bridge.name: "demo-oai" diff --git a/doc/tutorial_resources/oai_db.sql b/doc/tutorial_resources/oai_db.sql new file mode 100644 index 0000000000..e019c60e86 --- /dev/null +++ b/doc/tutorial_resources/oai_db.sql @@ -0,0 +1,312 @@ +-- phpMyAdmin SQL Dump +-- version 5.1.0 +-- https://www.phpmyadmin.net/ +-- +-- Host: 172.16.200.10:3306 +-- Generation Time: Mar 22, 2021 at 10:31 AM +-- Server version: 5.7.33 +-- PHP Version: 7.4.15 + +SET SQL_MODE = "NO_AUTO_VALUE_ON_ZERO"; +START TRANSACTION; +SET time_zone = "+00:00"; + + +/*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */; +/*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */; +/*!40101 SET @OLD_COLLATION_CONNECTION=@@COLLATION_CONNECTION */; +/*!40101 SET NAMES utf8mb4 */; + +-- +-- Database: `oai_db` +-- + +-- -------------------------------------------------------- + +-- +-- Table structure for table `AccessAndMobilitySubscriptionData` +-- + +CREATE TABLE `AccessAndMobilitySubscriptionData` ( + `ueid` varchar(15) NOT NULL, + `servingPlmnid` varchar(15) NOT NULL, + `supportedFeatures` varchar(50) DEFAULT NULL, + `gpsis` json DEFAULT NULL, + `internalGroupIds` json DEFAULT NULL, + `sharedVnGroupDataIds` json DEFAULT NULL, + `subscribedUeAmbr` json DEFAULT NULL, + `nssai` json DEFAULT NULL, + `ratRestrictions` json DEFAULT NULL, + `forbiddenAreas` json DEFAULT NULL, + `serviceAreaRestriction` json DEFAULT NULL, + `coreNetworkTypeRestrictions` json DEFAULT NULL, + `rfspIndex` int(10) DEFAULT NULL, + `subsRegTimer` int(10) DEFAULT NULL, + `ueUsageType` int(10) DEFAULT NULL, + `mpsPriority` tinyint(1) DEFAULT NULL, + `mcsPriority` tinyint(1) DEFAULT NULL, + `activeTime` int(10) DEFAULT NULL, + `sorInfo` json DEFAULT NULL, + `sorInfoExpectInd` tinyint(1) DEFAULT NULL, + `sorafRetrieval` tinyint(1) DEFAULT NULL, + `sorUpdateIndicatorList` json DEFAULT NULL, + `upuInfo` json DEFAULT NULL, + `micoAllowed` tinyint(1) DEFAULT NULL, + `sharedAmDataIds` json DEFAULT NULL, + `odbPacketServices` json DEFAULT NULL, + `serviceGapTime` int(10) DEFAULT NULL, + `mdtUserConsent` json DEFAULT NULL, + `mdtConfiguration` json DEFAULT NULL, + `traceData` json DEFAULT NULL, + `cagData` json DEFAULT NULL, + `stnSr` varchar(50) DEFAULT NULL, + `cMsisdn` varchar(50) DEFAULT NULL, + `nbIoTUePriority` int(10) DEFAULT NULL, + `nssaiInclusionAllowed` tinyint(1) DEFAULT NULL, + `rgWirelineCharacteristics` varchar(50) DEFAULT NULL, + `ecRestrictionDataWb` json DEFAULT NULL, + `ecRestrictionDataNb` tinyint(1) DEFAULT NULL, + `expectedUeBehaviourList` json DEFAULT NULL, + `primaryRatRestrictions` json DEFAULT NULL, + `secondaryRatRestrictions` json DEFAULT NULL, + `edrxParametersList` json DEFAULT NULL, + `ptwParametersList` json DEFAULT NULL, + `iabOperationAllowed` tinyint(1) DEFAULT NULL, + `wirelineForbiddenAreas` json DEFAULT NULL, + `wirelineServiceAreaRestriction` json DEFAULT NULL +) ENGINE=InnoDB DEFAULT CHARSET=utf8; + +-- -------------------------------------------------------- + +-- +-- Table structure for table `Amf3GppAccessRegistration` +-- + +CREATE TABLE `Amf3GppAccessRegistration` ( + `ueid` varchar(15) NOT NULL, + `amfInstanceId` varchar(50) NOT NULL, + `supportedFeatures` varchar(50) DEFAULT NULL, + `purgeFlag` tinyint(1) DEFAULT NULL, + `pei` varchar(50) DEFAULT NULL, + `imsVoPs` json DEFAULT NULL, + `deregCallbackUri` varchar(50) NOT NULL, + `amfServiceNameDereg` json DEFAULT NULL, + `pcscfRestorationCallbackUri` varchar(50) DEFAULT NULL, + `amfServiceNamePcscfRest` json DEFAULT NULL, + `initialRegistrationInd` tinyint(1) DEFAULT NULL, + `guami` json NOT NULL, + `backupAmfInfo` json DEFAULT NULL, + `drFlag` tinyint(1) DEFAULT NULL, + `ratType` json NOT NULL, + `urrpIndicator` tinyint(1) DEFAULT NULL, + `amfEeSubscriptionId` varchar(50) DEFAULT NULL, + `epsInterworkingInfo` json DEFAULT NULL, + `ueSrvccCapability` tinyint(1) DEFAULT NULL, + `registrationTime` varchar(50) DEFAULT NULL, + `vgmlcAddress` json DEFAULT NULL, + `contextInfo` json DEFAULT NULL, + `noEeSubscriptionInd` tinyint(1) DEFAULT NULL +) ENGINE=InnoDB DEFAULT CHARSET=utf8; + +-- -------------------------------------------------------- + +-- +-- Table structure for table `AuthenticationStatus` +-- + +CREATE TABLE `AuthenticationStatus` ( + `ueid` varchar(20) NOT NULL, + `nfInstanceId` varchar(50) NOT NULL, + `success` tinyint(1) NOT NULL, + `timeStamp` varchar(50) NOT NULL, + `authType` varchar(25) NOT NULL, + `servingNetworkName` varchar(50) NOT NULL, + `authRemovalInd` tinyint(1) DEFAULT NULL +) ENGINE=InnoDB DEFAULT CHARSET=utf8; + +-- -------------------------------------------------------- + +-- +-- Table structure for table `AuthenticationSubscription` +-- + +CREATE TABLE `AuthenticationSubscription` ( + `ueid` varchar(20) NOT NULL, + `authenticationMethod` varchar(25) NOT NULL, + `encPermanentKey` varchar(50) DEFAULT NULL, + `protectionParameterId` varchar(50) DEFAULT NULL, + `sequenceNumber` json DEFAULT NULL, + `authenticationManagementField` varchar(50) DEFAULT NULL, + `algorithmId` varchar(50) DEFAULT NULL, + `encOpcKey` varchar(50) DEFAULT NULL, + `encTopcKey` varchar(50) DEFAULT NULL, + `vectorGenerationInHss` tinyint(1) DEFAULT NULL, + `n5gcAuthMethod` varchar(15) DEFAULT NULL, + `rgAuthenticationInd` tinyint(1) DEFAULT NULL, + `supi` varchar(20) DEFAULT NULL +) ENGINE=InnoDB DEFAULT CHARSET=utf8; + +-- +-- Dumping data for table `AuthenticationSubscription` +-- + +INSERT INTO `AuthenticationSubscription` (`ueid`, `authenticationMethod`, `encPermanentKey`, `protectionParameterId`, `sequenceNumber`, `authenticationManagementField`, `algorithmId`, `encOpcKey`, `encTopcKey`, `vectorGenerationInHss`, `n5gcAuthMethod`, `rgAuthenticationInd`, `supi`) VALUES +('208950000000031', '5G_AKA', '0C0A34601D4F07677303652C0462535B', '0C0A34601D4F07677303652C0462535B', '{\"sqn\": \"000000000020\", \"sqnScheme\": \"NON_TIME_BASED\", \"lastIndexes\": {\"ausf\": 0}}', '8000', 'milenage', '63bfa50ee6523365ff14c1f45f88737d', NULL, NULL, NULL, NULL, '208950000000031'); + +INSERT INTO `AuthenticationSubscription` (`ueid`, `authenticationMethod`, `encPermanentKey`, `protectionParameterId`, `sequenceNumber`, `authenticationManagementField`, `algorithmId`, `encOpcKey`, `encTopcKey`, `vectorGenerationInHss`, `n5gcAuthMethod`, `rgAuthenticationInd`, `supi`) VALUES +('208990000000001', '5G_AKA', 'fec86ba6eb707ed08905757b1bb44b8f', 'fec86ba6eb707ed08905757b1bb44b8f', '{\"sqn\": \"000000000020\", \"sqnScheme\": \"NON_TIME_BASED\", \"lastIndexes\": {\"ausf\": 0}}', '8000', 'milenage', 'C42449363BBAD02B66D16BC975D77CC1', NULL, NULL, NULL, NULL, '208990000000001'); + +-- -------------------------------------------------------- + +-- +-- Table structure for table `SdmSubscriptions` +-- + +CREATE TABLE `SdmSubscriptions` ( + `ueid` varchar(15) NOT NULL, + `subsId` int(10) UNSIGNED NOT NULL, + `nfInstanceId` varchar(50) NOT NULL, + `implicitUnsubscribe` tinyint(1) DEFAULT NULL, + `expires` varchar(50) DEFAULT NULL, + `callbackReference` varchar(50) NOT NULL, + `amfServiceName` json DEFAULT NULL, + `monitoredResourceUris` json NOT NULL, + `singleNssai` json DEFAULT NULL, + `dnn` varchar(50) DEFAULT NULL, + `subscriptionId` varchar(50) DEFAULT NULL, + `plmnId` json DEFAULT NULL, + `immediateReport` tinyint(1) DEFAULT NULL, + `report` json DEFAULT NULL, + `supportedFeatures` varchar(50) DEFAULT NULL, + `contextInfo` json DEFAULT NULL +) ENGINE=InnoDB DEFAULT CHARSET=utf8; + +-- -------------------------------------------------------- + +-- +-- Table structure for table `SessionManagementSubscriptionData` +-- + +CREATE TABLE `SessionManagementSubscriptionData` ( + `ueid` varchar(15) NOT NULL, + `servingPlmnid` varchar(15) NOT NULL, + `singleNssai` json NOT NULL, + `dnnConfigurations` json DEFAULT NULL, + `internalGroupIds` json DEFAULT NULL, + `sharedVnGroupDataIds` json DEFAULT NULL, + `sharedDnnConfigurationsId` varchar(50) DEFAULT NULL, + `odbPacketServices` json DEFAULT NULL, + `traceData` json DEFAULT NULL, + `sharedTraceDataId` varchar(50) DEFAULT NULL, + `expectedUeBehavioursList` json DEFAULT NULL, + `suggestedPacketNumDlList` json DEFAULT NULL, + `3gppChargingCharacteristics` varchar(50) DEFAULT NULL +) ENGINE=InnoDB DEFAULT CHARSET=utf8; + +-- -------------------------------------------------------- + +-- +-- Table structure for table `SmfRegistrations` +-- + +CREATE TABLE `SmfRegistrations` ( + `ueid` varchar(15) NOT NULL, + `subpduSessionId` int(10) NOT NULL, + `smfInstanceId` varchar(50) NOT NULL, + `smfSetId` varchar(50) DEFAULT NULL, + `supportedFeatures` varchar(50) DEFAULT NULL, + `pduSessionId` int(10) NOT NULL, + `singleNssai` json NOT NULL, + `dnn` varchar(50) DEFAULT NULL, + `emergencyServices` tinyint(1) DEFAULT NULL, + `pcscfRestorationCallbackUri` varchar(50) DEFAULT NULL, + `plmnId` json NOT NULL, + `pgwFqdn` varchar(50) DEFAULT NULL, + `epdgInd` tinyint(1) DEFAULT NULL, + `deregCallbackUri` varchar(50) DEFAULT NULL, + `registrationReason` json DEFAULT NULL, + `registrationTime` varchar(50) DEFAULT NULL, + `contextInfo` json DEFAULT NULL +) ENGINE=InnoDB DEFAULT CHARSET=utf8; + +-- -------------------------------------------------------- + +-- +-- Table structure for table `SmfSelectionSubscriptionData` +-- + +CREATE TABLE `SmfSelectionSubscriptionData` ( + `ueid` varchar(15) NOT NULL, + `servingPlmnid` varchar(15) NOT NULL, + `supportedFeatures` varchar(50) DEFAULT NULL, + `subscribedSnssaiInfos` json DEFAULT NULL, + `sharedSnssaiInfosId` varchar(50) DEFAULT NULL +) ENGINE=InnoDB DEFAULT CHARSET=utf8; + +-- +-- Indexes for dumped tables +-- + +-- +-- Indexes for table `AccessAndMobilitySubscriptionData` +-- +ALTER TABLE `AccessAndMobilitySubscriptionData` + ADD PRIMARY KEY (`ueid`,`servingPlmnid`) USING BTREE; + +-- +-- Indexes for table `Amf3GppAccessRegistration` +-- +ALTER TABLE `Amf3GppAccessRegistration` + ADD PRIMARY KEY (`ueid`); + +-- +-- Indexes for table `AuthenticationStatus` +-- +ALTER TABLE `AuthenticationStatus` + ADD PRIMARY KEY (`ueid`); + +-- +-- Indexes for table `AuthenticationSubscription` +-- +ALTER TABLE `AuthenticationSubscription` + ADD PRIMARY KEY (`ueid`); + +-- +-- Indexes for table `SdmSubscriptions` +-- +ALTER TABLE `SdmSubscriptions` + ADD PRIMARY KEY (`subsId`,`ueid`) USING BTREE; + +-- +-- Indexes for table `SessionManagementSubscriptionData` +-- +ALTER TABLE `SessionManagementSubscriptionData` + ADD PRIMARY KEY (`ueid`,`servingPlmnid`) USING BTREE; + +-- +-- Indexes for table `SmfRegistrations` +-- +ALTER TABLE `SmfRegistrations` + ADD PRIMARY KEY (`ueid`,`subpduSessionId`) USING BTREE; + +-- +-- Indexes for table `SmfSelectionSubscriptionData` +-- +ALTER TABLE `SmfSelectionSubscriptionData` + ADD PRIMARY KEY (`ueid`,`servingPlmnid`) USING BTREE; + +-- +-- AUTO_INCREMENT for dumped tables +-- + +-- +-- AUTO_INCREMENT for table `SdmSubscriptions` +-- +ALTER TABLE `SdmSubscriptions` + MODIFY `subsId` int(10) UNSIGNED NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=3; +COMMIT; + +/*!40101 SET CHARACTER_SET_CLIENT=@OLD_CHARACTER_SET_CLIENT */; +/*!40101 SET CHARACTER_SET_RESULTS=@OLD_CHARACTER_SET_RESULTS */; +/*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */; + diff --git a/docker/Dockerfile.eNB.rhel8.2 b/docker/Dockerfile.eNB.rhel8.2 index 6c921a4932..5296ac2172 100644 --- a/docker/Dockerfile.eNB.rhel8.2 +++ b/docker/Dockerfile.eNB.rhel8.2 @@ -62,7 +62,6 @@ COPY --from=enb-build \ COPY --from=enb-build \ /oai-ran/cmake_targets/ran_build/build/liboai_eth_transpro.so \ - /oai-ran/cmake_targets/ran_build/build/libtcp_bridge_oai.so \ /oai-ran/cmake_targets/ran_build/build/librfsimulator.so \ /oai-ran/cmake_targets/ran_build/build/liboai_usrpdevif.so \ /oai-ran/cmake_targets/ran_build/build/libcoding.so \ @@ -97,7 +96,7 @@ COPY --from=enb-base \ # Now we are copying from builder-image the UHD files. COPY --from=enb-base /usr/local/bin/uhd_find_devices /usr/local/bin -COPY --from=enb-base /usr/local/lib/libprotobuf-c.so.1 /usr/local/lib +COPY --from=enb-base /usr/lib64/libprotobuf-c.so.1 /usr/local/lib COPY --from=enb-base /usr/local/lib64/libuhd.so.3.15.0 /usr/local/lib64 COPY --from=enb-base /usr/local/lib64/uhd/utils/uhd_images_downloader.py /opt/oai-enb/bin diff --git a/docker/Dockerfile.eNB.rhel8.2.oc4-4 b/docker/Dockerfile.eNB.rhel8.2.oc4-4 index 5b784c08a2..03f6ec8e45 100644 --- a/docker/Dockerfile.eNB.rhel8.2.oc4-4 +++ b/docker/Dockerfile.eNB.rhel8.2.oc4-4 @@ -62,7 +62,6 @@ COPY --from=enb-build /oai-ran/targets/bin/lte-softmodem.Rel15 . WORKDIR /usr/local/lib/ COPY --from=enb-build /oai-ran/targets/bin/liboai_eth_transpro.so.Rel15 . -COPY --from=enb-build /oai-ran/targets/bin/libtcp_bridge_oai.so.Rel15 . COPY --from=enb-build /oai-ran/targets/bin/librfsimulator.so.Rel15 . COPY --from=enb-build /oai-ran/targets/bin/liboai_usrpdevif.so.Rel15 . COPY --from=enb-build /oai-ran/targets/bin/libcoding.so . @@ -95,7 +94,6 @@ RUN ldconfig #debug RUN ldd /usr/local/lib/liboai_eth_transpro.so.Rel15 -RUN ldd /usr/local/lib/libtcp_bridge_oai.so.Rel15 RUN ldd /usr/local/lib/librfsimulator.so.Rel15 RUN ldd /usr/local/lib/liboai_usrpdevif.so.Rel15 RUN ldd /usr/local/lib/libcoding.so diff --git a/docker/Dockerfile.eNB.ubuntu18 b/docker/Dockerfile.eNB.ubuntu18 index 1f375a20dc..f95a03398a 100644 --- a/docker/Dockerfile.eNB.ubuntu18 +++ b/docker/Dockerfile.eNB.ubuntu18 @@ -69,7 +69,6 @@ COPY --from=enb-build \ COPY --from=enb-build \ /oai-ran/cmake_targets/ran_build/build/liboai_eth_transpro.so \ - /oai-ran/cmake_targets/ran_build/build/libtcp_bridge_oai.so \ /oai-ran/cmake_targets/ran_build/build/librfsimulator.so \ /oai-ran/cmake_targets/ran_build/build/liboai_usrpdevif.so \ /oai-ran/cmake_targets/ran_build/build/libcoding.so \ @@ -84,7 +83,7 @@ COPY --from=enb-build \ COPY --from=enb-base /usr/local/bin/uhd_find_devices /usr/local/bin COPY --from=enb-base \ /usr/local/lib/libuhd.so.3.15.0 \ - /usr/local/lib/libprotobuf-c.so.1 \ + /usr/lib/x86_64-linux-gnu/libprotobuf-c.so.1 \ /usr/local/lib/ COPY --from=enb-base /usr/local/lib/uhd/utils/uhd_images_downloader.py /opt/oai-enb/bin COPY --from=enb-base \ diff --git a/docker/Dockerfile.gNB.rhel8.2 b/docker/Dockerfile.gNB.rhel8.2 index 703f4c67b5..9ec7ee7556 100644 --- a/docker/Dockerfile.gNB.rhel8.2 +++ b/docker/Dockerfile.gNB.rhel8.2 @@ -64,7 +64,6 @@ COPY --from=gnb-build \ COPY --from=gnb-build \ /oai-ran/cmake_targets/ran_build/build/liboai_eth_transpro.so \ - /oai-ran/cmake_targets/ran_build/build/libtcp_bridge_oai.so \ /oai-ran/cmake_targets/ran_build/build/librfsimulator.so \ /oai-ran/cmake_targets/ran_build/build/liboai_usrpdevif.so \ /oai-ran/cmake_targets/ran_build/build/libcoding.so \ @@ -101,7 +100,7 @@ COPY --from=gnb-base \ # Now we are copying from builder-image the UHD files. COPY --from=gnb-base /usr/local/bin/uhd_find_devices /usr/local/bin -COPY --from=gnb-base /usr/local/lib/libprotobuf-c.so.1 /usr/local/lib +COPY --from=gnb-base /usr/lib64/libprotobuf-c.so.1 /usr/local/lib COPY --from=gnb-base /usr/local/lib64/libuhd.so.3.15.0 /usr/local/lib64 COPY --from=gnb-base /usr/local/lib64/uhd/utils/uhd_images_downloader.py /opt/oai-gnb/bin diff --git a/docker/Dockerfile.gNB.rhel8.2.oc4-4 b/docker/Dockerfile.gNB.rhel8.2.oc4-4 index 1e1eba016e..6c88d3ad8e 100644 --- a/docker/Dockerfile.gNB.rhel8.2.oc4-4 +++ b/docker/Dockerfile.gNB.rhel8.2.oc4-4 @@ -65,7 +65,6 @@ COPY --from=gnb-build /oai-ran/targets/bin/nr-softmodem.Rel15 . WORKDIR /usr/local/lib/ COPY --from=gnb-build /oai-ran/targets/bin/liboai_eth_transpro.so.Rel15 . -COPY --from=gnb-build /oai-ran/targets/bin/libtcp_bridge_oai.so.Rel15 . COPY --from=gnb-build /oai-ran/targets/bin/librfsimulator.so.Rel15 . COPY --from=gnb-build /oai-ran/targets/bin/liboai_usrpdevif.so.Rel15 . COPY --from=gnb-build /oai-ran/targets/bin/libcoding.so . @@ -102,7 +101,6 @@ RUN ldconfig #debug RUN ldd /opt/oai-gnb/bin/nr-softmodem.Rel15 RUN ldd /usr/local/lib/liboai_eth_transpro.so.Rel15 -RUN ldd /usr/local/lib/libtcp_bridge_oai.so.Rel15 RUN ldd /usr/local/lib/librfsimulator.so.Rel15 RUN ldd /usr/local/lib/liboai_usrpdevif.so.Rel15 RUN ldd /usr/local/lib/libcoding.so diff --git a/docker/Dockerfile.gNB.ubuntu18 b/docker/Dockerfile.gNB.ubuntu18 index 24e4bcbc7c..6a98c8d3ce 100644 --- a/docker/Dockerfile.gNB.ubuntu18 +++ b/docker/Dockerfile.gNB.ubuntu18 @@ -68,7 +68,6 @@ COPY --from=gnb-build \ COPY --from=gnb-build \ /oai-ran/cmake_targets/ran_build/build/liboai_eth_transpro.so \ - /oai-ran/cmake_targets/ran_build/build/libtcp_bridge_oai.so \ /oai-ran/cmake_targets/ran_build/build/librfsimulator.so \ /oai-ran/cmake_targets/ran_build/build/liboai_usrpdevif.so \ /oai-ran/cmake_targets/ran_build/build/libcoding.so \ @@ -85,7 +84,7 @@ COPY --from=gnb-build \ COPY --from=gnb-base /usr/local/bin/uhd_find_devices /usr/local/bin COPY --from=gnb-base \ /usr/local/lib/libuhd.so.3.15.0 \ - /usr/local/lib/libprotobuf-c.so.1 \ + /usr/lib/x86_64-linux-gnu/libprotobuf-c.so.1 \ /usr/local/lib/ COPY --from=gnb-base /usr/local/lib/uhd/utils/uhd_images_downloader.py /opt/oai-gnb/bin COPY --from=gnb-base \ diff --git a/docker/Dockerfile.lteRU.rhel8.2 b/docker/Dockerfile.lteRU.rhel8.2 index 5addbca655..b41aee36dc 100644 --- a/docker/Dockerfile.lteRU.rhel8.2 +++ b/docker/Dockerfile.lteRU.rhel8.2 @@ -59,7 +59,6 @@ COPY --from=ru-build \ COPY --from=ru-build \ /oai-ran/cmake_targets/ran_build/build/liboai_eth_transpro.so \ - /oai-ran/cmake_targets/ran_build/build/libtcp_bridge_oai.so \ /oai-ran/cmake_targets/ran_build/build/librfsimulator.so \ /oai-ran/cmake_targets/ran_build/build/liboai_usrpdevif.so \ /oai-ran/cmake_targets/ran_build/build/libparams_libconfig.so \ diff --git a/docker/Dockerfile.lteRU.ubuntu18 b/docker/Dockerfile.lteRU.ubuntu18 index 1f1c903a15..1810afb621 100644 --- a/docker/Dockerfile.lteRU.ubuntu18 +++ b/docker/Dockerfile.lteRU.ubuntu18 @@ -64,7 +64,6 @@ COPY --from=ru-build \ COPY --from=ru-build \ /oai-ran/cmake_targets/ran_build/build/liboai_eth_transpro.so \ - /oai-ran/cmake_targets/ran_build/build/libtcp_bridge_oai.so \ /oai-ran/cmake_targets/ran_build/build/librfsimulator.so \ /oai-ran/cmake_targets/ran_build/build/liboai_usrpdevif.so \ /oai-ran/cmake_targets/ran_build/build/libparams_libconfig.so \ diff --git a/docker/Dockerfile.lteUE.rhel8.2 b/docker/Dockerfile.lteUE.rhel8.2 index f547558bdb..ab7d224939 100644 --- a/docker/Dockerfile.lteUE.rhel8.2 +++ b/docker/Dockerfile.lteUE.rhel8.2 @@ -66,7 +66,6 @@ COPY --from=lte-ue-build \ COPY --from=lte-ue-build \ /oai-ran/cmake_targets/ran_build/build/liboai_eth_transpro.so \ - /oai-ran/cmake_targets/ran_build/build/libtcp_bridge_oai.so \ /oai-ran/cmake_targets/ran_build/build/librfsimulator.so \ /oai-ran/cmake_targets/ran_build/build/liboai_usrpdevif.so \ /oai-ran/cmake_targets/ran_build/build/libcoding.so \ @@ -99,7 +98,7 @@ COPY --from=lte-ue-base \ # Now we are copying from builder-image the UHD files. COPY --from=lte-ue-base /usr/local/bin/uhd_find_devices /usr/local/bin -COPY --from=lte-ue-base /usr/local/lib/libprotobuf-c.so.1 /usr/local/lib +COPY --from=lte-ue-base /usr/lib64/libprotobuf-c.so.1 /usr/local/lib COPY --from=lte-ue-base /usr/local/lib64/libuhd.so.3.15.0 /usr/local/lib64 COPY --from=lte-ue-base /usr/local/lib64/uhd/utils/uhd_images_downloader.py /opt/oai-lte-ue/bin diff --git a/docker/Dockerfile.lteUE.rhel8.2.oc4-4 b/docker/Dockerfile.lteUE.rhel8.2.oc4-4 index 1339d18de6..cc492882f5 100644 --- a/docker/Dockerfile.lteUE.rhel8.2.oc4-4 +++ b/docker/Dockerfile.lteUE.rhel8.2.oc4-4 @@ -68,7 +68,6 @@ COPY --from=lte-ue-build /oai-ran/targets/bin/.usim.nvram0 . WORKDIR /usr/local/lib/ COPY --from=lte-ue-build /oai-ran/targets/bin/liboai_eth_transpro.so.Rel15 . -COPY --from=lte-ue-build /oai-ran/targets/bin/libtcp_bridge_oai.so.Rel15 . COPY --from=lte-ue-build /oai-ran/targets/bin/librfsimulator.so.Rel15 . COPY --from=lte-ue-build /oai-ran/targets/bin/liboai_usrpdevif.so.Rel15 . COPY --from=lte-ue-build /oai-ran/targets/bin/libcoding.so . @@ -105,7 +104,6 @@ RUN ldd /opt/oai-lte-ue/bin/conf2uedata RUN ldd /opt/oai-lte-ue/bin/nvram RUN ldd /opt/oai-lte-ue/bin/usim RUN ldd /usr/local/lib/liboai_eth_transpro.so.Rel15 -RUN ldd /usr/local/lib/libtcp_bridge_oai.so.Rel15 RUN ldd /usr/local/lib/librfsimulator.so.Rel15 RUN ldd /usr/local/lib/liboai_usrpdevif.so.Rel15 RUN ldd /usr/local/lib/libcoding.so diff --git a/docker/Dockerfile.lteUE.ubuntu18 b/docker/Dockerfile.lteUE.ubuntu18 index a5bf4cfe94..b2a0fd6e93 100644 --- a/docker/Dockerfile.lteUE.ubuntu18 +++ b/docker/Dockerfile.lteUE.ubuntu18 @@ -73,7 +73,6 @@ COPY --from=lte-ue-build \ COPY --from=lte-ue-build \ /oai-ran/cmake_targets/ran_build/build/liboai_eth_transpro.so \ - /oai-ran/cmake_targets/ran_build/build/libtcp_bridge_oai.so \ /oai-ran/cmake_targets/ran_build/build/librfsimulator.so \ /oai-ran/cmake_targets/ran_build/build/liboai_usrpdevif.so \ /oai-ran/cmake_targets/ran_build/build/libcoding.so \ @@ -87,7 +86,7 @@ COPY --from=lte-ue-build \ COPY --from=lte-ue-base /usr/local/bin/uhd_find_devices /usr/local/bin COPY --from=lte-ue-base \ /usr/local/lib/libuhd.so.3.15.0 \ - /usr/local/lib/libprotobuf-c.so.1 \ + /usr/lib/x86_64-linux-gnu/libprotobuf-c.so.1 \ /usr/local/lib/ COPY --from=lte-ue-base /usr/local/lib/uhd/utils/uhd_images_downloader.py /opt/oai-lte-ue/bin diff --git a/docker/Dockerfile.nrUE.rhel8.2 b/docker/Dockerfile.nrUE.rhel8.2 index cbc8d8c65f..dfb28cfd1d 100644 --- a/docker/Dockerfile.nrUE.rhel8.2 +++ b/docker/Dockerfile.nrUE.rhel8.2 @@ -29,7 +29,8 @@ FROM ran-base:latest AS nr-ue-base FROM ran-build:latest AS nr-ue-build -RUN cp /oai-ran/docker/scripts/nr_ue_entrypoint.sh /oai-ran/docker/scripts/entrypoint.sh +RUN python3 ./docker/scripts/generateTemplate.py ./docker/scripts/nr_ue_parameters.yaml && \ + cp /oai-ran/docker/scripts/nr_ue_entrypoint.sh /oai-ran/docker/scripts/entrypoint.sh #start from scratch for target executable FROM registry.access.redhat.com/ubi8/ubi:latest as oai-nr-ue @@ -62,11 +63,13 @@ COPY --from=nr-ue-build \ ./ WORKDIR /opt/oai-nr-ue/etc -COPY --from=nr-ue-build /oai-ran/ci-scripts/conf_files/nr-ue-sim.conf . +COPY --from=nr-ue-build \ + /oai-ran/ci-scripts/conf_files/nr-ue-sim.conf \ + /oai-ran/docker/etc/nr-ue.nfapi.conf \ + ./ COPY --from=nr-ue-build \ /oai-ran/cmake_targets/ran_build/build/liboai_eth_transpro.so \ - /oai-ran/cmake_targets/ran_build/build/libtcp_bridge_oai.so \ /oai-ran/cmake_targets/ran_build/build/librfsimulator.so \ /oai-ran/cmake_targets/ran_build/build/liboai_usrpdevif.so \ /oai-ran/cmake_targets/ran_build/build/libcoding.so \ @@ -104,7 +107,7 @@ COPY --from=nr-ue-base \ # Now we are copying from builder-image the UHD files. COPY --from=nr-ue-base /usr/local/bin/uhd_find_devices /usr/local/bin -COPY --from=nr-ue-base /usr/local/lib/libprotobuf-c.so.1 /usr/local/lib +COPY --from=nr-ue-base /usr/lib64/libprotobuf-c.so.1 /usr/local/lib COPY --from=nr-ue-base /usr/local/lib64/libuhd.so.3.15.0 /usr/local/lib64 COPY --from=nr-ue-base /usr/local/lib64/uhd/utils/uhd_images_downloader.py /opt/oai-nr-ue/bin @@ -119,5 +122,5 @@ WORKDIR /opt/oai-nr-ue/etc COPY --from=nr-ue-build /oai-ran/ci-scripts/conf_files/ue.* . WORKDIR /opt/oai-nr-ue -CMD ["/opt/oai-nr-ue/bin/nr-uesoftmodem.Rel15", "-O", "/opt/oai-nr-ue/etc/nr-ue-sim.conf"] +CMD ["/opt/oai-nr-ue/bin/nr-uesoftmodem.Rel15", "-O", "/opt/oai-nr-ue/etc/nr-ue.conf"] ENTRYPOINT ["/opt/oai-nr-ue/bin/entrypoint.sh"] diff --git a/docker/Dockerfile.nrUE.rhel8.2.oc4-4 b/docker/Dockerfile.nrUE.rhel8.2.oc4-4 index d900fff998..2d018c96af 100644 --- a/docker/Dockerfile.nrUE.rhel8.2.oc4-4 +++ b/docker/Dockerfile.nrUE.rhel8.2.oc4-4 @@ -64,7 +64,6 @@ COPY --from=nr-ue-build /oai-ran/targets/bin/nr-uesoftmodem.Rel15 . WORKDIR /usr/local/lib/ COPY --from=nr-ue-build /oai-ran/targets/bin/liboai_eth_transpro.so.Rel15 . -COPY --from=nr-ue-build /oai-ran/targets/bin/libtcp_bridge_oai.so.Rel15 . COPY --from=nr-ue-build /oai-ran/targets/bin/librfsimulator.so.Rel15 . COPY --from=nr-ue-build /oai-ran/targets/bin/liboai_usrpdevif.so.Rel15 . COPY --from=nr-ue-build /oai-ran/targets/bin/libcoding.so . @@ -100,7 +99,6 @@ COPY --from=nr-ue-build /usr/local/lib64/libuhd.so.4.0.0 /usr/local/lib64 RUN ldconfig RUN ldd /opt/oai-nr-ue/bin/nr-uesoftmodem.Rel15 RUN ldd /usr/local/lib/liboai_eth_transpro.so.Rel15 -RUN ldd /usr/local/lib/libtcp_bridge_oai.so.Rel15 RUN ldd /usr/local/lib/librfsimulator.so.Rel15 RUN ldd /usr/local/lib/liboai_usrpdevif.so.Rel15 RUN ldd /usr/local/lib/libcoding.so diff --git a/docker/Dockerfile.nrUE.ubuntu18 b/docker/Dockerfile.nrUE.ubuntu18 index 126f268e00..9f68b947cd 100644 --- a/docker/Dockerfile.nrUE.ubuntu18 +++ b/docker/Dockerfile.nrUE.ubuntu18 @@ -29,7 +29,8 @@ FROM ran-base:latest AS nr-ue-base FROM ran-build:latest AS nr-ue-build -RUN cp /oai-ran/docker/scripts/nr_ue_entrypoint.sh /oai-ran/docker/scripts/entrypoint.sh +RUN python3 ./docker/scripts/generateTemplate.py ./docker/scripts/nr_ue_parameters.yaml && \ + cp /oai-ran/docker/scripts/nr_ue_entrypoint.sh /oai-ran/docker/scripts/entrypoint.sh #start from scratch for target executable FROM ubuntu:bionic as oai-nr-ue @@ -67,11 +68,13 @@ COPY --from=nr-ue-build \ ./ WORKDIR /opt/oai-nr-ue/etc -COPY --from=nr-ue-build /oai-ran/ci-scripts/conf_files/nr-ue-sim.conf . +COPY --from=nr-ue-build \ + /oai-ran/ci-scripts/conf_files/nr-ue-sim.conf \ + /oai-ran/docker/etc/nr-ue.nfapi.conf \ + ./ COPY --from=nr-ue-build \ /oai-ran/cmake_targets/ran_build/build/liboai_eth_transpro.so \ - /oai-ran/cmake_targets/ran_build/build/libtcp_bridge_oai.so \ /oai-ran/cmake_targets/ran_build/build/librfsimulator.so \ /oai-ran/cmake_targets/ran_build/build/liboai_usrpdevif.so \ /oai-ran/cmake_targets/ran_build/build/libcoding.so \ @@ -89,7 +92,7 @@ COPY --from=nr-ue-build \ COPY --from=nr-ue-base /usr/local/bin/uhd_find_devices /usr/local/bin COPY --from=nr-ue-base \ /usr/local/lib/libuhd.so.3.15.0 \ - /usr/local/lib/libprotobuf-c.so.1 \ + /usr/lib/x86_64-linux-gnu/libprotobuf-c.so.1 \ /usr/local/lib/ COPY --from=nr-ue-base /usr/local/lib/uhd/utils/uhd_images_downloader.py /opt/oai-nr-ue/bin @@ -107,5 +110,5 @@ RUN /bin/bash -c "ln -s /usr/local/lib/liboai_usrpdevif.so /usr/local/lib/liboai ldconfig WORKDIR /opt/oai-nr-ue -CMD ["/opt/oai-nr-ue/bin/nr-uesoftmodem.Rel15", "-O", "/opt/oai-nr-ue/etc/nr-ue-sim.conf"] +CMD ["/opt/oai-nr-ue/bin/nr-uesoftmodem.Rel15", "-O", "/opt/oai-nr-ue/etc/nr-ue.conf"] ENTRYPOINT ["/opt/oai-nr-ue/bin/entrypoint.sh"] diff --git a/docker/scripts/generateTemplate.py b/docker/scripts/generateTemplate.py index 297c202a03..850bb535a5 100644 --- a/docker/scripts/generateTemplate.py +++ b/docker/scripts/generateTemplate.py @@ -23,6 +23,7 @@ #----------------------------------------------------------- # Import #----------------------------------------------------------- +import glob import re import yaml import os @@ -33,7 +34,8 @@ def main(): #read yaml input parameters f = open(f'{sys.argv[1]}',) data = yaml.full_load(f) - dir = os.listdir(f'{data[0]["paths"]["source_dir"]}') + initial_path = f'{data[0]["paths"]["source_dir"]}' + dir = glob.glob(initial_path + '/**/*.conf', recursive=True) #identify configs, read and replace corresponding values for config in data[1]["configurations"]: @@ -42,7 +44,10 @@ def main(): print('================================================') print('filePrefix = ' + filePrefix) print('outputfilename = ' + outputfilename) + found = False for inputfile in dir: + if found: + continue if inputfile.find(filePrefix) >=0: prefix_outputfile = {"cu.band7.tm1.25PRB": f'{data[0]["paths"]["dest_dir"]}/{outputfilename}', "du.band7.tm1.25PRB": f'{data[0]["paths"]["dest_dir"]}/{outputfilename}', @@ -58,10 +63,13 @@ def main(): "gnb.sa.band66.fr1.106PRB.usrpn300.conf": f'{data[0]["paths"]["dest_dir"]}/{outputfilename}', "gNB_SA_CU.conf": f'{data[0]["paths"]["dest_dir"]}/{outputfilename}', "gNB_SA_DU.conf": f'{data[0]["paths"]["dest_dir"]}/{outputfilename}', + "proxy_gnb.band78.sa.fr1.106PRB.usrpn310.conf": f'{data[0]["paths"]["dest_dir"]}/{outputfilename}', + "proxy_nr-ue.nfapi.conf": f'{data[0]["paths"]["dest_dir"]}/{outputfilename}', "ue.nfapi": f'{data[0]["paths"]["dest_dir"]}/{outputfilename}', "ue_sim_ci": f'{data[0]["paths"]["dest_dir"]}/{outputfilename}' } print('inputfile = ' + inputfile) + found = True if filePrefix in prefix_outputfile: outputfile1 = prefix_outputfile[filePrefix] @@ -69,7 +77,7 @@ def main(): if not os.path.exists(directory): os.makedirs(directory, exist_ok=True) - with open(f'{data[0]["paths"]["source_dir"]}{inputfile}', mode='r') as inputfile, \ + with open(f'{inputfile}', mode='r') as inputfile, \ open(outputfile1, mode='w') as outputfile: for line in inputfile: count = 0 diff --git a/docker/scripts/gnb_entrypoint.sh b/docker/scripts/gnb_entrypoint.sh index aec5c48050..dd6256609c 100755 --- a/docker/scripts/gnb_entrypoint.sh +++ b/docker/scripts/gnb_entrypoint.sh @@ -11,8 +11,9 @@ THREAD_PARALLEL_CONFIG=${THREAD_PARALLEL_CONFIG:-PARALLEL_SINGLE_THREAD} if [[ -v USE_NSA_TDD_MONO ]]; then cp $PREFIX/etc/gnb.nsa.tdd.conf $PREFIX/etc/gnb.conf; fi if [[ -v USE_SA_TDD_MONO ]]; then cp $PREFIX/etc/gnb.sa.tdd.conf $PREFIX/etc/gnb.conf; fi if [[ -v USE_SA_FDD_MONO ]]; then cp $PREFIX/etc/gnb.sa.fdd.conf $PREFIX/etc/gnb.conf; fi -if [[ -v USE_SA_CU ]]; then ln -s $PREFIX/etc/gnb.sa.cu.conf $PREFIX/etc/gnb.conf; fi +if [[ -v USE_SA_CU ]]; then cp $PREFIX/etc/gnb.sa.cu.conf $PREFIX/etc/gnb.conf; fi if [[ -v USE_SA_TDD_CU ]]; then cp $PREFIX/etc/gnb.sa.du.tdd.conf $PREFIX/etc/gnb.conf; fi +if [[ -v USE_SA_NFAPI_VNF ]]; then cp $PREFIX/etc/gnb.sa.nfapi.vnf.conf $PREFIX/etc/gnb.conf; fi # Sometimes, the templates are not enough. We mount a conf file on $PREFIX/etc. It can be a template itself. if [[ -v USE_VOLUMED_CONF ]]; then cp $PREFIX/etc/mounted.conf $PREFIX/etc/gnb.conf; fi diff --git a/docker/scripts/gnb_parameters.yaml b/docker/scripts/gnb_parameters.yaml index 8547d48e67..d5942f2c9b 100644 --- a/docker/scripts/gnb_parameters.yaml +++ b/docker/scripts/gnb_parameters.yaml @@ -202,3 +202,39 @@ - key: remote_n_portd env: "@F1_CU_D_PORT@" + - filePrefix: proxy_gnb.band78.sa.fr1.106PRB.usrpn310.conf + outputfilename: "gnb.sa.nfapi.vnf.conf" + config: + - key: Active_gNBs + env: "@GNB_NAME@" + - key: gNB_name + env: "@GNB_NAME@" + - key: mcc + env: "@MCC@" + - key: mnc + env: "@MNC@" + - key: mnc_length + env: "@MNC_LENGTH@" + - key: tracking_area_code + env: "@TAC@" + - key: sst + env: "@NSSAI_SST@" + - key: ipv4 + env: "@AMF_IP_ADDRESS@" + - key: GNB_INTERFACE_NAME_FOR_NG_AMF + env: "@GNB_NGA_IF_NAME@" + - key: GNB_IPV4_ADDRESS_FOR_NG_AMF + env: "@GNB_NGA_IP_ADDRESS@" + - key: GNB_INTERFACE_NAME_FOR_NGU + env: "@GNB_NGU_IF_NAME@" + - key: GNB_IPV4_ADDRESS_FOR_NGU + env: "@GNB_NGU_IP_ADDRESS@" + - key: parallel_config + env: "@THREAD_PARALLEL_CONFIG@" + - key: local_s_if_name + env: "@LOCAL_S_IF_NAME@" + - key: remote_s_address + env: "@REMOTE_S_ADDRESS@" + - key: local_s_address + env: "@LOCAL_S_ADDRESS@" + diff --git a/docker/scripts/nr_ue_entrypoint.sh b/docker/scripts/nr_ue_entrypoint.sh index af2b8a8333..38b080a41b 100755 --- a/docker/scripts/nr_ue_entrypoint.sh +++ b/docker/scripts/nr_ue_entrypoint.sh @@ -5,12 +5,22 @@ set -euo pipefail PREFIX=/opt/oai-nr-ue # Based another env var, pick one template to use -#if [[ -v USE_NFAPI ]]; then cp $PREFIX/etc/ue.nfapi.conf $PREFIX/etc/ue.conf; fi +if [[ -v USE_NFAPI ]]; then cp $PREFIX/etc/nr-ue.nfapi.conf $PREFIX/etc/nr-ue.conf; fi +# Sometimes, the templates are not enough. We mount a conf file on $PREFIX/etc. It can be a template itself. +if [[ -v USE_VOLUMED_CONF ]]; then cp $PREFIX/etc/mounted.conf $PREFIX/etc/nr-ue.conf; fi +# if none, pick the default +if [ ! -f $PREFIX/etc/nr-ue.conf ]; then cp $PREFIX/etc/nr-ue-sim.conf $PREFIX/etc/nr-ue.conf; fi -# Only this template will be manipulated and the USIM one! -CONFIG_FILES=`ls $PREFIX/etc/ue.conf $PREFIX/etc/nr-ue-sim.conf || true` +# Only this template will be manipulated +CONFIG_FILES=`ls $PREFIX/etc/nr-ue.conf || true` for c in ${CONFIG_FILES}; do + # Sometimes templates have no pattern to be replaced. + if ! grep -oP '@[a-zA-Z0-9_]+@' ${c}; then + echo "Configuration is already set" + break + fi + # grep variable names (format: ${VAR}) from template to be rendered VARS=$(grep -oP '@[a-zA-Z0-9_]+@' ${c} | sort | uniq | xargs) diff --git a/docker/scripts/nr_ue_parameters.yaml b/docker/scripts/nr_ue_parameters.yaml new file mode 100644 index 0000000000..afdba880e1 --- /dev/null +++ b/docker/scripts/nr_ue_parameters.yaml @@ -0,0 +1,49 @@ +#/* +# * 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 +# */ + +--- +- paths: + source_dir: "ci-scripts/conf_files/" + dest_dir: docker/etc + +- configurations: + - filePrefix: proxy_nr-ue.nfapi.conf + outputfilename: "nr-ue.nfapi.conf" + config: + - key: imsi + env: "@FULL_IMSI@" + - key: key + env: "@FULL_KEY@" + - key: opc + env: "@OPC@" + - key: dnn + env: "@DNN@" + - key: nssai_sst + env: "@NSSAI_SST@" + - key: nssai_sd + env: "@NSSAI_SD@" + - key: remote_n_address + env: "@GNB_IP_ADDRESS@" + - key: local_n_address + env: "@NR_UE_IP_ADDRESS@" + - key: local_n_if_name + env: "@NR_UE_NFAPI_IF_NAME@" + diff --git a/executables/main-ocp.c b/executables/main-ocp.c index c9388e179d..5d949d5a28 100644 --- a/executables/main-ocp.c +++ b/executables/main-ocp.c @@ -173,7 +173,7 @@ void init_transport(PHY_VARS_eNB *eNB) { } for (int i=0; iulsch[1+i] = new_eNB_ulsch(MAX_TURBO_ITERATIONS,fp->N_RB_UL, 0)) != NULL, "Can't get eNB ulsch structures\n"); // this is the transmission mode for the signalling channels diff --git a/executables/nr-gnb.c b/executables/nr-gnb.c index 2cd7ab9413..b51e5b9098 100644 --- a/executables/nr-gnb.c +++ b/executables/nr-gnb.c @@ -63,7 +63,7 @@ #include "PHY/phy_extern.h" -#include "LAYER2/NR_MAC_COMMON/nr_mac_extern.h" +#include "common/ran_context.h" #include "RRC/LTE/rrc_extern.h" #include "PHY_INTERFACE/phy_interface.h" #include "common/utils/LOG/log_extern.h" @@ -75,7 +75,6 @@ #include "enb_config.h" #include "gnb_paramdef.h" - #include "s1ap_eNB.h" #include "SIMULATION/ETH_TRANSPORT/proto.h" #include @@ -129,7 +128,6 @@ void rx_func(void *param) { int slot_rx = info->slot_rx; int frame_tx = info->frame_tx; int slot_tx = info->slot_tx; - sl_ahead = sf_ahead*gNB->frame_parms.slots_per_subframe; nfapi_nr_config_request_scf_t *cfg = &gNB->gNB_config; start_meas(&softmodem_stats_rxtx_sf); @@ -177,15 +175,14 @@ void rx_func(void *param) { void clean_gNB_dlsch(NR_gNB_DLSCH_t *dlsch); int j; for (j = 0; j < NUMBER_OF_NR_ULSCH_MAX; j++) - if (gNB->ulsch[j][0]->rnti == rnti_to_remove[i]) { - gNB->ulsch[j][0]->rnti = 0; - gNB->ulsch[j][0]->harq_mask = 0; - //clean_gNB_ulsch(gNB->ulsch[j][0]); + if (gNB->ulsch[j]->rnti == rnti_to_remove[i]) { + gNB->ulsch[j]->rnti = 0; + gNB->ulsch[j]->harq_mask = 0; int h; for (h = 0; h < NR_MAX_ULSCH_HARQ_PROCESSES; h++) { - gNB->ulsch[j][0]->harq_processes[h]->status = SCH_IDLE; - gNB->ulsch[j][0]->harq_processes[h]->round = 0; - gNB->ulsch[j][0]->harq_processes[h]->handled = 0; + gNB->ulsch[j]->harq_processes[h]->status = SCH_IDLE; + gNB->ulsch[j]->harq_processes[h]->round = 0; + gNB->ulsch[j]->harq_processes[h]->handled = 0; } up_removed++; } @@ -210,7 +207,6 @@ void rx_func(void *param) { if (pthread_mutex_unlock(&rnti_to_remove_mutex)) exit(1); // RX processing - int tx_slot_type = nr_slot_select(cfg,frame_tx,slot_tx); int rx_slot_type = nr_slot_select(cfg,frame_rx,slot_rx); if (rx_slot_type == NR_UPLINK_SLOT || rx_slot_type == NR_MIXED_SLOT) { // UE-specific RX processing for subframe n @@ -244,7 +240,8 @@ void rx_func(void *param) { gNB->if_inst->NR_UL_indication(&gNB->UL_INFO); pthread_mutex_unlock(&gNB->UL_INFO_mutex); stop_meas(&gNB->ul_indication_stats); - + + int tx_slot_type = nr_slot_select(cfg,frame_rx,slot_tx); if (tx_slot_type == NR_DOWNLINK_SLOT || tx_slot_type == NR_MIXED_SLOT) { notifiedFIFO_elt_t *res; processingData_L1tx_t *syncMsg; @@ -256,8 +253,17 @@ void rx_func(void *param) { syncMsg->timestamp_tx = info->timestamp_tx; res->key = slot_tx; pushTpool(gNB->threadPool, res); + } else if (get_softmodem_params()->continuous_tx) { + notifiedFIFO_elt_t *res = pullTpool(gNB->L1_tx_free, gNB->threadPool); + processingData_L1tx_t *syncMsg = (processingData_L1tx_t *)NotifiedFifoData(res); + syncMsg->gNB = gNB; + syncMsg->timestamp_tx = info->timestamp_tx; + syncMsg->frame = frame_tx; + syncMsg->slot = slot_tx; + res->key = slot_tx; + pushNotifiedFIFO(gNB->L1_tx_out, res); } - + #if 0 LOG_D(PHY, "rxtx:%lld nfapi:%lld phy:%lld tx:%lld rx:%lld prach:%lld ofdm:%lld ", softmodem_stats_rxtx_sf.diff_now, nfapi_meas.diff_now, @@ -298,32 +304,36 @@ void rx_func(void *param) { ); #endif } -static void dump_L1_meas_stats(PHY_VARS_gNB *gNB, RU_t *ru, char *output) { - int stroff = 0; - stroff += print_meas_log(&gNB->phy_proc_tx, "L1 Tx processing", NULL, NULL, output); - stroff += print_meas_log(&gNB->dlsch_encoding_stats, "DLSCH encoding", NULL, NULL, output+stroff); - stroff += print_meas_log(&gNB->phy_proc_rx, "L1 Rx processing", NULL, NULL, output+stroff); - stroff += print_meas_log(&gNB->ul_indication_stats, "UL Indication", NULL, NULL, output+stroff); - stroff += print_meas_log(&gNB->rx_pusch_stats, "PUSCH inner-receiver", NULL, NULL, output+stroff); - stroff += print_meas_log(&gNB->ulsch_decoding_stats, "PUSCH decoding", NULL, NULL, output+stroff); - stroff += print_meas_log(&gNB->schedule_response_stats, "Schedule Response",NULL,NULL, output+stroff); - if (ru->feprx) stroff += print_meas_log(&ru->ofdm_demod_stats,"feprx",NULL,NULL, output+stroff); +static size_t dump_L1_meas_stats(PHY_VARS_gNB *gNB, RU_t *ru, char *output, size_t outputlen) { + const char *begin = output; + const char *end = output + outputlen; + output += print_meas_log(&gNB->phy_proc_tx, "L1 Tx processing", NULL, NULL, output, end - output); + output += print_meas_log(&gNB->dlsch_encoding_stats, "DLSCH encoding", NULL, NULL, output, end - output); + output += print_meas_log(&gNB->phy_proc_rx, "L1 Rx processing", NULL, NULL, output, end - output); + output += print_meas_log(&gNB->ul_indication_stats, "UL Indication", NULL, NULL, output, end - output); + output += print_meas_log(&gNB->rx_pusch_stats, "PUSCH inner-receiver", NULL, NULL, output, end - output); + output += print_meas_log(&gNB->ulsch_decoding_stats, "PUSCH decoding", NULL, NULL, output, end - output); + output += print_meas_log(&gNB->schedule_response_stats, "Schedule Response", NULL, NULL, output, end - output); + if (ru->feprx) + output += print_meas_log(&ru->ofdm_demod_stats, "feprx", NULL, NULL, output, end - output); if (ru->feptx_ofdm) { - stroff += print_meas_log(&ru->precoding_stats,"feptx_prec",NULL,NULL, output+stroff); - stroff += print_meas_log(&ru->txdataF_copy_stats,"txdataF_copy",NULL,NULL, output+stroff); - stroff += print_meas_log(&ru->ofdm_mod_stats,"feptx_ofdm",NULL,NULL, output+stroff); - stroff += print_meas_log(&ru->ofdm_total_stats,"feptx_total",NULL,NULL, output+stroff); + output += print_meas_log(&ru->precoding_stats,"feptx_prec",NULL,NULL, output, end - output); + output += print_meas_log(&ru->txdataF_copy_stats,"txdataF_copy",NULL,NULL, output, end - output); + output += print_meas_log(&ru->ofdm_mod_stats,"feptx_ofdm",NULL,NULL, output, end - output); + output += print_meas_log(&ru->ofdm_total_stats,"feptx_total",NULL,NULL, output, end - output); } - if (ru->fh_north_asynch_in) stroff += print_meas_log(&ru->rx_fhaul,"rx_fhaul",NULL,NULL, output+stroff); + if (ru->fh_north_asynch_in) + output += print_meas_log(&ru->rx_fhaul,"rx_fhaul",NULL,NULL, output, end - output); - stroff += print_meas_log(&ru->tx_fhaul,"tx_fhaul",NULL,NULL, output+stroff); + output += print_meas_log(&ru->tx_fhaul,"tx_fhaul",NULL,NULL, output, end - output); if (ru->fh_north_out) { - stroff += print_meas_log(&ru->compression,"compression",NULL,NULL, output+stroff); - stroff += print_meas_log(&ru->transport,"transport",NULL,NULL, output+stroff); + output += print_meas_log(&ru->compression,"compression",NULL,NULL, output, end - output); + output += print_meas_log(&ru->transport,"transport",NULL,NULL, output, end - output); } + return output - begin; } void *nrL1_stats_thread(void *param) { @@ -349,7 +359,7 @@ void *nrL1_stats_thread(void *param) { dump_nr_I0_stats(fd,gNB); dump_pdsch_stats(fd,gNB); dump_pusch_stats(fd,gNB); - dump_L1_meas_stats(gNB, ru, output); + dump_L1_meas_stats(gNB, ru, output, L1STATSSTRLEN); fprintf(fd,"%s\n",output); fflush(fd); fseek(fd,0,SEEK_SET); @@ -374,7 +384,7 @@ void *tx_reorder_thread(void* param) { if (resL1Reserve) { resL1=resL1Reserve; if (((processingData_L1tx_t *)NotifiedFifoData(resL1))->slot != next_tx_slot) { - LOG_E(PHY,"order mistake"); + LOG_E(PHY,"order mistake\n"); resL1Reserve=NULL; resL1 = pullTpool(gNB->L1_tx_out, gNB->threadPool); } @@ -395,7 +405,11 @@ void *tx_reorder_thread(void* param) { syncMsgRU.slot_tx = syncMsgL1->slot; syncMsgRU.timestamp_tx = syncMsgL1->timestamp_tx; syncMsgRU.ru = gNB->RU_list[0]; - next_tx_slot = get_next_downlink_slot(gNB, &gNB->gNB_config, syncMsgRU.frame_tx, syncMsgRU.slot_tx); + if (get_softmodem_params()->continuous_tx) { + int slots_per_frame = gNB->frame_parms.slots_per_frame; + next_tx_slot = (syncMsgRU.slot_tx + 1) % slots_per_frame; + } else + next_tx_slot = get_next_downlink_slot(gNB, &gNB->gNB_config, syncMsgRU.frame_tx, syncMsgRU.slot_tx); pushNotifiedFIFO(gNB->L1_tx_free, resL1); if (resL1==resL1Reserve) resL1Reserve=NULL; @@ -446,6 +460,7 @@ void init_gNB_Tpool(int inst) { for (int i=0; i < 2; i++) { notifiedFIFO_elt_t *msgL1Tx = newNotifiedFIFO_elt(sizeof(processingData_L1tx_t),0,gNB->L1_tx_out,tx_func); processingData_L1tx_t *msgDataTx = (processingData_L1tx_t *)NotifiedFifoData(msgL1Tx); + memset(msgDataTx,0, sizeof(processingData_L1tx_t)); init_DLSCH_struct(gNB, msgDataTx); memset(msgDataTx->ssb, 0, 64*sizeof(NR_gNB_SSB_t)); pushNotifiedFIFO(gNB->L1_tx_free,msgL1Tx); // to unblock the process in the beginning @@ -506,8 +521,10 @@ void init_eNB_afterRU(void) { RC.nb_nr_inst = 1; for (inst=0; instldpc_offload_flag = ldpc_offload_flag; + phy_init_nr_gNB(gNB,0,0); // map antennas and PRACH signals to gNB RX @@ -589,7 +606,8 @@ void init_gNB(int single_thread_flag,int wait_for_sync) { gNB->UL_INFO.cqi_ind.cqi_raw_pdu_list = gNB->cqi_raw_pdu_list;*/ gNB->prach_energy_counter = 0; - gNB->prb_interpolation = get_softmodem_params()->prb_interpolation; + gNB->chest_time = get_softmodem_params()->chest_time; + gNB->chest_freq = get_softmodem_params()->chest_freq; } diff --git a/executables/nr-ru.c b/executables/nr-ru.c index 08decf0f67..ad018b17ab 100644 --- a/executables/nr-ru.c +++ b/executables/nr-ru.c @@ -99,9 +99,6 @@ int attach_rru(RU_t *ru); int connect_rau(RU_t *ru); static void NRRCconfig_RU(void); -uint16_t sf_ahead; -uint16_t slot_ahead; -uint16_t sl_ahead; extern int emulate_rf; extern int numerology; @@ -372,8 +369,8 @@ void fh_if4p5_south_in(RU_t *ru, proc->frame_rx = f; proc->timestamp_rx = (proc->frame_rx * fp->samples_per_subframe * 10) + fp->get_samples_slot_timestamp(proc->tti_rx, fp, 0); // proc->timestamp_tx = proc->timestamp_rx + (4*fp->samples_per_subframe); - proc->tti_tx = (sl+(fp->slots_per_subframe*sf_ahead))%fp->slots_per_frame; - proc->frame_tx = (sl>(fp->slots_per_frame-1-(fp->slots_per_subframe*sf_ahead))) ? (f+1)&1023 : f; + proc->tti_tx = (sl+ru->sl_ahead)%fp->slots_per_frame; + proc->frame_tx = (sl>(fp->slots_per_frame-1-(ru->sl_ahead))) ? (f+1)&1023 : f; if (proc->first_rx == 0) { if (proc->tti_rx != *slot) { @@ -703,46 +700,60 @@ void tx_rf(RU_t *ru,int frame,int slot, uint64_t timestamp) { nfapi_nr_config_request_scf_t *cfg = &ru->config; void *txp[ru->nb_tx]; unsigned int txs; - int i,txsymb=fp->symbols_per_slot; + int i; T(T_ENB_PHY_OUTPUT_SIGNAL, T_INT(0), T_INT(0), T_INT(frame), T_INT(slot), T_INT(0), T_BUFFER(&ru->common.txdata[0][fp->get_samples_slot_timestamp(slot,fp,0)], fp->samples_per_subframe * 4)); - int slot_type = nr_slot_select(cfg,frame,slot%fp->slots_per_frame); - int prevslot_type = nr_slot_select(cfg,frame,(slot+(fp->slots_per_frame-1))%fp->slots_per_frame); - int nextslot_type = nr_slot_select(cfg,frame,(slot+1)%fp->slots_per_frame); int sf_extension = 0; int siglen=fp->get_samples_per_slot(slot,fp); - int flags=1; + int flags = 0; - //nr_subframe_t SF_type = nr_slot_select(cfg,slot%fp->slots_per_frame); - if (slot_type == NR_DOWNLINK_SLOT || slot_type == NR_MIXED_SLOT || IS_SOFTMODEM_RFSIM) { - if (cfg->cell_config.frame_duplex_type.value == TDD) { - if(slot_type == NR_MIXED_SLOT) { - txsymb = 0; + if (cfg->cell_config.frame_duplex_type.value == TDD && !get_softmodem_params()->continuous_tx) { + int slot_type = nr_slot_select(cfg,frame,slot%fp->slots_per_frame); + if(slot_type == NR_MIXED_SLOT) { + int txsymb = 0; - for(int symbol_count = 0; symbol_counttdd_table.max_tdd_periodicity_list[slot].max_num_of_symbol_per_slot_list[symbol_count].slot_config.value == 0) - txsymb++; - } + for(int symbol_count = 0; symbol_counttdd_table.max_tdd_periodicity_list[slot].max_num_of_symbol_per_slot_list[symbol_count].slot_config.value == 0) + txsymb++; + } - AssertFatal(txsymb>0,"illegal txsymb %d\n",txsymb); + AssertFatal(txsymb>0,"illegal txsymb %d\n",txsymb); + if (fp->slots_per_subframe == 1) { + if (txsymb <= 7) + siglen = (fp->ofdm_symbol_size + fp->nb_prefix_samples0) + (txsymb - 1) * (fp->ofdm_symbol_size + fp->nb_prefix_samples); + else + siglen = 2 * (fp->ofdm_symbol_size + fp->nb_prefix_samples0) + (txsymb - 2) * (fp->ofdm_symbol_size + fp->nb_prefix_samples); + } else { if(slot%(fp->slots_per_subframe/2)) siglen = txsymb * (fp->ofdm_symbol_size + fp->nb_prefix_samples); else siglen = (fp->ofdm_symbol_size + fp->nb_prefix_samples0) + (txsymb - 1) * (fp->ofdm_symbol_size + fp->nb_prefix_samples); - - //+ ru->end_of_burst_delay; - flags = 3; // end of burst } - if (slot_type == NR_DOWNLINK_SLOT && prevslot_type == NR_UPLINK_SLOT) { + //+ ru->end_of_burst_delay; + flags = 3; // end of burst + } else if (slot_type == NR_DOWNLINK_SLOT) { + int prevslot_type = nr_slot_select(cfg,frame,(slot+(fp->slots_per_frame-1))%fp->slots_per_frame); + int nextslot_type = nr_slot_select(cfg,frame,(slot+1)%fp->slots_per_frame); + if (prevslot_type == NR_UPLINK_SLOT) { flags = 2; // start of burst sf_extension = ru->sf_extension; - } - if (slot_type == NR_DOWNLINK_SLOT && nextslot_type == NR_UPLINK_SLOT) + } else if (nextslot_type == NR_UPLINK_SLOT) { flags = 3; // end of burst + } else { + flags = 1; // middle of burst + } } + } else { // FDD + if (proc->first_tx == 1) { + flags = 2; // start of burst + } else { + flags = 1; // middle of burst + } + } + if (flags) { if (fp->freq_range==nr_FR2) { // the beam index is written in bits 8-10 of the flags // bit 11 enables the gpio programming @@ -1045,11 +1056,12 @@ void fill_rf_config(RU_t *ru, char *rf_config_file) { cfg->tx_gain[i] = ru->att_tx; cfg->rx_gain[i] = ru->max_rxgain-ru->att_rx; cfg->configFilename = rf_config_file; - LOG_I(PHY, "Channel %d: setting tx_gain offset %f, rx_gain offset %f, tx_freq %lu Hz, rx_freq %lu Hz\n", + LOG_I(PHY, "Channel %d: setting tx_gain offset %.0f, rx_gain offset %.0f, tx_freq %.0f Hz, rx_freq %.0f Hz, tune_offset %.0f Hz\n", i, cfg->tx_gain[i], cfg->rx_gain[i], - (unsigned long)cfg->tx_freq[i], - (unsigned long)cfg->rx_freq[i]); + cfg->tx_freq[i], + cfg->rx_freq[i], + cfg->tune_offset); } } @@ -1293,8 +1305,7 @@ void *ru_thread( void *param ) { } } - sf_ahead = (uint16_t) ceil((float)6/(0x01<numerology_index)); - LOG_I(PHY, "Signaling main thread that RU %d is ready, sf_ahead %d\n",ru->idx,sf_ahead); + LOG_I(PHY, "Signaling main thread that RU %d is ready, sl_ahead %d\n",ru->idx,ru->sl_ahead); pthread_mutex_lock(&RC.ru_mutex); RC.ru_mask &= ~(1<idx); pthread_cond_signal(&RC.ru_cond); @@ -1312,6 +1323,7 @@ void *ru_thread( void *param ) { else LOG_I(PHY,"RU %d rf device ready\n",ru->idx); } else LOG_I(PHY,"RU %d no rf device\n",ru->idx); + LOG_I(PHY,"RU %d RF started\n",ru->idx); // start trx write thread if(usrp_tx_thread == 1) { if (ru->start_write_thread) { @@ -1379,9 +1391,12 @@ void *ru_thread( void *param ) { opp_enabled = opp_enabled0; } if (initial_wait == 0 && ru->rx_fhaul.trials > 1000) reset_meas(&ru->rx_fhaul); - proc->timestamp_tx = proc->timestamp_rx + (sf_ahead*fp->samples_per_subframe); - proc->frame_tx = (proc->tti_rx > (fp->slots_per_frame-1-(fp->slots_per_subframe*sf_ahead))) ? (proc->frame_rx+1)&1023 : proc->frame_rx; - proc->tti_tx = (proc->tti_rx + (fp->slots_per_subframe*sf_ahead))%fp->slots_per_frame; + proc->timestamp_tx = proc->timestamp_rx; + int sl=proc->tti_tx; + for (int slidx=0;slidxsl_ahead;slidx++) + proc->timestamp_tx += fp->get_samples_per_slot((sl+slidx)%fp->slots_per_frame,fp); + proc->frame_tx = (proc->tti_rx > (fp->slots_per_frame-1-(ru->sl_ahead))) ? (proc->frame_rx+1)&1023 : proc->frame_rx; + proc->tti_tx = (proc->tti_rx + ru->sl_ahead)%fp->slots_per_frame; LOG_D(PHY,"AFTER fh_south_in - SFN/SL:%d%d RU->proc[RX:%d.%d TX:%d.%d] RC.gNB[0]:[RX:%d%d TX(SFN):%d]\n", frame,slot, proc->frame_rx,proc->tti_rx, @@ -1412,7 +1427,6 @@ void *ru_thread( void *param ) { // Do PRACH RU processing int prach_id=find_nr_prach_ru(ru,proc->frame_rx,proc->tti_rx,SEARCH_EXIST); uint8_t prachStartSymbol,N_dur; - if (prach_id>=0) { T(T_GNB_PHY_PRACH_INPUT_SIGNAL, T_INT(proc->frame_rx), T_INT(proc->tti_rx), T_INT(0), T_BUFFER(&ru->common.rxdata[0][fp->get_samples_slot_timestamp(proc->tti_rx-1,fp,0)]/*-ru->N_TA_offset*/, fp->get_samples_per_slot(proc->tti_rx,fp)*4*2)); @@ -2045,6 +2059,8 @@ static void NRRCconfig_RU(void) { RC.ru[j]->openair0_cfg.time_source = internal; } + RC.ru[j]->openair0_cfg.tune_offset = get_softmodem_params()->tune_offset; + if (strcmp(*(RUParamList.paramarray[j][RU_LOCAL_RF_IDX].strptr), "yes") == 0) { if ( !(config_isparamset(RUParamList.paramarray[j],RU_LOCAL_IF_NAME_IDX)) ) { RC.ru[j]->if_south = LOCAL_RF; @@ -2084,9 +2100,7 @@ static void NRRCconfig_RU(void) { RC.ru[j]->max_pdschReferenceSignalPower = *(RUParamList.paramarray[j][RU_MAX_RS_EPRE_IDX].uptr);; RC.ru[j]->max_rxgain = *(RUParamList.paramarray[j][RU_MAX_RXGAIN_IDX].uptr); - RC.ru[j]->num_bands = RUParamList.paramarray[j][RU_BAND_LIST_IDX].numelt; RC.ru[j]->sf_extension = *(RUParamList.paramarray[j][RU_SF_EXTENSION_IDX].uptr); - for (i=0; inum_bands; i++) RC.ru[j]->band[i] = RUParamList.paramarray[j][RU_BAND_LIST_IDX].iptr[i]; } //strcmp(local_rf, "yes") == 0 else { printf("RU %d: Transport %s\n",j,*(RUParamList.paramarray[j][RU_TRANSPORT_PREFERENCE_IDX].strptr)); @@ -2106,8 +2120,6 @@ static void NRRCconfig_RU(void) { RC.ru[j]->if_south = REMOTE_IF5; RC.ru[j]->function = NGFI_RAU_IF5; RC.ru[j]->eth_params.transp_preference = ETH_UDP_IF5_ECPRI_MODE; - } else if (strcmp(*(RUParamList.paramarray[j][RU_TRANSPORT_PREFERENCE_IDX].strptr), "udp_ecpri_if5") == 0) { - RC.ru[j]->if_south = REMOTE_IF5; } else if (strcmp(*(RUParamList.paramarray[j][RU_TRANSPORT_PREFERENCE_IDX].strptr), "raw") == 0) { RC.ru[j]->if_south = REMOTE_IF5; RC.ru[j]->function = NGFI_RAU_IF5; @@ -2130,7 +2142,13 @@ static void NRRCconfig_RU(void) { RC.ru[j]->if_frequency = *(RUParamList.paramarray[j][RU_IF_FREQUENCY].u64ptr); RC.ru[j]->if_freq_offset = *(RUParamList.paramarray[j][RU_IF_FREQ_OFFSET].iptr); RC.ru[j]->do_precoding = *(RUParamList.paramarray[j][RU_DO_PRECODING].iptr); - + RC.ru[j]->sl_ahead = *(RUParamList.paramarray[j][RU_SL_AHEAD].iptr); + RC.ru[j]->num_bands = RUParamList.paramarray[j][RU_BAND_LIST_IDX].numelt; + for (i=0; inum_bands; i++) RC.ru[j]->band[i] = RUParamList.paramarray[j][RU_BAND_LIST_IDX].iptr[i]; + RC.ru[j]->openair0_cfg.nr_flag = *(RUParamList.paramarray[j][RU_NR_FLAG].iptr); + RC.ru[j]->openair0_cfg.nr_band = RC.ru[j]->band[0]; + RC.ru[j]->openair0_cfg.nr_scs_for_raster = *(RUParamList.paramarray[j][RU_NR_SCS_FOR_RASTER].iptr); + printf("[RU %d] Setting nr_flag %d, nr_band %d, nr_scs_for_raster %d\n",j,RC.ru[j]->openair0_cfg.nr_flag,RC.ru[j]->openair0_cfg.nr_band,RC.ru[j]->openair0_cfg.nr_scs_for_raster); if (config_isparamset(RUParamList.paramarray[j], RU_BF_WEIGHTS_LIST_IDX)) { RC.ru[j]->nb_bfw = RUParamList.paramarray[j][RU_BF_WEIGHTS_LIST_IDX].numelt; diff --git a/executables/nr-softmodem-common.h b/executables/nr-softmodem-common.h index ac6f81ad15..840c57c394 100644 --- a/executables/nr-softmodem-common.h +++ b/executables/nr-softmodem-common.h @@ -51,7 +51,6 @@ #define CONFIG_HLP_UEFO "set UE to enable estimation and compensation of frequency offset\n" #define CONFIG_HLP_DUMPFRAME "dump UE received frame to rxsig_frame0.dat and exit\n" #define CONFIG_HLP_DLSHIFT "dynamic shift for LLR compuation for TM3/4 (default 0)\n" -#define CONFIG_HLP_UELOOP "get softmodem (UE) to loop through memory instead of acquiring from HW\n" #define CONFIG_HLP_PHYTST "test UE phy layer, mac disabled\n" #define CONFIG_HLP_DORA "test gNB and UE with RA procedures\n" #define CONFIG_HLP_DMAMAP "sets flag for improved EXMIMO UE performance\n" @@ -67,6 +66,7 @@ #define CONFIG_HLP_ITTIL "Generate ITTI analyzser logs (similar to wireshark logs but with more details)\n" #define CONFIG_HLP_DLMCS_PHYTEST "Set the downlink MCS for PHYTEST mode\n" #define CONFIG_HLP_DLNL_PHYTEST "Set the downlink nrOfLayers for PHYTEST mode\n" +#define CONFIG_HLP_ULNL_PHYTEST "Set the uplink nrOfLayers for PHYTEST mode\n" #define CONFIG_HLP_STMON "Enable processing timing measurement of lte softmodem on per subframe basis \n" #define CONFIG_HLP_MSLOTS "Skip the missed slots/subframes \n" #define CONFIG_HLP_ULMCS_PHYTEST "Set the uplink MCS for PHYTEST mode\n" diff --git a/executables/nr-softmodem.c b/executables/nr-softmodem.c index ac5a1b0132..54345dc6b0 100644 --- a/executables/nr-softmodem.c +++ b/executables/nr-softmodem.c @@ -732,7 +732,7 @@ int main( int argc, char **argv ) { printf("wait_gNBs()\n"); wait_gNBs(); printf("About to Init RU threads RC.nb_RU:%d\n", RC.nb_RU); - + int sl_ahead=6; if (RC.nb_RU >0) { printf("Initializing RU threads\n"); init_NR_RU(get_softmodem_params()->rf_config_file); @@ -740,7 +740,10 @@ int main( int argc, char **argv ) { for (ru_id=0; ru_idrf_map.card=0; RC.ru[ru_id]->rf_map.chain=CC_id+chain_offset; + if (ru_id==0) sl_ahead = RC.ru[ru_id]->sl_ahead; + else AssertFatal(RC.ru[ru_id]->sl_ahead != RC.ru[0]->sl_ahead,"RU %d has different sl_ahead %d than RU 0 %d\n",ru_id,RC.ru[ru_id]->sl_ahead,RC.ru[0]->sl_ahead); } + } config_sync_var=0; @@ -757,6 +760,7 @@ int main( int argc, char **argv ) { // once all RUs are ready initialize the rest of the gNBs ((dependence on final RU parameters after configuration) printf("ALL RUs ready - init gNBs\n"); + for (int idx=0;idxif_inst->sl_ahead = sl_ahead; if(IS_SOFTMODEM_DOSCOPE) { sleep(1); scopeParms_t p; @@ -835,10 +839,10 @@ int main( int argc, char **argv ) { } for (int inst = 0; inst < NB_RU; inst++) { + kill_NR_RU_proc(inst); nr_phy_free_RU(RC.ru[inst]); } - free_lte_top(); pthread_cond_destroy(&sync_cond); pthread_mutex_destroy(&sync_mutex); pthread_cond_destroy(&nfapi_sync_cond); diff --git a/executables/nr-softmodem.h b/executables/nr-softmodem.h index 25351dd442..e7eda6a612 100644 --- a/executables/nr-softmodem.h +++ b/executables/nr-softmodem.h @@ -22,6 +22,7 @@ {"E" , CONFIG_HLP_TQFS, PARAMFLAG_BOOL, i8ptr:&threequarter_fs, defintval:0, TYPE_INT8, 0}, \ {"m" , CONFIG_HLP_DLMCS_PHYTEST,0, uptr:&target_dl_mcs, defintval:0, TYPE_UINT, 0}, \ {"l" , CONFIG_HLP_DLNL_PHYTEST,0, uptr:&target_dl_Nl, defintval:0, TYPE_UINT, 0}, \ + {"L" , CONFIG_HLP_ULNL_PHYTEST,0, uptr:&target_ul_Nl, defintval:0, TYPE_UINT, 0}, \ {"t" , CONFIG_HLP_ULMCS_PHYTEST,0, uptr:&target_ul_mcs, defintval:0, TYPE_UINT, 0}, \ {"M" , CONFIG_HLP_DLBW_PHYTEST,0, uptr:&target_dl_bw, defintval:0, TYPE_UINT, 0}, \ {"T" , CONFIG_HLP_ULBW_PHYTEST,0, uptr:&target_ul_bw, defintval:0, TYPE_UINT, 0}, \ @@ -37,6 +38,7 @@ extern threads_t threads; extern uint32_t target_dl_mcs; extern uint32_t target_dl_Nl; +extern uint32_t target_ul_Nl; extern uint32_t target_ul_mcs; extern uint32_t target_dl_bw; extern uint32_t target_ul_bw; diff --git a/executables/nr-ue.c b/executables/nr-ue.c index 543be7a8b5..01e6c62138 100644 --- a/executables/nr-ue.c +++ b/executables/nr-ue.c @@ -18,7 +18,8 @@ * For more information about the OpenAirInterface (OAI) Software Alliance: * contact@openairinterface.org */ -#define _GNU_SOURCE + +#define _GNU_SOURCE // For pthread_setname_np #include #include #include "executables/nr-uesoftmodem.h" @@ -105,23 +106,24 @@ queue_t nr_rach_ind_queue; static void *NRUE_phy_stub_standalone_pnf_task(void *arg); -static int dump_L1_UE_meas_stats(PHY_VARS_NR_UE *ue, char *output, int max_len) +static size_t dump_L1_UE_meas_stats(PHY_VARS_NR_UE *ue, char *output, size_t max_len) { - int stroff = 0; - stroff += print_meas_log(&ue->phy_proc_tx, "L1 TX processing", NULL, NULL, output); - stroff += print_meas_log(&ue->ulsch_encoding_stats, "ULSCH encoding", NULL, NULL, output + stroff); - stroff += print_meas_log(&ue->phy_proc_rx[0], "L1 RX processing t0", NULL, NULL, output + stroff); - stroff += print_meas_log(&ue->phy_proc_rx[1], "L1 RX processing t1", NULL, NULL, output + stroff); - stroff += print_meas_log(&ue->ue_ul_indication_stats, "UL Indication", NULL, NULL, output + stroff); - stroff += print_meas_log(&ue->rx_pdsch_stats, "PDSCH receiver", NULL, NULL, output + stroff); - stroff += print_meas_log(&ue->dlsch_decoding_stats[0], "PDSCH decoding t0", NULL, NULL, output + stroff); - stroff += print_meas_log(&ue->dlsch_decoding_stats[1], "PDSCH decoding t1", NULL, NULL, output + stroff); - stroff += print_meas_log(&ue->dlsch_deinterleaving_stats, " -> Deinterleive", NULL, NULL, output + stroff); - stroff += print_meas_log(&ue->dlsch_rate_unmatching_stats, " -> Rate Unmatch", NULL, NULL, output + stroff); - stroff += print_meas_log(&ue->dlsch_ldpc_decoding_stats, " -> LDPC Decode", NULL, NULL, output + stroff); - stroff += print_meas_log(&ue->dlsch_unscrambling_stats, "PDSCH unscrambling", NULL, NULL, output + stroff); - stroff += print_meas_log(&ue->dlsch_rx_pdcch_stats, "PDCCH handling", NULL, NULL, output + stroff); - return stroff; + const char *begin = output; + const char *end = output + max_len; + output += print_meas_log(&ue->phy_proc_tx, "L1 TX processing", NULL, NULL, output, end - output); + output += print_meas_log(&ue->ulsch_encoding_stats, "ULSCH encoding", NULL, NULL, output, end - output); + output += print_meas_log(&ue->phy_proc_rx[0], "L1 RX processing t0", NULL, NULL, output, end - output); + output += print_meas_log(&ue->phy_proc_rx[1], "L1 RX processing t1", NULL, NULL, output, end - output); + output += print_meas_log(&ue->ue_ul_indication_stats, "UL Indication", NULL, NULL, output, end - output); + output += print_meas_log(&ue->rx_pdsch_stats, "PDSCH receiver", NULL, NULL, output, end - output); + output += print_meas_log(&ue->dlsch_decoding_stats[0], "PDSCH decoding t0", NULL, NULL, output, end - output); + output += print_meas_log(&ue->dlsch_decoding_stats[1], "PDSCH decoding t1", NULL, NULL, output, end - output); + output += print_meas_log(&ue->dlsch_deinterleaving_stats, " -> Deinterleive", NULL, NULL, output, end - output); + output += print_meas_log(&ue->dlsch_rate_unmatching_stats, " -> Rate Unmatch", NULL, NULL, output, end - output); + output += print_meas_log(&ue->dlsch_ldpc_decoding_stats, " -> LDPC Decode", NULL, NULL, output, end - output); + output += print_meas_log(&ue->dlsch_unscrambling_stats, "PDSCH unscrambling", NULL, NULL, output, end - output); + output += print_meas_log(&ue->dlsch_rx_pdcch_stats, "PDCCH handling", NULL, NULL, output, end - output); + return output - begin; } static void *nrL1_UE_stats_thread(void *param) @@ -238,84 +240,21 @@ static void L1_nsa_prach_procedures(frame_t frame, int slot, fapi_nr_ul_config_p LOG_D(NR_MAC, "We have successfully filled the rach_ind queue with the recently filled rach ind\n"); } -static bool sfn_slot_matcher(void *wanted, void *candidate) -{ - nfapi_p7_message_header_t *msg = candidate; - int sfn_sf = *(int*)wanted; - - switch (msg->message_id) - { - case NFAPI_NR_PHY_MSG_TYPE_RACH_INDICATION: - { - nfapi_nr_rach_indication_t *ind = candidate; - return NFAPI_SFNSLOT2SFN(sfn_sf) == ind->sfn && NFAPI_SFNSLOT2SLOT(sfn_sf) == ind->slot; - } - - case NFAPI_NR_PHY_MSG_TYPE_RX_DATA_INDICATION: - { - nfapi_nr_rx_data_indication_t *ind = candidate; - return NFAPI_SFNSLOT2SFN(sfn_sf) == ind->sfn && NFAPI_SFNSLOT2SLOT(sfn_sf) == ind->slot; - } - - case NFAPI_NR_PHY_MSG_TYPE_CRC_INDICATION: - { - nfapi_nr_crc_indication_t *ind = candidate; - return NFAPI_SFNSLOT2SFN(sfn_sf) == ind->sfn && NFAPI_SFNSLOT2SLOT(sfn_sf) == ind->slot; - } - - case NFAPI_NR_PHY_MSG_TYPE_UCI_INDICATION: - { - nfapi_nr_uci_indication_t *ind = candidate; - return NFAPI_SFNSLOT2SFN(sfn_sf) == ind->sfn && NFAPI_SFNSLOT2SLOT(sfn_sf) == ind->slot; - } - - case NFAPI_NR_PHY_MSG_TYPE_DL_TTI_REQUEST: - { - nfapi_nr_dl_tti_request_t *ind = candidate; - return NFAPI_SFNSLOT2SFN(sfn_sf) == ind->SFN && NFAPI_SFNSLOT2SLOT(sfn_sf) == ind->Slot; - } - - case NFAPI_NR_PHY_MSG_TYPE_TX_DATA_REQUEST: - { - nfapi_nr_tx_data_request_t *ind = candidate; - return NFAPI_SFNSLOT2SFN(sfn_sf) == ind->SFN && NFAPI_SFNSLOT2SLOT(sfn_sf) == ind->Slot; - } - - case NFAPI_NR_PHY_MSG_TYPE_UL_DCI_REQUEST: - { - nfapi_nr_ul_dci_request_t *ind = candidate; - return NFAPI_SFNSLOT2SFN(sfn_sf) == ind->SFN && NFAPI_SFNSLOT2SLOT(sfn_sf) == ind->Slot; - } - - case NFAPI_NR_PHY_MSG_TYPE_UL_TTI_REQUEST: - { - nfapi_nr_ul_tti_request_t *ind = candidate; - return NFAPI_SFNSLOT2SFN(sfn_sf) == ind->SFN && NFAPI_SFNSLOT2SLOT(sfn_sf) == ind->Slot; - } - - default: - LOG_E(NR_MAC, "sfn_slot_match bad ID: %d\n", msg->message_id); - - } - - return false; -} - static void process_queued_nr_nfapi_msgs(NR_UE_MAC_INST_t *mac, int sfn_slot) { nfapi_nr_rach_indication_t *rach_ind = unqueue_matching(&nr_rach_ind_queue, MAX_QUEUE_SIZE, sfn_slot_matcher, &sfn_slot); - nfapi_nr_rx_data_indication_t *rx_ind = unqueue_matching(&nr_rx_ind_queue, MAX_QUEUE_SIZE, sfn_slot_matcher, &sfn_slot); - nfapi_nr_crc_indication_t *crc_ind = unqueue_matching(&nr_crc_ind_queue, MAX_QUEUE_SIZE, sfn_slot_matcher, &sfn_slot); nfapi_nr_dl_tti_request_t *dl_tti_request = get_queue(&nr_dl_tti_req_queue); nfapi_nr_ul_dci_request_t *ul_dci_request = get_queue(&nr_ul_dci_req_queue); - LOG_D(NR_MAC, "Try to get a ul_tti_req for sfn/slot %d %d from queue with %lu items\n", - NFAPI_SFNSLOT2SFN(mac->nr_ue_emul_l1.active_harq_sfn_slot),NFAPI_SFNSLOT2SLOT(mac->nr_ue_emul_l1.active_harq_sfn_slot), nr_ul_tti_req_queue.num_items); - nfapi_nr_ul_tti_request_t *ul_tti_request = unqueue_matching(&nr_ul_tti_req_queue, MAX_QUEUE_SIZE, sfn_slot_matcher, &mac->nr_ue_emul_l1.active_harq_sfn_slot); - if (!ul_tti_request) - { - LOG_D(NR_MAC, "Try to get a ul_tti_req from seprate queue because dl_tti_req was late\n"); - ul_tti_request = unqueue_matching(&nr_wait_ul_tti_req_queue, MAX_QUEUE_SIZE, sfn_slot_matcher, &mac->nr_ue_emul_l1.active_harq_sfn_slot); + for (int i = 0; i < NR_MAX_HARQ_PROCESSES; i++) { + LOG_D(NR_MAC, "Try to get a ul_tti_req by matching CRC active SFN %d/SLOT %d from queue with %lu items\n", + NFAPI_SFNSLOT2SFN(mac->nr_ue_emul_l1.harq[i].active_ul_harq_sfn_slot), + NFAPI_SFNSLOT2SLOT(mac->nr_ue_emul_l1.harq[i].active_ul_harq_sfn_slot), nr_ul_tti_req_queue.num_items); + nfapi_nr_ul_tti_request_t *ul_tti_request_crc = unqueue_matching(&nr_ul_tti_req_queue, MAX_QUEUE_SIZE, sfn_slot_matcher, &mac->nr_ue_emul_l1.harq[i].active_ul_harq_sfn_slot); + if (ul_tti_request_crc && ul_tti_request_crc->n_pdus > 0) + { + check_and_process_dci(NULL, NULL, NULL, ul_tti_request_crc); + } } if (rach_ind && rach_ind->number_of_pdus > 0) @@ -332,24 +271,6 @@ static void process_queued_nr_nfapi_msgs(NR_UE_MAC_INST_t *mac, int sfn_slot) free(rach_ind); nr_Msg1_transmitted(0, 0, NFAPI_SFNSLOT2SFN(sfn_slot), 0); } - if (crc_ind && crc_ind->number_crcs > 0) - { - NR_UL_IND_t UL_INFO = { - .crc_ind = *crc_ind, - }; - send_nsa_standalone_msg(&UL_INFO, crc_ind->header.message_id); - free(crc_ind->crc_list); - free(crc_ind); - } - if (rx_ind && rx_ind->number_of_pdus > 0) - { - NR_UL_IND_t UL_INFO = { - .rx_ind = *rx_ind, - }; - send_nsa_standalone_msg(&UL_INFO, rx_ind->header.message_id); - free(rx_ind->pdu_list); - free(rx_ind); - } if (dl_tti_request) { int dl_tti_sfn_slot = NFAPI_SFNSLOT2HEX(dl_tti_request->SFN, dl_tti_request->Slot); @@ -379,10 +300,6 @@ static void process_queued_nr_nfapi_msgs(NR_UE_MAC_INST_t *mac, int sfn_slot) { check_and_process_dci(NULL, NULL, ul_dci_request, NULL); } - if (ul_tti_request && ul_tti_request->n_pdus > 0) - { - check_and_process_dci(NULL, NULL, NULL, ul_tti_request); - } } static void check_nr_prach(NR_UE_MAC_INST_t *mac, nr_uplink_indication_t *ul_info, NR_PRACH_RESOURCES_t *prach_resources) @@ -433,7 +350,6 @@ static void *NRUE_phy_stub_standalone_pnf_task(void *arg) reset_queue(&nr_tx_req_queue); reset_queue(&nr_ul_dci_req_queue); reset_queue(&nr_ul_tti_req_queue); - reset_queue(&nr_wait_ul_tti_req_queue); NR_PRACH_RESOURCES_t prach_resources; memset(&prach_resources, 0, sizeof(prach_resources)); @@ -442,6 +358,13 @@ static void *NRUE_phy_stub_standalone_pnf_task(void *arg) int last_sfn_slot = -1; uint16_t sfn_slot = 0; + module_id_t mod_id = 0; + NR_UE_MAC_INST_t *mac = get_mac_inst(mod_id); + for (int i = 0; i < NR_MAX_HARQ_PROCESSES; i++) { + mac->nr_ue_emul_l1.harq[i].active = false; + mac->nr_ue_emul_l1.harq[i].active_ul_harq_sfn_slot = -1; + } + while (!oai_exit) { if (sem_wait(&sfn_slot_semaphore) != 0) @@ -458,9 +381,11 @@ static void *NRUE_phy_stub_standalone_pnf_task(void *arg) } if (slot_ind) { sfn_slot = *slot_ind; + free_and_zero(slot_ind); } else if (ch_info) { sfn_slot = ch_info->sfn_slot; + free_and_zero(ch_info); } frame_t frame = NFAPI_SFNSLOT2SFN(sfn_slot); @@ -476,8 +401,6 @@ 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); - module_id_t mod_id = 0; - NR_UE_MAC_INST_t *mac = get_mac_inst(mod_id); if (get_softmodem_params()->sa && mac->mib == NULL) { LOG_D(NR_MAC, "We haven't gotten MIB. Lets see if we received it\n"); @@ -532,8 +455,10 @@ static void *NRUE_phy_stub_standalone_pnf_task(void *arg) mac->scc_SIB->tdd_UL_DL_ConfigurationCommon, ul_info.slot_tx, mac->frame_type)) { - LOG_D(NR_MAC, "Slot %d. calling nr_ue_ul_ind() from %s\n", ul_info.slot_tx, __FUNCTION__); - nr_ue_ul_indication(&ul_info); + LOG_D(NR_MAC, "Slot %d. calling nr_ue_ul_ind() and nr_ue_pucch_scheduler() from %s\n", ul_info.slot_tx, __FUNCTION__); + nr_ue_scheduler(NULL, &ul_info); + nr_ue_prach_scheduler(mod_id, ul_info.frame_tx, ul_info.slot_tx, ul_info.thread_id); + nr_ue_pucch_scheduler(mod_id, ul_info.frame_tx, ul_info.slot_tx, ul_info.thread_id); check_nr_prach(mac, &ul_info, &prach_resources); } if (!IS_SOFTMODEM_NOS1 && get_softmodem_params()->sa) { @@ -543,10 +468,6 @@ static void *NRUE_phy_stub_standalone_pnf_task(void *arg) pdcp_run(&ctxt); } process_queued_nr_nfapi_msgs(mac, sfn_slot); - free(slot_ind); - slot_ind = NULL; - free(ch_info); - ch_info = NULL; } return NULL; } @@ -653,17 +574,7 @@ static void UE_synch(void *arg) { openair0_cfg[UE->rf_map.card].rx_freq[0], openair0_cfg[UE->rf_map.card].tx_freq[0]); - if (UE->mode != loop_through_memory) { - UE->rfdevice.trx_set_freq_func(&UE->rfdevice,&openair0_cfg[0],0); - //UE->rfdevice.trx_set_gains_func(&openair0,&openair0_cfg[0]); - //UE->rfdevice.trx_stop_func(&UE->rfdevice); - // sleep(1); - /*if (UE->rfdevice.trx_start_func(&UE->rfdevice) != 0 ) { - LOG_E(HW,"Could not start the device\n"); - oai_exit=1; - }*/ - } - + UE->rfdevice.trx_set_freq_func(&UE->rfdevice,&openair0_cfg[0],0); if (UE->UE_scan_carrier == 1) { UE->UE_scan_carrier = 0; } else { @@ -682,8 +593,7 @@ static void UE_synch(void *arg) { LOG_I(PHY, "Initial sync failed: trying carrier off %d Hz\n", freq_offset); - if (UE->mode != loop_through_memory) - UE->rfdevice.trx_set_freq_func(&UE->rfdevice,&openair0_cfg[0],0); + UE->rfdevice.trx_set_freq_func(&UE->rfdevice,&openair0_cfg[0],0); } break; @@ -704,7 +614,7 @@ void processSlotTX(void *arg) { int tx_slot_type = nr_ue_slot_select(cfg, proc->frame_tx, proc->nr_slot_tx); uint8_t gNB_id = 0; - LOG_D(PHY,"%d.%d => slot type %d\n",proc->frame_tx,proc->nr_slot_tx,tx_slot_type); + LOG_D(PHY,"processSlotTX %d.%d => slot type %d\n",proc->frame_tx,proc->nr_slot_tx,tx_slot_type); if (tx_slot_type == NR_UPLINK_SLOT || tx_slot_type == NR_MIXED_SLOT){ // trigger L2 to run ue_scheduler thru IF module @@ -728,7 +638,7 @@ void processSlotTX(void *arg) { stop_meas(&UE->ue_ul_indication_stats); } - if ((UE->mode != loop_through_memory) && (rxtxD->ue_sched_mode != NOT_PUSCH)) { + if (rxtxD->ue_sched_mode != NOT_PUSCH) { phy_procedures_nrUE_TX(UE,proc,0); } } @@ -743,6 +653,7 @@ void processSlotRX(void *arg) { int rx_slot_type = nr_ue_slot_select(cfg, proc->frame_rx, proc->nr_slot_rx); int tx_slot_type = nr_ue_slot_select(cfg, proc->frame_tx, proc->nr_slot_tx); uint8_t gNB_id = 0; + NR_UE_PDCCH_CONFIG phy_pdcch_config={0}; if (IS_SOFTMODEM_NOS1 || get_softmodem_params()->sa) { /* send tick to RLC and PDCP every ms */ @@ -758,7 +669,7 @@ void processSlotRX(void *arg) { if(UE->if_inst != NULL && UE->if_inst->dl_indication != NULL) { nr_downlink_indication_t dl_indication; - nr_fill_dl_indication(&dl_indication, NULL, NULL, proc, UE, gNB_id); + nr_fill_dl_indication(&dl_indication, NULL, NULL, proc, UE, gNB_id, &phy_pdcch_config); UE->if_inst->dl_indication(&dl_indication, NULL); } @@ -767,7 +678,7 @@ void processSlotRX(void *arg) { phy_procedures_slot_parallelization_nrUE_RX( UE, proc, 0, 0, 1, no_relay, NULL ); #else uint64_t a=rdtsc_oai(); - phy_procedures_nrUE_RX(UE, proc, gNB_id, get_nrUE_params()->nr_dlsch_parallel, &rxtxD->txFifo); + phy_procedures_nrUE_RX(UE, proc, gNB_id, get_nrUE_params()->nr_dlsch_parallel, &phy_pdcch_config, &rxtxD->txFifo); LOG_D(PHY, "In %s: slot %d, time %llu\n", __FUNCTION__, proc->nr_slot_rx, (rdtsc_oai()-a)/3500); #endif @@ -803,7 +714,8 @@ void processSlotRX(void *arg) { LOG_D(PHY, "Sending Uplink data \n"); nr_ue_pusch_common_procedures(UE, proc->nr_slot_tx, - &UE->frame_parms,1); + &UE->frame_parms, + UE->frame_parms.nb_antennas_tx); } if (UE->UE_mode[gNB_id] > NOT_SYNCHED && UE->UE_mode[gNB_id] < PUSCH) { @@ -817,9 +729,10 @@ void processSlotRX(void *arg) { void dummyWrite(PHY_VARS_NR_UE *UE,openair0_timestamp timestamp, int writeBlockSize) { void *dummy_tx[UE->frame_parms.nb_antennas_tx]; - + int16_t dummy_tx_data[UE->frame_parms.nb_antennas_tx][2*writeBlockSize]; // 2 because the function we call use pairs of int16_t implicitly as complex numbers + memset(dummy_tx_data, 0, sizeof(dummy_tx_data)); for (int i=0; iframe_parms.nb_antennas_tx; i++) - dummy_tx[i]=malloc16_clear(writeBlockSize*4); + dummy_tx[i]=dummy_tx_data[i]; AssertFatal( writeBlockSize == UE->rfdevice.trx_write_func(&UE->rfdevice, @@ -829,8 +742,6 @@ void dummyWrite(PHY_VARS_NR_UE *UE,openair0_timestamp timestamp, int writeBlockS UE->frame_parms.nb_antennas_tx, 4),""); - for (int i=0; iframe_parms.nb_antennas_tx; i++) - free(dummy_tx[i]); } void readFrame(PHY_VARS_NR_UE *UE, openair0_timestamp *timestamp, bool toTrash) { @@ -872,7 +783,7 @@ void syncInFrame(PHY_VARS_NR_UE *UE, openair0_timestamp *timestamp) { *timestamp += UE->frame_parms.get_samples_per_slot(1,&UE->frame_parms); for ( int size=UE->rx_offset ; size > 0 ; size -= UE->frame_parms.samples_per_subframe ) { int unitTransfer=size>UE->frame_parms.samples_per_subframe ? UE->frame_parms.samples_per_subframe : size ; - // we write before read becasue gNB waits for UE to write and both executions halt + // we write before read because gNB waits for UE to write and both executions halt // this happens here as the read size is samples_per_subframe which is very much larger than samp_per_slot if (IS_SOFTMODEM_RFSIM) dummyWrite(UE,*timestamp, unitTransfer); AssertFatal(unitTransfer == @@ -1125,9 +1036,8 @@ void *UE_thread(void *arg) { } int flags = 0; - int slot_tx_usrp = slot_nr + DURATION_RX_TO_TX - NR_RX_NB_TH; - if (openair0_cfg[0].duplex_mode == duplex_mode_TDD) { + if (openair0_cfg[0].duplex_mode == duplex_mode_TDD && !get_softmodem_params()->continuous_tx) { uint8_t tdd_period = mac->phy_config.config_req.tdd_table.tdd_period_in_slots; int nrofUplinkSlots, nrofUplinkSymbols; @@ -1139,8 +1049,9 @@ void *UE_thread(void *arg) { nrofUplinkSlots = mac->scc_SIB->tdd_UL_DL_ConfigurationCommon->pattern1.nrofUplinkSlots; nrofUplinkSymbols = mac->scc_SIB->tdd_UL_DL_ConfigurationCommon->pattern1.nrofUplinkSymbols; } - uint8_t num_UL_slots = nrofUplinkSlots + (nrofUplinkSymbols != 0); + int slot_tx_usrp = slot_nr + DURATION_RX_TO_TX - NR_RX_NB_TH; + uint8_t num_UL_slots = nrofUplinkSlots + (nrofUplinkSymbols != 0); uint8_t first_tx_slot = tdd_period - num_UL_slots; if (slot_tx_usrp % tdd_period == first_tx_slot) diff --git a/executables/nr-uesoftmodem.c b/executables/nr-uesoftmodem.c index c51f791588..2c3ab6b49f 100644 --- a/executables/nr-uesoftmodem.c +++ b/executables/nr-uesoftmodem.c @@ -50,6 +50,7 @@ #include "LAYER2/MAC/mac_vars.h" #include "RRC/LTE/rrc_vars.h" #include "PHY_INTERFACE/phy_interface_vars.h" +#include "NR_IF_Module.h" #include "openair1/SIMULATION/TOOLS/sim.h" #ifdef SMBV @@ -156,6 +157,9 @@ uint32_t N_RB_DL = 106; */ uint8_t abstraction_flag=0; +nr_bler_struct nr_bler_data[NR_NUM_MCS]; + +static void init_bler_table(void); /*---------------------BMC: timespec helpers -----------------------------*/ @@ -241,25 +245,25 @@ nrUE_params_t *get_nrUE_params(void) { } /* initialie thread pools used for NRUE processing paralleliation */ void init_tpools(uint8_t nun_dlsch_threads) { - char *params = NULL; - params = calloc(1,(NR_RX_NB_TH*NR_NB_TH_SLOT*3)+1); + char params[NR_RX_NB_TH*NR_NB_TH_SLOT*3+1]={0}; for (int i=0; i 0) ouput_vcd = 1; } @@ -311,8 +315,8 @@ void set_options(int CC_id, PHY_VARS_NR_UE *UE){ UE->rf_map.card = card_offset; UE->rf_map.chain = CC_id + chain_offset; - LOG_I(PHY,"Set UE mode %d, UE_fo_compensation %d, UE_scan_carrier %d, UE_no_timing_correction %d \n, do_prb_interpolation %d\n", - UE->mode, UE->UE_fo_compensation, UE->UE_scan_carrier, UE->no_timing_correction, UE->prb_interpolation); + LOG_I(PHY,"Set UE mode %d, UE_fo_compensation %d, UE_scan_carrier %d, UE_no_timing_correction %d \n, chest-freq %d\n", + UE->mode, UE->UE_fo_compensation, UE->UE_scan_carrier, UE->no_timing_correction, UE->chest_freq); // Set FP variables @@ -324,6 +328,7 @@ void set_options(int CC_id, PHY_VARS_NR_UE *UE){ LOG_I(PHY, "Set UE nb_rx_antenna %d, nb_tx_antenna %d, threequarter_fs %d, ssb_start_subcarrier %d\n", fp->nb_antennas_rx, fp->nb_antennas_tx, fp->threequarter_fs, fp->ssb_start_subcarrier); fp->ofdm_offset_divisor = nrUE_params.ofdm_offset_divisor; + UE->max_ldpc_iterations = nrUE_params.max_ldpc_iterations; } @@ -348,6 +353,7 @@ void init_openair0(void) { openair0_cfg[card].num_rb_dl = frame_parms->N_RB_DL; openair0_cfg[card].clock_source = get_softmodem_params()->clock_source; openair0_cfg[card].time_source = get_softmodem_params()->timing_source; + openair0_cfg[card].tune_offset = get_softmodem_params()->tune_offset; openair0_cfg[card].tx_num_channels = min(4, frame_parms->nb_antennas_tx); openair0_cfg[card].rx_num_channels = min(4, frame_parms->nb_antennas_rx); @@ -373,7 +379,7 @@ void init_openair0(void) { static void init_pdcp(int ue_id) { uint32_t pdcp_initmask = (!IS_SOFTMODEM_NOS1) ? LINK_ENB_PDCP_TO_GTPV1U_BIT : (LINK_ENB_PDCP_TO_GTPV1U_BIT | PDCP_USE_NETLINK_BIT | LINK_ENB_PDCP_TO_IP_DRIVER_BIT); - /*if (IS_SOFTMODEM_BASICSIM || IS_SOFTMODEM_RFSIM || (nfapi_getmode()==NFAPI_UE_STUB_PNF)) { + /*if (IS_SOFTMODEM_RFSIM || (nfapi_getmode()==NFAPI_UE_STUB_PNF)) { pdcp_initmask = pdcp_initmask | UE_NAS_USE_TUN_BIT; }*/ @@ -396,7 +402,14 @@ void *rrc_enb_process_msg(void *notUsed) { int main( int argc, char **argv ) { - set_priority(79); + int set_exe_prio = 1; + if (checkIfFedoraDistribution()) + if (checkIfGenericKernelOnFedora()) + if (checkIfInsideContainer()) + set_exe_prio = 0; + if (set_exe_prio) + set_priority(79); + if (mlockall(MCL_CURRENT | MCL_FUTURE) == -1) { fprintf(stderr, "mlockall: %s\n", strerror(errno)); @@ -465,6 +478,7 @@ int main( int argc, char **argv ) { PHY_vars_UE_g[0] = malloc(sizeof(PHY_VARS_NR_UE *)*MAX_NUM_CCs); if (get_softmodem_params()->emulate_l1) { RCconfig_nr_ue_L1(); + init_bler_table(); } if (get_softmodem_params()->do_ra) @@ -545,3 +559,56 @@ int main( int argc, char **argv ) { return 0; } + +// Read in each MCS file and build BLER-SINR-TB table +static void init_bler_table(void) { + memset(nr_bler_data, 0, sizeof(nr_bler_data)); + + const char *awgn_results_dir = getenv("AWGN_RESULTS_DIR"); + if (!awgn_results_dir) { + LOG_W(NR_MAC, "No $AWGN_RESULTS_DIR\n"); + return; + } + + for (unsigned int i = 0; i < NR_NUM_MCS; i++) { + char fName[1024]; + snprintf(fName, sizeof(fName), "%s/mcs%d_awgn_5G.csv", awgn_results_dir, i); + FILE *pFile = fopen(fName, "r"); + if (!pFile) { + LOG_E(NR_MAC, "%s: open %s: %s\n", __func__, fName, strerror(errno)); + continue; + } + size_t bufSize = 1024; + char * line = NULL; + char * token; + char * temp = NULL; + int nlines = 0; + while (getline(&line, &bufSize, pFile) > 0) { + if (!strncmp(line, "SNR", 3)) { + continue; + } + + if (nlines > NUM_SINR) { + LOG_E(NR_MAC, "BLER FILE ERROR - num lines greater than expected - file: %s\n", fName); + abort(); + } + + token = strtok_r(line, ";", &temp); + int ncols = 0; + while (token != NULL) { + if (ncols > NUM_BLER_COL) { + LOG_E(NR_MAC, "BLER FILE ERROR - num of cols greater than expected\n"); + abort(); + } + + nr_bler_data[i].bler_table[nlines][ncols] = strtof(token, NULL); + ncols++; + + token = strtok_r(NULL, ";", &temp); + } + nlines++; + } + nr_bler_data[i].length = nlines; + fclose(pFile); + } +} diff --git a/executables/nr-uesoftmodem.h b/executables/nr-uesoftmodem.h index 95914678e5..995d81f19c 100644 --- a/executables/nr-uesoftmodem.h +++ b/executables/nr-uesoftmodem.h @@ -7,10 +7,11 @@ -#define CONFIG_HLP_IF_FREQ "IF frequency for RF, if needed" -#define CONFIG_HLP_IF_FREQ_OFF "UL IF frequency offset for RF, if needed" +#define CONFIG_HLP_IF_FREQ "IF frequency for RF, if needed\n" +#define CONFIG_HLP_IF_FREQ_OFF "UL IF frequency offset for RF, if needed\n" #define CONFIG_HLP_DLSCH_PARA "number of threads for dlsch processing 0 for no parallelization\n" #define CONFIG_HLP_OFFSET_DIV "Divisor for computing OFDM symbol offset in Rx chain (num samples in CP/). Default value is 8. To set the sample offset to 0, set this value ~ 10e6\n" +#define CONFIG_HLP_MAX_LDPC_ITERATIONS "Maximum LDPC decoder iterations\n" /***************************************************************************************************************************************/ /* command line options definitions, CMDLINE_XXXX_DESC macros are used to initialize paramdef_t arrays which are then used as argument when calling config_get or config_getlist functions */ @@ -30,8 +31,9 @@ #define CMDLINE_NRUEPARAMS_DESC { \ {"usrp-args", CONFIG_HLP_USRP_ARGS, 0, strptr:(char **)&usrp_args, defstrval:"type=b200", TYPE_STRING, 0}, \ {"single-thread-disable", CONFIG_HLP_NOSNGLT, PARAMFLAG_BOOL, iptr:&single_thread_flag, defintval:1, TYPE_INT, 0}, \ - {"dlsch-parallel", CONFIG_HLP_DLSCH_PARA, 0, iptr:(int32_t *)&nrUE_params.nr_dlsch_parallel, defintval:0, TYPE_UINT8, 0}, \ - {"offset-divisor", CONFIG_HLP_OFFSET_DIV, 0, uptr:(uint32_t *)&nrUE_params.ofdm_offset_divisor, defuintval:UINT_MAX, TYPE_UINT32, 0}, \ + {"dlsch-parallel", CONFIG_HLP_DLSCH_PARA, 0, u8ptr:&nrUE_params.nr_dlsch_parallel, defintval:0, TYPE_UINT8, 0}, \ + {"offset-divisor", CONFIG_HLP_OFFSET_DIV, 0, uptr:&nrUE_params.ofdm_offset_divisor, defuintval:8, TYPE_UINT32, 0}, \ + {"max-ldpc-iterations", CONFIG_HLP_MAX_LDPC_ITERATIONS, 0, u8ptr:&nrUE_params.max_ldpc_iterations, defuintval:5, TYPE_UINT8, 0}, \ {"nr-dlsch-demod-shift", CONFIG_HLP_DLSHIFT, 0, iptr:(int32_t *)&nr_dlsch_demod_shift, defintval:0, TYPE_INT, 0}, \ {"V" , CONFIG_HLP_VCD, PARAMFLAG_BOOL, iptr:&vcdflag, defintval:0, TYPE_INT, 0}, \ {"uecap_file", CONFIG_HLP_UECAP_FILE, 0, strptr:(char **)&uecap_file, defstrval:"./uecap.xml", TYPE_STRING, 0}, \ @@ -67,7 +69,8 @@ {"T" , CONFIG_HLP_TDD, PARAMFLAG_BOOL, iptr:&tddflag, defintval:0, TYPE_INT, 0}, \ {"if_freq" , CONFIG_HLP_IF_FREQ, 0, u64ptr:&(UE->if_freq), defuintval:0, TYPE_UINT64,0}, \ {"if_freq_off" , CONFIG_HLP_IF_FREQ_OFF, 0, iptr:&(UE->if_freq_off), defuintval:0, TYPE_INT, 0}, \ - {"do-prb-interpolation", CONFIG_HLP_PRBINTER, PARAMFLAG_BOOL, iptr:&(UE->prb_interpolation), defintval:0, TYPE_INT, 0}, \ + {"chest-freq", CONFIG_HLP_CHESTFREQ, 0, iptr:&(UE->chest_freq), defintval:0, TYPE_INT, 0}, \ + {"chest-time", CONFIG_HLP_CHESTTIME, 0, iptr:&(UE->chest_time), defintval:0, TYPE_INT, 0}, \ {"ue-timing-correction-disable", CONFIG_HLP_DISABLETIMECORR, PARAMFLAG_BOOL, iptr:&(UE->no_timing_correction), defintval:0, TYPE_INT, 0}, \ } @@ -76,6 +79,7 @@ typedef struct { uint64_t optmask; //mask to store boolean config options uint32_t ofdm_offset_divisor; // Divisor for sample offset computation for each OFDM symbol uint8_t nr_dlsch_parallel; // number of threads for dlsch decoding, 0 means no parallelization + uint8_t max_ldpc_iterations; // number of maximum LDPC iterations tpool_t Tpool; // thread pool } nrUE_params_t; extern uint64_t get_nrUE_optmask(void); diff --git a/executables/softmodem-common.c b/executables/softmodem-common.c index 0cc726f3f2..eba5f34691 100644 --- a/executables/softmodem-common.c +++ b/executables/softmodem-common.c @@ -89,7 +89,7 @@ void get_common_options(uint32_t execmask) { uint32_t glog_level=0 ; uint32_t start_telnetsrv = 0, start_telnetclt = 0; uint32_t noS1 = 0, nokrnmod = 1, nonbiot = 0; - uint32_t rfsim = 0, basicsim = 0, do_forms = 0; + uint32_t rfsim = 0, do_forms = 0; char *logmem_filename = NULL; paramdef_t cmdline_params[] =CMDLINE_PARAMS_DESC ; paramdef_t cmdline_logparams[] =CMDLINE_LOGPARAMS_DESC ; @@ -141,10 +141,6 @@ void get_common_options(uint32_t execmask) { set_softmodem_optmask(SOFTMODEM_RFSIM_BIT); } - if (basicsim) { - set_softmodem_optmask(SOFTMODEM_BASICSIM_BIT); - } - if (do_forms) { set_softmodem_optmask(SOFTMODEM_DOSCOPE_BIT); } diff --git a/executables/softmodem-common.h b/executables/softmodem-common.h index 2891949ffe..007cf4e657 100644 --- a/executables/softmodem-common.h +++ b/executables/softmodem-common.h @@ -53,7 +53,6 @@ extern "C" #define CONFIG_HLP_DUMPFRAME "dump UE received frame to rxsig_frame0.dat and exit\n" -#define CONFIG_HLP_UELOOP "get softmodem (UE) to loop through memory instead of acquiring from HW\n" #define CONFIG_HLP_PHYTST "test UE phy layer, mac disabled\n" #define CONFIG_HLP_DORA "test gNB and UE with RA procedures\n" #define CONFIG_HLP_SA "run gNB in standalone mode\n" @@ -61,6 +60,7 @@ extern "C" #define CONFIG_HLP_DMRSSYNC "tells RU to insert DMRS in subframe 1 slot 0" #define CONFIG_HLP_CLK "tells hardware to use a clock reference (0:internal, 1:external, 2:gpsdo)\n" #define CONFIG_HLP_TME "tells hardware to use a time reference (0:internal, 1:external, 2:gpsdo)\n" +#define CONFIG_HLP_TUNE_OFFSET "LO tuning offset to use in Hz\n" #define CONFIG_HLP_USIM "use XOR autentication algo in case of test usim mode\n" #define CONFIG_HLP_NOSNGLT "Disables single-thread mode in lte-softmodem\n" #define CONFIG_HLP_DLF "Set the downlink frequency for all component carriers\n" @@ -72,7 +72,8 @@ extern "C" #define CONFIG_HLP_DLMCS "Set the maximum downlink MCS\n" #define CONFIG_HLP_STMON "Enable processing timing measurement of lte softmodem on per subframe basis \n" #define CONFIG_HLP_256QAM "Use the 256 QAM mcs table for PDSCH\n" -#define CONFIG_HLP_PRBINTER "Do PRB based averaging of channel estimates. Frequency domain linear interpolation by default\n" +#define CONFIG_HLP_CHESTFREQ "Set channel estimation type in frequency domain. 0-Linear interpolation (default). 1-PRB based averaging of channel estimates in frequency. \n" +#define CONFIG_HLP_CHESTTIME "Set channel estimation type in time domain. 0-Symbols take estimates of the last preceding DMRS symbol (default). 1-Symbol based averaging of channel estimates in time. \n" #define CONFIG_HLP_NONSTOP "Go back to frame sync mode after 100 consecutive PBCH failures\n" //#define CONFIG_HLP_NUMUES "Set the number of UEs for the emulation" @@ -93,12 +94,13 @@ extern "C" #define CONFIG_HLP_USRP_THREAD "having extra thead for usrp tx\n" #define CONFIG_HLP_NOS1 "Disable s1 interface\n" -#define CONFIG_HLP_RFSIM "Run in rf simulator mode (also known as basic simulator)\n" +#define CONFIG_HLP_RFSIM "Run in rf simulator mode\n" #define CONFIG_HLP_NOKRNMOD "(noS1 only): Use tun instead of namesh module \n" #define CONFIG_HLP_DISABLNBIOT "disable nb-iot, even if defined in config\n" #define CONFIG_HLP_USRP_THREAD "having extra thead for usrp tx\n" #define CONFIG_HLP_NFAPI "Change the nFAPI mode for NR\n" #define CONFIG_L1_EMULATOR "Run in L1 emulated mode (disable PHY layer)\n" +#define CONFIG_HLP_CONTINUOUS_TX "perform continuous transmission, even in TDD mode (to work around USRP issues)\n" /*-----------------------------------------------------------------------------------------------------------------------------------------------------*/ /* command line parameters common to eNodeB and UE */ @@ -118,14 +120,17 @@ extern "C" #define EMULATE_RF softmodem_params.emulate_rf #define CLOCK_SOURCE softmodem_params.clock_source #define TIMING_SOURCE softmodem_params.timing_source +#define TUNE_OFFSET softmodem_params.tune_offset #define SEND_DMRSSYNC softmodem_params.send_dmrs_sync #define USIM_TEST softmodem_params.usim_test -#define PRB_INTERPOLATION softmodem_params.prb_interpolation +#define CHEST_FREQ softmodem_params.chest_freq +#define CHEST_TIME softmodem_params.chest_time #define NFAPI softmodem_params.nfapi #define NSA softmodem_params.nsa #define NODE_NUMBER softmodem_params.node_number #define NON_STOP softmodem_params.non_stop #define EMULATE_L1 softmodem_params.emulate_l1 +#define CONTINUOUS_TX softmodem_params.continuous_tx #define DEFAULT_RFCONFIG_FILE "/usr/local/etc/syriq/ue.band7.tm1.PRB100.NR40.dat"; @@ -140,6 +145,7 @@ extern int usrp_tx_thread; {"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}, \ {"single-thread-enable", CONFIG_HLP_NOSNGLT, PARAMFLAG_BOOL, iptr:&SINGLE_THREAD_FLAG, defintval:0, TYPE_INT, 0}, \ {"C" , CONFIG_HLP_DLF, 0, u64ptr:&(downlink_frequency[0][0]), defuintval:0, TYPE_UINT64, 0}, \ @@ -154,16 +160,17 @@ extern int usrp_tx_thread; {"worker-config", CONFIG_HLP_WORKER_CMD, 0, strptr:(char **)&worker_config, defstrval:NULL, TYPE_STRING, 0}, \ {"noS1", CONFIG_HLP_NOS1, PARAMFLAG_BOOL, uptr:&noS1, defintval:0, TYPE_INT, 0}, \ {"rfsim", CONFIG_HLP_RFSIM, PARAMFLAG_BOOL, uptr:&rfsim, defintval:0, TYPE_INT, 0}, \ - {"basicsim", CONFIG_HLP_RFSIM, PARAMFLAG_BOOL, uptr:&basicsim, defintval:0, TYPE_INT, 0}, \ {"nokrnmod", CONFIG_HLP_NOKRNMOD, PARAMFLAG_BOOL, uptr:&nokrnmod, defintval:0, TYPE_INT, 0}, \ {"nbiot-disable", CONFIG_HLP_DISABLNBIOT, PARAMFLAG_BOOL, uptr:&nonbiot, defuintval:0, TYPE_INT, 0}, \ + {"chest-freq", CONFIG_HLP_CHESTFREQ, 0, iptr:&CHEST_FREQ, defintval:0, TYPE_INT, 0}, \ + {"chest-time", CONFIG_HLP_CHESTTIME, 0, iptr:&CHEST_TIME, defintval:0, TYPE_INT, 0}, \ {"nsa", CONFIG_HLP_NSA, PARAMFLAG_BOOL, iptr:&NSA, defintval:0, TYPE_INT, 0}, \ {"node-number", NULL, 0, u16ptr:&NODE_NUMBER, defuintval:0, TYPE_UINT16, 0}, \ {"usrp-tx-thread-config", CONFIG_HLP_USRP_THREAD, 0, iptr:&usrp_tx_thread, defstrval:0, TYPE_INT, 0}, \ - {"do-prb-interpolation", CONFIG_HLP_PRBINTER, PARAMFLAG_BOOL, iptr:&PRB_INTERPOLATION, defintval:0, TYPE_INT, 0}, \ {"nfapi", CONFIG_HLP_NFAPI, 0, u8ptr:&nfapi_mode, defintval:0, TYPE_UINT8, 0}, \ {"non-stop", CONFIG_HLP_NONSTOP, PARAMFLAG_BOOL, iptr:&NON_STOP, defintval:0, TYPE_INT, 0}, \ - {"emulate-l1", CONFIG_L1_EMULATOR, PARAMFLAG_BOOL, iptr:&EMULATE_L1, defintval:0, TYPE_INT, 0} \ + {"emulate-l1", CONFIG_L1_EMULATOR, PARAMFLAG_BOOL, iptr:&EMULATE_L1, defintval:0, TYPE_INT, 0}, \ + {"continuous-tx", CONFIG_HLP_CONTINUOUS_TX,PARAMFLAG_BOOL, iptr:&CONTINUOUS_TX, defintval:0, TYPE_INT, 0}, \ } #define CONFIG_HLP_NSA "Enable NSA mode \n" @@ -201,7 +208,6 @@ extern int usrp_tx_thread; #define SOFTMODEM_NOKRNMOD_BIT (1<<1) #define SOFTMODEM_NONBIOT_BIT (1<<2) #define SOFTMODEM_RFSIM_BIT (1<<10) -#define SOFTMODEM_BASICSIM_BIT (1<<11) #define SOFTMODEM_SIML1_BIT (1<<12) #define SOFTMODEM_DOSCOPE_BIT (1<<15) #define SOFTMODEM_RECPLAY_BIT (1<<16) @@ -218,7 +224,6 @@ extern int usrp_tx_thread; #define IS_SOFTMODEM_NOKRNMOD ( get_softmodem_optmask() & SOFTMODEM_NOKRNMOD_BIT) #define IS_SOFTMODEM_NONBIOT ( get_softmodem_optmask() & SOFTMODEM_NONBIOT_BIT) #define IS_SOFTMODEM_RFSIM ( get_softmodem_optmask() & SOFTMODEM_RFSIM_BIT) -#define IS_SOFTMODEM_BASICSIM ( get_softmodem_optmask() & SOFTMODEM_BASICSIM_BIT) #define IS_SOFTMODEM_SIML1 ( get_softmodem_optmask() & SOFTMODEM_SIML1_BIT) #define IS_SOFTMODEM_DOSCOPE ( get_softmodem_optmask() & SOFTMODEM_DOSCOPE_BIT) #define IS_SOFTMODEM_IQPLAYER ( get_softmodem_optmask() & SOFTMODEM_RECPLAY_BIT) @@ -246,14 +251,18 @@ typedef struct { int band; uint32_t clock_source; uint32_t timing_source; + double tune_offset; int hw_timing_advance; uint32_t send_dmrs_sync; - int prb_interpolation; + int use_256qam_table; + int chest_time; + int chest_freq; uint8_t nfapi; int nsa; uint16_t node_number; int non_stop; int emulate_l1; + int continuous_tx; } softmodem_params_t; extern uint64_t get_softmodem_optmask(void); diff --git a/nfapi/oai_integration/nfapi_vnf.c b/nfapi/oai_integration/nfapi_vnf.c index 44ee05940f..d13dc5d1c5 100644 --- a/nfapi/oai_integration/nfapi_vnf.c +++ b/nfapi/oai_integration/nfapi_vnf.c @@ -200,7 +200,6 @@ void install_nr_schedule_handlers(NR_IF_Module_t *if_inst); void install_schedule_handlers(IF_Module_t *if_inst); extern int single_thread_flag; extern uint16_t sf_ahead; -extern uint16_t slot_ahead; void oai_create_enb(void) { int bodge_counter=0; @@ -244,13 +243,13 @@ void oai_create_gnb(void) { if (RC.gNB == NULL) { RC.gNB = (PHY_VARS_gNB **) calloc(1, sizeof(PHY_VARS_gNB *)); - LOG_I(PHY,"gNB L1 structure RC.gNB allocated @ %p\n",RC.gNB); + LOG_D(PHY,"gNB L1 structure RC.gNB allocated @ %p\n",RC.gNB); } if (RC.gNB[0] == NULL) { RC.gNB[0] = (PHY_VARS_gNB *) calloc(1, sizeof(PHY_VARS_gNB)); - LOG_I(PHY,"[nr-gnb.c] gNB structure RC.gNB[%d] allocated @ %p\n",0,RC.gNB[0]); + LOG_D(PHY,"[nr-gnb.c] gNB structure RC.gNB[%d] allocated @ %p\n",0,RC.gNB[0]); } PHY_VARS_gNB *gNB = RC.gNB[0]; @@ -459,6 +458,7 @@ int wake_gNB_rxtx(PHY_VARS_gNB *gNB, uint16_t sfn, uint16_t slot) { //wait.tv_nsec = 0; // wake up TX for subframe n+sf_ahead // lock the TX mutex and make sure the thread is ready + AssertFatal(gNB->if_inst->sl_ahead==6,"gNB->if_inst->sl_ahead %d : This is hard-coded to 6 in nfapi P7!!!\n",gNB->if_inst->sl_ahead); if (pthread_mutex_timedlock(&L1_proc->mutex,&wait) != 0) { LOG_E( PHY, "[gNB] ERROR pthread_mutex_lock for gNB RXTX thread %d (IC %d)\n", L1_proc->slot_rx&1,L1_proc->instance_cnt ); exit_fun( "error locking mutex_rxtx" ); @@ -485,13 +485,13 @@ int wake_gNB_rxtx(PHY_VARS_gNB *gNB, uint16_t sfn, uint16_t slot) { // The last (TS_rx mod samples_per_frame) was n*samples_per_tti, // we want to generate subframe (n+N), so TS_tx = TX_rx+N*samples_per_tti, // and proc->subframe_tx = proc->subframe_rx+sf_ahead - L1_proc->timestamp_tx = proc->timestamp_rx + (slot_ahead *fp->samples_per_subframe); + L1_proc->timestamp_tx = proc->timestamp_rx + (gNB->if_inst->sl_ahead *fp->samples_per_subframe); L1_proc->frame_rx = proc->frame_rx; L1_proc->slot_rx = proc->slot_rx; - L1_proc->frame_tx = (L1_proc->slot_rx > (19-slot_ahead)) ? (L1_proc->frame_rx+1)&1023 : L1_proc->frame_rx; - L1_proc->slot_tx = (L1_proc->slot_rx + slot_ahead)%20; + L1_proc->frame_tx = (L1_proc->slot_rx > (19-gNB->if_inst->sl_ahead)) ? (L1_proc->frame_rx+1)&1023 : L1_proc->frame_rx; + L1_proc->slot_tx = (L1_proc->slot_rx + gNB->if_inst->sl_ahead)%20; - //LOG_I(PHY, "sfn/sf:%d%d proc[rx:%d%d] rx:%d%d] About to wake rxtx thread\n\n", sfn, slot, proc->frame_rx, proc->slot_rx, L1_proc->frame_rx, L1_proc->slot_rx); + //LOG_D(PHY, "sfn/sf:%d%d proc[rx:%d%d] rx:%d%d] About to wake rxtx thread\n\n", sfn, slot, proc->frame_rx, proc->slot_rx, L1_proc->frame_rx, L1_proc->slot_rx); //NFAPI_TRACE(NFAPI_TRACE_INFO, "\nEntering wake_gNB_rxtx sfn %d slot %d\n",L1_proc->frame_rx,L1_proc->slot_rx); // the thread can now be woken up if (pthread_cond_signal(&L1_proc->cond) != 0) { @@ -757,7 +757,7 @@ int phy_nr_rach_indication(nfapi_nr_rach_indication_t *ind) int phy_nr_uci_indication(nfapi_nr_uci_indication_t *ind) { - LOG_I(NR_MAC, "In %s() NFAPI SFN/SF: %d/%d number_of_pdus :%u\n", + LOG_D(NR_MAC, "In %s() NFAPI SFN/SF: %d/%d number_of_pdus :%u\n", __FUNCTION__,ind->sfn, ind->slot, ind->num_ucis); if(NFAPI_MODE == NFAPI_MODE_VNF) { @@ -787,12 +787,12 @@ int phy_nr_uci_indication(nfapi_nr_uci_indication_t *ind) if (ind_pdu->harq) { uci_ind_pdu->harq = CALLOC(1, sizeof(*uci_ind_pdu->harq)); AssertFatal(uci_ind_pdu->harq != NULL, "Memory not allocated for uci_ind_pdu->harq in phy_nr_uci_indication."); - *uci_ind_pdu->harq = *ind_pdu->harq; + uci_ind_pdu->harq->harq_list = CALLOC(uci_ind_pdu->harq->num_harq, sizeof(*uci_ind_pdu->harq->harq_list)); AssertFatal(uci_ind_pdu->harq->harq_list != NULL, "Memory not allocated for uci_ind_pdu->harq->harq_list in phy_nr_uci_indication."); for (int j = 0; j < uci_ind_pdu->harq->num_harq; j++) - uci_ind_pdu->harq->harq_list[j].harq_value = ind_pdu->harq->harq_list[j].harq_value; + uci_ind_pdu->harq->harq_list[j].harq_value = ind_pdu->harq->harq_list[j].harq_value; } break; } @@ -800,21 +800,27 @@ int phy_nr_uci_indication(nfapi_nr_uci_indication_t *ind) case NFAPI_NR_UCI_FORMAT_2_3_4_PDU_TYPE: { nfapi_nr_uci_pucch_pdu_format_2_3_4_t *uci_ind_pdu = &uci_ind->uci_list[i].pucch_pdu_format_2_3_4; nfapi_nr_uci_pucch_pdu_format_2_3_4_t *ind_pdu = &ind->uci_list[i].pucch_pdu_format_2_3_4; - - uci_ind_pdu->harq.harq_payload = CALLOC(1, sizeof(*uci_ind_pdu->harq.harq_payload)); - AssertFatal(uci_ind_pdu->harq.harq_payload != NULL, "Memory not allocated for uci_ind_pdu->harq.harq_payload in phy_nr_uci_indication."); - *uci_ind_pdu->harq.harq_payload = *ind_pdu->harq.harq_payload; - - - uci_ind_pdu->csi_part1.csi_part1_payload = CALLOC(1, sizeof(*uci_ind_pdu->csi_part1.csi_part1_payload)); - AssertFatal(uci_ind_pdu->csi_part1.csi_part1_payload != NULL, "Memory not allocated for uci_ind_pdu->csi_part1.csi_part1_payload in phy_nr_uci_indication."); - *uci_ind_pdu->csi_part1.csi_part1_payload = *ind_pdu->csi_part1.csi_part1_payload; - - - uci_ind_pdu->csi_part2.csi_part2_payload = CALLOC(1, sizeof(*uci_ind_pdu->csi_part2.csi_part2_payload)); - AssertFatal(uci_ind_pdu->csi_part2.csi_part2_payload != NULL, "Memory not allocated for uci_ind_pdu->csi_part2.csi_part2_payload in phy_nr_uci_indication."); - *uci_ind_pdu->csi_part2.csi_part2_payload = *ind_pdu->csi_part2.csi_part2_payload; - + *uci_ind_pdu = *ind_pdu; + if (ind_pdu->harq.harq_payload) { + uci_ind_pdu->harq.harq_payload = CALLOC(1, sizeof(*uci_ind_pdu->harq.harq_payload)); + AssertFatal(uci_ind_pdu->harq.harq_payload != NULL, "Memory not allocated for uci_ind_pdu->harq.harq_payload in phy_nr_uci_indication."); + *uci_ind_pdu->harq.harq_payload = *ind_pdu->harq.harq_payload; + } + if (ind_pdu->sr.sr_payload) { + uci_ind_pdu->sr.sr_payload = CALLOC(1, sizeof(*uci_ind_pdu->sr.sr_payload)); + AssertFatal(uci_ind_pdu->sr.sr_payload != NULL, "Memory not allocated for uci_ind_pdu->sr.sr_payload in phy_nr_uci_indication."); + *uci_ind_pdu->sr.sr_payload = *ind_pdu->sr.sr_payload; + } + if (ind_pdu->csi_part1.csi_part1_payload) { + uci_ind_pdu->csi_part1.csi_part1_payload = CALLOC(1, sizeof(*uci_ind_pdu->csi_part1.csi_part1_payload)); + AssertFatal(uci_ind_pdu->csi_part1.csi_part1_payload != NULL, "Memory not allocated for uci_ind_pdu->csi_part1.csi_part1_payload in phy_nr_uci_indication."); + *uci_ind_pdu->csi_part1.csi_part1_payload = *ind_pdu->csi_part1.csi_part1_payload; + } + if (ind_pdu->csi_part2.csi_part2_payload) { + uci_ind_pdu->csi_part2.csi_part2_payload = CALLOC(1, sizeof(*uci_ind_pdu->csi_part2.csi_part2_payload)); + AssertFatal(uci_ind_pdu->csi_part2.csi_part2_payload != NULL, "Memory not allocated for uci_ind_pdu->csi_part2.csi_part2_payload in phy_nr_uci_indication."); + *uci_ind_pdu->csi_part2.csi_part2_payload = *ind_pdu->csi_part2.csi_part2_payload; + } break; } } @@ -944,7 +950,7 @@ int phy_crc_indication(struct nfapi_vnf_p7_config *config, nfapi_crc_indication_ int phy_nr_crc_indication(nfapi_nr_crc_indication_t *ind) { - LOG_I(NR_MAC, "In %s() NFAPI SFN/SF: %d/%d number_of_pdus :%u\n", + LOG_D(NR_MAC, "In %s() NFAPI SFN/SF: %d/%d number_of_pdus :%u\n", __FUNCTION__,ind->sfn, ind->slot, ind->number_crcs); if(NFAPI_MODE == NFAPI_MODE_VNF) @@ -967,7 +973,7 @@ int phy_nr_crc_indication(nfapi_nr_crc_indication_t *ind) { crc_ind->crc_list[j].tb_crc_status = ind->crc_list[j].tb_crc_status; crc_ind->crc_list[j].timing_advance = ind->crc_list[j].timing_advance; crc_ind->crc_list[j].ul_cqi = ind->crc_list[j].ul_cqi; - LOG_I(NR_MAC, "Received crc_ind.harq_id = %d for %d index SFN SLot %u %u with rnti %x\n", + LOG_D(NR_MAC, "Received crc_ind.harq_id = %d for %d index SFN SLot %u %u with rnti %x\n", ind->crc_list[j].harq_id, j, ind->sfn, ind->slot, ind->crc_list[j].rnti); } if (!put_queue(&gnb_crc_ind_queue, crc_ind)) @@ -1063,7 +1069,7 @@ int phy_rx_indication(struct nfapi_vnf_p7_config *config, nfapi_rx_indication_t int phy_nr_rx_data_indication(nfapi_nr_rx_data_indication_t *ind) { - LOG_I(NR_MAC, "In %s() NFAPI SFN/SF: %d/%d number_of_pdus :%u, and pdu %p\n", + LOG_D(NR_MAC, "In %s() NFAPI SFN/SF: %d/%d number_of_pdus :%u, and pdu %p\n", __FUNCTION__,ind->sfn, ind->slot, ind->number_of_pdus, ind->pdu_list[0].pdu); if(NFAPI_MODE == NFAPI_MODE_VNF) @@ -1165,7 +1171,7 @@ static void analyze_cqi_pdus_for_duplicates(nfapi_cqi_indication_t *ind) { nfapi_cqi_indication_pdu_t *src_pdu = &ind->cqi_indication_body.cqi_pdu_list[i]; - LOG_I(MAC, "CQI_IND[PDU:%d][rnti:%x cqi:%d channel:%d]\n", i, src_pdu->rx_ue_information.rnti, + LOG_D(MAC, "CQI_IND[PDU:%d][rnti:%x cqi:%d channel:%d]\n", i, src_pdu->rx_ue_information.rnti, src_pdu->ul_cqi_information.ul_cqi, src_pdu->ul_cqi_information.channel); for (int j = i + 1; j < num_cqis; j++) @@ -1887,7 +1893,7 @@ int oai_nfapi_dl_config_req(nfapi_dl_config_request_t *dl_config_req) { nfapi_vnf_p7_config_t *p7_config = vnf.p7_vnfs[0].config; dl_config_req->header.phy_id = 1; // DJP HACK TODO FIXME - need to pass this around!!!! dl_config_req->header.message_id = NFAPI_DL_CONFIG_REQUEST; - LOG_I(PHY, "[VNF] %s() DL_CONFIG_REQ sfn_sf:%d_%d number_of_pdus:%d\n", __FUNCTION__, + LOG_D(PHY, "[VNF] %s() DL_CONFIG_REQ sfn_sf:%d_%d number_of_pdus:%d\n", __FUNCTION__, NFAPI_SFNSF2SFN(dl_config_req->sfn_sf),NFAPI_SFNSF2SF(dl_config_req->sfn_sf), dl_config_req->dl_config_request_body.number_pdu); if (dl_config_req->dl_config_request_body.number_pdu > 0) { @@ -1898,7 +1904,7 @@ int oai_nfapi_dl_config_req(nfapi_dl_config_request_t *dl_config_req) { { uint16_t dl_rnti = dl_config_req->dl_config_request_body.dl_config_pdu_list[i].dlsch_pdu.dlsch_pdu_rel8.rnti; uint16_t numPDUs = dl_config_req->dl_config_request_body.number_pdu; - LOG_I(MAC, "(OAI eNB) Sending dl_config_req at VNF during Frame: %d and Subframe: %d," + LOG_D(MAC, "(OAI eNB) Sending dl_config_req at VNF during Frame: %d and Subframe: %d," " with a RNTI value of: %x and with number of PDUs: %u\n", NFAPI_SFNSF2SFN(dl_config_req->sfn_sf),NFAPI_SFNSF2SF(dl_config_req->sfn_sf), dl_rnti, numPDUs); } @@ -1919,8 +1925,7 @@ int oai_nfapi_dl_config_req(nfapi_dl_config_request_t *dl_config_req) { int oai_nfapi_dl_tti_req(nfapi_nr_dl_tti_request_t *dl_config_req) { - //LOG_I(PHY, "sfn:%d,slot:%d\n",dl_config_req->SFN,dl_config_req->Slot); - //printf("\nEntering oai_nfapi_nr_dl_config_req sfn:%d,slot:%d\n",dl_config_req->SFN,dl_config_req->Slot); + LOG_D(NR_PHY, "Entering oai_nfapi_nr_dl_config_req sfn:%d,slot:%d\n", dl_config_req->SFN, dl_config_req->Slot); nfapi_vnf_p7_config_t *p7_config = vnf.p7_vnfs[0].config; dl_config_req->header.message_id= NFAPI_NR_PHY_MSG_TYPE_DL_TTI_REQUEST; dl_config_req->header.phy_id = 1; // DJP HACK TODO FIXME - need to pass this around!!!! @@ -1939,6 +1944,7 @@ int oai_nfapi_dl_tti_req(nfapi_nr_dl_tti_request_t *dl_config_req) int oai_nfapi_tx_data_req(nfapi_nr_tx_data_request_t *tx_data_req) { + LOG_D(NR_PHY, "Entering oai_nfapi_nr_tx_data_req sfn:%d,slot:%d\n", tx_data_req->SFN, tx_data_req->Slot); nfapi_vnf_p7_config_t *p7_config = vnf.p7_vnfs[0].config; tx_data_req->header.phy_id = 1; // DJP HACK TODO FIXME - need to pass this around!!!! tx_data_req->header.message_id = NFAPI_NR_PHY_MSG_TYPE_TX_DATA_REQUEST; @@ -2056,7 +2062,7 @@ int oai_nfapi_ul_config_req(nfapi_ul_config_request_t *ul_config_req) { { uint8_t pdu_type = pdu_list[i].pdu_type; - LOG_I(MAC, "ul_config_req num_pdus: %u pdu_number: %d pdu_type: %u SFN.SF: %d.%d\n", + LOG_D(MAC, "ul_config_req num_pdus: %u pdu_number: %d pdu_type: %u SFN.SF: %d.%d\n", num_pdus, i, pdu_type, ul_config_req->sfn_sf >> 4, ul_config_req->sfn_sf & 15); if (pdu_type != NFAPI_UL_CONFIG_ULSCH_CQI_RI_PDU_TYPE) diff --git a/nfapi/open-nFAPI/nfapi/inc/nfapi.h b/nfapi/open-nFAPI/nfapi/inc/nfapi.h index 0f09efa78a..c1f423a8db 100644 --- a/nfapi/open-nFAPI/nfapi/inc/nfapi.h +++ b/nfapi/open-nFAPI/nfapi/inc/nfapi.h @@ -44,13 +44,21 @@ uint8_t pulls32(uint8_t **in, int32_t *out, uint8_t *end); uint32_t pullarray8(uint8_t **in, uint8_t out[], uint32_t max_len, uint32_t len, uint8_t *end); uint32_t pullarray16(uint8_t **in, uint16_t out[], uint32_t max_len, uint32_t len, uint8_t *end); uint32_t pullarrays16(uint8_t **in, int16_t out[], uint32_t max_len, uint32_t len, uint8_t *end); -uint32_t pullarray32(uint8_t **in, uint32_t out[], uint32_t max_len, uint32_t len, uint8_t *end); +uint32_t pullarray32(uint8_t **values_to_pull, + uint32_t out[], + uint32_t max_num_values_to_pull, + uint32_t num_values_to_pull, + uint8_t *out_end); uint32_t pullarrays32(uint8_t **in, int32_t out[], uint32_t max_len, uint32_t len, uint8_t *end); uint32_t pusharray8(uint8_t in[], uint32_t max_len, uint32_t len, uint8_t **out, uint8_t *end); uint32_t pusharray16(uint16_t in[], uint32_t max_len, uint32_t len, uint8_t **out, uint8_t *end); uint32_t pusharrays16(int16_t in[], uint32_t max_len, uint32_t len, uint8_t **out, uint8_t *end); -uint32_t pusharray32(uint32_t in[], uint32_t max_len, uint32_t len, uint8_t **out, uint8_t *end); +uint32_t pusharray32(const uint32_t *values_to_push, + uint32_t max_num_values_to_push, + uint32_t num_values_to_push, + uint8_t **out, + uint8_t *out_end); uint32_t pusharrays32(int32_t in[], uint32_t max_len, uint32_t len, uint8_t **out, uint8_t *end); typedef uint8_t (*pack_array_elem_fn)(void* elem, uint8_t **ppWritePackedMsg, uint8_t *end); diff --git a/nfapi/open-nFAPI/nfapi/public_inc/fapi_nr_ue_constants.h b/nfapi/open-nFAPI/nfapi/public_inc/fapi_nr_ue_constants.h index 7fb42e566a..ba66daa9c0 100644 --- a/nfapi/open-nFAPI/nfapi/public_inc/fapi_nr_ue_constants.h +++ b/nfapi/open-nFAPI/nfapi/public_inc/fapi_nr_ue_constants.h @@ -10,7 +10,8 @@ #define FAPI_NR_MAX_RA_OCCASION_PER_CSIRS 64 // Constants Defined in 38.213 #define FAPI_NR_MAX_CORESET_PER_BWP 3 -#define FAPI_NR_MAX_SS 10 +#define FAPI_NR_MAX_SS_PER_BWP 10 +#define FAPI_NR_MAX_SS FAPI_NR_MAX_SS_PER_BWP*NR_MAX_NUM_BWP /// RX_IND diff --git a/nfapi/open-nFAPI/nfapi/public_inc/fapi_nr_ue_interface.h b/nfapi/open-nFAPI/nfapi/public_inc/fapi_nr_ue_interface.h index 284ef22fc4..fd9af01720 100644 --- a/nfapi/open-nFAPI/nfapi/public_inc/fapi_nr_ue_interface.h +++ b/nfapi/open-nFAPI/nfapi/public_inc/fapi_nr_ue_interface.h @@ -308,6 +308,7 @@ typedef struct uint8_t transform_precoding; uint16_t data_scrambling_id; uint8_t nrOfLayers; + uint8_t Tpmi; //DMRS uint16_t ul_dmrs_symb_pos; uint8_t dmrs_config_type; @@ -433,6 +434,9 @@ typedef struct { uint8_t mcs; uint8_t ndi; uint8_t rv; + uint16_t targetCodeRate; + uint8_t qamModOrder; + uint32_t TBS; uint8_t tb2_mcs; uint8_t tb2_ndi; uint8_t tb2_rv; @@ -464,7 +468,9 @@ typedef struct { uint8_t nEpreRatioOfPDSCHToPTRS; /// MCS table for this DLSCH uint8_t mcs_table; - + uint32_t tbslbrm; + uint8_t nscid; + uint16_t dlDmrsScramblingId; uint16_t pduBitmap; } fapi_nr_dl_config_dlsch_pdu_rel15_t; @@ -475,20 +481,20 @@ typedef struct { typedef struct { - uint16_t bwp_size;// - uint16_t bwp_start;// - uint8_t subcarrier_spacing;// - uint8_t cyclic_prefix;// - uint16_t start_rb; - uint16_t nr_of_rbs; - uint8_t csi_type;//Value: 0:TRS 1:CSI-RS NZP 2:CSI-RS ZP - uint8_t row;//Row entry into the CSI Resource location table. [TS38.211, sec 7.4.1.5.3 and table 7.4.1.5.3-1] Value: 1-18 - uint16_t freq_domain;//Value: Up to the 12 LSBs, actual size is determined by the Row parameter - uint8_t symb_l0;//The time domain location l0 and firstOFDMSymbolInTimeDomain Value: 0->13 - uint8_t symb_l1;// - uint8_t cdm_type; - uint8_t freq_density;//The density field, p and comb offset (for dot5).0: dot5 (even RB), 1: dot5 (odd RB), 2: one, 3: three - uint16_t scramb_id;//ScramblingID of the CSI-RS [TS38.214, sec 5.2.2.3.1] Value: 0->1023 + uint8_t subcarrier_spacing; // subcarrierSpacing [3GPP TS 38.211, sec 4.2], Value:0->4 + uint8_t cyclic_prefix; // Cyclic prefix type [3GPP TS 38.211, sec 4.2], 0: Normal; 1: Extended + uint16_t start_rb; // PRB where this CSI resource starts related to common resource block #0 (CRB#0). Only multiples of 4 are allowed. [3GPP TS 38.331, sec 6.3.2 parameter CSIFrequencyOccupation], Value: 0 ->274 + uint16_t nr_of_rbs; // Number of PRBs across which this CSI resource spans. Only multiples of 4 are allowed. [3GPP TS 38.331, sec 6.3.2 parameter CSI-FrequencyOccupation], Value: 24 -> 276 + uint8_t csi_type; // CSI Type [3GPP TS 38.211, sec 7.4.1.5], Value: 0:TRS; 1:CSI-RS NZP; 2:CSI-RS ZP + uint8_t row; // Row entry into the CSI Resource location table. [3GPP TS 38.211, sec 7.4.1.5.3 and table 7.4.1.5.3-1], Value: 1-18 + uint16_t freq_domain; // Bitmap defining the frequencyDomainAllocation [3GPP TS 38.211, sec 7.4.1.5.3] [3GPP TS 38.331 CSIResourceMapping], Value: Up to the 12 LSBs, actual size is determined by the Row parameter + uint8_t symb_l0; // The time domain location l0 and firstOFDMSymbolInTimeDomain [3GPP TS 38.211, sec 7.4.1.5.3], Value: 0->13 + uint8_t symb_l1; // The time domain location l1 and firstOFDMSymbolInTimeDomain2 [3GPP TS 38.211, sec 7.4.1.5.3], Value: 2->12 + uint8_t cdm_type; // The cdm-Type field [3GPP TS 38.211, sec 7.4.1.5.3 and table 7.4.1.5.3-1], Value: 0: noCDM; 1: fd-CDM2; 2: cdm4-FD2-TD2; 3: cdm8-FD2-TD4 + uint8_t freq_density; // The density field, p and comb offset (for dot5). [3GPP TS 38.211, sec 7.4.1.5.3 and table 7.4.1.5.3-1], Value: 0: dot5 (even RB); 1: dot5 (odd RB); 2: one; 3: three + uint16_t scramb_id; // ScramblingID of the CSI-RS [3GPP TS 38.214, sec 5.2.2.3.1], Value: 0->1023 + uint8_t power_control_offset; // Ratio of PDSCH EPRE to NZP CSI-RSEPRE [3GPP TS 38.214, sec 5.2.2.3.1], Value: 0->23 representing -8 to 15 dB in 1dB steps; 255: L1 is configured with ProfileSSS + uint8_t power_control_offset_ss; // Ratio of NZP CSI-RS EPRE to SSB/PBCH block EPRE [3GPP TS 38.214, sec 5.2.2.3.1], Values: 0: -3dB; 1: 0dB; 2: 3dB; 3: 6dB; 255: L1 is configured with ProfileSSS } fapi_nr_dl_config_csirs_pdu_rel15_t; diff --git a/nfapi/open-nFAPI/nfapi/public_inc/nfapi_nr_interface_scf.h b/nfapi/open-nFAPI/nfapi/public_inc/nfapi_nr_interface_scf.h index c3a173758c..8b564a5e37 100644 --- a/nfapi/open-nFAPI/nfapi/public_inc/nfapi_nr_interface_scf.h +++ b/nfapi/open-nFAPI/nfapi/public_inc/nfapi_nr_interface_scf.h @@ -776,6 +776,10 @@ typedef struct { nfapi_nr_dl_dci_pdu_t dci_pdu[MAX_DCI_CORESET]; } nfapi_nr_dl_tti_pdcch_pdu_rel15_t; +typedef struct { + uint32_t tbSizeLbrmBytes; +}nfapi_v3_pdsch_maintenance_parameters_t; + typedef struct { uint16_t pduBitmap; uint16_t rnti; @@ -854,6 +858,7 @@ typedef struct { uint8_t nEpreRatioOfPDSCHToPTRS; // Beamforming nfapi_nr_tx_precoding_and_beamforming_t precodingAndBeamforming; + nfapi_v3_pdsch_maintenance_parameters_t maintenance_parms_v3; }nfapi_nr_dl_tti_pdsch_pdu_rel15_t; @@ -920,32 +925,24 @@ typedef struct } nfapi_nr_dlsch_pdu_t; */ -//for csi-rs_pdu: - -//table 3-39 typedef struct { - uint16_t bwp_size;// - uint16_t bwp_start;// - uint8_t subcarrier_spacing;// - uint8_t cyclic_prefix;// - uint16_t start_rb; - uint16_t nr_of_rbs; - uint8_t csi_type;//Value: 0:TRS 1:CSI-RS NZP 2:CSI-RS ZP - uint8_t row;//Row entry into the CSI Resource location table. [TS38.211, sec 7.4.1.5.3 and table 7.4.1.5.3-1] Value: 1-18 - uint16_t freq_domain;//Value: Up to the 12 LSBs, actual size is determined by the Row parameter - uint8_t symb_l0;//The time domain location l0 and firstOFDMSymbolInTimeDomain Value: 0->13 - uint8_t symb_l1;// - uint8_t cdm_type; - uint8_t freq_density;//The density field, p and comb offset (for dot5).0: dot5 (even RB), 1: dot5 (odd RB), 2: one, 3: three - uint16_t scramb_id;//ScramblingID of the CSI-RS [TS38.214, sec 5.2.2.3.1] Value: 0->1023 - //tx power info - uint8_t power_control_offset;//Ratio of PDSCH EPRE to NZP CSI-RSEPRE Value :0->23 representing -8 to 15 dB in 1dB steps - uint8_t power_control_offset_ss;//Ratio of SSB/PBCH block EPRE to NZP CSI-RS EPRES 0: -3dB, 1: 0dB, 2: 3dB, 3: 6dB - + uint8_t subcarrier_spacing; // subcarrierSpacing [3GPP TS 38.211, sec 4.2], Value:0->4 + uint8_t cyclic_prefix; // Cyclic prefix type [3GPP TS 38.211, sec 4.2], 0: Normal; 1: Extended + uint16_t start_rb; // PRB where this CSI resource starts related to common resource block #0 (CRB#0). Only multiples of 4 are allowed. [3GPP TS 38.331, sec 6.3.2 parameter CSIFrequencyOccupation], Value: 0 ->274 + uint16_t nr_of_rbs; // Number of PRBs across which this CSI resource spans. Only multiples of 4 are allowed. [3GPP TS 38.331, sec 6.3.2 parameter CSI-FrequencyOccupation], Value: 24 -> 276 + uint8_t csi_type; // CSI Type [3GPP TS 38.211, sec 7.4.1.5], Value: 0:TRS; 1:CSI-RS NZP; 2:CSI-RS ZP + uint8_t row; // Row entry into the CSI Resource location table. [3GPP TS 38.211, sec 7.4.1.5.3 and table 7.4.1.5.3-1], Value: 1-18 + uint16_t freq_domain; // Bitmap defining the frequencyDomainAllocation [3GPP TS 38.211, sec 7.4.1.5.3] [3GPP TS 38.331 CSIResourceMapping], Value: Up to the 12 LSBs, actual size is determined by the Row parameter + uint8_t symb_l0; // The time domain location l0 and firstOFDMSymbolInTimeDomain [3GPP TS 38.211, sec 7.4.1.5.3], Value: 0->13 + uint8_t symb_l1; // The time domain location l1 and firstOFDMSymbolInTimeDomain2 [3GPP TS 38.211, sec 7.4.1.5.3], Value: 2->12 + uint8_t cdm_type; // The cdm-Type field [3GPP TS 38.211, sec 7.4.1.5.3 and table 7.4.1.5.3-1], Value: 0: noCDM; 1: fd-CDM2; 2: cdm4-FD2-TD2; 3: cdm8-FD2-TD4 + uint8_t freq_density; // The density field, p and comb offset (for dot5). [3GPP TS 38.211, sec 7.4.1.5.3 and table 7.4.1.5.3-1], Value: 0: dot5 (even RB); 1: dot5 (odd RB); 2: one; 3: three + uint16_t scramb_id; // ScramblingID of the CSI-RS [3GPP TS 38.214, sec 5.2.2.3.1], Value: 0->1023 + uint8_t power_control_offset; // Ratio of PDSCH EPRE to NZP CSI-RSEPRE [3GPP TS 38.214, sec 5.2.2.3.1], Value: 0->23 representing -8 to 15 dB in 1dB steps; 255: L1 is configured with ProfileSSS + uint8_t power_control_offset_ss; // Ratio of NZP CSI-RS EPRE to SSB/PBCH block EPRE [3GPP TS 38.214, sec 5.2.2.3.1], Values: 0: -3dB; 1: 0dB; 2: 3dB; 3: 6dB; 255: L1 is configured with ProfileSSS } nfapi_nr_dl_tti_csi_rs_pdu_rel15_t; -//for ssb_pdu: typedef struct { @@ -1195,6 +1192,10 @@ typedef struct #define PUSCH_PDU_BITMAP_PUSCH_PTRS 0x4 #define PUSCH_PDU_BITMAP_DFTS_OFDM 0x8 +typedef struct { + uint32_t tbSizeLbrmBytes; +}nfapi_v3_pusch_maintenance_parameters_t; + typedef struct { uint16_t pdu_bit_map;//Bitmap indicating presence of optional PDUs (see above) @@ -1240,7 +1241,7 @@ typedef struct nfapi_nr_dfts_ofdm_t dfts_ofdm; //beamforming nfapi_nr_ul_beamforming_t beamforming; - + nfapi_v3_pdsch_maintenance_parameters_t maintenance_parms_v3; } nfapi_nr_pusch_pdu_t; //for pucch_pdu: diff --git a/nfapi/open-nFAPI/nfapi/src/nfapi.c b/nfapi/open-nFAPI/nfapi/src/nfapi.c index 2783781e2c..09c0229db0 100644 --- a/nfapi/open-nFAPI/nfapi/src/nfapi.c +++ b/nfapi/open-nFAPI/nfapi/src/nfapi.c @@ -1,783 +1,855 @@ -/* - * Copyright (c) 2001-2016, Cisco Systems, Inc. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * - * Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following - * disclaimer in the documentation and/or other materials provided - * with the distribution. - * - * Neither the name of the Cisco Systems, Inc. nor the names of its - * contributors may be used to endorse or promote products derived - * from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS - * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE - * COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, - * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES - * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR - * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, - * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED - * OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include -#include -#include - - -// Fundamental routines - -uint8_t push8(uint8_t in, uint8_t **out, uint8_t *end) { - uint8_t *pOut = *out; - - if((end - pOut) >= 1) { - pOut[0] = in; - (*out)+=1; - return 1; - } else { - NFAPI_TRACE(NFAPI_TRACE_ERROR, "%s no space in buffer\n", __FUNCTION__); - return 0; - } -} - -uint8_t pushs8(int8_t in, uint8_t **out, uint8_t *end) { - uint8_t *pOut = *out; - - if((end - pOut) >= 1) { - pOut[0] = in; - (*out)+=1; - return 1; - } else { - NFAPI_TRACE(NFAPI_TRACE_ERROR, "%s no space in buffer\n", __FUNCTION__); - return 0; - } -} - -uint8_t push16(uint16_t in, uint8_t **out, uint8_t *end) { - uint8_t *pOut = *out; - - if((end - pOut) >= 2) { - pOut[0] = (in & 0xFF00) >> 8; - pOut[1] = (in & 0xFF); - (*out)+=2; - return 2; - } else { - NFAPI_TRACE(NFAPI_TRACE_ERROR, "%s no space in buffer\n", __FUNCTION__); - return 0; - } -} - -uint8_t pushs16(int16_t in, uint8_t **out, uint8_t *end) { - uint8_t *pOut = *out; - - if((end - pOut) >= 2) { - pOut[0] = (in & 0xFF00) >> 8; - pOut[1] = (in & 0xFF); - (*out)+=2; - return 2; - } else { - NFAPI_TRACE(NFAPI_TRACE_ERROR, "%s no space in buffer\n", __FUNCTION__); - return 0; - } -} - -uint8_t push32(uint32_t in, uint8_t **out, uint8_t *end) { - uint8_t *pOut = *out; - - if((end - pOut) >= 4) { - pOut[0] = (in & 0xFF000000) >> 24; - pOut[1] = (in & 0xFF0000) >> 16; - pOut[2] = (in & 0xFF00) >> 8; - pOut[3] = (in & 0xFF); - (*out)+=4; - return 4; - } else { - NFAPI_TRACE(NFAPI_TRACE_ERROR, "%s no space in buffer\n", __FUNCTION__); - return 0; - } -} - -uint8_t pushs32(int32_t in, uint8_t **out, uint8_t *end) { - uint8_t *pOut = *out; - - if((end - pOut) >= 4) { - pOut[0] = (in & 0xFF000000) >> 24; - pOut[1] = (in & 0xFF0000) >> 16; - pOut[2] = (in & 0xFF00) >> 8; - pOut[3] = (in & 0xFF); - (*out)+=4; - return 4; - } else { - NFAPI_TRACE(NFAPI_TRACE_ERROR, "%s no space in buffer\n", __FUNCTION__); - return 0; - } -} - -uint8_t pull8(uint8_t **in, uint8_t *out, uint8_t *end) { - uint8_t *pIn = *in; - - if((end - pIn) >= 1 ) { - *out = *pIn; - (*in)+=1; - return 1; - } else { - NFAPI_TRACE(NFAPI_TRACE_ERROR, "%s no space in buffer\n", __FUNCTION__); - return 0; - } -} - -uint8_t pulls8(uint8_t **in, int8_t *out, uint8_t *end) { - uint8_t *pIn = *in; - - if((end - pIn) >= 1 ) { - *out = *pIn; - (*in)+=1; - return 1; - } else { - NFAPI_TRACE(NFAPI_TRACE_ERROR, "%s no space in buffer\n", __FUNCTION__); - return 0; - } -} - -uint8_t pull16(uint8_t **in, uint16_t *out, uint8_t *end) { - uint8_t *pIn = *in; - - if((end - pIn) >=2 ) { - *out = ((pIn[0]) << 8) | pIn[1]; - (*in)+=2; - return 2; - } else { - NFAPI_TRACE(NFAPI_TRACE_ERROR, "%s no space in buffer\n", __FUNCTION__); - return 0; - } -} - -uint8_t pulls16(uint8_t **in, int16_t *out, uint8_t *end) { - uint8_t *pIn = *in; - - if((end - pIn) >=2 ) { - *out = ((pIn[0]) << 8) | pIn[1]; - (*in)+=2; - return 2; - } else { - NFAPI_TRACE(NFAPI_TRACE_ERROR, "%s no space in buffer\n", __FUNCTION__); - return 0; - } -} - -uint8_t pull32(uint8_t **in, uint32_t *out, uint8_t *end) { - uint8_t *pIn = *in; - - if((end - pIn) >=4 ) { - *out = (pIn[0] << 24) | (pIn[1] << 16) | (pIn[2] << 8) | pIn[3]; - (*in)+=4; - return 4; - } else { - NFAPI_TRACE(NFAPI_TRACE_ERROR, "%s no space in buffer\n", __FUNCTION__); - return 0; - } -} - -uint8_t pulls32(uint8_t **in, int32_t *out, uint8_t *end) { - uint8_t *pIn = *in; - - if((end - pIn) >=4 ) { - *out = (pIn[0] << 24) | (pIn[1] << 16) | (pIn[2] << 8) | pIn[3]; - (*in)+=4; - return 4; - } else { - NFAPI_TRACE(NFAPI_TRACE_ERROR, "%s no space in buffer\n", __FUNCTION__); - return 0; - } -} - -/* -inline void pusharray16(uint8_t **, uint16_t, uint32_t len) -{ -} -*/ - -uint32_t pullarray16(uint8_t **in, uint16_t out[], uint32_t max_len, uint32_t len, uint8_t *end) { - if(len == 0) - return 1; - - if(len > max_len) { - NFAPI_TRACE(NFAPI_TRACE_ERROR, "%s exceed array size (%d > %d)\n", __FUNCTION__, len, max_len); - return 0; - } - - if((end - (*in)) >= sizeof(uint16_t) * len) { - uint32_t idx; - - for(idx = 0; idx < len; ++idx) { - if(!pull16(in, &out[idx], end)) - return 0; - } - - return sizeof(uint16_t) * len; - } else { - NFAPI_TRACE(NFAPI_TRACE_ERROR, "%s no space in buffer\n", __FUNCTION__); - return 0; - } -} - -uint32_t pullarrays16(uint8_t **in, int16_t out[], uint32_t max_len, uint32_t len, uint8_t *end) { - if(len == 0) - return 1; - - if(len > max_len) { - NFAPI_TRACE(NFAPI_TRACE_ERROR, "%s exceed array size (%d > %d)\n", __FUNCTION__, len, max_len); - return 0; - } - - if((end - (*in)) >= sizeof(uint16_t) * len) { - uint32_t idx; - - for(idx = 0; idx < len; ++idx) { - if(!pulls16(in, &out[idx], end)) - return 0; - } - - return sizeof(uint16_t) * len; - } else { - NFAPI_TRACE(NFAPI_TRACE_ERROR, "%s no space in buffer\n", __FUNCTION__); - return 0; - } -} -uint32_t pusharray16(uint16_t in[], uint32_t max_len, uint32_t len, uint8_t **out, uint8_t *end) { - if(len == 0) - return 1; - - if(len > max_len) { - NFAPI_TRACE(NFAPI_TRACE_ERROR, "%s exceed array size (%d > %d)\n", __FUNCTION__, len, max_len); - return 0; - } - - if((end - (*out)) >= sizeof(uint16_t) * len) { - uint32_t idx; - - for(idx = 0; idx < len; ++idx) { - if(!push16(in[idx], out, end)) - return 0; - } - - return sizeof(uint16_t) * len; - } else { - NFAPI_TRACE(NFAPI_TRACE_ERROR, "%s no space in buffer\n", __FUNCTION__); - return 0; - } -} -uint32_t pusharrays16(int16_t in[], uint32_t max_len, uint32_t len, uint8_t **out, uint8_t *end) { - if(len == 0) - return 1; - - if(len > max_len) { - NFAPI_TRACE(NFAPI_TRACE_ERROR, "%s exceed array size (%d > %d)\n", __FUNCTION__, len, max_len); - return 0; - } - - if((end - (*out)) >= sizeof(uint16_t) * len) { - uint32_t idx; - - for(idx = 0; idx < len; ++idx) { - pushs16(in[idx], out, end); - } - - return sizeof(uint16_t) * len; - } else { - NFAPI_TRACE(NFAPI_TRACE_ERROR, "%s no space in buffer\n", __FUNCTION__); - return 0; - } -} -uint32_t pullarray32(uint8_t **in, uint32_t out[], uint32_t max_len, uint32_t len, uint8_t *end) { - if(len == 0) - return 1; - - if(len > max_len) { - NFAPI_TRACE(NFAPI_TRACE_ERROR, "%s exceed array size (%d > %d)\n", __FUNCTION__, len, max_len); - return 0; - } - - if((end - (*in)) >= sizeof(uint32_t) * len) { - uint32_t idx; - - for(idx = 0; idx < len; ++idx) { - if(!pull32(in, &out[idx], end)) - return 0; - } - - return sizeof(uint32_t) * len; - } else { - NFAPI_TRACE(NFAPI_TRACE_ERROR, "%s no space in buffer\n", __FUNCTION__); - return 0; - } -} - -uint32_t pullarrays32(uint8_t **in, int32_t out[], uint32_t max_len, uint32_t len, uint8_t *end) { - if(len == 0) - return 1; - - if(len > max_len) { - NFAPI_TRACE(NFAPI_TRACE_ERROR, "%s exceed array size (%d > %d)\n", __FUNCTION__, len, max_len); - return 0; - } - - if((end - (*in)) >= sizeof(uint32_t) * len) { - uint32_t idx; - - for(idx = 0; idx < len; ++idx) { - if(!pulls32(in, &out[idx], end)) - return 0; - } - - return sizeof(uint32_t) * len; - } else { - NFAPI_TRACE(NFAPI_TRACE_ERROR, "%s no space in buffer\n", __FUNCTION__); - return 0; - } -} -uint32_t pusharray32(uint32_t in[], uint32_t max_len, uint32_t len, uint8_t **out, uint8_t *end) { - if(len == 0) - return 1; - - if(len > max_len) { - NFAPI_TRACE(NFAPI_TRACE_ERROR, "%s exceed array size (%d > %d)\n", __FUNCTION__, len, max_len); - return 0; - } - - if((end - (*out)) >= sizeof(uint32_t) * len) { - uint32_t idx; - - for(idx = 0; idx < len; ++idx) { - if(!push32(in[idx], out, end)) - return 0; - } - - return sizeof(uint32_t) * len; - } else { - NFAPI_TRACE(NFAPI_TRACE_ERROR, "%s no space in buffer\n", __FUNCTION__); - return 0; - } -} -uint32_t pusharrays32(int32_t in[], uint32_t max_len, uint32_t len, uint8_t **out, uint8_t *end) { - if(len == 0) - return 1; - - if(len > max_len) { - NFAPI_TRACE(NFAPI_TRACE_ERROR, "%s exceed array size (%d > %d)\n", __FUNCTION__, len, max_len); - return 0; - } - - if((end - (*out)) >= sizeof(uint32_t) * len) { - uint32_t idx; - - for(idx = 0; idx < len; ++idx) { - pushs32(in[idx], out, end); - } - - return sizeof(uint32_t) * len; - } else { - NFAPI_TRACE(NFAPI_TRACE_ERROR, "%s no space in buffer\n", __FUNCTION__); - return 0; - } -} -uint32_t pullarray8(uint8_t **in, uint8_t out[], uint32_t max_len, uint32_t len, uint8_t *end) { - if(len == 0) - return 1; - - if(len > max_len) { - NFAPI_TRACE(NFAPI_TRACE_ERROR, "%s exceed array size (%d > %d)\n", __FUNCTION__, len, max_len); - return 0; - } - - if((end - (*in)) >= sizeof(uint8_t) * len) { - memcpy(out, (*in), len); - (*in)+=len; - return sizeof(uint8_t) * len; - } else { - NFAPI_TRACE(NFAPI_TRACE_ERROR, "%s no space in buffer\n", __FUNCTION__); - return 0; - } -} - -uint32_t pusharray8(uint8_t in[], uint32_t max_len, uint32_t len, uint8_t **out, uint8_t *end) { - if(len == 0) - return 1; - - if(len > max_len) { - NFAPI_TRACE(NFAPI_TRACE_ERROR, "%s exceed array size (%d > %d)\n", __FUNCTION__, len, max_len); - return 0; - } - - if((end - (*out)) >= sizeof(uint8_t) * len) { - memcpy((*out), in, len); - (*out)+=len; - return sizeof(uint8_t) * len; - } else { - NFAPI_TRACE(NFAPI_TRACE_ERROR, "%s no space in buffer\n", __FUNCTION__); - return 0; - } -} - -uint8_t packarray(void *array, uint16_t array_element_size, uint16_t max_count, uint16_t count, uint8_t **ppwritepackedmsg, uint8_t *end, pack_array_elem_fn fn) { - if(count > max_count) { - NFAPI_TRACE(NFAPI_TRACE_ERROR, "%s exceed array size (%d > %d)\n", __FUNCTION__, count, max_count); - return 0; - } - - uint16_t i = 0; - - for(i = 0; i < count; ++i) { - if((fn)(array, ppwritepackedmsg, end) == 0) - return 0; - - array += array_element_size; - } - - return 1; -} - -uint8_t unpackarray(uint8_t **ppReadPackedMsg, void *array, uint16_t array_element_size, uint16_t max_count, uint16_t count, uint8_t *end, unpack_array_elem_fn fn) { - if(count > max_count) { - NFAPI_TRACE(NFAPI_TRACE_ERROR, "%s exceed array size (%d > %d)\n", __FUNCTION__, count, max_count); - return 0; - } - - uint16_t i = 0; - - for(i = 0; i < count; ++i) { - if((fn)(array, ppReadPackedMsg, end) == 0) - return 0; - - array += array_element_size; - } - - return 1; -} - - -uint32_t pack_vendor_extension_tlv(nfapi_tl_t *ve, uint8_t **ppWritePackedMsg, uint8_t *end, nfapi_p4_p5_codec_config_t *config) { - if(ve != 0 && config != 0) { - if(config->pack_vendor_extension_tlv) { - uint8_t *pStartOfTlv = *ppWritePackedMsg; - - if(pack_tl(ve, ppWritePackedMsg, end) == 0) - return 0; - - uint8_t *pStartOfValue = *ppWritePackedMsg; - - if((config->pack_vendor_extension_tlv)(ve, ppWritePackedMsg, end, config) == 0) - return 0; - - ve->length = (*ppWritePackedMsg) - pStartOfValue; - pack_tl(ve, &pStartOfTlv, end); - return 1; - } - } - - return 1; -} - -uint32_t unpack_vendor_extension_tlv(nfapi_tl_t *tl, uint8_t **ppReadPackedMsg, uint8_t *end, nfapi_p4_p5_codec_config_t *config, nfapi_tl_t **ve_tlv) { - if(ve_tlv != 0 && config != 0) { - if(config->unpack_vendor_extension_tlv) { - return (config->unpack_vendor_extension_tlv)(tl, ppReadPackedMsg, end, (void **)ve_tlv, config); - } - } - - return 1; -} - -uint32_t pack_p7_vendor_extension_tlv(nfapi_tl_t *ve, uint8_t **ppWritePackedMsg, uint8_t *end,nfapi_p7_codec_config_t *config) { - if(ve != 0 && config != 0) { - if(config->pack_vendor_extension_tlv) { - uint8_t *pStartOfTlv = *ppWritePackedMsg; - - if(pack_tl(ve, ppWritePackedMsg, end) == 0) - return 0; - - uint8_t *pStartOfValue = *ppWritePackedMsg; - - if((config->pack_vendor_extension_tlv)(ve, ppWritePackedMsg, end, config) == 0) - return 0; - - ve->length = (*ppWritePackedMsg) - pStartOfValue; - pack_tl(ve, &pStartOfTlv, end); - return 1; - } - } - - return 1; -} - -int unpack_p7_vendor_extension_tlv(nfapi_tl_t *tl, uint8_t **ppReadPackedMsg, uint8_t *end, nfapi_p7_codec_config_t *config, nfapi_tl_t **ve_tlv) { - if(ve_tlv != 0 && config != 0) { - if(config->unpack_vendor_extension_tlv) { - return (config->unpack_vendor_extension_tlv)(tl, ppReadPackedMsg, end, (void **)ve_tlv, config); - } - } - - return 1; -} - - -uint8_t pack_tl(nfapi_tl_t *tl, uint8_t **ppWritePackedMsg, uint8_t *end) { - return (push16(tl->tag, ppWritePackedMsg, end) && - push16(tl->length, ppWritePackedMsg, end)); -} - -uint8_t unpack_tl(uint8_t **ppReadPackedMsg, nfapi_tl_t *tl, uint8_t *end) { - return (pull16(ppReadPackedMsg, &tl->tag, end) && - pull16(ppReadPackedMsg, &tl->length, end)); -} - -int unpack_tlv_list(unpack_tlv_t unpack_fns[], uint16_t size, uint8_t **ppReadPackedMsg, uint8_t *end, nfapi_p4_p5_codec_config_t *config, nfapi_tl_t **ve) { - nfapi_tl_t generic_tl; - uint8_t numBadTags = 0; - uint16_t idx = 0; - - while ((uint8_t *)(*ppReadPackedMsg) < end) { - // unpack the tl and process the values accordingly - if(unpack_tl(ppReadPackedMsg, &generic_tl, end) == 0) - return 0; - - uint8_t tagMatch = 0; - uint8_t *pStartOfValue = *ppReadPackedMsg; - - for(idx = 0; idx < size; ++idx) { - if(unpack_fns[idx].tag == generic_tl.tag) { // match the extracted tag value with all the tags in unpack_fn list - tagMatch = 1; - nfapi_tl_t *tl = (nfapi_tl_t *)(unpack_fns[idx].tlv); - tl->tag = generic_tl.tag; - tl->length = generic_tl.length; - int result = (*unpack_fns[idx].unpack_func)(tl, ppReadPackedMsg, end); - - if(result == 0) { - return 0; - } - - // check if the length was right; - if(tl->length != (*ppReadPackedMsg - pStartOfValue)) { - NFAPI_TRACE(NFAPI_TRACE_ERROR, "Warning tlv tag 0x%x length %d not equal to unpack %ld\n", tl->tag, tl->length, (*ppReadPackedMsg - pStartOfValue)); - } - } - } - - if(tagMatch == 0) { - if(generic_tl.tag >= NFAPI_VENDOR_EXTENSION_MIN_TAG_VALUE && - generic_tl.tag <= NFAPI_VENDOR_EXTENSION_MAX_TAG_VALUE) { - int result = unpack_vendor_extension_tlv(&generic_tl, ppReadPackedMsg, end, config, ve); - - if(result == 0) { - // got tot the end. - return 0; - } else if(result < 0) { - NFAPI_TRACE(NFAPI_TRACE_ERROR, "Unknown VE TAG value: 0x%04x\n", generic_tl.tag); - - if (++numBadTags > MAX_BAD_TAG) { - NFAPI_TRACE(NFAPI_TRACE_ERROR, "Supplied message has had too many bad tags\n"); - return 0; - } - - if((end - *ppReadPackedMsg) >= generic_tl.length) { - // Advance past the unknown TLV - (*ppReadPackedMsg) += generic_tl.length; - } else { - // go to the end - return 0; - } - } - } else { - NFAPI_TRACE(NFAPI_TRACE_ERROR, "Unknown TAG value: 0x%04x\n", generic_tl.tag); - - if (++numBadTags > MAX_BAD_TAG) { - NFAPI_TRACE(NFAPI_TRACE_ERROR, "Supplied message has had too many bad tags\n"); - return 0; - } - - if((end - *ppReadPackedMsg) >= generic_tl.length) { - // Advance past the unknown TLV - (*ppReadPackedMsg) += generic_tl.length; - } else { - // go to the end - return 0; - } - } - } - } - - return 1; -} -int unpack_p7_tlv_list(unpack_p7_tlv_t unpack_fns[], uint16_t size, uint8_t **ppReadPackedMsg, uint8_t *end, nfapi_p7_codec_config_t *config, nfapi_tl_t **ve) { - nfapi_tl_t generic_tl; - uint8_t numBadTags = 0; - uint16_t idx = 0; - - while ((uint8_t *)(*ppReadPackedMsg) < end) { - // unpack the tl and process the values accordingly - if(unpack_tl(ppReadPackedMsg, &generic_tl, end) == 0) - return 0; - - uint8_t tagMatch = 0; - uint8_t *pStartOfValue = *ppReadPackedMsg; - - for(idx = 0; idx < size; ++idx) { - if(unpack_fns[idx].tag == generic_tl.tag) { - tagMatch = 1; - nfapi_tl_t *tl = (nfapi_tl_t *)(unpack_fns[idx].tlv); - tl->tag = generic_tl.tag; - tl->length = generic_tl.length; - int result = (*unpack_fns[idx].unpack_func)(tl, ppReadPackedMsg, end, config); - - if(result == 0) { - return 0; - } - - // check if the length was right; - if(tl->length != (*ppReadPackedMsg - pStartOfValue)) { - NFAPI_TRACE(NFAPI_TRACE_ERROR, "Warning tlv tag 0x%x length %d not equal to unpack %ld\n", tl->tag, tl->length, (*ppReadPackedMsg - pStartOfValue)); - } - } - } - - if(tagMatch == 0) { - if(generic_tl.tag >= NFAPI_VENDOR_EXTENSION_MIN_TAG_VALUE && - generic_tl.tag <= NFAPI_VENDOR_EXTENSION_MAX_TAG_VALUE) { - int result = unpack_p7_vendor_extension_tlv(&generic_tl, ppReadPackedMsg, end, config, ve); - - if(result == 0) { - // got to end - return 0; - } else if(result < 0) { - NFAPI_TRACE(NFAPI_TRACE_ERROR, "Unknown TAG value: 0x%04x\n", generic_tl.tag); - - if (++numBadTags > MAX_BAD_TAG) { - NFAPI_TRACE(NFAPI_TRACE_ERROR, "Supplied message has had too many bad tags\n"); - return -1; - } - - if((end - *ppReadPackedMsg) >= generic_tl.length) { - // Advance past the unknown TLV - (*ppReadPackedMsg) += generic_tl.length; - } else { - // got ot the dn - return 0; - } - } - } else { - NFAPI_TRACE(NFAPI_TRACE_ERROR, "Unknown TAG value: 0x%04x\n", generic_tl.tag); - - if (++numBadTags > MAX_BAD_TAG) { - NFAPI_TRACE(NFAPI_TRACE_ERROR, "Supplied message has had too many bad tags\n"); - return -1; - } - - if((end - *ppReadPackedMsg) >= generic_tl.length) { - // Advance past the unknown TLV - (*ppReadPackedMsg) += generic_tl.length; - } else { - // got ot the dn - return 0; - } - } - } - } - - return 1; -} - -// This intermediate function deals with calculating the length of the value -// and writing into the tlv header. -uint8_t pack_tlv(uint16_t tag, void *tlv, uint8_t **ppWritePackedMsg, uint8_t *end, pack_tlv_fn fn) { - nfapi_tl_t *tl = (nfapi_tl_t *)tlv; - - // If the tag is defined - if(tl->tag == tag) { - uint8_t *pStartOfTlv = *ppWritePackedMsg; - - // write a dumy tlv header - if(pack_tl(tl, ppWritePackedMsg, end) == 0) - return 0; - - // Record the start of the value - uint8_t *pStartOfValue = *ppWritePackedMsg; - - // pack the tlv value - if(fn(tlv, ppWritePackedMsg, end) == 0) - return 0; - - // calculate the length of the value and rewrite the tl header - tl->length = (*ppWritePackedMsg) - pStartOfValue; - // rewrite the header with the correct length - pack_tl(tl, &pStartOfTlv, end); - } else { - if(tl->tag != 0) { - NFAPI_TRACE(NFAPI_TRACE_WARN, "Warning pack_tlv tag 0x%x does not match expected 0x%x\n", tl->tag, tag); - } else { - //NFAPI_TRACE(NFAPI_TRACE_ERROR, "Warning pack_tlv tag 0x%x ZERO does not match expected 0x%x\n", tl->tag, tag); - } - } - - return 1; -} - -const char *nfapi_error_code_to_str(nfapi_error_code_e value) { - switch(value) { - case NFAPI_MSG_OK: - return "NFAPI_MSG_OK"; - - case NFAPI_MSG_INVALID_STATE: - return "NFAPI_MSG_INVALID_STATE"; - - case NFAPI_MSG_INVALID_CONFIG: - return "NFAPI_MSG_INVALID_CONFIG"; - - case NFAPI_SFN_OUT_OF_SYNC: - return "NFAPI_SFN_OUT_OF_SYNC"; - - case NFAPI_MSG_SUBFRAME_ERR: - return "NFAPI_MSG_SUBFRAME_ERR"; - - case NFAPI_MSG_BCH_MISSING: - return "NFAPI_MSG_BCH_MISSING"; - - case NFAPI_MSG_INVALID_SFN: - return "NFAPI_MSG_INVALID_SFN"; - - case NFAPI_MSG_HI_ERR: - return "NFAPI_MSG_HI_ERR"; - - case NFAPI_MSG_TX_ERR: - return "NFAPI_MSG_TX_ERR"; - - default: - return "UNKNOWN"; - } -} +/* + * Copyright (c) 2001-2016, Cisco Systems, Inc. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * + * Redistributions in binary form must reproduce the above + * copyright notice, this list of conditions and the following + * disclaimer in the documentation and/or other materials provided + * with the distribution. + * + * Neither the name of the Cisco Systems, Inc. nor the names of its + * contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS + * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE + * COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, + * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, + * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED + * OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include +#include + +// What to do when an error happens (e.g., a push or pull fails) +static inline void on_error() +{ + // show the call stack + int fd = STDERR_FILENO; + static const char msg[] = "---stack trace---\n"; + __attribute__((unused)) int r = + write(fd, msg, sizeof(msg) - 1); + void *buffer[100]; + int nptrs = backtrace(buffer, sizeof(buffer) / sizeof(buffer[0])); + backtrace_symbols_fd(buffer, nptrs, fd); + + //abort(); +} + +// Fundamental routines + +uint8_t push8(uint8_t in, uint8_t **out, uint8_t *end) { + uint8_t *pOut = *out; + + if((end - pOut) >= 1) { + pOut[0] = in; + (*out)+=1; + return 1; + } else { + NFAPI_TRACE(NFAPI_TRACE_ERROR, "%s no space in buffer\n", __FUNCTION__); + on_error(); + return 0; + } +} + +uint8_t pushs8(int8_t in, uint8_t **out, uint8_t *end) { + uint8_t *pOut = *out; + + if((end - pOut) >= 1) { + pOut[0] = in; + (*out)+=1; + return 1; + } else { + NFAPI_TRACE(NFAPI_TRACE_ERROR, "%s no space in buffer\n", __FUNCTION__); + on_error(); + return 0; + } +} + +uint8_t push16(uint16_t in, uint8_t **out, uint8_t *end) { + uint8_t *pOut = *out; + + if((end - pOut) >= 2) { + pOut[0] = (in & 0xFF00) >> 8; + pOut[1] = (in & 0xFF); + (*out)+=2; + return 2; + } else { + NFAPI_TRACE(NFAPI_TRACE_ERROR, "%s no space in buffer\n", __FUNCTION__); + on_error(); + return 0; + } +} + +uint8_t pushs16(int16_t in, uint8_t **out, uint8_t *end) { + uint8_t *pOut = *out; + + if((end - pOut) >= 2) { + pOut[0] = (in & 0xFF00) >> 8; + pOut[1] = (in & 0xFF); + (*out)+=2; + return 2; + } else { + NFAPI_TRACE(NFAPI_TRACE_ERROR, "%s no space in buffer\n", __FUNCTION__); + on_error(); + return 0; + } +} + +uint8_t push32(uint32_t in, uint8_t **out, uint8_t *end) { + uint8_t *pOut = *out; + + if((end - pOut) >= 4) { + pOut[0] = (in & 0xFF000000) >> 24; + pOut[1] = (in & 0xFF0000) >> 16; + pOut[2] = (in & 0xFF00) >> 8; + pOut[3] = (in & 0xFF); + (*out)+=4; + return 4; + } else { + NFAPI_TRACE(NFAPI_TRACE_ERROR, "%s no space in buffer\n", __FUNCTION__); + on_error(); + return 0; + } +} + +uint8_t pushs32(int32_t in, uint8_t **out, uint8_t *end) { + uint8_t *pOut = *out; + + if((end - pOut) >= 4) { + pOut[0] = (in & 0xFF000000) >> 24; + pOut[1] = (in & 0xFF0000) >> 16; + pOut[2] = (in & 0xFF00) >> 8; + pOut[3] = (in & 0xFF); + (*out)+=4; + return 4; + } else { + NFAPI_TRACE(NFAPI_TRACE_ERROR, "%s no space in buffer\n", __FUNCTION__); + on_error(); + return 0; + } +} + +uint8_t pull8(uint8_t **in, uint8_t *out, uint8_t *end) { + uint8_t *pIn = *in; + + if((end - pIn) >= 1 ) { + *out = *pIn; + (*in)+=1; + return 1; + } else { + NFAPI_TRACE(NFAPI_TRACE_ERROR, "%s no space in buffer\n", __FUNCTION__); + on_error(); + return 0; + } +} + +uint8_t pulls8(uint8_t **in, int8_t *out, uint8_t *end) { + uint8_t *pIn = *in; + + if((end - pIn) >= 1 ) { + *out = *pIn; + (*in)+=1; + return 1; + } else { + NFAPI_TRACE(NFAPI_TRACE_ERROR, "%s no space in buffer\n", __FUNCTION__); + on_error(); + return 0; + } +} + +uint8_t pull16(uint8_t **in, uint16_t *out, uint8_t *end) { + uint8_t *pIn = *in; + + if((end - pIn) >=2 ) { + *out = ((pIn[0]) << 8) | pIn[1]; + (*in)+=2; + return 2; + } else { + NFAPI_TRACE(NFAPI_TRACE_ERROR, "%s no space in buffer\n", __FUNCTION__); + on_error(); + return 0; + } +} + +uint8_t pulls16(uint8_t **in, int16_t *out, uint8_t *end) { + uint8_t *pIn = *in; + + if((end - pIn) >=2 ) { + *out = ((pIn[0]) << 8) | pIn[1]; + (*in)+=2; + return 2; + } else { + NFAPI_TRACE(NFAPI_TRACE_ERROR, "%s no space in buffer\n", __FUNCTION__); + on_error(); + return 0; + } +} + +uint8_t pull32(uint8_t **in, uint32_t *out, uint8_t *end) { + uint8_t *pIn = *in; + + if((end - pIn) >=4 ) { + *out = (pIn[0] << 24) | (pIn[1] << 16) | (pIn[2] << 8) | pIn[3]; + (*in)+=4; + return 4; + } else { + NFAPI_TRACE(NFAPI_TRACE_ERROR, "%s no space in buffer\n", __FUNCTION__); + on_error(); + return 0; + } +} + +uint8_t pulls32(uint8_t **in, int32_t *out, uint8_t *end) { + uint8_t *pIn = *in; + + if((end - pIn) >=4 ) { + *out = (pIn[0] << 24) | (pIn[1] << 16) | (pIn[2] << 8) | pIn[3]; + (*in)+=4; + return 4; + } else { + NFAPI_TRACE(NFAPI_TRACE_ERROR, "%s no space in buffer\n", __FUNCTION__); + on_error(); + return 0; + } +} + +/* +inline void pusharray16(uint8_t **, uint16_t, uint32_t len) +{ +} +*/ + +uint32_t pullarray16(uint8_t **in, uint16_t out[], uint32_t max_len, uint32_t len, uint8_t *end) { + if(len == 0) + return 1; + + if(len > max_len) { + NFAPI_TRACE(NFAPI_TRACE_ERROR, "%s exceed array size (%d > %d)\n", __FUNCTION__, len, max_len); + on_error(); + return 0; + } + + if((end - (*in)) >= sizeof(uint16_t) * len) { + uint32_t idx; + + for(idx = 0; idx < len; ++idx) { + if(!pull16(in, &out[idx], end)) + return 0; + } + + return sizeof(uint16_t) * len; + } else { + NFAPI_TRACE(NFAPI_TRACE_ERROR, "%s no space in buffer\n", __FUNCTION__); + on_error(); + return 0; + } +} + +uint32_t pullarrays16(uint8_t **in, int16_t out[], uint32_t max_len, uint32_t len, uint8_t *end) { + if(len == 0) + return 1; + + if(len > max_len) { + NFAPI_TRACE(NFAPI_TRACE_ERROR, "%s exceed array size (%d > %d)\n", __FUNCTION__, len, max_len); + on_error(); + return 0; + } + + if((end - (*in)) >= sizeof(uint16_t) * len) { + uint32_t idx; + + for(idx = 0; idx < len; ++idx) { + if(!pulls16(in, &out[idx], end)) + return 0; + } + + return sizeof(uint16_t) * len; + } else { + NFAPI_TRACE(NFAPI_TRACE_ERROR, "%s no space in buffer\n", __FUNCTION__); + on_error(); + return 0; + } +} +uint32_t pusharray16(uint16_t in[], uint32_t max_len, uint32_t len, uint8_t **out, uint8_t *end) { + if(len == 0) + return 1; + + if(len > max_len) { + NFAPI_TRACE(NFAPI_TRACE_ERROR, "%s exceed array size (%d > %d)\n", __FUNCTION__, len, max_len); + on_error(); + return 0; + } + + if((end - (*out)) >= sizeof(uint16_t) * len) { + uint32_t idx; + + for(idx = 0; idx < len; ++idx) { + if(!push16(in[idx], out, end)) + return 0; + } + + return sizeof(uint16_t) * len; + } else { + NFAPI_TRACE(NFAPI_TRACE_ERROR, "%s no space in buffer\n", __FUNCTION__); + on_error(); + return 0; + } +} +uint32_t pusharrays16(int16_t in[], uint32_t max_len, uint32_t len, uint8_t **out, uint8_t *end) { + if(len == 0) + return 1; + + if(len > max_len) { + NFAPI_TRACE(NFAPI_TRACE_ERROR, "%s exceed array size (%d > %d)\n", __FUNCTION__, len, max_len); + on_error(); + return 0; + } + + if((end - (*out)) >= sizeof(uint16_t) * len) { + uint32_t idx; + + for(idx = 0; idx < len; ++idx) { + if (!pushs16(in[idx], out, end)) + return 0; + } + + return sizeof(uint16_t) * len; + } else { + NFAPI_TRACE(NFAPI_TRACE_ERROR, "%s no space in buffer\n", __FUNCTION__); + on_error(); + return 0; + } +} +uint32_t pullarray32(uint8_t **values_to_pull, + uint32_t out[], + uint32_t max_num_values_to_pull, + uint32_t num_values_to_pull, + uint8_t *out_end) { + if (num_values_to_pull == 0) + + return 1; + + if (num_values_to_pull > max_num_values_to_pull) { + NFAPI_TRACE(NFAPI_TRACE_ERROR, "%s exceed array size (%d > %d)\n", + __FUNCTION__, num_values_to_pull, max_num_values_to_pull); + on_error(); + return 0; + } + + if ((out_end - (*values_to_pull)) >= sizeof(uint32_t) * num_values_to_pull) { + uint32_t idx; + + for (idx = 0; idx < num_values_to_pull; ++idx) { + if (!pull32(values_to_pull, &out[idx], out_end)) + return 0; + } + + return sizeof(uint32_t) * num_values_to_pull; + } else { + NFAPI_TRACE(NFAPI_TRACE_ERROR, "%s no space in buffer\n", __FUNCTION__); + on_error(); + return 0; + } +} + +uint32_t pullarrays32(uint8_t **in, int32_t out[], uint32_t max_len, uint32_t len, uint8_t *end) { + if(len == 0) + return 1; + + if(len > max_len) { + NFAPI_TRACE(NFAPI_TRACE_ERROR, "%s exceed array size (%d > %d)\n", __FUNCTION__, len, max_len); + on_error(); + return 0; + } + + if((end - (*in)) >= sizeof(uint32_t) * len) { + uint32_t idx; + + for(idx = 0; idx < len; ++idx) { + if(!pulls32(in, &out[idx], end)) + return 0; + } + + return sizeof(uint32_t) * len; + } else { + NFAPI_TRACE(NFAPI_TRACE_ERROR, "%s no space in buffer\n", __FUNCTION__); + on_error(); + return 0; + } +} +uint32_t pusharray32(const uint32_t *values_to_push, + uint32_t max_num_values_to_push, + uint32_t num_values_to_push, + uint8_t **out, + uint8_t *out_end) { + if (num_values_to_push == 0) + return 1; + + if (num_values_to_push > max_num_values_to_push) { + NFAPI_TRACE(NFAPI_TRACE_ERROR, "%s exceed array size (%d > %d)\n", + __FUNCTION__, num_values_to_push, max_num_values_to_push); + on_error(); + return 0; + } + + if ((out_end - (*out)) >= sizeof(uint32_t) * num_values_to_push) { + uint32_t idx; + + for (idx = 0; idx < num_values_to_push; ++idx) { + if (!push32(values_to_push[idx], out, out_end)) + return 0; + } + + return sizeof(uint32_t) * num_values_to_push; + } else { + NFAPI_TRACE(NFAPI_TRACE_ERROR, "%s no space in buffer\n", __FUNCTION__); + on_error(); + return 0; + } +} +uint32_t pusharrays32(int32_t in[], uint32_t max_len, uint32_t len, uint8_t **out, uint8_t *end) { + if(len == 0) + return 1; + + if(len > max_len) { + NFAPI_TRACE(NFAPI_TRACE_ERROR, "%s exceed array size (%d > %d)\n", __FUNCTION__, len, max_len); + on_error(); + return 0; + } + + if((end - (*out)) >= sizeof(uint32_t) * len) { + uint32_t idx; + + for(idx = 0; idx < len; ++idx) { + if (!pushs32(in[idx], out, end)) + return 0; + } + + return sizeof(uint32_t) * len; + } else { + NFAPI_TRACE(NFAPI_TRACE_ERROR, "%s no space in buffer\n", __FUNCTION__); + on_error(); + return 0; + } +} +uint32_t pullarray8(uint8_t **in, uint8_t out[], uint32_t max_len, uint32_t len, uint8_t *end) { + if(len == 0) + return 1; + + if(len > max_len) { + NFAPI_TRACE(NFAPI_TRACE_ERROR, "%s exceed array size (%d > %d)\n", __FUNCTION__, len, max_len); + on_error(); + return 0; + } + + if((end - (*in)) >= sizeof(uint8_t) * len) { + memcpy(out, (*in), len); + (*in)+=len; + return sizeof(uint8_t) * len; + } else { + NFAPI_TRACE(NFAPI_TRACE_ERROR, "%s no space in buffer\n", __FUNCTION__); + on_error(); + return 0; + } +} + +uint32_t pusharray8(uint8_t in[], uint32_t max_len, uint32_t len, uint8_t **out, uint8_t *end) { + if(len == 0) + return 1; + + if(len > max_len) { + NFAPI_TRACE(NFAPI_TRACE_ERROR, "%s exceed array size (%d > %d)\n", __FUNCTION__, len, max_len); + on_error(); + return 0; + } + + if((end - (*out)) >= sizeof(uint8_t) * len) { + memcpy((*out), in, len); + (*out)+=len; + return sizeof(uint8_t) * len; + } else { + NFAPI_TRACE(NFAPI_TRACE_ERROR, "%s no space in buffer\n", __FUNCTION__); + on_error(); + return 0; + } +} + +uint8_t packarray(void *array, uint16_t array_element_size, uint16_t max_count, uint16_t count, uint8_t **ppwritepackedmsg, uint8_t *end, pack_array_elem_fn fn) { + if(count > max_count) { + NFAPI_TRACE(NFAPI_TRACE_ERROR, "%s exceed array size (%d > %d)\n", __FUNCTION__, count, max_count); + on_error(); + return 0; + } + + uint16_t i = 0; + + for(i = 0; i < count; ++i) { + if((fn)(array, ppwritepackedmsg, end) == 0) + return 0; + + array += array_element_size; + } + + return 1; +} + +uint8_t unpackarray(uint8_t **ppReadPackedMsg, void *array, uint16_t array_element_size, uint16_t max_count, uint16_t count, uint8_t *end, unpack_array_elem_fn fn) { + if(count > max_count) { + NFAPI_TRACE(NFAPI_TRACE_ERROR, "%s exceed array size (%d > %d)\n", __FUNCTION__, count, max_count); + on_error(); + return 0; + } + + uint16_t i = 0; + + for(i = 0; i < count; ++i) { + if((fn)(array, ppReadPackedMsg, end) == 0) + return 0; + + array += array_element_size; + } + + return 1; +} + + +uint32_t pack_vendor_extension_tlv(nfapi_tl_t *ve, uint8_t **ppWritePackedMsg, uint8_t *end, nfapi_p4_p5_codec_config_t *config) { + if(ve != 0 && config != 0) { + if(config->pack_vendor_extension_tlv) { + uint8_t *pStartOfTlv = *ppWritePackedMsg; + + if(pack_tl(ve, ppWritePackedMsg, end) == 0) + return 0; + + uint8_t *pStartOfValue = *ppWritePackedMsg; + + if((config->pack_vendor_extension_tlv)(ve, ppWritePackedMsg, end, config) == 0) + return 0; + + ve->length = (*ppWritePackedMsg) - pStartOfValue; + pack_tl(ve, &pStartOfTlv, end); + return 1; + } + } + + return 1; +} + +uint32_t unpack_vendor_extension_tlv(nfapi_tl_t *tl, uint8_t **ppReadPackedMsg, uint8_t *end, nfapi_p4_p5_codec_config_t *config, nfapi_tl_t **ve_tlv) { + if(ve_tlv != 0 && config != 0) { + if(config->unpack_vendor_extension_tlv) { + return (config->unpack_vendor_extension_tlv)(tl, ppReadPackedMsg, end, (void **)ve_tlv, config); + } + } + + return 1; +} + +uint32_t pack_p7_vendor_extension_tlv(nfapi_tl_t *ve, uint8_t **ppWritePackedMsg, uint8_t *end,nfapi_p7_codec_config_t *config) { + if(ve != 0 && config != 0) { + if(config->pack_vendor_extension_tlv) { + uint8_t *pStartOfTlv = *ppWritePackedMsg; + + if(pack_tl(ve, ppWritePackedMsg, end) == 0) + return 0; + + uint8_t *pStartOfValue = *ppWritePackedMsg; + + if((config->pack_vendor_extension_tlv)(ve, ppWritePackedMsg, end, config) == 0) + return 0; + + ve->length = (*ppWritePackedMsg) - pStartOfValue; + pack_tl(ve, &pStartOfTlv, end); + return 1; + } + } + + return 1; +} + +int unpack_p7_vendor_extension_tlv(nfapi_tl_t *tl, uint8_t **ppReadPackedMsg, uint8_t *end, nfapi_p7_codec_config_t *config, nfapi_tl_t **ve_tlv) { + if(ve_tlv != 0 && config != 0) { + if(config->unpack_vendor_extension_tlv) { + return (config->unpack_vendor_extension_tlv)(tl, ppReadPackedMsg, end, (void **)ve_tlv, config); + } + } + + return 1; +} + + +uint8_t pack_tl(nfapi_tl_t *tl, uint8_t **ppWritePackedMsg, uint8_t *end) { + return (push16(tl->tag, ppWritePackedMsg, end) && + push16(tl->length, ppWritePackedMsg, end)); +} + +uint8_t unpack_tl(uint8_t **ppReadPackedMsg, nfapi_tl_t *tl, uint8_t *end) { + return (pull16(ppReadPackedMsg, &tl->tag, end) && + pull16(ppReadPackedMsg, &tl->length, end)); +} + +int unpack_tlv_list(unpack_tlv_t unpack_fns[], uint16_t size, uint8_t **ppReadPackedMsg, uint8_t *end, nfapi_p4_p5_codec_config_t *config, nfapi_tl_t **ve) { + nfapi_tl_t generic_tl; + uint8_t numBadTags = 0; + uint16_t idx = 0; + + while ((uint8_t *)(*ppReadPackedMsg) < end) { + // unpack the tl and process the values accordingly + if(unpack_tl(ppReadPackedMsg, &generic_tl, end) == 0) + return 0; + + uint8_t tagMatch = 0; + uint8_t *pStartOfValue = *ppReadPackedMsg; + + for(idx = 0; idx < size; ++idx) { + if(unpack_fns[idx].tag == generic_tl.tag) { // match the extracted tag value with all the tags in unpack_fn list + tagMatch = 1; + nfapi_tl_t *tl = (nfapi_tl_t *)(unpack_fns[idx].tlv); + tl->tag = generic_tl.tag; + tl->length = generic_tl.length; + int result = (*unpack_fns[idx].unpack_func)(tl, ppReadPackedMsg, end); + + if(result == 0) { + return 0; + } + + // check if the length was right; + if(tl->length != (*ppReadPackedMsg - pStartOfValue)) { + NFAPI_TRACE(NFAPI_TRACE_ERROR, "Warning tlv tag 0x%x length %d not equal to unpack %ld\n", tl->tag, tl->length, (*ppReadPackedMsg - pStartOfValue)); + on_error(); + } + } + } + + if(tagMatch == 0) { + if(generic_tl.tag >= NFAPI_VENDOR_EXTENSION_MIN_TAG_VALUE && + generic_tl.tag <= NFAPI_VENDOR_EXTENSION_MAX_TAG_VALUE) { + int result = unpack_vendor_extension_tlv(&generic_tl, ppReadPackedMsg, end, config, ve); + + if(result == 0) { + // got tot the end. + return 0; + } else if(result < 0) { + NFAPI_TRACE(NFAPI_TRACE_ERROR, "Unknown VE TAG value: 0x%04x\n", generic_tl.tag); + on_error(); + + if (++numBadTags > MAX_BAD_TAG) { + NFAPI_TRACE(NFAPI_TRACE_ERROR, "Supplied message has had too many bad tags\n"); + on_error(); + return 0; + } + + if((end - *ppReadPackedMsg) >= generic_tl.length) { + // Advance past the unknown TLV + (*ppReadPackedMsg) += generic_tl.length; + } else { + // go to the end + return 0; + } + } + } else { + NFAPI_TRACE(NFAPI_TRACE_ERROR, "Unknown TAG value: 0x%04x\n", generic_tl.tag); + on_error(); + + if (++numBadTags > MAX_BAD_TAG) { + NFAPI_TRACE(NFAPI_TRACE_ERROR, "Supplied message has had too many bad tags\n"); + on_error(); + return 0; + } + + if((end - *ppReadPackedMsg) >= generic_tl.length) { + // Advance past the unknown TLV + (*ppReadPackedMsg) += generic_tl.length; + } else { + // go to the end + return 0; + } + } + } + } + + return 1; +} +int unpack_p7_tlv_list(unpack_p7_tlv_t unpack_fns[], uint16_t size, uint8_t **ppReadPackedMsg, uint8_t *end, nfapi_p7_codec_config_t *config, nfapi_tl_t **ve) { + nfapi_tl_t generic_tl; + uint8_t numBadTags = 0; + uint16_t idx = 0; + + while ((uint8_t *)(*ppReadPackedMsg) < end) { + // unpack the tl and process the values accordingly + if(unpack_tl(ppReadPackedMsg, &generic_tl, end) == 0) + return 0; + + uint8_t tagMatch = 0; + uint8_t *pStartOfValue = *ppReadPackedMsg; + + for(idx = 0; idx < size; ++idx) { + if(unpack_fns[idx].tag == generic_tl.tag) { + tagMatch = 1; + nfapi_tl_t *tl = (nfapi_tl_t *)(unpack_fns[idx].tlv); + tl->tag = generic_tl.tag; + tl->length = generic_tl.length; + int result = (*unpack_fns[idx].unpack_func)(tl, ppReadPackedMsg, end, config); + + if(result == 0) { + return 0; + } + + // check if the length was right; + if(tl->length != (*ppReadPackedMsg - pStartOfValue)) { + NFAPI_TRACE(NFAPI_TRACE_ERROR, "Warning tlv tag 0x%x length %d not equal to unpack %ld\n", tl->tag, tl->length, (*ppReadPackedMsg - pStartOfValue)); + on_error(); + } + } + } + + if(tagMatch == 0) { + if(generic_tl.tag >= NFAPI_VENDOR_EXTENSION_MIN_TAG_VALUE && + generic_tl.tag <= NFAPI_VENDOR_EXTENSION_MAX_TAG_VALUE) { + int result = unpack_p7_vendor_extension_tlv(&generic_tl, ppReadPackedMsg, end, config, ve); + + if(result == 0) { + // got to end + return 0; + } else if(result < 0) { + NFAPI_TRACE(NFAPI_TRACE_ERROR, "Unknown TAG value: 0x%04x\n", generic_tl.tag); + on_error(); + + if (++numBadTags > MAX_BAD_TAG) { + NFAPI_TRACE(NFAPI_TRACE_ERROR, "Supplied message has had too many bad tags\n"); + on_error(); + return -1; + } + + if((end - *ppReadPackedMsg) >= generic_tl.length) { + // Advance past the unknown TLV + (*ppReadPackedMsg) += generic_tl.length; + } else { + // got ot the dn + return 0; + } + } + } else { + NFAPI_TRACE(NFAPI_TRACE_ERROR, "Unknown TAG value: 0x%04x\n", generic_tl.tag); + on_error(); + + if (++numBadTags > MAX_BAD_TAG) { + NFAPI_TRACE(NFAPI_TRACE_ERROR, "Supplied message has had too many bad tags\n"); + on_error(); + return -1; + } + + if((end - *ppReadPackedMsg) >= generic_tl.length) { + // Advance past the unknown TLV + (*ppReadPackedMsg) += generic_tl.length; + } else { + // got ot the dn + return 0; + } + } + } + } + + return 1; +} + +// This intermediate function deals with calculating the length of the value +// and writing into the tlv header. +uint8_t pack_tlv(uint16_t tag, void *tlv, uint8_t **ppWritePackedMsg, uint8_t *end, pack_tlv_fn fn) { + nfapi_tl_t *tl = (nfapi_tl_t *)tlv; + + // If the tag is defined + if(tl->tag == tag) { + uint8_t *pStartOfTlv = *ppWritePackedMsg; + + // write a dumy tlv header + if(pack_tl(tl, ppWritePackedMsg, end) == 0) + return 0; + + // Record the start of the value + uint8_t *pStartOfValue = *ppWritePackedMsg; + + // pack the tlv value + if(fn(tlv, ppWritePackedMsg, end) == 0) + return 0; + + // calculate the length of the value and rewrite the tl header + tl->length = (*ppWritePackedMsg) - pStartOfValue; + // rewrite the header with the correct length + pack_tl(tl, &pStartOfTlv, end); + } else { + if(tl->tag != 0) { + NFAPI_TRACE(NFAPI_TRACE_WARN, "Warning pack_tlv tag 0x%x does not match expected 0x%x\n", tl->tag, tag); + } else { + //NFAPI_TRACE(NFAPI_TRACE_ERROR, "Warning pack_tlv tag 0x%x ZERO does not match expected 0x%x\n", tl->tag, tag); + } + } + + return 1; +} + +const char *nfapi_error_code_to_str(nfapi_error_code_e value) { + switch(value) { + case NFAPI_MSG_OK: + return "NFAPI_MSG_OK"; + + case NFAPI_MSG_INVALID_STATE: + return "NFAPI_MSG_INVALID_STATE"; + + case NFAPI_MSG_INVALID_CONFIG: + return "NFAPI_MSG_INVALID_CONFIG"; + + case NFAPI_SFN_OUT_OF_SYNC: + return "NFAPI_SFN_OUT_OF_SYNC"; + + case NFAPI_MSG_SUBFRAME_ERR: + return "NFAPI_MSG_SUBFRAME_ERR"; + + case NFAPI_MSG_BCH_MISSING: + return "NFAPI_MSG_BCH_MISSING"; + + case NFAPI_MSG_INVALID_SFN: + return "NFAPI_MSG_INVALID_SFN"; + + case NFAPI_MSG_HI_ERR: + return "NFAPI_MSG_HI_ERR"; + + case NFAPI_MSG_TX_ERR: + return "NFAPI_MSG_TX_ERR"; + + default: + return "UNKNOWN"; + } +} diff --git a/nfapi/open-nFAPI/nfapi/src/nfapi_p7.c b/nfapi/open-nFAPI/nfapi/src/nfapi_p7.c index 0e43c803e7..98f89f599c 100644 --- a/nfapi/open-nFAPI/nfapi/src/nfapi_p7.c +++ b/nfapi/open-nFAPI/nfapi/src/nfapi_p7.c @@ -200,8 +200,6 @@ static uint8_t pack_tpm_value(nfapi_dl_config_dci_dl_tpm_t *value, uint8_t **ppW static uint8_t pack_dl_tti_csi_rs_pdu_rel15_value(void *tlv, uint8_t **ppWritePackedMsg, uint8_t *end) { nfapi_nr_dl_tti_csi_rs_pdu_rel15_t *value = (nfapi_nr_dl_tti_csi_rs_pdu_rel15_t *)tlv; return( - push16(value->bwp_size, ppWritePackedMsg, end) && - push16(value->bwp_start, ppWritePackedMsg, end) && push8(value->subcarrier_spacing, ppWritePackedMsg, end) && push8(value->cyclic_prefix, ppWritePackedMsg, end) && push16(value->start_rb, ppWritePackedMsg, end) && @@ -1048,7 +1046,7 @@ static uint8_t pack_ul_tti_request_srs_pdu(nfapi_nr_srs_pdu_t *srs_pdu, uint8_t push8(srs_pdu->comb_offset, ppWritePackedMsg, end) && push8(srs_pdu->cyclic_shift, ppWritePackedMsg, end) && push8(srs_pdu->frequency_position, ppWritePackedMsg, end) && - push8(srs_pdu->frequency_shift, ppWritePackedMsg, end) && + push16(srs_pdu->frequency_shift, ppWritePackedMsg, end) && push8(srs_pdu->frequency_hopping, ppWritePackedMsg, end) && push8(srs_pdu->group_or_sequence_hopping, ppWritePackedMsg, end) && push8(srs_pdu->resource_type, ppWritePackedMsg, end) && @@ -1583,13 +1581,19 @@ static uint8_t pack_ul_config_request_body_value(void *tlv, uint8_t **ppWritePac static uint8_t pack_ul_tti_request(void *msg, uint8_t **ppWritePackedMsg, uint8_t *end, nfapi_p7_codec_config_t *config) { nfapi_nr_ul_tti_request_t *pNfapiMsg = (nfapi_nr_ul_tti_request_t *)msg; - if (!(push16(pNfapiMsg->SFN, ppWritePackedMsg, end) && - push16(pNfapiMsg->Slot, ppWritePackedMsg, end) && - push8(pNfapiMsg->n_pdus, ppWritePackedMsg, end) && - push8(pNfapiMsg->rach_present, ppWritePackedMsg, end) && - push8(pNfapiMsg->n_ulsch, ppWritePackedMsg, end) && - push8(pNfapiMsg->n_ulcch, ppWritePackedMsg, end) && - push8(pNfapiMsg->n_group, ppWritePackedMsg, end) )) + if (!push16(pNfapiMsg->SFN, ppWritePackedMsg, end)) + return 0; + if (!push16(pNfapiMsg->Slot, ppWritePackedMsg, end)) + return 0; + if (!push8(pNfapiMsg->n_pdus, ppWritePackedMsg, end)) + return 0; + if (!push8(pNfapiMsg->n_group, ppWritePackedMsg, end)) + return 0; + if (!push8(pNfapiMsg->rach_present, ppWritePackedMsg, end)) + return 0; + if (!push8(pNfapiMsg->n_ulsch, ppWritePackedMsg, end)) + return 0; + if (!push8(pNfapiMsg->n_ulcch, ppWritePackedMsg, end)) return 0; for(int i=0; in_pdus; i++) { @@ -1893,15 +1897,23 @@ static uint8_t pack_tx_data_pdu_list_value(void *tlv, uint8_t **ppWritePackedMsg switch(value->TLVs[i].tag) { case 0: { - if(!pusharray32(value->TLVs[i].value.direct, 16384, value->TLVs[i].length, ppWritePackedMsg, end)) + if (!pusharray32(value->TLVs[i].value.direct, sizeof(value->TLVs[i].value.direct) / sizeof(uint32_t), + value->TLVs[i].length / sizeof(uint32_t), ppWritePackedMsg, end)) { + NFAPI_TRACE(NFAPI_TRACE_ERROR, "%s():%d. value->TLVs[i].length %d \n", + __FUNCTION__, __LINE__, value->TLVs[i].length); return 0; + } break; } case 1: { - if(!pusharray32(value->TLVs[i].value.ptr, value->TLVs[i].length, value->TLVs[i].length, ppWritePackedMsg, end)) + if (!pusharray32(value->TLVs[i].value.ptr, value->TLVs[i].length / sizeof(uint32_t), + value->TLVs[i].length / sizeof(uint32_t), ppWritePackedMsg, end)) { + NFAPI_TRACE(NFAPI_TRACE_ERROR, "%s():%d. value->TLVs[i].length %d \n", + __FUNCTION__, __LINE__, value->TLVs[i].length); return 0; + } break; } @@ -3008,10 +3020,8 @@ return 1; //RX DATA INDICATION -static uint8_t pack_nr_rx_data_indication_body(void* tlv, uint8_t **ppWritePackedMsg, uint8_t *end) +static uint8_t pack_nr_rx_data_indication_body(nfapi_nr_rx_data_pdu_t *value, uint8_t **ppWritePackedMsg, uint8_t *end) { - nfapi_nr_rx_data_pdu_t* value = (nfapi_nr_rx_data_pdu_t*)tlv; - if(!(push32(value->handle, ppWritePackedMsg, end) && push16(value->rnti, ppWritePackedMsg, end) && push8(value->harq_id, ppWritePackedMsg, end) && @@ -3041,7 +3051,7 @@ static uint8_t pack_nr_rx_data_indication(void *msg, uint8_t **ppWritePackedMsg, for (int i = 0; i < pNfapiMsg->number_of_pdus; i++) { - if(!pack_nr_rx_data_indication_body(&(pNfapiMsg->pdu_list[i]), ppWritePackedMsg, end)) + if(!pack_nr_rx_data_indication_body(&(pNfapiMsg->pdu_list[i]), ppWritePackedMsg, end)) return 0; } @@ -3089,10 +3099,8 @@ return 1; //SRS INDICATION -static uint8_t pack_nr_srs_indication_body(void* tlv, uint8_t **ppWritePackedMsg, uint8_t *end) +static uint8_t pack_nr_srs_indication_body(nfapi_nr_srs_indication_pdu_t *value, uint8_t **ppWritePackedMsg, uint8_t *end) { - nfapi_nr_srs_indication_pdu_t* value = (nfapi_nr_srs_indication_pdu_t*)tlv; - if(!(push32(value->handle, ppWritePackedMsg, end) && push16(value->rnti, ppWritePackedMsg, end) && push16(value->timing_advance, ppWritePackedMsg, end) && @@ -3104,8 +3112,7 @@ static uint8_t pack_nr_srs_indication_body(void* tlv, uint8_t **ppWritePackedMsg return 0; for(int i = 0; i < value->reported_symbol_list->num_rbs; i++) { - if(!(push8(value->reported_symbol_list->rb_list->rb_snr, ppWritePackedMsg, end) - )) + if (!push8(value->reported_symbol_list->rb_list[i].rb_snr, ppWritePackedMsg, end)) return 0; } return 1; @@ -3181,32 +3188,36 @@ return 1; static uint8_t pack_nr_uci_pucch_0_1(void* tlv, uint8_t **ppWritePackedMsg, uint8_t *end) { nfapi_nr_uci_pucch_pdu_format_0_1_t* value = (nfapi_nr_uci_pucch_pdu_format_0_1_t*)tlv; - if(!(push8(value->pduBitmap, ppWritePackedMsg, end) && - push32(value->handle, ppWritePackedMsg, end) && - push16(value->rnti, ppWritePackedMsg, end) && - push8(value->pucch_format, ppWritePackedMsg, end) && - push8(value->ul_cqi, ppWritePackedMsg, end) && - push16(value->timing_advance, ppWritePackedMsg, end) && - push16(value->rssi, ppWritePackedMsg, end) - )) - return 0; + if (!push8(value->pduBitmap, ppWritePackedMsg, end)) + return 0; + if (!push32(value->handle, ppWritePackedMsg, end)) + return 0; + if (!push16(value->rnti, ppWritePackedMsg, end)) + return 0; + if (!push8(value->pucch_format, ppWritePackedMsg, end)) + return 0; + if (!push8(value->ul_cqi, ppWritePackedMsg, end)) + return 0; + if (!push16(value->timing_advance, ppWritePackedMsg, end)) + return 0; + if (!push16(value->rssi, ppWritePackedMsg, end)) + return 0; if (value->pduBitmap & 0x01) { //SR - if (!(push8(value->sr->sr_indication, ppWritePackedMsg, end) && - push8(value->sr->sr_confidence_level, ppWritePackedMsg, end) - )) - return 0; + if (!push8(value->sr->sr_indication, ppWritePackedMsg, end)) + return 0; + if (!push8(value->sr->sr_confidence_level, ppWritePackedMsg, end)) + return 0; } if (((value->pduBitmap >> 1) & 0x01)) { //HARQ - if (!(push8(value->harq->num_harq, ppWritePackedMsg, end) && - push8(value->harq->harq_confidence_level, ppWritePackedMsg, end) - )) + if (!push8(value->harq->num_harq, ppWritePackedMsg, end)) + return 0; + if (!push8(value->harq->harq_confidence_level, ppWritePackedMsg, end)) return 0; for (int i = 0; i < value->harq->num_harq; i++) { - if (!(push8(value->harq->harq_list[i].harq_value, ppWritePackedMsg, end) - )) - return 0; + if (!push8(value->harq->harq_list[i].harq_value, ppWritePackedMsg, end)) + return 0; } } @@ -3216,57 +3227,79 @@ static uint8_t pack_nr_uci_pucch_0_1(void* tlv, uint8_t **ppWritePackedMsg, uint static uint8_t pack_nr_uci_pucch_2_3_4(void* tlv, uint8_t **ppWritePackedMsg, uint8_t *end) { nfapi_nr_uci_pucch_pdu_format_2_3_4_t* value = (nfapi_nr_uci_pucch_pdu_format_2_3_4_t*) tlv; - if(!(push8(value->pduBitmap, ppWritePackedMsg, end) && - push32(value->handle, ppWritePackedMsg, end) && - push16(value->rnti, ppWritePackedMsg, end) && - push8(value->pucch_format, ppWritePackedMsg, end) && - push8(value->ul_cqi, ppWritePackedMsg, end) && - push16(value->timing_advance, ppWritePackedMsg, end) && - push16(value->rssi, ppWritePackedMsg, end) - )) - return 0; + if (!push8(value->pduBitmap, ppWritePackedMsg, end)) + return 0; + if (!push32(value->handle, ppWritePackedMsg, end)) + return 0; + if (!push16(value->rnti, ppWritePackedMsg, end)) + return 0; + if (!push8(value->pucch_format, ppWritePackedMsg, end)) + return 0; + if (!push8(value->ul_cqi, ppWritePackedMsg, end)) + return 0; + if (!push16(value->timing_advance, ppWritePackedMsg, end)) + return 0; + if (!push16(value->rssi, ppWritePackedMsg, end)) + return 0; if (value->pduBitmap & 0x01) { //SR - if(!(push8(value->sr.sr_bit_len, ppWritePackedMsg, end) && - pusharray8(value->sr.sr_payload, (int)(value->sr.sr_bit_len / 8) + 1, (int)(value->sr.sr_bit_len / 8) + 1, ppWritePackedMsg, end) - )) - return 0; - } - - if (((value->pduBitmap >> 1) & 0x01)) { //HARQ - if(!(push8(value->harq.harq_crc, ppWritePackedMsg, end) && - push8(value->harq.harq_bit_len, ppWritePackedMsg, end) && - pusharray8(value->harq.harq_payload, (int)(value->harq.harq_bit_len / 8) + 1, (int)(value->harq.harq_bit_len / 8) + 1, ppWritePackedMsg, end) - )) + if (!push16(value->sr.sr_bit_len, ppWritePackedMsg, end)) + return 0; + if (!pusharray8(value->sr.sr_payload, + (int)((value->sr.sr_bit_len / 8) + 1), + (int)((value->sr.sr_bit_len / 8) + 1), + ppWritePackedMsg, + end)) return 0; } - if (((value->pduBitmap >> 2) & 0x01)) { //CSI-1 - if(!(push8(value->csi_part1.csi_part1_crc, ppWritePackedMsg, end) && - push8(value->csi_part1.csi_part1_bit_len, ppWritePackedMsg, end) && - pusharray8(value->csi_part1.csi_part1_payload, (int)(value->csi_part1.csi_part1_bit_len / 8) + 1, (int)(value->csi_part1.csi_part1_bit_len / 8) + 1, ppWritePackedMsg, end) - )) + if ((value->pduBitmap >> 1) & 0x01) { //HARQ + if (!push8(value->harq.harq_crc, ppWritePackedMsg, end)) + return 0; + if (!push16(value->harq.harq_bit_len, ppWritePackedMsg, end)) + return 0; + if (!pusharray8(value->harq.harq_payload, + (int)((value->harq.harq_bit_len / 8) + 1), + (int)((value->harq.harq_bit_len / 8) + 1), + ppWritePackedMsg, + end)) return 0; } - if (((value->pduBitmap >> 3) & 0x01)) { //CSI-2 - if(!(push8(value->csi_part2.csi_part2_crc, ppWritePackedMsg, end) && - push8(value->csi_part2.csi_part2_bit_len, ppWritePackedMsg, end) && - pusharray8(value->csi_part2.csi_part2_payload, (int)(value->csi_part2.csi_part2_bit_len / 8) + 1, (int)(value->csi_part2.csi_part2_bit_len / 8) + 1, ppWritePackedMsg, end) - )) + if ((value->pduBitmap >> 2) & 0x01) { //CSI-1 + if (!push8(value->csi_part1.csi_part1_crc, ppWritePackedMsg, end)) + return 0; + if (!push16(value->csi_part1.csi_part1_bit_len, ppWritePackedMsg, end)) + return 0; + if (!pusharray8(value->csi_part1.csi_part1_payload, + (int)((value->csi_part1.csi_part1_bit_len / 8) + 1), + (int)((value->csi_part1.csi_part1_bit_len / 8) + 1), + ppWritePackedMsg, + end)) + return 0; + } + + if ((value->pduBitmap >> 3) & 0x01) { //CSI-2 + if (!push8(value->csi_part2.csi_part2_crc, ppWritePackedMsg, end)) + return 0; + if (!push16(value->csi_part2.csi_part2_bit_len, ppWritePackedMsg, end)) + return 0; + if (!pusharray8(value->csi_part2.csi_part2_payload, + (int)((value->csi_part2.csi_part2_bit_len / 8) + 1), + (int)((value->csi_part2.csi_part2_bit_len / 8) + 1), + ppWritePackedMsg, + end)) return 0; } return 1; } -static uint8_t pack_nr_uci_indication_body(void* tlv, uint8_t **ppWritePackedMsg, uint8_t *end) +static uint8_t pack_nr_uci_indication_body(nfapi_nr_uci_t* value, uint8_t **ppWritePackedMsg, uint8_t *end) { - nfapi_nr_uci_t* value = (nfapi_nr_uci_t*)tlv; - - if(!(push16(value->pdu_type, ppWritePackedMsg, end) && - push16(value->pdu_size, ppWritePackedMsg, end) - )) + if (!push16(value->pdu_type, ppWritePackedMsg, end)) + return 0; + if (!push16(value->pdu_size, ppWritePackedMsg, end)) return 0; switch (value->pdu_type) { @@ -3290,13 +3323,14 @@ static uint8_t pack_nr_uci_indication(void *msg, uint8_t **ppWritePackedMsg, uin { nfapi_nr_uci_indication_t *pNfapiMsg = (nfapi_nr_uci_indication_t*)msg; - if (!(push16(pNfapiMsg->sfn , ppWritePackedMsg, end) && - push16(pNfapiMsg->slot , ppWritePackedMsg, end) && - push16(pNfapiMsg->num_ucis, ppWritePackedMsg, end) - )) + if (!push16(pNfapiMsg->sfn , ppWritePackedMsg, end)) + return 0; + if (!push16(pNfapiMsg->slot , ppWritePackedMsg, end)) + return 0; + if (!push16(pNfapiMsg->num_ucis, ppWritePackedMsg, end)) return 0; - for(int i=0; inum_ucis;i++) + for (int i = 0; i < pNfapiMsg->num_ucis; i++) { if (!pack_nr_uci_indication_body(&pNfapiMsg->uci_list[i], ppWritePackedMsg, end)) return 0; @@ -3627,8 +3661,6 @@ int nfapi_p7_message_pack(void *pMessageBuf, void *pPackedBuf, uint32_t packedBu static uint8_t unpack_dl_tti_csi_rs_pdu_rel15_value(void *tlv, uint8_t **ppReadPackedMsg, uint8_t *end) { nfapi_nr_dl_tti_csi_rs_pdu_rel15_t *value = (nfapi_nr_dl_tti_csi_rs_pdu_rel15_t *)tlv; return( - pull16(ppReadPackedMsg, &value->bwp_size, end) && - pull16(ppReadPackedMsg, &value->bwp_start, end) && pull8(ppReadPackedMsg, &value->subcarrier_spacing, end) && pull8(ppReadPackedMsg, &value->cyclic_prefix, end) && pull16(ppReadPackedMsg, &value->start_rb, end) && @@ -4620,14 +4652,19 @@ static uint8_t unpack_ul_tti_groups_list_value(uint8_t **ppReadPackedMsg, uint8_ static uint8_t unpack_ul_tti_request(uint8_t **ppReadPackedMsg, uint8_t *end, void *msg, nfapi_p7_codec_config_t *config) { nfapi_nr_ul_tti_request_t *pNfapiMsg = (nfapi_nr_ul_tti_request_t *)msg; - if (!( - pull16(ppReadPackedMsg, &pNfapiMsg->SFN, end) && - pull16(ppReadPackedMsg, &pNfapiMsg->Slot, end) && - pull8(ppReadPackedMsg, &pNfapiMsg->n_pdus, end) && - pull8(ppReadPackedMsg, &pNfapiMsg->n_group, end) && - pull8(ppReadPackedMsg, &pNfapiMsg->rach_present, end) && - pull8(ppReadPackedMsg, &pNfapiMsg->n_ulcch, end) && - pull8(ppReadPackedMsg, &pNfapiMsg->n_ulsch, end) )) + if (!pull16(ppReadPackedMsg, &pNfapiMsg->SFN, end)) + return 0; + if (!pull16(ppReadPackedMsg, &pNfapiMsg->Slot, end)) + return 0; + if (!pull8(ppReadPackedMsg, &pNfapiMsg->n_pdus, end)) + return 0; + if (!pull8(ppReadPackedMsg, &pNfapiMsg->n_group, end)) + return 0; + if (!pull8(ppReadPackedMsg, &pNfapiMsg->rach_present, end)) + return 0; + if (!pull8(ppReadPackedMsg, &pNfapiMsg->n_ulcch, end)) + return 0; + if (!pull8(ppReadPackedMsg, &pNfapiMsg->n_ulsch, end)) return 0; for(int i=0; i< pNfapiMsg->n_pdus; i++) { @@ -5510,14 +5547,18 @@ static uint8_t unpack_tx_data_pdu_list_value(uint8_t **ppReadPackedMsg, uint8_t switch(pNfapiMsg->TLVs[i].tag) { case 0: { - if(!pullarray32(ppReadPackedMsg, pNfapiMsg->TLVs[i].value.direct, 16384, pNfapiMsg->TLVs[i].length, end)) + if (!pullarray32(ppReadPackedMsg, pNfapiMsg->TLVs[i].value.direct, + sizeof(pNfapiMsg->TLVs[i].value.direct) / sizeof(uint32_t), + pNfapiMsg->TLVs[i].length / sizeof(uint32_t), end)) return 0; break; } case 1: { - if(!pullarray32(ppReadPackedMsg, pNfapiMsg->TLVs[i].value.ptr, pNfapiMsg->TLVs[i].length, pNfapiMsg->TLVs[i].length, end)) + if (!pullarray32(ppReadPackedMsg,pNfapiMsg->TLVs[i].value.ptr, + pNfapiMsg->TLVs[i].length / sizeof(uint32_t), + pNfapiMsg->TLVs[i].length / sizeof(uint32_t), end)) return 0; break; @@ -5671,7 +5712,7 @@ static uint8_t unpack_nr_rx_data_indication_body(nfapi_nr_rx_data_pdu_t* value, return 0; uint16_t length = value->pdu_length; - value->pdu = nfapi_p7_allocate(length, config); + value->pdu = nfapi_p7_allocate(sizeof(*value->pdu) * length, config); if (pullarray8(ppReadPackedMsg, value->pdu, length, length, end) == 0) { @@ -5752,10 +5793,8 @@ return 1; //SRS INDICATION -static uint8_t unpack_nr_srs_indication_body(void* tlv, uint8_t **ppReadPackedMsg, uint8_t *end) +static uint8_t unpack_nr_srs_indication_body(nfapi_nr_srs_indication_pdu_t* value, uint8_t **ppReadPackedMsg, uint8_t *end) { - nfapi_nr_srs_indication_pdu_t* value = (nfapi_nr_srs_indication_pdu_t*)tlv; - if(!(pull32(ppReadPackedMsg, &value->handle, end) && pull16(ppReadPackedMsg, &value->rnti, end) && pull16(ppReadPackedMsg, &value->timing_advance, end) && @@ -5767,17 +5806,14 @@ static uint8_t unpack_nr_srs_indication_body(void* tlv, uint8_t **ppReadPackedMs return 0; for(int i = 0; i < value->reported_symbol_list->num_rbs; i++) { - if(!(pull8(ppReadPackedMsg, &value->reported_symbol_list->rb_list->rb_snr, end) - )) + if (!pull8(ppReadPackedMsg, &value->reported_symbol_list->rb_list[i].rb_snr, end)) return 0; } return 1; } -static uint8_t unpack_nr_srs_indication(uint8_t **ppReadPackedMsg, uint8_t *end, void *msg, nfapi_p7_codec_config_t* config) +static uint8_t unpack_nr_srs_indication(uint8_t **ppReadPackedMsg, uint8_t *end, nfapi_nr_srs_indication_t *pNfapiMsg, nfapi_p7_codec_config_t* config) { - nfapi_nr_srs_indication_t *pNfapiMsg = (nfapi_nr_srs_indication_t*)msg; - if (!(pull16(ppReadPackedMsg,&pNfapiMsg->sfn , end) && pull16(ppReadPackedMsg,&pNfapiMsg->slot , end) && pull8(ppReadPackedMsg,&pNfapiMsg->number_of_pdus, end) @@ -5786,7 +5822,7 @@ static uint8_t unpack_nr_srs_indication(uint8_t **ppReadPackedMsg, uint8_t *end, for(int i=0; inumber_of_pdus;i++) { - if(!unpack_nr_srs_indication_body(&pNfapiMsg->pdu_list,ppReadPackedMsg,end)) + if (!unpack_nr_srs_indication_body(&pNfapiMsg->pdu_list[i], ppReadPackedMsg, end)) return 0; } @@ -5907,58 +5943,111 @@ static uint8_t unpack_nr_uci_pucch_0_1(nfapi_nr_uci_pucch_pdu_format_0_1_t *valu } -static uint8_t unpack_nr_uci_pucch_2_3_4(nfapi_nr_uci_pucch_pdu_format_2_3_4_t* tlv, uint8_t **ppReadPackedMsg, uint8_t *end) { - nfapi_nr_uci_pucch_pdu_format_2_3_4_t* value = (nfapi_nr_uci_pucch_pdu_format_2_3_4_t*) tlv; +static uint8_t unpack_nr_uci_pucch_2_3_4(nfapi_nr_uci_pucch_pdu_format_2_3_4_t* value, + uint8_t **ppReadPackedMsg, + uint8_t *end, + nfapi_p7_codec_config_t *config) { + + if (!pull8(ppReadPackedMsg, &value->pduBitmap, end)) + return 0; + if (!pull32(ppReadPackedMsg, &value->handle, end)) + return 0; + if (!pull16(ppReadPackedMsg, &value->rnti, end)) + return 0; + if (!pull8(ppReadPackedMsg, &value->pucch_format, end)) + return 0; + if (!pull8(ppReadPackedMsg, &value->ul_cqi, end)) + return 0; + if (!pull16(ppReadPackedMsg, &value->timing_advance, end)) + return 0; + if (!pull16(ppReadPackedMsg, &value->rssi, end)) + return 0; - if(!(pull8(ppReadPackedMsg, &value->pduBitmap, end) && - pull32(ppReadPackedMsg, &value->handle, end) && - pull16(ppReadPackedMsg, &value->rnti, end) && - pull8(ppReadPackedMsg, &value->pucch_format, end) && - pull8(ppReadPackedMsg, &value->ul_cqi, end) && - pull16(ppReadPackedMsg, &value->timing_advance, end) && - pull16(ppReadPackedMsg, &value->rssi, end) - )) - return 0; if (value->pduBitmap & 0x01) { //SR - if(!(pull16(ppReadPackedMsg, &value->sr.sr_bit_len, end))) + if (!pull16(ppReadPackedMsg, &value->sr.sr_bit_len, end)) return 0; - value->sr.sr_payload = (uint8_t*) malloc(sizeof(uint8_t) * ((value->sr.sr_bit_len/8))); - - if(!(pullarray8(ppReadPackedMsg, &value->sr.sr_payload[0], (int)(value->sr.sr_bit_len / 8), (int)(value->sr.sr_bit_len / 8), end))) - return 0; - } - - if (((value->pduBitmap >> 1) & 0x01)) { //HARQ - if(!(pull8(ppReadPackedMsg, &value->harq.harq_crc, end)) && - (pull16(ppReadPackedMsg, &value->harq.harq_bit_len, end))) + value->sr.sr_payload = nfapi_p7_allocate(sizeof(*value->sr.sr_payload) * + (int)((value->sr.sr_bit_len / 8) + 1), + config); + if (value->sr.sr_payload == NULL) + { + NFAPI_TRACE(NFAPI_TRACE_ERROR, "%s failed to allocate value->sr.sr_payload\n", __FUNCTION__); return 0; + } - value->harq.harq_payload = (uint8_t*) malloc(sizeof(uint8_t) * ((value->harq.harq_bit_len/8 ))); - - if(!(pullarray8(ppReadPackedMsg, value->harq.harq_payload, (int)(value->harq.harq_bit_len / 8), (int)(value->harq.harq_bit_len / 8), end))) + if (!pullarray8(ppReadPackedMsg, value->sr.sr_payload, + (int)((value->sr.sr_bit_len / 8) + 1), + (int)((value->sr.sr_bit_len / 8) + 1), + end)) return 0; } - if (((value->pduBitmap >> 2) & 0x01)) { //CSI-1 - if(!(pull8(ppReadPackedMsg, &value->csi_part1.csi_part1_crc, end)) && - (pull16(ppReadPackedMsg, &value->csi_part1.csi_part1_bit_len, end))) + if ((value->pduBitmap >> 1) & 0x01) { //HARQ + if (!pull8(ppReadPackedMsg, &value->harq.harq_crc, end)) + return 0; + if (!pull16(ppReadPackedMsg, &value->harq.harq_bit_len, end)) return 0; - value->csi_part1.csi_part1_payload = (uint8_t*) malloc(sizeof(uint8_t) * ((value->csi_part1.csi_part1_bit_len/8))); + value->harq.harq_payload = nfapi_p7_allocate(sizeof(*value->harq.harq_payload) * + (int)((value->harq.harq_bit_len / 8) + 1), + config); + if (value->harq.harq_payload == NULL) + { + NFAPI_TRACE(NFAPI_TRACE_ERROR, "%s failed to allocate value->harq.harq_payload\n", __FUNCTION__); + return 0; + } -// if(!(pullarray8(ppReadPackedMsg, value->csi_part1.csi_part1_payload, (int)(value->csi_part1.csi_part1_bit_len / 8), (int)(value->csi_part1.csi_part1_bit_len / 8), end))) -// return 0; + if (!pullarray8(ppReadPackedMsg, value->harq.harq_payload, + (int)((value->harq.harq_bit_len / 8) + 1), + (int)((value->harq.harq_bit_len / 8) + 1), + end)) + return 0; } - if (((value->pduBitmap >> 3) & 0x01)) { //CSI-2 - if(!(pull8(ppReadPackedMsg, &value->csi_part2.csi_part2_crc, end)) && - (pull16(ppReadPackedMsg, &value->csi_part2.csi_part2_bit_len, end))) + if ((value->pduBitmap >> 2) & 0x01) { //CSI-1 + if (!pull8(ppReadPackedMsg, &value->csi_part1.csi_part1_crc, end)) + return 0; + if (!pull16(ppReadPackedMsg, &value->csi_part1.csi_part1_bit_len, end)) return 0; - value->csi_part2.csi_part2_payload = (uint8_t*) malloc(sizeof(uint8_t) * ((value->csi_part2.csi_part2_bit_len/8 ))); + value->csi_part1.csi_part1_payload = nfapi_p7_allocate(sizeof(*value->csi_part1.csi_part1_payload) * + (int)((value->csi_part1.csi_part1_bit_len / 8) + 1), + config); + if (value->csi_part1.csi_part1_payload == NULL) + { + NFAPI_TRACE(NFAPI_TRACE_ERROR, "%s failed to allocate value->csi_part1.csi_part1_payload\n", + __FUNCTION__); + return 0; + } - if(!(pullarray8(ppReadPackedMsg, value->csi_part2.csi_part2_payload, (int)(value->csi_part2.csi_part2_bit_len / 8) , (int)(value->csi_part2.csi_part2_bit_len / 8) , end))) + if (!pullarray8(ppReadPackedMsg, value->csi_part1.csi_part1_payload, + (int)((value->csi_part1.csi_part1_bit_len / 8) + 1), + (int)((value->csi_part1.csi_part1_bit_len / 8) + 1), + end)) + return 0; + } + + if ((value->pduBitmap >> 3) & 0x01) { //CSI-2 + if (!pull8(ppReadPackedMsg, &value->csi_part2.csi_part2_crc, end)) + return 0; + if (!pull16(ppReadPackedMsg, &value->csi_part2.csi_part2_bit_len, end)) + return 0; + + value->csi_part2.csi_part2_payload = nfapi_p7_allocate(sizeof(*value->csi_part2.csi_part2_payload) * + (int)((value->csi_part2.csi_part2_bit_len / 8) + 1), + config); + if (value->csi_part2.csi_part2_payload == NULL) + { + NFAPI_TRACE(NFAPI_TRACE_ERROR, "%s failed to allocate value->csi_part2.csi_part2_payload\n", + __FUNCTION__); + return 0; + } + + if (!pullarray8(ppReadPackedMsg, value->csi_part2.csi_part2_payload, + (int)((value->csi_part2.csi_part2_bit_len / 8) + 1), + (int)((value->csi_part2.csi_part2_bit_len / 8) + 1), + end)) return 0; } @@ -5970,9 +6059,9 @@ static uint8_t unpack_nr_uci_indication_body(nfapi_nr_uci_t *value, uint8_t *end, nfapi_p7_codec_config_t *config) { - if(!(pull16(ppReadPackedMsg, &value->pdu_type, end) && - pull16(ppReadPackedMsg, &value->pdu_size, end) - )) + if (!pull16(ppReadPackedMsg, &value->pdu_type, end)) + return 0; + if (!pull16(ppReadPackedMsg, &value->pdu_size, end)) return 0; switch (value->pdu_type) { @@ -5988,7 +6077,7 @@ static uint8_t unpack_nr_uci_indication_body(nfapi_nr_uci_t *value, } case NFAPI_NR_UCI_FORMAT_2_3_4_PDU_TYPE: { nfapi_nr_uci_pucch_pdu_format_2_3_4_t *uci_pdu = &value->pucch_pdu_format_2_3_4; - if (!unpack_nr_uci_pucch_2_3_4(uci_pdu, ppReadPackedMsg, end)) + if (!unpack_nr_uci_pucch_2_3_4(uci_pdu, ppReadPackedMsg, end, config)) return 0; break; } @@ -6004,17 +6093,18 @@ static uint8_t unpack_nr_uci_indication(uint8_t **ppReadPackedMsg, uint8_t *end, { nfapi_nr_uci_indication_t *pNfapiMsg = (nfapi_nr_uci_indication_t*)msg; - if (!(pull16(ppReadPackedMsg, &pNfapiMsg->sfn , end) && - pull16(ppReadPackedMsg, &pNfapiMsg->slot , end) && - pull16(ppReadPackedMsg, &pNfapiMsg->num_ucis, end) - )) - return 0; + if (!pull16(ppReadPackedMsg, &pNfapiMsg->sfn , end)) + return 0; + if (!pull16(ppReadPackedMsg, &pNfapiMsg->slot , end)) + return 0; + if (!pull16(ppReadPackedMsg, &pNfapiMsg->num_ucis, end)) + return 0; pNfapiMsg->uci_list = nfapi_p7_allocate(sizeof(*pNfapiMsg->uci_list) * pNfapiMsg->num_ucis, config); for (int i = 0; i < pNfapiMsg->num_ucis; i++) { - if(!unpack_nr_uci_indication_body(&pNfapiMsg->uci_list[i], ppReadPackedMsg, end, config)) - return 0; + if (!unpack_nr_uci_indication_body(&pNfapiMsg->uci_list[i], ppReadPackedMsg, end, config)) + return 0; } return 1; diff --git a/nfapi/open-nFAPI/pnf/src/pnf_p7.c b/nfapi/open-nFAPI/pnf/src/pnf_p7.c index fb1a713e56..0ce847a735 100644 --- a/nfapi/open-nFAPI/pnf/src/pnf_p7.c +++ b/nfapi/open-nFAPI/pnf/src/pnf_p7.c @@ -32,7 +32,6 @@ #define FAPI2_IP_DSCP 0 extern uint16_t sf_ahead; -extern uint16_t slot_ahead; //uint16_t sf_ahead=4; @@ -933,7 +932,7 @@ int pnf_p7_slot_ind(pnf_p7_t* pnf_p7, uint16_t phy_id, uint16_t sfn, uint16_t sl // save the curren time, sfn and slot pnf_p7->slot_start_time_hr = pnf_get_current_time_hr(); - slot_ahead = 6; + int slot_ahead = 6; uint32_t sfn_slot_tx = sfnslot_add_slot(sfn, slot, slot_ahead); uint16_t sfn_tx = NFAPI_SFNSLOT2SFN(sfn_slot_tx); uint8_t slot_tx = NFAPI_SFNSLOT2SLOT(sfn_slot_tx); diff --git a/nfapi/open-nFAPI/vnf/src/vnf_p7.c b/nfapi/open-nFAPI/vnf/src/vnf_p7.c index 2ac59dd7be..e4b4bef848 100644 --- a/nfapi/open-nFAPI/vnf/src/vnf_p7.c +++ b/nfapi/open-nFAPI/vnf/src/vnf_p7.c @@ -1473,7 +1473,7 @@ void vnf_handle_nr_slot_indication(void *pRecvMsg, int recvMsgLen, vnf_p7_t* vnf } else { - NFAPI_TRACE(NFAPI_TRACE_INFO, "%s: Handling NR SLOT Indication\n", __FUNCTION__); + NFAPI_TRACE(NFAPI_TRACE_DEBUG, "%s: Handling NR SLOT Indication\n", __FUNCTION__); if(vnf_p7->_public.nr_slot_indication) { (vnf_p7->_public.nr_slot_indication)(&ind); @@ -2574,32 +2574,28 @@ int vnf_p7_read_dispatch_message(vnf_p7_t* vnf_p7) // resize the buffer if we have a large segment if(header.message_length > vnf_p7->rx_message_buffer_size) { - NFAPI_TRACE(NFAPI_TRACE_NOTE, "reallocing rx buffer %d\n", header.message_length); + NFAPI_TRACE(NFAPI_TRACE_NOTE, "reallocing rx buffer %d\n", header.message_length); vnf_p7->rx_message_buffer = realloc(vnf_p7->rx_message_buffer, header.message_length); vnf_p7->rx_message_buffer_size = header.message_length; } // read the segment - recvfrom_result = recvfrom(vnf_p7->socket, vnf_p7->rx_message_buffer, header.message_length, MSG_WAITALL, (struct sockaddr*)&remote_addr, &remote_addr_size); + recvfrom_result = recvfrom(vnf_p7->socket, vnf_p7->rx_message_buffer, header.message_length, MSG_WAITALL | MSG_TRUNC, (struct sockaddr*)&remote_addr, &remote_addr_size); + NFAPI_TRACE(NFAPI_TRACE_INFO, "recvfrom_result = %d from %s():%d\n", recvfrom_result, __FUNCTION__, __LINE__); // todo : how to handle incomplete readfroms, need some sort of buffer/select - if(recvfrom_result == 0) - { - NFAPI_TRACE(NFAPI_TRACE_ERROR, "recvfrom returned 0\n"); - } - else if(recvfrom_result != -1 && recvfrom_result != header.message_length) - { - NFAPI_TRACE(NFAPI_TRACE_ERROR, "Received unexpected number of bytes %d %d\n", recvfrom_result, header.message_length); - - recvfrom_result += recvfrom(vnf_p7->socket, &vnf_p7->rx_message_buffer[recvfrom_result], header.message_length - recvfrom_result, MSG_WAITALL, (struct sockaddr*)&remote_addr, &remote_addr_size); - - } - - - if(recvfrom_result > 0) + if (recvfrom_result > 0) { + if (recvfrom_result != header.message_length) + { + NFAPI_TRACE(NFAPI_TRACE_ERROR, "(%d) Received unexpected number of bytes. %d != %d", + __LINE__, recvfrom_result, header.message_length); + break; + } + NFAPI_TRACE(NFAPI_TRACE_INFO, "Calling vnf_nr_handle_p7_message from %d\n", __LINE__); vnf_handle_p7_message(vnf_p7->rx_message_buffer, recvfrom_result, vnf_p7); + return 0; } else { diff --git a/oaienv b/oaienv index f8ef707c12..bb24469703 100644 --- a/oaienv +++ b/oaienv @@ -1,6 +1,7 @@ export OPENAIR_HOME=$(pwd) export OPENAIR_DIR=$(pwd) +export AWGN_RESULTS_DIR=$OPENAIR_DIR/openair1/SIMULATION/NR_PHY/BLER_SIMULATIONS/AWGN/AWGN_results export OPENAIR1_DIR=$OPENAIR_HOME/openair1 export OPENAIR2_DIR=$OPENAIR_HOME/openair2 export OPENAIR3_DIR=$OPENAIR_HOME/openair3 diff --git a/openair1/PHY/CODING/TESTBENCH/ldpctest.c b/openair1/PHY/CODING/TESTBENCH/ldpctest.c index 58d649d011..841a31fd85 100644 --- a/openair1/PHY/CODING/TESTBENCH/ldpctest.c +++ b/openair1/PHY/CODING/TESTBENCH/ldpctest.c @@ -31,6 +31,7 @@ #include "openair1/PHY/CODING/nrLDPC_decoder_LYC/nrLDPC_decoder_LYC.h" #include "openair1/PHY/defs_nr_common.h" #include "coding_unitary_defs.h" +#include "common/utils/LOG/log.h" #define MAX_BLOCK_LENGTH 8448 @@ -79,16 +80,19 @@ char quantize8bit(double D,double x) } typedef struct { - double n_iter_mean; - double n_iter_std; - int n_iter_max; + double n_iter_mean[400]; + double n_iter_std[400]; + int n_iter_max[400]; + double snr[400]; + double ber[400]; + double bler[400]; } n_iter_stats_t; nrLDPC_encoderfunc_t encoder_orig; short lift_size[51]= {2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,18,20,22,24,26,28,30,32,36,40,44,48,52,56,60,64,72,80,88,96,104,112,120,128,144,160,176,192,208,224,240,256,288,320,352,384}; -int test_ldpc(short No_iteration, +int test_ldpc(short max_iterations, int nom_rate, int denom_rate, double SNR, @@ -102,8 +106,8 @@ int test_ldpc(short No_iteration, unsigned int *crc_misses, time_stats_t *time_optim, time_stats_t *time_decoder, - n_iter_stats_t *dec_iter - ) + n_iter_stats_t *dec_iter, + int nsnr) { //clock initiate //time_stats_t time,time_optim,tinput,tprep,tparity,toutput, time_decoder; @@ -117,7 +121,7 @@ int test_ldpc(short No_iteration, sigma = 1.0/sqrt(2*SNR); opp_enabled=1; //short test_input[block_length]; - unsigned char *test_input[MAX_NUM_NR_DLSCH_SEGMENTS]={NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL};; + unsigned char *test_input[MAX_NUM_NR_DLSCH_SEGMENTS_PER_LAYER*NR_MAX_NB_LAYERS]={NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL};; //short *c; //padded codeword unsigned char estimated_output[MAX_NUM_DLSCH_SEGMENTS][block_length]; memset(estimated_output, 0, sizeof(estimated_output)); @@ -126,7 +130,6 @@ int test_ldpc(short No_iteration, //double channel_output[68 * 384]; double modulated_input[MAX_NUM_DLSCH_SEGMENTS][68 * 384] = { 0 }; char channel_output_fixed[MAX_NUM_DLSCH_SEGMENTS][68 * 384] = { 0 }; - unsigned int i,j,trial=0; short BG=0,nrows=0;//,ncols; int no_punctured_columns,removed_bit; int i1,Zc,Kb=0; @@ -137,12 +140,9 @@ int test_ldpc(short No_iteration, int code_rate_vec[8] = {15, 13, 25, 12, 23, 34, 56, 89}; //double code_rate_actual_vec[8] = {0.2, 0.33333, 0.4, 0.5, 0.66667, 0.73333, 0.81481, 0.88}; - t_nrLDPC_dec_params decParams; - t_nrLDPC_procBuf nrLDPC_procBuf; - t_nrLDPC_procBuf* p_nrLDPC_procBuf = &nrLDPC_procBuf; - + t_nrLDPC_dec_params decParams[MAX_NUM_DLSCH_SEGMENTS]={0}; + t_nrLDPC_time_stats decoder_profiler = {0}; - t_nrLDPC_time_stats* p_decoder_profiler =&decoder_profiler ; int32_t n_iter = 0; @@ -152,7 +152,7 @@ int test_ldpc(short No_iteration, *crc_misses=0; // generate input block - for(j=0;j>3; i++) - { - //printf("block_length>>3: %d \n",block_length>>3); - /// printf("i: %d \n",i); - ///printf("estimated_output[%d]: %d \n",i,estimated_output[i]); - ///printf("test_input[0][%d]: %d \n",i,test_input[0][i]); - if (estimated_output[j][i] != test_input[j][i]) - { - //////printf("error pos %d (%d, %d)\n\n",i,estimated_output[i],test_input[0][i]); - segment_bler = segment_bler + 1; - break; } - } + +#ifdef DEBUG_CODER + printf("\n"); + exit(-1); +#endif - for (i=0; i>(i&7); unsigned char inputbit = (test_input[j][i/8]&(1<<(i&7)))>>(i&7); // Further correct for multiple segments @@ -412,40 +377,33 @@ int test_ldpc(short No_iteration, *errors_bit = (*errors_bit) + 1; } - //if (*errors == 1000) - //break; + n_iter_mean += n_iter; + n_iter_std += pow(n_iter-1,2); - n_iter_mean = n_iter_mean + n_iter; - n_iter_std = n_iter_std + pow(n_iter-1,2); + if ( n_iter > n_iter_max ) + n_iter_max = n_iter; - if ( n_iter > n_iter_max ) - n_iter_max = n_iter; - - } // end segments + } // end segments if (segment_bler != 0) - *errors = (*errors) + 1; + *errors = (*errors) + 1; } - /*else if (trial==0) - printf("decoder is not supported\n");*/ } - dec_iter->n_iter_mean = n_iter_mean/(double)ntrials/(double)n_segments - 1; - dec_iter->n_iter_std = sqrt(n_iter_std/(double)ntrials/(double)n_segments - pow(n_iter_mean/(double)ntrials/(double)n_segments - 1,2)); - dec_iter->n_iter_max = n_iter_max -1; + dec_iter->n_iter_mean[nsnr] = n_iter_mean/(double)ntrials/(double)n_segments - 1; + dec_iter->n_iter_std[nsnr] = sqrt(n_iter_std/(double)ntrials/(double)n_segments - pow(n_iter_mean/(double)ntrials/(double)n_segments - 1,2)); + dec_iter->n_iter_max[nsnr] = n_iter_max -1; *errors_bit_uncoded = *errors_bit_uncoded / (double)((Kb+nrows-no_punctured_columns-2) * Zc-removed_bit); - for(j=0;j 1280, 2401 -> 2560 char *ldpc_version=NULL; /* version of the ldpc decoder library to use (XXX suffix to use when loading libldpc_XXX.so */ - short No_iteration=5; + short max_iterations=5; int n_segments=1; //double rate=0.333; @@ -486,7 +444,7 @@ int main(int argc, char *argv[]) unsigned char qbits=8; unsigned int decoded_errors[10000]; // initiate the size of matrix equivalent to size of SNR int c,i=0, i1 = 0; - int loglvl=OAILOG_WARNING; + int n_trials = 1; double SNR_step = 0.1; @@ -494,14 +452,11 @@ int main(int argc, char *argv[]) int test_uncoded= 0; time_stats_t time_optim[10], time_decoder[10]; - n_iter_stats_t dec_iter[3]; + n_iter_stats_t dec_iter; short BG=0,Zc,Kb=0; - if ( load_configmodule(argc,argv,CONFIG_ENABLECMDLINEONLY) == 0) { - exit_fun(" Error, configuration module init failed\n"); - } // must be done before specific options parsing to prevent errasing them - - while ((c = getopt (argc, argv, "q:r:s:S:l:L:G:n:d:i:t:u:hv:")) != -1) + + while ((c = getopt (argc, argv, "q:r:s:S:l:G:n:d:i:t:u:hv:")) != -1) switch (c) { case 'q': @@ -519,10 +474,6 @@ int main(int argc, char *argv[]) case 'l': block_length = atoi(optarg); break; - - case 'L': - loglvl = atoi(optarg); - break; case 'G': ldpc_version="_cuda"; @@ -545,7 +496,7 @@ int main(int argc, char *argv[]) break; case 'i': - No_iteration = atoi(optarg); + max_iterations = atoi(optarg); break; case 'u': @@ -560,11 +511,10 @@ int main(int argc, char *argv[]) printf("BG1 (blocklength > 3840): 1/3, 2/3, 22/25 (8/9) \n"); printf("BG2 (blocklength <= 3840): 1/5, 1/3, 2/3 \n\n"); printf("-h This message\n"); - printf("-L \n"); printf("-q Quantization bits, Default: 8\n"); printf("-r Nominator rate, (1, 2, 22), Default: 1\n"); printf("-d Denominator rate, (3, 5, 25), Default: 1\n"); - printf("-l Block length (l > 3840 -> BG1, rest BG2 ), Default: 8448\n"); + printf("-l Block length (l > 3840 -> BG1, rest BG2 ), Default: 8448\n"); printf("-G give 1 to run cuda for LDPC, Default: 0\n"); printf("-n Number of simulation trials, Default: 1\n"); //printf("-M MCS2 for TB 2\n"); @@ -583,8 +533,6 @@ int main(int argc, char *argv[]) printf("n_trials %d: \n", n_trials); printf("SNR0 %f: \n", SNR0); - logInit(); - set_glog(loglvl); if (ldpc_version != NULL) load_nrLDPClib(ldpc_version); @@ -632,7 +580,7 @@ int main(int argc, char *argv[]) } char fname[200]; - sprintf(fname,"ldpctest_BG_%d_Zc_%d_rate_%d-%d_block_length_%d_maxit_%d.txt",BG,Zc,nom_rate,denom_rate,block_length, No_iteration); + sprintf(fname,"ldpctest_BG_%d_Zc_%d_rate_%d-%d_block_length_%d_maxit_%d.txt",BG,Zc,nom_rate,denom_rate,block_length, max_iterations); FILE *fd=fopen(fname,"w"); AssertFatal(fd!=NULL,"cannot open %s\n",fname); @@ -647,7 +595,7 @@ int main(int argc, char *argv[]) else SNR_lin = pow(10,SNR/10.0)*nom_rate/denom_rate; printf("Linear SNR: %f\n", SNR_lin); - decoded_errors[i]=test_ldpc(No_iteration, + decoded_errors[i]=test_ldpc(max_iterations, nom_rate, denom_rate, SNR_lin, // noise standard deviation @@ -661,14 +609,18 @@ int main(int argc, char *argv[]) &crc_misses, time_optim, time_decoder, - dec_iter); + &dec_iter, + i); - printf("SNR %f, BLER %f (%u/%d)\n", SNR, (float)decoded_errors[i]/(float)n_trials, decoded_errors[i], n_trials); - printf("SNR %f, BER %f (%u/%d)\n", SNR, (float)errors_bit/(float)n_trials/(float)block_length/(double)n_segments, decoded_errors[i], n_trials); + dec_iter.snr[i] = SNR; + dec_iter.ber[i] = (float)errors_bit/(float)n_trials/(float)block_length/(double)n_segments; + dec_iter.bler[i] = (float)decoded_errors[i]/(float)n_trials; + printf("SNR %f, BLER %f (%u/%d)\n", SNR, dec_iter.bler[i], decoded_errors[i], n_trials); + printf("SNR %f, BER %f (%u/%d)\n", SNR, dec_iter.ber[i], decoded_errors[i], n_trials); printf("SNR %f, Uncoded BER %f (%u/%d)\n",SNR, errors_bit_uncoded/(float)n_trials/(double)n_segments, decoded_errors[i], n_trials); - printf("SNR %f, Mean iterations: %f\n",SNR, dec_iter->n_iter_mean); - printf("SNR %f, Std iterations: %f\n",SNR, dec_iter->n_iter_std); - printf("SNR %f, Max iterations: %d\n",SNR, dec_iter->n_iter_max); + printf("SNR %f, Mean iterations: %f\n",SNR, dec_iter.n_iter_mean[i]); + printf("SNR %f, Std iterations: %f\n",SNR, dec_iter.n_iter_std[i]); + printf("SNR %f, Max iterations: %d\n",SNR, dec_iter.n_iter_max[i]); printf("\n"); printf("Encoding time mean: %15.3f us\n",(double)time_optim->diff/time_optim->trials/1000.0/get_cpu_freq_GHz()); printf("Encoding time std: %15.3f us\n",sqrt((double)time_optim->diff_square/time_optim->trials/pow(1000,2)/pow(get_cpu_freq_GHz(),2)-pow((double)time_optim->diff/time_optim->trials/1000.0/get_cpu_freq_GHz(),2))); @@ -689,16 +641,20 @@ int main(int argc, char *argv[]) (double)time_decoder->diff/time_decoder->trials/1000.0/get_cpu_freq_GHz(), sqrt((double)time_decoder->diff_square/time_decoder->trials/pow(1000,2)/pow(get_cpu_freq_GHz(),2)-pow((double)time_decoder->diff/time_decoder->trials/1000.0/get_cpu_freq_GHz(),2)), (double)time_decoder->max/1000.0/get_cpu_freq_GHz(), - dec_iter->n_iter_mean, - dec_iter->n_iter_std, - dec_iter->n_iter_max + dec_iter.n_iter_mean[i], + dec_iter.n_iter_std[i], + dec_iter.n_iter_max[i] ); - if (decoded_errors[i] == 0) break; - i=i+1; + if (decoded_errors[i-1] == 0) break; + } fclose(fd); + LOG_M("ldpctestStats.m","SNR",&dec_iter.snr[0],i,1,7); + LOG_MM("ldpctestStats.m","BLER",&dec_iter.bler[0],i,1,7); + LOG_MM("ldpctestStats.m","BER",&dec_iter.ber[0],i,1,7); + LOG_MM("ldpctestStats.m","meanIter",&dec_iter.n_iter_mean[0],i,1,7); loader_reset(); logTerm(); diff --git a/openair1/PHY/CODING/coding_defs.h b/openair1/PHY/CODING/coding_defs.h index 8fe31f208e..1854f28fa7 100644 --- a/openair1/PHY/CODING/coding_defs.h +++ b/openair1/PHY/CODING/coding_defs.h @@ -38,7 +38,6 @@ #define MAX_TURBO_ITERATIONS_MBSFN 8 #define MAX_TURBO_ITERATIONS max_turbo_iterations -#define MAX_LDPC_ITERATIONS 5 #define MAX_LDPC_ITERATIONS_MBSFN 4 #define LTE_NULL 2 @@ -469,28 +468,11 @@ int32_t nr_segmentation(unsigned char *input_buffer, unsigned int *F, uint8_t BG); -/*!\fn uint32_t nr_compute_tbs -\brief This function returns the TBS in bits as per 6.1.4.2 of TS 38.214 -*/ -uint32_t nr_compute_tbs(uint16_t Qm, - uint16_t R, - uint16_t nb_rb, - uint16_t nb_symb_sch, - uint16_t nb_dmrs_prb, - uint16_t nb_rb_oh, - uint8_t tb_scaling, - uint8_t Nl); - -uint32_t nr_compute_tbslbrm(uint16_t table, - uint16_t nb_rb, - uint8_t Nl); - void nr_interleaving_ldpc(uint32_t E, uint8_t Qm, uint8_t *e,uint8_t *f); void nr_deinterleaving_ldpc(uint32_t E, uint8_t Qm, int16_t *e,int16_t *f); -int nr_rate_matching_ldpc(uint8_t Ilbrm, - uint32_t Tbslbrm, +int nr_rate_matching_ldpc(uint32_t Tbslbrm, uint8_t BG, uint16_t Z, uint8_t *w, @@ -501,8 +483,7 @@ int nr_rate_matching_ldpc(uint8_t Ilbrm, uint8_t rvidx, uint32_t E); -int nr_rate_matching_ldpc_rx(uint8_t Ilbrm, - uint32_t Tbslbrm, +int nr_rate_matching_ldpc_rx(uint32_t Tbslbrm, uint8_t BG, uint16_t Z, int16_t *w, diff --git a/openair1/PHY/CODING/crc_byte.c b/openair1/PHY/CODING/crc_byte.c index 7e37abcf81..9ad18cc1a6 100644 --- a/openair1/PHY/CODING/crc_byte.c +++ b/openair1/PHY/CODING/crc_byte.c @@ -72,10 +72,10 @@ unsigned int crcbit (unsigned char * inputptr, unsigned int i, crc = 0, c; while (octetlen-- > 0) { - c = (*inputptr++) << 24; + c = ((unsigned int)(*inputptr++)) << 24; for (i = 8; i != 0; i--) { - if ((1 << 31) & (c ^ crc)) + if ((1U << 31) & (c ^ crc)) crc = (crc << 1) ^ poly; else crc <<= 1; diff --git a/openair1/PHY/CODING/nrLDPC_decoder/nrLDPC_bnProc.h b/openair1/PHY/CODING/nrLDPC_decoder/nrLDPC_bnProc.h index 878150a9a8..91f552f935 100644 --- a/openair1/PHY/CODING/nrLDPC_decoder/nrLDPC_bnProc.h +++ b/openair1/PHY/CODING/nrLDPC_decoder/nrLDPC_bnProc.h @@ -37,17 +37,12 @@ \param p_lut Pointer to decoder LUTs \param Z Lifting size */ -static inline void nrLDPC_bnProcPc(t_nrLDPC_lut* p_lut, t_nrLDPC_procBuf* p_procBuf, uint16_t Z) +static inline void nrLDPC_bnProcPc(t_nrLDPC_lut* p_lut, int8_t* bnProcBuf, int8_t* bnProcBufRes, int8_t* llrProcBuf, int8_t* llrRes, uint16_t Z) { const uint8_t* lut_numBnInBnGroups = p_lut->numBnInBnGroups; const uint32_t* lut_startAddrBnGroups = p_lut->startAddrBnGroups; const uint16_t* lut_startAddrBnGroupsLlr = p_lut->startAddrBnGroupsLlr; - int8_t* bnProcBuf = p_procBuf->bnProcBuf; - int8_t* bnProcBufRes = p_procBuf->bnProcBufRes; - int8_t* llrRes = p_procBuf->llrRes; - int8_t* llrProcBuf = p_procBuf->llrProcBuf; - __m128i* p_bnProcBuf; __m256i* p_bnProcBufRes; __m128i* p_llrProcBuf; @@ -1681,7 +1676,7 @@ static inline void nrLDPC_bnProcPc(t_nrLDPC_lut* p_lut, t_nrLDPC_procBuf* p_proc \param p_lut Pointer to decoder LUTs \param Z Lifting size */ -static inline void nrLDPC_bnProc(t_nrLDPC_lut* p_lut, t_nrLDPC_procBuf* p_procBuf, uint16_t Z) +static inline void nrLDPC_bnProc(t_nrLDPC_lut* p_lut, int8_t* bnProcBuf, int8_t* bnProcBufRes, int8_t* llrRes, uint16_t Z) { // BN Processing calculating the values to send back to the CNs for next iteration // bnProcBufRes contains the sum of all edges to each BN at the start of each group @@ -1690,10 +1685,6 @@ static inline void nrLDPC_bnProc(t_nrLDPC_lut* p_lut, t_nrLDPC_procBuf* p_procBu const uint32_t* lut_startAddrBnGroups = p_lut->startAddrBnGroups; const uint16_t* lut_startAddrBnGroupsLlr = p_lut->startAddrBnGroupsLlr; - int8_t* bnProcBuf = p_procBuf->bnProcBuf; - int8_t* bnProcBufRes = p_procBuf->bnProcBufRes; - int8_t* llrRes = p_procBuf->llrRes; - __m256i* p_bnProcBuf; __m256i* p_bnProcBufRes; __m256i* p_llrRes; diff --git a/openair1/PHY/CODING/nrLDPC_decoder/nrLDPC_cnProc.h b/openair1/PHY/CODING/nrLDPC_decoder/nrLDPC_cnProc.h index db9d6e4119..6d82fe5f11 100644 --- a/openair1/PHY/CODING/nrLDPC_decoder/nrLDPC_cnProc.h +++ b/openair1/PHY/CODING/nrLDPC_decoder/nrLDPC_cnProc.h @@ -37,14 +37,11 @@ \param p_procBuf Pointer to processing buffers \param Z Lifting size */ -static inline void nrLDPC_cnProc_BG2(t_nrLDPC_lut* p_lut, t_nrLDPC_procBuf* p_procBuf, uint16_t Z) +static inline void nrLDPC_cnProc_BG2(t_nrLDPC_lut* p_lut, int8_t* cnProcBuf, int8_t* cnProcBufRes, uint16_t Z) { const uint8_t* lut_numCnInCnGroups = p_lut->numCnInCnGroups; const uint32_t* lut_startAddrCnGroups = p_lut->startAddrCnGroups; - int8_t* cnProcBuf = p_procBuf->cnProcBuf; - int8_t* cnProcBufRes = p_procBuf->cnProcBufRes; - __m256i* p_cnProcBuf; __m256i* p_cnProcBufRes; @@ -372,14 +369,11 @@ static inline void nrLDPC_cnProc_BG2(t_nrLDPC_lut* p_lut, t_nrLDPC_procBuf* p_pr \param p_lut Pointer to decoder LUTs \param Z Lifting size */ -static inline void nrLDPC_cnProc_BG1(t_nrLDPC_lut* p_lut, t_nrLDPC_procBuf* p_procBuf, uint16_t Z) +static inline void nrLDPC_cnProc_BG1(t_nrLDPC_lut* p_lut, int8_t* cnProcBuf, int8_t* cnProcBufRes, uint16_t Z) { const uint8_t* lut_numCnInCnGroups = p_lut->numCnInCnGroups; const uint32_t* lut_startAddrCnGroups = p_lut->startAddrCnGroups; - int8_t* cnProcBuf = p_procBuf->cnProcBuf; - int8_t* cnProcBufRes = p_procBuf->cnProcBufRes; - __m256i* p_cnProcBuf; __m256i* p_cnProcBufRes; @@ -871,14 +865,11 @@ static inline void nrLDPC_cnProc_BG1(t_nrLDPC_lut* p_lut, t_nrLDPC_procBuf* p_pr \param Z Lifting size \return 32-bit parity check indicator */ -static inline uint32_t nrLDPC_cnProcPc_BG1(t_nrLDPC_lut* p_lut, t_nrLDPC_procBuf* p_procBuf, uint16_t Z) +static inline uint32_t nrLDPC_cnProcPc_BG1(t_nrLDPC_lut* p_lut, int8_t* cnProcBuf, int8_t* cnProcBufRes, uint16_t Z) { const uint8_t* lut_numCnInCnGroups = p_lut->numCnInCnGroups; const uint32_t* lut_startAddrCnGroups = p_lut->startAddrCnGroups; - int8_t* cnProcBuf = p_procBuf->cnProcBuf; - int8_t* cnProcBufRes = p_procBuf->cnProcBufRes; - __m256i* p_cnProcBuf; __m256i* p_cnProcBufRes; @@ -1506,14 +1497,11 @@ static inline uint32_t nrLDPC_cnProcPc_BG1(t_nrLDPC_lut* p_lut, t_nrLDPC_procBuf \param Z Lifting size \return 32-bit parity check indicator */ -static inline uint32_t nrLDPC_cnProcPc_BG2(t_nrLDPC_lut* p_lut, t_nrLDPC_procBuf* p_procBuf, uint16_t Z) +static inline uint32_t nrLDPC_cnProcPc_BG2(t_nrLDPC_lut* p_lut, int8_t* cnProcBuf, int8_t* cnProcBufRes, uint16_t Z) { const uint8_t* lut_numCnInCnGroups = p_lut->numCnInCnGroups; const uint32_t* lut_startAddrCnGroups = p_lut->startAddrCnGroups; - int8_t* cnProcBuf = p_procBuf->cnProcBuf; - int8_t* cnProcBufRes = p_procBuf->cnProcBufRes; - __m256i* p_cnProcBuf; __m256i* p_cnProcBufRes; diff --git a/openair1/PHY/CODING/nrLDPC_decoder/nrLDPC_decoder.c b/openair1/PHY/CODING/nrLDPC_decoder/nrLDPC_decoder.c index 166cd9a5a3..bf0f401e97 100644 --- a/openair1/PHY/CODING/nrLDPC_decoder/nrLDPC_decoder.c +++ b/openair1/PHY/CODING/nrLDPC_decoder/nrLDPC_decoder.c @@ -45,22 +45,22 @@ #include "nrLDPC_tools/nrLDPC_debug.h" #endif -static inline uint32_t nrLDPC_decoder_core(int8_t* p_llr, int8_t* p_out, t_nrLDPC_procBuf* p_procBuf, uint32_t numLLR, t_nrLDPC_lut* p_lut, t_nrLDPC_dec_params* p_decParams, t_nrLDPC_time_stats* p_profiler); +static inline uint32_t nrLDPC_decoder_core(int8_t* p_llr, int8_t* p_out, uint32_t numLLR, t_nrLDPC_lut* p_lut, t_nrLDPC_dec_params* p_decParams, t_nrLDPC_time_stats* p_profiler); +int check_crc(uint8_t* decoded_bytes, uint32_t n, uint32_t F, uint8_t crc_type); void nrLDPC_initcall(t_nrLDPC_dec_params* p_decParams, int8_t* p_llr, int8_t* p_out) { } -int32_t nrLDPC_decod(t_nrLDPC_dec_params* p_decParams, int8_t* p_llr, int8_t* p_out, t_nrLDPC_procBuf* p_procBuf, t_nrLDPC_time_stats* p_profiler) +int32_t nrLDPC_decod(t_nrLDPC_dec_params* p_decParams, int8_t* p_llr, int8_t* p_out, t_nrLDPC_time_stats* p_profiler) { uint32_t numLLR; uint32_t numIter = 0; t_nrLDPC_lut lut; t_nrLDPC_lut* p_lut = &lut; - //printf("p_procBuf->cnProcBuf = %p\n", p_procBuf->cnProcBuf); // Initialize decoder core(s) with correct LUTs numLLR = nrLDPC_init(p_decParams, p_lut); // Launch LDPC decoder core for one segment - numIter = nrLDPC_decoder_core(p_llr, p_out, p_procBuf, numLLR, p_lut, p_decParams, p_profiler); + numIter = nrLDPC_decoder_core(p_llr, p_out, numLLR, p_lut, p_decParams, p_profiler); return numIter; } @@ -74,13 +74,20 @@ int32_t nrLDPC_decod(t_nrLDPC_dec_params* p_decParams, int8_t* p_llr, int8_t* p_ \param p_decParams LDPC decoder parameters \param p_profiler LDPC profiler statistics */ -static inline uint32_t nrLDPC_decoder_core(int8_t* p_llr, int8_t* p_out, t_nrLDPC_procBuf* p_procBuf, uint32_t numLLR, t_nrLDPC_lut* p_lut, t_nrLDPC_dec_params* p_decParams, t_nrLDPC_time_stats* p_profiler) +static inline uint32_t nrLDPC_decoder_core(int8_t* p_llr, int8_t* p_out, uint32_t numLLR, t_nrLDPC_lut* p_lut, t_nrLDPC_dec_params* p_decParams, t_nrLDPC_time_stats* p_profiler) { uint16_t Z = p_decParams->Z; uint8_t BG = p_decParams->BG; uint8_t numMaxIter = p_decParams->numMaxIter; e_nrLDPC_outMode outMode = p_decParams->outMode; + int8_t cnProcBuf[NR_LDPC_SIZE_CN_PROC_BUF] __attribute__ ((aligned(32))) = {0}; + int8_t cnProcBufRes[NR_LDPC_SIZE_CN_PROC_BUF] __attribute__ ((aligned(32))) = {0}; + int8_t bnProcBuf[NR_LDPC_SIZE_BN_PROC_BUF] __attribute__ ((aligned(32))) = {0}; + int8_t bnProcBufRes[NR_LDPC_SIZE_BN_PROC_BUF] __attribute__ ((aligned(32))) = {0}; + int8_t llrRes[NR_LDPC_MAX_NUM_LLR] __attribute__ ((aligned(32))) = {0}; + int8_t llrProcBuf[NR_LDPC_MAX_NUM_LLR] __attribute__ ((aligned(32))) = {0}; + int8_t llrOut[NR_LDPC_MAX_NUM_LLR] __attribute__ ((aligned(32))) = {0}; // Minimum number of iterations is 1 // 0 iterations means hard-decision on input LLRs uint32_t i = 1; @@ -95,9 +102,7 @@ static inline uint32_t nrLDPC_decoder_core(int8_t* p_llr, int8_t* p_out, t_nrLDP else { // Use LLR processing buffer as temporary output buffer - p_llrOut = p_procBuf->llrProcBuf; - // Clear llrProcBuf - memset(p_llrOut,0, NR_LDPC_MAX_NUM_LLR*sizeof(int8_t)); + p_llrOut = llrOut; } @@ -105,14 +110,14 @@ static inline uint32_t nrLDPC_decoder_core(int8_t* p_llr, int8_t* p_out, t_nrLDP #ifdef NR_LDPC_PROFILER_DETAIL start_meas(&p_profiler->llr2llrProcBuf); #endif - nrLDPC_llr2llrProcBuf(p_lut, p_llr, p_procBuf, Z, BG); + nrLDPC_llr2llrProcBuf(p_lut, p_llr, llrProcBuf, Z, BG); #ifdef NR_LDPC_PROFILER_DETAIL stop_meas(&p_profiler->llr2llrProcBuf); #endif #ifdef NR_LDPC_DEBUG_MODE nrLDPC_debug_initBuffer2File(nrLDPC_buffers_LLR_PROC); - nrLDPC_debug_writeBuffer2File(nrLDPC_buffers_LLR_PROC, p_procBuf); + nrLDPC_debug_writeBuffer2File(nrLDPC_buffers_LLR_PROC, llrProcBuf); #endif #ifdef NR_LDPC_PROFILER_DETAIL @@ -120,11 +125,11 @@ static inline uint32_t nrLDPC_decoder_core(int8_t* p_llr, int8_t* p_out, t_nrLDP #endif if (BG == 1) { - nrLDPC_llr2CnProcBuf_BG1(p_lut, p_llr, p_procBuf, Z); + nrLDPC_llr2CnProcBuf_BG1(p_lut, p_llr, cnProcBuf, Z); } else { - nrLDPC_llr2CnProcBuf_BG2(p_lut, p_llr, p_procBuf, Z); + nrLDPC_llr2CnProcBuf_BG2(p_lut, p_llr, cnProcBuf, Z); } #ifdef NR_LDPC_PROFILER_DETAIL stop_meas(&p_profiler->llr2CnProcBuf); @@ -132,7 +137,7 @@ static inline uint32_t nrLDPC_decoder_core(int8_t* p_llr, int8_t* p_out, t_nrLDP #ifdef NR_LDPC_DEBUG_MODE nrLDPC_debug_initBuffer2File(nrLDPC_buffers_CN_PROC); - nrLDPC_debug_writeBuffer2File(nrLDPC_buffers_CN_PROC, p_procBuf); + nrLDPC_debug_writeBuffer2File(nrLDPC_buffers_CN_PROC, cnProcBuf); #endif // First iteration @@ -143,11 +148,11 @@ static inline uint32_t nrLDPC_decoder_core(int8_t* p_llr, int8_t* p_out, t_nrLDP #endif if (BG == 1) { - nrLDPC_cnProc_BG1(p_lut, p_procBuf, Z); + nrLDPC_cnProc_BG1(p_lut, cnProcBuf, cnProcBufRes, Z); } else { - nrLDPC_cnProc_BG2(p_lut, p_procBuf, Z); + nrLDPC_cnProc_BG2(p_lut, cnProcBuf, cnProcBufRes, Z); } #ifdef NR_LDPC_PROFILER_DETAIL stop_meas(&p_profiler->cnProc); @@ -155,7 +160,7 @@ static inline uint32_t nrLDPC_decoder_core(int8_t* p_llr, int8_t* p_out, t_nrLDP #ifdef NR_LDPC_DEBUG_MODE nrLDPC_debug_initBuffer2File(nrLDPC_buffers_CN_PROC_RES); - nrLDPC_debug_writeBuffer2File(nrLDPC_buffers_CN_PROC_RES, p_procBuf); + nrLDPC_debug_writeBuffer2File(nrLDPC_buffers_CN_PROC_RES, cnProcBufRes); #endif #ifdef NR_LDPC_PROFILER_DETAIL @@ -163,11 +168,11 @@ static inline uint32_t nrLDPC_decoder_core(int8_t* p_llr, int8_t* p_out, t_nrLDP #endif if (BG == 1) { - nrLDPC_cn2bnProcBuf_BG1(p_lut, p_procBuf, Z); + nrLDPC_cn2bnProcBuf_BG1(p_lut, cnProcBufRes, bnProcBuf, Z); } else { - nrLDPC_cn2bnProcBuf_BG2(p_lut, p_procBuf, Z); + nrLDPC_cn2bnProcBuf_BG2(p_lut, cnProcBufRes, bnProcBuf, Z); } #ifdef NR_LDPC_PROFILER_DETAIL stop_meas(&p_profiler->cn2bnProcBuf); @@ -175,34 +180,34 @@ static inline uint32_t nrLDPC_decoder_core(int8_t* p_llr, int8_t* p_out, t_nrLDP #ifdef NR_LDPC_DEBUG_MODE nrLDPC_debug_initBuffer2File(nrLDPC_buffers_BN_PROC); - nrLDPC_debug_writeBuffer2File(nrLDPC_buffers_BN_PROC, p_procBuf); + nrLDPC_debug_writeBuffer2File(nrLDPC_buffers_BN_PROC, bnProcBuf); #endif // BN processing #ifdef NR_LDPC_PROFILER_DETAIL start_meas(&p_profiler->bnProcPc); #endif - nrLDPC_bnProcPc(p_lut, p_procBuf, Z); + nrLDPC_bnProcPc(p_lut, bnProcBuf, bnProcBufRes, llrProcBuf, llrRes, Z); #ifdef NR_LDPC_PROFILER_DETAIL stop_meas(&p_profiler->bnProcPc); #endif #ifdef NR_LDPC_DEBUG_MODE nrLDPC_debug_initBuffer2File(nrLDPC_buffers_LLR_RES); - nrLDPC_debug_writeBuffer2File(nrLDPC_buffers_LLR_RES, p_procBuf); + nrLDPC_debug_writeBuffer2File(nrLDPC_buffers_LLR_RES, llrRes); #endif #ifdef NR_LDPC_PROFILER_DETAIL start_meas(&p_profiler->bnProc); #endif - nrLDPC_bnProc(p_lut, p_procBuf, Z); + nrLDPC_bnProc(p_lut, bnProcBuf, bnProcBufRes, llrRes, Z); #ifdef NR_LDPC_PROFILER_DETAIL stop_meas(&p_profiler->bnProc); #endif #ifdef NR_LDPC_DEBUG_MODE nrLDPC_debug_initBuffer2File(nrLDPC_buffers_BN_PROC_RES); - nrLDPC_debug_writeBuffer2File(nrLDPC_buffers_BN_PROC_RES, p_procBuf); + nrLDPC_debug_writeBuffer2File(nrLDPC_buffers_BN_PROC_RES, bnProcBufRes); #endif // BN results to CN processing buffer @@ -211,18 +216,18 @@ static inline uint32_t nrLDPC_decoder_core(int8_t* p_llr, int8_t* p_out, t_nrLDP #endif if (BG == 1) { - nrLDPC_bn2cnProcBuf_BG1(p_lut, p_procBuf, Z); + nrLDPC_bn2cnProcBuf_BG1(p_lut, bnProcBufRes, cnProcBuf, Z); } else { - nrLDPC_bn2cnProcBuf_BG2(p_lut, p_procBuf, Z); + nrLDPC_bn2cnProcBuf_BG2(p_lut, bnProcBufRes, cnProcBuf, Z); } #ifdef NR_LDPC_PROFILER_DETAIL stop_meas(&p_profiler->bn2cnProcBuf); #endif #ifdef NR_LDPC_DEBUG_MODE - nrLDPC_debug_writeBuffer2File(nrLDPC_buffers_CN_PROC, p_procBuf); + nrLDPC_debug_writeBuffer2File(nrLDPC_buffers_CN_PROC, cnProcBuf); #endif // Parity Check not necessary here since it will fail @@ -242,18 +247,18 @@ static inline uint32_t nrLDPC_decoder_core(int8_t* p_llr, int8_t* p_out, t_nrLDP #endif if (BG == 1) { - nrLDPC_cnProc_BG1(p_lut, p_procBuf, Z); + nrLDPC_cnProc_BG1(p_lut, cnProcBuf, cnProcBufRes, Z); } else { - nrLDPC_cnProc_BG2(p_lut, p_procBuf, Z); + nrLDPC_cnProc_BG2(p_lut, cnProcBuf, cnProcBufRes, Z); } #ifdef NR_LDPC_PROFILER_DETAIL stop_meas(&p_profiler->cnProc); #endif #ifdef NR_LDPC_DEBUG_MODE - nrLDPC_debug_writeBuffer2File(nrLDPC_buffers_CN_PROC_RES, p_procBuf); + nrLDPC_debug_writeBuffer2File(nrLDPC_buffers_CN_PROC_RES, cnProcBufRes); #endif // Send CN results back to BNs @@ -262,43 +267,43 @@ static inline uint32_t nrLDPC_decoder_core(int8_t* p_llr, int8_t* p_out, t_nrLDP #endif if (BG == 1) { - nrLDPC_cn2bnProcBuf_BG1(p_lut, p_procBuf, Z); + nrLDPC_cn2bnProcBuf_BG1(p_lut, cnProcBufRes, bnProcBuf, Z); } else { - nrLDPC_cn2bnProcBuf_BG2(p_lut, p_procBuf, Z); + nrLDPC_cn2bnProcBuf_BG2(p_lut, cnProcBufRes, bnProcBuf, Z); } #ifdef NR_LDPC_PROFILER_DETAIL stop_meas(&p_profiler->cn2bnProcBuf); #endif #ifdef NR_LDPC_DEBUG_MODE - nrLDPC_debug_writeBuffer2File(nrLDPC_buffers_BN_PROC, p_procBuf); + nrLDPC_debug_writeBuffer2File(nrLDPC_buffers_BN_PROC, bnProcBuf); #endif // BN Processing #ifdef NR_LDPC_PROFILER_DETAIL start_meas(&p_profiler->bnProcPc); #endif - nrLDPC_bnProcPc(p_lut, p_procBuf, Z); + nrLDPC_bnProcPc(p_lut, bnProcBuf, bnProcBufRes, llrProcBuf, llrRes, Z); #ifdef NR_LDPC_PROFILER_DETAIL stop_meas(&p_profiler->bnProcPc); #endif #ifdef NR_LDPC_DEBUG_MODE - nrLDPC_debug_writeBuffer2File(nrLDPC_buffers_LLR_RES, p_procBuf); + nrLDPC_debug_writeBuffer2File(nrLDPC_buffers_LLR_RES, llrRes); #endif #ifdef NR_LDPC_PROFILER_DETAIL start_meas(&p_profiler->bnProc); #endif - nrLDPC_bnProc(p_lut, p_procBuf, Z); + nrLDPC_bnProc(p_lut, bnProcBuf, bnProcBufRes, llrRes, Z); #ifdef NR_LDPC_PROFILER_DETAIL stop_meas(&p_profiler->bnProc); #endif #ifdef NR_LDPC_DEBUG_MODE - nrLDPC_debug_writeBuffer2File(nrLDPC_buffers_BN_PROC_RES, p_procBuf); + nrLDPC_debug_writeBuffer2File(nrLDPC_buffers_BN_PROC_RES, bnProcBufRes); #endif // BN results to CN processing buffer @@ -307,18 +312,18 @@ static inline uint32_t nrLDPC_decoder_core(int8_t* p_llr, int8_t* p_out, t_nrLDP #endif if (BG == 1) { - nrLDPC_bn2cnProcBuf_BG1(p_lut, p_procBuf, Z); + nrLDPC_bn2cnProcBuf_BG1(p_lut, bnProcBufRes, cnProcBuf, Z); } else { - nrLDPC_bn2cnProcBuf_BG2(p_lut, p_procBuf, Z); + nrLDPC_bn2cnProcBuf_BG2(p_lut, bnProcBufRes, cnProcBuf, Z); } #ifdef NR_LDPC_PROFILER_DETAIL stop_meas(&p_profiler->bn2cnProcBuf); #endif #ifdef NR_LDPC_DEBUG_MODE - nrLDPC_debug_writeBuffer2File(nrLDPC_buffers_CN_PROC, p_procBuf); + nrLDPC_debug_writeBuffer2File(nrLDPC_buffers_CN_PROC, cnProcBuf); #endif // Parity Check @@ -328,123 +333,11 @@ static inline uint32_t nrLDPC_decoder_core(int8_t* p_llr, int8_t* p_out, t_nrLDP #endif if (BG == 1) { - pcRes = nrLDPC_cnProcPc_BG1(p_lut, p_procBuf, Z); + pcRes = nrLDPC_cnProcPc_BG1(p_lut, cnProcBuf, cnProcBufRes, Z); } else { - pcRes = nrLDPC_cnProcPc_BG2(p_lut, p_procBuf, Z); - } -#ifdef NR_LDPC_PROFILER_DETAIL - stop_meas(&p_profiler->cnProcPc); -#endif -#endif - } - - // Last iteration - if ( (i < numMaxIter) && (pcRes != 0) ) - { - // Increase iteration counter - i++; - - // CN processing -#ifdef NR_LDPC_PROFILER_DETAIL - start_meas(&p_profiler->cnProc); -#endif - if (BG == 1) - { - nrLDPC_cnProc_BG1(p_lut, p_procBuf, Z); - } - else - { - nrLDPC_cnProc_BG2(p_lut, p_procBuf, Z); - } -#ifdef NR_LDPC_PROFILER_DETAIL - stop_meas(&p_profiler->cnProc); -#endif - -#ifdef NR_LDPC_DEBUG_MODE - nrLDPC_debug_writeBuffer2File(nrLDPC_buffers_CN_PROC_RES, p_procBuf); -#endif - - // Send CN results back to BNs -#ifdef NR_LDPC_PROFILER_DETAIL - start_meas(&p_profiler->cn2bnProcBuf); -#endif - if (BG == 1) - { - nrLDPC_cn2bnProcBuf_BG1(p_lut, p_procBuf, Z); - } - else - { - nrLDPC_cn2bnProcBuf_BG2(p_lut, p_procBuf, Z); - } -#ifdef NR_LDPC_PROFILER_DETAIL - stop_meas(&p_profiler->cn2bnProcBuf); -#endif - -#ifdef NR_LDPC_DEBUG_MODE - nrLDPC_debug_writeBuffer2File(nrLDPC_buffers_BN_PROC, p_procBuf); -#endif - - // BN Processing -#ifdef NR_LDPC_PROFILER_DETAIL - start_meas(&p_profiler->bnProcPc); -#endif - nrLDPC_bnProcPc(p_lut, p_procBuf, Z); -#ifdef NR_LDPC_PROFILER_DETAIL - stop_meas(&p_profiler->bnProcPc); -#endif - -#ifdef NR_LDPC_DEBUG_MODE - nrLDPC_debug_writeBuffer2File(nrLDPC_buffers_LLR_RES, p_procBuf); -#endif - - // If parity check not enabled, no need to send the BN proc results - // back to CNs -#ifdef NR_LDPC_ENABLE_PARITY_CHECK -#ifdef NR_LDPC_PROFILER_DETAIL - start_meas(&p_profiler->bnProc); -#endif - nrLDPC_bnProc(p_lut, p_procBuf, Z); -#ifdef NR_LDPC_PROFILER_DETAIL - stop_meas(&p_profiler->bnProc); -#endif - -#ifdef NR_LDPC_DEBUG_MODE - nrLDPC_debug_writeBuffer2File(nrLDPC_buffers_BN_PROC_RES, p_procBuf); -#endif - - // BN results to CN processing buffer -#ifdef NR_LDPC_PROFILER_DETAIL - start_meas(&p_profiler->bn2cnProcBuf); -#endif - if (BG == 1) - { - nrLDPC_bn2cnProcBuf_BG1(p_lut, p_procBuf, Z); - } - else - { - nrLDPC_bn2cnProcBuf_BG2(p_lut, p_procBuf, Z); - } -#ifdef NR_LDPC_PROFILER_DETAIL - stop_meas(&p_profiler->bn2cnProcBuf); -#endif - -#ifdef NR_LDPC_DEBUG_MODE - nrLDPC_debug_writeBuffer2File(nrLDPC_buffers_CN_PROC, p_procBuf); -#endif - - // Parity Check -#ifdef NR_LDPC_PROFILER_DETAIL - start_meas(&p_profiler->cnProcPc); -#endif - if (BG == 1) - { - pcRes = nrLDPC_cnProcPc_BG1(p_lut, p_procBuf, Z); - } - else - { - pcRes = nrLDPC_cnProcPc_BG2(p_lut, p_procBuf, Z); + pcRes = nrLDPC_cnProcPc_BG2(p_lut, cnProcBuf, cnProcBufRes, Z); } #ifdef NR_LDPC_PROFILER_DETAIL stop_meas(&p_profiler->cnProcPc); @@ -466,7 +359,7 @@ static inline uint32_t nrLDPC_decoder_core(int8_t* p_llr, int8_t* p_out, t_nrLDP #ifdef NR_LDPC_PROFILER_DETAIL start_meas(&p_profiler->llrRes2llrOut); #endif - nrLDPC_llrRes2llrOut(p_lut, p_llrOut, p_procBuf, Z, BG); + nrLDPC_llrRes2llrOut(p_lut, p_llrOut, llrRes, Z, BG); #ifdef NR_LDPC_PROFILER_DETAIL stop_meas(&p_profiler->llrRes2llrOut); #endif diff --git a/openair1/PHY/CODING/nrLDPC_decoder/nrLDPC_init_mem.h b/openair1/PHY/CODING/nrLDPC_decoder/nrLDPC_init_mem.h deleted file mode 100644 index f08549130e..0000000000 --- a/openair1/PHY/CODING/nrLDPC_decoder/nrLDPC_init_mem.h +++ /dev/null @@ -1,83 +0,0 @@ -/* - * Licensed to the OpenAirInterface (OAI) Software Alliance under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The OpenAirInterface Software Alliance licenses this file to You under - * the OAI Public License, Version 1.1 (the "License"); you may not use this file - * except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.openairinterface.org/?page_id=698 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - *------------------------------------------------------------------------------- - * For more information about the OpenAirInterface (OAI) Software Alliance: - * contact@openairinterface.org - */ - -/*!\file nrLDPC_init_mem.h - * \brief Defines the function to initialize the LDPC decoder and sets correct LUTs. - * \author Sebastian Wagner (TCL Communications) Email: - * \date 07-12-2018 - * \version 1.0 - * \note - * \warning - */ - -#ifndef __NR_LDPC_INIT_MEM__H__ -#define __NR_LDPC_INIT_MEM__H__ - -#include -#include "nrLDPC_types.h" - -/** - \brief Allocates 32 byte aligned memory and initializes to zero - \param size Input size in bytes - \return Pointer to memory -*/ -static inline void* malloc32_clear(size_t size) -{ - void* ptr = (void*) memalign(32, size+32); - memset(ptr, 0, size); - return ptr; -} - -/** - \brief Allocates and initializes the internal decoder processing buffers - \param p_decParams Pointer to decoder parameters - \param p_lut Pointer to decoder LUTs - \return Number of LLR values -*/ -static inline t_nrLDPC_procBuf* nrLDPC_init_mem(void) -{ - t_nrLDPC_procBuf* p_procBuf = (t_nrLDPC_procBuf*) malloc32_clear(sizeof(t_nrLDPC_procBuf)); - - if (p_procBuf) - { - p_procBuf->cnProcBuf = (int8_t*) malloc32_clear(NR_LDPC_SIZE_CN_PROC_BUF*sizeof(int8_t)); - p_procBuf->cnProcBufRes = (int8_t*) malloc32_clear(NR_LDPC_SIZE_CN_PROC_BUF*sizeof(int8_t)); - p_procBuf->bnProcBuf = (int8_t*) malloc32_clear(NR_LDPC_SIZE_BN_PROC_BUF*sizeof(int8_t)); - p_procBuf->bnProcBufRes = (int8_t*) malloc32_clear(NR_LDPC_SIZE_BN_PROC_BUF*sizeof(int8_t)); - p_procBuf->llrRes = (int8_t*) malloc32_clear(NR_LDPC_MAX_NUM_LLR *sizeof(int8_t)); - p_procBuf->llrProcBuf = (int8_t*) malloc32_clear(NR_LDPC_MAX_NUM_LLR *sizeof(int8_t)); - } - - return(p_procBuf); -} - -static inline void nrLDPC_free_mem(t_nrLDPC_procBuf* p_procBuf) -{ - free(p_procBuf->cnProcBuf); - free(p_procBuf->cnProcBufRes); - free(p_procBuf->bnProcBuf); - free(p_procBuf->bnProcBufRes); - free(p_procBuf->llrRes); - free(p_procBuf->llrProcBuf); - - free(p_procBuf); -} -#endif diff --git a/openair1/PHY/CODING/nrLDPC_decoder/nrLDPC_mPass.h b/openair1/PHY/CODING/nrLDPC_decoder/nrLDPC_mPass.h index b76750459d..7f514d5cfa 100644 --- a/openair1/PHY/CODING/nrLDPC_decoder/nrLDPC_mPass.h +++ b/openair1/PHY/CODING/nrLDPC_decoder/nrLDPC_mPass.h @@ -97,7 +97,7 @@ static inline void *nrLDPC_circ_memcpy(int8_t *str1, const int8_t *str2, uint16_ \param Z Lifting size \param BG Base graph */ -static inline void nrLDPC_llr2llrProcBuf(t_nrLDPC_lut* p_lut, int8_t* llr, t_nrLDPC_procBuf* p_procBuf, uint16_t Z, uint8_t BG) +static inline void nrLDPC_llr2llrProcBuf(t_nrLDPC_lut* p_lut, int8_t* llr, int8_t* llrProcBuf, uint16_t Z, uint8_t BG) { uint32_t i; const uint8_t numBn2CnG1 = p_lut->numBnInBnGroups[0]; @@ -109,7 +109,6 @@ static inline void nrLDPC_llr2llrProcBuf(t_nrLDPC_lut* p_lut, int8_t* llr, t_nrL const uint8_t* lut_llr2llrProcBufBnPos = p_lut->llr2llrProcBufBnPos; uint32_t idxBn; - int8_t* llrProcBuf = p_procBuf->llrProcBuf; // Copy LLRs connected to 1 CN if (numBn2CnG1 > 0) @@ -133,7 +132,7 @@ static inline void nrLDPC_llr2llrProcBuf(t_nrLDPC_lut* p_lut, int8_t* llr, t_nrL \param p_procBuf Pointer to the processing buffers \param Z Lifting size */ -static inline void nrLDPC_llr2CnProcBuf_BG1(t_nrLDPC_lut* p_lut, int8_t* llr, t_nrLDPC_procBuf* p_procBuf, uint16_t Z) +static inline void nrLDPC_llr2CnProcBuf_BG1(t_nrLDPC_lut* p_lut, int8_t* llr, int8_t* cnProcBuf, uint16_t Z) { const uint16_t (*lut_circShift_CNG3) [lut_numCnInCnGroups_BG1_R13[0]] = (const uint16_t(*)[lut_numCnInCnGroups_BG1_R13[0]]) p_lut->circShift[0]; const uint16_t (*lut_circShift_CNG4) [lut_numCnInCnGroups_BG1_R13[1]] = (const uint16_t(*)[lut_numCnInCnGroups_BG1_R13[1]]) p_lut->circShift[1]; @@ -158,7 +157,6 @@ static inline void nrLDPC_llr2CnProcBuf_BG1(t_nrLDPC_lut* p_lut, int8_t* llr, t_ const uint8_t* lut_numCnInCnGroups = p_lut->numCnInCnGroups; const uint32_t* lut_startAddrCnGroups = p_lut->startAddrCnGroups; - int8_t* cnProcBuf = p_procBuf->cnProcBuf; uint32_t i; uint32_t j; @@ -342,7 +340,7 @@ static inline void nrLDPC_llr2CnProcBuf_BG1(t_nrLDPC_lut* p_lut, int8_t* llr, t_ \param p_procBuf Pointer to the processing buffers \param Z Lifting size */ -static inline void nrLDPC_llr2CnProcBuf_BG2(t_nrLDPC_lut* p_lut, int8_t* llr, t_nrLDPC_procBuf* p_procBuf, uint16_t Z) +static inline void nrLDPC_llr2CnProcBuf_BG2(t_nrLDPC_lut* p_lut, int8_t* llr, int8_t* cnProcBuf, uint16_t Z) { const uint16_t (*lut_circShift_CNG3) [lut_numCnInCnGroups_BG2_R15[0]] = (const uint16_t(*)[lut_numCnInCnGroups_BG2_R15[0]]) p_lut->circShift[0]; const uint16_t (*lut_circShift_CNG4) [lut_numCnInCnGroups_BG2_R15[1]] = (const uint16_t(*)[lut_numCnInCnGroups_BG2_R15[1]]) p_lut->circShift[1]; @@ -361,7 +359,6 @@ static inline void nrLDPC_llr2CnProcBuf_BG2(t_nrLDPC_lut* p_lut, int8_t* llr, t_ const uint8_t* lut_numCnInCnGroups = p_lut->numCnInCnGroups; const uint32_t* lut_startAddrCnGroups = p_lut->startAddrCnGroups; - int8_t* cnProcBuf = p_procBuf->cnProcBuf; uint32_t i; uint32_t j; @@ -478,7 +475,7 @@ static inline void nrLDPC_llr2CnProcBuf_BG2(t_nrLDPC_lut* p_lut, int8_t* llr, t_ \param p_procBuf Pointer to the processing buffers \param Z Lifting size */ -static inline void nrLDPC_cn2bnProcBuf_BG2(t_nrLDPC_lut* p_lut, t_nrLDPC_procBuf* p_procBuf, uint16_t Z) +static inline void nrLDPC_cn2bnProcBuf_BG2(t_nrLDPC_lut* p_lut, int8_t* cnProcBufRes, int8_t* bnProcBuf, uint16_t Z) { const uint8_t* lut_numCnInCnGroups = p_lut->numCnInCnGroups; const uint32_t* lut_startAddrCnGroups = p_lut->startAddrCnGroups; @@ -504,9 +501,6 @@ static inline void nrLDPC_cn2bnProcBuf_BG2(t_nrLDPC_lut* p_lut, t_nrLDPC_procBuf const uint8_t (*lut_bnPosBnProcBuf_CNG8) [lut_numCnInCnGroups[4]] = (const uint8_t(*)[lut_numCnInCnGroups[4]]) p_lut->bnPosBnProcBuf[4]; const uint8_t (*lut_bnPosBnProcBuf_CNG10) [lut_numCnInCnGroups[5]] = (const uint8_t(*)[lut_numCnInCnGroups[5]]) p_lut->bnPosBnProcBuf[5]; - int8_t* cnProcBufRes = p_procBuf->cnProcBufRes; - int8_t* bnProcBuf = p_procBuf->bnProcBuf; - int8_t* p_cnProcBufRes; uint32_t bitOffsetInGroup; uint32_t i; @@ -621,7 +615,7 @@ static inline void nrLDPC_cn2bnProcBuf_BG2(t_nrLDPC_lut* p_lut, t_nrLDPC_procBuf \param p_procBuf Pointer to the processing buffers \param Z Lifting size */ -static inline void nrLDPC_cn2bnProcBuf_BG1(t_nrLDPC_lut* p_lut, t_nrLDPC_procBuf* p_procBuf, uint16_t Z) +static inline void nrLDPC_cn2bnProcBuf_BG1(t_nrLDPC_lut* p_lut, int8_t* cnProcBufRes, int8_t* bnProcBuf, uint16_t Z) { const uint8_t* lut_numCnInCnGroups = p_lut->numCnInCnGroups; const uint32_t* lut_startAddrCnGroups = p_lut->startAddrCnGroups; @@ -655,9 +649,6 @@ static inline void nrLDPC_cn2bnProcBuf_BG1(t_nrLDPC_lut* p_lut, t_nrLDPC_procBuf const uint8_t (*lut_bnPosBnProcBuf_CNG10)[lut_numCnInCnGroups[7]] = (const uint8_t(*)[lut_numCnInCnGroups[7]]) p_lut->bnPosBnProcBuf[7]; const uint8_t (*lut_bnPosBnProcBuf_CNG19)[lut_numCnInCnGroups[8]] = (const uint8_t(*)[lut_numCnInCnGroups[8]]) p_lut->bnPosBnProcBuf[8]; - int8_t* cnProcBufRes = p_procBuf->cnProcBufRes; - int8_t* bnProcBuf = p_procBuf->bnProcBuf; - int8_t* p_cnProcBufRes; uint32_t bitOffsetInGroup; uint32_t i; @@ -819,7 +810,7 @@ static inline void nrLDPC_cn2bnProcBuf_BG1(t_nrLDPC_lut* p_lut, t_nrLDPC_procBuf \param p_procBuf Pointer to the processing buffers \param Z Lifting size */ -static inline void nrLDPC_bn2cnProcBuf_BG2(t_nrLDPC_lut* p_lut, t_nrLDPC_procBuf* p_procBuf, uint16_t Z) +static inline void nrLDPC_bn2cnProcBuf_BG2(t_nrLDPC_lut* p_lut, int8_t* bnProcBufRes, int8_t* cnProcBuf, uint16_t Z) { const uint8_t* lut_numCnInCnGroups = p_lut->numCnInCnGroups; const uint32_t* lut_startAddrCnGroups = p_lut->startAddrCnGroups; @@ -845,9 +836,6 @@ static inline void nrLDPC_bn2cnProcBuf_BG2(t_nrLDPC_lut* p_lut, t_nrLDPC_procBuf const uint8_t (*lut_bnPosBnProcBuf_CNG8) [lut_numCnInCnGroups[4]] = (const uint8_t(*)[lut_numCnInCnGroups[4]]) p_lut->bnPosBnProcBuf[4]; const uint8_t (*lut_bnPosBnProcBuf_CNG10) [lut_numCnInCnGroups[5]] = (const uint8_t(*)[lut_numCnInCnGroups[5]]) p_lut->bnPosBnProcBuf[5]; - int8_t* cnProcBuf = p_procBuf->cnProcBuf; - int8_t* bnProcBufRes = p_procBuf->bnProcBufRes; - int8_t* p_cnProcBuf; uint32_t bitOffsetInGroup; uint32_t i; @@ -961,7 +949,7 @@ static inline void nrLDPC_bn2cnProcBuf_BG2(t_nrLDPC_lut* p_lut, t_nrLDPC_procBuf \param p_procBuf Pointer to the processing buffers \param Z Lifting size */ -static inline void nrLDPC_bn2cnProcBuf_BG1(t_nrLDPC_lut* p_lut, t_nrLDPC_procBuf* p_procBuf, uint16_t Z) +static inline void nrLDPC_bn2cnProcBuf_BG1(t_nrLDPC_lut* p_lut, int8_t* bnProcBufRes, int8_t* cnProcBuf, uint16_t Z) { const uint8_t* lut_numCnInCnGroups = p_lut->numCnInCnGroups; const uint32_t* lut_startAddrCnGroups = p_lut->startAddrCnGroups; @@ -995,9 +983,6 @@ static inline void nrLDPC_bn2cnProcBuf_BG1(t_nrLDPC_lut* p_lut, t_nrLDPC_procBuf const uint8_t (*lut_bnPosBnProcBuf_CNG10)[lut_numCnInCnGroups[7]] = (const uint8_t(*)[lut_numCnInCnGroups[7]]) p_lut->bnPosBnProcBuf[7]; const uint8_t (*lut_bnPosBnProcBuf_CNG19)[lut_numCnInCnGroups[8]] = (const uint8_t(*)[lut_numCnInCnGroups[8]]) p_lut->bnPosBnProcBuf[8]; - int8_t* cnProcBuf = p_procBuf->cnProcBuf; - int8_t* bnProcBufRes = p_procBuf->bnProcBufRes; - int8_t* p_cnProcBuf; uint32_t bitOffsetInGroup; uint32_t i; @@ -1157,7 +1142,7 @@ static inline void nrLDPC_bn2cnProcBuf_BG1(t_nrLDPC_lut* p_lut, t_nrLDPC_procBuf \param Z Lifting size \param BG Base graph */ -static inline void nrLDPC_llrRes2llrOut(t_nrLDPC_lut* p_lut, int8_t* llrOut, t_nrLDPC_procBuf* p_procBuf, uint16_t Z, uint8_t BG) +static inline void nrLDPC_llrRes2llrOut(t_nrLDPC_lut* p_lut, int8_t* llrOut, int8_t* llrRes, uint16_t Z, uint8_t BG) { uint32_t i; const uint8_t numBn2CnG1 = p_lut->numBnInBnGroups[0]; @@ -1168,7 +1153,6 @@ static inline void nrLDPC_llrRes2llrOut(t_nrLDPC_lut* p_lut, int8_t* llrOut, t_n const uint16_t* lut_llr2llrProcBufAddr = p_lut->llr2llrProcBufAddr; const uint8_t* lut_llr2llrProcBufBnPos = p_lut->llr2llrProcBufBnPos; - int8_t* llrRes = p_procBuf->llrRes; int8_t* p_llrOut = &llrOut[0]; uint32_t idxBn; diff --git a/openair1/PHY/CODING/nrLDPC_decoder/nrLDPC_tools/nrLDPC_debug.h b/openair1/PHY/CODING/nrLDPC_decoder/nrLDPC_tools/nrLDPC_debug.h index e4dcb56edd..41c0a474a4 100644 --- a/openair1/PHY/CODING/nrLDPC_decoder/nrLDPC_tools/nrLDPC_debug.h +++ b/openair1/PHY/CODING/nrLDPC_decoder/nrLDPC_tools/nrLDPC_debug.h @@ -87,38 +87,38 @@ static inline void nrLDPC_initFile(const char* fileName) \brief Writes data of predefined buffers to file \param buffer Enum of buffer name to write */ -static inline void nrLDPC_debug_writeBuffer2File(e_nrLDPC_buffers buffer, t_nrLDPC_procBuf* p_procBuf) +static inline void nrLDPC_debug_writeBuffer2File(e_nrLDPC_buffers buffer, int8_t* p_buffer) { switch (buffer) { case nrLDPC_buffers_LLR_PROC: { - nrLDPC_writeFile("llrProcBuf.txt", p_procBuf->llrProcBuf, NR_LDPC_MAX_NUM_LLR); + nrLDPC_writeFile("llrProcBuf.txt", p_buffer, NR_LDPC_MAX_NUM_LLR); break; } case nrLDPC_buffers_CN_PROC: { - nrLDPC_writeFile("cnProcBuf.txt", p_procBuf->cnProcBuf, NR_LDPC_SIZE_CN_PROC_BUF); + nrLDPC_writeFile("cnProcBuf.txt", p_buffer, NR_LDPC_SIZE_CN_PROC_BUF); break; } case nrLDPC_buffers_CN_PROC_RES: { - nrLDPC_writeFile("cnProcBufRes.txt", p_procBuf->cnProcBufRes, NR_LDPC_SIZE_CN_PROC_BUF); + nrLDPC_writeFile("cnProcBufRes.txt", p_buffer, NR_LDPC_SIZE_CN_PROC_BUF); break; } case nrLDPC_buffers_BN_PROC: { - nrLDPC_writeFile("bnProcBuf.txt", p_procBuf->bnProcBuf, NR_LDPC_SIZE_BN_PROC_BUF); + nrLDPC_writeFile("bnProcBuf.txt", p_buffer, NR_LDPC_SIZE_BN_PROC_BUF); break; } case nrLDPC_buffers_BN_PROC_RES: { - nrLDPC_writeFile("bnProcBufRes.txt", p_procBuf->bnProcBufRes, NR_LDPC_SIZE_BN_PROC_BUF); + nrLDPC_writeFile("bnProcBufRes.txt", p_buffer, NR_LDPC_SIZE_BN_PROC_BUF); break; } case nrLDPC_buffers_LLR_RES: { - nrLDPC_writeFile("llrRes.txt", p_procBuf->llrRes, NR_LDPC_MAX_NUM_LLR); + nrLDPC_writeFile("llrRes.txt", p_buffer, NR_LDPC_MAX_NUM_LLR); break; } } diff --git a/openair1/PHY/CODING/nrLDPC_defs.h b/openair1/PHY/CODING/nrLDPC_defs.h index 9a9ad1dd50..1aab887640 100644 --- a/openair1/PHY/CODING/nrLDPC_defs.h +++ b/openair1/PHY/CODING/nrLDPC_defs.h @@ -58,7 +58,7 @@ typedef struct { /// Number of "Filler" bits uint32_t F; /// LDPC-code outputs - uint8_t *d[MAX_NUM_NR_DLSCH_SEGMENTS]; + uint8_t *d[MAX_NUM_NR_DLSCH_SEGMENTS_PER_LAYER*NR_MAX_NB_LAYERS]; } encoder_implemparams_t; #define INIT0_LDPCIMPLEMPARAMS {0,0,0,NULL,NULL,NULL,NULL} typedef void(*nrLDPC_initcallfunc_t)(t_nrLDPC_dec_params *p_decParams, int8_t *p_llr, int8_t *p_out); @@ -73,7 +73,7 @@ typedef int(*nrLDPC_encoderfunc_t)(unsigned char **,unsigned char **,int,int,sho \param p_profiler LDPC profiler statistics */ -typedef int32_t(*nrLDPC_decoderfunc_t)(t_nrLDPC_dec_params* , int8_t*, int8_t* , t_nrLDPC_procBuf* , t_nrLDPC_time_stats* ); +typedef int32_t(*nrLDPC_decoderfunc_t)(t_nrLDPC_dec_params* , int8_t*, int8_t* , t_nrLDPC_time_stats* ); typedef int32_t(*nrLDPC_decoffloadfunc_t)(t_nrLDPC_dec_params* , uint8_t, uint8_t, uint8_t , uint8_t, uint16_t, uint32_t, uint8_t, int8_t*, int8_t* ,uint8_t); typedef int32_t(*nrLDPC_dectopfunc_t)(void); diff --git a/openair1/PHY/CODING/nrLDPC_extern.h b/openair1/PHY/CODING/nrLDPC_extern.h index b415876d0b..e4e4032681 100644 --- a/openair1/PHY/CODING/nrLDPC_extern.h +++ b/openair1/PHY/CODING/nrLDPC_extern.h @@ -42,5 +42,4 @@ extern nrLDPC_decoffloadfunc_t nrLDPC_decoder_offload; extern nrLDPC_dectopfunc_t top_testsuite; // inline functions: -#include "openair1/PHY/CODING/nrLDPC_decoder/nrLDPC_init_mem.h" #endif diff --git a/openair1/PHY/CODING/nr_rate_matching.c b/openair1/PHY/CODING/nr_rate_matching.c index 29cba0a557..06dfcaa4a9 100644 --- a/openair1/PHY/CODING/nr_rate_matching.c +++ b/openair1/PHY/CODING/nr_rate_matching.c @@ -307,62 +307,76 @@ void nr_interleaving_ldpc(uint32_t E, uint8_t Qm, uint8_t *e,uint8_t *f) void nr_deinterleaving_ldpc(uint32_t E, uint8_t Qm, int16_t *e,int16_t *f) -{ +{ - int16_t *e1,*e2,*e3,*e4,*e5,*e6,*e7; + switch(Qm) { case 2: - e1=e+(E/2); - for (int j = 0,j2=0; j< E/2; j+=2,j2+=4){ - e[j] = f[j2]; - e1[j] = f[j2+1]; - e[j+1] = f[j2+2]; - e1[j+1] = f[j2+3]; + { + AssertFatal(E%2==0,""); + int16_t *e1=e+(E/2); + int16_t *end=f+E-1; + while( f E) { - LOG_E(PHY,"nr_rate_matching: invalid parameters (Foffset %d > E %d)\n",Foffset,E); + LOG_E(PHY,"nr_rate_matching: invalid parameters (Foffset %d > E %d) F %d, k0 %d, Ncb %d, rvidx %d, Tbslbrm %d\n",Foffset,E,F, ind, Ncb, rvidx, Tbslbrm); return -1; } if (Foffset > Ncb) { @@ -457,8 +470,7 @@ int nr_rate_matching_ldpc(uint8_t Ilbrm, return 0; } -int nr_rate_matching_ldpc_rx(uint8_t Ilbrm, - uint32_t Tbslbrm, +int nr_rate_matching_ldpc_rx(uint32_t Tbslbrm, uint8_t BG, uint16_t Z, int16_t *w, @@ -484,7 +496,7 @@ int nr_rate_matching_ldpc_rx(uint8_t Ilbrm, //Bit selection N = (BG==1)?(66*Z):(50*Z); - if (Ilbrm == 0) + if (Tbslbrm == 0) Ncb = N; else { Nref = (3*Tbslbrm/(2*C)); //R_LBRM = 2/3 @@ -502,7 +514,7 @@ int nr_rate_matching_ldpc_rx(uint8_t Ilbrm, } #ifdef RM_DEBUG - printf("nr_rate_matching_ldpc_rx: Clear %d, E %d, k0 %d, Ncb %d, rvidx %d, Ilbrm %d\n", clear, E, ind, Ncb, rvidx, Ilbrm); + printf("nr_rate_matching_ldpc_rx: Clear %d, E %d, k0 %d, Ncb %d, rvidx %d, Tbslbrm %d\n", clear, E, ind, Ncb, rvidx, Tbslbrm); #endif if (clear==1) memset(w,0,Ncb*sizeof(int16_t)); diff --git a/openair1/PHY/CODING/nr_segmentation.c b/openair1/PHY/CODING/nr_segmentation.c index 0eede23766..f43813a6ca 100644 --- a/openair1/PHY/CODING/nr_segmentation.c +++ b/openair1/PHY/CODING/nr_segmentation.c @@ -63,11 +63,6 @@ int32_t nr_segmentation(unsigned char *input_buffer, #endif } - if ((*C)>MAX_NUM_NR_DLSCH_SEGMENTS) { - LOG_E(PHY,"nr_segmentation.c: too many segments %d, B %d, L %d, Bprime %d\n",*C,B,L,Bprime); - return(-1); - } - // Find K+ Kprime = Bprime/(*C); @@ -92,7 +87,7 @@ if ((Kprime%Kb) > 0) else Z = (Kprime/Kb); - LOG_D(PHY,"nr segmetation B %u Bprime %u Kprime %u z %u \n", B, Bprime, Kprime, Z); + LOG_D(PHY,"nr segmentation B %u Bprime %u Kprime %u z %u \n", B, Bprime, Kprime, Z); if (Z <= 2) { *K = 2; diff --git a/openair1/PHY/INIT/lte_param_init.c b/openair1/PHY/INIT/lte_param_init.c index 504c8fa80a..5b661d7c2d 100644 --- a/openair1/PHY/INIT/lte_param_init.c +++ b/openair1/PHY/INIT/lte_param_init.c @@ -151,11 +151,5 @@ void lte_param_init(PHY_VARS_eNB **eNBp, else if (eNB->frame_parms.N_RB_DL == 25) ru->N_TA_offset = 624/4; } else ru->N_TA_offset=0; - if (IS_SOFTMODEM_BASICSIM) - /* this is required for the basic simulator in TDD mode - * TODO: find a proper cleaner solution - */ - UE->N_TA_offset = 0; - printf("Done lte_param_init\n"); } diff --git a/openair1/PHY/INIT/nr_init.c b/openair1/PHY/INIT/nr_init.c index e875b7ca79..76adf4d314 100644 --- a/openair1/PHY/INIT/nr_init.c +++ b/openair1/PHY/INIT/nr_init.c @@ -38,7 +38,7 @@ #include "openair1/PHY/CODING/nrLDPC_extern.h" #include "assertions.h" #include - +#include #include "PHY/NR_TRANSPORT/nr_ulsch.h" #include "PHY/NR_REFSIG/nr_refsig.h" #include "SCHED_NR/fapi_nr_l1.h" @@ -71,6 +71,407 @@ int l1_north_init_gNB() { return(0); } +int init_codebook_gNB(PHY_VARS_gNB *gNB) { + + if(gNB->frame_parms.nb_antennas_tx>1){ + int CSI_RS_antenna_ports = gNB->frame_parms.nb_antennas_tx; + //NR Codebook Generation for codebook type1 SinglePanel + int N1 = gNB->ap_N1; + int N2 = gNB->ap_N2; + //Uniform Planner Array: UPA + // X X X X ... X + // X X X X ... X + // N2 . . . . ... . + // X X X X ... X + // |<-----N1---->| + int x_polarization = gNB->ap_XP; + //Get the uniform planar array parameters + // To be confirmed + int O2 = N2 > 1? 4 : 1; //Vertical beam oversampling (1 or 4) + int O1 = CSI_RS_antenna_ports > 2 ? 4 : 1; //Horizontal beam oversampling (1 or 4) + AssertFatal(CSI_RS_antenna_ports == N1*N2*x_polarization, + "Nb of antenna ports at PHY %d does not correspond to what passed down with fapi %d\n", + N1*N2*x_polarization, CSI_RS_antenna_ports); + + // Generation of codebook Type1 with codebookMode 1 (CSI_RS_antenna_ports < 16) + if (CSI_RS_antenna_ports < 16) { + //Generate DFT vertical beams + //ll: index of a vertical beams vector (represented by i1_1 in TS 38.214) + double complex v[N1*O1][N1]; + for (int ll=0; llnr_mimo_precoding_matrix = (int32_t ***)malloc16(max_mimo_layers* sizeof(int32_t **)); + int32_t ***mat = gNB->nr_mimo_precoding_matrix; + double complex res_code; + + //Table 5.2.2.2.1-5: + //Codebook for 1-layer CSI reporting using antenna ports 3000 to 2999+PCSI-RS + gNB->pmiq_size[0] = N1*O1*N2*O2*4+1; + mat[0] = (int32_t **)malloc16(gNB->pmiq_size[0]*sizeof(int32_t *)); + + //pmi=0 corresponds to unit matrix + mat[0][0] = (int32_t *)calloc(2*N1*N2,sizeof(int32_t)); + for(int j_col=0; j_col<1; j_col++) { //1 layer + for (int i_rows=0; i_rows<2*N1*N2; i_rows++) { //2-x polarized antenna + if(j_col==i_rows) { + mat[0][0][i_rows+j_col] = 0x7fff; + } + } + } + + for(int ll=0; ll0) + ((short*) &mat[0][pmiq][len])[0] = (short) ((creal(res_code)*32768)+0.5);//convert to Q15 + else + ((short*) &mat[0][pmiq][len])[0] = (short) ((creal(res_code)*32768)-0.5);//convert to Q15 + if (cimag(res_code)>0) + ((short*) &mat[0][pmiq][len])[1] = (short) ((cimag(res_code)*32768)+0.5);//convert to Q15 + else + ((short*) &mat[0][pmiq][len])[1] = (short) ((cimag(res_code)*32768)-0.5);//convert to Q15 + LOG_D(PHY, "1 Layer Precoding Matrix[0][pmi %d][antPort %d]= %f+j %f -> Fixed Point %d+j %d \n", + pmiq, len, creal(res_code), cimag(res_code),((short*) &mat[0][pmiq][len])[0],((short*) &mat[0][pmiq][len])[1]); + } + + for(int len=N1*N2; len<2*N1*N2; len++) { + res_code=sqrt(1/(double)CSI_RS_antenna_ports)*theta_n[nn]*v_lm[ll][mm][len-N1*N2]; + if (creal(res_code)>0) + ((short*) &mat[0][pmiq][len])[0] = (short) ((creal(res_code)*32768)+0.5);//convert to Q15 + else + ((short*) &mat[0][pmiq][len])[0] = (short) ((creal(res_code)*32768)-0.5);//convert to Q15 + if (cimag(res_code)>0) + ((short*) &mat[0][pmiq][len])[1] = (short) ((cimag(res_code)*32768)+0.5);//convert to Q15 + else + ((short*) &mat[0][pmiq][len])[1] = (short) ((cimag(res_code)*32768)-0.5);//convert to Q15 + LOG_D(PHY, "1 Layer Precoding Matrix[0][pmi %d][antPort %d]= %f+j %f -> Fixed Point %d+j %d \n", + pmiq, len, creal(res_code), cimag(res_code),((short*) &mat[0][pmiq][len])[0],((short*) &mat[0][pmiq][len])[1]); + } + } + } + } + + int llc; + int mmc; + double complex phase_sign; + //Table 5.2.2.2.1-6: + //Codebook for 2-layer CSI reporting using antenna ports 3000 to 2999+PCSI-RS + //Compute the code book size for generating 2 layers out of Tx antenna ports + + //pmi_size is computed as follows + gNB->pmiq_size[1] = 1;//1 for unity matrix + for(int llb=0; llbpmiq_size[1] += 1; + } + } + } + } + } + mat[1] = (int32_t **)malloc16(gNB->pmiq_size[1]*sizeof(int32_t *)); + + //pmi=0 corresponds to unit matrix + mat[1][0] = (int32_t *)calloc((2*N1*N2)*(2),sizeof(int32_t)); + for(int j_col=0; j_col<2; j_col++) { //2 layers + for (int i_rows=0; i_rows<2*N1*N2; i_rows++) { //2-x polarized antenna + if(j_col==i_rows) { + mat[1][0][i_rows*2+j_col] = 0x7fff; + } + } + } + + //pmi=1,...,pmi_size, we construct + int pmiq = 0; + for(int llb=0; llb0) + ((short*) &mat[1][pmiq][i_rows*2+j_col])[0] = (short) ((creal(res_code)*32768)+0.5);//convert to Q15 + else + ((short*) &mat[1][pmiq][i_rows*2+j_col])[0] = (short) ((creal(res_code)*32768)-0.5);//convert to Q15 + if (cimag(res_code)>0) + ((short*) &mat[1][pmiq][i_rows*2+j_col])[1] = (short) ((cimag(res_code)*32768)+0.5);//convert to Q15 + else + ((short*) &mat[1][pmiq][i_rows*2+j_col])[1] = (short) ((cimag(res_code)*32768)-0.5);//convert to Q15 + LOG_D(PHY, "2 Layer Precoding Matrix[1][pmi %d][antPort %d][layerIdx %d]= %f+j %f -> Fixed Point %d+j %d \n", + pmiq,i_rows,j_col, creal(res_code), cimag(res_code),((short*) &mat[1][pmiq][i_rows*2+j_col])[0],((short*) &mat[1][pmiq][i_rows*2+j_col])[1]); + } + for (int i_rows=N1*N2; i_rows<2*N1*N2; i_rows++) { + res_code=sqrt(1/(double)(2*CSI_RS_antenna_ports))*(phase_sign)*theta_n[nn]*v_lm[llc][mmc][i_rows-N1*N2]; + if (creal(res_code)>0) + ((short*) &mat[1][pmiq][i_rows*2+j_col])[0] = (short) ((creal(res_code)*32768)+0.5);//convert to Q15 + else + ((short*) &mat[1][pmiq][i_rows*2+j_col])[0] = (short) ((creal(res_code)*32768)-0.5);//convert to Q15 + if (cimag(res_code)>0) + ((short*) &mat[1][pmiq][i_rows*2+j_col])[1] = (short) ((cimag(res_code)*32768)+0.5);//convert to Q15 + else + ((short*) &mat[1][pmiq][i_rows*2+j_col])[1] = (short) ((cimag(res_code)*32768)-0.5);//convert to Q15 + LOG_D(PHY, "2 Layer Precoding Matrix[1][pmi %d][antPort %d][layerIdx %d]= %f+j %f -> Fixed Point %d+j %d \n", + pmiq,i_rows,j_col, creal(res_code), cimag(res_code),((short*) &mat[1][pmiq][i_rows*2+j_col])[0],((short*) &mat[1][pmiq][i_rows*2+j_col])[1]); + } + } + } + } + } + } + } + } + + //Table 5.2.2.2.1-7: + //Codebook for 3-layer CSI reporting using antenna ports 3000 to 2999+PCSI-RS + if(max_mimo_layers>=3) { + + //pmi_size is computed as follows + gNB->pmiq_size[2] = 1;//unity matrix + for(int llb=0; llbpmiq_size[2] += 1; + } + } + } + } + } + mat[2] = (int32_t **)malloc16(gNB->pmiq_size[2]*sizeof(int32_t *)); + //pmi=0 corresponds to unit matrix + mat[2][0] = (int32_t *)calloc((2*N1*N2)*(3),sizeof(int32_t)); + for(int j_col=0; j_col<3; j_col++) { //3 layers + for (int i_rows=0; i_rows<2*N1*N2; i_rows++) { //2-x polarized antenna + if(j_col==i_rows) { + mat[2][0][i_rows*3+j_col] = 0x7fff; + } + } + } + + pmiq = 0; + //pmi=1,...,pmi_size are computed as follows + for(int llb=0; llb0) + ((short*) &mat[2][pmiq][i_rows*3+j_col])[0] = (short) ((creal(res_code)*32768)+0.5);//convert to Q15 + else + ((short*) &mat[2][pmiq][i_rows*3+j_col])[0] = (short) ((creal(res_code)*32768)-0.5);//convert to Q15 + if (cimag(res_code)>0) + ((short*) &mat[2][pmiq][i_rows*3+j_col])[1] = (short) ((cimag(res_code)*32768)+0.5);//convert to Q15 + else + ((short*) &mat[2][pmiq][i_rows*3+j_col])[1] = (short) ((cimag(res_code)*32768)-0.5);//convert to Q15 + LOG_D(PHY, "3 Layer Precoding Matrix[2][pmi %d][antPort %d][layerIdx %d]= %f+j %f -> Fixed Point %d+j %d \n", + pmiq,i_rows,j_col, creal(res_code), cimag(res_code),((short*) &mat[2][pmiq][i_rows*3+j_col])[0],((short*) &mat[2][pmiq][i_rows*3+j_col])[1]); + } + for (int i_rows=N1*N2; i_rows<2*N1*N2; i_rows++) { + res_code=sqrt(1/(double)(3*CSI_RS_antenna_ports))*(phase_sign)*theta_n[nn]*v_lm[llc][mmc][i_rows-N1*N2]; + if (creal(res_code)>0) + ((short*) &mat[2][pmiq][i_rows*3+j_col])[0] = (short) ((creal(res_code)*32768)+0.5);//convert to Q15 + else + ((short*) &mat[2][pmiq][i_rows*3+j_col])[0] = (short) ((creal(res_code)*32768)-0.5);//convert to Q15 + if (cimag(res_code)>0) + ((short*) &mat[2][pmiq][i_rows*3+j_col])[1] = (short) ((cimag(res_code)*32768)+0.5);//convert to Q15 + else + ((short*) &mat[2][pmiq][i_rows*3+j_col])[1] = (short) ((cimag(res_code)*32768)-0.5);//convert to Q15 + LOG_D(PHY, "3 Layer Precoding Matrix[2][pmi %d][antPort %d][layerIdx %d]= %f+j %f -> Fixed Point %d+j %d \n", + pmiq,i_rows,j_col, creal(res_code), cimag(res_code),((short*) &mat[2][pmiq][i_rows*3+j_col])[0],((short*) &mat[2][pmiq][i_rows*3+j_col])[1]); + } + } + } + } + } + } + } + } + } + + //Table 5.2.2.2.1-8: + //Codebook for 4-layer CSI reporting using antenna ports 3000 to 2999+PCSI-RS + if(max_mimo_layers>=4) { + //pmi_size is computed as follows + gNB->pmiq_size[3] = 1;//unity matrix + for(int llb=0; llbpmiq_size[3] += 1; + } + } + } + } + } + + mat[3] = (int32_t **)malloc16(gNB->pmiq_size[3]*sizeof(int32_t *)); + //pmi=0 corresponds to unit matrix + mat[3][0] = (int32_t *)calloc((2*N1*N2)*(4),sizeof(int32_t)); + for(int j_col=0; j_col<4; j_col++) { //4 layers + for (int i_rows=0; i_rows<2*N1*N2; i_rows++) { //2-x polarized antenna + if(j_col==i_rows) { + mat[3][0][i_rows*4+j_col] = 0x7fff; + } + } + } + + pmiq = 0; + //pmi=1,...,pmi_size are computed as follows + for(int llb=0; llb0) + ((short*) &mat[3][pmiq][i_rows*4+j_col])[0] = (short) ((creal(res_code)*32768)+0.5);//convert to Q15 + else + ((short*) &mat[3][pmiq][i_rows*4+j_col])[0] = (short) ((creal(res_code)*32768)-0.5);//convert to Q15 + if (cimag(res_code)>0) + ((short*) &mat[3][pmiq][i_rows*4+j_col])[1] = (short) ((cimag(res_code)*32768)+0.5);//convert to Q15 + else + ((short*) &mat[3][pmiq][i_rows*4+j_col])[1] = (short) ((cimag(res_code)*32768)-0.5);//convert to Q15 + LOG_D(PHY, "4 Layer Precoding Matrix[3][pmi %d][antPort %d][layerIdx %d]= %f+j %f -> Fixed Point %d+j %d \n", + pmiq,i_rows,j_col, creal(res_code), cimag(res_code),((short*) &mat[3][pmiq][i_rows*4+j_col])[0],((short*) &mat[3][pmiq][i_rows*4+j_col])[1]); + } + + for (int i_rows=N1*N2; i_rows<2*N1*N2; i_rows++) { + res_code=sqrt(1/(double)(4*CSI_RS_antenna_ports))*(phase_sign)*theta_n[nn]*v_lm[llc][mmc][i_rows-N1*N2]; + if (creal(res_code)>0) + ((short*) &mat[3][pmiq][i_rows*4+j_col])[0] = (short) ((creal(res_code)*32768)+0.5);//convert to Q15 + else + ((short*) &mat[3][pmiq][i_rows*4+j_col])[0] = (short) ((creal(res_code)*32768)-0.5);//convert to Q15 + if (cimag(res_code)>0) + ((short*) &mat[3][pmiq][i_rows*4+j_col])[1] = (short) ((cimag(res_code)*32768)+0.5);//convert to Q15 + else + ((short*) &mat[3][pmiq][i_rows*4+j_col])[1] = (short) ((cimag(res_code)*32768)-0.5);//convert to Q15 + LOG_D(PHY, "4 Layer Precoding Matrix[3][pmi %d][antPort %d][layerIdx %d]= %f+j %f -> Fixed Point %d+j %d \n", + pmiq,i_rows,j_col, creal(res_code), cimag(res_code),((short*) &mat[3][pmiq][i_rows*4+j_col])[0],((short*) &mat[3][pmiq][i_rows*4+j_col])[1]); + } + } + } + } + } + } + } + } + } + } + } + return 0; +} int phy_init_nr_gNB(PHY_VARS_gNB *gNB, unsigned char is_secondary_gNB, @@ -113,6 +514,8 @@ int phy_init_nr_gNB(PHY_VARS_gNB *gNB, if (gNB->ldpc_offload_flag) load_nrLDPClib_offload(); + init_codebook_gNB(gNB); + // PBCH DMRS gold sequences generation nr_init_pbch_dmrs(gNB); //PDCCH DMRS init @@ -122,18 +525,22 @@ int phy_init_nr_gNB(PHY_VARS_gNB *gNB, gNB->bad_pucch = 0; + // ceil(((NB_RB<<1)*3)/32) // 3 RE *2(QPSK) + int pdcch_dmrs_init_length = (((fp->N_RB_DL<<1)*3)>>5)+1; + for (int slot=0; slotslots_per_frame; slot++) { pdcch_dmrs[slot] = (uint32_t **)malloc16(fp->symbols_per_slot*sizeof(uint32_t *)); AssertFatal(pdcch_dmrs[slot]!=NULL, "NR init: pdcch_dmrs for slot %d - malloc failed\n", slot); for (int symb=0; symbsymbols_per_slot; symb++) { - pdcch_dmrs[slot][symb] = (uint32_t *)malloc16(NR_MAX_PDCCH_DMRS_INIT_LENGTH_DWORD*sizeof(uint32_t)); + pdcch_dmrs[slot][symb] = (uint32_t *)malloc16(pdcch_dmrs_init_length*sizeof(uint32_t)); LOG_D(PHY,"pdcch_dmrs[%d][%d] %p\n",slot,symb,pdcch_dmrs[slot][symb]); AssertFatal(pdcch_dmrs[slot][symb]!=NULL, "NR init: pdcch_dmrs for slot %d symbol %d - malloc failed\n", slot, symb); } } nr_generate_modulation_table(); + gNB->pdcch_gold_init = cfg->cell_config.phy_cell_id.value; nr_init_pdcch_dmrs(gNB, cfg->cell_config.phy_cell_id.value); nr_init_pbch_interleaver(gNB->nr_pbch_interleaver); @@ -141,29 +548,36 @@ int phy_init_nr_gNB(PHY_VARS_gNB *gNB, gNB->nr_gold_pdsch_dmrs = (uint32_t ****)malloc16(fp->slots_per_frame*sizeof(uint32_t ***)); uint32_t ****pdsch_dmrs = gNB->nr_gold_pdsch_dmrs; + // ceil(((NB_RB*12(k)*2(QPSK)/32) // 3 RE *2(QPSK) + const int pdsch_dmrs_init_length = ((fp->N_RB_DL*24)>>5)+1; for (int slot=0; slotslots_per_frame; slot++) { pdsch_dmrs[slot] = (uint32_t ***)malloc16(fp->symbols_per_slot*sizeof(uint32_t **)); AssertFatal(pdsch_dmrs[slot]!=NULL, "NR init: pdsch_dmrs for slot %d - malloc failed\n", slot); for (int symb=0; symbsymbols_per_slot; symb++) { - pdsch_dmrs[slot][symb] = (uint32_t **)malloc16(NR_MAX_NB_CODEWORDS*sizeof(uint32_t *)); + pdsch_dmrs[slot][symb] = (uint32_t **)malloc16(NR_NB_NSCID*sizeof(uint32_t *)); AssertFatal(pdsch_dmrs[slot][symb]!=NULL, "NR init: pdsch_dmrs for slot %d symbol %d - malloc failed\n", slot, symb); - for (int q=0; qcell_config.phy_cell_id.value); + + for (int nscid = 0; nscid < NR_NB_NSCID; nscid++) { + gNB->pdsch_gold_init[nscid] = cfg->cell_config.phy_cell_id.value; + nr_init_pdsch_dmrs(gNB, nscid, cfg->cell_config.phy_cell_id.value); + } //PUSCH DMRS init - gNB->nr_gold_pusch_dmrs = (uint32_t ****)malloc16(2*sizeof(uint32_t ***)); + gNB->nr_gold_pusch_dmrs = (uint32_t ****)malloc16(NR_NB_NSCID*sizeof(uint32_t ***)); uint32_t ****pusch_dmrs = gNB->nr_gold_pusch_dmrs; - for(int nscid=0; nscid<2; nscid++) { + int pusch_dmrs_init_length = ((fp->N_RB_UL*12)>>5)+1; + for(int nscid=0; nscidslots_per_frame*sizeof(uint32_t **)); AssertFatal(pusch_dmrs[nscid]!=NULL, "NR init: pusch_dmrs for nscid %d - malloc failed\n", nscid); @@ -172,35 +586,38 @@ int phy_init_nr_gNB(PHY_VARS_gNB *gNB, AssertFatal(pusch_dmrs[nscid][slot]!=NULL, "NR init: pusch_dmrs for slot %d - malloc failed\n", slot); for (int symb=0; symbsymbols_per_slot; symb++) { - pusch_dmrs[nscid][slot][symb] = (uint32_t *)malloc16(NR_MAX_PUSCH_DMRS_INIT_LENGTH_DWORD*sizeof(uint32_t)); + pusch_dmrs[nscid][slot][symb] = (uint32_t *)malloc16(pusch_dmrs_init_length*sizeof(uint32_t)); AssertFatal(pusch_dmrs[nscid][slot][symb]!=NULL, "NR init: pusch_dmrs for slot %d symbol %d - malloc failed\n", slot, symb); } } } - uint32_t Nid_pusch[2] = {cfg->cell_config.phy_cell_id.value,cfg->cell_config.phy_cell_id.value}; - LOG_D(PHY,"Initializing PUSCH DMRS Gold sequence with (%x,%x)\n",Nid_pusch[0],Nid_pusch[1]); - nr_gold_pusch(gNB, &Nid_pusch[0]); - - //CSI RS init - gNB->nr_gold_csi_rs = (uint32_t ***)malloc16(fp->slots_per_frame*sizeof(uint32_t **)); - uint32_t ***csi_rs = gNB->nr_gold_csi_rs; - AssertFatal(csi_rs!=NULL, "NR init: csi reference signal malloc failed\n"); + for (int nscid=0; nscidpusch_gold_init[nscid] = cfg->cell_config.phy_cell_id.value; + nr_gold_pusch(gNB, nscid, gNB->pusch_gold_init[nscid]); + } + // CSI RS init + // ceil((NB_RB*8(max allocation per RB)*2(QPSK))/32) + int csi_dmrs_init_length = ((fp->N_RB_DL<<4)>>5)+1; + gNB->nr_csi_rs_info = (nr_csi_rs_info_t *)malloc16_clear(sizeof(nr_csi_rs_info_t)); + gNB->nr_csi_rs_info->nr_gold_csi_rs = (uint32_t ***)malloc16(fp->slots_per_frame*sizeof(uint32_t **)); + AssertFatal(gNB->nr_csi_rs_info->nr_gold_csi_rs!=NULL, "NR init: csi reference signal malloc failed\n"); for (int slot=0; slotslots_per_frame; slot++) { - csi_rs[slot] = (uint32_t **)malloc16(fp->symbols_per_slot*sizeof(uint32_t *)); - AssertFatal(csi_rs[slot]!=NULL, "NR init: csi reference signal for slot %d - malloc failed\n", slot); - + gNB->nr_csi_rs_info->nr_gold_csi_rs[slot] = (uint32_t **)malloc16(fp->symbols_per_slot*sizeof(uint32_t *)); + AssertFatal(gNB->nr_csi_rs_info->nr_gold_csi_rs[slot]!=NULL, "NR init: csi reference signal for slot %d - malloc failed\n", slot); for (int symb=0; symbsymbols_per_slot; symb++) { - csi_rs[slot][symb] = (uint32_t *)malloc16(NR_MAX_CSI_RS_INIT_LENGTH_DWORD*sizeof(uint32_t)); - AssertFatal(csi_rs[slot][symb]!=NULL, "NR init: csi reference signal for slot %d symbol %d - malloc failed\n", slot, symb); + gNB->nr_csi_rs_info->nr_gold_csi_rs[slot][symb] = (uint32_t *)malloc16(csi_dmrs_init_length*sizeof(uint32_t)); + AssertFatal(gNB->nr_csi_rs_info->nr_gold_csi_rs[slot][symb]!=NULL, "NR init: csi reference signal for slot %d symbol %d - malloc failed\n", slot, symb); } } - nr_init_csi_rs(gNB, cfg->cell_config.phy_cell_id.value); + gNB->nr_csi_rs_info->csi_gold_init = cfg->cell_config.phy_cell_id.value; + nr_init_csi_rs(&gNB->frame_parms, gNB->nr_csi_rs_info->nr_gold_csi_rs, cfg->cell_config.phy_cell_id.value); for (int id=0; idnr_srs_info[id] = (nr_srs_info_t *)malloc16_clear(sizeof(nr_srs_info_t)); + gNB->nr_srs_info[id]->sc_list = (uint16_t *) malloc16_clear(6*fp->N_RB_UL*sizeof(uint16_t)); gNB->nr_srs_info[id]->srs_generated_signal = (int32_t*)malloc16_clear(fp->ofdm_symbol_size*MAX_NUM_NR_SRS_SYMBOLS*sizeof(int32_t)); gNB->nr_srs_info[id]->noise_power = (uint32_t*)malloc16_clear(sizeof(uint32_t)); gNB->nr_srs_info[id]->srs_received_signal = (int32_t **)malloc16(Prx*sizeof(int32_t*)); @@ -233,12 +650,12 @@ int phy_init_nr_gNB(PHY_VARS_gNB *gNB, common_vars->beam_id = (uint8_t **)malloc16(Ptx*sizeof(uint8_t*)); for (i=0;itxdataF[i] = (int32_t*)malloc16_clear(fp->samples_per_frame_wCP*sizeof(int32_t)); // [hna] samples_per_frame without CP - LOG_D(PHY,"[INIT] common_vars->txdataF[%d] = %p (%lu bytes)\n", - i,common_vars->txdataF[i], - fp->samples_per_frame_wCP*sizeof(int32_t)); - common_vars->beam_id[i] = (uint8_t*)malloc16_clear(fp->symbols_per_slot*fp->slots_per_frame*sizeof(uint8_t)); - memset(common_vars->beam_id[i],255,fp->symbols_per_slot*fp->slots_per_frame); + common_vars->txdataF[i] = (int32_t*)malloc16_clear(fp->samples_per_frame_wCP*sizeof(int32_t)); // [hna] samples_per_frame without CP + LOG_D(PHY,"[INIT] common_vars->txdataF[%d] = %p (%lu bytes)\n", + i,common_vars->txdataF[i], + fp->samples_per_frame_wCP*sizeof(int32_t)); + common_vars->beam_id[i] = (uint8_t*)malloc16_clear(fp->symbols_per_slot*fp->slots_per_frame*sizeof(uint8_t)); + memset(common_vars->beam_id[i],255,fp->symbols_per_slot*fp->slots_per_frame); } for (i=0;irxdataF[i] = (int32_t*)malloc16_clear(fp->samples_per_frame_wCP*sizeof(int32_t)); @@ -257,14 +674,18 @@ int phy_init_nr_gNB(PHY_VARS_gNB *gNB, int N_RB_UL = cfg->carrier_config.ul_grid_size[cfg->ssb_config.scs_common.value].value; int n_buf = Prx*max_ul_mimo_layers; + int nb_re_pusch = N_RB_UL * NR_NB_SC_PER_RB; +#ifdef __AVX2__ + int nb_re_pusch2 = nb_re_pusch + (nb_re_pusch&7); +#else + int nb_re_pusch2 = nb_re_pusch; +#endif + for (int ULSCH_id=0; ULSCH_idnumber_of_nr_ulsch_max; ULSCH_id++) { pusch_vars[ULSCH_id] = (NR_gNB_PUSCH *)malloc16_clear( sizeof(NR_gNB_PUSCH) ); pusch_vars[ULSCH_id]->rxdataF_ext = (int32_t **)malloc16(Prx*sizeof(int32_t *) ); - pusch_vars[ULSCH_id]->rxdataF_ext2 = (int32_t **)malloc16(Prx*sizeof(int32_t *) ); pusch_vars[ULSCH_id]->ul_ch_estimates = (int32_t **)malloc16(n_buf*sizeof(int32_t *) ); pusch_vars[ULSCH_id]->ul_ch_estimates_ext = (int32_t **)malloc16(n_buf*sizeof(int32_t *) ); - pusch_vars[ULSCH_id]->ul_ch_ptrs_estimates = (int32_t **)malloc16(n_buf*sizeof(int32_t *) ); - pusch_vars[ULSCH_id]->ul_ch_ptrs_estimates_ext = (int32_t **)malloc16(n_buf*sizeof(int32_t *) ); pusch_vars[ULSCH_id]->ptrs_phase_per_slot = (int32_t **)malloc16(n_buf*sizeof(int32_t *) ); pusch_vars[ULSCH_id]->ul_ch_estimates_time = (int32_t **)malloc16(n_buf*sizeof(int32_t *) ); pusch_vars[ULSCH_id]->rxdataF_comp = (int32_t **)malloc16(n_buf*sizeof(int32_t *) ); @@ -272,25 +693,33 @@ int phy_init_nr_gNB(PHY_VARS_gNB *gNB, pusch_vars[ULSCH_id]->ul_ch_magb0 = (int32_t **)malloc16(n_buf*sizeof(int32_t *) ); pusch_vars[ULSCH_id]->ul_ch_mag = (int32_t **)malloc16(n_buf*sizeof(int32_t *) ); pusch_vars[ULSCH_id]->ul_ch_magb = (int32_t **)malloc16(n_buf*sizeof(int32_t *) ); - pusch_vars[ULSCH_id]->rho = (int32_t **)malloc16_clear(n_buf*sizeof(int32_t*) ); + pusch_vars[ULSCH_id]->rho = (int32_t ***)malloc16(Prx*sizeof(int32_t **) ); + pusch_vars[ULSCH_id]->llr_layers = (int16_t **)malloc16(max_ul_mimo_layers*sizeof(int32_t *) ); for (i=0; irxdataF_ext[i] = (int32_t *)malloc16_clear( sizeof(int32_t)*N_RB_UL*12*fp->symbols_per_slot ); - pusch_vars[ULSCH_id]->rxdataF_ext2[i] = (int32_t *)malloc16_clear( sizeof(int32_t)*N_RB_UL*12*fp->symbols_per_slot ); + pusch_vars[ULSCH_id]->rxdataF_ext[i] = (int32_t *)malloc16_clear( sizeof(int32_t)*nb_re_pusch2*fp->symbols_per_slot ); + pusch_vars[ULSCH_id]->rho[i] = (int32_t **)malloc16_clear(NR_MAX_NB_LAYERS*NR_MAX_NB_LAYERS*sizeof(int32_t*)); + + for (int j=0; j< max_ul_mimo_layers; j++) { + for (int k=0; krho[i][j*max_ul_mimo_layers+k]=(int32_t *)malloc16_clear( sizeof(int32_t)*nb_re_pusch2*fp->symbols_per_slot ); + } + } } for (i=0; iul_ch_estimates[i] = (int32_t *)malloc16_clear( sizeof(int32_t)*fp->ofdm_symbol_size*2*fp->symbols_per_slot ); - pusch_vars[ULSCH_id]->ul_ch_estimates_ext[i] = (int32_t *)malloc16_clear( sizeof(int32_t)*N_RB_UL*12*fp->symbols_per_slot ); - pusch_vars[ULSCH_id]->ul_ch_estimates_time[i] = (int32_t *)malloc16_clear( 2*sizeof(int32_t)*fp->ofdm_symbol_size ); - pusch_vars[ULSCH_id]->ul_ch_ptrs_estimates[i] = (int32_t *)malloc16_clear( sizeof(int32_t)*fp->ofdm_symbol_size*2*fp->symbols_per_slot ); // max intensity in freq is 1 sc every 2 RBs - pusch_vars[ULSCH_id]->ul_ch_ptrs_estimates_ext[i] = (int32_t *)malloc16_clear( sizeof(int32_t)*N_RB_UL*12*fp->symbols_per_slot ); + pusch_vars[ULSCH_id]->ul_ch_estimates[i] = (int32_t *)malloc16_clear( sizeof(int32_t)*fp->ofdm_symbol_size*fp->symbols_per_slot ); + pusch_vars[ULSCH_id]->ul_ch_estimates_ext[i] = (int32_t *)malloc16_clear( sizeof(int32_t)*nb_re_pusch2*fp->symbols_per_slot ); + pusch_vars[ULSCH_id]->ul_ch_estimates_time[i] = (int32_t *)malloc16_clear( sizeof(int32_t)*fp->ofdm_symbol_size ); pusch_vars[ULSCH_id]->ptrs_phase_per_slot[i] = (int32_t *)malloc16_clear( sizeof(int32_t)*fp->symbols_per_slot); // symbols per slot - pusch_vars[ULSCH_id]->rxdataF_comp[i] = (int32_t *)malloc16_clear( sizeof(int32_t)*N_RB_UL*12*fp->symbols_per_slot ); - pusch_vars[ULSCH_id]->ul_ch_mag0[i] = (int32_t *)malloc16_clear( fp->symbols_per_slot*sizeof(int32_t)*N_RB_UL*12 ); - pusch_vars[ULSCH_id]->ul_ch_magb0[i] = (int32_t *)malloc16_clear( fp->symbols_per_slot*sizeof(int32_t)*N_RB_UL*12 ); - pusch_vars[ULSCH_id]->ul_ch_mag[i] = (int32_t *)malloc16_clear( fp->symbols_per_slot*sizeof(int32_t)*N_RB_UL*12 ); - pusch_vars[ULSCH_id]->ul_ch_magb[i] = (int32_t *)malloc16_clear( fp->symbols_per_slot*sizeof(int32_t)*N_RB_UL*12 ); - pusch_vars[ULSCH_id]->rho[i] = (int32_t *)malloc16_clear( sizeof(int32_t)*(fp->N_RB_UL*12*7*2) ); + pusch_vars[ULSCH_id]->rxdataF_comp[i] = (int32_t *)malloc16_clear( sizeof(int32_t)*nb_re_pusch2*fp->symbols_per_slot ); + pusch_vars[ULSCH_id]->ul_ch_mag0[i] = (int32_t *)malloc16_clear( sizeof(int32_t)*nb_re_pusch2*fp->symbols_per_slot ); + pusch_vars[ULSCH_id]->ul_ch_magb0[i] = (int32_t *)malloc16_clear( sizeof(int32_t)*nb_re_pusch2*fp->symbols_per_slot ); + pusch_vars[ULSCH_id]->ul_ch_mag[i] = (int32_t *)malloc16_clear( sizeof(int32_t)*nb_re_pusch2*fp->symbols_per_slot ); + pusch_vars[ULSCH_id]->ul_ch_magb[i] = (int32_t *)malloc16_clear( sizeof(int32_t)*nb_re_pusch2*fp->symbols_per_slot ); + } + + for (i=0; i< max_ul_mimo_layers; i++) { + pusch_vars[ULSCH_id]->llr_layers[i] = (int16_t *)malloc16_clear( (8*((3*8*6144)+12))*sizeof(int16_t) ); // [hna] 6144 is LTE and (8*((3*8*6144)+12)) is not clear } pusch_vars[ULSCH_id]->llr = (int16_t *)malloc16_clear( (8*((3*8*6144)+12))*sizeof(int16_t) ); // [hna] 6144 is LTE and (8*((3*8*6144)+12)) is not clear pusch_vars[ULSCH_id]->ul_valid_re_per_slot = (int16_t *)malloc16_clear( sizeof(int16_t)*fp->symbols_per_slot); @@ -310,6 +739,16 @@ void phy_free_nr_gNB(PHY_VARS_gNB *gNB) const int max_ul_mimo_layers = 4; // taken from phy_init_nr_gNB() const int n_buf = Prx * max_ul_mimo_layers; + int max_dl_mimo_layers =(fp->nb_antennas_txnb_antennas_tx : NR_MAX_NB_LAYERS; + if (fp->nb_antennas_tx>1) { + for (int nl = 0; nl < max_dl_mimo_layers; nl++) { + for(int size = 0; size < gNB->pmiq_size[nl]; size++) + free_and_zero(gNB->nr_mimo_precoding_matrix[nl][size]); + free_and_zero(gNB->nr_mimo_precoding_matrix[nl]); + } + free_and_zero(gNB->nr_mimo_precoding_matrix); + } + uint32_t ***pdcch_dmrs = gNB->nr_gold_pdcch_dmrs; for (int slot = 0; slot < fp->slots_per_frame; slot++) { for (int symb = 0; symb < fp->symbols_per_slot; symb++) @@ -321,7 +760,7 @@ void phy_free_nr_gNB(PHY_VARS_gNB *gNB) uint32_t ****pdsch_dmrs = gNB->nr_gold_pdsch_dmrs; for (int slot = 0; slot < fp->slots_per_frame; slot++) { for (int symb = 0; symb < fp->symbols_per_slot; symb++) { - for (int q = 0; q < NR_MAX_NB_CODEWORDS; q++) + for (int q = 0; q < NR_NB_NSCID; q++) free_and_zero(pdsch_dmrs[slot][symb][q]); free_and_zero(pdsch_dmrs[slot][symb]); } @@ -340,22 +779,24 @@ void phy_free_nr_gNB(PHY_VARS_gNB *gNB) } free_and_zero(pusch_dmrs); - uint32_t ***csi_rs = gNB->nr_gold_csi_rs; + uint32_t ***nr_gold_csi_rs = gNB->nr_csi_rs_info->nr_gold_csi_rs; for (int slot = 0; slot < fp->slots_per_frame; slot++) { for (int symb = 0; symb < fp->symbols_per_slot; symb++) - free_and_zero(csi_rs[slot][symb]); - free_and_zero(csi_rs[slot]); + free_and_zero(nr_gold_csi_rs[slot][symb]); + free_and_zero(nr_gold_csi_rs[slot]); } - free_and_zero(csi_rs); + free_and_zero(nr_gold_csi_rs); + free_and_zero(gNB->nr_csi_rs_info); for (int id = 0; id < NUMBER_OF_NR_SRS_MAX; id++) { - for (int i = 0; i < Prx; i++){ + for (int i = 0; i < Prx; i++) { free_and_zero(gNB->nr_srs_info[id]->srs_received_signal[i]); free_and_zero(gNB->nr_srs_info[id]->srs_ls_estimated_channel[i]); free_and_zero(gNB->nr_srs_info[id]->srs_estimated_channel_freq[i]); free_and_zero(gNB->nr_srs_info[id]->srs_estimated_channel_time[i]); free_and_zero(gNB->nr_srs_info[id]->srs_estimated_channel_time_shifted[i]); } + free_and_zero(gNB->nr_srs_info[id]->sc_list); free_and_zero(gNB->nr_srs_info[id]->srs_generated_signal); free_and_zero(gNB->nr_srs_info[id]->noise_power); free_and_zero(gNB->nr_srs_info[id]->srs_received_signal); @@ -396,30 +837,31 @@ void phy_free_nr_gNB(PHY_VARS_gNB *gNB) NR_gNB_PUSCH** pusch_vars = gNB->pusch_vars; for (int ULSCH_id=0; ULSCH_idnumber_of_nr_ulsch_max; ULSCH_id++) { + for (int i=0; i< max_ul_mimo_layers; i++) + free_and_zero(pusch_vars[ULSCH_id]->llr_layers[i]); for (int i = 0; i < Prx; i++) { free_and_zero(pusch_vars[ULSCH_id]->rxdataF_ext[i]); - free_and_zero(pusch_vars[ULSCH_id]->rxdataF_ext2[i]); + for (int j=0; j< max_ul_mimo_layers; j++) { + for (int k=0; krho[i][j*max_ul_mimo_layers+k]); + } + free_and_zero(pusch_vars[ULSCH_id]->rho[i]); } for (int i = 0; i < n_buf; i++) { free_and_zero(pusch_vars[ULSCH_id]->ul_ch_estimates[i]); free_and_zero(pusch_vars[ULSCH_id]->ul_ch_estimates_ext[i]); free_and_zero(pusch_vars[ULSCH_id]->ul_ch_estimates_time[i]); - free_and_zero(pusch_vars[ULSCH_id]->ul_ch_ptrs_estimates[i]); - free_and_zero(pusch_vars[ULSCH_id]->ul_ch_ptrs_estimates_ext[i]); free_and_zero(pusch_vars[ULSCH_id]->ptrs_phase_per_slot[i]); free_and_zero(pusch_vars[ULSCH_id]->rxdataF_comp[i]); free_and_zero(pusch_vars[ULSCH_id]->ul_ch_mag0[i]); free_and_zero(pusch_vars[ULSCH_id]->ul_ch_magb0[i]); free_and_zero(pusch_vars[ULSCH_id]->ul_ch_mag[i]); free_and_zero(pusch_vars[ULSCH_id]->ul_ch_magb[i]); - free_and_zero(pusch_vars[ULSCH_id]->rho[i]); } + free_and_zero(pusch_vars[ULSCH_id]->llr_layers); free_and_zero(pusch_vars[ULSCH_id]->rxdataF_ext); - free_and_zero(pusch_vars[ULSCH_id]->rxdataF_ext2); free_and_zero(pusch_vars[ULSCH_id]->ul_ch_estimates); free_and_zero(pusch_vars[ULSCH_id]->ul_ch_estimates_ext); - free_and_zero(pusch_vars[ULSCH_id]->ul_ch_ptrs_estimates); - free_and_zero(pusch_vars[ULSCH_id]->ul_ch_ptrs_estimates_ext); free_and_zero(pusch_vars[ULSCH_id]->ptrs_phase_per_slot); free_and_zero(pusch_vars[ULSCH_id]->ul_ch_estimates_time); free_and_zero(pusch_vars[ULSCH_id]->ul_valid_re_per_slot); @@ -483,7 +925,12 @@ void nr_phy_config_request_sim(PHY_VARS_gNB *gNB, //gNB_config->subframe_config.dl_cyclic_prefix_type.value = (fp->Ncp == NORMAL) ? NFAPI_CP_NORMAL : NFAPI_CP_EXTENDED; gNB->mac_enabled = 1; - if (mu==1) { + if (mu==0) { + fp->dl_CarrierFreq = 2600000000;//from_nrarfcn(gNB_config->nfapi_config.rf_bands.rf_band[0],gNB_config->nfapi_config.nrarfcn.value); + fp->ul_CarrierFreq = 2600000000;//fp->dl_CarrierFreq - (get_uldl_offset(gNB_config->nfapi_config.rf_bands.rf_band[0])*100000); + fp->nr_band = 38; + // fp->threequarter_fs= 0; + } else if (mu==1) { fp->dl_CarrierFreq = 3600000000;//from_nrarfcn(gNB_config->nfapi_config.rf_bands.rf_band[0],gNB_config->nfapi_config.nrarfcn.value); fp->ul_CarrierFreq = 3600000000;//fp->dl_CarrierFreq - (get_uldl_offset(gNB_config->nfapi_config.rf_bands.rf_band[0])*100000); fp->nr_band = 78; @@ -564,9 +1011,10 @@ void init_DLSCH_struct(PHY_VARS_gNB *gNB, processingData_L1tx_t *msg) { uint16_t grid_size = cfg->carrier_config.dl_grid_size[fp->numerology_index].value; msg->num_pdsch_slot = 0; + int num_cw = NR_MAX_NB_LAYERS > 4? 2:1; for (int i=0; inumber_of_nr_dlsch_max; i++) { LOG_I(PHY,"Allocating Transport Channel Buffers for DLSCH %d/%d\n",i,gNB->number_of_nr_dlsch_max); - for (int j=0; j<2; j++) { + for (int j=0; jdlsch[i][j] = new_gNB_dlsch(fp,1,16,NSOFT,0,grid_size); AssertFatal(msg->dlsch[i][j]!=NULL,"Can't initialize dlsch %d \n", i); } @@ -578,9 +1026,10 @@ void reset_DLSCH_struct(const PHY_VARS_gNB *gNB, processingData_L1tx_t *msg) const NR_DL_FRAME_PARMS *fp = &gNB->frame_parms; const nfapi_nr_config_request_scf_t *cfg = &gNB->gNB_config; const uint16_t grid_size = cfg->carrier_config.dl_grid_size[fp->numerology_index].value; + int num_cw = NR_MAX_NB_LAYERS > 4? 2:1; for (int i=0; inumber_of_nr_dlsch_max; i++) - for (int j=0; j<2; j++) - free_gNB_dlsch(&msg->dlsch[i][j], grid_size); + for (int j=0; jdlsch[i][j], grid_size, fp); } void init_nr_transport(PHY_VARS_gNB *gNB) { @@ -603,24 +1052,18 @@ void init_nr_transport(PHY_VARS_gNB *gNB) { for (int i=0; inumber_of_nr_ulsch_max; i++) { - LOG_I(PHY,"Allocating Transport Channel Buffer for ULSCH %d/%d\n",i,gNB->number_of_nr_ulsch_max); + LOG_I(PHY,"Allocating Transport Channel Buffers for ULSCH %d/%d\n",i,gNB->number_of_nr_ulsch_max); - for (int j=0; j<2; j++) { - // ULSCH for data - gNB->ulsch[i][j] = new_gNB_ulsch(MAX_LDPC_ITERATIONS, fp->N_RB_UL); - - if (!gNB->ulsch[i][j]) { - LOG_E(PHY,"Can't get gNB ulsch structures\n"); - exit(-1); - } + gNB->ulsch[i] = new_gNB_ulsch(gNB->max_ldpc_iterations, fp->N_RB_UL); + if (!gNB->ulsch[i]) { + LOG_E(PHY,"Can't get gNB ulsch structures\n"); + exit(-1); } - } gNB->rx_total_gain_dB=130; - //fp->pucch_config_common.deltaPUCCH_Shift = 1; } @@ -635,6 +1078,5 @@ void reset_nr_transport(PHY_VARS_gNB *gNB) free_gNB_srs(gNB->srs[i]); for (int i=0; inumber_of_nr_ulsch_max; i++) - for (int j=0; j<2; j++) - free_gNB_ulsch(&gNB->ulsch[i][j], fp->N_RB_UL); + free_gNB_ulsch(&gNB->ulsch[i], fp->N_RB_UL); } diff --git a/openair1/PHY/INIT/nr_init_ru.c b/openair1/PHY/INIT/nr_init_ru.c index 07f1d3b9e3..c96aeab432 100644 --- a/openair1/PHY/INIT/nr_init_ru.c +++ b/openair1/PHY/INIT/nr_init_ru.c @@ -41,7 +41,7 @@ int nr_phy_init_RU(RU_t *ru) { int p; int re; - LOG_I(PHY,"Initializing RU signal buffers (if_south %s) nb_tx %d\n",ru_if_types[ru->if_south],ru->nb_tx); + LOG_I(PHY,"Initializing RU signal buffers (if_south %s) nb_tx %d, nb_rx %d\n",ru_if_types[ru->if_south],ru->nb_tx, ru->nb_rx); nfapi_nr_config_request_scf_t *cfg; ru->nb_log_antennas=0; @@ -60,7 +60,7 @@ int nr_phy_init_RU(RU_t *ru) { for (i=0; inb_tx; i++) { // Allocate 10 subframes of I/Q TX signal data (time) if not - ru->common.txdata[i] = (int32_t*)malloc16_clear( ru->sf_extension + (fp->samples_per_frame*sizeof(int32_t) )); + ru->common.txdata[i] = (int32_t*)malloc16_clear((ru->sf_extension +fp->samples_per_frame) *sizeof(int32_t)); LOG_I(PHY,"[INIT] common.txdata[%d] = %p (%lu bytes,sf_extension %d)\n",i,ru->common.txdata[i], (ru->sf_extension + fp->samples_per_frame)*sizeof(int32_t),ru->sf_extension); ru->common.txdata[i] = &ru->common.txdata[i][ru->sf_extension]; @@ -124,9 +124,10 @@ int nr_phy_init_RU(RU_t *ru) { ru->num_gNB,NUMBER_OF_gNB_MAX); LOG_I(PHY,"[INIT] %s() ru->num_gNB:%d \n", __FUNCTION__, ru->num_gNB); - if (ru->do_precoding == 1) { + + if (ru->do_precoding == 1) { int beam_count = 0; - if (ru->nb_tx>1) {//Enable beamforming when nb_tx > 1 + if (ru->nb_tx>1) { //Enable beamforming when nb_tx > 1 for (p=0;pnb_log_antennas;p++) { //if ((fp->L_ssb >> (63-p)) & 0x01)//64 bit-map with the MSB @2⁶³ corresponds to SSB ssb_index 0 @@ -149,7 +150,7 @@ int nr_phy_init_RU(RU_t *ru) { } // for j //} } // for p - } //for i + } // for i } ru->common.beam_id = (uint8_t**)malloc16_clear(ru->nb_tx*sizeof(uint8_t*)); @@ -205,12 +206,11 @@ void nr_phy_free_RU(RU_t *ru) free_and_zero(ru->prach_rxsigF[j][i]); free_and_zero(ru->prach_rxsigF[j]); } - if (ru->do_precoding == 1) { for (i = 0; i < ru->num_gNB; i++) { for (p = 0; p < ru->nb_log_antennas; p++) { - for (j=0; jnb_tx; j++) free_and_zero(ru->beam_weights[i][p][j]); - free_and_zero(ru->beam_weights[i][p]); + for (j=0; jnb_tx; j++) free_and_zero(ru->beam_weights[i][p][j]); + free_and_zero(ru->beam_weights[i][p]); } } for(i=0; i< ru->nb_tx; ++i) diff --git a/openair1/PHY/INIT/nr_init_ue.c b/openair1/PHY/INIT/nr_init_ue.c index a27c541c80..c6e6ecd463 100644 --- a/openair1/PHY/INIT/nr_init_ue.c +++ b/openair1/PHY/INIT/nr_init_ue.c @@ -55,12 +55,11 @@ extern uint16_t beta_cqi[16]; * \param[in] frame_parms LTE_DL_FRAME_PARMS structure. * \note This function is optimistic in that it expects malloc() to succeed. */ -void phy_init_nr_ue__PDSCH(NR_UE_PDSCH *const pdsch, +void phy_init_nr_ue_PDSCH(NR_UE_PDSCH *const pdsch, const NR_DL_FRAME_PARMS *const fp) { + AssertFatal( pdsch, "pdsch==0" ); - pdsch->pmi_ext = (uint8_t *)malloc16_clear( fp->N_RB_DL ); - pdsch->llr[0] = (int16_t *)malloc16_clear( (8*(3*8*6144))*sizeof(int16_t) ); - pdsch->layer_llr[0] = (int16_t *)malloc16_clear( (8*(3*8*6144))*sizeof(int16_t) ); + pdsch->llr128 = (int16_t **)malloc16_clear( sizeof(int16_t *) ); // FIXME! no further allocation for (int16_t*)pdsch->llr128 !!! expect SIGSEGV // FK, 11-3-2015: this is only as a temporary pointer, no memory is stored there @@ -72,14 +71,11 @@ void phy_init_nr_ue__PDSCH(NR_UE_PDSCH *const pdsch, pdsch->dl_ch_estimates_ext = (int32_t **)malloc16_clear( NR_MAX_NB_LAYERS*fp->nb_antennas_rx*sizeof(int32_t *) ); pdsch->dl_bf_ch_estimates = (int32_t **)malloc16_clear( NR_MAX_NB_LAYERS*fp->nb_antennas_rx*sizeof(int32_t *) ); pdsch->dl_bf_ch_estimates_ext = (int32_t **)malloc16_clear( NR_MAX_NB_LAYERS*fp->nb_antennas_rx*sizeof(int32_t *) ); - //pdsch->dl_ch_rho_ext = (int32_t**)malloc16_clear( 8*sizeof(int32_t*) ); - //pdsch->dl_ch_rho2_ext = (int32_t**)malloc16_clear( 8*sizeof(int32_t*) ); pdsch->dl_ch_mag0 = (int32_t **)malloc16_clear( NR_MAX_NB_LAYERS*fp->nb_antennas_rx*sizeof(int32_t *) ); pdsch->dl_ch_magb0 = (int32_t **)malloc16_clear( NR_MAX_NB_LAYERS*fp->nb_antennas_rx*sizeof(int32_t *) ); pdsch->dl_ch_magr0 = (int32_t **)malloc16_clear( NR_MAX_NB_LAYERS*fp->nb_antennas_rx*sizeof(int32_t *) ); pdsch->ptrs_phase_per_slot = (int32_t **)malloc16_clear( fp->nb_antennas_rx*sizeof(int32_t *) ); pdsch->ptrs_re_per_slot = (int32_t **)malloc16_clear( fp->nb_antennas_rx*sizeof(int32_t *) ); - pdsch->dl_ch_ptrs_estimates_ext = (int32_t **)malloc16_clear( fp->nb_antennas_rx*sizeof(int32_t *) ); // the allocated memory size is fixed: AssertFatal( fp->nb_antennas_rx <= 4, "nb_antennas_rx > 4" );//Extend the max number of UE Rx antennas to 4 @@ -89,7 +85,6 @@ void phy_init_nr_ue__PDSCH(NR_UE_PDSCH *const pdsch, pdsch->rxdataF_uespec_pilots[i] = (int32_t *)malloc16_clear( sizeof(int32_t) * fp->N_RB_DL*12); pdsch->ptrs_phase_per_slot[i] = (int32_t *)malloc16_clear( sizeof(int32_t) * 14 ); pdsch->ptrs_re_per_slot[i] = (int32_t *)malloc16_clear( sizeof(int32_t) * 14); - pdsch->dl_ch_ptrs_estimates_ext[i] = (int32_t *)malloc16_clear( sizeof(int32_t) * num); pdsch->rho[i] = (int32_t **)malloc16_clear( NR_MAX_NB_LAYERS*NR_MAX_NB_LAYERS*sizeof(int32_t *) ); for (int j=0; jdl_ch_estimates_ext[idx] = (int32_t *)malloc16_clear( sizeof(int32_t) * num ); pdsch->dl_bf_ch_estimates[idx] = (int32_t *)malloc16_clear( sizeof(int32_t) * fp->ofdm_symbol_size*7*2); pdsch->dl_bf_ch_estimates_ext[idx] = (int32_t *)malloc16_clear( sizeof(int32_t) * num ); - //pdsch->dl_ch_rho_ext[idx] = (int32_t*)malloc16_clear( sizeof(int32_t) * num ); - //pdsch->dl_ch_rho2_ext[idx] = (int32_t*)malloc16_clear( sizeof(int32_t) * num ); pdsch->dl_ch_mag0[idx] = (int32_t *)malloc16_clear( sizeof(int32_t) * num ); pdsch->dl_ch_magb0[idx] = (int32_t *)malloc16_clear( sizeof(int32_t) * num ); pdsch->dl_ch_magr0[idx] = (int32_t *)malloc16_clear( sizeof(int32_t) * num ); @@ -131,12 +124,14 @@ void phy_term_nr_ue__PDSCH(NR_UE_PDSCH* pdsch, const NR_DL_FRAME_PARMS *const fp free_and_zero(pdsch->rxdataF_uespec_pilots[i]); free_and_zero(pdsch->ptrs_phase_per_slot[i]); free_and_zero(pdsch->ptrs_re_per_slot[i]); - free_and_zero(pdsch->dl_ch_ptrs_estimates_ext[i]); free_and_zero(pdsch->rho[i]); } free_and_zero(pdsch->pmi_ext); - free_and_zero(pdsch->llr[0]); - free_and_zero(pdsch->layer_llr[0]); + int nb_codewords = NR_MAX_NB_LAYERS > 4 ? 2 : 1; + for (int i=0; illr[i]); + for (int i=0; ilayer_llr[i]); free_and_zero(pdsch->llr128); free_and_zero(pdsch->rxdataF_ext); free_and_zero(pdsch->rxdataF_uespec_pilots); @@ -151,22 +146,6 @@ void phy_term_nr_ue__PDSCH(NR_UE_PDSCH* pdsch, const NR_DL_FRAME_PARMS *const fp free_and_zero(pdsch->dl_ch_magr0); free_and_zero(pdsch->ptrs_phase_per_slot); free_and_zero(pdsch->ptrs_re_per_slot); - free_and_zero(pdsch->dl_ch_ptrs_estimates_ext); -} - -void phy_init_nr_ue_PUSCH(NR_UE_PUSCH *const pusch, - const NR_DL_FRAME_PARMS *const fp) { - AssertFatal( pusch, "pusch==0" ); - - for (int i=0; itxdataF_layers[i] = (int32_t *)malloc16_clear(NR_MAX_PUSCH_ENCODED_LENGTH*sizeof(int32_t)); - } -} - -void phy_term_nr_ue_PUSCH(NR_UE_PUSCH *pusch) -{ - for (int i = 0; i < NR_MAX_NB_LAYERS; i++) - free_and_zero(pusch->txdataF_layers[i]); } int init_nr_ue_signal(PHY_VARS_NR_UE *ue, int nb_connected_gNB) @@ -176,13 +155,14 @@ int init_nr_ue_signal(PHY_VARS_NR_UE *ue, int nb_connected_gNB) NR_UE_COMMON *const common_vars = &ue->common_vars; NR_UE_PBCH **const pbch_vars = ue->pbch_vars; NR_UE_PRACH **const prach_vars = ue->prach_vars; + NR_UE_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; - int i,j,k,l,slot,symb,q; - int gNB_id; - int th_id; - uint32_t ****pusch_dmrs; + int i, j, slot, symb, gNB_id, th_id; + LOG_I(PHY, "Initializing UE vars for gNB TXant %u, UE RXant %u\n", fp->nb_antennas_tx, fp->nb_antennas_rx); + phy_init_nr_top(ue); // many memory allocation sizes are hard coded AssertFatal( fp->nb_antennas_rx <= 4, "hard coded allocation for ue_common_vars->dl_ch_estimates[gNB_id]" ); @@ -210,15 +190,6 @@ int init_nr_ue_signal(PHY_VARS_NR_UE *ue, int nb_connected_gNB) // init NR modulation lookup tables nr_generate_modulation_table(); - /////////////////////////PUSCH init///////////////////////// - /////////// - for (th_id = 0; th_id < RX_NB_TH_MAX; th_id++) { - for (gNB_id = 0; gNB_id < ue->n_connected_gNB; gNB_id++) { - ue->pusch_vars[th_id][gNB_id] = (NR_UE_PUSCH *)malloc16(sizeof(NR_UE_PUSCH)); - phy_init_nr_ue_PUSCH( ue->pusch_vars[th_id][gNB_id], fp ); - } - } - /////////////////////////PUCCH init///////////////////////// /////////// for (th_id = 0; th_id < RX_NB_TH_MAX; th_id++) { @@ -234,20 +205,23 @@ int init_nr_ue_signal(PHY_VARS_NR_UE *ue, int nb_connected_gNB) /////////////////////////PUSCH DMRS init///////////////////////// /////////// + + // ceil(((NB_RB*6(k)*2(QPSK)/32) // 3 RE *2(QPSK) + int pusch_dmrs_init_length = ((fp->N_RB_UL*12)>>5)+1; ue->nr_gold_pusch_dmrs = (uint32_t ****)malloc16(fp->slots_per_frame*sizeof(uint32_t ***)); - pusch_dmrs = ue->nr_gold_pusch_dmrs; + uint32_t ****pusch_dmrs = ue->nr_gold_pusch_dmrs; for (slot=0; slotslots_per_frame; slot++) { pusch_dmrs[slot] = (uint32_t ***)malloc16(fp->symbols_per_slot*sizeof(uint32_t **)); AssertFatal(pusch_dmrs[slot]!=NULL, "init_nr_ue_signal: pusch_dmrs for slot %d - malloc failed\n", slot); for (symb=0; symbsymbols_per_slot; symb++) { - pusch_dmrs[slot][symb] = (uint32_t **)malloc16(NR_MAX_NB_CODEWORDS*sizeof(uint32_t *)); + pusch_dmrs[slot][symb] = (uint32_t **)malloc16(NR_NB_NSCID*sizeof(uint32_t *)); AssertFatal(pusch_dmrs[slot][symb]!=NULL, "init_nr_ue_signal: pusch_dmrs for slot %d symbol %d - malloc failed\n", slot, symb); - for (q=0; qN_RB_DL<<1)*3)>>5)+1; //PDCCH DMRS init (gNB offset = 0) ue->nr_gold_pdcch[0] = (uint32_t ***)malloc16(fp->slots_per_frame*sizeof(uint32_t **)); uint32_t ***pdcch_dmrs = ue->nr_gold_pdcch[0]; @@ -307,11 +283,14 @@ int init_nr_ue_signal(PHY_VARS_NR_UE *ue, int nb_connected_gNB) AssertFatal(pdcch_dmrs[slot]!=NULL, "NR init: pdcch_dmrs for slot %d - malloc failed\n", slot); for (int symb=0; symbsymbols_per_slot; symb++) { - pdcch_dmrs[slot][symb] = (uint32_t *)malloc16(NR_MAX_PDCCH_DMRS_INIT_LENGTH_DWORD*sizeof(uint32_t)); + pdcch_dmrs[slot][symb] = (uint32_t *)malloc16(pdcch_dmrs_init_length*sizeof(uint32_t)); AssertFatal(pdcch_dmrs[slot][symb]!=NULL, "NR init: pdcch_dmrs for slot %d symbol %d - malloc failed\n", slot, symb); } } + // ceil(((NB_RB*6(k)*2(QPSK)/32) // 3 RE *2(QPSK) + int pdsch_dmrs_init_length = ((fp->N_RB_DL*12)>>5)+1; + //PDSCH DMRS init (eNB offset = 0) ue->nr_gold_pdsch[0] = (uint32_t ****)malloc16(fp->slots_per_frame*sizeof(uint32_t ***)); uint32_t ****pdsch_dmrs = ue->nr_gold_pdsch[0]; @@ -321,32 +300,84 @@ int init_nr_ue_signal(PHY_VARS_NR_UE *ue, int nb_connected_gNB) AssertFatal(pdsch_dmrs[slot]!=NULL, "NR init: pdsch_dmrs for slot %d - malloc failed\n", slot); for (int symb=0; symbsymbols_per_slot; symb++) { - pdsch_dmrs[slot][symb] = (uint32_t **)malloc16(NR_MAX_NB_CODEWORDS*sizeof(uint32_t *)); + pdsch_dmrs[slot][symb] = (uint32_t **)malloc16(NR_NB_NSCID*sizeof(uint32_t *)); AssertFatal(pdsch_dmrs[slot][symb]!=NULL, "NR init: pdsch_dmrs for slot %d symbol %d - malloc failed\n", slot, symb); - for (int q=0; qn_connected_gNB; gNB_id++) { + for (gNB_id = 0; gNB_id < ue->n_connected_gNB+1; gNB_id++) { for (th_id=0; th_idpdsch_vars[th_id][gNB_id] = (NR_UE_PDSCH *)malloc16_clear(sizeof(NR_UE_PDSCH)); } + for (th_id=0; th_idpdsch_vars[th_id][gNB_id], fp ); + } + int nb_codewords = NR_MAX_NB_LAYERS > 4 ? 2 : 1; + for (th_id=0; th_idpdsch_vars[th_id][gNB_id]->llr[i] = (int16_t *)malloc16_clear( (8*(3*8*8448))*sizeof(int16_t) );//Q_m = 8 bits/Sym, Code_Rate=3, Number of Segments =8, Circular Buffer K_cb = 8448 + } + for (i=0; ipdsch_vars[th_id][gNB_id]->layer_llr[i] = (int16_t *)malloc16_clear( (8*(3*8*8448))*sizeof(int16_t) );//Q_m = 8 bits/Sym, Code_Rate=3, Number of Segments =8, Circular Buffer K_cb = 8448 + } + } + } + + for (gNB_id = 0; gNB_id < ue->n_connected_gNB; gNB_id++) { for (th_id=0; th_idpdcch_vars[th_id][gNB_id] = (NR_UE_PDCCH *)malloc16_clear(sizeof(NR_UE_PDCCH)); } prach_vars[gNB_id] = (NR_UE_PRACH *)malloc16_clear(sizeof(NR_UE_PRACH)); pbch_vars[gNB_id] = (NR_UE_PBCH *)malloc16_clear(sizeof(NR_UE_PBCH)); + csiim_vars[gNB_id] = (NR_UE_CSI_IM *)malloc16_clear(sizeof(NR_UE_CSI_IM)); + csirs_vars[gNB_id] = (NR_UE_CSI_RS *)malloc16_clear(sizeof(NR_UE_CSI_RS)); srs_vars[gNB_id] = (NR_UE_SRS *)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) + int csi_dmrs_init_length = ((fp->N_RB_DL<<4)>>5)+1; + ue->nr_csi_rs_info = (nr_csi_rs_info_t *)malloc16_clear(sizeof(nr_csi_rs_info_t)); + ue->nr_csi_rs_info->nr_gold_csi_rs = (uint32_t ***)malloc16(fp->slots_per_frame*sizeof(uint32_t **)); + AssertFatal(ue->nr_csi_rs_info->nr_gold_csi_rs!=NULL, "NR init: csi reference signal malloc failed\n"); + for (int slot=0; slotslots_per_frame; slot++) { + ue->nr_csi_rs_info->nr_gold_csi_rs[slot] = (uint32_t **)malloc16(fp->symbols_per_slot*sizeof(uint32_t *)); + AssertFatal(ue->nr_csi_rs_info->nr_gold_csi_rs[slot]!=NULL, "NR init: csi reference signal for slot %d - malloc failed\n", slot); + for (int symb=0; symbsymbols_per_slot; symb++) { + ue->nr_csi_rs_info->nr_gold_csi_rs[slot][symb] = (uint32_t *)malloc16(csi_dmrs_init_length*sizeof(uint32_t)); + AssertFatal(ue->nr_csi_rs_info->nr_gold_csi_rs[slot][symb]!=NULL, "NR init: csi reference signal for slot %d symbol %d - malloc failed\n", slot, symb); + } + } + ue->nr_csi_rs_info->noise_power = (uint32_t*)malloc16_clear(sizeof(uint32_t)); + ue->nr_csi_rs_info->csi_rs_generated_signal = (int32_t **)malloc16(NR_MAX_NB_PORTS * sizeof(int32_t *) ); + for (i=0; inr_csi_rs_info->csi_rs_generated_signal[i] = (int32_t *) malloc16_clear(fp->samples_per_frame_wCP * sizeof(int32_t)); + } + ue->nr_csi_rs_info->csi_rs_received_signal = (int32_t **)malloc16(fp->nb_antennas_rx * sizeof(int32_t *) ); + ue->nr_csi_rs_info->csi_rs_ls_estimated_channel = (int32_t ***)malloc16(fp->nb_antennas_rx * sizeof(int32_t **) ); + ue->nr_csi_rs_info->csi_rs_estimated_channel_freq = (int32_t ***)malloc16(fp->nb_antennas_rx * sizeof(int32_t **) ); + for (i=0; inb_antennas_rx; i++) { + ue->nr_csi_rs_info->csi_rs_received_signal[i] = (int32_t *) malloc16_clear(fp->samples_per_frame_wCP * sizeof(int32_t)); + ue->nr_csi_rs_info->csi_rs_ls_estimated_channel[i] = (int32_t **) malloc16_clear(NR_MAX_NB_PORTS * sizeof(int32_t *)); + ue->nr_csi_rs_info->csi_rs_estimated_channel_freq[i] = (int32_t **) malloc16_clear(NR_MAX_NB_PORTS * sizeof(int32_t *)); + for (j=0; jnr_csi_rs_info->csi_rs_ls_estimated_channel[i][j] = (int32_t *) malloc16_clear(fp->ofdm_symbol_size * sizeof(int32_t)); + ue->nr_csi_rs_info->csi_rs_estimated_channel_freq[i][j] = (int32_t *) malloc16_clear(fp->ofdm_symbol_size * sizeof(int32_t)); + } + } + ue->nr_srs_info = (nr_srs_info_t *)malloc16_clear(sizeof(nr_srs_info_t)); + ue->nr_srs_info->sc_list = (uint16_t *) malloc16_clear(6*fp->N_RB_UL*sizeof(uint16_t)); ue->nr_srs_info->srs_generated_signal = (int32_t *) malloc16_clear( (2*(fp->samples_per_frame)+2048)*sizeof(int32_t) ); ue->nr_srs_info->noise_power = (uint32_t*)malloc16_clear(sizeof(uint32_t)); ue->nr_srs_info->srs_received_signal = (int32_t **)malloc16( fp->nb_antennas_rx*sizeof(int32_t *) ); @@ -362,119 +393,11 @@ int init_nr_ue_signal(PHY_VARS_NR_UE *ue, int nb_connected_gNB) ue->nr_srs_info->srs_estimated_channel_time_shifted[i] = (int32_t *) malloc16_clear(fp->ofdm_symbol_size*MAX_NUM_NR_SRS_SYMBOLS*sizeof(int32_t)); } - for (th_id=0; th_idpdsch_vars[th_id][gNB_id], fp ); - } - for (th_id=0; th_idpdsch_vars[th_id][gNB_id]->llr_shifts = (uint8_t *)malloc16_clear(7*2*fp->N_RB_DL*12); - ue->pdsch_vars[th_id][gNB_id]->llr_shifts_p = ue->pdsch_vars[0][gNB_id]->llr_shifts; - ue->pdsch_vars[th_id][gNB_id]->llr[1] = (int16_t *)malloc16_clear( (8*(3*8*8448))*sizeof(int16_t) ); - ue->pdsch_vars[th_id][gNB_id]->layer_llr[1] = (int16_t *)malloc16_clear( (8*(3*8*8448))*sizeof(int16_t) ); - ue->pdsch_vars[th_id][gNB_id]->llr128_2ndstream = (int16_t **)malloc16_clear( sizeof(int16_t *) ); - } - - - for (th_id=0; th_idpdsch_vars[th_id][gNB_id]->dl_ch_rho2_ext = (int32_t **)malloc16_clear( 4*fp->nb_antennas_rx*sizeof(int32_t *) ); - } - - for (i=0; inb_antennas_rx; i++) - for (j=0; j<4; j++) { - const int idx = (j*fp->nb_antennas_rx)+i; - const size_t num = 7*2*fp->N_RB_DL*12+4; - - for (th_id=0; th_idpdsch_vars[th_id][gNB_id]->dl_ch_rho2_ext[idx] = (int32_t *)malloc16_clear( sizeof(int32_t) * num ); - } - } - - //const size_t num = 7*2*fp->N_RB_DL*12+4; - for (k=0; k<8; k++) { //harq_pid - for (l=0; l<8; l++) { //round - for (th_id=0; th_idpdsch_vars[th_id][gNB_id]->rxdataF_comp1[k][l] = (int32_t **)malloc16_clear( 4*fp->nb_antennas_rx*sizeof(int32_t *) ); - ue->pdsch_vars[th_id][gNB_id]->dl_ch_rho_ext[k][l] = (int32_t **)malloc16_clear( 4*fp->nb_antennas_rx*sizeof(int32_t *) ); - ue->pdsch_vars[th_id][gNB_id]->dl_ch_mag1[k][l] = (int32_t **)malloc16_clear( 4*fp->nb_antennas_rx*sizeof(int32_t *) ); - ue->pdsch_vars[th_id][gNB_id]->dl_ch_magb1[k][l] = (int32_t **)malloc16_clear( 4*fp->nb_antennas_rx*sizeof(int32_t *) ); - } - - for (int i=0; inb_antennas_rx; i++) - for (int j=0; j<4; j++) { //frame_parms->nb_antennas_tx; j++) - const int idx = (j*fp->nb_antennas_rx)+i; - - for (th_id=0; th_idpdsch_vars[th_id][gNB_id]->dl_ch_rho_ext[k][l][idx] = (int32_t *)malloc16_clear(7*2*sizeof(int32_t)*(fp->N_RB_DL*12)); - ue->pdsch_vars[th_id][gNB_id]->rxdataF_comp1[k][l][idx] = (int32_t *)malloc16_clear(7*2*sizeof(int32_t)*(fp->N_RB_DL*12)); - ue->pdsch_vars[th_id][gNB_id]->dl_ch_mag1[k][l][idx] = (int32_t *)malloc16_clear(7*2*sizeof(int32_t)*(fp->N_RB_DL*12)); - ue->pdsch_vars[th_id][gNB_id]->dl_ch_magb1[k][l][idx] = (int32_t *)malloc16_clear(7*2*sizeof(int32_t)*(fp->N_RB_DL*12)); - } - } - } - } - - // 100 PRBs * 12 REs/PRB * 4 PDCCH SYMBOLS * 2 LLRs/RE - for (th_id=0; th_idpdcch_vars[th_id][gNB_id]->llr = (int16_t *)malloc16_clear( 2*4*100*12*sizeof(uint16_t) ); - ue->pdcch_vars[th_id][gNB_id]->llr16 = (int16_t *)malloc16_clear( 2*4*100*12*sizeof(uint16_t) ); - ue->pdcch_vars[th_id][gNB_id]->wbar = (int16_t *)malloc16_clear( 2*4*100*12*sizeof(uint16_t) ); - ue->pdcch_vars[th_id][gNB_id]->e_rx = (int16_t *)malloc16_clear( 4*2*100*12 ); - ue->pdcch_vars[th_id][gNB_id]->rxdataF_comp = (int32_t **)malloc16_clear( 4*fp->nb_antennas_rx*sizeof(int32_t *) ); - ue->pdcch_vars[th_id][gNB_id]->dl_ch_rho_ext = (int32_t **)malloc16_clear( 4*fp->nb_antennas_rx*sizeof(int32_t *) ); - ue->pdcch_vars[th_id][gNB_id]->rho = (int32_t **)malloc16( fp->nb_antennas_rx*sizeof(int32_t *) ); - ue->pdcch_vars[th_id][gNB_id]->rxdataF_ext = (int32_t **)malloc16_clear( 4*fp->nb_antennas_rx*sizeof(int32_t *) ); - ue->pdcch_vars[th_id][gNB_id]->dl_ch_estimates_ext = (int32_t **)malloc16_clear( 4*fp->nb_antennas_rx*sizeof(int32_t *) ); - // Channel estimates - ue->pdcch_vars[th_id][gNB_id]->dl_ch_estimates = (int32_t **)malloc16_clear(4*fp->nb_antennas_rx*sizeof(int32_t *)); - ue->pdcch_vars[th_id][gNB_id]->dl_ch_estimates_time = (int32_t **)malloc16_clear(4*fp->nb_antennas_rx*sizeof(int32_t *)); - - for (i=0; inb_antennas_rx; i++) { - ue->pdcch_vars[th_id][gNB_id]->rho[i] = (int32_t *)malloc16_clear( sizeof(int32_t)*(100*12*4)); - - for (j=0; j<4; j++) { - int idx = (j*fp->nb_antennas_rx)+i; - ue->pdcch_vars[th_id][gNB_id]->dl_ch_estimates[idx] = (int32_t *)malloc16_clear( sizeof(int32_t)*fp->symbols_per_slot*(fp->ofdm_symbol_size+LTE_CE_FILTER_LENGTH) ); - ue->pdcch_vars[th_id][gNB_id]->dl_ch_estimates_time[idx] = (int32_t *)malloc16_clear( sizeof(int32_t)*fp->ofdm_symbol_size*2 ); - // size_t num = 7*2*fp->N_RB_DL*12; - size_t num = 4*273*12; // 4 symbols, 100 PRBs, 12 REs per PRB - ue->pdcch_vars[th_id][gNB_id]->rxdataF_comp[idx] = (int32_t *)malloc16_clear(sizeof(int32_t) * num); - ue->pdcch_vars[th_id][gNB_id]->dl_ch_rho_ext[idx] = (int32_t *)malloc16_clear(sizeof(int32_t) * num); - ue->pdcch_vars[th_id][gNB_id]->rxdataF_ext[idx] = (int32_t *)malloc16_clear(sizeof(int32_t) * num); - ue->pdcch_vars[th_id][gNB_id]->dl_ch_estimates_ext[idx] = (int32_t *)malloc16_clear(sizeof(int32_t) * num); - } - } - } - - // PBCH - pbch_vars[gNB_id]->rxdataF_ext = (int32_t **)malloc16( fp->nb_antennas_rx*sizeof(int32_t *) ); - pbch_vars[gNB_id]->rxdataF_comp = (int32_t **)malloc16_clear( 4*fp->nb_antennas_rx*sizeof(int32_t *) ); - pbch_vars[gNB_id]->dl_ch_estimates = (int32_t **)malloc16_clear( 4*fp->nb_antennas_rx*sizeof(int32_t *) ); - pbch_vars[gNB_id]->dl_ch_estimates_ext = (int32_t **)malloc16_clear( 4*fp->nb_antennas_rx*sizeof(int32_t *) ); - pbch_vars[gNB_id]->dl_ch_estimates_time = (int32_t **)malloc16_clear( 4*fp->nb_antennas_rx*sizeof(int32_t *) ); - pbch_vars[gNB_id]->llr = (int16_t *)malloc16_clear( 1920 ); // + // RACH prach_vars[gNB_id]->prachF = (int16_t *)malloc16_clear( sizeof(int)*(7*2*sizeof(int)*(fp->ofdm_symbol_size*12)) ); prach_vars[gNB_id]->prach = (int16_t *)malloc16_clear( sizeof(int)*(7*2*sizeof(int)*(fp->ofdm_symbol_size*12)) ); - for (i=0; inb_antennas_rx; i++) { - pbch_vars[gNB_id]->rxdataF_ext[i] = (int32_t *)malloc16_clear( sizeof(int32_t)*20*12*4 ); - - for (j=0; j<4; j++) {//fp->nb_antennas_tx;j++) { - int idx = (j*fp->nb_antennas_rx)+i; - pbch_vars[gNB_id]->rxdataF_comp[idx] = (int32_t *)malloc16_clear( sizeof(int32_t)*20*12*4 ); - pbch_vars[gNB_id]->dl_ch_estimates[idx] = (int32_t *)malloc16_clear( sizeof(int32_t)*7*2*sizeof(int)*(fp->ofdm_symbol_size) ); - pbch_vars[gNB_id]->dl_ch_estimates_time[idx]= (int32_t *)malloc16_clear( sizeof(int32_t)*7*2*sizeof(int)*(fp->ofdm_symbol_size) ); - pbch_vars[gNB_id]->dl_ch_estimates_ext[idx] = (int32_t *)malloc16_clear( sizeof(int32_t)*20*12*4 ); - } - } - - pbch_vars[gNB_id]->decoded_output = (uint8_t *)malloc16_clear(64); - } - - // initialization for the last instance of pdsch_vars (used for MU-MIMO) - for (th_id=0; th_idpdsch_vars[th_id][gNB_id] = malloc16_clear(sizeof(NR_UE_PDSCH)); - ue->pdsch_vars[th_id][gNB_id]->llr[1] = malloc16_clear((8*(3*8*8448))*sizeof(int16_t)); - ue->pdsch_vars[th_id][gNB_id]->layer_llr[1] = malloc16_clear((8*(3*8*8448))*sizeof(int16_t)); } ue->sinr_CQI_dB = (double *) malloc16_clear( fp->N_RB_DL*12*sizeof(double) ); @@ -502,15 +425,13 @@ void term_nr_ue_signal(PHY_VARS_NR_UE *ue, int nb_connected_gNB) for (int th_id = 0; th_id < RX_NB_TH_MAX; th_id++) { for (int gNB_id = 0; gNB_id < ue->n_connected_gNB; gNB_id++) { - phy_term_nr_ue_PUSCH(ue->pusch_vars[th_id][gNB_id]); - free_and_zero(ue->pusch_vars[th_id][gNB_id]); free_and_zero(ue->pucch_vars[th_id][gNB_id]); } } for (int slot = 0; slot < fp->slots_per_frame; slot++) { for (int symb = 0; symb < fp->symbols_per_slot; symb++) { - for (int q = 0; q < NR_MAX_NB_CODEWORDS; q++) + for (int q=0; qnr_gold_pusch_dmrs[slot][symb][q]); free_and_zero(ue->nr_gold_pusch_dmrs[slot][symb]); } @@ -547,7 +468,7 @@ void term_nr_ue_signal(PHY_VARS_NR_UE *ue, int nb_connected_gNB) for (int slot=0; slotslots_per_frame; slot++) { for (int symb=0; symbsymbols_per_slot; symb++) { - for (int q=0; qnr_gold_pdsch[0][slot][symb][q]); free_and_zero(ue->nr_gold_pdsch[0][slot][symb]); } @@ -555,73 +476,50 @@ void term_nr_ue_signal(PHY_VARS_NR_UE *ue, int nb_connected_gNB) } free_and_zero(ue->nr_gold_pdsch[0]); - for (int gNB_id = 0; gNB_id < ue->n_connected_gNB; gNB_id++) { + for (int gNB_id = 0; gNB_id < ue->n_connected_gNB+1; gNB_id++) { // PDSCH for (int th_id = 0; th_id < RX_NB_TH_MAX; th_id++) { - for (int k = 0; k < 8; k++) { //harq_pid - for (int l = 0; l < 8; l++) { //round - for (int i = 0; i < fp->nb_antennas_rx; i++) { - for (int j = 0; j < 4; j++) { //frame_parms->nb_antennas_tx; j++) - const int idx = j * fp->nb_antennas_rx + i; - free_and_zero(ue->pdsch_vars[th_id][gNB_id]->dl_ch_rho_ext[k][l][idx]); - free_and_zero(ue->pdsch_vars[th_id][gNB_id]->rxdataF_comp1[k][l][idx]); - free_and_zero(ue->pdsch_vars[th_id][gNB_id]->dl_ch_mag1[k][l][idx]); - free_and_zero(ue->pdsch_vars[th_id][gNB_id]->dl_ch_magb1[k][l][idx]); - } - } - - free_and_zero(ue->pdsch_vars[th_id][gNB_id]->rxdataF_comp1[k][l]); - free_and_zero(ue->pdsch_vars[th_id][gNB_id]->dl_ch_rho_ext[k][l]); - free_and_zero(ue->pdsch_vars[th_id][gNB_id]->dl_ch_mag1[k][l]); - free_and_zero(ue->pdsch_vars[th_id][gNB_id]->dl_ch_magb1[k][l]); - } - } - - for (int i = 0; i < fp->nb_antennas_rx; i++) { - for (int j = 0; j < 4; j++) { - const int idx = (j*fp->nb_antennas_rx)+i; - free_and_zero(ue->pdsch_vars[th_id][gNB_id]->dl_ch_rho2_ext[idx]); - } - } free_and_zero(ue->pdsch_vars[th_id][gNB_id]->llr_shifts); - free_and_zero(ue->pdsch_vars[th_id][gNB_id]->llr[1]); - free_and_zero(ue->pdsch_vars[th_id][gNB_id]->layer_llr[1]); free_and_zero(ue->pdsch_vars[th_id][gNB_id]->llr128_2ndstream); - free_and_zero(ue->pdsch_vars[th_id][gNB_id]->dl_ch_rho2_ext); - phy_term_nr_ue__PDSCH(ue->pdsch_vars[th_id][gNB_id], fp); free_and_zero(ue->pdsch_vars[th_id][gNB_id]); } + } + + for (int gNB_id = 0; gNB_id < ue->n_connected_gNB; gNB_id++) { for (int th_id = 0; th_id < RX_NB_TH_MAX; th_id++) { - for (int i = 0; i < fp->nb_antennas_rx; i++) { - for (int j = 0; j < 4; j++) { - int idx = j * fp->nb_antennas_rx + i; - free_and_zero(ue->pdcch_vars[th_id][gNB_id]->dl_ch_estimates[idx]); - free_and_zero(ue->pdcch_vars[th_id][gNB_id]->dl_ch_estimates_time[idx]); - free_and_zero(ue->pdcch_vars[th_id][gNB_id]->rxdataF_comp[idx]); - free_and_zero(ue->pdcch_vars[th_id][gNB_id]->dl_ch_rho_ext[idx]); - free_and_zero(ue->pdcch_vars[th_id][gNB_id]->rxdataF_ext[idx]); - free_and_zero(ue->pdcch_vars[th_id][gNB_id]->dl_ch_estimates_ext[idx]); - } - free_and_zero(ue->pdcch_vars[th_id][gNB_id]->rho[i]); - } - free_and_zero(ue->pdcch_vars[th_id][gNB_id]->llr); - free_and_zero(ue->pdcch_vars[th_id][gNB_id]->llr16); - free_and_zero(ue->pdcch_vars[th_id][gNB_id]->wbar); - free_and_zero(ue->pdcch_vars[th_id][gNB_id]->e_rx); - free_and_zero(ue->pdcch_vars[th_id][gNB_id]->rxdataF_comp); - free_and_zero(ue->pdcch_vars[th_id][gNB_id]->dl_ch_rho_ext); - free_and_zero(ue->pdcch_vars[th_id][gNB_id]->rho); - free_and_zero(ue->pdcch_vars[th_id][gNB_id]->rxdataF_ext); - free_and_zero(ue->pdcch_vars[th_id][gNB_id]->dl_ch_estimates_ext); - free_and_zero(ue->pdcch_vars[th_id][gNB_id]->dl_ch_estimates); - free_and_zero(ue->pdcch_vars[th_id][gNB_id]->dl_ch_estimates_time); free_and_zero(ue->pdcch_vars[th_id][gNB_id]); } + for (int i=0; inr_csi_rs_info->csi_rs_generated_signal[i]); + } + for (int i = 0; i < fp->nb_antennas_rx; i++) { + free_and_zero(ue->nr_csi_rs_info->csi_rs_received_signal[i]); + for (int j=0; jnr_csi_rs_info->csi_rs_ls_estimated_channel[i][j]); + free_and_zero(ue->nr_csi_rs_info->csi_rs_estimated_channel_freq[i][j]); + } + free_and_zero(ue->nr_csi_rs_info->csi_rs_ls_estimated_channel[i]); + free_and_zero(ue->nr_csi_rs_info->csi_rs_estimated_channel_freq[i]); + } + for (int slot=0; slotslots_per_frame; slot++) { + for (int symb=0; symbsymbols_per_slot; symb++) { + free_and_zero(ue->nr_csi_rs_info->nr_gold_csi_rs[slot][symb]); + } + free_and_zero(ue->nr_csi_rs_info->nr_gold_csi_rs[slot]); + } + free_and_zero(ue->nr_csi_rs_info->noise_power); + free_and_zero(ue->nr_csi_rs_info->nr_gold_csi_rs); + free_and_zero(ue->nr_csi_rs_info->csi_rs_generated_signal); + free_and_zero(ue->nr_csi_rs_info->csi_rs_received_signal); + free_and_zero(ue->nr_csi_rs_info->csi_rs_ls_estimated_channel); + free_and_zero(ue->nr_csi_rs_info->csi_rs_estimated_channel_freq); + free_and_zero(ue->nr_csi_rs_info); + for (int i = 0; i < fp->nb_antennas_rx; i++) { free_and_zero(ue->nr_srs_info->srs_received_signal[i]); free_and_zero(ue->nr_srs_info->srs_ls_estimated_channel[i]); @@ -629,6 +527,7 @@ void term_nr_ue_signal(PHY_VARS_NR_UE *ue, int nb_connected_gNB) free_and_zero(ue->nr_srs_info->srs_estimated_channel_time[i]); free_and_zero(ue->nr_srs_info->srs_estimated_channel_time_shifted[i]); } + free_and_zero(ue->nr_srs_info->sc_list); free_and_zero(ue->nr_srs_info->srs_generated_signal); free_and_zero(ue->nr_srs_info->noise_power); free_and_zero(ue->nr_srs_info->srs_received_signal); @@ -638,27 +537,10 @@ void term_nr_ue_signal(PHY_VARS_NR_UE *ue, int nb_connected_gNB) free_and_zero(ue->nr_srs_info->srs_estimated_channel_time_shifted); 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]); - for (int i = 0; i < fp->nb_antennas_rx; i++) { - free_and_zero(ue->pbch_vars[gNB_id]->rxdataF_ext[i]); - - for (int j = 0; j < 4; j++) { - int idx = (j*fp->nb_antennas_rx)+i; - free_and_zero(ue->pbch_vars[gNB_id]->rxdataF_comp[idx]); - free_and_zero(ue->pbch_vars[gNB_id]->dl_ch_estimates[idx]); - free_and_zero(ue->pbch_vars[gNB_id]->dl_ch_estimates_time[idx]); - free_and_zero(ue->pbch_vars[gNB_id]->dl_ch_estimates_ext[idx]); - } - } - - free_and_zero(ue->pbch_vars[gNB_id]->rxdataF_ext); - free_and_zero(ue->pbch_vars[gNB_id]->rxdataF_comp); - free_and_zero(ue->pbch_vars[gNB_id]->dl_ch_estimates); - free_and_zero(ue->pbch_vars[gNB_id]->dl_ch_estimates_ext); - free_and_zero(ue->pbch_vars[gNB_id]->dl_ch_estimates_time); - free_and_zero(ue->pbch_vars[gNB_id]->llr); - free_and_zero(ue->pbch_vars[gNB_id]->decoded_output); free_and_zero(ue->pbch_vars[gNB_id]); free_and_zero(ue->prach_vars[gNB_id]->prachF); @@ -666,13 +548,6 @@ void term_nr_ue_signal(PHY_VARS_NR_UE *ue, int nb_connected_gNB) free_and_zero(ue->prach_vars[gNB_id]); } - const int gNB_id = ue->n_connected_gNB; - for (int th_id = 0; th_id < RX_NB_TH_MAX; th_id++) { - free_and_zero(ue->pdsch_vars[th_id][gNB_id]->llr[1]); - free_and_zero(ue->pdsch_vars[th_id][gNB_id]->layer_llr[1]); - free_and_zero(ue->pdsch_vars[th_id][gNB_id]); - } - free_and_zero(ue->sinr_CQI_dB); } @@ -683,7 +558,8 @@ void term_nr_ue_transport(PHY_VARS_NR_UE *ue) for (int j = 0; j < 2; j++) { for (int k = 0; k < RX_NB_TH_MAX; k++) { free_nr_ue_dlsch(&ue->dlsch[k][i][j], N_RB_DL); - free_nr_ue_ulsch(&ue->ulsch[k][i][j], N_RB_DL); + if (j==0) + free_nr_ue_ulsch(&ue->ulsch[k][i], N_RB_DL, &ue->frame_parms); } } @@ -694,20 +570,24 @@ void term_nr_ue_transport(PHY_VARS_NR_UE *ue) free_nr_ue_dlsch(&ue->dlsch_MCH[0], N_RB_DL); } -void init_nr_ue_transport(PHY_VARS_NR_UE *ue) -{ +void init_nr_ue_transport(PHY_VARS_NR_UE *ue) { + + int num_codeword = NR_MAX_NB_LAYERS > 4? 2:1; + for (int i = 0; i < NUMBER_OF_CONNECTED_gNB_MAX; i++) { - for (int j=0; j<2; j++) { + for (int j=0; jdlsch[k][i][j] = new_nr_ue_dlsch(1,NR_MAX_DLSCH_HARQ_PROCESSES,NSOFT,MAX_LDPC_ITERATIONS,ue->frame_parms.N_RB_DL))!=NULL,"Can't get ue dlsch structures\n"); + AssertFatal((ue->dlsch[k][i][j] = new_nr_ue_dlsch(1,NR_MAX_DLSCH_HARQ_PROCESSES,NSOFT,ue->max_ldpc_iterations,ue->frame_parms.N_RB_DL))!=NULL,"Can't get ue dlsch structures\n"); LOG_D(PHY,"dlsch[%d][%d][%d] => %p\n",k,i,j,ue->dlsch[k][i][j]); - AssertFatal((ue->ulsch[k][i][j] = new_nr_ue_ulsch(ue->frame_parms.N_RB_UL, NR_MAX_ULSCH_HARQ_PROCESSES))!=NULL,"Can't get ue ulsch structures\n"); - LOG_D(PHY,"ulsch[%d][%d][%d] => %p\n",k,i,j,ue->ulsch[k][i][j]); + if (j==0) { + AssertFatal((ue->ulsch[k][i] = new_nr_ue_ulsch(ue->frame_parms.N_RB_UL, NR_MAX_ULSCH_HARQ_PROCESSES,&ue->frame_parms))!=NULL,"Can't get ue ulsch structures\n"); + LOG_D(PHY,"ulsch[%d][%d] => %p\n",k,i,ue->ulsch[k][i]); + } } } - ue->dlsch_SI[i] = new_nr_ue_dlsch(1,1,NSOFT,MAX_LDPC_ITERATIONS,ue->frame_parms.N_RB_DL); - ue->dlsch_ra[i] = new_nr_ue_dlsch(1,1,NSOFT,MAX_LDPC_ITERATIONS,ue->frame_parms.N_RB_DL); + ue->dlsch_SI[i] = new_nr_ue_dlsch(1,1,NSOFT,ue->max_ldpc_iterations,ue->frame_parms.N_RB_DL); + ue->dlsch_ra[i] = new_nr_ue_dlsch(1,1,NSOFT,ue->max_ldpc_iterations,ue->frame_parms.N_RB_DL); ue->transmission_mode[i] = ue->frame_parms.nb_antenna_ports_gNB==1 ? 1 : 2; } diff --git a/openair1/PHY/INIT/nr_parms.c b/openair1/PHY/INIT/nr_parms.c index 35bc28d9c1..458c8b3403 100644 --- a/openair1/PHY/INIT/nr_parms.c +++ b/openair1/PHY/INIT/nr_parms.c @@ -253,7 +253,6 @@ int nr_init_frame_parms(nfapi_nr_config_request_scf_t* cfg, LOG_I(PHY,"Initializing frame parms for mu %d, N_RB %d, Ncp %d\n",mu, fp->N_RB_DL, Ncp); - if (Ncp == NFAPI_CP_EXTENDED) AssertFatal(mu == NR_MU_2,"Invalid cyclic prefix %d for numerology index %d\n", Ncp, mu); @@ -367,8 +366,10 @@ int nr_init_frame_parms_ue(NR_DL_FRAME_PARMS *fp, uint8_t sco = 0; if (((fp->freq_range == nr_FR1) && (config->ssb_table.ssb_subcarrier_offset<24)) || - ((fp->freq_range == nr_FR2) && (config->ssb_table.ssb_subcarrier_offset<12)) ) - sco = config->ssb_table.ssb_subcarrier_offset; + ((fp->freq_range == nr_FR2) && (config->ssb_table.ssb_subcarrier_offset<12)) ) { + if (fp->freq_range == nr_FR1) + sco = config->ssb_table.ssb_subcarrier_offset>>config->ssb_config.scs_common; + } fp->ssb_start_subcarrier = (12 * config->ssb_table.ssb_offset_point_a + sco); set_Lmax(fp); diff --git a/openair1/PHY/INIT/phy_init.h b/openair1/PHY/INIT/phy_init.h index 8648dd7d82..29940a4fbe 100644 --- a/openair1/PHY/INIT/phy_init.h +++ b/openair1/PHY/INIT/phy_init.h @@ -402,6 +402,7 @@ void init_nr_ue_transport(PHY_VARS_NR_UE *ue); void init_N_TA_offset(PHY_VARS_NR_UE *ue); void nr_dump_frame_parms(NR_DL_FRAME_PARMS *frame_parms); int phy_init_nr_gNB(PHY_VARS_gNB *gNB, unsigned char is_secondary_gNB, unsigned char lowmem_flag); +int init_codebook_gNB(PHY_VARS_gNB *gNB); void nr_phy_config_request(NR_PHY_Config_t *gNB); void nr_phy_config_request_sim(PHY_VARS_gNB *gNB,int N_RB_DL,int N_RB_UL,int mu,int Nid_cell,uint64_t position_in_burst); void phy_free_nr_gNB(PHY_VARS_gNB *gNB); diff --git a/openair1/PHY/LTE_ESTIMATION/lte_est_freq_offset.c b/openair1/PHY/LTE_ESTIMATION/lte_est_freq_offset.c index ed82aeb09e..80d9fc9cc3 100644 --- a/openair1/PHY/LTE_ESTIMATION/lte_est_freq_offset.c +++ b/openair1/PHY/LTE_ESTIMATION/lte_est_freq_offset.c @@ -102,7 +102,7 @@ int lte_est_freq_offset(int **dl_ch_estimates, { int ch_offset, omega, dl_ch_shift; - struct complex16 omega_cpx; + c16_t omega_cpx; double phase_offset; int freq_offset_est; unsigned char aa; @@ -142,8 +142,8 @@ int lte_est_freq_offset(int **dl_ch_estimates, // printf("Computing freq_offset\n"); omega = dot_product(dl_ch,dl_ch_prev,(frame_parms->N_RB_DL/2 - 1)*12,dl_ch_shift); //omega = dot_product(dl_ch,dl_ch_prev,frame_parms->ofdm_symbol_size,15); - omega_cpx.r = ((struct complex16*) &omega)->r; - omega_cpx.i = ((struct complex16*) &omega)->i; + omega_cpx.r = ((c16_t*) &omega)->r; + omega_cpx.i = ((c16_t*) &omega)->i; dl_ch = (int16_t *)&dl_ch_estimates[aa][(((frame_parms->N_RB_DL/2) + 1)*12) + ch_offset]; @@ -155,8 +155,8 @@ int lte_est_freq_offset(int **dl_ch_estimates, // calculate omega = angle(conj(dl_ch)*dl_ch_prev)) omega = dot_product(dl_ch,dl_ch_prev,((frame_parms->N_RB_DL/2) - 1)*12,dl_ch_shift); - omega_cpx.r += ((struct complex16*) &omega)->r; - omega_cpx.i += ((struct complex16*) &omega)->i; + omega_cpx.r += ((c16_t*) &omega)->r; + omega_cpx.i += ((c16_t*) &omega)->i; // phase_offset += atan2((double)omega_cpx->i,(double)omega_cpx->r); phase_offset += atan2((double)omega_cpx.i,(double)omega_cpx.r); @@ -195,7 +195,7 @@ int lte_mbsfn_est_freq_offset(int **dl_ch_estimates, { int ch_offset, omega, dl_ch_shift; - struct complex16 *omega_cpx; + c16_t *omega_cpx; double phase_offset; int freq_offset_est; unsigned char aa; @@ -234,7 +234,7 @@ int lte_mbsfn_est_freq_offset(int **dl_ch_estimates, // printf("Computing freq_offset\n"); omega = dot_product(dl_ch,dl_ch_prev,(frame_parms->N_RB_DL/2 - 1)*12,dl_ch_shift); //omega = dot_product(dl_ch,dl_ch_prev,frame_parms->ofdm_symbol_size,15); - omega_cpx = (struct complex16*) ω + omega_cpx = (c16_t*) ω // printf("omega (%d,%d)\n",omega_cpx->r,omega_cpx->i); @@ -247,8 +247,8 @@ int lte_mbsfn_est_freq_offset(int **dl_ch_estimates, // calculate omega = angle(conj(dl_ch)*dl_ch_prev)) omega = dot_product(dl_ch,dl_ch_prev,((frame_parms->N_RB_DL/2) - 1)*12,dl_ch_shift); - omega_cpx->r += ((struct complex16*) &omega)->r; - omega_cpx->i += ((struct complex16*) &omega)->i; + omega_cpx->r += ((c16_t*) &omega)->r; + omega_cpx->i += ((c16_t*) &omega)->i; // phase_offset += atan2((double)omega_cpx->i,(double)omega_cpx->r); phase_offset += atan2((double)omega_cpx->i,(double)omega_cpx->r); // printf("omega (%d,%d) -> %f\n",omega_cpx->r,omega_cpx->i,phase_offset); diff --git a/openair1/PHY/LTE_ESTIMATION/lte_sync_time.c b/openair1/PHY/LTE_ESTIMATION/lte_sync_time.c index 1fbc8b7ef2..b21f526fcc 100644 --- a/openair1/PHY/LTE_ESTIMATION/lte_sync_time.c +++ b/openair1/PHY/LTE_ESTIMATION/lte_sync_time.c @@ -34,9 +34,9 @@ // Note: this is for prototype of generate_drs_pusch (OTA synchronization of RRUs) #include "PHY/LTE_UE_TRANSPORT/transport_proto_ue.h" -static struct complex16 *primary_synch0_time __attribute__((aligned(32))); -static struct complex16 *primary_synch1_time __attribute__((aligned(32))); -static struct complex16 *primary_synch2_time __attribute__((aligned(32))); +static c16_t *primary_synch0_time __attribute__((aligned(32))); +static c16_t *primary_synch1_time __attribute__((aligned(32))); +static c16_t *primary_synch2_time __attribute__((aligned(32))); static void doIdft(int size, short *in, short *out) { switch (size) { @@ -67,7 +67,7 @@ static void doIdft(int size, short *in, short *out) { } } -static void copyPrimary( struct complex16 *out, struct complex16 *in, int ofdmSize) { +static void copyPrimary( c16_t *out, struct complex16 *in, int ofdmSize) { int k=ofdmSize-36; for (int i=0; i<72; i++) { @@ -83,20 +83,20 @@ static void copyPrimary( struct complex16 *out, struct complex16 *in, int ofdmSi } int lte_sync_time_init(LTE_DL_FRAME_PARMS *frame_parms ) { // LTE_UE_COMMON *common_vars - struct complex16 syncF_tmp[2048]__attribute__((aligned(32)))= {{0}}; + c16_t syncF_tmp[2048]__attribute__((aligned(32)))= {{0}}; int sz=frame_parms->ofdm_symbol_size*sizeof(*primary_synch0_time); - AssertFatal( NULL != (primary_synch0_time = (struct complex16 *)malloc16(sz)),""); + AssertFatal( NULL != (primary_synch0_time = (c16_t *)malloc16(sz)),""); bzero(primary_synch0_time,sz); - AssertFatal( NULL != (primary_synch1_time = (struct complex16 *)malloc16(sz)),""); + AssertFatal( NULL != (primary_synch1_time = (c16_t *)malloc16(sz)),""); bzero(primary_synch1_time,sz); - AssertFatal( NULL != (primary_synch2_time = (struct complex16 *)malloc16(sz)),""); + AssertFatal( NULL != (primary_synch2_time = (c16_t *)malloc16(sz)),""); bzero(primary_synch2_time,sz); // generate oversampled sync_time sequences - copyPrimary( syncF_tmp, (struct complex16 *) primary_synch0, frame_parms->ofdm_symbol_size); + copyPrimary( syncF_tmp, (c16_t *) primary_synch0, frame_parms->ofdm_symbol_size); doIdft(frame_parms->N_RB_DL, (short *)syncF_tmp,(short *)primary_synch0_time); - copyPrimary( syncF_tmp, (struct complex16 *) primary_synch1, frame_parms->ofdm_symbol_size); + copyPrimary( syncF_tmp, (c16_t *) primary_synch1, frame_parms->ofdm_symbol_size); doIdft(frame_parms->N_RB_DL, (short *)syncF_tmp,(short *)primary_synch1_time); - copyPrimary( syncF_tmp, (struct complex16 *) primary_synch2, frame_parms->ofdm_symbol_size); + copyPrimary( syncF_tmp, (c16_t *) primary_synch2, frame_parms->ofdm_symbol_size); doIdft(frame_parms->N_RB_DL, (short *)syncF_tmp,(short *)primary_synch2_time); if ( LOG_DUMPFLAG(DEBUG_LTEESTIM)){ diff --git a/openair1/PHY/LTE_TRANSPORT/dlsch_modulation.c b/openair1/PHY/LTE_TRANSPORT/dlsch_modulation.c index c6b312cc61..de21b7f4e2 100644 --- a/openair1/PHY/LTE_TRANSPORT/dlsch_modulation.c +++ b/openair1/PHY/LTE_TRANSPORT/dlsch_modulation.c @@ -2237,7 +2237,7 @@ int dlsch_modulation(PHY_VARS_eNB* phy_vars_eNB, int P1_SHIFT[13],P2_SHIFT[13]; int offset,nushiftmod3; - uint8_t get_pmi_temp; + int get_pmi_temp; MIMO_mode_t mimo_mode = -1; uint8_t mprime=0,Ns; diff --git a/openair1/PHY/LTE_TRANSPORT/if5_tools.c b/openair1/PHY/LTE_TRANSPORT/if5_tools.c index 86723d0fed..76d62f34a2 100644 --- a/openair1/PHY/LTE_TRANSPORT/if5_tools.c +++ b/openair1/PHY/LTE_TRANSPORT/if5_tools.c @@ -1052,7 +1052,7 @@ static inline int64_t clock_difftime_ns(struct timespec start, struct timespec e void send_IF5(RU_t *ru, openair0_timestamp proc_timestamp, int tti, uint8_t *seqno, uint16_t packet_type) { LTE_DL_FRAME_PARMS *fp=ru->frame_parms; - int32_t *txp[fp->nb_antennas_tx], *rxp[fp->nb_antennas_rx]; + int32_t *txp[ru->nb_tx], *rxp[ru->nb_rx]; int32_t *tx_buffer=NULL; uint16_t packet_id=0, i=0; @@ -1106,9 +1106,9 @@ void send_IF5(RU_t *ru, openair0_timestamp proc_timestamp, int tti, uint8_t *seq NR_DL_FRAME_PARMS *nrfp = ru->nr_frame_parms; - int offset,siglen; + int offset,siglen,factor=1; if (nrfp) { - offset = nrfp->get_samples_slot_timestamp(tti,nrfp,0); + offset = nrfp->get_samples_slot_timestamp(tti,nrfp,0); siglen = nrfp->get_samples_per_slot(tti,nrfp); } else { @@ -1116,6 +1116,13 @@ void send_IF5(RU_t *ru, openair0_timestamp proc_timestamp, int tti, uint8_t *seq siglen = spsf; } + if (ru->openair0_cfg.nr_flag==1) { + if (nrfp->N_RB_DL <= 162 && nrfp->N_RB_DL >= 106) factor = 2; + else if (nrfp->N_RB_DL < 106) factor=4; + } + else { + factor = 30720/spsf; + } for (i=0; i < ru->nb_tx; i++) txp[i] = (int32_t*)&ru->common.txdata[i][offset]; @@ -1124,8 +1131,9 @@ void send_IF5(RU_t *ru, openair0_timestamp proc_timestamp, int tti, uint8_t *seq //VCD_SIGNAL_DUMPER_DUMP_VARIABLE_BY_NAME( VCD_SIGNAL_DUMPER_VARIABLES_SEND_IF5_PKT_ID, packet_id ); //VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME( VCD_SIGNAL_DUMPER_FUNCTIONS_TRX_WRITE_IF0, 1 ); clock_gettime( CLOCK_MONOTONIC, &start_comp); + ru->ifdevice.trx_write_func2(&ru->ifdevice, - (proc_timestamp + packet_id*spp_eth-500)*(30720/spsf), + (proc_timestamp + packet_id*spp_eth-600)*factor, (void*)txp[aid], spp_eth, aid, @@ -1326,6 +1334,8 @@ void recv_IF5(RU_t *ru, openair0_timestamp *proc_timestamp, int tti, uint16_t pa NR_DL_FRAME_PARMS *nrfp = ru->nr_frame_parms; int offset,siglen; + int factor=1; + int ts_offset; if (nrfp) { offset = nrfp->get_samples_slot_timestamp(tti,nrfp,0); siglen = nrfp->get_samples_per_slot(tti,nrfp); @@ -1334,6 +1344,15 @@ void recv_IF5(RU_t *ru, openair0_timestamp *proc_timestamp, int tti, uint16_t pa offset = tti*fp->samples_per_subframe; siglen = spsf; } + if (ru->openair0_cfg.nr_flag==1) { // This check if RRU knows about NR numerologies + if (nrfp->N_RB_DL <= 162 && nrfp->N_RB_DL >= 106) factor = 2; + else if (nrfp->N_RB_DL < 106) factor=4; + ts_offset = 64; + } + else { + factor = 30720/spsf; + ts_offset = 256; + } for (i=0; i < ru->nb_rx; i++) rxp[i] = &ru->common.rxdata[i][offset]; int aid; @@ -1352,12 +1371,12 @@ void recv_IF5(RU_t *ru, openair0_timestamp *proc_timestamp, int tti, uint16_t pa &aid); clock_gettime( CLOCK_MONOTONIC, &if_time); timeout[packet_id] = if_time.tv_nsec; - timestamp[packet_id] /= (30720/spsf); - LOG_D(PHY,"TTI %d: Received packet %d: aid %d, TS %llu, oldTS %llu, diff %lld, \n",tti,packet_id,aid,(unsigned long long)timestamp[packet_id],(unsigned long long)oldTS,(unsigned long long)(timestamp[packet_id]-timestamp[0])); + timestamp[packet_id] /= factor; // for LTE this is the sample rate reduction w.r.t 30.72, for NR 122.88 + LOG_D(PHY,"TTI %d: factor = %d Received packet %d: aid %d, TS %llu, oldTS %llu, diff %lld, \n",tti,factor,packet_id,aid,(unsigned long long)timestamp[packet_id],(unsigned long long)oldTS,(unsigned long long)(timestamp[packet_id]-timestamp[0])); if (aid==0) { if (firstTS==1) firstTS=0; - else if (oldTS + 256 != timestamp[packet_id]) { + else if (oldTS + ts_offset != timestamp[packet_id]) { LOG_I(PHY,"oldTS %llu, newTS %llu, diff %llu, timein %lu, timeout %lu\n",(long long unsigned int)oldTS,(long long unsigned int)timestamp[packet_id],(long long unsigned int)timestamp[packet_id]-oldTS,timein[packet_id],timeout[packet_id]); for (int i=0;i<=packet_id;i++) LOG_I(PHY,"packet %d TS %llu, timein %lu, timeout %lu\n",i,(long long unsigned int)timestamp[i],timein[i],timeout[i]); AssertFatal(1==0,"fronthaul problem\n"); @@ -1369,7 +1388,7 @@ void recv_IF5(RU_t *ru, openair0_timestamp *proc_timestamp, int tti, uint16_t pa // HYPOTHESIS: first packet per subframe has lowest timestamp of subframe // should detect out of order and act accordingly .... - AssertFatal(aid==0 || aid==1,"aid %d != 0 or 1\n",aid); + AssertFatal(aid==0 || aid==1 || aid==2 || aid==3,"aid %d != 0,1,2 or 3\n",aid); LOG_D(PHY,"rxp[%d] %p, dest %p, offset %d (%llu,%llu)\n",aid,rxp[aid],rxp[aid]+(timestamp[packet_id]-timestamp[0]),(int)(timestamp[packet_id]-timestamp[0]),(long long unsigned int)timestamp[packet_id],(long long unsigned int)timestamp[0]); memcpy((void*)(rxp[aid]+(timestamp[packet_id]-timestamp[0])), (void*)temp_rx, diff --git a/openair1/PHY/LTE_TRANSPORT/prach.c b/openair1/PHY/LTE_TRANSPORT/prach.c index eb46a8d663..91c419ebe3 100644 --- a/openair1/PHY/LTE_TRANSPORT/prach.c +++ b/openair1/PHY/LTE_TRANSPORT/prach.c @@ -56,7 +56,7 @@ void rx_prach0(PHY_VARS_eNB *eNB, uint8_t ce_level ) { int i; - lte_frame_type_t frame_type; + frame_type_t frame_type; uint16_t rootSequenceIndex; uint8_t prach_ConfigIndex; uint8_t Ncs_config; diff --git a/openair1/PHY/LTE_TRANSPORT/prach_common.c b/openair1/PHY/LTE_TRANSPORT/prach_common.c index e366e8edbc..f3409a90e3 100644 --- a/openair1/PHY/LTE_TRANSPORT/prach_common.c +++ b/openair1/PHY/LTE_TRANSPORT/prach_common.c @@ -399,7 +399,7 @@ void compute_prach_seq(uint16_t rootSequenceIndex, uint8_t prach_ConfigIndex, uint8_t zeroCorrelationZoneConfig, uint8_t highSpeedFlag, - lte_frame_type_t frame_type, + frame_type_t frame_type, uint32_t X_u[64][839]) { // Compute DFT of x_u => X_u[k] = x_u(inv(u)*k)^* X_u[k] = exp(j\pi u*inv(u)*k*(inv(u)*k+1)/N_ZC) unsigned int k,inv_u,i,NCS=0,num_preambles; diff --git a/openair1/PHY/LTE_TRANSPORT/prach_extern.h b/openair1/PHY/LTE_TRANSPORT/prach_extern.h index 3404646923..3403861011 100644 --- a/openair1/PHY/LTE_TRANSPORT/prach_extern.h +++ b/openair1/PHY/LTE_TRANSPORT/prach_extern.h @@ -81,7 +81,7 @@ void compute_prach_seq(uint16_t rootSequenceIndex, uint8_t prach_ConfigIndex, uint8_t zeroCorrelationZoneConfig, uint8_t highSpeedFlag, - lte_frame_type_t frame_type, + frame_type_t frame_type, uint32_t X_u[64][839]); #endif diff --git a/openair1/PHY/LTE_TRANSPORT/pss.c b/openair1/PHY/LTE_TRANSPORT/pss.c index 9ebd841430..ce524ef611 100644 --- a/openair1/PHY/LTE_TRANSPORT/pss.c +++ b/openair1/PHY/LTE_TRANSPORT/pss.c @@ -72,10 +72,6 @@ int generate_pss(int32_t **txdataF, a = (frame_parms->nb_antenna_ports_eNB == 1) ? amp: (amp*ONE_OVER_SQRT2_Q15)>>15; //printf("[PSS] amp=%d, a=%d\n",amp,a); - if (IS_SOFTMODEM_BASICSIM) - /* a hack to remove at some point (the UE doesn't synch with 100 RBs) */ - a = (frame_parms->nb_antenna_ports_eNB == 1) ? 4*amp: (amp*ONE_OVER_SQRT2_Q15)>>15; - Nsymb = (frame_parms->Ncp==NORMAL)?14:12; for (aa=0; aanb_antenna_ports_eNB; aa++) { diff --git a/openair1/PHY/LTE_TRANSPORT/transport_common_proto.h b/openair1/PHY/LTE_TRANSPORT/transport_common_proto.h index af8e63c3ed..57a7b2ec91 100644 --- a/openair1/PHY/LTE_TRANSPORT/transport_common_proto.h +++ b/openair1/PHY/LTE_TRANSPORT/transport_common_proto.h @@ -224,7 +224,7 @@ uint8_t get_num_prach_tdd(module_id_t Mod_id); @returns 0-1 accordingly */ /* -uint8_t get_prach_fmt(uint8_t prach_ConfigIndex,lte_frame_type_t frame_type); +uint8_t get_prach_fmt(uint8_t prach_ConfigIndex,frame_type_t frame_type); */ /*! @@ -247,7 +247,7 @@ void compute_prach_seq(uint16_t rootSequenceIndex, uint8_t prach_ConfigIndex, uint8_t zeroCorrelationZoneConfig, uint8_t highSpeedFlag, - lte_frame_type_t frame_type, + frame_type_t frame_type, uint32_t X_u[64][839]); @@ -299,7 +299,7 @@ uint64_t pmi2hex_2Ar1(uint32_t pmi); uint64_t pmi2hex_2Ar2(uint32_t pmi); -uint8_t get_pmi(uint8_t N_RB_DL,MIMO_mode_t mode, uint32_t pmi_alloc,uint16_t rb); +uint8_t get_pmi(int N_RB_DL,MIMO_mode_t mode, uint32_t pmi_alloc,uint16_t rb); // DL power control functions double get_pa_dB(uint8_t pa); diff --git a/openair1/PHY/LTE_UE_TRANSPORT/dci_tools_ue.c b/openair1/PHY/LTE_UE_TRANSPORT/dci_tools_ue.c index efde277203..088e2c0a5e 100644 --- a/openair1/PHY/LTE_UE_TRANSPORT/dci_tools_ue.c +++ b/openair1/PHY/LTE_UE_TRANSPORT/dci_tools_ue.c @@ -64,7 +64,7 @@ extern uint16_t beta_cqi[16]; extern uint16_t beta_ri[16]; extern uint16_t beta_ack[16]; -void extract_dci1A_info(uint8_t N_RB_DL, lte_frame_type_t frame_type, void *dci_pdu, DCI_INFO_EXTRACTED_t *pdci_info_extarcted) +void extract_dci1A_info(uint8_t N_RB_DL, frame_type_t frame_type, void *dci_pdu, DCI_INFO_EXTRACTED_t *pdci_info_extarcted) { uint8_t harq_pid=0; uint32_t rballoc=0; @@ -182,7 +182,7 @@ void extract_dci1A_info(uint8_t N_RB_DL, lte_frame_type_t frame_type, void *dci_ pdci_info_extarcted->dai = dai; } -void extract_dci1C_info(uint8_t N_RB_DL, lte_frame_type_t frame_type, void *dci_pdu, DCI_INFO_EXTRACTED_t *pdci_info_extarcted) +void extract_dci1C_info(uint8_t N_RB_DL, frame_type_t frame_type, void *dci_pdu, DCI_INFO_EXTRACTED_t *pdci_info_extarcted) { uint32_t rballoc=0; @@ -222,7 +222,7 @@ void extract_dci1C_info(uint8_t N_RB_DL, lte_frame_type_t frame_type, void *dci_ pdci_info_extarcted->Ngap = Ngap; } -void extract_dci1_info(uint8_t N_RB_DL, lte_frame_type_t frame_type, void *dci_pdu, DCI_INFO_EXTRACTED_t *pdci_info_extarcted) +void extract_dci1_info(uint8_t N_RB_DL, frame_type_t frame_type, void *dci_pdu, DCI_INFO_EXTRACTED_t *pdci_info_extarcted) { uint32_t rballoc=0; @@ -329,7 +329,7 @@ void extract_dci1_info(uint8_t N_RB_DL, lte_frame_type_t frame_type, void *dci_p } -void extract_dci2_info(uint8_t N_RB_DL, lte_frame_type_t frame_type, uint8_t nb_antenna_ports_eNB, void *dci_pdu, DCI_INFO_EXTRACTED_t *pdci_info_extarcted) +void extract_dci2_info(uint8_t N_RB_DL, frame_type_t frame_type, uint8_t nb_antenna_ports_eNB, void *dci_pdu, DCI_INFO_EXTRACTED_t *pdci_info_extarcted) { uint32_t rballoc=0; @@ -615,7 +615,7 @@ void extract_dci2_info(uint8_t N_RB_DL, lte_frame_type_t frame_type, uint8_t nb_ } -void extract_dci2A_info(uint8_t N_RB_DL, lte_frame_type_t frame_type, uint8_t nb_antenna_ports_eNB, void *dci_pdu, DCI_INFO_EXTRACTED_t *pdci_info_extarcted) +void extract_dci2A_info(uint8_t N_RB_DL, frame_type_t frame_type, uint8_t nb_antenna_ports_eNB, void *dci_pdu, DCI_INFO_EXTRACTED_t *pdci_info_extarcted) { uint32_t rballoc=0; diff --git a/openair1/PHY/LTE_UE_TRANSPORT/get_pmi.c b/openair1/PHY/LTE_UE_TRANSPORT/get_pmi.c index 7bbe8e8942..6ab2ad9fdd 100644 --- a/openair1/PHY/LTE_UE_TRANSPORT/get_pmi.c +++ b/openair1/PHY/LTE_UE_TRANSPORT/get_pmi.c @@ -21,7 +21,7 @@ #include "PHY/LTE_UE_TRANSPORT/transport_proto_ue.h" -uint8_t get_pmi(uint8_t N_RB_DL, MIMO_mode_t mode, uint32_t pmi_alloc,uint16_t rb) +uint8_t get_pmi(int N_RB_DL, MIMO_mode_t mode, uint32_t pmi_alloc,uint16_t rb) { /* MIMO_mode_t mode = dlsch_harq->mimo_mode; diff --git a/openair1/PHY/LTE_UE_TRANSPORT/initial_sync.c b/openair1/PHY/LTE_UE_TRANSPORT/initial_sync.c index ba904629a1..ff7affe1b3 100644 --- a/openair1/PHY/LTE_UE_TRANSPORT/initial_sync.c +++ b/openair1/PHY/LTE_UE_TRANSPORT/initial_sync.c @@ -557,11 +557,6 @@ int initial_sync(PHY_VARS_UE *ue, runmode_t mode) { ue->measurements.rx_power_avg_dB[0] = dB_fixed(ue->measurements.rx_power_avg[0]); LOG_I(PHY,"[UE%d] Initial sync : Estimated power: %d dB\n",ue->Mod_id,ue->measurements.rx_power_avg_dB[0] ); - if (IS_SOFTMODEM_BASICSIM ) - phy_adjust_gain(ue,ue->measurements.rx_power_avg_dB[0],0); - } else { - if (IS_SOFTMODEM_BASICSIM ) - phy_adjust_gain(ue,dB_fixed(ue->measurements.rssi),0); } return ret; diff --git a/openair1/PHY/LTE_UE_TRANSPORT/prach_ue.c b/openair1/PHY/LTE_UE_TRANSPORT/prach_ue.c index 929f63e9fc..4faa8367c3 100644 --- a/openair1/PHY/LTE_UE_TRANSPORT/prach_ue.c +++ b/openair1/PHY/LTE_UE_TRANSPORT/prach_ue.c @@ -46,7 +46,7 @@ //#define PRACH_DEBUG 1 int32_t generate_prach( PHY_VARS_UE *ue, uint8_t eNB_id, uint8_t subframe, uint16_t Nf ) { - lte_frame_type_t frame_type = ue->frame_parms.frame_type; + frame_type_t frame_type = ue->frame_parms.frame_type; //uint8_t tdd_config = ue->frame_parms.tdd_config; uint16_t rootSequenceIndex = ue->frame_parms.prach_config_common.rootSequenceIndex; uint8_t prach_ConfigIndex = ue->frame_parms.prach_config_common.prach_ConfigInfo.prach_ConfigIndex; @@ -81,29 +81,20 @@ int32_t generate_prach( PHY_VARS_UE *ue, uint8_t eNB_id, uint8_t subframe, uint1 int i, prach_len; uint16_t first_nonzero_root_idx=0; - if ( !(IS_SOFTMODEM_BASICSIM ) ) { - prach_start = (ue->rx_offset+subframe*ue->frame_parms.samples_per_tti-ue->hw_timing_advance-ue->N_TA_offset); + prach_start = (ue->rx_offset+subframe*ue->frame_parms.samples_per_tti-ue->hw_timing_advance-ue->N_TA_offset); #ifdef PRACH_DEBUG - LOG_I(PHY,"[UE %d] prach_start %d, rx_offset %d, hw_timing_advance %d, N_TA_offset %d\n", ue->Mod_id, - prach_start, - ue->rx_offset, - ue->hw_timing_advance, - ue->N_TA_offset); + LOG_I(PHY,"[UE %d] prach_start %d, rx_offset %d, hw_timing_advance %d, N_TA_offset %d\n", ue->Mod_id, + prach_start, + ue->rx_offset, + ue->hw_timing_advance, + ue->N_TA_offset); #endif - if (prach_start<0) - prach_start+=(ue->frame_parms.samples_per_tti*LTE_NUMBER_OF_SUBFRAMES_PER_FRAME); + if (prach_start<0) + prach_start+=(ue->frame_parms.samples_per_tti*LTE_NUMBER_OF_SUBFRAMES_PER_FRAME); - if (prach_start>=(ue->frame_parms.samples_per_tti*LTE_NUMBER_OF_SUBFRAMES_PER_FRAME)) - prach_start-=(ue->frame_parms.samples_per_tti*LTE_NUMBER_OF_SUBFRAMES_PER_FRAME); - } else { //normal case (simulation) - prach_start = subframe*ue->frame_parms.samples_per_tti-ue->N_TA_offset; - LOG_I(PHY,"[UE %d] prach_start %d, rx_offset %d, hw_timing_advance %d, N_TA_offset %d\n", ue->Mod_id, - prach_start, - ue->rx_offset, - ue->hw_timing_advance, - ue->N_TA_offset); - } + if (prach_start>=(ue->frame_parms.samples_per_tti*LTE_NUMBER_OF_SUBFRAMES_PER_FRAME)) + prach_start-=(ue->frame_parms.samples_per_tti*LTE_NUMBER_OF_SUBFRAMES_PER_FRAME); // First compute physical root sequence if (restricted_set == 0) { @@ -476,40 +467,32 @@ int32_t generate_prach( PHY_VARS_UE *ue, uint8_t eNB_id, uint8_t subframe, uint1 AssertFatal(prach_fmt<4, "prach_fmt4 not fully implemented" ); - if (!(IS_SOFTMODEM_BASICSIM ) ) { - int j; - int overflow = prach_start + prach_len - LTE_NUMBER_OF_SUBFRAMES_PER_FRAME*ue->frame_parms.samples_per_tti; - LOG_I( PHY, "prach_start=%d, overflow=%d\n", prach_start, overflow ); + int j; + int overflow = prach_start + prach_len - LTE_NUMBER_OF_SUBFRAMES_PER_FRAME*ue->frame_parms.samples_per_tti; + LOG_I( PHY, "prach_start=%d, overflow=%d\n", prach_start, overflow ); - for (i=prach_start,j=0; iframe_parms.samples_per_tti*LTE_NUMBER_OF_SUBFRAMES_PER_FRAME,prach_start+prach_len); i++,j++) { - ((int16_t *)ue->common_vars.txdata[0])[2*i] = prach[2*j]; - ((int16_t *)ue->common_vars.txdata[0])[2*i+1] = prach[2*j+1]; - } + for (i=prach_start,j=0; iframe_parms.samples_per_tti*LTE_NUMBER_OF_SUBFRAMES_PER_FRAME,prach_start+prach_len); i++,j++) { + ((int16_t *)ue->common_vars.txdata[0])[2*i] = prach[2*j]; + ((int16_t *)ue->common_vars.txdata[0])[2*i+1] = prach[2*j+1]; + } - for (i=0; icommon_vars.txdata[0])[2*i] = prach[2*j]; - ((int16_t *)ue->common_vars.txdata[0])[2*i+1] = prach[2*j+1]; - } + for (i=0; icommon_vars.txdata[0])[2*i] = prach[2*j]; + ((int16_t *)ue->common_vars.txdata[0])[2*i+1] = prach[2*j+1]; + } #if defined(EXMIMO) - // handle switch before 1st TX subframe, guarantee that the slot prior to transmission is switch on - for (k=prach_start - (ue->frame_parms.samples_per_tti>>1) ; kcommon_vars.txdata[0][k+ue->frame_parms.samples_per_tti*LTE_NUMBER_OF_SUBFRAMES_PER_FRAME] &= 0xFFFEFFFE; - else if (k>(ue->frame_parms.samples_per_tti*LTE_NUMBER_OF_SUBFRAMES_PER_FRAME)) - ue->common_vars.txdata[0][k-ue->frame_parms.samples_per_tti*LTE_NUMBER_OF_SUBFRAMES_PER_FRAME] &= 0xFFFEFFFE; - else - ue->common_vars.txdata[0][k] &= 0xFFFEFFFE; - } - -#endif - } else { // simulators - for (i=0; icommon_vars.txdata[0][prach_start]))[2*i] = prach[2*i]; - ((int16_t *)(&ue->common_vars.txdata[0][prach_start]))[2*i+1] = prach[2*i+1]; - } + // handle switch before 1st TX subframe, guarantee that the slot prior to transmission is switch on + for (k=prach_start - (ue->frame_parms.samples_per_tti>>1) ; kcommon_vars.txdata[0][k+ue->frame_parms.samples_per_tti*LTE_NUMBER_OF_SUBFRAMES_PER_FRAME] &= 0xFFFEFFFE; + else if (k>(ue->frame_parms.samples_per_tti*LTE_NUMBER_OF_SUBFRAMES_PER_FRAME)) + ue->common_vars.txdata[0][k-ue->frame_parms.samples_per_tti*LTE_NUMBER_OF_SUBFRAMES_PER_FRAME] &= 0xFFFEFFFE; + else + ue->common_vars.txdata[0][k] &= 0xFFFEFFFE; } +#endif #if defined(PRACH_WRITE_OUTPUT_DEBUG) LOG_M("prach_txF0.m","prachtxF0",prachF,prach_len-Ncp,1,1); diff --git a/openair1/PHY/LTE_UE_TRANSPORT/transport_proto_ue.h b/openair1/PHY/LTE_UE_TRANSPORT/transport_proto_ue.h index c5d096ceb7..f5b8c6b64a 100644 --- a/openair1/PHY/LTE_UE_TRANSPORT/transport_proto_ue.h +++ b/openair1/PHY/LTE_UE_TRANSPORT/transport_proto_ue.h @@ -1550,16 +1550,6 @@ uint64_t cqi2hex(uint32_t cqi); uint16_t computeRIV(uint16_t N_RB_DL,uint16_t RBstart,uint16_t Lcrbs); - -/** \brief This routine extracts a single subband PMI from a bitmap coming from UCI or the pmi_extend function - @param N_RB_DL number of resource blocks - @param mimo_mode - @param pmi_alloc subband PMI bitmap - @param rb resource block for which to extract PMI - @returns subband PMI -*/ -uint8_t get_pmi(uint8_t N_RB_DL,MIMO_mode_t mode, uint32_t pmi_alloc,uint16_t rb); - int get_nCCE_offset_l1(int *CCE_table, const unsigned char L, const int nCCE, @@ -1669,7 +1659,7 @@ uint8_t get_num_prach_tdd(module_id_t Mod_id); @param frame_type 0-FDD, 1-TDD @returns 0-1 accordingly */ -uint8_t get_prach_fmt(uint8_t prach_ConfigIndex,lte_frame_type_t frame_type); +uint8_t get_prach_fmt(uint8_t prach_ConfigIndex,frame_type_t frame_type); /*! \brief Helper for MAC, returns frequency index of PRACH resource in TDD for a particular configuration index @@ -1691,7 +1681,7 @@ void compute_prach_seq(uint16_t rootSequenceIndex, uint8_t prach_ConfigIndex, uint8_t zeroCorrelationZoneConfig, uint8_t highSpeedFlag, - lte_frame_type_t frame_type, + frame_type_t frame_type, uint32_t X_u[64][839]); diff --git a/openair1/PHY/LTE_UE_TRANSPORT/transport_ue.h b/openair1/PHY/LTE_UE_TRANSPORT/transport_ue.h index 6b84a5f969..b4ae44f6ea 100644 --- a/openair1/PHY/LTE_UE_TRANSPORT/transport_ue.h +++ b/openair1/PHY/LTE_UE_TRANSPORT/transport_ue.h @@ -155,8 +155,6 @@ typedef struct { uint8_t h[MAX_NUM_CHANNEL_BITS]; /// Scrambled "b"-sequences (for definition see 36-211 V8.6 2009-03, p.14) uint8_t b_tilde[MAX_NUM_CHANNEL_BITS]; - /// Modulated "d"-sequences (for definition see 36-211 V8.6 2009-03, p.14) - int32_t d[MAX_NUM_RE]; /// Transform-coded "z"-sequences (for definition see 36-211 V8.6 2009-03, p.14-15) int32_t z[MAX_NUM_RE]; /// "q" sequences for CQI/PMI (for definition see 36-212 V8.6 2009-03, p.27) diff --git a/openair1/PHY/LTE_UE_TRANSPORT/ulsch_modulation.c b/openair1/PHY/LTE_UE_TRANSPORT/ulsch_modulation.c index 7ec3e7bfb6..6a663e8940 100644 --- a/openair1/PHY/LTE_UE_TRANSPORT/ulsch_modulation.c +++ b/openair1/PHY/LTE_UE_TRANSPORT/ulsch_modulation.c @@ -42,7 +42,7 @@ //#define DEBUG_ULSCH_MODULATION -void dft_lte(int32_t *z,int32_t *d, int32_t Msc_PUSCH, uint8_t Nsymb) +void dft_lte(int32_t *z,struct complex16 *input, int32_t Msc_PUSCH, uint8_t Nsymb) { #if defined(__x86_64__) || defined(__i386__) @@ -66,7 +66,7 @@ void dft_lte(int32_t *z,int32_t *d, int32_t Msc_PUSCH, uint8_t Nsymb) #endif // printf("Doing lte_dft for Msc_PUSCH %d\n",Msc_PUSCH); - d0 = (uint32_t *)d; + d0 = (uint32_t *)input; d1 = d0+Msc_PUSCH; d2 = d1+Msc_PUSCH; d3 = d2+Msc_PUSCH; @@ -476,7 +476,8 @@ void ulsch_modulation(int32_t **txdataF, // Modulation ulsch_Msymb = G/Q_m; - + /// Modulated "d"-sequences (for definition see 36-211 V8.6 2009-03, p.14) + struct complex16 d[MAX_NUM_RE] __attribute__((aligned(32))); if(ulsch->cooperation_flag == 2) // For Distributed Alamouti Scheme in Collabrative Communication { @@ -488,14 +489,14 @@ void ulsch_modulation(int32_t **txdataF, //UE1, -x1* - ((int16_t*)&ulsch->d[i])[0] = (ulsch->b_tilde[j] == 1) ? (gain_lin_QPSK) : -gain_lin_QPSK; - ((int16_t*)&ulsch->d[i])[1] = (ulsch->b_tilde[j+1] == 1)? (-gain_lin_QPSK) : gain_lin_QPSK; + d[i].r = (ulsch->b_tilde[j] == 1) ? (gain_lin_QPSK) : -gain_lin_QPSK; + d[i].i = (ulsch->b_tilde[j+1] == 1)? (-gain_lin_QPSK) : gain_lin_QPSK; // if (id[i],((int16_t*)&ulsch->d[i])[0],((int16_t*)&ulsch->d[i])[1]); // UE1, x0* - ((int16_t*)&ulsch->d[i+1])[0] = (ulsch->b_tilde[j-2] == 1) ? (-gain_lin_QPSK) : gain_lin_QPSK; - ((int16_t*)&ulsch->d[i+1])[1] = (ulsch->b_tilde[j-1] == 1)? (gain_lin_QPSK) : -gain_lin_QPSK; + d[i+1].r = (ulsch->b_tilde[j-2] == 1) ? (-gain_lin_QPSK) : gain_lin_QPSK; + d[i+1].i = (ulsch->b_tilde[j-1] == 1)? (gain_lin_QPSK) : -gain_lin_QPSK; break; @@ -521,8 +522,8 @@ void ulsch_modulation(int32_t **txdataF, qam16_table_offset_im+=1; - ((int16_t*)&ulsch->d[i])[0]=-(int16_t)(((int32_t)amp*qam16_table[qam16_table_offset_re])>>15); - ((int16_t*)&ulsch->d[i])[1]=(int16_t)(((int32_t)amp*qam16_table[qam16_table_offset_im])>>15); + d[i].r =-(int16_t)(((int32_t)amp*qam16_table[qam16_table_offset_re])>>15); + d[i].i =(int16_t)(((int32_t)amp*qam16_table[qam16_table_offset_im])>>15); //UE1,x0* qam16_table_offset_re = 0; @@ -544,8 +545,8 @@ void ulsch_modulation(int32_t **txdataF, // ((int16_t*)&ulsch->d[i+1])[0]=-(int16_t)(((int32_t)amp*qam16_table[qam16_table_offset_re])>>15); // ((int16_t*)&ulsch->d[i+1])[1]=(int16_t)(((int32_t)amp*qam16_table[qam16_table_offset_im])>>15); - ((int16_t*)&ulsch->d[i+1])[0]=(int16_t)(((int32_t)amp*qam16_table[qam16_table_offset_re])>>15); - ((int16_t*)&ulsch->d[i+1])[1]=-(int16_t)(((int32_t)amp*qam16_table[qam16_table_offset_im])>>15); + d[i+1].r=(int16_t)(((int32_t)amp*qam16_table[qam16_table_offset_re])>>15); + d[i+1].i=-(int16_t)(((int32_t)amp*qam16_table[qam16_table_offset_im])>>15); break; @@ -578,8 +579,8 @@ void ulsch_modulation(int32_t **txdataF, qam64_table_offset_im+=1; - ((int16_t*)&ulsch->d[i])[0]=-(int16_t)(((int32_t)amp*qam64_table[qam64_table_offset_re])>>15); - ((int16_t*)&ulsch->d[i])[1]=(int16_t)(((int32_t)amp*qam64_table[qam64_table_offset_im])>>15); + d[i].r=-(int16_t)(((int32_t)amp*qam64_table[qam64_table_offset_re])>>15); + d[i].i=(int16_t)(((int32_t)amp*qam64_table[qam64_table_offset_im])>>15); //UE1,x0* qam64_table_offset_re = 0; @@ -605,8 +606,8 @@ void ulsch_modulation(int32_t **txdataF, qam64_table_offset_im+=1; - ((int16_t*)&ulsch->d[i+1])[0]=(int16_t)(((int32_t)amp*qam64_table[qam64_table_offset_re])>>15); - ((int16_t*)&ulsch->d[i+1])[1]=-(int16_t)(((int32_t)amp*qam64_table[qam64_table_offset_im])>>15); + d[i+1].r=(int16_t)(((int32_t)amp*qam64_table[qam64_table_offset_re])>>15); + d[i+1].i=-(int16_t)(((int32_t)amp*qam64_table[qam64_table_offset_im])>>15); break; @@ -621,8 +622,8 @@ void ulsch_modulation(int32_t **txdataF, case 2: // TODO: this has to be updated!!! - ((int16_t*)&ulsch->d[i])[0] = (ulsch->b_tilde[j] == 1) ? (-gain_lin_QPSK) : gain_lin_QPSK; - ((int16_t*)&ulsch->d[i])[1] = (ulsch->b_tilde[j+1] == 1)? (-gain_lin_QPSK) : gain_lin_QPSK; + d[i].r = (ulsch->b_tilde[j] == 1) ? (-gain_lin_QPSK) : gain_lin_QPSK; + d[i].i = (ulsch->b_tilde[j+1] == 1)? (-gain_lin_QPSK) : gain_lin_QPSK; // if (id[i],((int16_t*)&ulsch->d[i])[0],((int16_t*)&ulsch->d[i])[1]); @@ -646,8 +647,8 @@ void ulsch_modulation(int32_t **txdataF, qam16_table_offset_im+=1; - ((int16_t*)&ulsch->d[i])[0]=(int16_t)(((int32_t)amp*qam16_table[qam16_table_offset_re])>>15); - ((int16_t*)&ulsch->d[i])[1]=(int16_t)(((int32_t)amp*qam16_table[qam16_table_offset_im])>>15); + d[i].r=(int16_t)(((int32_t)amp*qam16_table[qam16_table_offset_re])>>15); + d[i].i=(int16_t)(((int32_t)amp*qam16_table[qam16_table_offset_im])>>15); // printf("input(16qam) %d (%p): %d,%d\n", i,&ulsch->d[i],((int16_t*)&ulsch->d[i])[0],((int16_t*)&ulsch->d[i])[1]); break; @@ -676,8 +677,8 @@ void ulsch_modulation(int32_t **txdataF, qam64_table_offset_im+=1; - ((int16_t*)&ulsch->d[i])[0]=(int16_t)(((int32_t)amp*qam64_table[qam64_table_offset_re])>>15); - ((int16_t*)&ulsch->d[i])[1]=(int16_t)(((int32_t)amp*qam64_table[qam64_table_offset_im])>>15); + d[i].r=(int16_t)(((int32_t)amp*qam64_table[qam64_table_offset_re])>>15); + d[i].i=(int16_t)(((int32_t)amp*qam64_table[qam64_table_offset_im])>>15); break; @@ -688,7 +689,7 @@ void ulsch_modulation(int32_t **txdataF, // Transform Precoding - dft_lte(ulsch->z,ulsch->d,Msc_PUSCH,ulsch->Nsymb_pusch); + dft_lte(ulsch->z,d,Msc_PUSCH,ulsch->Nsymb_pusch); DevAssert(txdataF); diff --git a/openair1/PHY/MODULATION/nr_modulation.c b/openair1/PHY/MODULATION/nr_modulation.c index c81a88ff30..8352a7f5a6 100644 --- a/openair1/PHY/MODULATION/nr_modulation.c +++ b/openair1/PHY/MODULATION/nr_modulation.c @@ -320,98 +320,16 @@ void nr_layer_mapping(int16_t **mod_symbs, } } -void nr_ue_layer_mapping(NR_UE_ULSCH_t **ulsch_ue, +void nr_ue_layer_mapping(int16_t *mod_symbs, uint8_t n_layers, uint16_t n_symbs, - int16_t **tx_layers) -{ - int16_t *mod_symbs; + int16_t **tx_layers) { - switch (n_layers) { - - case 1: - mod_symbs = (int16_t *)ulsch_ue[0]->d_mod; - for (int i=0; i>15; - tx_layers[0][(i<<1)+1] = (mod_symbs[(i<<1)+1]*AMP)>>15; - } - break; - - case 2: - case 3: - case 4: - mod_symbs = (int16_t *)ulsch_ue[0]->d_mod; - - for (int i=0; i>15; - tx_layers[l][(i<<1)+1] = (mod_symbs[((n_layers*i+l)<<1)+1]*AMP)>>15; - } - } - break; - - case 5: - mod_symbs = (int16_t *)ulsch_ue[0]->d_mod; - - for (int i=0; i>1; i++) - for (int l=0; l<2; l++) { - tx_layers[l][i<<1] = (mod_symbs[((i<<1)+l)<<1]*AMP)>>15; - tx_layers[l][(i<<1)+1] = (mod_symbs[(((i<<1)+l)<<1)+1]*AMP)>>15; - } - - mod_symbs = (int16_t *)ulsch_ue[1]->d_mod; - - for (int i=0; i>15; - tx_layers[l][(i<<1)+1] = (mod_symbs[((3*i+l)<<1)+1]*AMP)>>15; - } - break; - - case 6: - for (int q=0; q<2; q++) { - mod_symbs = (int16_t *)ulsch_ue[q]->d_mod; - - for (int i=0; i>15; - tx_layers[l][(i<<1)+1] = (mod_symbs[((3*i+l)<<1)+1]*AMP)>>15; - } - } - break; - - case 7: - mod_symbs = (int16_t *)ulsch_ue[1]->d_mod; - - for (int i=0; i>15; - tx_layers[l][(i<<1)+1] = (mod_symbs[((3*i+l)<<1)+1]*AMP)>>15; - } - - mod_symbs = (int16_t *)ulsch_ue[0]->d_mod; - - for (int i=0; i>15; - tx_layers[l][(i<<1)+1] = (mod_symbs[(((i<<2)+l)<<1)+1]*AMP)>>15; - } - break; - - case 8: - for (int q=0; q<2; q++) { - mod_symbs = (int16_t *)ulsch_ue[q]->d_mod; - - for (int i=0; i>2; i++) - for (int l=0; l<3; l++) { - tx_layers[l][i<<1] = (mod_symbs[((i<<2)+l)<<1]*AMP)>>15; - tx_layers[l][(i<<1)+1] = (mod_symbs[(((i<<2)+l)<<1)+1]*AMP)>>15; - } - } - break; - - default: - AssertFatal(0, "Invalid number of layers %d\n", n_layers); + for (int i=0; i>15; + tx_layers[l][(i<<1)+1] = (mod_symbs[((n_layers*i+l)<<1)+1]*AMP)>>15; + } } } @@ -747,8 +665,9 @@ void init_symbol_rotation(NR_DL_FRAME_PARMS *fp) { void init_timeshift_rotation(NR_DL_FRAME_PARMS *fp) { + const int sample_offset = fp->nb_prefix_samples / fp->ofdm_offset_divisor; for (int i = 0; i < fp->ofdm_symbol_size; i++) { - double poff = -i * 2.0 * M_PI * 144.0 / 2048.0 / fp->ofdm_offset_divisor; + double poff = -i * 2.0 * M_PI * sample_offset / fp->ofdm_symbol_size; double exp_re = cos(poff); double exp_im = sin(-poff); fp->timeshift_symbol_rotation[i*2] = (int16_t)round(exp_re * 32767); @@ -801,3 +720,18 @@ int nr_layer_precoder(int16_t **datatx_F_precoding, char *prec_matrix, uint8_t n /* ((int16_t *)precodatatx_F)[0] = (int16_t)((((int16_t *)precodatatx_F)[0]*ONE_OVER_SQRT2_Q15)>>15); ((int16_t *)precodatatx_F)[1] = (int16_t)((((int16_t *)precodatatx_F)[1]*ONE_OVER_SQRT2_Q15)>>15);*/ } + +int nr_layer_precoder_cm(int16_t **datatx_F_precoding, int *prec_matrix, uint8_t n_layers, int32_t re_offset) +{ + int32_t precodatatx_F = 0; + for (int al = 0; al>15); + ((int16_t *) &precodatatx_F)[1] += (int16_t)(((int32_t)(antenna_re*(((int16_t *)&prec_matrix[al])[1])) + (int32_t)(antenna_im* (((int16_t *)&prec_matrix[al])[0])))>>15); + } + + return precodatatx_F; +} + diff --git a/openair1/PHY/MODULATION/nr_modulation.h b/openair1/PHY/MODULATION/nr_modulation.h index 75541a1361..65f147fffa 100644 --- a/openair1/PHY/MODULATION/nr_modulation.h +++ b/openair1/PHY/MODULATION/nr_modulation.h @@ -66,7 +66,7 @@ void nr_layer_mapping(int16_t **mod_symbs, @param[out] tx_layers, modulated symbols for each layer */ -void nr_ue_layer_mapping(NR_UE_ULSCH_t **ulsch_ue, +void nr_ue_layer_mapping(int16_t *mod_symbs, uint8_t n_layers, uint16_t n_symbs, int16_t **tx_layers); @@ -135,4 +135,9 @@ int nr_layer_precoder(int16_t **datatx_F_precoding, char *prec_matrix, uint8_t n_layers, int32_t re_offset); + +int nr_layer_precoder_cm(int16_t **datatx_F_precoding, + int *prec_matrix, + uint8_t n_layers, + int32_t re_offset); #endif diff --git a/openair1/PHY/MODULATION/slot_fep.c b/openair1/PHY/MODULATION/slot_fep.c index 8f41735f10..b2c7d934c6 100644 --- a/openair1/PHY/MODULATION/slot_fep.c +++ b/openair1/PHY/MODULATION/slot_fep.c @@ -91,7 +91,7 @@ int slot_fep(PHY_VARS_UE *ue, } // subframe_offset_F = frame_parms->ofdm_symbol_size * frame_parms->symbols_per_tti * (Ns>>1); - + if (l<0 || l>=7-frame_parms->Ncp) { printf("slot_fep: l must be between 0 and %d\n",7-frame_parms->Ncp); return(-1); diff --git a/openair1/PHY/MODULATION/slot_fep_nr.c b/openair1/PHY/MODULATION/slot_fep_nr.c index eb26dfc02b..139b730ce1 100644 --- a/openair1/PHY/MODULATION/slot_fep_nr.c +++ b/openair1/PHY/MODULATION/slot_fep_nr.c @@ -34,47 +34,6 @@ #define LOG_I(A,B...) printf(A) #endif*/ -dft_size_idx_t get_dft_size_idx(uint16_t ofdm_symbol_size) -{ - switch (ofdm_symbol_size) { - case 128: - return DFT_128; - - case 256: - return DFT_256; - - case 512: - return DFT_512; - - case 1024: - return DFT_1024; - - case 1536: - return DFT_1536; - - case 2048: - return DFT_2048; - - case 3072: - return DFT_3072; - - case 4096: - return DFT_4096; - - case 6144: - return DFT_6144; - - case 8192: - return DFT_8192; - - default: - printf("unsupported ofdm symbol size \n"); - assert(0); - } - - return DFT_SIZE_IDXTABLESIZE; -} - int nr_slot_fep(PHY_VARS_NR_UE *ue, UE_nr_rxtx_proc_t *proc, unsigned char symbol, @@ -96,7 +55,7 @@ int nr_slot_fep(PHY_VARS_NR_UE *ue, nb_prefix_samples0 = frame_parms->nb_prefix_samples; } - dft_size_idx_t dftsize = get_dft_size_idx(frame_parms->ofdm_symbol_size); + dft_size_idx_t dftsize = get_dft(frame_parms->ofdm_symbol_size); // This is for misalignment issues int32_t tmp_dft_in[8192] __attribute__ ((aligned (32))); @@ -195,7 +154,7 @@ int nr_slot_fep_init_sync(PHY_VARS_NR_UE *ue, } unsigned int frame_length_samples = frame_parms->samples_per_frame; - dft_size_idx_t dftsize = get_dft_size_idx(frame_parms->ofdm_symbol_size); + dft_size_idx_t dftsize = get_dft(frame_parms->ofdm_symbol_size); // This is for misalignment issues int32_t tmp_dft_in[8192] __attribute__ ((aligned (32))); @@ -289,7 +248,7 @@ int nr_slot_fep_ul(NR_DL_FRAME_PARMS *frame_parms, unsigned int nb_prefix_samples = frame_parms->nb_prefix_samples; unsigned int nb_prefix_samples0 = frame_parms->nb_prefix_samples0; - dft_size_idx_t dftsize = get_dft_size_idx(frame_parms->ofdm_symbol_size); + dft_size_idx_t dftsize = get_dft(frame_parms->ofdm_symbol_size); // This is for misalignment issues int32_t tmp_dft_in[8192] __attribute__ ((aligned (32))); diff --git a/openair1/PHY/NR_ESTIMATION/nr_measurements_gNB.c b/openair1/PHY/NR_ESTIMATION/nr_measurements_gNB.c index cfb5a2e56e..fb56322e54 100644 --- a/openair1/PHY/NR_ESTIMATION/nr_measurements_gNB.c +++ b/openair1/PHY/NR_ESTIMATION/nr_measurements_gNB.c @@ -107,25 +107,24 @@ void gNB_I0_measurements(PHY_VARS_gNB *gNB,int slot, int first_symb,int num_symb NR_DL_FRAME_PARMS *frame_parms = &gNB->frame_parms; NR_gNB_COMMON *common_vars = &gNB->common_vars; PHY_MEASUREMENTS_gNB *measurements = &gNB->measurements; - int rb, offset, offset0, nb_symb[275], len; - int32_t *ul_ch; - - LOG_D(PHY,"slot %d Doing I0 for first_symb %d, num_symb %d\n",slot,first_symb,num_symb); + int rb, nb_symb[275]={0}; + + memset(measurements->n0_subband_power, 0, sizeof(measurements->n0_subband_power)); + for (int s=first_symb;s<(first_symb+num_symb);s++) { for (rb=0; rbN_RB_UL; rb++) { - - if (s==first_symb) { + if (s==first_symb /*&& ((gNB->rb_mask_ul[s][rb>>5]&(1<<(rb&31))) == 0)*/) { nb_symb[rb]=0; for (int aarx=0; aarxnb_antennas_rx;aarx++) measurements->n0_subband_power[aarx][rb]=0; } - offset0 = (slot&3)*(frame_parms->symbols_per_slot * frame_parms->ofdm_symbol_size) + (frame_parms->first_carrier_offset + (rb*12))%frame_parms->ofdm_symbol_size; + int offset0 = (slot&3)*(frame_parms->symbols_per_slot * frame_parms->ofdm_symbol_size) + (frame_parms->first_carrier_offset + (rb*12))%frame_parms->ofdm_symbol_size; if ((gNB->rb_mask_ul[s][rb>>5]&(1<<(rb&31))) == 0) { // check that rb was not used in this subframe nb_symb[rb]++; for (int aarx=0; aarxnb_antennas_rx; aarx++) { - offset = offset0 + (s*frame_parms->ofdm_symbol_size); - ul_ch = &common_vars->rxdataF[aarx][offset]; - len = 12; + int offset = offset0 + (s*frame_parms->ofdm_symbol_size); + int32_t *ul_ch = &common_vars->rxdataF[aarx][offset]; + int len = 12; if (((frame_parms->N_RB_UL&1) == 1) && (rb==(frame_parms->N_RB_UL>>1))) { len=6; @@ -184,7 +183,7 @@ void nr_gnb_measurements(PHY_VARS_gNB *gNB, uint8_t ulsch_id, unsigned char harq PHY_MEASUREMENTS_gNB *meas = &gNB->measurements; NR_DL_FRAME_PARMS *fp = &gNB->frame_parms; int ch_offset = fp->ofdm_symbol_size * symbol; - int N_RB_UL = gNB->ulsch[ulsch_id][0]->harq_processes[harq_pid]->ulsch_pdu.rb_size; + int N_RB_UL = gNB->ulsch[ulsch_id]->harq_processes[harq_pid]->ulsch_pdu.rb_size; rx_power_tot[ulsch_id] = 0; diff --git a/openair1/PHY/NR_ESTIMATION/nr_ul_channel_estimation.c b/openair1/PHY/NR_ESTIMATION/nr_ul_channel_estimation.c index 9aaba7fb66..cd3b535b3f 100644 --- a/openair1/PHY/NR_ESTIMATION/nr_ul_channel_estimation.c +++ b/openair1/PHY/NR_ESTIMATION/nr_ul_channel_estimation.c @@ -86,12 +86,13 @@ int nr_pusch_channel_estimation(PHY_VARS_gNB *gNB, int pilot[3280] __attribute__((aligned(16))); unsigned char aarx; - unsigned short k; + unsigned short k0; unsigned int pilot_cnt,re_cnt; int16_t ch[2],ch_r[2],ch_l[2],*pil,*rxF,*ul_ch; int16_t *fl,*fm,*fr,*fml,*fmr,*fmm,*fdcl,*fdcr,*fdclh,*fdcrh; int ch_offset,symbol_offset ; int32_t **ul_ch_estimates_time = gNB->pusch_vars[ul_id]->ul_ch_estimates_time; + int chest_freq = gNB->chest_freq; __m128i *ul_ch_128; #ifdef DEBUG_CH @@ -112,18 +113,18 @@ int nr_pusch_channel_estimation(PHY_VARS_gNB *gNB, symbol_offset = gNB->frame_parms.ofdm_symbol_size*symbol; - k = bwp_start_subcarrier; + k0 = bwp_start_subcarrier; int re_offset; uint16_t nb_rb_pusch = pusch_pdu->rb_size; - LOG_D(PHY, "In %s: ch_offset %d, soffset %d, symbol_offset %d OFDM size %d, Ns = %d, k = %d symbol %d\n", + LOG_D(PHY, "In %s: ch_offset %d, soffset %d, symbol_offset %d, OFDM size %d, Ns = %d, k0 = %d, symbol %d\n", __FUNCTION__, ch_offset, soffset, symbol_offset, gNB->frame_parms.ofdm_symbol_size, Ns, - k, + k0, symbol); switch (nushift) { @@ -146,7 +147,7 @@ int nr_pusch_channel_estimation(PHY_VARS_gNB *gNB, fr = filt8_r1; fmm = filt8_mm1; fml = filt8_ml1; - fmr = filt8_m1; + fmr = filt8_mm1; fdcl = filt8_dcl1; fdcr = filt8_dcr1; fdclh = filt8_dcl1_h; @@ -165,9 +166,12 @@ int nr_pusch_channel_estimation(PHY_VARS_gNB *gNB, //------------------generate DMRS------------------// - // transform precoding = 1 means disabled - if (pusch_pdu->transform_precoding == 1) { - nr_pusch_dmrs_rx(gNB, Ns, gNB->nr_gold_pusch_dmrs[pusch_pdu->scid][Ns][symbol], &pilot[0], 1000, 0, nb_rb_pusch, + if(pusch_pdu->ul_dmrs_scrambling_id != gNB->pusch_gold_init[pusch_pdu->scid]) { + gNB->pusch_gold_init[pusch_pdu->scid] = pusch_pdu->ul_dmrs_scrambling_id; + nr_gold_pusch(gNB, pusch_pdu->scid, pusch_pdu->ul_dmrs_scrambling_id); + } + if (pusch_pdu->transform_precoding == transformPrecoder_disabled) { + nr_pusch_dmrs_rx(gNB, Ns, gNB->nr_gold_pusch_dmrs[pusch_pdu->scid][Ns][symbol], &pilot[0], (1000+p), 0, nb_rb_pusch, (pusch_pdu->bwp_start + pusch_pdu->rb_start)*NR_NB_SC_PER_RB, pusch_pdu->dmrs_config_type); } else { // if transform precoding or SC-FDMA is enabled in Uplink @@ -203,214 +207,81 @@ int nr_pusch_channel_estimation(PHY_VARS_gNB *gNB, } #endif + uint8_t b_shift = pusch_pdu->nrOfLayers == 1; + for (aarx=0; aarxframe_parms.nb_antennas_rx; aarx++) { - re_offset = k; /* Initializing the Resource element offset for each Rx antenna */ - pil = (int16_t *)&pilot[0]; - rxF = (int16_t *)&rxdataF[aarx][(soffset+symbol_offset+k+nushift)]; + rxF = (int16_t *)&rxdataF[aarx][(soffset + symbol_offset + k0 + nushift)]; ul_ch = (int16_t *)&ul_ch_estimates[p*gNB->frame_parms.nb_antennas_rx+aarx][ch_offset]; - re_offset = k; + re_offset = k0; memset(ul_ch,0,4*(gNB->frame_parms.ofdm_symbol_size)); #ifdef DEBUG_PUSCH LOG_I(PHY, "In %s symbol_offset %d, nushift %d\n", __FUNCTION__, symbol_offset, nushift); LOG_I(PHY, "In %s ch est pilot addr %p, N_RB_UL %d\n", __FUNCTION__, &pilot[0], gNB->frame_parms.N_RB_UL); - LOG_I(PHY, "In %s bwp_start_subcarrier %d, k %d, first_carrier %d, nb_rb_pusch %d\n", __FUNCTION__, bwp_start_subcarrier, k, gNB->frame_parms.first_carrier_offset, nb_rb_pusch); + LOG_I(PHY, "In %s bwp_start_subcarrier %d, k0 %d, first_carrier %d, nb_rb_pusch %d\n", __FUNCTION__, bwp_start_subcarrier, k0, gNB->frame_parms.first_carrier_offset, nb_rb_pusch); LOG_I(PHY, "In %s rxF addr %p p %d\n", __FUNCTION__, rxF, p); LOG_I(PHY, "In %s ul_ch addr %p nushift %d\n", __FUNCTION__, ul_ch, nushift); #endif - //if ((gNB->frame_parms.N_RB_UL&1)==0) { - if (pusch_pdu->dmrs_config_type == pusch_dmrs_type1 && gNB->prb_interpolation == 0){ + if (pusch_pdu->dmrs_config_type == pusch_dmrs_type1 && chest_freq == 0){ LOG_D(PHY,"PUSCH estimation DMRS type 1, Freq-domain interpolation"); - // Treat first 2 pilots specially (left edge) - ch[0] = (int16_t)(((int32_t)pil[0]*rxF[0] - (int32_t)pil[1]*rxF[1])>>15); - ch[1] = (int16_t)(((int32_t)pil[0]*rxF[1] + (int32_t)pil[1]*rxF[0])>>15); + // For configuration type 1: k = 4*n + 2*k' + delta, + // where k' is 0 or 1, and delta is in Table 6.4.1.1.3-1 from TS 38.211 + + pilot_cnt = 0; + int delta = nr_pusch_dmrs_delta(pusch_dmrs_type1, p); + + for (int n = 0; n < 3*nb_rb_pusch; n++) { + + // LS estimation + ch[0] = 0; + ch[1] = 0; + for (int k_line = 0; k_line <= 1; k_line++) { + re_offset = (k0 + (n << 2) + (k_line << 1) + delta) % gNB->frame_parms.ofdm_symbol_size; + rxF = (int16_t *) &rxdataF[aarx][(soffset + symbol_offset + re_offset)]; + ch[0] += (int16_t) (((int32_t) pil[0] * rxF[0] - (int32_t) pil[1] * rxF[1]) >> (15+b_shift)); + ch[1] += (int16_t) (((int32_t) pil[0] * rxF[1] + (int32_t) pil[1] * rxF[0]) >> (15+b_shift)); + pil += 2; + } + + // Channel interpolation + for (int k_line = 0; k_line <= 1; k_line++) { #ifdef DEBUG_PUSCH - LOG_I(PHY, "In %s ch 0 %d\n", __FUNCTION__, ((int32_t)pil[0]*rxF[0] - (int32_t)pil[1]*rxF[1])); - LOG_I(PHY, "In %s pilot 0 : rxF - > (%d,%d) (%d) ch -> (%d,%d) (%d), pil -> (%d,%d) \n", - __FUNCTION__, - rxF[0], - rxF[1], - dBc(rxF[0],rxF[1]), - ch[0], - ch[1], - dBc(ch[0],ch[1]), - pil[0], - pil[1]); - LOG_I(PHY, "In %s data 0 : rxF - > (%d,%d) (%d)\n", __FUNCTION__, rxF[2], rxF[3], dBc(rxF[2],rxF[3])); + re_offset = (k0 + (n << 2) + (k_line << 1)) % gNB->frame_parms.ofdm_symbol_size; + rxF = (int16_t *) &rxdataF[aarx][(soffset + symbol_offset + re_offset)]; + printf("pilot %4u: pil -> (%6d,%6d), rxF -> (%4d,%4d), ch -> (%4d,%4d)\n", + pilot_cnt, pil[0], pil[1], rxF[0], rxF[1], ch[0], ch[1]); + //printf("data %4u: rxF -> (%4d,%4d) (%2d)\n",pilot_cnt, rxF[2], rxF[3], dBc(rxF[2], rxF[3])); #endif - - multadd_real_vector_complex_scalar(fl, - ch, - ul_ch, - 8); - pil += 2; - re_offset = (re_offset+2) % gNB->frame_parms.ofdm_symbol_size; - rxF = (int16_t *)&rxdataF[aarx][(soffset+symbol_offset+nushift+re_offset)]; - //for (int i= 0; i<8; i++) - //printf("ul_ch addr %p %d\n", ul_ch+i, *(ul_ch+i)); - - ch[0] = (int16_t)(((int32_t)pil[0]*rxF[0] - (int32_t)pil[1]*rxF[1])>>15); - ch[1] = (int16_t)(((int32_t)pil[0]*rxF[1] + (int32_t)pil[1]*rxF[0])>>15); - -#ifdef DEBUG_PUSCH - LOG_I(PHY, "In %s pilot 1 : rxF - > (%d,%d) (%d) ch -> (%d,%d) (%d), pil -> (%d,%d) \n", - __FUNCTION__, - rxF[0], - rxF[1], - dBc(rxF[0],rxF[1]), - ch[0], - ch[1], - dBc(ch[0],ch[1]), - pil[0], - pil[1]); - LOG_I(PHY, "In %s data 1 : rxF - > (%d,%d) (%d)\n", - __FUNCTION__, - rxF[2], - rxF[3], - dBc(rxF[2],rxF[3])); -#endif - - multadd_real_vector_complex_scalar(fml, - ch, - ul_ch, - 8); - pil += 2; - re_offset = (re_offset+2) % gNB->frame_parms.ofdm_symbol_size; - rxF = (int16_t *)&rxdataF[aarx][(soffset+symbol_offset+nushift+re_offset)]; - //printf("ul_ch addr %p\n",ul_ch); - - ch[0] = (int16_t)(((int32_t)pil[0]*rxF[0] - (int32_t)pil[1]*rxF[1])>>15); - ch[1] = (int16_t)(((int32_t)pil[0]*rxF[1] + (int32_t)pil[1]*rxF[0])>>15); - -#ifdef DEBUG_PUSCH - LOG_I(PHY, "In %s pilot 2 : rxF - > (%d,%d) (%d) ch -> (%d,%d) (%d), pil -> (%d,%d) \n", - __FUNCTION__, - rxF[0], - rxF[1], - dBc(rxF[0],rxF[1]), - ch[0], - ch[1], - dBc(ch[0],ch[1]), - pil[0], - pil[1]); - LOG_I(PHY, "In %s data 2 : rxF - > (%d,%d) (%d)\n", - __FUNCTION__, - rxF[2], - rxF[3], - dBc(rxF[2],rxF[3])); -#endif - - multadd_real_vector_complex_scalar(fmm, - ch, - ul_ch, - 8); - - //for (int i= 0; i<16; i++) - //printf("ul_ch addr %p %d\n", ul_ch+i, *(ul_ch+i)); - - pil += 2; - re_offset = (re_offset+2) % gNB->frame_parms.ofdm_symbol_size; - rxF = (int16_t *)&rxdataF[aarx][(soffset+symbol_offset+nushift+re_offset)]; - ul_ch+=8; - - for (pilot_cnt=3; pilot_cnt<(6*nb_rb_pusch-3); pilot_cnt += 2) { - - ch[0] = (int16_t)(((int32_t)pil[0]*rxF[0] - (int32_t)pil[1]*rxF[1])>>15); - ch[1] = (int16_t)(((int32_t)pil[0]*rxF[1] + (int32_t)pil[1]*rxF[0])>>15); - - #ifdef DEBUG_PUSCH - printf("pilot %u : rxF - > (%d,%d) (%d) ch -> (%d,%d) (%d), pil -> (%d,%d) \n",pilot_cnt,rxF[0],rxF[1],dBc(rxF[0],rxF[1]),ch[0],ch[1],dBc(ch[0],ch[1]),pil[0],pil[1]); - printf("data %u : rxF - > (%d,%d) (%d)\n",pilot_cnt,rxF[2],rxF[3],dBc(rxF[2],rxF[3])); - #endif - multadd_real_vector_complex_scalar(fml, - ch, - ul_ch, - 8); - pil += 2; - re_offset = (re_offset+2) % gNB->frame_parms.ofdm_symbol_size; - rxF = (int16_t *)&rxdataF[aarx][(soffset+symbol_offset+nushift+re_offset)]; - //printf("ul_ch addr %p\n",ul_ch); - - ch[0] = (int16_t)(((int32_t)pil[0]*rxF[0] - (int32_t)pil[1]*rxF[1])>>15); - ch[1] = (int16_t)(((int32_t)pil[0]*rxF[1] + (int32_t)pil[1]*rxF[0])>>15); - - #ifdef DEBUG_PUSCH - printf("pilot %u : rxF - > (%d,%d) (%d) ch -> (%d,%d) (%d), pil -> (%d,%d) \n",pilot_cnt+1,rxF[0],rxF[1],dBc(rxF[0],rxF[1]),ch[0],ch[1],dBc(ch[0],ch[1]),pil[0],pil[1]); - printf("data %u : rxF - > (%d,%d) (%d)\n",pilot_cnt+1,rxF[2],rxF[3],dBc(rxF[2],rxF[3])); - #endif - multadd_real_vector_complex_scalar(fmm, - ch, - ul_ch, - 8); - - //for (int i= 0; i<16; i++) - //printf("ul_ch addr %p %d\n", ul_ch+i, *(ul_ch+i)); - - pil += 2; - re_offset = (re_offset+2) % gNB->frame_parms.ofdm_symbol_size; - rxF = (int16_t *)&rxdataF[aarx][soffset+(symbol_offset+nushift+re_offset)]; - ul_ch+=8; + if (pilot_cnt == 0) { + multadd_real_vector_complex_scalar(fl, ch, ul_ch, 8); + } else if (pilot_cnt == 1) { + multadd_real_vector_complex_scalar(fml, ch, ul_ch, 8); + } else if (pilot_cnt == (6*nb_rb_pusch-2)) { + multadd_real_vector_complex_scalar(fmr, ch, ul_ch, 8); + ul_ch+=8; + } else if (pilot_cnt == (6*nb_rb_pusch-1)) { + multadd_real_vector_complex_scalar(fr, ch, ul_ch, 8); + } else if (pilot_cnt%2 == 0) { + multadd_real_vector_complex_scalar(fmm, ch, ul_ch, 8); + ul_ch+=8; + } else { + multadd_real_vector_complex_scalar(fm, ch, ul_ch, 8); + } + pilot_cnt++; + } } - - // Treat first 2 pilots specially (right edge) - ch[0] = (int16_t)(((int32_t)pil[0]*rxF[0] - (int32_t)pil[1]*rxF[1])>>15); - ch[1] = (int16_t)(((int32_t)pil[0]*rxF[1] + (int32_t)pil[1]*rxF[0])>>15); -#ifdef DEBUG_PUSCH - printf("pilot %u : rxF - > (%d,%d) (%d) ch -> (%d,%d) (%d), pil -> (%d,%d) \n",pilot_cnt,rxF[0],rxF[1],dBc(rxF[0],rxF[1]),ch[0],ch[1],dBc(ch[0],ch[1]),pil[0],pil[1]); - printf("data %u : rxF - > (%d,%d) (%d)\n",pilot_cnt,rxF[2],rxF[3],dBc(rxF[2],rxF[3])); -#endif - multadd_real_vector_complex_scalar(fm, - ch, - ul_ch, - 8); - - //for (int i= 0; i<8; i++) - //printf("ul_ch addr %p %d\n", ul_ch+i, *(ul_ch+i)); - - pil += 2; - re_offset = (re_offset+2) % gNB->frame_parms.ofdm_symbol_size; - rxF = (int16_t *)&rxdataF[aarx][soffset+(symbol_offset+nushift+re_offset)]; - - ch[0] = (int16_t)(((int32_t)pil[0]*rxF[0] - (int32_t)pil[1]*rxF[1])>>15); - ch[1] = (int16_t)(((int32_t)pil[0]*rxF[1] + (int32_t)pil[1]*rxF[0])>>15); -#ifdef DEBUG_PUSCH - printf("ch 0 %d\n",((int32_t)pil[0]*rxF[0] - (int32_t)pil[1]*rxF[1])); - printf("pilot %u : rxF - > (%d,%d) (%d) ch -> (%d,%d) (%d), pil -> (%d,%d) \n",pilot_cnt+1,rxF[0],rxF[1],dBc(rxF[0],rxF[1]),ch[0],ch[1],dBc(ch[0],ch[1]),pil[0],pil[1]); - printf("data %u : rxF - > (%d,%d) (%d)\n",pilot_cnt+1,rxF[2],rxF[3],dBc(rxF[2],rxF[3])); -#endif - multadd_real_vector_complex_scalar(fmr, - ch, - ul_ch, - 8); - - pil += 2; - re_offset = (re_offset+2) % gNB->frame_parms.ofdm_symbol_size; - rxF = (int16_t *)&rxdataF[aarx][soffset+(symbol_offset+nushift+re_offset)]; - ul_ch+=8; - - ch[0] = (int16_t)(((int32_t)pil[0]*rxF[0] - (int32_t)pil[1]*rxF[1])>>15); - ch[1] = (int16_t)(((int32_t)pil[0]*rxF[1] + (int32_t)pil[1]*rxF[0])>>15); -#ifdef DEBUG_PUSCH - printf("pilot %u: rxF - > (%d,%d) (%d) ch -> (%d,%d) (%d), pil -> (%d,%d) \n",pilot_cnt+2,rxF[0],rxF[1],dBc(rxF[0],rxF[1]),ch[0],ch[1],dBc(ch[0],ch[1]),pil[0],pil[1]); - printf("data %u : rxF - > (%d,%d) (%d)\n",pilot_cnt+2,rxF[2],rxF[3],dBc(rxF[2],rxF[3])); -#endif - multadd_real_vector_complex_scalar(fr, - ch, - ul_ch, - 8); - // check if PRB crosses DC and improve estimates around DC if ((bwp_start_subcarrier < gNB->frame_parms.ofdm_symbol_size) && (bwp_start_subcarrier+nb_rb_pusch*12 >= gNB->frame_parms.ofdm_symbol_size)) { ul_ch = (int16_t *)&ul_ch_estimates[p*gNB->frame_parms.nb_antennas_rx+aarx][ch_offset]; uint16_t idxDC = 2*(gNB->frame_parms.ofdm_symbol_size - bwp_start_subcarrier); uint16_t idxPil = idxDC/2; - re_offset = k; + re_offset = k0; pil = (int16_t *)&pilot[0]; pil += (idxPil-2); ul_ch += (idxDC-4); @@ -423,10 +294,7 @@ int nr_pusch_channel_estimation(PHY_VARS_gNB *gNB, // for proper allignment of SIMD vectors if((gNB->frame_parms.N_RB_UL&1)==0) { - multadd_real_vector_complex_scalar(fdcl, - ch, - ul_ch-4, - 8); + multadd_real_vector_complex_scalar(fdcl, ch, ul_ch-4, 8); pil += 4; re_offset = (re_offset+4) % gNB->frame_parms.ofdm_symbol_size; @@ -434,16 +302,11 @@ int nr_pusch_channel_estimation(PHY_VARS_gNB *gNB, ch[0] = (int16_t)(((int32_t)pil[0]*rxF[0] - (int32_t)pil[1]*rxF[1])>>15); ch[1] = (int16_t)(((int32_t)pil[0]*rxF[1] + (int32_t)pil[1]*rxF[0])>>15); - multadd_real_vector_complex_scalar(fdcr, - ch, - ul_ch-4, - 8); - } - else { - multadd_real_vector_complex_scalar(fdclh, - ch, - ul_ch, - 8); + multadd_real_vector_complex_scalar(fdcr, ch, ul_ch-4, 8); + + } else { + + multadd_real_vector_complex_scalar(fdclh, ch, ul_ch, 8); pil += 4; re_offset = (re_offset+4) % gNB->frame_parms.ofdm_symbol_size; @@ -451,23 +314,22 @@ int nr_pusch_channel_estimation(PHY_VARS_gNB *gNB, ch[0] = (int16_t)(((int32_t)pil[0]*rxF[0] - (int32_t)pil[1]*rxF[1])>>15); ch[1] = (int16_t)(((int32_t)pil[0]*rxF[1] + (int32_t)pil[1]*rxF[0])>>15); - multadd_real_vector_complex_scalar(fdcrh, - ch, - ul_ch, - 8); + multadd_real_vector_complex_scalar(fdcrh, ch, ul_ch, 8); } } + #ifdef DEBUG_PUSCH ul_ch = (int16_t *)&ul_ch_estimates[p*gNB->frame_parms.nb_antennas_rx+aarx][ch_offset]; for(uint16_t idxP=0; idxPdmrs_config_type == pusch_dmrs_type2 && gNB->prb_interpolation == 0) { //pusch_dmrs_type2 |p_r,p_l,d,d,d,d,p_r,p_l,d,d,d,d| + else if (pusch_pdu->dmrs_config_type == pusch_dmrs_type2 && chest_freq == 0) { //pusch_dmrs_type2 |p_r,p_l,d,d,d,d,p_r,p_l,d,d,d,d| LOG_D(PHY,"PUSCH estimation DMRS type 2, Freq-domain interpolation"); // Treat first DMRS specially (left edge) @@ -803,6 +665,10 @@ int nr_pusch_channel_estimation(PHY_VARS_gNB *gNB, ch[0] = ch_0 / 4; ch[1] = ch_1 / 4; +#if NO_INTERP + for (int i=0;i<12;i++) ((int32_t*)ul_ch)[i] = *(int32_t*)ch; + ul_ch+=24; +#else multadd_real_vector_complex_scalar(filt8_avlip0, ch, ul_ch, @@ -820,6 +686,7 @@ int nr_pusch_channel_estimation(PHY_VARS_gNB *gNB, ul_ch, 8); ul_ch -= 24; +#endif for (pilot_cnt=4; pilot_cnt<4*(nb_rb_pusch-1); pilot_cnt += 4) { @@ -854,6 +721,10 @@ int nr_pusch_channel_estimation(PHY_VARS_gNB *gNB, ch[0] = ch_0 / 4; ch[1] = ch_1 / 4; +#if NO_INTERP + for (int i=0;i<12;i++) ((int32_t*)ul_ch)[i] = *(int32_t*)ch; + ul_ch+=24; +#else ul_ch[6] += (ch[0] * 1365)>>15; // 1/12*16384 ul_ch[7] += (ch[1] * 1365)>>15; // 1/12*16384 @@ -875,6 +746,7 @@ int nr_pusch_channel_estimation(PHY_VARS_gNB *gNB, ul_ch, 8); ul_ch -= 16; +#endif } // Last PRB ch_0 = ((int32_t)pil[0]*rxF[0] - (int32_t)pil[1]*rxF[1])>>15; @@ -908,6 +780,10 @@ int nr_pusch_channel_estimation(PHY_VARS_gNB *gNB, ch[0] = ch_0 / 4; ch[1] = ch_1 / 4; +#if NO_INTERP + for (int i=0;i<12;i++) ((int32_t*)ul_ch)[i] = *(int32_t*)ch; + ul_ch+=24; +#else ul_ch[6] += (ch[0] * 1365)>>15; // 1/12*16384 ul_ch[7] += (ch[1] * 1365)>>15; // 1/12*16384 @@ -922,6 +798,7 @@ int nr_pusch_channel_estimation(PHY_VARS_gNB *gNB, ch, ul_ch, 8); +#endif } #ifdef DEBUG_PUSCH ul_ch = (int16_t *)&ul_ch_estimates[p*gNB->frame_parms.nb_antennas_rx+aarx][ch_offset]; @@ -1028,7 +905,6 @@ void nr_pusch_ptrs_processing(PHY_VARS_gNB *gNB, /*------------------------------------------------------------------------------------------------------- */ nr_ptrs_cpe_estimation(*K_ptrs,*ptrsReOffset,*dmrsConfigType,*nb_rb, rel15_ul->rnti, - (int16_t *)&gNB->pusch_vars[ulsch_id]->ul_ch_ptrs_estimates_ext[aarx][symbol*nb_re_pusch], nr_tti_rx, symbol,frame_parms->ofdm_symbol_size, (int16_t*)&gNB->pusch_vars[ulsch_id]->rxdataF_comp[aarx][(symbol * nb_re_pusch)], @@ -1247,4 +1123,4 @@ int nr_srs_channel_estimation(PHY_VARS_gNB *gNB, #endif return 0; -} \ No newline at end of file +} diff --git a/openair1/PHY/NR_REFSIG/dmrs_nr.c b/openair1/PHY/NR_REFSIG/dmrs_nr.c index 2e270318f8..1fd502a93e 100644 --- a/openair1/PHY/NR_REFSIG/dmrs_nr.c +++ b/openair1/PHY/NR_REFSIG/dmrs_nr.c @@ -295,74 +295,6 @@ uint16_t get_dmrs_freq_idx_ul(uint16_t n, uint8_t k_prime, uint8_t delta, uint8_ #define CHECK_DMRS_PBCH_SEQUENCE -void generate_dmrs_pbch(uint32_t dmrs_pbch_bitmap[DMRS_PBCH_I_SSB][DMRS_PBCH_N_HF][DMRS_BITMAP_SIZE], uint16_t Nid_cell) -{ - uint32_t cinit; - int i_ssb; - int n_hf; - int _i_ssb; - -#ifdef CHECK_DMRS_PBCH_SEQUENCE - - uint32_t dmrs_bitmap[DMRS_PBCH_I_SSB][DMRS_PBCH_N_HF][DMRS_BITMAP_SIZE]; - uint32_t *dmrs_sequence = calloc(CELL_DMRS_LENGTH, sizeof(uint32_t)); - if (dmrs_sequence == NULL) { - msg("Fatal error: memory allocation problem \n"); - assert(0); - } - else - { - printf("Check of demodulation reference signal of pbch sequence \n"); - } - -#endif - - /* for each slot number */ - for (i_ssb = 0; i_ssb>4) + 1))<<11) + ((_i_ssb + 1)<<6) + (Nid_cell%4); - - pseudo_random_sequence_optimised(DMRS_BITMAP_SIZE, &(dmrs_pbch_bitmap[i_ssb][n_hf][0]), cinit); - -#ifdef CHECK_DMRS_PBCH_SEQUENCE - - /* it allows checking generated with standard generation code */ - pseudo_random_sequence(DMRS_BITMAP_SIZE*sizeof(uint32_t), dmrs_sequence, cinit); - - int j = 0; - int k = 0; - - /* format for getting bitmap from uint32_t */ - for (int i=0; i -1, "No DMRS symbol present in this slot\n"); + for (int aarx = 0; aarx < frame_parms->nb_antennas_rx; aarx++) { + for (int symb = first_dmrs_symb+1; symb < total_symbols; symb++) { + ul_ch128_0 = (__m128i *)&ch_est[aarx][first_dmrs_symb*frame_parms->ofdm_symbol_size]; + if ((dmrs_bitmap >> symb) & 0x01) { + ul_ch128_1 = (__m128i *)&ch_est[aarx][symb*frame_parms->ofdm_symbol_size]; + for (int rbIdx = 0; rbIdx < num_rbs; rbIdx++) { + ul_ch128_0[0] = _mm_adds_epi16(ul_ch128_0[0], ul_ch128_1[0]); + ul_ch128_0[1] = _mm_adds_epi16(ul_ch128_0[1], ul_ch128_1[1]); + ul_ch128_0[2] = _mm_adds_epi16(ul_ch128_0[2], ul_ch128_1[2]); + ul_ch128_0 += 3; + ul_ch128_1 += 3; + } + } + } + ul_ch128_0 = (__m128i *)&ch_est[aarx][first_dmrs_symb*frame_parms->ofdm_symbol_size]; + if (num_dmrs_symb == 2) { + for (int rbIdx = 0; rbIdx < num_rbs; rbIdx++) { + ul_ch128_0[0] = _mm_srai_epi16(ul_ch128_0[0], 1); + ul_ch128_0[1] = _mm_srai_epi16(ul_ch128_0[1], 1); + ul_ch128_0[2] = _mm_srai_epi16(ul_ch128_0[2], 1); + ul_ch128_0 += 3; + } + } else if (num_dmrs_symb == 4) { + for (int rbIdx = 0; rbIdx < num_rbs; rbIdx++) { + ul_ch128_0[0] = _mm_srai_epi16(ul_ch128_0[0], 2); + ul_ch128_0[1] = _mm_srai_epi16(ul_ch128_0[1], 2); + ul_ch128_0[2] = _mm_srai_epi16(ul_ch128_0[2], 2); + ul_ch128_0 += 3; + } + } else if (num_dmrs_symb == 3) { + ul_ch16_0 = (int16_t *)&ch_est[aarx][first_dmrs_symb*frame_parms->ofdm_symbol_size]; + for (int rbIdx = 0; rbIdx < num_rbs; rbIdx++) { + ul_ch16_0[0] /= 3; + ul_ch16_0[1] /= 3; + ul_ch16_0[2] /= 3; + ul_ch16_0[3] /= 3; + ul_ch16_0[4] /= 3; + ul_ch16_0[5] /= 3; + ul_ch16_0[6] /= 3; + ul_ch16_0[7] /= 3; + ul_ch16_0[8] /= 3; + ul_ch16_0[9] /= 3; + ul_ch16_0[10] /= 3; + ul_ch16_0[11] /= 3; + ul_ch16_0[12] /= 3; + ul_ch16_0[13] /= 3; + ul_ch16_0[14] /= 3; + ul_ch16_0[15] /= 3; + ul_ch16_0[16] /= 3; + ul_ch16_0[17] /= 3; + ul_ch16_0[18] /= 3; + ul_ch16_0[19] /= 3; + ul_ch16_0[20] /= 3; + ul_ch16_0[21] /= 3; + ul_ch16_0[22] /= 3; + ul_ch16_0[23] /= 3; + ul_ch16_0 += 24; + } + } else AssertFatal((num_dmrs_symb < 5) && (num_dmrs_symb > 0), "Illegal number of DMRS symbols in the slot\n"); + } +} + diff --git a/openair1/PHY/NR_REFSIG/dmrs_nr.h b/openair1/PHY/NR_REFSIG/dmrs_nr.h index b9e9ca6f0d..1297a0cc2f 100644 --- a/openair1/PHY/NR_REFSIG/dmrs_nr.h +++ b/openair1/PHY/NR_REFSIG/dmrs_nr.h @@ -53,7 +53,6 @@ int pseudo_random_sequence(int M_PN, uint32_t *c, uint32_t cinit); void lte_gold_new(LTE_DL_FRAME_PARMS *frame_parms, uint32_t lte_gold_table[20][2][14], uint16_t Nid_cell); -void generate_dmrs_pbch(uint32_t dmrs_pbch_bitmap[DMRS_PBCH_I_SSB][DMRS_PBCH_N_HF][DMRS_BITMAP_SIZE], uint16_t Nid_cell); uint16_t get_dmrs_freq_idx_ul(uint16_t n, uint8_t k_prime, uint8_t delta, uint8_t dmrs_type); uint8_t allowed_xlsch_re_in_dmrs_symbol(uint16_t k, @@ -66,6 +65,12 @@ void nr_gen_ref_conj_symbols(uint32_t *in, uint32_t length, int16_t *output, uin int8_t get_next_dmrs_symbol_in_slot(uint16_t ul_dmrs_symb_pos, uint8_t counter, uint8_t end_symbol); uint8_t get_dmrs_symbols_in_slot(uint16_t l_prime_mask, uint16_t nb_symb); int8_t get_valid_dmrs_idx_for_channel_est(uint16_t dmrs_symb_pos, uint8_t counter); +void nr_chest_time_domain_avg(NR_DL_FRAME_PARMS *frame_parms, + int **ch_est, + uint8_t num_symbols, + uint8_t start_symbol, + uint16_t dmrs_bitmap, + uint16_t num_rbs); static inline uint8_t is_dmrs_symbol(uint8_t l, uint16_t dmrsSymbMask ) { return ((dmrsSymbMask >> l) & 0x1); } #undef EXTERN diff --git a/openair1/PHY/NR_REFSIG/nr_dmrs_rx.c b/openair1/PHY/NR_REFSIG/nr_dmrs_rx.c index 920b78eac2..4f089562f6 100644 --- a/openair1/PHY/NR_REFSIG/nr_dmrs_rx.c +++ b/openair1/PHY/NR_REFSIG/nr_dmrs_rx.c @@ -39,9 +39,11 @@ #include "nr_refsig.h" #include "PHY/defs_gNB.h" -/*Table 7.4.1.1.2-1/2 from 38.211 */ +// Table 6.4.1.1.3-1/2 from TS 38.211 +int delta1[8] = {0, 0, 1, 1, 0, 0, 1, 1}; int wf1[8][2] = {{1,1},{1,-1},{1,1},{1,-1},{1,1},{1,-1},{1,1},{1,-1}}; int wt1[8][2] = {{1,1},{1,1},{1,1},{1,1},{1,-1},{1,-1},{1,-1},{1,-1}}; +int delta2[12] = {0, 0, 2, 2, 4, 4, 0, 0, 2, 2, 4, 4}; int wf2[12][2] = {{1,1},{1,-1},{1,1},{1,-1},{1,1},{1,-1},{1,1},{1,-1},{1,1},{1,-1},{1,1},{1,-1}}; int wt2[12][2] = {{1,1},{1,1},{1,1},{1,1},{1,1},{1,1},{1,-1},{1,-1},{1,-1},{1,-1},{1,-1},{1,-1}}; @@ -49,6 +51,13 @@ int wt2[12][2] = {{1,1},{1,1},{1,1},{1,1},{1,1},{1,1},{1,-1},{1,-1},{1,-1},{1,-1 short nr_rx_mod_table[14] = {0,0,23170,-23170,-23170,23170,23170,-23170,23170,23170,-23170,-23170,-23170,23170}; short nr_rx_nmod_table[14] = {0,0,-23170,23170,23170,-23170,-23170,23170,-23170,-23170,23170,23170,23170,-23170}; +int nr_pusch_dmrs_delta(uint8_t dmrs_config_type, unsigned short p) { + if (dmrs_config_type == pusch_dmrs_type1) { + return delta1[p]; + } else { + return delta2[p]; + } +} int nr_pusch_dmrs_rx(PHY_VARS_gNB *gNB, unsigned int Ns, diff --git a/openair1/PHY/NR_REFSIG/nr_gold.c b/openair1/PHY/NR_REFSIG/nr_gold.c index 7930839832..9b4cc50953 100644 --- a/openair1/PHY/NR_REFSIG/nr_gold.c +++ b/openair1/PHY/NR_REFSIG/nr_gold.c @@ -60,6 +60,7 @@ void nr_init_pdcch_dmrs(PHY_VARS_gNB* gNB, uint32_t Nid) uint8_t reset; NR_DL_FRAME_PARMS *fp = &gNB->frame_parms; uint32_t ***pdcch_dmrs = gNB->nr_gold_pdcch_dmrs; + int pdcch_dmrs_init_length = (((fp->N_RB_DL<<1)*3)>>5)+1; for (uint8_t slot=0; slotslots_per_frame; slot++) { for (uint8_t symb=0; symbsymbols_per_slot; symb++) { @@ -67,7 +68,7 @@ void nr_init_pdcch_dmrs(PHY_VARS_gNB* gNB, uint32_t Nid) reset = 1; x2 = ((1<<17) * (fp->symbols_per_slot*slot+symb+1) * ((Nid<<1)+1) + (Nid<<1)); LOG_D(PHY,"PDCCH DMRS slot %d, symb %d, Nid %d, x2 %x\n",slot,symb,Nid,x2); - for (uint32_t n=0; nframe_parms; uint32_t ****pdsch_dmrs = gNB->nr_gold_pdsch_dmrs; + int pdsch_dmrs_init_length = ((fp->N_RB_DL*12)>>5)+1; - uint16_t N_n_scid[NR_MAX_NB_CODEWORDS]={Nid, Nid}; // Not correct, appropriate scrambling IDs have to be updated to support DCI 1_1 - uint8_t n_scid=0; // again works only for 1_0 for (uint8_t slot=0; slotslots_per_frame; slot++) { for (uint8_t symb=0; symbsymbols_per_slot; symb++) { - reset = 1; - x2 = ((1<<17) * (fp->symbols_per_slot*slot+symb+1) * ((N_n_scid[n_scid]<<1)+1) +((N_n_scid[n_scid]<<1)+n_scid)); - LOG_D(PHY,"PDSCH DMRS slot %d, symb %d x2 %x, N_n_scid %d,n_scid %d\n",slot,symb,x2,N_n_scid[n_scid],n_scid); - for (uint32_t n=0; nsymbols_per_slot*slot+symb+1) * ((Nid<<1)+1) +((Nid<<1)+nscid)); + LOG_D(PHY,"PDSCH DMRS slot %d, symb %d x2 %x, Nid %d,nscid %d\n",slot,symb,x2,Nid,nscid); + for (uint32_t n=0; nframe_parms; unsigned short l; + int pusch_dmrs_init_length = ((fp->N_RB_UL*12)>>5)+1; - for (nscid=0; nscid<2; nscid++) { - nid = Nid[nscid]; - for (ns=0; nsslots_per_frame; ns++) { - for (l=0; lsymbols_per_slot; l++) { - reset = 1; - x2 = ((1<<17) * (fp->symbols_per_slot*ns+l+1) * ((nid<<1)+1) +((nid<<1)+nscid)); - LOG_D(PHY,"DMRS slot %d, symb %d x2 %x\n",ns,l,x2); + for (ns=0; nsslots_per_frame; ns++) { + for (l=0; lsymbols_per_slot; l++) { + reset = 1; + x2 = ((1<<17) * (fp->symbols_per_slot*ns+l+1) * ((nid<<1)+1) +((nid<<1)+nscid)); + LOG_D(PHY,"DMRS slot %d, symb %d x2 %x\n",ns,l,x2); - for (n=0; nnr_gold_pusch_dmrs[nscid][ns][l][n] = lte_gold_generic(&x1, &x2, reset); - reset = 0; - } + for (n=0; nnr_gold_pusch_dmrs[nscid][ns][l][n] = lte_gold_generic(&x1, &x2, reset); + reset = 0; } } } } - - -void nr_init_csi_rs(PHY_VARS_gNB* gNB, uint32_t Nid) -{ - NR_DL_FRAME_PARMS *fp = &gNB->frame_parms; - uint32_t ***csi_rs = gNB->nr_gold_csi_rs; - uint32_t x1, x2; - uint8_t reset; - - for (uint8_t slot=0; slotslots_per_frame; slot++) { - for (uint8_t symb=0; symbsymbols_per_slot; symb++) { - - reset = 1; - x2 = ((1<<10) * (fp->symbols_per_slot*slot+symb+1) * ((Nid<<1)+1) + (Nid)); - - for (uint32_t n=0; nframe_parms.N_RB_DL<<1)*3)>>5)+1; for (ns=0; nsframe_parms.slots_per_frame; ns++) { @@ -64,9 +65,9 @@ void nr_gold_pdcch(PHY_VARS_NR_UE* ue, reset = 1; x2tmp0 = ((ue->frame_parms.symbols_per_slot*ns+l+1)*((nid<<1)+1))<<17; - x2 = (x2tmp0+(nid<<1))%(1<<31); //cinit + x2 = (x2tmp0+(nid<<1))%(1U<<31); //cinit - for (n=0; nnr_gold_pdcch[0][ns][l][n] = lte_gold_generic(&x1, &x2, reset); reset = 0; } @@ -75,61 +76,51 @@ void nr_gold_pdcch(PHY_VARS_NR_UE* ue, } void nr_gold_pdsch(PHY_VARS_NR_UE* ue, - unsigned short *n_idDMRS) -{ - unsigned char l; - unsigned int n,x1,x2,x2tmp0,ns; - int nscid; - unsigned int nid; + int nscid, + uint32_t nid) { + + unsigned int x1,x2,x2tmp0; uint8_t reset; + int pdsch_dmrs_init_length = ((ue->frame_parms.N_RB_DL*12)>>5)+1; - /// to be updated from higher layer - //unsigned short lbar = 0; + for (int ns=0; nsframe_parms.slots_per_frame; ns++) { - for (nscid=0; nscid<2; nscid++) { - for (ns=0; nsframe_parms.slots_per_frame; ns++) { + for (int l=0; lframe_parms.symbols_per_slot; l++) { - nid = n_idDMRS[nscid]; + reset = 1; + x2tmp0 = ((ue->frame_parms.symbols_per_slot*ns+l+1)*((nid<<1)+1))<<17; + x2 = (x2tmp0+(nid<<1)+nscid)%(1U<<31); //cinit + LOG_D(PHY,"UE DMRS slot %d, symb %d, x2 %x, nscid %d\n",ns,l,x2,nscid); - for (l=0; lframe_parms.symbols_per_slot; l++) { - - reset = 1; - x2tmp0 = ((ue->frame_parms.symbols_per_slot*ns+l+1)*((nid<<1)+1))<<17; - x2 = (x2tmp0+(nid<<1)+nscid)%(1<<31); //cinit - LOG_D(PHY,"UE DMRS slot %d, symb %d, x2 %x, nscid %d\n",ns,l,x2,nscid); - - for (n=0; nnr_gold_pdsch[0][ns][l][nscid][n] = lte_gold_generic(&x1, &x2, reset); - reset = 0; - } + for (int n=0; nnr_gold_pdsch[0][ns][l][nscid][n] = lte_gold_generic(&x1, &x2, reset); + reset = 0; } } } } void nr_init_pusch_dmrs(PHY_VARS_NR_UE* ue, - uint16_t *N_n_scid, + uint16_t N_n_scid, uint8_t n_scid) { uint32_t x1, x2, n; - uint8_t reset, slot, symb, q; + uint8_t reset, slot, symb; NR_DL_FRAME_PARMS *fp = &ue->frame_parms; uint32_t ****pusch_dmrs = ue->nr_gold_pusch_dmrs; + int pusch_dmrs_init_length = ((fp->N_RB_UL*12)>>5)+1; for (slot=0; slotslots_per_frame; slot++) { for (symb=0; symbsymbols_per_slot; symb++) { reset = 1; - x2 = ((1<<17) * (fp->symbols_per_slot*slot+symb+1) * ((N_n_scid[n_scid]<<1)+1) +((N_n_scid[n_scid]<<1)+n_scid)); - - for (n=0; nsymbols_per_slot*slot+symb+1) * ((N_n_scid<<1)+1) +((N_n_scid<<1)+n_scid)); + LOG_D(PHY,"DMRS slot %d, symb %d x2 %x\n",slot,symb,x2); + for (n=0; nN_RB_DL<<4)>>5)+1; + for (uint8_t slot=0; slotslots_per_frame; slot++) { + for (uint8_t symb=0; symbsymbols_per_slot; symb++) { + reset = 1; + x2 = ((1<<10) * (fp->symbols_per_slot*slot+symb+1) * ((Nid<<1)+1) + (Nid)); + for (uint32_t n=0; nframe_parms; - int32_t **txdataF = gNB->common_vars.txdataF; - int txdataF_offset = slot*frame_parms.samples_per_slot_wCP; - uint32_t **gold_csi_rs = gNB->nr_gold_csi_rs[slot]; - int16_t mod_csi[frame_parms.symbols_per_slot][NR_MAX_CSI_RS_LENGTH>>1] __attribute__((aligned(16)));; - uint16_t b = csi_params.freq_domain; - uint16_t n, csi_bw, csi_start, p, k, l, mprime, na, kpn, csi_length; +#ifdef NR_CSIRS_DEBUG + LOG_I(NR_PHY, "csi_params->subcarrier_spacing = %i\n", csi_params->subcarrier_spacing); + LOG_I(NR_PHY, "csi_params->cyclic_prefix = %i\n", csi_params->cyclic_prefix); + LOG_I(NR_PHY, "csi_params->start_rb = %i\n", csi_params->start_rb); + LOG_I(NR_PHY, "csi_params->nr_of_rbs = %i\n", csi_params->nr_of_rbs); + LOG_I(NR_PHY, "csi_params->csi_type = %i (0:TRS, 1:CSI-RS NZP, 2:CSI-RS ZP)\n", csi_params->csi_type); + LOG_I(NR_PHY, "csi_params->row = %i\n", csi_params->row); + LOG_I(NR_PHY, "csi_params->freq_domain = %i\n", csi_params->freq_domain); + LOG_I(NR_PHY, "csi_params->symb_l0 = %i\n", csi_params->symb_l0); + LOG_I(NR_PHY, "csi_params->symb_l1 = %i\n", csi_params->symb_l1); + LOG_I(NR_PHY, "csi_params->cdm_type = %i\n", csi_params->cdm_type); + LOG_I(NR_PHY, "csi_params->freq_density = %i (0: dot5 (even RB), 1: dot5 (odd RB), 2: one, 3: three)\n", csi_params->freq_density); + LOG_I(NR_PHY, "csi_params->scramb_id = %i\n", csi_params->scramb_id); + LOG_I(NR_PHY, "csi_params->power_control_offset = %i\n", csi_params->power_control_offset); + LOG_I(NR_PHY, "csi_params->power_control_offset_ss = %i\n", csi_params->power_control_offset_ss); +#endif + + int dataF_offset = slot*frame_parms.samples_per_slot_wCP; + uint32_t **nr_gold_csi_rs = nr_csi_rs_info->nr_gold_csi_rs[slot]; + //*8(max allocation per RB)*2(QPSK)) + int csi_rs_length = frame_parms.N_RB_DL<<4; + int16_t mod_csi[frame_parms.symbols_per_slot][csi_rs_length>>1] __attribute__((aligned(16))); + uint16_t b = csi_params->freq_domain; + uint16_t n, p, k, l, mprime, na, kpn; uint8_t size, ports, kprime, lprime, i, gs; uint8_t j[16], k_n[6], koverline[16], loverline[16]; int found = 0; @@ -47,26 +81,17 @@ void nr_generate_csi_rs(PHY_VARS_gNB *gNB, uint8_t fi = 0; double rho, alpha; uint32_t beta = amp; + nr_csi_rs_info->csi_rs_generated_signal_bits = log2_approx(amp); AssertFatal(b!=0, "Invalid CSI frequency domain mapping: no bit selected in bitmap\n"); - // pre-computed for scrambling id equel to cell id - // if the scrambling id is not the cell id we need to re-initialize the rs - if (csi_params.scramb_id != cell_id) { - uint8_t reset; - uint32_t x1, x2; - uint32_t Nid = csi_params.scramb_id; - for (uint8_t symb=0; symbscramb_id != nr_csi_rs_info->csi_gold_init) { + nr_csi_rs_info->csi_gold_init = csi_params->scramb_id; + nr_init_csi_rs(&frame_parms, nr_csi_rs_info->nr_gold_csi_rs, csi_params->scramb_id); } - switch (csi_params.row) { + switch (csi_params->row) { // implementation of table 7.4.1.5.3-1 of 38.211 // lprime and kprime are the max value of l' and k' case 1: @@ -84,7 +109,7 @@ void nr_generate_csi_rs(PHY_VARS_gNB *gNB, } for (i=0; isymb_l0; koverline[i] = k_n[0] + (i<<2); } break; @@ -104,7 +129,7 @@ void nr_generate_csi_rs(PHY_VARS_gNB *gNB, } for (i=0; isymb_l0; koverline[i] = k_n[0]; } break; @@ -124,7 +149,7 @@ void nr_generate_csi_rs(PHY_VARS_gNB *gNB, } for (i=0; isymb_l0; koverline[i] = k_n[0]; } break; @@ -144,7 +169,7 @@ void nr_generate_csi_rs(PHY_VARS_gNB *gNB, } for (i=0; isymb_l0; koverline[i] = k_n[0] + (i<<1); } break; @@ -164,7 +189,7 @@ void nr_generate_csi_rs(PHY_VARS_gNB *gNB, } for (i=0; isymb_l0 + i; koverline[i] = k_n[0]; } break; @@ -183,7 +208,7 @@ void nr_generate_csi_rs(PHY_VARS_gNB *gNB, } for (i=0; isymb_l0; koverline[i] = k_n[i]; } break; @@ -202,7 +227,7 @@ void nr_generate_csi_rs(PHY_VARS_gNB *gNB, } for (i=0; i>1); + loverline[i] = csi_params->symb_l0 + (i>>1); koverline[i] = k_n[i%2]; } break; @@ -221,7 +246,7 @@ void nr_generate_csi_rs(PHY_VARS_gNB *gNB, } for (i=0; isymb_l0; koverline[i] = k_n[i]; } break; @@ -240,7 +265,7 @@ void nr_generate_csi_rs(PHY_VARS_gNB *gNB, } for (i=0; isymb_l0; koverline[i] = k_n[i]; } break; @@ -259,7 +284,7 @@ void nr_generate_csi_rs(PHY_VARS_gNB *gNB, } for (i=0; isymb_l0; koverline[i] = k_n[i]; } break; @@ -278,7 +303,7 @@ void nr_generate_csi_rs(PHY_VARS_gNB *gNB, } for (i=0; i>2); + loverline[i] = csi_params->symb_l0 + (i>>2); koverline[i] = k_n[i%4]; } break; @@ -297,7 +322,7 @@ void nr_generate_csi_rs(PHY_VARS_gNB *gNB, } for (i=0; isymb_l0; koverline[i] = k_n[i]; } break; @@ -317,9 +342,9 @@ void nr_generate_csi_rs(PHY_VARS_gNB *gNB, for (i=0; isymb_l0 + i/3; else - loverline[i] = csi_params.symb_l1 + i/9; + loverline[i] = csi_params->symb_l1 + i/9; koverline[i] = k_n[i%3]; } break; @@ -339,9 +364,9 @@ void nr_generate_csi_rs(PHY_VARS_gNB *gNB, for (i=0; isymb_l0; else - loverline[i] = csi_params.symb_l1; + loverline[i] = csi_params->symb_l1; koverline[i] = k_n[i%3]; } break; @@ -360,7 +385,7 @@ void nr_generate_csi_rs(PHY_VARS_gNB *gNB, } for (i=0; isymb_l0; koverline[i] = k_n[i]; } break; @@ -380,9 +405,9 @@ void nr_generate_csi_rs(PHY_VARS_gNB *gNB, for (i=0; i>2); + loverline[i] = csi_params->symb_l0 + (i>>2); else - loverline[i] = csi_params.symb_l1 + (i/12); + loverline[i] = csi_params->symb_l1 + (i/12); koverline[i] = k_n[i%4]; } break; @@ -402,9 +427,9 @@ void nr_generate_csi_rs(PHY_VARS_gNB *gNB, for (i=0; isymb_l0; else - loverline[i] = csi_params.symb_l1; + loverline[i] = csi_params->symb_l1; koverline[i] = k_n[i%4]; } break; @@ -423,17 +448,17 @@ void nr_generate_csi_rs(PHY_VARS_gNB *gNB, } for (i=0; isymb_l0; koverline[i] = k_n[i]; } break; default: - AssertFatal(0==1, "Row %d is not valid for CSI Table 7.4.1.5.3-1\n", csi_params.row); + AssertFatal(0==1, "Row %d is not valid for CSI Table 7.4.1.5.3-1\n", csi_params->row); } #ifdef NR_CSIRS_DEBUG - printf(" row %d, n. of ports %d\n k' ",csi_params.row,ports); + printf(" row %d, n. of ports %d\n k' ",csi_params->row,ports); for (kp=0; kp<=kprime; kp++) printf("%d, ",kp); printf("l' "); @@ -450,7 +475,7 @@ void nr_generate_csi_rs(PHY_VARS_gNB *gNB, // setting the frequency density from its index - switch (csi_params.freq_density) { + switch (csi_params->freq_density) { case 0: rho = 0.5; @@ -482,7 +507,7 @@ void nr_generate_csi_rs(PHY_VARS_gNB *gNB, #endif // CDM group size from CDM type index - switch (csi_params.cdm_type) { + switch (csi_params->cdm_type) { case 0: gs = 1; @@ -504,39 +529,31 @@ void nr_generate_csi_rs(PHY_VARS_gNB *gNB, AssertFatal(0==1, "Invalid cdm type index for CSI\n"); } - // according to 38.214 5.2.2.3.1 last paragraph - if (csi_params.start_rb (csi_params.bwp_start+csi_params.bwp_size-csi_start)) - csi_bw = csi_params.bwp_start+csi_params.bwp_size-csi_start; - else - csi_bw = csi_params.nr_of_rbs; - + uint16_t csi_length; if (rho < 1) { - if (csi_params.freq_density == 0) - csi_length = (((csi_bw + csi_start)>>1)<>1)<freq_density == 0) { + csi_length = (((csi_params->start_rb + csi_params->nr_of_rbs)>>1)<start_rb + csi_params->nr_of_rbs)>>1)<start_rb + csi_params->nr_of_rbs))<start_rb, csi_params->nr_of_rbs, csi_length); #endif // TRS - if (csi_params.csi_type == 0) { + if (csi_params->csi_type == 0) { // ??? } // NZP CSI RS - if (csi_params.csi_type == 1) { + if (csi_params->csi_type == 1) { // assuming amp is the amplitude of SSB channels - switch (csi_params.power_control_offset_ss) { + switch (csi_params->power_control_offset_ss) { case 0: beta = (amp*ONE_OVER_SQRT2_Q15)>>15; break; @@ -554,15 +571,15 @@ void nr_generate_csi_rs(PHY_VARS_gNB *gNB, } for (lp=0; lp<=lprime; lp++){ - symb = csi_params.symb_l0; - nr_modulation(gold_csi_rs[symb+lp], csi_length, DMRS_MOD_ORDER, mod_csi[symb+lp]); - if ((csi_params.row == 5) || (csi_params.row == 7) || (csi_params.row == 11) || (csi_params.row == 13) || (csi_params.row == 16)) - nr_modulation(gold_csi_rs[symb+1], csi_length, DMRS_MOD_ORDER, mod_csi[symb+1]); - if ((csi_params.row == 14) || (csi_params.row == 13) || (csi_params.row == 16) || (csi_params.row == 17)) { - symb = csi_params.symb_l1; - nr_modulation(gold_csi_rs[symb+lp], csi_length, DMRS_MOD_ORDER, mod_csi[symb+lp]); - if ((csi_params.row == 13) || (csi_params.row == 16)) - nr_modulation(gold_csi_rs[symb+1], csi_length, DMRS_MOD_ORDER, mod_csi[symb+1]); + symb = csi_params->symb_l0; + nr_modulation(nr_gold_csi_rs[symb+lp], csi_length, DMRS_MOD_ORDER, mod_csi[symb+lp]); + if ((csi_params->row == 5) || (csi_params->row == 7) || (csi_params->row == 11) || (csi_params->row == 13) || (csi_params->row == 16)) + nr_modulation(nr_gold_csi_rs[symb+1], csi_length, DMRS_MOD_ORDER, mod_csi[symb+1]); + if ((csi_params->row == 14) || (csi_params->row == 13) || (csi_params->row == 16) || (csi_params->row == 17)) { + symb = csi_params->symb_l1; + nr_modulation(nr_gold_csi_rs[symb+lp], csi_length, DMRS_MOD_ORDER, mod_csi[symb+lp]); + if ((csi_params->row == 13) || (csi_params->row == 16)) + nr_modulation(nr_gold_csi_rs[symb+1], csi_length, DMRS_MOD_ORDER, mod_csi[symb+1]); } } } @@ -570,14 +587,14 @@ void nr_generate_csi_rs(PHY_VARS_gNB *gNB, uint16_t start_sc = frame_parms.first_carrier_offset; // resource mapping according to 38.211 7.4.1.5.3 - for (n=csi_start; n<(csi_start+csi_bw); n++) { - if ( (csi_params.freq_density > 1) || (csi_params.freq_density == (n%2))) { // for freq density 0.5 checks if even or odd RB + for (n=csi_params->start_rb; n<(csi_params->start_rb+csi_params->nr_of_rbs); n++) { + if ( (csi_params->freq_density > 1) || (csi_params->freq_density == (n%2))) { // for freq density 0.5 checks if even or odd RB for (int ji=0; jicsi_type == 2) { + ((int16_t*)dataF[p])[((l*frame_parms.ofdm_symbol_size + k)<<1)+(2*dataF_offset)] = 0; + ((int16_t*)dataF[p])[((l*frame_parms.ofdm_symbol_size + k)<<1)+1+(2*dataF_offset)] = 0; } else { - ((int16_t*)txdataF[p])[((l*frame_parms.ofdm_symbol_size + k)<<1)+(2*txdataF_offset)] = (beta*wt*wf*mod_csi[l][mprime<<1]) >> 15; - ((int16_t*)txdataF[p])[((l*frame_parms.ofdm_symbol_size + k)<<1)+1+(2*txdataF_offset)] = (beta*wt*wf*mod_csi[l][(mprime<<1) + 1]) >> 15; + ((int16_t*)dataF[p])[((l*frame_parms.ofdm_symbol_size + k)<<1)+(2*dataF_offset)] = (beta*wt*wf*mod_csi[l][mprime<<1]) >> 15; + ((int16_t*)dataF[p])[((l*frame_parms.ofdm_symbol_size + k)<<1)+1+(2*dataF_offset)] = (beta*wt*wf*mod_csi[l][(mprime<<1) + 1]) >> 15; } #ifdef NR_CSIRS_DEBUG - printf("l,k (%d %d) seq. index %d \t port %d \t (%d,%d)\n",l,k,mprime,p+3000, - ((int16_t*)txdataF[p])[((l*frame_parms.ofdm_symbol_size + k)<<1)+(2*txdataF_offset)], - ((int16_t*)txdataF[p])[((l*frame_parms.ofdm_symbol_size + k)<<1)+1+(2*txdataF_offset)]); + printf("l,k (%d,%d) seq. index %d \t port %d \t (%d,%d)\n",l,k,mprime,p+3000, + ((int16_t*)dataF[p])[((l*frame_parms.ofdm_symbol_size + k)<<1)+(2*dataF_offset)], + ((int16_t*)dataF[p])[((l*frame_parms.ofdm_symbol_size + k)<<1)+1+(2*dataF_offset)]); #endif } } - } + } } } - } + } + nr_csi_rs_info->N_cdm_groups = size; + nr_csi_rs_info->CDM_group_size = gs; + nr_csi_rs_info->kprime = kprime; + nr_csi_rs_info->lprime = lprime; + nr_csi_rs_info->N_ports = ports; + memcpy(nr_csi_rs_info->j,j,16*sizeof(uint8_t)); + memcpy(nr_csi_rs_info->koverline,koverline,16*sizeof(uint8_t)); + memcpy(nr_csi_rs_info->loverline,loverline,16*sizeof(uint8_t)); + +#ifdef NR_CSIRS_DEBUG + LOG_I(NR_PHY, "nr_csi_rs_info->N_ports = %d\n", nr_csi_rs_info->N_ports); + LOG_I(NR_PHY, "nr_csi_rs_info->N_cdm_groups = %d\n", nr_csi_rs_info->N_cdm_groups); + LOG_I(NR_PHY, "nr_csi_rs_info->CDM_group_size = %d\n", nr_csi_rs_info->CDM_group_size); + LOG_I(NR_PHY, "nr_csi_rs_info->kprime = %d\n", nr_csi_rs_info->kprime); + LOG_I(NR_PHY, "nr_csi_rs_info->lprime = %d\n", nr_csi_rs_info->lprime); + for(int ji=0; jiN_cdm_groups; ji++) { + LOG_I(NR_PHY, "(CDM group %d) j = %d, koverline = %d, loverline = %d\n", ji, nr_csi_rs_info->j[ji], nr_csi_rs_info->koverline[ji], nr_csi_rs_info->loverline[ji]); + } +#endif } diff --git a/openair1/PHY/NR_TRANSPORT/nr_dci.c b/openair1/PHY/NR_TRANSPORT/nr_dci.c index 0af56ba706..d70d991e7b 100644 --- a/openair1/PHY/NR_TRANSPORT/nr_dci.c +++ b/openair1/PHY/NR_TRANSPORT/nr_dci.c @@ -66,13 +66,13 @@ void nr_pdcch_scrambling(uint32_t *in, } } -void nr_generate_dci(nfapi_nr_dl_tti_pdcch_pdu_rel15_t *pdcch_pdu_rel15, - uint32_t **gold_pdcch_dmrs, +void nr_generate_dci(PHY_VARS_gNB *gNB, + nfapi_nr_dl_tti_pdcch_pdu_rel15_t *pdcch_pdu_rel15, int32_t *txdataF, int16_t amp, - NR_DL_FRAME_PARMS *frame_parms) { + NR_DL_FRAME_PARMS *frame_parms, + int slot) { - int16_t mod_dmrs[NR_MAX_CSET_DURATION][NR_MAX_PDCCH_DMRS_LENGTH>>1] __attribute__((aligned(16))); // 3 for the max coreset duration uint16_t cset_start_sc; uint8_t cset_start_symb, cset_nsymb; int k,l,k_prime,dci_idx, dmrs_idx; @@ -81,13 +81,14 @@ void nr_generate_dci(nfapi_nr_dl_tti_pdcch_pdu_rel15_t *pdcch_pdu_rel15, int rb_offset; int n_rb; - // compute rb_offset and n_prb based on frequency allocation nr_cce_t cce_list[MAX_DCI_CORESET][NR_MAX_PDCCH_AGG_LEVEL]; - nr_fill_cce_list(cce_list,0,pdcch_pdu_rel15); + nr_fill_cce_list(cce_list, pdcch_pdu_rel15); get_coreset_rballoc(pdcch_pdu_rel15->FreqDomainResource,&n_rb,&rb_offset); cset_start_sc = frame_parms->first_carrier_offset + (pdcch_pdu_rel15->BWPStart + rb_offset) * NR_NB_SC_PER_RB; + int16_t mod_dmrs[pdcch_pdu_rel15->StartSymbolIndex+pdcch_pdu_rel15->DurationSymbols][(n_rb+rb_offset)*6] __attribute__((aligned(16))); // 3 for the max coreset duration + for (int d=0;dnumDlDci;d++) { /*The coreset is initialised * in frequency: the first subcarrier is obtained by adding the first CRB overlapping the SSB and the rb_offset for coreset 0 @@ -95,30 +96,37 @@ void nr_generate_dci(nfapi_nr_dl_tti_pdcch_pdu_rel15_t *pdcch_pdu_rel15, * in time: by its first slot and its first symbol*/ const nfapi_nr_dl_dci_pdu_t *dci_pdu = &pdcch_pdu_rel15->dci_pdu[d]; + if(dci_pdu->ScramblingId != gNB->pdcch_gold_init) { + gNB->pdcch_gold_init = dci_pdu->ScramblingId; + nr_init_pdcch_dmrs(gNB, dci_pdu->ScramblingId); + } + + uint32_t **gold_pdcch_dmrs = gNB->nr_gold_pdcch_dmrs[slot]; + cset_start_symb = pdcch_pdu_rel15->StartSymbolIndex; cset_nsymb = pdcch_pdu_rel15->DurationSymbols; dci_idx = 0; - LOG_D(PHY, "Coreset rb_offset %d, nb_rb %d BWP Start %d\n",rb_offset,n_rb,pdcch_pdu_rel15->BWPStart); - LOG_D(PHY, "Coreset starting subcarrier %d on symbol %d (%d symbols)\n", cset_start_sc, cset_start_symb, cset_nsymb); + LOG_D(PHY, "pdcch: Coreset rb_offset %d, nb_rb %d BWP Start %d\n",rb_offset,n_rb,pdcch_pdu_rel15->BWPStart); + LOG_D(PHY, "pdcch: Coreset starting subcarrier %d on symbol %d (%d symbols)\n", cset_start_sc, cset_start_symb, cset_nsymb); // DMRS length is per OFDM symbol uint32_t dmrs_length = n_rb*6; //2(QPSK)*3(per RB)*6(REG per CCE) uint32_t encoded_length = dci_pdu->AggregationLevel*108; //2(QPSK)*9(per RB)*6(REG per CCE) LOG_D(PHY, "DL_DCI : rb_offset %d, nb_rb %d, DMRS length per symbol %d\t DCI encoded length %d (precoder_granularity %d,reg_mapping %d),Scrambling_Id %d,ScramblingRNTI %x,PayloadSizeBits %d\n", - rb_offset, n_rb,dmrs_length, encoded_length,pdcch_pdu_rel15->precoderGranularity,pdcch_pdu_rel15->CceRegMappingType, - dci_pdu->ScramblingId,dci_pdu->ScramblingRNTI,dci_pdu->PayloadSizeBits); + rb_offset, n_rb,dmrs_length, encoded_length,pdcch_pdu_rel15->precoderGranularity,pdcch_pdu_rel15->CceRegMappingType, + dci_pdu->ScramblingId,dci_pdu->ScramblingRNTI,dci_pdu->PayloadSizeBits); dmrs_length += rb_offset*6; // To accommodate more DMRS symbols in case of rb offset /// DMRS QPSK modulation for (int symb=cset_start_symb; symbDurationSymbols; symb++) { - + nr_modulation(gold_pdcch_dmrs[symb], dmrs_length, DMRS_MOD_ORDER, mod_dmrs[symb]); //Qm = 2 as DMRS is QPSK modulated #ifdef DEBUG_PDCCH_DMRS if(dci_pdu->RNTI!=0xFFFF) { - for (int i=0; i>1; i++) - printf("symb %d i %d %p gold seq 0x%08x mod_dmrs %d %d\n", symb, i, - &gold_pdcch_dmrs[symb][i>>5],gold_pdcch_dmrs[symb][i>>5], mod_dmrs[symb][i<<1], mod_dmrs[symb][(i<<1)+1] ); - } + for (int i=0; i>1; i++) + printf("symb %d i %d %p gold seq 0x%08x mod_dmrs %d %d\n", symb, i, + &gold_pdcch_dmrs[symb][i>>5],gold_pdcch_dmrs[symb][i>>5], mod_dmrs[symb][i<<1], mod_dmrs[symb][(i<<1)+1] ); + } #endif } @@ -133,6 +141,7 @@ void nr_generate_dci(nfapi_nr_dl_tti_pdcch_pdu_rel15_t *pdcch_pdu_rel15, polar_encoder_fast((uint64_t*)dci_pdu->Payload, (void*)encoder_output, n_RNTI, 1, NR_POLAR_DCI_MESSAGE_TYPE, dci_pdu->PayloadSizeBits, dci_pdu->AggregationLevel); #ifdef DEBUG_CHANNEL_CODING +//debug dump dci printf("polar rnti %x,length %d, L %d\n",n_RNTI, dci_pdu->PayloadSizeBits,pdcch_pdu_rel15->dci_pdu->AggregationLevel); printf("DCI PDU: [0]->0x%lx \t [1]->0x%lx\n", ((uint64_t*)dci_pdu->Payload)[0], ((uint64_t*)dci_pdu->Payload)[1]); @@ -169,8 +178,10 @@ void nr_generate_dci(nfapi_nr_dl_tti_pdcch_pdu_rel15_t *pdcch_pdu_rel15, // Get cce_list indices by reg_idx in ascending order int reg_list_index = 0; + int N_regs = n_rb*pdcch_pdu_rel15->DurationSymbols; // nb of REGs per coreset + int N_cces = N_regs / NR_NB_REG_PER_CCE; // nb of cces in coreset int reg_list_order[NR_MAX_PDCCH_AGG_LEVEL] = {}; - for (int p = 0; p < NR_MAX_PDCCH_AGG_LEVEL; p++) { + for (int p = 0; p < N_cces; p++) { for(int p2 = 0; p2 < dci_pdu->AggregationLevel; p2++) { if(cce_list[d][p2].reg_list[0].reg_idx == p * NR_NB_REG_PER_CCE) { reg_list_order[reg_list_index] = p2; @@ -182,24 +193,25 @@ void nr_generate_dci(nfapi_nr_dl_tti_pdcch_pdu_rel15_t *pdcch_pdu_rel15, /*Mapping the encoded DCI along with the DMRS */ for(int symbol_idx = 0; symbol_idx < pdcch_pdu_rel15->DurationSymbols; symbol_idx++) { - for (int cce_count = 0; cce_count < dci_pdu->AggregationLevel; cce_count+=pdcch_pdu_rel15->DurationSymbols) { + for (int cce_count = 0; cce_count < dci_pdu->AggregationLevel; cce_count++) { int8_t cce_idx = reg_list_order[cce_count]; - for (int reg_in_cce_idx = 0; reg_in_cce_idx < NR_NB_REG_PER_CCE; reg_in_cce_idx++) { + for (int reg_in_cce_idx = 0; reg_in_cce_idx < NR_NB_REG_PER_CCE; reg_in_cce_idx+=pdcch_pdu_rel15->DurationSymbols) { k = cset_start_sc + cce_list[d][cce_idx].reg_list[reg_in_cce_idx].start_sc_idx; - + LOG_D(PHY,"CCE %d REG %d k %d\n",cce_idx,reg_in_cce_idx+symbol_idx,k); if (k >= frame_parms->ofdm_symbol_size) k -= frame_parms->ofdm_symbol_size; l = cset_start_symb + symbol_idx; // dmrs index depends on reference point for k according to 38.211 7.4.1.3.2 + int eff_reg_idx = cce_list[d][cce_idx].reg_list[reg_in_cce_idx].reg_idx/pdcch_pdu_rel15->DurationSymbols; if (pdcch_pdu_rel15->CoreSetType == NFAPI_NR_CSET_CONFIG_PDCCH_CONFIG) - dmrs_idx = (cce_list[d][cce_idx].reg_list[reg_in_cce_idx].reg_idx) * 3; + dmrs_idx = eff_reg_idx * 3; else - dmrs_idx = (cce_list[d][cce_idx].reg_list[reg_in_cce_idx].reg_idx + rb_offset) * 3; + dmrs_idx = (eff_reg_idx + rb_offset) * 3; k_prime = 0; @@ -248,15 +260,16 @@ void nr_generate_dci(nfapi_nr_dl_tti_pdcch_pdu_rel15_t *pdcch_pdu_rel15, } void nr_generate_dci_top(processingData_L1tx_t *msgTx, - uint32_t **gold_pdcch_dmrs, + int slot, int32_t *txdataF, int16_t amp, NR_DL_FRAME_PARMS *frame_parms) { + for (int i=0; inum_ul_pdcch; i++) - nr_generate_dci(&msgTx->ul_pdcch_pdu[i].pdcch_pdu.pdcch_pdu_rel15,gold_pdcch_dmrs,txdataF,amp,frame_parms); + nr_generate_dci(msgTx->gNB,&msgTx->ul_pdcch_pdu[i].pdcch_pdu.pdcch_pdu_rel15,txdataF,amp,frame_parms,slot); for (int i=0; inum_dl_pdcch; i++) - nr_generate_dci(&msgTx->pdcch_pdu[i].pdcch_pdu_rel15,gold_pdcch_dmrs,txdataF,amp,frame_parms); + nr_generate_dci(msgTx->gNB,&msgTx->pdcch_pdu[i].pdcch_pdu_rel15,txdataF,amp,frame_parms,slot); } diff --git a/openair1/PHY/NR_TRANSPORT/nr_dci.h b/openair1/PHY/NR_TRANSPORT/nr_dci.h index bdc8509d12..0bf6932bb5 100644 --- a/openair1/PHY/NR_TRANSPORT/nr_dci.h +++ b/openair1/PHY/NR_TRANSPORT/nr_dci.h @@ -30,7 +30,7 @@ uint16_t nr_get_dci_size(nfapi_nr_dci_format_e format, uint16_t N_RB); void nr_generate_dci_top(processingData_L1tx_t *msgTx, - uint32_t **gold_pdcch_dmrs, + int slot, int32_t *txdataF, int16_t amp, NR_DL_FRAME_PARMS *frame_parms); @@ -55,6 +55,6 @@ void nr_fill_ul_dci(PHY_VARS_gNB *gNB, int slot, nfapi_nr_ul_dci_request_pdus_t *pdcch_pdu); -void nr_fill_cce_list(nr_cce_t cce_list[MAX_DCI_CORESET][NR_MAX_PDCCH_AGG_LEVEL], uint8_t m,nfapi_nr_dl_tti_pdcch_pdu_rel15_t *pdcch_pdu_rel15); +void nr_fill_cce_list(nr_cce_t cce_list[MAX_DCI_CORESET][NR_MAX_PDCCH_AGG_LEVEL], nfapi_nr_dl_tti_pdcch_pdu_rel15_t *pdcch_pdu_rel15); #endif //__PHY_NR_TRANSPORT_DCI__H diff --git a/openair1/PHY/NR_TRANSPORT/nr_dci_tools.c b/openair1/PHY/NR_TRANSPORT/nr_dci_tools.c index 8d5eb4a660..e9d3010ce7 100644 --- a/openair1/PHY/NR_TRANSPORT/nr_dci_tools.c +++ b/openair1/PHY/NR_TRANSPORT/nr_dci_tools.c @@ -37,89 +37,8 @@ #include "nr_dlsch.h" -/* - Original version to keep code for Y that needs to be moved to MAC -void nr_fill_cce_list(PHY_VARS_gNB *gNB, uint16_t n_shift, uint8_t m) { - - nr_cce_t* cce; - nr_reg_t* reg; - nfapi_nr_dl_config_pdcch_pdu_rel15_t* pdcch_pdu = gNB->pdcch_pdu.pdcch; - - uint8_t L = dci_alloc->L; - uint8_t bsize = pdcch_params->reg_bundle_size; - uint8_t R = pdcch_params->interleaver_size; - uint16_t N_reg = pdcch_params->n_rb * pdcch_params->n_symb; - uint16_t Y, N_cce, M_s_max, n_CI=0, tmp, C=0; - uint16_t n_RNTI = (pdcch_params->search_space_type == NFAPI_NR_SEARCH_SPACE_TYPE_UE_SPECIFIC)? pdcch_params->rnti:0; - uint32_t A[3]={39827,39829,39839}; - - if (pdcch_params->config_type == NFAPI_NR_CSET_CONFIG_MIB_SIB1) - AssertFatal(L>=4, "Invalid aggregation level for SIB1 configured PDCCH %d\n", L); - - N_cce = N_reg / NR_NB_REG_PER_CCE; - //Max number of candidates per aggregation level -- SIB1 configured search space only - M_s_max = (L==4)?4:(L==8)?2:1; - - if (pdcch_params->search_space_type == NFAPI_NR_SEARCH_SPACE_TYPE_COMMON) - Y = 0; - else { //NFAPI_NR_SEARCH_SPACE_TYPE_UE_SPECIFIC - Y = (A[0]*n_RNTI)%65537; // Candidate 0, antenna port 0 - } - - if (pdcch_params->cr_mapping_type == NFAPI_NR_CCE_REG_MAPPING_INTERLEAVED) { - uint16_t assertFatalCond = (N_reg%(bsize*R)); - AssertFatal(assertFatalCond == 0,"CCE to REG interleaving: Invalid configuration leading to non integer C (N_reg %us, bsize %d R %d)\n",N_reg, bsize, R); - C = N_reg/(bsize*R); - } - - tmp = L * (( Y + (m*N_cce)/(L*M_s_max) + n_CI ) % CEILIDIV(N_cce,L)); - - LOG_D(PHY, "CCE list generation for candidate %d: bundle size %d ilv size %d tmp %d\n", m, bsize, R, tmp); - for (uint8_t cce_idx=0; cce_idxcce_list[cce_idx]; - cce->cce_idx = tmp + cce_idx; - LOG_D(PHY, "cce_idx %d\n", cce->cce_idx); - - if (pdcch_params->cr_mapping_type == NFAPI_NR_CCE_REG_MAPPING_INTERLEAVED) { - LOG_D(PHY, "Interleaved CCE to REG mapping\n"); - uint8_t j = cce->cce_idx, j_prime; - uint8_t r,c,idx; - - for (uint8_t bundle_idx=0; bundle_idxreg_list[reg_idx]; - reg->reg_idx = bsize*idx + reg_idx; - reg->start_sc_idx = (reg->reg_idx/pdcch_params->n_symb) * NR_NB_SC_PER_RB; - reg->symb_idx = reg->reg_idx % pdcch_params->n_symb; - LOG_D(PHY, "reg %d symbol %d start subcarrier %d\n", reg->reg_idx, reg->symb_idx, reg->start_sc_idx); - } - } - } - else { // NFAPI_NR_CCE_REG_MAPPING_NON_INTERLEAVED - LOG_D(PHY, "Non interleaved CCE to REG mapping\n"); - for (uint8_t reg_idx=0; reg_idxreg_list[reg_idx]; - reg->reg_idx = cce->cce_idx*NR_NB_REG_PER_CCE + reg_idx; - reg->start_sc_idx = (reg->reg_idx/pdcch_params->n_symb) * NR_NB_SC_PER_RB; - reg->symb_idx = reg->reg_idx % pdcch_params->n_symb; - LOG_D(PHY, "reg %d symbol %d start subcarrier %d\n", reg->reg_idx, reg->symb_idx, reg->start_sc_idx); - } - - } - - } -} - -*/ - -void nr_fill_cce_list(nr_cce_t cce_list[MAX_DCI_CORESET][NR_MAX_PDCCH_AGG_LEVEL], uint8_t m, nfapi_nr_dl_tti_pdcch_pdu_rel15_t *pdcch_pdu_rel15) { +void nr_fill_cce_list(nr_cce_t cce_list[MAX_DCI_CORESET][NR_MAX_PDCCH_AGG_LEVEL], nfapi_nr_dl_tti_pdcch_pdu_rel15_t *pdcch_pdu_rel15) { nr_cce_t* cce; nr_reg_t* reg; @@ -128,71 +47,51 @@ void nr_fill_cce_list(nr_cce_t cce_list[MAX_DCI_CORESET][NR_MAX_PDCCH_AGG_LEVEL] int R = pdcch_pdu_rel15->InterleaverSize; int n_shift = pdcch_pdu_rel15->ShiftIndex; - //Max number of candidates per aggregation level -- SIB1 configured search space only - int n_rb,rb_offset; get_coreset_rballoc(pdcch_pdu_rel15->FreqDomainResource,&n_rb,&rb_offset); - - int N_reg = n_rb; - int C=-1; - - AssertFatal(N_reg > 0,"N_reg cannot be 0\n"); - for (int d=0;dnumDlDci;d++) { + int L = pdcch_pdu_rel15->dci_pdu[d].AggregationLevel; + int dur = pdcch_pdu_rel15->DurationSymbols; + int N_regs = n_rb*dur; // nb of REGs per coreset + AssertFatal(N_regs > 0,"N_reg cannot be 0\n"); if (pdcch_pdu_rel15->CoreSetType == NFAPI_NR_CSET_CONFIG_MIB_SIB1) AssertFatal(L>=4, "Invalid aggregation level for SIB1 configured PDCCH %d\n", L); - + + int C = 0; + if (pdcch_pdu_rel15->CceRegMappingType == NFAPI_NR_CCE_REG_MAPPING_INTERLEAVED) { - uint16_t assertFatalCond = (N_reg%(bsize*R)); - AssertFatal(assertFatalCond == 0,"CCE to REG interleaving: Invalid configuration leading to non integer C (N_reg %us, bsize %d R %d)\n",N_reg, bsize, R); - C = N_reg/(bsize*R); + uint16_t assertFatalCond = (N_regs%(bsize*R)); + AssertFatal(assertFatalCond == 0,"CCE to REG interleaving: Invalid configuration leading to non integer C (N_reg %us, bsize %d R %d)\n",N_regs, bsize, R); + C = N_regs/(bsize*R); } - - if (pdcch_pdu_rel15->dci_pdu[d].RNTI != 0xFFFF) LOG_D(PHY, "CCE list generation for candidate %d: bundle size %d ilv size %d CceIndex %d\n", m, bsize, R, pdcch_pdu_rel15->dci_pdu[d].CceIndex); + + if (pdcch_pdu_rel15->dci_pdu[d].RNTI != 0xFFFF) + LOG_D(PHY, "CCE list generation for candidate %d: bundle size %d ilv size %d CceIndex %d\n", d, bsize, R, pdcch_pdu_rel15->dci_pdu[d].CceIndex); + for (uint8_t cce_idx=0; cce_idxcce_idx = pdcch_pdu_rel15->dci_pdu[d].CceIndex + cce_idx; LOG_D(PHY, "cce_idx %d\n", cce->cce_idx); - - if (pdcch_pdu_rel15->CceRegMappingType == NFAPI_NR_CCE_REG_MAPPING_INTERLEAVED) { - LOG_D(PHY, "Interleaved CCE to REG mapping\n"); - uint8_t j = cce->cce_idx, j_prime; - uint8_t r,c,idx; - - for (uint8_t bundle_idx=0; bundle_idxreg_list[reg_idx]; - reg->reg_idx = bsize*idx + reg_idx; - reg->start_sc_idx = reg->reg_idx * NR_NB_SC_PER_RB; - reg->symb_idx = 0; - LOG_D(PHY, "reg %d symbol %d start subcarrier %d\n", reg->reg_idx, reg->symb_idx, reg->start_sc_idx); - } - } - } - else { // NFAPI_NR_CCE_REG_MAPPING_NON_INTERLEAVED - LOG_D(PHY, "Non interleaved CCE to REG mapping\n"); - for (uint8_t reg_idx=0; reg_idxcce_idx; + for (int k=6*j/bsize; k<(6*j/bsize+6/bsize); k++) { // loop over REG bundles + + int f = cce_to_reg_interleaving(R, k, n_shift, C, bsize, N_regs); + + for (uint8_t reg_idx=0; reg_idxreg_list[reg_idx]; - reg->reg_idx = cce->cce_idx*NR_NB_REG_PER_CCE + reg_idx; - reg->start_sc_idx = reg->reg_idx * NR_NB_SC_PER_RB; - reg->symb_idx = 0; + reg->reg_idx = bsize*f + reg_idx; + reg->start_sc_idx = (reg->reg_idx/dur) * NR_NB_SC_PER_RB; + reg->symb_idx = reg_idx%dur; LOG_D(PHY, "reg %d symbol %d start subcarrier %d\n", reg->reg_idx, reg->symb_idx, reg->start_sc_idx); } - } - } } } diff --git a/openair1/PHY/NR_TRANSPORT/nr_dlsch.c b/openair1/PHY/NR_TRANSPORT/nr_dlsch.c index 37ef5fb207..45125c8db4 100644 --- a/openair1/PHY/NR_TRANSPORT/nr_dlsch.c +++ b/openair1/PHY/NR_TRANSPORT/nr_dlsch.c @@ -58,7 +58,6 @@ void nr_generate_pdsch(processingData_L1tx_t *msgTx, PHY_VARS_gNB *gNB = msgTx->gNB; NR_gNB_DLSCH_t *dlsch; - uint32_t ***pdsch_dmrs = gNB->nr_gold_pdsch_dmrs[slot]; int32_t** txdataF = gNB->common_vars.txdataF; int16_t amp = AMP; int xOverhead = 0; @@ -79,14 +78,14 @@ void nr_generate_pdsch(processingData_L1tx_t *msgTx, NR_DL_gNB_HARQ_t *harq = &dlsch->harq_process; nfapi_nr_dl_tti_pdsch_pdu_rel15_t *rel15 = &harq->pdsch_pdu.pdsch_pdu_rel15; - uint32_t scrambled_output[NR_MAX_NB_CODEWORDS][NR_MAX_PDSCH_ENCODED_LENGTH>>5]; int16_t **mod_symbs = (int16_t**)dlsch->mod_symbs; int16_t **tx_layers = (int16_t**)dlsch->txdataF; - int16_t **txdataF_precoding = (int16_t**)dlsch->txdataF_precoding; int8_t Wf[2], Wt[2], l0, l_prime, l_overline, delta; uint8_t dmrs_Type = rel15->dmrsConfigType; int nb_re_dmrs; uint16_t n_dmrs; + LOG_D(PHY,"pdsch: BWPStart %d, BWPSize %d, rbStart %d, rbsize %d\n", + rel15->BWPStart,rel15->BWPSize,rel15->rbStart,rel15->rbSize); if (rel15->dmrsConfigType==NFAPI_NR_DMRS_TYPE1) { nb_re_dmrs = 6*rel15->numDmrsCdmGrpsNoData; } @@ -95,6 +94,12 @@ void nr_generate_pdsch(processingData_L1tx_t *msgTx, } n_dmrs = (rel15->BWPStart+rel15->rbStart+rel15->rbSize)*nb_re_dmrs; + if(rel15->dlDmrsScramblingId != gNB->pdsch_gold_init[rel15->SCID]) { + gNB->pdsch_gold_init[rel15->SCID] = rel15->dlDmrsScramblingId; + nr_init_pdsch_dmrs(gNB, rel15->SCID, rel15->dlDmrsScramblingId); + } + + uint32_t ***pdsch_dmrs = gNB->nr_gold_pdsch_dmrs[slot]; uint16_t dmrs_symbol_map = rel15->dlDmrsSymbPos;//single DMRS: 010000100 Double DMRS 110001100 uint8_t dmrs_len = get_num_dmrs(rel15->dlDmrsSymbPos); uint16_t nb_re = ((12*rel15->NrOfSymbols)-nb_re_dmrs*dmrs_len-xOverhead)*rel15->rbSize*rel15->nrOfLayers; @@ -121,12 +126,12 @@ void nr_generate_pdsch(processingData_L1tx_t *msgTx, /// CRC, coding, interleaving and rate matching AssertFatal(harq->pdu!=NULL,"harq->pdu is null\n"); - unsigned char output[rel15->rbSize * NR_SYMBOLS_PER_SLOT * NR_NB_SC_PER_RB * 8 * NR_MAX_NB_LAYERS] __attribute__((aligned(32))); - bzero(output,rel15->rbSize * NR_SYMBOLS_PER_SLOT * NR_NB_SC_PER_RB * 8 * NR_MAX_NB_LAYERS); + unsigned char output[rel15->rbSize * NR_SYMBOLS_PER_SLOT * NR_NB_SC_PER_RB * Qm * rel15->nrOfLayers] __attribute__((aligned(32))); + bzero(output,rel15->rbSize * NR_SYMBOLS_PER_SLOT * NR_NB_SC_PER_RB * Qm * rel15->nrOfLayers); start_meas(dlsch_encoding_stats); if (nr_dlsch_encoding(gNB, - harq->pdu, frame, slot, dlsch, frame_parms,output,tinput,tprep,tparity,toutput, + frame, slot, harq, frame_parms,output,tinput,tprep,tparity,toutput, dlsch_rate_matching_stats, dlsch_interleaving_stats, dlsch_segmentation_stats) == -1) @@ -147,70 +152,69 @@ void nr_generate_pdsch(processingData_L1tx_t *msgTx, } printf("\n"); #endif - - - - /// scrambling - start_meas(dlsch_scrambling_stats); - for (int q=0; qNrOfCodewords; q++) - memset((void*)scrambled_output[q], 0, (encoded_length>>5)*sizeof(uint32_t)); - for (int q=0; qNrOfCodewords; q++) + + for (int q=0; qNrOfCodewords; q++) { + /// scrambling + start_meas(dlsch_scrambling_stats); + uint32_t scrambled_output[(encoded_length>>5)+4]; // modulator acces by 4 bytes in some cases + memset(scrambled_output, 0, sizeof(scrambled_output)); + if ( encoded_length > rel15->rbSize * NR_SYMBOLS_PER_SLOT * NR_NB_SC_PER_RB * Qm * rel15->nrOfLayers) abort(); nr_pdsch_codeword_scrambling(output, encoded_length, q, rel15->dataScramblingId, rel15->rnti, - scrambled_output[q]); - - stop_meas(dlsch_scrambling_stats); + scrambled_output); + #ifdef DEBUG_DLSCH - printf("PDSCH scrambling:\n"); - for (int i=0; i>8; i++) { - for (int j=0; j<8; j++) - printf("0x%08x\t", scrambled_output[0][(i<<3)+j]); - printf("\n"); - } -#endif - - /// Modulation - start_meas(dlsch_modulation_stats); - VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_gNB_PDSCH_MODULATION, 1); - for (int q=0; qNrOfCodewords; q++) - nr_modulation(scrambled_output[q], - encoded_length, - Qm, - mod_symbs[q]); - VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_gNB_PDSCH_MODULATION, 0); - stop_meas(dlsch_modulation_stats); -#ifdef DEBUG_DLSCH - printf("PDSCH Modulation: Qm %d(%d)\n", Qm, nb_re); - for (int i=0; i>3; i++) { - for (int j=0; j<8; j++) { - printf("%d %d\t", mod_symbs[0][((i<<3)+j)<<1], mod_symbs[0][(((i<<3)+j)<<1)+1]); + printf("PDSCH scrambling:\n"); + for (int i=0; i>8; i++) { + for (int j=0; j<8; j++) + printf("0x%08x\t", scrambled_output[(i<<3)+j]); + printf("\n"); } - printf("\n"); - } #endif + + stop_meas(dlsch_scrambling_stats); + /// Modulation + start_meas(dlsch_modulation_stats); + nr_modulation(scrambled_output, + encoded_length, + Qm, + mod_symbs[q]); + VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_gNB_PDSCH_MODULATION, 0); + stop_meas(dlsch_modulation_stats); +#ifdef DEBUG_DLSCH + printf("PDSCH Modulation: Qm %d(%d)\n", Qm, nb_re); + for (int i=0; i>3; i++) { + for (int j=0; j<8; j++) { + printf("%d %d\t", mod_symbs[0][((i<<3)+j)<<1], mod_symbs[0][(((i<<3)+j)<<1)+1]); + } + printf("\n"); + } +#endif + } start_meas(&gNB->dlsch_layer_mapping_stats); /// Layer mapping nr_layer_mapping(mod_symbs, - rel15->nrOfLayers, - nb_re, - tx_layers); + rel15->nrOfLayers, + nb_re, + tx_layers); #ifdef DEBUG_DLSCH printf("Layer mapping (%d layers):\n", rel15->nrOfLayers); for (int l=0; lnrOfLayers; l++) for (int i=0; i<(nb_re/rel15->nrOfLayers)>>3; i++) { - printf("layer %d, Re %d..%d : ",l,i<<3,(i<<3)+7); - for (int j=0; j<8; j++) { - printf("l%d %d\t", tx_layers[l][((i<<3)+j)<<1], tx_layers[l][(((i<<3)+j)<<1)+1]); - } - printf("\n"); + printf("layer %d, Re %d..%d : ",l,i<<3,(i<<3)+7); + for (int j=0; j<8; j++) { + printf("l%d %d\t", tx_layers[l][((i<<3)+j)<<1], tx_layers[l][(((i<<3)+j)<<1)+1]); + } + printf("\n"); } #endif stop_meas(&gNB->dlsch_layer_mapping_stats); + /// Resource mapping // Non interleaved VRB to PRB mapping @@ -219,16 +223,20 @@ void nr_generate_pdsch(processingData_L1tx_t *msgTx, start_sc -= frame_parms->ofdm_symbol_size; int txdataF_offset = slot*frame_parms->samples_per_slot_wCP; + int16_t **txdataF_precoding = (int16_t **)malloc16(rel15->nrOfLayers*sizeof(int16_t *)); + for (int layer = 0; layernrOfLayers; layer++) + txdataF_precoding[layer] = (int16_t *)malloc16(2*14*frame_parms->ofdm_symbol_size*sizeof(int16_t)); #ifdef DEBUG_DLSCH_MAPPING printf("PDSCH resource mapping started (start SC %d\tstart symbol %d\tN_PRB %d\tnb_re %d,nb_layers %d)\n", - start_sc, rel15->StartSymbolIndex, rel15->rbSize, nb_re,rel15->nrOfLayers); + start_sc, rel15->StartSymbolIndex, rel15->rbSize, nb_re,rel15->nrOfLayers); #endif start_meas(&gNB->dlsch_resource_mapping_stats); for (int nl=0; nlnrOfLayers; nl++) { int dmrs_port = get_dmrs_port(nl,rel15->dmrsPorts); + // DMRS params for this dmrs port get_Wt(Wt, dmrs_port, dmrs_Type); get_Wf(Wf, dmrs_port, dmrs_Type); @@ -275,7 +283,7 @@ void nr_generate_pdsch(processingData_L1tx_t *msgTx, l_prime = 0; } /// DMRS QPSK modulation - nr_modulation(pdsch_dmrs[l][0], n_dmrs*2, DMRS_MOD_ORDER, mod_dmrs); // currently only codeword 0 is modulated. Qm = 2 as DMRS is QPSK modulated + nr_modulation(pdsch_dmrs[l][rel15->SCID], n_dmrs*2, DMRS_MOD_ORDER, mod_dmrs); // Qm = 2 as DMRS is QPSK modulated #ifdef DEBUG_DLSCH printf("DMRS modulation (symbol %d, %d symbols, type %d):\n", l, n_dmrs, dmrs_Type); @@ -295,8 +303,8 @@ void nr_generate_pdsch(processingData_L1tx_t *msgTx, ptrs_symbol = is_ptrs_symbol(l,dlPtrsSymPos); if(ptrs_symbol) { /* PTRS QPSK Modulation for each OFDM symbol in a slot */ - printf("Doing ptrs modulation for symbol %d, n_ptrs %d\n",l,n_ptrs); - nr_modulation(pdsch_dmrs[l][0], (n_ptrs<<1), DMRS_MOD_ORDER, mod_ptrs); + LOG_D(PHY,"Doing ptrs modulation for symbol %d, n_ptrs %d\n",l,n_ptrs); + nr_modulation(pdsch_dmrs[l][rel15->SCID], (n_ptrs<<1), DMRS_MOD_ORDER, mod_ptrs); } } uint16_t k = start_sc; @@ -306,7 +314,8 @@ void nr_generate_pdsch(processingData_L1tx_t *msgTx, for (int i=0; irbSize*NR_NB_SC_PER_RB; i++) { /* check if cuurent RE is PTRS RE*/ is_ptrs_re = 0; - if (ptrs_symbol) + /* check for PTRS symbol and set flag for PTRS RE */ + if(ptrs_symbol){ is_ptrs_re = is_ptrs_subcarrier(k, rel15->rnti, nl, @@ -316,6 +325,7 @@ void nr_generate_pdsch(processingData_L1tx_t *msgTx, rel15->PTRSReOffset, start_sc, frame_parms->ofdm_symbol_size); + } /* Map DMRS Symbol */ if ( (dmrs_symbol_map & (1 << l)) && (k == ((start_sc+get_dmrs_freq_idx(n, k_prime, delta, dmrs_Type))%(frame_parms->ofdm_symbol_size)))) { @@ -331,6 +341,7 @@ void nr_generate_pdsch(processingData_L1tx_t *msgTx, k_prime&=1; n+=(k_prime)?0:1; } + /* Map PTRS Symbol */ else if(is_ptrs_re){ txdataF_precoding[nl][((l*frame_parms->ofdm_symbol_size + k)<<1) ] = (beta_ptrs*amp*mod_ptrs[ptrs_idx<<1]) >> 15; txdataF_precoding[nl][((l*frame_parms->ofdm_symbol_size + k)<<1) + 1] = (beta_ptrs*amp*mod_ptrs[(ptrs_idx<<1) + 1])>> 15; @@ -439,8 +450,7 @@ void nr_generate_pdsch(processingData_L1tx_t *msgTx, // The same precoding matrix is applied on prg_size RBs, Thus // pmi = prgs_list[rbidx/prg_size].pm_idx, rbidx =0,...,rbSize-1 // The Precoding matrix: - // The Codebook Type I and Type II are not supported yet. - // We`adopt the precoding matrices of PUSCH for 4 layers. + // The Codebook Type I start_meas(&gNB->dlsch_precoding_stats); for (int ap=0; apnb_antennas_tx; ap++) { @@ -457,61 +467,72 @@ void nr_generate_pdsch(processingData_L1tx_t *msgTx, pmi = 0;//no precoding if (pmi == 0) {//unitary Precoding - if(apnrOfLayers) - memcpy((void*)&txdataF[ap][l*frame_parms->ofdm_symbol_size + txdataF_offset + k], - (void*)&txdataF_precoding[ap][2*(l*frame_parms->ofdm_symbol_size + k)], - NR_NB_SC_PER_RB*sizeof(int32_t)); - else - memset((void*)&txdataF[ap][l*frame_parms->ofdm_symbol_size + txdataF_offset + k], - 0, - NR_NB_SC_PER_RB*sizeof(int32_t)); + if (k + NR_NB_SC_PER_RB <= frame_parms->ofdm_symbol_size) { // RB does not cross DC + if(apnrOfLayers) + memcpy((void*)&txdataF[ap][l*frame_parms->ofdm_symbol_size + txdataF_offset + k], + (void*)&txdataF_precoding[ap][2*(l*frame_parms->ofdm_symbol_size + k)], + NR_NB_SC_PER_RB*sizeof(int32_t)); + else + memset((void*)&txdataF[ap][l*frame_parms->ofdm_symbol_size + txdataF_offset + k], + 0, + NR_NB_SC_PER_RB*sizeof(int32_t)); + } else { // RB does cross DC + int neg_length = frame_parms->ofdm_symbol_size - k; + int pos_length = NR_NB_SC_PER_RB - neg_length; + if (apnrOfLayers) { + memcpy((void*)&txdataF[ap][l*frame_parms->ofdm_symbol_size + txdataF_offset + k], + (void*)&txdataF_precoding[ap][2*(l*frame_parms->ofdm_symbol_size + k)], + neg_length*sizeof(int32_t)); + memcpy((void*)&txdataF[ap][l*frame_parms->ofdm_symbol_size + txdataF_offset], + (void*)&txdataF_precoding[ap][2*(l*frame_parms->ofdm_symbol_size)], + pos_length*sizeof(int32_t)); + } else { + memset((void*)&txdataF[ap][l*frame_parms->ofdm_symbol_size + txdataF_offset + k], + 0, + neg_length*sizeof(int32_t)); + memset((void*)&txdataF[ap][l*frame_parms->ofdm_symbol_size + txdataF_offset], + 0, + pos_length*sizeof(int32_t)); + } + } k += NR_NB_SC_PER_RB; if (k >= frame_parms->ofdm_symbol_size) { k -= frame_parms->ofdm_symbol_size; } } else { - //get the precoding matrix weights: - char *W_prec; - switch (frame_parms->nb_antennas_tx) { - case 1://1 antenna port - W_prec = nr_W_1l_2p[pmi][ap]; - break; - case 2://2 antenna ports - if (rel15->nrOfLayers == 1)//1 layer - W_prec = nr_W_1l_2p[pmi][ap]; - else//2 layers - W_prec = nr_W_2l_2p[pmi][ap]; - break; - case 4://4 antenna ports - if (rel15->nrOfLayers == 1)//1 layer - W_prec = nr_W_1l_4p[pmi][ap]; - else if (rel15->nrOfLayers == 2)//2 layers - W_prec = nr_W_2l_4p[pmi][ap]; - else if (rel15->nrOfLayers == 3)//3 layers - W_prec = nr_W_3l_4p[pmi][ap]; - else//4 layers - W_prec = nr_W_4l_4p[pmi][ap]; - break; - default: - LOG_D(PHY,"Precoding 1,2, or 4 antenna ports are currently supported\n"); - W_prec = nr_W_1l_2p[pmi][ap]; - break; - } - for (int i=0; iofdm_symbol_size + k; - int32_t precodatatx_F = nr_layer_precoder(txdataF_precoding, W_prec, rel15->nrOfLayers, re_offset); - ((int16_t*)txdataF[ap])[(re_offset<<1) + (2*txdataF_offset)] = ((int16_t *) &precodatatx_F)[0]; - ((int16_t*)txdataF[ap])[(re_offset<<1) + 1 + (2*txdataF_offset)] = ((int16_t *) &precodatatx_F)[1]; -#ifdef DEBUG_DLSCH_MAPPING - printf("antenna %d\t l %d \t k %d \t txdataF: %d %d\n", - ap, l, k, ((int16_t*)txdataF[ap])[(re_offset<<1) + (2*txdataF_offset)], - ((int16_t*)txdataF[ap])[(re_offset<<1) + 1 + (2*txdataF_offset)]); -#endif - if (++k >= frame_parms->ofdm_symbol_size) { + if(frame_parms->nb_antennas_tx==1){//no precoding matrix defined + memcpy((void*)&txdataF[ap][l*frame_parms->ofdm_symbol_size + txdataF_offset + k], + (void*)&txdataF_precoding[ap][2*(l*frame_parms->ofdm_symbol_size + k)], + NR_NB_SC_PER_RB*sizeof(int32_t)); + k += NR_NB_SC_PER_RB; + if (k >= frame_parms->ofdm_symbol_size) { k -= frame_parms->ofdm_symbol_size; } } + else { + //get the precoding matrix weights: + int32_t **mat = gNB->nr_mimo_precoding_matrix[rel15->nrOfLayers-1]; + //i_row =0,...,dl_antenna_port + //j_col =0,...,nrOfLayers + //mat[pmi][i_rows*2+j_col] + int *W_prec; + W_prec = (int32_t *)&mat[pmi][ap*rel15->nrOfLayers]; + for (int i=0; iofdm_symbol_size + k; + int32_t precodatatx_F = nr_layer_precoder_cm(txdataF_precoding, W_prec, rel15->nrOfLayers, re_offset); + ((int16_t*)txdataF[ap])[(re_offset<<1) + (2*txdataF_offset)] = ((int16_t *) &precodatatx_F)[0]; + ((int16_t*)txdataF[ap])[(re_offset<<1) + 1 + (2*txdataF_offset)] = ((int16_t *) &precodatatx_F)[1]; + #ifdef DEBUG_DLSCH_MAPPING + printf("antenna %d\t l %d \t k %d \t txdataF: %d %d\n", + ap, l, k, ((int16_t*)txdataF[ap])[(re_offset<<1) + (2*txdataF_offset)], + ((int16_t*)txdataF[ap])[(re_offset<<1) + 1 + (2*txdataF_offset)]); + #endif + if (++k >= frame_parms->ofdm_symbol_size) { + k -= frame_parms->ofdm_symbol_size; + } + } + } } } //RB loop } // symbol loop @@ -535,6 +556,9 @@ void nr_generate_pdsch(processingData_L1tx_t *msgTx, else { LOG_D(PHY,"beam index for PDSCH allocation already taken\n"); } + for (int layer = 0; layernrOfLayers; layer++) + free16(txdataF_precoding[layer],2*14*frame_parms->ofdm_symbol_size); + free16(txdataF_precoding,rel15->nrOfLayers); }// dlsch loop } diff --git a/openair1/PHY/NR_TRANSPORT/nr_dlsch.h b/openair1/PHY/NR_TRANSPORT/nr_dlsch.h index 77db12672f..bdf681c21d 100644 --- a/openair1/PHY/NR_TRANSPORT/nr_dlsch.h +++ b/openair1/PHY/NR_TRANSPORT/nr_dlsch.h @@ -49,11 +49,6 @@ void nr_get_rbg_parms(NR_BWP_PARMS* bwp, uint8_t config_type); void nr_get_rbg_list(uint32_t bitmap, uint8_t n_rbg, uint8_t* rbg_list); - -uint8_t nr_get_Qm(uint8_t Imcs, uint8_t table_idx); - -uint32_t nr_get_code_rate(uint8_t Imcs, uint8_t table_idx); - void nr_pdsch_codeword_scrambling(uint8_t *in, uint32_t size, uint8_t q, @@ -68,7 +63,6 @@ void nr_fill_dlsch(processingData_L1tx_t *msgTx, void nr_generate_pdsch(processingData_L1tx_t *msgTx, int frame, int slot); -void free_gNB_dlsch(NR_gNB_DLSCH_t **dlschptr, uint16_t N_RB); void clean_gNB_dlsch(NR_gNB_DLSCH_t *dlsch); @@ -79,9 +73,9 @@ int16_t find_nr_dlsch(uint16_t rnti, PHY_VARS_gNB *gNB,find_type_t type); NR_gNB_SCH_STATS_t *find_nr_dlsch_stats(uint16_t rnti, PHY_VARS_gNB *gNB,find_type_t type); int nr_dlsch_encoding(PHY_VARS_gNB *gNB, - unsigned char *a,int frame, + int frame, uint8_t slot, - NR_gNB_DLSCH_t *dlsch, + NR_DL_gNB_HARQ_t *harq, NR_DL_FRAME_PARMS* frame_parms, unsigned char * output, time_stats_t *tinput, diff --git a/openair1/PHY/NR_TRANSPORT/nr_dlsch_coding.c b/openair1/PHY/NR_TRANSPORT/nr_dlsch_coding.c index cdf0e6c152..548cc6dbd4 100644 --- a/openair1/PHY/NR_TRANSPORT/nr_dlsch_coding.c +++ b/openair1/PHY/NR_TRANSPORT/nr_dlsch_coding.c @@ -50,10 +50,14 @@ //#define DEBUG_DLSCH_FREE 1 -void free_gNB_dlsch(NR_gNB_DLSCH_t **dlschptr, uint16_t N_RB) { - int r; +void free_gNB_dlsch(NR_gNB_DLSCH_t **dlschptr, + uint16_t N_RB, + const NR_DL_FRAME_PARMS* frame_parms) { + NR_gNB_DLSCH_t *dlsch = *dlschptr; - uint16_t a_segments = MAX_NUM_NR_DLSCH_SEGMENTS; //number of segments to be allocated + + int max_layers = (frame_parms->nb_antennas_txnb_antennas_tx : NR_MAX_NB_LAYERS; + uint16_t a_segments = MAX_NUM_NR_DLSCH_SEGMENTS_PER_LAYER*max_layers; if (N_RB != 273) { a_segments = a_segments*N_RB; @@ -65,26 +69,30 @@ void free_gNB_dlsch(NR_gNB_DLSCH_t **dlschptr, uint16_t N_RB) { free16(harq->b, a_segments * 1056); harq->b = NULL; } - for (r = 0; r < a_segments; r++) { + for (int r = 0; r < a_segments; r++) { free(harq->c[r]); harq->c[r] = NULL; } + free(harq->c); free(harq->pdu); for (int aa = 0; aa < 64; aa++) free(dlsch->calib_dl_ch_estimates[aa]); free(dlsch->calib_dl_ch_estimates); - for (int q=0; q 4 ? 2 : 1; + for (int q=0; qmod_symbs[q]); + free(dlsch->mod_symbs); - for (int layer = 0; layer < NR_MAX_NB_LAYERS; layer++) { - free(dlsch->txdataF_precoding[layer]); + for (int layer = 0; layer < max_layers; layer++) { free(dlsch->txdataF[layer]); for (int aa = 0; aa < 64; aa++) free(dlsch->ue_spec_bf_weights[layer][aa]); free(dlsch->ue_spec_bf_weights[layer]); } + free(dlsch->txdataF); + free(dlsch->ue_spec_bf_weights); free(dlsch); *dlschptr = NULL; @@ -96,9 +104,9 @@ NR_gNB_DLSCH_t *new_gNB_dlsch(NR_DL_FRAME_PARMS *frame_parms, uint32_t Nsoft, uint8_t abstraction_flag, uint16_t N_RB) { - unsigned char i,r,aa,layer; - int re; - uint16_t a_segments = MAX_NUM_NR_DLSCH_SEGMENTS; //number of segments to be allocated + + int max_layers = (frame_parms->nb_antennas_txnb_antennas_tx : NR_MAX_NB_LAYERS; + uint16_t a_segments = MAX_NUM_NR_DLSCH_SEGMENTS_PER_LAYER*max_layers; //number of segments to be allocated if (N_RB != 273) { a_segments = a_segments*N_RB; @@ -114,31 +122,36 @@ NR_gNB_DLSCH_t *new_gNB_dlsch(NR_DL_FRAME_PARMS *frame_parms, dlsch->Mlimit = 4; dlsch->Nsoft = Nsoft; - for (layer=0; layerN_RB_DL*NR_SYMBOLS_PER_SLOT*NR_NB_SC_PER_RB*8; // max pdsch encoded length for each layer + + dlsch->txdataF = (int32_t **)malloc16(max_layers*sizeof(int32_t *)); + + dlsch->ue_spec_bf_weights = (int32_t ***)malloc16(max_layers*sizeof(int32_t **)); + for (int layer=0; layerue_spec_bf_weights[layer] = (int32_t **)malloc16(64*sizeof(int32_t *)); - for (aa=0; aa<64; aa++) { + for (int aa=0; aa<64; aa++) { dlsch->ue_spec_bf_weights[layer][aa] = (int32_t *)malloc16(OFDM_SYMBOL_SIZE_COMPLEX_SAMPLES*sizeof(int32_t)); - for (re=0; reue_spec_bf_weights[layer][aa][re] = 0x00007fff; } } - - dlsch->txdataF[layer] = (int32_t *)malloc16((NR_MAX_PDSCH_ENCODED_LENGTH/NR_MAX_NB_LAYERS)*sizeof(int32_t)); // NR_MAX_NB_LAYERS is already included in NR_MAX_PDSCH_ENCODED_LENGTH - dlsch->txdataF_precoding[layer] = (int32_t *)malloc16(2*14*frame_parms->ofdm_symbol_size*sizeof(int32_t)); + dlsch->txdataF[layer] = (int32_t *)malloc16((txdataf_size)*sizeof(int32_t)); } - for (int q=0; qmod_symbs[q] = (int32_t *)malloc16(NR_MAX_PDSCH_ENCODED_LENGTH*sizeof(int32_t)); + int nb_codewords = NR_MAX_NB_LAYERS > 4 ? 2 : 1; + dlsch->mod_symbs = (int32_t **)malloc16(nb_codewords*sizeof(int32_t *)); + for (int q=0; qmod_symbs[q] = (int32_t *)malloc16(txdataf_size*max_layers*sizeof(int32_t)); dlsch->calib_dl_ch_estimates = (int32_t **)malloc16(64*sizeof(int32_t *)); - for (aa=0; aa<64; aa++) { + for (int aa=0; aa<64; aa++) { dlsch->calib_dl_ch_estimates[aa] = (int32_t *)malloc16(OFDM_SYMBOL_SIZE_COMPLEX_SAMPLES*sizeof(int32_t)); } - for (i=0; i<20; i++) { + for (int i=0; i<20; i++) { dlsch->harq_ids[0][i] = 0; dlsch->harq_ids[1][i] = 0; } @@ -153,7 +166,8 @@ NR_gNB_DLSCH_t *new_gNB_dlsch(NR_DL_FRAME_PARMS *frame_parms, nr_emulate_dlsch_payload(harq->pdu, (dlsch_bytes) >> 3); bzero(harq->b, dlsch_bytes); - for (r = 0; r < a_segments; r++) { + harq->c = (uint8_t **)malloc16(a_segments*sizeof(uint8_t *)); + for (int r = 0; r < a_segments; r++) { // account for filler in first segment and CRCs for multiple segment case // [hna] 8448 is the maximum CB size in NR // 68*348 = 68*(maximum size of Zc) @@ -218,27 +232,20 @@ void ldpc8blocks( void *p) { #endif uint32_t E = nr_get_E(G, impp->n_segments, mod_order, rel15->nrOfLayers, rr); //#ifdef DEBUG_DLSCH_CODING - LOG_D(NR_PHY,"Rate Matching, Code segment %d/%d (coded bits (G) %u, E %d, Filler bits %d, Filler offset %d mod_order %d, nb_rb %d)...\n", + LOG_D(NR_PHY,"Rate Matching, Code segment %d/%d (coded bits (G) %u, E %d, Filler bits %d, Filler offset %d mod_order %d, nb_rb %d,nrOfLayer %d)...\n", rr, impp->n_segments, G, E, impp->F, Kr-impp->F-2*(*impp->Zc), - mod_order,nb_rb); - // for tbslbrm calculation according to 5.4.2.1 of 38.212 - uint8_t Nl = 4; + mod_order,nb_rb,rel15->nrOfLayers); - if (rel15->nrOfLayers < Nl) - Nl = rel15->nrOfLayers; - - uint32_t Tbslbrm = nr_compute_tbslbrm(rel15->mcsTable[0],nb_rb,Nl); - uint8_t Ilbrm = 1; + uint32_t Tbslbrm = rel15->maintenance_parms_v3.tbSizeLbrmBytes; uint8_t e[E]; bzero (e, E); - nr_rate_matching_ldpc(Ilbrm, - Tbslbrm, + nr_rate_matching_ldpc(Tbslbrm, impp->BG, *impp->Zc, impp->d[rr], @@ -248,6 +255,20 @@ void ldpc8blocks( void *p) { Kr-impp->F-2*(*impp->Zc), rel15->rvIndex[0], E); + if (Kr-impp->F-2*(*impp->Zc)> E) { + LOG_E(PHY,"dlsch coding A %d Kr %d G %d (nb_rb %d, nb_symb_sch %d, nb_re_dmrs %d, length_dmrs %d, mod_order %d)\n", + A,impp->K,G, nb_rb,nb_symb_sch,nb_re_dmrs,length_dmrs,(int)mod_order); + + LOG_E(NR_PHY,"Rate Matching, Code segment %d/%d (coded bits (G) %u, E %d, Kr %d, Filler bits %d, Filler offset %d mod_order %d, nb_rb %d)...\n", + rr, + impp->n_segments, + G, + E, + Kr, + impp->F, + Kr-impp->F-2*(*impp->Zc), + mod_order,nb_rb); + } #ifdef DEBUG_DLSCH_CODING for (int i =0; i<16; i++) @@ -272,10 +293,9 @@ void ldpc8blocks( void *p) { } int nr_dlsch_encoding(PHY_VARS_gNB *gNB, - unsigned char *a, int frame, uint8_t slot, - NR_gNB_DLSCH_t *dlsch, + NR_DL_gNB_HARQ_t *harq, NR_DL_FRAME_PARMS *frame_parms, unsigned char * output, time_stats_t *tinput,time_stats_t *tprep,time_stats_t *tparity,time_stats_t *toutput, @@ -284,15 +304,13 @@ int nr_dlsch_encoding(PHY_VARS_gNB *gNB, encoder_implemparams_t impp; impp.output=output; unsigned int crc=1; - NR_DL_gNB_HARQ_t *harq = &dlsch->harq_process; nfapi_nr_dl_tti_pdsch_pdu_rel15_t *rel15 = &harq->pdsch_pdu.pdsch_pdu_rel15; - impp.Zc = &dlsch->harq_process.Z; - float Coderate = 0.0; + impp.Zc = &harq->Z; VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_gNB_DLSCH_ENCODING, VCD_FUNCTION_IN); uint32_t A = rel15->TBSize[0]<<3; - + unsigned char *a=harq->pdu; if ( rel15->rnti != SI_RNTI) - trace_NRpdu(DIRECTION_DOWNLINK, a, rel15->TBSize[0], 0, WS_C_RNTI, rel15->rnti, frame, slot,0, 0); + trace_NRpdu(DIRECTION_DOWNLINK, a, rel15->TBSize[0], WS_C_RNTI, rel15->rnti, frame, slot,0, 0); NR_gNB_SCH_STATS_t *stats=NULL; int first_free=-1; @@ -303,19 +321,20 @@ int nr_dlsch_encoding(PHY_VARS_gNB *gNB, stats=&gNB->dlsch_stats[i]; } - if (gNB->dlsch_stats[i].rnti == dlsch->rnti) { + if (gNB->dlsch_stats[i].rnti == rel15->rnti) { stats=&gNB->dlsch_stats[i]; break; } } if (stats) { - stats->rnti = dlsch->rnti; + stats->rnti = rel15->rnti; stats->total_bytes_tx += rel15->TBSize[0]; stats->current_RI = rel15->nrOfLayers; stats->current_Qm = rel15->qamModOrder[0]; } + int max_bytes = MAX_NUM_NR_DLSCH_SEGMENTS_PER_LAYER*rel15->nrOfLayers*1056; if (A > 3824) { // Add 24-bit crc (polynomial A) to payload crc = crc24a(a,A)>>8; @@ -326,11 +345,11 @@ int nr_dlsch_encoding(PHY_VARS_gNB *gNB, //printf("a0 %d a1 %d a2 %d\n", a[A>>3], a[1+(A>>3)], a[2+(A>>3)]); harq->B = A+24; // harq->b = a; - AssertFatal((A / 8) + 4 <= MAX_NR_DLSCH_PAYLOAD_BYTES, + AssertFatal((A / 8) + 4 <= max_bytes, "A %d is too big (A/8+4 = %d > %d)\n", A, (A / 8) + 4, - MAX_NR_DLSCH_PAYLOAD_BYTES); + max_bytes); memcpy(harq->b, a, (A / 8) + 4); // why is this +4 if the CRC is only 3 bytes? } else { // Add 16-bit crc (polynomial A) to payload @@ -341,18 +360,17 @@ int nr_dlsch_encoding(PHY_VARS_gNB *gNB, //printf("a0 %d a1 %d \n", a[A>>3], a[1+(A>>3)]); harq->B = A+16; // harq->b = a; - AssertFatal((A / 8) + 3 <= MAX_NR_DLSCH_PAYLOAD_BYTES, + AssertFatal((A / 8) + 3 <= max_bytes, "A %d is too big (A/8+3 = %d > %d)\n", A, (A / 8) + 3, - MAX_NR_DLSCH_PAYLOAD_BYTES); + max_bytes); memcpy(harq->b, a, (A / 8) + 3); // using 3 bytes to mimic the case of 24 bit crc } - if (rel15->targetCodeRate[0]<1000) - Coderate = (float)rel15->targetCodeRate[0] /(float) 1024; - else // to scale for mcs 20 and 26 in table 5.1.3.1-2 which are decimal and input 2* in nr_tbs_tools - Coderate = (float)rel15->targetCodeRate[0] /(float) 2048; + // target_code_rate is in 0.1 units + float Coderate = (float) rel15->targetCodeRate[0] / 10240.0f; + LOG_D(PHY,"DLSCH Coderate %f\n",Coderate); if ((A <=292) || ((A<=3824) && (Coderate <= 0.6667)) || Coderate <= 0.25) impp.BG = 2; @@ -363,6 +381,11 @@ int nr_dlsch_encoding(PHY_VARS_gNB *gNB, impp.Kb = nr_segmentation(harq->b, harq->c, harq->B, &impp.n_segments, &impp.K, impp.Zc, &impp.F, impp.BG); stop_meas(dlsch_segmentation_stats); + if (impp.n_segments>MAX_NUM_NR_DLSCH_SEGMENTS_PER_LAYER*rel15->nrOfLayers) { + LOG_E(PHY,"nr_segmentation.c: too many segments %d, B %d\n",impp.n_segments,harq->B); + return(-1); + } + for (int r=0; rd[r][0]; //channel_input[r] = &harq->d[r][0]; diff --git a/openair1/PHY/NR_TRANSPORT/nr_prach.c b/openair1/PHY/NR_TRANSPORT/nr_prach.c index 4e2fbd4e71..eb012532ce 100644 --- a/openair1/PHY/NR_TRANSPORT/nr_prach.c +++ b/openair1/PHY/NR_TRANSPORT/nr_prach.c @@ -68,7 +68,7 @@ int16_t find_nr_prach(PHY_VARS_gNB *gNB,int frame, int slot, find_type_t type) { } else if ((type == SEARCH_EXIST) && (gNB->prach_vars.list[i].frame == frame) && - (gNB->prach_vars.list[i].slot == slot)) { + (gNB->prach_vars.list[i].slot == slot)) { return i; } } @@ -107,15 +107,15 @@ int16_t find_nr_prach_ru(RU_t *ru,int frame,int slot, find_type_t type) { for (uint16_t i=0; i %d.%d\n", frame,slot,i, ru->prach_list[i].frame,ru->prach_list[i].slot); - if((type == SEARCH_EXIST_OR_FREE) && - (ru->prach_list[i].frame == -1) && - (ru->prach_list[i].slot == -1)) { - pthread_mutex_unlock(&ru->prach_list_mutex); - return i; - } + if((type == SEARCH_EXIST_OR_FREE) && + (ru->prach_list[i].frame == -1) && + (ru->prach_list[i].slot == -1)) { + pthread_mutex_unlock(&ru->prach_list_mutex); + return i; + } else if ((type == SEARCH_EXIST) && - (ru->prach_list[i].frame == frame) && - (ru->prach_list[i].slot == slot)) { + (ru->prach_list[i].frame == frame) && + (ru->prach_list[i].slot == slot)) { pthread_mutex_unlock(&ru->prach_list_mutex); return i; } @@ -175,106 +175,193 @@ void rx_nr_prach_ru(RU_t *ru, int msg1_frequencystart = ru->config.prach_config.num_prach_fd_occasions_list[numRA].k1.value; int sample_offset_slot; - if (!(slot%(fp->slots_per_subframe/2))) - sample_offset_slot = (prachStartSymbol==0?0:fp->ofdm_symbol_size*prachStartSymbol+fp->nb_prefix_samples0+fp->nb_prefix_samples*(prachStartSymbol-1)); - else - sample_offset_slot = (prachStartSymbol==0?0:prachStartSymbol*(fp->ofdm_symbol_size+fp->nb_prefix_samples)); - //to be checked for mu=0; + if (prachStartSymbol == 0) { + sample_offset_slot = 0; + } else if (fp->slots_per_subframe == 1) { + if (prachStartSymbol <= 7) + sample_offset_slot = (fp->ofdm_symbol_size + fp->nb_prefix_samples) * (prachStartSymbol - 1) + (fp->ofdm_symbol_size + fp->nb_prefix_samples0); + else + sample_offset_slot = (fp->ofdm_symbol_size + fp->nb_prefix_samples) * (prachStartSymbol - 2) + (fp->ofdm_symbol_size + fp->nb_prefix_samples0) * 2; + } else { + if (!(slot%(fp->slots_per_subframe/2))) + sample_offset_slot = (fp->ofdm_symbol_size + fp->nb_prefix_samples) * (prachStartSymbol - 1) + (fp->ofdm_symbol_size + fp->nb_prefix_samples0); + else + sample_offset_slot = (fp->ofdm_symbol_size + fp->nb_prefix_samples) * prachStartSymbol; + } LOG_D(PHY,"frame %d, slot %d: doing rx_nr_prach_ru for format %d, numRA %d, prachStartSymbol %d, prachOccasion %d\n",frame,slot,prachFormat,numRA,prachStartSymbol,prachOccasion); rxsigF = ru->prach_rxsigF[prachOccasion]; - AssertFatal(ru->if_south == LOCAL_RF,"we shouldn't call this if if_south != LOCAL_RF\n"); + AssertFatal(ru->if_south == LOCAL_RF || ru->if_south == REMOTE_IF5, + "we shouldn't call this if if_south != LOCAL_RF or REMOTE_IF5\n"); for (int aa=0; aanb_rx; aa++){ if (prach_sequence_length == 0) slot2=(slot/fp->slots_per_subframe)*fp->slots_per_subframe; prach[aa] = (int16_t*)&ru->common.rxdata[aa][fp->get_samples_slot_timestamp(slot2,fp,0)+sample_offset_slot-ru->N_TA_offset]; } - idft_size_idx_t dftsize; - int dftlen=0; + int reps; + int Ncp; + int dftlen; int mu = fp->numerology_index; - int Ncp = 0; - int16_t *prach2; if (prach_sequence_length == 0) { LOG_D(PHY,"PRACH (ru %d) in %d.%d, format %d, msg1_frequencyStart %d\n", ru->idx,frame,slot2,prachFormat,msg1_frequencystart); - AssertFatal(prachFormat<4,"Illegal prach format %d for length 839\n",prachFormat); switch (prachFormat) { case 0: + reps = 1; Ncp = 3168; + dftlen = 24576; break; - + case 1: + reps = 2; Ncp = 21024; + dftlen = 24576; break; - + case 2: + reps = 4; Ncp = 4688; + dftlen = 24576; break; - + case 3: + reps = 4; Ncp = 3168; + dftlen = 6144; + break; + + default: + AssertFatal(1==0, "Illegal prach format %d for length 839\n", prachFormat); break; - } } else { LOG_D(PHY,"PRACH (ru %d) in %d.%d, format %s, msg1_frequencyStart %d,startSymbol %d\n", ru->idx,frame,slot,prachfmt[prachFormat],msg1_frequencystart,prachStartSymbol); - switch (prachFormat) { case 4: //A1 - Ncp = 288/(1<> mu; break; - + case 5: //A2 - Ncp = 576/(1<> mu; break; - + case 6: //A3 - Ncp = 864/(1<> mu; break; - + case 7: //B1 - Ncp = 216/(1<> mu; + break; + /* // B2 and B3 do not exist in FAPI case 4: //B2 - Ncp = 360/(1<> mu; break; - + case 5: //B3 - Ncp = 504/(1<> mu; break; */ + case 8: //B4 - Ncp = 936/(1<> mu; break; - + case 9: //C0 - Ncp = 1240/(1<> mu; break; - + case 10: //C2 - Ncp = 2048/(1<> mu; break; - + default: AssertFatal(1==0,"unknown prach format %x\n",prachFormat); break; } + dftlen = 2048 >> mu; } + + //actually what we should be checking here is how often the current prach crosses a 0.5ms boundary. I am not quite sure for which paramter set this would be the case, so I will ignore it for now and just check if the prach starts on a 0.5ms boundary + if(fp->numerology_index == 0) { + if (prachStartSymbol == 0 || prachStartSymbol == 7) + Ncp += 16; + } + else { + if (slot%(fp->slots_per_subframe/2)==0 && prachStartSymbol == 0) + Ncp += 16; + } + + switch(fp->samples_per_subframe) { + case 7680: + // 5 MHz @ 7.68 Ms/s + Ncp >>= 2; + dftlen >>= 2; + break; + + case 15360: + // 10, 15 MHz @ 15.36 Ms/s + Ncp >>= 1; + dftlen >>= 1; + break; + + case 30720: + // 20, 25, 30 MHz @ 30.72 Ms/s + Ncp = Ncp; + dftlen = dftlen; + break; + + case 46080: + // 40 MHz @ 46.08 Ms/s + Ncp = (Ncp*3)/2; + dftlen = (dftlen*3)/2; + break; + + case 61440: + // 40, 50, 60 MHz @ 61.44 Ms/s + Ncp <<= 1; + dftlen <<= 1; + break; + + case 92160: + // 50, 60, 70, 80, 90 MHz @ 92.16 Ms/s + Ncp *= 3; + dftlen *= 3; + break; + + case 122880: + // 70, 80, 90, 100 MHz @ 122.88 Ms/s + Ncp <<= 2; + dftlen <<= 2; + break; + + default: + AssertFatal(1==0,"sample rate %f MHz not supported for numerology %d\n", fp->samples_per_subframe / 1000.0, mu); + } + + const idft_size_idx_t dftsize = get_dft(dftlen); + // Do forward transform if (LOG_DEBUGFLAG(PRACH)) { - LOG_D(PHY,"rx_prach: Doing PRACH FFT for nb_rx:%d Ncp:%d\n",ru->nb_rx, Ncp); + LOG_D(PHY, "rx_prach: Doing PRACH FFT for nb_rx:%d Ncp:%d dftlen:%d\n", ru->nb_rx, Ncp, dftlen); } - // Note: Assumes PUSCH SCS @ 30 kHz, take values for formats 0-2 and adjust for others below int kbar = 1; @@ -298,357 +385,13 @@ void rx_nr_prach_ru(RU_t *ru, k*=K; k+=kbar; - int reps=1; - for (int aa=0; aanb_rx; aa++) { AssertFatal(prach[aa]!=NULL,"prach[%d] is null\n",aa); // do DFT - if (mu==1) { - switch(fp->samples_per_subframe) { - case 15360: - // 10, 15 MHz @ 15.36 Ms/s - prach2 = prach[aa] + (1*Ncp); // Ncp is for 30.72 Ms/s, so divide by 2 to bring to 15.36 Ms/s and multiply by 2 for I/Q - if (prach_sequence_length == 0) { - if (prachFormat == 0 || prachFormat == 1 || prachFormat == 2) { - dftlen=12288; - dft(DFT_12288,prach2,rxsigF[aa],1); - } - if (prachFormat == 1 || prachFormat == 2) { - dft(DFT_12288,prach2+24576,rxsigF[aa]+24576,1); - reps++; - } - if (prachFormat == 2) { - dft(DFT_12288,prach2+(24576*2),rxsigF[aa]+(24576*2),1); - dft(DFT_12288,prach2+(24576*3),rxsigF[aa]+(24576*3),1); - reps+=2; - } - if (prachFormat == 3) { - dftlen=3072; - for (int i=0;i<4;i++) dft(DFT_3072,prach2+(i*3072*2),rxsigF[aa]+(i*3072*2),1); - reps=4; - } - } else { // 839 sequence - if (prachStartSymbol == 0) prach2+=16; // 8 samples @ 15.36 Ms/s in first symbol of each half subframe (15/30 kHz only) - - dftlen=512; - dft(DFT_512,prach2,rxsigF[aa],1); - if (prachFormat != 9/*C0*/) { - dft(DFT_512,prach2+1024,rxsigF[aa]+1024,1); - reps++; - } - if (prachFormat == 5/*A2*/ || prachFormat == 6/*A3*/|| prachFormat == 8/*B4*/ || prachFormat == 10/*C2*/) { - dft(DFT_512,prach2+1024*2,rxsigF[aa]+1024*2,1); - dft(DFT_512,prach2+1024*3,rxsigF[aa]+1024*3,1); - reps+=2; - } - if (prachFormat == 6/*A3*/ || prachFormat == 8/*B4*/) { - dft(DFT_512,prach2+1024*4,rxsigF[aa]+1024*4,1); - dft(DFT_512,prach2+1024*5,rxsigF[aa]+1024*5,1); - reps+=2; - } - if (prachFormat == 8/*B4*/) { - for (int i=6;i<12;i++) dft(DFT_512,prach2+(1024*i),rxsigF[aa]+(1024*i),1); - reps+=6; - } - } - break; - - case 30720: - // 20, 25, 30 MHz @ 30.72 Ms/s - prach2 = prach[aa] + (2*Ncp); // Ncp is for 30.72 Ms/s, so just multiply by 2 for I/Q - if (prach_sequence_length == 0) { - if (prachFormat == 0 || prachFormat == 1 || prachFormat == 2) { - dftlen=24576; - dft(DFT_24576,prach2,rxsigF[aa],1); - } - if (prachFormat == 1 || prachFormat == 2) { - dft(DFT_24576,prach2+49152,rxsigF[aa]+49152,1); - reps++; - } - if (prachFormat == 2) { - dft(DFT_24576,prach2+(49152*2),rxsigF[aa]+(49152*2),1); - dft(DFT_24576,prach2+(49152*3),rxsigF[aa]+(49152*3),1); - reps+=2; - } - if (prachFormat == 3) { - dftlen=6144; - for (int i=0;i<4;i++) dft(DFT_6144,prach2+(i*6144*2),rxsigF[aa]+(i*6144*2),1); - reps=4; - } - } else { // 839 sequence - if (prachStartSymbol == 0) prach2+=32; // 16 samples @ 30.72 Ms/s in first symbol of each half subframe (15/30 kHz only) - - dftlen=1024; - dft(DFT_1024,prach2,rxsigF[aa],1); - if (prachFormat != 9/*C0*/) { - dft(DFT_1024,prach2+2048,rxsigF[aa]+2048,1); - reps++; - } - if (prachFormat == 5/*A2*/ || prachFormat == 6/*A3*/|| prachFormat == 8/*B4*/ || prachFormat == 10/*C2*/) { - dft(DFT_1024,prach2+2048*2,rxsigF[aa]+2048*2,1); - dft(DFT_1024,prach2+2048*3,rxsigF[aa]+2048*3,1); - reps+=2; - } - if (prachFormat == 6/*A3*/ || prachFormat == 8/*B4*/) { - dft(DFT_1024,prach2+2048*4,rxsigF[aa]+2048*4,1); - dft(DFT_1024,prach2+2048*5,rxsigF[aa]+2048*5,1); - reps+=2; - } - if (prachFormat == 8/*B4*/) { - for (int i=6;i<12;i++) dft(DFT_1024,prach2+(2048*i),rxsigF[aa]+(2048*i),1); - reps+=6; - } - } - break; - - case 61440: - // 40, 50, 60 MHz @ 61.44 Ms/s - prach2 = prach[aa] + (4*Ncp); // Ncp is for 30.72 Ms/s, so multiply by 2 for I/Q, and 2 to bring to 61.44 Ms/s - if (prach_sequence_length == 0) { - if (prachFormat == 0 || prachFormat == 1 || prachFormat == 2) { - dftlen=49152; - dft(DFT_49152,prach2,rxsigF[aa],1); - } - if (prachFormat == 1 || prachFormat == 2) { - dft(DFT_49152,prach2+98304,rxsigF[aa]+98304,1); - reps++; - } - if (prachFormat == 2) { - dft(DFT_49152,prach2+(98304*2),rxsigF[aa]+(98304*2),1); - dft(DFT_49152,prach2+(98304*3),rxsigF[aa]+(98304*3),1); - reps+=2; - } - if (prachFormat == 3) { - dftlen=12288; - for (int i=0;i<4;i++) dft(DFT_12288,prach2+(i*12288*2),rxsigF[aa]+(i*12288*2),1); - reps=4; - } - } else { // 839 sequence - if (prachStartSymbol == 0) prach2+=64; // 32 samples @ 61.44 Ms/s in first symbol of each half subframe (15/30 kHz only) - - dftlen=2048; - dft(DFT_2048,prach2,rxsigF[aa],1); - if (prachFormat != 9/*C0*/) { - dft(DFT_2048,prach2+4096,rxsigF[aa]+4096,1); - reps++; - } - if (prachFormat == 5/*A2*/ || prachFormat == 6/*A3*/|| prachFormat == 8/*B4*/ || prachFormat == 10/*C2*/) { - dft(DFT_2048,prach2+4096*2,rxsigF[aa]+4096*2,1); - dft(DFT_2048,prach2+4096*3,rxsigF[aa]+4096*3,1); - reps+=2; - } - if (prachFormat == 6/*A3*/ || prachFormat == 8/*B4*/) { - dft(DFT_2048,prach2+4096*4,rxsigF[aa]+4096*4,1); - dft(DFT_2048,prach2+4096*5,rxsigF[aa]+4096*5,1); - reps+=2; - } - if (prachFormat == 8/*B4*/) { - for (int i=6;i<12;i++) dft(DFT_2048,prach2+(4096*i),rxsigF[aa]+(4096*i),1); - reps+=6; - } - } - break; - - case 46080: - // 40 MHz @ 46.08 Ms/s - prach2 = prach[aa] + (3*Ncp); // 46.08 is 1.5 * 30.72, times 2 for I/Q - if (prach_sequence_length == 0) { - if (prachFormat == 0 || prachFormat == 1 || prachFormat == 2) { - dftlen=36864; - dft(DFT_36864,prach2,rxsigF[aa],1); - } - if (prachFormat == 1 || prachFormat == 2) { - dft(DFT_36864,prach2+73728,rxsigF[aa]+73728,1); - reps++; - } - if (prachFormat == 2) { - dft(DFT_36864,prach2+(73728*2),rxsigF[aa]+(73728*2),1); - dft(DFT_36864,prach2+(73728*3),rxsigF[aa]+(73728*3),1); - reps+=2; - } - if (prachFormat == 3) { - dftlen=9216; - for (int i=0;i<4;i++) dft(DFT_9216,prach2+(i*9216*2),rxsigF[aa]+(i*9216*2),1); - reps=4; - } - } else { // 839 sequence - if (prachStartSymbol == 0) prach2+=48; // 24 samples @ 46.08 Ms/s in first symbol of each half subframe (15/30 kHz only) - - dftlen=1536; - dft(DFT_1536,prach2,rxsigF[aa],1); - if (prachFormat != 9/*C0*/) { - dft(DFT_1536,prach2+3072,rxsigF[aa]+3072,1); - reps++; - } - if (prachFormat == 5/*A2*/ || prachFormat == 6/*A3*/|| prachFormat == 8/*B4*/ || prachFormat == 10/*C2*/) { - dft(DFT_1536,prach2+3072*2,rxsigF[aa]+3072*2,1); - dft(DFT_1536,prach2+3072*3,rxsigF[aa]+3072*3,1); - reps+=2; - } - if (prachFormat == 6/*A3*/ || prachFormat == 8/*B4*/) { - dft(DFT_1536,prach2+3072*4,rxsigF[aa]+3072*4,1); - dft(DFT_1536,prach2+3072*5,rxsigF[aa]+3072*5,1); - reps+=2; - } - if (prachFormat == 8/*B4*/) { - for (int i=6;i<12;i++) dft(DFT_1536,prach2+(3072*i),rxsigF[aa]+(3072*i),1); - reps+=6; - } - } - break; - - case 122880: - // 70, 80, 90, 100 MHz @ 122.88 Ms/s - prach2 = prach[aa] + (8*Ncp); - if (prach_sequence_length == 0) { - if (prachFormat == 0 || prachFormat == 1 || prachFormat == 2) { - dftlen=98304; - dft(DFT_98304,prach2,rxsigF[aa],1); - } - if (prachFormat == 1 || prachFormat == 2) { - dft(DFT_98304,prach2+196608,rxsigF[aa]+196608,1); - reps++; - } - if (prachFormat == 2) { - dft(DFT_98304,prach2+(196608*2),rxsigF[aa]+(196608*2),1); - dft(DFT_98304,prach2+(196608*3),rxsigF[aa]+(196608*3),1); - reps+=2; - } - if (prachFormat == 3) { - dftlen=24576; - for (int i=0;i<4;i++) dft(DFT_24576,prach2+(i*2*24576),rxsigF[aa]+(i*2*24576),1); - reps=4; - } - } else { // 839 sequence - if (prachStartSymbol == 0) prach2+=128; // 64 samples @ 122.88 Ms/s in first symbol of each half subframe (15/30 kHz only) - - dftlen=4096; - dft(DFT_4096,prach2,rxsigF[aa],1); - if (prachFormat != 9/*C0*/) { - dft(DFT_4096,prach2+8192,rxsigF[aa]+8192,1); - reps++; - } - - if (prachFormat == 5/*A2*/ || prachFormat == 6/*A3*/|| prachFormat == 8/*B4*/ || prachFormat == 10/*C2*/) { - dft(DFT_4096,prach2+8192*2,rxsigF[aa]+8192*2,1); - dft(DFT_4096,prach2+8192*3,rxsigF[aa]+8192*3,1); - reps+=2; - } - if (prachFormat == 6/*A3*/ || prachFormat == 8/*B4*/) { - dft(DFT_4096,prach2+8192*4,rxsigF[aa]+8192*4,1); - dft(DFT_4096,prach2+8192*5,rxsigF[aa]+8192*5,1); - reps+=2; - } - if (prachFormat == 8/*B4*/) { - for (int i=6;i<12;i++) dft(DFT_4096,prach2+(8192*i),rxsigF[aa]+(8192*i),1); - reps+=6; - } - } - break; - - case 92160: - // 80, 90 MHz @ 92.16 Ms/s - prach2 = prach[aa] + (6*Ncp); - if (prach_sequence_length == 0) { - if (prachFormat == 0 || prachFormat == 1 || prachFormat == 2) { - dftlen=73728; - dft(DFT_73728,prach2,rxsigF[aa],1); - } - if (prachFormat == 1 || prachFormat == 2) { - dft(DFT_73728,prach2+147456,rxsigF[aa]+147456,1); - reps++; - } - if (prachFormat == 2) { - dft(DFT_73728,prach2+(147456*2),rxsigF[aa]+(147456*2),1); - dft(DFT_73728,prach2+(147456*3),rxsigF[aa]+(147456*3),1); - reps+=2; - } - if (prachFormat == 3) { - dftlen=18432; - for (int i=0;i<4;i++) dft(DFT_18432,prach2+(i*2*18432),rxsigF[aa]+(i*2*18432),1); - reps=4; - } - } else { - if (prachStartSymbol == 0) prach2+=96; // 64 samples @ 122.88 Ms/s in first symbol of each half subframe (15/30 kHz only) - - dftlen=3072; - dft(DFT_3072,prach2,rxsigF[aa],1); - if (prachFormat != 9/*C0*/) { - dft(DFT_3072,prach2+6144,rxsigF[aa]+6144,1); - reps++; - } - - if (prachFormat == 5/*A2*/ || prachFormat == 6/*A3*/|| prachFormat == 8/*B4*/ || prachFormat == 10/*C2*/) { - dft(DFT_3072,prach2+6144*2,rxsigF[aa]+6144*2,1); - dft(DFT_3072,prach2+6144*3,rxsigF[aa]+6144*3,1); - reps+=2; - } - if (prachFormat == 6/*A3*/ || prachFormat == 8/*B4*/) { - dft(DFT_3072,prach2+6144*4,rxsigF[aa]+6144*4,1); - dft(DFT_3072,prach2+6144*5,rxsigF[aa]+6144*5,1); - reps+=2; - } - if (prachFormat == 8/*B4*/) { - for (int i=6;i<12;i++) dft(DFT_3072,prach2+(6144*i),rxsigF[aa]+(6144*i),1); - reps+=6; - } - } - break; - default: - AssertFatal(1==0,"sample_rate %f MHz not support for NR PRACH yet\n", fp->samples_per_subframe / 1000.0); - } - } - else if (mu==3) { - if (fp->threequarter_fs) { - AssertFatal(1==0,"3/4 sampling not supported for numerology %d\n",mu); - } - if (prach_sequence_length == 0) { - AssertFatal(1==0,"long prach not supported for numerology %d\n",mu); - } - if (fp->N_RB_UL == 32) { - prach2 = prach[aa] + (Ncp<<2); // Ncp is for 30.72 Ms/s, so multiply by 2 for I/Q, and 2 for 61.44Msps - if (slot%(fp->slots_per_subframe/2)==0 && prachStartSymbol == 0) - prach2+=64; // 32 samples @ 61.44 Ms/s in first symbol of each half subframe - dftlen=512; - dftsize = DFT_512; - } - else if (fp->N_RB_UL == 66) { - prach2 = prach[aa] + (Ncp<<3); // Ncp is for 30.72 Ms/s, so multiply by 4 for I/Q, and 2 for 122.88Msps - if (slot%(fp->slots_per_subframe/2)==0 && prachStartSymbol == 0) - prach2+=128; // 64 samples @ 122.88 Ms/s in first symbol of each half subframe - dftlen=1024; - dftsize = DFT_1024; - } - else { - AssertFatal(1==0,"N_RB_UL %d not support for numerology %d\n",fp->N_RB_UL,mu); - } - - dft(dftsize,prach2,rxsigF[aa],1); - if (prachFormat != 9/*C0*/) { - dft(dftsize,prach2+dftlen*2,rxsigF[aa]+dftlen*2,1); - reps++; - } - - if (prachFormat == 5/*A2*/ || prachFormat == 6/*A3*/|| prachFormat == 8/*B4*/ || prachFormat == 10/*C2*/) { - dft(dftsize,prach2+dftlen*4,rxsigF[aa]+dftlen*4,1); - dft(dftsize,prach2+dftlen*6,rxsigF[aa]+dftlen*6,1); - reps+=2; - } - if (prachFormat == 6/*A3*/ || prachFormat == 8/*B4*/) { - dft(dftsize,prach2+dftlen*8,rxsigF[aa]+dftlen*8,1); - dft(dftsize,prach2+dftlen*10,rxsigF[aa]+dftlen*10,1); - reps+=2; - } - if (prachFormat == 8/*B4*/) { - for (int i=6;i<12;i++) - dft(dftsize,prach2+(dftlen*2*i),rxsigF[aa]+(dftlen*2*i),1); - reps+=6; - } - } - else { - AssertFatal(1==0,"Numerology not supported\n"); - } + int16_t *prach2 = prach[aa] + (2*Ncp); // times 2 for complex samples + for (int i = 0; i < reps; i++) + dft(dftsize, prach2 + 2*dftlen*i, rxsigF[aa] + 2*dftlen*i, 1); //LOG_M("ru_rxsigF_tmp.m","rxsFtmp", rxsigF[aa], dftlen*2*reps, 1, 1); diff --git a/openair1/PHY/NR_TRANSPORT/nr_scrambling.c b/openair1/PHY/NR_TRANSPORT/nr_scrambling.c index b68ad2d89f..8a49a7ffe0 100644 --- a/openair1/PHY/NR_TRANSPORT/nr_scrambling.c +++ b/openair1/PHY/NR_TRANSPORT/nr_scrambling.c @@ -40,7 +40,7 @@ void nr_codeword_scrambling(uint8_t *in, __m256i c = ((__m256i*)in)[i]; uint32_t in32 = _mm256_movemask_epi8(_mm256_slli_epi16(c,7)); out[i]=(in32^s); - //printf("in[%d] %x => %x\n",i,in32,out[i]); + LOG_D(PHY,"in[%d] %x => %x\n",i,in32,out[i]); s=lte_gold_generic(&x1, &x2, 0); } #elif defined(__SSE4__) @@ -52,6 +52,7 @@ void nr_codeword_scrambling(uint8_t *in, ((uint16_t*)&in32)[0] = _mm_movemask_epi8(_mm_slli_epi16(in128[0],7)); ((uint16_t*)&in32)[1] = _mm_movemask_epi8(_mm_slli_epi16(in128[1],7)); out[i]=(in32^s); + LOG_D(PHY,"in[%d] %x => %x\n",i,in32,out[i]); s=lte_gold_generic(&x1, &x2, 0); } //#elsif defined(__arm__) || defined(__aarch64) diff --git a/openair1/PHY/NR_TRANSPORT/nr_transport_common_proto.h b/openair1/PHY/NR_TRANSPORT/nr_transport_common_proto.h index 2daf2af1fb..74d19bf6f6 100644 --- a/openair1/PHY/NR_TRANSPORT/nr_transport_common_proto.h +++ b/openair1/PHY/NR_TRANSPORT/nr_transport_common_proto.h @@ -60,14 +60,6 @@ uint32_t nr_get_G(uint16_t nb_rb, uint16_t nb_symb_sch, uint8_t nb_re_dmrs, uint uint32_t nr_get_E(uint32_t G, uint8_t C, uint8_t Qm, uint8_t Nl, uint8_t r); -uint8_t nr_get_Qm_ul(uint8_t Imcs, uint8_t table_idx); - -uint8_t nr_get_Qm_dl(uint8_t Imcs, uint8_t table_idx); - -uint32_t nr_get_code_rate_ul(uint8_t Imcs, uint8_t table_idx); - -uint32_t nr_get_code_rate_dl(uint8_t Imcs, uint8_t table_idx); - void compute_nr_prach_seq(uint8_t short_sequence, uint8_t num_sequences, uint8_t rootSequenceIndex, diff --git a/openair1/PHY/NR_TRANSPORT/nr_transport_proto.h b/openair1/PHY/NR_TRANSPORT/nr_transport_proto.h index b62698c748..e3b7efacfb 100644 --- a/openair1/PHY/NR_TRANSPORT/nr_transport_proto.h +++ b/openair1/PHY/NR_TRANSPORT/nr_transport_proto.h @@ -106,7 +106,7 @@ NR_gNB_DLSCH_t *new_gNB_dlsch(NR_DL_FRAME_PARMS *frame_parms, uint8_t abstraction_flag, uint16_t N_RB); -void free_gNB_dlsch(NR_gNB_DLSCH_t **dlschptr, uint16_t N_RB); +void free_gNB_dlsch(NR_gNB_DLSCH_t **dlschptr, uint16_t N_RB, const NR_DL_FRAME_PARMS* frame_parms); /** \brief This function is the top-level entry point to PUSCH demodulation, after frequency-domain transformation and channel estimation. It performs - RB extraction (signal and channel estimates) @@ -136,21 +136,22 @@ int nr_rx_pusch(PHY_VARS_gNB *gNB, @param nb_rb_pusch The number of RBs allocated (used for Resource Allocation Type 1 in NR) @param frame_parms, Pointer to frame descriptor structure */ -void nr_ulsch_extract_rbs_single(int32_t **rxdataF, - NR_gNB_PUSCH *pusch_vars, - int slot, - unsigned char symbol, - uint8_t is_dmrs_symbol, - nfapi_nr_pusch_pdu_t *pusch_pdu, - NR_DL_FRAME_PARMS *frame_parms); +void nr_ulsch_extract_rbs(int32_t **rxdataF, + NR_gNB_PUSCH *pusch_vars, + int slot, + unsigned char symbol, + uint8_t is_dmrs_symbol, + nfapi_nr_pusch_pdu_t *pusch_pdu, + NR_DL_FRAME_PARMS *frame_parms); void nr_ulsch_scale_channel(int32_t **ul_ch_estimates_ext, NR_DL_FRAME_PARMS *frame_parms, - NR_gNB_ULSCH_t **ulsch_gNB, - uint8_t symbol, - uint8_t start_symbol, - uint16_t nb_rb, - pusch_dmrs_type_t pusch_dmrs_type); + NR_gNB_ULSCH_t *ulsch_gNB, + uint8_t symbol, + uint8_t is_dmrs_symbol, + uint32_t len, + uint8_t nrOfLayers, + uint16_t nb_rb); /** \brief This function computes the average channel level over all allocated RBs and antennas (TX/RX) in order to compute output shift for compensated signal @param ul_ch_estimates_ext Channel estimates in allocated RBs @@ -184,9 +185,10 @@ void nr_ulsch_channel_compensation(int **rxdataF_ext, int **ul_ch_mag, int **ul_ch_magb, int **rxdataF_comp, - int **rho, + int ***rho, NR_DL_FRAME_PARMS *frame_parms, unsigned char symbol, + int length, uint8_t is_dmrs_symbol, unsigned char mod_order, uint8_t nrOfLayers, @@ -254,8 +256,8 @@ void nr_ulsch_64qam_llr(int32_t *rxdataF_comp, @param mod_order modulation order */ void nr_ulsch_compute_llr(int32_t *rxdataF_comp, - int32_t **ul_ch_mag, - int32_t **ul_ch_magb, + int32_t *ul_ch_mag, + int32_t *ul_ch_magb, int16_t *ulsch_llr, uint32_t nb_rb, uint32_t nb_re, @@ -335,10 +337,11 @@ void init_prach_ru_list(RU_t *ru); void free_nr_ru_prach_entry(RU_t *ru, int prach_id); uint8_t get_nr_prach_duration(uint8_t prach_format); -void nr_generate_csi_rs(PHY_VARS_gNB *gNB, +void nr_generate_csi_rs(NR_DL_FRAME_PARMS frame_parms, + int32_t **dataF, int16_t amp, - nfapi_nr_dl_tti_csi_rs_pdu_rel15_t csi_params, - uint16_t cell_id, + nr_csi_rs_info_t *nr_csi_rs_info, + nfapi_nr_dl_tti_csi_rs_pdu_rel15_t *csi_params, int slot); void free_nr_prach_entry(PHY_VARS_gNB *gNB, int prach_id); diff --git a/openair1/PHY/NR_TRANSPORT/nr_ulsch.c b/openair1/PHY/NR_TRANSPORT/nr_ulsch.c index 1cb503489b..5c6839366c 100644 --- a/openair1/PHY/NR_TRANSPORT/nr_ulsch.c +++ b/openair1/PHY/NR_TRANSPORT/nr_ulsch.c @@ -42,15 +42,14 @@ int16_t find_nr_ulsch(uint16_t rnti, PHY_VARS_gNB *gNB,find_type_t type) { AssertFatal(gNB!=NULL,"gNB is null\n"); for (i=0; inumber_of_nr_ulsch_max; i++) { AssertFatal(gNB->ulsch[i]!=NULL,"gNB->ulsch[%d] is null\n",i); - AssertFatal(gNB->ulsch[i][0]!=NULL,"gNB->ulsch[%d][0] is null\n",i); - LOG_D(PHY,"searching for rnti %x : ulsch_index %d=> harq_mask %x, rnti %x, first_free_index %d\n", rnti,i,gNB->ulsch[i][0]->harq_mask,gNB->ulsch[i][0]->rnti,first_free_index); - if ((gNB->ulsch[i][0]->harq_mask >0) && - (gNB->ulsch[i][0]->rnti==rnti)) return i; - else if ((gNB->ulsch[i][0]->harq_mask == 0) && (first_free_index==-1)) first_free_index=i; + LOG_D(PHY,"searching for rnti %x : ulsch_index %d=> harq_mask %x, rnti %x, first_free_index %d\n", rnti,i,gNB->ulsch[i]->harq_mask,gNB->ulsch[i]->rnti,first_free_index); + if ((gNB->ulsch[i]->harq_mask >0) && + (gNB->ulsch[i]->rnti==rnti)) return i; + else if ((gNB->ulsch[i]->harq_mask == 0) && (first_free_index==-1)) first_free_index=i; } if (type == SEARCH_EXIST) return -1; if (first_free_index != -1) - gNB->ulsch[first_free_index][0]->rnti = 0; + gNB->ulsch[first_free_index]->rnti = 0; return first_free_index; } @@ -64,7 +63,7 @@ void nr_fill_ulsch(PHY_VARS_gNB *gNB, AssertFatal( (ulsch_id>=0) && (ulsch_idnumber_of_nr_ulsch_max), "illegal or no ulsch_id found!!! rnti %04x ulsch_id %d\n",ulsch_pdu->rnti,ulsch_id); - NR_gNB_ULSCH_t *ulsch = gNB->ulsch[ulsch_id][0]; + NR_gNB_ULSCH_t *ulsch = gNB->ulsch[ulsch_id]; int harq_pid = ulsch_pdu->pusch_data.harq_process_id; ulsch->rnti = ulsch_pdu->rnti; //ulsch->rnti_type; @@ -86,6 +85,33 @@ void nr_ulsch_unscrambling(int16_t* llr, uint32_t size, uint32_t Nid, uint32_t n nr_codeword_unscrambling(llr, size, 0, Nid, n_RNTI); } +void nr_ulsch_layer_demapping(int16_t *llr_cw, + uint8_t Nl, + uint8_t mod_order, + uint32_t length, + int16_t **llr_layers) +{ + + switch (Nl) { + case 1: + memcpy((void*)llr_cw, (void*)llr_layers[0], (length)*sizeof(int16_t)); + break; + case 2: + case 3: + case 4: + for (int i=0; i<(length/Nl/mod_order); i++) { + for (int l=0; lnumber_of_nr_ulsch_max;i++) { diff --git a/openair1/PHY/NR_TRANSPORT/nr_ulsch.h b/openair1/PHY/NR_TRANSPORT/nr_ulsch.h index 0791fd2bbc..c7229bc5d0 100644 --- a/openair1/PHY/NR_TRANSPORT/nr_ulsch.h +++ b/openair1/PHY/NR_TRANSPORT/nr_ulsch.h @@ -71,6 +71,12 @@ uint32_t nr_ulsch_decoding(PHY_VARS_gNB *phy_vars_gNB, void nr_ulsch_unscrambling(int16_t* llr, uint32_t size, uint32_t Nid, uint32_t n_RNTI); +void nr_ulsch_layer_demapping(int16_t *llr_cw, + uint8_t Nl, + uint8_t mod_order, + uint32_t length, + int16_t **llr_layers); + void nr_ulsch_procedures(PHY_VARS_gNB *gNB, int frame_rx, int slot_rx, diff --git a/openair1/PHY/NR_TRANSPORT/nr_ulsch_decoding.c b/openair1/PHY/NR_TRANSPORT/nr_ulsch_decoding.c index 8a7b1dbdd8..355dbafc6f 100644 --- a/openair1/PHY/NR_TRANSPORT/nr_ulsch_decoding.c +++ b/openair1/PHY/NR_TRANSPORT/nr_ulsch_decoding.c @@ -58,8 +58,7 @@ void free_gNB_ulsch(NR_gNB_ULSCH_t **ulschptr, uint16_t N_RB_UL) { - int i,r; - uint16_t a_segments = MAX_NUM_NR_ULSCH_SEGMENTS; //number of segments to be allocated + uint16_t a_segments = MAX_NUM_NR_ULSCH_SEGMENTS_PER_LAYER*NR_MAX_NB_LAYERS; //number of segments to be allocated NR_gNB_ULSCH_t *ulsch = *ulschptr; if (N_RB_UL != 273) { @@ -67,19 +66,18 @@ void free_gNB_ulsch(NR_gNB_ULSCH_t **ulschptr, uint16_t N_RB_UL) a_segments = a_segments/273 +1; } - for (i=0; iharq_processes[i]) { if (ulsch->harq_processes[i]->b) { free_and_zero(ulsch->harq_processes[i]->b); ulsch->harq_processes[i]->b = NULL; } - for (r=0; rharq_processes[i]->c[r]); free_and_zero(ulsch->harq_processes[i]->d[r]); - free_and_zero(ulsch->harq_processes[i]->w[r]); - nrLDPC_free_mem(ulsch->harq_processes[i]->p_nrLDPC_procBuf[r]); - ulsch->harq_processes[i]->p_nrLDPC_procBuf[r] = NULL; } + free_and_zero(ulsch->harq_processes[i]->c); + free_and_zero(ulsch->harq_processes[i]->d); free_and_zero(ulsch->harq_processes[i]); ulsch->harq_processes[i] = NULL; } @@ -93,7 +91,7 @@ NR_gNB_ULSCH_t *new_gNB_ulsch(uint8_t max_ldpc_iterations, uint16_t N_RB_UL) NR_gNB_ULSCH_t *ulsch; uint8_t i,r; - uint16_t a_segments = MAX_NUM_NR_ULSCH_SEGMENTS; //number of segments to be allocated + uint16_t a_segments = MAX_NUM_NR_ULSCH_SEGMENTS_PER_LAYER*NR_MAX_NB_LAYERS; //number of segments to be allocated if (N_RB_UL != 273) { a_segments = a_segments*N_RB_UL; @@ -102,22 +100,22 @@ NR_gNB_ULSCH_t *new_gNB_ulsch(uint8_t max_ldpc_iterations, uint16_t N_RB_UL) uint32_t ulsch_bytes = a_segments*1056; // allocated bytes per segment ulsch = (NR_gNB_ULSCH_t *)malloc16_clear(sizeof(NR_gNB_ULSCH_t)); - + ulsch->max_ldpc_iterations = max_ldpc_iterations; ulsch->Mlimit = 4; - + for (i=0; iharq_processes[i] = (NR_UL_gNB_HARQ_t *)malloc16_clear(sizeof(NR_UL_gNB_HARQ_t)); ulsch->harq_processes[i]->b = (uint8_t*)malloc16_clear(ulsch_bytes); + ulsch->harq_processes[i]->c = (uint8_t**)malloc16_clear(a_segments*sizeof(uint8_t *)); + ulsch->harq_processes[i]->d = (int16_t**)malloc16_clear(a_segments*sizeof(int16_t *)); for (r=0; rharq_processes[i]->p_nrLDPC_procBuf[r] = nrLDPC_init_mem(); ulsch->harq_processes[i]->c[r] = (uint8_t*)malloc16_clear(8448*sizeof(uint8_t)); ulsch->harq_processes[i]->d[r] = (int16_t*)malloc16_clear((68*384)*sizeof(int16_t)); - ulsch->harq_processes[i]->w[r] = (int16_t*)malloc16_clear((3*(6144+64))*sizeof(int16_t)); } } - + return(ulsch); } @@ -172,11 +170,9 @@ void clean_gNB_ulsch(NR_gNB_ULSCH_t *ulsch) ulsch->harq_processes[i]->C=0; /// Pointers to code blocks after LDPC coding (38.212 V15.4.0 section 5.3.2) //int16_t *d[MAX_NUM_NR_ULSCH_SEGMENTS]; - /// LDPC processing buffer - //t_nrLDPC_procBuf* p_nrLDPC_procBuf[MAX_NUM_NR_ULSCH_SEGMENTS]; ulsch->harq_processes[i]->Z=0; /// code blocks after bit selection in rate matching for LDPC code (38.212 V15.4.0 section 5.4.2.1) - //int16_t e[MAX_NUM_NR_DLSCH_SEGMENTS][3*8448]; + //int16_t e[MAX_NUM_NR_ULSCH_SEGMENTS][3*8448]; ulsch->harq_processes[i]->E=0; @@ -238,7 +234,6 @@ void nr_processULSegment(void* arg) { int rv_index = rdata->rv_index; int r_offset = rdata->r_offset; uint8_t kc = rdata->Kc; - uint32_t Tbslbrm = rdata->Tbslbrm; short* ulsch_llr = rdata->ulsch_llr; int max_ldpc_iterations = p_decoderParms->numMaxIter; int8_t llrProcBuf[OAI_UL_LDPC_MAX_NUM_LLR] __attribute__ ((aligned(32))); @@ -248,8 +243,6 @@ void nr_processULSegment(void* arg) { __m128i *pv = (__m128i*)&z; __m128i *pl = (__m128i*)&l; - - uint8_t Ilbrm = 0; Kr = ulsch_harq->K; Kr_bytes = Kr>>3; @@ -266,9 +259,12 @@ void nr_processULSegment(void* arg) { //////////////////////////// ulsch_llr =====> ulsch_harq->e ////////////////////////////// + /// code blocks after bit selection in rate matching for LDPC code (38.212 V15.4.0 section 5.4.2.1) + int16_t harq_e[3*8448]; + nr_deinterleaving_ldpc(E, Qm, - ulsch_harq->e[r], + harq_e, ulsch_llr+r_offset); //for (int i =0; i<16; i++) @@ -277,16 +273,7 @@ void nr_processULSegment(void* arg) { stop_meas(&phy_vars_gNB->ulsch_deinterleaving_stats); - /*LOG_D(PHY,"HARQ_PID %d Rate Matching Segment %d (coded bits %d,unpunctured/repeated bits %d, TBS %d, mod_order %d, nb_rb %d, Nl %d, rv %d, round %d)...\n", - harq_pid,r, G, - Kr*3, - ulsch_harq->TBS, - Qm, - nb_rb, - n_layers, - pusch_pdu->pusch_data.rv_index, - ulsch_harq->round);*/ - ////////////////////////////////////////////////////////////////////////////////////////// + ////////////////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////////////// @@ -297,12 +284,11 @@ void nr_processULSegment(void* arg) { //start_meas(&phy_vars_gNB->ulsch_rate_unmatching_stats); - if (nr_rate_matching_ldpc_rx(Ilbrm, - Tbslbrm, + if (nr_rate_matching_ldpc_rx(rdata->tbslbrm, p_decoderParms->BG, p_decoderParms->Z, ulsch_harq->d[r], - ulsch_harq->e[r], + harq_e, ulsch_harq->C, rv_index, ulsch_harq->new_rx, @@ -361,18 +347,17 @@ void nr_processULSegment(void* arg) { no_iteration_ldpc = nrLDPC_decoder(p_decoderParms, (int8_t*)&pl[0], llrProcBuf, - ulsch_harq->p_nrLDPC_procBuf[r], p_procTime); if (check_crc((uint8_t*)llrProcBuf,length_dec,ulsch_harq->F,crc_type)) { #ifdef PRINT_CRC_CHECK - LOG_I(PHY, "Segment %d CRC OK, iterations %d/%d\n",r,no_iteration_ldpc,max_ldpc_iterations); + LOG_I(PHY,"Segment %d CRC OK, iterations %d/%d\n",r,no_iteration_ldpc,max_ldpc_iterations); #endif rdata->decodeIterations = no_iteration_ldpc; if (rdata->decodeIterations > p_decoderParms->numMaxIter) rdata->decodeIterations--; } else { #ifdef PRINT_CRC_CHECK - LOG_I(PHY, "segment %d CRC NOK\n",r); + LOG_I(PHY,"CRC NOK\n"); #endif rdata->decodeIterations = max_ldpc_iterations + 1; } @@ -399,7 +384,6 @@ uint32_t nr_ulsch_decoding(PHY_VARS_gNB *phy_vars_gNB, uint32_t r_offset; uint32_t offset; int kc; - int Tbslbrm; int E; int8_t llrProcBuf[22*384]; int ret = 0; @@ -424,7 +408,7 @@ uint32_t nr_ulsch_decoding(PHY_VARS_gNB *phy_vars_gNB, #endif - NR_gNB_ULSCH_t *ulsch = phy_vars_gNB->ulsch[ULSCH_id][0]; + NR_gNB_ULSCH_t *ulsch = phy_vars_gNB->ulsch[ULSCH_id]; NR_gNB_PUSCH *pusch = phy_vars_gNB->pusch_vars[ULSCH_id]; NR_UL_gNB_HARQ_t *harq_process = ulsch->harq_processes[harq_pid]; @@ -441,13 +425,10 @@ uint32_t nr_ulsch_decoding(PHY_VARS_gNB *phy_vars_gNB, phy_vars_gNB->nbDecode = 0; harq_process->processedSegments = 0; - - double Coderate = 0.0; - uint8_t Ilbrm = 0; + // ------------------------------------------------------------------ uint16_t nb_rb = pusch_pdu->rb_size; uint8_t Qm = pusch_pdu->qam_mod_order; - uint16_t R = pusch_pdu->target_code_rate; uint8_t mcs = pusch_pdu->mcs_index; uint8_t n_layers = pusch_pdu->nrOfLayers; // ------------------------------------------------------------------ @@ -472,19 +453,18 @@ uint32_t nr_ulsch_decoding(PHY_VARS_gNB *phy_vars_gNB, if (harq_process->ndi != pusch_pdu->pusch_data.new_data_indicator) { harq_process->new_rx = true; harq_process->ndi = pusch_pdu->pusch_data.new_data_indicator; - dtx_det = 1; - LOG_E(PHY,"Missed ULSCH detection. NDI toggled but rv %d does not correspond to first reception\n",pusch_pdu->pusch_data.rv_index); + + LOG_D(PHY,"Missed ULSCH detection. NDI toggled but rv %d does not correspond to first reception\n",pusch_pdu->pusch_data.rv_index); } A = (harq_process->TBS)<<3; - LOG_D(NR_PHY, "ULSCH Decoding, harq_pid %d TBS %d G %d mcs %d Nl %d nb_rb %d, Qm %d, n_layers %d, Coderate %d\n", harq_pid, A, G, mcs, n_layers, nb_rb, Qm, n_layers, R); + // target_code_rate is in 0.1 units + float Coderate = (float) pusch_pdu->target_code_rate / 10240.0f; + + LOG_D(PHY,"ULSCH Decoding, harq_pid %d TBS %d G %d mcs %d Nl %d nb_rb %d, Qm %d, Coderate %f RV %d round %d\n", + harq_pid, A, G, mcs, n_layers, nb_rb, Qm, Coderate, pusch_pdu->pusch_data.rv_index, harq_process->round); - if (R<1024) - Coderate = (float) R /(float) 1024; - else - Coderate = (float) R /(float) 2048; - if ((A <=292) || ((A<=3824) && (Coderate <= 0.6667)) || Coderate <= 0.25){ p_decParams->BG = 2; kc = 52; @@ -552,12 +532,17 @@ uint32_t nr_ulsch_decoding(PHY_VARS_gNB *phy_vars_gNB, &harq_process->F, p_decParams->BG); + if (harq_process->C>MAX_NUM_NR_DLSCH_SEGMENTS_PER_LAYER*n_layers) { + LOG_E(PHY,"nr_segmentation.c: too many segments %d, B %d\n",harq_process->C,harq_process->B); + return(-1); + } + + #ifdef DEBUG_ULSCH_DECODING printf("ulsch decoding nr segmentation Z %d\n", harq_process->Z); if (!frame%100) printf("K %d C %d Z %d \n", harq_process->K, harq_process->C, harq_process->Z); #endif - Tbslbrm = nr_compute_tbslbrm(0,nb_rb,n_layers); p_decParams->Z = harq_process->Z; @@ -567,7 +552,7 @@ uint32_t nr_ulsch_decoding(PHY_VARS_gNB *phy_vars_gNB, r_offset = 0; - uint16_t a_segments = MAX_NUM_NR_ULSCH_SEGMENTS; //number of segments to be allocated + uint16_t a_segments = MAX_NUM_NR_ULSCH_SEGMENTS_PER_LAYER*n_layers; //number of segments to be allocated if (nb_rb != 273) { a_segments = a_segments*nb_rb; @@ -635,18 +620,19 @@ uint32_t nr_ulsch_decoding(PHY_VARS_gNB *phy_vars_gNB, t_nrLDPC_time_stats procTime = {0}; t_nrLDPC_time_stats* p_procTime = &procTime ; + /// code blocks after bit selection in rate matching for LDPC code (38.212 V15.4.0 section 5.4.2.1) + int16_t harq_e[3*8448]; nr_deinterleaving_ldpc(E, Qm, - harq_process->e[r], + harq_e, ulsch_llr+r_offset); - if (nr_rate_matching_ldpc_rx(Ilbrm, - Tbslbrm, + if (nr_rate_matching_ldpc_rx(pusch_pdu->maintenance_parms_v3.tbSizeLbrmBytes, p_decParams->BG, p_decParams->Z, harq_process->d[r], - harq_process->e[r], + harq_e, harq_process->C, pusch_pdu->pusch_data.rv_index, harq_process->new_rx, @@ -676,7 +662,6 @@ uint32_t nr_ulsch_decoding(PHY_VARS_gNB *phy_vars_gNB, no_iteration_ldpc = nrLDPC_decoder(p_decParams, (int8_t*)&pl[0], llrProcBuf, - harq_process->p_nrLDPC_procBuf[r], p_procTime); } @@ -782,10 +767,10 @@ uint32_t nr_ulsch_decoding(PHY_VARS_gNB *phy_vars_gNB, rdata->r_offset = r_offset; rdata->Kr_bytes = Kr_bytes; rdata->rv_index = pusch_pdu->pusch_data.rv_index; - rdata->Tbslbrm = Tbslbrm; rdata->offset = offset; rdata->ulsch = ulsch; rdata->ulsch_id = ULSCH_id; + rdata->tbslbrm = pusch_pdu->maintenance_parms_v3.tbSizeLbrmBytes; pushTpool(phy_vars_gNB->threadPool,req); phy_vars_gNB->nbDecode++; LOG_D(PHY,"Added a block to decode, in pipe: %d\n",phy_vars_gNB->nbDecode); diff --git a/openair1/PHY/NR_TRANSPORT/nr_ulsch_demodulation.c b/openair1/PHY/NR_TRANSPORT/nr_ulsch_demodulation.c index 681a9eae16..4b8315e1ce 100644 --- a/openair1/PHY/NR_TRANSPORT/nr_ulsch_demodulation.c +++ b/openair1/PHY/NR_TRANSPORT/nr_ulsch_demodulation.c @@ -302,36 +302,32 @@ void nr_idft(int32_t *z, uint32_t Msc_PUSCH) } -void nr_ulsch_extract_rbs_single(int32_t **rxdataF, - NR_gNB_PUSCH *pusch_vars, - int slot, - unsigned char symbol, - uint8_t is_dmrs_symbol, - nfapi_nr_pusch_pdu_t *pusch_pdu, - NR_DL_FRAME_PARMS *frame_parms) -{ +void nr_ulsch_extract_rbs(int32_t **rxdataF, + NR_gNB_PUSCH *pusch_vars, + int slot, + unsigned char symbol, + uint8_t is_dmrs_symbol, + nfapi_nr_pusch_pdu_t *pusch_pdu, + NR_DL_FRAME_PARMS *frame_parms) { unsigned short start_re, re, nb_re_pusch; - unsigned char aarx; + unsigned char aarx, aatx; uint32_t rxF_ext_index = 0; uint32_t ul_ch0_ext_index = 0; uint32_t ul_ch0_index = 0; - uint8_t k_prime; - uint16_t n; int16_t *rxF,*rxF_ext; int *ul_ch0,*ul_ch0_ext; - uint8_t delta = 0; int soffset = (slot&3)*frame_parms->symbols_per_slot*frame_parms->ofdm_symbol_size; -#ifdef DEBUG_RB_EXT +#ifdef DEBUG_RB_EXT printf("--------------------symbol = %d-----------------------\n", symbol); printf("--------------------ch_ext_index = %d-----------------------\n", symbol*NR_NB_SC_PER_RB * pusch_pdu->rb_size); - #endif - uint8_t is_dmrs_re; + uint8_t is_data_re; start_re = (frame_parms->first_carrier_offset + (pusch_pdu->rb_start + pusch_pdu->bwp_start) * NR_NB_SC_PER_RB)%frame_parms->ofdm_symbol_size; nb_re_pusch = NR_NB_SC_PER_RB * pusch_pdu->rb_size; + #ifdef __AVX2__ int nb_re_pusch2 = nb_re_pusch + (nb_re_pusch&7); #else @@ -340,62 +336,64 @@ void nr_ulsch_extract_rbs_single(int32_t **rxdataF, for (aarx = 0; aarx < frame_parms->nb_antennas_rx; aarx++) { - rxF = (int16_t *)&rxdataF[aarx][soffset+(symbol * frame_parms->ofdm_symbol_size)]; - rxF_ext = (int16_t *)&pusch_vars->rxdataF_ext[aarx][symbol * nb_re_pusch2]; // [hna] rxdataF_ext isn't contiguous in order to solve an alignment problem ib llr computation in case of mod_order = 4, 6 - - ul_ch0 = &pusch_vars->ul_ch_estimates[aarx][pusch_vars->dmrs_symbol*frame_parms->ofdm_symbol_size]; // update channel estimates if new dmrs symbol are available - - ul_ch0_ext = &pusch_vars->ul_ch_estimates_ext[aarx][symbol*nb_re_pusch2]; - - n = 0; - k_prime = 0; - rxF_ext_index = 0; - ul_ch0_ext_index = 0; - ul_ch0_index = 0; - + rxF = (int16_t *)&rxdataF[aarx][soffset+(symbol * frame_parms->ofdm_symbol_size)]; + rxF_ext = (int16_t *)&pusch_vars->rxdataF_ext[aarx][symbol * nb_re_pusch2]; // [hna] rxdataF_ext isn't contiguous in order to solve an alignment problem ib llr computation in case of mod_order = 4, 6 + if (is_dmrs_symbol == 0) { - // - //rxF[ ((start_re + re)*2) % (frame_parms->ofdm_symbol_size*2)]); - if (start_re + nb_re_pusch < frame_parms->ofdm_symbol_size) { - memcpy1((void*)rxF_ext, - (void*)&rxF[start_re*2], - nb_re_pusch*sizeof(int32_t)); + if (start_re + nb_re_pusch <= frame_parms->ofdm_symbol_size) { + memcpy1((void*)rxF_ext, (void*)&rxF[start_re*2], nb_re_pusch*sizeof(int32_t)); } else { - int neg_length = frame_parms->ofdm_symbol_size-start_re; - int pos_length = nb_re_pusch-neg_length; - - memcpy1((void*)rxF_ext,(void*)&rxF[start_re*2],neg_length*sizeof(int32_t)); - memcpy1((void*)&rxF_ext[2*neg_length],(void*)rxF,pos_length*sizeof(int32_t)); + int neg_length = frame_parms->ofdm_symbol_size-start_re; + int pos_length = nb_re_pusch-neg_length; + memcpy1((void*)rxF_ext,(void*)&rxF[start_re*2],neg_length*sizeof(int32_t)); + memcpy1((void*)&rxF_ext[2*neg_length],(void*)rxF,pos_length*sizeof(int32_t)); } - memcpy1((void*)ul_ch0_ext,(void*)ul_ch0,nb_re_pusch*sizeof(int32_t)); - } - else { - for (re = 0; re < nb_re_pusch; re++) { - is_dmrs_re = (re == get_dmrs_freq_idx_ul(n, k_prime, delta, pusch_pdu->dmrs_config_type)); + for (aatx = 0; aatx < pusch_pdu->nrOfLayers; aatx++) { + ul_ch0 = &pusch_vars->ul_ch_estimates[aatx*frame_parms->nb_antennas_rx+aarx][pusch_vars->dmrs_symbol*frame_parms->ofdm_symbol_size]; // update channel estimates if new dmrs symbol are available + ul_ch0_ext = &pusch_vars->ul_ch_estimates_ext[aatx*frame_parms->nb_antennas_rx+aarx][symbol*nb_re_pusch2]; + memcpy1((void*)ul_ch0_ext,(void*)ul_ch0,nb_re_pusch*sizeof(int32_t)); + } -#ifdef DEBUG_RB_EXT - printf("re = %d, kprime %d, n %d, is_dmrs_symbol = %d, symbol = %d\n", re, k_prime, n, is_dmrs_symbol, symbol); -#endif + } else { - /* save only data and respective channel estimates */ - if (is_dmrs_re == 0) { - rxF_ext[rxF_ext_index] = (rxF[ ((start_re + re)*2) % (frame_parms->ofdm_symbol_size*2)]); - rxF_ext[rxF_ext_index + 1] = (rxF[(((start_re + re)*2) + 1) % (frame_parms->ofdm_symbol_size*2)]); - ul_ch0_ext[ul_ch0_ext_index] = ul_ch0[ul_ch0_index]; + for (aatx = 0; aatx < pusch_pdu->nrOfLayers; aatx++) { + ul_ch0 = &pusch_vars->ul_ch_estimates[aatx*frame_parms->nb_antennas_rx+aarx][pusch_vars->dmrs_symbol*frame_parms->ofdm_symbol_size]; // update channel estimates if new dmrs symbol are available + ul_ch0_ext = &pusch_vars->ul_ch_estimates_ext[aatx*frame_parms->nb_antennas_rx+aarx][symbol*nb_re_pusch2]; -#ifdef DEBUG_RB_EXT - printf("dmrs symb %d: rxF_ext[%d] = (%d,%d), ul_ch0_ext[%d] = (%d,%d)\n", + rxF_ext_index = 0; + ul_ch0_ext_index = 0; + ul_ch0_index = 0; + for (re = 0; re < nb_re_pusch; re++) { + uint16_t k = start_re + re; + is_data_re = allowed_xlsch_re_in_dmrs_symbol(k, start_re, frame_parms->ofdm_symbol_size, pusch_pdu->num_dmrs_cdm_grps_no_data, pusch_pdu->dmrs_config_type); + if (++k >= frame_parms->ofdm_symbol_size) { + k -= frame_parms->ofdm_symbol_size; + } + + #ifdef DEBUG_RB_EXT + printf("re = %d, is_dmrs_symbol = %d, symbol = %d\n", re, is_dmrs_symbol, symbol); + #endif + + // save only data and respective channel estimates + if (is_data_re == 1) { + if (aatx == 0) { + rxF_ext[rxF_ext_index] = (rxF[ ((start_re + re)*2) % (frame_parms->ofdm_symbol_size*2)]); + rxF_ext[rxF_ext_index + 1] = (rxF[(((start_re + re)*2) + 1) % (frame_parms->ofdm_symbol_size*2)]); + rxF_ext_index +=2; + } + + ul_ch0_ext[ul_ch0_ext_index] = ul_ch0[ul_ch0_index]; + ul_ch0_ext_index++; + + #ifdef DEBUG_RB_EXT + printf("dmrs symb %d: rxF_ext[%d] = (%d,%d), ul_ch0_ext[%d] = (%d,%d)\n", is_dmrs_symbol,rxF_ext_index>>1, rxF_ext[rxF_ext_index],rxF_ext[rxF_ext_index+1], ul_ch0_ext_index, ((int16_t*)&ul_ch0_ext[ul_ch0_ext_index])[0], ((int16_t*)&ul_ch0_ext[ul_ch0_ext_index])[1]); -#endif - ul_ch0_ext_index++; - rxF_ext_index +=2; - } else { - n += k_prime; - k_prime ^= 1; + #endif + } + ul_ch0_index++; } - ul_ch0_index++; } } } @@ -403,22 +401,25 @@ void nr_ulsch_extract_rbs_single(int32_t **rxdataF, void nr_ulsch_scale_channel(int **ul_ch_estimates_ext, NR_DL_FRAME_PARMS *frame_parms, - NR_gNB_ULSCH_t **ulsch_gNB, + NR_gNB_ULSCH_t *ulsch_gNB, uint8_t symbol, uint8_t is_dmrs_symbol, - unsigned short nb_rb, - pusch_dmrs_type_t pusch_dmrs_type) + uint32_t len, + uint8_t nrOfLayers, + unsigned short nb_rb) { #if defined(__x86_64__)||defined(__i386__) short rb, ch_amp; - unsigned char aarx; + unsigned char aarx,aatx; __m128i *ul_ch128, ch_amp128; + uint32_t nb_rb_0 = len/12 + ((len%12)?1:0); + // Determine scaling amplitude based the symbol - ch_amp = 1024*8; //((pilots) ? (ulsch_gNB[0]->sqrt_rho_b) : (ulsch_gNB[0]->sqrt_rho_a)); + ch_amp = 1024*8; //((pilots) ? (ulsch_gNB->sqrt_rho_b) : (ulsch_gNB->sqrt_rho_a)); LOG_D(PHY,"Scaling PUSCH Chest in OFDM symbol %d by %d, pilots %d nb_rb %d NCP %d symbol %d\n", symbol, ch_amp, is_dmrs_symbol, nb_rb, frame_parms->Ncp, symbol); // printf("Scaling PUSCH Chest in OFDM symbol %d by %d\n",symbol_mod,ch_amp); @@ -431,35 +432,22 @@ void nr_ulsch_scale_channel(int **ul_ch_estimates_ext, int off = 0; #endif - for (aarx=0; aarx < frame_parms->nb_antennas_rx; aarx++) { - - ul_ch128 = (__m128i *)&ul_ch_estimates_ext[aarx][symbol*(off+(nb_rb*NR_NB_SC_PER_RB))]; - - if (is_dmrs_symbol==1){ - if (pusch_dmrs_type == pusch_dmrs_type1) - nb_rb = nb_rb>>1; - else - nb_rb = (2*nb_rb)/3; - } - - for (rb=0;rbnb_antennas_rx; aarx++) { + ul_ch128 = (__m128i *)&ul_ch_estimates_ext[aatx*frame_parms->nb_antennas_rx+aarx][symbol*(off+(nb_rb*NR_NB_SC_PER_RB))]; + for (rb=0;rb < nb_rb_0;rb++) { ul_ch128[0] = _mm_mulhi_epi16(ul_ch128[0], ch_amp128); ul_ch128[0] = _mm_slli_epi16(ul_ch128[0], 3); ul_ch128[1] = _mm_mulhi_epi16(ul_ch128[1], ch_amp128); ul_ch128[1] = _mm_slli_epi16(ul_ch128[1], 3); - if (is_dmrs_symbol) { - ul_ch128+=2; - } else { - ul_ch128[2] = _mm_mulhi_epi16(ul_ch128[2], ch_amp128); - ul_ch128[2] = _mm_slli_epi16(ul_ch128[2], 3); - ul_ch128+=3; - - } + ul_ch128[2] = _mm_mulhi_epi16(ul_ch128[2], ch_amp128); + ul_ch128[2] = _mm_slli_epi16(ul_ch128[2], 3); + ul_ch128+=3; } } + } #endif } @@ -481,6 +469,8 @@ void nr_ulsch_channel_level(int **ul_ch_estimates_ext, int16_t x = factor2(len); int16_t y = (len)>>x; + + uint32_t nb_rb_0 = len/12 + ((len%12)?1:0); #ifdef __AVX2__ int off = ((nb_rb&1) == 1)? 4:0; @@ -488,14 +478,14 @@ void nr_ulsch_channel_level(int **ul_ch_estimates_ext, int off = 0; #endif - for (aatx = 0; aatx < nrOfLayers; aatx++) + for (aatx = 0; aatx < nrOfLayers; aatx++) { for (aarx = 0; aarx < frame_parms->nb_antennas_rx; aarx++) { //clear average level avg128U = _mm_setzero_si128(); ul_ch128=(__m128i *)&ul_ch_estimates_ext[aatx*frame_parms->nb_antennas_rx+aarx][symbol*(off+(nb_rb*12))]; - for (rb = 0; rb < len/12; rb++) { + for (rb = 0; rb < nb_rb_0; rb++) { avg128U = _mm_add_epi32(avg128U, _mm_srai_epi32(_mm_madd_epi16(ul_ch128[0], ul_ch128[0]), x)); avg128U = _mm_add_epi32(avg128U, _mm_srai_epi32(_mm_madd_epi16(ul_ch128[1], ul_ch128[1]), x)); avg128U = _mm_add_epi32(avg128U, _mm_srai_epi32(_mm_madd_epi16(ul_ch128[2], ul_ch128[2]), x)); @@ -506,8 +496,8 @@ void nr_ulsch_channel_level(int **ul_ch_estimates_ext, ((int32_t*)&avg128U)[1] + ((int32_t*)&avg128U)[2] + ((int32_t*)&avg128U)[3]) / y; - } + } _mm_empty(); _m_empty(); @@ -520,7 +510,7 @@ void nr_ulsch_channel_level(int **ul_ch_estimates_ext, int16x4_t *ul_ch128; symbol_mod = (symbol>=(7-frame_parms->Ncp)) ? symbol-(7-frame_parms->Ncp) : symbol; - + uint32_t nb_rb_0 = len/12 + ((len%12)?1:0); for (aatx=0; aatxnb_antennas_rx; aarx++) { //clear average level @@ -529,7 +519,7 @@ void nr_ulsch_channel_level(int **ul_ch_estimates_ext, ul_ch128 = (int16x4_t *)&ul_ch_estimates_ext[aatx*frame_parms->nb_antennas_rx+aarx][symbol*frame_parms->N_RB_UL*12]; - for (rb = 0; rb < nb_rb; rb++) { + for (rb = 0; rb < nb_rb_0; rb++) { // printf("rb %d : ",rb); // print_shorts("ch",&ul_ch128[0]); avg128U = vqaddq_s32(avg128U, vmull_s16(ul_ch128[0], ul_ch128[0])); @@ -568,14 +558,20 @@ void nr_ulsch_channel_level(int **ul_ch_estimates_ext, #endif } + + +//============================================================================================== +// Pre-processing for LLR computation +//============================================================================================== void nr_ulsch_channel_compensation(int **rxdataF_ext, int **ul_ch_estimates_ext, int **ul_ch_mag, int **ul_ch_magb, int **rxdataF_comp, - int **rho, + int ***rho, NR_DL_FRAME_PARMS *frame_parms, unsigned char symbol, + int length, uint8_t is_dmrs_symbol, unsigned char mod_order, uint8_t nrOfLayers, @@ -591,22 +587,21 @@ void nr_ulsch_channel_compensation(int **rxdataF_ext, #ifdef DEBUG_CH_COMP int16_t *rxF, *ul_ch; int prnt_idx; + for (int nl=0; nlnb_antennas_rx; aarx++) { + rxF = (int16_t *) &rxdataF_ext[aarx][symbol * (off + (nb_rb * 12))]; + ul_ch = (int16_t *) &ul_ch_estimates_ext[nl * frame_parms->nb_antennas_rx + aarx][symbol * (off + (nb_rb * 12))]; - for (int ant=0; antnb_antennas_rx; ant++) { - rxF = (int16_t *)&rxdataF_ext[ant][symbol*(off+(nb_rb*12))]; - ul_ch = (int16_t *)&ul_ch_estimates_ext[ant][symbol*(off+(nb_rb*12))]; - - printf("--------------------symbol = %d, mod_order = %d, output_shift = %d-----------------------\n", symbol, mod_order, output_shift); - printf("----------------Before compensation------------------\n"); - - for (prnt_idx=0;prnt_idx<12*5*2;prnt_idx+=2){ - - printf("rxF[%d] = (%d,%d)\n", prnt_idx>>1, rxF[prnt_idx],rxF[prnt_idx+1]); - printf("ul_ch[%d] = (%d,%d)\n", prnt_idx>>1, ul_ch[prnt_idx],ul_ch[prnt_idx+1]); + printf("--------symbol = %d, mod_order = %d, output_shift = %d, layer %i, antenna rx = %d -----------\n", + symbol, mod_order, output_shift, nl, aarx); + printf("----------------Before compensation------------------\n"); + for (prnt_idx = 0; prnt_idx < 12 * 5 * 2; prnt_idx += 2) { + printf("rxF[%d] = (%d,%d)\n", prnt_idx >> 1, rxF[prnt_idx], rxF[prnt_idx + 1]); + printf("ul_ch[%d] = (%d,%d)\n", prnt_idx >> 1, ul_ch[prnt_idx], ul_ch[prnt_idx + 1]); + } } } - #endif #ifdef DEBUG_CH_MAG @@ -637,20 +632,20 @@ void nr_ulsch_channel_compensation(int **rxdataF_ext, __m128i mmtmpD0,mmtmpD1,mmtmpD2,mmtmpD3,QAM_amp128={0},QAM_amp128b={0}; QAM_amp128b = _mm_setzero_si128(); + uint32_t nb_rb_0 = length/12 + ((length%12)?1:0); for (aatx=0; aatxnb_antennas_rx; aarx++) { - + for (aarx=0; aarxnb_antennas_rx; aarx++) { ul_ch128 = (__m128i *)&ul_ch_estimates_ext[aatx*frame_parms->nb_antennas_rx+aarx][symbol*(off+(nb_rb*12))]; ul_ch_mag128 = (__m128i *)&ul_ch_mag[aatx*frame_parms->nb_antennas_rx+aarx][symbol*(off+(nb_rb*12))]; ul_ch_mag128b = (__m128i *)&ul_ch_magb[aatx*frame_parms->nb_antennas_rx+aarx][symbol*(off+(nb_rb*12))]; @@ -658,7 +653,7 @@ void nr_ulsch_channel_compensation(int **rxdataF_ext, rxdataF_comp128 = (__m128i *)&rxdataF_comp[aatx*frame_parms->nb_antennas_rx+aarx][symbol*(off+(nb_rb*12))]; - for (rb=0; rb2) { // get channel amplitude if not QPSK @@ -679,6 +674,8 @@ void nr_ulsch_channel_compensation(int **rxdataF_ext, ul_ch_mag128[0] = _mm_mulhi_epi16(ul_ch_mag128[0],QAM_amp128); ul_ch_mag128[0] = _mm_slli_epi16(ul_ch_mag128[0],1); + ul_ch_mag128b[0] = _mm_mulhi_epi16(ul_ch_mag128b[0],QAM_amp128b); + ul_ch_mag128b[0] = _mm_slli_epi16(ul_ch_mag128b[0],1); // print_ints("ch: = ",(int32_t*)&mmtmpD0); // print_shorts("QAM_amp:",(int16_t*)&QAM_amp128); // print_shorts("mag:",(int16_t*)&ul_ch_mag128[0]); @@ -687,30 +684,24 @@ void nr_ulsch_channel_compensation(int **rxdataF_ext, ul_ch_mag128b[1] = ul_ch_mag128[1]; ul_ch_mag128[1] = _mm_mulhi_epi16(ul_ch_mag128[1],QAM_amp128); ul_ch_mag128[1] = _mm_slli_epi16(ul_ch_mag128[1],1); - - if (is_dmrs_symbol==0) { - mmtmpD0 = _mm_madd_epi16(ul_ch128[2],ul_ch128[2]); - mmtmpD0 = _mm_srai_epi32(mmtmpD0,output_shift); - mmtmpD1 = _mm_packs_epi32(mmtmpD0,mmtmpD0); - - ul_ch_mag128[2] = _mm_unpacklo_epi16(mmtmpD1,mmtmpD1); - ul_ch_mag128b[2] = ul_ch_mag128[2]; - - ul_ch_mag128[2] = _mm_mulhi_epi16(ul_ch_mag128[2],QAM_amp128); - ul_ch_mag128[2] = _mm_slli_epi16(ul_ch_mag128[2],1); - } - - ul_ch_mag128b[0] = _mm_mulhi_epi16(ul_ch_mag128b[0],QAM_amp128b); - ul_ch_mag128b[0] = _mm_slli_epi16(ul_ch_mag128b[0],1); - - + ul_ch_mag128b[1] = _mm_mulhi_epi16(ul_ch_mag128b[1],QAM_amp128b); ul_ch_mag128b[1] = _mm_slli_epi16(ul_ch_mag128b[1],1); - if (is_dmrs_symbol==0) { - ul_ch_mag128b[2] = _mm_mulhi_epi16(ul_ch_mag128b[2],QAM_amp128b); - ul_ch_mag128b[2] = _mm_slli_epi16(ul_ch_mag128b[2],1); - } + mmtmpD0 = _mm_madd_epi16(ul_ch128[2],ul_ch128[2]); + mmtmpD0 = _mm_srai_epi32(mmtmpD0,output_shift); + mmtmpD1 = _mm_packs_epi32(mmtmpD0,mmtmpD0); + + ul_ch_mag128[2] = _mm_unpacklo_epi16(mmtmpD1,mmtmpD1); + ul_ch_mag128b[2] = ul_ch_mag128[2]; + + ul_ch_mag128[2] = _mm_mulhi_epi16(ul_ch_mag128[2],QAM_amp128); + ul_ch_mag128[2] = _mm_slli_epi16(ul_ch_mag128[2],1); + + + ul_ch_mag128b[2] = _mm_mulhi_epi16(ul_ch_mag128b[2],QAM_amp128b); + ul_ch_mag128b[2] = _mm_slli_epi16(ul_ch_mag128b[2],1); + } // multiply by conjugated channel @@ -755,117 +746,153 @@ void nr_ulsch_channel_compensation(int **rxdataF_ext, // print_shorts("ch:",ul_ch128+1); // print_shorts("pack:",rxdataF_comp128+1); - if (is_dmrs_symbol==0) { - // multiply by conjugated channel - mmtmpD0 = _mm_madd_epi16(ul_ch128[2],rxdataF128[2]); - // mmtmpD0 contains real part of 4 consecutive outputs (32-bit) - mmtmpD1 = _mm_shufflelo_epi16(ul_ch128[2],_MM_SHUFFLE(2,3,0,1)); - mmtmpD1 = _mm_shufflehi_epi16(mmtmpD1,_MM_SHUFFLE(2,3,0,1)); - mmtmpD1 = _mm_sign_epi16(mmtmpD1,*(__m128i*)conjugate); - mmtmpD1 = _mm_madd_epi16(mmtmpD1,rxdataF128[2]); - // mmtmpD1 contains imag part of 4 consecutive outputs (32-bit) - mmtmpD0 = _mm_srai_epi32(mmtmpD0,output_shift); - mmtmpD1 = _mm_srai_epi32(mmtmpD1,output_shift); - mmtmpD2 = _mm_unpacklo_epi32(mmtmpD0,mmtmpD1); - mmtmpD3 = _mm_unpackhi_epi32(mmtmpD0,mmtmpD1); + // multiply by conjugated channel + mmtmpD0 = _mm_madd_epi16(ul_ch128[2],rxdataF128[2]); + // mmtmpD0 contains real part of 4 consecutive outputs (32-bit) + mmtmpD1 = _mm_shufflelo_epi16(ul_ch128[2],_MM_SHUFFLE(2,3,0,1)); + mmtmpD1 = _mm_shufflehi_epi16(mmtmpD1,_MM_SHUFFLE(2,3,0,1)); + mmtmpD1 = _mm_sign_epi16(mmtmpD1,*(__m128i*)conjugate); + mmtmpD1 = _mm_madd_epi16(mmtmpD1,rxdataF128[2]); + // mmtmpD1 contains imag part of 4 consecutive outputs (32-bit) + mmtmpD0 = _mm_srai_epi32(mmtmpD0,output_shift); + mmtmpD1 = _mm_srai_epi32(mmtmpD1,output_shift); + mmtmpD2 = _mm_unpacklo_epi32(mmtmpD0,mmtmpD1); + mmtmpD3 = _mm_unpackhi_epi32(mmtmpD0,mmtmpD1); - rxdataF_comp128[2] = _mm_packs_epi32(mmtmpD2,mmtmpD3); - // print_shorts("rx:",rxdataF128+2); - // print_shorts("ch:",ul_ch128+2); - // print_shorts("pack:",rxdataF_comp128+2); - - ul_ch128+=3; - ul_ch_mag128+=3; - ul_ch_mag128b+=3; - rxdataF128+=3; - rxdataF_comp128+=3; - } else { // we have a smaller PUSCH in symbols with pilots so skip last group of 4 REs and increment less - ul_ch128+=2; - ul_ch_mag128+=2; - ul_ch_mag128b+=2; - rxdataF128+=2; - rxdataF_comp128+=2; - } + rxdataF_comp128[2] = _mm_packs_epi32(mmtmpD2,mmtmpD3); + //print_shorts("rx:",rxdataF128+2); + //print_shorts("ch:",ul_ch128+2); + //print_shorts("pack:",rxdataF_comp128+2); + ul_ch128+=3; + ul_ch_mag128+=3; + ul_ch_mag128b+=3; + rxdataF128+=3; + rxdataF_comp128+=3; } } } if (rho) { + //we compute the Tx correlation matrix for each Rx antenna + //As an example the 2x2 MIMO case requires + //rho[aarx][nb_aatx*nb_aatx] = [cov(H_aarx_0,H_aarx_0) cov(H_aarx_0,H_aarx_1) + // cov(H_aarx_1,H_aarx_0) cov(H_aarx_1,H_aarx_1)], aarx=0,...,nb_antennas_rx-1 - for (aarx=0; aarxnb_antennas_rx; aarx++) { - rho128 = (__m128i *)&rho[aarx][symbol*frame_parms->N_RB_UL*12]; - ul_ch128 = (__m128i *)&ul_ch_estimates_ext[aarx][symbol*frame_parms->N_RB_UL*12]; - ul_ch128_2 = (__m128i *)&ul_ch_estimates_ext[2+aarx][symbol*frame_parms->N_RB_UL*12]; + int avg_rho_re[frame_parms->nb_antennas_rx][nrOfLayers*nrOfLayers]; + int avg_rho_im[frame_parms->nb_antennas_rx][nrOfLayers*nrOfLayers]; - for (rb=0; rbnb_antennas_rx; aarx++) { + for (aatx=0; aatx < nrOfLayers; aatx++) { + for (int atx=0; atx< nrOfLayers; atx++) { - // mmtmpD0 contains real part of 4 consecutive outputs (32-bit) - mmtmpD1 = _mm_shufflelo_epi16(ul_ch128[0],_MM_SHUFFLE(2,3,0,1)); - mmtmpD1 = _mm_shufflehi_epi16(mmtmpD1,_MM_SHUFFLE(2,3,0,1)); - mmtmpD1 = _mm_sign_epi16(mmtmpD1,*(__m128i*)&conjugate[0]); - // print_ints("im",&mmtmpD1); - mmtmpD1 = _mm_madd_epi16(mmtmpD1,ul_ch128_2[0]); - // mmtmpD1 contains imag part of 4 consecutive outputs (32-bit) - mmtmpD0 = _mm_srai_epi32(mmtmpD0,output_shift); - // print_ints("re(shift)",&mmtmpD0); - mmtmpD1 = _mm_srai_epi32(mmtmpD1,output_shift); - // print_ints("im(shift)",&mmtmpD1); - mmtmpD2 = _mm_unpacklo_epi32(mmtmpD0,mmtmpD1); - mmtmpD3 = _mm_unpackhi_epi32(mmtmpD0,mmtmpD1); - // print_ints("c0",&mmtmpD2); - // print_ints("c1",&mmtmpD3); - rho128[0] = _mm_packs_epi32(mmtmpD2,mmtmpD3); + avg_rho_re[aarx][aatx*nrOfLayers+atx] = 0; + avg_rho_im[aarx][aatx*nrOfLayers+atx] = 0; + rho128 = (__m128i *)&rho[aarx][aatx*nrOfLayers+atx][symbol*(off+(nb_rb*12))]; + ul_ch128 = (__m128i *)&ul_ch_estimates_ext[aatx*frame_parms->nb_antennas_rx+aarx][symbol*(off+(nb_rb*12))]; + ul_ch128_2 = (__m128i *)&ul_ch_estimates_ext[atx*frame_parms->nb_antennas_rx+aarx][symbol*(off+(nb_rb*12))]; - //print_shorts("rx:",ul_ch128_2); - //print_shorts("ch:",ul_ch128); - //print_shorts("pack:",rho128); + for (rb=0; rbrx_correlation[0][0][aarx] = signal_energy(&rho[aarx][aatx*nb_aatx+atx][symbol*nb_rb*12],rb*12); + avg_rho_re[aarx][aatx*nrOfLayers+atx] = 16*avg_rho_re[aarx][aatx*nrOfLayers+atx]/(nb_rb*12); + avg_rho_im[aarx][aatx*nrOfLayers+atx] = 16*avg_rho_im[aarx][aatx*nrOfLayers+atx]/(nb_rb*12); + //printf("rho[rx]%d tx%d tx%d = Re: %d Im: %d\n",aarx, aatx,atx, avg_rho_re[aarx][aatx*nb_aatx+atx], avg_rho_im[aarx][aatx*nb_aatx+atx]); + } + } } - } } @@ -1070,19 +1097,17 @@ void nr_ulsch_channel_compensation(int **rxdataF_ext, #ifdef DEBUG_CH_COMP + for (int nl2=0; nl2nb_antennas_rx; aarx2++) { + rxF = (int16_t *)&rxdataF_comp[nl2*frame_parms->nb_antennas_rx+aarx2][(symbol*(off+(nb_rb*12)))]; - for (int ant=0; antnb_antennas_rx; ant++) { - rxF = (int16_t *)&rxdataF_comp[ant][(symbol*(off+(nb_rb*12)))]; - - printf("----------------After compansation------------------\n"); - - for (prnt_idx=0;prnt_idx<12*5*2;prnt_idx+=2){ - - printf("rxF[%d] = (%d,%d)\n", prnt_idx>>1, rxF[prnt_idx],rxF[prnt_idx+1]); + printf("--------After compansation, layer %i, antenna rx %i----------\n", nl2, aarx2); + for (prnt_idx=0;prnt_idx<12*5*2;prnt_idx+=2){ + printf("rxF[%d] = (%d,%d)\n", prnt_idx>>1, rxF[prnt_idx],rxF[prnt_idx+1]); + } } } - #endif #ifdef DEBUG_CH_MAG @@ -1105,19 +1130,23 @@ void nr_ulsch_channel_compensation(int **rxdataF_ext, } void nr_ulsch_detection_mrc(NR_DL_FRAME_PARMS *frame_parms, - int32_t **rxdataF_comp, - int32_t **ul_ch_mag, - int32_t **ul_ch_magb, - uint8_t symbol, - uint16_t nb_rb) { + int32_t **rxdataF_comp, + int32_t **ul_ch_mag, + int32_t **ul_ch_magb, + int32_t ***rho, + uint8_t nrOfLayers, + uint8_t symbol, + uint16_t nb_rb, + int length) { int n_rx = frame_parms->nb_antennas_rx; #if defined(__x86_64__) || defined(__i386__) - __m128i *rxdataF_comp128[1+n_rx],*ul_ch_mag128[1+n_rx],*ul_ch_mag128b[1+n_rx]; + __m128i *rxdataF_comp128[2],*ul_ch_mag128[2],*ul_ch_mag128b[2]; #elif defined(__arm__) int16x8_t *rxdataF_comp128_0,*ul_ch_mag128_0,*ul_ch_mag128_0b; int16x8_t *rxdataF_comp128_1,*ul_ch_mag128_1,*ul_ch_mag128_1b; #endif int32_t i; + uint32_t nb_rb_0 = length/12 + ((length%12)?1:0); #ifdef __AVX2__ int off = ((nb_rb&1) == 1)? 4:0; @@ -1125,23 +1154,30 @@ void nr_ulsch_detection_mrc(NR_DL_FRAME_PARMS *frame_parms, int off = 0; #endif - if (frame_parms->nb_antennas_rx>1) { -#if defined(__x86_64__) || defined(__i386__) - int nb_re = nb_rb*12; - for (int aa=0;aanb_antennas_rx;aa++) { - rxdataF_comp128[aa] = (__m128i *)&rxdataF_comp[aa][(symbol*(nb_re + off))]; - ul_ch_mag128[aa] = (__m128i *)&ul_ch_mag[aa][(symbol*(nb_re + off))]; - ul_ch_mag128b[aa] = (__m128i *)&ul_ch_magb[aa][(symbol*(nb_re + off))]; - } - for (int aa=1;aanb_antennas_rx;aa++) { - // MRC on each re of rb, both on MF output and magnitude (for 16QAM/64QAM llr computation) - for (i=0; i 1) { + #if defined(__x86_64__) || defined(__i386__) + for (int aatx=0; aatxnb_antennas_rx][(symbol*(nb_re + off))]; + ul_ch_mag128[0] = (__m128i *)&ul_ch_mag[aatx*frame_parms->nb_antennas_rx][(symbol*(nb_re + off))]; + ul_ch_mag128b[0] = (__m128i *)&ul_ch_magb[aatx*frame_parms->nb_antennas_rx][(symbol*(nb_re + off))]; + + for (int aa=1;aa < n_rx;aa++) { + rxdataF_comp128[1] = (__m128i *)&rxdataF_comp[aatx*frame_parms->nb_antennas_rx+aa][(symbol*(nb_re + off))]; + ul_ch_mag128[1] = (__m128i *)&ul_ch_mag[aatx*frame_parms->nb_antennas_rx+aa][(symbol*(nb_re + off))]; + ul_ch_mag128b[1] = (__m128i *)&ul_ch_magb[aatx*frame_parms->nb_antennas_rx+aa][(symbol*(nb_re + off))]; + + // MRC on each re of rb, both on MF output and magnitude (for 16QAM/64QAM llr computation) + for (i=0; iN_RB_DL*12]; rxdataF_comp128_1 = (int16x8_t *)&rxdataF_comp[1][symbol*frame_parms->N_RB_DL*12]; ul_ch_mag128_0 = (int16x8_t *)&ul_ch_mag[0][symbol*frame_parms->N_RB_DL*12]; @@ -1156,7 +1192,7 @@ void nr_ulsch_detection_mrc(NR_DL_FRAME_PARMS *frame_parms, ul_ch_mag128_0b[i] = vhaddq_s16(ul_ch_mag128_0b[i],ul_ch_mag128_1b[i]); rxdataF_comp128_0[i] = vqaddq_s16(rxdataF_comp128_0[i],(*(int16x8_t *)&jitterc[0])); } -#endif + #endif } #if defined(__x86_64__) || defined(__i386__) @@ -1165,6 +1201,696 @@ void nr_ulsch_detection_mrc(NR_DL_FRAME_PARMS *frame_parms, #endif } +/* Zero Forcing Rx function: nr_det_HhH() + * + * + * */ +void nr_ulsch_det_HhH(int32_t *after_mf_00,//a + int32_t *after_mf_01,//b + int32_t *after_mf_10,//c + int32_t *after_mf_11,//d + int32_t *det_fin,//1/ad-bc + unsigned short nb_rb, + unsigned char symbol, + int32_t shift) +{ + int16_t nr_conjug2[8]__attribute__((aligned(16))) = {1,-1,1,-1,1,-1,1,-1} ; + unsigned short rb; + __m128i *after_mf_00_128,*after_mf_01_128, *after_mf_10_128, *after_mf_11_128, ad_re_128, bc_re_128; //ad_im_128, bc_im_128; + __m128i *det_fin_128, det_re_128; //det_im_128, tmp_det0, tmp_det1; + + after_mf_00_128 = (__m128i *)after_mf_00; + after_mf_01_128 = (__m128i *)after_mf_01; + after_mf_10_128 = (__m128i *)after_mf_10; + after_mf_11_128 = (__m128i *)after_mf_11; + + det_fin_128 = (__m128i *)det_fin; + + for (rb=0; rb<3*nb_rb; rb++) { + + //complex multiplication (I_a+jQ_a)(I_d+jQ_d) = (I_aI_d - Q_aQ_d) + j(Q_aI_d + I_aQ_d) + //The imag part is often zero, we compute only the real part + ad_re_128 = _mm_sign_epi16(after_mf_00_128[0],*(__m128i*)&nr_conjug2[0]); + ad_re_128 = _mm_madd_epi16(ad_re_128,after_mf_11_128[0]); //Re: I_a0*I_d0 - Q_a1*Q_d1 + //ad_im_128 = _mm_shufflelo_epi16(after_mf_00_128[0],_MM_SHUFFLE(2,3,0,1));//permutes IQs for the low 64 bits as [I_a0 Q_a1 I_a2 Q_a3]_64bits to [Q_a1 I_a0 Q_a3 I_a2]_64bits + //ad_im_128 = _mm_shufflehi_epi16(ad_im_128,_MM_SHUFFLE(2,3,0,1));//permutes IQs for the high 64 bits as [I_a0 Q_a1 I_a2 Q_a3]_64bits to [Q_a1 I_a0 Q_a3 I_a2]_64bits + //ad_im_128 = _mm_madd_epi16(ad_im_128,after_mf_11_128[0]);//Im: (Q_aI_d + I_aQ_d) + + //complex multiplication (I_b+jQ_b)(I_c+jQ_c) = (I_bI_c - Q_bQ_c) + j(Q_bI_c + I_bQ_c) + //The imag part is often zero, we compute only the real part + bc_re_128 = _mm_sign_epi16(after_mf_01_128[0],*(__m128i*)&nr_conjug2[0]); + bc_re_128 = _mm_madd_epi16(bc_re_128,after_mf_10_128[0]); //Re: I_b0*I_c0 - Q_b1*Q_c1 + //bc_im_128 = _mm_shufflelo_epi16(after_mf_01_128[0],_MM_SHUFFLE(2,3,0,1));//permutes IQs for the low 64 bits as [I_b0 Q_b1 I_b2 Q_b3]_64bits to [Q_b1 I_b0 Q_b3 I_b2]_64bits + //bc_im_128 = _mm_shufflehi_epi16(bc_im_128,_MM_SHUFFLE(2,3,0,1));//permutes IQs for the high 64 bits as [I_b0 Q_b1 I_b2 Q_b3]_64bits to [Q_b1 I_b0 Q_b3 I_b2]_64bits + //bc_im_128 = _mm_madd_epi16(bc_im_128,after_mf_10_128[0]);//Im: (Q_bI_c + I_bQ_c) + + det_re_128 = _mm_sub_epi32(ad_re_128, bc_re_128); + //det_im_128 = _mm_sub_epi32(ad_im_128, bc_im_128); + + //det in Q30 format + det_fin_128[0] = _mm_abs_epi32(det_re_128); + + +#ifdef DEBUG_DLSCH_DEMOD + printf("\n Computing det_HhH_inv \n"); + //print_ints("det_re_128:",(int32_t*)&det_re_128); + //print_ints("det_im_128:",(int32_t*)&det_im_128); + print_ints("det_fin_128:",(int32_t*)&det_fin_128[0]); +#endif + det_fin_128+=1; + after_mf_00_128+=1; + after_mf_01_128+=1; + after_mf_10_128+=1; + after_mf_11_128+=1; + } + _mm_empty(); + _m_empty(); +} + +/* Zero Forcing Rx function: nr_inv_comp_muli + * Complex number multi: z = x*y + * = (x_re*y_re - x_im*y_im) + j(x_im*y_re + x_re*y_im) + * */ +__m128i nr_ulsch_inv_comp_muli(__m128i input_x, + __m128i input_y) +{ + int16_t nr_conjug2[8]__attribute__((aligned(16))) = {1,-1,1,-1,1,-1,1,-1} ; + + __m128i xy_re_128, xy_im_128; + __m128i output_z, tmp_z0, tmp_z1; + + // complex multiplication (x_re + jx_im)*(y_re + jy_im) = (x_re*y_re - x_im*y_im) + j(x_im*y_re + x_re*y_im) + + // the real part + xy_re_128 = _mm_sign_epi16(input_x,*(__m128i*)&nr_conjug2[0]); + xy_re_128 = _mm_madd_epi16(xy_re_128,input_y); //Re: (x_re*y_re - x_im*y_im) + + // the imag part + xy_im_128 = _mm_shufflelo_epi16(input_x,_MM_SHUFFLE(2,3,0,1));//permutes IQs for the low 64 bits as [I_a0 Q_a1 I_a2 Q_a3]_64bits to [Q_a1 I_a0 Q_a3 I_a2]_64bits + xy_im_128 = _mm_shufflehi_epi16(xy_im_128,_MM_SHUFFLE(2,3,0,1));//permutes IQs for the high 64 bits as [I_a0 Q_a1 I_a2 Q_a3]_64bits to [Q_a1 I_a0 Q_a3 I_a2]_64bits + xy_im_128 = _mm_madd_epi16(xy_im_128,input_y);//Im: (x_im*y_re + x_re*y_im) + + //convert back to Q15 before packing + xy_re_128 = _mm_srai_epi32(xy_re_128,4);//(2^15/64*2*16) + xy_im_128 = _mm_srai_epi32(xy_im_128,4); + + tmp_z0 = _mm_unpacklo_epi32(xy_re_128,xy_im_128); + //print_ints("unpack lo:",&tmp_z0[0]); + tmp_z1 = _mm_unpackhi_epi32(xy_re_128,xy_im_128); + //print_ints("unpack hi:",&tmp_z1[0]); + output_z = _mm_packs_epi32(tmp_z0,tmp_z1); + + _mm_empty(); + _m_empty(); + return(output_z); +} + +/* Zero Forcing Rx function: nr_conjch0_mult_ch1() + * + * + * */ +void nr_ulsch_conjch0_mult_ch1(int *ch0, + int *ch1, + int32_t *ch0conj_ch1, + unsigned short nb_rb, + unsigned char output_shift0) +{ + //This function is used to compute multiplications in H_hermitian * H matrix + short nr_conjugate[8]__attribute__((aligned(16))) = {-1,1,-1,1,-1,1,-1,1}; + unsigned short rb; + __m128i *dl_ch0_128,*dl_ch1_128, *ch0conj_ch1_128, mmtmpD0,mmtmpD1,mmtmpD2,mmtmpD3; + + dl_ch0_128 = (__m128i *)ch0; + dl_ch1_128 = (__m128i *)ch1; + + ch0conj_ch1_128 = (__m128i *)ch0conj_ch1; + + for (rb=0; rb<3*nb_rb; rb++) { + + mmtmpD0 = _mm_madd_epi16(dl_ch0_128[0],dl_ch1_128[0]); + mmtmpD1 = _mm_shufflelo_epi16(dl_ch0_128[0],_MM_SHUFFLE(2,3,0,1)); + mmtmpD1 = _mm_shufflehi_epi16(mmtmpD1,_MM_SHUFFLE(2,3,0,1)); + mmtmpD1 = _mm_sign_epi16(mmtmpD1,*(__m128i*)&nr_conjugate[0]); + mmtmpD1 = _mm_madd_epi16(mmtmpD1,dl_ch1_128[0]); + mmtmpD0 = _mm_srai_epi32(mmtmpD0,output_shift0); + mmtmpD1 = _mm_srai_epi32(mmtmpD1,output_shift0); + mmtmpD2 = _mm_unpacklo_epi32(mmtmpD0,mmtmpD1); + mmtmpD3 = _mm_unpackhi_epi32(mmtmpD0,mmtmpD1); + + ch0conj_ch1_128[0] = _mm_packs_epi32(mmtmpD2,mmtmpD3); + + /*printf("\n Computing conjugates \n"); + print_shorts("ch0:",(int16_t*)&dl_ch0_128[0]); + print_shorts("ch1:",(int16_t*)&dl_ch1_128[0]); + print_shorts("pack:",(int16_t*)&ch0conj_ch1_128[0]);*/ + + dl_ch0_128+=1; + dl_ch1_128+=1; + ch0conj_ch1_128+=1; + } + _mm_empty(); + _m_empty(); +} +__m128i nr_ulsch_comp_muli_sum(__m128i input_x, + __m128i input_y, + __m128i input_w, + __m128i input_z, + __m128i det) +{ + int16_t nr_conjug2[8]__attribute__((aligned(16))) = {1,-1,1,-1,1,-1,1,-1} ; + + __m128i xy_re_128, xy_im_128, wz_re_128, wz_im_128; + __m128i output, tmp_z0, tmp_z1; + + // complex multiplication (x_re + jx_im)*(y_re + jy_im) = (x_re*y_re - x_im*y_im) + j(x_im*y_re + x_re*y_im) + // the real part + xy_re_128 = _mm_sign_epi16(input_x,*(__m128i*)&nr_conjug2[0]); + xy_re_128 = _mm_madd_epi16(xy_re_128,input_y); //Re: (x_re*y_re - x_im*y_im) + + // the imag part + xy_im_128 = _mm_shufflelo_epi16(input_x,_MM_SHUFFLE(2,3,0,1));//permutes IQs for the low 64 bits as [I_a0 Q_a1 I_a2 Q_a3]_64bits to [Q_a1 I_a0 Q_a3 I_a2]_64bits + xy_im_128 = _mm_shufflehi_epi16(xy_im_128,_MM_SHUFFLE(2,3,0,1));//permutes IQs for the high 64 bits as [I_a0 Q_a1 I_a2 Q_a3]_64bits to [Q_a1 I_a0 Q_a3 I_a2]_64bits + xy_im_128 = _mm_madd_epi16(xy_im_128,input_y);//Im: (x_im*y_re + x_re*y_im) + + // complex multiplication (w_re + jw_im)*(z_re + jz_im) = (w_re*z_re - w_im*z_im) + j(w_im*z_re + w_re*z_im) + // the real part + wz_re_128 = _mm_sign_epi16(input_w,*(__m128i*)&nr_conjug2[0]); + wz_re_128 = _mm_madd_epi16(wz_re_128,input_z); //Re: (w_re*z_re - w_im*z_im) + + // the imag part + wz_im_128 = _mm_shufflelo_epi16(input_w,_MM_SHUFFLE(2,3,0,1));//permutes IQs for the low 64 bits as [I_a0 Q_a1 I_a2 Q_a3]_64bits to [Q_a1 I_a0 Q_a3 I_a2]_64bits + wz_im_128 = _mm_shufflehi_epi16(wz_im_128,_MM_SHUFFLE(2,3,0,1));//permutes IQs for the high 64 bits as [I_a0 Q_a1 I_a2 Q_a3]_64bits to [Q_a1 I_a0 Q_a3 I_a2]_64bits + wz_im_128 = _mm_madd_epi16(wz_im_128,input_z);//Im: (w_im*z_re + w_re*z_im) + + + xy_re_128 = _mm_sub_epi32(xy_re_128, wz_re_128); + xy_im_128 = _mm_sub_epi32(xy_im_128, wz_im_128); + //print_ints("rx_re:",(int32_t*)&xy_re_128[0]); + //print_ints("rx_Img:",(int32_t*)&xy_im_128[0]); + //divide by matrix det and convert back to Q15 before packing + int sum_det =0; + for (int k=0; k<4;k++) { + sum_det += ((((int *)&det[0])[k])>>2); + //printf("det_%d = %d log2 =%d \n",k,(((int *)&det[0])[k]),log2_approx(((int *)&det[0])[k])); + } + + xy_re_128 = _mm_slli_epi32(xy_re_128,5); + xy_re_128 = _mm_srai_epi32(xy_re_128,log2_approx(sum_det)); + xy_re_128 = _mm_slli_epi32(xy_re_128,5); + + xy_im_128 = _mm_slli_epi32(xy_im_128,5); + xy_im_128 = _mm_srai_epi32(xy_im_128,log2_approx(sum_det)); + xy_im_128 = _mm_slli_epi32(xy_im_128,5); + + tmp_z0 = _mm_unpacklo_epi32(xy_re_128,xy_im_128); + //print_ints("unpack lo:",&tmp_z0[0]); + tmp_z1 = _mm_unpackhi_epi32(xy_re_128,xy_im_128); + //print_ints("unpack hi:",&tmp_z1[0]); + output = _mm_packs_epi32(tmp_z0,tmp_z1); + + _mm_empty(); + _m_empty(); + return(output); +} +/* Zero Forcing Rx function: nr_construct_HhH_elements() + * + * + * */ +void nr_ulsch_construct_HhH_elements(int *conjch00_ch00, + int *conjch01_ch01, + int *conjch11_ch11, + int *conjch10_ch10,// + int *conjch20_ch20, + int *conjch21_ch21, + int *conjch30_ch30, + int *conjch31_ch31, + int *conjch00_ch01,//00_01 + int *conjch01_ch00,//01_00 + int *conjch10_ch11,//10_11 + int *conjch11_ch10,//11_10 + int *conjch20_ch21, + int *conjch21_ch20, + int *conjch30_ch31, + int *conjch31_ch30, + int32_t *after_mf_00, + int32_t *after_mf_01, + int32_t *after_mf_10, + int32_t *after_mf_11, + unsigned short nb_rb, + unsigned char symbol) +{ + //This function is used to construct the (H_hermitian * H matrix) matrix elements + unsigned short rb; + __m128i *conjch00_ch00_128, *conjch01_ch01_128, *conjch11_ch11_128, *conjch10_ch10_128; + __m128i *conjch20_ch20_128, *conjch21_ch21_128, *conjch30_ch30_128, *conjch31_ch31_128; + __m128i *conjch00_ch01_128, *conjch01_ch00_128, *conjch10_ch11_128, *conjch11_ch10_128; + __m128i *conjch20_ch21_128, *conjch21_ch20_128, *conjch30_ch31_128, *conjch31_ch30_128; + __m128i *after_mf_00_128, *after_mf_01_128, *after_mf_10_128, *after_mf_11_128; + + conjch00_ch00_128 = (__m128i *)conjch00_ch00; + conjch01_ch01_128 = (__m128i *)conjch01_ch01; + conjch11_ch11_128 = (__m128i *)conjch11_ch11; + conjch10_ch10_128 = (__m128i *)conjch10_ch10; + + conjch20_ch20_128 = (__m128i *)conjch20_ch20; + conjch21_ch21_128 = (__m128i *)conjch21_ch21; + conjch30_ch30_128 = (__m128i *)conjch30_ch30; + conjch31_ch31_128 = (__m128i *)conjch31_ch31; + + conjch00_ch01_128 = (__m128i *)conjch00_ch01; + conjch01_ch00_128 = (__m128i *)conjch01_ch00; + conjch10_ch11_128 = (__m128i *)conjch10_ch11; + conjch11_ch10_128 = (__m128i *)conjch11_ch10; + + conjch20_ch21_128 = (__m128i *)conjch20_ch21; + conjch21_ch20_128 = (__m128i *)conjch21_ch20; + conjch30_ch31_128 = (__m128i *)conjch30_ch31; + conjch31_ch30_128 = (__m128i *)conjch31_ch30; + + after_mf_00_128 = (__m128i *)after_mf_00; + after_mf_01_128 = (__m128i *)after_mf_01; + after_mf_10_128 = (__m128i *)after_mf_10; + after_mf_11_128 = (__m128i *)after_mf_11; + + for (rb=0; rb<3*nb_rb; rb++) { + + after_mf_00_128[0] =_mm_adds_epi16(conjch00_ch00_128[0],conjch10_ch10_128[0]);//00_00 + 10_10 + if (conjch20_ch20 != NULL) after_mf_00_128[0] =_mm_adds_epi16(after_mf_00_128[0],conjch20_ch20_128[0]); + if (conjch30_ch30 != NULL) after_mf_00_128[0] =_mm_adds_epi16(after_mf_00_128[0],conjch30_ch30_128[0]); + + after_mf_11_128[0] =_mm_adds_epi16(conjch01_ch01_128[0], conjch11_ch11_128[0]); //01_01 + 11_11 + if (conjch21_ch21 != NULL) after_mf_11_128[0] =_mm_adds_epi16(after_mf_11_128[0],conjch21_ch21_128[0]); + if (conjch31_ch31 != NULL) after_mf_11_128[0] =_mm_adds_epi16(after_mf_11_128[0],conjch31_ch31_128[0]); + + after_mf_01_128[0] =_mm_adds_epi16(conjch00_ch01_128[0], conjch10_ch11_128[0]);//00_01 + 10_11 + if (conjch20_ch21 != NULL) after_mf_01_128[0] =_mm_adds_epi16(after_mf_01_128[0],conjch20_ch21_128[0]); + if (conjch30_ch31 != NULL) after_mf_01_128[0] =_mm_adds_epi16(after_mf_01_128[0],conjch30_ch31_128[0]); + + after_mf_10_128[0] =_mm_adds_epi16(conjch01_ch00_128[0], conjch11_ch10_128[0]);//01_00 + 11_10 + if (conjch21_ch20 != NULL) after_mf_10_128[0] =_mm_adds_epi16(after_mf_10_128[0],conjch21_ch20_128[0]); + if (conjch31_ch30 != NULL) after_mf_10_128[0] =_mm_adds_epi16(after_mf_10_128[0],conjch31_ch30_128[0]); + +#ifdef DEBUG_DLSCH_DEMOD + if ((rb<=30)) + { + printf(" \n construct_HhH_elements \n"); + print_shorts("after_mf_00_128:",(int16_t*)&after_mf_00_128[0]); + print_shorts("after_mf_01_128:",(int16_t*)&after_mf_01_128[0]); + print_shorts("after_mf_10_128:",(int16_t*)&after_mf_10_128[0]); + print_shorts("after_mf_11_128:",(int16_t*)&after_mf_11_128[0]); + } +#endif + conjch00_ch00_128+=1; + conjch10_ch10_128+=1; + conjch01_ch01_128+=1; + conjch11_ch11_128+=1; + + if (conjch20_ch20 != NULL) conjch20_ch20_128+=1; + if (conjch21_ch21 != NULL) conjch21_ch21_128+=1; + if (conjch30_ch30 != NULL) conjch30_ch30_128+=1; + if (conjch31_ch31 != NULL) conjch31_ch31_128+=1; + + conjch00_ch01_128+=1; + conjch01_ch00_128+=1; + conjch10_ch11_128+=1; + conjch11_ch10_128+=1; + + if (conjch20_ch21 != NULL) conjch20_ch21_128+=1; + if (conjch21_ch20 != NULL) conjch21_ch20_128+=1; + if (conjch30_ch31 != NULL) conjch30_ch31_128+=1; + if (conjch31_ch30 != NULL) conjch31_ch30_128+=1; + + after_mf_00_128 += 1; + after_mf_01_128 += 1; + after_mf_10_128 += 1; + after_mf_11_128 += 1; + } + _mm_empty(); + _m_empty(); +} + +/* Zero Forcing Rx function: nr_ulsch_zero_forcing_rx_2layers() + * + * + * */ +uint8_t nr_ulsch_zero_forcing_rx_2layers(int **rxdataF_comp, + int **ul_ch_mag, + int **ul_ch_magb, + int **ul_ch_estimates_ext, + unsigned short nb_rb, + unsigned char n_rx, + unsigned char mod_order, + int shift, + unsigned char symbol, + int length) +{ + int *ch00, *ch01, *ch10, *ch11; + int *ch20, *ch30, *ch21, *ch31; + uint32_t nb_rb_0 = length/12 + ((length%12)?1:0); + + #ifdef __AVX2__ + int off = ((nb_rb&1) == 1)? 4:0; + #else + int off = 0; + #endif + + /* we need at least alignment to 16 bytes, let's put 32 to be sure + * (maybe not necessary but doesn't hurt) + */ + int32_t conjch00_ch01[12*nb_rb] __attribute__((aligned(32))); + int32_t conjch01_ch00[12*nb_rb] __attribute__((aligned(32))); + int32_t conjch10_ch11[12*nb_rb] __attribute__((aligned(32))); + int32_t conjch11_ch10[12*nb_rb] __attribute__((aligned(32))); + int32_t conjch00_ch00[12*nb_rb] __attribute__((aligned(32))); + int32_t conjch01_ch01[12*nb_rb] __attribute__((aligned(32))); + int32_t conjch10_ch10[12*nb_rb] __attribute__((aligned(32))); + int32_t conjch11_ch11[12*nb_rb] __attribute__((aligned(32))); + int32_t conjch20_ch20[12*nb_rb] __attribute__((aligned(32))); + int32_t conjch21_ch21[12*nb_rb] __attribute__((aligned(32))); + int32_t conjch30_ch30[12*nb_rb] __attribute__((aligned(32))); + int32_t conjch31_ch31[12*nb_rb] __attribute__((aligned(32))); + int32_t conjch20_ch21[12*nb_rb] __attribute__((aligned(32))); + int32_t conjch30_ch31[12*nb_rb] __attribute__((aligned(32))); + int32_t conjch21_ch20[12*nb_rb] __attribute__((aligned(32))); + int32_t conjch31_ch30[12*nb_rb] __attribute__((aligned(32))); + + int32_t af_mf_00[12*nb_rb] __attribute__((aligned(32))); + int32_t af_mf_01[12*nb_rb] __attribute__((aligned(32))); + int32_t af_mf_10[12*nb_rb] __attribute__((aligned(32))); + int32_t af_mf_11[12*nb_rb] __attribute__((aligned(32))); + int32_t determ_fin[12*nb_rb] __attribute__((aligned(32))); + + switch (n_rx) { + case 2:// + ch00 = (int *)&ul_ch_estimates_ext[0][symbol*(off+nb_rb*12)]; + ch01 = (int *)&ul_ch_estimates_ext[2][symbol*(off+nb_rb*12)]; + ch10 = (int *)&ul_ch_estimates_ext[1][symbol*(off+nb_rb*12)]; + ch11 = (int *)&ul_ch_estimates_ext[3][symbol*(off+nb_rb*12)]; + ch20 = NULL; + ch21 = NULL; + ch30 = NULL; + ch31 = NULL; + break; + + case 4:// + ch00 = (int *)&ul_ch_estimates_ext[0][symbol*(off+nb_rb*12)]; + ch01 = (int *)&ul_ch_estimates_ext[4][symbol*(off+nb_rb*12)]; + ch10 = (int *)&ul_ch_estimates_ext[1][symbol*(off+nb_rb*12)]; + ch11 = (int *)&ul_ch_estimates_ext[5][symbol*(off+nb_rb*12)]; + ch20 = (int *)&ul_ch_estimates_ext[2][symbol*(off+nb_rb*12)]; + ch21 = (int *)&ul_ch_estimates_ext[6][symbol*(off+nb_rb*12)]; + ch30 = (int *)&ul_ch_estimates_ext[3][symbol*(off+nb_rb*12)]; + ch31 = (int *)&ul_ch_estimates_ext[7][symbol*(off+nb_rb*12)]; + break; + + default: + return -1; + break; + } + + /* 1- Compute the rx channel matrix after compensation: (1/2^log2_max)x(H_herm x H) + * for n_rx = 2 + * |conj_H_00 conj_H_10| | H_00 H_01| |(conj_H_00xH_00+conj_H_10xH_10) (conj_H_00xH_01+conj_H_10xH_11)| + * | | x | | = | | + * |conj_H_01 conj_H_11| | H_10 H_11| |(conj_H_01xH_00+conj_H_11xH_10) (conj_H_01xH_01+conj_H_11xH_11)| + * + */ + + if (n_rx>=2){ + // (1/2^log2_maxh)*conj_H_00xH_00: (1/(64*2))conjH_00*H_00*2^15 + nr_ulsch_conjch0_mult_ch1(ch00, + ch00, + conjch00_ch00, + nb_rb_0, + shift); + // (1/2^log2_maxh)*conj_H_10xH_10: (1/(64*2))conjH_10*H_10*2^15 + nr_ulsch_conjch0_mult_ch1(ch10, + ch10, + conjch10_ch10, + nb_rb_0, + shift); + // conj_H_00xH_01 + nr_ulsch_conjch0_mult_ch1(ch00, + ch01, + conjch00_ch01, + nb_rb_0, + shift); // this shift is equal to the channel level log2_maxh + // conj_H_10xH_11 + nr_ulsch_conjch0_mult_ch1(ch10, + ch11, + conjch10_ch11, + nb_rb_0, + shift); + // conj_H_01xH_01 + nr_ulsch_conjch0_mult_ch1(ch01, + ch01, + conjch01_ch01, + nb_rb_0, + shift); + // conj_H_11xH_11 + nr_ulsch_conjch0_mult_ch1(ch11, + ch11, + conjch11_ch11, + nb_rb_0, + shift); + // conj_H_01xH_00 + nr_ulsch_conjch0_mult_ch1(ch01, + ch00, + conjch01_ch00, + nb_rb_0, + shift); + // conj_H_11xH_10 + nr_ulsch_conjch0_mult_ch1(ch11, + ch10, + conjch11_ch10, + nb_rb_0, + shift); + } + if (n_rx==4){ + // (1/2^log2_maxh)*conj_H_20xH_20: (1/(64*2*16))conjH_20*H_20*2^15 + nr_ulsch_conjch0_mult_ch1(ch20, + ch20, + conjch20_ch20, + nb_rb_0, + shift); + + // (1/2^log2_maxh)*conj_H_30xH_30: (1/(64*2*4))conjH_30*H_30*2^15 + nr_ulsch_conjch0_mult_ch1(ch30, + ch30, + conjch30_ch30, + nb_rb_0, + shift); + + // (1/2^log2_maxh)*conj_H_20xH_20: (1/(64*2))conjH_20*H_20*2^15 + nr_ulsch_conjch0_mult_ch1(ch20, + ch21, + conjch20_ch21, + nb_rb_0, + shift); + + nr_ulsch_conjch0_mult_ch1(ch30, + ch31, + conjch30_ch31, + nb_rb_0, + shift); + + nr_ulsch_conjch0_mult_ch1(ch21, + ch21, + conjch21_ch21, + nb_rb_0, + shift); + + nr_ulsch_conjch0_mult_ch1(ch31, + ch31, + conjch31_ch31, + nb_rb_0, + shift); + + // (1/2^log2_maxh)*conj_H_20xH_20: (1/(64*2))conjH_20*H_20*2^15 + nr_ulsch_conjch0_mult_ch1(ch21, + ch20, + conjch21_ch20, + nb_rb_0, + shift); + + nr_ulsch_conjch0_mult_ch1(ch31, + ch30, + conjch31_ch30, + nb_rb_0, + shift); + + nr_ulsch_construct_HhH_elements(conjch00_ch00, + conjch01_ch01, + conjch11_ch11, + conjch10_ch10,// + conjch20_ch20, + conjch21_ch21, + conjch30_ch30, + conjch31_ch31, + conjch00_ch01, + conjch01_ch00, + conjch10_ch11, + conjch11_ch10,// + conjch20_ch21, + conjch21_ch20, + conjch30_ch31, + conjch31_ch30, + af_mf_00, + af_mf_01, + af_mf_10, + af_mf_11, + nb_rb_0, + symbol); + } + if (n_rx==2){ + nr_ulsch_construct_HhH_elements(conjch00_ch00, + conjch01_ch01, + conjch11_ch11, + conjch10_ch10,// + NULL, + NULL, + NULL, + NULL, + conjch00_ch01, + conjch01_ch00, + conjch10_ch11, + conjch11_ch10,// + NULL, + NULL, + NULL, + NULL, + af_mf_00, + af_mf_01, + af_mf_10, + af_mf_11, + nb_rb_0, + symbol); + } + //det_HhH = ad -bc + nr_ulsch_det_HhH(af_mf_00,//a + af_mf_01,//b + af_mf_10,//c + af_mf_11,//d + determ_fin, + nb_rb_0, + symbol, + shift); + /* 2- Compute the channel matrix inversion ********************************** + * + * |(conj_H_00xH_00+conj_H_10xH_10) (conj_H_00xH_01+conj_H_10xH_11)| + * A= | | + * |(conj_H_01xH_00+conj_H_11xH_10) (conj_H_01xH_01+conj_H_11xH_11)| + * + * + * + *inv(A) =(1/det)*[d -b + * -c a] + * + * + **************************************************************************/ + __m128i *rxdataF_comp128_0,*rxdataF_comp128_1,*ul_ch_mag128_0=NULL,*ul_ch_mag128b_0=NULL,*determ_fin_128;//*dl_ch_mag128_1,*dl_ch_mag128b_1,*dl_ch_mag128r_1 + __m128i mmtmpD0,mmtmpD1,mmtmpD2,mmtmpD3; + __m128i *after_mf_a_128,*after_mf_b_128, *after_mf_c_128, *after_mf_d_128; + __m128i QAM_amp128={0},QAM_amp128b={0}; + + determ_fin_128 = (__m128i *)&determ_fin[0]; + + rxdataF_comp128_0 = (__m128i *)&rxdataF_comp[0][symbol*(off+nb_rb*12)];//aatx=0 @ aarx =0 + rxdataF_comp128_1 = (__m128i *)&rxdataF_comp[n_rx][symbol*(off+nb_rb*12)];//aatx=1 @ aarx =0 + + after_mf_a_128 = (__m128i *)af_mf_00; + after_mf_b_128 = (__m128i *)af_mf_01; + after_mf_c_128 = (__m128i *)af_mf_10; + after_mf_d_128 = (__m128i *)af_mf_11; + + if (mod_order>2) { + if (mod_order == 4) { + QAM_amp128 = _mm_set1_epi16(QAM16_n1); //2/sqrt(10) + QAM_amp128b = _mm_setzero_si128(); + } else if (mod_order == 6) { + QAM_amp128 = _mm_set1_epi16(QAM64_n1); //4/sqrt{42} + QAM_amp128b = _mm_set1_epi16(QAM64_n2); //2/sqrt{42} + } + ul_ch_mag128_0 = (__m128i *)&ul_ch_mag[0][symbol*(off+nb_rb*12)]; + ul_ch_mag128b_0 = (__m128i *)&ul_ch_magb[0][symbol*(off+nb_rb*12)]; + } + + for (int rb=0; rb<3*nb_rb_0; rb++) { + if (mod_order>2) { + int sum_det =0; + for (int k=0; k<4;k++) { + sum_det += ((((int *)&determ_fin_128[0])[k])>>2); + //printf("det_%d = %d\n",k,sum_det); + } + + mmtmpD2 = _mm_slli_epi32(determ_fin_128[0],5); + mmtmpD2 = _mm_srai_epi32(mmtmpD2,log2_approx(sum_det)); + mmtmpD2 = _mm_slli_epi32(mmtmpD2,5); + + mmtmpD3 = _mm_unpacklo_epi32(mmtmpD2,mmtmpD2); + + mmtmpD2 = _mm_unpackhi_epi32(mmtmpD2,mmtmpD2); + + mmtmpD2 = _mm_packs_epi32(mmtmpD3,mmtmpD2); + + ul_ch_mag128_0[0] = mmtmpD2; + ul_ch_mag128b_0[0] = mmtmpD2; + + ul_ch_mag128_0[0] = _mm_mulhi_epi16(ul_ch_mag128_0[0],QAM_amp128); + ul_ch_mag128_0[0] = _mm_slli_epi16(ul_ch_mag128_0[0],1); + + ul_ch_mag128b_0[0] = _mm_mulhi_epi16(ul_ch_mag128b_0[0],QAM_amp128b); + ul_ch_mag128b_0[0] = _mm_slli_epi16(ul_ch_mag128b_0[0],1); + + //print_shorts("mag layer 1:",(int16_t*)&dl_ch_mag128_0[0]); + //print_shorts("mag layer 2:",(int16_t*)&dl_ch_mag128_1[0]); + //print_shorts("magb layer 1:",(int16_t*)&dl_ch_mag128b_0[0]); + //print_shorts("magb layer 2:",(int16_t*)&dl_ch_mag128b_1[0]); + //print_shorts("magr layer 1:",(int16_t*)&dl_ch_mag128r_0[0]); + //print_shorts("magr layer 2:",(int16_t*)&dl_ch_mag128r_1[0]); + } + // multiply by channel Inv + //rxdataF_zf128_0 = rxdataF_comp128_0*d - b*rxdataF_comp128_1 + //rxdataF_zf128_1 = rxdataF_comp128_1*a - c*rxdataF_comp128_0 + //printf("layer_1 \n"); + mmtmpD0 = nr_ulsch_comp_muli_sum(rxdataF_comp128_0[0], + after_mf_d_128[0], + rxdataF_comp128_1[0], + after_mf_b_128[0], + determ_fin_128[0]); + + //printf("layer_2 \n"); + mmtmpD1 = nr_ulsch_comp_muli_sum(rxdataF_comp128_1[0], + after_mf_a_128[0], + rxdataF_comp128_0[0], + after_mf_c_128[0], + determ_fin_128[0]); + + rxdataF_comp128_0[0] = mmtmpD0; + rxdataF_comp128_1[0] = mmtmpD1; +#ifdef DEBUG_DLSCH_DEMOD + printf("\n Rx signal after ZF l%d rb%d\n",symbol,rb); + print_shorts(" Rx layer 1:",(int16_t*)&rxdataF_comp128_0[0]); + print_shorts(" Rx layer 2:",(int16_t*)&rxdataF_comp128_1[0]); +#endif + determ_fin_128 += 1; + ul_ch_mag128_0 += 1; + ul_ch_mag128b_0 += 1; + rxdataF_comp128_0 += 1; + rxdataF_comp128_1 += 1; + after_mf_a_128 += 1; + after_mf_b_128 += 1; + after_mf_c_128 += 1; + after_mf_d_128 += 1; + } + _mm_empty(); + _m_empty(); + return(0); +} + +//============================================================================================== + +/* Main Function */ int nr_rx_pusch(PHY_VARS_gNB *gNB, uint8_t ulsch_id, uint32_t frame, @@ -1177,7 +1903,7 @@ int nr_rx_pusch(PHY_VARS_gNB *gNB, int avgs = 0; NR_DL_FRAME_PARMS *frame_parms = &gNB->frame_parms; - nfapi_nr_pusch_pdu_t *rel15_ul = &gNB->ulsch[ulsch_id][0]->harq_processes[harq_pid]->ulsch_pdu; + nfapi_nr_pusch_pdu_t *rel15_ul = &gNB->ulsch[ulsch_id]->harq_processes[harq_pid]->ulsch_pdu; int avg[frame_parms->nb_antennas_rx*rel15_ul->nrOfLayers]; gNB->pusch_vars[ulsch_id]->dmrs_symbol = INVALID_VALUE; @@ -1186,7 +1912,10 @@ int nr_rx_pusch(PHY_VARS_gNB *gNB, bwp_start_subcarrier = ((rel15_ul->rb_start + rel15_ul->bwp_start)*NR_NB_SC_PER_RB + frame_parms->first_carrier_offset) % frame_parms->ofdm_symbol_size; LOG_D(PHY,"pusch %d.%d : bwp_start_subcarrier %d, rb_start %d, first_carrier_offset %d\n", frame,slot,bwp_start_subcarrier, rel15_ul->rb_start, frame_parms->first_carrier_offset); LOG_D(PHY,"pusch %d.%d : ul_dmrs_symb_pos %x\n",frame,slot,rel15_ul->ul_dmrs_symb_pos); - + LOG_D(PHY,"ulsch RX %x : start_rb %d nb_rb %d mcs %d Nl %d Tpmi %d bwp_start %d start_sc %d start_symbol %d num_symbols %d cdmgrpsnodata %d num_dmrs %d dmrs_ports %d\n", + rel15_ul->rnti,rel15_ul->rb_start,rel15_ul->rb_size,rel15_ul->mcs_index, + rel15_ul->nrOfLayers,0,rel15_ul->bwp_start,0,rel15_ul->start_symbol_index,rel15_ul->nr_of_symbols, + rel15_ul->num_dmrs_cdm_grps_no_data,rel15_ul->ul_dmrs_symb_pos,rel15_ul->dmrs_ports); //---------------------------------------------------------- //--------------------- Channel estimation --------------------- //---------------------------------------------------------- @@ -1194,11 +1923,13 @@ int nr_rx_pusch(PHY_VARS_gNB *gNB, for(uint8_t symbol = rel15_ul->start_symbol_index; symbol < (rel15_ul->start_symbol_index + rel15_ul->nr_of_symbols); symbol++) { uint8_t dmrs_symbol_flag = (rel15_ul->ul_dmrs_symb_pos >> symbol) & 0x01; LOG_D(PHY, "symbol %d, dmrs_symbol_flag :%d\n", symbol, dmrs_symbol_flag); + if (dmrs_symbol_flag == 1) { if (gNB->pusch_vars[ulsch_id]->dmrs_symbol == INVALID_VALUE) gNB->pusch_vars[ulsch_id]->dmrs_symbol = symbol; - for (int nl=0; nlnrOfLayers; nl++) + for (int nl=0; nlnrOfLayers; nl++) { + nr_pusch_channel_estimation(gNB, slot, get_dmrs_port(nl,rel15_ul->dmrs_ports), @@ -1206,6 +1937,7 @@ int nr_rx_pusch(PHY_VARS_gNB *gNB, ulsch_id, bwp_start_subcarrier, rel15_ul); + } nr_gnb_measurements(gNB, ulsch_id, harq_pid, symbol,rel15_ul->nrOfLayers); @@ -1214,17 +1946,34 @@ int nr_rx_pusch(PHY_VARS_gNB *gNB, gNB->pusch_vars[ulsch_id]->ulsch_power[aarx] = 0; gNB->pusch_vars[ulsch_id]->ulsch_noise_power[aarx] = 0; } - gNB->pusch_vars[ulsch_id]->ulsch_power[aarx] += signal_energy_nodc( - &gNB->pusch_vars[ulsch_id]->ul_ch_estimates[aarx][symbol * frame_parms->ofdm_symbol_size], + for (aatx = 0; aatx < rel15_ul->nrOfLayers; aatx++) { + gNB->pusch_vars[ulsch_id]->ulsch_power[aarx] += signal_energy_nodc( + &gNB->pusch_vars[ulsch_id]->ul_ch_estimates[aatx*gNB->frame_parms.nb_antennas_rx+aarx][symbol * frame_parms->ofdm_symbol_size], rel15_ul->rb_size * 12); + } for (int rb = 0; rb < rel15_ul->rb_size; rb++) { gNB->pusch_vars[ulsch_id]->ulsch_noise_power[aarx] += gNB->measurements.n0_subband_power[aarx][rel15_ul->bwp_start + rel15_ul->rb_start + rb] / rel15_ul->rb_size; } + LOG_D(PHY,"aa %d, bwp_start%d, rb_start %d, rb_size %d: ulsch_power %d, ulsch_noise_power %d\n",aarx, + rel15_ul->bwp_start,rel15_ul->rb_start,rel15_ul->rb_size, + gNB->pusch_vars[ulsch_id]->ulsch_power[aarx], + gNB->pusch_vars[ulsch_id]->ulsch_noise_power[aarx]); } } } + + if (gNB->chest_time == 1) { // averaging time domain channel estimates + nr_chest_time_domain_avg(frame_parms, + gNB->pusch_vars[ulsch_id]->ul_ch_estimates, + rel15_ul->nr_of_symbols, + rel15_ul->start_symbol_index, + rel15_ul->ul_dmrs_symb_pos, + rel15_ul->rb_size); + + gNB->pusch_vars[ulsch_id]->dmrs_symbol = get_next_dmrs_symbol_in_slot(rel15_ul->ul_dmrs_symb_pos, rel15_ul->start_symbol_index, rel15_ul->nr_of_symbols); + } stop_meas(&gNB->ulsch_channel_estimation_stats); #ifdef __AVX2__ @@ -1240,7 +1989,8 @@ int nr_rx_pusch(PHY_VARS_gNB *gNB, if ((rel15_ul->ul_dmrs_symb_pos >> ((symbol + 1) % frame_parms->symbols_per_slot)) & 0x01) AssertFatal(1==0,"Double DMRS configuration is not yet supported\n"); - gNB->pusch_vars[ulsch_id]->dmrs_symbol = symbol; + if (gNB->chest_time == 0) // Non averaging time domain channel estimates + gNB->pusch_vars[ulsch_id]->dmrs_symbol = symbol; if (rel15_ul->dmrs_config_type == 0) { // if no data in dmrs cdm group is 1 only even REs have no data @@ -1250,7 +2000,8 @@ int nr_rx_pusch(PHY_VARS_gNB *gNB, else { nb_re_pusch = rel15_ul->rb_size *(12 - (rel15_ul->num_dmrs_cdm_grps_no_data*4)); } - } else { + } + else { nb_re_pusch = rel15_ul->rb_size * NR_NB_SC_PER_RB; } @@ -1261,15 +2012,14 @@ int nr_rx_pusch(PHY_VARS_gNB *gNB, //--------------------- RBs extraction --------------------- //---------------------------------------------------------- if (nb_re_pusch > 0) { - start_meas(&gNB->ulsch_rbs_extraction_stats); - nr_ulsch_extract_rbs_single(gNB->common_vars.rxdataF, - gNB->pusch_vars[ulsch_id], - slot, - symbol, - dmrs_symbol_flag, - rel15_ul, - frame_parms); + nr_ulsch_extract_rbs(gNB->common_vars.rxdataF, + gNB->pusch_vars[ulsch_id], + slot, + symbol, + dmrs_symbol_flag, + rel15_ul, + frame_parms); stop_meas(&gNB->ulsch_rbs_extraction_stats); //---------------------------------------------------------- @@ -1280,8 +2030,9 @@ int nr_rx_pusch(PHY_VARS_gNB *gNB, gNB->ulsch[ulsch_id], symbol, dmrs_symbol_flag, - rel15_ul->rb_size, - rel15_ul->dmrs_config_type); + nb_re_pusch, + rel15_ul->nrOfLayers, + rel15_ul->rb_size); if (gNB->pusch_vars[ulsch_id]->cl_done==0) { nr_ulsch_channel_level(gNB->pusch_vars[ulsch_id]->ul_ch_estimates_ext, @@ -1315,6 +2066,7 @@ int nr_rx_pusch(PHY_VARS_gNB *gNB, (rel15_ul->nrOfLayers>1) ? gNB->pusch_vars[ulsch_id]->rho : NULL, frame_parms, symbol, + nb_re_pusch, dmrs_symbol_flag, rel15_ul->qam_mod_order, rel15_ul->nrOfLayers, @@ -1327,19 +2079,32 @@ int nr_rx_pusch(PHY_VARS_gNB *gNB, gNB->pusch_vars[ulsch_id]->rxdataF_comp, gNB->pusch_vars[ulsch_id]->ul_ch_mag0, gNB->pusch_vars[ulsch_id]->ul_ch_magb0, + (rel15_ul->nrOfLayers>1) ? gNB->pusch_vars[ulsch_id]->rho : NULL, + rel15_ul->nrOfLayers, symbol, - rel15_ul->rb_size); + rel15_ul->rb_size, + nb_re_pusch); + + if (rel15_ul->nrOfLayers == 2)//Apply zero forcing for 2 Tx layers + nr_ulsch_zero_forcing_rx_2layers(gNB->pusch_vars[ulsch_id]->rxdataF_comp, + gNB->pusch_vars[ulsch_id]->ul_ch_mag0, + gNB->pusch_vars[ulsch_id]->ul_ch_magb0, + gNB->pusch_vars[ulsch_id]->ul_ch_estimates_ext, + rel15_ul->rb_size, + frame_parms->nb_antennas_rx, + rel15_ul->qam_mod_order, + gNB->pusch_vars[ulsch_id]->log2_maxh, + symbol, + nb_re_pusch); stop_meas(&gNB->ulsch_mrc_stats); - // transform precoding = 0 means enabled - if (rel15_ul->transform_precoding == 0) { - - #ifdef __AVX2__ + if (rel15_ul->transform_precoding == transformPrecoder_enabled) { + #ifdef __AVX2__ // For odd number of resource blocks need byte alignment to multiple of 8 int nb_re_pusch2 = nb_re_pusch + (nb_re_pusch&7); - #else + #else int nb_re_pusch2 = nb_re_pusch; - #endif + #endif // perform IDFT operation on the compensated rxdata if transform precoding is enabled nr_idft(&gNB->pusch_vars[ulsch_id]->rxdataF_comp[0][symbol * nb_re_pusch2], nb_re_pusch); @@ -1370,14 +2135,16 @@ int nr_rx_pusch(PHY_VARS_gNB *gNB, /*-------------------- LLRs computation -------------------------------------------------------------*/ /*-----------------------------------------------------------------------------------------------------*/ start_meas(&gNB->ulsch_llr_stats); - nr_ulsch_compute_llr(&gNB->pusch_vars[ulsch_id]->rxdataF_comp[0][symbol * (off + rel15_ul->rb_size * NR_NB_SC_PER_RB)], - gNB->pusch_vars[ulsch_id]->ul_ch_mag0, - gNB->pusch_vars[ulsch_id]->ul_ch_magb0, - &gNB->pusch_vars[ulsch_id]->llr[rxdataF_ext_offset * rel15_ul->qam_mod_order], - rel15_ul->rb_size, - gNB->pusch_vars[ulsch_id]->ul_valid_re_per_slot[symbol], - symbol, - rel15_ul->qam_mod_order); + for (aatx=0; aatx < rel15_ul->nrOfLayers; aatx++) { + nr_ulsch_compute_llr(&gNB->pusch_vars[ulsch_id]->rxdataF_comp[aatx*frame_parms->nb_antennas_rx][symbol * (off + rel15_ul->rb_size * NR_NB_SC_PER_RB)], + gNB->pusch_vars[ulsch_id]->ul_ch_mag0[aatx*frame_parms->nb_antennas_rx], + gNB->pusch_vars[ulsch_id]->ul_ch_magb0[aatx*frame_parms->nb_antennas_rx], + &gNB->pusch_vars[ulsch_id]->llr_layers[aatx][rxdataF_ext_offset * rel15_ul->qam_mod_order], + rel15_ul->rb_size, + gNB->pusch_vars[ulsch_id]->ul_valid_re_per_slot[symbol], + symbol, + rel15_ul->qam_mod_order); + } stop_meas(&gNB->ulsch_llr_stats); rxdataF_ext_offset += gNB->pusch_vars[ulsch_id]->ul_valid_re_per_slot[symbol]; } diff --git a/openair1/PHY/NR_TRANSPORT/nr_ulsch_llr_computation.c b/openair1/PHY/NR_TRANSPORT/nr_ulsch_llr_computation.c index bf96a76106..ad41ebf3d6 100644 --- a/openair1/PHY/NR_TRANSPORT/nr_ulsch_llr_computation.c +++ b/openair1/PHY/NR_TRANSPORT/nr_ulsch_llr_computation.c @@ -64,7 +64,7 @@ void nr_ulsch_qpsk_llr(int32_t *rxdataF_comp, //---------------------------------------------------------------------------------------------- void nr_ulsch_16qam_llr(int32_t *rxdataF_comp, - int32_t **ul_ch_mag, + int32_t *ul_ch_mag, int16_t *ulsch_llr, uint32_t nb_rb, uint32_t nb_re, @@ -110,12 +110,12 @@ void nr_ulsch_16qam_llr(int32_t *rxdataF_comp, #if defined(__x86_64__) || defined(__i386__) #ifdef __AVX2__ - ch_mag = (__m256i*)&ul_ch_mag[0][(symbol*(off+(nb_rb*12)))]; + ch_mag = (__m256i*)&ul_ch_mag[(symbol*(off+(nb_rb*12)))]; #else - ch_mag = (__m128i*)&ul_ch_mag[0][(symbol*(off+(nb_rb*12)))]; + ch_mag = (__m128i*)&ul_ch_mag[(symbol*(off+(nb_rb*12)))]; #endif #elif defined(__arm__) - ch_mag = (int16x8_t*)&ul_ch_mag[0][(symbol*nb_rb*12)]; + ch_mag = (int16x8_t*)&ul_ch_mag[(symbol*nb_rb*12)]; #endif #ifdef __AVX2__ @@ -231,8 +231,8 @@ void nr_ulsch_16qam_llr(int32_t *rxdataF_comp, //---------------------------------------------------------------------------------------------- void nr_ulsch_64qam_llr(int32_t *rxdataF_comp, - int32_t **ul_ch_mag, - int32_t **ul_ch_magb, + int32_t *ul_ch_mag, + int32_t *ul_ch_magb, int16_t *ulsch_llr, uint32_t nb_rb, uint32_t nb_re, @@ -265,15 +265,15 @@ void nr_ulsch_64qam_llr(int32_t *rxdataF_comp, #if defined(__x86_64__) || defined(__i386__) #ifdef __AVX2__ - ch_mag = (__m256i*)&ul_ch_mag[0][(symbol*(off+(nb_rb*12)))]; - ch_magb = (__m256i*)&ul_ch_magb[0][(symbol*(off+(nb_rb*12)))]; + ch_mag = (__m256i*)&ul_ch_mag[(symbol*(off+(nb_rb*12)))]; + ch_magb = (__m256i*)&ul_ch_magb[(symbol*(off+(nb_rb*12)))]; #else - ch_mag = (__m128i*)&ul_ch_mag[0][(symbol*nb_rb*12)]; - ch_magb = (__m128i*)&ul_ch_magb[0][(symbol*nb_rb*12)]; + ch_mag = (__m128i*)&ul_ch_mag[(symbol*nb_rb*12)]; + ch_magb = (__m128i*)&ul_ch_magb[(symbol*nb_rb*12)]; #endif #elif defined(__arm__) - ch_mag = (int16x8_t*)&ul_ch_mag[0][(symbol*nb_rb*12)]; - ch_magb = (int16x8_t*)&ul_ch_magb[0][(symbol*nb_rb*12)]; + ch_mag = (int16x8_t*)&ul_ch_mag[(symbol*nb_rb*12)]; + ch_magb = (int16x8_t*)&ul_ch_magb[(symbol*nb_rb*12)]; #endif #ifdef __AVX2__ @@ -471,8 +471,8 @@ void nr_ulsch_64qam_llr(int32_t *rxdataF_comp, void nr_ulsch_compute_llr(int32_t *rxdataF_comp, - int32_t **ul_ch_mag, - int32_t **ul_ch_magb, + int32_t *ul_ch_mag, + int32_t *ul_ch_magb, int16_t *ulsch_llr, uint32_t nb_rb, uint32_t nb_re, diff --git a/openair1/PHY/NR_TRANSPORT/pucch_rx.c b/openair1/PHY/NR_TRANSPORT/pucch_rx.c index b85dbd1454..5617b8e58b 100644 --- a/openair1/PHY/NR_TRANSPORT/pucch_rx.c +++ b/openair1/PHY/NR_TRANSPORT/pucch_rx.c @@ -104,6 +104,8 @@ void nr_fill_pucch(PHY_VARS_gNB *gNB, pucch->frame = frame; pucch->slot = slot; pucch->active = 1; + if (pucch->pucch_pdu.format_type > 0) LOG_D(PHY,"Programming PUCCH[%d] for %d.%d, format %d, nb_harq %d, nb_sr %d, nb_csi %d\n",id, + pucch->frame,pucch->slot,pucch->pucch_pdu.format_type,pucch->pucch_pdu.bit_len_harq,pucch->pucch_pdu.sr_flag,pucch->pucch_pdu.bit_len_csi_part1); memcpy((void*)&pucch->pucch_pdu, (void*)pucch_pdu, sizeof(nfapi_nr_pucch_pdu_t)); } @@ -188,7 +190,7 @@ void nr_decode_pucch0(PHY_VARS_gNB *gNB, pucch_pdu->bit_len_harq,pucch_pdu->sr_flag); NR_gNB_UCI_STATS_t *uci_stats=NULL; - NR_gNB_UCI_STATS_t *first_uci_stats=NULL; + NR_gNB_UCI_STATS_t *first_uci_stats = gNB->uci_stats; for (int i=0;iuci_stats[i].rnti == pucch_pdu->rnti) { uci_stats = &gNB->uci_stats[i]; @@ -243,7 +245,7 @@ void nr_decode_pucch0(PHY_VARS_gNB *gNB, * x(l*12+n) = r_u_v_alpha_delta(n) */ // the value of u,v (delta always 0 for PUCCH) has to be calculated according to TS 38.211 Subclause 6.3.2.2.1 - uint8_t u[2]={0,0},v[2]={0,0}; + uint8_t u[2]={0},v[2]={0}; // x_n contains the sequence r_u_v_alpha_delta(n) @@ -262,7 +264,7 @@ void nr_decode_pucch0(PHY_VARS_gNB *gNB, AssertFatal(pucch_pdu->nr_of_symbols < 3,"nr_of_symbols %d not allowed\n",pucch_pdu->nr_of_symbols); - uint32_t re_offset[2]={0,0}; + uint32_t re_offset[2]={0}; uint8_t l2; const int16_t *x_re[2],*x_im[2]; @@ -271,16 +273,10 @@ void nr_decode_pucch0(PHY_VARS_gNB *gNB, x_re[1] = table_5_2_2_2_2_Re[u[1]]; x_im[1] = table_5_2_2_2_2_Im[u[1]]; - int16_t xr[1+frame_parms->nb_antennas_rx][1+pucch_pdu->nr_of_symbols][24] __attribute__((aligned(32))); + c64_t xr[frame_parms->nb_antennas_rx][pucch_pdu->nr_of_symbols][12] __attribute__((aligned(32))); int64_t xrtmag=0,xrtmag_next=0; uint8_t maxpos=0; uint8_t index=0; - for (int l=0; lnr_of_symbols; l++) { - for (int aarx=0;aarxnb_antennas_rx;aarx++) { - memset((void*)xr[aarx][l],0,24*sizeof(int16_t)); - } - } - int n2; for (int l=0; lnr_of_symbols; l++) { l2 = l+pucch_pdu->start_symbol_index; @@ -289,75 +285,68 @@ void nr_decode_pucch0(PHY_VARS_gNB *gNB, re_offset[l]-=frame_parms->ofdm_symbol_size; AssertFatal(re_offset[l]+12 < frame_parms->ofdm_symbol_size,"pucch straddles DC carrier, handle this!\n"); - int16_t *r; for (int aa=0;aanb_antennas_rx;aa++) { - r=(int16_t*)&rxdataF[aa][soffset+(l2*frame_parms->ofdm_symbol_size)+re_offset[l]]; - n2=0; - for (n=0;n<12;n++,n2+=2) { - xr[aa][l][n2] +=(int16_t)(((int32_t)x_re[l][n]*r[n2]+(int32_t)x_im[l][n]*r[n2+1])>>15); - xr[aa][l][n2+1]+=(int16_t)(((int32_t)x_re[l][n]*r[n2+1]-(int32_t)x_im[l][n]*r[n2])>>15); + c16_t *r=(c16_t*)&rxdataF[aa][soffset+(l2*frame_parms->ofdm_symbol_size)+re_offset[l]]; + for (n=0;n<12;n++) { + xr[aa][l][n].r = (int32_t)x_re[l][n] * r[n].r + (int32_t)x_im[l][n] * r[n].i; + xr[aa][l][n].i = (int32_t)x_re[l][n] * r[n].i - (int32_t)x_im[l][n] * r[n].r; #ifdef DEBUG_NR_PUCCH_RX - printf("x (%d,%d), r%d.%d (%d,%d), xr (%d,%d)\n", - x_re[l][n],x_im[l][n],l2,re_offset[l],r[n2],r[n2+1],xr[aa][l][n2],xr[aa][l][n2+1]); + printf("x (%d,%d), r%d.%d (%d,%d), xr (%lld,%lld)\n", + x_re[l][n],x_im[l][n],l2,re_offset[l],r[n].r,r[n].i,xr[aa][l][n].r,xr[aa][l][n].i); #endif } } } - int32_t corr_re[1+frame_parms->nb_antennas_rx][2]; - int32_t corr_im[1+frame_parms->nb_antennas_rx][2]; //int32_t no_corr = 0; int seq_index = 0; int64_t temp; for(i=0;inr_of_symbols;l++) { - seq_index = (pucch_pdu->initial_cyclic_shift+ - mcs[i]+ - gNB->pucch0_lut.lut[cs_ind][slot][l+pucch_pdu->start_symbol_index])%12; + c64_t corr[frame_parms->nb_antennas_rx][2]; + for (int aa=0;aanb_antennas_rx;aa++) { + for (int l=0;lnr_of_symbols;l++) { + seq_index = (pucch_pdu->initial_cyclic_shift+ + mcs[i]+ + gNB->pucch0_lut.lut[cs_ind][slot][l+pucch_pdu->start_symbol_index])%12; #ifdef DEBUG_NR_PUCCH_RX - printf("PUCCH symbol %d seq %d, seq_index %d, mcs %d\n",l,i,seq_index,mcs[i]); + printf("PUCCH symbol %d seq %d, seq_index %d, mcs %d\n",l,i,seq_index,mcs[i]); #endif - for (int aa=0;aanb_antennas_rx;aa++) { - corr_re[aa][l]=0; - corr_im[aa][l]=0; - - n2=0; - for (n=0;n<12;n++,n2+=2) { - corr_re[aa][l]+=(xr[aa][l][n2]*idft12_re[seq_index][n]+xr[aa][l][n2+1]*idft12_im[seq_index][n])>>15; - corr_im[aa][l]+=(xr[aa][l][n2]*idft12_im[seq_index][n]-xr[aa][l][n2+1]*idft12_re[seq_index][n])>>15; + corr[aa][l]=(c64_t){0}; + for (n = 0; n < 12; n++) { + corr[aa][l].r += xr[aa][l][n].r * idft12_re[seq_index][n] + xr[aa][l][n].i * idft12_im[seq_index][n]; + corr[aa][l].i += xr[aa][l][n].r * idft12_im[seq_index][n] - xr[aa][l][n].i * idft12_re[seq_index][n]; } + corr[aa][l].r >>= 31; + corr[aa][l].i >>= 31; } } - LOG_D(PHY,"PUCCH IDFT[%d/%d] = (%d,%d)=>%f\n", - mcs[i],seq_index,corr_re[0][0],corr_im[0][0], - 10*log10((double)corr_re[0][0]*corr_re[0][0] + (double)corr_im[0][0]*corr_im[0][0])); + LOG_D(PHY,"PUCCH IDFT[%d/%d] = (%ld,%ld)=>%f\n", + mcs[i],seq_index,corr[0][0].r,corr[0][0].i, + 10*log10((double)squaredMod(corr[0][0]))); if (pucch_pdu->nr_of_symbols==2) - LOG_D(PHY,"PUCCH 2nd symbol IDFT[%d/%d] = (%d,%d)=>%f\n", - mcs[i],seq_index,corr_re[0][1],corr_im[0][1], - 10*log10((double)corr_re[0][1]*corr_re[0][1] + (double)corr_im[0][1]*corr_im[0][1])); + LOG_D(PHY,"PUCCH 2nd symbol IDFT[%d/%d] = (%ld,%ld)=>%f\n", + mcs[i],seq_index,corr[0][1].r,corr[0][1].i, + 10*log10((double)squaredMod(corr[0][1]))); if (pucch_pdu->freq_hop_flag == 0) { if (pucch_pdu->nr_of_symbols==1) {// non-coherent correlation temp=0; for (int aa=0;aanb_antennas_rx;aa++) - temp+=(int64_t)corr_re[aa][0]*corr_re[aa][0] + (int64_t)corr_im[aa][0]*corr_im[aa][0]; + temp+=squaredMod(corr[aa][0]); } else { - int64_t corr_re2=0; - int64_t corr_im2=0; temp=0; for (int aa=0;aanb_antennas_rx;aa++) { - corr_re2 = (int64_t)corr_re[aa][0]+corr_re[aa][1]; - corr_im2 = (int64_t)corr_im[aa][0]+corr_im[aa][1]; - // coherent combining of 2 symbols and then complex modulus for single-frequency case - temp+=corr_re2*corr_re2 + corr_im2*corr_im2; + c64_t corr2; + csum(corr2, corr[aa][0], corr[aa][1]); + // coherent combining of 2 symbols and then complex modulus for single-frequency case + temp+=corr2.r*corr2.r + corr2.i*corr2.i; } } } else if (pucch_pdu->freq_hop_flag == 1) { // full non-coherent combining of 2 symbols for frequency-hopping case temp=0; for (int aa=0;aanb_antennas_rx;aa++) - temp += (int64_t)corr_re[aa][0]*corr_re[aa][0] + (int64_t)corr_im[aa][0]*corr_im[aa][0] + (int64_t)corr_re[aa][1]*corr_re[aa][1] + (int64_t)corr_im[aa][1]*corr_im[aa][1]; + temp += squaredMod(corr[aa][0]) + squaredMod(corr[aa][1]); } else AssertFatal(1==0,"shouldn't happen\n"); @@ -369,9 +358,9 @@ void nr_decode_pucch0(PHY_VARS_gNB *gNB, uci_stats->current_pucch0_stat0 = 0; int64_t temp2=0,temp3=0;; for (int aa=0;aanb_antennas_rx;aa++) { - temp2 += ((int64_t)corr_re[aa][0]*corr_re[aa][0] + (int64_t)corr_im[aa][0]*corr_im[aa][0]); + temp2 += squaredMod(corr[aa][0]); if (pucch_pdu->nr_of_symbols==2) - temp3 += ((int64_t)corr_re[aa][1]*corr_re[aa][1] + (int64_t)corr_im[aa][1]*corr_im[aa][1]); + temp3 += squaredMod(corr[aa][1]); } uci_stats->current_pucch0_stat0= dB_fixed64(temp2); if ( pucch_pdu->nr_of_symbols==2) @@ -392,7 +381,8 @@ void nr_decode_pucch0(PHY_VARS_gNB *gNB, uci_stats->pucch0_n01 = gNB->measurements.n0_subband_power_tot_dB[prb_offset[1]]; LOG_D(PHY,"n00[%d] = %d, n01[%d] = %d\n",prb_offset[0],uci_stats->pucch0_n00,prb_offset[1],uci_stats->pucch0_n01); // estimate CQI for MAC (from antenna port 0 only) - int max_n0 = uci_stats->pucch0_n00>uci_stats->pucch0_n01 ? uci_stats->pucch0_n00:uci_stats->pucch0_n01; + int max_n0 = max(gNB->measurements.n0_subband_power_tot_dB[prb_offset[0]], + gNB->measurements.n0_subband_power_tot_dB[prb_offset[1]]); int SNRtimes10,sigenergy=0; for (int aa=0;aanb_antennas_rx;aa++) sigenergy += signal_energy_nodc(&rxdataF[aa][soffset+ @@ -407,8 +397,15 @@ void nr_decode_pucch0(PHY_VARS_gNB *gNB, uci_stats->pucch0_thres = gNB->pucch0_thres; /* + (10*max_n0);*/ bool no_conf=false; if (nr_sequences>1) { - if (xrtmag_dBtimes10 < (50+xrtmag_next_dBtimes10) || SNRtimes10 < uci_stats->pucch0_thres) + if (/*xrtmag_dBtimes10 < (30+xrtmag_next_dBtimes10) ||*/ SNRtimes10 < uci_stats->pucch0_thres) { no_conf=true; + LOG_D(PHY,"%d.%d PUCCH bad confidence: %d threshold, %d, %d, %d\n", + frame, slot, + uci_stats->pucch0_thres, + SNRtimes10, + xrtmag_dBtimes10, + xrtmag_next_dBtimes10); + } } gNB->bad_pucch += no_conf; // first bit of bitmap for sr presence and second bit for acknack presence @@ -422,11 +419,12 @@ void nr_decode_pucch0(PHY_VARS_gNB *gNB, if (pucch_pdu->bit_len_harq==0) { uci_pdu->harq = NULL; uci_pdu->sr = calloc(1,sizeof(*uci_pdu->sr)); - uci_pdu->sr->sr_confidence_level = no_conf ? 1 : 0; + uci_pdu->sr->sr_confidence_level = SNRtimes10 < uci_stats->pucch0_thres; uci_stats->pucch0_sr_trials++; - if (xrtmag_dBtimes10>(10*gNB->measurements.n0_power_tot_dB)) { + if (xrtmag_dBtimes10>(10*max_n0+100)) { uci_pdu->sr->sr_indication = 1; uci_stats->pucch0_positive_SR++; + LOG_D(PHY,"PUCCH0 got positive SR. Cumulative number of positive SR %d\n", uci_stats->pucch0_positive_SR); } else { uci_pdu->sr->sr_indication = 0; } @@ -434,35 +432,49 @@ void nr_decode_pucch0(PHY_VARS_gNB *gNB, else if (pucch_pdu->bit_len_harq==1) { uci_pdu->harq = calloc(1,sizeof(*uci_pdu->harq)); uci_pdu->harq->num_harq = 1; - uci_pdu->harq->harq_confidence_level = no_conf ? 1 : 0; - uci_pdu->harq->harq_list = (nfapi_nr_harq_t*)malloc(1); - + uci_pdu->harq->harq_confidence_level = no_conf; + uci_pdu->harq->harq_list = (nfapi_nr_harq_t*)malloc(sizeof *uci_pdu->harq->harq_list); uci_pdu->harq->harq_list[0].harq_value = !(index&0x01); - LOG_D(PHY, "[DLSCH/PDSCH/PUCCH] %d.%d HARQ value %d (0 pass, 1 fail) with confidence level %d (0 is good, 1 is bad) xrt_mag %d xrt_mag_next %d n0 %d (%d,%d) pucch0_thres %d, cqi %d, SNRtimes10 %d, energy %f, sync_pos %d\n", - frame,slot,uci_pdu->harq->harq_list[0].harq_value,uci_pdu->harq->harq_confidence_level,xrtmag_dBtimes10,xrtmag_next_dBtimes10,max_n0,uci_stats->pucch0_n00,uci_stats->pucch0_n01,uci_stats->pucch0_thres,cqi,SNRtimes10,10*log10((double)sigenergy),gNB->ulsch_stats[0].sync_pos); + LOG_D(PHY, "[DLSCH/PDSCH/PUCCH] %d.%d HARQ %s with confidence level %s xrt_mag %d xrt_mag_next %d n0 %d (%d,%d) pucch0_thres %d, cqi %d, SNRtimes10 %d, energy %f, sync_pos %d\n", + frame,slot,uci_pdu->harq->harq_list[0].harq_value==0?"ACK":"NACK", + uci_pdu->harq->harq_confidence_level==0?"good":"bad", + xrtmag_dBtimes10,xrtmag_next_dBtimes10,max_n0,uci_stats->pucch0_n00,uci_stats->pucch0_n01,uci_stats->pucch0_thres,cqi,SNRtimes10,10*log10((double)sigenergy),gNB->ulsch_stats[0].sync_pos); if (pucch_pdu->sr_flag == 1) { uci_pdu->sr = calloc(1,sizeof(*uci_pdu->sr)); - uci_pdu->sr->sr_indication = (index>1) ? 1 : 0; - uci_pdu->sr->sr_confidence_level = no_conf ? 1 : 0; - uci_stats->pucch0_positive_SR++; + uci_pdu->sr->sr_indication = (index>1); + uci_pdu->sr->sr_confidence_level = no_conf; + if(uci_pdu->sr->sr_indication == 1 && uci_pdu->sr->sr_confidence_level == 0) { + uci_stats->pucch0_positive_SR++; + LOG_D(PHY,"PUCCH0 got positive SR. Cumulative number of positive SR %d\n", uci_stats->pucch0_positive_SR); + } } uci_stats->pucch01_trials++; } else { uci_pdu->harq = calloc(1,sizeof(*uci_pdu->harq)); uci_pdu->harq->num_harq = 2; - uci_pdu->harq->harq_confidence_level = (no_conf) ? 1 : 0; - uci_pdu->harq->harq_list = (nfapi_nr_harq_t*)malloc(2); + uci_pdu->harq->harq_confidence_level = no_conf; + uci_pdu->harq->harq_list = (nfapi_nr_harq_t*)malloc(2 * sizeof( *uci_pdu->harq->harq_list)); uci_pdu->harq->harq_list[1].harq_value = !(index&0x01); uci_pdu->harq->harq_list[0].harq_value = !((index>>1)&0x01); - LOG_D(PHY, "[DLSCH/PDSCH/PUCCH] %d.%d HARQ values %d (0 pass, 1 fail) and %d with confidence level %d (0 is good, 1 is bad), xrt_mag %d xrt_mag_next %d n0 %d (%d,%d) pucch0_thres %d, cqi %d, SNRtimes10 %d,sync_pos %d\n", - frame,slot,uci_pdu->harq->harq_list[1].harq_value,uci_pdu->harq->harq_list[0].harq_value,uci_pdu->harq->harq_confidence_level,xrtmag_dBtimes10,xrtmag_next_dBtimes10,max_n0,uci_stats->pucch0_n00,uci_stats->pucch0_n01,uci_stats->pucch0_thres,cqi,SNRtimes10,gNB->ulsch_stats[0].sync_pos); + LOG_D(PHY, "[DLSCH/PDSCH/PUCCH] %d.%d HARQ values (%s, %s) with confidence level %s, xrt_mag %d xrt_mag_next %d n0 %d (%d,%d) pucch0_thres %d, cqi %d, SNRtimes10 %d,sync_pos %d\n", + frame,slot, + uci_pdu->harq->harq_list[1].harq_value == 0 ? "ACK" : "NACK", + uci_pdu->harq->harq_list[0].harq_value == 0 ? "ACK" : "NACK", + uci_pdu->harq->harq_confidence_level == 0 ? "good" : "bad", + xrtmag_dBtimes10,xrtmag_next_dBtimes10,max_n0, + uci_stats->pucch0_n00,uci_stats->pucch0_n01,uci_stats->pucch0_thres,cqi, + SNRtimes10,gNB->ulsch_stats[0].sync_pos); if (pucch_pdu->sr_flag == 1) { uci_pdu->sr = calloc(1,sizeof(*uci_pdu->sr)); uci_pdu->sr->sr_indication = (index>3) ? 1 : 0; - uci_pdu->sr->sr_confidence_level = (no_conf) ? 1 : 0; + uci_pdu->sr->sr_confidence_level = no_conf; + if(uci_pdu->sr->sr_indication == 1 && uci_pdu->sr->sr_confidence_level == 0) { + uci_stats->pucch0_positive_SR++; + LOG_D(PHY,"PUCCH0 got positive SR. Cumulative number of positive SR %d\n", uci_stats->pucch0_positive_SR); + } } } } @@ -1177,9 +1189,9 @@ void nr_decode_pucch2(PHY_VARS_gNB *gNB, } } } -#ifdef DEBUG_NR_PUCCH_RX - printf("Decoding pucch2 for %d symbols, %d PRB\n",pucch_pdu->nr_of_symbols,pucch_pdu->prb_size); -#endif + LOG_D(PHY,"Decoding pucch2 for %d symbols, %d PRB, nb_harq %d, nb_sr %d, nb_csi %d/%d\n", + pucch_pdu->nr_of_symbols,pucch_pdu->prb_size, + pucch_pdu->bit_len_harq,pucch_pdu->sr_flag,pucch_pdu->bit_len_csi_part1,pucch_pdu->bit_len_csi_part2); int nc_group_size=1; // 2 PRB int ngroup = prb_size_ext/nc_group_size/2; @@ -1533,7 +1545,8 @@ void nr_decode_pucch2(PHY_VARS_gNB *gNB, #ifdef DEBUG_NR_PUCCH_RX printf("cw_ML %d, metric %d dB\n",cw_ML,corr_dB); #endif - LOG_D(PHY,"cw_ML %d, metric %d dB\n",cw_ML,corr_dB); + LOG_D(PHY,"slot %d PUCCH2 cw_ML %d, metric %d dB\n", slot, cw_ML, corr_dB); + decodedPayload[0]=(uint64_t)cw_ML; } else { // polar coded case @@ -1671,7 +1684,8 @@ void nr_decode_pucch2(PHY_VARS_gNB *gNB, LOG_D(PHY,"metric %d dB\n",corr_dB); } - // estimate CQI for MAC (from antenna port 0 only) + // estimate CQI for MAC (from antenna port 0 only) + // TODO this computation is wrong -> to be ignored at MAC for now int SNRtimes10 = dB_fixed_times10(signal_energy_nodc(&rxdataF[0][soffset+(l2*frame_parms->ofdm_symbol_size)+re_offset[0]], 12*pucch_pdu->prb_size)) - (10*gNB->measurements.n0_power_tot_dB); diff --git a/openair1/PHY/NR_UE_ESTIMATION/filt16a_32.c b/openair1/PHY/NR_UE_ESTIMATION/filt16a_32.c index 0c520aabe7..624894aeb9 100644 --- a/openair1/PHY/NR_UE_ESTIMATION/filt16a_32.c +++ b/openair1/PHY/NR_UE_ESTIMATION/filt16a_32.c @@ -148,7 +148,7 @@ short filt8_dcr0_h[8]= { 0,4096,8192,12288,16384,0,0,0}; short filt8_l1[8] = { -24576,16384,0,0,0,0,0,0}; +24576,16384,8192,0,0,0,0,0}; short filt8_ml1[8] = { -8192,0,8192,16384,8192,0,0,0}; @@ -163,10 +163,10 @@ short filt8_mm1[8]= { 0,0,0,0,8192,16384,8192,0}; short filt8_dcl1[8]= { -0,0,0,16384,12288,8192,4096,0}; +0,0,16384,12288,8192,4096,0,0}; short filt8_dcr1[8]= { -0,0,0,0,4096,8192,12288,16384}; +0,0,0,4096,8192,12288,16384,0}; short filt8_dcl1_h[8]= { 0,16384,12288,8192,4096,0,0,0}; @@ -282,4 +282,17 @@ short filt16_middle4[16] = { 4096,8192,8192,8192,8192,8192,8192,8192,4096,0,0,0,0,0,0,0}; short filt16_end[16] = { - 4096,8192,8192,8192,12288,16384,16384,16384,0,0,0,0,0,0,0,0}; \ No newline at end of file + 4096,8192,8192,8192,12288,16384,16384,16384,0,0,0,0,0,0,0,0}; + +// CSI-RS +short filt24_start[24] = { + 12288,11605,10923,10240,9557,8875,8192,7509,6827,6144,5461,4779, + 0,0,0,0,0,0,0,0,0,0,0,0}; + +short filt24_end[24] = { + 4096,4779,5461,6144,6827,7509,8192,8875,9557,10240,10923,11605, + 16384,16384,16384,16384,16384,16384,16384,16384,16384,16384,16384,16384}; + +short filt24_middle[24] = { + 4096,4779,5461,6144,6827,7509,8192,8875,9557,10240,10923,11605, + 12288,11605,10923,10240,9557,8875,8192,7509,6827,6144,5461,4779}; \ No newline at end of file diff --git a/openair1/PHY/NR_UE_ESTIMATION/filt16a_32.h b/openair1/PHY/NR_UE_ESTIMATION/filt16a_32.h index 72d1318545..41109cb7bb 100644 --- a/openair1/PHY/NR_UE_ESTIMATION/filt16a_32.h +++ b/openair1/PHY/NR_UE_ESTIMATION/filt16a_32.h @@ -193,4 +193,10 @@ extern short filt8_end[8]; extern short filt16_start[16]; extern short filt16_middle4[16]; extern short filt16_end[16]; + +/*CSI-RS*/ +extern short filt24_start[24]; +extern short filt24_end[24]; +extern short filt24_middle[24]; + #endif diff --git a/openair1/PHY/NR_UE_ESTIMATION/nr_adjust_synch_ue.c b/openair1/PHY/NR_UE_ESTIMATION/nr_adjust_synch_ue.c index 15f3abad79..045197adc1 100644 --- a/openair1/PHY/NR_UE_ESTIMATION/nr_adjust_synch_ue.c +++ b/openair1/PHY/NR_UE_ESTIMATION/nr_adjust_synch_ue.c @@ -36,6 +36,8 @@ void nr_adjust_synch_ue(NR_DL_FRAME_PARMS *frame_parms, PHY_VARS_NR_UE *ue, module_id_t gNB_id, + const int estimateSz, + struct complex16 dl_ch_estimates_time[][estimateSz], uint8_t frame, uint8_t subframe, unsigned char clear, @@ -60,8 +62,8 @@ void nr_adjust_synch_ue(NR_DL_FRAME_PARMS *frame_parms, int j = (i < 0) ? (i + frame_parms->ofdm_symbol_size) : i; for (int aa = 0; aa < frame_parms->nb_antennas_rx; aa++) { - int Re = ((int16_t*)ue->pbch_vars[gNB_id]->dl_ch_estimates_time[aa])[(j<<1)]; - int Im = ((int16_t*)ue->pbch_vars[gNB_id]->dl_ch_estimates_time[aa])[1+(j<<1)]; + int Re = dl_ch_estimates_time[aa][j].r; + int Im = dl_ch_estimates_time[aa][j].i; temp += (Re*Re/2) + (Im*Im/2); } diff --git a/openair1/PHY/NR_UE_ESTIMATION/nr_dl_channel_estimation.c b/openair1/PHY/NR_UE_ESTIMATION/nr_dl_channel_estimation.c index 7281f8e290..082370dff4 100644 --- a/openair1/PHY/NR_UE_ESTIMATION/nr_dl_channel_estimation.c +++ b/openair1/PHY/NR_UE_ESTIMATION/nr_dl_channel_estimation.c @@ -29,10 +29,12 @@ #include "PHY/NR_REFSIG/ptrs_nr.h" #include "PHY/NR_TRANSPORT/nr_sch_dmrs.h" #include "filt16a_32.h" +#include //#define DEBUG_PDSCH //#define DEBUG_PDCCH +#define NO_INTERP 1 int nr_pbch_dmrs_correlation(PHY_VARS_NR_UE *ue, UE_nr_rxtx_proc_t *proc, @@ -43,7 +45,6 @@ int nr_pbch_dmrs_correlation(PHY_VARS_NR_UE *ue, NR_UE_SSB *current_ssb) { int pilot[200] __attribute__((aligned(16))); - unsigned char aarx; unsigned short k; unsigned int pilot_cnt; int16_t ch[2],*pil,*rxF; @@ -77,7 +78,7 @@ int nr_pbch_dmrs_correlation(PHY_VARS_NR_UE *ue, // generate pilot nr_pbch_dmrs_rx(dmrss,ue->nr_gold_pbch[n_hf][ssb_index], &pilot[0]); - for (aarx=0; aarxframe_parms.nb_antennas_rx; aarx++) { + for (int aarx=0; aarxframe_parms.nb_antennas_rx; aarx++) { int re_offset = ssb_offset; pil = (int16_t *)&pilot[0]; @@ -197,6 +198,9 @@ int nr_pbch_dmrs_correlation(PHY_VARS_NR_UE *ue, int nr_pbch_channel_estimation(PHY_VARS_NR_UE *ue, + int estimateSz, + struct complex16 dl_ch_estimates [][estimateSz], + struct complex16 dl_ch_estimates_time [][ue->frame_parms.ofdm_symbol_size], UE_nr_rxtx_proc_t *proc, uint8_t gNB_id, unsigned char Ns, @@ -206,16 +210,14 @@ int nr_pbch_channel_estimation(PHY_VARS_NR_UE *ue, uint8_t n_hf) { int pilot[200] __attribute__((aligned(16))); - unsigned char aarx,p; unsigned short k; unsigned int pilot_cnt; - int16_t ch[2],*pil,*rxF,*dl_ch,*fl,*fm,*fr; + int16_t *pil,*rxF,*dl_ch,*fl,*fm,*fr; int ch_offset,symbol_offset; //int slot_pbch; uint8_t nushift; - int **dl_ch_estimates =ue->pbch_vars[gNB_id]->dl_ch_estimates; - int **rxdataF=ue->common_vars.common_vars_rx_data_per_thread[proc->thread_id].rxdataF; + int **rxdataF=ue->common_vars.common_vars_rx_data_per_thread[proc->thread_id].rxdataF; nushift = ue->frame_parms.Nid_cell%4; ue->frame_parms.nushift = nushift; @@ -269,17 +271,57 @@ int nr_pbch_channel_estimation(PHY_VARS_NR_UE *ue, break; } + idft_size_idx_t idftsizeidx; + + switch (ue->frame_parms.ofdm_symbol_size) { + case 128: + idftsizeidx = IDFT_128; + break; + + case 256: + idftsizeidx = IDFT_256; + break; + + case 512: + idftsizeidx = IDFT_512; + break; + + case 1024: + idftsizeidx = IDFT_1024; + break; + + case 1536: + idftsizeidx = IDFT_1536; + break; + + case 2048: + idftsizeidx = IDFT_2048; + break; + + case 3072: + idftsizeidx = IDFT_3072; + break; + + case 4096: + idftsizeidx = IDFT_4096; + break; + + default: + printf("unsupported ofdm symbol size \n"); + assert(0); + } + // generate pilot nr_pbch_dmrs_rx(dmrss,ue->nr_gold_pbch[n_hf][ssb_index], &pilot[0]); - for (aarx=0; aarxframe_parms.nb_antennas_rx; aarx++) { + for (int aarx=0; aarxframe_parms.nb_antennas_rx; aarx++) { int re_offset = ssb_offset; pil = (int16_t *)&pilot[0]; rxF = (int16_t *)&rxdataF[aarx][(symbol_offset+k+re_offset)]; dl_ch = (int16_t *)&dl_ch_estimates[aarx][ch_offset]; - memset(dl_ch,0,4*(ue->frame_parms.ofdm_symbol_size)); + memset(dl_ch,0,sizeof(struct complex16)*(ue->frame_parms.ofdm_symbol_size)); #ifdef DEBUG_CH printf("pbch ch est pilot addr %p RB_DL %d\n",&pilot[0], ue->frame_parms.N_RB_DL); @@ -289,6 +331,7 @@ int nr_pbch_channel_estimation(PHY_VARS_NR_UE *ue, #endif // Treat first 2 pilots specially (left edge) + int16_t ch[2]; ch[0] = (int16_t)(((int32_t)pil[0]*rxF[0] - (int32_t)pil[1]*rxF[1])>>15); ch[1] = (int16_t)(((int32_t)pil[0]*rxF[1] + (int32_t)pil[1]*rxF[0])>>15); @@ -345,10 +388,10 @@ int nr_pbch_channel_estimation(PHY_VARS_NR_UE *ue, // in 2nd symbol, skip middle REs (48 with DMRS, 144 for SSS, and another 48 with DMRS) if (dmrss == 1 && pilot_cnt == 12) { - pilot_cnt=48; - re_offset = (re_offset+144) % ue->frame_parms.ofdm_symbol_size; - rxF = (int16_t *)&rxdataF[aarx][(symbol_offset+k+re_offset)]; - dl_ch += 288; + pilot_cnt=48; + re_offset = (re_offset+144) % ue->frame_parms.ofdm_symbol_size; + rxF = (int16_t *)&rxdataF[aarx][(symbol_offset+k+re_offset)]; + dl_ch += 288; } ch[0] = (int16_t)(((int32_t)pil[0]*rxF[0] - (int32_t)pil[1]*rxF[1])>>15); ch[1] = (int16_t)(((int32_t)pil[0]*rxF[1] + (int32_t)pil[1]*rxF[0])>>15); @@ -402,62 +445,20 @@ int nr_pbch_channel_estimation(PHY_VARS_NR_UE *ue, } - idft_size_idx_t idftsizeidx; - - switch (ue->frame_parms.ofdm_symbol_size) { - case 128: - idftsizeidx = IDFT_128; - break; - - case 256: - idftsizeidx = IDFT_256; - break; - - case 512: - idftsizeidx = IDFT_512; - break; - - case 1024: - idftsizeidx = IDFT_1024; - break; - - case 1536: - idftsizeidx = IDFT_1536; - break; - - case 2048: - idftsizeidx = IDFT_2048; - break; - - case 3072: - idftsizeidx = IDFT_3072; - break; - - case 4096: - idftsizeidx = IDFT_4096; - break; - - default: - printf("unsupported ofdm symbol size \n"); - assert(0); - } - if( dmrss == 2) // update time statistics for last PBCH symbol { // do ifft of channel estimate - for (aarx=0; aarxframe_parms.nb_antennas_rx; aarx++) - for (p=0; pframe_parms.nb_antenna_ports_gNB; p++) { - if (ue->pbch_vars[gNB_id]->dl_ch_estimates[(p*ue->frame_parms.nb_antennas_rx)+aarx]) - { - LOG_D(PHY,"Channel Impulse Computation Slot %d ThreadId %d Symbol %d ch_offset %d\n", Ns, proc->thread_id, symbol, ch_offset); - idft(idftsizeidx, - (int16_t*) &ue->pbch_vars[gNB_id]->dl_ch_estimates[(p*ue->frame_parms.nb_antennas_rx)+aarx][ch_offset], - (int16_t*) ue->pbch_vars[gNB_id]->dl_ch_estimates_time[(p*ue->frame_parms.nb_antennas_rx)+aarx],1); - } - } + LOG_D(PHY,"Channel Impulse Computation Slot %d Symbol %d ch_offset %d\n", Ns, symbol, ch_offset); + idft(idftsizeidx, + (int16_t*) &dl_ch_estimates[aarx][ch_offset], + (int16_t*) dl_ch_estimates_time[aarx], + 1); } - } + + if (dmrss == 2) + UEscopeCopy(ue, pbchDlChEstimateTime, (void*)dl_ch_estimates_time, sizeof(struct complex16), ue->frame_parms.nb_antennas_rx, idftsizeidx); + return(0); } @@ -466,8 +467,11 @@ int nr_pdcch_channel_estimation(PHY_VARS_NR_UE *ue, uint8_t gNB_id, unsigned char Ns, unsigned char symbol, + unsigned short scrambling_id, unsigned short coreset_start_subcarrier, - unsigned short nb_rb_coreset) + unsigned short nb_rb_coreset, + int32_t pdcch_est_size, + int32_t pdcch_dl_ch_estimates[][pdcch_est_size]) { unsigned char aarx; @@ -476,7 +480,6 @@ int nr_pdcch_channel_estimation(PHY_VARS_NR_UE *ue, int16_t ch[2],*pil,*rxF,*dl_ch,*fl,*fm,*fr; int ch_offset,symbol_offset; - int **dl_ch_estimates =ue->pdcch_vars[proc->thread_id][gNB_id]->dl_ch_estimates; int **rxdataF=ue->common_vars.common_vars_rx_data_per_thread[proc->thread_id].rxdataF; ch_offset = ue->frame_parms.ofdm_symbol_size*symbol; @@ -493,13 +496,11 @@ int nr_pdcch_channel_estimation(PHY_VARS_NR_UE *ue, fm = filt16a_m1; fr = filt16a_r1; - // checking if re-initialization of scrambling IDs is needed (should be done here but scrambling ID for PDCCH is not taken from RRC) -/* if (( != ue->scramblingID_pdcch){ - ue->scramblingID_pdcch=; - nr_gold_pdsch(ue,ue->scramblingID_pdcch); - }*/ - + if (scrambling_id != ue->scramblingID_pdcch){ + ue->scramblingID_pdcch = scrambling_id; + nr_gold_pdcch(ue,ue->scramblingID_pdcch); + } // generate pilot int pilot[nb_rb_coreset * 3] __attribute__((aligned(16))); @@ -511,7 +512,7 @@ int nr_pdcch_channel_estimation(PHY_VARS_NR_UE *ue, k = coreset_start_subcarrier; pil = (int16_t *)&pilot[0]; rxF = (int16_t *)&rxdataF[aarx][(symbol_offset+k+1)]; - dl_ch = (int16_t *)&dl_ch_estimates[aarx][ch_offset]; + dl_ch = (int16_t *)&pdcch_dl_ch_estimates[aarx][ch_offset]; memset(dl_ch,0,4*(ue->frame_parms.ofdm_symbol_size)); @@ -536,8 +537,12 @@ int nr_pdcch_channel_estimation(PHY_VARS_NR_UE *ue, 16); pil += 2; rxF += 8; - //for (int i= 0; i<8; i++) - //printf("dl_ch addr %p %d\n", dl_ch+i, *(dl_ch+i)); + k += 4; + + if (k >= ue->frame_parms.ofdm_symbol_size) { + k -= ue->frame_parms.ofdm_symbol_size; + rxF = (int16_t *)&rxdataF[aarx][(symbol_offset+k+1)]; + } ch[0] = (int16_t)(((int32_t)pil[0]*rxF[0] - (int32_t)pil[1]*rxF[1])>>15); ch[1] = (int16_t)(((int32_t)pil[0]*rxF[1] + (int32_t)pil[1]*rxF[0])>>15); @@ -550,6 +555,12 @@ int nr_pdcch_channel_estimation(PHY_VARS_NR_UE *ue, 16); pil += 2; rxF += 8; + k += 4; + + if (k >= ue->frame_parms.ofdm_symbol_size) { + k -= ue->frame_parms.ofdm_symbol_size; + rxF = (int16_t *)&rxdataF[aarx][(symbol_offset+k+1)]; + } ch[0] = (int16_t)(((int32_t)pil[0]*rxF[0] - (int32_t)pil[1]*rxF[1])>>15); ch[1] = (int16_t)(((int32_t)pil[0]*rxF[1] + (int32_t)pil[1]*rxF[0])>>15); @@ -562,23 +573,22 @@ int nr_pdcch_channel_estimation(PHY_VARS_NR_UE *ue, ch, dl_ch, 16); - -#ifdef DEBUG_PDCCH +#ifdef DEBUG_PDCCH for (int m =0; m<12; m++) printf("data : dl_ch -> (%d,%d)\n",dl_ch[0+2*m],dl_ch[1+2*m]); -#endif +#endif + dl_ch += 24; + pil += 2; rxF += 8; - dl_ch += 24; - k += 12; - - + k += 4; for (pilot_cnt=3; pilot_cnt<(3*nb_rb_coreset); pilot_cnt += 3) { - if (k >= ue->frame_parms.ofdm_symbol_size){ - k-=ue->frame_parms.ofdm_symbol_size; - rxF = (int16_t *)&rxdataF[aarx][(symbol_offset+k+1)];} + if (k >= ue->frame_parms.ofdm_symbol_size) { + k -= ue->frame_parms.ofdm_symbol_size; + rxF = (int16_t *)&rxdataF[aarx][(symbol_offset+k+1)]; + } ch[0] = (int16_t)(((int32_t)pil[0]*rxF[0] - (int32_t)pil[1]*rxF[1])>>15); ch[1] = (int16_t)(((int32_t)pil[0]*rxF[1] + (int32_t)pil[1]*rxF[0])>>15); @@ -595,6 +605,12 @@ int nr_pdcch_channel_estimation(PHY_VARS_NR_UE *ue, pil += 2; rxF += 8; + k += 4; + + if (k >= ue->frame_parms.ofdm_symbol_size) { + k -= ue->frame_parms.ofdm_symbol_size; + rxF = (int16_t *)&rxdataF[aarx][(symbol_offset+k+1)]; + } ch[0] = (int16_t)(((int32_t)pil[0]*rxF[0] - (int32_t)pil[1]*rxF[1])>>15); ch[1] = (int16_t)(((int32_t)pil[0]*rxF[1] + (int32_t)pil[1]*rxF[0])>>15); @@ -607,6 +623,12 @@ int nr_pdcch_channel_estimation(PHY_VARS_NR_UE *ue, 16); pil += 2; rxF += 8; + k += 4; + + if (k >= ue->frame_parms.ofdm_symbol_size) { + k -= ue->frame_parms.ofdm_symbol_size; + rxF = (int16_t *)&rxdataF[aarx][(symbol_offset+k+1)]; + } ch[0] = (int16_t)(((int32_t)pil[0]*rxF[0] - (int32_t)pil[1]*rxF[1])>>15); ch[1] = (int16_t)(((int32_t)pil[0]*rxF[1] + (int32_t)pil[1]*rxF[0])>>15); @@ -619,11 +641,15 @@ int nr_pdcch_channel_estimation(PHY_VARS_NR_UE *ue, ch, dl_ch, 16); +#ifdef DEBUG_PDCCH + for (int m =0; m<12; m++) + printf("data : dl_ch -> (%d,%d)\n",dl_ch[0+2*m],dl_ch[1+2*m]); +#endif + dl_ch += 24; + pil += 2; rxF += 8; - dl_ch += 24; - k += 12; - + k += 4; } @@ -641,6 +667,8 @@ int nr_pdsch_channel_estimation(PHY_VARS_NR_UE *ue, unsigned char Ns, unsigned short p, unsigned char symbol, + unsigned char nscid, + unsigned short scrambling_id, unsigned short BWPStart, uint8_t config_type, unsigned short bwp_start_subcarrier, @@ -655,7 +683,7 @@ int nr_pdsch_channel_estimation(PHY_VARS_NR_UE *ue, int ch_offset,symbol_offset; uint8_t nushift; - int **dl_ch_estimates =ue->pdsch_vars[proc->thread_id][gNB_id]->dl_ch_estimates; + int **dl_ch_estimates = ue->pdsch_vars[proc->thread_id][gNB_id]->dl_ch_estimates; int **rxdataF=ue->common_vars.common_vars_rx_data_per_thread[proc->thread_id].rxdataF; ch_offset = ue->frame_parms.ofdm_symbol_size*symbol; @@ -665,7 +693,7 @@ int nr_pdsch_channel_estimation(PHY_VARS_NR_UE *ue, k = bwp_start_subcarrier; int re_offset = k; -#ifdef DEBUG_CH +#ifdef DEBUG_PDSCH printf("PDSCH Channel Estimation : ThreadId %d, gNB_id %d ch_offset %d, symbol_offset %d OFDM size %d, Ncp=%d, Ns=%d, k=%d symbol %d\n",proc->thread_id, gNB_id,ch_offset,symbol_offset,ue->frame_parms.ofdm_symbol_size, ue->frame_parms.Ncp,Ns,k, symbol); #endif @@ -678,11 +706,10 @@ int nr_pdsch_channel_estimation(PHY_VARS_NR_UE *ue, int8_t delta = get_delta(p, config_type); // checking if re-initialization of scrambling IDs is needed - /*if ((XXX.scramblingID0 != ue->scramblingID[0]) || (XXX.scramblingID1 != ue->scramblingID[1])){ - ue->scramblingID[0] = XXX.scramblingID0; - ue->scramblingID[1] = XXX.scramblingID1; - nr_gold_pdsch(ue,ue->scramblingID); - }*/ + if (scrambling_id != ue->scramblingID_dlsch[nscid]){ + ue->scramblingID_dlsch[nscid] = scrambling_id; + nr_gold_pdsch(ue, nscid, scrambling_id); + } nr_pdsch_dmrs_rx(ue, Ns, ue->nr_gold_pdsch[gNB_id][Ns][symbol][0], &pilot[0], 1000+p, 0, nb_rb_pdsch+rb_offset, config_type); @@ -781,7 +808,7 @@ int nr_pdsch_channel_estimation(PHY_VARS_NR_UE *ue, printf("rxF addr %p p %d\n", rxF,p); printf("dl_ch addr %p nushift %d\n",dl_ch,nushift); #endif - if (config_type == NFAPI_NR_DMRS_TYPE1 && ue->prb_interpolation == 0) { + if (config_type == NFAPI_NR_DMRS_TYPE1 && ue->chest_freq == 0) { // Treat first 2 pilots specially (left edge) ch[0] = (int16_t)(((int32_t)pil[0]*rxF[0] - (int32_t)pil[1]*rxF[1])>>15); @@ -958,7 +985,7 @@ int nr_pdsch_channel_estimation(PHY_VARS_NR_UE *ue, 8); } } - } else if (config_type == NFAPI_NR_DMRS_TYPE2 && ue->prb_interpolation == 0){ //pdsch_dmrs_type2 |dmrs_r,dmrs_l,0,0,0,0,dmrs_r,dmrs_l,0,0,0,0| + } else if (config_type == NFAPI_NR_DMRS_TYPE2 && ue->chest_freq == 0){ //pdsch_dmrs_type2 |dmrs_r,dmrs_l,0,0,0,0,dmrs_r,dmrs_l,0,0,0,0| // Treat first 4 pilots specially (left edge) ch_l[0] = (int16_t)(((int32_t)pil[0]*rxF[0] - (int32_t)pil[1]*rxF[1])>>15); @@ -1218,6 +1245,10 @@ int nr_pdsch_channel_estimation(PHY_VARS_NR_UE *ue, ch[0] = ch_0 / 6; ch[1] = ch_1 / 6; +#if NO_INTERP + for (int i=0;i<12;i++) ((int32_t*)dl_ch)[i] = *(int32_t*)ch; + dl_ch+=24; +#else multadd_real_vector_complex_scalar(filt8_avlip0, ch, dl_ch, @@ -1235,6 +1266,7 @@ int nr_pdsch_channel_estimation(PHY_VARS_NR_UE *ue, dl_ch, 8); dl_ch -= 24; +#endif for (pilot_cnt=6; pilot_cnt<6*(nb_rb_pdsch-1); pilot_cnt += 6) { @@ -1282,6 +1314,11 @@ int nr_pdsch_channel_estimation(PHY_VARS_NR_UE *ue, ch[0] = ch_0 / 6; ch[1] = ch_1 / 6; + +#if NO_INTERP + for (int i=0;i<12;i++) ((int32_t*)dl_ch)[i] = *(int32_t*)ch; + dl_ch+=24; +#else dl_ch[6] += (ch[0] * 1365)>>15; // 1/12*16384 dl_ch[7] += (ch[1] * 1365)>>15; // 1/12*16384 @@ -1303,6 +1340,7 @@ int nr_pdsch_channel_estimation(PHY_VARS_NR_UE *ue, dl_ch, 8); dl_ch -= 16; +#endif } ch_0 = ((int32_t)pil[0]*rxF[0] - (int32_t)pil[1]*rxF[1])>>15; ch_1 = ((int32_t)pil[0]*rxF[1] + (int32_t)pil[1]*rxF[0])>>15; @@ -1349,6 +1387,10 @@ int nr_pdsch_channel_estimation(PHY_VARS_NR_UE *ue, ch[0] = ch_0 / 6; ch[1] = ch_1 / 6; +#if NO_INTERP + for (int i=0;i<12;i++) ((int32_t*)dl_ch)[i] = *(int32_t*)ch; + dl_ch+=24; +#else dl_ch[6] += (ch[0] * 1365)>>15; // 1/12*16384 dl_ch[7] += (ch[1] * 1365)>>15; // 1/12*16384 @@ -1363,6 +1405,7 @@ int nr_pdsch_channel_estimation(PHY_VARS_NR_UE *ue, ch, dl_ch, 8); +#endif } else { // this is case without frequency-domain linear interpolation, just take average of LS channel estimates of 4 DMRS REs and use a common value for the whole PRB int32_t ch_0, ch_1; @@ -1398,6 +1441,10 @@ int nr_pdsch_channel_estimation(PHY_VARS_NR_UE *ue, ch[0] = ch_0 / 4; ch[1] = ch_1 / 4; +#if NO_INTERP + for (int i=0;i<12;i++) ((int32_t*)dl_ch)[i] = *(int32_t*)ch; + dl_ch+=24; +#else multadd_real_vector_complex_scalar(filt8_avlip0, ch, dl_ch, @@ -1415,6 +1462,7 @@ int nr_pdsch_channel_estimation(PHY_VARS_NR_UE *ue, dl_ch, 8); dl_ch -= 24; +#endif for (pilot_cnt=4; pilot_cnt<4*(nb_rb_pdsch-1); pilot_cnt += 4) { int32_t ch_0, ch_1; @@ -1450,6 +1498,10 @@ int nr_pdsch_channel_estimation(PHY_VARS_NR_UE *ue, ch[0] = ch_0 / 4; ch[1] = ch_1 / 4; +#if NO_INTERP + for (int i=0;i<12;i++) ((int32_t*)dl_ch)[i] = *(int32_t*)ch; + dl_ch+=24; +#else dl_ch[6] += (ch[0] * 1365)>>15; // 1/12*16384 dl_ch[7] += (ch[1] * 1365)>>15; // 1/12*16384 @@ -1471,6 +1523,7 @@ int nr_pdsch_channel_estimation(PHY_VARS_NR_UE *ue, dl_ch, 8); dl_ch -= 16; +#endif } ch_0 = ((int32_t)pil[0]*rxF[0] - (int32_t)pil[1]*rxF[1])>>15; @@ -1504,6 +1557,10 @@ int nr_pdsch_channel_estimation(PHY_VARS_NR_UE *ue, ch[0] = ch_0 / 4; ch[1] = ch_1 / 4; +#if NO_INTERP + for (int i=0;i<12;i++) ((int32_t*)dl_ch)[i] = *(int32_t*)ch; + dl_ch+=24; +#else dl_ch[6] += (ch[0] * 1365)>>15; // 1/12*16384 dl_ch[7] += (ch[1] * 1365)>>15; // 1/12*16384 @@ -1518,6 +1575,7 @@ int nr_pdsch_channel_estimation(PHY_VARS_NR_UE *ue, ch, dl_ch, 8); +#endif } #ifdef DEBUG_PDSCH dl_ch = (int16_t *)&dl_ch_estimates[p*ue->frame_parms.nb_antennas_rx+aarx][ch_offset]; @@ -1647,7 +1705,6 @@ void nr_pdsch_ptrs_processing(PHY_VARS_NR_UE *ue, /*------------------------------------------------------------------------------------------------------- */ nr_ptrs_cpe_estimation(*K_ptrs,*ptrsReOffset,*dmrsConfigType,*nb_rb, rnti, - (int16_t *)&pdsch_vars[gNB_id]->dl_ch_ptrs_estimates_ext[aarx][symbol*nb_re_pdsch], nr_slot_rx, symbol,frame_parms->ofdm_symbol_size, (int16_t*)&pdsch_vars[gNB_id]->rxdataF_comp0[aarx][(symbol * nb_re_pdsch)], diff --git a/openair1/PHY/NR_UE_ESTIMATION/nr_estimation.h b/openair1/PHY/NR_UE_ESTIMATION/nr_estimation.h index 4dec92143a..ce99f0f9c9 100644 --- a/openair1/PHY/NR_UE_ESTIMATION/nr_estimation.h +++ b/openair1/PHY/NR_UE_ESTIMATION/nr_estimation.h @@ -44,8 +44,11 @@ int nr_pdcch_channel_estimation(PHY_VARS_NR_UE *ue, uint8_t gNB_id, unsigned char Ns, unsigned char symbol, + unsigned short scrambling_id, unsigned short coreset_start_subcarrier, - unsigned short nb_rb_coreset); + unsigned short nb_rb_coreset, + int32_t pdcch_est_size, + int32_t pdcch_dl_ch_estimates[][pdcch_est_size]); int nr_pbch_dmrs_correlation(PHY_VARS_NR_UE *ue, UE_nr_rxtx_proc_t *proc, @@ -56,7 +59,10 @@ int nr_pbch_dmrs_correlation(PHY_VARS_NR_UE *ue, NR_UE_SSB *current_ssb); int nr_pbch_channel_estimation(PHY_VARS_NR_UE *ue, - UE_nr_rxtx_proc_t *proc, + int estimateSz, + struct complex16 dl_ch_estimates [][estimateSz], + struct complex16 dl_ch_estimates_time [][estimateSz], + UE_nr_rxtx_proc_t *proc, uint8_t gNB_id, unsigned char Ns, unsigned char symbol, @@ -71,6 +77,8 @@ int nr_pdsch_channel_estimation(PHY_VARS_NR_UE *ue, unsigned char Ns, unsigned short p, unsigned char symbol, + unsigned char nscid, + unsigned short scrambling_id, unsigned short BWPStart, uint8_t config_type, unsigned short bwp_start_subcarrier, @@ -79,6 +87,8 @@ int nr_pdsch_channel_estimation(PHY_VARS_NR_UE *ue, void nr_adjust_synch_ue(NR_DL_FRAME_PARMS *frame_parms, PHY_VARS_NR_UE *ue, module_id_t gNB_id, + int estimateSz, + struct complex16 dl_ch_estimates_time [][estimateSz], uint8_t frame, uint8_t subframe, unsigned char clear, diff --git a/openair1/PHY/NR_UE_TRANSPORT/csi_rx.c b/openair1/PHY/NR_UE_TRANSPORT/csi_rx.c new file mode 100644 index 0000000000..79fd7a3dd2 --- /dev/null +++ b/openair1/PHY/NR_UE_TRANSPORT/csi_rx.c @@ -0,0 +1,380 @@ +/* + * 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 + */ + +/*********************************************************************** +* +* FILENAME : csi_rx.c +* +* MODULE : +* +* DESCRIPTION : function to receive the channel state information +* +************************************************************************/ + +#include +#include +#include + +#include "nr_transport_proto_ue.h" +#include "PHY/phy_extern_nr_ue.h" +#include "common/utils/nr/nr_common.h" +#include "PHY/NR_TRANSPORT/nr_transport_proto.h" +#include "PHY/NR_UE_ESTIMATION/filt16a_32.h" + + +//#define NR_CSIRS_DEBUG + +bool is_csi_rs_in_symbol(fapi_nr_dl_config_csirs_pdu_rel15_t csirs_config_pdu, int symbol) { + + bool ret = false; + + // 38.211-Table 7.4.1.5.3-1: CSI-RS locations within a slot + switch(csirs_config_pdu.row){ + case 1: + case 2: + case 3: + case 4: + case 6: + case 9: + if(symbol == csirs_config_pdu.symb_l0) { + ret = true; + } + break; + case 5: + case 7: + case 8: + case 10: + case 11: + case 12: + if(symbol == csirs_config_pdu.symb_l0 || symbol == (csirs_config_pdu.symb_l0+1) ) { + ret = true; + } + break; + case 13: + case 14: + case 16: + case 17: + if(symbol == csirs_config_pdu.symb_l0 || symbol == (csirs_config_pdu.symb_l0+1) || + symbol == csirs_config_pdu.symb_l1 || symbol == (csirs_config_pdu.symb_l1+1)) { + ret = true; + } + break; + case 15: + case 18: + if(symbol == csirs_config_pdu.symb_l0 || symbol == (csirs_config_pdu.symb_l0+1) || symbol == (csirs_config_pdu.symb_l0+2) ) { + ret = true; + } + break; + default: + AssertFatal(0==1, "Row %d is not valid for CSI Table 7.4.1.5.3-1\n", csirs_config_pdu.row); + } + + return ret; +} + +int nr_get_csi_rs_signal(PHY_VARS_NR_UE *ue, + UE_nr_rxtx_proc_t *proc, + fapi_nr_dl_config_csirs_pdu_rel15_t *csirs_config_pdu, + nr_csi_rs_info_t *nr_csi_rs_info, + int32_t **csi_rs_received_signal) { + + int32_t **rxdataF = ue->common_vars.common_vars_rx_data_per_thread[proc->thread_id].rxdataF; + NR_DL_FRAME_PARMS *frame_parms = &ue->frame_parms; + + for (int ant_rx = 0; ant_rx < frame_parms->nb_antennas_rx; ant_rx++) { + memset(csi_rs_received_signal[ant_rx], 0, frame_parms->samples_per_frame_wCP*sizeof(int32_t)); + + for (int rb = csirs_config_pdu->start_rb; rb < (csirs_config_pdu->start_rb+csirs_config_pdu->nr_of_rbs); rb++) { + + // for freq density 0.5 checks if even or odd RB + if(csirs_config_pdu->freq_density <= 1 && csirs_config_pdu->freq_density != (rb % 2)) { + continue; + } + + for (int cdm_id = 0; cdm_id < nr_csi_rs_info->N_cdm_groups; cdm_id++) { + for (int s = 0; s < nr_csi_rs_info->CDM_group_size; s++) { + + // loop over frequency resource elements within a group + for (int kp = 0; kp <= nr_csi_rs_info->kprime; kp++) { + + uint16_t k = (frame_parms->first_carrier_offset + (rb*NR_NB_SC_PER_RB)+nr_csi_rs_info->koverline[cdm_id] + kp) % frame_parms->ofdm_symbol_size; + + // loop over time resource elements within a group + for (int lp = 0; lp <= nr_csi_rs_info->lprime; lp++) { + uint16_t symb = lp + nr_csi_rs_info->loverline[cdm_id]; + uint64_t symbol_offset = symb*frame_parms->ofdm_symbol_size; + int16_t *rx_signal = (int16_t*)&rxdataF[ant_rx][symbol_offset]; + int16_t *rx_csi_rs_signal = (int16_t*)&csi_rs_received_signal[ant_rx][symbol_offset]; + rx_csi_rs_signal[k<<1] = rx_signal[k<<1]; + rx_csi_rs_signal[(k<<1)+1] = rx_signal[(k<<1)+1]; + +#ifdef NR_CSIRS_DEBUG + int dataF_offset = proc->nr_slot_rx*ue->frame_parms.samples_per_slot_wCP; + uint16_t port_tx = s+nr_csi_rs_info->j[cdm_id]*nr_csi_rs_info->CDM_group_size; + int16_t *tx_csi_rs_signal = (int16_t*)&nr_csi_rs_info->csi_rs_generated_signal[port_tx][symbol_offset+dataF_offset]; + LOG_I(NR_PHY, "l,k (%2d,%4d) |\tport_tx %d (%4d,%4d)\tant_rx %d (%4d,%4d)\n", + symb, + k, + port_tx+3000, + tx_csi_rs_signal[k<<1], + tx_csi_rs_signal[(k<<1)+1], + ant_rx, + rx_csi_rs_signal[k<<1], + rx_csi_rs_signal[(k<<1)+1]); +#endif + } + } + } + } + } + } + + return 0; +} + +uint32_t calc_power_csirs(uint16_t *x, fapi_nr_dl_config_csirs_pdu_rel15_t *csirs_config_pdu) { + uint64_t sum_x = 0; + uint64_t sum_x2 = 0; + uint16_t size = 0; + for (int rb = csirs_config_pdu->start_rb; rb < (csirs_config_pdu->start_rb+csirs_config_pdu->nr_of_rbs); rb++) { + if (csirs_config_pdu->freq_density <= 1 && csirs_config_pdu->freq_density != (rb % 2)) { + continue; + } + sum_x = sum_x + x[rb-csirs_config_pdu->start_rb]; + sum_x2 = sum_x2 + x[rb]*x[rb-csirs_config_pdu->start_rb]; + size++; + } + return sum_x2/size - (sum_x/size)*(sum_x/size); +} + +int nr_csi_rs_channel_estimation(PHY_VARS_NR_UE *ue, + UE_nr_rxtx_proc_t *proc, + fapi_nr_dl_config_csirs_pdu_rel15_t *csirs_config_pdu, + nr_csi_rs_info_t *nr_csi_rs_info, + int32_t **csi_rs_generated_signal, + int32_t **csi_rs_received_signal, + int32_t ***csi_rs_estimated_channel_freq, + uint32_t *noise_power) { + + NR_DL_FRAME_PARMS *frame_parms = &ue->frame_parms; + int dataF_offset = proc->nr_slot_rx*ue->frame_parms.samples_per_slot_wCP; + *noise_power = 0; + + for (int ant_rx = 0; ant_rx < frame_parms->nb_antennas_rx; ant_rx++) { + + /// LS channel estimation + + for(uint16_t port_tx = 0; port_txN_ports; port_tx++) { + memset(nr_csi_rs_info->csi_rs_ls_estimated_channel[ant_rx][port_tx], 0, frame_parms->ofdm_symbol_size*sizeof(int32_t)); + } + + for (int rb = csirs_config_pdu->start_rb; rb < (csirs_config_pdu->start_rb+csirs_config_pdu->nr_of_rbs); rb++) { + + // for freq density 0.5 checks if even or odd RB + if(csirs_config_pdu->freq_density <= 1 && csirs_config_pdu->freq_density != (rb % 2)) { + continue; + } + + for (int cdm_id = 0; cdm_id < nr_csi_rs_info->N_cdm_groups; cdm_id++) { + for (int s = 0; s < nr_csi_rs_info->CDM_group_size; s++) { + + uint16_t port_tx = s+nr_csi_rs_info->j[cdm_id]*nr_csi_rs_info->CDM_group_size; + + // loop over frequency resource elements within a group + for (int kp = 0; kp <= nr_csi_rs_info->kprime; kp++) { + + uint16_t kinit = (frame_parms->first_carrier_offset + rb*NR_NB_SC_PER_RB) % frame_parms->ofdm_symbol_size; + uint16_t k = kinit + nr_csi_rs_info->koverline[cdm_id] + kp; + + // loop over time resource elements within a group + for (int lp = 0; lp <= nr_csi_rs_info->lprime; lp++) { + uint16_t symb = lp + nr_csi_rs_info->loverline[cdm_id]; + uint64_t symbol_offset = symb*frame_parms->ofdm_symbol_size; + int16_t *tx_csi_rs_signal = (int16_t*)&csi_rs_generated_signal[port_tx][symbol_offset+dataF_offset]; + int16_t *rx_csi_rs_signal = (int16_t*)&csi_rs_received_signal[ant_rx][symbol_offset]; + int16_t *csi_rs_ls_estimated_channel = (int16_t*)&nr_csi_rs_info->csi_rs_ls_estimated_channel[ant_rx][port_tx][0]; + + int16_t csi_rs_ls_estimated_channel_re = (int16_t)(((int32_t)tx_csi_rs_signal[k<<1]*rx_csi_rs_signal[k<<1] + (int32_t)tx_csi_rs_signal[(k<<1)+1]*rx_csi_rs_signal[(k<<1)+1])>>nr_csi_rs_info->csi_rs_generated_signal_bits); + int16_t csi_rs_ls_estimated_channel_im = (int16_t)(((int32_t)tx_csi_rs_signal[k<<1]*rx_csi_rs_signal[(k<<1)+1] - (int32_t)tx_csi_rs_signal[(k<<1)+1]*rx_csi_rs_signal[k<<1])>>nr_csi_rs_info->csi_rs_generated_signal_bits); + + // This is not just the LS estimation for each (k,l), but also the sum of the different contributions + // for the sake of optimizing the memory used. + csi_rs_ls_estimated_channel[kinit<<1] += csi_rs_ls_estimated_channel_re; + csi_rs_ls_estimated_channel[(kinit<<1)+1] += csi_rs_ls_estimated_channel_im; + } + } + } + } + } + +#ifdef NR_CSIRS_DEBUG + for(int symb = 0; symb < NR_SYMBOLS_PER_SLOT; symb++) { + if(!is_csi_rs_in_symbol(*csirs_config_pdu,symb)) { + continue; + } + for(int k = 0; kofdm_symbol_size; k++) { + LOG_I(NR_PHY, "l,k (%2d,%4d) | ", symb, k); + for(uint16_t port_tx = 0; port_txN_ports; port_tx++) { + uint64_t symbol_offset = symb*frame_parms->ofdm_symbol_size; + int16_t *tx_csi_rs_signal = (int16_t*)&csi_rs_generated_signal[port_tx][symbol_offset+dataF_offset]; + int16_t *rx_csi_rs_signal = (int16_t*)&csi_rs_received_signal[ant_rx][symbol_offset]; + int16_t *csi_rs_ls_estimated_channel = (int16_t*)&nr_csi_rs_info->csi_rs_ls_estimated_channel[ant_rx][port_tx][0]; + printf("port_tx %d --> ant_rx %d, tx (%4d,%4d), rx (%4d,%4d), ls (%4d,%4d) | ", + port_tx+3000, ant_rx, + tx_csi_rs_signal[k<<1], tx_csi_rs_signal[(k<<1)+1], + rx_csi_rs_signal[k<<1], rx_csi_rs_signal[(k<<1)+1], + csi_rs_ls_estimated_channel[k<<1], csi_rs_ls_estimated_channel[(k<<1)+1]); + } + printf("\n"); + } + } +#endif + + /// Channel interpolation + + for(uint16_t port_tx = 0; port_txN_ports; port_tx++) { + memset(csi_rs_estimated_channel_freq[ant_rx][port_tx], 0, frame_parms->ofdm_symbol_size*sizeof(int32_t)); + } + + for (int rb = csirs_config_pdu->start_rb; rb < (csirs_config_pdu->start_rb+csirs_config_pdu->nr_of_rbs); rb++) { + + // for freq density 0.5 checks if even or odd RB + if(csirs_config_pdu->freq_density <= 1 && csirs_config_pdu->freq_density != (rb % 2)) { + continue; + } + + uint16_t k = (frame_parms->first_carrier_offset + rb*NR_NB_SC_PER_RB) % frame_parms->ofdm_symbol_size; + for(uint16_t port_tx = 0; port_txN_ports; port_tx++) { + int16_t *csi_rs_ls_estimated_channel = (int16_t*)&nr_csi_rs_info->csi_rs_ls_estimated_channel[ant_rx][port_tx][k]; + int16_t *csi_rs_estimated_channel16 = (int16_t *)&csi_rs_estimated_channel_freq[ant_rx][port_tx][k]; + if( (k == 0) || (k == frame_parms->first_carrier_offset) ) { // Start of OFDM symbol case or first occupied subcarrier case + multadd_real_vector_complex_scalar(filt24_start, csi_rs_ls_estimated_channel, csi_rs_estimated_channel16, 24); + } else if( ( (k + NR_NB_SC_PER_RB) >= frame_parms->ofdm_symbol_size) || + (rb == (csirs_config_pdu->start_rb+csirs_config_pdu->nr_of_rbs-1)) ) { // End of OFDM symbol case or Last occupied subcarrier case + multadd_real_vector_complex_scalar(filt24_end, csi_rs_ls_estimated_channel, csi_rs_estimated_channel16 - 3*sizeof(uint64_t), 24); + } else { // Middle case + multadd_real_vector_complex_scalar(filt24_middle, csi_rs_ls_estimated_channel, csi_rs_estimated_channel16 - 3*sizeof(uint64_t), 24); + } + } + } + + /// Power noise estimation + uint16_t noise_real[frame_parms->nb_antennas_rx][nr_csi_rs_info->N_ports][csirs_config_pdu->nr_of_rbs]; + uint16_t noise_imag[frame_parms->nb_antennas_rx][nr_csi_rs_info->N_ports][csirs_config_pdu->nr_of_rbs]; + for (int rb = csirs_config_pdu->start_rb; rb < (csirs_config_pdu->start_rb+csirs_config_pdu->nr_of_rbs); rb++) { + if (csirs_config_pdu->freq_density <= 1 && csirs_config_pdu->freq_density != (rb % 2)) { + continue; + } + uint16_t k = (frame_parms->first_carrier_offset + rb*NR_NB_SC_PER_RB) % frame_parms->ofdm_symbol_size; + for(uint16_t port_tx = 0; port_txN_ports; port_tx++) { + int16_t *csi_rs_ls_estimated_channel = (int16_t*)&nr_csi_rs_info->csi_rs_ls_estimated_channel[ant_rx][port_tx][k]; + int16_t *csi_rs_estimated_channel16 = (int16_t *)&csi_rs_estimated_channel_freq[ant_rx][port_tx][k]; + noise_real[ant_rx][port_tx][rb-csirs_config_pdu->start_rb] = abs(csi_rs_ls_estimated_channel[0]-csi_rs_estimated_channel16[0]); + noise_imag[ant_rx][port_tx][rb-csirs_config_pdu->start_rb] = abs(csi_rs_ls_estimated_channel[1]-csi_rs_estimated_channel16[1]); + } + } + for(uint16_t port_tx = 0; port_txN_ports; port_tx++) { + *noise_power += (calc_power_csirs(noise_real[ant_rx][port_tx], csirs_config_pdu) + calc_power_csirs(noise_imag[ant_rx][port_tx],csirs_config_pdu)); + } + +#ifdef NR_CSIRS_DEBUG + for(int k = 0; kofdm_symbol_size; k++) { + int rb = k >= frame_parms->first_carrier_offset ? + (k - frame_parms->first_carrier_offset)/NR_NB_SC_PER_RB : + (k + frame_parms->ofdm_symbol_size - frame_parms->first_carrier_offset)/NR_NB_SC_PER_RB; + LOG_I(NR_PHY, "(k = %4d) |\t", k); + for(uint16_t port_tx = 0; port_txN_ports; port_tx++) { + int16_t *csi_rs_ls_estimated_channel = (int16_t*)&nr_csi_rs_info->csi_rs_ls_estimated_channel[ant_rx][port_tx][0]; + int16_t *csi_rs_estimated_channel16 = (int16_t *)&csi_rs_estimated_channel_freq[ant_rx][port_tx][0]; + printf("Channel port_tx %d --> ant_rx %d : ls (%4d,%4d), int (%4d,%4d), noise (%4d,%4d) | ", + port_tx+3000, ant_rx, + csi_rs_ls_estimated_channel[k<<1], csi_rs_ls_estimated_channel[(k<<1)+1], + csi_rs_estimated_channel16[k<<1], csi_rs_estimated_channel16[(k<<1)+1], + rb >= csirs_config_pdu->start_rb+csirs_config_pdu->nr_of_rbs ? 0 : noise_real[ant_rx][port_tx][rb-csirs_config_pdu->start_rb], + rb >= csirs_config_pdu->start_rb+csirs_config_pdu->nr_of_rbs ? 0 : noise_imag[ant_rx][port_tx][rb-csirs_config_pdu->start_rb]); + } + printf("\n"); + } +#endif + + } + + *noise_power /= (frame_parms->nb_antennas_rx*nr_csi_rs_info->N_ports); + +#ifdef NR_CSIRS_DEBUG + LOG_I(NR_PHY, "Noise power estimation based on CSI-RS: %i\n", *noise_power); +#endif + + return 0; +} + +int nr_ue_csi_im_procedures(PHY_VARS_NR_UE *ue, UE_nr_rxtx_proc_t *proc, uint8_t gNB_id) { + return 0; +} + +int nr_ue_csi_rs_procedures(PHY_VARS_NR_UE *ue, UE_nr_rxtx_proc_t *proc, uint8_t gNB_id) { + + if(!ue->csirs_vars[gNB_id]->active) { + return -1; + } + + fapi_nr_dl_config_csirs_pdu_rel15_t *csirs_config_pdu = (fapi_nr_dl_config_csirs_pdu_rel15_t*)&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); + LOG_I(NR_PHY, "csirs_config_pdu->start_rb = %i\n", csirs_config_pdu->start_rb); + LOG_I(NR_PHY, "csirs_config_pdu->nr_of_rbs = %i\n", csirs_config_pdu->nr_of_rbs); + LOG_I(NR_PHY, "csirs_config_pdu->csi_type = %i (0:TRS, 1:CSI-RS NZP, 2:CSI-RS ZP)\n", csirs_config_pdu->csi_type); + LOG_I(NR_PHY, "csirs_config_pdu->row = %i\n", csirs_config_pdu->row); + LOG_I(NR_PHY, "csirs_config_pdu->freq_domain = %i\n", csirs_config_pdu->freq_domain); + LOG_I(NR_PHY, "csirs_config_pdu->symb_l0 = %i\n", csirs_config_pdu->symb_l0); + LOG_I(NR_PHY, "csirs_config_pdu->symb_l1 = %i\n", csirs_config_pdu->symb_l1); + LOG_I(NR_PHY, "csirs_config_pdu->cdm_type = %i\n", csirs_config_pdu->cdm_type); + LOG_I(NR_PHY, "csirs_config_pdu->freq_density = %i (0: dot5 (even RB), 1: dot5 (odd RB), 2: one, 3: three)\n", csirs_config_pdu->freq_density); + LOG_I(NR_PHY, "csirs_config_pdu->scramb_id = %i\n", csirs_config_pdu->scramb_id); + LOG_I(NR_PHY, "csirs_config_pdu->power_control_offset = %i\n", csirs_config_pdu->power_control_offset); + LOG_I(NR_PHY, "csirs_config_pdu->power_control_offset_ss = %i\n", csirs_config_pdu->power_control_offset_ss); +#endif + + nr_generate_csi_rs(ue->frame_parms, + ue->nr_csi_rs_info->csi_rs_generated_signal, + AMP, + ue->nr_csi_rs_info, + (nfapi_nr_dl_tti_csi_rs_pdu_rel15_t *) csirs_config_pdu, + proc->nr_slot_rx); + + nr_get_csi_rs_signal(ue, + proc, + csirs_config_pdu, + ue->nr_csi_rs_info, + ue->nr_csi_rs_info->csi_rs_received_signal); + + nr_csi_rs_channel_estimation(ue, + proc, + csirs_config_pdu, + ue->nr_csi_rs_info, + ue->nr_csi_rs_info->csi_rs_generated_signal, + ue->nr_csi_rs_info->csi_rs_received_signal, + ue->nr_csi_rs_info->csi_rs_estimated_channel_freq, + ue->nr_csi_rs_info->noise_power); + return 0; +} diff --git a/openair1/PHY/NR_UE_TRANSPORT/dci_nr.c b/openair1/PHY/NR_UE_TRANSPORT/dci_nr.c index 5e18f6cc6d..45eadd2c95 100644 --- a/openair1/PHY/NR_UE_TRANSPORT/dci_nr.c +++ b/openair1/PHY/NR_UE_TRANSPORT/dci_nr.c @@ -42,6 +42,7 @@ #include "PHY/CODING/coding_extern.h" #include "PHY/sse_intrin.h" #include "common/utils/nr/nr_common.h" +#include #include "assertions.h" #include "T.h" @@ -61,12 +62,8 @@ char nr_dci_format_string[8][30] = { //#define NR_LTE_PDCCH_DCI_SWITCH //#define NR_PDCCH_DCI_DEBUG // activates NR_PDCCH_DCI_DEBUG logs #ifdef NR_PDCCH_DCI_DEBUG -#define LOG_DNL(a, ...) printf("\n\t\t<-NR_PDCCH_DCI_DEBUG (%s)-> " a, __func__, ##__VA_ARGS__ ) -#define LOG_DD(a, ...) printf("\t<-NR_PDCCH_DCI_DEBUG (%s)-> " a, __func__, ##__VA_ARGS__ ) -#define LOG_DDD(a, ...) printf("\t\t<-NR_PDCCH_DCI_DEBUG (%s)-> " a, __func__, ##__VA_ARGS__ ) +#define LOG_DDD(a, ...) printf("<-NR_PDCCH_DCI_DEBUG (%s)-> " a, __func__, ##__VA_ARGS__ ) #else -#define LOG_DNL(a...) -#define LOG_DD(a...) #define LOG_DDD(a...) #endif #define NR_NBR_CORESET_ACT_BWP 3 // The number of CoreSets per BWP is limited to 3 (including initial CORESET: ControlResourceId 0) @@ -83,8 +80,8 @@ char nr_dci_format_string[8][30] = { //static const int16_t conjugate[8]__attribute__((aligned(32))) = {-1,1,-1,1,-1,1,-1,1}; -void nr_pdcch_demapping_deinterleaving(uint32_t *llr, - uint32_t *z, +static void nr_pdcch_demapping_deinterleaving(uint32_t *llr, + uint32_t *e_rx, uint8_t coreset_time_dur, uint8_t start_symbol, uint32_t coreset_nbr_rb, @@ -145,7 +142,8 @@ void nr_pdcch_demapping_deinterleaving(uint32_t *llr, int B_rb = reg_bundle_size_L/coreset_time_dur; // nb of RBs occupied by each REG bundle int num_bundles_per_cce = 6/reg_bundle_size_L; - int max_bundles = NR_MAX_PDCCH_AGG_LEVEL*num_bundles_per_cce; + int n_cce = N_regs/6; + int max_bundles = n_cce*num_bundles_per_cce; int f_bundle_j_list[max_bundles]; // for each bundle @@ -190,10 +188,10 @@ void nr_pdcch_demapping_deinterleaving(uint32_t *llr, index_z = data_sc * rb_count; index_llr = (uint16_t) (f*B_rb + rb + symbol_idx * coreset_nbr_rb) * data_sc; for (int i = 0; i < data_sc; i++) { - z[index_z + i] = llr[index_llr + i]; + e_rx[index_z + i] = llr[index_llr + i]; #ifdef NR_PDCCH_DCI_DEBUG LOG_I(PHY,"[candidate=%d,symbol_idx=%d,cce=%d,REG bundle=%d,PRB=%d] z[%d]=(%d,%d) <-> \t llr[%d]=(%d,%d) \n", - c_id,symbol_idx,cce_count,k,f*B_rb + rb,(index_z + i),*(int16_t *) &z[index_z + i],*(1 + (int16_t *) &z[index_z + i]), + c_id,symbol_idx,cce_count,k,f*B_rb + rb,(index_z + i),*(int16_t *) &e_rx[index_z + i],*(1 + (int16_t *) &e_rx[index_z + i]), (index_llr + i),*(int16_t *) &llr[index_llr + i], *(1 + (int16_t *) &llr[index_llr + i])); #endif } @@ -205,7 +203,7 @@ void nr_pdcch_demapping_deinterleaving(uint32_t *llr, } } -int32_t nr_pdcch_llr(NR_DL_FRAME_PARMS *frame_parms, int32_t **rxdataF_comp, +int32_t nr_pdcch_llr(NR_DL_FRAME_PARMS *frame_parms, int32_t rx_size, int32_t rxdataF_comp[][rx_size], int16_t *pdcch_llr, uint8_t symbol,uint32_t coreset_nbr_rb) { int16_t *rxF = (int16_t *) &rxdataF_comp[0][(symbol * coreset_nbr_rb * 12)]; int32_t i; @@ -274,7 +272,8 @@ int32_t pdcch_llr(NR_DL_FRAME_PARMS *frame_parms, //__m128i avg128P; //compute average channel_level on each (TX,RX) antenna pair -void nr_pdcch_channel_level(int32_t **dl_ch_estimates_ext, +void nr_pdcch_channel_level(int32_t rx_size, + int32_t dl_ch_estimates_ext[][rx_size], NR_DL_FRAME_PARMS *frame_parms, int32_t *avg, int symbol, @@ -341,9 +340,11 @@ void nr_pdcch_channel_level(int32_t **dl_ch_estimates_ext, // This function will extract the mapped DM-RS PDCCH REs as per 38.211 Section 7.4.1.3.2 (Mapping to physical resources) void nr_pdcch_extract_rbs_single(int32_t **rxdataF, - int32_t **dl_ch_estimates, - int32_t **rxdataF_ext, - int32_t **dl_ch_estimates_ext, + int32_t est_size, + int32_t dl_ch_estimates[][est_size], + int32_t rx_size, + int32_t rxdataF_ext[][rx_size], + int32_t dl_ch_estimates_ext[][rx_size], uint8_t symbol, NR_DL_FRAME_PARMS *frame_parms, uint8_t *coreset_freq_dom, @@ -359,10 +360,7 @@ void nr_pdcch_extract_rbs_single(int32_t **rxdataF, * According to this equations, DM-RS PDCCH are mapped on k where k%12==1 || k%12==5 || k%12==9 * */ - // the bitmap coreset_frq_domain contains 45 bits -#define CORESET_FREQ_DOMAIN_BITMAP_SIZE 45 - // each bit is associated to 6 RBs -#define BIT_TO_NBR_RB_CORESET_FREQ_DOMAIN 6 + #define NBR_RE_PER_RB_WITH_DMRS 12 // after removing the 3 DMRS RE, the RB contains 9 RE with PDCCH #define NBR_RE_PER_RB_WITHOUT_DMRS 9 @@ -371,11 +369,6 @@ void nr_pdcch_extract_rbs_single(int32_t **rxdataF, uint8_t i, j, aarx; int32_t *dl_ch0, *dl_ch0_ext, *rxF, *rxF_ext; -#ifdef DEBUG_DCI_DECODING - uint8_t symbol_mod = (symbol >= (7 - frame_parms->Ncp)) ? symbol - (7 - frame_parms->Ncp) : symbol; - LOG_I(PHY, "extract_rbs_single: symbol_mod %d\n",symbol_mod); -#endif - for (aarx = 0; aarx < frame_parms->nb_antennas_rx; aarx++) { dl_ch0 = &dl_ch_estimates[aarx][frame_parms->ofdm_symbol_size*symbol]; LOG_DDD("dl_ch0 = &dl_ch_estimates[aarx = (%d)][0]\n",aarx); @@ -397,9 +390,9 @@ void nr_pdcch_extract_rbs_single(int32_t **rxdataF, * 1.2 The RB is >= than the N_RB_DL/2 -> IQ symbols are in the first half of the rxdataF (from element 0) * 2. Number of RBs in the system bandwidth is odd * (particular case when the RB with DC as it is treated differently: it is situated in symbol borders of rxdataF) - * 2.1 The RB is <= than the N_RB_DL/2 -> IQ symbols are in the second half of the rxdataF (from first_carrier_offset) - * 2.2 The RB is > than the N_RB_DL/2+1 -> IQ symbols are in the first half of the rxdataF (from element 0 + 2nd half RB containing DC) - * 2.3 The RB is == N_RB_DL/2+1 -> IQ symbols are in the lower border of the rxdataF for first 6 IQ element and the upper border of the rxdataF for the last 6 IQ elements + * 2.1 The RB is < than the N_RB_DL/2 -> IQ symbols are in the second half of the rxdataF (from first_carrier_offset) + * 2.2 The RB is > than the N_RB_DL/2 -> IQ symbols are in the first half of the rxdataF (from element 0 + 2nd half RB containing DC) + * 2.3 The RB is == N_RB_DL/2 -> IQ symbols are in the upper border of the rxdataF for first 6 IQ element and the lower border of the rxdataF for the last 6 IQ elements * If the first RB containing PDCCH within the UE BWP and within the CORESET is higher than half of the system bandwidth (N_RB_DL), * then the IQ symbol is going to be found at the position 0+c_rb-N_RB_DL/2 in rxdataF and * we have to point the pointer at (1+c_rb-N_RB_DL/2) in rxdataF @@ -429,64 +422,65 @@ void nr_pdcch_extract_rbs_single(int32_t **rxdataF, if (((c_rb + n_BWP_start) >= (frame_parms->N_RB_DL >> 1)) && ((frame_parms->N_RB_DL & 1) == 0)) { // number of RBs is even and c_rb is higher than half system bandwidth (we don't skip DC) // if these conditions are true the pointer has to be situated at the 1st part of the rxdataF - rxF = &rxdataF[aarx][(12*(c_rb - (frame_parms->N_RB_DL>>1)) + (symbol * (frame_parms->ofdm_symbol_size)))+n_BWP_start*12]; // we point at the 1st part of the rxdataF in symbol - LOG_DDD("in even case c_rb (%d) is higher than half N_RB_DL (not DC) -> rxF = &rxdataF[aarx = (%d)][(12*(c_rb - (frame_parms->N_RB_DL>>1)) + (symbol * (frame_parms->ofdm_symbol_size))) = (%d)]\n", - c_rb,aarx,(12*(c_rb - (frame_parms->N_RB_DL>>1)) + (symbol * (frame_parms->ofdm_symbol_size)))); - //rxF = &rxdataF[aarx][(1 + 12*(c_rb - (frame_parms->N_RB_DL>>1)) + (symbol * (frame_parms->ofdm_symbol_size)))]; // we point at the 1st part of the rxdataF in symbol - //#ifdef NR_PDCCH_DCI_DEBUG - // LOG_DDD("in even case c_rb (%d) is higher than half N_RB_DL (not DC) -> rxF = &rxdataF[aarx = (%d)][(1 + 12*(c_rb - (frame_parms->N_RB_DL>>1)) + (symbol * (frame_parms->ofdm_symbol_size))) = (%d)]\n", - // c_rb,aarx,(1 + 12*(c_rb - (frame_parms->N_RB_DL>>1)) + (symbol * (frame_parms->ofdm_symbol_size)))); - //#endif + rxF = &rxdataF[aarx][12*(c_rb + n_BWP_start - (frame_parms->N_RB_DL>>1)) + symbol * frame_parms->ofdm_symbol_size]; // we point at the 1st part of the rxdataF in symbol + LOG_DDD("in even case c_rb (%d) is higher than half N_RB_DL (not DC) -> rxF = &rxdataF[aarx = (%d)][12*(c_rb + n_BWP_start - (frame_parms->N_RB_DL>>1)) + symbol * frame_parms->ofdm_symbol_size = (%d)]\n", + c_rb,aarx,(12*(c_rb + n_BWP_start - (frame_parms->N_RB_DL>>1)) + symbol * frame_parms->ofdm_symbol_size)); } if (((c_rb + n_BWP_start) < (frame_parms->N_RB_DL >> 1)) && ((frame_parms->N_RB_DL & 1) != 0)) { //if RB to be treated is lower than middle system bandwidth then rxdataF pointed at (offset + c_br + symbol * ofdm_symbol_size): odd case - rxF = &rxdataF[aarx][(frame_parms->first_carrier_offset + 12 * c_rb + (symbol * (frame_parms->ofdm_symbol_size)))+n_BWP_start*12]; -#ifdef NR_PDCCH_DCI_DEBUG - LOG_D(PHY,"in odd case c_rb (%d) is lower or equal than half N_RB_DL -> rxF = &rxdataF[aarx = (%d)][(frame_parms->first_carrier_offset + 12 * c_rb + (symbol * (frame_parms->ofdm_symbol_size))) = (%d)]\n", - c_rb,aarx,(frame_parms->first_carrier_offset + 12 * c_rb + (symbol * (frame_parms->ofdm_symbol_size)))); -#endif + rxF = &rxdataF[aarx][frame_parms->first_carrier_offset + 12 * (c_rb + n_BWP_start) + symbol * frame_parms->ofdm_symbol_size]; + LOG_DDD("in odd case c_rb (%d) is lower or equal than half N_RB_DL -> rxF = &rxdataF[aarx = (%d)][frame_parms->first_carrier_offset + 12 * (c_rb + n_BWP_start) + symbol * frame_parms->ofdm_symbol_size = (%d)]\n", + c_rb,aarx,(frame_parms->first_carrier_offset + 12 * (c_rb + n_BWP_start) + symbol * frame_parms->ofdm_symbol_size)); } if (((c_rb + n_BWP_start) > (frame_parms->N_RB_DL >> 1)) && ((frame_parms->N_RB_DL & 1) != 0)) { // number of RBs is odd and c_rb is higher than half system bandwidth + 1 // if these conditions are true the pointer has to be situated at the 1st part of the rxdataF just after the first IQ symbols of the RB containing DC - rxF = &rxdataF[aarx][(12*(c_rb - (frame_parms->N_RB_DL>>1)) - 6 + (symbol * (frame_parms->ofdm_symbol_size)))+n_BWP_start*12]; // we point at the 1st part of the rxdataF in symbol -#ifdef NR_PDCCH_DCI_DEBUG - LOG_D(PHY,"in odd case c_rb (%d) is higher than half N_RB_DL (not DC) -> rxF = &rxdataF[aarx = (%d)][(12*(c_rb - frame_parms->N_RB_DL) - 5 + (symbol * (frame_parms->ofdm_symbol_size))) = (%d)]\n", - c_rb,aarx,(12*(c_rb - (frame_parms->N_RB_DL>>1)) - 6 + (symbol * (frame_parms->ofdm_symbol_size)))); -#endif + rxF = &rxdataF[aarx][12*(c_rb + n_BWP_start - (frame_parms->N_RB_DL>>1)) - 6 + symbol * frame_parms->ofdm_symbol_size]; // we point at the 1st part of the rxdataF in symbol + LOG_DDD("in odd case c_rb (%d) is higher than half N_RB_DL (not DC) -> rxF = &rxdataF[aarx = (%d)][12*(c_rb + n_BWP_start - (frame_parms->N_RB_DL>>1)) - 6 + symbol * frame_parms->ofdm_symbol_size = (%d)]\n", + c_rb,aarx,(12*(c_rb + n_BWP_start - (frame_parms->N_RB_DL>>1)) - 6 + symbol * frame_parms->ofdm_symbol_size)); } if (((c_rb + n_BWP_start) == (frame_parms->N_RB_DL >> 1)) && ((frame_parms->N_RB_DL & 1) != 0)) { // treatment of RB containing the DC // if odd number RBs in system bandwidth and first RB to be treated is higher than middle system bandwidth (around DC) // we have to treat the RB in two parts: first part from i=0 to 5, the data is at the end of rxdataF (pointing at the end of the table) - rxF = &rxdataF[aarx][(frame_parms->first_carrier_offset + 12 * c_rb + (symbol * (frame_parms->ofdm_symbol_size)))+n_BWP_start*12]; -#ifdef NR_PDCCH_DCI_DEBUG - LOG_D(PHY,"in odd case c_rb (%d) is half N_RB_DL + 1 we treat DC case -> rxF = &rxdataF[aarx = (%d)][(frame_parms->first_carrier_offset + 12 * c_rb + (symbol * (frame_parms->ofdm_symbol_size))) = (%d)]\n", - c_rb,aarx,(frame_parms->first_carrier_offset + 12 * c_rb + (symbol * (frame_parms->ofdm_symbol_size)))); -#endif + rxF = &rxdataF[aarx][frame_parms->first_carrier_offset + 12 * (c_rb + n_BWP_start) + symbol * frame_parms->ofdm_symbol_size]; + LOG_DDD("in odd case c_rb (%d) is half N_RB_DL + 1 we treat DC case -> rxF = &rxdataF[aarx = (%d)][frame_parms->first_carrier_offset + 12 * (c_rb + n_BWP_start) + symbol * frame_parms->ofdm_symbol_size = (%d)]\n", + c_rb,aarx,(frame_parms->first_carrier_offset + 12 * (c_rb + n_BWP_start) + symbol * frame_parms->ofdm_symbol_size)); j = 0; for (i = 0; i < 6; i++) { //treating first part of the RB note that i=5 would correspond to DC. We treat it in NR if ((i != 1) && (i != 5)) { dl_ch0_ext[j] = dl_ch0[i]; - rxF_ext[j++] = rxF[i]; - // printf("**extract rb %d, re %d => (%d,%d)\n",rb,i,*(short *)&rxF_ext[j-1],*(1+(short*)&rxF_ext[j-1])); + rxF_ext[j] = rxF[i]; + LOG_DDD("RB[c_rb %d] \t RE[re %d] => rxF_ext[%d]=(%d,%d)\t rxF[%d]=(%d,%d)\n", + c_rb, i, j, *(short *) &rxF_ext[j],*(1 + (short *) &rxF_ext[j]), i, + *(short *) &rxF[i], *(1 + (short *) &rxF[i])); + j++; + } else { + LOG_DDD("RB[c_rb %d] \t RE[re %d] => rxF_ext[%d]=(%d,%d)\t rxF[%d]=(%d,%d) \t\t <==> DM-RS PDCCH, this is a pilot symbol\n", + c_rb, i, j, *(short *) &rxF_ext[j], *(1 + (short *) &rxF_ext[j]), i, + *(short *) &rxF[i], *(1 + (short *) &rxF[i])); } } // then we point at the begining of the symbol part of rxdataF do process second part of RB - rxF = &rxdataF[aarx][((symbol * (frame_parms->ofdm_symbol_size)))]; // we point at the 1st part of the rxdataF in symbol -#ifdef NR_PDCCH_DCI_DEBUG - LOG_D(PHY,"in odd case c_rb (%d) is half N_RB_DL +1 we treat DC case -> rxF = &rxdataF[aarx = (%d)][(symbol * (frame_parms->ofdm_symbol_size)) = (%d)]\n", - c_rb,aarx,(symbol * (frame_parms->ofdm_symbol_size))); -#endif + rxF = &rxdataF[aarx][symbol * frame_parms->ofdm_symbol_size]; // we point at the 1st part of the rxdataF in symbol + LOG_DDD("in odd case c_rb (%d) is half N_RB_DL +1 we treat DC case -> rxF = &rxdataF[aarx = (%d)][symbol * frame_parms->ofdm_symbol_size = (%d)]\n", + c_rb,aarx,(symbol * frame_parms->ofdm_symbol_size)); for (; i < 12; i++) { if ((i != 9)) { dl_ch0_ext[j] = dl_ch0[i]; - rxF_ext[j++] = rxF[(1 + i - 6)]; - // printf("**extract rb %d, re %d => (%d,%d)\n",rb,i,*(short *)&rxF_ext[j-1],*(1+(short*)&rxF_ext[j-1])); + rxF_ext[j] = rxF[i - 6]; + LOG_DDD("RB[c_rb %d] \t RE[re %d] => rxF_ext[%d]=(%d,%d)\t rxF[%d]=(%d,%d)\n", + c_rb, i, j, *(short *) &rxF_ext[j],*(1 + (short *) &rxF_ext[j]), i, + *(short *) &rxF[i-6], *(1 + (short *) &rxF[i-6])); + j++; + } else { + LOG_DDD("RB[c_rb %d] \t RE[re %d] => rxF_ext[%d]=(%d,%d)\t rxF[%d]=(%d,%d) \t\t <==> DM-RS PDCCH, this is a pilot symbol\n", + c_rb, i, j, *(short *) &rxF_ext[j], *(1 + (short *) &rxF_ext[j]), i, + *(short *) &rxF[i-6], *(1 + (short *) &rxF[i-6])); } } @@ -494,32 +488,21 @@ void nr_pdcch_extract_rbs_single(int32_t **rxdataF, dl_ch0_ext += NBR_RE_PER_RB_WITHOUT_DMRS; rxF_ext += NBR_RE_PER_RB_WITHOUT_DMRS; dl_ch0 += 12; - //rxF += 7; - //c_rb++; - //n_BWP_start++; // We have to increment this variable here to be consequent in the for loop afterwards - //} } else { // treatment of any RB that does not contain the DC j = 0; for (i = 0; i < 12; i++) { if ((i != 1) && (i != 5) && (i != 9)) { rxF_ext[j] = rxF[i]; -#ifdef NR_PDCCH_DCI_DEBUG - LOG_D(PHY,"RB[c_rb %d] \t RE[re %d] => rxF_ext[%d]=(%d,%d)\t rxF[%d]=(%d,%d)\n", + LOG_DDD("RB[c_rb %d] \t RE[re %d] => rxF_ext[%d]=(%d,%d)\t rxF[%d]=(%d,%d)\n", c_rb, i, j, *(short *) &rxF_ext[j],*(1 + (short *) &rxF_ext[j]), i, *(short *) &rxF[i], *(1 + (short *) &rxF[i])); -#endif dl_ch0_ext[j] = dl_ch0[i]; - - //LOG_DDD("ch %d => dl_ch0(%d,%d)\n", i, *(short *) &dl_ch0[i], *(1 + (short*) &dl_ch0[i])); - //printf("\t-> dl_ch0[%d] => dl_ch0_ext[%d](%d,%d)\n", i,j, *(short *) &dl_ch0[i], *(1 + (short*) &dl_ch0[i])); j++; } else { -#ifdef NR_PDCCH_DCI_DEBUG - LOG_D(PHY,"RB[c_rb %d] \t RE[re %d] => rxF_ext[%d]=(%d,%d)\t rxF[%d]=(%d,%d) \t\t <==> DM-RS PDCCH, this is a pilot symbol\n", + LOG_DDD("RB[c_rb %d] \t RE[re %d] => rxF_ext[%d]=(%d,%d)\t rxF[%d]=(%d,%d) \t\t <==> DM-RS PDCCH, this is a pilot symbol\n", c_rb, i, j, *(short *) &rxF_ext[j], *(1 + (short *) &rxF_ext[j]), i, *(short *) &rxF[i], *(1 + (short *) &rxF[i])); -#endif } } @@ -527,8 +510,6 @@ void nr_pdcch_extract_rbs_single(int32_t **rxdataF, dl_ch0_ext += NBR_RE_PER_RB_WITHOUT_DMRS; rxF_ext += NBR_RE_PER_RB_WITHOUT_DMRS; dl_ch0 += 12; - //rxF += 12; - //} } } } @@ -536,9 +517,9 @@ void nr_pdcch_extract_rbs_single(int32_t **rxdataF, #define print_shorts(s,x) printf("%s %d,%d,%d,%d,%d,%d,%d,%d\n",s,(x)[0],(x)[1],(x)[2],(x)[3],(x)[4],(x)[5],(x)[6],(x)[7]) -void nr_pdcch_channel_compensation(int32_t **rxdataF_ext, - int32_t **dl_ch_estimates_ext, - int32_t **rxdataF_comp, +void nr_pdcch_channel_compensation(int32_t rx_size, int32_t rxdataF_ext[][rx_size], + int32_t dl_ch_estimates_ext[][rx_size], + int32_t rxdataF_comp[][rx_size], int32_t **rho, NR_DL_FRAME_PARMS *frame_parms, uint8_t symbol, @@ -649,7 +630,8 @@ void nr_pdcch_channel_compensation(int32_t **rxdataF_ext, void nr_pdcch_detection_mrc(NR_DL_FRAME_PARMS *frame_parms, - int32_t **rxdataF_comp, + int32_t rx_size, + int32_t rxdataF_comp[][rx_size], uint8_t symbol) { #if defined(__x86_64__) || defined(__i386__) __m128i *rxdataF_comp128_0,*rxdataF_comp128_1; @@ -685,18 +667,31 @@ void nr_pdcch_detection_mrc(NR_DL_FRAME_PARMS *frame_parms, int32_t nr_rx_pdcch(PHY_VARS_NR_UE *ue, UE_nr_rxtx_proc_t *proc, + int32_t pdcch_est_size, + int32_t pdcch_dl_ch_estimates[][pdcch_est_size], + int16_t *pdcch_e_rx, fapi_nr_dl_config_dci_dl_pdu_rel15_t *rel15) { uint32_t frame = proc->frame_rx; uint32_t slot = proc->nr_slot_rx; NR_UE_COMMON *common_vars = &ue->common_vars; NR_DL_FRAME_PARMS *frame_parms = &ue->frame_parms; - NR_UE_PDCCH *pdcch_vars = ue->pdcch_vars[proc->thread_id][0]; uint8_t log2_maxh, aarx; int32_t avgs; int32_t avgP[4]; int n_rb,rb_offset; + + // Pointers to extracted PDCCH symbols in frequency-domain. + int32_t rx_size = 4*273*12; + __attribute__ ((aligned(32))) int32_t rxdataF_ext[4*frame_parms->nb_antennas_rx][rx_size]; + __attribute__ ((aligned(32))) int32_t rxdataF_comp[4*frame_parms->nb_antennas_rx][rx_size]; + __attribute__ ((aligned(32))) int32_t pdcch_dl_ch_estimates_ext[4*frame_parms->nb_antennas_rx][rx_size]; + + // Pointer to llrs, 4-bit resolution. + int32_t llr_size = 2*4*100*12; + int16_t llr[llr_size]; + get_coreset_rballoc(rel15->coreset.frequency_domain_resource,&n_rb,&rb_offset); LOG_D(PHY,"pdcch coreset: freq %x, n_rb %d, rb_offset %d\n", rel15->coreset.frequency_domain_resource[0],n_rb,rb_offset); @@ -704,9 +699,11 @@ int32_t nr_rx_pdcch(PHY_VARS_NR_UE *ue, LOG_D(PHY,"in nr_pdcch_extract_rbs_single(rxdataF -> rxdataF_ext || dl_ch_estimates -> dl_ch_estimates_ext)\n"); nr_pdcch_extract_rbs_single(common_vars->common_vars_rx_data_per_thread[proc->thread_id].rxdataF, - pdcch_vars->dl_ch_estimates, - pdcch_vars->rxdataF_ext, - pdcch_vars->dl_ch_estimates_ext, + pdcch_est_size, + pdcch_dl_ch_estimates, + rx_size, + rxdataF_ext, + pdcch_dl_ch_estimates_ext, s, frame_parms, rel15->coreset.frequency_domain_resource, @@ -716,7 +713,8 @@ int32_t nr_rx_pdcch(PHY_VARS_NR_UE *ue, LOG_D(PHY,"we enter nr_pdcch_channel_level(avgP=%d) => compute channel level based on ofdm symbol 0, pdcch_vars[eNB_id]->dl_ch_estimates_ext\n",*avgP); LOG_D(PHY,"in nr_pdcch_channel_level(dl_ch_estimates_ext -> dl_ch_estimates_ext)\n"); // compute channel level based on ofdm symbol 0 - nr_pdcch_channel_level(pdcch_vars->dl_ch_estimates_ext, + nr_pdcch_channel_level(rx_size, + pdcch_dl_ch_estimates_ext, frame_parms, avgP, s, @@ -738,26 +736,33 @@ int32_t nr_rx_pdcch(PHY_VARS_NR_UE *ue, LOG_D(PHY,"we enter nr_pdcch_channel_compensation(log2_maxh=%d)\n",log2_maxh); LOG_D(PHY,"in nr_pdcch_channel_compensation(rxdataF_ext x dl_ch_estimates_ext -> rxdataF_comp)\n"); // compute LLRs for ofdm symbol 0 only - nr_pdcch_channel_compensation(pdcch_vars->rxdataF_ext, - pdcch_vars->dl_ch_estimates_ext, - pdcch_vars->rxdataF_comp, + nr_pdcch_channel_compensation(rx_size, rxdataF_ext, + pdcch_dl_ch_estimates_ext, + rxdataF_comp, NULL, frame_parms, s, log2_maxh, n_rb); // log2_maxh+I0_shift + + UEscopeCopy(ue, pdcchRxdataF_comp, rxdataF_comp, sizeof(struct complex16), frame_parms->nb_antennas_rx, rx_size); + if (frame_parms->nb_antennas_rx > 1) { LOG_D(PHY,"we enter nr_pdcch_detection_mrc(frame_parms->nb_antennas_rx=%d)\n", frame_parms->nb_antennas_rx); - nr_pdcch_detection_mrc(frame_parms, pdcch_vars->rxdataF_comp,s); + nr_pdcch_detection_mrc(frame_parms, rx_size, rxdataF_comp,s); } LOG_D(PHY,"we enter nr_pdcch_llr(for symbol %d), pdcch_vars[eNB_id]->rxdataF_comp ---> pdcch_vars[eNB_id]->llr \n",s); LOG_D(PHY,"in nr_pdcch_llr(rxdataF_comp -> llr)\n"); nr_pdcch_llr(frame_parms, - pdcch_vars->rxdataF_comp, - pdcch_vars->llr, + rx_size, + rxdataF_comp, + llr, s, n_rb); + + UEscopeCopy(ue, pdcchLlr, llr, sizeof(int16_t), 1, llr_size); + #if T_TRACER // T(T_UE_PHY_PDCCH_IQ, T_INT(frame_parms->N_RB_DL), T_INT(frame_parms->N_RB_DL), @@ -771,8 +776,8 @@ int32_t nr_rx_pdcch(PHY_VARS_NR_UE *ue, } LOG_D(PHY,"we enter nr_pdcch_demapping_deinterleaving(), number of candidates %d\n",rel15->number_of_candidates); - nr_pdcch_demapping_deinterleaving((uint32_t *) pdcch_vars->llr, - (uint32_t *) pdcch_vars->e_rx, + nr_pdcch_demapping_deinterleaving((uint32_t *) llr, + (uint32_t *) pdcch_e_rx, rel15->coreset.duration, rel15->coreset.StartSymbolIndex, n_rb, @@ -783,7 +788,7 @@ int32_t nr_rx_pdcch(PHY_VARS_NR_UE *ue, rel15->CCE, rel15->L); - LOG_D(PHY,"we end nr_pdcch_unscrambling()\n"); + LOG_D(PHY,"we end nr_pdcch_demapping_deinterleaving()\n"); LOG_D(PHY,"Ending nr_rx_pdcch() function\n"); return (0); @@ -791,7 +796,7 @@ int32_t nr_rx_pdcch(PHY_VARS_NR_UE *ue, -void nr_pdcch_unscrambling(int16_t *z, +void nr_pdcch_unscrambling(int16_t *e_rx, uint16_t scrambling_RNTI, uint32_t length, uint16_t pdcch_DMRS_scrambling_id, @@ -814,8 +819,10 @@ void nr_pdcch_unscrambling(int16_t *z, reset = 0; } - if (((s >> (i % 32)) & 1) == 1) z2[i] = -z[i]; - else z2[i]=z[i]; + if (((s >> (i % 32)) & 1) == 1) + z2[i] = -e_rx[i]; + else + z2[i]=e_rx[i]; } } @@ -853,10 +860,10 @@ static uint16_t nr_dci_false_detection(uint64_t *dci, uint8_t nr_dci_decoding_procedure(PHY_VARS_NR_UE *ue, UE_nr_rxtx_proc_t *proc, + int16_t *pdcch_e_rx, fapi_nr_dci_indication_t *dci_ind, - fapi_nr_dl_config_dci_dl_pdu_rel15_t *rel15) { - - NR_UE_PDCCH *pdcch_vars = ue->pdcch_vars[proc->thread_id][0]; + fapi_nr_dl_config_dci_dl_pdu_rel15_t *rel15, + NR_UE_PDCCH_CONFIG *phy_pdcch_config) { //int gNB_id = 0; int16_t tmp_e[16*108]; @@ -868,6 +875,7 @@ uint8_t nr_dci_decoding_procedure(PHY_VARS_NR_UE *ue, int L = rel15->L[j]; // Loop over possible DCI lengths + for (int k = 0; k < rel15->num_dci_options; k++) { // skip this candidate if we've already found one with the // same rnti and format at a different aggregation level @@ -883,16 +891,17 @@ uint8_t nr_dci_decoding_procedure(PHY_VARS_NR_UE *ue, int dci_length = rel15->dci_length_options[k]; uint64_t dci_estimation[2]= {0}; - LOG_D(PHY, "Trying DCI candidate %d of %d number of candidates, CCE %d (%d), L %d, length %d, format %s\n", - j, rel15->number_of_candidates, CCEind, e_rx_cand_idx, L, dci_length,nr_dci_format_string[rel15->dci_format_options[k]]); + LOG_D(PHY, "(%i.%i) Trying DCI candidate %d of %d number of candidates, CCE %d (%d), L %d, length %d, format %s\n", + proc->frame_rx, proc->nr_slot_rx, j, rel15->number_of_candidates, CCEind, e_rx_cand_idx, L, dci_length, nr_dci_format_string[rel15->dci_format_options[k]]); - nr_pdcch_unscrambling(&pdcch_vars->e_rx[e_rx_cand_idx], rel15->coreset.scrambling_rnti, L*108, rel15->coreset.pdcch_dmrs_scrambling_id, tmp_e); + + nr_pdcch_unscrambling(&pdcch_e_rx[e_rx_cand_idx], rel15->coreset.scrambling_rnti, L*108, rel15->coreset.pdcch_dmrs_scrambling_id, tmp_e); #ifdef DEBUG_DCI_DECODING - uint32_t *z = (uint32_t *) &pdcch_vars->e_rx[e_rx_cand_idx]; + uint32_t *z = (uint32_t *) &e_rx[e_rx_cand_idx]; for (int index_z = 0; index_z < L*6; index_z++){ for (int i=0; i<9; i++) { - LOG_D(PHY,"z[%d]=(%d,%d) \n", (9*index_z + i), *(int16_t *) &z[index_z + i],*(1 + (int16_t *) &z[index_z + i])); + LOG_I(PHY,"z[%d]=(%d,%d) \n", (9*index_z + i), *(int16_t *) &z[9*index_z + i],*(1 + (int16_t *) &z[9*index_z + i])); } } #endif @@ -902,8 +911,8 @@ uint8_t nr_dci_decoding_procedure(PHY_VARS_NR_UE *ue, NR_POLAR_DCI_MESSAGE_TYPE, dci_length, L); n_rnti = rel15->rnti; - LOG_D(PHY, "(%i.%i) dci indication (rnti %x,dci format %s,n_CCE %d,payloadSize %d)\n", - proc->frame_rx, proc->nr_slot_rx,n_rnti,nr_dci_format_string[rel15->dci_format_options[k]],CCEind,dci_length); + LOG_D(PHY, "(%i.%i) dci indication (rnti %x,dci format %s,n_CCE %d,payloadSize %d,payload %llx )\n", + proc->frame_rx, proc->nr_slot_rx,n_rnti,nr_dci_format_string[rel15->dci_format_options[k]],CCEind,dci_length, *(unsigned long long*)dci_estimation); if (crc == n_rnti) { LOG_D(PHY, "(%i.%i) Received dci indication (rnti %x,dci format %s,n_CCE %d,payloadSize %d,payload %llx)\n", proc->frame_rx, proc->nr_slot_rx,n_rnti,nr_dci_format_string[rel15->dci_format_options[k]],CCEind,dci_length,*(unsigned long long*)dci_estimation); @@ -931,7 +940,7 @@ uint8_t nr_dci_decoding_procedure(PHY_VARS_NR_UE *ue, } e_rx_cand_idx += 9*L*6*2; //e_rx index for next candidate (L CCEs, 6 REGs per CCE and 9 REs per REG and 2 uint16_t per RE) } - pdcch_vars->nb_search_space = 0; + phy_pdcch_config->nb_search_space = 0; return(dci_ind->number_of_dcis); } diff --git a/openair1/PHY/NR_UE_TRANSPORT/nr_dlsch_decoding.c b/openair1/PHY/NR_UE_TRANSPORT/nr_dlsch_decoding.c index a9b8ce2e55..403f016e79 100644 --- a/openair1/PHY/NR_UE_TRANSPORT/nr_dlsch_decoding.c +++ b/openair1/PHY/NR_UE_TRANSPORT/nr_dlsch_decoding.c @@ -79,9 +79,11 @@ void init_dlsch_tpool(uint8_t num_dlsch_threads) { free(params); } + void free_nr_ue_dlsch(NR_UE_DLSCH_t **dlschptr, uint16_t N_RB_DL) { - int i,r; - uint16_t a_segments = MAX_NUM_NR_DLSCH_SEGMENTS; //number of segments to be allocated + + uint16_t a_segments = MAX_NUM_NR_DLSCH_SEGMENTS_PER_LAYER*NR_MAX_NB_LAYERS; + NR_UE_DLSCH_t *dlsch=*dlschptr; if (dlsch) { @@ -90,36 +92,21 @@ void free_nr_ue_dlsch(NR_UE_DLSCH_t **dlschptr, uint16_t N_RB_DL) { a_segments = a_segments/273 +1; } - for (i=0; iMdlharq; i++) { + for (int i=0; iMdlharq; i++) { if (dlsch->harq_processes[i]) { if (dlsch->harq_processes[i]->b) { free16(dlsch->harq_processes[i]->b,a_segments*1056); dlsch->harq_processes[i]->b = NULL; } - for (r=0; rharq_processes[i]->c[r],1056); dlsch->harq_processes[i]->c[r] = NULL; + free16(dlsch->harq_processes[i]->d[r],5*8448); + dlsch->harq_processes[i]->d[r] = NULL; } - - for (r=0; rharq_processes[i]->d[r]) { - free16(dlsch->harq_processes[i]->d[r],(5*8448)*sizeof(short)); - dlsch->harq_processes[i]->d[r] = NULL; - } - - for (r=0; rharq_processes[i]->w[r]) { - free16(dlsch->harq_processes[i]->w[r],(5*8448)*sizeof(short)); - dlsch->harq_processes[i]->w[r] = NULL; - } - - for (r=0; rharq_processes[i]->p_nrLDPC_procBuf[r]) { - nrLDPC_free_mem(dlsch->harq_processes[i]->p_nrLDPC_procBuf[r]); - dlsch->harq_processes[i]->p_nrLDPC_procBuf[r] = NULL; - } - } + free16(dlsch->harq_processes[i]->c,a_segments); + free16(dlsch->harq_processes[i]->d,a_segments); free16(dlsch->harq_processes[i],sizeof(NR_DL_UE_HARQ_t)); dlsch->harq_processes[i] = NULL; @@ -131,10 +118,13 @@ void free_nr_ue_dlsch(NR_UE_DLSCH_t **dlschptr, uint16_t N_RB_DL) { } } + NR_UE_DLSCH_t *new_nr_ue_dlsch(uint8_t Kmimo,uint8_t Mdlharq,uint32_t Nsoft,uint8_t max_ldpc_iterations,uint16_t N_RB_DL) { + NR_UE_DLSCH_t *dlsch; - uint8_t exit_flag = 0,i,r; - uint16_t a_segments = MAX_NUM_NR_DLSCH_SEGMENTS; //number of segments to be allocated + uint8_t exit_flag = 0; + + uint16_t a_segments = MAX_NUM_NR_DLSCH_SEGMENTS_PER_LAYER*NR_MAX_NB_LAYERS; //number of segments to be allocated if (N_RB_DL != 273) { a_segments = a_segments*N_RB_DL; @@ -153,7 +143,7 @@ NR_UE_DLSCH_t *new_nr_ue_dlsch(uint8_t Kmimo,uint8_t Mdlharq,uint32_t Nsoft,uint dlsch->Mlimit = 4; dlsch->max_ldpc_iterations = max_ldpc_iterations; - for (i=0; iharq_processes[i] = (NR_DL_UE_HARQ_t *)malloc16(sizeof(NR_DL_UE_HARQ_t)); if (dlsch->harq_processes[i]) { @@ -167,28 +157,18 @@ NR_UE_DLSCH_t *new_nr_ue_dlsch(uint8_t Kmimo,uint8_t Mdlharq,uint32_t Nsoft,uint else exit_flag=3; - for (r=0; rharq_processes[i]->p_nrLDPC_procBuf[r] = nrLDPC_init_mem(); + dlsch->harq_processes[i]->c = (uint8_t **)malloc16(a_segments*sizeof(uint8_t *)); + dlsch->harq_processes[i]->d = (int16_t **)malloc16(a_segments*sizeof(int16_t *)); + for (int r=0; rharq_processes[i]->c[r] = (uint8_t *)malloc16(1056); - + dlsch->harq_processes[i]->d[r] = (int16_t *)malloc16(5*8448*sizeof(int16_t)); if (dlsch->harq_processes[i]->c[r]) memset(dlsch->harq_processes[i]->c[r],0,1056); - else - exit_flag=2; - - dlsch->harq_processes[i]->d[r] = (short *)malloc16((5*8448)*sizeof(short)); - if (dlsch->harq_processes[i]->d[r]) - memset(dlsch->harq_processes[i]->d[r],0,(5*8448)*sizeof(short)); + memset(dlsch->harq_processes[i]->d[r],0,5*8448); else exit_flag=2; - dlsch->harq_processes[i]->w[r] = (short *)malloc16((5*8448)*sizeof(short)); - - if (dlsch->harq_processes[i]->w[r]) - memset(dlsch->harq_processes[i]->w[r],0,(5*8448)*sizeof(short)); - else - exit_flag=2; } } else { exit_flag=1; @@ -242,7 +222,7 @@ bool nr_ue_postDecode(PHY_VARS_NR_UE *phy_vars_ue, notifiedFIFO_elt_t *req, bool //LOG_D(PHY,"[UE %d] DLSCH: Setting ACK for nr_slot_rx %d TBS %d mcs %d nb_rb %d harq_process->round %d\n", // phy_vars_ue->Mod_id,nr_slot_rx,harq_process->TBS,harq_process->mcs,harq_process->nb_rb, harq_process->round); harq_process->status = SCH_IDLE; - harq_process->round = 0; + harq_process->DLround = 0; harq_process->ack = 1; //LOG_D(PHY,"[UE %d] DLSCH: Setting ACK for SFN/SF %d/%d (pid %d, status %d, round %d, TBS %d, mcs %d)\n", @@ -257,9 +237,9 @@ bool nr_ue_postDecode(PHY_VARS_NR_UE *phy_vars_ue, notifiedFIFO_elt_t *req, bool //LOG_D(PHY,"[UE %d] DLSCH: Setting NAK for SFN/SF %d/%d (pid %d, status %d, round %d, TBS %d, mcs %d) Kr %d r %d harq_process->round %d\n", // phy_vars_ue->Mod_id, frame, nr_slot_rx, harq_pid,harq_process->status, harq_process->round,harq_process->TBS,harq_process->mcs,Kr,r,harq_process->round); harq_process->ack = 0; - if (harq_process->round >= dlsch->Mlimit) { + if (harq_process->DLround >= dlsch->Mlimit) { harq_process->status = SCH_IDLE; - harq_process->round = 0; + harq_process->DLround = 0; phy_vars_ue->dl_stats[4]++; } @@ -309,136 +289,134 @@ void nr_processDLSegment(void* arg) { __m128i *pv = (__m128i*)&z; __m128i *pl = (__m128i*)&l; - uint8_t Ilbrm = 1; - Kr = harq_process->K; // [hna] overwrites this line "Kr = p_decParams->Z*kb" Kr_bytes = Kr>>3; K_bits_F = Kr-harq_process->F; t_nrLDPC_time_stats procTime = {0}; - t_nrLDPC_time_stats* p_procTime = &procTime ; - t_nrLDPC_procBuf **p_nrLDPC_procBuf = harq_process->p_nrLDPC_procBuf; - start_meas(&rdata->ts_deinterleave); - //VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_DLSCH_DEINTERLEAVING, VCD_FUNCTION_IN); - nr_deinterleaving_ldpc(E, - Qm, - harq_process->w[r], // [hna] w is e - dlsch_llr+r_offset); - //VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_DLSCH_DEINTERLEAVING, VCD_FUNCTION_OUT); - stop_meas(&rdata->ts_deinterleave); - start_meas(&rdata->ts_rate_unmatch); - /* LOG_D(PHY,"HARQ_PID %d Rate Matching Segment %d (coded bits %d,E %d, F %d,unpunctured/repeated bits %d, TBS %d, mod_order %d, nb_rb %d, Nl %d, rv %d, round %d)...\n", - harq_pid,r, G,E,harq_process->F, - Kr*3, - harq_process->TBS, - Qm, - harq_process->nb_rb, - harq_process->Nl, - harq_process->rvidx, - harq_process->round); */ - //VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_DLSCH_RATE_MATCHING, VCD_FUNCTION_IN); + start_meas(&rdata->ts_deinterleave); - if (nr_rate_matching_ldpc_rx(Ilbrm, - Tbslbrm, - p_decoderParms->BG, - p_decoderParms->Z, - harq_process->d[r], - harq_process->w[r], - harq_process->C, - harq_process->rvidx, - (harq_process->first_rx==1)?1:0, - E, - harq_process->F, - Kr-harq_process->F-2*(p_decoderParms->Z))==-1) { - //VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_DLSCH_RATE_MATCHING, VCD_FUNCTION_OUT); - stop_meas(&rdata->ts_rate_unmatch); - LOG_E(PHY,"dlsch_decoding.c: Problem in rate_matching\n"); - rdata->decodeIterations = dlsch->max_ldpc_iterations + 1; - return; - } + //VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_DLSCH_DEINTERLEAVING, VCD_FUNCTION_IN); + int16_t w[E]; + memset(w, 0, sizeof(w)); + nr_deinterleaving_ldpc(E, + Qm, + w, // [hna] w is e + dlsch_llr+r_offset); + //VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_DLSCH_DEINTERLEAVING, VCD_FUNCTION_OUT); + stop_meas(&rdata->ts_deinterleave); + + start_meas(&rdata->ts_rate_unmatch); + /* LOG_D(PHY,"HARQ_PID %d Rate Matching Segment %d (coded bits %d,E %d, F %d,unpunctured/repeated bits %d, TBS %d, mod_order %d, nb_rb %d, Nl %d, rv %d, round %d)...\n", + harq_pid,r, G,E,harq_process->F, + Kr*3, + harq_process->TBS, + Qm, + harq_process->nb_rb, + harq_process->Nl, + harq_process->rvidx, + harq_process->round); */ + //VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_DLSCH_RATE_MATCHING, VCD_FUNCTION_IN); + + if (nr_rate_matching_ldpc_rx(Tbslbrm, + p_decoderParms->BG, + p_decoderParms->Z, + harq_process->d[r], + w, + harq_process->C, + harq_process->rvidx, + (harq_process->first_rx==1)?1:0, + E, + harq_process->F, + Kr-harq_process->F-2*(p_decoderParms->Z))==-1) { + //VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_DLSCH_RATE_MATCHING, VCD_FUNCTION_OUT); stop_meas(&rdata->ts_rate_unmatch); + LOG_E(PHY,"dlsch_decoding.c: Problem in rate_matching\n"); + rdata->decodeIterations = dlsch->max_ldpc_iterations + 1; + return; + } + stop_meas(&rdata->ts_rate_unmatch); - r_offset += E; + r_offset += E; - if (LOG_DEBUGFLAG(DEBUG_DLSCH_DECOD)) { - LOG_D(PHY,"decoder input(segment %u) :",r); + if (LOG_DEBUGFLAG(DEBUG_DLSCH_DECOD)) { + LOG_D(PHY,"decoder input(segment %u) :",r); - for (int i=0; id[r][i]); + for (int i=0; id[r][i]); - LOG_D(PHY,"\n"); + LOG_D(PHY,"\n"); + } + + memset(harq_process->c[r],0,Kr_bytes); + + if (harq_process->C == 1) { + if (A > NR_MAX_PDSCH_TBS) + crc_type = CRC24_A; + else + crc_type = CRC16; + + length_dec = harq_process->B; + } else { + crc_type = CRC24_B; + length_dec = (harq_process->B+24*harq_process->C)/harq_process->C; + } + + { + start_meas(&rdata->ts_ldpc_decode); + //set first 2*Z_c bits to zeros + memset(&z[0],0,2*harq_process->Z*sizeof(int16_t)); + //set Filler bits + memset((&z[0]+K_bits_F),127,harq_process->F*sizeof(int16_t)); + //Move coded bits before filler bits + memcpy((&z[0]+2*harq_process->Z),harq_process->d[r],(K_bits_F-2*harq_process->Z)*sizeof(int16_t)); + //skip filler bits + memcpy((&z[0]+Kr),harq_process->d[r]+(Kr-2*harq_process->Z),(kc*harq_process->Z-Kr)*sizeof(int16_t)); + + //Saturate coded bits before decoding into 8 bits values + for (i=0, j=0; j < ((kc*harq_process->Z)>>4)+1; i+=2, j++) { + pl[j] = _mm_packs_epi16(pv[i],pv[i+1]); } - memset(harq_process->c[r],0,Kr_bytes); + //VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_DLSCH_LDPC, VCD_FUNCTION_IN); + p_decoderParms->block_length=length_dec; + nrLDPC_initcall(p_decoderParms, (int8_t*)&pl[0], llrProcBuf); + no_iteration_ldpc = nrLDPC_decoder(p_decoderParms, + (int8_t *)&pl[0], + llrProcBuf, + &procTime); + //VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_DLSCH_LDPC, VCD_FUNCTION_OUT); - if (harq_process->C == 1) { - if (A > NR_MAX_PDSCH_TBS) - crc_type = CRC24_A; - else - crc_type = CRC16; + // Fixme: correct type is unsigned, but nrLDPC_decoder and all called behind use signed int + if (check_crc((uint8_t *)llrProcBuf,length_dec,harq_process->F,crc_type)) { + LOG_D(PHY,"Segment %u CRC OK\n",r); - length_dec = harq_process->B; + if (r==0) { + for (int i=0; i<10; i++) LOG_D(PHY,"byte %d : %x\n",i,((uint8_t *)llrProcBuf)[i]); + } + + //Temporary hack + no_iteration_ldpc = dlsch->max_ldpc_iterations; + rdata->decodeIterations = no_iteration_ldpc; } else { - crc_type = CRC24_B; - length_dec = (harq_process->B+24*harq_process->C)/harq_process->C; + LOG_D(PHY,"CRC NOT OK\n"); } - { - start_meas(&rdata->ts_ldpc_decode); - //set first 2*Z_c bits to zeros - memset(&z[0],0,2*harq_process->Z*sizeof(int16_t)); - //set Filler bits - memset((&z[0]+K_bits_F),127,harq_process->F*sizeof(int16_t)); - //Move coded bits before filler bits - memcpy((&z[0]+2*harq_process->Z),harq_process->d[r],(K_bits_F-2*harq_process->Z)*sizeof(int16_t)); - //skip filler bits - memcpy((&z[0]+Kr),harq_process->d[r]+(Kr-2*harq_process->Z),(kc*harq_process->Z-Kr)*sizeof(int16_t)); + nb_total_decod++; - //Saturate coded bits before decoding into 8 bits values - for (i=0, j=0; j < ((kc*harq_process->Z)>>4)+1; i+=2, j++) { - pl[j] = _mm_packs_epi16(pv[i],pv[i+1]); - } - - //VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_DLSCH_LDPC, VCD_FUNCTION_IN); - p_decoderParms->block_length=length_dec; - nrLDPC_initcall(p_decoderParms, (int8_t*)&pl[0], llrProcBuf); - no_iteration_ldpc = nrLDPC_decoder(p_decoderParms, - (int8_t *)&pl[0], - llrProcBuf, - p_nrLDPC_procBuf[r], - p_procTime); - //VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_DLSCH_LDPC, VCD_FUNCTION_OUT); - - // Fixme: correct type is unsigned, but nrLDPC_decoder and all called behind use signed int - if (check_crc((uint8_t *)llrProcBuf,length_dec,harq_process->F,crc_type)) { - LOG_D(PHY,"Segment %u CRC OK\n\033[0m",r); - - if (r==0) { - for (int i=0; i<10; i++) LOG_D(PHY,"byte %d : %x\n",i,((uint8_t *)llrProcBuf)[i]); - } - - //Temporary hack - no_iteration_ldpc = dlsch->max_ldpc_iterations; - rdata->decodeIterations = no_iteration_ldpc; - } else { - LOG_D(PHY,"CRC NOT OK\n\033[0m"); - } - - nb_total_decod++; - - if (no_iteration_ldpc > dlsch->max_ldpc_iterations) { - nb_error_decod++; - } - - for (int m=0; m < Kr>>3; m ++) { - harq_process->c[r][m]= (uint8_t) llrProcBuf[m]; - } - - stop_meas(&rdata->ts_ldpc_decode); + if (no_iteration_ldpc > dlsch->max_ldpc_iterations) { + nb_error_decod++; } + + for (int m=0; m < Kr>>3; m ++) { + harq_process->c[r][m]= (uint8_t) llrProcBuf[m]; + } + + stop_meas(&rdata->ts_ldpc_decode); + } } uint32_t nr_dlsch_decoding(PHY_VARS_NR_UE *phy_vars_ue, @@ -452,8 +430,7 @@ uint32_t nr_dlsch_decoding(PHY_VARS_NR_UE *phy_vars_ue, uint16_t nb_symb_sch, uint8_t nr_slot_rx, uint8_t harq_pid, - uint8_t is_crnti, - uint8_t llr8_flag) { + uint8_t is_crnti) { uint32_t A,E; uint32_t G; uint32_t ret,offset; @@ -467,12 +444,10 @@ uint32_t nr_dlsch_decoding(PHY_VARS_NR_UE *phy_vars_ue, } // HARQ stats - phy_vars_ue->dl_stats[harq_process->round]++; - LOG_D(PHY,"Round %d RV idx %d\n",harq_process->round,harq_process->rvidx); + phy_vars_ue->dl_stats[harq_process->DLround]++; + LOG_D(PHY,"Round %d RV idx %d\n",harq_process->DLround,harq_process->rvidx); uint8_t kc; - uint32_t Tbslbrm;// = 950984; uint16_t nb_rb;// = 30; - double Coderate;// = 0.0; uint8_t dmrs_Type = harq_process->dmrsConfigType; AssertFatal(dmrs_Type == 0 || dmrs_Type == 1, "Illegal dmrs_type %d\n", dmrs_Type); uint8_t nb_re_dmrs; @@ -521,22 +496,19 @@ uint32_t nr_dlsch_decoding(PHY_VARS_NR_UE *phy_vars_ue, } */ nb_rb = harq_process->nb_rb; - harq_process->trials[harq_process->round]++; - uint16_t nb_rb_oh = 0; // it was not computed at UE side even before and set to 0 in nr_compute_tbs - harq_process->TBS = nr_compute_tbs(harq_process->Qm,harq_process->R,nb_rb,nb_symb_sch,nb_re_dmrs*dmrs_length, nb_rb_oh, 0, harq_process->Nl); + harq_process->trials[harq_process->DLround]++; + A = harq_process->TBS; ret = dlsch->max_ldpc_iterations + 1; dlsch->last_iteration_cnt = ret; harq_process->G = nr_get_G(nb_rb, nb_symb_sch, nb_re_dmrs, dmrs_length, harq_process->Qm,harq_process->Nl); G = harq_process->G; - LOG_D(PHY,"%d.%d DLSCH Decoding, harq_pid %d TBS %d (%d) G %d nb_re_dmrs %d length dmrs %d mcs %d Nl %d nb_symb_sch %d nb_rb %d\n", - frame,nr_slot_rx,harq_pid,A,A/8,G, nb_re_dmrs, dmrs_length, harq_process->mcs, harq_process->Nl, nb_symb_sch,nb_rb); + // target_code_rate is in 0.1 units + float Coderate = (float) harq_process->R / 10240.0f; - if ((harq_process->R)<1024) - Coderate = (float) (harq_process->R) /(float) 1024; - else - Coderate = (float) (harq_process->R) /(float) 2048; + LOG_D(PHY,"%d.%d DLSCH Decoding, harq_pid %d TBS %d (%d) G %d nb_re_dmrs %d length dmrs %d mcs %d Nl %d nb_symb_sch %d nb_rb %d Qm %d Coderate %f\n", + frame,nr_slot_rx,harq_pid,A,A/8,G, nb_re_dmrs, dmrs_length, harq_process->mcs, harq_process->Nl, nb_symb_sch, nb_rb, harq_process->Qm, Coderate); if ((A <=292) || ((A <= NR_MAX_PDSCH_TBS) && (Coderate <= 0.6667)) || Coderate <= 0.25) { p_decParams->BG = 2; @@ -578,13 +550,14 @@ uint32_t nr_dlsch_decoding(PHY_VARS_NR_UE *phy_vars_ue, &harq_process->F, p_decParams->BG); + if (harq_process->C>MAX_NUM_NR_DLSCH_SEGMENTS_PER_LAYER*harq_process->Nl) { + LOG_E(PHY,"nr_segmentation.c: too many segments %d, B %d\n",harq_process->C,harq_process->B); + return(-1); + } + if (LOG_DEBUGFLAG(DEBUG_DLSCH_DECOD) && (!frame%100)) LOG_I(PHY,"K %d C %d Z %d nl %d \n", harq_process->K, harq_process->C, p_decParams->Z, harq_process->Nl); } - if ((harq_process->Nl)<4) - Tbslbrm = nr_compute_tbslbrm(harq_process->mcs_table,nb_rb,harq_process->Nl); - else - Tbslbrm = nr_compute_tbslbrm(harq_process->mcs_table,nb_rb,4); VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_DLSCH_SEGMENTATION, VCD_FUNCTION_OUT); p_decParams->Z = harq_process->Z; @@ -593,7 +566,7 @@ uint32_t nr_dlsch_decoding(PHY_VARS_NR_UE *phy_vars_ue, p_decParams->numMaxIter = dlsch->max_ldpc_iterations; p_decParams->outMode= 0; r_offset = 0; - uint16_t a_segments = MAX_NUM_NR_DLSCH_SEGMENTS; //number of segments to be allocated + uint16_t a_segments = MAX_NUM_NR_DLSCH_SEGMENTS_PER_LAYER*harq_process->Nl; //number of segments to be allocated if (nb_rb != 273) { a_segments = a_segments*nb_rb; @@ -635,7 +608,7 @@ uint32_t nr_dlsch_decoding(PHY_VARS_NR_UE *phy_vars_ue, rdata->r_offset = r_offset; rdata->Kr_bytes = Kr_bytes; rdata->rv_index = harq_process->rvidx; - rdata->Tbslbrm = Tbslbrm; + rdata->Tbslbrm = harq_process->tbslbrm; rdata->offset = offset; rdata->dlsch = dlsch; rdata->dlsch_id = 0; diff --git a/openair1/PHY/NR_UE_TRANSPORT/nr_dlsch_demodulation.c b/openair1/PHY/NR_UE_TRANSPORT/nr_dlsch_demodulation.c index 75517b7a6f..eb43d80525 100644 --- a/openair1/PHY/NR_UE_TRANSPORT/nr_dlsch_demodulation.c +++ b/openair1/PHY/NR_UE_TRANSPORT/nr_dlsch_demodulation.c @@ -39,6 +39,7 @@ #include "PHY/NR_REFSIG/nr_refsig.h" #include "PHY/NR_REFSIG/dmrs_nr.h" #include "common/utils/nr/nr_common.h" +#include /* dynamic shift for LLR computation for TM3/4 * set as command line argument, see lte-softmodem.c @@ -79,35 +80,28 @@ unsigned char offset_mumimo_llr_drange[29][3]={{8,8,8},{7,7,7},{7,7,7},{7,7,7},{ #define print_ints(s,x) printf("%s = %d %d %d %d\n",s,(x)[0],(x)[1],(x)[2],(x)[3]) #define print_shorts(s,x) printf("%s = [%d+j*%d, %d+j*%d, %d+j*%d, %d+j*%d]\n",s,(x)[0],(x)[1],(x)[2],(x)[3],(x)[4],(x)[5],(x)[6],(x)[7]) -static void nr_dlsch_dual_stream_correlation_core(int **dl_ch_estimates_ext, - int **dl_ch_estimates_ext_i, - int **dl_ch_rho_ext, - unsigned char n_tx, - unsigned char n_rx, - unsigned char output_shift, - int length, - int start_point); - -uint8_t nr_zero_forcing_rx_2layers(int **rxdataF_comp, +/* compute H_h_H matrix inversion up to 4x4 matrices */ +uint8_t nr_zero_forcing_rx(int **rxdataF_comp, int **dl_ch_mag, int **dl_ch_magb, int **dl_ch_magr, int **dl_ch_estimates_ext, unsigned short nb_rb, unsigned char n_rx, + unsigned char n_tx,//number of layer unsigned char mod_order, int shift, unsigned char symbol, int length); +/* Apply layer demapping */ static void nr_dlsch_layer_demapping(int16_t **llr_cw, - uint8_t Nl, - uint8_t mod_order, - uint32_t length, - int32_t codeword_TB0, - int32_t codeword_TB1, - int16_t **llr_layers); - + uint8_t Nl, + uint8_t mod_order, + uint32_t length, + int32_t codeword_TB0, + int32_t codeword_TB1, + int16_t **llr_layers); /* compute LLR */ static int nr_dlsch_llr(NR_UE_PDSCH **pdsch_vars, @@ -123,13 +117,13 @@ static int nr_dlsch_llr(NR_UE_PDSCH **pdsch_vars, unsigned char first_symbol_flag, unsigned char symbol, unsigned short nb_rb, - unsigned short round, int32_t codeword_TB0, int32_t codeword_TB1, uint32_t len, uint8_t nr_slot_rx, uint8_t beamforming_mode); + /* Main Function */ int nr_rx_pdsch(PHY_VARS_NR_UE *ue, UE_nr_rxtx_proc_t *proc, @@ -159,7 +153,6 @@ int nr_rx_pdsch(PHY_VARS_NR_UE *ue, unsigned char aatx=0,aarx=0; - unsigned short nb_rb = 0, round; int avgs = 0;// rb; NR_DL_UE_HARQ_t *dlsch0_harq, *dlsch1_harq = NULL; @@ -176,9 +169,8 @@ int nr_rx_pdsch(PHY_VARS_NR_UE *ue, //int16_t *pllr_symbol_cw0_deint; //int16_t *pllr_symbol_cw1_deint; //uint16_t bundle_L = 2; - uint16_t n_tx=1, n_rx=1; int32_t median[16]; - uint32_t len; + uint32_t nb_re_pdsch; uint16_t startSymbIdx=0; uint16_t nbSymb=0; uint16_t pduBitmap=0x0; @@ -202,8 +194,8 @@ int nr_rx_pdsch(PHY_VARS_NR_UE *ue, pdsch_vars = ue->pdsch_vars[proc->thread_id]; dlsch = ue->dlsch[proc->thread_id][gNB_id]; dlsch0_harq = dlsch[0]->harq_processes[harq_pid]; - dlsch1_harq = dlsch[1]->harq_processes[harq_pid]; - beamforming_mode = ue->transmission_mode[gNB_id] < 7 ? 0 :ue->transmission_mode[gNB_id]; + if (NR_MAX_NB_LAYERS>4) + dlsch1_harq = dlsch[1]->harq_processes[harq_pid]; break; default: @@ -268,13 +260,6 @@ int nr_rx_pdsch(PHY_VARS_NR_UE *ue, return -1; } - dlsch0_harq->Qm = nr_get_Qm_dl(dlsch[0]->harq_processes[harq_pid]->mcs, dlsch[0]->harq_processes[harq_pid]->mcs_table); - dlsch0_harq->R = nr_get_code_rate_dl(dlsch[0]->harq_processes[harq_pid]->mcs, dlsch[0]->harq_processes[harq_pid]->mcs_table); - if (dlsch0_harq->Qm == 0 || dlsch0_harq->R == 0) { - LOG_W(MAC, "Invalid code rate or Mod order, likely due to unexpected DL DCI.\n"); - return -1; - } - #ifdef DEBUG_HARQ printf("[DEMOD] MIMO mode = %d\n", dlsch0_harq->mimo_mode); printf("[DEMOD] cw for TB0 = %d, cw for TB1 = %d\n", codeword_TB0, codeword_TB1); @@ -284,8 +269,7 @@ int nr_rx_pdsch(PHY_VARS_NR_UE *ue, nb_rb_pdsch = dlsch0_harq->nb_rb; DevAssert(dlsch0_harq); - round = dlsch0_harq->round; - //printf("round = %d\n", round); + if (gNB_id > 2) { LOG_W(PHY, "In %s: Illegal gNB_id %d\n", __FUNCTION__, gNB_id); @@ -312,130 +296,93 @@ int nr_rx_pdsch(PHY_VARS_NR_UE *ue, return(-1); } - if (dlsch0_harq->mimo_mode>NR_DUALSTREAM) { - LOG_E(PHY,"This transmission mode is not yet supported!\n"); - return(-1); - } - - if (dlsch0_harq->mimo_mode==NR_DUALSTREAM) { - DevAssert(dlsch1_harq); - } - if(symbol > ue->frame_parms.symbols_per_slot>>1) { slot = 1; } -#ifdef DEBUG_HARQ - printf("Demod dlsch0_harq->pmi_alloc %d\n", dlsch0_harq->pmi_alloc); -#endif - uint8_t pilots = (dlsch0_harq->dlDmrsSymbPos >> symbol) & 1; uint8_t config_type = dlsch0_harq->dmrsConfigType; - - if (beamforming_mode==0) {//No beamforming - start_meas(&ue->generic_stat_bis[proc->thread_id][slot]); - if (dlsch0_harq->Nl > 1)//More than or equal 2 layers - nb_rb = nr_dlsch_extract_rbs_multiple(common_vars->common_vars_rx_data_per_thread[proc->thread_id].rxdataF, - pdsch_vars[gNB_id]->dl_ch_estimates, - pdsch_vars[gNB_id]->rxdataF_ext, - pdsch_vars[gNB_id]->dl_ch_estimates_ext, - symbol, - pilots, - config_type, - start_rb + dlsch0_harq->BWPStart, - nb_rb_pdsch, - dlsch0_harq->n_dmrs_cdm_groups, - dlsch0_harq->Nl, - frame_parms, - dlsch0_harq->dlDmrsSymbPos); - else// one layer - nb_rb = nr_dlsch_extract_rbs_single(common_vars->common_vars_rx_data_per_thread[proc->thread_id].rxdataF, - pdsch_vars[gNB_id]->dl_ch_estimates, - pdsch_vars[gNB_id]->rxdataF_ext, - pdsch_vars[gNB_id]->dl_ch_estimates_ext, - symbol, - pilots, - config_type, - start_rb + dlsch0_harq->BWPStart, - nb_rb_pdsch, - dlsch0_harq->n_dmrs_cdm_groups, - frame_parms, - dlsch0_harq->dlDmrsSymbPos); - } - else if(beamforming_mode>7) { - LOG_W(PHY,"dlsch_demodulation: beamforming mode not supported yet.\n"); - } - - //printf("nb_rb = %d, gNB_id %d\n",nb_rb,gNB_id); - if (nb_rb==0) { - LOG_D(PHY,"dlsch_demodulation.c: nb_rb=0\n"); - return(-1); - } - - len = (pilots==1)? ((config_type==NFAPI_NR_DMRS_TYPE1)?nb_rb*(12-6*dlsch0_harq->n_dmrs_cdm_groups): nb_rb*(12-4*dlsch0_harq->n_dmrs_cdm_groups)):(nb_rb*12); - + //---------------------------------------------------------- + //--------------------- RBs extraction --------------------- + //---------------------------------------------------------- + start_meas(&ue->generic_stat_bis[proc->thread_id][slot]); + nr_dlsch_extract_rbs(common_vars->common_vars_rx_data_per_thread[proc->thread_id].rxdataF, + pdsch_vars[gNB_id]->dl_ch_estimates, + pdsch_vars[gNB_id]->rxdataF_ext, + pdsch_vars[gNB_id]->dl_ch_estimates_ext, + symbol, + pilots, + config_type, + start_rb + dlsch0_harq->BWPStart, + nb_rb_pdsch, + dlsch0_harq->n_dmrs_cdm_groups, + dlsch0_harq->Nl, + frame_parms, + dlsch0_harq->dlDmrsSymbPos, + ue->chest_time); stop_meas(&ue->generic_stat_bis[proc->thread_id][slot]); if (cpumeas(CPUMEAS_GETSTATE)) LOG_D(PHY, "[AbsSFN %u.%d] Slot%d Symbol %d type %d: Pilot/Data extraction %5.2f \n", frame,nr_slot_rx,slot,symbol,type,ue->generic_stat_bis[proc->thread_id][slot].p_time/(cpuf*1000.0)); - + int nl = dlsch0_harq->Nl; + int n_rx = frame_parms->nb_antennas_rx; + nb_re_pdsch = (pilots==1)? ((config_type==NFAPI_NR_DMRS_TYPE1)?nb_rb_pdsch*(12-6*dlsch0_harq->n_dmrs_cdm_groups): nb_rb_pdsch*(12-4*dlsch0_harq->n_dmrs_cdm_groups)) : (nb_rb_pdsch*12); + //---------------------------------------------------------- + //--------------------- Channel Scaling -------------------- + //---------------------------------------------------------- start_meas(&ue->generic_stat_bis[proc->thread_id][slot]); - n_tx = dlsch0_harq->Nl; - n_rx = frame_parms->nb_antennas_rx; - nr_dlsch_scale_channel(pdsch_vars[gNB_id]->dl_ch_estimates_ext, frame_parms, - n_tx, + nl, n_rx, dlsch, symbol, pilots, - len, + nb_re_pdsch, nb_rb_pdsch); + stop_meas(&ue->generic_stat_bis[proc->thread_id][slot]); - stop_meas(&ue->generic_stat_bis[proc->thread_id][slot]); - if (cpumeas(CPUMEAS_GETSTATE)) - LOG_D(PHY, "[AbsSFN %u.%d] Slot%d Symbol %d: Channel Scale %5.2f \n",frame,nr_slot_rx,slot,symbol,ue->generic_stat_bis[proc->thread_id][slot].p_time/(cpuf*1000.0)); + if (cpumeas(CPUMEAS_GETSTATE)) + LOG_D(PHY, "[AbsSFN %u.%d] Slot%d Symbol %d: Channel Scale %5.2f \n", + frame,nr_slot_rx,slot,symbol,ue->generic_stat_bis[proc->thread_id][slot].p_time/(cpuf*1000.0)); - start_meas(&ue->generic_stat_bis[proc->thread_id][slot]); + //---------------------------------------------------------- + //--------------------- Channel Level Calc. ---------------- + //---------------------------------------------------------- + start_meas(&ue->generic_stat_bis[proc->thread_id][slot]); if (first_symbol_flag==1) { - if (beamforming_mode==0){ - nr_dlsch_channel_level(pdsch_vars[gNB_id]->dl_ch_estimates_ext, - frame_parms, - n_tx, - avg, - symbol, - len, - nb_rb_pdsch); - avgs = 0; - for (aatx=0;aatxnb_antennas_rx+aarx]); - avgs = cmax(avgs,avg[(aatx*frame_parms->nb_antennas_rx)+aarx]); - //LOG_I(PHY, "avgs Power per SC is %d\n", avgs); - median[(aatx*frame_parms->nb_antennas_rx)+aarx] = avg[(aatx*frame_parms->nb_antennas_rx)+aarx]; - } - - if (dlsch0_harq->mimo_mode == NR_DUALSTREAM) { - nr_dlsch_channel_level_median(pdsch_vars[gNB_id]->dl_ch_estimates_ext, - median, - n_tx, - n_rx, - len, - symbol*nb_rb*12); - - for (aatx = 0; aatx < n_tx; aatx++) { - for (aarx = 0; aarx < n_rx; aarx++) { - avgs = cmax(avgs, median[aatx*n_rx + aarx]); - } + nr_dlsch_channel_level(pdsch_vars[gNB_id]->dl_ch_estimates_ext, + frame_parms, + nl, + avg, + symbol, + nb_re_pdsch, + nb_rb_pdsch); + avgs = 0; + for (aatx=0;aatxNl > 1) { + nr_dlsch_channel_level_median(pdsch_vars[gNB_id]->dl_ch_estimates_ext, + median, + nl, + n_rx, + nb_re_pdsch, + symbol*nb_rb_pdsch*12); + for (aatx = 0; aatx < nl; aatx++) { + for (aarx = 0; aarx < n_rx; aarx++) { + avgs = cmax(avgs, median[aatx*n_rx + aarx]); } } - - pdsch_vars[gNB_id]->log2_maxh = (log2_approx(avgs)/2) + 1; - //LOG_I(PHY, "avgs Power per SC is %d lg2_maxh %d\n", avgs, pdsch_vars[gNB_id]->log2_maxh); } + pdsch_vars[gNB_id]->log2_maxh = (log2_approx(avgs)/2) + 1; + //LOG_I(PHY, "avgs Power per SC is %d lg2_maxh %d\n", avgs, pdsch_vars[gNB_id]->log2_maxh); LOG_D(PHY,"[DLSCH] AbsSubframe %d.%d log2_maxh = %d [log2_maxh0 %d log2_maxh1 %d] (%d,%d)\n", frame%1024, nr_slot_rx, @@ -445,128 +392,83 @@ int nr_rx_pdsch(PHY_VARS_NR_UE *ue, avg[0], avgs); } + stop_meas(&ue->generic_stat_bis[proc->thread_id][slot]); #if T_TRACER - if (type == PDSCH) - { - T(T_UE_PHY_PDSCH_ENERGY, T_INT(gNB_id), T_INT(0), T_INT(frame%1024), T_INT(nr_slot_rx), - T_INT(avg[0]), T_INT(avg[1]), T_INT(avg[2]), T_INT(avg[3])); - } + if (type == PDSCH) + { + T(T_UE_PHY_PDSCH_ENERGY, T_INT(gNB_id), T_INT(0), T_INT(frame%1024), T_INT(nr_slot_rx), + T_INT(avg[0]), T_INT(avg[1]), T_INT(avg[2]), T_INT(avg[3])); + } #endif - stop_meas(&ue->generic_stat_bis[proc->thread_id][slot]); - if (cpumeas(CPUMEAS_GETSTATE)) - LOG_D(PHY, "[AbsSFN %u.%d] Slot%d Symbol %d first_symbol_flag %d: Channel Level %5.2f \n",frame,nr_slot_rx,slot,symbol,first_symbol_flag,ue->generic_stat_bis[proc->thread_id][slot].p_time/(cpuf*1000.0)); - - start_meas(&ue->generic_stat_bis[proc->thread_id][slot]); -// Now channel compensation - if (dlsch0_harq->mimo_moderxdataF_ext, - pdsch_vars[gNB_id]->dl_ch_estimates_ext, - pdsch_vars[gNB_id]->dl_ch_mag0, - pdsch_vars[gNB_id]->dl_ch_magb0, - pdsch_vars[gNB_id]->dl_ch_magr0, - pdsch_vars[gNB_id]->rxdataF_comp0, - (n_tx>1) ? pdsch_vars[gNB_id]->rho : NULL, - frame_parms, - n_tx, - symbol, - len, - first_symbol_flag, - dlsch0_harq->Qm, - nb_rb_pdsch, - pdsch_vars[gNB_id]->log2_maxh, - measurements); // log2_maxh+I0_shift - } - - else if (dlsch0_harq->mimo_mode == NR_DUALSTREAM) { - nr_dlsch_channel_compensation_core(pdsch_vars[gNB_id]->rxdataF_ext, - pdsch_vars[gNB_id]->dl_ch_estimates_ext, - pdsch_vars[gNB_id]->dl_ch_mag0, - pdsch_vars[gNB_id]->dl_ch_magb0, - pdsch_vars[gNB_id]->rxdataF_comp0, //rxdataF_comp - NULL, - n_tx, - n_rx, - dlsch0_harq->Qm, - pdsch_vars[gNB_id]->log2_maxh, - 2*len, // subcarriers Re Im - 0); // we start from the beginning of the vector - // compute correlation between signal and interference channels (rho12 and rho21) - nr_dlsch_dual_stream_correlation_core(pdsch_vars[gNB_id]->dl_ch_estimates_ext, - &(pdsch_vars[gNB_id]->dl_ch_estimates_ext[2]), - pdsch_vars[gNB_id]->dl_ch_rho_ext[harq_pid][round], - n_tx, - n_rx, - pdsch_vars[gNB_id]->log2_maxh, - 2*len, - 0); - } + if (cpumeas(CPUMEAS_GETSTATE)) + LOG_D(PHY, "[AbsSFN %u.%d] Slot%d Symbol %d first_symbol_flag %d: Channel Level %5.2f \n",frame,nr_slot_rx,slot,symbol,first_symbol_flag,ue->generic_stat_bis[proc->thread_id][slot].p_time/(cpuf*1000.0)); + //---------------------------------------------------------- + //--------------------- channel compensation --------------- + //---------------------------------------------------------- + // Disable correlation measurement for optimizing UE + start_meas(&ue->generic_stat_bis[proc->thread_id][slot]); + nr_dlsch_channel_compensation(pdsch_vars[gNB_id]->rxdataF_ext, + pdsch_vars[gNB_id]->dl_ch_estimates_ext, + pdsch_vars[gNB_id]->dl_ch_mag0, + pdsch_vars[gNB_id]->dl_ch_magb0, + pdsch_vars[gNB_id]->dl_ch_magr0, + pdsch_vars[gNB_id]->rxdataF_comp0, + NULL,//NULL:disable meas. pdsch_vars[gNB_id]->rho:enable meas. + frame_parms, + nl, + symbol, + nb_re_pdsch, + first_symbol_flag, + dlsch0_harq->Qm, + nb_rb_pdsch, + pdsch_vars[gNB_id]->log2_maxh, + measurements); // log2_maxh+I0_shift stop_meas(&ue->generic_stat_bis[proc->thread_id][slot]); if (cpumeas(CPUMEAS_GETSTATE)) LOG_D(PHY, "[AbsSFN %u.%d] Slot%d Symbol %d log2_maxh %d channel_level %d: Channel Comp %5.2f \n", frame, nr_slot_rx, slot, symbol, pdsch_vars[gNB_id]->log2_maxh, proc->channel_level, ue->generic_stat_bis[proc->thread_id][slot].p_time/(cpuf*1000.0)); start_meas(&ue->generic_stat_bis[proc->thread_id][slot]); - if (frame_parms->nb_antennas_rx > 1) { - if (dlsch0_harq->mimo_moderxdataF_comp0, - (n_tx>1)? pdsch_vars[gNB_id]->rho : NULL, - pdsch_vars[gNB_id]->dl_ch_mag0, - pdsch_vars[gNB_id]->dl_ch_magb0, - pdsch_vars[gNB_id]->dl_ch_magr0, - n_tx, - n_rx, - symbol, - nb_rb_pdsch, - len); - if (n_tx == 2)//Apply zero forcing for 2 Tx layers - nr_zero_forcing_rx_2layers(pdsch_vars[gNB_id]->rxdataF_comp0, - pdsch_vars[gNB_id]->dl_ch_mag0, - pdsch_vars[gNB_id]->dl_ch_magb0, - pdsch_vars[gNB_id]->dl_ch_magr0, - pdsch_vars[gNB_id]->dl_ch_estimates_ext, - nb_rb_pdsch, - n_rx, - dlsch0_harq->Qm, - pdsch_vars[gNB_id]->log2_maxh, - symbol, - len); - } - else if (dlsch0_harq->mimo_mode == NR_DUALSTREAM) { - nr_dlsch_detection_mrc_core(pdsch_vars[gNB_id]->rxdataF_comp0, - NULL, - pdsch_vars[gNB_id]->dl_ch_rho_ext[harq_pid][round], - pdsch_vars[gNB_id]->dl_ch_rho2_ext, - pdsch_vars[gNB_id]->dl_ch_mag0, - pdsch_vars[gNB_id]->dl_ch_magb0, - NULL, - NULL, - n_tx, - n_rx, - 2*len, - 0); - } + if (n_rx > 1) { + nr_dlsch_detection_mrc(pdsch_vars[gNB_id]->rxdataF_comp0, + (nl>1)? pdsch_vars[gNB_id]->rho : NULL, + pdsch_vars[gNB_id]->dl_ch_mag0, + pdsch_vars[gNB_id]->dl_ch_magb0, + pdsch_vars[gNB_id]->dl_ch_magr0, + nl, + n_rx, + symbol, + nb_rb_pdsch, + nb_re_pdsch); + if (nl >= 2)//Apply zero forcing for 2, 3, and 4 Tx layers + nr_zero_forcing_rx(pdsch_vars[gNB_id]->rxdataF_comp0, + pdsch_vars[gNB_id]->dl_ch_mag0, + pdsch_vars[gNB_id]->dl_ch_magb0, + pdsch_vars[gNB_id]->dl_ch_magr0, + pdsch_vars[gNB_id]->dl_ch_estimates_ext, + nb_rb_pdsch, + n_rx, + nl, + dlsch0_harq->Qm, + pdsch_vars[gNB_id]->log2_maxh, + symbol, + nb_re_pdsch); } + stop_meas(&ue->generic_stat_bis[proc->thread_id][slot]); + //printf("start compute LLR\n"); - if (dlsch0_harq->mimo_mode == NR_DUALSTREAM) { - rxdataF_comp_ptr = pdsch_vars[gNB_id]->rxdataF_comp1[harq_pid][round]; - dl_ch_mag_ptr = pdsch_vars[gNB_id]->dl_ch_mag1[harq_pid][round]; - } - else { - rxdataF_comp_ptr = pdsch_vars[gNB_id_i]->rxdataF_comp0; - dl_ch_mag_ptr = pdsch_vars[gNB_id_i]->dl_ch_mag0; - //i_mod should have been passed as a parameter - } + rxdataF_comp_ptr = pdsch_vars[gNB_id_i]->rxdataF_comp0; + dl_ch_mag_ptr = pdsch_vars[gNB_id_i]->dl_ch_mag0; - stop_meas(&ue->generic_stat_bis[proc->thread_id][slot]); - if (cpumeas(CPUMEAS_GETSTATE)) - LOG_D(PHY, "[AbsSFN %u.%d] Slot%d Symbol %d: Channel Combine %5.2f \n",frame,nr_slot_rx,slot,symbol,ue->generic_stat_bis[proc->thread_id][slot].p_time/(cpuf*1000.0)); + if (cpumeas(CPUMEAS_GETSTATE)) + LOG_D(PHY, "[AbsSFN %u.%d] Slot%d Symbol %d: Channel Combine and zero forcing %5.2f \n",frame,nr_slot_rx,slot,symbol,ue->generic_stat_bis[proc->thread_id][slot].p_time/(cpuf*1000.0)); start_meas(&ue->generic_stat_bis[proc->thread_id][slot]); /* Store the valid DL RE's */ - pdsch_vars[gNB_id]->dl_valid_re[symbol-1] = len; + pdsch_vars[gNB_id]->dl_valid_re[symbol-1] = nb_re_pdsch; if(dlsch0_harq->status == ACTIVE) { startSymbIdx = dlsch0_harq->start_symbol; @@ -589,7 +491,7 @@ int nr_rx_pdsch(PHY_VARS_NR_UE *ue, gNB_id, nr_slot_rx, symbol, - (nb_rb*12), + (nb_rb_pdsch*12), dlsch[0]->rnti,rx_type); pdsch_vars[gNB_id]->dl_valid_re[symbol-1] -= pdsch_vars[gNB_id]->ptrs_re_per_slot[0][symbol]; } @@ -611,7 +513,7 @@ int nr_rx_pdsch(PHY_VARS_NR_UE *ue, rx_type, harq_pid, gNB_id, gNB_id_i, first_symbol_flag, - i, nb_rb, round, + i, nb_rb_pdsch, codeword_TB0, codeword_TB1, pdsch_vars[gNB_id]->dl_valid_re[i-1], nr_slot_rx, beamforming_mode); @@ -647,33 +549,34 @@ int nr_rx_pdsch(PHY_VARS_NR_UE *ue, // Please keep it: useful for debugging #ifdef DEBUG_PDSCH_RX - char filename[40]; + char filename[50]; uint8_t aa = 0; - snprintf(filename, 40, "rxdataF0_symb_%d_nr_slot_rx_%d.m", symbol, nr_slot_rx); + snprintf(filename, 50, "rxdataF0_symb_%d_nr_slot_rx_%d.m", symbol, nr_slot_rx); write_output(filename, "rxdataF0", &common_vars->common_vars_rx_data_per_thread[proc->thread_id].rxdataF[0][0], NR_SYMBOLS_PER_SLOT*frame_parms->ofdm_symbol_size, 1, 1); - snprintf(filename, 40, "dl_ch_estimates0%d_symb_%d_nr_slot_rx_%d.m", aa, symbol, nr_slot_rx); + snprintf(filename, 50, "dl_ch_estimates0%d_symb_%d_nr_slot_rx_%d.m", aa, symbol, nr_slot_rx); write_output(filename, "dl_ch_estimates", &pdsch_vars[gNB_id]->dl_ch_estimates[aa][0], NR_SYMBOLS_PER_SLOT*frame_parms->ofdm_symbol_size, 1, 1); - snprintf(filename, 40, "rxdataF_ext0%d_symb_%d_nr_slot_rx_%d.m", aa, symbol, nr_slot_rx); + snprintf(filename, 50, "rxdataF_ext0%d_symb_%d_nr_slot_rx_%d.m", aa, symbol, nr_slot_rx); write_output(filename, "rxdataF_ext", &pdsch_vars[gNB_id]->rxdataF_ext[aa][0], NR_SYMBOLS_PER_SLOT*frame_parms->N_RB_DL*NR_NB_SC_PER_RB, 1, 1); - snprintf(filename, 40, "dl_ch_estimates_ext0%d_symb_%d_nr_slot_rx_%d.m", aa, symbol, nr_slot_rx); + snprintf(filename, 50, "dl_ch_estimates_ext0%d_symb_%d_nr_slot_rx_%d.m", aa, symbol, nr_slot_rx); write_output(filename, "dl_ch_estimates_ext00", &pdsch_vars[gNB_id]->dl_ch_estimates_ext[aa][0], NR_SYMBOLS_PER_SLOT*frame_parms->N_RB_DL*NR_NB_SC_PER_RB, 1, 1); - snprintf(filename, 40, "rxdataF_comp0%d_symb_%d_nr_slot_rx_%d.m", aa, symbol, nr_slot_rx); + snprintf(filename, 50, "rxdataF_comp0%d_symb_%d_nr_slot_rx_%d.m", aa, symbol, nr_slot_rx); write_output(filename, "rxdataF_comp00", &pdsch_vars[gNB_id]->rxdataF_comp0[aa][0], NR_SYMBOLS_PER_SLOT*frame_parms->N_RB_DL*NR_NB_SC_PER_RB, 1, 1); - +/* for (int i=0; i < 2; i++){ - snprintf(filename, 40, "llr%d_symb_%d_nr_slot_rx_%d.m", i, symbol, nr_slot_rx); - write_output(filename,"llr", &pdsch_vars[gNB_id]->llr[i][0], (NR_SYMBOLS_PER_SLOT*nb_rb*NR_NB_SC_PER_RB*dlsch1_harq->Qm) - 4*(nb_rb*4*dlsch1_harq->Qm), 1, 0); + snprintf(filename, 50, "llr%d_symb_%d_nr_slot_rx_%d.m", i, symbol, nr_slot_rx); + write_output(filename,"llr", &pdsch_vars[gNB_id]->llr[i][0], (NR_SYMBOLS_PER_SLOT*nb_rb_pdsch*NR_NB_SC_PER_RB*dlsch1_harq->Qm) - 4*(nb_rb_pdsch*4*dlsch1_harq->Qm), 1, 0); } +*/ #endif #if T_TRACER T(T_UE_PHY_PDSCH_IQ, T_INT(gNB_id), T_INT(ue->Mod_id), T_INT(frame%1024), - T_INT(nr_slot_rx), T_INT(nb_rb), + T_INT(nr_slot_rx), T_INT(nb_rb_pdsch), T_INT(frame_parms->N_RB_UL), T_INT(frame_parms->symbols_per_slot), T_BUFFER(&pdsch_vars[gNB_id]->rxdataF_comp0[gNB_id][0], 2 * /* ulsch[UE_id]->harq_processes[harq_pid]->nb_rb */ frame_parms->N_RB_UL *12*frame_parms->symbols_per_slot*2)); #endif @@ -888,9 +791,11 @@ void nr_dlsch_channel_compensation(int **rxdataF_ext, mmtmpD3 = _mm_unpackhi_epi32(mmtmpD0,mmtmpD1); rxdataF_comp128[1] = _mm_packs_epi32(mmtmpD2,mmtmpD3); - //print_shorts("rx:",(int16_t*)&rxdataF128[1]); - //print_shorts("ch:",(int16_t*)&dl_ch128[1]); - //print_shorts("pack:",(int16_t*)&rxdataF_comp128[1]); +#ifdef DEBUG_DLSCH_DEMOD + print_shorts("rx:",(int16_t*)&rxdataF128[1]); + print_shorts("ch:",(int16_t*)&dl_ch128[1]); + print_shorts("pack:",(int16_t*)&rxdataF_comp128[1]); +#endif // multiply by conjugated channel mmtmpD0 = _mm_madd_epi16(dl_ch128[2],rxdataF128[2]); @@ -906,9 +811,11 @@ void nr_dlsch_channel_compensation(int **rxdataF_ext, mmtmpD3 = _mm_unpackhi_epi32(mmtmpD0,mmtmpD1); rxdataF_comp128[2] = _mm_packs_epi32(mmtmpD2,mmtmpD3); - //print_shorts("rx:",(int16_t*)&rxdataF128[2]); - //print_shorts("ch:",(int16_t*)&dl_ch128[2]); - //print_shorts("pack:",(int16_t*)&rxdataF_comp128[2]); +#ifdef DEBUG_DLSCH_DEMOD + print_shorts("rx:",(int16_t*)&rxdataF128[2]); + print_shorts("ch:",(int16_t*)&dl_ch128[2]); + print_shorts("pack:",(int16_t*)&rxdataF_comp128[2]); +#endif dl_ch128+=3; dl_ch_mag128+=3; @@ -925,16 +832,16 @@ void nr_dlsch_channel_compensation(int **rxdataF_ext, //rho[aarx][nb_aatx*nb_aatx] = [cov(H_aarx_0,H_aarx_0) cov(H_aarx_0,H_aarx_1) // cov(H_aarx_1,H_aarx_0) cov(H_aarx_1,H_aarx_1)], aarx=0,...,nb_antennas_rx-1 - int avg_rho_re[frame_parms->nb_antennas_rx][nb_aatx*nb_aatx]; - int avg_rho_im[frame_parms->nb_antennas_rx][nb_aatx*nb_aatx]; + //int avg_rho_re[frame_parms->nb_antennas_rx][nb_aatx*nb_aatx]; + //int avg_rho_im[frame_parms->nb_antennas_rx][nb_aatx*nb_aatx]; for (aarx=0; aarxnb_antennas_rx; aarx++) { for (aatx=0; aatxnb_antennas_rx+aarx][symbol*nb_rb*12]; dl_ch128_2 = (__m128i *)&dl_ch_estimates_ext[atx*frame_parms->nb_antennas_rx+aarx][symbol*nb_rb*12]; @@ -963,15 +870,14 @@ void nr_dlsch_channel_compensation(int **rxdataF_ext, //print_shorts("ch:",dl_ch128); //print_shorts("pack:",rho128); - avg_rho_re[aarx][aatx*nb_aatx+atx] +=(((int16_t*)&rho128[0])[0]+ + /*avg_rho_re[aarx][aatx*nb_aatx+atx] +=(((int16_t*)&rho128[0])[0]+ ((int16_t*)&rho128[0])[2] + ((int16_t*)&rho128[0])[4] + - ((int16_t*)&rho128[0])[6])/16;// - - avg_rho_im[aarx][aatx*nb_aatx+atx] +=(((int16_t*)&rho128[0])[1]+ + ((int16_t*)&rho128[0])[6])/16;*/ + /*avg_rho_im[aarx][aatx*nb_aatx+atx] +=(((int16_t*)&rho128[0])[1]+ ((int16_t*)&rho128[0])[3] + ((int16_t*)&rho128[0])[5] + - ((int16_t*)&rho128[0])[7])/16;// + ((int16_t*)&rho128[0])[7])/16;*/ // multiply by conjugated channel mmtmpD0 = _mm_madd_epi16(dl_ch128[1],dl_ch128_2[1]); @@ -991,15 +897,14 @@ void nr_dlsch_channel_compensation(int **rxdataF_ext, //print_shorts("pack:",rho128+1); // multiply by conjugated channel - avg_rho_re[aarx][aatx*nb_aatx+atx] +=(((int16_t*)&rho128[1])[0]+ + /*avg_rho_re[aarx][aatx*nb_aatx+atx] +=(((int16_t*)&rho128[1])[0]+ ((int16_t*)&rho128[1])[2] + ((int16_t*)&rho128[1])[4] + - ((int16_t*)&rho128[1])[6])/16; - - avg_rho_im[aarx][aatx*nb_aatx+atx] +=(((int16_t*)&rho128[1])[1]+ + ((int16_t*)&rho128[1])[6])/16;*/ + /*avg_rho_im[aarx][aatx*nb_aatx+atx] +=(((int16_t*)&rho128[1])[1]+ ((int16_t*)&rho128[1])[3] + ((int16_t*)&rho128[1])[5] + - ((int16_t*)&rho128[1])[7])/16; + ((int16_t*)&rho128[1])[7])/16;*/ mmtmpD0 = _mm_madd_epi16(dl_ch128[2],dl_ch128_2[2]); // mmtmpD0 contains real part of 4 consecutive outputs (32-bit) @@ -1017,25 +922,28 @@ void nr_dlsch_channel_compensation(int **rxdataF_ext, //print_shorts("rx:",dl_ch128_2+2); //print_shorts("ch:",dl_ch128+2); //print_shorts("pack:",rho128+2); - avg_rho_re[aarx][aatx*nb_aatx+atx] +=(((int16_t*)&rho128[2])[0]+ + + /*avg_rho_re[aarx][aatx*nb_aatx+atx] +=(((int16_t*)&rho128[2])[0]+ ((int16_t*)&rho128[2])[2] + ((int16_t*)&rho128[2])[4] + - ((int16_t*)&rho128[2])[6])/16; - - avg_rho_im[aarx][aatx*nb_aatx+atx] +=(((int16_t*)&rho128[2])[1]+ + ((int16_t*)&rho128[2])[6])/16;*/ + /*avg_rho_im[aarx][aatx*nb_aatx+atx] +=(((int16_t*)&rho128[2])[1]+ ((int16_t*)&rho128[2])[3] + ((int16_t*)&rho128[2])[5] + - ((int16_t*)&rho128[2])[7])/16; + ((int16_t*)&rho128[2])[7])/16;*/ dl_ch128+=3; dl_ch128_2+=3; rho128+=3; } if (first_symbol_flag==1) { - //measurements->rx_correlation[0][0][aarx] = signal_energy(&rho[aarx][aatx*nb_aatx+atx][symbol*nb_rb*12],rb*12); - avg_rho_re[aarx][aatx*nb_aatx+atx] = 16*avg_rho_re[aarx][aatx*nb_aatx+atx]/(nb_rb*12); - avg_rho_im[aarx][aatx*nb_aatx+atx] = 16*avg_rho_im[aarx][aatx*nb_aatx+atx]/(nb_rb*12); + //rho_nm = H_arx_n.conj(H_arx_m) + //rho_rx_corr[arx][nm] = |H_arx_n|^2.|H_arx_m|^2 &rho[aarx][aatx*nb_aatx+atx][symbol*nb_rb*12] + measurements->rx_correlation[0][aarx][aatx*nb_aatx+atx] = signal_energy(&rho[aarx][aatx*nb_aatx+atx][symbol*nb_rb*12],length); + //avg_rho_re[aarx][aatx*nb_aatx+atx] = 16*avg_rho_re[aarx][aatx*nb_aatx+atx]/length; + //avg_rho_im[aarx][aatx*nb_aatx+atx] = 16*avg_rho_im[aarx][aatx*nb_aatx+atx]/length; //printf("rho[rx]%d tx%d tx%d = Re: %d Im: %d\n",aarx, aatx,atx, avg_rho_re[aarx][aatx*nb_aatx+atx], avg_rho_im[aarx][aatx*nb_aatx+atx]); + //printf("rho_corr[rx]%d tx%d tx%d = %d ...\n",aarx, aatx,atx, measurements->rx_correlation[0][aarx][aatx*nb_aatx+atx]); } } } @@ -1688,294 +1596,6 @@ void nr_dlsch_channel_level_median(int **dl_ch_estimates_ext, } -static void nr_dlsch_dual_stream_correlation_core(int **dl_ch_estimates_ext, - int **dl_ch_estimates_ext_i, - int **dl_ch_rho_ext, - unsigned char n_tx, - unsigned char n_rx, - unsigned char output_shift, - int length, - int start_point) -{ -#if defined(__x86_64__)||defined(__i386__) - - __m128i *dl_ch128,*dl_ch128i,*dl_ch_rho128,mmtmpD0,mmtmpD1,mmtmpD2,mmtmpD3; - unsigned char aarx; - int ii, length2, length_mod8; - - - for (aarx=0; aarx>3; - - for (ii=0; ii1) { - - for (aatx=0; aatx>2; - - for (i=0; i>2; - - for (i=0; i>2; - - for (i=0; i>2; - - for (i=0; i1) { - - for (aatx=0; aatx>2; - - for (i=0; i>2; - - for (i=0; i>2; - - for (i=0; inb_antennas_rx; aarx++) { - - k = frame_parms->first_carrier_offset + NR_NB_SC_PER_RB*start_rb; + const unsigned short start_re = (frame_parms->first_carrier_offset + start_rb * NR_NB_SC_PER_RB) % frame_parms->ofdm_symbol_size; + int8_t validDmrsEst; + if (chest_time_type == 0) validDmrsEst = get_valid_dmrs_idx_for_channel_est(dlDmrsSymbPos,symbol); + else + validDmrsEst = get_next_dmrs_symbol_in_slot(dlDmrsSymbPos,0,14); // get first dmrs symbol index - dl_ch0 = &dl_ch_estimates[aarx][(validDmrsEst*(frame_parms->ofdm_symbol_size))]; + for (unsigned char aarx = 0; aarx < frame_parms->nb_antennas_rx; aarx++) { - dl_ch0_ext = &dl_ch_estimates_ext[aarx][symbol*(nb_rb_pdsch*12)]; + int32_t *dl_ch0 = &dl_ch_estimates[aarx][validDmrsEst * frame_parms->ofdm_symbol_size]; + int32_t *dl_ch0_ext = &dl_ch_estimates_ext[aarx][symbol * nb_rb_pdsch * NR_NB_SC_PER_RB]; + int32_t *rxF_ext = &rxdataF_ext[aarx][symbol * nb_rb_pdsch * NR_NB_SC_PER_RB]; + int32_t *rxF = &rxdataF[aarx][symbol * frame_parms->ofdm_symbol_size]; - rxF_ext = &rxdataF_ext[aarx][symbol*(nb_rb_pdsch*12)]; - rxF = &rxdataF[aarx][(k+(symbol*(frame_parms->ofdm_symbol_size)))]; - - for (rb = 0; rb < nb_rb_pdsch; rb++) { - if (k>=frame_parms->ofdm_symbol_size) { - k = k-frame_parms->ofdm_symbol_size; - rxF = &rxdataF[aarx][(k+(symbol*(frame_parms->ofdm_symbol_size)))]; + if (pilots == 0) { //data symbol only + if (start_re + nb_rb_pdsch * NR_NB_SC_PER_RB <= frame_parms->ofdm_symbol_size) { + memcpy((void*)rxF_ext, (void*)&rxF[start_re], nb_rb_pdsch * NR_NB_SC_PER_RB * sizeof(int32_t)); + } else { + int neg_length = frame_parms->ofdm_symbol_size - start_re; + int pos_length = nb_rb_pdsch * NR_NB_SC_PER_RB - neg_length; + + memcpy((void*)rxF_ext, (void*)&rxF[start_re], neg_length * sizeof(int32_t)); + memcpy((void*)&rxF_ext[neg_length], (void*)rxF, pos_length * sizeof(int32_t)); } - if (pilots==0) { - memcpy((void*)rxF_ext,(void*)rxF,12*sizeof(*rxF_ext)); - memcpy((void*)dl_ch0_ext,(void*)dl_ch0,12*sizeof(*dl_ch0_ext)); - dl_ch0_ext+=12; - rxF_ext+=12; - } else {//the symbol contains DMRS - j=0; - if (config_type==NFAPI_NR_DMRS_TYPE1){ - if (nushift == 0) {//data is multiplexed - for (i = (1-nushift); i<12; i+=2) { - rxF_ext[j]=rxF[i]; - dl_ch0_ext[j]=dl_ch0[i]; - j++; - } - dl_ch0_ext+=6; - rxF_ext+=6; - } - } else {//NFAPI_NR_DMRS_TYPE2 - for (i = (2+nushift); i<6; i++) { - rxF_ext[j]=rxF[i]; - dl_ch0_ext[j]=dl_ch0[i]; - j++; - } - for (i = (8+nushift); i<12; i++) { - rxF_ext[j]=rxF[i]; - dl_ch0_ext[j]=dl_ch0[i]; - j++; - } - dl_ch0_ext+= j; - rxF_ext+= j; + memcpy((void*)dl_ch0_ext, (void*)dl_ch0, nb_rb_pdsch * NR_NB_SC_PER_RB * sizeof(int32_t)); + } + else if (config_type == NFAPI_NR_DMRS_TYPE1){ + if (n_dmrs_cdm_groups == 1) { //data is multiplexed + unsigned short k = start_re; + for (unsigned short j = 0; j < 6*nb_rb_pdsch; j += 3) { + rxF_ext[j] = rxF[k+1]; + rxF_ext[j+1] = rxF[k+3]; + rxF_ext[j+2] = rxF[k+5]; + dl_ch0_ext[j] = dl_ch0[1]; + dl_ch0_ext[j+1] = dl_ch0[3]; + dl_ch0_ext[j+2] = dl_ch0[5]; + dl_ch0 += 6; + k += 6; + if (k >= frame_parms->ofdm_symbol_size) + k -= frame_parms->ofdm_symbol_size; } } - - dl_ch0+=12; - rxF+=12; - k+=12; - if (k>=frame_parms->ofdm_symbol_size) { - k = k-(frame_parms->ofdm_symbol_size); - rxF = &rxdataF[aarx][k+(symbol*(frame_parms->ofdm_symbol_size))]; + } + else {//NFAPI_NR_DMRS_TYPE2 + if (n_dmrs_cdm_groups == 1) { //data is multiplexed + unsigned short k = start_re; + for (unsigned short j = 0; j < 8*nb_rb_pdsch; j += 4) { + rxF_ext[j] = rxF[k+2]; + rxF_ext[j+1] = rxF[k+3]; + rxF_ext[j+2] = rxF[k+4]; + rxF_ext[j+3] = rxF[k+5]; + dl_ch0_ext[j] = dl_ch0[2]; + dl_ch0_ext[j+1] = dl_ch0[3]; + dl_ch0_ext[j+2] = dl_ch0[4]; + dl_ch0_ext[j+3] = dl_ch0[5]; + dl_ch0 += 6; + k += 6; + if (k >= frame_parms->ofdm_symbol_size) + k -= frame_parms->ofdm_symbol_size; + } + } + else if (n_dmrs_cdm_groups == 2) { //data is multiplexed + unsigned short k = start_re; + for (unsigned short j = 0; j < 4*nb_rb_pdsch; j += 2) { + rxF_ext[j] = rxF[k+4]; + rxF_ext[j+1] = rxF[k+5]; + dl_ch0_ext[j] = dl_ch0[4]; + dl_ch0_ext[j+1] = dl_ch0[5]; + dl_ch0 += 6; + k += 6; + if (k >= frame_parms->ofdm_symbol_size) + k -= frame_parms->ofdm_symbol_size; + } } } } - return(nb_rb_pdsch); + + return nb_rb_pdsch; } -unsigned short nr_dlsch_extract_rbs_multiple(int **rxdataF, - int **dl_ch_estimates, - int **rxdataF_ext, - int **dl_ch_estimates_ext, - unsigned char symbol, - uint8_t pilots, - uint8_t config_type, - unsigned short start_rb, - unsigned short nb_rb_pdsch, - uint8_t n_dmrs_cdm_groups, - uint8_t Nl, - NR_DL_FRAME_PARMS *frame_parms, - uint16_t dlDmrsSymbPos) +void nr_dlsch_extract_rbs(int **rxdataF, + int **dl_ch_estimates, + int **rxdataF_ext, + int **dl_ch_estimates_ext, + unsigned char symbol, + uint8_t pilots, + uint8_t config_type, + unsigned short start_rb, + unsigned short nb_rb_pdsch, + uint8_t n_dmrs_cdm_groups, + uint8_t Nl, + NR_DL_FRAME_PARMS *frame_parms, + uint16_t dlDmrsSymbPos, + int chest_time_type) { unsigned short k,rb; @@ -2106,7 +1734,10 @@ unsigned short nr_dlsch_extract_rbs_multiple(int **rxdataF, nushift = (n_dmrs_cdm_groups -1)<<1;//delta in Table 7.4.1.1.2-2 } - validDmrsEst = get_valid_dmrs_idx_for_channel_est(dlDmrsSymbPos,symbol); + if (chest_time_type == 0) + validDmrsEst = get_valid_dmrs_idx_for_channel_est(dlDmrsSymbPos,symbol); + else + validDmrsEst = get_next_dmrs_symbol_in_slot(dlDmrsSymbPos,0,14); // get first dmrs symbol index for (aarx=0; aarxnb_antennas_rx; aarx++) { @@ -2173,7 +1804,6 @@ unsigned short nr_dlsch_extract_rbs_multiple(int **rxdataF, }//rb }//aatx }//aarx - return(nb_rb_pdsch); } void nr_dlsch_detection_mrc(int **rxdataF_comp, @@ -2240,108 +1870,351 @@ void nr_dlsch_detection_mrc(int **rxdataF_comp, #endif } -/* Zero Forcing Rx function: nr_det_HhH() - * +/* Zero Forcing Rx function: nr_a_sum_b() + * Compute the complex addition x=x+y * * */ -void nr_det_HhH(int32_t *after_mf_00,//a - int32_t *after_mf_01,//b - int32_t *after_mf_10,//c - int32_t *after_mf_11,//d - int32_t *det_fin,//1/ad-bc - unsigned short nb_rb, - unsigned char symbol, - int32_t shift) +void nr_a_sum_b(__m128i *input_x, + __m128i *input_y, + unsigned short nb_rb) { - int16_t nr_conjug2[8]__attribute__((aligned(16))) = {1,-1,1,-1,1,-1,1,-1} ; unsigned short rb; - __m128i *after_mf_00_128,*after_mf_01_128, *after_mf_10_128, *after_mf_11_128, ad_re_128, bc_re_128; //ad_im_128, bc_im_128; - __m128i *det_fin_128, det_re_128; //det_im_128, tmp_det0, tmp_det1; - after_mf_00_128 = (__m128i *)after_mf_00; - after_mf_01_128 = (__m128i *)after_mf_01; - after_mf_10_128 = (__m128i *)after_mf_10; - after_mf_11_128 = (__m128i *)after_mf_11; + for (rb=0; rb inv_H_h_H(%d,%d) = %d+j%d \n",rtx,ctx,((short *)a44[ctx*size+rtx])[0],((short *)a44[ctx*size+rtx])[1],ctx,rtx,((short *)inv_H_h_H[rtx*size+ctx])[0],((short *)inv_H_h_H[rtx*size+ctx])[1]); + } + } + _mm_empty(); + _m_empty(); + } + else {//floating point calc. + //Allocate the submatrix elements + double complex sub_matrix_cpx[(size-1)*(size-1)]; + //Convert the IQ samples (in Q15 format) to float complex + double complex a44_cpx[size*size]; + double complex inv_H_h_H_cpx[size*size]; + double complex determin_cpx; + for (int i=0; i<12*nb_rb; i++) { + + //Convert Q15 to floating point + for (int rtx=0;rtx0) {//determin of the symmetric matrix is real part only + ((short*) ad_bc)[i<<1] = (short) ((creal(determin_cpx)*(1<<(shift0)))+0.5);// + //((short*) ad_bc)[(i<<1)+1] = (short) ((cimag(determin_cpx)*(1<<(shift0)))+0.5);// + } else { + ((short*) ad_bc)[i<<1] = (short) ((creal(determin_cpx)*(1<<(shift0)))-0.5);// + //((short*) ad_bc)[(i<<1)+1] = (short) ((cimag(determin_cpx)*(1<<(shift0)))-0.5);// + } + //if (i<4) printf("nr_det_FP= %d+j%d \n",((short*) ad_bc)[i<<1],((short*) ad_bc)[(i<<1)+1]); + //Compute Inversion of the H^*H matrix (normalized output divide by determinant) + for (int rtx=0;rtx inv_H_h_H(%d,%d) = %lf+j%lf \n",rtx,ctx,creal(a44_cpx[ctx*size+rtx]),cimag(a44_cpx[ctx*size+rtx]),ctx,rtx,creal(inv_H_h_H_cpx[rtx*size+ctx]),cimag(inv_H_h_H_cpx[rtx*size+ctx])); + + if (creal(inv_H_h_H_cpx[rtx*size+ctx])>0) + ((short *) inv_H_h_H[rtx*size+ctx])[i<<1] = (short) ((creal(inv_H_h_H_cpx[rtx*size+ctx])*(1<<(shift0-1)))+0.5);//Convert to Q 18 + else + ((short *) inv_H_h_H[rtx*size+ctx])[i<<1] = (short) ((creal(inv_H_h_H_cpx[rtx*size+ctx])*(1<<(shift0-1)))-0.5);// + + if (cimag(inv_H_h_H_cpx[rtx*size+ctx])>0) + ((short *) inv_H_h_H[rtx*size+ctx])[(i<<1)+1] = (short) ((cimag(inv_H_h_H_cpx[rtx*size+ctx])*(1<<(shift0-1)))+0.5);// + else + ((short *) inv_H_h_H[rtx*size+ctx])[(i<<1)+1] = (short) ((cimag(inv_H_h_H_cpx[rtx*size+ctx])*(1<<(shift0-1)))-0.5);// + + //if (i<4) printf("inv_H_h_H_FP(%d,%d)= %d+j%d \n",ctx,rtx, ((short *) inv_H_h_H[rtx*size+ctx])[i<<1],((short *) inv_H_h_H[rtx*size+ctx])[(i<<1)+1]); + } + } + } + } + return(0); } /* Zero Forcing Rx function: nr_conjch0_mult_ch1() @@ -2390,452 +2263,122 @@ void nr_conjch0_mult_ch1(int *ch0, _mm_empty(); _m_empty(); } -__m128i nr_comp_muli_sum(__m128i input_x, - __m128i input_y, - __m128i input_w, - __m128i input_z, - __m128i det) -{ - int16_t nr_conjug2[8]__attribute__((aligned(16))) = {1,-1,1,-1,1,-1,1,-1} ; - __m128i xy_re_128, xy_im_128, wz_re_128, wz_im_128; - __m128i output, tmp_z0, tmp_z1; - - // complex multiplication (x_re + jx_im)*(y_re + jy_im) = (x_re*y_re - x_im*y_im) + j(x_im*y_re + x_re*y_im) - // the real part - xy_re_128 = _mm_sign_epi16(input_x,*(__m128i*)&nr_conjug2[0]); - xy_re_128 = _mm_madd_epi16(xy_re_128,input_y); //Re: (x_re*y_re - x_im*y_im) - - // the imag part - xy_im_128 = _mm_shufflelo_epi16(input_x,_MM_SHUFFLE(2,3,0,1));//permutes IQs for the low 64 bits as [I_a0 Q_a1 I_a2 Q_a3]_64bits to [Q_a1 I_a0 Q_a3 I_a2]_64bits - xy_im_128 = _mm_shufflehi_epi16(xy_im_128,_MM_SHUFFLE(2,3,0,1));//permutes IQs for the high 64 bits as [I_a0 Q_a1 I_a2 Q_a3]_64bits to [Q_a1 I_a0 Q_a3 I_a2]_64bits - xy_im_128 = _mm_madd_epi16(xy_im_128,input_y);//Im: (x_im*y_re + x_re*y_im) - - // complex multiplication (w_re + jw_im)*(z_re + jz_im) = (w_re*z_re - w_im*z_im) + j(w_im*z_re + w_re*z_im) - // the real part - wz_re_128 = _mm_sign_epi16(input_w,*(__m128i*)&nr_conjug2[0]); - wz_re_128 = _mm_madd_epi16(wz_re_128,input_z); //Re: (w_re*z_re - w_im*z_im) - - // the imag part - wz_im_128 = _mm_shufflelo_epi16(input_w,_MM_SHUFFLE(2,3,0,1));//permutes IQs for the low 64 bits as [I_a0 Q_a1 I_a2 Q_a3]_64bits to [Q_a1 I_a0 Q_a3 I_a2]_64bits - wz_im_128 = _mm_shufflehi_epi16(wz_im_128,_MM_SHUFFLE(2,3,0,1));//permutes IQs for the high 64 bits as [I_a0 Q_a1 I_a2 Q_a3]_64bits to [Q_a1 I_a0 Q_a3 I_a2]_64bits - wz_im_128 = _mm_madd_epi16(wz_im_128,input_z);//Im: (w_im*z_re + w_re*z_im) - - - xy_re_128 = _mm_sub_epi32(xy_re_128, wz_re_128); - xy_im_128 = _mm_sub_epi32(xy_im_128, wz_im_128); - //print_ints("rx_re:",(int32_t*)&xy_re_128[0]); - //print_ints("rx_Img:",(int32_t*)&xy_im_128[0]); - //divide by matrix det and convert back to Q15 before packing - int sum_det =0; - for (int k=0; k<4;k++) { - sum_det += ((((int *)&det[0])[k])>>2); - //printf("det_%d = %d log2 =%d \n",k,(((int *)&det[0])[k]),log2_approx(((int *)&det[0])[k])); - } - - xy_re_128 = _mm_slli_epi32(xy_re_128,5); - xy_re_128 = _mm_srai_epi32(xy_re_128,log2_approx(sum_det)); - xy_re_128 = _mm_slli_epi32(xy_re_128,5); - - xy_im_128 = _mm_slli_epi32(xy_im_128,5); - xy_im_128 = _mm_srai_epi32(xy_im_128,log2_approx(sum_det)); - xy_im_128 = _mm_slli_epi32(xy_im_128,5); - - tmp_z0 = _mm_unpacklo_epi32(xy_re_128,xy_im_128); - //print_ints("unpack lo:",&tmp_z0[0]); - tmp_z1 = _mm_unpackhi_epi32(xy_re_128,xy_im_128); - //print_ints("unpack hi:",&tmp_z1[0]); - output = _mm_packs_epi32(tmp_z0,tmp_z1); - - _mm_empty(); - _m_empty(); - return(output); -} -/* Zero Forcing Rx function: nr_construct_HhH_elements() +/* Zero Forcing Rx function: up to 4 layers * * * */ -void nr_construct_HhH_elements(int *conjch00_ch00, - int *conjch01_ch01, - int *conjch11_ch11, - int *conjch10_ch10,// - int *conjch20_ch20, - int *conjch21_ch21, - int *conjch30_ch30, - int *conjch31_ch31, - int *conjch00_ch01,//00_01 - int *conjch01_ch00,//01_00 - int *conjch10_ch11,//10_11 - int *conjch11_ch10,//11_10 - int *conjch20_ch21, - int *conjch21_ch20, - int *conjch30_ch31, - int *conjch31_ch30, - int32_t *after_mf_00, - int32_t *after_mf_01, - int32_t *after_mf_10, - int32_t *after_mf_11, - unsigned short nb_rb, - unsigned char symbol) +uint8_t nr_zero_forcing_rx(int **rxdataF_comp, + int **dl_ch_mag, + int **dl_ch_magb, + int **dl_ch_magr, + int **dl_ch_estimates_ext, + unsigned short nb_rb, + unsigned char n_rx, + unsigned char n_tx,//number of layer + unsigned char mod_order, + int shift, + unsigned char symbol, + int length) { - //This function is used to construct the (H_hermitian * H matrix) matrix elements - unsigned short rb; - __m128i *conjch00_ch00_128, *conjch01_ch01_128, *conjch11_ch11_128, *conjch10_ch10_128; - __m128i *conjch20_ch20_128, *conjch21_ch21_128, *conjch30_ch30_128, *conjch31_ch31_128; - __m128i *conjch00_ch01_128, *conjch01_ch00_128, *conjch10_ch11_128, *conjch11_ch10_128; - __m128i *conjch20_ch21_128, *conjch21_ch20_128, *conjch30_ch31_128, *conjch31_ch30_128; - __m128i *after_mf_00_128, *after_mf_01_128, *after_mf_10_128, *after_mf_11_128; - - conjch00_ch00_128 = (__m128i *)conjch00_ch00; - conjch01_ch01_128 = (__m128i *)conjch01_ch01; - conjch11_ch11_128 = (__m128i *)conjch11_ch11; - conjch10_ch10_128 = (__m128i *)conjch10_ch10; - - conjch20_ch20_128 = (__m128i *)conjch20_ch20; - conjch21_ch21_128 = (__m128i *)conjch21_ch21; - conjch30_ch30_128 = (__m128i *)conjch30_ch30; - conjch31_ch31_128 = (__m128i *)conjch31_ch31; - - conjch00_ch01_128 = (__m128i *)conjch00_ch01; - conjch01_ch00_128 = (__m128i *)conjch01_ch00; - conjch10_ch11_128 = (__m128i *)conjch10_ch11; - conjch11_ch10_128 = (__m128i *)conjch11_ch10; - - conjch20_ch21_128 = (__m128i *)conjch20_ch21; - conjch21_ch20_128 = (__m128i *)conjch21_ch20; - conjch30_ch31_128 = (__m128i *)conjch30_ch31; - conjch31_ch30_128 = (__m128i *)conjch31_ch30; - - after_mf_00_128 = (__m128i *)after_mf_00; - after_mf_01_128 = (__m128i *)after_mf_01; - after_mf_10_128 = (__m128i *)after_mf_10; - after_mf_11_128 = (__m128i *)after_mf_11; - - for (rb=0; rb<3*nb_rb; rb++) { - - after_mf_00_128[0] =_mm_adds_epi16(conjch00_ch00_128[0],conjch10_ch10_128[0]);//00_00 + 10_10 - if (conjch20_ch20 != NULL) after_mf_00_128[0] =_mm_adds_epi16(after_mf_00_128[0],conjch20_ch20_128[0]); - if (conjch30_ch30 != NULL) after_mf_00_128[0] =_mm_adds_epi16(after_mf_00_128[0],conjch30_ch30_128[0]); - - after_mf_11_128[0] =_mm_adds_epi16(conjch01_ch01_128[0], conjch11_ch11_128[0]); //01_01 + 11_11 - if (conjch21_ch21 != NULL) after_mf_11_128[0] =_mm_adds_epi16(after_mf_11_128[0],conjch21_ch21_128[0]); - if (conjch31_ch31 != NULL) after_mf_11_128[0] =_mm_adds_epi16(after_mf_11_128[0],conjch31_ch31_128[0]); - - after_mf_01_128[0] =_mm_adds_epi16(conjch00_ch01_128[0], conjch10_ch11_128[0]);//00_01 + 10_11 - if (conjch20_ch21 != NULL) after_mf_01_128[0] =_mm_adds_epi16(after_mf_01_128[0],conjch20_ch21_128[0]); - if (conjch30_ch31 != NULL) after_mf_01_128[0] =_mm_adds_epi16(after_mf_01_128[0],conjch30_ch31_128[0]); - - after_mf_10_128[0] =_mm_adds_epi16(conjch01_ch00_128[0], conjch11_ch10_128[0]);//01_00 + 11_10 - if (conjch21_ch20 != NULL) after_mf_10_128[0] =_mm_adds_epi16(after_mf_10_128[0],conjch21_ch20_128[0]); - if (conjch31_ch30 != NULL) after_mf_10_128[0] =_mm_adds_epi16(after_mf_10_128[0],conjch31_ch30_128[0]); - -#ifdef DEBUG_DLSCH_DEMOD - if ((rb<=30)) - { - printf(" \n construct_HhH_elements \n"); - print_shorts("after_mf_00_128:",(int16_t*)&after_mf_00_128[0]); - print_shorts("after_mf_01_128:",(int16_t*)&after_mf_01_128[0]); - print_shorts("after_mf_10_128:",(int16_t*)&after_mf_10_128[0]); - print_shorts("after_mf_11_128:",(int16_t*)&after_mf_11_128[0]); - } -#endif - conjch00_ch00_128+=1; - conjch10_ch10_128+=1; - conjch01_ch01_128+=1; - conjch11_ch11_128+=1; - - if (conjch20_ch20 != NULL) conjch20_ch20_128+=1; - if (conjch21_ch21 != NULL) conjch21_ch21_128+=1; - if (conjch30_ch30 != NULL) conjch30_ch30_128+=1; - if (conjch31_ch31 != NULL) conjch31_ch31_128+=1; - - conjch00_ch01_128+=1; - conjch01_ch00_128+=1; - conjch10_ch11_128+=1; - conjch11_ch10_128+=1; - - if (conjch20_ch21 != NULL) conjch20_ch21_128+=1; - if (conjch21_ch20 != NULL) conjch21_ch20_128+=1; - if (conjch30_ch31 != NULL) conjch30_ch31_128+=1; - if (conjch31_ch30 != NULL) conjch31_ch30_128+=1; - - after_mf_00_128 += 1; - after_mf_01_128 += 1; - after_mf_10_128 += 1; - after_mf_11_128 += 1; - } - _mm_empty(); - _m_empty(); -} - -/* Zero Forcing Rx function: nr_zero_forcing_rx_2layers() - * - * - * */ -uint8_t nr_zero_forcing_rx_2layers(int **rxdataF_comp, - int **dl_ch_mag, - int **dl_ch_magb, - int **dl_ch_magr, - int **dl_ch_estimates_ext, - unsigned short nb_rb, - unsigned char n_rx, - unsigned char mod_order, - int shift, - unsigned char symbol, - int length) -{ - int *ch00, *ch01, *ch10, *ch11; - int *ch20, *ch30, *ch21, *ch31; + int *ch0r, *ch0c; + int32_t *** conjH_H_elements; uint32_t nb_rb_0 = length/12 + ((length%12)?1:0); - /* we need at least alignment to 16 bytes, let's put 32 to be sure - * (maybe not necessary but doesn't hurt) - */ - int32_t conjch00_ch01[12*nb_rb] __attribute__((aligned(32))); - int32_t conjch01_ch00[12*nb_rb] __attribute__((aligned(32))); - int32_t conjch10_ch11[12*nb_rb] __attribute__((aligned(32))); - int32_t conjch11_ch10[12*nb_rb] __attribute__((aligned(32))); - int32_t conjch00_ch00[12*nb_rb] __attribute__((aligned(32))); - int32_t conjch01_ch01[12*nb_rb] __attribute__((aligned(32))); - int32_t conjch10_ch10[12*nb_rb] __attribute__((aligned(32))); - int32_t conjch11_ch11[12*nb_rb] __attribute__((aligned(32))); - int32_t conjch20_ch20[12*nb_rb] __attribute__((aligned(32))); - int32_t conjch21_ch21[12*nb_rb] __attribute__((aligned(32))); - int32_t conjch30_ch30[12*nb_rb] __attribute__((aligned(32))); - int32_t conjch31_ch31[12*nb_rb] __attribute__((aligned(32))); - int32_t conjch20_ch21[12*nb_rb] __attribute__((aligned(32))); - int32_t conjch30_ch31[12*nb_rb] __attribute__((aligned(32))); - int32_t conjch21_ch20[12*nb_rb] __attribute__((aligned(32))); - int32_t conjch31_ch30[12*nb_rb] __attribute__((aligned(32))); + int32_t determ_fin[12*nb_rb_0] __attribute__((aligned(32))); - int32_t af_mf_00[12*nb_rb] __attribute__((aligned(32))); - int32_t af_mf_01[12*nb_rb] __attribute__((aligned(32))); - int32_t af_mf_10[12*nb_rb] __attribute__((aligned(32))); - int32_t af_mf_11[12*nb_rb] __attribute__((aligned(32))); - int32_t determ_fin[12*nb_rb] __attribute__((aligned(32))); - - switch (n_rx) { - case 2:// - ch00 = (int *)&dl_ch_estimates_ext[0][symbol*nb_rb*12]; - ch01 = (int *)&dl_ch_estimates_ext[2][symbol*nb_rb*12]; - ch10 = (int *)&dl_ch_estimates_ext[1][symbol*nb_rb*12]; - ch11 = (int *)&dl_ch_estimates_ext[3][symbol*nb_rb*12]; - ch20 = NULL; - ch21 = NULL; - ch30 = NULL; - ch31 = NULL; - break; - - case 4:// - ch00 = (int *)&dl_ch_estimates_ext[0][symbol*nb_rb*12]; - ch01 = (int *)&dl_ch_estimates_ext[4][symbol*nb_rb*12]; - ch10 = (int *)&dl_ch_estimates_ext[1][symbol*nb_rb*12]; - ch11 = (int *)&dl_ch_estimates_ext[5][symbol*nb_rb*12]; - ch20 = (int *)&dl_ch_estimates_ext[2][symbol*nb_rb*12]; - ch21 = (int *)&dl_ch_estimates_ext[6][symbol*nb_rb*12]; - ch30 = (int *)&dl_ch_estimates_ext[3][symbol*nb_rb*12]; - ch31 = (int *)&dl_ch_estimates_ext[7][symbol*nb_rb*12]; - break; - - default: - return -1; - break; + ///Allocate H^*H matrix elements and sub elements + conjH_H_elements = (int32_t ***)malloc16_clear( n_rx*sizeof(int32_t **) ); + for (int aarx=0;aarx=2){ - // (1/2^log2_maxh)*conj_H_00xH_00: (1/(64*2))conjH_00*H_00*2^15 - nr_conjch0_mult_ch1(ch00, - ch00, - conjch00_ch00, - nb_rb_0, - shift); - // (1/2^log2_maxh)*conj_H_10xH_10: (1/(64*2))conjH_10*H_10*2^15 - nr_conjch0_mult_ch1(ch10, - ch10, - conjch10_ch10, - nb_rb_0, - shift); - // conj_H_00xH_01 - nr_conjch0_mult_ch1(ch00, - ch01, - conjch00_ch01, - nb_rb_0, - shift); // this shift is equal to the channel level log2_maxh - // conj_H_10xH_11 - nr_conjch0_mult_ch1(ch10, - ch11, - conjch10_ch11, - nb_rb_0, - shift); - // conj_H_01xH_01 - nr_conjch0_mult_ch1(ch01, - ch01, - conjch01_ch01, - nb_rb_0, - shift); - // conj_H_11xH_11 - nr_conjch0_mult_ch1(ch11, - ch11, - conjch11_ch11, - nb_rb_0, - shift); - // conj_H_01xH_00 - nr_conjch0_mult_ch1(ch01, - ch00, - conjch01_ch00, - nb_rb_0, - shift); - // conj_H_11xH_10 - nr_conjch0_mult_ch1(ch11, - ch10, - conjch11_ch10, - nb_rb_0, - shift); + //Compute H^*H matrix elements and sub elements:(1/2^log2_maxh)*conjH_H_elements + for (int rtx=0;rtxllr_offset[symbol-1] = 0; + if (first_symbol_flag==1) + pdsch_vars[gNB_id]->llr_offset[symbol-1] = 0; llr_offset_symbol = pdsch_vars[gNB_id]->llr_offset[symbol-1]; - //pllr_symbol_cw0_deint = (int8_t*)pdsch_vars[gNB_id]->llr[0]; - //pllr_symbol_cw1_deint = (int8_t*)pdsch_vars[gNB_id]->llr[1]; - pllr_symbol_layer0 = pdsch_vars[gNB_id]->layer_llr[0]; - pllr_symbol_layer1 = pdsch_vars[gNB_id]->layer_llr[1]; - pllr_symbol_layer0 += llr_offset_symbol; - pllr_symbol_layer1 += llr_offset_symbol; - pllr_symbol_cw0 = pdsch_vars[gNB_id]->llr[0]; - pllr_symbol_cw1 = pdsch_vars[gNB_id]->llr[1]; - pllr_symbol_cw0 += llr_offset_symbol; - pllr_symbol_cw1 += llr_offset_symbol; - + pdsch_vars[gNB_id]->llr_offset[symbol] = len*dlsch0_harq->Qm + llr_offset_symbol; /*LOG_I(PHY,"compute LLRs [symbol %d] NbRB %d Qm %d LLRs-Length %d LLR-Offset %d @LLR Buff %x @LLR Buff(symb) %x\n", @@ -3020,14 +2501,6 @@ static int nr_dlsch_llr(NR_UE_PDSCH **pdsch_vars, pdsch_vars[gNB_id]->llr_offset[symbol], (int16_t*)pdsch_vars[gNB_id]->llr[0], pllr_symbol_cw0);*/ - - /*printf("compute LLRs [symbol %d] NbRB %d Qm %d LLRs-Length %d LLR-Offset %d @LLR Buff %p @LLR Buff(symb) %p\n", - symbol, - nb_rb,dlsch0_harq->Qm, - pdsch_vars[gNB_id]->llr_length[symbol], - pdsch_vars[gNB_id]->llr_offset[symbol], - pdsch_vars[gNB_id]->llr[0], - pllr_symbol_cw0);*/ switch (dlsch0_harq->Qm) { case 2 : @@ -3043,27 +2516,14 @@ static int nr_dlsch_llr(NR_UE_PDSCH **pdsch_vars, nb_rb, beamforming_mode); break; - case rx_IC_single_stream ://not implemented yet - /*nr_dlsch_qpsk_qpsk_llr(frame_parms, - pdsch_vars[gNB_id]->rxdataF_comp0, - rxdataF_comp_ptr, - pdsch_vars[gNB_id]->dl_ch_rho2_ext, - pdsch_vars[gNB_id]->layer_llr[0], - symbol,len,first_symbol_flag,nb_rb, - adjust_G2(frame_parms,dlsch0_harq->rb_alloc_even,2,nr_slot_rx,symbol), - pdsch_vars[gNB_id]->llr128);*/ + case rx_IC_single_stream ://From LTE Code!! + //not implemented yet break; - case rx_IC_dual_stream ://not implemented yet - /*nr_dlsch_qpsk_qpsk_llr(frame_parms, - rxdataF_comp_ptr, - pdsch_vars[gNB_id]->rxdataF_comp0, - pdsch_vars[gNB_id]->dl_ch_rho_ext[harq_pid][round], - pdsch_vars[gNB_id]->layer_llr[1], - symbol,len,first_symbol_flag,nb_rb, - adjust_G2(frame_parms,dlsch1_harq->rb_alloc_even,2,nr_slot_rx,symbol), - pdsch_vars[gNB_id]->llr128_2ndstream);*/ + case rx_IC_dual_stream : + //not implemented yet break; - case rx_SIC_dual_stream ://not implemented yet + case rx_SIC_dual_stream : + //not implemented yet break; } break; @@ -3144,7 +2604,7 @@ static int nr_dlsch_llr(NR_UE_PDSCH **pdsch_vars, } if (dlsch1_harq) { - switch (nr_get_Qm_dl(dlsch1_harq->mcs,dlsch1_harq->mcs_table)) { + switch (dlsch1_harq->Qm) { case 2 : if (rx_type==rx_standard) { nr_dlsch_qpsk_llr(frame_parms, diff --git a/openair1/PHY/NR_UE_TRANSPORT/nr_initial_sync.c b/openair1/PHY/NR_UE_TRANSPORT/nr_initial_sync.c index d7b1a030c9..5f3af5bb39 100644 --- a/openair1/PHY/NR_UE_TRANSPORT/nr_initial_sync.c +++ b/openair1/PHY/NR_UE_TRANSPORT/nr_initial_sync.c @@ -101,7 +101,7 @@ void free_list(NR_UE_SSB *node) { } -int nr_pbch_detection(UE_nr_rxtx_proc_t * proc, PHY_VARS_NR_UE *ue, int pbch_initial_symbol) +int nr_pbch_detection(UE_nr_rxtx_proc_t * proc, PHY_VARS_NR_UE *ue, int pbch_initial_symbol, NR_UE_PDCCH_CONFIG *phy_pdcch_config) { NR_DL_FRAME_PARMS *frame_parms=&ue->frame_parms; int ret =-1; @@ -146,17 +146,27 @@ int nr_pbch_detection(UE_nr_rxtx_proc_t * proc, PHY_VARS_NR_UE *ue, int pbch_ini start_meas(&ue->dlsch_channel_estimation_stats); // computing channel estimation for selected best ssb - for(int i=pbch_initial_symbol; ii_ssb,temp_ptr->n_hf); - stop_meas(&ue->dlsch_channel_estimation_stats); + const int estimateSz = frame_parms->symbols_per_slot * frame_parms->ofdm_symbol_size; + __attribute__ ((aligned(32))) struct complex16 dl_ch_estimates[frame_parms->nb_antennas_rx][estimateSz]; + __attribute__ ((aligned(32))) struct complex16 dl_ch_estimates_time[frame_parms->nb_antennas_rx][frame_parms->ofdm_symbol_size]; + for(int i=pbch_initial_symbol; ii_ssb,temp_ptr->n_hf); + + stop_meas(&ue->dlsch_channel_estimation_stats); + fapiPbch_t result; ret = nr_rx_pbch(ue, proc, + estimateSz, + dl_ch_estimates, ue->pbch_vars[0], frame_parms, 0, temp_ptr->i_ssb, - SISO); + SISO, + phy_pdcch_config, + &result); temp_ptr=temp_ptr->next_ssb; } @@ -206,6 +216,8 @@ int nr_initial_sync(UE_nr_rxtx_proc_t *proc, NR_DL_FRAME_PARMS *fp = &ue->frame_parms; int ret=-1; int rx_power=0; //aarx, + + NR_UE_PDCCH_CONFIG phy_pdcch_config={0}; VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_NR_INITIAL_UE_SYNC, VCD_FUNCTION_IN); @@ -296,7 +308,7 @@ int nr_initial_sync(UE_nr_rxtx_proc_t *proc, #endif int freq_offset_sss = 0; - rx_sss_nr(ue, proc, &metric_tdd_ncp, &phase_tdd_ncp, &freq_offset_sss); + ret = rx_sss_nr(ue, proc, &metric_tdd_ncp, &phase_tdd_ncp, &freq_offset_sss); accumulated_freq_offset += freq_offset_sss; @@ -324,8 +336,10 @@ int nr_initial_sync(UE_nr_rxtx_proc_t *proc, } } - nr_gold_pbch(ue); - ret = nr_pbch_detection(proc, ue, 1); // start pbch detection at first symbol after pss + if (ret==0) { //we got sss channel + nr_gold_pbch(ue); + ret = nr_pbch_detection(proc, ue, 1, &phy_pdcch_config); // start pbch detection at first symbol after pss + } if (ret == 0) { // sync at symbol ue->symbol_offset @@ -343,15 +357,19 @@ int nr_initial_sync(UE_nr_rxtx_proc_t *proc, nr_gold_pdcch(ue,fp->Nid_cell); // compute the scrambling IDs for PDSCH DMRS - for (int i=0; i<2; i++) - ue->scramblingID[i]=fp->Nid_cell; + for (int i=0; iscramblingID_dlsch[i]=fp->Nid_cell; + nr_gold_pdsch(ue, i, ue->scramblingID_dlsch[i]); + } - nr_gold_pdsch(ue,ue->scramblingID); + nr_init_csi_rs(fp, ue->nr_csi_rs_info->nr_gold_csi_rs, fp->Nid_cell); // initialize the pusch dmrs - uint16_t N_n_scid[2] = {fp->Nid_cell,fp->Nid_cell}; - int n_scid = 0; // This quantity is indicated by higher layer parameter dmrs-SeqInitialization - nr_init_pusch_dmrs(ue, N_n_scid, n_scid); + for (int i=0; iscramblingID_ulsch[i]=fp->Nid_cell; + nr_init_pusch_dmrs(ue, ue->scramblingID_ulsch[i], i); + } + // we also need to take into account the shift by samples_per_frame in case the if is true if (ue->ssb_offset < sync_pos_frame){ @@ -520,33 +538,40 @@ int nr_initial_sync(UE_nr_rxtx_proc_t *proc, // if stand alone and sync on ssb do sib1 detection as part of initial sync if (sa==1 && ret==0) { bool dec = false; - NR_UE_PDCCH *pdcch_vars = ue->pdcch_vars[proc->thread_id][0]; int gnb_id = 0; //FIXME int coreset_nb_rb=0; int coreset_start_rb=0; - for(int n_ss = 0; n_ssnb_search_space; n_ss++) { - uint8_t nb_symb_pdcch = pdcch_vars->pdcch_config[n_ss].coreset.duration; - int start_symb = pdcch_vars->pdcch_config[n_ss].coreset.StartSymbolIndex; - get_coreset_rballoc(pdcch_vars->pdcch_config[n_ss].coreset.frequency_domain_resource,&coreset_nb_rb,&coreset_start_rb); + // Hold the channel estimates in frequency domain. + int32_t pdcch_est_size = ((((fp->symbols_per_slot*(fp->ofdm_symbol_size+LTE_CE_FILTER_LENGTH))+15)/16)*16); + __attribute__ ((aligned(16))) int32_t pdcch_dl_ch_estimates[4*fp->nb_antennas_rx][pdcch_est_size]; + + + for(int n_ss = 0; n_ssslot, - is*fp->samples_per_frame+pdcch_vars->sfn*fp->samples_per_frame+ue->rx_offset); + phy_pdcch_config.slot, + is*fp->samples_per_frame+phy_pdcch_config.sfn*fp->samples_per_frame+ue->rx_offset); if (coreset_nb_rb > 0) nr_pdcch_channel_estimation(ue, proc, 0, - pdcch_vars->slot, + phy_pdcch_config.slot, l, - fp->first_carrier_offset+(pdcch_vars->pdcch_config[n_ss].BWPStart + coreset_start_rb)*12, - coreset_nb_rb); + fp->Nid_cell, + fp->first_carrier_offset+(phy_pdcch_config.pdcch_config[n_ss].BWPStart + coreset_start_rb)*12, + coreset_nb_rb, + pdcch_est_size, + pdcch_dl_ch_estimates); } - int dci_cnt = nr_ue_pdcch_procedures(gnb_id, ue, proc, n_ss); + int dci_cnt = nr_ue_pdcch_procedures(gnb_id, ue, proc, pdcch_est_size, pdcch_dl_ch_estimates, &phy_pdcch_config, n_ss); if (dci_cnt>0){ NR_UE_DLSCH_t *dlsch = ue->dlsch_SI[gnb_id]; if (dlsch && (dlsch->active == 1)) { @@ -559,8 +584,8 @@ int nr_initial_sync(UE_nr_rxtx_proc_t *proc, nr_slot_fep_init_sync(ue, proc, m, - pdcch_vars->slot, // same slot and offset as pdcch - is*fp->samples_per_frame+pdcch_vars->sfn*fp->samples_per_frame+ue->rx_offset); + phy_pdcch_config.slot, // same slot and offset as pdcch + is*fp->samples_per_frame+phy_pdcch_config.sfn*fp->samples_per_frame+ue->rx_offset); } int ret = nr_ue_pdsch_procedures(ue, diff --git a/openair1/PHY/NR_UE_TRANSPORT/nr_pbch.c b/openair1/PHY/NR_UE_TRANSPORT/nr_pbch.c index 6b5185dc2c..78e4a8a4e8 100644 --- a/openair1/PHY/NR_UE_TRANSPORT/nr_pbch.c +++ b/openair1/PHY/NR_UE_TRANSPORT/nr_pbch.c @@ -36,28 +36,30 @@ #include "PHY/LTE_REFSIG/lte_refsig.h" #include "PHY/INIT/phy_init.h" #include "openair1/SCHED_NR_UE/defs.h" +#include +#include -//#define DEBUG_PBCH +//#define DEBUG_PBCH //#define DEBUG_PBCH_ENCODING - //#include "PHY_INTERFACE/defs.h" +//#include "PHY_INTERFACE/defs.h" #define PBCH_A 24 - +#define PBCH_MAX_RE_PER_SYMBOL (20*12) +#define PBCH_MAX_RE (PBCH_MAX_RE_PER_SYMBOL*4) #define print_shorts(s,x) printf("%s : %d,%d,%d,%d,%d,%d,%d,%d\n",s,((int16_t*)x)[0],((int16_t*)x)[1],((int16_t*)x)[2],((int16_t*)x)[3],((int16_t*)x)[4],((int16_t*)x)[5],((int16_t*)x)[6],((int16_t*)x)[7]) -uint16_t nr_pbch_extract(int **rxdataF, - int **dl_ch_estimates, - int **rxdataF_ext, - int **dl_ch_estimates_ext, - uint32_t symbol, - uint32_t s_offset, - NR_DL_FRAME_PARMS *frame_parms) { +static uint16_t nr_pbch_extract(int **rxdataF, + const int estimateSz, + struct complex16 dl_ch_estimates[][estimateSz], + struct complex16 rxdataF_ext[][PBCH_MAX_RE_PER_SYMBOL], + struct complex16 dl_ch_estimates_ext[][PBCH_MAX_RE_PER_SYMBOL], + uint32_t symbol, + uint32_t s_offset, + NR_DL_FRAME_PARMS *frame_parms) { uint16_t rb; uint8_t i,j,aarx; - int32_t *dl_ch0,*dl_ch0_ext,*rxF,*rxF_ext; int nushiftmod4 = frame_parms->nushift; - AssertFatal(symbol>=1 && symbol<5, "symbol %d illegal for PBCH extraction\n", symbol); @@ -65,9 +67,8 @@ uint16_t nr_pbch_extract(int **rxdataF, for (aarx=0; aarxnb_antennas_rx; aarx++) { unsigned int rx_offset = frame_parms->first_carrier_offset + frame_parms->ssb_start_subcarrier; rx_offset = (rx_offset)%(frame_parms->ofdm_symbol_size); - - rxF = &rxdataF[aarx][(symbol+s_offset)*frame_parms->ofdm_symbol_size]; - rxF_ext = &rxdataF_ext[aarx][symbol*20*12]; + struct complex16 *rxF = (struct complex16 *)&rxdataF[aarx][(symbol+s_offset)*frame_parms->ofdm_symbol_size]; + struct complex16 *rxF_ext = rxdataF_ext[aarx]; #ifdef DEBUG_PBCH printf("extract_rbs (nushift %d): rx_offset=%d, symbol %u\n",frame_parms->nushift, (rx_offset + ((symbol+s_offset)*(frame_parms->ofdm_symbol_size))),symbol); @@ -76,7 +77,6 @@ uint16_t nr_pbch_extract(int **rxdataF, for (int i =0; i<8; i++) { printf("rxF [%d]= %d\n",i,rxF[i]); printf("pbch extract rxF %d %d addr %p\n", p[2*i], p[2*i+1], &p[2*i]); - printf("rxF ext addr %p\n", &rxF_ext[i]); } #endif @@ -91,19 +91,18 @@ uint16_t nr_pbch_extract(int **rxdataF, (i!=(nushiftmod4+8))) { rxF_ext[j]=rxF[rx_offset]; #ifdef DEBUG_PBCH - printf("rxF ext[%d] = (%d,%d) rxF [%u]= (%d,%d)\n",(9*rb) + j, - ((int16_t *)&rxF_ext[j])[0], - ((int16_t *)&rxF_ext[j])[1], + printf("rxF ext[%d] = (%d,%d) rxF [%u]= (%d,%d)\n", + (9*rb) + j, + rxF_ext[j].r, rxF_ext[j].i, rx_offset, - ((int16_t *)&rxF[rx_offset])[0], - ((int16_t *)&rxF[rx_offset])[1]); + rxF[rx_offset].r,rxF[rx_offset].j; #endif j++; } rx_offset=(rx_offset+1)%(frame_parms->ofdm_symbol_size); //rx_offset = (rx_offset >= frame_parms->ofdm_symbol_size) ? (rx_offset - frame_parms->ofdm_symbol_size + 1) : (rx_offset+1); - } + } rxF_ext+=9; } else { //symbol 2 @@ -115,11 +114,9 @@ uint16_t nr_pbch_extract(int **rxdataF, rxF_ext[j]=rxF[rx_offset]; #ifdef DEBUG_PBCH printf("rxF ext[%d] = (%d,%d) rxF [%u]= (%d,%d)\n",(rb<4) ? (9*rb) + j : (9*(rb-12))+j, - ((int16_t *)&rxF_ext[j])[0], - ((int16_t *)&rxF_ext[j])[1], + rxF_ext[j].r, rxF_ext[j].i, rx_offset, - ((int16_t *)&rxF[rx_offset])[0], - ((int16_t *)&rxF[rx_offset])[1]); + rxF[rx_offset].r,rxF[rx_offset].j; #endif j++; } @@ -129,16 +126,16 @@ uint16_t nr_pbch_extract(int **rxdataF, } rxF_ext+=9; - } else{ //rx_offset = (rx_offset >= frame_parms->ofdm_symbol_size) ? (rx_offset - frame_parms->ofdm_symbol_size + 12) : (rx_offset+12); - rx_offset = (rx_offset+12)%(frame_parms->ofdm_symbol_size); - } + } else { //rx_offset = (rx_offset >= frame_parms->ofdm_symbol_size) ? (rx_offset - frame_parms->ofdm_symbol_size + 12) : (rx_offset+12); + rx_offset = (rx_offset+12)%(frame_parms->ofdm_symbol_size); + } } } - dl_ch0 = &dl_ch_estimates[aarx][((symbol+s_offset)*(frame_parms->ofdm_symbol_size))]; + struct complex16 *dl_ch0 = &dl_ch_estimates[aarx][((symbol+s_offset)*(frame_parms->ofdm_symbol_size))]; //printf("dl_ch0 addr %p\n",dl_ch0); - dl_ch0_ext = &dl_ch_estimates_ext[aarx][symbol*20*12]; + struct complex16 *dl_ch0_ext = dl_ch_estimates_ext[aarx]; for (rb=0; rb<20; rb++) { j=0; @@ -150,15 +147,11 @@ uint16_t nr_pbch_extract(int **rxdataF, (i!=(nushiftmod4+8))) { dl_ch0_ext[j]=dl_ch0[i]; #ifdef DEBUG_PBCH - if ((rb==0) && (i<2)) printf("dl ch0 ext[%d] = (%d,%d) dl_ch0 [%d]= (%d,%d)\n",j, - ((int16_t *)&dl_ch0_ext[j])[0], - ((int16_t *)&dl_ch0_ext[j])[1], + dl_ch0_ext[j].r, dl_ch0_ext[j].i, i, - ((int16_t *)&dl_ch0[i])[0], - ((int16_t *)&dl_ch0[i])[1]); - + dl_ch0[j].r, dl_ch0[j].i, #endif j++; } @@ -175,11 +168,9 @@ uint16_t nr_pbch_extract(int **rxdataF, dl_ch0_ext[j]=dl_ch0[i]; #ifdef DEBUG_PBCH printf("dl ch0 ext[%d] = (%d,%d) dl_ch0 [%d]= (%d,%d)\n",j, - ((int16_t *)&dl_ch0_ext[j])[0], - ((int16_t *)&dl_ch0_ext[j])[1], + dl_ch0_ext[j].r, dl_ch0_ext[j].i, i, - ((int16_t *)&dl_ch0[i])[0], - ((int16_t *)&dl_ch0[i])[1]); + dl_ch0[j].r, dl_ch0[j].i, #endif j++; } @@ -199,11 +190,10 @@ uint16_t nr_pbch_extract(int **rxdataF, //__m128i avg128; //compute average channel_level on each (TX,RX) antenna pair -int nr_pbch_channel_level(int **dl_ch_estimates_ext, +int nr_pbch_channel_level(struct complex16 dl_ch_estimates_ext[][PBCH_MAX_RE_PER_SYMBOL], NR_DL_FRAME_PARMS *frame_parms, - uint32_t symbol) { - int16_t rb, nb_rb=20; - uint8_t aarx; + int nb_re) { + int16_t nb_rb=nb_re/12; #if defined(__x86_64__) || defined(__i386__) __m128i avg128; __m128i *dl_ch128; @@ -213,22 +203,23 @@ int nr_pbch_channel_level(int **dl_ch_estimates_ext, #endif int avg1=0,avg2=0; - for (aarx=0; aarxnb_antennas_rx; aarx++) { + for (int aarx=0; aarxnb_antennas_rx; aarx++) { //clear average level #if defined(__x86_64__) || defined(__i386__) avg128 = _mm_setzero_si128(); - dl_ch128=(__m128i *)&dl_ch_estimates_ext[aarx][symbol*20*12]; + dl_ch128=(__m128i *)dl_ch_estimates_ext[aarx]; #elif defined(__arm__) avg128 = vdupq_n_s32(0); - dl_ch128=(int16x8_t *)&dl_ch_estimates_ext[aarx][symbol*20*12]; + dl_ch128=(int16x8_t *)dl_ch_estimates_ext[aarx]; #endif - for (rb=0; rb 0 && symbol < 4), - "symbol %d is illegal for PBCH DM-RS\n", - symbol); - - // printf("comp: symbol %d : nb_re %d\n",symbol,nb_re); - +static void nr_pbch_channel_compensation(struct complex16 rxdataF_ext[][PBCH_MAX_RE_PER_SYMBOL], + struct complex16 dl_ch_estimates_ext[][PBCH_MAX_RE_PER_SYMBOL], + int nb_re, + struct complex16 rxdataF_comp[][PBCH_MAX_RE_PER_SYMBOL], + NR_DL_FRAME_PARMS *frame_parms, + uint8_t output_shift) { for (int aarx=0; aarxnb_antennas_rx; aarx++) { - vect128 *dl_ch128 = (vect128 *)&dl_ch_estimates_ext[aarx][symbol*20*12]; - vect128 *rxdataF128 = (vect128 *)&rxdataF_ext[aarx][symbol*20*12]; - vect128 *rxdataF_comp128 = (vect128 *)&rxdataF_comp[aarx][symbol*20*12]; - /* - printf("ch compensation dl_ch ext addr %p \n", &dl_ch_estimates_ext[aarx][symbol*20*12]); - printf("rxdataf ext addr %p symbol %d\n", &rxdataF_ext[aarx][symbol*20*12], symbol); - printf("rxdataf_comp addr %p\n",&rxdataF_comp[aarx][symbol*20*12]); - */ + vect128 *dl_ch128 = (vect128 *)dl_ch_estimates_ext[aarx]; + vect128 *rxdataF128 = (vect128 *)rxdataF_ext[aarx]; + vect128 *rxdataF_comp128 = (vect128 *)rxdataF_comp[aarx]; for (int re=0; rellr; reset = 1; // x1 is set in first call to lte_gold_generic x2 = Nid; //this is c_init @@ -361,10 +338,10 @@ static void nr_pbch_unscrambling(NR_UE_PBCH *pbch, reset = 0; } - (pbch->pbch_a_interleaved) ^= ((unscrambling_mask>>i)&1)? ((pbch->pbch_a_prime>>i)&1)<pbch_a_prime>>i)&1) ^ ((s>>((k+offset)&0x1f))&1))<>i)&1)? ((pbch_a_prime>>i)&1)<>i)&1) ^ ((s>>((k+offset)&0x1f))&1))<>i)&1)); #ifdef DEBUG_PBCH_ENCODING - printf("i %d k %d offset %d (unscrambling_mask>>i)&1) %d s: %08x\t pbch_a_interleaved 0x%08x (!((unscrambling_mask>>i)&1)) %d\n", i, k, offset, (unscrambling_mask>>i)&1, s, pbch->pbch_a_interleaved, + printf("i %d k %d offset %d (unscrambling_mask>>i)&1) %d s: %08x\t pbch_a_interleaved 0x%08x (!((unscrambling_mask>>i)&1)) %d\n", i, k, offset, (unscrambling_mask>>i)&1, s, *pbch_a_interleaved, (!((unscrambling_mask>>i)&1))); #endif } else { @@ -386,18 +363,16 @@ static void nr_pbch_unscrambling(NR_UE_PBCH *pbch, } } -void nr_pbch_quantize(int16_t *pbch_llr8, - int16_t *pbch_llr, - uint16_t len) { - uint16_t i; - - for (i=0; i31) pbch_llr8[i]=32; else if (pbch_llr[i]<-31) pbch_llr8[i]=-32; else - pbch_llr8[i] = (char)(pbch_llr[i]); + pbch_llr8[i]=pbch_llr[i]; } } /* @@ -410,36 +385,34 @@ uint8_t pbch_deinterleaving_pattern[32] = {28,0,31,30,7,29,25,27,5,8,24,9,10,11, int nr_rx_pbch( PHY_VARS_NR_UE *ue, UE_nr_rxtx_proc_t *proc, + int estimateSz, struct complex16 dl_ch_estimates [][estimateSz], NR_UE_PBCH *nr_ue_pbch_vars, NR_DL_FRAME_PARMS *frame_parms, uint8_t gNB_id, uint8_t i_ssb, - MIMO_mode_t mimo_mode) { - + MIMO_mode_t mimo_mode, + NR_UE_PDCCH_CONFIG *phy_pdcch_config, + fapiPbch_t *result) { NR_UE_COMMON *nr_ue_common_vars = &ue->common_vars; int max_h=0; int symbol; //uint8_t pbch_a[64]; -//FT ?? cppcheck doesn't like pbch_a allocation because of line 525..and i don't get what this variable is for.. -//uint8_t *pbch_a = malloc(sizeof(uint8_t) * NR_POLAR_PBCH_PAYLOAD_BITS); - //uint32_t pbch_a_prime; - int16_t *pbch_e_rx; - uint8_t *decoded_output = nr_ue_pbch_vars->decoded_output; + //FT ?? cppcheck doesn't like pbch_a allocation because of line 525..and i don't get what this variable is for.. + //uint8_t *pbch_a = malloc(sizeof(uint8_t) * NR_POLAR_PBCH_PAYLOAD_BITS); uint8_t nushift; uint16_t M; - uint8_t Lmax=frame_parms->Lmax; + uint8_t Lmax=frame_parms->Lmax; //uint16_t crc; //unsigned short idx_demod =0; uint32_t decoderState=0; //uint8_t decoderListSize = 8, pathMetricAppr = 0; //time_stats_t polar_decoder_init,polar_rate_matching,decoding,bit_extraction,deinterleaving; //time_stats_t path_metric,sorting,update_LLR; -// FT ?? cppcheck fix memset(&pbch_a[0], 0, sizeof(uint8_t) * NR_POLAR_PBCH_PAYLOAD_BITS); + // FT ?? cppcheck fix memset(&pbch_a[0], 0, sizeof(uint8_t) * NR_POLAR_PBCH_PAYLOAD_BITS); //printf("nr_pbch_ue nid_cell %d\n",frame_parms->Nid_cell); - - pbch_e_rx = &nr_ue_pbch_vars->llr[0]; - // clear LLR buffer - memset(nr_ue_pbch_vars->llr,0,NR_POLAR_PBCH_E); + int16_t pbch_e_rx[960]= {0}; //Fixme: previous version erase only NR_POLAR_PBCH_E bytes + int16_t pbch_unClipped[960]= {0}; + int pbch_e_rx_idx=0; int symbol_offset=1; if (ue->is_synchronized > 0) @@ -447,20 +420,24 @@ int nr_rx_pbch( PHY_VARS_NR_UE *ue, else symbol_offset=0; - #ifdef DEBUG_PBCH //printf("address dataf %p",nr_ue_common_vars->common_vars_rx_data_per_thread[proc->thread_id].rxdataF); write_output("rxdataF0_pbch.m","rxF0pbch", &nr_ue_common_vars->common_vars_rx_data_per_thread[proc->thread_id].rxdataF[0][(symbol_offset+1)*frame_parms->ofdm_symbol_size],frame_parms->ofdm_symbol_size*3,1,1); #endif - // symbol refers to symbol within SSB. symbol_offset is the offset of the SSB wrt start of slot - for (symbol=1; symbol<4; symbol++) { + double log2_maxh; + for (symbol=1; symbol<4; symbol++) { + const uint16_t nb_re=symbol == 2 ? 72 : 180; + __attribute__ ((aligned(32))) struct complex16 rxdataF_ext[frame_parms->nb_antennas_rx][PBCH_MAX_RE_PER_SYMBOL]; + __attribute__ ((aligned(32))) struct complex16 dl_ch_estimates_ext[frame_parms->nb_antennas_rx][PBCH_MAX_RE_PER_SYMBOL]; + memset(dl_ch_estimates_ext,0, sizeof dl_ch_estimates_ext); nr_pbch_extract(nr_ue_common_vars->common_vars_rx_data_per_thread[proc->thread_id].rxdataF, - nr_ue_pbch_vars->dl_ch_estimates, - nr_ue_pbch_vars->rxdataF_ext, - nr_ue_pbch_vars->dl_ch_estimates_ext, + estimateSz, + dl_ch_estimates, + rxdataF_ext, + dl_ch_estimates_ext, symbol, symbol_offset, frame_parms); @@ -470,142 +447,140 @@ int nr_rx_pbch( PHY_VARS_NR_UE *ue, #endif if (symbol == 1) { - max_h = nr_pbch_channel_level(nr_ue_pbch_vars->dl_ch_estimates_ext, + max_h = nr_pbch_channel_level(dl_ch_estimates_ext, frame_parms, - symbol); - nr_ue_pbch_vars->log2_maxh = 3+(log2_approx(max_h)/2); + nb_re); + log2_maxh = 3+(log2_approx(max_h)/2); } #ifdef DEBUG_PBCH LOG_I(PHY,"[PHY] PBCH log2_maxh = %d (%d)\n",nr_ue_pbch_vars->log2_maxh,max_h); #endif - nr_pbch_channel_compensation(nr_ue_pbch_vars->rxdataF_ext, - nr_ue_pbch_vars->dl_ch_estimates_ext, - nr_ue_pbch_vars->rxdataF_comp, + __attribute__ ((aligned(32))) struct complex16 rxdataF_comp[frame_parms->nb_antennas_rx][PBCH_MAX_RE_PER_SYMBOL]; + nr_pbch_channel_compensation(rxdataF_ext, + dl_ch_estimates_ext, + nb_re, + rxdataF_comp, frame_parms, - symbol, - nr_ue_pbch_vars->log2_maxh); // log2_maxh+I0_shift + log2_maxh); // log2_maxh+I0_shift /*if (frame_parms->nb_antennas_rx > 1) pbch_detection_mrc(frame_parms, - nr_ue_pbch_vars->rxdataF_comp, + rxdataF_comp, symbol);*/ /* if (mimo_mode == ALAMOUTI) { - nr_pbch_alamouti(frame_parms,nr_ue_pbch_vars->rxdataF_comp,symbol); + nr_pbch_alamouti(frame_parms,rxdataF_comp,symbol); } else if (mimo_mode != SISO) { LOG_I(PHY,"[PBCH][RX] Unsupported MIMO mode\n"); return(-1); } */ - if (symbol==2) { - nr_pbch_quantize(pbch_e_rx, - (short *)&(nr_ue_pbch_vars->rxdataF_comp[0][symbol*240]), - 144); - pbch_e_rx+=144; - } else { - nr_pbch_quantize(pbch_e_rx, - (short *)&(nr_ue_pbch_vars->rxdataF_comp[0][symbol*240]), - 360); - pbch_e_rx+=360; - } + int nb=symbol==2 ? 144 : 360; + nr_pbch_quantize(pbch_e_rx+pbch_e_rx_idx, + (short *)rxdataF_comp[0], + nb); + memcpy(pbch_unClipped+pbch_e_rx_idx, rxdataF_comp[0], nb*sizeof(int16_t)); + pbch_e_rx_idx+=nb; } + // legacy code use int16, but it is complex16 + UEscopeCopy(ue, pbchRxdataF_comp, pbch_unClipped, sizeof(struct complex16), frame_parms->nb_antennas_rx, pbch_e_rx_idx/2); + UEscopeCopy(ue, pbchLlr, pbch_e_rx, sizeof(int16_t), frame_parms->nb_antennas_rx, pbch_e_rx_idx); #ifdef DEBUG_PBCH - write_output("rxdataF_comp.m","rxFcomp",&nr_ue_pbch_vars->rxdataF_comp[0][240],240*3,1,1); -#endif - pbch_e_rx = nr_ue_pbch_vars->llr; - //demod_pbch_e = nr_ue_pbch_vars->demod_pbch_e; -// FT?? cppcheck fix - pbch_a = nr_ue_pbch_vars->pbch_a; -#ifdef DEBUG_PBCH - //pbch_e_rx = &nr_ue_pbch_vars->llr[0]; - short *p = (short *)&(nr_ue_pbch_vars->rxdataF_comp[0][20*12]); - + write_output("rxdataF_comp.m","rxFcomp",rxdataF_comp[0],240*3,1,1); + short *p = (short *)rxdataF_comp[0]); + for (int cnt = 0; cnt < 864 ; cnt++) printf("pbch rx llr %d\n",*(pbch_e_rx+cnt)); - + #endif //un-scrambling M = NR_POLAR_PBCH_E; nushift = (Lmax==4)? i_ssb&3 : i_ssb&7; uint32_t unscrambling_mask = (Lmax==64)?0x100006D:0x1000041; - - nr_pbch_unscrambling(nr_ue_pbch_vars,frame_parms->Nid_cell,nushift,M,NR_POLAR_PBCH_E,0,0); + uint32_t pbch_a_interleaved=0; + uint32_t pbch_a_prime=0; + nr_pbch_unscrambling(nr_ue_pbch_vars, pbch_e_rx, frame_parms->Nid_cell, nushift, M, NR_POLAR_PBCH_E, + 0, 0, pbch_a_prime, &pbch_a_interleaved); //polar decoding de-rate matching - decoderState = polar_decoder_int16(pbch_e_rx,(uint64_t *)&nr_ue_pbch_vars->pbch_a_prime,0, + uint64_t tmp=0; + decoderState = polar_decoder_int16(pbch_e_rx,(uint64_t *)&tmp,0, NR_POLAR_PBCH_MESSAGE_TYPE, NR_POLAR_PBCH_PAYLOAD_BITS, NR_POLAR_PBCH_AGGREGATION_LEVEL); + pbch_a_prime=tmp; + if(decoderState) + return(decoderState); - if(decoderState) return(decoderState); - - // printf("polar decoder output 0x%08x\n",nr_ue_pbch_vars->pbch_a_prime); + // printf("polar decoder output 0x%08x\n",pbch_a_prime); // Decoder reversal uint32_t a_reversed=0; for (int i=0; ipbch_a_prime>>i)&1)<<(31-i); + a_reversed |= (((uint64_t)pbch_a_prime>>i)&1)<<(31-i); - nr_ue_pbch_vars->pbch_a_prime = a_reversed; + pbch_a_prime = a_reversed; //payload un-scrambling - nr_ue_pbch_vars->pbch_a_interleaved=0; M = (Lmax == 64)? (NR_POLAR_PBCH_PAYLOAD_BITS - 6) : (NR_POLAR_PBCH_PAYLOAD_BITS - 3); - nushift = ((nr_ue_pbch_vars->pbch_a_prime>>24)&1) ^ (((nr_ue_pbch_vars->pbch_a_prime>>6)&1)<<1); - nr_pbch_unscrambling(nr_ue_pbch_vars,frame_parms->Nid_cell,nushift,M,NR_POLAR_PBCH_PAYLOAD_BITS,1,unscrambling_mask); - //printf("nushift %d sfn 3rd %d 2nd %d", nushift,((nr_ue_pbch_vars->pbch_a_prime>>6)&1), ((nr_ue_pbch_vars->pbch_a_prime>>24)&1) ); + nushift = ((pbch_a_prime>>24)&1) ^ (((pbch_a_prime>>6)&1)<<1); + pbch_a_interleaved=0; + nr_pbch_unscrambling(nr_ue_pbch_vars, pbch_e_rx, frame_parms->Nid_cell, nushift, M, NR_POLAR_PBCH_PAYLOAD_BITS, + 1, unscrambling_mask, pbch_a_prime, &pbch_a_interleaved); + //printf("nushift %d sfn 3rd %d 2nd %d", nushift,((pbch_a_prime>>6)&1), ((pbch_a_prime>>24)&1) ); //payload deinterleaving //uint32_t in=0; uint32_t out=0; for (int i=0; i<32; i++) { - out |= ((nr_ue_pbch_vars->pbch_a_interleaved>>i)&1)<<(pbch_deinterleaving_pattern[i]); + out |= ((pbch_a_interleaved>>i)&1)<<(pbch_deinterleaving_pattern[i]); #ifdef DEBUG_PBCH - printf("i %d in 0x%08x out 0x%08x ilv %d (in>>i)&1) 0x%08x\n", i, nr_ue_pbch_vars->pbch_a_interleaved, out, pbch_deinterleaving_pattern[i], (nr_ue_pbch_vars->pbch_a_interleaved>>i)&1); + printf("i %d in 0x%08x out 0x%08x ilv %d (in>>i)&1) 0x%08x\n", i, pbch_a_interleaved, out, pbch_deinterleaving_pattern[i], (pbch_a_interleaved>>i)&1); #endif } uint32_t payload = 0; - //uint8_t xtra_byte = 0; - nr_ue_pbch_vars->xtra_byte = (out>>24)&0xff; + result->xtra_byte = (out>>24)&0xff; for (int i=0; i>i)&1)<<(NR_POLAR_PBCH_PAYLOAD_BITS-i-1); - + for (int i=0; i<3; i++) - decoded_output[i] = (uint8_t)((payload>>((3-i)<<3))&0xff); - - frame_parms->half_frame_bit = ((nr_ue_pbch_vars->xtra_byte>>4)&0x01); // computing the half frame index from the extra byte - + result->decoded_output[i] = (uint8_t)((payload>>((3-i)<<3))&0xff); + + frame_parms->half_frame_bit = (result->xtra_byte>>4)&0x01; // computing the half frame index from the extra byte frame_parms->ssb_index = i_ssb; // ssb index corresponds to i_ssb for Lmax = 4,8 + if (Lmax == 64) { // for Lmax = 64 ssb index 4th,5th and 6th bits are in extra byte for (int i=0; i<3; i++) - frame_parms->ssb_index += (((nr_ue_pbch_vars->xtra_byte>>(7-i))&0x01)<<(3+i)); + frame_parms->ssb_index += (((result->xtra_byte>>(7-i))&0x01)<<(3+i)); } ue->symbol_offset = nr_get_ssb_start_symbol(frame_parms,frame_parms->ssb_index); + if (frame_parms->half_frame_bit) - ue->symbol_offset += (frame_parms->slots_per_frame>>1)*frame_parms->symbols_per_slot; + ue->symbol_offset += (frame_parms->slots_per_frame>>1)*frame_parms->symbols_per_slot; uint8_t frame_number_4lsb = 0; + for (int i=0; i<4; i++) - frame_number_4lsb |= ((nr_ue_pbch_vars->xtra_byte>>i)&1)<<(3-i); - + frame_number_4lsb |= ((result->xtra_byte>>i)&1)<<(3-i); + proc->decoded_frame_rx = frame_number_4lsb; - #ifdef DEBUG_PBCH - printf("xtra_byte %x payload %x\n", nr_ue_pbch_vars->xtra_byte, payload); + printf("xtra_byte %x payload %x\n", xtra_byte, payload); for (int i=0; i<(NR_POLAR_PBCH_PAYLOAD_BITS>>3); i++) { // printf("unscrambling pbch_a[%d] = %x \n", i,pbch_a[i]); - printf("[PBCH] decoder payload[%d] = %x\n",i,decoded_output[i]); + printf("[PBCH] decoder payload[%d] = %x\n",i,result->decoded_output[i]); } -#endif +#endif nr_downlink_indication_t dl_indication; fapi_nr_rx_indication_t *rx_ind=calloc(sizeof(*rx_ind),1); uint16_t number_pdus = 1; - nr_fill_dl_indication(&dl_indication, NULL, rx_ind, proc, ue, gNB_id); - nr_fill_rx_indication(rx_ind, FAPI_NR_RX_PDU_TYPE_SSB, gNB_id, ue, NULL, NULL, number_pdus, proc); + nr_fill_dl_indication(&dl_indication, NULL, rx_ind, proc, ue, gNB_id, phy_pdcch_config); + nr_fill_rx_indication(rx_ind, FAPI_NR_RX_PDU_TYPE_SSB, gNB_id, ue, NULL, NULL, number_pdus, proc,(void *)result); if (ue->if_inst && ue->if_inst->dl_indication) ue->if_inst->dl_indication(&dl_indication, NULL); diff --git a/openair1/PHY/NR_UE_TRANSPORT/nr_prach.c b/openair1/PHY/NR_UE_TRANSPORT/nr_prach.c index 24299fd788..8437b8f8f3 100644 --- a/openair1/PHY/NR_UE_TRANSPORT/nr_prach.c +++ b/openair1/PHY/NR_UE_TRANSPORT/nr_prach.c @@ -57,7 +57,7 @@ extern const char *prachfmt[]; // - idft for short sequence assumes we are transmitting starting in symbol 0 of a PRACH slot // - Assumes that PRACH SCS is same as PUSCH SCS @ 30 kHz, take values for formats 0-2 and adjust for others below // - Preamble index different from 0 is not detected by gNB -int32_t generate_nr_prach(PHY_VARS_NR_UE *ue, uint8_t gNB_id, uint8_t slot){ +int32_t generate_nr_prach(PHY_VARS_NR_UE *ue, uint8_t gNB_id, int frame, uint8_t slot){ NR_DL_FRAME_PARMS *fp=&ue->frame_parms; fapi_nr_config_request_t *nrUE_config = &ue->nrUE_config; @@ -67,7 +67,7 @@ int32_t generate_nr_prach(PHY_VARS_NR_UE *ue, uint8_t gNB_id, uint8_t slot){ uint8_t Mod_id, fd_occasion, preamble_index, restricted_set, not_found; uint16_t rootSequenceIndex, prach_fmt_id, NCS, *prach_root_sequence_map, preamble_offset = 0; uint16_t preamble_shift = 0, preamble_index0, n_shift_ra, n_shift_ra_bar, d_start=INT16_MAX, numshift, N_ZC, u, offset, offset2, first_nonzero_root_idx; - int16_t prach_tmp[98304*2*4] __attribute__((aligned(32))); + int16_t prach_tmp[(4688+4*24576)*4*2] __attribute__((aligned(32))); int16_t Ncp = 0, amp, *prach, *prach2, *prachF, *Xu; int32_t Xu_re, Xu_im; @@ -102,10 +102,19 @@ int32_t generate_nr_prach(PHY_VARS_NR_UE *ue, uint8_t gNB_id, uint8_t slot){ nrUE_config->prach_config.num_prach_fd_occasions_list[fd_occasion].prach_root_sequence_index, ue->X_u); - if (slot % (fp->slots_per_subframe / 2) == 0) - sample_offset_slot = (prachStartSymbol==0?0:fp->ofdm_symbol_size*prachStartSymbol+fp->nb_prefix_samples0+fp->nb_prefix_samples*(prachStartSymbol-1)); - else - sample_offset_slot = (fp->ofdm_symbol_size + fp->nb_prefix_samples) * prachStartSymbol; + if (prachStartSymbol == 0) { + sample_offset_slot = 0; + } else if (fp->slots_per_subframe == 1) { + if (prachStartSymbol <= 7) + sample_offset_slot = (fp->ofdm_symbol_size + fp->nb_prefix_samples) * (prachStartSymbol - 1) + (fp->ofdm_symbol_size + fp->nb_prefix_samples0); + else + sample_offset_slot = (fp->ofdm_symbol_size + fp->nb_prefix_samples) * (prachStartSymbol - 2) + (fp->ofdm_symbol_size + fp->nb_prefix_samples0) * 2; + } else { + if (slot % (fp->slots_per_subframe / 2) == 0) + sample_offset_slot = (fp->ofdm_symbol_size + fp->nb_prefix_samples) * (prachStartSymbol - 1) + (fp->ofdm_symbol_size + fp->nb_prefix_samples0); + else + sample_offset_slot = (fp->ofdm_symbol_size + fp->nb_prefix_samples) * prachStartSymbol; + } prach_start = fp->get_samples_slot_timestamp(slot, fp, 0) + sample_offset_slot; @@ -190,8 +199,9 @@ int32_t generate_nr_prach(PHY_VARS_NR_UE *ue, uint8_t gNB_id, uint8_t slot){ // now generate PRACH signal #ifdef NR_PRACH_DEBUG if (NCS>0) - LOG_I(PHY, "PRACH [UE %d] generate PRACH in slot %d for RootSeqIndex %d, Preamble Index %d, PRACH Format %s, NCS %d (N_ZC %d): Preamble_offset %d, Preamble_shift %d msg1 frequency start %d\n", + LOG_I(PHY, "PRACH [UE %d] generate PRACH in frame.slot %d.%d for RootSeqIndex %d, Preamble Index %d, PRACH Format %s, NCS %d (N_ZC %d): Preamble_offset %d, Preamble_shift %d msg1 frequency start %d\n", Mod_id, + frame, slot, rootSequenceIndex, preamble_index, @@ -221,7 +231,9 @@ int32_t generate_nr_prach(PHY_VARS_NR_UE *ue, uint8_t gNB_id, uint8_t slot){ k += kbar; k *= 2; - LOG_I(PHY, "PRACH [UE %d] in slot %d, placing PRACH in position %d, msg1 frequency start %d (k1 %d), preamble_offset %d, first_nonzero_root_idx %d\n", Mod_id, + LOG_I(PHY, "PRACH [UE %d] in frame.slot %d.%d, placing PRACH in position %d, msg1 frequency start %d (k1 %d), preamble_offset %d, first_nonzero_root_idx %d\n", + Mod_id, + frame, slot, k, n_ra_prb, @@ -229,10 +241,139 @@ int32_t generate_nr_prach(PHY_VARS_NR_UE *ue, uint8_t gNB_id, uint8_t slot){ preamble_offset, first_nonzero_root_idx); - Xu = (int16_t*)ue->X_u[preamble_offset-first_nonzero_root_idx]; + // Ncp and dftlen here is given in terms of T_s wich is 30.72MHz sampling + if (prach_sequence_length == 0) { + switch (prach_fmt_id) { + case 0: + Ncp = 3168; + dftlen = 24576; + break; - #if defined (PRACH_WRITE_OUTPUT_DEBUG) - LOG_M("X_u.m", "X_u", (int16_t*)ue->X_u[preamble_offset-first_nonzero_root_idx], N_ZC, 1, 1); + case 1: + Ncp = 21024; + dftlen = 24576; + break; + + case 2: + Ncp = 4688; + dftlen = 24576; + break; + + case 3: + Ncp = 3168; + dftlen = 6144; + break; + + default: + AssertFatal(1==0, "Illegal PRACH format %d for sequence length 839\n", prach_fmt_id); + break; + } + } else { + switch (prach_fmt_id) { + case 4: //A1 + Ncp = 288 >> mu; + break; + + case 5: //A2 + Ncp = 576 >> mu; + break; + + case 6: //A3 + Ncp = 864 >> mu; + break; + + case 7: //B1 + Ncp = 216 >> mu; + break; + + /* + case 4: //B2 + Ncp = 360 >> mu; + break; + + case 5: //B3 + Ncp = 504 >> mu; + break; + */ + + case 8: //B4 + Ncp = 936 >> mu; + break; + + case 9: //C0 + Ncp = 1240 >> mu; + break; + + case 10: //C2 + Ncp = 2048 >> mu; + break; + + default: + AssertFatal(1==0,"Unknown PRACH format ID %d\n", prach_fmt_id); + break; + } + dftlen = 2048 >> mu; + } + + //actually what we should be checking here is how often the current prach crosses a 0.5ms boundary. I am not quite sure for which paramter set this would be the case, so I will ignore it for now and just check if the prach starts on a 0.5ms boundary + if(fp->numerology_index == 0) { + if (prachStartSymbol == 0 || prachStartSymbol == 7) + Ncp += 16; + } + else { + if (slot%(fp->slots_per_subframe/2)==0 && prachStartSymbol == 0) + Ncp += 16; + } + + switch(fp->samples_per_subframe) { + case 7680: + // 5 MHz @ 7.68 Ms/s + Ncp >>= 2; + dftlen >>= 2; + break; + + case 15360: + // 10, 15 MHz @ 15.36 Ms/s + Ncp >>= 1; + dftlen >>= 1; + break; + + case 30720: + // 20, 25, 30 MHz @ 30.72 Ms/s + Ncp = Ncp; + dftlen = dftlen; + break; + + case 46080: + // 40 MHz @ 46.08 Ms/s + Ncp = (Ncp*3)/2; + dftlen = (dftlen*3)/2; + break; + + case 61440: + // 40, 50, 60 MHz @ 61.44 Ms/s + Ncp <<= 1; + dftlen <<= 1; + break; + + case 92160: + // 50, 60, 70, 80, 90 MHz @ 92.16 Ms/s + Ncp *= 3; + dftlen *= 3; + break; + + case 122880: + // 70, 80, 90, 100 MHz @ 122.88 Ms/s + Ncp <<= 2; + dftlen <<= 2; + break; + + default: + AssertFatal(1==0,"sample rate %f MHz not supported for numerology %d\n", fp->samples_per_subframe / 1000.0, mu); + } + + #ifdef NR_PRACH_DEBUG + LOG_I(PHY, "PRACH [UE %d] Ncp %d, dftlen %d \n", Mod_id, Ncp, dftlen); #endif /******************************************************** @@ -249,99 +390,11 @@ int32_t generate_nr_prach(PHY_VARS_NR_UE *ue, uint8_t gNB_id, uint8_t slot){ * *********************************************************/ - if (mu==1) { - switch(fp->samples_per_subframe) { - case 15360: - // 10, 15 MHz @ 15.36 Ms/s - if (prach_sequence_length == 0) { - if (prach_fmt_id == 0 || prach_fmt_id == 1 || prach_fmt_id == 2) - dftlen = 12288; - if (prach_fmt_id == 3) - dftlen = 3072; - } else { // 839 sequence - dftlen = 512; - } - break; - - case 30720: - // 20, 25, 30 MHz @ 30.72 Ms/s - if (prach_sequence_length == 0) { - if (prach_fmt_id == 0 || prach_fmt_id == 1 || prach_fmt_id == 2) - dftlen = 24576; - if (prach_fmt_id == 3) - dftlen = 6144; - } else { // 839 sequence - dftlen = 1024; - } - break; - - case 46080: - // 40 MHz @ 46.08 Ms/s - if (prach_sequence_length == 0) { - if (prach_fmt_id == 0 || prach_fmt_id == 1 || prach_fmt_id == 2) - dftlen = 36864; - if (prach_fmt_id == 3) - dftlen = 9216; - } else { // 839 sequence - dftlen = 1536; - } - break; - - case 61440: - // 40, 50, 60 MHz @ 61.44 Ms/s - if (prach_sequence_length == 0) { - if (prach_fmt_id == 0 || prach_fmt_id == 1 || prach_fmt_id == 2) - dftlen = 49152; - if (prach_fmt_id == 3) - dftlen = 12288; - } else { // 839 sequence - dftlen = 2048; - } - break; - - case 92160: - // 50, 60, 70, 80, 90 MHz @ 92.16 Ms/s - if (prach_sequence_length == 0) { - if (prach_fmt_id == 0 || prach_fmt_id == 1 || prach_fmt_id == 2) - dftlen = 73728; - if (prach_fmt_id == 3) - dftlen = 18432; - } else { // 839 sequence - dftlen = 3072; - } - break; - - case 122880: - // 70, 80, 90, 100 MHz @ 122.88 Ms/s - if (prach_sequence_length == 0) { - if (prach_fmt_id == 0 || prach_fmt_id == 1 || prach_fmt_id == 2) - dftlen = 98304; - if (prach_fmt_id == 3) - dftlen = 24576; - } else { // 839 sequence - dftlen = 4096; - } - break; - - default: - AssertFatal(1==0,"sample rate %f MHz not supported for numerology %d\n", fp->samples_per_subframe / 1000.0, mu); - } - } - else if (mu==3) { - if (fp->threequarter_fs) - AssertFatal(1==0,"3/4 sampling not supported for numerology %d\n",mu); - - if (prach_sequence_length == 0) - AssertFatal(1==0,"long prach not supported for numerology %d\n",mu); - - if (fp->N_RB_UL == 32) - dftlen=512; - else if (fp->N_RB_UL == 66) - dftlen=1024; - else - AssertFatal(1==0,"N_RB_UL %d not support for numerology %d\n",fp->N_RB_UL,mu); - } + Xu = (int16_t*)ue->X_u[preamble_offset-first_nonzero_root_idx]; + #if defined (PRACH_WRITE_OUTPUT_DEBUG) + LOG_M("X_u.m", "X_u", (int16_t*)ue->X_u[preamble_offset-first_nonzero_root_idx], N_ZC, 1, 1); + #endif for (offset=0,offset2=0; offsetnumerology_index == 0) { - if (prachStartSymbol == 0 || prachStartSymbol == 7) - use_extended_prach_prefix = 1; - } - else { - if (slot%(fp->slots_per_subframe/2)==0 && prachStartSymbol == 0) - use_extended_prach_prefix = 1; - } - - if (mu == 3) { - switch (fp->samples_per_subframe) { - case 61440: // 32 PRB case, 61.44 Msps - Ncp<<=1; //to account for 61.44Mbps - // This is after cyclic prefix - prach2 = prach+(Ncp<<1); //times 2 for complex samples - if (prach_sequence_length == 0) - AssertFatal(1==0,"no long PRACH for this PRACH size %d\n",fp->N_RB_UL); - else { - if (use_extended_prach_prefix) - Ncp+=32; // 16*kappa, kappa=2 for 61.44Msps - prach2 = prach+(Ncp<<1); //times 2 for complex samples - if (prach_fmt_id == 4 || prach_fmt_id == 7 || prach_fmt_id == 9) { - idft(IDFT_512,prachF,prach2,1); - // here we have |empty | Prach512 | - if (prach_fmt_id != 9) { - memmove(prach2+(512<<1),prach2,(512<<2)); - prach_len = (512*2)+Ncp; - } - else prach_len = (512*1)+Ncp; - memmove(prach,prach+(512<<1),(Ncp<<2)); - // here we have |Prefix | Prach512 | Prach512 (if ! 0xc0) | - } else if (prach_fmt_id == 5) { // 6x512 - idft(IDFT_512,prachF,prach2,1); - // here we have |empty | Prach512 | - memmove(prach2+(512<<1),prach2,(512<<2)); - // here we have |empty | Prach512 | Prach512| empty512 | empty512 | - memmove(prach2+(512<<2),prach2,(512<<3)); - // here we have |empty | Prach512 | Prach512| Prach512 | Prach512 | - memmove(prach,prach+(512<<1),(Ncp<<2)); - // here we have |Prefix | Prach512 | - prach_len = (512*4)+Ncp; - } else if (prach_fmt_id == 6) { // 6x512 - idft(IDFT_512,prachF,prach2,1); - // here we have |empty | Prach512 | - memmove(prach2+(512<<1),prach2,(512<<2)); - // here we have |empty | Prach512 | Prach512| empty512 | empty512 | empty512 | empty512 - memmove(prach2+(512<<2),prach2,(512<<3)); - // here we have |empty | Prach512 | Prach512| Prach512 | Prach512 | empty512 | empty512 - memmove(prach2+(512<<3),prach2,(512<<3)); - // here we have |empty | Prach512 | Prach512| Prach512 | Prach512 | Prach512 | Prach512 - memmove(prach,prach+(512<<1),(Ncp<<2)); - // here we have |Prefix | Prach512 | - prach_len = (512*6)+Ncp; - } else if (prach_fmt_id == 8) { // 12x512 - idft(IDFT_512,prachF,prach2,1); - // here we have |empty | Prach512 | - memmove(prach2+(512<<1),prach2,(512<<2)); - // here we have |empty | Prach512 | Prach512| empty512 | empty512 | empty512 | empty512 - memmove(prach2+(512<<2),prach2,(512<<3)); - // here we have |empty | Prach512 | Prach512| Prach512 | Prach512 | empty512 | empty512 - memmove(prach2+(512<<3),prach2,(512<<3)); - // here we have |empty | Prach512 | Prach512| Prach512 | Prach512 | Prach512 | Prach512 - memmove(prach2+(512<<1)*6,prach2,(512<<2)*6); - // here we have |empty | Prach512 | Prach512| Prach512 | Prach512 | Prach512 | Prach512 | Prach512 | Prach512| Prach512 | Prach512 | Prach512 | Prach512| - memmove(prach,prach+(512<<1),(Ncp<<2)); - // here we have |Prefix | Prach512 | Prach512| Prach512 | Prach512 | Prach512 | Prach512 | Prach512 | Prach512| Prach512 | Prach512 | Prach512 | Prach512| - prach_len = (512*12)+Ncp; - } - } - break; - - case 122880: // 66 PRB case, 122.88 Msps - Ncp<<=2; //to account for 122.88Mbps - // This is after cyclic prefix - prach2 = prach+(Ncp<<1); //times 2 for complex samples - if (prach_sequence_length == 0) - AssertFatal(1==0,"no long PRACH for this PRACH size %d\n",fp->N_RB_UL); - else { - if (use_extended_prach_prefix) - Ncp+=64; // 16*kappa, kappa=4 for 122.88Msps - prach2 = prach+(Ncp<<1); //times 2 for complex samples - if (prach_fmt_id == 4 || prach_fmt_id == 7 || prach_fmt_id == 9) { - idft(IDFT_1024,prachF,prach2,1); - // here we have |empty | Prach1024 | - if (prach_fmt_id != 9) { - memmove(prach2+(1024<<1),prach2,(1024<<2)); - prach_len = (1024*2)+Ncp; - } - else prach_len = (1024*1)+Ncp; - memmove(prach,prach+(1024<<1),(Ncp<<2)); - // here we have |Prefix | Prach1024 | Prach1024 (if ! 0xc0) | - } else if (prach_fmt_id == 5) { // 6x1024 - idft(IDFT_1024,prachF,prach2,1); - // here we have |empty | Prach1024 | - memmove(prach2+(1024<<1),prach2,(1024<<2)); - // here we have |empty | Prach1024 | Prach1024| empty1024 | empty1024 | - memmove(prach2+(1024<<2),prach2,(1024<<3)); - // here we have |empty | Prach1024 | Prach1024| Prach1024 | Prach1024 | - memmove(prach,prach+(1024<<1),(Ncp<<2)); - // here we have |Prefix | Prach1024 | - prach_len = (1024*4)+Ncp; - } else if (prach_fmt_id == 6) { // 6x1024 - idft(IDFT_1024,prachF,prach2,1); - // here we have |empty | Prach1024 | - memmove(prach2+(1024<<1),prach2,(1024<<2)); - // here we have |empty | Prach1024 | Prach1024| empty1024 | empty1024 | empty1024 | empty1024 - memmove(prach2+(1024<<2),prach2,(1024<<3)); - // here we have |empty | Prach1024 | Prach1024| Prach1024 | Prach1024 | empty1024 | empty1024 - memmove(prach2+(1024<<3),prach2,(1024<<3)); - // here we have |empty | Prach1024 | Prach1024| Prach1024 | Prach1024 | Prach1024 | Prach1024 - memmove(prach,prach+(1024<<1),(Ncp<<2)); - // here we have |Prefix | Prach1024 | - prach_len = (1024*6)+Ncp; - } else if (prach_fmt_id == 8) { // 12x1024 - idft(IDFT_1024,prachF,prach2,1); - // here we have |empty | Prach1024 | - memmove(prach2+(1024<<1),prach2,(1024<<2)); - // here we have |empty | Prach1024 | Prach1024| empty1024 | empty1024 | empty1024 | empty1024 - memmove(prach2+(1024<<2),prach2,(1024<<3)); - // here we have |empty | Prach1024 | Prach1024| Prach1024 | Prach1024 | empty1024 | empty1024 - memmove(prach2+(1024<<3),prach2,(1024<<3)); - // here we have |empty | Prach1024 | Prach1024| Prach1024 | Prach1024 | Prach1024 | Prach1024 - memmove(prach2+(1024<<1)*6,prach2,(1024<<2)*6); - // here we have |empty | Prach1024 | Prach1024| Prach1024 | Prach1024 | Prach1024 | Prach1024 | Prach1024 | Prach1024| Prach1024 | Prach1024 | Prach1024 | Prach1024| - memmove(prach,prach+(1024<<1),(Ncp<<2)); - // here we have |Prefix | Prach1024 | Prach1024| Prach1024 | Prach1024 | Prach1024 | Prach1024 | Prach1024 | Prach1024| Prach1024 | Prach1024 | Prach1024 | Prach1024| - prach_len = (1024*12)+Ncp; - } - } - break; - - default: - AssertFatal(1==0,"sample rate %f MHz not supported for numerology %d\n", fp->samples_per_subframe / 1000.0, mu); - } - } else if (mu == 1) { - switch (fp->samples_per_subframe) { - case 15360: // full sampling @ 15.36 Ms/s - Ncp = Ncp/2; // to account for 15.36 Ms/s - // This is after cyclic prefix - prach2 = prach+(2*Ncp); // times 2 for complex samples - if (prach_sequence_length == 0){ - if (prach_fmt_id == 0) { // 24576 samples @ 30.72 Ms/s, 12288 samples @ 15.36 Ms/s - idft(IDFT_12288,prachF,prach2,1); - // here we have | empty | Prach12288 | - memmove(prach,prach+(12288<<1),(Ncp<<2)); - // here we have | Prefix | Prach12288 | - prach_len = 12288+Ncp; - } else if (prach_fmt_id == 1) { // 24576 samples @ 30.72 Ms/s, 12288 samples @ 15.36 Ms/s - idft(IDFT_12288,prachF,prach2,1); - // here we have | empty | Prach12288 | empty12288 | - memmove(prach2+(12288<<1),prach2,(12288<<2)); - // here we have | empty | Prach12288 | Prach12288 | - memmove(prach,prach+(12288<<2),(Ncp<<2)); - // here we have | Prefix | Prach12288 | Prach12288 | - prach_len = (12288*2)+Ncp; - } else if (prach_fmt_id == 2) { // 24576 samples @ 30.72 Ms/s, 12288 samples @ 15.36 Ms/s - idft(IDFT_12288,prachF,prach2,1); - // here we have | empty | Prach12288 | empty12288 | empty12288 | empty12288 | - memmove(prach2+(12288<<1),prach2,(12288<<2)); - // here we have | empty | Prach12288 | Prach12288 | empty12288 | empty12288 | - memmove(prach2+(12288<<2),prach2,(12288<<3)); - // here we have | empty | Prach12288 | Prach12288 | Prach12288 | Prach12288 | - memmove(prach,prach+(12288<<3),(Ncp<<2)); - // here we have | Prefix | Prach12288 | Prach12288 | Prach12288 | Prach12288 | - prach_len = (12288*4)+Ncp; - } else if (prach_fmt_id == 3) { // 6144 samples @ 30.72 Ms/s, 3072 samples @ 15.36 Ms/s - idft(IDFT_3072,prachF,prach2,1); - // here we have | empty | Prach3072 | empty3072 | empty3072 | empty3072 | - memmove(prach2+(3072<<1),prach2,(3072<<2)); - // here we have | empty | Prach3072 | Prach3072 | empty3072 | empty3072 | - memmove(prach2+(3072<<2),prach2,(3072<<3)); - // here we have | empty | Prach3072 | Prach3072 | Prach3072 | Prach3072 | - memmove(prach,prach+(3072<<3),(Ncp<<2)); - // here we have | Prefix | Prach3072 | Prach3072 | Prach3072 | Prach3072 | - prach_len = (3072*4)+Ncp; - } - } else { // short PRACH sequence - if (use_extended_prach_prefix) - Ncp += 8; // 16*kappa, kappa=0.5 for 15.36 Ms/s - prach2 = prach+(2*Ncp); // times 2 for complex samples - if (prach_fmt_id == 9) { - idft(IDFT_512,prachF,prach2,1); - // here we have | empty | Prach512 | - memmove(prach,prach+(512<<1),(Ncp<<2)); - // here we have | Prefix | Prach512 | - prach_len = (512*1)+Ncp; - } else if (prach_fmt_id == 4 || prach_fmt_id == 7) { - idft(IDFT_512,prachF,prach2,1); - // here we have | empty | Prach512 | empty512 | - memmove(prach2+(512<<1),prach2,(512<<2)); - // here we have | empty | Prach512 | Prach512 | - memmove(prach,prach+(512<<1),(Ncp<<2)); - // here we have | Prefix | Prach512 | Prach512 | - prach_len = (512*2)+Ncp; - } else if (prach_fmt_id == 5) { // 4x512 - idft(IDFT_512,prachF,prach2,1); - // here we have | empty | Prach512 | empty512 | empty512 | empty512 | - memmove(prach2+(512<<1),prach2,(512<<2)); - // here we have | empty | Prach512 | Prach512 | empty512 | empty512 | - memmove(prach2+(512<<2),prach2,(512<<3)); - // here we have | empty | Prach512 | Prach512 | Prach512 | Prach512 | - memmove(prach,prach+(512<<1),(Ncp<<2)); - // here we have | Prefix | Prach512 | Prach512 | Prach512 | Prach512 | - prach_len = (512*4)+Ncp; - } else if (prach_fmt_id == 6) { // 6x512 - idft(IDFT_512,prachF,prach2,1); - // here we have | empty | Prach512 | empty512 | empty512 | empty512 | empty512 | empty512 | - memmove(prach2+(512<<1),prach2,(512<<2)); - // here we have | empty | Prach512 | Prach512 | empty512 | empty512 | empty512 | empty512 | - memmove(prach2+(512<<2),prach2,(512<<3)); - // here we have | empty | Prach512 | Prach512 | Prach512 | Prach512 | empty512 | empty512 | - memmove(prach2+(512<<3),prach2,(512<<3)); - // here we have | empty | Prach512 | Prach512 | Prach512 | Prach512 | Prach512 | Prach512 | - memmove(prach,prach+(512<<1),(Ncp<<2)); - // here we have | Prefix | Prach512 | Prach512 | Prach512 | Prach512 | Prach512 | Prach512 | - prach_len = (512*6)+Ncp; - } else if (prach_fmt_id == 8) { // 12x512 - idft(IDFT_512,prachF,prach2,1); - // here we have | empty | Prach512 | empty512 | empty512 | empty512 | empty512 | empty512 | empty512 | empty512 | empty512 | empty512 | empty512 | empty512 | - memmove(prach2+(512<<1),prach2,(512<<2)); - // here we have | empty | Prach512 | Prach512 | empty512 | empty512 | empty512 | empty512 | empty512 | empty512 | empty512 | empty512 | empty512 | empty512 | - memmove(prach2+(512<<2),prach2,(512<<3)); - // here we have | empty | Prach512 | Prach512 | Prach512 | Prach512 | empty512 | empty512 | empty512 | empty512 | empty512 | empty512 | empty512 | empty512 | - memmove(prach2+(512<<3),prach2,(512<<3)); - // here we have | empty | Prach512 | Prach512 | Prach512 | Prach512 | Prach512 | Prach512 | empty512 | empty512 | empty512 | empty512 | empty512 | empty512 | - memmove(prach2+(512<<1)*6,prach2,(512<<2)*6); - // here we have | empty | Prach512 | Prach512 | Prach512 | Prach512 | Prach512 | Prach512 | Prach512 | Prach512 | Prach512 | Prach512 | Prach512 | Prach512 | - memmove(prach,prach+(512<<1),(Ncp<<2)); - // here we have | Prefix | Prach512 | Prach512 | Prach512 | Prach512 | Prach512 | Prach512 | Prach512 | Prach512 | Prach512 | Prach512 | Prach512 | Prach512 | - prach_len = (512*12)+Ncp; - } - } - break; - - case 30720: // full sampling @ 30.72 Ms/s - Ncp = Ncp*1; // to account for 30.72 Ms/s - // This is after cyclic prefix - prach2 = prach+(2*Ncp); // times 2 for complex samples - if (prach_sequence_length == 0){ - if (prach_fmt_id == 0) { // 24576 samples @ 30.72 Ms/s - idft(IDFT_24576,prachF,prach2,1); - // here we have | empty | Prach24576 | - memmove(prach,prach+(24576<<1),(Ncp<<2)); - // here we have | Prefix | Prach24576 | - prach_len = 24576+Ncp; - } else if (prach_fmt_id == 1) { // 24576 samples @ 30.72 Ms/s - idft(IDFT_24576,prachF,prach2,1); - // here we have | empty | Prach24576 | empty24576 | - memmove(prach2+(24576<<1),prach2,(24576<<2)); - // here we have | empty | Prach24576 | Prach24576 | - memmove(prach,prach+(24576<<2),(Ncp<<2)); - // here we have | Prefix | Prach24576 | Prach24576 | - prach_len = (24576*2)+Ncp; - } else if (prach_fmt_id == 2) { // 24576 samples @ 30.72 Ms/s - idft(IDFT_24576,prachF,prach2,1); - // here we have | empty | Prach24576 | empty24576 | empty24576 | empty24576 | - memmove(prach2+(24576<<1),prach2,(24576<<2)); - // here we have | empty | Prach24576 | Prach24576 | empty24576 | empty24576 | - memmove(prach2+(24576<<2),prach2,(24576<<3)); - // here we have | empty | Prach24576 | Prach24576 | Prach24576 | Prach24576 | - memmove(prach,prach+(24576<<3),(Ncp<<2)); - // here we have | Prefix | Prach24576 | Prach24576 | Prach24576 | Prach24576 | - prach_len = (24576*4)+Ncp; - } else if (prach_fmt_id == 3) { // 6144 samples @ 30.72 Ms/s - idft(IDFT_6144,prachF,prach2,1); - // here we have | empty | Prach6144 | empty6144 | empty6144 | empty6144 | - memmove(prach2+(6144<<1),prach2,(6144<<2)); - // here we have | empty | Prach6144 | Prach6144 | empty6144 | empty6144 | - memmove(prach2+(6144<<2),prach2,(6144<<3)); - // here we have | empty | Prach6144 | Prach6144 | Prach6144 | Prach6144 | - memmove(prach,prach+(6144<<3),(Ncp<<2)); - // here we have | Prefix | Prach6144 | Prach6144 | Prach6144 | Prach6144 | - prach_len = (6144*4)+Ncp; - } - } else { // short PRACH sequence - if (use_extended_prach_prefix) - Ncp += 16; // 16*kappa, kappa=1 for 30.72Msps - prach2 = prach+(2*Ncp); // times 2 for complex samples - if (prach_fmt_id == 9) { - idft(IDFT_1024,prachF,prach2,1); - // here we have | empty | Prach1024 | - memmove(prach,prach+(1024<<1),(Ncp<<2)); - // here we have | Prefix | Prach1024 | - prach_len = (1024*1)+Ncp; - } else if (prach_fmt_id == 4 || prach_fmt_id == 7) { - idft(IDFT_1024,prachF,prach2,1); - // here we have | empty | Prach1024 | empty1024 | - memmove(prach2+(1024<<1),prach2,(1024<<2)); - // here we have | empty | Prach1024 | Prach1024 | - memmove(prach,prach+(1024<<1),(Ncp<<2)); - // here we have | Prefix | Prach1024 | Prach1024 | - prach_len = (1024*2)+Ncp; - } else if (prach_fmt_id == 5) { // 4x1024 - idft(IDFT_1024,prachF,prach2,1); - // here we have | empty | Prach1024 | empty1024 | empty1024 | empty1024 | - memmove(prach2+(1024<<1),prach2,(1024<<2)); - // here we have | empty | Prach1024 | Prach1024 | empty1024 | empty1024 | - memmove(prach2+(1024<<2),prach2,(1024<<3)); - // here we have | empty | Prach1024 | Prach1024 | Prach1024 | Prach1024 | - memmove(prach,prach+(1024<<1),(Ncp<<2)); - // here we have | Prefix | Prach1024 | Prach1024 | Prach1024 | Prach1024 | - prach_len = (1024*4)+Ncp; - } else if (prach_fmt_id == 6) { // 6x1024 - idft(IDFT_1024,prachF,prach2,1); - // here we have | empty | Prach1024 | empty1024 | empty1024 | empty1024 | empty1024 | empty1024 | - memmove(prach2+(1024<<1),prach2,(1024<<2)); - // here we have | empty | Prach1024 | Prach1024 | empty1024 | empty1024 | empty1024 | empty1024 | - memmove(prach2+(1024<<2),prach2,(1024<<3)); - // here we have | empty | Prach1024 | Prach1024 | Prach1024 | Prach1024 | empty1024 | empty1024 | - memmove(prach2+(1024<<3),prach2,(1024<<3)); - // here we have | empty | Prach1024 | Prach1024 | Prach1024 | Prach1024 | Prach1024 | Prach1024 | - memmove(prach,prach+(1024<<1),(Ncp<<2)); - // here we have | Prefix | Prach1024 | Prach1024 | Prach1024 | Prach1024 | Prach1024 | Prach1024 | - prach_len = (1024*6)+Ncp; - } else if (prach_fmt_id == 8) { // 12x1024 - idft(IDFT_1024,prachF,prach2,1); - // here we have | empty | Prach1024 | empty1024 | empty1024 | empty1024 | empty1024 | empty1024 | empty1024 | empty1024 | empty1024 | empty1024 | empty1024 | empty1024 | - memmove(prach2+(1024<<1),prach2,(1024<<2)); - // here we have | empty | Prach1024 | Prach1024 | empty1024 | empty1024 | empty1024 | empty1024 | empty1024 | empty1024 | empty1024 | empty1024 | empty1024 | empty1024 | - memmove(prach2+(1024<<2),prach2,(1024<<3)); - // here we have | empty | Prach1024 | Prach1024 | Prach1024 | Prach1024 | empty1024 | empty1024 | empty1024 | empty1024 | empty1024 | empty1024 | empty1024 | empty1024 | - memmove(prach2+(1024<<3),prach2,(1024<<3)); - // here we have | empty | Prach1024 | Prach1024 | Prach1024 | Prach1024 | Prach1024 | Prach1024 | empty1024 | empty1024 | empty1024 | empty1024 | empty1024 | empty1024 | - memmove(prach2+(1024<<1)*6,prach2,(1024<<2)*6); - // here we have | empty | Prach1024 | Prach1024 | Prach1024 | Prach1024 | Prach1024 | Prach1024 | Prach1024 | Prach1024 | Prach1024 | Prach1024 | Prach1024 | Prach1024 | - memmove(prach,prach+(1024<<1),(Ncp<<2)); - // here we have | Prefix | Prach1024 | Prach1024 | Prach1024 | Prach1024 | Prach1024 | Prach1024 | Prach1024 | Prach1024 | Prach1024 | Prach1024 | Prach1024 | Prach1024 | - prach_len = (1024*12)+Ncp; - } - } - break; - - case 61440: // full sampling @ 61.44 Ms/s - Ncp = Ncp*2; // to account for 61.44 Ms/s - // This is after cyclic prefix - prach2 = prach+(Ncp<<1); //times 2 for complex samples - if (prach_sequence_length == 0){ - if (prach_fmt_id == 0) { //24576 samples @ 30.72 Ms/s, 49152 samples @ 61.44 Ms/s - idft(IDFT_49152,prachF,prach2,1); - // here we have |empty | Prach49152| - memmove(prach,prach+(49152<<1),(Ncp<<2)); - // here we have |Prefix | Prach49152| - prach_len = 49152+Ncp; - } else if (prach_fmt_id == 1) { //24576 samples @ 30.72 Ms/s, 49152 samples @ 61.44 Ms/s - idft(IDFT_49152,prachF,prach2,1); - memmove(prach2+(49152<<1),prach2,(49152<<2)); - // here we have |empty | Prach49152 | Prach49152| - memmove(prach,prach+(49152<<2),(Ncp<<2)); - // here we have |Prefix | Prach49152 | Prach49152| - prach_len = (49152*2)+Ncp; - } else if (prach_fmt_id == 2) { //24576 samples @ 30.72 Ms/s, 49152 samples @ 61.44 Ms/s - idft(IDFT_49152,prachF,prach2,1); - memmove(prach2+(49152<<1),prach2,(49152<<2)); - // here we have |empty | Prach49152 | Prach49152| empty49152 | empty49152 - memmove(prach2+(49152<<2),prach2,(49152<<3)); - // here we have |empty | Prach49152 | Prach49152| Prach49152 | Prach49152 - memmove(prach,prach+(49152<<3),(Ncp<<2)); - // here we have |Prefix | Prach49152 | Prach49152| Prach49152 | Prach49152 - prach_len = (49152*4)+Ncp; - } else if (prach_fmt_id == 3) { // 6144 samples @ 30.72 Ms/s, 12288 samples @ 61.44 Ms/s - idft(IDFT_12288,prachF,prach2,1); - memmove(prach2+(12288<<1),prach2,(12288<<2)); - // here we have |empty | Prach12288 | Prach12288| empty12288 | empty12288 - memmove(prach2+(12288<<2),prach2,(12288<<3)); - // here we have |empty | Prach12288 | Prach12288| Prach12288 | Prach12288 - memmove(prach,prach+(12288<<3),(Ncp<<2)); - // here we have |Prefix | Prach12288 | Prach12288| Prach12288 | Prach12288 - prach_len = (12288*4)+Ncp; - } - } else { // short PRACH sequence - if (use_extended_prach_prefix) - Ncp+=32; // 16*kappa, kappa=2 for 61.44Msps - prach2 = prach+(Ncp<<1); //times 2 for complex samples - if (prach_fmt_id == 4 || prach_fmt_id == 7 || prach_fmt_id == 9) { - idft(IDFT_2048,prachF,prach2,1); - // here we have |empty | Prach2048 | - if (prach_fmt_id != 9) { - memmove(prach2+(2048<<1),prach2,(2048<<2)); - prach_len = (2048*2)+Ncp; - } - else prach_len = (2048*1)+Ncp; - memmove(prach,prach+(2048<<1),(Ncp<<2)); - // here we have |Prefix | Prach2048 | Prach2048 (if ! 0xc0) | - } else if (prach_fmt_id == 5) { // 6x2048 - idft(IDFT_2048,prachF,prach2,1); - // here we have |empty | Prach2048 | - memmove(prach2+(2048<<1),prach2,(2048<<2)); - // here we have |empty | Prach2048 | Prach2048| empty2048 | empty2048 | - memmove(prach2+(2048<<2),prach2,(2048<<3)); - // here we have |empty | Prach2048 | Prach2048| Prach2048 | Prach2048 | - memmove(prach,prach+(2048<<1),(Ncp<<2)); - // here we have |Prefix | Prach2048 | - prach_len = (2048*4)+Ncp; - } else if (prach_fmt_id == 6) { // 6x2048 - idft(IDFT_2048,prachF,prach2,1); - // here we have |empty | Prach2048 | - memmove(prach2+(2048<<1),prach2,(2048<<2)); - // here we have |empty | Prach2048 | Prach2048| empty2048 | empty2048 | empty2048 | empty2048 - memmove(prach2+(2048<<2),prach2,(2048<<3)); - // here we have |empty | Prach2048 | Prach2048| Prach2048 | Prach2048 | empty2048 | empty2048 - memmove(prach2+(2048<<3),prach2,(2048<<3)); - // here we have |empty | Prach2048 | Prach2048| Prach2048 | Prach2048 | Prach2048 | Prach2048 - memmove(prach,prach+(2048<<1),(Ncp<<2)); - // here we have |Prefix | Prach2048 | - prach_len = (2048*6)+Ncp; - } else if (prach_fmt_id == 8) { // 12x2048 - idft(IDFT_2048,prachF,prach2,1); - // here we have |empty | Prach2048 | - memmove(prach2+(2048<<1),prach2,(2048<<2)); - // here we have |empty | Prach2048 | Prach2048| empty2048 | empty2048 | empty2048 | empty2048 - memmove(prach2+(2048<<2),prach2,(2048<<3)); - // here we have |empty | Prach2048 | Prach2048| Prach2048 | Prach2048 | empty2048 | empty2048 - memmove(prach2+(2048<<3),prach2,(2048<<3)); - // here we have |empty | Prach2048 | Prach2048| Prach2048 | Prach2048 | Prach2048 | Prach2048 - memmove(prach2+(2048<<1)*6,prach2,(2048<<2)*6); - // here we have |empty | Prach2048 | Prach2048| Prach2048 | Prach2048 | Prach2048 | Prach2048 | Prach2048 | Prach2048| Prach2048 | Prach2048 | Prach2048 | Prach2048| - memmove(prach,prach+(2048<<1),(Ncp<<2)); - // here we have |Prefix | Prach2048 | Prach2048| Prach2048 | Prach2048 | Prach2048 | Prach2048 | Prach2048 | Prach2048| Prach2048 | Prach2048 | Prach2048 | Prach2048| - prach_len = (2048*12)+Ncp; - } - } - break; - - case 46080: // threequarter sampling @ 46.08 Ms/s - Ncp = (Ncp*3)/2; - prach2 = prach+(Ncp<<1); - if (prach_sequence_length == 0){ - if (prach_fmt_id == 0) { - idft(IDFT_36864,prachF,prach2,1); - // here we have |empty | Prach73728| - memmove(prach,prach+(36864<<1),(Ncp<<2)); - // here we have |Prefix | Prach73728| - prach_len = (36864*1)+Ncp; - } else if (prach_fmt_id == 1) { - idft(IDFT_36864,prachF,prach2,1); - memmove(prach2+(36864<<1),prach2,(36864<<2)); - // here we have |empty | Prach73728 | Prach73728| - memmove(prach,prach+(36864<<2),(Ncp<<2)); - // here we have |Prefix | Prach73728 | Prach73728| - prach_len = (36864*2)+Ncp; - } else if (prach_fmt_id == 2) { - idft(IDFT_36864,prachF,prach2,1); - memmove(prach2+(36864<<1),prach2,(36864<<2)); - // here we have |empty | Prach73728 | Prach73728| empty73728 | empty73728 - memmove(prach2+(36864<<2),prach2,(36864<<3)); - // here we have |empty | Prach73728 | Prach73728| Prach73728 | Prach73728 - memmove(prach,prach+(36864<<3),(Ncp<<2)); - // here we have |Prefix | Prach73728 | Prach73728| Prach73728 | Prach73728 - prach_len = (36864*4)+Ncp; - } else if (prach_fmt_id == 3) { - idft(IDFT_9216,prachF,prach2,1); - memmove(prach2+(9216<<1),prach2,(9216<<2)); - // here we have |empty | Prach9216 | Prach9216| empty9216 | empty9216 - memmove(prach2+(9216<<2),prach2,(9216<<3)); - // here we have |empty | Prach9216 | Prach9216| Prach9216 | Prach9216 - memmove(prach,prach+(9216<<3),(Ncp<<2)); - // here we have |Prefix | Prach9216 | Prach9216| Prach9216 | Prach9216 - prach_len = (9216*4)+Ncp; - } - } else { // short sequence - if (use_extended_prach_prefix) - Ncp+=24; // 16*kappa, kappa=1.5 for 46.08Msps - prach2 = prach+(Ncp<<1); //times 2 for complex samples - if (prach_fmt_id == 4 || prach_fmt_id == 7 || prach_fmt_id == 9) { - idft(IDFT_1536,prachF,prach2,1); - // here we have |empty | Prach1536 | - if (prach_fmt_id != 9) { - memmove(prach2+(1536<<1),prach2,(1536<<2)); - prach_len = (1536*2)+Ncp; - } else prach_len = (1536*1)+Ncp; - - memmove(prach,prach+(1536<<1),(Ncp<<2)); - // here we have |Prefix | Prach1536 | Prach1536 (if ! 0xc0) | - - } else if (prach_fmt_id == 5) { // 6x1536 - idft(IDFT_1536,prachF,prach2,1); - // here we have |empty | Prach1536 | - memmove(prach2+(1536<<1),prach2,(1536<<2)); - // here we have |empty | Prach1536 | Prach1536| empty1536 | empty1536 | - memmove(prach2+(1536<<2),prach2,(1536<<3)); - // here we have |empty | Prach1536 | Prach1536| Prach1536 | Prach1536 | - memmove(prach,prach+(1536<<1),(Ncp<<2)); - // here we have |Prefix | Prach1536 | - prach_len = (1536*4)+Ncp; - } else if (prach_fmt_id == 6) { // 6x1536 - idft(IDFT_1536,prachF,prach2,1); - // here we have |empty | Prach1536 | - memmove(prach2+(1536<<1),prach2,(1536<<2)); - // here we have |empty | Prach1536 | Prach1536| empty1536 | empty1536 | empty1536 | empty1536 - memmove(prach2+(1536<<2),prach2,(1536<<3)); - // here we have |empty | Prach1536 | Prach1536| Prach1536 | Prach1536 | empty1536 | empty1536 - memmove(prach2+(1536<<3),prach2,(1536<<3)); - // here we have |empty | Prach1536 | Prach1536| Prach1536 | Prach1536 | Prach1536 | Prach1536 - memmove(prach,prach+(1536<<1),(Ncp<<2)); - // here we have |Prefix | Prach1536 | - prach_len = (1536*6)+Ncp; - } else if (prach_fmt_id == 8) { // 12x1536 - idft(IDFT_1536,prachF,prach2,1); - // here we have |empty | Prach1536 | - memmove(prach2+(1536<<1),prach2,(1536<<2)); - // here we have |empty | Prach1536 | Prach1536| empty1536 | empty1536 | empty1536 | empty1536 - memmove(prach2+(1536<<2),prach2,(1536<<3)); - // here we have |empty | Prach1536 | Prach1536| Prach1536 | Prach1536 | empty1536 | empty1536 - memmove(prach2+(1536<<3),prach2,(1536<<3)); - // here we have |empty | Prach1536 | Prach1536| Prach1536 | Prach1536 | Prach1536 | Prach1536 - memmove(prach2+(1536<<1)*6,prach2,(1536<<2)*6); - // here we have |empty | Prach1536 | Prach1536| Prach1536 | Prach1536 | Prach1536 | Prach1536 | Prach1536 | Prach1536| Prach1536 | Prach1536 | Prach1536 | Prach1536| - memmove(prach,prach+(1536<<1),(Ncp<<2)); - // here we have |Prefix | Prach1536 | Prach1536| Prach1536 | Prach1536 | Prach1536 | Prach1536 | Prach1536 | Prach1536| Prach1536 | Prach1536 | Prach1536 | Prach1536| - prach_len = (1536*12)+Ncp; - } - } - break; - - case 122880: // full sampling @ 122.88 Ms/s - Ncp<<=2; //to account for 122.88Mbps - // This is after cyclic prefix - prach2 = prach+(Ncp<<1); //times 2 for complex samples - if (prach_sequence_length == 0){ - if (prach_fmt_id == 0) { //24576 samples @ 30.72 Ms/s, 98304 samples @ 122.88 Ms/s - idft(IDFT_98304,prachF,prach2,1); - // here we have |empty | Prach98304| - memmove(prach,prach+(98304<<1),(Ncp<<2)); - // here we have |Prefix | Prach98304| - prach_len = (98304*1)+Ncp; - } else if (prach_fmt_id == 1) { - idft(IDFT_98304,prachF,prach2,1); - memmove(prach2+(98304<<1),prach2,(98304<<2)); - // here we have |empty | Prach98304 | Prach98304| - memmove(prach,prach+(98304<<2),(Ncp<<2)); - // here we have |Prefix | Prach98304 | Prach98304| - prach_len = (98304*2)+Ncp; - } else if (prach_fmt_id == 2) { - idft(IDFT_98304,prachF,prach2,1); - memmove(prach2+(98304<<1),prach2,(98304<<2)); - // here we have |empty | Prach98304 | Prach98304| empty98304 | empty98304 - memmove(prach2+(98304<<2),prach2,(98304<<3)); - // here we have |empty | Prach98304 | Prach98304| Prach98304 | Prach98304 - memmove(prach,prach+(98304<<3),(Ncp<<2)); - // here we have |Prefix | Prach98304 | Prach98304| Prach98304 | Prach98304 - prach_len = (98304*4)+Ncp; - } else if (prach_fmt_id == 3) { // 4x6144, Ncp 3168 - idft(IDFT_24576,prachF,prach2,1); - memmove(prach2+(24576<<1),prach2,(24576<<2)); - // here we have |empty | Prach24576 | Prach24576| empty24576 | empty24576 - memmove(prach2+(24576<<2),prach2,(24576<<3)); - // here we have |empty | Prach24576 | Prach24576| Prach24576 | Prach24576 - memmove(prach,prach+(24576<<3),(Ncp<<2)); - // here we have |Prefix | Prach24576 | Prach24576| Prach24576 | Prach24576 - prach_len = (24576*4)+Ncp; - } - } else { // short sequence - if (use_extended_prach_prefix) - Ncp+=64; // 16*kappa, kappa=4 for 122.88Msps - prach2 = prach+(Ncp<<1); //times 2 for complex samples - if (prach_fmt_id == 4 || prach_fmt_id == 7 || prach_fmt_id == 9) { - idft(IDFT_4096,prachF,prach2,1); - // here we have |empty | Prach4096 | - if (prach_fmt_id != 9) { - memmove(prach2+(4096<<1),prach2,(4096<<2)); - prach_len = (4096*2)+Ncp; - } else prach_len = (4096*1)+Ncp; - memmove(prach,prach+(4096<<1),(Ncp<<2)); - // here we have |Prefix | Prach4096 | Prach4096 (if ! 0xc0) | - } else if (prach_fmt_id == 5) { // 4x4096 - idft(IDFT_4096,prachF,prach2,1); - // here we have |empty | Prach4096 | - memmove(prach2+(4096<<1),prach2,(4096<<2)); - // here we have |empty | Prach4096 | Prach4096| empty4096 | empty4096 | - memmove(prach2+(4096<<2),prach2,(4096<<3)); - // here we have |empty | Prach4096 | Prach4096| Prach4096 | Prach4096 | - memmove(prach,prach+(4096<<1),(Ncp<<2)); - // here we have |Prefix | Prach4096 | - prach_len = (4096*4)+Ncp; - } else if (prach_fmt_id == 6) { // 6x4096 - idft(IDFT_4096,prachF,prach2,1); - // here we have |empty | Prach4096 | - memmove(prach2+(4096<<1),prach2,(4096<<2)); - // here we have |empty | Prach4096 | Prach4096| empty4096 | empty4096 | empty4096 | empty4096 - memmove(prach2+(4096<<2),prach2,(4096<<3)); - // here we have |empty | Prach4096 | Prach4096| Prach4096 | Prach4096 | empty4096 | empty4096 - memmove(prach2+(4096<<3),prach2,(4096<<3)); - // here we have |empty | Prach4096 | Prach4096| Prach4096 | Prach4096 | Prach4096 | Prach4096 - memmove(prach,prach+(4096<<1),(Ncp<<2)); - // here we have |Prefix | Prach4096 | - prach_len = (4096*6)+Ncp; - } else if (prach_fmt_id == 8) { // 12x4096 - idft(IDFT_4096,prachF,prach2,1); - // here we have |empty | Prach4096 | - memmove(prach2+(4096<<1),prach2,(4096<<2)); - // here we have |empty | Prach4096 | Prach4096| empty4096 | empty4096 | empty4096 | empty4096 - memmove(prach2+(4096<<2),prach2,(4096<<3)); - // here we have |empty | Prach4096 | Prach4096| Prach4096 | Prach4096 | empty4096 | empty4096 - memmove(prach2+(4096<<3),prach2,(4096<<3)); - // here we have |empty | Prach4096 | Prach4096| Prach4096 | Prach4096 | Prach4096 | Prach4096 - memmove(prach2+(4096<<1)*6,prach2,(4096<<2)*6); - // here we have |empty | Prach4096 | Prach4096| Prach4096 | Prach4096 | Prach4096 | Prach4096 | Prach4096 | Prach4096| Prach4096 | Prach4096 | Prach4096 | Prach4096| - memmove(prach,prach+(4096<<1),(Ncp<<2)); - // here we have |Prefix | Prach4096 | Prach4096| Prach4096 | Prach4096 | Prach4096 | Prach4096 | Prach4096 | Prach4096| Prach4096 | Prach4096 | Prach4096 | Prach4096| - prach_len = (4096*12)+Ncp; - } - } - break; - - case 92160: // three quarter sampling @ 92.16 Ms/s - Ncp = (Ncp*3); //to account for 92.16 Msps - prach2 = prach+(Ncp<<1); //times 2 for complex samples - if (prach_sequence_length == 0){ - if (prach_fmt_id == 0) { - idft(IDFT_73728,prachF,prach2,1); - // here we have |empty | Prach73728| - memmove(prach,prach+(73728<<1),(Ncp<<2)); - // here we have |Prefix | Prach73728| - prach_len = (73728*1)+Ncp; - } else if (prach_fmt_id == 1) { - idft(IDFT_73728,prachF,prach2,1); - memmove(prach2+(73728<<1),prach2,(73728<<2)); - // here we have |empty | Prach73728 | Prach73728| - memmove(prach,prach+(73728<<2),(Ncp<<2)); - // here we have |Prefix | Prach73728 | Prach73728| - prach_len = (73728*2)+Ncp; - } if (prach_fmt_id == 2) { - idft(IDFT_73728,prachF,prach2,1); - memmove(prach2+(73728<<1),prach2,(73728<<2)); - // here we have |empty | Prach73728 | Prach73728| empty73728 | empty73728 - memmove(prach2+(73728<<2),prach2,(73728<<3)); - // here we have |empty | Prach73728 | Prach73728| Prach73728 | Prach73728 - memmove(prach,prach+(73728<<3),(Ncp<<2)); - // here we have |Prefix | Prach73728 | Prach73728| Prach73728 | Prach73728 - prach_len = (73728*4)+Ncp; - } else if (prach_fmt_id == 3) { - idft(IDFT_18432,prachF,prach2,1); - memmove(prach2+(18432<<1),prach2,(18432<<2)); - // here we have |empty | Prach18432 | Prach18432| empty18432 | empty18432 - memmove(prach2+(18432<<2),prach2,(18432<<3)); - // here we have |empty | Prach18432 | Prach18432| Prach18432 | Prach18432 - memmove(prach,prach+(18432<<3),(Ncp<<2)); - // here we have |Prefix | Prach18432 | Prach18432| Prach18432 | Prach18432 - prach_len = (18432*4)+Ncp; - } - } else { // short sequence - if (use_extended_prach_prefix) - Ncp+=48; // 16*kappa, kappa=3 for 92.16Msps - prach2 = prach+(Ncp<<1); //times 2 for complex samples - if (prach_fmt_id == 4 || prach_fmt_id == 7 || prach_fmt_id == 9) { - idft(IDFT_3072,prachF,prach2,1); - // here we have |empty | Prach3072 | - if (prach_fmt_id != 9) { - memmove(prach2+(3072<<1),prach2,(3072<<2)); - prach_len = (3072*2)+Ncp; - } else prach_len = (3072*1)+Ncp; - memmove(prach,prach+(3072<<1),(Ncp<<2)); - // here we have |Prefix | Prach3072 | Prach3072 (if ! 0xc0) | - } else if (prach_fmt_id == 6) { // 6x3072 - idft(IDFT_3072,prachF,prach2,1); - // here we have |empty | Prach3072 | - memmove(prach2+(3072<<1),prach2,(3072<<2)); - // here we have |empty | Prach3072 | Prach3072| empty3072 | empty3072 | empty3072 | empty3072 - memmove(prach2+(3072<<2),prach2,(3072<<3)); - // here we have |empty | Prach3072 | Prach3072| Prach3072 | Prach3072 | empty3072 | empty3072 - memmove(prach2+(3072<<3),prach2,(3072<<3)); - // here we have |empty | Prach3072 | Prach3072| Prach3072 | Prach3072 | Prach3072 | Prach3072 - memmove(prach,prach+(3072<<1),(Ncp<<2)); - // here we have |Prefix | Prach3072 | - prach_len = (3072*6)+Ncp; - } else if (prach_fmt_id == 5) { // 4x3072 - idft(IDFT_3072,prachF,prach2,1); - // here we have |empty | Prach3072 | - memmove(prach2+(3072<<1),prach2,(3072<<2)); - // here we have |empty | Prach3072 | Prach3072| empty3072 | empty3072 | - memmove(prach2+(3072<<2),prach2,(3072<<3)); - // here we have |empty | Prach3072 | Prach3072| Prach3072 | Prach3072 | - memmove(prach,prach+(3072<<1),(Ncp<<2)); - // here we have |Prefix | Prach3072 | - prach_len = (3072*4)+Ncp; - } else if (prach_fmt_id == 6) { // 12x3072 - idft(IDFT_3072,prachF,prach2,1); - // here we have |empty | Prach3072 | - memmove(prach2+(3072<<1),prach2,(3072<<2)); - // here we have |empty | Prach3072 | Prach3072| empty3072 | empty3072 | empty3072 | empty3072 - memmove(prach2+(3072<<2),prach2,(3072<<3)); - // here we have |empty | Prach3072 | Prach3072| Prach3072 | Prach3072 | empty3072 | empty3072 - memmove(prach2+(3072<<3),prach2,(3072<<3)); - // here we have |empty | Prach3072 | Prach3072| Prach3072 | Prach3072 | Prach3072 | Prach3072 - memmove(prach2+(3072<<1)*6,prach2,(3072<<2)*6); - // here we have |empty | Prach3072 | Prach3072| Prach3072 | Prach3072 | Prach3072 | Prach3072 | Prach3072 | Prach3072| Prach3072 | Prach3072 | Prach3072 | Prach3072| - memmove(prach,prach+(3072<<1),(Ncp<<2)); - // here we have |Prefix | Prach3072 | Prach3072| Prach3072 | Prach3072 | Prach3072 | Prach3072 | Prach3072 | Prach3072| Prach3072 | Prach3072 | Prach3072 | Prach3072| - prach_len = (3072*12)+Ncp; - } - } - break; - - default: - AssertFatal(1==0,"sample rate %f MHz not supported for numerology %d\n", fp->samples_per_subframe / 1000.0, mu); + } else { // short PRACH sequence + if (prach_fmt_id == 9) { + // here we have | empty | Prach | + memcpy(prach, prach+(dftlen<<1), (Ncp<<2)); + // here we have | Prefix | Prach | + prach_len = (dftlen*1)+Ncp; + } else if (prach_fmt_id == 4 || prach_fmt_id == 7) { + // here we have | empty | Prach | empty | + memcpy(prach2+(dftlen<<1), prach2, (dftlen<<2)); + // here we have | empty | Prach | Prach | + memcpy(prach, prach+(dftlen<<1), (Ncp<<2)); + // here we have | Prefix | Prach | Prach | + prach_len = (dftlen*2)+Ncp; + } else if (prach_fmt_id == 5) { // 4xdftlen + // here we have | empty | Prach | empty | empty | empty | + memcpy(prach2+(dftlen<<1), prach2, (dftlen<<2)); + // here we have | empty | Prach | Prach | empty | empty | + memcpy(prach2+(dftlen<<2), prach2, (dftlen<<3)); + // here we have | empty | Prach | Prach | Prach | Prach | + memcpy(prach, prach+(dftlen<<1), (Ncp<<2)); + // here we have | Prefix | Prach | Prach | Prach | Prach | + prach_len = (dftlen*4)+Ncp; + } else if (prach_fmt_id == 6) { // 6xdftlen + // here we have | empty | Prach | empty | empty | empty | empty | empty | + memcpy(prach2+(dftlen<<1), prach2, (dftlen<<2)); + // here we have | empty | Prach | Prach | empty | empty | empty | empty | + memcpy(prach2+(dftlen<<2), prach2, (dftlen<<3)); + // here we have | empty | Prach | Prach | Prach | Prach | empty | empty | + memcpy(prach2+(dftlen<<3), prach2, (dftlen<<3)); + // here we have | empty | Prach | Prach | Prach | Prach | Prach | Prach | + memcpy(prach, prach+(dftlen<<1), (Ncp<<2)); + // here we have | Prefix | Prach | Prach | Prach | Prach | Prach | Prach | + prach_len = (dftlen*6)+Ncp; + } else if (prach_fmt_id == 8) { // 12xdftlen + // here we have | empty | Prach | empty | empty | empty | empty | empty | empty | empty | empty | empty | empty | empty | + memcpy(prach2+(dftlen<<1), prach2, (dftlen<<2)); + // here we have | empty | Prach | Prach | empty | empty | empty | empty | empty | empty | empty | empty | empty | empty | + memcpy(prach2+(dftlen<<2), prach2, (dftlen<<3)); + // here we have | empty | Prach | Prach | Prach | Prach | empty | empty | empty | empty | empty | empty | empty | empty | + memcpy(prach2+(dftlen<<3), prach2, (dftlen<<3)); + // here we have | empty | Prach | Prach | Prach | Prach | Prach | Prach | empty | empty | empty | empty | empty | empty | + memcpy(prach2+(dftlen<<1)*6, prach2, (dftlen<<2)*6); + // here we have | empty | Prach | Prach | Prach | Prach | Prach | Prach | Prach | Prach | Prach | Prach | Prach | Prach | + memcpy(prach, prach+(dftlen<<1), (Ncp<<2)); + // here we have | Prefix | Prach | Prach | Prach | Prach | Prach | Prach | Prach | Prach | Prach | Prach | Prach | Prach | + prach_len = (dftlen*12)+Ncp; } } diff --git a/openair1/PHY/NR_UE_TRANSPORT/nr_transport_proto_ue.h b/openair1/PHY/NR_UE_TRANSPORT/nr_transport_proto_ue.h index 9bc3643557..9e680bf227 100644 --- a/openair1/PHY/NR_UE_TRANSPORT/nr_transport_proto_ue.h +++ b/openair1/PHY/NR_UE_TRANSPORT/nr_transport_proto_ue.h @@ -63,10 +63,12 @@ void free_nr_ue_dlsch(NR_UE_DLSCH_t **dlsch, uint16_t N_RB_DL); */ NR_UE_DLSCH_t *new_nr_ue_dlsch(uint8_t Kmimo,uint8_t Mdlharq,uint32_t Nsoft,uint8_t max_turbo_iterations,uint16_t N_RB_DL); +void free_nr_ue_ulsch(NR_UE_ULSCH_t **ulschptr, + uint16_t N_RB_UL, + NR_DL_FRAME_PARMS* frame_parms); -void free_nr_ue_ulsch(NR_UE_ULSCH_t **ulsch, uint16_t N_RB_UL); -NR_UE_ULSCH_t *new_nr_ue_ulsch(uint16_t N_RB_UL, int number_of_harq_pids); +NR_UE_ULSCH_t *new_nr_ue_ulsch(uint16_t N_RB_UL, int number_of_harq_pids, NR_DL_FRAME_PARMS* frame_parms); /** \brief This function computes the LLRs for ML (max-logsum approximation) dual-stream QPSK/QPSK reception. @param stream0_in Input from channel compensated (MR combined) stream 0 @@ -707,7 +709,8 @@ unsigned short nr_dlsch_extract_rbs_single(int **rxdataF, unsigned short nb_rb_pdsch, uint8_t n_dmrs_cdm_groups, NR_DL_FRAME_PARMS *frame_parms, - uint16_t dlDmrsSymbPos); + uint16_t dlDmrsSymbPos, + int chest_time_type); /** \fn dlsch_extract_rbs_multiple(int32_t **rxdataF, int32_t **dl_ch_estimates, @@ -733,7 +736,7 @@ unsigned short nr_dlsch_extract_rbs_single(int **rxdataF, @param n_dmrs_cdm_groups @param frame_parms Pointer to frame descriptor */ -unsigned short nr_dlsch_extract_rbs_multiple(int **rxdataF, +void nr_dlsch_extract_rbs(int **rxdataF, int **dl_ch_estimates, int **rxdataF_ext, int **dl_ch_estimates_ext, @@ -745,7 +748,8 @@ unsigned short nr_dlsch_extract_rbs_multiple(int **rxdataF, uint8_t n_dmrs_cdm_groups, uint8_t Nl, NR_DL_FRAME_PARMS *frame_parms, - uint16_t dlDmrsSymbPos); + uint16_t dlDmrsSymbPos, + int chest_time_type); /** \fn dlsch_extract_rbs_TM7(int32_t **rxdataF, int32_t **dl_bf_ch_estimates, @@ -824,28 +828,12 @@ void nr_dlsch_channel_compensation_core(int **rxdataF_ext, int start_point); void nr_dlsch_deinterleaving(uint8_t symbol, - uint8_t start_symbol, - uint16_t L, - uint16_t *llr, - uint16_t *llr_deint, - uint16_t nb_rb_pdsch); + uint8_t start_symbol, + uint16_t L, + uint16_t *llr, + uint16_t *llr_deint, + uint16_t nb_rb_pdsch); -void dlsch_dual_stream_correlation(NR_DL_FRAME_PARMS *frame_parms, - unsigned char symbol, - unsigned short nb_rb, - int **dl_ch_estimates_ext, - int **dl_ch_estimates_ext_i, - int **dl_ch_rho_ext, - unsigned char output_shift); - -void dlsch_dual_stream_correlationTM34(NR_DL_FRAME_PARMS *frame_parms, - unsigned char symbol, - unsigned short nb_rb, - int **dl_ch_estimates_ext, - int **dl_ch_estimates_ext_i, - int **dl_ch_rho_ext, - unsigned char output_shift0, - unsigned char output_shift1); //This function is used to compute multiplications in Hhermitian * H matrix void conjch0_mult_ch1(int *ch0, int *ch1, @@ -897,19 +885,6 @@ void nr_dlsch_detection_mrc(int **rxdataF_comp, unsigned short nb_rb, int length); -void nr_dlsch_detection_mrc_core(int **rxdataF_comp, - int **rxdataF_comp_i, - int **rho, - int **rho_i, - int **dl_ch_mag, - int **dl_ch_magb, - int **dl_ch_mag_i, - int **dl_ch_magb_i, - unsigned char n_tx, - unsigned char n_rx, - int length, - int start_point); - void det_HhH(int32_t *after_mf_00, int32_t *after_mf_01, int32_t *after_mf_10, @@ -1040,8 +1015,7 @@ uint32_t nr_dlsch_decoding(PHY_VARS_NR_UE *phy_vars_ue, uint16_t nb_symb_sch, uint8_t nr_slot_rx, uint8_t harq_pid, - uint8_t is_crnti, - uint8_t llr8_flag); + uint8_t is_crnti); int nr_ulsch_encoding(PHY_VARS_NR_UE *ue, NR_UE_ULSCH_t *ulsch, @@ -1105,6 +1079,9 @@ uint32_t dlsch_decoding_emul(PHY_VARS_NR_UE *phy_vars_ue, int32_t nr_rx_pdcch(PHY_VARS_NR_UE *ue, UE_nr_rxtx_proc_t *proc, + int32_t pdcch_est_size, + int32_t pdcch_dl_ch_estimates[][pdcch_est_size], + int16_t *pdcch_e_rx, fapi_nr_dl_config_dci_dl_pdu_rel15_t *rel15); @@ -1152,15 +1129,20 @@ int rx_sss(PHY_VARS_NR_UE *phy_vars_ue,int32_t *tot_metric,uint8_t *flip_max,uin */ int nr_rx_pbch( PHY_VARS_NR_UE *ue, UE_nr_rxtx_proc_t *proc, + const int estimateSz, + struct complex16 dl_ch_estimates[][estimateSz], NR_UE_PBCH *nr_ue_pbch_vars, NR_DL_FRAME_PARMS *frame_parms, uint8_t eNB_id, uint8_t i_ssb, - MIMO_mode_t mimo_mode); + MIMO_mode_t mimo_mode, + NR_UE_PDCCH_CONFIG *phy_pdcch_config, + fapiPbch_t* result); int nr_pbch_detection(UE_nr_rxtx_proc_t *proc, - PHY_VARS_NR_UE *ue, - int pbch_initial_symbol); + PHY_VARS_NR_UE *ue, + int pbch_initial_symbol, + NR_UE_PDCCH_CONFIG *phy_pdcch_config); uint16_t rx_pbch_emul(PHY_VARS_NR_UE *phy_vars_ue, uint8_t eNB_id, @@ -1477,16 +1459,6 @@ uint64_t cqi2hex(uint32_t cqi); uint16_t computeRIV(uint16_t N_RB_DL,uint16_t RBstart,uint16_t Lcrbs); - -/** \brief This routine extracts a single subband PMI from a bitmap coming from UCI or the pmi_extend function - @param N_RB_DL number of resource blocks - @param mimo_mode - @param pmi_alloc subband PMI bitmap - @param rb resource block for which to extract PMI - @returns subband PMI -*/ -uint8_t get_pmi(uint8_t N_RB_DL,MIMO_mode_t mode, uint32_t pmi_alloc,uint16_t rb); - int get_nCCE_offset_l1(int *CCE_table, const unsigned char L, const int nCCE, @@ -1588,7 +1560,7 @@ uint8_t get_num_prach_tdd(module_id_t Mod_id); @param frame_type 0-FDD, 1-TDD @returns 0-1 accordingly */ -uint8_t get_prach_fmt(uint8_t prach_ConfigIndex,lte_frame_type_t frame_type); +uint8_t get_prach_fmt(uint8_t prach_ConfigIndex,frame_type_t frame_type); /*! \brief Helper for MAC, returns frequency index of PRACH resource in TDD for a particular configuration index @@ -1610,7 +1582,7 @@ void compute_prach_seq(uint16_t rootSequenceIndex, uint8_t prach_ConfigIndex, uint8_t zeroCorrelationZoneConfig, uint8_t highSpeedFlag, - lte_frame_type_t frame_type, + frame_type_t frame_type, uint32_t X_u[64][839]); @@ -1666,8 +1638,10 @@ uint8_t get_prach_prb_offset(NR_DL_FRAME_PARMS *frame_parms, uint8_t nr_dci_decoding_procedure(PHY_VARS_NR_UE *ue, UE_nr_rxtx_proc_t *proc, + int16_t *pdcch_e_rx, fapi_nr_dci_indication_t *dci_ind, - fapi_nr_dl_config_dci_dl_pdu_rel15_t *rel15); + fapi_nr_dl_config_dci_dl_pdu_rel15_t *rel15, + NR_UE_PDCCH_CONFIG *phy_pdcch_config); /** \brief This function is the top-level entry point to PDSCH demodulation, after frequency-domain transformation and channel estimation. It performs @@ -1701,7 +1675,7 @@ int nr_rx_pdsch(PHY_VARS_NR_UE *ue, unsigned char i_mod, unsigned char harq_pid); -int32_t generate_nr_prach(PHY_VARS_NR_UE *ue, uint8_t gNB_id, uint8_t subframe); +int32_t generate_nr_prach(PHY_VARS_NR_UE *ue, uint8_t gNB_id, int frame, uint8_t slot); void dump_nrdlsch(PHY_VARS_NR_UE *ue,uint8_t gNB_id,uint8_t nr_slot_rx,unsigned int *coded_bits_per_codeword,int round, unsigned char harq_pid); /**@}*/ diff --git a/openair1/PHY/NR_UE_TRANSPORT/nr_transport_ue.h b/openair1/PHY/NR_UE_TRANSPORT/nr_transport_ue.h index caf3a19d85..7ecba40c3a 100644 --- a/openair1/PHY/NR_UE_TRANSPORT/nr_transport_ue.h +++ b/openair1/PHY/NR_UE_TRANSPORT/nr_transport_ue.h @@ -84,13 +84,13 @@ typedef struct { /// Pointer to the payload + CRC uint8_t *b; /// Pointers to transport block segments - uint8_t *c[MAX_NUM_NR_ULSCH_SEGMENTS]; + uint8_t **c; /// LDPC-code outputs - uint8_t *d[MAX_NUM_NR_ULSCH_SEGMENTS]; + uint8_t **d; /// LDPC-code outputs (TS 36.212 V15.4.0, Sec 5.3.2 p. 17) - uint8_t *e; + uint8_t *e; /// Rate matching (Interleaving) outputs (TS 36.212 V15.4.0, Sec 5.4.2.2 p. 30) - uint8_t *f; + uint8_t *f; /// Number of code segments uint32_t C; /// Number of bits in code segments @@ -122,55 +122,15 @@ typedef struct { typedef struct { /// SRS active flag uint8_t srs_active; -//#if defined(UPGRADE_RAT_NR) -#if 1 // Pointers to HARQ processes for the ULSCH NR_UL_UE_HARQ_t *harq_processes[NR_MAX_ULSCH_HARQ_PROCESSES]; int harq_process_id[NR_MAX_SLOTS_PER_FRAME]; // UL number of harq processes uint8_t number_harq_processes_for_pusch; -#endif - /* - /// Pointer to CQI data (+1 for 8 bits crc) - uint8_t o[1+MAX_CQI_BYTES]; - /// Length of CQI data (bits) - uint8_t O; - /// Format of CQI data - UCI_format_t uci_format; - /// Rank information - uint8_t o_RI[2]; - /// Length of rank information (bits) - uint8_t O_RI; - /// Pointer to ACK - uint8_t o_ACK[4]; - */ /// Minimum number of CQI bits for PUSCH (36-212 r8.6, Sec 5.2.4.1 p. 37) uint8_t O_CQI_MIN; /// ACK/NAK Bundling flag uint8_t bundling; - /// Concatenated "g"-sequences (for definition see 36-212 V15.4.0 2018-12, p.31) - uint8_t g[MAX_NUM_NR_CHANNEL_BITS] __attribute__ ((aligned(32))); - /// Interleaved "h"-sequences (for definition see 36-212 V8.6 2009-03, p.17-18) - uint8_t h[MAX_NUM_NR_CHANNEL_BITS]; - /// Scrambled "b"-sequences (for definition see 36-211 V8.6 2009-03, p.14) - uint8_t b_tilde[MAX_NUM_NR_CHANNEL_BITS]; - /// Modulated "d"-sequences (for definition see 36-211 V8.6 2009-03, p.14) - int32_t d_mod[MAX_NUM_NR_RE] __attribute__ ((aligned(16))); - /// Transform-coded "y"-sequences (for definition see 38-211 V15.3.0 2018-09, subsection 6.3.1.4) - int32_t y[MAX_NUM_NR_RE] __attribute__ ((aligned(16))); - /* - /// "q" sequences for CQI/PMI (for definition see 36-212 V8.6 2009-03, p.27) - uint8_t q[MAX_CQI_PAYLOAD]; - - /// coded and interleaved CQI bits - uint8_t o_w[(MAX_CQI_BITS+8)*3]; - /// coded CQI bits - uint8_t o_d[96+((MAX_CQI_BITS+8)*3)]; - /// coded ACK bits - uint8_t q_ACK[MAX_ACK_PAYLOAD]; - /// coded RI bits - uint8_t q_RI[MAX_RI_PAYLOAD]; - */ /// beta_offset_cqi times 8 uint16_t beta_offset_cqi_times8; /// beta_offset_ri times 8 @@ -219,9 +179,12 @@ typedef struct { /// Pointer to the payload uint8_t *b; /// Pointers to transport block segments - uint8_t *c[MAX_NUM_NR_DLSCH_SEGMENTS]; + uint8_t **c; + /// soft bits for each received segment ("d"-sequence)(for definition see 36-212 V8.6 2009-03, p.15) + /// Accumulates the soft bits for each round to increase decoding success (HARQ) + int16_t **d; /// Index of current HARQ round for this DLSCH - uint8_t round; + uint8_t DLround; /// MCS table for this DLSCH uint8_t mcs_table; /// MCS format for this DLSCH @@ -234,14 +197,6 @@ typedef struct { uint8_t rvidx; /// MIMO mode for this DLSCH MIMO_nrmode_t mimo_mode; - /// soft bits for each received segment ("w"-sequence)(for definition see 36-212 V8.6 2009-03, p.15) - int16_t *w[MAX_NUM_NR_DLSCH_SEGMENTS]; - /// for abstraction soft bits for each received segment ("w"-sequence)(for definition see 36-212 V8.6 2009-03, p.15) - //double w_abs[MAX_NUM_NR_DLSCH_SEGMENTS][3*8448]; - /// soft bits for each received segment ("d"-sequence)(for definition see 36-212 V8.6 2009-03, p.15) - int16_t *d[MAX_NUM_NR_DLSCH_SEGMENTS]; - /// LDPC processing buffers - t_nrLDPC_procBuf* p_nrLDPC_procBuf[MAX_NUM_NR_DLSCH_SEGMENTS]; /// Number of code segments uint32_t C; /// Number of bits in code segments @@ -305,6 +260,9 @@ typedef struct { uint16_t ptrs_symbols; // PTRS symbol index, to be updated every PTRS symbol within a slot. uint8_t ptrs_symbol_index; + uint32_t tbslbrm; + uint8_t nscid; + uint16_t dlDmrsScramblingId; /// PDU BITMAP uint16_t pduBitmap; } NR_DL_UE_HARQ_t; diff --git a/openair1/PHY/NR_UE_TRANSPORT/nr_ue_rf_helpers.c b/openair1/PHY/NR_UE_TRANSPORT/nr_ue_rf_helpers.c index 6530dd9512..80b803779d 100644 --- a/openair1/PHY/NR_UE_TRANSPORT/nr_ue_rf_helpers.c +++ b/openair1/PHY/NR_UE_TRANSPORT/nr_ue_rf_helpers.c @@ -67,7 +67,7 @@ void nr_rf_card_config_gain(openair0_config_t *openair0_cfg, openair0_cfg->autocal[i] = 1; if (i < openair0_cfg->rx_num_channels) { - LOG_I(PHY, "HW: Configuring channel %d (rf_chain %d): setting tx_gain %f, rx_gain %f\n", + LOG_I(PHY, "HW: Configuring channel %d (rf_chain %d): setting tx_gain %.0f, rx_gain %.0f\n", i, rf_chain, openair0_cfg->tx_gain[i], @@ -86,27 +86,29 @@ void nr_rf_card_config_freq(openair0_config_t *openair0_cfg, uint8_t cc_id = 0; PHY_VARS_NR_UE *ue = PHY_vars_UE_g[mod_id][cc_id]; int rf_chain = ue->rf_map.chain; + double freq_scale = (double)(dl_carrier + freq_offset) / dl_carrier; for (int i = rf_chain; i < rf_chain + 4; i++) { if (i < openair0_cfg->rx_num_channels) - openair0_cfg->rx_freq[i + rf_chain] = dl_carrier + freq_offset; + openair0_cfg->rx_freq[i + rf_chain] = dl_carrier * freq_scale; else openair0_cfg->rx_freq[i] = 0.0; if (itx_num_channels) - openair0_cfg->tx_freq[i] = ul_carrier + freq_offset; + openair0_cfg->tx_freq[i] = ul_carrier * freq_scale; else openair0_cfg->tx_freq[i] = 0.0; openair0_cfg->autocal[i] = 1; if (i < openair0_cfg->rx_num_channels) { - LOG_I(PHY, "HW: Configuring channel %d (rf_chain %d): setting tx_freq %f Hz, rx_freq %f Hz\n", + LOG_I(PHY, "HW: Configuring channel %d (rf_chain %d): setting tx_freq %.0f Hz, rx_freq %.0f Hz, tune_offset %.0f\n", i, rf_chain, openair0_cfg->tx_freq[i], - openair0_cfg->rx_freq[i]); + openair0_cfg->rx_freq[i], + openair0_cfg->tune_offset); } } diff --git a/openair1/PHY/NR_UE_TRANSPORT/nr_ulsch_coding.c b/openair1/PHY/NR_UE_TRANSPORT/nr_ulsch_coding.c index 0ab4c94b96..d09f2554cc 100644 --- a/openair1/PHY/NR_UE_TRANSPORT/nr_ulsch_coding.c +++ b/openair1/PHY/NR_UE_TRANSPORT/nr_ulsch_coding.c @@ -43,10 +43,10 @@ //#define DEBUG_ULSCH_CODING -void free_nr_ue_ulsch(NR_UE_ULSCH_t **ulschptr, uint16_t N_RB_UL) +void free_nr_ue_ulsch(NR_UE_ULSCH_t **ulschptr, + uint16_t N_RB_UL, + NR_DL_FRAME_PARMS* frame_parms) { -{ - int i, r; NR_UE_ULSCH_t *ulsch = *ulschptr; if (ulsch) { @@ -54,15 +54,15 @@ void free_nr_ue_ulsch(NR_UE_ULSCH_t **ulschptr, uint16_t N_RB_UL) printf("Freeing ulsch %p\n",ulsch); #endif - uint16_t a_segments = MAX_NUM_NR_ULSCH_SEGMENTS; //number of segments to be allocated + int max_layers = (frame_parms->nb_antennas_txnb_antennas_tx : NR_MAX_NB_LAYERS; + uint16_t a_segments = MAX_NUM_NR_ULSCH_SEGMENTS_PER_LAYER*max_layers; //number of segments to be allocated - if (N_RB_UL != 273) { - a_segments = a_segments*N_RB_UL; - a_segments = a_segments/273 +1; - } + if (N_RB_UL != 273) { + a_segments = a_segments*N_RB_UL; + a_segments = a_segments/273 +1; + } - - for (i=0; iharq_processes[i]) { if (ulsch->harq_processes[i]->a) { @@ -81,7 +81,7 @@ void free_nr_ue_ulsch(NR_UE_ULSCH_t **ulschptr, uint16_t N_RB_UL) free16(ulsch->harq_processes[i]->f,14*N_RB_UL*12*8); ulsch->harq_processes[i]->f = NULL; } - for (r=0; rharq_processes[i]->c[r]) { free16(ulsch->harq_processes[i]->c[r],((r==0)?8:0) + 3+768); ulsch->harq_processes[i]->c[r] = NULL; @@ -94,6 +94,15 @@ void free_nr_ue_ulsch(NR_UE_ULSCH_t **ulschptr, uint16_t N_RB_UL) } + if (ulsch->harq_processes[i]->c) { + free16(ulsch->harq_processes[i]->c,a_segments); + ulsch->harq_processes[i]->c = NULL; + } + if (ulsch->harq_processes[i]->d) { + free16(ulsch->harq_processes[i]->d,a_segments); + ulsch->harq_processes[i]->d = NULL; + } + free16(ulsch->harq_processes[i],sizeof(NR_UL_UE_HARQ_t)); ulsch->harq_processes[i] = NULL; } @@ -101,13 +110,13 @@ void free_nr_ue_ulsch(NR_UE_ULSCH_t **ulschptr, uint16_t N_RB_UL) free16(ulsch,sizeof(NR_UE_ULSCH_t)); *ulschptr = NULL; } - } -NR_UE_ULSCH_t *new_nr_ue_ulsch(uint16_t N_RB_UL, int number_of_harq_pids) -{ - uint16_t a_segments = MAX_NUM_NR_ULSCH_SEGMENTS; //number of segments to be allocated +NR_UE_ULSCH_t *new_nr_ue_ulsch(uint16_t N_RB_UL, int number_of_harq_pids, NR_DL_FRAME_PARMS* frame_parms) { + + int max_layers = (frame_parms->nb_antennas_txnb_antennas_tx : NR_MAX_NB_LAYERS; + uint16_t a_segments = MAX_NUM_NR_ULSCH_SEGMENTS_PER_LAYER*max_layers; //number of segments to be allocated if (N_RB_UL != 273) { a_segments = a_segments*N_RB_UL; @@ -140,6 +149,8 @@ NR_UE_ULSCH_t *new_nr_ue_ulsch(uint16_t N_RB_UL, int number_of_harq_pids) DevAssert(ulsch->harq_processes[i]->b); bzero(ulsch->harq_processes[i]->b,ulsch_bytes); + ulsch->harq_processes[i]->c = malloc16(a_segments*sizeof(uint8_t *)); + ulsch->harq_processes[i]->d = malloc16(a_segments*sizeof(uint16_t *)); for (int r = 0; r < a_segments; r++) { // account for filler in first segment and CRCs for multiple segment case ulsch->harq_processes[i]->c[r] = malloc16(8448); @@ -171,53 +182,32 @@ int nr_ulsch_encoding(PHY_VARS_NR_UE *ue, NR_UE_ULSCH_t *ulsch, NR_DL_FRAME_PARMS* frame_parms, uint8_t harq_pid, - unsigned int G) -{ + unsigned int G) { + start_meas(&ue->ulsch_encoding_stats); -/////////////////////////parameters and variables declaration///////////////////////// -/////////// - - unsigned int crc; - NR_UL_UE_HARQ_t *harq_process; - uint16_t nb_rb ; - uint32_t A, F; - uint32_t *pz; - uint8_t mod_order; - uint16_t Kr,r; - uint32_t r_offset; - uint32_t E,Kb; - uint8_t Ilbrm; - uint32_t Tbslbrm; - uint16_t R; - float Coderate; - -/////////// -/////////////////////////////////////////////////////////////////////////////////////// - /////////////////////////parameters and variables initialization///////////////////////// /////////// - crc = 1; - harq_process = ulsch->harq_processes[harq_pid]; - nb_rb = harq_process->pusch_pdu.rb_size; - A = harq_process->pusch_pdu.pusch_data.tb_size*8; - pz = &harq_process->Z; - mod_order = nr_get_Qm_ul(harq_process->pusch_pdu.mcs_index, harq_process->pusch_pdu.mcs_table); - R = nr_get_code_rate_ul(harq_process->pusch_pdu.mcs_index, harq_process->pusch_pdu.mcs_table); - Kr=0; - r_offset=0; - F=0; - Ilbrm = 0; - Tbslbrm = 950984; //max tbs - Coderate = 0.0; + unsigned int crc = 1; + NR_UL_UE_HARQ_t *harq_process = ulsch->harq_processes[harq_pid]; + uint16_t nb_rb = harq_process->pusch_pdu.rb_size; + uint32_t A = harq_process->pusch_pdu.pusch_data.tb_size<<3; + uint32_t *pz = &harq_process->Z; + uint8_t mod_order = harq_process->pusch_pdu.qam_mod_order; + uint16_t Kr=0; + uint32_t r_offset=0; + uint32_t F=0; + // target_code_rate is in 0.1 units + float Coderate = (float) harq_process->pusch_pdu.target_code_rate / 10240.0f; + /////////// ///////////////////////////////////////////////////////////////////////////////////////// VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_NR_UE_ULSCH_ENCODING, VCD_FUNCTION_IN); LOG_D(NR_PHY, "ulsch coding nb_rb %d, Nl = %d\n", nb_rb, harq_process->pusch_pdu.nrOfLayers); - LOG_D(NR_PHY, "ulsch coding A %d G %d mod_order %d\n", A, G, mod_order); + LOG_D(NR_PHY, "ulsch coding A %d G %d mod_order %d Coderate %f\n", A, G, mod_order, Coderate); LOG_D(NR_PHY, "harq_pid %d harq_process->ndi %d, pusch_data.new_data_indicator %d\n", harq_pid,harq_process->ndi,harq_process->pusch_pdu.pusch_data.new_data_indicator); @@ -237,6 +227,8 @@ int nr_ulsch_encoding(PHY_VARS_NR_UE *ue, printf("\n"); */ + int max_payload_bytes = MAX_NUM_NR_ULSCH_SEGMENTS_PER_LAYER*harq_process->pusch_pdu.nrOfLayers*1056; + if (A > 3824) { // Add 24-bit crc (polynomial A) to payload crc = crc24a(harq_process->a,A)>>8; @@ -248,7 +240,7 @@ int nr_ulsch_encoding(PHY_VARS_NR_UE *ue, harq_process->B = A+24; - AssertFatal((A/8)+4 <= MAX_NR_ULSCH_PAYLOAD_BYTES,"A %d is too big (A/8+4 = %d > %d)\n",A,(A/8)+4,MAX_NR_ULSCH_PAYLOAD_BYTES); + AssertFatal((A/8)+4 <= max_payload_bytes,"A %d is too big (A/8+4 = %d > %d)\n",A,(A/8)+4,max_payload_bytes); memcpy(harq_process->b,harq_process->a,(A/8)+4); } @@ -262,7 +254,7 @@ int nr_ulsch_encoding(PHY_VARS_NR_UE *ue, harq_process->B = A+16; - AssertFatal((A/8)+3 <= MAX_NR_ULSCH_PAYLOAD_BYTES,"A %d is too big (A/8+3 = %d > %d)\n",A,(A/8)+3,MAX_NR_ULSCH_PAYLOAD_BYTES); + AssertFatal((A/8)+3 <= max_payload_bytes,"A %d is too big (A/8+3 = %d > %d)\n",A,(A/8)+3,max_payload_bytes); memcpy(harq_process->b,harq_process->a,(A/8)+3); // using 3 bytes to mimic the case of 24 bit crc } @@ -272,11 +264,6 @@ int nr_ulsch_encoding(PHY_VARS_NR_UE *ue, ///////////////////////// b---->| block segmentation |---->c ///////////////////////// /////////// - if (R<1024) - Coderate = (float) R /(float) 1024; - else - Coderate = (float) R /(float) 2048; - if ((A <=292) || ((A<=3824) && (Coderate <= 0.6667)) || Coderate <= 0.25){ harq_process->BG = 2; } @@ -286,14 +273,19 @@ int nr_ulsch_encoding(PHY_VARS_NR_UE *ue, VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_NR_SEGMENTATION, VCD_FUNCTION_IN); start_meas(&ue->ulsch_segmentation_stats); - Kb=nr_segmentation(harq_process->b, - harq_process->c, - harq_process->B, - &harq_process->C, - &harq_process->K, - pz, - &harq_process->F, - harq_process->BG); + uint32_t Kb=nr_segmentation(harq_process->b, + harq_process->c, + harq_process->B, + &harq_process->C, + &harq_process->K, + pz, + &harq_process->F, + harq_process->BG); + + if (harq_process->C>MAX_NUM_NR_DLSCH_SEGMENTS_PER_LAYER*harq_process->pusch_pdu.nrOfLayers) { + LOG_E(PHY,"nr_segmentation.c: too many segments %d, B %d\n",harq_process->C,harq_process->B); + return(-1); + } stop_meas(&ue->ulsch_segmentation_stats); VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_NR_SEGMENTATION, VCD_FUNCTION_OUT); @@ -310,14 +302,14 @@ int nr_ulsch_encoding(PHY_VARS_NR_UE *ue, //printf("segment Z %d k %d Kr %d BG %d\n", *pz,harq_process->K,Kr,BG); //start_meas(te_stats); - for (r=0; rC; r++) { + for (int r=0; rC; r++) { //channel_input[r] = &harq_process->d[r][0]; #ifdef DEBUG_ULSCH_CODING printf("Encoder: B %d F %d \n",harq_process->B, harq_process->F); printf("start ldpc encoder segment %d/%d\n",r,harq_process->C); printf("input %d %d %d %d %d \n", harq_process->c[r][0], harq_process->c[r][1], harq_process->c[r][2],harq_process->c[r][3], harq_process->c[r][4]); for (int cnt =0 ; cnt < 22*(*pz)/8; cnt ++){ - printf("%d ", harq_process->c[r][cnt]); + printf("%d ", harq_process->c[r][cnt]); } printf("\n"); @@ -345,8 +337,7 @@ int nr_ulsch_encoding(PHY_VARS_NR_UE *ue, VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_LDPC_ENCODER_OPTIM, VCD_FUNCTION_IN); start_meas(&ue->ulsch_ldpc_encoding_stats); - for(int j = 0; j < (harq_process->C/8 + 1); j++) - { + for(int j = 0; j < (harq_process->C/8 + 1); j++) { impp.macro_num = j; nrLDPC_encoder(harq_process->c,harq_process->d,*pz,Kb,Kr,harq_process->BG,&impp); } @@ -369,14 +360,13 @@ int nr_ulsch_encoding(PHY_VARS_NR_UE *ue, F = harq_process->F; Kr = harq_process->K; - for (r=0; rC; r++) { // looping over C segments - + for (int r=0; rC; r++) { // looping over C segments if (harq_process->F>0) { - for (int k=(Kr-F-2*(*pz)); kd[r][k] = NR_NULL; - //if (k<(Kr-F+8)) - //printf("r %d filler bits [%d] = %d \n", r,k, harq_process->d[r][k]); - } + for (int k=(Kr-F-2*(*pz)); kd[r][k] = NR_NULL; + //if (k<(Kr-F+8)) + //printf("r %d filler bits [%d] = %d \n", r,k, harq_process->d[r][k]); + } } @@ -391,14 +381,11 @@ int nr_ulsch_encoding(PHY_VARS_NR_UE *ue, ///////////////////////// d---->| Rate matching bit selection |---->e ///////////////////////// /////////// - E = nr_get_E(G, harq_process->C, mod_order, harq_process->pusch_pdu.nrOfLayers, r); - - Tbslbrm = nr_compute_tbslbrm(0,nb_rb,harq_process->pusch_pdu.nrOfLayers); + uint32_t E = nr_get_E(G, harq_process->C, mod_order, harq_process->pusch_pdu.nrOfLayers, r); VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_NR_RATE_MATCHING_LDPC, VCD_FUNCTION_IN); start_meas(&ue->ulsch_rate_matching_stats); - if (nr_rate_matching_ldpc(Ilbrm, - Tbslbrm, + if (nr_rate_matching_ldpc(0, harq_process->BG, *pz, harq_process->d[r], @@ -434,9 +421,9 @@ int nr_ulsch_encoding(PHY_VARS_NR_UE *ue, start_meas(&ue->ulsch_interleaving_stats); nr_interleaving_ldpc(E, - mod_order, - harq_process->e+r_offset, - harq_process->f+r_offset); + mod_order, + harq_process->e+r_offset, + harq_process->f+r_offset); stop_meas(&ue->ulsch_interleaving_stats); VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_NR_INTERLEAVING_LDPC, VCD_FUNCTION_OUT); @@ -458,8 +445,6 @@ int nr_ulsch_encoding(PHY_VARS_NR_UE *ue, } - memcpy(ulsch->g,harq_process->f,G); // g is the concatenated code block - VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_NR_UE_ULSCH_ENCODING, VCD_FUNCTION_OUT); stop_meas(&ue->ulsch_encoding_stats); diff --git a/openair1/PHY/NR_UE_TRANSPORT/nr_ulsch_ue.c b/openair1/PHY/NR_UE_TRANSPORT/nr_ulsch_ue.c index 41cf9c2ffa..a07a19d085 100644 --- a/openair1/PHY/NR_UE_TRANSPORT/nr_ulsch_ue.c +++ b/openair1/PHY/NR_UE_TRANSPORT/nr_ulsch_ue.c @@ -32,11 +32,13 @@ #include #include "PHY/NR_REFSIG/dmrs_nr.h" #include "PHY/NR_REFSIG/ptrs_nr.h" +#include "PHY/NR_REFSIG/refsig_defs_ue.h" #include "PHY/NR_UE_TRANSPORT/nr_transport_ue.h" #include "PHY/NR_UE_TRANSPORT/nr_transport_proto_ue.h" #include "PHY/MODULATION/nr_modulation.h" #include "PHY/MODULATION/modulation_common.h" #include "common/utils/assertions.h" +#include "common/utils/nr/nr_common.h" #include "common/utils/LOG/vcd_signal_dumper.h" #include "PHY/NR_TRANSPORT/nr_transport_common_proto.h" #include "PHY/NR_TRANSPORT/nr_sch_dmrs.h" @@ -105,124 +107,123 @@ void nr_pusch_codeword_scrambling(uint8_t *in, } void nr_ue_ulsch_procedures(PHY_VARS_NR_UE *UE, - unsigned char harq_pid, - uint32_t frame, - uint8_t slot, - uint8_t thread_id, - int gNB_id) { + unsigned char harq_pid, + uint32_t frame, + uint8_t slot, + uint8_t thread_id, + int gNB_id) { LOG_D(PHY,"nr_ue_ulsch_procedures hard_id %d %d.%d\n",harq_pid,frame,slot); - uint32_t available_bits; - uint8_t cwd_index, l; - uint32_t scrambled_output[NR_MAX_NB_CODEWORDS][NR_MAX_PDSCH_ENCODED_LENGTH>>5]; - int16_t **tx_layers; - int32_t **txdataF; int8_t Wf[2], Wt[2]; int l_prime[2], delta; uint8_t nb_dmrs_re_per_rb; - int ap, i; + int i; int sample_offsetF, N_RE_prime; NR_DL_FRAME_PARMS *frame_parms = &UE->frame_parms; - NR_UE_PUSCH *pusch_ue = UE->pusch_vars[thread_id][gNB_id]; + int32_t **txdataF = UE->common_vars.txdataF; - uint8_t num_of_codewords = 1; // tmp assumption int N_PRB_oh = 0; // higher layer (RRC) parameter xOverhead in PUSCH-ServingCellConfig uint16_t number_dmrs_symbols = 0; - for (cwd_index = 0;cwd_index < num_of_codewords; cwd_index++) { + NR_UE_ULSCH_t *ulsch_ue = UE->ulsch[thread_id][gNB_id]; + NR_UL_UE_HARQ_t *harq_process_ul_ue = ulsch_ue->harq_processes[harq_pid]; + nfapi_nr_ue_pusch_pdu_t *pusch_pdu = &harq_process_ul_ue->pusch_pdu; - NR_UE_ULSCH_t *ulsch_ue = UE->ulsch[thread_id][gNB_id][cwd_index]; - NR_UL_UE_HARQ_t *harq_process_ul_ue = ulsch_ue->harq_processes[harq_pid]; - nfapi_nr_ue_pusch_pdu_t *pusch_pdu = &harq_process_ul_ue->pusch_pdu; + int start_symbol = pusch_pdu->start_symbol_index; + uint16_t ul_dmrs_symb_pos = pusch_pdu->ul_dmrs_symb_pos; + uint8_t number_of_symbols = pusch_pdu->nr_of_symbols; + uint8_t dmrs_type = pusch_pdu->dmrs_config_type; + uint16_t start_rb = pusch_pdu->rb_start; + uint16_t nb_rb = pusch_pdu->rb_size; + uint8_t Nl = pusch_pdu->nrOfLayers; + uint8_t mod_order = pusch_pdu->qam_mod_order; + uint16_t rnti = pusch_pdu->rnti; + uint8_t cdm_grps_no_data = pusch_pdu->num_dmrs_cdm_grps_no_data; + uint16_t start_sc = frame_parms->first_carrier_offset + (start_rb+pusch_pdu->bwp_start)*NR_NB_SC_PER_RB; - int start_symbol = pusch_pdu->start_symbol_index; - uint16_t ul_dmrs_symb_pos = pusch_pdu->ul_dmrs_symb_pos; - uint8_t number_of_symbols = pusch_pdu->nr_of_symbols; - uint8_t dmrs_type = pusch_pdu->dmrs_config_type; - uint16_t start_rb = pusch_pdu->rb_start; - uint16_t nb_rb = pusch_pdu->rb_size; - uint8_t Nl = pusch_pdu->nrOfLayers; - uint8_t mod_order = pusch_pdu->qam_mod_order; - uint16_t rnti = pusch_pdu->rnti; - uint8_t cdm_grps_no_data = pusch_pdu->num_dmrs_cdm_grps_no_data; - uint16_t start_sc = frame_parms->first_carrier_offset + (start_rb+pusch_pdu->bwp_start)*NR_NB_SC_PER_RB; + if (start_sc >= frame_parms->ofdm_symbol_size) + start_sc -= frame_parms->ofdm_symbol_size; - if (start_sc >= frame_parms->ofdm_symbol_size) - start_sc -= frame_parms->ofdm_symbol_size; + ulsch_ue->Nid_cell = frame_parms->Nid_cell; - ulsch_ue->Nid_cell = frame_parms->Nid_cell; + for (int i = start_symbol; i < start_symbol + number_of_symbols; i++) { + if((ul_dmrs_symb_pos >> i) & 0x01) + number_dmrs_symbols += 1; + } - for (int i = start_symbol; i < start_symbol + number_of_symbols; i++) { - if((ul_dmrs_symb_pos >> i) & 0x01) - number_dmrs_symbols += 1; - } + nb_dmrs_re_per_rb = ((dmrs_type == pusch_dmrs_type1) ? 6:4)*cdm_grps_no_data; - nb_dmrs_re_per_rb = ((dmrs_type == pusch_dmrs_type1) ? 6:4)*cdm_grps_no_data; + LOG_D(PHY,"ulsch TX %x : start_rb %d nb_rb %d mod_order %d Nl %d Tpmi %d bwp_start %d start_sc %d start_symbol %d num_symbols %d cdmgrpsnodata %d num_dmrs %d dmrs_re_per_rb %d\n", + rnti,start_rb,nb_rb,mod_order,Nl,pusch_pdu->Tpmi,pusch_pdu->bwp_start,start_sc,start_symbol,number_of_symbols,cdm_grps_no_data,number_dmrs_symbols,nb_dmrs_re_per_rb); + // TbD num_of_mod_symbols is set but never used + N_RE_prime = NR_NB_SC_PER_RB*number_of_symbols - nb_dmrs_re_per_rb*number_dmrs_symbols - N_PRB_oh; + harq_process_ul_ue->num_of_mod_symbols = N_RE_prime*nb_rb; - LOG_D(PHY,"ulsch %x : start_rb %d bwp_start %d start_sc %d start_symbol %d num_symbols %d cdmgrpsnodata %d num_dmrs %d dmrs_re_per_rb %d\n", - rnti,start_rb,pusch_pdu->bwp_start,start_sc,start_symbol,number_of_symbols,cdm_grps_no_data,number_dmrs_symbols,nb_dmrs_re_per_rb); + /////////////////////////ULSCH coding///////////////////////// + /////////// - // TbD num_of_mod_symbols is set but never used - N_RE_prime = NR_NB_SC_PER_RB*number_of_symbols - nb_dmrs_re_per_rb*number_dmrs_symbols - N_PRB_oh; - harq_process_ul_ue->num_of_mod_symbols = N_RE_prime*nb_rb*num_of_codewords; - - /////////////////////////ULSCH coding///////////////////////// - /////////// - - unsigned int G = nr_get_G(nb_rb, number_of_symbols, - nb_dmrs_re_per_rb, number_dmrs_symbols, mod_order, Nl); + unsigned int G = nr_get_G(nb_rb, number_of_symbols, + nb_dmrs_re_per_rb, number_dmrs_symbols, mod_order, Nl); - trace_NRpdu(DIRECTION_UPLINK, - ulsch_ue->harq_processes[harq_pid]->a, - ulsch_ue->harq_processes[harq_pid]->pusch_pdu.pusch_data.tb_size, - 0, WS_C_RNTI, rnti, frame, slot, 0, 0); + trace_NRpdu(DIRECTION_UPLINK, + harq_process_ul_ue->a, + harq_process_ul_ue->pusch_pdu.pusch_data.tb_size, + WS_C_RNTI, rnti, frame, slot, 0, 0); - if (nr_ulsch_encoding(UE, ulsch_ue, frame_parms, harq_pid, G) == -1) - return; + if (nr_ulsch_encoding(UE, ulsch_ue, frame_parms, harq_pid, G) == -1) + return; - /////////// - //////////////////////////////////////////////////////////////////// + /////////// + //////////////////////////////////////////////////////////////////// - /////////////////////////ULSCH scrambling///////////////////////// - /////////// + /////////////////////////ULSCH scrambling///////////////////////// + /////////// - available_bits = G; + uint32_t available_bits = G; + uint32_t scrambled_output[(available_bits>>5)+1]; + memset(scrambled_output, 0, ((available_bits>>5)+1)*sizeof(uint32_t)); - memset(scrambled_output[cwd_index], 0, ((available_bits>>5)+1)*sizeof(uint32_t)); + nr_pusch_codeword_scrambling(harq_process_ul_ue->f, + available_bits, + ulsch_ue->Nid_cell, + rnti, + false, + scrambled_output); - nr_pusch_codeword_scrambling(ulsch_ue->g, - available_bits, - ulsch_ue->Nid_cell, - rnti, - false, - scrambled_output[cwd_index]); // assume one codeword for the moment + ///////////// + ////////////////////////////////////////////////////////////////////////// + /////////////////////////ULSCH modulation///////////////////////// + /////////// - ///////////// - ////////////////////////////////////////////////////////////////////////// - - /////////////////////////ULSCH modulation///////////////////////// - /////////// - - nr_modulation(scrambled_output[cwd_index], // assume one codeword for the moment - available_bits, - mod_order, - (int16_t *)ulsch_ue->d_mod); + int max_num_re = Nl*number_of_symbols*nb_rb*NR_NB_SC_PER_RB; + int32_t d_mod[max_num_re] __attribute__ ((aligned(16))); + nr_modulation(scrambled_output, // assume one codeword for the moment + available_bits, + mod_order, + (int16_t *)d_mod); - /////////// - //////////////////////////////////////////////////////////////////////// + /////////// + //////////////////////////////////////////////////////////////////////// /////////////////////////DMRS Modulation///////////////////////// /////////// + + if(pusch_pdu->ul_dmrs_scrambling_id != UE->scramblingID_ulsch[pusch_pdu->scid]) { + UE->scramblingID_ulsch[pusch_pdu->scid] = pusch_pdu->ul_dmrs_scrambling_id; + nr_init_pusch_dmrs(UE, pusch_pdu->scid, pusch_pdu->ul_dmrs_scrambling_id); + } + uint32_t ***pusch_dmrs = UE->nr_gold_pusch_dmrs[slot]; uint16_t n_dmrs = (pusch_pdu->bwp_start + start_rb + nb_rb)*((dmrs_type == pusch_dmrs_type1) ? 6:4); int16_t mod_dmrs[n_dmrs<<1] __attribute((aligned(16))); + /////////// //////////////////////////////////////////////////////////////////////// @@ -256,9 +257,11 @@ void nr_ue_ulsch_procedures(PHY_VARS_NR_UE *UE, /////////////////////////ULSCH layer mapping///////////////////////// /////////// - tx_layers = (int16_t **)pusch_ue->txdataF_layers; + int16_t **tx_layers = (int16_t **)malloc16_clear(Nl*sizeof(int16_t *)); + for (int nl=0; nlulsch[thread_id][gNB_id], + nr_ue_layer_mapping((int16_t *)d_mod, Nl, available_bits/mod_order, tx_layers); @@ -276,13 +279,15 @@ void nr_ue_ulsch_procedures(PHY_VARS_NR_UE *UE, uint8_t u = 0, v = 0; int16_t *dmrs_seq = NULL; - // if transform precoding is enbaled (value 0) - if (pusch_pdu->transform_precoding == 0) { + /// Transform-coded "y"-sequences (for definition see 38-211 V15.3.0 2018-09, subsection 6.3.1.4) + int32_t y[max_num_re] __attribute__ ((aligned(16))); + + if (pusch_pdu->transform_precoding == transformPrecoder_enabled) { uint32_t nb_re_pusch=nb_rb * NR_NB_SC_PER_RB; uint32_t y_offset = 0; uint16_t num_dmrs_res_per_symbol = nb_rb*(NR_NB_SC_PER_RB/2); - + // Calculate index to dmrs seq array based on number of DMRS Subcarriers on this symbol index = get_index_for_dmrs_lowpapr_seq(num_dmrs_res_per_symbol); u = pusch_pdu->dfts_ofdm.low_papr_group_number; @@ -291,55 +296,49 @@ void nr_ue_ulsch_procedures(PHY_VARS_NR_UE *UE, AssertFatal(index >= 0, "Num RBs not configured according to 3GPP 38.211 section 6.3.1.4. For PUSCH with transform precoding, num RBs cannot be multiple of any other primenumber other than 2,3,5\n"); AssertFatal(dmrs_seq != NULL, "DMRS low PAPR seq not found, check if DMRS sequences are generated"); - + LOG_D(PHY,"Transform Precoding params. u: %d, v: %d, index for dmrsseq: %d\n", u, v, index); - for (l = start_symbol; l < start_symbol + number_of_symbols; l++) { + for (int l = start_symbol; l < start_symbol + number_of_symbols; l++) { if((ul_dmrs_symb_pos >> l) & 0x01) /* In the symbol with DMRS no data would be transmitted CDM groups is 2*/ continue; - nr_dft(&ulsch_ue->y[y_offset], &((int32_t*)tx_layers[0])[y_offset], nb_re_pusch); + nr_dft(&y[y_offset], &((int32_t*)tx_layers[0])[y_offset], nb_re_pusch); y_offset = y_offset + nb_re_pusch; LOG_D(PHY,"Transform precoding being done on data- symbol: %d, nb_re_pusch: %d, y_offset: %d\n", l, nb_re_pusch, y_offset); - #ifdef DEBUG_PUSCH_MAPPING - printf("NR_ULSCH_UE: y_offset %d\t nb_re_pusch %d \t Symbol %d \t nb_rb %d \n", - y_offset, nb_re_pusch, l, nb_rb); - #endif +#ifdef DEBUG_PUSCH_MAPPING + printf("NR_ULSCH_UE: y_offset %d\t nb_re_pusch %d \t Symbol %d \t nb_rb %d \n", + y_offset, nb_re_pusch, l, nb_rb); +#endif } - #ifdef DEBUG_DFT_IDFT - int32_t debug_symbols[MAX_NUM_NR_RE] __attribute__ ((aligned(16))); - int offset = 0; - printf("NR_ULSCH_UE: available_bits: %d, mod_order: %d", available_bits,mod_order); +#ifdef DEBUG_DFT_IDFT + int32_t debug_symbols[MAX_NUM_NR_RE] __attribute__ ((aligned(16))); + int offset = 0; + printf("NR_ULSCH_UE: available_bits: %d, mod_order: %d", available_bits,mod_order); - for (int ll = 0; ll < (available_bits/mod_order); ll++) { - debug_symbols[ll] = ulsch_ue->y[ll]; - } + for (int ll = 0; ll < (available_bits/mod_order); ll++) { + debug_symbols[ll] = ulsch_ue->y[ll]; + } - printf("NR_ULSCH_UE: numSym: %d, num_dmrs_sym: %d", number_of_symbols,number_dmrs_symbols); - for (int ll = 0; ll < (number_of_symbols-number_dmrs_symbols); ll++) { - - nr_idft(&debug_symbols[offset], nb_re_pusch); - - offset = offset + nb_re_pusch; - - } - LOG_M("preDFT_all_symbols.m","UE_preDFT", tx_layers[0],number_of_symbols*nb_re_pusch,1,1); - LOG_M("postDFT_all_symbols.m","UE_postDFT", ulsch_ue->y,number_of_symbols*nb_re_pusch,1,1); - LOG_M("DEBUG_IDFT_SYMBOLS.m","UE_Debug_IDFT", debug_symbols,number_of_symbols*nb_re_pusch,1,1); - LOG_M("UE_DMRS_SEQ.m","UE_DMRS_SEQ", dmrs_seq,nb_re_pusch,1,1); - #endif + printf("NR_ULSCH_UE: numSym: %d, num_dmrs_sym: %d", number_of_symbols,number_dmrs_symbols); + for (int ll = 0; ll < (number_of_symbols-number_dmrs_symbols); ll++) { + nr_idft(&debug_symbols[offset], nb_re_pusch); + offset = offset + nb_re_pusch; + } + LOG_M("preDFT_all_symbols.m","UE_preDFT", tx_layers[0],number_of_symbols*nb_re_pusch,1,1); + LOG_M("postDFT_all_symbols.m","UE_postDFT", y,number_of_symbols*nb_re_pusch,1,1); + LOG_M("DEBUG_IDFT_SYMBOLS.m","UE_Debug_IDFT", debug_symbols,number_of_symbols*nb_re_pusch,1,1); + LOG_M("UE_DMRS_SEQ.m","UE_DMRS_SEQ", dmrs_seq,nb_re_pusch,1,1); +#endif } - else - memcpy(ulsch_ue->y, tx_layers[0], (available_bits/mod_order)*sizeof(int32_t)); - /////////// //////////////////////////////////////////////////////////////////////// @@ -348,26 +347,26 @@ void nr_ue_ulsch_procedures(PHY_VARS_NR_UE *UE, /////////////////////////ULSCH RE mapping///////////////////////// /////////// - txdataF = UE->common_vars.txdataF; - - for (ap=0; ap< Nl; ap++) { + int encoded_length = frame_parms->N_RB_UL*14*NR_NB_SC_PER_RB*mod_order*Nl; + int16_t **tx_precoding = (int16_t **)malloc16_clear(Nl*sizeof(int16_t *)); + for (int nl=0; nlNid_cell, u); - #endif +#ifdef DEBUG_PUSCH_MAPPING + printf("NR_ULSCH_UE: Value of CELL ID %d /t, u %d \n", frame_parms->Nid_cell, u); +#endif - + int dmrs_port = get_dmrs_port(nl,pusch_pdu->dmrs_ports); + // DMRS params for this dmrs port + get_Wt(Wt, dmrs_port, dmrs_type); + get_Wf(Wf, dmrs_port, dmrs_type); + delta = get_delta(dmrs_port, dmrs_type); - // DMRS params for this ap - get_Wt(Wt, ap, dmrs_type); - get_Wf(Wf, ap, dmrs_type); - delta = get_delta(ap, dmrs_type); - - for (l=start_symbol; l> l) & 0x01) { is_dmrs_sym = 1; - // transform precoding disabled (value 1) - if (pusch_pdu->transform_precoding == 1){ + if (pusch_pdu->transform_precoding == transformPrecoder_disabled){ if (dmrs_type == pusch_dmrs_type1) dmrs_idx = (pusch_pdu->bwp_start + start_rb)*6; @@ -388,26 +386,22 @@ void nr_ue_ulsch_procedures(PHY_VARS_NR_UE *UE, // TODO: performance improvement, we can skip the modulation of DMRS symbols outside the bandwidth part // Perform this on gold sequence, not required when SC FDMA operation is done, - LOG_D(PHY,"DMRS in symbol %d\n",l); - nr_modulation(pusch_dmrs[l][0], n_dmrs*2, DMRS_MOD_ORDER, mod_dmrs); // currently only codeword 0 is modulated. Qm = 2 as DMRS is QPSK modulated - + LOG_D(PHY,"DMRS in symbol %d\n",l); + nr_modulation(pusch_dmrs[l][pusch_pdu->scid], n_dmrs*2, DMRS_MOD_ORDER, mod_dmrs); // currently only codeword 0 is modulated. Qm = 2 as DMRS is QPSK modulated } else { dmrs_idx = 0; } - - } else if (pusch_pdu->pdu_bit_map & PUSCH_PDU_BITMAP_PUSCH_PTRS) { - AssertFatal(pusch_pdu->transform_precoding == 1, "PTRS NOT SUPPORTED IF TRANSFORM PRECODING IS ENABLED\n"); + AssertFatal(pusch_pdu->transform_precoding == transformPrecoder_disabled, "PTRS NOT SUPPORTED IF TRANSFORM PRECODING IS ENABLED\n"); if(is_ptrs_symbol(l, ulsch_ue->ptrs_symbols)) { is_ptrs_sym = 1; - nr_modulation(pusch_dmrs[l][0], nb_rb, DMRS_MOD_ORDER, mod_ptrs); + nr_modulation(pusch_dmrs[l][pusch_pdu->scid], nb_rb, DMRS_MOD_ORDER, mod_ptrs); } } for (i=0; i< nb_rb*NR_NB_SC_PER_RB; i++) { - uint8_t is_dmrs = 0; uint8_t is_ptrs = 0; @@ -417,81 +411,159 @@ void nr_ue_ulsch_procedures(PHY_VARS_NR_UE *UE, if (k == ((start_sc+get_dmrs_freq_idx_ul(n, k_prime, delta, dmrs_type))%frame_parms->ofdm_symbol_size)) is_dmrs = 1; } else if (is_ptrs_sym) { - is_ptrs = is_ptrs_subcarrier(k, - rnti, - ap, - dmrs_type, - K_ptrs, - nb_rb, - pusch_pdu->pusch_ptrs.ptrs_ports_list[0].ptrs_re_offset, - start_sc, - frame_parms->ofdm_symbol_size); + is_ptrs = is_ptrs_subcarrier(k, + rnti, + nl, + dmrs_type, + K_ptrs, + nb_rb, + pusch_pdu->pusch_ptrs.ptrs_ports_list[0].ptrs_re_offset, + start_sc, + frame_parms->ofdm_symbol_size); } if (is_dmrs == 1) { // if transform precoding is enabled - if (pusch_pdu->transform_precoding == 0) { - - ((int16_t*)txdataF[ap])[(sample_offsetF)<<1] = (Wt[l_prime[0]]*Wf[k_prime]*AMP*dmrs_seq[2*dmrs_idx]) >> 15; - ((int16_t*)txdataF[ap])[((sample_offsetF)<<1) + 1] = (Wt[l_prime[0]]*Wf[k_prime]*AMP*dmrs_seq[(2*dmrs_idx) + 1]) >> 15; - + if (pusch_pdu->transform_precoding == transformPrecoder_enabled) { + ((int16_t*)tx_precoding[nl])[(sample_offsetF)<<1] = (Wt[l_prime[0]]*Wf[k_prime]*AMP*dmrs_seq[2*dmrs_idx]) >> 15; + ((int16_t*)tx_precoding[nl])[((sample_offsetF)<<1) + 1] = (Wt[l_prime[0]]*Wf[k_prime]*AMP*dmrs_seq[(2*dmrs_idx) + 1]) >> 15; } else { + ((int16_t*)tx_precoding[nl])[(sample_offsetF)<<1] = (Wt[l_prime[0]]*Wf[k_prime]*AMP*mod_dmrs[dmrs_idx<<1]) >> 15; + ((int16_t*)tx_precoding[nl])[((sample_offsetF)<<1) + 1] = (Wt[l_prime[0]]*Wf[k_prime]*AMP*mod_dmrs[(dmrs_idx<<1) + 1]) >> 15; + } - ((int16_t*)txdataF[ap])[(sample_offsetF)<<1] = (Wt[l_prime[0]]*Wf[k_prime]*AMP*mod_dmrs[dmrs_idx<<1]) >> 15; - ((int16_t*)txdataF[ap])[((sample_offsetF)<<1) + 1] = (Wt[l_prime[0]]*Wf[k_prime]*AMP*mod_dmrs[(dmrs_idx<<1) + 1]) >> 15; - - } - - #ifdef DEBUG_PUSCH_MAPPING - printf("dmrs_idx %d\t l %d \t k %d \t k_prime %d \t n %d \t dmrs: %d %d\n", - dmrs_idx, l, k, k_prime, n, ((int16_t*)txdataF[ap])[(sample_offsetF)<<1], - ((int16_t*)txdataF[ap])[((sample_offsetF)<<1) + 1]); - #endif - +#ifdef DEBUG_PUSCH_MAPPING + printf("DMRS: Layer: %d\t, dmrs_idx %d\t l %d \t k %d \t k_prime %d \t n %d \t dmrs: %d %d\n", + nl, dmrs_idx, l, k, k_prime, n, ((int16_t*)tx_precoding[nl])[(sample_offsetF)<<1], + ((int16_t*)tx_precoding[nl])[((sample_offsetF)<<1) + 1]); +#endif dmrs_idx++; k_prime++; k_prime&=1; n+=(k_prime)?0:1; - + } else if (is_ptrs == 1) { - - ((int16_t*)txdataF[ap])[(sample_offsetF)<<1] = (beta_ptrs*AMP*mod_ptrs[ptrs_idx<<1]) >> 15; - ((int16_t*)txdataF[ap])[((sample_offsetF)<<1) + 1] = (beta_ptrs*AMP*mod_ptrs[(ptrs_idx<<1) + 1]) >> 15; - + ((int16_t*)tx_precoding[nl])[(sample_offsetF)<<1] = (beta_ptrs*AMP*mod_ptrs[ptrs_idx<<1]) >> 15; + ((int16_t*)tx_precoding[nl])[((sample_offsetF)<<1) + 1] = (beta_ptrs*AMP*mod_ptrs[(ptrs_idx<<1) + 1]) >> 15; ptrs_idx++; - } else if (!is_dmrs_sym || allowed_xlsch_re_in_dmrs_symbol(k, start_sc, frame_parms->ofdm_symbol_size, cdm_grps_no_data, dmrs_type)) { + if (pusch_pdu->transform_precoding == transformPrecoder_disabled) { + ((int16_t*)tx_precoding[nl])[(sample_offsetF)<<1] = ((int16_t *)tx_layers[nl])[m<<1]; + ((int16_t*)tx_precoding[nl])[((sample_offsetF)<<1) + 1] = ((int16_t *)tx_layers[nl])[(m<<1) + 1]; + } + else { + ((int16_t*)tx_precoding[nl])[(sample_offsetF)<<1] = ((int16_t *) y)[m<<1]; + ((int16_t*)tx_precoding[nl])[((sample_offsetF)<<1) + 1] = ((int16_t *) y)[(m<<1) + 1]; + } - ((int16_t*)txdataF[ap])[(sample_offsetF)<<1] = ((int16_t *) ulsch_ue->y)[m<<1]; - ((int16_t*)txdataF[ap])[((sample_offsetF)<<1) + 1] = ((int16_t *) ulsch_ue->y)[(m<<1) + 1]; - - #ifdef DEBUG_PUSCH_MAPPING - printf("m %d\t l %d \t k %d \t txdataF: %d %d\n", - m, l, k, ((int16_t*)txdataF[ap])[(sample_offsetF)<<1], - ((int16_t*)txdataF[ap])[((sample_offsetF)<<1) + 1]); - #endif +#ifdef DEBUG_PUSCH_MAPPING + printf("DATA: layer %d\t m %d\t l %d \t k %d \t tx_precoding: %d %d\n", + nl, m, l, k, ((int16_t*)tx_precoding[nl])[(sample_offsetF)<<1], + ((int16_t*)tx_precoding[nl])[((sample_offsetF)<<1) + 1]); +#endif m++; } else { - - ((int16_t*)txdataF[ap])[(sample_offsetF)<<1] = 0; - ((int16_t*)txdataF[ap])[((sample_offsetF)<<1) + 1] = 0; - + ((int16_t*)tx_precoding[nl])[(sample_offsetF)<<1] = 0; + ((int16_t*)tx_precoding[nl])[((sample_offsetF)<<1) + 1] = 0; } if (++k >= frame_parms->ofdm_symbol_size) k -= frame_parms->ofdm_symbol_size; - } - } - } - } + } //for (i=0; i< nb_rb*NR_NB_SC_PER_RB; i++) + }//for (l=start_symbol; lnb_antennas_tx; ap++) { + for (int l=start_symbol; lTpmi; + + if (pmi == 0) {//unitary Precoding + if(ap< pusch_pdu->nrOfLayers) + memcpy((void*)&txdataF[ap][l*frame_parms->ofdm_symbol_size + k], + (void*)&tx_precoding[ap][2*(l*frame_parms->ofdm_symbol_size + k)], + NR_NB_SC_PER_RB*sizeof(int32_t)); + else + memset((void*)&txdataF[ap][l*frame_parms->ofdm_symbol_size + k], + 0, + NR_NB_SC_PER_RB*sizeof(int32_t)); + + k += NR_NB_SC_PER_RB; + if (k >= frame_parms->ofdm_symbol_size) { + k -= frame_parms->ofdm_symbol_size; + } + } + else { + //get the precoding matrix weights: + char *W_prec; + switch (frame_parms->nb_antennas_tx) { + case 1://1 antenna port + W_prec = nr_W_1l_2p[pmi][ap]; + break; + case 2://2 antenna ports + if (pusch_pdu->nrOfLayers == 1)//1 layer + W_prec = nr_W_1l_2p[pmi][ap]; + else//2 layers + W_prec = nr_W_2l_2p[pmi][ap]; + break; + case 4://4 antenna ports + if (pusch_pdu->nrOfLayers == 1)//1 layer + W_prec = nr_W_1l_4p[pmi][ap]; + else if (pusch_pdu->nrOfLayers == 2)//2 layers + W_prec = nr_W_2l_4p[pmi][ap]; + else if (pusch_pdu->nrOfLayers == 3)//3 layers + W_prec = nr_W_3l_4p[pmi][ap]; + else//4 layers + W_prec = nr_W_4l_4p[pmi][ap]; + break; + default: + LOG_D(PHY,"Precoding 1,2, or 4 antenna ports are currently supported\n"); + W_prec = nr_W_1l_2p[pmi][ap]; + break; + } + + for (int i=0; iofdm_symbol_size + k; + int32_t precodatatx_F = nr_layer_precoder(tx_precoding, W_prec, pusch_pdu->nrOfLayers, re_offset); + ((int16_t*)txdataF[ap])[(re_offset<<1)] = ((int16_t *) &precodatatx_F)[0]; + ((int16_t*)txdataF[ap])[(re_offset<<1) + 1] = ((int16_t *) &precodatatx_F)[1]; + + if (++k >= frame_parms->ofdm_symbol_size) { + k -= frame_parms->ofdm_symbol_size; + } + } + } + } //RB loop + } // symbol loop + }// port loop NR_UL_UE_HARQ_t *harq_process_ulsch=NULL; - harq_process_ulsch = UE->ulsch[thread_id][gNB_id][0]->harq_processes[harq_pid]; + harq_process_ulsch = UE->ulsch[thread_id][gNB_id]->harq_processes[harq_pid]; harq_process_ulsch->status = SCH_IDLE; + for (int nl = 0; nl < Nl; nl++) { + free_and_zero(tx_layers[nl]); + free_and_zero(tx_precoding[nl]); + } + free_and_zero(tx_layers); + free_and_zero(tx_precoding); + /////////// //////////////////////////////////////////////////////////////////////// @@ -501,7 +573,7 @@ void nr_ue_ulsch_procedures(PHY_VARS_NR_UE *UE, uint8_t nr_ue_pusch_common_procedures(PHY_VARS_NR_UE *UE, uint8_t slot, NR_DL_FRAME_PARMS *frame_parms, - uint8_t Nl) { + uint8_t n_antenna_ports) { int tx_offset, ap; int32_t **txdata; @@ -523,7 +595,7 @@ uint8_t nr_ue_pusch_common_procedures(PHY_VARS_NR_UE *UE, txdataF = UE->common_vars.txdataF; int symb_offset = (slot%frame_parms->slots_per_subframe)*frame_parms->symbols_per_slot; - for(ap = 0; ap < Nl; ap++) { + for(ap = 0; ap < n_antenna_ports; ap++) { for (int s=0;s (%d.%d)\n", @@ -541,7 +613,7 @@ uint8_t nr_ue_pusch_common_procedures(PHY_VARS_NR_UE *UE, } } - for (ap = 0; ap < Nl; ap++) { + for (ap = 0; ap < n_antenna_ports; ap++) { if (frame_parms->Ncp == 1) { // extended cyclic prefix PHY_ofdm_mod(txdataF[ap], &txdata[ap][tx_offset], diff --git a/openair1/PHY/NR_UE_TRANSPORT/pss_nr.c b/openair1/PHY/NR_UE_TRANSPORT/pss_nr.c index 88bdc3a9cd..d2034f3abf 100644 --- a/openair1/PHY/NR_UE_TRANSPORT/pss_nr.c +++ b/openair1/PHY/NR_UE_TRANSPORT/pss_nr.c @@ -48,126 +48,8 @@ #include "PHY/NR_REFSIG/sss_nr.h" #include "PHY/NR_UE_TRANSPORT/cic_filter_nr.h" -/******************************************************************* -* -* NAME : get_idft -* -* PARAMETERS : size of ofdm symbol -* -* RETURN : index pointing to the dft func in the dft library -* -* DESCRIPTION : get idft function depending of ofdm size -* -*********************************************************************/ - //#define DBG_PSS_NR -idft_size_idx_t get_idft(int ofdm_symbol_size) -{ - - - switch (ofdm_symbol_size) { - case 128: - return IDFT_128; - break; - - case 256: - return IDFT_256; - break; - - case 512: - return IDFT_512; - break; - - case 1024: - return IDFT_1024; - break; - - case 1536: - return IDFT_1536; - break; - - case 2048: - return IDFT_2048; - break; - - case 3072: - return IDFT_3072; - break; - - case 4096: - return IDFT_4096; - break; - - case 8192: - return IDFT_8192; - break; - - default: - printf("function get_idft : unsupported ofdm symbol size \n"); - assert(0); - break; - } - return IDFT_SIZE_IDXTABLESIZE; // never reached and will trigger assertion in idft function -} - -/******************************************************************* -* -* NAME : get_dft -* -* PARAMETERS : size of ofdm symbol -* -* RETURN : function for discrete fourier transform -* -* DESCRIPTION : get dft function depending of ofdm size -* -*********************************************************************/ - -dft_size_idx_t get_dft(int ofdm_symbol_size) -{ - - - switch (ofdm_symbol_size) { - case 128: - return DFT_128; - break; - - case 256: - return DFT_256; - break; - - case 512: - return DFT_512; - break; - - case 1024: - return DFT_1024; - break; - - case 1536: - return DFT_1536; - break; - - case 2048: - return DFT_2048; - break; - - case 4096: - return DFT_4096; - break; - - case 8192: - return DFT_8192; - break; - - default: - printf("function get_dft : unsupported ofdm symbol size \n"); - assert(0); - break; - } - return DFT_SIZE_IDXTABLESIZE; // never reached and will trigger assertion in idft function; -} - /******************************************************************* * * NAME : generate_pss_nr @@ -381,7 +263,6 @@ void init_context_pss_nr(NR_DL_FRAME_PARMS *frame_parms_ue) int sizePss = LENGTH_PSS_NR * IQ_SIZE; /* complex value i & q signed 16 bits */ int size = ofdm_symbol_size * IQ_SIZE; /* i and q samples signed 16 bits */ int16_t *p = NULL; - int64_t *q = NULL; AssertFatal(ofdm_symbol_size > 127, "illegal ofdm_symbol_size %d\n",ofdm_symbol_size); for (int i = 0; i < NUMBER_PSS_SEQUENCE; i++) { @@ -410,17 +291,6 @@ void init_context_pss_nr(NR_DL_FRAME_PARMS *frame_parms_ue) assert(0); } - size = sizeof(int64_t)*(frame_parms_ue->samples_per_frame + (2*ofdm_symbol_size)); - q = (int64_t*)malloc16(size); - if (q != NULL) { - pss_corr_ue[i] = q; - bzero( pss_corr_ue[i], size); - } - else { - LOG_E(PHY,"Fatal memory allocation problem \n"); - assert(0); - } - generate_pss_nr(frame_parms_ue,i); } } @@ -443,7 +313,6 @@ void free_context_pss_nr(void) free_and_zero(primary_synchro_nr[i]); free_and_zero(primary_synchro_nr2[i]); free_and_zero(primary_synchro_time_nr[i]); - free_and_zero(pss_corr_ue[i]); } } @@ -801,7 +670,6 @@ static inline double angle64(int64_t x) *********************************************************************/ #define DOT_PRODUCT_SCALING_SHIFT (17) - int pss_search_time_nr(int **rxdata, ///rx data in time domain NR_DL_FRAME_PARMS *frame_parms, int fo_flag, @@ -812,7 +680,7 @@ int pss_search_time_nr(int **rxdata, ///rx data in time domain unsigned int n, ar, peak_position, pss_source; int64_t peak_value; int64_t result; - int64_t avg[NUMBER_PSS_SEQUENCE]; + int64_t avg[NUMBER_PSS_SEQUENCE]={0}; double ffo_est=0; // performing the correlation on a frame length plus one symbol for the first of the two frame @@ -823,9 +691,8 @@ int pss_search_time_nr(int **rxdata, ///rx data in time domain else length = frame_parms->samples_per_frame; - AssertFatal(length>0,"illegal length %d\n",length); - for (int i = 0; i < NUMBER_PSS_SEQUENCE; i++) AssertFatal(pss_corr_ue[i] != NULL,"pss_corr_ue[%d] not yet allocated! Exiting.\n", i); + AssertFatal(length>0,"illegal length %d\n",length); peak_value = 0; peak_position = 0; pss_source = 0; @@ -846,47 +713,41 @@ int pss_search_time_nr(int **rxdata, ///rx data in time domain /* Correlation computation is based on a a dot product which is realized thank to SIMS extensions */ for (int pss_index = 0; pss_index < NUMBER_PSS_SEQUENCE; pss_index++) { - avg[pss_index]=0; - memset(pss_corr_ue[pss_index],0,length*sizeof(int64_t)); - } - for (n=0; n < length; n+=4) { // + for (n=0; n < length; n+=4) { // - for (int pss_index = 0; pss_index < NUMBER_PSS_SEQUENCE; pss_index++) { + int64_t pss_corr_ue=0; + /* calculate dot product of primary_synchro_time_nr and rxdata[ar][n] + * (ar=0..nb_ant_rx) and store the sum in temp[n]; */ + for (ar=0; arnb_antennas_rx; ar++) { - if ( n < (length - frame_parms->ofdm_symbol_size)) { + /* perform correlation of rx data and pss sequence ie it is a dot product */ + result = dot_product64((short*)primary_synchro_time_nr[pss_index], + (short*)&(rxdata[ar][n+is*frame_parms->samples_per_frame]), + frame_parms->ofdm_symbol_size, + shift); + pss_corr_ue += abs64(result); + //((short*)pss_corr_ue[pss_index])[2*n] += ((short*) &result)[0]; /* real part */ + //((short*)pss_corr_ue[pss_index])[2*n+1] += ((short*) &result)[1]; /* imaginary part */ + //((short*)&synchro_out)[0] += ((int*) &result)[0]; /* real part */ + //((short*)&synchro_out)[1] += ((int*) &result)[1]; /* imaginary part */ - /* calculate dot product of primary_synchro_time_nr and rxdata[ar][n] (ar=0..nb_ant_rx) and store the sum in temp[n]; */ - for (ar=0; arnb_antennas_rx; ar++) { - - /* perform correlation of rx data and pss sequence ie it is a dot product */ - result = dot_product64((short*)primary_synchro_time_nr[pss_index], - (short*) &(rxdata[ar][n+is*frame_parms->samples_per_frame]), - frame_parms->ofdm_symbol_size, - shift); - pss_corr_ue[pss_index][n] += abs64(result); - //((short*)pss_corr_ue[pss_index])[2*n] += ((short*) &result)[0]; /* real part */ - //((short*)pss_corr_ue[pss_index])[2*n+1] += ((short*) &result)[1]; /* imaginary part */ - //((short*)&synchro_out)[0] += ((int*) &result)[0]; /* real part */ - //((short*)&synchro_out)[1] += ((int*) &result)[1]; /* imaginary part */ - - } } - + /* calculate the absolute value of sync_corr[n] */ - avg[pss_index]+=pss_corr_ue[pss_index][n]; - if (pss_corr_ue[pss_index][n] > peak_value) { - peak_value = pss_corr_ue[pss_index][n]; + avg[pss_index]+=pss_corr_ue; + if (pss_corr_ue > peak_value) { + peak_value = pss_corr_ue; peak_position = n; pss_source = pss_index; - + #ifdef DEBUG_PSS_NR - printf("pss_index %d: n %6u peak_value %15llu\n", pss_index, n, (unsigned long long)pss_corr_ue[pss_index][n]); + printf("pss_index %d: n %6u peak_value %15llu\n", pss_index, n, (unsigned long long)pss_corr_ue[n]); #endif } } } - + if (fo_flag){ // fractional frequency offset computation according to Cross-correlation Synchronization Algorithm Using PSS @@ -922,7 +783,8 @@ int pss_search_time_nr(int **rxdata, ///rx data in time domain // computing absolute value of frequency offset *f_off = ffo_est*frame_parms->subcarrier_spacing; - for (int pss_index = 0; pss_index < NUMBER_PSS_SEQUENCE; pss_index++) avg[pss_index]/=(length/4); + for (int pss_index = 0; pss_index < NUMBER_PSS_SEQUENCE; pss_index++) + avg[pss_index]/=(length/4); *eNB_id = pss_source; @@ -937,9 +799,6 @@ int pss_search_time_nr(int **rxdata, ///rx data in time domain static int debug_cnt = 0; if (debug_cnt == 0) { - LOG_M("pss_corr_ue0.m","pss_corr_ue0",pss_corr_ue[0],length,1,6); - LOG_M("pss_corr_ue1.m","pss_corr_ue1",pss_corr_ue[1],length,1,6); - LOG_M("pss_corr_ue2.m","pss_corr_ue2",pss_corr_ue[2],length,1,6); if (is) LOG_M("rxdata1.m","rxd0",rxdata[frame_parms->samples_per_frame],length,1,1); else diff --git a/openair1/PHY/NR_UE_TRANSPORT/sss_nr.c b/openair1/PHY/NR_UE_TRANSPORT/sss_nr.c index dc73fe0add..ff8d5d42ff 100644 --- a/openair1/PHY/NR_UE_TRANSPORT/sss_nr.c +++ b/openair1/PHY/NR_UE_TRANSPORT/sss_nr.c @@ -558,8 +558,15 @@ int rx_sss_nr(PHY_VARS_NR_UE *ue, UE_nr_rxtx_proc_t *proc, int32_t *tot_metric, } //#endif + if (Nid1==N_ID_1_NUMBER) + return -1; + int re = 0; int im = 0; + if (Nid1 == N_ID_1_NUMBER) { + LOG_I(PHY,"Failled to detect SSS after PSS\n"); + return -1; + } d = (int16_t *)&d_sss[Nid2][Nid1]; for(i = 0; i=0,"%s",strerror(errno)); for (int i=0; idlsch[i][0]->Mlimit; j++) { + for (i=0; idlsch[k][0]->Mlimit; j++) { phy_vars_eNB->UE_stats[i].dlsch_NAK[k][j]=0; phy_vars_eNB->UE_stats[i].dlsch_ACK[k][j]=0; phy_vars_eNB->UE_stats[i].dlsch_trials[k][j]=0; diff --git a/openair1/PHY/TOOLS/nr_phy_scope.c b/openair1/PHY/TOOLS/nr_phy_scope.c index 5594d56693..723813fbb6 100644 --- a/openair1/PHY/TOOLS/nr_phy_scope.c +++ b/openair1/PHY/TOOLS/nr_phy_scope.c @@ -37,9 +37,16 @@ const FL_COLOR rx_antenna_colors[4] = {FL_RED,FL_BLUE,FL_GREEN,FL_YELLOW}; const FL_COLOR water_colors[4] = {FL_BLUE,FL_GREEN,FL_YELLOW,FL_RED}; -typedef struct complex16 scopeSample_t; +typedef c16_t scopeSample_t; #define SquaredNorm(VaR) ((VaR).r*(VaR).r+(VaR).i*(VaR).i) +typedef struct { + int dataSize; + int elementSz; + int colSz; + int lineSz; +} scopeGraphData_t; + typedef struct OAIgraph { FL_OBJECT *graph; FL_OBJECT *text; @@ -56,7 +63,7 @@ typedef struct OAIgraph { boolean_t initDone; int iteration; void (*gNBfunct) (struct OAIgraph *graph, scopeData_t *p, int UE_id); - void (*nrUEfunct)(struct OAIgraph *graph, PHY_VARS_NR_UE *phy_vars_ue, int eNB_id, int UE_id); + void (*nrUEfunct)(scopeGraphData_t **data, struct OAIgraph *graph, PHY_VARS_NR_UE *phy_vars_ue, int eNB_id, int UE_id); } OAIgraph_t; /* Forms and Objects */ @@ -140,7 +147,7 @@ static OAIgraph_t gNBcommonGraph( void (*funct) (OAIgraph_t *graph, scopeData_t return graph; } -static OAIgraph_t nrUEcommonGraph( void (*funct) (OAIgraph_t *graph, PHY_VARS_NR_UE *phy_vars_ue, int eNB_id, int UE_id), +static OAIgraph_t nrUEcommonGraph( void (*funct) (scopeGraphData_t **data, OAIgraph_t *graph, PHY_VARS_NR_UE *phy_vars_ue, int eNB_id, int UE_id), int type, FL_Coord x, FL_Coord y, FL_Coord w, FL_Coord h, const char *label, FL_COLOR pointColor) { OAIgraph_t graph; commonGraph(&graph, type, x, y, w, h, label, pointColor); @@ -341,7 +348,7 @@ static void timeResponse (OAIgraph_t *graph, scopeData_t *p, int nb_UEs) { static void gNBfreqWaterFall (OAIgraph_t *graph, scopeData_t *p, int nb_UEs) { NR_DL_FRAME_PARMS *frame_parms=&p->gNB->frame_parms; //use 1st antenna - genericWaterFall(graph, (scopeSample_t *)p->rxdataF, frame_parms->samples_per_frame_wCP, + genericWaterFall(graph, (scopeSample_t *)p->liveData, frame_parms->samples_per_frame_wCP, frame_parms->slots_per_frame, "X axis: Frequency domain, one subframe"); } @@ -515,6 +522,7 @@ void phy_scope_gNB(OAI_phy_scope_t *form, //fl_check_forms(); } + static void *scope_thread_gNB(void *arg) { scopeData_t *p=(scopeData_t *) arg; size_t stksize=0; @@ -539,11 +547,12 @@ static void *scope_thread_gNB(void *arg) { return NULL; } + static void copyRxdataF(int32_t *data, int slot, void *scopeData) { scopeData_t *scope=(scopeData_t *)scopeData; - memcpy(scope->rxdataF + slot*scope->gNB->frame_parms.samples_per_slot_wCP, + memcpy(((int32_t *)scope->liveData) + slot*scope->gNB->frame_parms.samples_per_slot_wCP, data, - scope->gNB->frame_parms.samples_per_slot_wCP); + scope->gNB->frame_parms.samples_per_slot_wCP*sizeof(int32_t)); } void gNBinitScope(scopeParms_t *p) { @@ -554,11 +563,11 @@ void gNBinitScope(scopeParms_t *p) { scope->ru=p->ru; scope->gNB=p->gNB; scope->slotFunc=copyRxdataF; - AssertFatal(scope->rxdataF=(int32_t *) calloc(p->gNB->frame_parms.samples_per_frame_wCP*sizeof(int32_t),1),""); + AssertFatal(scope->liveData= calloc(p->gNB->frame_parms.samples_per_frame_wCP*sizeof(int32_t),1),""); pthread_t forms_thread; threadCreate(&forms_thread, scope_thread_gNB, p->gNB->scopeData, "scope", -1, OAI_PRIORITY_RT_LOW); } -static void ueWaterFall (OAIgraph_t *graph, PHY_VARS_NR_UE *phy_vars_ue, int eNB_id, int UE_id) { +static void ueWaterFall (scopeGraphData_t **data, OAIgraph_t *graph, PHY_VARS_NR_UE *phy_vars_ue, int eNB_id, int UE_id) { // Received signal in time domain of receive antenna 0 genericWaterFall(graph, (scopeSample_t *) phy_vars_ue->common_vars.rxdata[0], @@ -574,13 +583,19 @@ static void ueTimeResponse (OAIgraph_t *graph, PHY_VARS_NR_UE *phy_vars_ue, int phy_vars_ue->frame_parms.samples_per_frame); } */ -static void ueChannelResponse (OAIgraph_t *graph, PHY_VARS_NR_UE *phy_vars_ue, int eNB_id, int UE_id) { + +static void ueChannelResponse (scopeGraphData_t **data, OAIgraph_t *graph, PHY_VARS_NR_UE *phy_vars_ue, int eNB_id, int UE_id) { // Channel Impulse Response - genericPowerPerAntena(graph, phy_vars_ue->frame_parms.nb_antennas_rx, - (const scopeSample_t **) phy_vars_ue->pbch_vars[eNB_id]->dl_ch_estimates_time, - phy_vars_ue->frame_parms.ofdm_symbol_size>>3); + if (!data[pbchDlChEstimateTime]) + return; + + const scopeSample_t *tmp=(scopeSample_t *)(data[pbchDlChEstimateTime]+1); + genericPowerPerAntena(graph, data[pbchDlChEstimateTime]->colSz, + &tmp, + data[pbchDlChEstimateTime]->lineSz); } -static void ueFreqWaterFall (OAIgraph_t *graph,PHY_VARS_NR_UE *phy_vars_ue, int eNB_id, int UE_id ) { + +static void ueFreqWaterFall (scopeGraphData_t **data, OAIgraph_t *graph,PHY_VARS_NR_UE *phy_vars_ue, int eNB_id, int UE_id ) { NR_DL_FRAME_PARMS *frame_parms=&phy_vars_ue->frame_parms; //use 1st antenna genericWaterFall(graph, @@ -624,105 +639,83 @@ static void uePbchFrequencyResp (OAIgraph_t *graph, PHY_VARS_NR_UE *phy_vars_ue oai_xygraph(graph,freq,chest_f_abs,frame_parms->ofdm_symbol_size,0,10); } */ -static void uePbchLLR (OAIgraph_t *graph, PHY_VARS_NR_UE *phy_vars_ue, int eNB_id, int UE_id) { +static void uePbchLLR (scopeGraphData_t **data, OAIgraph_t *graph, PHY_VARS_NR_UE *phy_vars_ue, int eNB_id, int UE_id) { // PBCH LLRs - if ( !phy_vars_ue->pbch_vars[eNB_id]->llr) + if ( !data[pbchLlr]) return; - int16_t *pbch_llr = (int16_t *) phy_vars_ue->pbch_vars[eNB_id]->llr; + const int sz=data[pbchLlr]->lineSz; + //const int antennas=data[pbchLlr]->colSz; + // We take the first antenna only for now + int16_t *llrs = (int16_t *) (data[pbchLlr]+1); float *llr_pbch, *bit_pbch; - oai_xygraph_getbuff(graph, &bit_pbch, &llr_pbch, 864, 0); + oai_xygraph_getbuff(graph, &bit_pbch, &llr_pbch, sz, 0); - for (int i=0; i<864; i++) { - llr_pbch[i] = (float) pbch_llr[i]; + for (int i=0; ipbch_vars[eNB_id]->rxdataF_comp[0]) + if (!data[pbchRxdataF_comp]) return; - scopeSample_t *pbch_comp = (scopeSample_t *) phy_vars_ue->pbch_vars[eNB_id]->rxdataF_comp[0]; + scopeSample_t *pbch_comp = (scopeSample_t *) (data[pbchRxdataF_comp]+1); + const int sz=data[pbchRxdataF_comp]->lineSz; float *I, *Q; - oai_xygraph_getbuff(graph, &I, &Q, 180*3, 0); - memset(I,0,180*3*sizeof(*I)); - memset(Q,0,180*3*sizeof(*Q)); - int first_symbol=1; - int base=0; + oai_xygraph_getbuff(graph, &I, &Q, sz, 0); - for (int symbol=first_symbol; symbol<(first_symbol+3); symbol++) { - int nb_re; - - if (symbol == 2 || symbol == 6) - nb_re = 72; - else - nb_re = 180; - - AssertFatal(base+nb_re<180*3,""); - - for (int i=0; ipdcch_vars[0][eNB_id]->llr) + if (!data[pdcchLlr]) return; //int num_re = 4*273*12; // 12*frame_parms->N_RB_DL*num_pdcch_symbols //int Qm = 2; - int coded_bits_per_codeword = 2*4*100*12; //num_re*Qm; + const int sz=data[pdcchLlr]->lineSz; float *llr, *bit; - oai_xygraph_getbuff(graph, &bit, &llr, coded_bits_per_codeword*RX_NB_TH_MAX, 0); - int base=0; + oai_xygraph_getbuff(graph, &bit, &llr, sz, 0); - for (int thr=0 ; thr < RX_NB_TH_MAX ; thr ++ ) { - int16_t *pdcch_llr = (int16_t *) phy_vars_ue->pdcch_vars[thr][eNB_id]->llr; + int16_t *pdcch_llr = (int16_t *)(data[pdcchLlr]+1); - for (int i=0; ipdcch_vars[0][eNB_id]->rxdataF_comp[0]) + if (!data[pdcchRxdataF_comp]) return; - int nb=4*273*12; // 12*frame_parms->N_RB_DL*num_pdcch_symbols + const int sz=data[pdcchRxdataF_comp]->lineSz; + //const int antennas=data[pdcchRxdataF_comp]->colSz; + // We take the first antenna only for now float *I, *Q; - oai_xygraph_getbuff(graph, &I, &Q, nb*RX_NB_TH_MAX, 0); - int base=0; + oai_xygraph_getbuff(graph, &I, &Q, sz, 0); - for (int thr=0 ; thr < RX_NB_TH_MAX ; thr ++ ) { - scopeSample_t *pdcch_comp = (scopeSample_t *) phy_vars_ue->pdcch_vars[thr][eNB_id]->rxdataF_comp[0]; + scopeSample_t *pdcch_comp = (scopeSample_t *) (data[pdcchRxdataF_comp]+1); - for (int i=0; i< nb; i++) { - I[base+i] = pdcch_comp[i].r; - Q[base+i] = pdcch_comp[i].i; - } - - base+=nb; + for (int i=0; ipdsch_vars[0][eNB_id]->llr[0]) return; @@ -749,7 +742,7 @@ static void uePdschLLR (OAIgraph_t *graph, PHY_VARS_NR_UE *phy_vars_ue, int eNB //fl_set_xyplot_xbounds(form->pdsch_llr,0,coded_bits_per_codeword); oai_xygraph(graph,bit,llr,base,0,10); } -static void uePdschIQ (OAIgraph_t *graph, PHY_VARS_NR_UE *phy_vars_ue, int eNB_id, int UE_id) { +static void uePdschIQ (scopeGraphData_t **data, OAIgraph_t *graph, PHY_VARS_NR_UE *phy_vars_ue, int eNB_id, int UE_id) { // PDSCH I/Q of MF Output if (!phy_vars_ue->pdsch_vars[0][eNB_id]->rxdataF_comp0[0]) return; @@ -776,7 +769,7 @@ static void uePdschIQ (OAIgraph_t *graph, PHY_VARS_NR_UE *phy_vars_ue, int eNB_ AssertFatal(base <= sz*RX_NB_TH_MAX, ""); oai_xygraph(graph,I,Q,sz*RX_NB_TH_MAX,0,10); } -static void uePdschThroughput (OAIgraph_t *graph, PHY_VARS_NR_UE *phy_vars_ue, int eNB_id, int UE_id) { +static void uePdschThroughput (scopeGraphData_t **data, OAIgraph_t *graph, PHY_VARS_NR_UE *phy_vars_ue, int eNB_id, int UE_id) { /* float tput_time_ue[NUMBER_OF_UE_MAX][TPUT_WINDOW_LENGTH] = {{0}}; float tput_ue[NUMBER_OF_UE_MAX][TPUT_WINDOW_LENGTH] = {{0}}; @@ -869,7 +862,9 @@ static OAI_phy_scope_t *create_phy_scope_nrue( int ID ) { fl_show_form (fdui->phy_scope, FL_PLACE_HOTSPOT, FL_FULLBORDER, buf); return fdui; } -void phy_scope_nrUE(OAI_phy_scope_t *form, + +void phy_scope_nrUE(scopeGraphData_t **UEliveData, + OAI_phy_scope_t *form, PHY_VARS_NR_UE *phy_vars_ue, int eNB_id, int UE_id) { @@ -886,16 +881,17 @@ void phy_scope_nrUE(OAI_phy_scope_t *form, int i=0; while (form->graph[i].graph) { - form->graph[i].nrUEfunct(form->graph+i, phy_vars_ue, eNB_id, UE_id); + form->graph[i].nrUEfunct(UEliveData, form->graph+i, phy_vars_ue, eNB_id, UE_id); i++; } //fl_check_forms(); } + static void *nrUEscopeThread(void *arg) { PHY_VARS_NR_UE *ue=(PHY_VARS_NR_UE *)arg; size_t stksize; - pthread_attr_t atr={0}; + pthread_attr_t atr= {0}; pthread_attr_getstacksize(&atr, &stksize); pthread_attr_setstacksize(&atr,32*1024*1024 ); int fl_argc=1; @@ -905,7 +901,8 @@ static void *nrUEscopeThread(void *arg) { while (!oai_exit) { fl_freeze_form(form_nrue->phy_scope); - phy_scope_nrUE(form_nrue, + phy_scope_nrUE((( scopeData_t *)ue->scopeData)->liveData, + form_nrue, ue, 0,0); fl_unfreeze_form(form_nrue->phy_scope); @@ -915,10 +912,57 @@ static void *nrUEscopeThread(void *arg) { pthread_exit((void *)arg); } + +void UEcopyData(PHY_VARS_NR_UE *ue, enum UEdataType type, void *dataIn, int elementSz, int colSz, int lineSz) { + // Local static copy of the scope data bufs + // The active data buf is alterned to avoid interference between the Scope thread (display) and the Rx thread (data input) + // Index of "2" could be set to the number of Rx threads + 1 + static scopeGraphData_t *copyDataBufs[UEdataTypeNumberOfItems][2] = {0}; + static int copyDataBufsIdx[UEdataTypeNumberOfItems] = {0}; + + scopeData_t *tmp=(scopeData_t *)ue->scopeData; + + if (tmp) { + // Begin of critical zone between UE Rx threads that might copy new data at the same time: might require a mutex + int newCopyDataIdx = (copyDataBufsIdx[type]==0)?1:0; + copyDataBufsIdx[type] = newCopyDataIdx; + // End of critical zone between UE Rx threads + + // New data will be copied in a different buffer than the live one + scopeGraphData_t *copyData= copyDataBufs[type][newCopyDataIdx]; + + if (copyData == NULL || copyData->dataSize < elementSz*colSz*lineSz) { + scopeGraphData_t *ptr=realloc(copyData, sizeof(scopeGraphData_t) + elementSz*colSz*lineSz); + + if (!ptr) { + LOG_E(PHY,"can't realloc\n"); + return; + } else { + copyData=ptr; + } + } + + copyData->dataSize=elementSz*colSz*lineSz; + copyData->elementSz=elementSz; + copyData->colSz=colSz; + copyData->lineSz=lineSz; + memcpy(copyData+1, dataIn, elementSz*colSz*lineSz); + copyDataBufs[type][newCopyDataIdx] = copyData; + + // The new data just copied in the local static buffer becomes live now + ((scopeGraphData_t **)tmp->liveData)[type]=copyData; + } +} + void nrUEinitScope(PHY_VARS_NR_UE *ue) { + AssertFatal(ue->scopeData=malloc(sizeof(scopeData_t)),""); + scopeData_t *scope=(scopeData_t *) ue->scopeData; + scope->copyData=UEcopyData; + AssertFatal(scope->liveData=calloc(sizeof(scopeGraphData_t *), UEdataTypeNumberOfItems),""); pthread_t forms_thread; threadCreate(&forms_thread, nrUEscopeThread, ue, "scope", -1, OAI_PRIORITY_RT_LOW); } + void nrscope_autoinit(void *dataptr) { AssertFatal( (IS_SOFTMODEM_GNB_BIT||IS_SOFTMODEM_5GUE_BIT),"Scope cannot find NRUE or GNB context"); diff --git a/openair1/PHY/TOOLS/oai_dfts.c b/openair1/PHY/TOOLS/oai_dfts.c index 83207426fd..c2b6a55210 100644 --- a/openair1/PHY/TOOLS/oai_dfts.c +++ b/openair1/PHY/TOOLS/oai_dfts.c @@ -7082,43 +7082,40 @@ static inline void dft12f(simd_q15_t *x0, simd_q15_t tmp_dft12[12]; - simd_q15_t *tmp_dft12_ptr = &tmp_dft12[0]; - // msg("dft12\n"); bfly4_tw1(x0, x3, x6, x9, - tmp_dft12_ptr, - tmp_dft12_ptr+3, - tmp_dft12_ptr+6, - tmp_dft12_ptr+9); - + tmp_dft12, + tmp_dft12+3, + tmp_dft12+6, + tmp_dft12+9); bfly4_tw1(x1, x4, x7, x10, - tmp_dft12_ptr+1, - tmp_dft12_ptr+4, - tmp_dft12_ptr+7, - tmp_dft12_ptr+10); + tmp_dft12+1, + tmp_dft12+4, + tmp_dft12+7, + tmp_dft12+10); bfly4_tw1(x2, x5, x8, x11, - tmp_dft12_ptr+2, - tmp_dft12_ptr+5, - tmp_dft12_ptr+8, - tmp_dft12_ptr+11); + tmp_dft12+2, + tmp_dft12+5, + tmp_dft12+8, + tmp_dft12+11); // k2=0; - bfly3_tw1(tmp_dft12_ptr, - tmp_dft12_ptr+1, - tmp_dft12_ptr+2, + bfly3_tw1(tmp_dft12, + tmp_dft12+1, + tmp_dft12+2, y0, y4, y8); @@ -7126,9 +7123,9 @@ static inline void dft12f(simd_q15_t *x0, // k2=1; - bfly3(tmp_dft12_ptr+3, - tmp_dft12_ptr+4, - tmp_dft12_ptr+5, + bfly3(tmp_dft12+3, + tmp_dft12+4, + tmp_dft12+5, y1, y5, y9, @@ -7138,9 +7135,9 @@ static inline void dft12f(simd_q15_t *x0, // k2=2; - bfly3(tmp_dft12_ptr+6, - tmp_dft12_ptr+7, - tmp_dft12_ptr+8, + bfly3(tmp_dft12+6, + tmp_dft12+7, + tmp_dft12+8, y2, y6, y10, @@ -7148,9 +7145,9 @@ static inline void dft12f(simd_q15_t *x0, W4_12); // k2=3; - bfly3(tmp_dft12_ptr+9, - tmp_dft12_ptr+10, - tmp_dft12_ptr+11, + bfly3(tmp_dft12+9, + tmp_dft12+10, + tmp_dft12+11, y3, y7, y11, @@ -10606,15 +10603,43 @@ int dfts_autoinit(void) #ifndef MR_MAIN -void dft(uint8_t sizeidx, int16_t *sigF,int16_t *sig,unsigned char scale_flag){ - AssertFatal((sizeidx>=0 && sizeidx<(int)DFT_SIZE_IDXTABLESIZE),"Invalid dft size index %i\n",sizeidx); - dft_ftab[sizeidx](sigF,sig,scale_flag); +void dft(uint8_t sizeidx, int16_t *input,int16_t *output,unsigned char scale_flag){ + AssertFatal((sizeidx >= 0 && sizeidx=0 && sizeidx<(int)IDFT_SIZE_IDXTABLESIZE),"Invalid idft size index %i\n",sizeidx); - idft_ftab[sizeidx](sigF,sig,scale_flag); +void idft(uint8_t sizeidx, int16_t *input,int16_t *output,unsigned char scale_flag){ + AssertFatal((sizeidx>=0 && sizeidx +#include + typedef struct { int *argc; char **argv; @@ -39,16 +41,27 @@ typedef struct { PHY_VARS_gNB *gNB; } scopeParms_t; +enum UEdataType { + pbchDlChEstimateTime, + pbchLlr, + pbchRxdataF_comp, + pdcchLlr, + pdcchRxdataF_comp, + UEdataTypeNumberOfItems +}; typedef struct scopeData_s { int *argc; char **argv; RU_t *ru; PHY_VARS_gNB *gNB; - int32_t * rxdataF; - void (*slotFunc)(int32_t* data, int slot, void * scopeData); + void *liveData; + void (*slotFunc)(int32_t *data, int slot, void *scopeData); + void (*copyData)(PHY_VARS_NR_UE *,enum UEdataType, void *data, int elementSz, int colSz, int lineSz); } scopeData_t; int load_softscope(char *exectype, void *initarg); int end_forms(void) ; + +#define UEscopeCopy(ue, type, ...) if(ue->scopeData) ((scopeData_t*)ue->scopeData)->copyData(ue, type, ##__VA_ARGS__); #endif diff --git a/openair1/PHY/TOOLS/tools_defs.h b/openair1/PHY/TOOLS/tools_defs.h index 966e93440e..839beb3dc9 100644 --- a/openair1/PHY/TOOLS/tools_defs.h +++ b/openair1/PHY/TOOLS/tools_defs.h @@ -33,32 +33,41 @@ extern "C" { #endif +#include #include +#include #include "PHY/sse_intrin.h" #define CEILIDIV(a,b) ((a+b-1)/b) #define ROUNDIDIV(a,b) (((a<<1)+b)/(b<<1)) -struct complexd { +typedef struct complexd { double r; double i; -}; +} cd_t; -struct complexf { +typedef struct complexf { float r; float i; -}; +} cf_t; -struct complex16 { +typedef struct complex16 { int16_t r; int16_t i; -}; +} c16_t; -struct complex32 { +typedef struct complex32 { int32_t r; int32_t i; -}; +} c32_t; + +typedef struct complex64 { + int64_t r; + int64_t i; +} c64_t; +#define squaredMod(a) ((a).r*(a).r+(a).i*(a).i) +#define csum(res, i1, i2) (res).r=(i1).r+(i2).r ; (res).i=(i1).i+(i2).i //cmult_sv.h /*!\fn void multadd_real_vector_complex_scalar(int16_t *x,int16_t *alpha,int16_t *y,uint32_t N) @@ -181,161 +190,275 @@ This function performs optimized fixed-point radix-2 FFT/IFFT. ); */ +#define FOREACH_DFTSZ(SZ_DEF) \ + SZ_DEF(12) \ + SZ_DEF(24) \ + SZ_DEF(36) \ + SZ_DEF(48) \ + SZ_DEF(60) \ + SZ_DEF(64) \ + SZ_DEF(72) \ + SZ_DEF(96) \ + SZ_DEF(108) \ + SZ_DEF(120) \ + SZ_DEF(128) \ + SZ_DEF(144) \ + SZ_DEF(180) \ + SZ_DEF(192) \ + SZ_DEF(216) \ + SZ_DEF(240) \ + SZ_DEF(256) \ + SZ_DEF(288) \ + SZ_DEF(300) \ + SZ_DEF(324) \ + SZ_DEF(360) \ + SZ_DEF(384) \ + SZ_DEF(432) \ + SZ_DEF(480) \ + SZ_DEF(512) \ + SZ_DEF(540) \ + SZ_DEF(576) \ + SZ_DEF(600) \ + SZ_DEF(648) \ + SZ_DEF(720) \ + SZ_DEF(768) \ + SZ_DEF(864) \ + SZ_DEF(900) \ + SZ_DEF(960) \ + SZ_DEF(972) \ + SZ_DEF(1024) \ + SZ_DEF(1080) \ + SZ_DEF(1152) \ + SZ_DEF(1200) \ + SZ_DEF(1296) \ + SZ_DEF(1440) \ + SZ_DEF(1500) \ + SZ_DEF(1536) \ + SZ_DEF(1620) \ + SZ_DEF(1728) \ + SZ_DEF(1800) \ + SZ_DEF(1920) \ + SZ_DEF(1944) \ + SZ_DEF(2048) \ + SZ_DEF(2160) \ + SZ_DEF(2304) \ + SZ_DEF(2400) \ + SZ_DEF(2592) \ + SZ_DEF(2700) \ + SZ_DEF(2880) \ + SZ_DEF(2916) \ + SZ_DEF(3000) \ + SZ_DEF(3072) \ + SZ_DEF(3240) \ + SZ_DEF(4096) \ + SZ_DEF(6144) \ + SZ_DEF(8192) \ + SZ_DEF(9216) \ + SZ_DEF(12288) \ + SZ_DEF(18432) \ + SZ_DEF(24576) \ + SZ_DEF(36864) \ + SZ_DEF(49152) \ + SZ_DEF(73728) \ + SZ_DEF(98304) +#define FOREACH_IDFTSZ(SZ_DEF)\ + SZ_DEF(64) \ + SZ_DEF(128) \ + SZ_DEF(256) \ + SZ_DEF(512) \ + SZ_DEF(1024) \ + SZ_DEF(1536) \ + SZ_DEF(2048) \ + SZ_DEF(3072) \ + SZ_DEF(4096) \ + SZ_DEF(6144) \ + SZ_DEF(8192) \ + SZ_DEF(9216) \ + SZ_DEF(12288) \ + SZ_DEF(18432) \ + SZ_DEF(24576) \ + SZ_DEF(36864) \ + SZ_DEF(49152) \ + SZ_DEF(73728) \ + SZ_DEF(98304) #ifdef OAIDFTS_MAIN -typedef void(*adftfunc_t)(int16_t *sigF,int16_t *sig,unsigned char scale_flag); -typedef void(*aidftfunc_t)(int16_t *sigF,int16_t *sig,unsigned char scale_flag); +typedef void(*adftfunc_t)(int16_t *sigF,int16_t *sig,unsigned char scale_flag); +typedef void(*aidftfunc_t)(int16_t *sigF,int16_t *sig,unsigned char scale_flag); -void dft12(int16_t *x,int16_t *y,uint8_t scale_flag); -void dft24(int16_t *x,int16_t *y,uint8_t scale_flag); -void dft36(int16_t *x,int16_t *y,uint8_t scale_flag); -void dft48(int16_t *x,int16_t *y,uint8_t scale_flag); -void dft60(int16_t *x,int16_t *y,uint8_t scale_flag); -void dft64(int16_t *x,int16_t *y,uint8_t scale_flag); -void dft72(int16_t *x,int16_t *y,uint8_t scale_flag); -void dft96(int16_t *x,int16_t *y,uint8_t scale_flag); -void dft108(int16_t *x,int16_t *y,uint8_t scale_flag); -void dft120(int16_t *x,int16_t *y,uint8_t scale_flag); -void dft128(int16_t *x,int16_t *y,uint8_t scale_flag); -void dft144(int16_t *x,int16_t *y,uint8_t scale_flag); -void dft180(int16_t *x,int16_t *y,uint8_t scale_flag); -void dft192(int16_t *x,int16_t *y,uint8_t scale_flag); -void dft216(int16_t *x,int16_t *y,uint8_t scale_flag); -void dft240(int16_t *x,int16_t *y,uint8_t scale_flag); -void dft256(int16_t *x,int16_t *y,uint8_t scale_flag); -void dft288(int16_t *x,int16_t *y,uint8_t scale_flag); -void dft300(int16_t *x,int16_t *y,uint8_t scale_flag); -void dft324(int16_t *x,int16_t *y,uint8_t scale_flag); -void dft360(int16_t *x,int16_t *y,uint8_t scale_flag); -void dft384(int16_t *x,int16_t *y,uint8_t scale_flag); -void dft432(int16_t *x,int16_t *y,uint8_t scale_flag); -void dft480(int16_t *x,int16_t *y,uint8_t scale_flag); -void dft512(int16_t *x,int16_t *y,uint8_t scale_flag); -void dft540(int16_t *x,int16_t *y,uint8_t scale_flag); -void dft576(int16_t *x,int16_t *y,uint8_t scale_flag); -void dft600(int16_t *x,int16_t *y,uint8_t scale_flag); -void dft648(int16_t *x,int16_t *y,uint8_t scale_flag); -void dft720(int16_t *x,int16_t *y,uint8_t scale_flag); -void dft768(int16_t *x,int16_t *y,uint8_t scale_flag); -void dft864(int16_t *x,int16_t *y,uint8_t scale_flag); -void dft900(int16_t *x,int16_t *y,uint8_t scale_flag); -void dft960(int16_t *x,int16_t *y,uint8_t scale_flag); -void dft972(int16_t *x,int16_t *y,uint8_t scale_flag); -void dft1024(int16_t *x,int16_t *y,uint8_t scale_flag); -void dft1080(int16_t *x,int16_t *y,uint8_t scale_flag); -void dft1152(int16_t *x,int16_t *y,uint8_t scale_flag); -void dft1200(int16_t *x,int16_t *y,uint8_t scale_flag); -void dft1296(int16_t *x,int16_t *y,uint8_t scale_flag); -void dft1440(int16_t *x,int16_t *y,uint8_t scale_flag); -void dft1500(int16_t *x,int16_t *y,uint8_t scale_flag); -void dft1536(int16_t *sigF,int16_t *sig,uint8_t scale_flag); -void dft1620(int16_t *x,int16_t *y,uint8_t scale_flag); -void dft1728(int16_t *x,int16_t *y,uint8_t scale_flag); -void dft1800(int16_t *x,int16_t *y,uint8_t scale_flag); -void dft1920(int16_t *x,int16_t *y,uint8_t scale_flag); -void dft1944(int16_t *x,int16_t *y,uint8_t scale_flag); -void dft2048(int16_t *x,int16_t *y,uint8_t scale_flag); -void dft2160(int16_t *x,int16_t *y,uint8_t scale_flag); -void dft2304(int16_t *x,int16_t *y,uint8_t scale_flag); -void dft2400(int16_t *x,int16_t *y,uint8_t scale_flag); -void dft2592(int16_t *x,int16_t *y,uint8_t scale_flag); -void dft2700(int16_t *x,int16_t *y,uint8_t scale_flag); -void dft2880(int16_t *x,int16_t *y,uint8_t scale_flag); -void dft2916(int16_t *x,int16_t *y,uint8_t scale_flag); -void dft3000(int16_t *x,int16_t *y,uint8_t scale_flag); -void dft3072(int16_t *sigF,int16_t *sig,uint8_t scale_flag); -void dft3240(int16_t *x,int16_t *y,uint8_t scale_flag); -void dft4096(int16_t *x,int16_t *y,uint8_t scale_flag); -void dft6144(int16_t *sigF,int16_t *sig,uint8_t scale_flag); -void dft8192(int16_t *x,int16_t *y,uint8_t scale_flag); -void dft9216(int16_t *x,int16_t *y,uint8_t scale_flag); -void dft12288(int16_t *x,int16_t *y,uint8_t scale_flag); -void dft18432(int16_t *x,int16_t *y,uint8_t scale_flag); -void dft24576(int16_t *x,int16_t *y,uint8_t scale_flag); -void dft36864(int16_t *x,int16_t *y,uint8_t scale_flag); -void dft49152(int16_t *x,int16_t *y,uint8_t scale_flag); -void dft73728(int16_t *x,int16_t *y,uint8_t scale_flag); -void dft98304(int16_t *x,int16_t *y,uint8_t scale_flag); - - -void idft64(int16_t *x,int16_t *y,uint8_t scale_flag); -void idft128(int16_t *x,int16_t *y,uint8_t scale_flag); -void idft256(int16_t *x,int16_t *y,uint8_t scale_flag); -void idft512(int16_t *x,int16_t *y,uint8_t scale_flag); -void idft1024(int16_t *x,int16_t *y,uint8_t scale_flag); -void idft1536(int16_t *sigF,int16_t *sig,uint8_t scale_flag); -void idft2048(int16_t *x,int16_t *y,uint8_t scale_flag); -void idft3072(int16_t *sigF,int16_t *sig,uint8_t scale_flag); -void idft4096(int16_t *x,int16_t *y,uint8_t scale_flag); -void idft6144(int16_t *sigF,int16_t *sig,uint8_t scale_flag); -void idft8192(int16_t *x,int16_t *y,uint8_t scale_flag); -void idft9216(int16_t *x,int16_t *y,uint8_t scale_flag); -void idft12288(int16_t *sigF,int16_t *sig,uint8_t scale_flag); -void idft18432(int16_t *sigF,int16_t *sig,uint8_t scale_flag); -void idft24576(int16_t *sigF,int16_t *sig,uint8_t scale_flag); -void idft36864(int16_t *sigF,int16_t *sig,uint8_t scale_flag); -void idft49152(int16_t *sigF,int16_t *sig,uint8_t scale_flag); -void idft73728(int16_t *sigF,int16_t *sig,uint8_t scale_flag); -void idft98304(int16_t *sigF,int16_t *sig,uint8_t scale_flag); +#define SZ_FUNC(Sz) void dft ## Sz(int16_t *x,int16_t *y,uint8_t scale_flag); +FOREACH_DFTSZ(SZ_FUNC) +#define SZ_iFUNC(Sz) void idft ## Sz(int16_t *x,int16_t *y,uint8_t scale_flag); +FOREACH_IDFTSZ(SZ_iFUNC) #else - typedef void(*dftfunc_t)(uint8_t sizeidx,int16_t *sigF,int16_t *sig,unsigned char scale_flag); - typedef void(*idftfunc_t)(uint8_t sizeidx,int16_t *sigF,int16_t *sig,unsigned char scale_flag); +typedef void(*dftfunc_t)(uint8_t sizeidx,int16_t *sigF,int16_t *sig,unsigned char scale_flag); +typedef void(*idftfunc_t)(uint8_t sizeidx,int16_t *sigF,int16_t *sig,unsigned char scale_flag); # ifdef OAIDFTS_LOADER - dftfunc_t dft; - idftfunc_t idft; +dftfunc_t dft; +idftfunc_t idft; # else - extern dftfunc_t dft; - extern idftfunc_t idft; - extern int load_dftslib(void); +extern dftfunc_t dft; +extern idftfunc_t idft; +extern int load_dftslib(void); # endif #endif -typedef enum DFT_size_idx { - DFT_12, DFT_24, DFT_36, DFT_48, DFT_60, DFT_72, DFT_96, - DFT_108, DFT_120, DFT_128, DFT_144, DFT_180, DFT_192, DFT_216, DFT_240, - DFT_256, DFT_288, DFT_300, DFT_324, DFT_360, DFT_384, DFT_432, DFT_480, - DFT_512, DFT_540, DFT_576, DFT_600, DFT_648, DFT_720, DFT_768, DFT_864, - DFT_900, DFT_960, DFT_972, DFT_1024, DFT_1080, DFT_1152, DFT_1200, DFT_1296, - DFT_1440, DFT_1500, DFT_1536, DFT_1620, DFT_1728, DFT_1800, DFT_1920, DFT_1944, - DFT_2048, DFT_2160, DFT_2304, DFT_2400, DFT_2592, DFT_2700, DFT_2880, DFT_2916, - DFT_3000, DFT_3072, DFT_3240, DFT_4096, DFT_6144, DFT_8192, DFT_9216, DFT_12288, - DFT_18432, DFT_24576, DFT_36864, DFT_49152, DFT_73728, DFT_98304, - DFT_SIZE_IDXTABLESIZE -} dft_size_idx_t; +#define SZ_ENUM(Sz) DFT_ ## Sz, -#ifdef OAIDFTS_MAIN -adftfunc_t dft_ftab[]={ - dft12, dft24, dft36, dft48, dft60, dft72, dft96, - dft108, dft120, dft128, dft144, dft180, dft192, dft216, dft240, - dft256, dft288, dft300, dft324, dft360, dft384, dft432, dft480, - dft512, dft540, dft576, dft600, dft648, dft720, dft768, dft864, - dft900, dft960, dft972, dft1024, dft1080, dft1152, dft1200, dft1296, - dft1440, dft1500, dft1536, dft1620, dft1728, dft1800, dft1920, dft1944, - dft2048, dft2160, dft2304, dft2400, dft2592, dft2700, dft2880, dft2916, - dft3000, dft3072, dft3240, dft4096, dft6144, dft8192, dft9216, dft12288, - dft18432, dft24576, dft36864, dft49152, dft73728, dft98304 -}; -#endif +typedef enum dft_size_idx { + FOREACH_DFTSZ(SZ_ENUM) + DFT_SIZE_IDXTABLESIZE +} dft_size_idx_t; + +#define SZ_iENUM(Sz) IDFT_ ## Sz, + +/******************************************************************* +* +* NAME : get_dft +* +* PARAMETERS : size of ofdm symbol +* +* RETURN : function for discrete fourier transform +* +* DESCRIPTION : get dft function depending of ofdm size +* +*********************************************************************/ +static inline +dft_size_idx_t get_dft(int ofdm_symbol_size) +{ + switch (ofdm_symbol_size) { + case 128: + return DFT_128; + case 256: + return DFT_256; + case 512: + return DFT_512; + case 1024: + return DFT_1024; + case 1536: + return DFT_1536; + case 2048: + return DFT_2048; + case 3072: + return DFT_3072; + case 4096: + return DFT_4096; + case 6144: + return DFT_6144; + case 8192: + return DFT_8192; + case 9216: + return DFT_9216; + case 12288: + return DFT_12288; + case 18432: + return DFT_18432; + case 24576: + return DFT_24576; + case 36864: + return DFT_36864; + case 49152: + return DFT_49152; + case 73728: + return DFT_73728; + case 98304: + return DFT_98304; + default: + printf("function get_dft : unsupported ofdm symbol size \n"); + assert(0); + break; + } + return DFT_SIZE_IDXTABLESIZE; // never reached and will trigger assertion in idft function; +} typedef enum idft_size_idx { - IDFT_128, IDFT_256, IDFT_512, IDFT_1024, IDFT_1536, IDFT_2048, IDFT_3072, IDFT_4096, - IDFT_6144, IDFT_8192, IDFT_9216, IDFT_12288, IDFT_18432, IDFT_24576, IDFT_36864, IDFT_49152, - IDFT_73728, IDFT_98304, - IDFT_SIZE_IDXTABLESIZE -} idft_size_idx_t; + FOREACH_IDFTSZ(SZ_iENUM) + IDFT_SIZE_IDXTABLESIZE +} idft_size_idx_t; + #ifdef OAIDFTS_MAIN -aidftfunc_t idft_ftab[]={ - idft128, idft256, idft512, idft1024, idft1536, idft2048, idft3072, idft4096, - idft6144, idft8192, idft9216, idft12288, idft18432, idft24576, idft36864, idft49152, - idft73728, idft98304 + +#define SZ_PTR(Sz) {dft ## Sz,Sz}, +struct { + adftfunc_t func; + int size; +} dft_ftab[]= { + FOREACH_DFTSZ(SZ_PTR) }; + +#define SZ_iPTR(Sz) {idft ## Sz,Sz}, +struct { + adftfunc_t func; + int size; +} idft_ftab[]= { + FOREACH_IDFTSZ(SZ_iPTR) +}; + #endif +/******************************************************************* +* +* NAME : get_idft +* +* PARAMETERS : size of ofdm symbol +* +* RETURN : index pointing to the dft func in the dft library +* +* DESCRIPTION : get idft function depending of ofdm size +* +*********************************************************************/ +static inline +idft_size_idx_t get_idft(int ofdm_symbol_size) +{ + switch (ofdm_symbol_size) { + case 128: + return IDFT_128; + case 256: + return IDFT_256; + case 512: + return IDFT_512; + case 1024: + return IDFT_1024; + case 1536: + return IDFT_1536; + case 2048: + return IDFT_2048; + case 3072: + return IDFT_3072; + case 4096: + return IDFT_4096; + case 6144: + return IDFT_6144; + case 8192: + return IDFT_8192; + case 9216: + return IDFT_9216; + case 12288: + return IDFT_12288; + case 18432: + return IDFT_18432; + case 24576: + return IDFT_24576; + case 36864: + return IDFT_36864; + case 49152: + return IDFT_49152; + case 73728: + return IDFT_73728; + case 98304: + return IDFT_98304; + default: + printf("function get_idft : unsupported ofdm symbol size \n"); + assert(0); + break; + } + return IDFT_SIZE_IDXTABLESIZE; // never reached and will trigger assertion in idft function +} /*!\fn int32_t rotate_cpx_vector(int16_t *x,int16_t *alpha,int16_t *y,uint32_t N,uint16_t output_shift) @@ -387,7 +510,7 @@ int32_t add_real_vector64(int16_t *x, uint32_t N); int32_t sub_real_vector64(int16_t *x, - int16_t* y, + int16_t *y, int16_t *z, uint32_t N); @@ -444,7 +567,7 @@ int32_t signal_energy_amp_shift(int32_t *input, uint32_t length); /*!\fn int32_t signal_energy(int *,uint32_t); \brief Computes the signal energy per subcarrier */ -int32_t subcarrier_energy(int32_t *,uint32_t, int32_t* subcarrier_energy, uint16_t rx_power_correction); +int32_t subcarrier_energy(int32_t *,uint32_t, int32_t *subcarrier_energy, uint16_t rx_power_correction); #endif /*!\fn int32_t signal_energy_nodc(int32_t *,uint32_t); diff --git a/openair1/PHY/defs_RU.h b/openair1/PHY/defs_RU.h index 6b18e55c4b..0320697ecf 100644 --- a/openair1/PHY/defs_RU.h +++ b/openair1/PHY/defs_RU.h @@ -54,7 +54,6 @@ typedef enum { no_L2_connect=5, calib_prach_tx=6, rx_dump_frame=7, - loop_through_memory=8 } runmode_t; /*! \brief Extension Type */ @@ -458,8 +457,6 @@ typedef struct RU_t_s { int emulate_rf; /// numerology index int numerology; - /// flag to indicate basicsim operation - int basicsim; /// flag to indicate the RU is in sync with a master reference int in_synch; /// timing offset @@ -506,6 +503,10 @@ typedef struct RU_t_s { int att_tx; /// flag to indicate precoding operation in RU int do_precoding; + /// TX processing advance in subframes (for LTE) + int sf_ahead; + /// TX processing advance in slots (for NR) + int sl_ahead; /// FAPI confiuration nfapi_nr_config_request_scf_t config; /// Frame parameters diff --git a/openair1/PHY/defs_UE.h b/openair1/PHY/defs_UE.h index fa55384093..4f9bc076ff 100644 --- a/openair1/PHY/defs_UE.h +++ b/openair1/PHY/defs_UE.h @@ -833,10 +833,10 @@ typedef struct { pthread_mutex_t timer_mutex; pthread_cond_t timer_cond; int instance_cnt_timer; - /// RF and Interface devices per CC openair0_device rfdevice; + void *scopeData; } PHY_VARS_UE; /* this structure is used to pass both UE phy vars and diff --git a/openair1/PHY/defs_common.h b/openair1/PHY/defs_common.h index 86df85db5c..d13fe260de 100644 --- a/openair1/PHY/defs_common.h +++ b/openair1/PHY/defs_common.h @@ -99,7 +99,7 @@ #define NB_RX_ANTENNAS_MAX 64 -typedef enum {TDD=1,FDD=0} lte_frame_type_t; +typedef enum {TDD=1,FDD=0} frame_type_t; typedef enum {EXTENDED=1,NORMAL=0} lte_prefix_type_t; @@ -597,7 +597,7 @@ typedef struct LTE_DL_FRAME_PARMS { /// shift of pilot position in one RB uint8_t nushift; /// Frame type (0 FDD, 1 TDD) - lte_frame_type_t frame_type; + frame_type_t frame_type; /// TDD subframe assignment (0-7) (default = 3) (254=RX only, 255=TX only) uint8_t tdd_config; /// TDD S-subframe configuration (0-9) diff --git a/openair1/PHY/defs_gNB.h b/openair1/PHY/defs_gNB.h index 16eec8cc00..956fa51391 100644 --- a/openair1/PHY/defs_gNB.h +++ b/openair1/PHY/defs_gNB.h @@ -89,7 +89,7 @@ typedef struct { /// Pointer to the payload uint8_t *b; /// Pointers to transport block segments - uint8_t *c[MAX_NUM_NR_DLSCH_SEGMENTS]; + uint8_t **c; /// Frame where current HARQ round was sent uint32_t frame; /// Subframe where current HARQ round was sent @@ -157,13 +157,11 @@ typedef struct { /// Pointers to variables related to DLSCH harq process NR_DL_gNB_HARQ_t harq_process; /// TX buffers for UE-spec transmission (antenna layers 1,...,4 after to precoding) - int32_t *txdataF[NR_MAX_NB_LAYERS]; - /// TX buffers for UE-spec transmission (antenna ports 1000 or 1001,...,1007, before precoding) - int32_t *txdataF_precoding[NR_MAX_NB_LAYERS]; + int32_t **txdataF; /// Modulated symbols buffer - int32_t *mod_symbs[NR_MAX_NB_CODEWORDS]; + int32_t **mod_symbs; /// beamforming weights for UE-spec transmission (antenna ports 5 or 7..14), for each codeword, maximum 4 layers? - int32_t **ue_spec_bf_weights[NR_MAX_NB_LAYERS]; + int32_t ***ue_spec_bf_weights; /// dl channel estimates (estimated from ul channel estimates) int32_t **calib_dl_ch_estimates; /// Allocated RNTI (0 means DLSCH_t is not currently used) @@ -273,7 +271,7 @@ typedef struct { /// The payload + CRC (24 bits) in bits (38.212 V15.4.0 section 5.1) uint32_t B; /// Pointers to code blocks after code block segmentation and CRC attachment (38.212 V15.4.0 section 5.2.2) - uint8_t *c[MAX_NUM_NR_ULSCH_SEGMENTS]; + uint8_t **c; /// Number of bits in each code block (38.212 V15.4.0 section 5.2.2) uint32_t K; /// Number of "Filler" bits added in the code block segmentation (38.212 V15.4.0 section 5.2.2) @@ -281,13 +279,9 @@ typedef struct { /// Number of code blocks after code block segmentation (38.212 V15.4.0 section 5.2.2) uint32_t C; /// Pointers to code blocks after LDPC coding (38.212 V15.4.0 section 5.3.2) - int16_t *d[MAX_NUM_NR_ULSCH_SEGMENTS]; - /// LDPC processing buffer - t_nrLDPC_procBuf* p_nrLDPC_procBuf[MAX_NUM_NR_ULSCH_SEGMENTS]; + int16_t **d; /// LDPC lifting size (38.212 V15.4.0 table 5.3.2-1) uint32_t Z; - /// code blocks after bit selection in rate matching for LDPC code (38.212 V15.4.0 section 5.4.2.1) - int16_t e[MAX_NUM_NR_DLSCH_SEGMENTS][3*8448]; /// Number of bits in each code block after rate matching for LDPC code (38.212 V15.4.0 section 5.4.2.1) uint32_t E; /// Number of segments processed so far @@ -342,8 +336,6 @@ typedef struct { int16_t q_RI[MAX_RI_PAYLOAD]; /// Temporary h sequence to flag PUSCH_x/PUSCH_y symbols which are not scrambled uint8_t h[MAX_NUM_CHANNEL_BITS]; - /// soft bits for each received segment ("w"-sequence)(for definition see 36-212 V8.6 2009-03, p.15) - int16_t *w[MAX_NUM_NR_ULSCH_SEGMENTS]; ////////////////////////////////////////////////////////////// } NR_UL_gNB_HARQ_t; @@ -436,10 +428,6 @@ typedef struct { /// - first index: rx antenna id [0..nb_antennas_rx[ /// - second index: ? [0..2*ofdm_symbol_size[ int32_t **rxdataF_ext; - /// \brief Holds the received data in the frequency domain for the allocated RBs in normal format. - /// - first index: rx antenna id [0..nb_antennas_rx[ - /// - second index (definition from phy_init_lte_eNB()): ? [0..12*N_RB_UL*frame_parms->symbols_per_tti[ - int32_t **rxdataF_ext2; /// \brief Hold the channel estimates in time domain based on DRS. /// - first index: rx antenna id [0..nb_antennas_rx[ /// - second index: ? [0..4*ofdm_symbol_size[ @@ -452,14 +440,6 @@ typedef struct { /// - first index: ? [0..7] (hard coded) FIXME! accessed via \c nb_antennas_rx /// - second index: ? [0..12*N_RB_UL*frame_parms->symbols_per_tti[ int32_t **ul_ch_estimates_ext; - /// \brief Hold the PTRS phase estimates in frequency domain. - /// - first index: rx antenna id [0..nb_antennas_rx[ - /// - second index: ? [0..12*N_RB_UL*frame_parms->symbols_per_tti[ - int32_t **ul_ch_ptrs_estimates; - /// \brief Uplink phase estimates extracted in PRBS. - /// - first index: ? [0..7] (hard coded) FIXME! accessed via \c nb_antennas_rx - /// - second index: ? [0..12*N_RB_UL*frame_parms->symbols_per_tti[ - int32_t **ul_ch_ptrs_estimates_ext; /// \brief Holds the compensated signal. /// - first index: rx antenna id [0..nb_antennas_rx[ /// - second index: ? [0..12*N_RB_UL*frame_parms->symbols_per_tti[ @@ -475,7 +455,7 @@ typedef struct { /// \brief Cross-correlation of two UE signals. /// - first index: rx antenna [0..nb_antennas_rx[ /// - second index: symbol [0..] - int32_t **rho; + int32_t ***rho; /// \f$\log_2(\max|H_i|^2)\f$ int16_t log2_maxh; /// \brief Magnitude of Uplink Channel first layer (16QAM level/First 64QAM level). @@ -505,6 +485,10 @@ typedef struct { /// \brief llr values. /// - first index: ? [0..1179743] (hard coded) int16_t *llr; + /// \brief llr values per layer. + /// - first index: ? [0..3] (hard coded) + /// - first index: ? [0..1179743] (hard coded) + int16_t **llr_layers; /// DMRS symbol index, to be updated every DMRS symbol within a slot. uint8_t dmrs_symbol; // PTRS symbol index, to be updated every PTRS symbol within a slot. @@ -591,9 +575,6 @@ typedef struct gNB_L1_proc_t_s { int instance_cnt_te; /// \internal This variable is protected by \ref mutex_prach. int instance_cnt_prach; - - // instance count for over-the-air gNB synchronization - int instance_cnt_synch; /// \internal This variable is protected by \ref mutex_asynch_rxtx. int instance_cnt_asynch_rxtx; /// pthread structure for eNB single processing thread @@ -665,8 +646,6 @@ typedef struct { unsigned int n0_power_tot; //! estimated avg noise power (dB) unsigned int n0_power_tot_dB; - //! estimated avg noise power (dB) - int n0_power_tot_dBm; //! estimated avg noise power per RB per RX ant (lin) unsigned int n0_subband_power[MAX_NUM_RU_PER_gNB][275]; //! estimated avg noise power per RB per RX ant (dB) @@ -771,7 +750,7 @@ typedef struct PHY_VARS_gNB_s { NR_gNB_PDCCH_t pdcch_pdu[NUMBER_OF_NR_PDCCH_MAX]; NR_gNB_UL_PDCCH_t ul_pdcch_pdu[NUMBER_OF_NR_PDCCH_MAX]; NR_gNB_DLSCH_t *dlsch[NUMBER_OF_NR_DLSCH_MAX][2]; // Nusers times two spatial streams - NR_gNB_ULSCH_t *ulsch[NUMBER_OF_NR_ULSCH_MAX][2]; // [Nusers times][2 codewords] + NR_gNB_ULSCH_t *ulsch[NUMBER_OF_NR_ULSCH_MAX]; // [Nusers times] NR_gNB_DLSCH_t *dlsch_SI,*dlsch_ra,*dlsch_p; NR_gNB_DLSCH_t *dlsch_PCH; /// statistics for DLSCH measurement collection @@ -784,6 +763,9 @@ typedef struct PHY_VARS_gNB_s { /// SRS variables nr_srs_info_t *nr_srs_info[NUMBER_OF_NR_SRS_MAX]; + /// CSI-RS variables + nr_csi_rs_info_t *nr_csi_rs_info; + uint8_t pbch_configured; char gNB_generate_rar; @@ -802,15 +784,19 @@ typedef struct PHY_VARS_gNB_s { /// PDSCH DMRS sequence uint32_t ****nr_gold_pdsch_dmrs; + /// PDSCH codebook I precoding LUTs + /// first dimension: Rank number [0,...,noOfLayers-1[ + /// second dimension: PMI [0,...,CodeSize-1[ + /// third dimension: [i_rows*noOfLayers+j_col], i_rows=0,...pdsch_AntennaPorts-1 and j_col=0,...,noOfLayers-1 + int32_t ***nr_mimo_precoding_matrix; + int pmiq_size[NR_MAX_NB_LAYERS]; + /// PUSCH DMRS uint32_t ****nr_gold_pusch_dmrs; // Mask of occupied RBs, per symbol and PRB uint32_t rb_mask_ul[14][9]; - /// CSI RS sequence - uint32_t ***nr_gold_csi_rs; - /// Indicator set to 0 after first SR uint8_t first_sr[NUMBER_OF_NR_SR_MAX]; @@ -840,13 +826,25 @@ typedef struct PHY_VARS_gNB_s { int **dl_precoder_SgNB[3]; char log2_maxp; /// holds the maximum channel/precoder coefficient - int prb_interpolation; + int max_ldpc_iterations; + /// indicate the channel estimation technique in time domain + int chest_time; + /// indicate the channel estimation technique in freq domain + int chest_freq; /// if ==0 enables phy only test mode int mac_enabled; /// counter to average prach energh over first 100 prach opportunities int prach_energy_counter; + int pdcch_gold_init; + int pdsch_gold_init[2]; + int pusch_gold_init[2]; + + int ap_N1; + int ap_N2; + int ap_XP; + int pucch0_thres; int pusch_thres; int prach_thres; @@ -928,8 +926,8 @@ typedef struct LDPCDecode_s { int segment_r; int r_offset; int offset; - int Tbslbrm; int decodeIterations; + uint32_t tbslbrm; } ldpcDecode_t; struct ldpcReqId { diff --git a/openair1/PHY/defs_nr_UE.h b/openair1/PHY/defs_nr_UE.h index f4b49ececa..8ba87b7a67 100644 --- a/openair1/PHY/defs_nr_UE.h +++ b/openair1/PHY/defs_nr_UE.h @@ -183,7 +183,7 @@ typedef struct { //! estimated rssi (dBm) short rx_rssi_dBm[NUMBER_OF_CONNECTED_gNB_MAX]; //! estimated correlation (wideband linear) between spatial channels (computed in dlsch_demodulation) - int rx_correlation[NUMBER_OF_CONNECTED_gNB_MAX][4][4]; + int rx_correlation[NUMBER_OF_CONNECTED_gNB_MAX][NB_ANTENNAS_RX][NR_MAX_NB_LAYERS*NR_MAX_NB_LAYERS];// //! estimated correlation (wideband dB) between spatial channels (computed in dlsch_demodulation) int rx_correlation_dB[NUMBER_OF_CONNECTED_gNB_MAX][2]; @@ -225,11 +225,6 @@ typedef struct { } NR_UE_COMMON_PER_THREAD; -typedef struct { - /// TX buffers for multiple layers - int32_t *txdataF_layers[NR_MAX_NB_LAYERS]; - } NR_UE_PUSCH; - typedef struct { bool active[2]; fapi_nr_ul_config_pucch_pdu pucch_pdu[2]; @@ -276,12 +271,6 @@ typedef struct { /// - first index: ? [0..7] (hard coded) FIXME! accessed via \c nb_antennas_rx /// - second index: ? [0..168*N_RB_DL[ int32_t **rxdataF_comp0; - /// \brief Received frequency-domain signal after extraction and channel compensation for the second stream. For the SIC receiver we need to store the history of this for each harq process and round - /// - first index: ? [0..7] (hard coded) accessed via \c harq_pid - /// - second index: ? [0..7] (hard coded) accessed via \c round - /// - third index: ? [0..7] (hard coded) FIXME! accessed via \c nb_antennas_rx - /// - fourth index: ? [0..168*N_RB_DL[ - int32_t **rxdataF_comp1[8][8]; /// \brief Hold the channel estimates in frequency domain. /// - first index: ? [0..7] (hard coded) FIXME! accessed via \c nb_antennas_rx /// - second index: samples? [0..symbols_per_tti*(ofdm_symbol_size+LTE_CE_FILTER_LENGTH)[ @@ -290,16 +279,6 @@ typedef struct { /// - first index: ? [0..7] (hard coded) FIXME! accessed via \c nb_antennas_rx /// - second index: ? [0..168*N_RB_DL[ int32_t **dl_ch_estimates_ext; - /// \brief Downlink channel estimates extracted in PRBS. - /// - first index: ? [0..7] (hard coded) FIXME! accessed via \c nb_antennas_rx - /// - second index: ? [0..168*N_RB_DL[ - int32_t **dl_ch_ptrs_estimates_ext; - /// \brief Downlink cross-correlation of MIMO channel estimates (unquantized PMI) extracted in PRBS. For the SIC receiver we need to store the history of this for each harq process and round - /// - first index: ? [0..7] (hard coded) accessed via \c harq_pid - /// - second index: ? [0..7] (hard coded) accessed via \c round - /// - third index: ? [0..7] (hard coded) FIXME! accessed via \c nb_antennas_rx - /// - fourth index: ? [0..168*N_RB_DL[ - int32_t **dl_ch_rho_ext[8][8]; /// \brief Downlink beamforming channel estimates in frequency domain. /// - first index: ? [0..7] (hard coded) FIXME! accessed via \c nb_antennas_rx /// - second index: samples? [0..symbols_per_tti*(ofdm_symbol_size+LTE_CE_FILTER_LENGTH)[ @@ -308,10 +287,6 @@ typedef struct { /// - first index: ? [0..7] (hard coded) FIXME! accessed via \c nb_antennas_rx /// - second index: ? [0..168*N_RB_DL[ int32_t **dl_bf_ch_estimates_ext; - /// \brief Downlink cross-correlation of MIMO channel estimates (unquantized PMI) extracted in PRBS. - /// - first index: ? [0..7] (hard coded) FIXME! accessed via \c nb_antennas_rx - /// - second index: ? [0..168*N_RB_DL[ - int32_t **dl_ch_rho2_ext; /// \brief Downlink PMIs extracted in PRBS and grouped in subbands. /// - first index: ressource block [0..N_RB_DL[ uint8_t *pmi_ext; @@ -319,18 +294,10 @@ typedef struct { /// - first index: ? [0..7] (hard coded) FIXME! accessed via \c nb_antennas_rx /// - second index: ? [0..168*N_RB_DL[ int32_t **dl_ch_mag0; - /// \brief Magnitude of Downlink Channel second layer (16QAM level/First 64QAM level). - /// - first index: ? [0..7] (hard coded) FIXME! accessed via \c nb_antennas_rx - /// - second index: ? [0..168*N_RB_DL[ - int32_t **dl_ch_mag1[8][8]; /// \brief Magnitude of Downlink Channel, first layer (2nd 64QAM level). /// - first index: ? [0..7] (hard coded) FIXME! accessed via \c nb_antennas_rx /// - second index: ? [0..168*N_RB_DL[ int32_t **dl_ch_magb0; - /// \brief Magnitude of Downlink Channel second layer (2nd 64QAM level). - /// - first index: ? [0..7] (hard coded) FIXME! accessed via \c nb_antennas_rx - /// - second index: ? [0..168*N_RB_DL[ - int32_t **dl_ch_magb1[8][8]; /// \brief Magnitude of Downlink Channel, first layer (256QAM level). int32_t **dl_ch_magr0; /// \brief Cross-correlation Matrix of the gNB Tx channel signals. @@ -579,64 +546,20 @@ typedef struct { } NR_UE_PDCCH_SEARCHSPACE; #endif typedef struct { - /// \brief Pointers to extracted PDCCH symbols in frequency-domain. - /// - first index: ? [0..7] (hard coded) FIXME! accessed via \c nb_antennas_rx - /// - second index: ? [0..168*N_RB_DL[ - int32_t **rxdataF_ext; - /// \brief Pointers to extracted and compensated PDCCH symbols in frequency-domain. - /// - first index: ? [0..7] (hard coded) FIXME! accessed via \c nb_antennas_rx - /// - second index: ? [0..168*N_RB_DL[ - int32_t **rxdataF_comp; - /// \brief Hold the channel estimates in frequency domain. - /// - first index: ? [0..7] (hard coded) FIXME! accessed via \c nb_antennas_rx - /// - second index: samples? [0..symbols_per_tti*(ofdm_symbol_size+LTE_CE_FILTER_LENGTH)[ - int32_t **dl_ch_estimates; - /// \brief Hold the channel estimates in time domain (used for tracking). - /// - first index: ? [0..7] (hard coded) FIXME! accessed via \c nb_antennas_rx - /// - second index: samples? [0..2*ofdm_symbol_size[ - int32_t **dl_ch_estimates_time; - /// \brief Pointers to extracted channel estimates of PDCCH symbols. - /// - first index: ? [0..7] (hard coded) FIXME! accessed via \c nb_antennas_rx - /// - second index: ? [0..168*N_RB_DL[ - int32_t **dl_ch_estimates_ext; - /// \brief Pointers to channel cross-correlation vectors for multi-gNB detection. - /// - first index: ? [0..7] (hard coded) FIXME! accessed via \c nb_antennas_rx - /// - second index: ? [0..168*N_RB_DL[ - int32_t **dl_ch_rho_ext; - /// \brief Pointers to channel cross-correlation vectors for multi-gNB detection. - /// - first index: rx antenna [0..nb_antennas_rx[ - /// - second index: ? [0..] - int32_t **rho; - /// \brief Pointer to llrs, 4-bit resolution. - /// - first index: ? [0..48*N_RB_DL[ - int16_t *llr; - /// \brief Pointer to llrs, 16-bit resolution. - /// - first index: ? [0..96*N_RB_DL[ - int16_t *llr16; - /// \brief \f$\overline{w}\f$ from 36-211. - /// - first index: ? [0..48*N_RB_DL[ - int16_t *wbar; - /// \brief PDCCH/DCI e-sequence (input to rate matching). - /// - first index: ? [0..96*N_RB_DL[ - int16_t *e_rx; - /// Total number of PDU errors (diagnostic mode) - uint32_t dci_errors; + int nb_search_space; + uint16_t sfn; + uint16_t slot; + fapi_nr_dl_config_dci_dl_pdu_rel15_t pdcch_config[FAPI_NR_MAX_SS]; +} NR_UE_PDCCH_CONFIG; + +typedef struct { /// Total number of PDU received uint32_t dci_received; /// Total number of DCI False detection (diagnostic mode) uint32_t dci_false; /// Total number of DCI missed (diagnostic mode) uint32_t dci_missed; - /// nCCE for PDCCH per subframe - uint8_t nCCE[10]; - //Check for specific DCIFormat and AgregationLevel - uint8_t dciFormat; - uint8_t agregationLevel; - int nb_search_space; - fapi_nr_dl_config_dci_dl_pdu_rel15_t pdcch_config[FAPI_NR_MAX_SS]; - // frame and slot for sib1 in initial sync - uint16_t sfn; - uint16_t slot; + /* #ifdef NR_PDCCH_DEFS_NR_UE int nb_searchSpaces; @@ -654,40 +577,6 @@ typedef struct { #define PBCH_A 24 typedef struct { - /// \brief Pointers to extracted PBCH symbols in frequency-domain. - /// - first index: rx antenna [0..nb_antennas_rx[ - /// - second index: ? [0..287] (hard coded) - int32_t **rxdataF_ext; - /// \brief Pointers to extracted and compensated PBCH symbols in frequency-domain. - /// - first index: ? [0..7] (hard coded) FIXME! accessed via \c nb_antennas_rx - /// - second index: ? [0..287] (hard coded) - int32_t **rxdataF_comp; - /// \brief Hold the channel estimates in frequency domain. - /// - first index: ? [0..7] (hard coded) FIXME! accessed via \c nb_antennas_rx - /// - second index: samples? [0..symbols_per_tti*(ofdm_symbol_size+LTE_CE_FILTER_LENGTH)[ - int32_t **dl_ch_estimates; - /// \brief Pointers to downlink channel estimates in frequency-domain extracted in PRBS. - /// - first index: ? [0..7] (hard coded) FIXME! accessed via \c nb_antennas_rx - /// - second index: ? [0..287] (hard coded) - int32_t **dl_ch_estimates_ext; - /// \brief Hold the channel estimates in time domain (used for tracking). - /// - first index: ? [0..7] (hard coded) FIXME! accessed via \c nb_antennas_rx - /// - second index: samples? [0..2*ofdm_symbol_size[ - int32_t **dl_ch_estimates_time; - int log2_maxh; - uint8_t pbch_a[NR_POLAR_PBCH_PAYLOAD_BITS>>3]; - uint32_t pbch_a_interleaved; - uint32_t pbch_a_prime; - uint8_t pbch_e[NR_POLAR_PBCH_E]; - int16_t demod_pbch_e[NR_POLAR_PBCH_E]; - /// \brief Pointer to PBCH llrs. - /// - first index: ? [0..1919] (hard coded) - int16_t *llr; - /// \brief Pointer to PBCH decoded output. - /// - first index: ? [0..63] (hard coded) - uint8_t *decoded_output; - /// \brief PBCH additional bits - uint8_t xtra_byte; /// \brief Total number of PDU errors. uint32_t pdu_errors; /// \brief Total number of PDU errors 128 frames ago. @@ -695,7 +584,7 @@ typedef struct { /// \brief Total number of consecutive PDU errors. uint32_t pdu_errors_conseq; /// \brief FER (in percent) . - uint32_t pdu_fer; + //uint32_t pdu_fer; } NR_UE_PBCH; typedef struct { @@ -705,6 +594,16 @@ typedef struct { fapi_nr_ul_config_prach_pdu prach_pdu; } NR_UE_PRACH; +typedef struct { + bool active; + fapi_nr_dl_config_csiim_pdu_rel15_t csiim_config_pdu; +} NR_UE_CSI_IM; + +typedef struct { + bool active; + fapi_nr_dl_config_csirs_pdu_rel15_t csirs_config_pdu; +} NR_UE_CSI_RS; + typedef struct { bool active; fapi_nr_ul_config_srs_pdu srs_config_pdu; @@ -818,11 +717,12 @@ typedef struct { NR_UE_PBCH *pbch_vars[NUMBER_OF_CONNECTED_gNB_MAX]; NR_UE_PDCCH *pdcch_vars[RX_NB_TH_MAX][NUMBER_OF_CONNECTED_gNB_MAX]; NR_UE_PRACH *prach_vars[NUMBER_OF_CONNECTED_gNB_MAX]; + NR_UE_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_PUSCH *pusch_vars[RX_NB_TH_MAX][NUMBER_OF_CONNECTED_gNB_MAX]; NR_UE_PUCCH *pucch_vars[RX_NB_TH_MAX][NUMBER_OF_CONNECTED_gNB_MAX]; - NR_UE_DLSCH_t *dlsch[RX_NB_TH_MAX][NUMBER_OF_CONNECTED_gNB_MAX][NR_MAX_NB_CODEWORDS]; // two RxTx Threads - NR_UE_ULSCH_t *ulsch[RX_NB_TH_MAX][NUMBER_OF_CONNECTED_gNB_MAX][NR_MAX_NB_CODEWORDS]; // two code words + NR_UE_DLSCH_t *dlsch[RX_NB_TH_MAX][NUMBER_OF_CONNECTED_gNB_MAX][NR_MAX_NB_LAYERS>4 ? 2:1]; // two RxTx Threads + NR_UE_ULSCH_t *ulsch[RX_NB_TH_MAX][NUMBER_OF_CONNECTED_gNB_MAX]; NR_UE_DLSCH_t *dlsch_SI[NUMBER_OF_CONNECTED_gNB_MAX]; NR_UE_DLSCH_t *dlsch_ra[NUMBER_OF_CONNECTED_gNB_MAX]; NR_UE_DLSCH_t *dlsch_p[NUMBER_OF_CONNECTED_gNB_MAX]; @@ -857,7 +757,10 @@ typedef struct { uint32_t ****nr_gold_pdsch[NUMBER_OF_CONNECTED_eNB_MAX]; // Scrambling IDs used in PDSCH DMRS - uint16_t scramblingID[2]; + uint16_t scramblingID_dlsch[2]; + + // Scrambling IDs used in PUSCH DMRS + uint16_t scramblingID_ulsch[2]; /// PDCCH DMRS uint32_t ***nr_gold_pdcch[NUMBER_OF_CONNECTED_eNB_MAX]; @@ -874,7 +777,8 @@ typedef struct { uint32_t perfect_ce; // flag to activate PRB based averaging of channel estimates // when off, defaults to frequency domain interpolation - int prb_interpolation; + int chest_freq; + int chest_time; int generate_ul_signal[NUMBER_OF_CONNECTED_gNB_MAX]; UE_NR_SCAN_INFO_t scan_info[NB_BANDS_MAX]; @@ -962,6 +866,8 @@ typedef struct { /// N0 (used for abstraction) double N0; + uint8_t max_ldpc_iterations; + /// PDSCH Varaibles PDSCH_CONFIG_DEDICATED pdsch_config_dedicated[NUMBER_OF_CONNECTED_gNB_MAX]; @@ -974,6 +880,9 @@ typedef struct { /// SRS variables nr_srs_info_t *nr_srs_info; + /// CSI-RS variables + nr_csi_rs_info_t *nr_csi_rs_info; + //#if defined(UPGRADE_RAT_NR) #if 1 SystemInformationBlockType1_nr_t systemInformationBlockType1_nr; @@ -1073,7 +982,7 @@ typedef struct { #endif int dl_stats[5]; - + void* scopeData; } PHY_VARS_NR_UE; /* this structure is used to pass both UE phy vars and diff --git a/openair1/PHY/defs_nr_common.h b/openair1/PHY/defs_nr_common.h index d3352fb520..9c8e90a9c7 100644 --- a/openair1/PHY/defs_nr_common.h +++ b/openair1/PHY/defs_nr_common.h @@ -44,8 +44,6 @@ #define MAX_NUM_SUBCARRIER_SPACING 5 -#define NR_MAX_NB_RB 275 - #define NR_NB_SC_PER_RB 12 #define NR_NB_REG_PER_CCE 6 @@ -67,21 +65,9 @@ #define NR_PBCH_DMRS_LENGTH 144 // in mod symbols #define NR_PBCH_DMRS_LENGTH_DWORD 10 // ceil(2(QPSK)*NR_PBCH_DMRS_LENGTH/32) -/*These max values are for the gold sequences which are generated at init for the - * full carrier bandwidth*/ -#define NR_MAX_PDCCH_DMRS_INIT_LENGTH ((NR_MAX_NB_RB<<1)*3) // 3 symbols *2(QPSK) -#define NR_MAX_PDCCH_DMRS_INIT_LENGTH_DWORD 52 // ceil(NR_MAX_PDCCH_DMRS_LENGTH/32) /*used for the resource mapping*/ #define NR_MAX_PDCCH_DMRS_LENGTH 576 // 16(L)*2(QPSK)*3(3 DMRS symbs per REG)*6(REG per CCE) - -#define NR_MAX_PDSCH_DMRS_LENGTH 3300 //275*6(k)*2(QPSK real+imag) -#define NR_MAX_PDSCH_DMRS_INIT_LENGTH_DWORD 104 // ceil(NR_MAX_PDSCH_DMRS_LENGTH/32) - -#define NR_MAX_CSI_RS_LENGTH 4400 //275*8(max allocation per RB)*2(QPSK) -#define NR_MAX_CSI_RS_INIT_LENGTH_DWORD 138 // ceil(NR_MAX_CSI_RS_LENGTH/32) - -#define NR_MAX_PUSCH_DMRS_LENGTH NR_MAX_PDSCH_DMRS_LENGTH -#define NR_MAX_PUSCH_DMRS_INIT_LENGTH_DWORD NR_MAX_PDSCH_DMRS_INIT_LENGTH_DWORD +#define NR_MAX_PDCCH_SIZE 8192 // It seems it is the max polar coded block size #define NR_MAX_DCI_PAYLOAD_SIZE 64 #define NR_MAX_DCI_SIZE 1728 //16(L)*2(QPSK)*9(12 RE per REG - 3(DMRS))*6(REG per CCE) @@ -93,27 +79,29 @@ #define NR_MAX_CSET_DURATION 3 #define NR_MAX_NB_RBG 18 -#define NR_MAX_NB_LAYERS 2 // 8 // SU-MIMO (3GPP TS 38.211 V15.4.0 section 7.3.1.3) -#define NR_MAX_NB_CODEWORDS 2 + +#define NR_MAX_NB_LAYERS 4 // 8 +#define NR_MAX_NB_PORTS 32 + #define NR_MAX_NB_HARQ_PROCESSES 16 -#define NR_MAX_PDSCH_ENCODED_LENGTH (NR_MAX_NB_RB*NR_SYMBOLS_PER_SLOT*NR_NB_SC_PER_RB*8*NR_MAX_NB_LAYERS) // 8 is the maximum modulation order (it was 950984 before !!) -#define NR_MAX_PUSCH_ENCODED_LENGTH NR_MAX_PDSCH_ENCODED_LENGTH + #define NR_MAX_PDSCH_TBS 3824 #define NR_MAX_SIB_LENGTH 2976 // 3GPP TS 38.331 section 5.2.1 - The physical layer imposes a limit to the maximum size a SIB can take. The maximum SIB1 or SI message size is 2976 bits. -#define MAX_NUM_NR_DLSCH_SEGMENTS (NR_MAX_NB_LAYERS*34) -#define MAX_NR_DLSCH_PAYLOAD_BYTES (MAX_NUM_NR_DLSCH_SEGMENTS*1056) +#define MAX_NUM_NR_DLSCH_SEGMENTS_PER_LAYER 36 -#define MAX_NUM_NR_ULSCH_SEGMENTS 34 -#define MAX_NR_ULSCH_PAYLOAD_BYTES (MAX_NUM_NR_ULSCH_SEGMENTS*1056) +#define MAX_NUM_NR_ULSCH_SEGMENTS_PER_LAYER 34 + +#define MAX_NUM_NR_CHANNEL_BITS (4*14*273*12*8) // 14 symbols, 273 RB +#define MAX_NUM_NR_RE (4*14*273*12) #define MAX_NUM_NR_SRS_SYMBOLS 4 -#define MAX_NUM_NR_CHANNEL_BITS (14*273*12*8) // 14 symbols, 273 RB -#define MAX_NUM_NR_RE (14*273*12) #define NR_RX_NB_TH 1 #define NR_NB_TH_SLOT 2 +#define NR_NB_NSCID 2 + extern const uint8_t nr_rv_round_map[4]; static inline @@ -253,7 +241,7 @@ typedef struct { typedef struct { uint16_t sc_list_length; - uint16_t sc_list[6 * NR_MAX_NB_RB]; + uint16_t *sc_list; uint8_t srs_generated_signal_bits; int32_t *srs_generated_signal; int32_t **srs_received_signal; @@ -264,6 +252,25 @@ typedef struct { uint32_t *noise_power; } nr_srs_info_t; +typedef struct { + uint8_t N_cdm_groups; + uint8_t CDM_group_size; + uint8_t kprime; + uint8_t lprime; + uint8_t N_ports; + uint8_t j[16]; + uint8_t koverline[16]; + uint8_t loverline[16]; + uint16_t csi_gold_init; + uint32_t ***nr_gold_csi_rs; + uint8_t csi_rs_generated_signal_bits; + int32_t **csi_rs_generated_signal; + int32_t **csi_rs_received_signal; + int32_t ***csi_rs_ls_estimated_channel; + int32_t ***csi_rs_estimated_channel_freq; + uint32_t *noise_power; +} nr_csi_rs_info_t; + typedef struct NR_DL_FRAME_PARMS NR_DL_FRAME_PARMS; typedef uint32_t (*get_samples_per_slot_t)(int slot, NR_DL_FRAME_PARMS* fp); @@ -298,7 +305,7 @@ struct NR_DL_FRAME_PARMS { uint32_t att_rx; /// total Number of Resource Block Groups: this is ceil(N_PRB/P) /// Frame type (0 FDD, 1 TDD) - lte_frame_type_t frame_type; + frame_type_t frame_type; uint8_t tdd_config; /// Cell ID uint16_t Nid_cell; @@ -342,7 +349,7 @@ struct NR_DL_FRAME_PARMS { uint32_t samples_per_frame_wCP; /// NR numerology index [0..5] as specified in 38.211 Section 4 (mu). 0=15khZ SCS, 1=30khZ, 2=60kHz, etc uint8_t numerology_index; - /// Number of Physical transmit antennas in node + /// Number of Physical transmit antennas in node (corresponds to nrOfAntennaPorts) uint8_t nb_antennas_tx; /// Number of Receive antennas in node uint8_t nb_antennas_rx; diff --git a/openair1/SCHED/phy_procedures_lte_common.c b/openair1/SCHED/phy_procedures_lte_common.c index 7033c52701..9de453da94 100644 --- a/openair1/SCHED/phy_procedures_lte_common.c +++ b/openair1/SCHED/phy_procedures_lte_common.c @@ -994,7 +994,7 @@ int is_srs_occasion_common(LTE_DL_FRAME_PARMS *frame_parms,int frame_tx,int subf return(isSubframeSRS); } -void compute_srs_pos(lte_frame_type_t frameType,uint16_t isrs,uint16_t *psrsPeriodicity,uint16_t *psrsOffset) +void compute_srs_pos(frame_type_t frameType,uint16_t isrs,uint16_t *psrsPeriodicity,uint16_t *psrsOffset) { if(TDD == frameType) { diff --git a/openair1/SCHED/phy_procedures_lte_eNb.c b/openair1/SCHED/phy_procedures_lte_eNb.c index ee1e0be49a..1a35f6ee68 100644 --- a/openair1/SCHED/phy_procedures_lte_eNb.c +++ b/openair1/SCHED/phy_procedures_lte_eNb.c @@ -1938,6 +1938,8 @@ void fill_ulsch_harq_indication (PHY_VARS_eNB *eNB, LTE_UL_eNB_HARQ_t *ulsch_har pthread_mutex_unlock(&eNB->UL_INFO_mutex); } +#define packetError(ConD, fmt, args...) if (!(ConD)) { LOG_E(PHY, fmt, args); goodPacket=false; } + void fill_uci_harq_indication (int UEid, PHY_VARS_eNB *eNB, LTE_eNB_UCI *uci, int frame, int subframe, uint8_t *harq_ack, uint8_t tdd_mapping_mode, uint16_t tdd_multiplexing_mask) { if ( split73 == SPLIT73_DU ) { sendFs6Ulharq(fs6ULindicationHarq, UEid, eNB, uci, frame, subframe, harq_ack, tdd_mapping_mode, tdd_multiplexing_mask, 0, 0); @@ -1953,6 +1955,7 @@ void fill_uci_harq_indication (int UEid, PHY_VARS_eNB *eNB, LTE_eNB_UCI *uci, in } pthread_mutex_lock(&eNB->UL_INFO_mutex); + bool goodPacket=true; nfapi_harq_indication_t *ind = &eNB->UL_INFO.harq_ind; nfapi_harq_indication_body_t *body = &ind->harq_indication_body; assert(eNB->UL_INFO.harq_ind.harq_indication_body.number_of_harqs <= NFAPI_HARQ_IND_MAX_PDU); @@ -1985,73 +1988,87 @@ void fill_uci_harq_indication (int UEid, PHY_VARS_eNB *eNB, LTE_eNB_UCI *uci, in pdu->harq_indication_fdd_rel13.tl.tag = NFAPI_HARQ_INDICATION_FDD_REL13_TAG; pdu->harq_indication_fdd_rel13.mode = 0; pdu->harq_indication_fdd_rel13.number_of_ack_nack = 1; - AssertFatal (harq_ack[0] == 1 || harq_ack[0] == 2 || harq_ack[0] == 4, "harq_ack[0] is %d, should be 1,2 or 4\n", harq_ack[0]); - pdu->harq_indication_fdd_rel13.harq_tb_n[0] = harq_ack[0]; - // release DLSCH if needed - release_harq(eNB,DLSCH_id,0,frame,subframe,0xffff, harq_ack[0] == 1); + packetError (harq_ack[0] == 1 || harq_ack[0] == 2 || harq_ack[0] == 4, "harq_ack[0] is %d, should be 1,2 or 4\n", harq_ack[0]); + if (goodPacket) { + pdu->harq_indication_fdd_rel13.harq_tb_n[0] = harq_ack[0]; + // release DLSCH if needed + release_harq(eNB,DLSCH_id,0,frame,subframe,0xffff, harq_ack[0] == 1); + } } else if (uci->pucch_fmt == pucch_format1b) { pdu->harq_indication_fdd_rel13.tl.tag = NFAPI_HARQ_INDICATION_FDD_REL13_TAG; pdu->harq_indication_fdd_rel13.mode = 0; pdu->harq_indication_fdd_rel13.number_of_ack_nack = 2; - AssertFatal (harq_ack[0] == 1 || harq_ack[0] == 2 || harq_ack[1] == 4, "harq_ack[0] is %d, should be 0,1 or 4\n", harq_ack[0]); - AssertFatal (harq_ack[1] == 1 || harq_ack[1] == 2 || harq_ack[1] == 4, "harq_ack[1] is %d, should be 0,1 or 4\n", harq_ack[1]); - pdu->harq_indication_fdd_rel13.harq_tb_n[0] = harq_ack[0]; - pdu->harq_indication_fdd_rel13.harq_tb_n[1] = harq_ack[1]; - // release DLSCH if needed - release_harq(eNB,DLSCH_id,0,frame,subframe,0xffff, harq_ack[0] == 1); - release_harq(eNB,DLSCH_id,1,frame,subframe,0xffff, harq_ack[1] == 1); - } else AssertFatal(1==0,"only format 1a/b for now, received %d\n",uci->pucch_fmt); + packetError (harq_ack[0] == 1 || harq_ack[0] == 2 || harq_ack[1] == 4, "harq_ack[0] is %d, should be 0,1 or 4\n", harq_ack[0]); + packetError (harq_ack[1] == 1 || harq_ack[1] == 2 || harq_ack[1] == 4, "harq_ack[1] is %d, should be 0,1 or 4\n", harq_ack[1]); + if (goodPacket) { + pdu->harq_indication_fdd_rel13.harq_tb_n[0] = harq_ack[0]; + pdu->harq_indication_fdd_rel13.harq_tb_n[1] = harq_ack[1]; + // release DLSCH if needed + release_harq(eNB,DLSCH_id,0,frame,subframe,0xffff, harq_ack[0] == 1); + release_harq(eNB,DLSCH_id,1,frame,subframe,0xffff, harq_ack[1] == 1); + } + } else + packetError(1==0,"only format 1a/b for now, received %d\n",uci->pucch_fmt); } else { // TDD - AssertFatal (tdd_mapping_mode == 0 || tdd_mapping_mode == 1 || tdd_mapping_mode == 2, "Illegal tdd_mapping_mode %d\n", tdd_mapping_mode); - pdu->harq_indication_tdd_rel13.tl.tag = NFAPI_HARQ_INDICATION_TDD_REL13_TAG; - pdu->harq_indication_tdd_rel13.mode = tdd_mapping_mode; - LOG_D(PHY,"%s(eNB, uci_harq format %d, rnti:%04x, frame:%d, subframe:%d, tdd_mapping_mode:%d) harq_ack[0]:%d harq_ack[1]:%d\n", __FUNCTION__, uci->pucch_fmt,uci->rnti, frame, subframe, - tdd_mapping_mode,harq_ack[0],harq_ack[1]); + packetError (tdd_mapping_mode == 0 || tdd_mapping_mode == 1 || tdd_mapping_mode == 2, "Illegal tdd_mapping_mode %d\n", tdd_mapping_mode); + if (goodPacket) { + pdu->harq_indication_tdd_rel13.tl.tag = NFAPI_HARQ_INDICATION_TDD_REL13_TAG; + pdu->harq_indication_tdd_rel13.mode = tdd_mapping_mode; + LOG_D(PHY,"%s(eNB, uci_harq format %d, rnti:%04x, frame:%d, subframe:%d, tdd_mapping_mode:%d) harq_ack[0]:%d harq_ack[1]:%d\n", __FUNCTION__, uci->pucch_fmt,uci->rnti, frame, subframe, + tdd_mapping_mode,harq_ack[0],harq_ack[1]); - switch (tdd_mapping_mode) { + switch (tdd_mapping_mode) { case 0: // bundling if (uci->pucch_fmt == pucch_format1a) { pdu->harq_indication_tdd_rel13.tl.tag = NFAPI_HARQ_INDICATION_TDD_REL13_TAG; pdu->harq_indication_tdd_rel13.number_of_ack_nack = 1; LOG_D(PHY,"bundling, pucch1a, number of ack nack %d\n",pdu->harq_indication_tdd_rel13.number_of_ack_nack); - AssertFatal(harq_ack[0] == 1 || harq_ack[0] == 2 || harq_ack[0] == 4, "harq_ack[0] is %d, should be 1,2 or 4\n",harq_ack[0]); - pdu->harq_indication_tdd_rel13.harq_data[0].bundling.value_0 = harq_ack[0]; - // release all bundled DLSCH if needed - release_harq(eNB,DLSCH_id,0,frame,subframe,0xffff, harq_ack[0] == 1); + packetError(harq_ack[0] == 1 || harq_ack[0] == 2 || harq_ack[0] == 4, "harq_ack[0] is %d, should be 1,2 or 4\n",harq_ack[0]); + if (goodPacket) { + pdu->harq_indication_tdd_rel13.harq_data[0].bundling.value_0 = harq_ack[0]; + // release all bundled DLSCH if needed + release_harq(eNB,DLSCH_id,0,frame,subframe,0xffff, harq_ack[0] == 1); + } } else if (uci->pucch_fmt == pucch_format1b) { pdu->harq_indication_tdd_rel13.number_of_ack_nack = 2; - AssertFatal(harq_ack[0] == 1 || harq_ack[0] == 2 || harq_ack[1] == 4, "harq_ack[0] is %d, should be 0,1 or 4\n",harq_ack[0]); - AssertFatal(harq_ack[1] == 1 || harq_ack[1] == 2 || harq_ack[1] == 4, "harq_ack[1] is %d, should be 0,1 or 4\n",harq_ack[1]); - pdu->harq_indication_tdd_rel13.tl.tag = NFAPI_HARQ_INDICATION_TDD_REL13_TAG; - pdu->harq_indication_tdd_rel13.harq_data[0].bundling.value_0 = harq_ack[0]; - pdu->harq_indication_tdd_rel13.harq_data[1].bundling.value_0 = harq_ack[1]; - // release all DLSCH if needed - release_harq(eNB,DLSCH_id,0,frame,subframe,0xffff, harq_ack[0] == 1); - release_harq(eNB,DLSCH_id,1,frame,subframe,0xffff, harq_ack[1] == 1); + packetError(harq_ack[0] == 1 || harq_ack[0] == 2 || harq_ack[1] == 4, "harq_ack[0] is %d, should be 0,1 or 4\n",harq_ack[0]); + packetError(harq_ack[1] == 1 || harq_ack[1] == 2 || harq_ack[1] == 4, "harq_ack[1] is %d, should be 0,1 or 4\n",harq_ack[1]); + if (goodPacket) { + pdu->harq_indication_tdd_rel13.tl.tag = NFAPI_HARQ_INDICATION_TDD_REL13_TAG; + pdu->harq_indication_tdd_rel13.harq_data[0].bundling.value_0 = harq_ack[0]; + pdu->harq_indication_tdd_rel13.harq_data[1].bundling.value_0 = harq_ack[1]; + // release all DLSCH if needed + release_harq(eNB,DLSCH_id,0,frame,subframe,0xffff, harq_ack[0] == 1); + release_harq(eNB,DLSCH_id,1,frame,subframe,0xffff, harq_ack[1] == 1); + } } break; case 1: // multiplexing - AssertFatal (uci->pucch_fmt == pucch_format1b, "uci->pucch_format %d is not format1b\n", uci->pucch_fmt); - - if (uci->num_pucch_resources == 1 && uci->pucch_fmt == pucch_format1a) { - pdu->harq_indication_tdd_rel13.tl.tag = NFAPI_HARQ_INDICATION_TDD_REL13_TAG; - pdu->harq_indication_tdd_rel13.number_of_ack_nack = 1; - AssertFatal(harq_ack[0] == 1 || harq_ack[0] == 2 || harq_ack[0] == 4, "harq_ack[0] is %d, should be 1,2 or 4\n",harq_ack[0]); - pdu->harq_indication_tdd_rel13.harq_data[0].multiplex.value_0 = harq_ack[0]; - // release all DLSCH if needed - release_harq(eNB,DLSCH_id,0,frame,subframe,0xffff, harq_ack[0] == 1); + packetError (uci->pucch_fmt == pucch_format1b, "uci->pucch_format %d is not format1b\n", uci->pucch_fmt); + if (goodPacket) { + if (uci->num_pucch_resources == 1 && uci->pucch_fmt == pucch_format1a) { + pdu->harq_indication_tdd_rel13.tl.tag = NFAPI_HARQ_INDICATION_TDD_REL13_TAG; + pdu->harq_indication_tdd_rel13.number_of_ack_nack = 1; + packetError(harq_ack[0] == 1 || harq_ack[0] == 2 || harq_ack[0] == 4, "harq_ack[0] is %d, should be 1,2 or 4\n",harq_ack[0]); + if (goodPacket) { + pdu->harq_indication_tdd_rel13.harq_data[0].multiplex.value_0 = harq_ack[0]; + // release all DLSCH if needed + release_harq(eNB,DLSCH_id,0,frame,subframe,0xffff, harq_ack[0] == 1); + } } else if (uci->num_pucch_resources == 1 && uci->pucch_fmt == pucch_format1b) { - pdu->harq_indication_tdd_rel13.tl.tag = NFAPI_HARQ_INDICATION_TDD_REL13_TAG; - pdu->harq_indication_tdd_rel13.number_of_ack_nack = 2; - AssertFatal(harq_ack[0] == 1 || harq_ack[0] == 2 || harq_ack[1] == 4, "harq_ack[0] is %d, should be 0,1 or 4\n",harq_ack[0]); - AssertFatal(harq_ack[1] == 1 || harq_ack[1] == 2 || harq_ack[1] == 4, "harq_ack[1] is %d, should be 0,1 or 4\n",harq_ack[1]); - pdu->harq_indication_tdd_rel13.harq_data[0].multiplex.value_0 = harq_ack[0]; - pdu->harq_indication_tdd_rel13.harq_data[1].multiplex.value_0 = harq_ack[1]; - // release all DLSCH if needed - release_harq(eNB,DLSCH_id,0,frame,subframe,0xffff, harq_ack[0] == 1); - release_harq(eNB,DLSCH_id,1,frame,subframe,0xffff, harq_ack[1] == 1); + pdu->harq_indication_tdd_rel13.tl.tag = NFAPI_HARQ_INDICATION_TDD_REL13_TAG; + pdu->harq_indication_tdd_rel13.number_of_ack_nack = 2; + packetError(harq_ack[0] == 1 || harq_ack[0] == 2 || harq_ack[1] == 4, "harq_ack[0] is %d, should be 0,1 or 4\n",harq_ack[0]); + packetError(harq_ack[1] == 1 || harq_ack[1] == 2 || harq_ack[1] == 4, "harq_ack[1] is %d, should be 0,1 or 4\n",harq_ack[1]); + if (goodPacket) { + pdu->harq_indication_tdd_rel13.harq_data[0].multiplex.value_0 = harq_ack[0]; + pdu->harq_indication_tdd_rel13.harq_data[1].multiplex.value_0 = harq_ack[1]; + // release all DLSCH if needed + release_harq(eNB,DLSCH_id,0,frame,subframe,0xffff, harq_ack[0] == 1); + release_harq(eNB,DLSCH_id,1,frame,subframe,0xffff, harq_ack[1] == 1); + } } else { // num_pucch_resources (M) > 1 pdu->harq_indication_tdd_rel13.tl.tag = NFAPI_HARQ_INDICATION_TDD_REL13_TAG; pdu->harq_indication_tdd_rel13.number_of_ack_nack = uci->num_pucch_resources; @@ -2067,7 +2084,7 @@ void fill_uci_harq_indication (int UEid, PHY_VARS_eNB *eNB, LTE_eNB_UCI *uci, in release_harq(eNB,DLSCH_id,1,frame,subframe,tdd_multiplexing_mask, 1 /* force release? previous code was unconditional */); } - break; + break; case 2: // special bundling (SR collision) pdu->harq_indication_tdd_rel13.tl.tag = NFAPI_HARQ_INDICATION_TDD_REL13_TAG; @@ -2117,16 +2134,23 @@ void fill_uci_harq_indication (int UEid, PHY_VARS_eNB *eNB, LTE_eNB_UCI *uci, in } else { pdu->harq_indication_tdd_rel13.harq_data[0].bundling.value_0 = 0; } - + break; } break; + } + } } } //TDD - - eNB->UL_INFO.harq_ind.harq_indication_body.number_of_harqs++; - LOG_D(PHY,"Incremented eNB->UL_INFO.harq_ind.harq_indication_body.number_of_harqs:%d\n", eNB->UL_INFO.harq_ind.harq_indication_body.number_of_harqs); + + if (goodPacket) { + eNB->UL_INFO.harq_ind.harq_indication_body.number_of_harqs++; + LOG_D(PHY,"Incremented eNB->UL_INFO.harq_ind.harq_indication_body.number_of_harqs:%d\n", eNB->UL_INFO.harq_ind.harq_indication_body.number_of_harqs); + } else { + LOG_W(PHY,"discarded a PUCCH because the decoded values are impossible\n"); + } + pthread_mutex_unlock(&eNB->UL_INFO_mutex); } diff --git a/openair1/SCHED/sched_common.h b/openair1/SCHED/sched_common.h index c9fc338686..9f3e6695b6 100644 --- a/openair1/SCHED/sched_common.h +++ b/openair1/SCHED/sched_common.h @@ -339,7 +339,7 @@ void dump_dlsch2(PHY_VARS_UE *phy_vars_ue,uint8_t eNB_id,uint8_t subframe, unsig int is_srs_occasion_common(LTE_DL_FRAME_PARMS *frame_parms,int frame_tx,int subframe_tx); -void compute_srs_pos(lte_frame_type_t frameType,uint16_t isrs,uint16_t *psrsPeriodicity,uint16_t *psrsOffset); +void compute_srs_pos(frame_type_t frameType,uint16_t isrs,uint16_t *psrsPeriodicity,uint16_t *psrsOffset); /* from here: prototype added to remove compilation warnings, doc to be written by the author of the function */ diff --git a/openair1/SCHED/sched_common_vars.h b/openair1/SCHED/sched_common_vars.h index 2cae2aa96f..8886e0d576 100644 --- a/openair1/SCHED/sched_common_vars.h +++ b/openair1/SCHED/sched_common_vars.h @@ -20,6 +20,7 @@ */ #include +#include // This is the formula from Section 5.1.1.1 in 36.213 100*10*log10((2^(MPR*Ks)-1)), where MPR is in the range [0,6] and Ks=1.25 diff --git a/openair1/SCHED/sched_eNB.h b/openair1/SCHED/sched_eNB.h index de987b0ac7..efdb1bd199 100644 --- a/openair1/SCHED/sched_eNB.h +++ b/openair1/SCHED/sched_eNB.h @@ -215,7 +215,7 @@ int16_t get_target_pucch_rx_power(module_id_t module_idP, uint8_t CC_id); int is_srs_occasion_common(LTE_DL_FRAME_PARMS *frame_parms,int frame_tx,int subframe_tx); -void compute_srs_pos(lte_frame_type_t frameType,uint16_t isrs,uint16_t *psrsPeriodicity,uint16_t *psrsOffset); +void compute_srs_pos(frame_type_t frameType,uint16_t isrs,uint16_t *psrsPeriodicity,uint16_t *psrsOffset); void release_rnti_of_phy(module_id_t mod_id); /*@}*/ diff --git a/openair1/SCHED_NR/fapi_nr_l1.c b/openair1/SCHED_NR/fapi_nr_l1.c index 4b9f9534f0..48728ba44a 100644 --- a/openair1/SCHED_NR/fapi_nr_l1.c +++ b/openair1/SCHED_NR/fapi_nr_l1.c @@ -227,7 +227,8 @@ void nr_schedule_response(NR_Sched_Rsp_t *Sched_INFO){ LOG_D(PHY,"frame %d, slot %d, Got NFAPI_NR_UL_TTI_PRACH_PDU_TYPE for %d.%d\n", frame, slot, UL_tti_req->SFN, UL_tti_req->Slot); nfapi_nr_prach_pdu_t *prach_pdu = &UL_tti_req->pdus_list[i].prach_pdu; nr_fill_prach(gNB, UL_tti_req->SFN, UL_tti_req->Slot, prach_pdu); - if (gNB->RU_list[0]->if_south == LOCAL_RF) nr_fill_prach_ru(gNB->RU_list[0], UL_tti_req->SFN, UL_tti_req->Slot, prach_pdu); + if (gNB->RU_list[0]->if_south == LOCAL_RF || + gNB->RU_list[0]->if_south == REMOTE_IF5) nr_fill_prach_ru(gNB->RU_list[0], UL_tti_req->SFN, UL_tti_req->Slot, prach_pdu); break; case NFAPI_NR_UL_CONFIG_SRS_PDU_TYPE: LOG_D(PHY,"frame %d, slot %d, Got NFAPI_NR_UL_CONFIG_SRS_PDU_TYPE for %d.%d\n", frame, slot, UL_tti_req->SFN, UL_tti_req->Slot); diff --git a/openair1/SCHED_NR/nr_ru_procedures.c b/openair1/SCHED_NR/nr_ru_procedures.c index b90f14a129..3d5e4a0ce4 100644 --- a/openair1/SCHED_NR/nr_ru_procedures.c +++ b/openair1/SCHED_NR/nr_ru_procedures.c @@ -526,7 +526,8 @@ void nr_fep0(RU_t *ru, int first_half) { end_symbol = NR_SYMBOLS_PER_SLOT; } - LOG_D(PHY,"In fep0 for slot = %d, first_half = %d, start_symbol = %d, end_symbol = %d\n", proc->tti_rx, first_half, start_symbol, end_symbol); + LOG_D(PHY,"In fep0 for slot = %d, first_half = %d, start_symbol = %d, end_symbol = %d, nb_antennas_rx = %d,N_TA_offset = %d\n", + proc->tti_rx, first_half, start_symbol, end_symbol,fp->nb_antennas_rx,ru->N_TA_offset); // printf("fep0: slot %d\n",slot); VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_PHY_PROCEDURES_RU_FEPRX+proc->tti_rx, 1); diff --git a/openair1/SCHED_NR/phy_procedures_nr_gNB.c b/openair1/SCHED_NR/phy_procedures_nr_gNB.c index 4f5da672a8..84ba6b6bcd 100644 --- a/openair1/SCHED_NR/phy_procedures_nr_gNB.c +++ b/openair1/SCHED_NR/phy_procedures_nr_gNB.c @@ -54,8 +54,10 @@ void nr_set_ssb_first_subcarrier(nfapi_nr_config_request_scf_t *cfg, NR_DL_FRAME uint8_t sco = 0; if (((fp->freq_range == nr_FR1) && (cfg->ssb_table.ssb_subcarrier_offset.value<24)) || - ((fp->freq_range == nr_FR2) && (cfg->ssb_table.ssb_subcarrier_offset.value<12)) ) - sco = cfg->ssb_table.ssb_subcarrier_offset.value; + ((fp->freq_range == nr_FR2) && (cfg->ssb_table.ssb_subcarrier_offset.value<12)) ) { + if (fp->freq_range == nr_FR1) + sco = cfg->ssb_table.ssb_subcarrier_offset.value>>cfg->ssb_config.scs_common.value; + } fp->ssb_start_subcarrier = (12 * cfg->ssb_table.ssb_offset_point_a.value + sco); LOG_D(PHY, "SSB first subcarrier %d (%d,%d)\n", fp->ssb_start_subcarrier,cfg->ssb_table.ssb_offset_point_a.value,sco); @@ -158,8 +160,7 @@ void phy_procedures_gNB_TX(processingData_L1tx_t *msgTx, VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_PHY_gNB_PDCCH_TX,1); - nr_generate_dci_top(msgTx, - gNB->nr_gold_pdcch_dmrs[slot], + nr_generate_dci_top(msgTx, slot, &gNB->common_vars.txdataF[0][txdataF_offset], AMP, fp); @@ -177,8 +178,8 @@ void phy_procedures_gNB_TX(processingData_L1tx_t *msgTx, NR_gNB_CSIRS_t *csirs = &msgTx->csirs_pdu[i]; if (csirs->active == 1) { LOG_D(PHY, "CSI-RS generation started in frame %d.%d\n",frame,slot); - nfapi_nr_dl_tti_csi_rs_pdu_rel15_t csi_params = csirs->csirs_pdu.csi_rs_pdu_rel15; - nr_generate_csi_rs(gNB, AMP, csi_params, gNB->gNB_config.cell_config.phy_cell_id.value, slot); + nfapi_nr_dl_tti_csi_rs_pdu_rel15_t *csi_params = &csirs->csirs_pdu.csi_rs_pdu_rel15; + nr_generate_csi_rs(gNB->frame_parms, gNB->common_vars.txdataF, AMP, gNB->nr_csi_rs_info, csi_params, slot); csirs->active = 0; } } @@ -198,7 +199,7 @@ void nr_postDecode(PHY_VARS_gNB *gNB, notifiedFIFO_elt_t *req) { NR_UL_gNB_HARQ_t *ulsch_harq = rdata->ulsch_harq; NR_gNB_ULSCH_t *ulsch = rdata->ulsch; int r = rdata->segment_r; - nfapi_nr_pusch_pdu_t *pusch_pdu = &gNB->ulsch[rdata->ulsch_id][0]->harq_processes[rdata->harq_pid]->ulsch_pdu; + nfapi_nr_pusch_pdu_t *pusch_pdu = &gNB->ulsch[rdata->ulsch_id]->harq_processes[rdata->harq_pid]->ulsch_pdu; bool decodeSuccess = (rdata->decodeIterations <= rdata->decoderParms.numMaxIter); ulsch_harq->processedSegments++; @@ -259,15 +260,17 @@ void nr_postDecode(PHY_VARS_gNB *gNB, notifiedFIFO_elt_t *req) { LOG_D(PHY, "ULSCH %d in error\n",rdata->ulsch_id); nr_fill_indication(gNB,ulsch_harq->frame, ulsch_harq->slot, rdata->ulsch_id, rdata->harq_pid, 1,0); +// dumpsig=1; } /* - if (ulsch_harq->ulsch_pdu.mcs_index == 9 && dumpsig==1) { + if (ulsch_harq->ulsch_pdu.mcs_index == 0 && dumpsig==1) { #ifdef __AVX2__ int off = ((ulsch_harq->ulsch_pdu.rb_size&1) == 1)? 4:0; #else int off = 0; #endif + LOG_M("rxsigF0.m","rxsF0",&gNB->common_vars.rxdataF[0][(ulsch_harq->slot&3)*gNB->frame_parms.ofdm_symbol_size*gNB->frame_parms.symbols_per_slot],gNB->frame_parms.ofdm_symbol_size*gNB->frame_parms.symbols_per_slot,1,1); LOG_M("rxsigF0_ext.m","rxsF0_ext", &gNB->pusch_vars[0]->rxdataF_ext[0][ulsch_harq->ulsch_pdu.start_symbol_index*NR_NB_SC_PER_RB * ulsch_harq->ulsch_pdu.rb_size],ulsch_harq->ulsch_pdu.nr_of_symbols*(off+(NR_NB_SC_PER_RB * ulsch_harq->ulsch_pdu.rb_size)),1,1); LOG_M("chestF0.m","chF0", @@ -293,7 +296,8 @@ void nr_postDecode(PHY_VARS_gNB *gNB, notifiedFIFO_elt_t *req) { } exit(-1); - } */ + } +*/ ulsch->last_iteration_cnt = rdata->decodeIterations; VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_PHY_gNB_ULSCH_DECODING,0); } @@ -303,7 +307,7 @@ void nr_postDecode(PHY_VARS_gNB *gNB, notifiedFIFO_elt_t *req) { void nr_ulsch_procedures(PHY_VARS_gNB *gNB, int frame_rx, int slot_rx, int ULSCH_id, uint8_t harq_pid) { NR_DL_FRAME_PARMS *frame_parms = &gNB->frame_parms; - nfapi_nr_pusch_pdu_t *pusch_pdu = &gNB->ulsch[ULSCH_id][0]->harq_processes[harq_pid]->ulsch_pdu; + nfapi_nr_pusch_pdu_t *pusch_pdu = &gNB->ulsch[ULSCH_id]->harq_processes[harq_pid]->ulsch_pdu; uint8_t l, number_dmrs_symbols = 0; uint32_t G; @@ -342,6 +346,14 @@ void nr_ulsch_procedures(PHY_VARS_gNB *gNB, int frame_rx, int slot_rx, int ULSCH number_dmrs_symbols, // number of dmrs symbols irrespective of single or double symbol dmrs pusch_pdu->qam_mod_order, pusch_pdu->nrOfLayers); + + + nr_ulsch_layer_demapping(gNB->pusch_vars[ULSCH_id]->llr, + pusch_pdu->nrOfLayers, + pusch_pdu->qam_mod_order, + G, + gNB->pusch_vars[ULSCH_id]->llr_layers); + //---------------------------------------------------------- //------------------- ULSCH unscrambling ------------------- //---------------------------------------------------------- @@ -380,13 +392,13 @@ void nr_fill_indication(PHY_VARS_gNB *gNB, int frame, int slot_rx, int ULSCH_id, pthread_mutex_lock(&gNB->UL_INFO_mutex); - NR_gNB_ULSCH_t *ulsch = gNB->ulsch[ULSCH_id][0]; + NR_gNB_ULSCH_t *ulsch = gNB->ulsch[ULSCH_id]; NR_UL_gNB_HARQ_t *harq_process = ulsch->harq_processes[harq_pid]; NR_gNB_SCH_STATS_t *stats=get_ulsch_stats(gNB,ulsch); nfapi_nr_pusch_pdu_t *pusch_pdu = &harq_process->ulsch_pdu; - // pdu->data = gNB->ulsch[ULSCH_id+1][0]->harq_processes[harq_pid]->b; + // pdu->data = gNB->ulsch[ULSCH_id+1]->harq_processes[harq_pid]->b; int sync_pos = nr_est_timing_advance_pusch(gNB, ULSCH_id); // estimate timing advance for MAC // scale the 16 factor in N_TA calculation in 38.213 section 4.2 according to the used FFT size @@ -423,7 +435,7 @@ void nr_fill_indication(PHY_VARS_gNB *gNB, int frame, int slot_rx, int ULSCH_id, int SNRtimes10 = dB_fixed_x10(gNB->pusch_vars[ULSCH_id]->ulsch_power_tot) - dB_fixed_x10(gNB->pusch_vars[ULSCH_id]->ulsch_noise_power_tot); - LOG_D(PHY, "Estimated SNR for PUSCH is = %f dB (ulsch_power %f, noise %f)\n", SNRtimes10/10.0,dB_fixed_x10(gNB->pusch_vars[ULSCH_id]->ulsch_power_tot)/10.0,dB_fixed_x10(gNB->pusch_vars[ULSCH_id]->ulsch_noise_power_tot)/10.0); + LOG_D(PHY, "%d.%d: Estimated SNR for PUSCH is = %f dB (ulsch_power %f, noise %f) delay %d\n", frame, slot_rx, SNRtimes10/10.0,dB_fixed_x10(gNB->pusch_vars[ULSCH_id]->ulsch_power_tot)/10.0,dB_fixed_x10(gNB->pusch_vars[ULSCH_id]->ulsch_noise_power_tot)/10.0,sync_pos); int cqi; if (SNRtimes10 < -640) cqi=0; @@ -550,7 +562,7 @@ void fill_ul_rb_mask(PHY_VARS_gNB *gNB, int frame_rx, int slot_rx) { } for (int ULSCH_id=0;ULSCH_idnumber_of_nr_ulsch_max;ULSCH_id++) { - NR_gNB_ULSCH_t *ulsch = gNB->ulsch[ULSCH_id][0]; + NR_gNB_ULSCH_t *ulsch = gNB->ulsch[ULSCH_id]; int harq_pid; NR_UL_gNB_HARQ_t *ulsch_harq; if ((ulsch) && @@ -694,6 +706,7 @@ int phy_procedures_gNB_uespec_RX(PHY_VARS_gNB *gNB, int frame_rx, int slot_rx) { gNB->uci_pdu_list[num_ucis].pdu_size = sizeof(nfapi_nr_uci_pucch_pdu_format_2_3_4_t); nfapi_nr_uci_pucch_pdu_format_2_3_4_t *uci_pdu_format2 = &gNB->uci_pdu_list[num_ucis].pucch_pdu_format_2_3_4; + LOG_D(PHY,"%d.%d Calling nr_decode_pucch2\n",frame_rx,slot_rx); nr_decode_pucch2(gNB, slot_rx, uci_pdu_format2, @@ -710,7 +723,7 @@ int phy_procedures_gNB_uespec_RX(PHY_VARS_gNB *gNB, int frame_rx, int slot_rx) { } for (int ULSCH_id=0;ULSCH_idnumber_of_nr_ulsch_max;ULSCH_id++) { - NR_gNB_ULSCH_t *ulsch = gNB->ulsch[ULSCH_id][0]; + NR_gNB_ULSCH_t *ulsch = gNB->ulsch[ULSCH_id]; int harq_pid; int no_sig; NR_UL_gNB_HARQ_t *ulsch_harq; @@ -785,12 +798,23 @@ int phy_procedures_gNB_uespec_RX(PHY_VARS_gNB *gNB, int frame_rx, int slot_rx) { dB_fixed_x10(gNB->pusch_vars[ULSCH_id]->ulsch_power_tot), dB_fixed_x10(gNB->pusch_vars[ULSCH_id]->ulsch_noise_power_tot),gNB->pusch_thres); gNB->pusch_vars[ULSCH_id]->ulsch_power_tot = gNB->pusch_vars[ULSCH_id]->ulsch_noise_power_tot; - nr_fill_indication(gNB,frame_rx, slot_rx, ULSCH_id, harq_pid, 1,1); gNB->pusch_vars[ULSCH_id]->DTX=1; if (stats) stats->DTX++; - return 1; - } else gNB->pusch_vars[ULSCH_id]->DTX=0; + if (!get_softmodem_params()->phy_test) { + /* in case of phy_test mode, we still want to decode to measure execution time. + Therefore, we don't yet call nr_fill_indication, it will be called later */ + nr_fill_indication(gNB,frame_rx, slot_rx, ULSCH_id, harq_pid, 1,1); + return 1; + } + } else { + LOG_D(PHY, "PUSCH detected in %d.%d (%d,%d,%d)\n",frame_rx,slot_rx, + dB_fixed_x10(gNB->pusch_vars[ULSCH_id]->ulsch_power_tot), + dB_fixed_x10(gNB->pusch_vars[ULSCH_id]->ulsch_noise_power_tot),gNB->pusch_thres); + gNB->pusch_vars[ULSCH_id]->DTX=0; + } + stop_meas(&gNB->rx_pusch_stats); + VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_NR_RX_PUSCH,0); //LOG_M("rxdataF_comp.m","rxF_comp",gNB->pusch_vars[0]->rxdataF_comp[0],6900,1,1); //LOG_M("rxdataF_ext.m","rxF_ext",gNB->pusch_vars[0]->rxdataF_ext[0],6900,1,1); VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_NR_ULSCH_PROCEDURES_RX,1); @@ -839,10 +863,6 @@ int phy_procedures_gNB_uespec_RX(PHY_VARS_gNB *gNB, int frame_rx, int slot_rx) { } stop_meas(&gNB->phy_proc_rx); - // figure out a better way to choose slot_rx, 19 is ok for a particular TDD configuration with 30kHz SCS - if ((frame_rx&127) == 0 && slot_rx==19) { - LOG_I(NR_PHY, "Number of bad PUCCH received: %lu\n", gNB->bad_pucch); - } if (pucch_decode_done || pusch_decode_done) { T(T_GNB_PHY_PUCCH_PUSCH_IQ, T_INT(frame_rx), T_INT(slot_rx), T_BUFFER(&gNB->common_vars.rxdataF[0][0], gNB->frame_parms.symbols_per_slot * gNB->frame_parms.ofdm_symbol_size * 4)); diff --git a/openair1/SCHED_NR_UE/defs.h b/openair1/SCHED_NR_UE/defs.h index c362bb470f..7672aee8a2 100644 --- a/openair1/SCHED_NR_UE/defs.h +++ b/openair1/SCHED_NR_UE/defs.h @@ -82,6 +82,11 @@ #define DAQ_AGC_OFF 0 +typedef struct { + uint8_t decoded_output[64]; + uint8_t xtra_byte; +} fapiPbch_t; + /** @addtogroup _PHY_PROCEDURES_ * @{ */ @@ -111,16 +116,18 @@ int phy_procedures_RN_UE_RX(unsigned char last_slot, unsigned char next_slot, re void phy_procedures_nrUE_TX(PHY_VARS_NR_UE *ue, UE_nr_rxtx_proc_t *proc, uint8_t eNB_id); /*! \brief Scheduling for UE RX procedures in normal subframes. - @param ue Pointer to UE variables on which to act - @param proc Pointer to proc information - @param gNB_id Local id of eNB on which to act - @param dlsch_parallel use multithreaded dlsch processing - @param txFifo Result fifo if PDSCH is run in parallel + @param ue Pointer to UE variables on which to act + @param proc Pointer to proc information + @param gNB_id Local id of eNB on which to act + @param dlsch_parallel use multithreaded dlsch processing + @param phy_pdcch_config PDCCH Config for this slot + @param txFifo Result fifo if PDSCH is run in parallel */ int phy_procedures_nrUE_RX(PHY_VARS_NR_UE *ue, UE_nr_rxtx_proc_t *proc, uint8_t gNB_id, uint8_t dlsch_parallel, + NR_UE_PDCCH_CONFIG *phy_pdcch_config, notifiedFIFO_t *txFifo); int phy_procedures_slot_parallelization_nrUE_RX(PHY_VARS_NR_UE *ue, UE_nr_rxtx_proc_t *proc, uint8_t eNB_id, uint8_t abstraction_flag, uint8_t do_pdcch_flag, relaying_type_t r_type); @@ -366,6 +373,7 @@ int get_tx_harq_id(NR_UE_ULSCH_t *ulsch, int slot_tx); int is_pbch_in_slot(fapi_nr_config_request_t *config, int frame, int slot, NR_DL_FRAME_PARMS *fp); int is_ssb_in_slot(fapi_nr_config_request_t *config, int frame, int slot, NR_DL_FRAME_PARMS *fp); +bool is_csi_rs_in_symbol(fapi_nr_dl_config_csirs_pdu_rel15_t csirs_config_pdu, int symbol); /*! \brief This function prepares the dl indication to pass to the MAC @param @@ -378,7 +386,8 @@ void nr_fill_dl_indication(nr_downlink_indication_t *dl_ind, fapi_nr_rx_indication_t *rx_ind, UE_nr_rxtx_proc_t *proc, PHY_VARS_NR_UE *ue, - uint8_t gNB_id); + uint8_t gNB_id, + void *phy_data); /*@}*/ @@ -395,7 +404,8 @@ void nr_fill_rx_indication(fapi_nr_rx_indication_t *rx_ind, NR_UE_DLSCH_t *dlsch0, NR_UE_DLSCH_t *dlsch1, uint16_t n_pdus, - UE_nr_rxtx_proc_t *proc); + UE_nr_rxtx_proc_t *proc, + void * typeSpecific); bool nr_ue_dlsch_procedures(PHY_VARS_NR_UE *ue, UE_nr_rxtx_proc_t *proc, @@ -411,10 +421,16 @@ int nr_ue_pdsch_procedures(PHY_VARS_NR_UE *ue, NR_UE_DLSCH_t *dlsch0, NR_UE_DLSCH_t *dlsch1); int nr_ue_pdcch_procedures(uint8_t gNB_id, - PHY_VARS_NR_UE *ue, - UE_nr_rxtx_proc_t *proc, + PHY_VARS_NR_UE *ue, + UE_nr_rxtx_proc_t *proc, + int32_t pdcch_est_size, + int32_t pdcch_dl_ch_estimates[][pdcch_est_size], + NR_UE_PDCCH_CONFIG *phy_pdcch_config, int n_ss); +int nr_ue_csi_im_procedures(PHY_VARS_NR_UE *ue, UE_nr_rxtx_proc_t *proc, uint8_t gNB_id); + +int nr_ue_csi_rs_procedures(PHY_VARS_NR_UE *ue, UE_nr_rxtx_proc_t *proc, uint8_t gNB_id); #endif diff --git a/openair1/SCHED_NR_UE/fapi_nr_ue_l1.c b/openair1/SCHED_NR_UE/fapi_nr_ue_l1.c index 8af91b1f38..046f67a7d0 100644 --- a/openair1/SCHED_NR_UE/fapi_nr_ue_l1.c +++ b/openair1/SCHED_NR_UE/fapi_nr_ue_l1.c @@ -36,21 +36,78 @@ #include "fapi_nr_ue_l1.h" #include "harq_nr.h" //#include "PHY/phy_vars_nr_ue.h" - +#include "openair2/NR_UE_PHY_INTERFACE/NR_IF_Module.h" #include "PHY/defs_nr_UE.h" #include "PHY/impl_defs_nr.h" #include "utils.h" +#include "openair2/PHY_INTERFACE/queue_t.h" extern PHY_VARS_NR_UE ***PHY_vars_UE_g; -const char *dl_pdu_type[]={"DCI", "DLSCH", "RA_DLSCH", "SI_DLSCH", "P_DLSCH"}; +const char *dl_pdu_type[]={"DCI", "DLSCH", "RA_DLSCH", "SI_DLSCH", "P_DLSCH", "CSI_RS", "CSI_IM"}; const char *ul_pdu_type[]={"PRACH", "PUCCH", "PUSCH", "SRS"}; queue_t nr_rx_ind_queue; queue_t nr_crc_ind_queue; queue_t nr_uci_ind_queue; -int8_t nr_ue_scheduled_response_stub(nr_scheduled_response_t *scheduled_response) { +static void fill_uci_2_3_4(nfapi_nr_uci_pucch_pdu_format_2_3_4_t *pdu_2_3_4, + fapi_nr_ul_config_pucch_pdu *pucch_pdu) +{ + memset(pdu_2_3_4, 0, sizeof(*pdu_2_3_4)); + pdu_2_3_4->handle = 0; + pdu_2_3_4->rnti = pucch_pdu->rnti; + pdu_2_3_4->pucch_format = 2; + pdu_2_3_4->ul_cqi = 255; + pdu_2_3_4->timing_advance = 0; + pdu_2_3_4->rssi = 0; + // TODO: Eventually check 38.212:Sect.631 to know when to use csi_part2, for now only using csi_part1 + pdu_2_3_4->pduBitmap = 4; + pdu_2_3_4->csi_part1.csi_part1_bit_len = pucch_pdu->nr_of_symbols; + int csi_part1_byte_len = (int)((pdu_2_3_4->csi_part1.csi_part1_bit_len / 8) + 1); + AssertFatal(!pdu_2_3_4->csi_part1.csi_part1_payload, "pdu_2_3_4->csi_part1.csi_part1_payload != NULL\n"); + pdu_2_3_4->csi_part1.csi_part1_payload = CALLOC(csi_part1_byte_len, + sizeof(pdu_2_3_4->csi_part1.csi_part1_payload)); + for (int k = 0; k < csi_part1_byte_len; k++) + { + pdu_2_3_4->csi_part1.csi_part1_payload[k] = (pucch_pdu->payload >> (k * 8)) & 0xff; + } + pdu_2_3_4->csi_part1.csi_part1_crc = 0; +} +static void free_uci_inds(nfapi_nr_uci_indication_t *uci_ind) +{ + for (int k = 0; k < uci_ind->num_ucis; k++) + { + if (uci_ind->uci_list[k].pdu_type == NFAPI_NR_UCI_FORMAT_0_1_PDU_TYPE) + { + nfapi_nr_uci_pucch_pdu_format_0_1_t *pdu_0_1 = &uci_ind->uci_list[k].pucch_pdu_format_0_1; + free(pdu_0_1->sr); + pdu_0_1->sr = NULL; + if (pdu_0_1->harq) + { + free(pdu_0_1->harq->harq_list); + pdu_0_1->harq->harq_list = NULL; + } + free(pdu_0_1->harq); + pdu_0_1->harq = NULL; + } + if (uci_ind->uci_list[k].pdu_type == NFAPI_NR_UCI_FORMAT_2_3_4_PDU_TYPE) + { + nfapi_nr_uci_pucch_pdu_format_2_3_4_t *pdu_2_3_4 = &uci_ind->uci_list[k].pucch_pdu_format_2_3_4; + free(pdu_2_3_4->sr.sr_payload); + pdu_2_3_4->sr.sr_payload = NULL; + free(pdu_2_3_4->harq.harq_payload); + pdu_2_3_4->harq.harq_payload = NULL; + } + } + free(uci_ind->uci_list); + uci_ind->uci_list = NULL; + free(uci_ind); + uci_ind = NULL; +} + +int8_t nr_ue_scheduled_response_stub(nr_scheduled_response_t *scheduled_response) { + NR_UE_MAC_INST_t *mac = get_mac_inst(0); if(scheduled_response != NULL) { if (scheduled_response->ul_config != NULL) @@ -60,7 +117,7 @@ int8_t nr_ue_scheduled_response_stub(nr_scheduled_response_t *scheduled_response "Too many ul_config pdus %d", ul_config->number_pdus); for (int i = 0; i < ul_config->number_pdus; ++i) { - LOG_I(PHY, "In %s: processing type %d PDU of %d total UL PDUs (ul_config %p) \n", + LOG_D(NR_PHY, "In %s: processing type %d PDU of %d total UL PDUs (ul_config %p) \n", __FUNCTION__, ul_config->ul_config_list[i].pdu_type, ul_config->number_pdus, ul_config); uint8_t pdu_type = ul_config->ul_config_list[i].pdu_type; @@ -95,10 +152,6 @@ int8_t nr_ue_scheduled_response_stub(nr_scheduled_response_t *scheduled_response abstracting L1. */ rx_ind->pdu_list[j].timing_advance = 31; rx_ind->pdu_list[j].ul_cqi = 255; - char buffer[1024]; - hexdump(rx_ind->pdu_list[j].pdu, rx_ind->pdu_list[j].pdu_length, buffer, sizeof(buffer)); - LOG_D(NR_MAC, "Hexdump of pdu %s before queuing rx_ind\n", - buffer); } crc_ind->header.message_id = NFAPI_NR_PHY_MSG_TYPE_CRC_INDICATION; @@ -118,6 +171,11 @@ int8_t nr_ue_scheduled_response_stub(nr_scheduled_response_t *scheduled_response crc_ind->crc_list[j].tb_crc_status = 0; crc_ind->crc_list[j].timing_advance = 31; crc_ind->crc_list[j].ul_cqi = 255; + AssertFatal(mac->nr_ue_emul_l1.harq[crc_ind->crc_list[j].harq_id].active_ul_harq_sfn_slot == -1, + "We did not send an active CRC when we should have!\n"); + mac->nr_ue_emul_l1.harq[crc_ind->crc_list[j].harq_id].active_ul_harq_sfn_slot = NFAPI_SFNSLOT2HEX(crc_ind->sfn, crc_ind->slot); + LOG_D(NR_MAC, "This is sched sfn/sl [%d %d] and crc sfn/sl [%d %d] with mcs_index in ul_cqi -> %d\n", + scheduled_response->frame, scheduled_response->slot, crc_ind->sfn, crc_ind->slot,pusch_config_pdu->mcs_index); } if (!put_queue(&nr_rx_ind_queue, rx_ind)) @@ -150,28 +208,7 @@ int8_t nr_ue_scheduled_response_stub(nr_scheduled_response_t *scheduled_response break; } - default: - LOG_I(NR_MAC, "Unknown ul_config->pdu_type %d\n", pdu_type); - break; - } - } - scheduled_response->ul_config->number_pdus = 0; - } - - if (scheduled_response->dl_config != NULL) - { - fapi_nr_dl_config_request_t *dl_config = scheduled_response->dl_config; - AssertFatal(dl_config->number_pdus < sizeof(dl_config->dl_config_list) / sizeof(dl_config->dl_config_list[0]), - "Too many dl_config pdus %d", dl_config->number_pdus); - for (int i = 0; i < dl_config->number_pdus; ++i) - { - LOG_D(PHY, "In %s: processing %s PDU of %d total DL PDUs (dl_config %p) \n", - __FUNCTION__, dl_pdu_type[dl_config->dl_config_list[i].pdu_type - 1], dl_config->number_pdus, dl_config); - - uint8_t pdu_type = dl_config->dl_config_list[i].pdu_type; - switch (pdu_type) - { - case (FAPI_NR_DL_CONFIG_TYPE_DLSCH): + case FAPI_NR_UL_CONFIG_TYPE_PUCCH: { nfapi_nr_uci_indication_t *uci_ind = CALLOC(1, sizeof(*uci_ind)); uci_ind->header.message_id = NFAPI_NR_PHY_MSG_TYPE_UCI_INDICATION; @@ -181,35 +218,70 @@ int8_t nr_ue_scheduled_response_stub(nr_scheduled_response_t *scheduled_response uci_ind->uci_list = CALLOC(uci_ind->num_ucis, sizeof(*uci_ind->uci_list)); for (int j = 0; j < uci_ind->num_ucis; j++) { - nfapi_nr_uci_pucch_pdu_format_0_1_t *pdu_0_1 = &uci_ind->uci_list[j].pucch_pdu_format_0_1; - uci_ind->uci_list[j].pdu_type = NFAPI_NR_UCI_FORMAT_0_1_PDU_TYPE; - uci_ind->uci_list[j].pdu_size = sizeof(nfapi_nr_uci_pucch_pdu_format_0_1_t); - memset(pdu_0_1, 0, sizeof(*pdu_0_1)); - pdu_0_1->handle = 0; - pdu_0_1->rnti = dl_config->dl_config_list[i].dlsch_config_pdu.rnti; - pdu_0_1->pucch_format = 1; - pdu_0_1->ul_cqi = 255; - pdu_0_1->timing_advance = 0; - pdu_0_1->rssi = 0; + LOG_D(NR_MAC, "ul_config->ul_config_list[%d].pucch_config_pdu.n_bit = %d\n", i, ul_config->ul_config_list[i].pucch_config_pdu.n_bit); + if (ul_config->ul_config_list[i].pucch_config_pdu.n_bit > 3 && mac->nr_ue_emul_l1.num_csi_reports > 0) + { + uci_ind->uci_list[j].pdu_type = NFAPI_NR_UCI_FORMAT_2_3_4_PDU_TYPE; + uci_ind->uci_list[j].pdu_size = sizeof(nfapi_nr_uci_pucch_pdu_format_2_3_4_t); + nfapi_nr_uci_pucch_pdu_format_2_3_4_t *pdu_2_3_4 = &uci_ind->uci_list[j].pucch_pdu_format_2_3_4; + fill_uci_2_3_4(pdu_2_3_4, &ul_config->ul_config_list[i].pucch_config_pdu); + } + else + { + nfapi_nr_uci_pucch_pdu_format_0_1_t *pdu_0_1 = &uci_ind->uci_list[j].pucch_pdu_format_0_1; + uci_ind->uci_list[j].pdu_type = NFAPI_NR_UCI_FORMAT_0_1_PDU_TYPE; + uci_ind->uci_list[j].pdu_size = sizeof(nfapi_nr_uci_pucch_pdu_format_0_1_t); + memset(pdu_0_1, 0, sizeof(*pdu_0_1)); + pdu_0_1->handle = 0; + pdu_0_1->rnti = ul_config->ul_config_list[i].pucch_config_pdu.rnti; + pdu_0_1->pucch_format = 1; + pdu_0_1->ul_cqi = 255; + pdu_0_1->timing_advance = 0; + pdu_0_1->rssi = 0; + + if (mac->nr_ue_emul_l1.num_harqs > 0) { + int harq_index = 0; + pdu_0_1->pduBitmap = 2; // (value->pduBitmap >> 1) & 0x01) == HARQ and (value->pduBitmap) & 0x01) == SR + pdu_0_1->harq = CALLOC(1, sizeof(*pdu_0_1->harq)); + pdu_0_1->harq->num_harq = mac->nr_ue_emul_l1.num_harqs; + pdu_0_1->harq->harq_confidence_level = 0; + pdu_0_1->harq->harq_list = CALLOC(pdu_0_1->harq->num_harq, sizeof(*pdu_0_1->harq->harq_list)); + int harq_pid = -1; + for (int k = 0; k < NR_MAX_HARQ_PROCESSES; k++) + { + if (mac->nr_ue_emul_l1.harq[k].active && + mac->nr_ue_emul_l1.harq[k].active_dl_harq_sfn == uci_ind->sfn && + mac->nr_ue_emul_l1.harq[k].active_dl_harq_slot == uci_ind->slot) + { + mac->nr_ue_emul_l1.harq[k].active = false; + harq_pid = k; + AssertFatal(harq_index < pdu_0_1->harq->num_harq, "Invalid harq_index %d\n", harq_index); + pdu_0_1->harq->harq_list[harq_index].harq_value = !mac->dl_harq_info[k].ack; + harq_index++; + } + } + AssertFatal(harq_pid != -1, "No active harq_pid, sfn_slot = %u.%u", uci_ind->sfn, uci_ind->slot); + } + } } - LOG_I(NR_PHY, "In %s: Filled queue uci_ind which was filled by dlconfig.\n" - "uci_num %d, SFN/SLOT: [%d, %d]\n", - __FUNCTION__, uci_ind->num_ucis, uci_ind->sfn, uci_ind->slot); - - if (!put_queue(&nr_uci_ind_queue, uci_ind)) - { - LOG_E(NR_MAC, "Put_queue failed for uci_ind\n"); - free(uci_ind->uci_list); - free(uci_ind); - } + LOG_D(NR_PHY, "Sending UCI with %d PDUs in sfn.slot %d/%d\n", + uci_ind->num_ucis, uci_ind->sfn, uci_ind->slot); + NR_UL_IND_t ul_info = { + .uci_ind = *uci_ind, + }; + send_nsa_standalone_msg(&ul_info, uci_ind->header.message_id); + free_uci_inds(uci_ind); break; } + + default: + LOG_W(NR_MAC, "Unknown ul_config->pdu_type %d\n", pdu_type); + break; } } - dl_config->number_pdus = 0; + scheduled_response->ul_config->number_pdus = 0; } - } return 0; } @@ -243,6 +315,12 @@ void configure_dlsch(NR_UE_DLSCH_t *dlsch0, dlsch0_harq->mcs = dlsch_config_pdu->mcs; dlsch0_harq->rvidx = dlsch_config_pdu->rv; dlsch0->g_pucch = dlsch_config_pdu->accumulated_delta_PUCCH; + dlsch0_harq->R = dlsch_config_pdu->targetCodeRate; + dlsch0_harq->Qm = dlsch_config_pdu->qamModOrder; + dlsch0_harq->TBS = dlsch_config_pdu->TBS; + dlsch0_harq->tbslbrm = dlsch_config_pdu->tbslbrm; + dlsch0_harq->nscid = dlsch_config_pdu->nscid; + dlsch0_harq->dlDmrsScramblingId = dlsch_config_pdu->dlDmrsScramblingId; //get nrOfLayers from DCI info uint8_t Nl = 0; for (int i = 0; i < 12; i++) { // max 12 ports @@ -267,6 +345,7 @@ void configure_dlsch(NR_UE_DLSCH_t *dlsch0, LOG_D(MAC, ">>>> \tdlsch0->g_pucch = %d\tdlsch0_harq.mcs = %d\n", dlsch0->g_pucch, dlsch0_harq->mcs); } + int8_t nr_ue_scheduled_response(nr_scheduled_response_t *scheduled_response){ bool found = false; @@ -279,15 +358,18 @@ int8_t nr_ue_scheduled_response(nr_scheduled_response_t *scheduled_response){ // Note: we have to handle the thread IDs for this. To be revisited completely. thread_id = scheduled_response->thread_id; NR_UE_DLSCH_t *dlsch0 = NULL; - NR_UE_PDCCH *pdcch_vars = PHY_vars_UE_g[module_id][cc_id]->pdcch_vars[thread_id][0]; - NR_UE_ULSCH_t *ulsch0 = PHY_vars_UE_g[module_id][cc_id]->ulsch[thread_id][0][0]; + NR_UE_ULSCH_t *ulsch = PHY_vars_UE_g[module_id][cc_id]->ulsch[thread_id][0]; NR_UE_PUCCH *pucch_vars = PHY_vars_UE_g[module_id][cc_id]->pucch_vars[thread_id][0]; + NR_UE_CSI_IM *csiim_vars = PHY_vars_UE_g[module_id][cc_id]->csiim_vars[0]; + NR_UE_CSI_RS *csirs_vars = PHY_vars_UE_g[module_id][cc_id]->csirs_vars[0]; + NR_UE_PDCCH_CONFIG *phy_pdcch_config = NULL; if(scheduled_response->dl_config != NULL){ fapi_nr_dl_config_request_t *dl_config = scheduled_response->dl_config; fapi_nr_dl_config_dlsch_pdu_rel15_t *dlsch_config_pdu; fapi_nr_dl_config_dci_dl_pdu_rel15_t *pdcch_config; - pdcch_vars->nb_search_space = 0; + fapi_nr_dl_config_csiim_pdu_rel15_t *csiim_config_pdu; + fapi_nr_dl_config_csirs_pdu_rel15_t *csirs_config_pdu; for (int i = 0; i < dl_config->number_pdus; ++i){ AssertFatal(dl_config->number_pdus < FAPI_NR_DL_CONFIG_LIST_NUM,"dl_config->number_pdus %d out of bounds\n",dl_config->number_pdus); @@ -297,18 +379,26 @@ int8_t nr_ue_scheduled_response(nr_scheduled_response_t *scheduled_response){ switch(dl_config->dl_config_list[i].pdu_type) { case FAPI_NR_DL_CONFIG_TYPE_DCI: + if (NULL == phy_pdcch_config) { + phy_pdcch_config = (NR_UE_PDCCH_CONFIG *)scheduled_response->phy_data; + phy_pdcch_config->nb_search_space = 0; + } pdcch_config = &dl_config->dl_config_list[i].dci_config_pdu.dci_config_rel15; - memcpy(&pdcch_vars->pdcch_config[pdcch_vars->nb_search_space],pdcch_config,sizeof(*pdcch_config)); - pdcch_vars->nb_search_space = pdcch_vars->nb_search_space + 1; - pdcch_vars->sfn = scheduled_response->frame; - pdcch_vars->slot = slot; - LOG_D(PHY,"Number of DCI SearchSpaces %d\n",pdcch_vars->nb_search_space); + memcpy((void*)&phy_pdcch_config->pdcch_config[phy_pdcch_config->nb_search_space],(void*)pdcch_config,sizeof(*pdcch_config)); + phy_pdcch_config->nb_search_space = phy_pdcch_config->nb_search_space + 1; + phy_pdcch_config->sfn = scheduled_response->frame; + phy_pdcch_config->slot = slot; + LOG_D(PHY,"Number of DCI SearchSpaces %d\n",phy_pdcch_config->nb_search_space); break; case FAPI_NR_DL_CONFIG_TYPE_CSI_IM: - LOG_I(PHY,"Received CSI-IM PDU at FAPI\n"); + csiim_config_pdu = &dl_config->dl_config_list[i].csiim_config_pdu.csiim_config_rel15; + memcpy((void*)&(csiim_vars->csiim_config_pdu), (void*)csiim_config_pdu, sizeof(fapi_nr_dl_config_csiim_pdu_rel15_t)); + csirs_vars->active = true; break; case FAPI_NR_DL_CONFIG_TYPE_CSI_RS: - LOG_I(PHY,"Received CSI-RS PDU at FAPI\n"); + csirs_config_pdu = &dl_config->dl_config_list[i].csirs_config_pdu.csirs_config_rel15; + memcpy((void*)&(csirs_vars->csirs_config_pdu), (void*)csirs_config_pdu, sizeof(fapi_nr_dl_config_csirs_pdu_rel15_t)); + csirs_vars->active = true; break; case FAPI_NR_DL_CONFIG_TYPE_RA_DLSCH: dlsch_config_pdu = &dl_config->dl_config_list[i].dlsch_config_pdu.dlsch_config_rel15; @@ -347,7 +437,7 @@ int8_t nr_ue_scheduled_response(nr_scheduled_response_t *scheduled_response){ for (int i = 0; i < ul_config->number_pdus; ++i){ AssertFatal(ul_config->ul_config_list[i].pdu_type <= FAPI_NR_UL_CONFIG_TYPES,"pdu_type %d out of bounds\n",ul_config->ul_config_list[i].pdu_type); - LOG_D(PHY, "In %s: processing %s PDU of %d total UL PDUs (ul_config %p) \n", __FUNCTION__, ul_pdu_type[ul_config->ul_config_list[i].pdu_type - 1], ul_config->number_pdus, ul_config); + LOG_D(PHY, "In %s i %d: processing %s PDU of %d total UL PDUs (ul_config %p) \n", __FUNCTION__, i, ul_pdu_type[ul_config->ul_config_list[i].pdu_type - 1], ul_config->number_pdus, ul_config); uint8_t pdu_type = ul_config->ul_config_list[i].pdu_type, current_harq_pid, gNB_id = 0; /* PRACH */ @@ -367,16 +457,17 @@ int8_t nr_ue_scheduled_response(nr_scheduled_response_t *scheduled_response){ // pusch config pdu pusch_config_pdu = &ul_config->ul_config_list[i].pusch_config_pdu; current_harq_pid = pusch_config_pdu->pusch_data.harq_process_id; - NR_UL_UE_HARQ_t *harq_process_ul_ue = ulsch0->harq_processes[current_harq_pid]; - harq_process_ul_ue->status = 0; + NR_UL_UE_HARQ_t *harq_process_ul_ue = ulsch->harq_processes[current_harq_pid]; if (harq_process_ul_ue){ nfapi_nr_ue_pusch_pdu_t *pusch_pdu = &harq_process_ul_ue->pusch_pdu; + + LOG_D(PHY, "In %s i %d: copy pusch_config_pdu nrOfLayers:%d, num_dmrs_cdm_grps_no_data:%d \n", __FUNCTION__, i, pusch_config_pdu->nrOfLayers,pusch_config_pdu->num_dmrs_cdm_grps_no_data); memcpy(pusch_pdu, pusch_config_pdu, sizeof(nfapi_nr_ue_pusch_pdu_t)); - ulsch0->f_pusch = pusch_config_pdu->absolute_delta_PUSCH; + ulsch->f_pusch = pusch_config_pdu->absolute_delta_PUSCH; if (scheduled_response->tx_request) { for (int j=0; jtx_request->number_of_pdus; j++) { @@ -384,15 +475,16 @@ int8_t nr_ue_scheduled_response(nr_scheduled_response_t *scheduled_response){ if ((tx_req_body->pdu_index == i) && (tx_req_body->pdu_length > 0)) { LOG_D(PHY,"%d.%d Copying %d bytes to harq_process_ul_ue->a (harq_pid %d)\n",scheduled_response->frame,slot,tx_req_body->pdu_length,current_harq_pid); memcpy(harq_process_ul_ue->a, tx_req_body->pdu, tx_req_body->pdu_length); - harq_process_ul_ue->status = ACTIVE; - ul_config->ul_config_list[i].pdu_type = FAPI_NR_UL_CONFIG_TYPE_DONE; // not handle it any more - pdu_done++; - LOG_D(PHY, "%d.%d ul A ul_config %p t %d pdu_done %d number_pdus %d\n", scheduled_response->frame, slot, ul_config, pdu_type, pdu_done, ul_config->number_pdus); break; } } } + harq_process_ul_ue->status = ACTIVE; + ul_config->ul_config_list[i].pdu_type = FAPI_NR_UL_CONFIG_TYPE_DONE; // not handle it any more + pdu_done++; + LOG_D(PHY, "%d.%d ul A ul_config %p t %d pdu_done %d number_pdus %d\n", scheduled_response->frame, slot, ul_config, pdu_type, pdu_done, ul_config->number_pdus); + } else { LOG_E(PHY, "[phy_procedures_nrUE_TX] harq_process_ul_ue is NULL !!\n"); diff --git a/openair1/SCHED_NR_UE/harq_nr.c b/openair1/SCHED_NR_UE/harq_nr.c index 4d92509d48..a9ff01d78a 100644 --- a/openair1/SCHED_NR_UE/harq_nr.c +++ b/openair1/SCHED_NR_UE/harq_nr.c @@ -123,7 +123,7 @@ void config_uplink_harq_process(PHY_VARS_NR_UE *ue, int gNB_id, int thread_id, i memset(ulsch,0,sizeof(NR_UE_ULSCH_t)); - ue->ulsch[thread_id][gNB_id][code_word_idx] = ulsch; + ue->ulsch[thread_id][gNB_id] = ulsch; } else { LOG_E(PHY, "Fatal memory allocation problem at line %d in function %s of file %s \n", __LINE__ , __func__, __FILE__); @@ -148,7 +148,7 @@ void config_uplink_harq_process(PHY_VARS_NR_UE *ue, int gNB_id, int thread_id, i } for (int slot_tx = 0; slot_tx < NR_MAX_SLOTS_PER_FRAME; slot_tx++) { - ue->ulsch[thread_id][gNB_id][code_word_idx]->harq_process_id[slot_tx] = NR_MAX_HARQ_PROCESSES; + ue->ulsch[thread_id][gNB_id]->harq_process_id[slot_tx] = NR_MAX_HARQ_PROCESSES; } } @@ -167,7 +167,7 @@ void config_uplink_harq_process(PHY_VARS_NR_UE *ue, int gNB_id, int thread_id, i void release_uplink_harq_process(PHY_VARS_NR_UE *ue, int gNB_id, int thread_id, int code_word_idx) { - NR_UE_ULSCH_t *ulsch = ue->ulsch[thread_id][gNB_id][code_word_idx]; + NR_UE_ULSCH_t *ulsch = ue->ulsch[thread_id][gNB_id]; for (int process_id = 0; process_id < ulsch->number_harq_processes_for_pusch; process_id++) { @@ -178,7 +178,7 @@ void release_uplink_harq_process(PHY_VARS_NR_UE *ue, int gNB_id, int thread_id, free16(ulsch, sizeof(NR_UE_ULSCH_t)); - ue->ulsch[thread_id][gNB_id][code_word_idx] = NULL; + ue->ulsch[thread_id][gNB_id] = NULL; } /******************************************************************* @@ -307,7 +307,7 @@ void init_downlink_harq_status(NR_DL_UE_HARQ_t *dl_harq) { dl_harq->status = SCH_IDLE; dl_harq->first_rx = 1; - dl_harq->round = 0; + dl_harq->DLround = 0; dl_harq->DCINdi = 1; dl_harq->ack = DL_ACKNACK_NO_SET; } @@ -334,60 +334,38 @@ void downlink_harq_process(NR_DL_UE_HARQ_t *dl_harq, int harq_pid, int ndi, int if (rnti_type == _SI_RNTI_ || rnti_type == _P_RNTI_ || rnti_type == _RA_RNTI_) { - dl_harq->round = 0; + dl_harq->DLround = 0; dl_harq->status = ACTIVE; dl_harq->first_rx = 1; - } - else{ - switch(rv){ - case 0: - dl_harq->round = 0; - dl_harq->status = ACTIVE; - dl_harq->first_rx = 1; - if (dl_harq->DCINdi == ndi) - LOG_E(PHY,"Warning! rv %d indicates new transmission but new ndi %d is the same as old ndi %d\n",rv,ndi,dl_harq->DCINdi); - dl_harq->DCINdi = ndi; - break; - case 1: - dl_harq->round = 3; - dl_harq->status = ACTIVE; - dl_harq->first_rx = 0; - if (dl_harq->DCINdi != ndi) { - LOG_E(PHY,"Missed previous DCI detections. NDI toggled but rv %d does not correspond to first reception\n",rv); - dl_harq->first_rx = 1; - dl_harq->DCINdi = ndi; - } - else if (dl_harq->ack == 1) - dl_harq->status = SCH_IDLE; - break; - case 2: - dl_harq->round = 1; - dl_harq->status = ACTIVE; - dl_harq->first_rx = 0; - if (dl_harq->DCINdi != ndi) { - LOG_E(PHY,"Missed previous DCI detections. NDI toggled but rv %d does not correspond to first reception\n",rv); - dl_harq->first_rx = 1; - dl_harq->DCINdi = ndi; - } - else if (dl_harq->ack == 1) - dl_harq->status = SCH_IDLE; - break; - case 3: - dl_harq->round = 2; - dl_harq->status = ACTIVE; - dl_harq->first_rx = 0; - if (dl_harq->DCINdi != ndi) { - LOG_E(PHY,"Missed previous DCI detections. NDI toggled but rv %d does not correspond to first reception\n",rv); - dl_harq->first_rx = 1; - dl_harq->DCINdi = ndi; - } - else if (dl_harq->ack == 1) - dl_harq->status = SCH_IDLE; - break; - default: - AssertFatal(1==0,"Invalid value for rv %d\n",rv); + } else { + LOG_D(PHY,"receive harq process: %p harqPid=%d, rv=%d, ndi=%d, rntiType=%d new transmission= %s\n", + dl_harq, harq_pid, rv, ndi, rnti_type, dl_harq->DCINdi != ndi ? "yes":"no"); + AssertFatal(rv<4 && rv>=0, "invalid redondancy version %d\n", rv); + + if (ndi!=dl_harq->DCINdi) { + if (dl_harq->ack == DL_NACK) + LOG_D(PHY,"New transmission on a harq pid (%d) never acknowledged\n", harq_pid); + else + LOG_D(PHY,"Starting new transmission on a harq pid (%d)\n", harq_pid); + } else { + if (dl_harq->ack != DL_NACK) + LOG_D(PHY,"gNB asked for retransmission even if we sent ACK\n"); + else + LOG_D(PHY,"Starting retransmission on a harq pid (%d), rv (%d)\n", harq_pid, rv); } - } + if (ndi!=dl_harq->DCINdi) { + dl_harq->first_rx = true; + dl_harq->DLround = 0; + } else { + dl_harq->first_rx = false; + dl_harq->DLround++; + } + + dl_harq->status = ACTIVE; + + dl_harq->DCINdi = ndi; + //dl_harq->status = SCH_IDLE; + } } diff --git a/openair1/SCHED_NR_UE/phy_procedures_nr_ue.c b/openair1/SCHED_NR_UE/phy_procedures_nr_ue.c index 0d284de71c..d366ae9ec1 100644 --- a/openair1/SCHED_NR_UE/phy_procedures_nr_ue.c +++ b/openair1/SCHED_NR_UE/phy_procedures_nr_ue.c @@ -36,6 +36,7 @@ #include "assertions.h" #include "defs.h" #include "PHY/defs_nr_UE.h" +#include "PHY/NR_REFSIG/dmrs_nr.h" #include "PHY/phy_extern_nr_ue.h" #include "PHY/MODULATION/modulation_UE.h" #include "PHY/NR_UE_TRANSPORT/nr_transport_ue.h" @@ -87,7 +88,8 @@ void nr_fill_dl_indication(nr_downlink_indication_t *dl_ind, fapi_nr_rx_indication_t *rx_ind, UE_nr_rxtx_proc_t *proc, PHY_VARS_NR_UE *ue, - uint8_t gNB_id){ + uint8_t gNB_id, + void *phy_data){ memset((void*)dl_ind, 0, sizeof(nr_downlink_indication_t)); @@ -97,6 +99,7 @@ void nr_fill_dl_indication(nr_downlink_indication_t *dl_ind, dl_ind->frame = proc->frame_rx; dl_ind->slot = proc->nr_slot_rx; dl_ind->thread_id = proc->thread_id; + dl_ind->phy_data = phy_data; if (dci_ind) { @@ -118,7 +121,8 @@ void nr_fill_rx_indication(fapi_nr_rx_indication_t *rx_ind, NR_UE_DLSCH_t *dlsch0, NR_UE_DLSCH_t *dlsch1, uint16_t n_pdus, - UE_nr_rxtx_proc_t *proc ){ + UE_nr_rxtx_proc_t *proc, + void * typeSpecific){ NR_DL_FRAME_PARMS *frame_parms = &ue->frame_parms; @@ -131,7 +135,6 @@ void nr_fill_rx_indication(fapi_nr_rx_indication_t *rx_ind, trace_NRpdu(DIRECTION_DOWNLINK, dlsch0->harq_processes[dlsch0->current_harq_pid]->b, dlsch0->harq_processes[dlsch0->current_harq_pid]->TBS / 8, - pdu_type, WS_C_RNTI, dlsch0->rnti, proc->frame_rx, @@ -162,8 +165,11 @@ void nr_fill_rx_indication(fapi_nr_rx_indication_t *rx_ind, rx_ind->rx_indication_body[n_pdus - 1].pdsch_pdu.pdu_length = dlsch0->harq_processes[dlsch0->current_harq_pid]->TBS / 8; break; case FAPI_NR_RX_PDU_TYPE_SSB: - rx_ind->rx_indication_body[n_pdus - 1].ssb_pdu.pdu = ue->pbch_vars[gNB_id]->decoded_output; - rx_ind->rx_indication_body[n_pdus - 1].ssb_pdu.additional_bits = ue->pbch_vars[gNB_id]->xtra_byte; + rx_ind->rx_indication_body[n_pdus - 1].ssb_pdu.pdu=malloc(sizeof(((fapiPbch_t*)typeSpecific)->decoded_output)); + memcpy(rx_ind->rx_indication_body[n_pdus - 1].ssb_pdu.pdu, + ((fapiPbch_t*)typeSpecific)->decoded_output, + sizeof(((fapiPbch_t*)typeSpecific)->decoded_output)); + rx_ind->rx_indication_body[n_pdus - 1].ssb_pdu.additional_bits = ((fapiPbch_t*)typeSpecific)->xtra_byte; rx_ind->rx_indication_body[n_pdus - 1].ssb_pdu.ssb_index = (frame_parms->ssb_index)&0x7; rx_ind->rx_indication_body[n_pdus - 1].ssb_pdu.ssb_length = frame_parms->Lmax; rx_ind->rx_indication_body[n_pdus - 1].ssb_pdu.cell_id = frame_parms->Nid_cell; @@ -278,15 +284,17 @@ void phy_procedures_nrUE_TX(PHY_VARS_NR_UE *ue, VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_PHY_PROCEDURES_UE_TX,VCD_FUNCTION_IN); - memset(ue->common_vars.txdataF[0], 0, sizeof(int)*14*ue->frame_parms.ofdm_symbol_size); + for(int i=0; i< ue->frame_parms.nb_antennas_tx; ++i) + memset(ue->common_vars.txdataF[i], 0, sizeof(int)*14*ue->frame_parms.ofdm_symbol_size); LOG_D(PHY,"****** start TX-Chain for AbsSubframe %d.%d ******\n", frame_tx, slot_tx); start_meas(&ue->phy_proc_tx); if (ue->UE_mode[gNB_id] <= PUSCH){ - for (uint8_t harq_pid = 0; harq_pid < ue->ulsch[proc->thread_id][gNB_id][0]->number_harq_processes_for_pusch; harq_pid++) { - if (ue->ulsch[proc->thread_id][gNB_id][0]->harq_processes[harq_pid]->status == ACTIVE) + + for (uint8_t harq_pid = 0; harq_pid < ue->ulsch[proc->thread_id][gNB_id]->number_harq_processes_for_pusch; harq_pid++) { + if (ue->ulsch[proc->thread_id][gNB_id]->harq_processes[harq_pid]->status == ACTIVE) nr_ue_ulsch_procedures(ue, harq_pid, frame_tx, slot_tx, proc->thread_id, gNB_id); } } @@ -353,10 +361,9 @@ void nr_ue_measurement_procedures(uint16_t l, VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_UE_MEASUREMENT_PROCEDURES, VCD_FUNCTION_OUT); } -void nr_ue_pbch_procedures(uint8_t gNB_id, +static void nr_ue_pbch_procedures(uint8_t gNB_id, PHY_VARS_NR_UE *ue, - UE_nr_rxtx_proc_t *proc, - uint8_t abstraction_flag) + UE_nr_rxtx_proc_t *proc,int estimateSz, struct complex16 dl_ch_estimates[][estimateSz], NR_UE_PDCCH_CONFIG *phy_pdcch_config) { int ret = 0; @@ -368,13 +375,16 @@ void nr_ue_pbch_procedures(uint8_t gNB_id, VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_UE_PBCH_PROCEDURES, VCD_FUNCTION_IN); LOG_D(PHY,"[UE %d] Frame %d Slot %d, Trying PBCH (NidCell %d, gNB_id %d)\n",ue->Mod_id,frame_rx,nr_slot_rx,ue->frame_parms.Nid_cell,gNB_id); - + fapiPbch_t result; ret = nr_rx_pbch(ue, proc, + estimateSz, dl_ch_estimates, ue->pbch_vars[gNB_id], &ue->frame_parms, gNB_id, (ue->frame_parms.ssb_index)&7, - SISO); + SISO, + phy_pdcch_config, + &result); if (ret==0) { @@ -444,7 +454,6 @@ void nr_ue_pbch_procedures(uint8_t gNB_id, } if (frame_rx % 100 == 0) { - ue->pbch_vars[gNB_id]->pdu_fer = ue->pbch_vars[gNB_id]->pdu_errors - ue->pbch_vars[gNB_id]->pdu_errors_last; ue->pbch_vars[gNB_id]->pdu_errors_last = ue->pbch_vars[gNB_id]->pdu_errors; } @@ -481,6 +490,9 @@ unsigned int nr_get_tx_amp(int power_dBm, int power_max_dBm, int N_RB_UL, int nb int nr_ue_pdcch_procedures(uint8_t gNB_id, PHY_VARS_NR_UE *ue, UE_nr_rxtx_proc_t *proc, + int32_t pdcch_est_size, + int32_t pdcch_dl_ch_estimates[][pdcch_est_size], + NR_UE_PDCCH_CONFIG *phy_pdcch_config, int n_ss) { int frame_rx = proc->frame_rx; @@ -489,13 +501,16 @@ int nr_ue_pdcch_procedures(uint8_t gNB_id, fapi_nr_dci_indication_t *dci_ind = calloc(1, sizeof(*dci_ind)); nr_downlink_indication_t dl_indication; - NR_UE_PDCCH *pdcch_vars = ue->pdcch_vars[proc->thread_id][gNB_id]; - fapi_nr_dl_config_dci_dl_pdu_rel15_t *rel15 = &pdcch_vars->pdcch_config[n_ss]; + fapi_nr_dl_config_dci_dl_pdu_rel15_t *rel15 = &phy_pdcch_config->pdcch_config[n_ss]; start_meas(&ue->dlsch_rx_pdcch_stats); + /// PDCCH/DCI e-sequence (input to rate matching). + int32_t pdcch_e_rx_size = NR_MAX_PDCCH_SIZE; + int16_t pdcch_e_rx[pdcch_e_rx_size]; + VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_RX_PDCCH, VCD_FUNCTION_IN); - nr_rx_pdcch(ue, proc, rel15); + nr_rx_pdcch(ue, proc, pdcch_est_size, pdcch_dl_ch_estimates, pdcch_e_rx, rel15); VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_RX_PDCCH, VCD_FUNCTION_OUT); @@ -506,7 +521,7 @@ int nr_ue_pdcch_procedures(uint8_t gNB_id, n_ss); #endif - dci_cnt = nr_dci_decoding_procedure(ue, proc, dci_ind, rel15); + dci_cnt = nr_dci_decoding_procedure(ue, proc, pdcch_e_rx, dci_ind, rel15, phy_pdcch_config); #ifdef NR_PDCCH_SCHED_DEBUG LOG_I(PHY,"<-NR_PDCCH_PHY_PROCEDURES_LTE_UE (nr_ue_pdcch_procedures)-> Ending function nr_dci_decoding_procedure() -> dci_cnt=%u\n",dci_cnt); @@ -526,11 +541,13 @@ int nr_ue_pdcch_procedures(uint8_t gNB_id, ue->pdcch_vars[proc->thread_id][gNB_id]->dci_received += dci_cnt; dci_ind->number_of_dcis = dci_cnt; + // fill dl_indication message - nr_fill_dl_indication(&dl_indication, dci_ind, NULL, proc, ue, gNB_id); + nr_fill_dl_indication(&dl_indication, dci_ind, NULL, proc, ue, gNB_id, phy_pdcch_config); // send to mac ue->if_inst->dl_indication(&dl_indication, NULL); + stop_meas(&ue->dlsch_rx_pdcch_stats); VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_UE_PDCCH_PROCEDURES, VCD_FUNCTION_OUT); @@ -575,6 +592,8 @@ int nr_ue_pdsch_procedures(PHY_VARS_NR_UE *ue, UE_nr_rxtx_proc_t *proc, int gNB_ nr_slot_rx, get_dmrs_port(aatx,dlsch0_harq->dmrs_ports), m, + dlsch0_harq->nscid, + dlsch0_harq->dlDmrsScramblingId, BWPStart, dlsch0_harq->dmrsConfigType, ue->frame_parms.first_carrier_offset+(BWPStart + pdsch_start_rb)*12, @@ -593,6 +612,15 @@ int nr_ue_pdsch_procedures(PHY_VARS_NR_UE *ue, UE_nr_rxtx_proc_t *proc, int gNB_ } } + if (ue->chest_time == 1) { // averaging time domain channel estimates + nr_chest_time_domain_avg(&ue->frame_parms, + ue->pdsch_vars[proc->thread_id][gNB_id]->dl_ch_estimates, + dlsch0_harq->nb_symbols, + dlsch0_harq->start_symbol, + dlsch0_harq->dlDmrsSymbPos, + pdsch_nb_rb); + } + uint16_t first_symbol_with_data = s0; uint32_t dmrs_data_re; @@ -783,8 +811,7 @@ bool nr_ue_dlsch_procedures(PHY_VARS_NR_UE *ue, nb_symb_sch, nr_slot_rx, harq_pid, - pdsch==PDSCH?1:0, - dlsch0->harq_processes[harq_pid]->TBS>256?1:0); + pdsch==PDSCH); LOG_T(PHY,"dlsch decoding, ret = %d\n", ret); @@ -794,17 +821,17 @@ bool nr_ue_dlsch_procedures(PHY_VARS_NR_UE *ue, switch (pdsch) { case RA_PDSCH: - nr_fill_dl_indication(&dl_indication, NULL, rx_ind, proc, ue, gNB_id); - nr_fill_rx_indication(rx_ind, FAPI_NR_RX_PDU_TYPE_RAR, gNB_id, ue, dlsch0, NULL, number_pdus, proc); + nr_fill_dl_indication(&dl_indication, NULL, rx_ind, proc, ue, gNB_id, NULL); + nr_fill_rx_indication(rx_ind, FAPI_NR_RX_PDU_TYPE_RAR, gNB_id, ue, dlsch0, NULL, number_pdus, proc, NULL); ue->UE_mode[gNB_id] = RA_RESPONSE; break; case PDSCH: - nr_fill_dl_indication(&dl_indication, NULL, rx_ind, proc, ue, gNB_id); - nr_fill_rx_indication(rx_ind, FAPI_NR_RX_PDU_TYPE_DLSCH, gNB_id, ue, dlsch0, NULL, number_pdus, proc); + nr_fill_dl_indication(&dl_indication, NULL, rx_ind, proc, ue, gNB_id, NULL); + nr_fill_rx_indication(rx_ind, FAPI_NR_RX_PDU_TYPE_DLSCH, gNB_id, ue, dlsch0, NULL, number_pdus, proc, NULL); break; case SI_PDSCH: - nr_fill_dl_indication(&dl_indication, NULL, rx_ind, proc, ue, gNB_id); - nr_fill_rx_indication(rx_ind, FAPI_NR_RX_PDU_TYPE_SIB, gNB_id, ue, dlsch0, NULL, number_pdus, proc); + nr_fill_dl_indication(&dl_indication, NULL, rx_ind, proc, ue, gNB_id, NULL); + nr_fill_rx_indication(rx_ind, FAPI_NR_RX_PDU_TYPE_SIB, gNB_id, ue, dlsch0, NULL, number_pdus, proc, NULL); break; default: break; @@ -860,8 +887,7 @@ bool nr_ue_dlsch_procedures(PHY_VARS_NR_UE *ue, nb_symb_sch, nr_slot_rx, harq_pid, - pdsch==PDSCH?1:0,//proc->decoder_switch, - dlsch1->harq_processes[harq_pid]->TBS>256?1:0); + pdsch==PDSCH);//proc->decoder_switch LOG_T(PHY,"CW dlsch decoding, ret1 = %d\n", ret1); stop_meas(&ue->dlsch_decoding_stats[proc->thread_id]); @@ -900,21 +926,25 @@ bool nr_ue_dlsch_procedures(PHY_VARS_NR_UE *ue, const double N_TA_max = Ta_max * bw_scaling * tc_factor; NR_UE_MAC_INST_t *mac = get_mac_inst(0); + NR_BWP_Id_t dl_bwp = mac->DL_BWP_Id; + NR_BWP_Id_t ul_bwp = mac->UL_BWP_Id; NR_PUSCH_TimeDomainResourceAllocationList_t *pusch_TimeDomainAllocationList = NULL; - if (mac->ULbwp[0] && - mac->ULbwp[0]->bwp_Dedicated && - mac->ULbwp[0]->bwp_Dedicated->pusch_Config && - mac->ULbwp[0]->bwp_Dedicated->pusch_Config->choice.setup && - mac->ULbwp[0]->bwp_Dedicated->pusch_Config->choice.setup->pusch_TimeDomainAllocationList) { - pusch_TimeDomainAllocationList = mac->ULbwp[0]->bwp_Dedicated->pusch_Config->choice.setup->pusch_TimeDomainAllocationList->choice.setup; - } - else if (mac->ULbwp[0] && - mac->ULbwp[0]->bwp_Common && - mac->ULbwp[0]->bwp_Common->pusch_ConfigCommon && - mac->ULbwp[0]->bwp_Common->pusch_ConfigCommon->choice.setup && - mac->ULbwp[0]->bwp_Common->pusch_ConfigCommon->choice.setup->pusch_TimeDomainAllocationList) { - pusch_TimeDomainAllocationList = mac->ULbwp[0]->bwp_Common->pusch_ConfigCommon->choice.setup->pusch_TimeDomainAllocationList; + if(ul_bwp){ + if (mac->ULbwp[ul_bwp-1] && + mac->ULbwp[ul_bwp-1]->bwp_Dedicated && + mac->ULbwp[ul_bwp-1]->bwp_Dedicated->pusch_Config && + mac->ULbwp[ul_bwp-1]->bwp_Dedicated->pusch_Config->choice.setup && + mac->ULbwp[ul_bwp-1]->bwp_Dedicated->pusch_Config->choice.setup->pusch_TimeDomainAllocationList) { + pusch_TimeDomainAllocationList = mac->ULbwp[ul_bwp-1]->bwp_Dedicated->pusch_Config->choice.setup->pusch_TimeDomainAllocationList->choice.setup; + } + else if (mac->ULbwp[ul_bwp-1] && + mac->ULbwp[ul_bwp-1]->bwp_Common && + mac->ULbwp[ul_bwp-1]->bwp_Common->pusch_ConfigCommon && + mac->ULbwp[ul_bwp-1]->bwp_Common->pusch_ConfigCommon->choice.setup && + mac->ULbwp[ul_bwp-1]->bwp_Common->pusch_ConfigCommon->choice.setup->pusch_TimeDomainAllocationList) { + pusch_TimeDomainAllocationList = mac->ULbwp[ul_bwp-1]->bwp_Common->pusch_ConfigCommon->choice.setup->pusch_TimeDomainAllocationList; + } } else if (mac->scc_SIB && mac->scc_SIB->uplinkConfigCommon && @@ -925,12 +955,15 @@ bool nr_ue_dlsch_procedures(PHY_VARS_NR_UE *ue, } long mapping_type_ul = pusch_TimeDomainAllocationList ? pusch_TimeDomainAllocationList->list.array[0]->mappingType : NR_PUSCH_TimeDomainResourceAllocation__mappingType_typeA; - NR_PDSCH_Config_t *pdsch_Config = (mac->DLbwp[0] && mac->DLbwp[0]->bwp_Dedicated->pdsch_Config->choice.setup) ? mac->DLbwp[0]->bwp_Dedicated->pdsch_Config->choice.setup : NULL; + NR_PDSCH_Config_t *pdsch_Config = NULL; NR_PDSCH_TimeDomainResourceAllocationList_t *pdsch_TimeDomainAllocationList = NULL; - if (mac->DLbwp[0] && mac->DLbwp[0]->bwp_Dedicated->pdsch_Config->choice.setup->pdsch_TimeDomainAllocationList) - pdsch_TimeDomainAllocationList = pdsch_Config->pdsch_TimeDomainAllocationList->choice.setup; - else if (mac->DLbwp[0] && mac->DLbwp[0]->bwp_Common->pdsch_ConfigCommon->choice.setup->pdsch_TimeDomainAllocationList) - pdsch_TimeDomainAllocationList = mac->DLbwp[0]->bwp_Common->pdsch_ConfigCommon->choice.setup->pdsch_TimeDomainAllocationList; + if(dl_bwp){ + pdsch_Config = (mac->DLbwp[dl_bwp-1] && mac->DLbwp[dl_bwp-1]->bwp_Dedicated->pdsch_Config->choice.setup) ? mac->DLbwp[dl_bwp-1]->bwp_Dedicated->pdsch_Config->choice.setup : NULL; + if (mac->DLbwp[dl_bwp-1] && mac->DLbwp[dl_bwp-1]->bwp_Dedicated->pdsch_Config->choice.setup->pdsch_TimeDomainAllocationList) + pdsch_TimeDomainAllocationList = pdsch_Config->pdsch_TimeDomainAllocationList->choice.setup; + else if (mac->DLbwp[dl_bwp-1] && mac->DLbwp[dl_bwp-1]->bwp_Common->pdsch_ConfigCommon->choice.setup->pdsch_TimeDomainAllocationList) + pdsch_TimeDomainAllocationList = mac->DLbwp[dl_bwp-1]->bwp_Common->pdsch_ConfigCommon->choice.setup->pdsch_TimeDomainAllocationList; + } else if (mac->scc_SIB && mac->scc_SIB->downlinkConfigCommon.initialDownlinkBWP.pdsch_ConfigCommon->choice.setup) pdsch_TimeDomainAllocationList = mac->scc_SIB->downlinkConfigCommon.initialDownlinkBWP.pdsch_ConfigCommon->choice.setup->pdsch_TimeDomainAllocationList; long mapping_type_dl = pdsch_TimeDomainAllocationList ? pdsch_TimeDomainAllocationList->list.array[0]->mappingType : NR_PDSCH_TimeDomainResourceAllocation__mappingType_typeA; @@ -984,7 +1017,7 @@ bool nr_ue_dlsch_procedures(PHY_VARS_NR_UE *ue, d_2_1 = 1; /* d_2_2 */ - const double d_2_2 = 0.0; // set to 0 because there is only 1 BWP: TODO this should corresponds to the switching time as defined in TS 38.133 + const double d_2_2 = pusch_d_2_2_timing_capability_1[numerology][1]; /* N_t_1 time duration in msec of N_1 symbols corresponding to a PDSCH reception time // N_t_2 time duration in msec of N_2 symbols corresponding to a PUSCH preparation time */ @@ -1356,11 +1389,11 @@ int is_pbch_in_slot(fapi_nr_config_request_t *config, int frame, int slot, NR_DL } } - int phy_procedures_nrUE_RX(PHY_VARS_NR_UE *ue, UE_nr_rxtx_proc_t *proc, uint8_t gNB_id, uint8_t dlsch_parallel, + NR_UE_PDCCH_CONFIG *phy_pdcch_config, notifiedFIFO_t *txFifo ) { @@ -1368,10 +1401,9 @@ int phy_procedures_nrUE_RX(PHY_VARS_NR_UE *ue, int nr_slot_rx = proc->nr_slot_rx; int slot_pbch; int slot_ssb; - NR_UE_PDCCH *pdcch_vars = ue->pdcch_vars[proc->thread_id][0]; fapi_nr_config_request_t *cfg = &ue->nrUE_config; - uint8_t nb_symb_pdcch = pdcch_vars->nb_search_space > 0 ? pdcch_vars->pdcch_config[0].coreset.duration : 0; + uint8_t nb_symb_pdcch = phy_pdcch_config->nb_search_space > 0 ? phy_pdcch_config->pdcch_config[0].coreset.duration : 0; uint8_t dci_cnt = 0; NR_DL_FRAME_PARMS *fp = &ue->frame_parms; @@ -1390,8 +1422,8 @@ int phy_procedures_nrUE_RX(PHY_VARS_NR_UE *ue, int coreset_nb_rb=0; int coreset_start_rb=0; - if (pdcch_vars->nb_search_space > 0) - get_coreset_rballoc(pdcch_vars->pdcch_config[0].coreset.frequency_domain_resource,&coreset_nb_rb,&coreset_start_rb); + if (phy_pdcch_config->nb_search_space > 0) + get_coreset_rballoc(phy_pdcch_config->pdcch_config[0].coreset.frequency_domain_resource,&coreset_nb_rb,&coreset_start_rb); slot_pbch = is_pbch_in_slot(cfg, frame_rx, nr_slot_rx, fp); slot_ssb = is_ssb_in_slot(cfg, frame_rx, nr_slot_rx, fp); @@ -1400,6 +1432,11 @@ int phy_procedures_nrUE_RX(PHY_VARS_NR_UE *ue, if (slot_ssb) { VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_UE_SLOT_FEP_PBCH, VCD_FUNCTION_IN); LOG_D(PHY," ------ PBCH ChannelComp/LLR: frame.slot %d.%d ------ \n", frame_rx%1024, nr_slot_rx); + + const int estimateSz = fp->symbols_per_slot * fp->ofdm_symbol_size; + __attribute__ ((aligned(32))) struct complex16 dl_ch_estimates[fp->nb_antennas_rx][estimateSz]; + __attribute__ ((aligned(32))) struct complex16 dl_ch_estimates_time[fp->nb_antennas_rx][fp->ofdm_symbol_size]; + for (int i=1; i<4; i++) { nr_slot_fep(ue, @@ -1407,9 +1444,8 @@ int phy_procedures_nrUE_RX(PHY_VARS_NR_UE *ue, (ue->symbol_offset+i)%(fp->symbols_per_slot), nr_slot_rx); - start_meas(&ue->dlsch_channel_estimation_stats); - nr_pbch_channel_estimation(ue,proc,gNB_id,nr_slot_rx,(ue->symbol_offset+i)%(fp->symbols_per_slot),i-1,(fp->ssb_index)&7,fp->half_frame_bit); + nr_pbch_channel_estimation(ue, estimateSz, dl_ch_estimates, dl_ch_estimates_time,proc,gNB_id,nr_slot_rx,(ue->symbol_offset+i)%(fp->symbols_per_slot),i-1,(fp->ssb_index)&7,fp->half_frame_bit); stop_meas(&ue->dlsch_channel_estimation_stats); } @@ -1418,13 +1454,15 @@ int phy_procedures_nrUE_RX(PHY_VARS_NR_UE *ue, if ((ue->decode_MIB == 1) && slot_pbch) { LOG_D(PHY," ------ Decode MIB: frame.slot %d.%d ------ \n", frame_rx%1024, nr_slot_rx); - nr_ue_pbch_procedures(gNB_id, ue, proc, 0); + nr_ue_pbch_procedures(gNB_id, ue, proc, estimateSz, dl_ch_estimates, phy_pdcch_config); if (ue->no_timing_correction==0) { LOG_D(PHY,"start adjust sync slot = %d no timing %d\n", nr_slot_rx, ue->no_timing_correction); nr_adjust_synch_ue(fp, ue, gNB_id, + fp->ofdm_symbol_size, + dl_ch_estimates_time, frame_rx, nr_slot_rx, 0, @@ -1457,13 +1495,17 @@ int phy_procedures_nrUE_RX(PHY_VARS_NR_UE *ue, nr_slot_rx); } + // Hold the channel estimates in frequency domain. + int32_t pdcch_est_size = ((((fp->symbols_per_slot*(fp->ofdm_symbol_size+LTE_CE_FILTER_LENGTH))+15)/16)*16); + __attribute__ ((aligned(16))) int32_t pdcch_dl_ch_estimates[4*fp->nb_antennas_rx][pdcch_est_size]; + dci_cnt = 0; - for(int n_ss = 0; n_ssnb_search_space; n_ss++) { + for(int n_ss = 0; n_ssnb_search_space; n_ss++) { for (uint16_t l=0; lfirst_carrier_offset, pdcch_vars->pdcch_config[n_ss].BWPStart, coreset_start_rb, coreset_nb_rb); + fp->first_carrier_offset, phy_pdcch_config->pdcch_config[n_ss].BWPStart, coreset_start_rb, coreset_nb_rb); if (coreset_nb_rb > 0) nr_pdcch_channel_estimation(ue, @@ -1471,13 +1513,16 @@ int phy_procedures_nrUE_RX(PHY_VARS_NR_UE *ue, gNB_id, nr_slot_rx, l, - fp->first_carrier_offset+(pdcch_vars->pdcch_config[n_ss].BWPStart + coreset_start_rb)*12, - coreset_nb_rb); + phy_pdcch_config->pdcch_config[n_ss].coreset.pdcch_dmrs_scrambling_id, + fp->first_carrier_offset+(phy_pdcch_config->pdcch_config[n_ss].BWPStart + coreset_start_rb)*12, + coreset_nb_rb, + pdcch_est_size, + pdcch_dl_ch_estimates); stop_meas(&ue->ofdm_demod_stats); } - dci_cnt = dci_cnt + nr_ue_pdcch_procedures(gNB_id, ue, proc, n_ss); + dci_cnt = dci_cnt + nr_ue_pdcch_procedures(gNB_id, ue, proc, pdcch_est_size, pdcch_dl_ch_estimates, phy_pdcch_config, n_ss); } VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_UE_SLOT_FEP_PDCCH, VCD_FUNCTION_OUT); @@ -1619,13 +1664,17 @@ int phy_procedures_nrUE_RX(PHY_VARS_NR_UE *ue, start_meas(&ue->dlsch_procedures_stat[proc->thread_id]); + NR_UE_DLSCH_t *dlsch1 = NULL; + if (NR_MAX_NB_LAYERS>4) + dlsch1 = ue->dlsch[proc->thread_id][gNB_id][1]; + if (ret_pdsch >= 0) nr_ue_dlsch_procedures(ue, proc, gNB_id, PDSCH, ue->dlsch[proc->thread_id][gNB_id][0], - ue->dlsch[proc->thread_id][gNB_id][1], + dlsch1, &ue->dlsch_errors[gNB_id]); stop_meas(&ue->dlsch_procedures_stat[proc->thread_id]); @@ -1641,6 +1690,23 @@ int phy_procedures_nrUE_RX(PHY_VARS_NR_UE *ue, } + // do procedures for CSI-IM + if ((ue->csiim_vars[gNB_id]) && (ue->csiim_vars[gNB_id]->active == 1)) { + nr_ue_csi_im_procedures(ue, proc, gNB_id); + ue->csiim_vars[gNB_id]->active = 0; + } + + // do procedures for CSI-RS + if ((ue->csirs_vars[gNB_id]) && (ue->csirs_vars[gNB_id]->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)) { + nr_slot_fep(ue, proc, symb, nr_slot_rx); + } + } + nr_ue_csi_rs_procedures(ue, proc, gNB_id); + ue->csirs_vars[gNB_id]->active = 0; + } + start_meas(&ue->generic_stat); if (nr_slot_rx==9) { @@ -1788,7 +1854,7 @@ void nr_ue_prach_procedures(PHY_VARS_NR_UE *ue, UE_nr_rxtx_proc_t *proc, uint8_t VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_UE_GENERATE_PRACH, VCD_FUNCTION_IN); - prach_power = generate_nr_prach(ue, gNB_id, nr_slot_tx); + prach_power = generate_nr_prach(ue, gNB_id, frame_tx, nr_slot_tx); VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_UE_GENERATE_PRACH, VCD_FUNCTION_OUT); diff --git a/openair1/SCHED_NR_UE/phy_sch_processing_time.h b/openair1/SCHED_NR_UE/phy_sch_processing_time.h index 1962df22ee..81cc4496a2 100644 --- a/openair1/SCHED_NR_UE/phy_sch_processing_time.h +++ b/openair1/SCHED_NR_UE/phy_sch_processing_time.h @@ -106,4 +106,36 @@ float pusch_N_2_timing_capability_2[3][2] = { { 0, 5 }, { 1, 5.5 }, { 2, 11 }, -}; \ No newline at end of file +}; + +/* TS 38.133 Table 8.6.2-1: BWP switch delay capability 1 +// corresponding to the PUSCH preparation time d_2_2 [slots] +// where mu corresponds to the one of {mu_DL, mu_UL} +// resulting with the largest T_proc_2 +// where mu_DL is the SCS with which the PDCCH +// carrying the DCI scheduling the PUSCH was transmitted +// mu_UL is the SCS of the UL channel with which PUSCH to be transmitted +*/ +float pusch_d_2_2_timing_capability_1[4][2] = { +/* mu d_2_2 */ +{ 0, 1 }, +{ 1, 2 }, +{ 2, 3 }, +{ 3, 6 }, +}; + +/* TS 38.133 Table 8.6.2-1: BWP switch delay capability 2 +// corresponding to the PUSCH preparation time d_2_2 [slots] +// where mu corresponds to the one of {mu_DL, mu_UL} +// resulting with the largest T_proc_2 +// where mu_DL is the SCS with which the PDCCH +// carrying the DCI scheduling the PUSCH was transmitted +// mu_UL is the SCS of the UL channel with which PUSCH to be transmitted +*/ +float pusch_d_2_2_timing_capability_2[4][2] = { +/* mu d_2_2 */ +{ 0, 3 }, +{ 1, 5 }, +{ 2, 9 }, +{ 3, 18 }, +}; diff --git a/openair1/SCHED_UE/phy_procedures_lte_ue.c b/openair1/SCHED_UE/phy_procedures_lte_ue.c index 4635f2b741..aa0ff0db80 100644 --- a/openair1/SCHED_UE/phy_procedures_lte_ue.c +++ b/openair1/SCHED_UE/phy_procedures_lte_ue.c @@ -574,7 +574,7 @@ void get_cqipmiri_params(PHY_VARS_UE *ue, } } -PUCCH_FMT_t get_pucch_format(lte_frame_type_t frame_type, +PUCCH_FMT_t get_pucch_format(frame_type_t frame_type, lte_prefix_type_t cyclic_prefix_type, uint8_t SR_payload, uint8_t nb_cw, @@ -1150,20 +1150,14 @@ void ulsch_common_procedures(PHY_VARS_UE *ue, nsymb = (frame_parms->Ncp == 0) ? 14 : 12; - if (!IS_SOFTMODEM_BASICSIM) { - ulsch_start = (ue->rx_offset+subframe_tx*frame_parms->samples_per_tti- - ue->hw_timing_advance- - ue->timing_advance- - ue->N_TA_offset+5); + ulsch_start = ue->rx_offset + subframe_tx * frame_parms->samples_per_tti + - ue->hw_timing_advance - ue->timing_advance - ue->N_TA_offset + 5; - if(ulsch_start < 0) - ulsch_start = ulsch_start + (LTE_NUMBER_OF_SUBFRAMES_PER_FRAME*frame_parms->samples_per_tti); + if(ulsch_start < 0) + ulsch_start = ulsch_start + (LTE_NUMBER_OF_SUBFRAMES_PER_FRAME*frame_parms->samples_per_tti); - if (ulsch_start > (LTE_NUMBER_OF_SUBFRAMES_PER_FRAME*frame_parms->samples_per_tti)) - ulsch_start = ulsch_start % (LTE_NUMBER_OF_SUBFRAMES_PER_FRAME*frame_parms->samples_per_tti); - } else { //this is the simulators case - ulsch_start = (frame_parms->samples_per_tti*subframe_tx)-ue->N_TA_offset; //-ue->timing_advance; - } + if (ulsch_start > (LTE_NUMBER_OF_SUBFRAMES_PER_FRAME*frame_parms->samples_per_tti)) + ulsch_start = ulsch_start % (LTE_NUMBER_OF_SUBFRAMES_PER_FRAME*frame_parms->samples_per_tti); if (empty_subframe) { overflow = ulsch_start - 9*frame_parms->samples_per_tti; @@ -1181,8 +1175,7 @@ void ulsch_common_procedures(PHY_VARS_UE *ue, } for (aa=0; aanb_antennas_tx; aa++) { - int *Buff = IS_SOFTMODEM_BASICSIM ? &ue->common_vars.txdata[aa][ulsch_start] :dummy_tx_buffer; - + int *Buff = dummy_tx_buffer; if (frame_parms->Ncp == 1) { PHY_ofdm_mod(&ue->common_vars.txdataF[aa][subframe_tx*nsymb*frame_parms->ofdm_symbol_size], Buff, @@ -1202,41 +1195,33 @@ void ulsch_common_procedures(PHY_VARS_UE *ue, &ue->frame_parms); } - if (IS_SOFTMODEM_BASICSIM) { - apply_7_5_kHz(ue,&ue->common_vars.txdata[aa][ulsch_start],0); - apply_7_5_kHz(ue,&ue->common_vars.txdata[aa][ulsch_start],1); - } else { - apply_7_5_kHz(ue,dummy_tx_buffer,0); - apply_7_5_kHz(ue,dummy_tx_buffer,1); + apply_7_5_kHz(ue,dummy_tx_buffer,0); + apply_7_5_kHz(ue,dummy_tx_buffer,1); + + overflow = ulsch_start - 9*frame_parms->samples_per_tti; + + for (k=ulsch_start,l=0; ksamples_per_tti*LTE_NUMBER_OF_SUBFRAMES_PER_FRAME,ulsch_start+frame_parms->samples_per_tti); k++,l++) { + ((short *)ue->common_vars.txdata[aa])[2*k] = ((short *)dummy_tx_buffer)[2*l]; + ((short *)ue->common_vars.txdata[aa])[2*k+1] = ((short *)dummy_tx_buffer)[2*l+1]; } - if (!(IS_SOFTMODEM_BASICSIM) ) { - overflow = ulsch_start - 9*frame_parms->samples_per_tti; - - for (k=ulsch_start,l=0; ksamples_per_tti*LTE_NUMBER_OF_SUBFRAMES_PER_FRAME,ulsch_start+frame_parms->samples_per_tti); k++,l++) { - ((short *)ue->common_vars.txdata[aa])[2*k] = ((short *)dummy_tx_buffer)[2*l]; - ((short *)ue->common_vars.txdata[aa])[2*k+1] = ((short *)dummy_tx_buffer)[2*l+1]; - } - - for (k=0; kcommon_vars.txdata[aa])[2*k] = ((short *)dummy_tx_buffer)[2*l]; - ((short *)ue->common_vars.txdata[aa])[2*k+1] = ((short *)dummy_tx_buffer)[2*l+1]; - } + for (k=0; kcommon_vars.txdata[aa])[2*k] = ((short *)dummy_tx_buffer)[2*l]; + ((short *)ue->common_vars.txdata[aa])[2*k+1] = ((short *)dummy_tx_buffer)[2*l+1]; + } #if defined(EXMIMO) - // handle switch before 1st TX subframe, guarantee that the slot prior to transmission is switch on - for (k=ulsch_start - (frame_parms->samples_per_tti>>1) ; kcommon_vars.txdata[aa][k+frame_parms->samples_per_tti*LTE_NUMBER_OF_SUBFRAMES_PER_FRAME] &= 0xFFFEFFFE; - else if (k>(frame_parms->samples_per_tti*LTE_NUMBER_OF_SUBFRAMES_PER_FRAME)) - ue->common_vars.txdata[aa][k-frame_parms->samples_per_tti*LTE_NUMBER_OF_SUBFRAMES_PER_FRAME] &= 0xFFFEFFFE; - else - ue->common_vars.txdata[aa][k] &= 0xFFFEFFFE; - } - -#endif + // handle switch before 1st TX subframe, guarantee that the slot prior to transmission is switch on + for (k=ulsch_start - (frame_parms->samples_per_tti>>1) ; kcommon_vars.txdata[aa][k+frame_parms->samples_per_tti*LTE_NUMBER_OF_SUBFRAMES_PER_FRAME] &= 0xFFFEFFFE; + else if (k>(frame_parms->samples_per_tti*LTE_NUMBER_OF_SUBFRAMES_PER_FRAME)) + ue->common_vars.txdata[aa][k-frame_parms->samples_per_tti*LTE_NUMBER_OF_SUBFRAMES_PER_FRAME] &= 0xFFFEFFFE; + else + ue->common_vars.txdata[aa][k] &= 0xFFFEFFFE; } +#endif /* only for debug @@ -1314,14 +1299,7 @@ void ue_prach_procedures(PHY_VARS_UE *ue, ue->prach_resources[eNB_id]->ra_RNTI); ue->tx_total_RE[subframe_tx] = 96; - if (IS_SOFTMODEM_BASICSIM) { - ue->prach_vars[eNB_id]->amp = get_tx_amp(ue->tx_power_dBm[subframe_tx], - ue->tx_power_max_dBm, - ue->frame_parms.N_RB_UL, - 6); - } else { - ue->prach_vars[eNB_id]->amp = AMP; - } + ue->prach_vars[eNB_id]->amp = AMP; if ((mode == calib_prach_tx) && (((proc->frame_tx&0xfffe)%100)==0)) LOG_D(PHY,"[UE %d][RAPROC] Frame %d, Subframe %d : PRACH TX power %d dBm, amp %d\n", @@ -1688,14 +1666,10 @@ void ue_ulsch_uespec_procedures(PHY_VARS_UE *ue, ue->tx_total_RE[subframe_tx] = nb_rb*12; - if (IS_SOFTMODEM_BASICSIM) { - tx_amp = AMP; - } else { - tx_amp = get_tx_amp(ue->tx_power_dBm[subframe_tx], - ue->tx_power_max_dBm, - ue->frame_parms.N_RB_UL, - nb_rb); - } + tx_amp = get_tx_amp(ue->tx_power_dBm[subframe_tx], + ue->tx_power_max_dBm, + ue->frame_parms.N_RB_UL, + nb_rb); T(T_UE_PHY_PUSCH_TX_POWER, T_INT(eNB_id), T_INT(frame_tx%1024), T_INT(subframe_tx),T_INT(ue->tx_power_dBm[subframe_tx]), T_INT(tx_amp),T_INT(ue->ulsch[eNB_id]->f_pusch),T_INT(get_PL(Mod_id,0,eNB_id)),T_INT(nb_rb)); @@ -1765,17 +1739,13 @@ void ue_srs_procedures(PHY_VARS_UE *ue, Po_SRS = ue->tx_power_max_dBm; } - if (IS_SOFTMODEM_BASICSIM) { - tx_amp = AMP; + if (ue->mac_enabled==1) { + tx_amp = get_tx_amp(Po_SRS, + ue->tx_power_max_dBm, + ue->frame_parms.N_RB_UL, + nb_rb_srs); } else { - if (ue->mac_enabled==1) { - tx_amp = get_tx_amp(Po_SRS, - ue->tx_power_max_dBm, - ue->frame_parms.N_RB_UL, - nb_rb_srs); - } else { - tx_amp = AMP; - } + tx_amp = AMP; } LOG_D(PHY,"SRS PROC; TX_MAX_POWER %d, Po_SRS %d, NB_RB_UL %d, NB_RB_SRS %d TX_AMPL %d\n",ue->tx_power_max_dBm, @@ -2008,14 +1978,10 @@ void ue_pucch_procedures(PHY_VARS_UE *ue, ue->tx_power_dBm[subframe_tx] = Po_PUCCH; ue->tx_total_RE[subframe_tx] = 12; - if (IS_SOFTMODEM_BASICSIM) { - tx_amp = AMP; - } else { - tx_amp = get_tx_amp(Po_PUCCH, - ue->tx_power_max_dBm, - ue->frame_parms.N_RB_UL, - 1); - } + tx_amp = get_tx_amp(Po_PUCCH, + ue->tx_power_max_dBm, + ue->frame_parms.N_RB_UL, + 1); T(T_UE_PHY_PUCCH_TX_POWER, T_INT(eNB_id), T_INT(frame_tx%1024), T_INT(subframe_tx),T_INT(ue->tx_power_dBm[subframe_tx]), T_INT(tx_amp),T_INT(ue->dlsch[ue->current_thread_id[proc->subframe_rx]][eNB_id][0]->g_pucch),T_INT(get_PL(ue->Mod_id,ue->CC_id,eNB_id))); @@ -2089,14 +2055,10 @@ void ue_pucch_procedures(PHY_VARS_UE *ue, ue->tx_power_dBm[subframe_tx] = Po_PUCCH; ue->tx_total_RE[subframe_tx] = 12; - if (IS_SOFTMODEM_BASICSIM) { - tx_amp = AMP; - } else { - tx_amp = get_tx_amp(Po_PUCCH, - ue->tx_power_max_dBm, - ue->frame_parms.N_RB_UL, - 1); - } + tx_amp = get_tx_amp(Po_PUCCH, + ue->tx_power_max_dBm, + ue->frame_parms.N_RB_UL, + 1); T(T_UE_PHY_PUCCH_TX_POWER, T_INT(eNB_id), T_INT(frame_tx%1024), T_INT(subframe_tx),T_INT(ue->tx_power_dBm[subframe_tx]), T_INT(tx_amp),T_INT(ue->dlsch[ue->current_thread_id[proc->subframe_rx]][eNB_id][0]->g_pucch),T_INT(get_PL(ue->Mod_id,ue->CC_id,eNB_id))); @@ -2344,9 +2306,6 @@ void ue_measurement_procedures(uint16_t l, // symbol index of each slot [0..6 // AGC VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_UE_GAIN_CONTROL, VCD_FUNCTION_IN); - if (IS_SOFTMODEM_BASICSIM) - phy_adjust_gain (ue,dB_fixed(ue->measurements.rssi),0); - VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_UE_GAIN_CONTROL, VCD_FUNCTION_OUT); eNB_id = 0; @@ -4911,109 +4870,3 @@ int phy_procedures_UE_RX(PHY_VARS_UE *ue, LOG_D(PHY," ****** end RX-Chain for AbsSubframe %d.%d ****** \n", frame_rx%1024, subframe_rx); return (0); } - - -void phy_procedures_UE_lte(PHY_VARS_UE *ue, - UE_rxtx_proc_t *proc, - uint8_t eNB_id, - uint8_t abstraction_flag, - uint8_t do_pdcch_flag, - runmode_t mode) { - MessageDef *msg_p; - int result; - int frame_rx = proc->frame_rx; - int frame_tx = proc->frame_tx; - int subframe_rx = proc->subframe_rx; - int subframe_tx = proc->subframe_tx; - UE_L2_STATE_t ret; - int slot; - - if (ue->mac_enabled == 0) { - ue->UE_mode[eNB_id]=PUSCH; - } - - VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_PHY_PROCEDURES_UE_LTE,1); - - if ( LOG_DEBUGFLAG(UE_TIMING)) { - start_meas(&ue->phy_proc[ue->current_thread_id[subframe_rx]]); - } - do { - // Checks if a message has been sent to PHY sub-task - itti_poll_msg (TASK_PHY_UE, &msg_p); - - if (msg_p != NULL) { - switch (ITTI_MSG_ID(msg_p)) { - case PHY_FIND_CELL_REQ: - LOG_I(PHY, "[UE ] Received %s\n", ITTI_MSG_NAME (msg_p)); - /* TODO process the message */ - break; - - default: - LOG_E(PHY, "[UE %ld] Received unexpected message %s\n", ITTI_MSG_DESTINATION_INSTANCE (msg_p), ITTI_MSG_NAME (msg_p)); - break; - } - - result = itti_free (ITTI_MSG_ORIGIN_ID(msg_p), msg_p); - AssertFatal (result == EXIT_SUCCESS, "Failed to free memory (%d)!\n", result); - } - } while(msg_p != NULL); - - for (slot=0; slot<2; slot++) { - if ((subframe_select(&ue->frame_parms,subframe_tx)==SF_UL)|| - (ue->frame_parms.frame_type == FDD)) { - phy_procedures_UE_TX(ue,proc,eNB_id,abstraction_flag,mode); - } - - if ((subframe_select(&ue->frame_parms,subframe_rx)==SF_DL) || - (ue->frame_parms.frame_type == FDD)) { - phy_procedures_UE_RX(ue,proc,eNB_id,abstraction_flag,do_pdcch_flag,mode); - } - - if ((subframe_select(&ue->frame_parms,subframe_tx)==SF_S) && - (slot==1)) { - phy_procedures_UE_S_TX(ue,eNB_id,abstraction_flag); - } - - if ((subframe_select(&ue->frame_parms,subframe_rx)==SF_S) && - (slot==0)) { - phy_procedures_UE_RX(ue,proc,eNB_id,abstraction_flag,do_pdcch_flag,mode); - } - - if (ue->mac_enabled==1) { - if (slot==0) { - //LOG_I(PHY,"[UE %d] Frame %d, subframe %d, star ue_scheduler\n", ue->Mod_id,frame_rx,subframe_tx); - ret = ue_scheduler(ue->Mod_id, - frame_rx, - subframe_rx, - frame_tx, - subframe_tx, - subframe_select(&ue->frame_parms,subframe_tx), - eNB_id, - 0/*FIXME CC_id*/); - - if (ret == CONNECTION_LOST) { - LOG_E(PHY,"[UE %d] Frame %d, subframe %d RRC Connection lost, returning to PRACH\n",ue->Mod_id, - frame_rx,subframe_tx); - ue->UE_mode[eNB_id] = PRACH; - // mac_xface->macphy_exit("Connection lost"); - } else if (ret == PHY_RESYNCH) { - LOG_E(PHY,"[UE %d] Frame %d, subframe %d RRC Connection lost, trying to resynch\n", - ue->Mod_id, - frame_rx,subframe_tx); - ue->UE_mode[eNB_id] = RESYNCH; - // mac_xface->macphy_exit("Connection lost"); - } else if (ret == PHY_HO_PRACH) { - LOG_I(PHY,"[UE %d] Frame %d, subframe %d, return to PRACH and perform a contention-free access\n", - ue->Mod_id,frame_rx,subframe_tx); - ue->UE_mode[eNB_id] = PRACH; - } - } - } - - VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_PHY_PROCEDURES_UE_LTE,0); - - if (LOG_DEBUGFLAG(UE_TIMING)) { - stop_meas(&ue->phy_proc[ue->current_thread_id[subframe_rx]]); - } - } // slot -} diff --git a/openair1/SCHED_UE/sched_UE.h b/openair1/SCHED_UE/sched_UE.h index 32702b1148..0dbb779630 100644 --- a/openair1/SCHED_UE/sched_UE.h +++ b/openair1/SCHED_UE/sched_UE.h @@ -278,7 +278,7 @@ void dump_dlsch2(PHY_VARS_UE *phy_vars_ue,uint8_t eNB_id,uint8_t subframe, unsig int is_srs_occasion_common(LTE_DL_FRAME_PARMS *frame_parms,int frame_tx,int subframe_tx); -void compute_srs_pos(lte_frame_type_t frameType,uint16_t isrs,uint16_t *psrsPeriodicity,uint16_t *psrsOffset); +void compute_srs_pos(frame_type_t frameType,uint16_t isrs,uint16_t *psrsPeriodicity,uint16_t *psrsOffset); /*@}*/ diff --git a/openair1/SIMULATION/LTE_PHY/BLER_SIMULATIONS/AWGN/AWGN_results/bler_tx1_chan18_nrx1_mcs28.csv b/openair1/SIMULATION/LTE_PHY/BLER_SIMULATIONS/AWGN/AWGN_results/bler_tx1_chan18_nrx1_mcs28.csv new file mode 100644 index 0000000000..11771acc87 --- /dev/null +++ b/openair1/SIMULATION/LTE_PHY/BLER_SIMULATIONS/AWGN/AWGN_results/bler_tx1_chan18_nrx1_mcs28.csv @@ -0,0 +1,21 @@ +SNR; MCS; TBS; rate; err0; trials0; err1; trials1; err2; trials2; err3; trials3; dci_err +16.000000;27;15840;0.704000;5002;5002;0;0;0;0;0;0;0 +16.100000;27;15840;0.704000;5002;5002;0;0;0;0;0;0;0 +16.200000;27;15840;0.704000;5002;5002;0;0;0;0;0;0;0 +16.300000;27;15840;0.704000;5002;5002;0;0;0;0;0;0;0 +16.400000;27;15840;0.704000;4999;5002;0;0;0;0;0;0;0 +16.500000;27;15840;0.704000;4981;5002;0;0;0;0;0;0;0 +16.600000;27;15840;0.704000;4887;5002;0;0;0;0;0;0;0 +16.700000;27;15840;0.704000;4688;5002;0;0;0;0;0;0;0 +16.800000;27;15840;0.704000;4176;5002;0;0;0;0;0;0;0 +16.900000;27;15840;0.704000;3340;5002;0;0;0;0;0;0;0 +17.000000;27;15840;0.704000;2386;5002;0;0;0;0;0;0;0 +17.100000;27;15840;0.704000;1510;5002;0;0;0;0;0;0;0 +17.200000;27;15840;0.704000;1000;5552;0;0;0;0;0;0;0 +17.300000;27;15840;0.704000;926;10000;0;0;0;0;0;0;0 +17.400000;27;15840;0.704000;516;10000;0;0;0;0;0;0;0 +17.500000;27;15840;0.704000;287;10000;0;0;0;0;0;0;0 +17.600000;27;15840;0.704000;198;10000;0;0;0;0;0;0;0 +17.700000;27;15840;0.704000;135;10000;0;0;0;0;0;0;0 +17.800000;27;15840;0.704000;102;10000;0;0;0;0;0;0;0 +17.900000;27;15840;0.704000;94;10000;0;0;0;0;0;0;0 diff --git a/openair1/SIMULATION/LTE_PHY/pdcchsim.c b/openair1/SIMULATION/LTE_PHY/pdcchsim.c index bd2c2d66b9..50910290c3 100644 --- a/openair1/SIMULATION/LTE_PHY/pdcchsim.c +++ b/openair1/SIMULATION/LTE_PHY/pdcchsim.c @@ -415,7 +415,7 @@ int main(int argc, char **argv) { uint8_t harq_pid; uint8_t phich_ACK; uint8_t num_phich_interf = 0; - lte_frame_type_t frame_type=TDD; + frame_type_t frame_type=TDD; // int re_offset; // uint32_t *txptr; int aarx; diff --git a/openair1/SIMULATION/NR_PHY/BLER_SIMULATIONS/AWGN/AWGN_results/mcs0_awgn_5G.csv b/openair1/SIMULATION/NR_PHY/BLER_SIMULATIONS/AWGN/AWGN_results/mcs0_awgn_5G.csv new file mode 100644 index 0000000000..ae7824fe1e --- /dev/null +++ b/openair1/SIMULATION/NR_PHY/BLER_SIMULATIONS/AWGN/AWGN_results/mcs0_awgn_5G.csv @@ -0,0 +1,62 @@ +SNR;MCS;TBS;rate;err0;trials0;err1;trials1;err2;trials2;err3;trials3;dci_err +-4;0;1864;0.2344;1500;1500;0;0;0;0;0;0;0 +-3.9;0;1864;0.2344;1500;1500;0;0;0;0;0;0;0 +-3.8;0;1864;0.2344;1500;1500;0;0;0;0;0;0;0 +-3.7;0;1864;0.2344;1500;1500;0;0;0;0;0;0;0 +-3.6;0;1864;0.2344;1500;1500;0;0;0;0;0;0;0 +-3.5;0;1864;0.2344;1500;1500;0;0;0;0;0;0;0 +-3.4;0;1864;0.2344;1500;1500;0;0;0;0;0;0;0 +-3.3;0;1864;0.2344;1500;1500;0;0;0;0;0;0;0 +-3.2;0;1864;0.2344;1500;1500;0;0;0;0;0;0;0 +-3.1;0;1864;0.2344;1500;1500;0;0;0;0;0;0;0 +-3;0;1864;0.2344;1500;1500;0;0;0;0;0;0;0 +-2.9;0;1864;0.2344;1500;1500;0;0;0;0;0;0;0 +-2.8;0;1864;0.2344;1500;1500;0;0;0;0;0;0;0 +-2.7;0;1864;0.2344;1500;1500;0;0;0;0;0;0;0 +-2.6;0;1864;0.2344;1500;1500;0;0;0;0;0;0;0 +-2.5;0;1864;0.2344;1500;1500;0;0;0;0;0;0;0 +-2.4;0;1864;0.2344;1500;1500;0;0;0;0;0;0;0 +-2.3;0;1864;0.2344;1500;1500;0;0;0;0;0;0;0 +-2.2;0;1864;0.2344;1500;1500;0;0;0;0;0;0;0 +-2.1;0;1864;0.2344;1500;1500;0;0;0;0;0;0;0 +-2;0;1864;0.2344;1500;1500;0;0;0;0;0;0;0 +-1.9;0;1864;0.2344;1499;1500;0;0;0;0;0;0;0 +-1.8;0;1864;0.2344;1499;1500;0;0;0;0;0;0;0 +-1.7;0;1864;0.2344;1498;1500;0;0;0;0;0;0;0 +-1.6;0;1864;0.2344;1498;1500;0;0;0;0;0;0;0 +-1.5;0;1864;0.2344;1497;1500;0;0;0;0;0;0;0 +-1.4;0;1864;0.2344;1445;1500;0;0;0;0;0;0;0 +-1.3;0;1864;0.2344;1394;1500;0;0;0;0;0;0;0 +-1.2;0;1864;0.2344;1346;1500;0;0;0;0;0;0;0 +-1.1;0;1864;0.2344;1299;1500;0;0;0;0;0;0;0 +-1;0;1864;0.2344;1253;1500;0;0;0;0;0;0;0 +-0.9;0;1864;0.2344;980;1500;0;0;0;0;0;0;0 +-0.8;0;1864;0.2344;767;1500;0;0;0;0;0;0;0 +-0.7;0;1864;0.2344;600;1500;0;0;0;0;0;0;0 +-0.6;0;1864;0.2344;469;1500;0;0;0;0;0;0;0 +-0.5;0;1864;0.2344;367;1500;0;0;0;0;0;0;0 +-0.4;0;1864;0.2344;215;1500;0;0;0;0;0;0;0 +-0.3;0;1864;0.2344;126;1500;0;0;0;0;0;0;0 +-0.2;0;1864;0.2344;74;1500;0;0;0;0;0;0;0 +-0.1;0;1864;0.2344;43;1500;0;0;0;0;0;0;0 +0;0;1864;0.2344;26;1500;0;0;0;0;0;0;0 +0.1;0;1864;0.2344;12;1500;0;0;0;0;0;0;0 +0.2;0;1864;0.2344;5;1500;0;0;0;0;0;0;0 +0.3;0;1864;0.2344;2;1500;0;0;0;0;0;0;0 +0.4;0;1864;0.2344;1;1500;0;0;0;0;0;0;0 +0.5;0;1864;0.2344;1;1500;0;0;0;0;0;0;0 +0.6;0;1864;0.2344;0;1500;0;0;0;0;0;0;0 +0.7;0;1864;0.2344;0;1500;0;0;0;0;0;0;0 +0.8;0;1864;0.2344;0;1500;0;0;0;0;0;0;0 +0.9;0;1864;0.2344;0;1500;0;0;0;0;0;0;0 +1;0;1864;0.2344;0;1500;0;0;0;0;0;0;0 +1.1;0;1864;0.2344;0;1500;0;0;0;0;0;0;0 +1.2;0;1864;0.2344;0;1500;0;0;0;0;0;0;0 +1.3;0;1864;0.2344;0;1500;0;0;0;0;0;0;0 +1.4;0;1864;0.2344;0;1500;0;0;0;0;0;0;0 +1.5;0;1864;0.2344;0;1500;0;0;0;0;0;0;0 +1.6;0;1864;0.2344;0;1500;0;0;0;0;0;0;0 +1.7;0;1864;0.2344;0;1500;0;0;0;0;0;0;0 +1.8;0;1864;0.2344;0;1500;0;0;0;0;0;0;0 +1.9;0;1864;0.2344;0;1500;0;0;0;0;0;0;0 +2;0;1864;0.2344;0;1500;0;0;0;0;0;0;0 diff --git a/openair1/SIMULATION/NR_PHY/BLER_SIMULATIONS/AWGN/AWGN_results/mcs10_awgn_5G.csv b/openair1/SIMULATION/NR_PHY/BLER_SIMULATIONS/AWGN/AWGN_results/mcs10_awgn_5G.csv new file mode 100644 index 0000000000..8d1ff3ebb6 --- /dev/null +++ b/openair1/SIMULATION/NR_PHY/BLER_SIMULATIONS/AWGN/AWGN_results/mcs10_awgn_5G.csv @@ -0,0 +1,92 @@ +SNR;MCS;TBS;rate;err0;trials0;err1;trials1;err2;trials2;err3;trials3;dci_err +3;10;10504;1.3281;1500;1500;0;0;0;0;0;0;0 +3.1;10;10504;1.3281;1500;1500;0;0;0;0;0;0;0 +3.2;10;10504;1.3281;1500;1500;0;0;0;0;0;0;0 +3.3;10;10504;1.3281;1500;1500;0;0;0;0;0;0;0 +3.4;10;10504;1.3281;1500;1500;0;0;0;0;0;0;0 +3.5;10;10504;1.3281;1500;1500;0;0;0;0;0;0;0 +3.6;10;10504;1.3281;1500;1500;0;0;0;0;0;0;0 +3.7;10;10504;1.3281;1500;1500;0;0;0;0;0;0;0 +3.8;10;10504;1.3281;1500;1500;0;0;0;0;0;0;0 +3.9;10;10504;1.3281;1500;1500;0;0;0;0;0;0;0 +4;10;10504;1.3281;1500;1500;0;0;0;0;0;0;0 +4.1;10;10504;1.3281;1500;1500;0;0;0;0;0;0;0 +4.2;10;10504;1.3281;1500;1500;0;0;0;0;0;0;0 +4.3;10;10504;1.3281;1500;1500;0;0;0;0;0;0;0 +4.4;10;10504;1.3281;1500;1500;0;0;0;0;0;0;0 +4.5;10;10504;1.3281;1500;1500;0;0;0;0;0;0;0 +4.6;10;10504;1.3281;1500;1500;0;0;0;0;0;0;0 +4.7;10;10504;1.3281;1500;1500;0;0;0;0;0;0;0 +4.8;10;10504;1.3281;1500;1500;0;0;0;0;0;0;0 +4.9;10;10504;1.3281;1500;1500;0;0;0;0;0;0;0 +5;10;10504;1.3281;1500;1500;0;0;0;0;0;0;0 +5.1;10;10504;1.3281;1454;1500;0;0;0;0;0;0;0 +5.2;10;10504;1.3281;1410;1500;0;0;0;0;0;0;0 +5.3;10;10504;1.3281;1367;1500;0;0;0;0;0;0;0 +5.4;10;10504;1.3281;1325;1500;0;0;0;0;0;0;0 +5.5;10;10504;1.3281;1285;1500;0;0;0;0;0;0;0 +5.6;10;10504;1.3281;1026;1500;0;0;0;0;0;0;0 +5.7;10;10504;1.3281;819;1500;0;0;0;0;0;0;0 +5.8;10;10504;1.3281;654;1500;0;0;0;0;0;0;0 +5.9;10;10504;1.3281;522;1500;0;0;0;0;0;0;0 +6;10;10504;1.3281;417;1500;0;0;0;0;0;0;0 +6.1;10;10504;1.3281;309;1500;0;0;0;0;0;0;0 +6.2;10;10504;1.3281;229;1500;0;0;0;0;0;0;0 +6.3;10;10504;1.3281;169;1500;0;0;0;0;0;0;0 +6.4;10;10504;1.3281;125;1500;0;0;0;0;0;0;0 +6.5;10;10504;1.3281;93;1500;0;0;0;0;0;0;0 +6.6;10;10504;1.3281;64;1500;0;0;0;0;0;0;0 +6.7;10;10504;1.3281;44;1500;0;0;0;0;0;0;0 +6.8;10;10504;1.3281;31;1500;0;0;0;0;0;0;0 +6.9;10;10504;1.3281;21;1500;0;0;0;0;0;0;0 +7;10;10504;1.3281;15;1500;0;0;0;0;0;0;0 +7.1;10;10504;1.3281;7;1500;0;0;0;0;0;0;0 +7.2;10;10504;1.3281;3;1500;0;0;0;0;0;0;0 +7.3;10;10504;1.3281;1;1500;0;0;0;0;0;0;0 +7.4;10;10504;1.3281;1;1500;0;0;0;0;0;0;0 +7.5;10;10504;1.3281;0;1500;0;0;0;0;0;0;0 +7.6;10;10504;1.3281;0;1500;0;0;0;0;0;0;0 +7.7;10;10504;1.3281;0;1500;0;0;0;0;0;0;0 +7.8;10;10504;1.3281;0;1500;0;0;0;0;0;0;0 +7.9;10;10504;1.3281;0;1500;0;0;0;0;0;0;0 +8;10;10504;1.3281;0;1500;0;0;0;0;0;0;0 +8.1;10;10504;1.3281;0;1500;0;0;0;0;0;0;0 +8.2;10;10504;1.3281;0;1500;0;0;0;0;0;0;0 +8.3;10;10504;1.3281;0;1500;0;0;0;0;0;0;0 +8.4;10;10504;1.3281;0;1500;0;0;0;0;0;0;0 +8.5;10;10504;1.3281;0;1500;0;0;0;0;0;0;0 +8.6;10;10504;1.3281;0;1500;0;0;0;0;0;0;0 +8.7;10;10504;1.3281;0;1500;0;0;0;0;0;0;0 +8.8;10;10504;1.3281;0;1500;0;0;0;0;0;0;0 +8.9;10;10504;1.3281;0;1500;0;0;0;0;0;0;0 +9;10;10504;1.3281;0;1500;0;0;0;0;0;0;0 +9.1;10;10504;1.3281;0;1500;0;0;0;0;0;0;0 +9.2;10;10504;1.3281;0;1500;0;0;0;0;0;0;0 +9.3;10;10504;1.3281;0;1500;0;0;0;0;0;0;0 +9.4;10;10504;1.3281;0;1500;0;0;0;0;0;0;0 +9.5;10;10504;1.3281;0;1500;0;0;0;0;0;0;0 +9.6;10;10504;1.3281;0;1500;0;0;0;0;0;0;0 +9.7;10;10504;1.3281;0;1500;0;0;0;0;0;0;0 +9.8;10;10504;1.3281;0;1500;0;0;0;0;0;0;0 +9.9;10;10504;1.3281;0;1500;0;0;0;0;0;0;0 +10;10;10504;1.3281;0;1500;0;0;0;0;0;0;0 +10.1;10;10504;1.3281;0;1500;0;0;0;0;0;0;0 +10.2;10;10504;1.3281;0;1500;0;0;0;0;0;0;0 +10.3;10;10504;1.3281;0;1500;0;0;0;0;0;0;0 +10.4;10;10504;1.3281;0;1500;0;0;0;0;0;0;0 +10.5;10;10504;1.3281;0;1500;0;0;0;0;0;0;0 +10.6;10;10504;1.3281;0;1500;0;0;0;0;0;0;0 +10.7;10;10504;1.3281;0;1500;0;0;0;0;0;0;0 +10.8;10;10504;1.3281;0;1500;0;0;0;0;0;0;0 +10.9;10;10504;1.3281;0;1500;0;0;0;0;0;0;0 +11;10;10504;1.3281;0;1500;0;0;0;0;0;0;0 +11.1;10;10504;1.3281;0;1500;0;0;0;0;0;0;0 +11.2;10;10504;1.3281;0;1500;0;0;0;0;0;0;0 +11.3;10;10504;1.3281;0;1500;0;0;0;0;0;0;0 +11.4;10;10504;1.3281;0;1500;0;0;0;0;0;0;0 +11.5;10;10504;1.3281;0;1500;0;0;0;0;0;0;0 +11.6;10;10504;1.3281;0;1500;0;0;0;0;0;0;0 +11.7;10;10504;1.3281;0;1500;0;0;0;0;0;0;0 +11.8;10;10504;1.3281;0;1500;0;0;0;0;0;0;0 +11.9;10;10504;1.3281;0;1500;0;0;0;0;0;0;0 +12;10;10504;1.3281;0;1500;0;0;0;0;0;0;0 diff --git a/openair1/SIMULATION/NR_PHY/BLER_SIMULATIONS/AWGN/AWGN_results/mcs11_awgn_5G.csv b/openair1/SIMULATION/NR_PHY/BLER_SIMULATIONS/AWGN/AWGN_results/mcs11_awgn_5G.csv new file mode 100644 index 0000000000..e581ab2ff1 --- /dev/null +++ b/openair1/SIMULATION/NR_PHY/BLER_SIMULATIONS/AWGN/AWGN_results/mcs11_awgn_5G.csv @@ -0,0 +1,92 @@ +SNR;MCS;TBS;rate;err0;trials0;err1;trials1;err2;trials2;err3;trials3;dci_err +3;11;11784;1.4766;1500;1500;0;0;0;0;0;0;0 +3.1;11;11784;1.4766;1500;1500;0;0;0;0;0;0;0 +3.2;11;11784;1.4766;1500;1500;0;0;0;0;0;0;0 +3.3;11;11784;1.4766;1500;1500;0;0;0;0;0;0;0 +3.4;11;11784;1.4766;1500;1500;0;0;0;0;0;0;0 +3.5;11;11784;1.4766;1500;1500;0;0;0;0;0;0;0 +3.6;11;11784;1.4766;1500;1500;0;0;0;0;0;0;0 +3.7;11;11784;1.4766;1500;1500;0;0;0;0;0;0;0 +3.8;11;11784;1.4766;1500;1500;0;0;0;0;0;0;0 +3.9;11;11784;1.4766;1500;1500;0;0;0;0;0;0;0 +4;11;11784;1.4766;1500;1500;0;0;0;0;0;0;0 +4.1;11;11784;1.4766;1500;1500;0;0;0;0;0;0;0 +4.2;11;11784;1.4766;1500;1500;0;0;0;0;0;0;0 +4.3;11;11784;1.4766;1500;1500;0;0;0;0;0;0;0 +4.4;11;11784;1.4766;1500;1500;0;0;0;0;0;0;0 +4.5;11;11784;1.4766;1500;1500;0;0;0;0;0;0;0 +4.6;11;11784;1.4766;1500;1500;0;0;0;0;0;0;0 +4.7;11;11784;1.4766;1500;1500;0;0;0;0;0;0;0 +4.8;11;11784;1.4766;1500;1500;0;0;0;0;0;0;0 +4.9;11;11784;1.4766;1500;1500;0;0;0;0;0;0;0 +5;11;11784;1.4766;1500;1500;0;0;0;0;0;0;0 +5.1;11;11784;1.4766;1500;1500;0;0;0;0;0;0;0 +5.2;11;11784;1.4766;1500;1500;0;0;0;0;0;0;0 +5.3;11;11784;1.4766;1500;1500;0;0;0;0;0;0;0 +5.4;11;11784;1.4766;1500;1500;0;0;0;0;0;0;0 +5.5;11;11784;1.4766;1500;1500;0;0;0;0;0;0;0 +5.6;11;11784;1.4766;1494;1500;0;0;0;0;0;0;0 +5.7;11;11784;1.4766;1489;1500;0;0;0;0;0;0;0 +5.8;11;11784;1.4766;1483;1500;0;0;0;0;0;0;0 +5.9;11;11784;1.4766;1477;1500;0;0;0;0;0;0;0 +6;11;11784;1.4766;1472;1500;0;0;0;0;0;0;0 +6.1;11;11784;1.4766;1367;1500;0;0;0;0;0;0;0 +6.2;11;11784;1.4766;1269;1500;0;0;0;0;0;0;0 +6.3;11;11784;1.4766;1179;1500;0;0;0;0;0;0;0 +6.4;11;11784;1.4766;1095;1500;0;0;0;0;0;0;0 +6.5;11;11784;1.4766;1016;1500;0;0;0;0;0;0;0 +6.6;11;11784;1.4766;762;1500;0;0;0;0;0;0;0 +6.7;11;11784;1.4766;571;1500;0;0;0;0;0;0;0 +6.8;11;11784;1.4766;428;1500;0;0;0;0;0;0;0 +6.9;11;11784;1.4766;320;1500;0;0;0;0;0;0;0 +7;11;11784;1.4766;240;1500;0;0;0;0;0;0;0 +7.1;11;11784;1.4766;169;1500;0;0;0;0;0;0;0 +7.2;11;11784;1.4766;119;1500;0;0;0;0;0;0;0 +7.3;11;11784;1.4766;83;1500;0;0;0;0;0;0;0 +7.4;11;11784;1.4766;59;1500;0;0;0;0;0;0;0 +7.5;11;11784;1.4766;41;1500;0;0;0;0;0;0;0 +7.6;11;11784;1.4766;24;1500;0;0;0;0;0;0;0 +7.7;11;11784;1.4766;14;1500;0;0;0;0;0;0;0 +7.8;11;11784;1.4766;8;1500;0;0;0;0;0;0;0 +7.9;11;11784;1.4766;5;1500;0;0;0;0;0;0;0 +8;11;11784;1.4766;3;1500;0;0;0;0;0;0;0 +8.1;11;11784;1.4766;1;1500;0;0;0;0;0;0;0 +8.2;11;11784;1.4766;1;1500;0;0;0;0;0;0;0 +8.3;11;11784;1.4766;0;1500;0;0;0;0;0;0;0 +8.4;11;11784;1.4766;0;1500;0;0;0;0;0;0;0 +8.5;11;11784;1.4766;0;1500;0;0;0;0;0;0;0 +8.6;11;11784;1.4766;0;1500;0;0;0;0;0;0;0 +8.7;11;11784;1.4766;0;1500;0;0;0;0;0;0;0 +8.8;11;11784;1.4766;0;1500;0;0;0;0;0;0;0 +8.9;11;11784;1.4766;0;1500;0;0;0;0;0;0;0 +9;11;11784;1.4766;0;1500;0;0;0;0;0;0;0 +9.1;11;11784;1.4766;0;1500;0;0;0;0;0;0;0 +9.2;11;11784;1.4766;0;1500;0;0;0;0;0;0;0 +9.3;11;11784;1.4766;0;1500;0;0;0;0;0;0;0 +9.4;11;11784;1.4766;0;1500;0;0;0;0;0;0;0 +9.5;11;11784;1.4766;0;1500;0;0;0;0;0;0;0 +9.6;11;11784;1.4766;0;1500;0;0;0;0;0;0;0 +9.7;11;11784;1.4766;0;1500;0;0;0;0;0;0;0 +9.8;11;11784;1.4766;0;1500;0;0;0;0;0;0;0 +9.9;11;11784;1.4766;0;1500;0;0;0;0;0;0;0 +10;11;11784;1.4766;0;1500;0;0;0;0;0;0;0 +10.1;11;11784;1.4766;0;1500;0;0;0;0;0;0;0 +10.2;11;11784;1.4766;0;1500;0;0;0;0;0;0;0 +10.3;11;11784;1.4766;0;1500;0;0;0;0;0;0;0 +10.4;11;11784;1.4766;0;1500;0;0;0;0;0;0;0 +10.5;11;11784;1.4766;0;1500;0;0;0;0;0;0;0 +10.6;11;11784;1.4766;0;1500;0;0;0;0;0;0;0 +10.7;11;11784;1.4766;0;1500;0;0;0;0;0;0;0 +10.8;11;11784;1.4766;0;1500;0;0;0;0;0;0;0 +10.9;11;11784;1.4766;0;1500;0;0;0;0;0;0;0 +11;11;11784;1.4766;0;1500;0;0;0;0;0;0;0 +11.1;11;11784;1.4766;0;1500;0;0;0;0;0;0;0 +11.2;11;11784;1.4766;0;1500;0;0;0;0;0;0;0 +11.3;11;11784;1.4766;0;1500;0;0;0;0;0;0;0 +11.4;11;11784;1.4766;0;1500;0;0;0;0;0;0;0 +11.5;11;11784;1.4766;0;1500;0;0;0;0;0;0;0 +11.6;11;11784;1.4766;0;1500;0;0;0;0;0;0;0 +11.7;11;11784;1.4766;0;1500;0;0;0;0;0;0;0 +11.8;11;11784;1.4766;0;1500;0;0;0;0;0;0;0 +11.9;11;11784;1.4766;0;1500;0;0;0;0;0;0;0 +12;11;11784;1.4766;0;1500;0;0;0;0;0;0;0 diff --git a/openair1/SIMULATION/NR_PHY/BLER_SIMULATIONS/AWGN/AWGN_results/mcs12_awgn_5G.csv b/openair1/SIMULATION/NR_PHY/BLER_SIMULATIONS/AWGN/AWGN_results/mcs12_awgn_5G.csv new file mode 100644 index 0000000000..08825dec27 --- /dev/null +++ b/openair1/SIMULATION/NR_PHY/BLER_SIMULATIONS/AWGN/AWGN_results/mcs12_awgn_5G.csv @@ -0,0 +1,92 @@ +SNR;MCS;TBS;rate;err0;trials0;err1;trials1;err2;trials2;err3;trials3;dci_err +3;12;13576;1.6953;1500;1500;0;0;0;0;0;0;0 +3.1;12;13576;1.6953;1500;1500;0;0;0;0;0;0;0 +3.2;12;13576;1.6953;1500;1500;0;0;0;0;0;0;0 +3.3;12;13576;1.6953;1500;1500;0;0;0;0;0;0;0 +3.4;12;13576;1.6953;1500;1500;0;0;0;0;0;0;0 +3.5;12;13576;1.6953;1500;1500;0;0;0;0;0;0;0 +3.6;12;13576;1.6953;1500;1500;0;0;0;0;0;0;0 +3.7;12;13576;1.6953;1500;1500;0;0;0;0;0;0;0 +3.8;12;13576;1.6953;1500;1500;0;0;0;0;0;0;0 +3.9;12;13576;1.6953;1500;1500;0;0;0;0;0;0;0 +4;12;13576;1.6953;1500;1500;0;0;0;0;0;0;0 +4.1;12;13576;1.6953;1500;1500;0;0;0;0;0;0;0 +4.2;12;13576;1.6953;1500;1500;0;0;0;0;0;0;0 +4.3;12;13576;1.6953;1500;1500;0;0;0;0;0;0;0 +4.4;12;13576;1.6953;1500;1500;0;0;0;0;0;0;0 +4.5;12;13576;1.6953;1500;1500;0;0;0;0;0;0;0 +4.6;12;13576;1.6953;1500;1500;0;0;0;0;0;0;0 +4.7;12;13576;1.6953;1500;1500;0;0;0;0;0;0;0 +4.8;12;13576;1.6953;1500;1500;0;0;0;0;0;0;0 +4.9;12;13576;1.6953;1500;1500;0;0;0;0;0;0;0 +5;12;13576;1.6953;1500;1500;0;0;0;0;0;0;0 +5.1;12;13576;1.6953;1500;1500;0;0;0;0;0;0;0 +5.2;12;13576;1.6953;1500;1500;0;0;0;0;0;0;0 +5.3;12;13576;1.6953;1500;1500;0;0;0;0;0;0;0 +5.4;12;13576;1.6953;1500;1500;0;0;0;0;0;0;0 +5.5;12;13576;1.6953;1500;1500;0;0;0;0;0;0;0 +5.6;12;13576;1.6953;1500;1500;0;0;0;0;0;0;0 +5.7;12;13576;1.6953;1500;1500;0;0;0;0;0;0;0 +5.8;12;13576;1.6953;1500;1500;0;0;0;0;0;0;0 +5.9;12;13576;1.6953;1500;1500;0;0;0;0;0;0;0 +6;12;13576;1.6953;1500;1500;0;0;0;0;0;0;0 +6.1;12;13576;1.6953;1500;1500;0;0;0;0;0;0;0 +6.2;12;13576;1.6953;1500;1500;0;0;0;0;0;0;0 +6.3;12;13576;1.6953;1500;1500;0;0;0;0;0;0;0 +6.4;12;13576;1.6953;1500;1500;0;0;0;0;0;0;0 +6.5;12;13576;1.6953;1500;1500;0;0;0;0;0;0;0 +6.6;12;13576;1.6953;1498;1500;0;0;0;0;0;0;0 +6.7;12;13576;1.6953;1495;1500;0;0;0;0;0;0;0 +6.8;12;13576;1.6953;1493;1500;0;0;0;0;0;0;0 +6.9;12;13576;1.6953;1491;1500;0;0;0;0;0;0;0 +7;12;13576;1.6953;1488;1500;0;0;0;0;0;0;0 +7.1;12;13576;1.6953;1357;1500;0;0;0;0;0;0;0 +7.2;12;13576;1.6953;1238;1500;0;0;0;0;0;0;0 +7.3;12;13576;1.6953;1129;1500;0;0;0;0;0;0;0 +7.4;12;13576;1.6953;1029;1500;0;0;0;0;0;0;0 +7.5;12;13576;1.6953;939;1500;0;0;0;0;0;0;0 +7.6;12;13576;1.6953;632;1500;0;0;0;0;0;0;0 +7.7;12;13576;1.6953;425;1500;0;0;0;0;0;0;0 +7.8;12;13576;1.6953;286;1500;0;0;0;0;0;0;0 +7.9;12;13576;1.6953;193;1500;0;0;0;0;0;0;0 +8;12;13576;1.6953;130;1500;0;0;0;0;0;0;0 +8.1;12;13576;1.6953;91;1500;0;0;0;0;0;0;0 +8.2;12;13576;1.6953;64;1500;0;0;0;0;0;0;0 +8.3;12;13576;1.6953;45;1500;0;0;0;0;0;0;0 +8.4;12;13576;1.6953;32;1500;0;0;0;0;0;0;0 +8.5;12;13576;1.6953;23;1500;0;0;0;0;0;0;0 +8.6;12;13576;1.6953;12;1500;0;0;0;0;0;0;0 +8.7;12;13576;1.6953;6;1500;0;0;0;0;0;0;0 +8.8;12;13576;1.6953;3;1500;0;0;0;0;0;0;0 +8.9;12;13576;1.6953;2;1500;0;0;0;0;0;0;0 +9;12;13576;1.6953;1;1500;0;0;0;0;0;0;0 +9.1;12;13576;1.6953;0;1500;0;0;0;0;0;0;0 +9.2;12;13576;1.6953;0;1500;0;0;0;0;0;0;0 +9.3;12;13576;1.6953;0;1500;0;0;0;0;0;0;0 +9.4;12;13576;1.6953;0;1500;0;0;0;0;0;0;0 +9.5;12;13576;1.6953;0;1500;0;0;0;0;0;0;0 +9.6;12;13576;1.6953;0;1500;0;0;0;0;0;0;0 +9.7;12;13576;1.6953;0;1500;0;0;0;0;0;0;0 +9.8;12;13576;1.6953;0;1500;0;0;0;0;0;0;0 +9.9;12;13576;1.6953;0;1500;0;0;0;0;0;0;0 +10;12;13576;1.6953;0;1500;0;0;0;0;0;0;0 +10.1;12;13576;1.6953;0;1500;0;0;0;0;0;0;0 +10.2;12;13576;1.6953;0;1500;0;0;0;0;0;0;0 +10.3;12;13576;1.6953;0;1500;0;0;0;0;0;0;0 +10.4;12;13576;1.6953;0;1500;0;0;0;0;0;0;0 +10.5;12;13576;1.6953;0;1500;0;0;0;0;0;0;0 +10.6;12;13576;1.6953;0;1500;0;0;0;0;0;0;0 +10.7;12;13576;1.6953;0;1500;0;0;0;0;0;0;0 +10.8;12;13576;1.6953;0;1500;0;0;0;0;0;0;0 +10.9;12;13576;1.6953;0;1500;0;0;0;0;0;0;0 +11;12;13576;1.6953;0;1500;0;0;0;0;0;0;0 +11.1;12;13576;1.6953;0;1500;0;0;0;0;0;0;0 +11.2;12;13576;1.6953;0;1500;0;0;0;0;0;0;0 +11.3;12;13576;1.6953;0;1500;0;0;0;0;0;0;0 +11.4;12;13576;1.6953;0;1500;0;0;0;0;0;0;0 +11.5;12;13576;1.6953;0;1500;0;0;0;0;0;0;0 +11.6;12;13576;1.6953;0;1500;0;0;0;0;0;0;0 +11.7;12;13576;1.6953;0;1500;0;0;0;0;0;0;0 +11.8;12;13576;1.6953;0;1500;0;0;0;0;0;0;0 +11.9;12;13576;1.6953;0;1500;0;0;0;0;0;0;0 +12;12;13576;1.6953;0;1500;0;0;0;0;0;0;0 diff --git a/openair1/SIMULATION/NR_PHY/BLER_SIMULATIONS/AWGN/AWGN_results/mcs13_awgn_5G.csv b/openair1/SIMULATION/NR_PHY/BLER_SIMULATIONS/AWGN/AWGN_results/mcs13_awgn_5G.csv new file mode 100644 index 0000000000..ef85933aaf --- /dev/null +++ b/openair1/SIMULATION/NR_PHY/BLER_SIMULATIONS/AWGN/AWGN_results/mcs13_awgn_5G.csv @@ -0,0 +1,72 @@ +SNR;MCS;TBS;rate;err0;trials0;err1;trials1;err2;trials2;err3;trials3;dci_err +7;13;15112;1.9141;1500;1500;0;0;0;0;0;0;0 +7.1;13;15112;1.9141;1500;1500;0;0;0;0;0;0;0 +7.2;13;15112;1.9141;1500;1500;0;0;0;0;0;0;0 +7.3;13;15112;1.9141;1500;1500;0;0;0;0;0;0;0 +7.4;13;15112;1.9141;1500;1500;0;0;0;0;0;0;0 +7.5;13;15112;1.9141;1500;1500;0;0;0;0;0;0;0 +7.6;13;15112;1.9141;1444;1500;0;0;0;0;0;0;0 +7.7;13;15112;1.9141;1391;1500;0;0;0;0;0;0;0 +7.8;13;15112;1.9141;1340;1500;0;0;0;0;0;0;0 +7.9;13;15112;1.9141;1290;1500;0;0;0;0;0;0;0 +8;13;15112;1.9141;1243;1500;0;0;0;0;0;0;0 +8.1;13;15112;1.9141;878;1500;0;0;0;0;0;0;0 +8.2;13;15112;1.9141;620;1500;0;0;0;0;0;0;0 +8.3;13;15112;1.9141;438;1500;0;0;0;0;0;0;0 +8.4;13;15112;1.9141;309;1500;0;0;0;0;0;0;0 +8.5;13;15112;1.9141;219;1500;0;0;0;0;0;0;0 +8.6;13;15112;1.9141;173;1500;0;0;0;0;0;0;0 +8.7;13;15112;1.9141;137;1500;0;0;0;0;0;0;0 +8.8;13;15112;1.9141;109;1500;0;0;0;0;0;0;0 +8.9;13;15112;1.9141;86;1500;0;0;0;0;0;0;0 +9;13;15112;1.9141;68;1500;0;0;0;0;0;0;0 +9.1;13;15112;1.9141;47;1500;0;0;0;0;0;0;0 +9.2;13;15112;1.9141;33;1500;0;0;0;0;0;0;0 +9.3;13;15112;1.9141;23;1500;0;0;0;0;0;0;0 +9.4;13;15112;1.9141;16;1500;0;0;0;0;0;0;0 +9.5;13;15112;1.9141;11;1500;0;0;0;0;0;0;0 +9.6;13;15112;1.9141;5;1500;0;0;0;0;0;0;0 +9.7;13;15112;1.9141;2;1500;0;0;0;0;0;0;0 +9.8;13;15112;1.9141;1;1500;0;0;0;0;0;0;0 +9.9;13;15112;1.9141;0;1500;0;0;0;0;0;0;0 +10;13;15112;1.9141;0;1500;0;0;0;0;0;0;0 +10.1;13;15112;1.9141;0;1500;0;0;0;0;0;0;0 +10.2;13;15112;1.9141;0;1500;0;0;0;0;0;0;0 +10.3;13;15112;1.9141;0;1500;0;0;0;0;0;0;0 +10.4;13;15112;1.9141;0;1500;0;0;0;0;0;0;0 +10.5;13;15112;1.9141;0;1500;0;0;0;0;0;0;0 +10.6;13;15112;1.9141;0;1500;0;0;0;0;0;0;0 +10.7;13;15112;1.9141;0;1500;0;0;0;0;0;0;0 +10.8;13;15112;1.9141;0;1500;0;0;0;0;0;0;0 +10.9;13;15112;1.9141;0;1500;0;0;0;0;0;0;0 +11;13;15112;1.9141;0;1500;0;0;0;0;0;0;0 +11.1;13;15112;1.9141;0;1500;0;0;0;0;0;0;0 +11.2;13;15112;1.9141;0;1500;0;0;0;0;0;0;0 +11.3;13;15112;1.9141;0;1500;0;0;0;0;0;0;0 +11.4;13;15112;1.9141;0;1500;0;0;0;0;0;0;0 +11.5;13;15112;1.9141;0;1500;0;0;0;0;0;0;0 +11.6;13;15112;1.9141;0;1500;0;0;0;0;0;0;0 +11.7;13;15112;1.9141;0;1500;0;0;0;0;0;0;0 +11.8;13;15112;1.9141;0;1500;0;0;0;0;0;0;0 +11.9;13;15112;1.9141;0;1500;0;0;0;0;0;0;0 +12;13;15112;1.9141;0;1500;0;0;0;0;0;0;0 +12.1;13;15112;1.9141;0;1500;0;0;0;0;0;0;0 +12.2;13;15112;1.9141;0;1500;0;0;0;0;0;0;0 +12.3;13;15112;1.9141;0;1500;0;0;0;0;0;0;0 +12.4;13;15112;1.9141;0;1500;0;0;0;0;0;0;0 +12.5;13;15112;1.9141;0;1500;0;0;0;0;0;0;0 +12.6;13;15112;1.9141;0;1500;0;0;0;0;0;0;0 +12.7;13;15112;1.9141;0;1500;0;0;0;0;0;0;0 +12.8;13;15112;1.9141;0;1500;0;0;0;0;0;0;0 +12.9;13;15112;1.9141;0;1500;0;0;0;0;0;0;0 +13;13;15112;1.9141;0;1500;0;0;0;0;0;0;0 +13.1;13;15112;1.9141;0;1500;0;0;0;0;0;0;0 +13.2;13;15112;1.9141;0;1500;0;0;0;0;0;0;0 +13.3;13;15112;1.9141;0;1500;0;0;0;0;0;0;0 +13.4;13;15112;1.9141;0;1500;0;0;0;0;0;0;0 +13.5;13;15112;1.9141;0;1500;0;0;0;0;0;0;0 +13.6;13;15112;1.9141;0;1500;0;0;0;0;0;0;0 +13.7;13;15112;1.9141;0;1500;0;0;0;0;0;0;0 +13.8;13;15112;1.9141;0;1500;0;0;0;0;0;0;0 +13.9;13;15112;1.9141;0;1500;0;0;0;0;0;0;0 +14;13;15112;1.9141;0;1500;0;0;0;0;0;0;0 diff --git a/openair1/SIMULATION/NR_PHY/BLER_SIMULATIONS/AWGN/AWGN_results/mcs14_awgn_5G.csv b/openair1/SIMULATION/NR_PHY/BLER_SIMULATIONS/AWGN/AWGN_results/mcs14_awgn_5G.csv new file mode 100644 index 0000000000..0667105011 --- /dev/null +++ b/openair1/SIMULATION/NR_PHY/BLER_SIMULATIONS/AWGN/AWGN_results/mcs14_awgn_5G.csv @@ -0,0 +1,72 @@ +SNR;MCS;TBS;rate;err0;trials0;err1;trials1;err2;trials2;err3;trials3;dci_err +7;14;17424;2.1602;1500;1500;0;0;0;0;0;0;0 +7.1;14;17424;2.1602;1500;1500;0;0;0;0;0;0;0 +7.2;14;17424;2.1602;1500;1500;0;0;0;0;0;0;0 +7.3;14;17424;2.1602;1500;1500;0;0;0;0;0;0;0 +7.4;14;17424;2.1602;1500;1500;0;0;0;0;0;0;0 +7.5;14;17424;2.1602;1500;1500;0;0;0;0;0;0;0 +7.6;14;17424;2.1602;1500;1500;0;0;0;0;0;0;0 +7.7;14;17424;2.1602;1500;1500;0;0;0;0;0;0;0 +7.8;14;17424;2.1602;1500;1500;0;0;0;0;0;0;0 +7.9;14;17424;2.1602;1500;1500;0;0;0;0;0;0;0 +8;14;17424;2.1602;1500;1500;0;0;0;0;0;0;0 +8.1;14;17424;2.1602;1500;1500;0;0;0;0;0;0;0 +8.2;14;17424;2.1602;1500;1500;0;0;0;0;0;0;0 +8.3;14;17424;2.1602;1500;1500;0;0;0;0;0;0;0 +8.4;14;17424;2.1602;1500;1500;0;0;0;0;0;0;0 +8.5;14;17424;2.1602;1500;1500;0;0;0;0;0;0;0 +8.6;14;17424;2.1602;1497;1500;0;0;0;0;0;0;0 +8.7;14;17424;2.1602;1493;1500;0;0;0;0;0;0;0 +8.8;14;17424;2.1602;1490;1500;0;0;0;0;0;0;0 +8.9;14;17424;2.1602;1487;1500;0;0;0;0;0;0;0 +9;14;17424;2.1602;1484;1500;0;0;0;0;0;0;0 +9.1;14;17424;2.1602;1291;1500;0;0;0;0;0;0;0 +9.2;14;17424;2.1602;1123;1500;0;0;0;0;0;0;0 +9.3;14;17424;2.1602;977;1500;0;0;0;0;0;0;0 +9.4;14;17424;2.1602;850;1500;0;0;0;0;0;0;0 +9.5;14;17424;2.1602;739;1500;0;0;0;0;0;0;0 +9.6;14;17424;2.1602;508;1500;0;0;0;0;0;0;0 +9.7;14;17424;2.1602;349;1500;0;0;0;0;0;0;0 +9.8;14;17424;2.1602;239;1500;0;0;0;0;0;0;0 +9.9;14;17424;2.1602;164;1500;0;0;0;0;0;0;0 +10;14;17424;2.1602;113;1500;0;0;0;0;0;0;0 +10.1;14;17424;2.1602;85;1500;0;0;0;0;0;0;0 +10.2;14;17424;2.1602;63;1500;0;0;0;0;0;0;0 +10.3;14;17424;2.1602;47;1500;0;0;0;0;0;0;0 +10.4;14;17424;2.1602;35;1500;0;0;0;0;0;0;0 +10.5;14;17424;2.1602;27;1500;0;0;0;0;0;0;0 +10.6;14;17424;2.1602;12;1500;0;0;0;0;0;0;0 +10.7;14;17424;2.1602;6;1500;0;0;0;0;0;0;0 +10.8;14;17424;2.1602;3;1500;0;0;0;0;0;0;0 +10.9;14;17424;2.1602;1;1500;0;0;0;0;0;0;0 +11;14;17424;2.1602;1;1500;0;0;0;0;0;0;0 +11.1;14;17424;2.1602;0;1500;0;0;0;0;0;0;0 +11.2;14;17424;2.1602;0;1500;0;0;0;0;0;0;0 +11.3;14;17424;2.1602;0;1500;0;0;0;0;0;0;0 +11.4;14;17424;2.1602;0;1500;0;0;0;0;0;0;0 +11.5;14;17424;2.1602;0;1500;0;0;0;0;0;0;0 +11.6;14;17424;2.1602;0;1500;0;0;0;0;0;0;0 +11.7;14;17424;2.1602;0;1500;0;0;0;0;0;0;0 +11.8;14;17424;2.1602;0;1500;0;0;0;0;0;0;0 +11.9;14;17424;2.1602;0;1500;0;0;0;0;0;0;0 +12;14;17424;2.1602;0;1500;0;0;0;0;0;0;0 +12.1;14;17424;2.1602;0;1500;0;0;0;0;0;0;0 +12.2;14;17424;2.1602;0;1500;0;0;0;0;0;0;0 +12.3;14;17424;2.1602;0;1500;0;0;0;0;0;0;0 +12.4;14;17424;2.1602;0;1500;0;0;0;0;0;0;0 +12.5;14;17424;2.1602;0;1500;0;0;0;0;0;0;0 +12.6;14;17424;2.1602;0;1500;0;0;0;0;0;0;0 +12.7;14;17424;2.1602;0;1500;0;0;0;0;0;0;0 +12.8;14;17424;2.1602;0;1500;0;0;0;0;0;0;0 +12.9;14;17424;2.1602;0;1500;0;0;0;0;0;0;0 +13;14;17424;2.1602;0;1500;0;0;0;0;0;0;0 +13.1;14;17424;2.1602;0;1500;0;0;0;0;0;0;0 +13.2;14;17424;2.1602;0;1500;0;0;0;0;0;0;0 +13.3;14;17424;2.1602;0;1500;0;0;0;0;0;0;0 +13.4;14;17424;2.1602;0;1500;0;0;0;0;0;0;0 +13.5;14;17424;2.1602;0;1500;0;0;0;0;0;0;0 +13.6;14;17424;2.1602;0;1500;0;0;0;0;0;0;0 +13.7;14;17424;2.1602;0;1500;0;0;0;0;0;0;0 +13.8;14;17424;2.1602;0;1500;0;0;0;0;0;0;0 +13.9;14;17424;2.1602;0;1500;0;0;0;0;0;0;0 +14;14;17424;2.1602;0;1500;0;0;0;0;0;0;0 diff --git a/openair1/SIMULATION/NR_PHY/BLER_SIMULATIONS/AWGN/AWGN_results/mcs15_awgn_5G.csv b/openair1/SIMULATION/NR_PHY/BLER_SIMULATIONS/AWGN/AWGN_results/mcs15_awgn_5G.csv new file mode 100644 index 0000000000..460d156d78 --- /dev/null +++ b/openair1/SIMULATION/NR_PHY/BLER_SIMULATIONS/AWGN/AWGN_results/mcs15_awgn_5G.csv @@ -0,0 +1,72 @@ +SNR;MCS;TBS;rate;err0;trials0;err1;trials1;err2;trials2;err3;trials3;dci_err +7;15;18960;2.4063;1500;1500;0;0;0;0;0;0;0 +7.1;15;18960;2.4063;1500;1500;0;0;0;0;0;0;0 +7.2;15;18960;2.4063;1500;1500;0;0;0;0;0;0;0 +7.3;15;18960;2.4063;1500;1500;0;0;0;0;0;0;0 +7.4;15;18960;2.4063;1500;1500;0;0;0;0;0;0;0 +7.5;15;18960;2.4063;1500;1500;0;0;0;0;0;0;0 +7.6;15;18960;2.4063;1500;1500;0;0;0;0;0;0;0 +7.7;15;18960;2.4063;1500;1500;0;0;0;0;0;0;0 +7.8;15;18960;2.4063;1500;1500;0;0;0;0;0;0;0 +7.9;15;18960;2.4063;1500;1500;0;0;0;0;0;0;0 +8;15;18960;2.4063;1500;1500;0;0;0;0;0;0;0 +8.1;15;18960;2.4063;1500;1500;0;0;0;0;0;0;0 +8.2;15;18960;2.4063;1500;1500;0;0;0;0;0;0;0 +8.3;15;18960;2.4063;1500;1500;0;0;0;0;0;0;0 +8.4;15;18960;2.4063;1500;1500;0;0;0;0;0;0;0 +8.5;15;18960;2.4063;1500;1500;0;0;0;0;0;0;0 +8.6;15;18960;2.4063;1500;1500;0;0;0;0;0;0;0 +8.7;15;18960;2.4063;1500;1500;0;0;0;0;0;0;0 +8.8;15;18960;2.4063;1500;1500;0;0;0;0;0;0;0 +8.9;15;18960;2.4063;1500;1500;0;0;0;0;0;0;0 +9;15;18960;2.4063;1500;1500;0;0;0;0;0;0;0 +9.1;15;18960;2.4063;1500;1500;0;0;0;0;0;0;0 +9.2;15;18960;2.4063;1499;1500;0;0;0;0;0;0;0 +9.3;15;18960;2.4063;1499;1500;0;0;0;0;0;0;0 +9.4;15;18960;2.4063;1499;1500;0;0;0;0;0;0;0 +9.5;15;18960;2.4063;1498;1500;0;0;0;0;0;0;0 +9.6;15;18960;2.4063;1377;1500;0;0;0;0;0;0;0 +9.7;15;18960;2.4063;1265;1500;0;0;0;0;0;0;0 +9.8;15;18960;2.4063;1163;1500;0;0;0;0;0;0;0 +9.9;15;18960;2.4063;1069;1500;0;0;0;0;0;0;0 +10;15;18960;2.4063;982;1500;0;0;0;0;0;0;0 +10.1;15;18960;2.4063;664;1500;0;0;0;0;0;0;0 +10.2;15;18960;2.4063;450;1500;0;0;0;0;0;0;0 +10.3;15;18960;2.4063;304;1500;0;0;0;0;0;0;0 +10.4;15;18960;2.4063;206;1500;0;0;0;0;0;0;0 +10.5;15;18960;2.4063;139;1500;0;0;0;0;0;0;0 +10.6;15;18960;2.4063;113;1500;0;0;0;0;0;0;0 +10.7;15;18960;2.4063;92;1500;0;0;0;0;0;0;0 +10.8;15;18960;2.4063;75;1500;0;0;0;0;0;0;0 +10.9;15;18960;2.4063;61;1500;0;0;0;0;0;0;0 +11;15;18960;2.4063;50;1500;0;0;0;0;0;0;0 +11.1;15;18960;2.4063;29;1500;0;0;0;0;0;0;0 +11.2;15;18960;2.4063;17;1500;0;0;0;0;0;0;0 +11.3;15;18960;2.4063;10;1500;0;0;0;0;0;0;0 +11.4;15;18960;2.4063;6;1500;0;0;0;0;0;0;0 +11.5;15;18960;2.4063;3;1500;0;0;0;0;0;0;0 +11.6;15;18960;2.4063;0;1500;0;0;0;0;0;0;0 +11.7;15;18960;2.4063;0;1500;0;0;0;0;0;0;0 +11.8;15;18960;2.4063;0;1500;0;0;0;0;0;0;0 +11.9;15;18960;2.4063;0;1500;0;0;0;0;0;0;0 +12;15;18960;2.4063;0;1500;0;0;0;0;0;0;0 +12.1;15;18960;2.4063;0;1500;0;0;0;0;0;0;0 +12.2;15;18960;2.4063;0;1500;0;0;0;0;0;0;0 +12.3;15;18960;2.4063;0;1500;0;0;0;0;0;0;0 +12.4;15;18960;2.4063;0;1500;0;0;0;0;0;0;0 +12.5;15;18960;2.4063;0;1500;0;0;0;0;0;0;0 +12.6;15;18960;2.4063;0;1500;0;0;0;0;0;0;0 +12.7;15;18960;2.4063;0;1500;0;0;0;0;0;0;0 +12.8;15;18960;2.4063;0;1500;0;0;0;0;0;0;0 +12.9;15;18960;2.4063;0;1500;0;0;0;0;0;0;0 +13;15;18960;2.4063;0;1500;0;0;0;0;0;0;0 +13.1;15;18960;2.4063;0;1500;0;0;0;0;0;0;0 +13.2;15;18960;2.4063;0;1500;0;0;0;0;0;0;0 +13.3;15;18960;2.4063;0;1500;0;0;0;0;0;0;0 +13.4;15;18960;2.4063;0;1500;0;0;0;0;0;0;0 +13.5;15;18960;2.4063;0;1500;0;0;0;0;0;0;0 +13.6;15;18960;2.4063;0;1500;0;0;0;0;0;0;0 +13.7;15;18960;2.4063;0;1500;0;0;0;0;0;0;0 +13.8;15;18960;2.4063;0;1500;0;0;0;0;0;0;0 +13.9;15;18960;2.4063;0;1500;0;0;0;0;0;0;0 +14;15;18960;2.4063;0;1500;0;0;0;0;0;0;0 diff --git a/openair1/SIMULATION/NR_PHY/BLER_SIMULATIONS/AWGN/AWGN_results/mcs16_awgn_5G.csv b/openair1/SIMULATION/NR_PHY/BLER_SIMULATIONS/AWGN/AWGN_results/mcs16_awgn_5G.csv new file mode 100644 index 0000000000..4f122de8c1 --- /dev/null +++ b/openair1/SIMULATION/NR_PHY/BLER_SIMULATIONS/AWGN/AWGN_results/mcs16_awgn_5G.csv @@ -0,0 +1,72 @@ +SNR;MCS;TBS;rate;err0;trials0;err1;trials1;err2;trials2;err3;trials3;dci_err +7;16;20496;2.5703;1500;1500;0;0;0;0;0;0;0 +7.1;16;20496;2.5703;1500;1500;0;0;0;0;0;0;0 +7.2;16;20496;2.5703;1500;1500;0;0;0;0;0;0;0 +7.3;16;20496;2.5703;1500;1500;0;0;0;0;0;0;0 +7.4;16;20496;2.5703;1500;1500;0;0;0;0;0;0;0 +7.5;16;20496;2.5703;1500;1500;0;0;0;0;0;0;0 +7.6;16;20496;2.5703;1500;1500;0;0;0;0;0;0;0 +7.7;16;20496;2.5703;1500;1500;0;0;0;0;0;0;0 +7.8;16;20496;2.5703;1500;1500;0;0;0;0;0;0;0 +7.9;16;20496;2.5703;1500;1500;0;0;0;0;0;0;0 +8;16;20496;2.5703;1500;1500;0;0;0;0;0;0;0 +8.1;16;20496;2.5703;1500;1500;0;0;0;0;0;0;0 +8.2;16;20496;2.5703;1500;1500;0;0;0;0;0;0;0 +8.3;16;20496;2.5703;1500;1500;0;0;0;0;0;0;0 +8.4;16;20496;2.5703;1500;1500;0;0;0;0;0;0;0 +8.5;16;20496;2.5703;1500;1500;0;0;0;0;0;0;0 +8.6;16;20496;2.5703;1500;1500;0;0;0;0;0;0;0 +8.7;16;20496;2.5703;1500;1500;0;0;0;0;0;0;0 +8.8;16;20496;2.5703;1500;1500;0;0;0;0;0;0;0 +8.9;16;20496;2.5703;1500;1500;0;0;0;0;0;0;0 +9;16;20496;2.5703;1500;1500;0;0;0;0;0;0;0 +9.1;16;20496;2.5703;1500;1500;0;0;0;0;0;0;0 +9.2;16;20496;2.5703;1500;1500;0;0;0;0;0;0;0 +9.3;16;20496;2.5703;1500;1500;0;0;0;0;0;0;0 +9.4;16;20496;2.5703;1500;1500;0;0;0;0;0;0;0 +9.5;16;20496;2.5703;1500;1500;0;0;0;0;0;0;0 +9.6;16;20496;2.5703;1500;1500;0;0;0;0;0;0;0 +9.7;16;20496;2.5703;1500;1500;0;0;0;0;0;0;0 +9.8;16;20496;2.5703;1500;1500;0;0;0;0;0;0;0 +9.9;16;20496;2.5703;1500;1500;0;0;0;0;0;0;0 +10;16;20496;2.5703;1500;1500;0;0;0;0;0;0;0 +10.1;16;20496;2.5703;1424;1500;0;0;0;0;0;0;0 +10.2;16;20496;2.5703;1352;1500;0;0;0;0;0;0;0 +10.3;16;20496;2.5703;1283;1500;0;0;0;0;0;0;0 +10.4;16;20496;2.5703;1218;1500;0;0;0;0;0;0;0 +10.5;16;20496;2.5703;1157;1500;0;0;0;0;0;0;0 +10.6;16;20496;2.5703;775;1500;0;0;0;0;0;0;0 +10.7;16;20496;2.5703;519;1500;0;0;0;0;0;0;0 +10.8;16;20496;2.5703;348;1500;0;0;0;0;0;0;0 +10.9;16;20496;2.5703;233;1500;0;0;0;0;0;0;0 +11;16;20496;2.5703;156;1500;0;0;0;0;0;0;0 +11.1;16;20496;2.5703;132;1500;0;0;0;0;0;0;0 +11.2;16;20496;2.5703;111;1500;0;0;0;0;0;0;0 +11.3;16;20496;2.5703;94;1500;0;0;0;0;0;0;0 +11.4;16;20496;2.5703;79;1500;0;0;0;0;0;0;0 +11.5;16;20496;2.5703;67;1500;0;0;0;0;0;0;0 +11.6;16;20496;2.5703;44;1500;0;0;0;0;0;0;0 +11.7;16;20496;2.5703;29;1500;0;0;0;0;0;0;0 +11.8;16;20496;2.5703;19;1500;0;0;0;0;0;0;0 +11.9;16;20496;2.5703;12;1500;0;0;0;0;0;0;0 +12;16;20496;2.5703;8;1500;0;0;0;0;0;0;0 +12.1;16;20496;2.5703;4;1500;0;0;0;0;0;0;0 +12.2;16;20496;2.5703;2;1500;0;0;0;0;0;0;0 +12.3;16;20496;2.5703;1;1500;0;0;0;0;0;0;0 +12.4;16;20496;2.5703;1;1500;0;0;0;0;0;0;0 +12.5;16;20496;2.5703;0;1500;0;0;0;0;0;0;0 +12.6;16;20496;2.5703;0;1500;0;0;0;0;0;0;0 +12.7;16;20496;2.5703;0;1500;0;0;0;0;0;0;0 +12.8;16;20496;2.5703;0;1500;0;0;0;0;0;0;0 +12.9;16;20496;2.5703;0;1500;0;0;0;0;0;0;0 +13;16;20496;2.5703;0;1500;0;0;0;0;0;0;0 +13.1;16;20496;2.5703;0;1500;0;0;0;0;0;0;0 +13.2;16;20496;2.5703;0;1500;0;0;0;0;0;0;0 +13.3;16;20496;2.5703;0;1500;0;0;0;0;0;0;0 +13.4;16;20496;2.5703;0;1500;0;0;0;0;0;0;0 +13.5;16;20496;2.5703;0;1500;0;0;0;0;0;0;0 +13.6;16;20496;2.5703;0;1500;0;0;0;0;0;0;0 +13.7;16;20496;2.5703;0;1500;0;0;0;0;0;0;0 +13.8;16;20496;2.5703;0;1500;0;0;0;0;0;0;0 +13.9;16;20496;2.5703;0;1500;0;0;0;0;0;0;0 +14;16;20496;2.5703;0;1500;0;0;0;0;0;0;0 diff --git a/openair1/SIMULATION/NR_PHY/BLER_SIMULATIONS/AWGN/AWGN_results/mcs17_awgn_5G.csv b/openair1/SIMULATION/NR_PHY/BLER_SIMULATIONS/AWGN/AWGN_results/mcs17_awgn_5G.csv new file mode 100644 index 0000000000..3254f76eb9 --- /dev/null +++ b/openair1/SIMULATION/NR_PHY/BLER_SIMULATIONS/AWGN/AWGN_results/mcs17_awgn_5G.csv @@ -0,0 +1,72 @@ +SNR;MCS;TBS;rate;err0;trials0;err1;trials1;err2;trials2;err3;trials3;dci_err +10;17;20496;2.5664;1500;1500;0;0;0;0;0;0;0 +10.1;17;20496;2.5664;1500;1500;0;0;0;0;0;0;0 +10.2;17;20496;2.5664;1500;1500;0;0;0;0;0;0;0 +10.3;17;20496;2.5664;1500;1500;0;0;0;0;0;0;0 +10.4;17;20496;2.5664;1500;1500;0;0;0;0;0;0;0 +10.5;17;20496;2.5664;1500;1500;0;0;0;0;0;0;0 +10.6;17;20496;2.5664;1498;1500;0;0;0;0;0;0;0 +10.7;17;20496;2.5664;1496;1500;0;0;0;0;0;0;0 +10.8;17;20496;2.5664;1494;1500;0;0;0;0;0;0;0 +10.9;17;20496;2.5664;1493;1500;0;0;0;0;0;0;0 +11;17;20496;2.5664;1491;1500;0;0;0;0;0;0;0 +11.1;17;20496;2.5664;1336;1500;0;0;0;0;0;0;0 +11.2;17;20496;2.5664;1197;1500;0;0;0;0;0;0;0 +11.3;17;20496;2.5664;1072;1500;0;0;0;0;0;0;0 +11.4;17;20496;2.5664;961;1500;0;0;0;0;0;0;0 +11.5;17;20496;2.5664;861;1500;0;0;0;0;0;0;0 +11.6;17;20496;2.5664;603;1500;0;0;0;0;0;0;0 +11.7;17;20496;2.5664;423;1500;0;0;0;0;0;0;0 +11.8;17;20496;2.5664;296;1500;0;0;0;0;0;0;0 +11.9;17;20496;2.5664;208;1500;0;0;0;0;0;0;0 +12;17;20496;2.5664;146;1500;0;0;0;0;0;0;0 +12.1;17;20496;2.5664;125;1500;0;0;0;0;0;0;0 +12.2;17;20496;2.5664;107;1500;0;0;0;0;0;0;0 +12.3;17;20496;2.5664;92;1500;0;0;0;0;0;0;0 +12.4;17;20496;2.5664;79;1500;0;0;0;0;0;0;0 +12.5;17;20496;2.5664;68;1500;0;0;0;0;0;0;0 +12.6;17;20496;2.5664;50;1500;0;0;0;0;0;0;0 +12.7;17;20496;2.5664;37;1500;0;0;0;0;0;0;0 +12.8;17;20496;2.5664;28;1500;0;0;0;0;0;0;0 +12.9;17;20496;2.5664;20;1500;0;0;0;0;0;0;0 +13;17;20496;2.5664;15;1500;0;0;0;0;0;0;0 +13.1;17;20496;2.5664;9;1500;0;0;0;0;0;0;0 +13.2;17;20496;2.5664;5;1500;0;0;0;0;0;0;0 +13.3;17;20496;2.5664;3;1500;0;0;0;0;0;0;0 +13.4;17;20496;2.5664;2;1500;0;0;0;0;0;0;0 +13.5;17;20496;2.5664;1;1500;0;0;0;0;0;0;0 +13.6;17;20496;2.5664;0;1500;0;0;0;0;0;0;0 +13.7;17;20496;2.5664;0;1500;0;0;0;0;0;0;0 +13.8;17;20496;2.5664;0;1500;0;0;0;0;0;0;0 +13.9;17;20496;2.5664;0;1500;0;0;0;0;0;0;0 +14;17;20496;2.5664;0;1500;0;0;0;0;0;0;0 +14.1;17;20496;2.5664;0;1500;0;0;0;0;0;0;0 +14.2;17;20496;2.5664;0;1500;0;0;0;0;0;0;0 +14.3;17;20496;2.5664;0;1500;0;0;0;0;0;0;0 +14.4;17;20496;2.5664;0;1500;0;0;0;0;0;0;0 +14.5;17;20496;2.5664;0;1500;0;0;0;0;0;0;0 +14.6;17;20496;2.5664;0;1500;0;0;0;0;0;0;0 +14.7;17;20496;2.5664;0;1500;0;0;0;0;0;0;0 +14.8;17;20496;2.5664;0;1500;0;0;0;0;0;0;0 +14.9;17;20496;2.5664;0;1500;0;0;0;0;0;0;0 +15;17;20496;2.5664;0;1500;0;0;0;0;0;0;0 +15.1;17;20496;2.5664;0;1500;0;0;0;0;0;0;0 +15.2;17;20496;2.5664;0;1500;0;0;0;0;0;0;0 +15.3;17;20496;2.5664;0;1500;0;0;0;0;0;0;0 +15.4;17;20496;2.5664;0;1500;0;0;0;0;0;0;0 +15.5;17;20496;2.5664;0;1500;0;0;0;0;0;0;0 +15.6;17;20496;2.5664;0;1500;0;0;0;0;0;0;0 +15.7;17;20496;2.5664;0;1500;0;0;0;0;0;0;0 +15.8;17;20496;2.5664;0;1500;0;0;0;0;0;0;0 +15.9;17;20496;2.5664;0;1500;0;0;0;0;0;0;0 +16;17;20496;2.5664;0;1500;0;0;0;0;0;0;0 +16.1;17;20496;2.5664;0;1500;0;0;0;0;0;0;0 +16.2;17;20496;2.5664;0;1500;0;0;0;0;0;0;0 +16.3;17;20496;2.5664;0;1500;0;0;0;0;0;0;0 +16.4;17;20496;2.5664;0;1500;0;0;0;0;0;0;0 +16.5;17;20496;2.5664;0;1500;0;0;0;0;0;0;0 +16.6;17;20496;2.5664;0;1500;0;0;0;0;0;0;0 +16.7;17;20496;2.5664;0;1500;0;0;0;0;0;0;0 +16.8;17;20496;2.5664;0;1500;0;0;0;0;0;0;0 +16.9;17;20496;2.5664;0;1500;0;0;0;0;0;0;0 +17;17;20496;2.5664;0;1500;0;0;0;0;0;0;0 diff --git a/openair1/SIMULATION/NR_PHY/BLER_SIMULATIONS/AWGN/AWGN_results/mcs18_awgn_5G.csv b/openair1/SIMULATION/NR_PHY/BLER_SIMULATIONS/AWGN/AWGN_results/mcs18_awgn_5G.csv new file mode 100644 index 0000000000..67ede60066 --- /dev/null +++ b/openair1/SIMULATION/NR_PHY/BLER_SIMULATIONS/AWGN/AWGN_results/mcs18_awgn_5G.csv @@ -0,0 +1,72 @@ +SNR;MCS;TBS;rate;err0;trials0;err1;trials1;err2;trials2;err3;trials3;dci_err +10;18;21504;2.7305;1500;1500;0;0;0;0;0;0;0 +10.1;18;21504;2.7305;1500;1500;0;0;0;0;0;0;0 +10.2;18;21504;2.7305;1500;1500;0;0;0;0;0;0;0 +10.3;18;21504;2.7305;1500;1500;0;0;0;0;0;0;0 +10.4;18;21504;2.7305;1500;1500;0;0;0;0;0;0;0 +10.5;18;21504;2.7305;1500;1500;0;0;0;0;0;0;0 +10.6;18;21504;2.7305;1500;1500;0;0;0;0;0;0;0 +10.7;18;21504;2.7305;1500;1500;0;0;0;0;0;0;0 +10.8;18;21504;2.7305;1500;1500;0;0;0;0;0;0;0 +10.9;18;21504;2.7305;1500;1500;0;0;0;0;0;0;0 +11;18;21504;2.7305;1500;1500;0;0;0;0;0;0;0 +11.1;18;21504;2.7305;1499;1500;0;0;0;0;0;0;0 +11.2;18;21504;2.7305;1499;1500;0;0;0;0;0;0;0 +11.3;18;21504;2.7305;1498;1500;0;0;0;0;0;0;0 +11.4;18;21504;2.7305;1498;1500;0;0;0;0;0;0;0 +11.5;18;21504;2.7305;1497;1500;0;0;0;0;0;0;0 +11.6;18;21504;2.7305;1399;1500;0;0;0;0;0;0;0 +11.7;18;21504;2.7305;1307;1500;0;0;0;0;0;0;0 +11.8;18;21504;2.7305;1221;1500;0;0;0;0;0;0;0 +11.9;18;21504;2.7305;1141;1500;0;0;0;0;0;0;0 +12;18;21504;2.7305;1066;1500;0;0;0;0;0;0;0 +12.1;18;21504;2.7305;788;1500;0;0;0;0;0;0;0 +12.2;18;21504;2.7305;582;1500;0;0;0;0;0;0;0 +12.3;18;21504;2.7305;431;1500;0;0;0;0;0;0;0 +12.4;18;21504;2.7305;318;1500;0;0;0;0;0;0;0 +12.5;18;21504;2.7305;235;1500;0;0;0;0;0;0;0 +12.6;18;21504;2.7305;185;1500;0;0;0;0;0;0;0 +12.7;18;21504;2.7305;146;1500;0;0;0;0;0;0;0 +12.8;18;21504;2.7305;115;1500;0;0;0;0;0;0;0 +12.9;18;21504;2.7305;90;1500;0;0;0;0;0;0;0 +13;18;21504;2.7305;71;1500;0;0;0;0;0;0;0 +13.1;18;21504;2.7305;50;1500;0;0;0;0;0;0;0 +13.2;18;21504;2.7305;35;1500;0;0;0;0;0;0;0 +13.3;18;21504;2.7305;25;1500;0;0;0;0;0;0;0 +13.4;18;21504;2.7305;18;1500;0;0;0;0;0;0;0 +13.5;18;21504;2.7305;12;1500;0;0;0;0;0;0;0 +13.6;18;21504;2.7305;7;1500;0;0;0;0;0;0;0 +13.7;18;21504;2.7305;3;1500;0;0;0;0;0;0;0 +13.8;18;21504;2.7305;2;1500;0;0;0;0;0;0;0 +13.9;18;21504;2.7305;1;1500;0;0;0;0;0;0;0 +14;18;21504;2.7305;1;1500;0;0;0;0;0;0;0 +14.1;18;21504;2.7305;0;1500;0;0;0;0;0;0;0 +14.2;18;21504;2.7305;0;1500;0;0;0;0;0;0;0 +14.3;18;21504;2.7305;0;1500;0;0;0;0;0;0;0 +14.4;18;21504;2.7305;0;1500;0;0;0;0;0;0;0 +14.5;18;21504;2.7305;0;1500;0;0;0;0;0;0;0 +14.6;18;21504;2.7305;0;1500;0;0;0;0;0;0;0 +14.7;18;21504;2.7305;0;1500;0;0;0;0;0;0;0 +14.8;18;21504;2.7305;0;1500;0;0;0;0;0;0;0 +14.9;18;21504;2.7305;0;1500;0;0;0;0;0;0;0 +15;18;21504;2.7305;0;1500;0;0;0;0;0;0;0 +15.1;18;21504;2.7305;0;1500;0;0;0;0;0;0;0 +15.2;18;21504;2.7305;0;1500;0;0;0;0;0;0;0 +15.3;18;21504;2.7305;0;1500;0;0;0;0;0;0;0 +15.4;18;21504;2.7305;0;1500;0;0;0;0;0;0;0 +15.5;18;21504;2.7305;0;1500;0;0;0;0;0;0;0 +15.6;18;21504;2.7305;0;1500;0;0;0;0;0;0;0 +15.7;18;21504;2.7305;0;1500;0;0;0;0;0;0;0 +15.8;18;21504;2.7305;0;1500;0;0;0;0;0;0;0 +15.9;18;21504;2.7305;0;1500;0;0;0;0;0;0;0 +16;18;21504;2.7305;0;1500;0;0;0;0;0;0;0 +16.1;18;21504;2.7305;0;1500;0;0;0;0;0;0;0 +16.2;18;21504;2.7305;0;1500;0;0;0;0;0;0;0 +16.3;18;21504;2.7305;0;1500;0;0;0;0;0;0;0 +16.4;18;21504;2.7305;0;1500;0;0;0;0;0;0;0 +16.5;18;21504;2.7305;0;1500;0;0;0;0;0;0;0 +16.6;18;21504;2.7305;0;1500;0;0;0;0;0;0;0 +16.7;18;21504;2.7305;0;1500;0;0;0;0;0;0;0 +16.8;18;21504;2.7305;0;1500;0;0;0;0;0;0;0 +16.9;18;21504;2.7305;0;1500;0;0;0;0;0;0;0 +17;18;21504;2.7305;0;1500;0;0;0;0;0;0;0 diff --git a/openair1/SIMULATION/NR_PHY/BLER_SIMULATIONS/AWGN/AWGN_results/mcs19_awgn_5G.csv b/openair1/SIMULATION/NR_PHY/BLER_SIMULATIONS/AWGN/AWGN_results/mcs19_awgn_5G.csv new file mode 100644 index 0000000000..3d18bd7987 --- /dev/null +++ b/openair1/SIMULATION/NR_PHY/BLER_SIMULATIONS/AWGN/AWGN_results/mcs19_awgn_5G.csv @@ -0,0 +1,72 @@ +SNR;MCS;TBS;rate;err0;trials0;err1;trials1;err2;trials2;err3;trials3;dci_err +10;19;24072;3.0293;1500;1500;0;0;0;0;0;0;0 +10.1;19;24072;3.0293;1500;1500;0;0;0;0;0;0;0 +10.2;19;24072;3.0293;1500;1500;0;0;0;0;0;0;0 +10.3;19;24072;3.0293;1500;1500;0;0;0;0;0;0;0 +10.4;19;24072;3.0293;1500;1500;0;0;0;0;0;0;0 +10.5;19;24072;3.0293;1500;1500;0;0;0;0;0;0;0 +10.6;19;24072;3.0293;1500;1500;0;0;0;0;0;0;0 +10.7;19;24072;3.0293;1500;1500;0;0;0;0;0;0;0 +10.8;19;24072;3.0293;1500;1500;0;0;0;0;0;0;0 +10.9;19;24072;3.0293;1500;1500;0;0;0;0;0;0;0 +11;19;24072;3.0293;1500;1500;0;0;0;0;0;0;0 +11.1;19;24072;3.0293;1500;1500;0;0;0;0;0;0;0 +11.2;19;24072;3.0293;1500;1500;0;0;0;0;0;0;0 +11.3;19;24072;3.0293;1500;1500;0;0;0;0;0;0;0 +11.4;19;24072;3.0293;1500;1500;0;0;0;0;0;0;0 +11.5;19;24072;3.0293;1500;1500;0;0;0;0;0;0;0 +11.6;19;24072;3.0293;1500;1500;0;0;0;0;0;0;0 +11.7;19;24072;3.0293;1500;1500;0;0;0;0;0;0;0 +11.8;19;24072;3.0293;1500;1500;0;0;0;0;0;0;0 +11.9;19;24072;3.0293;1500;1500;0;0;0;0;0;0;0 +12;19;24072;3.0293;1500;1500;0;0;0;0;0;0;0 +12.1;19;24072;3.0293;1499;1500;0;0;0;0;0;0;0 +12.2;19;24072;3.0293;1499;1500;0;0;0;0;0;0;0 +12.3;19;24072;3.0293;1498;1500;0;0;0;0;0;0;0 +12.4;19;24072;3.0293;1497;1500;0;0;0;0;0;0;0 +12.5;19;24072;3.0293;1497;1500;0;0;0;0;0;0;0 +12.6;19;24072;3.0293;1389;1500;0;0;0;0;0;0;0 +12.7;19;24072;3.0293;1290;1500;0;0;0;0;0;0;0 +12.8;19;24072;3.0293;1197;1500;0;0;0;0;0;0;0 +12.9;19;24072;3.0293;1111;1500;0;0;0;0;0;0;0 +13;19;24072;3.0293;1032;1500;0;0;0;0;0;0;0 +13.1;19;24072;3.0293;746;1500;0;0;0;0;0;0;0 +13.2;19;24072;3.0293;539;1500;0;0;0;0;0;0;0 +13.3;19;24072;3.0293;390;1500;0;0;0;0;0;0;0 +13.4;19;24072;3.0293;282;1500;0;0;0;0;0;0;0 +13.5;19;24072;3.0293;204;1500;0;0;0;0;0;0;0 +13.6;19;24072;3.0293;166;1500;0;0;0;0;0;0;0 +13.7;19;24072;3.0293;135;1500;0;0;0;0;0;0;0 +13.8;19;24072;3.0293;110;1500;0;0;0;0;0;0;0 +13.9;19;24072;3.0293;89;1500;0;0;0;0;0;0;0 +14;19;24072;3.0293;73;1500;0;0;0;0;0;0;0 +14.1;19;24072;3.0293;54;1500;0;0;0;0;0;0;0 +14.2;19;24072;3.0293;41;1500;0;0;0;0;0;0;0 +14.3;19;24072;3.0293;30;1500;0;0;0;0;0;0;0 +14.4;19;24072;3.0293;23;1500;0;0;0;0;0;0;0 +14.5;19;24072;3.0293;17;1500;0;0;0;0;0;0;0 +14.6;19;24072;3.0293;9;1500;0;0;0;0;0;0;0 +14.7;19;24072;3.0293;5;1500;0;0;0;0;0;0;0 +14.8;19;24072;3.0293;3;1500;0;0;0;0;0;0;0 +14.9;19;24072;3.0293;2;1500;0;0;0;0;0;0;0 +15;19;24072;3.0293;1;1500;0;0;0;0;0;0;0 +15.1;19;24072;3.0293;0;1500;0;0;0;0;0;0;0 +15.2;19;24072;3.0293;0;1500;0;0;0;0;0;0;0 +15.3;19;24072;3.0293;0;1500;0;0;0;0;0;0;0 +15.4;19;24072;3.0293;0;1500;0;0;0;0;0;0;0 +15.5;19;24072;3.0293;0;1500;0;0;0;0;0;0;0 +15.6;19;24072;3.0293;0;1500;0;0;0;0;0;0;0 +15.7;19;24072;3.0293;0;1500;0;0;0;0;0;0;0 +15.8;19;24072;3.0293;0;1500;0;0;0;0;0;0;0 +15.9;19;24072;3.0293;0;1500;0;0;0;0;0;0;0 +16;19;24072;3.0293;0;1500;0;0;0;0;0;0;0 +16.1;19;24072;3.0293;0;1500;0;0;0;0;0;0;0 +16.2;19;24072;3.0293;0;1500;0;0;0;0;0;0;0 +16.3;19;24072;3.0293;0;1500;0;0;0;0;0;0;0 +16.4;19;24072;3.0293;0;1500;0;0;0;0;0;0;0 +16.5;19;24072;3.0293;0;1500;0;0;0;0;0;0;0 +16.6;19;24072;3.0293;0;1500;0;0;0;0;0;0;0 +16.7;19;24072;3.0293;0;1500;0;0;0;0;0;0;0 +16.8;19;24072;3.0293;0;1500;0;0;0;0;0;0;0 +16.9;19;24072;3.0293;0;1500;0;0;0;0;0;0;0 +17;19;24072;3.0293;0;1500;0;0;0;0;0;0;0 diff --git a/openair1/SIMULATION/NR_PHY/BLER_SIMULATIONS/AWGN/AWGN_results/mcs1_awgn_5G.csv b/openair1/SIMULATION/NR_PHY/BLER_SIMULATIONS/AWGN/AWGN_results/mcs1_awgn_5G.csv new file mode 100644 index 0000000000..ccb17b0d1c --- /dev/null +++ b/openair1/SIMULATION/NR_PHY/BLER_SIMULATIONS/AWGN/AWGN_results/mcs1_awgn_5G.csv @@ -0,0 +1,27 @@ +SNR;MCS;TBS;rate;err0;trials0;err1;trials1;err2;trials2;err3;trials3;dci_err +-4;1;2472;0.3066;1500;1500;0;0;0;0;0;0;0 +-3.9;1;2472;0.3066;1497;1500;0;0;0;0;0;0;0 +-3.8;1;2472;0.3066;1494;1500;0;0;0;0;0;0;0 +-3.7;1;2472;0.3066;1490;1500;0;0;0;0;0;0;0 +-3.6;1;2472;0.3066;1487;1500;0;0;0;0;0;0;0 +-3.5;1;2472;0.3066;1484;1500;0;0;0;0;0;0;0 +-3.4;1;2472;0.3066;1386;1500;0;0;0;0;0;0;0 +-3.3;1;2472;0.3066;1295;1500;0;0;0;0;0;0;0 +-3.2;1;2472;0.3066;1209;1500;0;0;0;0;0;0;0 +-3.1;1;2472;0.3066;1130;1500;0;0;0;0;0;0;0 +-3;1;2472;0.3066;1055;1500;0;0;0;0;0;0;0 +-2.9;1;2472;0.3066;863;1500;0;0;0;0;0;0;0 +-2.8;1;2472;0.3066;706;1500;0;0;0;0;0;0;0 +-2.7;1;2472;0.3066;577;1500;0;0;0;0;0;0;0 +-2.6;1;2472;0.3066;472;1500;0;0;0;0;0;0;0 +-2.5;1;2472;0.3066;386;1500;0;0;0;0;0;0;0 +-2.4;1;2472;0.3066;215;1500;0;0;0;0;0;0;0 +-2.3;1;2472;0.3066;120;1500;0;0;0;0;0;0;0 +-2.2;1;2472;0.3066;67;1500;0;0;0;0;0;0;0 +-2.1;1;2472;0.3066;37;1500;0;0;0;0;0;0;0 +-2;1;2472;0.3066;21;1500;0;0;0;0;0;0;0 +-1.9;1;2472;0.3066;9;1500;0;0;0;0;0;0;0 +-1.8;1;2472;0.3066;4;1500;0;0;0;0;0;0;0 +-1.7;1;2472;0.3066;2;1500;0;0;0;0;0;0;0 +-1.6;1;2472;0.3066;1;1500;0;0;0;0;0;0;0 +-1.5;1;2472;0.3066;0;1500;0;0;0;0;0;0;0 diff --git a/openair1/SIMULATION/NR_PHY/BLER_SIMULATIONS/AWGN/AWGN_results/mcs20_awgn_5G.csv b/openair1/SIMULATION/NR_PHY/BLER_SIMULATIONS/AWGN/AWGN_results/mcs20_awgn_5G.csv new file mode 100644 index 0000000000..69d0055395 --- /dev/null +++ b/openair1/SIMULATION/NR_PHY/BLER_SIMULATIONS/AWGN/AWGN_results/mcs20_awgn_5G.csv @@ -0,0 +1,72 @@ +SNR;MCS;TBS;rate;err0;trials0;err1;trials1;err2;trials2;err3;trials3;dci_err +10;20;26632;3.3223;1500;1500;0;0;0;0;0;0;0 +10.1;20;26632;3.3223;1500;1500;0;0;0;0;0;0;0 +10.2;20;26632;3.3223;1500;1500;0;0;0;0;0;0;0 +10.3;20;26632;3.3223;1500;1500;0;0;0;0;0;0;0 +10.4;20;26632;3.3223;1500;1500;0;0;0;0;0;0;0 +10.5;20;26632;3.3223;1500;1500;0;0;0;0;0;0;0 +10.6;20;26632;3.3223;1500;1500;0;0;0;0;0;0;0 +10.7;20;26632;3.3223;1500;1500;0;0;0;0;0;0;0 +10.8;20;26632;3.3223;1500;1500;0;0;0;0;0;0;0 +10.9;20;26632;3.3223;1500;1500;0;0;0;0;0;0;0 +11;20;26632;3.3223;1500;1500;0;0;0;0;0;0;0 +11.1;20;26632;3.3223;1500;1500;0;0;0;0;0;0;0 +11.2;20;26632;3.3223;1500;1500;0;0;0;0;0;0;0 +11.3;20;26632;3.3223;1500;1500;0;0;0;0;0;0;0 +11.4;20;26632;3.3223;1500;1500;0;0;0;0;0;0;0 +11.5;20;26632;3.3223;1500;1500;0;0;0;0;0;0;0 +11.6;20;26632;3.3223;1500;1500;0;0;0;0;0;0;0 +11.7;20;26632;3.3223;1500;1500;0;0;0;0;0;0;0 +11.8;20;26632;3.3223;1500;1500;0;0;0;0;0;0;0 +11.9;20;26632;3.3223;1500;1500;0;0;0;0;0;0;0 +12;20;26632;3.3223;1500;1500;0;0;0;0;0;0;0 +12.1;20;26632;3.3223;1500;1500;0;0;0;0;0;0;0 +12.2;20;26632;3.3223;1500;1500;0;0;0;0;0;0;0 +12.3;20;26632;3.3223;1500;1500;0;0;0;0;0;0;0 +12.4;20;26632;3.3223;1500;1500;0;0;0;0;0;0;0 +12.5;20;26632;3.3223;1500;1500;0;0;0;0;0;0;0 +12.6;20;26632;3.3223;1500;1500;0;0;0;0;0;0;0 +12.7;20;26632;3.3223;1500;1500;0;0;0;0;0;0;0 +12.8;20;26632;3.3223;1500;1500;0;0;0;0;0;0;0 +12.9;20;26632;3.3223;1500;1500;0;0;0;0;0;0;0 +13;20;26632;3.3223;1500;1500;0;0;0;0;0;0;0 +13.1;20;26632;3.3223;1499;1500;0;0;0;0;0;0;0 +13.2;20;26632;3.3223;1499;1500;0;0;0;0;0;0;0 +13.3;20;26632;3.3223;1498;1500;0;0;0;0;0;0;0 +13.4;20;26632;3.3223;1498;1500;0;0;0;0;0;0;0 +13.5;20;26632;3.3223;1497;1500;0;0;0;0;0;0;0 +13.6;20;26632;3.3223;1390;1500;0;0;0;0;0;0;0 +13.7;20;26632;3.3223;1291;1500;0;0;0;0;0;0;0 +13.8;20;26632;3.3223;1199;1500;0;0;0;0;0;0;0 +13.9;20;26632;3.3223;1113;1500;0;0;0;0;0;0;0 +14;20;26632;3.3223;1034;1500;0;0;0;0;0;0;0 +14.1;20;26632;3.3223;745;1500;0;0;0;0;0;0;0 +14.2;20;26632;3.3223;537;1500;0;0;0;0;0;0;0 +14.3;20;26632;3.3223;387;1500;0;0;0;0;0;0;0 +14.4;20;26632;3.3223;279;1500;0;0;0;0;0;0;0 +14.5;20;26632;3.3223;201;1500;0;0;0;0;0;0;0 +14.6;20;26632;3.3223;161;1500;0;0;0;0;0;0;0 +14.7;20;26632;3.3223;129;1500;0;0;0;0;0;0;0 +14.8;20;26632;3.3223;104;1500;0;0;0;0;0;0;0 +14.9;20;26632;3.3223;83;1500;0;0;0;0;0;0;0 +15;20;26632;3.3223;67;1500;0;0;0;0;0;0;0 +15.1;20;26632;3.3223;45;1500;0;0;0;0;0;0;0 +15.2;20;26632;3.3223;30;1500;0;0;0;0;0;0;0 +15.3;20;26632;3.3223;20;1500;0;0;0;0;0;0;0 +15.4;20;26632;3.3223;13;1500;0;0;0;0;0;0;0 +15.5;20;26632;3.3223;9;1500;0;0;0;0;0;0;0 +15.6;20;26632;3.3223;4;1500;0;0;0;0;0;0;0 +15.7;20;26632;3.3223;1;1500;0;0;0;0;0;0;0 +15.8;20;26632;3.3223;1;1500;0;0;0;0;0;0;0 +15.9;20;26632;3.3223;0;1500;0;0;0;0;0;0;0 +16;20;26632;3.3223;0;1500;0;0;0;0;0;0;0 +16.1;20;26632;3.3223;0;1500;0;0;0;0;0;0;0 +16.2;20;26632;3.3223;0;1500;0;0;0;0;0;0;0 +16.3;20;26632;3.3223;0;1500;0;0;0;0;0;0;0 +16.4;20;26632;3.3223;0;1500;0;0;0;0;0;0;0 +16.5;20;26632;3.3223;0;1500;0;0;0;0;0;0;0 +16.6;20;26632;3.3223;0;1500;0;0;0;0;0;0;0 +16.7;20;26632;3.3223;0;1500;0;0;0;0;0;0;0 +16.8;20;26632;3.3223;0;1500;0;0;0;0;0;0;0 +16.9;20;26632;3.3223;0;1500;0;0;0;0;0;0;0 +17;20;26632;3.3223;0;1500;0;0;0;0;0;0;0 diff --git a/openair1/SIMULATION/NR_PHY/BLER_SIMULATIONS/AWGN/AWGN_results/mcs21_awgn_5G.csv b/openair1/SIMULATION/NR_PHY/BLER_SIMULATIONS/AWGN/AWGN_results/mcs21_awgn_5G.csv new file mode 100644 index 0000000000..2a5a691afb --- /dev/null +++ b/openair1/SIMULATION/NR_PHY/BLER_SIMULATIONS/AWGN/AWGN_results/mcs21_awgn_5G.csv @@ -0,0 +1,72 @@ +SNR;MCS;TBS;rate;err0;trials0;err1;trials1;err2;trials2;err3;trials3;dci_err +10;21;28680;3.6094;1500;1500;0;0;0;0;0;0;0 +10.1;21;28680;3.6094;1500;1500;0;0;0;0;0;0;0 +10.2;21;28680;3.6094;1500;1500;0;0;0;0;0;0;0 +10.3;21;28680;3.6094;1500;1500;0;0;0;0;0;0;0 +10.4;21;28680;3.6094;1500;1500;0;0;0;0;0;0;0 +10.5;21;28680;3.6094;1500;1500;0;0;0;0;0;0;0 +10.6;21;28680;3.6094;1500;1500;0;0;0;0;0;0;0 +10.7;21;28680;3.6094;1500;1500;0;0;0;0;0;0;0 +10.8;21;28680;3.6094;1500;1500;0;0;0;0;0;0;0 +10.9;21;28680;3.6094;1500;1500;0;0;0;0;0;0;0 +11;21;28680;3.6094;1500;1500;0;0;0;0;0;0;0 +11.1;21;28680;3.6094;1500;1500;0;0;0;0;0;0;0 +11.2;21;28680;3.6094;1500;1500;0;0;0;0;0;0;0 +11.3;21;28680;3.6094;1500;1500;0;0;0;0;0;0;0 +11.4;21;28680;3.6094;1500;1500;0;0;0;0;0;0;0 +11.5;21;28680;3.6094;1500;1500;0;0;0;0;0;0;0 +11.6;21;28680;3.6094;1500;1500;0;0;0;0;0;0;0 +11.7;21;28680;3.6094;1500;1500;0;0;0;0;0;0;0 +11.8;21;28680;3.6094;1500;1500;0;0;0;0;0;0;0 +11.9;21;28680;3.6094;1500;1500;0;0;0;0;0;0;0 +12;21;28680;3.6094;1500;1500;0;0;0;0;0;0;0 +12.1;21;28680;3.6094;1500;1500;0;0;0;0;0;0;0 +12.2;21;28680;3.6094;1500;1500;0;0;0;0;0;0;0 +12.3;21;28680;3.6094;1500;1500;0;0;0;0;0;0;0 +12.4;21;28680;3.6094;1500;1500;0;0;0;0;0;0;0 +12.5;21;28680;3.6094;1500;1500;0;0;0;0;0;0;0 +12.6;21;28680;3.6094;1500;1500;0;0;0;0;0;0;0 +12.7;21;28680;3.6094;1500;1500;0;0;0;0;0;0;0 +12.8;21;28680;3.6094;1500;1500;0;0;0;0;0;0;0 +12.9;21;28680;3.6094;1500;1500;0;0;0;0;0;0;0 +13;21;28680;3.6094;1500;1500;0;0;0;0;0;0;0 +13.1;21;28680;3.6094;1500;1500;0;0;0;0;0;0;0 +13.2;21;28680;3.6094;1500;1500;0;0;0;0;0;0;0 +13.3;21;28680;3.6094;1500;1500;0;0;0;0;0;0;0 +13.4;21;28680;3.6094;1500;1500;0;0;0;0;0;0;0 +13.5;21;28680;3.6094;1500;1500;0;0;0;0;0;0;0 +13.6;21;28680;3.6094;1500;1500;0;0;0;0;0;0;0 +13.7;21;28680;3.6094;1500;1500;0;0;0;0;0;0;0 +13.8;21;28680;3.6094;1500;1500;0;0;0;0;0;0;0 +13.9;21;28680;3.6094;1500;1500;0;0;0;0;0;0;0 +14;21;28680;3.6094;1500;1500;0;0;0;0;0;0;0 +14.1;21;28680;3.6094;1472;1500;0;0;0;0;0;0;0 +14.2;21;28680;3.6094;1444;1500;0;0;0;0;0;0;0 +14.3;21;28680;3.6094;1417;1500;0;0;0;0;0;0;0 +14.4;21;28680;3.6094;1390;1500;0;0;0;0;0;0;0 +14.5;21;28680;3.6094;1364;1500;0;0;0;0;0;0;0 +14.6;21;28680;3.6094;1040;1500;0;0;0;0;0;0;0 +14.7;21;28680;3.6094;793;1500;0;0;0;0;0;0;0 +14.8;21;28680;3.6094;605;1500;0;0;0;0;0;0;0 +14.9;21;28680;3.6094;461;1500;0;0;0;0;0;0;0 +15;21;28680;3.6094;351;1500;0;0;0;0;0;0;0 +15.1;21;28680;3.6094;265;1500;0;0;0;0;0;0;0 +15.2;21;28680;3.6094;199;1500;0;0;0;0;0;0;0 +15.3;21;28680;3.6094;150;1500;0;0;0;0;0;0;0 +15.4;21;28680;3.6094;113;1500;0;0;0;0;0;0;0 +15.5;21;28680;3.6094;85;1500;0;0;0;0;0;0;0 +15.6;21;28680;3.6094;79;1500;0;0;0;0;0;0;0 +15.7;21;28680;3.6094;73;1500;0;0;0;0;0;0;0 +15.8;21;28680;3.6094;67;1500;0;0;0;0;0;0;0 +15.9;21;28680;3.6094;62;1500;0;0;0;0;0;0;0 +16;21;28680;3.6094;57;1500;0;0;0;0;0;0;0 +16.1;21;28680;3.6094;37;1500;0;0;0;0;0;0;0 +16.2;21;28680;3.6094;23;1500;0;0;0;0;0;0;0 +16.3;21;28680;3.6094;15;1500;0;0;0;0;0;0;0 +16.4;21;28680;3.6094;10;1500;0;0;0;0;0;0;0 +16.5;21;28680;3.6094;6;1500;0;0;0;0;0;0;0 +16.6;21;28680;3.6094;3;1500;0;0;0;0;0;0;0 +16.7;21;28680;3.6094;1;1500;0;0;0;0;0;0;0 +16.8;21;28680;3.6094;1;1500;0;0;0;0;0;0;0 +16.9;21;28680;3.6094;0;1500;0;0;0;0;0;0;0 +17;21;28680;3.6094;0;1500;0;0;0;0;0;0;0 diff --git a/openair1/SIMULATION/NR_PHY/BLER_SIMULATIONS/AWGN/AWGN_results/mcs22_awgn_5G.csv b/openair1/SIMULATION/NR_PHY/BLER_SIMULATIONS/AWGN/AWGN_results/mcs22_awgn_5G.csv new file mode 100644 index 0000000000..10a4241376 --- /dev/null +++ b/openair1/SIMULATION/NR_PHY/BLER_SIMULATIONS/AWGN/AWGN_results/mcs22_awgn_5G.csv @@ -0,0 +1,52 @@ +SNR;MCS;TBS;rate;err0;trials0;err1;trials1;err2;trials2;err3;trials3;dci_err +14;22;31240;3.9023;1500;1500;0;0;0;0;0;0;0 +14.1;22;31240;3.9023;1500;1500;0;0;0;0;0;0;0 +14.2;22;31240;3.9023;1500;1500;0;0;0;0;0;0;0 +14.3;22;31240;3.9023;1500;1500;0;0;0;0;0;0;0 +14.4;22;31240;3.9023;1500;1500;0;0;0;0;0;0;0 +14.5;22;31240;3.9023;1500;1500;0;0;0;0;0;0;0 +14.6;22;31240;3.9023;1500;1500;0;0;0;0;0;0;0 +14.7;22;31240;3.9023;1500;1500;0;0;0;0;0;0;0 +14.8;22;31240;3.9023;1500;1500;0;0;0;0;0;0;0 +14.9;22;31240;3.9023;1500;1500;0;0;0;0;0;0;0 +15;22;31240;3.9023;1500;1500;0;0;0;0;0;0;0 +15.1;22;31240;3.9023;1421;1500;0;0;0;0;0;0;0 +15.2;22;31240;3.9023;1347;1500;0;0;0;0;0;0;0 +15.3;22;31240;3.9023;1276;1500;0;0;0;0;0;0;0 +15.4;22;31240;3.9023;1209;1500;0;0;0;0;0;0;0 +15.5;22;31240;3.9023;1146;1500;0;0;0;0;0;0;0 +15.6;22;31240;3.9023;807;1500;0;0;0;0;0;0;0 +15.7;22;31240;3.9023;569;1500;0;0;0;0;0;0;0 +15.8;22;31240;3.9023;400;1500;0;0;0;0;0;0;0 +15.9;22;31240;3.9023;282;1500;0;0;0;0;0;0;0 +16;22;31240;3.9023;199;1500;0;0;0;0;0;0;0 +16.1;22;31240;3.9023;165;1500;0;0;0;0;0;0;0 +16.2;22;31240;3.9023;137;1500;0;0;0;0;0;0;0 +16.3;22;31240;3.9023;114;1500;0;0;0;0;0;0;0 +16.4;22;31240;3.9023;94;1500;0;0;0;0;0;0;0 +16.5;22;31240;3.9023;78;1500;0;0;0;0;0;0;0 +16.6;22;31240;3.9023;74;1500;0;0;0;0;0;0;0 +16.7;22;31240;3.9023;69;1500;0;0;0;0;0;0;0 +16.8;22;31240;3.9023;65;1500;0;0;0;0;0;0;0 +16.9;22;31240;3.9023;61;1500;0;0;0;0;0;0;0 +17;22;31240;3.9023;58;1500;0;0;0;0;0;0;0 +17.1;22;31240;3.9023;36;1500;0;0;0;0;0;0;0 +17.2;22;31240;3.9023;23;1500;0;0;0;0;0;0;0 +17.3;22;31240;3.9023;15;1500;0;0;0;0;0;0;0 +17.4;22;31240;3.9023;9;1500;0;0;0;0;0;0;0 +17.5;22;31240;3.9023;6;1500;0;0;0;0;0;0;0 +17.6;22;31240;3.9023;3;1500;0;0;0;0;0;0;0 +17.7;22;31240;3.9023;1;1500;0;0;0;0;0;0;0 +17.8;22;31240;3.9023;1;1500;0;0;0;0;0;0;0 +17.9;22;31240;3.9023;0;1500;0;0;0;0;0;0;0 +18;22;31240;3.9023;0;1500;0;0;0;0;0;0;0 +18.1;22;31240;3.9023;0;1500;0;0;0;0;0;0;0 +18.2;22;31240;3.9023;0;1500;0;0;0;0;0;0;0 +18.3;22;31240;3.9023;0;1500;0;0;0;0;0;0;0 +18.4;22;31240;3.9023;0;1500;0;0;0;0;0;0;0 +18.5;22;31240;3.9023;0;1500;0;0;0;0;0;0;0 +18.6;22;31240;3.9023;0;1500;0;0;0;0;0;0;0 +18.7;22;31240;3.9023;0;1500;0;0;0;0;0;0;0 +18.8;22;31240;3.9023;0;1500;0;0;0;0;0;0;0 +18.9;22;31240;3.9023;0;1500;0;0;0;0;0;0;0 +19;22;31240;3.9023;0;1500;0;0;0;0;0;0;0 diff --git a/openair1/SIMULATION/NR_PHY/BLER_SIMULATIONS/AWGN/AWGN_results/mcs23_awgn_5G.csv b/openair1/SIMULATION/NR_PHY/BLER_SIMULATIONS/AWGN/AWGN_results/mcs23_awgn_5G.csv new file mode 100644 index 0000000000..07e9e257ff --- /dev/null +++ b/openair1/SIMULATION/NR_PHY/BLER_SIMULATIONS/AWGN/AWGN_results/mcs23_awgn_5G.csv @@ -0,0 +1,92 @@ +SNR;MCS;TBS;rate;err0;trials0;err1;trials1;err2;trials2;err3;trials3;dci_err +15;23;33816;4.2129;1500;1500;0;0;0;0;0;0;0 +15.1;23;33816;4.2129;1500;1500;0;0;0;0;0;0;0 +15.2;23;33816;4.2129;1500;1500;0;0;0;0;0;0;0 +15.3;23;33816;4.2129;1500;1500;0;0;0;0;0;0;0 +15.4;23;33816;4.2129;1500;1500;0;0;0;0;0;0;0 +15.5;23;33816;4.2129;1500;1500;0;0;0;0;0;0;0 +15.6;23;33816;4.2129;1499;1500;0;0;0;0;0;0;0 +15.7;23;33816;4.2129;1499;1500;0;0;0;0;0;0;0 +15.8;23;33816;4.2129;1498;1500;0;0;0;0;0;0;0 +15.9;23;33816;4.2129;1498;1500;0;0;0;0;0;0;0 +16;23;33816;4.2129;1497;1500;0;0;0;0;0;0;0 +16.1;23;33816;4.2129;1360;1500;0;0;0;0;0;0;0 +16.2;23;33816;4.2129;1236;1500;0;0;0;0;0;0;0 +16.3;23;33816;4.2129;1123;1500;0;0;0;0;0;0;0 +16.4;23;33816;4.2129;1020;1500;0;0;0;0;0;0;0 +16.5;23;33816;4.2129;927;1500;0;0;0;0;0;0;0 +16.6;23;33816;4.2129;630;1500;0;0;0;0;0;0;0 +16.7;23;33816;4.2129;428;1500;0;0;0;0;0;0;0 +16.8;23;33816;4.2129;291;1500;0;0;0;0;0;0;0 +16.9;23;33816;4.2129;198;1500;0;0;0;0;0;0;0 +17;23;33816;4.2129;135;1500;0;0;0;0;0;0;0 +17.1;23;33816;4.2129;120;1500;0;0;0;0;0;0;0 +17.2;23;33816;4.2129;108;1500;0;0;0;0;0;0;0 +17.3;23;33816;4.2129;96;1500;0;0;0;0;0;0;0 +17.4;23;33816;4.2129;86;1500;0;0;0;0;0;0;0 +17.5;23;33816;4.2129;77;1500;0;0;0;0;0;0;0 +17.6;23;33816;4.2129;70;1500;0;0;0;0;0;0;0 +17.7;23;33816;4.2129;63;1500;0;0;0;0;0;0;0 +17.8;23;33816;4.2129;57;1500;0;0;0;0;0;0;0 +17.9;23;33816;4.2129;52;1500;0;0;0;0;0;0;0 +18;23;33816;4.2129;47;1500;0;0;0;0;0;0;0 +18.1;23;33816;4.2129;28;1500;0;0;0;0;0;0;0 +18.2;23;33816;4.2129;16;1500;0;0;0;0;0;0;0 +18.3;23;33816;4.2129;9;1500;0;0;0;0;0;0;0 +18.4;23;33816;4.2129;6;1500;0;0;0;0;0;0;0 +18.5;23;33816;4.2129;3;1500;0;0;0;0;0;0;0 +18.6;23;33816;4.2129;3;1500;0;0;0;0;0;0;0 +18.7;23;33816;4.2129;3;1500;0;0;0;0;0;0;0 +18.8;23;33816;4.2129;3;1500;0;0;0;0;0;0;0 +18.9;23;33816;4.2129;3;1500;0;0;0;0;0;0;0 +19;23;33816;4.2129;3;1500;0;0;0;0;0;0;0 +19.1;23;33816;4.2129;3;1500;0;0;0;0;0;0;0 +19.2;23;33816;4.2129;4;1500;0;0;0;0;0;0;0 +19.3;23;33816;4.2129;5;1500;0;0;0;0;0;0;0 +19.4;23;33816;4.2129;6;1500;0;0;0;0;0;0;0 +19.5;23;33816;4.2129;8;1500;0;0;0;0;0;0;0 +19.6;23;33816;4.2129;6;1500;0;0;0;0;0;0;0 +19.7;23;33816;4.2129;4;1500;0;0;0;0;0;0;0 +19.8;23;33816;4.2129;3;1500;0;0;0;0;0;0;0 +19.9;23;33816;4.2129;2;1500;0;0;0;0;0;0;0 +20;23;33816;4.2129;2;1500;0;0;0;0;0;0;0 +20.1;23;33816;4.2129;1;1500;0;0;0;0;0;0;0 +20.2;23;33816;4.2129;1;1500;0;0;0;0;0;0;0 +20.3;23;33816;4.2129;0;1500;0;0;0;0;0;0;0 +20.4;23;33816;4.2129;0;1500;0;0;0;0;0;0;0 +20.5;23;33816;4.2129;0;1500;0;0;0;0;0;0;0 +20.6;23;33816;4.2129;0;1500;0;0;0;0;0;0;0 +20.7;23;33816;4.2129;0;1500;0;0;0;0;0;0;0 +20.8;23;33816;4.2129;0;1500;0;0;0;0;0;0;0 +20.9;23;33816;4.2129;0;1500;0;0;0;0;0;0;0 +21;23;33816;4.2129;0;1500;0;0;0;0;0;0;0 +21.1;23;33816;4.2129;0;1500;0;0;0;0;0;0;0 +21.2;23;33816;4.2129;0;1500;0;0;0;0;0;0;0 +21.3;23;33816;4.2129;0;1500;0;0;0;0;0;0;0 +21.4;23;33816;4.2129;0;1500;0;0;0;0;0;0;0 +21.5;23;33816;4.2129;0;1500;0;0;0;0;0;0;0 +21.6;23;33816;4.2129;0;1500;0;0;0;0;0;0;0 +21.7;23;33816;4.2129;0;1500;0;0;0;0;0;0;0 +21.8;23;33816;4.2129;0;1500;0;0;0;0;0;0;0 +21.9;23;33816;4.2129;0;1500;0;0;0;0;0;0;0 +22;23;33816;4.2129;0;1500;0;0;0;0;0;0;0 +22.1;23;33816;4.2129;0;1500;0;0;0;0;0;0;0 +22.2;23;33816;4.2129;0;1500;0;0;0;0;0;0;0 +22.3;23;33816;4.2129;0;1500;0;0;0;0;0;0;0 +22.4;23;33816;4.2129;0;1500;0;0;0;0;0;0;0 +22.5;23;33816;4.2129;0;1500;0;0;0;0;0;0;0 +22.6;23;33816;4.2129;0;1500;0;0;0;0;0;0;0 +22.7;23;33816;4.2129;0;1500;0;0;0;0;0;0;0 +22.8;23;33816;4.2129;0;1500;0;0;0;0;0;0;0 +22.9;23;33816;4.2129;0;1500;0;0;0;0;0;0;0 +23;23;33816;4.2129;0;1500;0;0;0;0;0;0;0 +23.1;23;33816;4.2129;0;1500;0;0;0;0;0;0;0 +23.2;23;33816;4.2129;0;1500;0;0;0;0;0;0;0 +23.3;23;33816;4.2129;0;1500;0;0;0;0;0;0;0 +23.4;23;33816;4.2129;0;1500;0;0;0;0;0;0;0 +23.5;23;33816;4.2129;0;1500;0;0;0;0;0;0;0 +23.6;23;33816;4.2129;0;1500;0;0;0;0;0;0;0 +23.7;23;33816;4.2129;0;1500;0;0;0;0;0;0;0 +23.8;23;33816;4.2129;0;1500;0;0;0;0;0;0;0 +23.9;23;33816;4.2129;0;1500;0;0;0;0;0;0;0 +24;23;33816;4.2129;0;1500;0;0;0;0;0;0;0 diff --git a/openair1/SIMULATION/NR_PHY/BLER_SIMULATIONS/AWGN/AWGN_results/mcs24_awgn_5G.csv b/openair1/SIMULATION/NR_PHY/BLER_SIMULATIONS/AWGN/AWGN_results/mcs24_awgn_5G.csv new file mode 100644 index 0000000000..6eac0f3f7d --- /dev/null +++ b/openair1/SIMULATION/NR_PHY/BLER_SIMULATIONS/AWGN/AWGN_results/mcs24_awgn_5G.csv @@ -0,0 +1,92 @@ +SNR;MCS;TBS;rate;err0;trials0;err1;trials1;err2;trials2;err3;trials3;dci_err +15;24;35856;4.5234;1500;1500;0;0;0;0;0;0;0 +15.1;24;35856;4.5234;1500;1500;0;0;0;0;0;0;0 +15.2;24;35856;4.5234;1500;1500;0;0;0;0;0;0;0 +15.3;24;35856;4.5234;1500;1500;0;0;0;0;0;0;0 +15.4;24;35856;4.5234;1500;1500;0;0;0;0;0;0;0 +15.5;24;35856;4.5234;1500;1500;0;0;0;0;0;0;0 +15.6;24;35856;4.5234;1500;1500;0;0;0;0;0;0;0 +15.7;24;35856;4.5234;1500;1500;0;0;0;0;0;0;0 +15.8;24;35856;4.5234;1500;1500;0;0;0;0;0;0;0 +15.9;24;35856;4.5234;1500;1500;0;0;0;0;0;0;0 +16;24;35856;4.5234;1500;1500;0;0;0;0;0;0;0 +16.1;24;35856;4.5234;1500;1500;0;0;0;0;0;0;0 +16.2;24;35856;4.5234;1500;1500;0;0;0;0;0;0;0 +16.3;24;35856;4.5234;1500;1500;0;0;0;0;0;0;0 +16.4;24;35856;4.5234;1500;1500;0;0;0;0;0;0;0 +16.5;24;35856;4.5234;1500;1500;0;0;0;0;0;0;0 +16.6;24;35856;4.5234;1474;1500;0;0;0;0;0;0;0 +16.7;24;35856;4.5234;1449;1500;0;0;0;0;0;0;0 +16.8;24;35856;4.5234;1424;1500;0;0;0;0;0;0;0 +16.9;24;35856;4.5234;1400;1500;0;0;0;0;0;0;0 +17;24;35856;4.5234;1376;1500;0;0;0;0;0;0;0 +17.1;24;35856;4.5234;1016;1500;0;0;0;0;0;0;0 +17.2;24;35856;4.5234;751;1500;0;0;0;0;0;0;0 +17.3;24;35856;4.5234;554;1500;0;0;0;0;0;0;0 +17.4;24;35856;4.5234;410;1500;0;0;0;0;0;0;0 +17.5;24;35856;4.5234;303;1500;0;0;0;0;0;0;0 +17.6;24;35856;4.5234;232;1500;0;0;0;0;0;0;0 +17.7;24;35856;4.5234;177;1500;0;0;0;0;0;0;0 +17.8;24;35856;4.5234;136;1500;0;0;0;0;0;0;0 +17.9;24;35856;4.5234;104;1500;0;0;0;0;0;0;0 +18;24;35856;4.5234;80;1500;0;0;0;0;0;0;0 +18.1;24;35856;4.5234;79;1500;0;0;0;0;0;0;0 +18.2;24;35856;4.5234;78;1500;0;0;0;0;0;0;0 +18.3;24;35856;4.5234;77;1500;0;0;0;0;0;0;0 +18.4;24;35856;4.5234;76;1500;0;0;0;0;0;0;0 +18.5;24;35856;4.5234;75;1500;0;0;0;0;0;0;0 +18.6;24;35856;4.5234;59;1500;0;0;0;0;0;0;0 +18.7;24;35856;4.5234;46;1500;0;0;0;0;0;0;0 +18.8;24;35856;4.5234;36;1500;0;0;0;0;0;0;0 +18.9;24;35856;4.5234;28;1500;0;0;0;0;0;0;0 +19;24;35856;4.5234;22;1500;0;0;0;0;0;0;0 +19.1;24;35856;4.5234;21;1500;0;0;0;0;0;0;0 +19.2;24;35856;4.5234;20;1500;0;0;0;0;0;0;0 +19.3;24;35856;4.5234;20;1500;0;0;0;0;0;0;0 +19.4;24;35856;4.5234;19;1500;0;0;0;0;0;0;0 +19.5;24;35856;4.5234;18;1500;0;0;0;0;0;0;0 +19.6;24;35856;4.5234;22;1500;0;0;0;0;0;0;0 +19.7;24;35856;4.5234;26;1500;0;0;0;0;0;0;0 +19.8;24;35856;4.5234;31;1500;0;0;0;0;0;0;0 +19.9;24;35856;4.5234;36;1500;0;0;0;0;0;0;0 +20;24;35856;4.5234;43;1500;0;0;0;0;0;0;0 +20.1;24;35856;4.5234;35;1500;0;0;0;0;0;0;0 +20.2;24;35856;4.5234;29;1500;0;0;0;0;0;0;0 +20.3;24;35856;4.5234;23;1500;0;0;0;0;0;0;0 +20.4;24;35856;4.5234;19;1500;0;0;0;0;0;0;0 +20.5;24;35856;4.5234;15;1500;0;0;0;0;0;0;0 +20.6;24;35856;4.5234;8;1500;0;0;0;0;0;0;0 +20.7;24;35856;4.5234;4;1500;0;0;0;0;0;0;0 +20.8;24;35856;4.5234;2;1500;0;0;0;0;0;0;0 +20.9;24;35856;4.5234;1;1500;0;0;0;0;0;0;0 +21;24;35856;4.5234;1;1500;0;0;0;0;0;0;0 +21.1;24;35856;4.5234;0;1500;0;0;0;0;0;0;0 +21.2;24;35856;4.5234;0;1500;0;0;0;0;0;0;0 +21.3;24;35856;4.5234;0;1500;0;0;0;0;0;0;0 +21.4;24;35856;4.5234;0;1500;0;0;0;0;0;0;0 +21.5;24;35856;4.5234;0;1500;0;0;0;0;0;0;0 +21.6;24;35856;4.5234;0;1500;0;0;0;0;0;0;0 +21.7;24;35856;4.5234;0;1500;0;0;0;0;0;0;0 +21.8;24;35856;4.5234;0;1500;0;0;0;0;0;0;0 +21.9;24;35856;4.5234;0;1500;0;0;0;0;0;0;0 +22;24;35856;4.5234;0;1500;0;0;0;0;0;0;0 +22.1;24;35856;4.5234;0;1500;0;0;0;0;0;0;0 +22.2;24;35856;4.5234;0;1500;0;0;0;0;0;0;0 +22.3;24;35856;4.5234;0;1500;0;0;0;0;0;0;0 +22.4;24;35856;4.5234;0;1500;0;0;0;0;0;0;0 +22.5;24;35856;4.5234;0;1500;0;0;0;0;0;0;0 +22.6;24;35856;4.5234;0;1500;0;0;0;0;0;0;0 +22.7;24;35856;4.5234;0;1500;0;0;0;0;0;0;0 +22.8;24;35856;4.5234;0;1500;0;0;0;0;0;0;0 +22.9;24;35856;4.5234;0;1500;0;0;0;0;0;0;0 +23;24;35856;4.5234;0;1500;0;0;0;0;0;0;0 +23.1;24;35856;4.5234;0;1500;0;0;0;0;0;0;0 +23.2;24;35856;4.5234;0;1500;0;0;0;0;0;0;0 +23.3;24;35856;4.5234;0;1500;0;0;0;0;0;0;0 +23.4;24;35856;4.5234;0;1500;0;0;0;0;0;0;0 +23.5;24;35856;4.5234;0;1500;0;0;0;0;0;0;0 +23.6;24;35856;4.5234;0;1500;0;0;0;0;0;0;0 +23.7;24;35856;4.5234;0;1500;0;0;0;0;0;0;0 +23.8;24;35856;4.5234;0;1500;0;0;0;0;0;0;0 +23.9;24;35856;4.5234;0;1500;0;0;0;0;0;0;0 +24;24;35856;4.5234;0;1500;0;0;0;0;0;0;0 diff --git a/openair1/SIMULATION/NR_PHY/BLER_SIMULATIONS/AWGN/AWGN_results/mcs25_awgn_5G.csv b/openair1/SIMULATION/NR_PHY/BLER_SIMULATIONS/AWGN/AWGN_results/mcs25_awgn_5G.csv new file mode 100644 index 0000000000..6f158f5bdc --- /dev/null +++ b/openair1/SIMULATION/NR_PHY/BLER_SIMULATIONS/AWGN/AWGN_results/mcs25_awgn_5G.csv @@ -0,0 +1,92 @@ +SNR;MCS;TBS;rate;err0;trials0;err1;trials1;err2;trials2;err3;trials3;dci_err +15;25;37896;4.8164;1500;1500;0;0;0;0;0;0;0 +15.1;25;37896;4.8164;1500;1500;0;0;0;0;0;0;0 +15.2;25;37896;4.8164;1500;1500;0;0;0;0;0;0;0 +15.3;25;37896;4.8164;1500;1500;0;0;0;0;0;0;0 +15.4;25;37896;4.8164;1500;1500;0;0;0;0;0;0;0 +15.5;25;37896;4.8164;1500;1500;0;0;0;0;0;0;0 +15.6;25;37896;4.8164;1500;1500;0;0;0;0;0;0;0 +15.7;25;37896;4.8164;1500;1500;0;0;0;0;0;0;0 +15.8;25;37896;4.8164;1500;1500;0;0;0;0;0;0;0 +15.9;25;37896;4.8164;1500;1500;0;0;0;0;0;0;0 +16;25;37896;4.8164;1500;1500;0;0;0;0;0;0;0 +16.1;25;37896;4.8164;1500;1500;0;0;0;0;0;0;0 +16.2;25;37896;4.8164;1500;1500;0;0;0;0;0;0;0 +16.3;25;37896;4.8164;1500;1500;0;0;0;0;0;0;0 +16.4;25;37896;4.8164;1500;1500;0;0;0;0;0;0;0 +16.5;25;37896;4.8164;1500;1500;0;0;0;0;0;0;0 +16.6;25;37896;4.8164;1500;1500;0;0;0;0;0;0;0 +16.7;25;37896;4.8164;1500;1500;0;0;0;0;0;0;0 +16.8;25;37896;4.8164;1500;1500;0;0;0;0;0;0;0 +16.9;25;37896;4.8164;1500;1500;0;0;0;0;0;0;0 +17;25;37896;4.8164;1500;1500;0;0;0;0;0;0;0 +17.1;25;37896;4.8164;1493;1500;0;0;0;0;0;0;0 +17.2;25;37896;4.8164;1486;1500;0;0;0;0;0;0;0 +17.3;25;37896;4.8164;1478;1500;0;0;0;0;0;0;0 +17.4;25;37896;4.8164;1471;1500;0;0;0;0;0;0;0 +17.5;25;37896;4.8164;1464;1500;0;0;0;0;0;0;0 +17.6;25;37896;4.8164;1138;1500;0;0;0;0;0;0;0 +17.7;25;37896;4.8164;885;1500;0;0;0;0;0;0;0 +17.8;25;37896;4.8164;688;1500;0;0;0;0;0;0;0 +17.9;25;37896;4.8164;535;1500;0;0;0;0;0;0;0 +18;25;37896;4.8164;416;1500;0;0;0;0;0;0;0 +18.1;25;37896;4.8164;302;1500;0;0;0;0;0;0;0 +18.2;25;37896;4.8164;219;1500;0;0;0;0;0;0;0 +18.3;25;37896;4.8164;159;1500;0;0;0;0;0;0;0 +18.4;25;37896;4.8164;115;1500;0;0;0;0;0;0;0 +18.5;25;37896;4.8164;84;1500;0;0;0;0;0;0;0 +18.6;25;37896;4.8164;89;1500;0;0;0;0;0;0;0 +18.7;25;37896;4.8164;94;1500;0;0;0;0;0;0;0 +18.8;25;37896;4.8164;100;1500;0;0;0;0;0;0;0 +18.9;25;37896;4.8164;106;1500;0;0;0;0;0;0;0 +19;25;37896;4.8164;113;1500;0;0;0;0;0;0;0 +19.1;25;37896;4.8164;110;1500;0;0;0;0;0;0;0 +19.2;25;37896;4.8164;108;1500;0;0;0;0;0;0;0 +19.3;25;37896;4.8164;105;1500;0;0;0;0;0;0;0 +19.4;25;37896;4.8164;103;1500;0;0;0;0;0;0;0 +19.5;25;37896;4.8164;101;1500;0;0;0;0;0;0;0 +19.6;25;37896;4.8164;89;1500;0;0;0;0;0;0;0 +19.7;25;37896;4.8164;79;1500;0;0;0;0;0;0;0 +19.8;25;37896;4.8164;71;1500;0;0;0;0;0;0;0 +19.9;25;37896;4.8164;63;1500;0;0;0;0;0;0;0 +20;25;37896;4.8164;56;1500;0;0;0;0;0;0;0 +20.1;25;37896;4.8164;58;1500;0;0;0;0;0;0;0 +20.2;25;37896;4.8164;61;1500;0;0;0;0;0;0;0 +20.3;25;37896;4.8164;64;1500;0;0;0;0;0;0;0 +20.4;25;37896;4.8164;67;1500;0;0;0;0;0;0;0 +20.5;25;37896;4.8164;71;1500;0;0;0;0;0;0;0 +20.6;25;37896;4.8164;64;1500;0;0;0;0;0;0;0 +20.7;25;37896;4.8164;58;1500;0;0;0;0;0;0;0 +20.8;25;37896;4.8164;52;1500;0;0;0;0;0;0;0 +20.9;25;37896;4.8164;47;1500;0;0;0;0;0;0;0 +21;25;37896;4.8164;43;1500;0;0;0;0;0;0;0 +21.1;25;37896;4.8164;27;1500;0;0;0;0;0;0;0 +21.2;25;37896;4.8164;17;1500;0;0;0;0;0;0;0 +21.3;25;37896;4.8164;10;1500;0;0;0;0;0;0;0 +21.4;25;37896;4.8164;6;1500;0;0;0;0;0;0;0 +21.5;25;37896;4.8164;4;1500;0;0;0;0;0;0;0 +21.6;25;37896;4.8164;2;1500;0;0;0;0;0;0;0 +21.7;25;37896;4.8164;1;1500;0;0;0;0;0;0;0 +21.8;25;37896;4.8164;1;1500;0;0;0;0;0;0;0 +21.9;25;37896;4.8164;0;1500;0;0;0;0;0;0;0 +22;25;37896;4.8164;0;1500;0;0;0;0;0;0;0 +22.1;25;37896;4.8164;0;1500;0;0;0;0;0;0;0 +22.2;25;37896;4.8164;0;1500;0;0;0;0;0;0;0 +22.3;25;37896;4.8164;0;1500;0;0;0;0;0;0;0 +22.4;25;37896;4.8164;0;1500;0;0;0;0;0;0;0 +22.5;25;37896;4.8164;0;1500;0;0;0;0;0;0;0 +22.6;25;37896;4.8164;0;1500;0;0;0;0;0;0;0 +22.7;25;37896;4.8164;0;1500;0;0;0;0;0;0;0 +22.8;25;37896;4.8164;0;1500;0;0;0;0;0;0;0 +22.9;25;37896;4.8164;0;1500;0;0;0;0;0;0;0 +23;25;37896;4.8164;0;1500;0;0;0;0;0;0;0 +23.1;25;37896;4.8164;0;1500;0;0;0;0;0;0;0 +23.2;25;37896;4.8164;0;1500;0;0;0;0;0;0;0 +23.3;25;37896;4.8164;0;1500;0;0;0;0;0;0;0 +23.4;25;37896;4.8164;0;1500;0;0;0;0;0;0;0 +23.5;25;37896;4.8164;0;1500;0;0;0;0;0;0;0 +23.6;25;37896;4.8164;0;1500;0;0;0;0;0;0;0 +23.7;25;37896;4.8164;0;1500;0;0;0;0;0;0;0 +23.8;25;37896;4.8164;0;1500;0;0;0;0;0;0;0 +23.9;25;37896;4.8164;0;1500;0;0;0;0;0;0;0 +24;25;37896;4.8164;0;1500;0;0;0;0;0;0;0 diff --git a/openair1/SIMULATION/NR_PHY/BLER_SIMULATIONS/AWGN/AWGN_results/mcs26_awgn_5G.csv b/openair1/SIMULATION/NR_PHY/BLER_SIMULATIONS/AWGN/AWGN_results/mcs26_awgn_5G.csv new file mode 100644 index 0000000000..94d779fb21 --- /dev/null +++ b/openair1/SIMULATION/NR_PHY/BLER_SIMULATIONS/AWGN/AWGN_results/mcs26_awgn_5G.csv @@ -0,0 +1,92 @@ +SNR;MCS;TBS;rate;err0;trials0;err1;trials1;err2;trials2;err3;trials3;dci_err +15;26;40976;5.1152;1500;1500;0;0;0;0;0;0;0 +15.1;26;40976;5.1152;1500;1500;0;0;0;0;0;0;0 +15.2;26;40976;5.1152;1500;1500;0;0;0;0;0;0;0 +15.3;26;40976;5.1152;1500;1500;0;0;0;0;0;0;0 +15.4;26;40976;5.1152;1500;1500;0;0;0;0;0;0;0 +15.5;26;40976;5.1152;1500;1500;0;0;0;0;0;0;0 +15.6;26;40976;5.1152;1500;1500;0;0;0;0;0;0;0 +15.7;26;40976;5.1152;1500;1500;0;0;0;0;0;0;0 +15.8;26;40976;5.1152;1500;1500;0;0;0;0;0;0;0 +15.9;26;40976;5.1152;1500;1500;0;0;0;0;0;0;0 +16;26;40976;5.1152;1500;1500;0;0;0;0;0;0;0 +16.1;26;40976;5.1152;1500;1500;0;0;0;0;0;0;0 +16.2;26;40976;5.1152;1500;1500;0;0;0;0;0;0;0 +16.3;26;40976;5.1152;1500;1500;0;0;0;0;0;0;0 +16.4;26;40976;5.1152;1500;1500;0;0;0;0;0;0;0 +16.5;26;40976;5.1152;1500;1500;0;0;0;0;0;0;0 +16.6;26;40976;5.1152;1500;1500;0;0;0;0;0;0;0 +16.7;26;40976;5.1152;1500;1500;0;0;0;0;0;0;0 +16.8;26;40976;5.1152;1500;1500;0;0;0;0;0;0;0 +16.9;26;40976;5.1152;1500;1500;0;0;0;0;0;0;0 +17;26;40976;5.1152;1500;1500;0;0;0;0;0;0;0 +17.1;26;40976;5.1152;1500;1500;0;0;0;0;0;0;0 +17.2;26;40976;5.1152;1500;1500;0;0;0;0;0;0;0 +17.3;26;40976;5.1152;1500;1500;0;0;0;0;0;0;0 +17.4;26;40976;5.1152;1500;1500;0;0;0;0;0;0;0 +17.5;26;40976;5.1152;1500;1500;0;0;0;0;0;0;0 +17.6;26;40976;5.1152;1500;1500;0;0;0;0;0;0;0 +17.7;26;40976;5.1152;1500;1500;0;0;0;0;0;0;0 +17.8;26;40976;5.1152;1500;1500;0;0;0;0;0;0;0 +17.9;26;40976;5.1152;1500;1500;0;0;0;0;0;0;0 +18;26;40976;5.1152;1500;1500;0;0;0;0;0;0;0 +18.1;26;40976;5.1152;1496;1500;0;0;0;0;0;0;0 +18.2;26;40976;5.1152;1492;1500;0;0;0;0;0;0;0 +18.3;26;40976;5.1152;1487;1500;0;0;0;0;0;0;0 +18.4;26;40976;5.1152;1483;1500;0;0;0;0;0;0;0 +18.5;26;40976;5.1152;1479;1500;0;0;0;0;0;0;0 +18.6;26;40976;5.1152;1188;1500;0;0;0;0;0;0;0 +18.7;26;40976;5.1152;954;1500;0;0;0;0;0;0;0 +18.8;26;40976;5.1152;766;1500;0;0;0;0;0;0;0 +18.9;26;40976;5.1152;615;1500;0;0;0;0;0;0;0 +19;26;40976;5.1152;494;1500;0;0;0;0;0;0;0 +19.1;26;40976;5.1152;478;1500;0;0;0;0;0;0;0 +19.2;26;40976;5.1152;462;1500;0;0;0;0;0;0;0 +19.3;26;40976;5.1152;447;1500;0;0;0;0;0;0;0 +19.4;26;40976;5.1152;433;1500;0;0;0;0;0;0;0 +19.5;26;40976;5.1152;419;1500;0;0;0;0;0;0;0 +19.6;26;40976;5.1152;491;1500;0;0;0;0;0;0;0 +19.7;26;40976;5.1152;577;1500;0;0;0;0;0;0;0 +19.8;26;40976;5.1152;677;1500;0;0;0;0;0;0;0 +19.9;26;40976;5.1152;795;1500;0;0;0;0;0;0;0 +20;26;40976;5.1152;934;1500;0;0;0;0;0;0;0 +20.1;26;40976;5.1152;799;1500;0;0;0;0;0;0;0 +20.2;26;40976;5.1152;684;1500;0;0;0;0;0;0;0 +20.3;26;40976;5.1152;586;1500;0;0;0;0;0;0;0 +20.4;26;40976;5.1152;502;1500;0;0;0;0;0;0;0 +20.5;26;40976;5.1152;429;1500;0;0;0;0;0;0;0 +20.6;26;40976;5.1152;315;1500;0;0;0;0;0;0;0 +20.7;26;40976;5.1152;231;1500;0;0;0;0;0;0;0 +20.8;26;40976;5.1152;169;1500;0;0;0;0;0;0;0 +20.9;26;40976;5.1152;124;1500;0;0;0;0;0;0;0 +21;26;40976;5.1152;91;1500;0;0;0;0;0;0;0 +21.1;26;40976;5.1152;87;1500;0;0;0;0;0;0;0 +21.2;26;40976;5.1152;84;1500;0;0;0;0;0;0;0 +21.3;26;40976;5.1152;81;1500;0;0;0;0;0;0;0 +21.4;26;40976;5.1152;78;1500;0;0;0;0;0;0;0 +21.5;26;40976;5.1152;75;1500;0;0;0;0;0;0;0 +21.6;26;40976;5.1152;75;1500;0;0;0;0;0;0;0 +21.7;26;40976;5.1152;75;1500;0;0;0;0;0;0;0 +21.8;26;40976;5.1152;75;1500;0;0;0;0;0;0;0 +21.9;26;40976;5.1152;75;1500;0;0;0;0;0;0;0 +22;26;40976;5.1152;75;1500;0;0;0;0;0;0;0 +22.1;26;40976;5.1152;73;1500;0;0;0;0;0;0;0 +22.2;26;40976;5.1152;72;1500;0;0;0;0;0;0;0 +22.3;26;40976;5.1152;70;1500;0;0;0;0;0;0;0 +22.4;26;40976;5.1152;68;1500;0;0;0;0;0;0;0 +22.5;26;40976;5.1152;67;1500;0;0;0;0;0;0;0 +22.6;26;40976;5.1152;53;1500;0;0;0;0;0;0;0 +22.7;26;40976;5.1152;42;1500;0;0;0;0;0;0;0 +22.8;26;40976;5.1152;33;1500;0;0;0;0;0;0;0 +22.9;26;40976;5.1152;26;1500;0;0;0;0;0;0;0 +23;26;40976;5.1152;21;1500;0;0;0;0;0;0;0 +23.1;26;40976;5.1152;11;1500;0;0;0;0;0;0;0 +23.2;26;40976;5.1152;6;1500;0;0;0;0;0;0;0 +23.3;26;40976;5.1152;3;1500;0;0;0;0;0;0;0 +23.4;26;40976;5.1152;2;1500;0;0;0;0;0;0;0 +23.5;26;40976;5.1152;1;1500;0;0;0;0;0;0;0 +23.6;26;40976;5.1152;1;1500;0;0;0;0;0;0;0 +23.7;26;40976;5.1152;0;1500;0;0;0;0;0;0;0 +23.8;26;40976;5.1152;0;1500;0;0;0;0;0;0;0 +23.9;26;40976;5.1152;0;1500;0;0;0;0;0;0;0 +24;26;40976;5.1152;0;1500;0;0;0;0;0;0;0 diff --git a/openair1/SIMULATION/NR_PHY/BLER_SIMULATIONS/AWGN/AWGN_results/mcs27_awgn_5G.csv b/openair1/SIMULATION/NR_PHY/BLER_SIMULATIONS/AWGN/AWGN_results/mcs27_awgn_5G.csv new file mode 100644 index 0000000000..5f25579439 --- /dev/null +++ b/openair1/SIMULATION/NR_PHY/BLER_SIMULATIONS/AWGN/AWGN_results/mcs27_awgn_5G.csv @@ -0,0 +1,92 @@ +SNR;MCS;TBS;rate;err0;trials0;err1;trials1;err2;trials2;err3;trials3;dci_err +18;27;42016;5.332;1500;1500;0;0;0;0;0;0;0 +18.1;27;42016;5.332;1500;1500;0;0;0;0;0;0;0 +18.2;27;42016;5.332;1500;1500;0;0;0;0;0;0;0 +18.3;27;42016;5.332;1500;1500;0;0;0;0;0;0;0 +18.4;27;42016;5.332;1500;1500;0;0;0;0;0;0;0 +18.5;27;42016;5.332;1500;1500;0;0;0;0;0;0;0 +18.6;27;42016;5.332;1465;1500;0;0;0;0;0;0;0 +18.7;27;42016;5.332;1430;1500;0;0;0;0;0;0;0 +18.8;27;42016;5.332;1397;1500;0;0;0;0;0;0;0 +18.9;27;42016;5.332;1364;1500;0;0;0;0;0;0;0 +19;27;42016;5.332;1332;1500;0;0;0;0;0;0;0 +19.1;27;42016;5.332;1092;1500;0;0;0;0;0;0;0 +19.2;27;42016;5.332;896;1500;0;0;0;0;0;0;0 +19.3;27;42016;5.332;735;1500;0;0;0;0;0;0;0 +19.4;27;42016;5.332;603;1500;0;0;0;0;0;0;0 +19.5;27;42016;5.332;494;1500;0;0;0;0;0;0;0 +19.6;27;42016;5.332;572;1500;0;0;0;0;0;0;0 +19.7;27;42016;5.332;662;1500;0;0;0;0;0;0;0 +19.8;27;42016;5.332;766;1500;0;0;0;0;0;0;0 +19.9;27;42016;5.332;886;1500;0;0;0;0;0;0;0 +20;27;42016;5.332;1025;1500;0;0;0;0;0;0;0 +20.1;27;42016;5.332;1041;1500;0;0;0;0;0;0;0 +20.2;27;42016;5.332;1058;1500;0;0;0;0;0;0;0 +20.3;27;42016;5.332;1074;1500;0;0;0;0;0;0;0 +20.4;27;42016;5.332;1091;1500;0;0;0;0;0;0;0 +20.5;27;42016;5.332;1109;1500;0;0;0;0;0;0;0 +20.6;27;42016;5.332;811;1500;0;0;0;0;0;0;0 +20.7;27;42016;5.332;594;1500;0;0;0;0;0;0;0 +20.8;27;42016;5.332;434;1500;0;0;0;0;0;0;0 +20.9;27;42016;5.332;318;1500;0;0;0;0;0;0;0 +21;27;42016;5.332;233;1500;0;0;0;0;0;0;0 +21.1;27;42016;5.332;187;1500;0;0;0;0;0;0;0 +21.2;27;42016;5.332;150;1500;0;0;0;0;0;0;0 +21.3;27;42016;5.332;121;1500;0;0;0;0;0;0;0 +21.4;27;42016;5.332;97;1500;0;0;0;0;0;0;0 +21.5;27;42016;5.332;78;1500;0;0;0;0;0;0;0 +21.6;27;42016;5.332;78;1500;0;0;0;0;0;0;0 +21.7;27;42016;5.332;77;1500;0;0;0;0;0;0;0 +21.8;27;42016;5.332;76;1500;0;0;0;0;0;0;0 +21.9;27;42016;5.332;76;1500;0;0;0;0;0;0;0 +22;27;42016;5.332;75;1500;0;0;0;0;0;0;0 +22.1;27;42016;5.332;75;1500;0;0;0;0;0;0;0 +22.2;27;42016;5.332;75;1500;0;0;0;0;0;0;0 +22.3;27;42016;5.332;75;1500;0;0;0;0;0;0;0 +22.4;27;42016;5.332;75;1500;0;0;0;0;0;0;0 +22.5;27;42016;5.332;75;1500;0;0;0;0;0;0;0 +22.6;27;42016;5.332;75;1500;0;0;0;0;0;0;0 +22.7;27;42016;5.332;75;1500;0;0;0;0;0;0;0 +22.8;27;42016;5.332;75;1500;0;0;0;0;0;0;0 +22.9;27;42016;5.332;75;1500;0;0;0;0;0;0;0 +23;27;42016;5.332;75;1500;0;0;0;0;0;0;0 +23.1;27;42016;5.332;75;1500;0;0;0;0;0;0;0 +23.2;27;42016;5.332;74;1500;0;0;0;0;0;0;0 +23.3;27;42016;5.332;74;1500;0;0;0;0;0;0;0 +23.4;27;42016;5.332;74;1500;0;0;0;0;0;0;0 +23.5;27;42016;5.332;74;1500;0;0;0;0;0;0;0 +23.6;27;42016;5.332;68;1500;0;0;0;0;0;0;0 +23.7;27;42016;5.332;63;1500;0;0;0;0;0;0;0 +23.8;27;42016;5.332;59;1500;0;0;0;0;0;0;0 +23.9;27;42016;5.332;55;1500;0;0;0;0;0;0;0 +24;27;42016;5.332;51;1500;0;0;0;0;0;0;0 +24.1;27;42016;5.332;38;1500;0;0;0;0;0;0;0 +24.2;27;42016;5.332;29;1500;0;0;0;0;0;0;0 +24.3;27;42016;5.332;21;1500;0;0;0;0;0;0;0 +24.4;27;42016;5.332;16;1500;0;0;0;0;0;0;0 +24.5;27;42016;5.332;12;1500;0;0;0;0;0;0;0 +24.6;27;42016;5.332;7;1500;0;0;0;0;0;0;0 +24.7;27;42016;5.332;4;1500;0;0;0;0;0;0;0 +24.8;27;42016;5.332;3;1500;0;0;0;0;0;0;0 +24.9;27;42016;5.332;2;1500;0;0;0;0;0;0;0 +25;27;42016;5.332;1;1500;0;0;0;0;0;0;0 +25.1;27;42016;5.332;1;1500;0;0;0;0;0;0;0 +25.2;27;42016;5.332;0;1500;0;0;0;0;0;0;0 +25.3;27;42016;5.332;0;1500;0;0;0;0;0;0;0 +25.4;27;42016;5.332;0;1500;0;0;0;0;0;0;0 +25.5;27;42016;5.332;0;1500;0;0;0;0;0;0;0 +25.6;27;42016;5.332;0;1500;0;0;0;0;0;0;0 +25.7;27;42016;5.332;0;1500;0;0;0;0;0;0;0 +25.8;27;42016;5.332;0;1500;0;0;0;0;0;0;0 +25.9;27;42016;5.332;0;1500;0;0;0;0;0;0;0 +26;27;42016;5.332;0;1500;0;0;0;0;0;0;0 +26.1;27;42016;5.332;0;1500;0;0;0;0;0;0;0 +26.2;27;42016;5.332;0;1500;0;0;0;0;0;0;0 +26.3;27;42016;5.332;0;1500;0;0;0;0;0;0;0 +26.4;27;42016;5.332;0;1500;0;0;0;0;0;0;0 +26.5;27;42016;5.332;0;1500;0;0;0;0;0;0;0 +26.6;27;42016;5.332;0;1500;0;0;0;0;0;0;0 +26.7;27;42016;5.332;0;1500;0;0;0;0;0;0;0 +26.8;27;42016;5.332;0;1500;0;0;0;0;0;0;0 +26.9;27;42016;5.332;0;1500;0;0;0;0;0;0;0 +27;27;42016;5.332;0;1500;0;0;0;0;0;0;0 diff --git a/openair1/SIMULATION/NR_PHY/BLER_SIMULATIONS/AWGN/AWGN_results/mcs28_awgn_5G.csv b/openair1/SIMULATION/NR_PHY/BLER_SIMULATIONS/AWGN/AWGN_results/mcs28_awgn_5G.csv new file mode 100644 index 0000000000..edf6ef2e2c --- /dev/null +++ b/openair1/SIMULATION/NR_PHY/BLER_SIMULATIONS/AWGN/AWGN_results/mcs28_awgn_5G.csv @@ -0,0 +1,92 @@ +SNR;MCS;TBS;rate;err0;trials0;err1;trials1;err2;trials2;err3;trials3;dci_err +18;28;44040;5.547;1500;1500;0;0;0;0;0;0;0 +18.1;28;44040;5.547;1500;1500;0;0;0;0;0;0;0 +18.2;28;44040;5.547;1500;1500;0;0;0;0;0;0;0 +18.3;28;44040;5.547;1500;1500;0;0;0;0;0;0;0 +18.4;28;44040;5.547;1500;1500;0;0;0;0;0;0;0 +18.5;28;44040;5.547;1500;1500;0;0;0;0;0;0;0 +18.6;28;44040;5.547;1500;1500;0;0;0;0;0;0;0 +18.7;28;44040;5.547;1500;1500;0;0;0;0;0;0;0 +18.8;28;44040;5.547;1500;1500;0;0;0;0;0;0;0 +18.9;28;44040;5.547;1500;1500;0;0;0;0;0;0;0 +19;28;44040;5.547;1500;1500;0;0;0;0;0;0;0 +19.1;28;44040;5.547;1499;1500;0;0;0;0;0;0;0 +19.2;28;44040;5.547;1498;1500;0;0;0;0;0;0;0 +19.3;28;44040;5.547;1498;1500;0;0;0;0;0;0;0 +19.4;28;44040;5.547;1497;1500;0;0;0;0;0;0;0 +19.5;28;44040;5.547;1496;1500;0;0;0;0;0;0;0 +19.6;28;44040;5.547;1429;1500;0;0;0;0;0;0;0 +19.7;28;44040;5.547;1366;1500;0;0;0;0;0;0;0 +19.8;28;44040;5.547;1305;1500;0;0;0;0;0;0;0 +19.9;28;44040;5.547;1247;1500;0;0;0;0;0;0;0 +20;28;44040;5.547;1191;1500;0;0;0;0;0;0;0 +20.1;28;44040;5.547;1234;1500;0;0;0;0;0;0;0 +20.2;28;44040;5.547;1279;1500;0;0;0;0;0;0;0 +20.3;28;44040;5.547;1325;1500;0;0;0;0;0;0;0 +20.4;28;44040;5.547;1373;1500;0;0;0;0;0;0;0 +20.5;28;44040;5.547;1423;1500;0;0;0;0;0;0;0 +20.6;28;44040;5.547;1426;1500;0;0;0;0;0;0;0 +20.7;28;44040;5.547;1429;1500;0;0;0;0;0;0;0 +20.8;28;44040;5.547;1432;1500;0;0;0;0;0;0;0 +20.9;28;44040;5.547;1435;1500;0;0;0;0;0;0;0 +21;28;44040;5.547;1438;1500;0;0;0;0;0;0;0 +21.1;28;44040;5.547;1207;1500;0;0;0;0;0;0;0 +21.2;28;44040;5.547;1014;1500;0;0;0;0;0;0;0 +21.3;28;44040;5.547;851;1500;0;0;0;0;0;0;0 +21.4;28;44040;5.547;715;1500;0;0;0;0;0;0;0 +21.5;28;44040;5.547;600;1500;0;0;0;0;0;0;0 +21.6;28;44040;5.547;418;1500;0;0;0;0;0;0;0 +21.7;28;44040;5.547;290;1500;0;0;0;0;0;0;0 +21.8;28;44040;5.547;202;1500;0;0;0;0;0;0;0 +21.9;28;44040;5.547;140;1500;0;0;0;0;0;0;0 +22;28;44040;5.547;98;1500;0;0;0;0;0;0;0 +22.1;28;44040;5.547;93;1500;0;0;0;0;0;0;0 +22.2;28;44040;5.547;88;1500;0;0;0;0;0;0;0 +22.3;28;44040;5.547;83;1500;0;0;0;0;0;0;0 +22.4;28;44040;5.547;79;1500;0;0;0;0;0;0;0 +22.5;28;44040;5.547;75;1500;0;0;0;0;0;0;0 +22.6;28;44040;5.547;0;1500;0;0;0;0;0;0;0 +22.7;28;44040;5.547;0;1500;0;0;0;0;0;0;0 +22.8;28;44040;5.547;0;1500;0;0;0;0;0;0;0 +22.9;28;44040;5.547;0;1500;0;0;0;0;0;0;0 +23;28;44040;5.547;0;1500;0;0;0;0;0;0;0 +23.1;28;44040;5.547;0;1500;0;0;0;0;0;0;0 +23.2;28;44040;5.547;0;1500;0;0;0;0;0;0;0 +23.3;28;44040;5.547;0;1500;0;0;0;0;0;0;0 +23.4;28;44040;5.547;0;1500;0;0;0;0;0;0;0 +23.5;28;44040;5.547;0;1500;0;0;0;0;0;0;0 +23.6;28;44040;5.547;0;1500;0;0;0;0;0;0;0 +23.7;28;44040;5.547;0;1500;0;0;0;0;0;0;0 +23.8;28;44040;5.547;0;1500;0;0;0;0;0;0;0 +23.9;28;44040;5.547;0;1500;0;0;0;0;0;0;0 +24;28;44040;5.547;0;1500;0;0;0;0;0;0;0 +24.1;28;44040;5.547;0;1500;0;0;0;0;0;0;0 +24.2;28;44040;5.547;0;1500;0;0;0;0;0;0;0 +24.3;28;44040;5.547;0;1500;0;0;0;0;0;0;0 +24.4;28;44040;5.547;0;1500;0;0;0;0;0;0;0 +24.5;28;44040;5.547;0;1500;0;0;0;0;0;0;0 +24.6;28;44040;5.547;0;1500;0;0;0;0;0;0;0 +24.7;28;44040;5.547;0;1500;0;0;0;0;0;0;0 +24.8;28;44040;5.547;0;1500;0;0;0;0;0;0;0 +24.9;28;44040;5.547;0;1500;0;0;0;0;0;0;0 +25;28;44040;5.547;0;1500;0;0;0;0;0;0;0 +25.1;28;44040;5.547;0;1500;0;0;0;0;0;0;0 +25.2;28;44040;5.547;0;1500;0;0;0;0;0;0;0 +25.3;28;44040;5.547;0;1500;0;0;0;0;0;0;0 +25.4;28;44040;5.547;0;1500;0;0;0;0;0;0;0 +25.5;28;44040;5.547;0;1500;0;0;0;0;0;0;0 +25.6;28;44040;5.547;0;1500;0;0;0;0;0;0;0 +25.7;28;44040;5.547;0;1500;0;0;0;0;0;0;0 +25.8;28;44040;5.547;0;1500;0;0;0;0;0;0;0 +25.9;28;44040;5.547;0;1500;0;0;0;0;0;0;0 +26;28;44040;5.547;0;1500;0;0;0;0;0;0;0 +26.1;28;44040;5.547;0;1500;0;0;0;0;0;0;0 +26.2;28;44040;5.547;0;1500;0;0;0;0;0;0;0 +26.3;28;44040;5.547;0;1500;0;0;0;0;0;0;0 +26.4;28;44040;5.547;0;1500;0;0;0;0;0;0;0 +26.5;28;44040;5.547;0;1500;0;0;0;0;0;0;0 +26.6;28;44040;5.547;0;1500;0;0;0;0;0;0;0 +26.7;28;44040;5.547;0;1500;0;0;0;0;0;0;0 +26.8;28;44040;5.547;0;1500;0;0;0;0;0;0;0 +26.9;28;44040;5.547;0;1500;0;0;0;0;0;0;0 +27;28;44040;5.547;0;1500;0;0;0;0;0;0;0 diff --git a/openair1/SIMULATION/NR_PHY/BLER_SIMULATIONS/AWGN/AWGN_results/mcs2_awgn_5G.csv b/openair1/SIMULATION/NR_PHY/BLER_SIMULATIONS/AWGN/AWGN_results/mcs2_awgn_5G.csv new file mode 100644 index 0000000000..2fbb6a20b9 --- /dev/null +++ b/openair1/SIMULATION/NR_PHY/BLER_SIMULATIONS/AWGN/AWGN_results/mcs2_awgn_5G.csv @@ -0,0 +1,62 @@ +SNR;MCS;TBS;rate;err0;trials0;err1;trials1;err2;trials2;err3;trials3;dci_err +-4;2;2976;0.377;1500;1500;0;0;0;0;0;0;0 +-3.9;2;2976;0.377;1500;1500;0;0;0;0;0;0;0 +-3.8;2;2976;0.377;1500;1500;0;0;0;0;0;0;0 +-3.7;2;2976;0.377;1500;1500;0;0;0;0;0;0;0 +-3.6;2;2976;0.377;1500;1500;0;0;0;0;0;0;0 +-3.5;2;2976;0.377;1500;1500;0;0;0;0;0;0;0 +-3.4;2;2976;0.377;1500;1500;0;0;0;0;0;0;0 +-3.3;2;2976;0.377;1500;1500;0;0;0;0;0;0;0 +-3.2;2;2976;0.377;1500;1500;0;0;0;0;0;0;0 +-3.1;2;2976;0.377;1500;1500;0;0;0;0;0;0;0 +-3;2;2976;0.377;1500;1500;0;0;0;0;0;0;0 +-2.9;2;2976;0.377;1500;1500;0;0;0;0;0;0;0 +-2.8;2;2976;0.377;1500;1500;0;0;0;0;0;0;0 +-2.7;2;2976;0.377;1500;1500;0;0;0;0;0;0;0 +-2.6;2;2976;0.377;1500;1500;0;0;0;0;0;0;0 +-2.5;2;2976;0.377;1500;1500;0;0;0;0;0;0;0 +-2.4;2;2976;0.377;1500;1500;0;0;0;0;0;0;0 +-2.3;2;2976;0.377;1500;1500;0;0;0;0;0;0;0 +-2.2;2;2976;0.377;1500;1500;0;0;0;0;0;0;0 +-2.1;2;2976;0.377;1500;1500;0;0;0;0;0;0;0 +-2;2;2976;0.377;1500;1500;0;0;0;0;0;0;0 +-1.9;2;2976;0.377;1500;1500;0;0;0;0;0;0;0 +-1.8;2;2976;0.377;1500;1500;0;0;0;0;0;0;0 +-1.7;2;2976;0.377;1500;1500;0;0;0;0;0;0;0 +-1.6;2;2976;0.377;1500;1500;0;0;0;0;0;0;0 +-1.5;2;2976;0.377;1500;1500;0;0;0;0;0;0;0 +-1.4;2;2976;0.377;1486;1500;0;0;0;0;0;0;0 +-1.3;2;2976;0.377;1473;1500;0;0;0;0;0;0;0 +-1.2;2;2976;0.377;1459;1500;0;0;0;0;0;0;0 +-1.1;2;2976;0.377;1446;1500;0;0;0;0;0;0;0 +-1;2;2976;0.377;1432;1500;0;0;0;0;0;0;0 +-0.9;2;2976;0.377;1149;1500;0;0;0;0;0;0;0 +-0.8;2;2976;0.377;921;1500;0;0;0;0;0;0;0 +-0.7;2;2976;0.377;738;1500;0;0;0;0;0;0;0 +-0.6;2;2976;0.377;592;1500;0;0;0;0;0;0;0 +-0.5;2;2976;0.377;475;1500;0;0;0;0;0;0;0 +-0.4;2;2976;0.377;292;1500;0;0;0;0;0;0;0 +-0.3;2;2976;0.377;179;1500;0;0;0;0;0;0;0 +-0.2;2;2976;0.377;110;1500;0;0;0;0;0;0;0 +-0.1;2;2976;0.377;68;1500;0;0;0;0;0;0;0 +0;2;2976;0.377;42;1500;0;0;0;0;0;0;0 +0.1;2;2976;0.377;22;1500;0;0;0;0;0;0;0 +0.2;2;2976;0.377;11;1500;0;0;0;0;0;0;0 +0.3;2;2976;0.377;6;1500;0;0;0;0;0;0;0 +0.4;2;2976;0.377;3;1500;0;0;0;0;0;0;0 +0.5;2;2976;0.377;2;1500;0;0;0;0;0;0;0 +0.6;2;2976;0.377;0;1500;0;0;0;0;0;0;0 +0.7;2;2976;0.377;0;1500;0;0;0;0;0;0;0 +0.8;2;2976;0.377;0;1500;0;0;0;0;0;0;0 +0.9;2;2976;0.377;0;1500;0;0;0;0;0;0;0 +1;2;2976;0.377;0;1500;0;0;0;0;0;0;0 +1.1;2;2976;0.377;0;1500;0;0;0;0;0;0;0 +1.2;2;2976;0.377;0;1500;0;0;0;0;0;0;0 +1.3;2;2976;0.377;0;1500;0;0;0;0;0;0;0 +1.4;2;2976;0.377;0;1500;0;0;0;0;0;0;0 +1.5;2;2976;0.377;0;1500;0;0;0;0;0;0;0 +1.6;2;2976;0.377;0;1500;0;0;0;0;0;0;0 +1.7;2;2976;0.377;0;1500;0;0;0;0;0;0;0 +1.8;2;2976;0.377;0;1500;0;0;0;0;0;0;0 +1.9;2;2976;0.377;0;1500;0;0;0;0;0;0;0 +2;2;2976;0.377;0;1500;0;0;0;0;0;0;0 diff --git a/openair1/SIMULATION/NR_PHY/BLER_SIMULATIONS/AWGN/AWGN_results/mcs3_awgn_5G.csv b/openair1/SIMULATION/NR_PHY/BLER_SIMULATIONS/AWGN/AWGN_results/mcs3_awgn_5G.csv new file mode 100644 index 0000000000..531c1548b0 --- /dev/null +++ b/openair1/SIMULATION/NR_PHY/BLER_SIMULATIONS/AWGN/AWGN_results/mcs3_awgn_5G.csv @@ -0,0 +1,62 @@ +SNR;MCS;TBS;rate;err0;trials0;err1;trials1;err2;trials2;err3;trials3;dci_err +-4;3;3912;0.4902;1500;1500;0;0;0;0;0;0;0 +-3.9;3;3912;0.4902;1500;1500;0;0;0;0;0;0;0 +-3.8;3;3912;0.4902;1500;1500;0;0;0;0;0;0;0 +-3.7;3;3912;0.4902;1500;1500;0;0;0;0;0;0;0 +-3.6;3;3912;0.4902;1500;1500;0;0;0;0;0;0;0 +-3.5;3;3912;0.4902;1500;1500;0;0;0;0;0;0;0 +-3.4;3;3912;0.4902;1500;1500;0;0;0;0;0;0;0 +-3.3;3;3912;0.4902;1500;1500;0;0;0;0;0;0;0 +-3.2;3;3912;0.4902;1500;1500;0;0;0;0;0;0;0 +-3.1;3;3912;0.4902;1500;1500;0;0;0;0;0;0;0 +-3;3;3912;0.4902;1500;1500;0;0;0;0;0;0;0 +-2.9;3;3912;0.4902;1500;1500;0;0;0;0;0;0;0 +-2.8;3;3912;0.4902;1500;1500;0;0;0;0;0;0;0 +-2.7;3;3912;0.4902;1500;1500;0;0;0;0;0;0;0 +-2.6;3;3912;0.4902;1500;1500;0;0;0;0;0;0;0 +-2.5;3;3912;0.4902;1500;1500;0;0;0;0;0;0;0 +-2.4;3;3912;0.4902;1500;1500;0;0;0;0;0;0;0 +-2.3;3;3912;0.4902;1500;1500;0;0;0;0;0;0;0 +-2.2;3;3912;0.4902;1500;1500;0;0;0;0;0;0;0 +-2.1;3;3912;0.4902;1500;1500;0;0;0;0;0;0;0 +-2;3;3912;0.4902;1500;1500;0;0;0;0;0;0;0 +-1.9;3;3912;0.4902;1500;1500;0;0;0;0;0;0;0 +-1.8;3;3912;0.4902;1500;1500;0;0;0;0;0;0;0 +-1.7;3;3912;0.4902;1500;1500;0;0;0;0;0;0;0 +-1.6;3;3912;0.4902;1500;1500;0;0;0;0;0;0;0 +-1.5;3;3912;0.4902;1500;1500;0;0;0;0;0;0;0 +-1.4;3;3912;0.4902;1500;1500;0;0;0;0;0;0;0 +-1.3;3;3912;0.4902;1500;1500;0;0;0;0;0;0;0 +-1.2;3;3912;0.4902;1500;1500;0;0;0;0;0;0;0 +-1.1;3;3912;0.4902;1500;1500;0;0;0;0;0;0;0 +-1;3;3912;0.4902;1500;1500;0;0;0;0;0;0;0 +-0.9;3;3912;0.4902;1499;1500;0;0;0;0;0;0;0 +-0.8;3;3912;0.4902;1498;1500;0;0;0;0;0;0;0 +-0.7;3;3912;0.4902;1496;1500;0;0;0;0;0;0;0 +-0.6;3;3912;0.4902;1495;1500;0;0;0;0;0;0;0 +-0.5;3;3912;0.4902;1494;1500;0;0;0;0;0;0;0 +-0.4;3;3912;0.4902;1322;1500;0;0;0;0;0;0;0 +-0.3;3;3912;0.4902;1169;1500;0;0;0;0;0;0;0 +-0.2;3;3912;0.4902;1034;1500;0;0;0;0;0;0;0 +-0.1;3;3912;0.4902;915;1500;0;0;0;0;0;0;0 +0;3;3912;0.4902;809;1500;0;0;0;0;0;0;0 +0.1;3;3912;0.4902;504;1500;0;0;0;0;0;0;0 +0.2;3;3912;0.4902;314;1500;0;0;0;0;0;0;0 +0.3;3;3912;0.4902;196;1500;0;0;0;0;0;0;0 +0.4;3;3912;0.4902;122;1500;0;0;0;0;0;0;0 +0.5;3;3912;0.4902;76;1500;0;0;0;0;0;0;0 +0.6;3;3912;0.4902;37;1500;0;0;0;0;0;0;0 +0.7;3;3912;0.4902;18;1500;0;0;0;0;0;0;0 +0.8;3;3912;0.4902;9;1500;0;0;0;0;0;0;0 +0.9;3;3912;0.4902;4;1500;0;0;0;0;0;0;0 +1;3;3912;0.4902;2;1500;0;0;0;0;0;0;0 +1.1;3;3912;0.4902;0;1500;0;0;0;0;0;0;0 +1.2;3;3912;0.4902;0;1500;0;0;0;0;0;0;0 +1.3;3;3912;0.4902;0;1500;0;0;0;0;0;0;0 +1.4;3;3912;0.4902;0;1500;0;0;0;0;0;0;0 +1.5;3;3912;0.4902;0;1500;0;0;0;0;0;0;0 +1.6;3;3912;0.4902;0;1500;0;0;0;0;0;0;0 +1.7;3;3912;0.4902;0;1500;0;0;0;0;0;0;0 +1.8;3;3912;0.4902;0;1500;0;0;0;0;0;0;0 +1.9;3;3912;0.4902;0;1500;0;0;0;0;0;0;0 +2;3;3912;0.4902;0;1500;0;0;0;0;0;0;0 diff --git a/openair1/SIMULATION/NR_PHY/BLER_SIMULATIONS/AWGN/AWGN_results/mcs4_awgn_5G.csv b/openair1/SIMULATION/NR_PHY/BLER_SIMULATIONS/AWGN/AWGN_results/mcs4_awgn_5G.csv new file mode 100644 index 0000000000..033c81afaf --- /dev/null +++ b/openair1/SIMULATION/NR_PHY/BLER_SIMULATIONS/AWGN/AWGN_results/mcs4_awgn_5G.csv @@ -0,0 +1,62 @@ +SNR;MCS;TBS;rate;err0;trials0;err1;trials1;err2;trials2;err3;trials3;dci_err +-1;4;4736;0.6016;1500;1500;0;0;0;0;0;0;0 +-0.9;4;4736;0.6016;1499;1500;0;0;0;0;0;0;0 +-0.8;4;4736;0.6016;1498;1500;0;0;0;0;0;0;0 +-0.7;4;4736;0.6016;1496;1500;0;0;0;0;0;0;0 +-0.6;4;4736;0.6016;1495;1500;0;0;0;0;0;0;0 +-0.5;4;4736;0.6016;1494;1500;0;0;0;0;0;0;0 +-0.4;4;4736;0.6016;1322;1500;0;0;0;0;0;0;0 +-0.3;4;4736;0.6016;1169;1500;0;0;0;0;0;0;0 +-0.2;4;4736;0.6016;1034;1500;0;0;0;0;0;0;0 +-0.1;4;4736;0.6016;915;1500;0;0;0;0;0;0;0 +0;4;4736;0.6016;809;1500;0;0;0;0;0;0;0 +0.1;4;4736;0.6016;504;1500;0;0;0;0;0;0;0 +0.2;4;4736;0.6016;314;1500;0;0;0;0;0;0;0 +0.3;4;4736;0.6016;196;1500;0;0;0;0;0;0;0 +0.4;4;4736;0.6016;122;1500;0;0;0;0;0;0;0 +0.5;4;4736;0.6016;76;1500;0;0;0;0;0;0;0 +0.6;4;4736;0.6016;37;1500;0;0;0;0;0;0;0 +0.7;4;4736;0.6016;18;1500;0;0;0;0;0;0;0 +0.8;4;4736;0.6016;9;1500;0;0;0;0;0;0;0 +0.9;4;4736;0.6016;4;1500;0;0;0;0;0;0;0 +1;4;4736;0.6016;2;1500;0;0;0;0;0;0;0 +1.1;4;4736;0.6016;0;1500;0;0;0;0;0;0;0 +1.2;4;4736;0.6016;0;1500;0;0;0;0;0;0;0 +1.3;4;4736;0.6016;0;1500;0;0;0;0;0;0;0 +1.4;4;4736;0.6016;0;1500;0;0;0;0;0;0;0 +1.5;4;4736;0.6016;0;1500;0;0;0;0;0;0;0 +1.6;4;4736;0.6016;0;1500;0;0;0;0;0;0;0 +1.7;4;4736;0.6016;0;1500;0;0;0;0;0;0;0 +1.8;4;4736;0.6016;0;1500;0;0;0;0;0;0;0 +1.9;4;4736;0.6016;0;1500;0;0;0;0;0;0;0 +2;4;4736;0.6016;0;1500;0;0;0;0;0;0;0 +2.1;4;4736;0.6016;0;1500;0;0;0;0;0;0;0 +2.2;4;4736;0.6016;0;1500;0;0;0;0;0;0;0 +2.3;4;4736;0.6016;0;1500;0;0;0;0;0;0;0 +2.4;4;4736;0.6016;0;1500;0;0;0;0;0;0;0 +2.5;4;4736;0.6016;0;1500;0;0;0;0;0;0;0 +2.6;4;4736;0.6016;0;1500;0;0;0;0;0;0;0 +2.7;4;4736;0.6016;0;1500;0;0;0;0;0;0;0 +2.8;4;4736;0.6016;0;1500;0;0;0;0;0;0;0 +2.9;4;4736;0.6016;0;1500;0;0;0;0;0;0;0 +3;4;4736;0.6016;0;1500;0;0;0;0;0;0;0 +3.1;4;4736;0.6016;0;1500;0;0;0;0;0;0;0 +3.2;4;4736;0.6016;0;1500;0;0;0;0;0;0;0 +3.3;4;4736;0.6016;0;1500;0;0;0;0;0;0;0 +3.4;4;4736;0.6016;0;1500;0;0;0;0;0;0;0 +3.5;4;4736;0.6016;0;1500;0;0;0;0;0;0;0 +3.6;4;4736;0.6016;0;1500;0;0;0;0;0;0;0 +3.7;4;4736;0.6016;0;1500;0;0;0;0;0;0;0 +3.8;4;4736;0.6016;0;1500;0;0;0;0;0;0;0 +3.9;4;4736;0.6016;0;1500;0;0;0;0;0;0;0 +4;4;4736;0.6016;0;1500;0;0;0;0;0;0;0 +4.1;4;4736;0.6016;0;1500;0;0;0;0;0;0;0 +4.2;4;4736;0.6016;0;1500;0;0;0;0;0;0;0 +4.3;4;4736;0.6016;0;1500;0;0;0;0;0;0;0 +4.4;4;4736;0.6016;0;1500;0;0;0;0;0;0;0 +4.5;4;4736;0.6016;0;1500;0;0;0;0;0;0;0 +4.6;4;4736;0.6016;0;1500;0;0;0;0;0;0;0 +4.7;4;4736;0.6016;0;1500;0;0;0;0;0;0;0 +4.8;4;4736;0.6016;0;1500;0;0;0;0;0;0;0 +4.9;4;4736;0.6016;0;1500;0;0;0;0;0;0;0 +5;4;4736;0.6016;0;1500;0;0;0;0;0;0;0 diff --git a/openair1/SIMULATION/NR_PHY/BLER_SIMULATIONS/AWGN/AWGN_results/mcs5_awgn_5G.csv b/openair1/SIMULATION/NR_PHY/BLER_SIMULATIONS/AWGN/AWGN_results/mcs5_awgn_5G.csv new file mode 100644 index 0000000000..f741966016 --- /dev/null +++ b/openair1/SIMULATION/NR_PHY/BLER_SIMULATIONS/AWGN/AWGN_results/mcs5_awgn_5G.csv @@ -0,0 +1,62 @@ +SNR;MCS;TBS;rate;err0;trials0;err1;trials1;err2;trials2;err3;trials3;dci_err +-1;5;5888;0.7402;1500;1500;0;0;0;0;0;0;0 +-0.9;5;5888;0.7402;1500;1500;0;0;0;0;0;0;0 +-0.8;5;5888;0.7402;1500;1500;0;0;0;0;0;0;0 +-0.7;5;5888;0.7402;1500;1500;0;0;0;0;0;0;0 +-0.6;5;5888;0.7402;1500;1500;0;0;0;0;0;0;0 +-0.5;5;5888;0.7402;1500;1500;0;0;0;0;0;0;0 +-0.4;5;5888;0.7402;1500;1500;0;0;0;0;0;0;0 +-0.3;5;5888;0.7402;1500;1500;0;0;0;0;0;0;0 +-0.2;5;5888;0.7402;1500;1500;0;0;0;0;0;0;0 +-0.1;5;5888;0.7402;1500;1500;0;0;0;0;0;0;0 +0;5;5888;0.7402;1500;1500;0;0;0;0;0;0;0 +0.1;5;5888;0.7402;1499;1500;0;0;0;0;0;0;0 +0.2;5;5888;0.7402;1499;1500;0;0;0;0;0;0;0 +0.3;5;5888;0.7402;1498;1500;0;0;0;0;0;0;0 +0.4;5;5888;0.7402;1498;1500;0;0;0;0;0;0;0 +0.5;5;5888;0.7402;1497;1500;0;0;0;0;0;0;0 +0.6;5;5888;0.7402;1323;1500;0;0;0;0;0;0;0 +0.7;5;5888;0.7402;1170;1500;0;0;0;0;0;0;0 +0.8;5;5888;0.7402;1034;1500;0;0;0;0;0;0;0 +0.9;5;5888;0.7402;914;1500;0;0;0;0;0;0;0 +1;5;5888;0.7402;808;1500;0;0;0;0;0;0;0 +1.1;5;5888;0.7402;513;1500;0;0;0;0;0;0;0 +1.2;5;5888;0.7402;326;1500;0;0;0;0;0;0;0 +1.3;5;5888;0.7402;207;1500;0;0;0;0;0;0;0 +1.4;5;5888;0.7402;131;1500;0;0;0;0;0;0;0 +1.5;5;5888;0.7402;83;1500;0;0;0;0;0;0;0 +1.6;5;5888;0.7402;48;1500;0;0;0;0;0;0;0 +1.7;5;5888;0.7402;28;1500;0;0;0;0;0;0;0 +1.8;5;5888;0.7402;16;1500;0;0;0;0;0;0;0 +1.9;5;5888;0.7402;9;1500;0;0;0;0;0;0;0 +2;5;5888;0.7402;5;1500;0;0;0;0;0;0;0 +2.1;5;5888;0.7402;2;1500;0;0;0;0;0;0;0 +2.2;5;5888;0.7402;1;1500;0;0;0;0;0;0;0 +2.3;5;5888;0.7402;0;1500;0;0;0;0;0;0;0 +2.4;5;5888;0.7402;0;1500;0;0;0;0;0;0;0 +2.5;5;5888;0.7402;0;1500;0;0;0;0;0;0;0 +2.6;5;5888;0.7402;0;1500;0;0;0;0;0;0;0 +2.7;5;5888;0.7402;0;1500;0;0;0;0;0;0;0 +2.8;5;5888;0.7402;0;1500;0;0;0;0;0;0;0 +2.9;5;5888;0.7402;0;1500;0;0;0;0;0;0;0 +3;5;5888;0.7402;0;1500;0;0;0;0;0;0;0 +3.1;5;5888;0.7402;0;1500;0;0;0;0;0;0;0 +3.2;5;5888;0.7402;0;1500;0;0;0;0;0;0;0 +3.3;5;5888;0.7402;0;1500;0;0;0;0;0;0;0 +3.4;5;5888;0.7402;0;1500;0;0;0;0;0;0;0 +3.5;5;5888;0.7402;0;1500;0;0;0;0;0;0;0 +3.6;5;5888;0.7402;0;1500;0;0;0;0;0;0;0 +3.7;5;5888;0.7402;0;1500;0;0;0;0;0;0;0 +3.8;5;5888;0.7402;0;1500;0;0;0;0;0;0;0 +3.9;5;5888;0.7402;0;1500;0;0;0;0;0;0;0 +4;5;5888;0.7402;0;1500;0;0;0;0;0;0;0 +4.1;5;5888;0.7402;0;1500;0;0;0;0;0;0;0 +4.2;5;5888;0.7402;0;1500;0;0;0;0;0;0;0 +4.3;5;5888;0.7402;0;1500;0;0;0;0;0;0;0 +4.4;5;5888;0.7402;0;1500;0;0;0;0;0;0;0 +4.5;5;5888;0.7402;0;1500;0;0;0;0;0;0;0 +4.6;5;5888;0.7402;0;1500;0;0;0;0;0;0;0 +4.7;5;5888;0.7402;0;1500;0;0;0;0;0;0;0 +4.8;5;5888;0.7402;0;1500;0;0;0;0;0;0;0 +4.9;5;5888;0.7402;0;1500;0;0;0;0;0;0;0 +5;5;5888;0.7402;0;1500;0;0;0;0;0;0;0 diff --git a/openair1/SIMULATION/NR_PHY/BLER_SIMULATIONS/AWGN/AWGN_results/mcs6_awgn_5G.csv b/openair1/SIMULATION/NR_PHY/BLER_SIMULATIONS/AWGN/AWGN_results/mcs6_awgn_5G.csv new file mode 100644 index 0000000000..350c53d695 --- /dev/null +++ b/openair1/SIMULATION/NR_PHY/BLER_SIMULATIONS/AWGN/AWGN_results/mcs6_awgn_5G.csv @@ -0,0 +1,62 @@ +SNR;MCS;TBS;rate;err0;trials0;err1;trials1;err2;trials2;err3;trials3;dci_err +-1;6;6912;0.877;1500;1500;0;0;0;0;0;0;0 +-0.9;6;6912;0.877;1500;1500;0;0;0;0;0;0;0 +-0.8;6;6912;0.877;1500;1500;0;0;0;0;0;0;0 +-0.7;6;6912;0.877;1500;1500;0;0;0;0;0;0;0 +-0.6;6;6912;0.877;1500;1500;0;0;0;0;0;0;0 +-0.5;6;6912;0.877;1500;1500;0;0;0;0;0;0;0 +-0.4;6;6912;0.877;1500;1500;0;0;0;0;0;0;0 +-0.3;6;6912;0.877;1500;1500;0;0;0;0;0;0;0 +-0.2;6;6912;0.877;1500;1500;0;0;0;0;0;0;0 +-0.1;6;6912;0.877;1500;1500;0;0;0;0;0;0;0 +0;6;6912;0.877;1500;1500;0;0;0;0;0;0;0 +0.1;6;6912;0.877;1500;1500;0;0;0;0;0;0;0 +0.2;6;6912;0.877;1500;1500;0;0;0;0;0;0;0 +0.3;6;6912;0.877;1500;1500;0;0;0;0;0;0;0 +0.4;6;6912;0.877;1500;1500;0;0;0;0;0;0;0 +0.5;6;6912;0.877;1500;1500;0;0;0;0;0;0;0 +0.6;6;6912;0.877;1500;1500;0;0;0;0;0;0;0 +0.7;6;6912;0.877;1500;1500;0;0;0;0;0;0;0 +0.8;6;6912;0.877;1500;1500;0;0;0;0;0;0;0 +0.9;6;6912;0.877;1500;1500;0;0;0;0;0;0;0 +1;6;6912;0.877;1500;1500;0;0;0;0;0;0;0 +1.1;6;6912;0.877;1493;1500;0;0;0;0;0;0;0 +1.2;6;6912;0.877;1487;1500;0;0;0;0;0;0;0 +1.3;6;6912;0.877;1480;1500;0;0;0;0;0;0;0 +1.4;6;6912;0.877;1473;1500;0;0;0;0;0;0;0 +1.5;6;6912;0.877;1467;1500;0;0;0;0;0;0;0 +1.6;6;6912;0.877;1117;1500;0;0;0;0;0;0;0 +1.7;6;6912;0.877;850;1500;0;0;0;0;0;0;0 +1.8;6;6912;0.877;648;1500;0;0;0;0;0;0;0 +1.9;6;6912;0.877;493;1500;0;0;0;0;0;0;0 +2;6;6912;0.877;376;1500;0;0;0;0;0;0;0 +2.1;6;6912;0.877;254;1500;0;0;0;0;0;0;0 +2.2;6;6912;0.877;172;1500;0;0;0;0;0;0;0 +2.3;6;6912;0.877;116;1500;0;0;0;0;0;0;0 +2.4;6;6912;0.877;79;1500;0;0;0;0;0;0;0 +2.5;6;6912;0.877;53;1500;0;0;0;0;0;0;0 +2.6;6;6912;0.877;32;1500;0;0;0;0;0;0;0 +2.7;6;6912;0.877;19;1500;0;0;0;0;0;0;0 +2.8;6;6912;0.877;11;1500;0;0;0;0;0;0;0 +2.9;6;6912;0.877;7;1500;0;0;0;0;0;0;0 +3;6;6912;0.877;4;1500;0;0;0;0;0;0;0 +3.1;6;6912;0.877;0;1500;0;0;0;0;0;0;0 +3.2;6;6912;0.877;0;1500;0;0;0;0;0;0;0 +3.3;6;6912;0.877;0;1500;0;0;0;0;0;0;0 +3.4;6;6912;0.877;0;1500;0;0;0;0;0;0;0 +3.5;6;6912;0.877;0;1500;0;0;0;0;0;0;0 +3.6;6;6912;0.877;0;1500;0;0;0;0;0;0;0 +3.7;6;6912;0.877;0;1500;0;0;0;0;0;0;0 +3.8;6;6912;0.877;0;1500;0;0;0;0;0;0;0 +3.9;6;6912;0.877;0;1500;0;0;0;0;0;0;0 +4;6;6912;0.877;0;1500;0;0;0;0;0;0;0 +4.1;6;6912;0.877;0;1500;0;0;0;0;0;0;0 +4.2;6;6912;0.877;0;1500;0;0;0;0;0;0;0 +4.3;6;6912;0.877;0;1500;0;0;0;0;0;0;0 +4.4;6;6912;0.877;0;1500;0;0;0;0;0;0;0 +4.5;6;6912;0.877;0;1500;0;0;0;0;0;0;0 +4.6;6;6912;0.877;0;1500;0;0;0;0;0;0;0 +4.7;6;6912;0.877;0;1500;0;0;0;0;0;0;0 +4.8;6;6912;0.877;0;1500;0;0;0;0;0;0;0 +4.9;6;6912;0.877;0;1500;0;0;0;0;0;0;0 +5;6;6912;0.877;0;1500;0;0;0;0;0;0;0 diff --git a/openair1/SIMULATION/NR_PHY/BLER_SIMULATIONS/AWGN/AWGN_results/mcs7_awgn_5G.csv b/openair1/SIMULATION/NR_PHY/BLER_SIMULATIONS/AWGN/AWGN_results/mcs7_awgn_5G.csv new file mode 100644 index 0000000000..9bd689cf0e --- /dev/null +++ b/openair1/SIMULATION/NR_PHY/BLER_SIMULATIONS/AWGN/AWGN_results/mcs7_awgn_5G.csv @@ -0,0 +1,62 @@ +SNR;MCS;TBS;rate;err0;trials0;err1;trials1;err2;trials2;err3;trials3;dci_err +-1;7;8912;1.0273;1500;1500;0;0;0;0;0;0;0 +-0.9;7;8912;1.0273;1500;1500;0;0;0;0;0;0;0 +-0.8;7;8912;1.0273;1500;1500;0;0;0;0;0;0;0 +-0.7;7;8912;1.0273;1500;1500;0;0;0;0;0;0;0 +-0.6;7;8912;1.0273;1500;1500;0;0;0;0;0;0;0 +-0.5;7;8912;1.0273;1500;1500;0;0;0;0;0;0;0 +-0.4;7;8912;1.0273;1500;1500;0;0;0;0;0;0;0 +-0.3;7;8912;1.0273;1500;1500;0;0;0;0;0;0;0 +-0.2;7;8912;1.0273;1500;1500;0;0;0;0;0;0;0 +-0.1;7;8912;1.0273;1500;1500;0;0;0;0;0;0;0 +0;7;8912;1.0273;1500;1500;0;0;0;0;0;0;0 +0.1;7;8912;1.0273;1500;1500;0;0;0;0;0;0;0 +0.2;7;8912;1.0273;1500;1500;0;0;0;0;0;0;0 +0.3;7;8912;1.0273;1500;1500;0;0;0;0;0;0;0 +0.4;7;8912;1.0273;1500;1500;0;0;0;0;0;0;0 +0.5;7;8912;1.0273;1500;1500;0;0;0;0;0;0;0 +0.6;7;8912;1.0273;1500;1500;0;0;0;0;0;0;0 +0.7;7;8912;1.0273;1500;1500;0;0;0;0;0;0;0 +0.8;7;8912;1.0273;1500;1500;0;0;0;0;0;0;0 +0.9;7;8912;1.0273;1500;1500;0;0;0;0;0;0;0 +1;7;8912;1.0273;1500;1500;0;0;0;0;0;0;0 +1.1;7;8912;1.0273;1500;1500;0;0;0;0;0;0;0 +1.2;7;8912;1.0273;1500;1500;0;0;0;0;0;0;0 +1.3;7;8912;1.0273;1500;1500;0;0;0;0;0;0;0 +1.4;7;8912;1.0273;1500;1500;0;0;0;0;0;0;0 +1.5;7;8912;1.0273;1500;1500;0;0;0;0;0;0;0 +1.6;7;8912;1.0273;1500;1500;0;0;0;0;0;0;0 +1.7;7;8912;1.0273;1500;1500;0;0;0;0;0;0;0 +1.8;7;8912;1.0273;1500;1500;0;0;0;0;0;0;0 +1.9;7;8912;1.0273;1500;1500;0;0;0;0;0;0;0 +2;7;8912;1.0273;1500;1500;0;0;0;0;0;0;0 +2.1;7;8912;1.0273;1492;1500;0;0;0;0;0;0;0 +2.2;7;8912;1.0273;1484;1500;0;0;0;0;0;0;0 +2.3;7;8912;1.0273;1477;1500;0;0;0;0;0;0;0 +2.4;7;8912;1.0273;1469;1500;0;0;0;0;0;0;0 +2.5;7;8912;1.0273;1462;1500;0;0;0;0;0;0;0 +2.6;7;8912;1.0273;1159;1500;0;0;0;0;0;0;0 +2.7;7;8912;1.0273;919;1500;0;0;0;0;0;0;0 +2.8;7;8912;1.0273;729;1500;0;0;0;0;0;0;0 +2.9;7;8912;1.0273;578;1500;0;0;0;0;0;0;0 +3;7;8912;1.0273;458;1500;0;0;0;0;0;0;0 +3.1;7;8912;1.0273;319;1500;0;0;0;0;0;0;0 +3.2;7;8912;1.0273;222;1500;0;0;0;0;0;0;0 +3.3;7;8912;1.0273;155;1500;0;0;0;0;0;0;0 +3.4;7;8912;1.0273;108;1500;0;0;0;0;0;0;0 +3.5;7;8912;1.0273;75;1500;0;0;0;0;0;0;0 +3.6;7;8912;1.0273;48;1500;0;0;0;0;0;0;0 +3.7;7;8912;1.0273;30;1500;0;0;0;0;0;0;0 +3.8;7;8912;1.0273;19;1500;0;0;0;0;0;0;0 +3.9;7;8912;1.0273;12;1500;0;0;0;0;0;0;0 +4;7;8912;1.0273;8;1500;0;0;0;0;0;0;0 +4.1;7;8912;1.0273;4;1500;0;0;0;0;0;0;0 +4.2;7;8912;1.0273;2;1500;0;0;0;0;0;0;0 +4.3;7;8912;1.0273;1;1500;0;0;0;0;0;0;0 +4.4;7;8912;1.0273;0;1500;0;0;0;0;0;0;0 +4.5;7;8912;1.0273;0;1500;0;0;0;0;0;0;0 +4.6;7;8912;1.0273;0;1500;0;0;0;0;0;0;0 +4.7;7;8912;1.0273;0;1500;0;0;0;0;0;0;0 +4.8;7;8912;1.0273;0;1500;0;0;0;0;0;0;0 +4.9;7;8912;1.0273;0;1500;0;0;0;0;0;0;0 +5;7;8912;1.0273;0;1500;0;0;0;0;0;0;0 diff --git a/openair1/SIMULATION/NR_PHY/BLER_SIMULATIONS/AWGN/AWGN_results/mcs8_awgn_5G.csv b/openair1/SIMULATION/NR_PHY/BLER_SIMULATIONS/AWGN/AWGN_results/mcs8_awgn_5G.csv new file mode 100644 index 0000000000..470cce69ae --- /dev/null +++ b/openair1/SIMULATION/NR_PHY/BLER_SIMULATIONS/AWGN/AWGN_results/mcs8_awgn_5G.csv @@ -0,0 +1,62 @@ +SNR;MCS;TBS;rate;err0;trials0;err1;trials1;err2;trials2;err3;trials3;dci_err +-1;8;9224;1.1758;1500;1500;0;0;0;0;0;0;0 +-0.9;8;9224;1.1758;1500;1500;0;0;0;0;0;0;0 +-0.8;8;9224;1.1758;1500;1500;0;0;0;0;0;0;0 +-0.7;8;9224;1.1758;1500;1500;0;0;0;0;0;0;0 +-0.6;8;9224;1.1758;1500;1500;0;0;0;0;0;0;0 +-0.5;8;9224;1.1758;1500;1500;0;0;0;0;0;0;0 +-0.4;8;9224;1.1758;1500;1500;0;0;0;0;0;0;0 +-0.3;8;9224;1.1758;1500;1500;0;0;0;0;0;0;0 +-0.2;8;9224;1.1758;1500;1500;0;0;0;0;0;0;0 +-0.1;8;9224;1.1758;1500;1500;0;0;0;0;0;0;0 +0;8;9224;1.1758;1500;1500;0;0;0;0;0;0;0 +0.1;8;9224;1.1758;1500;1500;0;0;0;0;0;0;0 +0.2;8;9224;1.1758;1500;1500;0;0;0;0;0;0;0 +0.3;8;9224;1.1758;1500;1500;0;0;0;0;0;0;0 +0.4;8;9224;1.1758;1500;1500;0;0;0;0;0;0;0 +0.5;8;9224;1.1758;1500;1500;0;0;0;0;0;0;0 +0.6;8;9224;1.1758;1500;1500;0;0;0;0;0;0;0 +0.7;8;9224;1.1758;1500;1500;0;0;0;0;0;0;0 +0.8;8;9224;1.1758;1500;1500;0;0;0;0;0;0;0 +0.9;8;9224;1.1758;1500;1500;0;0;0;0;0;0;0 +1;8;9224;1.1758;1500;1500;0;0;0;0;0;0;0 +1.1;8;9224;1.1758;1500;1500;0;0;0;0;0;0;0 +1.2;8;9224;1.1758;1500;1500;0;0;0;0;0;0;0 +1.3;8;9224;1.1758;1500;1500;0;0;0;0;0;0;0 +1.4;8;9224;1.1758;1500;1500;0;0;0;0;0;0;0 +1.5;8;9224;1.1758;1500;1500;0;0;0;0;0;0;0 +1.6;8;9224;1.1758;1500;1500;0;0;0;0;0;0;0 +1.7;8;9224;1.1758;1500;1500;0;0;0;0;0;0;0 +1.8;8;9224;1.1758;1500;1500;0;0;0;0;0;0;0 +1.9;8;9224;1.1758;1500;1500;0;0;0;0;0;0;0 +2;8;9224;1.1758;1500;1500;0;0;0;0;0;0;0 +2.1;8;9224;1.1758;1500;1500;0;0;0;0;0;0;0 +2.2;8;9224;1.1758;1500;1500;0;0;0;0;0;0;0 +2.3;8;9224;1.1758;1500;1500;0;0;0;0;0;0;0 +2.4;8;9224;1.1758;1500;1500;0;0;0;0;0;0;0 +2.5;8;9224;1.1758;1500;1500;0;0;0;0;0;0;0 +2.6;8;9224;1.1758;1500;1500;0;0;0;0;0;0;0 +2.7;8;9224;1.1758;1500;1500;0;0;0;0;0;0;0 +2.8;8;9224;1.1758;1500;1500;0;0;0;0;0;0;0 +2.9;8;9224;1.1758;1500;1500;0;0;0;0;0;0;0 +3;8;9224;1.1758;1500;1500;0;0;0;0;0;0;0 +3.1;8;9224;1.1758;1464;1500;0;0;0;0;0;0;0 +3.2;8;9224;1.1758;1429;1500;0;0;0;0;0;0;0 +3.3;8;9224;1.1758;1394;1500;0;0;0;0;0;0;0 +3.4;8;9224;1.1758;1361;1500;0;0;0;0;0;0;0 +3.5;8;9224;1.1758;1328;1500;0;0;0;0;0;0;0 +3.6;8;9224;1.1758;973;1500;0;0;0;0;0;0;0 +3.7;8;9224;1.1758;713;1500;0;0;0;0;0;0;0 +3.8;8;9224;1.1758;522;1500;0;0;0;0;0;0;0 +3.9;8;9224;1.1758;382;1500;0;0;0;0;0;0;0 +4;8;9224;1.1758;280;1500;0;0;0;0;0;0;0 +4.1;8;9224;1.1758;190;1500;0;0;0;0;0;0;0 +4.2;8;9224;1.1758;129;1500;0;0;0;0;0;0;0 +4.3;8;9224;1.1758;87;1500;0;0;0;0;0;0;0 +4.4;8;9224;1.1758;59;1500;0;0;0;0;0;0;0 +4.5;8;9224;1.1758;40;1500;0;0;0;0;0;0;0 +4.6;8;9224;1.1758;20;1500;0;0;0;0;0;0;0 +4.7;8;9224;1.1758;10;1500;0;0;0;0;0;0;0 +4.8;8;9224;1.1758;5;1500;0;0;0;0;0;0;0 +4.9;8;9224;1.1758;2;1500;0;0;0;0;0;0;0 +5;8;9224;1.1758;1;1500;0;0;0;0;0;0;0 diff --git a/openair1/SIMULATION/NR_PHY/BLER_SIMULATIONS/AWGN/AWGN_results/mcs9_awgn_5G.csv b/openair1/SIMULATION/NR_PHY/BLER_SIMULATIONS/AWGN/AWGN_results/mcs9_awgn_5G.csv new file mode 100644 index 0000000000..2ba438ea49 --- /dev/null +++ b/openair1/SIMULATION/NR_PHY/BLER_SIMULATIONS/AWGN/AWGN_results/mcs9_awgn_5G.csv @@ -0,0 +1,64 @@ +SNR;MCS;TBS;rate;err0;trials0;err1;trials1;err2;trials2;err3;trials3;dci_err +-1;9;10504;1.3262;1500;1500;0;0;0;0;0;0;0 +-0.9;9;10504;1.3262;1500;1500;0;0;0;0;0;0;0 +-0.8;9;10504;1.3262;1500;1500;0;0;0;0;0;0;0 +-0.7;9;10504;1.3262;1500;1500;0;0;0;0;0;0;0 +-0.6;9;10504;1.3262;1500;1500;0;0;0;0;0;0;0 +-0.5;9;10504;1.3262;1500;1500;0;0;0;0;0;0;0 +-0.4;9;10504;1.3262;1500;1500;0;0;0;0;0;0;0 +-0.3;9;10504;1.3262;1500;1500;0;0;0;0;0;0;0 +-0.2;9;10504;1.3262;1500;1500;0;0;0;0;0;0;0 +-0.1;9;10504;1.3262;1500;1500;0;0;0;0;0;0;0 +0;9;10504;1.3262;1500;1500;0;0;0;0;0;0;0 +0.1;9;10504;1.3262;1500;1500;0;0;0;0;0;0;0 +0.2;9;10504;1.3262;1500;1500;0;0;0;0;0;0;0 +0.3;9;10504;1.3262;1500;1500;0;0;0;0;0;0;0 +0.4;9;10504;1.3262;1500;1500;0;0;0;0;0;0;0 +0.5;9;10504;1.3262;1500;1500;0;0;0;0;0;0;0 +0.6;9;10504;1.3262;1500;1500;0;0;0;0;0;0;0 +0.7;9;10504;1.3262;1500;1500;0;0;0;0;0;0;0 +0.8;9;10504;1.3262;1500;1500;0;0;0;0;0;0;0 +0.9;9;10504;1.3262;1500;1500;0;0;0;0;0;0;0 +1;9;10504;1.3262;1500;1500;0;0;0;0;0;0;0 +1.1;9;10504;1.3262;1500;1500;0;0;0;0;0;0;0 +1.2;9;10504;1.3262;1500;1500;0;0;0;0;0;0;0 +1.3;9;10504;1.3262;1500;1500;0;0;0;0;0;0;0 +1.4;9;10504;1.3262;1500;1500;0;0;0;0;0;0;0 +1.5;9;10504;1.3262;1500;1500;0;0;0;0;0;0;0 +1.6;9;10504;1.3262;1500;1500;0;0;0;0;0;0;0 +1.7;9;10504;1.3262;1500;1500;0;0;0;0;0;0;0 +1.8;9;10504;1.3262;1500;1500;0;0;0;0;0;0;0 +1.9;9;10504;1.3262;1500;1500;0;0;0;0;0;0;0 +2;9;10504;1.3262;1500;1500;0;0;0;0;0;0;0 +2.1;9;10504;1.3262;1500;1500;0;0;0;0;0;0;0 +2.2;9;10504;1.3262;1500;1500;0;0;0;0;0;0;0 +2.3;9;10504;1.3262;1500;1500;0;0;0;0;0;0;0 +2.4;9;10504;1.3262;1500;1500;0;0;0;0;0;0;0 +2.5;9;10504;1.3262;1500;1500;0;0;0;0;0;0;0 +2.6;9;10504;1.3262;1500;1500;0;0;0;0;0;0;0 +2.7;9;10504;1.3262;1500;1500;0;0;0;0;0;0;0 +2.8;9;10504;1.3262;1500;1500;0;0;0;0;0;0;0 +2.9;9;10504;1.3262;1500;1500;0;0;0;0;0;0;0 +3;9;10504;1.3262;1500;1500;0;0;0;0;0;0;0 +3.1;9;10504;1.3262;1500;1500;0;0;0;0;0;0;0 +3.2;9;10504;1.3262;1500;1500;0;0;0;0;0;0;0 +3.3;9;10504;1.3262;1500;1500;0;0;0;0;0;0;0 +3.4;9;10504;1.3262;1500;1500;0;0;0;0;0;0;0 +3.5;9;10504;1.3262;1500;1500;0;0;0;0;0;0;0 +3.6;9;10504;1.3262;1500;1500;0;0;0;0;0;0;0 +3.7;9;10504;1.3262;1499;1500;0;0;0;0;0;0;0 +3.8;9;10504;1.3262;1499;1500;0;0;0;0;0;0;0 +3.9;9;10504;1.3262;1499;1500;0;0;0;0;0;0;0 +4;9;10504;1.3262;1498;1500;0;0;0;0;0;0;0 +4.1;9;10504;1.3262;1339;1500;0;0;0;0;0;0;0 +4.2;9;10504;1.3262;1196;1500;0;0;0;0;0;0;0 +4.3;9;10504;1.3262;1068;1500;0;0;0;0;0;0;0 +4.4;9;10504;1.3262;955;1500;0;0;0;0;0;0;0 +4.5;9;10504;1.3262;853;1500;0;0;0;0;0;0;0 +4.6;9;10504;1.3262;552;1500;0;0;0;0;0;0;0 +4.7;9;10504;1.3262;357;1500;0;0;0;0;0;0;0 +4.8;9;10504;1.3262;231;1500;0;0;0;0;0;0;0 +4.9;9;10504;1.3262;149;1500;0;0;0;0;0;0;0 +5;9;10504;1.3262;96;1500;0;0;0;0;0;0;0 +5.1;9;10504;1.3262;0;1500;0;0;0;0;0;0;0 +5.2;9;10504;1.3262;0;1500;0;0;0;0;0;0;0 diff --git a/openair1/SIMULATION/NR_PHY/dlschsim.c b/openair1/SIMULATION/NR_PHY/dlschsim.c index d3ee3fc10e..d3da01638a 100644 --- a/openair1/SIMULATION/NR_PHY/dlschsim.c +++ b/openair1/SIMULATION/NR_PHY/dlschsim.c @@ -47,14 +47,18 @@ #include "openair1/SIMULATION/RF/rf.h" #include "openair1/SIMULATION/NR_PHY/nr_unitary_defs.h" #include "openair1/SIMULATION/NR_PHY/nr_dummy_functions.c" +#include "openair2/LAYER2/NR_MAC_COMMON/nr_mac_common.h" + //#define DEBUG_NR_DLSCHSIM +THREAD_STRUCT thread_struct; PHY_VARS_gNB *gNB; PHY_VARS_NR_UE *UE; RAN_CONTEXT_t RC; UE_nr_rxtx_proc_t proc; int32_t uplink_frequency_offset[MAX_NUM_CCs][4]; +uint64_t downlink_frequency[MAX_NUM_CCs][4]; double cpuf; //uint8_t nfapi_mode = 0; @@ -120,6 +124,7 @@ int main(int argc, char **argv) double DS_TDL = .03; cpuf = get_cpu_freq_GHz(); char gNBthreads[128]="n"; + int Tbslbrm = 950984; if (load_configmodule(argc, argv, CONFIG_ENABLECMDLINEONLY) == 0) { exit_fun("[NR_DLSCHSIM] Error, configuration module init failed\n"); @@ -396,19 +401,6 @@ int main(int argc, char **argv) load_pbch_desc(pbch_file_fd); } - /* for (int k=0; k<2; k++) { - // Create transport channel structures for 2 transport blocks (MIMO) - for (i=0; i<2; i++) { - gNB->dlsch[k][i] = new_gNB_dlsch(Kmimo,8,Nsoft,0,frame_parms,gNB_config); - - if (!gNB->dlsch[k][i]) { - printf("Can't get eNB dlsch structures\n"); - exit(-1); - } - gNB->dlsch[k][i]->Nsoft = 10; - gNB->dlsch[k][i]->rnti = n_rnti+k; - } - }*/ //configure UE UE = malloc(sizeof(PHY_VARS_NR_UE)); memcpy(&UE->frame_parms, frame_parms, sizeof(NR_DL_FRAME_PARMS)); @@ -421,10 +413,10 @@ int main(int argc, char **argv) //nr_init_frame_parms_ue(&UE->frame_parms); //init_nr_ue_transport(UE, 0); + int num_codeword = NR_MAX_NB_LAYERS > 4? 2:1; for (int sf = 0; sf < 2; sf++) { - for (i = 0; i < 2; i++) { + for (i = 0; i < num_codeword; i++) { UE->dlsch[sf][0][i] = new_nr_ue_dlsch(Kmimo, 8, Nsoft, 5, N_RB_DL); - if (!UE->dlsch[sf][0][i]) { printf("Can't get ue dlsch structures\n"); exit(-1); @@ -435,18 +427,15 @@ int main(int argc, char **argv) } unsigned char harq_pid = 0; //dlsch->harq_ids[subframe]; - processingData_L1tx_t msgDataTx; - init_DLSCH_struct(gNB, &msgDataTx); + processingData_L1tx_t msgDataTx; + init_DLSCH_struct(gNB, &msgDataTx); NR_gNB_DLSCH_t *dlsch = msgDataTx.dlsch[0][0]; nfapi_nr_dl_tti_pdsch_pdu_rel15_t *rel15 = &dlsch->harq_process.pdsch_pdu.pdsch_pdu_rel15; //time_stats_t *rm_stats, *te_stats, *i_stats; - uint8_t is_crnti = 0, llr8_flag = 0; + uint8_t is_crnti = 0; unsigned int TBS = 8424; - unsigned int available_bits; uint8_t nb_re_dmrs = 6; // No data in dmrs symbol uint16_t length_dmrs = 1; - unsigned char mod_order; - uint16_t rate; uint8_t Nl = 1; uint8_t rvidx = 0; dlsch->rnti = 1; @@ -454,9 +443,9 @@ int main(int argc, char **argv) dlsch->harq_processes[0]->rvidx = rvidx;*/ //printf("dlschsim harqid %d nb_rb %d, mscs %d\n",dlsch->harq_ids[subframe], // dlsch->harq_processes[0]->nb_rb,dlsch->harq_processes[0]->mcs,dlsch->harq_processes[0]->Nl); - mod_order = nr_get_Qm_dl(Imcs, mcs_table); - rate = nr_get_code_rate_dl(Imcs, mcs_table); - available_bits = nr_get_G(nb_rb, nb_symb_sch, nb_re_dmrs, length_dmrs, mod_order, 1); + unsigned char mod_order = nr_get_Qm_dl(Imcs, mcs_table); + uint16_t rate = nr_get_code_rate_dl(Imcs, mcs_table); + unsigned int available_bits = nr_get_G(nb_rb, nb_symb_sch, nb_re_dmrs, length_dmrs, mod_order, 1); TBS = nr_compute_tbs(mod_order,rate, nb_rb, nb_symb_sch, nb_re_dmrs*length_dmrs, 0, 0, Nl); printf("available bits %u TBS %u mod_order %d\n", available_bits, TBS, mod_order); //dlsch->harq_ids[subframe]= 0; @@ -471,6 +460,7 @@ int main(int argc, char **argv) rel15->dlDmrsSymbPos = 4; rel15->mcsIndex[0] = Imcs; rel15->numDmrsCdmGrpsNoData = 1; + rel15->maintenance_parms_v3.tbSizeLbrmBytes = Tbslbrm; double modulated_input[16 * 68 * 384]; // [hna] 16 segments, 68*Zc short channel_output_fixed[16 * 68 * 384]; //unsigned char *estimated_output; @@ -487,19 +477,18 @@ int main(int argc, char **argv) harq_process->Qm = mod_order; harq_process->rvidx = rvidx; harq_process->R = rate; + harq_process->TBS = TBS; harq_process->dmrsConfigType = NFAPI_NR_DMRS_TYPE1; harq_process->dlDmrsSymbPos = 4; harq_process->n_dmrs_cdm_groups = 1; + harq_process->tbslbrm = Tbslbrm; printf("harq process ue mcs = %d Qm = %d, symb %d\n", harq_process->mcs, harq_process->Qm, nb_symb_sch); - unsigned char *test_input; - test_input = (unsigned char *) malloc16(sizeof(unsigned char) * TBS / 8); + unsigned char *test_input=dlsch->harq_process.pdu; //unsigned char test_input[TBS / 8] __attribute__ ((aligned(16))); for (i = 0; i < TBS / 8; i++) test_input[i] = (unsigned char) rand(); - //estimated_output = harq_process->b; - #ifdef DEBUG_NR_DLSCHSIM for (i = 0; i < TBS / 8; i++) printf("test_input[i]=%hhu \n",test_input[i]); #endif @@ -509,10 +498,10 @@ int main(int argc, char **argv) //printf("crc32: [0]->0x%08x\n",crc24c(test_input, 32)); // generate signal - unsigned char output[rel15->rbSize * NR_SYMBOLS_PER_SLOT * NR_NB_SC_PER_RB * 8 * NR_MAX_NB_LAYERS] __attribute__((aligned(32))); - bzero(output,rel15->rbSize * NR_SYMBOLS_PER_SLOT * NR_NB_SC_PER_RB * 8 * NR_MAX_NB_LAYERS); + unsigned char output[rel15->rbSize * NR_SYMBOLS_PER_SLOT * NR_NB_SC_PER_RB * 8 * NR_MAX_NB_LAYERS] __attribute__((aligned(32))); + bzero(output,rel15->rbSize * NR_SYMBOLS_PER_SLOT * NR_NB_SC_PER_RB * 8 * NR_MAX_NB_LAYERS); if (input_fd == NULL) { - nr_dlsch_encoding(gNB, test_input, frame, slot, dlsch, frame_parms,output,NULL,NULL,NULL,NULL,NULL,NULL,NULL); + nr_dlsch_encoding(gNB, frame, slot, &dlsch->harq_process, frame_parms,output,NULL,NULL,NULL,NULL,NULL,NULL,NULL); } for (SNR = snr0; SNR < snr1; SNR += snr_step) { @@ -562,7 +551,7 @@ int main(int argc, char **argv) ret = nr_dlsch_decoding(UE, &proc, 0, channel_output_fixed, &UE->frame_parms, dlsch0_ue, dlsch0_ue->harq_processes[0], frame, nb_symb_sch, - slot,harq_pid, is_crnti, llr8_flag); + slot,harq_pid, is_crnti); vcd_signal_dumper_dump_function_by_name(VCD_SIGNAL_DUMPER_FUNCTIONS_DLSCH_DECODING0, VCD_FUNCTION_OUT); @@ -632,8 +621,6 @@ int main(int argc, char **argv) } }*/ - free(test_input); - free_channel_desc_scm(gNB2UE); reset_DLSCH_struct(gNB, &msgDataTx); @@ -643,8 +630,9 @@ int main(int argc, char **argv) free(RC.gNB[0]); free(RC.gNB); + int num_cw = NR_MAX_NB_LAYERS > 4? 2:1; for (int sf = 0; sf < 2; sf++) - for (int i = 0; i < 2; i++) + for (int i = 0; i < num_cw; i++) free_nr_ue_dlsch(&UE->dlsch[sf][0][i], N_RB_DL); term_nr_ue_signal(UE, 1); free(UE); diff --git a/openair1/SIMULATION/NR_PHY/dlsim.c b/openair1/SIMULATION/NR_PHY/dlsim.c index e797c01096..bab67e4426 100644 --- a/openair1/SIMULATION/NR_PHY/dlsim.c +++ b/openair1/SIMULATION/NR_PHY/dlsim.c @@ -66,6 +66,7 @@ #include "NR_RRCReconfiguration.h" #define inMicroS(a) (((double)(a))/(get_cpu_freq_GHz()*1000.0)) #include "SIMULATION/LTE_PHY/common_sim.h" +#include "PHY/NR_REFSIG/dmrs_nr.h" #include #include @@ -96,7 +97,6 @@ uint16_t sl_ahead=0; uint64_t downlink_frequency[MAX_NUM_CCs][4]; THREAD_STRUCT thread_struct; nfapi_ue_release_request_body_t release_rntis; -uint32_t N_RB_DL = 106; //Fixme: Uniq dirty DU instance, by global var, datamodel need better management instance_t DUuniqInstance=0; instance_t CUuniqInstance=0; @@ -105,6 +105,10 @@ teid_t newGtpuCreateTunnel(instance_t instance, rnti_t rnti, int incoming_bearer return 0; } +int newGtpuDeleteAllTunnels(instance_t instance, rnti_t rnti) { + return 0; +} + // dummy functions int dummy_nr_ue_ul_indication(nr_uplink_indication_t *ul_info) { return(0); } @@ -209,8 +213,7 @@ void config_common(int Mod_idP, int ssb_SubcarrierOffset, int pdsch_AntennaPorts, int pusch_AntennaPorts, - NR_ServingCellConfigCommon_t *scc - ); + NR_ServingCellConfigCommon_t *scc); int generate_dlsch_header(unsigned char *mac_header, unsigned char num_sdus, @@ -239,6 +242,8 @@ int DU_send_INITIAL_UL_RRC_MESSAGE_TRANSFER(module_id_t module_idP, return 0; } +nr_bler_struct nr_bler_data[NR_NUM_MCS]; + void processSlotTX(void *arg) {} //nFAPI P7 dummy functions to avoid linking errors @@ -259,34 +264,44 @@ void update_ptrs_config(NR_CellGroupConfig_t *secondaryCellGroup, uint16_t *rbSi void update_dmrs_config(NR_CellGroupConfig_t *scg, int8_t* dmrs_arg); extern void fix_scd(NR_ServingCellConfig_t *scd);// forward declaration -/* specific dlsim DL preprocessor: uses rbStart/rbSize/mcs/nrOfLayers from command line of - dlsim, does not search for CCE/PUCCH occasion but simply sets to 0 */ +/* specific dlsim DL preprocessor: uses rbStart/rbSize/mcs/nrOfLayers from command line of dlsim */ int g_mcsIndex = -1, g_mcsTableIdx = 0, g_rbStart = -1, g_rbSize = -1, g_nrOfLayers = 1; void nr_dlsim_preprocessor(module_id_t module_id, frame_t frame, sub_frame_t slot) { - NR_UE_info_t *UE_info = &RC.nrmac[module_id]->UE_info; - AssertFatal(UE_info->num_UEs == 1, "can have only a single UE\n"); - NR_UE_sched_ctrl_t *sched_ctrl = &UE_info->UE_sched_ctrl[0]; + + NR_UE_info_t *UE_info = RC.nrmac[module_id]->UE_info.list[0]; + AssertFatal(RC.nrmac[module_id]->UE_info.list[1]==NULL, "can have only a single UE\n"); + NR_UE_sched_ctrl_t *sched_ctrl = &UE_info->UE_sched_ctrl; NR_ServingCellConfigCommon_t *scc = RC.nrmac[0]->common_channels[0].ServingCellConfigCommon; - /* manually set free CCE to 0 */ const int target_ss = NR_SearchSpace__searchSpaceType_PR_ue_Specific; - sched_ctrl->search_space = get_searchspace(scc, sched_ctrl->active_bwp ? sched_ctrl->active_bwp->bwp_Dedicated : NULL, target_ss); + sched_ctrl->search_space = get_searchspace(NULL, scc, sched_ctrl->active_bwp ? sched_ctrl->active_bwp->bwp_Dedicated : NULL, target_ss); uint8_t nr_of_candidates; find_aggregation_candidates(&sched_ctrl->aggregation_level, &nr_of_candidates, sched_ctrl->search_space,4); - sched_ctrl->coreset = get_coreset(module_id, scc, sched_ctrl->active_bwp->bwp_Dedicated, sched_ctrl->search_space, target_ss); - sched_ctrl->cce_index = 0; + + sched_ctrl->coreset = get_coreset(RC.nrmac[module_id], scc, sched_ctrl->active_bwp->bwp_Dedicated, sched_ctrl->search_space, target_ss); + uint32_t Y = get_Y(sched_ctrl->search_space, slot, UE_info->rnti); + int CCEIndex = find_pdcch_candidate(RC.nrmac[module_id], + /* CC_id = */ 0, + sched_ctrl->aggregation_level, + nr_of_candidates, + &sched_ctrl->sched_pdcch, + sched_ctrl->coreset, + Y); + AssertFatal(CCEIndex>=0, "%4d.%2d could not find CCE for DL DCI UE %d/RNTI %04x\n", frame, slot, 0, UE_info->rnti); + sched_ctrl->cce_index = CCEIndex; NR_pdsch_semi_static_t *ps = &sched_ctrl->pdsch_semi_static; - nr_set_pdsch_semi_static(scc, - UE_info->CellGroup[0], + nr_set_pdsch_semi_static(NULL, + scc, + UE_info->CellGroup, sched_ctrl->active_bwp, NULL, - /* tda = */ 2, + /* tda = */ 0, g_nrOfLayers, sched_ctrl, ps); @@ -308,8 +323,7 @@ void nr_dlsim_preprocessor(module_id_t module_id, ps->N_PRB_DMRS * ps->N_DMRS_SLOT, 0 /* N_PRB_oh, 0 for initialBWP */, 0 /* tb_scaling */, - ps->nrOfLayers) - >> 3; + ps->nrOfLayers) >> 3; /* the simulator assumes the HARQ PID is equal to the slot number */ sched_pdsch->dl_harq_pid = slot; @@ -430,7 +444,8 @@ int main(int argc, char **argv) uint16_t rbSize = 106; uint8_t mcsIndex = 9; uint8_t dlsch_threads = 0; - int prb_inter = 0; + int chest_type[2] = {0}; + uint8_t max_ldpc_iterations = 5; if ( load_configmodule(argc,argv,CONFIG_ENABLECMDLINEONLY) == 0) { exit_fun("[NR_DLSIM] Error, configuration module init failed\n"); } @@ -441,7 +456,7 @@ int main(int argc, char **argv) FILE *scg_fd=NULL; - while ((c = getopt (argc, argv, "f:hA:pf:g:in:s:S:t:x:y:z:M:N:F:GR:dPIL:Ea:b:d:e:q:m:w:T:U:X:")) != -1) { + while ((c = getopt (argc, argv, "f:hA:pf:g:i:n:s:S:t:x:y:z:M:N:F:GR:dPI:L:Ea:b:d:e:m:w:T:U:q:X:Y")) != -1) { switch (c) { case 'f': scg_fd = fopen(optarg,"r"); @@ -498,7 +513,9 @@ int main(int argc, char **argv) break; case 'i': - prb_inter=1; + for(i=0; i < atoi(optarg); i++){ + chest_type[i] = atoi(argv[optind++]); + } break; case 'n': @@ -537,8 +554,8 @@ int main(int argc, char **argv) case 'x': g_nrOfLayers=atoi(optarg); - if ((g_nrOfLayers!=1) && - (g_nrOfLayers!=2)) { + if ((g_nrOfLayers==0) || + (g_nrOfLayers>4)) { printf("Unsupported nr Of Layers %d\n",g_nrOfLayers); exit(-1); } @@ -585,9 +602,7 @@ int main(int argc, char **argv) break; case 'I': - run_initial_sync=1; - //target_error_rate=0.1; - slot = 0; + max_ldpc_iterations = atoi(optarg); break; case 'L': @@ -645,28 +660,34 @@ int main(int argc, char **argv) dmrs_arg[i] = atoi(argv[optind++]); } break; - + case 'X': strncpy(gNBthreads, optarg, sizeof(gNBthreads)); gNBthreads[sizeof(gNBthreads)-1]=0; break; + + case 'Y': + run_initial_sync=1; + //target_error_rate=0.1; + slot = 0; + break; default: case 'h': - printf("%s -h(elp) -p(extended_prefix) -N cell_id -f output_filename -F input_filename -g channel_model -n n_frames -t Delayspread -s snr0 -S snr1 -x transmission_mode -y TXant -z RXant -i Intefrence0 -j Interference1 -A interpolation_file -C(alibration offset dB) -N CellId\n", + printf("%s -h(elp) -p(extended_prefix) -N cell_id -f output_filename -F input_filename -g channel_model -n n_frames -s snr0 -S snr1 -x transmission_mode -y TXant -z RXant -i Intefrence0 -j Interference1 -A interpolation_file -C(alibration offset dB) -N CellId\n", argv[0]); printf("-h This message\n"); - printf("-L \n"); + printf("-L \n"); //printf("-p Use extended prefix mode\n"); //printf("-d Use TDD\n"); printf("-n Number of frames to simulate\n"); printf("-s Starting SNR, runs from SNR0 to SNR0 + 5 dB. If n_frames is 1 then just SNR is simulated\n"); printf("-S Ending SNR, runs from SNR0 to SNR1\n"); - printf("-t Delay spread for multipath channel\n"); + //printf("-t Delay spread for multipath channel\n"); printf("-g [A,B,C,D,E,F,G,R] Use 3GPP SCM (A,B,C,D) or 36-101 (E-EPA,F-EVA,G-ETU) models or R for MIMO model (ignores delay spread and Ricean factor)\n"); printf("-y Number of TX antennas used in gNB\n"); printf("-z Number of RX antennas used in UE\n"); - printf("-i Activate PRB based averaging for channel estimation. Frequncy domain interpolation by default.\n"); + printf("-i Change channel estimation technique. Arguments list: Frequency domain {0:Linear interpolation, 1:PRB based averaging}, Time domain {0:Estimates of last DMRS symbol, 1:Average of DMRS symbols}\n"); //printf("-j Relative strength of second intefering gNB (in dB) - cell_id mod 3 = 2\n"); printf("-R N_RB_DL\n"); printf("-O oversampling factor (1,2,4,8,16)\n"); @@ -683,12 +704,14 @@ int main(int argc, char **argv) printf("-e MSC index\n"); printf("-q MCS Table index\n"); printf("-t Acceptable effective throughput (in percentage)\n"); + printf("-I Maximum LDPC decoder iterations\n"); printf("-T Enable PTRS, arguments list L_PTRS{0,1,2} K_PTRS{2,4}, e.g. -T 2 0 2 \n"); printf("-U Change DMRS Config, arguments list DMRS TYPE{0=A,1=B} DMRS AddPos{0:2} DMRS ConfType{1:2}, e.g. -U 3 0 2 1 \n"); printf("-P Print DLSCH performances\n"); printf("-w Write txdata to binary file (one frame)\n"); printf("-d number of dlsch threads, 0: no dlsch parallelization\n"); - printf("-X gNB thread pool configuration, n => no threads"); + printf("-X gNB thread pool configuration, n => no threads\n"); + printf("-Y Run initial sync in UE\n"); exit (-1); break; } @@ -784,12 +807,27 @@ int main(int argc, char **argv) fix_scc(scc,ssb_bitmap); prepare_scd(scd); + rrc_pdsch_AntennaPorts_t pdsch_AntennaPorts; + pdsch_AntennaPorts.N1 = n_tx>1 ? n_tx>>1 : 1; + pdsch_AntennaPorts.N2 = 1; + pdsch_AntennaPorts.XP = n_tx>1 ? 2 : 1; + gNB->ap_N1 = pdsch_AntennaPorts.N1; + gNB->ap_N2 = pdsch_AntennaPorts.N2; + gNB->ap_XP = pdsch_AntennaPorts.XP; + NR_UE_NR_Capability_t* UE_Capability_nr = CALLOC(1,sizeof(NR_UE_NR_Capability_t)); prepare_sim_uecap(UE_Capability_nr,scc,mu, N_RB_DL,g_mcsTableIdx); // TODO do a UECAP for phy-sim - fill_default_secondaryCellGroup(scc, scd, secondaryCellGroup, UE_Capability_nr, 0, 1, n_tx, 6, 0, 0, 0); + const gNB_RrcConfigurationReq conf = { + .pdsch_AntennaPorts = pdsch_AntennaPorts, + .minRXTXTIME = 6, + .do_CSIRS = 0, + .do_SRS = 0, + .force_256qam_off = false + }; + fill_default_secondaryCellGroup(scc, scd, secondaryCellGroup, UE_Capability_nr, 0, 1, &conf, 0); /* RRC parameter validation for secondaryCellGroup */ fix_scd(scd); @@ -807,17 +845,17 @@ int main(int argc, char **argv) AssertFatal((gNB->if_inst = NR_IF_Module_init(0))!=NULL,"Cannot register interface"); gNB->if_inst->NR_PHY_config_req = nr_phy_config_request; + // common configuration - rrc_mac_config_req_gNB(0,0, n_tx, n_tx, 0, 6, scc, NULL, 0, 0, NULL); + rrc_mac_config_req_gNB(0,0, pdsch_AntennaPorts, n_tx, 0, 6, scc, NULL, NULL, 0, 0, NULL); // UE dedicated configuration - rrc_mac_config_req_gNB(0,0, n_tx, n_tx, 0, 6, scc, NULL, 1, secondaryCellGroup->spCellConfig->reconfigurationWithSync->newUE_Identity,secondaryCellGroup); + rrc_mac_config_req_gNB(0,0, pdsch_AntennaPorts, n_tx, 0, 6, scc, NULL, NULL, 1, secondaryCellGroup->spCellConfig->reconfigurationWithSync->newUE_Identity,secondaryCellGroup); // reset preprocessor to the one of DLSIM after it has been set during // rrc_mac_config_req_gNB gNB_mac->pre_processor_dl = nr_dlsim_preprocessor; phy_init_nr_gNB(gNB,0,1); N_RB_DL = gNB->frame_parms.N_RB_DL; - NR_UE_info_t *UE_info = &RC.nrmac[0]->UE_info; - UE_info->num_UEs=1; + NR_UE_info_t *UE_info = RC.nrmac[0]->UE_info.list[0]; // stub to configure frame_parms // nr_phy_config_request_sim(gNB,N_RB_DL,N_RB_DL,mu,Nid_cell,SSB_positions); @@ -832,10 +870,14 @@ int main(int argc, char **argv) double fs,bw; - if (mu == 1 && N_RB_DL == 217) { + if (mu == 0 && N_RB_DL == 25) { + fs = 7.68e6; + bw = 5e6; + } + else if (mu == 1 && N_RB_DL == 217) { fs = 122.88e6; bw = 80e6; - } + } else if (mu == 1 && N_RB_DL == 245) { fs = 122.88e6; bw = 90e6; @@ -848,14 +890,18 @@ int main(int argc, char **argv) fs = 61.44e6; bw = 40e6; } - else if (mu == 1 && N_RB_DL == 133) { + else if (mu == 1 && N_RB_DL == 133) { fs = 61.44e6; bw = 50e6; } - else if (mu == 1 && N_RB_DL == 162) { + else if (mu == 1 && N_RB_DL == 162) { fs = 61.44e6; bw = 60e6; } + else if (mu == 1 && N_RB_DL == 24) { + fs = 15.36e6; + bw = 10e6; + } else if (mu == 3 && N_RB_DL == 66) { fs = 122.88e6; bw = 100e6; @@ -921,6 +967,7 @@ int main(int argc, char **argv) PHY_vars_UE_g[0][0] = UE; memcpy(&UE->frame_parms,frame_parms,sizeof(NR_DL_FRAME_PARMS)); UE->frame_parms.nb_antennas_rx = n_rx; + UE->max_ldpc_iterations = max_ldpc_iterations; if (run_initial_sync==1) UE->is_synchronized = 0; else {UE->is_synchronized = 1; UE->UE_mode[0]=PUSCH;} @@ -942,10 +989,10 @@ int main(int argc, char **argv) nr_gold_pdcch(UE, frame_parms->Nid_cell); // compute the scrambling IDs for PDSCH DMRS - for (int i = 0; i < 2; i++) - UE->scramblingID[i] = frame_parms->Nid_cell; - - nr_gold_pdsch(UE, UE->scramblingID); + for (int i = 0; i < 2; i++) { + UE->scramblingID_dlsch[i] = frame_parms->Nid_cell; + nr_gold_pdsch(UE, i, UE->scramblingID_dlsch[i]); + } nr_l2_init_ue(NULL); UE_mac = get_mac_inst(0); @@ -955,8 +1002,8 @@ int main(int argc, char **argv) UE->if_inst->phy_config_request = nr_ue_phy_config_request; UE->if_inst->dl_indication = nr_ue_dl_indication; UE->if_inst->ul_indication = dummy_nr_ue_ul_indication; - UE->prb_interpolation = prb_inter; - + UE->chest_freq = chest_type[0]; + UE->chest_time = chest_type[1]; UE_mac->if_module = nr_ue_if_module_init(0); @@ -984,6 +1031,8 @@ int main(int argc, char **argv) nr_dcireq_t dcireq; nr_scheduled_response_t scheduled_response; + NR_UE_PDCCH_CONFIG phy_pdcch_config={0}; + memset((void*)&dcireq,0,sizeof(dcireq)); memset((void*)&scheduled_response,0,sizeof(scheduled_response)); dcireq.module_id = 0; @@ -998,6 +1047,7 @@ int main(int argc, char **argv) scheduled_response.frame = frame; scheduled_response.slot = slot; scheduled_response.thread_id = 0; + scheduled_response.phy_data = &phy_pdcch_config; nr_ue_phy_config_request(&UE_mac->phy_config); //NR_COMMON_channels_t *cc = RC.nrmac[0]->common_channels; @@ -1067,20 +1117,15 @@ int main(int argc, char **argv) UE_harq_process->ack = 0; round = 0; - UE_harq_process->round = round; + UE_harq_process->DLround = round; UE_harq_process->first_rx = 1; while ((roundack==0)) { clear_nr_nfapi_information(RC.nrmac[0], 0, frame, slot); + UE_info->UE_sched_ctrl.harq_processes[harq_pid].ndi = !(trial&1); + UE_info->UE_sched_ctrl.harq_processes[harq_pid].round = round; - UE_info->UE_sched_ctrl[0].harq_processes[harq_pid].ndi = !(trial&1); - - - UE_info->UE_sched_ctrl[0].harq_processes[harq_pid].round = round; - for (int i=0; ipdcch_cand[i] = 0; - if (css_flag == 0) { nr_schedule_ue_spec(0, frame, slot); } else { @@ -1110,7 +1155,7 @@ int main(int argc, char **argv) pdsch_pdu_rel15->dlDmrsSymbPos); ptrsSymbPerSlot = get_ptrs_symbols_in_slot(dlPtrsSymPos, pdsch_pdu_rel15->StartSymbolIndex, pdsch_pdu_rel15->NrOfSymbols); ptrsRePerSymb = ((rel15->rbSize + rel15->PTRSFreqDensity - 1)/rel15->PTRSFreqDensity); - printf("[DLSIM] PTRS Symbols in a slot: %2u, RE per Symbol: %3u, RE in a slot %4d\n", ptrsSymbPerSlot,ptrsRePerSymb, ptrsSymbPerSlot*ptrsRePerSymb ); + LOG_D(PHY,"[DLSIM] PTRS Symbols in a slot: %2u, RE per Symbol: %3u, RE in a slot %4d\n", ptrsSymbPerSlot,ptrsRePerSymb, ptrsSymbPerSlot*ptrsRePerSymb ); } msgDataTx->ssb[0].ssb_pdu.ssb_pdu_rel15.bchPayload=0x001234; @@ -1202,10 +1247,10 @@ int main(int argc, char **argv) frame_length_complex_samples, 0); - double H_awgn_mimo[4][4] ={{1.0, 0.5, 0.25, 0.125},//rx 0 - {0.5, 1.0, 0.5, 0.25}, //rx 1 - {0.25, 0.5, 1.0, 0.5}, //rx 2 - {0.125, 0.25, 0.5, 1.0}};//rx 3 + double H_awgn_mimo[4][4] ={{1.0, 0.2, 0.1, 0.05}, //rx 0 + {0.2, 1.0, 0.2, 0.1}, //rx 1 + {0.1, 0.2, 1.0, 0.2}, //rx 2 + {0.05, 0.1, 0.2, 1.0}};//rx 3 for (i=frame_parms->get_samples_slot_timestamp(slot,frame_parms,0); iget_samples_slot_timestamp(slot+1,frame_parms,0); @@ -1240,6 +1285,7 @@ int main(int argc, char **argv) &UE_proc, 0, dlsch_threads, + &phy_pdcch_config, NULL); //printf("dlsim round %d ends\n",round); @@ -1260,14 +1306,14 @@ int main(int argc, char **argv) TBS = UE_harq_process->TBS;//rel15->TBSize[0]; uint16_t length_dmrs = get_num_dmrs(rel15->dlDmrsSymbPos); uint16_t nb_rb = rel15->rbSize; - uint8_t nb_re_dmrs = rel15->dmrsConfigType == NFAPI_NR_DMRS_TYPE1 ? 6 : 4; + uint8_t nb_re_dmrs = rel15->dmrsConfigType == NFAPI_NR_DMRS_TYPE1 ? 6*UE_harq_process->n_dmrs_cdm_groups : 4*UE_harq_process->n_dmrs_cdm_groups; uint8_t mod_order = rel15->qamModOrder[0]; uint8_t nb_symb_sch = rel15->NrOfSymbols; available_bits = nr_get_G(nb_rb, nb_symb_sch, nb_re_dmrs, length_dmrs, mod_order, rel15->nrOfLayers); if(pdu_bit_map & 0x1) { available_bits-= (ptrsSymbPerSlot * ptrsRePerSymb *rel15->nrOfLayers* 2); - printf("[DLSIM][PTRS] Available bits are: %5u, removed PTRS bits are: %5u \n",available_bits, (ptrsSymbPerSlot * ptrsRePerSymb *rel15->nrOfLayers* 2) ); + LOG_D(PHY,"[DLSIM][PTRS] Available bits are: %5u, removed PTRS bits are: %5u \n",available_bits, (ptrsSymbPerSlot * ptrsRePerSymb *rel15->nrOfLayers* 2) ); } /* @@ -1324,7 +1370,8 @@ int main(int argc, char **argv) printf("*****************************************\n"); printf("\n"); dump_pdsch_stats(stdout,gNB); - printf("SNR %f : n_errors (negative CRC) = %d/%d, Avg round %.2f, Channel BER %e, BLER %.2f, Eff Rate %.4f bits/slot, Eff Throughput %.2f, TBS %u bits/slot\n", SNR, n_errors, n_trials,roundStats[snrRun],berStats[snrRun],blerStats[snrRun],effRate,effRate/TBS*100,TBS); + printf("SNR %f : n_errors (negative CRC) = %d/%d, Avg round %.2f, Channel BER %e, BLER %.2f, Eff Rate %.4f bits/slot, Eff Throughput %.2f, TBS %u bits/slot\n", + SNR, n_errors, n_trials,roundStats[snrRun],berStats[snrRun],blerStats[snrRun],effRate,effRate/TBS*100,TBS); printf("\n"); if (print_perf==1) { @@ -1387,8 +1434,6 @@ int main(int argc, char **argv) LOG_M("chestF0.m","chF0",&UE->pdsch_vars[0][0]->dl_ch_estimates_ext[0][0],g_rbSize*12*14,1,1); write_output("rxF_comp.m","rxFc",&UE->pdsch_vars[0][0]->rxdataF_comp0[0][0],N_RB_DL*12*14,1,1); LOG_M("rxF_llr.m","rxFllr",UE->pdsch_vars[UE_proc.thread_id][0]->llr[0],available_bits,1,0); - LOG_M("pdcch_rxFcomp.m","pdcch_rxFcomp",&UE->pdcch_vars[0][0]->rxdataF_comp[0][0],96*12,1,1); - LOG_M("pdcch_rxFllr.m","pdcch_rxFllr",UE->pdcch_vars[0][0]->llr,96*12,1,1); break; } diff --git a/openair1/SIMULATION/NR_PHY/nr_dummy_functions.c b/openair1/SIMULATION/NR_PHY/nr_dummy_functions.c index 7a47410129..21802cd41a 100644 --- a/openair1/SIMULATION/NR_PHY/nr_dummy_functions.c +++ b/openair1/SIMULATION/NR_PHY/nr_dummy_functions.c @@ -1,5 +1,6 @@ #include "nfapi/oai_integration/vendor_ext.h" + int oai_nfapi_hi_dci0_req(nfapi_hi_dci0_request_t *hi_dci0_req) { return(0); } int oai_nfapi_tx_req(nfapi_tx_request_t *tx_req) { return(0); } int oai_nfapi_dl_config_req(nfapi_dl_config_request_t *dl_config_req) { return(0); } @@ -20,6 +21,8 @@ nfapi_mode_t nfapi_mod; nfapi_mode_t nfapi_getmode(void) { return nfapi_mod; } +void nfapi_setmode(nfapi_mode_t nfapi_mode) {} + int dummy_nr_ue_dl_indication(nr_downlink_indication_t *dl_info) { return(0); } int dummy_nr_ue_ul_indication(nr_uplink_indication_t *ul_info) { return(0); } void nr_fill_dl_indication(nr_downlink_indication_t *dl_ind, @@ -27,7 +30,8 @@ void nr_fill_dl_indication(nr_downlink_indication_t *dl_ind, fapi_nr_rx_indication_t *rx_ind, UE_nr_rxtx_proc_t *proc, PHY_VARS_NR_UE *ue, - uint8_t gNB_id) {} + uint8_t gNB_id, + void *phy_data) {} void nr_fill_rx_indication(fapi_nr_rx_indication_t *rx_ind, uint8_t pdu_type, uint8_t gNB_id, @@ -35,4 +39,5 @@ void nr_fill_rx_indication(fapi_nr_rx_indication_t *rx_ind, NR_UE_DLSCH_t *dlsch0, NR_UE_DLSCH_t *dlsch1, uint16_t n_pdus, - UE_nr_rxtx_proc_t *proc) {} + UE_nr_rxtx_proc_t *proc, + void * typeSpecific ) {} diff --git a/openair1/SIMULATION/NR_PHY/pbchsim.c b/openair1/SIMULATION/NR_PHY/pbchsim.c index f3a8d21fdd..62f6b21528 100644 --- a/openair1/SIMULATION/NR_PHY/pbchsim.c +++ b/openair1/SIMULATION/NR_PHY/pbchsim.c @@ -74,7 +74,10 @@ void init_downlink_harq_status(NR_DL_UE_HARQ_t *dl_harq) {} int nr_ue_pdcch_procedures(uint8_t gNB_id, PHY_VARS_NR_UE *ue, UE_nr_rxtx_proc_t *proc, - int n_ss) { + int32_t pdcch_est_size, + int32_t pdcch_dl_ch_estimates[][pdcch_est_size], + NR_UE_PDCCH_CONFIG *phy_pdcch_config, + int n_ss) { return 0; } @@ -438,6 +441,7 @@ int main(int argc, char **argv) printf("Initializing gNodeB for mu %d, N_RB_DL %d\n",mu,N_RB_DL); + RC.gNB = (PHY_VARS_gNB**) malloc(sizeof(PHY_VARS_gNB *)); RC.gNB[0] = malloc16_clear(sizeof(*(RC.gNB[0]))); gNB = RC.gNB[0]; @@ -531,13 +535,13 @@ int main(int argc, char **argv) s_im = malloc(2*sizeof(double*)); r_re = malloc(2*sizeof(double*)); r_im = malloc(2*sizeof(double*)); - txdata = malloc(2*sizeof(int*)); + txdata = calloc(2,sizeof(int*)); for (i=0; i<2; i++) { + s_re[i] = malloc16_clear(frame_length_complex_samples*sizeof(double)); s_im[i] = malloc16_clear(frame_length_complex_samples*sizeof(double)); - r_re[i] = malloc16_clear(frame_length_complex_samples*sizeof(double)); r_im[i] = malloc16_clear(frame_length_complex_samples*sizeof(double)); printf("Allocating %d samples for txdata\n",frame_length_complex_samples); @@ -550,6 +554,7 @@ int main(int argc, char **argv) //configure UE + UE = malloc16_clear(sizeof(*UE)); memcpy(&UE->frame_parms,frame_parms,sizeof(UE->frame_parms)); //phy_init_nr_top(UE); //called from init_nr_ue_signal @@ -720,8 +725,13 @@ int main(int argc, char **argv) } else { UE_nr_rxtx_proc_t proc={0}; + NR_UE_PDCCH_CONFIG phy_pdcch_config={0}; + UE->rx_offset=0; uint8_t ssb_index = 0; + const int estimateSz=7*2*sizeof(int)*frame_parms->ofdm_symbol_size; + __attribute__ ((aligned(32))) struct complex16 dl_ch_estimates[frame_parms->nb_antennas_rx][estimateSz]; + __attribute__ ((aligned(32))) struct complex16 dl_ch_estimates_time[frame_parms->nb_antennas_rx][estimateSz]; while (!((SSB_positions >> ssb_index) & 0x01)) ssb_index++; // to select the first transmitted ssb UE->symbol_offset = nr_get_ssb_start_symbol(frame_parms,ssb_index); @@ -732,17 +742,21 @@ int main(int argc, char **argv) i%frame_parms->symbols_per_slot, ssb_slot); - nr_pbch_channel_estimation(UE,&proc,0,ssb_slot,i%frame_parms->symbols_per_slot,i-(UE->symbol_offset+1),ssb_index%8,n_hf); + nr_pbch_channel_estimation(UE,estimateSz, dl_ch_estimates, dl_ch_estimates_time, &proc, + 0,ssb_slot,i%frame_parms->symbols_per_slot,i-(UE->symbol_offset+1),ssb_index%8,n_hf); } - + fapiPbch_t result; ret = nr_rx_pbch(UE, &proc, - UE->pbch_vars[0], + estimateSz, dl_ch_estimates, + UE->pbch_vars[0], frame_parms, 0, ssb_index%8, - SISO); + SISO, + &phy_pdcch_config, + &result); if (ret==0) { //UE->rx_ind.rx_indication_body->mib_pdu.ssb_index; //not yet detected automatically @@ -751,9 +765,9 @@ int main(int argc, char **argv) for (int i=0; i<8; i++) gNB_xtra_byte |= ((gNB->pbch.pbch_a>>(31-i))&1)<<(7-i); - payload_ret = (UE->pbch_vars[0]->xtra_byte == gNB_xtra_byte); + payload_ret = (result.xtra_byte == gNB_xtra_byte); for (i=0;i<3;i++){ - payload_ret += (UE->pbch_vars[0]->decoded_output[i] == ((msgDataTx.ssb[ssb_index].ssb_pdu.ssb_pdu_rel15.bchPayload>>(8*i)) & 0xff)); + payload_ret += (result.decoded_output[i] == ((msgDataTx.ssb[ssb_index].ssb_pdu.ssb_pdu_rel15.bchPayload>>(8*i)) & 0xff)); } //printf("xtra byte gNB: 0x%02x UE: 0x%02x\n",gNB_xtra_byte, UE->pbch_vars[0]->xtra_byte); //printf("ret %d\n", payload_ret); diff --git a/openair1/SIMULATION/NR_PHY/prachsim.c b/openair1/SIMULATION/NR_PHY/prachsim.c index bc4f4a0b60..33717c944d 100644 --- a/openair1/SIMULATION/NR_PHY/prachsim.c +++ b/openair1/SIMULATION/NR_PHY/prachsim.c @@ -97,6 +97,10 @@ teid_t newGtpuCreateTunnel(instance_t instance, rnti_t rnti, int incoming_bearer return 0; } +int newGtpuDeleteAllTunnels(instance_t instance, rnti_t rnti) { + return 0; +} + void rrc_data_ind( const protocol_ctxt_t *const ctxt_pP, @@ -223,6 +227,8 @@ nrUE_params_t *get_nrUE_params(void) { return &nrUE_params; } +nr_bler_struct nr_bler_data[NR_NUM_MCS]; + void processSlotTX(void *arg) {} int main(int argc, char **argv){ @@ -234,7 +240,7 @@ int main(int argc, char **argv){ int i, l, aa, aarx, **txdata, trial, n_frames = 1, prach_start, rx_prach_start; //, ntrials=1; int N_RB_UL = 106, delay = 0, NCS_config = 13, rootSequenceIndex = 1, threequarter_fs = 0, mu = 1, fd_occasion = 0, loglvl = OAILOG_INFO, numRA = 0, prachStartSymbol = 0; uint8_t snr1set = 0, ue_speed1set = 0, transmission_mode = 1, n_tx = 1, n_rx = 1, awgn_flag = 0, msg1_frequencystart = 0, num_prach_fd_occasions = 1, prach_format=0; - uint8_t frame = 1, slot=19, slot_gNB=19, config_index = 98, prach_sequence_length = 1, restrictedSetConfig = 0, N_dur, N_t_slot, start_symbol; + uint8_t config_index = 98, prach_sequence_length = 1, restrictedSetConfig = 0, N_dur, N_t_slot, start_symbol; uint16_t Nid_cell = 0, preamble_tx = 0, preamble_delay, format, format0, format1; uint32_t tx_lev = 10000, prach_errors = 0; //,tx_lev_dB; uint64_t SSB_positions = 0x01; @@ -530,7 +536,7 @@ int main(int argc, char **argv){ frame_parms->N_RB_UL = N_RB_UL; frame_parms->threequarter_fs = threequarter_fs; frame_parms->frame_type = TDD; - frame_parms->freq_range = (mu==1 ? nr_FR1 : nr_FR2); + frame_parms->freq_range = (mu != 3 ? nr_FR1 : nr_FR2); frame_parms->numerology_index = mu; nr_phy_config_request_sim(gNB, N_RB_UL, N_RB_UL, mu, Nid_cell, SSB_positions); @@ -540,9 +546,11 @@ int main(int argc, char **argv){ frame_parms->numerology_index, frame_parms->N_RB_UL*(180e3)*(1 << frame_parms->numerology_index)); - uint8_t subframe = slot/frame_parms->slots_per_subframe; + uint8_t frame = 1; + uint8_t subframe = 9; + uint8_t slot = 10 * frame_parms->slots_per_subframe - 1; - if (config_index<67 && mu==1) { prach_sequence_length=0; slot = subframe*2; slot_gNB = 1+(subframe*2); } + if (config_index<67 && mu != 3) { prach_sequence_length=0; slot = subframe * frame_parms->slots_per_subframe; } uint16_t N_ZC = prach_sequence_length == 0 ? 839 : 139; printf("Config_index %d, prach_sequence_length %d\n",config_index,prach_sequence_length); @@ -563,9 +571,11 @@ int main(int argc, char **argv){ ru->gNB_list[0] = gNB; gNB->gNB_config.carrier_config.num_tx_ant.value = 1; gNB->gNB_config.carrier_config.num_rx_ant.value = 1; - if (mu==1) + if (mu == 0) + gNB->gNB_config.tdd_table.tdd_period.value = 7; + else if (mu == 1) gNB->gNB_config.tdd_table.tdd_period.value = 6; - else if (mu==3) + else if (mu == 3) gNB->gNB_config.tdd_table.tdd_period.value = 3; else { printf("unsupported numerology %d\n",mu); @@ -579,7 +589,7 @@ int main(int argc, char **argv){ int ret = get_nr_prach_info_from_index(config_index, (int)frame, - (int)slot_gNB, + (int)slot, absoluteFrequencyPointA, mu, frame_parms->frame_type, @@ -711,12 +721,7 @@ int main(int argc, char **argv){ bw = N_RB_UL*(180e3)*(1 << frame_parms->numerology_index); AssertFatal(bw<=122.88e6,"Illegal channel bandwidth %f (mu %d,N_RB_UL %d)\n", bw, frame_parms->numerology_index, N_RB_UL); - if (bw <= 30.72e6) - fs = 30.72e6; - else if (bw <= 61.44e6) - fs = 61.44e6; - else if (bw <= 122.88e6) - fs = 122.88e6; + fs = frame_parms->samples_per_subframe * 1e3; LOG_I(PHY,"Running with bandwidth %f Hz, fs %f samp/s, FRAME_LENGTH_COMPLEX_SAMPLES %d\n",bw,fs,FRAME_LENGTH_COMPLEX_SAMPLES); diff --git a/openair1/SIMULATION/NR_PHY/pucchsim.c b/openair1/SIMULATION/NR_PHY/pucchsim.c index 514e2f52a7..0b40997ae8 100644 --- a/openair1/SIMULATION/NR_PHY/pucchsim.c +++ b/openair1/SIMULATION/NR_PHY/pucchsim.c @@ -47,12 +47,13 @@ #include "openair1/SIMULATION/NR_PHY/nr_unitary_defs.h" #include "openair1/SIMULATION/NR_PHY/nr_dummy_functions.c" - +THREAD_STRUCT thread_struct; PHY_VARS_gNB *gNB; PHY_VARS_NR_UE *UE; RAN_CONTEXT_t RC; openair0_config_t openair0_cfg[MAX_CARDS]; int32_t uplink_frequency_offset[MAX_NUM_CCs][4]; +uint64_t downlink_frequency[MAX_NUM_CCs][4]; double cpuf; //uint8_t nfapi_mode = 0; @@ -552,7 +553,7 @@ int main(int argc, char **argv) if (n_trials==1) printf("txlev %d (%f dB), offset %d, sigma2 %f ( %f dB)\n",txlev,10*log10(txlev),startingSymbolIndex*frame_parms->ofdm_symbol_size,sigma2,sigma2_dB); - struct complex16 **rxdataF = (struct complex16 **)gNB->common_vars.rxdataF; + c16_t **rxdataF = (struct complex16 **)gNB->common_vars.rxdataF; for (int symb=0; symbframe_parms.symbols_per_slot;symb++) { if (symb= startingSymbolIndex+nrofSymbols) { int i0 = symb*gNB->frame_parms.ofdm_symbol_size; diff --git a/openair1/SIMULATION/NR_PHY/ulschsim.c b/openair1/SIMULATION/NR_PHY/ulschsim.c index 3d756ca86a..21218dea89 100644 --- a/openair1/SIMULATION/NR_PHY/ulschsim.c +++ b/openair1/SIMULATION/NR_PHY/ulschsim.c @@ -47,13 +47,16 @@ #include "openair1/SIMULATION/NR_PHY/nr_unitary_defs.h" #include "openair1/SIMULATION/NR_PHY/nr_dummy_functions.c" #include "common/utils/threadPool/thread-pool.h" +#include "openair2/LAYER2/NR_MAC_COMMON/nr_mac_common.h" //#define DEBUG_NR_ULSCHSIM +THREAD_STRUCT thread_struct; PHY_VARS_gNB *gNB; PHY_VARS_NR_UE *UE; RAN_CONTEXT_t RC; int32_t uplink_frequency_offset[MAX_NUM_CCs][4]; +uint64_t downlink_frequency[MAX_NUM_CCs][4]; void init_downlink_harq_status(NR_DL_UE_HARQ_t *dl_harq) {} @@ -138,6 +141,8 @@ int main(int argc, char **argv) uint16_t nb_symb_sch = 12; uint16_t nb_rb = 50; uint8_t Imcs = 9; + uint8_t Nl = 1; + uint8_t max_ldpc_iterations = 5; double DS_TDL = .03; @@ -151,7 +156,7 @@ int main(int argc, char **argv) randominit(0); //while ((c = getopt(argc, argv, "df:hpg:i:j:n:l:m:r:s:S:y:z:M:N:F:R:P:")) != -1) { - while ((c = getopt(argc, argv, "hg:n:s:S:py:z:M:N:R:F:m:l:r:")) != -1) { + while ((c = getopt(argc, argv, "hg:n:s:S:py:z:M:N:R:F:m:l:r:W:")) != -1) { switch (c) { /*case 'f': write_output_file = 1; @@ -252,7 +257,7 @@ int main(int argc, char **argv) case 'y': n_tx = atoi(optarg); - if ((n_tx == 0) || (n_tx > 2)) { + if ((n_tx == 0) || (n_tx > 4)) { printf("Unsupported number of TX antennas %d. Exiting.\n", n_tx); exit(-1); } @@ -262,7 +267,7 @@ int main(int argc, char **argv) case 'z': n_rx = atoi(optarg); - if ((n_rx == 0) || (n_rx > 2)) { + if ((n_rx == 0) || (n_rx > 4)) { printf("Unsupported number of RX antennas %d. Exiting.\n", n_rx); exit(-1); } @@ -300,6 +305,10 @@ int main(int argc, char **argv) printf("Illegal PBCH phase (0-3) got %d\n", pbch_phase); break;*/ + case 'W': + Nl = atoi(optarg); + break; + case 'm': Imcs = atoi(optarg); #ifdef DEBUG_NR_ULSCHSIM @@ -336,13 +345,14 @@ int main(int argc, char **argv) printf("-z Number of RX antennas used in UE\n"); //printf("-i Relative strength of first intefering eNB (in dB) - cell_id mod 3 = 1\n"); //printf("-j Relative strength of second intefering eNB (in dB) - cell_id mod 3 = 2\n"); + printf("-W number of layer\n"); printf("-M Multiple SSB positions in burst\n"); printf("-N Nid_cell\n"); printf("-R N_RB_UL\n"); printf("-F Input filename (.txt format) for RX conformance testing\n"); - printf("-m\n"); - printf("-l\n"); - printf("-r\n"); + printf("-m MCS\n"); + printf("-l number of symbol\n"); + printf("-r number of RB\n"); //printf("-O oversampling factor (1,2,4,8,16)\n"); //printf("-A Interpolation_filname Run with Abstraction to generate Scatter plot using interpolation polynomial in file\n"); //printf("-C Generate Calibration information for Abstraction (effective SNR adjustment to remove Pe bias w.r.t. AWGN)\n"); @@ -360,8 +370,8 @@ int main(int argc, char **argv) snr1 = snr0 + 10; gNB2UE = new_channel_desc_scm(n_tx, - n_rx, - channel_model, + n_rx, + channel_model, 61.44e6, //N_RB2sampling_rate(N_RB_DL), 40e6, //N_RB2channel_bandwidth(N_RB_DL), DS_TDL, @@ -384,15 +394,18 @@ int main(int argc, char **argv) initTpool(tp_param, gNB->threadPool, true); initNotifiedFIFO(gNB->respDecode); frame_parms = &gNB->frame_parms; //to be initialized I suppose (maybe not necessary for PBCH) - frame_parms->nb_antennas_tx = n_tx; - frame_parms->nb_antennas_rx = n_rx; frame_parms->N_RB_DL = N_RB_DL; frame_parms->N_RB_UL = N_RB_UL; frame_parms->Ncp = extended_prefix_flag ? EXTENDED : NORMAL; + gNB->max_ldpc_iterations = max_ldpc_iterations; + crcTableInit(); memcpy(&gNB->frame_parms, frame_parms, sizeof(NR_DL_FRAME_PARMS)); + gNB->frame_parms.nb_antennas_tx = 1; + gNB->frame_parms.nb_antennas_rx = n_rx; + nr_phy_config_request_sim(gNB, N_RB_UL, N_RB_UL, mu, Nid_cell, SSB_positions); phy_init_nr_gNB(gNB, 0, 1); //lowmem @@ -401,6 +414,9 @@ int main(int argc, char **argv) UE = malloc(sizeof(PHY_VARS_NR_UE)); memcpy(&UE->frame_parms, frame_parms, sizeof(NR_DL_FRAME_PARMS)); + UE->frame_parms.nb_antennas_tx = n_tx; + UE->frame_parms.nb_antennas_rx = 1; + //phy_init_nr_top(frame_parms); if (init_nr_ue_signal(UE, 1) != 0) { printf("Error at UE NR initialisation.\n"); @@ -408,15 +424,10 @@ int main(int argc, char **argv) } for (sf = 0; sf < 2; sf++) { - for (i = 0; i < 2; i++) { - - UE->ulsch[sf][0][i] = new_nr_ue_ulsch(N_RB_UL, 8); - - if (!UE->ulsch[sf][0][i]) { - printf("Can't get ue ulsch structures.\n"); - exit(-1); - } - + UE->ulsch[sf][0] = new_nr_ue_ulsch(N_RB_UL, 8, frame_parms); + if (!UE->ulsch[sf][0]) { + printf("Can't get ue ulsch structures.\n"); + exit(-1); } } @@ -427,20 +438,22 @@ int main(int argc, char **argv) uint8_t length_dmrs = 1; uint8_t N_PRB_oh; uint16_t N_RE_prime,code_rate; - unsigned char mod_order; - uint8_t Nl = 1; + unsigned char mod_order; uint8_t rvidx = 0; uint8_t UE_id = 0; - NR_gNB_ULSCH_t *ulsch_gNB = gNB->ulsch[UE_id][0]; + NR_gNB_ULSCH_t *ulsch_gNB = gNB->ulsch[UE_id]; NR_UL_gNB_HARQ_t *harq_process_gNB = ulsch_gNB->harq_processes[harq_pid]; nfapi_nr_pusch_pdu_t *rel15_ul = &harq_process_gNB->ulsch_pdu; - NR_UE_ULSCH_t *ulsch_ue = UE->ulsch[0][0][0]; + NR_UE_ULSCH_t *ulsch_ue = UE->ulsch[0][0]; + + if ((Nl==4)||(Nl==3)) + nb_re_dmrs = nb_re_dmrs*2; mod_order = nr_get_Qm_ul(Imcs, 0); code_rate = nr_get_code_rate_ul(Imcs, 0); - available_bits = nr_get_G(nb_rb, nb_symb_sch, nb_re_dmrs, length_dmrs, mod_order, 1); + available_bits = nr_get_G(nb_rb, nb_symb_sch, nb_re_dmrs, length_dmrs, mod_order, Nl); TBS = nr_compute_tbs(mod_order,code_rate, nb_rb, nb_symb_sch, nb_re_dmrs*length_dmrs, 0, 0, Nl); printf("\nAvailable bits %u TBS %u mod_order %d\n", available_bits, TBS, mod_order); @@ -453,7 +466,7 @@ int main(int argc, char **argv) rel15_ul->pusch_data.rv_index = rvidx; rel15_ul->nrOfLayers = Nl; rel15_ul->target_code_rate = code_rate; - rel15_ul->pusch_data.tb_size = TBS/8; + rel15_ul->pusch_data.tb_size = TBS>>3; /////////////////////////////////////////////////// double modulated_input[16 * 68 * 384]; // [hna] 16 segments, 68*Zc @@ -480,7 +493,9 @@ int main(int argc, char **argv) harq_process_ul_ue->pusch_pdu.nr_of_symbols = nb_symb_sch; harq_process_ul_ue->num_of_mod_symbols = N_RE_prime*nb_rb*nb_codewords; harq_process_ul_ue->pusch_pdu.pusch_data.rv_index = rvidx; - harq_process_ul_ue->pusch_pdu.pusch_data.tb_size = TBS/8; + harq_process_ul_ue->pusch_pdu.pusch_data.tb_size = TBS>>3; + harq_process_ul_ue->pusch_pdu.target_code_rate = code_rate; + harq_process_ul_ue->pusch_pdu.qam_mod_order = mod_order; unsigned char *test_input = harq_process_ul_ue->a; /////////// @@ -526,7 +541,7 @@ int main(int argc, char **argv) } */ - if (ulsch_ue->g[i] == 0) + if (ulsch_ue->harq_processes[harq_pid]->f[i] == 0) modulated_input[i] = 1.0; ///sqrt(2); //QPSK else modulated_input[i] = -1.0; ///sqrt(2); @@ -616,8 +631,8 @@ int main(int argc, char **argv) } for (sf = 0; sf < 2; sf++) - for (i = 0; i < 2; i++) - free_nr_ue_ulsch(&UE->ulsch[sf][0][i], N_RB_UL); + free_nr_ue_ulsch(&UE->ulsch[sf][0], N_RB_UL, frame_parms); + term_nr_ue_signal(UE, 1); free(UE); diff --git a/openair1/SIMULATION/NR_PHY/ulsim.c b/openair1/SIMULATION/NR_PHY/ulsim.c index af76fd7086..f16103e2db 100644 --- a/openair1/SIMULATION/NR_PHY/ulsim.c +++ b/openair1/SIMULATION/NR_PHY/ulsim.c @@ -91,7 +91,6 @@ double cpuf; uint64_t downlink_frequency[MAX_NUM_CCs][4]; THREAD_STRUCT thread_struct; nfapi_ue_release_request_body_t release_rntis; -uint32_t N_RB_DL = 106; //Fixme: Uniq dirty DU instance, by global var, datamodel need better management instance_t DUuniqInstance=0; @@ -100,6 +99,11 @@ teid_t newGtpuCreateTunnel(instance_t instance, rnti_t rnti, int incoming_bearer transport_layer_addr_t remoteAddr, int port, gtpCallback callBack) { return 0; } + +int newGtpuDeleteAllTunnels(instance_t instance, rnti_t rnti) { + return 0; +} + extern void fix_scd(NR_ServingCellConfig_t *scd);// forward declaration int8_t nr_mac_rrc_data_ind_ue(const module_id_t module_id, @@ -221,6 +225,8 @@ int DU_send_INITIAL_UL_RRC_MESSAGE_TRANSFER(module_id_t module_idP, return 0; } +nr_bler_struct nr_bler_data[NR_NUM_MCS]; + //nFAPI P7 dummy functions int oai_nfapi_dl_tti_req(nfapi_nr_dl_tti_request_t *dl_config_req) { return(0); } @@ -297,10 +303,9 @@ int main(int argc, char **argv) int gNB_id = 0; int ap; int tx_offset; - int32_t txlev=0; + int32_t txlev_sum = 0, atxlev[4]; int start_rb = 0; int UE_id =0; // [hna] only works for UE_id = 0 because NUMBER_OF_NR_UE_MAX is set to 1 (phy_init_nr_gNB causes segmentation fault) - float target_error_rate = 0.01; int print_perf = 0; cpuf = get_cpu_freq_GHz(); int msg3_flag = 0; @@ -308,23 +313,22 @@ int main(int argc, char **argv) float roundStats[100]; double effRate[100]; double effTP[100]; - //float eff_tp_check = 0.7; + float eff_tp_check = 100; uint8_t snrRun; - int prb_inter = 0; int ldpc_offload_flag = 0; uint8_t max_rounds = 4; + int chest_type[2] = {0}; int enable_ptrs = 0; int modify_dmrs = 0; /* L_PTRS = ptrs_arg[0], K_PTRS = ptrs_arg[1] */ int ptrs_arg[2] = {-1,-1};// Invalid values - /* DMRS TYPE = dmrs_arg[0], Add Pos = dmrs_arg[1] */ - int dmrs_arg[2] = {-1,-1};// Invalid values + int dmrs_arg[4] = {-1,-1,-1,-1};// Invalid values uint16_t ptrsSymPos = 0; uint16_t ptrsSymbPerSlot = 0; uint16_t ptrsRePerSymb = 0; - uint8_t transform_precoding = 1; // 0 - ENABLE, 1 - DISABLE + uint8_t transform_precoding = transformPrecoder_disabled; // 0 - ENABLE, 1 - DISABLE uint8_t num_dmrs_cdm_grps_no_data = 1; uint8_t mcs_table = 0; @@ -336,6 +340,7 @@ int main(int argc, char **argv) int ibwps=24; int ibwp_rboffset=41; int params_from_file = 0; + int max_ldpc_iterations = 5; if ( load_configmodule(argc,argv,CONFIG_ENABLECMDLINEONLY) == 0 ) { exit_fun("[NR_ULSIM] Error, configuration module init failed\n"); } @@ -346,7 +351,11 @@ int main(int argc, char **argv) /* initialize the sin-cos table */ InitSinLUT(); +<<<<<<< HEAD while ((c = getopt(argc, argv, "a:b:c:d:ef:g:h:ikl:m:n:o:p:q:r:s:u:w:y:z:F:G:H:M:N:PR:S:T:U:L:Z")) != -1) { +======= + while ((c = getopt(argc, argv, "a:b:c:d:ef:g:h:i:kl:m:n:p:q:r:s:t:u:w:y:z:F:G:H:I:M:N:PR:S:T:U:L:ZW:")) != -1) { +>>>>>>> develop printf("handling optarg %c\n",c); switch (c) { @@ -380,8 +389,8 @@ int main(int argc, char **argv) scg_fd = fopen(optarg, "r"); if (scg_fd == NULL) { - printf("Error opening %s\n", optarg); - exit(-1); + printf("Error opening %s\n", optarg); + exit(-1); } break; @@ -439,7 +448,9 @@ int main(int argc, char **argv) break; case 'i': - prb_inter=1; + for(i=0; i < atoi(optarg); i++){ + chest_type[i] = atoi(argv[optind++]); + } break; case 'k': @@ -454,7 +465,11 @@ int main(int argc, char **argv) case 'm': Imcs = atoi(optarg); break; - + + case 'W': + precod_nbr_layers = atoi(optarg); + break; + case 'n': n_trials = atoi(optarg); break; @@ -468,7 +483,11 @@ int main(int argc, char **argv) break; case 'q': +<<<<<<< HEAD max_rounds = atoi(optarg); +======= + mcs_table = atoi(optarg); +>>>>>>> develop break; case 'r': @@ -488,11 +507,10 @@ int main(int argc, char **argv) start_rb = atoi(optarg); break; -/* case 't': - eff_tp_check = (float)atoi(optarg)/100; + eff_tp_check = (float)atoi(optarg); break; -*/ + /* case 'r': ricean_factor = pow(10,-.1*atof(optarg)); @@ -509,32 +527,26 @@ int main(int argc, char **argv) case 'y': n_tx = atoi(optarg); - - if ((n_tx == 0) || (n_tx > 2)) { - printf("Unsupported number of tx antennas %d\n", n_tx); - exit(-1); + if ((n_tx == 0) || (n_tx > 4)) { + printf("Unsupported number of tx antennas %d\n", n_tx); + exit(-1); } - break; case 'z': n_rx = atoi(optarg); - if ((n_rx == 0) || (n_rx > 8)) { - printf("Unsupported number of rx antennas %d\n", n_rx); - exit(-1); + printf("Unsupported number of rx antennas %d\n", n_rx); + exit(-1); } - break; - + case 'F': input_fd = fopen(optarg, "r"); - if (input_fd == NULL) { - printf("Problem with filename %s\n", optarg); - exit(-1); + printf("Problem with filename %s\n", optarg); + exit(-1); } - break; case 'G': @@ -545,6 +557,10 @@ int main(int argc, char **argv) slot = atoi(optarg); break; + case 'I': + max_ldpc_iterations = atoi(optarg); + break; + case 'M': // SSB_positions = atoi(optarg); break; @@ -592,41 +608,40 @@ int main(int argc, char **argv) break; case 'Z': - - transform_precoding = 0; // enabled + transform_precoding = transformPrecoder_enabled; num_dmrs_cdm_grps_no_data = 2; mcs_table = 3; - - printf("NOTE: TRANSFORM PRECODING (SC-FDMA) is ENABLED in UPLINK (0 - ENABLE, 1 - DISABLE) : %d \n", transform_precoding); - + printf("NOTE: TRANSFORM PRECODING (SC-FDMA) is ENABLED in UPLINK (0 - ENABLE, 1 - DISABLE) : %d \n", transform_precoding); break; default: case 'h': - printf("%s -h(elp) -p(extended_prefix) -N cell_id -f output_filename -F input_filename -g channel_model -n n_frames -t Delayspread -s snr0 -S snr1 -x transmission_mode -y TXant -z RXant -i Intefrence0 -j Interference1 -A interpolation_file -C(alibration offset dB) -N CellId -Z Enable SC-FDMA in Uplink \n", argv[0]); + printf("%s -h(elp) -p(extended_prefix) -N cell_id -f output_filename -F input_filename -g channel_model -n n_frames -s snr0 -S snr1 -x transmission_mode -y TXant -z RXant -i Intefrence0 -j Interference1 -A interpolation_file -C(alibration offset dB) -N CellId -Z Enable SC-FDMA in Uplink \n", argv[0]); //printf("-d Use TDD\n"); printf("-d Introduce delay in terms of number of samples\n"); printf("-f Number of frames to simulate\n"); printf("-g [A,B,C,D,E,F,G] Use 3GPP SCM (A,B,C,D) or 36-101 (E-EPA,F-EVA,G-ETU) models (ignores delay spread and Ricean factor)\n"); printf("-h This message\n"); - printf("-i Activate PRB based averaging for channel estimation. Frequncy domain interpolation by default.\n"); + printf("-i Change channel estimation technique. Arguments list: Number of arguments=2, Frequency domain {0:Linear interpolation, 1:PRB based averaging}, Time domain {0:Estimates of last DMRS symbol, 1:Average of DMRS symbols}. e.g. -i 2 1 0\n"); //printf("-j Relative strength of second intefering eNB (in dB) - cell_id mod 3 = 2\n"); printf("-s Starting SNR, runs from SNR0 to SNR0 + 10 dB if ending SNR isn't given\n"); printf("-m MCS value\n"); printf("-n Number of trials to simulate\n"); printf("-o ldpc offload flag\n"); printf("-p Use extended prefix mode\n"); + printf("-q MCS table\n"); printf("-t Delay spread for multipath channel\n"); printf("-u Set the numerology\n"); printf("-w Start PRB for PUSCH\n"); //printf("-x Transmission mode (1,2,6 for the moment)\n"); - printf("-y Number of TX antennas used in eNB\n"); - printf("-z Number of RX antennas used in UE\n"); + printf("-y Number of TX antennas used at UE\n"); + printf("-z Number of RX antennas used at gNB\n"); printf("-A Interpolation_filname Run with Abstraction to generate Scatter plot using interpolation polynomial in file\n"); //printf("-C Generate Calibration information for Abstraction (effective SNR adjustment to remove Pe bias w.r.t. AWGN)\n"); printf("-F Input filename (.txt format) for RX conformance testing\n"); printf("-G Offset of samples to read from file (0 default)\n"); printf("-L \n"); + printf("-I Maximum LDPC decoder iterations\n"); printf("-M Multiple SSB positions in burst\n"); printf("-N Nid_cell\n"); printf("-O oversampling factor (1,2,4,8,16)\n"); @@ -634,10 +649,11 @@ int main(int argc, char **argv) printf("-t Acceptable effective throughput (in percentage)\n"); printf("-S Ending SNR, runs from SNR0 to SNR1\n"); printf("-P Print ULSCH performances\n"); - printf("-T Enable PTRS, arguments list L_PTRS{0,1,2} K_PTRS{2,4}, e.g. -T 2 0 2 \n"); - printf("-U Change DMRS Config, arguments list DMRS TYPE{0=A,1=B} DMRS AddPos{0:3}, e.g. -U 2 0 2 \n"); + printf("-T Enable PTRS, arguments list: Number of arguments=2 L_PTRS{0,1,2} K_PTRS{2,4}, e.g. -T 2 0 2 \n"); + printf("-U Change DMRS Config, arguments list: Number of arguments=4, DMRS Mapping Type{0=A,1=B}, DMRS AddPos{0:3}, DMRS Config Type{1,2}, Number of CDM groups without data{1,2,3} e.g. -U 4 0 2 0 1 \n"); printf("-Q If -F used, read parameters from file\n"); printf("-Z If -Z is used, SC-FDMA or transform precoding is enabled in Uplink \n"); + printf("-W Num of layer for PUSCH\n"); exit(-1); break; @@ -657,16 +673,37 @@ int main(int argc, char **argv) double sampling_frequency; double bandwidth; - if (N_RB_UL >= 217) sampling_frequency = 122.88; - else if (N_RB_UL >= 106) sampling_frequency = 61.44; - else if (N_RB_UL >= 32) sampling_frequency = 32.72; - else { printf("Need at least 106 PRBs\b"); exit(-1); } - if (N_RB_UL == 273) bandwidth = 100; - else if (N_RB_UL == 217) bandwidth = 80; - else if (N_RB_UL == 106) bandwidth = 40; - else if (N_RB_UL == 32) bandwidth = 50; - else { printf("Add N_RB_UL %d\n",N_RB_UL); exit(-1); } + if (mu == 0 && N_RB_UL == 25 ) { + sampling_frequency = 7.68; + bandwidth = 5; + } + else if (mu == 1 && N_RB_UL == 273) { + sampling_frequency = 122.88; + bandwidth = 100; + } + else if (mu == 1 && N_RB_UL == 217) { + sampling_frequency = 122.88; + bandwidth = 80; + } + else if (mu == 1 && N_RB_UL == 106) { + sampling_frequency = 61.44; + bandwidth = 40; + } + else if (mu == 1 && N_RB_UL == 24) { + sampling_frequency = 15.36; + bandwidth = 10; + } + else if (mu == 3 && N_RB_UL == 32) { + sampling_frequency = 61.44; + bandwidth = 50; + } + else { + printf("Add N_RB_UL %d\n",N_RB_UL); + exit(-1); + } + LOG_I( PHY,"++++++++++++++++++++++++++++++++++++++++++++++%i+++++++++++++++++++++++++++++++++++++++++",loglvl); + if (openair0_cfg[0].threequarter_fs == 1) sampling_frequency*=.75; UE2gNB = new_channel_desc_scm(n_tx, n_rx, channel_model, @@ -707,7 +744,7 @@ int main(int argc, char **argv) gNB->UL_INFO.crc_ind.crc_list = (nfapi_nr_crc_t *)malloc(NB_UE_INST*sizeof(nfapi_nr_crc_t)); gNB->UL_INFO.rx_ind.number_of_pdus = 0; gNB->UL_INFO.crc_ind.number_crcs = 0; - gNB->prb_interpolation = prb_inter; + gNB->max_ldpc_iterations = max_ldpc_iterations; frame_parms = &gNB->frame_parms; //to be initialized I suppose (maybe not necessary for PBCH) frame_parms->N_RB_DL = N_RB_DL; @@ -742,30 +779,44 @@ int main(int argc, char **argv) prepare_scd(scd); // TODO do a UECAP for phy-sim - fill_default_secondaryCellGroup(scc, scd, secondaryCellGroup, NULL, 0, 1, n_tx, 0, 0, 0, 0); + const gNB_RrcConfigurationReq conf = { + .pdsch_AntennaPorts = { .N1 = 1, .N2 = 1, .XP = 1 }, + .pusch_AntennaPorts = n_rx, + .minRXTXTIME = 0, + .do_CSIRS = 0, + .do_SRS = 0, + .force_256qam_off = false + }; + fill_default_secondaryCellGroup(scc, scd, secondaryCellGroup, NULL, 0, 1, &conf, 0); // xer_fprint(stdout, &asn_DEF_NR_CellGroupConfig, (const void*)secondaryCellGroup); /* RRC parameter validation for secondaryCellGroup */ fix_scd(scd); - AssertFatal((gNB->if_inst = NR_IF_Module_init(0))!=NULL,"Cannot register interface"); + AssertFatal((gNB->if_inst = NR_IF_Module_init(0))!=NULL,"Cannot register interface"); - gNB->if_inst->NR_PHY_config_req = nr_phy_config_request; + gNB->if_inst->NR_PHY_config_req = nr_phy_config_request; // common configuration - rrc_mac_config_req_gNB(0,0, n_tx, n_rx, 0, 6, scc, &rrc.carrier.mib,0, 0, NULL); + rrc_mac_config_req_gNB(0,0, conf.pdsch_AntennaPorts, n_rx, 0, 6, scc, &rrc.carrier.mib, rrc.carrier.siblock1, 0, 0, NULL); // UE dedicated configuration - rrc_mac_config_req_gNB(0,0, n_tx, n_rx, 0, 6, scc, &rrc.carrier.mib,1, secondaryCellGroup->spCellConfig->reconfigurationWithSync->newUE_Identity,secondaryCellGroup); - frame_parms->nb_antennas_tx = n_tx; + rrc_mac_config_req_gNB(0,0, conf.pdsch_AntennaPorts, n_rx, 0, 6, scc, &rrc.carrier.mib, rrc.carrier.siblock1, 1, + secondaryCellGroup->spCellConfig->reconfigurationWithSync->newUE_Identity, secondaryCellGroup); + frame_parms->nb_antennas_tx = 1; frame_parms->nb_antennas_rx = n_rx; nfapi_nr_config_request_scf_t *cfg = &gNB->gNB_config; - cfg->carrier_config.num_tx_ant.value = n_tx; + cfg->carrier_config.num_tx_ant.value = 1; cfg->carrier_config.num_rx_ant.value = n_rx; // nr_phy_config_request_sim(gNB,N_RB_DL,N_RB_DL,mu,0,0x01); +<<<<<<< HEAD gNB->ldpc_offload_flag = ldpc_offload_flag; +======= + gNB->chest_freq = chest_type[0]; + gNB->chest_time = chest_type[1]; +>>>>>>> develop phy_init_nr_gNB(gNB,0,1); N_RB_DL = gNB->frame_parms.N_RB_DL; @@ -780,6 +831,8 @@ int main(int argc, char **argv) PHY_vars_UE_g[0] = malloc(sizeof(PHY_VARS_NR_UE*)); PHY_vars_UE_g[0][0] = UE; memcpy(&UE->frame_parms, frame_parms, sizeof(NR_DL_FRAME_PARMS)); + UE->frame_parms.nb_antennas_tx = n_tx; + UE->frame_parms.nb_antennas_rx = 0; if (init_nr_ue_signal(UE, 1) != 0) { printf("Error at UE NR initialisation\n"); @@ -788,10 +841,10 @@ int main(int argc, char **argv) init_nr_ue_transport(UE); - // initialize the pusch dmrs - uint16_t N_n_scid[2] = {frame_parms->Nid_cell,frame_parms->Nid_cell}; - int n_scid = 0; // This quantity is indicated by higher layer parameter dmrs-SeqInitialization - nr_init_pusch_dmrs(UE, N_n_scid, n_scid); + for(int n_scid = 0; n_scid<2; n_scid++) { + UE->scramblingID_ulsch[n_scid] = frame_parms->Nid_cell; + nr_init_pusch_dmrs(UE, frame_parms->Nid_cell, n_scid); + } //Configure UE NR_UE_RRC_INST_t rrcue; @@ -818,8 +871,13 @@ int main(int argc, char **argv) unsigned char harq_pid = 0; +<<<<<<< HEAD NR_gNB_ULSCH_t *ulsch_gNB = gNB->ulsch[UE_id][0]; +======= + + NR_gNB_ULSCH_t *ulsch_gNB = gNB->ulsch[UE_id]; +>>>>>>> develop //nfapi_nr_ul_config_ulsch_pdu *rel15_ul = &ulsch_gNB->harq_processes[harq_pid]->ulsch_pdu; nfapi_nr_ul_tti_request_t *UL_tti_req = malloc(sizeof(*UL_tti_req)); NR_Sched_Rsp_t *Sched_INFO = malloc(sizeof(*Sched_INFO)); @@ -828,11 +886,11 @@ int main(int argc, char **argv) nfapi_nr_pusch_pdu_t *pusch_pdu = &UL_tti_req->pdus_list[0].pusch_pdu; - NR_UE_ULSCH_t **ulsch_ue = UE->ulsch[0][0]; + NR_UE_ULSCH_t *ulsch_ue = UE->ulsch[0][0]; unsigned char *estimated_output_bit; unsigned char *test_input_bit; - uint32_t errors_decoding = 0; + uint32_t errors_decoding = 0; test_input_bit = (unsigned char *) malloc16(sizeof(unsigned char) * 16 * 68 * 384); @@ -864,23 +922,21 @@ int main(int argc, char **argv) /* validate parameters othwerwise default values are used */ /* -U flag can be used to set DMRS parameters*/ - if(modify_dmrs) - { + if(modify_dmrs) { if(dmrs_arg[0] == 0) - { mapping_type = typeA; - } else if (dmrs_arg[0] == 1) - { mapping_type = typeB; - } /* Additional DMRS positions */ if(dmrs_arg[1] >= 0 && dmrs_arg[1] <=3 ) - { add_pos = dmrs_arg[1]; - } + /* DMRS Conf Type 1 or 2 */ + if(dmrs_arg[2] == 1) + dmrs_config_type = pusch_dmrs_type1; + else if(dmrs_arg[2] == 2) + dmrs_config_type = pusch_dmrs_type2; + num_dmrs_cdm_grps_no_data = dmrs_arg[3]; } - printf("NOTE: DMRS config is modified with Mapping Type %d , Additional Position %d \n", mapping_type, add_pos ); uint8_t length_dmrs = pusch_len1; uint16_t l_prime_mask = get_l_prime(nb_symb_sch, mapping_type, add_pos, length_dmrs, start_symbol, NR_MIB__dmrs_TypeA_Position_pos2); @@ -888,22 +944,25 @@ int main(int argc, char **argv) printf("num dmrs sym %d\n",number_dmrs_symbols); uint8_t nb_re_dmrs = (dmrs_config_type == pusch_dmrs_type1) ? 6 : 4; - // if transform precoding is enabled - if (transform_precoding == 0) { + if ((UE->frame_parms.nb_antennas_tx==4)&&(precod_nbr_layers==4)) + num_dmrs_cdm_grps_no_data = 2; + + if (transform_precoding == transformPrecoder_enabled) { AssertFatal(enable_ptrs == 0, "PTRS NOT SUPPORTED IF TRANSFORM PRECODING IS ENABLED\n"); int8_t index = get_index_for_dmrs_lowpapr_seq((NR_NB_SC_PER_RB/2) * nb_rb); - AssertFatal(index >= 0, "Num RBs not configured according to 3GPP 38.211 section 6.3.1.4. For PUSCH with transform precoding, num RBs cannot be multiple of any other primenumber other than 2,3,5\n"); + AssertFatal(index >= 0, "Num RBs not configured according to 3GPP 38.211 section 6.3.1.4. For PUSCH with transform precoding, num RBs cannot be multiple of any other primenumber other than 2,3,5\n"); dmrs_config_type = pusch_dmrs_type1; + nb_re_dmrs = 6; printf("[ULSIM]: TRANSFORM PRECODING ENABLED. Num RBs: %d, index for DMRS_SEQ: %d\n", nb_rb, index); } - nb_re_dmrs = nb_re_dmrs * num_dmrs_cdm_grps_no_data; + nb_re_dmrs = nb_re_dmrs * num_dmrs_cdm_grps_no_data; - unsigned int available_bits = nr_get_G(nb_rb, nb_symb_sch, nb_re_dmrs, number_dmrs_symbols, mod_order, 1); + unsigned int available_bits = nr_get_G(nb_rb, nb_symb_sch, nb_re_dmrs, number_dmrs_symbols, mod_order, precod_nbr_layers); unsigned int TBS = nr_compute_tbs(mod_order, code_rate, nb_rb, nb_symb_sch, nb_re_dmrs * number_dmrs_symbols, 0, 0, precod_nbr_layers); @@ -928,17 +987,12 @@ int main(int argc, char **argv) double ts = 1.0/(frame_parms->subcarrier_spacing * frame_parms->ofdm_symbol_size); /* -T option enable PTRS */ - if(enable_ptrs) - { + if(enable_ptrs) { /* validate parameters othwerwise default values are used */ if(ptrs_arg[0] == 0 || ptrs_arg[0] == 1 || ptrs_arg[0] == 2 ) - { ptrs_time_density = ptrs_arg[0]; - } if(ptrs_arg[1] == 2 || ptrs_arg[1] == 4 ) - { ptrs_freq_density = ptrs_arg[1]; - } pdu_bit_map |= PUSCH_PDU_BITMAP_PUSCH_PTRS; printf("NOTE: PTRS Enabled with L %d, K %d \n", ptrs_time_density, ptrs_freq_density ); } @@ -970,7 +1024,6 @@ int main(int argc, char **argv) int slot_length = slot_offset - frame_parms->get_samples_slot_timestamp(slot-1,frame_parms,0); if (input_fd != NULL) { - AssertFatal(frame_parms->nb_antennas_rx == 1, "nb_ant != 1\n"); // 800 samples is N_TA_OFFSET for FR1 @ 30.72 Ms/s, AssertFatal(frame_parms->subcarrier_spacing==30000,"only 30 kHz for file input for now (%d)\n",frame_parms->subcarrier_spacing); @@ -998,18 +1051,21 @@ int main(int argc, char **argv) printf("harq_pid %d\n",harq_pid); } fseek(input_fd,file_offset*sizeof(int16_t)*2,SEEK_SET); - read_errors+=fread((void*)&gNB->common_vars.rxdata[0][slot_offset-delay], - sizeof(int16_t), - slot_length<<1, - input_fd); - if (read_errors==0) { - printf("error reading file\n"); - exit(1); + for (int irx=0; irxnb_antennas_rx; irx++) { + fseek(input_fd,irx*(slot_length+15)*sizeof(int16_t)*2,SEEK_SET); // matlab adds samlples to the end to emulate channel delay + read_errors+=fread((void*)&gNB->common_vars.rxdata[irx][slot_offset-delay], + sizeof(int16_t), + slot_length<<1, + input_fd); + if (read_errors==0) { + printf("error reading file\n"); + exit(1); + } + for (int i=0;i<16;i+=2) printf("slot_offset %d : %d,%d\n", + slot_offset, + ((int16_t*)&gNB->common_vars.rxdata[irx][slot_offset])[i], + ((int16_t*)&gNB->common_vars.rxdata[irx][slot_offset])[1+i]); } - for (int i=0;i<16;i+=2) printf("slot_offset %d : %d,%d\n", - slot_offset, - ((int16_t*)&gNB->common_vars.rxdata[0][slot_offset])[i], - ((int16_t*)&gNB->common_vars.rxdata[0][slot_offset])[1+i]); mod_order = nr_get_Qm_ul(Imcs, mcs_table); code_rate = nr_get_code_rate_ul(Imcs, mcs_table); @@ -1056,12 +1112,12 @@ int main(int argc, char **argv) uint8_t round = 0; crc_status = 1; - errors_decoding = 0; + errors_decoding = 0; memset((void*)roundStats,0,50*sizeof(roundStats[0])); while (roundharq_processes[harq_pid]->round = round; - gNB->ulsch[0][0]->harq_processes[harq_pid]->round = round; + ulsch_ue->harq_processes[harq_pid]->round = round; + gNB->ulsch[0]->harq_processes[harq_pid]->round = round; rv_index = nr_rv_round_map[round]; UE_proc.thread_id = 0; @@ -1103,12 +1159,12 @@ int main(int argc, char **argv) pusch_pdu->qam_mod_order = mod_order; pusch_pdu->transform_precoding = transform_precoding; pusch_pdu->data_scrambling_id = *scc->physCellId; - pusch_pdu->nrOfLayers = 1; + pusch_pdu->nrOfLayers = precod_nbr_layers; pusch_pdu->ul_dmrs_symb_pos = l_prime_mask; pusch_pdu->dmrs_config_type = dmrs_config_type; pusch_pdu->ul_dmrs_scrambling_id = *scc->physCellId; pusch_pdu->scid = 0; - pusch_pdu->dmrs_ports = 1; + pusch_pdu->dmrs_ports = ((1<num_dmrs_cdm_grps_no_data = num_dmrs_cdm_grps_no_data; pusch_pdu->resource_alloc = 1; pusch_pdu->rb_start = start_rb; @@ -1128,7 +1184,7 @@ int main(int argc, char **argv) pusch_pdu->pusch_ptrs.ptrs_ports_list[0].ptrs_re_offset = 0; // if transform precoding is enabled - if (transform_precoding == 0) { + if (transform_precoding == transformPrecoder_enabled) { pusch_pdu->dfts_ofdm.low_papr_group_number = *scc->physCellId % 30; // U as defined in 38.211 section 6.4.1.1.1.2 pusch_pdu->dfts_ofdm.low_papr_sequence_number = 0; // V as defined in 38.211 section 6.4.1.1.1.2 @@ -1175,7 +1231,9 @@ int main(int argc, char **argv) ul_config.ul_config_list[0].pusch_config_pdu.mcs_table = mcs_table; ul_config.ul_config_list[0].pusch_config_pdu.num_dmrs_cdm_grps_no_data = num_dmrs_cdm_grps_no_data; ul_config.ul_config_list[0].pusch_config_pdu.nrOfLayers = precod_nbr_layers; + ul_config.ul_config_list[0].pusch_config_pdu.dmrs_ports = ((1<physCellId % 30;// U as defined in 38.211 section 6.4.1.1.1.2 ul_config.ul_config_list[0].pusch_config_pdu.dfts_ofdm.low_papr_sequence_number = 0;// V as defined in 38.211 section 6.4.1.1.1.2 @@ -1202,7 +1260,7 @@ int main(int argc, char **argv) //nr_fill_ulsch(gNB,frame,slot,pusch_pdu); // Not needed as its its already filled as apart of "nr_schedule_response(Sched_INFO);" - for (int i=0;i<(TBS/8);i++) ulsch_ue[0]->harq_processes[harq_pid]->a[i]=i&0xff; + for (int i=0;i<(TBS/8);i++) ulsch_ue->harq_processes[harq_pid]->a[i]=i&0xff; if (input_fd == NULL) { // set FAPI parameters for UE, put them in the scheduled response and call @@ -1218,43 +1276,83 @@ int main(int argc, char **argv) LOG_D(PHY, "Sending Uplink data \n"); nr_ue_pusch_common_procedures(UE, slot, - &UE->frame_parms,1); + &UE->frame_parms, + UE->frame_parms.nb_antennas_tx); + if (n_trials==1) { - LOG_M("txsig0.m","txs0", UE->common_vars.txdata[0],frame_parms->samples_per_subframe*10,1,1); + LOG_M("txsig0.m","txs0", &UE->common_vars.txdata[0][slot_offset],slot_length,1,1); LOG_M("txsig0F.m","txs0F", UE->common_vars.txdataF[0],frame_parms->ofdm_symbol_size*14,1,1); + if (precod_nbr_layers > 1) { + LOG_M("txsig1.m","txs1", &UE->common_vars.txdata[1][slot_offset],slot_length,1,1); + LOG_M("txsig1F.m","txs1F", UE->common_vars.txdataF[1],frame_parms->ofdm_symbol_size*14,1,1); + if (precod_nbr_layers==4) { + LOG_M("txsig2.m","txs2", &UE->common_vars.txdata[2][slot_offset],slot_length,1,1); + LOG_M("txsig3.m","txs3", &UE->common_vars.txdata[3][slot_offset],slot_length,1,1); + LOG_M("txsig2F.m","txs2F", UE->common_vars.txdataF[2],frame_parms->ofdm_symbol_size*14,1,1); + LOG_M("txsig3F.m","txs3F", UE->common_vars.txdataF[3],frame_parms->ofdm_symbol_size*14,1,1); + } + } } /////////// //////////////////////////////////////////////////// tx_offset = frame_parms->get_samples_slot_timestamp(slot,frame_parms,0); - - txlev = signal_energy(&UE->common_vars.txdata[0][tx_offset + 5*frame_parms->ofdm_symbol_size + 4*frame_parms->nb_prefix_samples + frame_parms->nb_prefix_samples0], + txlev_sum = 0; + for (int aa=0; aaframe_parms.nb_antennas_tx; aa++) { + atxlev[aa] = signal_energy(&UE->common_vars.txdata[aa][tx_offset + 5*frame_parms->ofdm_symbol_size + 4*frame_parms->nb_prefix_samples + frame_parms->nb_prefix_samples0], frame_parms->ofdm_symbol_size + frame_parms->nb_prefix_samples); - } - else n_trials = 1; - if (input_fd == NULL ) { + txlev_sum += atxlev[aa]; - sigma_dB = 10 * log10((double)txlev * ((double)frame_parms->ofdm_symbol_size/(12*nb_rb))) - SNR;; + if (n_trials==1) printf("txlev[%d] = %d (%f dB) txlev_sum %d\n",aa,atxlev[aa],10*log10((double)atxlev[aa]),txlev_sum); + } + } + else + n_trials = 1; + + if (input_fd == NULL) { + // Justification of division by precod_nbr_layers: + // When the channel is the identity matrix, the results in terms of SNR should be almost equal for 2x2 and 4x4. + sigma_dB = 10 * log10((double)txlev_sum/precod_nbr_layers * ((double)frame_parms->ofdm_symbol_size/(12*nb_rb))) - SNR;; sigma = pow(10,sigma_dB/10); - if(n_trials==1) printf("sigma %f (%f dB), txlev %f (factor %f)\n",sigma,sigma_dB,10*log10((double)txlev),(double)(double) - frame_parms->ofdm_symbol_size/(12*nb_rb)); + if(n_trials==1) printf("sigma %f (%f dB), txlev_sum %f (factor %f)\n",sigma,sigma_dB,10*log10((double)txlev_sum),(double)(double) + frame_parms->ofdm_symbol_size/(12*nb_rb)); for (i=0; inb_antennas_tx; aa++) { + for (int aa=0; aaframe_parms.nb_antennas_tx; aa++) { s_re[aa][i] = ((double)(((short *)&UE->common_vars.txdata[aa][slot_offset]))[(i<<1)]); s_im[aa][i] = ((double)(((short *)&UE->common_vars.txdata[aa][slot_offset]))[(i<<1)+1]); } } - - if (UE2gNB->max_Doppler == 0) { - multipath_channel(UE2gNB, s_re, s_im, r_re, r_im, slot_length, 0, (n_trials==1)?1:0); + // The multipath_channel() function calculates a channel matrix with only 1's. So the channel rank is 1, and we + // cannot use multi-layer. To solve this issue, for now we use the H_awgn_mimo matrix for multi-layer. + if (precod_nbr_layers == 1) { + if (UE2gNB->max_Doppler == 0) { + multipath_channel(UE2gNB, s_re, s_im, r_re, r_im, slot_length, 0, (n_trials==1)?1:0); + } else { + multipath_tv_channel(UE2gNB, s_re, s_im, r_re, r_im, 2*slot_length, 0); + } } else { - multipath_tv_channel(UE2gNB, s_re, s_im, r_re, r_im, 2*slot_length, 0); + double H_awgn_mimo[4][4] ={{1.0, 0.2, 0.1, 0.05}, //rx 0 + {0.2, 1.0, 0.2, 0.1}, //rx 1 + {0.1, 0.2, 1.0, 0.2}, //rx 2 + {0.05, 0.1, 0.2, 1.0}}; //rx 3 + for (i=0; inb_antennas_rx; ap++) { + // sum up signals from different Tx antennas + r_re[ap][i] = 0; + r_im[ap][i] = 0; + for (int aa=0; aanb_antennas_rx; ap++) { ((int16_t*) &gNB->common_vars.rxdata[ap][slot_offset])[(2*i) + (delay*2)] = (int16_t)((r_re[ap][i]) + (sqrt(sigma/2)*gaussdouble(0.0,1.0))); // convert to fixed point @@ -1278,7 +1376,7 @@ int main(int argc, char **argv) pusch_pdu->ul_dmrs_symb_pos); ptrsSymbPerSlot = get_ptrs_symbols_in_slot(ptrsSymPos, pusch_pdu->start_symbol_index, pusch_pdu->nr_of_symbols); ptrsRePerSymb = ((pusch_pdu->rb_size + ptrs_freq_density - 1)/ptrs_freq_density); - printf("[ULSIM] PTRS Symbols in a slot: %2u, RE per Symbol: %3u, RE in a slot %4d\n", ptrsSymbPerSlot,ptrsRePerSymb, ptrsSymbPerSlot*ptrsRePerSymb ); + LOG_D(PHY,"[ULSIM] PTRS Symbols in a slot: %2u, RE per Symbol: %3u, RE in a slot %4d\n", ptrsSymbPerSlot,ptrsRePerSymb, ptrsSymbPerSlot*ptrsRePerSymb ); } //////////////////////////////////////////////////////////// @@ -1288,130 +1386,152 @@ int main(int argc, char **argv) gNB->UL_INFO.rx_ind.number_of_pdus = 0; gNB->UL_INFO.crc_ind.number_crcs = 0; - phy_procedures_gNB_common_RX(gNB, frame, slot); + phy_procedures_gNB_common_RX(gNB, frame, slot); - ul_proc_error = phy_procedures_gNB_uespec_RX(gNB, frame, slot); + ul_proc_error = phy_procedures_gNB_uespec_RX(gNB, frame, slot); - if (n_trials==1 && round==0) { - LOG_M("rxsig0.m","rx0",&gNB->common_vars.rxdata[0][slot_offset],slot_length,1,1); - - LOG_M("rxsigF0.m","rxsF0",gNB->common_vars.rxdataF[0]+start_symbol*frame_parms->ofdm_symbol_size,nb_symb_sch*frame_parms->ofdm_symbol_size,1,1); - - } - - - if (n_trials == 1 && round==0) { -#ifdef __AVX2__ - __attribute__((unused)) - int off = ((nb_rb&1) == 1)? 4:0; -#else - __attribute__((unused)) - int off = 0; -#endif - - LOG_M("rxsigF0_ext.m","rxsF0_ext", - &gNB->pusch_vars[0]->rxdataF_ext[0][start_symbol*NR_NB_SC_PER_RB * pusch_pdu->rb_size],nb_symb_sch*(off+(NR_NB_SC_PER_RB * pusch_pdu->rb_size)),1,1); - LOG_M("chestF0.m","chF0", - &gNB->pusch_vars[0]->ul_ch_estimates[0][start_symbol*frame_parms->ofdm_symbol_size],frame_parms->ofdm_symbol_size,1,1); - LOG_M("chestT0.m","chT0", - &gNB->pusch_vars[0]->ul_ch_estimates_time[0][0],frame_parms->ofdm_symbol_size,1,1); - LOG_M("chestF0_ext.m","chF0_ext", - &gNB->pusch_vars[0]->ul_ch_estimates_ext[0][(start_symbol+1)*(off+(NR_NB_SC_PER_RB * pusch_pdu->rb_size))], - (nb_symb_sch-1)*(off+(NR_NB_SC_PER_RB * pusch_pdu->rb_size)),1,1); - LOG_M("rxsigF0_comp.m","rxsF0_comp", - &gNB->pusch_vars[0]->rxdataF_comp[0][start_symbol*(off+(NR_NB_SC_PER_RB * pusch_pdu->rb_size))],nb_symb_sch*(off+(NR_NB_SC_PER_RB * pusch_pdu->rb_size)),1,1); - LOG_M("chmagF0.m","chmF0", - &gNB->pusch_vars[0]->ul_ch_mag[0][start_symbol*(off+(NR_NB_SC_PER_RB * pusch_pdu->rb_size))],nb_symb_sch*(off+(NR_NB_SC_PER_RB * pusch_pdu->rb_size)),1,1); - LOG_M("chmagbF0.m","chmbF0", - &gNB->pusch_vars[0]->ul_ch_magb[0][start_symbol*(off+(NR_NB_SC_PER_RB * pusch_pdu->rb_size))],nb_symb_sch*(off+(NR_NB_SC_PER_RB * pusch_pdu->rb_size)),1,1); - if (n_rx == 2) { - LOG_MM("rxsigF0_comp.m","rxsF1_comp", - &gNB->pusch_vars[0]->rxdataF_comp[1][start_symbol*(off+(NR_NB_SC_PER_RB * pusch_pdu->rb_size))],nb_symb_sch*(off+(NR_NB_SC_PER_RB * pusch_pdu->rb_size)),1,1); - LOG_MM("rxsigF0_ext.m","rxsF1_ext", - &gNB->pusch_vars[0]->rxdataF_ext[1][start_symbol*NR_NB_SC_PER_RB * pusch_pdu->rb_size],nb_symb_sch*(off+(NR_NB_SC_PER_RB * pusch_pdu->rb_size)),1,1); - LOG_MM("chestF0_ext.m","chF1_ext", - &gNB->pusch_vars[0]->ul_ch_estimates_ext[1][(start_symbol+1)*(off+(NR_NB_SC_PER_RB * pusch_pdu->rb_size))], - (nb_symb_sch-1)*(off+(NR_NB_SC_PER_RB * pusch_pdu->rb_size)),1,1); - LOG_MM("chmagF0.m","chmF1", - &gNB->pusch_vars[0]->ul_ch_mag[1][start_symbol*(off+(NR_NB_SC_PER_RB * pusch_pdu->rb_size))],nb_symb_sch*(off+(NR_NB_SC_PER_RB * pusch_pdu->rb_size)),1,1); - LOG_MM("chmagbF0.m","chmbF1", - &gNB->pusch_vars[0]->ul_ch_magb[1][start_symbol*(off+(NR_NB_SC_PER_RB * pusch_pdu->rb_size))],nb_symb_sch*(off+(NR_NB_SC_PER_RB * pusch_pdu->rb_size)),1,1); - } else if (n_rx == 4) { - LOG_MM("rxsigF0_comp.m","rxsF1_comp", - &gNB->pusch_vars[0]->rxdataF_comp[1][start_symbol*(off+(NR_NB_SC_PER_RB * pusch_pdu->rb_size))],nb_symb_sch*(off+(NR_NB_SC_PER_RB * pusch_pdu->rb_size)),1,1); - LOG_MM("rxsigF0_comp.m","rxsF2_comp", - &gNB->pusch_vars[0]->rxdataF_comp[2][start_symbol*(off+(NR_NB_SC_PER_RB * pusch_pdu->rb_size))],nb_symb_sch*(off+(NR_NB_SC_PER_RB * pusch_pdu->rb_size)),1,1); - LOG_MM("rxsigF0_comp.m","rxsF3_comp", - &gNB->pusch_vars[0]->rxdataF_comp[3][start_symbol*(off+(NR_NB_SC_PER_RB * pusch_pdu->rb_size))],nb_symb_sch*(off+(NR_NB_SC_PER_RB * pusch_pdu->rb_size)),1,1); - LOG_MM("rxsigF0_ext.m","rxsF1_ext", - &gNB->pusch_vars[0]->rxdataF_ext[1][start_symbol*NR_NB_SC_PER_RB * pusch_pdu->rb_size],nb_symb_sch*(off+(NR_NB_SC_PER_RB * pusch_pdu->rb_size)),1,1); - LOG_MM("rxsigF0_ext.m","rxsF2_ext", - &gNB->pusch_vars[0]->rxdataF_ext[2][start_symbol*NR_NB_SC_PER_RB * pusch_pdu->rb_size],nb_symb_sch*(off+(NR_NB_SC_PER_RB * pusch_pdu->rb_size)),1,1); - LOG_MM("rxsigF0_ext.m","rxsF3_ext", - &gNB->pusch_vars[0]->rxdataF_ext[3][start_symbol*NR_NB_SC_PER_RB * pusch_pdu->rb_size],nb_symb_sch*(off+(NR_NB_SC_PER_RB * pusch_pdu->rb_size)),1,1); - LOG_MM("chestF0_ext.m","chF1_ext", - &gNB->pusch_vars[0]->ul_ch_estimates_ext[1][(start_symbol+1)*(off+(NR_NB_SC_PER_RB * pusch_pdu->rb_size))], - (nb_symb_sch-1)*(off+(NR_NB_SC_PER_RB * pusch_pdu->rb_size)),1,1); - LOG_MM("chestF0_ext.m","chF2_ext", - &gNB->pusch_vars[0]->ul_ch_estimates_ext[2][(start_symbol+1)*(off+(NR_NB_SC_PER_RB * pusch_pdu->rb_size))], - (nb_symb_sch-1)*(off+(NR_NB_SC_PER_RB * pusch_pdu->rb_size)),1,1); - LOG_MM("chestF0_ext.m","chF3_ext", - &gNB->pusch_vars[0]->ul_ch_estimates_ext[3][(start_symbol+1)*(off+(NR_NB_SC_PER_RB * pusch_pdu->rb_size))], - (nb_symb_sch-1)*(off+(NR_NB_SC_PER_RB * pusch_pdu->rb_size)),1,1); - LOG_MM("chmagF0.m","chmF1", - &gNB->pusch_vars[0]->ul_ch_mag[1][start_symbol*(off+(NR_NB_SC_PER_RB * pusch_pdu->rb_size))],nb_symb_sch*(off+(NR_NB_SC_PER_RB * pusch_pdu->rb_size)),1,1); - LOG_MM("chmagF0.m","chmF2", - &gNB->pusch_vars[0]->ul_ch_mag[2][start_symbol*(off+(NR_NB_SC_PER_RB * pusch_pdu->rb_size))],nb_symb_sch*(off+(NR_NB_SC_PER_RB * pusch_pdu->rb_size)),1,1); - LOG_MM("chmagF0.m","chmF3", - &gNB->pusch_vars[0]->ul_ch_mag[3][start_symbol*(off+(NR_NB_SC_PER_RB * pusch_pdu->rb_size))],nb_symb_sch*(off+(NR_NB_SC_PER_RB * pusch_pdu->rb_size)),1,1); - LOG_MM("chmagbF0.m","chmbF1", - &gNB->pusch_vars[0]->ul_ch_magb[1][start_symbol*(off+(NR_NB_SC_PER_RB * pusch_pdu->rb_size))],nb_symb_sch*(off+(NR_NB_SC_PER_RB * pusch_pdu->rb_size)),1,1); - LOG_MM("chmagbF0.m","chmbF2", - &gNB->pusch_vars[0]->ul_ch_magb[2][start_symbol*(off+(NR_NB_SC_PER_RB * pusch_pdu->rb_size))],nb_symb_sch*(off+(NR_NB_SC_PER_RB * pusch_pdu->rb_size)),1,1); - LOG_MM("chmagbF0.m","chmbF3", - &gNB->pusch_vars[0]->ul_ch_magb[3][start_symbol*(off+(NR_NB_SC_PER_RB * pusch_pdu->rb_size))],nb_symb_sch*(off+(NR_NB_SC_PER_RB * pusch_pdu->rb_size)),1,1); + if (n_trials==1 && round==0) { + LOG_M("rxsig0.m","rx0",&gNB->common_vars.rxdata[0][slot_offset],slot_length,1,1); + LOG_M("rxsigF0.m","rxsF0",gNB->common_vars.rxdataF[0],14*frame_parms->ofdm_symbol_size,1,1); + if (precod_nbr_layers > 1) { + LOG_M("rxsig1.m","rx1",&gNB->common_vars.rxdata[1][slot_offset],slot_length,1,1); + LOG_M("rxsigF1.m","rxsF1",gNB->common_vars.rxdataF[1],14*frame_parms->ofdm_symbol_size,1,1); + if (precod_nbr_layers==4) { + LOG_M("rxsig2.m","rx2",&gNB->common_vars.rxdata[2][slot_offset],slot_length,1,1); + LOG_M("rxsig3.m","rx3",&gNB->common_vars.rxdata[3][slot_offset],slot_length,1,1); + LOG_M("rxsigF2.m","rxsF2",gNB->common_vars.rxdataF[2],14*frame_parms->ofdm_symbol_size,1,1); + LOG_M("rxsigF3.m","rxsF3",gNB->common_vars.rxdataF[3],14*frame_parms->ofdm_symbol_size,1,1); + } + } } - LOG_M("rxsigF0_llr.m","rxsF0_llr", - &gNB->pusch_vars[0]->llr[0],(nb_symb_sch-1)*NR_NB_SC_PER_RB * pusch_pdu->rb_size * mod_order,1,0); - } - //////////////////////////////////////////////////////////// - if ((gNB->ulsch[0][0]->last_iteration_cnt >= - gNB->ulsch[0][0]->max_ldpc_iterations+1) || ul_proc_error == 1) { - error_flag = 1; - n_errors[round][snrRun]++; - crc_status = 1; - } else { - crc_status = 0; - } - if(n_trials==1) printf("end of round %d rv_index %d\n",round, rv_index); + if (n_trials == 1 && round==0) { +#ifdef __AVX2__ + __attribute__((unused)) + int off = ((nb_rb&1) == 1)? 4:0; +#else + __attribute__((unused)) + int off = 0; +#endif - //---------------------------------------------------------- - //----------------- count and print errors ----------------- - //---------------------------------------------------------- + LOG_M("rxsigF0_ext.m","rxsF0_ext", + &gNB->pusch_vars[0]->rxdataF_ext[0][start_symbol*NR_NB_SC_PER_RB * pusch_pdu->rb_size],nb_symb_sch*(off+(NR_NB_SC_PER_RB * pusch_pdu->rb_size)),1,1); + LOG_M("chestF0.m","chF0", + &gNB->pusch_vars[0]->ul_ch_estimates[0][start_symbol*frame_parms->ofdm_symbol_size],frame_parms->ofdm_symbol_size,1,1); + LOG_M("chestT0.m","chT0", + &gNB->pusch_vars[0]->ul_ch_estimates_time[0][0],frame_parms->ofdm_symbol_size,1,1); + LOG_M("chestF0_ext.m","chF0_ext", + &gNB->pusch_vars[0]->ul_ch_estimates_ext[0][(start_symbol+1)*(off+(NR_NB_SC_PER_RB * pusch_pdu->rb_size))], + (nb_symb_sch-1)*(off+(NR_NB_SC_PER_RB * pusch_pdu->rb_size)),1,1); + LOG_M("rxsigF0_comp.m","rxsF0_comp", + &gNB->pusch_vars[0]->rxdataF_comp[0][start_symbol*(off+(NR_NB_SC_PER_RB * pusch_pdu->rb_size))],nb_symb_sch*(off+(NR_NB_SC_PER_RB * pusch_pdu->rb_size)),1,1); + LOG_M("chmagF0.m","chmF0", + &gNB->pusch_vars[0]->ul_ch_mag[0][start_symbol*(off+(NR_NB_SC_PER_RB * pusch_pdu->rb_size))],nb_symb_sch*(off+(NR_NB_SC_PER_RB * pusch_pdu->rb_size)),1,1); + LOG_M("chmagbF0.m","chmbF0", + &gNB->pusch_vars[0]->ul_ch_magb[0][start_symbol*(off+(NR_NB_SC_PER_RB * pusch_pdu->rb_size))],nb_symb_sch*(off+(NR_NB_SC_PER_RB * pusch_pdu->rb_size)),1,1); + LOG_M("rxsigF0_llrlayers0.m","rxsF0_llrlayers0", + &gNB->pusch_vars[0]->llr_layers[0][0],(nb_symb_sch-1)*NR_NB_SC_PER_RB * pusch_pdu->rb_size * mod_order,1,0); + + if (precod_nbr_layers==2) { + LOG_M("rxsigF1_ext.m","rxsF1_ext", + &gNB->pusch_vars[0]->rxdataF_ext[1][start_symbol*NR_NB_SC_PER_RB * pusch_pdu->rb_size],nb_symb_sch*(off+(NR_NB_SC_PER_RB * pusch_pdu->rb_size)),1,1); + + LOG_M("chestF3.m","chF3", + &gNB->pusch_vars[0]->ul_ch_estimates[3][start_symbol*frame_parms->ofdm_symbol_size],frame_parms->ofdm_symbol_size,1,1); + + LOG_M("chestF3_ext.m","chF3_ext", + &gNB->pusch_vars[0]->ul_ch_estimates_ext[3][(start_symbol+1)*(off+(NR_NB_SC_PER_RB * pusch_pdu->rb_size))], + (nb_symb_sch-1)*(off+(NR_NB_SC_PER_RB * pusch_pdu->rb_size)),1,1); + + LOG_M("rxsigF2_comp.m","rxsF2_comp", + &gNB->pusch_vars[0]->rxdataF_comp[2][start_symbol*(off+(NR_NB_SC_PER_RB * pusch_pdu->rb_size))],nb_symb_sch*(off+(NR_NB_SC_PER_RB * pusch_pdu->rb_size)),1,1); + + LOG_M("rxsigF0_llrlayers1.m","rxsF0_llrlayers1", + &gNB->pusch_vars[0]->llr_layers[1][0],(nb_symb_sch-1)*NR_NB_SC_PER_RB * pusch_pdu->rb_size * mod_order,1,0); - if ((pusch_pdu->pdu_bit_map & PUSCH_PDU_BITMAP_PUSCH_PTRS) && (SNR==snr0) && (trial==0) && (round==0)) { - ptrs_symbols = 0; - for (int i = pusch_pdu->start_symbol_index; i < pusch_pdu->start_symbol_index + pusch_pdu->nr_of_symbols; i++){ - ptrs_symbols += ((gNB->pusch_vars[UE_id]->ptrs_symbols) >> i) & 1; - } - /* 2*5*(50/2), for RB = 50,K = 2 for 5 OFDM PTRS symbols */ - available_bits -= 2 * ptrs_symbols * ((nb_rb + ptrs_freq_density - 1) /ptrs_freq_density); - printf("[ULSIM][PTRS] Available bits are: %5u, removed PTRS bits are: %5d \n",available_bits, (ptrsSymbPerSlot * ptrsRePerSymb * 2) ); } - for (i = 0; i < available_bits; i++) { - - if(((ulsch_ue[0]->g[i] == 0) && (gNB->pusch_vars[UE_id]->llr[i] <= 0)) || - ((ulsch_ue[0]->g[i] == 1) && (gNB->pusch_vars[UE_id]->llr[i] >= 0))) - { - /*if(errors_scrambling == 0) - printf("\x1B[34m" "[frame %d][trial %d]\t1st bit in error in unscrambling = %d\n" "\x1B[0m", frame, trial, i);*/ - errors_scrambling[round][snrRun]++; - } - } - round++; + if (precod_nbr_layers==4) { + LOG_M("rxsigF1_ext.m","rxsF1_ext", + &gNB->pusch_vars[0]->rxdataF_ext[1][start_symbol*NR_NB_SC_PER_RB * pusch_pdu->rb_size],nb_symb_sch*(off+(NR_NB_SC_PER_RB * pusch_pdu->rb_size)),1,1); + LOG_M("rxsigF2_ext.m","rxsF2_ext", + &gNB->pusch_vars[0]->rxdataF_ext[2][start_symbol*NR_NB_SC_PER_RB * pusch_pdu->rb_size],nb_symb_sch*(off+(NR_NB_SC_PER_RB * pusch_pdu->rb_size)),1,1); + LOG_M("rxsigF3_ext.m","rxsF3_ext", + &gNB->pusch_vars[0]->rxdataF_ext[3][start_symbol*NR_NB_SC_PER_RB * pusch_pdu->rb_size],nb_symb_sch*(off+(NR_NB_SC_PER_RB * pusch_pdu->rb_size)),1,1); + + LOG_M("chestF5.m","chF5", + &gNB->pusch_vars[0]->ul_ch_estimates[5][start_symbol*frame_parms->ofdm_symbol_size],frame_parms->ofdm_symbol_size,1,1); + LOG_M("chestF10.m","chF10", + &gNB->pusch_vars[0]->ul_ch_estimates[10][start_symbol*frame_parms->ofdm_symbol_size],frame_parms->ofdm_symbol_size,1,1); + LOG_M("chestF15.m","chF15", + &gNB->pusch_vars[0]->ul_ch_estimates[15][start_symbol*frame_parms->ofdm_symbol_size],frame_parms->ofdm_symbol_size,1,1); + + + LOG_M("chestF5_ext.m","chF5_ext", + &gNB->pusch_vars[0]->ul_ch_estimates_ext[5][(start_symbol+1)*(off+(NR_NB_SC_PER_RB * pusch_pdu->rb_size))], + (nb_symb_sch-1)*(off+(NR_NB_SC_PER_RB * pusch_pdu->rb_size)),1,1); + LOG_M("chestF10_ext.m","chF10_ext", + &gNB->pusch_vars[0]->ul_ch_estimates_ext[10][(start_symbol+1)*(off+(NR_NB_SC_PER_RB * pusch_pdu->rb_size))], + (nb_symb_sch-1)*(off+(NR_NB_SC_PER_RB * pusch_pdu->rb_size)),1,1); + LOG_M("chestF15_ext.m","chF15_ext", + &gNB->pusch_vars[0]->ul_ch_estimates_ext[15][(start_symbol+1)*(off+(NR_NB_SC_PER_RB * pusch_pdu->rb_size))], + (nb_symb_sch-1)*(off+(NR_NB_SC_PER_RB * pusch_pdu->rb_size)),1,1); + + + LOG_M("rxsigF4_comp.m","rxsF4_comp", + &gNB->pusch_vars[0]->rxdataF_comp[4][start_symbol*(off+(NR_NB_SC_PER_RB * pusch_pdu->rb_size))],nb_symb_sch*(off+(NR_NB_SC_PER_RB * pusch_pdu->rb_size)),1,1); + LOG_M("rxsigF8_comp.m","rxsF8_comp", + &gNB->pusch_vars[0]->rxdataF_comp[8][start_symbol*(off+(NR_NB_SC_PER_RB * pusch_pdu->rb_size))],nb_symb_sch*(off+(NR_NB_SC_PER_RB * pusch_pdu->rb_size)),1,1); + LOG_M("rxsigF12_comp.m","rxsF12_comp", + &gNB->pusch_vars[0]->rxdataF_comp[12][start_symbol*(off+(NR_NB_SC_PER_RB * pusch_pdu->rb_size))],nb_symb_sch*(off+(NR_NB_SC_PER_RB * pusch_pdu->rb_size)),1,1); + LOG_M("rxsigF0_llrlayers1.m","rxsF0_llrlayers1", + &gNB->pusch_vars[0]->llr_layers[1][0],(nb_symb_sch-1)*NR_NB_SC_PER_RB * pusch_pdu->rb_size * mod_order,1,0); + LOG_M("rxsigF0_llrlayers2.m","rxsF0_llrlayers2", + &gNB->pusch_vars[0]->llr_layers[2][0],(nb_symb_sch-1)*NR_NB_SC_PER_RB * pusch_pdu->rb_size * mod_order,1,0); + LOG_M("rxsigF0_llrlayers3.m","rxsF0_llrlayers3", + &gNB->pusch_vars[0]->llr_layers[3][0],(nb_symb_sch-1)*NR_NB_SC_PER_RB * pusch_pdu->rb_size * mod_order,1,0); + } + + LOG_M("rxsigF0_llr.m","rxsF0_llr", + &gNB->pusch_vars[0]->llr[0],precod_nbr_layers*(nb_symb_sch-1)*NR_NB_SC_PER_RB * pusch_pdu->rb_size * mod_order,1,0); + } + //////////////////////////////////////////////////////////// + + if ((gNB->ulsch[0]->last_iteration_cnt >= + gNB->ulsch[0]->max_ldpc_iterations+1) || ul_proc_error == 1) { + error_flag = 1; + n_errors[round][snrRun]++; + crc_status = 1; + } else + crc_status = 0; + if(n_trials==1) printf("end of round %d rv_index %d\n",round, rv_index); + + //---------------------------------------------------------- + //----------------- count and print errors ----------------- + //---------------------------------------------------------- + + if ((pusch_pdu->pdu_bit_map & PUSCH_PDU_BITMAP_PUSCH_PTRS) && (SNR==snr0) && (trial==0) && (round==0)) { + ptrs_symbols = 0; + for (int i = pusch_pdu->start_symbol_index; i < pusch_pdu->start_symbol_index + pusch_pdu->nr_of_symbols; i++) + ptrs_symbols += ((gNB->pusch_vars[UE_id]->ptrs_symbols) >> i) & 1; + + /* 2*5*(50/2), for RB = 50,K = 2 for 5 OFDM PTRS symbols */ + available_bits -= 2 * ptrs_symbols * ((nb_rb + ptrs_freq_density - 1) /ptrs_freq_density); + printf("[ULSIM][PTRS] Available bits are: %5u, removed PTRS bits are: %5d \n",available_bits, (ptrsSymbPerSlot * ptrsRePerSymb * 2) ); + } + + for (i = 0; i < available_bits; i++) { + + if(((ulsch_ue->harq_processes[harq_pid]->f[i] == 0) && (gNB->pusch_vars[UE_id]->llr[i] <= 0)) || + ((ulsch_ue->harq_processes[harq_pid]->f[i] == 1) && (gNB->pusch_vars[UE_id]->llr[i] >= 0))) { + + /*if(errors_scrambling == 0) + printf("\x1B[34m" "[frame %d][trial %d]\t1st bit in error in unscrambling = %d\n" "\x1B[0m", frame, trial, i);*/ + errors_scrambling[round][snrRun]++; + } + } + round++; } // round @@ -1422,7 +1542,7 @@ int main(int argc, char **argv) for (i = 0; i < TBS; i++) { estimated_output_bit[i] = (ulsch_gNB->harq_processes[harq_pid]->b[i/8] & (1 << (i & 7))) >> (i & 7); - test_input_bit[i] = (ulsch_ue[0]->harq_processes[harq_pid]->b[i/8] & (1 << (i & 7))) >> (i & 7); + test_input_bit[i] = (ulsch_ue->harq_processes[harq_pid]->b[i/8] & (1 << (i & 7))) >> (i & 7); if (estimated_output_bit[i] != test_input_bit[i]) { /*if(errors_decoding == 0) @@ -1430,6 +1550,7 @@ int main(int argc, char **argv) errors_decoding++; } } +<<<<<<< HEAD /*if (n_trials == 1) { for (int r=0;rharq_processes[harq_pid]->C;r++) for (int i=0;iharq_processes[harq_pid]->K>>3;i++) { @@ -1438,6 +1559,16 @@ int main(int argc, char **argv) i,ulsch_ue[0]->harq_processes[harq_pid]->c[r][i], i,ulsch_gNB->harq_processes[harq_pid]->c[r][i], ulsch_ue[0]->harq_processes[harq_pid]->c[r][i]^ulsch_gNB->harq_processes[harq_pid]->c[r][i]); +======= + if (n_trials == 1) { + for (int r=0;rharq_processes[harq_pid]->C;r++) + for (int i=0;iharq_processes[harq_pid]->K>>3;i++) { + if ((ulsch_ue->harq_processes[harq_pid]->c[r][i]^ulsch_gNB->harq_processes[harq_pid]->c[r][i]) != 0) printf("************"); + /*printf("r %d: in[%d] %x, out[%d] %x (%x)\n",r, + i,ulsch_ue->harq_processes[harq_pid]->c[r][i], + i,ulsch_gNB->harq_processes[harq_pid]->c[r][i], + ulsch_ue->harq_processes[harq_pid]->c[r][i]^ulsch_gNB->harq_processes[harq_pid]->c[r][i]);*/ +>>>>>>> develop } }*/ if (errors_decoding > 0 && error_flag == 0) { @@ -1478,7 +1609,12 @@ int main(int argc, char **argv) roundStats[snrRun],effRate[snrRun],effTP[snrRun],TBS); FILE *fd=fopen("nr_ulsim.log","w"); + if (fd == NULL) { + printf("Problem with filename %s\n", "nr_ulsim.log"); + exit(-1); + } dump_pusch_stats(fd,gNB); + fclose(fd); printf("*****************************************\n"); printf("\n"); @@ -1510,7 +1646,7 @@ int main(int argc, char **argv) if(n_trials==1) break; - if ((float)n_errors[0][snrRun]/(float)n_trials <= target_error_rate) { + if ((float)effTP[snrRun] >= eff_tp_check) { printf("*************\n"); printf("PUSCH test OK\n"); printf("*************\n"); @@ -1540,6 +1676,7 @@ int main(int argc, char **argv) length_dmrs, num_dmrs_cdm_grps_no_data); +<<<<<<< HEAD LOG_M("ulsimStats.m","SNR",snrStats,snrRun,1,7); LOG_MM("ulsimStats.m","BLER_round0",blerStats[0],snrRun,1,7); LOG_MM("ulsimStats.m","BLER_round1",blerStats[1],snrRun,1,7); @@ -1552,6 +1689,21 @@ int main(int argc, char **argv) LOG_MM("ulsimStats.m","EffRate",effRate,snrRun,1,7); LOG_MM("ulsimStats.m","EffTP",effTP,snrRun,1,7); LOG_MM("ulsimStats.m","LDPC_dec_time",ldpcDecStats,snrRun,1,7); +======= + char opStatsFile[50]; + sprintf(opStatsFile, "ulsimStats_z%d.m", n_rx); + LOG_M(opStatsFile,"SNR",snrStats,snrRun,1,7); + LOG_MM(opStatsFile,"BLER_round0",blerStats[0],snrRun,1,7); + LOG_MM(opStatsFile,"BLER_round1",blerStats[1],snrRun,1,7); + LOG_MM(opStatsFile,"BLER_round2",blerStats[2],snrRun,1,7); + LOG_MM(opStatsFile,"BLER_round3",blerStats[3],snrRun,1,7); + LOG_MM(opStatsFile,"BER_round0",berStats[0],snrRun,1,7); + LOG_MM(opStatsFile,"BER_round1",berStats[1],snrRun,1,7); + LOG_MM(opStatsFile,"BER_round2",berStats[2],snrRun,1,7); + LOG_MM(opStatsFile,"BER_round3",berStats[3],snrRun,1,7); + LOG_MM(opStatsFile,"EffRate",effRate,snrRun,1,7); + LOG_MM(opStatsFile,"EffTP",effTP,snrRun,1,7); +>>>>>>> develop free(test_input_bit); free(estimated_output_bit); if (gNB->ldpc_offload_flag) diff --git a/openair1/SIMULATION/NR_UE_PHY/unit_tests/src/frame_config_test.c b/openair1/SIMULATION/NR_UE_PHY/unit_tests/src/frame_config_test.c index c88c261667..093bb2d000 100644 --- a/openair1/SIMULATION/NR_UE_PHY/unit_tests/src/frame_config_test.c +++ b/openair1/SIMULATION/NR_UE_PHY/unit_tests/src/frame_config_test.c @@ -285,7 +285,7 @@ int main(int argc, char *argv[]) uint8_t nb_antennas_tx = 1; uint8_t nb_antennas_rx = 1; uint8_t frame_type = FDD; - uint8_t N_RB_DL=100; + int N_RB_DL=100; lte_prefix_type_t extended_prefix_flag = NORMAL; int Nid_cell[] = {(3*0+0)}; VOID_PARAMETER argc; diff --git a/openair1/SIMULATION/NR_UE_PHY/unit_tests/src/harq_test.c b/openair1/SIMULATION/NR_UE_PHY/unit_tests/src/harq_test.c index 05170e0bc9..96d7382f2b 100644 --- a/openair1/SIMULATION/NR_UE_PHY/unit_tests/src/harq_test.c +++ b/openair1/SIMULATION/NR_UE_PHY/unit_tests/src/harq_test.c @@ -200,7 +200,7 @@ int main(int argc, char *argv[]) uint8_t nb_antennas_tx = 1; uint8_t nb_antennas_rx = 1; uint8_t frame_type = FDD; - uint8_t N_RB_DL=100; + int N_RB_DL=100; lte_prefix_type_t extended_prefix_flag = NORMAL; int Nid_cell[] = {(3*0+0)}; VOID_PARAMETER argc; diff --git a/openair1/SIMULATION/NR_UE_PHY/unit_tests/src/pbch_test.c b/openair1/SIMULATION/NR_UE_PHY/unit_tests/src/pbch_test.c index 7600dfb08f..5c7f3157e7 100644 --- a/openair1/SIMULATION/NR_UE_PHY/unit_tests/src/pbch_test.c +++ b/openair1/SIMULATION/NR_UE_PHY/unit_tests/src/pbch_test.c @@ -379,7 +379,7 @@ int main(int argc, char *argv[]) uint8_t nb_antennas_tx = 1; uint8_t nb_antennas_rx = 1; uint8_t frame_type = FDD; - uint8_t N_RB_DL=100; + int N_RB_DL=100; lte_prefix_type_t extended_prefix_flag = NORMAL; int decoded_pbch = -1; int Nid1, Nid2; diff --git a/openair1/SIMULATION/NR_UE_PHY/unit_tests/src/pss_test.c b/openair1/SIMULATION/NR_UE_PHY/unit_tests/src/pss_test.c index 2088d558cb..de1249457f 100644 --- a/openair1/SIMULATION/NR_UE_PHY/unit_tests/src/pss_test.c +++ b/openair1/SIMULATION/NR_UE_PHY/unit_tests/src/pss_test.c @@ -184,7 +184,7 @@ int main(int argc, char *argv[]) uint8_t nb_antennas_rx = 1; uint16_t Nid_cell=123; uint8_t frame_type=FDD; - uint8_t N_RB_DL=100; + int N_RB_DL=100; lte_prefix_type_t extended_prefix_flag=NORMAL; const char *name_test = "PSS NR"; test_t test = { name_test, 0, 0, 0, 0}; diff --git a/openair1/SIMULATION/NR_UE_PHY/unit_tests/src/pss_util_test.c b/openair1/SIMULATION/NR_UE_PHY/unit_tests/src/pss_util_test.c index 4334bd12f9..2302c50ab1 100644 --- a/openair1/SIMULATION/NR_UE_PHY/unit_tests/src/pss_util_test.c +++ b/openair1/SIMULATION/NR_UE_PHY/unit_tests/src/pss_util_test.c @@ -206,7 +206,7 @@ void undefined_function(const char *function) { *********************************************************************/ int init_test(unsigned char N_tx, unsigned char N_rx, unsigned char transmission_mode, - unsigned char extended_prefix_flag, uint8_t frame_type, uint16_t Nid_cell, uint8_t N_RB_DL) { + unsigned char extended_prefix_flag, uint8_t frame_type, uint16_t Nid_cell, int N_RB_DL) { (void) transmission_mode; NR_DL_FRAME_PARMS *frame_parms; int log_level = OAILOG_TRACE; diff --git a/openair1/SIMULATION/NR_UE_PHY/unit_tests/src/pss_util_test.h b/openair1/SIMULATION/NR_UE_PHY/unit_tests/src/pss_util_test.h index f0929e88c0..78efc2234b 100644 --- a/openair1/SIMULATION/NR_UE_PHY/unit_tests/src/pss_util_test.h +++ b/openair1/SIMULATION/NR_UE_PHY/unit_tests/src/pss_util_test.h @@ -90,7 +90,7 @@ int set_pss_in_rx_buffer(PHY_VARS_NR_UE *PHY_vars_UE, int position_symbol, int p int init_test(unsigned char N_tx, unsigned char N_rx, unsigned char transmission_mode, unsigned char extended_prefix_flag, uint8_t frame_type, uint16_t Nid_cell, - uint8_t N_RB_DL); + int N_RB_DL); void display_test_configuration_pss(int position, int pss_sequence_number); diff --git a/openair1/SIMULATION/NR_UE_PHY/unit_tests/src/pucch_uci_generator_test.c b/openair1/SIMULATION/NR_UE_PHY/unit_tests/src/pucch_uci_generator_test.c index 68acea6d98..4948d0a876 100644 --- a/openair1/SIMULATION/NR_UE_PHY/unit_tests/src/pucch_uci_generator_test.c +++ b/openair1/SIMULATION/NR_UE_PHY/unit_tests/src/pucch_uci_generator_test.c @@ -142,7 +142,7 @@ int main(int argc, char *argv[]) { uint8_t nb_antennas_tx = 1; uint8_t nb_antennas_rx = 1; uint8_t frame_type = FDD; - uint8_t N_RB_DL=106; + int N_RB_DL=106; lte_prefix_type_t extended_prefix_flag = NORMAL; int Nid_cell[] = {(3*1+3)}; VOID_PARAMETER argc; diff --git a/openair1/SIMULATION/NR_UE_PHY/unit_tests/src/pucch_uci_test.c b/openair1/SIMULATION/NR_UE_PHY/unit_tests/src/pucch_uci_test.c index f731edc20a..31fe15a6de 100644 --- a/openair1/SIMULATION/NR_UE_PHY/unit_tests/src/pucch_uci_test.c +++ b/openair1/SIMULATION/NR_UE_PHY/unit_tests/src/pucch_uci_test.c @@ -1239,7 +1239,7 @@ int main(int argc, char *argv[]) uint8_t nb_antennas_tx = 1; uint8_t nb_antennas_rx = 1; uint8_t frame_type = FDD; - uint8_t N_RB_DL=100; + int N_RB_DL=100; lte_prefix_type_t extended_prefix_flag = NORMAL; int Nid_cell[] = {(3*1+3)}; VOID_PARAMETER argc; diff --git a/openair1/SIMULATION/NR_UE_PHY/unit_tests/src/srs_test.c b/openair1/SIMULATION/NR_UE_PHY/unit_tests/src/srs_test.c index 34ea68bc61..235387acf7 100644 --- a/openair1/SIMULATION/NR_UE_PHY/unit_tests/src/srs_test.c +++ b/openair1/SIMULATION/NR_UE_PHY/unit_tests/src/srs_test.c @@ -442,7 +442,7 @@ int main(int argc, char *argv[]) uint8_t nb_antennas_tx = 1; uint8_t nb_antennas_rx = 1; uint8_t frame_type = FDD; - uint8_t N_RB_DL=100; + int N_RB_DL=100; lte_prefix_type_t extended_prefix_flag = NORMAL; int Nid_cell[] = {(3*0+0)}; VOID_PARAMETER argc; diff --git a/openair1/SIMULATION/NR_UE_PHY/unit_tests/src/sss_test.c b/openair1/SIMULATION/NR_UE_PHY/unit_tests/src/sss_test.c index 34127b604f..6f6594861a 100644 --- a/openair1/SIMULATION/NR_UE_PHY/unit_tests/src/sss_test.c +++ b/openair1/SIMULATION/NR_UE_PHY/unit_tests/src/sss_test.c @@ -181,7 +181,7 @@ int main(int argc, char *argv[]) uint8_t nb_antennas_tx = 1; uint8_t nb_antennas_rx = 1; uint8_t frame_type = FDD; - uint8_t N_RB_DL=100; + int N_RB_DL=100; lte_prefix_type_t extended_prefix_flag = NORMAL; int phase; int Nid1, Nid2; diff --git a/openair2/COMMON/f1ap_messages_types.h b/openair2/COMMON/f1ap_messages_types.h index cb1a8c9577..5e5b4c37d3 100644 --- a/openair2/COMMON/f1ap_messages_types.h +++ b/openair2/COMMON/f1ap_messages_types.h @@ -60,7 +60,9 @@ #define F1AP_MAX_NB_CELLS 2 #define F1AP_MAX_NO_OF_TNL_ASSOCIATIONS 32 -#define F1AP_MAX_NO_UE_ID 1024 +#define F1AP_MAX_NO_UE_ID 1024 +#define F1AP_MAX_DU2CU_RRC_LENGTH 1024 + typedef struct f1ap_net_ip_address_s { unsigned ipv4:1; unsigned ipv6:1; @@ -307,7 +309,7 @@ typedef struct f1ap_initial_ul_rrc_message_s { uint16_t crnti; uint8_t *rrc_container; int rrc_container_length; - char du2cu_rrc_container[200]; + char du2cu_rrc_container[F1AP_MAX_DU2CU_RRC_LENGTH]; int du2cu_rrc_container_length; } f1ap_initial_ul_rrc_message_t; diff --git a/openair2/COMMON/m2ap_messages_types.h b/openair2/COMMON/m2ap_messages_types.h index c70c50fc64..460dbfc4bb 100644 --- a/openair2/COMMON/m2ap_messages_types.h +++ b/openair2/COMMON/m2ap_messages_types.h @@ -354,7 +354,7 @@ typedef struct m2ap_register_mce_req_s { int32_t uplink_frequency_offset[MAX_NUM_CCs]; uint32_t Nid_cell[MAX_NUM_CCs]; int16_t N_RB_DL[MAX_NUM_CCs]; - lte_frame_type_t frame_type[MAX_NUM_CCs]; + frame_type_t frame_type[MAX_NUM_CCs]; uint32_t fdd_earfcn_DL[MAX_NUM_CCs]; uint32_t fdd_earfcn_UL[MAX_NUM_CCs]; int num_cc; @@ -427,7 +427,7 @@ typedef struct m2ap_register_enb_req_s { int32_t uplink_frequency_offset[MAX_NUM_CCs]; uint32_t Nid_cell[MAX_NUM_CCs]; int16_t N_RB_DL[MAX_NUM_CCs]; - lte_frame_type_t frame_type[MAX_NUM_CCs]; + frame_type_t frame_type[MAX_NUM_CCs]; uint32_t fdd_earfcn_DL[MAX_NUM_CCs]; uint32_t fdd_earfcn_UL[MAX_NUM_CCs]; int num_cc; diff --git a/openair2/COMMON/m3ap_messages_types.h b/openair2/COMMON/m3ap_messages_types.h index 21e24dd449..36ac8fcc9a 100644 --- a/openair2/COMMON/m3ap_messages_types.h +++ b/openair2/COMMON/m3ap_messages_types.h @@ -123,7 +123,7 @@ typedef struct m3ap_register_mce_req_s { int32_t uplink_frequency_offset[MAX_NUM_CCs]; uint32_t Nid_cell[MAX_NUM_CCs]; int16_t N_RB_DL[MAX_NUM_CCs]; - lte_frame_type_t frame_type[MAX_NUM_CCs]; + frame_type_t frame_type[MAX_NUM_CCs]; uint32_t fdd_earfcn_DL[MAX_NUM_CCs]; uint32_t fdd_earfcn_UL[MAX_NUM_CCs]; int num_cc; diff --git a/openair2/COMMON/mac_messages_types.h b/openair2/COMMON/mac_messages_types.h index cad7b9f172..e43d0007e7 100644 --- a/openair2/COMMON/mac_messages_types.h +++ b/openair2/COMMON/mac_messages_types.h @@ -58,7 +58,7 @@ // Some constants from "LAYER2/MAC/defs.h" #define BCCH_SDU_SIZE (512) #define BCCH_SDU_MBMS_SIZE (512) -#define CCCH_SDU_SIZE (512) +#define CCCH_SDU_SIZE (1024) #define MCCH_SDU_SIZE (512) #define PCCH_SDU_SIZE (512) diff --git a/openair2/COMMON/phy_messages_types.h b/openair2/COMMON/phy_messages_types.h index 1f040a0a77..40e4678228 100644 --- a/openair2/COMMON/phy_messages_types.h +++ b/openair2/COMMON/phy_messages_types.h @@ -70,7 +70,7 @@ typedef struct CellInfo_s { //-------------------------------------------------------------------------------------------// // eNB: ENB_APP -> PHY messages typedef struct PhyConfigurationReq_s { - lte_frame_type_t frame_type[MAX_NUM_CCs]; + frame_type_t frame_type[MAX_NUM_CCs]; lte_prefix_type_t prefix_type[MAX_NUM_CCs]; uint32_t downlink_frequency[MAX_NUM_CCs]; int32_t uplink_frequency_offset[MAX_NUM_CCs]; diff --git a/openair2/COMMON/platform_types.h b/openair2/COMMON/platform_types.h index c24291de64..67300da308 100644 --- a/openair2/COMMON/platform_types.h +++ b/openair2/COMMON/platform_types.h @@ -233,6 +233,7 @@ typedef uint8_t pdusessionid_t; //----------------------------------------------------------------------------- // may be ITTI not enabled, but type instance is useful also for OTG, typedef intptr_t instance_t; + typedef struct protocol_ctxt_s { module_id_t module_id; /*!< \brief Virtualized module identifier */ eNB_flag_t enb_flag; /*!< \brief Flag to indicate eNB (1) or UE (0) */ diff --git a/openair2/COMMON/rrc_messages_types.h b/openair2/COMMON/rrc_messages_types.h index 769bc7d01d..67b0b610cc 100644 --- a/openair2/COMMON/rrc_messages_types.h +++ b/openair2/COMMON/rrc_messages_types.h @@ -167,7 +167,7 @@ typedef struct RadioResourceConfig_s { long ue_TransmissionMode; long ue_multiple_max; //SIB2 BR Options - long *preambleTransMax_CE_r13; + long preambleTransMax_CE_r13; BOOLEAN_t prach_ConfigCommon_v1310; BOOLEAN_t *mpdcch_startSF_CSS_RA_r13; long mpdcch_startSF_CSS_RA_r13_val; @@ -188,7 +188,7 @@ typedef struct RrcConfigurationReq_s { uint32_t rrc_inactivity_timer_thres; // for testing, maybe change later paging_drx_t default_drx; int16_t nb_cc; - lte_frame_type_t frame_type[MAX_NUM_CCs]; + frame_type_t frame_type[MAX_NUM_CCs]; uint8_t tdd_config[MAX_NUM_CCs]; uint8_t tdd_config_s[MAX_NUM_CCs]; lte_prefix_type_t prefix_type[MAX_NUM_CCs]; @@ -339,7 +339,7 @@ typedef struct NbIoTRrcConfigurationReq_s { uint16_t mcc; uint16_t mnc; uint8_t mnc_digit_length; - lte_frame_type_t frame_type; + frame_type_t frame_type; uint8_t tdd_config; uint8_t tdd_config_s; lte_prefix_type_t prefix_type; @@ -401,6 +401,12 @@ typedef struct NbIoTRrcConfigurationReq_s { long ue_TimersAndConstants_n311_NB; } NbIoTRrcConfigurationReq; +typedef struct { + int N1; + int N2; + int XP; +} rrc_pdsch_AntennaPorts_t; + // gNB: GNB_APP -> RRC messages typedef struct NRRrcConfigurationReq_s { uint64_t cell_identity; @@ -413,13 +419,15 @@ typedef struct NRRrcConfigurationReq_s { NR_ServingCellConfig_t *scd; int ssb_SubcarrierOffset; int sib1_tda; - int pdsch_AntennaPorts; + rrc_pdsch_AntennaPorts_t pdsch_AntennaPorts; int pusch_AntennaPorts; int minRXTXTIME; int do_CSIRS; int do_SRS; + bool force_256qam_off; int pusch_TargetSNRx10; int pucch_TargetSNRx10; + bool enable_sdap; } gNB_RrcConfigurationReq; typedef struct NRDuDlReq_s { diff --git a/openair2/COMMON/x2ap_messages_types.h b/openair2/COMMON/x2ap_messages_types.h index 9339ab12f3..cd092b6ca8 100644 --- a/openair2/COMMON/x2ap_messages_types.h +++ b/openair2/COMMON/x2ap_messages_types.h @@ -138,7 +138,7 @@ typedef struct x2ap_register_enb_req_s { int32_t uplink_frequency_offset[MAX_NUM_CCs]; uint32_t Nid_cell[MAX_NUM_CCs]; int16_t N_RB_DL[MAX_NUM_CCs]; - lte_frame_type_t frame_type[MAX_NUM_CCs]; + frame_type_t frame_type[MAX_NUM_CCs]; uint32_t fdd_earfcn_DL[MAX_NUM_CCs]; uint32_t fdd_earfcn_UL[MAX_NUM_CCs]; uint32_t subframeAssignment[MAX_NUM_CCs]; diff --git a/openair2/ENB_APP/RRC_config_tools.h b/openair2/ENB_APP/RRC_config_tools.h index 488441ff59..89cefeaa1f 100644 --- a/openair2/ENB_APP/RRC_config_tools.h +++ b/openair2/ENB_APP/RRC_config_tools.h @@ -38,7 +38,7 @@ typedef struct eutra_band_s { uint32_t ul_max; uint32_t dl_min; uint32_t dl_max; - lte_frame_type_t frame_type; + frame_type_t frame_type; } eutra_band_t; diff --git a/openair2/ENB_APP/enb_config_eMTC.c b/openair2/ENB_APP/enb_config_eMTC.c index cfd057bad8..2e71f17e9d 100644 --- a/openair2/ENB_APP/enb_config_eMTC.c +++ b/openair2/ENB_APP/enb_config_eMTC.c @@ -681,6 +681,58 @@ void fill_eMTC_configuration(MessageDef *msg_p, ccparams_eMTC_t *eMTCconfig, in "Failed to parse eNB configuration file %s, enb %d unknown value \"%d\" for rach_maxHARQ_Msg3Tx choice: 1..8!\n", config_fname, cell_idx,eMTCconfig->ccparams.rach_maxHARQ_Msg3Tx); + switch (eMTCconfig->preambleTransMax_CE_r13) { + case 3: + RRC_CONFIGURATION_REQ (msg_p).radioresourceconfig_BR[cc_idx].preambleTransMax_CE_r13= LTE_PreambleTransMax_n3; + break; + + case 4: + RRC_CONFIGURATION_REQ (msg_p).radioresourceconfig_BR[cc_idx].preambleTransMax_CE_r13= LTE_PreambleTransMax_n4; + break; + + case 5: + RRC_CONFIGURATION_REQ (msg_p).radioresourceconfig_BR[cc_idx].preambleTransMax_CE_r13= LTE_PreambleTransMax_n5; + break; + + case 6: + RRC_CONFIGURATION_REQ (msg_p).radioresourceconfig_BR[cc_idx].preambleTransMax_CE_r13= LTE_PreambleTransMax_n6; + break; + + case 7: + RRC_CONFIGURATION_REQ (msg_p).radioresourceconfig_BR[cc_idx].preambleTransMax_CE_r13= LTE_PreambleTransMax_n7; + break; + + case 8: + RRC_CONFIGURATION_REQ (msg_p).radioresourceconfig_BR[cc_idx].preambleTransMax_CE_r13= LTE_PreambleTransMax_n8; + break; + + case 10: + RRC_CONFIGURATION_REQ (msg_p).radioresourceconfig_BR[cc_idx].preambleTransMax_CE_r13= LTE_PreambleTransMax_n10; + break; + + case 20: + RRC_CONFIGURATION_REQ (msg_p).radioresourceconfig_BR[cc_idx].preambleTransMax_CE_r13= LTE_PreambleTransMax_n20; + break; + + case 50: + RRC_CONFIGURATION_REQ (msg_p).radioresourceconfig_BR[cc_idx].preambleTransMax_CE_r13= LTE_PreambleTransMax_n50; + break; + + case 100: + RRC_CONFIGURATION_REQ (msg_p).radioresourceconfig_BR[cc_idx].preambleTransMax_CE_r13= LTE_PreambleTransMax_n100; + break; + + case 200: + RRC_CONFIGURATION_REQ (msg_p).radioresourceconfig_BR[cc_idx].preambleTransMax_CE_r13= LTE_PreambleTransMax_n200; + break; + + default: + AssertFatal (0, + "Failed to parse eNB configuration file %s, enb %d unknown value \"%d\" for rach_preambleTransMax_CE_r13 choice: 3,4,5,6,7,8,10,20,50,100,200!\n", + config_fname, cell_idx,eMTCconfig->preambleTransMax_CE_r13); + break; + } + switch (eMTCconfig->ccparams.pcch_defaultPagingCycle) { case 32: RRC_CONFIGURATION_REQ (msg_p).radioresourceconfig_BR[cc_idx].pcch_defaultPagingCycle= LTE_PCCH_Config__defaultPagingCycle_rf32; diff --git a/openair2/ENB_APP/enb_paramdef.h b/openair2/ENB_APP/enb_paramdef.h index 22af2a6de0..e6e97069fa 100644 --- a/openair2/ENB_APP/enb_paramdef.h +++ b/openair2/ENB_APP/enb_paramdef.h @@ -99,6 +99,15 @@ typedef enum { #define CONFIG_STRING_RU_IF_FREQUENCY "if_freq" #define CONFIG_STRING_RU_IF_FREQ_OFFSET "if_offset" #define CONFIG_STRING_RU_DO_PRECODING "do_precoding" +#define CONFIG_STRING_RU_SF_AHEAD "sf_ahead" +#define CONFIG_STRING_RU_SL_AHEAD "sl_ahead" +#define CONFIG_STRING_RU_NR_FLAG "nr_flag" +#define CONFIG_STRING_RU_NR_SCS_FOR_RASTER "nr_scs_for_raster" + +#define HLP_RU_SF_AHEAD "LTE TX processing advance" +#define HLP_RU_SL_AHEAD "NR TX processing advance" +#define HLP_RU_NR_FLAG "Use NR numerology (for AW2SORI)" +#define HLP_RU_NR_SCS_FOR_RASTER "NR SCS for raster (for AW2SORI)" #define RU_LOCAL_IF_NAME_IDX 0 #define RU_LOCAL_ADDRESS_IDX 1 @@ -129,6 +138,10 @@ typedef enum { #define RU_IF_FREQUENCY 26 #define RU_IF_FREQ_OFFSET 27 #define RU_DO_PRECODING 28 +#define RU_SF_AHEAD 29 +#define RU_SL_AHEAD 30 +#define RU_NR_FLAG 31 +#define RU_NR_SCS_FOR_RASTER 32 /*-----------------------------------------------------------------------------------------------------------------------------------------*/ /* RU configuration parameters */ /* optname helpstr paramflags XXXptr defXXXval type numelt */ @@ -163,6 +176,10 @@ typedef enum { {CONFIG_STRING_RU_IF_FREQUENCY, NULL, 0, u64ptr:NULL, defuintval:0, TYPE_UINT64, 0}, \ {CONFIG_STRING_RU_IF_FREQ_OFFSET, NULL, 0, iptr:NULL, defintval:0, TYPE_INT, 0}, \ {CONFIG_STRING_RU_DO_PRECODING, NULL, 0, iptr:NULL, defintval:0, TYPE_INT, 0}, \ + {CONFIG_STRING_RU_SF_AHEAD, HLP_RU_SF_AHEAD, 0, iptr:NULL, defintval:4, TYPE_INT, 0}, \ + {CONFIG_STRING_RU_SL_AHEAD, HLP_RU_SL_AHEAD, 0, iptr:NULL, defintval:6, TYPE_INT, 0}, \ + {CONFIG_STRING_RU_NR_FLAG, HLP_RU_NR_FLAG, 0, iptr:NULL, defintval:0, TYPE_INT, 0}, \ + {CONFIG_STRING_RU_NR_SCS_FOR_RASTER, HLP_RU_NR_SCS_FOR_RASTER, 0, iptr:NULL, defintval:1, TYPE_INT, 0}, \ } /*---------------------------------------------------------------------------------------------------------------------------------------*/ diff --git a/openair2/ENB_APP/enb_paramdef_emtc.h b/openair2/ENB_APP/enb_paramdef_emtc.h index de774c4ea6..928c9d22e3 100644 --- a/openair2/ENB_APP/enb_paramdef_emtc.h +++ b/openair2/ENB_APP/enb_paramdef_emtc.h @@ -147,7 +147,7 @@ typedef struct ccparams_eMTC_s { int interval_DLHoppingConfigCommonModeA_r13_val; int interval_DLHoppingConfigCommonModeB_r13_val; int mpdcch_pdsch_HoppingOffset_r13; - char *preambleTransMax_CE_r13; + int preambleTransMax_CE_r13; int prach_HoppingOffset_r13; int schedulingInfoSIB1_BR_r13; int64_t fdd_DownlinkOrTddSubframeBitmapBR_val_r13; @@ -253,7 +253,7 @@ typedef struct ccparams_eMTC_s { {ENB_CONFIG_STRING_INTERVAL_DL_HOPPING_CONFIG_COMMON_MODE_B_R13, NULL, 0, strptr:&eMTCconfig->interval_DLHoppingConfigCommonModeB_r13, defstrval:"interval-FDD-r13", TYPE_STRING, 0}, \ {ENB_CONFIG_STRING_INTERVAL_DL_HOPPING_CONFIG_COMMON_MODE_B_R13_VAL, NULL, 0, iptr:&eMTCconfig->interval_DLHoppingConfigCommonModeB_r13_val, defintval:0, TYPE_UINT, 0}, \ {ENB_CONFIG_STRING_MPDCCH_PDSCH_HOPPING_OFFSET_R13, NULL, 0, iptr:&eMTCconfig->mpdcch_pdsch_HoppingOffset_r13, defintval:1, TYPE_UINT, 0}, \ -{ENB_CONFIG_STRING_PREAMBLE_TRANSMAX_CE_R13, NULL, 0, strptr:&eMTCconfig->preambleTransMax_CE_r13, defstrval:"n10", TYPE_STRING, 0}, \ +{ENB_CONFIG_STRING_PREAMBLE_TRANSMAX_CE_R13, NULL, 0, iptr:&eMTCconfig->preambleTransMax_CE_r13, defintval:10, TYPE_UINT, 0}, \ {ENB_CONFIG_STRING_PUCCH_NUM_REPETITION_CE_MSG4_LEVEL0, NULL, 0, strptr:&eMTCconfig->pucch_NumRepetitionCE_Msg4_Level0_r13, defstrval:"n1", TYPE_STRING, 0}, \ {ENB_CONFIG_STRING_PUCCH_NUM_REPETITION_CE_MSG4_LEVEL1, NULL, 0, strptr:&eMTCconfig->pucch_NumRepetitionCE_Msg4_Level1_r13, defstrval:"", TYPE_STRING, 0}, \ {ENB_CONFIG_STRING_PUCCH_NUM_REPETITION_CE_MSG4_LEVEL2, NULL, 0, strptr:&eMTCconfig->pucch_NumRepetitionCE_Msg4_Level2_r13, defstrval:"", TYPE_STRING, 0}, \ diff --git a/openair2/ENB_APP/flexran_agent_ran_api.c b/openair2/ENB_APP/flexran_agent_ran_api.c index 68d1f3311f..9926ec9e20 100644 --- a/openair2/ENB_APP/flexran_agent_ran_api.c +++ b/openair2/ENB_APP/flexran_agent_ran_api.c @@ -1352,7 +1352,7 @@ void flexran_agent_set_operating_bandwidth(mid_t mod_id, uint8_t cc_id, uint8_t } } -void flexran_agent_set_operating_frame_type(mid_t mod_id, uint8_t cc_id, lte_frame_type_t frame_type) { +void flexran_agent_set_operating_frame_type(mid_t mod_id, uint8_t cc_id, frame_type_t frame_type) { if (phy_is_present(mod_id, cc_id)) { RC.eNB[mod_id][cc_id]->frame_parms.frame_type = frame_type; } else { diff --git a/openair2/ENB_APP/flexran_agent_ran_api.h b/openair2/ENB_APP/flexran_agent_ran_api.h index 79115b0a16..c15865ccfd 100644 --- a/openair2/ENB_APP/flexran_agent_ran_api.h +++ b/openair2/ENB_APP/flexran_agent_ran_api.h @@ -433,7 +433,7 @@ void flexran_agent_set_operating_eutra_band(mid_t mod_id, uint8_t cc_id, uint8_t void flexran_agent_set_operating_bandwidth(mid_t mod_id, uint8_t cc_id, uint8_t N_RB); /*set frame type*/ -void flexran_agent_set_operating_frame_type(mid_t mod_id, uint8_t cc_id, lte_frame_type_t frame_type); +void flexran_agent_set_operating_frame_type(mid_t mod_id, uint8_t cc_id, frame_type_t frame_type); /*RRC status flexRAN*/ uint8_t flexran_get_rrc_status(mid_t mod_id, rnti_t rnti); diff --git a/openair2/F1AP/dummy_enb.c b/openair2/F1AP/dummy_enb.c index d54f9b8df7..9085fdb57c 100644 --- a/openair2/F1AP/dummy_enb.c +++ b/openair2/F1AP/dummy_enb.c @@ -32,16 +32,18 @@ void apply_macrlc_config(gNB_RRC_INST *rrc, abort(); } -boolean_t sdap_gnb_data_req(protocol_ctxt_t *ctxt_p, - const srb_flag_t srb_flag, - const rb_id_t rb_id, - const mui_t mui, - const confirm_t confirm, - const sdu_size_t sdu_buffer_size, - unsigned char *const sdu_buffer, - const pdcp_transmission_mode_t pt_mode, - const uint32_t *sourceL2Id, - const uint32_t *destinationL2Id - ) { +boolean_t sdap_data_req(protocol_ctxt_t *ctxt_p, + const srb_flag_t srb_flag, + const rb_id_t rb_id, + const mui_t mui, + const confirm_t confirm, + const sdu_size_t sdu_buffer_size, + unsigned char *const sdu_buffer, + const pdcp_transmission_mode_t pt_mode, + const uint32_t *sourceL2Id, + const uint32_t *destinationL2Id, + const uint8_t qfi, + const boolean_t rqi, + const int pdusession_id) { abort(); } diff --git a/openair2/F1AP/f1ap_du_ue_context_management.c b/openair2/F1AP/f1ap_du_ue_context_management.c index 7b20bfb2aa..e19f077592 100644 --- a/openair2/F1AP/f1ap_du_ue_context_management.c +++ b/openair2/F1AP/f1ap_du_ue_context_management.c @@ -683,15 +683,15 @@ int DU_handle_UE_CONTEXT_RELEASE_COMMAND(instance_t instance, "RNTI obtained through DU ID (%x) is different from CU ID (%x)\n", rnti, ctxt.rnti); int UE_out_of_sync = 0; - if (RC.nrrrc && RC.nrrrc[instance]->node_type == ngran_gNB_DU) { - for (int n = 0; n < MAX_MOBILES_PER_GNB; ++n) { - if (RC.nrmac[instance]->UE_info.active[n] == TRUE - && rnti == RC.nrmac[instance]->UE_info.rnti[n]) { + UE_iterator(RC.nrmac[instance]->UE_info.list, UE) { + if (UE->rnti == rnti) { UE_out_of_sync = 0; break; } } + if (!UE) + LOG_E(F1AP,"Not found rnti: %x\n", rnti); } else { for (int n = 0; n < MAX_MOBILES_PER_ENB; ++n) { if (RC.mac[instance]->UE_info.active[n] == TRUE @@ -701,7 +701,6 @@ int DU_handle_UE_CONTEXT_RELEASE_COMMAND(instance_t instance, } } } - /* We don't need the Cause */ /* Optional RRC Container: if present, send to UE */ F1AP_FIND_PROTOCOLIE_BY_ID(F1AP_UEContextReleaseCommandIEs_t, ie, container, diff --git a/openair2/GNB_APP/L1_nr_paramdef.h b/openair2/GNB_APP/L1_nr_paramdef.h index 90cd9aae29..1e5122956e 100644 --- a/openair2/GNB_APP/L1_nr_paramdef.h +++ b/openair2/GNB_APP/L1_nr_paramdef.h @@ -51,6 +51,7 @@ #define CONFIG_STRING_L1_PUCCH0_DTX_THRESHOLD "pucch0_dtx_threshold" #define CONFIG_STRING_L1_PRACH_DTX_THRESHOLD "prach_dtx_threshold" #define CONFIG_STRING_L1_PUSCH_DTX_THRESHOLD "pusch_dtx_threshold" +#define CONFIG_STRING_L1_MAX_LDPC_ITERATIONS "max_ldpc_iterations" /*----------------------------------------------------------------------------------------------------------------------------------------------------*/ /* L1 configuration parameters */ /* optname helpstr paramflags XXXptr defXXXval type numelt */ @@ -69,7 +70,8 @@ {CONFIG_STRING_L1_OFDM_OFFSET_DIVISOR, NULL, 0, uptr:NULL, defuintval:8, TYPE_UINT, 0}, \ {CONFIG_STRING_L1_PUCCH0_DTX_THRESHOLD, NULL, 0, uptr:NULL, defintval:100, TYPE_UINT, 0}, \ {CONFIG_STRING_L1_PRACH_DTX_THRESHOLD, NULL, 0, uptr:NULL, defintval:150, TYPE_UINT, 0}, \ -{CONFIG_STRING_L1_PUSCH_DTX_THRESHOLD, NULL, 0, uptr:NULL, defintval:50, TYPE_UINT, 0} \ +{CONFIG_STRING_L1_PUSCH_DTX_THRESHOLD, NULL, 0, uptr:NULL, defintval:50, TYPE_UINT, 0}, \ +{CONFIG_STRING_L1_MAX_LDPC_ITERATIONS, NULL, 0, uptr:NULL, defintval:5, TYPE_UINT, 0}, \ } #define L1_CC_IDX 0 #define L1_TRANSPORT_N_PREFERENCE_IDX 1 @@ -85,6 +87,7 @@ #define L1_PUCCH0_DTX_THRESHOLD 11 #define L1_PRACH_DTX_THRESHOLD 12 #define L1_PUSCH_DTX_THRESHOLD 13 +#define L1_MAX_LDPC_ITERATIONS 14 /*----------------------------------------------------------------------------------------------------------------------------------------------------*/ #endif diff --git a/openair2/GNB_APP/MACRLC_nr_paramdef.h b/openair2/GNB_APP/MACRLC_nr_paramdef.h index b17fced7b7..a7bc3e8545 100644 --- a/openair2/GNB_APP/MACRLC_nr_paramdef.h +++ b/openair2/GNB_APP/MACRLC_nr_paramdef.h @@ -62,8 +62,13 @@ #define CONFIG_STRING_MACRLC_PUSCHFAILURETHRES "pusch_FailureThres" #define CONFIG_STRING_MACRLC_DL_BLER_TARGET_UPPER "dl_bler_target_upper" #define CONFIG_STRING_MACRLC_DL_BLER_TARGET_LOWER "dl_bler_target_lower" -#define CONFIG_STRING_MACRLC_DL_RD2_BLER_THRESHOLD "dl_rd2_bler_threshold" #define CONFIG_STRING_MACRLC_DL_MAX_MCS "dl_max_mcs" +#define CONFIG_STRING_MACRLC_UL_BLER_TARGET_UPPER "ul_bler_target_upper" +#define CONFIG_STRING_MACRLC_UL_BLER_TARGET_LOWER "ul_bler_target_lower" +#define CONFIG_STRING_MACRLC_UL_MAX_MCS "ul_max_mcs" +#define CONFIG_STRING_MACRLC_HARQ_ROUND_MAX "harq_round_max" +#define CONFIG_STRING_MACRLC_MIN_GRANT_PRB "min_grant_prb" +#define CONFIG_STRING_MACRLC_MIN_GRANT_MCS "min_grant_mcs" /*-------------------------------------------------------------------------------------------------------------------------------------------------------*/ @@ -95,8 +100,13 @@ {CONFIG_STRING_MACRLC_PUSCHFAILURETHRES, NULL, 0, iptr:NULL, defintval:10, TYPE_INT, 0}, \ {CONFIG_STRING_MACRLC_DL_BLER_TARGET_UPPER, "Upper threshold of BLER to decrease DL MCS", 0, dblptr:NULL, defdblval:0.15, TYPE_DOUBLE, 0}, \ {CONFIG_STRING_MACRLC_DL_BLER_TARGET_LOWER, "Lower threshold of BLER to increase DL MCS", 0, dblptr:NULL, defdblval:0.05, TYPE_DOUBLE, 0}, \ -{CONFIG_STRING_MACRLC_DL_RD2_BLER_THRESHOLD, "Threshold of RD2/RETX2 BLER to decrease DL MCS", 0, dblptr:NULL, defdblval:0.01, TYPE_DOUBLE, 0}, \ {CONFIG_STRING_MACRLC_DL_MAX_MCS, "Maximum DL MCS that should be used", 0, u8ptr:NULL, defintval:28, TYPE_UINT8, 0}, \ +{CONFIG_STRING_MACRLC_UL_BLER_TARGET_UPPER, "Upper threshold of BLER to decrease UL MCS", 0, dblptr:NULL, defdblval:0.15, TYPE_DOUBLE, 0}, \ +{CONFIG_STRING_MACRLC_UL_BLER_TARGET_LOWER, "Lower threshold of BLER to increase UL MCS", 0, dblptr:NULL, defdblval:0.05, TYPE_DOUBLE, 0}, \ +{CONFIG_STRING_MACRLC_UL_MAX_MCS, "Maximum UL MCS that should be used", 0, u8ptr:NULL, defintval:9, TYPE_UINT8, 0}, \ +{CONFIG_STRING_MACRLC_HARQ_ROUND_MAX, "Maximum number of HARQ rounds", 0, u8ptr:NULL, defintval:4, TYPE_UINT8, 0}, \ +{CONFIG_STRING_MACRLC_MIN_GRANT_PRB, "Minimal Periodic ULSCH Grant PRBs", 0, u8ptr:NULL, defintval:5, TYPE_UINT8, 0}, \ +{CONFIG_STRING_MACRLC_MIN_GRANT_MCS, "Minimal Periodic ULSCH Grant MCS", 0, u8ptr:NULL, defintval:9, TYPE_UINT8, 0} \ } #define MACRLC_CC_IDX 0 #define MACRLC_TRANSPORT_N_PREFERENCE_IDX 1 @@ -122,8 +132,13 @@ #define MACRLC_PUSCHFAILURETHRES_IDX 21 #define MACRLC_DL_BLER_TARGET_UPPER_IDX 22 #define MACRLC_DL_BLER_TARGET_LOWER_IDX 23 -#define MACRLC_DL_RD2_BLER_THRESHOLD_IDX 24 -#define MACRLC_DL_MAX_MCS_IDX 25 +#define MACRLC_DL_MAX_MCS_IDX 24 +#define MACRLC_UL_BLER_TARGET_UPPER_IDX 25 +#define MACRLC_UL_BLER_TARGET_LOWER_IDX 26 +#define MACRLC_UL_MAX_MCS_IDX 27 +#define MACRLC_HARQ_ROUND_MAX_IDX 28 +#define MACRLC_MIN_GRANT_PRB_IDX 29 +#define MACRLC_MIN_GRANT_MCS_IDX 30 /*---------------------------------------------------------------------------------------------------------------------------------------------------------*/ #endif diff --git a/openair2/GNB_APP/RRC_nr_paramsvalues.h b/openair2/GNB_APP/RRC_nr_paramsvalues.h index 8a7ce64d91..089569f84e 100644 --- a/openair2/GNB_APP/RRC_nr_paramsvalues.h +++ b/openair2/GNB_APP/RRC_nr_paramsvalues.h @@ -132,6 +132,34 @@ #define GNB_CONFIG_STRING_ULPTRSMAXPORTS_0 "ul_ptrsMaxPorts_0" #define GNB_CONFIG_STRING_ULPTRSPOWER_0 "ul_ptrsPower_0" +#define GNB_CONFIG_STRING_DLBWP1_ID "dl_bwp-Id_1" +#define GNB_CONFIG_STRING_DLBWP2_ID "dl_bwp-Id_2" +#define GNB_CONFIG_STRING_DLBWP3_ID "dl_bwp-Id_3" +#define GNB_CONFIG_STRING_DLBWP4_ID "dl_bwp-Id_4" +#define GNB_CONFIG_STRING_LOCATIONANDBANDWIDTH_DLBWP1 "dl_bwp1_locationAndBandwidth" +#define GNB_CONFIG_STRING_LOCATIONANDBANDWIDTH_DLBWP2 "dl_bwp2_locationAndBandwidth" +#define GNB_CONFIG_STRING_LOCATIONANDBANDWIDTH_DLBWP3 "dl_bwp3_locationAndBandwidth" +#define GNB_CONFIG_STRING_LOCATIONANDBANDWIDTH_DLBWP4 "dl_bwp4_locationAndBandwidth" +#define GNB_CONFIG_STRING_SCS_DLBWP1 "dl_bwp1_subcarrierSpacing" +#define GNB_CONFIG_STRING_SCS_DLBWP2 "dl_bwp2_subcarrierSpacing" +#define GNB_CONFIG_STRING_SCS_DLBWP3 "dl_bwp3_subcarrierSpacing" +#define GNB_CONFIG_STRING_SCS_DLBWP4 "dl_bwp4_subcarrierSpacing" +#define GNB_CONFIG_STRING_FIRSTACTIVEDLBWP_ID "firstActiveDownlinkBWP-Id" +#define GNB_CONFIG_STRING_DEFAULTDLBWP_ID "defaultDownlinkBWP-Id" +#define GNB_CONFIG_STRING_ULBWP1_ID "ul_bwp-Id_1" +#define GNB_CONFIG_STRING_ULBWP2_ID "ul_bwp-Id_2" +#define GNB_CONFIG_STRING_ULBWP3_ID "ul_bwp-Id_3" +#define GNB_CONFIG_STRING_ULBWP4_ID "ul_bwp-Id_4" +#define GNB_CONFIG_STRING_LOCATIONANDBANDWIDTH_ULBWP1 "ul_bwp1_locationAndBandwidth" +#define GNB_CONFIG_STRING_LOCATIONANDBANDWIDTH_ULBWP2 "ul_bwp2_locationAndBandwidth" +#define GNB_CONFIG_STRING_LOCATIONANDBANDWIDTH_ULBWP3 "ul_bwp3_locationAndBandwidth" +#define GNB_CONFIG_STRING_LOCATIONANDBANDWIDTH_ULBWP4 "ul_bwp4_locationAndBandwidth" +#define GNB_CONFIG_STRING_SCS_ULBWP1 "ul_bwp1_subcarrierSpacing" +#define GNB_CONFIG_STRING_SCS_ULBWP2 "ul_bwp2_subcarrierSpacing" +#define GNB_CONFIG_STRING_SCS_ULBWP3 "ul_bwp3_subcarrierSpacing" +#define GNB_CONFIG_STRING_SCS_ULBWP4 "ul_bwp4_subcarrierSpacing" +#define GNB_CONFIG_STRING_FIRSTACTIVEULBWP_ID "firstActiveUplinkBWP-Id" + /*--------------------------------------------------------------------------------------------------------------------*/ /* pdcch_ConfigSIB1 parameters */ /*--------------------------------------------------------------------------------------------------------------------*/ @@ -240,10 +268,33 @@ {GNB_CONFIG_STRING_ULPTRSTIMEDENSITY2_0,NULL,0,i64ptr:scd->uplinkConfig->uplinkBWP_ToAddModList->list.array[0]->bwp_Dedicated->pusch_Config->choice.setup->dmrs_UplinkForPUSCH_MappingTypeB->choice.setup->phaseTrackingRS->choice.setup->transformPrecoderDisabled->timeDensity->list.array[2],defint64val:-1,TYPE_INT64,0}, \ {GNB_CONFIG_STRING_ULPTRSREOFFSET_0,NULL,0,i64ptr:scd->uplinkConfig->uplinkBWP_ToAddModList->list.array[0]->bwp_Dedicated->pusch_Config->choice.setup->dmrs_UplinkForPUSCH_MappingTypeB->choice.setup->phaseTrackingRS->choice.setup->transformPrecoderDisabled->resourceElementOffset,defint64val:-1,TYPE_INT64,0}, \ {GNB_CONFIG_STRING_ULPTRSMAXPORTS_0,NULL,0,i64ptr:&scd->uplinkConfig->uplinkBWP_ToAddModList->list.array[0]->bwp_Dedicated->pusch_Config->choice.setup->dmrs_UplinkForPUSCH_MappingTypeB->choice.setup->phaseTrackingRS->choice.setup->transformPrecoderDisabled->maxNrofPorts,defint64val:0,TYPE_INT64,0}, \ -{GNB_CONFIG_STRING_ULPTRSPOWER_0,NULL,0,i64ptr:&scd->uplinkConfig->uplinkBWP_ToAddModList->list.array[0]->bwp_Dedicated->pusch_Config->choice.setup->dmrs_UplinkForPUSCH_MappingTypeB->choice.setup->phaseTrackingRS->choice.setup->transformPrecoderDisabled->ptrs_Power,defint64val:0,TYPE_INT64,0}} - - - - +{GNB_CONFIG_STRING_ULPTRSPOWER_0,NULL,0,i64ptr:&scd->uplinkConfig->uplinkBWP_ToAddModList->list.array[0]->bwp_Dedicated->pusch_Config->choice.setup->dmrs_UplinkForPUSCH_MappingTypeB->choice.setup->phaseTrackingRS->choice.setup->transformPrecoderDisabled->ptrs_Power,defint64val:0,TYPE_INT64,0}, \ +{GNB_CONFIG_STRING_FIRSTACTIVEDLBWP_ID,NULL,0,i64ptr:scd->firstActiveDownlinkBWP_Id,defint64val:1,TYPE_INT64,0}, \ +{GNB_CONFIG_STRING_FIRSTACTIVEULBWP_ID,NULL,0,i64ptr:scd->uplinkConfig->firstActiveUplinkBWP_Id,defint64val:1,TYPE_INT64,0}, \ +{GNB_CONFIG_STRING_DLBWP1_ID,NULL,0,i64ptr:&scd->downlinkBWP_ToAddModList->list.array[0]->bwp_Id,defint64val:1,TYPE_INT64,0}, \ +{GNB_CONFIG_STRING_DLBWP2_ID,NULL,0,i64ptr:&scd->downlinkBWP_ToAddModList->list.array[1]->bwp_Id,defint64val:2,TYPE_INT64,0}, \ +{GNB_CONFIG_STRING_DLBWP3_ID,NULL,0,i64ptr:&scd->downlinkBWP_ToAddModList->list.array[2]->bwp_Id,defint64val:3,TYPE_INT64,0}, \ +{GNB_CONFIG_STRING_DLBWP4_ID,NULL,0,i64ptr:&scd->downlinkBWP_ToAddModList->list.array[3]->bwp_Id,defint64val:4,TYPE_INT64,0}, \ +{GNB_CONFIG_STRING_SCS_DLBWP1,NULL,0,i64ptr:&scd->downlinkBWP_ToAddModList->list.array[0]->bwp_Common->genericParameters.subcarrierSpacing,defint64val:1,TYPE_INT64,0}, \ +{GNB_CONFIG_STRING_SCS_DLBWP2,NULL,0,i64ptr:&scd->downlinkBWP_ToAddModList->list.array[1]->bwp_Common->genericParameters.subcarrierSpacing,defint64val:1,TYPE_INT64,0}, \ +{GNB_CONFIG_STRING_SCS_DLBWP3,NULL,0,i64ptr:&scd->downlinkBWP_ToAddModList->list.array[2]->bwp_Common->genericParameters.subcarrierSpacing,defint64val:1,TYPE_INT64,0}, \ +{GNB_CONFIG_STRING_SCS_DLBWP4,NULL,0,i64ptr:&scd->downlinkBWP_ToAddModList->list.array[3]->bwp_Common->genericParameters.subcarrierSpacing,defint64val:1,TYPE_INT64,0}, \ +{GNB_CONFIG_STRING_LOCATIONANDBANDWIDTH_DLBWP1,NULL,0,i64ptr:&scd->downlinkBWP_ToAddModList->list.array[0]->bwp_Common->genericParameters.locationAndBandwidth,defint64val:0,TYPE_INT64,0}, \ +{GNB_CONFIG_STRING_LOCATIONANDBANDWIDTH_DLBWP2,NULL,0,i64ptr:&scd->downlinkBWP_ToAddModList->list.array[1]->bwp_Common->genericParameters.locationAndBandwidth,defint64val:0,TYPE_INT64,0}, \ +{GNB_CONFIG_STRING_LOCATIONANDBANDWIDTH_DLBWP3,NULL,0,i64ptr:&scd->downlinkBWP_ToAddModList->list.array[2]->bwp_Common->genericParameters.locationAndBandwidth,defint64val:0,TYPE_INT64,0}, \ +{GNB_CONFIG_STRING_LOCATIONANDBANDWIDTH_DLBWP4,NULL,0,i64ptr:&scd->downlinkBWP_ToAddModList->list.array[3]->bwp_Common->genericParameters.locationAndBandwidth,defint64val:0,TYPE_INT64,0}, \ +{GNB_CONFIG_STRING_ULBWP1_ID,NULL,0,i64ptr:&scd->uplinkConfig->uplinkBWP_ToAddModList->list.array[0]->bwp_Id,defint64val:1,TYPE_INT64,0}, \ +{GNB_CONFIG_STRING_ULBWP2_ID,NULL,0,i64ptr:&scd->uplinkConfig->uplinkBWP_ToAddModList->list.array[1]->bwp_Id,defint64val:2,TYPE_INT64,0}, \ +{GNB_CONFIG_STRING_ULBWP3_ID,NULL,0,i64ptr:&scd->uplinkConfig->uplinkBWP_ToAddModList->list.array[2]->bwp_Id,defint64val:3,TYPE_INT64,0}, \ +{GNB_CONFIG_STRING_ULBWP4_ID,NULL,0,i64ptr:&scd->uplinkConfig->uplinkBWP_ToAddModList->list.array[3]->bwp_Id,defint64val:4,TYPE_INT64,0}, \ +{GNB_CONFIG_STRING_SCS_ULBWP1,NULL,0,i64ptr:&scd->uplinkConfig->uplinkBWP_ToAddModList->list.array[0]->bwp_Common->genericParameters.subcarrierSpacing,defint64val:1,TYPE_INT64,0}, \ +{GNB_CONFIG_STRING_SCS_ULBWP2,NULL,0,i64ptr:&scd->uplinkConfig->uplinkBWP_ToAddModList->list.array[1]->bwp_Common->genericParameters.subcarrierSpacing,defint64val:1,TYPE_INT64,0}, \ +{GNB_CONFIG_STRING_SCS_ULBWP3,NULL,0,i64ptr:&scd->uplinkConfig->uplinkBWP_ToAddModList->list.array[2]->bwp_Common->genericParameters.subcarrierSpacing,defint64val:1,TYPE_INT64,0}, \ +{GNB_CONFIG_STRING_SCS_ULBWP4,NULL,0,i64ptr:&scd->uplinkConfig->uplinkBWP_ToAddModList->list.array[3]->bwp_Common->genericParameters.subcarrierSpacing,defint64val:1,TYPE_INT64,0}, \ +{GNB_CONFIG_STRING_LOCATIONANDBANDWIDTH_ULBWP1,NULL,0,i64ptr:&scd->uplinkConfig->uplinkBWP_ToAddModList->list.array[0]->bwp_Common->genericParameters.locationAndBandwidth,defint64val:0,TYPE_INT64,0}, \ +{GNB_CONFIG_STRING_LOCATIONANDBANDWIDTH_ULBWP2,NULL,0,i64ptr:&scd->uplinkConfig->uplinkBWP_ToAddModList->list.array[1]->bwp_Common->genericParameters.locationAndBandwidth,defint64val:0,TYPE_INT64,0}, \ +{GNB_CONFIG_STRING_LOCATIONANDBANDWIDTH_ULBWP3,NULL,0,i64ptr:&scd->uplinkConfig->uplinkBWP_ToAddModList->list.array[2]->bwp_Common->genericParameters.locationAndBandwidth,defint64val:0,TYPE_INT64,0}, \ +{GNB_CONFIG_STRING_LOCATIONANDBANDWIDTH_ULBWP4,NULL,0,i64ptr:&scd->uplinkConfig->uplinkBWP_ToAddModList->list.array[3]->bwp_Common->genericParameters.locationAndBandwidth,defint64val:0,TYPE_INT64,0}, \ +{GNB_CONFIG_STRING_DEFAULTDLBWP_ID,NULL,0,i64ptr:scd->defaultDownlinkBWP_Id,defint64val:0,TYPE_INT64,0}} #endif diff --git a/openair2/GNB_APP/gnb_config.c b/openair2/GNB_APP/gnb_config.c index 2795c07ce7..21655a74d5 100644 --- a/openair2/GNB_APP/gnb_config.c +++ b/openair2/GNB_APP/gnb_config.c @@ -213,15 +213,20 @@ void fill_scc_sim(NR_ServingCellConfigCommon_t *scc,uint64_t *ssb_bitmap,int N_R // *scc->n_TimingAdvanceOffset=NR_ServingCellConfigCommon__n_TimingAdvanceOffset_n0; *scc->ssb_periodicityServingCell=NR_ServingCellConfigCommon__ssb_periodicityServingCell_ms20; scc->dmrs_TypeA_Position=NR_ServingCellConfigCommon__dmrs_TypeA_Position_pos2; - *scc->ssbSubcarrierSpacing=NR_SubcarrierSpacing_kHz30; - *scc->downlinkConfigCommon->frequencyInfoDL->absoluteFrequencySSB=641032; - *scc->downlinkConfigCommon->frequencyInfoDL->frequencyBandList.list.array[0]=78; - scc->downlinkConfigCommon->frequencyInfoDL->absoluteFrequencyPointA=640000; + *scc->ssbSubcarrierSpacing=mu_dl; + if (mu_dl == 0) { + *scc->downlinkConfigCommon->frequencyInfoDL->absoluteFrequencySSB=520432; + *scc->downlinkConfigCommon->frequencyInfoDL->frequencyBandList.list.array[0]=38; + scc->downlinkConfigCommon->frequencyInfoDL->absoluteFrequencyPointA=520000; + } else { + *scc->downlinkConfigCommon->frequencyInfoDL->absoluteFrequencySSB=641032; + *scc->downlinkConfigCommon->frequencyInfoDL->frequencyBandList.list.array[0]=78; + scc->downlinkConfigCommon->frequencyInfoDL->absoluteFrequencyPointA=640000; + } scc->downlinkConfigCommon->frequencyInfoDL->scs_SpecificCarrierList.list.array[0]->offsetToCarrier=0; - scc->downlinkConfigCommon->frequencyInfoDL->scs_SpecificCarrierList.list.array[0]->subcarrierSpacing=NR_SubcarrierSpacing_kHz30; - + scc->downlinkConfigCommon->frequencyInfoDL->scs_SpecificCarrierList.list.array[0]->subcarrierSpacing=mu_dl; scc->downlinkConfigCommon->frequencyInfoDL->scs_SpecificCarrierList.list.array[0]->carrierBandwidth=N_RB_DL; - scc->downlinkConfigCommon->initialDownlinkBWP->genericParameters.locationAndBandwidth=13036; + scc->downlinkConfigCommon->initialDownlinkBWP->genericParameters.locationAndBandwidth=275*(N_RB_DL-1); scc->downlinkConfigCommon->initialDownlinkBWP->genericParameters.subcarrierSpacing=mu_dl;//NR_SubcarrierSpacing_kHz30; *scc->downlinkConfigCommon->initialDownlinkBWP->pdcch_ConfigCommon->choice.setup->controlResourceSetZero=12; *scc->downlinkConfigCommon->initialDownlinkBWP->pdcch_ConfigCommon->choice.setup->searchSpaceZero=0; @@ -235,13 +240,13 @@ void fill_scc_sim(NR_ServingCellConfigCommon_t *scc,uint64_t *ssb_bitmap,int N_R timedomainresourceallocation1->startSymbolAndLength=57; ASN_SEQUENCE_ADD(&scc->downlinkConfigCommon->initialDownlinkBWP->pdsch_ConfigCommon->choice.setup->pdsch_TimeDomainAllocationList->list, timedomainresourceallocation1); - *scc->uplinkConfigCommon->frequencyInfoUL->frequencyBandList->list.array[0]=78; + *scc->uplinkConfigCommon->frequencyInfoUL->frequencyBandList->list.array[0]=mu_ul?78:38; *scc->uplinkConfigCommon->frequencyInfoUL->absoluteFrequencyPointA=-1; scc->uplinkConfigCommon->frequencyInfoUL->scs_SpecificCarrierList.list.array[0]->offsetToCarrier=0; - scc->uplinkConfigCommon->frequencyInfoUL->scs_SpecificCarrierList.list.array[0]->subcarrierSpacing=NR_SubcarrierSpacing_kHz30; + scc->uplinkConfigCommon->frequencyInfoUL->scs_SpecificCarrierList.list.array[0]->subcarrierSpacing=mu_ul; scc->uplinkConfigCommon->frequencyInfoUL->scs_SpecificCarrierList.list.array[0]->carrierBandwidth=N_RB_UL; *scc->uplinkConfigCommon->frequencyInfoUL->p_Max=20; - scc->uplinkConfigCommon->initialUplinkBWP->genericParameters.locationAndBandwidth=13036; + scc->uplinkConfigCommon->initialUplinkBWP->genericParameters.locationAndBandwidth=275*(N_RB_UL-1); scc->uplinkConfigCommon->initialUplinkBWP->genericParameters.subcarrierSpacing=mu_ul;//NR_SubcarrierSpacing_kHz30; scc->uplinkConfigCommon->initialUplinkBWP->rach_ConfigCommon->choice.setup->rach_ConfigGeneric.prach_ConfigurationIndex=98; scc->uplinkConfigCommon->initialUplinkBWP->rach_ConfigCommon->choice.setup->rach_ConfigGeneric.msg1_FDM=NR_RACH_ConfigGeneric__msg1_FDM_one; @@ -277,8 +282,11 @@ void fill_scc_sim(NR_ServingCellConfigCommon_t *scc,uint64_t *ssb_bitmap,int N_R *scc->uplinkConfigCommon->initialUplinkBWP->pucch_ConfigCommon->choice.setup->p0_nominal=-90; scc->ssb_PositionsInBurst->present=NR_ServingCellConfigCommon__ssb_PositionsInBurst_PR_mediumBitmap; *ssb_bitmap=0xff; - scc->tdd_UL_DL_ConfigurationCommon->referenceSubcarrierSpacing=NR_SubcarrierSpacing_kHz30; - scc->tdd_UL_DL_ConfigurationCommon->pattern1.dl_UL_TransmissionPeriodicity=NR_TDD_UL_DL_Pattern__dl_UL_TransmissionPeriodicity_ms5; + scc->tdd_UL_DL_ConfigurationCommon->referenceSubcarrierSpacing=mu_dl; + if (mu_dl == 0) + scc->tdd_UL_DL_ConfigurationCommon->pattern1.dl_UL_TransmissionPeriodicity=NR_TDD_UL_DL_Pattern__dl_UL_TransmissionPeriodicity_ms10; + else + scc->tdd_UL_DL_ConfigurationCommon->pattern1.dl_UL_TransmissionPeriodicity=NR_TDD_UL_DL_Pattern__dl_UL_TransmissionPeriodicity_ms5; scc->tdd_UL_DL_ConfigurationCommon->pattern1.nrofDownlinkSlots=7; scc->tdd_UL_DL_ConfigurationCommon->pattern1.nrofDownlinkSymbols=6; scc->tdd_UL_DL_ConfigurationCommon->pattern1.nrofUplinkSlots=2; @@ -343,10 +351,12 @@ void fix_scc(NR_ServingCellConfigCommon_t *scc,uint64_t ssbmap) { if (*scc->uplinkConfigCommon->initialUplinkBWP->rach_ConfigCommon->choice.setup->msg3_transformPrecoder!=0) scc->uplinkConfigCommon->initialUplinkBWP->rach_ConfigCommon->choice.setup->msg3_transformPrecoder = NULL; - // prepare DL Allocation lists - nr_rrc_config_dl_tda(scc); + // Prepare PDSCH-TimeDomainResourceAllocation list + nr_rrc_config_dl_tda(scc, + scc->downlinkConfigCommon->initialDownlinkBWP->pdsch_ConfigCommon->choice.setup->pdsch_TimeDomainAllocationList, + scc->downlinkConfigCommon->frequencyInfoDL->scs_SpecificCarrierList.list.array[0]->carrierBandwidth); - lte_frame_type_t frame_type = get_frame_type((int)*scc->downlinkConfigCommon->frequencyInfoDL->frequencyBandList.list.array[0], *scc->ssbSubcarrierSpacing); + frame_type_t frame_type = get_frame_type((int)*scc->downlinkConfigCommon->frequencyInfoDL->frequencyBandList.list.array[0], *scc->ssbSubcarrierSpacing); if (frame_type == FDD) { ASN_STRUCT_FREE(asn_DEF_NR_TDD_UL_DL_ConfigCommon, scc->tdd_UL_DL_ConfigurationCommon); scc->tdd_UL_DL_ConfigurationCommon = NULL; @@ -371,157 +381,204 @@ void fix_scc(NR_ServingCellConfigCommon_t *scc,uint64_t ssbmap) { /* Function to allocate dedicated serving cell config strutures */ void prepare_scd(NR_ServingCellConfig_t *scd) { // Allocate downlink structures - scd->downlinkBWP_ToAddModList = CALLOC(1, sizeof(*scd->downlinkBWP_ToAddModList)); - - // Downlink bandwidth part - NR_BWP_Downlink_t *bwp = calloc(1, sizeof(*bwp)); - bwp->bwp_Id = 1; - - // Allocate downlink dedicated bandwidth part and PDSCH structures - bwp->bwp_Dedicated = calloc(1, sizeof(*bwp->bwp_Dedicated)); - bwp->bwp_Dedicated->pdsch_Config = calloc(1, sizeof(*bwp->bwp_Dedicated->pdsch_Config)); - bwp->bwp_Dedicated->pdsch_Config->present = NR_SetupRelease_PDSCH_Config_PR_setup; - bwp->bwp_Dedicated->pdsch_Config->choice.setup = calloc(1, sizeof(*bwp->bwp_Dedicated->pdsch_Config->choice.setup)); - bwp->bwp_Dedicated->pdsch_Config->choice.setup->dmrs_DownlinkForPDSCH_MappingTypeA = calloc(1, sizeof(*bwp->bwp_Dedicated->pdsch_Config->choice.setup->dmrs_DownlinkForPDSCH_MappingTypeA)); - bwp->bwp_Dedicated->pdsch_Config->choice.setup->dmrs_DownlinkForPDSCH_MappingTypeA->present = NR_SetupRelease_DMRS_DownlinkConfig_PR_setup; - - // Allocate DL DMRS and PTRS configuration - bwp->bwp_Dedicated->pdsch_Config->choice.setup->dmrs_DownlinkForPDSCH_MappingTypeA->choice.setup = calloc(1, sizeof(*bwp->bwp_Dedicated->pdsch_Config->choice.setup->dmrs_DownlinkForPDSCH_MappingTypeA->choice.setup)); - NR_DMRS_DownlinkConfig_t *NR_DMRS_DownlinkCfg = bwp->bwp_Dedicated->pdsch_Config->choice.setup->dmrs_DownlinkForPDSCH_MappingTypeA->choice.setup; - NR_DMRS_DownlinkCfg->phaseTrackingRS=CALLOC(1, sizeof(*NR_DMRS_DownlinkCfg->phaseTrackingRS)); - NR_DMRS_DownlinkCfg->phaseTrackingRS->present = NR_SetupRelease_PTRS_DownlinkConfig_PR_setup; - NR_DMRS_DownlinkCfg->phaseTrackingRS->choice.setup = CALLOC(1, sizeof(*NR_DMRS_DownlinkCfg->phaseTrackingRS->choice.setup)); - NR_PTRS_DownlinkConfig_t *NR_PTRS_DownlinkCfg = NR_DMRS_DownlinkCfg->phaseTrackingRS->choice.setup; - NR_PTRS_DownlinkCfg->frequencyDensity = CALLOC(1, sizeof(*NR_PTRS_DownlinkCfg->frequencyDensity)); - long *dl_rbs = CALLOC(2, sizeof(long)); - for (int i=0;i<2;i++) { - ASN_SEQUENCE_ADD(&NR_PTRS_DownlinkCfg->frequencyDensity->list, &dl_rbs[i]); - } - NR_PTRS_DownlinkCfg->timeDensity = CALLOC(1, sizeof(*NR_PTRS_DownlinkCfg->timeDensity)); - long *dl_mcs = CALLOC(3, sizeof(long)); - for (int i=0;i<3;i++) { - ASN_SEQUENCE_ADD(&NR_PTRS_DownlinkCfg->timeDensity->list, &dl_mcs[i]); - } - NR_PTRS_DownlinkCfg->epre_Ratio = CALLOC(1, sizeof(*NR_PTRS_DownlinkCfg->epre_Ratio)); - NR_PTRS_DownlinkCfg->resourceElementOffset = CALLOC(1, sizeof(*NR_PTRS_DownlinkCfg->resourceElementOffset)); - *NR_PTRS_DownlinkCfg->resourceElementOffset = 0; - ASN_SEQUENCE_ADD(&scd->downlinkBWP_ToAddModList->list,bwp); - - // Allocate uplink structures - scd->uplinkConfig = CALLOC(1, sizeof(*scd->uplinkConfig)); scd->uplinkConfig->uplinkBWP_ToAddModList = CALLOC(1, sizeof(*scd->uplinkConfig->uplinkBWP_ToAddModList)); + scd->bwp_InactivityTimer = CALLOC(1, sizeof(*scd->bwp_InactivityTimer)); + scd->uplinkConfig->firstActiveUplinkBWP_Id = CALLOC(1, sizeof(*scd->uplinkConfig->firstActiveUplinkBWP_Id)); + scd->firstActiveDownlinkBWP_Id = CALLOC(1, sizeof(*scd->firstActiveDownlinkBWP_Id)); + *scd->firstActiveDownlinkBWP_Id = 1; + *scd->uplinkConfig->firstActiveUplinkBWP_Id = 1; + scd->defaultDownlinkBWP_Id = CALLOC(1, sizeof(*scd->defaultDownlinkBWP_Id)); + *scd->defaultDownlinkBWP_Id = 0; - NR_PUSCH_Config_t *pusch_Config = CALLOC(1, sizeof(*pusch_Config)); + for (int j = 0; j < NR_MAX_NUM_BWP; j++) { - // Allocate UL DMRS and PTRS structures - pusch_Config->dmrs_UplinkForPUSCH_MappingTypeB = CALLOC(1, sizeof(*pusch_Config->dmrs_UplinkForPUSCH_MappingTypeB)); - pusch_Config->dmrs_UplinkForPUSCH_MappingTypeB->present = NR_SetupRelease_DMRS_UplinkConfig_PR_setup; - pusch_Config->dmrs_UplinkForPUSCH_MappingTypeB->choice.setup = CALLOC(1, sizeof(*pusch_Config->dmrs_UplinkForPUSCH_MappingTypeB->choice.setup)); - NR_DMRS_UplinkConfig_t *NR_DMRS_UplinkConfig = pusch_Config->dmrs_UplinkForPUSCH_MappingTypeB->choice.setup; - NR_DMRS_UplinkConfig->phaseTrackingRS = CALLOC(1, sizeof(*NR_DMRS_UplinkConfig->phaseTrackingRS)); - NR_DMRS_UplinkConfig->phaseTrackingRS->present = NR_SetupRelease_PTRS_UplinkConfig_PR_setup; - NR_DMRS_UplinkConfig->phaseTrackingRS->choice.setup = CALLOC(1, sizeof(*NR_DMRS_UplinkConfig->phaseTrackingRS->choice.setup)); - NR_PTRS_UplinkConfig_t *NR_PTRS_UplinkConfig = NR_DMRS_UplinkConfig->phaseTrackingRS->choice.setup; - NR_PTRS_UplinkConfig->transformPrecoderDisabled = CALLOC(1, sizeof(*NR_PTRS_UplinkConfig->transformPrecoderDisabled)); - NR_PTRS_UplinkConfig->transformPrecoderDisabled->frequencyDensity = CALLOC(1, sizeof(*NR_PTRS_UplinkConfig->transformPrecoderDisabled->frequencyDensity)); - long *n_rbs = CALLOC(2, sizeof(long)); - for (int i=0;i<2;i++) { - ASN_SEQUENCE_ADD(&NR_PTRS_UplinkConfig->transformPrecoderDisabled->frequencyDensity->list, &n_rbs[i]); + // Downlink bandwidth part + NR_BWP_Downlink_t *bwp = calloc(1, sizeof(*bwp)); + bwp->bwp_Id = j+1; + + // Allocate downlink dedicated bandwidth part and PDSCH structures + bwp->bwp_Common = calloc(1, sizeof(*bwp->bwp_Common)); + bwp->bwp_Common->pdcch_ConfigCommon = calloc(1, sizeof(*bwp->bwp_Common->pdcch_ConfigCommon)); + bwp->bwp_Common->pdsch_ConfigCommon = calloc(1, sizeof(*bwp->bwp_Common->pdsch_ConfigCommon)); + bwp->bwp_Dedicated = calloc(1, sizeof(*bwp->bwp_Dedicated)); + bwp->bwp_Dedicated->pdsch_Config = calloc(1, sizeof(*bwp->bwp_Dedicated->pdsch_Config)); + bwp->bwp_Dedicated->pdsch_Config->present = NR_SetupRelease_PDSCH_Config_PR_setup; + bwp->bwp_Dedicated->pdsch_Config->choice.setup = calloc(1, sizeof(*bwp->bwp_Dedicated->pdsch_Config->choice.setup)); + bwp->bwp_Dedicated->pdsch_Config->choice.setup->dmrs_DownlinkForPDSCH_MappingTypeA = calloc(1, sizeof(*bwp->bwp_Dedicated->pdsch_Config->choice.setup->dmrs_DownlinkForPDSCH_MappingTypeA)); + bwp->bwp_Dedicated->pdsch_Config->choice.setup->dmrs_DownlinkForPDSCH_MappingTypeA->present = NR_SetupRelease_DMRS_DownlinkConfig_PR_setup; + + // Allocate DL DMRS and PTRS configuration + bwp->bwp_Dedicated->pdsch_Config->choice.setup->dmrs_DownlinkForPDSCH_MappingTypeA->choice.setup = calloc(1, sizeof(*bwp->bwp_Dedicated->pdsch_Config->choice.setup->dmrs_DownlinkForPDSCH_MappingTypeA->choice.setup)); + NR_DMRS_DownlinkConfig_t *NR_DMRS_DownlinkCfg = bwp->bwp_Dedicated->pdsch_Config->choice.setup->dmrs_DownlinkForPDSCH_MappingTypeA->choice.setup; + NR_DMRS_DownlinkCfg->phaseTrackingRS=CALLOC(1, sizeof(*NR_DMRS_DownlinkCfg->phaseTrackingRS)); + NR_DMRS_DownlinkCfg->phaseTrackingRS->present = NR_SetupRelease_PTRS_DownlinkConfig_PR_setup; + NR_DMRS_DownlinkCfg->phaseTrackingRS->choice.setup = CALLOC(1, sizeof(*NR_DMRS_DownlinkCfg->phaseTrackingRS->choice.setup)); + NR_PTRS_DownlinkConfig_t *NR_PTRS_DownlinkCfg = NR_DMRS_DownlinkCfg->phaseTrackingRS->choice.setup; + NR_PTRS_DownlinkCfg->frequencyDensity = CALLOC(1, sizeof(*NR_PTRS_DownlinkCfg->frequencyDensity)); + long *dl_rbs = CALLOC(2, sizeof(long)); + for (int i=0;i<2;i++) { + ASN_SEQUENCE_ADD(&NR_PTRS_DownlinkCfg->frequencyDensity->list, &dl_rbs[i]); + } + NR_PTRS_DownlinkCfg->timeDensity = CALLOC(1, sizeof(*NR_PTRS_DownlinkCfg->timeDensity)); + long *dl_mcs = CALLOC(3, sizeof(long)); + for (int i=0;i<3;i++) { + ASN_SEQUENCE_ADD(&NR_PTRS_DownlinkCfg->timeDensity->list, &dl_mcs[i]); + } + NR_PTRS_DownlinkCfg->epre_Ratio = CALLOC(1, sizeof(*NR_PTRS_DownlinkCfg->epre_Ratio)); + NR_PTRS_DownlinkCfg->resourceElementOffset = CALLOC(1, sizeof(*NR_PTRS_DownlinkCfg->resourceElementOffset)); + *NR_PTRS_DownlinkCfg->resourceElementOffset = 0; + ASN_SEQUENCE_ADD(&scd->downlinkBWP_ToAddModList->list,bwp); + + // Allocate uplink structures + + NR_PUSCH_Config_t *pusch_Config = CALLOC(1, sizeof(*pusch_Config)); + + // Allocate UL DMRS and PTRS structures + pusch_Config->dmrs_UplinkForPUSCH_MappingTypeB = CALLOC(1, sizeof(*pusch_Config->dmrs_UplinkForPUSCH_MappingTypeB)); + pusch_Config->dmrs_UplinkForPUSCH_MappingTypeB->present = NR_SetupRelease_DMRS_UplinkConfig_PR_setup; + pusch_Config->dmrs_UplinkForPUSCH_MappingTypeB->choice.setup = CALLOC(1, sizeof(*pusch_Config->dmrs_UplinkForPUSCH_MappingTypeB->choice.setup)); + NR_DMRS_UplinkConfig_t *NR_DMRS_UplinkConfig = pusch_Config->dmrs_UplinkForPUSCH_MappingTypeB->choice.setup; + NR_DMRS_UplinkConfig->phaseTrackingRS = CALLOC(1, sizeof(*NR_DMRS_UplinkConfig->phaseTrackingRS)); + NR_DMRS_UplinkConfig->phaseTrackingRS->present = NR_SetupRelease_PTRS_UplinkConfig_PR_setup; + NR_DMRS_UplinkConfig->phaseTrackingRS->choice.setup = CALLOC(1, sizeof(*NR_DMRS_UplinkConfig->phaseTrackingRS->choice.setup)); + NR_PTRS_UplinkConfig_t *NR_PTRS_UplinkConfig = NR_DMRS_UplinkConfig->phaseTrackingRS->choice.setup; + NR_PTRS_UplinkConfig->transformPrecoderDisabled = CALLOC(1, sizeof(*NR_PTRS_UplinkConfig->transformPrecoderDisabled)); + NR_PTRS_UplinkConfig->transformPrecoderDisabled->frequencyDensity = CALLOC(1, sizeof(*NR_PTRS_UplinkConfig->transformPrecoderDisabled->frequencyDensity)); + long *n_rbs = CALLOC(2, sizeof(long)); + for (int i=0;i<2;i++) { + ASN_SEQUENCE_ADD(&NR_PTRS_UplinkConfig->transformPrecoderDisabled->frequencyDensity->list, &n_rbs[i]); + } + NR_PTRS_UplinkConfig->transformPrecoderDisabled->timeDensity = CALLOC(1, sizeof(*NR_PTRS_UplinkConfig->transformPrecoderDisabled->timeDensity)); + long *ptrs_mcs = CALLOC(3, sizeof(long)); + for (int i = 0; i < 3; i++) { + ASN_SEQUENCE_ADD(&NR_PTRS_UplinkConfig->transformPrecoderDisabled->timeDensity->list, &ptrs_mcs[i]); + } + NR_PTRS_UplinkConfig->transformPrecoderDisabled->resourceElementOffset = CALLOC(1, sizeof(*NR_PTRS_UplinkConfig->transformPrecoderDisabled->resourceElementOffset)); + *NR_PTRS_UplinkConfig->transformPrecoderDisabled->resourceElementOffset = 0; + + // UL bandwidth part + NR_BWP_Uplink_t *ubwp = CALLOC(1, sizeof(*ubwp)); + ubwp->bwp_Id = j+1; + ubwp->bwp_Common = CALLOC(1, sizeof(*ubwp->bwp_Common)); + ubwp->bwp_Dedicated = CALLOC(1, sizeof(*ubwp->bwp_Dedicated)); + + ubwp->bwp_Dedicated->pusch_Config = CALLOC(1, sizeof(*ubwp->bwp_Dedicated->pusch_Config)); + ubwp->bwp_Dedicated->pusch_Config->present = NR_SetupRelease_PUSCH_Config_PR_setup; + ubwp->bwp_Dedicated->pusch_Config->choice.setup = pusch_Config; + + ASN_SEQUENCE_ADD(&scd->uplinkConfig->uplinkBWP_ToAddModList->list,ubwp); } - NR_PTRS_UplinkConfig->transformPrecoderDisabled->timeDensity = CALLOC(1, sizeof(*NR_PTRS_UplinkConfig->transformPrecoderDisabled->timeDensity)); - long *ptrs_mcs = CALLOC(3, sizeof(long)); - for (int i = 0; i < 3; i++) { - ASN_SEQUENCE_ADD(&NR_PTRS_UplinkConfig->transformPrecoderDisabled->timeDensity->list, &ptrs_mcs[i]); - } - NR_PTRS_UplinkConfig->transformPrecoderDisabled->resourceElementOffset = CALLOC(1, sizeof(*NR_PTRS_UplinkConfig->transformPrecoderDisabled->resourceElementOffset)); - *NR_PTRS_UplinkConfig->transformPrecoderDisabled->resourceElementOffset = 0; - - // UL bandwidth part - NR_BWP_Uplink_t *ubwp = CALLOC(1, sizeof(*ubwp)); - ubwp->bwp_Id = 1; - ubwp->bwp_Dedicated = CALLOC(1, sizeof(*ubwp->bwp_Dedicated)); - - ubwp->bwp_Dedicated->pusch_Config = CALLOC(1, sizeof(*ubwp->bwp_Dedicated->pusch_Config)); - ubwp->bwp_Dedicated->pusch_Config->present = NR_SetupRelease_PUSCH_Config_PR_setup; - ubwp->bwp_Dedicated->pusch_Config->choice.setup = pusch_Config; - - ASN_SEQUENCE_ADD(&scd->uplinkConfig->uplinkBWP_ToAddModList->list,ubwp); } -/* This function checks dedicated serving cell configuration and performs fixes as needed */ +/* This function checks dedicated serving cell configuration and performs fixes as needed */ void fix_scd(NR_ServingCellConfig_t *scd) { + + // Remove unused BWPs + int b = 0; + while (bdownlinkBWP_ToAddModList->list.count) { + if (scd->downlinkBWP_ToAddModList->list.array[b]->bwp_Common->genericParameters.locationAndBandwidth == 0) { + asn_sequence_del(&scd->downlinkBWP_ToAddModList->list,b,1); + } else { + b++; + } + } + + b = 0; + while (buplinkConfig->uplinkBWP_ToAddModList->list.count) { + if (scd->uplinkConfig->uplinkBWP_ToAddModList->list.array[b]->bwp_Common->genericParameters.locationAndBandwidth == 0) { + asn_sequence_del(&scd->uplinkConfig->uplinkBWP_ToAddModList->list,b,1); + } else { + b++; + } + } + // Check for DL PTRS parameters validity - if (scd->downlinkBWP_ToAddModList->list.array[0]->bwp_Dedicated->pdsch_Config->choice.setup->dmrs_DownlinkForPDSCH_MappingTypeA->choice.setup->phaseTrackingRS) { - // If any of the frequencyDensity values are not set or are out of bounds, PTRS is assumed to be not present - for (int i = scd->downlinkBWP_ToAddModList->list.array[0]->bwp_Dedicated->pdsch_Config->choice.setup->dmrs_DownlinkForPDSCH_MappingTypeA->choice.setup->phaseTrackingRS->choice.setup->frequencyDensity->list.count-1; i >= 0; i--) { - if ((*scd->downlinkBWP_ToAddModList->list.array[0]->bwp_Dedicated->pdsch_Config->choice.setup->dmrs_DownlinkForPDSCH_MappingTypeA->choice.setup->phaseTrackingRS->choice.setup->frequencyDensity->list.array[i] < 1) - || (*scd->downlinkBWP_ToAddModList->list.array[0]->bwp_Dedicated->pdsch_Config->choice.setup->dmrs_DownlinkForPDSCH_MappingTypeA->choice.setup->phaseTrackingRS->choice.setup->frequencyDensity->list.array[i] > 276)) { - LOG_I(RRC, "DL PTRS frequencyDensity %d not set. Assuming PTRS not present! \n", i); - free(scd->downlinkBWP_ToAddModList->list.array[0]->bwp_Dedicated->pdsch_Config->choice.setup->dmrs_DownlinkForPDSCH_MappingTypeA->choice.setup->phaseTrackingRS); - scd->downlinkBWP_ToAddModList->list.array[0]->bwp_Dedicated->pdsch_Config->choice.setup->dmrs_DownlinkForPDSCH_MappingTypeA->choice.setup->phaseTrackingRS = NULL; - break; - } - } - } - if (scd->downlinkBWP_ToAddModList->list.array[0]->bwp_Dedicated->pdsch_Config->choice.setup->dmrs_DownlinkForPDSCH_MappingTypeA->choice.setup->phaseTrackingRS) { - // If any of the timeDensity values are not set or are out of bounds, PTRS is assumed to be not present - for (int i = scd->downlinkBWP_ToAddModList->list.array[0]->bwp_Dedicated->pdsch_Config->choice.setup->dmrs_DownlinkForPDSCH_MappingTypeA->choice.setup->phaseTrackingRS->choice.setup->timeDensity->list.count-1; i >= 0; i--) { - if ((*scd->downlinkBWP_ToAddModList->list.array[0]->bwp_Dedicated->pdsch_Config->choice.setup->dmrs_DownlinkForPDSCH_MappingTypeA->choice.setup->phaseTrackingRS->choice.setup->timeDensity->list.array[i] < 0) - || (*scd->downlinkBWP_ToAddModList->list.array[0]->bwp_Dedicated->pdsch_Config->choice.setup->dmrs_DownlinkForPDSCH_MappingTypeA->choice.setup->phaseTrackingRS->choice.setup->timeDensity->list.array[i] > 29)) { - LOG_I(RRC, "DL PTRS timeDensity %d not set. Assuming PTRS not present! \n", i); - free(scd->downlinkBWP_ToAddModList->list.array[0]->bwp_Dedicated->pdsch_Config->choice.setup->dmrs_DownlinkForPDSCH_MappingTypeA->choice.setup->phaseTrackingRS); - scd->downlinkBWP_ToAddModList->list.array[0]->bwp_Dedicated->pdsch_Config->choice.setup->dmrs_DownlinkForPDSCH_MappingTypeA->choice.setup->phaseTrackingRS = NULL; - break; - } - } - } - if (scd->downlinkBWP_ToAddModList->list.array[0]->bwp_Dedicated->pdsch_Config->choice.setup->dmrs_DownlinkForPDSCH_MappingTypeA->choice.setup->phaseTrackingRS) { - if (*scd->downlinkBWP_ToAddModList->list.array[0]->bwp_Dedicated->pdsch_Config->choice.setup->dmrs_DownlinkForPDSCH_MappingTypeA->choice.setup->phaseTrackingRS->choice.setup->resourceElementOffset > 2) { - LOG_I(RRC, "Freeing DL PTRS resourceElementOffset \n"); - free(scd->downlinkBWP_ToAddModList->list.array[0]->bwp_Dedicated->pdsch_Config->choice.setup->dmrs_DownlinkForPDSCH_MappingTypeA->choice.setup->phaseTrackingRS->choice.setup->resourceElementOffset); - scd->downlinkBWP_ToAddModList->list.array[0]->bwp_Dedicated->pdsch_Config->choice.setup->dmrs_DownlinkForPDSCH_MappingTypeA->choice.setup->phaseTrackingRS->choice.setup->resourceElementOffset = NULL; - } - if (*scd->downlinkBWP_ToAddModList->list.array[0]->bwp_Dedicated->pdsch_Config->choice.setup->dmrs_DownlinkForPDSCH_MappingTypeA->choice.setup->phaseTrackingRS->choice.setup->epre_Ratio > 1) { - LOG_I(RRC, "Freeing DL PTRS epre_Ratio \n"); - free(scd->downlinkBWP_ToAddModList->list.array[0]->bwp_Dedicated->pdsch_Config->choice.setup->dmrs_DownlinkForPDSCH_MappingTypeA->choice.setup->phaseTrackingRS->choice.setup->epre_Ratio); - scd->downlinkBWP_ToAddModList->list.array[0]->bwp_Dedicated->pdsch_Config->choice.setup->dmrs_DownlinkForPDSCH_MappingTypeA->choice.setup->phaseTrackingRS->choice.setup->epre_Ratio = NULL; - } - } + for (int bwp_i = 0 ; bwp_idownlinkBWP_ToAddModList->list.count; bwp_i++) { - if (scd->uplinkConfig->uplinkBWP_ToAddModList->list.array[0]->bwp_Dedicated->pusch_Config->choice.setup->dmrs_UplinkForPUSCH_MappingTypeB->choice.setup->phaseTrackingRS) { - // If any of the frequencyDensity values are not set or are out of bounds, PTRS is assumed to be not present - for (int i = scd->uplinkConfig->uplinkBWP_ToAddModList->list.array[0]->bwp_Dedicated->pusch_Config->choice.setup->dmrs_UplinkForPUSCH_MappingTypeB->choice.setup->phaseTrackingRS->choice.setup->transformPrecoderDisabled->frequencyDensity->list.count-1; i >= 0; i--) { - if ((*scd->uplinkConfig->uplinkBWP_ToAddModList->list.array[0]->bwp_Dedicated->pusch_Config->choice.setup->dmrs_UplinkForPUSCH_MappingTypeB->choice.setup->phaseTrackingRS->choice.setup->transformPrecoderDisabled->frequencyDensity->list.array[i] < 1) - || (*scd->uplinkConfig->uplinkBWP_ToAddModList->list.array[0]->bwp_Dedicated->pusch_Config->choice.setup->dmrs_UplinkForPUSCH_MappingTypeB->choice.setup->phaseTrackingRS->choice.setup->transformPrecoderDisabled->frequencyDensity->list.array[i] > 276)) { - LOG_I(RRC, "UL PTRS frequencyDensity %d not set. Assuming PTRS not present! \n", i); - free(scd->uplinkConfig->uplinkBWP_ToAddModList->list.array[0]->bwp_Dedicated->pusch_Config->choice.setup->dmrs_UplinkForPUSCH_MappingTypeB->choice.setup->phaseTrackingRS); - scd->uplinkConfig->uplinkBWP_ToAddModList->list.array[0]->bwp_Dedicated->pusch_Config->choice.setup->dmrs_UplinkForPUSCH_MappingTypeB->choice.setup->phaseTrackingRS = NULL; - break; + NR_DMRS_DownlinkConfig_t *dmrs_dl_config = scd->downlinkBWP_ToAddModList->list.array[bwp_i]->bwp_Dedicated->pdsch_Config->choice.setup->dmrs_DownlinkForPDSCH_MappingTypeA->choice.setup; + + if (dmrs_dl_config->phaseTrackingRS) { + // If any of the frequencyDensity values are not set or are out of bounds, PTRS is assumed to be not present + for (int i = dmrs_dl_config->phaseTrackingRS->choice.setup->frequencyDensity->list.count - 1; i >= 0; i--) { + if ((*dmrs_dl_config->phaseTrackingRS->choice.setup->frequencyDensity->list.array[i] < 1) + || (*dmrs_dl_config->phaseTrackingRS->choice.setup->frequencyDensity->list.array[i] > 276)) { + LOG_I(GNB_APP, "DL PTRS frequencyDensity %d not set. Assuming PTRS not present! \n", i); + free(dmrs_dl_config->phaseTrackingRS); + dmrs_dl_config->phaseTrackingRS = NULL; + break; + } + } + } + + if (dmrs_dl_config->phaseTrackingRS) { + // If any of the timeDensity values are not set or are out of bounds, PTRS is assumed to be not present + for (int i = dmrs_dl_config->phaseTrackingRS->choice.setup->timeDensity->list.count - 1; i >= 0; i--) { + if ((*dmrs_dl_config->phaseTrackingRS->choice.setup->timeDensity->list.array[i] < 0) + || (*dmrs_dl_config->phaseTrackingRS->choice.setup->timeDensity->list.array[i] > 29)) { + LOG_I(GNB_APP, "DL PTRS timeDensity %d not set. Assuming PTRS not present! \n", i); + free(dmrs_dl_config->phaseTrackingRS); + dmrs_dl_config->phaseTrackingRS = NULL; + break; + } + } + } + + if (dmrs_dl_config->phaseTrackingRS) { + if (*dmrs_dl_config->phaseTrackingRS->choice.setup->resourceElementOffset > 2) { + LOG_I(GNB_APP, "Freeing DL PTRS resourceElementOffset \n"); + free(dmrs_dl_config->phaseTrackingRS->choice.setup->resourceElementOffset); + dmrs_dl_config->phaseTrackingRS->choice.setup->resourceElementOffset = NULL; + } + if (*dmrs_dl_config->phaseTrackingRS->choice.setup->epre_Ratio > 1) { + LOG_I(GNB_APP, "Freeing DL PTRS epre_Ratio \n"); + free(dmrs_dl_config->phaseTrackingRS->choice.setup->epre_Ratio); + dmrs_dl_config->phaseTrackingRS->choice.setup->epre_Ratio = NULL; } } } - if (scd->uplinkConfig->uplinkBWP_ToAddModList->list.array[0]->bwp_Dedicated->pusch_Config->choice.setup->dmrs_UplinkForPUSCH_MappingTypeB->choice.setup->phaseTrackingRS) { - // If any of the timeDensity values are not set or are out of bounds, PTRS is assumed to be not present - for (int i = scd->uplinkConfig->uplinkBWP_ToAddModList->list.array[0]->bwp_Dedicated->pusch_Config->choice.setup->dmrs_UplinkForPUSCH_MappingTypeB->choice.setup->phaseTrackingRS->choice.setup->transformPrecoderDisabled->timeDensity->list.count-1; i >= 0; i--) { - if ((*scd->uplinkConfig->uplinkBWP_ToAddModList->list.array[0]->bwp_Dedicated->pusch_Config->choice.setup->dmrs_UplinkForPUSCH_MappingTypeB->choice.setup->phaseTrackingRS->choice.setup->transformPrecoderDisabled->timeDensity->list.array[i] < 0) - || (*scd->uplinkConfig->uplinkBWP_ToAddModList->list.array[0]->bwp_Dedicated->pusch_Config->choice.setup->dmrs_UplinkForPUSCH_MappingTypeB->choice.setup->phaseTrackingRS->choice.setup->transformPrecoderDisabled->timeDensity->list.array[i] > 29)) { - LOG_I(RRC, "UL PTRS timeDensity %d not set. Assuming PTRS not present! \n", i); - free(scd->uplinkConfig->uplinkBWP_ToAddModList->list.array[0]->bwp_Dedicated->pusch_Config->choice.setup->dmrs_UplinkForPUSCH_MappingTypeB->choice.setup->phaseTrackingRS); - scd->uplinkConfig->uplinkBWP_ToAddModList->list.array[0]->bwp_Dedicated->pusch_Config->choice.setup->dmrs_UplinkForPUSCH_MappingTypeB->choice.setup->phaseTrackingRS = NULL; - break; + // Check for UL PTRS parameters validity + for (int bwp_i = 0 ; bwp_iuplinkConfig->uplinkBWP_ToAddModList->list.count; bwp_i++) { + + NR_DMRS_UplinkConfig_t *dmrs_ul_config = scd->uplinkConfig->uplinkBWP_ToAddModList->list.array[bwp_i]->bwp_Dedicated->pusch_Config->choice.setup->dmrs_UplinkForPUSCH_MappingTypeB->choice.setup; + + if (dmrs_ul_config->phaseTrackingRS) { + // If any of the frequencyDensity values are not set or are out of bounds, PTRS is assumed to be not present + for (int i = dmrs_ul_config->phaseTrackingRS->choice.setup->transformPrecoderDisabled->frequencyDensity->list.count-1; i >= 0; i--) { + if ((*dmrs_ul_config->phaseTrackingRS->choice.setup->transformPrecoderDisabled->frequencyDensity->list.array[i] < 1) + || (*dmrs_ul_config->phaseTrackingRS->choice.setup->transformPrecoderDisabled->frequencyDensity->list.array[i] > 276)) { + LOG_I(GNB_APP, "UL PTRS frequencyDensity %d not set. Assuming PTRS not present! \n", i); + free(dmrs_ul_config->phaseTrackingRS); + dmrs_ul_config->phaseTrackingRS = NULL; + break; + } } } - } - if (scd->uplinkConfig->uplinkBWP_ToAddModList->list.array[0]->bwp_Dedicated->pusch_Config->choice.setup->dmrs_UplinkForPUSCH_MappingTypeB->choice.setup->phaseTrackingRS) { - // Check for UL PTRS parameters validity - if (*scd->uplinkConfig->uplinkBWP_ToAddModList->list.array[0]->bwp_Dedicated->pusch_Config->choice.setup->dmrs_UplinkForPUSCH_MappingTypeB->choice.setup->phaseTrackingRS->choice.setup->transformPrecoderDisabled->resourceElementOffset > 2) { - LOG_I(RRC, "Freeing UL PTRS resourceElementOffset \n"); - free(scd->uplinkConfig->uplinkBWP_ToAddModList->list.array[0]->bwp_Dedicated->pusch_Config->choice.setup->dmrs_UplinkForPUSCH_MappingTypeB->choice.setup->phaseTrackingRS->choice.setup->transformPrecoderDisabled->resourceElementOffset); - scd->uplinkConfig->uplinkBWP_ToAddModList->list.array[0]->bwp_Dedicated->pusch_Config->choice.setup->dmrs_UplinkForPUSCH_MappingTypeB->choice.setup->phaseTrackingRS->choice.setup->transformPrecoderDisabled->resourceElementOffset = NULL; + + if (dmrs_ul_config->phaseTrackingRS) { + // If any of the timeDensity values are not set or are out of bounds, PTRS is assumed to be not present + for (int i = dmrs_ul_config->phaseTrackingRS->choice.setup->transformPrecoderDisabled->timeDensity->list.count-1; i >= 0; i--) { + if ((*dmrs_ul_config->phaseTrackingRS->choice.setup->transformPrecoderDisabled->timeDensity->list.array[i] < 0) + || (*dmrs_ul_config->phaseTrackingRS->choice.setup->transformPrecoderDisabled->timeDensity->list.array[i] > 29)) { + LOG_I(GNB_APP, "UL PTRS timeDensity %d not set. Assuming PTRS not present! \n", i); + free(dmrs_ul_config->phaseTrackingRS); + dmrs_ul_config->phaseTrackingRS = NULL; + break; + } + } } + + if (dmrs_ul_config->phaseTrackingRS) { + // Check for UL PTRS parameters validity + if (*dmrs_ul_config->phaseTrackingRS->choice.setup->transformPrecoderDisabled->resourceElementOffset > 2) { + LOG_I(GNB_APP, "Freeing UL PTRS resourceElementOffset \n"); + free(dmrs_ul_config->phaseTrackingRS->choice.setup->transformPrecoderDisabled->resourceElementOffset); + dmrs_ul_config->phaseTrackingRS->choice.setup->transformPrecoderDisabled->resourceElementOffset = NULL; + } + } + } } @@ -621,22 +678,27 @@ void RCconfig_NR_L1(void) { 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( &GNBParamList,GNBParams,sizeof(GNBParams)/sizeof(paramdef_t),NULL); - char *ulprbbl = *GNBParamList.paramarray[0][GNB_ULPRBBLACKLIST_IDX].strptr; + config_getlist( &GNBParamList,GNBParams,sizeof(GNBParams)/sizeof(paramdef_t),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_I(NR_PHY,"PRB blacklist %s\n",ulprbbl); - char *pt = strtok(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) { - prbbl[atoi(pt)] = 1; + const int rb = atoi(pt); + AssertFatal(rb < 275, "RB %d out of bounds (max 275)\n", rb); + prbbl[rb] = 0x3FFF; // all symbols taken LOG_I(NR_PHY,"Blacklisting prb %d\n",atoi(pt)); - pt = strtok(NULL,","); + pt = strtok_r(NULL, ",", &save); num_prbbl++; } - paramdef_t L1_Params[] = L1PARAMS_DESC; paramlist_def_t L1_ParamList = {CONFIG_STRING_L1_LIST,NULL,0}; @@ -665,7 +727,11 @@ void RCconfig_NR_L1(void) { 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]->max_ldpc_iterations = *(L1_ParamList.paramarray[j][L1_MAX_LDPC_ITERATIONS].uptr); RC.gNB[j]->num_ulprbbl = num_prbbl; + RC.gNB[j]->ap_N1 = N1; + RC.gNB[j]->ap_N2 = N2; + RC.gNB[j]->ap_XP = XP; LOG_I(NR_PHY,"Copying %d blacklisted PRB to L1 context\n",num_prbbl); memcpy(RC.gNB[j]->ulprbbl,prbbl,275*sizeof(int)); if(strcmp(*(L1_ParamList.paramarray[j][L1_TRANSPORT_N_PREFERENCE_IDX].strptr), "local_mac") == 0) { @@ -736,21 +802,20 @@ void RCconfig_nr_macrlc() { config_getlist( &GNBParamList,GNBParams,sizeof(GNBParams)/sizeof(paramdef_t),NULL); char *ulprbbl = *GNBParamList.paramarray[0][GNB_ULPRBBLACKLIST_IDX].strptr; - char *pt = strtok(ulprbbl,","); - int prbbl[275]; + char *save = NULL; + char *pt = strtok_r(ulprbbl, ",", &save); + uint16_t prbbl[275]; int num_prbbl=0; - int prb; - memset(prbbl,0,275*sizeof(int)); + memset(prbbl,0,sizeof(prbbl)); while (pt) { - prb=atoi(pt); - prbbl[prb] = 1; - pt = strtok(NULL,","); + 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}; - config_getlist( &MacRLC_ParamList,MacRLC_Params,sizeof(MacRLC_Params)/sizeof(paramdef_t), NULL); if ( MacRLC_ParamList.numelt > 0) { @@ -817,14 +882,19 @@ void RCconfig_nr_macrlc() { AssertFatal(1==0,"MACRLC %d: %s unknown southbound midhaul\n",j,*(MacRLC_ParamList.paramarray[j][MACRLC_TRANSPORT_S_PREFERENCE_IDX].strptr)); } RC.nrmac[j]->ulsch_max_frame_inactivity = *(MacRLC_ParamList.paramarray[j][MACRLC_ULSCH_MAX_FRAME_INACTIVITY].uptr); - RC.nrmac[j]->dl_bler_target_upper = *(MacRLC_ParamList.paramarray[j][MACRLC_DL_BLER_TARGET_UPPER_IDX].dblptr); - RC.nrmac[j]->dl_bler_target_lower = *(MacRLC_ParamList.paramarray[j][MACRLC_DL_BLER_TARGET_LOWER_IDX].dblptr); - RC.nrmac[j]->dl_rd2_bler_threshold = *(MacRLC_ParamList.paramarray[j][MACRLC_DL_RD2_BLER_THRESHOLD_IDX].dblptr); - RC.nrmac[j]->dl_max_mcs = *(MacRLC_ParamList.paramarray[j][MACRLC_DL_MAX_MCS_IDX].u8ptr); + NR_bler_options_t *dl_bler_options = &RC.nrmac[j]->dl_bler; + dl_bler_options->upper = *(MacRLC_ParamList.paramarray[j][MACRLC_DL_BLER_TARGET_UPPER_IDX].dblptr); + dl_bler_options->lower = *(MacRLC_ParamList.paramarray[j][MACRLC_DL_BLER_TARGET_LOWER_IDX].dblptr); + dl_bler_options->max_mcs = *(MacRLC_ParamList.paramarray[j][MACRLC_DL_MAX_MCS_IDX].u8ptr); + NR_bler_options_t *ul_bler_options = &RC.nrmac[j]->ul_bler; + ul_bler_options->upper = *(MacRLC_ParamList.paramarray[j][MACRLC_UL_BLER_TARGET_UPPER_IDX].dblptr); + ul_bler_options->lower = *(MacRLC_ParamList.paramarray[j][MACRLC_UL_BLER_TARGET_LOWER_IDX].dblptr); + ul_bler_options->max_mcs = *(MacRLC_ParamList.paramarray[j][MACRLC_UL_MAX_MCS_IDX].u8ptr); + RC.nrmac[j]->harq_round_max = *(MacRLC_ParamList.paramarray[j][MACRLC_HARQ_ROUND_MAX_IDX].u8ptr); + 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]->num_ulprbbl = num_prbbl; - LOG_I(NR_MAC,"Blacklisted PRBS %d\n",num_prbbl); memcpy(RC.nrmac[j]->ulprbbl,prbbl,275*sizeof(prbbl[0])); - }// for (j=0;j 0 LOG_E(PHY,"No %s configuration found\n", CONFIG_STRING_MACRLC_LIST); @@ -976,8 +1046,8 @@ void RCconfig_NRRRC(MessageDef *msg_p, uint32_t i, gNB_RRC_INST *rrc) { prepare_scd(scd); paramdef_t SCDsParams[] = SCDPARAMS_DESC(scd); paramlist_def_t SCDsParamList = {GNB_CONFIG_STRING_SERVINGCELLCONFIGDEDICATED, NULL, 0}; - ////////// Physical parameters + ////////// Physical parameters /* get global parameters, defined outside any section in the config file */ @@ -1054,13 +1124,17 @@ void RCconfig_NRRRC(MessageDef *msg_p, uint32_t i, gNB_RRC_INST *rrc) { if (SCDsParamList.numelt > 0) { sprintf(aprefix, "%s.[%i].%s.[%i]", GNB_CONFIG_STRING_GNB_LIST,0,GNB_CONFIG_STRING_SERVINGCELLCONFIGDEDICATED, 0); config_get( SCDsParams,sizeof(SCDsParams)/sizeof(paramdef_t),aprefix); - LOG_I(RRC,"Read in ServingCellConfigDedicated UL (FreqDensity_0 %d, FreqDensity_1 %d, TimeDensity_0 %d, TimeDensity_1 %d, TimeDensity_2 %d, RE offset %d \n", + LOG_I(RRC,"Read in ServingCellConfigDedicated UL (FreqDensity_0 %d, FreqDensity_1 %d, TimeDensity_0 %d, TimeDensity_1 %d, TimeDensity_2 %d, RE offset %d, First_active_BWP_ID %d SCS %d, LocationandBW %d \n", (int)*scd->uplinkConfig->uplinkBWP_ToAddModList->list.array[0]->bwp_Dedicated->pusch_Config->choice.setup->dmrs_UplinkForPUSCH_MappingTypeB->choice.setup->phaseTrackingRS->choice.setup->transformPrecoderDisabled->frequencyDensity->list.array[0], (int)*scd->uplinkConfig->uplinkBWP_ToAddModList->list.array[0]->bwp_Dedicated->pusch_Config->choice.setup->dmrs_UplinkForPUSCH_MappingTypeB->choice.setup->phaseTrackingRS->choice.setup->transformPrecoderDisabled->frequencyDensity->list.array[1], (int)*scd->uplinkConfig->uplinkBWP_ToAddModList->list.array[0]->bwp_Dedicated->pusch_Config->choice.setup->dmrs_UplinkForPUSCH_MappingTypeB->choice.setup->phaseTrackingRS->choice.setup->transformPrecoderDisabled->timeDensity->list.array[0], (int)*scd->uplinkConfig->uplinkBWP_ToAddModList->list.array[0]->bwp_Dedicated->pusch_Config->choice.setup->dmrs_UplinkForPUSCH_MappingTypeB->choice.setup->phaseTrackingRS->choice.setup->transformPrecoderDisabled->timeDensity->list.array[1], (int)*scd->uplinkConfig->uplinkBWP_ToAddModList->list.array[0]->bwp_Dedicated->pusch_Config->choice.setup->dmrs_UplinkForPUSCH_MappingTypeB->choice.setup->phaseTrackingRS->choice.setup->transformPrecoderDisabled->timeDensity->list.array[2], - (int)*scd->uplinkConfig->uplinkBWP_ToAddModList->list.array[0]->bwp_Dedicated->pusch_Config->choice.setup->dmrs_UplinkForPUSCH_MappingTypeB->choice.setup->phaseTrackingRS->choice.setup->transformPrecoderDisabled->resourceElementOffset); + (int)*scd->uplinkConfig->uplinkBWP_ToAddModList->list.array[0]->bwp_Dedicated->pusch_Config->choice.setup->dmrs_UplinkForPUSCH_MappingTypeB->choice.setup->phaseTrackingRS->choice.setup->transformPrecoderDisabled->resourceElementOffset, + (int)*scd->firstActiveDownlinkBWP_Id, + (int)scd->downlinkBWP_ToAddModList->list.array[0]->bwp_Common->genericParameters.subcarrierSpacing, + (int)scd->downlinkBWP_ToAddModList->list.array[0]->bwp_Common->genericParameters.locationAndBandwidth + ); } fix_scd(scd); @@ -1100,6 +1174,7 @@ void RCconfig_NRRRC(MessageDef *msg_p, uint32_t i, gNB_RRC_INST *rrc) { rrc->nr_cellid = (uint64_t)*(GNBParamList.paramarray[i][GNB_NRCELLID_IDX].u64ptr); + rrc->um_on_default_drb = *(GNBParamList.paramarray[i][GNB_UMONDEFAULTDRB_IDX].uptr); if (strcmp(*(GNBParamList.paramarray[i][GNB_TRANSPORT_S_PREFERENCE_IDX].strptr), "local_mac") == 0) { } else if (strcmp(*(GNBParamList.paramarray[i][GNB_TRANSPORT_S_PREFERENCE_IDX].strptr), "cudu") == 0) { @@ -1160,23 +1235,31 @@ void RCconfig_NRRRC(MessageDef *msg_p, uint32_t i, gNB_RRC_INST *rrc) { (NRRRC_CONFIGURATION_REQ (msg_p).mnc_digit_length[l] == 3),"BAD MNC DIGIT LENGTH %d", NRRRC_CONFIGURATION_REQ (msg_p).mnc_digit_length[l]); } - LOG_I(RRC,"SSB SCO %d\n",*GNBParamList.paramarray[i][GNB_SSB_SUBCARRIEROFFSET_IDX].iptr); + LOG_I(GNB_APP,"SSB SCO %d\n",*GNBParamList.paramarray[i][GNB_SSB_SUBCARRIEROFFSET_IDX].iptr); NRRRC_CONFIGURATION_REQ (msg_p).ssb_SubcarrierOffset = *GNBParamList.paramarray[i][GNB_SSB_SUBCARRIEROFFSET_IDX].iptr; - LOG_I(RRC,"pdsch_AntennaPorts %d\n",*GNBParamList.paramarray[i][GNB_PDSCH_ANTENNAPORTS_IDX].iptr); - NRRRC_CONFIGURATION_REQ (msg_p).pdsch_AntennaPorts = *GNBParamList.paramarray[i][GNB_PDSCH_ANTENNAPORTS_IDX].iptr; - LOG_I(RRC,"pusch_AntennaPorts %d\n",*GNBParamList.paramarray[i][GNB_PUSCH_ANTENNAPORTS_IDX].iptr); + LOG_I(GNB_APP,"pdsch_AntennaPorts N1 %d\n",*GNBParamList.paramarray[i][GNB_PDSCH_ANTENNAPORTS_N1_IDX].iptr); + NRRRC_CONFIGURATION_REQ (msg_p).pdsch_AntennaPorts.N1 = *GNBParamList.paramarray[i][GNB_PDSCH_ANTENNAPORTS_N1_IDX].iptr; + LOG_I(GNB_APP,"pdsch_AntennaPorts N2 %d\n",*GNBParamList.paramarray[i][GNB_PDSCH_ANTENNAPORTS_N2_IDX].iptr); + NRRRC_CONFIGURATION_REQ (msg_p).pdsch_AntennaPorts.N2 = *GNBParamList.paramarray[i][GNB_PDSCH_ANTENNAPORTS_N2_IDX].iptr; + LOG_I(GNB_APP,"pdsch_AntennaPorts XP %d\n",*GNBParamList.paramarray[i][GNB_PDSCH_ANTENNAPORTS_XP_IDX].iptr); + NRRRC_CONFIGURATION_REQ (msg_p).pdsch_AntennaPorts.XP = *GNBParamList.paramarray[i][GNB_PDSCH_ANTENNAPORTS_XP_IDX].iptr; + LOG_I(GNB_APP,"pusch_AntennaPorts %d\n",*GNBParamList.paramarray[i][GNB_PUSCH_ANTENNAPORTS_IDX].iptr); NRRRC_CONFIGURATION_REQ (msg_p).pusch_AntennaPorts = *GNBParamList.paramarray[i][GNB_PUSCH_ANTENNAPORTS_IDX].iptr; - LOG_I(RRC,"minTXRXTIME %d\n",*GNBParamList.paramarray[i][GNB_MINRXTXTIME_IDX].iptr); + LOG_I(GNB_APP,"minTXRXTIME %d\n",*GNBParamList.paramarray[i][GNB_MINRXTXTIME_IDX].iptr); NRRRC_CONFIGURATION_REQ (msg_p).minRXTXTIME = *GNBParamList.paramarray[i][GNB_MINRXTXTIME_IDX].iptr; - LOG_I(RRC,"SIB1 TDA %d\n",*GNBParamList.paramarray[i][GNB_SIB1_TDA_IDX].iptr); + LOG_I(GNB_APP,"SIB1 TDA %d\n",*GNBParamList.paramarray[i][GNB_SIB1_TDA_IDX].iptr); NRRRC_CONFIGURATION_REQ (msg_p).sib1_tda = *GNBParamList.paramarray[i][GNB_SIB1_TDA_IDX].iptr; - LOG_I(RRC,"Do CSI-RS %d\n",*GNBParamList.paramarray[i][GNB_DO_CSIRS_IDX].iptr); + LOG_I(GNB_APP,"Do CSI-RS %d\n",*GNBParamList.paramarray[i][GNB_DO_CSIRS_IDX].iptr); NRRRC_CONFIGURATION_REQ (msg_p).do_CSIRS = *GNBParamList.paramarray[i][GNB_DO_CSIRS_IDX].iptr; - printf("Do SRS %d\n",*GNBParamList.paramarray[i][GNB_DO_SRS_IDX].iptr); + LOG_I(GNB_APP, "Do SRS %d\n",*GNBParamList.paramarray[i][GNB_DO_SRS_IDX].iptr); NRRRC_CONFIGURATION_REQ (msg_p).do_SRS = *GNBParamList.paramarray[i][GNB_DO_SRS_IDX].iptr; + NRRRC_CONFIGURATION_REQ (msg_p).force_256qam_off = *GNBParamList.paramarray[i][GNB_FORCE256QAMOFF_IDX].iptr; + LOG_I(GNB_APP, "256 QAM: %s\n", NRRRC_CONFIGURATION_REQ (msg_p).force_256qam_off ? "force off" : "may be on"); NRRRC_CONFIGURATION_REQ (msg_p).scc = scc; NRRRC_CONFIGURATION_REQ (msg_p).scd = scd; - + NRRRC_CONFIGURATION_REQ (msg_p).enable_sdap = *GNBParamList.paramarray[i][GNB_ENABLE_SDAP_IDX].iptr; + LOG_I(GNB_APP, "SDAP layer is %s\n", NRRRC_CONFIGURATION_REQ (msg_p).enable_sdap ? "enabled" : "disabled"); + }// }//End for (k=0; k configuration, &NRRRC_CONFIGURATION_REQ(msg_p), sizeof(NRRRC_CONFIGURATION_REQ(msg_p))); @@ -1458,7 +1541,8 @@ int RCconfig_NR_NG(MessageDef *msg_p, uint32_t i) { // NGAP_REGISTER_GNB_REQ (msg_p).enb_interface_name_for_NGU = strdup(enb_interface_name_for_NGU); cidr = *(NETParams[GNB_IPV4_ADDRESS_FOR_NG_AMF_IDX].strptr); - address = strtok(cidr, "/"); + char *save = NULL; + address = strtok_r(cidr, "/", &save); NGAP_REGISTER_GNB_REQ (msg_p).gnb_ip_address.ipv6 = 0; NGAP_REGISTER_GNB_REQ (msg_p).gnb_ip_address.ipv4 = 1; @@ -1730,7 +1814,8 @@ int RCconfig_NR_X2(MessageDef *msg_p, uint32_t i) { } cidr = *(NETParams[ENB_IPV4_ADDR_FOR_X2C_IDX].strptr); - address = strtok(cidr, "/"); + char *save = NULL; + address = strtok_r(cidr, "/", &save); X2AP_REGISTER_ENB_REQ (msg_p).enb_x2_ip_address.ipv6 = 0; X2AP_REGISTER_ENB_REQ (msg_p).enb_x2_ip_address.ipv4 = 1; strcpy(X2AP_REGISTER_ENB_REQ (msg_p).enb_x2_ip_address.ipv4_address, address); @@ -2043,10 +2128,10 @@ void configure_gnb_du_mac(int inst) { rrc->configuration.minRXTXTIME, rrc->configuration.scc, NULL, + NULL, 0, 0, // rnti - (NR_CellGroupConfig_t *)NULL - ); + NULL); } diff --git a/openair2/GNB_APP/gnb_paramdef.h b/openair2/GNB_APP/gnb_paramdef.h index cde7819e25..52dcbd3152 100644 --- a/openair2/GNB_APP/gnb_paramdef.h +++ b/openair2/GNB_APP/gnb_paramdef.h @@ -114,7 +114,9 @@ typedef enum { #define GNB_CONFIG_STRING_LOCAL_S_PORTD "local_s_portd" #define GNB_CONFIG_STRING_REMOTE_S_PORTD "remote_s_portd" #define GNB_CONFIG_STRING_SSBSUBCARRIEROFFSET "ssb_SubcarrierOffset" -#define GNB_CONFIG_STRING_PDSCHANTENNAPORTS "pdsch_AntennaPorts" +#define GNB_CONFIG_STRING_PDSCHANTENNAPORTS_N1 "pdsch_AntennaPorts_N1" +#define GNB_CONFIG_STRING_PDSCHANTENNAPORTS_N2 "pdsch_AntennaPorts_N2" +#define GNB_CONFIG_STRING_PDSCHANTENNAPORTS_XP "pdsch_AntennaPorts_XP" #define GNB_CONFIG_STRING_PUSCHANTENNAPORTS "pusch_AntennaPorts" #define GNB_CONFIG_STRING_SIB1TDA "sib1_tda" #define GNB_CONFIG_STRING_DOCSIRS "do_CSIRS" @@ -122,7 +124,11 @@ typedef enum { #define GNB_CONFIG_STRING_NRCELLID "nr_cellid" #define GNB_CONFIG_STRING_MINRXTXTIME "min_rxtxtime" #define GNB_CONFIG_STRING_ULPRBBLACKLIST "ul_prbblacklist" - +#define GNB_CONFIG_STRING_UMONDEFAULTDRB "um_on_default_drb" +#define GNB_CONFIG_STRING_FORCE256QAMOFF "force_256qam_off" +#define GNB_CONFIG_STRING_ENABLE_SDAP "enable_sdap" +#define GNB_CONFIG_HLP_STRING_ENABLE_SDAP "enable the SDAP layer\n" +#define GNB_CONFIG_HLP_FORCE256QAMOFF "suppress activation of 256 QAM despite UE support" /*-----------------------------------------------------------------------------------------------------------------------------------------*/ /* cell configuration parameters */ @@ -144,14 +150,19 @@ typedef enum { {GNB_CONFIG_STRING_LOCAL_S_PORTD, NULL, 0, uptr:NULL, defuintval:50001, TYPE_UINT, 0}, \ {GNB_CONFIG_STRING_REMOTE_S_PORTD, NULL, 0, uptr:NULL, defuintval:50001, TYPE_UINT, 0}, \ {GNB_CONFIG_STRING_SSBSUBCARRIEROFFSET, NULL, 0, iptr:NULL, defintval:31, TYPE_INT, 0}, \ -{GNB_CONFIG_STRING_PDSCHANTENNAPORTS, NULL, 0, iptr:NULL, defintval:1, TYPE_INT, 0}, \ +{GNB_CONFIG_STRING_PDSCHANTENNAPORTS_N1, "horiz. log. antenna ports", 0, iptr:NULL, defintval:1, TYPE_INT, 0}, \ +{GNB_CONFIG_STRING_PDSCHANTENNAPORTS_N2, "vert. log. antenna ports", 0, iptr:NULL, defintval:1, TYPE_INT, 0}, \ +{GNB_CONFIG_STRING_PDSCHANTENNAPORTS_XP, "XP log. antenna ports", 0, iptr:NULL, defintval:1, TYPE_INT, 0}, \ {GNB_CONFIG_STRING_PUSCHANTENNAPORTS, NULL, 0, iptr:NULL, defintval:1, TYPE_INT, 0}, \ -{GNB_CONFIG_STRING_SIB1TDA, NULL, 0, iptr:NULL, defintval:0, TYPE_INT, 0}, \ +{GNB_CONFIG_STRING_SIB1TDA, NULL, 0, iptr:NULL, defintval:1, TYPE_INT, 0}, \ {GNB_CONFIG_STRING_DOCSIRS, NULL, 0, iptr:NULL, defintval:0, TYPE_INT, 0}, \ {GNB_CONFIG_STRING_DOSRS, NULL, 0, iptr:NULL, defintval:0, TYPE_INT, 0}, \ {GNB_CONFIG_STRING_NRCELLID, NULL, 0, u64ptr:NULL, defint64val:1, TYPE_UINT64, 0}, \ {GNB_CONFIG_STRING_MINRXTXTIME, NULL, 0, iptr:NULL, defintval:2, TYPE_INT, 0}, \ -{GNB_CONFIG_STRING_ULPRBBLACKLIST, NULL, 0, strptr:NULL, defstrval:"", TYPE_STRING, 0} \ +{GNB_CONFIG_STRING_ULPRBBLACKLIST, NULL, 0, strptr:NULL, defstrval:"", TYPE_STRING, 0}, \ +{GNB_CONFIG_STRING_UMONDEFAULTDRB, NULL, 0, uptr:NULL, defuintval:0, TYPE_UINT, 0}, \ +{GNB_CONFIG_STRING_FORCE256QAMOFF, GNB_CONFIG_HLP_FORCE256QAMOFF, PARAMFLAG_BOOL, iptr:NULL, defintval:0, TYPE_INT, 0}, \ +{GNB_CONFIG_STRING_ENABLE_SDAP, GNB_CONFIG_HLP_STRING_ENABLE_SDAP, PARAMFLAG_BOOL, iptr:NULL, defintval:0, TYPE_INT, 0} \ } #define GNB_GNB_ID_IDX 0 @@ -169,14 +180,19 @@ typedef enum { #define GNB_LOCAL_S_PORTD_IDX 12 #define GNB_REMOTE_S_PORTD_IDX 13 #define GNB_SSB_SUBCARRIEROFFSET_IDX 14 -#define GNB_PDSCH_ANTENNAPORTS_IDX 15 -#define GNB_PUSCH_ANTENNAPORTS_IDX 16 -#define GNB_SIB1_TDA_IDX 17 -#define GNB_DO_CSIRS_IDX 18 -#define GNB_DO_SRS_IDX 19 -#define GNB_NRCELLID_IDX 20 -#define GNB_MINRXTXTIME_IDX 21 -#define GNB_ULPRBBLACKLIST_IDX 22 +#define GNB_PDSCH_ANTENNAPORTS_N1_IDX 15 +#define GNB_PDSCH_ANTENNAPORTS_N2_IDX 16 +#define GNB_PDSCH_ANTENNAPORTS_XP_IDX 17 +#define GNB_PUSCH_ANTENNAPORTS_IDX 18 +#define GNB_SIB1_TDA_IDX 19 +#define GNB_DO_CSIRS_IDX 20 +#define GNB_DO_SRS_IDX 21 +#define GNB_NRCELLID_IDX 22 +#define GNB_MINRXTXTIME_IDX 23 +#define GNB_ULPRBBLACKLIST_IDX 24 +#define GNB_UMONDEFAULTDRB_IDX 25 +#define GNB_FORCE256QAMOFF_IDX 26 +#define GNB_ENABLE_SDAP_IDX 27 #define TRACKING_AREA_CODE_OKRANGE {0x0001,0xFFFD} #define GNBPARAMS_CHECK { \ diff --git a/openair2/LAYER2/MAC/config.c b/openair2/LAYER2/MAC/config.c index 209275acb3..d22485d23f 100644 --- a/openair2/LAYER2/MAC/config.c +++ b/openair2/LAYER2/MAC/config.c @@ -58,11 +58,6 @@ extern int l2_init_eNB(void); extern void mac_top_init_eNB(void); extern void mac_init_cell_params(int Mod_idP,int CC_idP); - -int32_t **rxdata; -int32_t **txdata; - - typedef struct eutra_bandentry_s { int16_t band; uint32_t ul_min; diff --git a/openair2/LAYER2/NR_MAC_COMMON/nr_compute_tbs_common.c b/openair2/LAYER2/NR_MAC_COMMON/nr_compute_tbs_common.c index c33946fa5a..1acf23197c 100644 --- a/openair2/LAYER2/NR_MAC_COMMON/nr_compute_tbs_common.c +++ b/openair2/LAYER2/NR_MAC_COMMON/nr_compute_tbs_common.c @@ -49,16 +49,15 @@ uint32_t nr_compute_tbs(uint16_t Qm, uint16_t nbp_re, nb_re; uint32_t nr_tbs=0; uint32_t Ninfo, Np_info, C; - uint8_t n, scale; + uint8_t n; LOG_D(NR_MAC, "In %s: nb_symb_sch %d, nb_dmrs_prb %d, nb_rb %d, nb_rb_oh %d, tb_scaling %d Nl %d\n", __FUNCTION__, nb_symb_sch, nb_dmrs_prb, nb_rb, nb_rb_oh, tb_scaling, Nl); nbp_re = NR_NB_SC_PER_RB * nb_symb_sch - nb_dmrs_prb - nb_rb_oh; nb_re = min(156, nbp_re) * nb_rb; - scale = (R>1024)?11:10; // Intermediate number of information bits - Ninfo = ((nb_re * R * Qm * Nl)>>scale)>>tb_scaling; - + // R is tabulated as 10 times the actual code rate + Ninfo = ((nb_re * R * Qm * Nl / 10)>>10)>>tb_scaling; if (Ninfo <=3824) { n = max(3, floor(log2(Ninfo)) - 6); @@ -73,7 +72,7 @@ uint32_t nr_compute_tbs(uint16_t Qm, n = log2(Ninfo-24)-5; Np_info = max(3840, (ROUNDIDIV((Ninfo-24),(1<>10; if (Ninfo <=3824) { - n = max(3, floor(log2(Ninfo)) - 6); - Np_info = max(24, (Ninfo>>n)<= Np_info){ - nr_tbs = Tbstable_nr[i]; - break; - } - } + n = max(3, floor(log2(Ninfo)) - 6); + Np_info = max(24, (Ninfo>>n)<= Np_info){ + nr_tbs = Tbstable_nr[i]; + break; + } + } } else { - n = log2(Ninfo-24)-5; - Np_info = max(3840, (ROUNDIDIV((Ninfo-24),(1< 8424){ - C = CEILIDIV((Np_info+24),8424); - nr_tbs = (C<<3)*CEILIDIV((Np_info+24),(C<<3)) - 24; - } - else { - nr_tbs = ((CEILIDIV((Np_info+24),8))<<3) - 24; - } - - } + n = log2(Ninfo-24)-5; + Np_info = max(3840, (ROUNDIDIV((Ninfo-24),(1< 8424){ + C = CEILIDIV((Np_info+24),8424); + nr_tbs = (C<<3)*CEILIDIV((Np_info+24),(C<<3)) - 24; + } + else + nr_tbs = ((CEILIDIV((Np_info+24),8))<<3) - 24; + } } return nr_tbs; } diff --git a/openair2/LAYER2/NR_MAC_COMMON/nr_mac.h b/openair2/LAYER2/NR_MAC_COMMON/nr_mac.h index ba3128923f..9123afd324 100644 --- a/openair2/LAYER2/NR_MAC_COMMON/nr_mac.h +++ b/openair2/LAYER2/NR_MAC_COMMON/nr_mac.h @@ -39,6 +39,7 @@ #include #include "NR_SubcarrierSpacing.h" +#include "openair1/SCHED_NR_UE/harq_nr.h" #define NR_SHORT_BSR_TABLE_SIZE 32 #define NR_LONG_BSR_TABLE_SIZE 256 @@ -106,11 +107,10 @@ typedef struct { } __attribute__ ((__packed__)) NR_MAC_SUBHEADER_SHORT; typedef struct { - uint8_t LCID: 6; // octet 1 [5:0] - uint8_t F: 1; // octet 1 [6] - uint8_t R: 1; // octet 1 [7] - uint8_t L1: 8; // octet 2 [7:0] - uint8_t L2: 8; // octet 3 [7:0] + uint8_t LCID: 6; + uint8_t F: 1; + uint8_t R: 1; + uint16_t L: 16; } __attribute__ ((__packed__)) NR_MAC_SUBHEADER_LONG; typedef struct { @@ -118,6 +118,23 @@ typedef struct { uint8_t R: 2; // octet 1 [7:6] } __attribute__ ((__packed__)) NR_MAC_SUBHEADER_FIXED; +static inline int get_mac_len(uint8_t* pdu, int pdu_len, uint16_t *mac_ce_len, uint16_t *mac_subheader_len) { + if ( pdu_len < sizeof(NR_MAC_SUBHEADER_SHORT)) + return false; + NR_MAC_SUBHEADER_SHORT *s = (NR_MAC_SUBHEADER_SHORT*) pdu; + NR_MAC_SUBHEADER_LONG *l = (NR_MAC_SUBHEADER_LONG*) pdu; + if (s->F && pdu_len < sizeof(NR_MAC_SUBHEADER_LONG)) + return false; + if (s->F) { + *mac_subheader_len = sizeof(*l); + *mac_ce_len = ntohs(l->L); + } else { + *mac_subheader_len = sizeof(*s); + *mac_ce_len = s->L; + } + return true; +} + // BSR MAC CEs // TS 38.321 ch. 6.1.3.1 // Short BSR for a specific logical channel group ID @@ -264,14 +281,29 @@ typedef struct { uint8_t nbits; } dci_field_t; +typedef struct { + /* The active harq sfn/slot field was created to save the + scheduled SFN/Slot transmission for the ACK/NAK. If we + do not save it, then we have to calculate it again as the + NRUE MAC layer already does in get_downlink_ack(). */ + int active_dl_harq_sfn; + int active_dl_harq_slot; + int active_ul_harq_sfn_slot; + bool active; +} emul_l1_harq_t; + typedef struct { bool expected_sib; - bool index_has_sib[16]; + bool index_has_sib[NR_MAX_HARQ_PROCESSES]; bool expected_rar; - bool index_has_rar[16]; + bool index_has_rar[NR_MAX_HARQ_PROCESSES]; bool expected_dci; - bool index_has_dci[16]; - int active_harq_sfn_slot; + bool index_has_dci[NR_MAX_HARQ_PROCESSES]; + emul_l1_harq_t harq[NR_MAX_HARQ_PROCESSES]; + int active_uci_sfn_slot; + int num_srs; + int num_harqs; + int num_csi_reports; } nr_emulated_l1_t; typedef struct { diff --git a/openair2/LAYER2/NR_MAC_COMMON/nr_mac_common.c b/openair2/LAYER2/NR_MAC_COMMON/nr_mac_common.c index 94b7ab18bf..5d6f9a2f2e 100644 --- a/openair2/LAYER2/NR_MAC_COMMON/nr_mac_common.c +++ b/openair2/LAYER2/NR_MAC_COMMON/nr_mac_common.c @@ -33,6 +33,7 @@ #include "LAYER2/NR_MAC_gNB/mac_proto.h" #include "common/utils/nr/nr_common.h" #include +#include #define reserved 0xffff @@ -1685,7 +1686,7 @@ int get_nr_prach_info_from_index(uint8_t index, } if ( (s_map>>subframe)&0x01 ) { *N_RA_slot = table_6_3_3_2_3_prachConfig_Index[index][6]; // Number of RACH slots within a subframe - if (mu == 1) { + if (mu == 1 && index >= 67) { if ( (*N_RA_slot <= 1) && (slot%2 == 0) ) return 0; // no prach in even slots @ 30kHz for 1 prach per subframe } @@ -2094,17 +2095,15 @@ void nr_get_tbs_dl(nfapi_nr_dl_tti_pdsch_pdu *pdsch_pdu, uint16_t N_RE_prime = NR_NB_SC_PER_RB*N_sh_symb - N_PRB_DMRS*dmrs_length - N_PRB_oh; LOG_D(MAC, "N_RE_prime %d for %d symbols %d DMRS per PRB and %d overhead\n", N_RE_prime, N_sh_symb, N_PRB_DMRS, N_PRB_oh); - uint16_t R; uint32_t TBS=0; - uint8_t table_idx, Qm; /*uint8_t mcs_table = config.pdsch_config.mcs_table.value; uint8_t ss_type = params_rel15.search_space_type; uint8_t dci_format = params_rel15.dci_format; get_table_idx(mcs_table, dci_format, rnti_type, ss_type);*/ - table_idx = 0; - R = nr_get_code_rate_dl(Imcs, table_idx); - Qm = nr_get_Qm_dl(Imcs, table_idx); + uint8_t table_idx = 0; + uint16_t R = nr_get_code_rate_dl(Imcs, table_idx); + uint8_t Qm = nr_get_Qm_dl(Imcs, table_idx); TBS = nr_compute_tbs(Qm, R, @@ -2125,25 +2124,25 @@ void nr_get_tbs_dl(nfapi_nr_dl_tti_pdsch_pdu *pdsch_pdu, TBS, N_PRB_DMRS, N_sh_symb, N_PRB_oh, R, Qm, table_idx,N_RE_prime*pdsch_rel15->rbSize*pdsch_rel15->NrOfCodewords ); } +// the following tables contain 10 times the value reported in 214 (in line with SCF specification and to avoid fractional values) //Table 5.1.3.1-1 of 38.214 -uint16_t Table_51311[29][2] = {{2,120},{2,157},{2,193},{2,251},{2,308},{2,379},{2,449},{2,526},{2,602},{2,679},{4,340},{4,378},{4,434},{4,490},{4,553},{4,616}, - {4,658},{6,438},{6,466},{6,517},{6,567},{6,616},{6,666},{6,719},{6,772},{6,822},{6,873}, {6,910}, {6,948}}; +uint16_t Table_51311[29][2] = {{2,1200},{2,1570},{2,1930},{2,2510},{2,3080},{2,3790},{2,4490},{2,5260},{2,6020},{2,6790},{4,3400},{4,3780},{4,4340},{4,4900},{4,5530},{4,6160}, + {4,6580},{6,4380},{6,4660},{6,5170},{6,5670},{6,6160},{6,6660},{6,7190},{6,7720},{6,8220},{6,8730}, {6,9100}, {6,9480}}; //Table 5.1.3.1-2 of 38.214 // Imcs values 20 and 26 have been multiplied by 2 to avoid the floating point -uint16_t Table_51312[28][2] = {{2,120},{2,193},{2,308},{2,449},{2,602},{4,378},{4,434},{4,490},{4,553},{4,616},{4,658},{6,466},{6,517},{6,567},{6,616},{6,666}, - {6,719},{6,772},{6,822},{6,873},{8,1365},{8,711},{8,754},{8,797},{8,841},{8,885},{8,1833},{8,948}}; +uint16_t Table_51312[28][2] = {{2,1200},{2,1930},{2,3080},{2,4490},{2,6020},{4,3780},{4,4340},{4,4900},{4,5530},{4,6160},{4,6580},{6,4660},{6,5170},{6,5670},{6,6160},{6,6660}, + {6,7190},{6,7720},{6,8220},{6,8730},{8,6825},{8,7110},{8,7540},{8,7970},{8,8410},{8,8850},{8,9165},{8,9480}}; //Table 5.1.3.1-3 of 38.214 -uint16_t Table_51313[29][2] = {{2,30},{2,40},{2,50},{2,64},{2,78},{2,99},{2,120},{2,157},{2,193},{2,251},{2,308},{2,379},{2,449},{2,526},{2,602},{4,340}, - {4,378},{4,434},{4,490},{4,553},{4,616},{6,438},{6,466},{6,517},{6,567},{6,616},{6,666}, {6,719}, {6,772}}; +uint16_t Table_51313[29][2] = {{2,300},{2,400},{2,500},{2,640},{2,780},{2,990},{2,1200},{2,1570},{2,1930},{2,2510},{2,3080},{2,3790},{2,4490},{2,5260},{2,6020},{4,3400}, + {4,3780},{4,4340},{4,4900},{4,5530},{4,6160},{6,4380},{6,4660},{6,5170},{6,5670},{6,6160},{6,6660},{6,7190},{6,7720}}; -uint16_t Table_61411[28][2] = {{2,120},{2,157},{2,193},{2,251},{2,308},{2,379},{2,449},{2,526},{2,602},{2,679},{4,340},{4,378},{4,434},{4,490},{4,553},{4,616}, - {4,658},{6,466},{6,517},{6,567},{6,616},{6,666},{6,719},{6,772},{6,822},{6,873}, {6,910}, {6,948}}; - -uint16_t Table_61412[28][2] = {{2,30},{2,40},{2,50},{2,64},{2,78},{2,99},{2,120},{2,157},{2,193},{2,251},{2,308},{2,379},{2,449},{2,526},{2,602},{2,679}, - {4,378},{4,434},{4,490},{4,553},{4,616},{4,658},{4,699},{4,772},{6,567},{6,616},{6,666}, {6,772}}; +uint16_t Table_61411[28][2] = {{2,1200},{2,1570},{2,1930},{2,2510},{2,3080},{2,3790},{2,4490},{2,5260},{2,6020},{2,6790},{4,3400},{4,3780},{4,4340},{4,4900},{4,5530},{4,6160}, + {4,6580},{6,4660},{6,5170},{6,5670},{6,6160},{6,6660},{6,7190},{6,7720},{6,8220},{6,8730},{6,9100},{6,9480}}; +uint16_t Table_61412[28][2] = {{2,300},{2,400},{2,500},{2,640},{2,780},{2,990},{2,1200},{2,1570},{2,1930},{2,2510},{2,3080},{2,3790},{2,4490},{2,5260},{2,6020},{2,6790}, + {4,3780},{4,4340},{4,4900},{4,5530},{4,6160},{4,6580},{4,6990},{4,7720},{6,5670},{6,6160},{6,6660},{6,7720}}; uint8_t nr_get_Qm_dl(uint8_t Imcs, uint8_t table_idx) { @@ -2590,30 +2589,55 @@ uint8_t get_transformPrecoding(const NR_BWP_UplinkCommon_t *initialUplinkBWP, return -1; } +uint8_t get_pusch_nb_antenna_ports(NR_PUSCH_Config_t *pusch_Config, + NR_SRS_Config_t *srs_config, + dci_field_t srs_resource_indicator) { + + uint8_t n_antenna_port = 1; + if (get_softmodem_params()->phy_test == 1) { + // temporary hack to allow UL-MIMO in phy-test mode without SRS + n_antenna_port = *pusch_Config->maxRank; + } + else { + if(srs_config != NULL && srs_resource_indicator.nbits > 0) { + for(int rs = 0; rs < srs_config->srs_ResourceSetToAddModList->list.count; rs++) { + NR_SRS_ResourceSet_t *srs_resource_set = srs_config->srs_ResourceSetToAddModList->list.array[rs]; + if(srs_resource_set->usage == NR_SRS_ResourceSet__usage_codebook) { + NR_SRS_Resource_t *srs_resource = srs_config->srs_ResourceToAddModList->list.array[srs_resource_indicator.val]; + AssertFatal(srs_resource != NULL,"SRS resource indicated by DCI does not exist\n"); + n_antenna_port = 1<nrofSRS_Ports; + } + } + } + } + return n_antenna_port; +} + uint16_t nr_dci_size(const NR_BWP_DownlinkCommon_t *initialDownlinkBWP, const NR_BWP_UplinkCommon_t *initialUplinkBWP, const NR_CellGroupConfig_t *cg, dci_pdu_rel15_t *dci_pdu, nr_dci_format_t format, - nr_rnti_type_t rnti_type, - uint16_t N_RB, - int bwp_id) { + nr_rnti_type_t rnti_type, + uint16_t N_RB, + int bwp_id, + NR_ControlResourceSetId_t coreset_id, + uint16_t cset0_bwp_size) { uint16_t size = 0; uint16_t numRBG = 0; long rbg_size_config; int num_entries = 0; - int pusch_antenna_ports = 1; // TODO hardcoded number of antenna ports for pusch const NR_BWP_DownlinkDedicated_t *bwpd = NULL; const NR_BWP_UplinkDedicated_t *ubwpd = NULL; const NR_BWP_DownlinkCommon_t *bwpc = NULL; const NR_BWP_UplinkCommon_t *ubwpc = NULL; - const NR_PDSCH_Config_t *pdsch_Config = NULL; - const NR_PUSCH_Config_t *pusch_Config = NULL; - const NR_PUCCH_Config_t *pucch_Config = NULL; - const NR_PDCCH_Config_t *pdcch_Config = NULL; - const NR_SRS_Config_t *srs_config = NULL; + NR_PDSCH_Config_t *pdsch_Config = NULL; + NR_PUSCH_Config_t *pusch_Config = NULL; + NR_PUCCH_Config_t *pucch_Config = NULL; + NR_PDCCH_Config_t *pdcch_Config = NULL; + NR_SRS_Config_t *srs_config = NULL; if(bwp_id > 0) { AssertFatal(cg!=NULL,"Cellgroup is null and bwp_id!=0"); bwpd=cg->spCellConfig->spCellConfigDedicated->downlinkBWP_ToAddModList->list.array[bwp_id-1]->bwp_Dedicated; @@ -2627,15 +2651,17 @@ uint16_t nr_dci_size(const NR_BWP_DownlinkCommon_t *initialDownlinkBWP, srs_config = (ubwpd->srs_Config) ? ubwpd->srs_Config->choice.setup : NULL; } else if (cg){ - bwpd=cg->spCellConfig->spCellConfigDedicated->initialDownlinkBWP; - bwpc=initialDownlinkBWP; - ubwpd=cg->spCellConfig->spCellConfigDedicated->uplinkConfig->initialUplinkBWP; - ubwpc=initialUplinkBWP; - pdsch_Config = (bwpd->pdsch_Config) ? bwpd->pdsch_Config->choice.setup : NULL; - pdcch_Config = (bwpd->pdcch_Config) ? bwpd->pdcch_Config->choice.setup : NULL; - pucch_Config = (ubwpd->pucch_Config) ? ubwpd->pucch_Config->choice.setup : NULL; - pusch_Config = (ubwpd->pusch_Config) ? ubwpd->pusch_Config->choice.setup : NULL; - srs_config = (ubwpd->srs_Config) ? ubwpd->srs_Config->choice.setup: NULL; + bwpc = initialDownlinkBWP; + ubwpc = initialUplinkBWP; + bwpd = cg->spCellConfig && cg->spCellConfig->spCellConfigDedicated ? + cg->spCellConfig->spCellConfigDedicated->initialDownlinkBWP : NULL; + ubwpd = cg->spCellConfig && cg->spCellConfig->spCellConfigDedicated && cg->spCellConfig->spCellConfigDedicated->uplinkConfig ? + cg->spCellConfig->spCellConfigDedicated->uplinkConfig->initialUplinkBWP : NULL; + pdsch_Config = (bwpd && bwpd->pdsch_Config) ? bwpd->pdsch_Config->choice.setup : NULL; + pdcch_Config = (bwpd && bwpd->pdcch_Config) ? bwpd->pdcch_Config->choice.setup : NULL; + pucch_Config = (ubwpd && ubwpd->pucch_Config) ? ubwpd->pucch_Config->choice.setup : NULL; + pusch_Config = (ubwpd && ubwpd->pusch_Config) ? ubwpd->pusch_Config->choice.setup : NULL; + srs_config = (ubwpd && ubwpd->srs_Config) ? ubwpd->srs_Config->choice.setup: NULL; } int n_ul_bwp=1,n_dl_bwp=1; @@ -2645,7 +2671,9 @@ uint16_t nr_dci_size(const NR_BWP_DownlinkCommon_t *initialDownlinkBWP, /// fixed: Format identifier 1, Hop flag 1, MCS 5, NDI 1, RV 2, HARQ PID 4, PUSCH TPC 2 Time Domain assgnmt 4 --20 size += 20; size += (uint8_t)ceil( log2( (N_RB*(N_RB+1))>>1 ) ); // Freq domain assignment -- hopping scenario to be updated - size += nr_dci_size(initialDownlinkBWP,initialUplinkBWP,cg,dci_pdu,NR_DL_DCI_FORMAT_1_0, rnti_type, N_RB, bwp_id) - size; // Padding to match 1_0 size + int dci_10_size = nr_dci_size(initialDownlinkBWP,initialUplinkBWP,cg,dci_pdu,NR_DL_DCI_FORMAT_1_0, rnti_type, N_RB, bwp_id, coreset_id, cset0_bwp_size); + AssertFatal(dci_10_size >= size, "NR_UL_DCI_FORMAT_0_0 size is bigger than NR_DL_DCI_FORMAT_1_0! 3GPP TS 38.212 Section 7.3.1.0: DCI size alignment is not fully implemented"); + size += dci_10_size - size; // Padding to match 1_0 size // UL/SUL indicator assumed to be 0 break; @@ -2768,6 +2796,9 @@ uint16_t nr_dci_size(const NR_BWP_DownlinkCommon_t *initialDownlinkBWP, LOG_D(NR_MAC,"dci_pdu->srs_resource_indicator.nbits %d\n",dci_pdu->srs_resource_indicator.nbits); // Precoding info and number of layers long transformPrecoder = get_transformPrecoding(initialUplinkBWP, pusch_Config, ubwpd, (uint8_t*)&format, rnti_type, 0); + + uint8_t pusch_antenna_ports = get_pusch_nb_antenna_ports(pusch_Config, srs_config, dci_pdu->srs_resource_indicator); + dci_pdu->precoding_information.nbits=0; if (pusch_Config && pusch_Config->txConfig != NULL){ @@ -2863,6 +2894,14 @@ uint16_t nr_dci_size(const NR_BWP_DownlinkCommon_t *initialDownlinkBWP, case NR_DL_DCI_FORMAT_1_0: /// fixed: Format identifier 1, VRB2PRB 1, MCS 5, NDI 1, RV 2, HARQ PID 4, DAI 2, PUCCH TPC 2, PUCCH RInd 3, PDSCH to HARQ TInd 3 Time Domain assgnmt 4 -- 28 + + // 3GPP TS 38.212 Section 7.3.1.0: DCI size alignment + // Size of DCI format 1_0 is given by the size of CORESET 0 if CORESET 0 is configured for the cell and the size + // of initial DL bandwidth part if CORESET 0 is not configured for the cell + if(cset0_bwp_size>0) { + N_RB = cset0_bwp_size; + } + size = 28; size += (uint8_t)ceil( log2( (N_RB*(N_RB+1))>>1 ) ); // Freq domain assignment @@ -2979,10 +3018,15 @@ uint16_t nr_dci_size(const NR_BWP_DownlinkCommon_t *initialDownlinkBWP, size += dci_pdu->antenna_ports.nbits; LOG_D(NR_MAC,"dci_pdu->antenna_ports.nbits %d\n",dci_pdu->antenna_ports.nbits); // Tx Config Indication - long *isTciEnable = pdcch_Config->controlResourceSetToAddModList->list.array[0]->tci_PresentInDCI; - if (isTciEnable != NULL) { - dci_pdu->transmission_configuration_indication.nbits = 3; - size += dci_pdu->transmission_configuration_indication.nbits; + for (int i = 0; i < pdcch_Config->controlResourceSetToAddModList->list.count; i++) { + if (pdcch_Config->controlResourceSetToAddModList->list.array[i]->controlResourceSetId == coreset_id) { + long *isTciEnable = pdcch_Config->controlResourceSetToAddModList->list.array[i]->tci_PresentInDCI; + if (isTciEnable != NULL) { + dci_pdu->transmission_configuration_indication.nbits = 3; + size += dci_pdu->transmission_configuration_indication.nbits; + } + break; + } } // SRS request if (cg->spCellConfig->spCellConfigDedicated->supplementaryUplink==NULL) @@ -3079,7 +3123,7 @@ int is_nr_DL_slot(NR_TDD_UL_DL_ConfigCommon_t *tdd_UL_DL_ConfigurationCommon,slo else return(slot_in_period <= slots1+tdd_UL_DL_ConfigurationCommon->pattern2->nrofDownlinkSlots ? 1 : 0); } -int is_nr_UL_slot(NR_TDD_UL_DL_ConfigCommon_t *tdd_UL_DL_ConfigurationCommon, slot_t slot, lte_frame_type_t frame_type) { +int is_nr_UL_slot(NR_TDD_UL_DL_ConfigCommon_t *tdd_UL_DL_ConfigurationCommon, slot_t slot, frame_type_t frame_type) { int period,period1,period2=0; @@ -3454,6 +3498,22 @@ void csi_period_offset(NR_CSI_ReportConfig_t *csirep, } } +uint32_t get_Y(NR_SearchSpace_t *ss, int slot, rnti_t rnti) { + + if(ss->searchSpaceType->present == NR_SearchSpace__searchSpaceType_PR_common) + return 0; + + const int cid = *ss->controlResourceSetId%3; + const uint32_t A[3] = {39827, 39829, 39839}; + const uint32_t D = 65537; + uint32_t Y; + + Y = (A[cid] * rnti) % D; + for (int s = 0; s < slot; s++) + Y = (A[cid] * Y) % D; + + return Y; +} void get_type0_PDCCH_CSS_config_parameters(NR_Type0_PDCCH_CSS_config_t *type0_PDCCH_CSS_config, frame_t frameP, @@ -3894,25 +3954,17 @@ void fill_searchSpaceZero(NR_SearchSpace_t *ss0, NR_Type0_PDCCH_CSS_config_t *ty if(ss0->searchSpaceType->choice.common->dci_Format0_0_AndFormat1_0 == NULL) ss0->searchSpaceType->choice.common->dci_Format0_0_AndFormat1_0 = calloc(1,sizeof(*ss0->searchSpaceType->choice.common->dci_Format0_0_AndFormat1_0)); - uint32_t duration,periodicity,offset; - uint16_t symbols,max_agg; - AssertFatal(type0_PDCCH_CSS_config!=NULL,"No type0 CSS configuration\n"); - max_agg = (type0_PDCCH_CSS_config->num_symbols*type0_PDCCH_CSS_config->num_rbs)/6; - - symbols = (1-(1<num_symbols))<first_symbol_index; - duration = type0_PDCCH_CSS_config->search_space_duration; - periodicity = type0_PDCCH_CSS_config->search_space_frame_period; - if (type0_PDCCH_CSS_config->type0_pdcch_ss_mux_pattern == 1) - offset = type0_PDCCH_CSS_config->n_0; - else - offset = type0_PDCCH_CSS_config->n_c; + const uint32_t periodicity = type0_PDCCH_CSS_config->search_space_frame_period; + const uint32_t offset = type0_PDCCH_CSS_config->type0_pdcch_ss_mux_pattern == 1 + ? type0_PDCCH_CSS_config->n_0 : type0_PDCCH_CSS_config->n_c; ss0->searchSpaceId = 0; *ss0->controlResourceSetId = 0; ss0->monitoringSlotPeriodicityAndOffset = calloc(1,sizeof(*ss0->monitoringSlotPeriodicityAndOffset)); set_monitoring_periodicity_offset(ss0,periodicity,offset); + const uint32_t duration = type0_PDCCH_CSS_config->search_space_duration; if (duration==1) ss0->duration = NULL; else{ @@ -3920,6 +3972,7 @@ void fill_searchSpaceZero(NR_SearchSpace_t *ss0, NR_Type0_PDCCH_CSS_config_t *ty *ss0->duration = duration; } + const uint16_t symbols = SL_to_bitmap(type0_PDCCH_CSS_config->first_symbol_index, type0_PDCCH_CSS_config->num_symbols); ss0->monitoringSymbolsWithinSlot->size = 2; ss0->monitoringSymbolsWithinSlot->bits_unused = 2; ss0->monitoringSymbolsWithinSlot->buf[1] = 0; @@ -3929,6 +3982,7 @@ void fill_searchSpaceZero(NR_SearchSpace_t *ss0, NR_Type0_PDCCH_CSS_config_t *ty ss0->monitoringSymbolsWithinSlot->buf[0] |= ((symbols>>i)&0x01)<<(7-i); } + const uint16_t max_agg = (type0_PDCCH_CSS_config->num_symbols*type0_PDCCH_CSS_config->num_rbs)/6; // max values are set according to TS38.213 Section 10.1 Table 10.1-1 ss0->nrofCandidates->aggregationLevel1 = NR_SearchSpace__nrofCandidates__aggregationLevel1_n0; ss0->nrofCandidates->aggregationLevel2 = NR_SearchSpace__nrofCandidates__aggregationLevel2_n0; @@ -4057,8 +4111,6 @@ uint16_t compute_pucch_prb_size(uint8_t format, if ((O_tot+O_csi)>(nr_prbs*n_re_ctrl*n_symb*Qm*r)) AssertFatal(1==0,"MaxCodeRate %.2f can't support %d UCI bits and %d CRC bits with %d PRBs", r,O_tot,O_crc,nr_prbs); - else - return nr_prbs; } if (format==2){ @@ -4076,6 +4128,25 @@ uint16_t compute_pucch_prb_size(uint8_t format, } } +int get_bw_tbslbrm(NR_BWP_t *genericParameters, + NR_CellGroupConfig_t *cg) { + + int bw = 0; + if (cg && cg->spCellConfig && cg->spCellConfig->spCellConfigDedicated && + cg->spCellConfig->spCellConfigDedicated->downlinkBWP_ToAddModList) { + struct NR_ServingCellConfig__downlinkBWP_ToAddModList *BWP_list = cg->spCellConfig->spCellConfigDedicated->downlinkBWP_ToAddModList; + for (int i=0; ilist.count; i++) { + genericParameters = &BWP_list->list.array[i]->bwp_Common->genericParameters; + int curr_bw = NRRIV2BW(genericParameters->locationAndBandwidth, MAX_BWP_SIZE); + if (curr_bw > bw) + bw = curr_bw; + } + } + else + bw = NRRIV2BW(genericParameters->locationAndBandwidth, MAX_BWP_SIZE); + return bw; +} + /* extract UL PTRS values from RRC and validate it based upon 38.214 6.2.3 */ bool set_ul_ptrs_values(NR_PTRS_UplinkConfig_t *ul_ptrs_config, uint16_t rbSize,uint8_t mcsIndex, uint8_t mcsTable, diff --git a/openair2/LAYER2/NR_MAC_COMMON/nr_mac_common.h b/openair2/LAYER2/NR_MAC_COMMON/nr_mac_common.h index c150c4f134..6caddcff78 100644 --- a/openair2/LAYER2/NR_MAC_COMMON/nr_mac_common.h +++ b/openair2/LAYER2/NR_MAC_COMMON/nr_mac_common.h @@ -37,6 +37,8 @@ #include "nr_mac.h" #include "openair1/PHY/impl_defs_nr.h" +uint32_t get_Y(NR_SearchSpace_t *ss, int slot, rnti_t rnti); + uint64_t from_nrarfcn(int nr_bandP, uint8_t scs_index, uint32_t dl_nrarfcn); uint32_t to_nrarfcn(int nr_bandP, uint64_t dl_CarrierFreq, uint8_t scs_index, uint32_t bw); @@ -45,7 +47,7 @@ int16_t fill_dmrs_mask(NR_PDSCH_Config_t *pdsch_Config,int dmrs_TypeA_Position,i int is_nr_DL_slot(NR_TDD_UL_DL_ConfigCommon_t *tdd_UL_DL_ConfigurationCommon,slot_t slotP); -int is_nr_UL_slot(NR_TDD_UL_DL_ConfigCommon_t *tdd_UL_DL_ConfigurationCommon, slot_t slotP, lte_frame_type_t frame_type); +int is_nr_UL_slot(NR_TDD_UL_DL_ConfigCommon_t *tdd_UL_DL_ConfigurationCommon, slot_t slotP, frame_type_t frame_type); uint16_t nr_dci_size(const NR_BWP_DownlinkCommon_t *initialDLBWP, const NR_BWP_UplinkCommon_t *initialULBWP, @@ -54,7 +56,9 @@ uint16_t nr_dci_size(const NR_BWP_DownlinkCommon_t *initialDLBWP, nr_dci_format_t format, nr_rnti_type_t rnti_type, uint16_t N_RB, - int bwp_id); + int bwp_id, + NR_ControlResourceSetId_t coreset_id, + uint16_t cset0_bwp_size); void find_aggregation_candidates(uint8_t *aggregation_level, uint8_t *nr_of_candidates, @@ -119,8 +123,32 @@ int32_t get_l_prime(uint8_t duration_in_symbols, uint8_t mapping_type, pusch_dmr uint8_t get_L_ptrs(uint8_t mcs1, uint8_t mcs2, uint8_t mcs3, uint8_t I_mcs, uint8_t mcs_table); uint8_t get_K_ptrs(uint16_t nrb0, uint16_t nrb1, uint16_t N_RB); +uint32_t nr_compute_tbs(uint16_t Qm, + uint16_t R, + uint16_t nb_rb, + uint16_t nb_symb_sch, + uint16_t nb_dmrs_prb, + uint16_t nb_rb_oh, + uint8_t tb_scaling, + uint8_t Nl); + +/** \brief Computes Q based on I_MCS PDSCH and table_idx for downlink. Implements MCS Tables from 38.214. */ +uint8_t nr_get_Qm_dl(uint8_t Imcs, uint8_t table_idx); +uint32_t nr_get_code_rate_dl(uint8_t Imcs, uint8_t table_idx); + +/** \brief Computes Q based on I_MCS PDSCH and table_idx for uplink. Implements MCS Tables from 38.214. */ +uint8_t nr_get_Qm_ul(uint8_t Imcs, uint8_t table_idx); +uint32_t nr_get_code_rate_ul(uint8_t Imcs, uint8_t table_idx); + uint16_t get_nr_srs_offset(NR_SRS_PeriodicityAndOffset_t periodicityAndOffset); +int get_bw_tbslbrm(NR_BWP_t *genericParameters, + NR_CellGroupConfig_t *cg); + +uint32_t nr_compute_tbslbrm(uint16_t table, + uint16_t nb_rb, + uint8_t Nl); + void get_type0_PDCCH_CSS_config_parameters(NR_Type0_PDCCH_CSS_config_t *type0_PDCCH_CSS_config, frame_t frameP, NR_MIB_t *mib, @@ -147,6 +175,10 @@ void get_info_from_tda_tables(int default_abc, void fill_coresetZero(NR_ControlResourceSet_t *coreset0, NR_Type0_PDCCH_CSS_config_t *type0_PDCCH_CSS_config); void fill_searchSpaceZero(NR_SearchSpace_t *ss0, NR_Type0_PDCCH_CSS_config_t *type0_PDCCH_CSS_config); +uint8_t get_pusch_nb_antenna_ports(NR_PUSCH_Config_t *pusch_Config, + NR_SRS_Config_t *srs_config, + dci_field_t srs_resource_indicator); + uint16_t compute_pucch_prb_size(uint8_t format, uint8_t nr_prbs, uint16_t O_tot, diff --git a/openair2/LAYER2/NR_MAC_UE/config_ue.c b/openair2/LAYER2/NR_MAC_UE/config_ue.c index 3b10167e03..b0d41f317b 100644 --- a/openair2/LAYER2/NR_MAC_UE/config_ue.c +++ b/openair2/LAYER2/NR_MAC_UE/config_ue.c @@ -323,7 +323,7 @@ void config_common_ue(NR_UE_MAC_INST_t *mac, uint32_t band = *scc->downlinkConfigCommon->frequencyInfoDL->frequencyBandList.list.array[0]; mac->frequency_range = band<100?FR1:FR2; - lte_frame_type_t frame_type = get_frame_type(*scc->downlinkConfigCommon->frequencyInfoDL->frequencyBandList.list.array[0], *scc->ssbSubcarrierSpacing); + frame_type_t frame_type = get_frame_type(*scc->downlinkConfigCommon->frequencyInfoDL->frequencyBandList.list.array[0], *scc->ssbSubcarrierSpacing); // cell config @@ -434,19 +434,24 @@ void config_bwp_ue(NR_UE_MAC_INST_t *mac, uint16_t *bwp_ind, uint8_t *dci_format NR_ServingCellConfig_t *scd = mac->cg->spCellConfig->spCellConfigDedicated; - if (bwp_ind && dci_format){ + int n_ubwp = 0; + if (scd && scd->uplinkConfig && + scd->uplinkConfig->uplinkBWP_ToAddModList) + n_ubwp = scd->uplinkConfig->uplinkBWP_ToAddModList->list.count; + if (bwp_ind && dci_format){ switch(*dci_format){ case NR_UL_DCI_FORMAT_0_1: - mac->UL_BWP_Id = *bwp_ind; + mac->UL_BWP_Id = n_ubwp < 4 ? *bwp_ind : *bwp_ind + 1; break; case NR_DL_DCI_FORMAT_1_1: - mac->DL_BWP_Id = *bwp_ind; + mac->DL_BWP_Id = n_ubwp < 4 ? *bwp_ind : *bwp_ind + 1; break; default: LOG_E(MAC, "In %s: failed to configure BWP Id from DCI with format %d \n", __FUNCTION__, *dci_format); } - + // configure ss coreset after switching BWP + configure_ss_coreset(mac, scd, mac->DL_BWP_Id); } else { if (scd->firstActiveDownlinkBWP_Id) @@ -474,82 +479,96 @@ void config_bwp_ue(NR_UE_MAC_INST_t *mac, uint16_t *bwp_ind, uint8_t *dci_format */ void config_control_ue(NR_UE_MAC_INST_t *mac){ - uint8_t coreset_id = 1, ss_id; - NR_BWP_Id_t dl_bwp_id = mac->DL_BWP_Id; - NR_BWP_Id_t ul_bwp_id = mac->UL_BWP_Id; + int bwp_id; NR_ServingCellConfig_t *scd = mac->cg->spCellConfig->spCellConfigDedicated; - if (dl_bwp_id==0) AssertFatal(mac->scc_SIB,"dl_bwp_id 0 (DL %d,UL %d) means mac->scc_SIB should exist here!\n",(int)mac->DL_BWP_Id,(int)mac->UL_BWP_Id); - NR_BWP_DownlinkCommon_t *bwp_Common = dl_bwp_id>0 ? scd->downlinkBWP_ToAddModList->list.array[dl_bwp_id - 1]->bwp_Common : - &mac->scc_SIB->downlinkConfigCommon.initialDownlinkBWP; + config_bwp_ue(mac, NULL, NULL); + NR_BWP_Id_t dl_bwp_id = mac->DL_BWP_Id; - - if (dl_bwp_id > 0 ) { - AssertFatal(scd->downlinkBWP_ToAddModList != NULL, "downlinkBWP_ToAddModList is null\n"); - AssertFatal(scd->downlinkBWP_ToAddModList->list.count == 1, "downlinkBWP_ToAddModList->list->count is %d\n", scd->downlinkBWP_ToAddModList->list.count); + // configure DLbwp + if (scd->downlinkBWP_ToAddModList) { + for (int i = 0; i < scd->downlinkBWP_ToAddModList->list.count; i++) { + bwp_id = scd->downlinkBWP_ToAddModList->list.array[i]->bwp_Id; + mac->DLbwp[bwp_id-1] = scd->downlinkBWP_ToAddModList->list.array[i]; + } } + + // configure ULbwp + if (scd->uplinkConfig->uplinkBWP_ToAddModList) { + for (int i = 0; i < scd->uplinkConfig->uplinkBWP_ToAddModList->list.count; i++) { + bwp_id = scd->uplinkConfig->uplinkBWP_ToAddModList->list.array[i]->bwp_Id; + mac->ULbwp[bwp_id-1] = scd->uplinkConfig->uplinkBWP_ToAddModList->list.array[i]; + } + } + + configure_ss_coreset(mac, scd, dl_bwp_id); +} + + +void configure_ss_coreset(NR_UE_MAC_INST_t *mac, + NR_ServingCellConfig_t *scd, + NR_BWP_Id_t dl_bwp_id) { + + NR_BWP_DownlinkCommon_t *bwp_Common = get_bwp_downlink_common(mac, dl_bwp_id); + AssertFatal(bwp_Common != NULL, "bwp_Common is null\n"); + + NR_SetupRelease_PDCCH_ConfigCommon_t *pdcch_ConfigCommon = bwp_Common->pdcch_ConfigCommon; + AssertFatal(pdcch_ConfigCommon != NULL, "pdcch_ConfigCommon is null\n"); + + // configuring eventual common coreset + NR_ControlResourceSet_t *coreset = pdcch_ConfigCommon->choice.setup->commonControlResourceSet; + if (coreset) + mac->coreset[dl_bwp_id][coreset->controlResourceSetId - 1] = coreset; + NR_BWP_DownlinkDedicated_t *dl_bwp_Dedicated = dl_bwp_id>0 ? scd->downlinkBWP_ToAddModList->list.array[dl_bwp_id - 1]->bwp_Dedicated: scd->initialDownlinkBWP; + AssertFatal(dl_bwp_Dedicated != NULL, "dl_bwp_Dedicated is null\n"); - config_bwp_ue(mac, NULL, NULL); NR_SetupRelease_PDCCH_Config_t *pdcch_Config = dl_bwp_Dedicated->pdcch_Config; AssertFatal(pdcch_Config != NULL, "pdcch_Config is null\n"); - NR_SetupRelease_PDCCH_ConfigCommon_t *pdcch_ConfigCommon = bwp_Common->pdcch_ConfigCommon; - AssertFatal(pdcch_ConfigCommon != NULL, "pdcch_ConfigCommon is null\n"); - AssertFatal(pdcch_ConfigCommon->choice.setup->ra_SearchSpace != NULL, "ra_SearchSpace must be available in DL BWP\n"); - - struct NR_PDCCH_ConfigCommon__commonSearchSpaceList *commonSearchSpaceList = pdcch_ConfigCommon->choice.setup->commonSearchSpaceList; - AssertFatal(commonSearchSpaceList != NULL, "commonSearchSpaceList is null\n"); - AssertFatal(commonSearchSpaceList->list.count > 0, "PDCCH CSS list has 0 elements\n"); - struct NR_PDCCH_Config__controlResourceSetToAddModList *controlResourceSetToAddModList = pdcch_Config->choice.setup->controlResourceSetToAddModList; AssertFatal(controlResourceSetToAddModList != NULL, "controlResourceSetToAddModList is null\n"); - AssertFatal(controlResourceSetToAddModList->list.count == 1, "controlResourceSetToAddModList->list.count=%d\n", controlResourceSetToAddModList->list.count); - AssertFatal(controlResourceSetToAddModList->list.array[0] != NULL, "coreset[0][0] is null\n"); + + // configuring dedicated coreset + // In case network reconfigures control resource set with the same ControlResourceSetId as used for commonControlResourceSet configured via PDCCH-ConfigCommon, + // the configuration from PDCCH-Config always takes precedence + for (int i=0; ilist.count; i++) { + coreset = controlResourceSetToAddModList->list.array[i]; + mac->coreset[dl_bwp_id][coreset->controlResourceSetId - 1] = coreset; + } struct NR_PDCCH_Config__searchSpacesToAddModList *searchSpacesToAddModList = pdcch_Config->choice.setup->searchSpacesToAddModList; AssertFatal(searchSpacesToAddModList != NULL, "searchSpacesToAddModList is null\n"); AssertFatal(searchSpacesToAddModList->list.count > 0, "list of UE specifically configured Search Spaces is empty\n"); - AssertFatal(searchSpacesToAddModList->list.count < FAPI_NR_MAX_SS, "too many searchpaces per coreset %d\n", searchSpacesToAddModList->list.count); - - struct NR_UplinkConfig__uplinkBWP_ToAddModList *uplinkBWP_ToAddModList = scd->uplinkConfig->uplinkBWP_ToAddModList; - if (ul_bwp_id > 0) { - AssertFatal(uplinkBWP_ToAddModList != NULL, "uplinkBWP_ToAddModList is null\n"); - AssertFatal(uplinkBWP_ToAddModList->list.count == 1, "uplinkBWP_ToAddModList->list->count is %d\n", uplinkBWP_ToAddModList->list.count); - } - // check pdcch_Config, pdcch_ConfigCommon and DL BWP - mac->DLbwp[0] = dl_bwp_id>0?scd->downlinkBWP_ToAddModList->list.array[dl_bwp_id - 1]:NULL; - mac->coreset[dl_bwp_id][coreset_id - 1] = controlResourceSetToAddModList->list.array[0]; - - // Check dedicated UL BWP and pass to MAC - mac->ULbwp[0] = ul_bwp_id>0?uplinkBWP_ToAddModList->list.array[0]:NULL; - if (mac->ULbwp[0]) AssertFatal(mac->ULbwp[0]->bwp_Dedicated != NULL, "UL bwp_Dedicated is null\n"); + AssertFatal(searchSpacesToAddModList->list.count < FAPI_NR_MAX_SS_PER_BWP, "too many searchpaces per coreset %d\n", searchSpacesToAddModList->list.count); // check available Search Spaces in the searchSpacesToAddModList and pass to MAC // note: the network configures at most 10 Search Spaces per BWP per cell (including UE-specific and common Search Spaces). - for (ss_id = 0; ss_id < searchSpacesToAddModList->list.count; ss_id++) { + for (int ss_id = 0; ss_id < searchSpacesToAddModList->list.count; ss_id++) { NR_SearchSpace_t *ss = searchSpacesToAddModList->list.array[ss_id]; AssertFatal(ss->controlResourceSetId != NULL, "ss->controlResourceSetId is null\n"); AssertFatal(ss->searchSpaceType != NULL, "ss->searchSpaceType is null\n"); - AssertFatal(*ss->controlResourceSetId == mac->coreset[dl_bwp_id][coreset_id - 1]->controlResourceSetId, "ss->controlResourceSetId is unknown\n"); AssertFatal(ss->monitoringSymbolsWithinSlot != NULL, "NR_SearchSpace->monitoringSymbolsWithinSlot is null\n"); AssertFatal(ss->monitoringSymbolsWithinSlot->buf != NULL, "NR_SearchSpace->monitoringSymbolsWithinSlot->buf is null\n"); - mac->SSpace[dl_bwp_id][ss_id] = ss; + AssertFatal(ss->searchSpaceId <= FAPI_NR_MAX_SS, "Invalid searchSpaceId\n"); + mac->SSpace[dl_bwp_id][ss->searchSpaceId - 1] = ss; } + struct NR_PDCCH_ConfigCommon__commonSearchSpaceList *commonSearchSpaceList = pdcch_ConfigCommon->choice.setup->commonSearchSpaceList; + AssertFatal(commonSearchSpaceList != NULL, "commonSearchSpaceList is null\n"); + AssertFatal(commonSearchSpaceList->list.count > 0, "PDCCH CSS list has 0 elements\n"); + // Check available CSSs in the commonSearchSpaceList (list of additional common search spaces) // note: commonSearchSpaceList SIZE(1..4) for (int css_id = 0; css_id < commonSearchSpaceList->list.count; css_id++) { NR_SearchSpace_t *css = commonSearchSpaceList->list.array[css_id]; AssertFatal(css->controlResourceSetId != NULL, "ss->controlResourceSetId is null\n"); - AssertFatal(*css->controlResourceSetId == 0 || *css->controlResourceSetId == mac->coreset[dl_bwp_id][coreset_id - 1]->controlResourceSetId, "css->controlResourceSetId %ld is unknown, mac->coreset[%ld][%d]->controlResourceSetId %ld\n",*css->controlResourceSetId,dl_bwp_id,coreset_id-1,mac->coreset[dl_bwp_id][coreset_id - 1]->controlResourceSetId); - AssertFatal(css->searchSpaceType != NULL, "css->searchSpaceType is null\n"); AssertFatal(css->monitoringSymbolsWithinSlot != NULL, "css->monitoringSymbolsWithinSlot is null\n"); AssertFatal(css->monitoringSymbolsWithinSlot->buf != NULL, "css->monitoringSymbolsWithinSlot->buf is null\n"); - mac->SSpace[dl_bwp_id][ss_id] = css; - ss_id++; + AssertFatal(css->searchSpaceId <= FAPI_NR_MAX_SS, "Invalid searchSpaceId\n"); + mac->SSpace[dl_bwp_id][css->searchSpaceId - 1] = css; } } diff --git a/openair2/LAYER2/NR_MAC_UE/mac_defs.h b/openair2/LAYER2/NR_MAC_UE/mac_defs.h index ad86b1385d..800e042464 100644 --- a/openair2/LAYER2/NR_MAC_UE/mac_defs.h +++ b/openair2/LAYER2/NR_MAC_UE/mac_defs.h @@ -74,7 +74,7 @@ // ========== #define NB_NR_UE_MAC_INST 1 -#define MAX_NUM_BWP 2 +#define MAX_NUM_BWP_UE 4 #define NUM_SLOT_FRAME 10 /*!\brief value for indicating BSR Timer is not running */ @@ -364,12 +364,12 @@ typedef struct { NR_RNTI_Value_t *cs_RNTI; NR_MIB_t *mib; - NR_BWP_Downlink_t *DLbwp[MAX_NUM_BWP]; - NR_BWP_Uplink_t *ULbwp[MAX_NUM_BWP]; - NR_ControlResourceSet_t *coreset[MAX_NUM_BWP][FAPI_NR_MAX_CORESET_PER_BWP]; - NR_SearchSpace_t *SSpace[MAX_NUM_BWP][FAPI_NR_MAX_SS]; + NR_BWP_Downlink_t *DLbwp[MAX_NUM_BWP_UE]; + NR_BWP_Uplink_t *ULbwp[MAX_NUM_BWP_UE]; + NR_ControlResourceSet_t *coreset[MAX_NUM_BWP_UE][FAPI_NR_MAX_CORESET_PER_BWP]; + NR_SearchSpace_t *SSpace[MAX_NUM_BWP_UE][FAPI_NR_MAX_SS]; - lte_frame_type_t frame_type; + frame_type_t frame_type; /*BWP*/ // dedicated active DL BWP @@ -432,7 +432,7 @@ typedef struct { // Defined for abstracted mode nr_downlink_indication_t dl_info; - NR_UE_HARQ_STATUS_t dl_harq_info[16]; + NR_UE_HARQ_STATUS_t dl_harq_info[NR_MAX_HARQ_PROCESSES]; nr_emulated_l1_t nr_ue_emul_l1; @@ -558,7 +558,6 @@ typedef struct ssb_list_info { } ssb_list_info_t; void config_dci_pdu(NR_UE_MAC_INST_t *mac, fapi_nr_dl_config_dci_dl_pdu_rel15_t *rel15, fapi_nr_dl_config_request_t *dl_config, int rnti_type, int ss_id); -void fill_dci_search_candidates(NR_SearchSpace_t *ss,fapi_nr_dl_config_dci_dl_pdu_rel15_t *rel15); /*@}*/ #endif /*__LAYER2_MAC_DEFS_H__ */ diff --git a/openair2/LAYER2/NR_MAC_UE/mac_proto.h b/openair2/LAYER2/NR_MAC_UE/mac_proto.h index 3e4d53b985..caa4af4144 100644 --- a/openair2/LAYER2/NR_MAC_UE/mac_proto.h +++ b/openair2/LAYER2/NR_MAC_UE/mac_proto.h @@ -48,6 +48,7 @@ void nr_ue_init_mac(module_id_t module_idP); \param module_id module id \param cc_id component carrier id \param gNB_index gNB index + \param phy_data PHY structure to be filled in by the callee in the FAPI call (L1 caller -> indication to L2 -> FAPI call to L1 callee) \param extra_bits extra bits for frame calculation \param l_ssb_equal_64 check if ssb number of candicate is equal 64, 1=equal; 0=non equal. Reference 38.212 7.1.1 \param pduP pointer to pdu @@ -56,7 +57,8 @@ void nr_ue_init_mac(module_id_t module_idP); int8_t nr_ue_decode_mib( module_id_t module_id, int cc_id, - uint8_t gNB_index, + uint8_t gNB_index, + void *phy_data, uint8_t extra_bits, uint32_t ssb_length, uint32_t ssb_index, @@ -132,7 +134,7 @@ NR_UE_L2_STATE_t nr_ue_scheduler(nr_downlink_indication_t *dl_info, nr_uplink_in @param int cc_id CC ID @param frame_t frame frame number @param int slot reference number - @param UE_nr_rxtx_proc_t *proc pointer to process context */ + @param void *phy_pata pointer to a PHY specific structure to be filled in the scheduler response (can be null) */ void fill_scheduled_response(nr_scheduled_response_t *scheduled_response, fapi_nr_dl_config_request_t *dl_config, fapi_nr_ul_config_request_t *ul_config, @@ -141,7 +143,8 @@ void fill_scheduled_response(nr_scheduled_response_t *scheduled_response, int cc_id, frame_t frame, int slot, - int thread_id); + int thread_id, + void *phy_data); /*! \fn int8_t nr_ue_get_SR(module_id_t module_idP, frame_t frameP, slot_t slotP); \brief Called by PHY to get sdu for PUSCH transmission. It performs the following operations: Checks BSR for DCCH, DCCH1 and DTCH corresponding to previous values computed either in SR or BSR procedures. It gets rlc status indications on DCCH,DCCH1 and DTCH and forms BSR elements and PHR in MAC header. CRNTI element is not supported yet. It computes transport block for up to 3 SDUs and generates header and forms the complete MAC SDU. @@ -240,10 +243,7 @@ int nr_write_ce_ulsch_pdu(uint8_t *mac_ce, uint16_t *crnti, NR_BSR_SHORT *truncated_bsr, NR_BSR_SHORT *short_bsr, - NR_BSR_LONG *long_bsr - ); - -void fill_dci_search_candidates(NR_SearchSpace_t *ss,fapi_nr_dl_config_dci_dl_pdu_rel15_t *rel15); + NR_BSR_LONG *long_bsr); void config_dci_pdu(NR_UE_MAC_INST_t *mac, fapi_nr_dl_config_dci_dl_pdu_rel15_t *rel15, fapi_nr_dl_config_request_t *dl_config, int rnti_type, int ss_id); @@ -257,6 +257,8 @@ void get_bwp_info(NR_UE_MAC_INST_t *mac, NR_BWP_UplinkDedicated_t **ubwpd, NR_BWP_UplinkCommon_t **ubwpc); +NR_BWP_DownlinkCommon_t *get_bwp_downlink_common(NR_UE_MAC_INST_t *mac, NR_BWP_Id_t dl_bwp_id); + uint8_t nr_extract_dci_info(NR_UE_MAC_INST_t *mac, uint8_t dci_format, uint8_t dci_length, @@ -264,7 +266,7 @@ uint8_t nr_extract_dci_info(NR_UE_MAC_INST_t *mac, uint64_t *dci_pdu, dci_pdu_rel15_t *nr_pdci_info_extracted); -NR_PUSCH_TimeDomainResourceAllocationList_t *choose_ul_tda_list(NR_PUSCH_Config_t *pusch_Config,NR_PUSCH_ConfigCommon_t *pusch_ConfigCommon); +NR_PUSCH_TimeDomainResourceAllocationList_t *choose_ul_tda_list(const NR_PUSCH_Config_t *pusch_Config,NR_PUSCH_ConfigCommon_t *pusch_ConfigCommon); NR_PDSCH_TimeDomainResourceAllocationList_t *choose_dl_tda_list(NR_PDSCH_Config_t *pdsch_Config,NR_PDSCH_ConfigCommon_t *pdsch_ConfigCommon); int8_t nr_ue_process_dci_time_dom_resource_assignment(NR_UE_MAC_INST_t *mac, @@ -373,7 +375,8 @@ void nr_ue_sib1_scheduler(module_id_t module_idP, uint8_t ssb_subcarrier_offset, uint32_t ssb_index, uint16_t ssb_start_subcarrier, - frequency_range_t frequency_range); + frequency_range_t frequency_range, + void *phy_data); /* \brief Function called by PHY to process the received RAR and check that the preamble matches what was sent by the gNB. It provides the timing advance and t-CRNTI. @param Mod_id Index of UE instance @@ -442,12 +445,16 @@ int8_t nr_ue_process_dci_freq_dom_resource_assignment(nfapi_nr_ue_pusch_pdu_t *p uint16_t riv); void config_dci_pdu(NR_UE_MAC_INST_t *mac, fapi_nr_dl_config_dci_dl_pdu_rel15_t *rel15, fapi_nr_dl_config_request_t *dl_config, int rnti_type, int ss_id); -void fill_dci_search_candidates(NR_SearchSpace_t *ss,fapi_nr_dl_config_dci_dl_pdu_rel15_t *rel15); +void fill_dci_search_candidates(NR_SearchSpace_t *ss,fapi_nr_dl_config_dci_dl_pdu_rel15_t *rel15, int slot, int rnti); void build_ssb_to_ro_map(NR_UE_MAC_INST_t *mac); void config_bwp_ue(NR_UE_MAC_INST_t *mac, uint16_t *bwp_ind, uint8_t *dci_format); +void configure_ss_coreset(NR_UE_MAC_INST_t *mac, + NR_ServingCellConfig_t *scd, + NR_BWP_Id_t dl_bwp_id); + fapi_nr_ul_config_request_t *get_ul_config_request(NR_UE_MAC_INST_t *mac, int slot); void fill_ul_config(fapi_nr_ul_config_request_t *ul_config, frame_t frame_tx, int slot_tx, uint8_t pdu_type); diff --git a/openair2/LAYER2/NR_MAC_UE/nr_ra_procedures.c b/openair2/LAYER2/NR_MAC_UE/nr_ra_procedures.c index 3851ee011d..735ff1bd54 100644 --- a/openair2/LAYER2/NR_MAC_UE/nr_ra_procedures.c +++ b/openair2/LAYER2/NR_MAC_UE/nr_ra_procedures.c @@ -94,10 +94,12 @@ void init_RA(module_id_t mod_id, } } if (ss_id < 0) { - ra_ss = mac->DLbwp[0]->bwp_Common->pdcch_ConfigCommon->choice.setup->ra_SearchSpace; - if (ra_ss) { - commonSearchSpaceList = mac->DLbwp[0]->bwp_Common->pdcch_ConfigCommon->choice.setup->commonSearchSpaceList; - ss_id = *mac->DLbwp[0]->bwp_Common->pdcch_ConfigCommon->choice.setup->ra_SearchSpace; + if (mac->DL_BWP_Id>0) { + ra_ss = mac->DLbwp[mac->DL_BWP_Id-1]->bwp_Common->pdcch_ConfigCommon->choice.setup->ra_SearchSpace; + if (ra_ss) { + commonSearchSpaceList = mac->DLbwp[mac->DL_BWP_Id-1]->bwp_Common->pdcch_ConfigCommon->choice.setup->commonSearchSpaceList; + ss_id = *mac->DLbwp[mac->DL_BWP_Id-1]->bwp_Common->pdcch_ConfigCommon->choice.setup->ra_SearchSpace; + } } } } @@ -743,7 +745,7 @@ uint8_t nr_ue_get_rach(NR_PRACH_RESOURCES_t *prach_resources, } else if (get_softmodem_params()->nsa) { - uint8_t mac_sdus[MAX_NR_ULSCH_PAYLOAD_BYTES]; + uint8_t mac_sdus[MAX_NUM_NR_ULSCH_SEGMENTS_PER_LAYER*1056]; uint16_t sdu_lengths[NB_RB_MAX] = {0}; int TBS_bytes = 848; int mac_ce_len = 0; diff --git a/openair2/LAYER2/NR_MAC_UE/nr_ue_dci_configuration.c b/openair2/LAYER2/NR_MAC_UE/nr_ue_dci_configuration.c index 3453e071b1..9b618cdbfb 100644 --- a/openair2/LAYER2/NR_MAC_UE/nr_ue_dci_configuration.c +++ b/openair2/LAYER2/NR_MAC_UE/nr_ue_dci_configuration.c @@ -49,7 +49,9 @@ //#define DEBUG_DCI -void fill_dci_search_candidates(NR_SearchSpace_t *ss,fapi_nr_dl_config_dci_dl_pdu_rel15_t *rel15) { +void fill_dci_search_candidates(NR_SearchSpace_t *ss, + fapi_nr_dl_config_dci_dl_pdu_rel15_t *rel15, + int slot, int rnti) { LOG_D(NR_MAC,"Filling search candidates for DCI\n"); @@ -57,6 +59,9 @@ void fill_dci_search_candidates(NR_SearchSpace_t *ss,fapi_nr_dl_config_dci_dl_pd uint8_t number_of_candidates=0; rel15->number_of_candidates=0; int i=0; + uint32_t Y = 0; + if (slot >= 0) + Y = get_Y(ss, slot, rnti); for (int maxL=16;maxL>0;maxL>>=1) { find_aggregation_candidates(&aggregation, &number_of_candidates, @@ -65,8 +70,17 @@ void fill_dci_search_candidates(NR_SearchSpace_t *ss,fapi_nr_dl_config_dci_dl_pd if (number_of_candidates>0) { LOG_D(NR_MAC,"L %d, number of candidates %d, aggregation %d\n",maxL,number_of_candidates,aggregation); rel15->number_of_candidates += number_of_candidates; + int N_cce_sym = 0; // nb of rbs of coreset per symbol + for (int i=0;i<6;i++) { + for (int t=0;t<8;t++) { + N_cce_sym+=((rel15->coreset.frequency_domain_resource[i]>>t)&1); + } + } + int N_cces = N_cce_sym*rel15->coreset.duration; for (int j=0; jCCE[i] = j*aggregation; + int first_cce = aggregation * (( Y + CEILIDIV((j*N_cces),(aggregation*number_of_candidates)) + 0 ) % CEILIDIV(N_cces,aggregation)); + LOG_D(NR_MAC,"Candidate %d of %d first_cce %d (L %d N_cces %d Y %d)\n", j, number_of_candidates, first_cce, aggregation, N_cces, Y); + rel15->CCE[i] = first_cce; rel15->L[i] = aggregation; } } @@ -80,7 +94,7 @@ void config_dci_pdu(NR_UE_MAC_INST_t *mac, fapi_nr_dl_config_dci_dl_pdu_rel15_t AssertFatal(mac->scc == NULL || mac->scc_SIB == NULL, "both scc and scc_SIB cannot be non-null\n"); - NR_BWP_Id_t bwp_id = mac->DL_BWP_Id; + NR_BWP_Id_t dl_bwp_id = mac->DL_BWP_Id; NR_ServingCellConfigCommon_t *scc = mac->scc; NR_ServingCellConfigCommonSIB_t *scc_SIB = mac->scc_SIB; NR_BWP_DownlinkCommon_t *bwp_Common=NULL; @@ -91,7 +105,7 @@ void config_dci_pdu(NR_UE_MAC_INST_t *mac, fapi_nr_dl_config_dci_dl_pdu_rel15_t initialDownlinkBWP = scc!=NULL ? scc->downlinkConfigCommon->initialDownlinkBWP : &scc_SIB->downlinkConfigCommon.initialDownlinkBWP; initialUplinkBWP = scc!=NULL ? scc->uplinkConfigCommon->initialUplinkBWP : &scc_SIB->uplinkConfigCommon->initialUplinkBWP; } - bwp_Common = bwp_id>0 ? mac->DLbwp[bwp_id-1]->bwp_Common : NULL; + bwp_Common = dl_bwp_id>0 ? mac->DLbwp[dl_bwp_id-1]->bwp_Common : NULL; NR_SearchSpace_t *ss; NR_ControlResourceSet_t *coreset; @@ -102,7 +116,7 @@ void config_dci_pdu(NR_UE_MAC_INST_t *mac, fapi_nr_dl_config_dci_dl_pdu_rel15_t ss_id,mac->ra.ss->searchSpaceId); } else - ss = mac->SSpace[bwp_id][ss_id]; + ss = mac->SSpace[dl_bwp_id][ss_id-1]; } else ss = mac->search_space_zero; @@ -110,7 +124,7 @@ void config_dci_pdu(NR_UE_MAC_INST_t *mac, fapi_nr_dl_config_dci_dl_pdu_rel15_t uint8_t coreset_id = *ss->controlResourceSetId; if(coreset_id>0) { - coreset = mac->coreset[bwp_id][coreset_id - 1]; + coreset = mac->coreset[dl_bwp_id][coreset_id - 1]; rel15->coreset.CoreSetType = NFAPI_NR_CSET_CONFIG_PDCCH_CONFIG; } else { coreset = mac->coreset0; @@ -169,7 +183,7 @@ void config_dci_pdu(NR_UE_MAC_INST_t *mac, fapi_nr_dl_config_dci_dl_pdu_rel15_t rel15->SubcarrierSpacing = bwp_Common->genericParameters.subcarrierSpacing; } for (int i = 0; i < rel15->num_dci_options; i++) { - rel15->dci_length_options[i] = nr_dci_size(initialDownlinkBWP,initialUplinkBWP, mac->cg, &mac->def_dci_pdu_rel15[rel15->dci_format_options[i]], rel15->dci_format_options[i], NR_RNTI_C, rel15->BWPSize, bwp_id); + rel15->dci_length_options[i] = nr_dci_size(initialDownlinkBWP,initialUplinkBWP, mac->cg, &mac->def_dci_pdu_rel15[rel15->dci_format_options[i]], rel15->dci_format_options[i], NR_RNTI_C, rel15->BWPSize, dl_bwp_id, coreset_id, mac->type0_PDCCH_CSS_config.num_rbs); } break; case NR_RNTI_RA: @@ -185,7 +199,7 @@ void config_dci_pdu(NR_UE_MAC_INST_t *mac, fapi_nr_dl_config_dci_dl_pdu_rel15_t rel15->BWPStart = NRRIV2PRBOFFSET(bwp_Common->genericParameters.locationAndBandwidth, MAX_BWP_SIZE); } rel15->SubcarrierSpacing = initialDownlinkBWP->genericParameters.subcarrierSpacing; - rel15->dci_length_options[0] = nr_dci_size(initialDownlinkBWP,initialUplinkBWP, mac->cg, &mac->def_dci_pdu_rel15[rel15->dci_format_options[0]], rel15->dci_format_options[0], NR_RNTI_RA, rel15->BWPSize, bwp_id); + rel15->dci_length_options[0] = nr_dci_size(initialDownlinkBWP,initialUplinkBWP, mac->cg, &mac->def_dci_pdu_rel15[rel15->dci_format_options[0]], rel15->dci_format_options[0], NR_RNTI_RA, rel15->BWPSize, dl_bwp_id, coreset_id, mac->type0_PDCCH_CSS_config.num_rbs); break; case NR_RNTI_P: break; @@ -200,7 +214,7 @@ void config_dci_pdu(NR_UE_MAC_INST_t *mac, fapi_nr_dl_config_dci_dl_pdu_rel15_t rel15->BWPStart = mac->type0_PDCCH_CSS_config.cset_start_rb; rel15->SubcarrierSpacing = initialDownlinkBWP->genericParameters.subcarrierSpacing; for (int i = 0; i < rel15->num_dci_options; i++) { - rel15->dci_length_options[i] = nr_dci_size(initialDownlinkBWP,initialUplinkBWP, mac->cg, &mac->def_dci_pdu_rel15[rel15->dci_format_options[i]], rel15->dci_format_options[i], NR_RNTI_TC, rel15->BWPSize, bwp_id); + rel15->dci_length_options[i] = nr_dci_size(initialDownlinkBWP,initialUplinkBWP, mac->cg, &mac->def_dci_pdu_rel15[rel15->dci_format_options[i]], rel15->dci_format_options[i], NR_RNTI_TC, rel15->BWPSize, dl_bwp_id, coreset_id, mac->type0_PDCCH_CSS_config.num_rbs); } break; case NR_RNTI_SP_CSI: @@ -223,7 +237,7 @@ void config_dci_pdu(NR_UE_MAC_INST_t *mac, fapi_nr_dl_config_dci_dl_pdu_rel15_t rel15->SubcarrierSpacing = mac->mib->subCarrierSpacingCommon + 2; for (int i = 0; i < rel15->num_dci_options; i++) { - rel15->dci_length_options[i] = nr_dci_size(initialDownlinkBWP,initialUplinkBWP, mac->cg, &mac->def_dci_pdu_rel15[rel15->dci_format_options[i]], rel15->dci_format_options[i], NR_RNTI_SI, rel15->BWPSize, 0); + rel15->dci_length_options[i] = nr_dci_size(initialDownlinkBWP,initialUplinkBWP, mac->cg, &mac->def_dci_pdu_rel15[rel15->dci_format_options[i]], rel15->dci_format_options[i], NR_RNTI_SI, rel15->BWPSize, 0, coreset_id, mac->type0_PDCCH_CSS_config.num_rbs); } break; case NR_RNTI_SFI: @@ -273,11 +287,17 @@ void ue_dci_configuration(NR_UE_MAC_INST_t *mac, fapi_nr_dl_config_request_t *dl LOG_D(NR_MAC, "[DCI_CONFIG] ra_rnti %p (%x) crnti %p (%x) t_crnti %p (%x)\n", &ra->ra_rnti, ra->ra_rnti, &mac->crnti, mac->crnti, &ra->t_crnti, ra->t_crnti); - // loop over all available SS for CORESET ID 1 + // loop over all available SS for bwp_id if (bwpd) { - for (ss_id = 0; ss_id < FAPI_NR_MAX_SS && mac->SSpace[bwp_id][ss_id] != NULL; ss_id++){ + for (ss_id = 1; ss_id <= FAPI_NR_MAX_SS; ss_id++){ + + if(mac->SSpace[bwp_id][ss_id-1]==NULL) { + continue; + } + LOG_D(NR_MAC, "[DCI_CONFIG] ss_id %d\n",ss_id); - NR_SearchSpace_t *ss = mac->SSpace[bwp_id][ss_id]; + NR_SearchSpace_t *ss = mac->SSpace[bwp_id][ss_id-1]; + AssertFatal(ss_id == ss->searchSpaceId,"SS IDs don't correspond\n"); fapi_nr_dl_config_dci_dl_pdu_rel15_t *rel15 = &dl_config->dl_config_list[dl_config->number_pdus].dci_config_pdu.dci_config_rel15; NR_SetupRelease_PDCCH_ConfigCommon_t *pdcch_ConfigCommon = bwp_Common->pdcch_ConfigCommon; struct NR_PhysicalCellGroupConfig *phy_cgc = mac->cg->physicalCellGroupConfig; @@ -285,15 +305,6 @@ void ue_dci_configuration(NR_UE_MAC_INST_t *mac, fapi_nr_dl_config_request_t *dl case NR_SearchSpace__searchSpaceType_PR_common: // this is for CSSs, we use BWP common and pdcch_ConfigCommon - // Fetch configuration for searchSpaceZero - // note: The search space with the SearchSpaceId = 0 identifies the search space configured via PBCH (MIB) and in ServingCellConfigCommon (searchSpaceZero). - if (pdcch_ConfigCommon->choice.setup->searchSpaceZero){ - if (pdcch_ConfigCommon->choice.setup->searchSpaceSIB1 == NULL){ - pdcch_ConfigCommon->choice.setup->searchSpaceSIB1=calloc(1,sizeof(*pdcch_ConfigCommon->choice.setup->searchSpaceSIB1)); - } - *pdcch_ConfigCommon->choice.setup->searchSpaceSIB1 = 0; - LOG_D(NR_MAC, "[DCI_CONFIG] Configure SearchSpace#0 of the initial BWP\n"); - } if (ss->searchSpaceType->choice.common->dci_Format0_0_AndFormat1_0){ // check available SS IDs if (pdcch_ConfigCommon->choice.setup->ra_SearchSpace){ @@ -308,14 +319,14 @@ void ue_dci_configuration(NR_UE_MAC_INST_t *mac, fapi_nr_dl_config_request_t *dl } else { config_dci_pdu(mac, rel15, dl_config, NR_RNTI_RA, ss_id); } - fill_dci_search_candidates(ss, rel15); + fill_dci_search_candidates(ss, rel15, -1, -1); break; case WAIT_CONTENTION_RESOLUTION: LOG_D(NR_MAC, "[DCI_CONFIG] Configure monitoring of PDCCH candidates in Type1-PDCCH common random access search space (RA-Msg4)\n"); rel15->num_dci_options = 1; rel15->dci_format_options[0] = NR_DL_DCI_FORMAT_1_0; config_dci_pdu(mac, rel15, dl_config, NR_RNTI_TC, -1); - fill_dci_search_candidates(ss, rel15); + fill_dci_search_candidates(ss, rel15, -1, -1); break; default: break; @@ -387,7 +398,7 @@ void ue_dci_configuration(NR_UE_MAC_INST_t *mac, fapi_nr_dl_config_request_t *dl rel15->dci_format_options[0] = NR_DL_DCI_FORMAT_1_1; rel15->dci_format_options[1] = NR_UL_DCI_FORMAT_0_1; config_dci_pdu(mac, rel15, dl_config, NR_RNTI_C, ss_id); - fill_dci_search_candidates(ss, rel15); + fill_dci_search_candidates(ss, rel15, slot, mac->crnti); //#ifdef DEBUG_DCI LOG_D(NR_MAC, "[DCI_CONFIG] ss %d ue_Specific %p searchSpaceType->present %d dci_Formats %d\n", @@ -423,35 +434,4 @@ void ue_dci_configuration(NR_UE_MAC_INST_t *mac, fapi_nr_dl_config_request_t *dl AssertFatal(1==0,"Handle DCI searching when CellGroup without dedicated BWP\n"); } - // Search space 0, CORESET ID 0 - - NR_SetupRelease_PDCCH_ConfigCommon_t *pdcch_ConfigCommon = bwp_Common->pdcch_ConfigCommon; - - if (pdcch_ConfigCommon && - pdcch_ConfigCommon->choice.setup->searchSpaceSIB1 && - !get_softmodem_params()->nsa) { - - NR_SearchSpace_t *ss0 = mac->search_space_zero; - fapi_nr_dl_config_dci_dl_pdu_rel15_t *rel15 = &dl_config->dl_config_list[dl_config->number_pdus].dci_config_pdu.dci_config_rel15; - - if (ss0->searchSpaceId == *pdcch_ConfigCommon->choice.setup->searchSpaceSIB1){ - if( (frame%2 == mac->type0_PDCCH_CSS_config.sfn_c) && (slot == mac->type0_PDCCH_CSS_config.n_0) ){ - rel15->num_dci_options = 1; - rel15->dci_format_options[0] = NR_DL_DCI_FORMAT_1_0; - config_dci_pdu(mac, rel15, dl_config, NR_RNTI_SI, -1); - fill_dci_search_candidates(ss0, rel15); - } - } - } - else if (!get_softmodem_params()->nsa) { // use coreset0/ss0 - NR_SearchSpace_t *ss0 = mac->search_space_zero; - if(ss0) { - fapi_nr_dl_config_dci_dl_pdu_rel15_t *rel15 = &dl_config->dl_config_list[0].dci_config_pdu.dci_config_rel15; - rel15->num_dci_options = 1; - rel15->dci_format_options[0] = NR_DL_DCI_FORMAT_1_0; - config_dci_pdu(mac, rel15, dl_config, NR_RNTI_C , -1); - fill_dci_search_candidates(ss0, rel15); - dl_config->number_pdus = 1; - } - } } diff --git a/openair2/LAYER2/NR_MAC_UE/nr_ue_procedures.c b/openair2/LAYER2/NR_MAC_UE/nr_ue_procedures.c index c57736990c..0e043208e4 100644 --- a/openair2/LAYER2/NR_MAC_UE/nr_ue_procedures.c +++ b/openair2/LAYER2/NR_MAC_UE/nr_ue_procedures.c @@ -191,32 +191,27 @@ void get_bwp_info(NR_UE_MAC_INST_t *mac, NR_BWP_UplinkDedicated_t **ubwpd, NR_BWP_UplinkCommon_t **ubwpc) { - if (dl_bwp_id > 0) { - AssertFatal(mac->DLbwp[dl_bwp_id-1]!=NULL,"mac->DLbwp[%d] is null, shouldn't be\n", - (int)dl_bwp_id-1); - *bwpd = mac->DLbwp[dl_bwp_id-1]->bwp_Dedicated; - if (mac->DLbwp[dl_bwp_id-1]->bwp_Common) *bwpc = mac->DLbwp[dl_bwp_id-1]->bwp_Common; - else if (mac->scc_SIB) *bwpc = &mac->scc_SIB->downlinkConfigCommon.initialDownlinkBWP; - else if (mac->scc) *bwpc = mac->scc->downlinkConfigCommon->initialDownlinkBWP; - AssertFatal(*bwpc!=NULL,"bwpc shouldn't be null\n"); - } else { - if (mac->cg && - mac->cg->spCellConfig && - mac->cg->spCellConfig->spCellConfigDedicated && - mac->cg->spCellConfig->spCellConfigDedicated->initialDownlinkBWP) - *bwpd = mac->cg->spCellConfig->spCellConfigDedicated->initialDownlinkBWP; - if (mac->scc_SIB) *bwpc = &mac->scc_SIB->downlinkConfigCommon.initialDownlinkBWP; - else if (mac->scc) *bwpc = mac->scc->downlinkConfigCommon->initialDownlinkBWP; - AssertFatal(*bwpc!=NULL,"bwpc shouldn't be null\n"); - } + if (dl_bwp_id > 0) { + AssertFatal(mac->DLbwp[dl_bwp_id-1]!=NULL,"mac->DLbwp[%d] is null, shouldn't be\n", (int)dl_bwp_id-1); + *bwpd = mac->DLbwp[dl_bwp_id-1]->bwp_Dedicated; + } else { + if (mac->cg && + mac->cg->spCellConfig && + mac->cg->spCellConfig->spCellConfigDedicated && + mac->cg->spCellConfig->spCellConfigDedicated->initialDownlinkBWP) + *bwpd = mac->cg->spCellConfig->spCellConfigDedicated->initialDownlinkBWP; + } + + *bwpc = get_bwp_downlink_common(mac, dl_bwp_id); + AssertFatal(*bwpc!=NULL,"bwpc shouldn't be null\n"); if (ul_bwp_id > 0) { AssertFatal(mac->ULbwp[ul_bwp_id-1]!=NULL,"mac->ULbwp[%d] is null, shouldn't be\n", ul_bwp_id-1); *ubwpd = mac->ULbwp[ul_bwp_id-1]->bwp_Dedicated; if (mac->ULbwp[ul_bwp_id-1]->bwp_Common) *ubwpc = mac->ULbwp[ul_bwp_id-1]->bwp_Common; - else if (mac->scc_SIB) *ubwpc = &mac->scc_SIB->uplinkConfigCommon->initialUplinkBWP; else if (mac->scc) *ubwpc = mac->scc->uplinkConfigCommon->initialUplinkBWP; + else if (mac->scc_SIB) *ubwpc = &mac->scc_SIB->uplinkConfigCommon->initialUplinkBWP; AssertFatal(*bwpc!=NULL,"bwpc shouldn't be null\n"); } @@ -227,12 +222,24 @@ void get_bwp_info(NR_UE_MAC_INST_t *mac, mac->cg->spCellConfig->spCellConfigDedicated->uplinkConfig && mac->cg->spCellConfig->spCellConfigDedicated->uplinkConfig->initialUplinkBWP) *ubwpd = mac->cg->spCellConfig->spCellConfigDedicated->uplinkConfig->initialUplinkBWP; - if (mac->scc_SIB) *ubwpc = &mac->scc_SIB->uplinkConfigCommon->initialUplinkBWP; - else if (mac->scc) *ubwpc = mac->scc->uplinkConfigCommon->initialUplinkBWP; + if (mac->scc) *ubwpc = mac->scc->uplinkConfigCommon->initialUplinkBWP; + else if (mac->scc_SIB) *ubwpc = &mac->scc_SIB->uplinkConfigCommon->initialUplinkBWP; AssertFatal(*ubwpc!=NULL,"ubwpc shouldn't be null\n"); } } +NR_BWP_DownlinkCommon_t *get_bwp_downlink_common(NR_UE_MAC_INST_t *mac, NR_BWP_Id_t dl_bwp_id) { + NR_BWP_DownlinkCommon_t *bwp_Common = NULL; + if (dl_bwp_id > 0 && mac->cg->spCellConfig->spCellConfigDedicated->downlinkBWP_ToAddModList) { + bwp_Common = mac->cg->spCellConfig->spCellConfigDedicated->downlinkBWP_ToAddModList->list.array[dl_bwp_id-1]->bwp_Common; + } else if (mac->scc) { + bwp_Common = mac->scc->downlinkConfigCommon->initialDownlinkBWP; + } else if (mac->scc_SIB) { + bwp_Common = &mac->scc_SIB->downlinkConfigCommon.initialDownlinkBWP; + } + return bwp_Common; +} + NR_PDSCH_TimeDomainResourceAllocationList_t *choose_dl_tda_list(NR_PDSCH_Config_t *pdsch_Config,NR_PDSCH_ConfigCommon_t *pdsch_ConfigCommon) { NR_PDSCH_TimeDomainResourceAllocationList_t *pdsch_TimeDomainAllocationList=NULL; @@ -246,7 +253,7 @@ NR_PDSCH_TimeDomainResourceAllocationList_t *choose_dl_tda_list(NR_PDSCH_Config_ return(pdsch_TimeDomainAllocationList); } -NR_PUSCH_TimeDomainResourceAllocationList_t *choose_ul_tda_list(NR_PUSCH_Config_t *pusch_Config,NR_PUSCH_ConfigCommon_t *pusch_ConfigCommon) { +NR_PUSCH_TimeDomainResourceAllocationList_t *choose_ul_tda_list(const NR_PUSCH_Config_t *pusch_Config,NR_PUSCH_ConfigCommon_t *pusch_ConfigCommon) { NR_PUSCH_TimeDomainResourceAllocationList_t *pusch_TimeDomainAllocationList=NULL; @@ -281,13 +288,13 @@ int get_rnti_type(NR_UE_MAC_INST_t *mac, uint16_t rnti){ LOG_D(MAC, "In %s: returning rnti_type %s \n", __FUNCTION__, rnti_types[rnti_type]); return rnti_type; - } int8_t nr_ue_decode_mib(module_id_t module_id, int cc_id, uint8_t gNB_index, + void *phy_data, uint8_t extra_bits, // 8bits 38.212 c7.1.1 uint32_t ssb_length, uint32_t ssb_index, @@ -354,16 +361,22 @@ int8_t nr_ue_decode_mib(module_id_t module_id, scs_ssb = get_softmodem_params()->numerology; band = mac->nr_band; ssb_start_symbol = get_ssb_start_symbol(band,scs_ssb,ssb_index); + int ssb_sc_offset_norm; + if (ssb_subcarrier_offset<24 && mac->frequency_range == FR1) + ssb_sc_offset_norm = ssb_subcarrier_offset>>scs_ssb; + else + ssb_sc_offset_norm = ssb_subcarrier_offset; if (mac->common_configuration_complete == 0) nr_ue_sib1_scheduler(module_id, cc_id, ssb_start_symbol, frame, - ssb_subcarrier_offset, + ssb_sc_offset_norm, ssb_index, ssb_start_subcarrier, - mac->frequency_range); + mac->frequency_range, + phy_data); } else { NR_ServingCellConfigCommon_t *scc = mac->scc; @@ -566,7 +579,7 @@ int8_t nr_ue_process_dci_time_dom_resource_assignment(NR_UE_MAC_INST_t *mac, if(pusch_config_pdu != NULL){ if (pusch_TimeDomainAllocationList && use_default==false) { if (time_domain_ind >= pusch_TimeDomainAllocationList->list.count) { - LOG_E(MAC, "time_domain_ind %d >= pusch->TimeDomainAllocationList->list.count %d\n", + LOG_E(NR_MAC, "time_domain_ind %d >= pusch->TimeDomainAllocationList->list.count %d\n", time_domain_ind, pusch_TimeDomainAllocationList->list.count); pusch_config_pdu->start_symbol_index=0; pusch_config_pdu->nr_of_symbols=0; @@ -627,10 +640,13 @@ int8_t nr_ue_process_dci(module_id_t module_id, int cc_id, uint8_t gNB_index, fr RA_config_t *ra = &mac->ra; fapi_nr_dl_config_request_t *dl_config = &mac->dl_config_request; uint8_t is_Msg3 = 0; + NR_BWP_Id_t dl_bwp_id = mac->DL_BWP_Id; + NR_BWP_Id_t ul_bwp_id = mac->UL_BWP_Id; int default_abc = 1; uint16_t n_RB_DLBWP; - if (mac->DLbwp[0]) n_RB_DLBWP = NRRIV2BW(mac->DLbwp[0]->bwp_Common->genericParameters.locationAndBandwidth, MAX_BWP_SIZE); + if (dl_bwp_id>0 && mac->DLbwp[dl_bwp_id-1]) n_RB_DLBWP = NRRIV2BW(mac->DLbwp[dl_bwp_id-1]->bwp_Common->genericParameters.locationAndBandwidth, MAX_BWP_SIZE); + else if (mac->scc) n_RB_DLBWP = NRRIV2BW(mac->scc->uplinkConfigCommon->initialUplinkBWP->genericParameters.locationAndBandwidth,MAX_BWP_SIZE); else if (mac->scc_SIB) n_RB_DLBWP = NRRIV2BW(mac->scc_SIB->uplinkConfigCommon->initialUplinkBWP.genericParameters.locationAndBandwidth,MAX_BWP_SIZE); else n_RB_DLBWP = mac->type0_PDCCH_CSS_config.num_rbs; @@ -800,7 +816,7 @@ int8_t nr_ue_process_dci(module_id_t module_id, int cc_id, uint8_t gNB_index, fr dl_config->dl_config_list[dl_config->number_pdus].dlsch_config_pdu.rnti = rnti; fapi_nr_dl_config_dlsch_pdu_rel15_t *dlsch_config_pdu_1_0 = &dl_config->dl_config_list[dl_config->number_pdus].dlsch_config_pdu.dlsch_config_rel15; - NR_PDSCH_Config_t *pdsch_config= (mac->DLbwp[0]) ? mac->DLbwp[0]->bwp_Dedicated->pdsch_Config->choice.setup : NULL; + NR_PDSCH_Config_t *pdsch_config= (dl_bwp_id>0 && mac->DLbwp[dl_bwp_id-1]) ? mac->DLbwp[dl_bwp_id-1]->bwp_Dedicated->pdsch_Config->choice.setup : NULL; int is_common=0; if(rnti == SI_RNTI) { NR_Type0_PDCCH_CSS_config_t type0_PDCCH_CSS_config = mac->type0_PDCCH_CSS_config; @@ -827,14 +843,19 @@ int8_t nr_ue_process_dci(module_id_t module_id, int cc_id, uint8_t gNB_index, fr dlsch_config_pdu_1_0->BWPStart = NRRIV2PRBOFFSET(mac->scc->downlinkConfigCommon->initialDownlinkBWP->genericParameters.locationAndBandwidth, MAX_BWP_SIZE); } if (!get_softmodem_params()->sa) { // NSA mode is not using the Initial BWP - dlsch_config_pdu_1_0->BWPStart = NRRIV2PRBOFFSET(mac->DLbwp[0]->bwp_Common->genericParameters.locationAndBandwidth, MAX_BWP_SIZE); - pdsch_config = mac->DLbwp[0]->bwp_Dedicated->pdsch_Config->choice.setup; + dlsch_config_pdu_1_0->BWPStart = NRRIV2PRBOFFSET(mac->DLbwp[dl_bwp_id-1]->bwp_Common->genericParameters.locationAndBandwidth, MAX_BWP_SIZE); + pdsch_config = mac->DLbwp[dl_bwp_id-1]->bwp_Dedicated->pdsch_Config->choice.setup; } - } else if (mac->DLbwp[0]) { - dlsch_config_pdu_1_0->BWPSize = NRRIV2BW(mac->DLbwp[0]->bwp_Common->genericParameters.locationAndBandwidth, MAX_BWP_SIZE); - dlsch_config_pdu_1_0->BWPStart = NRRIV2PRBOFFSET(mac->DLbwp[0]->bwp_Common->genericParameters.locationAndBandwidth, MAX_BWP_SIZE); - dlsch_config_pdu_1_0->SubcarrierSpacing = mac->DLbwp[0]->bwp_Common->genericParameters.subcarrierSpacing; - pdsch_config = mac->DLbwp[0]->bwp_Dedicated->pdsch_Config->choice.setup; + } else if (dl_bwp_id>0 && mac->DLbwp[dl_bwp_id-1]) { + dlsch_config_pdu_1_0->BWPSize = NRRIV2BW(mac->DLbwp[dl_bwp_id-1]->bwp_Common->genericParameters.locationAndBandwidth, MAX_BWP_SIZE); + dlsch_config_pdu_1_0->BWPStart = NRRIV2PRBOFFSET(mac->DLbwp[dl_bwp_id-1]->bwp_Common->genericParameters.locationAndBandwidth, MAX_BWP_SIZE); + dlsch_config_pdu_1_0->SubcarrierSpacing = mac->DLbwp[dl_bwp_id-1]->bwp_Common->genericParameters.subcarrierSpacing; + pdsch_config = mac->DLbwp[dl_bwp_id-1]->bwp_Dedicated->pdsch_Config->choice.setup; + } else if (mac->scc) { + dlsch_config_pdu_1_0->BWPSize = NRRIV2BW(mac->scc->downlinkConfigCommon->initialDownlinkBWP->genericParameters.locationAndBandwidth, MAX_BWP_SIZE); + dlsch_config_pdu_1_0->BWPStart = NRRIV2PRBOFFSET(mac->scc->downlinkConfigCommon->initialDownlinkBWP->genericParameters.locationAndBandwidth, MAX_BWP_SIZE); + dlsch_config_pdu_1_0->SubcarrierSpacing = mac->scc->downlinkConfigCommon->initialDownlinkBWP->genericParameters.subcarrierSpacing; + pdsch_config = NULL; } else if (mac->scc_SIB) { dlsch_config_pdu_1_0->BWPSize = NRRIV2BW(mac->scc_SIB->downlinkConfigCommon.initialDownlinkBWP.genericParameters.locationAndBandwidth, MAX_BWP_SIZE); dlsch_config_pdu_1_0->BWPStart = NRRIV2PRBOFFSET(mac->scc_SIB->downlinkConfigCommon.initialDownlinkBWP.genericParameters.locationAndBandwidth, MAX_BWP_SIZE); @@ -852,13 +873,14 @@ int8_t nr_ue_process_dci(module_id_t module_id, int cc_id, uint8_t gNB_index, fr NR_PDSCH_TimeDomainResourceAllocationList_t *pdsch_TimeDomainAllocationList = NULL; - if (mac->DLbwp[0] && - mac->DLbwp[0]->bwp_Dedicated && - mac->DLbwp[0]->bwp_Dedicated->pdsch_Config && - mac->DLbwp[0]->bwp_Dedicated->pdsch_Config->choice.setup->pdsch_TimeDomainAllocationList) - pdsch_TimeDomainAllocationList = mac->DLbwp[0]->bwp_Dedicated->pdsch_Config->choice.setup->pdsch_TimeDomainAllocationList->choice.setup; - else if (mac->DLbwp[0] && mac->DLbwp[0]->bwp_Common->pdsch_ConfigCommon->choice.setup->pdsch_TimeDomainAllocationList) - pdsch_TimeDomainAllocationList = mac->DLbwp[0]->bwp_Common->pdsch_ConfigCommon->choice.setup->pdsch_TimeDomainAllocationList; + if (dl_bwp_id>0 && + mac->DLbwp[dl_bwp_id-1] && + mac->DLbwp[dl_bwp_id-1]->bwp_Dedicated && + mac->DLbwp[dl_bwp_id-1]->bwp_Dedicated->pdsch_Config && + mac->DLbwp[dl_bwp_id-1]->bwp_Dedicated->pdsch_Config->choice.setup->pdsch_TimeDomainAllocationList) + pdsch_TimeDomainAllocationList = mac->DLbwp[dl_bwp_id-1]->bwp_Dedicated->pdsch_Config->choice.setup->pdsch_TimeDomainAllocationList->choice.setup; + else if (dl_bwp_id>0 && mac->DLbwp[dl_bwp_id-1] && mac->DLbwp[dl_bwp_id-1]->bwp_Common->pdsch_ConfigCommon->choice.setup->pdsch_TimeDomainAllocationList) + pdsch_TimeDomainAllocationList = mac->DLbwp[dl_bwp_id-1]->bwp_Common->pdsch_ConfigCommon->choice.setup->pdsch_TimeDomainAllocationList; else if (mac->scc_SIB && mac->scc_SIB->downlinkConfigCommon.initialDownlinkBWP.pdsch_ConfigCommon->choice.setup) pdsch_TimeDomainAllocationList = mac->scc_SIB->downlinkConfigCommon.initialDownlinkBWP.pdsch_ConfigCommon->choice.setup->pdsch_TimeDomainAllocationList; @@ -874,14 +896,27 @@ int8_t nr_ue_process_dci(module_id_t module_id, int cc_id, uint8_t gNB_index, fr if(pdsch_TimeDomainAllocationList && rnti!=SI_RNTI) mappingtype = pdsch_TimeDomainAllocationList->list.array[dci->time_domain_assignment.val]->mappingType; + struct NR_DMRS_DownlinkConfig *dl_dmrs_config = NULL; + if(dl_bwp_id>0 && mac->DLbwp[dl_bwp_id-1] != NULL) + dl_dmrs_config = (mappingtype == typeA) ? + mac->DLbwp[dl_bwp_id-1]->bwp_Dedicated->pdsch_Config->choice.setup->dmrs_DownlinkForPDSCH_MappingTypeA->choice.setup : + mac->DLbwp[dl_bwp_id-1]->bwp_Dedicated->pdsch_Config->choice.setup->dmrs_DownlinkForPDSCH_MappingTypeB->choice.setup; + + dlsch_config_pdu_1_0->nscid = 0; + if(dl_dmrs_config && dl_dmrs_config->scramblingID0) + dlsch_config_pdu_1_0->dlDmrsScramblingId = *dl_dmrs_config->scramblingID0; + else + dlsch_config_pdu_1_0->dlDmrsScramblingId = mac->physCellId; + /* dmrs symbol positions*/ dlsch_config_pdu_1_0->dlDmrsSymbPos = fill_dmrs_mask(pdsch_config, (get_softmodem_params()->nsa) ? mac->scc->dmrs_TypeA_Position : mac->mib->dmrs_TypeA_Position, dlsch_config_pdu_1_0->number_symbols, dlsch_config_pdu_1_0->start_symbol, - mappingtype, 1); - dlsch_config_pdu_1_0->dmrsConfigType = (mac->DLbwp[0] != NULL) ? - (mac->DLbwp[0]->bwp_Dedicated->pdsch_Config->choice.setup->dmrs_DownlinkForPDSCH_MappingTypeA->choice.setup->dmrs_Type == NULL ? 0 : 1) : 0; + mappingtype, + 1); + dlsch_config_pdu_1_0->dmrsConfigType = (dl_dmrs_config != NULL) ? + (dl_dmrs_config->dmrs_Type == NULL ? 0 : 1) : 0; /* number of DM-RS CDM groups without data according to subclause 5.1.6.2 of 3GPP TS 38.214 version 15.9.0 Release 15 */ if (dlsch_config_pdu_1_0->number_symbols == 2) @@ -900,6 +935,36 @@ int8_t nr_ue_process_dci(module_id_t module_id, int cc_id, uint8_t gNB_index, fr LOG_W(MAC, "[%d.%d] MCS value %d out of bounds! Possibly due to false DCI. Ignoring DCI!\n", frame, slot, dlsch_config_pdu_1_0->mcs); return -1; } + + dlsch_config_pdu_1_0->qamModOrder = nr_get_Qm_dl(dlsch_config_pdu_1_0->mcs, dlsch_config_pdu_1_0->mcs_table); + int R = nr_get_code_rate_dl(dlsch_config_pdu_1_0->mcs, dlsch_config_pdu_1_0->mcs_table); + dlsch_config_pdu_1_0->targetCodeRate = R; + if (dlsch_config_pdu_1_0->targetCodeRate == 0 || dlsch_config_pdu_1_0->qamModOrder == 0) { + LOG_W(MAC, "Invalid code rate or Mod order, likely due to unexpected DL DCI.\n"); + return -1; + } + + int nb_rb_oh = 0; // it was not computed at UE side even before and set to 0 in nr_compute_tbs + int nb_re_dmrs = ((dlsch_config_pdu_1_0->dmrsConfigType == NFAPI_NR_DMRS_TYPE1) ? 6:4)*dlsch_config_pdu_1_0->n_dmrs_cdm_groups; + dlsch_config_pdu_1_0->TBS = nr_compute_tbs(dlsch_config_pdu_1_0->qamModOrder, + R, + dlsch_config_pdu_1_0->number_rbs, + dlsch_config_pdu_1_0->number_symbols, + nb_re_dmrs*get_num_dmrs(dlsch_config_pdu_1_0->dlDmrsSymbPos), + nb_rb_oh, 0, 1); + + int bw_tbslbrm; + if (mac->scc || mac->scc_SIB || mac->cg) { + NR_BWP_t genericParameters = mac->scc ? mac->scc->downlinkConfigCommon->initialDownlinkBWP->genericParameters : + mac->scc_SIB->downlinkConfigCommon.initialDownlinkBWP.genericParameters; + bw_tbslbrm = get_bw_tbslbrm(&genericParameters, mac->cg); + } + else + bw_tbslbrm = dlsch_config_pdu_1_0->BWPSize; + dlsch_config_pdu_1_0->tbslbrm = nr_compute_tbslbrm(dlsch_config_pdu_1_0->mcs_table, + bw_tbslbrm, + 1); + /* NDI (only if CRC scrambled by C-RNTI or CS-RNTI or new-RNTI or TC-RNTI)*/ dlsch_config_pdu_1_0->ndi = dci->ndi; /* RV (only if CRC scrambled by C-RNTI or CS-RNTI or new-RNTI or TC-RNTI)*/ @@ -920,14 +985,14 @@ int8_t nr_ue_process_dci(module_id_t module_id, int cc_id, uint8_t gNB_index, fr if (dci->tpc == 3) dlsch_config_pdu_1_0->accumulated_delta_PUCCH = 3; // Sanity check for pucch_resource_indicator value received to check for false DCI. valid = 0; - if (mac->ULbwp[0] && - mac->ULbwp[0]->bwp_Dedicated && - mac->ULbwp[0]->bwp_Dedicated->pucch_Config && - mac->ULbwp[0]->bwp_Dedicated->pucch_Config->choice.setup&& - mac->ULbwp[0]->bwp_Dedicated->pucch_Config->choice.setup->resourceSetToAddModList) { - pucch_res_set_cnt = mac->ULbwp[0]->bwp_Dedicated->pucch_Config->choice.setup->resourceSetToAddModList->list.count; + if (mac->ULbwp[ul_bwp_id-1] && + mac->ULbwp[ul_bwp_id-1]->bwp_Dedicated && + mac->ULbwp[ul_bwp_id-1]->bwp_Dedicated->pucch_Config && + mac->ULbwp[ul_bwp_id-1]->bwp_Dedicated->pucch_Config->choice.setup&& + mac->ULbwp[ul_bwp_id-1]->bwp_Dedicated->pucch_Config->choice.setup->resourceSetToAddModList) { + pucch_res_set_cnt = mac->ULbwp[ul_bwp_id-1]->bwp_Dedicated->pucch_Config->choice.setup->resourceSetToAddModList->list.count; for (int id = 0; id < pucch_res_set_cnt; id++) { - if (dci->pucch_resource_indicator < mac->ULbwp[0]->bwp_Dedicated->pucch_Config->choice.setup->resourceSetToAddModList->list.array[id]->resourceList.list.count) { + if (dci->pucch_resource_indicator < mac->ULbwp[ul_bwp_id-1]->bwp_Dedicated->pucch_Config->choice.setup->resourceSetToAddModList->list.array[id]->resourceList.list.count) { valid = 1; break; } @@ -1030,8 +1095,8 @@ int8_t nr_ue_process_dci(module_id_t module_id, int cc_id, uint8_t gNB_index, fr * 47 DMRS_SEQ_INI: */ - if (dci->bwp_indicator.val > 1) { - LOG_W(NR_MAC,"[%d.%d] bwp_indicator %d > 1 Possibly due to false DCI. Ignoring DCI!\n", frame, slot,dci->bwp_indicator.val); + if (dci->bwp_indicator.val > NR_MAX_NUM_BWP) { + LOG_W(NR_MAC,"[%d.%d] bwp_indicator %d > NR_MAX_NUM_BWP Possibly due to false DCI. Ignoring DCI!\n", frame, slot,dci->bwp_indicator.val); return -1; } config_bwp_ue(mac, &dci->bwp_indicator.val, &dci_format); @@ -1075,7 +1140,30 @@ int8_t nr_ue_process_dci(module_id_t module_id, int cc_id, uint8_t gNB_index, fr if(pdsch_TimeDomainAllocationList) mappingtype = pdsch_TimeDomainAllocationList->list.array[dci->time_domain_assignment.val]->mappingType; - dlsch_config_pdu_1_1->dmrsConfigType = pdsch_Config->dmrs_DownlinkForPDSCH_MappingTypeA->choice.setup->dmrs_Type == NULL ? NFAPI_NR_DMRS_TYPE1 : NFAPI_NR_DMRS_TYPE2; + struct NR_DMRS_DownlinkConfig *dl_dmrs_config = (mappingtype == typeA) ? + pdsch_Config->dmrs_DownlinkForPDSCH_MappingTypeA->choice.setup : + pdsch_Config->dmrs_DownlinkForPDSCH_MappingTypeB->choice.setup; + + switch (dci->dmrs_sequence_initialization.val) { + case 0: + dlsch_config_pdu_1_1->nscid = 0; + if(dl_dmrs_config->scramblingID0) + dlsch_config_pdu_1_1->dlDmrsScramblingId = *dl_dmrs_config->scramblingID0; + else + dlsch_config_pdu_1_1->dlDmrsScramblingId = mac->physCellId; + break; + case 1: + dlsch_config_pdu_1_1->nscid = 1; + if(dl_dmrs_config->scramblingID1) + dlsch_config_pdu_1_1->dlDmrsScramblingId = *dl_dmrs_config->scramblingID1; + else + dlsch_config_pdu_1_1->dlDmrsScramblingId = mac->physCellId; + break; + default: + AssertFatal(1==0,"Invalid dmrs sequence initialization value\n"); + } + + dlsch_config_pdu_1_1->dmrsConfigType = dl_dmrs_config->dmrs_Type == NULL ? NFAPI_NR_DMRS_TYPE1 : NFAPI_NR_DMRS_TYPE2; /* TODO: fix number of DM-RS CDM groups without data according to subclause 5.1.6.2 of 3GPP TS 38.214, using tables 7.3.1.2.2-1, 7.3.1.2.2-2, 7.3.1.2.2-3, 7.3.1.2.2-4 of 3GPP TS 38.212 */ @@ -1136,17 +1224,11 @@ int8_t nr_ue_process_dci(module_id_t module_id, int cc_id, uint8_t gNB_index, fr /* ANTENNA_PORTS */ uint8_t n_codewords = 1; // FIXME!!! - long *max_length = NULL; - long *dmrs_type = NULL; + long *max_length = dl_dmrs_config->maxLength; + long *dmrs_type = dl_dmrs_config->dmrs_Type; + dlsch_config_pdu_1_1->n_front_load_symb = 1; // default value - if (pdsch_Config->dmrs_DownlinkForPDSCH_MappingTypeA) { - max_length = pdsch_Config->dmrs_DownlinkForPDSCH_MappingTypeA->choice.setup->maxLength; - dmrs_type = pdsch_Config->dmrs_DownlinkForPDSCH_MappingTypeA->choice.setup->dmrs_Type; - } - if (pdsch_Config->dmrs_DownlinkForPDSCH_MappingTypeB) { - max_length = pdsch_Config->dmrs_DownlinkForPDSCH_MappingTypeB->choice.setup->maxLength; - dmrs_type = pdsch_Config->dmrs_DownlinkForPDSCH_MappingTypeB->choice.setup->dmrs_Type; - } + if ((dmrs_type == NULL) && (max_length == NULL)){ // Table 7.3.1.2.2-1: Antenna port(s) (1000 + DMRS port), dmrs-Type=1, maxLength=1 dlsch_config_pdu_1_1->n_dmrs_cdm_groups = table_7_3_2_3_3_1[dci->antenna_ports.val][0]; @@ -1241,8 +1323,8 @@ int8_t nr_ue_process_dci(module_id_t module_id, int cc_id, uint8_t gNB_index, fr /* dmrs symbol positions*/ dlsch_config_pdu_1_1->dlDmrsSymbPos = fill_dmrs_mask(pdsch_Config, - mac->scc? mac->scc->dmrs_TypeA_Position:mac->mib->dmrs_TypeA_Position, - dlsch_config_pdu_1_1->number_symbols, + mac->scc? mac->scc->dmrs_TypeA_Position:mac->mib->dmrs_TypeA_Position, + dlsch_config_pdu_1_1->number_symbols, dlsch_config_pdu_1_1->start_symbol, mappingtype, dlsch_config_pdu_1_1->n_front_load_symb); @@ -1288,6 +1370,36 @@ int8_t nr_ue_process_dci(module_id_t module_id, int cc_id, uint8_t gNB_index, fr dl_config->number_pdus = dl_config->number_pdus + 1; /* TODO same calculation for MCS table as done in UL */ dlsch_config_pdu_1_1->mcs_table = (pdsch_Config->mcs_Table) ? (*pdsch_Config->mcs_Table + 1) : 0; + dlsch_config_pdu_1_1->qamModOrder = nr_get_Qm_dl(dlsch_config_pdu_1_1->mcs, dlsch_config_pdu_1_1->mcs_table); + int R = nr_get_code_rate_dl(dlsch_config_pdu_1_1->mcs, dlsch_config_pdu_1_1->mcs_table); + dlsch_config_pdu_1_1->targetCodeRate = R; + if (dlsch_config_pdu_1_1->targetCodeRate == 0 || dlsch_config_pdu_1_1->qamModOrder == 0) { + LOG_W(MAC, "Invalid code rate or Mod order, likely due to unexpected DL DCI.\n"); + return -1; + } + uint8_t Nl = 0; + for (int i = 0; i < 12; i++) { // max 12 ports + if ((dlsch_config_pdu_1_1->dmrs_ports>>i)&0x01) Nl += 1; + } + int nb_rb_oh = 0; // it was not computed at UE side even before and set to 0 in nr_compute_tbs + int nb_re_dmrs = ((dmrs_type == NULL) ? 6:4)*dlsch_config_pdu_1_1->n_dmrs_cdm_groups; + dlsch_config_pdu_1_1->TBS = nr_compute_tbs(dlsch_config_pdu_1_1->qamModOrder, + R, + dlsch_config_pdu_1_1->number_rbs, + dlsch_config_pdu_1_1->number_symbols, + nb_re_dmrs*get_num_dmrs(dlsch_config_pdu_1_1->dlDmrsSymbPos), + nb_rb_oh, 0, Nl); + + // TBS_LBRM according to section 5.4.2.1 of 38.212 + long *maxMIMO_Layers = mac->cg->spCellConfig->spCellConfigDedicated->pdsch_ServingCellConfig->choice.setup->ext1->maxMIMO_Layers; + AssertFatal (maxMIMO_Layers != NULL,"Option with max MIMO layers not configured is not supported\n"); + int nl_tbslbrm = *maxMIMO_Layers < 4 ? *maxMIMO_Layers : 4; + NR_BWP_t genericParameters = mac->scc ? mac->scc->downlinkConfigCommon->initialDownlinkBWP->genericParameters : + mac->scc_SIB->downlinkConfigCommon.initialDownlinkBWP.genericParameters; + int bw_tbslbrm = get_bw_tbslbrm(&genericParameters, mac->cg); + dlsch_config_pdu_1_1->tbslbrm = nr_compute_tbslbrm(dlsch_config_pdu_1_1->mcs_table, + bw_tbslbrm, + nl_tbslbrm); /*PTRS configuration */ dlsch_config_pdu_1_1->pduBitmap = 0; if(pdsch_Config->dmrs_DownlinkForPDSCH_MappingTypeA->choice.setup->phaseTrackingRS != NULL) { @@ -1368,10 +1480,18 @@ void set_harq_status(NR_UE_MAC_INST_t *mac, // FIXME k0 != 0 currently not taken into consideration current_harq->dl_frame = frame; current_harq->dl_slot = slot; - mac->nr_ue_emul_l1.active_harq_sfn_slot = NFAPI_SFNSLOT2HEX(frame, (slot + data_toul_fb)); + if (get_softmodem_params()->emulate_l1) { + int scs = get_softmodem_params()->numerology; + int slots_per_frame = nr_slots_per_frame[scs]; + slot += data_toul_fb; + if (slot >= slots_per_frame) { + frame = (frame + 1) % 1024; + slot %= slots_per_frame; + } + } LOG_D(NR_PHY,"Setting harq_status for harq_id %d, dl %d.%d, sched ul %d.%d\n", - harq_id, frame, slot, frame, (slot + data_toul_fb)); + harq_id, current_harq->dl_frame, current_harq->dl_slot, frame, slot); } @@ -1392,7 +1512,7 @@ void nr_ue_configure_pucch(NR_UE_MAC_INST_t *mac, NR_BWP_UplinkCommon_t *initialUplinkBWP; if (mac->scc) initialUplinkBWP = mac->scc->uplinkConfigCommon->initialUplinkBWP; else initialUplinkBWP = &mac->scc_SIB->uplinkConfigCommon->initialUplinkBWP; - NR_BWP_Uplink_t *ubwp = mac->ULbwp[0]; + NR_BWP_Uplink_t *ubwp = mac->ULbwp[bwp_id-1]; if (mac->cg && ubwp && mac->cg->spCellConfig && mac->cg->spCellConfig->spCellConfigDedicated && @@ -1853,7 +1973,8 @@ int find_pucch_resource_set(NR_UE_MAC_INST_t *mac, int uci_size) { mac->cg->spCellConfig->spCellConfigDedicated->uplinkConfig->initialUplinkBWP->pucch_Config->choice.setup && mac->cg->spCellConfig->spCellConfigDedicated->uplinkConfig->initialUplinkBWP->pucch_Config->choice.setup->resourceSetToAddModList && mac->cg->spCellConfig->spCellConfigDedicated->uplinkConfig->initialUplinkBWP->pucch_Config->choice.setup->resourceSetToAddModList->list.array[pucch_resource_set_id] != NULL)) { - if (uci_size <= 2) { + // PUCCH with format0 can be up to 3 bits (2 ack/nacks + 1 sr is 3 max bits) + if (uci_size <= 3) { pucch_resource_set_id = 0; return (pucch_resource_set_id); break; @@ -2054,11 +2175,17 @@ uint8_t get_downlink_ack(NR_UE_MAC_INST_t *mac, sched_frame = current_harq->dl_frame; if (sched_slot>=slots_per_frame){ sched_slot %= slots_per_frame; - sched_frame++; + sched_frame = (sched_frame + 1) % 1024; } + AssertFatal(sched_slot < slots_per_frame, "sched_slot was calculated incorrect %d\n", sched_slot); LOG_D(PHY,"HARQ pid %d is active for %d.%d (dl_slot %d, feedback_to_ul %d, is_common %d\n",dl_harq_pid, sched_frame,sched_slot,current_harq->dl_slot,current_harq->feedback_to_ul,current_harq->is_common); /* check if current tx slot should transmit downlink acknowlegment */ if (sched_frame == frame && sched_slot == slot) { + if (get_softmodem_params()->emulate_l1) { + mac->nr_ue_emul_l1.harq[dl_harq_pid].active = true; + mac->nr_ue_emul_l1.harq[dl_harq_pid].active_dl_harq_sfn = frame; + mac->nr_ue_emul_l1.harq[dl_harq_pid].active_dl_harq_slot = slot; + } if (current_harq->dai > NR_DL_MAX_DAI) { LOG_E(MAC,"PUCCH Downlink DAI has an invalid value : at line %d in function %s of file %s \n", LINE_FILE , __func__, FILE_NAME); @@ -2092,6 +2219,7 @@ uint8_t get_downlink_ack(NR_UE_MAC_INST_t *mac, pucch->is_common = current_harq->is_common; current_harq->active = false; current_harq->ack_received = false; + LOG_D(PHY,"%4d.%2d Sent %d ack on harq pid %d\n", frame, slot, current_harq->ack, dl_harq_pid); } } } @@ -2212,7 +2340,7 @@ bool trigger_periodic_scheduling_request(NR_UE_MAC_INST_t *mac, NR_BWP_Id_t bwp_id = mac->UL_BWP_Id; NR_PUCCH_Config_t *pucch_Config = NULL; int scs; - NR_BWP_Uplink_t *ubwp = mac->ULbwp[0]; + NR_BWP_Uplink_t *ubwp = mac->ULbwp[bwp_id-1]; NR_BWP_UplinkCommon_t *initialUplinkBWP; if (mac->scc) initialUplinkBWP = mac->scc->uplinkConfigCommon->initialUplinkBWP; else initialUplinkBWP = &mac->scc_SIB->uplinkConfigCommon->initialUplinkBWP; @@ -2357,7 +2485,7 @@ uint8_t nr_get_csi_measurements(NR_UE_MAC_INST_t *mac, csi_period_offset(csirep, NULL, &period, &offset); int scs; - NR_BWP_Uplink_t *ubwp = mac->ULbwp[0]; + NR_BWP_Uplink_t *ubwp = mac->ULbwp[bwp_id-1]; NR_BWP_UplinkCommon_t *initialUplinkBWP; if (mac->scc) initialUplinkBWP = mac->scc->uplinkConfigCommon->initialUplinkBWP; else initialUplinkBWP = &mac->scc_SIB->uplinkConfigCommon->initialUplinkBWP; @@ -2438,7 +2566,8 @@ uint8_t nr_get_csi_payload(NR_UE_MAC_INST_t *mac, case NR_CSI_ReportConfig__reportQuantity_PR_cri_RI_i1_CQI: case NR_CSI_ReportConfig__reportQuantity_PR_cri_RI_CQI: case NR_CSI_ReportConfig__reportQuantity_PR_cri_RI_LI_PMI_CQI: - AssertFatal(1==0,"Measurement report based on CSI-RS not availalble\n"); + LOG_E(NR_MAC,"Measurement report based on CSI-RS not available\n"); + break; default: AssertFatal(1==0,"Invalid CSI report quantity type %d\n",csi_reportconfig->reportQuantity.present); } @@ -2580,14 +2709,14 @@ void nr_ue_send_sdu(nr_downlink_indication_t *dl_info, NR_UL_TIME_ALIGNMENT_t *u int get_n_rb(NR_UE_MAC_INST_t *mac, int rnti_type){ int N_RB = 0, start_RB; + NR_BWP_Id_t dl_bwp_id = mac->DL_BWP_Id; switch(rnti_type) { case NR_RNTI_RA: case NR_RNTI_TC: case NR_RNTI_P: { - NR_BWP_Id_t dl_bwp_id = mac->DL_BWP_Id; if (mac->DLbwp[dl_bwp_id-1]->bwp_Common->pdcch_ConfigCommon->choice.setup->controlResourceSetZero) { uint8_t coreset_id = 0; // assuming controlResourceSetId is 0 for controlResourceSetZero - NR_ControlResourceSet_t *coreset = mac->coreset[dl_bwp_id-1][coreset_id]; + NR_ControlResourceSet_t *coreset = mac->coreset[dl_bwp_id][coreset_id]; get_coreset_rballoc(coreset->frequencyDomainResources.buf,&N_RB,&start_RB); } else { N_RB = NRRIV2BW(mac->scc->downlinkConfigCommon->initialDownlinkBWP->genericParameters.locationAndBandwidth, MAX_BWP_SIZE); @@ -2598,7 +2727,7 @@ int get_n_rb(NR_UE_MAC_INST_t *mac, int rnti_type){ N_RB = mac->type0_PDCCH_CSS_config.num_rbs; break; case NR_RNTI_C: - N_RB = NRRIV2BW(mac->DLbwp[0]->bwp_Common->genericParameters.locationAndBandwidth, MAX_BWP_SIZE); + N_RB = NRRIV2BW(mac->DLbwp[dl_bwp_id-1]->bwp_Common->genericParameters.locationAndBandwidth, MAX_BWP_SIZE); break; } return N_RB; @@ -2617,14 +2746,16 @@ uint8_t nr_extract_dci_info(NR_UE_MAC_INST_t *mac, int fsize = 0; int rnti_type = get_rnti_type(mac, rnti); + NR_BWP_Id_t dl_bwp_id = mac->DL_BWP_Id ; + NR_BWP_Id_t ul_bwp_id = mac->UL_BWP_Id ; int N_RB_UL = 0; - if(mac->scc_SIB) { - N_RB_UL = NRRIV2BW(mac->scc_SIB->uplinkConfigCommon->initialUplinkBWP.genericParameters.locationAndBandwidth, MAX_BWP_SIZE); - } else if(mac->ULbwp[0]) { - N_RB_UL = NRRIV2BW(mac->ULbwp[0]->bwp_Common->genericParameters.locationAndBandwidth, MAX_BWP_SIZE); + if(ul_bwp_id > 0 && mac->ULbwp[ul_bwp_id-1]) { + N_RB_UL = NRRIV2BW(mac->ULbwp[ul_bwp_id - 1]->bwp_Common->genericParameters.locationAndBandwidth, MAX_BWP_SIZE); } else if(mac->scc) { N_RB_UL = NRRIV2BW(mac->scc->uplinkConfigCommon->initialUplinkBWP->genericParameters.locationAndBandwidth, MAX_BWP_SIZE); + } else if(mac->scc_SIB) { + N_RB_UL = NRRIV2BW(mac->scc_SIB->uplinkConfigCommon->initialUplinkBWP.genericParameters.locationAndBandwidth, MAX_BWP_SIZE); } LOG_D(MAC,"nr_extract_dci_info : dci_pdu %lx, size %d\n",*dci_pdu,dci_size); @@ -2688,7 +2819,7 @@ uint8_t nr_extract_dci_info(NR_UE_MAC_INST_t *mac, #endif // check BWP id - if (mac->DLbwp[0]) N_RB=NRRIV2BW(mac->DLbwp[0]->bwp_Common->genericParameters.locationAndBandwidth, MAX_BWP_SIZE); + if (dl_bwp_id>0 && mac->DLbwp[dl_bwp_id-1]) N_RB=NRRIV2BW(mac->DLbwp[dl_bwp_id-1]->bwp_Common->genericParameters.locationAndBandwidth, MAX_BWP_SIZE); else N_RB=NRRIV2BW(mac->scc_SIB->downlinkConfigCommon.initialDownlinkBWP.genericParameters.locationAndBandwidth, MAX_BWP_SIZE); // Freq domain assignment (275rb >> fsize = 16) @@ -2871,7 +3002,7 @@ uint8_t nr_extract_dci_info(NR_UE_MAC_INST_t *mac, case NR_RNTI_TC: // check BWP id - if (mac->DLbwp[0]) N_RB=NRRIV2BW(mac->DLbwp[0]->bwp_Common->genericParameters.locationAndBandwidth, MAX_BWP_SIZE); + if (dl_bwp_id>0 && mac->DLbwp[dl_bwp_id-1]) N_RB=NRRIV2BW(mac->DLbwp[dl_bwp_id-1]->bwp_Common->genericParameters.locationAndBandwidth, MAX_BWP_SIZE); else N_RB=mac->type0_PDCCH_CSS_config.num_rbs; @@ -2953,7 +3084,7 @@ uint8_t nr_extract_dci_info(NR_UE_MAC_INST_t *mac, break; case NR_UL_DCI_FORMAT_0_0: - if (mac->ULbwp[0]) N_RB_UL=NRRIV2BW(mac->ULbwp[0]->bwp_Common->genericParameters.locationAndBandwidth, MAX_BWP_SIZE); + if (mac->ULbwp[ul_bwp_id-1]) N_RB_UL=NRRIV2BW(mac->ULbwp[ul_bwp_id-1]->bwp_Common->genericParameters.locationAndBandwidth, MAX_BWP_SIZE); else N_RB_UL=NRRIV2BW(mac->scc_SIB->uplinkConfigCommon->initialUplinkBWP.genericParameters.locationAndBandwidth, MAX_BWP_SIZE); switch(rnti_type) @@ -3325,10 +3456,6 @@ void nr_ue_process_mac_pdu(nr_downlink_indication_t *dl_info, NR_UL_TIME_ALIGNMENT_t *ul_time_alignment, int pdu_id){ - uint8_t rx_lcid; - uint16_t mac_ce_len; - uint16_t mac_subheader_len; - uint16_t mac_sdu_len; module_id_t module_idP = dl_info->module_id; frame_t frameP = dl_info->frame; int slot = dl_info->slot; @@ -3347,139 +3474,100 @@ void nr_ue_process_mac_pdu(nr_downlink_indication_t *dl_info, LOG_D(MAC, "In %s [%d.%d]: processing PDU %d (with length %d) of %d total number of PDUs...\n", __FUNCTION__, frameP, slot, pdu_id, pdu_len, dl_info->rx_ind->number_pdus); while (!done && pdu_len > 0){ - mac_ce_len = 0x0000; - mac_subheader_len = 0x0001; // default to fixed-length subheader = 1-oct - mac_sdu_len = 0x0000; - rx_lcid = ((NR_MAC_SUBHEADER_FIXED *)pduP)->LCID; + uint16_t mac_len = 0x0000; + uint16_t mac_subheader_len = 0x0001; // default to fixed-length subheader = 1-oct + uint8_t rx_lcid = ((NR_MAC_SUBHEADER_FIXED *)pduP)->LCID; LOG_D(MAC, "[UE] LCID %d, PDU length %d\n", rx_lcid, pdu_len); + bool ret; switch(rx_lcid){ // MAC CE case DL_SCH_LCID_CCCH: // MSG4 RRC Setup 38.331 // variable length - if(((NR_MAC_SUBHEADER_SHORT *)pduP)->F){ - mac_sdu_len = ((uint16_t)(((NR_MAC_SUBHEADER_LONG *) pduP)->L1 & 0x7f) << 8) - | ((uint16_t)((NR_MAC_SUBHEADER_LONG *) pduP)->L2 & 0xff); - mac_subheader_len = 3; - } else { - mac_sdu_len = ((NR_MAC_SUBHEADER_SHORT *) pduP)->L; - mac_subheader_len = 2; - } - - AssertFatal(pdu_len > mac_sdu_len, "The mac_sdu_len (%d) has an invalid size. PDU len = %d! \n", - mac_sdu_len, pdu_len); + ret=get_mac_len(pduP, pdu_len, &mac_len, &mac_subheader_len); + AssertFatal(ret, "The mac_len (%d) has an invalid size. PDU len = %d! \n", + mac_len, pdu_len); // Check if it is a valid CCCH message, we get all 00's messages very often int i = 0; - for(i=0; i<(mac_subheader_len+mac_sdu_len); i++) { + for(i=0; i<(mac_subheader_len+mac_len); i++) { if(pduP[i] != 0) { break; } } - if (i == (mac_subheader_len+mac_sdu_len)) { + if (i == (mac_subheader_len+mac_len)) { LOG_D(NR_MAC, "%s() Invalid CCCH message!, pdu_len: %d\n", __func__, pdu_len); done = 1; break; } - if ( mac_sdu_len > 0 ) { - LOG_D(NR_MAC,"DL_SCH_LCID_CCCH (e.g. RRCSetup) with payload len %d\n", mac_sdu_len); + if ( mac_len > 0 ) { + LOG_D(NR_MAC,"DL_SCH_LCID_CCCH (e.g. RRCSetup) with payload len %d\n", mac_len); for (int i = 0; i < mac_subheader_len; i++) { LOG_D(NR_MAC, "MAC header %d: 0x%x\n", i, pduP[i]); } - for (int i = 0; i < mac_sdu_len; i++) { + for (int i = 0; i < mac_len; i++) { LOG_D(NR_MAC, "%d: 0x%x\n", i, pduP[mac_subheader_len + i]); } - nr_mac_rrc_data_ind_ue(module_idP, CC_id, gNB_index, frameP, 0, mac->crnti, CCCH, pduP+mac_subheader_len, mac_sdu_len); + nr_mac_rrc_data_ind_ue(module_idP, CC_id, gNB_index, frameP, 0, mac->crnti, CCCH, pduP+mac_subheader_len, mac_len); } break; case DL_SCH_LCID_TCI_STATE_ACT_UE_SPEC_PDSCH: + case DL_SCH_LCID_APERIODIC_CSI_TRI_STATE_SUBSEL: + case DL_SCH_LCID_SP_CSI_RS_CSI_IM_RES_SET_ACT: + case DL_SCH_LCID_SP_SRS_ACTIVATION: // 38.321 Ch6.1.3.14 // varialbe length - mac_ce_len |= (uint16_t)((NR_MAC_SUBHEADER_SHORT *)pduP)->L; - mac_subheader_len = 2; - if(((NR_MAC_SUBHEADER_SHORT *)pduP)->F){ - mac_ce_len |= (uint16_t)(((NR_MAC_SUBHEADER_LONG *)pduP)->L2)<<8; - mac_subheader_len = 3; - } - break; - case DL_SCH_LCID_APERIODIC_CSI_TRI_STATE_SUBSEL: - // 38.321 Ch6.1.3.13 - // varialbe length - mac_ce_len |= (uint16_t)((NR_MAC_SUBHEADER_SHORT *)pduP)->L; - mac_subheader_len = 2; - if(((NR_MAC_SUBHEADER_SHORT *)pduP)->F){ - mac_ce_len |= (uint16_t)(((NR_MAC_SUBHEADER_LONG *)pduP)->L2)<<8; - mac_subheader_len = 3; - } - break; - case DL_SCH_LCID_SP_CSI_RS_CSI_IM_RES_SET_ACT: - // 38.321 Ch6.1.3.12 - // varialbe length - mac_ce_len |= (uint16_t)((NR_MAC_SUBHEADER_SHORT *)pduP)->L; - mac_subheader_len = 2; - if(((NR_MAC_SUBHEADER_SHORT *)pduP)->F){ - mac_ce_len |= (uint16_t)(((NR_MAC_SUBHEADER_LONG *)pduP)->L2)<<8; - mac_subheader_len = 3; - } - break; - case DL_SCH_LCID_SP_SRS_ACTIVATION: - // 38.321 Ch6.1.3.17 - // varialbe length - mac_ce_len |= (uint16_t)((NR_MAC_SUBHEADER_SHORT *)pduP)->L; - mac_subheader_len = 2; - if(((NR_MAC_SUBHEADER_SHORT *)pduP)->F){ - mac_ce_len |= (uint16_t)(((NR_MAC_SUBHEADER_LONG *)pduP)->L2)<<8; - mac_subheader_len = 3; - } + get_mac_len(pduP, pdu_len, &mac_len, &mac_subheader_len); break; + case DL_SCH_LCID_RECOMMENDED_BITRATE: // 38.321 Ch6.1.3.20 - mac_ce_len = 2; + mac_len = 2; break; case DL_SCH_LCID_SP_ZP_CSI_RS_RES_SET_ACT: // 38.321 Ch6.1.3.19 - mac_ce_len = 2; + mac_len = 2; break; case DL_SCH_LCID_PUCCH_SPATIAL_RELATION_ACT: // 38.321 Ch6.1.3.18 - mac_ce_len = 3; + mac_len = 3; break; case DL_SCH_LCID_SP_CSI_REP_PUCCH_ACT: // 38.321 Ch6.1.3.16 - mac_ce_len = 2; + mac_len = 2; break; case DL_SCH_LCID_TCI_STATE_IND_UE_SPEC_PDCCH: // 38.321 Ch6.1.3.15 - mac_ce_len = 2; + mac_len = 2; break; case DL_SCH_LCID_DUPLICATION_ACT: // 38.321 Ch6.1.3.11 - mac_ce_len = 1; + mac_len = 1; break; case DL_SCH_LCID_SCell_ACT_4_OCT: // 38.321 Ch6.1.3.10 - mac_ce_len = 4; + mac_len = 4; break; case DL_SCH_LCID_SCell_ACT_1_OCT: // 38.321 Ch6.1.3.10 - mac_ce_len = 1; + mac_len = 1; break; case DL_SCH_LCID_L_DRX: // 38.321 Ch6.1.3.6 // fixed length but not yet specify. - mac_ce_len = 0; + mac_len = 0; break; case DL_SCH_LCID_DRX: // 38.321 Ch6.1.3.5 // fixed length but not yet specify. - mac_ce_len = 0; + mac_len = 0; break; case DL_SCH_LCID_TA_COMMAND: // 38.321 Ch6.1.3.4 - mac_ce_len = 1; + mac_len = 1; /*uint8_t ta_command = ((NR_MAC_CE_TA *)pduP)[1].TA_COMMAND; uint8_t tag_id = ((NR_MAC_CE_TA *)pduP)[1].TAGID;*/ @@ -3501,14 +3589,14 @@ void nr_ue_process_mac_pdu(nr_downlink_indication_t *dl_info, // Clause 5.1.5 and 6.1.3.3 of 3GPP TS 38.321 version 16.2.1 Release 16 // MAC Header: 1 byte (R/R/LCID) // MAC SDU: 6 bytes (UE Contention Resolution Identity) - mac_ce_len = 6; + mac_len = 6; if(ra->ra_state == WAIT_CONTENTION_RESOLUTION) { LOG_I(MAC, "[UE %d][RAPROC] Frame %d : received contention resolution identity: 0x%02x%02x%02x%02x%02x%02x Terminating RA procedure\n", module_idP, frameP, pduP[1], pduP[2], pduP[3], pduP[4], pduP[5], pduP[6]); bool ra_success = true; - for(int i = 0; icont_res_id[i] != pduP[i+1]) { ra_success = false; break; @@ -3536,25 +3624,9 @@ void nr_ue_process_mac_pdu(nr_downlink_indication_t *dl_info, // check if LCID is valid at current time. default: { - // check if LCID is valid at current time. - if (pdu_len < sizeof(NR_MAC_SUBHEADER_SHORT)) - return; - NR_MAC_SUBHEADER_SHORT *shs = (NR_MAC_SUBHEADER_SHORT *)pduP; - if (shs->F) { - //mac_sdu_len |= (uint16_t)(((NR_MAC_SUBHEADER_LONG *)pduP)->L2)<<8; - mac_subheader_len = 3; - if (pdu_len < sizeof(NR_MAC_SUBHEADER_LONG)) - return; - NR_MAC_SUBHEADER_LONG *shl = (NR_MAC_SUBHEADER_LONG *)pduP; - mac_sdu_len = ((uint16_t)(shl->L1 & 0x7f) << 8) | (uint16_t)(shl->L2 & 0xff); - } else { - if (pdu_len < sizeof(NR_MAC_SUBHEADER_SHORT)) - return; - mac_sdu_len = (uint16_t)((NR_MAC_SUBHEADER_SHORT *)pduP)->L; - mac_subheader_len = 2; - } - - LOG_D(NR_MAC, "[UE %d] Frame %d : DLSCH -> DL-DTCH %d (gNB %d, %d bytes)\n", module_idP, frameP, rx_lcid, gNB_index, mac_sdu_len); + if (!get_mac_len(pduP, pdu_len, &mac_len, &mac_subheader_len)) + return; + LOG_D(NR_MAC, "[UE %d] %4d.%2d : DLSCH -> DL-DTCH %d (gNB %d, %d bytes)\n", module_idP, frameP, slot, rx_lcid, gNB_index, mac_len); #if defined(ENABLE_MAC_PAYLOAD_DEBUG) LOG_T(MAC, "[UE %d] First 32 bytes of DLSCH : \n", module_idP); @@ -3575,7 +3647,7 @@ void nr_ue_process_mac_pdu(nr_downlink_indication_t *dl_info, MBMS_FLAG_NO, rx_lcid, (char *) (pduP + mac_subheader_len), - mac_sdu_len, + mac_len, 1, NULL); } else { @@ -3586,8 +3658,8 @@ void nr_ue_process_mac_pdu(nr_downlink_indication_t *dl_info, break; } } - pduP += ( mac_subheader_len + mac_ce_len + mac_sdu_len ); - pdu_len -= ( mac_subheader_len + mac_ce_len + mac_sdu_len ); + pduP += ( mac_subheader_len + mac_len ); + pdu_len -= ( mac_subheader_len + mac_len ); if (pdu_len < 0) LOG_E(MAC, "[UE %d][%d.%d] nr_ue_process_mac_pdu, residual mac pdu length %d < 0!\n", module_idP, frameP, slot, pdu_len); } diff --git a/openair2/LAYER2/NR_MAC_UE/nr_ue_scheduler.c b/openair2/LAYER2/NR_MAC_UE/nr_ue_scheduler.c index e1058e1173..140fde407f 100644 --- a/openair2/LAYER2/NR_MAC_UE/nr_ue_scheduler.c +++ b/openair2/LAYER2/NR_MAC_UE/nr_ue_scheduler.c @@ -44,6 +44,7 @@ /* MAC */ #include "NR_MAC_COMMON/nr_mac.h" +#include "NR_MAC_COMMON/nr_mac_common.h" #include "NR_MAC_UE/mac_proto.h" #include "NR_MAC_UE/mac_extern.h" @@ -93,7 +94,8 @@ void fill_scheduled_response(nr_scheduled_response_t *scheduled_response, int cc_id, frame_t frame, int slot, - int thread_id){ + int thread_id, + void *phy_data){ scheduled_response->dl_config = dl_config; scheduled_response->ul_config = ul_config; @@ -103,6 +105,7 @@ void fill_scheduled_response(nr_scheduled_response_t *scheduled_response, scheduled_response->frame = frame; scheduled_response->slot = slot; scheduled_response->thread_id = thread_id; + scheduled_response->phy_data = phy_data; } @@ -112,18 +115,20 @@ void fill_scheduled_response(nr_scheduled_response_t *scheduled_response, */ long get_k2(NR_UE_MAC_INST_t *mac, uint8_t time_domain_ind) { long k2 = -1; + + NR_BWP_Id_t ul_bwp_id = mac->UL_BWP_Id; // Get K2 from RRC configuration - NR_PUSCH_Config_t *pusch_config=mac->ULbwp[0] ? mac->ULbwp[0]->bwp_Dedicated->pusch_Config->choice.setup : NULL; + NR_PUSCH_Config_t *pusch_config=mac->ULbwp[ul_bwp_id-1] ? mac->ULbwp[ul_bwp_id-1]->bwp_Dedicated->pusch_Config->choice.setup : NULL; NR_PUSCH_TimeDomainResourceAllocationList_t *pusch_TimeDomainAllocationList = NULL; if (pusch_config && pusch_config->pusch_TimeDomainAllocationList) { pusch_TimeDomainAllocationList = pusch_config->pusch_TimeDomainAllocationList->choice.setup; } - else if (mac->ULbwp[0] && - mac->ULbwp[0]->bwp_Common&& - mac->ULbwp[0]->bwp_Common->pusch_ConfigCommon&& - mac->ULbwp[0]->bwp_Common->pusch_ConfigCommon->choice.setup && - mac->ULbwp[0]->bwp_Common->pusch_ConfigCommon->choice.setup->pusch_TimeDomainAllocationList) { - pusch_TimeDomainAllocationList = mac->ULbwp[0]->bwp_Common->pusch_ConfigCommon->choice.setup->pusch_TimeDomainAllocationList; + else if (mac->ULbwp[ul_bwp_id-1] && + mac->ULbwp[ul_bwp_id-1]->bwp_Common&& + mac->ULbwp[ul_bwp_id-1]->bwp_Common->pusch_ConfigCommon&& + mac->ULbwp[ul_bwp_id-1]->bwp_Common->pusch_ConfigCommon->choice.setup && + mac->ULbwp[ul_bwp_id-1]->bwp_Common->pusch_ConfigCommon->choice.setup->pusch_TimeDomainAllocationList) { + pusch_TimeDomainAllocationList = mac->ULbwp[ul_bwp_id-1]->bwp_Common->pusch_ConfigCommon->choice.setup->pusch_TimeDomainAllocationList; } else if (mac->scc_SIB->uplinkConfigCommon->initialUplinkBWP.pusch_ConfigCommon->choice.setup->pusch_TimeDomainAllocationList) pusch_TimeDomainAllocationList=mac->scc_SIB->uplinkConfigCommon->initialUplinkBWP.pusch_ConfigCommon->choice.setup->pusch_TimeDomainAllocationList; @@ -152,6 +157,7 @@ long get_k2(NR_UE_MAC_INST_t *mac, uint8_t time_domain_ind) { */ fapi_nr_ul_config_request_t *get_ul_config_request(NR_UE_MAC_INST_t *mac, int slot) { + NR_BWP_Id_t ul_bwp_id = mac->UL_BWP_Id; NR_TDD_UL_DL_ConfigCommon_t *tdd_config = mac->scc==NULL ? mac->scc_SIB->tdd_UL_DL_ConfigurationCommon : mac->scc->tdd_UL_DL_ConfigurationCommon; //Check if request to access ul_config is for a UL slot @@ -163,8 +169,8 @@ fapi_nr_ul_config_request_t *get_ul_config_request(NR_UE_MAC_INST_t *mac, int sl // Calculate the index of the UL slot in mac->ul_config_request list. This is // based on the TDD pattern (slot configuration period) and number of UL+mixed // slots in the period. TS 38.213 Sec 11.1 - int mu = mac->ULbwp[0] ? - mac->ULbwp[0]->bwp_Common->genericParameters.subcarrierSpacing : + int mu = mac->ULbwp[ul_bwp_id-1] ? + mac->ULbwp[ul_bwp_id-1]->bwp_Common->genericParameters.subcarrierSpacing : mac->scc_SIB->uplinkConfigCommon->initialUplinkBWP.genericParameters.subcarrierSpacing; const int n = nr_slots_per_frame[mu]; const int num_slots_per_tdd = tdd_config ? (n >> (7 - tdd_config->pattern1.dl_UL_TransmissionPeriodicity)) : n; @@ -186,17 +192,21 @@ fapi_nr_ul_config_request_t *get_ul_config_request(NR_UE_MAC_INST_t *mac, int sl void ul_layers_config(NR_UE_MAC_INST_t * mac, nfapi_nr_ue_pusch_pdu_t *pusch_config_pdu, dci_pdu_rel15_t *dci) { NR_ServingCellConfigCommon_t *scc = mac->scc; + NR_BWP_Id_t ul_bwp_id = mac->UL_BWP_Id; NR_BWP_UplinkDedicated_t *ubwpd=NULL; + NR_SRS_Config_t *srs_config = NULL; if (mac->cg && mac->cg->spCellConfig && mac->cg->spCellConfig->spCellConfigDedicated && mac->cg->spCellConfig->spCellConfigDedicated->uplinkConfig && - mac->cg->spCellConfig->spCellConfigDedicated->uplinkConfig->initialUplinkBWP) + mac->cg->spCellConfig->spCellConfigDedicated->uplinkConfig->initialUplinkBWP) { ubwpd = mac->cg->spCellConfig->spCellConfigDedicated->uplinkConfig->initialUplinkBWP; + srs_config = mac->cg->spCellConfig->spCellConfigDedicated->uplinkConfig->initialUplinkBWP->srs_Config->choice.setup; + } - NR_PUSCH_Config_t *pusch_Config = mac->ULbwp[0] ? - mac->ULbwp[0]->bwp_Dedicated->pusch_Config->choice.setup : + NR_PUSCH_Config_t *pusch_Config = mac->ULbwp[ul_bwp_id-1] ? + mac->ULbwp[ul_bwp_id-1]->bwp_Dedicated->pusch_Config->choice.setup : (ubwpd? ubwpd->pusch_Config->choice.setup: NULL); @@ -210,7 +220,7 @@ void ul_layers_config(NR_UE_MAC_INST_t * mac, nfapi_nr_ue_pusch_pdu_t *pusch_con else transformPrecoder = NR_PUSCH_Config__transformPrecoder_disabled; } - + pusch_config_pdu->transform_precoding = transformPrecoder; /* PRECOD_NBR_LAYERS */ if ((*pusch_Config->txConfig == NR_PUSCH_Config__txConfig_nonCodebook)); @@ -218,11 +228,14 @@ void ul_layers_config(NR_UE_MAC_INST_t * mac, nfapi_nr_ue_pusch_pdu_t *pusch_con if ((*pusch_Config->txConfig == NR_PUSCH_Config__txConfig_codebook)){ - uint8_t n_antenna_port = 0; //FIXME!!! + // The UE shall transmit PUSCH using the same antenna port(s) as the SRS port(s) in the SRS resource indicated by the DCI format 0_1 + // 38.214 Section 6.1.1 + + uint8_t n_antenna_port = get_pusch_nb_antenna_ports(pusch_Config, srs_config, dci->srs_resource_indicator); if (n_antenna_port == 1); // 1 antenna port and the higher layer parameter txConfig = codebook 0 bits - if (n_antenna_port == 4){ // 4 antenna port and the higher layer parameter txConfig = codebook + if (n_antenna_port == 4) { // 4 antenna port and the higher layer parameter txConfig = codebook // Table 7.3.1.1.2-2: transformPrecoder=disabled and maxRank = 2 or 3 or 4 if ((transformPrecoder == NR_PUSCH_Config__transformPrecoder_disabled) @@ -232,54 +245,54 @@ void ul_layers_config(NR_UE_MAC_INST_t * mac, nfapi_nr_ue_pusch_pdu_t *pusch_con if (*pusch_Config->codebookSubset == NR_PUSCH_Config__codebookSubset_fullyAndPartialAndNonCoherent) { pusch_config_pdu->nrOfLayers = table_7_3_1_1_2_2_3_4_5[dci->precoding_information.val][0]; - pusch_config_pdu->transform_precoding = table_7_3_1_1_2_2_3_4_5[dci->precoding_information.val][1]; + pusch_config_pdu->Tpmi = table_7_3_1_1_2_2_3_4_5[dci->precoding_information.val][1]; } if (*pusch_Config->codebookSubset == NR_PUSCH_Config__codebookSubset_partialAndNonCoherent){ pusch_config_pdu->nrOfLayers = table_7_3_1_1_2_2_3_4_5[dci->precoding_information.val][2]; - pusch_config_pdu->transform_precoding = table_7_3_1_1_2_2_3_4_5[dci->precoding_information.val][3]; + pusch_config_pdu->Tpmi = table_7_3_1_1_2_2_3_4_5[dci->precoding_information.val][3]; } if (*pusch_Config->codebookSubset == NR_PUSCH_Config__codebookSubset_nonCoherent){ pusch_config_pdu->nrOfLayers = table_7_3_1_1_2_2_3_4_5[dci->precoding_information.val][4]; - pusch_config_pdu->transform_precoding = table_7_3_1_1_2_2_3_4_5[dci->precoding_information.val][5]; + pusch_config_pdu->Tpmi = table_7_3_1_1_2_2_3_4_5[dci->precoding_information.val][5]; } } // Table 7.3.1.1.2-3: transformPrecoder= enabled, or transformPrecoder=disabled and maxRank = 1 if (((transformPrecoder == NR_PUSCH_Config__transformPrecoder_enabled) || (transformPrecoder == NR_PUSCH_Config__transformPrecoder_disabled)) - && (*pusch_Config->maxRank == 1)){ + && (*pusch_Config->maxRank == 1)) { if (*pusch_Config->codebookSubset == NR_PUSCH_Config__codebookSubset_fullyAndPartialAndNonCoherent) { pusch_config_pdu->nrOfLayers = table_7_3_1_1_2_2_3_4_5[dci->precoding_information.val][6]; - pusch_config_pdu->transform_precoding = table_7_3_1_1_2_2_3_4_5[dci->precoding_information.val][7]; + pusch_config_pdu->Tpmi = table_7_3_1_1_2_2_3_4_5[dci->precoding_information.val][7]; } if (*pusch_Config->codebookSubset == NR_PUSCH_Config__codebookSubset_partialAndNonCoherent){ pusch_config_pdu->nrOfLayers = table_7_3_1_1_2_2_3_4_5[dci->precoding_information.val][8]; - pusch_config_pdu->transform_precoding = table_7_3_1_1_2_2_3_4_5[dci->precoding_information.val][9]; + pusch_config_pdu->Tpmi = table_7_3_1_1_2_2_3_4_5[dci->precoding_information.val][9]; } if (*pusch_Config->codebookSubset == NR_PUSCH_Config__codebookSubset_nonCoherent){ pusch_config_pdu->nrOfLayers = table_7_3_1_1_2_2_3_4_5[dci->precoding_information.val][10]; - pusch_config_pdu->transform_precoding = table_7_3_1_1_2_2_3_4_5[dci->precoding_information.val][11]; + pusch_config_pdu->Tpmi = table_7_3_1_1_2_2_3_4_5[dci->precoding_information.val][11]; } } } - if (n_antenna_port == 4){ // 2 antenna port and the higher layer parameter txConfig = codebook + if (n_antenna_port == 2) { + // 2 antenna port and the higher layer parameter txConfig = codebook // Table 7.3.1.1.2-4: transformPrecoder=disabled and maxRank = 2 - if ((transformPrecoder == NR_PUSCH_Config__transformPrecoder_disabled) && (*pusch_Config->maxRank == 2)){ - + if ((transformPrecoder == NR_PUSCH_Config__transformPrecoder_disabled) && (*pusch_Config->maxRank == 2)) { if (*pusch_Config->codebookSubset == NR_PUSCH_Config__codebookSubset_fullyAndPartialAndNonCoherent) { pusch_config_pdu->nrOfLayers = table_7_3_1_1_2_2_3_4_5[dci->precoding_information.val][12]; - pusch_config_pdu->transform_precoding = table_7_3_1_1_2_2_3_4_5[dci->precoding_information.val][13]; + pusch_config_pdu->Tpmi = table_7_3_1_1_2_2_3_4_5[dci->precoding_information.val][13]; } if (*pusch_Config->codebookSubset == NR_PUSCH_Config__codebookSubset_nonCoherent){ pusch_config_pdu->nrOfLayers = table_7_3_1_1_2_2_3_4_5[dci->precoding_information.val][14]; - pusch_config_pdu->transform_precoding = table_7_3_1_1_2_2_3_4_5[dci->precoding_information.val][15]; + pusch_config_pdu->Tpmi = table_7_3_1_1_2_2_3_4_5[dci->precoding_information.val][15]; } } @@ -287,16 +300,16 @@ void ul_layers_config(NR_UE_MAC_INST_t * mac, nfapi_nr_ue_pusch_pdu_t *pusch_con // Table 7.3.1.1.2-5: transformPrecoder= enabled, or transformPrecoder= disabled and maxRank = 1 if (((transformPrecoder == NR_PUSCH_Config__transformPrecoder_enabled) || (transformPrecoder == NR_PUSCH_Config__transformPrecoder_disabled)) - && (*pusch_Config->maxRank == 1)){ + && (*pusch_Config->maxRank == 1)) { if (*pusch_Config->codebookSubset == NR_PUSCH_Config__codebookSubset_fullyAndPartialAndNonCoherent) { pusch_config_pdu->nrOfLayers = table_7_3_1_1_2_2_3_4_5[dci->precoding_information.val][16]; - pusch_config_pdu->transform_precoding = table_7_3_1_1_2_2_3_4_5[dci->precoding_information.val][17]; + pusch_config_pdu->Tpmi = table_7_3_1_1_2_2_3_4_5[dci->precoding_information.val][17]; } if (*pusch_Config->codebookSubset == NR_PUSCH_Config__codebookSubset_nonCoherent){ pusch_config_pdu->nrOfLayers = table_7_3_1_1_2_2_3_4_5[dci->precoding_information.val][18]; - pusch_config_pdu->transform_precoding = table_7_3_1_1_2_2_3_4_5[dci->precoding_information.val][19]; + pusch_config_pdu->Tpmi = table_7_3_1_1_2_2_3_4_5[dci->precoding_information.val][19]; } } @@ -305,9 +318,9 @@ void ul_layers_config(NR_UE_MAC_INST_t * mac, nfapi_nr_ue_pusch_pdu_t *pusch_con /*-------------------- Changed to enable Transform precoding in RF SIM------------------------------------------------*/ - /*if (pusch_config_pdu->transform_precoding == transform_precoder_enabled) { + /*if (pusch_config_pdu->transformPrecoder == transformPrecoder_enabled) { - pusch_config_dedicated->transform_precoder = transform_precoder_enabled; + pusch_config_dedicated->transform_precoder = transformPrecoder_enabled; if(pusch_Config->dmrs_UplinkForPUSCH_MappingTypeA != NULL) { @@ -329,15 +342,15 @@ void ul_layers_config(NR_UE_MAC_INST_t * mac, nfapi_nr_ue_pusch_pdu_t *pusch_con } } else - pusch_config_dedicated->transform_precoder = transform_precoder_disabled;*/ + pusch_config_dedicated->transformPrecoder = ttransformPrecoder_disabled;*/ } // todo: this function shall be reviewed completely because of the many comments left by the author -void ul_ports_config(NR_UE_MAC_INST_t * mac, nfapi_nr_ue_pusch_pdu_t *pusch_config_pdu, dci_pdu_rel15_t *dci) { +void ul_ports_config(NR_UE_MAC_INST_t *mac, int *n_front_load_symb, nfapi_nr_ue_pusch_pdu_t *pusch_config_pdu, dci_pdu_rel15_t *dci) { - /* ANTENNA_PORTS */ - uint8_t rank = 1; // We need to initialize rank FIXME!!! + uint8_t rank = pusch_config_pdu->nrOfLayers; + NR_BWP_Id_t ul_bwp_id = mac->UL_BWP_Id; NR_ServingCellConfigCommon_t *scc = mac->scc; NR_BWP_UplinkDedicated_t *ubwpd=NULL; @@ -348,7 +361,7 @@ void ul_ports_config(NR_UE_MAC_INST_t * mac, nfapi_nr_ue_pusch_pdu_t *pusch_conf mac->cg->spCellConfig->spCellConfigDedicated->uplinkConfig->initialUplinkBWP) ubwpd = mac->cg->spCellConfig->spCellConfigDedicated->uplinkConfig->initialUplinkBWP; - NR_PUSCH_Config_t *pusch_Config = mac->ULbwp[0] ? mac->ULbwp[0]->bwp_Dedicated->pusch_Config->choice.setup : (ubwpd?ubwpd->pusch_Config->choice.setup:NULL); + NR_PUSCH_Config_t *pusch_Config = mac->ULbwp[ul_bwp_id-1] ? mac->ULbwp[ul_bwp_id-1]->bwp_Dedicated->pusch_Config->choice.setup : (ubwpd?ubwpd->pusch_Config->choice.setup:NULL); AssertFatal(pusch_Config!=NULL,"pusch_Config shouldn't be null\n"); long transformPrecoder; @@ -373,51 +386,44 @@ void ul_ports_config(NR_UE_MAC_INST_t * mac, nfapi_nr_ue_pusch_pdu_t *pusch_conf dmrs_type = pusch_Config->dmrs_UplinkForPUSCH_MappingTypeB->choice.setup->dmrs_Type; } - LOG_D(NR_MAC,"MappingType%s max_length %s, dmrs_type %s, antenna_ports %d\n",pusch_Config->dmrs_UplinkForPUSCH_MappingTypeA?"A":"B",max_length?"len2":"len1",dmrs_type?"type2":"type1",dci->antenna_ports.val); + LOG_D(NR_MAC,"MappingType%s max_length %s, dmrs_type %s, antenna_ports %d\n", + pusch_Config->dmrs_UplinkForPUSCH_MappingTypeA?"A":"B",max_length?"len2":"len1",dmrs_type?"type2":"type1",dci->antenna_ports.val); + if ((transformPrecoder == NR_PUSCH_Config__transformPrecoder_enabled) && - (dmrs_type == NULL) && (max_length == NULL)) { // tables 7.3.1.1.2-6 - pusch_config_pdu->num_dmrs_cdm_grps_no_data = 2; //TBC - pusch_config_pdu->dmrs_ports = dci->antenna_ports.val; //TBC + (dmrs_type == NULL) && (max_length == NULL)) { // tables 7.3.1.1.2-6 + pusch_config_pdu->num_dmrs_cdm_grps_no_data = 2; + pusch_config_pdu->dmrs_ports = 1<antenna_ports.val; } if ((transformPrecoder == NR_PUSCH_Config__transformPrecoder_enabled) && - (dmrs_type == NULL) && (max_length != NULL)) { // tables 7.3.1.1.2-7 + (dmrs_type == NULL) && (max_length != NULL)) { // tables 7.3.1.1.2-7 pusch_config_pdu->num_dmrs_cdm_grps_no_data = 2; //TBC - pusch_config_pdu->dmrs_ports = (dci->antenna_ports.val > 3)?(dci->antenna_ports.val-4):(dci->antenna_ports.val); //TBC - //pusch_config_pdu->n_front_load_symb = (dci->antenna_ports > 3)?2:1; //FIXME + pusch_config_pdu->dmrs_ports = 1<<((dci->antenna_ports.val > 3)?(dci->antenna_ports.val-4):(dci->antenna_ports.val)); + *n_front_load_symb = (dci->antenna_ports.val > 3)?2:1; } if ((transformPrecoder == NR_PUSCH_Config__transformPrecoder_disabled) && (dmrs_type == NULL) && (max_length == NULL)) { // tables 7.3.1.1.2-8/9/10/11 if (rank == 1) { - pusch_config_pdu->num_dmrs_cdm_grps_no_data = (dci->antenna_ports.val > 1)?2:1; //TBC - pusch_config_pdu->dmrs_ports = (dci->antenna_ports.val > 1)?(dci->antenna_ports.val-2):(dci->antenna_ports.val); //TBC + pusch_config_pdu->num_dmrs_cdm_grps_no_data = (dci->antenna_ports.val > 1)?2:1; + pusch_config_pdu->dmrs_ports =1<<((dci->antenna_ports.val > 1)?(dci->antenna_ports.val-2):(dci->antenna_ports.val)); } if (rank == 2){ - pusch_config_pdu->num_dmrs_cdm_grps_no_data = (dci->antenna_ports.val > 0)?2:1; //TBC - pusch_config_pdu->dmrs_ports = 0; //FIXME - //pusch_config_pdu->dmrs_ports[0] = (dci->antenna_ports > 1)?(dci->antenna_ports > 2 ?0:2):0; - //pusch_config_pdu->dmrs_ports[1] = (dci->antenna_ports > 1)?(dci->antenna_ports > 2 ?2:3):1; + pusch_config_pdu->num_dmrs_cdm_grps_no_data = (dci->antenna_ports.val > 0)?2:1; + pusch_config_pdu->dmrs_ports = (dci->antenna_ports.val > 1)?((dci->antenna_ports.val> 2)?0x5:0xc):0x3; } if (rank == 3){ - pusch_config_pdu->num_dmrs_cdm_grps_no_data = 2; //TBC - pusch_config_pdu->dmrs_ports = 0; //FIXME - //pusch_config_pdu->dmrs_ports[0] = 0; - //pusch_config_pdu->dmrs_ports[1] = 1; - //pusch_config_pdu->dmrs_ports[2] = 2; + pusch_config_pdu->num_dmrs_cdm_grps_no_data = 2; + pusch_config_pdu->dmrs_ports = 0x7; // ports 0-2 } if (rank == 4){ - pusch_config_pdu->num_dmrs_cdm_grps_no_data = 2; //TBC - pusch_config_pdu->dmrs_ports = 0; //FIXME - //pusch_config_pdu->dmrs_ports[0] = 0; - //pusch_config_pdu->dmrs_ports[1] = 1; - //pusch_config_pdu->dmrs_ports[2] = 2; - //pusch_config_pdu->dmrs_ports[3] = 3; + pusch_config_pdu->num_dmrs_cdm_grps_no_data = 2; + pusch_config_pdu->dmrs_ports = 0xf; // ports 0-3 } } @@ -426,8 +432,8 @@ void ul_ports_config(NR_UE_MAC_INST_t * mac, nfapi_nr_ue_pusch_pdu_t *pusch_conf if (rank == 1){ pusch_config_pdu->num_dmrs_cdm_grps_no_data = (dci->antenna_ports.val > 1)?2:1; //TBC - pusch_config_pdu->dmrs_ports = (dci->antenna_ports.val > 1)?(dci->antenna_ports.val > 5 ?(dci->antenna_ports.val-6):(dci->antenna_ports.val-2)):dci->antenna_ports.val; //TBC - //pusch_config_pdu->n_front_load_symb = (dci->antenna_ports.val > 6)?2:1; //FIXME + pusch_config_pdu->dmrs_ports = 1<<((dci->antenna_ports.val > 1)?(dci->antenna_ports.val > 5 ?(dci->antenna_ports.val-6):(dci->antenna_ports.val-2)):dci->antenna_ports.val); + *n_front_load_symb = (dci->antenna_ports.val > 6)?2:1; } if (rank == 2){ @@ -435,7 +441,7 @@ void ul_ports_config(NR_UE_MAC_INST_t * mac, nfapi_nr_ue_pusch_pdu_t *pusch_conf pusch_config_pdu->dmrs_ports = 0; //FIXME //pusch_config_pdu->dmrs_ports[0] = table_7_3_1_1_2_13[dci->antenna_ports.val][1]; //pusch_config_pdu->dmrs_ports[1] = table_7_3_1_1_2_13[dci->antenna_ports.val][2]; - //pusch_config_pdu->n_front_load_symb = (dci->antenna_ports.val > 3)?2:1; // FIXME + //n_front_load_symb = (dci->antenna_ports.val > 3)?2:1; // FIXME } if (rank == 3){ @@ -444,7 +450,7 @@ void ul_ports_config(NR_UE_MAC_INST_t * mac, nfapi_nr_ue_pusch_pdu_t *pusch_conf //pusch_config_pdu->dmrs_ports[0] = table_7_3_1_1_2_14[dci->antenna_ports.val][1]; //pusch_config_pdu->dmrs_ports[1] = table_7_3_1_1_2_14[dci->antenna_ports.val][2]; //pusch_config_pdu->dmrs_ports[2] = table_7_3_1_1_2_14[dci->antenna_ports.val][3]; - //pusch_config_pdu->n_front_load_symb = (dci->antenna_ports.val > 1)?2:1; //FIXME + //n_front_load_symb = (dci->antenna_ports.val > 1)?2:1; //FIXME } if (rank == 4){ @@ -454,7 +460,7 @@ void ul_ports_config(NR_UE_MAC_INST_t * mac, nfapi_nr_ue_pusch_pdu_t *pusch_conf //pusch_config_pdu->dmrs_ports[1] = table_7_3_1_1_2_15[dci->antenna_ports.val][2]; //pusch_config_pdu->dmrs_ports[2] = table_7_3_1_1_2_15[dci->antenna_ports.val][3]; //pusch_config_pdu->dmrs_ports[3] = table_7_3_1_1_2_15[dci->antenna_ports.val][4]; - //pusch_config_pdu->n_front_load_symb = (dci->antenna_ports.val > 1)?2:1; //FIXME + //n_front_load_symb = (dci->antenna_ports.val > 1)?2:1; //FIXME } } @@ -498,7 +504,7 @@ void ul_ports_config(NR_UE_MAC_INST_t * mac, nfapi_nr_ue_pusch_pdu_t *pusch_conf if (rank == 1){ pusch_config_pdu->num_dmrs_cdm_grps_no_data = table_7_3_1_1_2_20[dci->antenna_ports.val][0]; //TBC pusch_config_pdu->dmrs_ports = table_7_3_1_1_2_20[dci->antenna_ports.val][1]; //TBC - //pusch_config_pdu->n_front_load_symb = table_7_3_1_1_2_20[dci->antenna_ports.val][2]; //FIXME + //n_front_load_symb = table_7_3_1_1_2_20[dci->antenna_ports.val][2]; //FIXME } if (rank == 2){ @@ -506,7 +512,7 @@ void ul_ports_config(NR_UE_MAC_INST_t * mac, nfapi_nr_ue_pusch_pdu_t *pusch_conf pusch_config_pdu->dmrs_ports = 0; //FIXME //pusch_config_pdu->dmrs_ports[0] = table_7_3_1_1_2_21[dci->antenna_ports.val][1]; //pusch_config_pdu->dmrs_ports[1] = table_7_3_1_1_2_21[dci->antenna_ports.val][2]; - //pusch_config_pdu->n_front_load_symb = table_7_3_1_1_2_21[dci->antenna_ports.val][3]; //FIXME + //n_front_load_symb = table_7_3_1_1_2_21[dci->antenna_ports.val][3]; //FIXME } if (rank == 3){ @@ -515,7 +521,7 @@ void ul_ports_config(NR_UE_MAC_INST_t * mac, nfapi_nr_ue_pusch_pdu_t *pusch_conf //pusch_config_pdu->dmrs_ports[0] = table_7_3_1_1_2_22[dci->antenna_ports.val][1]; //pusch_config_pdu->dmrs_ports[1] = table_7_3_1_1_2_22[dci->antenna_ports.val][2]; //pusch_config_pdu->dmrs_ports[2] = table_7_3_1_1_2_22[dci->antenna_ports.val][3]; - //pusch_config_pdu->n_front_load_symb = table_7_3_1_1_2_22[dci->antenna_ports.val][4]; //FIXME + //n_front_load_symb = table_7_3_1_1_2_22[dci->antenna_ports.val][4]; //FIXME } if (rank == 4){ @@ -525,7 +531,7 @@ void ul_ports_config(NR_UE_MAC_INST_t * mac, nfapi_nr_ue_pusch_pdu_t *pusch_conf //pusch_config_pdu->dmrs_ports[1] = table_7_3_1_1_2_23[dci->antenna_ports.val][2]; //pusch_config_pdu->dmrs_ports[2] = table_7_3_1_1_2_23[dci->antenna_ports.val][3]; //pusch_config_pdu->dmrs_ports[3] = table_7_3_1_1_2_23[dci->antenna_ports.val][4]; - //pusch_config_pdu->n_front_load_symb = table_7_3_1_1_2_23[dci->antenna_ports.val][5]; //FIXME + //n_front_load_symb = table_7_3_1_1_2_23[dci->antenna_ports.val][5]; //FIXME } } LOG_D(NR_MAC,"num_dmrs_cdm_grps_no_data %d, dmrs_ports %d\n",pusch_config_pdu->num_dmrs_cdm_grps_no_data,pusch_config_pdu->dmrs_ports); @@ -557,23 +563,25 @@ int nr_config_pusch_pdu(NR_UE_MAC_INST_t *mac, int N_PRB_oh = 0; int rnti_type = get_rnti_type(mac, rnti); + NR_BWP_Id_t ul_bwp_id = mac->UL_BWP_Id; // Common configuration pusch_config_pdu->dmrs_config_type = pusch_dmrs_type1; pusch_config_pdu->pdu_bit_map = PUSCH_PDU_BITMAP_PUSCH_DATA; pusch_config_pdu->nrOfLayers = 1; + pusch_config_pdu->Tpmi = 0; pusch_config_pdu->rnti = rnti; NR_BWP_UplinkCommon_t *initialUplinkBWP; if (mac->scc) initialUplinkBWP = mac->scc->uplinkConfigCommon->initialUplinkBWP; else initialUplinkBWP = &mac->scc_SIB->uplinkConfigCommon->initialUplinkBWP; pusch_dmrs_AdditionalPosition_t add_pos = pusch_dmrs_pos2; - pusch_maxLength_t dmrslength = pusch_len1; + int dmrslength = 1; if (rar_grant) { // Note: for Msg3 or MsgA PUSCH transmission the N_PRB_oh is always set to 0 - NR_BWP_Uplink_t *ubwp = mac->ULbwp[0]; + NR_BWP_Uplink_t *ubwp = mac->ULbwp[ul_bwp_id-1]; NR_BWP_UplinkDedicated_t *ibwp; int scs,abwp_start,abwp_size,startSymbolAndLength,mappingtype; NR_PUSCH_Config_t *pusch_Config=NULL; @@ -684,13 +692,12 @@ int nr_config_pusch_pdu(NR_UE_MAC_INST_t *mac, int target_ss; bool valid_ptrs_setup = 0; - uint16_t n_RB_ULBWP; - n_RB_ULBWP = NRRIV2BW(ubwpc->genericParameters.locationAndBandwidth, MAX_BWP_SIZE); + + uint16_t n_RB_ULBWP = NRRIV2BW(ubwpc->genericParameters.locationAndBandwidth, MAX_BWP_SIZE); pusch_config_pdu->bwp_start = NRRIV2PRBOFFSET(ubwpc->genericParameters.locationAndBandwidth, MAX_BWP_SIZE); pusch_config_pdu->bwp_size = n_RB_ULBWP; - AssertFatal(ubwpd->pusch_Config != NULL,"pusch_Config shouldn't be null\n"); - NR_PUSCH_Config_t *pusch_Config = ubwpd->pusch_Config->choice.setup; + const NR_PUSCH_Config_t *pusch_Config = ubwpd? ubwpd->pusch_Config->choice.setup : NULL; // Basic sanity check for MCS value to check for a false or erroneous DCI if (dci->mcs > 28) { @@ -711,11 +718,12 @@ int nr_config_pusch_pdu(NR_UE_MAC_INST_t *mac, } else if (*dci_format == NR_UL_DCI_FORMAT_0_1) { config_bwp_ue(mac, &dci->bwp_indicator.val, dci_format); + get_bwp_info(mac,dl_bwp_id,ul_bwp_id,&bwpd,&bwpc,&ubwpd,&ubwpc); target_ss = NR_SearchSpace__searchSpaceType_PR_ue_Specific; ul_layers_config(mac, pusch_config_pdu, dci); - ul_ports_config(mac, pusch_config_pdu, dci); + ul_ports_config(mac, &dmrslength, pusch_config_pdu, dci); } else { @@ -723,6 +731,7 @@ int nr_config_pusch_pdu(NR_UE_MAC_INST_t *mac, return -1; } + NR_PUSCH_ConfigCommon_t *pusch_ConfigCommon = ubwpc->pusch_ConfigCommon->choice.setup; NR_PUSCH_TimeDomainResourceAllocationList_t *pusch_TimeDomainAllocationList = choose_ul_tda_list(pusch_Config,pusch_ConfigCommon); @@ -734,6 +743,11 @@ int nr_config_pusch_pdu(NR_UE_MAC_INST_t *mac, ? pusch_Config->dmrs_UplinkForPUSCH_MappingTypeA->choice.setup : pusch_Config->dmrs_UplinkForPUSCH_MappingTypeB->choice.setup; } + pusch_config_pdu->scid = 0; + pusch_config_pdu->ul_dmrs_scrambling_id = mac->physCellId; + if(*dci_format == NR_UL_DCI_FORMAT_0_1) + pusch_config_pdu->scid = dci->dmrs_sequence_initialization.val; + /* TRANSFORM PRECODING ------------------------------------------------------------------------------------------*/ if (pusch_config_pdu->transform_precoding == NR_PUSCH_Config__transformPrecoder_enabled) { @@ -741,7 +755,8 @@ int nr_config_pusch_pdu(NR_UE_MAC_INST_t *mac, pusch_config_pdu->num_dmrs_cdm_grps_no_data = 2; uint32_t n_RS_Id = 0; - if (NR_DMRS_ulconfig->transformPrecodingEnabled->nPUSCH_Identity != NULL) + if (NR_DMRS_ulconfig->transformPrecodingEnabled && + NR_DMRS_ulconfig->transformPrecodingEnabled->nPUSCH_Identity != NULL) n_RS_Id = *NR_DMRS_ulconfig->transformPrecodingEnabled->nPUSCH_Identity; else n_RS_Id = *mac->scc->physCellId; @@ -759,6 +774,14 @@ int nr_config_pusch_pdu(NR_UE_MAC_INST_t *mac, LOG_D(NR_MAC,"TRANSFORM PRECODING IS ENABLED. CDM groups: %d, U: %d \n", pusch_config_pdu->num_dmrs_cdm_grps_no_data, pusch_config_pdu->dfts_ofdm.low_papr_group_number); } + else { + if (pusch_config_pdu->scid == 0 && NR_DMRS_ulconfig && + NR_DMRS_ulconfig->transformPrecodingDisabled->scramblingID0) + pusch_config_pdu->ul_dmrs_scrambling_id = *NR_DMRS_ulconfig->transformPrecodingDisabled->scramblingID0; + if (pusch_config_pdu->scid == 1 && NR_DMRS_ulconfig && + NR_DMRS_ulconfig->transformPrecodingDisabled->scramblingID1) + pusch_config_pdu->ul_dmrs_scrambling_id = *NR_DMRS_ulconfig->transformPrecodingDisabled->scramblingID1; + } /* TRANSFORM PRECODING --------------------------------------------------------------------------------------------------------*/ @@ -808,20 +831,21 @@ int nr_config_pusch_pdu(NR_UE_MAC_INST_t *mac, pusch_config_pdu->absolute_delta_PUSCH = 4; } - if (NR_DMRS_ulconfig != NULL) { + if (NR_DMRS_ulconfig != NULL) add_pos = (NR_DMRS_ulconfig->dmrs_AdditionalPosition == NULL) ? 2 : *NR_DMRS_ulconfig->dmrs_AdditionalPosition; - dmrslength = NR_DMRS_ulconfig->maxLength == NULL ? pusch_len1 : pusch_len2; - } /* DMRS */ l_prime_mask = get_l_prime(pusch_config_pdu->nr_of_symbols, mappingtype, add_pos, dmrslength, pusch_config_pdu->start_symbol_index, mac->scc ? mac->scc->dmrs_TypeA_Position : mac->mib->dmrs_TypeA_Position); - if ((mac->ULbwp[0] && pusch_config_pdu->transform_precoding == NR_PUSCH_Config__transformPrecoder_disabled)) - pusch_config_pdu->num_dmrs_cdm_grps_no_data = 1; - else if (*dci_format == NR_UL_DCI_FORMAT_0_0 || (mac->ULbwp[0] && pusch_config_pdu->transform_precoding == NR_PUSCH_Config__transformPrecoder_enabled)) + if ((mac->ULbwp[ul_bwp_id-1] && pusch_config_pdu->transform_precoding == NR_PUSCH_Config__transformPrecoder_disabled)) { + if (*dci_format != NR_UL_DCI_FORMAT_0_1) { + pusch_config_pdu->num_dmrs_cdm_grps_no_data = 1; + } + } else if (*dci_format == NR_UL_DCI_FORMAT_0_0 || (mac->ULbwp[ul_bwp_id-1] && pusch_config_pdu->transform_precoding == NR_PUSCH_Config__transformPrecoder_enabled)) { pusch_config_pdu->num_dmrs_cdm_grps_no_data = 2; + } // Num PRB Overhead from PUSCH-ServingCellConfig if (mac->cg && @@ -835,16 +859,16 @@ int nr_config_pusch_pdu(NR_UE_MAC_INST_t *mac, else N_PRB_oh = 0; /* PTRS */ - if (mac->ULbwp[0] && - mac->ULbwp[0]->bwp_Dedicated && - mac->ULbwp[0]->bwp_Dedicated->pusch_Config && - mac->ULbwp[0]->bwp_Dedicated->pusch_Config->choice.setup && - mac->ULbwp[0]->bwp_Dedicated->pusch_Config->choice.setup->dmrs_UplinkForPUSCH_MappingTypeB && - mac->ULbwp[0]->bwp_Dedicated->pusch_Config->choice.setup->dmrs_UplinkForPUSCH_MappingTypeB->choice.setup->phaseTrackingRS) { + if (mac->ULbwp[ul_bwp_id-1] && + mac->ULbwp[ul_bwp_id-1]->bwp_Dedicated && + mac->ULbwp[ul_bwp_id-1]->bwp_Dedicated->pusch_Config && + mac->ULbwp[ul_bwp_id-1]->bwp_Dedicated->pusch_Config->choice.setup && + mac->ULbwp[ul_bwp_id-1]->bwp_Dedicated->pusch_Config->choice.setup->dmrs_UplinkForPUSCH_MappingTypeB && + mac->ULbwp[ul_bwp_id-1]->bwp_Dedicated->pusch_Config->choice.setup->dmrs_UplinkForPUSCH_MappingTypeB->choice.setup->phaseTrackingRS) { if (pusch_config_pdu->transform_precoding == NR_PUSCH_Config__transformPrecoder_disabled) { nfapi_nr_ue_ptrs_ports_t ptrs_ports_list; pusch_config_pdu->pusch_ptrs.ptrs_ports_list = &ptrs_ports_list; - valid_ptrs_setup = set_ul_ptrs_values(mac->ULbwp[0]->bwp_Dedicated->pusch_Config->choice.setup->dmrs_UplinkForPUSCH_MappingTypeB->choice.setup->phaseTrackingRS->choice.setup, + valid_ptrs_setup = set_ul_ptrs_values(mac->ULbwp[ul_bwp_id-1]->bwp_Dedicated->pusch_Config->choice.setup->dmrs_UplinkForPUSCH_MappingTypeB->choice.setup->phaseTrackingRS->choice.setup, pusch_config_pdu->rb_size, pusch_config_pdu->mcs_index, pusch_config_pdu->mcs_table, &pusch_config_pdu->pusch_ptrs.ptrs_freq_density,&pusch_config_pdu->pusch_ptrs.ptrs_time_density, &pusch_config_pdu->pusch_ptrs.ptrs_ports_list->ptrs_re_offset,&pusch_config_pdu->pusch_ptrs.num_ptrs_ports, @@ -867,7 +891,8 @@ int nr_config_pusch_pdu(NR_UE_MAC_INST_t *mac, rnti_types[rnti_type]); pusch_config_pdu->ul_dmrs_symb_pos = l_prime_mask; - pusch_config_pdu->target_code_rate = nr_get_code_rate_ul(pusch_config_pdu->mcs_index, pusch_config_pdu->mcs_table); + uint16_t R = nr_get_code_rate_ul(pusch_config_pdu->mcs_index, pusch_config_pdu->mcs_table); + pusch_config_pdu->target_code_rate = R; pusch_config_pdu->qam_mod_order = nr_get_Qm_ul(pusch_config_pdu->mcs_index, pusch_config_pdu->mcs_table); if (pusch_config_pdu->target_code_rate == 0 || pusch_config_pdu->qam_mod_order == 0) { @@ -886,14 +911,13 @@ int nr_config_pusch_pdu(NR_UE_MAC_INST_t *mac, // Compute TBS pusch_config_pdu->pusch_data.tb_size = nr_compute_tbs(pusch_config_pdu->qam_mod_order, - pusch_config_pdu->target_code_rate, + R, pusch_config_pdu->rb_size, pusch_config_pdu->nr_of_symbols, nb_dmrs_re_per_rb*number_dmrs_symbols, N_PRB_oh, 0, // TBR to verify tb scaling - pusch_config_pdu->nrOfLayers)/8; - + pusch_config_pdu->nrOfLayers)>>3; return 0; } @@ -940,9 +964,10 @@ bool nr_ue_periodic_srs_scheduling(module_id_t mod_id, frame_t frame, slot_t slo continue; } - NR_BWP_t ubwp = mac->ULbwp[0] ? - mac->ULbwp[0]->bwp_Common->genericParameters : - mac->scc_SIB->uplinkConfigCommon->initialUplinkBWP.genericParameters; + NR_BWP_Id_t ul_bwp_id = mac->UL_BWP_Id; + NR_BWP_t ubwp = ul_bwp_id > 0 && mac->ULbwp[ul_bwp_id-1] ? + mac->ULbwp[ul_bwp_id-1]->bwp_Common->genericParameters : + mac->scc_SIB->uplinkConfigCommon->initialUplinkBWP.genericParameters; uint16_t period = srs_period[srs_resource->resourceType.choice.periodic->periodicityAndOffset_p.present]; uint16_t offset = get_nr_srs_offset(srs_resource->resourceType.choice.periodic->periodicityAndOffset_p); @@ -1047,9 +1072,6 @@ NR_UE_L2_STATE_t nr_ue_scheduler(nr_downlink_indication_t *dl_info, nr_uplink_in if(mac->cg != NULL){ // we have a cg - nr_schedule_csirs_reception(mac, rx_frame, rx_slot); - nr_schedule_csi_for_im(mac, rx_frame, rx_slot); - dcireq.module_id = mod_id; dcireq.gNB_index = gNB_index; dcireq.cc_id = cc_id; @@ -1059,9 +1081,14 @@ NR_UE_L2_STATE_t nr_ue_scheduler(nr_downlink_indication_t *dl_info, nr_uplink_in nr_ue_dcireq(&dcireq); //to be replaced with function pointer later mac->dl_config_request = dcireq.dl_config_req; - fill_scheduled_response(&scheduled_response, &dcireq.dl_config_req, NULL, NULL, mod_id, cc_id, rx_frame, rx_slot, dl_info->thread_id); + nr_schedule_csirs_reception(mac, rx_frame, rx_slot); + nr_schedule_csi_for_im(mac, rx_frame, rx_slot); + dcireq.dl_config_req = mac->dl_config_request; + + fill_scheduled_response(&scheduled_response, &dcireq.dl_config_req, NULL, NULL, mod_id, cc_id, rx_frame, rx_slot, dl_info->thread_id, dl_info->phy_data); if(mac->if_module != NULL && mac->if_module->scheduled_response != NULL) - mac->if_module->scheduled_response(&scheduled_response); + LOG_D(NR_MAC,"1# scheduled_response transmitted, %d, %d\n", rx_frame, rx_slot); + mac->if_module->scheduled_response(&scheduled_response); } else { // this is for Msg2/Msg4 @@ -1072,13 +1099,17 @@ NR_UE_L2_STATE_t nr_ue_scheduler(nr_downlink_indication_t *dl_info, nr_uplink_in if (mac->ra.ra_state == WAIT_CONTENTION_RESOLUTION) rel15->dci_format_options[1] = NR_UL_DCI_FORMAT_0_0; // msg3 retransmission config_dci_pdu(mac, rel15, dl_config, mac->ra.ra_state == WAIT_RAR ? NR_RNTI_RA : NR_RNTI_TC , mac->ra.ss->searchSpaceId); - fill_dci_search_candidates(mac->ra.ss, rel15); + fill_dci_search_candidates(mac->ra.ss, rel15, -1 , -1); dl_config->number_pdus = 1; LOG_D(MAC,"mac->cg %p: Calling fill_scheduled_response rnti %x, type0_pdcch, num_pdus %d\n",mac->cg,rel15->rnti,dl_config->number_pdus); - fill_scheduled_response(&scheduled_response, dl_config, NULL, NULL, mod_id, cc_id, rx_frame, rx_slot, dl_info->thread_id); + fill_scheduled_response(&scheduled_response, dl_config, NULL, NULL, mod_id, cc_id, rx_frame, rx_slot, dl_info->thread_id, dl_info->phy_data); if(mac->if_module != NULL && mac->if_module->scheduled_response != NULL) mac->if_module->scheduled_response(&scheduled_response); } + else + { + dl_config->number_pdus = 0; + } } } else if (ul_info) { @@ -1119,7 +1150,7 @@ NR_UE_L2_STATE_t nr_ue_scheduler(nr_downlink_indication_t *dl_info, nr_uplink_in tx_req.number_of_pdus = 0; for (int j = 0; j < ul_config->number_pdus; j++) { - uint8_t *ulsch_input_buffer = &(ulsch_input_buffer_array[tx_req.number_of_pdus][MAX_ULSCH_PAYLOAD_BYTES]); + uint8_t *ulsch_input_buffer = ulsch_input_buffer_array[tx_req.number_of_pdus]; fapi_nr_ul_config_request_pdu_t *ulcfg_pdu = &ul_config->ul_config_list[j]; @@ -1180,8 +1211,9 @@ NR_UE_L2_STATE_t nr_ue_scheduler(nr_downlink_indication_t *dl_info, nr_uplink_in } pthread_mutex_unlock(&ul_config->mutex_ul_config); // avoid double lock - fill_scheduled_response(&scheduled_response, NULL, ul_config, &tx_req, mod_id, cc_id, frame_tx, slot_tx, ul_info->thread_id); + fill_scheduled_response(&scheduled_response, NULL, ul_config, &tx_req, mod_id, cc_id, frame_tx, slot_tx, ul_info->thread_id, NULL); if(mac->if_module != NULL && mac->if_module->scheduled_response != NULL){ + LOG_D(NR_MAC,"3# scheduled_response transmitted,%d, %d\n", frame_tx, slot_tx); mac->if_module->scheduled_response(&scheduled_response); } pthread_mutex_lock(&ul_config->mutex_ul_config); @@ -1524,7 +1556,9 @@ int nr_ue_pusch_scheduler(NR_UE_MAC_INST_t *mac, uint8_t tda_id){ int delta = 0; - NR_BWP_Uplink_t *ubwp = mac->ULbwp[0]; + NR_BWP_Id_t ul_bwp_id = mac->UL_BWP_Id; + NR_BWP_Uplink_t *ubwp = mac->ULbwp[ul_bwp_id-1]; + // Get the numerology to calculate the Tx frame and slot int mu = ubwp ? ubwp->bwp_Common->genericParameters.subcarrierSpacing : @@ -2251,26 +2285,27 @@ void nr_ue_pucch_scheduler(module_id_t module_idP, frame_t frameP, int slotP, in int O_CSI = 0; int N_UCI = 0; - PUCCH_sched_t *pucch = calloc(1,sizeof(*pucch)); - pucch->resource_indicator = -1; - pucch->initial_pucch_id = -1; + PUCCH_sched_t pucch = { + .resource_indicator = -1, + .initial_pucch_id = -1 + }; uint16_t rnti = mac->crnti; //FIXME not sure this is valid for all pucch instances // SR - if(trigger_periodic_scheduling_request(mac, pucch, frameP, slotP)) { + if (trigger_periodic_scheduling_request(mac, &pucch, frameP, slotP)) { O_SR = 1; /* sr_payload = 1 means that this is a positive SR, sr_payload = 0 means that it is a negative SR */ - pucch->sr_payload = nr_ue_get_SR(module_idP, + pucch.sr_payload = nr_ue_get_SR(module_idP, frameP, slotP); } // CSI if (mac->ra.ra_state == RA_SUCCEEDED || get_softmodem_params()->phy_test == 1) - O_CSI = nr_get_csi_measurements(mac, frameP, slotP, pucch); + O_CSI = nr_get_csi_measurements(mac, frameP, slotP, &pucch); // ACKNACK - O_ACK = get_downlink_ack(mac, frameP, slotP, pucch); + O_ACK = get_downlink_ack(mac, frameP, slotP, &pucch); NR_BWP_Id_t bwp_id = mac->UL_BWP_Id; NR_PUCCH_Config_t *pucch_Config = NULL; @@ -2300,37 +2335,41 @@ void nr_ue_pucch_scheduler(module_id_t module_idP, frame_t frameP, int slotP, in pucch_Config->format2 && (pucch_Config->format2->choice.setup->simultaneousHARQ_ACK_CSI == NULL)) { O_CSI = 0; - pucch->csi_part1_payload = 0; - pucch->csi_part2_payload = 0; + pucch.csi_part1_payload = 0; + pucch.csi_part2_payload = 0; } N_UCI = O_SR + O_ACK + O_CSI; + mac->nr_ue_emul_l1.num_srs = O_SR; + mac->nr_ue_emul_l1.num_harqs = O_ACK; + mac->nr_ue_emul_l1.num_csi_reports = O_CSI; // do no transmit pucch if only SR scheduled and it is negative - if ((O_ACK + O_CSI) == 0 && pucch->sr_payload == 0) + if ((O_ACK + O_CSI) == 0 && pucch.sr_payload == 0) return; if (N_UCI > 0) { LOG_D(NR_MAC,"%d.%d configure pucch, O_SR %d, O_ACK %d, O_CSI %d\n",frameP,slotP,O_SR,O_ACK,O_CSI); - pucch->resource_set_id = find_pucch_resource_set(mac, O_ACK + O_CSI); - select_pucch_resource(mac, pucch); + pucch.resource_set_id = find_pucch_resource_set(mac, O_ACK + O_CSI); + select_pucch_resource(mac, &pucch); fapi_nr_ul_config_request_t *ul_config = get_ul_config_request(mac, slotP); pthread_mutex_lock(&ul_config->mutex_ul_config); AssertFatal(ul_config->number_pdusnumber_pdus %d out of bounds\n",ul_config->number_pdus); fapi_nr_ul_config_pucch_pdu *pucch_pdu = &ul_config->ul_config_list[ul_config->number_pdus].pucch_config_pdu; fill_ul_config(ul_config, frameP, slotP, FAPI_NR_UL_CONFIG_TYPE_PUCCH); + mac->nr_ue_emul_l1.active_uci_sfn_slot = NFAPI_SFNSLOT2HEX(frameP, slotP); pthread_mutex_unlock(&ul_config->mutex_ul_config); nr_ue_configure_pucch(mac, slotP, rnti, - pucch, + &pucch, pucch_pdu, O_SR, O_ACK, O_CSI); - LOG_D(NR_MAC,"Configuring pucch, is_common = %d\n",pucch->is_common); + LOG_D(NR_MAC, "Configuring pucch, is_common = %d\n", pucch.is_common); nr_scheduled_response_t scheduled_response; - fill_scheduled_response(&scheduled_response, NULL, ul_config, NULL, module_idP, 0 /*TBR fix*/, frameP, slotP, thread_id); + fill_scheduled_response(&scheduled_response, NULL, ul_config, NULL, module_idP, 0 /*TBR fix*/, frameP, slotP, thread_id, NULL); if(mac->if_module != NULL && mac->if_module->scheduled_response != NULL) mac->if_module->scheduled_response(&scheduled_response); } @@ -2357,9 +2396,17 @@ void nr_schedule_csi_for_im(NR_UE_MAC_INST_t *mac, int frame, int slot) { NR_CSI_IM_Resource_t *imcsi; int period, offset; NR_BWP_Id_t dl_bwp_id = mac->DL_BWP_Id; - int mu = mac->DLbwp[dl_bwp_id-1] ? - mac->DLbwp[dl_bwp_id-1]->bwp_Common->genericParameters.subcarrierSpacing : - mac->scc_SIB->downlinkConfigCommon.initialDownlinkBWP.genericParameters.subcarrierSpacing; + + NR_BWP_t *genericParameters = NULL; + if(dl_bwp_id > 0 && mac->DLbwp[dl_bwp_id-1]) { + genericParameters = &mac->DLbwp[dl_bwp_id-1]->bwp_Common->genericParameters; + } else { + genericParameters = &mac->scc_SIB->downlinkConfigCommon.initialDownlinkBWP.genericParameters; + } + + int mu = genericParameters->subcarrierSpacing; + uint16_t bwp_size = NRRIV2BW(genericParameters->locationAndBandwidth, MAX_BWP_SIZE); + uint16_t bwp_start = NRRIV2PRBOFFSET(genericParameters->locationAndBandwidth, MAX_BWP_SIZE); for (int id = 0; id < csi_measconfig->csi_IM_ResourceToAddModList->list.count; id++){ imcsi = csi_measconfig->csi_IM_ResourceToAddModList->list.array[id]; @@ -2367,11 +2414,8 @@ void nr_schedule_csi_for_im(NR_UE_MAC_INST_t *mac, int frame, int slot) { if((frame*nr_slots_per_frame[mu]+slot-offset)%period != 0) continue; fapi_nr_dl_config_csiim_pdu_rel15_t *csiim_config_pdu = &dl_config->dl_config_list[dl_config->number_pdus].csiim_config_pdu.csiim_config_rel15; - const NR_BWP_Downlink_t *dlbwp = mac->DLbwp[dl_bwp_id-1]; - const int locationAndBandwidth = dlbwp != NULL ? dlbwp->bwp_Common->genericParameters.locationAndBandwidth: - mac->scc_SIB->downlinkConfigCommon.initialDownlinkBWP.genericParameters.locationAndBandwidth; - csiim_config_pdu->bwp_size = NRRIV2BW(locationAndBandwidth, MAX_BWP_SIZE); - csiim_config_pdu->bwp_start = NRRIV2PRBOFFSET(locationAndBandwidth, MAX_BWP_SIZE); + csiim_config_pdu->bwp_size = bwp_size; + csiim_config_pdu->bwp_start = bwp_start; csiim_config_pdu->subcarrier_spacing = mu; csiim_config_pdu->start_rb = imcsi->freqBand->startingRB; csiim_config_pdu->nr_of_rbs = imcsi->freqBand->nrofRBs; @@ -2393,7 +2437,7 @@ void nr_schedule_csi_for_im(NR_UE_MAC_INST_t *mac, int frame, int slot) { AssertFatal(1==0, "Invalid CSI-IM pattern\n"); } dl_config->dl_config_list[dl_config->number_pdus].pdu_type = FAPI_NR_DL_CONFIG_TYPE_CSI_IM; - dl_config->number_pdus = dl_config->number_pdus + 1; + dl_config->number_pdus += 1; } } @@ -2417,9 +2461,17 @@ void nr_schedule_csirs_reception(NR_UE_MAC_INST_t *mac, int frame, int slot) { NR_NZP_CSI_RS_Resource_t *nzpcsi; int period, offset; NR_BWP_Id_t dl_bwp_id = mac->DL_BWP_Id; - int mu = mac->DLbwp[dl_bwp_id-1] ? - mac->DLbwp[dl_bwp_id-1]->bwp_Common->genericParameters.subcarrierSpacing : - mac->scc_SIB->downlinkConfigCommon.initialDownlinkBWP.genericParameters.subcarrierSpacing; + + NR_BWP_t *genericParameters = NULL; + if(dl_bwp_id > 0 && mac->DLbwp[dl_bwp_id-1]) { + genericParameters = &mac->DLbwp[dl_bwp_id-1]->bwp_Common->genericParameters; + } else { + genericParameters = &mac->scc_SIB->downlinkConfigCommon.initialDownlinkBWP.genericParameters; + } + + int mu = genericParameters->subcarrierSpacing; + uint16_t bwp_size = NRRIV2BW(genericParameters->locationAndBandwidth, MAX_BWP_SIZE); + uint16_t bwp_start = NRRIV2PRBOFFSET(genericParameters->locationAndBandwidth, MAX_BWP_SIZE); for (int id = 0; id < csi_measconfig->nzp_CSI_RS_ResourceToAddModList->list.count; id++){ nzpcsi = csi_measconfig->nzp_CSI_RS_ResourceToAddModList->list.array[id]; @@ -2428,17 +2480,23 @@ void nr_schedule_csirs_reception(NR_UE_MAC_INST_t *mac, int frame, int slot) { continue; LOG_D(MAC,"Scheduling reception of CSI-RS in frame %d slot %d\n",frame,slot); fapi_nr_dl_config_csirs_pdu_rel15_t *csirs_config_pdu = &dl_config->dl_config_list[dl_config->number_pdus].csirs_config_pdu.csirs_config_rel15; - NR_CSI_RS_ResourceMapping_t resourceMapping = nzpcsi->resourceMapping; - - const NR_BWP_Downlink_t *dlbwp = mac->DLbwp[dl_bwp_id-1]; - const int locationAndBandwidth = dlbwp != NULL ? dlbwp->bwp_Common->genericParameters.locationAndBandwidth: - mac->scc_SIB->downlinkConfigCommon.initialDownlinkBWP.genericParameters.locationAndBandwidth; - csirs_config_pdu->bwp_size = NRRIV2BW(locationAndBandwidth, MAX_BWP_SIZE); - csirs_config_pdu->bwp_start = NRRIV2PRBOFFSET(locationAndBandwidth, MAX_BWP_SIZE); csirs_config_pdu->subcarrier_spacing = mu; - csirs_config_pdu->start_rb = resourceMapping.freqBand.startingRB; - csirs_config_pdu->nr_of_rbs = resourceMapping.freqBand.nrofRBs; + csirs_config_pdu->cyclic_prefix = genericParameters->cyclicPrefix ? *genericParameters->cyclicPrefix : 0; + + // According to last paragraph of TS 38.214 5.2.2.3.1 + if (resourceMapping.freqBand.startingRB < bwp_start) { + csirs_config_pdu->start_rb = bwp_start; + } else { + csirs_config_pdu->start_rb = resourceMapping.freqBand.startingRB; + } + if (resourceMapping.freqBand.nrofRBs > (bwp_start + bwp_size - csirs_config_pdu->start_rb)) { + csirs_config_pdu->nr_of_rbs = bwp_start + bwp_size - csirs_config_pdu->start_rb; + } else { + csirs_config_pdu->nr_of_rbs = resourceMapping.freqBand.nrofRBs; + } + AssertFatal(csirs_config_pdu->nr_of_rbs >= 24, "CSI-RS has %d RBs, but the minimum is 24\n", csirs_config_pdu->nr_of_rbs); + csirs_config_pdu->csi_type = 1; // NZP-CSI-RS csirs_config_pdu->symb_l0 = resourceMapping.firstOFDMSymbolInTimeDomain; if (resourceMapping.firstOFDMSymbolInTimeDomain2) @@ -2449,6 +2507,11 @@ void nr_schedule_csirs_reception(NR_UE_MAC_INST_t *mac, int frame, int slot) { && (resourceMapping.density.choice.dot5 == NR_CSI_RS_ResourceMapping__density__dot5_evenPRBs)) csirs_config_pdu->freq_density--; csirs_config_pdu->scramb_id = nzpcsi->scramblingID; + csirs_config_pdu->power_control_offset = nzpcsi->powerControlOffset + 8; + if (nzpcsi->powerControlOffsetSS) + csirs_config_pdu->power_control_offset_ss = *nzpcsi->powerControlOffsetSS; + else + csirs_config_pdu->power_control_offset_ss = 1; // 0 dB switch(resourceMapping.frequencyDomainAllocation.present){ case NR_CSI_RS_ResourceMapping__frequencyDomainAllocation_PR_row1: csirs_config_pdu->row = 1; @@ -2529,7 +2592,7 @@ void nr_schedule_csirs_reception(NR_UE_MAC_INST_t *mac, int frame, int slot) { AssertFatal(1==0,"Invalid freqency domain allocation in CSI-RS resource\n"); } dl_config->dl_config_list[dl_config->number_pdus].pdu_type = FAPI_NR_DL_CONFIG_TYPE_CSI_RS; - dl_config->number_pdus = dl_config->number_pdus + 1; + dl_config->number_pdus += 1; } } @@ -2677,7 +2740,7 @@ void nr_ue_prach_scheduler(module_id_t module_idP, frame_t frameP, sub_frame_t s } } // if format1 - fill_scheduled_response(&scheduled_response, NULL, ul_config, NULL, module_idP, 0 /*TBR fix*/, frameP, slotP, thread_id); + fill_scheduled_response(&scheduled_response, NULL, ul_config, NULL, module_idP, 0 /*TBR fix*/, frameP, slotP, thread_id, NULL); if(mac->if_module != NULL && mac->if_module->scheduled_response != NULL) mac->if_module->scheduled_response(&scheduled_response); } // is_nr_prach_slot @@ -2692,7 +2755,8 @@ void nr_ue_sib1_scheduler(module_id_t module_idP, uint8_t ssb_subcarrier_offset, uint32_t ssb_index, uint16_t ssb_start_subcarrier, - frequency_range_t frequency_range) { + frequency_range_t frequency_range, + void *phy_data) { NR_UE_MAC_INST_t *mac = get_mac_inst(module_idP); nr_scheduled_response_t scheduled_response; @@ -2725,7 +2789,7 @@ void nr_ue_sib1_scheduler(module_id_t module_idP, rel15->num_dci_options = 1; rel15->dci_format_options[0] = NR_DL_DCI_FORMAT_1_0; config_dci_pdu(mac, rel15, dl_config, NR_RNTI_SI, -1); - fill_dci_search_candidates(mac->search_space_zero, rel15); + fill_dci_search_candidates(mac->search_space_zero, rel15, -1, -1); if(mac->type0_PDCCH_CSS_config.type0_pdcch_ss_mux_pattern == 1){ // same frame as ssb @@ -2740,7 +2804,7 @@ void nr_ue_sib1_scheduler(module_id_t module_idP, slot_s = mac->type0_PDCCH_CSS_config.n_c; } LOG_D(MAC,"Calling fill_scheduled_response, type0_pdcch, num_pdus %d\n",dl_config->number_pdus); - fill_scheduled_response(&scheduled_response, dl_config, NULL, NULL, module_idP, cc_id, frame_s, slot_s, 0); // TODO fix thread_id, for now assumed 0 + fill_scheduled_response(&scheduled_response, dl_config, NULL, NULL, module_idP, cc_id, frame_s, slot_s, 0, phy_data); // TODO fix thread_id, for now assumed 0 if (dl_config->number_pdus) { if(mac->if_module != NULL && mac->if_module->scheduled_response != NULL) @@ -3118,8 +3182,7 @@ uint8_t nr_ue_get_sdu(module_id_t module_idP, header->R = 0; header->F = 1; header->LCID = lcid; - header->L1 = ((unsigned short) sdu_length >> 8) & 0x7f; - header->L2 = (unsigned short) sdu_length & 0xff; + header->L = htons(sdu_length); #ifdef ENABLE_MAC_PAYLOAD_DEBUG LOG_I(NR_MAC, "In %s: dumping MAC sub-header with length %d: \n", __FUNCTION__, sh_size); diff --git a/openair2/LAYER2/NR_MAC_gNB/config.c b/openair2/LAYER2/NR_MAC_gNB/config.c index 7833b41f0b..f775938868 100644 --- a/openair2/LAYER2/NR_MAC_gNB/config.c +++ b/openair2/LAYER2/NR_MAC_gNB/config.c @@ -58,19 +58,42 @@ void process_rlcBearerConfig(struct NR_CellGroupConfig__rlc_BearerToAddModList * struct NR_CellGroupConfig__rlc_BearerToReleaseList *rlc_bearer2release_list, NR_UE_sched_ctrl_t *sched_ctrl) { - - if (rlc_bearer2add_list) - // keep lcids - for (int i=0;ilist.count;i++) { - sched_ctrl->lcid_mask |= (1<list.array[i]->logicalChannelIdentity); - LOG_I(NR_MAC,"Adding LCID %d (%s %d)\n", - (int)rlc_bearer2add_list->list.array[i]->logicalChannelIdentity, - rlc_bearer2add_list->list.array[i]->logicalChannelIdentity<4 ? "SRB" : "DRB", - (int)rlc_bearer2add_list->list.array[i]->logicalChannelIdentity); + if (rlc_bearer2release_list) { + for (int i = 0; i < rlc_bearer2release_list->list.count; i++) { + for (int idx = 0; idx < sched_ctrl->dl_lc_num; idx++) { + if (sched_ctrl->dl_lc_ids[idx] == *rlc_bearer2release_list->list.array[i]) { + const int remaining_lcs = sched_ctrl->dl_lc_num - idx - 1; + memmove(&sched_ctrl->dl_lc_ids[idx], &sched_ctrl->dl_lc_ids[idx + 1], sizeof(sched_ctrl->dl_lc_ids[idx]) * remaining_lcs); + sched_ctrl->dl_lc_num--; + break; + } + } } - if (rlc_bearer2release_list) - for (int i=0;ilist.count;i++) - sched_ctrl->lcid_mask |= (1<<*rlc_bearer2release_list->list.array[i]); + } + + if (rlc_bearer2add_list) { + // keep lcids + for (int i = 0; i < rlc_bearer2add_list->list.count; i++) { + const int lcid = rlc_bearer2add_list->list.array[i]->logicalChannelIdentity; + bool found = false; + for (int idx = 0; idx < sched_ctrl->dl_lc_num; idx++) { + if (sched_ctrl->dl_lc_ids[idx] == lcid) { + found = true; + break; + } + } + + if (!found) { + sched_ctrl->dl_lc_num++; + sched_ctrl->dl_lc_ids[sched_ctrl->dl_lc_num - 1] = lcid; + LOG_D(NR_MAC, "Adding LCID %d (%s %d)\n", lcid, lcid < 4 ? "SRB" : "DRB", lcid); + } + } + } + + LOG_D(NR_MAC, "In %s: total num of active bearers %d) \n", + __FUNCTION__, + sched_ctrl->dl_lc_num); } @@ -141,7 +164,6 @@ void config_common(int Mod_idP, int ssb_SubcarrierOffset, int pdsch_AntennaPorts nfapi_nr_config_request_scf_t *cfg = &RC.nrmac[Mod_idP]->config[0]; RC.nrmac[Mod_idP]->common_channels[0].ServingCellConfigCommon = scc; - int i; // Carrier configuration @@ -158,7 +180,7 @@ void config_common(int Mod_idP, int ssb_SubcarrierOffset, int pdsch_AntennaPorts cfg->carrier_config.dl_frequency.tl.tag = NFAPI_NR_CONFIG_DL_FREQUENCY_TAG; cfg->num_tlv++; - for (i=0; i<5; i++) { + for (int i=0; i<5; i++) { if (i==scc->downlinkConfigCommon->frequencyInfoDL->scs_SpecificCarrierList.list.array[0]->subcarrierSpacing) { cfg->carrier_config.dl_grid_size[i].value = scc->downlinkConfigCommon->frequencyInfoDL->scs_SpecificCarrierList.list.array[0]->carrierBandwidth; cfg->carrier_config.dl_k0[i].value = scc->downlinkConfigCommon->frequencyInfoDL->scs_SpecificCarrierList.list.array[0]->offsetToCarrier; @@ -192,7 +214,7 @@ void config_common(int Mod_idP, int ssb_SubcarrierOffset, int pdsch_AntennaPorts cfg->carrier_config.uplink_frequency.tl.tag = NFAPI_NR_CONFIG_UPLINK_FREQUENCY_TAG; cfg->num_tlv++; - for (i=0; i<5; i++) { + for (int i=0; i<5; i++) { if (i==scc->uplinkConfigCommon->frequencyInfoUL->scs_SpecificCarrierList.list.array[0]->subcarrierSpacing) { cfg->carrier_config.ul_grid_size[i].value = scc->uplinkConfigCommon->frequencyInfoUL->scs_SpecificCarrierList.list.array[0]->carrierBandwidth; cfg->carrier_config.ul_k0[i].value = scc->uplinkConfigCommon->frequencyInfoUL->scs_SpecificCarrierList.list.array[0]->offsetToCarrier; @@ -210,7 +232,7 @@ void config_common(int Mod_idP, int ssb_SubcarrierOffset, int pdsch_AntennaPorts uint32_t band = *scc->downlinkConfigCommon->frequencyInfoDL->frequencyBandList.list.array[0]; frequency_range_t frequency_range = band<100?FR1:FR2; - lte_frame_type_t frame_type = get_frame_type(*scc->downlinkConfigCommon->frequencyInfoDL->frequencyBandList.list.array[0], *scc->ssbSubcarrierSpacing); + frame_type_t frame_type = get_frame_type(*scc->downlinkConfigCommon->frequencyInfoDL->frequencyBandList.list.array[0], *scc->ssbSubcarrierSpacing); RC.nrmac[Mod_idP]->common_channels[0].frame_type = frame_type; // Cell configuration @@ -283,7 +305,7 @@ void config_common(int Mod_idP, int ssb_SubcarrierOffset, int pdsch_AntennaPorts cfg->num_tlv++; cfg->prach_config.num_prach_fd_occasions_list = (nfapi_nr_num_prach_fd_occasions_t *) malloc(cfg->prach_config.num_prach_fd_occasions.value*sizeof(nfapi_nr_num_prach_fd_occasions_t)); - for (i=0; iprach_config.num_prach_fd_occasions.value; i++) { + for (int i=0; iprach_config.num_prach_fd_occasions.value; i++) { // cfg->prach_config.num_prach_fd_occasions_list[i].num_prach_fd_occasions = i; if (cfg->prach_config.prach_sequence_length.value) cfg->prach_config.num_prach_fd_occasions_list[i].prach_root_sequence_index.value = scc->uplinkConfigCommon->initialUplinkBWP->rach_ConfigCommon->choice.setup->prach_RootSequenceIndex.choice.l139; @@ -321,22 +343,24 @@ void config_common(int Mod_idP, int ssb_SubcarrierOffset, int pdsch_AntennaPorts uint32_t absolute_diff = (*scc->downlinkConfigCommon->frequencyInfoDL->absoluteFrequencySSB - scc->downlinkConfigCommon->frequencyInfoDL->absoluteFrequencyPointA); uint16_t sco = absolute_diff%(12*scs_scaling); // values of subcarrier offset larger than the limit only indicates CORESET for Type0-PDCCH CSS set is not present - uint8_t ssb_SubcarrierOffset_limit = 0; + int ssb_SubcarrierOffset_limit = 0; + int offset_scaling = 0; //15kHz if(frequency_range == FR1) { ssb_SubcarrierOffset_limit = 24; - } else { + if (ssb_SubcarrierOffsetssb_config.scs_common.value; + } else ssb_SubcarrierOffset_limit = 12; - } if (ssb_SubcarrierOffsetssb_table.ssb_offset_point_a.value = absolute_diff/(12*scs_scaling) - 10; //absoluteFrequencySSB is the central frequency of SSB which is made by 20RBs in total cfg->ssb_table.ssb_offset_point_a.tl.tag = NFAPI_NR_CONFIG_SSB_OFFSET_POINT_A_TAG; cfg->num_tlv++; cfg->ssb_table.ssb_period.value = *scc->ssb_periodicityServingCell; cfg->ssb_table.ssb_period.tl.tag = NFAPI_NR_CONFIG_SSB_PERIOD_TAG; cfg->num_tlv++; - cfg->ssb_table.ssb_subcarrier_offset.value = ssb_SubcarrierOffset; + cfg->ssb_table.ssb_subcarrier_offset.value = ssb_SubcarrierOffset<ssb_table.ssb_subcarrier_offset.tl.tag = NFAPI_NR_CONFIG_SSB_SUBCARRIER_OFFSET_TAG; cfg->num_tlv++; @@ -352,7 +376,7 @@ void config_common(int Mod_idP, int ssb_SubcarrierOffset, int pdsch_AntennaPorts case 3 : cfg->ssb_table.ssb_mask_list[0].ssb_mask.value = 0; cfg->ssb_table.ssb_mask_list[1].ssb_mask.value = 0; - for (i=0; i<4; i++) { + for (int i=0; i<4; i++) { cfg->ssb_table.ssb_mask_list[0].ssb_mask.value += (scc->ssb_PositionsInBurst->choice.longBitmap.buf[3-i]<ssb_table.ssb_mask_list[1].ssb_mask.value += (scc->ssb_PositionsInBurst->choice.longBitmap.buf[7-i]<carrier_config.num_rx_ant.value = pusch_AntennaPorts; AssertFatal(pusch_AntennaPorts > 0 && pusch_AntennaPorts < 13, "pusch_AntennaPorts in 1...12\n"); cfg->carrier_config.num_rx_ant.tl.tag = NFAPI_NR_CONFIG_NUM_RX_ANT_TAG; - LOG_I(NR_MAC,"Set TX/RX antenna number to %d (num ssb %d: %x,%x)\n",cfg->carrier_config.num_tx_ant.value,num_ssb,cfg->ssb_table.ssb_mask_list[0].ssb_mask.value,cfg->ssb_table.ssb_mask_list[1].ssb_mask.value); + LOG_I(NR_MAC,"Set RX antenna number to %d, Set TX antenna number to %d (num ssb %d: %x,%x)\n", + cfg->carrier_config.num_tx_ant.value,cfg->carrier_config.num_rx_ant.value,num_ssb,cfg->ssb_table.ssb_mask_list[0].ssb_mask.value,cfg->ssb_table.ssb_mask_list[1].ssb_mask.value); AssertFatal(cfg->carrier_config.num_tx_ant.value > 0,"carrier_config.num_tx_ant.value %d !\n",cfg->carrier_config.num_tx_ant.value ); cfg->num_tlv++; cfg->num_tlv++; @@ -425,18 +450,38 @@ void config_common(int Mod_idP, int ssb_SubcarrierOffset, int pdsch_AntennaPorts } +int nr_mac_enable_ue_rrc_processing_timer(module_id_t Mod_idP, rnti_t rnti, NR_SubcarrierSpacing_t subcarrierSpacing, uint32_t rrc_reconfiguration_delay) { + + if (rrc_reconfiguration_delay == 0) { + return -1; + } + + NR_UE_info_t *UE_info = find_nr_UE(&RC.nrmac[Mod_idP]->UE_info,rnti); + if (!UE_info) { + LOG_W(NR_MAC, "Could not find UE for RNTI 0x%04x\n", rnti); + return -1; + } + NR_UE_sched_ctrl_t *sched_ctrl = &UE_info->UE_sched_ctrl; + const uint16_t sf_ahead = 6/(0x01<0); + const uint16_t sl_ahead = sf_ahead * (0x01<rrc_processing_timer = (rrc_reconfiguration_delay<rnti, rrc_reconfiguration_delay); + + return 0; +} int rrc_mac_config_req_gNB(module_id_t Mod_idP, int ssb_SubcarrierOffset, - int pdsch_AntennaPorts, + rrc_pdsch_AntennaPorts_t pdsch_AntennaPorts, int pusch_AntennaPorts, int sib1_tda, int minRXTXTIMEpdsch, NR_ServingCellConfigCommon_t *scc, NR_BCCH_BCH_Message_t *mib, - int add_ue, + NR_BCCH_DL_SCH_Message_t *sib1, + int add_ue, uint32_t rnti, - NR_CellGroupConfig_t *CellGroup) { + NR_CellGroupConfig_t *CellGroup) { if (scc != NULL ) { AssertFatal((scc->ssb_PositionsInBurst->present > 0) && (scc->ssb_PositionsInBurst->present < 4), "SSB Bitmap type %d is not valid\n",scc->ssb_PositionsInBurst->present); @@ -447,14 +492,11 @@ int rrc_mac_config_req_gNB(module_id_t Mod_idP, AssertFatal(RC.nrmac[Mod_idP]->UL_tti_req_ahead[0], "could not allocate memory for RC.nrmac[]->UL_tti_req_ahead[]\n"); /* fill in slot/frame numbers: slot is fixed, frame will be updated by scheduler - extern sf_ahead is initialized in ru_thread but that function is not executed yet here*/ - const uint16_t sf_ahead = (uint16_t) ceil((float)6/(0x01<<(*scc->ssbSubcarrierSpacing))); - const uint16_t sl_ahead = sf_ahead * (0x01<<(*scc->ssbSubcarrierSpacing)); - /* consider that scheduler runs sl_ahead: the first sl_ahead slots are - * already "in the past" and thus we put frame 1 instead of 0!*/ + * consider that scheduler runs sl_ahead: the first sl_ahead slots are + * already "in the past" and thus we put frame 1 instead of 0! */ for (int i = 0; i < n; ++i) { nfapi_nr_ul_tti_request_t *req = &RC.nrmac[Mod_idP]->UL_tti_req_ahead[0][i]; - req->SFN = i < (sl_ahead-1); + req->SFN = i < (RC.nrmac[Mod_idP]->if_inst->sl_ahead-1); req->Slot = i; } RC.nrmac[Mod_idP]->common_channels[0].vrb_map_UL = @@ -464,9 +506,11 @@ int rrc_mac_config_req_gNB(module_id_t Mod_idP, LOG_I(NR_MAC,"Configuring common parameters from NR ServingCellConfig\n"); + int num_pdsch_antenna_ports = pdsch_AntennaPorts.N1 * pdsch_AntennaPorts.N2 * pdsch_AntennaPorts.XP; + RC.nrmac[Mod_idP]->xp_pdsch_antenna_ports = pdsch_AntennaPorts.XP; config_common(Mod_idP, ssb_SubcarrierOffset, - pdsch_AntennaPorts, + num_pdsch_antenna_ports, pusch_AntennaPorts, scc); LOG_D(NR_MAC, "%s() %s:%d RC.nrmac[Mod_idP]->if_inst->NR_PHY_config_req:%p\n", __FUNCTION__, __FILE__, __LINE__, RC.nrmac[Mod_idP]->if_inst->NR_PHY_config_req); @@ -506,12 +550,7 @@ int rrc_mac_config_req_gNB(module_id_t Mod_idP, AssertFatal(RC.nrmac[Mod_idP]->common_channels[0].frame_type == FDD,"Dynamic TDD not handled yet\n"); for (int slot = 0; slot < n; ++slot) { - /* FIXME: it seems there is a problem with slot 0/10/slots right after UL: - * we just get retransmissions. Thus, do not schedule such slots in DL in TDD */ - if (RC.nrmac[Mod_idP]->common_channels[0].frame_type == FDD || - (slot % nr_slots_period != 0)){ - RC.nrmac[Mod_idP]->dlsch_slot_bitmap[slot / 64] |= (uint64_t)((slot % nr_slots_period) < nr_dl_slots) << (slot % 64); - } + RC.nrmac[Mod_idP]->dlsch_slot_bitmap[slot / 64] |= (uint64_t)((slot % nr_slots_period) < nr_dl_slots) << (slot % 64); RC.nrmac[Mod_idP]->ulsch_slot_bitmap[slot / 64] |= (uint64_t)((slot % nr_slots_period) >= nr_ulstart_slot) << (slot % 64); LOG_I(NR_MAC, "In %s: slot %d DL %d UL %d\n", @@ -544,36 +583,24 @@ int rrc_mac_config_req_gNB(module_id_t Mod_idP, } } - if (mib) RC.nrmac[Mod_idP]->common_channels[0].mib = mib; - + if (mib) RC.nrmac[Mod_idP]->common_channels[0].mib = mib; + if (sib1) RC.nrmac[Mod_idP]->common_channels[0].sib1 = sib1; + if (CellGroup) { - const NR_ServingCellConfig_t *servingCellConfig = CellGroup->spCellConfig->spCellConfigDedicated; - const struct NR_ServingCellConfig__downlinkBWP_ToAddModList *bwpList = servingCellConfig->downlinkBWP_ToAddModList; - if(bwpList) { - AssertFatal(bwpList->list.count > 0, "downlinkBWP_ToAddModList has no BWPs!\n"); - for (int i = 0; i < bwpList->list.count; ++i) { - const NR_BWP_Downlink_t *bwp = bwpList->list.array[i]; - calculate_preferred_dl_tda(Mod_idP, bwp); - } - } else { - calculate_preferred_dl_tda(Mod_idP, NULL); - } + const NR_ServingCellConfig_t *servingCellConfig = NULL; + if(CellGroup->spCellConfig && CellGroup->spCellConfig->spCellConfigDedicated) + servingCellConfig = CellGroup->spCellConfig->spCellConfigDedicated; - const struct NR_UplinkConfig__uplinkBWP_ToAddModList *ubwpList = servingCellConfig->uplinkConfig->uplinkBWP_ToAddModList; - if(ubwpList) { - AssertFatal(ubwpList->list.count > 0, "uplinkBWP_ToAddModList no BWPs!\n"); - for (int i = 0; i < ubwpList->list.count; ++i) { - const NR_BWP_Uplink_t *ubwp = ubwpList->list.array[i]; - calculate_preferred_ul_tda(Mod_idP, ubwp); - } - } - - NR_UE_info_t *UE_info = &RC.nrmac[Mod_idP]->UE_info; if (add_ue == 1 && get_softmodem_params()->phy_test) { - const int UE_id = add_new_nr_ue(Mod_idP, rnti, CellGroup); - LOG_I(NR_MAC,"Added new UE_id %d/%x with initial CellGroup\n",UE_id,rnti); - process_CellGroup(CellGroup,&UE_info->UE_sched_ctrl[UE_id]); + NR_UE_info_t* UE = add_new_nr_ue(RC.nrmac[Mod_idP], rnti, CellGroup); + if (UE) { + LOG_I(NR_MAC,"Added new UE %x with initial CellGroup\n", rnti); + } else { + LOG_E(NR_MAC,"Error adding UE %04x\n", rnti); + return -1; + } + process_CellGroup(CellGroup,&UE->UE_sched_ctrl); } else if (add_ue == 1 && !get_softmodem_params()->phy_test) { const int CC_id = 0; NR_COMMON_channels_t *cc = &RC.nrmac[Mod_idP]->common_channels[CC_id]; @@ -619,53 +646,34 @@ int rrc_mac_config_req_gNB(module_id_t Mod_idP, ra->msg3_dcch_dtch = false; LOG_I(NR_MAC,"Added new RA process for UE RNTI %04x with initial CellGroup\n", rnti); } else { // CellGroup has been updated - NR_ServingCellConfigCommon_t *scc = RC.nrmac[Mod_idP]->common_channels[0].ServingCellConfigCommon; - const int UE_id = find_nr_UE_id(Mod_idP,rnti); - int target_ss; - UE_info->CellGroup[UE_id] = CellGroup; - LOG_I(NR_MAC,"Modified UE_id %d/%x with CellGroup\n",UE_id,rnti); - process_CellGroup(CellGroup,&UE_info->UE_sched_ctrl[UE_id]); - const NR_ServingCellConfig_t *servingCellConfig = CellGroup ? CellGroup->spCellConfig->spCellConfigDedicated : NULL; - NR_UE_sched_ctrl_t *sched_ctrl = &UE_info->UE_sched_ctrl[UE_id]; - sched_ctrl->update_pdsch_ps = true; - sched_ctrl->update_pusch_ps = true; + NR_UE_info_t * UE = find_nr_UE(&RC.nrmac[Mod_idP]->UE_info,rnti); + if (!UE) { + LOG_E(NR_MAC, "Can't find UE %04x\n", rnti); + return -1; + } + + UE->CellGroup = CellGroup; + LOG_I(NR_MAC,"Modified rnti %04x with CellGroup\n",rnti); + process_CellGroup(CellGroup,&UE->UE_sched_ctrl); + NR_UE_sched_ctrl_t *sched_ctrl = &UE->UE_sched_ctrl; + const NR_PDSCH_ServingCellConfig_t *pdsch = servingCellConfig ? servingCellConfig->pdsch_ServingCellConfig->choice.setup : NULL; if (get_softmodem_params()->sa) { // add all available DL HARQ processes for this UE in SA create_dl_harq_list(sched_ctrl, pdsch); } - // update coreset/searchspace - void *bwpd = NULL; - NR_BWP_t *genericParameters = NULL; - target_ss = NR_SearchSpace__searchSpaceType_PR_common; - if ((sched_ctrl->active_bwp)) { - target_ss = NR_SearchSpace__searchSpaceType_PR_ue_Specific; - bwpd = (void*)sched_ctrl->active_bwp->bwp_Dedicated; - genericParameters = &sched_ctrl->active_bwp->bwp_Common->genericParameters; - } - else if (CellGroup->spCellConfig && - CellGroup->spCellConfig->spCellConfigDedicated && - (CellGroup->spCellConfig->spCellConfigDedicated->initialDownlinkBWP)) { - target_ss = NR_SearchSpace__searchSpaceType_PR_ue_Specific; - bwpd = (void*)CellGroup->spCellConfig->spCellConfigDedicated->initialDownlinkBWP; - genericParameters = &scc->downlinkConfigCommon->initialDownlinkBWP->genericParameters; - } - else - AssertFatal(1==0,"Either initial BWP or active BWP should always be present\n"); - sched_ctrl->search_space = get_searchspace(scc, bwpd, target_ss); - sched_ctrl->coreset = get_coreset(Mod_idP, scc, bwpd, sched_ctrl->search_space, target_ss); - sched_ctrl->sched_pdcch = set_pdcch_structure(RC.nrmac[Mod_idP], - sched_ctrl->search_space, - sched_ctrl->coreset, - scc, - genericParameters, - NULL); + sched_ctrl->maxL = 2; + + if (CellGroup->spCellConfig && + CellGroup->spCellConfig->spCellConfigDedicated && + CellGroup->spCellConfig->spCellConfigDedicated->csi_MeasConfig && + CellGroup->spCellConfig->spCellConfigDedicated->csi_MeasConfig->choice.setup) { + compute_csi_bitlen(CellGroup->spCellConfig->spCellConfigDedicated->csi_MeasConfig->choice.setup, UE); + } } } VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_RRC_MAC_CONFIG, VCD_FUNCTION_OUT); - - - return(0); + return 0; }// END rrc_mac_config_req_gNB diff --git a/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler.c b/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler.c index 51541353f4..385cf5af16 100644 --- a/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler.c +++ b/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler.c @@ -104,167 +104,6 @@ void clear_nr_nfapi_information(gNB_MAC_INST * gNB, TX_req[CC_idP].Number_of_PDUs = 0; } -/* -void check_nr_ul_failure(module_id_t module_idP, - int CC_id, - int UE_id, - frame_t frameP, - sub_frame_t slotP) { - - NR_UE_info_t *UE_info = &RC.nrmac[module_idP]->UE_info; - nfapi_nr_dl_dci_request_t *DL_req = &RC.nrmac[module_idP]->DL_req[0]; - uint16_t rnti = UE_RNTI(module_idP, UE_id); - NR_COMMON_channels_t *cc = RC.nrmac[module_idP]->common_channels; - - // check uplink failure - if ((UE_info->UE_sched_ctrl[UE_id].ul_failure_timer > 0) && - (UE_info->UE_sched_ctrl[UE_id].ul_out_of_sync == 0)) { - LOG_I(MAC, "UE %d rnti %x: UL Failure timer %d \n", UE_id, rnti, - UE_info->UE_sched_ctrl[UE_id].ul_failure_timer); - if (UE_info->UE_sched_ctrl[UE_id].ra_pdcch_order_sent == 0) { - UE_info->UE_sched_ctrl[UE_id].ra_pdcch_order_sent = 1; - - // add a format 1A dci for this UE to request an RA procedure (only one UE per subframe) - nfapi_nr_dl_dci_request_pdu_t *dl_config_pdu = &DL_req[CC_id].dl_tti_request_body.dl_config_pdu_list[DL_req[CC_id].dl_tti_request_body.number_pdu]; - memset((void *) dl_config_pdu, 0,sizeof(nfapi_dl_dci_request_pdu_t)); - dl_config_pdu->pdu_type = NFAPI_DL_CONFIG_DCI_DL_PDU_TYPE; - dl_config_pdu->pdu_size = (uint8_t) (2 + sizeof(nfapi_dl_config_dci_dl_pdu)); - dl_config_pdu->dci_dl_pdu.dci_dl_pdu_rel8.tl.tag = NFAPI_DL_DCI_REQUEST_DCI_DL_PDU_REL8_TAG; - dl_config_pdu->dci_dl_pdu.dci_dl_pdu_rel8.dci_format = NFAPI_DL_DCI_FORMAT_1A; - dl_config_pdu->dci_dl_pdu.dci_dl_pdu_rel8.aggregation_level = get_aggregation(get_bw_index(module_idP, CC_id), - UE_info->UE_sched_ctrl[UE_id]. - dl_cqi[CC_id], format1A); - dl_config_pdu->dci_dl_pdu.dci_dl_pdu_rel8.rnti = rnti; - dl_config_pdu->dci_dl_pdu.dci_dl_pdu_rel8.rnti_type = 1; // CRNTI : see Table 4-10 from SCF082 - nFAPI specifications - dl_config_pdu->dci_dl_pdu.dci_dl_pdu_rel8.transmission_power = 6000; // equal to RS power - - AssertFatal((cc[CC_id].mib->message.dl_Bandwidth >= 0) && (cc[CC_id].mib->message.dl_Bandwidth < 6), - "illegal dl_Bandwidth %d\n", - (int) cc[CC_id].mib->message.dl_Bandwidth); - dl_config_pdu->dci_dl_pdu.dci_dl_pdu_rel8.resource_block_coding = nr_pdcch_order_table[cc[CC_id].mib->message.dl_Bandwidth]; - DL_req[CC_id].dl_tti_request_body.number_dci++; - DL_req[CC_id].dl_tti_request_body.number_pdu++; - DL_req[CC_id].dl_tti_request_body.tl.tag = NFAPI_DL_TTI_REQUEST_BODY_TAG; - LOG_I(MAC, - "UE %d rnti %x: sending PDCCH order for RAPROC (failure timer %d), resource_block_coding %d \n", - UE_id, rnti, - UE_info->UE_sched_ctrl[UE_id].ul_failure_timer, - dl_config_pdu->dci_dl_pdu. - dci_dl_pdu_rel8.resource_block_coding); - } else { // ra_pdcch_sent==1 - LOG_I(MAC, - "UE %d rnti %x: sent PDCCH order for RAPROC waiting (failure timer %d) \n", - UE_id, rnti, - UE_info->UE_sched_ctrl[UE_id].ul_failure_timer); - if ((UE_info->UE_sched_ctrl[UE_id].ul_failure_timer % 40) == 0) UE_info->UE_sched_ctrl[UE_id].ra_pdcch_order_sent = 0; // resend every 4 frames - } - - UE_info->UE_sched_ctrl[UE_id].ul_failure_timer++; - // check threshold - if (UE_info->UE_sched_ctrl[UE_id].ul_failure_timer > 20000) { - // inform RRC of failure and clear timer - LOG_I(MAC, - "UE %d rnti %x: UL Failure after repeated PDCCH orders: Triggering RRC \n", - UE_id, rnti); - mac_eNB_rrc_ul_failure(module_idP, CC_id, frameP, subframeP,rnti); - UE_info->UE_sched_ctrl[UE_id].ul_failure_timer = 0; - UE_info->UE_sched_ctrl[UE_id].ul_out_of_sync = 1; - - //Inform the controller about the UE deactivation. Should be moved to RRC agent in the future - if (rrc_agent_registered[module_idP]) { - LOG_W(MAC, "notify flexran Agent of UE state change\n"); - agent_rrc_xface[module_idP]->flexran_agent_notify_ue_state_change(module_idP, - rnti, PROTOCOL__FLEX_UE_STATE_CHANGE_TYPE__FLUESC_DEACTIVATED); - } - } - } // ul_failure_timer>0 - -} -*/ -/* -void schedule_nr_SRS(module_id_t module_idP, frame_t frameP, sub_frame_t subframeP) -{ - gNB_MAC_INST *gNB = RC.nrmac[module_idP]; - NR_UE_info_t *UE_info = &gNB->UE_info; - nfapi_ul_config_request_body_t *ul_req; - int CC_id, UE_id; - NR_COMMON_channels_t *cc = RC.nrmac[module_idP]->common_channels; - SoundingRS_UL_ConfigCommon_t *soundingRS_UL_ConfigCommon; - struct SoundingRS_UL_ConfigDedicated *soundingRS_UL_ConfigDedicated; - uint8_t TSFC; - uint16_t deltaTSFC; // bitmap - uint8_t srs_SubframeConfig; - - // table for TSFC (Period) and deltaSFC (offset) - const uint16_t deltaTSFCTabType1[15][2] = { {1, 1}, {1, 2}, {2, 2}, {1, 5}, {2, 5}, {4, 5}, {8, 5}, {3, 5}, {12, 5}, {1, 10}, {2, 10}, {4, 10}, {8, 10}, {351, 10}, {383, 10} }; // Table 5.5.3.3-2 3GPP 36.211 FDD - const uint16_t deltaTSFCTabType2[14][2] = { {2, 5}, {6, 5}, {10, 5}, {18, 5}, {14, 5}, {22, 5}, {26, 5}, {30, 5}, {70, 10}, {74, 10}, {194, 10}, {326, 10}, {586, 10}, {210, 10} }; // Table 5.5.3.3-2 3GPP 36.211 TDD - - uint16_t srsPeriodicity, srsOffset; - - for (CC_id = 0; CC_id < MAX_NUM_CCs; CC_id++) { - soundingRS_UL_ConfigCommon = &cc[CC_id].radioResourceConfigCommon->soundingRS_UL_ConfigCommon; - // check if SRS is enabled in this frame/subframe - if (soundingRS_UL_ConfigCommon) { - srs_SubframeConfig = soundingRS_UL_ConfigCommon->choice.setup.srs_SubframeConfig; - if (cc[CC_id].tdd_Config == NULL) { // FDD - deltaTSFC = deltaTSFCTabType1[srs_SubframeConfig][0]; - TSFC = deltaTSFCTabType1[srs_SubframeConfig][1]; - } else { // TDD - deltaTSFC = deltaTSFCTabType2[srs_SubframeConfig][0]; - TSFC = deltaTSFCTabType2[srs_SubframeConfig][1]; - } - // Sounding reference signal subframes are the subframes satisfying ns/2 mod TSFC (- deltaTSFC - uint16_t tmp = (subframeP % TSFC); - - if ((1 << tmp) & deltaTSFC) { - // This is an SRS subframe, loop over UEs - for (UE_id = 0; UE_id < MAX_MOBILES_PER_GNB; UE_id++) { - if (!RC.nrmac[module_idP]->UE_info.active[UE_id]) continue; - ul_req = &RC.nrmac[module_idP]->UL_req[CC_id].ul_config_request_body; - // drop the allocation if the UE hasn't send RRCConnectionSetupComplete yet - if (mac_eNB_get_rrc_status(module_idP,UE_RNTI(module_idP, UE_id)) < RRC_CONNECTED) continue; - - AssertFatal(UE_info->UE_template[CC_id][UE_id].physicalConfigDedicated != NULL, - "physicalConfigDedicated is null for UE %d\n", - UE_id); - - if ((soundingRS_UL_ConfigDedicated = UE_info->UE_template[CC_id][UE_id].physicalConfigDedicated->soundingRS_UL_ConfigDedicated) != NULL) { - if (soundingRS_UL_ConfigDedicated->present == SoundingRS_UL_ConfigDedicated_PR_setup) { - get_srs_pos(&cc[CC_id], - soundingRS_UL_ConfigDedicated->choice. - setup.srs_ConfigIndex, - &srsPeriodicity, &srsOffset); - if (((10 * frameP + subframeP) % srsPeriodicity) == srsOffset) { - // Program SRS - ul_req->srs_present = 1; - nfapi_ul_config_request_pdu_t * ul_config_pdu = &ul_req->ul_config_pdu_list[ul_req->number_of_pdus]; - memset((void *) ul_config_pdu, 0, sizeof(nfapi_ul_config_request_pdu_t)); - ul_config_pdu->pdu_type = NFAPI_UL_CONFIG_SRS_PDU_TYPE; - ul_config_pdu->pdu_size = 2 + (uint8_t) (2 + sizeof(nfapi_ul_config_srs_pdu)); - ul_config_pdu->srs_pdu.srs_pdu_rel8.tl.tag = NFAPI_UL_CONFIG_REQUEST_SRS_PDU_REL8_TAG; - ul_config_pdu->srs_pdu.srs_pdu_rel8.size = (uint8_t)sizeof(nfapi_ul_config_srs_pdu); - ul_config_pdu->srs_pdu.srs_pdu_rel8.rnti = UE_info->UE_template[CC_id][UE_id].rnti; - ul_config_pdu->srs_pdu.srs_pdu_rel8.srs_bandwidth = soundingRS_UL_ConfigDedicated->choice.setup.srs_Bandwidth; - ul_config_pdu->srs_pdu.srs_pdu_rel8.frequency_domain_position = soundingRS_UL_ConfigDedicated->choice.setup.freqDomainPosition; - ul_config_pdu->srs_pdu.srs_pdu_rel8.srs_hopping_bandwidth = soundingRS_UL_ConfigDedicated->choice.setup.srs_HoppingBandwidth;; - ul_config_pdu->srs_pdu.srs_pdu_rel8.transmission_comb = soundingRS_UL_ConfigDedicated->choice.setup.transmissionComb; - ul_config_pdu->srs_pdu.srs_pdu_rel8.i_srs = soundingRS_UL_ConfigDedicated->choice.setup.srs_ConfigIndex; - ul_config_pdu->srs_pdu.srs_pdu_rel8.sounding_reference_cyclic_shift = soundingRS_UL_ConfigDedicated->choice.setup.cyclicShift; // ul_config_pdu->srs_pdu.srs_pdu_rel10.antenna_port = ;// - // ul_config_pdu->srs_pdu.srs_pdu_rel13.number_of_combs = ;// - RC.nrmac[module_idP]->UL_req[CC_id].sfn_sf = (frameP << 4) + subframeP; - RC.nrmac[module_idP]->UL_req[CC_id].header.message_id = NFAPI_UL_CONFIG_REQUEST; - ul_req->number_of_pdus++; - } // if (((10*frameP+subframeP) % srsPeriodicity) == srsOffset) - } // if (soundingRS_UL_ConfigDedicated->present == SoundingRS_UL_ConfigDedicated_PR_setup) - } // if ((soundingRS_UL_ConfigDedicated = UE_info->UE_template[CC_id][UE_id].physicalConfigDedicated->soundingRS_UL_ConfigDedicated)!=NULL) - } // for (UE_id ... - } // if((1<=64) return false; //quickfix for FR2 where there are more than 64 slots (bitmap to be removed) @@ -278,8 +117,6 @@ void gNB_dlsch_ulsch_scheduler(module_id_t module_idP, protocol_ctxt_t ctxt={0}; PROTOCOL_CTXT_SET_BY_MODULE_ID(&ctxt, module_idP, ENB_FLAG_YES, NOT_A_RNTI, frame, slot,module_idP); - char stats_output[16384]; - gNB_MAC_INST *gNB = RC.nrmac[module_idP]; NR_COMMON_channels_t *cc = gNB->common_channels; NR_ServingCellConfigCommon_t *scc = cc->ServingCellConfigCommon; @@ -307,8 +144,6 @@ void gNB_dlsch_ulsch_scheduler(module_id_t module_idP, nr_rrc_trigger(&ctxt, 0 /*CC_id*/, frame, slot >> *scc->ssbSubcarrierSpacing); } - for (int i=0; ipdcch_cand[i] = 0; for (int CC_id = 0; CC_id < MAX_NUM_CCs; CC_id++) { //mbsfn_status[CC_id] = 0; @@ -318,7 +153,7 @@ void gNB_dlsch_ulsch_scheduler(module_id_t module_idP, const int num_slots = nr_slots_per_frame[*scc->ssbSubcarrierSpacing]; const int last_slot = (slot + num_slots - 1) % num_slots; uint16_t *vrb_map_UL = cc[CC_id].vrb_map_UL; - memset(&vrb_map_UL[last_slot * MAX_BWP_SIZE], 0, sizeof(uint16_t) * MAX_BWP_SIZE); + memcpy(&vrb_map_UL[last_slot * MAX_BWP_SIZE], &RC.nrmac[module_idP]->ulprbbl, sizeof(uint16_t) * MAX_BWP_SIZE); clear_nr_nfapi_information(RC.nrmac[module_idP], CC_id, frame, slot); @@ -341,11 +176,16 @@ void gNB_dlsch_ulsch_scheduler(module_id_t module_idP, if ((slot == 0) && (frame & 127) == 0) { - stats_output[0]='\0'; - dump_mac_stats(RC.nrmac[module_idP],stats_output,16384,true); - LOG_I(NR_MAC,"Frame.Slot %d.%d\n%s\n",frame,slot,stats_output); + char stats_output[16384]; + stats_output[0] = '\0'; + dump_mac_stats(RC.nrmac[module_idP], stats_output, sizeof(stats_output), true); + LOG_I(NR_MAC, "Frame.Slot %d.%d\n%s\n", frame, slot, stats_output); } + nr_mac_update_timers(module_idP, frame, slot); + + schedule_nr_bwp_switch(module_idP, frame, slot); + // This schedules MIB schedule_nr_mib(module_idP, frame, slot); @@ -368,9 +208,6 @@ void gNB_dlsch_ulsch_scheduler(module_id_t module_idP, schedule_nr_prach(module_idP, f, s); } - // This schedule SR - nr_sr_reporting(module_idP, frame, slot); - // Schedule CSI-RS transmission nr_csirs_scheduling(module_idP, frame, slot, nr_slots_per_frame[*scc->ssbSubcarrierSpacing]); @@ -396,7 +233,10 @@ void gNB_dlsch_ulsch_scheduler(module_id_t module_idP, nr_schedule_ue_spec(module_idP, frame, slot); stop_meas(&gNB->schedule_dlsch); - nr_schedule_pucch(module_idP, frame, slot); + nr_schedule_pucch(RC.nrmac[module_idP], frame, slot); + + // This schedule SR after PUCCH for multiplexing + nr_sr_reporting(RC.nrmac[module_idP], frame, slot); stop_meas(&RC.nrmac[module_idP]->eNB_scheduler); diff --git a/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_RA.c b/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_RA.c index a10845a6ab..e3d3a5409d 100644 --- a/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_RA.c +++ b/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_RA.c @@ -228,7 +228,7 @@ void find_SSB_and_RO_available(module_id_t module_idP) { cc->total_prach_occasions = total_RA_occasions - unused_RA_occasion; cc->num_active_ssb = num_active_ssb; - LOG_I(NR_MAC, + LOG_D(NR_MAC, "Total available RO %d, num of active SSB %d: unused RO = %d association_period %u N_RA_sfn %u total_prach_occasions_per_config_period %u\n", cc->total_prach_occasions, cc->num_active_ssb, @@ -300,6 +300,8 @@ void schedule_nr_prach(module_id_t module_idP, frame_t frameP, sub_frame_t slotP (RA_sfn_index + slot_index) * N_t_slot * fdm + td_index * fdm + fdm_index; if((prach_occasion_id < cc->total_prach_occasions) && (td_index == 0)){ + AssertFatal(UL_tti_req->n_pdus < sizeof(UL_tti_req->pdus_list) / sizeof(UL_tti_req->pdus_list[0]), + "Invalid UL_tti_req->n_pdus %d\n", UL_tti_req->n_pdus); UL_tti_req->pdus_list[UL_tti_req->n_pdus].pdu_type = NFAPI_NR_UL_CONFIG_PRACH_PDU_TYPE; UL_tti_req->pdus_list[UL_tti_req->n_pdus].pdu_size = sizeof(nfapi_nr_prach_pdu_t); @@ -389,7 +391,7 @@ void schedule_nr_prach(module_id_t module_idP, frame_t frameP, sub_frame_t slotP const int16_t N_RA_RB = get_N_RA_RB(cfg->prach_config.prach_sub_c_spacing.value, mu_pusch); uint16_t *vrb_map_UL = &cc->vrb_map_UL[slotP * MAX_BWP_SIZE]; for (int i = 0; i < N_RA_RB * fdm; ++i) - vrb_map_UL[bwp_start + rach_ConfigGeneric->msg1_FrequencyStart + i] = 0xff; // all symbols + vrb_map_UL[bwp_start + rach_ConfigGeneric->msg1_FrequencyStart + i] |= SL_to_bitmap(start_symbol, N_t_slot*N_dur); } } } @@ -397,11 +399,11 @@ void schedule_nr_prach(module_id_t module_idP, frame_t frameP, sub_frame_t slotP void nr_schedule_msg2(uint16_t rach_frame, uint16_t rach_slot, uint16_t *msg2_frame, uint16_t *msg2_slot, NR_ServingCellConfigCommon_t *scc, - lte_frame_type_t frame_type, + frame_type_t frame_type, uint16_t monitoring_slot_period, uint16_t monitoring_offset,uint8_t beam_index, uint8_t num_active_ssb, - int16_t *tdd_beam_association){ + int16_t *tdd_beam_association, int sl_ahead){ // preferentially we schedule the msg2 in the mixed slot or in the last dl slot // if they are allowed by search space configuration @@ -463,27 +465,24 @@ void nr_schedule_msg2(uint16_t rach_frame, uint16_t rach_slot, int FR = *scc->downlinkConfigCommon->frequencyInfoDL->frequencyBandList.list.array[0] >= 257 ? nr_FR2 : nr_FR1; - uint8_t start_next_period = (rach_slot-(rach_slot%tdd_period_slot)+tdd_period_slot)%nr_slots_per_frame[mu]; - *msg2_slot = start_next_period + last_dl_slot_period; // initializing scheduling of slot to next mixed (or last dl) slot - *msg2_frame = ((*msg2_slot>(rach_slot))? rach_frame : (rach_frame+1))%1024; - + uint8_t start_next_period = rach_slot-(rach_slot%tdd_period_slot)+tdd_period_slot; + int eff_slot = start_next_period + last_dl_slot_period; // initializing scheduling of slot to next mixed (or last dl) slot // we can't schedule msg2 before sl_ahead since prach - int eff_slot = *msg2_slot+(*msg2_frame-rach_frame)*nr_slots_per_frame[mu]; - if ((eff_slot-rach_slot)<=sl_ahead) { - *msg2_slot = (*msg2_slot+tdd_period_slot)%nr_slots_per_frame[mu]; - *msg2_frame = ((*msg2_slot>(rach_slot))? rach_frame : (rach_frame+1))%1024; + while ((eff_slot-rach_slot)<=sl_ahead) { + eff_slot += tdd_period_slot; } if (FR==nr_FR2) { - int num_tdd_period = *msg2_slot/tdd_period_slot; + int num_tdd_period = (eff_slot%nr_slots_per_frame[mu])/tdd_period_slot; while((tdd_beam_association[num_tdd_period]!=-1)&&(tdd_beam_association[num_tdd_period]!=beam_index)) { - *msg2_slot = (*msg2_slot+tdd_period_slot)%nr_slots_per_frame[mu]; - *msg2_frame = ((*msg2_slot>(rach_slot))? rach_frame : (rach_frame+1))%1024; - num_tdd_period = *msg2_slot/tdd_period_slot; + eff_slot += tdd_period_slot; + num_tdd_period = (eff_slot % nr_slots_per_frame[mu])/tdd_period_slot; } if(tdd_beam_association[num_tdd_period] == -1) tdd_beam_association[num_tdd_period] = beam_index; } + *msg2_frame=(rach_frame + eff_slot/nr_slots_per_frame[mu])%1024; + *msg2_slot=eff_slot%nr_slots_per_frame[mu]; // go to previous slot if the current scheduled slot is beyond the response window // and if the slot is not among the PDCCH monitored ones (38.213 10.1) while (*msg2_frame > frame_limit @@ -523,7 +522,7 @@ void nr_initiate_ra_proc(module_id_t module_idP, gNB_MAC_INST *nr_mac = RC.nrmac[module_idP]; NR_COMMON_channels_t *cc = &nr_mac->common_channels[CC_id]; NR_ServingCellConfigCommon_t *scc = cc->ServingCellConfigCommon; - lte_frame_type_t frame_type = cc->frame_type; + frame_type_t frame_type = cc->frame_type; uint8_t total_RApreambles = MAX_NUM_NR_PRACH_PREAMBLES; uint8_t num_ssb_per_RO = scc->uplinkConfigCommon->initialUplinkBWP->rach_ConfigCommon->choice.setup->ssb_perRACH_OccasionAndCB_PreamblesPerSSB->present; @@ -538,157 +537,164 @@ void nr_initiate_ra_proc(module_id_t module_idP, } for (int i = 0; i < NR_NB_RA_PROC_MAX; i++) { + NR_RA_t *ra = &cc->ra[i]; - pr_found = 0; - const int UE_id = find_nr_UE_id(module_idP, ra->rnti); - if (UE_id != -1) { + if (ra->state != RA_IDLE) continue; + + pr_found = 0; + + for(int j = 0; j < ra->preambles.num_preambles; j++) { + //check if the preamble received correspond to one of the listed or configured preambles + if (preamble_index == ra->preambles.preamble_list[j]) { + if (ra->rnti == 0 && get_softmodem_params()->nsa) + continue; + pr_found=1; + break; + } } - if (ra->state == RA_IDLE) { - for(int j = 0; j < ra->preambles.num_preambles; j++) { - //check if the preamble received correspond to one of the listed or configured preambles - if (preamble_index == ra->preambles.preamble_list[j]) { - if (ra->rnti == 0 && get_softmodem_params()->nsa) - continue; - pr_found=1; - break; - } - } - if (pr_found == 0) { - continue; + if (pr_found == 0) { + continue; + } + + uint16_t ra_rnti; + + // ra_rnti from 5.1.3 in 38.321 + // FK: in case of long PRACH the phone seems to expect the subframe number instead of the slot number here. + if (scc->uplinkConfigCommon->initialUplinkBWP->rach_ConfigCommon->choice.setup->prach_RootSequenceIndex.present + == NR_RACH_ConfigCommon__prach_RootSequenceIndex_PR_l839) + ra_rnti = 1 + symbol + (9 /*slotP*/ * 14) + (freq_index * 14 * 80) + (ul_carrier_id * 14 * 80 * 8); + else + ra_rnti = 1 + symbol + (slotP * 14) + (freq_index * 14 * 80) + (ul_carrier_id * 14 * 80 * 8); + + // This should be handled differently when we use the initialBWP for RA + ra->dl_bwp_id = 0;//TODO + ra->ul_bwp_id = 0; + NR_BWP_Downlink_t *bwp=NULL; + if (ra->CellGroup && ra->CellGroup->spCellConfig && ra->CellGroup->spCellConfig->spCellConfigDedicated) { + if (ra->CellGroup->spCellConfig->spCellConfigDedicated->firstActiveDownlinkBWP_Id && + ra->CellGroup->spCellConfig->spCellConfigDedicated->downlinkBWP_ToAddModList) { + ra->dl_bwp_id = *ra->CellGroup->spCellConfig->spCellConfigDedicated->firstActiveDownlinkBWP_Id; + bwp = ra->CellGroup->spCellConfig->spCellConfigDedicated->downlinkBWP_ToAddModList->list.array[ra->dl_bwp_id - 1]; } + if (ra->CellGroup->spCellConfig->spCellConfigDedicated->uplinkConfig && + ra->CellGroup->spCellConfig->spCellConfigDedicated->uplinkConfig->firstActiveUplinkBWP_Id) + ra->ul_bwp_id = *ra->CellGroup->spCellConfig->spCellConfigDedicated->uplinkConfig->firstActiveUplinkBWP_Id; + } - uint16_t ra_rnti; + VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_INITIATE_RA_PROC, 1); - // ra_rnti from 5.1.3 in 38.321 - // FK: in case of long PRACH the phone seems to expect the subframe number instead of the slot number here. - if (scc->uplinkConfigCommon->initialUplinkBWP->rach_ConfigCommon->choice.setup->prach_RootSequenceIndex.present - == NR_RACH_ConfigCommon__prach_RootSequenceIndex_PR_l839) - ra_rnti = 1 + symbol + (9 /*slotP*/ * 14) + (freq_index * 14 * 80) + (ul_carrier_id * 14 * 80 * 8); - else - ra_rnti = 1 + symbol + (slotP * 14) + (freq_index * 14 * 80) + (ul_carrier_id * 14 * 80 * 8); + LOG_D(NR_MAC, + "[gNB %d][RAPROC] CC_id %d Frame %d, Slot %d Initiating RA procedure for preamble index %d\n", + module_idP, + CC_id, + frameP, + slotP, + preamble_index); - // This should be handled differently when we use the initialBWP for RA - ra->bwp_id = 0; - NR_BWP_Downlink_t *bwp=NULL; - if (ra->CellGroup && ra->CellGroup->spCellConfig && ra->CellGroup->spCellConfig->spCellConfigDedicated && - ra->CellGroup->spCellConfig->spCellConfigDedicated->downlinkBWP_ToAddModList) { - ra->bwp_id = 1; - bwp = ra->CellGroup->spCellConfig->spCellConfigDedicated->downlinkBWP_ToAddModList->list.array[ra->bwp_id - 1]; - } + uint8_t beam_index = ssb_index_from_prach(module_idP, frameP, slotP, preamble_index, freq_index, symbol); - VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_INITIATE_RA_PROC, 1); - - LOG_D(NR_MAC, - "[gNB %d][RAPROC] CC_id %d Frame %d, Slot %d Initiating RA procedure for preamble index %d\n", + // the UE sent a RACH either for starting RA procedure or RA procedure failed and UE retries + if (ra->cfra) { + // if the preamble received correspond to one of the listed + if (!(preamble_index == ra->preambles.preamble_list[beam_index])) { + LOG_E( + NR_MAC, + "[gNB %d][RAPROC] FAILURE: preamble %d does not correspond to any of the ones in rach_ConfigDedicated\n", module_idP, - CC_id, - frameP, - slotP, preamble_index); - - uint8_t beam_index = ssb_index_from_prach(module_idP, frameP, slotP, preamble_index, freq_index, symbol); - - // the UE sent a RACH either for starting RA procedure or RA procedure failed and UE retries - if (ra->cfra) { - // if the preamble received correspond to one of the listed - if (!(preamble_index == ra->preambles.preamble_list[beam_index])) { - LOG_E( - NR_MAC, - "[gNB %d][RAPROC] FAILURE: preamble %d does not correspond to any of the ones in rach_ConfigDedicated\n", - module_idP, - preamble_index); - continue; // if the PRACH preamble does not correspond to any of the ones sent through RRC abort RA proc - } + continue; // if the PRACH preamble does not correspond to any of the ones sent through RRC abort RA proc } - LOG_D(NR_MAC, "Frame %d, Slot %d: Activating RA process \n", frameP, slotP); - ra->state = Msg2; - ra->timing_offset = timing_offset; - ra->preamble_slot = slotP; - - NR_SearchSpaceId_t ra_SearchSpace = 0; - struct NR_PDCCH_ConfigCommon__commonSearchSpaceList *commonSearchSpaceList = NULL; - NR_BWP_t *genericParameters = NULL; - if(bwp) { - commonSearchSpaceList = bwp->bwp_Common->pdcch_ConfigCommon->choice.setup->commonSearchSpaceList; - ra_SearchSpace = *bwp->bwp_Common->pdcch_ConfigCommon->choice.setup->ra_SearchSpace; - genericParameters = &bwp->bwp_Common->genericParameters; - } else { - commonSearchSpaceList = scc->downlinkConfigCommon->initialDownlinkBWP->pdcch_ConfigCommon->choice.setup->commonSearchSpaceList; - ra_SearchSpace = *scc->downlinkConfigCommon->initialDownlinkBWP->pdcch_ConfigCommon->choice.setup->ra_SearchSpace; - genericParameters = &scc->downlinkConfigCommon->initialDownlinkBWP->genericParameters; - } - AssertFatal(commonSearchSpaceList->list.count > 0, "common SearchSpace list has 0 elements\n"); - - // Common SearchSpace list - for (int i = 0; i < commonSearchSpaceList->list.count; i++) { - ss = commonSearchSpaceList->list.array[i]; - if (ss->searchSpaceId == ra_SearchSpace) - ra->ra_ss = ss; - } - - AssertFatal(ra->ra_ss!=NULL,"SearchSpace cannot be null for RA\n"); - - ra->coreset = get_coreset(module_idP, scc, bwp, ra->ra_ss, NR_SearchSpace__searchSpaceType_PR_common); - ra->sched_pdcch = set_pdcch_structure(nr_mac, - ra->ra_ss, - ra->coreset, - scc, - genericParameters, - NULL); - - // retrieving ra pdcch monitoring period and offset - find_monitoring_periodicity_offset_common(ra->ra_ss, &monitoring_slot_period, &monitoring_offset); - - nr_schedule_msg2(frameP, - slotP, - &msg2_frame, - &msg2_slot, - scc, - frame_type, - monitoring_slot_period, - monitoring_offset, - beam_index, - cc->num_active_ssb, - nr_mac->tdd_beam_association); - - ra->Msg2_frame = msg2_frame; - ra->Msg2_slot = msg2_slot; - - LOG_D(NR_MAC, "%s() Msg2[%04d%d] SFN/SF:%04d%d\n", __FUNCTION__, ra->Msg2_frame, ra->Msg2_slot, frameP, slotP); - - int loop = 0; - if (ra->rnti == 0) { // This condition allows for the usage of a preconfigured rnti for the CFRA - do { - ra->rnti = (taus() % 65518) + 1; - loop++; - } while (loop != 100 - && !((find_nr_UE_id(module_idP, ra->rnti) == -1) && (find_nr_RA_id(module_idP, CC_id, ra->rnti) == -1) - && ra->rnti >= 1 && ra->rnti <= 65519)); - if (loop == 100) { - LOG_E(NR_MAC, "%s:%d:%s: [RAPROC] initialisation random access aborted\n", __FILE__, __LINE__, __FUNCTION__); - abort(); - } - } - - ra->RA_rnti = ra_rnti; - ra->preamble_index = preamble_index; - ra->beam_id = beam_index; - - LOG_I(NR_MAC, - "[gNB %d][RAPROC] CC_id %d Frame %d Activating Msg2 generation in frame %d, slot %d using RA rnti %x SSB " - "index %u RA index %d\n", - module_idP, - CC_id, - frameP, - ra->Msg2_frame, - ra->Msg2_slot, - ra->RA_rnti, - cc->ssb_index[beam_index], - i); - - return; } + LOG_D(NR_MAC, "Frame %d, Slot %d: Activating RA process \n", frameP, slotP); + ra->state = Msg2; + ra->timing_offset = timing_offset; + ra->preamble_slot = slotP; + + NR_SearchSpaceId_t ra_SearchSpace = 0; + struct NR_PDCCH_ConfigCommon__commonSearchSpaceList *commonSearchSpaceList = NULL; + NR_BWP_t *genericParameters = NULL; + if(bwp) { + commonSearchSpaceList = bwp->bwp_Common->pdcch_ConfigCommon->choice.setup->commonSearchSpaceList; + ra_SearchSpace = *bwp->bwp_Common->pdcch_ConfigCommon->choice.setup->ra_SearchSpace; + genericParameters = &bwp->bwp_Common->genericParameters; + } else { + commonSearchSpaceList = scc->downlinkConfigCommon->initialDownlinkBWP->pdcch_ConfigCommon->choice.setup->commonSearchSpaceList; + ra_SearchSpace = *scc->downlinkConfigCommon->initialDownlinkBWP->pdcch_ConfigCommon->choice.setup->ra_SearchSpace; + genericParameters = &scc->downlinkConfigCommon->initialDownlinkBWP->genericParameters; + } + AssertFatal(commonSearchSpaceList->list.count > 0, "common SearchSpace list has 0 elements\n"); + + // Common SearchSpace list + for (int i = 0; i < commonSearchSpaceList->list.count; i++) { + ss = commonSearchSpaceList->list.array[i]; + if (ss->searchSpaceId == ra_SearchSpace) + ra->ra_ss = ss; + } + + AssertFatal(ra->ra_ss!=NULL,"SearchSpace cannot be null for RA\n"); + + ra->coreset = get_coreset(nr_mac, scc, bwp, ra->ra_ss, NR_SearchSpace__searchSpaceType_PR_common); + ra->sched_pdcch = set_pdcch_structure(nr_mac, + ra->ra_ss, + ra->coreset, + scc, + genericParameters, + &nr_mac->type0_PDCCH_CSS_config[ra->beam_id]); + + // retrieving ra pdcch monitoring period and offset + find_monitoring_periodicity_offset_common(ra->ra_ss, &monitoring_slot_period, &monitoring_offset); + + nr_schedule_msg2(frameP, + slotP, + &msg2_frame, + &msg2_slot, + scc, + frame_type, + monitoring_slot_period, + monitoring_offset, + beam_index, + cc->num_active_ssb, + nr_mac->tdd_beam_association, + nr_mac->if_inst->sl_ahead); + + ra->Msg2_frame = msg2_frame; + ra->Msg2_slot = msg2_slot; + + LOG_D(NR_MAC, "%s() Msg2[%04d%d] SFN/SF:%04d%d\n", __FUNCTION__, ra->Msg2_frame, ra->Msg2_slot, frameP, slotP); + + int loop = 0; + if (ra->rnti == 0) { // This condition allows for the usage of a preconfigured rnti for the CFRA + do { + ra->rnti = (taus() % 65518) + 1; + loop++; + } while (loop != 100 + && !((find_nr_UE(&nr_mac->UE_info, ra->rnti) == NULL) && (find_nr_RA_id(module_idP, CC_id, ra->rnti) == -1) + && ra->rnti >= 1 && ra->rnti <= 65519)); + if (loop == 100) { + LOG_E(NR_MAC, "%s:%d:%s: [RAPROC] initialisation random access aborted\n", __FILE__, __LINE__, __FUNCTION__); + abort(); + } + } + + ra->RA_rnti = ra_rnti; + ra->preamble_index = preamble_index; + ra->beam_id = beam_index; + + LOG_I(NR_MAC, + "[gNB %d][RAPROC] CC_id %d Frame %d Activating Msg2 generation in frame %d, slot %d using RA rnti %x SSB, new rnti %04x " + "index %u RA index %d\n", + module_idP, + CC_id, + frameP, + ra->Msg2_frame, + ra->Msg2_slot, + ra->RA_rnti, + ra->rnti, + cc->ssb_index[beam_index], + i); + + return; } LOG_E(NR_MAC, "[gNB %d][RAPROC] FAILURE: CC_id %d Frame %d initiating RA procedure for preamble index %d\n", module_idP, CC_id, frameP, preamble_index); @@ -738,7 +744,7 @@ void nr_generate_Msg3_retransmission(module_id_t module_idP, int CC_id, frame_t NR_PUSCH_TimeDomainResourceAllocationList_t *pusch_TimeDomainAllocationList = NULL; NR_BWP_t *genericParameters = NULL; if(ra->CellGroup) { - ubwp = ra->CellGroup->spCellConfig->spCellConfigDedicated->uplinkConfig->uplinkBWP_ToAddModList->list.array[ra->bwp_id-1]; + ubwp = ra->CellGroup->spCellConfig->spCellConfigDedicated->uplinkConfig->uplinkBWP_ToAddModList->list.array[ra->ul_bwp_id-1]; ubwpd = ra->CellGroup->spCellConfig->spCellConfigDedicated->uplinkConfig->initialUplinkBWP; genericParameters = &ubwp->bwp_Common->genericParameters; pusch_TimeDomainAllocationList = ubwp->bwp_Common->pusch_ConfigCommon->choice.setup->pusch_TimeDomainAllocationList; @@ -772,15 +778,18 @@ void nr_generate_Msg3_retransmission(module_id_t module_idP, int CC_id, frame_t int scs = scc->uplinkConfigCommon->initialUplinkBWP->genericParameters.subcarrierSpacing; int fh = 0; int startSymbolAndLength = scc->uplinkConfigCommon->initialUplinkBWP->pusch_ConfigCommon->choice.setup->pusch_TimeDomainAllocationList->list.array[ra->Msg3_tda_id]->startSymbolAndLength; + int StartSymbolIndex, NrOfSymbols; + SLIV2SL(startSymbolAndLength, &StartSymbolIndex, &NrOfSymbols); int mappingtype = scc->uplinkConfigCommon->initialUplinkBWP->pusch_ConfigCommon->choice.setup->pusch_TimeDomainAllocationList->list.array[ra->Msg3_tda_id]->mappingType; uint16_t *vrb_map_UL = &RC.nrmac[module_idP]->common_channels[CC_id].vrb_map_UL[sched_slot * MAX_BWP_SIZE]; - int BWPStart = nr_mac->type0_PDCCH_CSS_config[ra->beam_id].cset_start_rb; - int BWPSize = nr_mac->type0_PDCCH_CSS_config[ra->beam_id].num_rbs; + const int BWPSize = NRRIV2BW(scc->uplinkConfigCommon->initialUplinkBWP->genericParameters.locationAndBandwidth, MAX_BWP_SIZE); + const int BWPStart = NRRIV2PRBOFFSET(scc->uplinkConfigCommon->initialUplinkBWP->genericParameters.locationAndBandwidth, MAX_BWP_SIZE); + int rbStart = 0; for (int i = 0; (i < ra->msg3_nb_rb) && (rbStart <= (BWPSize - ra->msg3_nb_rb)); i++) { - if (vrb_map_UL[rbStart + BWPStart + i]) { + if (vrb_map_UL[rbStart + BWPStart + i]&SL_to_bitmap(StartSymbolIndex, NrOfSymbols)) { rbStart += i; i = 0; } @@ -801,6 +810,9 @@ void nr_generate_Msg3_retransmission(module_id_t module_idP, int CC_id, frame_t future_ul_tti_req->Slot, sched_frame, sched_slot); + AssertFatal(future_ul_tti_req->n_pdus < + sizeof(future_ul_tti_req->pdus_list) / sizeof(future_ul_tti_req->pdus_list[0]), + "Invalid future_ul_tti_req->n_pdus %d\n", future_ul_tti_req->n_pdus); future_ul_tti_req->pdus_list[future_ul_tti_req->n_pdus].pdu_type = NFAPI_NR_UL_CONFIG_PUSCH_PDU_TYPE; future_ul_tti_req->pdus_list[future_ul_tti_req->n_pdus].pdu_size = sizeof(nfapi_nr_pusch_pdu_t); nfapi_nr_pusch_pdu_t *pusch_pdu = &future_ul_tti_req->pdus_list[future_ul_tti_req->n_pdus].pusch_pdu; @@ -869,7 +881,9 @@ void nr_generate_Msg3_retransmission(module_id_t module_idP, int CC_id, frame_t dci_pdu_rel15_t uldci_payload; memset(&uldci_payload, 0, sizeof(uldci_payload)); - config_uldci(ubwp, + const NR_SIB1_t *sib1 = cc->sib1 ? cc->sib1->message.choice.c1->choice.systemInformationBlockType1 : NULL; + config_uldci(sib1, + ubwp, ubwpd, scc, pusch_pdu, @@ -878,7 +892,7 @@ void nr_generate_Msg3_retransmission(module_id_t module_idP, int CC_id, frame_t ra->Msg3_tda_id, ra->msg3_TPC, 0, // not used in format 0_0 - ra->bwp_id); + ra->ul_bwp_id); fill_dci_pdu_rel15(scc, ra->CellGroup, @@ -887,7 +901,9 @@ void nr_generate_Msg3_retransmission(module_id_t module_idP, int CC_id, frame_t NR_UL_DCI_FORMAT_0_0, NR_RNTI_TC, pusch_pdu->bwp_size, - ra->bwp_id); + ra->ul_bwp_id, + coresetid, + nr_mac->cset0_bwp_size); // Mark the corresponding RBs as used @@ -898,7 +914,7 @@ void nr_generate_Msg3_retransmission(module_id_t module_idP, int CC_id, frame_t aggregation_level); for (int rb = 0; rb < ra->msg3_nb_rb; rb++) { - vrb_map_UL[rbStart + BWPStart + rb] = 1; + vrb_map_UL[rbStart + BWPStart + rb] |= SL_to_bitmap(StartSymbolIndex, NrOfSymbols); } // reset state to wait msg3 @@ -923,11 +939,14 @@ void nr_get_Msg3alloc(module_id_t module_id, uint16_t msg3_nb_rb = 8; // sdu has 6 or 8 bytes - lte_frame_type_t frame_type = RC.nrmac[module_id]->common_channels->frame_type; + frame_type_t frame_type = RC.nrmac[module_id]->common_channels->frame_type; int mu = ubwp ? ubwp->bwp_Common->genericParameters.subcarrierSpacing : scc->uplinkConfigCommon->initialUplinkBWP->genericParameters.subcarrierSpacing; + int StartSymbolIndex = 0; + int NrOfSymbols = 0; + int startSymbolAndLength = 0; int temp_slot = 0; ra->Msg3_tda_id = 16; // initialization to a value above limit @@ -942,17 +961,28 @@ void nr_get_Msg3alloc(module_id_t module_id, int nb_periods_per_frame = get_nb_periods_per_frame(scc->tdd_UL_DL_ConfigurationCommon->pattern1.dl_UL_TransmissionPeriodicity); int nb_slots_per_period = ((1<list.count; i++) { + startSymbolAndLength = pusch_TimeDomainAllocationList->list.array[i]->startSymbolAndLength; + SLIV2SL(startSymbolAndLength, &StartSymbolIndex, &NrOfSymbols); k2 = *pusch_TimeDomainAllocationList->list.array[i]->k2; - // we want to transmit in the uplink symbols of mixed slot + int start_symbol_index,nr_of_symbols; + SLIV2SL(pusch_TimeDomainAllocationList->list.array[i]->startSymbolAndLength, &start_symbol_index, &nr_of_symbols); + LOG_D(NR_MAC,"Checking Msg3 TDA %d : k2 %d, sliv %d,S %d L %d\n",i,(int)k2,(int)pusch_TimeDomainAllocationList->list.array[i]->startSymbolAndLength,start_symbol_index,nr_of_symbols); + // we want to transmit in the uplink symbols of mixed slot AND assuming Msg2 was in the mixed slot if ((k2 + DELTA[mu])%nb_slots_per_period == 0) { temp_slot = current_slot + k2 + DELTA[mu]; // msg3 slot according to 8.3 in 38.213 ra->Msg3_slot = temp_slot%nr_slots_per_frame[mu]; - if (is_xlsch_in_slot(RC.nrmac[module_id]->ulsch_slot_bitmap[ra->Msg3_slot / 64], ra->Msg3_slot)) { + + if (is_xlsch_in_slot(RC.nrmac[module_id]->ulsch_slot_bitmap[ra->Msg3_slot / 64], ra->Msg3_slot) && + nr_of_symbols<=scc->tdd_UL_DL_ConfigurationCommon->pattern1.nrofUplinkSymbols&& + start_symbol_index>=(14-scc->tdd_UL_DL_ConfigurationCommon->pattern1.nrofUplinkSymbols)) { ra->Msg3_tda_id = i; + ra->msg3_startsymb = StartSymbolIndex; + ra->msg3_nrsymb = NrOfSymbols; break; } } } + AssertFatal(ra->Msg3_tda_id < 16, "Couldn't find an appropriate TD allocation for Msg3\n"); } else { ra->Msg3_tda_id = 0; @@ -987,9 +1017,7 @@ void nr_get_Msg3alloc(module_id_t module_id, int bwpStart = NRRIV2PRBOFFSET(scc->uplinkConfigCommon->initialUplinkBWP->genericParameters.locationAndBandwidth, MAX_BWP_SIZE); if (ra->CellGroup) { - AssertFatal(ra->CellGroup->spCellConfig->spCellConfigDedicated->downlinkBWP_ToAddModList->list.count == 1, - "downlinkBWP_ToAddModList has %d BWP!\n", ra->CellGroup->spCellConfig->spCellConfigDedicated->downlinkBWP_ToAddModList->list.count); - NR_BWP_Uplink_t *ubwp = ra->CellGroup->spCellConfig->spCellConfigDedicated->uplinkConfig->uplinkBWP_ToAddModList->list.array[ra->bwp_id - 1]; + NR_BWP_Uplink_t *ubwp = ra->CellGroup->spCellConfig->spCellConfigDedicated->uplinkConfig->uplinkBWP_ToAddModList->list.array[ra->ul_bwp_id - 1]; int act_bwp_start = NRRIV2PRBOFFSET(ubwp->bwp_Common->genericParameters.locationAndBandwidth, MAX_BWP_SIZE); int act_bwp_size = NRRIV2BW(ubwp->bwp_Common->genericParameters.locationAndBandwidth, MAX_BWP_SIZE); if (!((bwpStart >= act_bwp_start) && ((bwpStart+bwpSize) <= (act_bwp_start+act_bwp_size)))) @@ -1002,11 +1030,12 @@ void nr_get_Msg3alloc(module_id_t module_id, while (rbSize < msg3_nb_rb) { rbStart += rbSize; /* last iteration rbSize was not enough, skip it */ rbSize = 0; - while (rbStart < bwpSize && vrb_map_UL[rbStart + bwpStart]) + while (rbStart < bwpSize && + (vrb_map_UL[rbStart + bwpStart]&SL_to_bitmap(StartSymbolIndex, NrOfSymbols))) rbStart++; AssertFatal(rbStart < bwpSize - msg3_nb_rb, "no space to allocate Msg 3 for RA!\n"); while (rbStart + rbSize < bwpSize - && !vrb_map_UL[rbStart + bwpStart + rbSize] + && !(vrb_map_UL[rbStart + bwpStart + rbSize]&SL_to_bitmap(StartSymbolIndex, NrOfSymbols)) && rbSize < msg3_nb_rb) rbSize++; } @@ -1078,10 +1107,11 @@ void fill_msg3_pusch_pdu(nfapi_nr_pusch_pdu_t *pusch_pdu, int TBS = 0; while(TBS<7) { // TBS for msg3 is 7 bytes (except for RRCResumeRequest1 currently not implemented) mcsindex++; - pusch_pdu->target_code_rate = nr_get_code_rate_ul(mcsindex,pusch_pdu->mcs_table); + int R = nr_get_code_rate_ul(mcsindex,pusch_pdu->mcs_table); + pusch_pdu->target_code_rate = R; pusch_pdu->qam_mod_order = nr_get_Qm_ul(mcsindex,pusch_pdu->mcs_table); TBS = nr_compute_tbs(pusch_pdu->qam_mod_order, - pusch_pdu->target_code_rate, + R, pusch_pdu->rb_size, pusch_pdu->nr_of_symbols, num_dmrs_symb*12, // nb dmrs set for no data in dmrs symbol @@ -1113,7 +1143,7 @@ void nr_add_msg3(module_id_t module_idP, int CC_id, frame_t frameP, sub_frame_t i + ra->msg3_first_rb, ra->Msg3_frame, ra->Msg3_slot); - vrb_map_UL[i + ra->msg3_first_rb + ra->msg3_bwp_start] = 1; + vrb_map_UL[i + ra->msg3_first_rb + ra->msg3_bwp_start] |= SL_to_bitmap(ra->msg3_startsymb, ra->msg3_nrsymb); } LOG_D(NR_MAC, "[gNB %d][RAPROC] Frame %d, Slot %d : CC_id %d RA is active, Msg3 in (%d,%d)\n", module_idP, frameP, slotP, CC_id, ra->Msg3_frame, ra->Msg3_slot); @@ -1138,9 +1168,7 @@ void nr_add_msg3(module_id_t module_idP, int CC_id, frame_t frameP, sub_frame_t int mappingtype = scc->uplinkConfigCommon->initialUplinkBWP->pusch_ConfigCommon->choice.setup->pusch_TimeDomainAllocationList->list.array[ra->Msg3_tda_id]->mappingType; if (ra->CellGroup) { - AssertFatal(ra->CellGroup->spCellConfig->spCellConfigDedicated->downlinkBWP_ToAddModList->list.count == 1, - "downlinkBWP_ToAddModList has %d BWP!\n", ra->CellGroup->spCellConfig->spCellConfigDedicated->downlinkBWP_ToAddModList->list.count); - NR_BWP_Uplink_t *ubwp = ra->CellGroup->spCellConfig->spCellConfigDedicated->uplinkConfig->uplinkBWP_ToAddModList->list.array[ra->bwp_id - 1]; + NR_BWP_Uplink_t *ubwp = ra->CellGroup->spCellConfig->spCellConfigDedicated->uplinkConfig->uplinkBWP_ToAddModList->list.array[ra->ul_bwp_id - 1]; startSymbolAndLength = ubwp->bwp_Common->pusch_ConfigCommon->choice.setup->pusch_TimeDomainAllocationList->list.array[ra->Msg3_tda_id]->startSymbolAndLength; mappingtype = ubwp->bwp_Common->pusch_ConfigCommon->choice.setup->pusch_TimeDomainAllocationList->list.array[ra->Msg3_tda_id]->mappingType; @@ -1171,20 +1199,13 @@ void nr_add_msg3(module_id_t module_idP, int CC_id, frame_t frameP, sub_frame_t nr_fill_rar(module_idP, ra, RAR_pdu, pusch_pdu); } -void nr_generate_Msg2(module_id_t module_idP, int CC_id, frame_t frameP, sub_frame_t slotP, NR_RA_t *ra) -{ +void nr_generate_Msg2(module_id_t module_idP, int CC_id, frame_t frameP, sub_frame_t slotP, NR_RA_t *ra) { gNB_MAC_INST *nr_mac = RC.nrmac[module_idP]; NR_COMMON_channels_t *cc = &nr_mac->common_channels[CC_id]; if ((ra->Msg2_frame == frameP) && (ra->Msg2_slot == slotP)) { - //TODO time domain assignment for msg2 needs to be improved - uint8_t time_domain_assignment; - if(cc->frame_type == TDD) - time_domain_assignment = 1; - else - time_domain_assignment = 0; int mcsIndex = -1; // initialization value int rbStart = 0; int rbSize = 8; @@ -1201,8 +1222,8 @@ void nr_generate_Msg2(module_id_t module_idP, int CC_id, frame_t frameP, sub_fra ra->CellGroup->spCellConfig && ra->CellGroup->spCellConfig->spCellConfigDedicated && ra->CellGroup->spCellConfig->spCellConfigDedicated->downlinkBWP_ToAddModList && - ra->CellGroup->spCellConfig->spCellConfigDedicated->downlinkBWP_ToAddModList->list.array[ra->bwp_id-1]) { - bwp = ra->CellGroup->spCellConfig->spCellConfigDedicated->downlinkBWP_ToAddModList->list.array[ra->bwp_id-1]; + ra->CellGroup->spCellConfig->spCellConfigDedicated->downlinkBWP_ToAddModList->list.array[ra->dl_bwp_id-1]) { + bwp = ra->CellGroup->spCellConfig->spCellConfigDedicated->downlinkBWP_ToAddModList->list.array[ra->dl_bwp_id-1]; genericParameters = &bwp->bwp_Common->genericParameters; pdsch_TimeDomainAllocationList = bwp->bwp_Common->pdsch_ConfigCommon->choice.setup->pdsch_TimeDomainAllocationList; } @@ -1224,6 +1245,7 @@ void nr_generate_Msg2(module_id_t module_idP, int CC_id, frame_t frameP, sub_fra } // Calculate number of symbols + int time_domain_assignment = get_dl_tda(nr_mac, scc, slotP); int startSymbolIndex, nrOfSymbols; const int startSymbolAndLength = pdsch_TimeDomainAllocationList->list.array[time_domain_assignment]->startSymbolAndLength; SLIV2SL(startSymbolAndLength, &startSymbolIndex, &nrOfSymbols); @@ -1363,7 +1385,8 @@ void nr_generate_Msg2(module_id_t module_idP, int CC_id, frame_t frameP, sub_fra nr_mac->common_channels->ServingCellConfigCommon->dmrs_TypeA_Position, nrOfSymbols, startSymbolIndex, - mappingtype, 1); + mappingtype, + 1); uint8_t tb_scaling = 0; int R, Qm; @@ -1398,6 +1421,11 @@ void nr_generate_Msg2(module_id_t module_idP, int CC_id, frame_t frameP, sub_fra pdsch_pdu_rel15->TBSize[0] = TBS; } + int bw_tbslbrm = get_bw_tbslbrm(genericParameters, ra->CellGroup); + pdsch_pdu_rel15->maintenance_parms_v3.tbSizeLbrmBytes = nr_compute_tbslbrm(mcsTableIdx, + bw_tbslbrm, + 1); + // Fill PDCCH DL DCI PDU nfapi_nr_dl_dci_pdu_t *dci_pdu = &pdcch_pdu_rel15->dci_pdu[pdcch_pdu_rel15->numDlDci]; pdcch_pdu_rel15->numDlDci++; @@ -1450,21 +1478,24 @@ void nr_generate_Msg2(module_id_t module_idP, int CC_id, frame_t frameP, sub_fra NR_DL_DCI_FORMAT_1_0, NR_RNTI_RA, BWPSize, - bwpid); + bwpid, + coresetid, + nr_mac->cset0_bwp_size); // DL TX request nfapi_nr_pdu_t *tx_req = &nr_mac->TX_req[CC_id].pdu_list[nr_mac->TX_req[CC_id].Number_of_PDUs]; // Program UL processing for Msg3 NR_BWP_Uplink_t *ubwp = ra->CellGroup ? - ra->CellGroup->spCellConfig->spCellConfigDedicated->uplinkConfig->uplinkBWP_ToAddModList->list.array[ra->bwp_id-1] : + ra->CellGroup->spCellConfig->spCellConfigDedicated->uplinkConfig->uplinkBWP_ToAddModList->list.array[ra->dl_bwp_id-1] : NULL; nr_get_Msg3alloc(module_idP, CC_id, scc, ubwp, slotP, frameP, ra, nr_mac->tdd_beam_association); nr_add_msg3(module_idP, CC_id, frameP, slotP, ra, (uint8_t *) &tx_req->TLVs[0].value.direct[0]); if(ra->cfra) { - LOG_I(NR_MAC, "Frame %d, Subframe %d: Setting RA-Msg3 reception for Frame %d Subframe %d\n", frameP, slotP, ra->Msg3_frame, ra->Msg3_slot); + LOG_D(NR_MAC, "Frame %d, Subframe %d: Setting RA-Msg3 reception (CFRA) for SFN.Slot %d.%d\n", frameP, slotP, ra->Msg3_frame, ra->Msg3_slot); } + else LOG_D(NR_MAC, "Frame %d, Subframe %d: Setting RA-Msg3 reception (CBRA) for SFN.Slot %d.%d\n", frameP, slotP, ra->Msg3_frame, ra->Msg3_slot); T(T_GNB_MAC_DL_RAR_PDU_WITH_DATA, T_INT(module_idP), T_INT(CC_id), T_INT(ra->RA_rnti), T_INT(frameP), T_INT(slotP), T_INT(0), T_BUFFER(&tx_req->TLVs[0].value.direct[0], tx_req->TLVs[0].length)); @@ -1488,7 +1519,7 @@ void nr_generate_Msg2(module_id_t module_idP, int CC_id, frame_t frameP, sub_fra } ra->state = WAIT_Msg3; - LOG_D(NR_MAC,"[gNB %d][RAPROC] Frame %d, Subframe %d: RA state %d\n", module_idP, frameP, slotP, ra->state); + LOG_W(NR_MAC,"[gNB %d][RAPROC] Frame %d, Subframe %d: rnti %04x RA state %d\n", module_idP, frameP, slotP, ra->rnti, ra->state); } } @@ -1513,8 +1544,8 @@ void nr_generate_Msg4(module_id_t module_idP, int CC_id, frame_t frameP, sub_fra ra->CellGroup->spCellConfig && ra->CellGroup->spCellConfig->spCellConfigDedicated && ra->CellGroup->spCellConfig->spCellConfigDedicated->downlinkBWP_ToAddModList && - ra->CellGroup->spCellConfig->spCellConfigDedicated->downlinkBWP_ToAddModList->list.array[ra->bwp_id-1]) { - bwp = ra->CellGroup->spCellConfig->spCellConfigDedicated->downlinkBWP_ToAddModList->list.array[ra->bwp_id-1]; + ra->CellGroup->spCellConfig->spCellConfigDedicated->downlinkBWP_ToAddModList->list.array[ra->dl_bwp_id-1]) { + bwp = ra->CellGroup->spCellConfig->spCellConfigDedicated->downlinkBWP_ToAddModList->list.array[ra->dl_bwp_id-1]; pdsch_TimeDomainAllocationList = bwp->bwp_Common->pdsch_ConfigCommon->choice.setup->pdsch_TimeDomainAllocationList; } else { @@ -1531,9 +1562,14 @@ void nr_generate_Msg4(module_id_t module_idP, int CC_id, frame_t frameP, sub_fra ra->rnti = ra->crnti; } - int UE_id = find_nr_UE_id(module_idP, ra->rnti); - NR_UE_info_t *UE_info = &nr_mac->UE_info; - NR_UE_sched_ctrl_t *sched_ctrl = &UE_info->UE_sched_ctrl[UE_id]; + NR_UE_info_t * UE = find_nr_UE(&nr_mac->UE_info, ra->rnti); + if (!UE) { + LOG_E(NR_MAC,"want to generate Msg4, but rnti %04x not in the table\n", ra->rnti); + return; + } + + LOG_I(NR_MAC,"Generate msg4, rnti: %04x\n", ra->rnti); + NR_UE_sched_ctrl_t *sched_ctrl = &UE->UE_sched_ctrl; NR_BWP_t *genericParameters = bwp ? & bwp->bwp_Common->genericParameters : &scc->downlinkConfigCommon->initialDownlinkBWP->genericParameters; @@ -1566,7 +1602,7 @@ void nr_generate_Msg4(module_id_t module_idP, int CC_id, frame_t frameP, sub_fra // Remove UE associated to TC-RNTI if(harq->round==0 && ra->msg3_dcch_dtch) { - mac_remove_nr_ue(module_idP, tc_rnti); + mac_remove_nr_ue(nr_mac, tc_rnti); } // get CCEindex, needed also for PUCCH and then later for PDCCH @@ -1592,24 +1628,18 @@ void nr_generate_Msg4(module_id_t module_idP, int CC_id, frame_t frameP, sub_fra return; } - int n_rb=0; - for (int i=0;i<6;i++) - for (int j=0;j<8;j++) { - n_rb+=((coreset->frequencyDomainResources.buf[i]>>j)&1); - } - n_rb*=6; - const uint16_t N_cce = n_rb * coreset->duration / NR_NB_REG_PER_CCE; const int delta_PRI=0; - int r_pucch = ((CCEIndex<<1)/N_cce)+(delta_PRI<<1); + int r_pucch = nr_get_pucch_resource(coreset, sched_ctrl->active_ubwp, NULL, CCEIndex); - LOG_D(NR_MAC,"[RAPROC] Msg4 r_pucch %d (CCEIndex %d, N_cce %d, nb_of_candidates %d,delta_PRI %d)\n",r_pucch,CCEIndex,N_cce,nr_of_candidates,delta_PRI); - int alloc = nr_acknack_scheduling(module_idP, UE_id, frameP, slotP, r_pucch, 1); + LOG_D(NR_MAC,"[RAPROC] Msg4 r_pucch %d (CCEIndex %d, nb_of_candidates %d, delta_PRI %d)\n", r_pucch, CCEIndex, nr_of_candidates, delta_PRI); + + int alloc = nr_acknack_scheduling(module_idP, UE, frameP, slotP, r_pucch, 1); AssertFatal(alloc>=0,"Couldn't find a pucch allocation for ack nack (msg4)\n"); NR_sched_pucch_t *pucch = &sched_ctrl->sched_pucch[alloc]; harq->feedback_slot = pucch->ul_slot; harq->feedback_frame = pucch->frame; - uint8_t *buf = (uint8_t *) harq->tb; + uint8_t *buf = (uint8_t *) harq->transportBlock; // Bytes to be transmitted if (harq->round == 0) { if (ra->msg3_dcch_dtch) { @@ -1619,13 +1649,25 @@ void nr_generate_Msg4(module_id_t module_idP, int CC_id, frame_t frameP, sub_fra } else { uint16_t mac_pdu_length = nr_write_ce_dlsch_pdu(module_idP, nr_mac->sched_ctrlCommon, buf, 255, ra->cont_res_id); LOG_D(NR_MAC,"Encoded contention resolution mac_pdu_length %d\n",mac_pdu_length); - uint16_t mac_sdu_length = mac_rrc_nr_data_req(module_idP, CC_id, frameP, CCCH, ra->rnti, 1, &buf[mac_pdu_length+2]); - ((NR_MAC_SUBHEADER_SHORT *) &buf[mac_pdu_length])->R = 0; - ((NR_MAC_SUBHEADER_SHORT *) &buf[mac_pdu_length])->F = 0; - ((NR_MAC_SUBHEADER_SHORT *) &buf[mac_pdu_length])->LCID = DL_SCH_LCID_CCCH; - ((NR_MAC_SUBHEADER_SHORT *) &buf[mac_pdu_length])->L = mac_sdu_length; - ra->mac_pdu_length = mac_pdu_length + mac_sdu_length + sizeof(NR_MAC_SUBHEADER_SHORT); - LOG_D(NR_MAC,"Encoded RRCSetup Piggyback (%d + %d bytes), mac_pdu_length %d\n", mac_sdu_length, (int)sizeof(NR_MAC_SUBHEADER_SHORT), ra->mac_pdu_length); + uint8_t buffer[CCCH_SDU_SIZE]; + uint8_t mac_subheader_len = sizeof(NR_MAC_SUBHEADER_SHORT); + uint16_t mac_sdu_length = mac_rrc_nr_data_req(module_idP, CC_id, frameP, CCCH, ra->rnti, 1, buffer); + if (mac_sdu_length < 256) { + ((NR_MAC_SUBHEADER_SHORT *) &buf[mac_pdu_length])->R = 0; + ((NR_MAC_SUBHEADER_SHORT *) &buf[mac_pdu_length])->F = 0; + ((NR_MAC_SUBHEADER_SHORT *) &buf[mac_pdu_length])->LCID = DL_SCH_LCID_CCCH; + ((NR_MAC_SUBHEADER_SHORT *) &buf[mac_pdu_length])->L = mac_sdu_length; + ra->mac_pdu_length = mac_pdu_length + mac_sdu_length + sizeof(NR_MAC_SUBHEADER_SHORT); + } else { + mac_subheader_len = sizeof(NR_MAC_SUBHEADER_LONG); + ((NR_MAC_SUBHEADER_LONG *) &buf[mac_pdu_length])->R = 0; + ((NR_MAC_SUBHEADER_LONG *) &buf[mac_pdu_length])->F = 1; + ((NR_MAC_SUBHEADER_LONG *) &buf[mac_pdu_length])->LCID = DL_SCH_LCID_CCCH; + ((NR_MAC_SUBHEADER_LONG *) &buf[mac_pdu_length])->L = htons(mac_sdu_length); + ra->mac_pdu_length = mac_pdu_length + mac_sdu_length + sizeof(NR_MAC_SUBHEADER_LONG); + } + LOG_I(NR_MAC,"Encoded RRCSetup Piggyback (%d + %d bytes), mac_pdu_length %d\n", mac_sdu_length, mac_subheader_len, ra->mac_pdu_length); + memcpy(&buf[mac_pdu_length + mac_subheader_len], buffer, mac_sdu_length); } } @@ -1641,7 +1683,8 @@ void nr_generate_Msg4(module_id_t module_idP, int CC_id, frame_t frameP, sub_fra scc->dmrs_TypeA_Position, nrOfSymbols, startSymbolIndex, - mappingtype, 1); + mappingtype, + 1); uint16_t N_DMRS_SLOT = get_num_dmrs(dlDmrsSymbPos); @@ -1682,6 +1725,7 @@ void nr_generate_Msg4(module_id_t module_idP, int CC_id, frame_t frameP, sub_fra int rbSize = 0; uint8_t tb_scaling = 0; uint16_t *vrb_map = cc[CC_id].vrb_map; + // increase PRBs until we get to BWPSize or TBS is bigger than MAC PDU size do { if(rbSize < BWPSize) rbSize++; @@ -1693,6 +1737,8 @@ void nr_generate_Msg4(module_id_t module_idP, int CC_id, frame_t frameP, sub_fra rbSize, nrOfSymbols, N_PRB_DMRS * N_DMRS_SLOT, 0, tb_scaling,1) >> 3; } while (harq->tb_size < ra->mac_pdu_length && mcsIndex<=28); + AssertFatal(harq->tb_size >= ra->mac_pdu_length,"Cannot allocate Msg4\n"); + int i = 0; while ((i < rbSize) && (rbStart + rbSize <= BWPSize)) { if (vrb_map[BWPStart + rbStart + i]&SL_to_bitmap(startSymbolIndex, nrOfSymbols)) { @@ -1753,7 +1799,8 @@ void nr_generate_Msg4(module_id_t module_idP, int CC_id, frame_t frameP, sub_fra pdsch_pdu_rel15->SubcarrierSpacing = genericParameters->subcarrierSpacing; pdsch_pdu_rel15->CyclicPrefix = 0; pdsch_pdu_rel15->NrOfCodewords = 1; - pdsch_pdu_rel15->targetCodeRate[0] = nr_get_code_rate_dl(mcsIndex,mcsTableIdx); + int R = nr_get_code_rate_dl(mcsIndex,mcsTableIdx); + pdsch_pdu_rel15->targetCodeRate[0] = R; pdsch_pdu_rel15->qamModOrder[0] = 2; pdsch_pdu_rel15->mcsIndex[0] = mcsIndex; pdsch_pdu_rel15->mcsTable[0] = mcsTableIdx; @@ -1778,6 +1825,11 @@ void nr_generate_Msg4(module_id_t module_idP, int CC_id, frame_t frameP, sub_fra int x_Overhead = 0; nr_get_tbs_dl(&dl_tti_pdsch_pdu->pdsch_pdu, x_Overhead, pdsch_pdu_rel15->numDmrsCdmGrpsNoData, tb_scaling); + int bw_tbslbrm = get_bw_tbslbrm(genericParameters, ra->CellGroup); + pdsch_pdu_rel15->maintenance_parms_v3.tbSizeLbrmBytes = nr_compute_tbslbrm(mcsTableIdx, + bw_tbslbrm, + 1); + pdsch_pdu_rel15->precodingAndBeamforming.num_prgs=1; pdsch_pdu_rel15->precodingAndBeamforming.prg_size=275; pdsch_pdu_rel15->precodingAndBeamforming.dig_bf_interfaces=1; @@ -1843,7 +1895,9 @@ void nr_generate_Msg4(module_id_t module_idP, int CC_id, frame_t frameP, sub_fra NR_DL_DCI_FORMAT_1_0, NR_RNTI_TC, pdsch_pdu_rel15->BWPSize, - bwpid); + bwpid, + coresetid, + nr_mac->cset0_bwp_size); // Add padding header and zero rest out if there is space left if (ra->mac_pdu_length < harq->tb_size) { @@ -1856,11 +1910,11 @@ void nr_generate_Msg4(module_id_t module_idP, int CC_id, frame_t frameP, sub_fra } T(T_GNB_MAC_DL_PDU_WITH_DATA, T_INT(module_idP), T_INT(CC_id), T_INT(ra->rnti), - T_INT(frameP), T_INT(slotP), T_INT(current_harq_pid), T_BUFFER(harq->tb, harq->tb_size)); + T_INT(frameP), T_INT(slotP), T_INT(current_harq_pid), T_BUFFER(harq->transportBlock, harq->tb_size)); // DL TX request nfapi_nr_pdu_t *tx_req = &nr_mac->TX_req[CC_id].pdu_list[nr_mac->TX_req[CC_id].Number_of_PDUs]; - memcpy(tx_req->TLVs[0].value.direct, harq->tb, sizeof(uint8_t) * harq->tb_size); + memcpy(tx_req->TLVs[0].value.direct, harq->transportBlock, sizeof(uint8_t) * harq->tb_size); tx_req->PDU_length = harq->tb_size; tx_req->PDU_index = pduindex; tx_req->num_TLV = 1; @@ -1896,10 +1950,9 @@ void nr_generate_Msg4(module_id_t module_idP, int CC_id, frame_t frameP, sub_fra if(ra->msg3_dcch_dtch) { // If the UE used MSG3 to transfer a DCCH or DTCH message, then contention resolution is successful upon transmission of PDCCH - LOG_I(NR_MAC, "(ue %i, rnti 0x%04x) CBRA procedure succeeded!\n", UE_id, ra->rnti); + LOG_A(NR_MAC, "(ue rnti 0x%04x) CBRA procedure succeeded!\n", ra->rnti); nr_clear_ra_proc(module_idP, CC_id, frameP, ra); - UE_info->active[UE_id] = true; - UE_info->Msg4_ACKed[UE_id] = true; + UE->Msg4_ACKed = true; remove_front_nr_list(&sched_ctrl->feedback_dl_harq); harq->feedback_slot = -1; @@ -1916,34 +1969,45 @@ void nr_generate_Msg4(module_id_t module_idP, int CC_id, frame_t frameP, sub_fra void nr_check_Msg4_Ack(module_id_t module_id, int CC_id, frame_t frame, sub_frame_t slot, NR_RA_t *ra) { - int UE_id = find_nr_UE_id(module_id, ra->rnti); + NR_UE_info_t * UE = find_nr_UE(&RC.nrmac[module_id]->UE_info, ra->rnti); const int current_harq_pid = ra->harq_pid; - NR_UE_info_t *UE_info = &RC.nrmac[module_id]->UE_info; - NR_UE_sched_ctrl_t *sched_ctrl = &UE_info->UE_sched_ctrl[UE_id]; + NR_UE_sched_ctrl_t *sched_ctrl = &UE->UE_sched_ctrl; NR_UE_harq_t *harq = &sched_ctrl->harq_processes[current_harq_pid]; - NR_mac_stats_t *stats = &UE_info->mac_stats[UE_id]; + NR_mac_stats_t *stats = &UE->mac_stats; - LOG_D(NR_MAC, "ue %d, rnti 0x%04x, harq is waiting %d, round %d, frame %d %d, harq id %d\n", UE_id, ra->rnti, harq->is_waiting, harq->round, frame, slot, current_harq_pid); + LOG_D(NR_MAC, "ue rnti 0x%04x, harq is waiting %d, round %d, frame %d %d, harq id %d\n", ra->rnti, harq->is_waiting, harq->round, frame, slot, current_harq_pid); if (harq->is_waiting == 0) { if (harq->round == 0) { - if (stats->dlsch_errors == 0) { - LOG_A(NR_MAC, "(ue %i, rnti 0x%04x) Received Ack of RA-Msg4. CBRA procedure succeeded!\n", UE_id, ra->rnti); - UE_info->active[UE_id] = true; - UE_info->Msg4_ACKed[UE_id] = true; - } - else { - LOG_I(NR_MAC, "(ue %i, rnti 0x%04x) RA Procedure failed at Msg4!\n", UE_id, ra->rnti); + + if (stats->dl.errors == 0) { + LOG_A(NR_MAC, "(UE RNTI 0x%04x) Received Ack of RA-Msg4. CBRA procedure succeeded!\n", ra->rnti); + UE->Msg4_ACKed = true; + + // Pause scheduling according to: + // 3GPP TS 38.331 Section 12 Table 12.1-1: UE performance requirements for RRC procedures for UEs + const NR_COMMON_channels_t *common_channels = &RC.nrmac[module_id]->common_channels[0]; + const NR_SIB1_t *sib1 = common_channels->sib1 ? common_channels->sib1->message.choice.c1->choice.systemInformationBlockType1 : NULL; + const NR_ServingCellConfig_t *servingCellConfig = UE->CellGroup ? UE->CellGroup->spCellConfig->spCellConfigDedicated : NULL; + NR_BWP_t *genericParameters = get_dl_bwp_genericParameters(sched_ctrl->active_bwp, + common_channels->ServingCellConfigCommon, + sib1); + uint32_t delay_ms = servingCellConfig && servingCellConfig->downlinkBWP_ToAddModList ? + NR_RRC_SETUP_DELAY_MS + NR_RRC_BWP_SWITCHING_DELAY_MS : NR_RRC_SETUP_DELAY_MS; + + sched_ctrl->rrc_processing_timer = (delay_ms << genericParameters->subcarrierSpacing); + LOG_I(NR_MAC, "(%d.%d) Activating RRC processing timer for UE %04x with %d ms\n", frame, slot, UE->rnti, delay_ms); + } else { + LOG_I(NR_MAC, "(ue rnti 0x%04x) RA Procedure failed at Msg4!\n", ra->rnti); } nr_clear_ra_proc(module_id, CC_id, frame, ra); - if(sched_ctrl->retrans_dl_harq.head >= 0) { + if (sched_ctrl->retrans_dl_harq.head >= 0) { remove_nr_list(&sched_ctrl->retrans_dl_harq, current_harq_pid); } - } - else { - LOG_I(NR_MAC, "(ue %i, rnti 0x%04x) Received Nack of RA-Msg4. Preparing retransmission!\n", UE_id, ra->rnti); + } else { + LOG_I(NR_MAC, "(UE %04x) Received Nack of RA-Msg4. Preparing retransmission!\n", ra->rnti); ra->Msg4_frame = (frame + 1) % 1024; ra->Msg4_slot = 1; ra->state = Msg4; @@ -2000,7 +2064,7 @@ void nr_fill_rar(uint8_t Mod_idP, uint8_t * dlsch_buffer, nfapi_nr_pusch_pdu_t *pusch_pdu){ - LOG_I(NR_MAC, "[gNB] Generate RAR MAC PDU frame %d slot %d preamble index %u TA command %d \n", ra->Msg2_frame, ra-> Msg2_slot, ra->preamble_index, ra->timing_offset); + LOG_D(NR_MAC, "[gNB] Generate RAR MAC PDU frame %d slot %d preamble index %u TA command %d \n", ra->Msg2_frame, ra-> Msg2_slot, ra->preamble_index, ra->timing_offset); NR_RA_HEADER_BI *rarbi = (NR_RA_HEADER_BI *) dlsch_buffer; NR_RA_HEADER_RAPID *rarh = (NR_RA_HEADER_RAPID *) (dlsch_buffer + 1); NR_MAC_RAR *rar = (NR_MAC_RAR *) (dlsch_buffer + 2); diff --git a/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_bch.c b/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_bch.c index 7d16a4ee01..e2ceadb889 100644 --- a/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_bch.c +++ b/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_bch.c @@ -411,14 +411,14 @@ uint32_t schedule_control_sib1(module_id_t module_id, gNB_mac->sched_ctrlCommon->sched_pdsch.rbSize = rbSize; gNB_mac->sched_ctrlCommon->sched_pdsch.rbStart = 0; - LOG_D(MAC,"mcs = %i\n", gNB_mac->sched_ctrlCommon->sched_pdsch.mcs); - LOG_D(MAC,"startSymbolIndex = %i\n", startSymbolIndex); - LOG_D(MAC,"nrOfSymbols = %i\n", nrOfSymbols); - LOG_D(MAC, "rbSize = %i\n", gNB_mac->sched_ctrlCommon->sched_pdsch.rbSize); - LOG_D(MAC,"TBS = %i\n", TBS); - LOG_D(MAC,"dmrs_length %d\n",dmrs_length); - LOG_D(MAC,"N_PRB_DMRS = %d\n",N_PRB_DMRS); - LOG_D(MAC,"mappingtype = %d\n", mappingtype); + LOG_D(NR_MAC,"mcs = %i\n", gNB_mac->sched_ctrlCommon->sched_pdsch.mcs); + LOG_D(NR_MAC,"startSymbolIndex = %i\n", startSymbolIndex); + LOG_D(NR_MAC,"nrOfSymbols = %i\n", nrOfSymbols); + LOG_D(NR_MAC, "rbSize = %i\n", gNB_mac->sched_ctrlCommon->sched_pdsch.rbSize); + LOG_D(NR_MAC,"TBS = %i\n", TBS); + LOG_D(NR_MAC,"dmrs_length %d\n",dmrs_length); + LOG_D(NR_MAC,"N_PRB_DMRS = %d\n",N_PRB_DMRS); + LOG_D(NR_MAC,"mappingtype = %d\n", mappingtype); // Mark the corresponding RBs as used fill_pdcch_vrb_map(gNB_mac, CC_id, @@ -426,7 +426,7 @@ uint32_t schedule_control_sib1(module_id_t module_id, gNB_mac->sched_ctrlCommon->cce_index, gNB_mac->sched_ctrlCommon->aggregation_level); for (int rb = 0; rb < gNB_mac->sched_ctrlCommon->sched_pdsch.rbSize; rb++) { - vrb_map[rb + rbStart] = SL_to_bitmap(startSymbolIndex, nrOfSymbols); + vrb_map[rb + rbStart] |= SL_to_bitmap(startSymbolIndex, nrOfSymbols); } return TBS; } @@ -500,7 +500,13 @@ void nr_fill_nfapi_dl_sib1_pdu(int Mod_idP, pdsch_pdu_rel15->StartSymbolIndex = StartSymbolIndex; pdsch_pdu_rel15->NrOfSymbols = NrOfSymbols; pdsch_pdu_rel15->dlDmrsSymbPos = dlDmrsSymbPos; - LOG_D(MAC,"dlDmrsSymbPos = 0x%x\n", pdsch_pdu_rel15->dlDmrsSymbPos); + LOG_D(NR_MAC,"sib1:bwpStart %d, bwpSize %d\n",pdsch_pdu_rel15->BWPStart,pdsch_pdu_rel15->BWPSize); + LOG_D(NR_MAC,"sib1:rbStart %d, rbSize %d\n",pdsch_pdu_rel15->rbStart,pdsch_pdu_rel15->rbSize); + LOG_D(NR_MAC,"sib1:dlDmrsSymbPos = 0x%x\n", pdsch_pdu_rel15->dlDmrsSymbPos); + + pdsch_pdu_rel15->maintenance_parms_v3.tbSizeLbrmBytes = nr_compute_tbslbrm(0, + pdsch_pdu_rel15->BWPSize, + 1); /* Fill PDCCH DL DCI PDU */ nfapi_nr_dl_dci_pdu_t *dci_pdu = &pdcch_pdu_rel15->dci_pdu[pdcch_pdu_rel15->numDlDci]; @@ -545,7 +551,9 @@ void nr_fill_nfapi_dl_sib1_pdu(int Mod_idP, dci_format, rnti_type, pdsch_pdu_rel15->BWPSize, - 0); + 0, + 0, + gNB_mac->cset0_bwp_size); LOG_D(MAC,"BWPSize: %i\n", pdcch_pdu_rel15->BWPSize); LOG_D(MAC,"BWPStart: %i\n", pdcch_pdu_rel15->BWPStart); @@ -620,6 +628,8 @@ void schedule_nr_sib1(module_id_t module_idP, frame_t frameP, sub_frame_t slotP) 1, &is_typeA, &startSymbolIndex, &nrOfSymbols); + AssertFatal((startSymbolIndex+nrOfSymbols)<14,"SIB1 TDA %d would cause overlap with CSI-RS. Please select a different SIB1 TDA.\n",time_domain_allocation); + int mappingtype = is_typeA? typeA: typeB; uint16_t dlDmrsSymbPos = fill_dmrs_mask(NULL, gNB_mac->common_channels->ServingCellConfigCommon->dmrs_TypeA_Position, nrOfSymbols, startSymbolIndex, mappingtype, 1); @@ -640,7 +650,7 @@ void schedule_nr_sib1(module_id_t module_idP, frame_t frameP, sub_frame_t slotP) nfapi_nr_pdu_t *tx_req = &gNB_mac->TX_req[CC_id].pdu_list[ntx_req]; // Data to be transmitted - bzero(tx_req->TLVs[0].value.direct,MAX_NR_DLSCH_PAYLOAD_BYTES); + bzero(tx_req->TLVs[0].value.direct,MAX_NUM_NR_DLSCH_SEGMENTS_PER_LAYER*1056); memcpy(tx_req->TLVs[0].value.direct, sib1_payload, sib1_sdu_length); tx_req->PDU_length = TBS; diff --git a/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_dlsch.c b/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_dlsch.c index f366b2c4f9..3b5c9ffad4 100644 --- a/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_dlsch.c +++ b/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_dlsch.c @@ -53,96 +53,21 @@ #define WORD 32 //#define SIZE_OF_POINTER sizeof (void *) -void calculate_preferred_dl_tda(module_id_t module_id, const NR_BWP_Downlink_t *bwp) -{ - gNB_MAC_INST *nrmac = RC.nrmac[module_id]; - const int bwp_id = bwp ? bwp->bwp_Id : 0; - if (nrmac->preferred_dl_tda[bwp_id]) - return; +const int get_dl_tda(const gNB_MAC_INST *nrmac, const NR_ServingCellConfigCommon_t *scc, int slot) { - /* there is a mixed slot only when in TDD */ - NR_ServingCellConfigCommon_t *scc = nrmac->common_channels->ServingCellConfigCommon; - lte_frame_type_t frame_type = nrmac->common_channels->frame_type; - const int n = nr_slots_per_frame[*scc->ssbSubcarrierSpacing]; - const NR_TDD_UL_DL_Pattern_t *tdd = - scc->tdd_UL_DL_ConfigurationCommon ? &scc->tdd_UL_DL_ConfigurationCommon->pattern1 : NULL; + const NR_TDD_UL_DL_Pattern_t *tdd = scc->tdd_UL_DL_ConfigurationCommon ? &scc->tdd_UL_DL_ConfigurationCommon->pattern1 : NULL; + AssertFatal(tdd || nrmac->common_channels->frame_type == FDD, "Dynamic TDD not handled yet\n"); - int symb_dlMixed = 0; - int nr_mix_slots = 0; - int nr_slots_period = n; - if (tdd) { - symb_dlMixed = (1 << tdd->nrofDownlinkSymbols) - 1; - nr_mix_slots = tdd->nrofDownlinkSymbols != 0 || tdd->nrofUplinkSymbols != 0; - nr_slots_period /= get_nb_periods_per_frame(tdd->dl_UL_TransmissionPeriodicity); - } - else - // if TDD configuration is not present and the band is not FDD, it means it is a dynamic TDD configuration - AssertFatal(nrmac->common_channels->frame_type == FDD,"Dynamic TDD not handled yet\n"); - - int target_ss; - if (bwp) { - target_ss = NR_SearchSpace__searchSpaceType_PR_ue_Specific; - } - else { - target_ss = NR_SearchSpace__searchSpaceType_PR_common; - } - NR_SearchSpace_t *search_space = get_searchspace(scc, bwp ? bwp->bwp_Dedicated : NULL, target_ss); - NR_ControlResourceSet_t *coreset = get_coreset(module_id, scc, bwp ? bwp->bwp_Dedicated : NULL, search_space, target_ss); - // get coreset symbol "map" - const uint16_t symb_coreset = (1 << coreset->duration) - 1; - - /* check that TDA index 0 fits into DL and does not overlap CORESET */ - const struct NR_PDSCH_TimeDomainResourceAllocationList *tdaList = bwp ? - bwp->bwp_Common->pdsch_ConfigCommon->choice.setup->pdsch_TimeDomainAllocationList : - scc->downlinkConfigCommon->initialDownlinkBWP->pdsch_ConfigCommon->choice.setup->pdsch_TimeDomainAllocationList; - AssertFatal(tdaList->list.count >= 1, "need to have at least one TDA for DL slots\n"); - const NR_PDSCH_TimeDomainResourceAllocation_t *tdaP_DL = tdaList->list.array[0]; - AssertFatal(!tdaP_DL->k0 || *tdaP_DL->k0 == 0, - "TimeDomainAllocation at index 1: non-null k0 (%ld) is not supported by the scheduler\n", - *tdaP_DL->k0); - int start, len; - SLIV2SL(tdaP_DL->startSymbolAndLength, &start, &len); - const uint16_t symb_tda = ((1 << len) - 1) << start; - // check whether coreset and TDA overlap: then we cannot use it. Note that - // here we assume that the coreset is scheduled every slot (which it - // currently is) and starting at symbol 0 - AssertFatal((symb_coreset & symb_tda) == 0, "TDA index 0 for DL overlaps with CORESET\n"); - - /* check that TDA index 1 fits into DL part of mixed slot, if it exists */ - int tdaMi = -1; - if (frame_type == TDD && tdaList->list.count > 1) { - const NR_PDSCH_TimeDomainResourceAllocation_t *tdaP_Mi = tdaList->list.array[1]; - AssertFatal(!tdaP_Mi->k0 || *tdaP_Mi->k0 == 0, - "TimeDomainAllocation at index 1: non-null k0 (%ld) is not supported by the scheduler\n", - *tdaP_Mi->k0); - int start, len; - SLIV2SL(tdaP_Mi->startSymbolAndLength, &start, &len); - const uint16_t symb_tda = ((1 << len) - 1) << start; - // check whether coreset and TDA overlap: then, we cannot use it. Also, - // check whether TDA is entirely within mixed slot DL. Note that - // here we assume that the coreset is scheduled every slot (which it - // currently is) - if ((symb_coreset & symb_tda) == 0 && (symb_dlMixed & symb_tda) == symb_tda) { - tdaMi = 1; - } else { - LOG_E(MAC, - "TDA index 1 DL overlaps with CORESET or is not entirely in mixed slot (symb_coreset %x symb_dlMixed %x symb_tda %x), won't schedule DL mixed slot\n", - symb_coreset, - symb_dlMixed, - symb_tda); - } - } - - nrmac->preferred_dl_tda[bwp_id] = malloc(n * sizeof(*nrmac->preferred_dl_tda[bwp_id])); - - for (int i = 0; i < n; ++i) { - nrmac->preferred_dl_tda[bwp_id][i] = -1; - if (frame_type == FDD || i % nr_slots_period < tdd->nrofDownlinkSlots) - nrmac->preferred_dl_tda[bwp_id][i] = 0; - else if (nr_mix_slots && i % nr_slots_period == tdd->nrofDownlinkSlots) - nrmac->preferred_dl_tda[bwp_id][i] = tdaMi; - LOG_D(MAC, "slot %d preferred_dl_tda %d\n", i, nrmac->preferred_dl_tda[bwp_id][i]); + // Use special TDA in case of CSI-RS + if(nrmac->UE_info.sched_csirs) + return 1; + + if (tdd && tdd->nrofDownlinkSymbols > 1) { // if there is a mixed slot where we can transmit DL + const int nr_slots_period = tdd->nrofDownlinkSlots + tdd->nrofUplinkSlots + 1; + if ((slot%nr_slots_period) == tdd->nrofDownlinkSlots) + return 2; } + return 0; // if FDD or not mixed slot in TDD, for now use default TDA (TODO handle CSI-RS slots) } // Compute and write all MAC CEs and subheaders, and return number of written @@ -151,8 +76,7 @@ int nr_write_ce_dlsch_pdu(module_id_t module_idP, const NR_UE_sched_ctrl_t *ue_sched_ctl, unsigned char *mac_pdu, unsigned char drx_cmd, - unsigned char *ue_cont_res_id) -{ + unsigned char *ue_cont_res_id) { gNB_MAC_INST *gNB = RC.nrmac[module_idP]; NR_MAC_SUBHEADER_FIXED *mac_pdu_ptr = (NR_MAC_SUBHEADER_FIXED *) mac_pdu; uint8_t last_size = 0; @@ -195,8 +119,6 @@ int nr_write_ce_dlsch_pdu(module_id_t module_idP, memcpy((void *) mac_pdu_ptr, (void *) ce_ptr, mac_ce_size); ce_ptr += mac_ce_size; mac_pdu_ptr += (unsigned char) mac_ce_size; - - } // Contention resolution fixed subheader and MAC CE @@ -391,156 +313,55 @@ int nr_write_ce_dlsch_pdu(module_id_t module_idP, return offset; } -#define BLER_UPDATE_FRAME 10 -#define BLER_FILTER 0.9f -int get_mcs_from_bler(module_id_t mod_id, int CC_id, frame_t frame, sub_frame_t slot, int UE_id, int mcs_table) -{ - gNB_MAC_INST *nrmac = RC.nrmac[mod_id]; - const NR_ServingCellConfigCommon_t *scc = nrmac->common_channels[CC_id].ServingCellConfigCommon; - const int n = nr_slots_per_frame[*scc->ssbSubcarrierSpacing]; - - int max_allowed_mcs = (mcs_table == 1) ? 27 : 28; - int max_mcs = nrmac->dl_max_mcs; - if (nrmac->dl_max_mcs>max_allowed_mcs) - max_mcs = max_allowed_mcs; - - NR_DL_bler_stats_t *bler_stats = &nrmac->UE_info.UE_sched_ctrl[UE_id].dl_bler_stats; - /* first call: everything is zero. Initialize to sensible default */ - if (bler_stats->last_frame_slot == 0 && bler_stats->mcs == 0) { - bler_stats->last_frame_slot = frame * n + slot; - bler_stats->mcs = 9; - bler_stats->bler = (nrmac->dl_bler_target_lower + nrmac->dl_bler_target_upper) / 2; - bler_stats->rd2_bler = nrmac->dl_rd2_bler_threshold; - } - const int now = frame * n + slot; - int diff = now - bler_stats->last_frame_slot; - if (diff < 0) // wrap around - diff += 1024 * n; - - const uint8_t old_mcs = bler_stats->mcs; - const NR_mac_stats_t *stats = &nrmac->UE_info.mac_stats[UE_id]; - // TODO put back this condition when relevant - /*const int dret3x = stats->dlsch_rounds[3] - bler_stats->dlsch_rounds[3]; - if (dret3x > 0) { - if there is a third retransmission, decrease MCS for stabilization and - restart averaging window to stabilize transmission - bler_stats->last_frame_slot = now; - bler_stats->mcs = max(9, bler_stats->mcs - 1); - memcpy(bler_stats->dlsch_rounds, stats->dlsch_rounds, sizeof(stats->dlsch_rounds)); - LOG_D(MAC, "%4d.%2d: %d retx in 3rd round, setting MCS to %d and restarting window\n", frame, slot, dret3x, bler_stats->mcs); - return bler_stats->mcs; - }*/ - if (diff < BLER_UPDATE_FRAME * n) - return old_mcs; // no update - - // last update is longer than x frames ago - const int dtx = (int)(stats->dlsch_rounds[0] - bler_stats->dlsch_rounds[0]); - const int dretx = (int)(stats->dlsch_rounds[1] - bler_stats->dlsch_rounds[1]); - const int dretx2 = (int)(stats->dlsch_rounds[2] - bler_stats->dlsch_rounds[2]); - const float bler_window = dtx > 0 ? (float) dretx / dtx : bler_stats->bler; - const float rd2_bler_wnd = dtx > 0 ? (float) dretx2 / dtx : bler_stats->rd2_bler; - bler_stats->bler = BLER_FILTER * bler_stats->bler + (1 - BLER_FILTER) * bler_window; - bler_stats->rd2_bler = BLER_FILTER / 4 * bler_stats->rd2_bler + (1 - BLER_FILTER / 4) * rd2_bler_wnd; - - int new_mcs = old_mcs; - // TODO put back this condition when relevant - /* first ensure that number of 2nd retx is below threshold. If this is the - * case, use 1st retx to adjust faster - if (bler_stats->rd2_bler > nrmac->dl_rd2_bler_threshold && old_mcs > 6) { - new_mcs -= 2; - } else if (bler_stats->rd2_bler < nrmac->dl_rd2_bler_threshold) {*/ - if (bler_stats->bler < nrmac->dl_bler_target_lower && old_mcs < max_mcs && dtx > 9) - new_mcs += 1; - else if (bler_stats->bler > nrmac->dl_bler_target_upper && old_mcs > 6) - new_mcs -= 1; - // else we are within threshold boundaries - - - bler_stats->last_frame_slot = now; - bler_stats->mcs = new_mcs; - memcpy(bler_stats->dlsch_rounds, stats->dlsch_rounds, sizeof(stats->dlsch_rounds)); - LOG_D(MAC, "%4d.%2d MCS %d -> %d (dtx %d, dretx %d, BLER wnd %.3f avg %.6f, dretx2 %d, RD2 BLER wnd %.3f avg %.6f)\n", - frame, slot, old_mcs, new_mcs, dtx, dretx, bler_window, bler_stats->bler, dretx2, rd2_bler_wnd, bler_stats->rd2_bler); - return new_mcs; -} - void nr_store_dlsch_buffer(module_id_t module_id, frame_t frame, sub_frame_t slot) { - NR_UE_info_t *UE_info = &RC.nrmac[module_id]->UE_info; - - for (int UE_id = UE_info->list.head; UE_id >= 0; UE_id = UE_info->list.next[UE_id]) { - NR_UE_sched_ctrl_t *sched_ctrl = &UE_info->UE_sched_ctrl[UE_id]; - + UE_iterator(RC.nrmac[module_id]->UE_info.list, UE) { + NR_UE_sched_ctrl_t *sched_ctrl = &UE->UE_sched_ctrl; sched_ctrl->num_total_bytes = 0; + sched_ctrl->dl_pdus_total = 0; - int lcid; - const uint16_t rnti = UE_info->rnti[UE_id]; - LOG_D(NR_MAC,"UE %d/%x : lcid_mask %x\n",UE_id,rnti,sched_ctrl->lcid_mask); - if ((sched_ctrl->lcid_mask&(1<<2)) > 0) - sched_ctrl->rlc_status[DL_SCH_LCID_DCCH1] = mac_rlc_status_ind(module_id, - rnti, - module_id, - frame, - slot, - ENB_FLAG_YES, - MBMS_FLAG_NO, - DL_SCH_LCID_DCCH1, - 0, - 0); - if ((sched_ctrl->lcid_mask&(1<<1)) > 0) - sched_ctrl->rlc_status[DL_SCH_LCID_DCCH] = mac_rlc_status_ind(module_id, + /* loop over all activated logical channels */ + // Note: DL_SCH_LCID_DCCH, DL_SCH_LCID_DCCH1, DL_SCH_LCID_DTCH + for (int i = 0; i < sched_ctrl->dl_lc_num; ++i) { + const int lcid = sched_ctrl->dl_lc_ids[i]; + const uint16_t rnti = UE->rnti; + LOG_D(NR_MAC, "In %s: UE %x: LCID %d\n", __FUNCTION__, rnti, lcid); + if (lcid == DL_SCH_LCID_DTCH && sched_ctrl->rrc_processing_timer > 0) { + continue; + } + start_meas(&RC.nrmac[module_id]->rlc_status_ind); + sched_ctrl->rlc_status[lcid] = mac_rlc_status_ind(module_id, rnti, module_id, frame, slot, ENB_FLAG_YES, MBMS_FLAG_NO, - DL_SCH_LCID_DCCH, + lcid, 0, 0); - if ((sched_ctrl->lcid_mask&(1<<4)) > 0) { - start_meas(&RC.nrmac[module_id]->rlc_status_ind); - sched_ctrl->rlc_status[DL_SCH_LCID_DTCH] = mac_rlc_status_ind(module_id, - rnti, - module_id, - frame, - slot, - ENB_FLAG_YES, - MBMS_FLAG_NO, - DL_SCH_LCID_DTCH, - 0, - 0); - stop_meas(&RC.nrmac[module_id]->rlc_status_ind); - } - if(sched_ctrl->rlc_status[DL_SCH_LCID_DCCH].bytes_in_buffer > 0){ - lcid = DL_SCH_LCID_DCCH; - } - else if (sched_ctrl->rlc_status[DL_SCH_LCID_DCCH1].bytes_in_buffer > 0) - { - lcid = DL_SCH_LCID_DCCH1; - }else{ - lcid = DL_SCH_LCID_DTCH; - } - - sched_ctrl->num_total_bytes += sched_ctrl->rlc_status[lcid].bytes_in_buffer; - //later multiplex here. Just select DCCH/SRB before DTCH/DRB - sched_ctrl->lcid_to_schedule = lcid; + stop_meas(&RC.nrmac[module_id]->rlc_status_ind); - if (sched_ctrl->num_total_bytes == 0 - && !sched_ctrl->ta_apply) /* If TA should be applied, give at least one RB */ - continue; + if (sched_ctrl->rlc_status[lcid].bytes_in_buffer == 0) + continue; - LOG_D(NR_MAC, - "[%s][%d.%d], %s%d->DLSCH, RLC status %d bytes TA %d\n", - __func__, - frame, - slot, - lcid<4?"DCCH":"DTCH", - lcid, - sched_ctrl->rlc_status[lcid].bytes_in_buffer, - sched_ctrl->ta_apply); + sched_ctrl->dl_pdus_total += sched_ctrl->rlc_status[lcid].pdus_in_buffer; + sched_ctrl->num_total_bytes += sched_ctrl->rlc_status[lcid].bytes_in_buffer; + LOG_D(MAC, + "[gNB %d][%4d.%2d] %s%d->DLSCH, RLC status for UE %d: %d bytes in buffer, total DL buffer size = %d bytes, %d total PDU bytes, %s TA command\n", + module_id, + frame, + slot, + lcid < 4 ? "DCCH":"DTCH", + lcid, + UE->rnti, + sched_ctrl->rlc_status[lcid].bytes_in_buffer, + sched_ctrl->num_total_bytes, + sched_ctrl->dl_pdus_total, + sched_ctrl->ta_apply ? "send":"do not send"); + } } } @@ -549,63 +370,96 @@ bool allocate_dl_retransmission(module_id_t module_id, sub_frame_t slot, uint16_t *rballoc_mask, int *n_rb_sched, - int UE_id, + NR_UE_info_t *UE, int current_harq_pid) { - const NR_ServingCellConfigCommon_t *scc = RC.nrmac[module_id]->common_channels->ServingCellConfigCommon; - NR_UE_info_t *UE_info = &RC.nrmac[module_id]->UE_info; - NR_UE_sched_ctrl_t *sched_ctrl = &UE_info->UE_sched_ctrl[UE_id]; + gNB_MAC_INST *nr_mac = RC.nrmac[module_id]; + const NR_ServingCellConfigCommon_t *scc = nr_mac->common_channels->ServingCellConfigCommon; + NR_UE_sched_ctrl_t *sched_ctrl = &UE->UE_sched_ctrl; NR_sched_pdsch_t *retInfo = &sched_ctrl->harq_processes[current_harq_pid].sched_pdsch; - NR_CellGroupConfig_t *cg = UE_info->CellGroup[UE_id]; - NR_BWP_DownlinkDedicated_t *bwpd= cg ? cg->spCellConfig->spCellConfigDedicated->initialDownlinkBWP:NULL; + NR_CellGroupConfig_t *cg = UE->CellGroup; + NR_BWP_DownlinkDedicated_t *bwpd = + cg && + cg->spCellConfig && + cg->spCellConfig->spCellConfigDedicated ? + cg->spCellConfig->spCellConfigDedicated->initialDownlinkBWP : NULL; - NR_BWP_t *genericParameters = sched_ctrl->active_bwp ? - &sched_ctrl->active_bwp->bwp_Common->genericParameters : - &RC.nrmac[module_id]->common_channels[0].ServingCellConfigCommon->downlinkConfigCommon->initialDownlinkBWP->genericParameters; + NR_BWP_UplinkDedicated_t *ubwpd = + cg && + cg->spCellConfig && + cg->spCellConfig->spCellConfigDedicated && + cg->spCellConfig->spCellConfigDedicated->uplinkConfig ? + cg->spCellConfig->spCellConfigDedicated->uplinkConfig->initialUplinkBWP : NULL; + + const NR_SIB1_t *sib1 = RC.nrmac[module_id]->common_channels[0].sib1 ? RC.nrmac[module_id]->common_channels[0].sib1->message.choice.c1->choice.systemInformationBlockType1 : NULL; + NR_BWP_t *genericParameters = get_dl_bwp_genericParameters(sched_ctrl->active_bwp, + RC.nrmac[module_id]->common_channels[0].ServingCellConfigCommon, + sib1); + + const int coresetid = (sched_ctrl->active_bwp||bwpd) ? sched_ctrl->coreset->controlResourceSetId : RC.nrmac[module_id]->sched_ctrlCommon->coreset->controlResourceSetId; + const uint16_t bwpSize = coresetid == 0 ? RC.nrmac[module_id]->cset0_bwp_size : NRRIV2BW(genericParameters->locationAndBandwidth, MAX_BWP_SIZE); - const uint16_t bwpSize = NRRIV2BW(genericParameters->locationAndBandwidth, MAX_BWP_SIZE); int rbStart = 0; // start wrt BWPstart - NR_pdsch_semi_static_t *ps = &sched_ctrl->pdsch_semi_static; - int rbSize = 0; - const int tda = RC.nrmac[module_id]->preferred_dl_tda[sched_ctrl->active_bwp ? sched_ctrl->active_bwp->bwp_Id : 0][slot]; + const int tda = get_dl_tda(RC.nrmac[module_id], scc, slot); AssertFatal(tda>=0,"Unable to find PDSCH time domain allocation in list\n"); + if (tda == retInfo->time_domain_allocation) { /* Check that there are enough resources for retransmission */ while (rbSize < retInfo->rbSize) { rbStart += rbSize; /* last iteration rbSize was not enough, skip it */ rbSize = 0; - while (rbStart < bwpSize && - !(rballoc_mask[rbStart]&SL_to_bitmap(ps->startSymbolIndex, ps->nrOfSymbols))) + + const int slbitmap = SL_to_bitmap(ps->startSymbolIndex, ps->nrOfSymbols); + while (rbStart < bwpSize && (rballoc_mask[rbStart] & slbitmap) != slbitmap) rbStart++; + if (rbStart >= bwpSize) { - LOG_D(NR_MAC, "cannot allocate retransmission for UE %d/RNTI %04x: no resources\n", UE_id, UE_info->rnti[UE_id]); + LOG_D(NR_MAC, "cannot allocate retransmission for RNTI %04x: no resources\n", UE->rnti); return false; } + while (rbStart + rbSize < bwpSize && - (rballoc_mask[rbStart + rbSize]&SL_to_bitmap(ps->startSymbolIndex, ps->nrOfSymbols)) && + (rballoc_mask[rbStart + rbSize] & slbitmap) == slbitmap && rbSize < retInfo->rbSize) rbSize++; } + /* check whether we need to switch the TDA allocation since the last * (re-)transmission */ - if (ps->time_domain_allocation != tda || sched_ctrl->update_pdsch_ps) { - nr_set_pdsch_semi_static(scc, cg, sched_ctrl->active_bwp, bwpd, tda, ps->nrOfLayers, sched_ctrl, ps); - sched_ctrl->update_pdsch_ps = false; + if (ps->time_domain_allocation != tda) { + nr_set_pdsch_semi_static(sib1, + scc, + cg, + sched_ctrl->active_bwp, + bwpd, + tda, + ps->nrOfLayers, + sched_ctrl, + ps); } } else { /* the retransmission will use a different time domain allocation, check * that we have enough resources */ - NR_pdsch_semi_static_t temp_ps = *ps; - nr_set_pdsch_semi_static(scc, UE_info->CellGroup[UE_id], sched_ctrl->active_bwp, bwpd, tda, ps->nrOfLayers, sched_ctrl, &temp_ps); - while (rbStart < bwpSize && - !(rballoc_mask[rbStart]&SL_to_bitmap(temp_ps.startSymbolIndex, temp_ps.nrOfSymbols))) + + nr_set_pdsch_semi_static(sib1, + scc, + cg, + sched_ctrl->active_bwp, + bwpd, + tda, + ps->nrOfLayers, + sched_ctrl, + &temp_ps); + + const uint16_t slbitmap = SL_to_bitmap(temp_ps.startSymbolIndex, temp_ps.nrOfSymbols); + while (rbStart < bwpSize && (rballoc_mask[rbStart] & slbitmap) != slbitmap) rbStart++; - while (rbStart + rbSize < bwpSize && - (rballoc_mask[rbStart + rbSize]&SL_to_bitmap(temp_ps.startSymbolIndex, temp_ps.nrOfSymbols))) + + while (rbStart + rbSize < bwpSize && (rballoc_mask[rbStart + rbSize] & slbitmap) == slbitmap) rbSize++; uint32_t new_tbs; @@ -620,10 +474,12 @@ bool allocate_dl_retransmission(module_id_t module_id, rbSize, &new_tbs, &new_rbSize); + if (!success || new_tbs != retInfo->tb_size) { - LOG_D(MAC, "%s(): new TBsize %d of new TDA does not match old TBS %d\n", __func__, new_tbs, retInfo->tb_size); + LOG_D(MAC, "new TBsize %d of new TDA does not match old TBS %d\n", new_tbs, retInfo->tb_size); return false; /* the maximum TBsize we might have is smaller than what we need */ } + /* we can allocate it. Overwrite the time_domain_allocation, the number * of RBs, and the new TB size. The rest is done below */ retInfo->tb_size = new_tbs; @@ -633,15 +489,17 @@ bool allocate_dl_retransmission(module_id_t module_id, } /* Find a free CCE */ - const int cid = sched_ctrl->coreset->controlResourceSetId; - const uint16_t Y = get_Y(cid%3, slot, UE_info->rnti[UE_id]); + + const uint32_t Y = get_Y(sched_ctrl->search_space, slot, UE->rnti); uint8_t nr_of_candidates; + for (int i=0; i<5; i++) { // for now taking the lowest value among the available aggregation levels find_aggregation_candidates(&sched_ctrl->aggregation_level, &nr_of_candidates, sched_ctrl->search_space, 1<0) break; } @@ -654,105 +512,117 @@ bool allocate_dl_retransmission(module_id_t module_id, Y); if (CCEIndex<0) { - LOG_D(MAC, "%4d.%2d could not find CCE for DL DCI retransmission UE %d/RNTI %04x\n", - frame, slot, UE_id, UE_info->rnti[UE_id]); + LOG_D(MAC, "%4d.%2d could not find CCE for DL DCI retransmission RNTI %04x\n", + frame, slot, UE->rnti); return false; } /* Find PUCCH occasion: if it fails, undo CCE allocation (undoing PUCCH * allocation after CCE alloc fail would be more complex) */ - const int alloc = nr_acknack_scheduling(module_id, UE_id, frame, slot, -1, 0); + + int r_pucch = nr_get_pucch_resource(sched_ctrl->coreset, sched_ctrl->active_ubwp, ubwpd, CCEIndex); + const int alloc = nr_acknack_scheduling(module_id, UE, frame, slot, r_pucch, 0); if (alloc<0) { LOG_D(MAC, - "%s(): could not find PUCCH for UE %d/%04x@%d.%d\n", - __func__, - UE_id, - UE_info->rnti[UE_id], + "could not find PUCCH for UE %04x@%d.%d\n", + UE->rnti, frame, slot); - RC.nrmac[module_id]->pdcch_cand[cid]--; return false; } sched_ctrl->cce_index = CCEIndex; - fill_pdcch_vrb_map(RC.nrmac[module_id], /* CC_id = */ 0, &sched_ctrl->sched_pdcch, CCEIndex, sched_ctrl->aggregation_level); - /* just reuse from previous scheduling opportunity, set new start RB */ sched_ctrl->sched_pdsch = *retInfo; sched_ctrl->sched_pdsch.rbStart = rbStart; - sched_ctrl->sched_pdsch.pucch_allocation = alloc; - /* retransmissions: directly allocate */ *n_rb_sched -= sched_ctrl->sched_pdsch.rbSize; + for (int rb = 0; rb < sched_ctrl->sched_pdsch.rbSize; rb++) - rballoc_mask[rb + sched_ctrl->sched_pdsch.rbStart] -= SL_to_bitmap(ps->startSymbolIndex, ps->nrOfSymbols); + rballoc_mask[rb + sched_ctrl->sched_pdsch.rbStart] ^= SL_to_bitmap(ps->startSymbolIndex, ps->nrOfSymbols); + return true; } -float thr_ue[MAX_MOBILES_PER_GNB]; uint32_t pf_tbs[3][29]; // pre-computed, approximate TBS values for PF coefficient +typedef struct UEsched_s { + float coef; + NR_UE_info_t * UE; +} UEsched_t; + +static int comparator(const void *p, const void *q) { + return ((UEsched_t*)p)->coef < ((UEsched_t*)q)->coef; +} void pf_dl(module_id_t module_id, frame_t frame, sub_frame_t slot, - NR_list_t *UE_list, + NR_UE_info_t **UE_list, int max_num_ue, int n_rb_sched, uint16_t *rballoc_mask) { - gNB_MAC_INST *mac = RC.nrmac[module_id]; - NR_UE_info_t *UE_info = &mac->UE_info; NR_ServingCellConfigCommon_t *scc=mac->common_channels[0].ServingCellConfigCommon; - float coeff_ue[MAX_MOBILES_PER_GNB]; // UEs that could be scheduled - int ue_array[MAX_MOBILES_PER_GNB]; - int layers[MAX_MOBILES_PER_GNB]; - NR_list_t UE_sched = { .head = -1, .next = ue_array, .tail = -1, .len = MAX_MOBILES_PER_GNB }; + UEsched_t UE_sched[MAX_MOBILES_PER_GNB] = {0}; + int remainUEs = max_num_ue; + int curUE = 0; /* Loop UE_info->list to check retransmission */ - for (int UE_id = UE_list->head; UE_id >= 0; UE_id = UE_list->next[UE_id]) { - if (UE_info->Msg4_ACKed[UE_id] != true) continue; - NR_UE_sched_ctrl_t *sched_ctrl = &UE_info->UE_sched_ctrl[UE_id]; + UE_iterator(UE_list, UE) { + if (UE->Msg4_ACKed != true) + continue; + + NR_UE_sched_ctrl_t *sched_ctrl = &UE->UE_sched_ctrl; + if (sched_ctrl->ul_failure==1 && get_softmodem_params()->phy_test==0) continue; + + const NR_mac_dir_stats_t *stats = &UE->mac_stats.dl; NR_sched_pdsch_t *sched_pdsch = &sched_ctrl->sched_pdsch; NR_pdsch_semi_static_t *ps = &sched_ctrl->pdsch_semi_static; /* get the PID of a HARQ process awaiting retrnasmission, or -1 otherwise */ sched_pdsch->dl_harq_pid = sched_ctrl->retrans_dl_harq.head; - - layers[UE_id] = ps->nrOfLayers; // initialization of layers to the previous value in the strcuture - + UE->layers = ps->nrOfLayers; // initialization of layers to the previous value in the structure /* Calculate Throughput */ const float a = 0.0005f; // corresponds to 200ms window - const uint32_t b = UE_info->mac_stats[UE_id].dlsch_current_bytes; - thr_ue[UE_id] = (1 - a) * thr_ue[UE_id] + a * b; + const uint32_t b = UE->mac_stats.dl.current_bytes; + UE->dl_thr_ue = (1 - a) * UE->dl_thr_ue + a * b; /* retransmission */ if (sched_pdsch->dl_harq_pid >= 0) { /* Allocate retransmission */ - bool r = allocate_dl_retransmission( - module_id, frame, slot, rballoc_mask, &n_rb_sched, UE_id, sched_pdsch->dl_harq_pid); + bool r = allocate_dl_retransmission(module_id, frame, slot, rballoc_mask, &n_rb_sched, UE, sched_pdsch->dl_harq_pid); + if (!r) { LOG_D(NR_MAC, "%4d.%2d retransmission can NOT be allocated\n", frame, slot); continue; } + /* reduce max_num_ue once we are sure UE can be allocated, i.e., has CCE */ - max_num_ue--; - if (max_num_ue < 0) return; + remainUEs--; + + // we have filled all with mandatory retransmissions + // no need to schedule new transmissions + if (remainUEs == 0) + return; + } else { /* Check DL buffer and skip this UE if no bytes and no TA necessary */ if (sched_ctrl->num_total_bytes == 0 && frame != (sched_ctrl->ta_frame + 10) % 1024) continue; /* Calculate coeff */ - set_dl_mcs(sched_pdsch,sched_ctrl,&mac->dl_max_mcs,ps->mcsTableIdx); - sched_pdsch->mcs = get_mcs_from_bler(module_id, /* CC_id = */ 0, frame, slot, UE_id, ps->mcsTableIdx); - layers[UE_id] = set_dl_nrOfLayers(sched_ctrl); + const NR_bler_options_t *bo = &mac->dl_bler; + const int max_mcs_table = ps->mcsTableIdx == 1 ? 27 : 28; + const int max_mcs = min(sched_ctrl->dl_max_mcs, max_mcs_table); + sched_pdsch->mcs = get_mcs_from_bler(bo, stats, &sched_ctrl->dl_bler_stats, max_mcs, frame); + UE->layers = set_dl_nrOfLayers(sched_ctrl); const uint8_t Qm = nr_get_Qm_dl(sched_pdsch->mcs, ps->mcsTableIdx); const uint16_t R = nr_get_code_rate_dl(sched_pdsch->mcs, ps->mcsTableIdx); uint32_t tbs = nr_compute_tbs(Qm, @@ -762,62 +632,75 @@ void pf_dl(module_id_t module_id, 0, /* N_PRB_DMRS * N_DMRS_SLOT */ 0 /* N_PRB_oh, 0 for initialBWP */, 0 /* tb_scaling */, - layers[UE_id]) >> 3; - coeff_ue[UE_id] = (float) tbs / thr_ue[UE_id]; - LOG_D(NR_MAC,"b %d, thr_ue[%d] %f, tbs %d, coeff_ue[%d] %f\n", - b, UE_id, thr_ue[UE_id], tbs, UE_id, coeff_ue[UE_id]); + UE->layers) >> 3; + float coeff_ue = (float) tbs / UE->dl_thr_ue; + LOG_D(NR_MAC,"UE %04x b %d, thr_ue %f, tbs %d, coeff_ue %f\n", + UE->rnti, b, UE->dl_thr_ue, tbs, coeff_ue); /* Create UE_sched list for UEs eligible for new transmission*/ - add_tail_nr_list(&UE_sched, UE_id); + UE_sched[curUE].coef=coeff_ue; + UE_sched[curUE].UE=UE; + curUE++; } } + qsort(UE_sched, sizeof(*UE_sched), sizeofArray(UE_sched), comparator); + UEsched_t *iterator = UE_sched; + const int min_rbSize = 5; + /* Loop UE_sched to find max coeff and allocate transmission */ - while (max_num_ue > 0 && n_rb_sched >= min_rbSize && UE_sched.head >= 0) { + while (remainUEs> 0 && n_rb_sched >= min_rbSize && iterator->UE != NULL) { - /* Find max coeff from UE_sched*/ - int *max = &UE_sched.head; /* assume head is max */ - int *p = &UE_sched.next[*max]; - while (*p >= 0) { - /* if the current one has larger coeff, save for later */ - if (coeff_ue[*p] > coeff_ue[*max]) - max = p; - p = &UE_sched.next[*p]; - } - /* remove the max one: do not use remove_nr_list() it goes through the - * whole list every time. Note that UE_sched.tail might not be set - * correctly anymore */ - const int UE_id = *max; - p = &UE_sched.next[*max]; - *max = UE_sched.next[*max]; - *p = -1; - NR_CellGroupConfig_t *cg = UE_info->CellGroup[UE_id]; - NR_BWP_DownlinkDedicated_t *bwpd= cg ? cg->spCellConfig->spCellConfigDedicated->initialDownlinkBWP:NULL; + NR_CellGroupConfig_t *cg = iterator->UE->CellGroup; - NR_UE_sched_ctrl_t *sched_ctrl = &UE_info->UE_sched_ctrl[UE_id]; - const uint16_t rnti = UE_info->rnti[UE_id]; - NR_BWP_t *genericParameters = sched_ctrl->active_bwp ? - &sched_ctrl->active_bwp->bwp_Common->genericParameters: - &scc->downlinkConfigCommon->initialDownlinkBWP->genericParameters; + NR_BWP_DownlinkDedicated_t *bwpd = + cg && + cg->spCellConfig && + cg->spCellConfig->spCellConfigDedicated ? + cg->spCellConfig->spCellConfigDedicated->initialDownlinkBWP : NULL; - const uint16_t bwpSize = NRRIV2BW(genericParameters->locationAndBandwidth,MAX_BWP_SIZE); + NR_BWP_UplinkDedicated_t *ubwpd = + cg && + cg->spCellConfig && + cg->spCellConfig->spCellConfigDedicated && + cg->spCellConfig->spCellConfigDedicated->uplinkConfig ? + cg->spCellConfig->spCellConfigDedicated->uplinkConfig->initialUplinkBWP : NULL; + + NR_UE_sched_ctrl_t *sched_ctrl = &iterator->UE->UE_sched_ctrl; + const uint16_t rnti = iterator->UE->rnti; + const NR_SIB1_t *sib1 = RC.nrmac[module_id]->common_channels[0].sib1 ? + RC.nrmac[module_id]->common_channels[0].sib1->message.choice.c1->choice.systemInformationBlockType1 : + NULL; + + NR_BWP_t *genericParameters = get_dl_bwp_genericParameters(sched_ctrl->active_bwp, + RC.nrmac[module_id]->common_channels[0].ServingCellConfigCommon, + sib1); + + const int coresetid = (sched_ctrl->active_bwp||bwpd) ? + sched_ctrl->coreset->controlResourceSetId : + RC.nrmac[module_id]->sched_ctrlCommon->coreset->controlResourceSetId; + const uint16_t bwpSize = coresetid == 0 ? + RC.nrmac[module_id]->cset0_bwp_size : + NRRIV2BW(genericParameters->locationAndBandwidth, MAX_BWP_SIZE); int rbStart = 0; // start wrt BWPstart if (sched_ctrl->available_dl_harq.head < 0) { - LOG_D(MAC, "UE %d RNTI %04x has no free HARQ process, skipping\n", UE_id, UE_info->rnti[UE_id]); + LOG_D(MAC, "RNTI %04x has no free HARQ process, skipping\n", iterator->UE->rnti); + iterator++; continue; } /* Find a free CCE */ - const int cid = sched_ctrl->coreset->controlResourceSetId; - const uint16_t Y = get_Y(cid%3, slot, UE_info->rnti[UE_id]); + const uint32_t Y = get_Y(sched_ctrl->search_space, slot, iterator->UE->rnti); uint8_t nr_of_candidates; + for (int i=0; i<5; i++) { // for now taking the lowest value among the available aggregation levels find_aggregation_candidates(&sched_ctrl->aggregation_level, &nr_of_candidates, sched_ctrl->search_space, 1<0) break; } @@ -830,32 +713,28 @@ void pf_dl(module_id_t module_id, Y); if (CCEIndex<0) { - LOG_D(NR_MAC, "%4d.%2d could not find CCE for DL DCI UE %d/RNTI %04x\n", frame, slot, UE_id, rnti); + LOG_D(NR_MAC, "%4d.%2d could not find CCE for DL DCI RNTI %04x\n", frame, slot, rnti); + iterator++; continue; } /* Find PUCCH occasion: if it fails, undo CCE allocation (undoing PUCCH * allocation after CCE alloc fail would be more complex) */ - const int alloc = nr_acknack_scheduling(module_id, UE_id, frame, slot, -1, 0); + + int r_pucch = nr_get_pucch_resource(sched_ctrl->coreset, sched_ctrl->active_ubwp, ubwpd, CCEIndex); + const int alloc = nr_acknack_scheduling(module_id, iterator->UE, frame, slot, r_pucch, 0); + if (alloc<0) { LOG_D(NR_MAC, - "%s(): could not find PUCCH for UE %d/%04x@%d.%d\n", - __func__, - UE_id, + "could not find PUCCH for %04x@%d.%d\n", rnti, frame, slot); - mac->pdcch_cand[cid]--; + iterator++; continue; } - /* reduce max_num_ue once we are sure UE can be allocated, i.e., has CCE - * and PUCCH */ - max_num_ue--; - AssertFatal(max_num_ue >= 0, "Illegal max_num_ue %d\n", max_num_ue); - sched_ctrl->cce_index = CCEIndex; - fill_pdcch_vrb_map(mac, /* CC_id = */ 0, &sched_ctrl->sched_pdcch, @@ -863,28 +742,32 @@ void pf_dl(module_id_t module_id, sched_ctrl->aggregation_level); /* MCS has been set above */ - - const int tda = RC.nrmac[module_id]->preferred_dl_tda[sched_ctrl->active_bwp ? sched_ctrl->active_bwp->bwp_Id : 0][slot]; + const int tda = get_dl_tda(RC.nrmac[module_id], scc, slot); AssertFatal(tda>=0,"Unable to find PDSCH time domain allocation in list\n"); NR_sched_pdsch_t *sched_pdsch = &sched_ctrl->sched_pdsch; NR_pdsch_semi_static_t *ps = &sched_ctrl->pdsch_semi_static; - if (ps->nrOfLayers != layers[UE_id] || - ps->time_domain_allocation != tda || - sched_ctrl->update_pdsch_ps) { - nr_set_pdsch_semi_static(scc, UE_info->CellGroup[UE_id], sched_ctrl->active_bwp, bwpd, tda, layers[UE_id], sched_ctrl, ps); - sched_ctrl->update_pdsch_ps = false; + if (ps->nrOfLayers != iterator->UE->layers || ps->time_domain_allocation != tda ) { + nr_set_pdsch_semi_static(sib1, + scc, + iterator->UE->CellGroup, + sched_ctrl->active_bwp, + bwpd, + tda, + iterator->UE->layers, + sched_ctrl, + ps); } const uint16_t slbitmap = SL_to_bitmap(ps->startSymbolIndex, ps->nrOfSymbols); + // Freq-demain allocation - while (rbStart < bwpSize && - !(rballoc_mask[rbStart]&slbitmap)) + while (rbStart < bwpSize && (rballoc_mask[rbStart] & slbitmap) != slbitmap) rbStart++; uint16_t max_rbSize = 1; - while (rbStart + max_rbSize < bwpSize && - (rballoc_mask[rbStart + max_rbSize]&slbitmap)) + + while (rbStart + max_rbSize < bwpSize && (rballoc_mask[rbStart + max_rbSize] & slbitmap) == slbitmap) max_rbSize++; sched_pdsch->Qm = nr_get_Qm_dl(sched_pdsch->mcs, ps->mcsTableIdx); @@ -892,7 +775,12 @@ void pf_dl(module_id_t module_id, sched_pdsch->pucch_allocation = alloc; uint32_t TBS = 0; uint16_t rbSize; - const int oh = 3 + 2 * (frame == (sched_ctrl->ta_frame + 10) % 1024); + // Fix me: currently, the RLC does not give us the total number of PDUs + // awaiting. Therefore, for the time being, we put a fixed overhead of 12 + // (for 4 PDUs) and optionally + 2 for TA. Once RLC gives the number of + // PDUs, we replace with 3 * numPDUs + const int oh = 3 * 4 + 2 * (frame == (sched_ctrl->ta_frame + 10) % 1024); + //const int oh = 3 * sched_ctrl->dl_pdus_total + 2 * (frame == (sched_ctrl->ta_frame + 10) % 1024); nr_find_nb_rb(sched_pdsch->Qm, sched_pdsch->R, ps->nrOfLayers, @@ -906,77 +794,83 @@ void pf_dl(module_id_t module_id, sched_pdsch->rbSize = rbSize; sched_pdsch->rbStart = rbStart; sched_pdsch->tb_size = TBS; - /* transmissions: directly allocate */ n_rb_sched -= sched_pdsch->rbSize; + for (int rb = 0; rb < sched_pdsch->rbSize; rb++) - rballoc_mask[rb + sched_pdsch->rbStart] -= slbitmap; + rballoc_mask[rb + sched_pdsch->rbStart] ^= slbitmap; + + remainUEs--; + iterator++; } } -void nr_fr1_dlsch_preprocessor(module_id_t module_id, frame_t frame, sub_frame_t slot) -{ - NR_UE_info_t *UE_info = &RC.nrmac[module_id]->UE_info; - if (UE_info->num_UEs == 0) +void nr_fr1_dlsch_preprocessor(module_id_t module_id, frame_t frame, sub_frame_t slot) { + NR_UEs_t *UE_info = &RC.nrmac[module_id]->UE_info; + + if (UE_info->list[0] == NULL) return; NR_ServingCellConfigCommon_t *scc = RC.nrmac[module_id]->common_channels[0].ServingCellConfigCommon; const int CC_id = 0; - /* Get bwpSize and TDAfrom the first UE */ /* This is temporary and it assumes all UEs have the same BWP and TDA*/ - int UE_id = UE_info->list.head; - NR_UE_sched_ctrl_t *sched_ctrl = &UE_info->UE_sched_ctrl[UE_id]; - const int bwp_id = sched_ctrl->active_bwp ? sched_ctrl->active_bwp->bwp_Id : 0; - if (!RC.nrmac[module_id]->preferred_dl_tda[bwp_id]) - return; - const int tda = RC.nrmac[module_id]->preferred_dl_tda[bwp_id][slot]; + NR_UE_info_t *UE=UE_info->list[0]; + NR_UE_sched_ctrl_t *sched_ctrl = &UE->UE_sched_ctrl; + const int tda = get_dl_tda(RC.nrmac[module_id], scc, slot); int startSymbolIndex, nrOfSymbols; const struct NR_PDSCH_TimeDomainResourceAllocationList *tdaList = sched_ctrl->active_bwp ? - sched_ctrl->active_bwp->bwp_Common->pdsch_ConfigCommon->choice.setup->pdsch_TimeDomainAllocationList : - scc->downlinkConfigCommon->initialDownlinkBWP->pdsch_ConfigCommon->choice.setup->pdsch_TimeDomainAllocationList; + sched_ctrl->active_bwp->bwp_Common->pdsch_ConfigCommon->choice.setup->pdsch_TimeDomainAllocationList : + scc->downlinkConfigCommon->initialDownlinkBWP->pdsch_ConfigCommon->choice.setup->pdsch_TimeDomainAllocationList; AssertFatal(tda < tdaList->list.count, "time_domain_allocation %d>=%d\n", tda, tdaList->list.count); const int startSymbolAndLength = tdaList->list.array[tda]->startSymbolAndLength; SLIV2SL(startSymbolAndLength, &startSymbolIndex, &nrOfSymbols); - const uint16_t bwpSize = NRRIV2BW(sched_ctrl->active_bwp ? - sched_ctrl->active_bwp->bwp_Common->genericParameters.locationAndBandwidth: - scc->downlinkConfigCommon->initialDownlinkBWP->genericParameters.locationAndBandwidth, - MAX_BWP_SIZE); - const uint16_t BWPStart = NRRIV2PRBOFFSET(sched_ctrl->active_bwp ? - sched_ctrl->active_bwp->bwp_Common->genericParameters.locationAndBandwidth: - scc->downlinkConfigCommon->initialDownlinkBWP->genericParameters.locationAndBandwidth, - MAX_BWP_SIZE); + const NR_SIB1_t *sib1 = RC.nrmac[module_id]->common_channels[0].sib1 ? RC.nrmac[module_id]->common_channels[0].sib1->message.choice.c1->choice.systemInformationBlockType1 : NULL; + NR_BWP_t *genericParameters = get_dl_bwp_genericParameters(sched_ctrl->active_bwp, + RC.nrmac[module_id]->common_channels[0].ServingCellConfigCommon, + sib1); + + NR_BWP_DownlinkDedicated_t *bwpd = + UE->CellGroup && + UE->CellGroup->spCellConfig && + UE->CellGroup->spCellConfig->spCellConfigDedicated ? + UE->CellGroup->spCellConfig->spCellConfigDedicated->initialDownlinkBWP : NULL; + + const int coresetid = (sched_ctrl->active_bwp||bwpd) ? sched_ctrl->coreset->controlResourceSetId : RC.nrmac[module_id]->sched_ctrlCommon->coreset->controlResourceSetId; + + const uint16_t bwpSize = coresetid == 0 ? RC.nrmac[module_id]->cset0_bwp_size : NRRIV2BW(genericParameters->locationAndBandwidth,MAX_BWP_SIZE); + const uint16_t BWPStart = coresetid == 0 ? RC.nrmac[module_id]->cset0_bwp_start : NRRIV2PRBOFFSET(genericParameters->locationAndBandwidth,MAX_BWP_SIZE); const uint16_t slbitmap = SL_to_bitmap(startSymbolIndex, nrOfSymbols); uint16_t *vrb_map = RC.nrmac[module_id]->common_channels[CC_id].vrb_map; uint16_t rballoc_mask[bwpSize]; int n_rb_sched = 0; + for (int i = 0; i < bwpSize; i++) { // calculate mask: init with "NOT" vrb_map: // if any RB in vrb_map is blocked (1), the current RBG will be 0 rballoc_mask[i] = (~vrb_map[i+BWPStart])&0x3fff; //bitwise not and 14 symbols + // if all the pdsch symbols are free - if((rballoc_mask[i]&slbitmap) == - slbitmap) + if ((rballoc_mask[i]&slbitmap) == slbitmap) { n_rb_sched++; + } } /* Retrieve amount of data to send for this UE */ nr_store_dlsch_buffer(module_id, frame, slot); - /* proportional fair scheduling algorithm */ pf_dl(module_id, frame, slot, - &UE_info->list, + UE_info->list, MAX_MOBILES_PER_GNB, n_rb_sched, rballoc_mask); } -nr_pp_impl_dl nr_init_fr1_dlsch_preprocessor(module_id_t module_id, int CC_id) -{ +nr_pp_impl_dl nr_init_fr1_dlsch_preprocessor(module_id_t module_id, int CC_id) { /* in the PF algorithm, we have to use the TBsize to compute the coefficient. * This would include the number of DMRS symbols, which in turn depends on * the time domain allocation. In case we are in a mixed slot, we do not want @@ -986,6 +880,7 @@ nr_pp_impl_dl nr_init_fr1_dlsch_preprocessor(module_id_t module_id, int CC_id) for (int mcs = 0; mcs < 29; ++mcs) { if (mcs > 27 && mcsTableIdx == 1) continue; + const uint8_t Qm = nr_get_Qm_dl(mcs, mcsTableIdx); const uint16_t R = nr_get_code_rate_dl(mcs, mcsTableIdx); pf_tbs[mcsTableIdx][mcs] = nr_compute_tbs(Qm, @@ -995,8 +890,7 @@ nr_pp_impl_dl nr_init_fr1_dlsch_preprocessor(module_id_t module_id, int CC_id) 0, /* N_PRB_DMRS * N_DMRS_SLOT */ 0 /* N_PRB_oh, 0 for initialBWP */, 0 /* tb_scaling */, - 1 /* nrOfLayers */) - >> 3; + 1 /* nrOfLayers */) >> 3; } } @@ -1007,59 +901,64 @@ void nr_schedule_ue_spec(module_id_t module_id, frame_t frame, sub_frame_t slot) { gNB_MAC_INST *gNB_mac = RC.nrmac[module_id]; + if (!is_xlsch_in_slot(gNB_mac->dlsch_slot_bitmap[slot / 64], slot)) return; + //if (slot==7 || slot == 17) return; + /* PREPROCESSOR */ gNB_mac->pre_processor_dl(module_id, frame, slot); - const int CC_id = 0; NR_ServingCellConfigCommon_t *scc = gNB_mac->common_channels[CC_id].ServingCellConfigCommon; - NR_UE_info_t *UE_info = &gNB_mac->UE_info; - + NR_UEs_t *UE_info = &gNB_mac->UE_info; nfapi_nr_dl_tti_request_body_t *dl_req = &gNB_mac->DL_req[CC_id].dl_tti_request_body; - NR_list_t *UE_list = &UE_info->list; - for (int UE_id = UE_list->head; UE_id >= 0; UE_id = UE_list->next[UE_id]) { - NR_UE_sched_ctrl_t *sched_ctrl = &UE_info->UE_sched_ctrl[UE_id]; + UE_iterator(UE_info->list, UE) { + NR_UE_sched_ctrl_t *sched_ctrl = &UE->UE_sched_ctrl; + if (sched_ctrl->ul_failure==1 && get_softmodem_params()->phy_test==0) continue; + NR_sched_pdsch_t *sched_pdsch = &sched_ctrl->sched_pdsch; - UE_info->mac_stats[UE_id].dlsch_current_bytes = 0; - NR_CellGroupConfig_t *cg = UE_info->CellGroup[UE_id]; - NR_BWP_DownlinkDedicated_t *bwpd= cg ? cg->spCellConfig->spCellConfigDedicated->initialDownlinkBWP:NULL; + UE->mac_stats.dl.current_bytes = 0; + NR_CellGroupConfig_t *cg = UE->CellGroup; + + NR_BWP_DownlinkDedicated_t *bwpd = + cg && + cg->spCellConfig && + cg->spCellConfig->spCellConfigDedicated ? + cg->spCellConfig->spCellConfigDedicated->initialDownlinkBWP : NULL; /* update TA and set ta_apply every 10 frames. * Possible improvement: take the periodicity from input file. * If such UE is not scheduled now, it will be by the preprocessor later. * If we add the CE, ta_apply will be reset */ - if (frame == (sched_ctrl->ta_frame + 10) % 1024){ + if (frame == (sched_ctrl->ta_frame + 10) % 1024) { sched_ctrl->ta_apply = true; /* the timer is reset once TA CE is scheduled */ - LOG_D(NR_MAC, "[UE %d][%d.%d] UL timing alignment procedures: setting flag for Timing Advance command\n", UE_id, frame, slot); + LOG_D(NR_MAC, "[UE %04x][%d.%d] UL timing alignment procedures: setting flag for Timing Advance command\n", UE->rnti, frame, slot); } if (sched_pdsch->rbSize <= 0) continue; - const rnti_t rnti = UE_info->rnti[UE_id]; - + const rnti_t rnti = UE->rnti; /* pre-computed PDSCH values that only change if time domain * allocation/DMRS parameters change. Updated in the preprocessor through * nr_set_pdsch_semi_static() */ NR_pdsch_semi_static_t *ps = &sched_ctrl->pdsch_semi_static; - /* POST processing */ const uint8_t nrOfLayers = ps->nrOfLayers; const uint16_t R = sched_pdsch->R; const uint8_t Qm = sched_pdsch->Qm; const uint32_t TBS = sched_pdsch->tb_size; - int8_t current_harq_pid = sched_pdsch->dl_harq_pid; + if (current_harq_pid < 0) { /* PP has not selected a specific HARQ Process, get a new one */ current_harq_pid = sched_ctrl->available_dl_harq.head; AssertFatal(current_harq_pid >= 0, - "no free HARQ process available for UE %d\n", - UE_id); + "no free HARQ process available for UE %04x\n", + UE->rnti); remove_front_nr_list(&sched_ctrl->available_dl_harq); sched_pdsch->dl_harq_pid = current_harq_pid; } else { @@ -1071,6 +970,7 @@ void nr_schedule_ue_spec(module_id_t module_id, else remove_nr_list(&sched_ctrl->retrans_dl_harq, current_harq_pid); } + NR_UE_harq_t *harq = &sched_ctrl->harq_processes[current_harq_pid]; DevAssert(!harq->is_waiting); add_tail_nr_list(&sched_ctrl->feedback_dl_harq, current_harq_pid); @@ -1078,12 +978,11 @@ void nr_schedule_ue_spec(module_id_t module_id, harq->feedback_frame = pucch->frame; harq->feedback_slot = pucch->ul_slot; harq->is_waiting = true; - UE_info->mac_stats[UE_id].dlsch_rounds[harq->round]++; - - LOG_D(NR_MAC,"%4d.%2d [DLSCH/PDSCH/PUCCH] UE %d RNTI %04x DCI L %d start %3d RBs %3d startSymbol %2d nb_symbol %2d dmrspos %x MCS %2d nrOfLayers %d TBS %4d HARQ PID %2d round %d RV %d NDI %d dl_data_to_ULACK %d (%d.%d) PUCCH allocation %d TPC %d\n", + UE->mac_stats.dl.rounds[harq->round]++; + LOG_D(NR_MAC, + "%4d.%2d [DLSCH/PDSCH/PUCCH] RNTI %04x DCI L %d start %3d RBs %3d startSymbol %2d nb_symbol %2d dmrspos %x MCS %2d nrOfLayers %d TBS %4d HARQ PID %2d round %d RV %d NDI %d dl_data_to_ULACK %d (%d.%d) PUCCH allocation %d TPC %d\n", frame, slot, - UE_id, rnti, sched_ctrl->aggregation_level, sched_pdsch->rbStart, @@ -1103,18 +1002,21 @@ void nr_schedule_ue_spec(module_id_t module_id, pucch->ul_slot, sched_pdsch->pucch_allocation, sched_ctrl->tpc1); - NR_BWP_Downlink_t *bwp = sched_ctrl->active_bwp; - /* look up the PDCCH PDU for this CC, BWP, and CORESET. If it does not - * exist, create it */ + const NR_SIB1_t *sib1 = RC.nrmac[module_id]->common_channels[0].sib1 ? RC.nrmac[module_id]->common_channels[0].sib1->message.choice.c1->choice.systemInformationBlockType1 : NULL; + NR_BWP_t *genericParameters = get_dl_bwp_genericParameters(bwp, + RC.nrmac[module_id]->common_channels[0].ServingCellConfigCommon, + sib1); - // BWP - NR_BWP_t *genericParameters = bwp ? &bwp->bwp_Common->genericParameters : &scc->downlinkConfigCommon->initialDownlinkBWP->genericParameters; + NR_SearchSpace_t *ss = (bwp||bwpd) ? sched_ctrl->search_space : gNB_mac->sched_ctrlCommon->search_space; - const int bwpid = bwp ? bwp->bwp_Id : 0; + const int bwp_id = bwp ? bwp->bwp_Id : 0; const int coresetid = (bwp||bwpd) ? sched_ctrl->coreset->controlResourceSetId : gNB_mac->sched_ctrlCommon->coreset->controlResourceSetId; + + /* look up the PDCCH PDU for this CC, BWP, and CORESET. If it does not exist, create it */ nfapi_nr_dl_tti_pdcch_pdu_rel15_t *pdcch_pdu = gNB_mac->pdcch_pdu_idx[CC_id][coresetid]; + if (!pdcch_pdu) { LOG_D(NR_MAC, "creating pdcch pdu, pdcch_pdu = NULL. \n"); nfapi_nr_dl_tti_request_pdu_t *dl_tti_pdcch_pdu = &dl_req->dl_tti_pdu_list[dl_req->nPDUs]; @@ -1123,7 +1025,7 @@ void nr_schedule_ue_spec(module_id_t module_id, dl_tti_pdcch_pdu->PDUSize = (uint8_t)(2+sizeof(nfapi_nr_dl_tti_pdcch_pdu)); dl_req->nPDUs += 1; pdcch_pdu = &dl_tti_pdcch_pdu->pdcch_pdu.pdcch_pdu_rel15; - LOG_D(NR_MAC,"Trying to configure DL pdcch for UE %d, bwp %d, cs %d\n",UE_id,bwpid,coresetid); + LOG_D(NR_MAC,"Trying to configure DL pdcch for UE %04x, bwp %d, cs %d\n", UE->rnti, bwp_id, coresetid); NR_ControlResourceSet_t *coreset = (bwp||bwpd)? sched_ctrl->coreset:gNB_mac->sched_ctrlCommon->coreset; nr_configure_pdcch(pdcch_pdu, coreset, genericParameters, &sched_ctrl->sched_pdcch); gNB_mac->pdcch_pdu_idx[CC_id][coresetid] = pdcch_pdu; @@ -1135,7 +1037,6 @@ void nr_schedule_ue_spec(module_id_t module_id, dl_tti_pdsch_pdu->PDUSize = (uint8_t)(2+sizeof(nfapi_nr_dl_tti_pdsch_pdu)); dl_req->nPDUs += 1; nfapi_nr_dl_tti_pdsch_pdu_rel15_t *pdsch_pdu = &dl_tti_pdsch_pdu->pdsch_pdu.pdsch_pdu_rel15; - pdsch_pdu->pduBitmap = 0; pdsch_pdu->rnti = rnti; /* SCF222: PDU index incremented for each PDSCH PDU sent in TX control @@ -1144,14 +1045,19 @@ void nr_schedule_ue_spec(module_id_t module_id, const int pduindex = gNB_mac->pdu_index[CC_id]++; pdsch_pdu->pduIndex = pduindex; - pdsch_pdu->BWPSize = NRRIV2BW(genericParameters->locationAndBandwidth, MAX_BWP_SIZE); - pdsch_pdu->BWPStart = NRRIV2PRBOFFSET(genericParameters->locationAndBandwidth,MAX_BWP_SIZE); + if (coresetid == 0) { + pdsch_pdu->BWPSize = gNB_mac->cset0_bwp_size; + pdsch_pdu->BWPStart = gNB_mac->cset0_bwp_start; + } else { + pdsch_pdu->BWPSize = NRRIV2BW(genericParameters->locationAndBandwidth, MAX_BWP_SIZE); + pdsch_pdu->BWPStart = NRRIV2PRBOFFSET(genericParameters->locationAndBandwidth,MAX_BWP_SIZE); + } + pdsch_pdu->SubcarrierSpacing = genericParameters->subcarrierSpacing; - pdsch_pdu->CyclicPrefix = genericParameters->cyclicPrefix ? *genericParameters->cyclicPrefix : 0; - // Codeword information pdsch_pdu->NrOfCodewords = 1; + //number of information bits per 1024 coded bits expressed in 0.1 bit units pdsch_pdu->targetCodeRate[0] = R; pdsch_pdu->qamModOrder[0] = Qm; pdsch_pdu->mcsIndex[0] = sched_pdsch->mcs; @@ -1160,12 +1066,10 @@ void nr_schedule_ue_spec(module_id_t module_id, AssertFatal(harq->round<4,"%d",harq->round); pdsch_pdu->rvIndex[0] = nr_rv_round_map[harq->round]; pdsch_pdu->TBSize[0] = TBS; - pdsch_pdu->dataScramblingId = *scc->physCellId; pdsch_pdu->nrOfLayers = nrOfLayers; pdsch_pdu->transmissionScheme = 0; pdsch_pdu->refPoint = 0; // Point A - // DMRS pdsch_pdu->dlDmrsSymbPos = ps->dl_dmrs_symb_pos; pdsch_pdu->dmrsConfigType = ps->dmrsConfigType; @@ -1173,18 +1077,38 @@ void nr_schedule_ue_spec(module_id_t module_id, pdsch_pdu->SCID = 0; pdsch_pdu->numDmrsCdmGrpsNoData = ps->numDmrsCdmGrpsNoData; pdsch_pdu->dmrsPorts = (1<resourceAlloc = 1; pdsch_pdu->rbStart = sched_pdsch->rbStart; pdsch_pdu->rbSize = sched_pdsch->rbSize; pdsch_pdu->VRBtoPRBMapping = 1; // non-interleaved, check if this is ok for initialBWP - // Resource Allocation in time domain pdsch_pdu->StartSymbolIndex = ps->startSymbolIndex; pdsch_pdu->NrOfSymbols = ps->nrOfSymbols; + // Precoding + if (sched_ctrl->set_pmi) { + const int report_id = sched_ctrl->CSI_report.cri_ri_li_pmi_cqi_report.csi_report_id; + nr_csi_report_t *csi_report = &UE->csi_report_template[report_id]; + pdsch_pdu->precodingAndBeamforming.prg_size = pdsch_pdu->rbSize; + pdsch_pdu->precodingAndBeamforming.prgs_list[0].pm_idx = set_pm_index(sched_ctrl, + nrOfLayers, + csi_report->N1, + csi_report->N2, + gNB_mac->xp_pdsch_antenna_ports, + csi_report->codebook_mode); + } + // TBS_LBRM according to section 5.4.2.1 of 38.212 + long *maxMIMO_Layers = cg->spCellConfig->spCellConfigDedicated->pdsch_ServingCellConfig->choice.setup->ext1->maxMIMO_Layers; + AssertFatal (maxMIMO_Layers != NULL,"Option with max MIMO layers not configured is not supported\n"); + int nl_tbslbrm = *maxMIMO_Layers < 4 ? *maxMIMO_Layers : 4; + // Maximum number of PRBs across all configured DL BWPs + int bw_tbslbrm = get_bw_tbslbrm(genericParameters, cg); + pdsch_pdu->maintenance_parms_v3.tbSizeLbrmBytes = nr_compute_tbslbrm(ps->mcsTableIdx, + bw_tbslbrm, + nl_tbslbrm); NR_PDSCH_Config_t *pdsch_Config=NULL; + if (bwp && bwp->bwp_Dedicated && bwp->bwp_Dedicated->pdsch_Config && @@ -1193,7 +1117,8 @@ void nr_schedule_ue_spec(module_id_t module_id, /* Check and validate PTRS values */ struct NR_SetupRelease_PTRS_DownlinkConfig *phaseTrackingRS = - pdsch_Config ? pdsch_Config->dmrs_DownlinkForPDSCH_MappingTypeA->choice.setup->phaseTrackingRS : NULL; + pdsch_Config ? pdsch_Config->dmrs_DownlinkForPDSCH_MappingTypeA->choice.setup->phaseTrackingRS : NULL; + if (phaseTrackingRS) { bool valid_ptrs_setup = set_dl_ptrs_values(phaseTrackingRS->choice.setup, pdsch_pdu->rbSize, @@ -1205,6 +1130,7 @@ void nr_schedule_ue_spec(module_id_t module_id, &pdsch_pdu->nEpreRatioOfPDSCHToPTRS, &pdsch_pdu->PTRSReOffset, pdsch_pdu->NrOfSymbols); + if (valid_ptrs_setup) pdsch_pdu->pduBitmap |= 0x1; // Bit 0: pdschPtrs - Indicates PTRS included (FR2) } @@ -1214,6 +1140,7 @@ void nr_schedule_ue_spec(module_id_t module_id, nfapi_nr_dl_dci_pdu_t *dci_pdu = &pdcch_pdu->dci_pdu[pdcch_pdu->numDlDci]; pdcch_pdu->numDlDci++; dci_pdu->RNTI = rnti; + if (sched_ctrl->coreset && sched_ctrl->search_space && sched_ctrl->coreset->pdcch_DMRS_ScramblingID && @@ -1224,27 +1151,27 @@ void nr_schedule_ue_spec(module_id_t module_id, dci_pdu->ScramblingId = *scc->physCellId; dci_pdu->ScramblingRNTI = 0; } + dci_pdu->AggregationLevel = sched_ctrl->aggregation_level; dci_pdu->CceIndex = sched_ctrl->cce_index; dci_pdu->beta_PDCCH_1_0 = 0; dci_pdu->powerControlOffsetSS = 1; - /* DCI payload */ dci_pdu_rel15_t dci_payload; memset(&dci_payload, 0, sizeof(dci_pdu_rel15_t)); // bwp indicator - const int n_dl_bwp = bwp ? UE_info->CellGroup[UE_id]->spCellConfig->spCellConfigDedicated->downlinkBWP_ToAddModList->list.count : 0; - AssertFatal(n_dl_bwp <= 1, "downlinkBWP_ToAddModList has %d BWP!\n", n_dl_bwp); + const int n_dl_bwp = bwp ? cg->spCellConfig->spCellConfigDedicated->downlinkBWP_ToAddModList->list.count : 0; + AssertFatal(n_dl_bwp <= NR_MAX_NUM_BWP, "downlinkBWP_ToAddModList has %d BWP!\n", n_dl_bwp); // as per table 7.3.1.1.2-1 in 38.212 dci_payload.bwp_indicator.val = bwp ? (n_dl_bwp < 4 ? bwp->bwp_Id : bwp->bwp_Id - 1) : 0; + if (bwp) AssertFatal(bwp->bwp_Dedicated->pdsch_Config->choice.setup->resourceAllocation == NR_PDSCH_Config__resourceAllocation_resourceAllocationType1, - "Only frequency resource allocation type 1 is currently supported\n"); - dci_payload.frequency_domain_assignment.val = - PRBalloc_to_locationandbandwidth0( - pdsch_pdu->rbSize, - pdsch_pdu->rbStart, - pdsch_pdu->BWPSize); + "Only frequency resource allocation type 1 is currently supported\n"); + + dci_payload.frequency_domain_assignment.val = PRBalloc_to_locationandbandwidth0(pdsch_pdu->rbSize, + pdsch_pdu->rbStart, + pdsch_pdu->BWPSize); dci_payload.format_indicator = 1; dci_payload.time_domain_assignment.val = ps->time_domain_allocation; dci_payload.mcs = sched_pdsch->mcs; @@ -1259,13 +1186,14 @@ void nr_schedule_ue_spec(module_id_t module_id, dci_payload.dmrs_sequence_initialization.val = pdsch_pdu->SCID; LOG_D(NR_MAC, "%4d.%2d DCI type 1 payload: freq_alloc %d (%d,%d,%d), " - "time_alloc %d, vrb to prb %d, mcs %d tb_scaling %d ndi %d rv %d tpc %d ti %d\n", + "nrOfLayers %d, time_alloc %d, vrb to prb %d, mcs %d tb_scaling %d ndi %d rv %d tpc %d ti %d\n", frame, slot, dci_payload.frequency_domain_assignment.val, pdsch_pdu->rbStart, pdsch_pdu->rbSize, pdsch_pdu->BWPSize, + pdsch_pdu->nrOfLayers, dci_payload.time_domain_assignment.val, dci_payload.vrb_to_prb_mapping.val, dci_payload.mcs, @@ -1275,24 +1203,20 @@ void nr_schedule_ue_spec(module_id_t module_id, dci_payload.tpc, pucch->timing_indicator); - const long f = sched_ctrl->search_space->searchSpaceType->choice.ue_Specific->dci_Formats; - int dci_format; - if (sched_ctrl->search_space) { - dci_format = f ? NR_DL_DCI_FORMAT_1_1 : NR_DL_DCI_FORMAT_1_0; - } - else { - dci_format = NR_DL_DCI_FORMAT_1_0; - } - const int rnti_type = NR_RNTI_C; + int dci_format = ss && ss->searchSpaceType && ss->searchSpaceType->present == NR_SearchSpace__searchSpaceType_PR_ue_Specific ? + NR_DL_DCI_FORMAT_1_1 : NR_DL_DCI_FORMAT_1_0; + const int rnti_type = NR_RNTI_C; fill_dci_pdu_rel15(scc, - UE_info->CellGroup[UE_id], + cg, dci_pdu, &dci_payload, dci_format, rnti_type, pdsch_pdu->BWPSize, - bwp? bwp->bwp_Id : 0); + bwp ? bwp->bwp_Id : 0, + coresetid, + gNB_mac->cset0_bwp_size); LOG_D(NR_MAC, "coreset params: FreqDomainResource %llx, start_symbol %d n_symb %d\n", @@ -1302,31 +1226,25 @@ void nr_schedule_ue_spec(module_id_t module_id, if (harq->round != 0) { /* retransmission */ /* we do not have to do anything, since we do not require to get data - * from RLC or encode MAC CEs. The TX_req structure is filled below + * from RLC or encode MAC CEs. The TX_req structure is filled below * or copy data to FAPI structures */ LOG_D(NR_MAC, - "%d.%2d DL retransmission UE %d/RNTI %04x HARQ PID %d round %d NDI %d\n", + "%d.%2d DL retransmission RNTI %04x HARQ PID %d round %d NDI %d\n", frame, slot, - UE_id, rnti, current_harq_pid, harq->round, harq->ndi); - AssertFatal(harq->sched_pdsch.tb_size == TBS, - "UE %d mismatch between scheduled TBS and buffered TB for HARQ PID %d\n", - UE_id, + "UE %04x mismatch between scheduled TBS and buffered TB for HARQ PID %d\n", + UE->rnti, current_harq_pid); - T(T_GNB_MAC_RETRANSMISSION_DL_PDU_WITH_DATA, T_INT(module_id), T_INT(CC_id), T_INT(rnti), - T_INT(frame), T_INT(slot), T_INT(current_harq_pid), T_INT(harq->round), T_BUFFER(harq->tb, TBS)); + T_INT(frame), T_INT(slot), T_INT(current_harq_pid), T_INT(harq->round), T_BUFFER(harq->transportBlock, TBS)); } else { /* initial transmission */ - LOG_D(NR_MAC, "[%s] Initial HARQ transmission in %d.%d\n", __FUNCTION__, frame, slot); - - uint8_t *buf = (uint8_t *) harq->tb; - + uint8_t *buf = (uint8_t *) harq->transportBlock; /* first, write all CEs that might be there */ int written = nr_write_ce_dlsch_pdu(module_id, sched_ctrl, @@ -1334,109 +1252,104 @@ void nr_schedule_ue_spec(module_id_t module_id, 255, // no drx NULL); // contention res id buf += written; - int size = TBS - written; - DevAssert(size >= 0); - - /* next, get RLC data */ - - // const int lcid = DL_SCH_LCID_DTCH; - const int lcid = sched_ctrl->lcid_to_schedule; + uint8_t *bufEnd = buf + TBS - written; + DevAssert(TBS > written); int dlsch_total_bytes = 0; + /* next, get RLC data */ start_meas(&gNB_mac->rlc_data_req); + if (sched_ctrl->num_total_bytes > 0) { - tbs_size_t len = 0; - while (size > 3) { - // we do not know how much data we will get from RLC, i.e., whether it - // will be longer than 256B or not. Therefore, reserve space for long header, then - // fetch data, then fill real length - NR_MAC_SUBHEADER_LONG *header = (NR_MAC_SUBHEADER_LONG *) buf; - buf += 3; - size -= 3; + /* loop over all activated logical channels */ + for (int i = 0; i < sched_ctrl->dl_lc_num; ++i) { + const int lcid = sched_ctrl->dl_lc_ids[i]; - /* limit requested number of bytes to what preprocessor specified, or - * such that TBS is full */ - const rlc_buffer_occupancy_t ndata = min(sched_ctrl->rlc_status[lcid].bytes_in_buffer, size); + if (sched_ctrl->rlc_status[lcid].bytes_in_buffer == 0) + continue; // no data for this LC tbs_size_t len = 0; - len = mac_rlc_data_req(module_id, - rnti, - module_id, - frame, - ENB_FLAG_YES, - MBMS_FLAG_NO, - lcid, - ndata, - (char *)buf, - 0, - 0); + int lcid_bytes=0; + while (bufEnd-buf > sizeof(NR_MAC_SUBHEADER_LONG) + 1 ) { + // we do not know how much data we will get from RLC, i.e., whether it + // will be longer than 256B or not. Therefore, reserve space for long header, then + // fetch data, then fill real length + NR_MAC_SUBHEADER_LONG *header = (NR_MAC_SUBHEADER_LONG *) buf; + /* limit requested number of bytes to what preprocessor specified, or + * such that TBS is full */ + const rlc_buffer_occupancy_t ndata = min(sched_ctrl->rlc_status[lcid].bytes_in_buffer, + bufEnd-buf-sizeof(NR_MAC_SUBHEADER_LONG)); + tbs_size_t len = mac_rlc_data_req(module_id, + rnti, + module_id, + frame, + ENB_FLAG_YES, + MBMS_FLAG_NO, + lcid, + ndata, + (char *)buf+sizeof(NR_MAC_SUBHEADER_LONG), + 0, + 0); + LOG_D(NR_MAC, + "%4d.%2d RNTI %04x: %d bytes from %s %d (ndata %d, remaining size %ld)\n", + frame, + slot, + rnti, + len, + lcid < 4 ? "DCCH" : "DTCH", + lcid, + ndata, + bufEnd-buf-+sizeof(NR_MAC_SUBHEADER_LONG)); - LOG_D(NR_MAC, - "%4d.%2d RNTI %04x: %d bytes from %s %d (ndata %d, remaining size %d)\n", - frame, - slot, - rnti, - len, - lcid < 4 ? "DCCH" : "DTCH", - lcid, - ndata, - size); - if (len == 0) - break; + if (len == 0) + break; - header->R = 0; - header->F = 1; - header->LCID = lcid; - header->L1 = (len >> 8) & 0xff; - header->L2 = len & 0xff; - size -= len; - buf += len; - dlsch_total_bytes += len; + header->R = 0; + header->F = 1; + header->LCID = lcid; + header->L = htons(len); + buf += len+sizeof(NR_MAC_SUBHEADER_LONG); + dlsch_total_bytes += len; + lcid_bytes += len; + } + + UE->mac_stats.dl.lc_bytes[lcid] += lcid_bytes; } - if (len == 0) { - /* RLC did not have data anymore, mark buffer as unused */ - buf -= 3; - size += 3; - } - } - else if (get_softmodem_params()->phy_test || get_softmodem_params()->do_ra || get_softmodem_params()->sa) { + } else if (get_softmodem_params()->phy_test || get_softmodem_params()->do_ra) { /* we will need the large header, phy-test typically allocates all * resources and fills to the last byte below */ - NR_MAC_SUBHEADER_LONG *header = (NR_MAC_SUBHEADER_LONG *) buf; - buf += 3; - size -= 3; - DevAssert(size > 0); - LOG_D(NR_MAC, "Configuring DL_TX in %d.%d: TBS %d with %d B of random data\n", frame, slot, TBS, size); - // fill dlsch_buffer with random data - for (int i = 0; i < size; i++) - buf[i] = lrand48() & 0xff; - header->R = 0; - header->F = 1; - header->LCID = DL_SCH_LCID_PADDING; - header->L1 = (size >> 8) & 0xff; - header->L2 = size & 0xff; - size -= size; - buf += size; - dlsch_total_bytes += size; + LOG_D(NR_MAC, "Configuring DL_TX in %d.%d: TBS %d of random data\n", frame, slot, TBS); + + if (bufEnd-buf > sizeof(NR_MAC_SUBHEADER_LONG) ) { + NR_MAC_SUBHEADER_LONG *header = (NR_MAC_SUBHEADER_LONG *) buf; + // fill dlsch_buffer with random data + header->R = 0; + header->F = 1; + header->LCID = DL_SCH_LCID_PADDING; + buf += sizeof(NR_MAC_SUBHEADER_LONG); + header->L = htons(bufEnd-buf); + dlsch_total_bytes += bufEnd-buf; + + for (; buf < bufEnd - 3; buf += 4) { + uint32_t *buf32 = (uint32_t *)buf; + *buf32 = lrand48(); + } + for (; buf < bufEnd; buf++) + *buf = lrand48() & 0xff; + } } + stop_meas(&gNB_mac->rlc_data_req); // Add padding header and zero rest out if there is space left - if (size > 0) { + if (bufEnd-buf > 0) { NR_MAC_SUBHEADER_FIXED *padding = (NR_MAC_SUBHEADER_FIXED *) buf; padding->R = 0; padding->LCID = DL_SCH_LCID_PADDING; - size -= 1; buf += 1; - while (size > 0) { - *buf = 0; - buf += 1; - size -= 1; - } + memset(buf,0,bufEnd-buf); + buf=bufEnd; } - UE_info->mac_stats[UE_id].dlsch_total_bytes += TBS; - UE_info->mac_stats[UE_id].dlsch_current_bytes = TBS; - UE_info->mac_stats[UE_id].lc_bytes_tx[lcid] += dlsch_total_bytes; - + UE->mac_stats.dl.total_bytes += TBS; + UE->mac_stats.dl.current_bytes = TBS; /* save retransmission information */ harq->sched_pdsch = *sched_pdsch; /* save which time allocation has been used, to be used on @@ -1448,14 +1361,14 @@ void nr_schedule_ue_spec(module_id_t module_id, sched_ctrl->ta_apply = false; sched_ctrl->ta_frame = frame; LOG_D(NR_MAC, - "%d.%2d UE %d TA scheduled, resetting TA frame\n", + "%d.%2d UE %04x TA scheduled, resetting TA frame\n", frame, slot, - UE_id); + UE->rnti); } T(T_GNB_MAC_DL_PDU_WITH_DATA, T_INT(module_id), T_INT(CC_id), T_INT(rnti), - T_INT(frame), T_INT(slot), T_INT(current_harq_pid), T_BUFFER(harq->tb, TBS)); + T_INT(frame), T_INT(slot), T_INT(current_harq_pid), T_BUFFER(harq->transportBlock, TBS)); } const int ntx_req = gNB_mac->TX_req[CC_id].Number_of_PDUs; @@ -1464,11 +1377,10 @@ void nr_schedule_ue_spec(module_id_t module_id, tx_req->PDU_index = pduindex; tx_req->num_TLV = 1; tx_req->TLVs[0].length = TBS + 2; - memcpy(tx_req->TLVs[0].value.direct, harq->tb, TBS); + memcpy(tx_req->TLVs[0].value.direct, harq->transportBlock, TBS); gNB_mac->TX_req[CC_id].Number_of_PDUs++; gNB_mac->TX_req[CC_id].SFN = frame; gNB_mac->TX_req[CC_id].Slot = slot; - /* mark UE as scheduled */ sched_pdsch->rbSize = 0; } diff --git a/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_phytest.c b/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_phytest.c index fddf084a38..808fc613f1 100644 --- a/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_phytest.c +++ b/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_phytest.c @@ -55,8 +55,6 @@ extern RAN_CONTEXT_t RC; //#define ENABLE_MAC_PAYLOAD_DEBUG 1 -//uint8_t mac_pdu[MAX_NR_DLSCH_PAYLOAD_BYTES]; - /*Scheduling of DLSCH with associated DCI in common search space * current version has only a DCI for type 1 PDCCH for C_RNTI*/ void nr_schedule_css_dlsch_phytest(module_id_t module_idP, @@ -71,7 +69,6 @@ void nr_schedule_css_dlsch_phytest(module_id_t module_idP, nfapi_nr_pdu_t *TX_req; uint16_t rnti = 0x1234; - // int time_domain_assignment,k0; NR_ServingCellConfigCommon_t *scc=cc->ServingCellConfigCommon; @@ -154,8 +151,6 @@ void nr_schedule_css_dlsch_phytest(module_id_t module_idP, NrOfSymbols = NrOfSymbols_tmp; StartSymbolIndex = StartSymbolIndex_tmp; mappingtype = mappingtype_tmp; - // k0 = *scc->downlinkConfigCommon->initialDownlinkBWP->pdsch_ConfigCommon->choice.setup->pdsch_TimeDomainAllocationList->list.array[i]->k0; - // time_domain_assignment = i; } } AssertFatal(StartSymbolIndex>=0,"StartSymbolIndex is negative\n"); @@ -165,80 +160,9 @@ void nr_schedule_css_dlsch_phytest(module_id_t module_idP, scc->dmrs_TypeA_Position, NrOfSymbols, StartSymbolIndex, - mappingtype, 1); + mappingtype, + 1); - /* - AssertFatal(k0==0,"k0 is not zero for Initial DL BWP TimeDomain Alloc\n"); - nr_configure_css_dci_initial(pdcch_pdu_rel15, - scs, - scs, - FR, - 0, - 0, - 0, - sfn_sf, slotP, - slots_per_frame, - dlBWP_carrier_bandwidth); - - - pdu_rel15->frequency_domain_assignment = PRBalloc_to_locationandbandwidth0(pdsch_pdu_rel15->rbSize, - pdsch_pdu_rel15->rbStart, - dlBWP_carrier_bandwidth); - pdu_rel15->time_domain_assignment = time_domain_assignment; - - pdu_rel15->vrb_to_prb_mapping = 1; - pdu_rel15->mcs = 9; - pdu_rel15->tb_scaling = 1; - - pdu_rel15->ra_preamble_index = 25; - pdu_rel15->format_indicator = 1; - pdu_rel15->ndi = 1; - pdu_rel15->rv = 0; - pdu_rel15->harq_pid = 0; - pdu_rel15->dai = 2; - pdu_rel15->tpc = 2; - pdu_rel15->pucch_resource_indicator = 7; - pdu_rel15->pdsch_to_harq_feedback_timing_indicator = 7; - - LOG_D(MAC, "[gNB scheduler phytest] DCI type 1 payload: freq_alloc %d, time_alloc %d, vrb to prb %d, mcs %d tb_scaling %d ndi %d rv %d\n", - pdu_rel15->frequency_domain_assignment, - pdu_rel15->time_domain_assignment, - pdu_rel15->vrb_to_prb_mapping, - pdu_rel15->mcs, - pdu_rel15->tb_scaling, - pdu_rel15->ndi, - pdu_rel15->rv); - - params_rel15->rnti = rnti; - params_rel15->rnti_type = NFAPI_NR_RNTI_C; - params_rel15->dci_format = NFAPI_NR_DL_DCI_FORMAT_1_0; - //params_rel15->aggregation_level = 1; - LOG_D(MAC, "DCI type 1 params: rnti %x, rnti_type %d, dci_format %d\n \ - coreset params: mux_pattern %d, n_rb %d, n_symb %d, rb_offset %d \n \ - ss params : nb_ss_sets_per_slot %d, first symb %d, nb_slots %d, sfn_mod2 %d, first slot %d\n", - params_rel15->rnti, - params_rel15->rnti_type, - params_rel15->dci_format, - params_rel15->mux_pattern, - params_rel15->n_rb, - params_rel15->n_symb, - params_rel15->rb_offset, - params_rel15->nb_ss_sets_per_slot, - params_rel15->first_symbol, - params_rel15->nb_slots, - params_rel15->sfn_mod2, - params_rel15->first_slot); - nr_get_tbs_dl(&dl_tti_pdsch_pdu->pdsch_pdu, dl_tti_dci_pdu->dci_dl_pdu,0); - LOG_D(MAC, "DLSCH PDU: start PRB %d n_PRB %d start symbol %d nb_symbols %d nb_layers %d nb_codewords %d mcs %d\n", - pdsch_pdu_rel15->rbStart, - pdsch_pdu_rel15->rbSize, - pdsch_pdu_rel15->StartSymbolIndex, - pdsch_pdu_rel15->NrOfSymbols, - pdsch_pdu_rel15->nrOfLayers, - pdsch_pdu_rel15->NrOfCodewords, - pdsch_pdu_rel15->mcsIndex[0]); - */ - nr_mac->DL_req[CC_id].dl_tti_request_body.nPDUs+=2; TX_req = &nr_mac->TX_req[CC_id].pdu_list[nr_mac->TX_req[CC_id].Number_of_PDUs]; @@ -268,25 +192,21 @@ void nr_preprocessor_phytest(module_id_t module_id, { if (!is_xlsch_in_slot(dlsch_slot_bitmap, slot)) return; - NR_UE_info_t *UE_info = &RC.nrmac[module_id]->UE_info; + NR_UE_info_t *UE = RC.nrmac[module_id]->UE_info.list[0]; NR_ServingCellConfigCommon_t *scc = RC.nrmac[module_id]->common_channels[0].ServingCellConfigCommon; - const int UE_id = 0; + NR_UE_sched_ctrl_t *sched_ctrl = &UE->UE_sched_ctrl; const int CC_id = 0; - AssertFatal(UE_info->active[UE_id], - "%s(): expected UE %d to be active\n", - __func__, - UE_id); - NR_UE_sched_ctrl_t *sched_ctrl = &UE_info->UE_sched_ctrl[UE_id]; - const int tda = sched_ctrl->active_bwp ? RC.nrmac[module_id]->preferred_dl_tda[sched_ctrl->active_bwp->bwp_Id][slot] : 1; + + const int tda = get_dl_tda(RC.nrmac[module_id], scc, slot); NR_pdsch_semi_static_t *ps = &sched_ctrl->pdsch_semi_static; ps->nrOfLayers = target_dl_Nl; - if (ps->time_domain_allocation != tda || ps->nrOfLayers != target_dl_Nl) - nr_set_pdsch_semi_static(scc, UE_info->CellGroup[UE_id], sched_ctrl->active_bwp, NULL, tda, target_dl_Nl, sched_ctrl, ps); + nr_set_pdsch_semi_static(NULL, scc, UE->CellGroup, sched_ctrl->active_bwp, NULL, tda, target_dl_Nl,sched_ctrl , ps); /* find largest unallocated chunk */ const int bwpSize = NRRIV2BW(sched_ctrl->active_bwp->bwp_Common->genericParameters.locationAndBandwidth, MAX_BWP_SIZE); const int BWPStart = NRRIV2PRBOFFSET(sched_ctrl->active_bwp->bwp_Common->genericParameters.locationAndBandwidth, MAX_BWP_SIZE); + int rbStart = 0; int rbSize = 0; if (target_dl_bw>bwpSize) @@ -314,8 +234,10 @@ void nr_preprocessor_phytest(module_id_t module_id, } sched_ctrl->num_total_bytes = 0; + sched_ctrl->dl_lc_num = 1; const int lcid = DL_SCH_LCID_DTCH; - const uint16_t rnti = UE_info->rnti[UE_id]; + sched_ctrl->dl_lc_ids[sched_ctrl->dl_lc_num - 1] = lcid; + const uint16_t rnti = UE->rnti; /* update sched_ctrl->num_total_bytes so that postprocessor schedules data, * if available */ sched_ctrl->rlc_status[lcid] = mac_rlc_status_ind(module_id, @@ -329,7 +251,6 @@ void nr_preprocessor_phytest(module_id_t module_id, 0, 0); sched_ctrl->num_total_bytes += sched_ctrl->rlc_status[lcid].bytes_in_buffer; - sched_ctrl->lcid_to_schedule = lcid; uint8_t nr_of_candidates; for (int i=0; i<5; i++) { @@ -342,8 +263,7 @@ void nr_preprocessor_phytest(module_id_t module_id, } AssertFatal(nr_of_candidates>0,"nr_of_candidates is 0\n"); - const int cid = sched_ctrl->coreset->controlResourceSetId; - const uint16_t Y = get_Y(cid%3, slot, UE_info->rnti[UE_id]); + const uint32_t Y = get_Y(sched_ctrl->search_space, slot, UE->rnti); int CCEIndex = find_pdcch_candidate(RC.nrmac[module_id], CC_id, @@ -354,20 +274,19 @@ void nr_preprocessor_phytest(module_id_t module_id, Y); AssertFatal(CCEIndex >= 0, - "%s(): could not find CCE for UE %d\n", + "%s(): could not find CCE for UE %04x\n", __func__, - UE_id); + UE->rnti); - const int alloc = nr_acknack_scheduling(module_id, UE_id, frame, slot, -1, 0); + int r_pucch = nr_get_pucch_resource(sched_ctrl->coreset, sched_ctrl->active_ubwp, NULL, CCEIndex); + const int alloc = nr_acknack_scheduling(module_id, UE, frame, slot, r_pucch, 0); if (alloc < 0) { LOG_D(MAC, - "%s(): could not find PUCCH for UE %d/%04x@%d.%d\n", + "%s(): could not find PUCCH for UE %04x@%d.%d\n", __func__, - UE_id, rnti, frame, slot); - RC.nrmac[module_id]->pdcch_cand[cid]--; return; } @@ -389,6 +308,7 @@ void nr_preprocessor_phytest(module_id_t module_id, sched_pdsch->rbSize = rbSize; sched_pdsch->mcs = target_dl_mcs; + sched_ctrl->dl_bler_stats.mcs = target_dl_mcs; /* for logging output */ sched_pdsch->Qm = nr_get_Qm_dl(sched_pdsch->mcs, ps->mcsTableIdx); sched_pdsch->R = nr_get_code_rate_dl(sched_pdsch->mcs, ps->mcsTableIdx); sched_pdsch->tb_size = nr_compute_tbs(sched_pdsch->Qm, @@ -413,6 +333,7 @@ void nr_preprocessor_phytest(module_id_t module_id, uint32_t target_ul_mcs = 9; uint32_t target_ul_bw = 50; +uint32_t target_ul_Nl = 1; uint64_t ulsch_slot_bitmap = (1 << 8); bool nr_ul_preprocessor_phytest(module_id_t module_id, frame_t frame, sub_frame_t slot) { @@ -420,49 +341,59 @@ bool nr_ul_preprocessor_phytest(module_id_t module_id, frame_t frame, sub_frame_ NR_COMMON_channels_t *cc = nr_mac->common_channels; NR_ServingCellConfigCommon_t *scc = cc->ServingCellConfigCommon; const int mu = scc->uplinkConfigCommon->initialUplinkBWP->genericParameters.subcarrierSpacing; - NR_UE_info_t *UE_info = &nr_mac->UE_info; + NR_UE_info_t *UE = nr_mac->UE_info.list[0]; - AssertFatal(UE_info->num_UEs <= 1, - "%s() cannot handle more than one UE, but found %d\n", - __func__, - UE_info->num_UEs); - if (UE_info->num_UEs == 0) + AssertFatal(nr_mac->UE_info.list[1] == NULL, + "cannot handle more than one UE\n"); + if (UE == NULL) return false; - const int UE_id = 0; const int CC_id = 0; - NR_UE_sched_ctrl_t *sched_ctrl = &UE_info->UE_sched_ctrl[UE_id]; + NR_UE_sched_ctrl_t *sched_ctrl = &UE->UE_sched_ctrl; - const int tda = sched_ctrl->active_ubwp ? RC.nrmac[module_id]->preferred_ul_tda[sched_ctrl->active_ubwp->bwp_Id][slot] : 1; - if (tda < 0) - return false; const struct NR_PUSCH_TimeDomainResourceAllocationList *tdaList = sched_ctrl->active_ubwp->bwp_Common->pusch_ConfigCommon->choice.setup->pusch_TimeDomainAllocationList; + const int temp_tda = get_ul_tda(nr_mac, scc, slot); + if (temp_tda < 0) + return false; + AssertFatal(temp_tda < tdaList->list.count, + "time domain assignment %d >= %d\n", + temp_tda, + tdaList->list.count); + int K2 = get_K2(scc,NULL,sched_ctrl->active_ubwp, temp_tda, mu); + const int sched_frame = frame + (slot + K2 >= nr_slots_per_frame[mu]); + const int sched_slot = (slot + K2) % nr_slots_per_frame[mu]; + const int tda = get_ul_tda(nr_mac, scc, sched_slot); + if (tda < 0) + return false; AssertFatal(tda < tdaList->list.count, "time domain assignment %d >= %d\n", tda, tdaList->list.count); - int K2 = get_K2(scc,sched_ctrl->active_ubwp, tda, mu); - const int sched_frame = frame + (slot + K2 >= nr_slots_per_frame[mu]); - const int sched_slot = (slot + K2) % nr_slots_per_frame[mu]; /* check if slot is UL, and that slot is 8 (assuming K2=6 because of UE * limitations). Note that if K2 or the TDD configuration is changed, below * conditions might exclude each other and never be true */ if (!is_xlsch_in_slot(ulsch_slot_bitmap, sched_slot)) return false; - const long f = sched_ctrl->search_space->searchSpaceType->choice.ue_Specific->dci_Formats; + const long f = (sched_ctrl->active_bwp && sched_ctrl->search_space && + sched_ctrl->search_space->searchSpaceType->present == NR_SearchSpace__searchSpaceType_PR_ue_Specific) ? + sched_ctrl->search_space->searchSpaceType->choice.ue_Specific->dci_Formats : 0; const int dci_format = f ? NR_UL_DCI_FORMAT_0_1 : NR_UL_DCI_FORMAT_0_0; - const uint8_t num_dmrs_cdm_grps_no_data = 1; + uint8_t num_dmrs_cdm_grps_no_data = 1; + if ((target_ul_Nl==4)||(target_ul_Nl==3)) + num_dmrs_cdm_grps_no_data = 2; + /* we want to avoid a lengthy deduction of DMRS and other parameters in * every TTI if we can save it, so check whether dci_format, TDA, or * num_dmrs_cdm_grps_no_data has changed and only then recompute */ NR_pusch_semi_static_t *ps = &sched_ctrl->pusch_semi_static; if (ps->time_domain_allocation != tda || ps->dci_format != dci_format + || ps->nrOfLayers != target_ul_Nl || ps->num_dmrs_cdm_grps_no_data != num_dmrs_cdm_grps_no_data) - nr_set_pusch_semi_static(scc, sched_ctrl->active_ubwp, NULL,dci_format, tda, num_dmrs_cdm_grps_no_data, ps); + nr_set_pusch_semi_static(NULL, scc, sched_ctrl->active_ubwp, NULL,dci_format, tda, num_dmrs_cdm_grps_no_data,target_ul_Nl,ps); uint16_t rbStart = 0; uint16_t rbSize; @@ -481,9 +412,8 @@ bool nr_ul_preprocessor_phytest(module_id_t module_id, frame_t frame, sub_frame_ uint16_t *vrb_map_UL = &RC.nrmac[module_id]->common_channels[CC_id].vrb_map_UL[sched_slot * MAX_BWP_SIZE]; - const uint16_t symb = ((1 << ps->nrOfSymbols) - 1) << ps->startSymbolIndex; for (int i = rbStart; i < rbStart + rbSize; ++i) { - if ((vrb_map_UL[i+BWPStart] & symb) != 0) { + if ((vrb_map_UL[i+BWPStart] & SL_to_bitmap(ps->startSymbolIndex, ps->nrOfSymbols)) != 0) { LOG_E(MAC, "%s(): %4d.%2d RB %d is already reserved, cannot schedule UE\n", __func__, @@ -508,8 +438,7 @@ bool nr_ul_preprocessor_phytest(module_id_t module_id, frame_t frame, sub_frame_ } AssertFatal(nr_of_candidates>0,"nr_of_candidates is 0\n"); - const int cid = sched_ctrl->coreset->controlResourceSetId; - const uint16_t Y = get_Y(cid%3, slot, UE_info->rnti[UE_id]); + const uint32_t Y = get_Y(sched_ctrl->search_space, slot, UE->rnti); int CCEIndex = find_pdcch_candidate(nr_mac, CC_id, @@ -521,7 +450,6 @@ bool nr_ul_preprocessor_phytest(module_id_t module_id, frame_t frame, sub_frame_ if (CCEIndex < 0) { LOG_E(MAC, "%s(): CCE list not empty, couldn't schedule PUSCH\n", __func__); - nr_mac->pdcch_cand[cid]--; return false; } @@ -530,12 +458,14 @@ bool nr_ul_preprocessor_phytest(module_id_t module_id, frame_t frame, sub_frame_ const int mcs = target_ul_mcs; NR_sched_pusch_t *sched_pusch = &sched_ctrl->sched_pusch; sched_pusch->mcs = mcs; + sched_ctrl->ul_bler_stats.mcs = mcs; /* for logging output */ sched_pusch->rbStart = rbStart; sched_pusch->rbSize = rbSize; /* get the PID of a HARQ process awaiting retransmission, or -1 for "any new" */ sched_pusch->ul_harq_pid = sched_ctrl->retrans_ul_harq.head; /* Calculate TBS from MCS */ + ps->nrOfLayers = target_ul_Nl; sched_pusch->R = nr_get_code_rate_ul(mcs, ps->mcs_table); sched_pusch->Qm = nr_get_Qm_ul(mcs, ps->mcs_table); if (ps->pusch_Config->tp_pi2BPSK @@ -550,7 +480,7 @@ bool nr_ul_preprocessor_phytest(module_id_t module_id, frame_t frame, sub_frame_ ps->N_PRB_DMRS * ps->num_dmrs_symb, 0, // nb_rb_oh 0, - 1 /* NrOfLayers */) + ps->nrOfLayers /* NrOfLayers */) >> 3; /* mark the corresponding RBs as used */ @@ -561,6 +491,6 @@ bool nr_ul_preprocessor_phytest(module_id_t module_id, frame_t frame, sub_frame_ sched_ctrl->aggregation_level); for (int rb = rbStart; rb < rbStart + rbSize; rb++) - vrb_map_UL[rb+BWPStart] = 1; + vrb_map_UL[rb+BWPStart] |= SL_to_bitmap(ps->startSymbolIndex, ps->nrOfSymbols); return true; } diff --git a/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_primitives.c b/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_primitives.c index 4d05320e64..e6797bbab8 100644 --- a/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_primitives.c +++ b/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_primitives.c @@ -113,18 +113,18 @@ uint8_t nr_ss_first_symb_idx_scs_120_120_mux3[4] = {4,8,2,6}; uint8_t nr_max_number_of_candidates_per_slot[4] = {44, 36, 22, 20}; uint8_t nr_max_number_of_cces_per_slot[4] = {56, 56, 48, 32}; -// CQI TABLES +// CQI TABLES (10 times the value in 214 to adequately compare with R) // Table 1 (38.214 5.2.2.1-2) -uint16_t cqi_table1[16][2] = {{0,0},{2,78},{2,120},{2,193},{2,308},{2,449},{2,602},{4,378}, - {4,490},{4,616},{6,466},{6,567},{6,666},{6,772},{6,873},{6,948}}; +uint16_t cqi_table1[16][2] = {{0,0},{2,780},{2,1200},{2,1930},{2,3080},{2,4490},{2,6020},{4,3780}, + {4,4900},{4,6160},{6,4660},{6,5670},{6,6660},{6,7720},{6,8730},{6,9480}}; // Table 2 (38.214 5.2.2.1-3) -uint16_t cqi_table2[16][2] = {{0,0},{2,78},{2,193},{2,449},{4,378},{4,490},{4,616},{6,466}, - {6,567},{6,666},{6,772},{6,873},{8,711},{8,797},{8,885},{8,948}}; +uint16_t cqi_table2[16][2] = {{0,0},{2,780},{2,1930},{2,4490},{4,3780},{4,4900},{4,6160},{6,4660}, + {6,5670},{6,6660},{6,7720},{6,8730},{8,7110},{8,7970},{8,8850},{8,9480}}; // Table 2 (38.214 5.2.2.1-4) -uint16_t cqi_table3[16][2] = {{0,0},{2,30},{2,50},{2,78},{2,120},{2,193},{2,308},{2,449}, - {2,602},{4,378},{4,490},{4,616},{6,466},{6,567},{6,666},{6,772}}; +uint16_t cqi_table3[16][2] = {{0,0},{2,300},{2,500},{2,780},{2,1200},{2,1930},{2,3080},{2,4490}, + {2,6020},{4,3780},{4,4900},{4,6160},{6,4660},{6,5670},{6,6660},{6,7720}}; static inline uint8_t get_max_candidates(uint8_t scs) { @@ -145,49 +145,68 @@ uint8_t set_dl_nrOfLayers(NR_UE_sched_ctrl_t *sched_ctrl) { } -void set_dl_mcs(NR_sched_pdsch_t *sched_pdsch, - NR_UE_sched_ctrl_t *sched_ctrl, - uint8_t *target_mcs, - uint8_t mcs_table_idx) { +uint16_t set_pm_index(NR_UE_sched_ctrl_t *sched_ctrl, + int layers, + int N1, int N2, + int xp_pdsch_antenna_ports, + int codebook_mode) { - if (sched_ctrl->set_mcs) { - // TODO for wideband case and multiple TB - int cqi_idx = sched_ctrl->CSI_report.cri_ri_li_pmi_cqi_report.wb_cqi_1tb; - uint16_t target_coderate,target_qm; - if (cqi_idx>0) { - int cqi_table = sched_ctrl->CSI_report.cri_ri_li_pmi_cqi_report.cqi_table; - AssertFatal(cqi_table == mcs_table_idx, "Indices of MCS tables don't correspond\n"); - switch (cqi_table) { - case 0: - target_qm = cqi_table1[cqi_idx][0]; - target_coderate = cqi_table1[cqi_idx][1]; - break; - case 1: - target_qm = cqi_table2[cqi_idx][0]; - target_coderate = cqi_table2[cqi_idx][1]; - break; - case 2: - target_qm = cqi_table3[cqi_idx][0]; - target_coderate = cqi_table3[cqi_idx][1]; - break; - default: - AssertFatal(1==0,"Invalid cqi table index %d\n",cqi_table); - } - int max_mcs = 28; - int R,Qm; - if (mcs_table_idx == 1) - max_mcs = 27; - for (int i=0; i<=max_mcs; i++) { - R = nr_get_code_rate_dl(i, mcs_table_idx); - Qm = nr_get_Qm_dl(i, mcs_table_idx); - if ((Qm == target_qm) && (target_coderate <= R)) { - *target_mcs = i; - break; - } - } - } - sched_ctrl->set_mcs = FALSE; + int antenna_ports = (N1*N2)<<1; + if (xp_pdsch_antenna_ports == 1 && + antenna_ports>1) + return 0; //identity matrix (basic 5G configuration handled by PMI report is with XP antennas) + + int x1 = sched_ctrl->CSI_report.cri_ri_li_pmi_cqi_report.pmi_x1; + int x2 = sched_ctrl->CSI_report.cri_ri_li_pmi_cqi_report.pmi_x2; + LOG_D(NR_MAC,"PMI report: x1 %d x2 %d\n",x1,x2); + + sched_ctrl->set_pmi = false; + + if (antenna_ports == 2) + return x2; + else + AssertFatal(1==0,"More than 2 antenna ports not yet supported\n"); +} + +uint8_t get_mcs_from_cqi(int mcs_table, int cqi_table, int cqi_idx) +{ + if (cqi_idx <= 0) { + LOG_E(NR_MAC, "invalid cqi_idx %d, default to MCS 9\n", cqi_idx); + return 9; } + + if (mcs_table != cqi_table) { + LOG_E(NR_MAC, "indices of CQI (%d) and MCS (%d) tables don't correspond yet\n", cqi_table, mcs_table); + return 9; + } + + uint16_t target_coderate, target_qm; + switch (cqi_table) { + case 0: + target_qm = cqi_table1[cqi_idx][0]; + target_coderate = cqi_table1[cqi_idx][1]; + break; + case 1: + target_qm = cqi_table2[cqi_idx][0]; + target_coderate = cqi_table2[cqi_idx][1]; + break; + case 2: + target_qm = cqi_table3[cqi_idx][0]; + target_coderate = cqi_table3[cqi_idx][1]; + break; + default: + AssertFatal(1==0,"Invalid cqi table index %d\n",cqi_table); + } + const int max_mcs = mcs_table == 1 ? 27 : 28; + for (int i = 0; i <= max_mcs; i++) { + const int R = nr_get_code_rate_dl(i, mcs_table); + const int Qm = nr_get_Qm_dl(i, mcs_table); + if (Qm == target_qm && target_coderate <= R) + return i; + } + + LOG_E(NR_MAC, "could not find maximum MCS from cqi_idx %d, default to 9\n", cqi_idx); + return 9; } void set_dl_dmrs_ports(NR_pdsch_semi_static_t *ps) { @@ -226,7 +245,50 @@ void set_dl_dmrs_ports(NR_pdsch_semi_static_t *ps) { } } -NR_ControlResourceSet_t *get_coreset(module_id_t module_idP, +NR_BWP_t *get_dl_bwp_genericParameters(NR_BWP_Downlink_t *active_bwp, + NR_ServingCellConfigCommon_t *ServingCellConfigCommon, + const NR_SIB1_t *sib1) { + NR_BWP_t *genericParameters = NULL; + if (active_bwp) { + genericParameters = &active_bwp->bwp_Common->genericParameters; + } else if (ServingCellConfigCommon) { + genericParameters = &ServingCellConfigCommon->downlinkConfigCommon->initialDownlinkBWP->genericParameters; + } else { + genericParameters = &sib1->servingCellConfigCommon->downlinkConfigCommon.initialDownlinkBWP.genericParameters; + } + return genericParameters; +} + +NR_BWP_t *get_ul_bwp_genericParameters(NR_BWP_Uplink_t *active_ubwp, + NR_ServingCellConfigCommon_t *ServingCellConfigCommon, + const NR_SIB1_t *sib1) { + NR_BWP_t *genericParameters = NULL; + if (active_ubwp) { + genericParameters = &active_ubwp->bwp_Common->genericParameters; + } else if (ServingCellConfigCommon) { + genericParameters = &ServingCellConfigCommon->uplinkConfigCommon->initialUplinkBWP->genericParameters; + } else { + genericParameters = &sib1->servingCellConfigCommon->uplinkConfigCommon->initialUplinkBWP.genericParameters; + } + return genericParameters; +} + +NR_PDSCH_TimeDomainResourceAllocationList_t *get_pdsch_TimeDomainAllocationList(const NR_BWP_Downlink_t *active_bwp, + const NR_ServingCellConfigCommon_t *ServingCellConfigCommon, + const NR_SIB1_t *sib1) { + NR_PDSCH_TimeDomainResourceAllocationList_t *tdaList = NULL; + if (active_bwp) { + tdaList = active_bwp->bwp_Common->pdsch_ConfigCommon->choice.setup->pdsch_TimeDomainAllocationList; + } else if (ServingCellConfigCommon) { + tdaList = ServingCellConfigCommon->downlinkConfigCommon->initialDownlinkBWP->pdsch_ConfigCommon->choice.setup->pdsch_TimeDomainAllocationList; + } else { + tdaList = sib1->servingCellConfigCommon->downlinkConfigCommon.initialDownlinkBWP.pdsch_ConfigCommon->choice.setup->pdsch_TimeDomainAllocationList; + } + return tdaList; +} + + +NR_ControlResourceSet_t *get_coreset(gNB_MAC_INST *nrmac, NR_ServingCellConfigCommon_t *scc, void *bwp, NR_SearchSpace_t *ss, @@ -236,7 +298,7 @@ NR_ControlResourceSet_t *get_coreset(module_id_t module_idP, if (ss_type == NR_SearchSpace__searchSpaceType_PR_common) { // common search space NR_ControlResourceSet_t *coreset; if(coreset_id == 0) { - coreset = RC.nrmac[module_idP]->sched_ctrlCommon->coreset; // this is coreset 0 + coreset = nrmac->sched_ctrlCommon->coreset; // this is coreset 0 } else if (bwp) { coreset = ((NR_BWP_Downlink_t*)bwp)->bwp_Common->pdcch_ConfigCommon->choice.setup->commonControlResourceSet; } else if (scc->downlinkConfigCommon->initialDownlinkBWP->pdcch_ConfigCommon->choice.setup->commonControlResourceSet) { @@ -262,17 +324,29 @@ NR_ControlResourceSet_t *get_coreset(module_id_t module_idP, } } -NR_SearchSpace_t *get_searchspace(NR_ServingCellConfigCommon_t *scc, - NR_BWP_DownlinkDedicated_t *bwp_Dedicated, - NR_SearchSpace__searchSpaceType_PR target_ss) { +NR_SearchSpace_t *get_searchspace(const NR_SIB1_t *sib1, + NR_ServingCellConfigCommon_t *scc, + NR_BWP_DownlinkDedicated_t *bwp_Dedicated, + NR_SearchSpace__searchSpaceType_PR target_ss) { + + int n = 0; + if(bwp_Dedicated) { + n = bwp_Dedicated->pdcch_Config->choice.setup->searchSpacesToAddModList->list.count; + } else if(scc) { + n = scc->downlinkConfigCommon->initialDownlinkBWP->pdcch_ConfigCommon->choice.setup->commonSearchSpaceList->list.count; + } else { + n = sib1->servingCellConfigCommon->downlinkConfigCommon.initialDownlinkBWP.pdcch_ConfigCommon->choice.setup->commonSearchSpaceList->list.count; + } - const int n = bwp_Dedicated ? - bwp_Dedicated->pdcch_Config->choice.setup->searchSpacesToAddModList->list.count: - scc->downlinkConfigCommon->initialDownlinkBWP->pdcch_ConfigCommon->choice.setup->commonSearchSpaceList->list.count; for (int i=0;ipdcch_Config->choice.setup->searchSpacesToAddModList->list.array[i]: - scc->downlinkConfigCommon->initialDownlinkBWP->pdcch_ConfigCommon->choice.setup->commonSearchSpaceList->list.array[i]; + NR_SearchSpace_t *ss = NULL; + if(bwp_Dedicated) { + ss = bwp_Dedicated->pdcch_Config->choice.setup->searchSpacesToAddModList->list.array[i]; + } else if(scc) { + ss = scc->downlinkConfigCommon->initialDownlinkBWP->pdcch_ConfigCommon->choice.setup->commonSearchSpaceList->list.array[i]; + } else { + ss = sib1->servingCellConfigCommon->downlinkConfigCommon.initialDownlinkBWP.pdcch_ConfigCommon->choice.setup->commonSearchSpaceList->list.array[i]; + } AssertFatal(ss->controlResourceSetId != NULL, "ss->controlResourceSetId is null\n"); AssertFatal(ss->searchSpaceType != NULL, "ss->searchSpaceType is null\n"); if (ss->searchSpaceType->present == target_ss) { @@ -366,36 +440,17 @@ NR_sched_pdcch_t set_pdcch_structure(gNB_MAC_INST *gNB_mac, } -int cce_to_reg_interleaving(const int R, int k, int n_shift, const int C, int L, const int N_regs) { - - int f; // interleaving function - if(R==0) - f = k; - else { - int c = k/R; - int r = k%R; - f = (r*C + c + n_shift)%(N_regs/L); - } - return f; -} - int find_pdcch_candidate(gNB_MAC_INST *mac, int cc_id, int aggregation, int nr_of_candidates, NR_sched_pdcch_t *pdcch, NR_ControlResourceSet_t *coreset, - uint16_t Y){ + uint32_t Y){ uint16_t *vrb_map = mac->common_channels[cc_id].vrb_map; - const int next_cand = mac->pdcch_cand[coreset->controlResourceSetId]; const int N_ci = 0; - if(next_cand>=nr_of_candidates) { - LOG_D(NR_MAC,"No more available candidates for this coreset\n"); - return -1; - } - const int N_rb = pdcch->n_rb; // nb of rbs of coreset per symbol const int N_symb = coreset->duration; // nb of coreset symbols const int N_regs = N_rb*N_symb; // nb of REGs per coreset @@ -407,9 +462,10 @@ int find_pdcch_candidate(gNB_MAC_INST *mac, // loop over all the available candidates // this implements TS 38.211 Sec. 7.3.2.2 - for(int m=next_cand; mShiftIndex, C, L, N_regs); @@ -421,10 +477,8 @@ int find_pdcch_candidate(gNB_MAC_INST *mac, } } } - if(!taken){ - mac->pdcch_cand[coreset->controlResourceSetId] = m++; // using candidate m, next available is m+1 + if(!taken) return first_cce; - } } return -1; } @@ -455,7 +509,6 @@ void fill_pdcch_vrb_map(gNB_MAC_INST *mac, } } - bool nr_find_nb_rb(uint16_t Qm, uint16_t R, uint8_t nrOfLayers, @@ -504,7 +557,8 @@ bool nr_find_nb_rb(uint16_t Qm, return *tbs >= bytes && *nb_rb <= nb_rb_max; } -void nr_set_pdsch_semi_static(const NR_ServingCellConfigCommon_t *scc, +void nr_set_pdsch_semi_static(const NR_SIB1_t *sib1, + const NR_ServingCellConfigCommon_t *scc, const NR_CellGroupConfig_t *secondaryCellGroup, const NR_BWP_Downlink_t *bwp, const NR_BWP_DownlinkDedicated_t *bwpd0, @@ -515,55 +569,57 @@ void nr_set_pdsch_semi_static(const NR_ServingCellConfigCommon_t *scc, { bool reset_dmrs = false; - NR_BWP_DownlinkDedicated_t *bwpd; - + NR_BWP_DownlinkDedicated_t *bwpd = NULL; if (bwp && bwp->bwp_Dedicated) { bwpd = bwp->bwp_Dedicated; } else { bwpd = (NR_BWP_DownlinkDedicated_t*)bwpd0; } - if (bwpd->pdsch_Config && - bwpd->pdsch_Config->choice.setup && - bwpd->pdsch_Config->choice.setup->mcs_Table) { - if (*bwpd->pdsch_Config->choice.setup->mcs_Table == 0) - ps->mcsTableIdx = 1; - else - ps->mcsTableIdx = 2; + // Prevent gNB to enable 256QAM table while the RRCProcessing timer is running. + // For example, after the RRC created RRC Reconfiguration message we need to prevent gNB to apply another MCS table + // before the RRC Reconfiguration being received by the UE, otherwise UE will not be able to decode PDSCH + // and the connection will drop. + if (sched_ctrl->rrc_processing_timer == 0) { + if (bwpd && + bwpd->pdsch_Config && + bwpd->pdsch_Config->choice.setup && + bwpd->pdsch_Config->choice.setup->mcs_Table) { + if (*bwpd->pdsch_Config->choice.setup->mcs_Table == 0) { + ps->mcsTableIdx = 1; + } else { + ps->mcsTableIdx = 2; + } + } else { + ps->mcsTableIdx = 0; + } } - else ps->mcsTableIdx = 0; LOG_D(NR_MAC,"MCS Table Index: %d\n",ps->mcsTableIdx); - NR_PDSCH_Config_t *pdsch_Config; - if (bwp && - bwp->bwp_Dedicated && - bwp->bwp_Dedicated->pdsch_Config && - bwp->bwp_Dedicated->pdsch_Config->choice.setup) - pdsch_Config = bwp->bwp_Dedicated->pdsch_Config->choice.setup; - else - pdsch_Config = NULL; - - if (ps->time_domain_allocation != tda) { - reset_dmrs = true; - ps->time_domain_allocation = tda; - const struct NR_PDSCH_TimeDomainResourceAllocationList *tdaList = bwp ? - bwp->bwp_Common->pdsch_ConfigCommon->choice.setup->pdsch_TimeDomainAllocationList : - scc->downlinkConfigCommon->initialDownlinkBWP->pdsch_ConfigCommon->choice.setup->pdsch_TimeDomainAllocationList; - AssertFatal(tda < tdaList->list.count, "time_domain_allocation %d>=%d\n", tda, tdaList->list.count); - ps->mapping_type = tdaList->list.array[tda]->mappingType; - if (pdsch_Config) { - if (ps->mapping_type == NR_PDSCH_TimeDomainResourceAllocation__mappingType_typeB) - ps->dmrsConfigType = pdsch_Config->dmrs_DownlinkForPDSCH_MappingTypeB->choice.setup->dmrs_Type == NULL ? 0 : 1; - else - ps->dmrsConfigType = pdsch_Config->dmrs_DownlinkForPDSCH_MappingTypeA->choice.setup->dmrs_Type == NULL ? 0 : 1; - } + NR_PDSCH_Config_t *pdsch_Config = NULL; + if (bwpd && bwpd->pdsch_Config) pdsch_Config = bwpd->pdsch_Config->choice.setup; + LOG_D(NR_MAC,"tda %d, ps->time_domain_allocation %d,layers %d, ps->nrOfLayers %d, pdsch_config %p\n",tda,ps->time_domain_allocation,layers,ps->nrOfLayers,pdsch_Config); + reset_dmrs = true; + ps->time_domain_allocation = tda; + NR_PDSCH_TimeDomainResourceAllocationList_t *tdaList = get_pdsch_TimeDomainAllocationList(bwp, scc, sib1); + AssertFatal(tda < tdaList->list.count, "time_domain_allocation %d>=%d\n", tda, tdaList->list.count); + ps->mapping_type = tdaList->list.array[tda]->mappingType; + if (pdsch_Config) { + if (ps->mapping_type == NR_PDSCH_TimeDomainResourceAllocation__mappingType_typeB) + ps->dmrsConfigType = pdsch_Config->dmrs_DownlinkForPDSCH_MappingTypeB->choice.setup->dmrs_Type != NULL; else - ps->dmrsConfigType = NFAPI_NR_DMRS_TYPE1; - const int startSymbolAndLength = tdaList->list.array[tda]->startSymbolAndLength; - SLIV2SL(startSymbolAndLength, &ps->startSymbolIndex, &ps->nrOfSymbols); + ps->dmrsConfigType = pdsch_Config->dmrs_DownlinkForPDSCH_MappingTypeA->choice.setup->dmrs_Type != NULL; } + else + ps->dmrsConfigType = NFAPI_NR_DMRS_TYPE1; + const int startSymbolAndLength = tdaList->list.array[tda]->startSymbolAndLength; + SLIV2SL(startSymbolAndLength, &ps->startSymbolIndex, &ps->nrOfSymbols); + + const long f = ((bwp || bwpd) && + sched_ctrl->search_space && + sched_ctrl->search_space->searchSpaceType->present == NR_SearchSpace__searchSpaceType_PR_ue_Specific) ? + sched_ctrl->search_space->searchSpaceType->choice.ue_Specific->dci_Formats : 0; - const long f = sched_ctrl->search_space->searchSpaceType->choice.ue_Specific->dci_Formats; int dci_format; if (sched_ctrl->search_space) { dci_format = f ? NR_DL_DCI_FORMAT_1_1 : NR_DL_DCI_FORMAT_1_0; @@ -581,8 +637,8 @@ void nr_set_pdsch_semi_static(const NR_ServingCellConfigCommon_t *scc, ps->nrOfLayers = 1; } else { - if (ps->nrOfLayers != layers || - ps->numDmrsCdmGrpsNoData == 0) { + LOG_D(NR_MAC,"checking layers\n"); + if (ps->nrOfLayers != layers || ps->numDmrsCdmGrpsNoData == 0) { reset_dmrs = true; ps->nrOfLayers = layers; set_dl_dmrs_ports(ps); @@ -592,33 +648,41 @@ void nr_set_pdsch_semi_static(const NR_ServingCellConfigCommon_t *scc, ps->N_PRB_DMRS = ps->numDmrsCdmGrpsNoData * (ps->dmrsConfigType == NFAPI_NR_DMRS_TYPE1 ? 6 : 4); if (reset_dmrs) { - ps->dl_dmrs_symb_pos = fill_dmrs_mask(bwpd ? bwpd->pdsch_Config->choice.setup : NULL, scc->dmrs_TypeA_Position, ps->nrOfSymbols, ps->startSymbolIndex, ps->mapping_type, ps->frontloaded_symb); + ps->dl_dmrs_symb_pos = fill_dmrs_mask(bwpd ? bwpd->pdsch_Config->choice.setup : NULL, scc ? scc->dmrs_TypeA_Position : 0, ps->nrOfSymbols, ps->startSymbolIndex, ps->mapping_type, ps->frontloaded_symb); ps->N_DMRS_SLOT = get_num_dmrs(ps->dl_dmrs_symb_pos); } LOG_D(NR_MAC,"bwpd0 %p, bwpd %p : Filling dmrs info, ps->N_PRB_DMRS %d, ps->dl_dmrs_symb_pos %x, ps->N_DMRS_SLOT %d\n",bwpd0,bwpd,ps->N_PRB_DMRS,ps->dl_dmrs_symb_pos,ps->N_DMRS_SLOT); } -void nr_set_pusch_semi_static(const NR_ServingCellConfigCommon_t *scc, +void nr_set_pusch_semi_static(const NR_SIB1_t *sib1, + const NR_ServingCellConfigCommon_t *scc, const NR_BWP_Uplink_t *ubwp, const NR_BWP_UplinkDedicated_t *ubwpd, long dci_format, int tda, uint8_t num_dmrs_cdm_grps_no_data, - NR_pusch_semi_static_t *ps) -{ + uint8_t nrOfLayers, + NR_pusch_semi_static_t *ps) { + ps->dci_format = dci_format; ps->time_domain_allocation = tda; - const struct NR_PUSCH_TimeDomainResourceAllocationList *tdaList = - ubwp? - ubwp->bwp_Common->pusch_ConfigCommon->choice.setup->pusch_TimeDomainAllocationList: - scc->uplinkConfigCommon->initialUplinkBWP->pusch_ConfigCommon->choice.setup->pusch_TimeDomainAllocationList ; + NR_PUSCH_TimeDomainResourceAllocationList_t *tdaList = NULL; + if(ubwp) { + tdaList = ubwp->bwp_Common->pusch_ConfigCommon->choice.setup->pusch_TimeDomainAllocationList; + } else if(scc) { + tdaList = scc->uplinkConfigCommon->initialUplinkBWP->pusch_ConfigCommon->choice.setup->pusch_TimeDomainAllocationList; + } else { + tdaList = sib1->servingCellConfigCommon->uplinkConfigCommon->initialUplinkBWP.pusch_ConfigCommon->choice.setup->pusch_TimeDomainAllocationList; + } + const int startSymbolAndLength = tdaList->list.array[tda]->startSymbolAndLength; SLIV2SL(startSymbolAndLength, &ps->startSymbolIndex, &ps->nrOfSymbols); - ps->pusch_Config = ubwp?ubwp->bwp_Dedicated->pusch_Config->choice.setup:(ubwpd ? ubwpd->pusch_Config->choice.setup : NULL); + ps->pusch_Config = ubwp && ubwp->bwp_Dedicated && ubwp->bwp_Dedicated->pusch_Config ? + ubwp->bwp_Dedicated->pusch_Config->choice.setup : (ubwpd ? ubwpd->pusch_Config->choice.setup : NULL); if (ps->pusch_Config == NULL || !ps->pusch_Config->transformPrecoder) ps->transform_precoding = !scc->uplinkConfigCommon->initialUplinkBWP->rach_ConfigCommon->choice.setup->msg3_transformPrecoder; else @@ -641,6 +705,7 @@ void nr_set_pusch_semi_static(const NR_ServingCellConfigCommon_t *scc, num_dmrs_cdm_grps_no_data = 2; // in case of transform precoding - no Data sent in DMRS symbol } + ps->nrOfLayers = nrOfLayers; ps->num_dmrs_cdm_grps_no_data = num_dmrs_cdm_grps_no_data; /* DMRS calculations */ @@ -674,10 +739,55 @@ void nr_set_pusch_semi_static(const NR_ServingCellConfigCommon_t *scc, : num_dmrs_cdm_grps_no_data * 4; } +#define BLER_UPDATE_FRAME 10 +#define BLER_FILTER 0.9f +int get_mcs_from_bler(const NR_bler_options_t *bler_options, + const NR_mac_dir_stats_t *stats, + NR_bler_stats_t *bler_stats, + int max_mcs, + frame_t frame) +{ + /* first call: everything is zero. Initialize to sensible default */ + if (bler_stats->last_frame == 0 && bler_stats->mcs == 0) { + bler_stats->last_frame = frame; + bler_stats->mcs = 9; + bler_stats->bler = (bler_options->lower + bler_options->upper) / 2.0f; + } + int diff = frame - bler_stats->last_frame; + if (diff < 0) // wrap around + diff += 1024; + + max_mcs = min(max_mcs, bler_options->max_mcs); + const uint8_t old_mcs = min(bler_stats->mcs, max_mcs); + if (diff < BLER_UPDATE_FRAME) + return old_mcs; // no update + + // last update is longer than x frames ago + const int dtx = (int)(stats->rounds[0] - bler_stats->rounds[0]); + const int dretx = (int)(stats->rounds[1] - bler_stats->rounds[1]); + const float bler_window = dtx > 0 ? (float) dretx / dtx : bler_stats->bler; + bler_stats->bler = BLER_FILTER * bler_stats->bler + (1 - BLER_FILTER) * bler_window; + + int new_mcs = old_mcs; + if (bler_stats->bler < bler_options->lower && old_mcs < max_mcs && dtx > 9) + new_mcs += 1; + else if ((bler_stats->bler > bler_options->upper && old_mcs > 6) // above threshold + || (dtx <= 3 && old_mcs > 9)) // no activity + new_mcs -= 1; + // else we are within threshold boundaries + + bler_stats->last_frame = frame; + bler_stats->mcs = new_mcs; + memcpy(bler_stats->rounds, stats->rounds, sizeof(stats->rounds)); + LOG_D(MAC, "frame %4d MCS %d -> %d (dtx %d, dretx %d, BLER wnd %.3f avg %.6f)\n", + frame, old_mcs, new_mcs, dtx, dretx, bler_window, bler_stats->bler); + return new_mcs; +} + void nr_configure_css_dci_initial(nfapi_nr_dl_tti_pdcch_pdu_rel15_t* pdcch_pdu, nr_scs_e scs_common, nr_scs_e pdcch_scs, - nr_frequency_range_e freq_range, + frequency_range_t freq_range, uint8_t rmsi_pdcch_config, uint8_t ssb_idx, uint8_t k_ssb, @@ -892,7 +1002,8 @@ void nr_configure_css_dci_initial(nfapi_nr_dl_tti_pdcch_pdu_rel15_t* pdcch_pdu, } -void config_uldci(const NR_BWP_Uplink_t *ubwp, +void config_uldci(const NR_SIB1_t *sib1, + const NR_BWP_Uplink_t *ubwp, const NR_BWP_UplinkDedicated_t *ubwpd, const NR_ServingCellConfigCommon_t *scc, const nfapi_nr_pusch_pdu_t *pusch_pdu, @@ -903,9 +1014,11 @@ void config_uldci(const NR_BWP_Uplink_t *ubwp, int n_ubwp, int bwp_id) { - const int bw = NRRIV2BW(ubwp ? - ubwp->bwp_Common->genericParameters.locationAndBandwidth : - scc->uplinkConfigCommon->initialUplinkBWP->genericParameters.locationAndBandwidth, MAX_BWP_SIZE); + NR_BWP_t *genericParameters = get_ul_bwp_genericParameters((NR_BWP_Uplink_t *)ubwp, + (NR_ServingCellConfigCommon_t *)scc, + (NR_SIB1_t *)sib1); + + const int bw = NRRIV2BW(genericParameters->locationAndBandwidth, MAX_BWP_SIZE); dci_pdu_rel15->frequency_domain_assignment.val = PRBalloc_to_locationandbandwidth0(pusch_pdu->rb_size, pusch_pdu->rb_start, bw); @@ -938,8 +1051,16 @@ void config_uldci(const NR_BWP_Uplink_t *ubwp, "Non Codebook configuration non supported\n"); dci_pdu_rel15->srs_resource_indicator.val = 0; // taking resource 0 for SRS } + dci_pdu_rel15->precoding_information.val= 0; + if (pusch_pdu->nrOfLayers == 2) + dci_pdu_rel15->precoding_information.val = 4; + else if (pusch_pdu->nrOfLayers == 4) + dci_pdu_rel15->precoding_information.val = 11; + + // antenna_ports.val = 0 for transform precoder is disabled, dmrs-Type=1, maxLength=1, Rank=1/2/3/4 // Antenna Ports - dci_pdu_rel15->antenna_ports.val = 0; // TODO for now it is hardcoded, it should depends on cdm group no data and rank + dci_pdu_rel15->antenna_ports.val = 0; + // DMRS sequence initialization dci_pdu_rel15->dmrs_sequence_initialization.val = pusch_pdu->scid; break; @@ -948,11 +1069,14 @@ void config_uldci(const NR_BWP_Uplink_t *ubwp, } LOG_D(NR_MAC, - "%s() ULDCI type 0 payload: freq_alloc %d, time_alloc %d, freq_hop_flag %d, mcs %d tpc %d ndi %d rv %d\n", + "%s() ULDCI type 0 payload: dci_format %d, freq_alloc %d, time_alloc %d, freq_hop_flag %d, precoding_information.val %d antenna_ports.val %d mcs %d tpc %d ndi %d rv %d\n", __func__, + dci_format, dci_pdu_rel15->frequency_domain_assignment.val, dci_pdu_rel15->time_domain_assignment.val, dci_pdu_rel15->frequency_hopping_flag.val, + dci_pdu_rel15->precoding_information.val, + dci_pdu_rel15->antenna_ports.val, dci_pdu_rel15->mcs, dci_pdu_rel15->tpc, dci_pdu_rel15->ndi, @@ -972,8 +1096,6 @@ int nr_get_default_pucch_res(int pucch_ResourceCommon) { return(default_pucch_csset[pucch_ResourceCommon]); } - - void nr_configure_pdcch(nfapi_nr_dl_tti_pdcch_pdu_rel15_t *pdcch_pdu, NR_ControlResourceSet_t *coreset, NR_BWP_t *bwp, @@ -991,7 +1113,7 @@ void nr_configure_pdcch(nfapi_nr_dl_tti_pdcch_pdu_rel15_t *pdcch_pdu, for (int i=0;i<6;i++) pdcch_pdu->FreqDomainResource[i] = coreset->frequencyDomainResources.buf[i]; - LOG_D(MAC,"Coreset : BWPstart %d, BWPsize %d, SCS %d, freq %x, , duration %d, \n", + LOG_D(MAC,"Coreset : BWPstart %d, BWPsize %d, SCS %d, freq %x, , duration %d\n", pdcch_pdu->BWPStart,pdcch_pdu->BWPSize,(int)pdcch_pdu->SubcarrierSpacing,(int)coreset->frequencyDomainResources.buf[0],(int)coreset->duration); pdcch_pdu->CceRegMappingType = pdcch->CceRegMappingType; @@ -1012,9 +1134,24 @@ void nr_configure_pdcch(nfapi_nr_dl_tti_pdcch_pdu_rel15_t *pdcch_pdu, pdcch_pdu->precoderGranularity = coreset->precoderGranularity; } +int nr_get_pucch_resource(NR_ControlResourceSet_t *coreset, + NR_BWP_Uplink_t *bwp, + NR_BWP_UplinkDedicated_t *bwpd, + int CCEIndex) { + int r_pucch = -1; + if(bwp == NULL && bwpd == NULL) { + int n_rb,rb_offset; + get_coreset_rballoc(coreset->frequencyDomainResources.buf,&n_rb,&rb_offset); + const uint16_t N_cce = n_rb * coreset->duration / NR_NB_REG_PER_CCE; + const int delta_PRI=0; + r_pucch = ((CCEIndex<<1)/N_cce)+(delta_PRI<<1); + } + return r_pucch; +} // This function configures pucch pdu fapi structure -void nr_configure_pucch(nfapi_nr_pucch_pdu_t* pucch_pdu, +void nr_configure_pucch(const NR_SIB1_t *sib1, + nfapi_nr_pucch_pdu_t* pucch_pdu, NR_ServingCellConfigCommon_t *scc, NR_CellGroupConfig_t *CellGroup, NR_BWP_Uplink_t *bwp, @@ -1042,7 +1179,13 @@ void nr_configure_pucch(nfapi_nr_pucch_pdu_t* pucch_pdu, uint16_t O_uci = O_csi + O_ack; - NR_PUSCH_Config_t *pusch_Config = bwp ? bwp->bwp_Dedicated->pusch_Config->choice.setup : bwpd->pusch_Config->choice.setup; + NR_PUSCH_Config_t *pusch_Config = NULL; + if(bwp && bwp->bwp_Dedicated && bwp->bwp_Dedicated->pusch_Config) { + pusch_Config = bwp->bwp_Dedicated->pusch_Config->choice.setup; + } else if(bwpd && bwpd->pusch_Config) { + pusch_Config = bwpd->pusch_Config->choice.setup; + } + long *pusch_id = pusch_Config ? pusch_Config->dataScramblingIdentityPUSCH : NULL; if (pusch_Config && pusch_Config->dmrs_UplinkForPUSCH_MappingTypeA != NULL) @@ -1051,9 +1194,15 @@ void nr_configure_pucch(nfapi_nr_pucch_pdu_t* pucch_pdu, id0 = pusch_Config->dmrs_UplinkForPUSCH_MappingTypeB->choice.setup->transformPrecodingDisabled->scramblingID0; else id0 = scc->physCellId; - NR_PUCCH_ConfigCommon_t *pucch_ConfigCommon = bwp ? - bwp->bwp_Common->pucch_ConfigCommon->choice.setup : - scc->uplinkConfigCommon->initialUplinkBWP->pucch_ConfigCommon->choice.setup; + NR_PUCCH_ConfigCommon_t *pucch_ConfigCommon = NULL; + if(bwp) { + pucch_ConfigCommon = bwp->bwp_Common->pucch_ConfigCommon->choice.setup; + } else if(scc) { + pucch_ConfigCommon = scc->uplinkConfigCommon->initialUplinkBWP->pucch_ConfigCommon->choice.setup; + } else { + pucch_ConfigCommon = sib1->servingCellConfigCommon->uplinkConfigCommon->initialUplinkBWP.pucch_ConfigCommon->choice.setup; + } + // hop flags and hopping id are valid for any BWP switch (pucch_ConfigCommon->pucch_GroupHopping){ case 0 : @@ -1079,9 +1228,9 @@ void nr_configure_pucch(nfapi_nr_pucch_pdu_t* pucch_pdu, pucch_pdu->hopping_id = *pucch_ConfigCommon->hoppingId; else pucch_pdu->hopping_id = *scc->physCellId; - NR_BWP_t *genericParameters = bwp ? - &bwp->bwp_Common->genericParameters: - &scc->uplinkConfigCommon->initialUplinkBWP->genericParameters; + + NR_BWP_t *genericParameters = get_ul_bwp_genericParameters(bwp,scc, sib1); + pucch_pdu->bwp_size = NRRIV2BW(genericParameters->locationAndBandwidth, MAX_BWP_SIZE); pucch_pdu->bwp_start = NRRIV2PRBOFFSET(genericParameters->locationAndBandwidth,MAX_BWP_SIZE); pucch_pdu->subcarrier_spacing = genericParameters->subcarrierSpacing; @@ -1090,9 +1239,8 @@ void nr_configure_pucch(nfapi_nr_pucch_pdu_t* pucch_pdu, LOG_D(NR_MAC,"pucch_acknak: Filling dedicated configuration for PUCCH\n"); // we have either a dedicated BWP or Dedicated PUCCH configuration on InitialBWP AssertFatal(bwp!=NULL || bwpd!=NULL,"We need one dedicated configuration for a BWP (neither additional or initial BWP has a dedicated configuration)\n"); - pucch_Config = bwp ? - bwp->bwp_Dedicated->pucch_Config->choice.setup: - bwpd->pucch_Config->choice.setup; + pucch_Config = bwp && bwp->bwp_Dedicated && bwp->bwp_Dedicated->pucch_Config ? + bwp->bwp_Dedicated->pucch_Config->choice.setup : bwpd->pucch_Config->choice.setup; AssertFatal(pucch_Config->resourceSetToAddModList!=NULL, "PUCCH resourceSetToAddModList is null\n"); @@ -1231,27 +1379,31 @@ void nr_configure_pucch(nfapi_nr_pucch_pdu_t* pucch_pdu, } } AssertFatal(res_found==1,"No PUCCH resource found corresponding to id %ld\n",*resource_id); + LOG_D(NR_MAC,"Configure pucch: pucch_pdu->format_type %d pucch_pdu->bit_len_harq %d, pucch->pdu->bit_len_csi %d\n",pucch_pdu->format_type,pucch_pdu->bit_len_harq,pucch_pdu->bit_len_csi_part1); } else { // this is the default PUCCH configuration, PUCCH format 0 or 1 LOG_D(NR_MAC,"pucch_acknak: Filling default PUCCH configuration from Tables (r_pucch %d, bwp %p)\n",r_pucch,bwp); int rsetindex = *scc->uplinkConfigCommon->initialUplinkBWP->pucch_ConfigCommon->choice.setup->pucch_ResourceCommon; - int prboffset = r_pucch/default_pucch_csset[rsetindex]; - int prboffsetm8 = (r_pucch-8)/default_pucch_csset[rsetindex]; - pucch_pdu->prb_start = (r_pucch>>3)==0 ? - default_pucch_prboffset[rsetindex] + prboffset: - pucch_pdu->bwp_size-1-default_pucch_prboffset[rsetindex]-prboffsetm8; + int prb_start, second_hop_prb, nr_of_symb, start_symb; + set_r_pucch_parms(rsetindex, + r_pucch, + pucch_pdu->bwp_size, + &prb_start, + &second_hop_prb, + &nr_of_symb, + &start_symb); + + pucch_pdu->prb_start = prb_start; pucch_pdu->rnti = rnti; pucch_pdu->freq_hop_flag = 1; - pucch_pdu->second_hop_prb = (r_pucch>>3)==0? - pucch_pdu->bwp_size-1-default_pucch_prboffset[rsetindex]-prboffset: - default_pucch_prboffset[rsetindex] + prboffsetm8; + pucch_pdu->second_hop_prb = second_hop_prb; pucch_pdu->format_type = default_pucch_fmt[rsetindex]; pucch_pdu->initial_cyclic_shift = r_pucch%default_pucch_csset[rsetindex]; if (rsetindex==3||rsetindex==7||rsetindex==11) pucch_pdu->initial_cyclic_shift*=6; else if (rsetindex==1||rsetindex==2) pucch_pdu->initial_cyclic_shift*=3; else pucch_pdu->initial_cyclic_shift*=4; - pucch_pdu->nr_of_symbols = default_pucch_numbsymb[rsetindex]; - pucch_pdu->start_symbol_index = default_pucch_firstsymb[rsetindex]; + pucch_pdu->nr_of_symbols = nr_of_symb; + pucch_pdu->start_symbol_index = start_symb; if (pucch_pdu->format_type == 1) pucch_pdu->time_domain_occ_idx = 0; // check this!! pucch_pdu->sr_flag = O_sr; pucch_pdu->prb_size=1; @@ -1259,6 +1411,32 @@ void nr_configure_pucch(nfapi_nr_pucch_pdu_t* pucch_pdu, } +void set_r_pucch_parms(int rsetindex, + int r_pucch, + int bwp_size, + int *prb_start, + int *second_hop_prb, + int *nr_of_symbols, + int *start_symbol_index) { + + // procedure described in 38.213 section 9.2.1 + + int prboffset = r_pucch/default_pucch_csset[rsetindex]; + int prboffsetm8 = (r_pucch-8)/default_pucch_csset[rsetindex]; + + *prb_start = (r_pucch>>3)==0 ? + default_pucch_prboffset[rsetindex] + prboffset: + bwp_size-1-default_pucch_prboffset[rsetindex]-prboffsetm8; + + *second_hop_prb = (r_pucch>>3)==0? + bwp_size-1-default_pucch_prboffset[rsetindex]-prboffset: + default_pucch_prboffset[rsetindex] + prboffsetm8; + + *nr_of_symbols = default_pucch_numbsymb[rsetindex]; + *start_symbol_index = default_pucch_firstsymb[rsetindex]; +} + + void prepare_dci(const NR_CellGroupConfig_t *CellGroup, dci_pdu_rel15_t *dci_pdu_rel15, nr_dci_format_t format, @@ -1358,12 +1536,14 @@ void fill_dci_pdu_rel15(const NR_ServingCellConfigCommon_t *scc, int dci_format, int rnti_type, int N_RB, - int bwp_id) { + int bwp_id, + NR_ControlResourceSetId_t coreset_id, + uint16_t cset0_bwp_size) { uint8_t fsize = 0, pos = 0; uint64_t *dci_pdu = (uint64_t *)pdcch_dci_pdu->Payload; *dci_pdu=0; - int dci_size = nr_dci_size(scc->downlinkConfigCommon->initialDownlinkBWP,scc->uplinkConfigCommon->initialUplinkBWP, CellGroup, dci_pdu_rel15, dci_format, rnti_type, N_RB, bwp_id); + int dci_size = nr_dci_size(scc->downlinkConfigCommon->initialDownlinkBWP,scc->uplinkConfigCommon->initialUplinkBWP, CellGroup, dci_pdu_rel15, dci_format, rnti_type, N_RB, bwp_id, coreset_id, cset0_bwp_size); pdcch_dci_pdu->PayloadSizeBits = dci_size; AssertFatal(dci_size <= 64, "DCI sizes above 64 bits not yet supported"); if (dci_format == NR_DL_DCI_FORMAT_1_1 || dci_format == NR_UL_DCI_FORMAT_0_1) @@ -1707,7 +1887,7 @@ void fill_dci_pdu_rel15(const NR_ServingCellConfigCommon_t *scc, pos+=4; *dci_pdu |= ((uint64_t)dci_pdu_rel15->harq_pid & 0xf) << (dci_size - pos); // Padding bits - for (int a = pos; a < 32; a++) + for (int a = pos; a < dci_size; a++) *dci_pdu |= ((uint64_t)dci_pdu_rel15->padding & 1) << (dci_size - pos++); // UL/SUL indicator – 1 bit /* commented for now (RK): need to get this from BWP descriptor @@ -1931,10 +2111,11 @@ int extract_length(int startSymbolAndLength) { /* * Dump the UL or DL UE_info into LOG_T(MAC) */ -void dump_nr_list(NR_list_t *listP) +void dump_nr_list(NR_UE_info_t **list) { - for (int j = listP->head; j >= 0; j = listP->next[j]) - LOG_T(NR_MAC, "NR list node %d => %d\n", j, listP->next[j]); + UE_iterator(list, UE) { + LOG_T(NR_MAC, "NR list UEs rntis %04x\n", (*list)->rnti); + } } /* @@ -2063,35 +2244,17 @@ void remove_front_nr_list(NR_list_t *listP) listP->tail = -1; } -int find_nr_UE_id(module_id_t mod_idP, rnti_t rntiP) -//------------------------------------------------------------------------------ +NR_UE_info_t *find_nr_UE(NR_UEs_t *UEs, rnti_t rntiP) { - int UE_id; - NR_UE_info_t *UE_info = &RC.nrmac[mod_idP]->UE_info; - for (UE_id = 0; UE_id < MAX_MOBILES_PER_GNB; UE_id++) { - if (UE_info->active[UE_id]) { - if (UE_info->rnti[UE_id] == rntiP) { - return UE_id; - } + UE_iterator(UEs->list, UE) { + if (UE->rnti == rntiP) { + LOG_D(NR_MAC,"Search and found rnti: %04x\n", rntiP); + return UE; } } - - return -1; -} - -uint16_t get_Y(int cid, int slot, rnti_t rnti) { - - const int A[3] = {39827, 39829, 39839}; - const int D = 65537; - int Y; - - Y = (A[cid] * rnti) % D; - - for (int s = 0; s < slot; s++) - Y = (A[cid] * Y) % D; - - return Y; + LOG_W(NR_MAC,"Search for not existing rnti (ignore for RA): %04x\n", rntiP); + return NULL; } int find_nr_RA_id(module_id_t mod_idP, int CC_idP, rnti_t rntiP) { @@ -2150,40 +2313,86 @@ int get_ul_bwp_id(const NR_ServingCellConfig_t *servingCellConfig) return 1; } -//------------------------------------------------------------------------------ -int add_new_nr_ue(module_id_t mod_idP, rnti_t rntiP, NR_CellGroupConfig_t *CellGroup) -{ - NR_ServingCellConfigCommon_t *scc = RC.nrmac[mod_idP]->common_channels[0].ServingCellConfigCommon; - NR_UE_info_t *UE_info = &RC.nrmac[mod_idP]->UE_info; - LOG_I(NR_MAC, "[gNB %d] Adding UE with rnti 0x%04x (num_UEs %d)\n", - mod_idP, - rntiP, - UE_info->num_UEs); - dump_nr_list(&UE_info->list); +/* hack data to remove UE in the phy */ +int rnti_to_remove[10]; +volatile int rnti_to_remove_count; +pthread_mutex_t rnti_to_remove_mutex = PTHREAD_MUTEX_INITIALIZER; - for (int i = 0; i < MAX_MOBILES_PER_GNB; i++) { - if (UE_info->active[i]) { - LOG_D(NR_MAC,"UE %x is active, skipping\n",rntiP); - continue; +void delete_nr_ue_data(NR_UE_info_t *UE, NR_COMMON_channels_t *ccPtr) +{ + NR_UE_sched_ctrl_t *sched_ctrl = &UE->UE_sched_ctrl; + destroy_nr_list(&sched_ctrl->available_dl_harq); + destroy_nr_list(&sched_ctrl->feedback_dl_harq); + destroy_nr_list(&sched_ctrl->retrans_dl_harq); + destroy_nr_list(&sched_ctrl->available_ul_harq); + destroy_nr_list(&sched_ctrl->feedback_ul_harq); + destroy_nr_list(&sched_ctrl->retrans_ul_harq); + LOG_I(NR_MAC, "Remove NR rnti 0x%04x\n", UE->rnti); + const rnti_t rnti = UE->rnti; + free(UE); + /* hack to remove UE in the phy */ + if (pthread_mutex_lock(&rnti_to_remove_mutex)) + exit(1); + if (rnti_to_remove_count == 10) + exit(1); + rnti_to_remove[rnti_to_remove_count] = rnti; + LOG_W(NR_MAC, "to remove in mac rnti_to_remove[%d] = 0x%04x\n", rnti_to_remove_count, rnti); + rnti_to_remove_count++; + if (pthread_mutex_unlock(&rnti_to_remove_mutex)) + exit(1); + + /* clear RA process(es?) associated to the UE */ + for (int cc_id = 0; cc_id < NFAPI_CC_MAX; cc_id++) { + for (int i = 0; i < NR_NB_RA_PROC_MAX; i++) { + NR_COMMON_channels_t *cc = &ccPtr[cc_id]; + if (cc->ra[i].rnti == rnti) { + LOG_D(NR_MAC, "free RA process %d for rnti %04x\n", i, rnti); + /* is it enough? */ + cc->ra[i].cfra = false; + cc->ra[i].rnti = 0; + cc->ra[i].crnti = 0; + } } - int UE_id = i; - UE_info->num_UEs++; - UE_info->active[UE_id] = true; - if (CellGroup) UE_info->Msg4_ACKed[UE_id] = true; - else UE_info->Msg4_ACKed[UE_id] = false; - UE_info->rnti[UE_id] = rntiP; - UE_info->CellGroup[UE_id] = CellGroup; - add_nr_list(&UE_info->list, UE_id); - memset(&UE_info->mac_stats[UE_id], 0, sizeof(NR_mac_stats_t)); - if (CellGroup && CellGroup->spCellConfig && CellGroup->spCellConfig->spCellConfigDedicated) - compute_csi_bitlen (CellGroup->spCellConfig->spCellConfigDedicated->csi_MeasConfig->choice.setup, UE_info, UE_id, mod_idP); - NR_UE_sched_ctrl_t *sched_ctrl = &UE_info->UE_sched_ctrl[UE_id]; + } +} + +//------------------------------------------------------------------------------ +NR_UE_info_t *add_new_nr_ue(gNB_MAC_INST *nr_mac, rnti_t rntiP, NR_CellGroupConfig_t *CellGroup) +{ + NR_ServingCellConfigCommon_t *scc = nr_mac->common_channels[0].ServingCellConfigCommon; + NR_UEs_t *UE_info = &nr_mac->UE_info; + LOG_I(NR_MAC, "Adding UE with rnti 0x%04x\n", + rntiP); + dump_nr_list(UE_info->list); + + // We will attach at the end, to mitigate race conditions + // This is not good, but we will fix it progressively + NR_UE_info_t *UE=calloc(1,sizeof(NR_UE_info_t)); + if(!UE) { + LOG_E(NR_MAC,"want to add UE %04x but the fixed allocated size is full\n",rntiP); + return NULL; + } + + UE->rnti = rntiP; + UE->CellGroup = CellGroup; + + if (CellGroup) + UE->Msg4_ACKed = true; + else + UE->Msg4_ACKed = false; + + if (CellGroup && + CellGroup->spCellConfig && + CellGroup->spCellConfig->spCellConfigDedicated && + CellGroup->spCellConfig->spCellConfigDedicated->csi_MeasConfig && + CellGroup->spCellConfig->spCellConfigDedicated->csi_MeasConfig->choice.setup) { + compute_csi_bitlen(CellGroup->spCellConfig->spCellConfigDedicated->csi_MeasConfig->choice.setup, UE); + } + + NR_UE_sched_ctrl_t *sched_ctrl = &UE->UE_sched_ctrl; memset(sched_ctrl, 0, sizeof(*sched_ctrl)); - sched_ctrl->set_mcs = TRUE; - sched_ctrl->lcid_mask = 0; - if (!get_softmodem_params()->phy_test && !get_softmodem_params()->do_ra && !get_softmodem_params()->sa) { - sched_ctrl->lcid_mask = 1<dl_max_mcs = 28; /* do not limit MCS for individual UEs */ + sched_ctrl->set_pmi = false; sched_ctrl->ta_frame = 0; sched_ctrl->ta_update = 31; sched_ctrl->ta_apply = false; @@ -2191,7 +2400,6 @@ int add_new_nr_ue(module_id_t mod_idP, rnti_t rntiP, NR_CellGroupConfig_t *CellG sched_ctrl->pucch_consecutive_dtx_cnt = 0; sched_ctrl->pusch_consecutive_dtx_cnt = 0; sched_ctrl->ul_failure = 0; - sched_ctrl->sched_srs.frame = -1; sched_ctrl->sched_srs.slot = -1; sched_ctrl->sched_srs.srs_scheduled = false; @@ -2199,13 +2407,10 @@ int add_new_nr_ue(module_id_t mod_idP, rnti_t rntiP, NR_CellGroupConfig_t *CellG /* set illegal time domain allocation to force recomputation of all fields */ sched_ctrl->pdsch_semi_static.time_domain_allocation = -1; sched_ctrl->pusch_semi_static.time_domain_allocation = -1; - const NR_ServingCellConfig_t *servingCellConfig = CellGroup ? CellGroup->spCellConfig->spCellConfigDedicated : NULL; + const NR_ServingCellConfig_t *servingCellConfig = CellGroup && CellGroup->spCellConfig ? CellGroup->spCellConfig->spCellConfigDedicated : NULL; - /* Set default BWPs */ - const struct NR_ServingCellConfig__downlinkBWP_ToAddModList *bwpList = servingCellConfig ? servingCellConfig->downlinkBWP_ToAddModList : NULL; - if (bwpList) AssertFatal(bwpList->list.count == 1, - "downlinkBWP_ToAddModList has %d BWP!\n", - bwpList->list.count); + /* Set default BWPs */ + const struct NR_ServingCellConfig__downlinkBWP_ToAddModList *bwpList = servingCellConfig ? servingCellConfig->downlinkBWP_ToAddModList : NULL; const int bwp_id = servingCellConfig ? *servingCellConfig->firstActiveDownlinkBWP_Id : 0; sched_ctrl->active_bwp = bwpList && bwp_id > 0 ? bwpList->list.array[bwp_id - 1] : NULL; @@ -2213,29 +2418,37 @@ int add_new_nr_ue(module_id_t mod_idP, rnti_t rntiP, NR_CellGroupConfig_t *CellG &sched_ctrl->active_bwp->bwp_Common->genericParameters: &scc->uplinkConfigCommon->initialUplinkBWP->genericParameters; const int target_ss = sched_ctrl->active_bwp ? NR_SearchSpace__searchSpaceType_PR_ue_Specific : NR_SearchSpace__searchSpaceType_PR_common; - sched_ctrl->search_space = get_searchspace(scc, + const NR_SIB1_t *sib1 = nr_mac->common_channels[0].sib1 ? nr_mac->common_channels[0].sib1->message.choice.c1->choice.systemInformationBlockType1 : NULL; + sched_ctrl->search_space = get_searchspace(sib1, + scc, sched_ctrl->active_bwp ? sched_ctrl->active_bwp->bwp_Dedicated : NULL, target_ss); - sched_ctrl->coreset = get_coreset(mod_idP, scc, - sched_ctrl->active_bwp ? (void*)sched_ctrl->active_bwp->bwp_Dedicated : NULL, - sched_ctrl->search_space, target_ss); - sched_ctrl->sched_pdcch = set_pdcch_structure(RC.nrmac[mod_idP], + sched_ctrl->coreset = get_coreset(nr_mac, + scc, + sched_ctrl->active_bwp ? sched_ctrl->active_bwp->bwp_Dedicated : NULL, + sched_ctrl->search_space, + target_ss); + sched_ctrl->sched_pdcch = set_pdcch_structure(nr_mac, sched_ctrl->search_space, sched_ctrl->coreset, scc, genericParameters, NULL); + sched_ctrl->next_dl_bwp_id = -1; + sched_ctrl->next_ul_bwp_id = -1; const struct NR_UplinkConfig__uplinkBWP_ToAddModList *ubwpList = servingCellConfig ? servingCellConfig->uplinkConfig->uplinkBWP_ToAddModList : NULL; - if (ubwpList) AssertFatal(ubwpList->list.count == 1, + if (ubwpList) + AssertFatal(ubwpList->list.count <= NR_MAX_NUM_BWP, "uplinkBWP_ToAddModList has %d BWP!\n", ubwpList->list.count); const int ul_bwp_id = servingCellConfig ? *servingCellConfig->uplinkConfig->firstActiveUplinkBWP_Id : 0; sched_ctrl->active_ubwp = ubwpList && ul_bwp_id > 0 ? ubwpList->list.array[ul_bwp_id - 1] : NULL; /* get Number of HARQ processes for this UE */ - if (servingCellConfig) AssertFatal(servingCellConfig->pdsch_ServingCellConfig->present == NR_SetupRelease_PDSCH_ServingCellConfig_PR_setup, - "no pdsch-ServingCellConfig found for UE %d\n", - UE_id); + if (servingCellConfig) + AssertFatal(servingCellConfig->pdsch_ServingCellConfig->present == NR_SetupRelease_PDSCH_ServingCellConfig_PR_setup, + "no pdsch-ServingCellConfig found for UE %04x\n", + UE->rnti); const NR_PDSCH_ServingCellConfig_t *pdsch = servingCellConfig ? servingCellConfig->pdsch_ServingCellConfig->choice.setup : NULL; // pdsch == NULL in SA -> will create default (8) number of HARQ processes create_dl_harq_list(sched_ctrl, pdsch); @@ -2246,21 +2459,27 @@ int add_new_nr_ue(module_id_t mod_idP, rnti_t rntiP, NR_CellGroupConfig_t *CellG add_tail_nr_list(&sched_ctrl->available_ul_harq, harq); create_nr_list(&sched_ctrl->feedback_ul_harq, 16); create_nr_list(&sched_ctrl->retrans_ul_harq, 16); - LOG_D(NR_MAC, "[gNB %d] Add NR UE_id %d : rnti %x\n", - mod_idP, - UE_id, - rntiP); - dump_nr_list(&UE_info->list); - return (UE_id); + + pthread_mutex_lock(&UE_info->mutex); + int i; + for(i=0; ilist[i] == NULL) { + UE_info->list[i] = UE; + break; + } + if (i == MAX_MOBILES_PER_GNB) { + LOG_E(NR_MAC,"Try to add UE %04x but the list is full\n", rntiP); + delete_nr_ue_data(UE, nr_mac->common_channels); + pthread_mutex_unlock(&UE_info->mutex); + return NULL; } + pthread_mutex_unlock(&UE_info->mutex); - // printf("MAC: cannot add new UE for rnti %x\n", rntiP); - LOG_E(NR_MAC, "error in add_new_ue(), could not find space in UE_info, Dumping UE list\n"); - dump_nr_list(&UE_info->list); - return -1; + LOG_D(NR_MAC, "Add NR rnti %x\n", rntiP); + dump_nr_list(UE_info->list); + return (UE); } - void create_dl_harq_list(NR_UE_sched_ctrl_t *sched_ctrl, const NR_PDSCH_ServingCellConfig_t *pdsch) { const int nrofHARQ = pdsch && pdsch->nrofHARQ_ProcessesForPDSCH ? @@ -2293,66 +2512,30 @@ void create_dl_harq_list(NR_UE_sched_ctrl_t *sched_ctrl, } } -/* hack data to remove UE in the phy */ -int rnti_to_remove[10]; -volatile int rnti_to_remove_count; -pthread_mutex_t rnti_to_remove_mutex = PTHREAD_MUTEX_INITIALIZER; - -void mac_remove_nr_ue(module_id_t mod_id, rnti_t rnti) +void mac_remove_nr_ue(gNB_MAC_INST *nr_mac, rnti_t rnti) { - int UE_id; - int i; - int cc_id; - NR_UE_info_t *UE_info = &RC.nrmac[mod_id]->UE_info; + NR_UEs_t *UE_info = &nr_mac->UE_info; + pthread_mutex_lock(&UE_info->mutex); + UE_iterator(UE_info->list, UE) { + if (UE->rnti==rnti) + break; + } - for (i = 0; i < MAX_MOBILES_PER_GNB; i++) { + if (!UE) { + LOG_W(NR_MAC,"Call to del rnti %04x, but not existing\n", rnti); + pthread_mutex_unlock(&UE_info->mutex); + return; + } - if (UE_info->active[i] != TRUE) - continue; - if (UE_info->rnti[i] != rnti) - continue; + NR_UE_info_t * newUEs[MAX_MOBILES_PER_GNB+1]={0}; + int newListIdx=0; + for (int i=0; ilist[i] && UE_info->list[i]->rnti != rnti) + newUEs[newListIdx++]=UE_info->list[i]; + memcpy(UE_info->list, newUEs, sizeof(UE_info->list)); + pthread_mutex_unlock(&UE_info->mutex); - /* UE found, remove it */ - UE_id = i; - - UE_info->num_UEs--; - UE_info->active[UE_id] = FALSE; - UE_info->rnti[UE_id] = 0; - remove_nr_list(&UE_info->list, UE_id); - NR_UE_sched_ctrl_t *sched_ctrl = &UE_info->UE_sched_ctrl[UE_id]; - destroy_nr_list(&sched_ctrl->available_dl_harq); - destroy_nr_list(&sched_ctrl->feedback_dl_harq); - destroy_nr_list(&sched_ctrl->retrans_dl_harq); - destroy_nr_list(&sched_ctrl->available_ul_harq); - destroy_nr_list(&sched_ctrl->feedback_ul_harq); - destroy_nr_list(&sched_ctrl->retrans_ul_harq); - LOG_I(NR_MAC, "[gNB %d] Remove NR UE_id %d: rnti 0x%04x\n", - mod_id, - UE_id, - rnti); - - /* hack to remove UE in the phy */ - if (pthread_mutex_lock(&rnti_to_remove_mutex)) exit(1); - if (rnti_to_remove_count == 10) exit(1); - rnti_to_remove[rnti_to_remove_count] = rnti; - LOG_W(NR_MAC, "to remove in mac rnti_to_remove[%d] = 0x%04x\n", rnti_to_remove_count, rnti); - rnti_to_remove_count++; - if (pthread_mutex_unlock(&rnti_to_remove_mutex)) exit(1); - } - - /* clear RA process(es?) associated to the UE */ - for (cc_id = 0; cc_id < NFAPI_CC_MAX; cc_id++) { - NR_COMMON_channels_t *cc = &RC.nrmac[mod_id]->common_channels[cc_id]; - for (i = 0; i < NR_NB_RA_PROC_MAX; i++) { - if (cc->ra[i].rnti == rnti) { - LOG_D(NR_MAC, "free RA process %d for rnti %d\n", i, rnti); - /* is it enough? */ - cc->ra[i].cfra = false; - cc->ra[i].rnti = 0; - cc->ra[i].crnti = 0; - } - } - } + delete_nr_ue_data(UE, nr_mac->common_channels); } void nr_mac_remove_ra_rnti(module_id_t mod_id, rnti_t rnti) { @@ -2376,20 +2559,18 @@ uint8_t nr_get_tpc(int target, uint8_t cqi, int incr) { } -void get_pdsch_to_harq_feedback(int Mod_idP, - int UE_id, +void get_pdsch_to_harq_feedback(NR_UE_info_t *UE, int bwp_id, NR_SearchSpace__searchSpaceType_PR ss_type, int *max_fb_time, uint8_t *pdsch_to_harq_feedback) { - NR_UE_info_t *UE_info = &RC.nrmac[Mod_idP]->UE_info; - NR_CellGroupConfig_t *CellGroup = UE_info->CellGroup[UE_id]; + NR_CellGroupConfig_t *CellGroup = UE->CellGroup; NR_BWP_DownlinkDedicated_t *bwpd=NULL; NR_BWP_UplinkDedicated_t *ubwpd=NULL; if (ss_type == NR_SearchSpace__searchSpaceType_PR_ue_Specific) { - AssertFatal(CellGroup!=NULL,"Cellgroup is not defined for UE_id %d\n",UE_id); + AssertFatal(CellGroup!=NULL,"Cellgroup is not defined for UE %04x\n",UE->rnti); AssertFatal(CellGroup->spCellConfig!=NULL,"Cellgroup->spCellConfig is null\n"); AssertFatal(CellGroup->spCellConfig->spCellConfigDedicated!=NULL,"CellGroup->spCellConfig->spCellConfigDedicated is null\n"); } @@ -2408,7 +2589,7 @@ void get_pdsch_to_harq_feedback(int Mod_idP, bwpd = CellGroup->spCellConfig->spCellConfigDedicated->downlinkBWP_ToAddModList->list.array[bwp_id-1]->bwp_Dedicated; ubwpd = CellGroup->spCellConfig->spCellConfigDedicated->uplinkConfig->uplinkBWP_ToAddModList->list.array[bwp_id-1]->bwp_Dedicated; } - else if (CellGroup) { // this is an initialBWP + else if (CellGroup && CellGroup->spCellConfig && CellGroup->spCellConfig->spCellConfigDedicated) { // this is an initialBWP AssertFatal((bwpd=CellGroup->spCellConfig->spCellConfigDedicated->initialDownlinkBWP)!=NULL, "CellGroup->spCellConfig->spCellConfigDedicated->initialDownlinkBWP is null\n"); AssertFatal((ubwpd=CellGroup->spCellConfig->spCellConfigDedicated->uplinkConfig->initialUplinkBWP)!=NULL, @@ -2447,7 +2628,6 @@ void get_pdsch_to_harq_feedback(int Mod_idP, pdsch_to_harq_feedback[i] = i+1; if(pdsch_to_harq_feedback[i]>*max_fb_time) *max_fb_time = pdsch_to_harq_feedback[i]; - } } else { @@ -2465,23 +2645,25 @@ void get_pdsch_to_harq_feedback(int Mod_idP, } } - - void nr_csirs_scheduling(int Mod_idP, frame_t frame, sub_frame_t slot, int n_slots_frame){ int CC_id = 0; - NR_UE_info_t *UE_info = &RC.nrmac[Mod_idP]->UE_info; - NR_list_t *UE_list = &UE_info->list; + NR_UEs_t *UE_info = &RC.nrmac[Mod_idP]->UE_info; gNB_MAC_INST *gNB_mac = RC.nrmac[Mod_idP]; uint16_t *vrb_map = gNB_mac->common_channels[CC_id].vrb_map; - for (int UE_id = UE_list->head; UE_id >= 0; UE_id = UE_list->next[UE_id]) { + UE_info->sched_csirs = false; - NR_UE_sched_ctrl_t *sched_ctrl = &UE_info->UE_sched_ctrl[UE_id]; - NR_CellGroupConfig_t *CellGroup = UE_info->CellGroup[UE_id]; + UE_iterator(UE_info->list, UE) { + + NR_UE_sched_ctrl_t *sched_ctrl = &UE->UE_sched_ctrl; + if (sched_ctrl->rrc_processing_timer > 0) { + continue; + } + NR_CellGroupConfig_t *CellGroup = UE->CellGroup; if (!CellGroup || !CellGroup->spCellConfig || !CellGroup->spCellConfig->spCellConfigDedicated || !CellGroup->spCellConfig->spCellConfigDedicated->csi_MeasConfig) continue; @@ -2494,7 +2676,9 @@ void nr_csirs_scheduling(int Mod_idP, int period, offset; nfapi_nr_dl_tti_request_body_t *dl_req = &gNB_mac->DL_req[CC_id].dl_tti_request_body; - NR_BWP_Downlink_t *bwp=CellGroup->spCellConfig->spCellConfigDedicated->downlinkBWP_ToAddModList->list.array[sched_ctrl->active_bwp->bwp_Id-1]; + NR_BWP_t *genericParameters = sched_ctrl->active_bwp ? + &sched_ctrl->active_bwp->bwp_Common->genericParameters : + &gNB_mac->common_channels[0].ServingCellConfigCommon->downlinkConfigCommon->initialDownlinkBWP->genericParameters; for (int id = 0; id < csi_measconfig->nzp_CSI_RS_ResourceToAddModList->list.count; id++){ nzpcsi = csi_measconfig->nzp_CSI_RS_ResourceToAddModList->list.array[id]; @@ -2503,7 +2687,8 @@ void nr_csirs_scheduling(int Mod_idP, if((frame*n_slots_frame+slot-offset)%period == 0) { - LOG_D(MAC,"Scheduling CSI-RS in frame %d slot %d\n",frame,slot); + LOG_D(NR_MAC,"Scheduling CSI-RS in frame %d slot %d\n",frame,slot); + UE_info->sched_csirs = true; nfapi_nr_dl_tti_request_pdu_t *dl_tti_csirs_pdu = &dl_req->dl_tti_pdu_list[dl_req->nPDUs]; memset((void*)dl_tti_csirs_pdu,0,sizeof(nfapi_nr_dl_tti_request_pdu_t)); @@ -2512,16 +2697,27 @@ void nr_csirs_scheduling(int Mod_idP, nfapi_nr_dl_tti_csi_rs_pdu_rel15_t *csirs_pdu_rel15 = &dl_tti_csirs_pdu->csi_rs_pdu.csi_rs_pdu_rel15; - csirs_pdu_rel15->bwp_size = NRRIV2BW(bwp->bwp_Common->genericParameters.locationAndBandwidth,275); - csirs_pdu_rel15->bwp_start = NRRIV2PRBOFFSET(bwp->bwp_Common->genericParameters.locationAndBandwidth,275); - csirs_pdu_rel15->subcarrier_spacing = bwp->bwp_Common->genericParameters.subcarrierSpacing; - if (bwp->bwp_Common->genericParameters.cyclicPrefix) - csirs_pdu_rel15->cyclic_prefix = *bwp->bwp_Common->genericParameters.cyclicPrefix; + csirs_pdu_rel15->subcarrier_spacing = genericParameters->subcarrierSpacing; + if (genericParameters->cyclicPrefix) + csirs_pdu_rel15->cyclic_prefix = *genericParameters->cyclicPrefix; else csirs_pdu_rel15->cyclic_prefix = 0; - csirs_pdu_rel15->start_rb = resourceMapping.freqBand.startingRB; - csirs_pdu_rel15->nr_of_rbs = resourceMapping.freqBand.nrofRBs; + // According to last paragraph of TS 38.214 5.2.2.3.1 + uint16_t BWPSize = NRRIV2BW(genericParameters->locationAndBandwidth, MAX_BWP_SIZE); + uint16_t BWPStart = NRRIV2PRBOFFSET(genericParameters->locationAndBandwidth, MAX_BWP_SIZE); + if (resourceMapping.freqBand.startingRB < BWPStart) { + csirs_pdu_rel15->start_rb = BWPStart; + } else { + csirs_pdu_rel15->start_rb = resourceMapping.freqBand.startingRB; + } + if (resourceMapping.freqBand.nrofRBs > (BWPStart + BWPSize - csirs_pdu_rel15->start_rb)) { + csirs_pdu_rel15->nr_of_rbs = BWPStart + BWPSize - csirs_pdu_rel15->start_rb; + } else { + csirs_pdu_rel15->nr_of_rbs = resourceMapping.freqBand.nrofRBs; + } + AssertFatal(csirs_pdu_rel15->nr_of_rbs >= 24, "CSI-RS has %d RBs, but the minimum is 24\n", csirs_pdu_rel15->nr_of_rbs); + csirs_pdu_rel15->csi_type = 1; // NZP-CSI-RS csirs_pdu_rel15->symb_l0 = resourceMapping.firstOFDMSymbolInTimeDomain; if (resourceMapping.firstOFDMSymbolInTimeDomain2) @@ -2542,20 +2738,20 @@ void nr_csirs_scheduling(int Mod_idP, csirs_pdu_rel15->row = 1; csirs_pdu_rel15->freq_domain = ((resourceMapping.frequencyDomainAllocation.choice.row1.buf[0])>>4)&0x0f; for (int rb = csirs_pdu_rel15->start_rb; rb < (csirs_pdu_rel15->start_rb + csirs_pdu_rel15->nr_of_rbs); rb++) - vrb_map[rb+csirs_pdu_rel15->bwp_start] |= SL_to_bitmap(csirs_pdu_rel15->symb_l0, 1); + vrb_map[rb] |= SL_to_bitmap(csirs_pdu_rel15->symb_l0, 1); break; case NR_CSI_RS_ResourceMapping__frequencyDomainAllocation_PR_row2: csirs_pdu_rel15->row = 2; csirs_pdu_rel15->freq_domain = (((resourceMapping.frequencyDomainAllocation.choice.row2.buf[1]>>4)&0x0f) | ((resourceMapping.frequencyDomainAllocation.choice.row2.buf[0]<<4)&0xff0)); for (int rb = csirs_pdu_rel15->start_rb; rb < (csirs_pdu_rel15->start_rb + csirs_pdu_rel15->nr_of_rbs); rb++) - vrb_map[rb+csirs_pdu_rel15->bwp_start] |= SL_to_bitmap(csirs_pdu_rel15->symb_l0, 1); + vrb_map[rb] |= SL_to_bitmap(csirs_pdu_rel15->symb_l0, 1); break; case NR_CSI_RS_ResourceMapping__frequencyDomainAllocation_PR_row4: csirs_pdu_rel15->row = 4; csirs_pdu_rel15->freq_domain = ((resourceMapping.frequencyDomainAllocation.choice.row4.buf[0])>>5)&0x07; for (int rb = csirs_pdu_rel15->start_rb; rb < (csirs_pdu_rel15->start_rb + csirs_pdu_rel15->nr_of_rbs); rb++) - vrb_map[rb+csirs_pdu_rel15->bwp_start] |= SL_to_bitmap(csirs_pdu_rel15->symb_l0, 1); + vrb_map[rb] |= SL_to_bitmap(csirs_pdu_rel15->symb_l0, 1); break; case NR_CSI_RS_ResourceMapping__frequencyDomainAllocation_PR_other: csirs_pdu_rel15->freq_domain = ((resourceMapping.frequencyDomainAllocation.choice.other.buf[0])>>2)&0x3f; @@ -2567,18 +2763,18 @@ void nr_csirs_scheduling(int Mod_idP, case NR_CSI_RS_ResourceMapping__nrofPorts_p2: csirs_pdu_rel15->row = 3; for (int rb = csirs_pdu_rel15->start_rb; rb < (csirs_pdu_rel15->start_rb + csirs_pdu_rel15->nr_of_rbs); rb++) - vrb_map[rb+csirs_pdu_rel15->bwp_start] |= SL_to_bitmap(csirs_pdu_rel15->symb_l0, 1); + vrb_map[rb] |= SL_to_bitmap(csirs_pdu_rel15->symb_l0, 1); break; case NR_CSI_RS_ResourceMapping__nrofPorts_p4: csirs_pdu_rel15->row = 5; for (int rb = csirs_pdu_rel15->start_rb; rb < (csirs_pdu_rel15->start_rb + csirs_pdu_rel15->nr_of_rbs); rb++) - vrb_map[rb+csirs_pdu_rel15->bwp_start] |= SL_to_bitmap(csirs_pdu_rel15->symb_l0, 2); + vrb_map[rb] |= SL_to_bitmap(csirs_pdu_rel15->symb_l0, 2); break; case NR_CSI_RS_ResourceMapping__nrofPorts_p8: if (resourceMapping.cdm_Type == NR_CSI_RS_ResourceMapping__cdm_Type_cdm4_FD2_TD2) { csirs_pdu_rel15->row = 8; for (int rb = csirs_pdu_rel15->start_rb; rb < (csirs_pdu_rel15->start_rb + csirs_pdu_rel15->nr_of_rbs); rb++) - vrb_map[rb+csirs_pdu_rel15->bwp_start] |= SL_to_bitmap(csirs_pdu_rel15->symb_l0, 2); + vrb_map[rb] |= SL_to_bitmap(csirs_pdu_rel15->symb_l0, 2); } else{ int num_k = 0; @@ -2587,12 +2783,12 @@ void nr_csirs_scheduling(int Mod_idP, if(num_k==4) { csirs_pdu_rel15->row = 6; for (int rb = csirs_pdu_rel15->start_rb; rb < (csirs_pdu_rel15->start_rb + csirs_pdu_rel15->nr_of_rbs); rb++) - vrb_map[rb+csirs_pdu_rel15->bwp_start] |= SL_to_bitmap(csirs_pdu_rel15->symb_l0, 1); + vrb_map[rb] |= SL_to_bitmap(csirs_pdu_rel15->symb_l0, 1); } else { csirs_pdu_rel15->row = 7; for (int rb = csirs_pdu_rel15->start_rb; rb < (csirs_pdu_rel15->start_rb + csirs_pdu_rel15->nr_of_rbs); rb++) - vrb_map[rb+csirs_pdu_rel15->bwp_start] |= SL_to_bitmap(csirs_pdu_rel15->symb_l0, 2); + vrb_map[rb] |= SL_to_bitmap(csirs_pdu_rel15->symb_l0, 2); } } break; @@ -2600,12 +2796,12 @@ void nr_csirs_scheduling(int Mod_idP, if (resourceMapping.cdm_Type == NR_CSI_RS_ResourceMapping__cdm_Type_cdm4_FD2_TD2) { csirs_pdu_rel15->row = 10; for (int rb = csirs_pdu_rel15->start_rb; rb < (csirs_pdu_rel15->start_rb + csirs_pdu_rel15->nr_of_rbs); rb++) - vrb_map[rb+csirs_pdu_rel15->bwp_start] |= SL_to_bitmap(csirs_pdu_rel15->symb_l0, 2); + vrb_map[rb] |= SL_to_bitmap(csirs_pdu_rel15->symb_l0, 2); } else { csirs_pdu_rel15->row = 9; for (int rb = csirs_pdu_rel15->start_rb; rb < (csirs_pdu_rel15->start_rb + csirs_pdu_rel15->nr_of_rbs); rb++) - vrb_map[rb+csirs_pdu_rel15->bwp_start] |= SL_to_bitmap(csirs_pdu_rel15->symb_l0, 1); + vrb_map[rb] |= SL_to_bitmap(csirs_pdu_rel15->symb_l0, 1); } break; case NR_CSI_RS_ResourceMapping__nrofPorts_p16: @@ -2614,24 +2810,24 @@ void nr_csirs_scheduling(int Mod_idP, else csirs_pdu_rel15->row = 11; for (int rb = csirs_pdu_rel15->start_rb; rb < (csirs_pdu_rel15->start_rb + csirs_pdu_rel15->nr_of_rbs); rb++) - vrb_map[rb+csirs_pdu_rel15->bwp_start] |= SL_to_bitmap(csirs_pdu_rel15->symb_l0, 2); + vrb_map[rb] |= SL_to_bitmap(csirs_pdu_rel15->symb_l0, 2); break; case NR_CSI_RS_ResourceMapping__nrofPorts_p24: if (resourceMapping.cdm_Type == NR_CSI_RS_ResourceMapping__cdm_Type_cdm4_FD2_TD2) { csirs_pdu_rel15->row = 14; for (int rb = csirs_pdu_rel15->start_rb; rb < (csirs_pdu_rel15->start_rb + csirs_pdu_rel15->nr_of_rbs); rb++) - vrb_map[rb+csirs_pdu_rel15->bwp_start] |= (SL_to_bitmap(csirs_pdu_rel15->symb_l0, 2) | SL_to_bitmap(csirs_pdu_rel15->symb_l1, 2)); + vrb_map[rb] |= (SL_to_bitmap(csirs_pdu_rel15->symb_l0, 2) | SL_to_bitmap(csirs_pdu_rel15->symb_l1, 2)); } else{ if (resourceMapping.cdm_Type == NR_CSI_RS_ResourceMapping__cdm_Type_cdm8_FD2_TD4) { csirs_pdu_rel15->row = 15; for (int rb = csirs_pdu_rel15->start_rb; rb < (csirs_pdu_rel15->start_rb + csirs_pdu_rel15->nr_of_rbs); rb++) - vrb_map[rb+csirs_pdu_rel15->bwp_start] |= SL_to_bitmap(csirs_pdu_rel15->symb_l0, 3); + vrb_map[rb] |= SL_to_bitmap(csirs_pdu_rel15->symb_l0, 3); } else { csirs_pdu_rel15->row = 13; for (int rb = csirs_pdu_rel15->start_rb; rb < (csirs_pdu_rel15->start_rb + csirs_pdu_rel15->nr_of_rbs); rb++) - vrb_map[rb+csirs_pdu_rel15->bwp_start] |= (SL_to_bitmap(csirs_pdu_rel15->symb_l0, 2) | SL_to_bitmap(csirs_pdu_rel15->symb_l1, 2)); + vrb_map[rb] |= (SL_to_bitmap(csirs_pdu_rel15->symb_l0, 2) | SL_to_bitmap(csirs_pdu_rel15->symb_l1, 2)); } } break; @@ -2639,18 +2835,18 @@ void nr_csirs_scheduling(int Mod_idP, if (resourceMapping.cdm_Type == NR_CSI_RS_ResourceMapping__cdm_Type_cdm4_FD2_TD2) { csirs_pdu_rel15->row = 17; for (int rb = csirs_pdu_rel15->start_rb; rb < (csirs_pdu_rel15->start_rb + csirs_pdu_rel15->nr_of_rbs); rb++) - vrb_map[rb+csirs_pdu_rel15->bwp_start] |= (SL_to_bitmap(csirs_pdu_rel15->symb_l0, 2) | SL_to_bitmap(csirs_pdu_rel15->symb_l1, 2)); + vrb_map[rb] |= (SL_to_bitmap(csirs_pdu_rel15->symb_l0, 2) | SL_to_bitmap(csirs_pdu_rel15->symb_l1, 2)); } else{ if (resourceMapping.cdm_Type == NR_CSI_RS_ResourceMapping__cdm_Type_cdm8_FD2_TD4) { csirs_pdu_rel15->row = 18; for (int rb = csirs_pdu_rel15->start_rb; rb < (csirs_pdu_rel15->start_rb + csirs_pdu_rel15->nr_of_rbs); rb++) - vrb_map[rb+csirs_pdu_rel15->bwp_start] |= SL_to_bitmap(csirs_pdu_rel15->symb_l0, 3); + vrb_map[rb] |= SL_to_bitmap(csirs_pdu_rel15->symb_l0, 3); } else { csirs_pdu_rel15->row = 16; for (int rb = csirs_pdu_rel15->start_rb; rb < (csirs_pdu_rel15->start_rb + csirs_pdu_rel15->nr_of_rbs); rb++) - vrb_map[rb+csirs_pdu_rel15->bwp_start] |= (SL_to_bitmap(csirs_pdu_rel15->symb_l0, 2) | SL_to_bitmap(csirs_pdu_rel15->symb_l1, 2)); + vrb_map[rb] |= (SL_to_bitmap(csirs_pdu_rel15->symb_l0, 2) | SL_to_bitmap(csirs_pdu_rel15->symb_l1, 2)); } } break; @@ -2668,307 +2864,133 @@ void nr_csirs_scheduling(int Mod_idP, } } +void nr_mac_update_timers(module_id_t module_id, + frame_t frame, + sub_frame_t slot) { + NR_UEs_t *UE_info = &RC.nrmac[module_id]->UE_info; -/*void fill_nfapi_coresets_and_searchspaces(NR_CellGroupConfig_t *cg, - nfapi_nr_coreset_t *coreset, - nfapi_nr_search_space_t *search_space) { + UE_iterator(UE_info->list, UE) { + NR_UE_sched_ctrl_t *sched_ctrl = &UE->UE_sched_ctrl; + if (sched_ctrl->rrc_processing_timer > 0) { + sched_ctrl->rrc_processing_timer--; + if (sched_ctrl->rrc_processing_timer == 0) { + LOG_I(NR_MAC, "(%d.%d) De-activating RRC processing timer for UE %04x\n", frame, slot, UE->rnti); - nfapi_nr_coreset_t *cs; - nfapi_nr_search_space_t *ss; - NR_ServingCellConfigCommon_t *scc=cg->spCellConfig->reconfigurationWithSync->spCellConfigCommon; - AssertFatal(cg->spCellConfig->spCellConfigDedicated->downlinkBWP_ToAddModList->list.count == 1, - "downlinkBWP_ToAddModList has %d BWP!\n", - cg->spCellConfig->spCellConfigDedicated->downlinkBWP_ToAddModList->list.count); + const NR_SIB1_t *sib1 = RC.nrmac[module_id]->common_channels[0].sib1 ? RC.nrmac[module_id]->common_channels[0].sib1->message.choice.c1->choice.systemInformationBlockType1 : NULL; + NR_CellGroupConfig_t *cg = UE->CellGroup; + NR_ServingCellConfigCommon_t *scc = RC.nrmac[module_id]->common_channels[0].ServingCellConfigCommon; + const NR_ServingCellConfig_t *spCellConfigDedicated = cg && cg->spCellConfig ? cg->spCellConfig->spCellConfigDedicated : NULL; - NR_BWP_Downlink_t *bwp=cg->spCellConfig->spCellConfigDedicated->downlinkBWP_ToAddModList->list.array[0]; - struct NR_PDCCH_Config__controlResourceSetToAddModList *coreset_list = bwp->bwp_Dedicated->pdcch_Config->choice.setup->controlResourceSetToAddModList; - AssertFatal(coreset_list->list.count>0, - "cs list has 0 elements\n"); - for (int i=0;ilist.count;i++) { - NR_ControlResourceSet_t *coreset_i=coreset_list->list.array[i]; - cs = coreset + coreset_i->controlResourceSetId; - - cs->coreset_id = coreset_i->controlResourceSetId; - AssertFatal(coreset_i->frequencyDomainResources.size <=8 && coreset_i->frequencyDomainResources.size>0, - "coreset_i->frequencyDomainResources.size=%d\n", - (int)coreset_i->frequencyDomainResources.size); - - for (int f=0;ffrequencyDomainResources.size;f++) - ((uint8_t*)&cs->frequency_domain_resources)[coreset_i->frequencyDomainResources.size-1-f]=coreset_i->frequencyDomainResources.buf[f]; - - cs->frequency_domain_resources>>=coreset_i->frequencyDomainResources.bits_unused; - - cs->duration = coreset_i->duration; - // Need to add information about TCI_StateIDs + // If needed, update the Dedicated BWP + const int current_bwp_id = sched_ctrl->active_bwp ? sched_ctrl->active_bwp->bwp_Id : 0; + const int current_ubwp_id = sched_ctrl->active_ubwp ? sched_ctrl->active_ubwp->bwp_Id : 0; + if (spCellConfigDedicated && + spCellConfigDedicated->downlinkBWP_ToAddModList && + spCellConfigDedicated->uplinkConfig && + spCellConfigDedicated->uplinkConfig->uplinkBWP_ToAddModList) { + if (*spCellConfigDedicated->firstActiveDownlinkBWP_Id != current_bwp_id) { + sched_ctrl->active_bwp = spCellConfigDedicated->downlinkBWP_ToAddModList->list.array[*spCellConfigDedicated->firstActiveDownlinkBWP_Id - 1]; + LOG_I(NR_MAC, "Changing to DL-BWP %li\n", sched_ctrl->active_bwp->bwp_Id); + } + if (*spCellConfigDedicated->uplinkConfig->firstActiveUplinkBWP_Id != current_ubwp_id) { + sched_ctrl->active_ubwp = spCellConfigDedicated->uplinkConfig->uplinkBWP_ToAddModList->list.array[*spCellConfigDedicated->uplinkConfig->firstActiveUplinkBWP_Id - 1]; + LOG_I(NR_MAC, "Changing to UL-BWP %li\n", sched_ctrl->active_ubwp->bwp_Id); + } + } - if (coreset_i->cce_REG_MappingType.present == NR_ControlResourceSet__cce_REG_MappingType_PR_nonInterleaved) - cs->cce_reg_mapping_type = NFAPI_NR_CCE_REG_MAPPING_NON_INTERLEAVED; - else { - cs->cce_reg_mapping_type = NFAPI_NR_CCE_REG_MAPPING_INTERLEAVED; + NR_BWP_Downlink_t *bwp = sched_ctrl->active_bwp; + NR_BWP_DownlinkDedicated_t *bwpd = cg && + cg->spCellConfig && + cg->spCellConfig->spCellConfigDedicated ? + cg->spCellConfig->spCellConfigDedicated->initialDownlinkBWP : NULL; - if (coreset_i->cce_REG_MappingType.choice.interleaved->reg_BundleSize==NR_ControlResourceSet__cce_REG_MappingType__interleaved__reg_BundleSize_n6) - cs->reg_bundle_size = 6; - else cs->reg_bundle_size = 2+coreset_i->cce_REG_MappingType.choice.interleaved->reg_BundleSize; + // update coreset/searchspace + int target_ss = NR_SearchSpace__searchSpaceType_PR_common; + NR_BWP_t *genericParameters = NULL; + if (sched_ctrl->active_bwp) { + target_ss = NR_SearchSpace__searchSpaceType_PR_ue_Specific; + bwpd = (void*)sched_ctrl->active_bwp->bwp_Dedicated; + genericParameters = &sched_ctrl->active_bwp->bwp_Common->genericParameters; + } + else if (cg->spCellConfig && + cg->spCellConfig->spCellConfigDedicated && + (cg->spCellConfig->spCellConfigDedicated->initialDownlinkBWP)) { + target_ss = NR_SearchSpace__searchSpaceType_PR_ue_Specific; + genericParameters = &scc->downlinkConfigCommon->initialDownlinkBWP->genericParameters; + } + NR_BCCH_DL_SCH_Message_t *SIB1 = RC.nrmac[module_id]->common_channels[0].sib1; + sched_ctrl->search_space = get_searchspace(SIB1 ? SIB1->message.choice.c1->choice.systemInformationBlockType1 : NULL, scc, bwpd, target_ss); + sched_ctrl->coreset = get_coreset(RC.nrmac[module_id], scc, bwpd, sched_ctrl->search_space, target_ss); + sched_ctrl->sched_pdcch = set_pdcch_structure(RC.nrmac[module_id], + sched_ctrl->search_space, + sched_ctrl->coreset, + scc, + genericParameters, + RC.nrmac[module_id]->type0_PDCCH_CSS_config); - if (coreset_i->cce_REG_MappingType.choice.interleaved->interleaverSize==NR_ControlResourceSet__cce_REG_MappingType__interleaved__interleaverSize_n6) - cs->interleaver_size = 6; - else cs->interleaver_size = 2+coreset_i->cce_REG_MappingType.choice.interleaved->interleaverSize; + NR_pdsch_semi_static_t *ps = &sched_ctrl->pdsch_semi_static; - if (coreset_i->cce_REG_MappingType.choice.interleaved->shiftIndex) - cs->shift_index = *coreset_i->cce_REG_MappingType.choice.interleaved->shiftIndex; - else cs->shift_index = 0; - } - - if (coreset_i->precoderGranularity == NR_ControlResourceSet__precoderGranularity_sameAsREG_bundle) - cs->precoder_granularity = NFAPI_NR_CSET_SAME_AS_REG_BUNDLE; - else cs->precoder_granularity = NFAPI_NR_CSET_ALL_CONTIGUOUS_RBS; - if (coreset_i->tci_PresentInDCI == NULL) cs->tci_present_in_dci = 0; - else cs->tci_present_in_dci = 1; + const uint8_t layers = set_dl_nrOfLayers(sched_ctrl); + const int tda = get_dl_tda(RC.nrmac[module_id], scc, slot); - if (coreset_i->tci_PresentInDCI == NULL) cs->dmrs_scrambling_id = 0; - else cs->dmrs_scrambling_id = *coreset_i->tci_PresentInDCI; - } + nr_set_pdsch_semi_static(sib1, + scc, + cg, + bwp, + bwpd, + tda, + layers, + sched_ctrl, + ps); - struct NR_PDCCH_ConfigCommon__commonSearchSpaceList *commonSearchSpaceList = bwp->bwp_Common->pdcch_ConfigCommon->choice.setup->commonSearchSpaceList; - AssertFatal(commonSearchSpaceList->list.count>0, - "common SearchSpace list has 0 elements\n"); - // Common searchspace list - for (int i=0;ilist.count;i++) { - NR_SearchSpace_t *searchSpace_i=commonSearchSpaceList->list.array[i]; - ss=search_space + searchSpace_i->searchSpaceId; - if (searchSpace_i->controlResourceSetId) ss->coreset_id = *searchSpace_i->controlResourceSetId; - switch(searchSpace_i->monitoringSlotPeriodicityAndOffset->present) { - case NR_SearchSpace__monitoringSlotPeriodicityAndOffset_PR_sl1: - ss->slot_monitoring_periodicity = NFAPI_NR_SS_PERIODICITY_SL1; - break; - case NR_SearchSpace__monitoringSlotPeriodicityAndOffset_PR_sl2: - ss->slot_monitoring_periodicity = NFAPI_NR_SS_PERIODICITY_SL2; - ss->slot_monitoring_offset = searchSpace_i->monitoringSlotPeriodicityAndOffset->choice.sl2; - break; - case NR_SearchSpace__monitoringSlotPeriodicityAndOffset_PR_sl4: - ss->slot_monitoring_periodicity = NFAPI_NR_SS_PERIODICITY_SL4; - ss->slot_monitoring_offset = searchSpace_i->monitoringSlotPeriodicityAndOffset->choice.sl4; - break; - case NR_SearchSpace__monitoringSlotPeriodicityAndOffset_PR_sl5: - ss->slot_monitoring_periodicity = NFAPI_NR_SS_PERIODICITY_SL5; - ss->slot_monitoring_offset = searchSpace_i->monitoringSlotPeriodicityAndOffset->choice.sl5; - break; - case NR_SearchSpace__monitoringSlotPeriodicityAndOffset_PR_sl8: - ss->slot_monitoring_periodicity = NFAPI_NR_SS_PERIODICITY_SL8; - ss->slot_monitoring_offset = searchSpace_i->monitoringSlotPeriodicityAndOffset->choice.sl8; - break; - case NR_SearchSpace__monitoringSlotPeriodicityAndOffset_PR_sl10: - ss->slot_monitoring_periodicity = NFAPI_NR_SS_PERIODICITY_SL10; - ss->slot_monitoring_offset = searchSpace_i->monitoringSlotPeriodicityAndOffset->choice.sl10; - break; - case NR_SearchSpace__monitoringSlotPeriodicityAndOffset_PR_sl16: - ss->slot_monitoring_periodicity = NFAPI_NR_SS_PERIODICITY_SL16; - ss->slot_monitoring_offset = searchSpace_i->monitoringSlotPeriodicityAndOffset->choice.sl16; - break; - case NR_SearchSpace__monitoringSlotPeriodicityAndOffset_PR_sl20: - ss->slot_monitoring_periodicity = NFAPI_NR_SS_PERIODICITY_SL20; - ss->slot_monitoring_offset = searchSpace_i->monitoringSlotPeriodicityAndOffset->choice.sl20; - break; - case NR_SearchSpace__monitoringSlotPeriodicityAndOffset_PR_sl40: - ss->slot_monitoring_periodicity = NFAPI_NR_SS_PERIODICITY_SL40; - ss->slot_monitoring_offset = searchSpace_i->monitoringSlotPeriodicityAndOffset->choice.sl40; - break; - case NR_SearchSpace__monitoringSlotPeriodicityAndOffset_PR_sl80: - ss->slot_monitoring_periodicity = NFAPI_NR_SS_PERIODICITY_SL80; - ss->slot_monitoring_offset = searchSpace_i->monitoringSlotPeriodicityAndOffset->choice.sl80; - break; - case NR_SearchSpace__monitoringSlotPeriodicityAndOffset_PR_sl160: - ss->slot_monitoring_periodicity = NFAPI_NR_SS_PERIODICITY_SL160; - ss->slot_monitoring_offset = searchSpace_i->monitoringSlotPeriodicityAndOffset->choice.sl160; - break; - case NR_SearchSpace__monitoringSlotPeriodicityAndOffset_PR_sl320: - ss->slot_monitoring_periodicity = NFAPI_NR_SS_PERIODICITY_SL320; - ss->slot_monitoring_offset = searchSpace_i->monitoringSlotPeriodicityAndOffset->choice.sl320; - break; - case NR_SearchSpace__monitoringSlotPeriodicityAndOffset_PR_sl640: - ss->slot_monitoring_periodicity = NFAPI_NR_SS_PERIODICITY_SL640; - ss->slot_monitoring_offset = searchSpace_i->monitoringSlotPeriodicityAndOffset->choice.sl640; - break; - case NR_SearchSpace__monitoringSlotPeriodicityAndOffset_PR_sl1280: - ss->slot_monitoring_periodicity = NFAPI_NR_SS_PERIODICITY_SL1280; - ss->slot_monitoring_offset = searchSpace_i->monitoringSlotPeriodicityAndOffset->choice.sl1280; - break; - case NR_SearchSpace__monitoringSlotPeriodicityAndOffset_PR_sl2560: - ss->slot_monitoring_periodicity = NFAPI_NR_SS_PERIODICITY_SL2560; - ss->slot_monitoring_offset = searchSpace_i->monitoringSlotPeriodicityAndOffset->choice.sl2560; - break; - default: - AssertFatal(1==0,"Shouldn't get here\n"); - break; - } - if (searchSpace_i->duration) ss->duration = *searchSpace_i->duration; - else ss->duration = 1; + NR_BWP_Uplink_t *ubwp = sched_ctrl->active_ubwp; + NR_BWP_UplinkDedicated_t *ubwpd = cg && + cg->spCellConfig && + cg->spCellConfig->spCellConfigDedicated && + cg->spCellConfig->spCellConfigDedicated->uplinkConfig ? + cg->spCellConfig->spCellConfigDedicated->uplinkConfig->initialUplinkBWP : NULL; + NR_pusch_semi_static_t *ups = &sched_ctrl->pusch_semi_static; - AssertFatal(searchSpace_i->monitoringSymbolsWithinSlot->size == 2, - "ss_i->monitoringSymbolsWithinSlot = %d != 2\n", - (int)searchSpace_i->monitoringSymbolsWithinSlot->size); - ((uint8_t*)&ss->monitoring_symbols_in_slot)[1] = searchSpace_i->monitoringSymbolsWithinSlot->buf[0]; - ((uint8_t*)&ss->monitoring_symbols_in_slot)[0] = searchSpace_i->monitoringSymbolsWithinSlot->buf[1]; + int dci_format = get_dci_format(sched_ctrl); + const uint8_t num_dmrs_cdm_grps_no_data = (ubwp || ubwpd) ? 1 : 2; + const uint8_t nrOfLayers = 1; + const int utda = get_ul_tda(RC.nrmac[module_id], scc, slot); - AssertFatal(searchSpace_i->nrofCandidates!=NULL,"searchSpace_%d->nrofCandidates is null\n",(int)searchSpace_i->searchSpaceId); - if (searchSpace_i->nrofCandidates->aggregationLevel1 == NR_SearchSpace__nrofCandidates__aggregationLevel1_n8) - ss->number_of_candidates[0] = 8; - else ss->number_of_candidates[0] = searchSpace_i->nrofCandidates->aggregationLevel1; - if (searchSpace_i->nrofCandidates->aggregationLevel2 == NR_SearchSpace__nrofCandidates__aggregationLevel2_n8) - ss->number_of_candidates[1] = 8; - else ss->number_of_candidates[1] = searchSpace_i->nrofCandidates->aggregationLevel2; - if (searchSpace_i->nrofCandidates->aggregationLevel4 == NR_SearchSpace__nrofCandidates__aggregationLevel4_n8) - ss->number_of_candidates[2] = 8; - else ss->number_of_candidates[2] = searchSpace_i->nrofCandidates->aggregationLevel4; - if (searchSpace_i->nrofCandidates->aggregationLevel8 == NR_SearchSpace__nrofCandidates__aggregationLevel8_n8) - ss->number_of_candidates[3] = 8; - else ss->number_of_candidates[3] = searchSpace_i->nrofCandidates->aggregationLevel8; - if (searchSpace_i->nrofCandidates->aggregationLevel16 == NR_SearchSpace__nrofCandidates__aggregationLevel16_n8) - ss->number_of_candidates[4] = 8; - else ss->number_of_candidates[4] = searchSpace_i->nrofCandidates->aggregationLevel16; - - AssertFatal(searchSpace_i->searchSpaceType->present==NR_SearchSpace__searchSpaceType_PR_common, - "searchspace %d is not common\n",(int)searchSpace_i->searchSpaceId); - AssertFatal(searchSpace_i->searchSpaceType->choice.common!=NULL, - "searchspace %d common is null\n",(int)searchSpace_i->searchSpaceId); - ss->search_space_type = NFAPI_NR_SEARCH_SPACE_TYPE_COMMON; - if (searchSpace_i->searchSpaceType->choice.common->dci_Format0_0_AndFormat1_0) - ss->css_formats_0_0_and_1_0 = 1; - if (searchSpace_i->searchSpaceType->choice.common->dci_Format2_0) { - ss->css_format_2_0 = 1; - // add aggregation info - } - if (searchSpace_i->searchSpaceType->choice.common->dci_Format2_1) - ss->css_format_2_1 = 1; - if (searchSpace_i->searchSpaceType->choice.common->dci_Format2_2) - ss->css_format_2_2 = 1; - if (searchSpace_i->searchSpaceType->choice.common->dci_Format2_3) - ss->css_format_2_3 = 1; - } - - struct NR_PDCCH_Config__searchSpacesToAddModList *dedicatedSearchSpaceList = bwp->bwp_Dedicated->pdcch_Config->choice.setup->searchSpacesToAddModList; - AssertFatal(dedicatedSearchSpaceList->list.count>0, - "Dedicated Search Space list has 0 elements\n"); - // Dedicated searchspace list - for (int i=0;ilist.count;i++) { - NR_SearchSpace_t *searchSpace_i=dedicatedSearchSpaceList->list.array[i]; - ss=search_space + searchSpace_i->searchSpaceId; - ss->search_space_id = searchSpace_i->searchSpaceId; - if (searchSpace_i->controlResourceSetId) ss->coreset_id = *searchSpace_i->controlResourceSetId; - switch(searchSpace_i->monitoringSlotPeriodicityAndOffset->present) { - case NR_SearchSpace__monitoringSlotPeriodicityAndOffset_PR_sl1: - ss->slot_monitoring_periodicity = NFAPI_NR_SS_PERIODICITY_SL1; - break; - case NR_SearchSpace__monitoringSlotPeriodicityAndOffset_PR_sl2: - ss->slot_monitoring_periodicity = NFAPI_NR_SS_PERIODICITY_SL2; - ss->slot_monitoring_offset = searchSpace_i->monitoringSlotPeriodicityAndOffset->choice.sl2; - break; - case NR_SearchSpace__monitoringSlotPeriodicityAndOffset_PR_sl4: - ss->slot_monitoring_periodicity = NFAPI_NR_SS_PERIODICITY_SL4; - ss->slot_monitoring_offset = searchSpace_i->monitoringSlotPeriodicityAndOffset->choice.sl4; - break; - case NR_SearchSpace__monitoringSlotPeriodicityAndOffset_PR_sl5: - ss->slot_monitoring_periodicity = NFAPI_NR_SS_PERIODICITY_SL5; - ss->slot_monitoring_offset = searchSpace_i->monitoringSlotPeriodicityAndOffset->choice.sl5; - break; - case NR_SearchSpace__monitoringSlotPeriodicityAndOffset_PR_sl8: - ss->slot_monitoring_periodicity = NFAPI_NR_SS_PERIODICITY_SL8; - ss->slot_monitoring_offset = searchSpace_i->monitoringSlotPeriodicityAndOffset->choice.sl8; - break; - case NR_SearchSpace__monitoringSlotPeriodicityAndOffset_PR_sl10: - ss->slot_monitoring_periodicity = NFAPI_NR_SS_PERIODICITY_SL10; - ss->slot_monitoring_offset = searchSpace_i->monitoringSlotPeriodicityAndOffset->choice.sl10; - break; - case NR_SearchSpace__monitoringSlotPeriodicityAndOffset_PR_sl16: - ss->slot_monitoring_periodicity = NFAPI_NR_SS_PERIODICITY_SL16; - ss->slot_monitoring_offset = searchSpace_i->monitoringSlotPeriodicityAndOffset->choice.sl16; - break; - case NR_SearchSpace__monitoringSlotPeriodicityAndOffset_PR_sl20: - ss->slot_monitoring_periodicity = NFAPI_NR_SS_PERIODICITY_SL20; - ss->slot_monitoring_offset = searchSpace_i->monitoringSlotPeriodicityAndOffset->choice.sl20; - break; - case NR_SearchSpace__monitoringSlotPeriodicityAndOffset_PR_sl40: - ss->slot_monitoring_periodicity = NFAPI_NR_SS_PERIODICITY_SL40; - ss->slot_monitoring_offset = searchSpace_i->monitoringSlotPeriodicityAndOffset->choice.sl40; - break; - case NR_SearchSpace__monitoringSlotPeriodicityAndOffset_PR_sl80: - ss->slot_monitoring_periodicity = NFAPI_NR_SS_PERIODICITY_SL80; - ss->slot_monitoring_offset = searchSpace_i->monitoringSlotPeriodicityAndOffset->choice.sl80; - break; - case NR_SearchSpace__monitoringSlotPeriodicityAndOffset_PR_sl160: - ss->slot_monitoring_periodicity = NFAPI_NR_SS_PERIODICITY_SL160; - ss->slot_monitoring_offset = searchSpace_i->monitoringSlotPeriodicityAndOffset->choice.sl160; - break; - case NR_SearchSpace__monitoringSlotPeriodicityAndOffset_PR_sl320: - ss->slot_monitoring_periodicity = NFAPI_NR_SS_PERIODICITY_SL320; - ss->slot_monitoring_offset = searchSpace_i->monitoringSlotPeriodicityAndOffset->choice.sl320; - break; - case NR_SearchSpace__monitoringSlotPeriodicityAndOffset_PR_sl640: - ss->slot_monitoring_periodicity = NFAPI_NR_SS_PERIODICITY_SL640; - ss->slot_monitoring_offset = searchSpace_i->monitoringSlotPeriodicityAndOffset->choice.sl640; - break; - case NR_SearchSpace__monitoringSlotPeriodicityAndOffset_PR_sl1280: - ss->slot_monitoring_periodicity = NFAPI_NR_SS_PERIODICITY_SL1280; - ss->slot_monitoring_offset = searchSpace_i->monitoringSlotPeriodicityAndOffset->choice.sl1280; - break; - case NR_SearchSpace__monitoringSlotPeriodicityAndOffset_PR_sl2560: - ss->slot_monitoring_periodicity = NFAPI_NR_SS_PERIODICITY_SL2560; - ss->slot_monitoring_offset = searchSpace_i->monitoringSlotPeriodicityAndOffset->choice.sl2560; - break; - default: - AssertFatal(1==0,"Shouldn't get here\n"); - break; - } - if (searchSpace_i->duration) ss->duration = *searchSpace_i->duration; - else ss->duration = 1; - - - AssertFatal(searchSpace_i->monitoringSymbolsWithinSlot->size == 2, - "ss_i->monitoringSymbolsWithinSlot = %d != 2\n", - (int)searchSpace_i->monitoringSymbolsWithinSlot->size); - ((uint8_t*)&ss->monitoring_symbols_in_slot)[1] = searchSpace_i->monitoringSymbolsWithinSlot->buf[0]; - ((uint8_t*)&ss->monitoring_symbols_in_slot)[0] = searchSpace_i->monitoringSymbolsWithinSlot->buf[1]; - - AssertFatal(searchSpace_i->nrofCandidates!=NULL,"searchSpace_%d->nrofCandidates is null\n",(int)searchSpace_i->searchSpaceId); - if (searchSpace_i->nrofCandidates->aggregationLevel1 == NR_SearchSpace__nrofCandidates__aggregationLevel1_n8) - ss->number_of_candidates[0] = 8; - else ss->number_of_candidates[0] = searchSpace_i->nrofCandidates->aggregationLevel1; - if (searchSpace_i->nrofCandidates->aggregationLevel2 == NR_SearchSpace__nrofCandidates__aggregationLevel2_n8) - ss->number_of_candidates[1] = 8; - else ss->number_of_candidates[1] = searchSpace_i->nrofCandidates->aggregationLevel2; - if (searchSpace_i->nrofCandidates->aggregationLevel4 == NR_SearchSpace__nrofCandidates__aggregationLevel4_n8) - ss->number_of_candidates[2] = 8; - else ss->number_of_candidates[2] = searchSpace_i->nrofCandidates->aggregationLevel4; - if (searchSpace_i->nrofCandidates->aggregationLevel8 == NR_SearchSpace__nrofCandidates__aggregationLevel8_n8) - ss->number_of_candidates[3] = 8; - else ss->number_of_candidates[3] = searchSpace_i->nrofCandidates->aggregationLevel8; - if (searchSpace_i->nrofCandidates->aggregationLevel16 == NR_SearchSpace__nrofCandidates__aggregationLevel16_n8) - ss->number_of_candidates[4] = 8; - else ss->number_of_candidates[4] = searchSpace_i->nrofCandidates->aggregationLevel16; - - if (searchSpace_i->searchSpaceType->present==NR_SearchSpace__searchSpaceType_PR_ue_Specific && searchSpace_i->searchSpaceType->choice.ue_Specific!=NULL) { - - ss->search_space_type = NFAPI_NR_SEARCH_SPACE_TYPE_UE_SPECIFIC; - - ss->uss_dci_formats = searchSpace_i->searchSpaceType->choice.ue_Specific-> dci_Formats; - - } else if (searchSpace_i->searchSpaceType->present==NR_SearchSpace__searchSpaceType_PR_common && searchSpace_i->searchSpaceType->choice.common!=NULL) { - ss->search_space_type = NFAPI_NR_SEARCH_SPACE_TYPE_COMMON; - - if (searchSpace_i->searchSpaceType->choice.common->dci_Format0_0_AndFormat1_0) - ss->css_formats_0_0_and_1_0 = 1; - if (searchSpace_i->searchSpaceType->choice.common->dci_Format2_0) { - ss->css_format_2_0 = 1; - // add aggregation info + nr_set_pusch_semi_static(sib1, + scc, + ubwp, + ubwpd, + dci_format, + utda, + num_dmrs_cdm_grps_no_data, + nrOfLayers, + ups); } - if (searchSpace_i->searchSpaceType->choice.common->dci_Format2_1) - ss->css_format_2_1 = 1; - if (searchSpace_i->searchSpaceType->choice.common->dci_Format2_2) - ss->css_format_2_2 = 1; - if (searchSpace_i->searchSpaceType->choice.common->dci_Format2_3) - ss->css_format_2_3 = 1; } } } -*/ + +void schedule_nr_bwp_switch(module_id_t module_id, + frame_t frame, + sub_frame_t slot) { + + NR_UEs_t *UE_info = &RC.nrmac[module_id]->UE_info; + + // TODO: Implementation of a algorithm to perform: + // - DL BWP selection: sched_ctrl->next_dl_bwp_id = dl_bwp_id + // - UL BWP selection: sched_ctrl->next_ul_bwp_id = ul_bwp_id + + UE_iterator(UE_info->list, UE) { + NR_UE_sched_ctrl_t *sched_ctrl = &UE->UE_sched_ctrl; + if (sched_ctrl->rrc_processing_timer == 0 && + UE->Msg4_ACKed && + ((sched_ctrl->next_dl_bwp_id >= 0 && sched_ctrl->active_bwp && sched_ctrl->active_bwp->bwp_Id != sched_ctrl->next_dl_bwp_id) || + (sched_ctrl->next_ul_bwp_id >= 0 && sched_ctrl->active_ubwp && sched_ctrl->active_ubwp->bwp_Id != sched_ctrl->next_ul_bwp_id))) { + + LOG_W(NR_MAC,"%4d.%2d UE %04x Schedule BWP switch from dl_bwp_id %ld to %ld and from ul_bwp_id %ld to %ld\n", + frame, slot, UE->rnti, sched_ctrl->active_bwp->bwp_Id, sched_ctrl->next_dl_bwp_id, sched_ctrl->active_ubwp->bwp_Id, sched_ctrl->next_ul_bwp_id); + nr_mac_rrc_bwp_switch_req(module_id, frame, slot, UE->rnti, sched_ctrl->next_dl_bwp_id, sched_ctrl->next_ul_bwp_id); + } + } +} diff --git a/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_srs.c b/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_srs.c index a2b27357dd..c156ebf36d 100644 --- a/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_srs.c +++ b/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_srs.c @@ -34,18 +34,17 @@ extern RAN_CONTEXT_t RC; -void nr_configure_srs(nfapi_nr_srs_pdu_t *srs_pdu, int module_id, int CC_id, int UE_id, NR_SRS_Resource_t *srs_resource) { +void nr_configure_srs(nfapi_nr_srs_pdu_t *srs_pdu, int module_id, int CC_id,NR_UE_info_t* UE, NR_SRS_Resource_t *srs_resource) { gNB_MAC_INST *nrmac = RC.nrmac[module_id]; NR_ServingCellConfigCommon_t *scc = nrmac->common_channels[CC_id].ServingCellConfigCommon; - NR_UE_info_t *UE_info = &nrmac->UE_info; - NR_UE_sched_ctrl_t *sched_ctrl = &UE_info->UE_sched_ctrl[UE_id]; + NR_UE_sched_ctrl_t *sched_ctrl = &UE->UE_sched_ctrl; NR_BWP_t ubwp = sched_ctrl->active_ubwp ? sched_ctrl->active_ubwp->bwp_Common->genericParameters : scc->uplinkConfigCommon->initialUplinkBWP->genericParameters; - srs_pdu->rnti = UE_info->rnti[UE_id]; + srs_pdu->rnti = UE->rnti; srs_pdu->handle = 0; srs_pdu->bwp_size = NRRIV2BW(ubwp.locationAndBandwidth, MAX_BWP_SIZE);; srs_pdu->bwp_start = NRRIV2PRBOFFSET(ubwp.locationAndBandwidth, MAX_BWP_SIZE);; @@ -82,17 +81,19 @@ void nr_configure_srs(nfapi_nr_srs_pdu_t *srs_pdu, int module_id, int CC_id, int srs_pdu->t_offset = get_nr_srs_offset(srs_resource->resourceType.choice.periodic->periodicityAndOffset_p); } -void nr_fill_nfapi_srs(int module_id, int CC_id, int UE_id, sub_frame_t slot, NR_SRS_Resource_t *srs_resource) { +void nr_fill_nfapi_srs(int module_id, int CC_id, NR_UE_info_t* UE, sub_frame_t slot, NR_SRS_Resource_t *srs_resource) { nfapi_nr_ul_tti_request_t *future_ul_tti_req = &RC.nrmac[module_id]->UL_tti_req_ahead[0][slot]; - + AssertFatal(future_ul_tti_req->n_pdus < + sizeof(future_ul_tti_req->pdus_list) / sizeof(future_ul_tti_req->pdus_list[0]), + "Invalid future_ul_tti_req->n_pdus %d\n", future_ul_tti_req->n_pdus); future_ul_tti_req->pdus_list[future_ul_tti_req->n_pdus].pdu_type = NFAPI_NR_UL_CONFIG_SRS_PDU_TYPE; future_ul_tti_req->pdus_list[future_ul_tti_req->n_pdus].pdu_size = sizeof(nfapi_nr_srs_pdu_t); nfapi_nr_srs_pdu_t *srs_pdu = &future_ul_tti_req->pdus_list[future_ul_tti_req->n_pdus].srs_pdu; memset(srs_pdu, 0, sizeof(nfapi_nr_srs_pdu_t)); future_ul_tti_req->n_pdus += 1; - nr_configure_srs(srs_pdu, module_id, CC_id, UE_id, srs_resource); + nr_configure_srs(srs_pdu, module_id, CC_id, UE, srs_resource); } /******************************************************************* @@ -109,21 +110,19 @@ void nr_fill_nfapi_srs(int module_id, int CC_id, int UE_id, sub_frame_t slot, NR void nr_schedule_srs(int module_id, frame_t frame) { gNB_MAC_INST *nrmac = RC.nrmac[module_id]; - NR_UE_info_t *UE_info = &nrmac->UE_info; - const NR_list_t *UE_list = &UE_info->list; - - for (int UE_id = UE_list->head; UE_id >= 0; UE_id = UE_list->next[UE_id]) { + NR_UEs_t *UE_info = &nrmac->UE_info; + UE_iterator(UE_info->list, UE) { const int CC_id = 0; NR_ServingCellConfigCommon_t *scc = RC.nrmac[module_id]->common_channels[CC_id].ServingCellConfigCommon; - NR_CellGroupConfig_t *cg = UE_info->CellGroup[UE_id]; - NR_UE_sched_ctrl_t *sched_ctrl = &UE_info->UE_sched_ctrl[UE_id]; + NR_CellGroupConfig_t *cg = UE->CellGroup; + NR_UE_sched_ctrl_t *sched_ctrl = &UE->UE_sched_ctrl; sched_ctrl->sched_srs.frame = -1; sched_ctrl->sched_srs.slot = -1; sched_ctrl->sched_srs.srs_scheduled = false; - if(!UE_info->Msg4_ACKed[UE_id]) { + if(!UE->Msg4_ACKed || sched_ctrl->rrc_processing_timer > 0) { continue; } @@ -176,11 +175,11 @@ void nr_schedule_srs(int module_id, frame_t frame) { // Check if UE will transmit the SRS in this frame if ( ((frame - offset/n_slots_frame)*n_slots_frame)%period == 0) { LOG_D(NR_MAC,"Scheduling SRS reception for %d.%d\n", frame, offset%n_slots_frame); - nr_fill_nfapi_srs(module_id, CC_id, UE_id, offset%n_slots_frame, srs_resource); + nr_fill_nfapi_srs(module_id, CC_id, UE, offset%n_slots_frame, srs_resource); sched_ctrl->sched_srs.frame = frame; sched_ctrl->sched_srs.slot = offset%n_slots_frame; sched_ctrl->sched_srs.srs_scheduled = true; } } } -} \ No newline at end of file +} diff --git a/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_uci.c b/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_uci.c index cfff41a6ad..d64b9c43db 100644 --- a/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_uci.c +++ b/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_uci.c @@ -38,23 +38,29 @@ extern RAN_CONTEXT_t RC; -void nr_fill_nfapi_pucch(module_id_t mod_id, - frame_t frame, - sub_frame_t slot, - const NR_sched_pucch_t *pucch, - int UE_id) -{ - NR_UE_info_t *UE_info = &RC.nrmac[mod_id]->UE_info; +static void nr_fill_nfapi_pucch(gNB_MAC_INST *nrmac, + frame_t frame, + sub_frame_t slot, + const NR_sched_pucch_t *pucch, + NR_UE_info_t* UE) +{ nfapi_nr_ul_tti_request_t *future_ul_tti_req = - &RC.nrmac[mod_id]->UL_tti_req_ahead[0][pucch->ul_slot]; + &nrmac->UL_tti_req_ahead[0][pucch->ul_slot]; AssertFatal(future_ul_tti_req->SFN == pucch->frame && future_ul_tti_req->Slot == pucch->ul_slot, - "future UL_tti_req's frame.slot %d.%d does not match PUCCH %d.%d\n", + "Current %4d.%2d : future UL_tti_req's frame.slot %4d.%2d does not match PUCCH %4d.%2d\n", + frame,slot, future_ul_tti_req->SFN, future_ul_tti_req->Slot, pucch->frame, pucch->ul_slot); + // n_pdus is number of pdus, so, in the array, it is the index of the next free element + if (future_ul_tti_req->n_pdus >= sizeofArray(future_ul_tti_req->pdus_list) ) { + LOG_E(NR_MAC,"future_ul_tti_req->n_pdus %d is full, slot: %d, sr flag %d dropping request\n", + future_ul_tti_req->n_pdus, pucch->ul_slot, pucch->sr_flag); + return; + } future_ul_tti_req->pdus_list[future_ul_tti_req->n_pdus].pdu_type = NFAPI_NR_UL_CONFIG_PUCCH_PDU_TYPE; future_ul_tti_req->pdus_list[future_ul_tti_req->n_pdus].pdu_size = sizeof(nfapi_nr_pucch_pdu_t); nfapi_nr_pucch_pdu_t *pucch_pdu = &future_ul_tti_req->pdus_list[future_ul_tti_req->n_pdus].pucch_pdu; @@ -72,20 +78,25 @@ void nr_fill_nfapi_pucch(module_id_t mod_id, pucch->dai_c, pucch->csi_bits, pucch->resource_indicator); + NR_COMMON_channels_t * common_ch=nrmac->common_channels; + NR_ServingCellConfigCommon_t *scc = common_ch->ServingCellConfigCommon; + NR_CellGroupConfig_t *cg=UE->CellGroup; - NR_ServingCellConfigCommon_t *scc = RC.nrmac[mod_id]->common_channels->ServingCellConfigCommon; - NR_CellGroupConfig_t *cg=UE_info->CellGroup[UE_id]; + NR_BWP_UplinkDedicated_t *ubwpd = cg && cg->spCellConfig && cg->spCellConfig->spCellConfigDedicated && + cg->spCellConfig->spCellConfigDedicated->uplinkConfig ? + cg->spCellConfig->spCellConfigDedicated->uplinkConfig->initialUplinkBWP : NULL; - NR_BWP_UplinkDedicated_t *ubwpd; - ubwpd = cg ? cg->spCellConfig->spCellConfigDedicated->uplinkConfig->initialUplinkBWP:NULL; + LOG_D(NR_MAC,"%4d.%2d Calling nr_configure_pucch (ubwpd %p,r_pucch %d) pucch to be scheduled in %4d.%2d\n", + frame,slot,ubwpd,pucch->r_pucch,pucch->frame,pucch->ul_slot); - LOG_D(NR_MAC,"pucch_acknak: %d.%d Calling nr_configure_pucch (ubwpd %p,r_pucch %d) pucch in %d.%d\n",frame,slot,ubwpd,pucch->r_pucch,pucch->frame,pucch->ul_slot); - nr_configure_pucch(pucch_pdu, + const NR_SIB1_t *sib1 = common_ch->sib1 ? common_ch->sib1->message.choice.c1->choice.systemInformationBlockType1 : NULL; + nr_configure_pucch(sib1, + pucch_pdu, scc, - UE_info->CellGroup[UE_id], - UE_info->UE_sched_ctrl[UE_id].active_ubwp, + UE->CellGroup, + UE->UE_sched_ctrl.active_ubwp, ubwpd, - UE_info->rnti[UE_id], + UE->rnti, pucch->resource_indicator, pucch->csi_bits, pucch->dai_c, @@ -129,22 +140,18 @@ int diff_rsrp_ssb_csi_meas_10_1_6_1_2[16] = { }; -void nr_schedule_pucch(int Mod_idP, +void nr_schedule_pucch(gNB_MAC_INST *nrmac, frame_t frameP, sub_frame_t slotP) { - gNB_MAC_INST *nrmac = RC.nrmac[Mod_idP]; if (!is_xlsch_in_slot(nrmac->ulsch_slot_bitmap[slotP / 64], slotP)) return; - NR_UE_info_t *UE_info = &nrmac->UE_info; - const NR_list_t *UE_list = &UE_info->list; - - for (int UE_id = UE_list->head; UE_id >= 0; UE_id = UE_list->next[UE_id]) { - NR_UE_sched_ctrl_t *sched_ctrl = &UE_info->UE_sched_ctrl[UE_id]; + UE_iterator(nrmac->UE_info.list, UE) { + NR_UE_sched_ctrl_t *sched_ctrl = &UE->UE_sched_ctrl; const int n = sizeof(sched_ctrl->sched_pucch) / sizeof(*sched_ctrl->sched_pucch); for (int i = 0; i < n; i++) { - NR_sched_pucch_t *curr_pucch = &UE_info->UE_sched_ctrl[UE_id].sched_pucch[i]; + NR_sched_pucch_t *curr_pucch = &UE->UE_sched_ctrl.sched_pucch[i]; const uint16_t O_ack = curr_pucch->dai_c; const uint16_t O_csi = curr_pucch->csi_bits; const uint8_t O_sr = curr_pucch->sr_flag; @@ -152,8 +159,11 @@ void nr_schedule_pucch(int Mod_idP, || frameP != curr_pucch->frame || slotP != curr_pucch->ul_slot) continue; - LOG_D(NR_MAC,"Scheduling PUCCH[%d] RX for UE %d in %d.%d O_ack %d\n",i,UE_id,curr_pucch->frame,curr_pucch->ul_slot,O_ack); - nr_fill_nfapi_pucch(Mod_idP, frameP, slotP, curr_pucch, UE_id); + + if (O_csi > 0) + LOG_D(NR_MAC,"Scheduling PUCCH[%d] RX for UE %04x in %4d.%2d O_ack %d, O_sr %d, O_csi %d\n", + i,UE->rnti,curr_pucch->frame,curr_pucch->ul_slot,O_ack,O_sr,O_csi); + nr_fill_nfapi_pucch(nrmac, frameP, slotP, curr_pucch, UE); memset(curr_pucch, 0, sizeof(*curr_pucch)); } } @@ -280,7 +290,6 @@ void compute_li_bitlen(struct NR_CSI_ReportConfig *csi_reportconfig, } } - void get_n1n2_o1o2_singlepanel(int *n1, int *n2, int *o1, int *o2, struct NR_CodebookConfig__codebookType__type1__subType__typeI_SinglePanel__nrOfAntennaPorts__moreThanTwo *morethantwo) { @@ -492,6 +501,8 @@ void compute_pmi_bitlen(struct NR_CSI_ReportConfig *csi_reportconfig, if(codebookConfig->codebookType.choice.type1->subType.present == NR_CodebookConfig__codebookType__type1__subType_PR_typeI_SinglePanel) { if(codebookConfig->codebookType.choice.type1->subType.choice.typeI_SinglePanel->nrOfAntennaPorts.present == NR_CodebookConfig__codebookType__type1__subType__typeI_SinglePanel__nrOfAntennaPorts_PR_two) { + csi_report->N1 = 1; + csi_report->N2 = 1; if (i==0) csi_report->csi_meas_bitlen.pmi_x2_bitlen[i]=2; if (i==1) @@ -501,6 +512,9 @@ void compute_pmi_bitlen(struct NR_CSI_ReportConfig *csi_reportconfig, int n1,n2,o1,o2,x1,x2; get_n1n2_o1o2_singlepanel(&n1,&n2,&o1,&o2,codebookConfig->codebookType.choice.type1->subType.choice.typeI_SinglePanel->nrOfAntennaPorts.choice.moreThanTwo); get_x1x2_bitlen_singlepanel(n1,n2,o1,o2,&x1,&x2,i+1,codebookConfig->codebookType.choice.type1->codebookMode); + csi_report->N1 = n1; + csi_report->N2 = n2; + csi_report->codebook_mode = codebookConfig->codebookType.choice.type1->codebookMode; csi_report->csi_meas_bitlen.pmi_x1_bitlen[i]=x1; csi_report->csi_meas_bitlen.pmi_x2_bitlen[i]=x2; } @@ -547,9 +561,8 @@ void compute_cqi_bitlen(struct NR_CSI_ReportConfig *csi_reportconfig, AssertFatal(1==0,"Sub-band CQI reporting not yet supported"); } - //!TODO : same function can be written to handle csi_resources -void compute_csi_bitlen(NR_CSI_MeasConfig_t *csi_MeasConfig, NR_UE_info_t *UE_info, int UE_id, module_id_t Mod_idP){ +void compute_csi_bitlen(NR_CSI_MeasConfig_t *csi_MeasConfig, NR_UE_info_t *UE){ uint8_t csi_report_id = 0; uint8_t nb_resources = 0; NR_CSI_ReportConfig__reportQuantity_PR reportQuantity_type; @@ -557,10 +570,11 @@ void compute_csi_bitlen(NR_CSI_MeasConfig_t *csi_MeasConfig, NR_UE_info_t *UE_in struct NR_CSI_ResourceConfig *csi_resourceconfig; // for each CSI measurement report configuration (list of CSI-ReportConfig) + LOG_D(NR_MAC,"Searching %d csi_reports\n",csi_MeasConfig->csi_ReportConfigToAddModList->list.count); for (csi_report_id=0; csi_report_id < csi_MeasConfig->csi_ReportConfigToAddModList->list.count; csi_report_id++){ struct NR_CSI_ReportConfig *csi_reportconfig = csi_MeasConfig->csi_ReportConfigToAddModList->list.array[csi_report_id]; // MAC structure for CSI measurement reports (per UE and per report) - nr_csi_report_t *csi_report = &UE_info->csi_report_template[UE_id][csi_report_id]; + nr_csi_report_t *csi_report = &UE->csi_report_template[csi_report_id]; // csi-ResourceConfigId of a CSI-ResourceConfig included in the configuration // (either CSI-RS or SSB) csi_ResourceConfigId = csi_reportconfig->resourcesForChannelMeasurement; @@ -611,7 +625,7 @@ void compute_csi_bitlen(NR_CSI_MeasConfig_t *csi_MeasConfig, NR_UE_info_t *UE_in } else AssertFatal(1==0,"Only periodic resource configuration currently supported\n"); } - + LOG_D(NR_MAC,"nb_resources %d\n",nb_resources); // computation of bit length depending on the report type switch(reportQuantity_type){ case (NR_CSI_ReportConfig__reportQuantity_PR_ssb_Index_RSRP): @@ -645,24 +659,22 @@ void compute_csi_bitlen(NR_CSI_MeasConfig_t *csi_MeasConfig, NR_UE_info_t *UE_in } -uint16_t nr_get_csi_bitlen(int Mod_idP, - int UE_id, +uint16_t nr_get_csi_bitlen(NR_UE_info_t *UE, uint8_t csi_report_id) { uint16_t csi_bitlen = 0; uint16_t max_bitlen = 0; - NR_UE_info_t *UE_info = &RC.nrmac[Mod_idP]->UE_info; L1_RSRP_bitlen_t * CSI_report_bitlen = NULL; CSI_Meas_bitlen_t * csi_meas_bitlen = NULL; - if (NR_CSI_ReportConfig__reportQuantity_PR_ssb_Index_RSRP==UE_info->csi_report_template[UE_id][csi_report_id].reportQuantity_type|| - NR_CSI_ReportConfig__reportQuantity_PR_cri_RSRP==UE_info->csi_report_template[UE_id][csi_report_id].reportQuantity_type){ - CSI_report_bitlen = &(UE_info->csi_report_template[UE_id][csi_report_id].CSI_report_bitlen); //This might need to be moodif for Aperiodic CSI-RS measurements + if (NR_CSI_ReportConfig__reportQuantity_PR_ssb_Index_RSRP==UE->csi_report_template[csi_report_id].reportQuantity_type|| + NR_CSI_ReportConfig__reportQuantity_PR_cri_RSRP==UE->csi_report_template[csi_report_id].reportQuantity_type){ + CSI_report_bitlen = &(UE->csi_report_template[csi_report_id].CSI_report_bitlen); //This might need to be moodif for Aperiodic CSI-RS measurements csi_bitlen+= ((CSI_report_bitlen->cri_ssbri_bitlen * CSI_report_bitlen->nb_ssbri_cri) + CSI_report_bitlen->rsrp_bitlen +(CSI_report_bitlen->diff_rsrp_bitlen * (CSI_report_bitlen->nb_ssbri_cri -1 ))); } else{ - csi_meas_bitlen = &(UE_info->csi_report_template[UE_id][csi_report_id].csi_meas_bitlen); //This might need to be moodif for Aperiodic CSI-RS measurements + csi_meas_bitlen = &(UE->csi_report_template[csi_report_id].csi_meas_bitlen); //This might need to be moodif for Aperiodic CSI-RS measurements uint16_t temp_bitlen; for (int i=0; i<8; i++) { temp_bitlen = (csi_meas_bitlen->cri_bitlen+ @@ -688,18 +700,29 @@ void nr_csi_meas_reporting(int Mod_idP, NR_ServingCellConfigCommon_t *scc = RC.nrmac[Mod_idP]->common_channels->ServingCellConfigCommon; const int n_slots_frame = nr_slots_per_frame[*scc->ssbSubcarrierSpacing]; - NR_UE_info_t *UE_info = &RC.nrmac[Mod_idP]->UE_info; - NR_list_t *UE_list = &UE_info->list; - for (int UE_id = UE_list->head; UE_id >= 0; UE_id = UE_list->next[UE_id]) { - const NR_CellGroupConfig_t *CellGroup = UE_info->CellGroup[UE_id]; - NR_UE_sched_ctrl_t *sched_ctrl = &UE_info->UE_sched_ctrl[UE_id]; - if (sched_ctrl->ul_failure==1 && get_softmodem_params()->phy_test==0) continue; + + UE_iterator(RC.nrmac[Mod_idP]->UE_info.list, UE ) { + const NR_CellGroupConfig_t *CellGroup = UE->CellGroup; + NR_UE_sched_ctrl_t *sched_ctrl = &UE->UE_sched_ctrl; + if ((sched_ctrl->rrc_processing_timer > 0) || (sched_ctrl->ul_failure==1 && get_softmodem_params()->phy_test==0)) { + continue; + } if (!CellGroup || !CellGroup->spCellConfig || !CellGroup->spCellConfig->spCellConfigDedicated || !CellGroup->spCellConfig->spCellConfigDedicated->csi_MeasConfig) continue; const NR_CSI_MeasConfig_t *csi_measconfig = CellGroup->spCellConfig->spCellConfigDedicated->csi_MeasConfig->choice.setup; AssertFatal(csi_measconfig->csi_ReportConfigToAddModList->list.count > 0, "NO CSI report configuration available"); - NR_PUCCH_Config_t *pucch_Config = sched_ctrl->active_ubwp->bwp_Dedicated->pucch_Config->choice.setup; + NR_PUCCH_Config_t *pucch_Config = NULL; + if (sched_ctrl->active_ubwp) { + pucch_Config = sched_ctrl->active_ubwp->bwp_Dedicated->pucch_Config->choice.setup; + } else if (CellGroup && + CellGroup->spCellConfig && + CellGroup->spCellConfig->spCellConfigDedicated && + CellGroup->spCellConfig->spCellConfigDedicated->uplinkConfig && + CellGroup->spCellConfig->spCellConfigDedicated->uplinkConfig->initialUplinkBWP && + CellGroup->spCellConfig->spCellConfigDedicated->uplinkConfig->initialUplinkBWP->pucch_Config->choice.setup) { + pucch_Config = CellGroup->spCellConfig->spCellConfigDedicated->uplinkConfig->initialUplinkBWP->pucch_Config->choice.setup; + } for (int csi_report_id = 0; csi_report_id < csi_measconfig->csi_ReportConfigToAddModList->list.count; csi_report_id++){ NR_CSI_ReportConfig_t *csirep = csi_measconfig->csi_ReportConfigToAddModList->list.array[csi_report_id]; @@ -723,7 +746,7 @@ void nr_csi_meas_reporting(int Mod_idP, if (*pucchresset->resourceList.list.array[res_index] == pucchcsires->pucch_Resource) break; AssertFatal(res_index < n, - "CSI resource not found among PUCCH resources\n"); + "CSI pucch resource %ld not found among PUCCH resources\n", pucchcsires->pucch_Resource); // find free PUCCH that is in order with possibly existing PUCCH // schedulings (other CSI, SR) @@ -732,17 +755,18 @@ void nr_csi_meas_reporting(int Mod_idP, && !curr_pucch->sr_flag && curr_pucch->dai_c == 0, "PUCCH not free at index 1 for UE %04x\n", - UE_info->rnti[UE_id]); + UE->rnti); curr_pucch->r_pucch = -1; curr_pucch->frame = frame; curr_pucch->ul_slot = sched_slot; curr_pucch->resource_indicator = res_index; - curr_pucch->csi_bits += - nr_get_csi_bitlen(Mod_idP,UE_id,csi_report_id); + curr_pucch->csi_bits += nr_get_csi_bitlen(UE,csi_report_id); + + const NR_SIB1_t *sib1 = RC.nrmac[Mod_idP]->common_channels[0].sib1 ? RC.nrmac[Mod_idP]->common_channels[0].sib1->message.choice.c1->choice.systemInformationBlockType1 : NULL; + NR_BWP_t *genericParameters = get_ul_bwp_genericParameters(sched_ctrl->active_ubwp, + scc, + sib1); - NR_BWP_t *genericParameters = sched_ctrl->active_ubwp ? - &sched_ctrl->active_ubwp->bwp_Common->genericParameters: - &scc->uplinkConfigCommon->initialUplinkBWP->genericParameters; int bwp_start = NRRIV2PRBOFFSET(genericParameters->locationAndBandwidth,MAX_BWP_SIZE); // going through the list of PUCCH resources to find the one indexed by resource_id @@ -758,16 +782,17 @@ void nr_csi_meas_reporting(int Mod_idP, switch(pucchres->format.present){ case NR_PUCCH_Resource__format_PR_format2: len = pucchres->format.choice.format2->nrofPRBs; - mask = ((1 << pucchres->format.choice.format2->nrofSymbols) - 1) << pucchres->format.choice.format2->startingSymbolIndex; + mask = SL_to_bitmap(pucchres->format.choice.format2->startingSymbolIndex, pucchres->format.choice.format2->nrofSymbols); curr_pucch->simultaneous_harqcsi = pucch_Config->format2->choice.setup->simultaneousHARQ_ACK_CSI; + LOG_D(NR_MAC,"%d.%d Allocating PUCCH format 2, startPRB %d, nPRB %d, simulHARQ %d, num_bits %d\n", frame, sched_slot,start,len,curr_pucch->simultaneous_harqcsi,curr_pucch->csi_bits); break; case NR_PUCCH_Resource__format_PR_format3: len = pucchres->format.choice.format3->nrofPRBs; - mask = ((1 << pucchres->format.choice.format3->nrofSymbols) - 1) << pucchres->format.choice.format3->startingSymbolIndex; + mask = SL_to_bitmap(pucchres->format.choice.format3->startingSymbolIndex, pucchres->format.choice.format3->nrofSymbols); curr_pucch->simultaneous_harqcsi = pucch_Config->format3->choice.setup->simultaneousHARQ_ACK_CSI; break; case NR_PUCCH_Resource__format_PR_format4: - mask = ((1 << pucchres->format.choice.format4->nrofSymbols) - 1) << pucchres->format.choice.format4->startingSymbolIndex; + mask = SL_to_bitmap(pucchres->format.choice.format4->startingSymbolIndex, pucchres->format.choice.format4->nrofSymbols); curr_pucch->simultaneous_harqcsi = pucch_Config->format4->choice.setup->simultaneousHARQ_ACK_CSI; break; default: @@ -775,43 +800,49 @@ void nr_csi_meas_reporting(int Mod_idP, } // verify resources are free for (int i = start; i < start + len; ++i) { - vrb_map_UL[i+bwp_start] |= mask; + if((vrb_map_UL[i+bwp_start] & mask) != 0) { + LOG_E(NR_MAC, "%4d.%2d VRB MAP in %4d.%2d not free. Can't schedule CSI reporting on PUCCH.\n", frame, slot, frame, sched_slot); + memset(curr_pucch, 0, sizeof(*curr_pucch)); + } + else + vrb_map_UL[i+bwp_start] |= mask; } } } } } -__attribute__((unused)) -static void handle_dl_harq(module_id_t mod_id, - int UE_id, +static void handle_dl_harq(NR_UE_info_t * UE, int8_t harq_pid, - bool success) + bool success, + int harq_round_max) { - NR_UE_info_t *UE_info = &RC.nrmac[mod_id]->UE_info; - NR_UE_harq_t *harq = &UE_info->UE_sched_ctrl[UE_id].harq_processes[harq_pid]; + NR_UE_harq_t *harq = &UE->UE_sched_ctrl.harq_processes[harq_pid]; harq->feedback_slot = -1; harq->is_waiting = false; if (success) { - add_tail_nr_list(&UE_info->UE_sched_ctrl[UE_id].available_dl_harq, harq_pid); + add_tail_nr_list(&UE->UE_sched_ctrl.available_dl_harq, harq_pid); harq->round = 0; harq->ndi ^= 1; - } else if (harq->round >= MAX_HARQ_ROUNDS - 1) { - add_tail_nr_list(&UE_info->UE_sched_ctrl[UE_id].available_dl_harq, harq_pid); + + } else if (harq->round >= harq_round_max - 1) { + add_tail_nr_list(&UE->UE_sched_ctrl.available_dl_harq, harq_pid); harq->round = 0; harq->ndi ^= 1; - NR_mac_stats_t *stats = &UE_info->mac_stats[UE_id]; - stats->dlsch_errors++; - LOG_D(NR_MAC, "retransmission error for UE %d (total %"PRIu64")\n", UE_id, stats->dlsch_errors); + + NR_mac_stats_t *stats = &UE->mac_stats; + stats->dl.errors++; + LOG_D(NR_MAC, "retransmission error for UE %04x (total %"PRIu64")\n", UE->rnti, stats->dl.errors); + } else { - add_tail_nr_list(&UE_info->UE_sched_ctrl[UE_id].retrans_dl_harq, harq_pid); + LOG_D(PHY,"NACK for: pid %d, ue %04x\n",harq_pid, UE->rnti); + add_tail_nr_list(&UE->UE_sched_ctrl.retrans_dl_harq, harq_pid); harq->round++; } } -int checkTargetSSBInFirst64TCIStates_pdschConfig(int ssb_index_t, int Mod_idP, int UE_id) { - NR_UE_info_t *UE_info = &RC.nrmac[Mod_idP]->UE_info; - NR_CellGroupConfig_t *CellGroup = UE_info->CellGroup[UE_id] ; +int checkTargetSSBInFirst64TCIStates_pdschConfig(int ssb_index_t, NR_UE_info_t * UE) { + NR_CellGroupConfig_t *CellGroup = UE->CellGroup; int nb_tci_states = CellGroup->spCellConfig->spCellConfigDedicated->initialDownlinkBWP->pdsch_Config->choice.setup->tci_StatesToAddModList->list.count; NR_TCI_State_t *tci =NULL; int i; @@ -836,15 +867,13 @@ int checkTargetSSBInFirst64TCIStates_pdschConfig(int ssb_index_t, int Mod_idP, i return -1; } -int checkTargetSSBInTCIStates_pdcchConfig(int ssb_index_t, int Mod_idP, int UE_id) { - NR_UE_info_t *UE_info = &RC.nrmac[Mod_idP]->UE_info; - NR_CellGroupConfig_t *CellGroup = UE_info->CellGroup[UE_id] ; +int checkTargetSSBInTCIStates_pdcchConfig(int ssb_index_t, NR_UE_info_t *UE) { + NR_CellGroupConfig_t *CellGroup = UE->CellGroup ; int nb_tci_states = CellGroup->spCellConfig->spCellConfigDedicated->initialDownlinkBWP->pdsch_Config->choice.setup->tci_StatesToAddModList->list.count; NR_TCI_State_t *tci =NULL; NR_TCI_StateId_t *tci_id = NULL; - int bwp_id = 1; - NR_BWP_Downlink_t *bwp = CellGroup->spCellConfig->spCellConfigDedicated->downlinkBWP_ToAddModList->list.array[bwp_id-1]; - NR_ControlResourceSet_t *coreset = bwp->bwp_Dedicated->pdcch_Config->choice.setup->controlResourceSetToAddModList->list.array[bwp_id-1]; + NR_UE_sched_ctrl_t *sched_ctrl = &UE->UE_sched_ctrl; + NR_ControlResourceSet_t *coreset = sched_ctrl->coreset; int i; int flag = 0; int tci_stateID = -1; @@ -898,7 +927,7 @@ int get_diff_rsrp(uint8_t index, int strongest_rsrp) { //identifies the target SSB Beam index //keeps the required date for PDCCH and PDSCH TCI state activation/deactivation CE consutruction globally //handles triggering of PDCCH and PDSCH MAC CEs -void tci_handling(module_id_t Mod_idP, int UE_id, frame_t frame, slot_t slot) { +void tci_handling(NR_UE_info_t *UE, frame_t frame, slot_t slot) { int strongest_ssb_rsrp = 0; int cqi_idx = 0; @@ -910,18 +939,23 @@ void tci_handling(module_id_t Mod_idP, int UE_id, frame_t frame, slot_t slot) { int ssb_index[MAX_NUM_SSB] = {0}; int ssb_rsrp[MAX_NUM_SSB] = {0}; uint8_t idx = 0; - int bwp_id = 1; - NR_UE_info_t *UE_info = &RC.nrmac[Mod_idP]->UE_info; - NR_CellGroupConfig_t *CellGroup = UE_info->CellGroup[UE_id]; - NR_BWP_Downlink_t *bwp = CellGroup->spCellConfig->spCellConfigDedicated->downlinkBWP_ToAddModList->list.array[bwp_id-1]; + + NR_UE_sched_ctrl_t *sched_ctrl = &UE->UE_sched_ctrl; + const int bwp_id = sched_ctrl->active_bwp ? sched_ctrl->active_bwp->bwp_Id : 0; + NR_CellGroupConfig_t *CellGroup = UE->CellGroup; + //bwp indicator - int n_dl_bwp = CellGroup->spCellConfig->spCellConfigDedicated->downlinkBWP_ToAddModList->list.count; + int n_dl_bwp=0; + if (CellGroup->spCellConfig && + CellGroup->spCellConfig->spCellConfigDedicated && + CellGroup->spCellConfig->spCellConfigDedicated->downlinkBWP_ToAddModList) + n_dl_bwp = CellGroup->spCellConfig->spCellConfigDedicated->downlinkBWP_ToAddModList->list.count; + uint8_t nr_ssbri_cri = 0; - uint8_t nb_of_csi_ssb_report = UE_info->csi_report_template[UE_id][cqi_idx].nb_of_csi_ssb_report; + uint8_t nb_of_csi_ssb_report = UE->csi_report_template[cqi_idx].nb_of_csi_ssb_report; int better_rsrp_reported = -140-(-0); /*minimum_measured_RSRP_value - minimum_differntail_RSRP_value*///considering the minimum RSRP value as better RSRP initially uint8_t diff_rsrp_idx = 0; uint8_t i, j; - NR_UE_sched_ctrl_t *sched_ctrl = &UE_info->UE_sched_ctrl[UE_id]; if (n_dl_bwp < 4) pdsch_bwp_id = bwp_id; @@ -989,7 +1023,7 @@ void tci_handling(module_id_t Mod_idP, int UE_id, frame_t frame, slot_t slot) { The length of the field is 7 bits */ if(sched_ctrl->UE_mac_ce_ctrl.pdcch_state_ind.coresetId == 0) { - int tci_state_id = checkTargetSSBInFirst64TCIStates_pdschConfig(ssb_index[target_ssb_beam_index], Mod_idP, UE_id); + int tci_state_id = checkTargetSSBInFirst64TCIStates_pdschConfig(ssb_index[target_ssb_beam_index], UE); if( tci_state_id != -1) sched_ctrl->UE_mac_ce_ctrl.pdcch_state_ind.tciStateId = tci_state_id; @@ -999,7 +1033,7 @@ void tci_handling(module_id_t Mod_idP, int UE_id, frame_t frame, slot_t slot) { int flag = 0; for(i =0; ssb_index_sorted[i]!=0; i++) { - tci_state_id = checkTargetSSBInFirst64TCIStates_pdschConfig(ssb_index_sorted[i], Mod_idP, UE_id) ; + tci_state_id = checkTargetSSBInFirst64TCIStates_pdschConfig(ssb_index_sorted[i],UE) ; if(tci_state_id != -1 && ssb_rsrp_sorted[i] > ssb_rsrp[curr_ssb_beam_index] && ssb_rsrp_sorted[i] - ssb_rsrp[curr_ssb_beam_index] > L1_RSRP_HYSTERIS) { sched_ctrl->UE_mac_ce_ctrl.pdcch_state_ind.tciStateId = tci_state_id; @@ -1013,7 +1047,7 @@ void tci_handling(module_id_t Mod_idP, int UE_id, frame_t frame, slot_t slot) { } } } else { - int tci_state_id = checkTargetSSBInTCIStates_pdcchConfig(ssb_index[target_ssb_beam_index], Mod_idP, UE_id); + int tci_state_id = checkTargetSSBInTCIStates_pdcchConfig(ssb_index[target_ssb_beam_index], UE); if (tci_state_id !=-1) sched_ctrl->UE_mac_ce_ctrl.pdcch_state_ind.tciStateId = tci_state_id; @@ -1023,7 +1057,7 @@ void tci_handling(module_id_t Mod_idP, int UE_id, frame_t frame, slot_t slot) { int flag = 0; for(i =0; ssb_index_sorted[i]!=0; i++) { - tci_state_id = checkTargetSSBInTCIStates_pdcchConfig(ssb_index_sorted[i], Mod_idP, UE_id); + tci_state_id = checkTargetSSBInTCIStates_pdcchConfig(ssb_index_sorted[i], UE); if( tci_state_id != -1 && ssb_rsrp_sorted[i] > ssb_rsrp[curr_ssb_beam_index] && ssb_rsrp_sorted[i] - ssb_rsrp[curr_ssb_beam_index] > L1_RSRP_HYSTERIS) { sched_ctrl->UE_mac_ce_ctrl.pdcch_state_ind.tciStateId = tci_state_id; @@ -1038,7 +1072,8 @@ void tci_handling(module_id_t Mod_idP, int UE_id, frame_t frame, slot_t slot) { } } - sched_ctrl->UE_mac_ce_ctrl.pdcch_state_ind.tci_present_inDCI = bwp->bwp_Dedicated->pdcch_Config->choice.setup->controlResourceSetToAddModList->list.array[bwp_id-1]->tci_PresentInDCI; + sched_ctrl->UE_mac_ce_ctrl.pdcch_state_ind.tci_present_inDCI = sched_ctrl->coreset ? + sched_ctrl->coreset->tci_PresentInDCI : NULL; //filling pdsch tci state activation deactivation mac ce structure fields if(sched_ctrl->UE_mac_ce_ctrl.pdcch_state_ind.tci_present_inDCI) { @@ -1083,15 +1118,14 @@ uint8_t pickandreverse_bits(uint8_t *payload, uint16_t bitlen, uint8_t start_bit } -void evaluate_rsrp_report(NR_UE_info_t *UE_info, +void evaluate_rsrp_report(NR_UE_info_t *UE, NR_UE_sched_ctrl_t *sched_ctrl, - int UE_id, uint8_t csi_report_id, uint8_t *payload, int *cumul_bits, NR_CSI_ReportConfig__reportQuantity_PR reportQuantity_type){ - nr_csi_report_t *csi_report = &UE_info->csi_report_template[UE_id][csi_report_id]; + nr_csi_report_t *csi_report = &UE->csi_report_template[csi_report_id]; uint8_t cri_ssbri_bitlen = csi_report->CSI_report_bitlen.cri_ssbri_bitlen; uint16_t curr_payload; @@ -1143,13 +1177,10 @@ void evaluate_rsrp_report(NR_UE_info_t *UE_info, } csi_report->nb_of_csi_ssb_report++; int strongest_ssb_rsrp = get_measured_rsrp(sched_ctrl->CSI_report.ssb_cri_report.RSRP); - NR_mac_stats_t *stats = &UE_info->mac_stats[UE_id]; + NR_mac_stats_t *stats = &UE->mac_stats; // including ssb rsrp in mac stats stats->cumul_rsrp += strongest_ssb_rsrp; stats->num_rsrp_meas++; - LOG_D(MAC,"rsrp_id = %d rsrp = %d\n", - sched_ctrl->CSI_report.ssb_cri_report.RSRP, - get_measured_rsrp(sched_ctrl->CSI_report.ssb_cri_report.RSRP)); } @@ -1174,7 +1205,7 @@ int evaluate_ri_report(uint8_t *payload, if ((ri_restriction>>i)&0x01) { if(count == ri_index) { sched_ctrl->CSI_report.cri_ri_li_pmi_cqi_report.ri = i; - LOG_I(MAC,"CSI Reported Rank %d\n", i+1); + LOG_D(MAC,"CSI Reported Rank %d\n", i+1); return i; } count++; @@ -1204,13 +1235,18 @@ void evaluate_cqi_report(uint8_t *payload, else AssertFatal(1==0,"CQI Table not present in RRC configuration\n"); sched_ctrl->CSI_report.cri_ri_li_pmi_cqi_report.wb_cqi_1tb = temp_cqi; - LOG_I(MAC,"Wide-band CQI for the first TB %d\n", temp_cqi); + LOG_D(MAC,"Wide-band CQI for the first TB %d\n", temp_cqi); if (cqi_bitlen > 4) { temp_cqi = pickandreverse_bits(payload, 4, cumul_bits); sched_ctrl->CSI_report.cri_ri_li_pmi_cqi_report.wb_cqi_2tb = temp_cqi; LOG_D(MAC,"Wide-band CQI for the second TB %d\n", temp_cqi); } - sched_ctrl->set_mcs = TRUE; + + // TODO for wideband case and multiple TB + const int cqi_idx = sched_ctrl->CSI_report.cri_ri_li_pmi_cqi_report.wb_cqi_1tb; + const int mcs_table = sched_ctrl->pdsch_semi_static.mcsTableIdx; + const int cqi_table = sched_ctrl->CSI_report.cri_ri_li_pmi_cqi_report.cqi_table; + sched_ctrl->dl_max_mcs = get_mcs_from_cqi(mcs_table, cqi_table, cqi_idx); } @@ -1229,10 +1265,11 @@ uint8_t evaluate_pmi_report(uint8_t *payload, sched_ctrl->CSI_report.cri_ri_li_pmi_cqi_report.pmi_x1 = temp_pmi&((1<CSI_report.cri_ri_li_pmi_cqi_report.pmi_x2 = (temp_pmi>>x1_bitlen)&((1<CSI_report.cri_ri_li_pmi_cqi_report.pmi_x1, sched_ctrl->CSI_report.cri_ri_li_pmi_cqi_report.pmi_x2); + sched_ctrl->set_pmi = true; return tot_bitlen; } @@ -1248,7 +1285,7 @@ int evaluate_li_report(uint8_t *payload, if (li_bitlen>0) { int temp_li = pickandreverse_bits(payload, li_bitlen, cumul_bits); - LOG_I(MAC,"LI %d\n",temp_li); + LOG_D(MAC,"LI %d\n",temp_li); sched_ctrl->CSI_report.cri_ri_li_pmi_cqi_report.li = temp_li; } return li_bitlen; @@ -1278,22 +1315,19 @@ void extract_pucch_csi_report(NR_CSI_MeasConfig_t *csi_MeasConfig, const nfapi_nr_uci_pucch_pdu_format_2_3_4_t *uci_pdu, frame_t frame, slot_t slot, - int UE_id, - module_id_t Mod_idP) { - + NR_UE_info_t *UE, + NR_ServingCellConfigCommon_t *scc) +{ /** From Table 6.3.1.1.2-3: RI, LI, CQI, and CRI of codebookType=typeI-SinglePanel */ - NR_ServingCellConfigCommon_t *scc = - RC.nrmac[Mod_idP]->common_channels->ServingCellConfigCommon; const int n_slots_frame = nr_slots_per_frame[*scc->ssbSubcarrierSpacing]; uint8_t *payload = uci_pdu->csi_part1.csi_part1_payload; uint16_t bitlen = uci_pdu->csi_part1.csi_part1_bit_len; NR_CSI_ReportConfig__reportQuantity_PR reportQuantity_type = NR_CSI_ReportConfig__reportQuantity_PR_NOTHING; - NR_UE_info_t *UE_info = &(RC.nrmac[Mod_idP]->UE_info); - NR_UE_sched_ctrl_t *sched_ctrl = &UE_info->UE_sched_ctrl[UE_id]; + NR_UE_sched_ctrl_t *sched_ctrl = &UE->UE_sched_ctrl; int cumul_bits = 0; int r_index = -1; for (int csi_report_id = 0; csi_report_id < csi_MeasConfig->csi_ReportConfigToAddModList->list.count; csi_report_id++ ) { - nr_csi_report_t *csi_report = &UE_info->csi_report_template[UE_id][csi_report_id]; + nr_csi_report_t *csi_report = &UE->csi_report_template[csi_report_id]; csi_report->nb_of_csi_ssb_report = 0; uint8_t cri_bitlen = 0; uint8_t ri_bitlen = 0; @@ -1308,10 +1342,10 @@ void extract_pucch_csi_report(NR_CSI_MeasConfig_t *csi_MeasConfig, LOG_D(MAC,"SFN/SF:%d/%d reportQuantity type = %d\n",frame,slot,reportQuantity_type); switch(reportQuantity_type){ case NR_CSI_ReportConfig__reportQuantity_PR_cri_RSRP: - evaluate_rsrp_report(UE_info,sched_ctrl,UE_id,csi_report_id,payload,&cumul_bits,reportQuantity_type); + evaluate_rsrp_report(UE,sched_ctrl,csi_report_id,payload,&cumul_bits,reportQuantity_type); break; case NR_CSI_ReportConfig__reportQuantity_PR_ssb_Index_RSRP: - evaluate_rsrp_report(UE_info,sched_ctrl,UE_id,csi_report_id,payload,&cumul_bits,reportQuantity_type); + evaluate_rsrp_report(UE,sched_ctrl,csi_report_id,payload,&cumul_bits,reportQuantity_type); break; case NR_CSI_ReportConfig__reportQuantity_PR_cri_RI_CQI: cri_bitlen = csi_report->csi_meas_bitlen.cri_bitlen; @@ -1338,6 +1372,7 @@ void extract_pucch_csi_report(NR_CSI_MeasConfig_t *csi_MeasConfig, if (r_index != -1) skip_zero_padding(&cumul_bits,csi_report,r_index,bitlen); pmi_bitlen = evaluate_pmi_report(payload,csi_report,cumul_bits,r_index,sched_ctrl); + sched_ctrl->CSI_report.cri_ri_li_pmi_cqi_report.csi_report_id = csi_report_id; cumul_bits += pmi_bitlen; evaluate_cqi_report(payload,csi_report,cumul_bits,r_index,sched_ctrl,csirep->cqi_Table); break; @@ -1355,6 +1390,7 @@ void extract_pucch_csi_report(NR_CSI_MeasConfig_t *csi_MeasConfig, if (r_index != -1) skip_zero_padding(&cumul_bits,csi_report,r_index,bitlen); pmi_bitlen = evaluate_pmi_report(payload,csi_report,cumul_bits,r_index,sched_ctrl); + sched_ctrl->CSI_report.cri_ri_li_pmi_cqi_report.csi_report_id = csi_report_id; cumul_bits += pmi_bitlen; evaluate_cqi_report(payload,csi_report,cumul_bits,r_index,sched_ctrl,csirep->cqi_Table); break; @@ -1365,7 +1401,7 @@ void extract_pucch_csi_report(NR_CSI_MeasConfig_t *csi_MeasConfig, } } -static NR_UE_harq_t *find_harq(module_id_t mod_id, frame_t frame, sub_frame_t slot, int UE_id) +static NR_UE_harq_t *find_harq(frame_t frame, sub_frame_t slot, NR_UE_info_t * UE, int harq_round_max) { /* In case of realtime problems: we can only identify a HARQ process by * timing. If the HARQ process's feedback_frame/feedback_slot is not the one we @@ -1373,7 +1409,7 @@ static NR_UE_harq_t *find_harq(module_id_t mod_id, frame_t frame, sub_frame_t sl * skip this HARQ process, which is what happens in the loop below. * Similarly, we might be "in advance", in which case we need to skip * this result. */ - NR_UE_sched_ctrl_t *sched_ctrl = &RC.nrmac[mod_id]->UE_info.UE_sched_ctrl[UE_id]; + NR_UE_sched_ctrl_t *sched_ctrl = &UE->UE_sched_ctrl; int8_t pid = sched_ctrl->feedback_dl_harq.head; if (pid < 0) return NULL; @@ -1382,14 +1418,14 @@ static NR_UE_harq_t *find_harq(module_id_t mod_id, frame_t frame, sub_frame_t sl while (harq->feedback_frame != frame || (harq->feedback_frame == frame && harq->feedback_slot < slot)) { LOG_W(NR_MAC, - "expected HARQ pid %d feedback at %d.%d, but is at %d.%d instead (HARQ feedback is in the past)\n", + "expected HARQ pid %d feedback at %4d.%2d, but is at %4d.%2d instead (HARQ feedback is in the past)\n", pid, harq->feedback_frame, harq->feedback_slot, frame, slot); remove_front_nr_list(&sched_ctrl->feedback_dl_harq); - handle_dl_harq(mod_id, UE_id, pid, 0); + handle_dl_harq(UE, pid, 0, harq_round_max); pid = sched_ctrl->feedback_dl_harq.head; if (pid < 0) return NULL; @@ -1398,7 +1434,7 @@ static NR_UE_harq_t *find_harq(module_id_t mod_id, frame_t frame, sub_frame_t sl /* feedbacks that we wait for in the future: don't do anything */ if (harq->feedback_slot > slot) { LOG_W(NR_MAC, - "expected HARQ pid %d feedback at %d.%d, but is at %d.%d instead (HARQ feedback is in the future)\n", + "expected HARQ pid %d feedback at %4d.%2d, but is at %4d.%2d instead (HARQ feedback is in the future)\n", pid, harq->feedback_frame, harq->feedback_slot, @@ -1414,20 +1450,19 @@ void handle_nr_uci_pucch_0_1(module_id_t mod_id, sub_frame_t slot, const nfapi_nr_uci_pucch_pdu_format_0_1_t *uci_01) { - int UE_id = find_nr_UE_id(mod_id, uci_01->rnti); - if (UE_id < 0) { + NR_UE_info_t * UE = find_nr_UE(&RC.nrmac[mod_id]->UE_info, uci_01->rnti); + if (!UE) { LOG_E(NR_MAC, "%s(): unknown RNTI %04x in PUCCH UCI\n", __func__, uci_01->rnti); return; } - NR_UE_info_t *UE_info = &RC.nrmac[mod_id]->UE_info; - NR_UE_sched_ctrl_t *sched_ctrl = &UE_info->UE_sched_ctrl[UE_id]; + NR_UE_sched_ctrl_t *sched_ctrl = &UE->UE_sched_ctrl; if (((uci_01->pduBitmap >> 1) & 0x01)) { // iterate over received harq bits for (int harq_bit = 0; harq_bit < uci_01->harq->num_harq; harq_bit++) { const uint8_t harq_value = uci_01->harq->harq_list[harq_bit].harq_value; const uint8_t harq_confidence = uci_01->harq->harq_confidence_level; - NR_UE_harq_t *harq = find_harq(mod_id, frame, slot, UE_id); + NR_UE_harq_t *harq = find_harq(frame, slot, UE, RC.nrmac[mod_id]->harq_round_max); if (!harq) { LOG_E(NR_MAC, "Oh no! Could not find a harq in %s!\n", __FUNCTION__); break; @@ -1435,9 +1470,9 @@ void handle_nr_uci_pucch_0_1(module_id_t mod_id, DevAssert(harq->is_waiting); const int8_t pid = sched_ctrl->feedback_dl_harq.head; remove_front_nr_list(&sched_ctrl->feedback_dl_harq); - LOG_D(NR_MAC,"bit %d pid %d ack/nack %d\n",harq_bit,pid,harq_value); - handle_dl_harq(mod_id, UE_id, pid, harq_value == 0 && harq_confidence == 0); - if (harq_confidence == 1) UE_info->mac_stats[UE_id].pucch0_DTX++; + LOG_D(NR_MAC,"%4d.%2d bit %d pid %d ack/nack %d\n",frame, slot, harq_bit,pid,harq_value); + handle_dl_harq(UE, pid, harq_value == 0 && harq_confidence == 0, RC.nrmac[mod_id]->harq_round_max); + if (harq_confidence == 1) UE->mac_stats.pucch0_DTX++; } } @@ -1462,81 +1497,129 @@ void handle_nr_uci_pucch_2_3_4(module_id_t mod_id, sub_frame_t slot, const nfapi_nr_uci_pucch_pdu_format_2_3_4_t *uci_234) { - int UE_id = find_nr_UE_id(mod_id, uci_234->rnti); - if (UE_id < 0) { + NR_UE_info_t * UE = find_nr_UE(&RC.nrmac[mod_id]->UE_info, uci_234->rnti); + if (!UE) { LOG_E(NR_MAC, "%s(): unknown RNTI %04x in PUCCH UCI\n", __func__, uci_234->rnti); return; } - AssertFatal(RC.nrmac[mod_id]->UE_info.CellGroup[UE_id],"Cellgroup is null for UE %d/%x\n",UE_id,uci_234->rnti); - AssertFatal(RC.nrmac[mod_id]->UE_info.CellGroup[UE_id]->spCellConfig, "Cellgroup->spCellConfig is null for UE %d/%x\n",UE_id,uci_234->rnti); - AssertFatal(RC.nrmac[mod_id]->UE_info.CellGroup[UE_id]->spCellConfig->spCellConfigDedicated, "Cellgroup->spCellConfig->spCellConfigDedicated is null for UE %d/%x\n",UE_id,uci_234->rnti); - if ( RC.nrmac[mod_id]->UE_info.CellGroup[UE_id]->spCellConfig->spCellConfigDedicated->csi_MeasConfig==NULL) return; + AssertFatal(UE->CellGroup,"Cellgroup is null for UE %04x\n", uci_234->rnti); + AssertFatal(UE->CellGroup->spCellConfig, + "Cellgroup->spCellConfig is null for UE %04x\n", uci_234->rnti); + AssertFatal(UE->CellGroup->spCellConfig->spCellConfigDedicated, + "Cellgroup->spCellConfig->spCellConfigDedicated is null for UE %04x\n", uci_234->rnti); + if ( UE->CellGroup->spCellConfig->spCellConfigDedicated->csi_MeasConfig==NULL) + return; - NR_CSI_MeasConfig_t *csi_MeasConfig = RC.nrmac[mod_id]->UE_info.CellGroup[UE_id]->spCellConfig->spCellConfigDedicated->csi_MeasConfig->choice.setup; - NR_UE_info_t *UE_info = &RC.nrmac[mod_id]->UE_info; - NR_UE_sched_ctrl_t *sched_ctrl = &UE_info->UE_sched_ctrl[UE_id]; + NR_CSI_MeasConfig_t *csi_MeasConfig = UE->CellGroup->spCellConfig->spCellConfigDedicated->csi_MeasConfig->choice.setup; + NR_UE_sched_ctrl_t *sched_ctrl = &UE->UE_sched_ctrl; // tpc (power control) - sched_ctrl->tpc1 = nr_get_tpc(RC.nrmac[mod_id]->pucch_target_snrx10, - uci_234->ul_cqi, - 30); - sched_ctrl->pucch_snrx10 = uci_234->ul_cqi * 5 - 640; + // TODO PUCCH2 SNR computation is not correct -> ignore the following + //sched_ctrl->tpc1 = nr_get_tpc(RC.nrmac[mod_id]->pucch_target_snrx10, + // uci_234->ul_cqi, + // 30); + //sched_ctrl->pucch_snrx10 = uci_234->ul_cqi * 5 - 640; if ((uci_234->pduBitmap >> 1) & 0x01) { // iterate over received harq bits for (int harq_bit = 0; harq_bit < uci_234->harq.harq_bit_len; harq_bit++) { const int acknack = ((uci_234->harq.harq_payload[harq_bit >> 3]) >> harq_bit) & 0x01; - NR_UE_harq_t *harq = find_harq(mod_id, frame, slot, UE_id); + NR_UE_harq_t *harq = find_harq(frame, slot, UE, RC.nrmac[mod_id]->harq_round_max); if (!harq) break; DevAssert(harq->is_waiting); const int8_t pid = sched_ctrl->feedback_dl_harq.head; remove_front_nr_list(&sched_ctrl->feedback_dl_harq); - handle_dl_harq(mod_id, UE_id, pid, uci_234->harq.harq_crc != 1 && acknack); + handle_dl_harq(UE, pid, uci_234->harq.harq_crc != 1 && acknack, RC.nrmac[mod_id]->harq_round_max); } } if ((uci_234->pduBitmap >> 2) & 0x01) { //API to parse the csi report and store it into sched_ctrl - extract_pucch_csi_report(csi_MeasConfig, uci_234, frame, slot, UE_id, mod_id); + extract_pucch_csi_report(csi_MeasConfig, uci_234, frame, slot, UE, RC.nrmac[mod_id]->common_channels->ServingCellConfigCommon); //TCI handling function - tci_handling(mod_id, UE_id,frame, slot); + tci_handling(UE,frame, slot); } if ((uci_234->pduBitmap >> 3) & 0x01) { //@TODO:Handle CSI Report 2 } } +bool test_acknack_vrb_occupation(NR_UE_sched_ctrl_t *sched_ctrl, + NR_sched_pucch_t *pucch, + uint16_t *vrb_map_UL, + const NR_ServingCellConfigCommon_t *scc, + NR_PUCCH_Config_t *pucch_Config, + int r_pucch, + int bwp_start, + int bwp_size) { + + // We assume initial cyclic shift is always 0 so different pucch resources can't overlap + + NR_sched_pucch_t *csi_pucch = &sched_ctrl->sched_pucch[1]; + if (csi_pucch && + csi_pucch->csi_bits > 0 && + csi_pucch->frame == pucch->frame && + csi_pucch->ul_slot == pucch->ul_slot && + csi_pucch->simultaneous_harqcsi && + (csi_pucch->csi_bits + csi_pucch->dai_c) < 11) + return true; // available resources for csi_pucch already verified + + if(r_pucch<0){ + const NR_PUCCH_Resource_t *resource = pucch_Config->resourceToAddModList->list.array[0]; + DevAssert(resource->format.present == NR_PUCCH_Resource__format_PR_format0); + pucch->second_hop_prb = resource->secondHopPRB!= NULL ? *resource->secondHopPRB : 0; + pucch->nr_of_symb = resource->format.choice.format0->nrofSymbols; + pucch->start_symb = resource->format.choice.format0->startingSymbolIndex; + pucch->prb_start = resource->startingPRB; + } + else{ + int rsetindex = *scc->uplinkConfigCommon->initialUplinkBWP->pucch_ConfigCommon->choice.setup->pucch_ResourceCommon; + set_r_pucch_parms(rsetindex, + r_pucch, + bwp_size, + &pucch->prb_start, + &pucch->second_hop_prb, + &pucch->nr_of_symb, + &pucch->start_symb); + } + + // verifying occupation of PRBs for ACK/NACK on dedicated pucch + for (int l=0; lnr_of_symb; l++) { + uint16_t symb = SL_to_bitmap(pucch->start_symb+l, 1); + int prb; + if (l==1 && pucch->second_hop_prb != 0) + prb = pucch->second_hop_prb; + else + prb = pucch->prb_start; + if ((vrb_map_UL[bwp_start+prb] & symb) != 0) { + return false; + break; + } + } + return true; +} + // this function returns an index to NR_sched_pucch structure // currently this structure contains PUCCH0 at index 0 and PUCCH2 at index 1 // if the function returns -1 it was not possible to schedule acknack // when current pucch is ready to be scheduled nr_fill_nfapi_pucch is called int nr_acknack_scheduling(int mod_id, - int UE_id, + NR_UE_info_t *UE, frame_t frame, sub_frame_t slot, int r_pucch, int is_common) { - const int CC_id = 0; const int minfbtime = RC.nrmac[mod_id]->minRXTXTIMEpdsch; const NR_ServingCellConfigCommon_t *scc = RC.nrmac[mod_id]->common_channels[CC_id].ServingCellConfigCommon; const int n_slots_frame = nr_slots_per_frame[*scc->ssbSubcarrierSpacing]; const NR_TDD_UL_DL_Pattern_t *tdd = scc->tdd_UL_DL_ConfigurationCommon ? &scc->tdd_UL_DL_ConfigurationCommon->pattern1 : NULL; - // initializing the values for FDD - int nr_slots_period = n_slots_frame; - int first_ul_slot_tdd = slot + minfbtime; - int first_ul_slot_period = 0; - if(tdd){ - nr_slots_period /= get_nb_periods_per_frame(tdd->dl_UL_TransmissionPeriodicity); - first_ul_slot_tdd = tdd->nrofDownlinkSlots + nr_slots_period * (slot / nr_slots_period); - first_ul_slot_period = tdd->nrofDownlinkSlots; - } - else - // if TDD configuration is not present and the band is not FDD, it means it is a dynamic TDD configuration - AssertFatal(RC.nrmac[mod_id]->common_channels[CC_id].frame_type == FDD,"Dynamic TDD not handled yet\n"); + AssertFatal(tdd || RC.nrmac[mod_id]->common_channels[CC_id].frame_type == FDD, "Dynamic TDD not handled yet\n"); + const int nr_slots_period = tdd ? n_slots_frame / get_nb_periods_per_frame(tdd->dl_UL_TransmissionPeriodicity) : n_slots_frame; + const int next_ul_slot = tdd ? tdd->nrofDownlinkSlots + nr_slots_period * (slot / nr_slots_period) : slot + minfbtime; + const int first_ul_slot_period = tdd ? tdd->nrofDownlinkSlots : 0; - NR_sched_pucch_t *csi_pucch; /* for the moment, we consider: * * only pucch_sched[0] holds HARQ (and SR) @@ -1544,9 +1627,27 @@ int nr_acknack_scheduling(int mod_id, * * SR uses format 0 and is allocated in the first UL (mixed) slot (and not * later) * * each UE has dedicated PUCCH Format 0 resources, and we use index 0! */ - NR_UE_sched_ctrl_t *sched_ctrl = &RC.nrmac[mod_id]->UE_info.UE_sched_ctrl[UE_id]; + NR_UE_sched_ctrl_t *sched_ctrl = &UE->UE_sched_ctrl; + NR_CellGroupConfig_t *cg = UE->CellGroup; + + NR_PUCCH_Config_t *pucch_Config = NULL; + if (sched_ctrl->active_ubwp) { + pucch_Config = sched_ctrl->active_ubwp->bwp_Dedicated->pucch_Config->choice.setup; + } else if (cg && + cg->spCellConfig && + cg->spCellConfig->spCellConfigDedicated && + cg->spCellConfig->spCellConfigDedicated->uplinkConfig && + cg->spCellConfig->spCellConfigDedicated->uplinkConfig->initialUplinkBWP) { + pucch_Config = cg->spCellConfig->spCellConfigDedicated->uplinkConfig->initialUplinkBWP->pucch_Config->choice.setup; + } + NR_BWP_t *genericParameters = sched_ctrl->active_ubwp ? + &sched_ctrl->active_ubwp->bwp_Common->genericParameters: + &scc->uplinkConfigCommon->initialUplinkBWP->genericParameters; + int bwp_start = NRRIV2PRBOFFSET(genericParameters->locationAndBandwidth,MAX_BWP_SIZE); + int bwp_size = NRRIV2BW(genericParameters->locationAndBandwidth, MAX_BWP_SIZE); + NR_sched_pucch_t *pucch = &sched_ctrl->sched_pucch[0]; - LOG_D(NR_MAC, "In %s: %d.%d Trying to allocate pucch, current DAI %d\n", __FUNCTION__, frame, slot, pucch->dai_c); + LOG_D(NR_MAC, "In %s: %4d.%2d Trying to allocate pucch, current DAI %d\n", __FUNCTION__, frame, slot, pucch->dai_c); pucch->r_pucch=r_pucch; AssertFatal(pucch->csi_bits == 0, @@ -1555,13 +1656,20 @@ int nr_acknack_scheduling(int mod_id, pucch->csi_bits); /* if the currently allocated PUCCH of this UE is full, allocate it */ + NR_sched_pucch_t *csi_pucch = &sched_ctrl->sched_pucch[1]; if (pucch->dai_c == 2) { /* advance the UL slot information in PUCCH by one so we won't schedule in * the same slot again */ const int f = pucch->frame; const int s = pucch->ul_slot; - LOG_D(NR_MAC, "In %s: %d.%d DAI = 2 pucch currently in %d.%d, advancing by 1 slot\n", __FUNCTION__, frame, slot, f, s); - nr_fill_nfapi_pucch(mod_id, frame, slot, pucch, UE_id); + LOG_D(NR_MAC, "In %s: %4d.%2d DAI = 2 pucch currently in %4d.%2d, advancing by 1 slot\n", __FUNCTION__, frame, slot, f, s); + + if (!(csi_pucch + && csi_pucch->csi_bits > 0 + && csi_pucch->frame == f + && csi_pucch->ul_slot == s)) + nr_fill_nfapi_pucch(RC.nrmac[mod_id], frame, slot, pucch, UE); + memset(pucch, 0, sizeof(*pucch)); pucch->frame = s == n_slots_frame - 1 ? (f + 1) % 1024 : f; if(((s + 1)%nr_slots_period) == 0) @@ -1569,15 +1677,17 @@ int nr_acknack_scheduling(int mod_id, else pucch->ul_slot = (s + 1) % n_slots_frame; // we assume that only two indices over the array sched_pucch exist - csi_pucch = &sched_ctrl->sched_pucch[1]; // skip the CSI PUCCH if it is present and if in the next frame/slot // and if we don't multiplex csi_pucch->r_pucch=-1; - if (csi_pucch->csi_bits > 0 + if (csi_pucch + && csi_pucch->csi_bits > 0 && csi_pucch->frame == pucch->frame && csi_pucch->ul_slot == pucch->ul_slot && !csi_pucch->simultaneous_harqcsi) { - nr_fill_nfapi_pucch(mod_id, frame, slot, csi_pucch, UE_id); + LOG_D(NR_MAC,"Cannot multiplex csi_pucch for %d.%d\n",csi_pucch->frame,csi_pucch->ul_slot); + nr_fill_nfapi_pucch(RC.nrmac[mod_id], frame, slot, csi_pucch, UE); + memset(csi_pucch, 0, sizeof(*csi_pucch)); pucch->frame = pucch->ul_slot == n_slots_frame - 1 ? (pucch->frame + 1) % 1024 : pucch->frame; if(((pucch->ul_slot + 1)%nr_slots_period) == 0) @@ -1587,10 +1697,9 @@ int nr_acknack_scheduling(int mod_id, } } - LOG_D(NR_MAC, "In %s: pucch_acknak 1. DL %d.%d, UL_ACK %d.%d, DAI_C %d\n", __FUNCTION__, frame, slot, pucch->frame, pucch->ul_slot, pucch->dai_c); + LOG_D(NR_MAC, "In %s: pucch_acknak 1. DL %4d.%2d, UL_ACK %4d.%2d, DAI_C %d\n", __FUNCTION__, frame, slot, pucch->frame, pucch->ul_slot, pucch->dai_c); // this is hardcoded for now as ue specific only if we are not on the initialBWP (to be fixed to allow ue_Specific also on initialBWP - NR_CellGroupConfig_t *cg = RC.nrmac[mod_id]->UE_info.CellGroup[UE_id]; NR_BWP_UplinkDedicated_t *ubwpd=NULL; if (cg && @@ -1602,13 +1711,12 @@ int nr_acknack_scheduling(int mod_id, NR_SearchSpace__searchSpaceType_PR ss_type = (is_common==0 && (sched_ctrl->active_bwp || ubwpd)) ? NR_SearchSpace__searchSpaceType_PR_ue_Specific: NR_SearchSpace__searchSpaceType_PR_common; uint8_t pdsch_to_harq_feedback[8]; - int bwp_Id = 0; - if (sched_ctrl->active_ubwp) bwp_Id = sched_ctrl->active_ubwp->bwp_Id; + const int bwp_id = sched_ctrl->active_bwp ? sched_ctrl->active_bwp->bwp_Id : 0; int max_fb_time = 0; - get_pdsch_to_harq_feedback(mod_id, UE_id, bwp_Id, ss_type, &max_fb_time, pdsch_to_harq_feedback); + get_pdsch_to_harq_feedback(UE, bwp_id, ss_type, &max_fb_time, pdsch_to_harq_feedback); - LOG_D(NR_MAC, "In %s: 1b. DL %d.%d, UL_ACK %d.%d, DAI_C %d\n", __FUNCTION__, frame,slot,pucch->frame,pucch->ul_slot,pucch->dai_c); + LOG_D(NR_MAC, "In %s: 1b. DL %4d.%2d, UL_ACK %4d.%2d, DAI_C %d\n", __FUNCTION__, frame,slot,pucch->frame,pucch->ul_slot,pucch->dai_c); /* there is a HARQ. Check whether we can use it for this ACKNACK */ if (pucch->dai_c > 0) { /* this UE already has a PUCCH occasion */ @@ -1628,25 +1736,37 @@ int nr_acknack_scheduling(int mod_id, const int f = pucch->frame; const int s = pucch->ul_slot; const int n_slots_frame = nr_slots_per_frame[*scc->ssbSubcarrierSpacing]; - LOG_D(NR_MAC, "In %s: %d.%d DAI > 0, cannot reach timing for pucch in %d.%d, advancing slot by 1 and trying again\n", __FUNCTION__, frame, slot, f, s); - nr_fill_nfapi_pucch(mod_id, frame, slot, pucch, UE_id); + LOG_D(NR_MAC, "In %s: %4d.%2d DAI > 0, cannot reach timing for pucch in %4d.%2d, advancing slot by 1 and trying again\n", __FUNCTION__, frame, slot, f, s); + if (!(csi_pucch && + csi_pucch->csi_bits > 0 && + csi_pucch->frame == f && + csi_pucch->ul_slot == s)) + nr_fill_nfapi_pucch(RC.nrmac[mod_id], frame, slot, pucch, UE); memset(pucch, 0, sizeof(*pucch)); pucch->frame = s == n_slots_frame - 1 ? (f + 1) % 1024 : f; if(((s + 1)%nr_slots_period) == 0) pucch->ul_slot = (s + 1 + first_ul_slot_period) % n_slots_frame; else pucch->ul_slot = (s + 1) % n_slots_frame; - return nr_acknack_scheduling(mod_id, UE_id, frame, slot, r_pucch,is_common); + return nr_acknack_scheduling(mod_id, UE, frame, slot, r_pucch,is_common); } pucch->timing_indicator = i; pucch->dai_c++; + // if there is CSI in this slot update the HARQ information for that one too + if (csi_pucch && + csi_pucch->csi_bits > 0 && + csi_pucch->frame == pucch->frame && + csi_pucch->ul_slot == pucch->ul_slot) { + csi_pucch->timing_indicator = i; + csi_pucch->dai_c++; + } // retain old resource indicator, and we are good - LOG_D(NR_MAC, "In %s: %d.%d. DAI > 0, pucch allocated for %d.%d (index %d)\n", __FUNCTION__, frame,slot,pucch->frame,pucch->ul_slot,pucch->timing_indicator); + LOG_D(NR_MAC, "In %s: %4d.%2d. DAI > 0, pucch allocated for %4d.%2d (index %d)\n", __FUNCTION__, frame,slot,pucch->frame,pucch->ul_slot,pucch->timing_indicator); return 0; } - LOG_D(NR_MAC, "In %s: %d.%d DAI = 0, looking for new pucch occasion\n", __FUNCTION__, frame, slot); + LOG_D(NR_MAC, "In %s: %4d.%2d DAI = 0, looking for new pucch occasion\n", __FUNCTION__, frame, slot); /* we need to find a new PUCCH occasion */ /*(Re)Inizialization of timing information*/ @@ -1654,33 +1774,46 @@ int nr_acknack_scheduling(int mod_id, ((pucch->frame*n_slots_frame + pucch->ul_slot) < (frame*n_slots_frame + slot))) { AssertFatal(pucch->sr_flag + pucch->dai_c == 0, - "expected no SR/AckNack for UE %d in %4d.%2d, but has %d/%d for %4d.%2d\n", - UE_id, frame, slot, pucch->sr_flag, pucch->dai_c, pucch->frame, pucch->ul_slot); - const int s = first_ul_slot_tdd; - pucch->frame = (s < n_slots_frame - 1) ? frame : (frame + 1) % 1024; + "expected no SR/AckNack for UE %04x in %4d.%2d, but has %d/%d for %4d.%2d\n", + UE->rnti, frame, slot, pucch->sr_flag, pucch->dai_c, pucch->frame, pucch->ul_slot); + const int s = next_ul_slot; + pucch->frame = s < n_slots_frame ? frame : (frame + 1) % 1024; pucch->ul_slot = s % n_slots_frame; } // Find the right timing_indicator value. int ind_found = -1; // while we are within the feedback limits + uint16_t *vrb_map_UL; while ((n_slots_frame + pucch->ul_slot - slot) % n_slots_frame <= max_fb_time) { - int i = 0; - while (i < 8) { - LOG_D(NR_MAC, "In %s: pdsch_to_harq_feedback[%d] = %d (pucch->ul_slot %d - slot %d)\n", __FUNCTION__, - i,pdsch_to_harq_feedback[i],pucch->ul_slot,slot); - int diff = pucch->ul_slot - slot; - if (diff<0) - diff += n_slots_frame; - if (pdsch_to_harq_feedback[i] == diff && - pdsch_to_harq_feedback[i] >= minfbtime) { - ind_found = i; - break; + // checking if in ul_slot the resources potentially to be assigned to this PUCCH are available + vrb_map_UL = &RC.nrmac[mod_id]->common_channels[CC_id].vrb_map_UL[pucch->ul_slot * MAX_BWP_SIZE]; + bool ret = test_acknack_vrb_occupation(sched_ctrl, + pucch, + vrb_map_UL, + scc, + pucch_Config, + r_pucch, + bwp_start, + bwp_size); + if (ret) { + int i = 0; + while (i < 8) { + LOG_D(NR_MAC,"pdsch_to_harq_feedback[%d] = %d (pucch->ul_slot %d - slot %d)\n", + i,pdsch_to_harq_feedback[i],pucch->ul_slot,slot); + int diff = pucch->ul_slot - slot; + if (diff<0) + diff += n_slots_frame; + if (pdsch_to_harq_feedback[i] == diff && + pdsch_to_harq_feedback[i] >= minfbtime) { + ind_found = i; + break; + } + ++i; } - ++i; + if (ind_found!=-1) + break; } - if (ind_found!=-1) - break; // advance to the next ul slot const int f = pucch->frame; const int s = pucch->ul_slot; @@ -1692,17 +1825,15 @@ int nr_acknack_scheduling(int mod_id, } if (ind_found==-1) { LOG_D(NR_MAC, - "%4d.%2d could not find pdsch_to_harq_feedback for UE %d: earliest " + "%4d.%2d could not find pdsch_to_harq_feedback for UE %04x: earliest " "ack slot %d\n", frame, slot, - UE_id, + UE->rnti, pucch->ul_slot); return -1; } - // is there already CSI in this slot? - csi_pucch = &sched_ctrl->sched_pucch[1]; if (csi_pucch && csi_pucch->csi_bits > 0 && csi_pucch->frame == pucch->frame && @@ -1712,7 +1843,9 @@ int nr_acknack_scheduling(int mod_id, // FIXME currently we support at most 11 bits in pucch2 so skip also in that case if(!csi_pucch->simultaneous_harqcsi || ((csi_pucch->csi_bits + csi_pucch->dai_c) >= 11)) { - nr_fill_nfapi_pucch(mod_id, frame, slot, csi_pucch, UE_id); + + LOG_D(NR_MAC,"Cannot multiplex csi_pucch %d +csi_pucch->dai_c %d for %d.%d\n",csi_pucch->csi_bits,csi_pucch->dai_c,csi_pucch->frame,csi_pucch->ul_slot); + nr_fill_nfapi_pucch(RC.nrmac[mod_id], frame, slot, csi_pucch, UE); memset(csi_pucch, 0, sizeof(*csi_pucch)); /* advance the UL slot information in PUCCH by one so we won't schedule in * the same slot again */ @@ -1724,91 +1857,63 @@ int nr_acknack_scheduling(int mod_id, pucch->ul_slot = (s + 1 + first_ul_slot_period) % n_slots_frame; else pucch->ul_slot = (s + 1) % n_slots_frame; - return nr_acknack_scheduling(mod_id, UE_id, frame, slot, r_pucch,is_common); + return nr_acknack_scheduling(mod_id, UE, frame, slot, r_pucch,is_common); } // multiplexing harq and csi in a pucch else { csi_pucch->timing_indicator = ind_found; csi_pucch->dai_c++; + // keep updating format 2 indicator + pucch->timing_indicator = ind_found; // index in the list of timing indicators + pucch->dai_c++; + + LOG_D(NR_MAC,"multiplexing csi_pucch %d +csi_pucch->dai_c %d for %d.%d\n",csi_pucch->csi_bits,csi_pucch->dai_c,csi_pucch->frame,csi_pucch->ul_slot); return 1; } } pucch->timing_indicator = ind_found; // index in the list of timing indicators - LOG_D(NR_MAC, "In %s: 2. DAI 0 DL %d.%d, UL_ACK %d.%d (index %d)\n", __FUNCTION__, frame,slot,pucch->frame,pucch->ul_slot,pucch->timing_indicator); + LOG_D(NR_MAC, "In %s: 2. DAI 0 DL %4d.%2d, UL_ACK %4d.%2d (index %d)\n", __FUNCTION__, frame,slot,pucch->frame,pucch->ul_slot,pucch->timing_indicator); pucch->dai_c++; pucch->resource_indicator = 0; // each UE has dedicated PUCCH resources pucch->r_pucch=r_pucch; - NR_PUCCH_Config_t *pucch_Config = NULL; - if (sched_ctrl->active_ubwp) { - pucch_Config = sched_ctrl->active_ubwp->bwp_Dedicated->pucch_Config->choice.setup; - } else if (RC.nrmac[mod_id]->UE_info.CellGroup[UE_id] && - RC.nrmac[mod_id]->UE_info.CellGroup[UE_id]->spCellConfig && - RC.nrmac[mod_id]->UE_info.CellGroup[UE_id]->spCellConfig->spCellConfigDedicated && - RC.nrmac[mod_id]->UE_info.CellGroup[UE_id]->spCellConfig->spCellConfigDedicated->uplinkConfig && - RC.nrmac[mod_id]->UE_info.CellGroup[UE_id]->spCellConfig->spCellConfigDedicated->uplinkConfig->initialUplinkBWP && - RC.nrmac[mod_id]->UE_info.CellGroup[UE_id]->spCellConfig->spCellConfigDedicated->uplinkConfig->initialUplinkBWP->pucch_Config->choice.setup) { - pucch_Config = RC.nrmac[mod_id]->UE_info.CellGroup[UE_id]->spCellConfig->spCellConfigDedicated->uplinkConfig->initialUplinkBWP->pucch_Config->choice.setup; - } - NR_BWP_t *genericParameters = sched_ctrl->active_ubwp ? - &sched_ctrl->active_ubwp->bwp_Common->genericParameters: - &scc->uplinkConfigCommon->initialUplinkBWP->genericParameters; - int bwp_start = NRRIV2PRBOFFSET(genericParameters->locationAndBandwidth,MAX_BWP_SIZE); - - /* verify that at that slot and symbol, resources are free. We only do this - * for initialCyclicShift 0 (we assume it always has that one), so other - * initialCyclicShifts can overlap with ICS 0!*/ - - if (pucch_Config) { - const NR_PUCCH_Resource_t *resource = pucch_Config->resourceToAddModList->list.array[pucch->resource_indicator]; - DevAssert(resource->format.present == NR_PUCCH_Resource__format_PR_format0); - int second_hop_prb = resource->secondHopPRB!= NULL ? *resource->secondHopPRB : 0; - int nr_of_symbols = resource->format.choice.format0->nrofSymbols; - if (resource->format.choice.format0->initialCyclicShift == 0) { - uint16_t *vrb_map_UL = &RC.nrmac[mod_id]->common_channels[CC_id].vrb_map_UL[pucch->ul_slot * MAX_BWP_SIZE]; - for (int l=0; lformat.choice.format0->startingSymbolIndex + l); - int prb; - if (l==1 && second_hop_prb != 0) - prb = second_hop_prb; - else - prb = resource->startingPRB; - if ((vrb_map_UL[bwp_start+prb] & symb) != 0) - LOG_W(MAC, "symbol 0x%x is not free for PUCCH alloc in vrb_map_UL at RB %ld and slot %d.%d\n", symb, resource->startingPRB, pucch->frame, pucch->ul_slot); - vrb_map_UL[bwp_start+prb] |= symb; - } - } + vrb_map_UL = &RC.nrmac[mod_id]->common_channels[CC_id].vrb_map_UL[pucch->ul_slot * MAX_BWP_SIZE]; + for (int l=0; lnr_of_symb; l++) { + uint16_t symb = SL_to_bitmap(pucch->start_symb+l, 1); + int prb; + if (l==1 && pucch->second_hop_prb != 0) + prb = pucch->second_hop_prb; + else + prb = pucch->prb_start; + vrb_map_UL[bwp_start+prb] |= symb; } return 0; } -void nr_sr_reporting(int Mod_idP, frame_t SFN, sub_frame_t slot) +void nr_sr_reporting(gNB_MAC_INST *nrmac, frame_t SFN, sub_frame_t slot) { - gNB_MAC_INST *nrmac = RC.nrmac[Mod_idP]; if (!is_xlsch_in_slot(nrmac->ulsch_slot_bitmap[slot / 64], slot)) return; NR_ServingCellConfigCommon_t *scc = nrmac->common_channels->ServingCellConfigCommon; const int n_slots_frame = nr_slots_per_frame[*scc->ssbSubcarrierSpacing]; - NR_UE_info_t *UE_info = &nrmac->UE_info; - NR_list_t *UE_list = &UE_info->list; - for (int UE_id = UE_list->head; UE_id >= 0; UE_id = UE_list->next[UE_id]) { - NR_UE_sched_ctrl_t *sched_ctrl = &UE_info->UE_sched_ctrl[UE_id]; + UE_iterator(nrmac->UE_info.list, UE) { + NR_UE_sched_ctrl_t *sched_ctrl = &UE->UE_sched_ctrl; if (sched_ctrl->ul_failure==1) continue; NR_PUCCH_Config_t *pucch_Config = NULL; if (sched_ctrl->active_ubwp) { pucch_Config = sched_ctrl->active_ubwp->bwp_Dedicated->pucch_Config->choice.setup; - } else if (RC.nrmac[Mod_idP]->UE_info.CellGroup[UE_id] && - RC.nrmac[Mod_idP]->UE_info.CellGroup[UE_id]->spCellConfig && - RC.nrmac[Mod_idP]->UE_info.CellGroup[UE_id]->spCellConfig->spCellConfigDedicated && - RC.nrmac[Mod_idP]->UE_info.CellGroup[UE_id]->spCellConfig->spCellConfigDedicated->uplinkConfig && - RC.nrmac[Mod_idP]->UE_info.CellGroup[UE_id]->spCellConfig->spCellConfigDedicated->uplinkConfig->initialUplinkBWP && - RC.nrmac[Mod_idP]->UE_info.CellGroup[UE_id]->spCellConfig->spCellConfigDedicated->uplinkConfig->initialUplinkBWP->pucch_Config->choice.setup) { - pucch_Config = RC.nrmac[Mod_idP]->UE_info.CellGroup[UE_id]->spCellConfig->spCellConfigDedicated->uplinkConfig->initialUplinkBWP->pucch_Config->choice.setup; + } else if (UE->CellGroup && + UE->CellGroup->spCellConfig && + UE->CellGroup->spCellConfig->spCellConfigDedicated && + UE->CellGroup->spCellConfig->spCellConfigDedicated->uplinkConfig && + UE->CellGroup->spCellConfig->spCellConfigDedicated->uplinkConfig->initialUplinkBWP && + UE->CellGroup->spCellConfig->spCellConfigDedicated->uplinkConfig->initialUplinkBWP->pucch_Config->choice.setup) { + pucch_Config = UE->CellGroup->spCellConfig->spCellConfigDedicated->uplinkConfig->initialUplinkBWP->pucch_Config->choice.setup; } else continue; @@ -1855,12 +1960,44 @@ void nr_sr_reporting(int Mod_idP, frame_t SFN, sub_frame_t slot) continue; nfapi_nr_pucch_pdu_t *pdu = &ul_tti_req->pdus_list[i].pucch_pdu; /* check that it is our PUCCH F0. Assuming there can be only one */ - if (pdu->rnti == UE_info->rnti[UE_id] + if (pdu->rnti == UE->rnti && pdu->format_type == 0 // does not use NR_PUCCH_Resource__format_PR_format0 && pdu->initial_cyclic_shift == pucch_res->format.choice.format0->initialCyclicShift && pdu->nr_of_symbols == pucch_res->format.choice.format0->nrofSymbols && pdu->start_symbol_index == pucch_res->format.choice.format0->startingSymbolIndex) { - LOG_D(NR_MAC,"%4d.%2d adding SR_flag 1 to PUCCH nFAPI SR for RNTI %04x\n", SFN, slot, pdu->rnti); + LOG_D(NR_MAC,"%4d.%2d adding SR_flag 1 to PUCCH format 0 nFAPI SR for RNTI %04x\n", SFN, slot, pdu->rnti); + pdu->sr_flag = 1; + nfapi_allocated = true; + break; + } else if (pdu->rnti == UE->rnti + && pdu->format_type == 2 // does not use NR_PUCCH_Resource__format_PR_format0 + && pdu->nr_of_symbols == pucch_res->format.choice.format2->nrofSymbols + && pdu->start_symbol_index == pucch_res->format.choice.format2->startingSymbolIndex) { + LOG_D(NR_MAC,"%4d.%2d adding SR_flag 1 to PUCCH format 2 nFAPI SR for RNTI %04x\n", SFN, slot, pdu->rnti); + pdu->sr_flag = 1; + nfapi_allocated = true; + break; + } else if (pdu->rnti == UE->rnti + && pdu->format_type == 1 // does not use NR_PUCCH_Resource__format_PR_format0 + && pdu->nr_of_symbols == pucch_res->format.choice.format1->nrofSymbols + && pdu->start_symbol_index == pucch_res->format.choice.format1->startingSymbolIndex) { + LOG_D(NR_MAC,"%4d.%2d adding SR_flag 1 to PUCCH format 1 nFAPI SR for RNTI %04x\n", SFN, slot, pdu->rnti); + pdu->sr_flag = 1; + nfapi_allocated = true; + break; + } else if (pdu->rnti == UE->rnti + && pdu->format_type == 3 // does not use NR_PUCCH_Resource__format_PR_format0 + && pdu->nr_of_symbols == pucch_res->format.choice.format3->nrofSymbols + && pdu->start_symbol_index == pucch_res->format.choice.format3->startingSymbolIndex) { + LOG_D(NR_MAC,"%4d.%2d adding SR_flag 1 to PUCCH format 3 nFAPI SR for RNTI %04x\n", SFN, slot, pdu->rnti); + pdu->sr_flag = 1; + nfapi_allocated = true; + break; + } else if (pdu->rnti == UE->rnti + && pdu->format_type == 4 // does not use NR_PUCCH_Resource__format_PR_format0 + && pdu->nr_of_symbols == pucch_res->format.choice.format4->nrofSymbols + && pdu->start_symbol_index == pucch_res->format.choice.format4->startingSymbolIndex) { + LOG_D(NR_MAC,"%4d.%2d adding SR_flag 1 to PUCCH format 4 nFAPI SR for RNTI %04x\n", SFN, slot, pdu->rnti); pdu->sr_flag = 1; nfapi_allocated = true; break; @@ -1880,13 +2017,14 @@ void nr_sr_reporting(int Mod_idP, frame_t SFN, sub_frame_t slot) } curr_pucch->sr_flag = true; } else { - NR_sched_pucch_t sched_sr; - memset(&sched_sr, 0, sizeof(sched_sr)); - sched_sr.frame = SFN; - sched_sr.ul_slot = slot; - sched_sr.resource_indicator = found; - sched_sr.sr_flag = true; - nr_fill_nfapi_pucch(Mod_idP, SFN, slot, &sched_sr, UE_id); + NR_sched_pucch_t sched_sr = { + .frame = SFN, + .ul_slot = slot, + .sr_flag = true, + .resource_indicator = found, + .r_pucch = -1 + }; + nr_fill_nfapi_pucch(nrmac, SFN, slot, &sched_sr, UE); } } } diff --git a/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_ulsch.c b/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_ulsch.c index a49154f20d..495ca765e6 100644 --- a/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_ulsch.c +++ b/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_ulsch.c @@ -39,137 +39,25 @@ int get_dci_format(NR_UE_sched_ctrl_t *sched_ctrl) { - const long f = sched_ctrl->search_space->searchSpaceType->choice.ue_Specific->dci_Formats; - int dci_format; - if (sched_ctrl->search_space) { - dci_format = f ? NR_UL_DCI_FORMAT_0_1 : NR_UL_DCI_FORMAT_0_0; - } - else { - dci_format = NR_UL_DCI_FORMAT_0_0; - } + int dci_format = sched_ctrl->search_space && sched_ctrl->search_space->searchSpaceType && + sched_ctrl->search_space->searchSpaceType->present == NR_SearchSpace__searchSpaceType_PR_ue_Specific ? + NR_UL_DCI_FORMAT_0_1 : NR_UL_DCI_FORMAT_0_0; - return(dci_format); + return(dci_format); } -void calculate_preferred_ul_tda(module_id_t module_id, const NR_BWP_Uplink_t *ubwp) -{ - gNB_MAC_INST *nrmac = RC.nrmac[module_id]; - const int bwp_id = ubwp->bwp_Id; - if (nrmac->preferred_ul_tda[bwp_id]) - return; +const int get_ul_tda(const gNB_MAC_INST *nrmac, const NR_ServingCellConfigCommon_t *scc, int slot) { /* there is a mixed slot only when in TDD */ - NR_ServingCellConfigCommon_t *scc = nrmac->common_channels->ServingCellConfigCommon; - lte_frame_type_t frame_type = nrmac->common_channels->frame_type; - const int n = nr_slots_per_frame[*scc->ssbSubcarrierSpacing]; - const int mu = scc->uplinkConfigCommon->initialUplinkBWP->genericParameters.subcarrierSpacing; - const NR_TDD_UL_DL_Pattern_t *tdd = - scc->tdd_UL_DL_ConfigurationCommon ? &scc->tdd_UL_DL_ConfigurationCommon->pattern1 : NULL; - /* Uplink symbols are at the end of the slot */ - int symb_ulMixed = 0; - int nr_mix_slots = 0; - int nr_slots_period = n; - if (tdd) { - symb_ulMixed = ((1 << tdd->nrofUplinkSymbols) - 1) << (14 - tdd->nrofUplinkSymbols); - nr_mix_slots = tdd->nrofDownlinkSymbols != 0 || tdd->nrofUplinkSymbols != 0; - nr_slots_period /= get_nb_periods_per_frame(tdd->dl_UL_TransmissionPeriodicity); - } - else - // if TDD configuration is not present and the band is not FDD, it means it is a dynamic TDD configuration - AssertFatal(nrmac->common_channels->frame_type == FDD,"Dynamic TDD not handled yet\n"); + const NR_TDD_UL_DL_Pattern_t *tdd = scc->tdd_UL_DL_ConfigurationCommon ? &scc->tdd_UL_DL_ConfigurationCommon->pattern1 : NULL; + AssertFatal(tdd || nrmac->common_channels->frame_type == FDD, "Dynamic TDD not handled yet\n"); - const struct NR_PUCCH_Config__resourceToAddModList *resList = ubwp->bwp_Dedicated->pucch_Config->choice.setup->resourceToAddModList; - // for the moment, just block any symbol that might hold a PUCCH, regardless - // of the RB. This is a big simplification, as most RBs will NOT have a PUCCH - // in the respective symbols, but it simplifies scheduling - uint16_t symb_pucch = 0; - for (int i = 0; i < resList->list.count; ++i) { - const NR_PUCCH_Resource_t *resource = resList->list.array[i]; - int nrofSymbols = 0; - int startingSymbolIndex = 0; - switch (resource->format.present) { - case NR_PUCCH_Resource__format_PR_format0: - nrofSymbols = resource->format.choice.format0->nrofSymbols; - startingSymbolIndex = resource->format.choice.format0->startingSymbolIndex; - break; - case NR_PUCCH_Resource__format_PR_format1: - nrofSymbols = resource->format.choice.format1->nrofSymbols; - startingSymbolIndex = resource->format.choice.format1->startingSymbolIndex; - break; - case NR_PUCCH_Resource__format_PR_format2: - nrofSymbols = resource->format.choice.format2->nrofSymbols; - startingSymbolIndex = resource->format.choice.format2->startingSymbolIndex; - break; - case NR_PUCCH_Resource__format_PR_format3: - nrofSymbols = resource->format.choice.format3->nrofSymbols; - startingSymbolIndex = resource->format.choice.format3->startingSymbolIndex; - break; - case NR_PUCCH_Resource__format_PR_format4: - nrofSymbols = resource->format.choice.format4->nrofSymbols; - startingSymbolIndex = resource->format.choice.format4->startingSymbolIndex; - break; - default: - AssertFatal(0, "found NR_PUCCH format index %d\n", resource->format.present); - break; - } - symb_pucch |= ((1 << nrofSymbols) - 1) << startingSymbolIndex; - } - - /* check that TDA index 1 fits into UL slot and does not overlap with PUCCH */ - const struct NR_PUSCH_TimeDomainResourceAllocationList *tdaList = ubwp->bwp_Common->pusch_ConfigCommon->choice.setup->pusch_TimeDomainAllocationList; - const NR_PUSCH_TimeDomainResourceAllocation_t *tdaP_UL = tdaList->list.array[0]; - const int k2 = get_K2(scc, (NR_BWP_Uplink_t*)ubwp,0, mu); - int start, len; - SLIV2SL(tdaP_UL->startSymbolAndLength, &start, &len); - const uint16_t symb_tda = ((1 << len) - 1) << start; - // check whether PUCCH and TDA overlap: then, we cannot use it. Note that - // here we assume that the PUCCH is scheduled in every slot, and on all RBs - // (which is mostly not true, this is a simplification) - AssertFatal((symb_pucch & symb_tda) == 0, "TDA index 0 for UL overlaps with PUCCH\n"); - - // get largest time domain allocation (TDA) for UL slot and UL in mixed slot - int tdaMi = -1; - if (nr_mix_slots>0) { - const NR_PUSCH_TimeDomainResourceAllocation_t *tdaP_Mi = tdaList->list.array[1]; - AssertFatal(k2 == get_K2(scc, (NR_BWP_Uplink_t*)ubwp, 1, mu), - "scheduler cannot handle different k2 for UL slot (%d) and UL Mixed slot (%ld)\n", - k2, - get_K2(scc, (NR_BWP_Uplink_t*)ubwp, 1, mu)); - SLIV2SL(tdaP_Mi->startSymbolAndLength, &start, &len); - const uint16_t symb_tda_mi = ((1 << len) - 1) << start; - // check whether PUCCH and TDA overlap: then, we cannot use it. Also, check - // whether TDA is entirely within mixed slot, UL. Note that here we assume - // that the PUCCH is scheduled in every slot, and on all RBs (which is - // mostly not true, this is a simplification) - if ((symb_pucch & symb_tda_mi) == 0 && (symb_ulMixed & symb_tda_mi) == symb_tda_mi) { - tdaMi = 1; - } else { - LOG_E(NR_MAC, - "TDA index 1 UL overlaps with PUCCH or is not entirely in mixed slot (symb_pucch %x symb_ulMixed %x symb_tda_mi %x), won't schedule UL mixed slot\n", - symb_pucch, - symb_ulMixed, - symb_tda_mi); - } - } - - nrmac->preferred_ul_tda[bwp_id] = malloc(n * sizeof(*nrmac->preferred_ul_tda[bwp_id])); - - for (int slot = 0; slot < n; ++slot) { - const int sched_slot = (slot + k2) % n; - nrmac->preferred_ul_tda[bwp_id][slot] = -1; - if (frame_type == FDD || sched_slot % nr_slots_period >= tdd->nrofDownlinkSlots + nr_mix_slots) - nrmac->preferred_ul_tda[bwp_id][slot] = 0; - else if (nr_mix_slots && sched_slot % nr_slots_period == tdd->nrofDownlinkSlots) - nrmac->preferred_ul_tda[bwp_id][slot] = tdaMi; - LOG_D(MAC, "DL slot %d UL slot %d preferred_ul_tda %d\n", slot, sched_slot, nrmac->preferred_ul_tda[bwp_id][slot]); - } - - if (tdd && k2 < tdd->nrofUplinkSlots) { - LOG_W(NR_MAC, - "k2 %d < tdd->nrofUplinkSlots %ld: not all UL slots can be scheduled\n", - k2, - tdd->nrofUplinkSlots); + if (tdd && tdd->nrofUplinkSymbols > 1) { // if there is uplink symbols in mixed slot + const int nr_slots_period = tdd->nrofDownlinkSlots + tdd->nrofUplinkSlots + 1; + if ((slot%nr_slots_period) == tdd->nrofDownlinkSlots) + return 1; } + return 0; // if FDD or not mixed slot in TDD, for now use default TDA (TODO handle CSI-RS slots) } // For both UL-SCH except: @@ -196,8 +84,8 @@ void calculate_preferred_ul_tda(module_id_t module_id, const NR_BWP_Uplink_t *ub // F: length of L is 0:8 or 1:16 bits wide // R: Reserved bit, set to zero. -int nr_process_mac_pdu(module_id_t module_idP, - int UE_id, +int nr_process_mac_pdu( instance_t module_idP, + NR_UE_info_t* UE, uint8_t CC_id, frame_t frameP, sub_frame_t slot, @@ -205,17 +93,13 @@ int nr_process_mac_pdu(module_id_t module_idP, int pdu_len) { - uint8_t rx_lcid; - uint8_t done = 0; - uint16_t mac_ce_len; - uint16_t mac_subheader_len; - uint16_t mac_sdu_len; - NR_UE_info_t *UE_info = &RC.nrmac[module_idP]->UE_info; - NR_UE_sched_ctrl_t *sched_ctrl = &UE_info->UE_sched_ctrl[UE_id]; + uint8_t done = 0; + + NR_UE_sched_ctrl_t *sched_ctrl = &UE->UE_sched_ctrl; if ( pduP[0] != UL_SCH_LCID_PADDING ) - trace_NRpdu(DIRECTION_UPLINK, pduP, pdu_len, UE_id, WS_C_RNTI, UE_info->rnti[UE_id], frameP, 0, 0, 0); + trace_NRpdu(DIRECTION_UPLINK, pduP, pdu_len, WS_C_RNTI, UE->rnti, frameP, 0, 0, 0); #ifdef ENABLE_MAC_PAYLOAD_DEBUG LOG_I(NR_MAC, "In %s: dumping MAC PDU in %d.%d:\n", __func__, frameP, slot); @@ -223,10 +107,9 @@ int nr_process_mac_pdu(module_id_t module_idP, #endif while (!done && pdu_len > 0){ - mac_ce_len = 0; - mac_subheader_len = sizeof(NR_MAC_SUBHEADER_FIXED); - mac_sdu_len = 0; - rx_lcid = ((NR_MAC_SUBHEADER_FIXED *)pduP)->LCID; + uint16_t mac_len=0; + uint16_t mac_subheader_len=sizeof(NR_MAC_SUBHEADER_FIXED); + uint8_t rx_lcid = ((NR_MAC_SUBHEADER_FIXED *)pduP)->LCID; LOG_D(NR_MAC, "In %s: received UL-SCH sub-PDU with LCID 0x%x in %d.%d (remaining PDU length %d)\n", __func__, rx_lcid, frameP, slot, pdu_len); @@ -241,7 +124,7 @@ int nr_process_mac_pdu(module_id_t module_idP, #endif*/ case UL_SCH_LCID_RECOMMENDED_BITRATE_QUERY: // 38.321 Ch6.1.3.20 - mac_ce_len = 2; + mac_len = 2; break; case UL_SCH_LCID_CONFIGURED_GRANT_CONFIRMATION: // 38.321 Ch6.1.3.7 @@ -251,7 +134,7 @@ int nr_process_mac_pdu(module_id_t module_idP, case UL_SCH_LCID_S_TRUNCATED_BSR: //38.321 section 6.1.3.1 //fixed length - mac_ce_len =1; + mac_len =1; /* Extract short BSR value */ ce_ptr = &pduP[mac_subheader_len]; NR_BSR_SHORT *bsr_s = (NR_BSR_SHORT *) ce_ptr; @@ -271,12 +154,13 @@ int nr_process_mac_pdu(module_id_t module_idP, case UL_SCH_LCID_L_TRUNCATED_BSR: //38.321 section 6.1.3.1 //variable length - mac_ce_len |= (uint16_t)((NR_MAC_SUBHEADER_SHORT *)pduP)->L; - mac_subheader_len = 2; - if(((NR_MAC_SUBHEADER_SHORT *)pduP)->F){ - mac_ce_len |= (uint16_t)(((NR_MAC_SUBHEADER_LONG *)pduP)->L2)<<8; - mac_subheader_len = 3; - } + /* Several checks have been added to this function to + ensure that the casting of the pduP is possible. There seems + to be a partial PDU at the end of this buffer, so here + we gracefully ignore that by returning 0. See: + https://gitlab.eurecom.fr/oai/openairinterface5g/-/issues/534 */ + if (!get_mac_len(pduP, pdu_len, &mac_len, &mac_subheader_len)) + return 0; /* Extract long BSR value */ ce_ptr = &pduP[mac_subheader_len]; NR_BSR_LONG *bsr_l = (NR_BSR_LONG *) ce_ptr; @@ -312,7 +196,7 @@ int nr_process_mac_pdu(module_id_t module_idP, for (int i = 0; i < NR_NB_RA_PROC_MAX; i++) { NR_RA_t *ra = &RC.nrmac[module_idP]->common_channels[CC_id].ra[i]; - if (ra->state >= WAIT_Msg3 && ra->rnti == UE_info->rnti[UE_id]) { + if (ra->state >= WAIT_Msg3 && ra->rnti == UE->rnti) { ra->crnti = ((pduP[1]&0xFF)<<8)|(pduP[2]&0xFF); ra->msg3_dcch_dtch = true; LOG_I(NR_MAC, "Received UL_SCH_LCID_C_RNTI with C-RNTI 0x%04x\n", ra->crnti); @@ -322,14 +206,14 @@ int nr_process_mac_pdu(module_id_t module_idP, //38.321 section 6.1.3.2 //fixed length - mac_ce_len = 2; + mac_len = 2; /* Extract CRNTI value */ break; case UL_SCH_LCID_SINGLE_ENTRY_PHR: //38.321 section 6.1.3.8 //fixed length - mac_ce_len = 2; + mac_len = 2; /* Extract SINGLE ENTRY PHR elements for PHR calculation */ ce_ptr = &pduP[mac_subheader_len]; NR_SINGLE_ENTRY_PHR_MAC_CE *phr = (NR_SINGLE_ENTRY_PHR_MAC_CE *) ce_ptr; @@ -350,24 +234,16 @@ int nr_process_mac_pdu(module_id_t module_idP, case UL_SCH_LCID_MULTI_ENTRY_PHR_1_OCT: //38.321 section 6.1.3.9 // varialbe length - mac_ce_len |= (uint16_t)((NR_MAC_SUBHEADER_SHORT *)pduP)->L; - mac_subheader_len = 2; - if(((NR_MAC_SUBHEADER_SHORT *)pduP)->F){ - mac_ce_len |= (uint16_t)(((NR_MAC_SUBHEADER_LONG *)pduP)->L2)<<8; - mac_subheader_len = 3; - } + if (!get_mac_len(pduP, pdu_len, &mac_len, &mac_subheader_len)) + return 0; /* Extract MULTI ENTRY PHR elements from single octet bitmap for PHR calculation */ break; case UL_SCH_LCID_MULTI_ENTRY_PHR_4_OCT: //38.321 section 6.1.3.9 // varialbe length - mac_ce_len |= (uint16_t)((NR_MAC_SUBHEADER_SHORT *)pduP)->L; - mac_subheader_len = 2; - if(((NR_MAC_SUBHEADER_SHORT *)pduP)->F){ - mac_ce_len |= (uint16_t)(((NR_MAC_SUBHEADER_LONG *)pduP)->L2)<<8; - mac_subheader_len = 3; - } + if (!get_mac_len(pduP, pdu_len, &mac_len, &mac_subheader_len)) + return 0; /* Extract MULTI ENTRY PHR elements from four octets bitmap for PHR calculation */ break; @@ -378,32 +254,26 @@ int nr_process_mac_pdu(module_id_t module_idP, case UL_SCH_LCID_SRB1: case UL_SCH_LCID_SRB2: - if(((NR_MAC_SUBHEADER_SHORT *)pduP)->F){ - //mac_sdu_len |= (uint16_t)(((NR_MAC_SUBHEADER_LONG *)pduP)->L2)<<8; - mac_subheader_len = 3; - mac_sdu_len = ((uint16_t)(((NR_MAC_SUBHEADER_LONG *) pduP)->L1 & 0x7f) << 8) - | ((uint16_t)((NR_MAC_SUBHEADER_LONG *) pduP)->L2 & 0xff); - } else { - mac_sdu_len = (uint16_t)((NR_MAC_SUBHEADER_SHORT *)pduP)->L; - mac_subheader_len = 2; - } + if (!get_mac_len(pduP, pdu_len, &mac_len, &mac_subheader_len)) + return 0; - rnti_t crnti = UE_info->rnti[UE_id]; - int UE_idx = UE_id; + rnti_t crnti = UE->rnti; + NR_UE_info_t* UE_idx = UE; for (int i = 0; i < NR_NB_RA_PROC_MAX; i++) { NR_RA_t *ra = &RC.nrmac[module_idP]->common_channels[CC_id].ra[i]; - if (ra->state >= WAIT_Msg3 && ra->rnti == UE_info->rnti[UE_id]) { - uint8_t *next_subpduP = pduP + mac_subheader_len + mac_sdu_len; - if ((pduP[mac_subheader_len+mac_sdu_len] & 0x3F) == UL_SCH_LCID_C_RNTI) { + if (ra->state >= WAIT_Msg3 && ra->rnti == UE->rnti) { + uint8_t *next_subpduP = pduP + mac_subheader_len + mac_len; + if ((pduP[mac_subheader_len+mac_len] & 0x3F) == UL_SCH_LCID_C_RNTI) { crnti = ((next_subpduP[1]&0xFF)<<8)|(next_subpduP[2]&0xFF); - UE_idx = find_nr_UE_id(module_idP, crnti); + LOG_W(NR_MAC, " UL_SCH_LCID_SRB for rnti %04x\n", crnti); + UE_idx = find_nr_UE(&RC.nrmac[module_idP]->UE_info, crnti); break; } } } - if (UE_info->CellGroup[UE_idx]) { - LOG_D(NR_MAC, "[UE %d] Frame %d : ULSCH -> UL-DCCH %d (gNB %d, %d bytes), rnti: 0x%04x \n", module_idP, frameP, rx_lcid, module_idP, mac_sdu_len, crnti); + if (UE_idx->CellGroup) { + LOG_D(NR_MAC, "Frame %d : ULSCH -> UL-DCCH %d (gNB %ld, %d bytes), rnti: 0x%04x \n", frameP, rx_lcid, module_idP, mac_len, crnti); mac_rlc_data_ind(module_idP, crnti, module_idP, @@ -412,11 +282,11 @@ int nr_process_mac_pdu(module_id_t module_idP, MBMS_FLAG_NO, rx_lcid, (char *) (pduP + mac_subheader_len), - mac_sdu_len, + mac_len, 1, NULL); } else { - AssertFatal(1==0,"[UE %d] Frame/Slot %d.%d : Received LCID %d which is not configured, dropping packet\n",UE_id,frameP,slot,rx_lcid); + AssertFatal(1==0,"[UE %04x] Frame/Slot %d.%d : Received LCID %d which is not configured, dropping packet\n",UE->rnti,frameP,slot,rx_lcid); } break; case UL_SCH_LCID_SRB3: @@ -430,23 +300,23 @@ int nr_process_mac_pdu(module_id_t module_idP, if ( rx_lcid == UL_SCH_LCID_CCCH1 ) { // RRCResumeRequest1 message includes the full I-RNTI and has a size of 8 bytes - mac_sdu_len = 8; + mac_len = 8; // Check if it is a valid CCCH1 message, we get all 00's messages very often int i = 0; - for(i=0; i<(mac_subheader_len+mac_sdu_len); i++) { + for(i=0; i<(mac_subheader_len+mac_len); i++) { if(pduP[i] != 0) { break; } } - if (i == (mac_subheader_len+mac_sdu_len)) { + if (i == (mac_subheader_len+mac_len)) { LOG_D(NR_MAC, "%s() Invalid CCCH1 message!, pdu_len: %d\n", __func__, pdu_len); done = 1; break; } } else { // fixed length of 6 bytes - mac_sdu_len = 6; + mac_len = 6; } nr_mac_rrc_data_ind(module_idP, @@ -454,52 +324,44 @@ int nr_process_mac_pdu(module_id_t module_idP, frameP, 0, 0, - UE_info->rnti[UE_id], + UE->rnti, CCCH, pduP + mac_subheader_len, - mac_sdu_len, + mac_len, 0); break; - case UL_SCH_LCID_DTCH: + case UL_SCH_LCID_DTCH ... (UL_SCH_LCID_DTCH + 28): // check if LCID is valid at current time. - if (((NR_MAC_SUBHEADER_SHORT *)pduP)->F) { - // mac_sdu_len |= (uint16_t)(((NR_MAC_SUBHEADER_LONG *)pduP)->L2)<<8; - mac_subheader_len = 3; - mac_sdu_len = ((uint16_t)(((NR_MAC_SUBHEADER_LONG *)pduP)->L1 & 0x7f) << 8) - | ((uint16_t)((NR_MAC_SUBHEADER_LONG *)pduP)->L2 & 0xff); + if (!get_mac_len(pduP, pdu_len, &mac_len, &mac_subheader_len)) + return 0; - } else { - mac_sdu_len = (uint16_t)((NR_MAC_SUBHEADER_SHORT *)pduP)->L; - mac_subheader_len = 2; - } - LOG_D(NR_MAC, "In %s: [UE %d] %d.%d : ULSCH -> UL-%s %d (gNB %d, %d bytes)\n", - __func__, - module_idP, + LOG_D(NR_MAC, "[UE %04x] %d.%d : ULSCH -> UL-%s %d (gNB %ld, %d bytes)\n", + UE->rnti, frameP, slot, rx_lcid<4?"DCCH":"DTCH", rx_lcid, module_idP, - mac_sdu_len); - UE_info->mac_stats[UE_id].lc_bytes_rx[rx_lcid] += mac_sdu_len; + mac_len); + UE->mac_stats.ul.lc_bytes[rx_lcid] += mac_len; mac_rlc_data_ind(module_idP, - UE_info->rnti[UE_id], + UE->rnti, module_idP, frameP, ENB_FLAG_YES, MBMS_FLAG_NO, rx_lcid, (char *)(pduP + mac_subheader_len), - mac_sdu_len, + mac_len, 1, NULL); /* Updated estimated buffer when receiving data */ - if (sched_ctrl->estimated_ul_buffer >= mac_sdu_len) - sched_ctrl->estimated_ul_buffer -= mac_sdu_len; + if (sched_ctrl->estimated_ul_buffer >= mac_len) + sched_ctrl->estimated_ul_buffer -= mac_len; else sched_ctrl->estimated_ul_buffer = 0; break; @@ -514,16 +376,16 @@ int nr_process_mac_pdu(module_id_t module_idP, if (rx_lcid < 45 || rx_lcid == 52 || rx_lcid == 63) { LOG_I(NR_MAC, "In %s: dumping UL MAC SDU sub-header with length %d (LCID = 0x%02x):\n", __func__, mac_subheader_len, rx_lcid); log_dump(NR_MAC, pduP, mac_subheader_len, LOG_DUMP_CHAR, "\n"); - LOG_I(NR_MAC, "In %s: dumping UL MAC SDU with length %d (LCID = 0x%02x):\n", __func__, mac_sdu_len, rx_lcid); - log_dump(NR_MAC, pduP + mac_subheader_len, mac_sdu_len, LOG_DUMP_CHAR, "\n"); + LOG_I(NR_MAC, "In %s: dumping UL MAC SDU with length %d (LCID = 0x%02x):\n", __func__, mac_len, rx_lcid); + log_dump(NR_MAC, pduP + mac_subheader_len, mac_len, LOG_DUMP_CHAR, "\n"); } else { - LOG_I(NR_MAC, "In %s: dumping UL MAC CE with length %d (LCID = 0x%02x):\n", __func__, mac_ce_len, rx_lcid); - log_dump(NR_MAC, pduP + mac_subheader_len + mac_sdu_len, mac_ce_len, LOG_DUMP_CHAR, "\n"); + LOG_I(NR_MAC, "In %s: dumping UL MAC CE with length %d (LCID = 0x%02x):\n", __func__, mac_len, rx_lcid); + log_dump(NR_MAC, pduP + mac_subheader_len + mac_len, mac_len, LOG_DUMP_CHAR, "\n"); } #endif - pduP += ( mac_subheader_len + mac_ce_len + mac_sdu_len ); - pdu_len -= ( mac_subheader_len + mac_ce_len + mac_sdu_len ); + pduP += ( mac_subheader_len + mac_len ); + pdu_len -= ( mac_subheader_len + mac_len ); if (pdu_len < 0) { LOG_E(NR_MAC, "In %s: residual UL MAC PDU in %d.%d with length < 0!, pdu_len %d \n", __func__, frameP, slot, pdu_len); @@ -537,15 +399,14 @@ int nr_process_mac_pdu(module_id_t module_idP, return 0; } -void abort_nr_ul_harq(module_id_t mod_id, int UE_id, int8_t harq_pid) +void abort_nr_ul_harq( NR_UE_info_t* UE, int8_t harq_pid) { - NR_UE_info_t *UE_info = &RC.nrmac[mod_id]->UE_info; - NR_UE_sched_ctrl_t *sched_ctrl = &UE_info->UE_sched_ctrl[UE_id]; + NR_UE_sched_ctrl_t *sched_ctrl = &UE->UE_sched_ctrl; NR_UE_ul_harq_t *harq = &sched_ctrl->ul_harq_processes[harq_pid]; harq->ndi ^= 1; harq->round = 0; - UE_info->mac_stats[UE_id].ulsch_errors++; + UE->mac_stats.ul.errors++; add_tail_nr_list(&sched_ctrl->available_ul_harq, harq_pid); /* the transmission failed: the UE won't send the data we expected initially, @@ -561,11 +422,11 @@ void handle_nr_ul_harq(const int CC_idP, sub_frame_t slot, const nfapi_nr_crc_t *crc_pdu) { - gNB_MAC_INST *gNB_mac = RC.nrmac[mod_id]; - int UE_id = find_nr_UE_id(mod_id, crc_pdu->rnti); - if (UE_id < 0) { + NR_UE_info_t* UE = find_nr_UE(&RC.nrmac[mod_id]->UE_info, crc_pdu->rnti); + if (!UE) { + LOG_W(NR_MAC, "handle harq for rnti %04x, in RA process\n", crc_pdu->rnti); for (int i = 0; i < NR_NB_RA_PROC_MAX; ++i) { - NR_RA_t *ra = &gNB_mac->common_channels[CC_idP].ra[i]; + NR_RA_t *ra = &RC.nrmac[mod_id]->common_channels[CC_idP].ra[i]; if (ra->state >= WAIT_Msg3 && ra->rnti == crc_pdu->rnti) return; @@ -573,8 +434,7 @@ void handle_nr_ul_harq(const int CC_idP, LOG_E(NR_MAC, "%s(): unknown RNTI 0x%04x in PUSCH\n", __func__, crc_pdu->rnti); return; } - NR_UE_info_t *UE_info = &RC.nrmac[mod_id]->UE_info; - NR_UE_sched_ctrl_t *sched_ctrl = &UE_info->UE_sched_ctrl[UE_id]; + NR_UE_sched_ctrl_t *sched_ctrl = &UE->UE_sched_ctrl; int8_t harq_pid = sched_ctrl->feedback_ul_harq.head; LOG_D(NR_MAC, "Comparing crc_pdu->harq_id vs feedback harq_pid = %d %d\n",crc_pdu->harq_id, harq_pid); while (crc_pdu->harq_id != harq_pid || harq_pid < 0) { @@ -588,8 +448,9 @@ void handle_nr_ul_harq(const int CC_idP, remove_front_nr_list(&sched_ctrl->feedback_ul_harq); sched_ctrl->ul_harq_processes[harq_pid].is_waiting = false; - if(sched_ctrl->ul_harq_processes[harq_pid].round >= MAX_HARQ_ROUNDS - 1) { - abort_nr_ul_harq(mod_id, UE_id, harq_pid); + + if(sched_ctrl->ul_harq_processes[harq_pid].round >= RC.nrmac[mod_id]->harq_round_max - 1) { + abort_nr_ul_harq(UE, harq_pid); } else { sched_ctrl->ul_harq_processes[harq_pid].round++; add_tail_nr_list(&sched_ctrl->retrans_ul_harq, harq_pid); @@ -609,8 +470,8 @@ void handle_nr_ul_harq(const int CC_idP, harq_pid, crc_pdu->rnti); add_tail_nr_list(&sched_ctrl->available_ul_harq, harq_pid); - } else if (harq->round >= MAX_HARQ_ROUNDS - 1) { - abort_nr_ul_harq(mod_id, UE_id, harq_pid); + } else if (harq->round >= RC.nrmac[mod_id]->harq_round_max - 1) { + abort_nr_ul_harq(UE, harq_pid); LOG_D(NR_MAC, "RNTI %04x: Ulharq id %d crc failed in all rounds\n", crc_pdu->rnti, @@ -640,15 +501,15 @@ void nr_rx_sdu(const module_id_t gnb_mod_idP, const uint16_t rssi){ gNB_MAC_INST *gNB_mac = RC.nrmac[gnb_mod_idP]; - NR_UE_info_t *UE_info = &gNB_mac->UE_info; const int current_rnti = rntiP; - const int UE_id = find_nr_UE_id(gnb_mod_idP, current_rnti); + LOG_D(NR_MAC, "rx_sdu for rnti %04x\n", current_rnti); const int target_snrx10 = gNB_mac->pusch_target_snrx10; const int pusch_failure_thres = gNB_mac->pusch_failure_thres; - - if (UE_id != -1) { - NR_UE_sched_ctrl_t *UE_scheduling_control = &UE_info->UE_sched_ctrl[UE_id]; + + NR_UE_info_t* UE = find_nr_UE(&gNB_mac->UE_info, current_rnti); + if (UE) { + NR_UE_sched_ctrl_t *UE_scheduling_control = &UE->UE_sched_ctrl; const int8_t harq_pid = UE_scheduling_control->feedback_ul_harq.head; if (sduP) @@ -656,15 +517,14 @@ void nr_rx_sdu(const module_id_t gnb_mod_idP, T_INT(rntiP), T_INT(frameP), T_INT(slotP), T_INT(harq_pid), T_BUFFER(sduP, sdu_lenP)); - UE_info->mac_stats[UE_id].ulsch_total_bytes_rx += sdu_lenP; - LOG_D(NR_MAC, "[gNB %d][PUSCH %d] CC_id %d %d.%d Received ULSCH sdu from PHY (rnti %x, UE_id %d) ul_cqi %d TA %d sduP %p, rssi %d\n", + UE->mac_stats.ul.total_bytes += sdu_lenP; + LOG_D(NR_MAC, "[gNB %d][PUSCH %d] CC_id %d %d.%d Received ULSCH sdu from PHY (rnti %04x) ul_cqi %d TA %d sduP %p, rssi %d\n", gnb_mod_idP, harq_pid, CC_idP, frameP, slotP, current_rnti, - UE_id, ul_cqi, timing_advance, sduP, @@ -677,11 +537,13 @@ void nr_rx_sdu(const module_id_t gnb_mod_idP, UE_scheduling_control->ta_update = timing_advance; UE_scheduling_control->raw_rssi = rssi; UE_scheduling_control->pusch_snrx10 = ul_cqi * 5 - 640; - LOG_D(NR_MAC, "[UE %d] PUSCH TPC %d and TA %d\n",UE_id,UE_scheduling_control->tpc0,UE_scheduling_control->ta_update); + + LOG_D(NR_MAC, "[UE %04x] PUSCH TPC %d and TA %d\n",UE->rnti,UE_scheduling_control->tpc0,UE_scheduling_control->ta_update); } else{ - LOG_D(NR_MAC,"[UE %d] Detected DTX : increasing UE TX power\n",UE_id); - UE_scheduling_control->tpc0 = 3; + LOG_D(NR_MAC,"[UE %04x] Detected DTX : increasing UE TX power\n",UE->rnti); + UE_scheduling_control->tpc0 = 1; + } #if defined(ENABLE_MAC_PAYLOAD_DEBUG) @@ -699,13 +561,13 @@ void nr_rx_sdu(const module_id_t gnb_mod_idP, if (sduP != NULL){ LOG_D(NR_MAC, "Received PDU at MAC gNB \n"); - UE_info->UE_sched_ctrl[UE_id].pusch_consecutive_dtx_cnt = 0; + UE->UE_sched_ctrl.pusch_consecutive_dtx_cnt = 0; const uint32_t tb_size = UE_scheduling_control->ul_harq_processes[harq_pid].sched_pusch.tb_size; UE_scheduling_control->sched_ul_bytes -= tb_size; if (UE_scheduling_control->sched_ul_bytes < 0) UE_scheduling_control->sched_ul_bytes = 0; - nr_process_mac_pdu(gnb_mod_idP, UE_id, CC_idP, frameP, slotP, sduP, sdu_lenP); + nr_process_mac_pdu(gnb_mod_idP, UE, CC_idP, frameP, slotP, sduP, sdu_lenP); } else { NR_UE_ul_harq_t *cur_harq = &UE_scheduling_control->ul_harq_processes[harq_pid]; @@ -717,13 +579,15 @@ void nr_rx_sdu(const module_id_t gnb_mod_idP, UE_scheduling_control->sched_ul_bytes = 0; } if (ul_cqi <= 128) { - UE_info->UE_sched_ctrl[UE_id].pusch_consecutive_dtx_cnt++; - UE_info->mac_stats[UE_id].ulsch_DTX++; + UE->UE_sched_ctrl.pusch_consecutive_dtx_cnt++; + UE->mac_stats.ulsch_DTX++; } - if (!get_softmodem_params()->phy_test && UE_info->UE_sched_ctrl[UE_id].pusch_consecutive_dtx_cnt >= pusch_failure_thres) { + + if (!get_softmodem_params()->phy_test && UE->UE_sched_ctrl.pusch_consecutive_dtx_cnt >= pusch_failure_thres) { LOG_W(NR_MAC,"Detected UL Failure on PUSCH after %d PUSCH DTX, stopping scheduling\n", - UE_info->UE_sched_ctrl[UE_id].pusch_consecutive_dtx_cnt); - UE_info->UE_sched_ctrl[UE_id].ul_failure = 1; + UE->UE_sched_ctrl.pusch_consecutive_dtx_cnt); + UE->UE_sched_ctrl.ul_failure = 1; + nr_mac_gNB_rrc_ul_failure(gnb_mod_idP,CC_idP,frameP,slotP,rntiP); } } @@ -744,7 +608,7 @@ void nr_rx_sdu(const module_id_t gnb_mod_idP, T(T_GNB_MAC_UL_PDU_WITH_DATA, T_INT(gnb_mod_idP), T_INT(CC_idP), T_INT(rntiP), T_INT(frameP), T_INT(slotP), T_INT(-1) /* harq_pid */, T_BUFFER(sduP, sdu_lenP)); - + /* we don't know this UE (yet). Check whether there is a ongoing RA (Msg 3) * and check the corresponding UE's RNTI match, in which case we activate * it. */ @@ -752,22 +616,22 @@ void nr_rx_sdu(const module_id_t gnb_mod_idP, NR_RA_t *ra = &gNB_mac->common_channels[CC_idP].ra[i]; if (ra->state != WAIT_Msg3) continue; - + if(no_sig) { - LOG_W(NR_MAC, "Random Access %i failed at state %i (no signal)\n", i, ra->state); + LOG_D(NR_MAC, "Random Access %i failed at state %i (no signal)\n", i, ra->state); nr_mac_remove_ra_rnti(gnb_mod_idP, ra->rnti); nr_clear_ra_proc(gnb_mod_idP, CC_idP, frameP, ra); } else { // random access pusch with TC-RNTI if (ra->rnti != current_rnti) { - LOG_W(NR_MAC, + LOG_D(NR_MAC, "expected TC_RNTI %04x to match current RNTI %04x\n", ra->rnti, current_rnti); if( (frameP==ra->Msg3_frame) && (slotP==ra->Msg3_slot) ) { - LOG_W(NR_MAC, "Random Access %i failed at state %i (TC_RNTI %04x RNTI %04x)\n", i, ra->state,ra->rnti,current_rnti); + LOG_D(NR_MAC, "Random Access %i failed at state %i (TC_RNTI %04x RNTI %04x)\n", i, ra->state,ra->rnti,current_rnti); nr_mac_remove_ra_rnti(gnb_mod_idP, ra->rnti); nr_clear_ra_proc(gnb_mod_idP, CC_idP, frameP, ra); } @@ -775,20 +639,20 @@ void nr_rx_sdu(const module_id_t gnb_mod_idP, continue; } - int UE_id=-1; - UE_id = add_new_nr_ue(gnb_mod_idP, ra->rnti, ra->CellGroup); - if (UE_id<0) { + NR_UE_info_t* UE = add_new_nr_ue(gNB_mac, ra->rnti, ra->CellGroup); + if (!UE) { LOG_W(NR_MAC, "Random Access %i discarded at state %i (TC_RNTI %04x RNTI %04x): max number of users achieved!\n", i, ra->state,ra->rnti,current_rnti); + nr_mac_remove_ra_rnti(gnb_mod_idP, ra->rnti); nr_clear_ra_proc(gnb_mod_idP, CC_idP, frameP, ra); return; } - UE_info->UE_beam_index[UE_id] = ra->beam_id; + UE->UE_beam_index = ra->beam_id; // re-initialize ta update variables after RA procedure completion - UE_info->UE_sched_ctrl[UE_id].ta_frame = frameP; + UE->UE_sched_ctrl.ta_frame = frameP; LOG_D(NR_MAC, "reset RA state information for RA-RNTI 0x%04x/index %d\n", @@ -797,26 +661,25 @@ void nr_rx_sdu(const module_id_t gnb_mod_idP, LOG_I(NR_MAC, "[gNB %d][RAPROC] PUSCH with TC_RNTI 0x%04x received correctly, " - "adding UE MAC Context UE_id %d/RNTI 0x%04x\n", + "adding UE MAC Context RNTI 0x%04x\n", gnb_mod_idP, current_rnti, - UE_id, ra->rnti); - NR_UE_sched_ctrl_t *UE_scheduling_control = &UE_info->UE_sched_ctrl[UE_id]; + NR_UE_sched_ctrl_t *UE_scheduling_control = &UE->UE_sched_ctrl; UE_scheduling_control->tpc0 = nr_get_tpc(target_snrx10,ul_cqi,30); if (timing_advance != 0xffff) UE_scheduling_control->ta_update = timing_advance; UE_scheduling_control->raw_rssi = rssi; UE_scheduling_control->pusch_snrx10 = ul_cqi * 5 - 640; - LOG_D(NR_MAC, "[UE %d] PUSCH TPC %d and TA %d\n",UE_id,UE_scheduling_control->tpc0,UE_scheduling_control->ta_update); + LOG_D(NR_MAC, "[UE %04x] PUSCH TPC %d and TA %d\n",UE->rnti,UE_scheduling_control->tpc0,UE_scheduling_control->ta_update); if(ra->cfra) { - LOG_A(NR_MAC, "(ue %i, rnti 0x%04x) CFRA procedure succeeded!\n", UE_id, ra->rnti); + LOG_A(NR_MAC, "(rnti 0x%04x) CFRA procedure succeeded!\n", ra->rnti); nr_mac_remove_ra_rnti(gnb_mod_idP, ra->rnti); nr_clear_ra_proc(gnb_mod_idP, CC_idP, frameP, ra); - UE_info->active[UE_id] = true; + process_CellGroup(ra->CellGroup, UE_scheduling_control); } else { @@ -831,25 +694,25 @@ void nr_rx_sdu(const module_id_t gnb_mod_idP, // First byte corresponds to R/LCID MAC sub-header memcpy(ra->cont_res_id, &sduP[1], sizeof(uint8_t) * 6); - if (nr_process_mac_pdu(gnb_mod_idP, UE_id, CC_idP, frameP, slotP, sduP, sdu_lenP) == 0) { + if (nr_process_mac_pdu(gnb_mod_idP, UE, CC_idP, frameP, slotP, sduP, sdu_lenP) == 0) { ra->state = Msg4; ra->Msg4_frame = (frameP + 2) % 1024; ra->Msg4_slot = 1; if (ra->msg3_dcch_dtch) { // Check if the UE identified by C-RNTI still exists at the gNB - int UE_id_C = find_nr_UE_id(gnb_mod_idP, ra->crnti); - if (UE_id_C < 0) { + NR_UE_info_t * UE_C = find_nr_UE(&gNB_mac->UE_info, ra->crnti); + if (!UE_C) { // The UE identified by C-RNTI no longer exists at the gNB // Let's abort the current RA, so the UE will trigger a new RA later but using RRCSetupRequest instead. A better solution may be implemented - mac_remove_nr_ue(gnb_mod_idP, ra->rnti); + mac_remove_nr_ue(gNB_mac, ra->rnti); nr_clear_ra_proc(gnb_mod_idP, CC_idP, frameP, ra); return; } else { // The UE identified by C-RNTI still exists at the gNB // Reset uplink failure flags/counters/timers at MAC and at RRC so gNB will resume again scheduling resources for this UE - UE_info->UE_sched_ctrl[UE_id_C].pusch_consecutive_dtx_cnt = 0; - UE_info->UE_sched_ctrl[UE_id_C].ul_failure = 0; + UE_C->UE_sched_ctrl.pusch_consecutive_dtx_cnt = 0; + UE_C->UE_sched_ctrl.ul_failure = 0; nr_mac_gNB_rrc_ul_failure_reset(gnb_mod_idP, frameP, slotP, ra->crnti); } } @@ -875,31 +738,43 @@ void nr_rx_sdu(const module_id_t gnb_mod_idP, // for CFRA (NSA) do not schedule retransmission of msg3 if (ra->cfra) { - LOG_W(NR_MAC, "Random Access %i failed at state %i (NSA msg3 reception failed)\n", i, ra->state); + LOG_D(NR_MAC, "Random Access %i failed at state %i (NSA msg3 reception failed)\n", i, ra->state); nr_mac_remove_ra_rnti(gnb_mod_idP, ra->rnti); nr_clear_ra_proc(gnb_mod_idP, CC_idP, frameP, ra); return; } if (ra->msg3_round >= MAX_HARQ_ROUNDS - 1) { - LOG_W(NR_MAC, "Random Access %i failed at state %i (Reached msg3 max harq rounds)\n", i, ra->state); + LOG_D(NR_MAC, "Random Access %i failed at state %i (Reached msg3 max harq rounds)\n", i, ra->state); nr_mac_remove_ra_rnti(gnb_mod_idP, ra->rnti); nr_clear_ra_proc(gnb_mod_idP, CC_idP, frameP, ra); return; } - LOG_W(NR_MAC, "Random Access %i Msg3 CRC did not pass)\n", i); + + LOG_D(NR_MAC, "Random Access %i Msg3 CRC did not pass)\n", i); + ra->msg3_round++; ra->state = Msg3_retransmission; } } } -long get_K2(NR_ServingCellConfigCommon_t *scc,NR_BWP_Uplink_t *ubwp, int time_domain_assignment, int mu) { - DevAssert(scc); - const NR_PUSCH_TimeDomainResourceAllocation_t *tda_list = ubwp ? - ubwp->bwp_Common->pusch_ConfigCommon->choice.setup->pusch_TimeDomainAllocationList->list.array[time_domain_assignment]: - scc->uplinkConfigCommon->initialUplinkBWP->pusch_ConfigCommon->choice.setup->pusch_TimeDomainAllocationList->list.array[time_domain_assignment]; +long get_K2(NR_ServingCellConfigCommon_t *scc, + NR_ServingCellConfigCommonSIB_t *scc_sib1, + NR_BWP_Uplink_t *ubwp, + int time_domain_assignment, + int mu) { + + NR_PUSCH_TimeDomainResourceAllocation_t *tda_list = NULL; + if(ubwp) { + tda_list = ubwp->bwp_Common->pusch_ConfigCommon->choice.setup->pusch_TimeDomainAllocationList->list.array[time_domain_assignment]; + } else if(scc) { + tda_list = scc->uplinkConfigCommon->initialUplinkBWP->pusch_ConfigCommon->choice.setup->pusch_TimeDomainAllocationList->list.array[time_domain_assignment]; + } else if(scc_sib1) { + tda_list = scc_sib1->uplinkConfigCommon->initialUplinkBWP.pusch_ConfigCommon->choice.setup->pusch_TimeDomainAllocationList->list.array[time_domain_assignment]; + } + if (tda_list->k2) return *tda_list->k2; else if (mu < 2) @@ -910,32 +785,37 @@ long get_K2(NR_ServingCellConfigCommon_t *scc,NR_BWP_Uplink_t *ubwp, int time_do return 3; } -bool nr_UE_is_to_be_scheduled(module_id_t mod_id, int CC_id, int UE_id, frame_t frame, sub_frame_t slot) +static bool nr_UE_is_to_be_scheduled(const NR_ServingCellConfigCommon_t *scc, + int CC_id, NR_UE_info_t* UE, frame_t frame, sub_frame_t slot, uint32_t ulsch_max_frame_inactivity) { - const NR_ServingCellConfigCommon_t *scc = RC.nrmac[mod_id]->common_channels->ServingCellConfigCommon; const int n = nr_slots_per_frame[*scc->ssbSubcarrierSpacing]; const int now = frame * n + slot; - const struct gNB_MAC_INST_s *nrmac = RC.nrmac[mod_id]; - const NR_UE_sched_ctrl_t *sched_ctrl = &nrmac->UE_info.UE_sched_ctrl[UE_id]; - const int last_ul_sched = sched_ctrl->last_ul_frame * n + sched_ctrl->last_ul_slot; + + const NR_UE_sched_ctrl_t *sched_ctrl =&UE->UE_sched_ctrl; + const NR_TDD_UL_DL_Pattern_t *tdd = scc->tdd_UL_DL_ConfigurationCommon ? &scc->tdd_UL_DL_ConfigurationCommon->pattern1 : NULL; int num_slots_per_period; + int last_ul_slot; int tdd_period_len[8] = {500,625,1000,1250,2000,2500,5000,10000}; - if (tdd) + if (tdd) { // Force the default transmission in a full slot as early as possible in the UL portion of TDD period (last_ul_slot) num_slots_per_period = n*tdd_period_len[tdd->dl_UL_TransmissionPeriodicity]/10000; - else + last_ul_slot=1+tdd->nrofDownlinkSlots; + } else { num_slots_per_period = n; + last_ul_slot = sched_ctrl->last_ul_slot; + } + const int last_ul_sched = sched_ctrl->last_ul_frame * n + last_ul_slot; const int diff = (now - last_ul_sched + 1024 * n) % (1024 * n); /* UE is to be scheduled if * (1) we think the UE has more bytes awaiting than what we scheduled * (2) there is a scheduling request * (3) or we did not schedule it in more than 10 frames */ const bool has_data = sched_ctrl->estimated_ul_buffer > sched_ctrl->sched_ul_bytes; - const bool high_inactivity = diff >= (nrmac->ulsch_max_frame_inactivity>0 ? (nrmac->ulsch_max_frame_inactivity * n) : num_slots_per_period); + const bool high_inactivity = diff >= (ulsch_max_frame_inactivity > 0 ? ulsch_max_frame_inactivity * n : num_slots_per_period); LOG_D(NR_MAC, "%4d.%2d UL inactivity %d slots has_data %d SR %d\n", frame, @@ -946,44 +826,37 @@ bool nr_UE_is_to_be_scheduled(module_id_t mod_id, int CC_id, int UE_id, frame_t return has_data || sched_ctrl->SR || high_inactivity; } -int next_list_entry_looped(NR_list_t *list, int UE_id) -{ - if (UE_id < 0) - return list->head; - return list->next[UE_id] < 0 ? list->head : list->next[UE_id]; -} - -bool allocate_ul_retransmission(module_id_t module_id, - frame_t frame, - sub_frame_t slot, - uint8_t *rballoc_mask, - int *n_rb_sched, - int UE_id, - int harq_pid) +static bool allocate_ul_retransmission(gNB_MAC_INST *nrmac, + frame_t frame, + sub_frame_t slot, + uint16_t *rballoc_mask, + int *n_rb_sched, + NR_UE_info_t* UE, + int harq_pid, + const NR_SIB1_t *sib1, + const NR_ServingCellConfigCommon_t *scc, + const int tda) { const int CC_id = 0; - const NR_ServingCellConfigCommon_t *scc = RC.nrmac[module_id]->common_channels[CC_id].ServingCellConfigCommon; - NR_UE_info_t *UE_info = &RC.nrmac[module_id]->UE_info; - NR_UE_sched_ctrl_t *sched_ctrl = &UE_info->UE_sched_ctrl[UE_id]; + NR_UE_sched_ctrl_t *sched_ctrl = &UE->UE_sched_ctrl; NR_sched_pusch_t *retInfo = &sched_ctrl->ul_harq_processes[harq_pid].sched_pusch; - NR_CellGroupConfig_t *cg = UE_info->CellGroup[UE_id]; - NR_BWP_UplinkDedicated_t *ubwpd= cg ? cg->spCellConfig->spCellConfigDedicated->uplinkConfig->initialUplinkBWP:NULL; - NR_BWP_t *genericParameters = sched_ctrl->active_ubwp ? &sched_ctrl->active_ubwp->bwp_Common->genericParameters : &scc->uplinkConfigCommon->initialUplinkBWP->genericParameters; + NR_CellGroupConfig_t *cg = UE->CellGroup; + + NR_BWP_UplinkDedicated_t *ubwpd = cg && cg->spCellConfig && cg->spCellConfig->spCellConfigDedicated && + cg->spCellConfig->spCellConfigDedicated->uplinkConfig ? + cg->spCellConfig->spCellConfigDedicated->uplinkConfig->initialUplinkBWP : NULL; + + NR_BWP_t *genericParameters = get_ul_bwp_genericParameters(sched_ctrl->active_ubwp, + (NR_ServingCellConfigCommon_t *)scc, + sib1); + int rbStart = 0; // wrt BWP start const uint16_t bwpSize = NRRIV2BW(genericParameters->locationAndBandwidth, MAX_BWP_SIZE); - + const uint8_t nrOfLayers = 1; const uint8_t num_dmrs_cdm_grps_no_data = (sched_ctrl->active_bwp || ubwpd) ? 1 : 2; - const int tda = sched_ctrl->active_ubwp ? RC.nrmac[module_id]->preferred_ul_tda[sched_ctrl->active_ubwp->bwp_Id][slot] : 0; LOG_D(NR_MAC,"retInfo->time_domain_allocation = %d, tda = %d\n", retInfo->time_domain_allocation, tda); LOG_D(NR_MAC,"num_dmrs_cdm_grps_no_data %d, tbs %d\n",num_dmrs_cdm_grps_no_data, retInfo->tb_size); if (tda == retInfo->time_domain_allocation) { - /* Check the resource is enough for retransmission */ - while (rbStart < bwpSize && !rballoc_mask[rbStart]) - rbStart++; - if (rbStart + retInfo->rbSize > bwpSize) { - LOG_W(NR_MAC, "cannot allocate retransmission of UE %d/RNTI %04x: no resources (rbStart %d, retInfo->rbSize %d, bwpSize %d\n", UE_id, UE_info->rnti[UE_id], rbStart, retInfo->rbSize, bwpSize); - return false; - } /* check whether we need to switch the TDA allocation since tha last * (re-)transmission */ NR_pusch_semi_static_t *ps = &sched_ctrl->pusch_semi_static; @@ -992,23 +865,48 @@ bool allocate_ul_retransmission(module_id_t module_id, if (ps->time_domain_allocation != tda || ps->dci_format != dci_format - || ps->num_dmrs_cdm_grps_no_data != num_dmrs_cdm_grps_no_data - || sched_ctrl->update_pusch_ps) { - nr_set_pusch_semi_static(scc, sched_ctrl->active_ubwp, ubwpd, dci_format, tda, num_dmrs_cdm_grps_no_data, ps); - sched_ctrl->update_pusch_ps = false; + || ps->nrOfLayers != nrOfLayers + || ps->num_dmrs_cdm_grps_no_data != num_dmrs_cdm_grps_no_data) { + nr_set_pusch_semi_static(sib1, + scc, + sched_ctrl->active_ubwp, + ubwpd, + dci_format, + tda, + num_dmrs_cdm_grps_no_data, + nrOfLayers, + ps); + } + + /* Check the resource is enough for retransmission */ + const uint16_t slbitmap = SL_to_bitmap(ps->startSymbolIndex, ps->nrOfSymbols); + while (rbStart < bwpSize && (rballoc_mask[rbStart] & slbitmap) != slbitmap) + rbStart++; + if (rbStart + retInfo->rbSize > bwpSize) { + LOG_W(NR_MAC, "cannot allocate retransmission of RNTI %04x: no resources (rbStart %d, retInfo->rbSize %d, bwpSize %d\n", UE->rnti, rbStart, retInfo->rbSize, bwpSize); + return false; } LOG_D(NR_MAC, "%s(): retransmission keeping TDA %d and TBS %d\n", __func__, tda, retInfo->tb_size); } else { - /* the retransmission will use a different time domain allocation, check - * that we have enough resources */ - while (rbStart < bwpSize && !rballoc_mask[rbStart]) - rbStart++; - int rbSize = 0; - while (rbStart + rbSize < bwpSize && rballoc_mask[rbStart + rbSize]) - rbSize++; NR_pusch_semi_static_t temp_ps; int dci_format = get_dci_format(sched_ctrl); - nr_set_pusch_semi_static(scc, sched_ctrl->active_ubwp,ubwpd, dci_format, tda, num_dmrs_cdm_grps_no_data, &temp_ps); + nr_set_pusch_semi_static(sib1, + scc, + sched_ctrl->active_ubwp, + ubwpd, + dci_format, + tda, + num_dmrs_cdm_grps_no_data, + nrOfLayers, + &temp_ps); + /* the retransmission will use a different time domain allocation, check + * that we have enough resources */ + const uint16_t slbitmap = SL_to_bitmap(temp_ps.startSymbolIndex, temp_ps.nrOfSymbols); + while (rbStart < bwpSize && (rballoc_mask[rbStart] & slbitmap) != slbitmap) + rbStart++; + int rbSize = 0; + while (rbStart + rbSize < bwpSize && (rballoc_mask[rbStart + rbSize] & slbitmap) == slbitmap) + rbSize++; uint32_t new_tbs; uint16_t new_rbSize; bool success = nr_find_nb_rb(retInfo->Qm, @@ -1035,8 +933,7 @@ bool allocate_ul_retransmission(module_id_t module_id, } /* Find a free CCE */ - const int cid = sched_ctrl->coreset->controlResourceSetId; - const uint16_t Y = get_Y(cid%3, slot, UE_info->rnti[UE_id]); + const uint32_t Y = get_Y(sched_ctrl->search_space, slot, UE->rnti); uint8_t nr_of_candidates; for (int i=0; i<5; i++) { // for now taking the lowest value among the available aggregation levels @@ -1046,7 +943,7 @@ bool allocate_ul_retransmission(module_id_t module_id, 1<0) break; } - int CCEIndex = find_pdcch_candidate(RC.nrmac[module_id], + int CCEIndex = find_pdcch_candidate(nrmac, CC_id, sched_ctrl->aggregation_level, nr_of_candidates, @@ -1055,12 +952,12 @@ bool allocate_ul_retransmission(module_id_t module_id, Y); if (CCEIndex<0) { - LOG_D(NR_MAC, "%4d.%2d no free CCE for retransmission UL DCI UE %04x\n", frame, slot, UE_info->rnti[UE_id]); + LOG_D(NR_MAC, "%4d.%2d no free CCE for retransmission UL DCI UE %04x\n", frame, slot, UE->rnti); return false; } sched_ctrl->cce_index = CCEIndex; - fill_pdcch_vrb_map(RC.nrmac[module_id], + fill_pdcch_vrb_map(nrmac, CC_id, &sched_ctrl->sched_pdcch, CCEIndex, @@ -1076,11 +973,10 @@ bool allocate_ul_retransmission(module_id_t module_id, NR_sched_pusch_t *sched_pusch = &sched_ctrl->sched_pusch; LOG_D(NR_MAC, - "%4d.%2d Allocate UL retransmission UE %d/RNTI %04x sched %4d.%2d (%d RBs)\n", + "%4d.%2d Allocate UL retransmission RNTI %04x sched %4d.%2d (%d RBs)\n", frame, slot, - UE_id, - UE_info->rnti[UE_id], + UE->rnti, sched_pusch->frame, sched_pusch->slot, sched_pusch->rbSize); @@ -1091,7 +987,7 @@ bool allocate_ul_retransmission(module_id_t module_id, /* Mark the corresponding RBs as used */ n_rb_sched -= sched_pusch->rbSize; for (int rb = 0; rb < sched_ctrl->sched_pusch.rbSize; rb++) - rballoc_mask[rb + sched_ctrl->sched_pusch.rbStart] = 0; + rballoc_mask[rb + sched_ctrl->sched_pusch.rbStart] ^= SL_to_bitmap(sched_ctrl->pusch_semi_static.startSymbolIndex, sched_ctrl->pusch_semi_static.nrOfSymbols); return true; } @@ -1107,113 +1003,164 @@ void update_ul_ue_R_Qm(NR_sched_pusch_t *sched_pusch, const NR_pusch_semi_static } } -float ul_thr_ue[MAX_MOBILES_PER_GNB]; uint32_t ul_pf_tbs[3][29]; // pre-computed, approximate TBS values for PF coefficient +typedef struct UEsched_s { + float coef; + NR_UE_info_t * UE; +} UEsched_t; + +static int comparator(const void *p, const void *q) { + return ((UEsched_t*)p)->coef < ((UEsched_t*)q)->coef; +} + void pf_ul(module_id_t module_id, frame_t frame, sub_frame_t slot, - NR_list_t *UE_list, + NR_UE_info_t *UE_list[], int max_num_ue, int n_rb_sched, - uint8_t *rballoc_mask) { + uint16_t *rballoc_mask) { const int CC_id = 0; gNB_MAC_INST *nrmac = RC.nrmac[module_id]; NR_ServingCellConfigCommon_t *scc = nrmac->common_channels[CC_id].ServingCellConfigCommon; - NR_UE_info_t *UE_info = &nrmac->UE_info; + const NR_SIB1_t *sib1 = RC.nrmac[module_id]->common_channels[0].sib1 ? RC.nrmac[module_id]->common_channels[0].sib1->message.choice.c1->choice.systemInformationBlockType1 : NULL; + const int min_rb = 5; - float coeff_ue[MAX_MOBILES_PER_GNB]; // UEs that could be scheduled - int ue_array[MAX_MOBILES_PER_GNB]; - NR_list_t UE_sched = { .head = -1, .next = ue_array, .tail = -1, .len = MAX_MOBILES_PER_GNB }; + UEsched_t UE_sched[MAX_MOBILES_PER_GNB] = {0}; + int remainUEs=max_num_ue; + int curUE=0; /* Loop UE_list to calculate throughput and coeff */ - for (int UE_id = UE_list->head; UE_id >= 0; UE_id = UE_list->next[UE_id]) { + UE_iterator(UE_list, UE) { - if (UE_info->Msg4_ACKed[UE_id] != true) continue; + if (UE->Msg4_ACKed != true) + continue; + + LOG_D(NR_MAC,"pf_ul: preparing UL scheduling for UE %04x\n",UE->rnti); + NR_UE_sched_ctrl_t *sched_ctrl = &UE->UE_sched_ctrl; + + NR_BWP_t *genericParameters = get_ul_bwp_genericParameters(sched_ctrl->active_ubwp, + scc, + sib1); - LOG_D(NR_MAC,"pf_ul: preparing UL scheduling for UE %d\n",UE_id); - NR_UE_sched_ctrl_t *sched_ctrl = &UE_info->UE_sched_ctrl[UE_id]; - NR_BWP_t *genericParameters = sched_ctrl->active_ubwp ? &sched_ctrl->active_ubwp->bwp_Common->genericParameters : &scc->uplinkConfigCommon->initialUplinkBWP->genericParameters; int rbStart = 0; // wrt BWP start - NR_CellGroupConfig_t *cg = UE_info->CellGroup[UE_id]; - NR_BWP_UplinkDedicated_t *ubwpd= cg ? cg->spCellConfig->spCellConfigDedicated->uplinkConfig->initialUplinkBWP : NULL; + NR_CellGroupConfig_t *cg = UE->CellGroup; + NR_BWP_UplinkDedicated_t *ubwpd = cg && cg->spCellConfig && cg->spCellConfig->spCellConfigDedicated && + cg->spCellConfig->spCellConfigDedicated->uplinkConfig ? + cg->spCellConfig->spCellConfigDedicated->uplinkConfig->initialUplinkBWP : NULL; const uint16_t bwpSize = NRRIV2BW(genericParameters->locationAndBandwidth, MAX_BWP_SIZE); NR_sched_pusch_t *sched_pusch = &sched_ctrl->sched_pusch; NR_pusch_semi_static_t *ps = &sched_ctrl->pusch_semi_static; + const NR_mac_dir_stats_t *stats = &UE->mac_stats.ul; /* Calculate throughput */ const float a = 0.0005f; // corresponds to 200ms window - const uint32_t b = UE_info->mac_stats[UE_id].ulsch_current_bytes; - ul_thr_ue[UE_id] = (1 - a) * ul_thr_ue[UE_id] + a * b; + const uint32_t b = stats->current_bytes; + UE->ul_thr_ue = (1 - a) * UE->ul_thr_ue + a * b; /* Check if retransmission is necessary */ sched_pusch->ul_harq_pid = sched_ctrl->retrans_ul_harq.head; - LOG_D(NR_MAC,"pf_ul: UE %d harq_pid %d\n",UE_id,sched_pusch->ul_harq_pid); + LOG_D(NR_MAC,"pf_ul: UE %04x harq_pid %d\n",UE->rnti,sched_pusch->ul_harq_pid); if (sched_pusch->ul_harq_pid >= 0) { /* Allocate retransmission*/ - bool r = allocate_ul_retransmission( - module_id, frame, slot, rballoc_mask, &n_rb_sched, UE_id, sched_pusch->ul_harq_pid); + const int tda = get_ul_tda(nrmac, scc, sched_pusch->slot); + bool r = allocate_ul_retransmission(nrmac, frame, slot, rballoc_mask, &n_rb_sched, UE, sched_pusch->ul_harq_pid, sib1, scc, tda); if (!r) { - LOG_D(NR_MAC, "%4d.%2d UL retransmission UE RNTI %04x can NOT be allocated\n", frame, slot, UE_info->rnti[UE_id]); + LOG_D(NR_MAC, "%4d.%2d UL retransmission UE RNTI %04x can NOT be allocated\n", frame, slot, UE->rnti); continue; } - else LOG_D(NR_MAC,"%4d.%2d UL Retransmission UE RNTI %04x to be allocated, max_num_ue %d\n",frame,slot,UE_info->rnti[UE_id],max_num_ue); + else LOG_D(NR_MAC,"%4d.%2d UL Retransmission UE RNTI %04x to be allocated, max_num_ue %d\n",frame,slot,UE->rnti,max_num_ue); /* reduce max_num_ue once we are sure UE can be allocated, i.e., has CCE */ - max_num_ue--; - if (max_num_ue < 0) - return; - continue; - } + remainUEs--; + if (remainUEs == 0) + // we have filled all with mandatory retransmissions + // no need to schedule new transmissions + return; + continue; + } const int B = max(0, sched_ctrl->estimated_ul_buffer - sched_ctrl->sched_ul_bytes); /* preprocessor computed sched_frame/sched_slot */ - const bool do_sched = nr_UE_is_to_be_scheduled(module_id, 0, UE_id, sched_pusch->frame, sched_pusch->slot); + const bool do_sched = nr_UE_is_to_be_scheduled(scc, 0, UE, sched_pusch->frame, sched_pusch->slot, nrmac->ulsch_max_frame_inactivity); - LOG_D(NR_MAC,"pf_ul: do_sched UE %d => %s\n",UE_id,do_sched ? "yes" : "no"); - if (B == 0 && !do_sched) + LOG_D(NR_MAC,"pf_ul: do_sched UE %04x => %s\n",UE->rnti,do_sched ? "yes" : "no"); + if ((B == 0 && !do_sched) || (sched_ctrl->rrc_processing_timer > 0)) continue; + + const NR_bler_options_t *bo = &nrmac->ul_bler; + const int max_mcs = bo->max_mcs; /* no per-user maximum MCS yet */ + sched_pusch->mcs = get_mcs_from_bler(bo, stats, &UE->UE_sched_ctrl.ul_bler_stats, max_mcs, frame); /* Schedule UE on SR or UL inactivity and no data (otherwise, will be scheduled * based on data to transmit) */ if (B == 0 && do_sched) { /* if no data, pre-allocate 5RB */ /* Find a free CCE */ - const int cid = sched_ctrl->coreset->controlResourceSetId; - const uint16_t Y = get_Y(cid%3, slot, UE_info->rnti[UE_id]); + const uint32_t Y = get_Y(sched_ctrl->search_space, slot, UE->rnti); uint8_t nr_of_candidates; for (int i=0; i<5; i++) { - // for now taking the lowest value among the available aggregation levels - find_aggregation_candidates(&sched_ctrl->aggregation_level, - &nr_of_candidates, - sched_ctrl->search_space, - 1<0) break; + // for now taking the lowest value among the available aggregation levels + find_aggregation_candidates(&sched_ctrl->aggregation_level, + &nr_of_candidates, + sched_ctrl->search_space, + 1<0) break; } int CCEIndex = find_pdcch_candidate(RC.nrmac[module_id], - CC_id, - sched_ctrl->aggregation_level, - nr_of_candidates, - &sched_ctrl->sched_pdcch, - sched_ctrl->coreset, - Y); - + CC_id, + sched_ctrl->aggregation_level, + nr_of_candidates, + &sched_ctrl->sched_pdcch, + sched_ctrl->coreset, + Y); + if (CCEIndex<0) { - LOG_D(NR_MAC, "%4d.%2d no free CCE for UL DCI UE %04x (BSR 0)\n", frame, slot, UE_info->rnti[UE_id]); - continue; + LOG_D(NR_MAC, "%4d.%2d no free CCE for UL DCI UE %04x (BSR 0)\n", frame, slot, UE->rnti); + continue; } /* reduce max_num_ue once we are sure UE can be allocated, i.e., has CCE */ - max_num_ue--; - if (max_num_ue < 0) - return; + remainUEs--; + + if (remainUEs == 0) + // we have filled all with mandatory retransmissions + // no need to schedule new transmissions + return; - LOG_D(NR_MAC,"Looking for min_rb %d RBs, starting at %d\n", min_rb, rbStart); - while (rbStart < bwpSize && !rballoc_mask[rbStart]) rbStart++; + /* Save PUSCH field */ + /* we want to avoid a lengthy deduction of DMRS and other parameters in + * every TTI if we can save it, so check whether dci_format, TDA, or + * num_dmrs_cdm_grps_no_data has changed and only then recompute */ + const uint8_t nrOfLayers = 1; + const uint8_t num_dmrs_cdm_grps_no_data = (sched_ctrl->active_ubwp || ubwpd) ? 1 : 2; + int dci_format = get_dci_format(sched_ctrl); + const int tda = get_ul_tda(nrmac, scc, sched_pusch->slot); + if (ps->time_domain_allocation != tda + || ps->dci_format != dci_format + || ps->nrOfLayers != nrOfLayers + || ps->num_dmrs_cdm_grps_no_data != num_dmrs_cdm_grps_no_data) { + nr_set_pusch_semi_static(sib1, + scc, + sched_ctrl->active_ubwp, + ubwpd, + dci_format, + tda, + num_dmrs_cdm_grps_no_data, + nrOfLayers, + ps); + } + + LOG_D(NR_MAC,"Looking for min_rb %d RBs, starting at %d num_dmrs_cdm_grps_no_data %d\n", + min_rb, rbStart, ps->num_dmrs_cdm_grps_no_data); + const uint16_t slbitmap = SL_to_bitmap(ps->startSymbolIndex, ps->nrOfSymbols); + while (rbStart < bwpSize && (rballoc_mask[rbStart] & slbitmap) != slbitmap) + rbStart++; if (rbStart + min_rb >= bwpSize) { - LOG_W(NR_MAC, "cannot allocate continuous UL data for UE %d/RNTI %04x: no resources (rbStart %d, min_rb %d, bwpSize %d\n", - UE_id, UE_info->rnti[UE_id],rbStart,min_rb,bwpSize); + LOG_W(NR_MAC, "cannot allocate continuous UL data for RNTI %04x: no resources (rbStart %d, min_rb %d, bwpSize %d\n", + UE->rnti,rbStart,min_rb,bwpSize); return; } @@ -1224,22 +1171,8 @@ void pf_ul(module_id_t module_id, CCEIndex, sched_ctrl->aggregation_level); - /* Save PUSCH field */ - /* we want to avoid a lengthy deduction of DMRS and other parameters in - * every TTI if we can save it, so check whether dci_format, TDA, or - * num_dmrs_cdm_grps_no_data has changed and only then recompute */ - const uint8_t num_dmrs_cdm_grps_no_data = (sched_ctrl->active_ubwp || ubwpd) ? 1 : 2; - int dci_format = get_dci_format(sched_ctrl); - const int tda = sched_ctrl->active_ubwp ? nrmac->preferred_ul_tda[sched_ctrl->active_ubwp->bwp_Id][slot] : 0; - if (ps->time_domain_allocation != tda - || ps->dci_format != dci_format - || ps->num_dmrs_cdm_grps_no_data != num_dmrs_cdm_grps_no_data - || sched_ctrl->update_pusch_ps) { - nr_set_pusch_semi_static(scc, sched_ctrl->active_ubwp, ubwpd, dci_format, tda, num_dmrs_cdm_grps_no_data, ps); - sched_ctrl->update_pusch_ps = false; - } NR_sched_pusch_t *sched_pusch = &sched_ctrl->sched_pusch; - sched_pusch->mcs = 9; + sched_pusch->mcs = min(nrmac->min_grant_mcs, sched_pusch->mcs); update_ul_ue_R_Qm(sched_pusch, ps); sched_pusch->rbStart = rbStart; sched_pusch->rbSize = min_rb; @@ -1250,53 +1183,38 @@ void pf_ul(module_id_t module_id, ps->N_PRB_DMRS * ps->num_dmrs_symb, 0, // nb_rb_oh 0, - 1 /* NrOfLayers */) + ps->nrOfLayers) >> 3; /* Mark the corresponding RBs as used */ n_rb_sched -= sched_pusch->rbSize; for (int rb = 0; rb < sched_ctrl->sched_pusch.rbSize; rb++) - rballoc_mask[rb + sched_ctrl->sched_pusch.rbStart] = 0; + rballoc_mask[rb + sched_ctrl->sched_pusch.rbStart] ^= slbitmap; continue; } /* Create UE_sched for UEs eligibale for new data transmission*/ - add_tail_nr_list(&UE_sched, UE_id); - /* Calculate coefficient*/ - sched_pusch->mcs = 9; const uint32_t tbs = ul_pf_tbs[ps->mcs_table][sched_pusch->mcs]; - coeff_ue[UE_id] = (float) tbs / ul_thr_ue[UE_id]; - LOG_D(NR_MAC,"b %d, ul_thr_ue[%d] %f, tbs %d, coeff_ue[%d] %f\n", - b, UE_id, ul_thr_ue[UE_id], tbs, UE_id, coeff_ue[UE_id]); + float coeff_ue = (float) tbs / UE->ul_thr_ue; + LOG_D(NR_MAC,"rnti %04x b %d, ul_thr_ue %f, tbs %d, coeff_ue %f\n", + UE->rnti, b, UE->ul_thr_ue, tbs, coeff_ue); + UE_sched[curUE].coef=coeff_ue; + UE_sched[curUE].UE=UE; + curUE++; } - + qsort(UE_sched, sizeof(*UE_sched), sizeofArray(UE_sched), comparator); + UEsched_t *iterator=UE_sched; + const int min_rbSize = 5; /* Loop UE_sched to find max coeff and allocate transmission */ - while (UE_sched.head >= 0 && max_num_ue> 0 && n_rb_sched >= min_rbSize) { - /* Find max coeff */ - int *max = &UE_sched.head; /* Find max coeff: assume head is max */ - int *p = &UE_sched.next[*max]; - while (*p >= 0) { - /* Find max coeff: if the current one has larger coeff, save for later */ - if (coeff_ue[*p] > coeff_ue[*max]) - max = p; - p = &UE_sched.next[*p]; - } - /* Find max coeff: remove the max one: do not use remove_nr_list() since it - * goes through the whole list every time. Note that UE_sched.tail might - * not be set correctly anymore */ - const int UE_id = *max; - p = &UE_sched.next[*max]; - *max = UE_sched.next[*max]; - *p = -1; + while (remainUEs> 0 && n_rb_sched >= min_rbSize && iterator->UE != NULL) { - NR_UE_sched_ctrl_t *sched_ctrl = &UE_info->UE_sched_ctrl[UE_id]; + NR_UE_sched_ctrl_t *sched_ctrl = &iterator->UE->UE_sched_ctrl; - const int cid = sched_ctrl->coreset->controlResourceSetId; - const uint16_t Y = get_Y(cid%3, slot, UE_info->rnti[UE_id]); + const uint32_t Y = get_Y(sched_ctrl->search_space, slot, iterator->UE->rnti); uint8_t nr_of_candidates; for (int i=0; i<5; i++) { // for now taking the lowest value among the available aggregation levels @@ -1304,7 +1222,8 @@ void pf_ul(module_id_t module_id, &nr_of_candidates, sched_ctrl->search_space, 1<0) break; + if(nr_of_candidates>0) + break; } int CCEIndex = find_pdcch_candidate(RC.nrmac[module_id], CC_id, @@ -1314,56 +1233,71 @@ void pf_ul(module_id_t module_id, sched_ctrl->coreset, Y); if (CCEIndex<0) { - LOG_D(NR_MAC, "%4d.%2d no free CCE for UL DCI UE %04x\n", frame, slot, UE_info->rnti[UE_id]); + LOG_D(NR_MAC, "%4d.%2d no free CCE for UL DCI UE %04x\n", frame, slot, iterator->UE->rnti); + iterator++; continue; } - else LOG_D(NR_MAC, "%4d.%2d free CCE for UL DCI UE %04x\n",frame,slot, UE_info->rnti[UE_id]); + else LOG_D(NR_MAC, "%4d.%2d free CCE for UL DCI UE %04x\n",frame,slot, iterator->UE->rnti); - /* reduce max_num_ue once we are sure UE can be allocated, i.e., has CCE */ - max_num_ue--; - AssertFatal(max_num_ue >= 0, "Illegal max_num_ue %d\n", max_num_ue); + NR_CellGroupConfig_t *cg = iterator->UE->CellGroup; + NR_BWP_UplinkDedicated_t *ubwpd = cg && cg->spCellConfig && cg->spCellConfig->spCellConfigDedicated + && cg->spCellConfig->spCellConfigDedicated->uplinkConfig ? + cg->spCellConfig->spCellConfigDedicated->uplinkConfig->initialUplinkBWP : NULL; + + NR_BWP_t *genericParameters = get_ul_bwp_genericParameters(sched_ctrl->active_ubwp, + scc, + sib1); - NR_CellGroupConfig_t *cg = UE_info->CellGroup[UE_id]; - NR_BWP_UplinkDedicated_t *ubwpd= cg ? cg->spCellConfig->spCellConfigDedicated->uplinkConfig->initialUplinkBWP:NULL; - NR_BWP_t *genericParameters = sched_ctrl->active_ubwp ? &sched_ctrl->active_ubwp->bwp_Common->genericParameters : &scc->uplinkConfigCommon->initialUplinkBWP->genericParameters; int rbStart = sched_ctrl->active_ubwp ? NRRIV2PRBOFFSET(genericParameters->locationAndBandwidth, MAX_BWP_SIZE) : 0; const uint16_t bwpSize = NRRIV2BW(genericParameters->locationAndBandwidth, MAX_BWP_SIZE); NR_sched_pusch_t *sched_pusch = &sched_ctrl->sched_pusch; NR_pusch_semi_static_t *ps = &sched_ctrl->pusch_semi_static; - while (rbStart < bwpSize && !rballoc_mask[rbStart]) rbStart++; - sched_pusch->rbStart = rbStart; - uint16_t max_rbSize = 1; - while (rbStart + max_rbSize < bwpSize && rballoc_mask[rbStart + max_rbSize]) - max_rbSize++; - - if (rbStart + min_rb >= bwpSize) { - LOG_W(NR_MAC, "cannot allocate UL data for UE %d/RNTI %04x: no resources (rbStart %d, min_rb %d, bwpSize %d\n", - UE_id, UE_info->rnti[UE_id],rbStart,min_rb,bwpSize); - return; - } - else LOG_D(NR_MAC,"allocating UL data for UE %d/RNTI %04x (rbStsart %d, min_rb %d, bwpSize %d\n",UE_id, UE_info->rnti[UE_id],rbStart,min_rb,bwpSize); - /* Save PUSCH field */ /* we want to avoid a lengthy deduction of DMRS and other parameters in * every TTI if we can save it, so check whether dci_format, TDA, or * num_dmrs_cdm_grps_no_data has changed and only then recompute */ + const uint8_t nrOfLayers = 1; const uint8_t num_dmrs_cdm_grps_no_data = (sched_ctrl->active_ubwp || ubwpd) ? 1 : 2; int dci_format = get_dci_format(sched_ctrl); - const int tda = sched_ctrl->active_ubwp ? nrmac->preferred_ul_tda[sched_ctrl->active_ubwp->bwp_Id][slot] : 0; + const int tda = get_ul_tda(nrmac, scc, sched_pusch->slot); if (ps->time_domain_allocation != tda || ps->dci_format != dci_format - || ps->num_dmrs_cdm_grps_no_data != num_dmrs_cdm_grps_no_data - || sched_ctrl->update_pusch_ps) { - nr_set_pusch_semi_static(scc, sched_ctrl->active_ubwp, ubwpd, dci_format, tda, num_dmrs_cdm_grps_no_data, ps); - sched_ctrl->update_pusch_ps = false; + || ps->nrOfLayers != nrOfLayers + || ps->num_dmrs_cdm_grps_no_data != num_dmrs_cdm_grps_no_data) { + nr_set_pusch_semi_static(sib1, + scc, + sched_ctrl->active_ubwp, + ubwpd, + dci_format, + tda, + num_dmrs_cdm_grps_no_data, + nrOfLayers, + ps); } update_ul_ue_R_Qm(sched_pusch, ps); + const uint16_t slbitmap = SL_to_bitmap(ps->startSymbolIndex, ps->nrOfSymbols); + while (rbStart < bwpSize && (rballoc_mask[rbStart] & slbitmap) != slbitmap) + rbStart++; + sched_pusch->rbStart = rbStart; + uint16_t max_rbSize = 1; + while (rbStart + max_rbSize < bwpSize && (rballoc_mask[rbStart + max_rbSize] & slbitmap) == slbitmap) + max_rbSize++; + + if (rbStart + min_rb >= bwpSize) { + LOG_W(NR_MAC, "cannot allocate UL data for RNTI %04x: no resources (rbStart %d, min_rb %d, bwpSize %d)\n", + iterator->UE->rnti,rbStart,min_rb,bwpSize); + return; + } + else + LOG_D(NR_MAC,"allocating UL data for RNTI %04x (rbStsart %d, min_rb %d, bwpSize %d)\n", iterator->UE->rnti,rbStart,min_rb,bwpSize); + /* Calculate the current scheduling bytes and the necessary RBs */ const int B = cmax(sched_ctrl->estimated_ul_buffer - sched_ctrl->sched_ul_bytes, 0); uint16_t rbSize = 0; uint32_t TBS = 0; + nr_find_nb_rb(sched_pusch->Qm, sched_pusch->R, 1, // layers @@ -1376,8 +1310,8 @@ void pf_ul(module_id_t module_id, &rbSize); sched_pusch->rbSize = rbSize; sched_pusch->tb_size = TBS; - LOG_D(NR_MAC,"rbSize %d, TBS %d, est buf %d, sched_ul %d, B %d, CCE %d, num_dmrs_symb %d, N_PRB_DMRS %d\n", - rbSize, sched_pusch->tb_size, sched_ctrl->estimated_ul_buffer, sched_ctrl->sched_ul_bytes, B,sched_ctrl->cce_index,ps->num_dmrs_symb,ps->N_PRB_DMRS); + LOG_D(NR_MAC,"rbSize %d (max_rbSize %d), TBS %d, est buf %d, sched_ul %d, B %d, CCE %d, num_dmrs_symb %d, N_PRB_DMRS %d\n", + rbSize, max_rbSize,sched_pusch->tb_size, sched_ctrl->estimated_ul_buffer, sched_ctrl->sched_ul_bytes, B,sched_ctrl->cce_index,ps->num_dmrs_symb,ps->N_PRB_DMRS); /* Mark the corresponding RBs as used */ @@ -1390,7 +1324,11 @@ void pf_ul(module_id_t module_id, n_rb_sched -= sched_pusch->rbSize; for (int rb = 0; rb < sched_ctrl->sched_pusch.rbSize; rb++) - rballoc_mask[rb + sched_ctrl->sched_pusch.rbStart] = 0; + + rballoc_mask[rb + sched_ctrl->sched_pusch.rbStart] ^= slbitmap; + /* reduce max_num_ue once we are sure UE can be allocated, i.e., has CCE */ + remainUEs--; + iterator++; } } @@ -1399,10 +1337,16 @@ bool nr_fr1_ulsch_preprocessor(module_id_t module_id, frame_t frame, sub_frame_t gNB_MAC_INST *nr_mac = RC.nrmac[module_id]; NR_COMMON_channels_t *cc = nr_mac->common_channels; NR_ServingCellConfigCommon_t *scc = cc->ServingCellConfigCommon; - const int mu = scc->uplinkConfigCommon->initialUplinkBWP->genericParameters.subcarrierSpacing; - NR_UE_info_t *UE_info = &nr_mac->UE_info; + const NR_SIB1_t *sib1 = nr_mac->common_channels[0].sib1 ? nr_mac->common_channels[0].sib1->message.choice.c1->choice.systemInformationBlockType1 : NULL; + NR_ServingCellConfigCommonSIB_t *scc_sib1 = sib1 ? sib1->servingCellConfigCommon : NULL; - if (UE_info->num_UEs == 0) + AssertFatal(scc!=NULL || scc_sib1!=NULL,"We need one serving cell config common\n"); + + const int mu = scc ? scc->uplinkConfigCommon->initialUplinkBWP->genericParameters.subcarrierSpacing : + scc_sib1->uplinkConfigCommon->initialUplinkBWP.genericParameters.subcarrierSpacing; + + if (nr_mac->UE_info.list[0] == NULL) + // no UEs return false; const int CC_id = 0; @@ -1411,14 +1355,15 @@ bool nr_fr1_ulsch_preprocessor(module_id_t module_id, frame_t frame, sub_frame_t * have the same K2 (we don't support multiple/different K2s via different * TDAs yet). If the TDA is negative, it means that there is no UL slot to * schedule now (slot + k2 is not UL slot) */ - int UE_id = UE_info->list.head; - NR_UE_sched_ctrl_t *sched_ctrl = &UE_info->UE_sched_ctrl[UE_id]; - const int tda = sched_ctrl->active_ubwp ? nr_mac->preferred_ul_tda[sched_ctrl->active_ubwp->bwp_Id][slot] : 0; + NR_UE_sched_ctrl_t *sched_ctrl = &nr_mac->UE_info.list[0]->UE_sched_ctrl; + const int temp_tda = get_ul_tda(nr_mac, scc, slot); + int K2 = get_K2(scc, scc_sib1, sched_ctrl->active_ubwp, temp_tda, mu); + const int sched_frame = (frame + (slot + K2 >= nr_slots_per_frame[mu])) & 1023; + const int sched_slot = (slot + K2) % nr_slots_per_frame[mu]; + const int tda = get_ul_tda(nr_mac, scc, sched_slot); if (tda < 0) return false; - int K2 = get_K2(scc, sched_ctrl->active_ubwp, tda, mu); - const int sched_frame = frame + (slot + K2 >= nr_slots_per_frame[mu]); - const int sched_slot = (slot + K2) % nr_slots_per_frame[mu]; + DevAssert(K2 == get_K2(scc, scc_sib1, sched_ctrl->active_ubwp, tda, mu)); if (!is_xlsch_in_slot(nr_mac->ulsch_slot_bitmap[sched_slot / 64], sched_slot)) return false; @@ -1436,9 +1381,8 @@ bool nr_fr1_ulsch_preprocessor(module_id_t module_id, frame_t frame, sub_frame_t return false; // Avoid slots with the SRS - const NR_list_t *UE_list = &UE_info->list; - for (int UE_idx = UE_list->head; UE_idx >= 0; UE_idx = UE_list->next[UE_idx]) { - NR_sched_srs_t sched_srs = UE_info->UE_sched_ctrl[UE_idx].sched_srs; + UE_iterator(nr_mac->UE_info.list, UE) { + NR_sched_srs_t sched_srs = UE->UE_sched_ctrl.sched_srs; if(sched_srs.srs_scheduled && sched_srs.frame==sched_frame && sched_srs.slot==sched_slot) { return false; } @@ -1446,10 +1390,11 @@ bool nr_fr1_ulsch_preprocessor(module_id_t module_id, frame_t frame, sub_frame_t sched_ctrl->sched_pusch.slot = sched_slot; sched_ctrl->sched_pusch.frame = sched_frame; - for (UE_id = UE_info->list.next[UE_id]; UE_id >= 0; UE_id = UE_info->list.next[UE_id]) { - NR_UE_sched_ctrl_t *sched_ctrl = &UE_info->UE_sched_ctrl[UE_id]; - AssertFatal(K2 == get_K2(scc,sched_ctrl->active_ubwp, tda, mu), - "Different K2, %d(UE%d) != %ld(UE%d)\n", K2, 0, get_K2(scc,sched_ctrl->active_ubwp, tda, mu), UE_id); + UE_iterator(nr_mac->UE_info.list, UE2) { + NR_UE_sched_ctrl_t *sched_ctrl = &UE2->UE_sched_ctrl; + AssertFatal(K2 == get_K2(scc,scc_sib1,sched_ctrl->active_ubwp, tda, mu), + "Different K2, %d(UE%d) != %ld(UE%04x)\n", + K2, 0, get_K2(scc,scc_sib1,sched_ctrl->active_ubwp, tda, mu), UE2->rnti); sched_ctrl->sched_pusch.slot = sched_slot; sched_ctrl->sched_pusch.frame = sched_frame; } @@ -1459,25 +1404,30 @@ bool nr_fr1_ulsch_preprocessor(module_id_t module_id, frame_t frame, sub_frame_t * Calculate largest contiguous RBs */ uint16_t *vrb_map_UL = &RC.nrmac[module_id]->common_channels[CC_id].vrb_map_UL[sched_slot * MAX_BWP_SIZE]; - const uint16_t bwpSize = NRRIV2BW(sched_ctrl->active_ubwp ? - sched_ctrl->active_ubwp->bwp_Common->genericParameters.locationAndBandwidth: - scc->uplinkConfigCommon->initialUplinkBWP->genericParameters.locationAndBandwidth, - MAX_BWP_SIZE); - const uint16_t bwpStart = NRRIV2PRBOFFSET(sched_ctrl->active_ubwp ? - sched_ctrl->active_ubwp->bwp_Common->genericParameters.locationAndBandwidth: - scc->uplinkConfigCommon->initialUplinkBWP->genericParameters.locationAndBandwidth, - MAX_BWP_SIZE); - const struct NR_PUSCH_TimeDomainResourceAllocationList *tdaList = sched_ctrl->active_ubwp ? - sched_ctrl->active_ubwp->bwp_Common->pusch_ConfigCommon->choice.setup->pusch_TimeDomainAllocationList: - scc->uplinkConfigCommon->initialUplinkBWP->pusch_ConfigCommon->choice.setup->pusch_TimeDomainAllocationList; + + NR_BWP_t *genericParameters = get_ul_bwp_genericParameters(sched_ctrl->active_ubwp, + scc, + sib1); + + const uint16_t bwpSize = NRRIV2BW(genericParameters->locationAndBandwidth,MAX_BWP_SIZE); + const uint16_t bwpStart = NRRIV2PRBOFFSET(genericParameters->locationAndBandwidth,MAX_BWP_SIZE); + + NR_PUSCH_TimeDomainResourceAllocationList_t *tdaList = NULL; + if (sched_ctrl->active_ubwp) { + tdaList = sched_ctrl->active_ubwp->bwp_Common->pusch_ConfigCommon->choice.setup->pusch_TimeDomainAllocationList; + } else if (scc) { + tdaList = scc->uplinkConfigCommon->initialUplinkBWP->pusch_ConfigCommon->choice.setup->pusch_TimeDomainAllocationList; + } else { + NR_SIB1_t *sib1 = RC.nrmac[module_id]->common_channels[0].sib1->message.choice.c1->choice.systemInformationBlockType1; + tdaList = sib1->servingCellConfigCommon->uplinkConfigCommon->initialUplinkBWP.pusch_ConfigCommon->choice.setup->pusch_TimeDomainAllocationList; + } + const int startSymbolAndLength = tdaList->list.array[tda]->startSymbolAndLength; int startSymbolIndex, nrOfSymbols; SLIV2SL(startSymbolAndLength, &startSymbolIndex, &nrOfSymbols); - const uint16_t symb = ((1 << nrOfSymbols) - 1) << startSymbolIndex; + const uint16_t symb = SL_to_bitmap(startSymbolIndex, nrOfSymbols); int st = 0, e = 0, len = 0; - for (int i = 0; i < bwpSize; i++) - if (RC.nrmac[module_id]->ulprbbl[i] == 1) vrb_map_UL[i]=symb; for (int i = 0; i < bwpSize; i++) { while ((vrb_map_UL[bwpStart + i] & symb) != 0 && i < bwpSize) @@ -1494,17 +1444,17 @@ bool nr_fr1_ulsch_preprocessor(module_id_t module_id, frame_t frame, sub_frame_t LOG_D(NR_MAC,"UL %d.%d : start_prb %d, end PRB %d\n",frame,slot,st,e); - uint8_t rballoc_mask[bwpSize]; + uint16_t rballoc_mask[bwpSize]; /* Calculate mask: if any RB in vrb_map_UL is blocked (1), the current RB will be 0 */ for (int i = 0; i < bwpSize; i++) - rballoc_mask[i] = i >= st && i <= e; + rballoc_mask[i] = (i >= st && i <= e)*SL_to_bitmap(startSymbolIndex, nrOfSymbols); /* proportional fair scheduling algorithm */ pf_ul(module_id, frame, slot, - &UE_info->list, + nr_mac->UE_info.list, 2, len, rballoc_mask); @@ -1525,7 +1475,7 @@ nr_pp_impl_ul nr_init_fr1_ulsch_preprocessor(module_id_t module_id, int CC_id) if (mcs > 27 && mcsTableIdx == 1) continue; const uint8_t Qm = nr_get_Qm_dl(mcs, mcsTableIdx); - const uint16_t R = nr_get_code_rate_dl(mcs, mcsTableIdx); + const uint16_t R = nr_get_code_rate_ul(mcs, mcsTableIdx); /* note: we do not update R/Qm based on low MCS or pi2BPSK */ ul_pf_tbs[mcsTableIdx][mcs] = nr_compute_tbs(Qm, R, @@ -1565,24 +1515,28 @@ void nr_schedule_ulsch(module_id_t module_id, frame_t frame, sub_frame_t slot) NR_ServingCellConfigCommon_t *scc = RC.nrmac[module_id]->common_channels[0].ServingCellConfigCommon; - NR_UE_info_t *UE_info = &RC.nrmac[module_id]->UE_info; - const NR_list_t *UE_list = &UE_info->list; - for (int UE_id = UE_list->head; UE_id >= 0; UE_id = UE_list->next[UE_id]) { - NR_UE_sched_ctrl_t *sched_ctrl = &UE_info->UE_sched_ctrl[UE_id]; + NR_UEs_t *UE_info = &RC.nrmac[module_id]->UE_info; + const NR_SIB1_t *sib1 = RC.nrmac[module_id]->common_channels[0].sib1 ? RC.nrmac[module_id]->common_channels[0].sib1->message.choice.c1->choice.systemInformationBlockType1 : NULL; + UE_iterator( UE_info->list, UE) { + NR_UE_sched_ctrl_t *sched_ctrl = &UE->UE_sched_ctrl; if (sched_ctrl->ul_failure == 1 && get_softmodem_params()->phy_test==0) continue; - NR_CellGroupConfig_t *cg = UE_info->CellGroup[UE_id]; - NR_BWP_UplinkDedicated_t *ubwpd= cg ? cg->spCellConfig->spCellConfigDedicated->uplinkConfig->initialUplinkBWP:NULL; - UE_info->mac_stats[UE_id].ulsch_current_bytes = 0; + NR_CellGroupConfig_t *cg = UE->CellGroup; + + NR_BWP_UplinkDedicated_t *ubwpd = cg && cg->spCellConfig && cg->spCellConfig->spCellConfigDedicated && + cg->spCellConfig->spCellConfigDedicated->uplinkConfig ? + cg->spCellConfig->spCellConfigDedicated->uplinkConfig->initialUplinkBWP : NULL; + + UE->mac_stats.ul.current_bytes = 0; /* dynamic PUSCH values (RB alloc, MCS, hence R, Qm, TBS) that change in * every TTI are pre-populated by the preprocessor and used below */ NR_sched_pusch_t *sched_pusch = &sched_ctrl->sched_pusch; - LOG_D(NR_MAC,"UE %x : sched_pusch->rbSize %d\n",UE_info->rnti[UE_id],sched_pusch->rbSize); + LOG_D(NR_MAC,"UE %04x : sched_pusch->rbSize %d\n",UE->rnti,sched_pusch->rbSize); if (sched_pusch->rbSize <= 0) continue; - uint16_t rnti = UE_info->rnti[UE_id]; + uint16_t rnti = UE->rnti; sched_ctrl->SR = false; int8_t harq_id = sched_pusch->ul_harq_pid; @@ -1590,8 +1544,8 @@ void nr_schedule_ulsch(module_id_t module_id, frame_t frame, sub_frame_t slot) /* PP has not selected a specific HARQ Process, get a new one */ harq_id = sched_ctrl->available_ul_harq.head; AssertFatal(harq_id >= 0, - "no free HARQ process available for UE %d\n", - UE_id); + "no free HARQ process available for UE %04x\n", + UE->rnti); remove_front_nr_list(&sched_ctrl->available_ul_harq); sched_pusch->ul_harq_pid = harq_id; } else { @@ -1618,9 +1572,9 @@ void nr_schedule_ulsch(module_id_t module_id, frame_t frame, sub_frame_t slot) /* Statistics */ AssertFatal(cur_harq->round < 8, "Indexing ulsch_rounds[%d] is out of bounds\n", cur_harq->round); - UE_info->mac_stats[UE_id].ulsch_rounds[cur_harq->round]++; + UE->mac_stats.ul.rounds[cur_harq->round]++; if (cur_harq->round == 0) { - UE_info->mac_stats[UE_id].ulsch_total_bytes_scheduled += sched_pusch->tb_size; + UE->mac_stats.ulsch_total_bytes_scheduled += sched_pusch->tb_size; /* Save information on MCS, TBS etc for the current initial transmission * so we have access to it when retransmitting */ cur_harq->sched_pusch = *sched_pusch; @@ -1640,12 +1594,12 @@ void nr_schedule_ulsch(module_id_t module_id, frame_t frame, sub_frame_t slot) cur_harq->round, cur_harq->ndi); } - UE_info->mac_stats[UE_id].ulsch_current_bytes = sched_pusch->tb_size; + UE->mac_stats.ul.current_bytes = sched_pusch->tb_size; sched_ctrl->last_ul_frame = sched_pusch->frame; sched_ctrl->last_ul_slot = sched_pusch->slot; LOG_D(NR_MAC, - "ULSCH/PUSCH: %4d.%2d RNTI %04x UL sched %4d.%2d DCI L %d start %2d RBS %3d startSymbol %2d nb_symbol %2d dmrs_pos %x MCS %2d TBS %4d HARQ PID %2d round %d RV %d NDI %d est %6d sched %6d est BSR %6d TPC %d\n", + "ULSCH/PUSCH: %4d.%2d RNTI %04x UL sched %4d.%2d DCI L %d start %2d RBS %3d startSymbol %2d nb_symbol %2d dmrs_pos %x MCS %2d nrOfLayers %2d num_dmrs_cdm_grps_no_data %2d TBS %4d HARQ PID %2d round %d RV %d NDI %d est %6d sched %6d est BSR %6d TPC %d\n", frame, slot, rnti, @@ -1658,6 +1612,8 @@ void nr_schedule_ulsch(module_id_t module_id, frame_t frame, sub_frame_t slot) ps->nrOfSymbols, ps->ul_dmrs_symb_pos, sched_pusch->mcs, + ps->nrOfLayers, + ps->num_dmrs_cdm_grps_no_data, sched_pusch->tb_size, harq_id, cur_harq->round, @@ -1668,7 +1624,6 @@ void nr_schedule_ulsch(module_id_t module_id, frame_t frame, sub_frame_t slot) sched_ctrl->estimated_ul_buffer - sched_ctrl->sched_ul_bytes, sched_ctrl->tpc0); - /* PUSCH in a later slot, but corresponding DCI now! */ nfapi_nr_ul_tti_request_t *future_ul_tti_req = &RC.nrmac[module_id]->UL_tti_req_ahead[0][sched_pusch->slot]; AssertFatal(future_ul_tti_req->SFN == sched_pusch->frame @@ -1679,6 +1634,9 @@ void nr_schedule_ulsch(module_id_t module_id, frame_t frame, sub_frame_t slot) future_ul_tti_req->Slot, sched_pusch->frame, sched_pusch->slot); + AssertFatal(future_ul_tti_req->n_pdus < + sizeof(future_ul_tti_req->pdus_list) / sizeof(future_ul_tti_req->pdus_list[0]), + "Invalid future_ul_tti_req->n_pdus %d\n", future_ul_tti_req->n_pdus); future_ul_tti_req->pdus_list[future_ul_tti_req->n_pdus].pdu_type = NFAPI_NR_UL_CONFIG_PUSCH_PDU_TYPE; future_ul_tti_req->pdus_list[future_ul_tti_req->n_pdus].pdu_size = sizeof(nfapi_nr_pusch_pdu_t); nfapi_nr_pusch_pdu_t *pusch_pdu = &future_ul_tti_req->pdus_list[future_ul_tti_req->n_pdus].pusch_pdu; @@ -1693,7 +1651,10 @@ void nr_schedule_ulsch(module_id_t module_id, frame_t frame, sub_frame_t slot) pusch_pdu->handle = 0; //not yet used /* FAPI: BWP */ - NR_BWP_t *genericParameters = sched_ctrl->active_ubwp ? &sched_ctrl->active_ubwp->bwp_Common->genericParameters:&scc->uplinkConfigCommon->initialUplinkBWP->genericParameters; + NR_BWP_t *genericParameters = get_ul_bwp_genericParameters(sched_ctrl->active_ubwp, + scc, + sib1); + pusch_pdu->bwp_size = NRRIV2BW(genericParameters->locationAndBandwidth, MAX_BWP_SIZE); pusch_pdu->bwp_start = NRRIV2PRBOFFSET(genericParameters->locationAndBandwidth, MAX_BWP_SIZE); pusch_pdu->subcarrier_spacing = genericParameters->subcarrierSpacing; @@ -1709,7 +1670,8 @@ void nr_schedule_ulsch(module_id_t module_id, frame_t frame, sub_frame_t slot) pusch_pdu->data_scrambling_id = *ps->pusch_Config->dataScramblingIdentityPUSCH; else pusch_pdu->data_scrambling_id = *scc->physCellId; - pusch_pdu->nrOfLayers = 1; + pusch_pdu->nrOfLayers = ps->nrOfLayers; + pusch_pdu->num_dmrs_cdm_grps_no_data = ps->num_dmrs_cdm_grps_no_data; /* FAPI: DMRS */ pusch_pdu->ul_dmrs_symb_pos = ps->ul_dmrs_symb_pos; @@ -1734,7 +1696,7 @@ void nr_schedule_ulsch(module_id_t module_id, frame_t frame, sub_frame_t slot) } pusch_pdu->scid = 0; // DMRS sequence initialization [TS38.211, sec 6.4.1.1.1] pusch_pdu->num_dmrs_cdm_grps_no_data = ps->num_dmrs_cdm_grps_no_data; - pusch_pdu->dmrs_ports = 1; + pusch_pdu->dmrs_ports = ((1<nrOfLayers) - 1); /* FAPI: Pusch Allocation in frequency domain */ pusch_pdu->resource_alloc = 1; //type 1 @@ -1758,6 +1720,8 @@ void nr_schedule_ulsch(module_id_t module_id, frame_t frame, sub_frame_t slot) pusch_pdu->pusch_data.tb_size = sched_pusch->tb_size; pusch_pdu->pusch_data.num_cb = 0; //CBG not supported + pusch_pdu->maintenance_parms_v3.tbSizeLbrmBytes = 0; + LOG_D(NR_MAC,"PUSCH PDU : data_scrambling_identity %x, dmrs_scrambling_id %x\n",pusch_pdu->data_scrambling_id,pusch_pdu->ul_dmrs_scrambling_id); /* TRANSFORM PRECODING --------------------------------------------------------*/ @@ -1797,7 +1761,7 @@ void nr_schedule_ulsch(module_id_t module_id, frame_t frame, sub_frame_t slot) /* look up the PDCCH PDU for this BWP and CORESET. If it does not exist, * create it */ - const int bwpid = sched_ctrl->active_bwp ? sched_ctrl->active_bwp->bwp_Id : 0; + const int bwp_id = sched_ctrl->active_bwp ? sched_ctrl->active_bwp->bwp_Id : 0; NR_SearchSpace_t *ss = (sched_ctrl->active_bwp || ubwpd) ? sched_ctrl->search_space: RC.nrmac[module_id]->sched_ctrlCommon->search_space; NR_ControlResourceSet_t *coreset = (sched_ctrl->active_bwp || ubwpd) ? sched_ctrl->coreset: RC.nrmac[module_id]->sched_ctrlCommon->coreset; const int coresetid = coreset->controlResourceSetId; @@ -1813,7 +1777,7 @@ void nr_schedule_ulsch(module_id_t module_id, frame_t frame, sub_frame_t slot) pdcch_pdu_coreset[coresetid] = pdcch_pdu; } - LOG_D(NR_MAC,"Configuring ULDCI/PDCCH in %d.%d at CCE %d, rnti %x\n", frame,slot,sched_ctrl->cce_index,rnti); + LOG_D(NR_MAC,"Configuring ULDCI/PDCCH in %d.%d at CCE %d, rnti %04x\n", frame,slot,sched_ctrl->cce_index,rnti); /* Fill PDCCH DL DCI PDU */ nfapi_nr_dl_dci_pdu_t *dci_pdu = &pdcch_pdu->dci_pdu[pdcch_pdu->numDlDci]; @@ -1835,19 +1799,25 @@ void nr_schedule_ulsch(module_id_t module_id, frame_t frame, sub_frame_t slot) dci_pdu_rel15_t uldci_payload; memset(&uldci_payload, 0, sizeof(uldci_payload)); int n_ubwp=1; - if (cg->spCellConfig->spCellConfigDedicated->uplinkConfig->uplinkBWP_ToAddModList) - n_ubwp = cg->spCellConfig->spCellConfigDedicated->uplinkConfig->uplinkBWP_ToAddModList->list.count; + if (cg && + cg->spCellConfig && + cg->spCellConfig->spCellConfigDedicated && + cg->spCellConfig->spCellConfigDedicated->uplinkConfig && + cg->spCellConfig->spCellConfigDedicated->uplinkConfig->uplinkBWP_ToAddModList) { + n_ubwp = cg->spCellConfig->spCellConfigDedicated->uplinkConfig->uplinkBWP_ToAddModList->list.count; + } - config_uldci(sched_ctrl->active_ubwp, + config_uldci(sib1, + sched_ctrl->active_ubwp, ubwpd, scc, pusch_pdu, &uldci_payload, ps->dci_format, ps->time_domain_allocation, - UE_info->UE_sched_ctrl[UE_id].tpc0, + UE->UE_sched_ctrl.tpc0, n_ubwp, - bwpid); + bwp_id); fill_dci_pdu_rel15(scc, cg, dci_pdu, @@ -1855,7 +1825,9 @@ void nr_schedule_ulsch(module_id_t module_id, frame_t frame, sub_frame_t slot) ps->dci_format, rnti_types[0], pusch_pdu->bwp_size, - bwpid); + bwp_id, + coresetid, + nr_mac->cset0_bwp_size); memset(sched_pusch, 0, sizeof(*sched_pusch)); } diff --git a/openair2/LAYER2/NR_MAC_gNB/mac_proto.h b/openair2/LAYER2/NR_MAC_gNB/mac_proto.h index 28e9d689fa..b6774756c9 100644 --- a/openair2/LAYER2/NR_MAC_gNB/mac_proto.h +++ b/openair2/LAYER2/NR_MAC_gNB/mac_proto.h @@ -38,21 +38,28 @@ void set_cset_offset(uint16_t); void mac_top_init_gNB(void); +void process_CellGroup(NR_CellGroupConfig_t *CellGroup, NR_UE_sched_ctrl_t *sched_ctrl); + void config_common(int Mod_idP, int ssb_SubcarrierOffset, int pdsch_AntennaPorts, int pusch_AntennaPorts, - NR_ServingCellConfigCommon_t *scc - ); + NR_ServingCellConfigCommon_t *scc); + +int nr_mac_enable_ue_rrc_processing_timer(module_id_t Mod_idP, + rnti_t rnti, + NR_SubcarrierSpacing_t subcarrierSpacing, + uint32_t rrc_reconfiguration_delay); int rrc_mac_config_req_gNB(module_id_t Mod_idP, int ssb_SubcarrierOffset, - int pdsch_AntennaPorts, + rrc_pdsch_AntennaPorts_t pdsch_AntennaPorts, int pusch_AntennaPorts, int sib1_tda, int minRXTXTIMEpdsch, NR_ServingCellConfigCommon_t *scc, NR_BCCH_BCH_Message_t *mib, + NR_BCCH_DL_SCH_Message_t *sib1, int add_ue, uint32_t rnti, NR_CellGroupConfig_t *CellGroup); @@ -62,9 +69,17 @@ void clear_nr_nfapi_information(gNB_MAC_INST * gNB, frame_t frameP, sub_frame_t subframeP); +void nr_mac_update_timers(module_id_t module_id, + frame_t frame, + sub_frame_t slot); + void gNB_dlsch_ulsch_scheduler(module_id_t module_idP, frame_t frame_rxP, sub_frame_t slot_rxP); +void schedule_nr_bwp_switch(module_id_t module_id, + frame_t frame, + sub_frame_t slot); + /* \brief main DL scheduler function. Calls a preprocessor to decide on * resource allocation, then "post-processes" resource allocation (nFAPI * messages, statistics, HARQ handling, CEs, ... */ @@ -176,7 +191,8 @@ void handle_nr_uci_pucch_2_3_4(module_id_t mod_id, const nfapi_nr_uci_pucch_pdu_format_2_3_4_t *uci_234); -void config_uldci(const NR_BWP_Uplink_t *ubwp, +void config_uldci(const NR_SIB1_t *sib1, + const NR_BWP_Uplink_t *ubwp, const NR_BWP_UplinkDedicated_t *ubwpd, const NR_ServingCellConfigCommon_t *scc, const nfapi_nr_pusch_pdu_t *pusch_pdu, @@ -187,7 +203,7 @@ void config_uldci(const NR_BWP_Uplink_t *ubwp, int n_ubwp, int bwp_id); -void nr_schedule_pucch(int Mod_idP, +void nr_schedule_pucch(gNB_MAC_INST* nrmac, frame_t frameP, sub_frame_t slotP); @@ -202,15 +218,14 @@ void nr_csi_meas_reporting(int Mod_idP, frame_t frameP, sub_frame_t slotP); -int nr_acknack_scheduling(int Mod_idP, - int UE_id, +int nr_acknack_scheduling( int Mod_idP, + NR_UE_info_t * UE, frame_t frameP, sub_frame_t slotP, int r_pucch, int do_common); -void get_pdsch_to_harq_feedback(int Mod_idP, - int UE_id, +void get_pdsch_to_harq_feedback(NR_UE_info_t *, int bwp_id, NR_SearchSpace__searchSpaceType_PR ss_type, int *max_fb_time, @@ -219,7 +234,7 @@ void get_pdsch_to_harq_feedback(int Mod_idP, void nr_configure_css_dci_initial(nfapi_nr_dl_tti_pdcch_pdu_rel15_t* pdcch_pdu, nr_scs_e scs_common, nr_scs_e pdcch_scs, - nr_frequency_range_e freq_range, + frequency_range_t freq_range, uint8_t rmsi_pdcch_config, uint8_t ssb_idx, uint8_t k_ssb, @@ -235,7 +250,13 @@ int nr_is_dci_opportunity(nfapi_nr_search_space_t search_space, nfapi_nr_config_request_scf_t cfg); */ -void nr_configure_pucch(nfapi_nr_pucch_pdu_t* pucch_pdu, +int nr_get_pucch_resource(NR_ControlResourceSet_t *coreset, + NR_BWP_Uplink_t *bwp, + NR_BWP_UplinkDedicated_t *bwpd, + int CCEIndex); + +void nr_configure_pucch(const NR_SIB1_t *sib1, + nfapi_nr_pucch_pdu_t* pucch_pdu, NR_ServingCellConfigCommon_t *scc, NR_CellGroupConfig_t *CellGroup, NR_BWP_Uplink_t *bwp, @@ -269,7 +290,7 @@ int find_pdcch_candidate(gNB_MAC_INST *mac, int nr_of_candidates, NR_sched_pdcch_t *pdcch, NR_ControlResourceSet_t *coreset, - uint16_t Y); + uint32_t Y); void fill_pdcch_vrb_map(gNB_MAC_INST *mac, int CC_id, @@ -284,28 +305,56 @@ void fill_dci_pdu_rel15(const NR_ServingCellConfigCommon_t *scc, int dci_formats, int rnti_types, int N_RB, - int bwp_id); + int bwp_id, + NR_ControlResourceSetId_t coreset_id, + uint16_t cset0_bwp_size); void prepare_dci(const NR_CellGroupConfig_t *CellGroup, dci_pdu_rel15_t *dci_pdu_rel15, nr_dci_format_t format, int bwp_id); +void set_r_pucch_parms(int rsetindex, + int r_pucch, + int bwp_size, + int *prb_start, + int *second_hop_prb, + int *nr_of_symbols, + int *start_symbol_index); + +NR_BWP_t *get_dl_bwp_genericParameters(NR_BWP_Downlink_t *active_bwp, + NR_ServingCellConfigCommon_t *ServingCellConfigCommon, + const NR_SIB1_t *sib1); + +NR_BWP_t *get_ul_bwp_genericParameters(NR_BWP_Uplink_t *active_ubwp, + NR_ServingCellConfigCommon_t *ServingCellConfigCommon, + const NR_SIB1_t *sib1); + +NR_PDSCH_TimeDomainResourceAllocationList_t *get_pdsch_TimeDomainAllocationList(const NR_BWP_Downlink_t *active_bwp, + const NR_ServingCellConfigCommon_t *ServingCellConfigCommon, + const NR_SIB1_t *sib1); + /* find coreset within the search space */ -NR_ControlResourceSet_t *get_coreset(module_id_t module_idP, +NR_ControlResourceSet_t *get_coreset(gNB_MAC_INST *nrmac, NR_ServingCellConfigCommon_t *scc, void *bwp, NR_SearchSpace_t *ss, NR_SearchSpace__searchSpaceType_PR ss_type); /* find a search space within a BWP */ -NR_SearchSpace_t *get_searchspace(NR_ServingCellConfigCommon_t *scc, +NR_SearchSpace_t *get_searchspace(const NR_SIB1_t *sib1, + NR_ServingCellConfigCommon_t *scc, NR_BWP_DownlinkDedicated_t *bwp_Dedicated, NR_SearchSpace__searchSpaceType_PR target_ss); -long get_K2(NR_ServingCellConfigCommon_t *scc, NR_BWP_Uplink_t *ubwp, int time_domain_assignment, int mu); +long get_K2(NR_ServingCellConfigCommon_t *scc, + NR_ServingCellConfigCommonSIB_t *scc_sib1, + NR_BWP_Uplink_t *ubwp, + int time_domain_assignment, + int mu); -void nr_set_pdsch_semi_static(const NR_ServingCellConfigCommon_t *scc, +void nr_set_pdsch_semi_static(const NR_SIB1_t *sib1, + const NR_ServingCellConfigCommon_t *scc, const NR_CellGroupConfig_t *secondaryCellGroup, const NR_BWP_Downlink_t *bwp, const NR_BWP_DownlinkDedicated_t *bwpd0, @@ -314,16 +363,16 @@ void nr_set_pdsch_semi_static(const NR_ServingCellConfigCommon_t *scc, NR_UE_sched_ctrl_t *sched_ctrl, NR_pdsch_semi_static_t *ps); -void nr_set_pusch_semi_static(const NR_ServingCellConfigCommon_t *scc, +void nr_set_pusch_semi_static(const NR_SIB1_t *sib1, + const NR_ServingCellConfigCommon_t *scc, const NR_BWP_Uplink_t *ubwp, - const NR_BWP_UplinkDedicated_t *ubwpd, + const NR_BWP_UplinkDedicated_t *ubwpd, long dci_format, int tda, uint8_t num_dmrs_cdm_grps_no_data, + uint8_t nrOfLayers, NR_pusch_semi_static_t *ps); -uint16_t get_Y(int cid, int slot, rnti_t rnti); - uint8_t nr_get_tpc(int target, uint8_t cqi, int incr); int get_spf(nfapi_nr_config_request_scf_t *cfg); @@ -336,20 +385,12 @@ void nr_get_tbs_dl(nfapi_nr_dl_tti_pdsch_pdu *pdsch_pdu, int x_overhead, uint8_t numdmrscdmgroupnodata, uint8_t tb_scaling); -/** \brief Computes Q based on I_MCS PDSCH and table_idx for downlink. Implements MCS Tables from 38.214. */ -uint8_t nr_get_Qm_dl(uint8_t Imcs, uint8_t table_idx); -uint32_t nr_get_code_rate_dl(uint8_t Imcs, uint8_t table_idx); - -/** \brief Computes Q based on I_MCS PDSCH and table_idx for uplink. Implements MCS Tables from 38.214. */ -uint8_t nr_get_Qm_ul(uint8_t Imcs, uint8_t table_idx); -uint32_t nr_get_code_rate_ul(uint8_t Imcs, uint8_t table_idx); int NRRIV2BW(int locationAndBandwidth,int N_RB); int NRRIV2PRBOFFSET(int locationAndBandwidth,int N_RB); /* Functions to manage an NR_list_t */ -void dump_nr_list(NR_list_t *listP); void create_nr_list(NR_list_t *listP, int len); void resize_nr_list(NR_list_t *list, int new_len); void destroy_nr_list(NR_list_t *list); @@ -359,27 +400,19 @@ void add_tail_nr_list(NR_list_t *listP, int id); void add_front_nr_list(NR_list_t *listP, int id); void remove_front_nr_list(NR_list_t *listP); -int find_nr_UE_id(module_id_t mod_idP, rnti_t rntiP); +NR_UE_info_t * find_nr_UE(NR_UEs_t* UEs, rnti_t rntiP); int find_nr_RA_id(module_id_t mod_idP, int CC_idP, rnti_t rntiP); -int add_new_nr_ue(module_id_t mod_idP, rnti_t rntiP, NR_CellGroupConfig_t *CellGroup); +NR_UE_info_t*add_new_nr_ue(gNB_MAC_INST *nr_mac, rnti_t rntiP, NR_CellGroupConfig_t *CellGroup); -void mac_remove_nr_ue(module_id_t mod_id, rnti_t rnti); +void mac_remove_nr_ue(gNB_MAC_INST *nr_mac, rnti_t rnti); void nr_mac_remove_ra_rnti(module_id_t mod_id, rnti_t rnti); -int allocate_nr_CCEs(gNB_MAC_INST *nr_mac, - NR_BWP_Downlink_t *bwp, - NR_ControlResourceSet_t *coreset, - int aggregation, - uint16_t Y, - int m, - int nr_of_candidates); - int nr_get_default_pucch_res(int pucch_ResourceCommon); -void compute_csi_bitlen(NR_CSI_MeasConfig_t *csi_MeasConfig, NR_UE_info_t *UE_info, int UE_id, module_id_t Mod_idP); +void compute_csi_bitlen(NR_CSI_MeasConfig_t *csi_MeasConfig, NR_UE_info_t *UE); int get_dlscs(nfapi_nr_config_request_t *cfg); @@ -456,17 +489,21 @@ void find_SSB_and_RO_available(module_id_t module_idP); void set_dl_dmrs_ports(NR_pdsch_semi_static_t *ps); -void set_dl_mcs(NR_sched_pdsch_t *sched_pdsch, - NR_UE_sched_ctrl_t *sched_ctrl, - uint8_t *target_mcs, - uint8_t mcs_table_idx); +uint16_t set_pm_index(NR_UE_sched_ctrl_t *sched_ctrl, + int layers, + int N1, int N2, + int xp_pdsch_antenna_ports, + int codebook_mode); + +uint8_t get_mcs_from_cqi(int mcs_table, int cqi_table, int cqi_idx); uint8_t set_dl_nrOfLayers(NR_UE_sched_ctrl_t *sched_ctrl); -void calculate_preferred_dl_tda(module_id_t module_id, const NR_BWP_Downlink_t *bwp); -void calculate_preferred_ul_tda(module_id_t module_id, const NR_BWP_Uplink_t *ubwp); +int get_dci_format(NR_UE_sched_ctrl_t *sched_ctrl); +const int get_dl_tda(const gNB_MAC_INST *nrmac, const NR_ServingCellConfigCommon_t *scc, int slot); +const int get_ul_tda(const gNB_MAC_INST *nrmac, const NR_ServingCellConfigCommon_t *scc, int slot); -bool find_free_CCE(module_id_t module_id, sub_frame_t slot, int UE_id); +bool find_free_CCE(sub_frame_t slot, NR_UE_info_t *UE); bool nr_find_nb_rb(uint16_t Qm, uint16_t R, @@ -479,7 +516,16 @@ bool nr_find_nb_rb(uint16_t Qm, uint32_t *tbs, uint16_t *nb_rb); -void nr_sr_reporting(int Mod_idP, frame_t frameP, sub_frame_t slotP); +int get_mcs_from_bler(const NR_bler_options_t *bler_options, + const NR_mac_dir_stats_t *stats, + NR_bler_stats_t *bler_stats, + int max_mcs, + frame_t frame); + +void nr_sr_reporting(gNB_MAC_INST *nrmac, frame_t frameP, sub_frame_t slotP); + +size_t dump_mac_stats(gNB_MAC_INST *gNB, char *output, size_t strlen, bool reset_rsrp); + +void process_CellGroup(NR_CellGroupConfig_t *CellGroup, NR_UE_sched_ctrl_t *sched_ctrl); -void dump_mac_stats(gNB_MAC_INST *gNB, char *output, int strlen, bool reset_rsrp); #endif /*__LAYER2_NR_MAC_PROTO_H__*/ diff --git a/openair2/LAYER2/NR_MAC_gNB/main.c b/openair2/LAYER2/NR_MAC_gNB/main.c index b9da84ead2..9b9fd4e76c 100644 --- a/openair2/LAYER2/NR_MAC_gNB/main.c +++ b/openair2/LAYER2/NR_MAC_gNB/main.c @@ -45,101 +45,130 @@ extern RAN_CONTEXT_t RC; -#define MACSTATSSTRLEN 16384 +#define MACSTATSSTRLEN 65536 void *nrmac_stats_thread(void *arg) { gNB_MAC_INST *gNB = (gNB_MAC_INST *)arg; - char output[MACSTATSSTRLEN]; - memset(output,0,MACSTATSSTRLEN); - FILE *fd=fopen("nrMAC_stats.log","w"); - AssertFatal(fd!=NULL,"Cannot open nrMAC_stats.log, error %s\n",strerror(errno)); + char output[MACSTATSSTRLEN] = {0}; + const char *end = output + MACSTATSSTRLEN; + FILE *file = fopen("nrMAC_stats.log","w"); + AssertFatal(file!=NULL,"Cannot open nrMAC_stats.log, error %s\n",strerror(errno)); while (oai_exit == 0) { - dump_mac_stats(gNB,output,MACSTATSSTRLEN,false); - fprintf(fd,"%s\n",output); - fflush(fd); - usleep(200000); - fseek(fd,0,SEEK_SET); + char *p = output; + p += dump_mac_stats(gNB, p, end - p, false); + p += snprintf(p, end - p, "\n"); + p += print_meas_log(&gNB->eNB_scheduler, "DL & UL scheduling timing", NULL, NULL, p, end - p); + p += print_meas_log(&gNB->schedule_dlsch, "dlsch scheduler", NULL, NULL, p, end - p); + p += print_meas_log(&gNB->rlc_data_req, "rlc_data_req", NULL, NULL, p, end - p); + p += print_meas_log(&gNB->rlc_status_ind, "rlc_status_ind", NULL, NULL, p, end - p); + fwrite(output, p - output, 1, file); + fflush(file); + sleep(1); + fseek(file,0,SEEK_SET); } - fclose(fd); + fclose(file); return NULL; } void clear_mac_stats(gNB_MAC_INST *gNB) { - memset((void*)gNB->UE_info.mac_stats,0,MAX_MOBILES_PER_GNB*sizeof(NR_mac_stats_t)); + UE_iterator(gNB->UE_info.list, UE) { + memset(&UE->mac_stats,0,sizeof(UE->mac_stats)); + } } -void dump_mac_stats(gNB_MAC_INST *gNB, char *output, int strlen, bool reset_rsrp) +size_t dump_mac_stats(gNB_MAC_INST *gNB, char *output, size_t strlen, bool reset_rsrp) { - NR_UE_info_t *UE_info = &gNB->UE_info; int num = 1; + const char *begin = output; + const char *end = output + strlen; - int stroff=0; - if (UE_info->num_UEs == 0) return; - - for (int UE_id = UE_info->list.head; UE_id >= 0; UE_id = UE_info->list.next[UE_id]) { - - const NR_UE_sched_ctrl_t *sched_ctrl = &UE_info->UE_sched_ctrl[UE_id]; - NR_mac_stats_t *stats = &UE_info->mac_stats[UE_id]; + pthread_mutex_lock(&gNB->UE_info.mutex); + UE_iterator(gNB->UE_info.list, UE) { + NR_UE_sched_ctrl_t *sched_ctrl = &UE->UE_sched_ctrl; + NR_mac_stats_t *stats = &UE->mac_stats; const int avg_rsrp = stats->num_rsrp_meas > 0 ? stats->cumul_rsrp / stats->num_rsrp_meas : 0; - stroff+=sprintf(output+stroff,"UE ID %d RNTI %04x (%d/%d) PH %d dB PCMAX %d dBm, average RSRP %d (%d meas)\n", - UE_id, - UE_info->rnti[UE_id], - num++, - UE_info->num_UEs, - sched_ctrl->ph, - sched_ctrl->pcmax, - avg_rsrp, - stats->num_rsrp_meas); - stroff+=sprintf(output+stroff,"UE %d: dlsch_rounds %"PRIu64"/%"PRIu64"/%"PRIu64"/%"PRIu64", dlsch_errors %"PRIu64", pucch0_DTX %d, BLER %.5f MCS %d\n", - UE_id, - stats->dlsch_rounds[0], stats->dlsch_rounds[1], - stats->dlsch_rounds[2], stats->dlsch_rounds[3], - stats->dlsch_errors, - stats->pucch0_DTX, - sched_ctrl->dl_bler_stats.bler, - sched_ctrl->dl_bler_stats.mcs); + + output += snprintf(output, + end - output, + "UE RNTI %04x (%d) PH %d dB PCMAX %d dBm, average RSRP %d (%d meas)\n", + UE->rnti, + num++, + sched_ctrl->ph, + sched_ctrl->pcmax, + avg_rsrp, + stats->num_rsrp_meas); + output += snprintf(output, + end - output, + "UE %04x: CQI %d, RI %d, PMI (%d,%d)\n", + UE->rnti, + UE->UE_sched_ctrl.CSI_report.cri_ri_li_pmi_cqi_report.wb_cqi_1tb, + UE->UE_sched_ctrl.CSI_report.cri_ri_li_pmi_cqi_report.ri+1, + UE->UE_sched_ctrl.CSI_report.cri_ri_li_pmi_cqi_report.pmi_x1, + UE->UE_sched_ctrl.CSI_report.cri_ri_li_pmi_cqi_report.pmi_x2); + + output += snprintf(output, + end - output, + "UE %04x: dlsch_rounds %"PRIu64"/%"PRIu64"/%"PRIu64"/%"PRIu64", dlsch_errors %"PRIu64", pucch0_DTX %d, BLER %.5f MCS %d\n", + UE->rnti, + stats->dl.rounds[0], stats->dl.rounds[1], + stats->dl.rounds[2], stats->dl.rounds[3], + stats->dl.errors, + stats->pucch0_DTX, + sched_ctrl->dl_bler_stats.bler, + sched_ctrl->dl_bler_stats.mcs); if (reset_rsrp) { stats->num_rsrp_meas = 0; stats->cumul_rsrp = 0; } - stroff+=sprintf(output+stroff,"UE %d: dlsch_total_bytes %"PRIu64"\n", UE_id, stats->dlsch_total_bytes); - stroff+=sprintf(output+stroff,"UE %d: ulsch_rounds %"PRIu64"/%"PRIu64"/%"PRIu64"/%"PRIu64", ulsch_DTX %d, ulsch_errors %"PRIu64"\n", - UE_id, - stats->ulsch_rounds[0], stats->ulsch_rounds[1], - stats->ulsch_rounds[2], stats->ulsch_rounds[3], - stats->ulsch_DTX, - stats->ulsch_errors); - stroff+=sprintf(output+stroff, - "UE %d: ulsch_total_bytes_scheduled %"PRIu64", ulsch_total_bytes_received %"PRIu64"\n", - UE_id, - stats->ulsch_total_bytes_scheduled, stats->ulsch_total_bytes_rx); + output += snprintf(output, + end - output, + "UE %04x: dlsch_total_bytes %"PRIu64"\n", + UE->rnti, + stats->dl.total_bytes); + output += snprintf(output, + end - output, + "UE %04x: ulsch_rounds %"PRIu64"/%"PRIu64"/%"PRIu64"/%"PRIu64", ulsch_DTX %d, ulsch_errors %"PRIu64", BLER %.5f MCS %d\n", + UE->rnti, + stats->ul.rounds[0], stats->ul.rounds[1], + stats->ul.rounds[2], stats->ul.rounds[3], + stats->ulsch_DTX, + stats->ul.errors, + sched_ctrl->ul_bler_stats.bler, + sched_ctrl->ul_bler_stats.mcs); + output += snprintf(output, + end - output, + "UE %04x: ulsch_total_bytes_scheduled %"PRIu64", ulsch_total_bytes_received %"PRIu64"\n", + UE->rnti, + stats->ulsch_total_bytes_scheduled, stats->ul.total_bytes); for (int lc_id = 0; lc_id < 63; lc_id++) { - if (stats->lc_bytes_tx[lc_id] > 0) { - stroff+=sprintf(output+stroff, "UE %d: LCID %d: %"PRIu64" bytes TX\n", UE_id, lc_id, stats->lc_bytes_tx[lc_id]); - LOG_D(NR_MAC, "UE %d: LCID %d: %"PRIu64" bytes TX\n", UE_id, lc_id, stats->lc_bytes_tx[lc_id]); - } - if (stats->lc_bytes_rx[lc_id] > 0) { - stroff+=sprintf(output+stroff, "UE %d: LCID %d: %"PRIu64" bytes RX\n", UE_id, lc_id, stats->lc_bytes_rx[lc_id]); - LOG_D(NR_MAC, "UE %d: LCID %d: %"PRIu64" bytes RX\n", UE_id, lc_id, stats->lc_bytes_rx[lc_id]); - } + if (stats->dl.lc_bytes[lc_id] > 0) + output += snprintf(output, + end - output, + "UE %04x: LCID %d: %"PRIu64" bytes TX\n", + UE->rnti, + lc_id, + stats->dl.lc_bytes[lc_id]); + if (stats->ul.lc_bytes[lc_id] > 0) + output += snprintf(output, + end - output, + "UE %04x: LCID %d: %"PRIu64" bytes RX\n", + UE->rnti, + lc_id, + stats->ul.lc_bytes[lc_id]); } } - print_meas(&gNB->eNB_scheduler, "DL & UL scheduling timing stats", NULL, NULL); - print_meas(&gNB->schedule_dlsch,"dlsch scheduler",NULL,NULL); - print_meas(&gNB->rlc_data_req, "rlc_data_req",NULL,NULL); - print_meas(&gNB->rlc_status_ind,"rlc_status_ind",NULL,NULL); + pthread_mutex_unlock(&gNB->UE_info.mutex); + return output - begin; } void mac_top_init_gNB(void) { module_id_t i; - int list_el; - NR_UE_info_t *UE_info; gNB_MAC_INST *nrmac; LOG_I(MAC, "[MAIN] Init function start:nb_nr_macrlc_inst=%d\n",RC.nb_nr_macrlc_inst); @@ -173,6 +202,8 @@ void mac_top_init_gNB(void) RC.nrmac[i]->first_MIB = true; + pthread_mutex_init(&RC.nrmac[i]->UE_info.mutex, NULL); + if (get_softmodem_params()->phy_test) { RC.nrmac[i]->pre_processor_dl = nr_preprocessor_phytest; RC.nrmac[i]->pre_processor_ul = nr_ul_preprocessor_phytest; @@ -204,13 +235,7 @@ void mac_top_init_gNB(void) nrmac = RC.nrmac[i]; nrmac->if_inst = NR_IF_Module_init(i); - - UE_info = &nrmac->UE_info; - UE_info->num_UEs = 0; - create_nr_list(&UE_info->list, MAX_MOBILES_PER_GNB); - for (list_el = 0; list_el < MAX_MOBILES_PER_GNB; list_el++) { - UE_info->active[list_el] = false; - } + memset(&nrmac->UE_info, 0, sizeof(nrmac->UE_info)); } srand48(0); diff --git a/openair2/LAYER2/NR_MAC_gNB/nr_mac_gNB.h b/openair2/LAYER2/NR_MAC_gNB/nr_mac_gNB.h index b1e1241487..03a982ab7b 100644 --- a/openair2/LAYER2/NR_MAC_gNB/nr_mac_gNB.h +++ b/openair2/LAYER2/NR_MAC_gNB/nr_mac_gNB.h @@ -72,7 +72,7 @@ /* Defs */ -#define MAX_NUM_BWP 2 +#define MAX_NUM_BWP 5 #define MAX_NUM_CORESET 12 #define MAX_NUM_CCE 90 #define MAX_HARQ_ROUNDS 4 @@ -80,6 +80,8 @@ #define NR_NB_RA_PROC_MAX 4 #define MAX_NUM_OF_SSB 64 +#define MIN_NUM_PRBS_TO_SCHEDULE 5 + /*! \brief NR_list_t is a "list" (of users, HARQ processes, slices, ...). * Especially useful in the scheduler and to keep "classes" of users. */ typedef struct { @@ -89,6 +91,7 @@ typedef struct { int len; } NR_list_t; + typedef enum { RA_IDLE = 0, Msg2 = 1, @@ -121,8 +124,10 @@ typedef struct NR_sched_pdcch { typedef struct { /// Flag to indicate this process is active RA_gNB_state_t state; - /// BWP id of RA process - int bwp_id; + /// DL BWP id of RA process + int dl_bwp_id; + /// UL BWP id of RA process + int ul_bwp_id; /// CORESET0 configured flag int coreset0_configured; /// Slot where preamble was received @@ -171,6 +176,8 @@ typedef struct { uint8_t msg3_round; /// Flag to indicate if Msg3 carries a DCCH or DTCH message bool msg3_dcch_dtch; + int msg3_startsymb; + int msg3_nrsymb; /// TBS used for Msg4 int msg4_TBsize; /// MCS used for Msg4 @@ -200,9 +207,10 @@ typedef struct { int p_gNB; int Ncp; int nr_band; - lte_frame_type_t frame_type; + frame_type_t frame_type; uint64_t dl_CarrierFreq; NR_BCCH_BCH_Message_t *mib; + NR_BCCH_DL_SCH_Message_t *sib1; NR_ServingCellConfigCommon_t *ServingCellConfigCommon; NR_ARFCN_ValueEUTRA_t ul_CarrierFreq; long ul_Bandwidth; @@ -327,6 +335,10 @@ typedef struct NR_sched_pucch { uint8_t timing_indicator; uint8_t resource_indicator; int r_pucch; + int prb_start; + int second_hop_prb; + int nr_of_symb; + int start_symb; } NR_sched_pucch_t; /* PUSCH semi-static configuration: as long as the TDA and DCI format remain @@ -336,6 +348,7 @@ typedef struct NR_sched_pucch { typedef struct NR_pusch_semi_static_t { int dci_format; int time_domain_allocation; + uint8_t nrOfLayers; uint8_t num_dmrs_cdm_grps_no_data; int startSymbolIndex; @@ -438,7 +451,7 @@ typedef struct NR_UE_harq { /* Transport block to be sent using this HARQ process, its size is in * sched_pdsch */ - uint32_t tb[16384]; + uint32_t transportBlock[16384]; uint32_t tb_size; /// sched_pdsch keeps information on MCS etc used for the initial transmission @@ -447,13 +460,12 @@ typedef struct NR_UE_harq { //! fixme : need to enhace for the multiple TB CQI report -typedef struct NR_DL_bler_stats { - frame_t last_frame_slot; +typedef struct NR_bler_stats { + frame_t last_frame; float bler; - float rd2_bler; uint8_t mcs; - uint64_t dlsch_rounds[8]; -} NR_DL_bler_stats_t; + uint64_t rounds[8]; +} NR_bler_stats_t; // /*! As per spec 38.214 section 5.2.1.4.2 @@ -479,6 +491,7 @@ struct CRI_RI_LI_PMI_CQI { uint8_t wb_cqi_1tb; uint8_t wb_cqi_2tb; uint8_t cqi_table; + uint8_t csi_report_id; }; typedef struct CRI_SSB_RSRP { @@ -522,6 +535,9 @@ typedef struct nr_csi_report { uint8_t nb_of_csi_ssb_report; L1_RSRP_bitlen_t CSI_report_bitlen; CSI_Meas_bitlen_t csi_meas_bitlen; + int codebook_mode; + int N1; + int N2; } nr_csi_report_t; /*! As per the spec 38.212 and table: 6.3.1.1.2-12 in a single UCI sequence we can have multiple CSI_report @@ -554,6 +570,12 @@ typedef struct { NR_BWP_Downlink_t *active_bwp; /// the currently active BWP in UL NR_BWP_Uplink_t *active_ubwp; + + /// the next active BWP ID in DL + NR_BWP_Id_t next_dl_bwp_id; + /// the next active BWP ID in UL + NR_BWP_Id_t next_ul_bwp_id; + /// CCE index and aggregation, should be coherent with cce_list NR_SearchSpace_t *search_space; NR_ControlResourceSet_t *coreset; @@ -591,20 +613,23 @@ typedef struct { NR_pdsch_semi_static_t pdsch_semi_static; /// Sched PDSCH: scheduling decisions, copied into HARQ and cleared every TTI NR_sched_pdsch_t sched_pdsch; + /// UE-estimated maximum MCS (from CSI-RS) + uint8_t dl_max_mcs; + /// For UL synchronization: store last UL scheduling grant frame_t last_ul_frame; sub_frame_t last_ul_slot; /// total amount of data awaiting for this UE uint32_t num_total_bytes; + uint16_t dl_pdus_total; /// per-LC status data - mac_rlc_status_resp_t rlc_status[MAX_NUM_LCID]; + mac_rlc_status_resp_t rlc_status[NR_MAX_NUM_LCID]; /// Estimation of HARQ from BLER - NR_DL_bler_stats_t dl_bler_stats; + NR_bler_stats_t dl_bler_stats; + NR_bler_stats_t ul_bler_stats; - int lcid_mask; - int lcid_to_schedule; uint16_t ta_frame; int16_t ta_update; bool ta_apply; @@ -620,9 +645,7 @@ typedef struct { int ul_failure; struct CSI_Report CSI_report; bool SR; - bool update_pdsch_ps; - bool update_pusch_ps; - bool set_mcs; + bool set_pmi; /// information about every HARQ process NR_UE_harq_t harq_processes[NR_MAX_NB_HARQ_PROCESSES]; /// HARQ processes that are free @@ -640,6 +663,13 @@ typedef struct { /// UL HARQ processes that await retransmission NR_list_t retrans_ul_harq; NR_UE_mac_ce_ctrl_t UE_mac_ce_ctrl;// MAC CE related information + /// number of active DL LCs + uint8_t dl_lc_num; + /// order in which DLSCH scheduler should allocate LCs + uint8_t dl_lc_ids[NR_MAX_NUM_LCID]; + + /// Timer for RRC processing procedures + uint32_t rrc_processing_timer; } NR_UE_sched_ctrl_t; typedef struct { @@ -647,45 +677,61 @@ typedef struct { uicc_t *uicc; } NRUEcontext_t; -typedef struct { - uint64_t lc_bytes_tx[64]; - uint64_t lc_bytes_rx[64]; - uint64_t dlsch_rounds[8]; - uint64_t dlsch_errors; - uint64_t dlsch_total_bytes; - int dlsch_current_bytes; - uint64_t ulsch_rounds[8]; - uint64_t ulsch_errors; +typedef struct NR_mac_dir_stats { + uint64_t lc_bytes[64]; + uint64_t rounds[8]; + uint64_t errors; + uint64_t total_bytes; + uint32_t current_bytes; +} NR_mac_dir_stats_t; + +typedef struct NR_mac_stats { + NR_mac_dir_stats_t dl; + NR_mac_dir_stats_t ul; uint32_t ulsch_DTX; uint64_t ulsch_total_bytes_scheduled; - uint64_t ulsch_total_bytes_rx; - int ulsch_current_bytes; uint32_t pucch0_DTX; int cumul_rsrp; uint8_t num_rsrp_meas; } NR_mac_stats_t; +typedef struct NR_bler_options { + double upper; + double lower; + uint8_t max_mcs; +} NR_bler_options_t; /*! \brief UE list used by gNB to order UEs/CC for scheduling*/ #define MAX_CSI_REPORTCONFIG 48 typedef struct { + rnti_t rnti; /// scheduling control info - nr_csi_report_t csi_report_template[MAX_MOBILES_PER_GNB][MAX_CSI_REPORTCONFIG]; - NR_UE_sched_ctrl_t UE_sched_ctrl[MAX_MOBILES_PER_GNB]; - NR_mac_stats_t mac_stats[MAX_MOBILES_PER_GNB]; - NR_list_t list; - int num_UEs; - bool active[MAX_MOBILES_PER_GNB]; - rnti_t rnti[MAX_MOBILES_PER_GNB]; - NR_CellGroupConfig_t *CellGroup[MAX_MOBILES_PER_GNB]; + nr_csi_report_t csi_report_template[MAX_CSI_REPORTCONFIG]; + NR_UE_sched_ctrl_t UE_sched_ctrl; + NR_mac_stats_t mac_stats; + NR_CellGroupConfig_t *CellGroup; /// CCE indexing - int m[MAX_MOBILES_PER_GNB]; + int m; // UE selected beam index - uint8_t UE_beam_index[MAX_MOBILES_PER_GNB]; - bool Msg4_ACKed[MAX_MOBILES_PER_GNB]; - + uint8_t UE_beam_index; + bool Msg4_ACKed; + /// Sched CSI-RS: scheduling decisions + NR_gNB_UCI_STATS_t uci_statS; + float ul_thr_ue; + float dl_thr_ue; + int layers; } NR_UE_info_t; +typedef struct { + /// scheduling control info + // last element always NULL + pthread_mutex_t mutex; + NR_UE_info_t *list[MAX_MOBILES_PER_GNB+1]; + bool sched_csirs; +} NR_UEs_t; + +#define UE_iterator(BaSe, VaR) NR_UE_info_t ** VaR##pptr=BaSe, *VaR; while ((VaR=*(VaR##pptr++))) + typedef void (*nr_pp_impl_dl)(module_id_t mod_id, frame_t frame, sub_frame_t slot); @@ -724,7 +770,7 @@ typedef struct gNB_MAC_INST_s { /// current PDU index (BCH,DLSCH) uint16_t pdu_index[NFAPI_CC_MAX]; int num_ulprbbl; - int ulprbbl[275]; + uint16_t ulprbbl[275]; /// NFAPI Config Request Structure nfapi_nr_config_request_scf_t config[NFAPI_CC_MAX]; /// NFAPI DL Config Request Structure @@ -743,8 +789,8 @@ typedef struct gNB_MAC_INST_s { nfapi_nr_ul_dci_request_t UL_dci_req[NFAPI_CC_MAX]; /// NFAPI DL PDU structure nfapi_nr_tx_data_request_t TX_req[NFAPI_CC_MAX]; - int pdcch_cand[MAX_NUM_CORESET]; - NR_UE_info_t UE_info; + + NR_UEs_t UE_info; /// UL handle uint32_t ul_handle; @@ -780,15 +826,8 @@ typedef struct gNB_MAC_INST_s { /// bitmap of DLSCH slots, can hold up to 160 slots uint64_t dlsch_slot_bitmap[3]; - /// Lookup for preferred time domain allocation for BWP, in DL, slots - /// dynamically allocated - int *preferred_dl_tda[MAX_NUM_BWP]; /// bitmap of ULSCH slots, can hold up to 160 slots uint64_t ulsch_slot_bitmap[3]; - /// Lookup for preferred time domain allocation for UL BWP, dynamically - /// allocated. The index refers to the DL slot, and the indicated TDA's k2 - /// points to the right UL slot - int *preferred_ul_tda[MAX_NUM_BWP]; /// maximum number of slots before a UE will be scheduled ULSCH automatically uint32_t ulsch_max_frame_inactivity; @@ -803,11 +842,14 @@ typedef struct gNB_MAC_INST_s { uint16_t cset0_bwp_size; NR_Type0_PDCCH_CSS_config_t type0_PDCCH_CSS_config[64]; + int xp_pdsch_antenna_ports; + bool first_MIB; - double dl_bler_target_upper; - double dl_bler_target_lower; - double dl_rd2_bler_threshold; - uint8_t dl_max_mcs; + NR_bler_options_t dl_bler; + NR_bler_options_t ul_bler; + uint8_t harq_round_max; + uint8_t min_grant_prb; + uint8_t min_grant_mcs; } gNB_MAC_INST; #endif /*__LAYER2_NR_MAC_GNB_H__ */ diff --git a/openair2/LAYER2/nr_pdcp/nr_pdcp_entity.c b/openair2/LAYER2/nr_pdcp/nr_pdcp_entity.c index 62aa101a50..7e1ddb62bd 100644 --- a/openair2/LAYER2/nr_pdcp/nr_pdcp_entity.c +++ b/openair2/LAYER2/nr_pdcp/nr_pdcp_entity.c @@ -51,7 +51,12 @@ static void nr_pdcp_entity_recv_pdu(nr_pdcp_entity_t *entity, if (entity->type != NR_PDCP_SRB && !(buffer[0] & 0x80)) { LOG_E(PDCP, "%s:%d:%s: fatal\n", __FILE__, __LINE__, __FUNCTION__); - exit(1); + /* TODO: This is something of a hack. The most significant bit + in buffer[0] should be 1 if the packet is a data packet. We are + processing malformed data packets if the most significant bit + is 0. Rather than exit(1), this hack allows us to continue for now. + We need to investigate why this hack is neccessary. */ + buffer[0] |= 128; } if (entity->sn_size == 12) { @@ -108,7 +113,7 @@ static void nr_pdcp_entity_recv_pdu(nr_pdcp_entity_t *entity, if (rcvd_count < entity->rx_deliv || nr_pdcp_sdu_in_list(entity->rx_list, rcvd_count)) { - LOG_W(PDCP, "discard NR PDU rcvd_count=%d\n", rcvd_count); + LOG_W(PDCP, "discard NR PDU rcvd_count=%d, entity->rx_deliv %d,sdu_in_list %d\n", rcvd_count,entity->rx_deliv,nr_pdcp_sdu_in_list(entity->rx_list,rcvd_count)); return; } @@ -368,8 +373,8 @@ nr_pdcp_entity_t *new_nr_pdcp_entity( ret->set_security = nr_pdcp_entity_set_security; ret->set_time = nr_pdcp_entity_set_time; - ret->delete = nr_pdcp_entity_delete; - + ret->delete_entity = nr_pdcp_entity_delete; + ret->deliver_sdu = deliver_sdu; ret->deliver_sdu_data = deliver_sdu_data; diff --git a/openair2/LAYER2/nr_pdcp/nr_pdcp_entity.h b/openair2/LAYER2/nr_pdcp/nr_pdcp_entity.h index fbcc2b96cd..49e9c4142b 100644 --- a/openair2/LAYER2/nr_pdcp/nr_pdcp_entity.h +++ b/openair2/LAYER2/nr_pdcp/nr_pdcp_entity.h @@ -39,7 +39,7 @@ typedef struct nr_pdcp_entity_t { void (*recv_pdu)(struct nr_pdcp_entity_t *entity, char *buffer, int size); void (*recv_sdu)(struct nr_pdcp_entity_t *entity, char *buffer, int size, int sdu_id); - void (*delete)(struct nr_pdcp_entity_t *entity); + void (*delete_entity)(struct nr_pdcp_entity_t *entity); /* set_security: pass -1 to integrity_algorithm / ciphering_algorithm * to keep the current algorithm diff --git a/openair2/LAYER2/nr_pdcp/nr_pdcp_oai_api.c b/openair2/LAYER2/nr_pdcp/nr_pdcp_oai_api.c index 1f66400af1..ea4b7e80c7 100644 --- a/openair2/LAYER2/nr_pdcp/nr_pdcp_oai_api.c +++ b/openair2/LAYER2/nr_pdcp/nr_pdcp_oai_api.c @@ -36,7 +36,7 @@ #include "pdcp.h" #include "LAYER2/nr_rlc/nr_rlc_oai_api.h" #include -#include "openair2/SDAP/nr_sdap/nr_sdap_gnb.h" +#include "openair2/SDAP/nr_sdap/nr_sdap.h" #define TODO do { \ printf("%s:%d:%s: todo\n", __FILE__, __LINE__, __FUNCTION__); \ @@ -438,9 +438,13 @@ static void *enb_tun_read_thread(void *_) ctxt.rnti = rnti; - pdcp_data_req(&ctxt, SRB_FLAG_NO, rb_id, RLC_MUI_UNDEFINED, + uint8_t qfi = 7; + boolean_t rqi = 0; + int pdusession_id = 10; + + sdap_data_req(&ctxt, SRB_FLAG_NO, rb_id, RLC_MUI_UNDEFINED, RLC_SDU_CONFIRM_NO, len, (unsigned char *)rx_buf, - PDCP_TRANSMISSION_MODE_DATA, NULL, NULL); + PDCP_TRANSMISSION_MODE_DATA, NULL, NULL, qfi, rqi, pdusession_id); } return NULL; @@ -481,9 +485,13 @@ static void *ue_tun_read_thread(void *_) ctxt.rnti = rnti; - pdcp_data_req(&ctxt, SRB_FLAG_NO, rb_id, RLC_MUI_UNDEFINED, + boolean_t dc = SDAP_HDR_UL_DATA_PDU; + uint8_t qfi = 7; + int pdusession_id = 10; + + sdap_data_req(&ctxt, SRB_FLAG_NO, rb_id, RLC_MUI_UNDEFINED, RLC_SDU_CONFIRM_NO, len, (unsigned char *)rx_buf, - PDCP_TRANSMISSION_MODE_DATA, NULL, NULL); + PDCP_TRANSMISSION_MODE_DATA, NULL, NULL, qfi, dc, pdusession_id); } return NULL; @@ -607,28 +615,20 @@ uint64_t nr_pdcp_module_init(uint64_t _pdcp_optmask, int id) static void deliver_sdu_drb(void *_ue, nr_pdcp_entity_t *entity, char *buf, int size) { - extern int nas_sock_fd[]; - int len; nr_pdcp_ue_t *ue = _ue; - MessageDef *message_p; - uint8_t *gtpu_buffer_p; int rb_id; int i; if (IS_SOFTMODEM_NOS1 || UE_NAS_USE_TUN) { - LOG_D(PDCP, "IP packet received, to be sent to TUN interface"); - - if(entity->has_sdapDLheader){ - size -= SDAP_HDR_LENGTH; - len = write(nas_sock_fd[0], &buf[SDAP_HDR_LENGTH], size); - } else { - len = write(nas_sock_fd[0], buf, size); - } - - if (len != size) { - LOG_E(PDCP, "%s:%d:%s: fatal error %d: %s\n", __FILE__, __LINE__, __FUNCTION__, errno, strerror(errno)); - } - + LOG_D(PDCP, "IP packet received with size %d, to be sent to SDAP interface, UE rnti: %d\n", size, ue->rnti); + sdap_data_ind(entity->rb_id, + entity->is_gnb, + entity->has_sdap, + entity->has_sdapULheader, + entity->pdusession_id, + ue->rnti, + buf, + size); } else{ for (i = 0; i < 5; i++) { @@ -644,31 +644,16 @@ static void deliver_sdu_drb(void *_ue, nr_pdcp_entity_t *entity, rb_found: { - int offset=0; - if (entity->has_sdap == 1 && entity->has_sdapULheader == 1) - offset = 1; // this is the offset of the SDAP header in bytes - - message_p = itti_alloc_new_message_sized(TASK_PDCP_ENB, 0, - GTPV1U_GNB_TUNNEL_DATA_REQ, - sizeof(gtpv1u_gnb_tunnel_data_req_t) + size - + GTPU_HEADER_OVERHEAD_MAX - offset); - AssertFatal(message_p != NULL, "OUT OF MEMORY"); - - gtpv1u_gnb_tunnel_data_req_t *req=>PV1U_GNB_TUNNEL_DATA_REQ(message_p); - gtpu_buffer_p = (uint8_t*)(req+1); - memcpy(gtpu_buffer_p+GTPU_HEADER_OVERHEAD_MAX, buf+offset, size-offset); - req->buffer = gtpu_buffer_p; - req->length = size-offset; - req->offset = GTPU_HEADER_OVERHEAD_MAX; - req->rnti = ue->rnti; - req->pdusession_id = entity->pdusession_id; - if (offset==1) { - LOG_I(PDCP, "%s() (drb %d) SDAP header %2x\n",__func__, rb_id, buf[0]); - sdap_gnb_ul_header_handler(buf[0]); // Handler for the UL gNB SDAP Header - } - LOG_D(PDCP, "%s() (drb %d) sending message to gtp size %d\n", __func__, rb_id, size-offset); - itti_send_msg_to_task(TASK_GTPV1_U, INSTANCE_DEFAULT, message_p); - } + LOG_D(PDCP, "%s() (drb %d) sending message to SDAP size %d\n", __func__, rb_id, size); + sdap_data_ind(rb_id, + ue->drb[rb_id-1]->is_gnb, + ue->drb[rb_id-1]->has_sdap, + ue->drb[rb_id-1]->has_sdapULheader, + ue->drb[rb_id-1]->pdusession_id, + ue->rnti, + buf, + size); + } } } @@ -718,7 +703,7 @@ rb_found: req->offset = GTPU_HEADER_OVERHEAD_MAX; req->rnti = ue->rnti; req->pdusession_id = rb_id; - LOG_D(PDCP, "%s() (drb %d) sending message to gtp size %d\n", + LOG_I(PDCP, "%s() (drb %d) sending message to gtp size %d\n", __func__, rb_id, size); extern instance_t CUuniqInstance; itti_send_msg_to_task(TASK_GTPV1_U, CUuniqInstance, message_p); @@ -726,7 +711,6 @@ rb_found: memblock = get_free_mem_block(size, __FUNCTION__); memcpy(memblock->data, buf, size); - LOG_D(PDCP, "%s(): (srb %d) calling rlc_data_req size %d\n", __func__, rb_id, size); //for (i = 0; i < size; i++) printf(" %2.2x", (unsigned char)memblock->data[i]); //printf("\n"); @@ -967,6 +951,9 @@ static void add_drb_am(int is_gnb, int rnti, struct NR_DRB_ToAddMod *s, int has_sdap = 0; int has_sdapULheader=0; int has_sdapDLheader=0; + boolean_t is_sdap_DefaultDRB = false; + NR_QFI_t *mappedQFIs2Add = NULL; + uint8_t mappedQFIs2AddCount=0; if (s->cnAssociation->present == NR_DRB_ToAddMod__cnAssociation_PR_eps_BearerIdentity) pdusession_id = s->cnAssociation->choice.eps_BearerIdentity; else { @@ -975,9 +962,13 @@ static void add_drb_am(int is_gnb, int rnti, struct NR_DRB_ToAddMod *s, exit(-1); } pdusession_id = s->cnAssociation->choice.sdap_Config->pdu_Session; - has_sdap = 1; has_sdapULheader = s->cnAssociation->choice.sdap_Config->sdap_HeaderUL == NR_SDAP_Config__sdap_HeaderUL_present ? 1 : 0; has_sdapDLheader = s->cnAssociation->choice.sdap_Config->sdap_HeaderDL == NR_SDAP_Config__sdap_HeaderDL_present ? 1 : 0; + has_sdap = has_sdapULheader | has_sdapDLheader; + is_sdap_DefaultDRB = s->cnAssociation->choice.sdap_Config->defaultDRB == true ? 1 : 0; + mappedQFIs2Add = (NR_QFI_t*)s->cnAssociation->choice.sdap_Config->mappedQoS_FlowsToAdd->list.array[0]; + mappedQFIs2AddCount = s->cnAssociation->choice.sdap_Config->mappedQoS_FlowsToAdd->list.count; + LOG_D(SDAP, "Captured mappedQoS_FlowsToAdd from RRC: %ld \n", *mappedQFIs2Add); } /* TODO(?): accept different UL and DL SN sizes? */ if (sn_size_ul != sn_size_dl) { @@ -986,11 +977,6 @@ static void add_drb_am(int is_gnb, int rnti, struct NR_DRB_ToAddMod *s, exit(1); } - if (drb_id != 1) { - LOG_E(PDCP, "%s:%d:%s: fatal, bad drb id %d\n", - __FILE__, __LINE__, __FUNCTION__, drb_id); - exit(1); - } nr_pdcp_manager_lock(nr_pdcp_ue_manager); ue = nr_pdcp_manager_get_ue(nr_pdcp_ue_manager, rnti); @@ -1009,6 +995,15 @@ static void add_drb_am(int is_gnb, int rnti, struct NR_DRB_ToAddMod *s, nr_pdcp_ue_add_drb_pdcp_entity(ue, drb_id, pdcp_drb); LOG_D(PDCP, "%s:%d:%s: added drb %d to ue rnti %x\n", __FILE__, __LINE__, __FUNCTION__, drb_id, rnti); + + new_nr_sdap_entity(has_sdap, + rnti, + pdusession_id, + is_sdap_DefaultDRB, + drb_id, + mappedQFIs2Add, + mappedQFIs2AddCount); + LOG_D(SDAP, "Added SDAP entity to ue rnti %x with pdusession_id %d\n", rnti, pdusession_id); } nr_pdcp_manager_unlock(nr_pdcp_ue_manager); } @@ -1140,7 +1135,7 @@ void nr_DRB_preconfiguration(uint16_t crnti) NR_DRB_ToAddMod_t *drb_ToAddMod = calloc(1,sizeof(*drb_ToAddMod)); drb_ToAddMod->cnAssociation = calloc(1,sizeof(*drb_ToAddMod->cnAssociation)); drb_ToAddMod->cnAssociation->present = NR_DRB_ToAddMod__cnAssociation_PR_eps_BearerIdentity; - drb_ToAddMod->cnAssociation->choice.eps_BearerIdentity= 5; + drb_ToAddMod->cnAssociation->choice.eps_BearerIdentity= 10; drb_ToAddMod->drb_Identity = 1; drb_ToAddMod->reestablishPDCP = NULL; drb_ToAddMod->recoverPDCP = NULL; @@ -1149,9 +1144,9 @@ void nr_DRB_preconfiguration(uint16_t crnti) drb_ToAddMod->pdcp_Config->drb->discardTimer = calloc(1,sizeof(*drb_ToAddMod->pdcp_Config->drb->discardTimer)); *drb_ToAddMod->pdcp_Config->drb->discardTimer=NR_PDCP_Config__drb__discardTimer_infinity; drb_ToAddMod->pdcp_Config->drb->pdcp_SN_SizeUL = calloc(1,sizeof(*drb_ToAddMod->pdcp_Config->drb->pdcp_SN_SizeUL)); - *drb_ToAddMod->pdcp_Config->drb->pdcp_SN_SizeUL = NR_PDCP_Config__drb__pdcp_SN_SizeUL_len12bits; + *drb_ToAddMod->pdcp_Config->drb->pdcp_SN_SizeUL = NR_PDCP_Config__drb__pdcp_SN_SizeUL_len18bits; drb_ToAddMod->pdcp_Config->drb->pdcp_SN_SizeDL = calloc(1,sizeof(*drb_ToAddMod->pdcp_Config->drb->pdcp_SN_SizeDL)); - *drb_ToAddMod->pdcp_Config->drb->pdcp_SN_SizeDL = NR_PDCP_Config__drb__pdcp_SN_SizeDL_len12bits; + *drb_ToAddMod->pdcp_Config->drb->pdcp_SN_SizeDL = NR_PDCP_Config__drb__pdcp_SN_SizeDL_len18bits; drb_ToAddMod->pdcp_Config->drb->headerCompression.present = NR_PDCP_Config__drb__headerCompression_PR_notUsed; drb_ToAddMod->pdcp_Config->drb->headerCompression.choice.notUsed = 0; @@ -1181,7 +1176,8 @@ void nr_DRB_preconfiguration(uint16_t crnti) NR_RLC_BearerConfig_t *RLC_BearerConfig = calloc(1,sizeof(*RLC_BearerConfig)); nr_rlc_bearer_init(RLC_BearerConfig,NR_RLC_BearerConfig__servedRadioBearer_PR_drb_Identity); - nr_drb_config(RLC_BearerConfig->rlc_Config, NR_RLC_Config_PR_am); + nr_drb_config(RLC_BearerConfig->rlc_Config, NR_RLC_Config_PR_um_Bi_Directional); + //nr_drb_config(RLC_BearerConfig->rlc_Config, NR_RLC_Config_PR_am); nr_rlc_bearer_init_ul_spec(RLC_BearerConfig->mac_LogicalChannelConfig); Rlc_Bearer_ToAdd_list = calloc(1,sizeof(*Rlc_Bearer_ToAdd_list)); @@ -1449,3 +1445,10 @@ void nr_pdcp_tick(int frame, int subframe) nr_pdcp_wakeup_timer_thread(nr_pdcp_current_time); } } + +/* + * For the SDAP API + */ +nr_pdcp_ue_manager_t *nr_pdcp_sdap_get_ue_manager(){ + return nr_pdcp_ue_manager; +} diff --git a/openair2/LAYER2/nr_pdcp/nr_pdcp_ue_manager.c b/openair2/LAYER2/nr_pdcp/nr_pdcp_ue_manager.c index 160c5ebb22..1f21593c63 100644 --- a/openair2/LAYER2/nr_pdcp/nr_pdcp_ue_manager.c +++ b/openair2/LAYER2/nr_pdcp/nr_pdcp_ue_manager.c @@ -127,11 +127,11 @@ void nr_pdcp_manager_remove_ue(nr_pdcp_ue_manager_t *_m, int rnti) for (j = 0; j < 2; j++) if (ue->srb[j] != NULL) - ue->srb[j]->delete(ue->srb[j]); + ue->srb[j]->delete_entity(ue->srb[j]); for (j = 0; j < 5; j++) if (ue->drb[j] != NULL) - ue->drb[j]->delete(ue->drb[j]); + ue->drb[j]->delete_entity(ue->drb[j]); free(ue); diff --git a/openair2/LAYER2/nr_rlc/nr_rlc_entity_am.c b/openair2/LAYER2/nr_rlc/nr_rlc_entity_am.c index af8cb5715a..2382db267f 100644 --- a/openair2/LAYER2/nr_rlc/nr_rlc_entity_am.c +++ b/openair2/LAYER2/nr_rlc/nr_rlc_entity_am.c @@ -103,36 +103,6 @@ static int segment_already_received(nr_rlc_entity_am_t *entity, return size <= 0; } -static void consider_retransmission(nr_rlc_entity_am_t *entity, - nr_rlc_sdu_segment_t *cur, int update_retx) -{ - if (update_retx) - cur->sdu->retx_count++; - - /* let's report max RETX reached for all retx_count >= max_retx_threshold - * (specs say to report if retx_count == max_retx_threshold). - * Upper layers should react (radio link failure), so no big deal actually. - */ - if (update_retx && cur->sdu->retx_count >= entity->max_retx_threshold) { - entity->common.max_retx_reached(entity->common.max_retx_reached_data, - (nr_rlc_entity_t *)entity); - } - - /* let's put in retransmit list even if we are over max_retx_threshold. - * upper layers should deal with this condition, internally it's better - * for the RLC code to keep going with this segment (we only remove - * a segment that was ACKed) - */ - LOG_D(RLC, "RLC segment to be added at the ReTx list \n"); - nr_rlc_sdu_segment_list_append(&entity->retransmit_list, - &entity->retransmit_end, - cur); - - /* update buffer status */ - entity->common.bstatus.retx_size += compute_pdu_header_size(entity, cur) - + cur->size; -} - /* checks that all the bytes of the SDU sn have been received (but SDU * has not been already processed) */ @@ -315,81 +285,6 @@ static void reception_actions(nr_rlc_entity_am_t *entity, nr_rlc_pdu_t *pdu) } } -static void process_received_ack(nr_rlc_entity_am_t *entity, int ack_sn) -{ - nr_rlc_sdu_segment_t head; - nr_rlc_sdu_segment_t *cur; - nr_rlc_sdu_segment_t *prev; - unsigned char sn_set[32768]; /* used to dec retx_count only once per sdu */ - - memset(sn_set, 0, 32768); - -#define IS_SN_SET(b) (sn_set[(b)/8] & (1 << ((b) % 8))) -#define SET_SN(b) do { sn_set[(b)/8] |= (1 << ((b) % 8)); } while (0) - - /* put SDUs from wait and retransmit lists with SN < 'ack_sn' to ack_list */ - - /* process wait list */ - head.next = entity->wait_list; - prev = &head; - cur = entity->wait_list; - while (cur != NULL) { - if (sn_compare_tx(entity, cur->sdu->sn, ack_sn) < 0) { - /* remove from wait list */ - prev->next = cur->next; - /* put the PDU in the ack list */ - entity->ack_list = nr_rlc_sdu_segment_list_add(sn_compare_tx, entity, - entity->ack_list, cur); - entity->wait_end = prev; - cur = prev->next; - } else { - entity->wait_end = cur; - prev = cur; - cur = cur->next; - } - } - entity->wait_list = head.next; - if (entity->wait_list == NULL) - entity->wait_end = NULL; - - /* process retransmit list */ - head.next = entity->retransmit_list; - prev = &head; - cur = entity->retransmit_list; - while (cur != NULL) { - if (sn_compare_tx(entity, cur->sdu->sn, ack_sn) < 0) { - /* dec. retx_count in case we put this segment back in retransmit list - * in 'process_received_nack' - * do it only once per SDU - */ - if (!IS_SN_SET(cur->sdu->sn)) { - cur->sdu->retx_count--; - SET_SN(cur->sdu->sn); - } - /* remove from retransmit list */ - prev->next = cur->next; - /* update buffer status */ - entity->common.bstatus.retx_size -= compute_pdu_header_size(entity, cur) - + cur->size; - /* put the PDU in the ack list */ - entity->ack_list = nr_rlc_sdu_segment_list_add(sn_compare_tx, entity, - entity->ack_list, cur); - entity->retransmit_end = prev; - cur = prev->next; - } else { - entity->retransmit_end = cur; - prev = cur; - cur = cur->next; - } - } - entity->retransmit_list = head.next; - if (entity->retransmit_list == NULL) - entity->retransmit_end = NULL; - -#undef IS_BIT_SET -#undef SET_BIT -} - static int so_overlap(int s1, int e1, int s2, int e2) { if (s1 < s2) { @@ -402,136 +297,375 @@ static int so_overlap(int s1, int e1, int s2, int e2) return 0; } -static void process_nack_sn(nr_rlc_entity_am_t *entity, int nack_sn, - int so_start, int so_end, unsigned char *sn_set) -{ - /* put all SDU segments with SN == 'sn' and with an overlapping so start/end - * to the retransmit list - * source lists are ack list and wait list. - * Not sure if we should consider wait list, isn't the other end supposed - * to only NACK SNs lower than the ACK SN sent in the status PDU, in which - * case all potential SDU segments should all be in ack list when calling - * the current function? in doubt let's accept anything and thus process - * also wait list. - */ - nr_rlc_sdu_segment_t head; - nr_rlc_sdu_segment_t *cur; - nr_rlc_sdu_segment_t *prev; - -#define IS_SN_SET(b) (sn_set[(b)/8] & (1 << ((b) % 8))) -#define SET_SN(b) do { sn_set[(b)/8] |= (1 << ((b) % 8)); } while (0) - - /* check that tx_next_ack <= sn < tx_next */ - if (!(sn_compare_tx(entity, entity->tx_next_ack, nack_sn) <= 0 && - sn_compare_tx(entity, nack_sn, entity->tx_next) < 0)) - return; - - /* process wait list */ - head.next = entity->wait_list; - prev = &head; - cur = entity->wait_list; - while (cur != NULL) { - if (cur->sdu->sn == nack_sn && - so_overlap(so_start, so_end, cur->so, cur->so + cur->size - 1)) { - /* remove from wait list */ - prev->next = cur->next; - cur->next = NULL; - /* consider the SDU segment for retransmission */ - consider_retransmission(entity, cur, !IS_SN_SET(cur->sdu->sn)); - SET_SN(cur->sdu->sn); - entity->wait_end = prev; - cur = prev->next; - } else { - entity->wait_end = cur; - prev = cur; - cur = cur->next; - } - } - entity->wait_list = head.next; - if (entity->wait_list == NULL) - entity->wait_end = NULL; - - /* process ack list */ - head.next = entity->ack_list; - prev = &head; - cur = entity->ack_list; - while (cur != NULL) { - if (cur->sdu->sn == nack_sn && - so_overlap(so_start, so_end, cur->so, cur->so + cur->size - 1)) { - /* remove from ack list */ - prev->next = cur->next; - cur->next = NULL; - /* consider the SDU segment for retransmission */ - consider_retransmission(entity, cur, !IS_SN_SET(cur->sdu->sn)); - SET_SN(cur->sdu->sn); - cur = prev->next; - } else { - prev = cur; - cur = cur->next; - } - } - entity->ack_list = head.next; - -#undef IS_BIT_SET -#undef SET_BIT -} - -static void process_received_nack(nr_rlc_entity_am_t *entity, int nack_sn, - int so_start, int so_end, int range, - unsigned char *sn_set) +static void process_control_pdu(nr_rlc_entity_am_t *entity, + char *buffer, int size) { +#define R(d) do { if (nr_rlc_pdu_decoder_in_error(&d)) goto err; } while (0) + nr_rlc_pdu_decoder_t decoder; int i; + int cpt; + int ack_sn; + int nack_sn; + int e1; + int e2; + int e3; + int so_start; + int so_end; + int range; + int prev_nack_sn = -1; + int prev_so_start; + int prev_so_end; + int tx_next_ack; + nr_rlc_sdu_segment_t *cur_wait_list; + nr_rlc_sdu_segment_t *prev_wait_list; + nr_rlc_sdu_segment_t *end_wait_list = NULL; + nr_rlc_sdu_segment_t head_wait_list; + nr_rlc_sdu_segment_t *cur_retransmit_list; + nr_rlc_sdu_segment_t *new_retransmit_list; + nr_rlc_sdu_segment_t head_retransmit_list; - for (i = 0; i < range; i++) - process_nack_sn(entity, (nack_sn + i) % entity->sn_modulus, - i == 0 ? so_start : 0, - i == range - 1 ? so_end : -1, - sn_set); -} + head_wait_list.next = entity->wait_list; + cur_wait_list = entity->wait_list; + prev_wait_list = &head_wait_list; -static int sdu_segment_in_ack_list_full(nr_rlc_sdu_segment_t *sdu) -{ - int target_count = sdu->sdu->ref_count; - int actual_count = 0; - int sn = sdu->sdu->sn; + head_retransmit_list.next = NULL; + cur_retransmit_list = entity->retransmit_list; + new_retransmit_list = &head_retransmit_list; - while (sdu != NULL && sdu->sdu->sn == sn) { - actual_count++; - sdu = sdu->next; + nr_rlc_pdu_decoder_init(&decoder, buffer, size); + nr_rlc_pdu_decoder_get_bits(&decoder, 1); R(decoder); /* dc */ + + cpt = nr_rlc_pdu_decoder_get_bits(&decoder, 3); R(decoder); + if (cpt != 0) { + LOG_E(RLC, "%s:%d:%s: warning: discard PDU, CPT not 0 (%d)\n", + __FILE__, __LINE__, __FUNCTION__, cpt); + goto err; + } + ack_sn = nr_rlc_pdu_decoder_get_bits(&decoder, entity->sn_field_length); R(decoder); + e1 = nr_rlc_pdu_decoder_get_bits(&decoder, 1); R(decoder); + /* r bits */ + if (entity->sn_field_length == 18) { + nr_rlc_pdu_decoder_get_bits(&decoder, 1); R(decoder); + } else { + nr_rlc_pdu_decoder_get_bits(&decoder, 7); R(decoder); } - return actual_count == target_count; -} - -static void finalize_ack_nack_processing(nr_rlc_entity_am_t *entity) -{ - nr_rlc_sdu_segment_t *cur = entity->ack_list; - int sn; - - /* - send indication of successful delivery for all consecutive acked SDUs - * starting from tx_next_ack. Also free them. - * - update tx_next_ack to the next SN not acked yet + /* 38.322 5.3.3.3 says to stop t_poll_retransmit if a ACK or NACK is + * received for the SN 'poll_sn' - check ACK case (NACK done below) */ - /* todo: send indication of successful delivery as soon as possible as - * the specs say (38.322 5.2.3.1.1). As the code is, if we receive - * ack for SN+2 we won't indicate successful delivery before - * SN+1 has been indicated. + if (sn_compare_tx(entity, entity->poll_sn, ack_sn) < 0) + entity->t_poll_retransmit_start = 0; + + while (e1) { + nack_sn = nr_rlc_pdu_decoder_get_bits(&decoder, entity->sn_field_length); R(decoder); + e1 = nr_rlc_pdu_decoder_get_bits(&decoder, 1); R(decoder); + e2 = nr_rlc_pdu_decoder_get_bits(&decoder, 1); R(decoder); + e3 = nr_rlc_pdu_decoder_get_bits(&decoder, 1); R(decoder); + /* r bits */ + if (entity->sn_field_length == 18) { + nr_rlc_pdu_decoder_get_bits(&decoder, 3); R(decoder); + } else { + nr_rlc_pdu_decoder_get_bits(&decoder, 1); R(decoder); + } + if (e2) { + so_start = nr_rlc_pdu_decoder_get_bits(&decoder, 16); R(decoder); + so_end = nr_rlc_pdu_decoder_get_bits(&decoder, 16); R(decoder); + } else { + so_start = 0; + so_end = 0xffff; + } + if (e3) { + range = nr_rlc_pdu_decoder_get_bits(&decoder, 8); R(decoder); + } else { + range = 1; + } + /* special value 0xffff indicates 'all bytes to the end' */ + if (so_end == 0xffff) + so_end = -1; + + /* process nacks */ + for (i = 0; i < range; i++) { + int cur_nack_sn = (nack_sn + i) % entity->sn_modulus; + int cur_so_start = i == 0 ? so_start : 0; + int cur_so_end = i == range - 1 ? so_end : -1; + + /* check that current nack is > previous nack and <= ack + * if not then skip it and all following nacks, and + * do not touch t_poll_retransmit + */ + if (prev_nack_sn != -1) { + int cmp = sn_compare_tx(entity, cur_nack_sn, prev_nack_sn); + if (cmp < 0 + || (cmp == 0 + && (prev_so_end == -1 + || cur_so_start <= prev_so_end))) { + LOG_E(RLC, "%s:%d:%s: bad NACK (nack sn %d so start/end %d/%d, previous nack sn %d so start/end %d/%d), skip it and all following NACKs\n", + __FILE__, __LINE__, __FUNCTION__, + cur_nack_sn, cur_so_start, cur_so_end, + prev_nack_sn, prev_so_start, prev_so_end); + goto nacks_done; + } + } + if (sn_compare_tx(entity, cur_nack_sn, ack_sn) > 0) { + LOG_E(RLC, "%s:%d:%s: bad NACK (nack %d ack %d), skip it and all following NACKs\n", + __FILE__, __LINE__, __FUNCTION__, + cur_nack_sn, ack_sn); + goto nacks_done; + } + +process_next_pdu: + /* process smallest SN either from wait_list or retransmit list */ + if (cur_wait_list == NULL && cur_retransmit_list == NULL) + goto lists_over; + if (cur_wait_list == NULL) + goto process_retransmit_list_head; + if (cur_retransmit_list == NULL) + goto process_wait_list_head; + if (cur_wait_list->sdu->sn < cur_retransmit_list->sdu->sn + || (cur_wait_list->sdu->sn == cur_retransmit_list->sdu->sn && + cur_wait_list->so < cur_retransmit_list->so)) + goto process_wait_list_head; + goto process_retransmit_list_head; + +process_wait_list_head: + /* if nack overlaps with current segment, put it in retransmit list */ + if (cur_wait_list->sdu->sn == cur_nack_sn + && so_overlap(cur_so_start, cur_so_end, + cur_wait_list->so, + cur_wait_list->so + cur_wait_list->size - 1)) { + prev_wait_list->next = cur_wait_list->next; + if (cur_wait_list == entity->wait_end) + end_wait_list = prev_wait_list; + cur_wait_list->next = NULL; + new_retransmit_list->next = cur_wait_list; + new_retransmit_list = cur_wait_list; + /* increase retx count. Don't care about segmentation, so maybe we + * increase too much. + */ + cur_wait_list->sdu->retx_count++; + /* report max RETX reached for all retx_count >= max_retx_threshold + * (specs say to report if retx_count == max_retx_threshold). + * Upper layers should react (radio link failure), so no big deal. + * We deal with segmentation by requiring + * retx_count >= max_retx_threshold * number of segments. + * We may report max RETX reached too late/early. To be refined if + * this is a problem. + */ + if (cur_wait_list->sdu->retx_count + >= entity->max_retx_threshold * cur_wait_list->sdu->ref_count) + entity->common.max_retx_reached(entity->common.max_retx_reached_data, + (nr_rlc_entity_t *)entity); + /* update buffer status */ + entity->common.bstatus.retx_size += compute_pdu_header_size(entity, cur_wait_list) + + cur_wait_list->size; + /* and go process the next pdu, still for the current nack */ + cur_wait_list = prev_wait_list->next; + goto process_next_pdu; + } + + /* if current segment SN > current NACK, we can't classify it yet */ + if (sn_compare_tx(entity, cur_wait_list->sdu->sn, cur_nack_sn) > 0 + || (cur_wait_list->sdu->sn == cur_nack_sn + && cur_wait_list->so > cur_so_start)) + goto done_nack; + + /* if current segment is acked, free it, indicate successful delivery + * if fully acked + */ + if (sn_compare_tx(entity, cur_wait_list->sdu->sn, ack_sn) < 0) { + nr_rlc_sdu_segment_t *cur = cur_wait_list; + int upper_layer_id = cur->sdu->upper_layer_id; + int sdu_size = cur->sdu->size; + cur_wait_list = cur_wait_list->next; + prev_wait_list->next = cur_wait_list; + if (cur_wait_list == entity->wait_end) + end_wait_list = prev_wait_list; + if (nr_rlc_free_sdu_segment(cur)) { + entity->tx_size -= sdu_size; + entity->common.sdu_successful_delivery( + entity->common.sdu_successful_delivery_data, + (nr_rlc_entity_t *)entity, upper_layer_id); + } + goto process_next_pdu; + } + + /* if current segment SN > ack_sn, we're done with this list */ + if (sn_compare_tx(entity, cur_wait_list->sdu->sn, ack_sn) > 0) { + cur_wait_list = NULL; + goto process_next_pdu; + } + + /* current segment SN == ack_sn, skip this segment and move to the next. + * Not sure if correct, can we get a nack_sn == ack_sn? 38.322 5.3.4 says + * "set the ACK_SN to the SN of the next not received RLC SDU which is + * not indicated as missing in the resulting STATUS PDU." Is it okay to + * receive some NACK for a given SN and an ACK == this SN? I can see a + * case where it's possible (only parts of an SN were received and the + * TB is too small to report the several NACKs for this SN, then we + * can't set ACK = SN+1 but in this case, shouldn't we skip sending + * NACKs for this SN and only send ACK = SN? our current implementation + * does send both NACKs and ACK, see function generate_status()). + */ + prev_wait_list = cur_wait_list; + cur_wait_list = cur_wait_list->next; + goto process_next_pdu; + +process_retransmit_list_head: + /* if nack overlaps with current segment, leave it in retransmit list */ + if (cur_retransmit_list->sdu->sn == cur_nack_sn + && so_overlap(cur_so_start, cur_so_end, + cur_retransmit_list->so, + cur_retransmit_list->so + cur_retransmit_list->size - 1)) { + new_retransmit_list->next = cur_retransmit_list; + cur_retransmit_list = cur_retransmit_list->next; + new_retransmit_list = new_retransmit_list->next; + new_retransmit_list->next = NULL; + /* go process the next pdu, still for the current nack */ + goto process_next_pdu; + } + + /* if current segment SN > current NACK, we can't classify it yet */ + if (sn_compare_tx(entity, cur_retransmit_list->sdu->sn, cur_nack_sn) > 0 + || (cur_retransmit_list->sdu->sn == cur_nack_sn + && cur_retransmit_list->so > cur_so_start)) + goto done_nack; + + /* if current segment is acked, free it, indicate successful delivery + * if fully acked + */ + if (sn_compare_tx(entity, cur_retransmit_list->sdu->sn, ack_sn) < 0) { + nr_rlc_sdu_segment_t *cur = cur_retransmit_list; + int upper_layer_id = cur->sdu->upper_layer_id; + int sdu_size = cur->sdu->size; + cur_retransmit_list = cur_retransmit_list->next; + /* update buffer status */ + entity->common.bstatus.retx_size -= compute_pdu_header_size(entity, cur) + + cur->size; + if (nr_rlc_free_sdu_segment(cur)) { + entity->tx_size -= sdu_size; + entity->common.sdu_successful_delivery( + entity->common.sdu_successful_delivery_data, + (nr_rlc_entity_t *)entity, upper_layer_id); + } + goto process_next_pdu; + } + + /* current segment SN >= ack_sn + * if the wait list is empty, then put the remaining retransmit list at + * the end of the new retransmit list (just a speedup) + * if not, put only this segment + */ + if (cur_wait_list == NULL) { + new_retransmit_list->next = cur_retransmit_list; + cur_retransmit_list = NULL; + goto lists_over; + } + new_retransmit_list->next = cur_retransmit_list; + cur_retransmit_list = cur_retransmit_list->next; + new_retransmit_list = new_retransmit_list->next; + new_retransmit_list->next = NULL; + goto process_next_pdu; + +done_nack: + prev_nack_sn = cur_nack_sn; + prev_so_start = cur_so_start; + prev_so_end = cur_so_end; + } /* for (i = 0; i < range; i++) */ + +lists_over: + /* 38.322 5.3.3.3 says to stop t_poll_retransmit if a ACK or NACK is + * received for the SN 'poll_sn' - check NACK case (ACK done above) + */ + if (sn_compare_tx(entity, nack_sn, entity->poll_sn) <= 0 && + sn_compare_tx(entity, entity->poll_sn, (nack_sn + range) % entity->sn_modulus) < 0) + entity->t_poll_retransmit_start = 0; + } /* while (e1) */ + +nacks_done: + /* nacks done, finish with ack */ + /* we may report successful delivery out of order, if it's a problem + * then we can have a single loop and deal with the smallest sn of + * the current head of wait list and the current head of retransmit list. + * (It's simpler to process those two lists the one after the other.) */ - while (cur != NULL && cur->sdu->sn == entity->tx_next_ack && - sdu_segment_in_ack_list_full(cur)) { - entity->tx_size -= cur->sdu->size; - sn = cur->sdu->sn; - entity->common.sdu_successful_delivery( - entity->common.sdu_successful_delivery_data, - (nr_rlc_entity_t *)entity, cur->sdu->upper_layer_id); - while (cur != NULL && cur->sdu->sn == sn) { - nr_rlc_sdu_segment_t *s = cur; - cur = cur->next; - nr_rlc_free_sdu_segment(s); + /* deal with wait list */ + while (cur_wait_list != NULL + && sn_compare_tx(entity, cur_wait_list->sdu->sn, ack_sn) < 0) { + /* current segment is acked, free it, indicate successful delivery + * if fully acked + */ + nr_rlc_sdu_segment_t *cur = cur_wait_list; + int upper_layer_id = cur->sdu->upper_layer_id; + int sdu_size = cur->sdu->size; + prev_wait_list->next = cur_wait_list->next; + if (cur_wait_list == entity->wait_end) + end_wait_list = prev_wait_list; + cur_wait_list = cur_wait_list->next; + if (nr_rlc_free_sdu_segment(cur)) { + entity->tx_size -= sdu_size; + entity->common.sdu_successful_delivery( + entity->common.sdu_successful_delivery_data, + (nr_rlc_entity_t *)entity, upper_layer_id); } - entity->ack_list = cur; - entity->tx_next_ack = (entity->tx_next_ack + 1) % entity->sn_modulus; } + /* deal with retransmit list */ + while (cur_retransmit_list != NULL + && sn_compare_tx(entity, cur_retransmit_list->sdu->sn, ack_sn) < 0) { + /* current segment is acked, free it, indicate successful delivery + * if fully acked + */ + nr_rlc_sdu_segment_t *cur = cur_retransmit_list; + int upper_layer_id = cur->sdu->upper_layer_id; + int sdu_size = cur->sdu->size; + cur_retransmit_list = cur_retransmit_list->next; + /* update buffer status */ + entity->common.bstatus.retx_size -= compute_pdu_header_size(entity, cur) + + cur->size; + if (nr_rlc_free_sdu_segment(cur)) { + entity->tx_size -= sdu_size; + entity->common.sdu_successful_delivery( + entity->common.sdu_successful_delivery_data, + (nr_rlc_entity_t *)entity, upper_layer_id); + } + } + + new_retransmit_list->next = cur_retransmit_list; + + entity->wait_list = head_wait_list.next; + entity->retransmit_list = head_retransmit_list.next; + + if (end_wait_list != NULL) { + if (end_wait_list == &head_wait_list) + entity->wait_end = NULL; + else + entity->wait_end = end_wait_list; + } + + /* update tx_next_ack */ + /* 38.322 5.2.3.1.1 says "set TX_Next_Ack equal to the SN of the RLC SDU + * with the smallest SN, whose SN falls within the range + * TX_Next_Ack <= SN <= TX_Next and for which a positive acknowledgment + * has not been received yet. + */ + /* let's start from highest possible value and go down as needed */ + tx_next_ack = entity->tx_next; + if (entity->wait_list != NULL + && sn_compare_tx(entity, entity->wait_list->sdu->sn, tx_next_ack) < 0) + tx_next_ack = entity->wait_list->sdu->sn; + if (entity->retransmit_list != NULL + && sn_compare_tx(entity, entity->retransmit_list->sdu->sn, tx_next_ack) < 0) + tx_next_ack = entity->retransmit_list->sdu->sn; + if (sn_compare_tx(entity, ack_sn, tx_next_ack) < 0) + tx_next_ack = ack_sn; + entity->tx_next_ack = tx_next_ack; + + return; + +err: + LOG_E(RLC, "%s:%d:%s: error decoding PDU, NR RLC entity in inconsistent state\n", + __FILE__, __LINE__, __FUNCTION__); + +#undef R } void nr_rlc_entity_am_recv_pdu(nr_rlc_entity_t *_entity, @@ -540,7 +674,6 @@ void nr_rlc_entity_am_recv_pdu(nr_rlc_entity_t *_entity, #define R(d) do { if (nr_rlc_pdu_decoder_in_error(&d)) goto err; } while (0) nr_rlc_entity_am_t *entity = (nr_rlc_entity_am_t *)_entity; nr_rlc_pdu_decoder_t decoder; - nr_rlc_pdu_decoder_t control_decoder; nr_rlc_pdu_t *pdu; int dc; int p = 0; @@ -551,23 +684,11 @@ void nr_rlc_entity_am_recv_pdu(nr_rlc_entity_t *_entity, int is_first; int is_last; - int cpt; - int e1; - int e2; - int e3; - int ack_sn; - int nack_sn; - int so_start; - int so_end; - int range; - int control_e1; - int control_e2; - int control_e3; - unsigned char sn_set[32768]; /* used to dec retx_count only once per sdu */ - nr_rlc_pdu_decoder_init(&decoder, buffer, size); dc = nr_rlc_pdu_decoder_get_bits(&decoder, 1); R(decoder); - if (dc == 0) goto control; + + if (dc == 0) + return process_control_pdu(entity, buffer, size); /* data PDU */ p = nr_rlc_pdu_decoder_get_bits(&decoder, 1); R(decoder); @@ -596,20 +717,20 @@ void nr_rlc_entity_am_recv_pdu(nr_rlc_entity_t *_entity, /* dicard PDU if no data */ if (data_size <= 0) { - LOG_W(RLC, "%s:%d:%s: warning: discard PDU, no data\n", + LOG_D(RLC, "%s:%d:%s: warning: discard PDU, no data\n", __FILE__, __LINE__, __FUNCTION__); goto discard; } /* dicard PDU if rx buffer is full */ if (entity->rx_size + data_size > entity->rx_maxsize) { - LOG_W(RLC, "%s:%d:%s: warning: discard PDU, RX buffer full\n", + LOG_D(RLC, "%s:%d:%s: warning: discard PDU, RX buffer full\n", __FILE__, __LINE__, __FUNCTION__); goto discard; } if (!sn_in_recv_window(entity, sn)) { - LOG_W(RLC, "%s:%d:%s: warning: discard PDU, sn out of window (sn %d rx_next %d)\n", + LOG_D(RLC, "%s:%d:%s: warning: discard PDU, sn out of window (sn %d rx_next %d)\n", __FILE__, __LINE__, __FUNCTION__, sn, entity->rx_next); goto discard; @@ -617,7 +738,7 @@ void nr_rlc_entity_am_recv_pdu(nr_rlc_entity_t *_entity, /* discard segment if all the bytes of the segment are already there */ if (segment_already_received(entity, sn, so, data_size)) { - LOG_W(RLC, "%s:%d:%s: warning: discard PDU, already received\n", + LOG_D(RLC, "%s:%d:%s: warning: discard PDU, already received\n", __FILE__, __LINE__, __FUNCTION__); goto discard; } @@ -650,118 +771,6 @@ void nr_rlc_entity_am_recv_pdu(nr_rlc_entity_t *_entity, return; -control: - cpt = nr_rlc_pdu_decoder_get_bits(&decoder, 3); R(decoder); - if (cpt != 0) { - LOG_W(RLC, "%s:%d:%s: warning: discard PDU, CPT not 0 (%d)\n", - __FILE__, __LINE__, __FUNCTION__, cpt); - goto discard; - } - ack_sn = nr_rlc_pdu_decoder_get_bits(&decoder, entity->sn_field_length); R(decoder); - e1 = nr_rlc_pdu_decoder_get_bits(&decoder, 1); R(decoder); - /* r bits */ - if (entity->sn_field_length == 18) { - nr_rlc_pdu_decoder_get_bits(&decoder, 1); R(decoder); - } else { - nr_rlc_pdu_decoder_get_bits(&decoder, 7); R(decoder); - } - - /* let's try to parse the control PDU once to check consistency */ - control_decoder = decoder; - control_e1 = e1; - while (control_e1) { - nack_sn = nr_rlc_pdu_decoder_get_bits(&control_decoder, entity->sn_field_length); R(control_decoder); - control_e1 = nr_rlc_pdu_decoder_get_bits(&control_decoder, 1); R(control_decoder); - control_e2 = nr_rlc_pdu_decoder_get_bits(&control_decoder, 1); R(control_decoder); - control_e3 = nr_rlc_pdu_decoder_get_bits(&control_decoder, 1); R(control_decoder); - /* r bits */ - if (entity->sn_field_length == 18) { - nr_rlc_pdu_decoder_get_bits(&control_decoder, 3); R(control_decoder); - } else { - nr_rlc_pdu_decoder_get_bits(&control_decoder, 1); R(control_decoder); - } - /* check range and so_start/so_end consistency */ - if (control_e2) { - so_start = nr_rlc_pdu_decoder_get_bits(&control_decoder, 16); R(control_decoder); - so_end = nr_rlc_pdu_decoder_get_bits(&control_decoder, 16); R(control_decoder); - } else { - so_start = 0; - so_end = 0xffff; - } - if (control_e3) { - range = nr_rlc_pdu_decoder_get_bits(&control_decoder, 8); R(control_decoder); - } else { - range = 1; - } - if (range < 1) { - LOG_E(RLC, "%s:%d:%s: error, bad 'range' in RLC NACK (sn %d)\n", - __FILE__, __LINE__, __FUNCTION__, nack_sn); - goto err; - } - /* so_start can be > so_end if more than one range; they don't refer - * to the same PDU then - */ - if (range == 1 && so_end < so_start) { - LOG_E(RLC, "%s:%d:%s: error, bad so start/end (sn %d)\n", - __FILE__, __LINE__, __FUNCTION__, nack_sn); - goto err; - } - } - - /* 38.322 5.3.3.3 says to stop t_poll_retransmit if a ACK or NACK is - * received for the SN 'poll_sn' - check ACK case (NACK done below) - */ - if (sn_compare_tx(entity, entity->poll_sn, ack_sn) < 0) - entity->t_poll_retransmit_start = 0; - - /* at this point, accept the PDU even if the actual values - * may be incorrect (eg. if so_start > so_end) - */ - process_received_ack(entity, ack_sn); - - if (e1) - memset(sn_set, 0, 32768); - - while (e1) { - nack_sn = nr_rlc_pdu_decoder_get_bits(&decoder, entity->sn_field_length); R(decoder); - e1 = nr_rlc_pdu_decoder_get_bits(&decoder, 1); R(decoder); - e2 = nr_rlc_pdu_decoder_get_bits(&decoder, 1); R(decoder); - e3 = nr_rlc_pdu_decoder_get_bits(&decoder, 1); R(decoder); - /* r bits */ - if (entity->sn_field_length == 18) { - nr_rlc_pdu_decoder_get_bits(&decoder, 3); R(decoder); - } else { - nr_rlc_pdu_decoder_get_bits(&decoder, 1); R(decoder); - } - if (e2) { - so_start = nr_rlc_pdu_decoder_get_bits(&decoder, 16); R(decoder); - so_end = nr_rlc_pdu_decoder_get_bits(&decoder, 16); R(decoder); - } else { - so_start = 0; - so_end = 0xffff; - } - if (e3) { - range = nr_rlc_pdu_decoder_get_bits(&decoder, 8); R(decoder); - } else { - range = 1; - } - /* special value 0xffff indicates 'all bytes to the end' */ - if (so_end == 0xffff) - so_end = -1; - process_received_nack(entity, nack_sn, so_start, so_end, range, sn_set); - - /* 38.322 5.3.3.3 says to stop t_poll_retransmit if a ACK or NACK is - * received for the SN 'poll_sn' - check NACK case (ACK done above) - */ - if (sn_compare_tx(entity, nack_sn, entity->poll_sn) <= 0 && - sn_compare_tx(entity, entity->poll_sn, (nack_sn + range) % entity->sn_modulus) < 0) - entity->t_poll_retransmit_start = 0; - } - - finalize_ack_nack_processing(entity); - - return; - err: LOG_W(RLC, "%s:%d:%s: error decoding PDU, discarding\n", __FILE__, __LINE__, __FUNCTION__); goto discard; @@ -908,8 +917,6 @@ typedef struct { int so_start; int sn_end; int so_end; - /* data for maximum ack */ - int ack_sn; /* -1 if not to be used */ /* pdu to use for next call to 'next_missing' */ nr_rlc_pdu_t *next; } missing_data_t; @@ -924,13 +931,12 @@ static missing_data_t next_missing(nr_rlc_entity_am_t *entity, int max_so = 0; int last_reached = 0; - ret.ack_sn = -1; - /* special case: missing part before the head of RX list */ if (check_head) { if (cur->sn != entity->rx_next || !cur->is_first) { /* don't report if out of reporting window */ - if (sn_compare_rx(entity, entity->rx_highest_status, cur->sn) <= 0) { + if (sn_compare_rx(entity, entity->rx_highest_status, + entity->rx_next) <= 0) { ret.sn_start = -1; return ret; } @@ -954,10 +960,6 @@ next_pdu: max_so = cur_max_so; last_reached = last_reached | cur->is_last; - /* if cur already processed, it can be the acked SDU */ - if (cur->data == NULL) - ret.ack_sn = (cur->sn + 1) % entity->sn_modulus; - /* no next? */ if (cur->next == NULL) { /* inform the caller that work is over */ @@ -1033,32 +1035,36 @@ next_pdu: } /* discontinuity between different SDUs */ - ret.sn_start = sn; + if (last_reached) { + ret.sn_start = (sn + 1) % entity->sn_modulus; + ret.so_start = 0; + } else { + ret.sn_start = sn; + ret.so_start = max_so + 1; + } /* don't report if out of reporting window */ if (sn_compare_rx(entity, entity->rx_highest_status, ret.sn_start) <= 0) { ret.sn_start = -1; return ret; } - ret.so_start = max_so + 1; set_end_different_sdu: - /* don't go more than rx_highest_status - 1 */ - if (sn_compare_rx(entity, entity->rx_highest_status, cur->sn) <= 0) { - ret.sn_end = (entity->rx_highest_status - 1 + entity->sn_modulus) % - entity->sn_modulus; - ret.so_end = 0xffff; - return ret; - } - /* if cur is the head of a SDU, then use cur-1 */ if (cur->is_first) { ret.sn_end = (cur->sn - 1 + entity->sn_modulus) % entity->sn_modulus; ret.so_end = 0xffff; - return ret; + } else { + ret.sn_end = cur->sn; + ret.so_end = cur->so - 1; + } + /* don't go more than rx_highest_status - 1 */ + if (sn_compare_rx(entity, entity->rx_highest_status, ret.sn_end) <= 0) { + ret.sn_end = (entity->rx_highest_status - 1 + entity->sn_modulus) % + entity->sn_modulus; + ret.so_end = 0xffff; + ret.next = NULL; } - ret.sn_end = cur->sn; - ret.so_end = cur->so - 1; return ret; } @@ -1098,21 +1104,20 @@ static void get_e1_position(nr_rlc_entity_am_t *entity, } } -/* returns the number of nacks serialized. - * In most cases it is 1, it can be more if the - * missing data consists of a range that is more - * than 255 SNs in which case it has to be cut in - * smaller ranges. +/* returns the last nack SN generated, -1 if nothing generated. * If there is no more room in the status buffer, * will set m->next = NULL (and may serialize - * less nacks than required by 'm'). + * less nacks than required by 'm'), also + * sets *generation_truncated to 1. */ static int generate_missing(nr_rlc_entity_am_t *entity, nr_rlc_pdu_encoder_t *encoder, - missing_data_t *m, int *e1_byte, int *e1_bit) + missing_data_t *m, int *e1_byte, int *e1_bit, + int *generation_truncated, + unsigned char **so_end_address) { int r_bits = entity->sn_field_length == 18 ? 3 : 1; - int range_count = 0; + int last_nack_generated = -1; int sn_start; int so_start; int sn_end; @@ -1164,6 +1169,7 @@ static int generate_missing(nr_rlc_entity_am_t *entity, m_nack.so_end = so_end; if (encoder->byte + nack_size(entity, &m_nack) > encoder->size) { m->next = NULL; + *generation_truncated = 1; break; } @@ -1197,6 +1203,7 @@ static int generate_missing(nr_rlc_entity_am_t *entity, /* nack_sn */ nr_rlc_pdu_encoder_put_bits(encoder, sn_start, entity->sn_field_length); + last_nack_generated = sn_start; /* e1 = 0 (set later if needed) */ nr_rlc_pdu_encoder_put_bits(encoder, 0, 1); /* e2 */ @@ -1208,34 +1215,44 @@ static int generate_missing(nr_rlc_entity_am_t *entity, /* so_start/so_end */ if (e2) { nr_rlc_pdu_encoder_put_bits(encoder, so_start, 16); + *so_end_address = (unsigned char *)encoder->buffer + encoder->byte; nr_rlc_pdu_encoder_put_bits(encoder, so_end, 16); - } + } else + *so_end_address = NULL; /* nack range */ - if (e3) + if (e3) { nr_rlc_pdu_encoder_put_bits(encoder, cur_sn_count, 8); + last_nack_generated += cur_sn_count - 1; + } sn_count -= cur_sn_count; sn_start = (sn_start + cur_sn_count) % entity->sn_modulus; - range_count++; } - return range_count; + return last_nack_generated; } static int generate_status(nr_rlc_entity_am_t *entity, char *buffer, int size) { - int ack_sn = entity->rx_next; - missing_data_t m; + int last_nack; + int ack_sn; + missing_data_t m; nr_rlc_pdu_t *cur; - int nack_count = 0; + int check_head = 1; nr_rlc_pdu_encoder_t encoder; int e1_byte; int e1_bit; + int generation_truncated; + int ln; + unsigned char *so_end_address = NULL; /* if not enough room, do nothing */ if (size < 3) return 0; + /* initial last_nack is rx_next - 1 */ + last_nack = (entity->rx_next - 1 + entity->sn_modulus) % entity->sn_modulus; + nr_rlc_pdu_encoder_init(&encoder, buffer, size); /* first 3 bytes, ack_sn and e1 will be set later */ @@ -1250,22 +1267,33 @@ static int generate_status(nr_rlc_entity_am_t *entity, char *buffer, int size) e1_bit = entity->sn_field_length == 18 ? 1 : 7; while (cur != NULL) { - m = next_missing(entity, cur, nack_count == 0); - - /* update ack_sn if the returned value is valid */ - if (m.ack_sn != -1) - ack_sn = m.ack_sn; + m = next_missing(entity, cur, check_head); + check_head = 0; /* stop here if no more nack to report */ if (m.sn_start == -1) break; - nack_count += generate_missing(entity, &encoder, &m, &e1_byte, &e1_bit); + generation_truncated = 0; + ln = generate_missing(entity, &encoder, &m, &e1_byte, &e1_bit, + &generation_truncated, &so_end_address); + /* remember the last nack put, if any */ + if (ln != -1) + last_nack = ln; + /* if generation was truncated and so_end was put, we force its value to + * 0xffff (end of SDU) because we don't know what missing nack information + * was supposed to be put, so we nack until the end of the PDU to be sure + */ + if (generation_truncated && so_end_address != NULL) { + so_end_address[0] = 0xff; + so_end_address[1] = 0xff; + } cur = m.next; } - /* put ack_sn */ + /* put ack_sn, which is last_nack + 1 */ + ack_sn = (last_nack + 1) % entity->sn_modulus; if (entity->sn_field_length == 12) { buffer[0] = ack_sn >> 8; buffer[1] = ack_sn & 255; @@ -1427,8 +1455,6 @@ static int generate_retx_pdu(nr_rlc_entity_am_t *entity, char *buffer, return 0; entity->retransmit_list = entity->retransmit_list->next; - if (entity->retransmit_list == NULL) - entity->retransmit_end = NULL; sdu->next = NULL; @@ -1444,15 +1470,24 @@ static int generate_retx_pdu(nr_rlc_entity_am_t *entity, char *buffer, /* put the second SDU back at the head of the retransmit list */ next_sdu->next = entity->retransmit_list; entity->retransmit_list = next_sdu; - if (entity->retransmit_end == NULL) - entity->retransmit_end = entity->retransmit_list; /* update buffer status */ entity->common.bstatus.retx_size += compute_pdu_header_size(entity, next_sdu) + next_sdu->size; } /* put SDU/SDU segment in the wait list */ - nr_rlc_sdu_segment_list_append(&entity->wait_list, &entity->wait_end, sdu); + /* speedup: check end of wait list, maybe the new sdu comes after */ + if (entity->wait_end == NULL + || sn_compare_tx(entity, sdu->sdu->sn, entity->wait_end->sdu->sn) > 0 + || (sn_compare_tx(entity, sdu->sdu->sn, entity->wait_end->sdu->sn) == 0 + && sdu->so > entity->wait_end->so)) + nr_rlc_sdu_segment_list_append(&entity->wait_list, &entity->wait_end, sdu); + else { + entity->wait_list = nr_rlc_sdu_segment_list_add(sn_compare_tx, entity, + entity->wait_list, sdu); + if (entity->wait_list->next == NULL) + entity->wait_end = entity->wait_list; + } p = check_poll_after_pdu_assembly(entity); @@ -1519,7 +1554,18 @@ static int generate_tx_pdu(nr_rlc_entity_am_t *entity, char *buffer, int size) entity->tx_next = (entity->tx_next + 1) % entity->sn_modulus; /* put SDU/SDU segment in the wait list */ - nr_rlc_sdu_segment_list_append(&entity->wait_list, &entity->wait_end, sdu); + /* speedup: check end of wait list, probably the new sdu comes after */ + if (entity->wait_end == NULL + || sn_compare_tx(entity, sdu->sdu->sn, entity->wait_end->sdu->sn) > 0 + || (sn_compare_tx(entity, sdu->sdu->sn, entity->wait_end->sdu->sn) == 0 + && sdu->so > entity->wait_end->so)) + nr_rlc_sdu_segment_list_append(&entity->wait_list, &entity->wait_end, sdu); + else { + entity->wait_list = nr_rlc_sdu_segment_list_add(sn_compare_tx, entity, + entity->wait_list, sdu); + if (entity->wait_list->next == NULL) + entity->wait_end = entity->wait_list; + } /* polling actions for a new PDU */ entity->pdu_without_poll++; @@ -1629,11 +1675,7 @@ void nr_rlc_entity_am_recv_sdu(nr_rlc_entity_t *_entity, static void check_t_poll_retransmit(nr_rlc_entity_am_t *entity) { - nr_rlc_sdu_segment_t head; nr_rlc_sdu_segment_t *cur; - nr_rlc_sdu_segment_t *prev; - int sn; - int old_retx_count; /* 38.322 5.3.3.4 */ /* did t_poll_retransmit expire? */ @@ -1659,74 +1701,58 @@ static void check_t_poll_retransmit(nr_rlc_entity_am_t *entity) */ entity->force_poll = 1; - LOG_W(RLC, "%s:%d:%s: warning: t_poll_retransmit expired\n", + LOG_D(RLC, "%s:%d:%s: warning: t_poll_retransmit expired\n", __FILE__, __LINE__, __FUNCTION__); /* do we meet conditions of 38.322 5.3.3.4? */ if (!check_poll_after_pdu_assembly(entity)) return; - /* search wait list for SDU with highest SN */ - /* this code may be incorrect: in LTE we had to look for PDU - * with SN = VT(S) - 1, but for NR the specs say "highest SN among the - * ones submitted to lower layers" not 'tx_next - 1'. So we should look - * for the highest SN in the wait list. But that's no big deal. If the - * program runs this code, then the connection is in a bad state and we - * can retransmit whatever we want. At some point we will receive a status - * report and retransmit what we really have to. Actually we could just - * retransmit the head of wait list (the specs have this 'or'). - * (Actually, maybe this interpretation is not correct and what the code - * does is correct. The specs are confusing.) + /* retransmit the head of wait list, this is the case + * "consider any RLC SDU which has not been positively acknowledged for + * retransmission" of 36.322 5.3.3.4. + * We don't search for the highest SN, it's simpler to just take the head + * of wait list. This can be changed if needed. */ - sn = (entity->tx_next - 1 + entity->sn_modulus) % entity->sn_modulus; - - head.next = entity->wait_list; cur = entity->wait_list; - prev = &head; - - while (cur != NULL) { - if (cur->sdu->sn == sn) - break; - prev = cur; - cur = cur->next; - } - - /* SDU with highest SN not found? take the head of wait list */ - if (cur == NULL) { - cur = entity->wait_list; - prev = &head; - sn = cur->sdu->sn; - } /* todo: do we need to for check cur == NULL? * It seems that no, the wait list should not be empty here, but not sure. */ - old_retx_count = cur->sdu->retx_count; + entity->wait_list = cur->next; + if (entity->wait_list == NULL) + entity->wait_end = NULL; - /* 38.322 says "SDU", not "SDU segment", so let's retransmit all - * SDU segments with this SN + /* 38.322 says "SDU", not "SDU segment", but let's retransmit only + * the 'cur' SDU segment. To be changed if needed. (Maybe we have + * to retransmit all SDU segments with the same SN that are in the + * wait list.) */ - /* todo: maybe we could simply retransmit the current SDU segment, - * so that we don't have to run through the full wait list. + + /* increase retx count. Don't care about segmentation, so maybe we + * increase too much. */ - while (cur != NULL) { - if (cur->sdu->sn == sn) { - prev->next = cur->next; - cur->next = NULL; - /* put in retransmit list */ - consider_retransmission(entity, cur, - old_retx_count == cur->sdu->retx_count); - } else { - prev = cur; - } - cur = prev->next; - } - entity->wait_list = head.next; - /* reset wait_end (todo: optimize?) */ - entity->wait_end = entity->wait_list; - while (entity->wait_end != NULL && entity->wait_end->next != NULL) - entity->wait_end = entity->wait_end->next; + cur->sdu->retx_count++; + /* report max RETX reached for all retx_count >= max_retx_threshold + * (specs say to report if retx_count == max_retx_threshold). + * Upper layers should react (radio link failure), so no big deal. + * We deal with segmentation by requiring + * retx_count >= max_retx_threshold * number of segments. + * We may report max RETX reached too late/early. To be refined if + * this is a problem. + */ + if (cur->sdu->retx_count + >= entity->max_retx_threshold * cur->sdu->ref_count) + entity->common.max_retx_reached(entity->common.max_retx_reached_data, + (nr_rlc_entity_t *)entity); + /* update buffer status */ + entity->common.bstatus.retx_size += compute_pdu_header_size(entity, cur) + + cur->size; + + /* put in retransmit list */ + entity->retransmit_list = nr_rlc_sdu_segment_list_add(sn_compare_tx, entity, + entity->retransmit_list, cur); } static void check_t_reassembly(nr_rlc_entity_am_t *entity) @@ -1815,6 +1841,7 @@ void nr_rlc_entity_am_discard_sdu(nr_rlc_entity_t *_entity, int sdu_id) entity->common.bstatus.tx_size -= compute_pdu_header_size(entity, cur) + cur->size; + entity->tx_size -= cur->sdu->size; nr_rlc_free_sdu_segment(cur); } @@ -1857,7 +1884,6 @@ static void clear_entity(nr_rlc_entity_am_t *entity) nr_rlc_free_sdu_segment_list(entity->tx_list); nr_rlc_free_sdu_segment_list(entity->wait_list); nr_rlc_free_sdu_segment_list(entity->retransmit_list); - nr_rlc_free_sdu_segment_list(entity->ack_list); entity->tx_list = NULL; entity->tx_end = NULL; @@ -1867,9 +1893,6 @@ static void clear_entity(nr_rlc_entity_am_t *entity) entity->wait_end = NULL; entity->retransmit_list = NULL; - entity->retransmit_end = NULL; - - entity->ack_list = NULL; entity->common.bstatus.tx_size = 0; entity->common.bstatus.retx_size = 0; diff --git a/openair2/LAYER2/nr_rlc/nr_rlc_entity_am.h b/openair2/LAYER2/nr_rlc/nr_rlc_entity_am.h index 453fe87026..57ae1a3485 100644 --- a/openair2/LAYER2/nr_rlc/nr_rlc_entity_am.h +++ b/openair2/LAYER2/nr_rlc/nr_rlc_entity_am.h @@ -84,9 +84,6 @@ typedef struct { nr_rlc_sdu_segment_t *wait_end; nr_rlc_sdu_segment_t *retransmit_list; - nr_rlc_sdu_segment_t *retransmit_end; - - nr_rlc_sdu_segment_t *ack_list; } nr_rlc_entity_am_t; void nr_rlc_entity_am_recv_sdu(nr_rlc_entity_t *entity, diff --git a/openair2/LAYER2/nr_rlc/nr_rlc_oai_api.c b/openair2/LAYER2/nr_rlc/nr_rlc_oai_api.c index baae1fa436..7ba08aaa71 100644 --- a/openair2/LAYER2/nr_rlc/nr_rlc_oai_api.c +++ b/openair2/LAYER2/nr_rlc/nr_rlc_oai_api.c @@ -123,7 +123,7 @@ void nr_drb_config(struct NR_RLC_Config *rlc_Config, NR_RLC_Config_PR rlc_config rlc_Config->choice.am->dl_AM_RLC.t_StatusProhibit = NR_T_StatusProhibit_ms15; break; default: - LOG_E (RLC, "Error in %s: RLC config type %d is not handled\n", __FUNCTION__, rlc_config_pr); + AssertFatal(0, "RLC config type %d not handled\n", rlc_config_pr); break; } @@ -385,7 +385,6 @@ rlc_op_status_t rlc_data_req (const protocol_ctxt_t *const ctxt_pP, rb->recv_sdu(rb, (char *)sdu_pP->data, sdu_sizeP, muiP); } else { LOG_E(RLC, "%s:%d:%s: fatal: SDU sent to unknown RB\n", __FILE__, __LINE__, __FUNCTION__); - exit(1); } nr_rlc_manager_unlock(nr_rlc_ue_manager); diff --git a/openair2/LAYER2/nr_rlc/nr_rlc_sdu.c b/openair2/LAYER2/nr_rlc/nr_rlc_sdu.c index ef0d52558a..ef64389ac5 100644 --- a/openair2/LAYER2/nr_rlc/nr_rlc_sdu.c +++ b/openair2/LAYER2/nr_rlc/nr_rlc_sdu.c @@ -58,14 +58,19 @@ oom: exit(1); } -void nr_rlc_free_sdu_segment(nr_rlc_sdu_segment_t *sdu) +int nr_rlc_free_sdu_segment(nr_rlc_sdu_segment_t *sdu) { - sdu->sdu->ref_count--; - if (sdu->sdu->ref_count == 0) { + int ret = 0; + + sdu->sdu->free_count++; + if (sdu->sdu->free_count == sdu->sdu->ref_count) { free(sdu->sdu->data); free(sdu->sdu); + ret = 1; } free(sdu); + + return ret; } void nr_rlc_sdu_segment_list_append(nr_rlc_sdu_segment_t **list, diff --git a/openair2/LAYER2/nr_rlc/nr_rlc_sdu.h b/openair2/LAYER2/nr_rlc/nr_rlc_sdu.h index f4585fb7d6..20cc90f185 100644 --- a/openair2/LAYER2/nr_rlc/nr_rlc_sdu.h +++ b/openair2/LAYER2/nr_rlc/nr_rlc_sdu.h @@ -30,6 +30,10 @@ typedef struct nr_rlc_sdu_t { int retx_count; int ref_count; /* incremented each time the SDU is segmented */ + int free_count; /* incremented each time a segment is freed + * when it equals ref_count we can free the SDU + * completely + */ } nr_rlc_sdu_t; typedef struct nr_rlc_sdu_segment_t { @@ -44,7 +48,8 @@ typedef struct nr_rlc_sdu_segment_t { nr_rlc_sdu_segment_t *nr_rlc_new_sdu( char *buffer, int size, int upper_layer_id); -void nr_rlc_free_sdu_segment(nr_rlc_sdu_segment_t *sdu); +/* return 1 if the SDU has been freed too, 0 if not (more segments to free) */ +int nr_rlc_free_sdu_segment(nr_rlc_sdu_segment_t *sdu); void nr_rlc_sdu_segment_list_append(nr_rlc_sdu_segment_t **list, nr_rlc_sdu_segment_t **end, nr_rlc_sdu_segment_t *sdu); diff --git a/openair2/LAYER2/nr_rlc/tests/test14.txt.gz b/openair2/LAYER2/nr_rlc/tests/test14.txt.gz index 53616dae3d..45e54651eb 100644 Binary files a/openair2/LAYER2/nr_rlc/tests/test14.txt.gz and b/openair2/LAYER2/nr_rlc/tests/test14.txt.gz differ diff --git a/openair2/LAYER2/nr_rlc/tests/test15.txt.gz b/openair2/LAYER2/nr_rlc/tests/test15.txt.gz index 2619436c2d..ddb895d56f 100644 Binary files a/openair2/LAYER2/nr_rlc/tests/test15.txt.gz and b/openair2/LAYER2/nr_rlc/tests/test15.txt.gz differ diff --git a/openair2/M2AP/m2ap_MCE_defs.h b/openair2/M2AP/m2ap_MCE_defs.h index 5267232d69..73183e89c2 100644 --- a/openair2/M2AP/m2ap_MCE_defs.h +++ b/openair2/M2AP/m2ap_MCE_defs.h @@ -170,7 +170,7 @@ typedef struct m2ap_MCE_instance_s { int32_t uplink_frequency_offset[MAX_NUM_CCs]; uint32_t Nid_cell[MAX_NUM_CCs]; int16_t N_RB_DL[MAX_NUM_CCs]; - lte_frame_type_t frame_type[MAX_NUM_CCs]; + frame_type_t frame_type[MAX_NUM_CCs]; uint32_t fdd_earfcn_DL[MAX_NUM_CCs]; uint32_t fdd_earfcn_UL[MAX_NUM_CCs]; int num_cc; diff --git a/openair2/M2AP/m2ap_eNB_defs.h b/openair2/M2AP/m2ap_eNB_defs.h index b8f7e4b3c6..0b30c33d80 100644 --- a/openair2/M2AP/m2ap_eNB_defs.h +++ b/openair2/M2AP/m2ap_eNB_defs.h @@ -181,7 +181,7 @@ typedef struct m2ap_eNB_instance_s { int32_t uplink_frequency_offset[MAX_NUM_CCs]; uint32_t Nid_cell[MAX_NUM_CCs]; int16_t N_RB_DL[MAX_NUM_CCs]; - lte_frame_type_t frame_type[MAX_NUM_CCs]; + frame_type_t frame_type[MAX_NUM_CCs]; uint32_t fdd_earfcn_DL[MAX_NUM_CCs]; uint32_t fdd_earfcn_UL[MAX_NUM_CCs]; int num_cc; diff --git a/openair2/NR_PHY_INTERFACE/NR_IF_Module.c b/openair2/NR_PHY_INTERFACE/NR_IF_Module.c index 2654988557..ac0e48a910 100644 --- a/openair2/NR_PHY_INTERFACE/NR_IF_Module.c +++ b/openair2/NR_PHY_INTERFACE/NR_IF_Module.c @@ -57,8 +57,6 @@ extern int oai_nfapi_nr_srs_indication(nfapi_nr_srs_indication_t *ind); extern int oai_nfapi_nr_uci_indication(nfapi_nr_uci_indication_t *ind); extern int oai_nfapi_nr_rach_indication(nfapi_nr_rach_indication_t *ind); extern uint8_t nfapi_mode; -extern uint16_t sf_ahead; -extern uint16_t sl_ahead; void handle_nr_rach(NR_UL_IND_t *UL_info) @@ -374,9 +372,6 @@ static void match_crc_rx_pdu(nfapi_nr_rx_data_indication_t *rx_ind, nfapi_nr_crc void NR_UL_indication(NR_UL_IND_t *UL_info) { AssertFatal(UL_info!=NULL,"UL_info is null\n"); -#ifdef DUMP_FAPI - dump_ul(UL_info); -#endif module_id_t module_id = UL_info->module_id; int CC_id = UL_info->CC_id; NR_Sched_Rsp_t *sched_info = &NR_Sched_INFO[module_id][CC_id]; @@ -461,14 +456,14 @@ void NR_UL_indication(NR_UL_IND_t *UL_info) { nfapi_nr_config_request_scf_t *cfg = &mac->config[CC_id]; int spf = get_spf(cfg); gNB_dlsch_ulsch_scheduler(module_id, - (UL_info->frame+((UL_info->slot>(spf-1-sl_ahead))?1:0)) % 1024, - (UL_info->slot+sl_ahead)%spf); + (UL_info->frame+((UL_info->slot>(spf-1-ifi->sl_ahead))?1:0)) % 1024, + (UL_info->slot+ifi->sl_ahead)%spf); ifi->CC_mask = 0; sched_info->module_id = module_id; sched_info->CC_id = CC_id; - sched_info->frame = (UL_info->frame + ((UL_info->slot>(spf-1-sl_ahead)) ? 1 : 0)) % 1024; - sched_info->slot = (UL_info->slot+sl_ahead)%spf; + sched_info->frame = (UL_info->frame + ((UL_info->slot>(spf-1-ifi->sl_ahead)) ? 1 : 0)) % 1024; + sched_info->slot = (UL_info->slot+ifi->sl_ahead)%spf; sched_info->DL_req = &mac->DL_req[CC_id]; sched_info->UL_dci_req = &mac->UL_dci_req[CC_id]; diff --git a/openair2/NR_PHY_INTERFACE/NR_IF_Module.h b/openair2/NR_PHY_INTERFACE/NR_IF_Module.h index f857151763..9d543b0918 100644 --- a/openair2/NR_PHY_INTERFACE/NR_IF_Module.h +++ b/openair2/NR_PHY_INTERFACE/NR_IF_Module.h @@ -115,6 +115,7 @@ typedef struct NR_IF_Module_s { uint16_t current_frame; uint8_t current_slot; pthread_mutex_t if_mutex; + int sl_ahead; } NR_IF_Module_t; /*Initial */ diff --git a/openair2/NR_UE_PHY_INTERFACE/NR_IF_Module.c b/openair2/NR_UE_PHY_INTERFACE/NR_IF_Module.c index 9bce0e8843..b8b79f8399 100644 --- a/openair2/NR_UE_PHY_INTERFACE/NR_IF_Module.c +++ b/openair2/NR_UE_PHY_INTERFACE/NR_IF_Module.c @@ -42,6 +42,7 @@ #include "SCHED_NR_UE/fapi_nr_ue_l1.h" #include "executables/softmodem-common.h" #include "openair2/RRC/NR_UE/rrc_proto.h" +#include "openair2/RRC/NR_UE/rrc_vars.h" #include "openair2/GNB_APP/L1_nr_paramdef.h" #include "openair2/GNB_APP/gnb_paramdef.h" #include "targets/ARCH/ETHERNET/USERSPACE/LIB/if_defs.h" @@ -64,7 +65,17 @@ queue_t nr_dl_tti_req_queue; queue_t nr_tx_req_queue; queue_t nr_ul_dci_req_queue; queue_t nr_ul_tti_req_queue; -queue_t nr_wait_ul_tti_req_queue; + +static slot_rnti_mcs_s slot_rnti_mcs[NUM_NFAPI_SLOT]; + +//static int get_mcs_from_sinr(float sinr); +//static int get_cqi_from_mcs(void); +static void read_channel_param(const nfapi_nr_dl_tti_pdsch_pdu_rel15_t * pdu, int sf, int index); +//static bool did_drop_transport_block(int slot, uint16_t rnti); +static float get_bler_val(uint8_t mcs, int sinr); +static bool should_drop_transport_block(int slot, uint16_t rnti); +static void save_pdsch_pdu_for_crnti(nfapi_nr_dl_tti_request_t *dl_tti_request); +static inline bool is_channel_modeling(void); void nrue_init_standalone_socket(int tx_port, int rx_port) { @@ -78,13 +89,13 @@ void nrue_init_standalone_socket(int tx_port, int rx_port) int sd = socket(server_address.sin_family, SOCK_DGRAM, 0); if (sd < 0) { - LOG_E(MAC, "Socket creation error standalone PNF\n"); + LOG_E(NR_MAC, "Socket creation error standalone PNF\n"); return; } if (inet_pton(server_address.sin_family, stub_eth_params.remote_addr, &server_address.sin_addr) <= 0) { - LOG_E(MAC, "Invalid standalone PNF Address\n"); + LOG_E(NR_MAC, "Invalid standalone PNF Address\n"); close(sd); return; } @@ -92,13 +103,13 @@ void nrue_init_standalone_socket(int tx_port, int rx_port) // Using connect to use send() instead of sendto() if (connect(sd, (struct sockaddr *)&server_address, addr_len) < 0) { - LOG_E(MAC, "Connection to standalone PNF failed: %s\n", strerror(errno)); + LOG_E(NR_MAC, "Connection to standalone PNF failed: %s\n", strerror(errno)); close(sd); return; } assert(ue_tx_sock_descriptor == -1); ue_tx_sock_descriptor = sd; - LOG_D(NR_RRC, "Successfully set up tx_socket in %s.\n", __FUNCTION__); + LOG_T(NR_RRC, "Successfully set up tx_socket in %s.\n", __FUNCTION__); } { @@ -118,15 +129,15 @@ void nrue_init_standalone_socket(int tx_port, int rx_port) if (bind(sd, (struct sockaddr *)&server_address, addr_len) < 0) { - LOG_E(MAC, "Connection to standalone PNF failed: %s\n", strerror(errno)); + LOG_E(NR_MAC, "Connection to standalone PNF failed: %s\n", strerror(errno)); close(sd); return; } assert(ue_rx_sock_descriptor == -1); ue_rx_sock_descriptor = sd; - LOG_D(NR_RRC, "Successfully set up rx_socket in %s.\n", __FUNCTION__); + LOG_T(NR_RRC, "Successfully set up rx_socket in %s.\n", __FUNCTION__); } - LOG_I(NR_RRC, "NRUE standalone socket info: tx_port %d rx_port %d on %s.\n", + LOG_D(NR_RRC, "NRUE standalone socket info: tx_port %d rx_port %d on %s.\n", tx_port, rx_port, stub_eth_params.remote_addr); } @@ -137,7 +148,7 @@ void send_nsa_standalone_msg(NR_UL_IND_t *UL_INFO, uint16_t msg_id) case NFAPI_NR_PHY_MSG_TYPE_RACH_INDICATION: { char buffer[NFAPI_MAX_PACKED_MESSAGE_SIZE]; - LOG_D(NR_MAC, "RACH header id :%d", UL_INFO->rach_ind.header.message_id); + LOG_T(NR_MAC, "RACH header id :%d\n", UL_INFO->rach_ind.header.message_id); int encoded_size = nfapi_nr_p7_message_pack(&UL_INFO->rach_ind, buffer, sizeof(buffer), NULL); if (encoded_size <= 0) { @@ -145,7 +156,7 @@ void send_nsa_standalone_msg(NR_UL_IND_t *UL_INFO, uint16_t msg_id) return; } - LOG_I(NR_MAC, "NR_RACH_IND sent to Proxy, Size: %d Frame %d Slot %d Num PDUS %d\n", encoded_size, + LOG_D(NR_MAC, "NR_RACH_IND sent to Proxy, Size: %d Frame %d Slot %d Num PDUS %d\n", encoded_size, UL_INFO->rach_ind.sfn, UL_INFO->rach_ind.slot, UL_INFO->rach_ind.number_of_pdus); if (send(ue_tx_sock_descriptor, buffer, encoded_size, 0) < 0) { @@ -157,7 +168,7 @@ void send_nsa_standalone_msg(NR_UL_IND_t *UL_INFO, uint16_t msg_id) case NFAPI_NR_PHY_MSG_TYPE_RX_DATA_INDICATION: { char buffer[NFAPI_MAX_PACKED_MESSAGE_SIZE]; - LOG_D(NR_MAC, "RX header id :%d", UL_INFO->rx_ind.header.message_id); + LOG_T(NR_MAC, "RX header id :%d\n", UL_INFO->rx_ind.header.message_id); int encoded_size = nfapi_nr_p7_message_pack(&UL_INFO->rx_ind, buffer, sizeof(buffer), NULL); if (encoded_size <= 0) { @@ -165,7 +176,7 @@ void send_nsa_standalone_msg(NR_UL_IND_t *UL_INFO, uint16_t msg_id) return; } - LOG_I(NR_MAC, "NR_RX_IND sent to Proxy, Size: %d Frame %d Slot %d Num PDUS %d\n", encoded_size, + LOG_D(NR_MAC, "NR_RX_IND sent to Proxy, Size: %d Frame %d Slot %d Num PDUS %d\n", encoded_size, UL_INFO->rx_ind.sfn, UL_INFO->rx_ind.slot, UL_INFO->rx_ind.number_of_pdus); if (send(ue_tx_sock_descriptor, buffer, encoded_size, 0) < 0) { @@ -177,7 +188,7 @@ void send_nsa_standalone_msg(NR_UL_IND_t *UL_INFO, uint16_t msg_id) case NFAPI_NR_PHY_MSG_TYPE_CRC_INDICATION: { char buffer[NFAPI_MAX_PACKED_MESSAGE_SIZE]; - LOG_D(NR_MAC, "CRC header id :%d", UL_INFO->crc_ind.header.message_id); + LOG_T(NR_MAC, "CRC header id :%d\n", UL_INFO->crc_ind.header.message_id); int encoded_size = nfapi_nr_p7_message_pack(&UL_INFO->crc_ind, buffer, sizeof(buffer), NULL); if (encoded_size <= 0) { @@ -185,7 +196,7 @@ void send_nsa_standalone_msg(NR_UL_IND_t *UL_INFO, uint16_t msg_id) return; } - LOG_I(NR_MAC, "NR_CRC_IND sent to Proxy, Size: %d Frame %d Slot %d Num PDUS %d\n", encoded_size, + LOG_D(NR_MAC, "NR_CRC_IND sent to Proxy, Size: %d Frame %d Slot %d Num PDUS %d\n", encoded_size, UL_INFO->crc_ind.sfn, UL_INFO->crc_ind.slot, UL_INFO->crc_ind.number_crcs); if (send(ue_tx_sock_descriptor, buffer, encoded_size, 0) < 0) { @@ -197,7 +208,7 @@ void send_nsa_standalone_msg(NR_UL_IND_t *UL_INFO, uint16_t msg_id) case NFAPI_NR_PHY_MSG_TYPE_UCI_INDICATION: { char buffer[NFAPI_MAX_PACKED_MESSAGE_SIZE]; - LOG_I(NR_MAC, "UCI header id :%d", UL_INFO->uci_ind.header.message_id); + LOG_D(NR_MAC, "UCI header id :%d\n", UL_INFO->uci_ind.header.message_id); int encoded_size = nfapi_nr_p7_message_pack(&UL_INFO->uci_ind, buffer, sizeof(buffer), NULL); if (encoded_size <= 0) { @@ -205,7 +216,7 @@ void send_nsa_standalone_msg(NR_UL_IND_t *UL_INFO, uint16_t msg_id) return; } - LOG_I(NR_MAC, "NR_UCI_IND sent to Proxy, Size: %d Frame %d Slot %d Num PDUS %d\n", encoded_size, + LOG_D(NR_MAC, "NR_UCI_IND sent to Proxy, Size: %d Frame %d Slot %d Num PDUS %d\n", encoded_size, UL_INFO->uci_ind.sfn, UL_INFO->uci_ind.slot, UL_INFO->uci_ind.num_ucis); if (send(ue_tx_sock_descriptor, buffer, encoded_size, 0) < 0) { @@ -221,18 +232,83 @@ void send_nsa_standalone_msg(NR_UL_IND_t *UL_INFO, uint16_t msg_id) } } +bool sfn_slot_matcher(void *wanted, void *candidate) +{ + nfapi_p7_message_header_t *msg = candidate; + int sfn_sf = *(int*)wanted; + + switch (msg->message_id) + { + case NFAPI_NR_PHY_MSG_TYPE_RACH_INDICATION: + { + nfapi_nr_rach_indication_t *ind = candidate; + return NFAPI_SFNSLOT2SFN(sfn_sf) == ind->sfn && NFAPI_SFNSLOT2SLOT(sfn_sf) == ind->slot; + } + + case NFAPI_NR_PHY_MSG_TYPE_RX_DATA_INDICATION: + { + nfapi_nr_rx_data_indication_t *ind = candidate; + return NFAPI_SFNSLOT2SFN(sfn_sf) == ind->sfn && NFAPI_SFNSLOT2SLOT(sfn_sf) == ind->slot; + } + + case NFAPI_NR_PHY_MSG_TYPE_CRC_INDICATION: + { + nfapi_nr_crc_indication_t *ind = candidate; + return NFAPI_SFNSLOT2SFN(sfn_sf) == ind->sfn && NFAPI_SFNSLOT2SLOT(sfn_sf) == ind->slot; + } + + case NFAPI_NR_PHY_MSG_TYPE_UCI_INDICATION: + { + nfapi_nr_uci_indication_t *ind = candidate; + return NFAPI_SFNSLOT2SFN(sfn_sf) == ind->sfn && NFAPI_SFNSLOT2SLOT(sfn_sf) == ind->slot; + } + + case NFAPI_NR_PHY_MSG_TYPE_DL_TTI_REQUEST: + { + nfapi_nr_dl_tti_request_t *ind = candidate; + return NFAPI_SFNSLOT2SFN(sfn_sf) == ind->SFN && NFAPI_SFNSLOT2SLOT(sfn_sf) == ind->Slot; + } + + case NFAPI_NR_PHY_MSG_TYPE_TX_DATA_REQUEST: + { + nfapi_nr_tx_data_request_t *ind = candidate; + return NFAPI_SFNSLOT2SFN(sfn_sf) == ind->SFN && NFAPI_SFNSLOT2SLOT(sfn_sf) == ind->Slot; + } + + case NFAPI_NR_PHY_MSG_TYPE_UL_DCI_REQUEST: + { + nfapi_nr_ul_dci_request_t *ind = candidate; + return NFAPI_SFNSLOT2SFN(sfn_sf) == ind->SFN && NFAPI_SFNSLOT2SLOT(sfn_sf) == ind->Slot; + } + + case NFAPI_NR_PHY_MSG_TYPE_UL_TTI_REQUEST: + { + nfapi_nr_ul_tti_request_t *ind = candidate; + return NFAPI_SFNSLOT2SFN(sfn_sf) == ind->SFN && NFAPI_SFNSLOT2SLOT(sfn_sf) == ind->Slot; + } + + default: + LOG_E(NR_MAC, "sfn_slot_match bad ID: %d\n", msg->message_id); + + } + + return false; +} + static void fill_dl_info_with_pdcch(fapi_nr_dci_indication_t *dci, nfapi_nr_dl_dci_pdu_t *rx_dci, int idx) { int num_bytes = (rx_dci->PayloadSizeBits + 7) / 8; - LOG_I(NR_PHY, "[%d, %d] PDCCH DCI (Payload) for rnti %x with PayloadSizeBits %d, num_bytes %d\n", + LOG_D(NR_PHY, "[%d, %d] PDCCH DCI (Payload) for rnti %x with PayloadSizeBits %d, num_bytes %d\n", dci->SFN, dci->slot, rx_dci->RNTI, rx_dci->PayloadSizeBits, num_bytes); for (int k = 0; k < num_bytes; k++) { - LOG_I(NR_MAC, "PDCCH DCI PDU payload[%d] = %d\n", k, rx_dci->Payload[k]); + LOG_D(NR_MAC, "PDCCH DCI PDU payload[%d] = %d\n", k, rx_dci->Payload[k]); dci->dci_list[idx].payloadBits[k] = rx_dci->Payload[k]; } dci->dci_list[idx].payloadSize = rx_dci->PayloadSizeBits; dci->dci_list[idx].rnti = rx_dci->RNTI; + dci->dci_list[idx].n_CCE = rx_dci->CceIndex; + dci->dci_list[idx].N_CCE = rx_dci->AggregationLevel; dci->number_of_dcis = idx + 1; } @@ -242,7 +318,7 @@ static void fill_mib_in_rx_ind(nfapi_nr_dl_tti_request_pdu_t *pdu_list, fapi_nr_ "pdu_index (%d) is greater than rx_indication_body size!\n", pdu_idx); AssertFatal(pdu_idx == rx_ind->number_pdus, "Invalid pdu_idx %d!\n", pdu_idx); - LOG_D(NR_MAC, "Recevied an SSB and are filling rx_ind with the MIB!\n"); + LOG_T(NR_MAC, "Recevied an SSB and are filling rx_ind with the MIB!\n"); nfapi_nr_dl_tti_ssb_pdu_rel15_t *ssb_pdu = &pdu_list->ssb_pdu.ssb_pdu_rel15; rx_ind->rx_indication_body[pdu_idx].ssb_pdu.cell_id = ssb_pdu->PhysCellId; @@ -311,13 +387,13 @@ static void copy_dl_tti_req_to_dl_info(nr_downlink_indication_t *dl_info, nfapi_ nfapi_nr_dl_tti_request_pdu_t *pdu_list = &dl_tti_request->dl_tti_request_body.dl_tti_pdu_list[i]; if (pdu_list->PDUType == NFAPI_NR_DL_TTI_PDSCH_PDU_TYPE) { - LOG_I(NR_PHY, "[%d, %d] PDSCH PDU for rnti %x\n", + LOG_D(NR_PHY, "[%d, %d] PDSCH PDU for rnti %x\n", dl_tti_request->SFN, dl_tti_request->Slot, pdu_list->pdsch_pdu.pdsch_pdu_rel15.rnti); } if (pdu_list->PDUType == NFAPI_NR_DL_TTI_PDCCH_PDU_TYPE) { - LOG_I(NR_PHY, "[%d, %d] PDCCH DCI PDU (Format for incoming PDSCH PDU)\n", + LOG_D(NR_PHY, "[%d, %d] PDCCH DCI PDU (Format for incoming PDSCH PDU)\n", dl_tti_request->SFN, dl_tti_request->Slot); uint16_t num_dcis = pdu_list->pdcch_pdu.pdcch_pdu_rel15.numDlDci; if (num_dcis > 0) @@ -342,19 +418,19 @@ static void copy_dl_tti_req_to_dl_info(nr_downlink_indication_t *dl_info, nfapi_ { mac->nr_ue_emul_l1.expected_sib = true; mac->nr_ue_emul_l1.index_has_sib[j] = true; - LOG_D(NR_MAC, "Setting index_has_sib[%d] = true\n", j); + LOG_T(NR_MAC, "Setting index_has_sib[%d] = true\n", j); } else if (dci_pdu_list->RNTI == mac->ra.ra_rnti) { mac->nr_ue_emul_l1.expected_rar = true; mac->nr_ue_emul_l1.index_has_rar[j] = true; - LOG_D(NR_MAC, "Setting index_has_rar[%d] = true\n", j); + LOG_T(NR_MAC, "Setting index_has_rar[%d] = true\n", j); } else { mac->nr_ue_emul_l1.expected_dci = true; mac->nr_ue_emul_l1.index_has_dci[j] = true; - LOG_D(NR_MAC, "Setting index_has_dci[%d] = true\n", j); + LOG_T(NR_MAC, "Setting index_has_dci[%d] = true\n", j); } pdu_idx++; } @@ -388,13 +464,14 @@ static void copy_dl_tti_req_to_dl_info(nr_downlink_indication_t *dl_info, nfapi_ static void fill_rx_ind(nfapi_nr_pdu_t *pdu_list, fapi_nr_rx_indication_t *rx_ind, int pdu_idx, int pdu_type) { + NR_UE_MAC_INST_t *mac = get_mac_inst(0); AssertFatal(pdu_list->num_TLV < sizeof(pdu_list->TLVs) / sizeof(pdu_list->TLVs[0]), "Num TLVs exceeds TLV array size"); int length = 0; for (int j = 0; j < pdu_list->num_TLV; j++) { length += pdu_list->TLVs[j].length; } - LOG_I(NR_PHY, "%s: num_tlv %d and length %d, pdu index %d\n", + LOG_D(NR_PHY, "%s: num_tlv %d and length %d, pdu index %d\n", __FUNCTION__, pdu_list->num_TLV, length, pdu_idx); uint8_t *pdu = malloc(length); AssertFatal(pdu != NULL, "%s: Out of memory in malloc", __FUNCTION__); @@ -409,7 +486,12 @@ static void fill_rx_ind(nfapi_nr_pdu_t *pdu_list, fapi_nr_rx_indication_t *rx_in memcpy(pdu, ptr, pdu_list->TLVs[j].length); pdu += pdu_list->TLVs[j].length; } - rx_ind->rx_indication_body[pdu_idx].pdsch_pdu.ack_nack = 1; + bool ack_nack = true; + if (mac->ra.ra_state >= RA_SUCCEEDED && should_drop_transport_block(rx_ind->slot, mac->crnti)) + { + ack_nack = false; + } + rx_ind->rx_indication_body[pdu_idx].pdsch_pdu.ack_nack = ack_nack; rx_ind->rx_indication_body[pdu_idx].pdsch_pdu.pdu_length = length; rx_ind->rx_indication_body[pdu_idx].pdu_type = pdu_type; @@ -455,7 +537,7 @@ static void copy_tx_data_req_to_dl_info(nr_downlink_indication_t *dl_info, nfapi } else { - LOG_D(NR_MAC, "mac->nr_ue_emul_l1.index_has_dci[%d] = 0, so this index contained a DCI for a different UE\n", i); + LOG_T(NR_MAC, "mac->nr_ue_emul_l1.index_has_dci[%d] = 0, so this index contained a DCI for a different UE\n", i); } } @@ -476,7 +558,7 @@ static void copy_ul_dci_data_req_to_dl_info(nr_downlink_indication_t *dl_info, n { nfapi_nr_ul_dci_request_pdus_t *pdu_list = &ul_dci_req->ul_dci_pdu_list[i]; AssertFatal(pdu_list->PDUType == 0, "ul_dci_req pdu type != PUCCH"); - LOG_I(NR_PHY, "[%d %d] PUCCH PDU in ul_dci for rnti %x and numDLDCI = %d\n", + LOG_D(NR_PHY, "[%d %d] PUCCH PDU in ul_dci for rnti %x and numDLDCI = %d\n", ul_dci_req->SFN, ul_dci_req->Slot, pdu_list->pdcch_pdu.pdcch_pdu_rel15.dci_pdu->RNTI, pdu_list->pdcch_pdu.pdcch_pdu_rel15.numDlDci); uint16_t num_dci = pdu_list->pdcch_pdu.pdcch_pdu_rel15.numDlDci; @@ -495,7 +577,7 @@ static void copy_ul_dci_data_req_to_dl_info(nr_downlink_indication_t *dl_info, n nfapi_nr_dl_dci_pdu_t *dci_pdu_list = &pdu_list->pdcch_pdu.pdcch_pdu_rel15.dci_pdu[j]; if (dci_pdu_list->RNTI != mac->crnti) { - LOG_D(NR_MAC, "dci_pdu_list->RNTI (%x) != mac->crnti (%x)\n", dci_pdu_list->RNTI, mac->crnti); + LOG_T(NR_MAC, "dci_pdu_list->RNTI (%x) != mac->crnti (%x)\n", dci_pdu_list->RNTI, mac->crnti); continue; } fill_dl_info_with_pdcch(dl_info->dci_ind, dci_pdu_list, pdu_idx); @@ -507,148 +589,60 @@ static void copy_ul_dci_data_req_to_dl_info(nr_downlink_indication_t *dl_info, n dl_info->slot = ul_dci_req->Slot; } -static nfapi_nr_uci_indication_t *multiplex_uci_ind(NR_UE_MAC_INST_t *mac, int num_active_harqs) +static bool send_crc_ind_and_rx_ind(int sfn_slot) { - AssertFatal(num_active_harqs >= 0, "Invalid value for num_active_harqs %d\n", num_active_harqs); - if (num_active_harqs == 0) - { - return NULL; - } - if (num_active_harqs != nr_uci_ind_queue.num_items) - { - LOG_I(NR_MAC, "The number of active harqs %d doesn't match the number of UCIs in the queue %lu\n", - num_active_harqs, nr_uci_ind_queue.num_items); - return NULL; - } + bool sent_crc_rx = true; - nfapi_nr_uci_indication_t *uci_ind = MALLOC(sizeof(*uci_ind)); - uci_ind->header.message_id = NFAPI_NR_PHY_MSG_TYPE_UCI_INDICATION; - uci_ind->sfn = NFAPI_SFNSLOT2SFN(mac->nr_ue_emul_l1.active_harq_sfn_slot); - uci_ind->slot = NFAPI_SFNSLOT2SLOT(mac->nr_ue_emul_l1.active_harq_sfn_slot); - uci_ind->num_ucis = num_active_harqs; - uci_ind->uci_list = CALLOC(uci_ind->num_ucis, sizeof(*uci_ind->uci_list)); - for (int i = 0; i < num_active_harqs; i++) - { - nfapi_nr_uci_indication_t *queued_uci_ind = get_queue(&nr_uci_ind_queue); - AssertFatal(queued_uci_ind, "There was not a UCI in the queue!\n"); - nfapi_nr_uci_pucch_pdu_format_0_1_t *pdu_0_1 = &uci_ind->uci_list[i].pucch_pdu_format_0_1; + nfapi_nr_rx_data_indication_t *rx_ind = unqueue_matching(&nr_rx_ind_queue, MAX_QUEUE_SIZE, sfn_slot_matcher, &sfn_slot); + nfapi_nr_crc_indication_t *crc_ind = unqueue_matching(&nr_crc_ind_queue, MAX_QUEUE_SIZE, sfn_slot_matcher, &sfn_slot); - /* In openair1/SCHED_NR_UE/fapi_nr_ue_l1.c nr_ue_schedule_response_stub(), the - number of UCIs is hard coded to 1. This is why we always use index 0 of the - queued UCI indication to fill the new multiplexed UCI indication */ - AssertFatal(queued_uci_ind->num_ucis == 1, "The number of UCIs from de-queueud UCI is not 1, its %d\n", - queued_uci_ind->num_ucis); - uci_ind->uci_list[i].pdu_type = queued_uci_ind->uci_list[0].pdu_type; - uci_ind->uci_list[i].pdu_size = queued_uci_ind->uci_list[0].pdu_size; - - nfapi_nr_uci_pucch_pdu_format_0_1_t *queued_pdu_0_1 = &queued_uci_ind->uci_list[0].pucch_pdu_format_0_1; - pdu_0_1->handle = queued_pdu_0_1->handle; - pdu_0_1->rnti = queued_pdu_0_1->rnti; - pdu_0_1->pucch_format = queued_pdu_0_1->pucch_format; - pdu_0_1->ul_cqi = queued_pdu_0_1->ul_cqi; - pdu_0_1->timing_advance = queued_pdu_0_1->timing_advance; - pdu_0_1->rssi = queued_pdu_0_1->rssi; - free(queued_uci_ind->uci_list); - queued_uci_ind->uci_list = NULL; - free(queued_uci_ind); - queued_uci_ind = NULL; + if (crc_ind && crc_ind->number_crcs > 0) + { + NR_UE_MAC_INST_t *mac = get_mac_inst(0); + for (int i = 0; i < crc_ind->number_crcs; i++) { + int harq_pid = crc_ind->crc_list[i].harq_id; + LOG_T(NR_MAC, "Resetting harq_pid %d active_ul_harq_sfn_slot\n", harq_pid); + mac->nr_ue_emul_l1.harq[harq_pid].active_ul_harq_sfn_slot = -1; } - return uci_ind; + NR_UL_IND_t UL_INFO = { + .crc_ind = *crc_ind, + }; + send_nsa_standalone_msg(&UL_INFO, crc_ind->header.message_id); + free(crc_ind->crc_list); + free(crc_ind); + } + if (rx_ind && rx_ind->number_of_pdus > 0) + { + NR_UL_IND_t UL_INFO = { + .rx_ind = *rx_ind, + }; + send_nsa_standalone_msg(&UL_INFO, rx_ind->header.message_id); + free(rx_ind->pdu_list); + free(rx_ind); + } + else + { + sent_crc_rx = false; + } + return sent_crc_rx; } static void copy_ul_tti_data_req_to_dl_info(nr_downlink_indication_t *dl_info, nfapi_nr_ul_tti_request_t *ul_tti_req) { - NR_UE_MAC_INST_t *mac = get_mac_inst(dl_info->module_id); int num_pdus = ul_tti_req->n_pdus; + int sfn_slot = NFAPI_SFNSLOT2HEX(ul_tti_req->SFN, ul_tti_req->Slot); AssertFatal(num_pdus >= 0, "Invalid ul_tti_request number of PDUS\n"); AssertFatal(num_pdus <= sizeof(ul_tti_req->pdus_list) / sizeof(ul_tti_req->pdus_list[0]), "Too many pdus %d in ul_tti_req\n", num_pdus); - bool sent_uci = false; - for (int i = 0; i < num_pdus; i++) + if (!send_crc_ind_and_rx_ind(sfn_slot)) { - nfapi_nr_ul_tti_request_number_of_pdus_t *pdu_list = &ul_tti_req->pdus_list[i]; - LOG_D(NR_PHY, "This is the pdu type %d and rnti %x and SR flag %d and harq_pdu_len %d in in ul_tti_req\n", - pdu_list->pdu_type, ul_tti_req->pdus_list[i].pucch_pdu.rnti, pdu_list->pucch_pdu.sr_flag, pdu_list->pucch_pdu.bit_len_harq); - if (pdu_list->pdu_type == NFAPI_NR_UL_CONFIG_PUCCH_PDU_TYPE && pdu_list->pucch_pdu.rnti == mac->crnti) - { - AssertFatal(nr_uci_ind_queue.num_items >= 0, "Invalid num_items in UCI_ind queue %lu\n", - nr_uci_ind_queue.num_items); - int num_active_harqs = pdu_list->pucch_pdu.bit_len_harq; - LOG_I(NR_MAC, "The number of active harqs %d from ul_tti_req\n", num_active_harqs); - nfapi_nr_uci_indication_t *uci_ind = multiplex_uci_ind(mac, num_active_harqs); - - if (uci_ind && uci_ind->num_ucis > 0) - { - LOG_D(NR_MAC, "This is the SFN/SF [%d, %d] and RNTI %x of the UCI ind. ul_tti_req.pdu[%d]->rnti = %x \n", - uci_ind->sfn, uci_ind->slot, uci_ind->uci_list[0].pucch_pdu_format_0_1.rnti, i, ul_tti_req->pdus_list[i].pucch_pdu.rnti); - uci_ind->sfn = ul_tti_req->SFN; - uci_ind->slot = ul_tti_req->Slot; - for (int j = 0; j < uci_ind->num_ucis; j++) - { - nfapi_nr_uci_pucch_pdu_format_0_1_t *pdu_0_1 = &uci_ind->uci_list[j].pucch_pdu_format_0_1; - if (pdu_list->pucch_pdu.sr_flag) - { - LOG_D(NR_MAC, "We have the SR flag in pdu i %d\n", i); - pdu_0_1->pduBitmap = 1; // (value->pduBitmap >> 1) & 0x01) == HARQ and (value->pduBitmap) & 0x01) == SR - pdu_0_1->sr = CALLOC(1, sizeof(*pdu_0_1->sr)); - pdu_0_1->sr->sr_confidence_level = 0; - pdu_0_1->sr->sr_indication = 1; - } - if (pdu_list->pucch_pdu.bit_len_harq > 0) - { - LOG_D(NR_MAC, "We have the Harq len bits %d\n", pdu_list->pucch_pdu.bit_len_harq); - pdu_0_1->pduBitmap = 2; // (value->pduBitmap >> 1) & 0x01) == HARQ and (value->pduBitmap) & 0x01) == SR - pdu_0_1->harq = CALLOC(1, sizeof(*pdu_0_1->harq)); - pdu_0_1->harq->num_harq = 1; - pdu_0_1->harq->harq_confidence_level = 0; - pdu_0_1->harq->harq_list = CALLOC(pdu_0_1->harq->num_harq, sizeof(*pdu_0_1->harq->harq_list)); - for (int k = 0; k < pdu_0_1->harq->num_harq; k++) - { - pdu_0_1->harq->harq_list[k].harq_value = 0; - } - } - } - LOG_I(NR_MAC, "We have dequeued the previously filled uci_ind and updated the snf/slot to %d/%d.\n", - uci_ind->sfn, uci_ind->slot); - NR_UL_IND_t UL_INFO = { - .uci_ind = *uci_ind, - }; - send_nsa_standalone_msg(&UL_INFO, uci_ind->header.message_id); - sent_uci = true; - - for (int k = 0; k < uci_ind->num_ucis; k++) - { - nfapi_nr_uci_pucch_pdu_format_0_1_t *pdu_0_1 = &uci_ind->uci_list[k].pucch_pdu_format_0_1; - if (pdu_list->pucch_pdu.sr_flag) - { - free(pdu_0_1->sr); - pdu_0_1->sr = NULL; - } - if (pdu_list->pucch_pdu.bit_len_harq > 1) - { - free(pdu_0_1->harq->harq_list); - pdu_0_1->harq->harq_list = NULL; - free(pdu_0_1->harq); - pdu_0_1->harq = NULL; - } - } - free(uci_ind->uci_list); - uci_ind->uci_list = NULL; - free(uci_ind); - uci_ind = NULL; - } - } - } - if (!sent_uci) - { - LOG_E(NR_MAC, "UCI ind not sent\n"); + LOG_T(NR_MAC, "CRC_RX ind not sent\n"); if (!put_queue(&nr_ul_tti_req_queue, ul_tti_req)) { LOG_E(NR_PHY, "put_queue failed for ul_tti_req.\n"); - free(ul_tti_req); - ul_tti_req = NULL; } + return; } } @@ -663,13 +657,13 @@ static void fill_dci_from_dl_config(nr_downlink_indication_t*dl_ind, fapi_nr_dl_ "Too many dl_config pdus %d", dl_config->number_pdus); for (int i = 0; i < dl_config->number_pdus; i++) { - LOG_I(PHY, "In %s: filling DCI with a total of %d total DL PDUs (dl_config %p) \n", + LOG_D(PHY, "In %s: filling DCI with a total of %d total DL PDUs (dl_config %p) \n", __FUNCTION__, dl_config->number_pdus, dl_config); fapi_nr_dl_config_dci_dl_pdu_rel15_t *rel15_dci = &dl_config->dl_config_list[i].dci_config_pdu.dci_config_rel15; int num_dci_options = rel15_dci->num_dci_options; if (num_dci_options <= 0) { - LOG_I(NR_MAC, "num_dci_opts = %d for pdu[%d] in dl_config_list\n", rel15_dci->num_dci_options, i); + LOG_D(NR_MAC, "num_dci_opts = %d for pdu[%d] in dl_config_list\n", rel15_dci->num_dci_options, i); } AssertFatal(num_dci_options <= sizeof(rel15_dci->dci_length_options) / sizeof(rel15_dci->dci_length_options[0]), "num_dci_options %d > dci_length_options array\n", num_dci_options); @@ -683,17 +677,15 @@ static void fill_dci_from_dl_config(nr_downlink_indication_t*dl_ind, fapi_nr_dl_ "dl_config->number_pdus %d > dci_ind->dci_list array\n", num_dcis); for (int k = 0; k < num_dcis; k++) { - LOG_I(NR_PHY, "Received len %d, length options[%d] %d, format assigned %d, format options[%d] %d\n", + LOG_T(NR_PHY, "Received len %d, length options[%d] %d, format assigned %d, format options[%d] %d\n", dl_ind->dci_ind->dci_list[k].payloadSize, j, rel15_dci->dci_length_options[j], dl_ind->dci_ind->dci_list[k].dci_format, j, rel15_dci->dci_format_options[j]); if (rel15_dci->dci_length_options[j] == dl_ind->dci_ind->dci_list[k].payloadSize) { dl_ind->dci_ind->dci_list[k].dci_format = rel15_dci->dci_format_options[j]; + LOG_D(NR_PHY, "format assigned dl_ind->dci_ind->dci_list[k].dci_format %d\n", + dl_ind->dci_ind->dci_list[k].dci_format); } - int CCEind = rel15_dci->CCE[j]; - int L = rel15_dci->L[j]; - dl_ind->dci_ind->dci_list[k].n_CCE = CCEind; - dl_ind->dci_ind->dci_list[k].N_CCE = L; } } } @@ -714,41 +706,52 @@ void check_and_process_dci(nfapi_nr_dl_tti_request_t *dl_tti_request, { frame = dl_tti_request->SFN; slot = dl_tti_request->Slot; - LOG_I(NR_PHY, "[%d, %d] dl_tti_request\n", frame, slot); + LOG_D(NR_PHY, "[%d, %d] dl_tti_request\n", frame, slot); copy_dl_tti_req_to_dl_info(&mac->dl_info, dl_tti_request); + free_and_zero(dl_tti_request); } /* This checks if the previously recevied DCI matches our current RNTI value. The assumption is that if the DCI matches our RNTI, then the incoming tx_data_request is also destined for the current UE. If the RAR hasn't been processed yet, we do not want to be filtering the tx_data_requests. */ - if (tx_data_request && (mac->nr_ue_emul_l1.expected_sib || - mac->nr_ue_emul_l1.expected_rar || - mac->nr_ue_emul_l1.expected_dci)) + if (tx_data_request) { - frame = tx_data_request->SFN; - slot = tx_data_request->Slot; - LOG_I(NR_PHY, "[%d, %d] PDSCH in tx_request\n", frame, slot); - copy_tx_data_req_to_dl_info(&mac->dl_info, tx_data_request); + if (mac->nr_ue_emul_l1.expected_sib || + mac->nr_ue_emul_l1.expected_rar || + mac->nr_ue_emul_l1.expected_dci) + { + frame = tx_data_request->SFN; + slot = tx_data_request->Slot; + LOG_I(NR_PHY, "[%d, %d] PDSCH in tx_request\n", frame, slot); + copy_tx_data_req_to_dl_info(&mac->dl_info, tx_data_request); + } + else + { + LOG_D(NR_MAC, "Unexpected tx_data_req\n"); + } + free_and_zero(tx_data_request); } else if (ul_dci_request) { frame = ul_dci_request->SFN; slot = ul_dci_request->Slot; - LOG_I(NR_PHY, "[%d, %d] ul_dci_request\n", frame, slot); + LOG_D(NR_PHY, "[%d, %d] ul_dci_request\n", frame, slot); copy_ul_dci_data_req_to_dl_info(&mac->dl_info, ul_dci_request); + free_and_zero(ul_dci_request); } else if (ul_tti_request) { frame = ul_tti_request->SFN; slot = ul_tti_request->Slot; - LOG_I(NR_PHY, "[%d, %d] ul_tti_request\n", frame, slot); + LOG_T(NR_PHY, "[%d, %d] ul_tti_request\n", frame, slot); copy_ul_tti_data_req_to_dl_info(&mac->dl_info, ul_tti_request); + free_and_zero(ul_tti_request); } else { if (pthread_mutex_unlock(&mac->mutex_dl_info)) abort(); - LOG_E(NR_MAC, "Error! All indications were NULL\n"); + LOG_T(NR_MAC, "All indications were NULL in %s\n", __FUNCTION__); return; } @@ -756,6 +759,7 @@ void check_and_process_dci(nfapi_nr_dl_tti_request_t *dl_tti_request, NR_UL_TIME_ALIGNMENT_t ul_time_alignment; memset(&ul_time_alignment, 0, sizeof(ul_time_alignment)); fill_dci_from_dl_config(&mac->dl_info, &mac->dl_config_request); + nr_ue_scheduler(&mac->dl_info, NULL); nr_ue_dl_indication(&mac->dl_info, &ul_time_alignment); if (pthread_mutex_unlock(&mac->mutex_dl_info)) abort(); @@ -776,8 +780,11 @@ void check_and_process_dci(nfapi_nr_dl_tti_request_t *dl_tti_request, mac->scc->tdd_UL_DL_ConfigurationCommon : mac->scc_SIB->tdd_UL_DL_ConfigurationCommon, ul_info.slot_tx, - mac->frame_type)) - nr_ue_ul_indication(&ul_info); + mac->frame_type) && mac->ra.ra_state != RA_SUCCEEDED) + { + nr_ue_scheduler(NULL, &ul_info); + nr_ue_prach_scheduler(ul_info.module_id, ul_info.frame_tx, ul_info.slot_tx, ul_info.thread_id); + } } } @@ -790,19 +797,19 @@ void save_nr_measurement_info(nfapi_nr_dl_tti_request_t *dl_tti_request) LOG_E(NR_PHY, "%s: dl_tti_request number of PDUS <= 0\n", __FUNCTION__); abort(); } - LOG_D(NR_PHY, "%s: dl_tti_request number of PDUS: %d\n", __FUNCTION__, num_pdus); + LOG_T(NR_PHY, "%s: dl_tti_request number of PDUS: %d\n", __FUNCTION__, num_pdus); for (int i = 0; i < num_pdus; i++) { nfapi_nr_dl_tti_request_pdu_t *pdu_list = &dl_tti_request->dl_tti_request_body.dl_tti_pdu_list[i]; if (pdu_list->PDUType == NFAPI_NR_DL_TTI_SSB_PDU_TYPE) { - LOG_D(NR_PHY, "Cell_id: %d, the ssb_block_idx %d, sc_offset: %d and payload %d\n", + LOG_T(NR_PHY, "Cell_id: %d, the ssb_block_idx %d, sc_offset: %d and payload %d\n", pdu_list->ssb_pdu.ssb_pdu_rel15.PhysCellId, pdu_list->ssb_pdu.ssb_pdu_rel15.SsbBlockIndex, pdu_list->ssb_pdu.ssb_pdu_rel15.SsbSubcarrierOffset, pdu_list->ssb_pdu.ssb_pdu_rel15.bchPayload); pdu_list->ssb_pdu.ssb_pdu_rel15.ssbRsrp = 60; - LOG_D(NR_RRC, "Setting pdulist[%d].ssbRsrp to %d\n", i, pdu_list->ssb_pdu.ssb_pdu_rel15.ssbRsrp); + LOG_T(NR_RRC, "Setting pdulist[%d].ssbRsrp to %d\n", i, pdu_list->ssb_pdu.ssb_pdu_rel15.ssbRsrp); } } @@ -820,7 +827,7 @@ void save_nr_measurement_info(nfapi_nr_dl_tti_request_t *dl_tti_request) static void enqueue_nr_nfapi_msg(void *buffer, ssize_t len, nfapi_p7_message_header_t header) { - + NR_UE_MAC_INST_t *mac = get_mac_inst(0); switch (header.message_id) { case NFAPI_NR_PHY_MSG_TYPE_DL_TTI_REQUEST: @@ -832,8 +839,12 @@ static void enqueue_nr_nfapi_msg(void *buffer, ssize_t len, nfapi_p7_message_hea LOG_E(NR_PHY, "Message dl_tti_request failed to unpack\n"); break; } - LOG_I(NR_PHY, "Received an NFAPI_NR_PHY_MSG_TYPE_DL_TTI_REQUEST message in sfn/slot %d %d. \n", + LOG_D(NR_PHY, "Received an NFAPI_NR_PHY_MSG_TYPE_DL_TTI_REQUEST message in sfn/slot %d %d. \n", dl_tti_request->SFN, dl_tti_request->Slot); + + if (is_channel_modeling()) + save_pdsch_pdu_for_crnti(dl_tti_request); + if (!put_queue(&nr_dl_tti_req_queue, dl_tti_request)) { LOG_E(NR_PHY, "put_queue failed for dl_tti_request.\n"); @@ -852,7 +863,7 @@ static void enqueue_nr_nfapi_msg(void *buffer, ssize_t len, nfapi_p7_message_hea LOG_E(NR_PHY, "Message tx_data_request failed to unpack\n"); break; } - LOG_I(NR_PHY, "Received an NFAPI_NR_PHY_MSG_TYPE_TX_DATA_REQUEST message in SFN/slot %d %d. \n", + LOG_D(NR_PHY, "Received an NFAPI_NR_PHY_MSG_TYPE_TX_DATA_REQUEST message in SFN/slot %d %d. \n", tx_data_request->SFN, tx_data_request->Slot); if (!put_queue(&nr_tx_req_queue, tx_data_request)) { @@ -872,7 +883,7 @@ static void enqueue_nr_nfapi_msg(void *buffer, ssize_t len, nfapi_p7_message_hea LOG_E(NR_PHY, "Message ul_dci_request failed to unpack\n"); break; } - LOG_I(NR_PHY, "Received an NFAPI_NR_PHY_MSG_TYPE_UL_DCI_REQUEST message in SFN/slot %d %d. \n", + LOG_D(NR_PHY, "Received an NFAPI_NR_PHY_MSG_TYPE_UL_DCI_REQUEST message in SFN/slot %d %d. \n", ul_dci_request->SFN, ul_dci_request->Slot); if (!put_queue(&nr_ul_dci_req_queue, ul_dci_request)) { @@ -892,30 +903,30 @@ static void enqueue_nr_nfapi_msg(void *buffer, ssize_t len, nfapi_p7_message_hea LOG_E(NR_PHY, "Message ul_tti_request failed to unpack\n"); break; } - LOG_I(NR_PHY, "Received an NFAPI_NR_PHY_MSG_TYPE_UL_TTI_REQUEST message in SFN/slot %d %d.\n", - ul_tti_request->SFN, ul_tti_request->Slot); - if (nr_uci_ind_queue.num_items > 0) //TODO: In the future UL_TTIs can be for ULSCH and SRS. - { - LOG_D(NR_MAC, "We added UL_TTI_REQ to queue for sfn slot %d %d\n", - ul_tti_request->SFN, ul_tti_request->Slot); - if (!put_queue(&nr_ul_tti_req_queue, ul_tti_request)) - { - LOG_E(NR_PHY, "put_queue failed for ul_tti_request.\n"); - free(ul_tti_request); - ul_tti_request = NULL; + /* We are filtering UL_TTI_REQs below. We only care about UL_TTI_REQs that + will trigger sending a ul_harq (CRC/RX pair). This UL_TTI_REQ will have + NFAPI_NR_UL_CONFIG_PUSCH_PDU_TYPE. If we have not yet completed the CBRA/ + CFRA procedure, we need to queue all UL_TTI_REQs. */ + for (int i = 0; i < ul_tti_request->n_pdus; i++) { + if (ul_tti_request->pdus_list[i].pdu_type == NFAPI_NR_UL_CONFIG_PUSCH_PDU_TYPE && + mac->ra.ra_state >= RA_SUCCEEDED) { + if (!put_queue(&nr_ul_tti_req_queue, ul_tti_request)) + { + LOG_D(NR_PHY, "put_queue failed for ul_tti_request, calling put_queue_replace.\n"); + nfapi_nr_ul_tti_request_t *evicted_ul_tti_req = put_queue_replace(&nr_ul_tti_req_queue, ul_tti_request); + free(evicted_ul_tti_req); + } + break; + } + else if (mac->ra.ra_state < RA_SUCCEEDED) { + if (!put_queue(&nr_ul_tti_req_queue, ul_tti_request)) + { + LOG_D(NR_PHY, "put_queue failed for ul_tti_request, calling put_queue_replace.\n"); + nfapi_nr_ul_tti_request_t *evicted_ul_tti_req = put_queue_replace(&nr_ul_tti_req_queue, ul_tti_request); + free(evicted_ul_tti_req); + } + break; } - } - /* TODO: This indicates that dl_tti_req was late or never arrived. If there are - not any prepared uci indications, the NRUE likely never had time to - populate the message is the dl_tti_req came in late and we received a - ul_tti_req immediately after the dl_tti_request. This is an attempt to - mitigate proxy timing issues. */ - else if (nr_uci_ind_queue.num_items == 0) - { - LOG_D(NR_MAC, "We added UL_TTI_REQ to queue for sfn slot %d %d\n", - ul_tti_request->SFN, ul_tti_request->Slot); - nfapi_nr_ul_tti_request_t *evicted_ul_tti_req = put_queue_replace(&nr_wait_ul_tti_req_queue, ul_tti_request); - free(evicted_ul_tti_req); } break; } @@ -928,6 +939,46 @@ static void enqueue_nr_nfapi_msg(void *buffer, ssize_t len, nfapi_p7_message_hea return; } +static void save_pdsch_pdu_for_crnti(nfapi_nr_dl_tti_request_t *dl_tti_request) +{ + int count_sent = 0; + NR_UE_MAC_INST_t *mac = get_mac_inst(0); + int number_of_pdu = dl_tti_request->dl_tti_request_body.nPDUs; + if (number_of_pdu <= 0) + { + LOG_E(NR_MAC, "%s: dl_tti_request pdu size <= 0\n", __FUNCTION__); + abort(); + } + + for (int i = 0; i < number_of_pdu; i++) + { + const nfapi_nr_dl_tti_request_pdu_t *pdu_list = &dl_tti_request->dl_tti_request_body.dl_tti_pdu_list[i]; + + if (pdu_list->PDUType == NFAPI_NR_DL_TTI_PDSCH_PDU_TYPE) + { + const nfapi_nr_dl_tti_pdsch_pdu_rel15_t *pdsch_pdu = &pdu_list->pdsch_pdu.pdsch_pdu_rel15; + if (pdsch_pdu->rnti == mac->crnti && mac->ra.ra_state == RA_SUCCEEDED) + { + read_channel_param(pdsch_pdu, dl_tti_request->Slot, count_sent); + count_sent++; + LOG_T(NR_MAC, "pdsch_pdu->rnti %x mac->crnti %x mac->ra.ra_state %d count_sent %d\n", + pdsch_pdu->rnti, mac->crnti, mac->ra.ra_state, count_sent); + } + } + } +} + +static uint16_t get_message_id(const uint8_t *buffer, ssize_t len) +{ + if (len < 4) + return 0; + + // Unpack 2 bytes message_id from buffer. + uint16_t v; + memcpy(&v, buffer + 2, sizeof(v)); + return ntohs(v); +} + void *nrue_standalone_pnf_task(void *context) { struct sockaddr_in server_address; @@ -957,7 +1008,7 @@ void *nrue_standalone_pnf_task(void *context) uint16_t *sfn_slot = CALLOC(1, sizeof(*sfn_slot)); memcpy(sfn_slot, buffer, sizeof(*sfn_slot)); - LOG_I(NR_PHY, "Received from proxy sfn %d slot %d\n", + LOG_D(NR_PHY, "Received from proxy sfn %d slot %d\n", NFAPI_SFNSLOT2SFN(*sfn_slot), NFAPI_SFNSLOT2SLOT(*sfn_slot)); if (!put_queue(&nr_sfn_slot_queue, sfn_slot)) @@ -971,13 +1022,22 @@ void *nrue_standalone_pnf_task(void *context) abort(); } } - else if (len == sizeof(nr_phy_channel_params_t)) + else if (get_message_id((const uint8_t *)buffer, len) == 0x0FFF) // 0x0FFF : channel info identifier. { nr_phy_channel_params_t *ch_info = CALLOC(1, sizeof(*ch_info)); memcpy(ch_info, buffer, sizeof(*ch_info)); - LOG_D(NR_PHY, "Received_SINR = %f, sfn:slot %d:%d\n", - ch_info->sinr, NFAPI_SFNSLOT2SFN(ch_info->sfn_slot), NFAPI_SFNSLOT2SLOT(ch_info->sfn_slot)); + if (ch_info->nb_of_sinrs > 1) + LOG_W(NR_PHY, "Expecting at most one SINR.\n"); + + // TODO: Update sinr field of slot_rnti_mcs to be array. + for (int i = 0; i < ch_info->nb_of_sinrs; ++i) + { + slot_rnti_mcs[NFAPI_SFNSLOT2SLOT(ch_info->sfn_slot)].sinr = ch_info->sinr[i]; + + LOG_T(NR_PHY, "Received_SINR[%d] = %f, sfn:slot %d:%d\n", + i, ch_info->sinr[i], NFAPI_SFNSLOT2SFN(ch_info->sfn_slot), NFAPI_SFNSLOT2SLOT(ch_info->sfn_slot)); + } if (!put_queue(&nr_chan_param_queue, ch_info)) { @@ -986,7 +1046,7 @@ void *nrue_standalone_pnf_task(void *context) if (sem_post(&sfn_slot_semaphore) != 0) { - LOG_E(MAC, "sem_post() error\n"); + LOG_E(NR_MAC, "sem_post() error\n"); abort(); } } @@ -1005,7 +1065,7 @@ void *nrue_standalone_pnf_task(void *context) // L2 Abstraction Layer int handle_bcch_bch(module_id_t module_id, int cc_id, - unsigned int gNB_index, uint8_t *pduP, + unsigned int gNB_index, void *phy_data, uint8_t *pduP, unsigned int additional_bits, uint32_t ssb_index, uint32_t ssb_length, uint16_t ssb_start_subcarrier, uint16_t cell_id){ @@ -1013,6 +1073,7 @@ int handle_bcch_bch(module_id_t module_id, int cc_id, return nr_ue_decode_mib(module_id, cc_id, gNB_index, + phy_data, additional_bits, ssb_length, // Lssb = 64 is not support ssb_index, @@ -1037,7 +1098,10 @@ int handle_dci(module_id_t module_id, int cc_id, unsigned int gNB_index, frame_t // L2 Abstraction Layer // Note: sdu should always be processed because data and timing advance updates are transmitted by the UE int8_t handle_dlsch(nr_downlink_indication_t *dl_info, NR_UL_TIME_ALIGNMENT_t *ul_time_alignment, int pdu_id){ - + /* L1 assigns harq_pid, but in emulated L1 mode we need to assign + the harq_pid based on the saved global g_harq_pid. Because we are + emulating L1, no antenna measurements are conducted to calculate + a harq_pid, therefore we must set it here. */ if (get_softmodem_params()->emulate_l1) dl_info->rx_ind->rx_indication_body[pdu_id].pdsch_pdu.harq_pid = g_harq_pid; @@ -1058,18 +1122,17 @@ void update_harq_status(module_id_t module_id, uint8_t harq_pid, uint8_t ack_nac if (current_harq->active) { current_harq->ack = ack_nack; current_harq->ack_received = true; - LOG_D(PHY,"Updating harq_status for harq_id %d,ack/nak %d\n",harq_pid,current_harq->ack); + LOG_T(PHY,"Updating harq_status for harq_id %d,ack/nak %d\n",harq_pid,current_harq->ack); } else { //shouldn't get here - LOG_E(MAC, "Trying to process acknack for an inactive harq process (%d)\n", harq_pid); + LOG_E(NR_MAC, "Trying to process acknack for an inactive harq process (%d)\n", harq_pid); } } - int nr_ue_ul_indication(nr_uplink_indication_t *ul_info){ - NR_UE_L2_STATE_t ret; + NR_UE_L2_STATE_t ret=0; module_id_t module_id = ul_info->module_id; NR_UE_MAC_INST_t *mac = get_mac_inst(module_id); @@ -1081,7 +1144,7 @@ int nr_ue_ul_indication(nr_uplink_indication_t *ul_info){ ret = nr_ue_scheduler(NULL, ul_info); } else - LOG_D(NR_MAC, "In %s():%d not calling scheduler. sched mode = %d and mac->ra.ra_state = %d\n", + LOG_T(NR_MAC, "In %s():%d not calling scheduler. sched mode = %d and mac->ra.ra_state = %d\n", __FUNCTION__, __LINE__, ul_info->ue_sched_mode, mac->ra.ra_state); NR_TDD_UL_DL_ConfigCommon_t *tdd_UL_DL_ConfigurationCommon = mac->scc != NULL ? mac->scc->tdd_UL_DL_ConfigurationCommon : mac->scc_SIB->tdd_UL_DL_ConfigurationCommon; @@ -1121,9 +1184,10 @@ int nr_ue_dl_indication(nr_downlink_indication_t *dl_info, NR_UL_TIME_ALIGNMENT_ } else { // UL indication after reception of DCI or DL PDU if (dl_info && dl_info->dci_ind && dl_info->dci_ind->number_of_dcis) { - LOG_D(MAC,"[L2][IF MODULE][DL INDICATION][DCI_IND]\n"); + + LOG_T(MAC,"[L2][IF MODULE][DL INDICATION][DCI_IND]\n"); for (int i = 0; i < dl_info->dci_ind->number_of_dcis; i++) { - LOG_D(MAC,">>>NR_IF_Module i=%d, dl_info->dci_ind->number_of_dcis=%d\n",i,dl_info->dci_ind->number_of_dcis); + LOG_T(MAC,">>>NR_IF_Module i=%d, dl_info->dci_ind->number_of_dcis=%d\n",i,dl_info->dci_ind->number_of_dcis); nr_scheduled_response_t scheduled_response; int8_t ret = handle_dci(dl_info->module_id, dl_info->cc_id, @@ -1137,17 +1201,17 @@ int nr_ue_dl_indication(nr_downlink_indication_t *dl_info, NR_UL_TIME_ALIGNMENT_ /* The check below filters out UL_DCIs (format 7) which are being processed as DL_DCIs. */ if (dci_index->dci_format == 7 && mac->ra.ra_state == RA_SUCCEEDED) { LOG_D(NR_MAC, "We are filtering a UL_DCI to prevent it from being treated like a DL_DCI\n"); - break; + continue; } dci_pdu_rel15_t *def_dci_pdu_rel15 = &mac->def_dci_pdu_rel15[dci_index->dci_format]; g_harq_pid = def_dci_pdu_rel15->harq_pid; - LOG_D(NR_MAC, "Setting harq_pid = %d and dci_index = %d (based on format)\n", g_harq_pid, dci_index->dci_format); + LOG_T(NR_MAC, "Setting harq_pid = %d and dci_index = %d (based on format)\n", g_harq_pid, dci_index->dci_format); ret_mask |= (ret << FAPI_NR_DCI_IND); if (ret >= 0) { AssertFatal( nr_ue_if_module_inst[module_id] != NULL, "IF module is NULL!\n" ); AssertFatal( nr_ue_if_module_inst[module_id]->scheduled_response != NULL, "scheduled_response is NULL!\n" ); - fill_scheduled_response(&scheduled_response, dl_config, NULL, NULL, dl_info->module_id, dl_info->cc_id, dl_info->frame, dl_info->slot, dl_info->thread_id); + fill_scheduled_response(&scheduled_response, dl_config, NULL, NULL, dl_info->module_id, dl_info->cc_id, dl_info->frame, dl_info->slot, dl_info->thread_id, dl_info->phy_data); nr_ue_if_module_inst[module_id]->scheduled_response(&scheduled_response); } memset(def_dci_pdu_rel15, 0, sizeof(*def_dci_pdu_rel15)); @@ -1160,7 +1224,7 @@ int nr_ue_dl_indication(nr_downlink_indication_t *dl_info, NR_UL_TIME_ALIGNMENT_ for (int i=0; irx_ind->number_pdus; ++i) { - LOG_D(MAC, "In %s sending DL indication to MAC. 1 PDU type %d of %d total number of PDUs \n", + LOG_D(NR_MAC, "In %s sending DL indication to MAC. 1 PDU type %d of %d total number of PDUs \n", __FUNCTION__, dl_info->rx_ind->rx_indication_body[i].pdu_type, dl_info->rx_ind->number_pdus); @@ -1168,14 +1232,14 @@ int nr_ue_dl_indication(nr_downlink_indication_t *dl_info, NR_UL_TIME_ALIGNMENT_ switch(dl_info->rx_ind->rx_indication_body[i].pdu_type){ case FAPI_NR_RX_PDU_TYPE_SSB: mac->ssb_rsrp_dBm = (dl_info->rx_ind->rx_indication_body+i)->ssb_pdu.rsrp_dBm; - ret_mask |= (handle_bcch_bch(dl_info->module_id, dl_info->cc_id, dl_info->gNB_index, + ret_mask |= (handle_bcch_bch(dl_info->module_id, dl_info->cc_id, dl_info->gNB_index, dl_info->phy_data, (dl_info->rx_ind->rx_indication_body+i)->ssb_pdu.pdu, (dl_info->rx_ind->rx_indication_body+i)->ssb_pdu.additional_bits, (dl_info->rx_ind->rx_indication_body+i)->ssb_pdu.ssb_index, (dl_info->rx_ind->rx_indication_body+i)->ssb_pdu.ssb_length, (dl_info->rx_ind->rx_indication_body+i)->ssb_pdu.ssb_start_subcarrier, (dl_info->rx_ind->rx_indication_body+i)->ssb_pdu.cell_id)) << FAPI_NR_RX_PDU_TYPE_SSB; - + free((dl_info->rx_ind->rx_indication_body+i)->ssb_pdu.pdu); break; case FAPI_NR_RX_PDU_TYPE_SIB: ret_mask |= (handle_bcch_dlsch(dl_info->module_id, @@ -1244,7 +1308,7 @@ int nr_ue_dcireq(nr_dcireq_t *dcireq) { dl_config->sfn = UE_mac->dl_config_request.sfn; dl_config->slot = UE_mac->dl_config_request.slot; - LOG_D(PHY, "Entering UE DCI configuration frame %d slot %d \n", dcireq->frame, dcireq->slot); + LOG_T(PHY, "Entering UE DCI configuration frame %d slot %d \n", dcireq->frame, dcireq->slot); ue_dci_configuration(UE_mac, dl_config, dcireq->frame, dcireq->slot); @@ -1279,3 +1343,245 @@ void RCconfig_nr_ue_L1(void) { } } } + +/* +static int get_mcs_from_sinr(float sinr) +{ + if (sinr < (nr_bler_data[0].bler_table[0][0])) + { + LOG_D(NR_MAC, "The SINR found is smaller than first MCS table\n"); + return 0; + } + + if (sinr > (nr_bler_data[NR_NUM_MCS-1].bler_table[nr_bler_data[NR_NUM_MCS-1].length - 1][0])) + { + LOG_D(NR_MAC, "The SINR found is larger than last MCS table\n"); + return NR_NUM_MCS-1; + } + + for (int n = NR_NUM_MCS-1; n >= 0; n--) + { + CHECK_INDEX(nr_bler_data, n); + float largest_sinr = (nr_bler_data[n].bler_table[nr_bler_data[n].length - 1][0]); + float smallest_sinr = (nr_bler_data[n].bler_table[0][0]); + if (sinr < largest_sinr && sinr > smallest_sinr) + { + LOG_D(NR_MAC, "The SINR found in MCS %d table\n", n); + return n; + } + } + LOG_E(NR_MAC, "Unable to get an MCS value.\n"); + abort(); +} +*/ + +/* +static int get_cqi_from_mcs(void) +{ + static const int mcs_to_cqi[] = {0, 1, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, + 9, 9, 10, 10, 11, 11, 12, 12, 13, 13, 14, 14, 15}; + assert(NUM_ELEMENTS(mcs_to_cqi) == NR_NUM_MCS); + int slot = 0; + while (slot < NUM_NFAPI_SLOT) + { + if (slot_rnti_mcs[slot].latest) + { + int num_pdus = slot_rnti_mcs[slot].num_pdus; + if (num_pdus <= 0) + { + LOG_E(NR_MAC, "%s: slot_rnti_mcs[%d].num_pdus = 0\n", __FUNCTION__, slot); + abort(); + } + + CHECK_INDEX(slot_rnti_mcs[slot].mcs, num_pdus); + int mcs = get_mcs_from_sinr(slot_rnti_mcs[slot].sinr); + CHECK_INDEX(mcs_to_cqi, mcs); + int cqi = mcs_to_cqi[mcs]; + LOG_D(NR_MAC, "SINR: %f -> MCS: %d -> CQI: %d\n", slot_rnti_mcs[slot].sinr, mcs, cqi); + return cqi; + } + slot++; + } + LOG_E(NR_MAC, "Unable to get CQI value because no MCS found\n"); + abort(); +} +*/ + +static void read_channel_param(const nfapi_nr_dl_tti_pdsch_pdu_rel15_t * pdu, int slot, int index) +{ + if (pdu == NULL) + { + LOG_E(NR_MAC,"PDU NULL\n"); + abort(); + } + + /* This function is executed for every pdsch pdu type in a dl_tti_request. We save + the assocaited MCS and RNTI value for each. The 'index' passed in is a count of + how many times we have called this function for a particular dl_tti_request. It + allows us to save MCS/RNTI data in correct indicies when multiple pdsch pdu's are received.*/ + for (int i = 0; i < NUM_NFAPI_SLOT; i++) + { + slot_rnti_mcs[i].latest = false; + } + + CHECK_INDEX(slot_rnti_mcs[slot].rnti, index); + CHECK_INDEX(slot_rnti_mcs[slot].mcs, index); + CHECK_INDEX(slot_rnti_mcs[slot].drop_flag, index); + slot_rnti_mcs[slot].rnti[index] = pdu->rnti; + slot_rnti_mcs[slot].mcs[index] = pdu->mcsIndex[0]; + slot_rnti_mcs[slot].rvIndex[index] = pdu->rvIndex[0]; + slot_rnti_mcs[slot].drop_flag[index] = false; + slot_rnti_mcs[slot].num_pdus = index+1; //index starts at 0 so we incrament to get num of pdus + slot_rnti_mcs[slot].latest = true; + LOG_D(NR_MAC, "Adding MCS %d and RNTI %x for slot_rnti_mcs[%d]\n", slot_rnti_mcs[slot].mcs[index], slot_rnti_mcs[slot].rnti[index], slot); + + return; +} + +/* +static bool did_drop_transport_block(int slot, uint16_t rnti) +{ + int num_pdus = slot_rnti_mcs[slot].num_pdus; + if (num_pdus <= 0) + { + LOG_E(MAC, "Problem, the PDU size is <= 0. We dropped this packet\n"); + return true; + } + CHECK_INDEX(slot_rnti_mcs[slot].rnti, num_pdus); + CHECK_INDEX(slot_rnti_mcs[slot].drop_flag, num_pdus); + for (int n = 0; n < num_pdus; n++) + { + if (slot_rnti_mcs[slot].rnti[n] == rnti && slot_rnti_mcs[slot].drop_flag[n]) + { + return true; + } + } + return false; +} +*/ + +static float get_bler_val(uint8_t mcs, int sinr) +{ + // 4th col = dropped packets, 5th col = total packets + float bler_val = 0.0; + CHECK_INDEX(nr_bler_data, mcs); + LOG_D(NR_MAC, "sinr %d min %d max %d\n", sinr, + (int)(nr_bler_data[mcs].bler_table[0][0] * 10), + (int)(nr_bler_data[mcs].bler_table[nr_bler_data[mcs].length - 1][0] * 10) + ); + + if (sinr < (int)(nr_bler_data[mcs].bler_table[0][0] * 10)) + { + LOG_D(NR_MAC, "MCS %d table. SINR is smaller than lowest SINR, bler_val is set based on lowest SINR in table\n", mcs); + bler_val = nr_bler_data[mcs].bler_table[0][4] / nr_bler_data[mcs].bler_table[0][5]; + return bler_val; + } + if (sinr > (int)(nr_bler_data[mcs].bler_table[nr_bler_data[mcs].length - 1][0] * 10)) + { + LOG_D(NR_MAC, "MCS %d table. SINR is greater than largest SINR. bler_val is set based on largest SINR in table\n", mcs); + bler_val = nr_bler_data[mcs].bler_table[(nr_bler_data[mcs].length - 1)][4] / nr_bler_data[mcs].bler_table[(nr_bler_data[mcs].length - 1)][5]; + return bler_val; + } + // Loop through bler table to find sinr_index + for (int i = 0; i < nr_bler_data[mcs].length; i++) + { + int temp_sinr = (int)(nr_bler_data[mcs].bler_table[i][0] * 10); + if (temp_sinr == sinr) + { + bler_val = nr_bler_data[mcs].bler_table[i][4] / nr_bler_data[mcs].bler_table[i][5]; + return bler_val; + } + // Linear interpolation when SINR is between indices + if (temp_sinr > sinr) + { + float bler_val1 = nr_bler_data[mcs].bler_table[i - 1][4] / nr_bler_data[mcs].bler_table[i - 1][5]; + float bler_val2 = nr_bler_data[mcs].bler_table[i][4] / nr_bler_data[mcs].bler_table[i][5]; + LOG_D(NR_MAC, "sinr %d min %f max %f\n", sinr, bler_val1, bler_val2); + return ((bler_val1 + bler_val2) / 2); + } + } + LOG_E(NR_MAC, "NO SINR INDEX FOUND!\n"); + abort(); + +} + +static inline bool is_channel_modeling(void) +{ + /* TODO: For now we enable channel modeling based on the node_number. + Replace with a command line option to enable/disable channel modeling. + The LTE UE will crash when channel modeling is conducted for NSA + mode. It does not crash for LTE mode. We have not implemented channel + modeling for NSA mode yet. For now, we ensure only do do channel modeling + in LTE/NR mode. */ + return get_softmodem_params()->node_number == 0 && !get_softmodem_params()->nsa; +} + +static bool should_drop_transport_block(int slot, uint16_t rnti) +{ + if (!is_channel_modeling()) + { + return false; + } + + /* We want to avoid dropping setup messages because this would be pathological. */ + NR_UE_MAC_INST_t *mac = get_mac_inst(0); + if (mac->ra.ra_state < RA_SUCCEEDED) + { + LOG_D(NR_MAC, "Not dropping because MAC state: %d", mac->ra.ra_state); + return false; + } + + /* Get block error rate (bler_val) from table based on every saved + MCS and SINR to be used as the cutoff rate for dropping packets. + Generate random uniform vairable to compare against bler_val. */ + int num_pdus = slot_rnti_mcs[slot].num_pdus; + assert(slot < 20 && slot >= 0); + LOG_D(NR_MAC, "rnti: %x num_pdus %d state %d slot %u sinr %f\n", + rnti, num_pdus, mac->ra.ra_state, slot, slot_rnti_mcs[slot].sinr); + assert(num_pdus > 0); + CHECK_INDEX(slot_rnti_mcs[slot].rnti, num_pdus); + CHECK_INDEX(slot_rnti_mcs[slot].mcs, num_pdus); + CHECK_INDEX(slot_rnti_mcs[slot].drop_flag, num_pdus); + int n = 0; + uint8_t mcs = 99; + for (n = 0; n < num_pdus; n++) + { + if (slot_rnti_mcs[slot].rnti[n] == rnti) + { + mcs = slot_rnti_mcs[slot].mcs[n]; + } + if (mcs != 99) + { + /* Use MCS to get the bler value. Since there can be multiple MCS + values for a particular slot, we verify that all PDUs are not + flagged for drop before returning. If even one is flagged for drop + we return immediately because we drop the entire packet. */ + + LOG_D(NR_MAC, "rnti: %x mcs %u slot %u sinr %f\n", + slot_rnti_mcs[slot].rnti[n], mcs, slot, slot_rnti_mcs[slot].sinr); + + float bler_val; + if (slot_rnti_mcs[slot].rvIndex[n] != 0) + bler_val = 0; + else + bler_val = get_bler_val(mcs, ((int)(slot_rnti_mcs[slot].sinr * 10))); + double drop_cutoff = ((double) rand() / (RAND_MAX)); + assert(drop_cutoff <= 1); + LOG_D(NR_MAC, "SINR = %f, Bler_val = %f, MCS = %"PRIu8"\n", slot_rnti_mcs[slot].sinr, bler_val, slot_rnti_mcs[slot].mcs[n]); + if (drop_cutoff <= bler_val) + { + slot_rnti_mcs[slot].drop_flag[n] = true; + LOG_T(NR_MAC, "We are dropping this packet. Bler_val = %f, MCS = %"PRIu8", slot = %d\n", bler_val, slot_rnti_mcs[slot].mcs[n], slot); + return slot_rnti_mcs[slot].drop_flag[n]; + } + } + + } + + if (mcs == 99) + { + LOG_E(NR_MAC, "NO MCS Found for rnti %x. slot_rnti_mcs[%d].mcs[%d] \n", rnti, slot, n); + abort(); + } + return false; +} diff --git a/openair2/NR_UE_PHY_INTERFACE/NR_IF_Module.h b/openair2/NR_UE_PHY_INTERFACE/NR_IF_Module.h index 2a8a514769..45d1a071ca 100755 --- a/openair2/NR_UE_PHY_INTERFACE/NR_IF_Module.h +++ b/openair2/NR_UE_PHY_INTERFACE/NR_IF_Module.h @@ -41,15 +41,44 @@ #include "nfapi_nr_interface_scf.h" #include "openair2/NR_PHY_INTERFACE/NR_IF_Module.h" +#define NR_NUM_MCS 29 +#define NUM_SINR 100 +#define NUM_BLER_COL 13 +#define NUM_NFAPI_SLOT 20 +#define NR_NUM_LAYER 1 + typedef struct NR_UL_TIME_ALIGNMENT NR_UL_TIME_ALIGNMENT_t; typedef struct nr_phy_channel_params_t { uint16_t sfn_slot; - float sinr; + uint16_t message_id; + uint16_t nb_of_sinrs; + float sinr[NR_NUM_LAYER]; // Incomplete, need all channel parameters } nr_phy_channel_params_t; +typedef struct +{ + uint8_t slot; + uint16_t rnti[256]; + uint8_t mcs[256]; + uint8_t rvIndex[256]; + float sinr; + uint16_t num_pdus; + bool drop_flag[256]; + bool latest; + +} slot_rnti_mcs_s; + +typedef struct +{ + uint16_t length; + float bler_table[NUM_SINR][NUM_BLER_COL]; +} nr_bler_struct; + +extern nr_bler_struct nr_bler_data[NR_NUM_MCS]; + typedef enum { ONLY_PUSCH, NOT_PUSCH, @@ -94,6 +123,9 @@ typedef struct { /// dci reception indication structure fapi_nr_dci_indication_t *dci_ind; + /// PHY specific data structure that can be passed on to L2 via nr_downlink_indication_t and + /// back to L1 via the nr_scheduled_response_t + void *phy_data; } nr_downlink_indication_t; @@ -147,6 +179,9 @@ typedef struct { /// data transmission request structure fapi_nr_tx_request_t *tx_request; + /// PHY data structure initially passed on to L2 via the nr_downlink_indication_t and + /// returned to L1 via nr_scheduled_response_t + void *phy_data; } nr_scheduled_response_t; typedef struct { @@ -240,6 +275,8 @@ void check_and_process_dci(nfapi_nr_dl_tti_request_t *dl_tti_request, nfapi_nr_ul_dci_request_t *ul_dci_request, nfapi_nr_ul_tti_request_t *ul_tti_request); +bool sfn_slot_matcher(void *wanted, void *candidate); + /**\brief done free of memory allocation by module_id and release to pointer pool. \param module_id module id*/ int nr_ue_if_module_kill(uint32_t module_id); @@ -255,6 +292,7 @@ int nr_ue_dcireq(nr_dcireq_t *dcireq); // TODO check /**\brief handle BCCH-BCH message from dl_indication + \param phy_data PHY structure to be filled in by the callee in the FAPI call (L1 caller -> indication to L2 -> FAPI call to L1 callee) \param pduP pointer to bch pdu \param additional_bits corresponding to 38.212 ch.7 \param ssb_index SSB index within 0 - (L_ssb-1) corresponding to 38.331 ch.13 parameter i @@ -263,6 +301,7 @@ int nr_ue_dcireq(nr_dcireq_t *dcireq); int handle_bcch_bch(module_id_t module_id, int cc_id, unsigned int gNB_index, + void *phy_data, uint8_t *pduP, unsigned int additional_bits, uint32_t ssb_index, diff --git a/openair2/PHY_INTERFACE/IF_Module.c b/openair2/PHY_INTERFACE/IF_Module.c index fba9e1d8b6..68d390f097 100644 --- a/openair2/PHY_INTERFACE/IF_Module.c +++ b/openair2/PHY_INTERFACE/IF_Module.c @@ -16,7 +16,7 @@ extern int oai_nfapi_cqi_indication(nfapi_cqi_indication_t *cqi_ind); extern int oai_nfapi_sr_indication(nfapi_sr_indication_t *ind); extern int oai_nfapi_rx_ind(nfapi_rx_indication_t *ind); -extern uint16_t sf_ahead; +int sf_ahead=4; extern UL_RCC_IND_t UL_RCC_INFO; extern RAN_CONTEXT_t RC; diff --git a/openair2/PHY_INTERFACE/phy_stub_UE.c b/openair2/PHY_INTERFACE/phy_stub_UE.c index 1598e3d620..c4650f18f3 100644 --- a/openair2/PHY_INTERFACE/phy_stub_UE.c +++ b/openair2/PHY_INTERFACE/phy_stub_UE.c @@ -1259,6 +1259,17 @@ void ue_init_standalone_socket(int tx_port, int rx_port) } } +static uint16_t get_message_id(const uint8_t *buffer, ssize_t len) +{ + if (len < 4) + return 0; + + // Unpack 2 bytes message_id from buffer. + uint16_t v; + memcpy(&v, buffer + 2, sizeof(v)); + return ntohs(v); +} + void *ue_standalone_pnf_task(void *context) { struct sockaddr_in server_address; @@ -1301,7 +1312,7 @@ void *ue_standalone_pnf_task(void *context) abort(); } } - else if (len == sizeof(phy_channel_params_t)) + else if (get_message_id((const uint8_t *)buffer, len) == 0x0FFF) // 0x0FFF : channel info identifier. { phy_channel_params_t ch_info; memcpy(&ch_info, buffer, sizeof(phy_channel_params_t)); @@ -1314,8 +1325,15 @@ void *ue_standalone_pnf_task(void *context) uint16_t sf = ch_info.sfn_sf & 15; assert(sf < 10); - sf_rnti_mcs[sf].sinr = ch_info.sinr; - LOG_D(MAC, "Received_SINR = %f\n",ch_info.sinr); + if (ch_info.nb_of_sinrs > 1) + LOG_W(MAC, "Expecting at most one SINR.\n"); + + // TODO: Update sinr field of slot_rnti_mcs to be array. + for (int i = 0; i < ch_info.nb_of_sinrs; ++i) + { + sf_rnti_mcs[sf].sinr = ch_info.sinr[i]; + LOG_D(MAC, "Received_SINR[%d] = %f\n", i, ch_info.sinr[i]); + } } else { diff --git a/openair2/PHY_INTERFACE/phy_stub_UE.h b/openair2/PHY_INTERFACE/phy_stub_UE.h index ebaae6e667..d68d1dffdd 100644 --- a/openair2/PHY_INTERFACE/phy_stub_UE.h +++ b/openair2/PHY_INTERFACE/phy_stub_UE.h @@ -24,6 +24,7 @@ #define NUM_MCS 28 #define NUM_SINR 100 #define NUM_BLER_COL 13 +#define LTE_NUM_LAYER 1 // this mutex is used to set multiple UE's UL value in L2 FAPI simulator. extern FILL_UL_INFO_MUTEX_t fill_ul_mutex; @@ -126,7 +127,9 @@ void handle_nfapi_ul_pdu_UE_MAC(module_id_t Mod_id, typedef struct phy_channel_params_t { uint16_t sfn_sf; - float sinr; + uint16_t message_id; + uint16_t nb_of_sinrs; + float sinr[LTE_NUM_LAYER]; // Incomplete, need all channel parameters } phy_channel_params_t; diff --git a/openair2/PHY_INTERFACE/queue_t.h b/openair2/PHY_INTERFACE/queue_t.h index 4678e31030..5c644a320c 100644 --- a/openair2/PHY_INTERFACE/queue_t.h +++ b/openair2/PHY_INTERFACE/queue_t.h @@ -24,7 +24,8 @@ } */ -#pragma once +#ifndef __OPENAIR2_PHY_INTERFACE_QUEUE_T__H__ +#define __OPENAIR2_PHY_INTERFACE_QUEUE_T__H__ #include #include @@ -62,3 +63,5 @@ typedef bool queue_matcher_t(void *wanted, void *candidate); Look only at the last `max_depth` items on the queue, at most. Returns the candidate item, or NULL if none matches */ void *unqueue_matching(queue_t *q, size_t max_depth, queue_matcher_t *matcher, void *wanted); + +#endif /* __OPENAIR2_PHY_INTERFACE_QUEUE_T__H__ */ diff --git a/openair2/RRC/LTE/MESSAGES/asn1_msg.c b/openair2/RRC/LTE/MESSAGES/asn1_msg.c index c3e41978e5..c34c65b195 100644 --- a/openair2/RRC/LTE/MESSAGES/asn1_msg.c +++ b/openair2/RRC/LTE/MESSAGES/asn1_msg.c @@ -1331,10 +1331,8 @@ uint8_t do_SIB23(uint8_t Mod_id, (*sib2)->radioResourceConfigCommon.rach_ConfigCommon.ext1 = calloc(1, sizeof(struct LTE_RACH_ConfigCommon__ext1)); memset((*sib2)->radioResourceConfigCommon.rach_ConfigCommon.ext1, 0, sizeof(struct LTE_RACH_ConfigCommon__ext1)); - if (rrconfig->preambleTransMax_CE_r13) { - (*sib2)->radioResourceConfigCommon.rach_ConfigCommon.ext1->preambleTransMax_CE_r13 = calloc(1, sizeof(LTE_PreambleTransMax_t)); - *(*sib2)->radioResourceConfigCommon.rach_ConfigCommon.ext1->preambleTransMax_CE_r13 = *rrconfig->preambleTransMax_CE_r13; // to be re-initialized when we find the enum - } else (*sib2)->radioResourceConfigCommon.rach_ConfigCommon.ext1->preambleTransMax_CE_r13 = NULL; + (*sib2)->radioResourceConfigCommon.rach_ConfigCommon.ext1->preambleTransMax_CE_r13 = calloc(1, sizeof(LTE_PreambleTransMax_t)); + *(*sib2)->radioResourceConfigCommon.rach_ConfigCommon.ext1->preambleTransMax_CE_r13 = rrconfig->preambleTransMax_CE_r13; // to be re-initialized when we find the enum (*sib2)->radioResourceConfigCommon.rach_ConfigCommon.ext1->rach_CE_LevelInfoList_r13 = calloc(1, sizeof(LTE_RACH_CE_LevelInfoList_r13_t)); memset((*sib2)->radioResourceConfigCommon.rach_ConfigCommon.ext1->rach_CE_LevelInfoList_r13, 0, sizeof(LTE_RACH_CE_LevelInfoList_r13_t)); @@ -4297,6 +4295,7 @@ ssize_t do_nrMeasurementReport(uint8_t *buffer, If we delete this asn1cCalloc statement, eNB will crash in NSA mode. Please don't delete the following line unless the bug has been found. */ asn1cCalloc(measresulteutra_list->cgi_Info, measresult_cgi2); + (void) measresult_cgi2; struct LTE_MeasResultEUTRA__measResult* measResult= &measresulteutra_list->measResult; asn1cCallocOne(measResult->rsrpResult, rsrp_tar); asn1cCallocOne(measResult->rsrqResult, rsrq_tar); diff --git a/openair2/RRC/LTE/MESSAGES/asn1_msg.h b/openair2/RRC/LTE/MESSAGES/asn1_msg.h index d1d1d3febe..8373bb53f3 100644 --- a/openair2/RRC/LTE/MESSAGES/asn1_msg.h +++ b/openair2/RRC/LTE/MESSAGES/asn1_msg.h @@ -28,6 +28,9 @@ * \email: raymond.knopp@eurecom.fr and navid.nikaein@eurecom.fr */ +#ifndef __RRC_LTE_MESSAGES_ASN1_MSG__H__ +#define __RRC_LTE_MESSAGES_ASN1_MSG__H__ + #include #include #include /* for atoi(3) */ @@ -405,3 +408,5 @@ uint8_t do_SecurityModeCommand( const uint8_t Transaction_id, const uint8_t cipheringAlgorithm, const uint8_t integrityProtAlgorithm); + +#endif /* __RRC_LTE_MESSAGES_ASN1_MSG__H__ */ diff --git a/openair2/RRC/LTE/defs_NB_IoT.h b/openair2/RRC/LTE/defs_NB_IoT.h index 37a26086b5..c76bdea53f 100644 --- a/openair2/RRC/LTE/defs_NB_IoT.h +++ b/openair2/RRC/LTE/defs_NB_IoT.h @@ -148,7 +148,7 @@ typedef struct UE_RRC_INFO_NB_IoT_s { //Measurement Report not supported in NB-IoT #define PAYLOAD_SIZE_MAX 1024 -#define RRC_BUF_SIZE 512 +#define RRC_BUF_SIZE 1024 #define UNDEF_SECURITY_MODE 0xff #define NO_SECURITY_MODE 0x20 diff --git a/openair2/RRC/LTE/rrc_UE.c b/openair2/RRC/LTE/rrc_UE.c index b46bba2492..9b37853ed2 100644 --- a/openair2/RRC/LTE/rrc_UE.c +++ b/openair2/RRC/LTE/rrc_UE.c @@ -3175,7 +3175,8 @@ int decode_SIB1( const protocol_ctxt_t *const ctxt_pP, const uint8_t eNB_index, const size_t num_plmn_data = sizeof(plmn_data) / sizeof(plmn_data[0]); for (size_t plmn_ind = 0;; ++plmn_ind) { if (plmn_ind == num_plmn_data) { - LOG_E( RRC, "Did not find name from internal table for %u %u\n", mcc, mnc); + LOG_W( RRC, "Did not find operator name from internal table for MCC %0*d, MNC %0*d\n", + mccdigits, mcc, mncdigits, mnc); break; } if ((plmn_data[plmn_ind].mcc == mcc) && (plmn_data[plmn_ind].mnc == mnc)) { diff --git a/openair2/RRC/LTE/rrc_defs.h b/openair2/RRC/LTE/rrc_defs.h index f537dcbbd2..64baf5e2ac 100644 --- a/openair2/RRC/LTE/rrc_defs.h +++ b/openair2/RRC/LTE/rrc_defs.h @@ -316,7 +316,7 @@ typedef enum SL_TRIGGER_e { #define MAX_MEAS_ID 7 #define PAYLOAD_SIZE_MAX 1024 -#define RRC_BUF_SIZE 512 +#define RRC_BUF_SIZE 1024 #define UNDEF_SECURITY_MODE 0xff #define NO_SECURITY_MODE 0x20 @@ -484,7 +484,7 @@ typedef struct MEASUREMENT_INFO_s { typedef struct { char Payload[RRC_BUFFER_SIZE_MAX]; char Header[RRC_HEADER_SIZE_MAX]; - char payload_size; + uint16_t payload_size; } RRC_BUFFER; #define RRC_BUFFER_SIZE sizeof(RRC_BUFFER) diff --git a/openair2/RRC/LTE/rrc_eNB_S1AP.c b/openair2/RRC/LTE/rrc_eNB_S1AP.c index 9b9e267828..f24c9ab1b6 100644 --- a/openair2/RRC/LTE/rrc_eNB_S1AP.c +++ b/openair2/RRC/LTE/rrc_eNB_S1AP.c @@ -1757,7 +1757,7 @@ int rrc_eNB_process_PAGING_IND(MessageDef *msg_p, const char *msg_name, instance && RC.rrc[instance]->configuration.mnc[j] == S1AP_PAGING_IND(msg_p).plmn_identity[tai_size].mnc && RC.rrc[instance]->configuration.tac == S1AP_PAGING_IND(msg_p).tac[tai_size]) { for (uint8_t CC_id = 0; CC_id < MAX_NUM_CCs; CC_id++) { - lte_frame_type_t frame_type = RC.eNB[instance][CC_id]->frame_parms.frame_type; + frame_type_t frame_type = RC.eNB[instance][CC_id]->frame_parms.frame_type; /* get nB from configuration */ /* get default DRX cycle from configuration */ Tc = (uint8_t)RC.rrc[instance]->configuration.radioresourceconfig[CC_id].pcch_defaultPagingCycle; diff --git a/openair2/RRC/NR/L2_nr_interface.c b/openair2/RRC/NR/L2_nr_interface.c index 1cf690ac0c..952f32fb10 100644 --- a/openair2/RRC/NR/L2_nr_interface.c +++ b/openair2/RRC/NR/L2_nr_interface.c @@ -207,90 +207,103 @@ nr_rrc_data_req( return TRUE; // TODO should be changed to a CNF message later, currently RRC lite does not used the returned value anyway. } -int8_t mac_rrc_nr_data_req(const module_id_t Mod_idP, - const int CC_id, - const frame_t frameP, - const rb_id_t Srb_id, - const rnti_t rnti, - const uint8_t Nb_tb, - uint8_t *const buffer_pP ){ +uint16_t mac_rrc_nr_data_req(const module_id_t Mod_idP, + const int CC_id, + const frame_t frameP, + const rb_id_t Srb_id, + const rnti_t rnti, + const uint8_t Nb_tb, + uint8_t *const buffer_pP ){ #ifdef DEBUG_RRC LOG_D(RRC,"[eNB %d] mac_rrc_data_req to SRB ID=%ld\n",Mod_idP,Srb_id); #endif - // MIBCH - if ((Srb_id & RAB_OFFSET) == MIBCH) { + // MIBCH + if ((Srb_id & RAB_OFFSET) == MIBCH) { - asn_enc_rval_t enc_rval; - uint8_t sfn_msb = (uint8_t)((frameP>>4)&0x3f); - rrc_gNB_carrier_data_t *carrier = &RC.nrrrc[Mod_idP]->carrier; - NR_BCCH_BCH_Message_t *mib = &carrier->mib; + asn_enc_rval_t enc_rval; + uint8_t sfn_msb = (uint8_t)((frameP>>4)&0x3f); + rrc_gNB_carrier_data_t *carrier = &RC.nrrrc[Mod_idP]->carrier; + NR_BCCH_BCH_Message_t *mib = &carrier->mib; - // Currently we are getting the pdcch_ConfigSIB1 from the configuration file. - // Uncomment this function for a dynamic pdcch_ConfigSIB1. - //channel_bandwidth_t min_channel_bw = bw_10MHz; // Must be obtained based on TS 38.101-1 Table 5.3.5-1 - //generate_pdcch_ConfigSIB1(carrier->pdcch_ConfigSIB1, - // *carrier->servingcellconfigcommon->ssbSubcarrierSpacing, - // carrier->mib.message.choice.mib->subCarrierSpacingCommon, - // min_channel_bw); + // Currently we are getting the pdcch_ConfigSIB1 from the configuration file. + // Uncomment this function for a dynamic pdcch_ConfigSIB1. + //channel_bandwidth_t min_channel_bw = bw_10MHz; // Must be obtained based on TS 38.101-1 Table 5.3.5-1 + //generate_pdcch_ConfigSIB1(carrier->pdcch_ConfigSIB1, + // *carrier->servingcellconfigcommon->ssbSubcarrierSpacing, + // carrier->mib.message.choice.mib->subCarrierSpacingCommon, + // min_channel_bw); - mib->message.choice.mib->pdcch_ConfigSIB1.controlResourceSetZero = carrier->pdcch_ConfigSIB1->controlResourceSetZero; - mib->message.choice.mib->pdcch_ConfigSIB1.searchSpaceZero = carrier->pdcch_ConfigSIB1->searchSpaceZero; + mib->message.choice.mib->pdcch_ConfigSIB1.controlResourceSetZero = carrier->pdcch_ConfigSIB1->controlResourceSetZero; + mib->message.choice.mib->pdcch_ConfigSIB1.searchSpaceZero = carrier->pdcch_ConfigSIB1->searchSpaceZero; - mib->message.choice.mib->systemFrameNumber.buf[0] = sfn_msb << 2; - enc_rval = uper_encode_to_buffer(&asn_DEF_NR_BCCH_BCH_Message, - NULL, - (void *) mib, - carrier->MIB, - 24); - LOG_D(NR_RRC, "Encoded MIB for frame %d sfn_msb %d (%p), bits %lu\n", frameP, sfn_msb, carrier->MIB, - enc_rval.encoded); - buffer_pP[0] = carrier->MIB[0]; - buffer_pP[1] = carrier->MIB[1]; - buffer_pP[2] = carrier->MIB[2]; - LOG_D(NR_RRC, "MIB PDU buffer_pP[0]=%x , buffer_pP[1]=%x, buffer_pP[2]=%x\n", buffer_pP[0], buffer_pP[1], - buffer_pP[2]); - AssertFatal (enc_rval.encoded > 0, "ASN1 message encoding failed (%s, %lu)!\n", - enc_rval.failed_type->name, enc_rval.encoded); - return (3); - } + mib->message.choice.mib->systemFrameNumber.buf[0] = sfn_msb << 2; + enc_rval = uper_encode_to_buffer(&asn_DEF_NR_BCCH_BCH_Message, + NULL, + (void *) mib, + carrier->MIB, + 24); + LOG_D(NR_RRC, "Encoded MIB for frame %d sfn_msb %d (%p), bits %lu\n", frameP, sfn_msb, carrier->MIB, + enc_rval.encoded); + buffer_pP[0] = carrier->MIB[0]; + buffer_pP[1] = carrier->MIB[1]; + buffer_pP[2] = carrier->MIB[2]; + LOG_D(NR_RRC, "MIB PDU buffer_pP[0]=%x , buffer_pP[1]=%x, buffer_pP[2]=%x\n", buffer_pP[0], buffer_pP[1], + buffer_pP[2]); + AssertFatal (enc_rval.encoded > 0, "ASN1 message encoding failed (%s, %lu)!\n", + enc_rval.failed_type->name, enc_rval.encoded); + return 3; + } // TODO BCCH SIB1 SIBs - if ((Srb_id & RAB_OFFSET ) == BCCH) { - memcpy(&buffer_pP[0], - RC.nrrrc[Mod_idP]->carrier.SIB1, - RC.nrrrc[Mod_idP]->carrier.sizeof_SIB1); - + if ((Srb_id & RAB_OFFSET) == BCCH) { + memcpy(&buffer_pP[0], RC.nrrrc[Mod_idP]->carrier.SIB1, RC.nrrrc[Mod_idP]->carrier.sizeof_SIB1); return RC.nrrrc[Mod_idP]->carrier.sizeof_SIB1; } // CCCH - if( (Srb_id & RAB_OFFSET ) == CCCH) { + if ((Srb_id & RAB_OFFSET) == CCCH) { + LOG_D(NR_RRC,"[gNB %d] Frame %d CCCH request (Srb_id %ld)\n", Mod_idP, frameP, Srb_id); char *payload_pP; - uint8_t Sdu_size = 0; struct rrc_gNB_ue_context_s *ue_context_p = rrc_gNB_get_ue_context(RC.nrrrc[Mod_idP], rnti); LOG_D(NR_RRC,"[gNB %d] Frame %d CCCH request (Srb_id %ld)\n", Mod_idP, frameP, Srb_id); + if (ue_context_p == NULL) { + LOG_E(NR_RRC,"[gNB %d] Frame %d CCCH request but no ue_context\n", Mod_idP, frameP); + return 0; + } - AssertFatal(ue_context_p!=NULL,"failed to get ue_context, rnti %x\n",rnti); - char payload_size = ue_context_p->ue_context.Srb0.Tx_buffer.payload_size; - + uint16_t payload_size = ue_context_p->ue_context.Srb0.Tx_buffer.payload_size; // check if data is there for MAC if (payload_size > 0) { payload_pP = ue_context_p->ue_context.Srb0.Tx_buffer.Payload; LOG_D(NR_RRC,"[gNB %d] CCCH has %d bytes (dest: %p, src %p)\n", Mod_idP, payload_size, buffer_pP, payload_pP); // Fill buffer memcpy((void *)buffer_pP, (void*)payload_pP, payload_size); - Sdu_size = payload_size; ue_context_p->ue_context.Srb0.Tx_buffer.payload_size = 0; } - return Sdu_size; + return payload_size; } - return(0); + return 0; +} +int8_t nr_mac_rrc_bwp_switch_req(const module_id_t module_idP, + const frame_t frameP, + const sub_frame_t sub_frameP, + const rnti_t rntiP, + const int dl_bwp_id, + const int ul_bwp_id) { + + struct rrc_gNB_ue_context_s *ue_context_p = rrc_gNB_get_ue_context(RC.nrrrc[module_idP], rntiP); + + protocol_ctxt_t ctxt; + PROTOCOL_CTXT_SET_BY_MODULE_ID(&ctxt, module_idP, GNB_FLAG_YES, rntiP, frameP, sub_frameP, 0); + nr_rrc_reconfiguration_req(ue_context_p, &ctxt, dl_bwp_id, ul_bwp_id); + + return 0; } int8_t nr_mac_rrc_data_ind(const module_id_t module_idP, @@ -312,6 +325,7 @@ int8_t nr_mac_rrc_data_ind(const module_id_t module_idP, // call do_RRCSetup like full procedure and extract masterCellGroup NR_CellGroupConfig_t cellGroupConfig; NR_ServingCellConfigCommon_t *scc=RC.nrrrc[module_idP]->carrier.servingcellconfigcommon; + NR_ServingCellConfig_t *servingcellconfigdedicated = RC.nrrrc[module_idP]->configuration.scd; memset(&cellGroupConfig,0,sizeof(cellGroupConfig)); struct rrc_gNB_ue_context_s *ue_context_p = rrc_gNB_allocate_new_UE_context(RC.nrrrc[module_idP]); @@ -321,16 +335,16 @@ int8_t nr_mac_rrc_data_ind(const module_id_t module_idP, ue_context_p->ue_context.Srb0.Active = 1; RB_INSERT(rrc_nr_ue_tree_s, &RC.nrrrc[module_idP]->rrc_ue_head, ue_context_p); - fill_initial_cellGroupConfig(ue_context_p->local_uid,&cellGroupConfig,scc,&RC.nrrrc[module_idP]->carrier); + fill_initial_cellGroupConfig(ue_context_p->local_uid,&cellGroupConfig,scc,servingcellconfigdedicated,&RC.nrrrc[module_idP]->configuration); MessageDef* tmp=itti_alloc_new_message_sized(TASK_RRC_GNB, 0, F1AP_INITIAL_UL_RRC_MESSAGE, sizeof(f1ap_initial_ul_rrc_message_t) + sdu_lenP); f1ap_initial_ul_rrc_message_t *msg = &F1AP_INITIAL_UL_RRC_MESSAGE(tmp); asn_enc_rval_t enc_rval = uper_encode_to_buffer(&asn_DEF_NR_CellGroupConfig, - NULL, - (void *)&cellGroupConfig, - msg->du2cu_rrc_container, - 1024); //sizeof(msg->du2cu_rrc_container)); + NULL, + (void *)&cellGroupConfig, + msg->du2cu_rrc_container, + F1AP_MAX_DU2CU_RRC_LENGTH); if (enc_rval.encoded == -1) { LOG_E(F1AP,"Could not encoded cellGroupConfig, failed element %s\n",enc_rval.failed_type->name); diff --git a/openair2/RRC/NR/MESSAGES/asn1_msg.c b/openair2/RRC/NR/MESSAGES/asn1_msg.c index d04ed78270..d38a8ff13d 100755 --- a/openair2/RRC/NR/MESSAGES/asn1_msg.c +++ b/openair2/RRC/NR/MESSAGES/asn1_msg.c @@ -40,7 +40,9 @@ #include /* for _ASN_DEFAULT_STACK_MAX */ #include #include +#include +#include "LAYER2/nr_rlc/nr_rlc_oai_api.h" #include "asn1_msg.h" #include "../nr_rrc_proto.h" #include "RRC/NR/nr_rrc_extern.h" @@ -197,6 +199,7 @@ uint8_t do_MIB_NR(gNB_RRC_INST *rrc,uint32_t frame) { asn_enc_rval_t enc_rval; rrc_gNB_carrier_data_t *carrier = &rrc->carrier; + const gNB_RrcConfigurationReq *configuration = &rrc->configuration; NR_BCCH_BCH_Message_t *mib = &carrier->mib; NR_ServingCellConfigCommon_t *scc = carrier->servingcellconfigcommon; @@ -220,7 +223,15 @@ uint8_t do_MIB_NR(gNB_RRC_INST *rrc,uint32_t frame) { mib->message.choice.mib->spare.size = 1; mib->message.choice.mib->spare.bits_unused = 7; // This makes a spare of 1 bits - mib->message.choice.mib->ssb_SubcarrierOffset = (carrier->ssb_SubcarrierOffset)&15; + AssertFatal(scc->ssbSubcarrierSpacing != NULL, "scc->ssbSubcarrierSpacing is null\n"); + int band = *scc->downlinkConfigCommon->frequencyInfoDL->frequencyBandList.list.array[0]; + frequency_range_t frequency_range = band<100?FR1:FR2; + int ssb_subcarrier_offset; + if(frequency_range == FR1) + ssb_subcarrier_offset = (configuration->ssb_SubcarrierOffset<24) ? (configuration->ssb_SubcarrierOffset<<*scc->ssbSubcarrierSpacing) : configuration->ssb_SubcarrierOffset; + else + ssb_subcarrier_offset = configuration->ssb_SubcarrierOffset; + mib->message.choice.mib->ssb_SubcarrierOffset = ssb_subcarrier_offset&15; /* * The SIB1 will be sent in this allocation (Type0-PDCCH) : 38.213, 13-4 Table and 38.213 13-11 to 13-14 tables @@ -234,7 +245,6 @@ uint8_t do_MIB_NR(gNB_RRC_INST *rrc,uint32_t frame) { mib->message.choice.mib->pdcch_ConfigSIB1.searchSpaceZero = *scc->downlinkConfigCommon->initialDownlinkBWP->pdcch_ConfigCommon->choice.setup->searchSpaceZero; } - AssertFatal(scc->ssbSubcarrierSpacing != NULL, "scc->ssbSubcarrierSpacing is null\n"); switch (*scc->ssbSubcarrierSpacing) { case NR_SubcarrierSpacing_kHz15: mib->message.choice.mib->subCarrierSpacingCommon = NR_MIB__subCarrierSpacingCommon_scs15or60; @@ -394,7 +404,6 @@ uint8_t do_SIB1_NR(rrc_gNB_carrier_data_t *carrier, NR_BWP_DownlinkCommon_t *initialDownlinkBWP=&ServCellCom->downlinkConfigCommon.initialDownlinkBWP; initialDownlinkBWP->genericParameters= configuration->scc->downlinkConfigCommon->initialDownlinkBWP->genericParameters; - for(int i = 0; i< configuration->scc->downlinkConfigCommon->frequencyInfoDL->frequencyBandList.list.count; i++) { asn1cSequenceAdd(ServCellCom->downlinkConfigCommon.frequencyInfoDL.frequencyBandList.list, @@ -402,7 +411,6 @@ uint8_t do_SIB1_NR(rrc_gNB_carrier_data_t *carrier, nrMultiBandInfo->freqBandIndicatorNR = configuration->scc->downlinkConfigCommon->frequencyInfoDL->frequencyBandList.list.array[i]; } - int scs_scaling0 = 1<<(configuration->scc->downlinkConfigCommon->initialDownlinkBWP->genericParameters.subcarrierSpacing); int scs_scaling = scs_scaling0; int scs_scaling2 = scs_scaling0; @@ -511,7 +519,6 @@ uint8_t do_SIB1_NR(rrc_gNB_carrier_data_t *carrier, ss7->searchSpaceType->choice.common=calloc(1,sizeof(*ss7->searchSpaceType->choice.common)); ss7->searchSpaceType->choice.common->dci_Format0_0_AndFormat1_0 = calloc(1,sizeof(*ss7->searchSpaceType->choice.common->dci_Format0_0_AndFormat1_0)); - asn1cCallocOne(initialDownlinkBWP->pdcch_ConfigCommon->choice.setup->searchSpaceSIB1, 0); asn1cCallocOne(initialDownlinkBWP->pdcch_ConfigCommon->choice.setup->searchSpaceOtherSystemInformation, 7); asn1cCallocOne(initialDownlinkBWP->pdcch_ConfigCommon->choice.setup->pagingSearchSpace, 5); @@ -1004,11 +1011,463 @@ long rrc_get_max_nr_csrs(uint8_t max_rbs, long b_SRS) { return c_srs; } +void fill_default_downlinkBWP(NR_BWP_Downlink_t *bwp, + int bwp_loop, + NR_ServingCellConfig_t *servingcellconfigdedicated, + NR_ServingCellConfigCommon_t *scc, + const gNB_RrcConfigurationReq *configuration) { + + /// BWP common configuration + bwp->bwp_Common = calloc(1,sizeof(*bwp->bwp_Common)); + if(servingcellconfigdedicated->downlinkBWP_ToAddModList && + bwp_loop < servingcellconfigdedicated->downlinkBWP_ToAddModList->list.count) { + bwp->bwp_Id = servingcellconfigdedicated->downlinkBWP_ToAddModList->list.array[bwp_loop]->bwp_Id; + bwp->bwp_Common->genericParameters.locationAndBandwidth = servingcellconfigdedicated->downlinkBWP_ToAddModList->list.array[bwp_loop]->bwp_Common->genericParameters.locationAndBandwidth; + bwp->bwp_Common->genericParameters.subcarrierSpacing = servingcellconfigdedicated->downlinkBWP_ToAddModList->list.array[bwp_loop]->bwp_Common->genericParameters.subcarrierSpacing; + bwp->bwp_Common->genericParameters.cyclicPrefix = servingcellconfigdedicated->downlinkBWP_ToAddModList->list.array[bwp_loop]->bwp_Common->genericParameters.cyclicPrefix; + } else { + bwp->bwp_Id=bwp_loop+1; + bwp->bwp_Common->genericParameters.locationAndBandwidth = PRBalloc_to_locationandbandwidth(scc->downlinkConfigCommon->frequencyInfoDL->scs_SpecificCarrierList.list.array[0]->carrierBandwidth,0); + bwp->bwp_Common->genericParameters.subcarrierSpacing = scc->downlinkConfigCommon->initialDownlinkBWP->genericParameters.subcarrierSpacing; + bwp->bwp_Common->genericParameters.cyclicPrefix = scc->downlinkConfigCommon->initialDownlinkBWP->genericParameters.cyclicPrefix; + } + + bwp->bwp_Common->pdcch_ConfigCommon=calloc(1,sizeof(*bwp->bwp_Common->pdcch_ConfigCommon)); + bwp->bwp_Common->pdcch_ConfigCommon->present = NR_SetupRelease_PDCCH_ConfigCommon_PR_setup; + bwp->bwp_Common->pdcch_ConfigCommon->choice.setup = calloc(1,sizeof(*bwp->bwp_Common->pdcch_ConfigCommon->choice.setup)); + bwp->bwp_Common->pdcch_ConfigCommon->choice.setup->controlResourceSetZero=NULL; + bwp->bwp_Common->pdcch_ConfigCommon->choice.setup->commonControlResourceSet=calloc(1,sizeof(*bwp->bwp_Common->pdcch_ConfigCommon->choice.setup->commonControlResourceSet)); + + int curr_bwp = NRRIV2BW(bwp->bwp_Common->genericParameters.locationAndBandwidth,MAX_BWP_SIZE); + + NR_ControlResourceSet_t *coreset = calloc(1,sizeof(*coreset)); + uint64_t bitmap = get_ssb_bitmap(scc); + rrc_coreset_config(coreset, bwp->bwp_Id, curr_bwp, bitmap); + + bwp->bwp_Common->pdcch_ConfigCommon->choice.setup->commonControlResourceSet = coreset; + bwp->bwp_Common->pdcch_ConfigCommon->choice.setup->searchSpaceZero=NULL; + bwp->bwp_Common->pdcch_ConfigCommon->choice.setup->commonSearchSpaceList=NULL; + bwp->bwp_Common->pdcch_ConfigCommon->choice.setup->commonSearchSpaceList=calloc(1,sizeof(*bwp->bwp_Common->pdcch_ConfigCommon->choice.setup->commonSearchSpaceList)); + + NR_SearchSpace_t *ss=calloc(1,sizeof(*ss)); + ss->searchSpaceId = (bwp->bwp_Id<<1)-1 + 7; // To uniquely identify each SearchSpace lets derive it from the BWPId + ss->controlResourceSetId=calloc(1,sizeof(*ss->controlResourceSetId)); + *ss->controlResourceSetId=coreset->controlResourceSetId; + ss->monitoringSlotPeriodicityAndOffset = calloc(1,sizeof(*ss->monitoringSlotPeriodicityAndOffset)); + ss->monitoringSlotPeriodicityAndOffset->present = NR_SearchSpace__monitoringSlotPeriodicityAndOffset_PR_sl1; + ss->duration=NULL; + ss->monitoringSymbolsWithinSlot = calloc(1,sizeof(*ss->monitoringSymbolsWithinSlot)); + ss->monitoringSymbolsWithinSlot->buf = calloc(1,2); + // should be '1100 0000 0000 00'B (LSB first!), first two symols in slot, adjust if needed + ss->monitoringSymbolsWithinSlot->buf[1] = 0; + ss->monitoringSymbolsWithinSlot->buf[0] = (1<<7); + ss->monitoringSymbolsWithinSlot->size = 2; + ss->monitoringSymbolsWithinSlot->bits_unused = 2; + ss->nrofCandidates = calloc(1,sizeof(*ss->nrofCandidates)); + ss->nrofCandidates->aggregationLevel1 = NR_SearchSpace__nrofCandidates__aggregationLevel1_n0; + ss->nrofCandidates->aggregationLevel2 = NR_SearchSpace__nrofCandidates__aggregationLevel2_n2; + ss->nrofCandidates->aggregationLevel4 = NR_SearchSpace__nrofCandidates__aggregationLevel4_n1; + ss->nrofCandidates->aggregationLevel8 = NR_SearchSpace__nrofCandidates__aggregationLevel8_n0; + ss->nrofCandidates->aggregationLevel16 = NR_SearchSpace__nrofCandidates__aggregationLevel16_n0; + ss->searchSpaceType = calloc(1,sizeof(*ss->searchSpaceType)); + ss->searchSpaceType->present = NR_SearchSpace__searchSpaceType_PR_common; + ss->searchSpaceType->choice.common=calloc(1,sizeof(*ss->searchSpaceType->choice.common)); + ss->searchSpaceType->choice.common->dci_Format0_0_AndFormat1_0 = calloc(1,sizeof(*ss->searchSpaceType->choice.common->dci_Format0_0_AndFormat1_0)); + + ASN_SEQUENCE_ADD(&bwp->bwp_Common->pdcch_ConfigCommon->choice.setup->commonSearchSpaceList->list,ss); + + bwp->bwp_Common->pdcch_ConfigCommon->choice.setup->searchSpaceSIB1=NULL; + bwp->bwp_Common->pdcch_ConfigCommon->choice.setup->searchSpaceOtherSystemInformation=NULL; + bwp->bwp_Common->pdcch_ConfigCommon->choice.setup->pagingSearchSpace=NULL; + bwp->bwp_Common->pdcch_ConfigCommon->choice.setup->ra_SearchSpace=NULL; + bwp->bwp_Common->pdcch_ConfigCommon->choice.setup->ext1=NULL; + bwp->bwp_Common->pdsch_ConfigCommon=calloc(1,sizeof(*bwp->bwp_Common->pdsch_ConfigCommon)); + bwp->bwp_Common->pdsch_ConfigCommon->present = NR_SetupRelease_PDSCH_ConfigCommon_PR_setup; + bwp->bwp_Common->pdsch_ConfigCommon->choice.setup = calloc(1,sizeof(*bwp->bwp_Common->pdsch_ConfigCommon->choice.setup)); + bwp->bwp_Common->pdsch_ConfigCommon->choice.setup->pdsch_TimeDomainAllocationList = calloc(1,sizeof(*bwp->bwp_Common->pdsch_ConfigCommon->choice.setup->pdsch_TimeDomainAllocationList)); + + // Prepare PDSCH-TimeDomainResourceAllocation list + nr_rrc_config_dl_tda(scc, + bwp->bwp_Common->pdsch_ConfigCommon->choice.setup->pdsch_TimeDomainAllocationList, + curr_bwp); + + /// BWP dedicated configuration + bwp->bwp_Dedicated=calloc(1,sizeof(*bwp->bwp_Dedicated)); + bwp->bwp_Dedicated->pdcch_Config=calloc(1,sizeof(*bwp->bwp_Dedicated->pdcch_Config)); + bwp->bwp_Dedicated->pdcch_Config->present = NR_SetupRelease_PDCCH_Config_PR_setup; + bwp->bwp_Dedicated->pdcch_Config->choice.setup = calloc(1,sizeof(*bwp->bwp_Dedicated->pdcch_Config->choice.setup)); + bwp->bwp_Dedicated->pdcch_Config->choice.setup->searchSpacesToAddModList = calloc(1,sizeof(*bwp->bwp_Dedicated->pdcch_Config->choice.setup->searchSpacesToAddModList)); + bwp->bwp_Dedicated->pdcch_Config->choice.setup->controlResourceSetToAddModList = calloc(1,sizeof(*bwp->bwp_Dedicated->pdcch_Config->choice.setup->controlResourceSetToAddModList)); + + NR_ControlResourceSet_t *coreset2 = calloc(1,sizeof(*coreset2)); + rrc_coreset_config(coreset2, bwp->bwp_Id, curr_bwp, bitmap); + ASN_SEQUENCE_ADD(&bwp->bwp_Dedicated->pdcch_Config->choice.setup->controlResourceSetToAddModList->list, coreset2); + + bwp->bwp_Dedicated->pdcch_Config->choice.setup->searchSpacesToAddModList = calloc(1,sizeof(*bwp->bwp_Dedicated->pdcch_Config->choice.setup->searchSpacesToAddModList)); + NR_SearchSpace_t *ss2 = calloc(1,sizeof(*ss2)); + ss2->searchSpaceId=(bwp->bwp_Id<<1) + 7; // To uniquely identify each SearchSpace lets derive it from the BWPId + ss2->controlResourceSetId=calloc(1,sizeof(*ss2->controlResourceSetId)); + *ss2->controlResourceSetId=coreset2->controlResourceSetId; + ss2->monitoringSlotPeriodicityAndOffset=calloc(1,sizeof(*ss2->monitoringSlotPeriodicityAndOffset)); + ss2->monitoringSlotPeriodicityAndOffset->present = NR_SearchSpace__monitoringSlotPeriodicityAndOffset_PR_sl1; + ss2->monitoringSlotPeriodicityAndOffset->choice.sl1=(NULL_t)0; + ss2->duration=NULL; + ss2->monitoringSymbolsWithinSlot = calloc(1,sizeof(*ss2->monitoringSymbolsWithinSlot)); + ss2->monitoringSymbolsWithinSlot->buf = calloc(1,2); + ss2->monitoringSymbolsWithinSlot->size = 2; + ss2->monitoringSymbolsWithinSlot->buf[0]=0x80; + ss2->monitoringSymbolsWithinSlot->buf[1]=0x0; + ss2->monitoringSymbolsWithinSlot->bits_unused = 2; + ss2->nrofCandidates=calloc(1,sizeof(*ss2->nrofCandidates)); + ss2->nrofCandidates->aggregationLevel1 = NR_SearchSpace__nrofCandidates__aggregationLevel1_n0; + ss2->nrofCandidates->aggregationLevel2 = NR_SearchSpace__nrofCandidates__aggregationLevel2_n2; + ss2->nrofCandidates->aggregationLevel4 = NR_SearchSpace__nrofCandidates__aggregationLevel4_n1; + ss2->nrofCandidates->aggregationLevel8 = NR_SearchSpace__nrofCandidates__aggregationLevel8_n0; + ss2->nrofCandidates->aggregationLevel16 = NR_SearchSpace__nrofCandidates__aggregationLevel16_n0; + ss2->searchSpaceType=calloc(1,sizeof(*ss2->searchSpaceType)); + ss2->searchSpaceType->present = NR_SearchSpace__searchSpaceType_PR_ue_Specific; + ss2->searchSpaceType->choice.ue_Specific = calloc(1,sizeof(*ss2->searchSpaceType->choice.ue_Specific)); + ss2->searchSpaceType->choice.ue_Specific->dci_Formats=NR_SearchSpace__searchSpaceType__ue_Specific__dci_Formats_formats0_1_And_1_1; + ASN_SEQUENCE_ADD(&bwp->bwp_Dedicated->pdcch_Config->choice.setup->searchSpacesToAddModList->list, ss2); + + bwp->bwp_Dedicated->pdsch_Config=calloc(1,sizeof(*bwp->bwp_Dedicated->pdsch_Config)); + bwp->bwp_Dedicated->pdsch_Config->present = NR_SetupRelease_PDSCH_Config_PR_setup; + bwp->bwp_Dedicated->pdsch_Config->choice.setup = calloc(1,sizeof(*bwp->bwp_Dedicated->pdsch_Config->choice.setup)); + bwp->bwp_Dedicated->pdsch_Config->choice.setup->dataScramblingIdentityPDSCH = NULL; + bwp->bwp_Dedicated->pdsch_Config->choice.setup->dmrs_DownlinkForPDSCH_MappingTypeA = calloc(1,sizeof(*bwp->bwp_Dedicated->pdsch_Config->choice.setup->dmrs_DownlinkForPDSCH_MappingTypeA)); + bwp->bwp_Dedicated->pdsch_Config->choice.setup->dmrs_DownlinkForPDSCH_MappingTypeA->present= NR_SetupRelease_DMRS_DownlinkConfig_PR_setup; + bwp->bwp_Dedicated->pdsch_Config->choice.setup->dmrs_DownlinkForPDSCH_MappingTypeA->choice.setup = calloc(1,sizeof(*bwp->bwp_Dedicated->pdsch_Config->choice.setup->dmrs_DownlinkForPDSCH_MappingTypeA->choice.setup)); + bwp->bwp_Dedicated->pdsch_Config->choice.setup->dmrs_DownlinkForPDSCH_MappingTypeA->choice.setup->dmrs_Type=NULL; + bwp->bwp_Dedicated->pdsch_Config->choice.setup->dmrs_DownlinkForPDSCH_MappingTypeA->choice.setup->maxLength=NULL; + bwp->bwp_Dedicated->pdsch_Config->choice.setup->dmrs_DownlinkForPDSCH_MappingTypeA->choice.setup->dmrs_AdditionalPosition = calloc(1,sizeof(*bwp->bwp_Dedicated->pdsch_Config->choice.setup->dmrs_DownlinkForPDSCH_MappingTypeA->choice.setup->dmrs_AdditionalPosition)); + *bwp->bwp_Dedicated->pdsch_Config->choice.setup->dmrs_DownlinkForPDSCH_MappingTypeA->choice.setup->dmrs_AdditionalPosition = NR_DMRS_DownlinkConfig__dmrs_AdditionalPosition_pos1; + bwp->bwp_Dedicated->pdsch_Config->choice.setup->resourceAllocation = NR_PDSCH_Config__resourceAllocation_resourceAllocationType1; + bwp->bwp_Dedicated->pdsch_Config->choice.setup->prb_BundlingType.present = NR_PDSCH_Config__prb_BundlingType_PR_staticBundling; + bwp->bwp_Dedicated->pdsch_Config->choice.setup->prb_BundlingType.choice.staticBundling = calloc(1,sizeof(*bwp->bwp_Dedicated->pdsch_Config->choice.setup->prb_BundlingType.choice.staticBundling)); + bwp->bwp_Dedicated->pdsch_Config->choice.setup->prb_BundlingType.choice.staticBundling->bundleSize = + calloc(1,sizeof(*bwp->bwp_Dedicated->pdsch_Config->choice.setup->prb_BundlingType.choice.staticBundling->bundleSize)); + *bwp->bwp_Dedicated->pdsch_Config->choice.setup->prb_BundlingType.choice.staticBundling->bundleSize = NR_PDSCH_Config__prb_BundlingType__staticBundling__bundleSize_wideband; + bwp->bwp_Dedicated->pdsch_Config->choice.setup->tci_StatesToAddModList=calloc(1,sizeof(*bwp->bwp_Dedicated->pdsch_Config->choice.setup->tci_StatesToAddModList)); + NR_TCI_State_t *tcic = calloc(1,sizeof(*tcic)); + tcic->tci_StateId=0; + tcic->qcl_Type1.cell=NULL; + tcic->qcl_Type1.bwp_Id=NULL; + tcic->qcl_Type1.referenceSignal.present = NR_QCL_Info__referenceSignal_PR_ssb; + tcic->qcl_Type1.referenceSignal.choice.ssb = 0; + tcic->qcl_Type1.qcl_Type=NR_QCL_Info__qcl_Type_typeD; + ASN_SEQUENCE_ADD(&bwp->bwp_Dedicated->pdsch_Config->choice.setup->tci_StatesToAddModList->list,tcic); +} + +void fill_default_uplinkBWP(NR_BWP_Uplink_t *ubwp, + int bwp_loop, + NR_ServingCellConfig_t *servingcellconfigdedicated, + NR_ServingCellConfigCommon_t *scc, + const gNB_RrcConfigurationReq *configuration, + int uid) { + + /// BWP common configuration + ubwp->bwp_Common = calloc(1,sizeof(*ubwp->bwp_Common)); + if(servingcellconfigdedicated->uplinkConfig->uplinkBWP_ToAddModList && + bwp_loop < servingcellconfigdedicated->uplinkConfig->uplinkBWP_ToAddModList->list.count) { + ubwp->bwp_Id = servingcellconfigdedicated->uplinkConfig->uplinkBWP_ToAddModList->list.array[bwp_loop]->bwp_Id; + ubwp->bwp_Common->genericParameters.locationAndBandwidth = servingcellconfigdedicated->uplinkConfig->uplinkBWP_ToAddModList->list.array[bwp_loop]->bwp_Common->genericParameters.locationAndBandwidth; + ubwp->bwp_Common->genericParameters.subcarrierSpacing = servingcellconfigdedicated->uplinkConfig->uplinkBWP_ToAddModList->list.array[bwp_loop]->bwp_Common->genericParameters.subcarrierSpacing; + ubwp->bwp_Common->genericParameters.cyclicPrefix = servingcellconfigdedicated->uplinkConfig->uplinkBWP_ToAddModList->list.array[bwp_loop]->bwp_Common->genericParameters.cyclicPrefix; + } else { + ubwp->bwp_Id=bwp_loop+1; + ubwp->bwp_Common->genericParameters.locationAndBandwidth = PRBalloc_to_locationandbandwidth(scc->uplinkConfigCommon->frequencyInfoUL->scs_SpecificCarrierList.list.array[0]->carrierBandwidth,0); + ubwp->bwp_Common->genericParameters.subcarrierSpacing = scc->uplinkConfigCommon->initialUplinkBWP->genericParameters.subcarrierSpacing; + ubwp->bwp_Common->genericParameters.cyclicPrefix = scc->uplinkConfigCommon->initialUplinkBWP->genericParameters.cyclicPrefix; + } + + ubwp->bwp_Common->rach_ConfigCommon = NULL; + ubwp->bwp_Common->pusch_ConfigCommon = scc->uplinkConfigCommon->initialUplinkBWP->pusch_ConfigCommon; + ubwp->bwp_Common->pucch_ConfigCommon = scc->uplinkConfigCommon->initialUplinkBWP->pucch_ConfigCommon; + + /// BWP dedicated configuration + ubwp->bwp_Dedicated = calloc(1,sizeof(*ubwp->bwp_Dedicated)); + + // PUCCH config + ubwp->bwp_Dedicated->pucch_Config = calloc(1,sizeof(*ubwp->bwp_Dedicated->pucch_Config)); + ubwp->bwp_Dedicated->pucch_Config->present = NR_SetupRelease_PUCCH_Config_PR_setup; + NR_PUCCH_Config_t *pucch_Config = calloc(1,sizeof(*pucch_Config)); + ubwp->bwp_Dedicated->pucch_Config->choice.setup=pucch_Config; + pucch_Config->resourceSetToAddModList = calloc(1,sizeof(*pucch_Config->resourceSetToAddModList)); + pucch_Config->resourceSetToReleaseList = NULL; + NR_PUCCH_ResourceSet_t *pucchresset0=calloc(1,sizeof(*pucchresset0)); + NR_PUCCH_ResourceSet_t *pucchresset1=calloc(1,sizeof(*pucchresset1)); + pucchresset0->pucch_ResourceSetId = 0; + NR_PUCCH_ResourceId_t *pucchresset0id0=calloc(1,sizeof(*pucchresset0id0)); + *pucchresset0id0=0; + ASN_SEQUENCE_ADD(&pucchresset0->resourceList.list,pucchresset0id0); + pucchresset0->maxPayloadSize=NULL; + ASN_SEQUENCE_ADD(&pucch_Config->resourceSetToAddModList->list,pucchresset0); + pucchresset1->pucch_ResourceSetId = 1; + NR_PUCCH_ResourceId_t *pucchresset1id0=calloc(1,sizeof(*pucchresset1id0)); + *pucchresset1id0=1; + ASN_SEQUENCE_ADD(&pucchresset1->resourceList.list,pucchresset1id0); + pucchresset1->maxPayloadSize=NULL; + ASN_SEQUENCE_ADD(&pucch_Config->resourceSetToAddModList->list,pucchresset1); + pucch_Config->resourceToAddModList = calloc(1,sizeof(*pucch_Config->resourceToAddModList)); + pucch_Config->resourceToReleaseList = NULL; + int curr_bwp = NRRIV2BW(ubwp->bwp_Common->genericParameters.locationAndBandwidth,MAX_BWP_SIZE); + NR_PUCCH_Resource_t *pucchres0=calloc(1,sizeof(*pucchres0)); + pucchres0->pucch_ResourceId=0; + pucchres0->startingPRB=(8+uid) % (curr_bwp/2); + LOG_D(NR_RRC, "pucchres0->startPRB %ld uid %d curr_bwp %d\n", pucchres0->startingPRB, uid, curr_bwp); + pucchres0->intraSlotFrequencyHopping=NULL; + pucchres0->secondHopPRB=NULL; + pucchres0->format.present= NR_PUCCH_Resource__format_PR_format0; + pucchres0->format.choice.format0=calloc(1,sizeof(*pucchres0->format.choice.format0)); + pucchres0->format.choice.format0->initialCyclicShift=0; + pucchres0->format.choice.format0->nrofSymbols=1; + pucchres0->format.choice.format0->startingSymbolIndex=13; + ASN_SEQUENCE_ADD(&pucch_Config->resourceToAddModList->list,pucchres0); + NR_PUCCH_Resource_t *pucchres2=calloc(1,sizeof(*pucchres2)); + pucchres2->pucch_ResourceId=1; + pucchres2->startingPRB=0; + pucchres2->intraSlotFrequencyHopping=NULL; + pucchres2->secondHopPRB=NULL; + pucchres2->format.present= NR_PUCCH_Resource__format_PR_format2; + pucchres2->format.choice.format2=calloc(1,sizeof(*pucchres2->format.choice.format2)); + pucchres2->format.choice.format2->nrofPRBs=8; + pucchres2->format.choice.format2->nrofSymbols=1; + pucchres2->format.choice.format2->startingSymbolIndex=13; + ASN_SEQUENCE_ADD(&pucch_Config->resourceToAddModList->list,pucchres2); + pucch_Config->format2=calloc(1,sizeof(*pucch_Config->format2)); + pucch_Config->format2->present=NR_SetupRelease_PUCCH_FormatConfig_PR_setup; + NR_PUCCH_FormatConfig_t *pucchfmt2 = calloc(1,sizeof(*pucchfmt2)); + pucch_Config->format2->choice.setup = pucchfmt2; + pucchfmt2->interslotFrequencyHopping=NULL; + pucchfmt2->additionalDMRS=NULL; + pucchfmt2->maxCodeRate=calloc(1,sizeof(*pucchfmt2->maxCodeRate)); + *pucchfmt2->maxCodeRate=NR_PUCCH_MaxCodeRate_zeroDot35; + pucchfmt2->nrofSlots=NULL; + pucchfmt2->pi2BPSK=NULL; + pucchfmt2->simultaneousHARQ_ACK_CSI=calloc(1,sizeof(*pucchfmt2->simultaneousHARQ_ACK_CSI)); + *pucchfmt2->simultaneousHARQ_ACK_CSI=NR_PUCCH_FormatConfig__simultaneousHARQ_ACK_CSI_true; + + // PUCCH config - Scheduling request configuration + pucch_Config->schedulingRequestResourceToAddModList = calloc(1,sizeof(*pucch_Config->schedulingRequestResourceToAddModList)); + NR_SchedulingRequestResourceConfig_t *schedulingRequestResourceConfig = calloc(1,sizeof(*schedulingRequestResourceConfig)); + schedulingRequestResourceConfig->schedulingRequestResourceId = 1; + schedulingRequestResourceConfig->schedulingRequestID = 0; + schedulingRequestResourceConfig->periodicityAndOffset = calloc(1,sizeof(*schedulingRequestResourceConfig->periodicityAndOffset)); + schedulingRequestResourceConfig->periodicityAndOffset->present = NR_SchedulingRequestResourceConfig__periodicityAndOffset_PR_sl40; // 40 slot period + // note: make sure that there is no issue here. Later choose the RNTI accordingly. + // Here we would be limited to 3 UEs on this resource (1 1/2 Frames 30 kHz SCS, 5 ms TDD periodicity => slots 7,8,9). + // This should be a temporary resource until the first RRCReconfiguration gives new pucch resources. + // Check for above configuration and exit for now if it is not the case + AssertFatal(scc->downlinkConfigCommon->initialDownlinkBWP->genericParameters.subcarrierSpacing==NR_SubcarrierSpacing_kHz30, + "SCS != 30kHz\n"); + AssertFatal(scc->tdd_UL_DL_ConfigurationCommon->pattern1.dl_UL_TransmissionPeriodicity==NR_TDD_UL_DL_Pattern__dl_UL_TransmissionPeriodicity_ms5, + "TDD period != 5ms : %ld\n",scc->tdd_UL_DL_ConfigurationCommon->pattern1.dl_UL_TransmissionPeriodicity); + schedulingRequestResourceConfig->periodicityAndOffset->choice.sl40 = 8; + schedulingRequestResourceConfig->resource = calloc(1,sizeof(*schedulingRequestResourceConfig->resource)); + *schedulingRequestResourceConfig->resource = 0; + ASN_SEQUENCE_ADD(&pucch_Config->schedulingRequestResourceToAddModList->list,schedulingRequestResourceConfig); + pucch_Config->schedulingRequestResourceToReleaseList=NULL; + + pucch_Config->multi_CSI_PUCCH_ResourceList=NULL; + pucch_Config->dl_DataToUL_ACK = calloc(1,sizeof(*pucch_Config->dl_DataToUL_ACK)); + long *delay[8]; + for (int i=0;i<8;i++) { + delay[i] = calloc(1,sizeof(*delay[i])); + AssertFatal(configuration->minRXTXTIME >=2 && configuration->minRXTXTIME <7, "check minRXTXTIME %d\n",configuration->minRXTXTIME); + *delay[i] = i+configuration->minRXTXTIME; + ASN_SEQUENCE_ADD(&pucch_Config->dl_DataToUL_ACK->list,delay[i]); + } + pucch_Config->spatialRelationInfoToAddModList = calloc(1,sizeof(*pucch_Config->spatialRelationInfoToAddModList)); + NR_PUCCH_SpatialRelationInfo_t *pucchspatial = calloc(1,sizeof(*pucchspatial)); + pucchspatial->pucch_SpatialRelationInfoId = 1; + pucchspatial->servingCellId = NULL; + if(configuration->do_CSIRS) { + pucchspatial->referenceSignal.present = NR_PUCCH_SpatialRelationInfo__referenceSignal_PR_csi_RS_Index; + pucchspatial->referenceSignal.choice.csi_RS_Index = 0; + } + else { + pucchspatial->referenceSignal.present = NR_PUCCH_SpatialRelationInfo__referenceSignal_PR_ssb_Index; + pucchspatial->referenceSignal.choice.ssb_Index = 0; + } + pucchspatial->pucch_PathlossReferenceRS_Id = 0; + pucchspatial->p0_PUCCH_Id = 1; + pucchspatial->closedLoopIndex = NR_PUCCH_SpatialRelationInfo__closedLoopIndex_i0; + ASN_SEQUENCE_ADD(&pucch_Config->spatialRelationInfoToAddModList->list,pucchspatial); + pucch_Config->spatialRelationInfoToReleaseList=NULL; + pucch_Config->pucch_PowerControl=calloc(1,sizeof(*pucch_Config->pucch_PowerControl)); + pucch_Config->pucch_PowerControl->deltaF_PUCCH_f0 = calloc(1,sizeof(*pucch_Config->pucch_PowerControl->deltaF_PUCCH_f0)); + *pucch_Config->pucch_PowerControl->deltaF_PUCCH_f0 = 0; + pucch_Config->pucch_PowerControl->deltaF_PUCCH_f1 = calloc(1,sizeof(*pucch_Config->pucch_PowerControl->deltaF_PUCCH_f1)); + *pucch_Config->pucch_PowerControl->deltaF_PUCCH_f1 = 0; + pucch_Config->pucch_PowerControl->deltaF_PUCCH_f2 = calloc(1,sizeof(*pucch_Config->pucch_PowerControl->deltaF_PUCCH_f2)); + *pucch_Config->pucch_PowerControl->deltaF_PUCCH_f2 = 0; + pucch_Config->pucch_PowerControl->deltaF_PUCCH_f3 = calloc(1,sizeof(*pucch_Config->pucch_PowerControl->deltaF_PUCCH_f3)); + *pucch_Config->pucch_PowerControl->deltaF_PUCCH_f3 = 0; + pucch_Config->pucch_PowerControl->deltaF_PUCCH_f4 = calloc(1,sizeof(*pucch_Config->pucch_PowerControl->deltaF_PUCCH_f4)); + *pucch_Config->pucch_PowerControl->deltaF_PUCCH_f4 = 0; + pucch_Config->pucch_PowerControl->p0_Set = calloc(1,sizeof(*pucch_Config->pucch_PowerControl->p0_Set)); + NR_P0_PUCCH_t *p00 = calloc(1,sizeof(*p00)); + p00->p0_PUCCH_Id=1; + p00->p0_PUCCH_Value = 0; + ASN_SEQUENCE_ADD(&pucch_Config->pucch_PowerControl->p0_Set->list,p00); + pucch_Config->pucch_PowerControl->pathlossReferenceRSs = NULL; + + // PUSCH config + ubwp->bwp_Dedicated->pusch_Config = calloc(1,sizeof(*ubwp->bwp_Dedicated->pusch_Config)); + ubwp->bwp_Dedicated->pusch_Config->present = NR_SetupRelease_PUSCH_Config_PR_setup; + NR_PUSCH_Config_t *pusch_Config = calloc(1,sizeof(*pusch_Config)); + ubwp->bwp_Dedicated->pusch_Config->choice.setup = pusch_Config; + pusch_Config->txConfig=calloc(1,sizeof(*pusch_Config->txConfig)); + *pusch_Config->txConfig= NR_PUSCH_Config__txConfig_codebook; + pusch_Config->dmrs_UplinkForPUSCH_MappingTypeA = NULL; + pusch_Config->dmrs_UplinkForPUSCH_MappingTypeB = calloc(1,sizeof(*pusch_Config->dmrs_UplinkForPUSCH_MappingTypeB)); + pusch_Config->dmrs_UplinkForPUSCH_MappingTypeB->present = NR_SetupRelease_DMRS_UplinkConfig_PR_setup; + pusch_Config->dmrs_UplinkForPUSCH_MappingTypeB->choice.setup = calloc(1,sizeof(*pusch_Config->dmrs_UplinkForPUSCH_MappingTypeB->choice.setup)); + NR_DMRS_UplinkConfig_t *NR_DMRS_UplinkConfig = pusch_Config->dmrs_UplinkForPUSCH_MappingTypeB->choice.setup; + NR_DMRS_UplinkConfig->dmrs_Type = NULL; + NR_DMRS_UplinkConfig->dmrs_AdditionalPosition = calloc(1,sizeof(*NR_DMRS_UplinkConfig->dmrs_AdditionalPosition)); + *NR_DMRS_UplinkConfig->dmrs_AdditionalPosition = NR_DMRS_UplinkConfig__dmrs_AdditionalPosition_pos0; + NR_DMRS_UplinkConfig->phaseTrackingRS=NULL; + NR_DMRS_UplinkConfig->maxLength=NULL; + NR_DMRS_UplinkConfig->transformPrecodingDisabled = calloc(1,sizeof(*NR_DMRS_UplinkConfig->transformPrecodingDisabled)); + NR_DMRS_UplinkConfig->transformPrecodingDisabled->scramblingID0 = NULL; + NR_DMRS_UplinkConfig->transformPrecodingDisabled->scramblingID1 = NULL; + NR_DMRS_UplinkConfig->transformPrecodingEnabled = NULL; + pusch_Config->pusch_PowerControl = calloc(1,sizeof(*pusch_Config->pusch_PowerControl)); + pusch_Config->pusch_PowerControl->tpc_Accumulation = NULL; + pusch_Config->pusch_PowerControl->msg3_Alpha = calloc(1,sizeof(*pusch_Config->pusch_PowerControl->msg3_Alpha)); + *pusch_Config->pusch_PowerControl->msg3_Alpha = NR_Alpha_alpha1; + pusch_Config->pusch_PowerControl->p0_NominalWithoutGrant = calloc(1,sizeof(*pusch_Config->pusch_PowerControl->p0_NominalWithoutGrant)); + *pusch_Config->pusch_PowerControl->p0_NominalWithoutGrant = -98; + pusch_Config->pusch_PowerControl->p0_AlphaSets = calloc(1,sizeof(*pusch_Config->pusch_PowerControl->p0_AlphaSets)); + NR_P0_PUSCH_AlphaSet_t *aset = calloc(1,sizeof(*aset)); + aset->p0_PUSCH_AlphaSetId=0; + aset->p0=calloc(1,sizeof(*aset->p0)); + *aset->p0 = 0; + aset->alpha=calloc(1,sizeof(*aset->alpha)); + *aset->alpha=NR_Alpha_alpha1; + ASN_SEQUENCE_ADD(&pusch_Config->pusch_PowerControl->p0_AlphaSets->list,aset); + pusch_Config->pusch_PowerControl->pathlossReferenceRSToAddModList = calloc(1,sizeof(*pusch_Config->pusch_PowerControl->pathlossReferenceRSToAddModList)); + NR_PUSCH_PathlossReferenceRS_t *plrefRS = calloc(1,sizeof(*plrefRS)); + plrefRS->pusch_PathlossReferenceRS_Id=0; + plrefRS->referenceSignal.present = NR_PUSCH_PathlossReferenceRS__referenceSignal_PR_ssb_Index; + plrefRS->referenceSignal.choice.ssb_Index = 0; + ASN_SEQUENCE_ADD(&pusch_Config->pusch_PowerControl->pathlossReferenceRSToAddModList->list,plrefRS); + pusch_Config->pusch_PowerControl->pathlossReferenceRSToReleaseList = NULL; + pusch_Config->pusch_PowerControl->twoPUSCH_PC_AdjustmentStates = NULL; + pusch_Config->pusch_PowerControl->deltaMCS = NULL; + pusch_Config->pusch_PowerControl->sri_PUSCH_MappingToAddModList = calloc(1,sizeof(*pusch_Config->pusch_PowerControl->sri_PUSCH_MappingToAddModList)); + NR_SRI_PUSCH_PowerControl_t *sriPUSCHPC=calloc(1,sizeof(*sriPUSCHPC)); + sriPUSCHPC->sri_PUSCH_PowerControlId=0; + sriPUSCHPC->sri_PUSCH_PathlossReferenceRS_Id=0; + sriPUSCHPC->sri_P0_PUSCH_AlphaSetId=0; + sriPUSCHPC->sri_PUSCH_ClosedLoopIndex=NR_SRI_PUSCH_PowerControl__sri_PUSCH_ClosedLoopIndex_i0; + ASN_SEQUENCE_ADD(&pusch_Config->pusch_PowerControl->sri_PUSCH_MappingToAddModList->list,sriPUSCHPC); + pusch_Config->pusch_PowerControl->sri_PUSCH_MappingToReleaseList = NULL; + pusch_Config->frequencyHopping=NULL; + pusch_Config->frequencyHoppingOffsetLists=NULL; + pusch_Config->resourceAllocation = NR_PUSCH_Config__resourceAllocation_resourceAllocationType1; + pusch_Config->pusch_TimeDomainAllocationList = NULL; + pusch_Config->pusch_AggregationFactor=NULL; + pusch_Config->mcs_Table=NULL; + pusch_Config->mcs_TableTransformPrecoder=NULL; + pusch_Config->transformPrecoder= NULL; + if (scc->uplinkConfigCommon->initialUplinkBWP->rach_ConfigCommon->choice.setup->msg3_transformPrecoder == NULL) { + pusch_Config->transformPrecoder=calloc(1,sizeof(*pusch_Config->transformPrecoder)); + *pusch_Config->transformPrecoder = NR_PUSCH_Config__transformPrecoder_disabled; + } + pusch_Config->codebookSubset=calloc(1,sizeof(*pusch_Config->codebookSubset)); + *pusch_Config->codebookSubset = NR_PUSCH_Config__codebookSubset_nonCoherent; + pusch_Config->maxRank=calloc(1,sizeof(*pusch_Config->maxRank)); + *pusch_Config->maxRank= 1; + pusch_Config->rbg_Size=NULL; + pusch_Config->uci_OnPUSCH=NULL; + pusch_Config->tp_pi2BPSK=NULL; + uint8_t transform_precoding = NR_PUSCH_Config__transformPrecoder_disabled; + if (pusch_Config->transformPrecoder == NULL) { + if (scc->uplinkConfigCommon->initialUplinkBWP->rach_ConfigCommon->choice.setup->msg3_transformPrecoder != NULL) + transform_precoding = NR_PUSCH_Config__transformPrecoder_enabled; + } + else { + transform_precoding = *pusch_Config->transformPrecoder; + } + if (transform_precoding == NR_PUSCH_Config__transformPrecoder_enabled) { + // Enable DMRS uplink config for transform precoding enabled + NR_DMRS_UplinkConfig->transformPrecodingEnabled = calloc(1,sizeof(*NR_DMRS_UplinkConfig->transformPrecodingEnabled)); + NR_DMRS_UplinkConfig->transformPrecodingEnabled->nPUSCH_Identity = NULL; + NR_DMRS_UplinkConfig->transformPrecodingEnabled->sequenceGroupHopping = NULL; + NR_DMRS_UplinkConfig->transformPrecodingEnabled->sequenceHopping = NULL; + NR_DMRS_UplinkConfig->transformPrecodingEnabled->ext1 = NULL; + LOG_I(NR_RRC,"Transform precoding enabled\n"); + } + + // SRS config + ubwp->bwp_Dedicated->configuredGrantConfig = NULL; + ubwp->bwp_Dedicated->srs_Config = calloc(1,sizeof(*ubwp->bwp_Dedicated->srs_Config)); + ubwp->bwp_Dedicated->srs_Config->present = NR_SetupRelease_SRS_Config_PR_setup; + NR_SRS_Config_t *srs_Config = calloc(1,sizeof(*srs_Config)); + ubwp->bwp_Dedicated->srs_Config->choice.setup = srs_Config; + srs_Config->srs_ResourceSetToReleaseList=NULL; + srs_Config->srs_ResourceSetToAddModList=calloc(1,sizeof(*srs_Config->srs_ResourceSetToAddModList)); + NR_SRS_ResourceSet_t *srs_resset0=calloc(1,sizeof(*srs_resset0)); + srs_resset0->srs_ResourceSetId = 0; + srs_resset0->srs_ResourceIdList=calloc(1,sizeof(*srs_resset0->srs_ResourceIdList)); + NR_SRS_ResourceId_t *srs_resset0_id=calloc(1,sizeof(*srs_resset0_id)); + *srs_resset0_id=0; + ASN_SEQUENCE_ADD(&srs_resset0->srs_ResourceIdList->list,srs_resset0_id); + srs_Config->srs_ResourceToReleaseList=NULL; + srs_resset0->resourceType.present = NR_SRS_ResourceSet__resourceType_PR_aperiodic; + srs_resset0->resourceType.choice.aperiodic = calloc(1,sizeof(*srs_resset0->resourceType.choice.aperiodic)); + srs_resset0->resourceType.choice.aperiodic->aperiodicSRS_ResourceTrigger=1; + srs_resset0->resourceType.choice.aperiodic->csi_RS=NULL; + srs_resset0->resourceType.choice.aperiodic->slotOffset= calloc(1,sizeof(*srs_resset0->resourceType.choice.aperiodic->slotOffset)); + *srs_resset0->resourceType.choice.aperiodic->slotOffset=2; + srs_resset0->resourceType.choice.aperiodic->ext1=NULL; + srs_resset0->usage=NR_SRS_ResourceSet__usage_codebook; + srs_resset0->alpha = calloc(1,sizeof(*srs_resset0->alpha)); + *srs_resset0->alpha = NR_Alpha_alpha1; + srs_resset0->p0=calloc(1,sizeof(*srs_resset0->p0)); + *srs_resset0->p0=-80; + srs_resset0->pathlossReferenceRS=NULL; + srs_resset0->srs_PowerControlAdjustmentStates=NULL; + ASN_SEQUENCE_ADD(&srs_Config->srs_ResourceSetToAddModList->list,srs_resset0); + srs_Config->srs_ResourceToReleaseList=NULL; + srs_Config->srs_ResourceToAddModList=calloc(1,sizeof(*srs_Config->srs_ResourceToAddModList)); + NR_SRS_Resource_t *srs_res0=calloc(1,sizeof(*srs_res0)); + srs_res0->srs_ResourceId=0; + srs_res0->nrofSRS_Ports=NR_SRS_Resource__nrofSRS_Ports_port1; + srs_res0->ptrs_PortIndex=NULL; + srs_res0->transmissionComb.present=NR_SRS_Resource__transmissionComb_PR_n2; + srs_res0->transmissionComb.choice.n2=calloc(1,sizeof(*srs_res0->transmissionComb.choice.n2)); + srs_res0->transmissionComb.choice.n2->combOffset_n2=0; + srs_res0->transmissionComb.choice.n2->cyclicShift_n2=0; + srs_res0->resourceMapping.startPosition=2; + srs_res0->resourceMapping.nrofSymbols=NR_SRS_Resource__resourceMapping__nrofSymbols_n1; + srs_res0->resourceMapping.repetitionFactor=NR_SRS_Resource__resourceMapping__repetitionFactor_n1; + srs_res0->freqDomainPosition=0; + srs_res0->freqDomainShift=0; + srs_res0->freqHopping.c_SRS=0; + srs_res0->freqHopping.b_SRS=0; + srs_res0->freqHopping.b_hop=0; + srs_res0->groupOrSequenceHopping=NR_SRS_Resource__groupOrSequenceHopping_neither; + srs_res0->resourceType.present= NR_SRS_Resource__resourceType_PR_aperiodic; + srs_res0->resourceType.choice.aperiodic=calloc(1,sizeof(*srs_res0->resourceType.choice.aperiodic)); + srs_res0->sequenceId=40; + srs_res0->spatialRelationInfo=calloc(1,sizeof(*srs_res0->spatialRelationInfo)); + srs_res0->spatialRelationInfo->servingCellId=NULL; + srs_res0->spatialRelationInfo->referenceSignal.present=NR_SRS_SpatialRelationInfo__referenceSignal_PR_csi_RS_Index; + srs_res0->spatialRelationInfo->referenceSignal.choice.csi_RS_Index=0; + ASN_SEQUENCE_ADD(&srs_Config->srs_ResourceToAddModList->list,srs_res0); + + ubwp->bwp_Dedicated->beamFailureRecoveryConfig = NULL; +} + void fill_initial_SpCellConfig(int uid, NR_SpCellConfig_t *SpCellConfig, NR_ServingCellConfigCommon_t *scc, - rrc_gNB_carrier_data_t *carrier) { - + NR_ServingCellConfig_t *servingcellconfigdedicated, + const gNB_RrcConfigurationReq *configuration) +{ // This assert will never happen in the current implementation because NUMBER_OF_UE_MAX = 4. // However, if in the future NUMBER_OF_UE_MAX is increased, it will be necessary to improve the allocation of SRS resources, // where the startPosition = 2 or 3 and sl160 = 17, 17, 27 ... 157 only give us 30 different allocations. @@ -1019,8 +1478,10 @@ void fill_initial_SpCellConfig(int uid, SpCellConfig->reconfigurationWithSync = NULL; SpCellConfig->rlmInSyncOutOfSyncThreshold = NULL; SpCellConfig->rlf_TimersAndConstants = NULL; + SpCellConfig->spCellConfigDedicated = calloc(1,sizeof(*SpCellConfig->spCellConfigDedicated)); SpCellConfig->spCellConfigDedicated->uplinkConfig = calloc(1,sizeof(*SpCellConfig->spCellConfigDedicated->uplinkConfig)); + NR_BWP_UplinkDedicated_t *initialUplinkBWP = calloc(1,sizeof(*initialUplinkBWP)); SpCellConfig->spCellConfigDedicated->uplinkConfig->initialUplinkBWP = initialUplinkBWP; initialUplinkBWP->pucch_Config = calloc(1,sizeof(*initialUplinkBWP->pucch_Config)); @@ -1030,6 +1491,7 @@ void fill_initial_SpCellConfig(int uid, pucch_Config->resourceSetToAddModList = calloc(1,sizeof(*pucch_Config->resourceSetToAddModList)); pucch_Config->resourceSetToReleaseList = NULL; NR_PUCCH_ResourceSet_t *pucchresset0=calloc(1,sizeof(*pucchresset0)); + NR_PUCCH_ResourceSet_t *pucchresset1=calloc(1,sizeof(*pucchresset1)); pucchresset0->pucch_ResourceSetId = 0; NR_PUCCH_ResourceId_t *pucchresset0id0=calloc(1,sizeof(*pucchresset0id0)); *pucchresset0id0=0; @@ -1037,13 +1499,21 @@ void fill_initial_SpCellConfig(int uid, pucchresset0->maxPayloadSize=NULL; ASN_SEQUENCE_ADD(&pucch_Config->resourceSetToAddModList->list,pucchresset0); + pucchresset1->pucch_ResourceSetId = 1; + NR_PUCCH_ResourceId_t *pucchresset1id0=calloc(1,sizeof(*pucchresset1id0)); + *pucchresset1id0=1; + ASN_SEQUENCE_ADD(&pucchresset1->resourceList.list,pucchresset1id0); + pucchresset1->maxPayloadSize=NULL; + ASN_SEQUENCE_ADD(&pucch_Config->resourceSetToAddModList->list,pucchresset1); + pucch_Config->resourceToAddModList = calloc(1,sizeof(*pucch_Config->resourceToAddModList)); pucch_Config->resourceToReleaseList = NULL; // configure one single PUCCH0 opportunity for initial connection procedure // one symbol (13) NR_PUCCH_Resource_t *pucchres0=calloc(1,sizeof(*pucchres0)); pucchres0->pucch_ResourceId=0; - pucchres0->startingPRB=(8+uid) % curr_bwp; + //pucchres0->startingPRB=0; + pucchres0->startingPRB=(8+uid) % (curr_bwp/2); LOG_D(NR_RRC, "pucchres0->startPRB %ld uid %d curr_bwp %d\n", pucchres0->startingPRB, uid, curr_bwp); pucchres0->intraSlotFrequencyHopping=NULL; pucchres0->secondHopPRB=NULL; @@ -1053,6 +1523,49 @@ void fill_initial_SpCellConfig(int uid, pucchres0->format.choice.format0->nrofSymbols=1; pucchres0->format.choice.format0->startingSymbolIndex=13; ASN_SEQUENCE_ADD(&pucch_Config->resourceToAddModList->list,pucchres0); + + NR_PUCCH_Resource_t *pucchres2=calloc(1,sizeof(*pucchres2)); + pucchres2->pucch_ResourceId=1; + pucchres2->startingPRB=0; + pucchres2->intraSlotFrequencyHopping=NULL; + pucchres2->secondHopPRB=NULL; + pucchres2->format.present= NR_PUCCH_Resource__format_PR_format2; + pucchres2->format.choice.format2=calloc(1,sizeof(*pucchres2->format.choice.format2)); + pucchres2->format.choice.format2->nrofPRBs=8; + pucchres2->format.choice.format2->nrofSymbols=1; + pucchres2->format.choice.format2->startingSymbolIndex=13; + ASN_SEQUENCE_ADD(&pucch_Config->resourceToAddModList->list,pucchres2); + + pucch_Config->format2=calloc(1,sizeof(*pucch_Config->format2)); + pucch_Config->format2->present=NR_SetupRelease_PUCCH_FormatConfig_PR_setup; + NR_PUCCH_FormatConfig_t *pucchfmt2 = calloc(1,sizeof(*pucchfmt2)); + pucch_Config->format2->choice.setup = pucchfmt2; + pucchfmt2->interslotFrequencyHopping=NULL; + pucchfmt2->additionalDMRS=NULL; + pucchfmt2->maxCodeRate=calloc(1,sizeof(*pucchfmt2->maxCodeRate)); + *pucchfmt2->maxCodeRate=NR_PUCCH_MaxCodeRate_zeroDot35; + pucchfmt2->nrofSlots=NULL; + pucchfmt2->pi2BPSK=NULL; + pucchfmt2->simultaneousHARQ_ACK_CSI=calloc(1,sizeof(*pucchfmt2->simultaneousHARQ_ACK_CSI)); + *pucchfmt2->simultaneousHARQ_ACK_CSI=NR_PUCCH_FormatConfig__simultaneousHARQ_ACK_CSI_true; + + pucch_Config->spatialRelationInfoToAddModList = calloc(1,sizeof(*pucch_Config->spatialRelationInfoToAddModList)); + NR_PUCCH_SpatialRelationInfo_t *pucchspatial = calloc(1,sizeof(*pucchspatial)); + pucchspatial->pucch_SpatialRelationInfoId = 1; + pucchspatial->servingCellId = NULL; + if(configuration->do_CSIRS) { + pucchspatial->referenceSignal.present = NR_PUCCH_SpatialRelationInfo__referenceSignal_PR_csi_RS_Index; + pucchspatial->referenceSignal.choice.csi_RS_Index = 0; + } + else { + pucchspatial->referenceSignal.present = NR_PUCCH_SpatialRelationInfo__referenceSignal_PR_ssb_Index; + pucchspatial->referenceSignal.choice.ssb_Index = 0; + } + pucchspatial->pucch_PathlossReferenceRS_Id = 0; + pucchspatial->p0_PUCCH_Id = 1; + pucchspatial->closedLoopIndex = NR_PUCCH_SpatialRelationInfo__closedLoopIndex_i0; + ASN_SEQUENCE_ADD(&pucch_Config->spatialRelationInfoToAddModList->list,pucchspatial); + initialUplinkBWP->pusch_Config = calloc(1,sizeof(*initialUplinkBWP->pusch_Config)); initialUplinkBWP->pusch_Config->present = NR_SetupRelease_PUSCH_Config_PR_setup; NR_PUSCH_Config_t *pusch_Config = calloc(1,sizeof(*pusch_Config)); @@ -1139,7 +1652,7 @@ void fill_initial_SpCellConfig(int uid, ASN_SEQUENCE_ADD(&srs_resset0->srs_ResourceIdList->list,srs_resset0_id); srs_Config->srs_ResourceToReleaseList=NULL; - if(carrier->do_SRS) { + if (configuration->do_SRS) { srs_resset0->resourceType.present = NR_SRS_ResourceSet__resourceType_PR_periodic; srs_resset0->resourceType.choice.periodic = calloc(1,sizeof(*srs_resset0->resourceType.choice.periodic)); srs_resset0->resourceType.choice.periodic->associatedCSI_RS = NULL; @@ -1183,7 +1696,7 @@ void fill_initial_SpCellConfig(int uid, srs_res0->freqHopping.b_SRS); srs_res0->groupOrSequenceHopping=NR_SRS_Resource__groupOrSequenceHopping_neither; - if(carrier->do_SRS) { + if (configuration->do_SRS) { srs_res0->resourceType.present= NR_SRS_Resource__resourceType_PR_periodic; srs_res0->resourceType.choice.periodic=calloc(1,sizeof(*srs_res0->resourceType.choice.periodic)); srs_res0->resourceType.choice.periodic->periodicityAndOffset_p.present = NR_SRS_PeriodicityAndOffset_PR_sl160; @@ -1205,21 +1718,12 @@ void fill_initial_SpCellConfig(int uid, pucch_Config->schedulingRequestResourceToAddModList = calloc(1,sizeof(*pucch_Config->schedulingRequestResourceToAddModList)); NR_SchedulingRequestResourceConfig_t *schedulingRequestResourceConfig = calloc(1,sizeof(*schedulingRequestResourceConfig)); schedulingRequestResourceConfig->schedulingRequestResourceId = 1; - schedulingRequestResourceConfig->schedulingRequestID= 0; + schedulingRequestResourceConfig->schedulingRequestID = 0; schedulingRequestResourceConfig->periodicityAndOffset = calloc(1,sizeof(*schedulingRequestResourceConfig->periodicityAndOffset)); schedulingRequestResourceConfig->periodicityAndOffset->present = NR_SchedulingRequestResourceConfig__periodicityAndOffset_PR_sl40; - // note: make sure that there is no issue here. Later choose the RNTI accordingly. - // Here we would be limited to 3 UEs on this resource (1 1/2 Frames 30 kHz SCS, 5 ms TDD periodicity => slots 7,8,9). - // This should be a temporary resource until the first RRCReconfiguration gives new pucch resources. - // Check for above configuration and exit for now if it is not the case AssertFatal(scc->downlinkConfigCommon->initialDownlinkBWP->genericParameters.subcarrierSpacing==NR_SubcarrierSpacing_kHz30, "SCS != 30kHz\n"); - if (scc->tdd_UL_DL_ConfigurationCommon) { - AssertFatal(scc->tdd_UL_DL_ConfigurationCommon->pattern1.dl_UL_TransmissionPeriodicity == NR_TDD_UL_DL_Pattern__dl_UL_TransmissionPeriodicity_ms5, - "TDD period != 5ms : %ld\n", scc->tdd_UL_DL_ConfigurationCommon->pattern1.dl_UL_TransmissionPeriodicity); - } - schedulingRequestResourceConfig->periodicityAndOffset->choice.sl40 = 8; schedulingRequestResourceConfig->resource = calloc(1,sizeof(*schedulingRequestResourceConfig->resource)); *schedulingRequestResourceConfig->resource = 0; @@ -1229,9 +1733,9 @@ void fill_initial_SpCellConfig(int uid, long *delay[8]; for (int i=0;i<8;i++) { delay[i] = calloc(1,sizeof(*delay[i])); - AssertFatal(carrier->minRXTXTIME >=2 && carrier->minRXTXTIME <7, - "check minRXTXTIME %d\n",carrier->minRXTXTIME); - *delay[i] = (i+carrier->minRXTXTIME); + AssertFatal(configuration->minRXTXTIME >= 2 && configuration->minRXTXTIME < 7, + "minRXTXTIME is %d but should be within [2,7)\n", configuration->minRXTXTIME); + *delay[i] = i + configuration->minRXTXTIME; ASN_SEQUENCE_ADD(&pucch_Config->dl_DataToUL_ACK->list,delay[i]); } @@ -1246,38 +1750,9 @@ void fill_initial_SpCellConfig(int uid, bwp_Dedicated->pdcch_Config->choice.setup->controlResourceSetToAddModList = calloc(1,sizeof(*bwp_Dedicated->pdcch_Config->choice.setup->controlResourceSetToAddModList)); NR_ControlResourceSet_t *coreset = calloc(1,sizeof(*coreset)); - coreset->controlResourceSetId=1; - // frequency domain resources depends on BWP size - // options are 24, 48 or 96 - coreset->frequencyDomainResources.buf = calloc(1,6); - if (0) { - int curr_bwp = scc->downlinkConfigCommon->frequencyInfoDL->scs_SpecificCarrierList.list.array[0]->carrierBandwidth; - if (curr_bwp < 48) - coreset->frequencyDomainResources.buf[0] = 0xf0; - else - coreset->frequencyDomainResources.buf[0] = 0xff; - if (curr_bwp < 96) - coreset->frequencyDomainResources.buf[1] = 0; - else - coreset->frequencyDomainResources.buf[1] = 0xff; - } else { - coreset->frequencyDomainResources.buf[0] = 0xf0; - coreset->frequencyDomainResources.buf[1] = 0; - } - coreset->frequencyDomainResources.buf[2] = 0; - coreset->frequencyDomainResources.buf[3] = 0; - coreset->frequencyDomainResources.buf[4] = 0; - coreset->frequencyDomainResources.buf[5] = 0; - coreset->frequencyDomainResources.size = 6; - coreset->frequencyDomainResources.bits_unused = 3; - coreset->duration=1; - coreset->cce_REG_MappingType.present = NR_ControlResourceSet__cce_REG_MappingType_PR_nonInterleaved; - coreset->precoderGranularity = NR_ControlResourceSet__precoderGranularity_sameAsREG_bundle; - coreset->tci_StatesPDCCH_ToAddList=NULL; - coreset->tci_StatesPDCCH_ToReleaseList = NULL; - coreset->tci_PresentInDCI = NULL; - coreset->pdcch_DMRS_ScramblingID = NULL; + uint64_t bitmap = get_ssb_bitmap(scc); + rrc_coreset_config(coreset, 0, curr_bwp, bitmap); ASN_SEQUENCE_ADD(&bwp_Dedicated->pdcch_Config->choice.setup->controlResourceSetToAddModList->list, coreset); @@ -1288,7 +1763,7 @@ void fill_initial_SpCellConfig(int uid, ss2->searchSpaceId=2; ss2->controlResourceSetId=calloc(1,sizeof(*ss2->controlResourceSetId)); - *ss2->controlResourceSetId=1; + *ss2->controlResourceSetId=coreset->controlResourceSetId; ss2->monitoringSlotPeriodicityAndOffset=calloc(1,sizeof(*ss2->monitoringSlotPeriodicityAndOffset)); ss2->monitoringSlotPeriodicityAndOffset->present = NR_SearchSpace__monitoringSlotPeriodicityAndOffset_PR_sl1; ss2->monitoringSlotPeriodicityAndOffset->choice.sl1=(NULL_t)0; @@ -1296,9 +1771,9 @@ void fill_initial_SpCellConfig(int uid, ss2->monitoringSymbolsWithinSlot = calloc(1,sizeof(*ss2->monitoringSymbolsWithinSlot)); ss2->monitoringSymbolsWithinSlot->buf = calloc(1,2); ss2->monitoringSymbolsWithinSlot->size = 2; - ss2->monitoringSymbolsWithinSlot->bits_unused = 2; ss2->monitoringSymbolsWithinSlot->buf[0]=0x80; ss2->monitoringSymbolsWithinSlot->buf[1]=0x0; + ss2->monitoringSymbolsWithinSlot->bits_unused = 2; ss2->nrofCandidates=calloc(1,sizeof(*ss2->nrofCandidates)); ss2->nrofCandidates->aggregationLevel1 = NR_SearchSpace__nrofCandidates__aggregationLevel1_n0; ss2->nrofCandidates->aggregationLevel2 = NR_SearchSpace__nrofCandidates__aggregationLevel2_n2; @@ -1350,6 +1825,191 @@ void fill_initial_SpCellConfig(int uid, NR_PDSCH_ServingCellConfig_t *pdsch_servingcellconfig = calloc(1,sizeof(*pdsch_servingcellconfig)); SpCellConfig->spCellConfigDedicated->pdsch_ServingCellConfig->present = NR_SetupRelease_PDSCH_ServingCellConfig_PR_setup; SpCellConfig->spCellConfigDedicated->pdsch_ServingCellConfig->choice.setup = pdsch_servingcellconfig; + + if (configuration->do_CSIRS) { + + SpCellConfig->spCellConfigDedicated->csi_MeasConfig=calloc(1,sizeof(*SpCellConfig->spCellConfigDedicated->csi_MeasConfig)); + SpCellConfig->spCellConfigDedicated->csi_MeasConfig->present = NR_SetupRelease_CSI_MeasConfig_PR_setup; + + NR_CSI_MeasConfig_t *csi_MeasConfig = calloc(1,sizeof(*csi_MeasConfig)); + SpCellConfig->spCellConfigDedicated->csi_MeasConfig->choice.setup = csi_MeasConfig; + int pdsch_AntennaPorts = configuration->pdsch_AntennaPorts.N1 * configuration->pdsch_AntennaPorts.N2 * configuration->pdsch_AntennaPorts.XP; + + config_csirs(scc, csi_MeasConfig, uid, pdsch_AntennaPorts, curr_bwp, configuration->do_CSIRS); + config_csiim(configuration->do_CSIRS, pdsch_AntennaPorts, curr_bwp, csi_MeasConfig); + + csi_MeasConfig->csi_SSB_ResourceSetToAddModList = calloc(1,sizeof(*csi_MeasConfig->csi_SSB_ResourceSetToAddModList)); + csi_MeasConfig->csi_SSB_ResourceSetToReleaseList = NULL; + + NR_CSI_SSB_ResourceSet_t *ssbresset0 = calloc(1,sizeof(*ssbresset0)); + ssbresset0->csi_SSB_ResourceSetId=0; + + uint64_t bitmap=0; + switch (scc->ssb_PositionsInBurst->present) { + case 1 : + bitmap = ((uint64_t) scc->ssb_PositionsInBurst->choice.shortBitmap.buf[0])<<56; + break; + case 2 : + bitmap = ((uint64_t) scc->ssb_PositionsInBurst->choice.mediumBitmap.buf[0])<<56; + break; + case 3 : + for (int i=0; i<8; i++) { + bitmap |= (((uint64_t) scc->ssb_PositionsInBurst->choice.longBitmap.buf[i])<<((7-i)*8)); + } + break; + default: + AssertFatal(1==0,"SSB bitmap size value %d undefined (allowed values 1,2,3) \n", scc->ssb_PositionsInBurst->present); + } + + NR_SSB_Index_t *ssbresset[64]; + for (int i=0;i<64;i++) { + if ((bitmap>>(63-i))&0x01){ + ssbresset[i]=calloc(1,sizeof(*ssbresset[i])); + *ssbresset[i] = i; + ASN_SEQUENCE_ADD(&ssbresset0->csi_SSB_ResourceList.list,ssbresset[i]); + } + } + ASN_SEQUENCE_ADD(&csi_MeasConfig->csi_SSB_ResourceSetToAddModList->list,ssbresset0); + + csi_MeasConfig->csi_ResourceConfigToAddModList = calloc(1,sizeof(*csi_MeasConfig->csi_ResourceConfigToAddModList)); + + csi_MeasConfig->csi_ResourceConfigToReleaseList = NULL; + NR_CSI_ResourceConfig_t *csires0 = calloc(1,sizeof(*csires0)); + csires0->csi_ResourceConfigId=0; + csires0->csi_RS_ResourceSetList.present = NR_CSI_ResourceConfig__csi_RS_ResourceSetList_PR_nzp_CSI_RS_SSB; + csires0->csi_RS_ResourceSetList.choice.nzp_CSI_RS_SSB = calloc(1,sizeof(*csires0->csi_RS_ResourceSetList.choice.nzp_CSI_RS_SSB)); + csires0->csi_RS_ResourceSetList.choice.nzp_CSI_RS_SSB->nzp_CSI_RS_ResourceSetList = calloc(1,sizeof(*csires0->csi_RS_ResourceSetList.choice.nzp_CSI_RS_SSB->nzp_CSI_RS_ResourceSetList)); + NR_NZP_CSI_RS_ResourceSetId_t *nzp0 = calloc(1,sizeof(*nzp0)); + *nzp0 = 0; + ASN_SEQUENCE_ADD(&csires0->csi_RS_ResourceSetList.choice.nzp_CSI_RS_SSB->nzp_CSI_RS_ResourceSetList->list,nzp0); + csires0->bwp_Id = 0; + csires0->resourceType = NR_CSI_ResourceConfig__resourceType_periodic; + ASN_SEQUENCE_ADD(&csi_MeasConfig->csi_ResourceConfigToAddModList->list,csires0); + + + NR_CSI_ResourceConfig_t *csires1 = calloc(1,sizeof(*csires1)); + csires1->csi_ResourceConfigId=1; + csires1->csi_RS_ResourceSetList.present = NR_CSI_ResourceConfig__csi_RS_ResourceSetList_PR_nzp_CSI_RS_SSB; + csires1->csi_RS_ResourceSetList.choice.nzp_CSI_RS_SSB = calloc(1,sizeof(*csires1->csi_RS_ResourceSetList.choice.nzp_CSI_RS_SSB)); + csires1->csi_RS_ResourceSetList.choice.nzp_CSI_RS_SSB->csi_SSB_ResourceSetList = calloc(1,sizeof(*csires1->csi_RS_ResourceSetList.choice.nzp_CSI_RS_SSB->csi_SSB_ResourceSetList)); + NR_CSI_SSB_ResourceSetId_t *ssbres00 = calloc(1,sizeof(*ssbres00)); + *ssbres00 = 0; + ASN_SEQUENCE_ADD(&csires1->csi_RS_ResourceSetList.choice.nzp_CSI_RS_SSB->csi_SSB_ResourceSetList->list,ssbres00); + csires1->bwp_Id = 0; + csires1->resourceType = NR_CSI_ResourceConfig__resourceType_periodic; + ASN_SEQUENCE_ADD(&csi_MeasConfig->csi_ResourceConfigToAddModList->list,csires1); + + if (pdsch_AntennaPorts > 1) { + NR_CSI_ResourceConfig_t *csires2 = calloc(1,sizeof(*csires2)); + csires2->csi_ResourceConfigId=2; + csires2->csi_RS_ResourceSetList.present = NR_CSI_ResourceConfig__csi_RS_ResourceSetList_PR_csi_IM_ResourceSetList; + csires2->csi_RS_ResourceSetList.choice.csi_IM_ResourceSetList = calloc(1,sizeof(*csires2->csi_RS_ResourceSetList.choice.csi_IM_ResourceSetList)); + NR_CSI_IM_ResourceSetId_t *csiim00 = calloc(1,sizeof(*csiim00)); + *csiim00 = 0; + ASN_SEQUENCE_ADD(&csires2->csi_RS_ResourceSetList.choice.csi_IM_ResourceSetList->list,csiim00); + csires2->bwp_Id=0; + csires2->resourceType = NR_CSI_ResourceConfig__resourceType_periodic; + ASN_SEQUENCE_ADD(&csi_MeasConfig->csi_ResourceConfigToAddModList->list,csires2); + } + + NR_PUCCH_CSI_Resource_t *pucchcsires1 = calloc(1,sizeof(*pucchcsires1)); + pucchcsires1->uplinkBandwidthPartId=0; + pucchcsires1->pucch_Resource=1; + csi_MeasConfig->csi_ReportConfigToAddModList = calloc(1,sizeof(*csi_MeasConfig->csi_ReportConfigToAddModList)); + csi_MeasConfig->csi_ReportConfigToReleaseList = NULL; + if (pdsch_AntennaPorts > 1) { + LOG_I(NR_RRC,"Filling CSI Report Config for RI_PMI_CQI\n"); + NR_CSI_ReportConfig_t *csirep1 = calloc(1,sizeof(*csirep1)); + csirep1->reportConfigId=0; + csirep1->carrier=NULL; + csirep1->resourcesForChannelMeasurement=0; + csirep1->csi_IM_ResourcesForInterference=calloc(1,sizeof(*csirep1->csi_IM_ResourcesForInterference)); + *csirep1->csi_IM_ResourcesForInterference=2; + csirep1->nzp_CSI_RS_ResourcesForInterference=NULL; + csirep1->reportConfigType.present = NR_CSI_ReportConfig__reportConfigType_PR_periodic; + csirep1->reportConfigType.choice.periodic = calloc(1,sizeof(*csirep1->reportConfigType.choice.periodic)); + csirep1->reportConfigType.choice.periodic->reportSlotConfig.present=NR_CSI_ReportPeriodicityAndOffset_PR_slots320; + csirep1->reportConfigType.choice.periodic->reportSlotConfig.choice.slots320 = (7 + (20 * uid)) % 320; + ASN_SEQUENCE_ADD(&csirep1->reportConfigType.choice.periodic->pucch_CSI_ResourceList.list,pucchcsires1); + csirep1->reportQuantity.present = NR_CSI_ReportConfig__reportQuantity_PR_cri_RI_PMI_CQI; + csirep1->reportQuantity.choice.cri_RI_PMI_CQI=(NULL_t)0; + csirep1->reportFreqConfiguration = calloc(1,sizeof(*csirep1->reportFreqConfiguration)); + csirep1->reportFreqConfiguration->cqi_FormatIndicator = calloc(1,sizeof(*csirep1->reportFreqConfiguration->cqi_FormatIndicator)); + *csirep1->reportFreqConfiguration->cqi_FormatIndicator=NR_CSI_ReportConfig__reportFreqConfiguration__cqi_FormatIndicator_widebandCQI; + csirep1->reportFreqConfiguration->pmi_FormatIndicator = calloc(1,sizeof(*csirep1->reportFreqConfiguration->pmi_FormatIndicator)); + *csirep1->reportFreqConfiguration->pmi_FormatIndicator=NR_CSI_ReportConfig__reportFreqConfiguration__pmi_FormatIndicator_widebandPMI; + csirep1->reportFreqConfiguration->csi_ReportingBand = NULL; + /*calloc(1,sizeof(*csirep1->reportFreqConfiguration->csi_ReportingBand)); + csirep1->reportFreqConfiguration->csi_ReportingBand->present = NR_CSI_ReportConfig__reportFreqConfiguration__csi_ReportingBand_PR_subbands7; + csirep1->reportFreqConfiguration->csi_ReportingBand->choice.subbands7.size=1; + csirep1->reportFreqConfiguration->csi_ReportingBand->choice.subbands7.bits_unused=1; + csirep1->reportFreqConfiguration->csi_ReportingBand->choice.subbands7.buf=malloc(1); + csirep1->reportFreqConfiguration->csi_ReportingBand->choice.subbands7.buf[0]=254;*/ + csirep1->timeRestrictionForChannelMeasurements= NR_CSI_ReportConfig__timeRestrictionForChannelMeasurements_notConfigured; + csirep1->timeRestrictionForInterferenceMeasurements=NR_CSI_ReportConfig__timeRestrictionForInterferenceMeasurements_notConfigured; + csirep1->codebookConfig=calloc(1,sizeof(*csirep1->codebookConfig)); + csirep1->codebookConfig->codebookType.present = NR_CodebookConfig__codebookType_PR_type1; + csirep1->codebookConfig->codebookType.choice.type1 = calloc(1,sizeof(*csirep1->codebookConfig->codebookType.choice.type1)); + csirep1->codebookConfig->codebookType.choice.type1->subType.present=NR_CodebookConfig__codebookType__type1__subType_PR_typeI_SinglePanel; + csirep1->codebookConfig->codebookType.choice.type1->subType.choice.typeI_SinglePanel=calloc(1,sizeof(*csirep1->codebookConfig->codebookType.choice.type1->subType.choice.typeI_SinglePanel)); + csirep1->codebookConfig->codebookType.choice.type1->subType.choice.typeI_SinglePanel->nrOfAntennaPorts.present= + NR_CodebookConfig__codebookType__type1__subType__typeI_SinglePanel__nrOfAntennaPorts_PR_two; + csirep1->codebookConfig->codebookType.choice.type1->subType.choice.typeI_SinglePanel->nrOfAntennaPorts.choice.two= + calloc(1,sizeof(*csirep1->codebookConfig->codebookType.choice.type1->subType.choice.typeI_SinglePanel->nrOfAntennaPorts.choice.two)); + csirep1->codebookConfig->codebookType.choice.type1->subType.choice.typeI_SinglePanel->nrOfAntennaPorts.choice.two->twoTX_CodebookSubsetRestriction.size=1; + csirep1->codebookConfig->codebookType.choice.type1->subType.choice.typeI_SinglePanel->nrOfAntennaPorts.choice.two->twoTX_CodebookSubsetRestriction.bits_unused=2; + csirep1->codebookConfig->codebookType.choice.type1->subType.choice.typeI_SinglePanel->nrOfAntennaPorts.choice.two->twoTX_CodebookSubsetRestriction.buf=malloc(1); + csirep1->codebookConfig->codebookType.choice.type1->subType.choice.typeI_SinglePanel->nrOfAntennaPorts.choice.two->twoTX_CodebookSubsetRestriction.buf[0]=0xfc; + csirep1->codebookConfig->codebookType.choice.type1->subType.choice.typeI_SinglePanel->typeI_SinglePanel_ri_Restriction.size=1; + csirep1->codebookConfig->codebookType.choice.type1->subType.choice.typeI_SinglePanel->typeI_SinglePanel_ri_Restriction.bits_unused=0; + csirep1->codebookConfig->codebookType.choice.type1->subType.choice.typeI_SinglePanel->typeI_SinglePanel_ri_Restriction.buf=malloc(1); + csirep1->codebookConfig->codebookType.choice.type1->subType.choice.typeI_SinglePanel->typeI_SinglePanel_ri_Restriction.buf[0]=0x03; + csirep1->codebookConfig->codebookType.choice.type1->codebookMode=1; + csirep1->dummy = NULL; + csirep1->groupBasedBeamReporting.present = NR_CSI_ReportConfig__groupBasedBeamReporting_PR_disabled; + csirep1->groupBasedBeamReporting.choice.disabled=calloc(1,sizeof(*csirep1->groupBasedBeamReporting.choice.disabled)); + //csirep1->groupBasedBeamReporting.choice.disabled->nrofReportedRS = calloc(1,sizeof(*csirep1->groupBasedBeamReporting.choice.disabled->nrofReportedRS)); + //*csirep1->groupBasedBeamReporting.choice.disabled->nrofReportedRS=NR_CSI_ReportConfig__groupBasedBeamReporting__disabled__nrofReportedRS_n1; + csirep1->cqi_Table = calloc(1,sizeof(*csirep1->cqi_Table)); + *csirep1->cqi_Table = NR_CSI_ReportConfig__cqi_Table_table1; + csirep1->subbandSize = NR_CSI_ReportConfig__subbandSize_value2; + csirep1->non_PMI_PortIndication = NULL; + csirep1->ext1 = NULL; + ASN_SEQUENCE_ADD(&csi_MeasConfig->csi_ReportConfigToAddModList->list,csirep1); + } + + LOG_I(NR_RRC,"Filling CSI Report Config for CRI_RSRP\n"); + NR_CSI_ReportConfig_t *csirep2 = calloc(1,sizeof(*csirep2)); + csirep2->reportConfigId=1; + csirep2->carrier=NULL; + csirep2->resourcesForChannelMeasurement=0; + csirep2->csi_IM_ResourcesForInterference=NULL; + csirep2->nzp_CSI_RS_ResourcesForInterference=NULL; + csirep2->reportConfigType.present = NR_CSI_ReportConfig__reportConfigType_PR_periodic; + csirep2->reportConfigType.choice.periodic = calloc(1,sizeof(*csirep2->reportConfigType.choice.periodic)); + csirep2->reportConfigType.choice.periodic->reportSlotConfig.present=NR_CSI_ReportPeriodicityAndOffset_PR_slots320; + csirep2->reportConfigType.choice.periodic->reportSlotConfig.choice.slots320 = (27 + (20 * uid)) % 320; + ASN_SEQUENCE_ADD(&csirep2->reportConfigType.choice.periodic->pucch_CSI_ResourceList.list,pucchcsires1); + csirep2->reportQuantity.present = NR_CSI_ReportConfig__reportQuantity_PR_cri_RSRP; + csirep2->reportQuantity.choice.cri_RSRP=(NULL_t)0; + csirep2->reportFreqConfiguration = calloc(1,sizeof(*csirep2->reportFreqConfiguration)); + csirep2->reportFreqConfiguration->cqi_FormatIndicator = NULL; + csirep2->reportFreqConfiguration->pmi_FormatIndicator=NULL; + csirep2->reportFreqConfiguration->csi_ReportingBand=NULL; + csirep2->timeRestrictionForChannelMeasurements= NR_CSI_ReportConfig__timeRestrictionForChannelMeasurements_configured; + csirep2->timeRestrictionForInterferenceMeasurements=NR_CSI_ReportConfig__timeRestrictionForInterferenceMeasurements_configured; + csirep2->codebookConfig=NULL; + csirep2->dummy = NULL; + csirep2->groupBasedBeamReporting.present = NR_CSI_ReportConfig__groupBasedBeamReporting_PR_disabled; + csirep2->groupBasedBeamReporting.choice.disabled=calloc(1,sizeof(*csirep2->groupBasedBeamReporting.choice.disabled)); + csirep2->groupBasedBeamReporting.choice.disabled->nrofReportedRS=calloc(1,sizeof(*csirep2->groupBasedBeamReporting.choice.disabled->nrofReportedRS)); + *csirep2->groupBasedBeamReporting.choice.disabled->nrofReportedRS=NR_CSI_ReportConfig__groupBasedBeamReporting__disabled__nrofReportedRS_n1; + csirep2->cqi_Table = NULL; + csirep2->subbandSize = NR_CSI_ReportConfig__subbandSize_value1; + csirep2->non_PMI_PortIndication = NULL; + csirep2->ext1 = NULL; + ASN_SEQUENCE_ADD(&csi_MeasConfig->csi_ReportConfigToAddModList->list,csirep2); + } pdsch_servingcellconfig->codeBlockGroupTransmission = NULL; pdsch_servingcellconfig->xOverhead = NULL; pdsch_servingcellconfig->nrofHARQ_ProcessesForPDSCH = calloc(1, sizeof(*pdsch_servingcellconfig->nrofHARQ_ProcessesForPDSCH)); @@ -1359,9 +2019,127 @@ void fill_initial_SpCellConfig(int uid, pdsch_servingcellconfig->ext1->maxMIMO_Layers = calloc(1,sizeof(*pdsch_servingcellconfig->ext1->maxMIMO_Layers)); *pdsch_servingcellconfig->ext1->maxMIMO_Layers = 2; + // Downlink BWPs + int n_dl_bwp = 0; + if (servingcellconfigdedicated && + servingcellconfigdedicated->downlinkBWP_ToAddModList && + servingcellconfigdedicated->downlinkBWP_ToAddModList->list.count > 0) { + n_dl_bwp = servingcellconfigdedicated->downlinkBWP_ToAddModList->list.count; + } + if(n_dl_bwp>0){ + SpCellConfig->spCellConfigDedicated->downlinkBWP_ToAddModList = calloc(1,sizeof(*SpCellConfig->spCellConfigDedicated->downlinkBWP_ToAddModList)); + for (int bwp_loop = 0; bwp_loop < n_dl_bwp; bwp_loop++) { + NR_BWP_Downlink_t *bwp = calloc(1, sizeof(*bwp)); + fill_default_downlinkBWP(bwp, bwp_loop, servingcellconfigdedicated, scc, configuration); + ASN_SEQUENCE_ADD(&SpCellConfig->spCellConfigDedicated->downlinkBWP_ToAddModList->list,bwp); + } + SpCellConfig->spCellConfigDedicated->firstActiveDownlinkBWP_Id = calloc(1,sizeof(*SpCellConfig->spCellConfigDedicated->firstActiveDownlinkBWP_Id)); + *SpCellConfig->spCellConfigDedicated->firstActiveDownlinkBWP_Id = servingcellconfigdedicated->firstActiveDownlinkBWP_Id ? *servingcellconfigdedicated->firstActiveDownlinkBWP_Id : 1; + SpCellConfig->spCellConfigDedicated->defaultDownlinkBWP_Id = calloc(1,sizeof(*SpCellConfig->spCellConfigDedicated->defaultDownlinkBWP_Id)); + *SpCellConfig->spCellConfigDedicated->defaultDownlinkBWP_Id = servingcellconfigdedicated->defaultDownlinkBWP_Id ? *servingcellconfigdedicated->defaultDownlinkBWP_Id : 1; + } + + // Uplink BWPs + int n_ul_bwp = 0; + if (servingcellconfigdedicated && servingcellconfigdedicated->uplinkConfig && + servingcellconfigdedicated->uplinkConfig->uplinkBWP_ToAddModList && + servingcellconfigdedicated->uplinkConfig->uplinkBWP_ToAddModList->list.count > 0) { + n_ul_bwp = servingcellconfigdedicated->uplinkConfig->uplinkBWP_ToAddModList->list.count; + } + if(n_ul_bwp>0) { + SpCellConfig->spCellConfigDedicated->uplinkConfig->uplinkBWP_ToAddModList = calloc(1,sizeof(*SpCellConfig->spCellConfigDedicated->uplinkConfig->uplinkBWP_ToAddModList)); + for (int bwp_loop = 0; bwp_loop < n_ul_bwp; bwp_loop++) { + NR_BWP_Uplink_t *ubwp = calloc(1, sizeof(*ubwp)); + fill_default_uplinkBWP(ubwp, bwp_loop, servingcellconfigdedicated, scc, configuration, uid); + ASN_SEQUENCE_ADD(&SpCellConfig->spCellConfigDedicated->uplinkConfig->uplinkBWP_ToAddModList->list, ubwp); + } + SpCellConfig->spCellConfigDedicated->uplinkConfig->firstActiveUplinkBWP_Id = calloc(1,sizeof(*SpCellConfig->spCellConfigDedicated->uplinkConfig->firstActiveUplinkBWP_Id)); + *SpCellConfig->spCellConfigDedicated->uplinkConfig->firstActiveUplinkBWP_Id = servingcellconfigdedicated->uplinkConfig->firstActiveUplinkBWP_Id ? *servingcellconfigdedicated->uplinkConfig->firstActiveUplinkBWP_Id : 1; + } + + if ( LOG_DEBUGFLAG(DEBUG_ASN1) ) { + xer_fprint(stdout, &asn_DEF_NR_SpCellConfig, (void *)SpCellConfig); + } + } -void fill_mastercellGroupConfig(NR_CellGroupConfig_t *cellGroupConfig, NR_CellGroupConfig_t *ue_context_mastercellGroup) { +NR_RLC_BearerConfig_t *get_SRB_RLC_BearerConfig(long channelId, + long priority, + e_NR_LogicalChannelConfig__ul_SpecificParameters__bucketSizeDuration bucketSizeDuration) +{ + NR_RLC_BearerConfig_t *rlc_BearerConfig = NULL; + rlc_BearerConfig = calloc(1, sizeof(NR_RLC_BearerConfig_t)); + rlc_BearerConfig->logicalChannelIdentity = channelId; + rlc_BearerConfig->servedRadioBearer = calloc(1, sizeof(*rlc_BearerConfig->servedRadioBearer)); + rlc_BearerConfig->servedRadioBearer->present = NR_RLC_BearerConfig__servedRadioBearer_PR_srb_Identity; + rlc_BearerConfig->servedRadioBearer->choice.srb_Identity = channelId; + rlc_BearerConfig->reestablishRLC = NULL; + + NR_RLC_Config_t *rlc_Config = calloc(1, sizeof(NR_RLC_Config_t)); + rlc_Config->present = NR_RLC_Config_PR_am; + rlc_Config->choice.am = calloc(1, sizeof(*rlc_Config->choice.am)); + rlc_Config->choice.am->dl_AM_RLC.sn_FieldLength = calloc(1, sizeof(NR_SN_FieldLengthAM_t)); + *(rlc_Config->choice.am->dl_AM_RLC.sn_FieldLength) = NR_SN_FieldLengthAM_size12; + rlc_Config->choice.am->dl_AM_RLC.t_Reassembly = NR_T_Reassembly_ms35; + rlc_Config->choice.am->dl_AM_RLC.t_StatusProhibit = NR_T_StatusProhibit_ms0; + rlc_Config->choice.am->ul_AM_RLC.sn_FieldLength = calloc(1, sizeof(NR_SN_FieldLengthAM_t)); + *(rlc_Config->choice.am->ul_AM_RLC.sn_FieldLength) = NR_SN_FieldLengthAM_size12; + rlc_Config->choice.am->ul_AM_RLC.t_PollRetransmit = NR_T_PollRetransmit_ms45; + rlc_Config->choice.am->ul_AM_RLC.pollPDU = NR_PollPDU_infinity; + rlc_Config->choice.am->ul_AM_RLC.pollByte = NR_PollByte_infinity; + rlc_Config->choice.am->ul_AM_RLC.maxRetxThreshold = NR_UL_AM_RLC__maxRetxThreshold_t8; + rlc_BearerConfig->rlc_Config = rlc_Config; + + NR_LogicalChannelConfig_t *logicalChannelConfig = calloc(1, sizeof(NR_LogicalChannelConfig_t)); + logicalChannelConfig->ul_SpecificParameters = calloc(1, sizeof(*logicalChannelConfig->ul_SpecificParameters)); + logicalChannelConfig->ul_SpecificParameters->priority = priority; + logicalChannelConfig->ul_SpecificParameters->prioritisedBitRate = NR_LogicalChannelConfig__ul_SpecificParameters__prioritisedBitRate_infinity; + logicalChannelConfig->ul_SpecificParameters->bucketSizeDuration = bucketSizeDuration; + + long *logicalChannelGroup = CALLOC(1, sizeof(long)); + *logicalChannelGroup = 0; + logicalChannelConfig->ul_SpecificParameters->logicalChannelGroup = logicalChannelGroup; + logicalChannelConfig->ul_SpecificParameters->schedulingRequestID = CALLOC(1, sizeof(*logicalChannelConfig->ul_SpecificParameters->schedulingRequestID)); + *logicalChannelConfig->ul_SpecificParameters->schedulingRequestID = 0; + logicalChannelConfig->ul_SpecificParameters->logicalChannelSR_Mask = 0; + logicalChannelConfig->ul_SpecificParameters->logicalChannelSR_DelayTimerApplied = 0; + rlc_BearerConfig->mac_LogicalChannelConfig = logicalChannelConfig; + + return rlc_BearerConfig; +} + +NR_RLC_BearerConfig_t *get_DRB_RLC_BearerConfig(long lcChannelId, long drbId, NR_RLC_Config_PR rlc_conf, long priority) +{ + NR_RLC_BearerConfig_t *rlc_BearerConfig = calloc(1, sizeof(NR_RLC_BearerConfig_t)); + rlc_BearerConfig->logicalChannelIdentity = lcChannelId; + rlc_BearerConfig->servedRadioBearer = calloc(1, sizeof(*rlc_BearerConfig->servedRadioBearer)); + rlc_BearerConfig->servedRadioBearer->present = NR_RLC_BearerConfig__servedRadioBearer_PR_drb_Identity; + rlc_BearerConfig->servedRadioBearer->choice.drb_Identity = drbId; + rlc_BearerConfig->reestablishRLC = NULL; + + NR_RLC_Config_t *rlc_Config = calloc(1, sizeof(NR_RLC_Config_t)); + nr_drb_config(rlc_Config, rlc_conf); + rlc_BearerConfig->rlc_Config = rlc_Config; + + NR_LogicalChannelConfig_t *logicalChannelConfig = calloc(1, sizeof(NR_LogicalChannelConfig_t)); + logicalChannelConfig->ul_SpecificParameters = calloc(1, sizeof(*logicalChannelConfig->ul_SpecificParameters)); + logicalChannelConfig->ul_SpecificParameters->priority = priority; + logicalChannelConfig->ul_SpecificParameters->prioritisedBitRate = NR_LogicalChannelConfig__ul_SpecificParameters__prioritisedBitRate_kBps8; + logicalChannelConfig->ul_SpecificParameters->bucketSizeDuration = NR_LogicalChannelConfig__ul_SpecificParameters__bucketSizeDuration_ms100; + + long *logicalChannelGroup = CALLOC(1, sizeof(long)); + *logicalChannelGroup = 1; + logicalChannelConfig->ul_SpecificParameters->logicalChannelGroup = logicalChannelGroup; + logicalChannelConfig->ul_SpecificParameters->schedulingRequestID = CALLOC(1, sizeof(*logicalChannelConfig->ul_SpecificParameters->schedulingRequestID)); + *logicalChannelConfig->ul_SpecificParameters->schedulingRequestID = 0; + logicalChannelConfig->ul_SpecificParameters->logicalChannelSR_Mask = 0; + logicalChannelConfig->ul_SpecificParameters->logicalChannelSR_DelayTimerApplied = 0; + rlc_BearerConfig->mac_LogicalChannelConfig = logicalChannelConfig; + + return rlc_BearerConfig; +} + +void fill_mastercellGroupConfig(NR_CellGroupConfig_t *cellGroupConfig, NR_CellGroupConfig_t *ue_context_mastercellGroup, int use_rlc_um_for_drb, uint8_t configure_srb, uint8_t bearer_id_start, uint8_t nb_bearers_to_setup, long *priority ) { cellGroupConfig->cellGroupId = 0; cellGroupConfig->rlc_BearerToReleaseList = NULL; @@ -1369,161 +2147,62 @@ void fill_mastercellGroupConfig(NR_CellGroupConfig_t *cellGroupConfig, NR_CellGr // RLC Bearer Config // TS38.331 9.2.1 Default SRB configurations - NR_RLC_BearerConfig_t *rlc_BearerConfig = NULL; - NR_RLC_Config_t *rlc_Config = NULL; - NR_LogicalChannelConfig_t *logicalChannelConfig = NULL; - long *logicalChannelGroup = NULL; - rlc_BearerConfig = calloc(1, sizeof(NR_RLC_BearerConfig_t)); - rlc_BearerConfig->logicalChannelIdentity = 2; - rlc_BearerConfig->servedRadioBearer = calloc(1, sizeof(*rlc_BearerConfig->servedRadioBearer)); - rlc_BearerConfig->servedRadioBearer->present = NR_RLC_BearerConfig__servedRadioBearer_PR_srb_Identity; - rlc_BearerConfig->servedRadioBearer->choice.srb_Identity = 2; - rlc_BearerConfig->reestablishRLC = NULL; - rlc_Config = calloc(1, sizeof(NR_RLC_Config_t)); - rlc_Config->present = NR_RLC_Config_PR_am; - rlc_Config->choice.am = calloc(1, sizeof(*rlc_Config->choice.am)); - rlc_Config->choice.am->dl_AM_RLC.sn_FieldLength = calloc(1, sizeof(NR_SN_FieldLengthAM_t)); - *(rlc_Config->choice.am->dl_AM_RLC.sn_FieldLength) = NR_SN_FieldLengthAM_size12; - rlc_Config->choice.am->dl_AM_RLC.t_Reassembly = NR_T_Reassembly_ms35; - rlc_Config->choice.am->dl_AM_RLC.t_StatusProhibit = NR_T_StatusProhibit_ms0; - rlc_Config->choice.am->ul_AM_RLC.sn_FieldLength = calloc(1, sizeof(NR_SN_FieldLengthAM_t)); - *(rlc_Config->choice.am->ul_AM_RLC.sn_FieldLength) = NR_SN_FieldLengthAM_size12; - rlc_Config->choice.am->ul_AM_RLC.t_PollRetransmit = NR_T_PollRetransmit_ms45; - rlc_Config->choice.am->ul_AM_RLC.pollPDU = NR_PollPDU_infinity; - rlc_Config->choice.am->ul_AM_RLC.pollByte = NR_PollByte_infinity; - rlc_Config->choice.am->ul_AM_RLC.maxRetxThreshold = NR_UL_AM_RLC__maxRetxThreshold_t8; - rlc_BearerConfig->rlc_Config = rlc_Config; - logicalChannelConfig = calloc(1, sizeof(NR_LogicalChannelConfig_t)); - logicalChannelConfig->ul_SpecificParameters = calloc(1, sizeof(*logicalChannelConfig->ul_SpecificParameters)); - logicalChannelConfig->ul_SpecificParameters->priority = 3; - logicalChannelConfig->ul_SpecificParameters->prioritisedBitRate = NR_LogicalChannelConfig__ul_SpecificParameters__prioritisedBitRate_infinity; - logicalChannelConfig->ul_SpecificParameters->bucketSizeDuration = NR_LogicalChannelConfig__ul_SpecificParameters__bucketSizeDuration_ms5; - logicalChannelGroup = CALLOC(1, sizeof(long)); - *logicalChannelGroup = 0; - logicalChannelConfig->ul_SpecificParameters->logicalChannelGroup = logicalChannelGroup; - logicalChannelConfig->ul_SpecificParameters->schedulingRequestID = CALLOC(1, sizeof(*logicalChannelConfig->ul_SpecificParameters->schedulingRequestID)); - *logicalChannelConfig->ul_SpecificParameters->schedulingRequestID = 0; - logicalChannelConfig->ul_SpecificParameters->logicalChannelSR_Mask = 0; - logicalChannelConfig->ul_SpecificParameters->logicalChannelSR_DelayTimerApplied = 0; - rlc_BearerConfig->mac_LogicalChannelConfig = logicalChannelConfig; - ASN_SEQUENCE_ADD(&cellGroupConfig->rlc_BearerToAddModList->list, rlc_BearerConfig); - ASN_SEQUENCE_ADD(&ue_context_mastercellGroup->rlc_BearerToAddModList->list, rlc_BearerConfig); + if (configure_srb){ + NR_RLC_BearerConfig_t *rlc_BearerConfig = get_SRB_RLC_BearerConfig(2, 3, NR_LogicalChannelConfig__ul_SpecificParameters__bucketSizeDuration_ms5); + ASN_SEQUENCE_ADD(&cellGroupConfig->rlc_BearerToAddModList->list, rlc_BearerConfig); + ASN_SEQUENCE_ADD(&ue_context_mastercellGroup->rlc_BearerToAddModList->list, rlc_BearerConfig); + } // DRB Configuration - NR_RLC_BearerConfig_t *rlc_BearerConfig_drb = NULL; - NR_RLC_Config_t *rlc_Config_drb = NULL; - NR_LogicalChannelConfig_t *logicalChannelConfig_drb = NULL; - long *logicalChannelGroup_drb = NULL; - rlc_BearerConfig_drb = calloc(1, sizeof(NR_RLC_BearerConfig_t)); - rlc_BearerConfig_drb->logicalChannelIdentity = 4; - rlc_BearerConfig_drb->servedRadioBearer = calloc(1, sizeof(*rlc_BearerConfig_drb->servedRadioBearer)); - rlc_BearerConfig_drb->servedRadioBearer->present = NR_RLC_BearerConfig__servedRadioBearer_PR_drb_Identity; - rlc_BearerConfig_drb->servedRadioBearer->choice.drb_Identity = 1; - rlc_BearerConfig_drb->reestablishRLC = NULL; - rlc_Config_drb = calloc(1, sizeof(NR_RLC_Config_t)); - rlc_Config_drb->present = NR_RLC_Config_PR_am; - rlc_Config_drb->choice.am = calloc(1, sizeof(*rlc_Config_drb->choice.am)); - rlc_Config_drb->choice.am->dl_AM_RLC.sn_FieldLength = calloc(1, sizeof(NR_SN_FieldLengthAM_t)); - *(rlc_Config_drb->choice.am->dl_AM_RLC.sn_FieldLength) = NR_SN_FieldLengthAM_size18; - rlc_Config_drb->choice.am->dl_AM_RLC.t_Reassembly = NR_T_Reassembly_ms80; - rlc_Config_drb->choice.am->dl_AM_RLC.t_StatusProhibit = NR_T_StatusProhibit_ms10; - rlc_Config_drb->choice.am->ul_AM_RLC.sn_FieldLength = calloc(1, sizeof(NR_SN_FieldLengthAM_t)); - *(rlc_Config_drb->choice.am->ul_AM_RLC.sn_FieldLength) = NR_SN_FieldLengthAM_size18; - rlc_Config_drb->choice.am->ul_AM_RLC.t_PollRetransmit = NR_T_PollRetransmit_ms80; - rlc_Config_drb->choice.am->ul_AM_RLC.pollPDU = NR_PollPDU_p64; - rlc_Config_drb->choice.am->ul_AM_RLC.pollByte = NR_PollByte_kB125; - rlc_Config_drb->choice.am->ul_AM_RLC.maxRetxThreshold = NR_UL_AM_RLC__maxRetxThreshold_t8; - rlc_BearerConfig_drb->rlc_Config = rlc_Config_drb; - logicalChannelConfig_drb = calloc(1, sizeof(NR_LogicalChannelConfig_t)); - logicalChannelConfig_drb->ul_SpecificParameters = calloc(1, sizeof(*logicalChannelConfig_drb->ul_SpecificParameters)); - logicalChannelConfig_drb->ul_SpecificParameters->priority = 13; - logicalChannelConfig_drb->ul_SpecificParameters->prioritisedBitRate = NR_LogicalChannelConfig__ul_SpecificParameters__prioritisedBitRate_kBps8; - logicalChannelConfig_drb->ul_SpecificParameters->bucketSizeDuration = NR_LogicalChannelConfig__ul_SpecificParameters__bucketSizeDuration_ms100; - logicalChannelGroup_drb = CALLOC(1, sizeof(long)); - *logicalChannelGroup_drb = 1; - logicalChannelConfig_drb->ul_SpecificParameters->logicalChannelGroup = logicalChannelGroup_drb; - logicalChannelConfig_drb->ul_SpecificParameters->schedulingRequestID = CALLOC(1, sizeof(*logicalChannelConfig_drb->ul_SpecificParameters->schedulingRequestID)); - *logicalChannelConfig_drb->ul_SpecificParameters->schedulingRequestID = 0; - logicalChannelConfig_drb->ul_SpecificParameters->logicalChannelSR_Mask = 0; - logicalChannelConfig_drb->ul_SpecificParameters->logicalChannelSR_DelayTimerApplied = 0; - rlc_BearerConfig_drb->mac_LogicalChannelConfig = logicalChannelConfig_drb; - ASN_SEQUENCE_ADD(&cellGroupConfig->rlc_BearerToAddModList->list, rlc_BearerConfig_drb); - ASN_SEQUENCE_ADD(&ue_context_mastercellGroup->rlc_BearerToAddModList->list, rlc_BearerConfig_drb); + for (int i = bearer_id_start; i < bearer_id_start + nb_bearers_to_setup; i++ ){ + const NR_RLC_Config_PR rlc_conf = use_rlc_um_for_drb ? NR_RLC_Config_PR_um_Bi_Directional : NR_RLC_Config_PR_am; + NR_RLC_BearerConfig_t *rlc_BearerConfig = get_DRB_RLC_BearerConfig(3 + i, i, rlc_conf, priority[i-bearer_id_start]); + ASN_SEQUENCE_ADD(&cellGroupConfig->rlc_BearerToAddModList->list, rlc_BearerConfig); + ASN_SEQUENCE_ADD(&ue_context_mastercellGroup->rlc_BearerToAddModList->list, rlc_BearerConfig); + } } void update_cellGroupConfig(NR_CellGroupConfig_t *cellGroupConfig, - rrc_gNB_carrier_data_t *carrier, - NR_UE_NR_Capability_t *uecap) { + NR_UE_NR_Capability_t *uecap, + const gNB_RrcConfigurationReq* configuration) { NR_SpCellConfig_t *SpCellConfig = cellGroupConfig->spCellConfig; if (SpCellConfig == NULL) return; - NR_ServingCellConfigCommon_t *scc = carrier->servingcellconfigcommon; + NR_ServingCellConfigCommon_t *scc = configuration ? configuration->scc : NULL; - NR_BWP_DownlinkDedicated_t *bwp_Dedicated = SpCellConfig->spCellConfigDedicated->initialDownlinkBWP; - set_dl_mcs_table(scc->downlinkConfigCommon->initialDownlinkBWP->genericParameters.subcarrierSpacing, - uecap, bwp_Dedicated, scc); - - struct NR_ServingCellConfig__downlinkBWP_ToAddModList *DL_BWP_list = SpCellConfig->spCellConfigDedicated->downlinkBWP_ToAddModList; - if (DL_BWP_list) { - for (int i=0; ilist.count; i++){ - NR_BWP_Downlink_t *bwp = DL_BWP_list->list.array[i]; - int scs = bwp->bwp_Common->genericParameters.subcarrierSpacing; - set_dl_mcs_table(scs, uecap, bwp->bwp_Dedicated, carrier->servingcellconfigcommon); + // Set DL MCS table + if(scc) { + NR_BWP_DownlinkDedicated_t *bwp_Dedicated = SpCellConfig->spCellConfigDedicated->initialDownlinkBWP; + set_dl_mcs_table(scc->downlinkConfigCommon->initialDownlinkBWP->genericParameters.subcarrierSpacing, + configuration->force_256qam_off ? NULL : uecap, SpCellConfig, bwp_Dedicated, scc); + struct NR_ServingCellConfig__downlinkBWP_ToAddModList *DL_BWP_list = SpCellConfig->spCellConfigDedicated->downlinkBWP_ToAddModList; + if (DL_BWP_list) { + for (int i=0; ilist.count; i++){ + NR_BWP_Downlink_t *bwp = DL_BWP_list->list.array[i]; + int scs = bwp->bwp_Common->genericParameters.subcarrierSpacing; + set_dl_mcs_table(scs, configuration->force_256qam_off ? NULL : uecap, SpCellConfig, bwp->bwp_Dedicated, scc); + } } } -} +} void fill_initial_cellGroupConfig(int uid, NR_CellGroupConfig_t *cellGroupConfig, NR_ServingCellConfigCommon_t *scc, - rrc_gNB_carrier_data_t *carrier) { - - NR_RLC_BearerConfig_t *rlc_BearerConfig = NULL; - NR_RLC_Config_t *rlc_Config = NULL; - NR_LogicalChannelConfig_t *logicalChannelConfig = NULL; + NR_ServingCellConfig_t *servingcellconfigdedicated, + const gNB_RrcConfigurationReq *configuration) +{ NR_MAC_CellGroupConfig_t *mac_CellGroupConfig = NULL; NR_PhysicalCellGroupConfig_t *physicalCellGroupConfig = NULL; - long *logicalChannelGroup = NULL; cellGroupConfig->cellGroupId = 0; /* Rlc Bearer Config */ /* TS38.331 9.2.1 Default SRB configurations */ cellGroupConfig->rlc_BearerToAddModList = calloc(1, sizeof(*cellGroupConfig->rlc_BearerToAddModList)); - rlc_BearerConfig = calloc(1, sizeof(NR_RLC_BearerConfig_t)); - rlc_BearerConfig->logicalChannelIdentity = 1; - rlc_BearerConfig->servedRadioBearer = calloc(1, sizeof(*rlc_BearerConfig->servedRadioBearer)); - rlc_BearerConfig->servedRadioBearer->present = NR_RLC_BearerConfig__servedRadioBearer_PR_srb_Identity; - rlc_BearerConfig->servedRadioBearer->choice.srb_Identity = 1; - rlc_BearerConfig->reestablishRLC = NULL; - rlc_Config = calloc(1, sizeof(NR_RLC_Config_t)); - rlc_Config->present = NR_RLC_Config_PR_am; - rlc_Config->choice.am = calloc(1, sizeof(*rlc_Config->choice.am)); - rlc_Config->choice.am->dl_AM_RLC.sn_FieldLength = calloc(1, sizeof(NR_SN_FieldLengthAM_t)); - *(rlc_Config->choice.am->dl_AM_RLC.sn_FieldLength) = NR_SN_FieldLengthAM_size12; - rlc_Config->choice.am->dl_AM_RLC.t_Reassembly = NR_T_Reassembly_ms35; - rlc_Config->choice.am->dl_AM_RLC.t_StatusProhibit = NR_T_StatusProhibit_ms0; - rlc_Config->choice.am->ul_AM_RLC.sn_FieldLength = calloc(1, sizeof(NR_SN_FieldLengthAM_t)); - *(rlc_Config->choice.am->ul_AM_RLC.sn_FieldLength) = NR_SN_FieldLengthAM_size12; - rlc_Config->choice.am->ul_AM_RLC.t_PollRetransmit = NR_T_PollRetransmit_ms45; - rlc_Config->choice.am->ul_AM_RLC.pollPDU = NR_PollPDU_infinity; - rlc_Config->choice.am->ul_AM_RLC.pollByte = NR_PollByte_infinity; - rlc_Config->choice.am->ul_AM_RLC.maxRetxThreshold = NR_UL_AM_RLC__maxRetxThreshold_t8; - rlc_BearerConfig->rlc_Config = rlc_Config; - logicalChannelConfig = calloc(1, sizeof(NR_LogicalChannelConfig_t)); - logicalChannelConfig->ul_SpecificParameters = calloc(1, sizeof(*logicalChannelConfig->ul_SpecificParameters)); - logicalChannelConfig->ul_SpecificParameters->priority = 1; - logicalChannelConfig->ul_SpecificParameters->prioritisedBitRate = NR_LogicalChannelConfig__ul_SpecificParameters__prioritisedBitRate_infinity; - logicalChannelGroup = CALLOC(1, sizeof(long)); - *logicalChannelGroup = 0; - logicalChannelConfig->ul_SpecificParameters->logicalChannelGroup = logicalChannelGroup; - logicalChannelConfig->ul_SpecificParameters->schedulingRequestID = CALLOC(1, sizeof(*logicalChannelConfig->ul_SpecificParameters->schedulingRequestID)); - *logicalChannelConfig->ul_SpecificParameters->schedulingRequestID = 0; - logicalChannelConfig->ul_SpecificParameters->logicalChannelSR_Mask = 0; - logicalChannelConfig->ul_SpecificParameters->logicalChannelSR_DelayTimerApplied = 0; - rlc_BearerConfig->mac_LogicalChannelConfig = logicalChannelConfig; + NR_RLC_BearerConfig_t *rlc_BearerConfig = get_SRB_RLC_BearerConfig(1, 1, NR_LogicalChannelConfig__ul_SpecificParameters__bucketSizeDuration_ms1000); ASN_SEQUENCE_ADD(&cellGroupConfig->rlc_BearerToAddModList->list, rlc_BearerConfig); cellGroupConfig->rlc_BearerToReleaseList = NULL; @@ -1569,19 +2248,20 @@ void fill_initial_cellGroupConfig(int uid, cellGroupConfig->spCellConfig = calloc(1,sizeof(*cellGroupConfig->spCellConfig)); - fill_initial_SpCellConfig(uid,cellGroupConfig->spCellConfig,scc,carrier); + fill_initial_SpCellConfig(uid,cellGroupConfig->spCellConfig,scc,servingcellconfigdedicated,configuration); cellGroupConfig->sCellToAddModList = NULL; cellGroupConfig->sCellToReleaseList = NULL; } //------------------------------------------------------------------------------ -uint8_t do_RRCSetup(rrc_gNB_ue_context_t *const ue_context_pP, - uint8_t *const buffer, - const uint8_t transaction_id, - OCTET_STRING_t *masterCellGroup_from_DU, - NR_ServingCellConfigCommon_t *scc, - rrc_gNB_carrier_data_t *carrier) +int16_t do_RRCSetup(rrc_gNB_ue_context_t *const ue_context_pP, + uint8_t *const buffer, + const uint8_t transaction_id, + OCTET_STRING_t *masterCellGroup_from_DU, + NR_ServingCellConfigCommon_t *scc, + NR_ServingCellConfig_t *servingcellconfigdedicated, + const gNB_RrcConfigurationReq *configuration) //------------------------------------------------------------------------------ { asn_enc_rval_t enc_rval; @@ -1591,7 +2271,7 @@ uint8_t do_RRCSetup(rrc_gNB_ue_context_t *const ue_context_pP, NR_SRB_ToAddMod_t *SRB1_config = NULL; NR_PDCP_Config_t *pdcp_Config = NULL; NR_CellGroupConfig_t *cellGroupConfig = NULL; - char masterCellGroup_buf[1000]; + char masterCellGroup_buf[3000]; AssertFatal(ue_context_pP != NULL,"ue_context_p is null\n"); gNB_RRC_UE_t *ue_p = &ue_context_pP->ue_context; @@ -1642,19 +2322,17 @@ uint8_t do_RRCSetup(rrc_gNB_ue_context_t *const ue_context_pP, &asn_DEF_NR_CellGroupConfig, //might be added prefix later (void **)&cellGroupConfig, (uint8_t *)masterCellGroup_from_DU->buf, - masterCellGroup_from_DU->size, 0, 0); - - xer_fprint(stdout, &asn_DEF_NR_CellGroupConfig, (const void*)cellGroupConfig); + masterCellGroup_from_DU->size, 0, 0); } else { cellGroupConfig = calloc(1, sizeof(NR_CellGroupConfig_t)); - fill_initial_cellGroupConfig(ue_context_pP->local_uid,cellGroupConfig,scc,carrier); + fill_initial_cellGroupConfig(ue_context_pP->local_uid,cellGroupConfig,scc,servingcellconfigdedicated,configuration); enc_rval = uper_encode_to_buffer(&asn_DEF_NR_CellGroupConfig, NULL, (void *)cellGroupConfig, masterCellGroup_buf, - 1000); + 3000); if(enc_rval.encoded == -1) { LOG_E(NR_RRC, "ASN1 message CellGroupConfig encoding failed (%s, %lu)!\n", @@ -1671,8 +2349,10 @@ uint8_t do_RRCSetup(rrc_gNB_ue_context_t *const ue_context_pP, ue_p->masterCellGroup = cellGroupConfig; if ( LOG_DEBUGFLAG(DEBUG_ASN1) ) { + xer_fprint(stdout, &asn_DEF_NR_CellGroupConfig, (const void*)cellGroupConfig); xer_fprint(stdout, &asn_DEF_NR_DL_CCCH_Message, (void *)&dl_ccch_msg); } + enc_rval = uper_encode_to_buffer(&asn_DEF_NR_DL_CCCH_Message, NULL, (void *)&dl_ccch_msg, @@ -1896,6 +2576,7 @@ int16_t do_RRCReconfiguration( struct NR_RRCReconfiguration_v1530_IEs__dedicatedNAS_MessageList *dedicatedNAS_MessageList, rrc_gNB_ue_context_t *const ue_context_pP, rrc_gNB_carrier_data_t *carrier, + const gNB_RrcConfigurationReq *configuration, NR_MAC_CellGroupConfig_t *mac_CellGroupConfig, NR_CellGroupConfig_t *cellGroupConfig) //------------------------------------------------------------------------------ @@ -1948,8 +2629,9 @@ int16_t do_RRCReconfiguration( if(cellGroupConfig!=NULL){ update_cellGroupConfig(cellGroupConfig, - carrier, - ue_context_pP->ue_context.UE_Capability_nr); + ue_context_pP ? ue_context_pP->ue_context.UE_Capability_nr : NULL, + configuration); + enc_rval = uper_encode_to_buffer(&asn_DEF_NR_CellGroupConfig, NULL, (void *)cellGroupConfig, @@ -1960,7 +2642,9 @@ int16_t do_RRCReconfiguration( enc_rval.failed_type->name, enc_rval.encoded); return -1; } - xer_fprint(stdout, &asn_DEF_NR_CellGroupConfig, (const void*)cellGroupConfig); + if ( LOG_DEBUGFLAG(DEBUG_ASN1) ) { + xer_fprint(stdout, &asn_DEF_NR_CellGroupConfig, (const void *) cellGroupConfig); + } ie->nonCriticalExtension->masterCellGroup = calloc(1,sizeof(OCTET_STRING_t)); ie->nonCriticalExtension->masterCellGroup->buf = masterCellGroup_buf; @@ -1969,9 +2653,9 @@ int16_t do_RRCReconfiguration( dl_dcch_msg.message.choice.c1->choice.rrcReconfiguration->criticalExtensions.choice.rrcReconfiguration = ie; - //if ( LOG_DEBUGFLAG(DEBUG_ASN1) ) { - xer_fprint(stdout, &asn_DEF_NR_DL_DCCH_Message, (void *)&dl_dcch_msg); - //} + if ( LOG_DEBUGFLAG(DEBUG_ASN1) ) { + xer_fprint(stdout, &asn_DEF_NR_DL_DCCH_Message, (void *)&dl_dcch_msg); + } enc_rval = uper_encode_to_buffer(&asn_DEF_NR_DL_DCCH_Message, NULL, diff --git a/openair2/RRC/NR/MESSAGES/asn1_msg.h b/openair2/RRC/NR/MESSAGES/asn1_msg.h index 7fe08704c2..e79f79493d 100644 --- a/openair2/RRC/NR/MESSAGES/asn1_msg.h +++ b/openair2/RRC/NR/MESSAGES/asn1_msg.h @@ -28,7 +28,8 @@ * \email: raymond.knopp@eurecom.fr and navid.nikaein@eurecom.fr, kroempa@gmail.com */ -#pragma once +#ifndef __RRC_NR_MESSAGES_ASN1_MSG__H__ +#define __RRC_NR_MESSAGES_ASN1_MSG__H__ #include #include @@ -101,27 +102,36 @@ uint8_t do_RRCReject(uint8_t Mod_id, uint8_t *const buffer); void fill_initial_SpCellConfig(int uid, - NR_SpCellConfig_t *SpCellConfig, - NR_ServingCellConfigCommon_t *scc, - rrc_gNB_carrier_data_t *carrier); + NR_SpCellConfig_t *SpCellConfig, + NR_ServingCellConfigCommon_t *scc, + NR_ServingCellConfig_t *servingcellconfigdedicated, + const gNB_RrcConfigurationReq *configuration); void fill_initial_cellGroupConfig(int uid, - NR_CellGroupConfig_t *cellGroupConfig, - NR_ServingCellConfigCommon_t *scc, - rrc_gNB_carrier_data_t *carrier); + NR_CellGroupConfig_t *cellGroupConfig, + NR_ServingCellConfigCommon_t *scc, + NR_ServingCellConfig_t *servingcellconfigdedicated, + const gNB_RrcConfigurationReq *configuration); void update_cellGroupConfig(NR_CellGroupConfig_t *cellGroupConfig, - rrc_gNB_carrier_data_t *carrier, - NR_UE_NR_Capability_t *uecap); + NR_UE_NR_Capability_t *uecap, + const gNB_RrcConfigurationReq *configuration); -void fill_mastercellGroupConfig(NR_CellGroupConfig_t *cellGroupConfig, NR_CellGroupConfig_t *ue_context_mastercellGroup); +void fill_mastercellGroupConfig(NR_CellGroupConfig_t *cellGroupConfig, + NR_CellGroupConfig_t *ue_context_mastercellGroup, + int use_rlc_um_for_drb, + uint8_t configure_srb, + uint8_t bearer_id_start, + uint8_t nb_bearers_to_setup, + long *priority); -uint8_t do_RRCSetup(rrc_gNB_ue_context_t *const ue_context_pP, +int16_t do_RRCSetup(rrc_gNB_ue_context_t *const ue_context_pP, uint8_t *const buffer, const uint8_t transaction_id, OCTET_STRING_t *masterCellGroup_from_DU, NR_ServingCellConfigCommon_t *scc, - rrc_gNB_carrier_data_t *carrier); + NR_ServingCellConfig_t *servingcellconfigdedicated, + const gNB_RrcConfigurationReq *configuration); uint8_t do_NR_SecurityModeCommand( const protocol_ctxt_t *const ctxt_pP, @@ -151,6 +161,7 @@ int16_t do_RRCReconfiguration( struct NR_RRCReconfiguration_v1530_IEs__dedicatedNAS_MessageList *dedicatedNAS_MessageList, rrc_gNB_ue_context_t *const ue_context_pP, rrc_gNB_carrier_data_t *carrier, + const gNB_RrcConfigurationReq *configuration, NR_MAC_CellGroupConfig_t *mac_CellGroupConfig, NR_CellGroupConfig_t *cellGroupConfig); @@ -205,3 +216,4 @@ do_RRCReestablishmentComplete( uint8_t *buffer, size_t buffer_size, int64_t rrc_TransactionIdentifier); +#endif /* __RRC_NR_MESSAGES_ASN1_MSG__H__ */ diff --git a/openair2/RRC/NR/nr_rrc_config.c b/openair2/RRC/NR/nr_rrc_config.c index f8f05f2fe5..3517cf76a0 100644 --- a/openair2/RRC/NR/nr_rrc_config.c +++ b/openair2/RRC/NR/nr_rrc_config.c @@ -31,6 +31,300 @@ #include "nr_rrc_config.h" #include "common/utils/nr/nr_common.h" +const uint8_t slotsperframe[5] = {10, 20, 40, 80, 160}; + + +void rrc_coreset_config(NR_ControlResourceSet_t *coreset, + int bwp_id, + int curr_bwp, + uint64_t ssb_bitmap) { + + + // frequency domain resources depending on BWP size + coreset->frequencyDomainResources.buf = calloc(1,6); + coreset->frequencyDomainResources.buf[0] = (curr_bwp < 48) ? 0xf0 : 0xff; + coreset->frequencyDomainResources.buf[1] = (curr_bwp < 96) ? 0x00 : 0xff; + coreset->frequencyDomainResources.buf[2] = (curr_bwp < 144) ? 0x00 : 0xff; + coreset->frequencyDomainResources.buf[3] = (curr_bwp < 192) ? 0x00 : 0xff; + coreset->frequencyDomainResources.buf[4] = (curr_bwp < 240) ? 0x00 : 0xff; + coreset->frequencyDomainResources.buf[5] = 0x00; + coreset->frequencyDomainResources.size = 6; + coreset->frequencyDomainResources.bits_unused = 3; + coreset->duration = (curr_bwp < 48) ? 2 : 1; + coreset->cce_REG_MappingType.present = NR_ControlResourceSet__cce_REG_MappingType_PR_nonInterleaved; + coreset->precoderGranularity = NR_ControlResourceSet__precoderGranularity_sameAsREG_bundle; + + // The ID space is used across the BWPs of a Serving Cell as per 38.331 + coreset->controlResourceSetId = bwp_id + 1; + + coreset->tci_StatesPDCCH_ToAddList=calloc(1,sizeof(*coreset->tci_StatesPDCCH_ToAddList)); + NR_TCI_StateId_t *tci[64]; + for (int i=0;i<64;i++) { + if ((ssb_bitmap>>(63-i))&0x01){ + tci[i]=calloc(1,sizeof(*tci[i])); + *tci[i] = i; + ASN_SEQUENCE_ADD(&coreset->tci_StatesPDCCH_ToAddList->list,tci[i]); + } + } + coreset->tci_StatesPDCCH_ToReleaseList = NULL; + coreset->tci_PresentInDCI = NULL; + coreset->pdcch_DMRS_ScramblingID = NULL; +} + +uint64_t get_ssb_bitmap(NR_ServingCellConfigCommon_t *scc) { + uint64_t bitmap=0; + switch (scc->ssb_PositionsInBurst->present) { + case 1 : + bitmap = ((uint64_t) scc->ssb_PositionsInBurst->choice.shortBitmap.buf[0])<<56; + break; + case 2 : + bitmap = ((uint64_t) scc->ssb_PositionsInBurst->choice.mediumBitmap.buf[0])<<56; + break; + case 3 : + for (int i=0; i<8; i++) { + bitmap |= (((uint64_t) scc->ssb_PositionsInBurst->choice.longBitmap.buf[i])<<((7-i)*8)); + } + break; + default: + AssertFatal(1==0,"SSB bitmap size value %d undefined (allowed values 1,2,3) \n", scc->ssb_PositionsInBurst->present); + } + return bitmap; +} + +void set_csirs_periodicity(NR_NZP_CSI_RS_Resource_t *nzpcsi0, int uid, int nb_slots_per_period) { + + nzpcsi0->periodicityAndOffset = calloc(1,sizeof(*nzpcsi0->periodicityAndOffset)); + int ideal_period = nb_slots_per_period*MAX_MOBILES_PER_GNB; + + if (ideal_period<5) { + nzpcsi0->periodicityAndOffset->present = NR_CSI_ResourcePeriodicityAndOffset_PR_slots4; + nzpcsi0->periodicityAndOffset->choice.slots4 = nb_slots_per_period*uid; + } + else if (ideal_period<6) { + nzpcsi0->periodicityAndOffset->present = NR_CSI_ResourcePeriodicityAndOffset_PR_slots5; + nzpcsi0->periodicityAndOffset->choice.slots5 = nb_slots_per_period*uid; + } + else if (ideal_period<9) { + nzpcsi0->periodicityAndOffset->present = NR_CSI_ResourcePeriodicityAndOffset_PR_slots8; + nzpcsi0->periodicityAndOffset->choice.slots8 = nb_slots_per_period*uid; + } + else if (ideal_period<11) { + nzpcsi0->periodicityAndOffset->present = NR_CSI_ResourcePeriodicityAndOffset_PR_slots10; + nzpcsi0->periodicityAndOffset->choice.slots10 = nb_slots_per_period*uid; + } + else if (ideal_period<17) { + nzpcsi0->periodicityAndOffset->present = NR_CSI_ResourcePeriodicityAndOffset_PR_slots16; + nzpcsi0->periodicityAndOffset->choice.slots16 = nb_slots_per_period*uid; + } + else if (ideal_period<21) { + nzpcsi0->periodicityAndOffset->present = NR_CSI_ResourcePeriodicityAndOffset_PR_slots20; + nzpcsi0->periodicityAndOffset->choice.slots20 = nb_slots_per_period*uid; + } + else if (ideal_period<41) { + nzpcsi0->periodicityAndOffset->present = NR_CSI_ResourcePeriodicityAndOffset_PR_slots40; + nzpcsi0->periodicityAndOffset->choice.slots40 = nb_slots_per_period*uid; + } + else if (ideal_period<81) { + nzpcsi0->periodicityAndOffset->present = NR_CSI_ResourcePeriodicityAndOffset_PR_slots80; + nzpcsi0->periodicityAndOffset->choice.slots80 = nb_slots_per_period*uid; + } + else if (ideal_period<161) { + nzpcsi0->periodicityAndOffset->present = NR_CSI_ResourcePeriodicityAndOffset_PR_slots160; + nzpcsi0->periodicityAndOffset->choice.slots160 = nb_slots_per_period*uid; + } + else { + nzpcsi0->periodicityAndOffset->present = NR_CSI_ResourcePeriodicityAndOffset_PR_slots320; + nzpcsi0->periodicityAndOffset->choice.slots320 = (nb_slots_per_period*uid)%320 + (nb_slots_per_period*uid)/320; + } +} + + +void config_csirs(NR_ServingCellConfigCommon_t *servingcellconfigcommon, + NR_CSI_MeasConfig_t *csi_MeasConfig, + int uid, + int num_dl_antenna_ports, + int curr_bwp, + int do_csirs) { + + if (do_csirs) { + + csi_MeasConfig->nzp_CSI_RS_ResourceSetToAddModList = calloc(1,sizeof(*csi_MeasConfig->nzp_CSI_RS_ResourceSetToAddModList)); + NR_NZP_CSI_RS_ResourceSet_t *nzpcsirs0 = calloc(1,sizeof(*nzpcsirs0)); + nzpcsirs0->nzp_CSI_ResourceSetId = 0; + NR_NZP_CSI_RS_ResourceId_t *nzpid0 = calloc(1,sizeof(*nzpid0)); + *nzpid0 = 0; + ASN_SEQUENCE_ADD(&nzpcsirs0->nzp_CSI_RS_Resources,nzpid0); + nzpcsirs0->repetition = NULL; + nzpcsirs0->aperiodicTriggeringOffset = NULL; + nzpcsirs0->trs_Info = NULL; + ASN_SEQUENCE_ADD(&csi_MeasConfig->nzp_CSI_RS_ResourceSetToAddModList->list,nzpcsirs0); + + const NR_TDD_UL_DL_Pattern_t *tdd = servingcellconfigcommon->tdd_UL_DL_ConfigurationCommon ? + &servingcellconfigcommon->tdd_UL_DL_ConfigurationCommon->pattern1 : NULL; + + const int n_slots_frame = slotsperframe[*servingcellconfigcommon->ssbSubcarrierSpacing]; + + int nb_slots_per_period = n_slots_frame; + if (tdd) + nb_slots_per_period = n_slots_frame/get_nb_periods_per_frame(tdd->dl_UL_TransmissionPeriodicity); + + csi_MeasConfig->nzp_CSI_RS_ResourceToAddModList = calloc(1,sizeof(*csi_MeasConfig->nzp_CSI_RS_ResourceToAddModList)); + NR_NZP_CSI_RS_Resource_t *nzpcsi0 = calloc(1,sizeof(*nzpcsi0)); + nzpcsi0->nzp_CSI_RS_ResourceId = 0; + NR_CSI_RS_ResourceMapping_t resourceMapping; + switch (num_dl_antenna_ports) { + case 1: + resourceMapping.frequencyDomainAllocation.present = NR_CSI_RS_ResourceMapping__frequencyDomainAllocation_PR_row2; + resourceMapping.frequencyDomainAllocation.choice.row2.buf = calloc(2, sizeof(uint8_t)); + resourceMapping.frequencyDomainAllocation.choice.row2.size = 2; + resourceMapping.frequencyDomainAllocation.choice.row2.bits_unused = 4; + resourceMapping.frequencyDomainAllocation.choice.row2.buf[0] = 0; + resourceMapping.frequencyDomainAllocation.choice.row2.buf[1] = 16; + resourceMapping.nrofPorts = NR_CSI_RS_ResourceMapping__nrofPorts_p1; + resourceMapping.cdm_Type = NR_CSI_RS_ResourceMapping__cdm_Type_noCDM; + break; + case 2: + resourceMapping.frequencyDomainAllocation.present = NR_CSI_RS_ResourceMapping__frequencyDomainAllocation_PR_other; + resourceMapping.frequencyDomainAllocation.choice.other.buf = calloc(2, sizeof(uint8_t)); + resourceMapping.frequencyDomainAllocation.choice.other.size = 1; + resourceMapping.frequencyDomainAllocation.choice.other.bits_unused = 2; + resourceMapping.frequencyDomainAllocation.choice.other.buf[0] = 4; + resourceMapping.nrofPorts = NR_CSI_RS_ResourceMapping__nrofPorts_p2; + resourceMapping.cdm_Type = NR_CSI_RS_ResourceMapping__cdm_Type_fd_CDM2; + break; + case 4: + resourceMapping.frequencyDomainAllocation.present = NR_CSI_RS_ResourceMapping__frequencyDomainAllocation_PR_row4; + resourceMapping.frequencyDomainAllocation.choice.row4.buf = calloc(2, sizeof(uint8_t)); + resourceMapping.frequencyDomainAllocation.choice.row4.size = 1; + resourceMapping.frequencyDomainAllocation.choice.row4.bits_unused = 5; + resourceMapping.frequencyDomainAllocation.choice.row4.buf[0] = 32; + resourceMapping.nrofPorts = NR_CSI_RS_ResourceMapping__nrofPorts_p4; + resourceMapping.cdm_Type = NR_CSI_RS_ResourceMapping__cdm_Type_fd_CDM2; + break; + default: + AssertFatal(1==0,"Number of ports not yet supported\n"); + } + resourceMapping.firstOFDMSymbolInTimeDomain = 13; // last symbol of slot + resourceMapping.firstOFDMSymbolInTimeDomain2 = NULL; + resourceMapping.density.present = NR_CSI_RS_ResourceMapping__density_PR_one; + resourceMapping.density.choice.one = (NULL_t)0; + resourceMapping.freqBand.startingRB = 0; + resourceMapping.freqBand.nrofRBs = ((curr_bwp>>2)+(curr_bwp%4>0))<<2; + nzpcsi0->resourceMapping = resourceMapping; + nzpcsi0->powerControlOffset = 0; + nzpcsi0->powerControlOffsetSS=calloc(1,sizeof(*nzpcsi0->powerControlOffsetSS)); + *nzpcsi0->powerControlOffsetSS = NR_NZP_CSI_RS_Resource__powerControlOffsetSS_db0; + nzpcsi0->scramblingID = *servingcellconfigcommon->physCellId; + set_csirs_periodicity(nzpcsi0, uid, nb_slots_per_period); + nzpcsi0->qcl_InfoPeriodicCSI_RS = calloc(1,sizeof(*nzpcsi0->qcl_InfoPeriodicCSI_RS)); + *nzpcsi0->qcl_InfoPeriodicCSI_RS = 0; + ASN_SEQUENCE_ADD(&csi_MeasConfig->nzp_CSI_RS_ResourceToAddModList->list,nzpcsi0); + } + else { + csi_MeasConfig->nzp_CSI_RS_ResourceToAddModList = NULL; + csi_MeasConfig->nzp_CSI_RS_ResourceSetToAddModList = NULL; + } + csi_MeasConfig->nzp_CSI_RS_ResourceSetToReleaseList = NULL; + csi_MeasConfig->nzp_CSI_RS_ResourceToReleaseList = NULL; +} + +void set_csiim_offset(struct NR_CSI_ResourcePeriodicityAndOffset *periodicityAndOffset, + struct NR_CSI_ResourcePeriodicityAndOffset *target_periodicityAndOffset) { + + switch(periodicityAndOffset->present) { + case NR_CSI_ResourcePeriodicityAndOffset_PR_slots4: + periodicityAndOffset->choice.slots4 = target_periodicityAndOffset->choice.slots4; + break; + case NR_CSI_ResourcePeriodicityAndOffset_PR_slots5: + periodicityAndOffset->choice.slots5 = target_periodicityAndOffset->choice.slots5; + break; + case NR_CSI_ResourcePeriodicityAndOffset_PR_slots8: + periodicityAndOffset->choice.slots8 = target_periodicityAndOffset->choice.slots8; + break; + case NR_CSI_ResourcePeriodicityAndOffset_PR_slots10: + periodicityAndOffset->choice.slots10 = target_periodicityAndOffset->choice.slots10; + break; + case NR_CSI_ResourcePeriodicityAndOffset_PR_slots16: + periodicityAndOffset->choice.slots16 = target_periodicityAndOffset->choice.slots16; + break; + case NR_CSI_ResourcePeriodicityAndOffset_PR_slots20: + periodicityAndOffset->choice.slots20 = target_periodicityAndOffset->choice.slots20; + break; + case NR_CSI_ResourcePeriodicityAndOffset_PR_slots32: + periodicityAndOffset->choice.slots32 = target_periodicityAndOffset->choice.slots32; + break; + case NR_CSI_ResourcePeriodicityAndOffset_PR_slots40: + periodicityAndOffset->choice.slots40 = target_periodicityAndOffset->choice.slots40; + break; + case NR_CSI_ResourcePeriodicityAndOffset_PR_slots64: + periodicityAndOffset->choice.slots64 = target_periodicityAndOffset->choice.slots64; + break; + case NR_CSI_ResourcePeriodicityAndOffset_PR_slots80: + periodicityAndOffset->choice.slots80 = target_periodicityAndOffset->choice.slots80; + break; + case NR_CSI_ResourcePeriodicityAndOffset_PR_slots160: + periodicityAndOffset->choice.slots160 = target_periodicityAndOffset->choice.slots160; + break; + case NR_CSI_ResourcePeriodicityAndOffset_PR_slots320: + periodicityAndOffset->choice.slots320 = target_periodicityAndOffset->choice.slots320; + break; + case NR_CSI_ResourcePeriodicityAndOffset_PR_slots640: + periodicityAndOffset->choice.slots640 = target_periodicityAndOffset->choice.slots640; + break; + default: + AssertFatal(1==0,"CSI periodicity not among allowed values\n"); + } + +} + +void config_csiim(int do_csirs, int dl_antenna_ports, int curr_bwp, + NR_CSI_MeasConfig_t *csi_MeasConfig) { + + if (do_csirs && dl_antenna_ports > 1) { + csi_MeasConfig->csi_IM_ResourceToAddModList = calloc(1,sizeof(*csi_MeasConfig->csi_IM_ResourceToAddModList)); + NR_CSI_IM_Resource_t *imres = calloc(1,sizeof(*imres)); + imres->csi_IM_ResourceId = 0; + NR_NZP_CSI_RS_Resource_t *nzpcsi = NULL; + for (int i=0; inzp_CSI_RS_ResourceToAddModList->list.count; i++){ + nzpcsi = csi_MeasConfig->nzp_CSI_RS_ResourceToAddModList->list.array[i]; + if (nzpcsi->nzp_CSI_RS_ResourceId == imres->csi_IM_ResourceId) + break; + } + AssertFatal(nzpcsi->nzp_CSI_RS_ResourceId == imres->csi_IM_ResourceId, "Couldn't find NZP CSI-RS corresponding to CSI-IM\n"); + imres->csi_IM_ResourceElementPattern = calloc(1,sizeof(*imres->csi_IM_ResourceElementPattern)); + imres->csi_IM_ResourceElementPattern->present = NR_CSI_IM_Resource__csi_IM_ResourceElementPattern_PR_pattern1; + imres->csi_IM_ResourceElementPattern->choice.pattern1 = calloc(1,sizeof(*imres->csi_IM_ResourceElementPattern->choice.pattern1)); + // starting subcarrier is 4 in the following configuration + // this is ok for current possible CSI-RS configurations (using only the first 4 symbols) + // TODO needs a more dynamic setting if CSI-RS is changed + imres->csi_IM_ResourceElementPattern->choice.pattern1->subcarrierLocation_p1 = NR_CSI_IM_Resource__csi_IM_ResourceElementPattern__pattern1__subcarrierLocation_p1_s4; + imres->csi_IM_ResourceElementPattern->choice.pattern1->symbolLocation_p1 = nzpcsi->resourceMapping.firstOFDMSymbolInTimeDomain; // same symbol as CSI-RS + imres->freqBand = calloc(1,sizeof(*imres->freqBand)); + imres->freqBand->startingRB = 0; + imres->freqBand->nrofRBs = ((curr_bwp>>2)+(curr_bwp%4>0))<<2; + imres->periodicityAndOffset = calloc(1,sizeof(*imres->periodicityAndOffset)); + // same period and offset of the associated CSI-RS + imres->periodicityAndOffset->present = nzpcsi->periodicityAndOffset->present; + set_csiim_offset(imres->periodicityAndOffset, nzpcsi->periodicityAndOffset); + ASN_SEQUENCE_ADD(&csi_MeasConfig->csi_IM_ResourceToAddModList->list,imres); + csi_MeasConfig->csi_IM_ResourceSetToAddModList = calloc(1,sizeof(*csi_MeasConfig->csi_IM_ResourceSetToAddModList)); + NR_CSI_IM_ResourceSet_t *imset = calloc(1,sizeof(*imset)); + imset->csi_IM_ResourceSetId = 0; + NR_CSI_IM_ResourceId_t *res = calloc(1,sizeof(*res)); + *res = imres->csi_IM_ResourceId; + ASN_SEQUENCE_ADD(&imset->csi_IM_Resources,res); + ASN_SEQUENCE_ADD(&csi_MeasConfig->csi_IM_ResourceSetToAddModList->list,imset); + } + else { + csi_MeasConfig->csi_IM_ResourceToAddModList = NULL; + csi_MeasConfig->csi_IM_ResourceSetToAddModList = NULL; + } + + csi_MeasConfig->csi_IM_ResourceToReleaseList = NULL; + csi_MeasConfig->csi_IM_ResourceSetToReleaseList = NULL; +} + + void prepare_sim_uecap(NR_UE_NR_Capability_t *cap, NR_ServingCellConfigCommon_t *scc, int numerology, @@ -70,35 +364,42 @@ void prepare_sim_uecap(NR_UE_NR_Capability_t *cap, } fs_cc->supportedModulationOrderDL = CALLOC(1,sizeof(*fs_cc->supportedModulationOrderDL)); *fs_cc->supportedModulationOrderDL = NR_ModulationOrder_qam256; - ASN_SEQUENCE_ADD(&fs->featureSetsDownlinkPerCC->list, - fs_cc); + ASN_SEQUENCE_ADD(&fs->featureSetsDownlinkPerCC->list, fs_cc); } } -void nr_rrc_config_dl_tda(NR_ServingCellConfigCommon_t *scc){ +void nr_rrc_config_dl_tda(NR_ServingCellConfigCommon_t *scc, + NR_PDSCH_TimeDomainResourceAllocationList_t *pdsch_TimeDomainAllocationList, + int curr_bwp) { + + frame_type_t frame_type = get_frame_type(*scc->downlinkConfigCommon->frequencyInfoDL->frequencyBandList.list.array[0], *scc->ssbSubcarrierSpacing); - lte_frame_type_t frame_type = get_frame_type(*scc->downlinkConfigCommon->frequencyInfoDL->frequencyBandList.list.array[0], *scc->ssbSubcarrierSpacing); - int curr_bwp = scc->downlinkConfigCommon->frequencyInfoDL->scs_SpecificCarrierList.list.array[0]->carrierBandwidth; // coreset duration setting to be improved in the framework of RRC harmonization, potentially using a common function int len_coreset = 1; if (curr_bwp < 48) len_coreset = 2; - // setting default TDA for DL with + // setting default TDA for DL with TDA index 0 struct NR_PDSCH_TimeDomainResourceAllocation *timedomainresourceallocation = CALLOC(1,sizeof(NR_PDSCH_TimeDomainResourceAllocation_t)); + // k0: Slot offset between DCI and its scheduled PDSCH (see TS 38.214 clause 5.1.2.1) When the field is absent the UE applies the value 0. + //timedomainresourceallocation->k0 = calloc(1,sizeof(*timedomainresourceallocation->k0)); + //*timedomainresourceallocation->k0 = 0; timedomainresourceallocation->mappingType = NR_PDSCH_TimeDomainResourceAllocation__mappingType_typeA; timedomainresourceallocation->startSymbolAndLength = get_SLIV(len_coreset,14-len_coreset); // basic slot configuration starting in symbol 1 til the end of the slot - ASN_SEQUENCE_ADD(&scc->downlinkConfigCommon->initialDownlinkBWP->pdsch_ConfigCommon->choice.setup->pdsch_TimeDomainAllocationList->list, - timedomainresourceallocation); + ASN_SEQUENCE_ADD(&pdsch_TimeDomainAllocationList->list, timedomainresourceallocation); + // setting TDA for CSI-RS symbol with index 1 + struct NR_PDSCH_TimeDomainResourceAllocation *timedomainresourceallocation1 = CALLOC(1,sizeof(NR_PDSCH_TimeDomainResourceAllocation_t)); + timedomainresourceallocation1->mappingType = NR_PDSCH_TimeDomainResourceAllocation__mappingType_typeA; + timedomainresourceallocation1->startSymbolAndLength = get_SLIV(len_coreset,14-len_coreset-1); // 1 symbol CSI-RS + ASN_SEQUENCE_ADD(&pdsch_TimeDomainAllocationList->list, timedomainresourceallocation1); if(frame_type==TDD) { - // TDD if(scc->tdd_UL_DL_ConfigurationCommon) { int dl_symb = scc->tdd_UL_DL_ConfigurationCommon->pattern1.nrofDownlinkSymbols; if(dl_symb > 1) { - timedomainresourceallocation = CALLOC(1,sizeof(NR_PDSCH_TimeDomainResourceAllocation_t)); - timedomainresourceallocation->mappingType = NR_PDSCH_TimeDomainResourceAllocation__mappingType_typeA; - timedomainresourceallocation->startSymbolAndLength = get_SLIV(len_coreset,dl_symb-len_coreset); // mixed slot configuration starting in symbol 1 til the end of the dl allocation - ASN_SEQUENCE_ADD(&scc->downlinkConfigCommon->initialDownlinkBWP->pdsch_ConfigCommon->choice.setup->pdsch_TimeDomainAllocationList->list, - timedomainresourceallocation); + // mixed slot TDA with TDA index 2 + struct NR_PDSCH_TimeDomainResourceAllocation *timedomainresourceallocation2 = CALLOC(1,sizeof(NR_PDSCH_TimeDomainResourceAllocation_t)); + timedomainresourceallocation2->mappingType = NR_PDSCH_TimeDomainResourceAllocation__mappingType_typeA; + timedomainresourceallocation2->startSymbolAndLength = get_SLIV(len_coreset,dl_symb-len_coreset); // mixed slot configuration starting in symbol 1 til the end of the dl allocation + ASN_SEQUENCE_ADD(&pdsch_TimeDomainAllocationList->list, timedomainresourceallocation2); } } } @@ -109,50 +410,52 @@ void nr_rrc_config_ul_tda(NR_ServingCellConfigCommon_t *scc, int min_fb_delay){ //TODO change to accomodate for SRS - int temp_min_delay = 6; // k2 = 2 or 3 won'r work as well as higher values - int k2 = (min_fb_delaydownlinkConfigCommon->frequencyInfoDL->frequencyBandList.list.array[0], *scc->ssbSubcarrierSpacing); + const int k2 = min_fb_delay; uint8_t DELTA[4]= {2,3,4,6}; // Delta parameter for Msg3 int mu = scc->uplinkConfigCommon->initialUplinkBWP->genericParameters.subcarrierSpacing; - lte_frame_type_t frame_type = get_frame_type(*scc->downlinkConfigCommon->frequencyInfoDL->frequencyBandList.list.array[0], *scc->ssbSubcarrierSpacing); + // UL TDA index 0 is basic slot configuration starting in symbol 0 til the last but one symbol struct NR_PUSCH_TimeDomainResourceAllocation *pusch_timedomainresourceallocation = CALLOC(1,sizeof(struct NR_PUSCH_TimeDomainResourceAllocation)); pusch_timedomainresourceallocation->k2 = CALLOC(1,sizeof(long)); *pusch_timedomainresourceallocation->k2 = k2; pusch_timedomainresourceallocation->mappingType = NR_PUSCH_TimeDomainResourceAllocation__mappingType_typeB; - pusch_timedomainresourceallocation->startSymbolAndLength = get_SLIV(0,13); // basic slot configuration starting in symbol 0 til the last but one symbol + pusch_timedomainresourceallocation->startSymbolAndLength = get_SLIV(0,13); ASN_SEQUENCE_ADD(&scc->uplinkConfigCommon->initialUplinkBWP->pusch_ConfigCommon->choice.setup->pusch_TimeDomainAllocationList->list,pusch_timedomainresourceallocation); if(frame_type==TDD) { - // TDD if(scc->tdd_UL_DL_ConfigurationCommon) { int ul_symb = scc->tdd_UL_DL_ConfigurationCommon->pattern1.nrofUplinkSymbols; - pusch_timedomainresourceallocation = CALLOC(1,sizeof(struct NR_PUSCH_TimeDomainResourceAllocation)); - pusch_timedomainresourceallocation->k2 = CALLOC(1,sizeof(long)); - *pusch_timedomainresourceallocation->k2 = k2; - pusch_timedomainresourceallocation->mappingType = NR_PUSCH_TimeDomainResourceAllocation__mappingType_typeB; - pusch_timedomainresourceallocation->startSymbolAndLength = get_SLIV(14-ul_symb,ul_symb-1); // starting in fist ul symbol til the last but one - ASN_SEQUENCE_ADD(&scc->uplinkConfigCommon->initialUplinkBWP->pusch_ConfigCommon->choice.setup->pusch_TimeDomainAllocationList->list,pusch_timedomainresourceallocation); + if (ul_symb>1) { + // UL TDA index 1 for mixed slot (TDD) + pusch_timedomainresourceallocation = CALLOC(1,sizeof(struct NR_PUSCH_TimeDomainResourceAllocation)); + pusch_timedomainresourceallocation->k2 = CALLOC(1,sizeof(long)); + *pusch_timedomainresourceallocation->k2 = k2; + pusch_timedomainresourceallocation->mappingType = NR_PUSCH_TimeDomainResourceAllocation__mappingType_typeB; + pusch_timedomainresourceallocation->startSymbolAndLength = get_SLIV(14-ul_symb,ul_symb-1); // starting in fist ul symbol til the last but one + ASN_SEQUENCE_ADD(&scc->uplinkConfigCommon->initialUplinkBWP->pusch_ConfigCommon->choice.setup->pusch_TimeDomainAllocationList->list,pusch_timedomainresourceallocation); - // for msg3 in the mixed slot - int nb_periods_per_frame = get_nb_periods_per_frame(scc->tdd_UL_DL_ConfigurationCommon->pattern1.dl_UL_TransmissionPeriodicity); - int nb_slots_per_period = ((1<k2 = CALLOC(1,sizeof(long)); - *pusch_timedomainresourceallocation_msg3->k2 = nb_slots_per_period - DELTA[mu]; - if(*pusch_timedomainresourceallocation_msg3->k2 < min_fb_delay) - *pusch_timedomainresourceallocation_msg3->k2 += nb_slots_per_period; - AssertFatal(*pusch_timedomainresourceallocation_msg3->k2<33,"Computed k2 for msg3 %ld is larger than the range allowed by RRC (0..32)\n", - *pusch_timedomainresourceallocation_msg3->k2); - pusch_timedomainresourceallocation_msg3->mappingType = NR_PUSCH_TimeDomainResourceAllocation__mappingType_typeB; - pusch_timedomainresourceallocation_msg3->startSymbolAndLength = get_SLIV(14-ul_symb,ul_symb-1); // starting in fist ul symbol til the last but one - ASN_SEQUENCE_ADD(&scc->uplinkConfigCommon->initialUplinkBWP->pusch_ConfigCommon->choice.setup->pusch_TimeDomainAllocationList->list,pusch_timedomainresourceallocation_msg3); + // UL TDA index 2 for msg3 in the mixed slot (TDD) + int nb_periods_per_frame = get_nb_periods_per_frame(scc->tdd_UL_DL_ConfigurationCommon->pattern1.dl_UL_TransmissionPeriodicity); + int nb_slots_per_period = ((1<k2 = CALLOC(1,sizeof(long)); + *pusch_timedomainresourceallocation_msg3->k2 = nb_slots_per_period - DELTA[mu]; + if(*pusch_timedomainresourceallocation_msg3->k2 < min_fb_delay) + *pusch_timedomainresourceallocation_msg3->k2 += nb_slots_per_period; + AssertFatal(*pusch_timedomainresourceallocation_msg3->k2<33,"Computed k2 for msg3 %ld is larger than the range allowed by RRC (0..32)\n", + *pusch_timedomainresourceallocation_msg3->k2); + pusch_timedomainresourceallocation_msg3->mappingType = NR_PUSCH_TimeDomainResourceAllocation__mappingType_typeB; + pusch_timedomainresourceallocation_msg3->startSymbolAndLength = get_SLIV(14-ul_symb,ul_symb-1); // starting in fist ul symbol til the last but one + ASN_SEQUENCE_ADD(&scc->uplinkConfigCommon->initialUplinkBWP->pusch_ConfigCommon->choice.setup->pusch_TimeDomainAllocationList->list,pusch_timedomainresourceallocation_msg3); + } } } } - void set_dl_mcs_table(int scs, NR_UE_NR_Capability_t *cap, + NR_SpCellConfig_t *SpCellConfig, NR_BWP_DownlinkDedicated_t *bwp_Dedicated, NR_ServingCellConfigCommon_t *scc) { @@ -172,7 +475,7 @@ void set_dl_mcs_table(int scs, NR_UE_NR_Capability_t *cap, } AssertFatal(bw_rb>0,"Could not find scs-SpecificCarrierList element for scs %d",scs); int bw = get_supported_band_index(scs, band, bw_rb); - AssertFatal(bw>0,"Supported band corresponding to %d RBs not found\n", bw_rb); + AssertFatal(bw>=0,"Supported band corresponding to %d RBs not found\n", bw_rb); bool supported = false; if (band>256) { @@ -191,10 +494,19 @@ void set_dl_mcs_table(int scs, NR_UE_NR_Capability_t *cap, if(bwp_Dedicated->pdsch_Config->choice.setup->mcs_Table == NULL) bwp_Dedicated->pdsch_Config->choice.setup->mcs_Table = calloc(1, sizeof(*bwp_Dedicated->pdsch_Config->choice.setup->mcs_Table)); *bwp_Dedicated->pdsch_Config->choice.setup->mcs_Table = NR_PDSCH_Config__mcs_Table_qam256; +// set table 2 in correct entry in SpCellConfig->spCellConfigDedicated->csi_MeasConfig->csi_ReportConfigToAddModList->list + AssertFatal(SpCellConfig!=NULL,"SpCellConfig shouldn't be null\n"); + AssertFatal(SpCellConfig->spCellConfigDedicated!=NULL,"SpCellConfigDedicated shouldn't be null\n"); + if (SpCellConfig->spCellConfigDedicated->csi_MeasConfig && + SpCellConfig->spCellConfigDedicated->csi_MeasConfig->present== NR_SetupRelease_CSI_MeasConfig_PR_setup && + SpCellConfig->spCellConfigDedicated->csi_MeasConfig->choice.setup && + SpCellConfig->spCellConfigDedicated->csi_MeasConfig->choice.setup->csi_ReportConfigToAddModList) + for (int i=0;ispCellConfigDedicated->csi_MeasConfig->choice.setup->csi_ReportConfigToAddModList->list.count;i++) { + if (SpCellConfig->spCellConfigDedicated->csi_MeasConfig->choice.setup->csi_ReportConfigToAddModList->list.array[i]->cqi_Table) + *SpCellConfig->spCellConfigDedicated->csi_MeasConfig->choice.setup->csi_ReportConfigToAddModList->list.array[i]->cqi_Table=NR_CSI_ReportConfig__cqi_Table_table2; + } } else bwp_Dedicated->pdsch_Config->choice.setup->mcs_Table = NULL; } - - diff --git a/openair2/RRC/NR/nr_rrc_config.h b/openair2/RRC/NR/nr_rrc_config.h index 1a0d091e35..8b28e2d584 100644 --- a/openair2/RRC/NR/nr_rrc_config.h +++ b/openair2/RRC/NR/nr_rrc_config.h @@ -111,9 +111,25 @@ typedef struct physicalcellgroup_s{ long RNTI_Value[MAX_NUM_CCs]; }physicalcellgroup_t; -void nr_rrc_config_dl_tda(NR_ServingCellConfigCommon_t *scc); +uint64_t get_ssb_bitmap(NR_ServingCellConfigCommon_t *scc); +void rrc_coreset_config(NR_ControlResourceSet_t *coreset, + int bwp_id, + int curr_bwp, + uint64_t ssb_bitmap); +void nr_rrc_config_dl_tda(NR_ServingCellConfigCommon_t *scc, + NR_PDSCH_TimeDomainResourceAllocationList_t *pdsch_TimeDomainAllocationList, + int curr_bwp); void nr_rrc_config_ul_tda(NR_ServingCellConfigCommon_t *scc, int min_fb_delay); +void config_csirs(NR_ServingCellConfigCommon_t *servingcellconfigcommon, + NR_CSI_MeasConfig_t *csi_MeasConfig, + int uid, + int num_dl_antenna_ports, + int curr_bwp, + int do_csirs); +void config_csiim(int do_csirs, int dl_antenna_ports, int curr_bwp, + NR_CSI_MeasConfig_t *csi_MeasConfig); void set_dl_mcs_table(int scs, NR_UE_NR_Capability_t *cap, + NR_SpCellConfig_t *SpCellConfig, NR_BWP_DownlinkDedicated_t *bwp_Dedicated, NR_ServingCellConfigCommon_t *scc); void prepare_sim_uecap(NR_UE_NR_Capability_t *cap, diff --git a/openair2/RRC/NR/nr_rrc_defs.h b/openair2/RRC/NR/nr_rrc_defs.h index 1b2c38c835..89ae9c1d2b 100644 --- a/openair2/RRC/NR/nr_rrc_defs.h +++ b/openair2/RRC/NR/nr_rrc_defs.h @@ -96,6 +96,10 @@ typedef struct nr_uid_linear_allocator_s { #define PROTOCOL_NR_RRC_CTXT_FMT PROTOCOL_CTXT_FMT #define PROTOCOL_NR_RRC_CTXT_ARGS(CTXT_Pp) PROTOCOL_NR_CTXT_ARGS(CTXT_Pp) +// 3GPP TS 38.331 Section 12 Table 12.1-1: UE performance requirements for RRC procedures for UEs +#define NR_RRC_SETUP_DELAY_MS 10 +#define NR_RRC_RECONFIGURATION_DELAY_MS 10 +#define NR_RRC_BWP_SWITCHING_DELAY_MS 6 #define NR_UE_MODULE_INVALID ((module_id_t) ~0) // FIXME attention! depends on type uint8_t!!! #define NR_UE_INDEX_INVALID ((module_id_t) ~0) // FIXME attention! depends on type uint8_t!!! used to be -1 @@ -128,7 +132,7 @@ typedef enum UE_STATE_NR_e { #define MAX_MEAS_ID 7 #define PAYLOAD_SIZE_MAX 1024 -#define RRC_BUF_SIZE 512 +#define RRC_BUF_SIZE 1024 #define UNDEF_SECURITY_MODE 0xff #define NO_SECURITY_MODE 0x20 @@ -213,7 +217,7 @@ typedef struct HANDOVER_INFO_NR_s { typedef struct { char Payload[NR_RRC_BUFFER_SIZE_MAX]; char Header[NR_RRC_HEADER_SIZE_MAX]; - char payload_size; + uint16_t payload_size; } NR_RRC_BUFFER; #define NR_RRC_BUFFER_SIZE sizeof(RRC_BUFFER_NR) @@ -286,10 +290,10 @@ typedef struct gNB_RRC_UE_s { NR_DRB_ToReleaseList_t *DRB_Release_configList2[RRC_TRANSACTION_IDENTIFIER_NUMBER]; uint8_t DRB_active[8]; - SRB_INFO SI; - SRB_INFO Srb0; - SRB_INFO_TABLE_ENTRY Srb1; - SRB_INFO_TABLE_ENTRY Srb2; + NR_SRB_INFO SI; + NR_SRB_INFO Srb0; + NR_SRB_INFO_TABLE_ENTRY Srb1; + NR_SRB_INFO_TABLE_ENTRY Srb2; NR_MeasConfig_t *measConfig; HANDOVER_INFO *handover_info; NR_MeasResults_t *measResults; @@ -372,7 +376,7 @@ typedef struct gNB_RRC_UE_s { rb_id_t gnb_gtp_ebi[S1AP_MAX_E_RAB]; rb_id_t gnb_gtp_psi[S1AP_MAX_E_RAB]; //GTPV1 F1-U TUNNELS - uint32_t incoming_teid[S1AP_MAX_E_RAB]; + uint32_t incoming_teid[S1AP_MAX_E_RAB]; uint32_t ul_failure_timer; uint32_t ue_release_timer; @@ -424,7 +428,6 @@ typedef struct rrc_gNB_ue_context_s { struct gNB_RRC_UE_s ue_context; } rrc_gNB_ue_context_t; - typedef struct { // buffer that contains the encoded messages @@ -449,15 +452,9 @@ typedef struct { NR_SIB2_t *sib2; NR_SIB3_t *sib3; NR_BCCH_DL_SCH_Message_t systemInformation; // SIB23 - int ssb_SubcarrierOffset; - int sib1_tda; - int pdsch_AntennaPorts; - int pusch_AntennaPorts; - int minRXTXTIME; - int do_CSIRS; - int do_SRS; NR_BCCH_DL_SCH_Message_t *siblock1; NR_ServingCellConfigCommon_t *servingcellconfigcommon; + NR_ServingCellConfig_t *servingcellconfig; NR_PDCCH_ConfigSIB1_t *pdcch_ConfigSIB1; NR_CellGroupConfig_t *secondaryCellGroup[MAX_NR_RRC_UE_CONTEXTS]; NR_SRB_INFO SI; @@ -520,6 +517,7 @@ typedef struct gNB_RRC_INST_s { int srb1_max_retx_threshold; int srb1_timer_reordering; int srb1_timer_status_prohibit; + int um_on_default_drb; int srs_enable[MAX_NUM_CCs]; uint16_t sctp_in_streams; uint16_t sctp_out_streams; diff --git a/openair2/RRC/NR/nr_rrc_proto.h b/openair2/RRC/NR/nr_rrc_proto.h index 7dceb55a4b..6a320123de 100644 --- a/openair2/RRC/NR/nr_rrc_proto.h +++ b/openair2/RRC/NR/nr_rrc_proto.h @@ -47,13 +47,13 @@ void rrc_config_nr_buffer(NR_SRB_INFO* Srb_info, uint8_t Lchan_type, uint8_t Role); -int8_t mac_rrc_nr_data_req(const module_id_t Mod_idP, - const int CC_id, - const frame_t frameP, - const rb_id_t Srb_id, - const rnti_t rnti, - const uint8_t Nb_tb, - uint8_t *const buffer_pP ); +uint16_t mac_rrc_nr_data_req(const module_id_t Mod_idP, + const int CC_id, + const frame_t frameP, + const rb_id_t Srb_id, + const rnti_t rnti, + const uint8_t Nb_tb, + uint8_t *const buffer_pP); void rrc_gNB_process_SgNBAdditionRequest( const protocol_ctxt_t *const ctxt_pP, @@ -79,27 +79,15 @@ void fill_default_secondaryCellGroup(NR_ServingCellConfigCommon_t *servingcellco NR_UE_NR_Capability_t *uecap, int scg_id, int servCellIndex, - int dl_antenna_ports, - int minRXTXTIMEpdsch, - int do_csirs, - int do_srs, + const gNB_RrcConfigurationReq *configuration, int uid); -void config_csirs(NR_ServingCellConfigCommon_t *servingcellconfigcommon, - NR_CSI_MeasConfig_t *csi_MeasConfig, - int dl_antenna_ports, - int curr_bwp, - int do_csirs); - void fill_default_reconfig(NR_ServingCellConfigCommon_t *servingcellconfigcommon, NR_ServingCellConfig_t *servingcellconfigdedicated, NR_RRCReconfiguration_IEs_t *reconfig, NR_CellGroupConfig_t *secondaryCellGroup, NR_UE_NR_Capability_t *uecap, - int dl_antenna_ports, - int minRXTXTIMEpdsch, - int do_csirs, - int do_srs, + const gNB_RrcConfigurationReq *configuration, int uid); void fill_default_rbconfig(NR_RadioBearerConfig_t *rbconfig, @@ -179,6 +167,13 @@ int nr_rrc_mac_remove_ue(module_id_t mod_idP, rnti_t rntiP); +int8_t nr_mac_rrc_bwp_switch_req(const module_id_t module_idP, + const frame_t frameP, + const sub_frame_t sub_frameP, + const rnti_t rntiP, + const int dl_bwp_id, + const int ul_bwp_id); + int8_t nr_mac_rrc_data_ind( const module_id_t module_idP, const int CC_id, @@ -192,6 +187,11 @@ int8_t nr_mac_rrc_data_ind( const boolean_t brOption ); +int nr_rrc_reconfiguration_req(rrc_gNB_ue_context_t *const ue_context_pP, + protocol_ctxt_t *const ctxt_pP, + const int dl_bwp_id, + const int ul_bwp_id); + int nr_rrc_gNB_decode_ccch(protocol_ctxt_t *const ctxt_pP, const uint8_t *buffer, int buffer_length, diff --git a/openair2/RRC/NR/rrc_gNB.c b/openair2/RRC/NR/rrc_gNB.c index d6c658f01d..9c4eba15a7 100755 --- a/openair2/RRC/NR/rrc_gNB.c +++ b/openair2/RRC/NR/rrc_gNB.c @@ -166,17 +166,17 @@ static void init_NR_SI(gNB_RRC_INST *rrc, gNB_RrcConfigurationReq *configuration if (NODE_IS_MONOLITHIC(rrc->node_type)){ rrc_mac_config_req_gNB(rrc->module_id, - rrc->carrier.ssb_SubcarrierOffset, - rrc->carrier.pdsch_AntennaPorts, - rrc->carrier.pusch_AntennaPorts, - rrc->carrier.sib1_tda, - rrc->carrier.minRXTXTIME, - (NR_ServingCellConfigCommon_t *)rrc->carrier.servingcellconfigcommon, - &rrc->carrier.mib, - 0, - 0, // WIP hardcoded rnti - (NR_CellGroupConfig_t *)NULL - ); + rrc->configuration.ssb_SubcarrierOffset, + rrc->configuration.pdsch_AntennaPorts, + rrc->configuration.pusch_AntennaPorts, + rrc->configuration.sib1_tda, + rrc->configuration.minRXTXTIME, + rrc->carrier.servingcellconfigcommon, + &rrc->carrier.mib, + rrc->carrier.siblock1, + 0, + 0, // WIP hardcoded rnti + NULL); } /* set flag to indicate that cell information is configured. This is required @@ -216,14 +216,9 @@ char openair_rrc_gNB_configuration(const module_id_t gnb_mod_idP, gNB_RrcConfigu rrc->s1ap_id2_s1ap_ids = hashtable_create (NUMBER_OF_UE_MAX * 2, NULL, NULL); rrc->initial_id2_ngap_ids = hashtable_create (NUMBER_OF_UE_MAX * 2, NULL, NULL); rrc->ngap_id2_ngap_ids = hashtable_create (NUMBER_OF_UE_MAX * 2, NULL, NULL); + rrc->configuration = *configuration; rrc->carrier.servingcellconfigcommon = configuration->scc; - rrc->carrier.ssb_SubcarrierOffset = configuration->ssb_SubcarrierOffset; - rrc->carrier.pdsch_AntennaPorts = configuration->pdsch_AntennaPorts; - rrc->carrier.pusch_AntennaPorts = configuration->pusch_AntennaPorts; - rrc->carrier.minRXTXTIME = configuration->minRXTXTIME; - rrc->carrier.sib1_tda = configuration->sib1_tda; - rrc->carrier.do_CSIRS = configuration->do_CSIRS; - rrc->carrier.do_SRS = configuration->do_SRS; + rrc->carrier.servingcellconfig = configuration->scd; nr_rrc_config_ul_tda(configuration->scc,configuration->minRXTXTIME); /// System Information INIT pthread_mutex_init(&rrc->cell_info_mutex,NULL); @@ -279,24 +274,26 @@ void apply_macrlc_config(gNB_RRC_INST *rrc, rrc_gNB_ue_context_t *const ue_context_pP, const protocol_ctxt_t *const ctxt_pP ) { - rrc_mac_config_req_gNB(rrc->module_id, - rrc->carrier.ssb_SubcarrierOffset, - rrc->carrier.pdsch_AntennaPorts, - rrc->carrier.pusch_AntennaPorts, - rrc->carrier.sib1_tda, - rrc->carrier.minRXTXTIME, - NULL, - NULL, - 0, - ue_context_pP->ue_context.rnti, - get_softmodem_params()->sa ? ue_context_pP->ue_context.masterCellGroup : (NR_CellGroupConfig_t *)NULL); + NR_CellGroupConfig_t *cgc = get_softmodem_params()->sa ? ue_context_pP->ue_context.masterCellGroup : NULL; + rrc_mac_config_req_gNB(rrc->module_id, + rrc->configuration.ssb_SubcarrierOffset, + rrc->configuration.pdsch_AntennaPorts, + rrc->configuration.pusch_AntennaPorts, + rrc->configuration.sib1_tda, + rrc->configuration.minRXTXTIME, + NULL, + NULL, + NULL, + 0, + ue_context_pP->ue_context.rnti, + cgc); - nr_rrc_rlc_config_asn1_req(ctxt_pP, - ue_context_pP->ue_context.SRB_configList, - ue_context_pP->ue_context.DRB_configList, - NULL, - NULL, - get_softmodem_params()->sa ? ue_context_pP->ue_context.masterCellGroup->rlc_BearerToAddModList : NULL); + nr_rrc_rlc_config_asn1_req(ctxt_pP, + ue_context_pP->ue_context.SRB_configList, + ue_context_pP->ue_context.DRB_configList, + NULL, + NULL, + get_softmodem_params()->sa ? cgc->rlc_BearerToAddModList : NULL); } @@ -339,11 +336,16 @@ rrc_gNB_generate_RRCSetup( // T_INT(ctxt_pP->rnti)); gNB_RRC_UE_t *ue_p = &ue_context_pP->ue_context; gNB_RRC_INST *rrc = RC.nrrrc[ctxt_pP->module_id]; - ue_p->Srb0.Tx_buffer.payload_size = do_RRCSetup(ue_context_pP, - (uint8_t *) ue_p->Srb0.Tx_buffer.Payload, - rrc_gNB_get_next_transaction_identifier(ctxt_pP->module_id), - masterCellGroup_from_DU, - scc,&rrc->carrier); + NR_ServingCellConfig_t *servingcellconfigdedicated = rrc->configuration.scd; + int16_t ret = do_RRCSetup(ue_context_pP, + (uint8_t *) ue_p->Srb0.Tx_buffer.Payload, + rrc_gNB_get_next_transaction_identifier(ctxt_pP->module_id), + masterCellGroup_from_DU, + scc,servingcellconfigdedicated,&rrc->configuration); + + AssertFatal(ret>0,"Error generating RRCSetup for RRCSetupRequest\n"); + + ue_p->Srb0.Tx_buffer.payload_size = ret; LOG_DUMPMSG(NR_RRC, DEBUG_RRC, (char *)(ue_p->Srb0.Tx_buffer.Payload), @@ -445,15 +447,20 @@ rrc_gNB_generate_RRCSetup_for_RRCReestablishmentRequest( rrc_gNB_ue_context_t *ue_context_pP = NULL; gNB_RRC_INST *rrc_instance_p = RC.nrrrc[ctxt_pP->module_id]; NR_ServingCellConfigCommon_t *scc=rrc_instance_p->carrier.servingcellconfigcommon; + NR_ServingCellConfig_t *servingcellconfigdedicated = rrc_instance_p->configuration.scd; ue_context_pP = rrc_gNB_get_next_free_ue_context(ctxt_pP, rrc_instance_p, 0); gNB_RRC_UE_t *ue_p = &ue_context_pP->ue_context; - ue_p->Srb0.Tx_buffer.payload_size = do_RRCSetup(ue_context_pP, - (uint8_t *) ue_p->Srb0.Tx_buffer.Payload, - rrc_gNB_get_next_transaction_identifier(ctxt_pP->module_id), - NULL, - scc,&rrc_instance_p->carrier); + int16_t ret = do_RRCSetup(ue_context_pP, + (uint8_t *) ue_p->Srb0.Tx_buffer.Payload, + rrc_gNB_get_next_transaction_identifier(ctxt_pP->module_id), + NULL, + scc,servingcellconfigdedicated,&rrc_instance_p->configuration); + + AssertFatal(ret>0,"Error generating RRCSetup for RRCReestablishmentRequest\n"); + + ue_p->Srb0.Tx_buffer.payload_size = ret; LOG_DUMPMSG(NR_RRC, DEBUG_RRC, (char *)(ue_p->Srb0.Tx_buffer.Payload), @@ -465,17 +472,17 @@ rrc_gNB_generate_RRCSetup_for_RRCReestablishmentRequest( PROTOCOL_NR_RRC_CTXT_UE_ARGS(ctxt_pP)); rrc_mac_config_req_gNB(rrc_instance_p->module_id, - rrc_instance_p->carrier.ssb_SubcarrierOffset, - rrc_instance_p->carrier.pdsch_AntennaPorts, - rrc_instance_p->carrier.pusch_AntennaPorts, - rrc_instance_p->carrier.sib1_tda, - rrc_instance_p->carrier.minRXTXTIME, - (NR_ServingCellConfigCommon_t *)rrc_instance_p->carrier.servingcellconfigcommon, + rrc_instance_p->configuration.ssb_SubcarrierOffset, + rrc_instance_p->configuration.pdsch_AntennaPorts, + rrc_instance_p->configuration.pusch_AntennaPorts, + rrc_instance_p->configuration.sib1_tda, + rrc_instance_p->configuration.minRXTXTIME, + rrc_instance_p->carrier.servingcellconfigcommon, &rrc_instance_p->carrier.mib, + rrc_instance_p->carrier.siblock1, 0, ue_context_pP->ue_context.rnti, - (NR_CellGroupConfig_t *)NULL - ); + NULL); LOG_I(NR_RRC, PROTOCOL_NR_RRC_CTXT_UE_FMT" [RAPROC] Logical Channel DL-CCCH, Generating RRCSetup (bytes %d)\n", @@ -723,6 +730,7 @@ rrc_gNB_generate_defaultRRCReconfiguration( dedicatedNAS_MessageList, ue_context_pP, &rrc->carrier, + &rrc->configuration, NULL, ue_p->masterCellGroup); @@ -798,6 +806,19 @@ rrc_gNB_generate_defaultRRCReconfiguration( default : LOG_W(NR_RRC, "Unknown node type %d\n", RC.nrrrc[ctxt_pP->module_id]->node_type); } + + if (NODE_IS_DU(rrc->node_type) || NODE_IS_MONOLITHIC(rrc->node_type)) { + uint32_t delay_ms = ue_context_pP->ue_context.masterCellGroup && + ue_context_pP->ue_context.masterCellGroup->spCellConfig && + ue_context_pP->ue_context.masterCellGroup->spCellConfig->spCellConfigDedicated && + ue_context_pP->ue_context.masterCellGroup->spCellConfig->spCellConfigDedicated->downlinkBWP_ToAddModList ? + NR_RRC_RECONFIGURATION_DELAY_MS + NR_RRC_BWP_SWITCHING_DELAY_MS : NR_RRC_RECONFIGURATION_DELAY_MS; + + nr_mac_enable_ue_rrc_processing_timer(ctxt_pP->module_id, + ue_context_pP->ue_context.rnti, + *rrc->carrier.servingcellconfigcommon->ssbSubcarrierSpacing, + delay_ms); + } } //----------------------------------------------------------------------------- @@ -822,9 +843,11 @@ rrc_gNB_generate_dedicatedRRCReconfiguration( uint8_t buffer[RRC_BUF_SIZE]; uint16_t size; int qos_flow_index = 0; - NR_QFI_t qfi = 0; int pdu_sessions_done = 0; int i; + uint8_t drb_id_to_setup_start = 1; + uint8_t nb_drb_to_setup = 0; + long drb_priority[1] = {13}; // For now, we assume only one drb per pdu sessions with a default preiority (will be dynamique in future) NR_CellGroupConfig_t *cellGroupConfig; uint8_t xid = rrc_gNB_get_next_transaction_identifier(ctxt_pP->module_id); @@ -867,21 +890,29 @@ rrc_gNB_generate_dedicatedRRCReconfiguration( DRB_config = CALLOC(1, sizeof(*DRB_config)); DRB_config->drb_Identity = i+1; + if (drb_id_to_setup_start == 1) drb_id_to_setup_start = DRB_config->drb_Identity; + nb_drb_to_setup++; DRB_config->cnAssociation = CALLOC(1, sizeof(*DRB_config->cnAssociation)); DRB_config->cnAssociation->present = NR_DRB_ToAddMod__cnAssociation_PR_sdap_Config; // sdap_Config sdap_config = CALLOC(1, sizeof(NR_SDAP_Config_t)); memset(sdap_config, 0, sizeof(NR_SDAP_Config_t)); sdap_config->pdu_Session = ue_context_pP->ue_context.pduSession[i].param.pdusession_id; - sdap_config->sdap_HeaderDL = NR_SDAP_Config__sdap_HeaderDL_present; - sdap_config->sdap_HeaderUL = NR_SDAP_Config__sdap_HeaderUL_absent; + if (rrc->configuration.enable_sdap) { + sdap_config->sdap_HeaderDL = NR_SDAP_Config__sdap_HeaderDL_present; + sdap_config->sdap_HeaderUL = NR_SDAP_Config__sdap_HeaderUL_present; + } else { + sdap_config->sdap_HeaderDL = NR_SDAP_Config__sdap_HeaderDL_absent; + sdap_config->sdap_HeaderUL = NR_SDAP_Config__sdap_HeaderUL_absent; + } sdap_config->defaultDRB = TRUE; sdap_config->mappedQoS_FlowsToAdd = calloc(1, sizeof(struct NR_SDAP_Config__mappedQoS_FlowsToAdd)); memset(sdap_config->mappedQoS_FlowsToAdd, 0, sizeof(struct NR_SDAP_Config__mappedQoS_FlowsToAdd)); for (qos_flow_index = 0; qos_flow_index < ue_context_pP->ue_context.pduSession[i].param.nb_qos; qos_flow_index++) { - qfi = ue_context_pP->ue_context.pduSession[i].param.qos[qos_flow_index].qfi; - ASN_SEQUENCE_ADD(&sdap_config->mappedQoS_FlowsToAdd->list, &qfi); + NR_QFI_t *qfi = calloc(1, sizeof(NR_QFI_t)); + *qfi = ue_context_pP->ue_context.pduSession[i].param.qos[qos_flow_index].qfi; + ASN_SEQUENCE_ADD(&sdap_config->mappedQoS_FlowsToAdd->list, qfi); } sdap_config->mappedQoS_FlowsToRelease = NULL; DRB_config->cnAssociation->choice.sdap_Config = sdap_config; @@ -974,7 +1005,8 @@ rrc_gNB_generate_dedicatedRRCReconfiguration( memset(buffer, 0, sizeof(buffer)); cellGroupConfig = calloc(1, sizeof(NR_CellGroupConfig_t)); - fill_mastercellGroupConfig(cellGroupConfig, ue_context_pP->ue_context.masterCellGroup); + + fill_mastercellGroupConfig(cellGroupConfig, ue_context_pP->ue_context.masterCellGroup, rrc->um_on_default_drb, (drb_id_to_setup_start < 2) ? 1 : 0, drb_id_to_setup_start, nb_drb_to_setup, drb_priority); size = do_RRCReconfiguration(ctxt_pP, buffer, sizeof(buffer), xid, *SRB_configList2, @@ -986,6 +1018,7 @@ rrc_gNB_generate_dedicatedRRCReconfiguration( dedicatedNAS_MessageList, ue_context_pP, &rrc->carrier, + &rrc->configuration, NULL, cellGroupConfig); LOG_DUMPMSG(NR_RRC,DEBUG_RRC,(char *)buffer,size,"[MSG] RRC Reconfiguration\n"); @@ -1026,6 +1059,19 @@ rrc_gNB_generate_dedicatedRRCReconfiguration( buffer, PDCP_TRANSMISSION_MODE_CONTROL); #endif + + if (NODE_IS_DU(rrc->node_type) || NODE_IS_MONOLITHIC(rrc->node_type)) { + uint32_t delay_ms = ue_context_pP->ue_context.masterCellGroup && + ue_context_pP->ue_context.masterCellGroup->spCellConfig && + ue_context_pP->ue_context.masterCellGroup->spCellConfig->spCellConfigDedicated && + ue_context_pP->ue_context.masterCellGroup->spCellConfig->spCellConfigDedicated->downlinkBWP_ToAddModList ? + NR_RRC_RECONFIGURATION_DELAY_MS + NR_RRC_BWP_SWITCHING_DELAY_MS : NR_RRC_RECONFIGURATION_DELAY_MS; + + nr_mac_enable_ue_rrc_processing_timer(ctxt_pP->module_id, + ue_context_pP->ue_context.rnti, + *rrc->carrier.servingcellconfigcommon->ssbSubcarrierSpacing, + delay_ms); + } } //----------------------------------------------------------------------------- @@ -1159,6 +1205,7 @@ rrc_gNB_modify_dedicatedRRCReconfiguration( NULL, NULL, NULL, + NULL, NULL); LOG_DUMPMSG(NR_RRC, DEBUG_RRC, (char *)buffer, size, "[MSG] RRC Reconfiguration\n"); @@ -1198,6 +1245,19 @@ rrc_gNB_modify_dedicatedRRCReconfiguration( buffer, PDCP_TRANSMISSION_MODE_CONTROL); #endif + + if (NODE_IS_DU(RC.nrrrc[ctxt_pP->module_id]->node_type) || NODE_IS_MONOLITHIC(RC.nrrrc[ctxt_pP->module_id]->node_type)) { + uint32_t delay_ms = ue_context_pP->ue_context.masterCellGroup && + ue_context_pP->ue_context.masterCellGroup->spCellConfig && + ue_context_pP->ue_context.masterCellGroup->spCellConfig->spCellConfigDedicated && + ue_context_pP->ue_context.masterCellGroup->spCellConfig->spCellConfigDedicated->downlinkBWP_ToAddModList ? + NR_RRC_RECONFIGURATION_DELAY_MS + NR_RRC_BWP_SWITCHING_DELAY_MS : NR_RRC_RECONFIGURATION_DELAY_MS; + + nr_mac_enable_ue_rrc_processing_timer(ctxt_pP->module_id, + ue_context_pP->ue_context.rnti, + *RC.nrrrc[ctxt_pP->module_id]->carrier.servingcellconfigcommon->ssbSubcarrierSpacing, + delay_ms); + } } //----------------------------------------------------------------------------- @@ -1259,11 +1319,12 @@ rrc_gNB_generate_dedicatedRRCReconfiguration_release( NULL, NULL, NULL, + NULL, NULL); ue_context_pP->ue_context.pdu_session_release_command_flag = 1; - LOG_DUMPMSG(NR_RRC,DEBUG_RRC,(char *)buffer,size, - "[MSG] RRC Reconfiguration\n"); + + LOG_DUMPMSG(NR_RRC,DEBUG_RRC,(char *)buffer,size, "[MSG] RRC Reconfiguration\n"); /* Free all NAS PDUs */ if (nas_length > 0) { @@ -1297,6 +1358,19 @@ rrc_gNB_generate_dedicatedRRCReconfiguration_release( buffer, PDCP_TRANSMISSION_MODE_CONTROL); #endif + + if (NODE_IS_DU(RC.nrrrc[ctxt_pP->module_id]->node_type) || NODE_IS_MONOLITHIC(RC.nrrrc[ctxt_pP->module_id]->node_type)) { + uint32_t delay_ms = ue_context_pP->ue_context.masterCellGroup && + ue_context_pP->ue_context.masterCellGroup->spCellConfig && + ue_context_pP->ue_context.masterCellGroup->spCellConfig->spCellConfigDedicated && + ue_context_pP->ue_context.masterCellGroup->spCellConfig->spCellConfigDedicated->downlinkBWP_ToAddModList ? + NR_RRC_RECONFIGURATION_DELAY_MS + NR_RRC_BWP_SWITCHING_DELAY_MS : NR_RRC_RECONFIGURATION_DELAY_MS; + + nr_mac_enable_ue_rrc_processing_timer(ctxt_pP->module_id, + ue_context_pP->ue_context.rnti, + *RC.nrrrc[ctxt_pP->module_id]->carrier.servingcellconfigcommon->ssbSubcarrierSpacing, + delay_ms); + } } //----------------------------------------------------------------------------- @@ -1362,17 +1436,17 @@ rrc_gNB_process_RRCReconfigurationComplete( if (!NODE_IS_CU(RC.nrrrc[ctxt_pP->module_id]->node_type)) { rrc_mac_config_req_gNB(rrc->module_id, - rrc->carrier.ssb_SubcarrierOffset, - rrc->carrier.pdsch_AntennaPorts, - rrc->carrier.pusch_AntennaPorts, - rrc->carrier.sib1_tda, - rrc->carrier.minRXTXTIME, + rrc->configuration.ssb_SubcarrierOffset, + rrc->configuration.pdsch_AntennaPorts, + rrc->configuration.pusch_AntennaPorts, + rrc->configuration.sib1_tda, + rrc->configuration.minRXTXTIME, + NULL, NULL, NULL, 0, ue_context_pP->ue_context.rnti, - ue_context_pP->ue_context.masterCellGroup - ); + ue_context_pP->ue_context.masterCellGroup); LOG_D(NR_RRC,"Configuring RLC DRBs/SRBs for UE %x\n",ue_context_pP->ue_context.rnti); nr_rrc_rlc_config_asn1_req(ctxt_pP, SRB_configList, // NULL, @@ -1574,7 +1648,7 @@ rrc_gNB_generate_RRCReestablishment( ue_context->Srb0.Tx_buffer.payload_size); #if(0) /* TODO : It may be needed if gNB goes into full stack working. */ - UE_id = find_nr_UE_id(module_id, rnti); + UE = find_nr_UE(module_id, rnti); if (UE_id != -1) { /* Activate reject timer, if RRCComplete not received after 10 frames, reject UE */ RC.nrmac[module_id]->UE_info.UE_sched_ctrl[UE_id].ue_reestablishment_reject_timer = 1; @@ -1810,9 +1884,10 @@ rrc_gNB_process_RRCConnectionReestablishmentComplete( NULL, NULL, NULL, + NULL, NULL); - LOG_DUMPMSG(NR_RRC,DEBUG_RRC,(char *)buffer,size, - "[MSG] RRC Reconfiguration\n"); + + LOG_DUMPMSG(NR_RRC,DEBUG_RRC,(char *)buffer,size, "[MSG] RRC Reconfiguration\n"); /* Free all NAS PDUs */ for (i = 0; i < ue_context_pP->ue_context.nb_of_pdusessions; i++) { @@ -1854,9 +1929,81 @@ rrc_gNB_process_RRCConnectionReestablishmentComplete( PDCP_TRANSMISSION_MODE_CONTROL); #endif } + + if (NODE_IS_DU(RC.nrrrc[ctxt_pP->module_id]->node_type) || NODE_IS_MONOLITHIC(RC.nrrrc[ctxt_pP->module_id]->node_type)) { + uint32_t delay_ms = ue_context_pP->ue_context.masterCellGroup && + ue_context_pP->ue_context.masterCellGroup->spCellConfig && + ue_context_pP->ue_context.masterCellGroup->spCellConfig->spCellConfigDedicated && + ue_context_pP->ue_context.masterCellGroup->spCellConfig->spCellConfigDedicated->downlinkBWP_ToAddModList ? + NR_RRC_RECONFIGURATION_DELAY_MS + NR_RRC_BWP_SWITCHING_DELAY_MS : NR_RRC_RECONFIGURATION_DELAY_MS; + + nr_mac_enable_ue_rrc_processing_timer(ctxt_pP->module_id, + ue_context_pP->ue_context.rnti, + *RC.nrrrc[ctxt_pP->module_id]->carrier.servingcellconfigcommon->ssbSubcarrierSpacing, + delay_ms); + } } //----------------------------------------------------------------------------- +int nr_rrc_reconfiguration_req(rrc_gNB_ue_context_t *const ue_context_pP, + protocol_ctxt_t *const ctxt_pP, + const int dl_bwp_id, + const int ul_bwp_id) { + + uint8_t buffer[RRC_BUF_SIZE]; + memset(buffer, 0, sizeof(buffer)); + uint8_t xid = rrc_gNB_get_next_transaction_identifier(ctxt_pP->module_id); + + NR_CellGroupConfig_t *masterCellGroup = ue_context_pP->ue_context.masterCellGroup; + if (dl_bwp_id >= 0) { + *masterCellGroup->spCellConfig->spCellConfigDedicated->firstActiveDownlinkBWP_Id = dl_bwp_id; + *masterCellGroup->spCellConfig->spCellConfigDedicated->defaultDownlinkBWP_Id = dl_bwp_id; + } + if (ul_bwp_id >= 0) { + *masterCellGroup->spCellConfig->spCellConfigDedicated->uplinkConfig->firstActiveUplinkBWP_Id = ul_bwp_id; + } + + uint16_t size = do_RRCReconfiguration(ctxt_pP, + buffer, + sizeof(buffer), + xid, + NULL, + NULL, + NULL, + NULL, + NULL, + NULL, + NULL, + NULL, + NULL, + NULL, + NULL, + masterCellGroup); + + nr_rrc_data_req(ctxt_pP, + DCCH, + rrc_gNB_mui++, + SDU_CONFIRM_NO, + size, + buffer, + PDCP_TRANSMISSION_MODE_CONTROL); + + if (NODE_IS_DU(RC.nrrrc[ctxt_pP->module_id]->node_type) || NODE_IS_MONOLITHIC(RC.nrrrc[ctxt_pP->module_id]->node_type)) { + uint32_t delay_ms = ue_context_pP->ue_context.masterCellGroup && + ue_context_pP->ue_context.masterCellGroup->spCellConfig && + ue_context_pP->ue_context.masterCellGroup->spCellConfig->spCellConfigDedicated && + ue_context_pP->ue_context.masterCellGroup->spCellConfig->spCellConfigDedicated->downlinkBWP_ToAddModList ? + NR_RRC_RECONFIGURATION_DELAY_MS + NR_RRC_BWP_SWITCHING_DELAY_MS : NR_RRC_RECONFIGURATION_DELAY_MS; + + nr_mac_enable_ue_rrc_processing_timer(ctxt_pP->module_id, + ue_context_pP->ue_context.rnti, + *RC.nrrrc[ctxt_pP->module_id]->carrier.servingcellconfigcommon->ssbSubcarrierSpacing, + delay_ms); + } + + return 0; +} + /*------------------------------------------------------------------------------*/ int nr_rrc_gNB_decode_ccch(protocol_ctxt_t *const ctxt_pP, const uint8_t *buffer, @@ -3103,10 +3250,9 @@ static void rrc_DU_process_ue_context_setup_request(MessageDef *msg_p, const cha f1ap_ue_context_setup_t * resp=&F1AP_UE_CONTEXT_SETUP_RESP(message_p); uint32_t incoming_teid = 0; - - NR_CellGroupConfig_t *cellGroupConfig; - cellGroupConfig = calloc(1, sizeof(NR_CellGroupConfig_t)); - fill_mastercellGroupConfig(cellGroupConfig, ue_context_p->ue_context.masterCellGroup); + uint8_t drb_id_to_setup_start = 0; + uint8_t nb_drb_to_setup = 0; + long drb_priority[1] = {13}; // For now, we assume only one drb per pdu sessions with a default preiority (will be dynamique in future) /* Configure SRB2 */ NR_SRB_ToAddMod_t *SRB2_config = NULL; @@ -3135,6 +3281,7 @@ static void rrc_DU_process_ue_context_setup_request(MessageDef *msg_p, const cha ue_context_p->ue_context.DRB_configList = CALLOC(1, sizeof(*ue_context_p->ue_context.DRB_configList)); } DRB_configList = ue_context_p->ue_context.DRB_configList; + nb_drb_to_setup = req->drbs_to_be_setup_length; for (int i=0; idrbs_to_be_setup_length; i++){ DRB_config = CALLOC(1, sizeof(*DRB_config)); DRB_config->drb_Identity = req->drbs_to_be_setup[i].drb_id; @@ -3144,6 +3291,7 @@ static void rrc_DU_process_ue_context_setup_request(MessageDef *msg_p, const cha memcpy(addr.buffer, &drb_p.up_ul_tnl[0].tl_address, sizeof(drb_p.up_ul_tnl[0].tl_address)); addr.length=sizeof(drb_p.up_ul_tnl[0].tl_address)*8; extern instance_t DUuniqInstance; + if (!drb_id_to_setup_start) drb_id_to_setup_start = drb_p.drb_id; incoming_teid=newGtpuCreateTunnel(DUuniqInstance, req->rnti, drb_p.drb_id, @@ -3155,6 +3303,10 @@ static void rrc_DU_process_ue_context_setup_request(MessageDef *msg_p, const cha } } + NR_CellGroupConfig_t *cellGroupConfig; + cellGroupConfig = calloc(1, sizeof(NR_CellGroupConfig_t)); + fill_mastercellGroupConfig(cellGroupConfig, ue_context_p->ue_context.masterCellGroup, rrc->um_on_default_drb, SRB2_config ? 1 : 0, drb_id_to_setup_start, nb_drb_to_setup, drb_priority); + apply_macrlc_config(rrc, ue_context_p, &ctxt); /* Fill the UE context setup response ITTI message to send to F1AP */ resp->gNB_CU_ue_id = req->gNB_CU_ue_id; @@ -3407,6 +3559,7 @@ void nr_rrc_subframe_process(protocol_ctxt_t *const ctxt_pP, const int CC_id) { FILE *fd=NULL;//fopen("nrRRCstats.log","w"); RB_FOREACH(ue_context_p, rrc_nr_ue_tree_s, &(RC.nrrrc[ctxt_pP->module_id]->rrc_ue_head)) { ctxt_pP->rnti = ue_context_p->ue_id_rnti; + gNB_MAC_INST *nrmac=RC.nrmac[ctxt_pP->module_id]; //WHAT A BEAUTIFULL RACE CONDITION !!! if (fd) { if (ue_context_p->ue_context.Initialue_identity_5g_s_TMSI.presence == TRUE) { @@ -3446,7 +3599,7 @@ void nr_rrc_subframe_process(protocol_ctxt_t *const ctxt_pP, const int CC_id) { // Remove here the MAC and RRC context when RRC is not connected or gNB is not connected to CN5G if(ue_context_p->ue_context.StatusRrc < NR_RRC_CONNECTED || ue_context_p->ue_context.gNB_ue_ngap_id == 0) { - mac_remove_nr_ue(ctxt_pP->module_id, ctxt_pP->rnti); + mac_remove_nr_ue(nrmac, ctxt_pP->rnti); rrc_rlc_remove_ue(ctxt_pP); pdcp_remove_UE(ctxt_pP); @@ -3470,9 +3623,10 @@ void nr_rrc_subframe_process(protocol_ctxt_t *const ctxt_pP, const int CC_id) { ue_context_p->ue_context.rnti); ue_context_p->ue_context.ue_release_timer_rrc = 0; - mac_remove_nr_ue(ctxt_pP->module_id, ctxt_pP->rnti); + mac_remove_nr_ue(nrmac, ctxt_pP->rnti); rrc_rlc_remove_ue(ctxt_pP); pdcp_remove_UE(ctxt_pP); + newGtpuDeleteAllTunnels(ctxt_pP->instance, ctxt_pP->rnti); /* remove RRC UE Context */ ue_context_p = rrc_gNB_get_ue_context(RC.nrrrc[ctxt_pP->module_id], ctxt_pP->rnti); @@ -3488,7 +3642,6 @@ void nr_rrc_subframe_process(protocol_ctxt_t *const ctxt_pP, const int CC_id) { if (fd) fclose(fd); - /* send a tick to x2ap */ if (is_x2ap_enabled()){ msg = itti_alloc_new_message(TASK_RRC_ENB, 0, X2AP_SUBFRAME_PROCESS); diff --git a/openair2/RRC/NR/rrc_gNB_NGAP.c b/openair2/RRC/NR/rrc_gNB_NGAP.c index 4286ea0d62..96ec634433 100644 --- a/openair2/RRC/NR/rrc_gNB_NGAP.c +++ b/openair2/RRC/NR/rrc_gNB_NGAP.c @@ -905,30 +905,27 @@ rrc_gNB_send_NGAP_PDUSESSION_SETUP_RESP( for (pdusession = 0; pdusession < ue_context_pP->ue_context.setup_pdu_sessions; pdusession++) { // if (xid == ue_context_pP->ue_context.pdusession[pdusession].xid) { if (ue_context_pP->ue_context.pduSession[pdusession].status == PDU_SESSION_STATUS_DONE) { - NGAP_PDUSESSION_SETUP_RESP(msg_p).pdusessions[pdusession].pdusession_id = ue_context_pP->ue_context.pduSession[pdusession].param.pdusession_id; - // NGAP_PDUSESSION_SETUP_RESP(msg_p).pdusessions[pdusession].pdusession_id = 1; - NGAP_PDUSESSION_SETUP_RESP(msg_p).pdusessions[pdusession].nb_of_qos_flow = ue_context_pP->ue_context.pduSession[pdusession].param.nb_qos; - NGAP_PDUSESSION_SETUP_RESP(msg_p).pdusessions[pdusession].gtp_teid = ue_context_pP->ue_context.gnb_gtp_teid[pdusession]; - NGAP_PDUSESSION_SETUP_RESP(msg_p).pdusessions[pdusession].gNB_addr.pdu_session_type = PDUSessionType_ipv4; - NGAP_PDUSESSION_SETUP_RESP(msg_p).pdusessions[pdusession].gNB_addr.length = ue_context_pP->ue_context.gnb_gtp_addrs[pdusession].length; - memcpy(NGAP_PDUSESSION_SETUP_RESP(msg_p).pdusessions[pdusession].gNB_addr.buffer, - ue_context_pP->ue_context.gnb_gtp_addrs[pdusession].buffer, sizeof(uint8_t)*20); - for (qos_flow_index = 0; qos_flow_index < NGAP_PDUSESSION_SETUP_RESP(msg_p).pdusessions[pdusession].nb_of_qos_flow; qos_flow_index++) { - NGAP_PDUSESSION_SETUP_RESP(msg_p).pdusessions[pdusession].associated_qos_flows[qos_flow_index].qfi = + pdusession_setup_t * tmp=&NGAP_PDUSESSION_SETUP_RESP(msg_p).pdusessions[pdu_sessions_done]; + tmp->pdusession_id = ue_context_pP->ue_context.pduSession[pdusession].param.pdusession_id; + // tmp->pdusession_id = 1; + tmp->nb_of_qos_flow = ue_context_pP->ue_context.pduSession[pdusession].param.nb_qos; + tmp->gtp_teid = ue_context_pP->ue_context.gnb_gtp_teid[pdusession]; + tmp->gNB_addr.pdu_session_type = PDUSessionType_ipv4; + tmp->gNB_addr.length = ue_context_pP->ue_context.gnb_gtp_addrs[pdusession].length; + memcpy(tmp->gNB_addr.buffer, + ue_context_pP->ue_context.gnb_gtp_addrs[pdusession].buffer, tmp->gNB_addr.length); + for (qos_flow_index = 0; qos_flow_index < tmp->nb_of_qos_flow; qos_flow_index++) { + tmp->associated_qos_flows[qos_flow_index].qfi = ue_context_pP->ue_context.pduSession[pdusession].param.qos[qos_flow_index].qfi; - NGAP_PDUSESSION_SETUP_RESP(msg_p).pdusessions[pdusession].associated_qos_flows[qos_flow_index].qos_flow_mapping_ind = QOSFLOW_MAPPING_INDICATION_DL; + tmp->associated_qos_flows[qos_flow_index].qos_flow_mapping_ind = QOSFLOW_MAPPING_INDICATION_DL; } ue_context_pP->ue_context.pduSession[pdusession].status = PDU_SESSION_STATUS_ESTABLISHED; - LOG_I (NR_RRC,"gnb_gtp_addr (msg index %d, pdu_sessions index %d, status %d, xid %d): nb_of_pdusessions %d, pdusession_id %d, teid: %u, addr: %d.%d.%d.%d \n ", + LOG_I (NR_RRC,"gnb_gtp_addr (msg index %d, pdu_sessions index %d, status %d, xid %d): nb_of_pdusessions %d, pdusession_id %d, teid: %u \n ", pdu_sessions_done, pdusession, ue_context_pP->ue_context.pduSession[pdusession].status, xid, ue_context_pP->ue_context.nb_of_pdusessions, NGAP_PDUSESSION_SETUP_RESP (msg_p).pdusessions[pdu_sessions_done].pdusession_id, - NGAP_PDUSESSION_SETUP_RESP (msg_p).pdusessions[pdu_sessions_done].gtp_teid, - NGAP_PDUSESSION_SETUP_RESP (msg_p).pdusessions[pdu_sessions_done].gNB_addr.buffer[0], - NGAP_PDUSESSION_SETUP_RESP (msg_p).pdusessions[pdu_sessions_done].gNB_addr.buffer[1], - NGAP_PDUSESSION_SETUP_RESP (msg_p).pdusessions[pdu_sessions_done].gNB_addr.buffer[2], - NGAP_PDUSESSION_SETUP_RESP (msg_p).pdusessions[pdu_sessions_done].gNB_addr.buffer[3]); + NGAP_PDUSESSION_SETUP_RESP (msg_p).pdusessions[pdu_sessions_done].gtp_teid); pdu_sessions_done++; } else if ((ue_context_pP->ue_context.pduSession[pdusession].status == PDU_SESSION_STATUS_NEW) || (ue_context_pP->ue_context.pduSession[pdusession].status == PDU_SESSION_STATUS_ESTABLISHED)) { @@ -972,9 +969,9 @@ rrc_gNB_process_NGAP_PDUSESSION_SETUP_REQ( uint16_t ue_initial_id; uint32_t gNB_ue_ngap_id; rrc_gNB_ue_context_t *ue_context_p = NULL; - protocol_ctxt_t ctxt; - gtpv1u_gnb_create_tunnel_req_t create_tunnel_req; - gtpv1u_gnb_create_tunnel_resp_t create_tunnel_resp; + protocol_ctxt_t ctxt={0}; + gtpv1u_gnb_create_tunnel_req_t create_tunnel_req={0}; + gtpv1u_gnb_create_tunnel_resp_t create_tunnel_resp={0}; uint8_t pdu_sessions_done; uint8_t inde_list[NR_NB_RB_MAX - 3]= {0}; int ret = 0; diff --git a/openair2/RRC/NR/rrc_gNB_nsa.c b/openair2/RRC/NR/rrc_gNB_nsa.c index 70dfebaaf7..07a6bd85be 100644 --- a/openair2/RRC/NR/rrc_gNB_nsa.c +++ b/openair2/RRC/NR/rrc_gNB_nsa.c @@ -106,6 +106,9 @@ void rrc_parse_ue_capabilities(gNB_RRC_INST *rrc, NR_UE_CapabilityRAT_ContainerL } LOG_A(NR_RRC, "Successfully decoded UE NR capabilities (NR and MRDC)\n"); + ue_context_p->ue_context.spCellConfig = calloc(1, sizeof(struct NR_SpCellConfig)); + ue_context_p->ue_context.spCellConfig->spCellConfigDedicated = rrc->carrier.servingcellconfig; + LOG_I(NR_RRC,"Adding new NSA user (%p)\n",ue_context_p); rrc_add_nsa_user(rrc,ue_context_p, m); } @@ -116,6 +119,7 @@ RB_PROTOTYPE(rrc_nr_ue_tree_s, rrc_gNB_ue_context_s, entries, void rrc_add_nsa_user(gNB_RRC_INST *rrc,struct rrc_gNB_ue_context_s *ue_context_p, x2ap_ENDC_sgnb_addition_req_t *m) { // generate nr-Config-r15 containers for LTE RRC : inside message for X2 EN-DC (CG-Config Message from 38.331) rrc_gNB_carrier_data_t *carrier=&rrc->carrier; + const gNB_RrcConfigurationReq *configuration = &rrc->configuration; MessageDef *msg; msg = itti_alloc_new_message(TASK_RRC_ENB, 0, X2AP_ENDC_SGNB_ADDITION_REQ_ACK); gtpv1u_enb_create_tunnel_req_t create_tunnel_req; @@ -240,29 +244,17 @@ void rrc_add_nsa_user(gNB_RRC_INST *rrc,struct rrc_gNB_ue_context_s *ue_context_ cipher_algo, NR_SecurityConfig__keyToUse_secondary); } - if (ue_context_p->ue_context.spCellConfig) { - fill_default_reconfig(carrier->servingcellconfigcommon, - ue_context_p->ue_context.spCellConfig->spCellConfigDedicated, - reconfig_ies, - ue_context_p->ue_context.secondaryCellGroup, - ue_context_p->ue_context.UE_Capability_nr, - carrier->pdsch_AntennaPorts, - carrier->minRXTXTIME, - carrier->do_CSIRS, - carrier->do_SRS, - ue_context_p->local_uid); - } else { - fill_default_reconfig(carrier->servingcellconfigcommon, - NULL, - reconfig_ies, - ue_context_p->ue_context.secondaryCellGroup, - ue_context_p->ue_context.UE_Capability_nr, - carrier->pdsch_AntennaPorts, - carrier->minRXTXTIME, - carrier->do_CSIRS, - carrier->do_SRS, - ue_context_p->local_uid); - } + + NR_ServingCellConfig_t *scc = ue_context_p->ue_context.spCellConfig ? + ue_context_p->ue_context.spCellConfig->spCellConfigDedicated : NULL; + fill_default_reconfig(carrier->servingcellconfigcommon, + scc, + reconfig_ies, + ue_context_p->ue_context.secondaryCellGroup, + ue_context_p->ue_context.UE_Capability_nr, + configuration, + ue_context_p->local_uid); + ue_context_p->ue_id_rnti = ue_context_p->ue_context.secondaryCellGroup->spCellConfig->reconfigurationWithSync->newUE_Identity; NR_CG_Config_t *CG_Config = calloc(1,sizeof(*CG_Config)); memset((void *)CG_Config,0,sizeof(*CG_Config)); @@ -351,31 +343,31 @@ void rrc_add_nsa_user(gNB_RRC_INST *rrc,struct rrc_gNB_ue_context_s *ue_context_ sizeof(X2AP_ENDC_SGNB_ADDITION_REQ_ACK(msg).rrc_buffer)); X2AP_ENDC_SGNB_ADDITION_REQ_ACK(msg).rrc_buffer_size = (enc_rval.encoded+7)>>3; itti_send_msg_to_task(TASK_X2AP, ENB_MODULE_ID_TO_INSTANCE(0), msg); //Check right id instead of hardcoding - } else if (get_softmodem_params()->do_ra || get_softmodem_params()->sa) { - PROTOCOL_CTXT_SET_BY_MODULE_ID(&ctxt, rrc->module_id, GNB_FLAG_YES, ue_context_p->ue_id_rnti, 0, 0,rrc->module_id); } rrc->Nb_ue++; // configure MAC and RLC if (NODE_IS_DU(rrc->node_type)) { rrc_mac_config_req_gNB(rrc->module_id, - rrc->carrier.ssb_SubcarrierOffset, - rrc->carrier.pdsch_AntennaPorts, - rrc->carrier.pusch_AntennaPorts, - rrc->carrier.sib1_tda, - rrc->carrier.minRXTXTIME, + rrc->configuration.ssb_SubcarrierOffset, + rrc->configuration.pdsch_AntennaPorts, + rrc->configuration.pusch_AntennaPorts, + rrc->configuration.sib1_tda, + rrc->configuration.minRXTXTIME, rrc->carrier.servingcellconfigcommon, &rrc->carrier.mib, + NULL, 1, // add_ue flag ue_context_p->ue_id_rnti, ue_context_p->ue_context.secondaryCellGroup); } else { rrc_mac_config_req_gNB(rrc->module_id, - rrc->carrier.ssb_SubcarrierOffset, - rrc->carrier.pdsch_AntennaPorts, - rrc->carrier.pusch_AntennaPorts, - rrc->carrier.sib1_tda, - rrc->carrier.minRXTXTIME, + rrc->configuration.ssb_SubcarrierOffset, + rrc->configuration.pdsch_AntennaPorts, + rrc->configuration.pusch_AntennaPorts, + rrc->configuration.sib1_tda, + rrc->configuration.minRXTXTIME, + NULL, NULL, NULL, 1, // add_ue flag @@ -383,14 +375,15 @@ void rrc_add_nsa_user(gNB_RRC_INST *rrc,struct rrc_gNB_ue_context_s *ue_context_ ue_context_p->ue_context.secondaryCellGroup); } - if(m == NULL){ - LOG_W(RRC, "Calling RRC PDCP/RLC ASN1 request functions for protocol context %p with module_id %d, rnti %x, frame %d, subframe %d eNB_index %d \n", &ctxt, - ctxt.module_id, - ctxt.rnti, - ctxt.frame, - ctxt.subframe, - ctxt.eNB_index); - } + PROTOCOL_CTXT_SET_BY_MODULE_ID(&ctxt, rrc->module_id, GNB_FLAG_YES, ue_context_p->ue_id_rnti, 0, 0, rrc->module_id); + LOG_W(RRC, + "Calling RRC PDCP/RLC ASN1 request functions for protocol context %p with module_id %d, rnti %x, frame %d, subframe %d eNB_index %d \n", + &ctxt, + ctxt.module_id, + ctxt.rnti, + ctxt.frame, + ctxt.subframe, + ctxt.eNB_index); nr_rrc_pdcp_config_asn1_req(&ctxt, get_softmodem_params()->sa ? ue_context_p->ue_context.rb_config->srb_ToAddModList : (NR_SRB_ToAddModList_t *) NULL, @@ -405,15 +398,14 @@ void rrc_add_nsa_user(gNB_RRC_INST *rrc,struct rrc_gNB_ue_context_s *ue_context_ NULL, ue_context_p->ue_context.secondaryCellGroup->rlc_BearerToAddModList); - nr_rrc_rlc_config_asn1_req (&ctxt, - get_softmodem_params()->sa ? ue_context_p->ue_context.rb_config->srb_ToAddModList : (NR_SRB_ToAddModList_t *) NULL, - ue_context_p->ue_context.rb_config->drb_ToAddModList, - ue_context_p->ue_context.rb_config->drb_ToReleaseList, - (LTE_PMCH_InfoList_r9_t *) NULL, - ue_context_p->ue_context.secondaryCellGroup->rlc_BearerToAddModList); + nr_rrc_rlc_config_asn1_req(&ctxt, + get_softmodem_params()->sa ? ue_context_p->ue_context.rb_config->srb_ToAddModList : (NR_SRB_ToAddModList_t *) NULL, + ue_context_p->ue_context.rb_config->drb_ToAddModList, + ue_context_p->ue_context.rb_config->drb_ToReleaseList, + (LTE_PMCH_InfoList_r9_t *) NULL, + ue_context_p->ue_context.secondaryCellGroup->rlc_BearerToAddModList); LOG_D(RRC, "%s:%d: done RRC PDCP/RLC ASN1 request for UE rnti %x\n", __FUNCTION__, __LINE__, ctxt.rnti); - } void rrc_remove_nsa_user(gNB_RRC_INST *rrc, int rnti) { @@ -434,7 +426,8 @@ void rrc_remove_nsa_user(gNB_RRC_INST *rrc, int rnti) { rrc_rlc_remove_ue(&ctxt); - mac_remove_nr_ue(rrc->module_id, rnti); + // WHAT A RACE CONDITION + mac_remove_nr_ue(RC.nrmac[rrc->module_id], rnti); gtpv1u_enb_delete_tunnel_req_t tmp={0}; tmp.rnti=rnti; tmp.from_gnb=1; diff --git a/openair2/RRC/NR/rrc_gNB_reconfig.c b/openair2/RRC/NR/rrc_gNB_reconfig.c index 1de34804df..0118778582 100644 --- a/openair2/RRC/NR/rrc_gNB_reconfig.c +++ b/openair2/RRC/NR/rrc_gNB_reconfig.c @@ -50,18 +50,576 @@ #define false 0 #define true 1 +void fix_servingcellconfigdedicated(NR_ServingCellConfig_t *scd) { + + int b = 0; + while (b < scd->downlinkBWP_ToAddModList->list.count) { + if (scd->downlinkBWP_ToAddModList->list.array[b]->bwp_Common->genericParameters.locationAndBandwidth == 0) { + asn_sequence_del(&scd->downlinkBWP_ToAddModList->list, b, 1); + } else { + b++; + } + } + + if(scd->downlinkBWP_ToAddModList->list.count == 0) { + free(scd->downlinkBWP_ToAddModList); + scd->downlinkBWP_ToAddModList = NULL; + } + + b = 0; + while (b < scd->uplinkConfig->uplinkBWP_ToAddModList->list.count) { + if (scd->uplinkConfig->uplinkBWP_ToAddModList->list.array[b]->bwp_Common->genericParameters.locationAndBandwidth == + 0) { + asn_sequence_del(&scd->uplinkConfig->uplinkBWP_ToAddModList->list, b, 1); + } else { + b++; + } + } + + if(scd->uplinkConfig->uplinkBWP_ToAddModList->list.count == 0) { + free(scd->uplinkConfig->uplinkBWP_ToAddModList); + scd->uplinkConfig->uplinkBWP_ToAddModList = NULL; + } + +} + +void fill_default_nsa_downlinkBWP(NR_BWP_Downlink_t *bwp, + long bwp_loop, + NR_CellGroupConfig_t *secondaryCellGroup, + NR_ServingCellConfig_t *servingcellconfigdedicated, + NR_ServingCellConfigCommon_t *servingcellconfigcommon, + const gNB_RrcConfigurationReq *configuration, + NR_UE_NR_Capability_t *uecap, + int dl_antenna_ports, + uint64_t bitmap) { + + /// BWP common configuration + + bwp->bwp_Common = calloc(1,sizeof(*bwp->bwp_Common)); + + if(servingcellconfigdedicated->downlinkBWP_ToAddModList && + bwp_loop < servingcellconfigdedicated->downlinkBWP_ToAddModList->list.count) { + bwp->bwp_Id = servingcellconfigdedicated->downlinkBWP_ToAddModList->list.array[bwp_loop]->bwp_Id; + bwp->bwp_Common->genericParameters.locationAndBandwidth = servingcellconfigdedicated->downlinkBWP_ToAddModList->list.array[bwp_loop]->bwp_Common->genericParameters.locationAndBandwidth; + bwp->bwp_Common->genericParameters.subcarrierSpacing = servingcellconfigdedicated->downlinkBWP_ToAddModList->list.array[bwp_loop]->bwp_Common->genericParameters.subcarrierSpacing; + bwp->bwp_Common->genericParameters.cyclicPrefix = servingcellconfigdedicated->downlinkBWP_ToAddModList->list.array[bwp_loop]->bwp_Common->genericParameters.cyclicPrefix; + } else { + bwp->bwp_Id=bwp_loop+1; + bwp->bwp_Common->genericParameters.locationAndBandwidth = PRBalloc_to_locationandbandwidth(servingcellconfigcommon->downlinkConfigCommon->frequencyInfoDL->scs_SpecificCarrierList.list.array[0]->carrierBandwidth,0); + bwp->bwp_Common->genericParameters.subcarrierSpacing = servingcellconfigcommon->downlinkConfigCommon->initialDownlinkBWP->genericParameters.subcarrierSpacing; + bwp->bwp_Common->genericParameters.cyclicPrefix = servingcellconfigcommon->downlinkConfigCommon->initialDownlinkBWP->genericParameters.cyclicPrefix; + } + + bwp->bwp_Common->pdcch_ConfigCommon=calloc(1,sizeof(*bwp->bwp_Common->pdcch_ConfigCommon)); + bwp->bwp_Common->pdcch_ConfigCommon->present = NR_SetupRelease_PDCCH_ConfigCommon_PR_setup; + bwp->bwp_Common->pdcch_ConfigCommon->choice.setup = calloc(1,sizeof(*bwp->bwp_Common->pdcch_ConfigCommon->choice.setup)); + bwp->bwp_Common->pdcch_ConfigCommon->choice.setup->controlResourceSetZero=NULL; + bwp->bwp_Common->pdcch_ConfigCommon->choice.setup->commonControlResourceSet=calloc(1,sizeof(*bwp->bwp_Common->pdcch_ConfigCommon->choice.setup->commonControlResourceSet)); + + int curr_bwp = NRRIV2BW(bwp->bwp_Common->genericParameters.locationAndBandwidth,275); + + NR_ControlResourceSet_t *coreset = calloc(1,sizeof(*coreset)); + rrc_coreset_config(coreset, bwp->bwp_Id, curr_bwp, bitmap); + bwp->bwp_Common->pdcch_ConfigCommon->choice.setup->commonControlResourceSet = coreset; + + bwp->bwp_Common->pdcch_ConfigCommon->choice.setup->searchSpaceZero=NULL; + bwp->bwp_Common->pdcch_ConfigCommon->choice.setup->commonSearchSpaceList=NULL; + bwp->bwp_Common->pdcch_ConfigCommon->choice.setup->commonSearchSpaceList=calloc(1,sizeof(*bwp->bwp_Common->pdcch_ConfigCommon->choice.setup->commonSearchSpaceList)); + + NR_SearchSpace_t *ss=calloc(1,sizeof(*ss)); + ss->searchSpaceId = (bwp->bwp_Id<<1)-1; // To uniquely identify each SearchSpace lets derive it from the BWPId + ss->controlResourceSetId=calloc(1,sizeof(*ss->controlResourceSetId)); + *ss->controlResourceSetId=coreset->controlResourceSetId; + ss->monitoringSlotPeriodicityAndOffset = calloc(1,sizeof(*ss->monitoringSlotPeriodicityAndOffset)); + ss->monitoringSlotPeriodicityAndOffset->present = NR_SearchSpace__monitoringSlotPeriodicityAndOffset_PR_sl1; + ss->duration=NULL; + ss->monitoringSymbolsWithinSlot = calloc(1,sizeof(*ss->monitoringSymbolsWithinSlot)); + ss->monitoringSymbolsWithinSlot->buf = calloc(1,2); + // should be '1100 0000 0000 00'B (LSB first!), first two symols in slot, adjust if needed + ss->monitoringSymbolsWithinSlot->buf[1] = 0; + ss->monitoringSymbolsWithinSlot->buf[0] = (1<<7) | (1<<6); + ss->monitoringSymbolsWithinSlot->size = 2; + ss->monitoringSymbolsWithinSlot->bits_unused = 2; + ss->nrofCandidates = calloc(1,sizeof(*ss->nrofCandidates)); + ss->nrofCandidates->aggregationLevel1 = NR_SearchSpace__nrofCandidates__aggregationLevel1_n0; + ss->nrofCandidates->aggregationLevel2 = NR_SearchSpace__nrofCandidates__aggregationLevel2_n0; + ss->nrofCandidates->aggregationLevel4 = NR_SearchSpace__nrofCandidates__aggregationLevel4_n1; + ss->nrofCandidates->aggregationLevel8 = NR_SearchSpace__nrofCandidates__aggregationLevel8_n0; + ss->nrofCandidates->aggregationLevel16 = NR_SearchSpace__nrofCandidates__aggregationLevel16_n0; + ss->searchSpaceType = calloc(1,sizeof(*ss->searchSpaceType)); + ss->searchSpaceType->present = NR_SearchSpace__searchSpaceType_PR_common; + ss->searchSpaceType->choice.common=calloc(1,sizeof(*ss->searchSpaceType->choice.common)); + ss->searchSpaceType->choice.common->dci_Format0_0_AndFormat1_0 = calloc(1,sizeof(*ss->searchSpaceType->choice.common->dci_Format0_0_AndFormat1_0)); + ASN_SEQUENCE_ADD(&bwp->bwp_Common->pdcch_ConfigCommon->choice.setup->commonSearchSpaceList->list,ss); + + bwp->bwp_Common->pdcch_ConfigCommon->choice.setup->searchSpaceSIB1=NULL; + bwp->bwp_Common->pdcch_ConfigCommon->choice.setup->searchSpaceOtherSystemInformation=NULL; + bwp->bwp_Common->pdcch_ConfigCommon->choice.setup->pagingSearchSpace=NULL; + bwp->bwp_Common->pdcch_ConfigCommon->choice.setup->ra_SearchSpace=calloc(1,sizeof(*bwp->bwp_Common->pdcch_ConfigCommon->choice.setup->ra_SearchSpace)); + *bwp->bwp_Common->pdcch_ConfigCommon->choice.setup->ra_SearchSpace=ss->searchSpaceId; + bwp->bwp_Common->pdcch_ConfigCommon->choice.setup->ext1=NULL; + + bwp->bwp_Common->pdsch_ConfigCommon=calloc(1,sizeof(*bwp->bwp_Common->pdsch_ConfigCommon)); + bwp->bwp_Common->pdsch_ConfigCommon->present = NR_SetupRelease_PDSCH_ConfigCommon_PR_setup; + bwp->bwp_Common->pdsch_ConfigCommon->choice.setup = calloc(1,sizeof(*bwp->bwp_Common->pdsch_ConfigCommon->choice.setup)); + bwp->bwp_Common->pdsch_ConfigCommon->choice.setup->pdsch_TimeDomainAllocationList = calloc(1,sizeof(*bwp->bwp_Common->pdsch_ConfigCommon->choice.setup->pdsch_TimeDomainAllocationList)); + + // Prepare PDSCH-TimeDomainResourceAllocation list + nr_rrc_config_dl_tda(servingcellconfigcommon, + bwp->bwp_Common->pdsch_ConfigCommon->choice.setup->pdsch_TimeDomainAllocationList, + curr_bwp); + + /// BWP dedicated configuration + + if (!bwp->bwp_Dedicated) { + bwp->bwp_Dedicated=calloc(1,sizeof(*bwp->bwp_Dedicated)); + } + bwp->bwp_Dedicated->pdcch_Config=calloc(1,sizeof(*bwp->bwp_Dedicated->pdcch_Config)); + bwp->bwp_Dedicated->pdcch_Config->present = NR_SetupRelease_PDCCH_Config_PR_setup; + bwp->bwp_Dedicated->pdcch_Config->choice.setup = calloc(1,sizeof(*bwp->bwp_Dedicated->pdcch_Config->choice.setup)); + bwp->bwp_Dedicated->pdcch_Config->choice.setup->controlResourceSetToAddModList = calloc(1,sizeof(*bwp->bwp_Dedicated->pdcch_Config->choice.setup->controlResourceSetToAddModList)); + + ASN_SEQUENCE_ADD(&bwp->bwp_Dedicated->pdcch_Config->choice.setup->controlResourceSetToAddModList->list, coreset); + + bwp->bwp_Dedicated->pdcch_Config->choice.setup->searchSpacesToAddModList = calloc(1,sizeof(*bwp->bwp_Dedicated->pdcch_Config->choice.setup->searchSpacesToAddModList)); + + NR_SearchSpace_t *ss2 = calloc(1,sizeof(*ss2)); + ss2->searchSpaceId=(bwp->bwp_Id<<1); // To uniquely identify each SearchSpace lets derive it from the BWPId + ss2->controlResourceSetId=calloc(1,sizeof(*ss2->controlResourceSetId)); + *ss2->controlResourceSetId=coreset->controlResourceSetId; + ss2->monitoringSlotPeriodicityAndOffset=calloc(1,sizeof(*ss2->monitoringSlotPeriodicityAndOffset)); + ss2->monitoringSlotPeriodicityAndOffset->present = NR_SearchSpace__monitoringSlotPeriodicityAndOffset_PR_sl1; + ss2->monitoringSlotPeriodicityAndOffset->choice.sl1=(NULL_t)0; + ss2->duration=NULL; + ss2->monitoringSymbolsWithinSlot = calloc(1,sizeof(*ss2->monitoringSymbolsWithinSlot)); + ss2->monitoringSymbolsWithinSlot->buf = calloc(1,2); + ss2->monitoringSymbolsWithinSlot->size = 2; + ss2->monitoringSymbolsWithinSlot->bits_unused = 2; + ss2->monitoringSymbolsWithinSlot->buf[0]=0xc0; + ss2->monitoringSymbolsWithinSlot->buf[1]=0x0; + ss2->nrofCandidates=calloc(1,sizeof(*ss2->nrofCandidates)); + ss2->nrofCandidates->aggregationLevel1 = NR_SearchSpace__nrofCandidates__aggregationLevel1_n0; + ss2->nrofCandidates->aggregationLevel2 = NR_SearchSpace__nrofCandidates__aggregationLevel2_n0; + if (curr_bwp < 48) + ss2->nrofCandidates->aggregationLevel4 = NR_SearchSpace__nrofCandidates__aggregationLevel4_n1; + else if (curr_bwp < 96) + ss2->nrofCandidates->aggregationLevel4 = NR_SearchSpace__nrofCandidates__aggregationLevel4_n2; + else + ss2->nrofCandidates->aggregationLevel4 = NR_SearchSpace__nrofCandidates__aggregationLevel4_n4; + ss2->nrofCandidates->aggregationLevel8 = NR_SearchSpace__nrofCandidates__aggregationLevel8_n0; + ss2->nrofCandidates->aggregationLevel16 = NR_SearchSpace__nrofCandidates__aggregationLevel16_n0; + ss2->searchSpaceType=calloc(1,sizeof(*ss2->searchSpaceType)); + ss2->searchSpaceType->present = NR_SearchSpace__searchSpaceType_PR_ue_Specific; + ss2->searchSpaceType->choice.ue_Specific = calloc(1,sizeof(*ss2->searchSpaceType->choice.ue_Specific)); + ss2->searchSpaceType->choice.ue_Specific->dci_Formats=NR_SearchSpace__searchSpaceType__ue_Specific__dci_Formats_formats0_1_And_1_1; + ASN_SEQUENCE_ADD(&bwp->bwp_Dedicated->pdcch_Config->choice.setup->searchSpacesToAddModList->list, ss2); + + bwp->bwp_Dedicated->pdcch_Config->choice.setup->searchSpacesToReleaseList = NULL; + + if (!bwp->bwp_Dedicated->pdsch_Config) { + bwp->bwp_Dedicated->pdsch_Config = calloc(1,sizeof(*bwp->bwp_Dedicated->pdsch_Config)); + bwp->bwp_Dedicated->pdsch_Config->present = NR_SetupRelease_PDSCH_Config_PR_setup; + bwp->bwp_Dedicated->pdsch_Config->choice.setup = calloc(1,sizeof(*bwp->bwp_Dedicated->pdsch_Config->choice.setup)); + bwp->bwp_Dedicated->pdsch_Config->choice.setup->dmrs_DownlinkForPDSCH_MappingTypeA = calloc(1,sizeof(*bwp->bwp_Dedicated->pdsch_Config->choice.setup->dmrs_DownlinkForPDSCH_MappingTypeA)); + bwp->bwp_Dedicated->pdsch_Config->choice.setup->dmrs_DownlinkForPDSCH_MappingTypeA->present= NR_SetupRelease_DMRS_DownlinkConfig_PR_setup; + bwp->bwp_Dedicated->pdsch_Config->choice.setup->dmrs_DownlinkForPDSCH_MappingTypeA->choice.setup = calloc(1,sizeof(*bwp->bwp_Dedicated->pdsch_Config->choice.setup->dmrs_DownlinkForPDSCH_MappingTypeA->choice.setup)); + } + bwp->bwp_Dedicated->pdsch_Config->choice.setup->dataScramblingIdentityPDSCH = NULL; + + if ((get_softmodem_params()->do_ra || get_softmodem_params()->phy_test) && dl_antenna_ports > 1) // for MIMO, we use DMRS Config Type 2 but only with OAI UE + bwp->bwp_Dedicated->pdsch_Config->choice.setup->dmrs_DownlinkForPDSCH_MappingTypeA->choice.setup->dmrs_Type=calloc(1,sizeof(*bwp->bwp_Dedicated->pdsch_Config->choice.setup->dmrs_DownlinkForPDSCH_MappingTypeA->choice.setup->dmrs_Type)); + else + bwp->bwp_Dedicated->pdsch_Config->choice.setup->dmrs_DownlinkForPDSCH_MappingTypeA->choice.setup->dmrs_Type=NULL; + bwp->bwp_Dedicated->pdsch_Config->choice.setup->dmrs_DownlinkForPDSCH_MappingTypeA->choice.setup->maxLength=NULL; + bwp->bwp_Dedicated->pdsch_Config->choice.setup->dmrs_DownlinkForPDSCH_MappingTypeA->choice.setup->scramblingID0=NULL; + bwp->bwp_Dedicated->pdsch_Config->choice.setup->dmrs_DownlinkForPDSCH_MappingTypeA->choice.setup->scramblingID1=NULL; + if (!bwp->bwp_Dedicated->pdsch_Config) { + bwp->bwp_Dedicated->pdsch_Config->choice.setup->dmrs_DownlinkForPDSCH_MappingTypeA->choice.setup->phaseTrackingRS=NULL; + } + bwp->bwp_Dedicated->pdsch_Config->choice.setup->dmrs_DownlinkForPDSCH_MappingTypeA->choice.setup->dmrs_AdditionalPosition = calloc(1,sizeof(*bwp->bwp_Dedicated->pdsch_Config->choice.setup->dmrs_DownlinkForPDSCH_MappingTypeA->choice.setup->dmrs_AdditionalPosition)); + *bwp->bwp_Dedicated->pdsch_Config->choice.setup->dmrs_DownlinkForPDSCH_MappingTypeA->choice.setup->dmrs_AdditionalPosition = NR_DMRS_DownlinkConfig__dmrs_AdditionalPosition_pos1; + + bwp->bwp_Dedicated->pdsch_Config->choice.setup->tci_StatesToAddModList=calloc(1,sizeof(*bwp->bwp_Dedicated->pdsch_Config->choice.setup->tci_StatesToAddModList)); + + int n_ssb = 0; + NR_TCI_State_t *tcid[64]; + for (int i=0;i<64;i++) { + if ((bitmap>>(63-i))&0x01){ + tcid[i]=calloc(1,sizeof(*tcid[i])); + tcid[i]->tci_StateId=n_ssb; + tcid[i]->qcl_Type1.cell=NULL; + tcid[i]->qcl_Type1.bwp_Id=calloc(1,sizeof(*tcid[i]->qcl_Type1.bwp_Id)); + *tcid[i]->qcl_Type1.bwp_Id=1; + tcid[i]->qcl_Type1.referenceSignal.present = NR_QCL_Info__referenceSignal_PR_ssb; + tcid[i]->qcl_Type1.referenceSignal.choice.ssb = i; + tcid[i]->qcl_Type1.qcl_Type=NR_QCL_Info__qcl_Type_typeC; + ASN_SEQUENCE_ADD(&bwp->bwp_Dedicated->pdsch_Config->choice.setup->tci_StatesToAddModList->list,tcid[i]); + n_ssb++; + } + } + + bwp->bwp_Dedicated->pdsch_Config->choice.setup->tci_StatesToReleaseList=NULL; + bwp->bwp_Dedicated->pdsch_Config->choice.setup->vrb_ToPRB_Interleaver=NULL; + bwp->bwp_Dedicated->pdsch_Config->choice.setup->resourceAllocation=NR_PDSCH_Config__resourceAllocation_resourceAllocationType1; + bwp->bwp_Dedicated->pdsch_Config->choice.setup->pdsch_TimeDomainAllocationList=NULL; + bwp->bwp_Dedicated->pdsch_Config->choice.setup->pdsch_AggregationFactor=NULL; + bwp->bwp_Dedicated->pdsch_Config->choice.setup->rateMatchPatternToAddModList=NULL; + bwp->bwp_Dedicated->pdsch_Config->choice.setup->rateMatchPatternToReleaseList=NULL; + bwp->bwp_Dedicated->pdsch_Config->choice.setup->rateMatchPatternGroup1=NULL; + bwp->bwp_Dedicated->pdsch_Config->choice.setup->rateMatchPatternGroup2=NULL; + bwp->bwp_Dedicated->pdsch_Config->choice.setup->rbg_Size=NR_PDSCH_Config__rbg_Size_config1; + set_dl_mcs_table(bwp->bwp_Common->genericParameters.subcarrierSpacing, + configuration->force_256qam_off ? NULL : uecap, + secondaryCellGroup->spCellConfig, + bwp->bwp_Dedicated, + servingcellconfigcommon); + bwp->bwp_Dedicated->pdsch_Config->choice.setup->maxNrofCodeWordsScheduledByDCI = calloc(1,sizeof(*bwp->bwp_Dedicated->pdsch_Config->choice.setup->maxNrofCodeWordsScheduledByDCI)); + *bwp->bwp_Dedicated->pdsch_Config->choice.setup->maxNrofCodeWordsScheduledByDCI = NR_PDSCH_Config__maxNrofCodeWordsScheduledByDCI_n1; + bwp->bwp_Dedicated->pdsch_Config->choice.setup->prb_BundlingType.present = NR_PDSCH_Config__prb_BundlingType_PR_staticBundling; + bwp->bwp_Dedicated->pdsch_Config->choice.setup->prb_BundlingType.choice.staticBundling = calloc(1,sizeof(*bwp->bwp_Dedicated->pdsch_Config->choice.setup->prb_BundlingType.choice.staticBundling)); + bwp->bwp_Dedicated->pdsch_Config->choice.setup->prb_BundlingType.choice.staticBundling->bundleSize = + calloc(1,sizeof(*bwp->bwp_Dedicated->pdsch_Config->choice.setup->prb_BundlingType.choice.staticBundling->bundleSize)); + *bwp->bwp_Dedicated->pdsch_Config->choice.setup->prb_BundlingType.choice.staticBundling->bundleSize = NR_PDSCH_Config__prb_BundlingType__staticBundling__bundleSize_wideband; + bwp->bwp_Dedicated->pdsch_Config->choice.setup->zp_CSI_RS_ResourceToAddModList=NULL; + bwp->bwp_Dedicated->pdsch_Config->choice.setup->zp_CSI_RS_ResourceToReleaseList=NULL; + bwp->bwp_Dedicated->pdsch_Config->choice.setup->aperiodic_ZP_CSI_RS_ResourceSetsToAddModList=NULL; + bwp->bwp_Dedicated->pdsch_Config->choice.setup->aperiodic_ZP_CSI_RS_ResourceSetsToReleaseList=NULL; + bwp->bwp_Dedicated->pdsch_Config->choice.setup->sp_ZP_CSI_RS_ResourceSetsToAddModList=NULL; + bwp->bwp_Dedicated->pdsch_Config->choice.setup->sp_ZP_CSI_RS_ResourceSetsToReleaseList=NULL; + bwp->bwp_Dedicated->pdsch_Config->choice.setup->p_ZP_CSI_RS_ResourceSet=NULL; + bwp->bwp_Dedicated->sps_Config = NULL; + bwp->bwp_Dedicated->radioLinkMonitoringConfig = NULL; + +#if 0 + bwp->bwp_Dedicated->radioLinkMonitoringConfig = calloc(1,sizeof(*bwp->bwp_Dedicated->radioLinkMonitoringConfig)); + bwp->bwp_Dedicated->radioLinkMonitoringConfig->present = NR_SetupRelease_RadioLinkMonitoringConfig_PR_setup; + bwp->bwp_Dedicated->radioLinkMonitoringConfig->choice.setup = calloc(1,sizeof(*bwp->bwp_Dedicated->radioLinkMonitoringConfig->choice.setup)); + bwp->bwp_Dedicated->radioLinkMonitoringConfig->choice.setup->failureDetectionResourcesToAddModList=NULL; + bwp->bwp_Dedicated->radioLinkMonitoringConfig->choice.setup->failureDetectionResourcesToReleaseList=NULL; + bwp->bwp_Dedicated->radioLinkMonitoringConfig->choice.setup->beamFailureInstanceMaxCount = calloc(1,sizeof(*bwp->bwp_Dedicated->radioLinkMonitoringConfig->choice.setup->beamFailureInstanceMaxCount)); + *bwp->bwp_Dedicated->radioLinkMonitoringConfig->choice.setup->beamFailureInstanceMaxCount = NR_RadioLinkMonitoringConfig__beamFailureInstanceMaxCount_n3; + bwp->bwp_Dedicated->radioLinkMonitoringConfig->choice.setup->beamFailureDetectionTimer = calloc(1,sizeof(*bwp->bwp_Dedicated->radioLinkMonitoringConfig->choice.setup->beamFailureDetectionTimer)); + *bwp->bwp_Dedicated->radioLinkMonitoringConfig->choice.setup->beamFailureDetectionTimer = NR_RadioLinkMonitoringConfig__beamFailureDetectionTimer_pbfd2; +#endif + +} + +void fill_default_nsa_uplinkBWP(NR_BWP_Uplink_t *ubwp, + long bwp_loop, + NR_ServingCellConfig_t *servingcellconfigdedicated, + NR_ServingCellConfigCommon_t *servingcellconfigcommon, + const gNB_RrcConfigurationReq *configuration, + int uid) { + + /// BWP common configuration + + ubwp->bwp_Common = calloc(1,sizeof(*ubwp->bwp_Common)); + + if(servingcellconfigdedicated->uplinkConfig->uplinkBWP_ToAddModList && + bwp_loop < servingcellconfigdedicated->uplinkConfig->uplinkBWP_ToAddModList->list.count) { + ubwp->bwp_Id = servingcellconfigdedicated->uplinkConfig->uplinkBWP_ToAddModList->list.array[bwp_loop]->bwp_Id; + ubwp->bwp_Common->genericParameters.locationAndBandwidth = servingcellconfigdedicated->uplinkConfig->uplinkBWP_ToAddModList->list.array[bwp_loop]->bwp_Common->genericParameters.locationAndBandwidth; + ubwp->bwp_Common->genericParameters.subcarrierSpacing = servingcellconfigdedicated->uplinkConfig->uplinkBWP_ToAddModList->list.array[bwp_loop]->bwp_Common->genericParameters.subcarrierSpacing; + ubwp->bwp_Common->genericParameters.cyclicPrefix = servingcellconfigdedicated->uplinkConfig->uplinkBWP_ToAddModList->list.array[bwp_loop]->bwp_Common->genericParameters.cyclicPrefix; + } else { + ubwp->bwp_Id=bwp_loop+1; + ubwp->bwp_Common->genericParameters.locationAndBandwidth = PRBalloc_to_locationandbandwidth(servingcellconfigcommon->uplinkConfigCommon->frequencyInfoUL->scs_SpecificCarrierList.list.array[0]->carrierBandwidth,0); + ubwp->bwp_Common->genericParameters.subcarrierSpacing = servingcellconfigcommon->uplinkConfigCommon->initialUplinkBWP->genericParameters.subcarrierSpacing; + ubwp->bwp_Common->genericParameters.cyclicPrefix = servingcellconfigcommon->uplinkConfigCommon->initialUplinkBWP->genericParameters.cyclicPrefix; + } + + ubwp->bwp_Common->rach_ConfigCommon = servingcellconfigcommon->uplinkConfigCommon->initialUplinkBWP->rach_ConfigCommon; + ubwp->bwp_Common->pusch_ConfigCommon = servingcellconfigcommon->uplinkConfigCommon->initialUplinkBWP->pusch_ConfigCommon; + ubwp->bwp_Common->pucch_ConfigCommon = servingcellconfigcommon->uplinkConfigCommon->initialUplinkBWP->pucch_ConfigCommon; + + /// BWP dedicated configuration + + if (!ubwp->bwp_Dedicated) { + ubwp->bwp_Dedicated = calloc(1,sizeof(*ubwp->bwp_Dedicated)); + } + ubwp->bwp_Dedicated->pucch_Config = calloc(1,sizeof(*ubwp->bwp_Dedicated->pucch_Config)); + ubwp->bwp_Dedicated->pucch_Config->present = NR_SetupRelease_PUCCH_Config_PR_setup; + NR_PUCCH_Config_t *pucch_Config = calloc(1,sizeof(*pucch_Config)); + ubwp->bwp_Dedicated->pucch_Config->choice.setup=pucch_Config; + pucch_Config->resourceSetToAddModList = calloc(1,sizeof(*pucch_Config->resourceSetToAddModList)); + pucch_Config->resourceSetToReleaseList = NULL; + NR_PUCCH_ResourceSet_t *pucchresset0=calloc(1,sizeof(*pucchresset0)); + NR_PUCCH_ResourceSet_t *pucchresset1=calloc(1,sizeof(*pucchresset1)); + pucchresset0->pucch_ResourceSetId = 0; + NR_PUCCH_ResourceId_t *pucchresset0id0=calloc(1,sizeof(*pucchresset0id0)); + *pucchresset0id0=1; + ASN_SEQUENCE_ADD(&pucchresset0->resourceList.list,pucchresset0id0); + pucchresset0->maxPayloadSize=NULL; + ASN_SEQUENCE_ADD(&pucch_Config->resourceSetToAddModList->list,pucchresset0); + + pucchresset1->pucch_ResourceSetId = 1; + NR_PUCCH_ResourceId_t *pucchresset1id0=calloc(1,sizeof(*pucchresset1id0)); + *pucchresset1id0=2; + ASN_SEQUENCE_ADD(&pucchresset1->resourceList.list,pucchresset1id0); + pucchresset1->maxPayloadSize=NULL; + ASN_SEQUENCE_ADD(&pucch_Config->resourceSetToAddModList->list,pucchresset1); + + pucch_Config->resourceToAddModList = calloc(1,sizeof(*pucch_Config->resourceToAddModList)); + pucch_Config->resourceToReleaseList = NULL; + NR_PUCCH_Resource_t *pucchres0=calloc(1,sizeof(*pucchres0)); + NR_PUCCH_Resource_t *pucchres2=calloc(1,sizeof(*pucchres2)); + + int curr_bwp = NRRIV2BW(ubwp->bwp_Common->genericParameters.locationAndBandwidth,275); + + pucchres0->pucch_ResourceId=1; + pucchres0->startingPRB= (8 + uid) % curr_bwp; + pucchres0->intraSlotFrequencyHopping=NULL; + pucchres0->secondHopPRB=NULL; + pucchres0->format.present= NR_PUCCH_Resource__format_PR_format0; + pucchres0->format.choice.format0=calloc(1,sizeof(*pucchres0->format.choice.format0)); + pucchres0->format.choice.format0->initialCyclicShift=0; + pucchres0->format.choice.format0->nrofSymbols=1; + pucchres0->format.choice.format0->startingSymbolIndex=13; + ASN_SEQUENCE_ADD(&pucch_Config->resourceToAddModList->list,pucchres0); + + pucchres2->pucch_ResourceId=2; + pucchres2->startingPRB=0; + pucchres2->intraSlotFrequencyHopping=NULL; + pucchres2->secondHopPRB=NULL; + pucchres2->format.present= NR_PUCCH_Resource__format_PR_format2; + pucchres2->format.choice.format2=calloc(1,sizeof(*pucchres2->format.choice.format2)); + pucchres2->format.choice.format2->nrofPRBs=8; + pucchres2->format.choice.format2->nrofSymbols=1; + pucchres2->format.choice.format2->startingSymbolIndex=13; + ASN_SEQUENCE_ADD(&pucch_Config->resourceToAddModList->list,pucchres2); + + pucch_Config->format2=calloc(1,sizeof(*pucch_Config->format2)); + pucch_Config->format2->present=NR_SetupRelease_PUCCH_FormatConfig_PR_setup; + NR_PUCCH_FormatConfig_t *pucchfmt2 = calloc(1,sizeof(*pucchfmt2)); + pucch_Config->format2->choice.setup = pucchfmt2; + pucchfmt2->interslotFrequencyHopping=NULL; + pucchfmt2->additionalDMRS=NULL; + pucchfmt2->maxCodeRate=calloc(1,sizeof(*pucchfmt2->maxCodeRate)); + *pucchfmt2->maxCodeRate=NR_PUCCH_MaxCodeRate_zeroDot35; + pucchfmt2->nrofSlots=NULL; + pucchfmt2->pi2BPSK=NULL; + pucchfmt2->simultaneousHARQ_ACK_CSI=calloc(1,sizeof(*pucchfmt2->simultaneousHARQ_ACK_CSI)); + *pucchfmt2->simultaneousHARQ_ACK_CSI=NR_PUCCH_FormatConfig__simultaneousHARQ_ACK_CSI_true; + + // for scheduling requestresource + pucch_Config->schedulingRequestResourceToAddModList = calloc(1,sizeof(*pucch_Config->schedulingRequestResourceToAddModList)); + NR_SchedulingRequestResourceConfig_t *schedulingRequestResourceConfig = calloc(1,sizeof(*schedulingRequestResourceConfig)); + schedulingRequestResourceConfig->schedulingRequestResourceId = 1; + schedulingRequestResourceConfig->schedulingRequestID = 0; + schedulingRequestResourceConfig->periodicityAndOffset = calloc(1,sizeof(*schedulingRequestResourceConfig->periodicityAndOffset)); + schedulingRequestResourceConfig->periodicityAndOffset->present = NR_SchedulingRequestResourceConfig__periodicityAndOffset_PR_sl10; + schedulingRequestResourceConfig->periodicityAndOffset->choice.sl10 = 7; + schedulingRequestResourceConfig->resource = calloc(1,sizeof(*schedulingRequestResourceConfig->resource)); + *schedulingRequestResourceConfig->resource = 1; + ASN_SEQUENCE_ADD(&pucch_Config->schedulingRequestResourceToAddModList->list,schedulingRequestResourceConfig); + + pucch_Config->schedulingRequestResourceToReleaseList=NULL; + pucch_Config->multi_CSI_PUCCH_ResourceList=NULL; + pucch_Config->dl_DataToUL_ACK = calloc(1,sizeof(*pucch_Config->dl_DataToUL_ACK)); + long *delay[8]; + for (int i=0;i<8;i++) { + delay[i] = calloc(1,sizeof(*delay[i])); + *delay[i] = i + configuration->minRXTXTIME; + ASN_SEQUENCE_ADD(&pucch_Config->dl_DataToUL_ACK->list,delay[i]); + } + pucch_Config->spatialRelationInfoToAddModList = calloc(1,sizeof(*pucch_Config->spatialRelationInfoToAddModList)); + NR_PUCCH_SpatialRelationInfo_t *pucchspatial = calloc(1,sizeof(*pucchspatial)); + pucchspatial->pucch_SpatialRelationInfoId = 1; + pucchspatial->servingCellId = NULL; + if(configuration->do_CSIRS) { + pucchspatial->referenceSignal.present = NR_PUCCH_SpatialRelationInfo__referenceSignal_PR_csi_RS_Index; + pucchspatial->referenceSignal.choice.csi_RS_Index = 0; + } + else { + pucchspatial->referenceSignal.present = NR_PUCCH_SpatialRelationInfo__referenceSignal_PR_ssb_Index; + pucchspatial->referenceSignal.choice.ssb_Index = 0; + } + pucchspatial->pucch_PathlossReferenceRS_Id = 0; + pucchspatial->p0_PUCCH_Id = 1; + pucchspatial->closedLoopIndex = NR_PUCCH_SpatialRelationInfo__closedLoopIndex_i0; + ASN_SEQUENCE_ADD(&pucch_Config->spatialRelationInfoToAddModList->list,pucchspatial); + pucch_Config->spatialRelationInfoToReleaseList=NULL; + pucch_Config->pucch_PowerControl=calloc(1,sizeof(*pucch_Config->pucch_PowerControl)); + pucch_Config->pucch_PowerControl->deltaF_PUCCH_f0 = calloc(1,sizeof(*pucch_Config->pucch_PowerControl->deltaF_PUCCH_f0)); + *pucch_Config->pucch_PowerControl->deltaF_PUCCH_f0 = 0; + pucch_Config->pucch_PowerControl->deltaF_PUCCH_f1 = calloc(1,sizeof(*pucch_Config->pucch_PowerControl->deltaF_PUCCH_f1)); + *pucch_Config->pucch_PowerControl->deltaF_PUCCH_f1 = 0; + pucch_Config->pucch_PowerControl->deltaF_PUCCH_f2 = calloc(1,sizeof(*pucch_Config->pucch_PowerControl->deltaF_PUCCH_f2)); + *pucch_Config->pucch_PowerControl->deltaF_PUCCH_f2 = 0; + pucch_Config->pucch_PowerControl->deltaF_PUCCH_f3 = calloc(1,sizeof(*pucch_Config->pucch_PowerControl->deltaF_PUCCH_f3)); + *pucch_Config->pucch_PowerControl->deltaF_PUCCH_f3 = 0; + pucch_Config->pucch_PowerControl->deltaF_PUCCH_f4 = calloc(1,sizeof(*pucch_Config->pucch_PowerControl->deltaF_PUCCH_f4)); + *pucch_Config->pucch_PowerControl->deltaF_PUCCH_f4 = 0; + pucch_Config->pucch_PowerControl->p0_Set = calloc(1,sizeof(*pucch_Config->pucch_PowerControl->p0_Set)); + NR_P0_PUCCH_t *p00 = calloc(1,sizeof(*p00)); + p00->p0_PUCCH_Id=1; + p00->p0_PUCCH_Value = 0; + ASN_SEQUENCE_ADD(&pucch_Config->pucch_PowerControl->p0_Set->list,p00); + pucch_Config->pucch_PowerControl->pathlossReferenceRSs = NULL; + + ubwp->bwp_Dedicated->pusch_Config = calloc(1,sizeof(*ubwp->bwp_Dedicated->pusch_Config)); + ubwp->bwp_Dedicated->pusch_Config->present = NR_SetupRelease_PUSCH_Config_PR_setup; + NR_PUSCH_Config_t *pusch_Config = NULL; + if(servingcellconfigdedicated->uplinkConfig->uplinkBWP_ToAddModList && + bwp_loop < servingcellconfigdedicated->uplinkConfig->uplinkBWP_ToAddModList->list.count) { + pusch_Config = servingcellconfigdedicated->uplinkConfig->uplinkBWP_ToAddModList->list.array[bwp_loop]->bwp_Dedicated->pusch_Config->choice.setup; + } else { + pusch_Config = calloc(1,sizeof(*pusch_Config)); + } + ubwp->bwp_Dedicated->pusch_Config->choice.setup = pusch_Config; + pusch_Config->txConfig=calloc(1,sizeof(*pusch_Config->txConfig)); + *pusch_Config->txConfig= NR_PUSCH_Config__txConfig_codebook; + pusch_Config->dmrs_UplinkForPUSCH_MappingTypeA = NULL; + if (!pusch_Config->dmrs_UplinkForPUSCH_MappingTypeB) { + pusch_Config->dmrs_UplinkForPUSCH_MappingTypeB = calloc(1,sizeof(*pusch_Config->dmrs_UplinkForPUSCH_MappingTypeB)); + pusch_Config->dmrs_UplinkForPUSCH_MappingTypeB->present = NR_SetupRelease_DMRS_UplinkConfig_PR_setup; + pusch_Config->dmrs_UplinkForPUSCH_MappingTypeB->choice.setup = calloc(1,sizeof(*pusch_Config->dmrs_UplinkForPUSCH_MappingTypeB->choice.setup)); + } + NR_DMRS_UplinkConfig_t *NR_DMRS_UplinkConfig = pusch_Config->dmrs_UplinkForPUSCH_MappingTypeB->choice.setup; + NR_DMRS_UplinkConfig->dmrs_Type = NULL; + NR_DMRS_UplinkConfig->dmrs_AdditionalPosition = calloc(1,sizeof(*NR_DMRS_UplinkConfig->dmrs_AdditionalPosition)); + *NR_DMRS_UplinkConfig->dmrs_AdditionalPosition = NR_DMRS_UplinkConfig__dmrs_AdditionalPosition_pos0; + if (!servingcellconfigdedicated) { + NR_DMRS_UplinkConfig->phaseTrackingRS=NULL; + } + NR_DMRS_UplinkConfig->maxLength=NULL; + NR_DMRS_UplinkConfig->transformPrecodingDisabled = calloc(1,sizeof(*NR_DMRS_UplinkConfig->transformPrecodingDisabled)); + NR_DMRS_UplinkConfig->transformPrecodingDisabled->scramblingID0 = NULL; + NR_DMRS_UplinkConfig->transformPrecodingDisabled->scramblingID1 = NULL; + NR_DMRS_UplinkConfig->transformPrecodingEnabled = NULL; + pusch_Config->pusch_PowerControl = calloc(1,sizeof(*pusch_Config->pusch_PowerControl)); + pusch_Config->pusch_PowerControl->tpc_Accumulation = NULL; + pusch_Config->pusch_PowerControl->msg3_Alpha = calloc(1,sizeof(*pusch_Config->pusch_PowerControl->msg3_Alpha)); + *pusch_Config->pusch_PowerControl->msg3_Alpha = NR_Alpha_alpha1; + pusch_Config->pusch_PowerControl->p0_NominalWithoutGrant = NULL; + pusch_Config->pusch_PowerControl->p0_AlphaSets = calloc(1,sizeof(*pusch_Config->pusch_PowerControl->p0_AlphaSets)); + NR_P0_PUSCH_AlphaSet_t *aset = calloc(1,sizeof(*aset)); + aset->p0_PUSCH_AlphaSetId=0; + aset->p0=calloc(1,sizeof(*aset->p0)); + *aset->p0 = 0; + aset->alpha=calloc(1,sizeof(*aset->alpha)); + *aset->alpha=NR_Alpha_alpha1; + ASN_SEQUENCE_ADD(&pusch_Config->pusch_PowerControl->p0_AlphaSets->list,aset); + pusch_Config->pusch_PowerControl->pathlossReferenceRSToAddModList = NULL; + pusch_Config->pusch_PowerControl->pathlossReferenceRSToReleaseList = NULL; + pusch_Config->pusch_PowerControl->twoPUSCH_PC_AdjustmentStates = NULL; + pusch_Config->pusch_PowerControl->deltaMCS = NULL; + pusch_Config->pusch_PowerControl->sri_PUSCH_MappingToAddModList = NULL; + pusch_Config->pusch_PowerControl->sri_PUSCH_MappingToReleaseList = NULL; + pusch_Config->frequencyHopping=NULL; + pusch_Config->frequencyHoppingOffsetLists=NULL; + pusch_Config->resourceAllocation = NR_PUSCH_Config__resourceAllocation_resourceAllocationType1; + pusch_Config->pusch_TimeDomainAllocationList = NULL; + pusch_Config->pusch_AggregationFactor=NULL; + pusch_Config->mcs_Table=NULL; + pusch_Config->transformPrecoder= NULL; + pusch_Config->mcs_TableTransformPrecoder=NULL; + /* if msg3_transformprecoding is set in conf file - pusch config should not disable it */ + if (servingcellconfigcommon->uplinkConfigCommon->initialUplinkBWP->rach_ConfigCommon->choice.setup->msg3_transformPrecoder == NULL) { + pusch_Config->transformPrecoder=calloc(1,sizeof(*pusch_Config->transformPrecoder)); + *pusch_Config->transformPrecoder = NR_PUSCH_Config__transformPrecoder_disabled; + } + pusch_Config->codebookSubset=calloc(1,sizeof(*pusch_Config->codebookSubset)); + *pusch_Config->codebookSubset = NR_PUSCH_Config__codebookSubset_nonCoherent; + pusch_Config->maxRank=calloc(1,sizeof(*pusch_Config->maxRank)); + *pusch_Config->maxRank= 1; + pusch_Config->rbg_Size=NULL; + pusch_Config->uci_OnPUSCH=NULL; + pusch_Config->tp_pi2BPSK=NULL; + + ubwp->bwp_Dedicated->srs_Config = calloc(1,sizeof(*ubwp->bwp_Dedicated->srs_Config)); + ubwp->bwp_Dedicated->srs_Config->present = NR_SetupRelease_SRS_Config_PR_setup; + NR_SRS_Config_t *srs_Config = calloc(1,sizeof(*srs_Config)); + ubwp->bwp_Dedicated->srs_Config->choice.setup = srs_Config; + srs_Config->srs_ResourceSetToReleaseList=NULL; + srs_Config->srs_ResourceSetToAddModList=calloc(1,sizeof(*srs_Config->srs_ResourceSetToAddModList)); + NR_SRS_ResourceSet_t *srs_resset0=calloc(1,sizeof(*srs_resset0)); + srs_resset0->srs_ResourceSetId = 0; + srs_resset0->srs_ResourceIdList=calloc(1,sizeof(*srs_resset0->srs_ResourceIdList)); + NR_SRS_ResourceId_t *srs_resset0_id=calloc(1,sizeof(*srs_resset0_id)); + *srs_resset0_id=0; + ASN_SEQUENCE_ADD(&srs_resset0->srs_ResourceIdList->list,srs_resset0_id); + srs_Config->srs_ResourceToReleaseList=NULL; + + if(configuration->do_SRS) { + srs_resset0->resourceType.present = NR_SRS_ResourceSet__resourceType_PR_periodic; + srs_resset0->resourceType.choice.periodic = calloc(1,sizeof(*srs_resset0->resourceType.choice.periodic)); + srs_resset0->resourceType.choice.periodic->associatedCSI_RS = NULL; + } else { + srs_resset0->resourceType.present = NR_SRS_ResourceSet__resourceType_PR_aperiodic; + srs_resset0->resourceType.choice.aperiodic = calloc(1,sizeof(*srs_resset0->resourceType.choice.aperiodic)); + srs_resset0->resourceType.choice.aperiodic->aperiodicSRS_ResourceTrigger=1; + srs_resset0->resourceType.choice.aperiodic->csi_RS=NULL; + srs_resset0->resourceType.choice.aperiodic->slotOffset= calloc(1,sizeof(*srs_resset0->resourceType.choice.aperiodic->slotOffset)); + *srs_resset0->resourceType.choice.aperiodic->slotOffset=2; + srs_resset0->resourceType.choice.aperiodic->ext1=NULL; + } + + srs_resset0->usage=NR_SRS_ResourceSet__usage_codebook; + srs_resset0->alpha = calloc(1,sizeof(*srs_resset0->alpha)); + *srs_resset0->alpha = NR_Alpha_alpha1; + srs_resset0->p0=calloc(1,sizeof(*srs_resset0->p0)); + *srs_resset0->p0=-80; + srs_resset0->pathlossReferenceRS=NULL; + srs_resset0->srs_PowerControlAdjustmentStates=NULL; + ASN_SEQUENCE_ADD(&srs_Config->srs_ResourceSetToAddModList->list,srs_resset0); + srs_Config->srs_ResourceToReleaseList=NULL; + srs_Config->srs_ResourceToAddModList=calloc(1,sizeof(*srs_Config->srs_ResourceToAddModList)); + NR_SRS_Resource_t *srs_res0=calloc(1,sizeof(*srs_res0)); + srs_res0->srs_ResourceId=0; + srs_res0->nrofSRS_Ports=NR_SRS_Resource__nrofSRS_Ports_port1; + srs_res0->ptrs_PortIndex=NULL; + srs_res0->transmissionComb.present=NR_SRS_Resource__transmissionComb_PR_n2; + srs_res0->transmissionComb.choice.n2=calloc(1,sizeof(*srs_res0->transmissionComb.choice.n2)); + srs_res0->transmissionComb.choice.n2->combOffset_n2=0; + srs_res0->transmissionComb.choice.n2->cyclicShift_n2=0; + srs_res0->resourceMapping.startPosition = 2 + uid%2; + srs_res0->resourceMapping.nrofSymbols=NR_SRS_Resource__resourceMapping__nrofSymbols_n1; + srs_res0->resourceMapping.repetitionFactor=NR_SRS_Resource__resourceMapping__repetitionFactor_n1; + srs_res0->freqDomainPosition=0; + srs_res0->freqDomainShift=0; + srs_res0->freqHopping.b_SRS=0; + srs_res0->freqHopping.b_hop=0; + srs_res0->freqHopping.c_SRS = rrc_get_max_nr_csrs( + NRRIV2BW(servingcellconfigcommon->uplinkConfigCommon->initialUplinkBWP->genericParameters.locationAndBandwidth, 275), + srs_res0->freqHopping.b_SRS); + srs_res0->groupOrSequenceHopping=NR_SRS_Resource__groupOrSequenceHopping_neither; + + if(configuration->do_SRS) { + srs_res0->resourceType.present= NR_SRS_Resource__resourceType_PR_periodic; + srs_res0->resourceType.choice.periodic=calloc(1,sizeof(*srs_res0->resourceType.choice.periodic)); + srs_res0->resourceType.choice.periodic->periodicityAndOffset_p.present = NR_SRS_PeriodicityAndOffset_PR_sl160; + srs_res0->resourceType.choice.periodic->periodicityAndOffset_p.choice.sl160 = 17 + (uid>1)*10; // 17/17/.../147/157 are mixed slots + } else { + srs_res0->resourceType.present= NR_SRS_Resource__resourceType_PR_aperiodic; + srs_res0->resourceType.choice.aperiodic=calloc(1,sizeof(*srs_res0->resourceType.choice.aperiodic)); + } + + srs_res0->sequenceId=40; + srs_res0->spatialRelationInfo=calloc(1,sizeof(*srs_res0->spatialRelationInfo)); + srs_res0->spatialRelationInfo->servingCellId=NULL; + srs_res0->spatialRelationInfo->referenceSignal.present=NR_SRS_SpatialRelationInfo__referenceSignal_PR_csi_RS_Index; + srs_res0->spatialRelationInfo->referenceSignal.choice.csi_RS_Index=0; + ASN_SEQUENCE_ADD(&srs_Config->srs_ResourceToAddModList->list,srs_res0); + + ubwp->bwp_Dedicated->configuredGrantConfig = NULL; + ubwp->bwp_Dedicated->beamFailureRecoveryConfig = NULL; + +} + void fill_default_secondaryCellGroup(NR_ServingCellConfigCommon_t *servingcellconfigcommon, NR_ServingCellConfig_t *servingcellconfigdedicated, NR_CellGroupConfig_t *secondaryCellGroup, NR_UE_NR_Capability_t *uecap, int scg_id, int servCellIndex, - int dl_antenna_ports, - int minRXTXTIME, - int do_csirs, - int do_srs, + const gNB_RrcConfigurationReq *configuration, int uid) { + const rrc_pdsch_AntennaPorts_t* pdschap = &configuration->pdsch_AntennaPorts; + const int dl_antenna_ports = pdschap->N1 * pdschap->N2 * pdschap->XP; + const int do_csirs = configuration->do_CSIRS; + AssertFatal(servingcellconfigcommon!=NULL,"servingcellconfigcommon is null\n"); AssertFatal(secondaryCellGroup!=NULL,"secondaryCellGroup is null\n"); @@ -73,31 +631,15 @@ void fill_default_secondaryCellGroup(NR_ServingCellConfigCommon_t *servingcellco // where the startPosition = 2 or 3 and sl160 = 17, 17, 27 ... 157 only give us 30 different allocations. AssertFatal(uid>=0 && uid<30, "gNB cannot allocate the SRS resources\n"); - uint64_t bitmap=0; - switch (servingcellconfigcommon->ssb_PositionsInBurst->present) { - case 1 : - bitmap = ((uint64_t) servingcellconfigcommon->ssb_PositionsInBurst->choice.shortBitmap.buf[0])<<56; - break; - case 2 : - bitmap = ((uint64_t) servingcellconfigcommon->ssb_PositionsInBurst->choice.mediumBitmap.buf[0])<<56; - break; - case 3 : - for (int i=0; i<8; i++) { - bitmap |= (((uint64_t) servingcellconfigcommon->ssb_PositionsInBurst->choice.longBitmap.buf[i])<<((7-i)*8)); - } - break; - default: - AssertFatal(1==0,"SSB bitmap size value %d undefined (allowed values 1,2,3) \n", servingcellconfigcommon->ssb_PositionsInBurst->present); - } + uint64_t bitmap = get_ssb_bitmap(servingcellconfigcommon); + fix_servingcellconfigdedicated(servingcellconfigdedicated); memset(secondaryCellGroup,0,sizeof(NR_CellGroupConfig_t)); secondaryCellGroup->cellGroupId = scg_id; NR_RLC_BearerConfig_t *RLC_BearerConfig = calloc(1,sizeof(*RLC_BearerConfig)); nr_rlc_bearer_init(RLC_BearerConfig, NR_RLC_BearerConfig__servedRadioBearer_PR_drb_Identity); - if (get_softmodem_params()->do_ra || get_softmodem_params()->sa) - nr_drb_config(RLC_BearerConfig->rlc_Config, NR_RLC_Config_PR_um_Bi_Directional); - else - nr_drb_config(RLC_BearerConfig->rlc_Config, NR_RLC_Config_PR_am); + nr_drb_config(RLC_BearerConfig->rlc_Config, NR_RLC_Config_PR_um_Bi_Directional); + //nr_drb_config(RLC_BearerConfig->rlc_Config, NR_RLC_Config_PR_am); nr_rlc_bearer_init_ul_spec(RLC_BearerConfig->mac_LogicalChannelConfig); secondaryCellGroup->rlc_BearerToAddModList = calloc(1,sizeof(*secondaryCellGroup->rlc_BearerToAddModList)); @@ -199,12 +741,12 @@ void fill_default_secondaryCellGroup(NR_ServingCellConfigCommon_t *servingcellco secondaryCellGroup->spCellConfig->rlf_TimersAndConstants->choice.setup->ext1 = calloc(1,sizeof(*secondaryCellGroup->spCellConfig->rlf_TimersAndConstants->choice.setup->ext1)); secondaryCellGroup->spCellConfig->rlf_TimersAndConstants->choice.setup->ext1->t311 = NR_RLF_TimersAndConstants__ext1__t311_ms30000; secondaryCellGroup->spCellConfig->rlmInSyncOutOfSyncThreshold = NULL; - if (servingcellconfigdedicated) { - secondaryCellGroup->spCellConfig->spCellConfigDedicated = servingcellconfigdedicated; - } else { - secondaryCellGroup->spCellConfig->spCellConfigDedicated = calloc(1,sizeof(*secondaryCellGroup->spCellConfig->spCellConfigDedicated)); - } + + secondaryCellGroup->spCellConfig->spCellConfigDedicated = calloc(1,sizeof(*secondaryCellGroup->spCellConfig->spCellConfigDedicated)); secondaryCellGroup->spCellConfig->spCellConfigDedicated->tdd_UL_DL_ConfigurationDedicated = NULL; + + /// initialDownlinkBWP + secondaryCellGroup->spCellConfig->spCellConfigDedicated->initialDownlinkBWP = calloc(1,sizeof(*secondaryCellGroup->spCellConfig->spCellConfigDedicated->initialDownlinkBWP)); secondaryCellGroup->spCellConfig->spCellConfigDedicated->initialDownlinkBWP->pdcch_Config=NULL; secondaryCellGroup->spCellConfig->spCellConfigDedicated->initialDownlinkBWP->pdsch_Config=calloc(1,sizeof(*secondaryCellGroup->spCellConfig->spCellConfigDedicated->initialDownlinkBWP->pdsch_Config)); @@ -224,8 +766,7 @@ void fill_default_secondaryCellGroup(NR_ServingCellConfigCommon_t *servingcellco secondaryCellGroup->spCellConfig->spCellConfigDedicated->initialDownlinkBWP->pdsch_Config->choice.setup->dmrs_DownlinkForPDSCH_MappingTypeA->choice.setup->phaseTrackingRS=NULL; secondaryCellGroup->spCellConfig->spCellConfigDedicated->initialDownlinkBWP->pdsch_Config->choice.setup->dmrs_DownlinkForPDSCH_MappingTypeA->choice.setup->dmrs_AdditionalPosition = calloc(1,sizeof(*secondaryCellGroup->spCellConfig->spCellConfigDedicated->initialDownlinkBWP->pdsch_Config->choice.setup->dmrs_DownlinkForPDSCH_MappingTypeA->choice.setup->dmrs_AdditionalPosition)); - *secondaryCellGroup->spCellConfig->spCellConfigDedicated->initialDownlinkBWP->pdsch_Config->choice.setup->dmrs_DownlinkForPDSCH_MappingTypeA->choice.setup->dmrs_AdditionalPosition = NR_DMRS_DownlinkConfig__dmrs_AdditionalPosition_pos0; - + *secondaryCellGroup->spCellConfig->spCellConfigDedicated->initialDownlinkBWP->pdsch_Config->choice.setup->dmrs_DownlinkForPDSCH_MappingTypeA->choice.setup->dmrs_AdditionalPosition = NR_DMRS_DownlinkConfig__dmrs_AdditionalPosition_pos1; secondaryCellGroup->spCellConfig->spCellConfigDedicated->initialDownlinkBWP->pdsch_Config->choice.setup->tci_StatesToAddModList=calloc(1,sizeof(*secondaryCellGroup->spCellConfig->spCellConfigDedicated->initialDownlinkBWP->pdsch_Config->choice.setup->tci_StatesToAddModList)); @@ -246,7 +787,6 @@ void fill_default_secondaryCellGroup(NR_ServingCellConfigCommon_t *servingcellco } } - #if 0 NR_TCI_State_t*tci0=calloc(1,sizeof(*tci0)); @@ -372,405 +912,131 @@ void fill_default_secondaryCellGroup(NR_ServingCellConfigCommon_t *servingcellco *secondaryCellGroup->spCellConfig->spCellConfigDedicated->initialDownlinkBWP->radioLinkMonitoringConfig->choice.setup->beamFailureDetectionTimer = NR_RadioLinkMonitoringConfig__beamFailureDetectionTimer_pbfd2; #endif - secondaryCellGroup->spCellConfig->spCellConfigDedicated->downlinkBWP_ToReleaseList= NULL; - - NR_BWP_Downlink_t *bwp = NULL; - if (servingcellconfigdedicated) { - bwp=servingcellconfigdedicated->downlinkBWP_ToAddModList->list.array[0]; - } else { - secondaryCellGroup->spCellConfig->spCellConfigDedicated->downlinkBWP_ToAddModList = calloc(1,sizeof(*secondaryCellGroup->spCellConfig->spCellConfigDedicated->downlinkBWP_ToAddModList)); + /// initialUplinkBWP - bwp=calloc(1,sizeof(*bwp)); - } - bwp->bwp_Id=1; - bwp->bwp_Common=calloc(1,sizeof(*bwp->bwp_Common)); - // copy common BWP size from initial BWP except for bandwdith - memcpy((void*)&bwp->bwp_Common->genericParameters, - &servingcellconfigcommon->downlinkConfigCommon->initialDownlinkBWP->genericParameters, - sizeof(bwp->bwp_Common->genericParameters)); - bwp->bwp_Common->genericParameters.locationAndBandwidth=PRBalloc_to_locationandbandwidth(servingcellconfigcommon->downlinkConfigCommon->frequencyInfoDL->scs_SpecificCarrierList.list.array[0]->carrierBandwidth,0); + if (!secondaryCellGroup->spCellConfig->spCellConfigDedicated->uplinkConfig) { + secondaryCellGroup->spCellConfig->spCellConfigDedicated->uplinkConfig=calloc(1,sizeof(*secondaryCellGroup->spCellConfig->spCellConfigDedicated->uplinkConfig)); + } - - bwp->bwp_Common->pdcch_ConfigCommon=calloc(1,sizeof(*bwp->bwp_Common->pdcch_ConfigCommon)); - bwp->bwp_Common->pdcch_ConfigCommon->present = NR_SetupRelease_PDCCH_ConfigCommon_PR_setup; - bwp->bwp_Common->pdcch_ConfigCommon->choice.setup = calloc(1,sizeof(*bwp->bwp_Common->pdcch_ConfigCommon->choice.setup)); - bwp->bwp_Common->pdcch_ConfigCommon->choice.setup->controlResourceSetZero=NULL; - bwp->bwp_Common->pdcch_ConfigCommon->choice.setup->commonControlResourceSet=calloc(1,sizeof(*bwp->bwp_Common->pdcch_ConfigCommon->choice.setup->commonControlResourceSet)); + NR_BWP_UplinkDedicated_t *initialUplinkBWP = calloc(1,sizeof(*initialUplinkBWP)); + secondaryCellGroup->spCellConfig->spCellConfigDedicated->uplinkConfig->initialUplinkBWP = initialUplinkBWP; + initialUplinkBWP->pucch_Config = NULL; + initialUplinkBWP->pusch_Config = calloc(1,sizeof(*initialUplinkBWP->pusch_Config)); + initialUplinkBWP->pusch_Config->present = NR_SetupRelease_PUSCH_Config_PR_setup; - int curr_bwp = NRRIV2BW(bwp->bwp_Common->genericParameters.locationAndBandwidth,275); - - NR_ControlResourceSet_t *coreset = calloc(1,sizeof(*coreset)); - coreset->controlResourceSetId=1; - // frequency domain resources depends on BWP size - // options are 24, 48 or 96 - coreset->frequencyDomainResources.buf = calloc(1,6); - if (curr_bwp < 48) - coreset->frequencyDomainResources.buf[0] = 0xf0; - else - coreset->frequencyDomainResources.buf[0] = 0xff; - if (curr_bwp < 96) - coreset->frequencyDomainResources.buf[1] = 0; - else - coreset->frequencyDomainResources.buf[1] = 0xff; - coreset->frequencyDomainResources.buf[2] = 0; - coreset->frequencyDomainResources.buf[3] = 0; - coreset->frequencyDomainResources.buf[4] = 0; - coreset->frequencyDomainResources.buf[5] = 0; - coreset->frequencyDomainResources.size = 6; - coreset->frequencyDomainResources.bits_unused = 3; - coreset->duration=1; - coreset->cce_REG_MappingType.present = NR_ControlResourceSet__cce_REG_MappingType_PR_nonInterleaved; - coreset->precoderGranularity = NR_ControlResourceSet__precoderGranularity_sameAsREG_bundle; - - coreset->tci_StatesPDCCH_ToAddList=calloc(1,sizeof(*coreset->tci_StatesPDCCH_ToAddList)); - NR_TCI_StateId_t *tci[64]; - for (int i=0;i<64;i++) { - if ((bitmap>>(63-i))&0x01){ - tci[i]=calloc(1,sizeof(*tci[i])); - *tci[i] = i; - ASN_SEQUENCE_ADD(&coreset->tci_StatesPDCCH_ToAddList->list,tci[i]); - } - } - coreset->tci_StatesPDCCH_ToReleaseList = NULL; - coreset->tci_PresentInDCI = NULL; - coreset->pdcch_DMRS_ScramblingID = NULL; - - bwp->bwp_Common->pdcch_ConfigCommon->choice.setup->commonControlResourceSet = coreset; - - bwp->bwp_Common->pdcch_ConfigCommon->choice.setup->searchSpaceZero=NULL; - bwp->bwp_Common->pdcch_ConfigCommon->choice.setup->commonSearchSpaceList=NULL; - bwp->bwp_Common->pdcch_ConfigCommon->choice.setup->commonSearchSpaceList=calloc(1,sizeof(*bwp->bwp_Common->pdcch_ConfigCommon->choice.setup->commonSearchSpaceList)); - - NR_SearchSpace_t *ss=calloc(1,sizeof(*ss)); - ss->searchSpaceId = 1; - ss->controlResourceSetId=calloc(1,sizeof(*ss->controlResourceSetId)); - *ss->controlResourceSetId=1; - ss->monitoringSlotPeriodicityAndOffset = calloc(1,sizeof(*ss->monitoringSlotPeriodicityAndOffset)); - ss->monitoringSlotPeriodicityAndOffset->present = NR_SearchSpace__monitoringSlotPeriodicityAndOffset_PR_sl1; - ss->duration=NULL; - ss->monitoringSymbolsWithinSlot = calloc(1,sizeof(*ss->monitoringSymbolsWithinSlot)); - ss->monitoringSymbolsWithinSlot->buf = calloc(1,2); - // should be '1100 0000 0000 00'B (LSB first!), first two symols in slot, adjust if needed - ss->monitoringSymbolsWithinSlot->buf[1] = 0; - ss->monitoringSymbolsWithinSlot->buf[0] = (1<<7) | (1<<6); - ss->monitoringSymbolsWithinSlot->size = 2; - ss->monitoringSymbolsWithinSlot->bits_unused = 2; - ss->nrofCandidates = calloc(1,sizeof(*ss->nrofCandidates)); - ss->nrofCandidates->aggregationLevel1 = NR_SearchSpace__nrofCandidates__aggregationLevel1_n0; - ss->nrofCandidates->aggregationLevel2 = NR_SearchSpace__nrofCandidates__aggregationLevel2_n0; - ss->nrofCandidates->aggregationLevel4 = NR_SearchSpace__nrofCandidates__aggregationLevel4_n1; - ss->nrofCandidates->aggregationLevel8 = NR_SearchSpace__nrofCandidates__aggregationLevel8_n0; - ss->nrofCandidates->aggregationLevel16 = NR_SearchSpace__nrofCandidates__aggregationLevel16_n0; - ss->searchSpaceType = calloc(1,sizeof(*ss->searchSpaceType)); - ss->searchSpaceType->present = NR_SearchSpace__searchSpaceType_PR_common; - ss->searchSpaceType->choice.common=calloc(1,sizeof(*ss->searchSpaceType->choice.common)); - ss->searchSpaceType->choice.common->dci_Format0_0_AndFormat1_0 = calloc(1,sizeof(*ss->searchSpaceType->choice.common->dci_Format0_0_AndFormat1_0)); - - ASN_SEQUENCE_ADD(&bwp->bwp_Common->pdcch_ConfigCommon->choice.setup->commonSearchSpaceList->list,ss); - - bwp->bwp_Common->pdcch_ConfigCommon->choice.setup->searchSpaceSIB1=NULL; - if(get_softmodem_params()->sa) { - bwp->bwp_Common->pdcch_ConfigCommon->choice.setup->searchSpaceSIB1=calloc(1,sizeof(*bwp->bwp_Common->pdcch_ConfigCommon->choice.setup->searchSpaceSIB1)); - *bwp->bwp_Common->pdcch_ConfigCommon->choice.setup->searchSpaceSIB1=0; - } - bwp->bwp_Common->pdcch_ConfigCommon->choice.setup->searchSpaceOtherSystemInformation=NULL; - bwp->bwp_Common->pdcch_ConfigCommon->choice.setup->pagingSearchSpace=NULL; - bwp->bwp_Common->pdcch_ConfigCommon->choice.setup->ra_SearchSpace=calloc(1,sizeof(*bwp->bwp_Common->pdcch_ConfigCommon->choice.setup->ra_SearchSpace)); - *bwp->bwp_Common->pdcch_ConfigCommon->choice.setup->ra_SearchSpace=1; - bwp->bwp_Common->pdcch_ConfigCommon->choice.setup->ext1=NULL; - - bwp->bwp_Common->pdsch_ConfigCommon=calloc(1,sizeof(*bwp->bwp_Common->pdsch_ConfigCommon)); - bwp->bwp_Common->pdsch_ConfigCommon->present = NR_SetupRelease_PDSCH_ConfigCommon_PR_setup; - bwp->bwp_Common->pdsch_ConfigCommon->choice.setup = calloc(1,sizeof(*bwp->bwp_Common->pdsch_ConfigCommon->choice.setup)); - bwp->bwp_Common->pdsch_ConfigCommon->choice.setup->pdsch_TimeDomainAllocationList = calloc(1,sizeof(*bwp->bwp_Common->pdsch_ConfigCommon->choice.setup->pdsch_TimeDomainAllocationList)); - - // copy PDSCH TimeDomainResourceAllocation from InitialBWP - - NR_PDSCH_TimeDomainResourceAllocation_t *pdschi; - for (int i=0;idownlinkConfigCommon->initialDownlinkBWP->pdsch_ConfigCommon->choice.setup->pdsch_TimeDomainAllocationList->list.count;i++) { - pdschi= calloc(1,sizeof(*pdschi)); - if(servingcellconfigcommon->downlinkConfigCommon->initialDownlinkBWP->pdsch_ConfigCommon->choice.setup->pdsch_TimeDomainAllocationList->list.array[i]->k0){ - pdschi->k0 = calloc(1,sizeof(*pdschi->k0)); - *pdschi->k0 = *servingcellconfigcommon->downlinkConfigCommon->initialDownlinkBWP->pdsch_ConfigCommon->choice.setup->pdsch_TimeDomainAllocationList->list.array[i]->k0; - } - pdschi->mappingType = servingcellconfigcommon->downlinkConfigCommon->initialDownlinkBWP->pdsch_ConfigCommon->choice.setup->pdsch_TimeDomainAllocationList->list.array[i]->mappingType; - pdschi->startSymbolAndLength = servingcellconfigcommon->downlinkConfigCommon->initialDownlinkBWP->pdsch_ConfigCommon->choice.setup->pdsch_TimeDomainAllocationList->list.array[i]->startSymbolAndLength; - ASN_SEQUENCE_ADD(&bwp->bwp_Common->pdsch_ConfigCommon->choice.setup->pdsch_TimeDomainAllocationList->list,pdschi); - } - - if (!servingcellconfigdedicated) { - bwp->bwp_Dedicated=calloc(1,sizeof(*bwp->bwp_Dedicated)); - } - bwp->bwp_Dedicated->pdcch_Config=calloc(1,sizeof(*bwp->bwp_Dedicated->pdcch_Config)); - bwp->bwp_Dedicated->pdcch_Config->present = NR_SetupRelease_PDCCH_Config_PR_setup; - bwp->bwp_Dedicated->pdcch_Config->choice.setup = calloc(1,sizeof(*bwp->bwp_Dedicated->pdcch_Config->choice.setup)); - bwp->bwp_Dedicated->pdcch_Config->choice.setup->controlResourceSetToAddModList = calloc(1,sizeof(*bwp->bwp_Dedicated->pdcch_Config->choice.setup->controlResourceSetToAddModList)); - - ASN_SEQUENCE_ADD(&bwp->bwp_Dedicated->pdcch_Config->choice.setup->controlResourceSetToAddModList->list, - coreset); - - bwp->bwp_Dedicated->pdcch_Config->choice.setup->searchSpacesToAddModList = calloc(1,sizeof(*bwp->bwp_Dedicated->pdcch_Config->choice.setup->searchSpacesToAddModList)); - - NR_SearchSpace_t *ss2 = calloc(1,sizeof(*ss2)); - - ss2->searchSpaceId=2; - ss2->controlResourceSetId=calloc(1,sizeof(*ss2->controlResourceSetId)); - *ss2->controlResourceSetId=1; - ss2->monitoringSlotPeriodicityAndOffset=calloc(1,sizeof(*ss2->monitoringSlotPeriodicityAndOffset)); - ss2->monitoringSlotPeriodicityAndOffset->present = NR_SearchSpace__monitoringSlotPeriodicityAndOffset_PR_sl1; - ss2->monitoringSlotPeriodicityAndOffset->choice.sl1=(NULL_t)0; - ss2->duration=NULL; - ss2->monitoringSymbolsWithinSlot = calloc(1,sizeof(*ss2->monitoringSymbolsWithinSlot)); - ss2->monitoringSymbolsWithinSlot->buf = calloc(1,2); - ss2->monitoringSymbolsWithinSlot->size = 2; - ss2->monitoringSymbolsWithinSlot->bits_unused = 2; - ss2->monitoringSymbolsWithinSlot->buf[0]=0xc0; - ss2->monitoringSymbolsWithinSlot->buf[1]=0x0; - ss2->nrofCandidates=calloc(1,sizeof(*ss2->nrofCandidates)); - ss2->nrofCandidates->aggregationLevel1 = NR_SearchSpace__nrofCandidates__aggregationLevel1_n0; - ss2->nrofCandidates->aggregationLevel2 = NR_SearchSpace__nrofCandidates__aggregationLevel2_n0; - if (curr_bwp < 48) - ss2->nrofCandidates->aggregationLevel4 = NR_SearchSpace__nrofCandidates__aggregationLevel4_n1; - else if (curr_bwp < 96) - ss2->nrofCandidates->aggregationLevel4 = NR_SearchSpace__nrofCandidates__aggregationLevel4_n2; - else - ss2->nrofCandidates->aggregationLevel4 = NR_SearchSpace__nrofCandidates__aggregationLevel4_n4; - ss2->nrofCandidates->aggregationLevel8 = NR_SearchSpace__nrofCandidates__aggregationLevel8_n0; - ss2->nrofCandidates->aggregationLevel16 = NR_SearchSpace__nrofCandidates__aggregationLevel16_n0; - ss2->searchSpaceType=calloc(1,sizeof(*ss2->searchSpaceType)); - ss2->searchSpaceType->present = NR_SearchSpace__searchSpaceType_PR_ue_Specific; - ss2->searchSpaceType->choice.ue_Specific = calloc(1,sizeof(*ss2->searchSpaceType->choice.ue_Specific)); - ss2->searchSpaceType->choice.ue_Specific->dci_Formats=NR_SearchSpace__searchSpaceType__ue_Specific__dci_Formats_formats0_1_And_1_1; - - ASN_SEQUENCE_ADD(&bwp->bwp_Dedicated->pdcch_Config->choice.setup->searchSpacesToAddModList->list, - ss2); - - - bwp->bwp_Dedicated->pdcch_Config->choice.setup->searchSpacesToReleaseList = NULL; - - if (!servingcellconfigdedicated) { - bwp->bwp_Dedicated->pdsch_Config = calloc(1,sizeof(*bwp->bwp_Dedicated->pdsch_Config)); - - bwp->bwp_Dedicated->pdsch_Config->present = NR_SetupRelease_PDSCH_Config_PR_setup; - bwp->bwp_Dedicated->pdsch_Config->choice.setup = calloc(1,sizeof(*bwp->bwp_Dedicated->pdsch_Config->choice.setup)); - bwp->bwp_Dedicated->pdsch_Config->choice.setup->dmrs_DownlinkForPDSCH_MappingTypeA = calloc(1,sizeof(*bwp->bwp_Dedicated->pdsch_Config->choice.setup->dmrs_DownlinkForPDSCH_MappingTypeA)); - bwp->bwp_Dedicated->pdsch_Config->choice.setup->dmrs_DownlinkForPDSCH_MappingTypeA->present= NR_SetupRelease_DMRS_DownlinkConfig_PR_setup; - - bwp->bwp_Dedicated->pdsch_Config->choice.setup->dmrs_DownlinkForPDSCH_MappingTypeA->choice.setup = calloc(1,sizeof(*bwp->bwp_Dedicated->pdsch_Config->choice.setup->dmrs_DownlinkForPDSCH_MappingTypeA->choice.setup)); - } - bwp->bwp_Dedicated->pdsch_Config->choice.setup->dataScramblingIdentityPDSCH = NULL; - - if ((get_softmodem_params()->do_ra || - get_softmodem_params()->phy_test) && - dl_antenna_ports > 1) // for MIMO, we use DMRS Config Type 2 but only with OAI UE - bwp->bwp_Dedicated->pdsch_Config->choice.setup->dmrs_DownlinkForPDSCH_MappingTypeA->choice.setup->dmrs_Type=calloc(1,sizeof(*bwp->bwp_Dedicated->pdsch_Config->choice.setup->dmrs_DownlinkForPDSCH_MappingTypeA->choice.setup->dmrs_Type)); - else - bwp->bwp_Dedicated->pdsch_Config->choice.setup->dmrs_DownlinkForPDSCH_MappingTypeA->choice.setup->dmrs_Type=NULL; - bwp->bwp_Dedicated->pdsch_Config->choice.setup->dmrs_DownlinkForPDSCH_MappingTypeA->choice.setup->maxLength=NULL; - bwp->bwp_Dedicated->pdsch_Config->choice.setup->dmrs_DownlinkForPDSCH_MappingTypeA->choice.setup->scramblingID0=NULL; - bwp->bwp_Dedicated->pdsch_Config->choice.setup->dmrs_DownlinkForPDSCH_MappingTypeA->choice.setup->scramblingID1=NULL; - if (!servingcellconfigdedicated) { - bwp->bwp_Dedicated->pdsch_Config->choice.setup->dmrs_DownlinkForPDSCH_MappingTypeA->choice.setup->phaseTrackingRS=NULL; - } - bwp->bwp_Dedicated->pdsch_Config->choice.setup->dmrs_DownlinkForPDSCH_MappingTypeA->choice.setup->dmrs_AdditionalPosition = calloc(1,sizeof(*bwp->bwp_Dedicated->pdsch_Config->choice.setup->dmrs_DownlinkForPDSCH_MappingTypeA->choice.setup->dmrs_AdditionalPosition)); - *bwp->bwp_Dedicated->pdsch_Config->choice.setup->dmrs_DownlinkForPDSCH_MappingTypeA->choice.setup->dmrs_AdditionalPosition = NR_DMRS_DownlinkConfig__dmrs_AdditionalPosition_pos0; - - bwp->bwp_Dedicated->pdsch_Config->choice.setup->tci_StatesToAddModList=calloc(1,sizeof(*bwp->bwp_Dedicated->pdsch_Config->choice.setup->tci_StatesToAddModList)); - - n_ssb = 0; - NR_TCI_State_t *tcid[64]; - for (int i=0;i<64;i++) { - if ((bitmap>>(63-i))&0x01){ - tcid[i]=calloc(1,sizeof(*tcid[i])); - tcid[i]->tci_StateId=n_ssb; - tcid[i]->qcl_Type1.cell=NULL; - tcid[i]->qcl_Type1.bwp_Id=calloc(1,sizeof(*tcid[i]->qcl_Type1.bwp_Id)); - *tcid[i]->qcl_Type1.bwp_Id=1; - tcid[i]->qcl_Type1.referenceSignal.present = NR_QCL_Info__referenceSignal_PR_ssb; - tcid[i]->qcl_Type1.referenceSignal.choice.ssb = i; - tcid[i]->qcl_Type1.qcl_Type=NR_QCL_Info__qcl_Type_typeC; - ASN_SEQUENCE_ADD(&bwp->bwp_Dedicated->pdsch_Config->choice.setup->tci_StatesToAddModList->list,tcid[i]); - n_ssb++; - } - } - - - bwp->bwp_Dedicated->pdsch_Config->choice.setup->tci_StatesToReleaseList=NULL; - bwp->bwp_Dedicated->pdsch_Config->choice.setup->vrb_ToPRB_Interleaver=NULL; - bwp->bwp_Dedicated->pdsch_Config->choice.setup->resourceAllocation=NR_PDSCH_Config__resourceAllocation_resourceAllocationType1; - bwp->bwp_Dedicated->pdsch_Config->choice.setup->pdsch_TimeDomainAllocationList=NULL; - bwp->bwp_Dedicated->pdsch_Config->choice.setup->pdsch_AggregationFactor=NULL; - bwp->bwp_Dedicated->pdsch_Config->choice.setup->rateMatchPatternToAddModList=NULL; - bwp->bwp_Dedicated->pdsch_Config->choice.setup->rateMatchPatternToReleaseList=NULL; - bwp->bwp_Dedicated->pdsch_Config->choice.setup->rateMatchPatternGroup1=NULL; - bwp->bwp_Dedicated->pdsch_Config->choice.setup->rateMatchPatternGroup2=NULL; - bwp->bwp_Dedicated->pdsch_Config->choice.setup->rbg_Size=NR_PDSCH_Config__rbg_Size_config1; - set_dl_mcs_table(bwp->bwp_Common->genericParameters.subcarrierSpacing, uecap, bwp->bwp_Dedicated, servingcellconfigcommon); - bwp->bwp_Dedicated->pdsch_Config->choice.setup->maxNrofCodeWordsScheduledByDCI = calloc(1,sizeof(*bwp->bwp_Dedicated->pdsch_Config->choice.setup->maxNrofCodeWordsScheduledByDCI)); - *bwp->bwp_Dedicated->pdsch_Config->choice.setup->maxNrofCodeWordsScheduledByDCI = NR_PDSCH_Config__maxNrofCodeWordsScheduledByDCI_n1; - bwp->bwp_Dedicated->pdsch_Config->choice.setup->prb_BundlingType.present = NR_PDSCH_Config__prb_BundlingType_PR_staticBundling; - bwp->bwp_Dedicated->pdsch_Config->choice.setup->prb_BundlingType.choice.staticBundling = calloc(1,sizeof(*bwp->bwp_Dedicated->pdsch_Config->choice.setup->prb_BundlingType.choice.staticBundling)); - bwp->bwp_Dedicated->pdsch_Config->choice.setup->prb_BundlingType.choice.staticBundling->bundleSize = - calloc(1,sizeof(*bwp->bwp_Dedicated->pdsch_Config->choice.setup->prb_BundlingType.choice.staticBundling->bundleSize)); - *bwp->bwp_Dedicated->pdsch_Config->choice.setup->prb_BundlingType.choice.staticBundling->bundleSize = NR_PDSCH_Config__prb_BundlingType__staticBundling__bundleSize_wideband; - bwp->bwp_Dedicated->pdsch_Config->choice.setup->zp_CSI_RS_ResourceToAddModList=NULL; - bwp->bwp_Dedicated->pdsch_Config->choice.setup->zp_CSI_RS_ResourceToReleaseList=NULL; - bwp->bwp_Dedicated->pdsch_Config->choice.setup->aperiodic_ZP_CSI_RS_ResourceSetsToAddModList=NULL; - bwp->bwp_Dedicated->pdsch_Config->choice.setup->aperiodic_ZP_CSI_RS_ResourceSetsToReleaseList=NULL; - bwp->bwp_Dedicated->pdsch_Config->choice.setup->sp_ZP_CSI_RS_ResourceSetsToAddModList=NULL; - bwp->bwp_Dedicated->pdsch_Config->choice.setup->sp_ZP_CSI_RS_ResourceSetsToReleaseList=NULL; - bwp->bwp_Dedicated->pdsch_Config->choice.setup->p_ZP_CSI_RS_ResourceSet=NULL; - bwp->bwp_Dedicated->sps_Config = NULL; //calloc(1,sizeof(struct NR_SetupRelease_SPS_Config)); - - bwp->bwp_Dedicated->radioLinkMonitoringConfig = NULL; -#if 0 - bwp->bwp_Dedicated->radioLinkMonitoringConfig = calloc(1,sizeof(*bwp->bwp_Dedicated->radioLinkMonitoringConfig)); - bwp->bwp_Dedicated->radioLinkMonitoringConfig->present = NR_SetupRelease_RadioLinkMonitoringConfig_PR_setup; - - bwp->bwp_Dedicated->radioLinkMonitoringConfig->choice.setup = calloc(1,sizeof(*bwp->bwp_Dedicated->radioLinkMonitoringConfig->choice.setup)); - bwp->bwp_Dedicated->radioLinkMonitoringConfig->choice.setup->failureDetectionResourcesToAddModList=NULL; - bwp->bwp_Dedicated->radioLinkMonitoringConfig->choice.setup->failureDetectionResourcesToReleaseList=NULL; - bwp->bwp_Dedicated->radioLinkMonitoringConfig->choice.setup->beamFailureInstanceMaxCount = calloc(1,sizeof(*bwp->bwp_Dedicated->radioLinkMonitoringConfig->choice.setup->beamFailureInstanceMaxCount)); - *bwp->bwp_Dedicated->radioLinkMonitoringConfig->choice.setup->beamFailureInstanceMaxCount = NR_RadioLinkMonitoringConfig__beamFailureInstanceMaxCount_n3; - bwp->bwp_Dedicated->radioLinkMonitoringConfig->choice.setup->beamFailureDetectionTimer = calloc(1,sizeof(*bwp->bwp_Dedicated->radioLinkMonitoringConfig->choice.setup->beamFailureDetectionTimer)); - *bwp->bwp_Dedicated->radioLinkMonitoringConfig->choice.setup->beamFailureDetectionTimer = NR_RadioLinkMonitoringConfig__beamFailureDetectionTimer_pbfd2; -#endif - - if (!servingcellconfigdedicated) { - ASN_SEQUENCE_ADD(&secondaryCellGroup->spCellConfig->spCellConfigDedicated->downlinkBWP_ToAddModList->list,bwp); - } - secondaryCellGroup->spCellConfig->spCellConfigDedicated->firstActiveDownlinkBWP_Id=calloc(1,sizeof(*secondaryCellGroup->spCellConfig->spCellConfigDedicated->firstActiveDownlinkBWP_Id)); - - *secondaryCellGroup->spCellConfig->spCellConfigDedicated->firstActiveDownlinkBWP_Id=1; - secondaryCellGroup->spCellConfig->spCellConfigDedicated->bwp_InactivityTimer = NULL; - secondaryCellGroup->spCellConfig->spCellConfigDedicated->defaultDownlinkBWP_Id = NULL; - secondaryCellGroup->spCellConfig->spCellConfigDedicated->defaultDownlinkBWP_Id = calloc(1, sizeof(*secondaryCellGroup->spCellConfig->spCellConfigDedicated->defaultDownlinkBWP_Id)); - *secondaryCellGroup->spCellConfig->spCellConfigDedicated->defaultDownlinkBWP_Id = 1; - - if (!servingcellconfigdedicated) { - secondaryCellGroup->spCellConfig->spCellConfigDedicated->uplinkConfig=calloc(1,sizeof(*secondaryCellGroup->spCellConfig->spCellConfigDedicated->uplinkConfig)); - } - - NR_BWP_UplinkDedicated_t *initialUplinkBWP = calloc(1,sizeof(*initialUplinkBWP)); - secondaryCellGroup->spCellConfig->spCellConfigDedicated->uplinkConfig->initialUplinkBWP = initialUplinkBWP; - initialUplinkBWP->pucch_Config = NULL; - initialUplinkBWP->pusch_Config = calloc(1,sizeof(*initialUplinkBWP->pusch_Config)); - initialUplinkBWP->pusch_Config->present = NR_SetupRelease_PUSCH_Config_PR_setup; - NR_PUSCH_Config_t *pusch_Config = NULL; - if (servingcellconfigdedicated) { - pusch_Config = servingcellconfigdedicated->uplinkConfig->uplinkBWP_ToAddModList->list.array[0]->bwp_Dedicated->pusch_Config->choice.setup; - } else { - pusch_Config = calloc(1,sizeof(*pusch_Config)); - } - initialUplinkBWP->pusch_Config->choice.setup = pusch_Config; - pusch_Config->txConfig=calloc(1,sizeof(*pusch_Config->txConfig)); - *pusch_Config->txConfig= NR_PUSCH_Config__txConfig_codebook; - pusch_Config->dmrs_UplinkForPUSCH_MappingTypeA = NULL; - if (!servingcellconfigdedicated) { - pusch_Config->dmrs_UplinkForPUSCH_MappingTypeB = calloc(1,sizeof(*pusch_Config->dmrs_UplinkForPUSCH_MappingTypeB)); - pusch_Config->dmrs_UplinkForPUSCH_MappingTypeB->present = NR_SetupRelease_DMRS_UplinkConfig_PR_setup; - pusch_Config->dmrs_UplinkForPUSCH_MappingTypeB->choice.setup = calloc(1,sizeof(*pusch_Config->dmrs_UplinkForPUSCH_MappingTypeB->choice.setup)); - } - NR_DMRS_UplinkConfig_t *NR_DMRS_UplinkConfig = pusch_Config->dmrs_UplinkForPUSCH_MappingTypeB->choice.setup; - NR_DMRS_UplinkConfig->dmrs_Type = NULL; - NR_DMRS_UplinkConfig->dmrs_AdditionalPosition = calloc(1,sizeof(*NR_DMRS_UplinkConfig->dmrs_AdditionalPosition)); - *NR_DMRS_UplinkConfig->dmrs_AdditionalPosition = NR_DMRS_UplinkConfig__dmrs_AdditionalPosition_pos0; - if (!servingcellconfigdedicated) { - NR_DMRS_UplinkConfig->phaseTrackingRS=NULL; - } - NR_DMRS_UplinkConfig->maxLength=NULL; - NR_DMRS_UplinkConfig->transformPrecodingDisabled = calloc(1,sizeof(*NR_DMRS_UplinkConfig->transformPrecodingDisabled)); - NR_DMRS_UplinkConfig->transformPrecodingDisabled->scramblingID0 = NULL; - NR_DMRS_UplinkConfig->transformPrecodingDisabled->scramblingID1 = NULL; - NR_DMRS_UplinkConfig->transformPrecodingEnabled = NULL; - pusch_Config->pusch_PowerControl = calloc(1,sizeof(*pusch_Config->pusch_PowerControl)); - pusch_Config->pusch_PowerControl->tpc_Accumulation = NULL; - pusch_Config->pusch_PowerControl->msg3_Alpha = calloc(1,sizeof(*pusch_Config->pusch_PowerControl->msg3_Alpha)); - *pusch_Config->pusch_PowerControl->msg3_Alpha = NR_Alpha_alpha1; - pusch_Config->pusch_PowerControl->p0_NominalWithoutGrant = NULL; - pusch_Config->pusch_PowerControl->p0_AlphaSets = calloc(1,sizeof(*pusch_Config->pusch_PowerControl->p0_AlphaSets)); - NR_P0_PUSCH_AlphaSet_t *aset = calloc(1,sizeof(*aset)); - aset->p0_PUSCH_AlphaSetId=0; - aset->p0=calloc(1,sizeof(*aset->p0)); - *aset->p0 = 0; - aset->alpha=calloc(1,sizeof(*aset->alpha)); - *aset->alpha=NR_Alpha_alpha1; - ASN_SEQUENCE_ADD(&pusch_Config->pusch_PowerControl->p0_AlphaSets->list,aset); - pusch_Config->pusch_PowerControl->pathlossReferenceRSToAddModList = NULL; - pusch_Config->pusch_PowerControl->pathlossReferenceRSToReleaseList = NULL; - pusch_Config->pusch_PowerControl->twoPUSCH_PC_AdjustmentStates = NULL; - pusch_Config->pusch_PowerControl->deltaMCS = NULL; - pusch_Config->pusch_PowerControl->sri_PUSCH_MappingToAddModList = NULL; - pusch_Config->pusch_PowerControl->sri_PUSCH_MappingToReleaseList = NULL; - pusch_Config->frequencyHopping=NULL; - pusch_Config->frequencyHoppingOffsetLists=NULL; - pusch_Config->resourceAllocation = NR_PUSCH_Config__resourceAllocation_resourceAllocationType1; - pusch_Config->pusch_TimeDomainAllocationList = NULL; - pusch_Config->pusch_AggregationFactor=NULL; - pusch_Config->mcs_Table=NULL; - pusch_Config->transformPrecoder= NULL; - pusch_Config->mcs_TableTransformPrecoder=NULL; - /* if msg3_transformprecoding is set in conf file - pusch config should not disable it */ - if (servingcellconfigcommon->uplinkConfigCommon->initialUplinkBWP->rach_ConfigCommon->choice.setup->msg3_transformPrecoder == NULL) { + NR_PUSCH_Config_t *pusch_Config = NULL; + if (servingcellconfigdedicated->uplinkConfig->uplinkBWP_ToAddModList) { + pusch_Config = servingcellconfigdedicated->uplinkConfig->uplinkBWP_ToAddModList->list.array[0]->bwp_Dedicated->pusch_Config->choice.setup; + } else { + pusch_Config = calloc(1,sizeof(*pusch_Config)); + } + initialUplinkBWP->pusch_Config->choice.setup = pusch_Config; + pusch_Config->txConfig=calloc(1,sizeof(*pusch_Config->txConfig)); + *pusch_Config->txConfig= NR_PUSCH_Config__txConfig_codebook; + pusch_Config->dmrs_UplinkForPUSCH_MappingTypeA = NULL; + if (!pusch_Config->dmrs_UplinkForPUSCH_MappingTypeB) { + pusch_Config->dmrs_UplinkForPUSCH_MappingTypeB = calloc(1,sizeof(*pusch_Config->dmrs_UplinkForPUSCH_MappingTypeB)); + pusch_Config->dmrs_UplinkForPUSCH_MappingTypeB->present = NR_SetupRelease_DMRS_UplinkConfig_PR_setup; + pusch_Config->dmrs_UplinkForPUSCH_MappingTypeB->choice.setup = calloc(1,sizeof(*pusch_Config->dmrs_UplinkForPUSCH_MappingTypeB->choice.setup)); + } + NR_DMRS_UplinkConfig_t *NR_DMRS_UplinkConfig = pusch_Config->dmrs_UplinkForPUSCH_MappingTypeB->choice.setup; + NR_DMRS_UplinkConfig->dmrs_Type = NULL; + NR_DMRS_UplinkConfig->dmrs_AdditionalPosition = calloc(1,sizeof(*NR_DMRS_UplinkConfig->dmrs_AdditionalPosition)); + *NR_DMRS_UplinkConfig->dmrs_AdditionalPosition = NR_DMRS_UplinkConfig__dmrs_AdditionalPosition_pos0; + if (!servingcellconfigdedicated) { + NR_DMRS_UplinkConfig->phaseTrackingRS=NULL; + } + NR_DMRS_UplinkConfig->maxLength=NULL; + NR_DMRS_UplinkConfig->transformPrecodingDisabled = calloc(1,sizeof(*NR_DMRS_UplinkConfig->transformPrecodingDisabled)); + NR_DMRS_UplinkConfig->transformPrecodingDisabled->scramblingID0 = NULL; + NR_DMRS_UplinkConfig->transformPrecodingDisabled->scramblingID1 = NULL; + NR_DMRS_UplinkConfig->transformPrecodingEnabled = NULL; + pusch_Config->pusch_PowerControl = calloc(1,sizeof(*pusch_Config->pusch_PowerControl)); + pusch_Config->pusch_PowerControl->tpc_Accumulation = NULL; + pusch_Config->pusch_PowerControl->msg3_Alpha = calloc(1,sizeof(*pusch_Config->pusch_PowerControl->msg3_Alpha)); + *pusch_Config->pusch_PowerControl->msg3_Alpha = NR_Alpha_alpha1; + pusch_Config->pusch_PowerControl->p0_NominalWithoutGrant = NULL; + pusch_Config->pusch_PowerControl->p0_AlphaSets = calloc(1,sizeof(*pusch_Config->pusch_PowerControl->p0_AlphaSets)); + NR_P0_PUSCH_AlphaSet_t *aset = calloc(1,sizeof(*aset)); + aset->p0_PUSCH_AlphaSetId=0; + aset->p0=calloc(1,sizeof(*aset->p0)); + *aset->p0 = 0; + aset->alpha=calloc(1,sizeof(*aset->alpha)); + *aset->alpha=NR_Alpha_alpha1; + ASN_SEQUENCE_ADD(&pusch_Config->pusch_PowerControl->p0_AlphaSets->list,aset); + pusch_Config->pusch_PowerControl->pathlossReferenceRSToAddModList = NULL; + pusch_Config->pusch_PowerControl->pathlossReferenceRSToReleaseList = NULL; + pusch_Config->pusch_PowerControl->twoPUSCH_PC_AdjustmentStates = NULL; + pusch_Config->pusch_PowerControl->deltaMCS = NULL; + pusch_Config->pusch_PowerControl->sri_PUSCH_MappingToAddModList = NULL; + pusch_Config->pusch_PowerControl->sri_PUSCH_MappingToReleaseList = NULL; + pusch_Config->frequencyHopping=NULL; + pusch_Config->frequencyHoppingOffsetLists=NULL; + pusch_Config->resourceAllocation = NR_PUSCH_Config__resourceAllocation_resourceAllocationType1; + pusch_Config->pusch_TimeDomainAllocationList = NULL; + pusch_Config->pusch_AggregationFactor=NULL; + pusch_Config->mcs_Table=NULL; + pusch_Config->transformPrecoder= NULL; + pusch_Config->mcs_TableTransformPrecoder=NULL; + /* if msg3_transformprecoding is set in conf file - pusch config should not disable it */ + if (servingcellconfigcommon->uplinkConfigCommon->initialUplinkBWP->rach_ConfigCommon->choice.setup->msg3_transformPrecoder == NULL) { pusch_Config->transformPrecoder=calloc(1,sizeof(*pusch_Config->transformPrecoder)); *pusch_Config->transformPrecoder = NR_PUSCH_Config__transformPrecoder_disabled; - } - pusch_Config->codebookSubset=calloc(1,sizeof(*pusch_Config->codebookSubset)); - *pusch_Config->codebookSubset = NR_PUSCH_Config__codebookSubset_nonCoherent; - pusch_Config->maxRank=calloc(1,sizeof(*pusch_Config->maxRank)); - *pusch_Config->maxRank= 1; - pusch_Config->rbg_Size=NULL; - pusch_Config->uci_OnPUSCH=NULL; - pusch_Config->tp_pi2BPSK=NULL; + } + pusch_Config->codebookSubset=calloc(1,sizeof(*pusch_Config->codebookSubset)); + *pusch_Config->codebookSubset = NR_PUSCH_Config__codebookSubset_nonCoherent; + pusch_Config->maxRank=calloc(1,sizeof(*pusch_Config->maxRank)); + *pusch_Config->maxRank= configuration->pusch_AntennaPorts; + pusch_Config->rbg_Size=NULL; + pusch_Config->uci_OnPUSCH=NULL; + pusch_Config->tp_pi2BPSK=NULL; - /*------------------------------TRANSFORM PRECODING- -----------------------------------------------------------------------*/ + /*------------------------------TRANSFORM PRECODING- -----------------------------------------------------------------------*/ - uint8_t transform_precoding = NR_PUSCH_Config__transformPrecoder_disabled; + uint8_t transformPrecoder = NR_PUSCH_Config__transformPrecoder_disabled; - // TBD: configure this from .conf file, Dedicated params cannot yet be configured in .conf file. - // Enable this to test transform precoding enabled from dedicated config. - /*if (pusch_Config->transformPrecoder == NULL) - pusch_Config->transformPrecoder=calloc(1,sizeof(*pusch_Config->transformPrecoder)); + // TBD: configure this from .conf file, Dedicated params cannot yet be configured in .conf file. + // Enable this to test transform precoding enabled from dedicated config. + /*if (pusch_Config->transformPrecoder == NULL) + pusch_Config->transformPrecoder=calloc(1,sizeof(*pusch_Config->transformPrecoder)); - *pusch_Config->transformPrecoder = NR_PUSCH_Config__transformPrecoder_enabled; */ + *pusch_Config->transformPrecoder = NR_PUSCH_Config__transformPrecoder_enabled; */ // END ------- - if (pusch_Config->transformPrecoder == NULL) { - if (servingcellconfigcommon->uplinkConfigCommon->initialUplinkBWP->rach_ConfigCommon->choice.setup->msg3_transformPrecoder != NULL) - transform_precoding = NR_PUSCH_Config__transformPrecoder_enabled; - } - else - transform_precoding = *pusch_Config->transformPrecoder; + if (pusch_Config->transformPrecoder == NULL) { + if (servingcellconfigcommon->uplinkConfigCommon->initialUplinkBWP->rach_ConfigCommon->choice.setup->msg3_transformPrecoder != NULL) + transformPrecoder = NR_PUSCH_Config__transformPrecoder_enabled; + } + else + transformPrecoder = *pusch_Config->transformPrecoder; - if (transform_precoding == NR_PUSCH_Config__transformPrecoder_enabled ) { + if (transformPrecoder == NR_PUSCH_Config__transformPrecoder_enabled ) { /* Enable DMRS uplink config for transform precoding enabled */ NR_DMRS_UplinkConfig->transformPrecodingEnabled = calloc(1,sizeof(*NR_DMRS_UplinkConfig->transformPrecodingEnabled)); NR_DMRS_UplinkConfig->transformPrecodingEnabled->nPUSCH_Identity = NULL; NR_DMRS_UplinkConfig->transformPrecodingEnabled->sequenceGroupHopping = NULL; NR_DMRS_UplinkConfig->transformPrecodingEnabled->sequenceHopping = NULL; NR_DMRS_UplinkConfig->transformPrecodingEnabled->ext1 = NULL; - LOG_I(RRC,"TRANSFORM PRECODING ENABLED......\n"); - } - /*----------------------------------------------------------------------------------------------------------------------------*/ - initialUplinkBWP->srs_Config = calloc(1,sizeof(*initialUplinkBWP->srs_Config)); - initialUplinkBWP->srs_Config->present = NR_SetupRelease_SRS_Config_PR_setup; - NR_SRS_Config_t *srs_Config = calloc(1,sizeof(*srs_Config)); - initialUplinkBWP->srs_Config->choice.setup=srs_Config; - srs_Config->srs_ResourceSetToReleaseList=NULL; - srs_Config->srs_ResourceSetToAddModList=calloc(1,sizeof(*srs_Config->srs_ResourceSetToAddModList)); - NR_SRS_ResourceSet_t *srs_resset0=calloc(1,sizeof(*srs_resset0)); - srs_resset0->srs_ResourceSetId = 0; - srs_resset0->srs_ResourceIdList=calloc(1,sizeof(*srs_resset0->srs_ResourceIdList)); - NR_SRS_ResourceId_t *srs_resset0_id=calloc(1,sizeof(*srs_resset0_id)); - *srs_resset0_id=0; - ASN_SEQUENCE_ADD(&srs_resset0->srs_ResourceIdList->list,srs_resset0_id); - srs_Config->srs_ResourceToReleaseList=NULL; + initialUplinkBWP->srs_Config = calloc(1,sizeof(*initialUplinkBWP->srs_Config)); + initialUplinkBWP->srs_Config->present = NR_SetupRelease_SRS_Config_PR_setup; - if(do_srs) { + NR_SRS_Config_t *srs_Config = calloc(1,sizeof(*srs_Config)); + initialUplinkBWP->srs_Config->choice.setup=srs_Config; + srs_Config->srs_ResourceSetToReleaseList=NULL; + srs_Config->srs_ResourceSetToAddModList=calloc(1,sizeof(*srs_Config->srs_ResourceSetToAddModList)); + NR_SRS_ResourceSet_t *srs_resset0=calloc(1,sizeof(*srs_resset0)); + srs_resset0->srs_ResourceSetId = 0; + srs_resset0->srs_ResourceIdList=calloc(1,sizeof(*srs_resset0->srs_ResourceIdList)); + NR_SRS_ResourceId_t *srs_resset0_id=calloc(1,sizeof(*srs_resset0_id)); + *srs_resset0_id=0; + ASN_SEQUENCE_ADD(&srs_resset0->srs_ResourceIdList->list,srs_resset0_id); + srs_Config->srs_ResourceToReleaseList=NULL; + + if (configuration->do_SRS) { srs_resset0->resourceType.present = NR_SRS_ResourceSet__resourceType_PR_periodic; srs_resset0->resourceType.choice.periodic = calloc(1,sizeof(*srs_resset0->resourceType.choice.periodic)); srs_resset0->resourceType.choice.periodic->associatedCSI_RS = NULL; @@ -784,37 +1050,37 @@ void fill_default_secondaryCellGroup(NR_ServingCellConfigCommon_t *servingcellco srs_resset0->resourceType.choice.aperiodic->ext1=NULL; } - srs_resset0->usage=NR_SRS_ResourceSet__usage_codebook; - srs_resset0->alpha = calloc(1,sizeof(*srs_resset0->alpha)); - *srs_resset0->alpha = NR_Alpha_alpha1; - srs_resset0->p0=calloc(1,sizeof(*srs_resset0->p0)); - *srs_resset0->p0=-80; - srs_resset0->pathlossReferenceRS=NULL; - srs_resset0->srs_PowerControlAdjustmentStates=NULL; - ASN_SEQUENCE_ADD(&srs_Config->srs_ResourceSetToAddModList->list,srs_resset0); - srs_Config->srs_ResourceToReleaseList=NULL; - srs_Config->srs_ResourceToAddModList=calloc(1,sizeof(*srs_Config->srs_ResourceToAddModList)); - NR_SRS_Resource_t *srs_res0=calloc(1,sizeof(*srs_res0)); - srs_res0->srs_ResourceId=0; - srs_res0->nrofSRS_Ports=NR_SRS_Resource__nrofSRS_Ports_port1; - srs_res0->ptrs_PortIndex=NULL; - srs_res0->transmissionComb.present=NR_SRS_Resource__transmissionComb_PR_n2; - srs_res0->transmissionComb.choice.n2=calloc(1,sizeof(*srs_res0->transmissionComb.choice.n2)); - srs_res0->transmissionComb.choice.n2->combOffset_n2=0; - srs_res0->transmissionComb.choice.n2->cyclicShift_n2=0; - srs_res0->resourceMapping.startPosition = 2 + uid%2; - srs_res0->resourceMapping.nrofSymbols=NR_SRS_Resource__resourceMapping__nrofSymbols_n1; - srs_res0->resourceMapping.repetitionFactor=NR_SRS_Resource__resourceMapping__repetitionFactor_n1; - srs_res0->freqDomainPosition=0; - srs_res0->freqDomainShift=0; - srs_res0->freqHopping.b_SRS=0; - srs_res0->freqHopping.b_hop=0; - srs_res0->freqHopping.c_SRS = rrc_get_max_nr_csrs( - NRRIV2BW(servingcellconfigcommon->uplinkConfigCommon->initialUplinkBWP->genericParameters.locationAndBandwidth, 275), - srs_res0->freqHopping.b_SRS); - srs_res0->groupOrSequenceHopping=NR_SRS_Resource__groupOrSequenceHopping_neither; + srs_resset0->usage=NR_SRS_ResourceSet__usage_codebook; + srs_resset0->alpha = calloc(1,sizeof(*srs_resset0->alpha)); + *srs_resset0->alpha = NR_Alpha_alpha1; + srs_resset0->p0=calloc(1,sizeof(*srs_resset0->p0)); + *srs_resset0->p0=-80; + srs_resset0->pathlossReferenceRS=NULL; + srs_resset0->srs_PowerControlAdjustmentStates=NULL; + ASN_SEQUENCE_ADD(&srs_Config->srs_ResourceSetToAddModList->list,srs_resset0); + srs_Config->srs_ResourceToReleaseList=NULL; + srs_Config->srs_ResourceToAddModList=calloc(1,sizeof(*srs_Config->srs_ResourceToAddModList)); + NR_SRS_Resource_t *srs_res0=calloc(1,sizeof(*srs_res0)); + srs_res0->srs_ResourceId=0; + srs_res0->nrofSRS_Ports=NR_SRS_Resource__nrofSRS_Ports_port1; + srs_res0->ptrs_PortIndex=NULL; + srs_res0->transmissionComb.present=NR_SRS_Resource__transmissionComb_PR_n2; + srs_res0->transmissionComb.choice.n2=calloc(1,sizeof(*srs_res0->transmissionComb.choice.n2)); + srs_res0->transmissionComb.choice.n2->combOffset_n2=0; + srs_res0->transmissionComb.choice.n2->cyclicShift_n2=0; + srs_res0->resourceMapping.startPosition = 2 + uid%2; + srs_res0->resourceMapping.nrofSymbols=NR_SRS_Resource__resourceMapping__nrofSymbols_n1; + srs_res0->resourceMapping.repetitionFactor=NR_SRS_Resource__resourceMapping__repetitionFactor_n1; + srs_res0->freqDomainPosition=0; + srs_res0->freqDomainShift=0; + srs_res0->freqHopping.b_SRS=0; + srs_res0->freqHopping.b_hop=0; + srs_res0->freqHopping.c_SRS = rrc_get_max_nr_csrs( + NRRIV2BW(servingcellconfigcommon->uplinkConfigCommon->initialUplinkBWP->genericParameters.locationAndBandwidth, 275), + srs_res0->freqHopping.b_SRS); + srs_res0->groupOrSequenceHopping=NR_SRS_Resource__groupOrSequenceHopping_neither; - if(do_srs) { + if (configuration->do_SRS) { srs_res0->resourceType.present= NR_SRS_Resource__resourceType_PR_periodic; srs_res0->resourceType.choice.periodic=calloc(1,sizeof(*srs_res0->resourceType.choice.periodic)); srs_res0->resourceType.choice.periodic->periodicityAndOffset_p.present = NR_SRS_PeriodicityAndOffset_PR_sl160; @@ -824,174 +1090,52 @@ void fill_default_secondaryCellGroup(NR_ServingCellConfigCommon_t *servingcellco srs_res0->resourceType.choice.aperiodic=calloc(1,sizeof(*srs_res0->resourceType.choice.aperiodic)); } - srs_res0->sequenceId=40; - srs_res0->spatialRelationInfo=calloc(1,sizeof(*srs_res0->spatialRelationInfo)); - srs_res0->spatialRelationInfo->servingCellId=NULL; - srs_res0->spatialRelationInfo->referenceSignal.present=NR_SRS_SpatialRelationInfo__referenceSignal_PR_csi_RS_Index; - srs_res0->spatialRelationInfo->referenceSignal.choice.csi_RS_Index=0; - ASN_SEQUENCE_ADD(&srs_Config->srs_ResourceToAddModList->list,srs_res0); + srs_res0->sequenceId=40; + srs_res0->spatialRelationInfo=calloc(1,sizeof(*srs_res0->spatialRelationInfo)); + srs_res0->spatialRelationInfo->servingCellId=NULL; + srs_res0->spatialRelationInfo->referenceSignal.present=NR_SRS_SpatialRelationInfo__referenceSignal_PR_csi_RS_Index; + srs_res0->spatialRelationInfo->referenceSignal.choice.csi_RS_Index=0; + ASN_SEQUENCE_ADD(&srs_Config->srs_ResourceToAddModList->list,srs_res0); - secondaryCellGroup->spCellConfig->spCellConfigDedicated->uplinkConfig->uplinkBWP_ToReleaseList = NULL; - NR_BWP_Uplink_t *ubwp = NULL; - if (servingcellconfigdedicated) { - ubwp = servingcellconfigdedicated->uplinkConfig->uplinkBWP_ToAddModList->list.array[0]; - } else { - secondaryCellGroup->spCellConfig->spCellConfigDedicated->uplinkConfig->uplinkBWP_ToAddModList = calloc(1,sizeof(*secondaryCellGroup->spCellConfig->spCellConfigDedicated->uplinkConfig->uplinkBWP_ToAddModList)); - ubwp = calloc(1,sizeof(*ubwp)); - } - ubwp->bwp_Id=1; - ubwp->bwp_Common = calloc(1,sizeof(*ubwp->bwp_Common)); - // copy bwp_Common from Initial UL BWP except for bandwidth - memcpy((void*)&ubwp->bwp_Common->genericParameters, - (void*)&servingcellconfigcommon->uplinkConfigCommon->initialUplinkBWP->genericParameters, - sizeof(servingcellconfigcommon->uplinkConfigCommon->initialUplinkBWP->genericParameters)); - ubwp->bwp_Common->genericParameters.locationAndBandwidth=PRBalloc_to_locationandbandwidth(servingcellconfigcommon->uplinkConfigCommon->frequencyInfoUL->scs_SpecificCarrierList.list.array[0]->carrierBandwidth,0); + /// Dedicated BWPs - ubwp->bwp_Common->rach_ConfigCommon = servingcellconfigcommon->uplinkConfigCommon->initialUplinkBWP->rach_ConfigCommon; - ubwp->bwp_Common->pusch_ConfigCommon = servingcellconfigcommon->uplinkConfigCommon->initialUplinkBWP->pusch_ConfigCommon; - ubwp->bwp_Common->pucch_ConfigCommon = servingcellconfigcommon->uplinkConfigCommon->initialUplinkBWP->pucch_ConfigCommon; - - if (!servingcellconfigdedicated) { - ubwp->bwp_Dedicated = calloc(1,sizeof(*ubwp->bwp_Dedicated)); - } - ubwp->bwp_Dedicated->pucch_Config = calloc(1,sizeof(*ubwp->bwp_Dedicated->pucch_Config)); - ubwp->bwp_Dedicated->pucch_Config->present = NR_SetupRelease_PUCCH_Config_PR_setup; - NR_PUCCH_Config_t *pucch_Config = calloc(1,sizeof(*pucch_Config)); - ubwp->bwp_Dedicated->pucch_Config->choice.setup=pucch_Config; - pucch_Config->resourceSetToAddModList = calloc(1,sizeof(*pucch_Config->resourceSetToAddModList)); - pucch_Config->resourceSetToReleaseList = NULL; - NR_PUCCH_ResourceSet_t *pucchresset0=calloc(1,sizeof(*pucchresset0)); - NR_PUCCH_ResourceSet_t *pucchresset1=calloc(1,sizeof(*pucchresset1)); - pucchresset0->pucch_ResourceSetId = 0; - NR_PUCCH_ResourceId_t *pucchresset0id0=calloc(1,sizeof(*pucchresset0id0)); - *pucchresset0id0=1; - ASN_SEQUENCE_ADD(&pucchresset0->resourceList.list,pucchresset0id0); - pucchresset0->maxPayloadSize=NULL; + // Downlink BWPs + int n_dl_bwp = 1; + if (servingcellconfigdedicated && servingcellconfigdedicated->downlinkBWP_ToAddModList) { + n_dl_bwp = servingcellconfigdedicated->downlinkBWP_ToAddModList->list.count; + } + if(n_dl_bwp>0) { + secondaryCellGroup->spCellConfig->spCellConfigDedicated->downlinkBWP_ToAddModList = calloc(1,sizeof(*secondaryCellGroup->spCellConfig->spCellConfigDedicated->downlinkBWP_ToAddModList)); + for (int bwp_loop = 0; bwp_loop < n_dl_bwp; bwp_loop++) { + NR_BWP_Downlink_t *bwp = calloc(1,sizeof(*bwp)); + fill_default_nsa_downlinkBWP(bwp, bwp_loop, secondaryCellGroup, servingcellconfigdedicated, servingcellconfigcommon, configuration, uecap, dl_antenna_ports, bitmap); + ASN_SEQUENCE_ADD(&secondaryCellGroup->spCellConfig->spCellConfigDedicated->downlinkBWP_ToAddModList->list,bwp); + } + secondaryCellGroup->spCellConfig->spCellConfigDedicated->firstActiveDownlinkBWP_Id = calloc(1,sizeof(*secondaryCellGroup->spCellConfig->spCellConfigDedicated->firstActiveDownlinkBWP_Id)); + *secondaryCellGroup->spCellConfig->spCellConfigDedicated->firstActiveDownlinkBWP_Id = servingcellconfigdedicated->firstActiveDownlinkBWP_Id ? *servingcellconfigdedicated->firstActiveDownlinkBWP_Id : 1; + secondaryCellGroup->spCellConfig->spCellConfigDedicated->defaultDownlinkBWP_Id = calloc(1, sizeof(*secondaryCellGroup->spCellConfig->spCellConfigDedicated->defaultDownlinkBWP_Id)); + *secondaryCellGroup->spCellConfig->spCellConfigDedicated->defaultDownlinkBWP_Id = servingcellconfigdedicated->defaultDownlinkBWP_Id ? *servingcellconfigdedicated->defaultDownlinkBWP_Id : 1; + } - ASN_SEQUENCE_ADD(&pucch_Config->resourceSetToAddModList->list,pucchresset0); + // Uplink BWPs + int n_ul_bwp = 1; + if (servingcellconfigdedicated && servingcellconfigdedicated->uplinkConfig && servingcellconfigdedicated->uplinkConfig->uplinkBWP_ToAddModList) { + n_ul_bwp = servingcellconfigdedicated->uplinkConfig->uplinkBWP_ToAddModList->list.count; + } + if(n_ul_bwp>0) { + secondaryCellGroup->spCellConfig->spCellConfigDedicated->uplinkConfig->uplinkBWP_ToAddModList = calloc(1,sizeof(*secondaryCellGroup->spCellConfig->spCellConfigDedicated->uplinkConfig->uplinkBWP_ToAddModList)); + for (int bwp_loop = 0; bwp_loop < n_ul_bwp; bwp_loop++) { + NR_BWP_Uplink_t *ubwp = calloc(1,sizeof(*ubwp)); + fill_default_nsa_uplinkBWP(ubwp, bwp_loop, servingcellconfigdedicated, servingcellconfigcommon, configuration, uid); + ASN_SEQUENCE_ADD(&secondaryCellGroup->spCellConfig->spCellConfigDedicated->uplinkConfig->uplinkBWP_ToAddModList->list,ubwp); + } + secondaryCellGroup->spCellConfig->spCellConfigDedicated->uplinkConfig->firstActiveUplinkBWP_Id = calloc(1,sizeof(*secondaryCellGroup->spCellConfig->spCellConfigDedicated->uplinkConfig->firstActiveUplinkBWP_Id)); + *secondaryCellGroup->spCellConfig->spCellConfigDedicated->uplinkConfig->firstActiveUplinkBWP_Id = servingcellconfigdedicated->uplinkConfig->firstActiveUplinkBWP_Id ? *servingcellconfigdedicated->uplinkConfig->firstActiveUplinkBWP_Id : 1; + } - pucchresset1->pucch_ResourceSetId = 1; - NR_PUCCH_ResourceId_t *pucchresset1id0=calloc(1,sizeof(*pucchresset1id0)); - *pucchresset1id0=2; - ASN_SEQUENCE_ADD(&pucchresset1->resourceList.list,pucchresset1id0); - pucchresset1->maxPayloadSize=NULL; - ASN_SEQUENCE_ADD(&pucch_Config->resourceSetToAddModList->list,pucchresset1); - - pucch_Config->resourceToAddModList = calloc(1,sizeof(*pucch_Config->resourceToAddModList)); - pucch_Config->resourceToReleaseList = NULL; - NR_PUCCH_Resource_t *pucchres0=calloc(1,sizeof(*pucchres0)); - NR_PUCCH_Resource_t *pucchres2=calloc(1,sizeof(*pucchres2)); - - pucchres0->pucch_ResourceId=1; - pucchres0->startingPRB= (8 + uid) % curr_bwp; - pucchres0->intraSlotFrequencyHopping=NULL; - pucchres0->secondHopPRB=NULL; - pucchres0->format.present= NR_PUCCH_Resource__format_PR_format0; - pucchres0->format.choice.format0=calloc(1,sizeof(*pucchres0->format.choice.format0)); - pucchres0->format.choice.format0->initialCyclicShift=0; - pucchres0->format.choice.format0->nrofSymbols=1; - pucchres0->format.choice.format0->startingSymbolIndex=13; - ASN_SEQUENCE_ADD(&pucch_Config->resourceToAddModList->list,pucchres0); - - pucchres2->pucch_ResourceId=2; - pucchres2->startingPRB=0; - pucchres2->intraSlotFrequencyHopping=NULL; - pucchres2->secondHopPRB=NULL; - pucchres2->format.present= NR_PUCCH_Resource__format_PR_format2; - pucchres2->format.choice.format2=calloc(1,sizeof(*pucchres2->format.choice.format2)); - pucchres2->format.choice.format2->nrofPRBs=8; - pucchres2->format.choice.format2->nrofSymbols=1; - pucchres2->format.choice.format2->startingSymbolIndex=13; - ASN_SEQUENCE_ADD(&pucch_Config->resourceToAddModList->list,pucchres2); - - pucch_Config->format2=calloc(1,sizeof(*pucch_Config->format2)); - pucch_Config->format2->present=NR_SetupRelease_PUCCH_FormatConfig_PR_setup; - NR_PUCCH_FormatConfig_t *pucchfmt2 = calloc(1,sizeof(*pucchfmt2)); - pucch_Config->format2->choice.setup = pucchfmt2; - pucchfmt2->interslotFrequencyHopping=NULL; - pucchfmt2->additionalDMRS=NULL; - pucchfmt2->maxCodeRate=calloc(1,sizeof(*pucchfmt2->maxCodeRate)); - *pucchfmt2->maxCodeRate=NR_PUCCH_MaxCodeRate_zeroDot35; - pucchfmt2->nrofSlots=NULL; - pucchfmt2->pi2BPSK=NULL; - pucchfmt2->simultaneousHARQ_ACK_CSI=calloc(1,sizeof(*pucchfmt2->simultaneousHARQ_ACK_CSI)); - *pucchfmt2->simultaneousHARQ_ACK_CSI=NR_PUCCH_FormatConfig__simultaneousHARQ_ACK_CSI_true; - - // for scheduling requestresource - pucch_Config->schedulingRequestResourceToAddModList = calloc(1,sizeof(*pucch_Config->schedulingRequestResourceToAddModList)); - NR_SchedulingRequestResourceConfig_t *schedulingRequestResourceConfig = calloc(1,sizeof(*schedulingRequestResourceConfig)); - schedulingRequestResourceConfig->schedulingRequestResourceId = 1; - schedulingRequestResourceConfig->schedulingRequestID = 0; - schedulingRequestResourceConfig->periodicityAndOffset = calloc(1,sizeof(*schedulingRequestResourceConfig->periodicityAndOffset)); - schedulingRequestResourceConfig->periodicityAndOffset->present = NR_SchedulingRequestResourceConfig__periodicityAndOffset_PR_sl10; - schedulingRequestResourceConfig->periodicityAndOffset->choice.sl10 = 7; - schedulingRequestResourceConfig->resource = calloc(1,sizeof(*schedulingRequestResourceConfig->resource)); - *schedulingRequestResourceConfig->resource = 1; - ASN_SEQUENCE_ADD(&pucch_Config->schedulingRequestResourceToAddModList->list,schedulingRequestResourceConfig); - - pucch_Config->schedulingRequestResourceToReleaseList=NULL; - pucch_Config->multi_CSI_PUCCH_ResourceList=NULL; - pucch_Config->dl_DataToUL_ACK = calloc(1,sizeof(*pucch_Config->dl_DataToUL_ACK)); - long *delay[8]; - for (int i=0;i<8;i++) { - delay[i] = calloc(1,sizeof(*delay[i])); - *delay[i] = i+minRXTXTIME; - ASN_SEQUENCE_ADD(&pucch_Config->dl_DataToUL_ACK->list,delay[i]); - } - pucch_Config->spatialRelationInfoToAddModList = calloc(1,sizeof(*pucch_Config->spatialRelationInfoToAddModList)); - NR_PUCCH_SpatialRelationInfo_t *pucchspatial = calloc(1,sizeof(*pucchspatial)); - pucchspatial->pucch_SpatialRelationInfoId = 1; - pucchspatial->servingCellId = NULL; - if(do_csirs) { - pucchspatial->referenceSignal.present = NR_PUCCH_SpatialRelationInfo__referenceSignal_PR_csi_RS_Index; - pucchspatial->referenceSignal.choice.csi_RS_Index = 0; - } - else { - pucchspatial->referenceSignal.present = NR_PUCCH_SpatialRelationInfo__referenceSignal_PR_ssb_Index; - pucchspatial->referenceSignal.choice.ssb_Index = 0; - } - pucchspatial->pucch_PathlossReferenceRS_Id = 0; - pucchspatial->p0_PUCCH_Id = 1; - pucchspatial->closedLoopIndex = NR_PUCCH_SpatialRelationInfo__closedLoopIndex_i0; - ASN_SEQUENCE_ADD(&pucch_Config->spatialRelationInfoToAddModList->list,pucchspatial); - pucch_Config->spatialRelationInfoToReleaseList=NULL; - pucch_Config->pucch_PowerControl=calloc(1,sizeof(*pucch_Config->pucch_PowerControl)); - pucch_Config->pucch_PowerControl->deltaF_PUCCH_f0 = calloc(1,sizeof(*pucch_Config->pucch_PowerControl->deltaF_PUCCH_f0)); - *pucch_Config->pucch_PowerControl->deltaF_PUCCH_f0 = 0; - pucch_Config->pucch_PowerControl->deltaF_PUCCH_f1 = calloc(1,sizeof(*pucch_Config->pucch_PowerControl->deltaF_PUCCH_f1)); - *pucch_Config->pucch_PowerControl->deltaF_PUCCH_f1 = 0; - pucch_Config->pucch_PowerControl->deltaF_PUCCH_f2 = calloc(1,sizeof(*pucch_Config->pucch_PowerControl->deltaF_PUCCH_f2)); - *pucch_Config->pucch_PowerControl->deltaF_PUCCH_f2 = 0; - pucch_Config->pucch_PowerControl->deltaF_PUCCH_f3 = calloc(1,sizeof(*pucch_Config->pucch_PowerControl->deltaF_PUCCH_f3)); - *pucch_Config->pucch_PowerControl->deltaF_PUCCH_f3 = 0; - pucch_Config->pucch_PowerControl->deltaF_PUCCH_f4 = calloc(1,sizeof(*pucch_Config->pucch_PowerControl->deltaF_PUCCH_f4)); - *pucch_Config->pucch_PowerControl->deltaF_PUCCH_f4 = 0; - pucch_Config->pucch_PowerControl->p0_Set = calloc(1,sizeof(*pucch_Config->pucch_PowerControl->p0_Set)); - NR_P0_PUCCH_t *p00 = calloc(1,sizeof(*p00)); - p00->p0_PUCCH_Id=1; - p00->p0_PUCCH_Value = 0; - ASN_SEQUENCE_ADD(&pucch_Config->pucch_PowerControl->p0_Set->list,p00); - pucch_Config->pucch_PowerControl->pathlossReferenceRSs = NULL; - - if (!servingcellconfigdedicated) { - // copy pusch_Config from dedicated initialBWP - ubwp->bwp_Dedicated->pusch_Config = calloc(1,sizeof(*ubwp->bwp_Dedicated->pusch_Config)); - ubwp->bwp_Dedicated->pusch_Config->present = NR_SetupRelease_PUSCH_Config_PR_setup; - ubwp->bwp_Dedicated->pusch_Config->choice.setup = pusch_Config; - } - ubwp->bwp_Dedicated->configuredGrantConfig = NULL; - ubwp->bwp_Dedicated->srs_Config = calloc(1,sizeof(*ubwp->bwp_Dedicated->srs_Config)); - ubwp->bwp_Dedicated->srs_Config->present = NR_SetupRelease_SRS_Config_PR_setup; - ubwp->bwp_Dedicated->srs_Config->choice.setup = srs_Config; - - ubwp->bwp_Dedicated->beamFailureRecoveryConfig = NULL; - - if (!servingcellconfigdedicated) { - ASN_SEQUENCE_ADD(&secondaryCellGroup->spCellConfig->spCellConfigDedicated->uplinkConfig->uplinkBWP_ToAddModList->list,ubwp); - } - - secondaryCellGroup->spCellConfig->spCellConfigDedicated->uplinkConfig->firstActiveUplinkBWP_Id = calloc(1,sizeof(*secondaryCellGroup->spCellConfig->spCellConfigDedicated->uplinkConfig->firstActiveUplinkBWP_Id)); - *secondaryCellGroup->spCellConfig->spCellConfigDedicated->uplinkConfig->firstActiveUplinkBWP_Id = 1; + secondaryCellGroup->spCellConfig->spCellConfigDedicated->bwp_InactivityTimer = NULL; + secondaryCellGroup->spCellConfig->spCellConfigDedicated->downlinkBWP_ToReleaseList= NULL; + secondaryCellGroup->spCellConfig->spCellConfigDedicated->uplinkConfig->uplinkBWP_ToReleaseList = NULL; secondaryCellGroup->spCellConfig->spCellConfigDedicated->uplinkConfig->pusch_ServingCellConfig = calloc(1,sizeof(*secondaryCellGroup->spCellConfig->spCellConfigDedicated->uplinkConfig->pusch_ServingCellConfig)); NR_PUSCH_ServingCellConfig_t *pusch_scc = calloc(1,sizeof(*pusch_scc)); @@ -1006,9 +1150,7 @@ void fill_default_secondaryCellGroup(NR_ServingCellConfigCommon_t *servingcellco pusch_scc->ext1->processingType2Enabled = NULL; secondaryCellGroup->spCellConfig->spCellConfigDedicated->uplinkConfig->carrierSwitching = NULL; - secondaryCellGroup->spCellConfig->spCellConfigDedicated->supplementaryUplink=NULL; - secondaryCellGroup->spCellConfig->spCellConfigDedicated->pdcch_ServingCellConfig=NULL; secondaryCellGroup->spCellConfig->spCellConfigDedicated->pdsch_ServingCellConfig=calloc(1,sizeof(*secondaryCellGroup->spCellConfig->spCellConfigDedicated->pdsch_ServingCellConfig)); @@ -1032,56 +1174,9 @@ void fill_default_secondaryCellGroup(NR_ServingCellConfigCommon_t *servingcellco NR_CSI_MeasConfig_t *csi_MeasConfig = calloc(1,sizeof(*csi_MeasConfig)); secondaryCellGroup->spCellConfig->spCellConfigDedicated->csi_MeasConfig->choice.setup = csi_MeasConfig; - if (do_csirs && dl_antenna_ports > 1) { - csi_MeasConfig->csi_IM_ResourceToAddModList = calloc(1,sizeof(*csi_MeasConfig->csi_IM_ResourceToAddModList)); - NR_CSI_IM_Resource_t *imres0 = calloc(1,sizeof(*imres0)); - imres0->csi_IM_ResourceId = 0; - imres0->csi_IM_ResourceElementPattern = calloc(1,sizeof(*imres0->csi_IM_ResourceElementPattern)); - imres0->csi_IM_ResourceElementPattern->present = NR_CSI_IM_Resource__csi_IM_ResourceElementPattern_PR_pattern1; - imres0->csi_IM_ResourceElementPattern->choice.pattern1 = calloc(1,sizeof(*imres0->csi_IM_ResourceElementPattern->choice.pattern1)); - imres0->csi_IM_ResourceElementPattern->choice.pattern1->subcarrierLocation_p1 = NR_CSI_IM_Resource__csi_IM_ResourceElementPattern__pattern1__subcarrierLocation_p1_s4; - imres0->csi_IM_ResourceElementPattern->choice.pattern1->symbolLocation_p1 = 6; - imres0->freqBand = calloc(1,sizeof(*imres0->freqBand)); - imres0->freqBand->startingRB = 0; - imres0->freqBand->nrofRBs = ((curr_bwp>>2)+(curr_bwp%4>0))<<2; - imres0->periodicityAndOffset = calloc(1,sizeof(*imres0->periodicityAndOffset)); - imres0->periodicityAndOffset->present = NR_CSI_ResourcePeriodicityAndOffset_PR_slots320; - imres0->periodicityAndOffset->choice.slots320 = 0; - ASN_SEQUENCE_ADD(&csi_MeasConfig->csi_IM_ResourceToAddModList->list,imres0); - csi_MeasConfig->csi_IM_ResourceSetToAddModList = calloc(1,sizeof(*csi_MeasConfig->csi_IM_ResourceSetToAddModList)); - NR_CSI_IM_ResourceSet_t *imset0 = calloc(1,sizeof(*imset0)); - imset0->csi_IM_ResourceSetId = 0; - NR_CSI_IM_ResourceId_t *res0 = calloc(1,sizeof(*res0)); - *res0 = 0; - ASN_SEQUENCE_ADD(&imset0->csi_IM_Resources,res0); - ASN_SEQUENCE_ADD(&csi_MeasConfig->csi_IM_ResourceSetToAddModList->list,imset0); - } - else { - csi_MeasConfig->csi_IM_ResourceToAddModList = NULL; - csi_MeasConfig->csi_IM_ResourceSetToAddModList = NULL; - } - - csi_MeasConfig->csi_IM_ResourceToReleaseList = NULL; - csi_MeasConfig->csi_IM_ResourceSetToReleaseList = NULL; - - if (do_csirs) { - csi_MeasConfig->nzp_CSI_RS_ResourceSetToAddModList = calloc(1,sizeof(*csi_MeasConfig->nzp_CSI_RS_ResourceSetToAddModList)); - NR_NZP_CSI_RS_ResourceSet_t *nzpcsirs0 = calloc(1,sizeof(*nzpcsirs0)); - nzpcsirs0->nzp_CSI_ResourceSetId = 0; - NR_NZP_CSI_RS_ResourceId_t *nzpid0 = calloc(1,sizeof(*nzpid0)); - *nzpid0 = 0; - ASN_SEQUENCE_ADD(&nzpcsirs0->nzp_CSI_RS_Resources,nzpid0); - nzpcsirs0->repetition = NULL; - nzpcsirs0->aperiodicTriggeringOffset = NULL; - nzpcsirs0->trs_Info = NULL; - ASN_SEQUENCE_ADD(&csi_MeasConfig->nzp_CSI_RS_ResourceSetToAddModList->list,nzpcsirs0); - } - else - csi_MeasConfig->nzp_CSI_RS_ResourceSetToAddModList = NULL; - - csi_MeasConfig->nzp_CSI_RS_ResourceSetToReleaseList = NULL; - - config_csirs(servingcellconfigcommon, csi_MeasConfig,dl_antenna_ports,curr_bwp,do_csirs); + int curr_bwp = NRRIV2BW(PRBalloc_to_locationandbandwidth(servingcellconfigcommon->downlinkConfigCommon->frequencyInfoDL->scs_SpecificCarrierList.list.array[0]->carrierBandwidth,0),275); + config_csirs(servingcellconfigcommon, csi_MeasConfig, uid, dl_antenna_ports, curr_bwp, do_csirs); + config_csiim(do_csirs, dl_antenna_ports, curr_bwp, csi_MeasConfig); csi_MeasConfig->csi_SSB_ResourceSetToAddModList = calloc(1,sizeof(*csi_MeasConfig->csi_SSB_ResourceSetToAddModList)); csi_MeasConfig->csi_SSB_ResourceSetToReleaseList = NULL; @@ -1100,9 +1195,9 @@ void fill_default_secondaryCellGroup(NR_ServingCellConfigCommon_t *servingcellco ASN_SEQUENCE_ADD(&csi_MeasConfig->csi_SSB_ResourceSetToAddModList->list,ssbresset0); csi_MeasConfig->csi_ResourceConfigToAddModList = calloc(1,sizeof(*csi_MeasConfig->csi_ResourceConfigToAddModList)); + csi_MeasConfig->csi_ResourceConfigToReleaseList = NULL; if (do_csirs) { - csi_MeasConfig->csi_ResourceConfigToReleaseList = NULL; NR_CSI_ResourceConfig_t *csires0 = calloc(1,sizeof(*csires0)); csires0->csi_ResourceConfigId=0; csires0->csi_RS_ResourceSetList.present = NR_CSI_ResourceConfig__csi_RS_ResourceSetList_PR_nzp_CSI_RS_SSB; @@ -1180,19 +1275,50 @@ void fill_default_secondaryCellGroup(NR_ServingCellConfigCommon_t *servingcellco csirep1->codebookConfig->codebookType.choice.type1 = calloc(1,sizeof(*csirep1->codebookConfig->codebookType.choice.type1)); csirep1->codebookConfig->codebookType.choice.type1->subType.present=NR_CodebookConfig__codebookType__type1__subType_PR_typeI_SinglePanel; csirep1->codebookConfig->codebookType.choice.type1->subType.choice.typeI_SinglePanel=calloc(1,sizeof(*csirep1->codebookConfig->codebookType.choice.type1->subType.choice.typeI_SinglePanel)); - csirep1->codebookConfig->codebookType.choice.type1->subType.choice.typeI_SinglePanel->nrOfAntennaPorts.present= - NR_CodebookConfig__codebookType__type1__subType__typeI_SinglePanel__nrOfAntennaPorts_PR_two; - csirep1->codebookConfig->codebookType.choice.type1->subType.choice.typeI_SinglePanel->nrOfAntennaPorts.choice.two= - calloc(1,sizeof(*csirep1->codebookConfig->codebookType.choice.type1->subType.choice.typeI_SinglePanel->nrOfAntennaPorts.choice.two)); - csirep1->codebookConfig->codebookType.choice.type1->subType.choice.typeI_SinglePanel->nrOfAntennaPorts.choice.two->twoTX_CodebookSubsetRestriction.size=1; - csirep1->codebookConfig->codebookType.choice.type1->subType.choice.typeI_SinglePanel->nrOfAntennaPorts.choice.two->twoTX_CodebookSubsetRestriction.bits_unused=2; - csirep1->codebookConfig->codebookType.choice.type1->subType.choice.typeI_SinglePanel->nrOfAntennaPorts.choice.two->twoTX_CodebookSubsetRestriction.buf=malloc(1); - csirep1->codebookConfig->codebookType.choice.type1->subType.choice.typeI_SinglePanel->nrOfAntennaPorts.choice.two->twoTX_CodebookSubsetRestriction.buf[0]=0xfc; - csirep1->codebookConfig->codebookType.choice.type1->subType.choice.typeI_SinglePanel->typeI_SinglePanel_ri_Restriction.size=1; - csirep1->codebookConfig->codebookType.choice.type1->subType.choice.typeI_SinglePanel->typeI_SinglePanel_ri_Restriction.bits_unused=0; - csirep1->codebookConfig->codebookType.choice.type1->subType.choice.typeI_SinglePanel->typeI_SinglePanel_ri_Restriction.buf=malloc(1); - csirep1->codebookConfig->codebookType.choice.type1->subType.choice.typeI_SinglePanel->typeI_SinglePanel_ri_Restriction.buf[0]=0x03; - csirep1->codebookConfig->codebookType.choice.type1->codebookMode=1; + if (dl_antenna_ports == 2) { + csirep1->codebookConfig->codebookType.choice.type1->subType.choice.typeI_SinglePanel->nrOfAntennaPorts.present= + NR_CodebookConfig__codebookType__type1__subType__typeI_SinglePanel__nrOfAntennaPorts_PR_two; + csirep1->codebookConfig->codebookType.choice.type1->subType.choice.typeI_SinglePanel->nrOfAntennaPorts.choice.two= + calloc(1,sizeof(*csirep1->codebookConfig->codebookType.choice.type1->subType.choice.typeI_SinglePanel->nrOfAntennaPorts.choice.two)); + csirep1->codebookConfig->codebookType.choice.type1->subType.choice.typeI_SinglePanel->nrOfAntennaPorts.choice.two->twoTX_CodebookSubsetRestriction.size=1; + csirep1->codebookConfig->codebookType.choice.type1->subType.choice.typeI_SinglePanel->nrOfAntennaPorts.choice.two->twoTX_CodebookSubsetRestriction.bits_unused=2; + csirep1->codebookConfig->codebookType.choice.type1->subType.choice.typeI_SinglePanel->nrOfAntennaPorts.choice.two->twoTX_CodebookSubsetRestriction.buf=malloc(1); + csirep1->codebookConfig->codebookType.choice.type1->subType.choice.typeI_SinglePanel->nrOfAntennaPorts.choice.two->twoTX_CodebookSubsetRestriction.buf[0]=0xfc; + csirep1->codebookConfig->codebookType.choice.type1->subType.choice.typeI_SinglePanel->typeI_SinglePanel_ri_Restriction.size=1; + csirep1->codebookConfig->codebookType.choice.type1->subType.choice.typeI_SinglePanel->typeI_SinglePanel_ri_Restriction.bits_unused=0; + csirep1->codebookConfig->codebookType.choice.type1->subType.choice.typeI_SinglePanel->typeI_SinglePanel_ri_Restriction.buf=malloc(1); + csirep1->codebookConfig->codebookType.choice.type1->subType.choice.typeI_SinglePanel->typeI_SinglePanel_ri_Restriction.buf[0]=0x03; + csirep1->codebookConfig->codebookType.choice.type1->codebookMode=1; + } else if (dl_antenna_ports < 16) { + csirep1->codebookConfig->codebookType.choice.type1->subType.choice.typeI_SinglePanel->nrOfAntennaPorts.present= + NR_CodebookConfig__codebookType__type1__subType__typeI_SinglePanel__nrOfAntennaPorts_PR_moreThanTwo; + csirep1->codebookConfig->codebookType.choice.type1->subType.choice.typeI_SinglePanel->nrOfAntennaPorts.choice.moreThanTwo= + calloc(1,sizeof(*csirep1->codebookConfig->codebookType.choice.type1->subType.choice.typeI_SinglePanel->nrOfAntennaPorts.choice.moreThanTwo)); + if(dl_antenna_ports == 4) + csirep1->codebookConfig->codebookType.choice.type1->subType.choice.typeI_SinglePanel->nrOfAntennaPorts.choice.moreThanTwo->n1_n2.present= + NR_CodebookConfig__codebookType__type1__subType__typeI_SinglePanel__nrOfAntennaPorts__moreThanTwo__n1_n2_PR_two_one_TypeI_SinglePanel_Restriction; + else if(dl_antenna_ports == 8) + csirep1->codebookConfig->codebookType.choice.type1->subType.choice.typeI_SinglePanel->nrOfAntennaPorts.choice.moreThanTwo->n1_n2.present= + NR_CodebookConfig__codebookType__type1__subType__typeI_SinglePanel__nrOfAntennaPorts__moreThanTwo__n1_n2_PR_four_one_TypeI_SinglePanel_Restriction; + else if(dl_antenna_ports == 12) + csirep1->codebookConfig->codebookType.choice.type1->subType.choice.typeI_SinglePanel->nrOfAntennaPorts.choice.moreThanTwo->n1_n2.present= + NR_CodebookConfig__codebookType__type1__subType__typeI_SinglePanel__nrOfAntennaPorts__moreThanTwo__n1_n2_PR_six_one_TypeI_SinglePanel_Restriction; + else//default + csirep1->codebookConfig->codebookType.choice.type1->subType.choice.typeI_SinglePanel->nrOfAntennaPorts.choice.moreThanTwo->n1_n2.present= + NR_CodebookConfig__codebookType__type1__subType__typeI_SinglePanel__nrOfAntennaPorts__moreThanTwo__n1_n2_PR_two_one_TypeI_SinglePanel_Restriction; + + /*csirep1->codebookConfig->codebookType.choice.type1->subType.choice.typeI_SinglePanel->nrOfAntennaPorts.choice.moreThanTwo->n1_n2.choice.two_one_TypeI_SinglePanel_Restriction.size=1; + csirep1->codebookConfig->codebookType.choice.type1->subType.choice.typeI_SinglePanel->nrOfAntennaPorts.choice.moreThanTwo->n1_n2.choice.two_one_TypeI_SinglePanel_Restriction.bits_unused=1; + csirep1->codebookConfig->codebookType.choice.type1->subType.choice.typeI_SinglePanel->nrOfAntennaPorts.choice.moreThanTwo->n1_n2.choice.two_one_TypeI_SinglePanel_Restriction.buf=malloc(1); + csirep1->codebookConfig->codebookType.choice.type1->subType.choice.typeI_SinglePanel->nrOfAntennaPorts.choice.moreThanTwo->n1_n2.choice.two_one_TypeI_SinglePanel_Restriction.buf[0]=0xc0; //'00000011'B + csirep1->codebookConfig->codebookType.choice.type1->subType.choice.typeI_SinglePanel->nrOfAntennaPorts.choice.moreThanTwo->typeI_SinglePanel_codebookSubsetRestriction_i2->size = 1; + csirep1->codebookConfig->codebookType.choice.type1->subType.choice.typeI_SinglePanel->nrOfAntennaPorts.choice.moreThanTwo->typeI_SinglePanel_codebookSubsetRestriction_i2->bits_unused=1; + csirep1->codebookConfig->codebookType.choice.type1->subType.choice.typeI_SinglePanel->nrOfAntennaPorts.choice.moreThanTwo->typeI_SinglePanel_codebookSubsetRestriction_i2->buf=malloc(1); + csirep1->codebookConfig->codebookType.choice.type1->subType.choice.typeI_SinglePanel->nrOfAntennaPorts.choice.moreThanTwo->typeI_SinglePanel_codebookSubsetRestriction_i2->buf[0]=0xc0;*/ + csirep1->codebookConfig->codebookType.choice.type1->codebookMode=1; + } else {//32 antennas are Not implemented yet + csirep1->codebookConfig->codebookType.choice.type1->codebookMode=2; + } csirep1->dummy = NULL; csirep1->groupBasedBeamReporting.present = NR_CSI_ReportConfig__groupBasedBeamReporting_PR_disabled; csirep1->groupBasedBeamReporting.choice.disabled=calloc(1,sizeof(*csirep1->groupBasedBeamReporting.choice.disabled)); @@ -1252,10 +1378,7 @@ void fill_default_secondaryCellGroup(NR_ServingCellConfigCommon_t *servingcellco ASN_SEQUENCE_ADD(&csirep2->reportConfigType.choice.periodic->pucch_CSI_ResourceList.list,pucchcsires1); csirep2->reportQuantity.present = NR_CSI_ReportConfig__reportQuantity_PR_ssb_Index_RSRP; csirep2->reportQuantity.choice.ssb_Index_RSRP=(NULL_t)0; - csirep2->reportFreqConfiguration = calloc(1,sizeof(*csirep2->reportFreqConfiguration)); - csirep2->reportFreqConfiguration->cqi_FormatIndicator=NR_CSI_ReportConfig__reportFreqConfiguration__cqi_FormatIndicator_widebandCQI; - csirep2->reportFreqConfiguration->pmi_FormatIndicator=NR_CSI_ReportConfig__reportFreqConfiguration__pmi_FormatIndicator_widebandPMI; - csirep2->reportFreqConfiguration->csi_ReportingBand=NULL; + csirep2->reportFreqConfiguration = NULL; csirep2->timeRestrictionForChannelMeasurements= NR_CSI_ReportConfig__timeRestrictionForChannelMeasurements_configured; csirep2->timeRestrictionForInterferenceMeasurements=NR_CSI_ReportConfig__timeRestrictionForInterferenceMeasurements_configured; csirep2->codebookConfig= NULL; @@ -1279,74 +1402,19 @@ void fill_default_secondaryCellGroup(NR_ServingCellConfigCommon_t *servingcellco secondaryCellGroup->spCellConfig->spCellConfigDedicated->pathlossReferenceLinking=NULL; secondaryCellGroup->spCellConfig->spCellConfigDedicated->servingCellMO=NULL; + *servingcellconfigdedicated = *secondaryCellGroup->spCellConfig->spCellConfigDedicated; + + if ( LOG_DEBUGFLAG(DEBUG_ASN1) ) { + xer_fprint(stdout, &asn_DEF_NR_SpCellConfig, (void *)secondaryCellGroup->spCellConfig); + } } - -void config_csirs(NR_ServingCellConfigCommon_t *servingcellconfigcommon, - NR_CSI_MeasConfig_t *csi_MeasConfig, - int dl_antenna_ports, - int curr_bwp, - int do_csirs) { - - if (do_csirs) { - csi_MeasConfig->nzp_CSI_RS_ResourceToAddModList = calloc(1,sizeof(*csi_MeasConfig->nzp_CSI_RS_ResourceToAddModList)); - NR_NZP_CSI_RS_Resource_t *nzpcsi0 = calloc(1,sizeof(*nzpcsi0)); - nzpcsi0->nzp_CSI_RS_ResourceId = 0; - NR_CSI_RS_ResourceMapping_t resourceMapping; - switch (dl_antenna_ports) { - case 1: - resourceMapping.frequencyDomainAllocation.present = NR_CSI_RS_ResourceMapping__frequencyDomainAllocation_PR_row2; - resourceMapping.frequencyDomainAllocation.choice.row2.buf = calloc(2, sizeof(uint8_t)); - resourceMapping.frequencyDomainAllocation.choice.row2.size = 2; - resourceMapping.frequencyDomainAllocation.choice.row2.bits_unused = 4; - resourceMapping.frequencyDomainAllocation.choice.row2.buf[0] = 0; - resourceMapping.frequencyDomainAllocation.choice.row2.buf[1] = 16; - resourceMapping.nrofPorts = NR_CSI_RS_ResourceMapping__nrofPorts_p1; - resourceMapping.cdm_Type = NR_CSI_RS_ResourceMapping__cdm_Type_noCDM; - break; - case 2: - resourceMapping.frequencyDomainAllocation.present = NR_CSI_RS_ResourceMapping__frequencyDomainAllocation_PR_other; - resourceMapping.frequencyDomainAllocation.choice.other.buf = calloc(2, sizeof(uint8_t)); - resourceMapping.frequencyDomainAllocation.choice.other.size = 1; - resourceMapping.frequencyDomainAllocation.choice.other.bits_unused = 2; - resourceMapping.frequencyDomainAllocation.choice.other.buf[0] = 4; - resourceMapping.nrofPorts = NR_CSI_RS_ResourceMapping__nrofPorts_p2; - resourceMapping.cdm_Type = NR_CSI_RS_ResourceMapping__cdm_Type_fd_CDM2; - break; - default: - AssertFatal(1==0,"Number of ports not yet supported\n"); - } - resourceMapping.firstOFDMSymbolInTimeDomain = 6; - resourceMapping.firstOFDMSymbolInTimeDomain2 = NULL; - resourceMapping.density.present = NR_CSI_RS_ResourceMapping__density_PR_one; - resourceMapping.density.choice.one = (NULL_t)0; - resourceMapping.freqBand.startingRB = 0; - resourceMapping.freqBand.nrofRBs = ((curr_bwp>>2)+(curr_bwp%4>0))<<2; - nzpcsi0->resourceMapping = resourceMapping; - nzpcsi0->powerControlOffset = 0; - nzpcsi0->powerControlOffsetSS=calloc(1,sizeof(*nzpcsi0->powerControlOffsetSS)); - *nzpcsi0->powerControlOffsetSS = NR_NZP_CSI_RS_Resource__powerControlOffsetSS_db0; - nzpcsi0->scramblingID = *servingcellconfigcommon->physCellId; - nzpcsi0->periodicityAndOffset = calloc(1,sizeof(*nzpcsi0->periodicityAndOffset)); - nzpcsi0->periodicityAndOffset->present = NR_CSI_ResourcePeriodicityAndOffset_PR_slots320; - nzpcsi0->periodicityAndOffset->choice.slots320 = 0; - nzpcsi0->qcl_InfoPeriodicCSI_RS = NULL; - ASN_SEQUENCE_ADD(&csi_MeasConfig->nzp_CSI_RS_ResourceToAddModList->list,nzpcsi0); - } - else - csi_MeasConfig->nzp_CSI_RS_ResourceToAddModList = NULL; -} - - void fill_default_reconfig(NR_ServingCellConfigCommon_t *servingcellconfigcommon, NR_ServingCellConfig_t *servingcellconfigdedicated, NR_RRCReconfiguration_IEs_t *reconfig, NR_CellGroupConfig_t *secondaryCellGroup, NR_UE_NR_Capability_t *uecap, - int dl_antenna_ports, - int minRXTXTIME, - int do_csirs, - int do_srs, + const gNB_RrcConfigurationReq *configuration, int uid) { AssertFatal(servingcellconfigcommon!=NULL,"servingcellconfigcommon is null\n"); AssertFatal(reconfig!=NULL,"reconfig is null\n"); @@ -1360,10 +1428,7 @@ void fill_default_reconfig(NR_ServingCellConfigCommon_t *servingcellconfigcommon uecap, 1, 1, - dl_antenna_ports, - minRXTXTIME, - do_csirs, - do_srs, + configuration, uid); xer_fprint(stdout, &asn_DEF_NR_CellGroupConfig, (const void*)secondaryCellGroup); diff --git a/openair2/RRC/NR_UE/rrc_UE.c b/openair2/RRC/NR_UE/rrc_UE.c index fa1690e450..50ec32772d 100644 --- a/openair2/RRC/NR_UE/rrc_UE.c +++ b/openair2/RRC/NR_UE/rrc_UE.c @@ -359,7 +359,8 @@ void process_nsa_message(NR_UE_RRC_INST_t *rrc, nsa_message_t nsa_message_type, return; } nr_rrc_ue_process_rrcReconfiguration(module_id,RRCReconfiguration); - } + ASN_STRUCT_FREE(asn_DEF_NR_RRCReconfiguration, RRCReconfiguration); + } break; case nr_RadioBearerConfigX_r15: @@ -392,6 +393,7 @@ void process_nsa_message(NR_UE_RRC_INST_t *rrc, nsa_message_t nsa_message_type, else if ( LOG_DEBUGFLAG(DEBUG_ASN1) ) { xer_fprint(stdout, &asn_DEF_NR_RadioBearerConfig, (const void *) RadioBearerConfig); } + ASN_STRUCT_FREE(asn_DEF_NR_RadioBearerConfig, RadioBearerConfig); } break; @@ -1338,13 +1340,6 @@ static void rrc_ue_generate_RRCSetupComplete( uint8_t size; const char *nas_msg; int nas_msg_length; - NR_UE_MAC_INST_t *mac = get_mac_inst(0); - - if (mac->cg && - mac->cg->spCellConfig && - mac->cg->spCellConfig->spCellConfigDedicated && - mac->cg->spCellConfig->spCellConfigDedicated->csi_MeasConfig) - AssertFatal(1==0,"2 > csi_MeasConfig is not null\n"); if (AMF_MODE_ENABLED) { #if defined(ITTI_SIM) @@ -1460,8 +1455,8 @@ int8_t nr_rrc_ue_decode_ccch( const protocol_ctxt_t *const ctxt_pP, const NR_SRB nr_rrc_ue_process_RadioBearerConfig(ctxt_pP, gNB_index, &dl_ccch_msg->message.choice.c1->choice.rrcSetup->criticalExtensions.choice.rrcSetup->radioBearerConfig); - nr_rrc_set_state (ctxt_pP->module_id, RRC_STATE_CONNECTED); - nr_rrc_set_sub_state (ctxt_pP->module_id, RRC_SUB_STATE_CONNECTED); + nr_rrc_set_state (ctxt_pP->module_id, RRC_STATE_CONNECTED_NR); + nr_rrc_set_sub_state (ctxt_pP->module_id, RRC_SUB_STATE_CONNECTED_NR); NR_UE_rrc_inst[ctxt_pP->module_id].Info[gNB_index].rnti = ctxt_pP->rnti; rrc_ue_generate_RRCSetupComplete( ctxt_pP, @@ -2795,7 +2790,6 @@ void start_oai_nrue_threads() init_queue(&nr_tx_req_queue); init_queue(&nr_ul_dci_req_queue); init_queue(&nr_ul_tti_req_queue); - init_queue(&nr_wait_ul_tti_req_queue); if (sem_init(&sfn_slot_semaphore, 0, 0) != 0) { diff --git a/openair2/RRC/NR_UE/rrc_proto.h b/openair2/RRC/NR_UE/rrc_proto.h index 62d9167251..510fbff230 100644 --- a/openair2/RRC/NR_UE/rrc_proto.h +++ b/openair2/RRC/NR_UE/rrc_proto.h @@ -51,7 +51,6 @@ extern queue_t nr_dl_tti_req_queue; extern queue_t nr_tx_req_queue; extern queue_t nr_ul_dci_req_queue; extern queue_t nr_ul_tti_req_queue; -extern queue_t nr_wait_ul_tti_req_queue; // // main_rrc.c // diff --git a/openair2/SDAP/nr_sdap/nr_sdap.c b/openair2/SDAP/nr_sdap/nr_sdap.c new file mode 100644 index 0000000000..74ef93aff7 --- /dev/null +++ b/openair2/SDAP/nr_sdap/nr_sdap.c @@ -0,0 +1,86 @@ +/* + * Licensed to the OpenAirInterface (OAI) Software Alliance under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The OpenAirInterface Software Alliance licenses this file to You under + * the OAI Public License, Version 1.1 (the "License"); you may not use this file + * except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.openairinterface.org/?page_id=698 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + *------------------------------------------------------------------------------- + * For more information about the OpenAirInterface (OAI) Software Alliance: + * contact@openairinterface.org + */ + +#include "nr_sdap.h" + +boolean_t sdap_data_req(protocol_ctxt_t *ctxt_p, + const srb_flag_t srb_flag, + const rb_id_t rb_id, + const mui_t mui, + const confirm_t confirm, + const sdu_size_t sdu_buffer_size, + unsigned char *const sdu_buffer, + const pdcp_transmission_mode_t pt_mode, + const uint32_t *sourceL2Id, + const uint32_t *destinationL2Id, + const uint8_t qfi, + const boolean_t rqi, + const int pdusession_id) { + nr_sdap_entity_t *sdap_entity; + sdap_entity = nr_sdap_get_entity(ctxt_p->rnti, pdusession_id); + + if(sdap_entity == NULL) { + LOG_E(SDAP, "%s:%d:%s: Entity not found with ue rnti: %x and pdusession id: %d\n", __FILE__, __LINE__, __FUNCTION__, ctxt_p->rnti, pdusession_id); + return 0; + } + + boolean_t ret = sdap_entity->tx_entity(sdap_entity, + ctxt_p, + srb_flag, + rb_id, + mui, + confirm, + sdu_buffer_size, + sdu_buffer, + pt_mode, + sourceL2Id, + destinationL2Id, + qfi, + rqi); + return ret; +} + +void sdap_data_ind(rb_id_t pdcp_entity, + int is_gnb, + int has_sdap, + int has_sdapULheader, + int pdusession_id, + int rnti, + char *buf, + int size) { + nr_sdap_entity_t *sdap_entity; + sdap_entity = nr_sdap_get_entity(rnti, pdusession_id); + + if(sdap_entity == NULL) { + LOG_E(SDAP, "%s:%d:%s: Entity not found\n", __FILE__, __LINE__, __FUNCTION__); + return; + } + + sdap_entity->rx_entity(sdap_entity, + pdcp_entity, + is_gnb, + has_sdap, + has_sdapULheader, + pdusession_id, + rnti, + buf, + size); +} diff --git a/openair2/SDAP/nr_sdap/nr_sdap.h b/openair2/SDAP/nr_sdap/nr_sdap.h new file mode 100644 index 0000000000..cd702cfd7f --- /dev/null +++ b/openair2/SDAP/nr_sdap/nr_sdap.h @@ -0,0 +1,66 @@ +/* + * Licensed to the OpenAirInterface (OAI) Software Alliance under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The OpenAirInterface Software Alliance licenses this file to You under + * the OAI Public License, Version 1.1 (the "License"); you may not use this file + * except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.openairinterface.org/?page_id=698 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + *------------------------------------------------------------------------------- + * For more information about the OpenAirInterface (OAI) Software Alliance: + * contact@openairinterface.org + */ + +#ifndef _NR_SDAP_GNB_H_ +#define _NR_SDAP_GNB_H_ + +#include "openair2/COMMON/platform_types.h" +#include "common/utils/LOG/log.h" +#include "nr_sdap_entity.h" + +/* + * TS 37.324 4.4 Functions + * Transfer of user plane data + * Downlink - gNB + * Uplink - nrUE + */ +boolean_t sdap_data_req(protocol_ctxt_t *ctxt_p, + const srb_flag_t srb_flag, + const rb_id_t rb_id, + const mui_t mui, + const confirm_t confirm, + const sdu_size_t sdu_buffer_size, + unsigned char *const sdu_buffer, + const pdcp_transmission_mode_t pt_mode, + const uint32_t *sourceL2Id, + const uint32_t *destinationL2Id, + const uint8_t qfi, + const boolean_t rqi, + const int pdusession_id + ); + +/* + * TS 37.324 4.4 Functions + * Transfer of user plane data + * Uplink - gNB + * Downlink - nrUE + */ +void sdap_data_ind(rb_id_t pdcp_entity, + int is_gnb, + int has_sdap, + int has_sdapULheader, + int pdusession_id, + int rnti, + char *buf, + int size + ); + +#endif diff --git a/openair2/SDAP/nr_sdap/nr_sdap_entity.c b/openair2/SDAP/nr_sdap/nr_sdap_entity.c new file mode 100644 index 0000000000..79532748d2 --- /dev/null +++ b/openair2/SDAP/nr_sdap/nr_sdap_entity.c @@ -0,0 +1,482 @@ +/* + * Licensed to the OpenAirInterface (OAI) Software Alliance under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The OpenAirInterface Software Alliance licenses this file to You under + * the OAI Public License, Version 1.1 (the "License"); you may not use this file + * except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.openairinterface.org/?page_id=698 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + *------------------------------------------------------------------------------- + * For more information about the OpenAirInterface (OAI) Software Alliance: + * contact@openairinterface.org + */ + +#include "nr_sdap_entity.h" +#include "common/utils/LOG/log.h" +#include +#include +#include "openair2/LAYER2/nr_pdcp/nr_pdcp_ue_manager.h" + +#include +#include +#include + +typedef struct { + nr_sdap_entity_t *sdap_entity_llist; +} nr_sdap_entity_info; + +static nr_sdap_entity_info sdap_info; + +nr_pdcp_ue_manager_t *nr_pdcp_sdap_get_ue_manager(void); + +void nr_pdcp_submit_sdap_ctrl_pdu(int rnti, rb_id_t sdap_ctrl_pdu_drb, nr_sdap_ul_hdr_t ctrl_pdu){ + nr_pdcp_ue_t *ue; + nr_pdcp_ue_manager_t *nr_pdcp_ue_manager; + nr_pdcp_ue_manager = nr_pdcp_sdap_get_ue_manager(); + ue = nr_pdcp_manager_get_ue(nr_pdcp_ue_manager, rnti); + ue->drb[sdap_ctrl_pdu_drb-1]->recv_sdu(ue->drb[sdap_ctrl_pdu_drb-1], (char*)&ctrl_pdu, SDAP_HDR_LENGTH, RLC_MUI_UNDEFINED); + return; +} + +static boolean_t nr_sdap_tx_entity(nr_sdap_entity_t *entity, + protocol_ctxt_t *ctxt_p, + const srb_flag_t srb_flag, + const rb_id_t rb_id, + const mui_t mui, + const confirm_t confirm, + const sdu_size_t sdu_buffer_size, + unsigned char *const sdu_buffer, + const pdcp_transmission_mode_t pt_mode, + const uint32_t *sourceL2Id, + const uint32_t *destinationL2Id, + const uint8_t qfi, + const boolean_t rqi + ) { + /* The offset of the SDAP header, it might be 0 if the has_sdap is not true in the pdcp entity. */ + int offset=0; + boolean_t ret=false; + /*Hardcode DRB ID given from upper layer (ue/enb_tun_read_thread rb_id), it will change if we have SDAP*/ + rb_id_t sdap_drb_id = rb_id; + int pdcp_ent_has_sdap = 0; + + if(sdu_buffer == NULL) { + LOG_E(SDAP, "%s:%d:%s: NULL sdu_buffer \n", __FILE__, __LINE__, __FUNCTION__); + exit(1); + } + + uint8_t sdap_buf[SDAP_MAX_PDU]; + rb_id_t pdcp_entity = entity->qfi2drb_map(entity, qfi, rb_id); + + if(pdcp_entity){ + sdap_drb_id = pdcp_entity; + pdcp_ent_has_sdap = entity->qfi2drb_table[qfi].hasSdap; + } + + if(!pdcp_ent_has_sdap){ + ret = pdcp_data_req(ctxt_p, + srb_flag, + sdap_drb_id, + mui, + confirm, + sdu_buffer_size, + sdu_buffer, + pt_mode, + sourceL2Id, + destinationL2Id); + + if(!ret) + LOG_E(SDAP, "%s:%d:%s: PDCP refused PDU\n", __FILE__, __LINE__, __FUNCTION__); + + return ret; + } + + if(sdu_buffer_size == 0 || sdu_buffer_size > 8999) { + LOG_E(SDAP, "%s:%d:%s: NULL or 0 or exceeded sdu_buffer_size (over max PDCP SDU)\n", __FILE__, __LINE__, __FUNCTION__); + return 0; + } + + if(ctxt_p->enb_flag) { // gNB + offset = SDAP_HDR_LENGTH; + /* + * TS 37.324 4.4 Functions + * marking QoS flow ID in DL packets. + * + * Construct the DL SDAP data PDU. + */ + nr_sdap_dl_hdr_t sdap_hdr; + sdap_hdr.QFI = qfi; + sdap_hdr.RQI = rqi; + sdap_hdr.RDI = 0; // SDAP Hardcoded Value + /* Add the SDAP DL Header to the buffer */ + memcpy(&sdap_buf[0], &sdap_hdr, SDAP_HDR_LENGTH); + memcpy(&sdap_buf[SDAP_HDR_LENGTH], sdu_buffer, sdu_buffer_size); + LOG_D(SDAP, "TX Entity QFI: %u \n", sdap_hdr.QFI); + LOG_D(SDAP, "TX Entity RQI: %u \n", sdap_hdr.RQI); + LOG_D(SDAP, "TX Entity RDI: %u \n", sdap_hdr.RDI); + } else { // nrUE + offset = SDAP_HDR_LENGTH; + /* + * TS 37.324 4.4 Functions + * marking QoS flow ID in UL packets. + * + * 5.2.1 Uplink + * construct the UL SDAP data PDU as specified in the subclause 6.2.2.3. + */ + nr_sdap_ul_hdr_t sdap_hdr; + sdap_hdr.QFI = qfi; + sdap_hdr.R = 0; + sdap_hdr.DC = rqi; + /* Add the SDAP UL Header to the buffer */ + memcpy(&sdap_buf[0], &sdap_hdr, SDAP_HDR_LENGTH); + memcpy(&sdap_buf[SDAP_HDR_LENGTH], sdu_buffer, sdu_buffer_size); + LOG_D(SDAP, "TX Entity QFI: %u \n", sdap_hdr.QFI); + LOG_D(SDAP, "TX Entity R: %u \n", sdap_hdr.R); + LOG_D(SDAP, "TX Entity DC: %u \n", sdap_hdr.DC); + } + + /* + * TS 37.324 5.2 Data transfer + * 5.2.1 Uplink UE side + * submit the constructed UL SDAP data PDU to the lower layers + * + * Downlink gNB side + */ + ret = pdcp_data_req(ctxt_p, + srb_flag, + sdap_drb_id, + mui, + confirm, + sdu_buffer_size+offset, + sdap_buf, + pt_mode, + sourceL2Id, + destinationL2Id); + + if(!ret) + LOG_E(SDAP, "%s:%d:%s: PDCP refused PDU\n", __FILE__, __LINE__, __FUNCTION__); + + return ret; +} + +static void nr_sdap_rx_entity(nr_sdap_entity_t *entity, + rb_id_t pdcp_entity, + int is_gnb, + int has_sdap, + int has_sdapHeader, + int pdusession_id, + int rnti, + char *buf, + int size) { + /* The offset of the SDAP header, it might be 0 if the has_sdap is not true in the pdcp entity. */ + int offset=0; + + if(is_gnb) { // gNB + if(has_sdap && has_sdapHeader ) { // Handling the SDAP Header + offset = SDAP_HDR_LENGTH; + nr_sdap_ul_hdr_t *sdap_hdr = (nr_sdap_ul_hdr_t *)buf; + LOG_D(SDAP, "RX Entity Received QFI : %u\n", sdap_hdr->QFI); + LOG_D(SDAP, "RX Entity Received Reserved bit : %u\n", sdap_hdr->R); + LOG_D(SDAP, "RX Entity Received DC bit : %u\n", sdap_hdr->DC); + + switch (sdap_hdr->DC) { + case SDAP_HDR_UL_DATA_PDU: + LOG_D(SDAP, "RX Entity Received SDAP Data PDU\n"); + break; + + case SDAP_HDR_UL_CTRL_PDU: + LOG_D(SDAP, "RX Entity Received SDAP Control PDU\n"); + break; + } + } + + // Pushing SDAP SDU to GTP-U Layer + MessageDef *message_p; + uint8_t *gtpu_buffer_p; + gtpu_buffer_p = itti_malloc(TASK_PDCP_ENB, TASK_GTPV1_U, size + GTPU_HEADER_OVERHEAD_MAX - offset); + AssertFatal(gtpu_buffer_p != NULL, "OUT OF MEMORY"); + memcpy(>pu_buffer_p[GTPU_HEADER_OVERHEAD_MAX], buf+offset, size-offset); + message_p = itti_alloc_new_message(TASK_PDCP_ENB, 0 , GTPV1U_GNB_TUNNEL_DATA_REQ); + AssertFatal(message_p != NULL, "OUT OF MEMORY"); + GTPV1U_GNB_TUNNEL_DATA_REQ(message_p).buffer = gtpu_buffer_p; + GTPV1U_GNB_TUNNEL_DATA_REQ(message_p).length = size-offset; + GTPV1U_GNB_TUNNEL_DATA_REQ(message_p).offset = GTPU_HEADER_OVERHEAD_MAX; + GTPV1U_GNB_TUNNEL_DATA_REQ(message_p).rnti = rnti; + GTPV1U_GNB_TUNNEL_DATA_REQ(message_p).pdusession_id = pdusession_id; + LOG_D(SDAP, "%s() sending message to gtp size %d\n", __func__, size-offset); + itti_send_msg_to_task(TASK_GTPV1_U, INSTANCE_DEFAULT, message_p); + } else { //nrUE + /* + * TS 37.324 5.2 Data transfer + * 5.2.2 Downlink + * if the DRB from which this SDAP data PDU is received is configured by RRC with the presence of SDAP header. + */ + if(has_sdap && has_sdapHeader) { // Handling the SDAP Header + offset = SDAP_HDR_LENGTH; + /* + * TS 37.324 5.2 Data transfer + * 5.2.2 Downlink + * retrieve the SDAP SDU from the DL SDAP data PDU as specified in the subclause 6.2.2.2. + */ + nr_sdap_dl_hdr_t *sdap_hdr = (nr_sdap_dl_hdr_t *)buf; + LOG_D(SDAP, "RX Entity Received QFI : %u\n", sdap_hdr->QFI); + LOG_D(SDAP, "RX Entity Received RQI : %u\n", sdap_hdr->RQI); + LOG_D(SDAP, "RX Entity Received RDI : %u\n", sdap_hdr->RDI); + + /* + * TS 37.324 5.2 Data transfer + * 5.2.2 Downlink + * Perform reflective QoS flow to DRB mapping as specified in the subclause 5.3.2. + */ + if(sdap_hdr->RDI == SDAP_REFLECTIVE_MAPPING) { + /* + * TS 37.324 5.3 QoS flow to DRB Mapping + * 5.3.2 Reflective mapping + * If there is no stored QoS flow to DRB mapping rule for the QoS flow and a default DRB is configured. + */ + if(!entity->qfi2drb_table[sdap_hdr->QFI].drb_id && entity->default_drb){ + nr_sdap_ul_hdr_t sdap_ctrl_pdu = entity->sdap_construct_ctrl_pdu(sdap_hdr->QFI); + rb_id_t sdap_ctrl_pdu_drb = entity->sdap_map_ctrl_pdu(entity, pdcp_entity, SDAP_CTRL_PDU_MAP_DEF_DRB, sdap_hdr->QFI); + entity->sdap_submit_ctrl_pdu(rnti, sdap_ctrl_pdu_drb, sdap_ctrl_pdu); + } + + /* + * TS 37.324 5.3 QoS flow to DRB mapping + * 5.3.2 Reflective mapping + * if the stored QoS flow to DRB mapping rule for the QoS flow + * is different from the QoS flow to DRB mapping of the DL SDAP data PDU + * and + * the DRB according to the stored QoS flow to DRB mapping rule is configured by RRC + * with the presence of UL SDAP header + */ + if( (pdcp_entity != entity->qfi2drb_table[sdap_hdr->QFI].drb_id) && + has_sdapHeader ){ + nr_sdap_ul_hdr_t sdap_ctrl_pdu = entity->sdap_construct_ctrl_pdu(sdap_hdr->QFI); + rb_id_t sdap_ctrl_pdu_drb = entity->sdap_map_ctrl_pdu(entity, pdcp_entity, SDAP_CTRL_PDU_MAP_RULE_DRB, sdap_hdr->QFI); + entity->sdap_submit_ctrl_pdu(rnti, sdap_ctrl_pdu_drb, sdap_ctrl_pdu); + } + + /* + * TS 37.324 5.3 QoS flow to DRB Mapping + * 5.3.2 Reflective mapping + * store the QoS flow to DRB mapping of the DL SDAP data PDU as the QoS flow to DRB mapping rule for the UL. + */ + entity->qfi2drb_table[sdap_hdr->QFI].drb_id = pdcp_entity; + } + + /* + * TS 37.324 5.2 Data transfer + * 5.2.2 Downlink + * perform RQI handling as specified in the subclause 5.4 + */ + if(sdap_hdr->RQI == SDAP_RQI_HANDLING) { + LOG_W(SDAP, "UE - TODD 5.4\n"); + } + } /* else - retrieve the SDAP SDU from the DL SDAP data PDU as specified in the subclause 6.2.2.1 */ + + /* + * TS 37.324 5.2 Data transfer + * 5.2.2 Downlink + * deliver the retrieved SDAP SDU to the upper layer. + */ + extern int nas_sock_fd[]; + int len = write(nas_sock_fd[0], &buf[offset], size-offset); + LOG_D(SDAP, "RX Entity len : %d\n", len); + LOG_D(SDAP, "RX Entity size : %d\n", size); + LOG_D(SDAP, "RX Entity offset : %d\n", offset); + + if (len != size-offset) + LOG_E(SDAP, "%s:%d:%s: fatal\n", __FILE__, __LINE__, __FUNCTION__); + } +} + +void nr_sdap_qfi2drb_map_update(nr_sdap_entity_t *entity, uint8_t qfi, rb_id_t drb, boolean_t hasSdap){ + if(qfi < SDAP_MAX_QFI && + qfi > SDAP_MAP_RULE_EMPTY && + drb > 0 && + drb <= AVLBL_DRB) + { + entity->qfi2drb_table[qfi].drb_id = drb; + entity->qfi2drb_table[qfi].hasSdap = hasSdap; + LOG_D(SDAP, "Updated QFI to DRB Map: QFI %u -> DRB %ld \n", qfi, entity->qfi2drb_table[qfi].drb_id); + LOG_D(SDAP, "DRB %ld %s\n", entity->qfi2drb_table[qfi].drb_id, hasSdap ? "has SDAP" : "does not have SDAP"); + } +} + +void nr_sdap_qfi2drb_map_del(nr_sdap_entity_t *entity, uint8_t qfi){ + entity->qfi2drb_table[qfi].drb_id = SDAP_NO_MAPPING_RULE; + LOG_D(SDAP, "Deleted QFI to DRB Map for QFI %u \n", qfi); +} + +rb_id_t nr_sdap_qfi2drb_map(nr_sdap_entity_t *entity, uint8_t qfi, rb_id_t upper_layer_rb_id){ + rb_id_t pdcp_entity; + + pdcp_entity = entity->qfi2drb_table[qfi].drb_id; + + if(pdcp_entity){ + return pdcp_entity; + } else if(entity->default_drb) { + LOG_D(SDAP, "Mapped QFI %u to Default DRB\n", qfi); + return entity->default_drb; + } else { + return SDAP_MAP_RULE_EMPTY; + } + + return pdcp_entity; +} + +nr_sdap_ul_hdr_t nr_sdap_construct_ctrl_pdu(uint8_t qfi){ + nr_sdap_ul_hdr_t sdap_end_marker_hdr; + sdap_end_marker_hdr.QFI = qfi; + sdap_end_marker_hdr.R = 0; + sdap_end_marker_hdr.DC = SDAP_HDR_UL_CTRL_PDU; + LOG_D(SDAP, "Constructed Control PDU with QFI:%u R:%u DC:%u \n", sdap_end_marker_hdr.QFI, + sdap_end_marker_hdr.R, + sdap_end_marker_hdr.DC); + return sdap_end_marker_hdr; +} + +rb_id_t nr_sdap_map_ctrl_pdu(nr_sdap_entity_t *entity, rb_id_t pdcp_entity, int map_type, uint8_t dl_qfi){ + rb_id_t drb_of_endmarker = 0; + if(map_type == SDAP_CTRL_PDU_MAP_DEF_DRB){ + drb_of_endmarker = entity->default_drb; + LOG_D(SDAP, "Mapped Control PDU to default drb\n"); + } + if(map_type == SDAP_CTRL_PDU_MAP_RULE_DRB){ + drb_of_endmarker = entity->qfi2drb_map(entity, dl_qfi, pdcp_entity); + LOG_D(SDAP, "Mapped Control PDU according to the mapping rule, qfi %u \n", dl_qfi); + } + return drb_of_endmarker; +} + +void nr_sdap_submit_ctrl_pdu(int rnti, rb_id_t sdap_ctrl_pdu_drb, nr_sdap_ul_hdr_t ctrl_pdu){ + if(sdap_ctrl_pdu_drb){ + nr_pdcp_submit_sdap_ctrl_pdu(rnti, sdap_ctrl_pdu_drb, ctrl_pdu); + LOG_D(SDAP, "Sent Control PDU to PDCP Layer.\n"); + } +} + +void nr_sdap_ue_qfi2drb_config(nr_sdap_entity_t *existing_sdap_entity, + rb_id_t pdcp_entity, + uint16_t rnti, + NR_QFI_t *mapped_qfi_2_add, + uint8_t mappedQFIs2AddCount, + uint8_t drb_identity) +{ + uint8_t qfi = 0; + + for(int i = 0; i < mappedQFIs2AddCount; i++){ + qfi = mapped_qfi_2_add[i]; + if(existing_sdap_entity->default_drb && existing_sdap_entity->qfi2drb_table[qfi].drb_id == SDAP_NO_MAPPING_RULE){ + nr_sdap_ul_hdr_t sdap_ctrl_pdu = existing_sdap_entity->sdap_construct_ctrl_pdu(qfi); + rb_id_t sdap_ctrl_pdu_drb = existing_sdap_entity->sdap_map_ctrl_pdu(existing_sdap_entity, pdcp_entity, SDAP_CTRL_PDU_MAP_DEF_DRB, qfi); + existing_sdap_entity->sdap_submit_ctrl_pdu(rnti, sdap_ctrl_pdu_drb, sdap_ctrl_pdu); + } + if(existing_sdap_entity->qfi2drb_table[qfi].drb_id != drb_identity && existing_sdap_entity->qfi2drb_table[qfi].hasSdap){ + nr_sdap_ul_hdr_t sdap_ctrl_pdu = existing_sdap_entity->sdap_construct_ctrl_pdu(qfi); + rb_id_t sdap_ctrl_pdu_drb = existing_sdap_entity->sdap_map_ctrl_pdu(existing_sdap_entity, pdcp_entity, SDAP_CTRL_PDU_MAP_RULE_DRB, qfi); + existing_sdap_entity->sdap_submit_ctrl_pdu(rnti, sdap_ctrl_pdu_drb, sdap_ctrl_pdu); + } + } +} + +nr_sdap_entity_t *new_nr_sdap_entity(int has_sdap, + uint16_t rnti, + int pdusession_id, + boolean_t is_defaultDRB, + uint8_t drb_identity, + NR_QFI_t *mapped_qfi_2_add, + uint8_t mappedQFIs2AddCount) +{ + if(nr_sdap_get_entity(rnti, pdusession_id)) { + LOG_E(SDAP, "SDAP Entity for UE already exists.\n"); + nr_sdap_entity_t *existing_sdap_entity = nr_sdap_get_entity(rnti, pdusession_id); + rb_id_t pdcp_entity = existing_sdap_entity->default_drb; + nr_sdap_ue_qfi2drb_config(existing_sdap_entity, pdcp_entity, rnti, mapped_qfi_2_add, mappedQFIs2AddCount, drb_identity); + return existing_sdap_entity; + } + + nr_sdap_entity_t *sdap_entity; + sdap_entity = calloc(1, sizeof(nr_sdap_entity_t)); + + if(sdap_entity == NULL) { + LOG_E(SDAP, "SDAP Entity creation failed, out of memory\n"); + exit(1); + } + + sdap_entity->rnti = rnti; + sdap_entity->pdusession_id = pdusession_id; + + sdap_entity->tx_entity = nr_sdap_tx_entity; + sdap_entity->rx_entity = nr_sdap_rx_entity; + + sdap_entity->sdap_construct_ctrl_pdu = nr_sdap_construct_ctrl_pdu; + sdap_entity->sdap_map_ctrl_pdu = nr_sdap_map_ctrl_pdu; + sdap_entity->sdap_submit_ctrl_pdu = nr_sdap_submit_ctrl_pdu; + + sdap_entity->qfi2drb_map_update = nr_sdap_qfi2drb_map_update; + sdap_entity->qfi2drb_map_delete = nr_sdap_qfi2drb_map_del; + sdap_entity->qfi2drb_map = nr_sdap_qfi2drb_map; + + if(is_defaultDRB) { + sdap_entity->default_drb = drb_identity; + LOG_I(SDAP, "Default DRB for the created SDAP entity: %ld \n", sdap_entity->default_drb); + + if(mappedQFIs2AddCount) { + for (int i = 0; i < mappedQFIs2AddCount; i++) + { + LOG_D(SDAP, "Mapped QFI to Add : %ld \n", mapped_qfi_2_add[i]); + sdap_entity->qfi2drb_map_update(sdap_entity, mapped_qfi_2_add[i], sdap_entity->default_drb, has_sdap); + } + } + } + + sdap_entity->next_entity = sdap_info.sdap_entity_llist; + sdap_info.sdap_entity_llist = sdap_entity; + return sdap_entity; +} + +nr_sdap_entity_t *nr_sdap_get_entity(uint16_t rnti, int pdusession_id) { + nr_sdap_entity_t *sdap_entity; + sdap_entity = sdap_info.sdap_entity_llist; + + if(sdap_entity == NULL) + return NULL; + + while(( sdap_entity->rnti != rnti || sdap_entity->pdusession_id != pdusession_id ) && sdap_entity->next_entity != NULL) { + sdap_entity = sdap_entity->next_entity; + } + + if (sdap_entity->rnti == rnti && sdap_entity->pdusession_id == pdusession_id) + return sdap_entity; + + return NULL; +} + + +void delete_nr_sdap_entity(uint16_t rnti) { + nr_sdap_entity_t *entityPtr, *entityPrev = NULL; + entityPtr = sdap_info.sdap_entity_llist; + + if(entityPtr->rnti == rnti) { + sdap_info.sdap_entity_llist = sdap_info.sdap_entity_llist->next_entity; + free(entityPtr); + } else { + while(entityPtr->rnti != rnti && entityPtr->next_entity != NULL) { + entityPrev = entityPtr; + entityPtr = entityPtr->next_entity; + } + + if(entityPtr->rnti != rnti) { + entityPrev->next_entity = entityPtr->next_entity; + free(entityPtr); + } + } +} diff --git a/openair2/SDAP/nr_sdap/nr_sdap_entity.h b/openair2/SDAP/nr_sdap/nr_sdap_entity.h new file mode 100644 index 0000000000..b46e5bf4e3 --- /dev/null +++ b/openair2/SDAP/nr_sdap/nr_sdap_entity.h @@ -0,0 +1,182 @@ +/* + * Licensed to the OpenAirInterface (OAI) Software Alliance under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The OpenAirInterface Software Alliance licenses this file to You under + * the OAI Public License, Version 1.1 (the "License"); you may not use this file + * except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.openairinterface.org/?page_id=698 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + *------------------------------------------------------------------------------- + * For more information about the OpenAirInterface (OAI) Software Alliance: + * contact@openairinterface.org + */ + +#ifndef _NR_SDAP_ENTITY_H_ +#define _NR_SDAP_ENTITY_H_ + +#include +#include "openair2/COMMON/platform_types.h" +#include "openair2/LAYER2/nr_pdcp/nr_pdcp_entity.h" +#include "NR_RadioBearerConfig.h" + +#define SDAP_BITMASK_DC (0x80) +#define SDAP_BITMASK_R (0x40) +#define SDAP_BITMASK_QFI (0x3F) +#define SDAP_BITMASK_RQI (0x40) +#define SDAP_HDR_UL_DATA_PDU (1) +#define SDAP_HDR_UL_CTRL_PDU (0) +#define SDAP_HDR_LENGTH (1) +#define SDAP_MAX_QFI (64) +#define SDAP_MAP_RULE_EMPTY (0) +#define AVLBL_DRB (5) +#define SDAP_NO_MAPPING_RULE (0) +#define SDAP_REFLECTIVE_MAPPING (1) +#define SDAP_RQI_HANDLING (1) +#define SDAP_CTRL_PDU_MAP_DEF_DRB (0) +#define SDAP_CTRL_PDU_MAP_RULE_DRB (1) +#define SDAP_MAX_PDU (9000) + +/* + * The values of QoS Flow ID (QFI) and Reflective QoS Indication, + * are located in the PDU Session Container, which is conveyed by + * the GTP-U Extension Header. Inside the DL PDU SESSION INFORMATION frame. + * TS 38.415 Fig. 5.5.2.1-1 + */ +typedef struct nr_sdap_dl_hdr_s { + uint8_t QFI:6; + uint8_t RQI:1; + uint8_t RDI:1; +} __attribute__((packed)) nr_sdap_dl_hdr_t; + +typedef struct nr_sdap_ul_hdr_s { + uint8_t QFI:6; + uint8_t R:1; + uint8_t DC:1; +} __attribute__((packed)) nr_sdap_ul_hdr_t; + +typedef struct qfi2drb_s { + rb_id_t drb_id; + boolean_t hasSdap; +} qfi2drb_t; + +void nr_pdcp_submit_sdap_ctrl_pdu(int rnti, rb_id_t sdap_ctrl_pdu_drb, nr_sdap_ul_hdr_t ctrl_pdu); + +typedef struct nr_sdap_entity_s { + uint16_t rnti; + rb_id_t default_drb; + int pdusession_id; + qfi2drb_t qfi2drb_table[SDAP_MAX_QFI]; + + void (*qfi2drb_map_update)(struct nr_sdap_entity_s *entity, uint8_t qfi, rb_id_t drb, boolean_t hasSdap); + void (*qfi2drb_map_delete)(struct nr_sdap_entity_s *entity, uint8_t qfi); + rb_id_t (*qfi2drb_map)(struct nr_sdap_entity_s *entity, uint8_t qfi, rb_id_t upper_layer_rb_id); + + nr_sdap_ul_hdr_t (*sdap_construct_ctrl_pdu)(uint8_t qfi); + rb_id_t (*sdap_map_ctrl_pdu)(struct nr_sdap_entity_s *entity, rb_id_t pdcp_entity, int map_type, uint8_t dl_qfi); + void (*sdap_submit_ctrl_pdu)(int rnti, rb_id_t sdap_ctrl_pdu_drb, nr_sdap_ul_hdr_t ctrl_pdu); + + + boolean_t (*tx_entity)(struct nr_sdap_entity_s *entity, + protocol_ctxt_t *ctxt_p, + const srb_flag_t srb_flag, + const rb_id_t rb_id, + const mui_t mui, + const confirm_t confirm, + const sdu_size_t sdu_buffer_size, + unsigned char *const sdu_buffer, + const pdcp_transmission_mode_t pt_mode, + const uint32_t *sourceL2Id, + const uint32_t *destinationL2Id, + const uint8_t qfi, + const boolean_t rqi + ); + + void (*rx_entity)(struct nr_sdap_entity_s *entity, + rb_id_t pdcp_entity, + int is_gnb, + int has_sdap, + int has_sdapULheader, + int pdusession_id, + int rnti, + char *buf, + int size); + + /* List of entities */ + struct nr_sdap_entity_s *next_entity; +} nr_sdap_entity_t; + +/* QFI to DRB Mapping Related Function */ +void nr_sdap_qfi2drb_map_update(nr_sdap_entity_t *entity, uint8_t qfi, rb_id_t drb, boolean_t hasSdap); + +/* QFI to DRB Mapping Related Function */ +void nr_sdap_qfi2drb_map_del(nr_sdap_entity_t *entity, uint8_t qfi); + +/* + * TS 37.324 + * 4.4 Functions + * Mapping between a QoS flow and a DRB for both DL and UL. + * + * 5.2.1 Uplink + * If there is no stored QoS flow to DRB mapping rule for the QoS flow as specified in the subclause 5.3, map the SDAP SDU to the default DRB + * else, map the SDAP SDU to the DRB according to the stored QoS flow to DRB mapping rule. + */ +rb_id_t nr_sdap_qfi2drb_map(nr_sdap_entity_t *entity, uint8_t qfi, rb_id_t upper_layer_rb_id); + +/* + * TS 37.324 5.3 QoS flow to DRB Mapping + * construct an end-marker control PDU, as specified in the subclause 6.2.3, for the QoS flow; + */ +nr_sdap_ul_hdr_t nr_sdap_construct_ctrl_pdu(uint8_t qfi); + +/* + * TS 37.324 5.3 QoS flow to DRB Mapping + * map the end-marker control PDU to the + * 1.) default DRB or + * 2.) DRB according to the stored QoS flow to DRB mapping rule + */ +rb_id_t nr_sdap_map_ctrl_pdu(nr_sdap_entity_t *entity, rb_id_t pdcp_entity, int map_type, uint8_t dl_qfi); + +/* + * TS 37.324 5.3 QoS flow to DRB Mapping + * Submit the end-marker control PDU to the lower layer. + */ +void nr_sdap_submit_ctrl_pdu(int rnti, rb_id_t sdap_ctrl_pdu_drb, nr_sdap_ul_hdr_t ctrl_pdu); + +/* + * TS 37.324 5.3 QoS flow to DRB Mapping + * 5.3.1 Configuration Procedures + */ +void nr_sdap_ue_qfi2drb_config(nr_sdap_entity_t *existing_sdap_entity, + rb_id_t pdcp_entity, + uint16_t rnti, + NR_QFI_t *mapped_qfi_2_add, + uint8_t mappedQFIs2AddCount, + uint8_t drb_identity); + +/* + * TS 37.324 4.4 5.1.1 SDAP entity establishment + * Establish an SDAP entity. + */ +nr_sdap_entity_t *new_nr_sdap_entity(int has_sdap, + uint16_t rnti, + int pdusession_id, + boolean_t is_defaultDRB, + uint8_t default_DRB, + NR_QFI_t *mapped_qfi_2_add, + uint8_t mappedQFIs2AddCount); + +/* Entity Handling Related Functions */ +nr_sdap_entity_t *nr_sdap_get_entity(uint16_t rnti, int pdusession_id); + +/* Entity Handling Related Functions */ +void delete_nr_sdap_entity(uint16_t rnti); + +#endif diff --git a/openair2/SDAP/nr_sdap/nr_sdap_gnb.c b/openair2/SDAP/nr_sdap/nr_sdap_gnb.c deleted file mode 100644 index 5f0a2640e9..0000000000 --- a/openair2/SDAP/nr_sdap/nr_sdap_gnb.c +++ /dev/null @@ -1,87 +0,0 @@ -/* - * Licensed to the OpenAirInterface (OAI) Software Alliance under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The OpenAirInterface Software Alliance licenses this file to You under - * the OAI Public License, Version 1.1 (the "License"); you may not use this file - * except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.openairinterface.org/?page_id=698 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - *------------------------------------------------------------------------------- - * For more information about the OpenAirInterface (OAI) Software Alliance: - * contact@openairinterface.org - */ - -#include "nr_sdap_gnb.h" -#include - -boolean_t sdap_gnb_data_req(protocol_ctxt_t *ctxt_p, - const srb_flag_t srb_flag, - const rb_id_t rb_id, - const mui_t mui, - const confirm_t confirm, - const sdu_size_t sdu_buffer_size, - unsigned char *const sdu_buffer, - const pdcp_transmission_mode_t pt_mode, - const uint32_t *sourceL2Id, - const uint32_t *destinationL2Id - ) { - if(sdu_buffer == NULL) { - LOG_E(PDCP, "%s:%d:%s: SDAP Layer gNB - NULL sdu_buffer \n", __FILE__, __LINE__, __FUNCTION__); - exit(1); - } - - if(sdu_buffer_size == 0) { - LOG_E(PDCP, "%s:%d:%s: SDAP Layer gNB - NULL or 0 sdu_buffer_size \n", __FILE__, __LINE__, __FUNCTION__); - exit(1); - } - - uint8_t *sdap_buf = (uint8_t *)malloc(sdu_buffer_size+SDAP_HDR_LENGTH); - nr_sdap_dl_hdr_t sdap_hdr; - sdap_hdr.RDI = 0; // SDAP_Hardcoded - - sdap_hdr.RQI = 0; // SDAP_Hardcoded - Should get this info from DL_PDU_SESSION_INFORMATION - sdap_hdr.QFI = 1; // SDAP_Hardcoded - Should get this info from DL_PDU_SESSION_INFORMATION - memcpy(&sdap_buf[0], &sdap_hdr, 1); - memcpy(&sdap_buf[1], sdu_buffer, sdu_buffer_size); - rb_id_t sdap_drb_id = rb_id; // SDAP_Hardcoded - Should get this info from QFI to DRB mapping table - boolean_t ret = pdcp_data_req(ctxt_p, - srb_flag, - sdap_drb_id, - mui, - confirm, - sdu_buffer_size+1, - sdap_buf, - pt_mode, - sourceL2Id, - destinationL2Id); - - if(!ret) { - LOG_E(PDCP, "%s:%d:%s: SDAP Layer gNB - PDCP DL refused PDU\n", __FILE__, __LINE__, __FUNCTION__); - free(sdap_buf); - return 0; - } - - free(sdap_buf); - return 1; -} - -void sdap_gnb_ul_header_handler(char sdap_gnb_ul_hdr) { - nr_sdap_ul_hdr_t *sdap_hdr_ul = (nr_sdap_ul_hdr_t *)&sdap_gnb_ul_hdr; - - switch (sdap_hdr_ul->DC) { - case SDAP_HDR_UL_DATA_PDU: - LOG_I(PDCP, "%s:%d:%s: SDAP Layer gNB - UL Received SDAP Data PDU\n", __FILE__, __LINE__, __FUNCTION__); - break; - - case SDAP_HDR_UL_CTRL_PDU: - LOG_I(PDCP, "%s:%d:%s: SDAP Layer gNB - Received SDAP Control PDU\n", __FILE__, __LINE__, __FUNCTION__); - break; - } -} \ No newline at end of file diff --git a/openair2/SDAP/nr_sdap/nr_sdap_gnb.h b/openair2/SDAP/nr_sdap/nr_sdap_gnb.h deleted file mode 100644 index 243aa89010..0000000000 --- a/openair2/SDAP/nr_sdap/nr_sdap_gnb.h +++ /dev/null @@ -1,61 +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 - */ - -#ifndef _NR_SDAP_GNB_ -#define _NR_SDAP_GNB_ - -#include "openair2/COMMON/platform_types.h" -#include "common/utils/LOG/log.h" - -#define SDAP_BITMASK_DC (0x80) -#define SDAP_BITMASK_R (0x40) -#define SDAP_BITMASK_QFI (0x3F) -#define SDAP_HDR_UL_DATA_PDU (1) -#define SDAP_HDR_UL_CTRL_PDU (0) -#define SDAP_HDR_LENGTH (1) - -typedef struct nr_sdap_dl_hdr_s { - uint8_t QFI:6; - uint8_t RQI:1; - uint8_t RDI:1; -} __attribute__((packed)) nr_sdap_dl_hdr_t; - -typedef struct nr_sdap_ul_hdr_s { - uint8_t QFI:6; - uint8_t R:1; - uint8_t DC:1; -} __attribute__((packed)) nr_sdap_ul_hdr_t; - -boolean_t sdap_gnb_data_req(protocol_ctxt_t *ctxt_p, - const srb_flag_t srb_flag, - const rb_id_t rb_id, - const mui_t mui, - const confirm_t confirm, - const sdu_size_t sdu_buffer_size, - unsigned char *const sdu_buffer, - const pdcp_transmission_mode_t pt_mode, - const uint32_t *sourceL2Id, - const uint32_t *destinationL2Id - ); - -void sdap_gnb_ul_header_handler(char sdap_gnb_ul_hdr); - -#endif \ No newline at end of file diff --git a/openair2/SDAP/nr_sdap/sdap_gNB.c b/openair2/SDAP/nr_sdap/sdap_gNB.c deleted file mode 100644 index ad84e4c273..0000000000 --- a/openair2/SDAP/nr_sdap/sdap_gNB.c +++ /dev/null @@ -1,30 +0,0 @@ -/* - * Licensed to the OpenAirInterface (OAI) Software Alliance under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The OpenAirInterface Software Alliance licenses this file to You under - * the OAI Public License, Version 1.1 (the "License"); you may not use this file - * except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.openairinterface.org/?page_id=698 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - *------------------------------------------------------------------------------- - * For more information about the OpenAirInterface (OAI) Software Alliance: - * contact@openairinterface.org - */ - -/*! \file sdap_gNB.c - * \brief sdap tasks for gNB - * \author Konstantinos Alexandris , Cedric Roux , Navid Nikaein - * \date 2018 - * \version 1.0 - */ -#define SDAP_GNB -#define SDAP_GNB_C - diff --git a/openair2/UTIL/LFDS/liblfds6.1.1/liblfds611/building.txt b/openair2/UTIL/LFDS/liblfds6.1.1/liblfds611/building.txt deleted file mode 100644 index 56b4be609f..0000000000 --- a/openair2/UTIL/LFDS/liblfds6.1.1/liblfds611/building.txt +++ /dev/null @@ -1,40 +0,0 @@ -building liblfds -================ - -Windows (user-mode) -=================== -1. Use Microsoft Visual Studio 2008 or Visual C++ 2008 Express Edition (or - later versions) to load "liblfds.sln". The "Win32" platform is x86, - the "x64" platform is x64. - -2. Use Microsoft Windows SDK and GNUmake to run makefile.windows (obviously - you'll need to have run setenv.bat or the appropriate vcvars*.bat first; - you can build for x64/64-bit and x86/32-bit - just run the correct batch - file). - - Targets are "librel", "libdbg", "dllrel", "dlldbg" and "clean". You need - to clean between switching targets. - -Windows (kernel) -================ -Use the Windows Driver Kit "build" command. Prior to running "build", -if you wish to build a static library, run the batch file -"runme_before_win_kernel_static_lib_build.bat"; if you wish to -build a dynamic library, instead run "runme_before_win_kernel_dynamic_lib_build.bat". - -The Windows kernel build system is rather limited and rather than -really rather messing up the directory/file structure just for the -Windows kernel platform, I've instead arranged it that these batch -files do the necessary work so that "build" will work. - -The batch files are idempotent; you can run them as often as you -like, in any order, at any time (before or after builds), and they'll -do the right thing. You need to clean between switching targets. - -Linux -===== -Use GNUmake to run "makefile.linux". Targets are "arrel", "ardbg", -"sorel", "sodbg" and "clean". You need to clean between switching -targets. - - diff --git a/openair2/UTIL/LFDS/liblfds6.1.1/liblfds611/dirs b/openair2/UTIL/LFDS/liblfds6.1.1/liblfds611/dirs deleted file mode 100644 index 0be5295378..0000000000 --- a/openair2/UTIL/LFDS/liblfds6.1.1/liblfds611/dirs +++ /dev/null @@ -1,2 +0,0 @@ -DIRS = src - diff --git a/openair2/UTIL/LFDS/liblfds6.1.1/liblfds611/inc/liblfds611.h b/openair2/UTIL/LFDS/liblfds6.1.1/liblfds611/inc/liblfds611.h deleted file mode 100644 index f2c05ee5e3..0000000000 --- a/openair2/UTIL/LFDS/liblfds6.1.1/liblfds611/inc/liblfds611.h +++ /dev/null @@ -1,334 +0,0 @@ -#ifndef __LIBLFDS611_H - -/***** library header *****/ -#define LFDS611_RELEASE_NUMBER_STRING "6.1.1" - - - - -/***** lfds611_abstraction *****/ - -/***** defines *****/ -#if (defined _WIN64 && defined _MSC_VER && !defined WIN_KERNEL_BUILD) -// TRD : 64-bit Windows user-mode with the Microsoft C compiler, any CPU -#include -#include -#include -#include -#include -typedef unsigned __int64 lfds611_atom_t; -#define LFDS611_INLINE __forceinline -#define LFDS611_ALIGN(alignment) __declspec( align(alignment) ) -#define LFDS611_ALIGN_SINGLE_POINTER 8 -#define LFDS611_ALIGN_DOUBLE_POINTER 16 -#define LFDS611_BARRIER_COMPILER_LOAD _ReadBarrier() -#define LFDS611_BARRIER_COMPILER_STORE _WriteBarrier() -#define LFDS611_BARRIER_COMPILER_FULL _ReadWriteBarrier() -#define LFDS611_BARRIER_PROCESSOR_LOAD _mm_lfence() -#define LFDS611_BARRIER_PROCESSOR_STORE _mm_sfence() -#define LFDS611_BARRIER_PROCESSOR_FULL _mm_mfence() -#endif - -#if (!defined _WIN64 && defined _WIN32 && defined _MSC_VER && !defined WIN_KERNEL_BUILD) -// TRD : 32-bit Windows user-mode with the Microsoft C compiler, any CPU -#include -#include -#include -#include -#include -typedef unsigned long int lfds611_atom_t; -#define LFDS611_INLINE __forceinline -#define LFDS611_ALIGN(alignment) __declspec( align(alignment) ) -#define LFDS611_ALIGN_SINGLE_POINTER 4 -#define LFDS611_ALIGN_DOUBLE_POINTER 8 -#define LFDS611_BARRIER_COMPILER_LOAD _ReadBarrier() -#define LFDS611_BARRIER_COMPILER_STORE _WriteBarrier() -#define LFDS611_BARRIER_COMPILER_FULL _ReadWriteBarrier() -#define LFDS611_BARRIER_PROCESSOR_LOAD _mm_lfence() -#define LFDS611_BARRIER_PROCESSOR_STORE _mm_sfence() -#define LFDS611_BARRIER_PROCESSOR_FULL _mm_mfence() - -// TRD : this define is documented but missing in Microsoft Platform SDK v7.0 -#define _InterlockedCompareExchangePointer(destination, exchange, compare) _InterlockedCompareExchange((volatile long *) destination, (long) exchange, (long) compare) -#endif - -#if (defined _WIN64 && defined _MSC_VER && defined WIN_KERNEL_BUILD) -// TRD : 64-bit Windows kernel with the Microsoft C compiler, any CPU -#include -#include -#include -#include -typedef unsigned __int64 lfds611_atom_t; -#define LFDS611_INLINE __forceinline -#define LFDS611_ALIGN(alignment) __declspec( align(alignment) ) -#define LFDS611_ALIGN_SINGLE_POINTER 8 -#define LFDS611_ALIGN_DOUBLE_POINTER 16 -#define LFDS611_BARRIER_COMPILER_LOAD _ReadBarrier() -#define LFDS611_BARRIER_COMPILER_STORE _WriteBarrier() -#define LFDS611_BARRIER_COMPILER_FULL _ReadWriteBarrier() -#define LFDS611_BARRIER_PROCESSOR_LOAD _mm_lfence() -#define LFDS611_BARRIER_PROCESSOR_STORE _mm_sfence() -#define LFDS611_BARRIER_PROCESSOR_FULL _mm_mfence() -#endif - -#if (!defined _WIN64 && defined _WIN32 && defined _MSC_VER && defined WIN_KERNEL_BUILD) -// TRD : 32-bit Windows kernel with the Microsoft C compiler, any CPU -#include -#include -#include -#include -typedef unsigned long int lfds611_atom_t; -#define LFDS611_INLINE __forceinline -#define LFDS611_ALIGN(alignment) __declspec( align(alignment) ) -#define LFDS611_ALIGN_SINGLE_POINTER 4 -#define LFDS611_ALIGN_DOUBLE_POINTER 8 -#define LFDS611_BARRIER_COMPILER_LOAD _ReadBarrier() -#define LFDS611_BARRIER_COMPILER_STORE _WriteBarrier() -#define LFDS611_BARRIER_COMPILER_FULL _ReadWriteBarrier() -#define LFDS611_BARRIER_PROCESSOR_LOAD _mm_lfence() -#define LFDS611_BARRIER_PROCESSOR_STORE _mm_sfence() -#define LFDS611_BARRIER_PROCESSOR_FULL _mm_mfence() - -// TRD : this define is documented but missing in Microsoft Platform SDK v7.0 -#define _InterlockedCompareExchangePointer(destination, exchange, compare) _InterlockedCompareExchange((volatile long *) destination, (long) exchange, (long) compare) -#endif - -#if (defined __unix__ && defined __x86_64__ && __GNUC__) -// TRD : any UNIX with GCC on x64 -#include -#include -#include -typedef unsigned long long int lfds611_atom_t; -#define LFDS611_INLINE inline -#define LFDS611_ALIGN(alignment) __attribute__( (aligned(alignment)) ) -#define LFDS611_ALIGN_SINGLE_POINTER 8 -#define LFDS611_ALIGN_DOUBLE_POINTER 16 -#define LFDS611_BARRIER_COMPILER_LOAD __asm__ __volatile__ ( "" : : : "memory" ) -#define LFDS611_BARRIER_COMPILER_STORE __asm__ __volatile__ ( "" : : : "memory" ) -#define LFDS611_BARRIER_COMPILER_FULL __asm__ __volatile__ ( "" : : : "memory" ) -#define LFDS611_BARRIER_PROCESSOR_LOAD __sync_synchronize() -#define LFDS611_BARRIER_PROCESSOR_STORE __sync_synchronize() -#define LFDS611_BARRIER_PROCESSOR_FULL __sync_synchronize() -#endif - -#if (defined __unix__ && defined __i386__ && __GNUC__) -// TRD : any UNIX with GCC on x86 -#include -#include -#include -typedef unsigned long int lfds611_atom_t; -#define LFDS611_INLINE inline -#define LFDS611_ALIGN(alignment) __attribute__( (aligned(alignment)) ) -#define LFDS611_ALIGN_SINGLE_POINTER 4 -#define LFDS611_ALIGN_DOUBLE_POINTER 8 -#define LFDS611_BARRIER_COMPILER_LOAD __asm__ __volatile__ ( "" : : : "memory" ) -#define LFDS611_BARRIER_COMPILER_STORE __asm__ __volatile__ ( "" : : : "memory" ) -#define LFDS611_BARRIER_COMPILER_FULL __asm__ __volatile__ ( "" : : : "memory" ) -#define LFDS611_BARRIER_PROCESSOR_LOAD __sync_synchronize() -#define LFDS611_BARRIER_PROCESSOR_STORE __sync_synchronize() -#define LFDS611_BARRIER_PROCESSOR_FULL __sync_synchronize() -#endif - -#if (defined __unix__ && defined __arm__ && __GNUC__) -// TRD : any UNIX with GCC on ARM -#include -#include -#include -typedef unsigned long int lfds611_atom_t; -#define LFDS611_INLINE inline -#define LFDS611_ALIGN(alignment) __attribute__( (aligned(alignment)) ) -#define LFDS611_ALIGN_SINGLE_POINTER 4 -#define LFDS611_ALIGN_DOUBLE_POINTER 8 -#define LFDS611_BARRIER_COMPILER_LOAD __asm__ __volatile__ ( "" : : : "memory" ) -#define LFDS611_BARRIER_COMPILER_STORE __asm__ __volatile__ ( "" : : : "memory" ) -#define LFDS611_BARRIER_COMPILER_FULL __asm__ __volatile__ ( "" : : : "memory" ) -#define LFDS611_BARRIER_PROCESSOR_LOAD __sync_synchronize() -#define LFDS611_BARRIER_PROCESSOR_STORE __sync_synchronize() -#define LFDS611_BARRIER_PROCESSOR_FULL __sync_synchronize() -#endif - -#define LFDS611_BARRIER_LOAD LFDS611_BARRIER_COMPILER_LOAD; LFDS611_BARRIER_PROCESSOR_LOAD; LFDS611_BARRIER_COMPILER_LOAD -#define LFDS611_BARRIER_STORE LFDS611_BARRIER_COMPILER_STORE; LFDS611_BARRIER_PROCESSOR_STORE; LFDS611_BARRIER_COMPILER_STORE -#define LFDS611_BARRIER_FULL LFDS611_BARRIER_COMPILER_FULL; LFDS611_BARRIER_PROCESSOR_FULL; LFDS611_BARRIER_COMPILER_FULL - -/***** enums *****/ -enum lfds611_data_structure_validity { - LFDS611_VALIDITY_VALID, - LFDS611_VALIDITY_INVALID_LOOP, - LFDS611_VALIDITY_INVALID_MISSING_ELEMENTS, - LFDS611_VALIDITY_INVALID_ADDITIONAL_ELEMENTS, - LFDS611_VALIDITY_INVALID_TEST_DATA -}; - -/***** structs *****/ -struct lfds611_validation_info { - lfds611_atom_t - min_elements, - max_elements; -}; - -/***** public prototypes *****/ -void *lfds611_abstraction_malloc( size_t size ); -void lfds611_abstraction_free( void *memory ); - - - - - -/***** lfds611_freelist *****/ - -/***** enums *****/ -enum lfds611_freelist_query_type { - LFDS611_FREELIST_QUERY_ELEMENT_COUNT, - LFDS611_FREELIST_QUERY_VALIDATE -}; - -/***** incomplete types *****/ -struct lfds611_freelist_state; -struct lfds611_freelist_element; - -/***** public prototypes *****/ -int lfds611_freelist_new( struct lfds611_freelist_state **fs, lfds611_atom_t number_elements, int (*user_data_init_function)(void **user_data, void *user_state), void *user_state ); -void lfds611_freelist_use( struct lfds611_freelist_state *fs ); -void lfds611_freelist_delete( struct lfds611_freelist_state *fs, void (*user_data_delete_function)(void *user_data, void *user_state), void *user_state ); - -lfds611_atom_t lfds611_freelist_new_elements( struct lfds611_freelist_state *fs, lfds611_atom_t number_elements ); - -struct lfds611_freelist_element *lfds611_freelist_pop( struct lfds611_freelist_state *fs, struct lfds611_freelist_element **fe ); -struct lfds611_freelist_element *lfds611_freelist_guaranteed_pop( struct lfds611_freelist_state *fs, struct lfds611_freelist_element **fe ); -void lfds611_freelist_push( struct lfds611_freelist_state *fs, struct lfds611_freelist_element *fe ); - -void *lfds611_freelist_get_user_data_from_element( struct lfds611_freelist_element *fe, void **user_data ); -void lfds611_freelist_set_user_data_in_element( struct lfds611_freelist_element *fe, void *user_data ); - -void lfds611_freelist_query( struct lfds611_freelist_state *fs, enum lfds611_freelist_query_type query_type, void *query_input, void *query_output ); - - - - - -/***** lfds611_liblfds *****/ - -/***** public prototypes *****/ -void lfds611_liblfds_abstraction_test_helper_increment_non_atomic( lfds611_atom_t *shared_counter ); -void lfds611_liblfds_abstraction_test_helper_increment_atomic( volatile lfds611_atom_t *shared_counter ); -void lfds611_liblfds_abstraction_test_helper_cas( volatile lfds611_atom_t *shared_counter, lfds611_atom_t *local_counter ); -void lfds611_liblfds_abstraction_test_helper_dcas( volatile lfds611_atom_t *shared_counter, lfds611_atom_t *local_counter ); - - - - - -/***** lfds611_queue *****/ - -/***** enums *****/ -enum lfds611_queue_query_type { - LFDS611_QUEUE_QUERY_ELEMENT_COUNT, - LFDS611_QUEUE_QUERY_VALIDATE -}; - -/***** incomplete types *****/ -struct lfds611_queue_state; - -/***** public prototypes *****/ -int lfds611_queue_new( struct lfds611_queue_state **sq, lfds611_atom_t number_elements ); -void lfds611_queue_use( struct lfds611_queue_state *qs ); -void lfds611_queue_delete( struct lfds611_queue_state *qs, void (*user_data_delete_function)(void *user_data, void *user_state), void *user_state ); - -int lfds611_queue_enqueue( struct lfds611_queue_state *qs, void *user_data ); -int lfds611_queue_guaranteed_enqueue( struct lfds611_queue_state *qs, void *user_data ); -int lfds611_queue_dequeue( struct lfds611_queue_state *qs, void **user_data ); - -void lfds611_queue_query( struct lfds611_queue_state *qs, enum lfds611_queue_query_type query_type, void *query_input, void *query_output ); - - - - - -/***** lfds611_ringbuffer *****/ - -/***** enums *****/ -enum lfds611_ringbuffer_query_type { - LFDS611_RINGBUFFER_QUERY_VALIDATE -}; - -/***** incomplete types *****/ -struct lfds611_ringbuffer_state; - -/***** public prototypes *****/ -int lfds611_ringbuffer_new( struct lfds611_ringbuffer_state **rs, lfds611_atom_t number_elements, int (*user_data_init_function)(void **user_data, void *user_state), void *user_state ); -void lfds611_ringbuffer_use( struct lfds611_ringbuffer_state *rs ); -void lfds611_ringbuffer_delete( struct lfds611_ringbuffer_state *rs, void (*user_data_delete_function)(void *user_data, void *user_state), void *user_state ); - -struct lfds611_freelist_element *lfds611_ringbuffer_get_read_element( struct lfds611_ringbuffer_state *rs, struct lfds611_freelist_element **fe ); -struct lfds611_freelist_element *lfds611_ringbuffer_get_write_element( struct lfds611_ringbuffer_state *rs, struct lfds611_freelist_element **fe, int *overwrite_flag ); - -void lfds611_ringbuffer_put_read_element( struct lfds611_ringbuffer_state *rs, struct lfds611_freelist_element *fe ); -void lfds611_ringbuffer_put_write_element( struct lfds611_ringbuffer_state *rs, struct lfds611_freelist_element *fe ); - -void lfds611_ringbuffer_query( struct lfds611_ringbuffer_state *rs, enum lfds611_ringbuffer_query_type query_type, void *query_input, void *query_output ); - - - - - -/***** lfds611_slist *****/ - -/***** incomplete types *****/ -struct lfds611_slist_state; -struct lfds611_slist_element; - -/***** public prototypes *****/ -int lfds611_slist_new( struct lfds611_slist_state **ss, void (*user_data_delete_function)(void *user_data, void *user_state), void *user_state ); -void lfds611_slist_use( struct lfds611_slist_state *ss ); -void lfds611_slist_delete( struct lfds611_slist_state *ss ); - -struct lfds611_slist_element *lfds611_slist_new_head( struct lfds611_slist_state *ss, void *user_data ); -struct lfds611_slist_element *lfds611_slist_new_next( struct lfds611_slist_element *se, void *user_data ); - -int lfds611_slist_logically_delete_element( struct lfds611_slist_state *ss, struct lfds611_slist_element *se ); -void lfds611_slist_single_threaded_physically_delete_all_elements( struct lfds611_slist_state *ss ); - -int lfds611_slist_get_user_data_from_element( struct lfds611_slist_element *se, void **user_data ); -int lfds611_slist_set_user_data_in_element( struct lfds611_slist_element *se, void *user_data ); - -struct lfds611_slist_element *lfds611_slist_get_head( struct lfds611_slist_state *ss, struct lfds611_slist_element **se ); -struct lfds611_slist_element *lfds611_slist_get_next( struct lfds611_slist_element *se, struct lfds611_slist_element **next_se ); -struct lfds611_slist_element *lfds611_slist_get_head_and_then_next( struct lfds611_slist_state *ss, struct lfds611_slist_element **se ); - - - - - -/***** lfds611_stack *****/ - -/***** enums *****/ -enum lfds611_stack_query_type { - LFDS611_STACK_QUERY_ELEMENT_COUNT, - LFDS611_STACK_QUERY_VALIDATE -}; - -/***** incomplete types *****/ -struct lfds611_stack_state; - -/***** public prototypes *****/ -int lfds611_stack_new( struct lfds611_stack_state **ss, lfds611_atom_t number_elements ); -void lfds611_stack_use( struct lfds611_stack_state *ss ); -void lfds611_stack_delete( struct lfds611_stack_state *ss, void (*user_data_delete_function)(void *user_data, void *user_state), void *user_state ); - -void lfds611_stack_clear( struct lfds611_stack_state *ss, void (*user_data_clear_function)(void *user_data, void *user_state), void *user_state ); - -int lfds611_stack_push( struct lfds611_stack_state *ss, void *user_data ); -int lfds611_stack_guaranteed_push( struct lfds611_stack_state *ss, void *user_data ); -int lfds611_stack_pop( struct lfds611_stack_state *ss, void **user_data ); - -void lfds611_stack_query( struct lfds611_stack_state *ss, enum lfds611_stack_query_type query_type, void *query_input, void *query_output ); - - - - - -#define __LIBLFDS611_H - -#endif - diff --git a/openair2/UTIL/LFDS/liblfds6.1.1/liblfds611/liblfds611.def b/openair2/UTIL/LFDS/liblfds6.1.1/liblfds611/liblfds611.def deleted file mode 100644 index b9c92b0cf9..0000000000 --- a/openair2/UTIL/LFDS/liblfds6.1.1/liblfds611/liblfds611.def +++ /dev/null @@ -1,57 +0,0 @@ -EXPORTS - -lfds611_liblfds_abstraction_test_helper_increment_non_atomic = lfds611_liblfds_abstraction_test_helper_increment_non_atomic @1 -lfds611_liblfds_abstraction_test_helper_increment_atomic = lfds611_liblfds_abstraction_test_helper_increment_atomic @2 -lfds611_liblfds_abstraction_test_helper_cas = lfds611_liblfds_abstraction_test_helper_cas @3 -lfds611_liblfds_abstraction_test_helper_dcas = lfds611_liblfds_abstraction_test_helper_dcas @4 - -lfds611_freelist_delete = lfds611_freelist_delete @5 -lfds611_freelist_get_user_data_from_element = lfds611_freelist_get_user_data_from_element @6 -lfds611_freelist_guaranteed_pop = lfds611_freelist_guaranteed_pop @7 -lfds611_freelist_new = lfds611_freelist_new @8 -lfds611_freelist_new_elements = lfds611_freelist_new_elements @9 -lfds611_freelist_pop = lfds611_freelist_pop @10 -lfds611_freelist_push = lfds611_freelist_push @11 -lfds611_freelist_query = lfds611_freelist_query @12 -lfds611_freelist_set_user_data_in_element = lfds611_freelist_set_user_data_in_element @13 -lfds611_freelist_use = lfds611_freelist_use @14 - -lfds611_queue_delete = lfds611_queue_delete @15 -lfds611_queue_dequeue = lfds611_queue_dequeue @16 -lfds611_queue_enqueue = lfds611_queue_enqueue @17 -lfds611_queue_guaranteed_enqueue = lfds611_queue_guaranteed_enqueue @18 -lfds611_queue_new = lfds611_queue_new @19 -lfds611_queue_query = lfds611_queue_query @20 -lfds611_queue_use = lfds611_queue_use @21 - -lfds611_ringbuffer_delete = lfds611_ringbuffer_delete @22 -lfds611_ringbuffer_get_read_element = lfds611_ringbuffer_get_read_element @23 -lfds611_ringbuffer_get_write_element = lfds611_ringbuffer_get_write_element @24 -lfds611_ringbuffer_new = lfds611_ringbuffer_new @25 -lfds611_ringbuffer_put_read_element = lfds611_ringbuffer_put_read_element @26 -lfds611_ringbuffer_put_write_element = lfds611_ringbuffer_put_write_element @27 -lfds611_ringbuffer_query = lfds611_ringbuffer_query @28 -lfds611_ringbuffer_use = lfds611_ringbuffer_use @29 - -lfds611_slist_delete = lfds611_slist_delete @30 -lfds611_slist_get_head = lfds611_slist_get_head @31 -lfds611_slist_get_head_and_then_next = lfds611_slist_get_head_and_then_next @32 -lfds611_slist_get_next = lfds611_slist_get_next @33 -lfds611_slist_get_user_data_from_element = lfds611_slist_get_user_data_from_element @34 -lfds611_slist_logically_delete_element = lfds611_slist_logically_delete_element @35 -lfds611_slist_new = lfds611_slist_new @36 -lfds611_slist_new_head = lfds611_slist_new_head @37 -lfds611_slist_new_next = lfds611_slist_new_next @38 -lfds611_slist_set_user_data_in_element = lfds611_slist_set_user_data_in_element @39 -lfds611_slist_single_threaded_physically_delete_all_elements = lfds611_slist_single_threaded_physically_delete_all_elements @40 -lfds611_slist_use = lfds611_slist_use @41 - -lfds611_stack_clear = lfds611_stack_clear @42 -lfds611_stack_delete = lfds611_stack_delete @43 -lfds611_stack_guaranteed_push = lfds611_stack_guaranteed_push @44 -lfds611_stack_new = lfds611_stack_new @45 -lfds611_stack_pop = lfds611_stack_pop @46 -lfds611_stack_push = lfds611_stack_push @47 -lfds611_stack_query = lfds611_stack_query @48 -lfds611_stack_use = lfds611_stack_use @49 - diff --git a/openair2/UTIL/LFDS/liblfds6.1.1/liblfds611/liblfds611.sln b/openair2/UTIL/LFDS/liblfds6.1.1/liblfds611/liblfds611.sln deleted file mode 100644 index de51b657c4..0000000000 --- a/openair2/UTIL/LFDS/liblfds6.1.1/liblfds611/liblfds611.sln +++ /dev/null @@ -1,38 +0,0 @@ - -Microsoft Visual Studio Solution File, Format Version 10.00 -# Visual Studio 2008 -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "liblfds611", "liblfds611.vcproj", "{F73AE755-F6D8-4C3A-977D-FBB40DC0ED05}" -EndProject -Global - GlobalSection(SolutionConfigurationPlatforms) = preSolution - Debug DLL|Win32 = Debug DLL|Win32 - Debug DLL|x64 = Debug DLL|x64 - Debug Lib|Win32 = Debug Lib|Win32 - Debug Lib|x64 = Debug Lib|x64 - Release DLL|Win32 = Release DLL|Win32 - Release DLL|x64 = Release DLL|x64 - Release Lib|Win32 = Release Lib|Win32 - Release Lib|x64 = Release Lib|x64 - EndGlobalSection - GlobalSection(ProjectConfigurationPlatforms) = postSolution - {F73AE755-F6D8-4C3A-977D-FBB40DC0ED05}.Debug DLL|Win32.ActiveCfg = Debug DLL|Win32 - {F73AE755-F6D8-4C3A-977D-FBB40DC0ED05}.Debug DLL|Win32.Build.0 = Debug DLL|Win32 - {F73AE755-F6D8-4C3A-977D-FBB40DC0ED05}.Debug DLL|x64.ActiveCfg = Debug DLL|x64 - {F73AE755-F6D8-4C3A-977D-FBB40DC0ED05}.Debug DLL|x64.Build.0 = Debug DLL|x64 - {F73AE755-F6D8-4C3A-977D-FBB40DC0ED05}.Debug Lib|Win32.ActiveCfg = Debug Lib|Win32 - {F73AE755-F6D8-4C3A-977D-FBB40DC0ED05}.Debug Lib|Win32.Build.0 = Debug Lib|Win32 - {F73AE755-F6D8-4C3A-977D-FBB40DC0ED05}.Debug Lib|x64.ActiveCfg = Debug Lib|x64 - {F73AE755-F6D8-4C3A-977D-FBB40DC0ED05}.Debug Lib|x64.Build.0 = Debug Lib|x64 - {F73AE755-F6D8-4C3A-977D-FBB40DC0ED05}.Release DLL|Win32.ActiveCfg = Release DLL|Win32 - {F73AE755-F6D8-4C3A-977D-FBB40DC0ED05}.Release DLL|Win32.Build.0 = Release DLL|Win32 - {F73AE755-F6D8-4C3A-977D-FBB40DC0ED05}.Release DLL|x64.ActiveCfg = Release DLL|x64 - {F73AE755-F6D8-4C3A-977D-FBB40DC0ED05}.Release DLL|x64.Build.0 = Release DLL|x64 - {F73AE755-F6D8-4C3A-977D-FBB40DC0ED05}.Release Lib|Win32.ActiveCfg = Release Lib|Win32 - {F73AE755-F6D8-4C3A-977D-FBB40DC0ED05}.Release Lib|Win32.Build.0 = Release Lib|Win32 - {F73AE755-F6D8-4C3A-977D-FBB40DC0ED05}.Release Lib|x64.ActiveCfg = Release Lib|x64 - {F73AE755-F6D8-4C3A-977D-FBB40DC0ED05}.Release Lib|x64.Build.0 = Release Lib|x64 - EndGlobalSection - GlobalSection(SolutionProperties) = preSolution - HideSolutionNode = FALSE - EndGlobalSection -EndGlobal diff --git a/openair2/UTIL/LFDS/liblfds6.1.1/liblfds611/liblfds611.vcproj b/openair2/UTIL/LFDS/liblfds6.1.1/liblfds611/liblfds611.vcproj deleted file mode 100644 index 96d5028eb8..0000000000 --- a/openair2/UTIL/LFDS/liblfds6.1.1/liblfds611/liblfds611.vcproj +++ /dev/null @@ -1,800 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/openair2/UTIL/LFDS/liblfds6.1.1/liblfds611/makefile.linux b/openair2/UTIL/LFDS/liblfds6.1.1/liblfds611/makefile.linux deleted file mode 100644 index 2655d8ec5e..0000000000 --- a/openair2/UTIL/LFDS/liblfds6.1.1/liblfds611/makefile.linux +++ /dev/null @@ -1,111 +0,0 @@ -##### paths ##### -OUTDIR := . -BINDIR = $(OUTDIR)/bin -OBJDIR = $(OUTDIR)/obj -INCDIR = inc -SRCDIR = src - -##### misc ##### -QUIETLY = 1>/dev/null 2>/dev/null - -##### sources, objects and libraries ##### -BINNAME = liblfds611 -AR_BINARY = $(BINDIR)/$(BINNAME).a -$(info $(AR_BINARY)) -SO_BINARY = $(BINDIR)/$(BINNAME).so -SRCDIRS = lfds611_abstraction lfds611_freelist lfds611_liblfds lfds611_queue lfds611_ringbuffer lfds611_slist lfds611_stack -# TRD : be aware - in the linux makefile, with the one-pass linking behaviour of the GNU linker, the order -# of source files matters! this is because it leads to the ordering of objects in the library and -# that in turn, since the data structures all use the freelist API and the abstraction API, has to be -# correct -# TRD : lfds611_abstraction_cas.c lfds611_abstraction_dcas.c lfds611_abstraction_increment.c are inlined and are compiled by every C file -SOURCES = lfds611_queue_delete.c lfds611_queue_new.c lfds611_queue_query.c lfds611_queue_queue.c \ - lfds611_ringbuffer_delete.c lfds611_ringbuffer_get_and_put.c lfds611_ringbuffer_new.c lfds611_ringbuffer_query.c \ - lfds611_slist_delete.c lfds611_slist_get_and_set.c lfds611_slist_link.c lfds611_slist_new.c \ - lfds611_stack_delete.c lfds611_stack_new.c lfds611_stack_push_pop.c lfds611_stack_query.c \ - lfds611_freelist_delete.c lfds611_freelist_get_and_set.c lfds611_freelist_new.c lfds611_freelist_query.c lfds611_freelist_pop_push.c \ - lfds611_liblfds_abstraction_test_helpers.c lfds611_liblfds_aligned_free.c lfds611_liblfds_aligned_malloc.c \ - lfds611_abstraction_free.c lfds611_abstraction_malloc.c -OBJECTS = $(patsubst %.c,$(OBJDIR)/%.o,$(notdir $(SOURCES))) - -##### CPU variants ##### -UNAME = $(shell uname -m) -GCCARCH = -march=$(UNAME) - -ifeq ($(UNAME),x86_64) - GCCARCH = -march=core2 -endif - -ifeq ($(findstring arm,$(UNAME)),arm) - GCCARCH = -march=armv6k -marm -endif - -##### tools ##### -MAKE = make -MFLAGS = - -DG = gcc -DGFLAGS = -MM -std=c99 -I"$(SRCDIR)" -I"$(INCDIR)" - -CC = gcc -CBASE = -Wall -Wno-unknown-pragmas -std=c99 $(GCCARCH) -pthread -c -I"$(SRCDIR)" -I"$(INCDIR)" -CFREL = -O2 -finline-functions -Wno-strict-aliasing -CFDBG = -O0 -g - -AR = ar -AFLAGS = -rcs - -LD = gcc -LFBASE = -Wall -std=c99 -shared -LFREL = -O2 -s -LFDBG = -O0 -g - -##### rel/dbg .a/.so variants ##### -ifeq ($(findstring so,$(MAKECMDGOALS)),so) - CBASE := $(CBASE) -fpic -endif - -CFLAGS = $(CBASE) $(CFDBG) -LFLAGS = $(LFBASE) $(LFDBG) - -ifeq ($(findstring rel,$(MAKECMDGOALS)),rel) - CFLAGS = $(CBASE) $(CFREL) - LFLAGS = $(LFBASE) $(LFREL) -endif - -##### search paths ##### -vpath %.c $(patsubst %,$(SRCDIR)/%:,$(SRCDIRS)) - -##### implicit rules ##### -$(OBJDIR)/%.o : %.c - @echo "Compiling $<" - @$(DG) $(DGFLAGS) $< >$(OBJDIR)/$*.d - @$(CC) $(CFLAGS) -o $@ $< - -##### explicit rules ##### -$(AR_BINARY) : $(OBJECTS) - @echo "Creating $(AR_BINARY)" - @$(AR) $(AFLAGS) $(AR_BINARY) $(OBJECTS) - -$(SO_BINARY) : $(OBJECTS) - @echo "Creating $(SO_BINARY)" - $(LD) $(LFLAGS) $(SYSLIBS) $(OBJECTS) -o $(SO_BINARY) - -##### phony ##### -.PHONY : clean arrel ardbg sorel sodbg - -clean : - @rm -f $(BINDIR)/$(BINNAME).* $(OBJDIR)/*.o $(OBJDIR)/*.d - -arrel : $(AR_BINARY) -ardbg : $(AR_BINARY) - -sorel : $(SO_BINARY) -sodbg : $(SO_BINARY) - -##### dependencies ##### --include $(DEPENDS) - -##### notes ##### -# TRD : we use -std=c99 purely to permit C++ style comments - diff --git a/openair2/UTIL/LFDS/liblfds6.1.1/liblfds611/makefile.windows b/openair2/UTIL/LFDS/liblfds6.1.1/liblfds611/makefile.windows deleted file mode 100644 index 9948e7cea7..0000000000 --- a/openair2/UTIL/LFDS/liblfds6.1.1/liblfds611/makefile.windows +++ /dev/null @@ -1,97 +0,0 @@ -##### paths ##### -BINDIR = bin -INCDIR = inc -OBJDIR = obj -SRCDIR = src - -##### misc ##### -QUIETLY = 1>nul 2>nul - -##### sources, objects and libraries ##### -BINNAME = liblfds611 -LIB_BINARY = $(BINDIR)\$(BINNAME).lib -DLL_BINARY = $(BINDIR)\$(BINNAME).dll -SRCDIRS = lfds611_abstraction lfds611_freelist lfds611_liblfds lfds611_queue lfds611_ringbuffer lfds611_slist lfds611_stack -# TRD : lfds611_abstraction_cas.c lfds611_abstraction_dcas.c lfds611_abstraction_increment.c are inlined and are compiled by every C file -SOURCES = lfds611_abstraction_free.c lfds611_abstraction_malloc.c \ - lfds611_freelist_delete.c lfds611_freelist_get_and_set.c lfds611_freelist_new.c lfds611_freelist_query.c lfds611_freelist_pop_push.c \ - lfds611_liblfds_abstraction_test_helpers.c lfds611_liblfds_aligned_free.c lfds611_liblfds_aligned_malloc.c \ - lfds611_queue_delete.c lfds611_queue_new.c lfds611_queue_query.c lfds611_queue_queue.c \ - lfds611_ringbuffer_delete.c lfds611_ringbuffer_get_and_put.c lfds611_ringbuffer_new.c lfds611_ringbuffer_query.c \ - lfds611_slist_delete.c lfds611_slist_get_and_set.c lfds611_slist_link.c lfds611_slist_new.c \ - lfds611_stack_delete.c lfds611_stack_new.c lfds611_stack_push_pop.c lfds611_stack_query.c -OBJECTS = $(patsubst %.c,$(OBJDIR)/%.obj,$(notdir $(SOURCES))) -SYSLIBS = kernel32.lib - -##### tools ##### -MAKE = make -MFLAGS = - -CC = cl -CBASE = /nologo /W4 /WX /c "-I$(SRCDIR)" "-I$(INCDIR)" "/Fd$(BINDIR)\$(BINNAME).pdb" /DUNICODE /D_UNICODE /DWIN32_LEAN_AND_MEAN -CFREL = /Ox /DNDEBUG -CFDBG = /Od /Gm /Zi /D_DEBUG - -AR = lib -AFLAGS = /nologo /subsystem:console /wx /verbose - -LD = link -LFBASE = /dll /def:$(BINNAME).def /nologo /subsystem:console /wx /nodefaultlib /nxcompat -LFREL = /incremental:no -LFDBG = /debug "/pdb:$(BINDIR)\$(BINNAME).pdb" - -##### variants ##### -CFLAGS = $(CBASE) $(CFDBG) /MTd -LFLAGS = $(LFBASE) $(LFDBG) -CLIB = libcmtd.lib - -ifeq ($(MAKECMDGOALS),librel) - CFLAGS = $(CBASE) $(CFREL) /MT - LFLAGS = $(LFBASE) $(LFREL) - CLIB = libcmt.lib -endif - -ifeq ($(MAKECMDGOALS),libdbg) - CFLAGS = $(CBASE) $(CFDBG) /MTd - LFLAGS = $(LFBASE) $(LFDBG) - CLIB = libcmtd.lib -endif - -ifeq ($(MAKECMDGOALS),dllrel) - CFLAGS = $(CBASE) $(CFREL) /MD - LFLAGS = $(LFBASE) $(LFREL) - CLIB = msvcrt.lib -endif - -ifeq ($(MAKECMDGOALS),dlldbg) - CFLAGS = $(CBASE) $(CFDBG) /MDd - LFLAGS = $(LFBASE) $(LFDBG) - CLIB = msvcrtd.lib -endif - -##### search paths ##### -vpath %.c $(patsubst %,$(SRCDIR)/%;,$(SRCDIRS)) - -##### implicit rules ##### -$(OBJDIR)/%.obj : %.c - $(CC) $(CFLAGS) "/Fo$@" $< - -##### explicit rules ##### -$(LIB_BINARY) : $(OBJECTS) - $(AR) $(AFLAGS) $(OBJECTS) /out:$(LIB_BINARY) - -$(DLL_BINARY) : $(OBJECTS) - $(LD) $(LFLAGS) $(CLIB) $(SYSLIBS) $(OBJECTS) /out:$(DLL_BINARY) - -##### phony ##### -.PHONY : clean librel libdbg dllrel dlldbg - -clean : - @erase /Q $(BINDIR)\$(BINNAME).* $(OBJDIR)\*.obj $(QUIETLY) - -librel : $(LIB_BINARY) -libdbg : $(LIB_BINARY) - -dllrel : $(DLL_BINARY) -dlldbg : $(DLL_BINARY) - diff --git a/openair2/UTIL/LFDS/liblfds6.1.1/liblfds611/readme.txt b/openair2/UTIL/LFDS/liblfds6.1.1/liblfds611/readme.txt deleted file mode 100644 index cbe196238c..0000000000 --- a/openair2/UTIL/LFDS/liblfds6.1.1/liblfds611/readme.txt +++ /dev/null @@ -1,147 +0,0 @@ -introduction -============ -Welcome to liblfds, a portable, license-free, lock-free data structure library -written in C. - -supported platforms -=================== -Out-of-the-box ports are provided for; - -Operating System CPU Toolchain Choices -================ ============= ================= -Windows 64-bit x64 1. Microsoft Visual Studio - 2. Microsoft Windows SDK and GNUmake - -Windows 32-bit x64, x86 1. Microsoft Visual Studio - 2. Visual C++ Express Edition - 3. Microsoft Windows SDK and GNUmake - -Windows Kernel x64, x86 1. Windows Driver Kit - -Linux 64-bit x64 1. GCC and GNUmake - -Linux 32-bit ARM, x64, x86 1. GCC and GNUmake - -For more information including version requirements, see the building guide (lfds). - -data structures -=============== -This release of liblfds provides the following; - - * Freelist - * Queue - * Ringbuffer (each element read by a single reader) - * Singly-linked list (logical delete only) - * Stack - -These are all many-readers, many-writers. - -liblfds on-line -=============== -On the liblfds home page, you will find the blog, a bugzilla, a forum, a -mediawiki and the current and all historical releases. - -The mediawiki contains comprehensive documentation for development, building, -testing and porting. - -http://www.liblfds.org - -license -======= -There is no license. You are free to use this code in any way. - -using -===== -Once built, there is a single header file, /inc/liblfds.h, which you must include -in your source code, and a single library file /bin/liblfds.*, where the suffix -depends on your platform and your build choice (static or dynamic), to which, -if statically built, you must link directly or, if dynamically built, you must -arrange your system such that the library can be found by the loader at run-time. - -testing -======= -The library comes with a command line test and benchmark program. This program -requires threads. As such, it is only suitable for platforms which can execute -a command line binary and provide thread support. Currently this means the test -and benchmark program works for all platforms except the Windows Kernel. - -For documentation, see the testing and benchmarking guide in the mediawiki. - -porting -======= -Both the test program and liblfds provide an abstraction layer which acts to -mask platform differences. Porting is the act of implementing on your platform -the functions which make up the abstraction layers. You do not need to port -the test program to port liblfds, but obviously it is recommended, so you can -test your port. - -To support liblfds, your platform MUST support; - - * atomic single-word* increment - * atomic single-word compare-and-swap - * atomic contiguous double-word compare-and-swap* - * malloc and free - * compiler directive for alignment of variables declared on the stack - * compiler directives for compiler barriers and processor barriers - -* A ''word'' here means a type equal in length to the platform pointer size. -* This requirement excludes the Alpha, IA64, MIPS, PowerPC and SPARC platforms. - -Also, your platform MAY support; - - * compiler keyword for function inlining - -To support the test programme, your platform MUST support; - - * determining the number of logical cores - * threads (starting and waiting on for completion) - -For documentation, see the porting guide (lfds) in the mediawiki. - -release history -=============== -release 1, 25th September 2009, svn revision 1574. - - initial release - -release 2, 5th October 2009, svn revision 1599. - - added abstraction layer for Windows kernel - - minor code tidyups/fixes - -release 3, 25th October 2009, svn revision 1652. - - added singly linked list (logical delete only) - - minor code tidyups/fixes - -release 4, 7th December 2009, svn revision 1716. - - added ARM support - - added benchmarking functionality to the test program - - fixed a profound and pervasive pointer - declaration bug; earlier releases of liblfds - *should not be used* - -release 5, 19th December 2009, svn revision 1738. - - fixed subtle queue bug, which also affected ringbuffer - and caused data re-ordering under high load - - added benchmarks for freelist, ringbuffer and stack - -release 6, 29th December 2009, svn revision 1746. - - fixed two implementation errors, which reduced performance, - spotted by Codeplug from "http://cboard.cprogramming.com". - -release 6.0.0, 18th December 2012, svn revision 2537 - - introduction of namespaces, e.g. the "lfds600_" prefix - code otherwise COMPLETELY AND WHOLLY UNCHANGED - this release is a stepping-stone to 6.1.0 - -release 6.0.1, 2nd January 2013, svn revision 3296 - - bug fix where an enum wasn't moved into the new namespacing policy - -release 6.1.0, 31th December 2012, svn revision 2600 - - fixed all existing non-enhancement bugs - - discovered some new bugs and fixed them too - - a very few minor changes/enhancements - -release 6.1.1, 2nd January 2013, svn revision 3297 - - crucial bug fix where compiler barriers for atomic operations - were not brought over from 7.0.0 during backporting - - minor fix for abstraction tests, two missing store barriers - diff --git a/openair2/UTIL/LFDS/liblfds6.1.1/liblfds611/runme_before_win_kernel_build_readme.txt b/openair2/UTIL/LFDS/liblfds6.1.1/liblfds611/runme_before_win_kernel_build_readme.txt deleted file mode 100644 index d7087ecd48..0000000000 --- a/openair2/UTIL/LFDS/liblfds6.1.1/liblfds611/runme_before_win_kernel_build_readme.txt +++ /dev/null @@ -1,32 +0,0 @@ -The Windows kernel build environment is primitive and has a number -of severe limitations; in particular, all source files must be in -one directory and it is not possible to choose the output binary type -(static or dynamic library) from the build command line; rather, -a string has to be modified in a text file used by the build (!) - -To deal with these limitations, it is necessary for a Windows kernel -build to run a batch file prior to building. - -There are two batch files, one for static library builds and the other -for dynamic library builds. - -They are both idempotent; you can run them as often as you like and -switch between them as often as you want. It's all fine; whenever -you run one of them, it will take you from whatever state you were -previously in, into the state you want to be in. - -Both batch files copy all the sources file into a single directory, -"/src/single_dir_for_windows_kernel/". - -The static library batch file will then copy "/sources.static" into -"/src/single_dir_for_windows_kernel/", which will cause a static -library to be built. - -The dynamic library batch file will then copy "/sources.dynamic" into -"/src/single_dir_for_windows_kernel/", which will cause a dynamic -library to be built. It will also copy "src/driver_entry.c" into -"/src/single_dir_for_windows_kernel/", since the linker requires -the DriverEntry function to exist for dynamic libraries, even -though it's not used. - - diff --git a/openair2/UTIL/LFDS/liblfds6.1.1/liblfds611/runme_before_win_kernel_dynamic_lib_build.bat b/openair2/UTIL/LFDS/liblfds6.1.1/liblfds611/runme_before_win_kernel_dynamic_lib_build.bat deleted file mode 100644 index 6a9f68b428..0000000000 --- a/openair2/UTIL/LFDS/liblfds6.1.1/liblfds611/runme_before_win_kernel_dynamic_lib_build.bat +++ /dev/null @@ -1,15 +0,0 @@ -@echo off -rmdir /q /s src\single_dir_for_windows_kernel 1>nul 2>nul -mkdir src\single_dir_for_windows_kernel 1>nul 2>nul -copy /y src\lfds611_abstraction\* src\single_dir_for_windows_kernel 1>nul 2>nul -copy /y src\lfds611_freelist\* src\single_dir_for_windows_kernel 1>nul 2>nul -copy /y src\lfds611_liblfds\* src\single_dir_for_windows_kernel 1>nul 2>nul -copy /y src\lfds611_queue\* src\single_dir_for_windows_kernel 1>nul 2>nul -copy /y src\lfds611_ringbuffer\* src\single_dir_for_windows_kernel 1>nul 2>nul -copy /y src\lfds611_slist\* src\single_dir_for_windows_kernel 1>nul 2>nul -copy /y src\lfds611_stack\* src\single_dir_for_windows_kernel 1>nul 2>nul -copy /y sources.dynamic src\single_dir_for_windows_kernel\sources 1>nul 2>nul -copy /y src\driver_entry.c src\single_dir_for_windows_kernel 1>nul 2>nul -echo Windows kernel dynamic library build directory structure created. -echo (Note the effects of this batch file are idempotent). - diff --git a/openair2/UTIL/LFDS/liblfds6.1.1/liblfds611/runme_before_win_kernel_static_lib_build.bat b/openair2/UTIL/LFDS/liblfds6.1.1/liblfds611/runme_before_win_kernel_static_lib_build.bat deleted file mode 100644 index a3b9362b0e..0000000000 --- a/openair2/UTIL/LFDS/liblfds6.1.1/liblfds611/runme_before_win_kernel_static_lib_build.bat +++ /dev/null @@ -1,15 +0,0 @@ -@echo off -rmdir /q /s src\single_dir_for_windows_kernel 1>nul 2>nul -mkdir src\single_dir_for_windows_kernel 1>nul 2>nul -copy /y src\lfds611_abstraction\* src\single_dir_for_windows_kernel 1>nul 2>nul -copy /y src\lfds611_freelist\* src\single_dir_for_windows_kernel 1>nul 2>nul -copy /y src\lfds611_liblfds\* src\single_dir_for_windows_kernel 1>nul 2>nul -copy /y src\lfds611_queue\* src\single_dir_for_windows_kernel 1>nul 2>nul -copy /y src\lfds611_ringbuffer\* src\single_dir_for_windows_kernel 1>nul 2>nul -copy /y src\lfds611_slist\* src\single_dir_for_windows_kernel 1>nul 2>nul -copy /y src\lfds611_stack\* src\single_dir_for_windows_kernel 1>nul 2>nul -copy /y sources.static src\single_dir_for_windows_kernel\sources 1>nul 2>nul -erase /f src\single_dir_for_windows_kernel\driver_entry.c 1>nul 2>nul -echo Windows kernel static library build directory structure created. -echo (Note the effects of this batch file are idempotent). - diff --git a/openair2/UTIL/LFDS/liblfds6.1.1/liblfds611/sources.dynamic b/openair2/UTIL/LFDS/liblfds6.1.1/liblfds611/sources.dynamic deleted file mode 100644 index 0ed73dc06e..0000000000 --- a/openair2/UTIL/LFDS/liblfds6.1.1/liblfds611/sources.dynamic +++ /dev/null @@ -1,37 +0,0 @@ -MSC_WARNING_LEVEL = /WX /W4 -DLLDEF = ../../liblfds611.def -TARGETNAME = liblfds611 -TARGETPATH = ../../bin/ -TARGETTYPE = EXPORT_DRIVER -UMTYPE = nt -USER_C_FLAGS = /DWIN_KERNEL_BUILD - -INCLUDES = ..;../../inc/ -SOURCES = lfds611_abstraction_free.c \ - lfds611_abstraction_malloc.c \ - lfds611_freelist_delete.c \ - lfds611_freelist_get_and_set.c \ - lfds611_freelist_new.c \ - lfds611_freelist_pop_push.c \ - lfds611_freelist_query.c \ - lfds611_liblfds_abstraction_test_helpers.c \ - lfds611_liblfds_aligned_free.c \ - lfds611_liblfds_aligned_malloc.c \ - lfds611_queue_delete.c \ - lfds611_queue_new.c \ - lfds611_queue_query.c \ - lfds611_queue_queue.c \ - lfds611_ringbuffer_delete.c \ - lfds611_ringbuffer_get_and_put.c \ - lfds611_ringbuffer_new.c \ - lfds611_ringbuffer_query.c \ - lfds611_slist_delete.c \ - lfds611_slist_get_and_set.c \ - lfds611_slist_link.c \ - lfds611_slist_new.c \ - lfds611_stack_delete.c \ - lfds611_stack_new.c \ - lfds611_stack_push_pop.c \ - lfds611_stack_query.c \ - driver_entry.c - diff --git a/openair2/UTIL/LFDS/liblfds6.1.1/liblfds611/sources.static b/openair2/UTIL/LFDS/liblfds6.1.1/liblfds611/sources.static deleted file mode 100644 index 64965033ed..0000000000 --- a/openair2/UTIL/LFDS/liblfds6.1.1/liblfds611/sources.static +++ /dev/null @@ -1,35 +0,0 @@ -MSC_WARNING_LEVEL = /WX /W4 -TARGETNAME = liblfds611 -TARGETPATH = ../../bin/ -TARGETTYPE = DRIVER_LIBRARY -UMTYPE = nt -USER_C_FLAGS = /DWIN_KERNEL_BUILD - -INCLUDES = ..;../../inc/ -SOURCES = lfds611_abstraction_free.c \ - lfds611_abstraction_malloc.c \ - lfds611_freelist_delete.c \ - lfds611_freelist_get_and_set.c \ - lfds611_freelist_new.c \ - lfds611_freelist_pop_push.c \ - lfds611_freelist_query.c \ - lfds611_liblfds_abstraction_test_helpers.c \ - lfds611_liblfds_aligned_free.c \ - lfds611_liblfds_aligned_malloc.c \ - lfds611_queue_delete.c \ - lfds611_queue_new.c \ - lfds611_queue_query.c \ - lfds611_queue_queue.c \ - lfds611_ringbuffer_delete.c \ - lfds611_ringbuffer_get_and_put.c \ - lfds611_ringbuffer_new.c \ - lfds611_ringbuffer_query.c \ - lfds611_slist_delete.c \ - lfds611_slist_get_and_set.c \ - lfds611_slist_link.c \ - lfds611_slist_new.c \ - lfds611_stack_delete.c \ - lfds611_stack_new.c \ - lfds611_stack_push_pop.c \ - lfds611_stack_query.c - diff --git a/openair2/UTIL/LFDS/liblfds6.1.1/liblfds611/src/dirs b/openair2/UTIL/LFDS/liblfds6.1.1/liblfds611/src/dirs deleted file mode 100644 index 64e002cc57..0000000000 --- a/openair2/UTIL/LFDS/liblfds6.1.1/liblfds611/src/dirs +++ /dev/null @@ -1,3 +0,0 @@ -DIRS = single_dir_for_windows_kernel - - diff --git a/openair2/UTIL/LFDS/liblfds6.1.1/liblfds611/src/driver_entry.c b/openair2/UTIL/LFDS/liblfds6.1.1/liblfds611/src/driver_entry.c deleted file mode 100644 index a2dac56f2d..0000000000 --- a/openair2/UTIL/LFDS/liblfds6.1.1/liblfds611/src/driver_entry.c +++ /dev/null @@ -1,16 +0,0 @@ -#include "liblfds611_internal.h" - - - - - -/****************************************************************************/ -#pragma warning( disable : 4100 ) - -NTSTATUS DriverEntry( struct _DRIVER_OBJECT *DriverObject, PUNICODE_STRING RegistryPath ) -{ - return( STATUS_SUCCESS ); -} - -#pragma warning( default : 4100 ) - diff --git a/openair2/UTIL/LFDS/liblfds6.1.1/liblfds611/src/driver_entry_readme.txt b/openair2/UTIL/LFDS/liblfds6.1.1/liblfds611/src/driver_entry_readme.txt deleted file mode 100644 index a3979772f2..0000000000 --- a/openair2/UTIL/LFDS/liblfds6.1.1/liblfds611/src/driver_entry_readme.txt +++ /dev/null @@ -1,4 +0,0 @@ -This C file (driver_entry.c) is used when building a dynamic library for -the Windows kernel. It exists to work around one of the limitations of -that build environment. It is not used by any other build; just ignore it. - diff --git a/openair2/UTIL/LFDS/liblfds6.1.1/liblfds611/src/lfds611_abstraction/lfds611_abstraction_cas.c b/openair2/UTIL/LFDS/liblfds6.1.1/liblfds611/src/lfds611_abstraction/lfds611_abstraction_cas.c deleted file mode 100644 index ed3d7d7d26..0000000000 --- a/openair2/UTIL/LFDS/liblfds6.1.1/liblfds611/src/lfds611_abstraction/lfds611_abstraction_cas.c +++ /dev/null @@ -1,71 +0,0 @@ -#include "lfds611_abstraction_internal_body.h" - - - - - -/****************************************************************************/ -#if (defined _WIN32 && defined _MSC_VER) - -/* TRD : 64 bit and 32 bit Windows (user-mode or kernel) on any CPU with the Microsoft C compiler - - _WIN32 indicates 64-bit or 32-bit Windows - _MSC_VER indicates Microsoft C compiler -*/ - -static LFDS611_INLINE lfds611_atom_t lfds611_abstraction_cas( volatile lfds611_atom_t *destination, lfds611_atom_t exchange, lfds611_atom_t compare ) -{ - lfds611_atom_t - rv; - - assert( destination != NULL ); - // TRD : exchange can be any value in its range - // TRD : compare can be any value in its range - - LFDS611_BARRIER_COMPILER_FULL; - - rv = (lfds611_atom_t) _InterlockedCompareExchangePointer( (void * volatile *) destination, (void *) exchange, (void *) compare ); - - LFDS611_BARRIER_COMPILER_FULL; - - return( rv ); -} - -#endif - - - - - -/****************************************************************************/ -#if (__GNUC__ >= 4 && __GNUC_MINOR__ >= 1 && __GNUC_PATCHLEVEL__ >= 0) - -/* TRD : any OS on any CPU with GCC 4.1.0 or better - - GCC 4.1.0 introduced the __sync_*() atomic intrinsics - - __GNUC__ / __GNUC_MINOR__ / __GNUC_PATCHLEVEL__ indicates GCC and which version -*/ - -static LFDS611_INLINE lfds611_atom_t lfds611_abstraction_cas( volatile lfds611_atom_t *destination, lfds611_atom_t exchange, lfds611_atom_t compare ) -{ - lfds611_atom_t - rv; - - assert( destination != NULL ); - // TRD : exchange can be any value in its range - // TRD : compare can be any value in its range - - // TRD : note the different argument order for the GCC instrinsic to the MSVC instrinsic - - LFDS611_BARRIER_COMPILER_FULL; - - rv = (lfds611_atom_t) __sync_val_compare_and_swap( destination, compare, exchange ); - - LFDS611_BARRIER_COMPILER_FULL; - - return( rv ); -} - -#endif - diff --git a/openair2/UTIL/LFDS/liblfds6.1.1/liblfds611/src/lfds611_abstraction/lfds611_abstraction_dcas.c b/openair2/UTIL/LFDS/liblfds6.1.1/liblfds611/src/lfds611_abstraction/lfds611_abstraction_dcas.c deleted file mode 100644 index 61f243735b..0000000000 --- a/openair2/UTIL/LFDS/liblfds6.1.1/liblfds611/src/lfds611_abstraction/lfds611_abstraction_dcas.c +++ /dev/null @@ -1,157 +0,0 @@ -#include "lfds611_abstraction_internal_body.h" - - - - - -/****************************************************************************/ -#if (defined _WIN64 && defined _MSC_VER) - -/* TRD : 64 bit Windows (user-mode or kernel) on any CPU with the Microsoft C compiler - - _WIN64 indicates 64 bit Windows - _MSC_VER indicates Microsoft C compiler -*/ - -static LFDS611_INLINE unsigned char lfds611_abstraction_dcas( volatile lfds611_atom_t *destination, lfds611_atom_t *exchange, lfds611_atom_t *compare ) -{ - unsigned char - cas_result; - - assert( destination != NULL ); - assert( exchange != NULL ); - assert( compare != NULL ); - - LFDS611_BARRIER_COMPILER_FULL; - - cas_result = _InterlockedCompareExchange128( (volatile __int64 *) destination, (__int64) *(exchange+1), (__int64) *exchange, (__int64 *) compare ); - - LFDS611_BARRIER_COMPILER_FULL; - - return( cas_result ) ; -} - -#endif - - - - - -/****************************************************************************/ -#if (!defined _WIN64 && defined _WIN32 && defined _MSC_VER) - -/* TRD : 32 bit Windows (user-mode or kernel) on any CPU with the Microsoft C compiler - - (!defined _WIN64 && defined _WIN32) indicates 32 bit Windows - _MSC_VER indicates Microsoft C compiler -*/ - -static LFDS611_INLINE unsigned char lfds611_abstraction_dcas( volatile lfds611_atom_t *destination, lfds611_atom_t *exchange, lfds611_atom_t *compare ) -{ - __int64 - original_compare; - - assert( destination != NULL ); - assert( exchange != NULL ); - assert( compare != NULL ); - - *(__int64 *) &original_compare = *(__int64 *) compare; - - LFDS611_BARRIER_COMPILER_FULL; - - *(__int64 *) compare = _InterlockedCompareExchange64( (volatile __int64 *) destination, *(__int64 *) exchange, *(__int64 *) compare ); - - LFDS611_BARRIER_COMPILER_FULL; - - return( (unsigned char) (*(__int64 *) compare == *(__int64 *) &original_compare) ); -} - -#endif - - - - - -/****************************************************************************/ -#if (defined __x86_64__ && defined __GNUC__) - -/* TRD : any OS on x64 with GCC - - __x86_64__ indicates x64 - __GNUC__ indicates GCC -*/ - -static LFDS611_INLINE unsigned char lfds611_abstraction_dcas( volatile lfds611_atom_t *destination, lfds611_atom_t *exchange, lfds611_atom_t *compare ) -{ - unsigned char - cas_result; - - assert( destination != NULL ); - assert( exchange != NULL ); - assert( compare != NULL ); - - // TRD : __asm__ with "memory" in the clobber list is for GCC a full compiler barrier - __asm__ __volatile__ - ( - "lock;" // make cmpxchg16b atomic - "cmpxchg16b %0;" // cmpxchg16b sets ZF on success - "setz %3;" // if ZF set, set cas_result to 1 - - // output - : "+m" (*(volatile lfds611_atom_t (*)[2]) destination), "+a" (*compare), "+d" (*(compare+1)), "=q" (cas_result) - - // input - : "b" (*exchange), "c" (*(exchange+1)) - - // clobbered - : "cc", "memory" - ); - - return( cas_result ); -} - -#endif - - - - - -/****************************************************************************/ -#if ((defined __i686__ || defined __arm__) && __GNUC__ >= 4 && __GNUC_MINOR__ >= 1 && __GNUC_PATCHLEVEL__ >= 0) - -/* TRD : any OS on x86 or ARM with GCC 4.1.0 or better - - GCC 4.1.0 introduced the __sync_*() atomic intrinsics - - __GNUC__ / __GNUC_MINOR__ / __GNUC_PATCHLEVEL__ indicates GCC and which version -*/ - -static LFDS611_INLINE unsigned char lfds611_abstraction_dcas( volatile lfds611_atom_t *destination, lfds611_atom_t *exchange, lfds611_atom_t *compare ) -{ - unsigned char - cas_result = 0; - - unsigned long long int - original_destination; - - assert( destination != NULL ); - assert( exchange != NULL ); - assert( compare != NULL ); - - LFDS611_BARRIER_COMPILER_FULL; - - original_destination = __sync_val_compare_and_swap( (volatile unsigned long long int *) destination, *(unsigned long long int *) compare, *(unsigned long long int *) exchange ); - - LFDS611_BARRIER_COMPILER_FULL; - - if( original_destination == *(unsigned long long int *) compare ) - cas_result = 1; - - *(unsigned long long int *) compare = original_destination; - - return( cas_result ); -} - -#endif - - diff --git a/openair2/UTIL/LFDS/liblfds6.1.1/liblfds611/src/lfds611_abstraction/lfds611_abstraction_free.c b/openair2/UTIL/LFDS/liblfds6.1.1/liblfds611/src/lfds611_abstraction/lfds611_abstraction_free.c deleted file mode 100644 index e582374c98..0000000000 --- a/openair2/UTIL/LFDS/liblfds6.1.1/liblfds611/src/lfds611_abstraction/lfds611_abstraction_free.c +++ /dev/null @@ -1,44 +0,0 @@ -#include "lfds611_abstraction_internal_wrapper.h" - - - - - -/****************************************************************************/ -#if (!defined WIN_KERNEL_BUILD) - -/* TRD : any OS except Windows kernel on any CPU with any compiler - - !WIN_KERNEL_BUILD indicates not Windows kernel -*/ - -void lfds611_abstraction_free( void *memory ) -{ - free( memory ); - - return; -} - -#endif - - - - - -/****************************************************************************/ -#if (defined WIN_KERNEL_BUILD) - -/* TRD : any Windows (kernel) on any CPU with the Microsoft C compiler - - WIN_KERNEL_BUILD indicates Windows kernel -*/ - -void lfds611_abstraction_free( void *memory ) -{ - ExFreePoolWithTag( memory, 'sdfl' ); - - return; -} - -#endif - diff --git a/openair2/UTIL/LFDS/liblfds6.1.1/liblfds611/src/lfds611_abstraction/lfds611_abstraction_increment.c b/openair2/UTIL/LFDS/liblfds6.1.1/liblfds611/src/lfds611_abstraction/lfds611_abstraction_increment.c deleted file mode 100644 index 4cdd068d02..0000000000 --- a/openair2/UTIL/LFDS/liblfds6.1.1/liblfds611/src/lfds611_abstraction/lfds611_abstraction_increment.c +++ /dev/null @@ -1,98 +0,0 @@ -#include "lfds611_abstraction_internal_body.h" - - - - - -/****************************************************************************/ -#if (defined _WIN64 && defined _MSC_VER) - -/* TRD : 64 bit Windows (user-mode or kernel) on any CPU with the Microsoft C compiler - - _WIN64 indicates 64 bit Windows - _MSC_VER indicates Microsoft C compiler -*/ - -static LFDS611_INLINE lfds611_atom_t lfds611_abstraction_increment( volatile lfds611_atom_t *value ) -{ - lfds611_atom_t - rv; - - assert( value != NULL ); - - LFDS611_BARRIER_COMPILER_FULL; - - rv = (lfds611_atom_t) _InterlockedIncrement64( (__int64 *) value ); - - LFDS611_BARRIER_COMPILER_FULL; - - return( rv ); -} - -#endif - - - - - -/****************************************************************************/ -#if (!defined _WIN64 && defined _WIN32 && defined _MSC_VER) - -/* TRD : 32 bit Windows (user-mode or kernel) on any CPU with the Microsoft C compiler - - (!defined _WIN64 && defined _WIN32) indicates 32 bit Windows - _MSC_VER indicates Microsoft C compiler -*/ - -static LFDS611_INLINE lfds611_atom_t lfds611_abstraction_increment( volatile lfds611_atom_t *value ) -{ - lfds611_atom_t - rv; - - assert( value != NULL ); - - LFDS611_BARRIER_COMPILER_FULL; - - rv = (lfds611_atom_t) _InterlockedIncrement( (long int *) value ); - - LFDS611_BARRIER_COMPILER_FULL; - - return( rv ); -} - -#endif - - - - - -/****************************************************************************/ -#if (__GNUC__ >= 4 && __GNUC_MINOR__ >= 1 && __GNUC_PATCHLEVEL__ >= 0) - -/* TRD : any OS on any CPU with GCC 4.1.0 or better - - GCC 4.1.0 introduced the __sync_*() atomic intrinsics - - __GNUC__ / __GNUC_MINOR__ / __GNUC_PATCHLEVEL__ indicates GCC and which version -*/ - -static LFDS611_INLINE lfds611_atom_t lfds611_abstraction_increment( volatile lfds611_atom_t *value ) -{ - lfds611_atom_t - rv; - - assert( value != NULL ); - - // TRD : no need for casting here, GCC has a __sync_add_and_fetch() for all native types - - LFDS611_BARRIER_COMPILER_FULL; - - rv = (lfds611_atom_t) __sync_add_and_fetch( value, 1 ); - - LFDS611_BARRIER_COMPILER_FULL; - - return( rv ); -} - -#endif - diff --git a/openair2/UTIL/LFDS/liblfds6.1.1/liblfds611/src/lfds611_abstraction/lfds611_abstraction_internal_body.h b/openair2/UTIL/LFDS/liblfds6.1.1/liblfds611/src/lfds611_abstraction/lfds611_abstraction_internal_body.h deleted file mode 100644 index ac10143514..0000000000 --- a/openair2/UTIL/LFDS/liblfds6.1.1/liblfds611/src/lfds611_abstraction/lfds611_abstraction_internal_body.h +++ /dev/null @@ -1,2 +0,0 @@ -/***** private prototypes *****/ - diff --git a/openair2/UTIL/LFDS/liblfds6.1.1/liblfds611/src/lfds611_abstraction/lfds611_abstraction_internal_wrapper.h b/openair2/UTIL/LFDS/liblfds6.1.1/liblfds611/src/lfds611_abstraction/lfds611_abstraction_internal_wrapper.h deleted file mode 100644 index c9129c2748..0000000000 --- a/openair2/UTIL/LFDS/liblfds6.1.1/liblfds611/src/lfds611_abstraction/lfds611_abstraction_internal_wrapper.h +++ /dev/null @@ -1,6 +0,0 @@ -/***** the library wide include file *****/ -#include "liblfds611_internal.h" - -/***** the internal header body *****/ -#include "lfds611_abstraction_internal_body.h" - diff --git a/openair2/UTIL/LFDS/liblfds6.1.1/liblfds611/src/lfds611_abstraction/lfds611_abstraction_malloc.c b/openair2/UTIL/LFDS/liblfds6.1.1/liblfds611/src/lfds611_abstraction/lfds611_abstraction_malloc.c deleted file mode 100644 index d97b820872..0000000000 --- a/openair2/UTIL/LFDS/liblfds6.1.1/liblfds611/src/lfds611_abstraction/lfds611_abstraction_malloc.c +++ /dev/null @@ -1,40 +0,0 @@ -#include "lfds611_abstraction_internal_wrapper.h" - - - - - -/****************************************************************************/ -#if (!defined WIN_KERNEL_BUILD) - -/* TRD : any OS except Windows kernel on any CPU with any compiler - - !WIN_KERNEL_BUILD indicates not Windows kernel -*/ - -void *lfds611_abstraction_malloc( size_t size ) -{ - return( malloc(size) ); -} - -#endif - - - - - -/****************************************************************************/ -#if (defined WIN_KERNEL_BUILD) - -/* TRD : any Windows (kernel) on any CPU with the Microsoft C compiler - - WIN_KERNEL_BUILD indicates Windows kernel -*/ - -void *lfds611_abstraction_malloc( size_t size ) -{ - return( ExAllocatePoolWithTag(NonPagedPool, size, 'sdfl') ); -} - -#endif - diff --git a/openair2/UTIL/LFDS/liblfds6.1.1/liblfds611/src/lfds611_freelist/lfds611_freelist_delete.c b/openair2/UTIL/LFDS/liblfds6.1.1/liblfds611/src/lfds611_freelist/lfds611_freelist_delete.c deleted file mode 100644 index b5de6f6ac2..0000000000 --- a/openair2/UTIL/LFDS/liblfds6.1.1/liblfds611/src/lfds611_freelist/lfds611_freelist_delete.c +++ /dev/null @@ -1,35 +0,0 @@ -#include "lfds611_freelist_internal.h" - - - - - -/****************************************************************************/ -void lfds611_freelist_delete( struct lfds611_freelist_state *fs, void (*user_data_delete_function)(void *user_data, void *user_state), void *user_state ) -{ - struct lfds611_freelist_element - *fe; - - void - *user_data; - - assert( fs != NULL ); - // TRD : user_data_delete_function can be NULL - // TRD : user_state can be NULL - - // TRD : leading load barrier not required as it will be performed by the pop - - while( lfds611_freelist_pop(fs, &fe) ) { - if( user_data_delete_function != NULL ) { - lfds611_freelist_get_user_data_from_element( fe, &user_data ); - user_data_delete_function( user_data, user_state ); - } - - lfds611_liblfds_aligned_free( fe ); - } - - lfds611_liblfds_aligned_free( fs ); - - return; -} - diff --git a/openair2/UTIL/LFDS/liblfds6.1.1/liblfds611/src/lfds611_freelist/lfds611_freelist_get_and_set.c b/openair2/UTIL/LFDS/liblfds6.1.1/liblfds611/src/lfds611_freelist/lfds611_freelist_get_and_set.c deleted file mode 100644 index 9e5108c5b5..0000000000 --- a/openair2/UTIL/LFDS/liblfds6.1.1/liblfds611/src/lfds611_freelist/lfds611_freelist_get_and_set.c +++ /dev/null @@ -1,37 +0,0 @@ -#include "lfds611_freelist_internal.h" - - - - - -/****************************************************************************/ -void *lfds611_freelist_get_user_data_from_element( struct lfds611_freelist_element *fe, void **user_data ) -{ - assert( fe != NULL ); - // TRD : user_data can be NULL - - LFDS611_BARRIER_LOAD; - - if( user_data != NULL ) - *user_data = fe->user_data; - - return( fe->user_data ); -} - - - - - -/****************************************************************************/ -void lfds611_freelist_set_user_data_in_element( struct lfds611_freelist_element *fe, void *user_data ) -{ - assert( fe != NULL ); - // TRD : user_data can be NULL - - fe->user_data = user_data; - - LFDS611_BARRIER_STORE; - - return; -} - diff --git a/openair2/UTIL/LFDS/liblfds6.1.1/liblfds611/src/lfds611_freelist/lfds611_freelist_internal.h b/openair2/UTIL/LFDS/liblfds6.1.1/liblfds611/src/lfds611_freelist/lfds611_freelist_internal.h deleted file mode 100644 index a593a4d959..0000000000 --- a/openair2/UTIL/LFDS/liblfds6.1.1/liblfds611/src/lfds611_freelist/lfds611_freelist_internal.h +++ /dev/null @@ -1,40 +0,0 @@ -/***** the library wide include file *****/ -#include "liblfds611_internal.h" - -/***** defines *****/ -#define LFDS611_FREELIST_POINTER 0 -#define LFDS611_FREELIST_COUNTER 1 -#define LFDS611_FREELIST_PAC_SIZE 2 - -/***** structures *****/ -#pragma pack( push, LFDS611_ALIGN_DOUBLE_POINTER ) - -struct lfds611_freelist_state { - struct lfds611_freelist_element - *volatile top[LFDS611_FREELIST_PAC_SIZE]; - - int - (*user_data_init_function)( void **user_data, void *user_state ); - - void - *user_state; - - lfds611_atom_t - aba_counter, - element_count; -}; - -struct lfds611_freelist_element { - struct lfds611_freelist_element - *next[LFDS611_FREELIST_PAC_SIZE]; - - void - *user_data; -}; - -#pragma pack( pop ) - -/***** private prototypes *****/ -lfds611_atom_t lfds611_freelist_internal_new_element( struct lfds611_freelist_state *fs, struct lfds611_freelist_element **fe ); -void lfds611_freelist_internal_validate( struct lfds611_freelist_state *fs, struct lfds611_validation_info *vi, enum lfds611_data_structure_validity *lfds611_freelist_validity ); - diff --git a/openair2/UTIL/LFDS/liblfds6.1.1/liblfds611/src/lfds611_freelist/lfds611_freelist_new.c b/openair2/UTIL/LFDS/liblfds6.1.1/liblfds611/src/lfds611_freelist/lfds611_freelist_new.c deleted file mode 100644 index 2eeae80097..0000000000 --- a/openair2/UTIL/LFDS/liblfds6.1.1/liblfds611/src/lfds611_freelist/lfds611_freelist_new.c +++ /dev/null @@ -1,136 +0,0 @@ -#include "lfds611_freelist_internal.h" - - - - - -/****************************************************************************/ -int lfds611_freelist_new( struct lfds611_freelist_state **fs, lfds611_atom_t number_elements, int (*user_data_init_function)(void **user_data, void *user_state), void *user_state ) -{ - int - rv = 0; - - lfds611_atom_t - element_count; - - assert( fs != NULL ); - // TRD : number_elements can be any value in its range - // TRD : user_data_init_function can be NULL - - *fs = (struct lfds611_freelist_state *) lfds611_liblfds_aligned_malloc( sizeof(struct lfds611_freelist_state), LFDS611_ALIGN_DOUBLE_POINTER ); - - if( (*fs) != NULL ) { - (*fs)->top[LFDS611_FREELIST_POINTER] = NULL; - (*fs)->top[LFDS611_FREELIST_COUNTER] = 0; - (*fs)->user_data_init_function = user_data_init_function; - (*fs)->user_state = user_state; - (*fs)->aba_counter = 0; - (*fs)->element_count = 0; - - element_count = lfds611_freelist_new_elements( *fs, number_elements ); - - if( element_count == number_elements ) - rv = 1; - - if( element_count != number_elements ) { - lfds611_liblfds_aligned_free( (*fs) ); - *fs = NULL; - } - } - - LFDS611_BARRIER_STORE; - - return( rv ); -} - - - - - -/****************************************************************************/ -//#pragma warning( disable : 4100 ) - -void lfds611_freelist_use( struct lfds611_freelist_state *fs ) -{ - assert( fs != NULL ); - - LFDS611_BARRIER_LOAD; - - return; -} - -//#pragma warning( default : 4100 ) - - - - - -/****************************************************************************/ -lfds611_atom_t lfds611_freelist_new_elements( struct lfds611_freelist_state *fs, lfds611_atom_t number_elements ) -{ - struct lfds611_freelist_element - *fe; - - lfds611_atom_t - loop, - count = 0; - - assert( fs != NULL ); - // TRD : number_elements can be any value in its range - // TRD : user_data_init_function can be NULL - - for( loop = 0 ; loop < number_elements ; loop++ ) - if( lfds611_freelist_internal_new_element(fs, &fe) ) { - lfds611_freelist_push( fs, fe ); - count++; - } - - return( count ); -} - - - - - -/****************************************************************************/ -lfds611_atom_t lfds611_freelist_internal_new_element( struct lfds611_freelist_state *fs, struct lfds611_freelist_element **fe ) -{ - lfds611_atom_t - rv = 0; - - assert( fs != NULL ); - assert( fe != NULL ); - - /* TRD : basically, does what you'd expect; - - allocates an element - calls the user init function - if anything fails, cleans up, - sets *fe to NULL - and returns 0 - */ - - *fe = (struct lfds611_freelist_element *) lfds611_liblfds_aligned_malloc( sizeof(struct lfds611_freelist_element), LFDS611_ALIGN_DOUBLE_POINTER ); - - if( *fe != NULL ) { - if( fs->user_data_init_function == NULL ) { - (*fe)->user_data = NULL; - rv = 1; - } - - if( fs->user_data_init_function != NULL ) { - rv = fs->user_data_init_function( &(*fe)->user_data, fs->user_state ); - - if( rv == 0 ) { - lfds611_liblfds_aligned_free( *fe ); - *fe = NULL; - } - } - } - - if( rv == 1 ) - lfds611_abstraction_increment( (lfds611_atom_t *) &fs->element_count ); - - return( rv ); -} - diff --git a/openair2/UTIL/LFDS/liblfds6.1.1/liblfds611/src/lfds611_freelist/lfds611_freelist_pop_push.c b/openair2/UTIL/LFDS/liblfds6.1.1/liblfds611/src/lfds611_freelist/lfds611_freelist_pop_push.c deleted file mode 100644 index c0e2282414..0000000000 --- a/openair2/UTIL/LFDS/liblfds6.1.1/liblfds611/src/lfds611_freelist/lfds611_freelist_pop_push.c +++ /dev/null @@ -1,87 +0,0 @@ -#include "lfds611_freelist_internal.h" - - - - - -/****************************************************************************/ -struct lfds611_freelist_element *lfds611_freelist_pop( struct lfds611_freelist_state *fs, struct lfds611_freelist_element **fe ) -{ - LFDS611_ALIGN(LFDS611_ALIGN_DOUBLE_POINTER) struct lfds611_freelist_element - *fe_local[LFDS611_FREELIST_PAC_SIZE]; - - assert( fs != NULL ); - assert( fe != NULL ); - - LFDS611_BARRIER_LOAD; - - fe_local[LFDS611_FREELIST_COUNTER] = fs->top[LFDS611_FREELIST_COUNTER]; - fe_local[LFDS611_FREELIST_POINTER] = fs->top[LFDS611_FREELIST_POINTER]; - - /* TRD : note that lfds611_abstraction_dcas loads the original value of the destination (fs->top) into the compare (fe_local) - (this happens of course after the CAS itself has occurred inside lfds611_abstraction_dcas) - */ - - do { - if( fe_local[LFDS611_FREELIST_POINTER] == NULL ) { - *fe = NULL; - return( *fe ); - } - } while( 0 == lfds611_abstraction_dcas((volatile lfds611_atom_t *) fs->top, (lfds611_atom_t *) fe_local[LFDS611_FREELIST_POINTER]->next, (lfds611_atom_t *) fe_local) ); - - *fe = (struct lfds611_freelist_element *) fe_local[LFDS611_FREELIST_POINTER]; - - return( *fe ); -} - - - - - -/****************************************************************************/ -struct lfds611_freelist_element *lfds611_freelist_guaranteed_pop( struct lfds611_freelist_state *fs, struct lfds611_freelist_element **fe ) -{ - assert( fs != NULL ); - assert( fe != NULL ); - - lfds611_freelist_internal_new_element( fs, fe ); - - return( *fe ); -} - - - - - -/****************************************************************************/ -void lfds611_freelist_push( struct lfds611_freelist_state *fs, struct lfds611_freelist_element *fe ) -{ - LFDS611_ALIGN(LFDS611_ALIGN_DOUBLE_POINTER) struct lfds611_freelist_element - *fe_local[LFDS611_FREELIST_PAC_SIZE], - *original_fe_next[LFDS611_FREELIST_PAC_SIZE]; - - assert( fs != NULL ); - assert( fe != NULL ); - - LFDS611_BARRIER_LOAD; - - fe_local[LFDS611_FREELIST_POINTER] = fe; - fe_local[LFDS611_FREELIST_COUNTER] = (struct lfds611_freelist_element *) lfds611_abstraction_increment( (lfds611_atom_t *) &fs->aba_counter ); - - original_fe_next[LFDS611_FREELIST_POINTER] = fs->top[LFDS611_FREELIST_POINTER]; - original_fe_next[LFDS611_FREELIST_COUNTER] = fs->top[LFDS611_FREELIST_COUNTER]; - - /* TRD : note that lfds611_abstraction_dcas loads the original value of the destination (fs->top) into the compare (original_fe_next) - (this happens of course after the CAS itself has occurred inside lfds611_abstraction_dcas) - this then causes us in our loop, should we repeat it, to update fe_local->next to a more - up-to-date version of the head of the lfds611_freelist - */ - - do { - fe_local[LFDS611_FREELIST_POINTER]->next[LFDS611_FREELIST_POINTER] = original_fe_next[LFDS611_FREELIST_POINTER]; - fe_local[LFDS611_FREELIST_POINTER]->next[LFDS611_FREELIST_COUNTER] = original_fe_next[LFDS611_FREELIST_COUNTER]; - } while( 0 == lfds611_abstraction_dcas((volatile lfds611_atom_t *) fs->top, (lfds611_atom_t *) fe_local, (lfds611_atom_t *) original_fe_next) ); - - return; -} - diff --git a/openair2/UTIL/LFDS/liblfds6.1.1/liblfds611/src/lfds611_freelist/lfds611_freelist_query.c b/openair2/UTIL/LFDS/liblfds6.1.1/liblfds611/src/lfds611_freelist/lfds611_freelist_query.c deleted file mode 100644 index 9e42ee0361..0000000000 --- a/openair2/UTIL/LFDS/liblfds6.1.1/liblfds611/src/lfds611_freelist/lfds611_freelist_query.c +++ /dev/null @@ -1,110 +0,0 @@ -#include "lfds611_freelist_internal.h" - - - - - -/****************************************************************************/ -void lfds611_freelist_query( struct lfds611_freelist_state *fs, enum lfds611_freelist_query_type query_type, void *query_input, void *query_output ) -{ - assert( fs != NULL ); - // TRD : query type can be any value in its range - // TRD : query_input can be NULL in some cases - assert( query_output != NULL ); - - LFDS611_BARRIER_LOAD; - - switch( query_type ) { - case LFDS611_FREELIST_QUERY_ELEMENT_COUNT: - assert( query_input == NULL ); - - *(lfds611_atom_t *) query_output = fs->element_count; - break; - - case LFDS611_FREELIST_QUERY_VALIDATE: - // TRD : query_input can be NULL - - lfds611_freelist_internal_validate( fs, (struct lfds611_validation_info *) query_input, (enum lfds611_data_structure_validity *) query_output ); - break; - } - - return; -} - - - - - -/****************************************************************************/ -void lfds611_freelist_internal_validate( struct lfds611_freelist_state *fs, struct lfds611_validation_info *vi, enum lfds611_data_structure_validity *lfds611_freelist_validity ) -{ - struct lfds611_freelist_element - *fe, - *fe_slow, - *fe_fast; - - lfds611_atom_t - element_count = 0; - - assert( fs != NULL ); - // TRD : vi can be NULL - assert( lfds611_freelist_validity != NULL ); - - *lfds611_freelist_validity = LFDS611_VALIDITY_VALID; - - fe_slow = fe_fast = (struct lfds611_freelist_element *) fs->top[LFDS611_FREELIST_POINTER]; - - /* TRD : first, check for a loop - we have two pointers - both of which start at the top of the lfds611_freelist - we enter a loop - and on each iteration - we advance one pointer by one element - and the other by two - - we exit the loop when both pointers are NULL - (have reached the end of the lfds611_freelist) - - or - - if we fast pointer 'sees' the slow pointer - which means we have a loop - */ - - if( fe_slow != NULL ) - do { - fe_slow = fe_slow->next[LFDS611_FREELIST_POINTER]; - - if( fe_fast != NULL ) - fe_fast = fe_fast->next[LFDS611_FREELIST_POINTER]; - - if( fe_fast != NULL ) - fe_fast = fe_fast->next[LFDS611_FREELIST_POINTER]; - } while( fe_slow != NULL and fe_fast != fe_slow ); - - if( fe_fast != NULL and fe_slow != NULL and fe_fast == fe_slow ) - *lfds611_freelist_validity = LFDS611_VALIDITY_INVALID_LOOP; - - /* TRD : now check for expected number of elements - vi can be NULL, in which case we do not check - we know we don't have a loop from our earlier check - */ - - if( *lfds611_freelist_validity == LFDS611_VALIDITY_VALID and vi != NULL ) { - fe = (struct lfds611_freelist_element *) fs->top[LFDS611_FREELIST_POINTER]; - - while( fe != NULL ) { - element_count++; - fe = (struct lfds611_freelist_element *) fe->next[LFDS611_FREELIST_POINTER]; - } - - if( element_count < vi->min_elements ) - *lfds611_freelist_validity = LFDS611_VALIDITY_INVALID_MISSING_ELEMENTS; - - if( element_count > vi->max_elements ) - *lfds611_freelist_validity = LFDS611_VALIDITY_INVALID_ADDITIONAL_ELEMENTS; - } - - return; -} - diff --git a/openair2/UTIL/LFDS/liblfds6.1.1/liblfds611/src/lfds611_liblfds/lfds611_liblfds_abstraction_test_helpers.c b/openair2/UTIL/LFDS/liblfds6.1.1/liblfds611/src/lfds611_liblfds/lfds611_liblfds_abstraction_test_helpers.c deleted file mode 100644 index a015159b7f..0000000000 --- a/openair2/UTIL/LFDS/liblfds6.1.1/liblfds611/src/lfds611_liblfds/lfds611_liblfds_abstraction_test_helpers.c +++ /dev/null @@ -1,106 +0,0 @@ -#include "lfds611_liblfds_internal.h" - - - - - -/****************************************************************************/ -void lfds611_liblfds_abstraction_test_helper_increment_non_atomic( lfds611_atom_t *shared_counter ) -{ - /* TRD : lfds611_atom_t must be volatile or the compiler - optimizes it away into a single store - */ - - volatile lfds611_atom_t - count = 0; - - assert( shared_counter != NULL ); - - while( count++ < 10000000 ) - (*(lfds611_atom_t *) shared_counter)++; - - return; -} - - - - - -/****************************************************************************/ -void lfds611_liblfds_abstraction_test_helper_increment_atomic( volatile lfds611_atom_t *shared_counter ) -{ - lfds611_atom_t - count = 0; - - assert( shared_counter != NULL ); - - while( count++ < 10000000 ) - lfds611_abstraction_increment( shared_counter ); - - return; -} - - - - - -/****************************************************************************/ -void lfds611_liblfds_abstraction_test_helper_cas( volatile lfds611_atom_t *shared_counter, lfds611_atom_t *local_counter ) -{ - lfds611_atom_t - loop = 0, - original_destination; - - LFDS611_ALIGN(LFDS611_ALIGN_SINGLE_POINTER) lfds611_atom_t - exchange, - compare; - - assert( shared_counter != NULL ); - assert( local_counter != NULL ); - - while( loop++ < 1000000 ) { - do { - compare = *shared_counter; - exchange = compare + 1; - - original_destination = lfds611_abstraction_cas( shared_counter, exchange, compare ); - } while( original_destination != compare ); - - (*local_counter)++; - } - - return; -} - - - - - -/****************************************************************************/ -void lfds611_liblfds_abstraction_test_helper_dcas( volatile lfds611_atom_t *shared_counter, lfds611_atom_t *local_counter ) -{ - lfds611_atom_t - loop = 0; - - LFDS611_ALIGN(LFDS611_ALIGN_DOUBLE_POINTER) lfds611_atom_t - exchange[2], - compare[2]; - - assert( shared_counter != NULL ); - assert( local_counter != NULL ); - - while( loop++ < 1000000 ) { - compare[0] = *shared_counter; - compare[1] = *(shared_counter+1); - - do { - exchange[0] = compare[0] + 1; - exchange[1] = compare[1]; - } while( 0 == lfds611_abstraction_dcas(shared_counter, exchange, compare) ); - - (*local_counter)++; - } - - return; -} - diff --git a/openair2/UTIL/LFDS/liblfds6.1.1/liblfds611/src/lfds611_liblfds/lfds611_liblfds_aligned_free.c b/openair2/UTIL/LFDS/liblfds6.1.1/liblfds611/src/lfds611_liblfds/lfds611_liblfds_aligned_free.c deleted file mode 100644 index 0449f8b244..0000000000 --- a/openair2/UTIL/LFDS/liblfds6.1.1/liblfds611/src/lfds611_liblfds/lfds611_liblfds_aligned_free.c +++ /dev/null @@ -1,17 +0,0 @@ -#include "lfds611_liblfds_internal.h" - - - - - -/****************************************************************************/ -void lfds611_liblfds_aligned_free( void *memory ) -{ - assert( memory != NULL ); - - // TRD : the "void *" stored above memory points to the root of the allocation - lfds611_abstraction_free( *( (void **) memory - 1 ) ); - - return; -} - diff --git a/openair2/UTIL/LFDS/liblfds6.1.1/liblfds611/src/lfds611_liblfds/lfds611_liblfds_aligned_malloc.c b/openair2/UTIL/LFDS/liblfds6.1.1/liblfds611/src/lfds611_liblfds/lfds611_liblfds_aligned_malloc.c deleted file mode 100644 index ef6ee57426..0000000000 --- a/openair2/UTIL/LFDS/liblfds6.1.1/liblfds611/src/lfds611_liblfds/lfds611_liblfds_aligned_malloc.c +++ /dev/null @@ -1,31 +0,0 @@ -#include "lfds611_liblfds_internal.h" - - - - - -/****************************************************************************/ -void *lfds611_liblfds_aligned_malloc( size_t size, size_t align_in_bytes ) -{ - void - *original_memory, - *memory; - - size_t - offset; - - // TRD : size can be any value in its range - // TRD : align_in_bytes can be any value in its range - - original_memory = memory = lfds611_abstraction_malloc( size + sizeof(void *) + align_in_bytes ); - - if( memory != NULL ) { - memory = (void **) memory + 1; - offset = align_in_bytes - (size_t) memory % align_in_bytes; - memory = (unsigned char *) memory + offset; - *( (void **) memory - 1 ) = original_memory; - } - - return( memory ); -} - diff --git a/openair2/UTIL/LFDS/liblfds6.1.1/liblfds611/src/lfds611_liblfds/lfds611_liblfds_internal.h b/openair2/UTIL/LFDS/liblfds6.1.1/liblfds611/src/lfds611_liblfds/lfds611_liblfds_internal.h deleted file mode 100644 index d6fa122759..0000000000 --- a/openair2/UTIL/LFDS/liblfds6.1.1/liblfds611/src/lfds611_liblfds/lfds611_liblfds_internal.h +++ /dev/null @@ -1,4 +0,0 @@ -/***** the library wide include file *****/ -#include "liblfds611_internal.h" - - diff --git a/openair2/UTIL/LFDS/liblfds6.1.1/liblfds611/src/lfds611_liblfds/lfds611_liblfds_readme.txt b/openair2/UTIL/LFDS/liblfds6.1.1/liblfds611/src/lfds611_liblfds/lfds611_liblfds_readme.txt deleted file mode 100644 index aa3327028c..0000000000 --- a/openair2/UTIL/LFDS/liblfds6.1.1/liblfds611/src/lfds611_liblfds/lfds611_liblfds_readme.txt +++ /dev/null @@ -1,2 +0,0 @@ -This is not a data structure but rather functions internal to the library. - diff --git a/openair2/UTIL/LFDS/liblfds6.1.1/liblfds611/src/lfds611_queue/lfds611_queue_delete.c b/openair2/UTIL/LFDS/liblfds6.1.1/liblfds611/src/lfds611_queue/lfds611_queue_delete.c deleted file mode 100644 index a11b501e56..0000000000 --- a/openair2/UTIL/LFDS/liblfds6.1.1/liblfds611/src/lfds611_queue/lfds611_queue_delete.c +++ /dev/null @@ -1,57 +0,0 @@ -#include "lfds611_queue_internal.h" - - - - - -/****************************************************************************/ -void lfds611_queue_delete( struct lfds611_queue_state *qs, void (*user_data_delete_function)(void *user_data, void *user_state), void *user_state ) -{ - void - *user_data; - - assert( qs != NULL ); - // TRD : user_data_delete_function can be NULL - // TRD : user_state can be NULL - - // TRD : leading load barrier not required as it will be performed by the dequeue - - while( lfds611_queue_dequeue(qs, &user_data) ) - if( user_data_delete_function != NULL ) - user_data_delete_function( user_data, user_state ); - - /* TRD : fully dequeuing will leave us - with a single dummy element - which both qs->enqueue and qs->dequeue point at - we push this back onto the lfds611_freelist - before we delete the lfds611_freelist - */ - - lfds611_freelist_push( qs->fs, qs->enqueue[LFDS611_QUEUE_POINTER]->fe ); - - lfds611_freelist_delete( qs->fs, lfds611_queue_internal_freelist_delete_function, NULL ); - - lfds611_liblfds_aligned_free( qs ); - - return; -} - - - - - -/****************************************************************************/ -//#pragma warning( disable : 4100 ) - -void lfds611_queue_internal_freelist_delete_function( void *user_data, void *user_state ) -{ - assert( user_data != NULL ); - assert( user_state == NULL ); - - lfds611_liblfds_aligned_free( user_data ); - - return; -} - -//#pragma warning( default : 4100 ) - diff --git a/openair2/UTIL/LFDS/liblfds6.1.1/liblfds611/src/lfds611_queue/lfds611_queue_internal.h b/openair2/UTIL/LFDS/liblfds6.1.1/liblfds611/src/lfds611_queue/lfds611_queue_internal.h deleted file mode 100644 index e84e35035a..0000000000 --- a/openair2/UTIL/LFDS/liblfds6.1.1/liblfds611/src/lfds611_queue/lfds611_queue_internal.h +++ /dev/null @@ -1,59 +0,0 @@ -/***** the library wide include file *****/ -#include "liblfds611_internal.h" - -/***** pragmas *****/ - -/***** defines *****/ -#define LFDS611_QUEUE_STATE_UNKNOWN -1 -#define LFDS611_QUEUE_STATE_EMPTY 0 -#define LFDS611_QUEUE_STATE_ENQUEUE_OUT_OF_PLACE 1 -#define LFDS611_QUEUE_STATE_ATTEMPT_DELFDS611_QUEUE 2 - -#define LFDS611_QUEUE_POINTER 0 -#define LFDS611_QUEUE_COUNTER 1 -#define LFDS611_QUEUE_PAC_SIZE 2 - -/***** structures *****/ -#pragma pack( push, LFDS611_ALIGN_DOUBLE_POINTER ) - -struct lfds611_queue_state { - struct lfds611_queue_element - *volatile enqueue[LFDS611_QUEUE_PAC_SIZE], - *volatile dequeue[LFDS611_QUEUE_PAC_SIZE]; - - lfds611_atom_t - aba_counter; - - struct lfds611_freelist_state - *fs; -}; - -struct lfds611_queue_element { - // TRD : next in a lfds611_queue requires volatile as it is target of CAS - struct lfds611_queue_element - *volatile next[LFDS611_QUEUE_PAC_SIZE]; - - struct lfds611_freelist_element - *fe; - - void - *user_data; -}; - -#pragma pack( pop ) - -/***** externs *****/ - -/***** private prototypes *****/ -int lfds611_queue_internal_freelist_init_function( void **user_data, void *user_state ); -void lfds611_queue_internal_freelist_delete_function( void *user_data, void *user_state ); - -void lfds611_queue_internal_new_element_from_freelist( struct lfds611_queue_state *qs, struct lfds611_queue_element *qe[LFDS611_QUEUE_PAC_SIZE], void *user_data ); -void lfds611_queue_internal_guaranteed_new_element_from_freelist( struct lfds611_queue_state *qs, struct lfds611_queue_element * qe[LFDS611_QUEUE_PAC_SIZE], void *user_data ); -void lfds611_queue_internal_init_element( struct lfds611_queue_state *qs, struct lfds611_queue_element *qe[LFDS611_QUEUE_PAC_SIZE], struct lfds611_freelist_element *fe, void *user_data ); - -void lfds611_queue_internal_queue( struct lfds611_queue_state *qs, struct lfds611_queue_element *qe[LFDS611_QUEUE_PAC_SIZE] ); - -void lfds611_queue_internal_validate( struct lfds611_queue_state *qs, struct lfds611_validation_info *vi, enum lfds611_data_structure_validity *lfds611_queue_validity, - enum lfds611_data_structure_validity *lfds611_freelist_validity ); - diff --git a/openair2/UTIL/LFDS/liblfds6.1.1/liblfds611/src/lfds611_queue/lfds611_queue_new.c b/openair2/UTIL/LFDS/liblfds6.1.1/liblfds611/src/lfds611_queue/lfds611_queue_new.c deleted file mode 100644 index 7fec0a2e90..0000000000 --- a/openair2/UTIL/LFDS/liblfds6.1.1/liblfds611/src/lfds611_queue/lfds611_queue_new.c +++ /dev/null @@ -1,158 +0,0 @@ -#include "lfds611_queue_internal.h" - - - - - -/****************************************************************************/ -int lfds611_queue_new( struct lfds611_queue_state **qs, lfds611_atom_t number_elements ) -{ - int - rv = 0; - - struct lfds611_queue_element - *qe[LFDS611_QUEUE_PAC_SIZE]; - - assert( qs != NULL ); - // TRD : number_elements can be any value in its range - - *qs = (struct lfds611_queue_state *) lfds611_liblfds_aligned_malloc( sizeof(struct lfds611_queue_state), LFDS611_ALIGN_DOUBLE_POINTER ); - - if( *qs != NULL ) { - // TRD : the size of the lfds611_freelist is the size of the lfds611_queue (+1 for the leading dummy element, which is hidden from the caller) - lfds611_freelist_new( &(*qs)->fs, number_elements+1, lfds611_queue_internal_freelist_init_function, NULL ); - - if( (*qs)->fs != NULL ) { - lfds611_queue_internal_new_element_from_freelist( *qs, qe, NULL ); - (*qs)->enqueue[LFDS611_QUEUE_POINTER] = (*qs)->dequeue[LFDS611_QUEUE_POINTER] = qe[LFDS611_QUEUE_POINTER]; - (*qs)->enqueue[LFDS611_QUEUE_COUNTER] = (*qs)->dequeue[LFDS611_QUEUE_COUNTER] = 0; - (*qs)->aba_counter = 0; - rv = 1; - } - - if( (*qs)->fs == NULL ) { - lfds611_liblfds_aligned_free( *qs ); - *qs = NULL; - } - } - - LFDS611_BARRIER_STORE; - - return( rv ); -} - - - - - -/****************************************************************************/ -//#pragma warning( disable : 4100 ) - -void lfds611_queue_use( struct lfds611_queue_state *qs ) -{ - assert( qs != NULL ); - - LFDS611_BARRIER_LOAD; - - return; -} - -//#pragma warning( default : 4100 ) - - - - - -/****************************************************************************/ -//#pragma warning( disable : 4100 ) - -int lfds611_queue_internal_freelist_init_function( void **user_data, void *user_state ) -{ - int - rv = 0; - - assert( user_data != NULL ); - assert( user_state == NULL ); - - *user_data = lfds611_liblfds_aligned_malloc( sizeof(struct lfds611_queue_element), LFDS611_ALIGN_DOUBLE_POINTER ); - - if( *user_data != NULL ) - rv = 1; - - return( rv ); -} - -//#pragma warning( default : 4100 ) - - - - - -/****************************************************************************/ -void lfds611_queue_internal_new_element_from_freelist( struct lfds611_queue_state *qs, struct lfds611_queue_element *qe[LFDS611_QUEUE_PAC_SIZE], void *user_data ) -{ - struct lfds611_freelist_element - *fe; - - assert( qs != NULL ); - assert( qe != NULL ); - // TRD : user_data can be any value in its range - - qe[LFDS611_QUEUE_POINTER] = NULL; - - lfds611_freelist_pop( qs->fs, &fe ); - - if( fe != NULL ) - lfds611_queue_internal_init_element( qs, qe, fe, user_data ); - - return; -} - - - - - -/****************************************************************************/ -void lfds611_queue_internal_guaranteed_new_element_from_freelist( struct lfds611_queue_state *qs, struct lfds611_queue_element *qe[LFDS611_QUEUE_PAC_SIZE], void *user_data ) -{ - struct lfds611_freelist_element - *fe; - - assert( qs != NULL ); - assert( qe != NULL ); - // TRD : user_data can be any value in its range - - qe[LFDS611_QUEUE_POINTER] = NULL; - - lfds611_freelist_guaranteed_pop( qs->fs, &fe ); - - if( fe != NULL ) - lfds611_queue_internal_init_element( qs, qe, fe, user_data ); - - return; -} - - - - - -/****************************************************************************/ -void lfds611_queue_internal_init_element( struct lfds611_queue_state *qs, struct lfds611_queue_element *qe[LFDS611_QUEUE_PAC_SIZE], struct lfds611_freelist_element *fe, void *user_data ) -{ - assert( qs != NULL ); - assert( qe != NULL ); - assert( fe != NULL ); - // TRD : user_data can be any value in its range - - lfds611_freelist_get_user_data_from_element( fe, (void **) &qe[LFDS611_QUEUE_POINTER] ); - qe[LFDS611_QUEUE_COUNTER] = (struct lfds611_queue_element *) lfds611_abstraction_increment( (lfds611_atom_t *) &qs->aba_counter ); - - qe[LFDS611_QUEUE_POINTER]->next[LFDS611_QUEUE_POINTER] = NULL; - qe[LFDS611_QUEUE_POINTER]->next[LFDS611_QUEUE_COUNTER] = (struct lfds611_queue_element *) lfds611_abstraction_increment( (lfds611_atom_t *) &qs->aba_counter ); - - qe[LFDS611_QUEUE_POINTER]->fe = fe; - qe[LFDS611_QUEUE_POINTER]->user_data = user_data; - - return; -} - diff --git a/openair2/UTIL/LFDS/liblfds6.1.1/liblfds611/src/lfds611_queue/lfds611_queue_query.c b/openair2/UTIL/LFDS/liblfds6.1.1/liblfds611/src/lfds611_queue/lfds611_queue_query.c deleted file mode 100644 index 504485d7b5..0000000000 --- a/openair2/UTIL/LFDS/liblfds6.1.1/liblfds611/src/lfds611_queue/lfds611_queue_query.c +++ /dev/null @@ -1,150 +0,0 @@ -#include "lfds611_queue_internal.h" - - - - - -/****************************************************************************/ -//#pragma warning( disable : 4100 ) - -void lfds611_queue_query( struct lfds611_queue_state *qs, enum lfds611_queue_query_type query_type, void *query_input, void *query_output ) -{ - assert( qs != NULL ); - // TRD : query_type can be any value in its range - // TRD : query_input can be NULL - assert( query_output != NULL ); - - switch( query_type ) { - case LFDS611_QUEUE_QUERY_ELEMENT_COUNT: - assert( query_input == NULL ); - - lfds611_freelist_query( qs->fs, LFDS611_FREELIST_QUERY_ELEMENT_COUNT, NULL, query_output ); - break; - - case LFDS611_QUEUE_QUERY_VALIDATE: - // TRD : query_input can be NULL - - lfds611_queue_internal_validate( qs, (struct lfds611_validation_info *) query_input, (enum lfds611_data_structure_validity *) query_output, ((enum lfds611_data_structure_validity *) query_output)+1 ); - break; - } - - return; -} - -//#pragma warning( default : 4100 ) - - - - - -/****************************************************************************/ -void lfds611_queue_internal_validate( struct lfds611_queue_state *qs, struct lfds611_validation_info *vi, enum lfds611_data_structure_validity *lfds611_queue_validity, - enum lfds611_data_structure_validity *lfds611_freelist_validity ) -{ - struct lfds611_queue_element - *qe, - *qe_slow, - *qe_fast; - - lfds611_atom_t - element_count = 0, - total_elements; - - struct lfds611_validation_info - lfds611_freelist_vi; - - assert( qs != NULL ); - // TRD : vi can be NULL - assert( lfds611_queue_validity != NULL ); - assert( lfds611_freelist_validity != NULL ); - - *lfds611_queue_validity = LFDS611_VALIDITY_VALID; - - LFDS611_BARRIER_LOAD; - - qe_slow = qe_fast = (struct lfds611_queue_element *) qs->dequeue[LFDS611_QUEUE_POINTER]; - - /* TRD : first, check for a loop - we have two pointers - both of which start at the dequeue end of the lfds611_queue - we enter a loop - and on each iteration - we advance one pointer by one element - and the other by two - - we exit the loop when both pointers are NULL - (have reached the end of the lfds611_queue) - - or - - if we fast pointer 'sees' the slow pointer - which means we have a loop - */ - - if( qe_slow != NULL ) - do { - qe_slow = qe_slow->next[LFDS611_QUEUE_POINTER]; - - if( qe_fast != NULL ) - qe_fast = qe_fast->next[LFDS611_QUEUE_POINTER]; - - if( qe_fast != NULL ) - qe_fast = qe_fast->next[LFDS611_QUEUE_POINTER]; - } while( qe_slow != NULL and qe_fast != qe_slow ); - - if( qe_fast != NULL and qe_slow != NULL and qe_fast == qe_slow ) - *lfds611_queue_validity = LFDS611_VALIDITY_INVALID_LOOP; - - /* TRD : now check for expected number of elements - vi can be NULL, in which case we do not check - we know we don't have a loop from our earlier check - */ - - if( *lfds611_queue_validity == LFDS611_VALIDITY_VALID and vi != NULL ) { - qe = (struct lfds611_queue_element *) qs->dequeue[LFDS611_QUEUE_POINTER]; - - while( qe != NULL ) { - element_count++; - qe = (struct lfds611_queue_element *) qe->next[LFDS611_QUEUE_POINTER]; - } - - /* TRD : remember there is a dummy element in the lfds611_queue */ - element_count--; - - if( element_count < vi->min_elements ) - *lfds611_queue_validity = LFDS611_VALIDITY_INVALID_MISSING_ELEMENTS; - - if( element_count > vi->max_elements ) - *lfds611_queue_validity = LFDS611_VALIDITY_INVALID_ADDITIONAL_ELEMENTS; - } - - /* TRD : now we validate the lfds611_freelist - - we may be able to check for the expected number of - elements in the lfds611_freelist - - if the caller has given us an expected min and max - number of elements in the lfds611_queue, then the total number - of elements in the lfds611_freelist, minus that min and max, - gives us the expected number of elements in the - lfds611_freelist - */ - - if( vi != NULL ) { - lfds611_freelist_query( qs->fs, LFDS611_FREELIST_QUERY_ELEMENT_COUNT, NULL, (void *) &total_elements ); - - /* TRD : remember there is a dummy element in the lfds611_queue */ - total_elements--; - - lfds611_freelist_vi.min_elements = total_elements - vi->max_elements; - lfds611_freelist_vi.max_elements = total_elements - vi->min_elements; - - lfds611_freelist_query( qs->fs, LFDS611_FREELIST_QUERY_VALIDATE, (void *) &lfds611_freelist_vi, (void *) lfds611_freelist_validity ); - } - - if( vi == NULL ) - lfds611_freelist_query( qs->fs, LFDS611_FREELIST_QUERY_VALIDATE, NULL, (void *) lfds611_freelist_validity ); - - return; -} - diff --git a/openair2/UTIL/LFDS/liblfds6.1.1/liblfds611/src/lfds611_queue/lfds611_queue_queue.c b/openair2/UTIL/LFDS/liblfds6.1.1/liblfds611/src/lfds611_queue/lfds611_queue_queue.c deleted file mode 100644 index c3abe45043..0000000000 --- a/openair2/UTIL/LFDS/liblfds6.1.1/liblfds611/src/lfds611_queue/lfds611_queue_queue.c +++ /dev/null @@ -1,184 +0,0 @@ -#include "lfds611_queue_internal.h" - - - - - -/****************************************************************************/ -int lfds611_queue_enqueue( struct lfds611_queue_state *qs, void *user_data ) -{ - LFDS611_ALIGN(LFDS611_ALIGN_DOUBLE_POINTER) struct lfds611_queue_element - *qe[LFDS611_QUEUE_PAC_SIZE]; - - assert( qs != NULL ); - // TRD : user_data can be NULL - - lfds611_queue_internal_new_element_from_freelist( qs, qe, user_data ); - - if( qe[LFDS611_QUEUE_POINTER] == NULL ) - return( 0 ); - - lfds611_queue_internal_queue( qs, qe ); - - return( 1 ); -} - - - - - -/****************************************************************************/ -int lfds611_queue_guaranteed_enqueue( struct lfds611_queue_state *qs, void *user_data ) -{ - LFDS611_ALIGN(LFDS611_ALIGN_DOUBLE_POINTER) struct lfds611_queue_element - *qe[LFDS611_QUEUE_PAC_SIZE]; - - assert( qs != NULL ); - // TRD : user_data can be NULL - - lfds611_queue_internal_guaranteed_new_element_from_freelist( qs, qe, user_data ); - - if( qe[LFDS611_QUEUE_POINTER] == NULL ) - return( 0 ); - - lfds611_queue_internal_queue( qs, qe ); - - return( 1 ); -} - - - - - -/****************************************************************************/ -void lfds611_queue_internal_queue( struct lfds611_queue_state *qs, struct lfds611_queue_element *qe[LFDS611_QUEUE_PAC_SIZE] ) -{ - LFDS611_ALIGN(LFDS611_ALIGN_DOUBLE_POINTER) struct lfds611_queue_element - *enqueue[LFDS611_QUEUE_PAC_SIZE], - *next[LFDS611_QUEUE_PAC_SIZE]; - - unsigned char - cas_result = 0; - - assert( qs != NULL ); - assert( qe != NULL ); - - // TRD : the DCAS operation issues a read and write barrier, so we don't need a read barrier in the do() loop - - LFDS611_BARRIER_LOAD; - - do { - enqueue[LFDS611_QUEUE_POINTER] = qs->enqueue[LFDS611_QUEUE_POINTER]; - enqueue[LFDS611_QUEUE_COUNTER] = qs->enqueue[LFDS611_QUEUE_COUNTER]; - - next[LFDS611_QUEUE_POINTER] = enqueue[LFDS611_QUEUE_POINTER]->next[LFDS611_QUEUE_POINTER]; - next[LFDS611_QUEUE_COUNTER] = enqueue[LFDS611_QUEUE_POINTER]->next[LFDS611_QUEUE_COUNTER]; - - /* TRD : this if() ensures that the next we read, just above, - really is from qs->enqueue (which we copied into enqueue) - */ - - LFDS611_BARRIER_LOAD; - - if( qs->enqueue[LFDS611_QUEUE_POINTER] == enqueue[LFDS611_QUEUE_POINTER] and qs->enqueue[LFDS611_QUEUE_COUNTER] == enqueue[LFDS611_QUEUE_COUNTER] ) { - if( next[LFDS611_QUEUE_POINTER] == NULL ) { - qe[LFDS611_QUEUE_COUNTER] = next[LFDS611_QUEUE_COUNTER] + 1; - cas_result = lfds611_abstraction_dcas( (volatile lfds611_atom_t *) enqueue[LFDS611_QUEUE_POINTER]->next, (lfds611_atom_t *) qe, (lfds611_atom_t *) next ); - } else { - next[LFDS611_QUEUE_COUNTER] = enqueue[LFDS611_QUEUE_COUNTER] + 1; - lfds611_abstraction_dcas( (volatile lfds611_atom_t *) qs->enqueue, (lfds611_atom_t *) next, (lfds611_atom_t *) enqueue ); - } - } - } while( cas_result == 0 ); - - qe[LFDS611_QUEUE_COUNTER] = enqueue[LFDS611_QUEUE_COUNTER] + 1; - lfds611_abstraction_dcas( (volatile lfds611_atom_t *) qs->enqueue, (lfds611_atom_t *) qe, (lfds611_atom_t *) enqueue ); - - return; -} - - - - - -/****************************************************************************/ -int lfds611_queue_dequeue( struct lfds611_queue_state *qs, void **user_data ) -{ - LFDS611_ALIGN(LFDS611_ALIGN_DOUBLE_POINTER) struct lfds611_queue_element - *enqueue[LFDS611_QUEUE_PAC_SIZE], - *dequeue[LFDS611_QUEUE_PAC_SIZE], - *next[LFDS611_QUEUE_PAC_SIZE]; - - unsigned char - cas_result = 0; - - int - rv = 1, - state = LFDS611_QUEUE_STATE_UNKNOWN, - finished_flag = LOWERED; - - assert( qs != NULL ); - assert( user_data != NULL ); - - // TRD : the DCAS operation issues a read and write barrier, so we don't need a read barrier in the do() loop - - LFDS611_BARRIER_LOAD; - - do { - dequeue[LFDS611_QUEUE_POINTER] = qs->dequeue[LFDS611_QUEUE_POINTER]; - dequeue[LFDS611_QUEUE_COUNTER] = qs->dequeue[LFDS611_QUEUE_COUNTER]; - - enqueue[LFDS611_QUEUE_POINTER] = qs->enqueue[LFDS611_QUEUE_POINTER]; - enqueue[LFDS611_QUEUE_COUNTER] = qs->enqueue[LFDS611_QUEUE_COUNTER]; - - next[LFDS611_QUEUE_POINTER] = dequeue[LFDS611_QUEUE_POINTER]->next[LFDS611_QUEUE_POINTER]; - next[LFDS611_QUEUE_COUNTER] = dequeue[LFDS611_QUEUE_POINTER]->next[LFDS611_QUEUE_COUNTER]; - - /* TRD : confirm that dequeue didn't move between reading it - and reading its next pointer - */ - - LFDS611_BARRIER_LOAD; - - if( dequeue[LFDS611_QUEUE_POINTER] == qs->dequeue[LFDS611_QUEUE_POINTER] and dequeue[LFDS611_QUEUE_COUNTER] == qs->dequeue[LFDS611_QUEUE_COUNTER] ) { - if( enqueue[LFDS611_QUEUE_POINTER] == dequeue[LFDS611_QUEUE_POINTER] and next[LFDS611_QUEUE_POINTER] == NULL ) - state = LFDS611_QUEUE_STATE_EMPTY; - - if( enqueue[LFDS611_QUEUE_POINTER] == dequeue[LFDS611_QUEUE_POINTER] and next[LFDS611_QUEUE_POINTER] != NULL ) - state = LFDS611_QUEUE_STATE_ENQUEUE_OUT_OF_PLACE; - - if( enqueue[LFDS611_QUEUE_POINTER] != dequeue[LFDS611_QUEUE_POINTER] ) - state = LFDS611_QUEUE_STATE_ATTEMPT_DELFDS611_QUEUE; - - switch( state ) { - case LFDS611_QUEUE_STATE_EMPTY: - *user_data = NULL; - rv = 0; - finished_flag = RAISED; - break; - - case LFDS611_QUEUE_STATE_ENQUEUE_OUT_OF_PLACE: - next[LFDS611_QUEUE_COUNTER] = enqueue[LFDS611_QUEUE_COUNTER] + 1; - lfds611_abstraction_dcas( (volatile lfds611_atom_t *) qs->enqueue, (lfds611_atom_t *) next, (lfds611_atom_t *) enqueue ); - break; - - case LFDS611_QUEUE_STATE_ATTEMPT_DELFDS611_QUEUE: - *user_data = next[LFDS611_QUEUE_POINTER]->user_data; - - next[LFDS611_QUEUE_COUNTER] = dequeue[LFDS611_QUEUE_COUNTER] + 1; - cas_result = lfds611_abstraction_dcas( (volatile lfds611_atom_t *) qs->dequeue, (lfds611_atom_t *) next, (lfds611_atom_t *) dequeue ); - - if( cas_result == 1 ) - finished_flag = RAISED; - - break; - } - } - } while( finished_flag == LOWERED ); - - if( cas_result == 1 ) - lfds611_freelist_push( qs->fs, dequeue[LFDS611_QUEUE_POINTER]->fe ); - - return( rv ); -} - diff --git a/openair2/UTIL/LFDS/liblfds6.1.1/liblfds611/src/lfds611_ringbuffer/lfds611_ringbuffer_delete.c b/openair2/UTIL/LFDS/liblfds6.1.1/liblfds611/src/lfds611_ringbuffer/lfds611_ringbuffer_delete.c deleted file mode 100644 index 847d442d28..0000000000 --- a/openair2/UTIL/LFDS/liblfds6.1.1/liblfds611/src/lfds611_ringbuffer/lfds611_ringbuffer_delete.c +++ /dev/null @@ -1,22 +0,0 @@ -#include "lfds611_ringbuffer_internal.h" - - - - - -/****************************************************************************/ -void lfds611_ringbuffer_delete( struct lfds611_ringbuffer_state *rs, void (*user_data_delete_function)(void *user_data, void *user_state), void *user_state ) -{ - assert( rs != NULL ); - // TRD : user_data_delete_function can be NULL - // TRD : user_state can be NULL - - lfds611_queue_delete( rs->qs, NULL, NULL ); - - lfds611_freelist_delete( rs->fs, user_data_delete_function, user_state ); - - lfds611_liblfds_aligned_free( rs ); - - return; -} - diff --git a/openair2/UTIL/LFDS/liblfds6.1.1/liblfds611/src/lfds611_ringbuffer/lfds611_ringbuffer_get_and_put.c b/openair2/UTIL/LFDS/liblfds6.1.1/liblfds611/src/lfds611_ringbuffer/lfds611_ringbuffer_get_and_put.c deleted file mode 100644 index 9b0ea2a667..0000000000 --- a/openair2/UTIL/LFDS/liblfds6.1.1/liblfds611/src/lfds611_ringbuffer/lfds611_ringbuffer_get_and_put.c +++ /dev/null @@ -1,105 +0,0 @@ -#include "lfds611_ringbuffer_internal.h" - - - - - -/****************************************************************************/ -struct lfds611_freelist_element *lfds611_ringbuffer_get_read_element( struct lfds611_ringbuffer_state *rs, struct lfds611_freelist_element **fe ) -{ - assert( rs != NULL ); - assert( fe != NULL ); - - lfds611_queue_dequeue( rs->qs, (void **) fe ); - - return( *fe ); -} - - - - - -/****************************************************************************/ -struct lfds611_freelist_element *lfds611_ringbuffer_get_write_element( struct lfds611_ringbuffer_state *rs, struct lfds611_freelist_element **fe, int *overwrite_flag ) -{ - assert( rs != NULL ); - assert( fe != NULL ); - // TRD : overwrite_flag can be NULL - - /* TRD : we try to obtain an element from the lfds611_freelist - if we can, we populate it and add it to the lfds611_queue - - if we cannot, then the lfds611_ringbuffer is full - so instead we grab the current read element and - use that instead - - dequeue may fail since the lfds611_queue may be emptied - during our dequeue attempt - - so what we actually do here is a loop, attempting - the lfds611_freelist and if it fails then a dequeue, until - we obtain an element - - once we have an element, we lfds611_queue it - - you may be wondering why this operation is in a loop - remember - these operations are lock-free; anything - can happen in between - - so for example the pop could fail because the lfds611_freelist - is empty; but by the time we go to get an element from - the lfds611_queue, the whole lfds611_queue has been emptied back into - the lfds611_freelist! - - if overwrite_flag is provided, we set it to 0 if we - obtained a new element from the lfds611_freelist, 1 if we - stole an element from the lfds611_queue - */ - - do { - if( overwrite_flag != NULL ) - *overwrite_flag = 0; - - lfds611_freelist_pop( rs->fs, fe ); - - if( *fe == NULL ) { - lfds611_ringbuffer_get_read_element( rs, fe ); - - if( overwrite_flag != NULL and *fe != NULL ) - *overwrite_flag = 1; - } - } while( *fe == NULL ); - - return( *fe ); -} - - - - - -/****************************************************************************/ -void lfds611_ringbuffer_put_read_element( struct lfds611_ringbuffer_state *rs, struct lfds611_freelist_element *fe ) -{ - assert( rs != NULL ); - assert( fe != NULL ); - - lfds611_freelist_push( rs->fs, fe ); - - return; -} - - - - - -/****************************************************************************/ -void lfds611_ringbuffer_put_write_element( struct lfds611_ringbuffer_state *rs, struct lfds611_freelist_element *fe ) -{ - assert( rs != NULL ); - assert( fe != NULL ); - - lfds611_queue_enqueue( rs->qs, fe ); - - return; -} - diff --git a/openair2/UTIL/LFDS/liblfds6.1.1/liblfds611/src/lfds611_ringbuffer/lfds611_ringbuffer_internal.h b/openair2/UTIL/LFDS/liblfds6.1.1/liblfds611/src/lfds611_ringbuffer/lfds611_ringbuffer_internal.h deleted file mode 100644 index e32a5f2d13..0000000000 --- a/openair2/UTIL/LFDS/liblfds6.1.1/liblfds611/src/lfds611_ringbuffer/lfds611_ringbuffer_internal.h +++ /dev/null @@ -1,24 +0,0 @@ -/***** the library wide include file *****/ -#include "liblfds611_internal.h" - -/***** defines *****/ - -/***** structures *****/ -#pragma pack( push, LFDS611_ALIGN_DOUBLE_POINTER ) - -struct lfds611_ringbuffer_state { - struct lfds611_queue_state - *qs; - - struct lfds611_freelist_state - *fs; -}; - -#pragma pack( pop ) - -/***** externs *****/ - -/***** private prototypes *****/ -void lfds611_ringbuffer_internal_validate( struct lfds611_ringbuffer_state *rs, struct lfds611_validation_info *vi, enum lfds611_data_structure_validity *lfds611_queue_validity, - enum lfds611_data_structure_validity *lfds611_freelist_validity ); - diff --git a/openair2/UTIL/LFDS/liblfds6.1.1/liblfds611/src/lfds611_ringbuffer/lfds611_ringbuffer_new.c b/openair2/UTIL/LFDS/liblfds6.1.1/liblfds611/src/lfds611_ringbuffer/lfds611_ringbuffer_new.c deleted file mode 100644 index 6d8dde2a54..0000000000 --- a/openair2/UTIL/LFDS/liblfds6.1.1/liblfds611/src/lfds611_ringbuffer/lfds611_ringbuffer_new.c +++ /dev/null @@ -1,63 +0,0 @@ -#include "lfds611_ringbuffer_internal.h" - - - - - -/****************************************************************************/ -int lfds611_ringbuffer_new( struct lfds611_ringbuffer_state **rs, lfds611_atom_t number_elements, int (*user_data_init_function)(void **user_data, void *user_state), void *user_state ) -{ - int - rv = 0; - - assert( rs != NULL ); - // TRD : number_elements can be any value in its range - // TRD : user_data_init_function can be NULL - // TRD : user_state can be NULL - - *rs = (struct lfds611_ringbuffer_state *) lfds611_liblfds_aligned_malloc( sizeof(struct lfds611_ringbuffer_state), LFDS611_ALIGN_DOUBLE_POINTER ); - - if( *rs != NULL ) { - lfds611_freelist_new( &(*rs)->fs, number_elements, user_data_init_function, user_state ); - - if( (*rs)->fs != NULL ) { - lfds611_queue_new( &(*rs)->qs, number_elements ); - - if( (*rs)->qs != NULL ) - rv = 1; - - if( (*rs)->qs == NULL ) { - lfds611_liblfds_aligned_free( *rs ); - *rs = NULL; - } - } - - if( (*rs)->fs == NULL ) { - lfds611_liblfds_aligned_free( *rs ); - *rs = NULL; - } - } - - LFDS611_BARRIER_STORE; - - return( rv ); -} - - - - - -/****************************************************************************/ -//#pragma warning( disable : 4100 ) - -void lfds611_ringbuffer_use( struct lfds611_ringbuffer_state *rs ) -{ - assert( rs != NULL ); - - LFDS611_BARRIER_LOAD; - - return; -} - -//#pragma warning( default : 4100 ) - diff --git a/openair2/UTIL/LFDS/liblfds6.1.1/liblfds611/src/lfds611_ringbuffer/lfds611_ringbuffer_query.c b/openair2/UTIL/LFDS/liblfds6.1.1/liblfds611/src/lfds611_ringbuffer/lfds611_ringbuffer_query.c deleted file mode 100644 index 11bf8b0b6e..0000000000 --- a/openair2/UTIL/LFDS/liblfds6.1.1/liblfds611/src/lfds611_ringbuffer/lfds611_ringbuffer_query.c +++ /dev/null @@ -1,64 +0,0 @@ -#include "lfds611_ringbuffer_internal.h" - - - - - -/****************************************************************************/ -//#pragma warning( disable : 4100 ) - -void lfds611_ringbuffer_query( struct lfds611_ringbuffer_state *rs, enum lfds611_ringbuffer_query_type query_type, void *query_input, void *query_output ) -{ - assert( rs != NULL ); - // TRD : query_type can be any value in its range - // TRD : query_input can be NULL - assert( query_output != NULL ); - - switch( query_type ) { - case LFDS611_RINGBUFFER_QUERY_VALIDATE: - // TRD : query_input can be NULL - - lfds611_ringbuffer_internal_validate( rs, (struct lfds611_validation_info *) query_input, (enum lfds611_data_structure_validity *) query_output, - ((enum lfds611_data_structure_validity *) query_output)+2 ); - break; - } - - return; -} - -//#pragma warning( default : 4100 ) - - - - - -/****************************************************************************/ -void lfds611_ringbuffer_internal_validate( struct lfds611_ringbuffer_state *rs, struct lfds611_validation_info *vi, enum lfds611_data_structure_validity *lfds611_queue_validity, - enum lfds611_data_structure_validity *lfds611_freelist_validity ) -{ - assert( rs != NULL ); - // TRD : vi can be NULL - assert( lfds611_queue_validity != NULL ); - assert( lfds611_freelist_validity != NULL ); - - lfds611_queue_query( rs->qs, LFDS611_QUEUE_QUERY_VALIDATE, vi, lfds611_queue_validity ); - - if( vi != NULL ) { - struct lfds611_validation_info - lfds611_freelist_vi; - - lfds611_atom_t - total_elements; - - lfds611_freelist_query( rs->fs, LFDS611_FREELIST_QUERY_ELEMENT_COUNT, NULL, (void *) &total_elements ); - lfds611_freelist_vi.min_elements = total_elements - vi->max_elements; - lfds611_freelist_vi.max_elements = total_elements - vi->min_elements; - lfds611_freelist_query( rs->fs, LFDS611_FREELIST_QUERY_VALIDATE, (void *) &lfds611_freelist_vi, (void *) lfds611_freelist_validity ); - } - - if( vi == NULL ) - lfds611_freelist_query( rs->fs, LFDS611_FREELIST_QUERY_VALIDATE, NULL, (void *) lfds611_freelist_validity ); - - return; -} - diff --git a/openair2/UTIL/LFDS/liblfds6.1.1/liblfds611/src/lfds611_slist/lfds611_slist_delete.c b/openair2/UTIL/LFDS/liblfds6.1.1/liblfds611/src/lfds611_slist/lfds611_slist_delete.c deleted file mode 100644 index 18a897b593..0000000000 --- a/openair2/UTIL/LFDS/liblfds6.1.1/liblfds611/src/lfds611_slist/lfds611_slist_delete.c +++ /dev/null @@ -1,83 +0,0 @@ -#include "lfds611_slist_internal.h" - - - - - -/****************************************************************************/ -void lfds611_slist_delete( struct lfds611_slist_state *ss ) -{ - lfds611_slist_single_threaded_physically_delete_all_elements( ss ); - - lfds611_liblfds_aligned_free( ss ); - - return; -} - - - - - -/****************************************************************************/ -int lfds611_slist_logically_delete_element( struct lfds611_slist_state *ss, struct lfds611_slist_element *se ) -{ - LFDS611_ALIGN(LFDS611_ALIGN_DOUBLE_POINTER) void - *volatile user_data_and_flags[2], - *volatile new_user_data_and_flags[2]; - - unsigned char - cas_rv = 0; - - assert( ss != NULL ); - assert( se != NULL ); - - LFDS611_BARRIER_LOAD; - - user_data_and_flags[LFDS611_SLIST_USER_DATA] = se->user_data_and_flags[LFDS611_SLIST_USER_DATA]; - user_data_and_flags[LFDS611_SLIST_FLAGS] = se->user_data_and_flags[LFDS611_SLIST_FLAGS]; - - do { - new_user_data_and_flags[LFDS611_SLIST_USER_DATA] = user_data_and_flags[LFDS611_SLIST_USER_DATA]; - new_user_data_and_flags[LFDS611_SLIST_FLAGS] = (void *) ((lfds611_atom_t) user_data_and_flags[LFDS611_SLIST_FLAGS] | LFDS611_SLIST_FLAG_DELETED); - } while( !((lfds611_atom_t) user_data_and_flags[LFDS611_SLIST_FLAGS] & LFDS611_SLIST_FLAG_DELETED) - and 0 == (cas_rv = lfds611_abstraction_dcas((volatile lfds611_atom_t *) se->user_data_and_flags, (lfds611_atom_t *) new_user_data_and_flags, (lfds611_atom_t *) user_data_and_flags)) ); - - if( cas_rv == 1 ) - if( ss->user_data_delete_function != NULL ) - ss->user_data_delete_function( (void *) user_data_and_flags[LFDS611_SLIST_USER_DATA], ss->user_state ); - - return( cas_rv ); -} - - - - - -/****************************************************************************/ -void lfds611_slist_single_threaded_physically_delete_all_elements( struct lfds611_slist_state *ss ) -{ - struct lfds611_slist_element - *volatile se, - *volatile se_temp; - - LFDS611_BARRIER_LOAD; - - se = ss->head; - - while( se != NULL ) { - // TRD : if a non-deleted element and there is a delete function, call the delete function - if( ss->user_data_delete_function != NULL ) - ss->user_data_delete_function( (void *) se->user_data_and_flags[LFDS611_SLIST_USER_DATA], ss->user_state ); - - se_temp = se; - se = se->next; - lfds611_liblfds_aligned_free( (void *) se_temp ); - } - - lfds611_slist_internal_init_slist( ss, ss->user_data_delete_function, ss->user_state ); - - LFDS611_BARRIER_STORE; - - return; -} - diff --git a/openair2/UTIL/LFDS/liblfds6.1.1/liblfds611/src/lfds611_slist/lfds611_slist_get_and_set.c b/openair2/UTIL/LFDS/liblfds6.1.1/liblfds611/src/lfds611_slist/lfds611_slist_get_and_set.c deleted file mode 100644 index 5d5112b3b3..0000000000 --- a/openair2/UTIL/LFDS/liblfds6.1.1/liblfds611/src/lfds611_slist/lfds611_slist_get_and_set.c +++ /dev/null @@ -1,133 +0,0 @@ -#include "lfds611_slist_internal.h" - - - - - -/****************************************************************************/ -int lfds611_slist_get_user_data_from_element( struct lfds611_slist_element *se, void **user_data ) -{ - int - rv = 1; - - assert( se != NULL ); - assert( user_data != NULL ); - - LFDS611_BARRIER_LOAD; - - *user_data = (void *) se->user_data_and_flags[LFDS611_SLIST_USER_DATA]; - - if( (lfds611_atom_t) se->user_data_and_flags[LFDS611_SLIST_FLAGS] & LFDS611_SLIST_FLAG_DELETED ) - rv = 0; - - return( rv ); -} - - - - - -/****************************************************************************/ -int lfds611_slist_set_user_data_in_element( struct lfds611_slist_element *se, void *user_data ) -{ - LFDS611_ALIGN(LFDS611_ALIGN_DOUBLE_POINTER) void - *user_data_and_flags[2], - *new_user_data_and_flags[2]; - - int - rv = 1; - - assert( se != NULL ); - // TRD : user_data can be NULL - - LFDS611_BARRIER_LOAD; - - user_data_and_flags[LFDS611_SLIST_USER_DATA] = se->user_data_and_flags[LFDS611_SLIST_USER_DATA]; - user_data_and_flags[LFDS611_SLIST_FLAGS] = se->user_data_and_flags[LFDS611_SLIST_FLAGS]; - - new_user_data_and_flags[LFDS611_SLIST_USER_DATA] = user_data; - - do { - new_user_data_and_flags[LFDS611_SLIST_FLAGS] = user_data_and_flags[LFDS611_SLIST_FLAGS]; - } while( !((lfds611_atom_t) user_data_and_flags[LFDS611_SLIST_FLAGS] & LFDS611_SLIST_FLAG_DELETED) and - 0 == lfds611_abstraction_dcas((volatile lfds611_atom_t *) se->user_data_and_flags, (lfds611_atom_t *) new_user_data_and_flags, (lfds611_atom_t *) user_data_and_flags) ); - - if( (lfds611_atom_t) user_data_and_flags[LFDS611_SLIST_FLAGS] & LFDS611_SLIST_FLAG_DELETED ) - rv = 0; - - LFDS611_BARRIER_STORE; - - return( rv ); -} - - - - - -/****************************************************************************/ -struct lfds611_slist_element *lfds611_slist_get_head( struct lfds611_slist_state *ss, struct lfds611_slist_element **se ) -{ - assert( ss != NULL ); - assert( se != NULL ); - - LFDS611_BARRIER_LOAD; - - *se = (struct lfds611_slist_element *) ss->head; - - lfds611_slist_internal_move_to_first_undeleted_element( se ); - - return( *se ); -} - - - - - -/****************************************************************************/ -struct lfds611_slist_element *lfds611_slist_get_next( struct lfds611_slist_element *se, struct lfds611_slist_element **next_se ) -{ - assert( se != NULL ); - assert( next_se != NULL ); - - LFDS611_BARRIER_LOAD; - - *next_se = (struct lfds611_slist_element *) se->next; - - lfds611_slist_internal_move_to_first_undeleted_element( next_se ); - - return( *next_se ); -} - - - - - -/****************************************************************************/ -struct lfds611_slist_element *lfds611_slist_get_head_and_then_next( struct lfds611_slist_state *ss, struct lfds611_slist_element **se ) -{ - assert( ss != NULL ); - assert( se != NULL ); - - if( *se == NULL ) - lfds611_slist_get_head( ss, se ); - else - lfds611_slist_get_next( *se, se ); - - return( *se ); -} - - - - - -/****************************************************************************/ -void lfds611_slist_internal_move_to_first_undeleted_element( struct lfds611_slist_element **se ) -{ - assert( se != NULL ); - - while( *se != NULL and (lfds611_atom_t) (*se)->user_data_and_flags[LFDS611_SLIST_FLAGS] & LFDS611_SLIST_FLAG_DELETED ) - (*se) = (struct lfds611_slist_element *) (*se)->next; - - return; -} - diff --git a/openair2/UTIL/LFDS/liblfds6.1.1/liblfds611/src/lfds611_slist/lfds611_slist_internal.h b/openair2/UTIL/LFDS/liblfds6.1.1/liblfds611/src/lfds611_slist/lfds611_slist_internal.h deleted file mode 100644 index fe7e767515..0000000000 --- a/openair2/UTIL/LFDS/liblfds6.1.1/liblfds611/src/lfds611_slist/lfds611_slist_internal.h +++ /dev/null @@ -1,53 +0,0 @@ -/***** the library wide include file *****/ -#include "liblfds611_internal.h" - -/***** defines *****/ -#define LFDS611_SLIST_USER_DATA 0 -#define LFDS611_SLIST_FLAGS 1 - -#define LFDS611_SLIST_NO_FLAGS 0x0 -#define LFDS611_SLIST_FLAG_DELETED 0x1 - -/***** structures *****/ -#pragma pack( push, LFDS611_ALIGN_SINGLE_POINTER ) - -struct lfds611_slist_state { - struct lfds611_slist_element - *volatile head; - - void - (*user_data_delete_function)( void *user_data, void *user_state ), - *user_state; -}; - -#pragma pack( pop ) - -#pragma pack( push, LFDS611_ALIGN_DOUBLE_POINTER ) - -/* TRD : this pragma pack doesn't seem to work under Windows - if the structure members are the correct way round - (next first), then user_data_and_flags ends up on - a single pointer boundary and DCAS crashes - - accordingly, I've moved user_data_and_flags first -*/ - -struct lfds611_slist_element { - void - *volatile user_data_and_flags[2]; - - // TRD : requires volatile as is target of CAS - struct lfds611_slist_element - *volatile next; -}; - -#pragma pack( pop ) - -/***** private prototypes *****/ -void lfds611_slist_internal_init_slist( struct lfds611_slist_state *ss, void (*user_data_delete_function)(void *user_data, void *user_state), void *user_state ); - -void lfds611_slist_internal_link_element_to_head( struct lfds611_slist_state *lfds611_slist_state, struct lfds611_slist_element *volatile se ); -void lfds611_slist_internal_link_element_after_element( struct lfds611_slist_element *volatile lfds611_slist_in_list_element, struct lfds611_slist_element *volatile se ); - -void lfds611_slist_internal_move_to_first_undeleted_element( struct lfds611_slist_element **se ); - diff --git a/openair2/UTIL/LFDS/liblfds6.1.1/liblfds611/src/lfds611_slist/lfds611_slist_link.c b/openair2/UTIL/LFDS/liblfds6.1.1/liblfds611/src/lfds611_slist/lfds611_slist_link.c deleted file mode 100644 index 3df2775c4f..0000000000 --- a/openair2/UTIL/LFDS/liblfds6.1.1/liblfds611/src/lfds611_slist/lfds611_slist_link.c +++ /dev/null @@ -1,53 +0,0 @@ -#include "lfds611_slist_internal.h" - - - - - -/****************************************************************************/ -void lfds611_slist_internal_link_element_to_head( struct lfds611_slist_state *ss, struct lfds611_slist_element *volatile se ) -{ - LFDS611_ALIGN(LFDS611_ALIGN_SINGLE_POINTER) struct lfds611_slist_element - *se_next; - - assert( ss != NULL ); - assert( se != NULL ); - - LFDS611_BARRIER_LOAD; - - se_next = ss->head; - - do { - se->next = se_next; - } while( se->next != (se_next = (struct lfds611_slist_element *) lfds611_abstraction_cas((volatile lfds611_atom_t *) &ss->head, (lfds611_atom_t) se, (lfds611_atom_t) se->next)) ); - - return; -} - - - - - -/****************************************************************************/ -void lfds611_slist_internal_link_element_after_element( struct lfds611_slist_element *volatile lfds611_slist_in_list_element, struct lfds611_slist_element *volatile se ) -{ - LFDS611_ALIGN(LFDS611_ALIGN_SINGLE_POINTER) struct lfds611_slist_element - *se_prev, - *se_next; - - assert( lfds611_slist_in_list_element != NULL ); - assert( se != NULL ); - - LFDS611_BARRIER_LOAD; - - se_prev = (struct lfds611_slist_element *) lfds611_slist_in_list_element; - - se_next = se_prev->next; - - do { - se->next = se_next; - } while( se->next != (se_next = (struct lfds611_slist_element *) lfds611_abstraction_cas((volatile lfds611_atom_t *) &se_prev->next, (lfds611_atom_t) se, (lfds611_atom_t) se->next)) ); - - return; -} - diff --git a/openair2/UTIL/LFDS/liblfds6.1.1/liblfds611/src/lfds611_slist/lfds611_slist_new.c b/openair2/UTIL/LFDS/liblfds6.1.1/liblfds611/src/lfds611_slist/lfds611_slist_new.c deleted file mode 100644 index b48e349ab0..0000000000 --- a/openair2/UTIL/LFDS/liblfds6.1.1/liblfds611/src/lfds611_slist/lfds611_slist_new.c +++ /dev/null @@ -1,114 +0,0 @@ -#include "lfds611_slist_internal.h" - - - - - -/****************************************************************************/ -int lfds611_slist_new( struct lfds611_slist_state **ss, void (*user_data_delete_function)(void *user_data, void *user_state), void *user_state ) -{ - int - rv = 0; - - assert( ss != NULL ); - // TRD : user_data_delete_function can be NULL - // TRD : user_state can be NULL - - *ss = (struct lfds611_slist_state *) lfds611_liblfds_aligned_malloc( sizeof(struct lfds611_slist_state), LFDS611_ALIGN_SINGLE_POINTER ); - - if( *ss != NULL ) { - lfds611_slist_internal_init_slist( *ss, user_data_delete_function, user_state ); - rv = 1; - } - - LFDS611_BARRIER_STORE; - - return( rv ); -} - - - - - -/****************************************************************************/ -//#pragma warning( disable : 4100 ) - -void lfds611_slist_use( struct lfds611_slist_state *ss ) -{ - assert( ss != NULL ); - - LFDS611_BARRIER_LOAD; - - return; -} - -//#pragma warning( default : 4100 ) - - - - - -/****************************************************************************/ -void lfds611_slist_internal_init_slist( struct lfds611_slist_state *ss, void (*user_data_delete_function)(void *user_data, void *user_state), void *user_state ) -{ - assert( ss != NULL ); - // TRD : user_data_delete_function can be NULL - // TRD : user_state can be NULL - - ss->head = NULL; - ss->user_data_delete_function = user_data_delete_function; - ss->user_state = user_state; - - return; -} - - - - - -/****************************************************************************/ -struct lfds611_slist_element *lfds611_slist_new_head( struct lfds611_slist_state *ss, void *user_data ) -{ - LFDS611_ALIGN(LFDS611_ALIGN_SINGLE_POINTER) struct lfds611_slist_element - *volatile se; - - assert( ss != NULL ); - // TRD : user_data can be NULL - - se = (struct lfds611_slist_element *) lfds611_liblfds_aligned_malloc( sizeof(struct lfds611_slist_element), LFDS611_ALIGN_DOUBLE_POINTER ); - - if( se != NULL ) { - se->user_data_and_flags[LFDS611_SLIST_USER_DATA] = user_data; - se->user_data_and_flags[LFDS611_SLIST_FLAGS] = LFDS611_SLIST_NO_FLAGS; - - lfds611_slist_internal_link_element_to_head( ss, se ); - } - - return( (struct lfds611_slist_element *) se ); -} - - - - - -/****************************************************************************/ -struct lfds611_slist_element *lfds611_slist_new_next( struct lfds611_slist_element *se, void *user_data ) -{ - LFDS611_ALIGN(LFDS611_ALIGN_SINGLE_POINTER) struct lfds611_slist_element - *volatile se_next; - - assert( se != NULL ); - // TRD : user_data can be NULL - - se_next = (struct lfds611_slist_element *) lfds611_liblfds_aligned_malloc( sizeof(struct lfds611_slist_element), LFDS611_ALIGN_DOUBLE_POINTER ); - - if( se_next != NULL ) { - se_next->user_data_and_flags[LFDS611_SLIST_USER_DATA] = user_data; - se_next->user_data_and_flags[LFDS611_SLIST_FLAGS] = LFDS611_SLIST_NO_FLAGS; - - lfds611_slist_internal_link_element_after_element( se, se_next ); - } - - return( (struct lfds611_slist_element *) se_next ); -} - diff --git a/openair2/UTIL/LFDS/liblfds6.1.1/liblfds611/src/lfds611_stack/lfds611_stack_delete.c b/openair2/UTIL/LFDS/liblfds6.1.1/liblfds611/src/lfds611_stack/lfds611_stack_delete.c deleted file mode 100644 index 75700e6b39..0000000000 --- a/openair2/UTIL/LFDS/liblfds6.1.1/liblfds611/src/lfds611_stack/lfds611_stack_delete.c +++ /dev/null @@ -1,67 +0,0 @@ -#include "lfds611_stack_internal.h" - - - - - -/****************************************************************************/ -void lfds611_stack_delete( struct lfds611_stack_state *ss, void (*user_data_delete_function)(void *user_data, void *user_state), void *user_state ) -{ - void - *user_data; - - assert( ss != NULL ); - // TRD : user_data_delete_function can be NULL - // TRD : user_state can be NULL - - while( lfds611_stack_pop(ss, &user_data) ) - if( user_data_delete_function != NULL ) - user_data_delete_function( user_data, user_state ); - - lfds611_freelist_delete( ss->fs, lfds611_stack_internal_freelist_delete_function, NULL ); - - lfds611_liblfds_aligned_free( ss ); - - return; -} - - - - - -/****************************************************************************/ -void lfds611_stack_clear( struct lfds611_stack_state *ss, void (*user_data_clear_function)(void *user_data, void *user_state), void *user_state ) -{ - void - *user_data; - - assert( ss != NULL ); - // TRD : user_data_clear_function can be NULL - // TRD : user_state can be NULL - - while( lfds611_stack_pop(ss, &user_data) ) - if( user_data_clear_function != NULL ) - user_data_clear_function( user_data, user_state ); - - return; -} - - - - - -/****************************************************************************/ -//#pragma warning( disable : 4100 ) - -void lfds611_stack_internal_freelist_delete_function( void *user_data, void *user_state ) -{ - assert( user_data != NULL ); - assert( user_state == NULL ); - - lfds611_liblfds_aligned_free( user_data ); - - return; -} - -//#pragma warning( default : 4100 ) - diff --git a/openair2/UTIL/LFDS/liblfds6.1.1/liblfds611/src/lfds611_stack/lfds611_stack_internal.h b/openair2/UTIL/LFDS/liblfds6.1.1/liblfds611/src/lfds611_stack/lfds611_stack_internal.h deleted file mode 100644 index 32f4f3fa40..0000000000 --- a/openair2/UTIL/LFDS/liblfds6.1.1/liblfds611/src/lfds611_stack/lfds611_stack_internal.h +++ /dev/null @@ -1,51 +0,0 @@ -/***** the library wide include file *****/ -#include "liblfds611_internal.h" - -/***** pragmas *****/ - -/***** defines *****/ -#define LFDS611_STACK_POINTER 0 -#define LFDS611_STACK_COUNTER 1 -#define LFDS611_STACK_PAC_SIZE 2 - -/***** structures *****/ -#pragma pack( push, LFDS611_ALIGN_DOUBLE_POINTER ) - -struct lfds611_stack_state { - // TRD : must come first for alignment - struct lfds611_stack_element - *volatile top[LFDS611_STACK_PAC_SIZE]; - - lfds611_atom_t - aba_counter; - - struct lfds611_freelist_state - *fs; -}; - -struct lfds611_stack_element { - struct lfds611_stack_element - *next[LFDS611_STACK_PAC_SIZE]; - - struct lfds611_freelist_element - *fe; - - void - *user_data; -}; - -#pragma pack( pop ) - -/***** private prototypes *****/ -int lfds611_stack_internal_freelist_init_function( void **user_data, void *user_state ); -void lfds611_stack_internal_freelist_delete_function( void *user_data, void *user_state ); - -void lfds611_stack_internal_new_element_from_freelist( struct lfds611_stack_state *ss, struct lfds611_stack_element *se[LFDS611_STACK_PAC_SIZE], void *user_data ); -void lfds611_stack_internal_new_element( struct lfds611_stack_state *ss, struct lfds611_stack_element *se[LFDS611_STACK_PAC_SIZE], void *user_data ); -void lfds611_stack_internal_init_element( struct lfds611_stack_state *ss, struct lfds611_stack_element *se[LFDS611_STACK_PAC_SIZE], struct lfds611_freelist_element *fe, void *user_data ); - -void lfds611_stack_internal_push( struct lfds611_stack_state *ss, struct lfds611_stack_element *se[LFDS611_STACK_PAC_SIZE] ); - -void lfds611_stack_internal_validate( struct lfds611_stack_state *ss, struct lfds611_validation_info *vi, enum lfds611_data_structure_validity *stack_validity, - enum lfds611_data_structure_validity *freelist_validity ); - diff --git a/openair2/UTIL/LFDS/liblfds6.1.1/liblfds611/src/lfds611_stack/lfds611_stack_new.c b/openair2/UTIL/LFDS/liblfds6.1.1/liblfds611/src/lfds611_stack/lfds611_stack_new.c deleted file mode 100644 index 927f28c88c..0000000000 --- a/openair2/UTIL/LFDS/liblfds6.1.1/liblfds611/src/lfds611_stack/lfds611_stack_new.c +++ /dev/null @@ -1,156 +0,0 @@ -#include "lfds611_stack_internal.h" - - - - - -/****************************************************************************/ -int lfds611_stack_new( struct lfds611_stack_state **ss, lfds611_atom_t number_elements ) -{ - int - rv = 0; - - assert( ss != NULL ); - // TRD : number_elements can be any value in its range - - *ss = (struct lfds611_stack_state *) lfds611_liblfds_aligned_malloc( sizeof(struct lfds611_stack_state), LFDS611_ALIGN_DOUBLE_POINTER ); - - if( *ss != NULL ) { - // TRD : the size of the lfds611_freelist is the size of the lfds611_stack - lfds611_freelist_new( &(*ss)->fs, number_elements, lfds611_stack_internal_freelist_init_function, NULL ); - - if( (*ss)->fs == NULL ) { - lfds611_liblfds_aligned_free( *ss ); - *ss = NULL; - } - - if( (*ss)->fs != NULL ) { - (*ss)->top[LFDS611_STACK_POINTER] = NULL; - (*ss)->top[LFDS611_STACK_COUNTER] = 0; - (*ss)->aba_counter = 0; - rv = 1; - } - } - - LFDS611_BARRIER_STORE; - - return( rv ); -} - - - - - -/****************************************************************************/ -//#pragma warning( disable : 4100 ) - -void lfds611_stack_use( struct lfds611_stack_state *ss ) -{ - assert( ss != NULL ); - - LFDS611_BARRIER_LOAD; - - return; -} - -//#pragma warning( default : 4100 ) - - - - - -/****************************************************************************/ -//#pragma warning( disable : 4100 ) - -int lfds611_stack_internal_freelist_init_function( void **user_data, void *user_state ) -{ - int - rv = 0; - - assert( user_data != NULL ); - assert( user_state == NULL ); - - *user_data = lfds611_liblfds_aligned_malloc( sizeof(struct lfds611_stack_element), LFDS611_ALIGN_DOUBLE_POINTER ); - - if( *user_data != NULL ) - rv = 1; - - return( rv ); -} - -//#pragma warning( default : 4100 ) - - - - - -/****************************************************************************/ -void lfds611_stack_internal_new_element_from_freelist( struct lfds611_stack_state *ss, struct lfds611_stack_element *se[LFDS611_STACK_PAC_SIZE], void *user_data ) -{ - struct lfds611_freelist_element - *fe; - - assert( ss != NULL ); - assert( se != NULL ); - // TRD : user_data can be any value in its range - - lfds611_freelist_pop( ss->fs, &fe ); - - if( fe == NULL ) - se[LFDS611_STACK_POINTER] = NULL; - - if( fe != NULL ) - lfds611_stack_internal_init_element( ss, se, fe, user_data ); - - return; -} - - - - - -/****************************************************************************/ -void lfds611_stack_internal_new_element( struct lfds611_stack_state *ss, struct lfds611_stack_element *se[LFDS611_STACK_PAC_SIZE], void *user_data ) -{ - struct lfds611_freelist_element - *fe; - - assert( ss != NULL ); - assert( se != NULL ); - // TRD : user_data can be any value in its range - - lfds611_freelist_guaranteed_pop( ss->fs, &fe ); - - if( fe == NULL ) - se[LFDS611_STACK_POINTER] = NULL; - - if( fe != NULL ) - lfds611_stack_internal_init_element( ss, se, fe, user_data ); - - return; -} - - - - - -/****************************************************************************/ -void lfds611_stack_internal_init_element( struct lfds611_stack_state *ss, struct lfds611_stack_element *se[LFDS611_STACK_PAC_SIZE], struct lfds611_freelist_element *fe, void *user_data ) -{ - assert( ss != NULL ); - assert( se != NULL ); - assert( fe != NULL ); - // TRD : user_data can be any value in its range - - lfds611_freelist_get_user_data_from_element( fe, (void **) &se[LFDS611_STACK_POINTER] ); - - se[LFDS611_STACK_COUNTER] = (struct lfds611_stack_element *) lfds611_abstraction_increment( (lfds611_atom_t *) &ss->aba_counter ); - - se[LFDS611_STACK_POINTER]->next[LFDS611_STACK_POINTER] = NULL; - se[LFDS611_STACK_POINTER]->next[LFDS611_STACK_COUNTER] = 0; - se[LFDS611_STACK_POINTER]->fe = fe; - se[LFDS611_STACK_POINTER]->user_data = user_data; - - return; -} - diff --git a/openair2/UTIL/LFDS/liblfds6.1.1/liblfds611/src/lfds611_stack/lfds611_stack_push_pop.c b/openair2/UTIL/LFDS/liblfds6.1.1/liblfds611/src/lfds611_stack/lfds611_stack_push_pop.c deleted file mode 100644 index 402051114b..0000000000 --- a/openair2/UTIL/LFDS/liblfds6.1.1/liblfds611/src/lfds611_stack/lfds611_stack_push_pop.c +++ /dev/null @@ -1,110 +0,0 @@ -#include "lfds611_stack_internal.h" - - - - - -/****************************************************************************/ -int lfds611_stack_push( struct lfds611_stack_state *ss, void *user_data ) -{ - LFDS611_ALIGN(LFDS611_ALIGN_DOUBLE_POINTER) struct lfds611_stack_element - *se[LFDS611_STACK_PAC_SIZE]; - - assert( ss != NULL ); - // TRD : user_data can be NULL - - lfds611_stack_internal_new_element_from_freelist( ss, se, user_data ); - - if( se[LFDS611_STACK_POINTER] == NULL ) - return( 0 ); - - lfds611_stack_internal_push( ss, se ); - - return( 1 ); -} - - - - - -/****************************************************************************/ -int lfds611_stack_guaranteed_push( struct lfds611_stack_state *ss, void *user_data ) -{ - LFDS611_ALIGN(LFDS611_ALIGN_DOUBLE_POINTER) struct lfds611_stack_element - *se[LFDS611_STACK_PAC_SIZE]; - - assert( ss != NULL ); - // TRD : user_data can be NULL - - /* TRD : this function allocated a new lfds611_freelist element and uses that - to push onto the lfds611_stack, guaranteeing success (unless malloc() - fails of course) - */ - - lfds611_stack_internal_new_element( ss, se, user_data ); - - // TRD : malloc failed - if( se[LFDS611_STACK_POINTER] == NULL ) - return( 0 ); - - lfds611_stack_internal_push( ss, se ); - - return( 1 ); -} - - - - - -/****************************************************************************/ -void lfds611_stack_internal_push( struct lfds611_stack_state *ss, struct lfds611_stack_element *se[LFDS611_STACK_PAC_SIZE] ) -{ - LFDS611_ALIGN(LFDS611_ALIGN_DOUBLE_POINTER) struct lfds611_stack_element - *original_se_next[LFDS611_STACK_PAC_SIZE]; - - assert( ss != NULL ); - assert( se != NULL ); - - LFDS611_BARRIER_LOAD; - - original_se_next[LFDS611_STACK_POINTER] = ss->top[LFDS611_STACK_POINTER]; - original_se_next[LFDS611_STACK_COUNTER] = ss->top[LFDS611_STACK_COUNTER]; - - do { - se[LFDS611_STACK_POINTER]->next[LFDS611_STACK_POINTER] = original_se_next[LFDS611_STACK_POINTER]; - se[LFDS611_STACK_POINTER]->next[LFDS611_STACK_COUNTER] = original_se_next[LFDS611_STACK_COUNTER]; - } while( 0 == lfds611_abstraction_dcas((volatile lfds611_atom_t *) ss->top, (lfds611_atom_t *) se, (lfds611_atom_t *) original_se_next) ); - - return; -} - - - - - -/****************************************************************************/ -int lfds611_stack_pop( struct lfds611_stack_state *ss, void **user_data ) -{ - LFDS611_ALIGN(LFDS611_ALIGN_DOUBLE_POINTER) struct lfds611_stack_element - *se[LFDS611_STACK_PAC_SIZE]; - - assert( ss != NULL ); - assert( user_data != NULL ); - - LFDS611_BARRIER_LOAD; - - se[LFDS611_STACK_COUNTER] = ss->top[LFDS611_STACK_COUNTER]; - se[LFDS611_STACK_POINTER] = ss->top[LFDS611_STACK_POINTER]; - - do { - if( se[LFDS611_STACK_POINTER] == NULL ) - return( 0 ); - } while( 0 == lfds611_abstraction_dcas((volatile lfds611_atom_t *) ss->top, (lfds611_atom_t *) se[LFDS611_STACK_POINTER]->next, (lfds611_atom_t *) se) ); - - *user_data = se[LFDS611_STACK_POINTER]->user_data; - - lfds611_freelist_push( ss->fs, se[LFDS611_STACK_POINTER]->fe ); - - return( 1 ); -} - diff --git a/openair2/UTIL/LFDS/liblfds6.1.1/liblfds611/src/lfds611_stack/lfds611_stack_query.c b/openair2/UTIL/LFDS/liblfds6.1.1/liblfds611/src/lfds611_stack/lfds611_stack_query.c deleted file mode 100644 index 51ef2d1283..0000000000 --- a/openair2/UTIL/LFDS/liblfds6.1.1/liblfds611/src/lfds611_stack/lfds611_stack_query.c +++ /dev/null @@ -1,154 +0,0 @@ -#include "lfds611_stack_internal.h" - - - - - -/****************************************************************************/ -void lfds611_stack_query( struct lfds611_stack_state *ss, enum lfds611_stack_query_type query_type, void *query_input, void *query_output ) -{ - assert( ss != NULL ); - // TRD : query_type can be any value in its range - // TRD : query_iput can be NULL - assert( query_output != NULL ); - - LFDS611_BARRIER_LOAD; - - switch( query_type ) { - case LFDS611_STACK_QUERY_ELEMENT_COUNT: - assert( query_input == NULL ); - - lfds611_freelist_query( ss->fs, LFDS611_FREELIST_QUERY_ELEMENT_COUNT, NULL, query_output ); - break; - - case LFDS611_STACK_QUERY_VALIDATE: - // TRD : query_input can be NULL - - /* TRD : the validation info passed in is for the stack - it indicates the minimum and maximum number of elements - which should be present - - we need to validate the freelist - and validate the stack - - we cannot know the min/max for the freelist, given only - the min/max for the stack - */ - - lfds611_freelist_query( ss->fs, LFDS611_FREELIST_QUERY_VALIDATE, NULL, (enum lfds611_data_structure_validity *) query_output ); - - if( *(enum lfds611_data_structure_validity *) query_output == LFDS611_VALIDITY_VALID ) - lfds611_stack_internal_validate( ss, (struct lfds611_validation_info *) query_input, (enum lfds611_data_structure_validity *) query_output, ((enum lfds611_data_structure_validity *) query_output)+1 ); - - break; - } - - return; -} - - - - - -/****************************************************************************/ -void lfds611_stack_internal_validate( struct lfds611_stack_state *ss, struct lfds611_validation_info *vi, enum lfds611_data_structure_validity *stack_validity, - enum lfds611_data_structure_validity *freelist_validity ) -{ - struct lfds611_stack_element - *se, - *se_slow, - *se_fast; - - lfds611_atom_t - element_count = 0, - total_elements; - - struct lfds611_validation_info - freelist_vi; - - assert( ss != NULL ); - // TRD : vi can be NULL - assert( stack_validity != NULL ); - - *stack_validity = LFDS611_VALIDITY_VALID; - - se_slow = se_fast = (struct lfds611_stack_element *) ss->top[LFDS611_STACK_POINTER]; - - /* TRD : first, check for a loop - we have two pointers - both of which start at the top of the stack - we enter a loop - and on each iteration - we advance one pointer by one element - and the other by two - - we exit the loop when both pointers are NULL - (have reached the end of the stack) - - or - - if we fast pointer 'sees' the slow pointer - which means we have a loop - */ - - if( se_slow != NULL ) - do { - se_slow = se_slow->next[LFDS611_STACK_POINTER]; - - if( se_fast != NULL ) - se_fast = se_fast->next[LFDS611_STACK_POINTER]; - - if( se_fast != NULL ) - se_fast = se_fast->next[LFDS611_STACK_POINTER]; - } while( se_slow != NULL and se_fast != se_slow ); - - if( se_fast != NULL and se_slow != NULL and se_fast == se_slow ) - *stack_validity = LFDS611_VALIDITY_INVALID_LOOP; - - /* TRD : now check for expected number of elements - vi can be NULL, in which case we do not check - we know we don't have a loop from our earlier check - */ - - if( *stack_validity == LFDS611_VALIDITY_VALID and vi != NULL ) { - se = (struct lfds611_stack_element *) ss->top[LFDS611_STACK_POINTER]; - - while( se != NULL ) { - element_count++; - se = (struct lfds611_stack_element *) se->next[LFDS611_STACK_POINTER]; - } - - if( element_count < vi->min_elements ) - *stack_validity = LFDS611_VALIDITY_INVALID_MISSING_ELEMENTS; - - if( element_count > vi->max_elements ) - *stack_validity = LFDS611_VALIDITY_INVALID_ADDITIONAL_ELEMENTS; - } - - /* TRD : now we validate the freelist - - we may be able to check for the expected number of - elements in the freelist - - if the caller has given us an expected min and max - number of elements in the stack, then the total number - of elements in the freelist, minus that min and max, - gives us the expected number of elements in the - freelist - */ - - if( vi != NULL ) { - lfds611_freelist_query( ss->fs, LFDS611_FREELIST_QUERY_ELEMENT_COUNT, NULL, (void *) &total_elements ); - - freelist_vi.min_elements = total_elements - vi->max_elements; - freelist_vi.max_elements = total_elements - vi->min_elements; - - lfds611_freelist_query( ss->fs, LFDS611_FREELIST_QUERY_VALIDATE, (void *) &freelist_vi, (void *) freelist_validity ); - } - - if( vi == NULL ) - lfds611_freelist_query( ss->fs, LFDS611_FREELIST_QUERY_VALIDATE, NULL, (void *) freelist_validity ); - - return; -} - diff --git a/openair2/UTIL/LFDS/liblfds6.1.1/liblfds611/src/liblfds611_internal.h b/openair2/UTIL/LFDS/liblfds6.1.1/liblfds611/src/liblfds611_internal.h deleted file mode 100644 index 9bcf726504..0000000000 --- a/openair2/UTIL/LFDS/liblfds6.1.1/liblfds611/src/liblfds611_internal.h +++ /dev/null @@ -1,25 +0,0 @@ -/***** public prototypes *****/ -#include "liblfds611.h" - -/***** defines *****/ -#define and && -#define or || - -#define RAISED 1 -#define LOWERED 0 - -#define NO_FLAGS 0x0 - -/***** private prototypes *****/ -void *lfds611_liblfds_aligned_malloc( size_t size, size_t align_in_bytes ); -void lfds611_liblfds_aligned_free( void *memory ); - -static LFDS611_INLINE lfds611_atom_t lfds611_abstraction_cas( volatile lfds611_atom_t *destination, lfds611_atom_t exchange, lfds611_atom_t compare ); -static LFDS611_INLINE unsigned char lfds611_abstraction_dcas( volatile lfds611_atom_t *destination, lfds611_atom_t *exchange, lfds611_atom_t *compare ); -static LFDS611_INLINE lfds611_atom_t lfds611_abstraction_increment( volatile lfds611_atom_t *value ); - -/***** inlined code *****/ -#include "lfds611_abstraction/lfds611_abstraction_cas.c" -#include "lfds611_abstraction/lfds611_abstraction_dcas.c" -#include "lfds611_abstraction/lfds611_abstraction_increment.c" - diff --git a/openair2/UTIL/LFDS/liblfds6.1.1/test/building.txt b/openair2/UTIL/LFDS/liblfds6.1.1/test/building.txt deleted file mode 100644 index 685cda0cf1..0000000000 --- a/openair2/UTIL/LFDS/liblfds6.1.1/test/building.txt +++ /dev/null @@ -1,51 +0,0 @@ -building test -============= - -Windows (user-mode) -=================== -1. Use Microsoft Visual Studio 2008 or Visual C++ 2008 Express Edition (or - later versions) to load "liblfds.sln". The "Win32" platform is x86, - the "x64" platform is x64. The test programme provides the "Release" - and "Debug" targets. The other targets ("Release DLL", "Release Lib", - "Debug DLL" and "Debug Lib") are carried over will-nilly from the liblds - library. - - All builds will work, but DLL builds will require the DLL from liblfds - to be placed into a location where the test executable can find it (e.g. - the same directory). - -2. Use Microsoft Windows SDK and GNUmake to run makefile.windows (obviously - you'll need to have run setenv.bat or the appropriate vcvars*.bat first; - you can build for x64/64-bit and x86/32-bit - just run the correct batch - file). - - If liblfds has been built as a DLL, the DLL from liblfds needs to be - placed into a location where the test executable can find it (e.g. the - same directory). - - Targets are "rel", "dbg" and "clean". You need to clean between switching - targets. - -Windows (kernel) -================ -No build supported, since this is a command line utility. - -Linux -===== -Use GNUmake to run "makefile.linux". Targets are "rel", "dbg" and -"clean". You need to clean between switching targets. - -If liblfds has been built as a shared object, the shared object file from -liblfds will need to be placed somewhere the text executable can find it. - -A convenient solution is to place the shared object file in the same -directory as the text executable and set the environment variable -"LD_LIBRARY_PATH" to ".", e.g. in bash; - -export LD_LIBRARY_PATH=. - -Remember to unset after finishing testing, or your system will continue -to scan the current directory for shared object files. - -unset LD_LIBRARY_PATH - diff --git a/openair2/UTIL/LFDS/liblfds6.1.1/test/makefile.linux b/openair2/UTIL/LFDS/liblfds6.1.1/test/makefile.linux deleted file mode 100644 index 8bc0c1c860..0000000000 --- a/openair2/UTIL/LFDS/liblfds6.1.1/test/makefile.linux +++ /dev/null @@ -1,82 +0,0 @@ -##### paths ##### -BINDIR = bin -INCDIR = ../liblfds611/inc -LIBDIR = ../liblfds611/bin -OBJDIR = obj -SRCDIR = src - -##### misc ##### -QUIETLY = 1>nul 2>nul - -##### sources, objects and libraries ##### -BINNAME = test -BINARY = $(BINDIR)/$(BINNAME) -SRCDIRS = . -SOURCES = abstraction_cpu_count.c test_abstraction.c abstraction_thread_start.c abstraction_thread_wait.c benchmark_freelist.c benchmark_queue.c benchmark_ringbuffer.c benchmark_stack.c test_freelist.c main.c misc.c test_queue.c test_ringbuffer.c test_slist.c test_stack.c -OBJECTS = $(patsubst %.c,$(OBJDIR)/%.o,$(notdir $(SOURCES))) -SYSLIBS = -lpthread -lc -lm -USRLIBS = -llfds611 - -##### CPU variants ##### -UNAME = $(shell uname -m) -GCCARCH = -march=$(UNAME) - -ifeq ($(UNAME),x86_64) - GCCARCH = -march=core2 -endif - -ifeq ($(findstring arm,$(UNAME)),arm) - GCCARCH = -march=armv6k -marm -endif - -##### tools ##### -MAKE = make -MFLAGS = - -DG = gcc -DGFLAGS = -MM -std=c99 -I"$(SRCDIR)" -I"$(INCDIR)" - -CC = gcc -CFBASE = -Wall -Wno-unknown-pragmas -std=c99 $(GCCARCH) -pthread -c -I"$(SRCDIR)" -I"$(INCDIR)" -CFREL = -O2 -Wno-strict-aliasing -CFDBG = -O0 -g - -LD = gcc -LFBASE = -L"$(LIBDIR)" -LFREL = -O2 -s -LFDBG = -O0 -g - -##### variants ##### -CFLAGS = $(CFBASE) $(CFDBG) -LFLAGS = $(LFBASE) $(LFDBG) - -ifeq ($(MAKECMDGOALS),rel) - CFLAGS = $(CFBASE) $(CFREL) - LFLAGS = $(LFBASE) $(LFREL) -endif - -##### search paths ##### -vpath %.c $(patsubst %,$(SRCDIR)/%:,$(SRCDIRS)) - -##### implicit rules ##### -$(OBJDIR)/%.o : %.c - $(DG) $(DGFLAGS) $< >$(OBJDIR)/$*.d - $(CC) $(CFLAGS) -o $@ $< - -##### explicit rules ##### -$(BINARY) : $(OBJECTS) - $(LD) -o $(BINARY) $(LFLAGS) $(OBJECTS) $(USRLIBS) $(SYSLIBS) - chmod +x $(BINARY) - -##### phony ##### -.PHONY : clean rel dbg - -clean : - @rm -f $(BINDIR)/$(BINNAME) $(OBJDIR)/*.o $(OBJDIR)/*.d - -rel : $(BINARY) -dbg : $(BINARY) - -##### dependencies ##### --include $(DEPENDS) - diff --git a/openair2/UTIL/LFDS/liblfds6.1.1/test/makefile.windows b/openair2/UTIL/LFDS/liblfds6.1.1/test/makefile.windows deleted file mode 100644 index d899414b07..0000000000 --- a/openair2/UTIL/LFDS/liblfds6.1.1/test/makefile.windows +++ /dev/null @@ -1,64 +0,0 @@ -##### paths ##### -BINDIR = bin -INCDIR = ../liblfds611/inc -LIBDIR = ../liblfds611/bin -OBJDIR = obj -SRCDIR = src - -##### misc ##### -QUIETLY = 1>nul 2>nul - -##### sources, objects and libraries ##### -BINNAME = test -BINARY = $(BINDIR)\$(BINNAME).exe -SRCDIRS = . -SOURCES = abstraction_cpu_count.c test_abstraction.c abstraction_thread_start.c abstraction_thread_wait.c benchmark_freelist.c benchmark_queue.c benchmark_ringbuffer.c benchmark_stack.c test_freelist.c main.c misc.c test_queue.c test_ringbuffer.c test_slist.c test_stack.c -OBJECTS = $(patsubst %.c,$(OBJDIR)/%.obj,$(notdir $(SOURCES))) -SYSLIBS = kernel32.lib -USRLIBS = liblfds611.lib - -##### tools ##### -MAKE = make -MFLAGS = - -CC = cl -CFBASE = /nologo /W4 /WX /c "-I$(SRCDIR)" "-I$(INCLUDE)" "-I$(INCDIR)" "/Fd$(BINDIR)\$(BINNAME).pdb" /D UNICODE /D _UNICODE /DWIN32_LEAN_AND_MEAN /D_CRT_SECURE_NO_WARNINGS -CFREL = /Ox /DNDEBUG /MT -CFDBG = /Od /Gm /Zi /D_DEBUG /MTd - -LD = link -LFBASE = "/libpath:$(LIB)" "/libpath:$(LIBDIR)" /nologo /subsystem:console /nodefaultlib /nxcompat /wx -LFREL = /incremental:no -LFDBG = /debug "/pdb:$(BINDIR)\$(BINNAME).pdb" - -##### variants ##### -CFLAGS = $(CFBASE) $(CFDBG) -LFLAGS = $(LFBASE) $(LFDBG) -CLIB = libcmtd.lib - -ifeq ($(MAKECMDGOALS),rel) - CFLAGS = $(CFBASE) $(CFREL) - LFLAGS = $(LFBASE) $(LFREL) - CLIB = libcmt.lib -endif - -##### search paths ##### -vpath %.c $(patsubst %,$(SRCDIR)/%;,$(SRCDIRS)) - -##### implicit rules ##### -$(OBJDIR)/%.obj : %.c - $(CC) $(CFLAGS) "/Fo$@" $< - -##### explicit rules ##### -$(BINARY) : $(OBJECTS) - $(LD) $(LFLAGS) $(CLIB) $(SYSLIBS) $(USRLIBS) $(OBJECTS) /out:$(BINARY) - -##### phony ##### -.PHONY : clean rel dbg - -clean : - @erase /Q $(OBJDIR)\*.obj $(BINDIR)\$(BINNAME).* $(QUIETLY) - -rel : $(BINARY) -dbg : $(BINARY) - diff --git a/openair2/UTIL/LFDS/liblfds6.1.1/test/src/abstraction.h b/openair2/UTIL/LFDS/liblfds6.1.1/test/src/abstraction.h deleted file mode 100644 index 7a7e82f9bb..0000000000 --- a/openair2/UTIL/LFDS/liblfds6.1.1/test/src/abstraction.h +++ /dev/null @@ -1,50 +0,0 @@ -/***** defines *****/ -#if (defined _WIN32 && defined _MSC_VER && !defined WIN_KERNEL_BUILD) -/* TRD : any Windows (user-mode) on any CPU with the Microsoft C compiler - - _WIN32 indicates 64-bit or 32-bit Windows - _MSC_VER indicates Microsoft C compiler - !WIN_KERNEL_BUILD indicates Windows user-mode -*/ - -#include -typedef HANDLE thread_state_t; -typedef DWORD thread_return_t; -#define CALLING_CONVENTION WINAPI -#endif - -#if (defined _WIN32 && defined _MSC_VER && defined WIN_KERNEL_BUILD) -/* TRD : any Windows (kernel-mode) on any CPU with the Microsoft C compiler - - _WIN32 indicates 64-bit or 32-bit Windows - _MSC_VER indicates Microsoft C compiler - WIN_KERNEL_BUILD indicates Windows kernel -*/ - -#include -typedef HANDLE thread_state_t; -typedef VOID thread_return_t; -#define CALLING_CONVENTION -#endif - -#if (defined __unix__ && defined __GNUC__) -/* TRD : any UNIX on any CPU with GCC - - __unix__ indicates Solaris, Linux, HPUX, etc - __GNUC__ indicates GCC -*/ -#include -#include -#include -typedef pthread_t thread_state_t; -typedef void * thread_return_t; -#define CALLING_CONVENTION -#endif - -typedef thread_return_t (CALLING_CONVENTION *thread_function_t)( void *thread_user_state ); - -/***** public prototypes *****/ -unsigned int abstraction_cpu_count( void ); -int abstraction_thread_start( thread_state_t *thread_state, unsigned int cpu, thread_function_t thread_function, void *thread_user_state ); -void abstraction_thread_wait( thread_state_t thread_state ); - diff --git a/openair2/UTIL/LFDS/liblfds6.1.1/test/src/abstraction_cpu_count.c b/openair2/UTIL/LFDS/liblfds6.1.1/test/src/abstraction_cpu_count.c deleted file mode 100644 index fb6ff5e79c..0000000000 --- a/openair2/UTIL/LFDS/liblfds6.1.1/test/src/abstraction_cpu_count.c +++ /dev/null @@ -1,81 +0,0 @@ -#include "internal.h" - - - - - -/****************************************************************************/ -#if (defined _WIN32 && defined _MSC_VER && !defined WIN_KERNEL_BUILD) - -/* TRD : any Windows (user-mode) on any CPU with the Microsoft C compiler - - _WIN32 indicates 64-bit or 32-bit Windows - _MSC_VER indicates Microsoft C compiler - !WIN_KERNEL_BUILD indicates Windows user-mode -*/ - -unsigned int abstraction_cpu_count() -{ - SYSTEM_INFO - si; - - GetNativeSystemInfo( &si ); - - return( (unsigned int) si.dwNumberOfProcessors ); -} - -#endif - - - - - -/****************************************************************************/ -#if (defined _WIN32 && defined _MSC_VER && defined WIN_KERNEL_BUILD) - -/* TRD : any Windows on any CPU with the Microsoft C compiler - - _WIN32 indicates 64-bit or 32-bit Windows - _MSC_VER indicates Microsoft C compiler - WIN_KERNEL_BUILD indicates Windows kernel -*/ - -unsigned int abstraction_cpu_count() -{ - unsigned int - active_processor_count; - - active_processor_count = KeQueryActiveProcessorCount( NULL ); - - return( active_processor_count ); -} - -#endif - - - - - -/****************************************************************************/ -#if (defined __linux__ && defined __GNUC__) - -/* TRD : Linux on any CPU with GCC - - this function I believe is Linux specific and varies by UNIX flavour - - __linux__ indicates Linux - __GNUC__ indicates GCC -*/ - -unsigned int abstraction_cpu_count() -{ - long int - cpu_count; - - cpu_count = sysconf( _SC_NPROCESSORS_ONLN ); - - return( (unsigned int) cpu_count ); -} - -#endif - diff --git a/openair2/UTIL/LFDS/liblfds6.1.1/test/src/abstraction_thread_start.c b/openair2/UTIL/LFDS/liblfds6.1.1/test/src/abstraction_thread_start.c deleted file mode 100644 index 5075c5f8de..0000000000 --- a/openair2/UTIL/LFDS/liblfds6.1.1/test/src/abstraction_thread_start.c +++ /dev/null @@ -1,141 +0,0 @@ -#include "internal.h" - - - - - -/****************************************************************************/ -#if (defined _WIN32 && defined _MSC_VER && !defined WIN_KERNEL_BUILD) - -/* TRD : any Windows (user-mode) on any CPU with the Microsoft C compiler - - _WIN32 indicates 64-bit or 32-bit Windows - _MSC_VER indicates Microsoft C compiler - !WIN_KERNEL_BUILD indicates Windows user-mode -*/ - -int abstraction_thread_start( thread_state_t *thread_state, unsigned int cpu, thread_function_t thread_function, void *thread_user_state ) -{ - int - rv = 0; - - DWORD - thread_id; - - DWORD_PTR - affinity_mask, - result; - - assert( thread_state != NULL ); - // TRD : cpu can be any value in its range - assert( thread_function != NULL ); - // TRD : thread_user_state can be NULL - - affinity_mask = (DWORD_PTR) (1 << cpu); - - *thread_state = CreateThread( NULL, 0, thread_function, thread_user_state, NO_FLAGS, &thread_id ); - - result = SetThreadAffinityMask( *thread_state, affinity_mask ); - - if( *thread_state != NULL and result != 0 ) - rv = 1; - - return( rv ); -} - -#endif - - - - - -/****************************************************************************/ -#if (defined _WIN32 && defined _MSC_VER && defined WIN_KERNEL_BUILD) - -/* TRD : any Windows on any CPU with the Microsoft C compiler - - _WIN32 indicates 64-bit or 32-bit Windows - _MSC_VER indicates Microsoft C compiler - WIN_KERNEL_BUILD indicates Windows kernel -*/ - -int abstraction_thread_start( thread_state_t *thread_state, unsigned int cpu, thread_function_t thread_function, void *thread_user_state ) -{ - int - rv = 0; - - KAFFINITY - affinity_mask - - NTSTATUS - nts_create, - nts_affinity; - - assert( thread_state != NULL ); - // TRD : cpu can be any value in its range - assert( thread_function != NULL ); - // TRD : thread_user_state can be NULL - - affinity_mask = 1 << cpu; - - nts_create = PsCreateSystemThread( thread_state, THREAD_ALL_ACCESS, NULL, NULL, NULL, thread_function, thread_user_state ); - - nts_affinity = ZwSetInformationThread( thread_state, ThreadAffinityMask, &affinity_mask, sizeof(KAFFINITY) ); - - if( nts_create == STATUS_SUCCESS and nts_affinity == STATUS_SUCCESS ) - rv = 1; - - return( rv ); -} - -#endif - - - - - -/****************************************************************************/ -#if (defined __unix__) - -/* TRD : any UNIX on any CPU with any compiler - - I assumed pthreads is available on any UNIX. - - __unix__ indicates Solaris, Linux, HPUX, etc -*/ - -int abstraction_thread_start( thread_state_t *thread_state, unsigned int cpu, thread_function_t thread_function, void *thread_user_state ) -{ - int - rv = 0, - rv_create; - - pthread_attr_t - attr; - - cpu_set_t - cpuset; - - assert( thread_state != NULL ); - // TRD : cpu can be any value in its range - assert( thread_function != NULL ); - // TRD : thread_user_state can be NULL - - pthread_attr_init( &attr ); - - CPU_ZERO( &cpuset ); - CPU_SET( cpu, &cpuset ); - pthread_attr_setaffinity_np( &attr, sizeof(cpuset), &cpuset ); - - rv_create = pthread_create( thread_state, &attr, thread_function, thread_user_state ); - - if( rv_create == 0 ) - rv = 1; - - pthread_attr_destroy( &attr ); - - return( rv ); -} - -#endif - diff --git a/openair2/UTIL/LFDS/liblfds6.1.1/test/src/abstraction_thread_wait.c b/openair2/UTIL/LFDS/liblfds6.1.1/test/src/abstraction_thread_wait.c deleted file mode 100644 index a5835c9051..0000000000 --- a/openair2/UTIL/LFDS/liblfds6.1.1/test/src/abstraction_thread_wait.c +++ /dev/null @@ -1,71 +0,0 @@ -#include "internal.h" - - - - - -/****************************************************************************/ -#if (defined _WIN32 && defined _MSC_VER && !defined WIN_KERNEL_BUILD) - -/* TRD : any Windows (user-mode) on any CPU with the Microsoft C compiler - - _WIN32 indicates 64-bit or 32-bit Windows - _MSC_VER indicates Microsoft C compiler - !WIN_KERNEL_BUILD indicates Windows user-mode -*/ - -void abstraction_thread_wait( thread_state_t thread_state ) -{ - WaitForSingleObject( thread_state, INFINITE ); - - return; -} - -#endif - - - - - -/****************************************************************************/ -#if (defined _WIN32 && defined _MSC_VER && defined WIN_KERNEL_BUILD) - -/* TRD : any Windows on any CPU with the Microsoft C compiler - - _WIN32 indicates 64-bit or 32-bit Windows - _MSC_VER indicates Microsoft C compiler - WIN_KERNEL_BUILD indicates Windows kernel -*/ - -void abstraction_thread_wait( thread_state_t thread_state ) -{ - KeWaitForSingleObject( thread_state, Executive, KernelMode, FALSE, NULL ); - - return; -} - -#endif - - - - - -/****************************************************************************/ -#if (defined __unix__) - -/* TRD : any UNIX on any CPU with any compiler - - I assumed pthreads is available on any UNIX. - - __unix__ indicates Solaris, Linux, HPUX, etc -*/ - -void abstraction_thread_wait( thread_state_t thread_state ) -{ - pthread_join( thread_state, NULL ); - - return; -} - -#endif - diff --git a/openair2/UTIL/LFDS/liblfds6.1.1/test/src/benchmark_freelist.c b/openair2/UTIL/LFDS/liblfds6.1.1/test/src/benchmark_freelist.c deleted file mode 100644 index 689de3eaa7..0000000000 --- a/openair2/UTIL/LFDS/liblfds6.1.1/test/src/benchmark_freelist.c +++ /dev/null @@ -1,134 +0,0 @@ -#include "internal.h" - - - - - -/****************************************************************************/ -void benchmark_lfds611_freelist( void ) -{ - unsigned int - loop, - thread_count, - cpu_count; - - struct lfds611_freelist_state - *fs; - - struct lfds611_freelist_benchmark - *fb; - - thread_state_t - *thread_handles; - - lfds611_atom_t - total_operations_for_full_test_for_all_cpus, - total_operations_for_full_test_for_all_cpus_for_one_cpu = 0; - - double - mean_operations_per_second_per_cpu, - difference_per_second_per_cpu, - total_difference_per_second_per_cpu, - std_dev_per_second_per_cpu, - scalability; - - /* TRD : here we benchmark the freelist - - the benchmark is to have a single freelist - where a worker thread busy-works popping and then pushing - */ - - cpu_count = abstraction_cpu_count(); - - thread_handles = (thread_state_t *) malloc( sizeof(thread_state_t) * cpu_count ); - - fb = (struct lfds611_freelist_benchmark *) malloc( sizeof(struct lfds611_freelist_benchmark) * cpu_count ); - - // TRD : print the benchmark ID and CSV header - printf( "\n" - "Release %s Freelist Benchmark #1\n" - "CPUs,total ops,mean ops/sec per CPU,standard deviation,scalability\n", LFDS611_RELEASE_NUMBER_STRING ); - - // TRD : we run CPU count times for scalability - for( thread_count = 1 ; thread_count <= cpu_count ; thread_count++ ) { - // TRD : initialisation - lfds611_freelist_new( &fs, 1000, NULL, NULL ); - - for( loop = 0 ; loop < cpu_count ; loop++ ) { - (fb+loop)->fs = fs; - (fb+loop)->operation_count = 0; - } - - // TRD : main test - for( loop = 0 ; loop < thread_count ; loop++ ) - abstraction_thread_start( &thread_handles[loop], loop, benchmark_lfds611_freelist_thread_pop_and_push, fb+loop ); - - for( loop = 0 ; loop < thread_count ; loop++ ) - abstraction_thread_wait( thread_handles[loop] ); - - // TRD : post test math - total_operations_for_full_test_for_all_cpus = 0; - total_difference_per_second_per_cpu = 0; - - for( loop = 0 ; loop < thread_count ; loop++ ) - total_operations_for_full_test_for_all_cpus += (fb+loop)->operation_count; - - mean_operations_per_second_per_cpu = ((double) total_operations_for_full_test_for_all_cpus / (double) thread_count) / (double) 10; - - if( thread_count == 1 ) - total_operations_for_full_test_for_all_cpus_for_one_cpu = total_operations_for_full_test_for_all_cpus; - - for( loop = 0 ; loop < thread_count ; loop++ ) { - difference_per_second_per_cpu = ((double) (fb+loop)->operation_count / (double) 10) - mean_operations_per_second_per_cpu; - total_difference_per_second_per_cpu += difference_per_second_per_cpu * difference_per_second_per_cpu; - } - - std_dev_per_second_per_cpu = sqrt( (double) total_difference_per_second_per_cpu ); - - scalability = (double) total_operations_for_full_test_for_all_cpus / (double) (total_operations_for_full_test_for_all_cpus_for_one_cpu * thread_count); - - printf( "%u,%u,%.0f,%.0f,%0.2f\n", thread_count, (unsigned int) total_operations_for_full_test_for_all_cpus, mean_operations_per_second_per_cpu, std_dev_per_second_per_cpu, scalability ); - - // TRD : cleanup - lfds611_freelist_delete( fs, NULL, NULL ); - } - - free( fb ); - - free( thread_handles ); - - return; -} - - - - - -/****************************************************************************/ -thread_return_t CALLING_CONVENTION benchmark_lfds611_freelist_thread_pop_and_push( void *freelist_benchmark ) -{ - struct lfds611_freelist_benchmark - *fb; - - struct lfds611_freelist_element - *fe; - - time_t - start_time; - - assert( freelist_benchmark != NULL ); - - fb = (struct lfds611_freelist_benchmark *) freelist_benchmark; - - time( &start_time ); - - while( time(NULL) < start_time + 10 ) { - lfds611_freelist_pop( fb->fs, &fe ); - lfds611_freelist_push( fb->fs, fe ); - - fb->operation_count += 2; - } - - return( (thread_return_t) EXIT_SUCCESS ); -} - diff --git a/openair2/UTIL/LFDS/liblfds6.1.1/test/src/benchmark_queue.c b/openair2/UTIL/LFDS/liblfds6.1.1/test/src/benchmark_queue.c deleted file mode 100644 index 70ab8e06e5..0000000000 --- a/openair2/UTIL/LFDS/liblfds6.1.1/test/src/benchmark_queue.c +++ /dev/null @@ -1,138 +0,0 @@ -#include "internal.h" - - - - - -/****************************************************************************/ -void benchmark_lfds611_queue( void ) -{ - unsigned int - loop, - thread_count, - cpu_count; - - struct lfds611_queue_state - *qs; - - struct lfds611_queue_benchmark - *qb; - - thread_state_t - *thread_handles; - - lfds611_atom_t - total_operations_for_full_test_for_all_cpus, - total_operations_for_full_test_for_all_cpus_for_one_cpu = 0; - - double - mean_operations_per_second_per_cpu, - difference_per_second_per_cpu, - total_difference_per_second_per_cpu, - std_dev_per_second_per_cpu, - scalability; - - /* TRD : here we benchmark the queue - - the benchmark is to have a single queue - where a worker thread busy-works dequeuing and then queuing - */ - - cpu_count = abstraction_cpu_count(); - - thread_handles = (thread_state_t *) malloc( sizeof(thread_state_t) * cpu_count ); - - qb = (struct lfds611_queue_benchmark *) malloc( sizeof(struct lfds611_queue_benchmark) * cpu_count ); - - // TRD : print the benchmark ID and CSV header - printf( "\n" - "Release %s Queue Benchmark #1\n" - "CPUs,total ops,mean ops/sec per CPU,standard deviation,scalability\n", LFDS611_RELEASE_NUMBER_STRING ); - - // TRD : we run CPU count times for scalability - for( thread_count = 1 ; thread_count <= cpu_count ; thread_count++ ) { - // TRD : initialisation - lfds611_queue_new( &qs, 1000 ); - - for( loop = 0 ; loop < cpu_count ; loop++ ) { - (qb+loop)->qs = qs; - (qb+loop)->operation_count = 0; - } - - // TRD : populate the queue (we don't actually use the user data) - for( loop = 0 ; loop < 500 ; loop++ ) - lfds611_queue_enqueue( qs, (void *) (lfds611_atom_t) loop ); - - // TRD : main test - for( loop = 0 ; loop < thread_count ; loop++ ) - abstraction_thread_start( &thread_handles[loop], loop, benchmark_lfds611_queue_thread_delfds611_queue_and_enqueue, qb+loop ); - - for( loop = 0 ; loop < thread_count ; loop++ ) - abstraction_thread_wait( thread_handles[loop] ); - - // TRD : post test math - total_operations_for_full_test_for_all_cpus = 0; - total_difference_per_second_per_cpu = 0; - - for( loop = 0 ; loop < thread_count ; loop++ ) - total_operations_for_full_test_for_all_cpus += (qb+loop)->operation_count; - - mean_operations_per_second_per_cpu = ((double) total_operations_for_full_test_for_all_cpus / (double) thread_count) / (double) 10; - - if( thread_count == 1 ) - total_operations_for_full_test_for_all_cpus_for_one_cpu = total_operations_for_full_test_for_all_cpus; - - for( loop = 0 ; loop < thread_count ; loop++ ) { - difference_per_second_per_cpu = ((double) (qb+loop)->operation_count / (double) 10) - mean_operations_per_second_per_cpu; - total_difference_per_second_per_cpu += difference_per_second_per_cpu * difference_per_second_per_cpu; - } - - std_dev_per_second_per_cpu = sqrt( (double) total_difference_per_second_per_cpu ); - - scalability = (double) total_operations_for_full_test_for_all_cpus / (double) (total_operations_for_full_test_for_all_cpus_for_one_cpu * thread_count); - - printf( "%u,%u,%.0f,%.0f,%0.2f\n", thread_count, (unsigned int) total_operations_for_full_test_for_all_cpus, mean_operations_per_second_per_cpu, std_dev_per_second_per_cpu, scalability ); - - // TRD : cleanup - lfds611_queue_delete( qs, NULL, NULL ); - } - - free( qb ); - - free( thread_handles ); - - return; -} - - - - - -/****************************************************************************/ -thread_return_t CALLING_CONVENTION benchmark_lfds611_queue_thread_delfds611_queue_and_enqueue( void *queue_benchmark ) -{ - struct lfds611_queue_benchmark - *qb; - - void - *user_data; - - time_t - start_time; - - assert( queue_benchmark != NULL ); - - qb = (struct lfds611_queue_benchmark *) queue_benchmark; - - time( &start_time ); - - while( time(NULL) < start_time + 10 ) { - lfds611_queue_dequeue( qb->qs, &user_data ); - lfds611_queue_enqueue( qb->qs, user_data ); - - qb->operation_count += 2; - } - - return( (thread_return_t) EXIT_SUCCESS ); -} - diff --git a/openair2/UTIL/LFDS/liblfds6.1.1/test/src/benchmark_ringbuffer.c b/openair2/UTIL/LFDS/liblfds6.1.1/test/src/benchmark_ringbuffer.c deleted file mode 100644 index 1322b4e0ce..0000000000 --- a/openair2/UTIL/LFDS/liblfds6.1.1/test/src/benchmark_ringbuffer.c +++ /dev/null @@ -1,137 +0,0 @@ -#include "internal.h" - - - - - -/****************************************************************************/ -void benchmark_lfds611_ringbuffer( void ) -{ - unsigned int - loop, - thread_count, - cpu_count; - - struct lfds611_ringbuffer_state - *rs; - - struct lfds611_ringbuffer_benchmark - *rb; - - thread_state_t - *thread_handles; - - lfds611_atom_t - total_operations_for_full_test_for_all_cpus, - total_operations_for_full_test_for_all_cpus_for_one_cpu = 0; - - double - mean_operations_per_second_per_cpu, - difference_per_second_per_cpu, - total_difference_per_second_per_cpu, - std_dev_per_second_per_cpu, - scalability; - - /* TRD : here we benchmark the ringbuffer - - the benchmark is to have a single ringbuffer - where a worker thread busy-works writing and then reading - */ - - cpu_count = abstraction_cpu_count(); - - thread_handles = (thread_state_t *) malloc( sizeof(thread_state_t) * cpu_count ); - - rb = (struct lfds611_ringbuffer_benchmark *) malloc( sizeof(struct lfds611_ringbuffer_benchmark) * cpu_count ); - - // TRD : print the benchmark ID and CSV header - printf( "\n" - "Release %s Ringbuffer Benchmark #1\n" - "CPUs,total ops,mean ops/sec per CPU,standard deviation,scalability\n", LFDS611_RELEASE_NUMBER_STRING ); - - // TRD : we run CPU count times for scalability - for( thread_count = 1 ; thread_count <= cpu_count ; thread_count++ ) { - // TRD : initialisation - lfds611_ringbuffer_new( &rs, 1000, NULL, NULL ); - - for( loop = 0 ; loop < cpu_count ; loop++ ) { - (rb+loop)->rs = rs; - (rb+loop)->operation_count = 0; - } - - // TRD : main test - for( loop = 0 ; loop < thread_count ; loop++ ) - abstraction_thread_start( &thread_handles[loop], loop, benchmark_lfds611_ringbuffer_thread_write_and_read, rb+loop ); - - for( loop = 0 ; loop < thread_count ; loop++ ) - abstraction_thread_wait( thread_handles[loop] ); - - // TRD : post test math - total_operations_for_full_test_for_all_cpus = 0; - total_difference_per_second_per_cpu = 0; - - for( loop = 0 ; loop < thread_count ; loop++ ) - total_operations_for_full_test_for_all_cpus += (rb+loop)->operation_count; - - mean_operations_per_second_per_cpu = ((double) total_operations_for_full_test_for_all_cpus / (double) thread_count) / (double) 10; - - if( thread_count == 1 ) - total_operations_for_full_test_for_all_cpus_for_one_cpu = total_operations_for_full_test_for_all_cpus; - - for( loop = 0 ; loop < thread_count ; loop++ ) { - difference_per_second_per_cpu = ((double) (rb+loop)->operation_count / (double) 10) - mean_operations_per_second_per_cpu; - total_difference_per_second_per_cpu += difference_per_second_per_cpu * difference_per_second_per_cpu; - } - - std_dev_per_second_per_cpu = sqrt( (double) total_difference_per_second_per_cpu ); - - scalability = (double) total_operations_for_full_test_for_all_cpus / (double) (total_operations_for_full_test_for_all_cpus_for_one_cpu * thread_count); - - printf( "%u,%u,%.0f,%.0f,%0.2f\n", thread_count, (unsigned int) total_operations_for_full_test_for_all_cpus, mean_operations_per_second_per_cpu, std_dev_per_second_per_cpu, scalability ); - - // TRD : cleanup - lfds611_ringbuffer_delete( rs, NULL, NULL ); - } - - free( rb ); - - free( thread_handles ); - - return; -} - - - - - -/****************************************************************************/ -thread_return_t CALLING_CONVENTION benchmark_lfds611_ringbuffer_thread_write_and_read( void *ringbuffer_benchmark ) -{ - struct lfds611_ringbuffer_benchmark - *rb; - - struct lfds611_freelist_element - *fe; - - time_t - start_time; - - assert( ringbuffer_benchmark != NULL ); - - rb = (struct lfds611_ringbuffer_benchmark *) ringbuffer_benchmark; - - time( &start_time ); - - while( time(NULL) < start_time + 10 ) { - lfds611_ringbuffer_get_write_element( rb->rs, &fe, NULL ); - lfds611_ringbuffer_put_write_element( rb->rs, fe ); - - lfds611_ringbuffer_get_read_element( rb->rs, &fe ); - lfds611_ringbuffer_put_read_element( rb->rs, fe ); - - rb->operation_count += 2; - } - - return( (thread_return_t) EXIT_SUCCESS ); -} - diff --git a/openair2/UTIL/LFDS/liblfds6.1.1/test/src/benchmark_stack.c b/openair2/UTIL/LFDS/liblfds6.1.1/test/src/benchmark_stack.c deleted file mode 100644 index 0a9f6c8698..0000000000 --- a/openair2/UTIL/LFDS/liblfds6.1.1/test/src/benchmark_stack.c +++ /dev/null @@ -1,134 +0,0 @@ -#include "internal.h" - - - - - -/****************************************************************************/ -void benchmark_lfds611_stack( void ) -{ - unsigned int - loop, - thread_count, - cpu_count; - - struct lfds611_stack_state - *ss; - - struct lfds611_stack_benchmark - *sb; - - thread_state_t - *thread_handles; - - lfds611_atom_t - total_operations_for_full_test_for_all_cpus, - total_operations_for_full_test_for_all_cpus_for_one_cpu = 0; - - double - mean_operations_per_second_per_cpu, - difference_per_second_per_cpu, - total_difference_per_second_per_cpu, - std_dev_per_second_per_cpu, - scalability; - - /* TRD : here we benchmark the stack - - the benchmark is to have a single stack - where a worker thread busy-works pushing then popping - */ - - cpu_count = abstraction_cpu_count(); - - thread_handles = (thread_state_t *) malloc( sizeof(thread_state_t) * cpu_count ); - - sb = (struct lfds611_stack_benchmark *) malloc( sizeof(struct lfds611_stack_benchmark) * cpu_count ); - - // TRD : print the benchmark ID and CSV header - printf( "\n" - "Release %s Stack Benchmark #1\n" - "CPUs,total ops,mean ops/sec per CPU,standard deviation,scalability\n", LFDS611_RELEASE_NUMBER_STRING ); - - // TRD : we run CPU count times for scalability - for( thread_count = 1 ; thread_count <= cpu_count ; thread_count++ ) { - // TRD : initialisation - lfds611_stack_new( &ss, 1000 ); - - for( loop = 0 ; loop < cpu_count ; loop++ ) { - (sb+loop)->ss = ss; - (sb+loop)->operation_count = 0; - } - - // TRD : main test - for( loop = 0 ; loop < thread_count ; loop++ ) - abstraction_thread_start( &thread_handles[loop], loop, benchmark_lfds611_stack_thread_push_and_pop, sb+loop ); - - for( loop = 0 ; loop < thread_count ; loop++ ) - abstraction_thread_wait( thread_handles[loop] ); - - // TRD : post test math - total_operations_for_full_test_for_all_cpus = 0; - total_difference_per_second_per_cpu = 0; - - for( loop = 0 ; loop < thread_count ; loop++ ) - total_operations_for_full_test_for_all_cpus += (sb+loop)->operation_count; - - mean_operations_per_second_per_cpu = ((double) total_operations_for_full_test_for_all_cpus / (double) thread_count) / (double) 10; - - if( thread_count == 1 ) - total_operations_for_full_test_for_all_cpus_for_one_cpu = total_operations_for_full_test_for_all_cpus; - - for( loop = 0 ; loop < thread_count ; loop++ ) { - difference_per_second_per_cpu = ((double) (sb+loop)->operation_count / (double) 10) - mean_operations_per_second_per_cpu; - total_difference_per_second_per_cpu += difference_per_second_per_cpu * difference_per_second_per_cpu; - } - - std_dev_per_second_per_cpu = sqrt( (double) total_difference_per_second_per_cpu ); - - scalability = (double) total_operations_for_full_test_for_all_cpus / (double) (total_operations_for_full_test_for_all_cpus_for_one_cpu * thread_count); - - printf( "%u,%u,%.0f,%.0f,%0.2f\n", thread_count, (unsigned int) total_operations_for_full_test_for_all_cpus, mean_operations_per_second_per_cpu, std_dev_per_second_per_cpu, scalability ); - - // TRD : cleanup - lfds611_stack_delete( ss, NULL, NULL ); - } - - free( sb ); - - free( thread_handles ); - - return; -} - - - - - -/****************************************************************************/ -thread_return_t CALLING_CONVENTION benchmark_lfds611_stack_thread_push_and_pop( void *stack_benchmark ) -{ - struct lfds611_stack_benchmark - *sb; - - void - *user_data = NULL; - - time_t - start_time; - - assert( stack_benchmark != NULL ); - - sb = (struct lfds611_stack_benchmark *) stack_benchmark; - - time( &start_time ); - - while( time(NULL) < start_time + 10 ) { - lfds611_stack_push( sb->ss, user_data ); - lfds611_stack_pop( sb->ss, &user_data ); - - sb->operation_count += 2; - } - - return( (thread_return_t) EXIT_SUCCESS ); -} - diff --git a/openair2/UTIL/LFDS/liblfds6.1.1/test/src/internal.h b/openair2/UTIL/LFDS/liblfds6.1.1/test/src/internal.h deleted file mode 100644 index ae30bf142c..0000000000 --- a/openair2/UTIL/LFDS/liblfds6.1.1/test/src/internal.h +++ /dev/null @@ -1,123 +0,0 @@ -/***** ANSI includes *****/ -/* TRD : _GNU_SOURCE is required by sched.h for pthread_attr_setaffinity_np, CPU_ZERO and CPU_SET - however it has to be defined very early as even the ANSI headers pull in stuff - which uses _GNU_SOURCE and which I think must be protected against multiple inclusion, - which basically means if you set it too late, it's not seen, because the headers - have already been parsed with _GNU_SOURCE unset -*/ - -#define _GNU_SOURCE - -#include -#include -#include -#include -#include -#include -#include - -/***** internal includes *****/ -#include "abstraction.h" - -/***** external includes *****/ -#include "liblfds611.h" - -/***** defines *****/ -#define and && -#define or || - -#define RAISED 1 -#define LOWERED 0 - -#define NO_FLAGS 0x0 - -/***** enums *****/ -enum lfds611_test_operation { - UNKNOWN, - HELP, - TEST, - BENCHMARK -}; - -/***** structs *****/ -#include "structures.h" - -/***** prototypes *****/ -int main( int argc, char **argv ); - -void internal_display_test_name( char *test_name ); -void internal_display_test_result( unsigned int number_name_dvs_pairs, ... ); -void internal_display_lfds611_data_structure_validity( enum lfds611_data_structure_validity dvs ); - -void benchmark_lfds611_freelist( void ); -thread_return_t CALLING_CONVENTION benchmark_lfds611_freelist_thread_pop_and_push( void *freelist_benchmark ); - -void benchmark_lfds611_queue( void ); -thread_return_t CALLING_CONVENTION benchmark_lfds611_queue_thread_delfds611_queue_and_enqueue( void *queue_benchmark ); - -void benchmark_lfds611_ringbuffer( void ); -thread_return_t CALLING_CONVENTION benchmark_lfds611_ringbuffer_thread_write_and_read( void *ringbuffer_benchmark ); - -void benchmark_lfds611_stack( void ); -thread_return_t CALLING_CONVENTION benchmark_lfds611_stack_thread_push_and_pop( void *stack_benchmark ); - -void test_lfds611_abstraction( void ); -void abstraction_test_increment( void ); -thread_return_t CALLING_CONVENTION abstraction_test_internal_thread_increment( void *shared_counter ); -thread_return_t CALLING_CONVENTION abstraction_test_internal_thread_atomic_increment( void *shared_counter ); -void abstraction_test_cas( void ); -thread_return_t CALLING_CONVENTION abstraction_test_internal_thread_cas( void *abstraction_test_cas_state ); -void abstraction_test_dcas( void ); -thread_return_t CALLING_CONVENTION abstraction_test_internal_thread_dcas( void *abstraction_test_dcas_state ); - -void test_lfds611_freelist( void ); -void freelist_test_internal_popping( void ); -int freelist_test_internal_popping_init( void **user_data, void *user_state ); -thread_return_t CALLING_CONVENTION freelist_test_internal_thread_popping( void *freelist_test_popping_state ); -void freelist_test_internal_pushing( void ); -int freelist_test_internal_pushing_init( void **user_data, void *user_state ); -void freelist_test_internal_pushing_delete( void *user_data, void *user_state ); -thread_return_t CALLING_CONVENTION freelist_test_internal_thread_pushing( void *freelist_test_pushing_state ); -void freelist_test_internal_popping_and_pushing( void ); -thread_return_t CALLING_CONVENTION freelist_test_internal_thread_popping_and_pushing_start_popping( void *freelist_test_popping_and_pushing_state ); -thread_return_t CALLING_CONVENTION freelist_test_internal_thread_popping_and_pushing_start_pushing( void *freelist_test_popping_and_pushing_state ); -void freelist_test_internal_rapid_popping_and_pushing( void ); -thread_return_t CALLING_CONVENTION freelist_test_internal_thread_rapid_popping_and_pushing( void *lfds611_freelist_state ); - -void test_lfds611_queue( void ); -void queue_test_enqueuing( void ); -thread_return_t CALLING_CONVENTION queue_test_internal_thread_simple_enqueuer( void *queue_test_enqueuing_state ); -void queue_test_dequeuing( void ); -thread_return_t CALLING_CONVENTION queue_test_internal_thread_simple_dequeuer( void *queue_test_dequeuing_state ); -void queue_test_enqueuing_and_dequeuing( void ); -thread_return_t CALLING_CONVENTION queue_test_internal_thread_enqueuer_and_dequeuer( void *queue_test_rapid_enqueuing_and_dequeuing_state ); -void queue_test_rapid_enqueuing_and_dequeuing( void ); -thread_return_t CALLING_CONVENTION queue_test_internal_thread_rapid_enqueuer_and_dequeuer( void *queue_test_rapid_enqueuing_and_dequeuing_state ); - -void test_lfds611_ringbuffer( void ); -void ringbuffer_test_reading( void ); -thread_return_t CALLING_CONVENTION ringbuffer_test_thread_simple_reader( void *ringbuffer_test_reading_state ); -void ringbuffer_test_writing( void ); -thread_return_t CALLING_CONVENTION ringbuffer_test_thread_simple_writer( void *ringbuffer_test_writing_state ); -void ringbuffer_test_reading_and_writing( void ); -thread_return_t CALLING_CONVENTION ringbuffer_test_thread_reader_writer( void *ringbuffer_test_reading_and_writing_state ); - -void test_lfds611_slist( void ); -void test_slist_new_delete_get( void ); -thread_return_t CALLING_CONVENTION slist_test_internal_thread_new_delete_get_new_head_and_next( void *slist_test_state ); -thread_return_t CALLING_CONVENTION slist_test_internal_thread_new_delete_get_delete_and_get( void *slist_test_state ); -void test_slist_get_set_user_data( void ); -thread_return_t CALLING_CONVENTION slist_test_internal_thread_get_set_user_data( void *slist_test_state ); -void test_slist_delete_all_elements( void ); - -void test_lfds611_stack( void ); -void stack_test_internal_popping( void ); -thread_return_t CALLING_CONVENTION stack_test_internal_thread_popping( void *stack_test_popping_state ); -void stack_test_internal_pushing( void ); -thread_return_t CALLING_CONVENTION stack_test_internal_thread_pushing( void *stack_test_pushing_state ); -void stack_test_internal_popping_and_pushing( void ); -thread_return_t CALLING_CONVENTION stack_test_internal_thread_popping_and_pushing_start_popping( void *stack_test_popping_and_pushing_state ); -thread_return_t CALLING_CONVENTION stack_test_internal_thread_popping_and_pushing_start_pushing( void *stack_test_popping_and_pushing_state ); -void stack_test_internal_rapid_popping_and_pushing( void ); -thread_return_t CALLING_CONVENTION stack_test_internal_thread_rapid_popping_and_pushing( void *stack_state ); - diff --git a/openair2/UTIL/LFDS/liblfds6.1.1/test/src/main.c b/openair2/UTIL/LFDS/liblfds6.1.1/test/src/main.c deleted file mode 100644 index 66836ba441..0000000000 --- a/openair2/UTIL/LFDS/liblfds6.1.1/test/src/main.c +++ /dev/null @@ -1,83 +0,0 @@ -#include "internal.h" - - - - - -/****************************************************************************/ -int main( int argc, char **argv ) -{ - enum lfds611_test_operation - operation = UNKNOWN; - - unsigned int - loop, - iterations = 1; - - assert( argc >= 1 ); - assert( argv != NULL ); - - if( argc == 1 or argc >= 4 ) - operation = HELP; - - if( operation == UNKNOWN ) { - if( 0 == strcmp(*(argv+1), "test") ) { - operation = TEST; - - // TRD : sscanf() may fail, but iterations is initialised to 1, so it's okay - if( argc == 3 ) - sscanf( *(argv+2), "%u", &iterations ); - } - - if( 0 == strcmp(*(argv+1), "benchmark") ) { - operation = BENCHMARK; - - // TRD : sscanf() may fail, but iterations is initialised to 1, so it's okay - if( argc == 3 ) - sscanf( *(argv+2), "%u", &iterations ); - } - } - - switch( operation ) { - case UNKNOWN: - case HELP: - printf( "test [test|benchmark] [iterations]\n" - " test : run the test suite\n" - " benchmark : run the benchmark suite\n" - " iterations : optional, default is 1\n" ); - break; - - case TEST: - for( loop = 1 ; loop < iterations+1 ; loop++ ) { - printf( "\n" - "Test Iteration %02u\n" - "=================\n", loop ); - - test_lfds611_abstraction(); - test_lfds611_freelist(); - test_lfds611_queue(); - test_lfds611_ringbuffer(); - test_lfds611_slist(); - test_lfds611_stack(); - } - - break; - - case BENCHMARK: - for( loop = 1 ; loop < iterations+1 ; loop++ ) { - printf( "\n" - "Benchmark Iteration %02u\n" - "========================\n", loop ); - - benchmark_lfds611_freelist(); - benchmark_lfds611_queue(); - benchmark_lfds611_ringbuffer(); - benchmark_lfds611_stack(); - } - - break; - } - - return( EXIT_SUCCESS ); -} - diff --git a/openair2/UTIL/LFDS/liblfds6.1.1/test/src/misc.c b/openair2/UTIL/LFDS/liblfds6.1.1/test/src/misc.c deleted file mode 100644 index 9b5891832f..0000000000 --- a/openair2/UTIL/LFDS/liblfds6.1.1/test/src/misc.c +++ /dev/null @@ -1,119 +0,0 @@ -#include "internal.h" - - - - - -/****************************************************************************/ -void internal_display_test_name( char *test_name ) -{ - assert( test_name != NULL ); - - printf( "%s...", test_name ); - fflush( stdout ); - - return; -} - - - - - -/****************************************************************************/ -void internal_display_test_result( unsigned int number_name_dvs_pairs, ... ) -{ - va_list - va; - - int - passed_flag = RAISED; - - unsigned int - loop; - - char - *name; - - enum lfds611_data_structure_validity - dvs; - - // TRD : number_name_dvs_pairs can be any value in its range - - va_start( va, number_name_dvs_pairs ); - - for( loop = 0 ; loop < number_name_dvs_pairs ; loop++ ) { - name = va_arg( va, char * ); - dvs = va_arg( va, enum lfds611_data_structure_validity ); - - if( dvs != LFDS611_VALIDITY_VALID ) { - passed_flag = LOWERED; - break; - } - } - - va_end( va ); - - if( passed_flag == RAISED ) - puts( "passed" ); - - if( passed_flag == LOWERED ) { - printf( "failed (" ); - - va_start( va, number_name_dvs_pairs ); - - for( loop = 0 ; loop < number_name_dvs_pairs ; loop++ ) { - name = va_arg( va, char * ); - dvs = va_arg( va, enum lfds611_data_structure_validity ); - - printf( "%s ", name ); - internal_display_lfds611_data_structure_validity( dvs ); - - if( loop+1 < number_name_dvs_pairs ) - printf( ", " ); - } - - va_end( va ); - - printf( ")\n" ); - } - - return; -} - - - - - -/****************************************************************************/ -void internal_display_lfds611_data_structure_validity( enum lfds611_data_structure_validity dvs ) -{ - char - *string = NULL; - - switch( dvs ) { - case LFDS611_VALIDITY_VALID: - string = "valid"; - break; - - case LFDS611_VALIDITY_INVALID_LOOP: - string = "invalid - loop detected"; - break; - - case LFDS611_VALIDITY_INVALID_MISSING_ELEMENTS: - string = "invalid - missing elements"; - break; - - case LFDS611_VALIDITY_INVALID_ADDITIONAL_ELEMENTS: - string = "invalid - additional elements"; - break; - - case LFDS611_VALIDITY_INVALID_TEST_DATA: - string = "invalid - invalid test data"; - break; - } - - printf( "%s", string ); - - return; -} - diff --git a/openair2/UTIL/LFDS/liblfds6.1.1/test/src/structures.h b/openair2/UTIL/LFDS/liblfds6.1.1/test/src/structures.h deleted file mode 100644 index 36d01536b5..0000000000 --- a/openair2/UTIL/LFDS/liblfds6.1.1/test/src/structures.h +++ /dev/null @@ -1,205 +0,0 @@ -/***** structs *****/ -#pragma pack( push, LFDS611_ALIGN_DOUBLE_POINTER ) - -/***** abstraction tests *****/ -struct abstraction_test_cas_state { - volatile lfds611_atom_t - *shared_counter; - - lfds611_atom_t - local_counter; -}; - -struct abstraction_test_dcas_state { - volatile lfds611_atom_t - *shared_counter; - - lfds611_atom_t - local_counter; -}; - -/***** freelist tests *****/ -struct freelist_test_popping_state { - struct lfds611_freelist_state - *fs, - *fs_thread_local; -}; - -struct freelist_test_pushing_state { - lfds611_atom_t - *count, - thread_number; - - struct lfds611_freelist_state - *source_fs, - *fs; -}; - -struct freelist_test_popping_and_pushing_state { - struct lfds611_freelist_state - *local_fs, - *fs; -}; - -struct freelist_test_counter_and_thread_number { - lfds611_atom_t - thread_number; - - unsigned long long int - counter; -}; - -/***** queue tests *****/ -struct queue_test_enqueuing_state { - struct lfds611_queue_state - *qs; - - lfds611_atom_t - counter; -}; - -struct queue_test_dequeuing_state { - struct lfds611_queue_state - *qs; - - int - error_flag; -}; - -struct queue_test_enqueuing_and_dequeuing_state { - struct lfds611_queue_state - *qs; - - lfds611_atom_t - counter, - thread_number, - *per_thread_counters; - - unsigned int - cpu_count; - - int - error_flag; -}; - -struct queue_test_rapid_enqueuing_and_dequeuing_state { - struct lfds611_queue_state - *qs; - - lfds611_atom_t - counter; -}; - -/***** ringbuffer tests *****/ -struct ringbuffer_test_reading_state { - struct lfds611_ringbuffer_state - *rs; - - int - error_flag; - - lfds611_atom_t - read_count; -}; - -struct ringbuffer_test_writing_state { - struct lfds611_ringbuffer_state - *rs; - - lfds611_atom_t - write_count; -}; - -struct ringbuffer_test_reading_and_writing_state { - struct lfds611_ringbuffer_state - *rs; - - lfds611_atom_t - counter, - *per_thread_counters; - - unsigned int - cpu_count; - - int - error_flag; -}; - -/***** slist tests *****/ -struct slist_test_state { - struct lfds611_slist_state - *ss; - - size_t - create_count, - delete_count; - - lfds611_atom_t - thread_and_count; -}; - -/***** stack tests *****/ -struct stack_test_popping_state { - struct lfds611_stack_state - *ss, - *ss_thread_local; -}; - -struct stack_test_pushing_state { - lfds611_atom_t - thread_number; - - struct lfds611_stack_state - *ss; -}; - -struct stack_test_popping_and_pushing_state { - struct lfds611_stack_state - *local_ss, - *ss; -}; - -struct stack_test_counter_and_thread_number { - lfds611_atom_t - thread_number, - counter; -}; - -/***** freelist benchmarks *****/ -struct lfds611_freelist_benchmark { - struct lfds611_freelist_state - *fs; - - lfds611_atom_t - operation_count; -}; - -/***** queue benchmarks *****/ -struct lfds611_queue_benchmark { - struct lfds611_queue_state - *qs; - - lfds611_atom_t - operation_count; -}; - -/***** ringbuffer benchmarks *****/ -struct lfds611_ringbuffer_benchmark { - struct lfds611_ringbuffer_state - *rs; - - lfds611_atom_t - operation_count; -}; - -/***** stack benchmarks *****/ -struct lfds611_stack_benchmark { - struct lfds611_stack_state - *ss; - - lfds611_atom_t - operation_count; -}; - -#pragma pack( pop ) - diff --git a/openair2/UTIL/LFDS/liblfds6.1.1/test/src/test_abstraction.c b/openair2/UTIL/LFDS/liblfds6.1.1/test/src/test_abstraction.c deleted file mode 100644 index 772fbf5ca3..0000000000 --- a/openair2/UTIL/LFDS/liblfds6.1.1/test/src/test_abstraction.c +++ /dev/null @@ -1,323 +0,0 @@ -#include "internal.h" - - - - - -/****************************************************************************/ -void test_lfds611_abstraction( void ) -{ - printf( "\n" - "Abstraction Tests\n" - "=================\n" ); - - abstraction_test_increment(); - abstraction_test_cas(); - abstraction_test_dcas(); - - return; -} - - - - - -/****************************************************************************/ -void abstraction_test_increment( void ) -{ - unsigned int - loop, - cpu_count; - - thread_state_t - *thread_handles; - - LFDS611_ALIGN(LFDS611_ALIGN_SINGLE_POINTER) volatile lfds611_atom_t - shared_counter, - atomic_shared_counter; - - /* TRD : here we test lfds611_abstraction_increment - - first, we run one thread per CPU where each thread increments - a shared counter 10,000,000 times - however, this first test - does NOT use atomic increment; it uses "++" - - second, we repeat the exercise, but this time using - lfds611_abstraction_increment() - - if the final value in the first test is less than (10,000,000*cpu_count) - then the system is sensitive to non-atomic increments; this means if - our atomic version of the test passes, we can have some degree of confidence - that it works - - if the final value in the first test is in fact correct, then we can't know - that our atomic version has changed anything - - and of course if the final value in the atomic test is wrong, we know things - are broken - */ - - internal_display_test_name( "Atomic increment" ); - - cpu_count = abstraction_cpu_count(); - - shared_counter = 0; - atomic_shared_counter = 0; - - LFDS611_BARRIER_STORE; - - thread_handles = malloc( sizeof(thread_state_t) * cpu_count ); - - // TRD : non-atomic - for( loop = 0 ; loop < cpu_count ; loop++ ) - abstraction_thread_start( &thread_handles[loop], loop, abstraction_test_internal_thread_increment, (void *) &shared_counter ); - - for( loop = 0 ; loop < cpu_count ; loop++ ) - abstraction_thread_wait( thread_handles[loop] ); - - // TRD : atomic - for( loop = 0 ; loop < cpu_count ; loop++ ) - abstraction_thread_start( &thread_handles[loop], loop, abstraction_test_internal_thread_atomic_increment, (void *) &atomic_shared_counter ); - - for( loop = 0 ; loop < cpu_count ; loop++ ) - abstraction_thread_wait( thread_handles[loop] ); - - free( thread_handles ); - - // TRD : results - if( shared_counter < (10000000 * cpu_count) and atomic_shared_counter == (10000000 * cpu_count) ) - puts( "passed" ); - - if( shared_counter == (10000000 * cpu_count) and atomic_shared_counter == (10000000 * cpu_count) ) - puts( "indeterminate" ); - - if( atomic_shared_counter < (10000000 * cpu_count) ) - puts( "failed" ); - - return; -} - - - - - -/****************************************************************************/ -thread_return_t CALLING_CONVENTION abstraction_test_internal_thread_increment( void *shared_counter ) -{ - assert( shared_counter != NULL ); - - LFDS611_BARRIER_LOAD; - - lfds611_liblfds_abstraction_test_helper_increment_non_atomic( shared_counter ); - - return( (thread_return_t) EXIT_SUCCESS ); -} - - - - - -/****************************************************************************/ -thread_return_t CALLING_CONVENTION abstraction_test_internal_thread_atomic_increment( void *shared_counter ) -{ - assert( shared_counter != NULL ); - - LFDS611_BARRIER_LOAD; - - lfds611_liblfds_abstraction_test_helper_increment_atomic( shared_counter ); - - return( (thread_return_t) EXIT_SUCCESS ); -} - - - - - -/****************************************************************************/ -void abstraction_test_cas( void ) -{ - unsigned int - loop, - cpu_count; - - thread_state_t - *thread_handles; - - struct abstraction_test_cas_state - *atcs; - - LFDS611_ALIGN(LFDS611_ALIGN_SINGLE_POINTER) volatile lfds611_atom_t - shared_counter; - - lfds611_atom_t - local_total = 0; - - // TRD : number_logical_processors can be any value in its range - - /* TRD : here we test lfds611_abstraction_cas - - we run one thread per CPU - we use lfds611_abstraction_cas() to increment a shared counter - every time a thread successfully increments the counter, - it increments a thread local counter - the threads run for ten seconds - after the threads finish, we total the local counters - they should equal the shared counter - */ - - internal_display_test_name( "Atomic CAS" ); - - cpu_count = abstraction_cpu_count(); - - shared_counter = 0; - - LFDS611_BARRIER_STORE; - - atcs = malloc( sizeof(struct abstraction_test_cas_state) * cpu_count ); - - for( loop = 0 ; loop < cpu_count ; loop++ ) { - (atcs+loop)->shared_counter = &shared_counter; - (atcs+loop)->local_counter = 0; - } - - thread_handles = malloc( sizeof(thread_state_t) * cpu_count ); - - for( loop = 0 ; loop < cpu_count ; loop++ ) - abstraction_thread_start( &thread_handles[loop], loop, abstraction_test_internal_thread_cas, atcs+loop ); - - for( loop = 0 ; loop < cpu_count ; loop++ ) - abstraction_thread_wait( thread_handles[loop] ); - - free( thread_handles ); - - // TRD : results - for( loop = 0 ; loop < cpu_count ; loop++ ) - local_total += (atcs+loop)->local_counter; - - if( local_total == shared_counter ) - puts( "passed" ); - - if( local_total != shared_counter ) - puts( "failed" ); - - // TRD : cleanup - free( atcs ); - - return; -} - - - - - -/****************************************************************************/ -thread_return_t CALLING_CONVENTION abstraction_test_internal_thread_cas( void *abstraction_test_cas_state ) -{ - struct abstraction_test_cas_state - *atcs; - - assert( abstraction_test_cas_state != NULL ); - - atcs = (struct abstraction_test_cas_state *) abstraction_test_cas_state; - - LFDS611_BARRIER_LOAD; - - lfds611_liblfds_abstraction_test_helper_cas( atcs->shared_counter, &atcs->local_counter ); - - return( (thread_return_t) EXIT_SUCCESS ); -} - - - - - -/****************************************************************************/ -void abstraction_test_dcas( void ) -{ - unsigned int - loop, - cpu_count; - - thread_state_t - *thread_handles; - - struct abstraction_test_dcas_state - *atds; - - LFDS611_ALIGN(LFDS611_ALIGN_DOUBLE_POINTER) volatile lfds611_atom_t - shared_counter[2] = { 0, 0 }; - - lfds611_atom_t - local_total = 0; - - /* TRD : here we test lfds611_abstraction_dcas - - we run one thread per CPU - we use lfds611_abstraction_dcas() to increment a shared counter - every time a thread successfully increments the counter, - it increments a thread local counter - the threads run for ten seconds - after the threads finish, we total the local counters - they should equal the shared counter - */ - - internal_display_test_name( "Atomic DCAS" ); - - cpu_count = abstraction_cpu_count(); - - atds = malloc( sizeof(struct abstraction_test_dcas_state) * cpu_count ); - - for( loop = 0 ; loop < cpu_count ; loop++ ) { - (atds+loop)->shared_counter = shared_counter; - (atds+loop)->local_counter = 0; - } - - LFDS611_BARRIER_STORE; - - thread_handles = malloc( sizeof(thread_state_t) * cpu_count ); - - for( loop = 0 ; loop < cpu_count ; loop++ ) - abstraction_thread_start( &thread_handles[loop], loop, abstraction_test_internal_thread_dcas, atds+loop ); - - for( loop = 0 ; loop < cpu_count ; loop++ ) - abstraction_thread_wait( thread_handles[loop] ); - - free( thread_handles ); - - // TRD : results - for( loop = 0 ; loop < cpu_count ; loop++ ) - local_total += (atds+loop)->local_counter; - - if( local_total == shared_counter[0] ) - puts( "passed" ); - - if( local_total != shared_counter[0] ) - puts( "failed" ); - - // TRD : cleanup - free( atds ); - - return; -} - - - - - -/****************************************************************************/ -thread_return_t CALLING_CONVENTION abstraction_test_internal_thread_dcas( void *abstraction_test_dcas_state ) -{ - struct abstraction_test_dcas_state - *atds; - - assert( abstraction_test_dcas_state != NULL ); - - atds = (struct abstraction_test_dcas_state *) abstraction_test_dcas_state; - - LFDS611_BARRIER_LOAD; - - lfds611_liblfds_abstraction_test_helper_dcas( atds->shared_counter, &atds->local_counter ); - - return( (thread_return_t) EXIT_SUCCESS ); -} - diff --git a/openair2/UTIL/LFDS/liblfds6.1.1/test/src/test_freelist.c b/openair2/UTIL/LFDS/liblfds6.1.1/test/src/test_freelist.c deleted file mode 100644 index d915b815b0..0000000000 --- a/openair2/UTIL/LFDS/liblfds6.1.1/test/src/test_freelist.c +++ /dev/null @@ -1,673 +0,0 @@ -#include "internal.h" - - - - - -/****************************************************************************/ -void test_lfds611_freelist( void ) -{ - printf( "\n" - "Freelist Tests\n" - "==============\n" ); - - freelist_test_internal_popping(); - freelist_test_internal_pushing(); - freelist_test_internal_popping_and_pushing(); - freelist_test_internal_rapid_popping_and_pushing(); - - return; -} - - - - - -/****************************************************************************/ -void freelist_test_internal_popping( void ) -{ - unsigned int - loop, - cpu_count; - - lfds611_atom_t - count = 0; - - thread_state_t - *thread_handles; - - enum lfds611_data_structure_validity - dvs = LFDS611_VALIDITY_VALID; - - struct lfds611_freelist_state - *fs; - - struct lfds611_freelist_element - *fe; - - struct freelist_test_popping_state - *ftps; - - unsigned int - *found_count; - - /* TRD : we create a freelist with 1,000,000 elements - - the creation function runs in a single thread and creates - and pushes those elements onto the freelist - - each element contains a void pointer which is its element number - - we then run one thread per CPU - where each thread loops, popping as quickly as possible - each popped element is pushed onto a thread-local freelist - - the threads run till the source freelist is empty - - we then check the thread-local freelists - we should find we have every element - - then tidy up - */ - - internal_display_test_name( "Popping" ); - - cpu_count = abstraction_cpu_count(); - - lfds611_freelist_new( &fs, 1000000, freelist_test_internal_popping_init, &count ); - ftps = malloc( sizeof(struct freelist_test_popping_state) * cpu_count ); - - for( loop = 0 ; loop < cpu_count ; loop++ ) { - (ftps+loop)->fs = fs; - lfds611_freelist_new( &(ftps+loop)->fs_thread_local, 0, NULL, NULL ); - } - - thread_handles = malloc( sizeof(thread_state_t) * cpu_count ); - - for( loop = 0 ; loop < cpu_count ; loop++ ) - abstraction_thread_start( &thread_handles[loop], loop, freelist_test_internal_thread_popping, ftps+loop ); - - for( loop = 0 ; loop < cpu_count ; loop++ ) - abstraction_thread_wait( thread_handles[loop] ); - - free( thread_handles ); - - // TRD : now we check the thread-local freelists - found_count = malloc( sizeof(unsigned int) * 1000000 ); - - for( loop = 0 ; loop < 1000000 ; loop++ ) - *(found_count+loop) = 0; - - for( loop = 0 ; loop < cpu_count ; loop++ ) { - while( lfds611_freelist_pop((ftps+loop)->fs_thread_local, &fe) ) { - lfds611_freelist_get_user_data_from_element( fe, (void **) &count ); - (*(found_count+count))++; - lfds611_freelist_push( fs, fe ); - } - } - - for( loop = 0 ; loop < 1000000 and dvs == LFDS611_VALIDITY_VALID ; loop++ ) { - if( *(found_count+loop) == 0 ) - dvs = LFDS611_VALIDITY_INVALID_MISSING_ELEMENTS; - - if( *(found_count+loop) > 1 ) - dvs = LFDS611_VALIDITY_INVALID_ADDITIONAL_ELEMENTS; - } - - // TRD : cleanup - free( found_count ); - - for( loop = 0 ; loop < cpu_count ; loop++ ) - lfds611_freelist_delete( (ftps+loop)->fs_thread_local, NULL, NULL ); - - free( ftps ); - lfds611_freelist_delete( fs, NULL, NULL ); - - // TRD : print the test result - internal_display_test_result( 1, "freelist", dvs ); - - return; -} - - - - - -/****************************************************************************/ -#pragma warning( disable : 4100 ) - -int freelist_test_internal_popping_init( void **user_data, void *user_state ) -{ - lfds611_atom_t - *count; - - assert( user_data != NULL ); - assert( user_state != NULL ); - - count = (lfds611_atom_t *) user_state; - - *(lfds611_atom_t *) user_data = (*count)++; - - return( 1 ); -} - -#pragma warning( default : 4100 ) - - - - - -/****************************************************************************/ -thread_return_t CALLING_CONVENTION freelist_test_internal_thread_popping( void *freelist_test_popping_state ) -{ - struct freelist_test_popping_state - *ftps; - - struct lfds611_freelist_element - *fe; - - assert( freelist_test_popping_state != NULL ); - - ftps = (struct freelist_test_popping_state *) freelist_test_popping_state; - - lfds611_freelist_use( ftps->fs ); - lfds611_freelist_use( ftps->fs_thread_local ); - - while( lfds611_freelist_pop(ftps->fs, &fe) ) - lfds611_freelist_push( ftps->fs_thread_local, fe ); - - return( (thread_return_t) EXIT_SUCCESS ); -} - - - - - -/****************************************************************************/ -void freelist_test_internal_pushing( void ) -{ - unsigned int - loop, - cpu_count; - - lfds611_atom_t - count = 0; - - thread_state_t - *thread_handles; - - enum lfds611_data_structure_validity - dvs; - - struct freelist_test_pushing_state - *ftps; - - struct lfds611_freelist_element - *fe; - - struct lfds611_freelist_state - *fs, - *cleanup_fs; - - struct freelist_test_counter_and_thread_number - *cnt, - *counter_and_number_trackers; - - struct lfds611_validation_info - vi; - - /* TRD : we create an empty freelist, which we will push to - - we then create one freelist per CPU, where this freelist - contains 100,000 elements per thread and - each element is an incrementing counter and unique ID - (from 0 to number of CPUs) - - we then start one thread per CPU, where each thread is - given one of the populated freelists and pops from that - to push to the empty freelist - - the reason for this is to achieve memory pre-allocation - which allows the pushing threads to run at maximum speed - - the threads end when their freelists are empty - - we then fully pop the now populated main freelist (onto - a second freelist, so we can cleanly free all memory), - checking that the counts increment on a per unique ID basis - and that the number of elements we pop equals 1,000,000 per thread - (since each element has an incrementing counter which is - unique on a per unique ID basis, we can know we didn't lose - any elements) - */ - - internal_display_test_name( "Pushing" ); - - cpu_count = abstraction_cpu_count(); - - ftps = malloc( sizeof(struct freelist_test_pushing_state) * cpu_count ); - - lfds611_freelist_new( &fs, 0, NULL, NULL ); - - for( loop = 0 ; loop < cpu_count ; loop++ ) { - (ftps+loop)->thread_number = (lfds611_atom_t) loop; - // TRD : note count is shared across threads, so thread 0 is 0-100000, thread 1 is 100000-200000, etc - (ftps+loop)->count = &count; - lfds611_freelist_new( &(ftps+loop)->source_fs, 100000, freelist_test_internal_pushing_init, (void *) (ftps+loop) ); - (ftps+loop)->fs = fs; - } - - thread_handles = malloc( sizeof(thread_state_t) * cpu_count ); - - for( loop = 0 ; loop < cpu_count ; loop++ ) - abstraction_thread_start( &thread_handles[loop], loop, freelist_test_internal_thread_pushing, ftps+loop ); - - for( loop = 0 ; loop < cpu_count ; loop++ ) - abstraction_thread_wait( thread_handles[loop] ); - - free( thread_handles ); - - // TRD : now fully pop and verify the main freelist - lfds611_freelist_new( &cleanup_fs, 0, NULL, NULL ); - - counter_and_number_trackers = malloc( sizeof(struct freelist_test_counter_and_thread_number) * cpu_count ); - - for( loop = 0 ; loop < cpu_count ; loop++ ) { - (counter_and_number_trackers+loop)->counter = 100000 * loop; - (counter_and_number_trackers+loop)->thread_number = (lfds611_atom_t) loop; - } - - vi.min_elements = vi.max_elements = 100000 * cpu_count; - - lfds611_freelist_query( fs, LFDS611_FREELIST_QUERY_VALIDATE, &vi, (void *) &dvs ); - - while( dvs == LFDS611_VALIDITY_VALID and lfds611_freelist_pop(fs, &fe) ) { - lfds611_freelist_get_user_data_from_element( fe, (void **) &cnt ); - - if( cnt->counter != (counter_and_number_trackers+cnt->thread_number)->counter++ ) - dvs = LFDS611_VALIDITY_INVALID_MISSING_ELEMENTS; - - lfds611_freelist_push( cleanup_fs, fe ); - } - - // TRD : clean up - free( counter_and_number_trackers ); - - for( loop = 0 ; loop < cpu_count ; loop++ ) - lfds611_freelist_delete( (ftps+loop)->source_fs, NULL, NULL ); - - free( ftps ); - - lfds611_freelist_delete( cleanup_fs, freelist_test_internal_pushing_delete, NULL ); - lfds611_freelist_delete( fs, NULL, NULL ); - - // TRD : print the test result - internal_display_test_result( 1, "freelist", dvs ); - - return; -} - - - - - -/****************************************************************************/ -int freelist_test_internal_pushing_init( void **user_data, void *user_state ) -{ - struct freelist_test_counter_and_thread_number - *ftcatn; - - struct freelist_test_pushing_state - *ftps; - - assert( user_data != NULL ); - // TRD : user_state is being used as an integer type - - *user_data = malloc( sizeof(struct freelist_test_counter_and_thread_number) ); - ftps = (struct freelist_test_pushing_state *) user_state; - - ftcatn = (struct freelist_test_counter_and_thread_number *) *user_data; - - ftcatn->counter = (*ftps->count)++; - ftcatn->thread_number = ftps->thread_number; - - return( 1 ); -} - - - - - -/****************************************************************************/ -#pragma warning( disable : 4100 ) - -void freelist_test_internal_pushing_delete( void *user_data, void *user_state ) -{ - assert( user_data != NULL ); - assert( user_state == NULL ); - - free( user_data ); - - return; -} - -#pragma warning( default : 4100 ) - - - - - -/****************************************************************************/ -thread_return_t CALLING_CONVENTION freelist_test_internal_thread_pushing( void *freelist_test_pushing_state ) -{ - struct freelist_test_pushing_state - *ftps; - - struct lfds611_freelist_element - *fe; - - assert( freelist_test_pushing_state != NULL ); - - ftps = (struct freelist_test_pushing_state *) freelist_test_pushing_state; - - lfds611_freelist_use( ftps->source_fs ); - lfds611_freelist_use( ftps->fs ); - - while( lfds611_freelist_pop(ftps->source_fs, &fe) ) - lfds611_freelist_push( ftps->fs, fe ); - - return( (thread_return_t) EXIT_SUCCESS ); -} - - - - - -/****************************************************************************/ -void freelist_test_internal_popping_and_pushing( void ) -{ - unsigned int - loop, - cpu_count; - - thread_state_t - *thread_handles; - - enum lfds611_data_structure_validity - dvs; - - struct lfds611_freelist_state - *fs; - - struct freelist_test_popping_and_pushing_state - *pps; - - struct lfds611_validation_info - vi; - - /* TRD : we have two threads per CPU - the threads loop for ten seconds - the first thread pushes 100000 elements then pops 100000 elements - the second thread pops 100000 elements then pushes 100000 elements - all pushes and pops go onto the single main freelist - - after time is up, all threads push what they have remaining onto - the main freelist - - we then validate the main freelist - */ - - internal_display_test_name( "Popping and pushing (10 seconds)" ); - - cpu_count = abstraction_cpu_count(); - - lfds611_freelist_new( &fs, 100000 * cpu_count, NULL, NULL ); - - pps = malloc( sizeof(struct freelist_test_popping_and_pushing_state) * cpu_count * 2 ); - - for( loop = 0 ; loop < cpu_count ; loop++ ) { - (pps+loop)->fs = fs; - lfds611_freelist_new( &(pps+loop)->local_fs, 0, NULL, NULL ); - - (pps+loop+cpu_count)->fs = fs; - lfds611_freelist_new( &(pps+loop+cpu_count)->local_fs, 100000, NULL, NULL ); - } - - thread_handles = malloc( sizeof(thread_state_t) * cpu_count * 2 ); - - for( loop = 0 ; loop < cpu_count ; loop++ ) { - abstraction_thread_start( &thread_handles[loop], loop, freelist_test_internal_thread_popping_and_pushing_start_popping, pps+loop ); - abstraction_thread_start( &thread_handles[loop+cpu_count], loop, freelist_test_internal_thread_popping_and_pushing_start_pushing, pps+loop+cpu_count ); - } - - for( loop = 0 ; loop < cpu_count * 2 ; loop++ ) - abstraction_thread_wait( thread_handles[loop] ); - - free( thread_handles ); - - for( loop = 0 ; loop < cpu_count * 2 ; loop++ ) - lfds611_freelist_delete( (pps+loop)->local_fs, NULL, NULL ); - - free( pps ); - - vi.min_elements = vi.max_elements = 100000 * cpu_count * 2; - - lfds611_freelist_query( fs, LFDS611_FREELIST_QUERY_VALIDATE, (void *) &vi, (void *) &dvs ); - - lfds611_freelist_delete( fs, NULL, NULL ); - - // TRD : print the test result - internal_display_test_result( 1, "freelist", dvs ); - - return; -} - - - - - - -/****************************************************************************/ -thread_return_t CALLING_CONVENTION freelist_test_internal_thread_popping_and_pushing_start_popping( void *freelist_test_popping_and_pushing_state ) -{ - struct freelist_test_popping_and_pushing_state - *pps; - - struct lfds611_freelist_element - *fe; - - time_t - start_time; - - unsigned int - count; - - assert( freelist_test_popping_and_pushing_state != NULL ); - - pps = (struct freelist_test_popping_and_pushing_state *) freelist_test_popping_and_pushing_state; - - lfds611_freelist_use( pps->fs ); - lfds611_freelist_use( pps->local_fs ); - - time( &start_time ); - - while( time(NULL) < start_time + 10 ) { - count = 0; - - while( count < 100000 ) { - lfds611_freelist_pop( pps->fs, &fe ); - - if( fe != NULL ) { - lfds611_freelist_push( pps->local_fs, fe ); - count++; - } - } - - while( lfds611_freelist_pop(pps->local_fs, &fe) ) - lfds611_freelist_push( pps->fs, fe ); - } - - return( (thread_return_t) EXIT_SUCCESS ); -} - - - - - -/****************************************************************************/ -thread_return_t CALLING_CONVENTION freelist_test_internal_thread_popping_and_pushing_start_pushing( void *freelist_test_popping_and_pushing_state ) -{ - struct freelist_test_popping_and_pushing_state - *pps; - - struct lfds611_freelist_element - *fe; - - time_t - start_time; - - unsigned int - count; - - assert( freelist_test_popping_and_pushing_state != NULL ); - - pps = (struct freelist_test_popping_and_pushing_state *) freelist_test_popping_and_pushing_state; - - lfds611_freelist_use( pps->fs ); - lfds611_freelist_use( pps->local_fs ); - - time( &start_time ); - - while( time(NULL) < start_time + 10 ) { - while( lfds611_freelist_pop(pps->local_fs, &fe) ) - lfds611_freelist_push( pps->fs, fe ); - - count = 0; - - while( count < 1000 ) { - lfds611_freelist_pop( pps->fs, &fe ); - - if( fe != NULL ) { - lfds611_freelist_push( pps->local_fs, fe ); - count++; - } - } - } - - // TRD : now push whatever we have in our local freelist - while( lfds611_freelist_pop(pps->local_fs, &fe) ) - lfds611_freelist_push( pps->fs, fe ); - - return( (thread_return_t) EXIT_SUCCESS ); -} - - - - - -/****************************************************************************/ -void freelist_test_internal_rapid_popping_and_pushing( void ) -{ - unsigned int - loop, - cpu_count; - - thread_state_t - *thread_handles; - - struct lfds611_freelist_state - *fs; - - struct lfds611_validation_info - vi; - - enum lfds611_data_structure_validity - dvs; - - /* TRD : in these tests there is a fundamental antagonism between - how much checking/memory clean up that we do and the - likelyhood of collisions between threads in their lock-free - operations - - the lock-free operations are very quick; if we do anything - much at all between operations, we greatly reduce the chance - of threads colliding - - so we have some tests which do enough checking/clean up that - they can tell the freelist is valid and don't leak memory - and here, this test now is one of those which does minimal - checking - in fact, the nature of the test is that you can't - do any real checking - but goes very quickly - - what we do is create a small freelist and then run one thread - per CPU, where each thread simply pops and then immediately - pushes - - the test runs for ten seconds - - after the test is done, the only check we do is to traverse - the freelist, checking for loops and ensuring the number of - elements is correct - */ - - internal_display_test_name( "Rapid popping and pushing (10 seconds)" ); - - cpu_count = abstraction_cpu_count(); - - lfds611_freelist_new( &fs, cpu_count, NULL, NULL ); - - thread_handles = malloc( sizeof(thread_state_t) * cpu_count ); - - for( loop = 0 ; loop < cpu_count ; loop++ ) - abstraction_thread_start( &thread_handles[loop], loop, freelist_test_internal_thread_rapid_popping_and_pushing, fs ); - - for( loop = 0 ; loop < cpu_count ; loop++ ) - abstraction_thread_wait( thread_handles[loop] ); - - free( thread_handles ); - - vi.min_elements = cpu_count; - vi.max_elements = cpu_count; - - lfds611_freelist_query( fs, LFDS611_FREELIST_QUERY_VALIDATE, (void *) &vi, (void *) &dvs ); - - lfds611_freelist_delete( fs, NULL, NULL ); - - // TRD : print the test result - internal_display_test_result( 1, "freelist", dvs ); - - return; -} - - - - - -/****************************************************************************/ -thread_return_t CALLING_CONVENTION freelist_test_internal_thread_rapid_popping_and_pushing( void *lfds611_freelist_state ) -{ - struct lfds611_freelist_state - *fs; - - struct lfds611_freelist_element - *fe; - - time_t - start_time; - - assert( lfds611_freelist_state != NULL ); - - fs = (struct lfds611_freelist_state *) lfds611_freelist_state; - - lfds611_freelist_use( fs ); - - time( &start_time ); - - while( time(NULL) < start_time + 10 ) { - lfds611_freelist_pop( fs, &fe ); - lfds611_freelist_push( fs, fe ); - } - - return( (thread_return_t) EXIT_SUCCESS ); -} - diff --git a/openair2/UTIL/LFDS/liblfds6.1.1/test/src/test_queue.c b/openair2/UTIL/LFDS/liblfds6.1.1/test/src/test_queue.c deleted file mode 100644 index 9acb516ff7..0000000000 --- a/openair2/UTIL/LFDS/liblfds6.1.1/test/src/test_queue.c +++ /dev/null @@ -1,515 +0,0 @@ -#include "internal.h" - - - - - -/****************************************************************************/ -void test_lfds611_queue( void ) -{ - printf( "\n" - "Queue Tests\n" - "===========\n" ); - - queue_test_enqueuing(); - queue_test_dequeuing(); - queue_test_enqueuing_and_dequeuing(); - queue_test_rapid_enqueuing_and_dequeuing(); - - return; -} - - - - - -/****************************************************************************/ -void queue_test_enqueuing( void ) -{ - unsigned int - loop, - cpu_count; - - thread_state_t - *thread_handles; - - struct lfds611_queue_state - *qs; - - struct queue_test_enqueuing_state - *qtes; - - lfds611_atom_t - user_data, - thread, - count, - *per_thread_counters; - - struct lfds611_validation_info - vi = { 1000000, 1000000 }; - - enum lfds611_data_structure_validity - dvs[2]; - - /* TRD : create an empty queue with 1,000,000 elements in its freelist - then run one thread per CPU - where each thread busy-works, enqueuing elements (until there are no more elements) - each element's void pointer of user data is (thread number | element number) - where element_number is a thread-local counter starting at 0 - where the thread_number occupies the top byte - - when we're done, we check that all the elements are present - and increment on a per-thread basis - */ - - internal_display_test_name( "Enqueuing" ); - - cpu_count = abstraction_cpu_count(); - - lfds611_queue_new( &qs, 1000000 ); - - qtes = malloc( sizeof(struct queue_test_enqueuing_state) * cpu_count ); - - for( loop = 0 ; loop < cpu_count ; loop++ ) { - (qtes+loop)->qs = qs; - (qtes+loop)->counter = (lfds611_atom_t) loop << (sizeof(lfds611_atom_t)*8-8); - } - - thread_handles = malloc( sizeof(thread_state_t) * cpu_count ); - - for( loop = 0 ; loop < cpu_count ; loop++ ) - abstraction_thread_start( &thread_handles[loop], loop, queue_test_internal_thread_simple_enqueuer, qtes+loop ); - - for( loop = 0 ; loop < cpu_count ; loop++ ) - abstraction_thread_wait( thread_handles[loop] ); - - free( thread_handles ); - - free( qtes ); - - /* TRD : first, validate the queue - - then dequeue - we expect to find element numbers increment on a per thread basis - */ - - lfds611_queue_query( qs, LFDS611_QUEUE_QUERY_VALIDATE, &vi, dvs ); - - per_thread_counters = malloc( sizeof(lfds611_atom_t) * cpu_count ); - - for( loop = 0 ; loop < cpu_count ; loop++ ) - *(per_thread_counters+loop) = 0; - - while( dvs[0] == LFDS611_VALIDITY_VALID and dvs[1] == LFDS611_VALIDITY_VALID and lfds611_queue_dequeue(qs, (void *) &user_data) ) { - thread = user_data >> (sizeof(lfds611_atom_t)*8-8); - count = (user_data << 8) >> 8; - - if( thread >= cpu_count ) { - dvs[0] = LFDS611_VALIDITY_INVALID_TEST_DATA; - break; - } - - if( count < per_thread_counters[thread] ) - dvs[0] = LFDS611_VALIDITY_INVALID_ADDITIONAL_ELEMENTS; - - if( count > per_thread_counters[thread] ) - dvs[0] = LFDS611_VALIDITY_INVALID_MISSING_ELEMENTS; - - if( count == per_thread_counters[thread] ) - per_thread_counters[thread]++; - } - - free( per_thread_counters ); - - lfds611_queue_delete( qs, NULL, NULL ); - - internal_display_test_result( 2, "queue", dvs[0], "queue freelist", dvs[1] ); - - return; -} - - - - - -/****************************************************************************/ -thread_return_t CALLING_CONVENTION queue_test_internal_thread_simple_enqueuer( void *queue_test_enqueuing_state ) -{ - struct queue_test_enqueuing_state - *qtes; - - assert( queue_test_enqueuing_state != NULL ); - - qtes = (struct queue_test_enqueuing_state *) queue_test_enqueuing_state; - - lfds611_queue_use( qtes->qs ); - - // TRD : top byte of counter is already our thread number - while( lfds611_queue_enqueue(qtes->qs, (void *) qtes->counter++) ); - - return( (thread_return_t) EXIT_SUCCESS ); -} - - - - - -/****************************************************************************/ -void queue_test_dequeuing( void ) -{ - unsigned int - loop, - cpu_count; - - thread_state_t - *thread_handles; - - struct lfds611_queue_state - *qs; - - struct queue_test_dequeuing_state - *qtds; - - struct lfds611_validation_info - vi = { 0, 0 }; - - enum lfds611_data_structure_validity - dvs[2]; - - /* TRD : create a queue with 1,000,000 elements - - use a single thread to enqueue every element - each elements user data is an incrementing counter - - then run one thread per CPU - where each busy-works dequeuing - - when an element is dequeued, we check (on a per-thread basis) the - value deqeued is greater than the element previously dequeued - */ - - internal_display_test_name( "Dequeuing" ); - - cpu_count = abstraction_cpu_count(); - - lfds611_queue_new( &qs, 1000000 ); - - for( loop = 0 ; loop < 1000000 ; loop++ ) - lfds611_queue_enqueue( qs, (void *) (lfds611_atom_t) loop ); - - qtds = malloc( sizeof(struct queue_test_dequeuing_state) * cpu_count ); - - for( loop = 0 ; loop < cpu_count ; loop++ ) { - (qtds+loop)->qs = qs; - (qtds+loop)->error_flag = LOWERED; - } - - thread_handles = malloc( sizeof(thread_state_t) * cpu_count ); - - for( loop = 0 ; loop < cpu_count ; loop++ ) - abstraction_thread_start( &thread_handles[loop], loop, queue_test_internal_thread_simple_dequeuer, qtds+loop ); - - for( loop = 0 ; loop < cpu_count ; loop++ ) - abstraction_thread_wait( thread_handles[loop] ); - - free( thread_handles ); - - // TRD : check queue is empty - lfds611_queue_query( qs, LFDS611_QUEUE_QUERY_VALIDATE, (void *) &vi, (void *) dvs ); - - // TRD : check for raised error flags - for( loop = 0 ; loop < cpu_count ; loop++ ) - if( (qtds+loop)->error_flag == RAISED ) - dvs[0] = LFDS611_VALIDITY_INVALID_TEST_DATA; - - free( qtds ); - - lfds611_queue_delete( qs, NULL, NULL ); - - internal_display_test_result( 2, "queue", dvs[0], "queue freelist", dvs[1] ); - - return; -} - - - - - -/****************************************************************************/ -thread_return_t CALLING_CONVENTION queue_test_internal_thread_simple_dequeuer( void *queue_test_dequeuing_state ) -{ - struct queue_test_dequeuing_state - *qtds; - - lfds611_atom_t - *prev_user_data, - *user_data; - - assert( queue_test_dequeuing_state != NULL ); - - qtds = (struct queue_test_dequeuing_state *) queue_test_dequeuing_state; - - lfds611_queue_use( qtds->qs ); - - lfds611_queue_dequeue( qtds->qs, (void *) &prev_user_data ); - - while( lfds611_queue_dequeue(qtds->qs, (void *) &user_data) ) { - if( user_data <= prev_user_data ) - qtds->error_flag = RAISED; - - prev_user_data = user_data; - } - - return( (thread_return_t) EXIT_SUCCESS ); -} - - - - - -/****************************************************************************/ -void queue_test_enqueuing_and_dequeuing( void ) -{ - unsigned int - loop, - subloop, - cpu_count; - - thread_state_t - *thread_handles; - - struct lfds611_queue_state - *qs; - - struct queue_test_enqueuing_and_dequeuing_state - *qteds; - - struct lfds611_validation_info - vi = { 0, 0 }; - - enum lfds611_data_structure_validity - dvs[2]; - - internal_display_test_name( "Enqueuing and dequeuing (10 seconds)" ); - - cpu_count = abstraction_cpu_count(); - - lfds611_queue_new( &qs, cpu_count ); - - qteds = malloc( sizeof(struct queue_test_enqueuing_and_dequeuing_state) * cpu_count ); - - for( loop = 0 ; loop < cpu_count ; loop++ ) { - (qteds+loop)->qs = qs; - (qteds+loop)->thread_number = loop; - (qteds+loop)->counter = (lfds611_atom_t) loop << (sizeof(lfds611_atom_t)*8-8); - (qteds+loop)->cpu_count = cpu_count; - (qteds+loop)->error_flag = LOWERED; - (qteds+loop)->per_thread_counters = malloc( sizeof(lfds611_atom_t) * cpu_count ); - - for( subloop = 0 ; subloop < cpu_count ; subloop++ ) - *((qteds+loop)->per_thread_counters+subloop) = 0; - } - - thread_handles = malloc( sizeof(thread_state_t) * cpu_count ); - - for( loop = 0 ; loop < cpu_count ; loop++ ) - abstraction_thread_start( &thread_handles[loop], loop, queue_test_internal_thread_enqueuer_and_dequeuer, qteds+loop ); - - for( loop = 0 ; loop < cpu_count ; loop++ ) - abstraction_thread_wait( thread_handles[loop] ); - - free( thread_handles ); - - lfds611_queue_query( qs, LFDS611_QUEUE_QUERY_VALIDATE, (void *) &vi, (void *) dvs ); - - for( loop = 0 ; loop < cpu_count ; loop++ ) - if( (qteds+loop)->error_flag == RAISED ) - dvs[0] = LFDS611_VALIDITY_INVALID_TEST_DATA; - - for( loop = 0 ; loop < cpu_count ; loop++ ) - free( (qteds+loop)->per_thread_counters ); - - free( qteds ); - - lfds611_queue_delete( qs, NULL, NULL ); - - internal_display_test_result( 2, "queue", dvs[0], "queue freelist", dvs[1] ); - - return; -} - - - - - -/****************************************************************************/ -thread_return_t CALLING_CONVENTION queue_test_internal_thread_enqueuer_and_dequeuer( void *queue_test_enqueuing_and_dequeuing_state ) -{ - struct queue_test_enqueuing_and_dequeuing_state - *qteds; - - time_t - start_time; - - lfds611_atom_t - thread, - count, - user_data; - - assert( queue_test_enqueuing_and_dequeuing_state != NULL ); - - qteds = (struct queue_test_enqueuing_and_dequeuing_state *) queue_test_enqueuing_and_dequeuing_state; - - lfds611_queue_use( qteds->qs ); - - time( &start_time ); - - while( time(NULL) < start_time + 10 ) { - lfds611_queue_enqueue( qteds->qs, (void *) (qteds->counter++) ); - lfds611_queue_dequeue( qteds->qs, (void *) &user_data ); - - thread = user_data >> (sizeof(lfds611_atom_t)*8-8); - count = (user_data << 8) >> 8; - - if( thread >= qteds->cpu_count ) - qteds->error_flag = RAISED; - else { - if( count < qteds->per_thread_counters[thread] ) - qteds->error_flag = RAISED; - - if( count >= qteds->per_thread_counters[thread] ) - qteds->per_thread_counters[thread] = count+1; - } - } - - return( (thread_return_t) EXIT_SUCCESS ); -} - - - - - -/****************************************************************************/ -void queue_test_rapid_enqueuing_and_dequeuing( void ) -{ - unsigned int - loop, - cpu_count; - - thread_state_t - *thread_handles; - - struct lfds611_queue_state - *qs; - - struct queue_test_rapid_enqueuing_and_dequeuing_state - *qtreds; - - struct lfds611_validation_info - vi = { 50000, 50000 }; - - lfds611_atom_t - user_data, - thread, - count, - *per_thread_counters; - - enum lfds611_data_structure_validity - dvs[2]; - - internal_display_test_name( "Rapid enqueuing and dequeuing (10 seconds)" ); - - cpu_count = abstraction_cpu_count(); - - lfds611_queue_new( &qs, 100000 ); - - for( loop = 0 ; loop < 50000 ; loop++ ) - lfds611_queue_enqueue( qs, NULL ); - - qtreds = malloc( sizeof(struct queue_test_rapid_enqueuing_and_dequeuing_state) * cpu_count ); - - for( loop = 0 ; loop < cpu_count ; loop++ ) { - (qtreds+loop)->qs = qs; - (qtreds+loop)->counter = (lfds611_atom_t) loop << (sizeof(lfds611_atom_t)*8-8); - } - - thread_handles = malloc( sizeof(thread_state_t) * cpu_count ); - - for( loop = 0 ; loop < cpu_count ; loop++ ) - abstraction_thread_start( &thread_handles[loop], loop, queue_test_internal_thread_rapid_enqueuer_and_dequeuer, qtreds+loop ); - - for( loop = 0 ; loop < cpu_count ; loop++ ) - abstraction_thread_wait( thread_handles[loop] ); - - free( thread_handles ); - - lfds611_queue_query( qs, LFDS611_QUEUE_QUERY_VALIDATE, (void *) &vi, (void *) dvs ); - - // TRD : now check results - per_thread_counters = malloc( sizeof(lfds611_atom_t) * cpu_count ); - - for( loop = 0 ; loop < cpu_count ; loop++ ) - *(per_thread_counters+loop) = 0; - - while( dvs[0] == LFDS611_VALIDITY_VALID and dvs[1] == LFDS611_VALIDITY_VALID and lfds611_queue_dequeue(qs, (void *) &user_data) ) { - thread = user_data >> (sizeof(lfds611_atom_t)*8-8); - count = (user_data << 8) >> 8; - - if( thread >= cpu_count ) { - dvs[0] = LFDS611_VALIDITY_INVALID_TEST_DATA; - break; - } - - if( per_thread_counters[thread] == 0 ) - per_thread_counters[thread] = count; - - if( count < per_thread_counters[thread] ) - dvs[0] = LFDS611_VALIDITY_INVALID_ADDITIONAL_ELEMENTS; - - if( count >= per_thread_counters[thread] ) - per_thread_counters[thread] = count+1; - } - - free( per_thread_counters ); - - free( qtreds ); - - lfds611_queue_delete( qs, NULL, NULL ); - - internal_display_test_result( 2, "queue", dvs[0], "queue freelist", dvs[1] ); - - return; -} - - - - - -/****************************************************************************/ -thread_return_t CALLING_CONVENTION queue_test_internal_thread_rapid_enqueuer_and_dequeuer( void *queue_test_rapid_enqueuing_and_dequeuing_state ) -{ - struct queue_test_rapid_enqueuing_and_dequeuing_state - *qtreds; - - time_t - start_time; - - lfds611_atom_t - user_data; - - assert( queue_test_rapid_enqueuing_and_dequeuing_state != NULL ); - - qtreds = (struct queue_test_rapid_enqueuing_and_dequeuing_state *) queue_test_rapid_enqueuing_and_dequeuing_state; - - lfds611_queue_use( qtreds->qs ); - - time( &start_time ); - - while( time(NULL) < start_time + 10 ) { - lfds611_queue_enqueue( qtreds->qs, (void *) (qtreds->counter++) ); - lfds611_queue_dequeue( qtreds->qs, (void *) &user_data ); - } - - return( (thread_return_t) EXIT_SUCCESS ); -} - diff --git a/openair2/UTIL/LFDS/liblfds6.1.1/test/src/test_ringbuffer.c b/openair2/UTIL/LFDS/liblfds6.1.1/test/src/test_ringbuffer.c deleted file mode 100644 index c9c0fd1721..0000000000 --- a/openair2/UTIL/LFDS/liblfds6.1.1/test/src/test_ringbuffer.c +++ /dev/null @@ -1,472 +0,0 @@ -#include "internal.h" - - - - - -/****************************************************************************/ -void test_lfds611_ringbuffer( void ) -{ - printf( "\n" - "Ringbuffer Tests\n" - "================\n" ); - - ringbuffer_test_reading(); - ringbuffer_test_writing(); - ringbuffer_test_reading_and_writing(); - - return; -} - - - - - -/****************************************************************************/ -void ringbuffer_test_reading( void ) -{ - unsigned int - loop, - cpu_count; - - thread_state_t - *thread_handles; - - struct lfds611_ringbuffer_state - *rs; - - struct lfds611_freelist_element - *fe; - - struct ringbuffer_test_reading_state - *rtrs; - - struct lfds611_validation_info - vi = { 0, 0 }; - - enum lfds611_data_structure_validity - dvs[3]; - - lfds611_atom_t - total_read = 0; - - /* TRD : we create a single ringbuffer - with 1,000,000 elements - we populate the ringbuffer, where the - user data is an incrementing counter - - we create one thread per CPU - where each thread busy-works, - reading until the ringbuffer is empty - - each thread keeps track of the number of reads it manages - and that each user data it reads is greater than the - previous user data that was read - */ - - internal_display_test_name( "Reading" ); - - cpu_count = abstraction_cpu_count(); - - lfds611_ringbuffer_new( &rs, 1000000, NULL, NULL ); - - for( loop = 0 ; loop < 1000000 ; loop++ ) { - lfds611_ringbuffer_get_write_element( rs, &fe, NULL ); - lfds611_freelist_set_user_data_in_element( fe, (void *) (lfds611_atom_t) loop ); - lfds611_ringbuffer_put_write_element( rs, fe ); - } - - rtrs = malloc( sizeof(struct ringbuffer_test_reading_state) * cpu_count ); - - for( loop = 0 ; loop < cpu_count ; loop++ ) { - (rtrs+loop)->rs = rs; - (rtrs+loop)->read_count = 0; - (rtrs+loop)->error_flag = LOWERED; - } - - thread_handles = malloc( sizeof(thread_state_t) * cpu_count ); - - for( loop = 0 ; loop < cpu_count ; loop++ ) - abstraction_thread_start( &thread_handles[loop], loop, ringbuffer_test_thread_simple_reader, rtrs+loop ); - - for( loop = 0 ; loop < cpu_count ; loop++ ) - abstraction_thread_wait( thread_handles[loop] ); - - free( thread_handles ); - - lfds611_ringbuffer_query( rs, LFDS611_RINGBUFFER_QUERY_VALIDATE, (void *) &vi, (void *) dvs ); - - // TRD : check for raised error flags - for( loop = 0 ; loop < cpu_count ; loop++ ) - if( (rtrs+loop)->error_flag == RAISED ) - dvs[0] = LFDS611_VALIDITY_INVALID_TEST_DATA; - - // TRD : check thread reads total to 1,000,000 - for( loop = 0 ; loop < cpu_count ; loop++ ) - total_read += (rtrs+loop)->read_count; - - if( total_read < 1000000 ) - dvs[0] = LFDS611_VALIDITY_INVALID_MISSING_ELEMENTS; - - if( total_read > 1000000 ) - dvs[0] = LFDS611_VALIDITY_INVALID_ADDITIONAL_ELEMENTS; - - free( rtrs ); - - lfds611_ringbuffer_delete( rs, NULL, NULL ); - - internal_display_test_result( 3, "queue", dvs[0], "queue freelist", dvs[1], "freelist", dvs[2] ); - - return; -} - - - - - -/****************************************************************************/ -thread_return_t CALLING_CONVENTION ringbuffer_test_thread_simple_reader( void *ringbuffer_test_reading_state ) -{ - struct ringbuffer_test_reading_state - *rtrs; - - struct lfds611_freelist_element - *fe; - - lfds611_atom_t - *prev_user_data, - *user_data; - - assert( ringbuffer_test_reading_state != NULL ); - - rtrs = (struct ringbuffer_test_reading_state *) ringbuffer_test_reading_state; - - lfds611_ringbuffer_use( rtrs->rs ); - - /* TRD : read an initial element to load a value into prev_user_data - it may be (under valgrind for example) that by the time we start - there are no elements remaining to read - */ - - lfds611_ringbuffer_get_read_element( rtrs->rs, &fe ); - - if( fe == NULL ) - return( (thread_return_t) EXIT_SUCCESS ); - - lfds611_freelist_get_user_data_from_element( fe, (void **) &prev_user_data ); - lfds611_ringbuffer_put_read_element( rtrs->rs, fe ); - - rtrs->read_count++; - - while( lfds611_ringbuffer_get_read_element(rtrs->rs, &fe) ) { - lfds611_freelist_get_user_data_from_element( fe, (void **) &user_data ); - lfds611_ringbuffer_put_read_element( rtrs->rs, fe ); - - if( user_data <= prev_user_data ) - rtrs->error_flag = RAISED; - - prev_user_data = user_data; - - rtrs->read_count++; - } - - return( (thread_return_t) EXIT_SUCCESS ); -} - - - - - -/****************************************************************************/ -void ringbuffer_test_writing( void ) -{ - unsigned int - loop, - cpu_count; - - thread_state_t - *thread_handles; - - struct lfds611_ringbuffer_state - *rs; - - struct lfds611_freelist_element - *fe; - - struct ringbuffer_test_writing_state - *rtws; - - struct lfds611_validation_info - vi = { 100000, 100000 }; - - enum lfds611_data_structure_validity - dvs[3]; - - lfds611_atom_t - thread, - count, - user_data, - *per_thread_counters; - - /* TRD : we create a single ringbuffer - with 100000 elements - the ringbuffers starts empty - - we create one thread per CPU - where each thread busy-works writing - for ten seconds - - the user data in each written element is a combination - of the thread number and the counter - - after the threads are complete, we validate by - checking the user data counters increment on a per thread - basis - */ - - internal_display_test_name( "Writing (10 seconds)" ); - - cpu_count = abstraction_cpu_count(); - - lfds611_ringbuffer_new( &rs, 100000, NULL, NULL ); - - rtws = malloc( sizeof(struct ringbuffer_test_writing_state) * cpu_count ); - - for( loop = 0 ; loop < cpu_count ; loop++ ) { - (rtws+loop)->rs = rs; - (rtws+loop)->write_count = (lfds611_atom_t) loop << (sizeof(lfds611_atom_t)*8-8); - } - - thread_handles = malloc( sizeof(thread_state_t) * cpu_count ); - - for( loop = 0 ; loop < cpu_count ; loop++ ) - abstraction_thread_start( &thread_handles[loop], loop, ringbuffer_test_thread_simple_writer, rtws+loop ); - - for( loop = 0 ; loop < cpu_count ; loop++ ) - abstraction_thread_wait( thread_handles[loop] ); - - free( thread_handles ); - - // TRD : now check results - per_thread_counters = malloc( sizeof(lfds611_atom_t) * cpu_count ); - - for( loop = 0 ; loop < cpu_count ; loop++ ) - *(per_thread_counters+loop) = 0; - - lfds611_ringbuffer_query( rs, LFDS611_RINGBUFFER_QUERY_VALIDATE, (void *) &vi, (void *) dvs ); - - while( dvs[0] == LFDS611_VALIDITY_VALID and dvs[1] == LFDS611_VALIDITY_VALID and dvs[2] == LFDS611_VALIDITY_VALID and lfds611_ringbuffer_get_read_element(rs, &fe) ) { - lfds611_freelist_get_user_data_from_element( fe, (void *) &user_data ); - - thread = user_data >> (sizeof(lfds611_atom_t)*8-8); - count = (user_data << 8) >> 8; - - if( thread >= cpu_count ) { - dvs[0] = LFDS611_VALIDITY_INVALID_TEST_DATA; - lfds611_ringbuffer_put_read_element( rs, fe ); - break; - } - - if( per_thread_counters[thread] == 0 ) - per_thread_counters[thread] = count; - - if( count < per_thread_counters[thread] ) - dvs[0] = LFDS611_VALIDITY_INVALID_ADDITIONAL_ELEMENTS; - - if( count >= per_thread_counters[thread] ) - per_thread_counters[thread] = count+1; - - lfds611_ringbuffer_put_read_element( rs, fe ); - } - - free( per_thread_counters ); - - free( rtws ); - - lfds611_ringbuffer_delete( rs, NULL, NULL ); - - internal_display_test_result( 3, "queue", dvs[0], "queue freelist", dvs[1], "freelist", dvs[2] ); - - return; -} - - - - - -/****************************************************************************/ -thread_return_t CALLING_CONVENTION ringbuffer_test_thread_simple_writer( void *ringbuffer_test_writing_state ) -{ - struct ringbuffer_test_writing_state - *rtws; - - struct lfds611_freelist_element - *fe; - - time_t - start_time; - - assert( ringbuffer_test_writing_state != NULL ); - - rtws = (struct ringbuffer_test_writing_state *) ringbuffer_test_writing_state; - - lfds611_ringbuffer_use( rtws->rs ); - - time( &start_time ); - - while( time(NULL) < start_time + 10 ) { - lfds611_ringbuffer_get_write_element( rtws->rs, &fe, NULL ); - lfds611_freelist_set_user_data_in_element( fe, (void *) (lfds611_atom_t) (rtws->write_count++) ); - lfds611_ringbuffer_put_write_element( rtws->rs, fe ); - } - - return( (thread_return_t) EXIT_SUCCESS ); -} - - - - - -/****************************************************************************/ -void ringbuffer_test_reading_and_writing( void ) -{ - unsigned int - loop, - subloop, - cpu_count; - - thread_state_t - *thread_handles; - - struct lfds611_ringbuffer_state - *rs; - - struct ringbuffer_test_reading_and_writing_state - *rtrws; - - struct lfds611_validation_info - vi = { 0, 0 }; - - enum lfds611_data_structure_validity - dvs[3]; - - /* TRD : we create a single ringbuffer - with 100000 elements - the ringbuffers starts empty - - we create one thread per CPU - where each thread busy-works writing - and then immediately reading - for ten seconds - - the user data in each written element is a combination - of the thread number and the counter - - while a thread runs, it keeps track of the - counters for the other threads and throws an error - if it sees the number stay the same or decrease - */ - - internal_display_test_name( "Reading and writing (10 seconds)" ); - - cpu_count = abstraction_cpu_count(); - - lfds611_ringbuffer_new( &rs, 100000, NULL, NULL ); - - rtrws = malloc( sizeof(struct ringbuffer_test_reading_and_writing_state) * cpu_count ); - - for( loop = 0 ; loop < cpu_count ; loop++ ) { - (rtrws+loop)->rs = rs; - (rtrws+loop)->counter = (lfds611_atom_t) loop << (sizeof(lfds611_atom_t)*8-8); - (rtrws+loop)->cpu_count = cpu_count; - (rtrws+loop)->error_flag = LOWERED; - (rtrws+loop)->per_thread_counters = malloc( sizeof(lfds611_atom_t) * cpu_count ); - - for( subloop = 0 ; subloop < cpu_count ; subloop++ ) - *((rtrws+loop)->per_thread_counters+subloop) = 0; - } - - thread_handles = malloc( sizeof(thread_state_t) * cpu_count ); - - for( loop = 0 ; loop < cpu_count ; loop++ ) - abstraction_thread_start( &thread_handles[loop], loop, ringbuffer_test_thread_reader_writer, rtrws+loop ); - - for( loop = 0 ; loop < cpu_count ; loop++ ) - abstraction_thread_wait( thread_handles[loop] ); - - free( thread_handles ); - - lfds611_ringbuffer_query( rs, LFDS611_RINGBUFFER_QUERY_VALIDATE, (void *) &vi, (void *) dvs ); - - for( loop = 0 ; loop < cpu_count ; loop++ ) - if( (rtrws+loop)->error_flag == RAISED ) - dvs[0] = LFDS611_VALIDITY_INVALID_TEST_DATA; - - for( loop = 0 ; loop < cpu_count ; loop++ ) - free( (rtrws+loop)->per_thread_counters ); - - free( rtrws ); - - lfds611_ringbuffer_delete( rs, NULL, NULL ); - - internal_display_test_result( 3, "queue", dvs[0], "queue freelist", dvs[1], "freelist", dvs[2] ); - - return; -} - - - - - -/****************************************************************************/ -thread_return_t CALLING_CONVENTION ringbuffer_test_thread_reader_writer( void *ringbuffer_test_reading_and_writing_state ) -{ - struct ringbuffer_test_reading_and_writing_state - *rtrws; - - struct lfds611_freelist_element - *fe; - - lfds611_atom_t - user_data, - thread, - count; - - time_t - start_time; - - assert( ringbuffer_test_reading_and_writing_state != NULL ); - - rtrws = (struct ringbuffer_test_reading_and_writing_state *) ringbuffer_test_reading_and_writing_state; - - lfds611_ringbuffer_use( rtrws->rs ); - - time( &start_time ); - - while( time(NULL) < start_time + 10 ) { - lfds611_ringbuffer_get_write_element( rtrws->rs, &fe, NULL ); - lfds611_freelist_set_user_data_in_element( fe, (void *) (lfds611_atom_t) (rtrws->counter++) ); - lfds611_ringbuffer_put_write_element( rtrws->rs, fe ); - - lfds611_ringbuffer_get_read_element( rtrws->rs, &fe ); - lfds611_freelist_get_user_data_from_element( fe, (void *) &user_data ); - - thread = user_data >> (sizeof(lfds611_atom_t)*8-8); - count = (user_data << 8) >> 8; - - if( thread >= rtrws->cpu_count ) - rtrws->error_flag = RAISED; - else { - if( count < rtrws->per_thread_counters[thread] ) - rtrws->error_flag = RAISED; - - if( count >= rtrws->per_thread_counters[thread] ) - rtrws->per_thread_counters[thread] = count+1; - } - - lfds611_ringbuffer_put_read_element( rtrws->rs, fe ); - } - - return( (thread_return_t) EXIT_SUCCESS ); -} - diff --git a/openair2/UTIL/LFDS/liblfds6.1.1/test/src/test_slist.c b/openair2/UTIL/LFDS/liblfds6.1.1/test/src/test_slist.c deleted file mode 100644 index 0388ad8c7d..0000000000 --- a/openair2/UTIL/LFDS/liblfds6.1.1/test/src/test_slist.c +++ /dev/null @@ -1,388 +0,0 @@ -#include "internal.h" - - - - - -/****************************************************************************/ -void test_lfds611_slist( void ) -{ - printf( "\n" - "SList Tests\n" - "===========\n" ); - - test_slist_new_delete_get(); - test_slist_get_set_user_data(); - test_slist_delete_all_elements(); - - return; -} - - - - - -/****************************************************************************/ -void test_slist_new_delete_get( void ) -{ - unsigned int - loop, - cpu_count; - - struct lfds611_slist_state - *ss; - - struct lfds611_slist_element - *se = NULL; - - struct slist_test_state - *sts; - - thread_state_t - *thread_handles; - - size_t - total_create_count = 0, - total_delete_count = 0, - element_count = 0; - - enum lfds611_data_structure_validity - dvs = LFDS611_VALIDITY_VALID; - - /* TRD : two threads per CPU - first simply alternates between new_head() and new_next() (next on element created by head) - second calls get_next, if NULL, then calls get_head, and deletes the element - both threads keep count of created and deleted - validate is to reconcile created, deleted and remaining in list - */ - - internal_display_test_name( "New head/next, delete and get next" ); - - cpu_count = abstraction_cpu_count(); - - lfds611_slist_new( &ss, NULL, NULL ); - - sts = malloc( sizeof(struct slist_test_state) * cpu_count * 2 ); - - for( loop = 0 ; loop < cpu_count * 2 ; loop++ ) { - (sts+loop)->ss = ss; - (sts+loop)->create_count = 0; - (sts+loop)->delete_count = 0; - } - - thread_handles = malloc( sizeof(thread_state_t) * cpu_count * 2 ); - - for( loop = 0 ; loop < cpu_count ; loop++ ) { - abstraction_thread_start( &thread_handles[loop], loop, slist_test_internal_thread_new_delete_get_new_head_and_next, sts+loop ); - abstraction_thread_start( &thread_handles[loop+cpu_count], loop, slist_test_internal_thread_new_delete_get_delete_and_get, sts+loop+cpu_count ); - } - - for( loop = 0 ; loop < cpu_count * 2 ; loop++ ) - abstraction_thread_wait( thread_handles[loop] ); - - free( thread_handles ); - - // TRD : now validate - for( loop = 0 ; loop < cpu_count * 2 ; loop++ ) { - total_create_count += (sts+loop)->create_count; - total_delete_count += (sts+loop)->delete_count; - } - - while( NULL != lfds611_slist_get_head_and_then_next(ss, &se) ) - element_count++; - - if( total_create_count - total_delete_count - element_count != 0 ) - dvs = LFDS611_VALIDITY_INVALID_TEST_DATA; - - free( sts ); - - lfds611_slist_delete( ss ); - - internal_display_test_result( 1, "slist", dvs ); - - return; -} - - - - - -/****************************************************************************/ -thread_return_t CALLING_CONVENTION slist_test_internal_thread_new_delete_get_new_head_and_next( void *slist_test_state ) -{ - struct slist_test_state - *sts; - - time_t - start_time; - - struct lfds611_slist_element - *se = NULL; - - assert( slist_test_state != NULL ); - - sts = (struct slist_test_state *) slist_test_state; - - lfds611_slist_use( sts->ss ); - - time( &start_time ); - - while( time(NULL) < start_time + 1 ) { - if( sts->create_count % 2 == 0 ) - se = lfds611_slist_new_head( sts->ss, NULL ); - else - lfds611_slist_new_next( se, NULL ); - - sts->create_count++; - } - - return( (thread_return_t) EXIT_SUCCESS ); -} - - - - - -/****************************************************************************/ -thread_return_t CALLING_CONVENTION slist_test_internal_thread_new_delete_get_delete_and_get( void *slist_test_state ) -{ - struct slist_test_state - *sts; - - time_t - start_time; - - struct lfds611_slist_element - *se = NULL; - - assert( slist_test_state != NULL ); - - sts = (struct slist_test_state *) slist_test_state; - - lfds611_slist_use( sts->ss ); - - time( &start_time ); - - while( time(NULL) < start_time + 1 ) { - if( se == NULL ) - lfds611_slist_get_head( sts->ss, &se ); - else - lfds611_slist_get_next( se, &se ); - - if( se != NULL ) { - if( 1 == lfds611_slist_logically_delete_element(sts->ss, se) ) - sts->delete_count++; - } - } - - return( (thread_return_t) EXIT_SUCCESS ); -} - - - - - -/****************************************************************************/ -void test_slist_get_set_user_data( void ) -{ - unsigned int - loop, - cpu_count; - - struct lfds611_slist_state - *ss; - - struct lfds611_slist_element - *se = NULL; - - struct slist_test_state - *sts; - - thread_state_t - *thread_handles; - - lfds611_atom_t - thread_and_count, - thread, - count, - *per_thread_counters, - *per_thread_drop_flags; - - enum lfds611_data_structure_validity - dvs = LFDS611_VALIDITY_VALID; - - /* TRD : create a list of (cpu_count*10) elements, user data 0 - one thread per CPU - each thread loops, setting user_data to ((thread_number << (sizeof(lfds611_atom_t)*8-8)) | count) - validation is to scan list, count on a per thread basis should go down only once - */ - - internal_display_test_name( "Get and set user data" ); - - cpu_count = abstraction_cpu_count(); - - lfds611_slist_new( &ss, NULL, NULL ); - - for( loop = 0 ; loop < cpu_count * 10 ; loop++ ) - lfds611_slist_new_head( ss, NULL ); - - sts = malloc( sizeof(struct slist_test_state) * cpu_count ); - - for( loop = 0 ; loop < cpu_count ; loop++ ) { - (sts+loop)->ss = ss; - (sts+loop)->thread_and_count = (lfds611_atom_t) loop << (sizeof(lfds611_atom_t)*8-8); - } - - thread_handles = malloc( sizeof(thread_state_t) * cpu_count ); - - for( loop = 0 ; loop < cpu_count ; loop++ ) - abstraction_thread_start( &thread_handles[loop], loop, slist_test_internal_thread_get_set_user_data, sts+loop ); - - for( loop = 0 ; loop < cpu_count ; loop++ ) - abstraction_thread_wait( thread_handles[loop] ); - - free( thread_handles ); - - // now validate - per_thread_counters = malloc( sizeof(lfds611_atom_t) * cpu_count ); - per_thread_drop_flags = malloc( sizeof(lfds611_atom_t) * cpu_count ); - - for( loop = 0 ; loop < cpu_count ; loop++ ) { - *(per_thread_counters+loop) = 0; - *(per_thread_drop_flags+loop) = 0; - } - - while( dvs == LFDS611_VALIDITY_VALID and NULL != lfds611_slist_get_head_and_then_next(ss, &se) ) { - lfds611_slist_get_user_data_from_element( se, (void **) &thread_and_count ); - - thread = thread_and_count >> (sizeof(lfds611_atom_t)*8-8); - count = (thread_and_count << 8) >> 8; - - if( thread >= cpu_count ) { - dvs = LFDS611_VALIDITY_INVALID_TEST_DATA; - break; - } - - if( per_thread_counters[thread] == 0 ) { - per_thread_counters[thread] = count; - continue; - } - - per_thread_counters[thread]++; - - if( count < per_thread_counters[thread] and per_thread_drop_flags[thread] == 1 ) { - dvs = LFDS611_VALIDITY_INVALID_ADDITIONAL_ELEMENTS; - break; - } - - if( count < per_thread_counters[thread] and per_thread_drop_flags[thread] == 0 ) { - per_thread_drop_flags[thread] = 1; - per_thread_counters[thread] = count; - continue; - } - - if( count < per_thread_counters[thread] ) - dvs = LFDS611_VALIDITY_INVALID_ADDITIONAL_ELEMENTS; - - if( count >= per_thread_counters[thread] ) - per_thread_counters[thread] = count; - } - - free( per_thread_drop_flags ); - free( per_thread_counters ); - - free( sts ); - - lfds611_slist_delete( ss ); - - internal_display_test_result( 1, "slist", dvs ); - - return; -} - - - - - -/****************************************************************************/ -thread_return_t CALLING_CONVENTION slist_test_internal_thread_get_set_user_data( void *slist_test_state ) -{ - struct slist_test_state - *sts; - - time_t - start_time; - - struct lfds611_slist_element - *se = NULL; - - assert( slist_test_state != NULL ); - - sts = (struct slist_test_state *) slist_test_state; - - lfds611_slist_use( sts->ss ); - - time( &start_time ); - - while( time(NULL) < start_time + 1 ) { - if( se == NULL ) - lfds611_slist_get_head( sts->ss, &se ); - - lfds611_slist_set_user_data_in_element( se, (void *) sts->thread_and_count++ ); - - lfds611_slist_get_next( se, &se ); - } - - return( (thread_return_t) EXIT_SUCCESS ); -} - - - - - -/****************************************************************************/ -void test_slist_delete_all_elements( void ) -{ - struct lfds611_slist_state - *ss; - - struct lfds611_slist_element - *se = NULL; - - size_t - element_count = 0; - - unsigned int - loop; - - enum lfds611_data_structure_validity - dvs = LFDS611_VALIDITY_VALID; - - /* TRD : this test creates a list of 100,000 elements - then simply calls delete_all_elements() - we then count the number of elements remaining - should be zero :-) - */ - - internal_display_test_name( "Delete all elements" ); - - lfds611_slist_new( &ss, NULL, NULL ); - - for( loop = 0 ; loop < 1000000 ; loop++ ) - lfds611_slist_new_head( ss, NULL ); - - lfds611_slist_single_threaded_physically_delete_all_elements( ss ); - - while( NULL != lfds611_slist_get_head_and_then_next(ss, &se) ) - element_count++; - - if( element_count != 0 ) - dvs = LFDS611_VALIDITY_INVALID_TEST_DATA; - - lfds611_slist_delete( ss ); - - internal_display_test_result( 1, "slist", dvs ); - - return; -} - diff --git a/openair2/UTIL/LFDS/liblfds6.1.1/test/src/test_stack.c b/openair2/UTIL/LFDS/liblfds6.1.1/test/src/test_stack.c deleted file mode 100644 index cb5916620b..0000000000 --- a/openair2/UTIL/LFDS/liblfds6.1.1/test/src/test_stack.c +++ /dev/null @@ -1,582 +0,0 @@ -#include "internal.h" - - - - - -/****************************************************************************/ -void test_lfds611_stack( void ) -{ - printf( "\n" - "Stack Tests\n" - "===========\n" ); - - stack_test_internal_popping(); - stack_test_internal_pushing(); - stack_test_internal_popping_and_pushing(); - stack_test_internal_rapid_popping_and_pushing(); - - return; -} - - - - - -/****************************************************************************/ -void stack_test_internal_popping( void ) -{ - unsigned int - loop, - *found_count, - cpu_count; - - lfds611_atom_t - count; - - thread_state_t - *thread_handles; - - enum lfds611_data_structure_validity - dvs = LFDS611_VALIDITY_VALID; - - struct lfds611_stack_state - *ss; - - struct stack_test_popping_state - *stps; - - /* TRD : we create a stack with 1,000,000 elements - - we then populate the stack, where each element is - set to contain a void pointer which is its element number - - we then run one thread per CPU - where each thread loops, popping as quickly as possible - each popped element is pushed onto a thread-local stack - - the threads run till the source stack is empty - - we then check the thread-local stacks - we should find we have every element - - then tidy up - */ - - internal_display_test_name( "Popping" ); - - cpu_count = abstraction_cpu_count(); - - lfds611_stack_new( &ss, 1000000 ); - - for( loop = 0 ; loop < 1000000 ; loop++ ) - lfds611_stack_push( ss, (void *) (lfds611_atom_t) loop ); - - stps = malloc( sizeof(struct stack_test_popping_state) * cpu_count ); - - for( loop = 0 ; loop < cpu_count ; loop++ ) { - (stps+loop)->ss = ss; - lfds611_stack_new( &(stps+loop)->ss_thread_local, 1000000 ); - } - - thread_handles = malloc( sizeof(thread_state_t) * cpu_count ); - - for( loop = 0 ; loop < cpu_count ; loop++ ) - abstraction_thread_start( &thread_handles[loop], loop, stack_test_internal_thread_popping, stps+loop ); - - for( loop = 0 ; loop < cpu_count ; loop++ ) - abstraction_thread_wait( thread_handles[loop] ); - - free( thread_handles ); - - // TRD : now we check the thread-local stacks - found_count = malloc( sizeof(unsigned int) * 1000000 ); - - for( loop = 0 ; loop < 1000000 ; loop++ ) - *(found_count+loop) = 0; - - for( loop = 0 ; loop < cpu_count ; loop++ ) - while( lfds611_stack_pop((stps+loop)->ss_thread_local, (void **) &count) ) - (*(found_count+count))++; - - for( loop = 0 ; loop < 1000000 and dvs == LFDS611_VALIDITY_VALID ; loop++ ) { - if( *(found_count+loop) == 0 ) - dvs = LFDS611_VALIDITY_INVALID_MISSING_ELEMENTS; - - if( *(found_count+loop) > 1 ) - dvs = LFDS611_VALIDITY_INVALID_ADDITIONAL_ELEMENTS; - } - - // TRD : cleanup - free( found_count ); - - for( loop = 0 ; loop < cpu_count ; loop++ ) - lfds611_stack_delete( (stps+loop)->ss_thread_local, NULL, NULL ); - - free( stps ); - lfds611_stack_delete( ss, NULL, NULL ); - - // TRD : print the test result - internal_display_test_result( 1, "stack", dvs ); - - return; -} - - - - - -/****************************************************************************/ -thread_return_t CALLING_CONVENTION stack_test_internal_thread_popping( void *stack_test_popping_state ) -{ - struct stack_test_popping_state - *stps; - - lfds611_atom_t - count; - - assert( stack_test_popping_state != NULL ); - - stps = (struct stack_test_popping_state *) stack_test_popping_state; - - lfds611_stack_use( stps->ss ); - - while( lfds611_stack_pop(stps->ss, (void **) &count) ) - lfds611_stack_push( stps->ss_thread_local, (void *) count ); - - return( (thread_return_t) EXIT_SUCCESS ); -} - - - - - -/****************************************************************************/ -void stack_test_internal_pushing( void ) -{ - unsigned int - loop, - cpu_count; - - thread_state_t - *thread_handles; - - enum lfds611_data_structure_validity - dvs[2]; - - struct stack_test_pushing_state - *stps; - - struct lfds611_stack_state - *ss; - - lfds611_atom_t - user_data, - thread, - count, - *per_thread_counters; - - struct lfds611_validation_info - vi = { 1000000, 1000000 }; - - /* TRD : we create a stack with 1,000,000 elements - - we then create one thread per CPU, where each thread - pushes as quickly as possible to the stack - - the data pushed is a counter and a thread ID - - the threads exit when the stack is full - - we then validate the stack; - - checking that the counts increment on a per unique ID basis - and that the number of elements we pop equals 1,000,000 - (since each element has an incrementing counter which is - unique on a per unique ID basis, we can know we didn't lose - any elements) - */ - - internal_display_test_name( "Pushing" ); - - cpu_count = abstraction_cpu_count(); - - stps = malloc( sizeof(struct stack_test_pushing_state) * cpu_count ); - - // TRD : the main stack - lfds611_stack_new( &ss, 1000000 ); - - for( loop = 0 ; loop < cpu_count ; loop++ ) { - (stps+loop)->thread_number = (lfds611_atom_t) loop; - (stps+loop)->ss = ss; - } - - thread_handles = malloc( sizeof(thread_state_t) * cpu_count ); - - for( loop = 0 ; loop < cpu_count ; loop++ ) - abstraction_thread_start( &thread_handles[loop], loop, stack_test_internal_thread_pushing, stps+loop ); - - for( loop = 0 ; loop < cpu_count ; loop++ ) - abstraction_thread_wait( thread_handles[loop] ); - - free( thread_handles ); - - // TRD : the stack is now fully pushed; time to verify - per_thread_counters = malloc( sizeof(lfds611_atom_t) * cpu_count ); - - for( loop = 0 ; loop < cpu_count ; loop++ ) - *(per_thread_counters+loop) = 1000000; - - lfds611_stack_query( ss, LFDS611_STACK_QUERY_VALIDATE, &vi, (void *) dvs ); - - while( dvs[0] == LFDS611_VALIDITY_VALID and lfds611_stack_pop(ss, (void **) &user_data) ) { - thread = user_data >> (sizeof(lfds611_atom_t)*8-8); - count = (user_data << 8) >> 8; - - if( thread >= cpu_count ) { - dvs[0] = LFDS611_VALIDITY_INVALID_TEST_DATA; - break; - } - - if( count > per_thread_counters[thread] ) - dvs[0] = LFDS611_VALIDITY_INVALID_ADDITIONAL_ELEMENTS; - - if( count < per_thread_counters[thread] ) - per_thread_counters[thread] = count-1; - } - - // TRD : clean up - free( per_thread_counters ); - - free( stps ); - - lfds611_stack_delete( ss, NULL, NULL ); - - // TRD : print the test result - internal_display_test_result( 2, "stack", dvs[0], "stack freelist", dvs[1] ); - - return; -} - - - - - -/****************************************************************************/ -thread_return_t CALLING_CONVENTION stack_test_internal_thread_pushing( void *stack_test_pushing_state ) -{ - struct stack_test_pushing_state - *stps; - - lfds611_atom_t - counter = 0; - - assert( stack_test_pushing_state != NULL ); - - stps = (struct stack_test_pushing_state *) stack_test_pushing_state; - - lfds611_stack_use( stps->ss ); - - // TRD : we write (thread_number | counter), where thread_number is the top 8 bits of the lfds611_atom_t - while( lfds611_stack_push(stps->ss, (void **) ((stps->thread_number << (sizeof(lfds611_atom_t)*8-8)) | counter++)) ); - - return( (thread_return_t) EXIT_SUCCESS ); -} - - - - - -/****************************************************************************/ -void stack_test_internal_popping_and_pushing( void ) -{ - unsigned int - loop, - subloop, - cpu_count; - - thread_state_t - *thread_handles; - - enum lfds611_data_structure_validity - dvs[2]; - - struct lfds611_stack_state - *ss; - - struct stack_test_popping_and_pushing_state - *stpps; - - struct lfds611_validation_info - vi; - - /* TRD : we have two threads per CPU - the threads loop for ten seconds - the first thread pushes 100000 elements then pops 100000 elements - the second thread pops 100000 elements then pushes 100000 elements - all pushes and pops go onto the single main stack - - after time is up, all threads push what they have remaining onto - the main stack - - we then validate the main stack - */ - - internal_display_test_name( "Popping and pushing (10 seconds)" ); - - cpu_count = abstraction_cpu_count(); - - // TRD : just some initial elements so the pushing threads can start immediately - lfds611_stack_new( &ss, 100000 * cpu_count * 2 ); - - for( loop = 0 ; loop < 100000 * cpu_count ; loop++ ) - lfds611_stack_push( ss, (void *) (lfds611_atom_t) loop ); - - stpps = malloc( sizeof(struct stack_test_popping_and_pushing_state) * cpu_count * 2 ); - - for( loop = 0 ; loop < cpu_count ; loop++ ) { - (stpps+loop)->ss = ss; - lfds611_stack_new( &(stpps+loop)->local_ss, 100000 ); - - (stpps+loop+cpu_count)->ss = ss; - lfds611_stack_new( &(stpps+loop+cpu_count)->local_ss, 100000 ); - - // TRD : fill the pushing thread stacks - for( subloop = 0 ; subloop < 100000 ; subloop++ ) - lfds611_stack_push( (stpps+loop+cpu_count)->local_ss, (void *) (lfds611_atom_t) subloop ); - } - - thread_handles = malloc( sizeof(thread_state_t) * cpu_count * 2 ); - - for( loop = 0 ; loop < cpu_count ; loop++ ) { - abstraction_thread_start( &thread_handles[loop], loop, stack_test_internal_thread_popping_and_pushing_start_popping, stpps+loop ); - abstraction_thread_start( &thread_handles[loop+cpu_count], loop, stack_test_internal_thread_popping_and_pushing_start_pushing, stpps+loop+cpu_count ); - } - - for( loop = 0 ; loop < cpu_count * 2 ; loop++ ) - abstraction_thread_wait( thread_handles[loop] ); - - free( thread_handles ); - - for( loop = 0 ; loop < cpu_count * 2 ; loop++ ) - lfds611_stack_delete( (stpps+loop)->local_ss, NULL, NULL ); - - free( stpps ); - - vi.min_elements = vi.max_elements = 100000 * cpu_count * 2; - - lfds611_stack_query( ss, LFDS611_STACK_QUERY_VALIDATE, (void *) &vi, (void *) dvs ); - - lfds611_stack_delete( ss, NULL, NULL ); - - // TRD : print the test result - internal_display_test_result( 2, "stack", dvs[0], "stack freelist", dvs[1] ); - - return; -} - - - - - - -/****************************************************************************/ -thread_return_t CALLING_CONVENTION stack_test_internal_thread_popping_and_pushing_start_popping( void *stack_test_popping_and_pushing_state ) -{ - struct stack_test_popping_and_pushing_state - *stpps; - - void - *user_data; - - time_t - start_time; - - unsigned int - count; - - assert( stack_test_popping_and_pushing_state != NULL ); - - stpps = (struct stack_test_popping_and_pushing_state *) stack_test_popping_and_pushing_state; - - lfds611_stack_use( stpps->ss ); - lfds611_stack_use( stpps->local_ss ); - - time( &start_time ); - - while( time(NULL) < start_time + 10 ) { - count = 0; - - while( count < 100000 ) - if( lfds611_stack_pop(stpps->ss, &user_data) ) { - lfds611_stack_push( stpps->local_ss, user_data ); - count++; - } - - // TRD : return our local stack to the main stack - while( lfds611_stack_pop(stpps->local_ss, &user_data) ) - lfds611_stack_push( stpps->ss, user_data ); - } - - return( (thread_return_t) EXIT_SUCCESS ); -} - - - - - -/****************************************************************************/ -thread_return_t CALLING_CONVENTION stack_test_internal_thread_popping_and_pushing_start_pushing( void *stack_test_popping_and_pushing_state ) -{ - struct stack_test_popping_and_pushing_state - *stpps; - - void - *user_data; - - time_t - start_time; - - unsigned int - count; - - assert( stack_test_popping_and_pushing_state != NULL ); - - stpps = (struct stack_test_popping_and_pushing_state *) stack_test_popping_and_pushing_state; - - lfds611_stack_use( stpps->ss ); - lfds611_stack_use( stpps->local_ss ); - - time( &start_time ); - - while( time(NULL) < start_time + 10 ) { - // TRD : return our local stack to the main stack - while( lfds611_stack_pop(stpps->local_ss, &user_data) ) - lfds611_stack_push( stpps->ss, user_data ); - - count = 0; - - while( count < 100000 ) - if( lfds611_stack_pop(stpps->ss, &user_data) ) { - lfds611_stack_push( stpps->local_ss, user_data ); - count++; - } - } - - // TRD : now push whatever we have in our local stack - while( lfds611_stack_pop(stpps->local_ss, &user_data) ) - lfds611_stack_push( stpps->ss, user_data ); - - return( (thread_return_t) EXIT_SUCCESS ); -} - - - - - -/****************************************************************************/ -void stack_test_internal_rapid_popping_and_pushing( void ) -{ - unsigned int - loop, - cpu_count; - - thread_state_t - *thread_handles; - - struct lfds611_stack_state - *ss; - - struct lfds611_validation_info - vi; - - enum lfds611_data_structure_validity - dvs[2]; - - /* TRD : in these tests there is a fundamental antagonism between - how much checking/memory clean up that we do and the - likelyhood of collisions between threads in their lock-free - operations - - the lock-free operations are very quick; if we do anything - much at all between operations, we greatly reduce the chance - of threads colliding - - so we have some tests which do enough checking/clean up that - they can tell the stack is valid and don't leak memory - and here, this test now is one of those which does minimal - checking - in fact, the nature of the test is that you can't - do any real checking - but goes very quickly - - what we do is create a small stack and then run one thread - per CPU, where each thread simply pushes and then immediately - pops - - the test runs for ten seconds - - after the test is done, the only check we do is to traverse - the stack, checking for loops and ensuring the number of - elements is correct - */ - - internal_display_test_name( "Rapid popping and pushing (10 seconds)" ); - - cpu_count = abstraction_cpu_count(); - - lfds611_stack_new( &ss, cpu_count ); - - thread_handles = malloc( sizeof(thread_state_t) * cpu_count ); - - for( loop = 0 ; loop < cpu_count ; loop++ ) - abstraction_thread_start( &thread_handles[loop], loop, stack_test_internal_thread_rapid_popping_and_pushing, ss ); - - for( loop = 0 ; loop < cpu_count ; loop++ ) - abstraction_thread_wait( thread_handles[loop] ); - - free( thread_handles ); - - vi.min_elements = 0; - vi.max_elements = 0; - - lfds611_stack_query( ss, LFDS611_STACK_QUERY_VALIDATE, (void *) &vi, (void *) dvs ); - - lfds611_stack_delete( ss, NULL, NULL ); - - // TRD : print the test result - internal_display_test_result( 2, "stack", dvs[0], "stack freelist", dvs[1] ); - - return; -} - - - - - -/****************************************************************************/ -thread_return_t CALLING_CONVENTION stack_test_internal_thread_rapid_popping_and_pushing( void *stack_state ) -{ - struct lfds611_stack_state - *ss; - - void - *user_data = NULL; - - time_t - start_time; - - assert( stack_state != NULL ); - - ss = (struct lfds611_stack_state *) stack_state; - - lfds611_stack_use( ss ); - - time( &start_time ); - - while( time(NULL) < start_time + 10 ) { - lfds611_stack_push( ss, user_data ); - lfds611_stack_pop( ss, &user_data ); - } - - return( (thread_return_t) EXIT_SUCCESS ); -} - diff --git a/openair2/UTIL/LFDS/liblfds6.1.1/test/test.sln b/openair2/UTIL/LFDS/liblfds6.1.1/test/test.sln deleted file mode 100644 index 3cfb5b2031..0000000000 --- a/openair2/UTIL/LFDS/liblfds6.1.1/test/test.sln +++ /dev/null @@ -1,79 +0,0 @@ - -Microsoft Visual Studio Solution File, Format Version 10.00 -# Visual Studio 2008 -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "test", "test.vcproj", "{6E4CBF20-DF1A-4FA0-8A90-58E2A3A5CF09}" - ProjectSection(ProjectDependencies) = postProject - {F73AE755-F6D8-4C3A-977D-FBB40DC0ED05} = {F73AE755-F6D8-4C3A-977D-FBB40DC0ED05} - EndProjectSection -EndProject -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "liblfds611", "..\liblfds611\liblfds611.vcproj", "{F73AE755-F6D8-4C3A-977D-FBB40DC0ED05}" -EndProject -Global - GlobalSection(SolutionConfigurationPlatforms) = preSolution - Debug DLL|Win32 = Debug DLL|Win32 - Debug DLL|x64 = Debug DLL|x64 - Debug Lib|Win32 = Debug Lib|Win32 - Debug Lib|x64 = Debug Lib|x64 - Debug|Win32 = Debug|Win32 - Debug|x64 = Debug|x64 - Release DLL|Win32 = Release DLL|Win32 - Release DLL|x64 = Release DLL|x64 - Release Lib|Win32 = Release Lib|Win32 - Release Lib|x64 = Release Lib|x64 - Release|Win32 = Release|Win32 - Release|x64 = Release|x64 - EndGlobalSection - GlobalSection(ProjectConfigurationPlatforms) = postSolution - {6E4CBF20-DF1A-4FA0-8A90-58E2A3A5CF09}.Debug DLL|Win32.ActiveCfg = Debug|Win32 - {6E4CBF20-DF1A-4FA0-8A90-58E2A3A5CF09}.Debug DLL|Win32.Build.0 = Debug|Win32 - {6E4CBF20-DF1A-4FA0-8A90-58E2A3A5CF09}.Debug DLL|x64.ActiveCfg = Debug|x64 - {6E4CBF20-DF1A-4FA0-8A90-58E2A3A5CF09}.Debug DLL|x64.Build.0 = Debug|x64 - {6E4CBF20-DF1A-4FA0-8A90-58E2A3A5CF09}.Debug Lib|Win32.ActiveCfg = Debug|Win32 - {6E4CBF20-DF1A-4FA0-8A90-58E2A3A5CF09}.Debug Lib|Win32.Build.0 = Debug|Win32 - {6E4CBF20-DF1A-4FA0-8A90-58E2A3A5CF09}.Debug Lib|x64.ActiveCfg = Debug|x64 - {6E4CBF20-DF1A-4FA0-8A90-58E2A3A5CF09}.Debug Lib|x64.Build.0 = Debug|x64 - {6E4CBF20-DF1A-4FA0-8A90-58E2A3A5CF09}.Debug|Win32.ActiveCfg = Debug|Win32 - {6E4CBF20-DF1A-4FA0-8A90-58E2A3A5CF09}.Debug|Win32.Build.0 = Debug|Win32 - {6E4CBF20-DF1A-4FA0-8A90-58E2A3A5CF09}.Debug|x64.ActiveCfg = Debug|x64 - {6E4CBF20-DF1A-4FA0-8A90-58E2A3A5CF09}.Debug|x64.Build.0 = Debug|x64 - {6E4CBF20-DF1A-4FA0-8A90-58E2A3A5CF09}.Release DLL|Win32.ActiveCfg = Release|Win32 - {6E4CBF20-DF1A-4FA0-8A90-58E2A3A5CF09}.Release DLL|Win32.Build.0 = Release|Win32 - {6E4CBF20-DF1A-4FA0-8A90-58E2A3A5CF09}.Release DLL|x64.ActiveCfg = Release|x64 - {6E4CBF20-DF1A-4FA0-8A90-58E2A3A5CF09}.Release DLL|x64.Build.0 = Release|x64 - {6E4CBF20-DF1A-4FA0-8A90-58E2A3A5CF09}.Release Lib|Win32.ActiveCfg = Release|Win32 - {6E4CBF20-DF1A-4FA0-8A90-58E2A3A5CF09}.Release Lib|Win32.Build.0 = Release|Win32 - {6E4CBF20-DF1A-4FA0-8A90-58E2A3A5CF09}.Release Lib|x64.ActiveCfg = Release|x64 - {6E4CBF20-DF1A-4FA0-8A90-58E2A3A5CF09}.Release Lib|x64.Build.0 = Release|x64 - {6E4CBF20-DF1A-4FA0-8A90-58E2A3A5CF09}.Release|Win32.ActiveCfg = Release|Win32 - {6E4CBF20-DF1A-4FA0-8A90-58E2A3A5CF09}.Release|Win32.Build.0 = Release|Win32 - {6E4CBF20-DF1A-4FA0-8A90-58E2A3A5CF09}.Release|x64.ActiveCfg = Release|x64 - {6E4CBF20-DF1A-4FA0-8A90-58E2A3A5CF09}.Release|x64.Build.0 = Release|x64 - {F73AE755-F6D8-4C3A-977D-FBB40DC0ED05}.Debug DLL|Win32.ActiveCfg = Debug DLL|Win32 - {F73AE755-F6D8-4C3A-977D-FBB40DC0ED05}.Debug DLL|Win32.Build.0 = Debug DLL|Win32 - {F73AE755-F6D8-4C3A-977D-FBB40DC0ED05}.Debug DLL|x64.ActiveCfg = Debug DLL|x64 - {F73AE755-F6D8-4C3A-977D-FBB40DC0ED05}.Debug DLL|x64.Build.0 = Debug DLL|x64 - {F73AE755-F6D8-4C3A-977D-FBB40DC0ED05}.Debug Lib|Win32.ActiveCfg = Debug Lib|Win32 - {F73AE755-F6D8-4C3A-977D-FBB40DC0ED05}.Debug Lib|Win32.Build.0 = Debug Lib|Win32 - {F73AE755-F6D8-4C3A-977D-FBB40DC0ED05}.Debug Lib|x64.ActiveCfg = Debug Lib|x64 - {F73AE755-F6D8-4C3A-977D-FBB40DC0ED05}.Debug Lib|x64.Build.0 = Debug Lib|x64 - {F73AE755-F6D8-4C3A-977D-FBB40DC0ED05}.Debug|Win32.ActiveCfg = Debug Lib|Win32 - {F73AE755-F6D8-4C3A-977D-FBB40DC0ED05}.Debug|Win32.Build.0 = Debug Lib|Win32 - {F73AE755-F6D8-4C3A-977D-FBB40DC0ED05}.Debug|x64.ActiveCfg = Debug Lib|x64 - {F73AE755-F6D8-4C3A-977D-FBB40DC0ED05}.Debug|x64.Build.0 = Debug Lib|x64 - {F73AE755-F6D8-4C3A-977D-FBB40DC0ED05}.Release DLL|Win32.ActiveCfg = Release DLL|Win32 - {F73AE755-F6D8-4C3A-977D-FBB40DC0ED05}.Release DLL|Win32.Build.0 = Release DLL|Win32 - {F73AE755-F6D8-4C3A-977D-FBB40DC0ED05}.Release DLL|x64.ActiveCfg = Release DLL|x64 - {F73AE755-F6D8-4C3A-977D-FBB40DC0ED05}.Release DLL|x64.Build.0 = Release DLL|x64 - {F73AE755-F6D8-4C3A-977D-FBB40DC0ED05}.Release Lib|Win32.ActiveCfg = Release Lib|Win32 - {F73AE755-F6D8-4C3A-977D-FBB40DC0ED05}.Release Lib|Win32.Build.0 = Release Lib|Win32 - {F73AE755-F6D8-4C3A-977D-FBB40DC0ED05}.Release Lib|x64.ActiveCfg = Release Lib|x64 - {F73AE755-F6D8-4C3A-977D-FBB40DC0ED05}.Release Lib|x64.Build.0 = Release Lib|x64 - {F73AE755-F6D8-4C3A-977D-FBB40DC0ED05}.Release|Win32.ActiveCfg = Release Lib|Win32 - {F73AE755-F6D8-4C3A-977D-FBB40DC0ED05}.Release|Win32.Build.0 = Release Lib|Win32 - {F73AE755-F6D8-4C3A-977D-FBB40DC0ED05}.Release|x64.ActiveCfg = Release Lib|x64 - {F73AE755-F6D8-4C3A-977D-FBB40DC0ED05}.Release|x64.Build.0 = Release Lib|x64 - EndGlobalSection - GlobalSection(SolutionProperties) = preSolution - HideSolutionNode = FALSE - EndGlobalSection -EndGlobal diff --git a/openair2/UTIL/LFDS/liblfds6.1.1/test/test.vcproj b/openair2/UTIL/LFDS/liblfds6.1.1/test/test.vcproj deleted file mode 100644 index 97159c86b4..0000000000 --- a/openair2/UTIL/LFDS/liblfds6.1.1/test/test.vcproj +++ /dev/null @@ -1,415 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/openair2/UTIL/LISTS/list.c b/openair2/UTIL/LISTS/list.c index 65f70c0786..578833edba 100644 --- a/openair2/UTIL/LISTS/list.c +++ b/openair2/UTIL/LISTS/list.c @@ -43,7 +43,7 @@ list_init (list_t * listP, char *nameP) { //----------------------------------------------------------------------------- if (nameP) { - strncpy( listP->name, nameP, LIST_NAME_MAX_CHAR ); + strncpy( listP->name, nameP, LIST_NAME_MAX_CHAR-1 ); listP->name[LIST_NAME_MAX_CHAR-1] = 0; // terminate string } diff --git a/openair2/UTIL/LISTS/list2.c b/openair2/UTIL/LISTS/list2.c index 3f0a59df53..d9aa1b6a90 100644 --- a/openair2/UTIL/LISTS/list2.c +++ b/openair2/UTIL/LISTS/list2.c @@ -53,7 +53,7 @@ list2_init (list2_t * listP, char *nameP) { //----------------------------------------------------------------------------- if (nameP) { - strncpy( listP->name, nameP, LIST_NAME_MAX_CHAR ); + strncpy( listP->name, nameP, LIST_NAME_MAX_CHAR-1 ); listP->name[LIST_NAME_MAX_CHAR-1] = 0; // terminate string } diff --git a/openair2/UTIL/OCG/OCG.h b/openair2/UTIL/OCG/OCG.h index 58cc7184e7..452581bb17 100644 --- a/openair2/UTIL/OCG/OCG.h +++ b/openair2/UTIL/OCG/OCG.h @@ -700,7 +700,7 @@ typedef struct { unsigned int n_frames_flag; // if set, then let the emulation goes to infinity node_function_t node_function[MAX_NUM_CCs]; node_timing_t node_timing[MAX_NUM_CCs]; - unsigned char frame_type[MAX_NUM_CCs]; //! LTE frame type (TDD=1, FDD=0). \note this should be converted to \ref lte_frame_type_t (header file reorganization needed) + unsigned char frame_type[MAX_NUM_CCs]; //! LTE frame type (TDD=1, FDD=0). \note this should be converted to \ref frame_type_t (header file reorganization needed) char *frame_type_name[MAX_NUM_CCs]; unsigned char tdd_config[MAX_NUM_CCs]; unsigned char tdd_config_S[MAX_NUM_CCs]; diff --git a/openair2/UTIL/OPT/opt.h b/openair2/UTIL/OPT/opt.h index ae6a3eb2a6..d08790a058 100644 --- a/openair2/UTIL/OPT/opt.h +++ b/openair2/UTIL/OPT/opt.h @@ -109,11 +109,14 @@ typedef enum radio_type_e { extern int opt_enabled; #define trace_pdu(x...) if (opt_enabled) trace_pdu_implementation(0, x) -#define trace_NRpdu(x...) if (opt_enabled) trace_pdu_implementation(1, x) +#define trace_NRpdu(x...) if (opt_enabled) nr_trace_pdu_implementation(1, x) void trace_pdu_implementation(int nr, int direction, uint8_t *pdu_buffer, unsigned int pdu_buffer_size, int ueid, int rntiType, int rnti, uint16_t sysFrame, uint8_t subframe, int oob_event, int oob_event_value); +void nr_trace_pdu_implementation(int nr, int direction, uint8_t *pdu_buffer, unsigned int pdu_buffer_size, + int rntiType, int rnti, uint16_t sysFrame, uint8_t subframe, + int oob_event, int oob_event_value); int init_opt(void); diff --git a/openair2/UTIL/OPT/probe.c b/openair2/UTIL/OPT/probe.c index 8731eb294a..9359c48e95 100644 --- a/openair2/UTIL/OPT/probe.c +++ b/openair2/UTIL/OPT/probe.c @@ -476,6 +476,14 @@ static void SendFrameNR(guint8 radioType, guint8 direction, guint8 rntiType, extern RAN_CONTEXT_t RC; #include /* Remote serveraddress (where Wireshark is running) */ +void nr_trace_pdu_implementation(int nr, int direction, uint8_t *pdu_buffer, unsigned int pdu_buffer_size, + int rntiType, int rnti, uint16_t sysFrameNumber, uint8_t subFrameNumber, int oob_event, + int oob_event_value) { + trace_pdu_implementation(nr, direction, pdu_buffer, pdu_buffer_size, + rnti, rntiType, rnti, sysFrameNumber, subFrameNumber, oob_event, + oob_event_value); +} + void trace_pdu_implementation(int nr, int direction, uint8_t *pdu_buffer, unsigned int pdu_buffer_size, int ueid, int rntiType, int rnti, uint16_t sysFrameNumber, uint8_t subFrameNumber, int oob_event, int oob_event_value) { diff --git a/openair2/X2AP/x2ap_eNB.c b/openair2/X2AP/x2ap_eNB.c index 2b1d19001a..a73bc0a640 100644 --- a/openair2/X2AP/x2ap_eNB.c +++ b/openair2/X2AP/x2ap_eNB.c @@ -70,8 +70,7 @@ void x2ap_eNB_register_eNB(x2ap_eNB_instance_t *instance_p, net_ip_address_t *local_ip_addr, uint16_t in_streams, uint16_t out_streams, - uint32_t enb_port_for_X2C, - int multi_sd); + uint32_t enb_port_for_X2C); static void x2ap_eNB_handle_handover_req(instance_t instance, @@ -249,20 +248,17 @@ static void x2ap_eNB_register_eNB(x2ap_eNB_instance_t *instance_p, net_ip_address_t *local_ip_addr, uint16_t in_streams, uint16_t out_streams, - uint32_t enb_port_for_X2C, - int multi_sd) { + uint32_t enb_port_for_X2C) { MessageDef *message = NULL; - sctp_new_association_req_multi_t *sctp_new_association_req = NULL; x2ap_eNB_data_t *x2ap_enb_data = NULL; DevAssert(instance_p != NULL); DevAssert(target_eNB_ip_address != NULL); - message = itti_alloc_new_message(TASK_X2AP, 0, SCTP_NEW_ASSOCIATION_REQ_MULTI); - sctp_new_association_req = &message->ittiMsg.sctp_new_association_req_multi; + message = itti_alloc_new_message(TASK_X2AP, 0, SCTP_NEW_ASSOCIATION_REQ); + sctp_new_association_req_t *sctp_new_association_req = &message->ittiMsg.sctp_new_association_req; sctp_new_association_req->port = enb_port_for_X2C; sctp_new_association_req->ppid = X2AP_SCTP_PPID; sctp_new_association_req->in_streams = in_streams; sctp_new_association_req->out_streams = out_streams; - sctp_new_association_req->multi_sd = multi_sd; memcpy(&sctp_new_association_req->remote_address, target_eNB_ip_address, sizeof(*target_eNB_ip_address)); @@ -399,8 +395,7 @@ void x2ap_eNB_handle_sctp_init_msg_multi_cnf( &instance->enb_x2_ip_address, instance->sctp_in_streams, instance->sctp_out_streams, - instance->enb_port_for_X2C, - instance->multi_sd); + instance->enb_port_for_X2C); } } @@ -645,7 +640,8 @@ void *x2ap_task(void *arg) { while (1) { itti_receive_msg(TASK_X2AP, &received_msg); - + LOG_D(X2AP, "Received message %d:%s\n", + ITTI_MSG_ID(received_msg), ITTI_MSG_NAME(received_msg)); switch (ITTI_MSG_ID(received_msg)) { case TERMINATE_MESSAGE: X2AP_WARN(" *** Exiting X2AP thread\n"); @@ -684,7 +680,6 @@ void *x2ap_task(void *arg) { case X2AP_ENDC_SGNB_ADDITION_REQ_ACK: x2ap_gNB_trigger_sgNB_add_req_ack(ITTI_MSG_DESTINATION_INSTANCE(received_msg), &X2AP_ENDC_SGNB_ADDITION_REQ_ACK(received_msg)); - LOG_I(X2AP, "Received elements for X2AP_ENDC_SGNB_ADDITION_REQ_ACK \n"); break; case X2AP_ENDC_SGNB_RECONF_COMPLETE: diff --git a/openair2/X2AP/x2ap_eNB_defs.h b/openair2/X2AP/x2ap_eNB_defs.h index 063302d03a..bd6092e0cb 100644 --- a/openair2/X2AP/x2ap_eNB_defs.h +++ b/openair2/X2AP/x2ap_eNB_defs.h @@ -172,7 +172,7 @@ typedef struct x2ap_eNB_instance_s { int32_t uplink_frequency_offset[MAX_NUM_CCs]; uint32_t Nid_cell[MAX_NUM_CCs]; int16_t N_RB_DL[MAX_NUM_CCs]; - lte_frame_type_t frame_type[MAX_NUM_CCs]; + frame_type_t frame_type[MAX_NUM_CCs]; uint32_t fdd_earfcn_DL[MAX_NUM_CCs]; uint32_t fdd_earfcn_UL[MAX_NUM_CCs]; uint32_t subframeAssignment[MAX_NUM_CCs]; diff --git a/openair3/M3AP/m3ap_MCE_defs.h b/openair3/M3AP/m3ap_MCE_defs.h index 18ad70a408..4dcb2b4db0 100644 --- a/openair3/M3AP/m3ap_MCE_defs.h +++ b/openair3/M3AP/m3ap_MCE_defs.h @@ -170,7 +170,7 @@ typedef struct m3ap_MCE_instance_s { int32_t uplink_frequency_offset[MAX_NUM_CCs]; uint32_t Nid_cell[MAX_NUM_CCs]; int16_t N_RB_DL[MAX_NUM_CCs]; - lte_frame_type_t frame_type[MAX_NUM_CCs]; + frame_type_t frame_type[MAX_NUM_CCs]; uint32_t fdd_earfcn_DL[MAX_NUM_CCs]; uint32_t fdd_earfcn_UL[MAX_NUM_CCs]; int num_cc; diff --git a/openair3/M3AP/m3ap_MME_defs.h b/openair3/M3AP/m3ap_MME_defs.h index 3b5725655d..6608587cc3 100644 --- a/openair3/M3AP/m3ap_MME_defs.h +++ b/openair3/M3AP/m3ap_MME_defs.h @@ -170,7 +170,7 @@ typedef struct m3ap_MME_instance_s { int32_t uplink_frequency_offset[MAX_NUM_CCs]; uint32_t Nid_cell[MAX_NUM_CCs]; int16_t N_RB_DL[MAX_NUM_CCs]; - lte_frame_type_t frame_type[MAX_NUM_CCs]; + frame_type_t frame_type[MAX_NUM_CCs]; uint32_t fdd_earfcn_DL[MAX_NUM_CCs]; uint32_t fdd_earfcn_UL[MAX_NUM_CCs]; int num_cc; diff --git a/openair3/NAS/NR_UE/nr_nas_msg_sim.c b/openair3/NAS/NR_UE/nr_nas_msg_sim.c index 283f3b7311..e151fec9b4 100644 --- a/openair3/NAS/NR_UE/nr_nas_msg_sim.c +++ b/openair3/NAS/NR_UE/nr_nas_msg_sim.c @@ -428,7 +428,7 @@ void generateRegistrationRequest(as_nas_info_t *initialNasMsg, int Mod_id) { size += 10; // encode the message - initialNasMsg->data = (Byte_t *)malloc(size * sizeof(Byte_t)); + initialNasMsg->data = malloc16_clear(size * sizeof(Byte_t)); registration_request_buf = initialNasMsg->data; initialNasMsg->length = mm_msg_encode(mm_msg, (uint8_t*)(initialNasMsg->data), size); diff --git a/openair3/NAS/UE/EMM/Authentication.c b/openair3/NAS/UE/EMM/Authentication.c index 850f97150a..a2762d08e8 100644 --- a/openair3/NAS/UE/EMM/Authentication.c +++ b/openair3/NAS/UE/EMM/Authentication.c @@ -178,12 +178,15 @@ int emm_proc_authentication_request(nas_user_t *user, int native_ksi, int ksi, OctetString ik = {AUTH_IK_SIZE, authentication_data->ik}; OctetString res = {AUTH_RES_SIZE, authentication_data->res}; - if (memcmp(authentication_data->rand, rand->value, AUTH_CK_SIZE) != 0) { + if ((memcmp(authentication_data->rand, rand->value, AUTH_CK_SIZE) != 0) || + (authentication_data->auth_process_started == FALSE)) { /* * There is no valid stored RAND in the ME or the stored RAND is * different from the new received value in the AUTHENTICATION - * REQUEST message + * REQUEST message OR if this is first time UE starting the + * Authentication process */ + authentication_data->auth_process_started = TRUE; OctetString auts; auts.length = 0; auts.value = (uint8_t *)malloc(AUTH_AUTS_SIZE); diff --git a/openair3/NAS/UE/EMM/Authentication.h b/openair3/NAS/UE/EMM/Authentication.h index 50b2d990aa..466d3256f3 100644 --- a/openair3/NAS/UE/EMM/Authentication.h +++ b/openair3/NAS/UE/EMM/Authentication.h @@ -18,6 +18,8 @@ typedef struct { unsigned char mac_count:2; /* MAC failure counter (#20) */ unsigned char umts_count:2; /* UMTS challenge failure counter (#26) */ unsigned char sync_count:2; /* Sync failure counter (#21) */ + unsigned char auth_process_started:1; /* Authentication started */ + unsigned char reserve:1; /* For future use, byte aligned */ } authentication_data_t; #endif diff --git a/openair3/NGAP/ngap_gNB_nas_procedures.c b/openair3/NGAP/ngap_gNB_nas_procedures.c index 3f4b7d1aa1..d7db2f70b4 100644 --- a/openair3/NGAP/ngap_gNB_nas_procedures.c +++ b/openair3/NGAP/ngap_gNB_nas_procedures.c @@ -680,24 +680,20 @@ int ngap_gNB_initial_ctxt_resp( pdusessionTransfer_p->dLQosFlowPerTNLInformation.uPTransportLayerInformation.present = NGAP_UPTransportLayerInformation_PR_gTPTunnel; - pdusessionTransfer_p->dLQosFlowPerTNLInformation.uPTransportLayerInformation.choice.gTPTunnel = (NGAP_GTPTunnel_t *)calloc(1, sizeof(NGAP_GTPTunnel_t)); - GTP_TEID_TO_ASN1(initial_ctxt_resp_p->pdusessions[i].gtp_teid, &pdusessionTransfer_p->dLQosFlowPerTNLInformation.uPTransportLayerInformation.choice.gTPTunnel->gTP_TEID); + pdusessionTransfer_p->dLQosFlowPerTNLInformation.uPTransportLayerInformation.choice.gTPTunnel = (NGAP_GTPTunnel_t *)calloc(1, sizeof(NGAP_GTPTunnel_t)); + struct NGAP_GTPTunnel *tmp=pdusessionTransfer_p->dLQosFlowPerTNLInformation.uPTransportLayerInformation.choice.gTPTunnel; + GTP_TEID_TO_ASN1(initial_ctxt_resp_p->pdusessions[i].gtp_teid, &tmp->gTP_TEID); - pdusessionTransfer_p->dLQosFlowPerTNLInformation.uPTransportLayerInformation.choice.gTPTunnel->transportLayerAddress.buf = malloc(initial_ctxt_resp_p->pdusessions[i].gNB_addr.length); + tmp->transportLayerAddress.buf = malloc(initial_ctxt_resp_p->pdusessions[i].gNB_addr.length); - memcpy(pdusessionTransfer_p->dLQosFlowPerTNLInformation.uPTransportLayerInformation.choice.gTPTunnel->transportLayerAddress.buf, + memcpy(tmp->transportLayerAddress.buf, initial_ctxt_resp_p->pdusessions[i].gNB_addr.buffer, initial_ctxt_resp_p->pdusessions[i].gNB_addr.length); - pdusessionTransfer_p->dLQosFlowPerTNLInformation.uPTransportLayerInformation.choice.gTPTunnel->transportLayerAddress.size = initial_ctxt_resp_p->pdusessions[i].gNB_addr.length; - pdusessionTransfer_p->dLQosFlowPerTNLInformation.uPTransportLayerInformation.choice.gTPTunnel->transportLayerAddress.bits_unused = 0; + tmp->transportLayerAddress.size = initial_ctxt_resp_p->pdusessions[i].gNB_addr.length; + tmp->transportLayerAddress.bits_unused = 0; - NGAP_DEBUG("initial_ctxt_resp_p: pdusession ID %ld, gnb_addr %d.%d.%d.%d, SIZE %ld \n", - item->pDUSessionID, - pdusessionTransfer_p->dLQosFlowPerTNLInformation.uPTransportLayerInformation.choice.gTPTunnel->transportLayerAddress.buf[0], - pdusessionTransfer_p->dLQosFlowPerTNLInformation.uPTransportLayerInformation.choice.gTPTunnel->transportLayerAddress.buf[1], - pdusessionTransfer_p->dLQosFlowPerTNLInformation.uPTransportLayerInformation.choice.gTPTunnel->transportLayerAddress.buf[2], - pdusessionTransfer_p->dLQosFlowPerTNLInformation.uPTransportLayerInformation.choice.gTPTunnel->transportLayerAddress.buf[3], - pdusessionTransfer_p->dLQosFlowPerTNLInformation.uPTransportLayerInformation.choice.gTPTunnel->transportLayerAddress.size); + NGAP_DEBUG("initial_ctxt_resp_p: pdusession ID %ld\n", + item->pDUSessionID); /* associatedQosFlowList. number of 1? */ for(int j=0; j < initial_ctxt_resp_p->pdusessions[i].nb_of_qos_flow; j++) { @@ -987,24 +983,25 @@ int ngap_gNB_pdusession_setup_resp(instance_t instance, pdusessionTransfer_p->dLQosFlowPerTNLInformation.uPTransportLayerInformation.present = NGAP_UPTransportLayerInformation_PR_gTPTunnel; pdusessionTransfer_p->dLQosFlowPerTNLInformation.uPTransportLayerInformation.choice.gTPTunnel = calloc(1, sizeof(struct NGAP_GTPTunnel)); + struct NGAP_GTPTunnel *tmp=pdusessionTransfer_p->dLQosFlowPerTNLInformation.uPTransportLayerInformation.choice.gTPTunnel; + GTP_TEID_TO_ASN1(pdusession_setup_resp_p->pdusessions[i].gtp_teid, &tmp->gTP_TEID); + if (pdusession_setup_resp_p->pdusessions[i].gNB_addr.length) { + tmp->transportLayerAddress.buf = malloc(pdusession_setup_resp_p->pdusessions[i].gNB_addr.length); - GTP_TEID_TO_ASN1(pdusession_setup_resp_p->pdusessions[i].gtp_teid, &pdusessionTransfer_p->dLQosFlowPerTNLInformation.uPTransportLayerInformation.choice.gTPTunnel->gTP_TEID); + memcpy(tmp->transportLayerAddress.buf, + pdusession_setup_resp_p->pdusessions[i].gNB_addr.buffer, + pdusession_setup_resp_p->pdusessions[i].gNB_addr.length); + tmp->transportLayerAddress.size = pdusession_setup_resp_p->pdusessions[i].gNB_addr.length; + tmp->transportLayerAddress.bits_unused = 0; - pdusessionTransfer_p->dLQosFlowPerTNLInformation.uPTransportLayerInformation.choice.gTPTunnel->transportLayerAddress.buf = malloc(pdusession_setup_resp_p->pdusessions[i].gNB_addr.length); - - memcpy(pdusessionTransfer_p->dLQosFlowPerTNLInformation.uPTransportLayerInformation.choice.gTPTunnel->transportLayerAddress.buf, - pdusession_setup_resp_p->pdusessions[i].gNB_addr.buffer, - pdusession_setup_resp_p->pdusessions[i].gNB_addr.length); - pdusessionTransfer_p->dLQosFlowPerTNLInformation.uPTransportLayerInformation.choice.gTPTunnel->transportLayerAddress.size = pdusession_setup_resp_p->pdusessions[i].gNB_addr.length; - pdusessionTransfer_p->dLQosFlowPerTNLInformation.uPTransportLayerInformation.choice.gTPTunnel->transportLayerAddress.bits_unused = 0; - - NGAP_DEBUG("pdusession_setup_resp_p: pdusession ID %ld, gnb_addr %d.%d.%d.%d, SIZE %ld \n", - item->pDUSessionID, - pdusessionTransfer_p->dLQosFlowPerTNLInformation.uPTransportLayerInformation.choice.gTPTunnel->transportLayerAddress.buf[0], - pdusessionTransfer_p->dLQosFlowPerTNLInformation.uPTransportLayerInformation.choice.gTPTunnel->transportLayerAddress.buf[1], - pdusessionTransfer_p->dLQosFlowPerTNLInformation.uPTransportLayerInformation.choice.gTPTunnel->transportLayerAddress.buf[2], - pdusessionTransfer_p->dLQosFlowPerTNLInformation.uPTransportLayerInformation.choice.gTPTunnel->transportLayerAddress.buf[3], - pdusessionTransfer_p->dLQosFlowPerTNLInformation.uPTransportLayerInformation.choice.gTPTunnel->transportLayerAddress.size); + NGAP_DEBUG("pdusession_setup_resp_p: pdusession ID %ld, gnb_addr %d.%d.%d.%d, SIZE %ld \n", + item->pDUSessionID, + tmp->transportLayerAddress.buf[0], + tmp->transportLayerAddress.buf[1], + tmp->transportLayerAddress.buf[2], + tmp->transportLayerAddress.buf[3], + tmp->transportLayerAddress.size); + } /* associatedQosFlowList. number of 1? */ for(int j=0; j < pdusession_setup_resp_p->pdusessions[i].nb_of_qos_flow; j++) { diff --git a/openair3/SCTP/sctp_common.h b/openair3/SCTP/sctp_common.h index ecaeebd090..024feb8b09 100644 --- a/openair3/SCTP/sctp_common.h +++ b/openair3/SCTP/sctp_common.h @@ -37,7 +37,7 @@ #if defined(ENB_MODE) # include "common/utils/LOG/log.h" # define SCTP_ERROR(x, args...) LOG_E(SCTP, x, ##args) -# define SCTP_DEBUG(x, args...) LOG_I(SCTP, x, ##args) +# define SCTP_DEBUG(x, args...) LOG_D(SCTP, x, ##args) # define SCTP_WARN(x, args...) LOG_W(SCTP, x, ##args) #else # define SCTP_ERROR(x, args...) do { fprintf(stderr, "[SCTP][E]"x, ##args); } while(0) diff --git a/openair3/SCTP/sctp_eNB_task.c b/openair3/SCTP/sctp_eNB_task.c index ab49125856..06e606e36b 100644 --- a/openair3/SCTP/sctp_eNB_task.c +++ b/openair3/SCTP/sctp_eNB_task.c @@ -318,7 +318,8 @@ sctp_handle_new_association_req_multi( assoc_id, used_address); } } else { - SCTP_DEBUG("sctp_connectx SUCCESS, used %d addresses assoc_id %d\n", + SCTP_DEBUG("sctp_connectx SUCCESS, socket %d used %d addresses assoc_id %d\n", + sd, used_address, assoc_id); } @@ -750,7 +751,7 @@ static int sctp_create_new_listener( } if (server_type) { - if ((sd = socket(PF_INET, SOCK_SEQPACKET, IPPROTO_SCTP)) < 0) { + if ((sd = socket(AF_INET, SOCK_SEQPACKET, IPPROTO_SCTP)) < 0) { SCTP_ERROR("socket: %s:%d\n", strerror(errno), errno); free(addr); return -1; @@ -822,7 +823,7 @@ static int sctp_create_new_listener( sctp_cnx = NULL; return -1; } - + SCTP_DEBUG("Created listen socket: %d\n", sd); /* Insert new element at end of list */ STAILQ_INSERT_TAIL(&sctp_cnx_list, sctp_cnx, entries); sctp_nb_cnx++; @@ -1110,11 +1111,10 @@ void *sctp_eNB_process_itti_msg(void *notUsed) /* Check if there is a packet to handle */ if (received_msg != NULL) { + LOG_D(SCTP,"Received message %d:%s\n", + ITTI_MSG_ID(received_msg), ITTI_MSG_NAME(received_msg)); switch (ITTI_MSG_ID(received_msg)) { case SCTP_INIT_MSG: { - SCTP_DEBUG("Received SCTP_INIT_MSG\n"); - - /* We received a new connection request */ if (sctp_create_new_listener( ITTI_MSG_DESTINATION_INSTANCE(received_msg), ITTI_MSG_ORIGIN_ID(received_msg), @@ -1126,11 +1126,7 @@ void *sctp_eNB_process_itti_msg(void *notUsed) break; case SCTP_INIT_MSG_MULTI_REQ: { - int multi_sd; - - SCTP_DEBUG("Received SCTP_INIT_MSG_MULTI_REQ\n"); - - multi_sd = sctp_create_new_listener( + int multi_sd = sctp_create_new_listener( ITTI_MSG_DESTINATION_INSTANCE(received_msg), ITTI_MSG_ORIGIN_ID(received_msg), &received_msg->ittiMsg.sctp_init_multi,1); diff --git a/openair3/ocp-gtpu/gtp_itf.cpp b/openair3/ocp-gtpu/gtp_itf.cpp index cc41de3550..9537f9e18a 100644 --- a/openair3/ocp-gtpu/gtp_itf.cpp +++ b/openair3/ocp-gtpu/gtp_itf.cpp @@ -17,9 +17,11 @@ extern "C" { #include #include #include -#include "openair2/SDAP/nr_sdap/nr_sdap_gnb.h" +#include "openair2/SDAP/nr_sdap/nr_sdap.h" //#include +static boolean_t is_gnb = false; + #pragma pack(1) typedef struct Gtpv1uMsgHeader { @@ -34,8 +36,35 @@ typedef struct Gtpv1uMsgHeader { teid_t teid; } __attribute__((packed)) Gtpv1uMsgHeaderT; +typedef struct Gtpv1uMsgHeaderOptFields { + uint8_t seqNum1Oct; + uint8_t seqNum2Oct; + uint8_t NPDUNum; + uint8_t NextExtHeaderType; +} __attribute__((packed)) Gtpv1uMsgHeaderOptFieldsT; + +typedef struct PDUSessionContainer { + uint8_t spare:4; + uint8_t PDU_type:4; + uint8_t QFI:6; + uint8_t RQI:1; + uint8_t PPP:1; +} __attribute__((packed)) PDUSessionContainerT; + +typedef struct Gtpv1uExtHeader { + uint8_t ExtHeaderLen; + PDUSessionContainerT pdusession_cntr; + //uint8_t NextExtHeaderType; +}__attribute__((packed)) Gtpv1uExtHeaderT; + #pragma pack() +// TS 29.281, fig 5.2.1-3 +#define PDU_SESSION_CONTAINER (0x85) +// TS 29.281, 5.2.1 +#define EXT_HDR_LNTH_OCTET_UNITS (4) +#define NO_MORE_EXT_HDRS (0) + // TS 29.060, table 7.1 defines the possible message types // here are all the possible messages (3GPP R16) #define GTP_ECHO_REQ (1) @@ -65,6 +94,8 @@ typedef struct { rnti_t rnti; ebi_t incoming_rb_id; gtpCallback callBack; + gtpCallbackSDAP callBackSDAP; + int pdusession_id; } rntiData_t; class gtpEndPoint { @@ -431,7 +462,7 @@ teid_t newGtpuCreateTunnel(instance_t instance, rnti_t rnti, int incoming_bearer auto inst=&globGtp.instances[instance]; auto it=inst->ue2te_mapping.find(rnti); - if ( it != inst->ue2te_mapping.end() ) { + if ( it != inst->ue2te_mapping.end() && it->second.bearers.find(outgoing_bearer_id) != it->second.bearers.end()) { LOG_W(GTPU,"[%ld] Create a config for a already existing GTP tunnel (rnti %x)\n", instance, rnti); inst->ue2te_mapping.erase(it); } @@ -448,6 +479,10 @@ teid_t newGtpuCreateTunnel(instance_t instance, rnti_t rnti, int incoming_bearer inst->te2ue_mapping[incoming_teid].incoming_rb_id= incoming_bearer_id; inst->te2ue_mapping[incoming_teid].callBack=callBack; + + inst->te2ue_mapping[incoming_teid].callBackSDAP = sdap_data_req; + + inst->te2ue_mapping[incoming_teid].pdusession_id = (uint8_t)outgoing_bearer_id; gtpv1u_bearer_t *tmp=&inst->ue2te_mapping[rnti].bearers[outgoing_bearer_id]; @@ -567,14 +602,14 @@ int gtpv1u_create_ngu_tunnel( const instance_t instance, create_tunnel_req->num_tunnels, create_tunnel_req->outgoing_teid[0]); tcp_udp_port_t dstport=globGtp.instances[compatInst(instance)].get_dstport(); - + is_gnb = true; for (int i = 0; i < create_tunnel_req->num_tunnels; i++) { teid_t teid=newGtpuCreateTunnel(instance, create_tunnel_req->rnti, create_tunnel_req->incoming_rb_id[i], create_tunnel_req->pdusession_id[i], create_tunnel_req->outgoing_teid[i], create_tunnel_req->dst_addr[i], dstport, - sdap_gnb_data_req); + pdcp_data_req); create_tunnel_resp->status=0; create_tunnel_resp->rnti=create_tunnel_req->rnti; create_tunnel_resp->num_tunnels=create_tunnel_req->num_tunnels; @@ -815,10 +850,28 @@ static int Gtpv1uHandleGpdu(int h, return GTPNOK; } - int offset=8; + int offset=sizeof(Gtpv1uMsgHeaderT); - if( msgHdr->E || msgHdr->S ||msgHdr->PN) - offset+=8; + uint8_t qfi = 0; + boolean_t rqi = FALSE; + + if( msgHdr->E || msgHdr->S || msgHdr->PN){ + Gtpv1uMsgHeaderOptFieldsT *msgHdrOpt = (Gtpv1uMsgHeaderOptFieldsT *)(msgBuf+offset); + offset+=sizeof(Gtpv1uMsgHeaderOptFieldsT); + if( msgHdr->E && msgHdrOpt->NextExtHeaderType == PDU_SESSION_CONTAINER){ + Gtpv1uExtHeaderT *msgHdrExt = (Gtpv1uExtHeaderT *)(msgBuf+offset); + offset+=msgHdrExt->ExtHeaderLen*EXT_HDR_LNTH_OCTET_UNITS; + qfi = msgHdrExt->pdusession_cntr.QFI; + rqi = msgHdrExt->pdusession_cntr.RQI; + + /* + * Check if the next extension header type of GTP extension header is set to 0 + * We can not put it in the struct Gtpv1uExtHeaderT because the length is dynamic. + */ + if(*(msgBuf+offset-1) != NO_MORE_EXT_HDRS) + LOG_W(GTPU, "Warning - Next extension header is not zero, handle it \n"); + } + } // This context is not good for gtp // frame, ... has no meaning @@ -843,17 +896,34 @@ static int Gtpv1uHandleGpdu(int h, const uint32_t destinationL2Id=0; pthread_mutex_unlock(&globGtp.gtp_lock); - if ( !tunnel->second.callBack(&ctxt, - srb_flag, - rb_id, - mui, - confirm, - sdu_buffer_size, - sdu_buffer, - mode, - &sourceL2Id, - &destinationL2Id) ) - LOG_E(GTPU,"[%d] down layer refused incoming packet\n", h); + if(is_gnb && qfi){ + if ( !tunnel->second.callBackSDAP(&ctxt, + srb_flag, + rb_id, + mui, + confirm, + sdu_buffer_size, + sdu_buffer, + mode, + &sourceL2Id, + &destinationL2Id, + qfi, + rqi, + tunnel->second.pdusession_id) ) + LOG_E(GTPU,"[%d] down layer refused incoming packet\n", h); + } else { + if ( !tunnel->second.callBack(&ctxt, + srb_flag, + rb_id, + mui, + confirm, + sdu_buffer_size, + sdu_buffer, + mode, + &sourceL2Id, + &destinationL2Id) ) + LOG_E(GTPU,"[%d] down layer refused incoming packet\n", h); + } LOG_D(GTPU,"[%d] Received a %d bytes packet for: teid:%x\n", h, msgBufLen-offset, diff --git a/openair3/ocp-gtpu/gtp_itf.h b/openair3/ocp-gtpu/gtp_itf.h index ba6cf0f8bb..17882ebf1e 100644 --- a/openair3/ocp-gtpu/gtp_itf.h +++ b/openair3/ocp-gtpu/gtp_itf.h @@ -20,6 +20,21 @@ typedef boolean_t (*gtpCallback)( const uint32_t *sourceL2Id, const uint32_t *destinationL2Id); +typedef boolean_t (*gtpCallbackSDAP)( + protocol_ctxt_t *ctxt_pP, + const srb_flag_t srb_flagP, + const rb_id_t rb_idP, + const mui_t muiP, + const confirm_t confirmP, + const sdu_size_t sdu_buffer_sizeP, + unsigned char *const sdu_buffer_pP, + const pdcp_transmission_mode_t modeP, + const uint32_t *sourceL2Id, + const uint32_t *destinationL2Id, + const uint8_t qfi, + const boolean_t rqi, + const int pdusession_id); + typedef struct openAddr_s { char originHost[HOST_NAME_MAX]; char originService[HOST_NAME_MAX]; diff --git a/targets/ARCH/AW2SORI/oaiori.c b/targets/ARCH/AW2SORI/oaiori.c index f79e2fad20..3c424086dd 100644 --- a/targets/ARCH/AW2SORI/oaiori.c +++ b/targets/ARCH/AW2SORI/oaiori.c @@ -101,31 +101,37 @@ static const eutra_bandentry_t eutra_bandtable[] = { uint32_t to_earfcn_DL_aw2s(int eutra_bandP, long long int dl_CarrierFreq, uint32_t bw) { uint32_t dl_CarrierFreq_by_100k = dl_CarrierFreq / 100000; - int i; + int i=0; if (eutra_bandP > 68) { printf("eutra_band %d > 68\n", eutra_bandP); exit(-1);} - for (i = 0; i < BANDTABLE_SIZE && eutra_bandtable[i].band != eutra_bandP; i++); - printf("AW2S: band %d, index %d\n",eutra_bandP, i); + + if (eutra_bandP > 0) + for (i = 0; i < BANDTABLE_SIZE && eutra_bandtable[i].band != eutra_bandP; i++); + printf("AW2S: band %d: index %d\n",eutra_bandP, i); if (i >= BANDTABLE_SIZE) { printf(" i = %d , it will trigger out-of-bounds read.\n",i); exit(-1);} - if (dl_CarrierFreq_by_100k < eutra_bandtable[i].dl_min) { - printf("Band %d, bw %u : DL carrier frequency %u .1 MHz < %u\n", - eutra_bandP, bw, dl_CarrierFreq_by_100k, - eutra_bandtable[i].dl_min); exit(-1);} + while(i - (eutra_bandtable[i].dl_max - bw)) { - printf("Band %d, bw %u : DL carrier frequency %u .1MHz > %d\n", - eutra_bandP, bw, dl_CarrierFreq_by_100k, - eutra_bandtable[i].dl_max - bw); exit(-1); } - printf("AW2S: dl_CarrierFreq_by_100k %d, dl_min %d\n",dl_CarrierFreq_by_100k,eutra_bandtable[i].dl_min); + if(dl_CarrierFreq_by_100k > + (eutra_bandtable[i].dl_max - bw)) { + printf("Band %d, bw %u : DL carrier frequency %u .1MHz > %d\n", + eutra_bandtable[i].band, bw, dl_CarrierFreq_by_100k, + eutra_bandtable[i].dl_max - bw); i++;continue; } + printf("AW2S: dl_CarrierFreq_by_100k %d, dl_min %d\n",dl_CarrierFreq_by_100k,eutra_bandtable[i].dl_min); - return (dl_CarrierFreq_by_100k - eutra_bandtable[i].dl_min + - (eutra_bandtable[i].N_OFFs_DL / 10)); + return (dl_CarrierFreq_by_100k - eutra_bandtable[i].dl_min + + (eutra_bandtable[i].N_OFFs_DL / 10)); + + } + printf("No DL band found\n"); + exit(-1); } - uint32_t to_earfcn_UL_aw2s(int eutra_bandP, long long int ul_CarrierFreq, uint32_t bw) { uint32_t ul_CarrierFreq_by_100k = ul_CarrierFreq / 100000; int i; @@ -134,6 +140,7 @@ uint32_t to_earfcn_UL_aw2s(int eutra_bandP, long long int ul_CarrierFreq, uint32 exit(-1); } + for (i = 0; i < BANDTABLE_SIZE && eutra_bandtable[i].band != eutra_bandP; i++); if(i >= BANDTABLE_SIZE) {printf("i = %d , it will trigger out-of-bounds read.\n",i); exit(-1);} @@ -221,15 +228,41 @@ int aw2s_startstreaming(openair0_device *device) { ORI_Result_e RE_result; openair0_config_t *openair0_cfg = device->openair0_cfg; + ORI_Object_s *tx0,*tx1,*tx2,*tx3,*rx0,*rx1,*rx2,*rx3; + if (openair0_cfg->nr_flag == 0 ) { + tx0= ORI_FindObject(ori, openair0_cfg->duplex_mode == duplex_mode_FDD ? ORI_ObjectType_TxEUtraFDD :ORI_ObjectType_TxEUtraTDD, 0, NULL); + tx1= (openair0_cfg->tx_num_channels > 1) ? ORI_FindObject(ori, openair0_cfg->duplex_mode == duplex_mode_FDD ?ORI_ObjectType_TxEUtraFDD : ORI_ObjectType_TxEUtraTDD, 1, NULL) : NULL; + tx2= (openair0_cfg->tx_num_channels > 2) ? ORI_FindObject(ori, openair0_cfg->duplex_mode == duplex_mode_FDD ?ORI_ObjectType_TxEUtraFDD : ORI_ObjectType_TxEUtraTDD, 2, NULL) : NULL; + tx3= (openair0_cfg->tx_num_channels > 3) ? ORI_FindObject(ori, openair0_cfg->duplex_mode == duplex_mode_FDD ?ORI_ObjectType_TxEUtraFDD : ORI_ObjectType_TxEUtraTDD, 3, NULL) : NULL; + rx0= ORI_FindObject(ori, openair0_cfg->duplex_mode == duplex_mode_FDD ?ORI_ObjectType_RxEUtraFDD : ORI_ObjectType_RxEUtraTDD, 0, NULL); + rx1= (openair0_cfg->rx_num_channels > 1) ? ORI_FindObject(ori, openair0_cfg->duplex_mode == duplex_mode_FDD ?ORI_ObjectType_RxEUtraFDD : ORI_ObjectType_RxEUtraTDD, 1, NULL) : NULL; + rx2= (openair0_cfg->rx_num_channels > 2) ? ORI_FindObject(ori, openair0_cfg->duplex_mode == duplex_mode_FDD ?ORI_ObjectType_RxEUtraFDD : ORI_ObjectType_RxEUtraTDD, 2, NULL) : NULL; + rx3= (openair0_cfg->rx_num_channels > 3) ? ORI_FindObject(ori, openair0_cfg->duplex_mode == duplex_mode_FDD ?ORI_ObjectType_RxEUtraFDD : ORI_ObjectType_RxEUtraTDD, 3, NULL) : NULL; + } else { + tx0= ORI_FindObject(ori, openair0_cfg->duplex_mode == duplex_mode_FDD ? ORI_ObjectType_TxNRFDD :ORI_ObjectType_TxNRTDD, 0, NULL); + tx1= (openair0_cfg->tx_num_channels > 1) ? ORI_FindObject(ori, openair0_cfg->duplex_mode == duplex_mode_FDD ?ORI_ObjectType_TxNRFDD : ORI_ObjectType_TxNRTDD, 1, NULL) : NULL; + tx2= (openair0_cfg->tx_num_channels > 2) ? ORI_FindObject(ori, openair0_cfg->duplex_mode == duplex_mode_FDD ?ORI_ObjectType_TxNRFDD : ORI_ObjectType_TxNRTDD, 2, NULL) : NULL; + tx3= (openair0_cfg->tx_num_channels > 3) ? ORI_FindObject(ori, openair0_cfg->duplex_mode == duplex_mode_FDD ?ORI_ObjectType_TxNRFDD : ORI_ObjectType_TxNRTDD, 3, NULL) : NULL; + rx0= ORI_FindObject(ori, openair0_cfg->duplex_mode == duplex_mode_FDD ?ORI_ObjectType_RxNRFDD : ORI_ObjectType_RxNRTDD, 0, NULL); + rx1= (openair0_cfg->rx_num_channels > 1) ? ORI_FindObject(ori, openair0_cfg->duplex_mode == duplex_mode_FDD ?ORI_ObjectType_RxNRFDD : ORI_ObjectType_RxNRTDD, 1, NULL) : NULL; + rx2= (openair0_cfg->rx_num_channels > 2) ? ORI_FindObject(ori, openair0_cfg->duplex_mode == duplex_mode_FDD ?ORI_ObjectType_RxNRFDD : ORI_ObjectType_RxNRTDD, 2, NULL) : NULL; + rx3= (openair0_cfg->rx_num_channels > 3) ? ORI_FindObject(ori, openair0_cfg->duplex_mode == duplex_mode_FDD ?ORI_ObjectType_RxNRFDD : ORI_ObjectType_RxNRTDD, 3, NULL) : NULL; - ORI_Object_s *tx0= ORI_FindObject(ori, openair0_cfg->duplex_mode == duplex_mode_FDD ? ORI_ObjectType_TxEUtraFDD :ORI_ObjectType_TxEUtraTDD, 0, NULL); - ORI_Object_s *tx1= (openair0_cfg->tx_num_channels > 1) ? ORI_FindObject(ori, openair0_cfg->duplex_mode == duplex_mode_FDD ?ORI_ObjectType_TxEUtraFDD : ORI_ObjectType_TxEUtraTDD, 1, NULL) : NULL; - ORI_Object_s *rx0= ORI_FindObject(ori, openair0_cfg->duplex_mode == duplex_mode_FDD ?ORI_ObjectType_RxEUtraFDD : ORI_ObjectType_RxEUtraTDD, 0, NULL); - ORI_Object_s *rx1= (openair0_cfg->rx_num_channels > 1) ? ORI_FindObject(ori, openair0_cfg->duplex_mode == duplex_mode_FDD ?ORI_ObjectType_RxEUtraFDD : ORI_ObjectType_RxEUtraTDD, 1, NULL) : NULL; + } ORI_Object_s *link= ORI_FindObject(ori, ORI_ObjectType_ORILink, 0, NULL); - if (tx0 == NULL || (tx1 == NULL && openair0_cfg->tx_num_channels > 1) || rx0 == NULL || (rx1 == NULL && openair0_cfg->rx_num_channels > 1) || link == NULL) return (-1); - + if (tx0 == NULL || + (tx1 == NULL && openair0_cfg->tx_num_channels > 1) || + (tx2 == NULL && openair0_cfg->tx_num_channels > 2) || + (tx3 == NULL && openair0_cfg->tx_num_channels > 3) || + rx0 == NULL || + (rx1 == NULL && openair0_cfg->rx_num_channels > 1) || + (rx2 == NULL && openair0_cfg->rx_num_channels > 2) || + (rx3 == NULL && openair0_cfg->rx_num_channels > 3) || + link == NULL) { + printf("tx0 %p, tx1 %p, tx2 %p, tx3 %p, rx0 %p, rx1 %p, rx2 %p, rx3 %p\n",tx0,tx1,tx2,tx3,rx0,rx1,rx2,rx3); + return (-1); + } /******************************************************************* * UNLOCK Link *******************************************************************/ @@ -277,6 +310,40 @@ int aw2s_startstreaming(openair0_device *device) { } printf("ORI_ObjectStateModify: %s\n", ORI_Result_Print(RE_result)); } + /******************************************************************* + * UNLOCK TX2 + *******************************************************************/ + + if (tx2) { + printf("\n\n\n========================================================\n"); + + /* Put Tx1 into service */ + result = ORI_ObjectStateModification(ori, tx2, ORI_AST_Unlocked, &RE_result); + if(result != ORI_Result_SUCCESS) + { + printf("ORI_ObjectStateModify failed with error: %s\n", ORI_Result_Print(result)); + aw2s_oricleanup(device); + return -1; + } + printf("ORI_ObjectStateModify: %s\n", ORI_Result_Print(RE_result)); + } + /******************************************************************* + * UNLOCK TX3 + *******************************************************************/ + + if (tx3) { + printf("\n\n\n========================================================\n"); + + /* Put Tx3 into service */ + result = ORI_ObjectStateModification(ori, tx1, ORI_AST_Unlocked, &RE_result); + if(result != ORI_Result_SUCCESS) + { + printf("ORI_ObjectStateModify failed with error: %s\n", ORI_Result_Print(result)); + aw2s_oricleanup(device); + return -1; + } + printf("ORI_ObjectStateModify: %s\n", ORI_Result_Print(RE_result)); + } /******************************************************************* * UNLOCK RX0 *******************************************************************/ @@ -313,16 +380,51 @@ int aw2s_startstreaming(openair0_device *device) { printf("ORI_ObjectStateModify: %s\n", ORI_Result_Print(RE_result)); } + /******************************************************************* + * UNLOCK RX2 + *******************************************************************/ + if (rx2) { + printf("\n\n\n========================================================\n"); + + /* Put Rx1 into service */ + result = ORI_ObjectStateModification(ori, rx2, ORI_AST_Unlocked, &RE_result); + if(result != ORI_Result_SUCCESS) + { + printf("ORI_ObjectStateModify failed with error: %s\n", ORI_Result_Print(result)); + aw2s_oricleanup(device); + return -1; + } + printf("ORI_ObjectStateModify: %s\n", ORI_Result_Print(RE_result)); + } + /******************************************************************* + * UNLOCK RX3 + *******************************************************************/ + if (rx3) { + printf("\n\n\n========================================================\n"); + + /* Put Rx1 into service */ + result = ORI_ObjectStateModification(ori, rx3, ORI_AST_Unlocked, &RE_result); + if(result != ORI_Result_SUCCESS) + { + printf("ORI_ObjectStateModify failed with error: %s\n", ORI_Result_Print(result)); + aw2s_oricleanup(device); + return -1; + } + printf("ORI_ObjectStateModify: %s\n", ORI_Result_Print(RE_result)); + } + /* while (rx0->fst != ORI_FST_Operational || (openair0_cfg->rx_num_channels > 1 && rx1->fst != ORI_FST_Operational) || tx0->fst != ORI_FST_Operational || (openair0_cfg->tx_num_channels > 1 && tx1->fst != ORI_FST_Operational)) - {} - + {}*/ // test RX interface uint64_t TS; - char temp_rx[1024] __attribute__((aligned(32))); + char temp_rx[2048] __attribute__((aligned(32))); int aid,r0=0,r1=(openair0_cfg->rx_num_channels > 1) ? 0 : 1; + int r2=(openair0_cfg->rx_num_channels > 2) ? 0 : 1; + int r3=(openair0_cfg->rx_num_channels > 3) ? 0 : 1; + int i; int Npackets=1024000; for (i=0;iduplex_mode == duplex_mode_FDD ? ORI_ObjectType_TxEUtraFDD : ORI_ObjectType_TxEUtraTDD}; + ORI_ObjectTypeRef_s txTypeRef = { NULL, openair0_cfg->duplex_mode == duplex_mode_FDD ? + (openair0_cfg->nr_flag == 0 ? ORI_ObjectType_TxEUtraFDD : ORI_ObjectType_TxNRFDD): + (openair0_cfg->nr_flag == 0 ? ORI_ObjectType_TxEUtraTDD : ORI_ObjectType_TxNRTDD)}; ORI_ObjectParams_u txParams; ORI_ObjectParam_e txParamList[9]; ORI_Result_e txParamResult[9]; int num_txparams; - if (openair0_cfg->duplex_mode == duplex_mode_FDD) { - txParamList[0] = ORI_ObjectParam_SigPath_antPort; - txParamList[1] = ORI_ObjectParam_SigPath_axcW; - txParamList[2] = ORI_ObjectParam_SigPath_axcB; - txParamList[3] = ORI_ObjectParam_SigPath_chanBW; - txParamList[4] = ORI_ObjectParam_SigPath_earfcn; - txParamList[5] = ORI_ObjectParam_TxSigPath_maxTxPwr; - num_txparams = 6; - } - else { - txParamList[0] = ORI_ObjectParam_SigPath_antPort; - txParamList[1] = ORI_ObjectParam_SigPath_axcW; - txParamList[2] = ORI_ObjectParam_SigPath_axcB; - txParamList[3] = ORI_ObjectParam_SigPath_chanBW; - txParamList[4] = ORI_ObjectParam_SigPath_earfcn; - txParamList[5] = ORI_ObjectParam_TxSigPath_maxTxPwr; - txParamList[6] = ORI_ObjectParam_SigPath_tddULDLConfig; - txParamList[7] = ORI_ObjectParam_SigPath_tddSpecialSFConfig; - txParamList[8] = ORI_ObjectParam_TxSigPath_tddCPLengthDL; - num_txparams = 9; - } + txParamList[0] = ORI_ObjectParam_SigPath_antPort; + txParamList[1] = ORI_ObjectParam_SigPath_axcW; + txParamList[2] = ORI_ObjectParam_SigPath_axcB; + txParamList[3] = ORI_ObjectParam_SigPath_chanBW; + txParamList[4] = (openair0_cfg->nr_flag ==0) ? ORI_ObjectParam_SigPath_earfcn : ORI_ObjectParam_SigPath_AWS_arfcn; + txParamList[5] = ORI_ObjectParam_TxSigPath_maxTxPwr; + num_txparams = 6; /* Create tx0 */ ORI_Object_s * tx0; printf("AW2S: duplex_mode %d, tx_bw %f, rx_bw %f\n",openair0_cfg->duplex_mode,openair0_cfg->tx_bw,openair0_cfg->rx_bw); - if (openair0_cfg->duplex_mode == duplex_mode_FDD) { + if (openair0_cfg->duplex_mode == duplex_mode_FDD && openair0_cfg->nr_flag == 0) { txParams.TxEUtraFDD.antPort = ORI_FindObject(ori, ORI_ObjectType_AntennaPort, 0, NULL); txParams.TxEUtraFDD.axcW = 1; txParams.TxEUtraFDD.axcB = 0; txParams.TxEUtraFDD.chanBW = openair0_cfg->tx_bw/100e3; - txParams.TxEUtraFDD.earfcn = 3350; - txParams.TxEUtraFDD.maxTxPwr = -100; + txParams.TxEUtraTDD.earfcn = to_earfcn_DL_aw2s(-1,(long long int)openair0_cfg->tx_freq[0],txParams.TxEUtraTDD.chanBW); + txParams.TxEUtraFDD.maxTxPwr = 430-((int)openair0_cfg->tx_gain[0]*10); } - else if (openair0_cfg->duplex_mode == duplex_mode_TDD) { + else if (openair0_cfg->duplex_mode == duplex_mode_FDD && openair0_cfg->nr_flag == 1) { + txParams.TxNRFDD.antPort = ORI_FindObject(ori, ORI_ObjectType_AntennaPort, 0, NULL); + txParams.TxNRFDD.axcW = 1; + txParams.TxNRFDD.axcB = 0; + txParams.TxNRFDD.chanBW = openair0_cfg->tx_bw/100e3; + + txParams.TxNRFDD.AWS_arfcn = to_nrarfcn(openair0_cfg->nr_band,(long long int)openair0_cfg->tx_freq[0],openair0_cfg->nr_scs_for_raster,(uint32_t)openair0_cfg->tx_bw); + txParams.TxNRFDD.maxTxPwr = 430-((int)openair0_cfg->tx_gain[0]*10); + } + else if (openair0_cfg->duplex_mode == duplex_mode_TDD && openair0_cfg->nr_flag == 0) { txParams.TxEUtraTDD.antPort = ORI_FindObject(ori, ORI_ObjectType_AntennaPort, 0, NULL); txParams.TxEUtraTDD.axcW = 1; txParams.TxEUtraTDD.axcB = 0; txParams.TxEUtraTDD.chanBW = openair0_cfg->tx_bw/100e3; - txParams.TxEUtraTDD.earfcn = to_earfcn_DL_aw2s(38,(long long int)openair0_cfg->tx_freq[0],txParams.TxEUtraTDD.chanBW); + txParams.TxEUtraTDD.earfcn = to_earfcn_DL_aw2s(-1,(long long int)openair0_cfg->tx_freq[0],txParams.TxEUtraTDD.chanBW); txParams.TxEUtraTDD.maxTxPwr = 430-((int)openair0_cfg->tx_gain[0]*10); - txParams.TxEUtraTDD.tddULDLConfig = 1; - txParams.TxEUtraTDD.tddSpecialSFConfig = 0; - txParams.TxEUtraTDD.tddCPLengthDL = ORI_tddCPLength_Normal; - printf("AW2S: Configuring for TDD, EARFCN %u, Power %d, BW %d\n", + printf("AW2S: Configuring for LTE TDD, EARFCN %u, Power %d, BW %d\n", txParams.TxEUtraTDD.earfcn,txParams.TxEUtraTDD.maxTxPwr,txParams.TxEUtraTDD.chanBW); } + else if (openair0_cfg->duplex_mode == duplex_mode_TDD && openair0_cfg->nr_flag == 1) { + txParams.TxNRTDD.antPort = ORI_FindObject(ori, ORI_ObjectType_AntennaPort, 0, NULL); + txParams.TxNRTDD.axcW = 1; + txParams.TxNRTDD.axcB = 0; + txParams.TxNRTDD.chanBW = openair0_cfg->tx_bw/100e3; + txParams.TxNRTDD.AWS_arfcn = to_nrarfcn(openair0_cfg->nr_band,(long long int)openair0_cfg->tx_freq[0],openair0_cfg->nr_scs_for_raster,(uint32_t)openair0_cfg->tx_bw); + txParams.TxNRTDD.maxTxPwr = 430-((int)openair0_cfg->tx_gain[0]*10); + + printf("AW2S: Configuring for NR TDD, NRARFCN %u, Power %d, BW %d\n", + txParams.TxNRTDD.AWS_arfcn,txParams.TxNRTDD.maxTxPwr,txParams.TxNRTDD.chanBW); + } else { aw2s_oricleanup(device); return -1; @@ -491,37 +606,78 @@ int aw2s_oriinit(openair0_device *device) { result = ORI_ObjectCreation(ori, txTypeRef, txParams, txParamList, num_txparams, txParamResult, &tx0, &RE_result); if(RE_result != ORI_Result_SUCCESS) { - printf("ORI_ObjectCreation (txParams0.TxEUtraFDD/TDD) failed with error: %s (%s,%s,%s,%s,%s,%s,%s,%s,%s\n", ORI_Result_Print(result), + printf("ORI_ObjectCreation (txParams0.TxEUtra/NR/FDD/TDD) failed with error: %s (%s,%s,%s,%s,%s,%s\n", ORI_Result_Print(RE_result), ORI_Result_Print(txParamResult[0]), ORI_Result_Print(txParamResult[1]), ORI_Result_Print(txParamResult[2]), ORI_Result_Print(txParamResult[3]), ORI_Result_Print(txParamResult[4]), - ORI_Result_Print(txParamResult[5]), - ORI_Result_Print(txParamResult[6]), - ORI_Result_Print(txParamResult[7]), - ORI_Result_Print(txParamResult[8])); + ORI_Result_Print(txParamResult[5])); aw2s_oricleanup(device); return -1; } - printf("ORI_ObjectCreation (txParams0.TxEUtraFDD/TDD): %s\n", ORI_Result_Print(RE_result)); + printf("ORI_ObjectCreation (txParams0.TxEUtra/NR/FDD/TDD): %s\n", ORI_Result_Print(RE_result)); /* Create tx1 */ if (openair0_cfg->tx_num_channels > 1) { ORI_Object_s * tx1; - if (openair0_cfg->duplex_mode ==duplex_mode_FDD) txParams.TxEUtraFDD.antPort = ORI_FindObject(ori, ORI_ObjectType_AntennaPort, 1, NULL); - else txParams.TxEUtraTDD.antPort = ORI_FindObject(ori, ORI_ObjectType_AntennaPort, 1, NULL); + if (openair0_cfg->duplex_mode == duplex_mode_FDD && openair0_cfg->nr_flag == 0) + txParams.TxEUtraFDD.antPort = ORI_FindObject(ori, ORI_ObjectType_AntennaPort, 1, NULL); + else if (openair0_cfg->duplex_mode == duplex_mode_FDD && openair0_cfg->nr_flag == 1) + txParams.TxNRFDD.antPort = ORI_FindObject(ori, ORI_ObjectType_AntennaPort, 1, NULL); + else if (openair0_cfg->duplex_mode == duplex_mode_TDD && openair0_cfg->nr_flag == 0) + txParams.TxEUtraTDD.antPort = ORI_FindObject(ori, ORI_ObjectType_AntennaPort, 1, NULL); + else if (openair0_cfg->duplex_mode == duplex_mode_TDD && openair0_cfg->nr_flag == 1) + txParams.TxNRTDD.antPort = ORI_FindObject(ori, ORI_ObjectType_AntennaPort, 1, NULL); result = ORI_ObjectCreation(ori, txTypeRef, txParams, txParamList, num_txparams, txParamResult, &tx1, &RE_result); if(RE_result != ORI_Result_SUCCESS) { - printf("ORI_ObjectCreation (txParams1.TxEUtraFDD/TDD) failed with error: %s\n", ORI_Result_Print(result)); + printf("ORI_ObjectCreation (txParams1.TxEUtra/NR/FDD/TDD) failed with error: %s\n", ORI_Result_Print(result)); aw2s_oricleanup(device); return -1; } - printf("ORI_ObjectCreation (txParams1.TxEUtraFDD/TDD): %s\n", ORI_Result_Print(RE_result)); + printf("ORI_ObjectCreation (txParams1.TxEUtra/NR/FDD/TDD): %s\n", ORI_Result_Print(RE_result)); } + if (openair0_cfg->tx_num_channels > 2) { + ORI_Object_s * tx2; + if (openair0_cfg->duplex_mode == duplex_mode_FDD && openair0_cfg->nr_flag == 0) + txParams.TxEUtraFDD.antPort = ORI_FindObject(ori, ORI_ObjectType_AntennaPort, 2, NULL); + else if (openair0_cfg->duplex_mode == duplex_mode_FDD && openair0_cfg->nr_flag == 1) + txParams.TxNRFDD.antPort = ORI_FindObject(ori, ORI_ObjectType_AntennaPort, 2, NULL); + else if (openair0_cfg->duplex_mode == duplex_mode_TDD && openair0_cfg->nr_flag == 0) + txParams.TxEUtraTDD.antPort = ORI_FindObject(ori, ORI_ObjectType_AntennaPort, 2, NULL); + else if (openair0_cfg->duplex_mode == duplex_mode_TDD && openair0_cfg->nr_flag == 1) + txParams.TxNRTDD.antPort = ORI_FindObject(ori, ORI_ObjectType_AntennaPort, 2, NULL); + result = ORI_ObjectCreation(ori, txTypeRef, txParams, txParamList, num_txparams, txParamResult, &tx2, &RE_result); + if(RE_result != ORI_Result_SUCCESS) + { + printf("ORI_ObjectCreation (txParams2.TxEUtra/NR/FDD/TDD) failed with error: %s\n", ORI_Result_Print(result)); + aw2s_oricleanup(device); + return -1; + } + printf("ORI_ObjectCreation (txParams2.TxEUtra/NR/FDD/TDD): %s\n", ORI_Result_Print(RE_result)); + } + if (openair0_cfg->tx_num_channels == 4) { + ORI_Object_s * tx3; + if (openair0_cfg->duplex_mode == duplex_mode_FDD && openair0_cfg->nr_flag == 0) + txParams.TxEUtraFDD.antPort = ORI_FindObject(ori, ORI_ObjectType_AntennaPort, 3, NULL); + else if (openair0_cfg->duplex_mode == duplex_mode_FDD && openair0_cfg->nr_flag == 1) + txParams.TxNRFDD.antPort = ORI_FindObject(ori, ORI_ObjectType_AntennaPort, 3, NULL); + else if (openair0_cfg->duplex_mode == duplex_mode_TDD && openair0_cfg->nr_flag == 0) + txParams.TxEUtraTDD.antPort = ORI_FindObject(ori, ORI_ObjectType_AntennaPort, 3, NULL); + else if (openair0_cfg->duplex_mode == duplex_mode_TDD && openair0_cfg->nr_flag == 1) + txParams.TxNRTDD.antPort = ORI_FindObject(ori, ORI_ObjectType_AntennaPort, 3, NULL); + result = ORI_ObjectCreation(ori, txTypeRef, txParams, txParamList, num_txparams, txParamResult, &tx3, &RE_result); + if(RE_result != ORI_Result_SUCCESS) + { + printf("ORI_ObjectCreation (txParams3.TxEUtra/NRFDD/TDD) failed with error: %s\n", ORI_Result_Print(result)); + aw2s_oricleanup(device); + return -1; + } + printf("ORI_ObjectCreation (txParams3.TxEUtra/NRFDD/TDD): %s\n", ORI_Result_Print(RE_result)); + } /******************************************************************* @@ -529,42 +685,56 @@ int aw2s_oriinit(openair0_device *device) { *******************************************************************/ /* Prepare parameters */ - ORI_ObjectTypeRef_s rxTypeRef = { NULL, openair0_cfg->duplex_mode == duplex_mode_FDD ? ORI_ObjectType_RxEUtraFDD : ORI_ObjectType_RxEUtraTDD}; - ORI_ObjectParams_u rxParams,rxParams1; - ORI_ObjectParam_e rxParamList[8] = { ORI_ObjectParam_SigPath_antPort, ORI_ObjectParam_SigPath_axcW, ORI_ObjectParam_SigPath_axcB, - ORI_ObjectParam_SigPath_chanBW, ORI_ObjectParam_SigPath_earfcn }; - ORI_Result_e rxParamResult[8]; + ORI_ObjectTypeRef_s rxTypeRef = { NULL, openair0_cfg->duplex_mode == duplex_mode_FDD ? + (openair0_cfg->nr_flag == 0 ? ORI_ObjectType_RxEUtraFDD : ORI_ObjectType_RxNRFDD ) : + (openair0_cfg->nr_flag == 0 ? ORI_ObjectType_RxEUtraTDD : ORI_ObjectType_RxNRTDD)}; + ORI_ObjectParams_u rxParams; + ORI_ObjectParam_e rxParamList[5] = { ORI_ObjectParam_SigPath_antPort, ORI_ObjectParam_SigPath_axcW, ORI_ObjectParam_SigPath_axcB, + ORI_ObjectParam_SigPath_chanBW, + openair0_cfg->nr_flag == 0 ? ORI_ObjectParam_SigPath_earfcn : ORI_ObjectParam_SigPath_AWS_arfcn}; + ORI_Result_e rxParamResult[5]; int num_rxparams = 5; - if (openair0_cfg->duplex_mode == duplex_mode_TDD) { - rxParamList[5] = ORI_ObjectParam_SigPath_tddULDLConfig; - rxParamList[6] = ORI_ObjectParam_SigPath_tddSpecialSFConfig; - rxParamList[7] = ORI_ObjectParam_RxSigPath_tddCPLengthUL; - num_rxparams = 8; - } /* Create rx0 */ ORI_Object_s * rx0; - if (openair0_cfg->duplex_mode == duplex_mode_FDD) { + if (openair0_cfg->duplex_mode == duplex_mode_FDD && openair0_cfg->nr_flag == 0) { rxParams.RxEUtraFDD.antPort = ORI_FindObject(ori, ORI_ObjectType_AntennaPort, 0, NULL); rxParams.RxEUtraFDD.axcW = 1; rxParams.RxEUtraFDD.axcB = 0; - rxParams.RxEUtraFDD.chanBW = 200; - rxParams.RxEUtraFDD.earfcn = 21350; + rxParams.RxEUtraFDD.chanBW = txParams.TxEUtraFDD.chanBW; + rxParams.RxEUtraFDD.earfcn = to_earfcn_UL_aw2s(-1,(long long int)openair0_cfg->rx_freq[0],txParams.TxEUtraFDD.chanBW); result = ORI_ObjectCreation(ori, rxTypeRef, rxParams, rxParamList, num_rxparams, rxParamResult, &rx0, &RE_result); } - else { + else if (openair0_cfg->duplex_mode == duplex_mode_FDD && openair0_cfg->nr_flag == 1) { + rxParams.RxNRFDD.antPort = ORI_FindObject(ori, ORI_ObjectType_AntennaPort, 0, NULL); + rxParams.RxNRFDD.axcW = 1; + rxParams.RxNRFDD.axcB = 0; + rxParams.RxNRFDD.chanBW = txParams.TxNRFDD.chanBW; + rxParams.RxNRFDD.AWS_arfcn = to_nrarfcn(openair0_cfg->nr_band,(long long int)openair0_cfg->rx_freq[0],openair0_cfg->nr_scs_for_raster,openair0_cfg->rx_bw); + result = ORI_ObjectCreation(ori, rxTypeRef, rxParams, rxParamList, num_rxparams, rxParamResult, &rx0, &RE_result); + } + else if (openair0_cfg->duplex_mode == duplex_mode_TDD && openair0_cfg->nr_flag == 0) { rxParams.RxEUtraTDD.antPort = ORI_FindObject(ori, ORI_ObjectType_AntennaPort, 0, NULL); rxParams.RxEUtraTDD.axcW = 1; rxParams.RxEUtraTDD.axcB = 0; rxParams.RxEUtraTDD.chanBW = txParams.TxEUtraTDD.chanBW; rxParams.RxEUtraTDD.earfcn = txParams.TxEUtraTDD.earfcn; - rxParams.RxEUtraTDD.tddULDLConfig = 1; - rxParams.RxEUtraTDD.tddSpecialSFConfig = 1; - rxParams.RxEUtraTDD.tddCPLengthUL = ORI_tddCPLength_Normal; printf("AW2S: Creating RX0 for EARFCN %d\n",rxParams.RxEUtraTDD.earfcn); result = ORI_ObjectCreation(ori, rxTypeRef, rxParams, rxParamList, num_rxparams, rxParamResult, &rx0, &RE_result); + } + else if (openair0_cfg->duplex_mode == duplex_mode_TDD && openair0_cfg->nr_flag == 1) { + rxParams.RxNRTDD.antPort = ORI_FindObject(ori, ORI_ObjectType_AntennaPort, 0, NULL); + rxParams.RxNRTDD.axcW = 1; + rxParams.RxNRTDD.axcB = 0; + rxParams.RxNRTDD.chanBW = txParams.TxNRTDD.chanBW; + rxParams.RxNRTDD.AWS_arfcn = txParams.TxNRTDD.AWS_arfcn; + + printf("AW2S: Creating RX0 for NRARFCN %d\n",rxParams.RxNRTDD.AWS_arfcn); + + result = ORI_ObjectCreation(ori, rxTypeRef, rxParams, rxParamList, num_rxparams, rxParamResult, &rx0, &RE_result); + } if(result != ORI_Result_SUCCESS) @@ -573,27 +743,78 @@ int aw2s_oriinit(openair0_device *device) { aw2s_oricleanup(device); return -1; } - printf("ORI_ObjectCreation (rxParams0.RxEUtraFDD/TDD): %s\n", ORI_Result_Print(RE_result)); + printf("ORI_ObjectCreation (rxParams0.RxEUtra/NR/FDD/TDD): %s\n", ORI_Result_Print(RE_result)); if (openair0_cfg->rx_num_channels > 1) { /* Create rx1 */ ORI_Object_s * rx1; - memcpy((void*)&rxParams1,(void*)&rxParams,sizeof(rxParams)); - if (openair0_cfg->duplex_mode == duplex_mode_FDD) rxParams1.RxEUtraFDD.antPort = ORI_FindObject(ori, ORI_ObjectType_AntennaPort, 1, NULL); - else rxParams1.RxEUtraTDD.antPort = ORI_FindObject(ori, ORI_ObjectType_AntennaPort, 1, NULL); + if (openair0_cfg->duplex_mode == duplex_mode_FDD && openair0_cfg->nr_flag == 0) + rxParams.RxEUtraFDD.antPort = ORI_FindObject(ori, ORI_ObjectType_AntennaPort, 1, NULL); + else if (openair0_cfg->duplex_mode == duplex_mode_FDD && openair0_cfg->nr_flag == 1) + rxParams.RxNRFDD.antPort = ORI_FindObject(ori, ORI_ObjectType_AntennaPort, 1, NULL); + else if (openair0_cfg->duplex_mode == duplex_mode_TDD && openair0_cfg->nr_flag == 0) + rxParams.RxEUtraTDD.antPort = ORI_FindObject(ori, ORI_ObjectType_AntennaPort, 1, NULL); + else if (openair0_cfg->duplex_mode == duplex_mode_TDD && openair0_cfg->nr_flag == 1) + rxParams.RxNRTDD.antPort = ORI_FindObject(ori, ORI_ObjectType_AntennaPort, 1, NULL); - result = ORI_ObjectCreation(ori, rxTypeRef, rxParams1, rxParamList, num_rxparams, rxParamResult, &rx1, &RE_result); + result = ORI_ObjectCreation(ori, rxTypeRef, rxParams, rxParamList, num_rxparams, rxParamResult, &rx1, &RE_result); if(result != ORI_Result_SUCCESS) { - printf("ORI_ObjectCreation (rxParams1.RxEUtraFDD/TDD) failed with error: %s\n", ORI_Result_Print(result)); + printf("ORI_ObjectCreation (rxParams1.RxEUtra/NR/FDD/TDD) failed with error: %s\n", ORI_Result_Print(result)); aw2s_oricleanup(device); return -1; } - printf("ORI_ObjectCreation (rxParams1.RxEUtraFDD/TDD): %s\n", ORI_Result_Print(RE_result)); + printf("ORI_ObjectCreation (rxParams1.RxEUtra/NR/FDD/TDD): %s\n", ORI_Result_Print(RE_result)); } + if (openair0_cfg->rx_num_channels > 2) { + /* Create rx2 */ + ORI_Object_s * rx2; + if (openair0_cfg->duplex_mode == duplex_mode_FDD && openair0_cfg->nr_flag == 0) + rxParams.RxEUtraFDD.antPort = ORI_FindObject(ori, ORI_ObjectType_AntennaPort, 2, NULL); + else if (openair0_cfg->duplex_mode == duplex_mode_FDD && openair0_cfg->nr_flag == 1) + rxParams.RxNRFDD.antPort = ORI_FindObject(ori, ORI_ObjectType_AntennaPort, 2, NULL); + else if (openair0_cfg->duplex_mode == duplex_mode_TDD && openair0_cfg->nr_flag == 0) + rxParams.RxEUtraTDD.antPort = ORI_FindObject(ori, ORI_ObjectType_AntennaPort, 2, NULL); + else if (openair0_cfg->duplex_mode == duplex_mode_TDD && openair0_cfg->nr_flag == 1) + rxParams.RxNRTDD.antPort = ORI_FindObject(ori, ORI_ObjectType_AntennaPort, 2, NULL); + + result = ORI_ObjectCreation(ori, rxTypeRef, rxParams, rxParamList, num_rxparams, rxParamResult, &rx2, &RE_result); + + + if(result != ORI_Result_SUCCESS) + { + printf("ORI_ObjectCreation (rxParams2.RxEUtra/NR/FDD/TDD) failed with error: %s\n", ORI_Result_Print(result)); + aw2s_oricleanup(device); + return -1; + } + printf("ORI_ObjectCreation (rxParams2.RxEUtra/NR/FDD/TDD): %s\n", ORI_Result_Print(RE_result)); + } + if (openair0_cfg->rx_num_channels > 3) { + /* Create rx3 */ + ORI_Object_s * rx3; + if (openair0_cfg->duplex_mode == duplex_mode_FDD && openair0_cfg->nr_flag == 0) + rxParams.RxEUtraFDD.antPort = ORI_FindObject(ori, ORI_ObjectType_AntennaPort, 3, NULL); + else if (openair0_cfg->duplex_mode == duplex_mode_FDD && openair0_cfg->nr_flag == 1) + rxParams.RxNRFDD.antPort = ORI_FindObject(ori, ORI_ObjectType_AntennaPort, 3, NULL); + else if (openair0_cfg->duplex_mode == duplex_mode_TDD && openair0_cfg->nr_flag == 0) + rxParams.RxEUtraTDD.antPort = ORI_FindObject(ori, ORI_ObjectType_AntennaPort, 3, NULL); + else if (openair0_cfg->duplex_mode == duplex_mode_TDD && openair0_cfg->nr_flag == 1) + rxParams.RxNRTDD.antPort = ORI_FindObject(ori, ORI_ObjectType_AntennaPort, 3, NULL); + + result = ORI_ObjectCreation(ori, rxTypeRef, rxParams, rxParamList, num_rxparams, rxParamResult, &rx3, &RE_result); + + + if(result != ORI_Result_SUCCESS) + { + printf("ORI_ObjectCreation (rxParams3.RxEUtra/NR/FDD/TDD) failed with error: %s\n", ORI_Result_Print(result)); + aw2s_oricleanup(device); + return -1; + } + printf("ORI_ObjectCreation (rxParams3.RxEUtra/NR/FDD/TDD): %s\n", ORI_Result_Print(RE_result)); + } /* Create link */ ORI_ObjectParams_u linkParams; @@ -609,14 +830,14 @@ int aw2s_oriinit(openair0_device *device) { result = ORI_ObjectParamModify(ori,link,linkParams,linkParamList,3,linkParamResult,&RE_result); if(result != ORI_Result_SUCCESS) { - printf("ORI_ObjectParamModify (linkParams) failed with error: %s\n", ORI_Result_Print(result)); + printf("ORI_ObjectParamModify (linkParams) failed with error: %s\n", ORI_Result_Print(RE_result)); aw2s_oricleanup(device); return -1; } result = ORI_ObjectStateModification(ori, link, ORI_AST_Locked, &RE_result); if(result != ORI_Result_SUCCESS) { - printf("ORI_ObjectStateModify failed with error: %s\n", ORI_Result_Print(result)); + printf("ORI_ObjectStateModify failed with error: %s\n", ORI_Result_Print(RE_result)); aw2s_oricleanup(device); return -1; } @@ -632,7 +853,7 @@ int aw2s_oriinit(openair0_device *device) { result = ORI_ObjectParamReport(ori, NULL, 0, ORI_ObjectParam_All, &RE_result); if(result != ORI_Result_SUCCESS) { - printf("ORI_ObjectParamReport failed with error: %s\n", ORI_Result_Print(result)); + printf("ORI_ObjectParamReport failed with error: %s\n", ORI_Result_Print(RE_result)); aw2s_oricleanup(device); return -1; } @@ -651,7 +872,7 @@ int aw2s_oriinit(openair0_device *device) { result = ORI_ObjectStateReport(ori, NULL, 0, ORI_StateType_All, ORI_EventDrivenReport_True, &RE_result); if(result != ORI_Result_SUCCESS) { - printf("ORI_ObjectStateReport failed with error: %s\n", ORI_Result_Print(result)); + printf("ORI_ObjectStateReport failed with error: %s\n", ORI_Result_Print(RE_result)); aw2s_oricleanup(device); return -1; } @@ -675,7 +896,7 @@ int aw2s_oriinit(openair0_device *device) { result = ORI_ObjectFaultReport(ori, NULL, 0, ORI_EventDrivenReport_True, &RE_result); if(result != ORI_Result_SUCCESS) { - printf("ORI_ObjectFaultReport failed with error: %s\n", ORI_Result_Print(result)); + printf("ORI_ObjectFaultReport failed with error: %s\n", ORI_Result_Print(RE_result)); aw2s_oricleanup(device); return -1; } diff --git a/targets/ARCH/AW2SORI/ori.h b/targets/ARCH/AW2SORI/ori.h index d4a4f2cbbf..3650d15ec6 100644 --- a/targets/ARCH/AW2SORI/ori.h +++ b/targets/ARCH/AW2SORI/ori.h @@ -2,8 +2,8 @@ * @file ori.h * @brief Open Radio Interface (ORI) C library header file. * @author AW2S (http://www.aw2s.com) -* @version 1.6 -* @date July 29, 2019 +* @version 1.8 +* @date January 18, 2022 * * This file is the AW2S REC ORI C library header, and contains all necessary * functions prototypes, enumerations, data structures and type definitions @@ -14,7 +14,7 @@ #define ORI_H_ #define ORILIB_VERSION_MAJOR 1 -#define ORILIB_VERSION_MINOR 6 +#define ORILIB_VERSION_MINOR 8 #include @@ -144,10 +144,14 @@ typedef enum ORI_ObjectType_TxEUtraFDD, /**< */ ORI_ObjectType_TxEUtraTDD, /**< */ ORI_ObjectType_TxGSM, /**< */ + ORI_ObjectType_TxNRFDD, /**< */ + ORI_ObjectType_TxNRTDD, /**< */ ORI_ObjectType_RxUtra, /**< */ ORI_ObjectType_RxEUtraFDD, /**< */ ORI_ObjectType_RxEUtraTDD, /**< */ ORI_ObjectType_RxGSM, /**< */ + ORI_ObjectType_RxNRFDD, /**< */ + ORI_ObjectType_RxNRTDD, /**< */ ORI_ObjectType_ORILink, /**< */ ORI_ObjectType_ExternalEventPort, /**< */ ORI_ObjectType_AISGPort, /**< */ @@ -223,6 +227,7 @@ typedef enum ORI_ObjectParam_SigPath_AWS_enableCompBitChange, /**< */ ORI_ObjectParam_SigPath_AWS_measuredPwr, /**< */ ORI_ObjectParam_SigPath_AWS_axcIncr, /**< */ + ORI_ObjectParam_SigPath_AWS_arfcn, /**< */ ORI_ObjectParam_TxSigPath_t2a, /**< */ ORI_ObjectParam_TxSigPath_maxTxPwr, /**< */ ORI_ObjectParam_TxSigPath_dlCalRE, /**< */ @@ -252,12 +257,12 @@ typedef enum ORI_ObjectParam_ORILink_AWS_localMAC, /**< */ ORI_ObjectParam_ORILink_AWS_remoteMAC, /**< */ ORI_ObjectParam_ORILink_AWS_t14, /**< */ + ORI_ObjectParam_ORILink_AWS_sfpTxPow, /**< */ + ORI_ObjectParam_ORILink_AWS_sfpRxPow, /**< */ ORI_ObjectParam_ORILink_AWS_remoteIP, /**< */ ORI_ObjectParam_ORILink_AWS_localIP, /**< */ ORI_ObjectParam_ORILink_AWS_remoteUdpPort, /**< */ ORI_ObjectParam_ORILink_AWS_localUdpPort, /**< */ - ORI_ObjectParam_ORILink_AWS_sfpTxPow, /**< */ - ORI_ObjectParam_ORILink_AWS_sfpRxPow, /**< */ ORI_ObjectParam_AISGPort_busPowerEnable, /**< */ ORI_ObjectParam_AISGALD_deviceType, /**< */ ORI_ObjectParam_AISGALD_UID, /**< */ @@ -1146,6 +1151,50 @@ typedef struct ORI_Boolean_e AWS_enPeakCancel; /**< RW-Locked. AW2S Vendor specific: Peak-Cancellation CFR enablement. */ } ORI_ObjectParams_TxSigPathGSM_s; +/** + * @struct ORI_ObjectParams_TxSigPathNRFDD_s + * @brief Structure containing the parameters of a TxSigPath NRFDD object. + */ +typedef struct +{ + uint16_t chanBW; /**< RW-Locked. Channel bandwith in MHz/10. */ + uint16_t dlCalREMax; /**< RO. Max possible buffer in RE for DL timing calibration in Tc/16.*/ + uint32_t t2a; /**< RO. RE time delay. */ + uint16_t dlCalRE; /**< RW-Locked. Time delay to enable DL timing calibration in Tc/16. */ + int16_t maxTxPwr; /**< RW. Max tx power for this path, unit is dBm/10 (e.g. 400 for 40 dBm). */ + uint8_t axcW; /**< RW-Locked. AxC W parameter. */ + uint8_t axcB; /**< RW-Locked. AxC B parameter. */ + ORI_Object_s * oriLink; /**< RW-Locked. ORI Link on which the AxC is mapped. */ + ORI_Object_s * antPort; /**< RW-Locked. Reference Antenna port for this signal. */ + ORI_Boolean_e AWS_enableCompRateChange; /**< RW-Locked. AW2S Vendor specific: Enable IQ data compression sample rate change. */ + int16_t AWS_measuredPwr; /**< RO. AW2S Vendor specific: Measured Tx power for this path, unit is dBm/10 (e.g. 400 for 40 dBm). */ + uint16_t AWS_axcIncr; /**< RW-Locked. AW2S Vendor specific: AxC increment for each sample, 0 means auto (= packed, no interleaving). */ + ORI_Boolean_e AWS_enPeakCancel; /**< RW-Locked. AW2S Vendor specific: Peak-Cancellation CFR enablement. */ + uint32_t AWS_arfcn; /**< RW-Locked. ARFCN of the NR carrier. */ +} ORI_ObjectParams_TxSigPathNRFDD_s; + +/** + * @struct ORI_ObjectParams_TxSigPathNRTDD_s + * @brief Structure containing the parameters of a TxSigPath NRTDD object. + */ +typedef struct +{ + uint16_t chanBW; /**< RW-Locked. Channel bandwith in MHz/10. */ + uint16_t dlCalREMax; /**< RO. Max possible buffer in RE for DL timing calibration in Tc/16.*/ + uint32_t t2a; /**< RO. RE time delay. */ + uint16_t dlCalRE; /**< RW-Locked. Time delay to enable DL timing calibration in Tc/16. */ + int16_t maxTxPwr; /**< RW. Max tx power for this path, unit is dBm/10 (e.g. 400 for 40 dBm). */ + uint8_t axcW; /**< RW-Locked. AxC W parameter. */ + uint8_t axcB; /**< RW-Locked. AxC B parameter. */ + ORI_Object_s * oriLink; /**< RW-Locked. ORI Link on which the AxC is mapped. */ + ORI_Object_s * antPort; /**< RW-Locked. Reference Antenna port for this signal. */ + ORI_Boolean_e AWS_enableCompRateChange; /**< RW-Locked. AW2S Vendor specific: Enable IQ data compression sample rate change. */ + int16_t AWS_measuredPwr; /**< RO. AW2S Vendor specific: Measured Tx power for this path, unit is dBm/10 (e.g. 400 for 40 dBm). */ + uint16_t AWS_axcIncr; /**< RW-Locked. AW2S Vendor specific: AxC increment for each sample, 0 means auto (= packed, no interleaving). */ + ORI_Boolean_e AWS_enPeakCancel; /**< RW-Locked. AW2S Vendor specific: Peak-Cancellation CFR enablement. */ + uint32_t AWS_arfcn; /**< RW-Locked. ARFCN of the NR carrier. */ +} ORI_ObjectParams_TxSigPathNRTDD_s; + /** * @struct ORI_ObjectParams_RxSigPathUtra_s * @brief Structure containing the parameters of a RxSigPath UTRAFDD object. @@ -1239,6 +1288,48 @@ typedef struct uint16_t AWS_axcIncr; /**< RW-Locked. AW2S Vendor specific: AxC increment for each sample, 0 means auto (= packed, no interleaving). */ } ORI_ObjectParams_RxSigPathGSM_s; +/** + * @struct ORI_ObjectParams_RxSigPathNRFDD_s + * @brief Structure containing the parameters of a RxSigPath NRFDD object. + * + */ +typedef struct +{ + uint16_t chanBW; /**< RW-Locked. Channel bandwith in MHz/10. */ + uint16_t ulCalREMax; /**< RO. Max possible buffer in RE for UL timing calibration in Tc/2.*/ + uint32_t ta3; /**< RO. RE time delay. */ + uint16_t ulCalRE; /**< RW-Locked. Time delay to enable UL timing calibration in Tc/2. */ + uint8_t axcW; /**< RW-Locked. AxC W parameter. */ + uint8_t axcB; /**< RW-Locked. AxC B parameter. */ + ORI_Object_s * oriLink; /**< RW-Locked. ORI Link on which the AxC is mapped. */ + ORI_Object_s * antPort; /**< RW-Locked. Reference Antenna port for this signal. */ + ORI_Boolean_e AWS_enableCompRateChange; /**< RW-Locked. AW2S Vendor specific: Enable IQ data compression sample rate change. */ + int16_t AWS_measuredPwr; /**< RO. AW2S Vendor specific: Measured Rx power for this path, unit is dBm/10 (e.g. -650 for -65 dBm). */ + uint16_t AWS_axcIncr; /**< RW-Locked. AW2S Vendor specific: AxC increment for each sample, 0 means auto (= packed, no interleaving). */ + uint32_t AWS_arfcn; /**< RW-Locked. ARFCN of the NR carrier. */ +} ORI_ObjectParams_RxSigPathNRFDD_s; + +/** + * @struct ORI_ObjectParams_RxSigPathNRTDD_s + * @brief Structure containing the parameters of a RxSigPath NRTDD object. + * + */ +typedef struct +{ + uint16_t chanBW; /**< RW-Locked. Channel bandwith in MHz/10. */ + uint16_t ulCalREMax; /**< RO. Max possible buffer in RE for UL timing calibration in Tc/2.*/ + uint32_t ta3; /**< RO. RE time delay. */ + uint16_t ulCalRE; /**< RW-Locked. Time delay to enable UL timing calibration in Tc/2. */ + uint8_t axcW; /**< RW-Locked. AxC W parameter. */ + uint8_t axcB; /**< RW-Locked. AxC B parameter. */ + ORI_Object_s * oriLink; /**< RW-Locked. ORI Link on which the AxC is mapped. */ + ORI_Object_s * antPort; /**< RW-Locked. Reference Antenna port for this signal. */ + ORI_Boolean_e AWS_enableCompRateChange; /**< RW-Locked. AW2S Vendor specific: Enable IQ data compression sample rate change. */ + int16_t AWS_measuredPwr; /**< RO. AW2S Vendor specific: Measured Rx power for this path, unit is dBm/10 (e.g. -650 for -65 dBm). */ + uint16_t AWS_axcIncr; /**< RW-Locked. AW2S Vendor specific: AxC increment for each sample, 0 means auto (= packed, no interleaving). */ + uint32_t AWS_arfcn; /**< RW-Locked. ARFCN of the NR carrier. */ +} ORI_ObjectParams_RxSigPathNRTDD_s; + /** * @struct ORI_ObjectParams_ORILink_s * @brief Structure containing the parameters of an ORI Link object. @@ -1258,12 +1349,12 @@ typedef struct uint8_t AWS_localMAC[6]; /**< R0. AW2S Vendor specific: Local MAC address of the ORI link. */ uint8_t AWS_remoteMAC[6]; /**< RW. AW2S Vendor specific: Remote MAC address of the ORI link. */ uint32_t AWS_t14; /**< RO. AW2S Vendor specific: CPRI time delay component. */ - uint8_t AWS_remoteIP[4]; /**< RW. AW2S Vendor specific: REC IP for ECPRI Ethernet frame */ - uint8_t AWS_localIP[4]; /**< R0. AW2S Vendor specific: RE IP for ECPRI Ethernet frame */ - uint16_t AWS_remoteUdpPort; /**< RW. AW2S Vendor specific: REC Udp Port for ECPRI Ethernet frame */ - uint16_t AWS_localUdpPort; /**< R0. AW2S Vendor specific: RE Udp Port for ECPRI Ethernet frame */ uint32_t AWS_sfpTxPow; /**< RO. AW2S Vendor specific: SFP Tx power. */ uint32_t AWS_sfpRxPow; /**< RO. AW2S Vendor specific: SFP Rx power. */ + uint8_t AWS_remoteIP[4]; /**< RW. AW2S Vendor specific: IP of REC for ECPRI Ethernet frame */ + uint8_t AWS_localIP[4]; /**< RW. AW2S Vendor specific: IP of RE for ECPRI Ethernet frame */ + uint16_t AWS_remoteUdpPort; /**< RW. AW2S Vendor specific: UDP port of REC for ECPRI Ethernet frame */ + uint16_t AWS_localUdpPort; /**< RO. AW2S Vendor specific: UDP port of RE for ECPRI Ethernet frame */ } ORI_ObjectParams_ORILink_s; /** @@ -1393,10 +1484,14 @@ typedef union ORI_ObjectParams_TxSigPathEUtraFDD_s TxEUtraFDD; /**< Parameters for ::ORI_ObjectType_TxEUtraFDD. */ ORI_ObjectParams_TxSigPathEUtraTDD_s TxEUtraTDD; /**< Parameters for ::ORI_ObjectType_TxEUtraTDD. */ ORI_ObjectParams_TxSigPathGSM_s TxGSM; /**< Parameters for ::ORI_ObjectType_TxGSM. */ + ORI_ObjectParams_TxSigPathNRFDD_s TxNRFDD; /**< Parameters for ::ORI_ObjectType_TxNRFDD. */ + ORI_ObjectParams_TxSigPathNRTDD_s TxNRTDD; /**< Parameters for ::ORI_ObjectType_TxNRTDD. */ ORI_ObjectParams_RxSigPathUtra_s RxUtra; /**< Parameters for ::ORI_ObjectType_RxUtra. */ ORI_ObjectParams_RxSigPathEUtraFDD_s RxEUtraFDD; /**< Parameters for ::ORI_ObjectType_RxEUtraFDD. */ ORI_ObjectParams_RxSigPathEUtraTDD_s RxEUtraTDD; /**< Parameters for ::ORI_ObjectType_RxEUtraTDD. */ ORI_ObjectParams_RxSigPathGSM_s RxGSM; /**< Parameters for ::ORI_ObjectType_RxGSM. */ + ORI_ObjectParams_RxSigPathNRFDD_s RxNRFDD; /**< Parameters for ::ORI_ObjectType_RxNRFDD. */ + ORI_ObjectParams_RxSigPathNRTDD_s RxNRTDD; /**< Parameters for ::ORI_ObjectType_RxNRTDD. */ ORI_ObjectParams_ORILink_s ORILink; /**< Parameters for ::ORI_ObjectType_ORILink. */ ORI_ObjectParams_ExternalEventPort_s ExternalEventPort; /**< Parameters for ::ORI_ObjectType_ExternalEventPort. */ ORI_ObjectParams_AISGPort_s AISGPort; /**< Parameters for ::ORI_ObjectType_AISGPort. */ diff --git a/targets/ARCH/COMMON/common_lib.c b/targets/ARCH/COMMON/common_lib.c index c4f4e3ead5..4d681b8d62 100644 --- a/targets/ARCH/COMMON/common_lib.c +++ b/targets/ARCH/COMMON/common_lib.c @@ -43,16 +43,31 @@ //#include "targets/RT/USER/lte-softmodem.h" #include "executables/softmodem-common.h" -char *get_devname(int devtype) { -char *devnames[MAX_RF_DEV_TYPE]=DEVTYPE_NAMES; +const char* devtype_names[MAX_RF_DEV_TYPE] = { + "", + "EXMIMO", + "USRP B200", + "USRP X300", + "USRP N300", + "USRP X400", + "BLADERF", + "LMSSDR", + "IRIS", + "No HW", + "ADRV9371_ZC706", + "UEDv2", + "RFSIMULATOR" +}; + +const char *get_devname(int devtype) { if (devtype < MAX_RF_DEV_TYPE && devtype !=MIN_RF_DEV_TYPE ) - return devnames[devtype]; + return devtype_names[devtype]; return "none"; } int set_device(openair0_device *device) { - char *devname = get_devname(device->type); + const char *devname = get_devname(device->type); if (strcmp(devname,"none") != 0) { LOG_I(HW,"[%s] has loaded %s device.\n",((device->host_type == RAU_HOST) ? "RAU": "RRU"),devname); } else { @@ -101,9 +116,6 @@ int load_lib(openair0_device *device, deflibname=OAI_IQPLAYER_LIBNAME; shlib_fdesc[0].fname="device_init"; set_softmodem_optmask(SOFTMODEM_RECPLAY_BIT); // softmodem has to know we use the iqplayer to workaround randomized algorithms - } else if ( IS_SOFTMODEM_BASICSIM ) { - deflibname=OAI_BASICSIM_LIBNAME; - shlib_fdesc[0].fname="device_init"; } else if (IS_SOFTMODEM_RFSIM && flag == RAU_LOCAL_RADIO_HEAD) { deflibname=OAI_RFSIM_LIBNAME; shlib_fdesc[0].fname="device_init"; diff --git a/targets/ARCH/COMMON/common_lib.h b/targets/ARCH/COMMON/common_lib.h index 0c71a9999a..78acc373ee 100644 --- a/targets/ARCH/COMMON/common_lib.h +++ b/targets/ARCH/COMMON/common_lib.h @@ -46,8 +46,6 @@ #define OAI_THIRDPARTY_TP_LIBNAME "thirdparty_transpro" /* name of shared library implementing the rf simulator */ #define OAI_RFSIM_LIBNAME "rfsimulator" -/* name of shared library implementing the basic simulator */ -#define OAI_BASICSIM_LIBNAME "tcp_bridge_oai" /* name of shared library implementing the iq player */ #define OAI_IQPLAYER_LIBNAME "oai_iqplayer" @@ -92,6 +90,8 @@ typedef enum { USRP_X300_DEV, /*!\brief device is USRP N300/N310*/ USRP_N300_DEV, + /*!\brief device is USRP X400/X410*/ + USRP_X400_DEV, /*!\brief device is BLADE RF*/ BLADERF_DEV, /*!\brief device is LMSSDR (SoDeRa)*/ @@ -107,7 +107,9 @@ typedef enum { RFSIMULATOR, MAX_RF_DEV_TYPE } dev_type_t; -#define DEVTYPE_NAMES {"","EXMIMO","USRP B200","USRP X300","USRP N300","BLADERF","LMSSDR","IRIS","No HW","ADRV9371_ZC706","UEDv2", "RFSIMULATOR"} +/* list of names of devices, needs to match dev_type_t */ +extern const char* devtype_names[MAX_RF_DEV_TYPE]; + /*!\brief transport protocol types */ typedef enum { @@ -186,6 +188,7 @@ typedef struct { //! \brief Center frequency in Hz for TX. //! index: [0..rx_num_channels[ !!! see lte-ue.c:427 FIXME iterates over rx_num_channels double tx_freq[4]; + double tune_offset; //! \brief memory //! \brief Pointer to Calibration table for RX gains rx_gain_calib_table_t *rx_gain_calib_table; @@ -237,6 +240,12 @@ typedef struct { double tx_sample_rate; //! check for threequarter sampling rate int8_t threequarter_fs; + //! Flag to indicate this configuration is for NR + int nr_flag; + //! NR band number + int nr_band; + //! NR scs for raster + int nr_scs_for_raster; } openair0_config_t; /*! \brief RF mapping */ @@ -535,7 +544,7 @@ extern "C" /*! \brief get device name from device type */ -char *get_devname(int devtype); +const char *get_devname(int devtype); /*! \brief Initialize openair RF target. It returns 0 if OK */ int openair0_device_load(openair0_device *device, openair0_config_t *openair0_cfg); /*! \brief Initialize transport protocol . It returns 0 if OK */ diff --git a/targets/ARCH/USRP/USERSPACE/LIB/usrp_lib.cpp b/targets/ARCH/USRP/USERSPACE/LIB/usrp_lib.cpp index e3b06a6438..8976284345 100644 --- a/targets/ARCH/USRP/USERSPACE/LIB/usrp_lib.cpp +++ b/targets/ARCH/USRP/USERSPACE/LIB/usrp_lib.cpp @@ -273,18 +273,20 @@ static int sync_to_gps(openair0_device *device) { static int trx_usrp_start(openair0_device *device) { usrp_state_t *s = (usrp_state_t *)device->priv; - // setup GPIO for TDD, GPIO(4) = ATR_RX - //set data direction register (DDR) to output - s->usrp->set_gpio_attr("FP0", "DDR", 0xfff, 0xfff); - //set lower 7 bits to be controlled automatically by ATR (the rest 5 bits are controlled manually) - s->usrp->set_gpio_attr("FP0", "CTRL", 0x7f,0xfff); - //set pins 4 (RX_TX_Switch) and 6 (Shutdown PA) to 1 when the radio is only receiving (ATR_RX) - s->usrp->set_gpio_attr("FP0", "ATR_RX", (1<<4)|(1<<6), 0x7f); - // set pin 5 (Shutdown LNA) to 1 when the radio is transmitting and receiveing (ATR_XX) - // (we use full duplex here, because our RX is on all the time - this might need to change later) - s->usrp->set_gpio_attr("FP0", "ATR_XX", (1<<5), 0x7f); - // set the output pins to 1 - s->usrp->set_gpio_attr("FP0", "OUT", 7<<7, 0xf80); + if (device->type != USRP_X400_DEV) { + // setup GPIO for TDD, GPIO(4) = ATR_RX + //set data direction register (DDR) to output + s->usrp->set_gpio_attr("FP0", "DDR", 0xfff, 0xfff); + //set lower 7 bits to be controlled automatically by ATR (the rest 5 bits are controlled manually) + s->usrp->set_gpio_attr("FP0", "CTRL", 0x7f,0xfff); + //set pins 4 (RX_TX_Switch) and 6 (Shutdown PA) to 1 when the radio is only receiving (ATR_RX) + s->usrp->set_gpio_attr("FP0", "ATR_RX", (1<<4)|(1<<6), 0x7f); + // set pin 5 (Shutdown LNA) to 1 when the radio is transmitting and receiveing (ATR_XX) + // (we use full duplex here, because our RX is on all the time - this might need to change later) + s->usrp->set_gpio_attr("FP0", "ATR_XX", (1<<5), 0x7f); + // set the output pins to 1 + s->usrp->set_gpio_attr("FP0", "OUT", 7<<7, 0xf80); + } s->wait_for_first_pps = 1; s->rx_count = 0; @@ -642,6 +644,7 @@ static int trx_usrp_read(openair0_device *device, openair0_timestamp *ptimestamp break; case USRP_X300_DEV: case USRP_N300_DEV: + case USRP_X400_DEV: rxshift=2; break; default: @@ -672,27 +675,27 @@ static int trx_usrp_read(openair0_device *device, openair0_timestamp *ptimestamp } if (samples_received == nsamps) s->wait_for_first_pps=0; - // bring RX data into 12 LSBs for softmodem RX + // bring RX data into 12 LSBs for softmodem RX for (int i=0; ipriv; - s->usrp->set_tx_freq(device->openair0_cfg[0].tx_freq[0]); - s->usrp->set_rx_freq(device->openair0_cfg[0].rx_freq[0]); + uhd::tune_request_t tx_tune_req(device->openair0_cfg[0].tx_freq[0], + device->openair0_cfg[0].tune_offset); + uhd::tune_request_t rx_tune_req(device->openair0_cfg[0].rx_freq[0], + device->openair0_cfg[0].tune_offset); + s->usrp->set_tx_freq(tx_tune_req); + s->usrp->set_rx_freq(rx_tune_req); return NULL; } /*! \brief Set frequencies (TX/RX). Spawns a thread to handle the frequency change to not block the calling thread @@ -757,14 +764,18 @@ void *freq_thread(void *arg) { int trx_usrp_set_freq(openair0_device *device, openair0_config_t *openair0_cfg, int dont_block) { usrp_state_t *s = (usrp_state_t *)device->priv; pthread_t f_thread; - printf("Setting USRP TX Freq %f, RX Freq %f\n",openair0_cfg[0].tx_freq[0],openair0_cfg[0].rx_freq[0]); + printf("Setting USRP TX Freq %f, RX Freq %f, tune_offset: %f, dont_block: %d\n", + openair0_cfg[0].tx_freq[0],openair0_cfg[0].rx_freq[0], + openair0_cfg[0].tune_offset, dont_block); // spawn a thread to handle the frequency change to not block the calling thread if (dont_block == 1) pthread_create(&f_thread,NULL,freq_thread,(void *)device); else { - s->usrp->set_tx_freq(device->openair0_cfg[0].tx_freq[0]); - s->usrp->set_rx_freq(device->openair0_cfg[0].rx_freq[0]); + uhd::tune_request_t tx_tune_req(openair0_cfg[0].tx_freq[0], openair0_cfg[0].tune_offset); + uhd::tune_request_t rx_tune_req(openair0_cfg[0].rx_freq[0], openair0_cfg[0].tune_offset); + s->usrp->set_tx_freq(tx_tune_req); + s->usrp->set_rx_freq(rx_tune_req); } return(0); @@ -777,9 +788,11 @@ int trx_usrp_set_freq(openair0_device *device, openair0_config_t *openair0_cfg, */ int openair0_set_rx_frequencies(openair0_device *device, openair0_config_t *openair0_cfg) { usrp_state_t *s = (usrp_state_t *)device->priv; - uhd::tune_request_t rx_tune_req(openair0_cfg[0].rx_freq[0]); - rx_tune_req.rf_freq_policy = uhd::tune_request_t::POLICY_MANUAL; - rx_tune_req.rf_freq = openair0_cfg[0].rx_freq[0]; + uhd::tune_request_t rx_tune_req(openair0_cfg[0].rx_freq[0], openair0_cfg[0].tune_offset); + printf("In openair0_set_rx_frequencies, freq: %f, tune offset: %f\n", + openair0_cfg[0].rx_freq[0], openair0_cfg[0].tune_offset); + //rx_tune_req.rf_freq_policy = uhd::tune_request_t::POLICY_MANUAL; + //rx_tune_req.rf_freq = openair0_cfg[0].rx_freq[0]; s->usrp->set_rx_freq(rx_tune_req); return(0); } @@ -847,7 +860,7 @@ rx_gain_calib_table_t calib_table_x310[] = { {-1,0} }; -/*! \brief USRPB210 RX calibration table */ +/*! \brief USRPn3xf RX calibration table */ rx_gain_calib_table_t calib_table_n310[] = { {3500000000.0,0.0}, {2660000000.0,0.0}, @@ -857,6 +870,16 @@ rx_gain_calib_table_t calib_table_n310[] = { {-1,0} }; +/*! \brief Empty RX calibration table */ +rx_gain_calib_table_t calib_table_none[] = { + {3500000000.0,0.0}, + {2660000000.0,0.0}, + {2300000000.0,0.0}, + {1880000000.0,0.0}, + {816000000.0, 0.0}, + {-1,0} +}; + /*! \brief Set RX gain offset * \param openair0_cfg RF frontend parameters set by application @@ -1011,7 +1034,9 @@ extern "C" { device->type=USRP_N300_DEV; usrp_master_clock = 122.88e6; args += boost::str(boost::format(",master_clock_rate=%f") % usrp_master_clock); - //args += ", send_buff_size=33554432"; + + if ( 0 != system("sysctl -w net.core.rmem_max=62500000 net.core.wmem_max=62500000") ) + LOG_W(HW,"Can't set kernel parameters for N3x0\n"); } if (device_adds[0].get("type") == "x300") { @@ -1025,6 +1050,13 @@ extern "C" { LOG_W(HW,"Can't set kernel parameters for X3xx\n"); } + if (device_adds[0].get("type") == "x4xx") { + printf("Found USRP x400\n"); + device->type = USRP_X400_DEV; + usrp_master_clock = 245.76e6; + args += boost::str(boost::format(",master_clock_rate=%f") % usrp_master_clock); + } + s->usrp = uhd::usrp::multi_usrp::make(args); if (args.find("clock_source")==std::string::npos) { @@ -1095,7 +1127,6 @@ extern "C" { if (device->type==USRP_X300_DEV) { openair0_cfg[0].rx_gain_calib_table = calib_table_x310; std::cerr << "-- Using calibration table: calib_table_x310" << std::endl; - s->usrp->set_rx_dc_offset(true); } if (device->type==USRP_N300_DEV) { @@ -1103,8 +1134,13 @@ extern "C" { std::cerr << "-- Using calibration table: calib_table_n310" << std::endl; } + if (device->type == USRP_X400_DEV) { + openair0_cfg[0].rx_gain_calib_table = calib_table_none; + std::cerr << "-- Using calibration table: calib_table_none" << std::endl; + } - if (device->type==USRP_N300_DEV || device->type==USRP_X300_DEV) { + + if (device->type==USRP_N300_DEV || device->type==USRP_X300_DEV || device->type==USRP_X400_DEV) { LOG_I(HW,"%s() sample_rate:%u\n", __FUNCTION__, (int)openair0_cfg[0].sample_rate); switch ((int)openair0_cfg[0].sample_rate) { @@ -1251,7 +1287,9 @@ extern "C" { for(int i=0; i<((int) s->usrp->get_rx_num_channels()); i++) { if (iusrp->set_rx_rate(openair0_cfg[0].sample_rate,i+choffset); - s->usrp->set_rx_freq(openair0_cfg[0].rx_freq[i],i+choffset); + uhd::tune_request_t rx_tune_req(openair0_cfg[0].rx_freq[i], + openair0_cfg[0].tune_offset); + s->usrp->set_rx_freq(rx_tune_req, i+choffset); set_rx_gain_offset(&openair0_cfg[0],i,bw_gain_adjust); ::uhd::gain_range_t gain_range = s->usrp->get_rx_gain_range(i+choffset); // limit to maximum gain @@ -1277,7 +1315,9 @@ extern "C" { if (iusrp->set_tx_rate(openair0_cfg[0].sample_rate,i+choffset); - s->usrp->set_tx_freq(openair0_cfg[0].tx_freq[i],i+choffset); + uhd::tune_request_t tx_tune_req(openair0_cfg[0].tx_freq[i], + openair0_cfg[0].tune_offset); + s->usrp->set_tx_freq(tx_tune_req, i+choffset); s->usrp->set_tx_gain(gain_range_tx.stop()-openair0_cfg[0].tx_gain[i],i+choffset); LOG_I(HW,"USRP TX_GAIN:%3.2lf gain_range:%3.2lf tx_gain:%3.2lf\n", gain_range_tx.stop()-openair0_cfg[0].tx_gain[i], gain_range_tx.stop(), openair0_cfg[0].tx_gain[i]); } diff --git a/targets/ARCH/rfsimulator/README.md b/targets/ARCH/rfsimulator/README.md index 4a8d5ff79a..feb7f015b9 100644 --- a/targets/ARCH/rfsimulator/README.md +++ b/targets/ARCH/rfsimulator/README.md @@ -61,6 +61,8 @@ Setting the env variable RFSIMULATOR can be used instead of using the serveraddr ## How to use the RF simulator options +To define and use a channel model, the configuration file needs to include a channel configuration file. To do this, add `@include "channelmod_rfsimu.conf"` to the end of the configuration file, and place the channel configuration file in the same directory. An example channel configuration file `channelmod_rfsimu.conf` is in `ci-scripts/conf_files`. + Add the following options to the command line to enable the channel model and the IQ samples saving for future replay: ```bash --rfsimulator.options chanmod,saviq @@ -82,6 +84,8 @@ Example run: sudo RFSIMULATOR=server ./nr-softmodem -O ../../../targets/PROJECTS/GENERIC-LTE-EPC/CONF/gnb.band78.tm1.106PRB.usrpn300.conf --parallel-config PARALLEL_SINGLE_THREAD --rfsim --phy-test --rfsimulator.options chanmod --rfsimulator.modelname AWGN ``` +where `@include "channelmod_rfsimu.conf"` has been added at the end of the file, and `ci-scripts/conf_files/channelmod_rfsimu.conf` copied to `targets/PROJECTS/GENERIC-LTE-EPC/CONF/`. + ## 4G case For the UE, it should be set to the IP address of the eNB. For example: @@ -102,9 +106,7 @@ $OPENAIR_DIR/targets/bin/conf2uedata -c $OPENAIR_DIR/openair3/NAS/TOOLS/ue_eurec ## 5G case -The 5G RF simulator will be aligned with the 4G as the efforts for merging the 5G specific branches into the develop make progresses. - -After regular build, add the simulation driver (do not use ./build_oai -w SIMU until 4G and 5G branches are merged). +If `build_oai` has not been run with `-w SIMU`, you need to build the `rfsimulator` manually. To do so: ```bash cd ran_build/build make rfsimulator @@ -113,7 +115,7 @@ make rfsimulator ### Launch gNB in one window ```bash -sudo RFSIMULATOR=server ./nr-softmodem -O ../../../targets/PROJECTS/GENERIC-LTE-EPC/CONF/gnb.band78.tm1.106PRB.usrpn300.conf --parallel-config PARALLEL_SINGLE_THREAD --rfsim --phy-test +sudo RFSIMULATOR=server ./nr-softmodem -O ../../../targets/PROJECTS/GENERIC-LTE-EPC/CONF/gnb.band78.tm1.106PRB.usrpn300.conf --parallel-config PARALLEL_SINGLE_THREAD --rfsim --phy-test --nokrnmod 1 ``` ### Launch UE in another window @@ -124,15 +126,17 @@ sudo RFSIMULATOR= ./nr-uesoftmodem --rfsim --phy-t Notes: -1. can be 127.0.0.1 if both gNB and nrUE executables run on the same host, OR the IP interface address of the remote host running the gNB executable, if the gNB and nrUE run on separate hosts -2. the --rrc_config_path parameter SHALL specify where the 2 RAW files are located (`rbconfig.raw` and `reconfig.raw`). +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, and a configurable scheduler is used instead of the default one. The options `-m`, `-l`, `-t`, `-M`, `-T`, `-D`, and `-U` can be used to configure this scheduler. +2. can be 127.0.0.1 if both gNB and nrUE executables run on the same host, OR the IP interface address of the remote host running the gNB executable, if the gNB and nrUE run on separate hosts. +3. The --rrc_config_path parameter SHALL specify where the 2 RAW files are located (`rbconfig.raw` and `reconfig.raw`). - If you are running on the same machine and launched the 2 executables (`nr-softmodem` and `nr-uesoftmodem`) from the same directory, nothing has to be done. - If you launched the 2 executables from 2 different folders, just point to the location where you launched the `nr-softmodem`: * `sudo RFSIMULATOR= ./nr-uesoftmodem --rfsim --phy-test --rrc_config_path /the/path/where/you/launched/nr-softmodem` - If you are not running on the same machine or launched the 2 executables from 2 different folders, you need to **COPY** the 2 raw files * `scp usera@machineA:/the/path/where/you/launched/nr-softmodem/r*config.raw userb@machineB:/the/path/where/you/will/launch/nr-uesoftmodem/` * Obviously this operation SHALL be done before launching the `nr-uesoftmodem` executable. -3. to enable the noS1 mode --noS1 and --nokrnmod 1 options should be added to the command line +4. To enable the noS1 mode, `--noS1` option should be added to the command line. +5. To operate the gNB/UE with a 5GC, start them using the `--sa` option. More information can be found [here](../../../doc/TESTING_5GSA_setup.md#2-sa-setup-with-oai-nr-ue-softmodem). In the UE, you can add `-d` option to get the softscope. diff --git a/targets/ARCH/rfsimulator/apply_channelmod.c b/targets/ARCH/rfsimulator/apply_channelmod.c index d7d3a68965..4ff5321e4d 100644 --- a/targets/ARCH/rfsimulator/apply_channelmod.c +++ b/targets/ARCH/rfsimulator/apply_channelmod.c @@ -52,7 +52,8 @@ either we regenerate the channel (call again random_channel(desc,0)), or we keep it over subframes legacy: we regenerate each sub frame in UL, and each frame only in DL */ -void rxAddInput( struct complex16 *input_sig, struct complex16 *after_channel_sig, +void rxAddInput( const c16_t *input_sig, + c16_t *after_channel_sig, int rxAnt, channel_desc_t *channelDesc, int nbSamples, @@ -73,7 +74,7 @@ void rxAddInput( struct complex16 *input_sig, struct complex16 *after_channel_si const int nbTx=channelDesc->nb_tx; for (int i=0; i<((int)nbSamples-dd); i++) { - struct complex16 *out_ptr=after_channel_sig+dd+i; + c16_t *out_ptr=after_channel_sig+dd+i; struct complexd rx_tmp= {0}; for (int txAnt=0; txAnt < nbTx; txAnt++) { @@ -87,7 +88,7 @@ void rxAddInput( struct complex16 *input_sig, struct complex16 *after_channel_si // but it is not very usefull // it would be better to split out each antenna in a separate flow // that will allow to mix ru antennas freely - struct complex16 tx16=input_sig[((TS+i-l)*nbTx+txAnt)%CirSize]; + c16_t tx16=input_sig[((TS+i-l)*nbTx+txAnt)%CirSize]; rx_tmp.r += tx16.r * channelModel[l].r - tx16.i * channelModel[l].i; rx_tmp.i += tx16.i * channelModel[l].r + tx16.r * channelModel[l].i; } //l diff --git a/targets/ARCH/rfsimulator/rfsimulator.h b/targets/ARCH/rfsimulator/rfsimulator.h index 292873032e..e69d41fa6c 100644 --- a/targets/ARCH/rfsimulator/rfsimulator.h +++ b/targets/ARCH/rfsimulator/rfsimulator.h @@ -25,8 +25,8 @@ #define __RFSIMULATOR_H double gaussZiggurat(double mean, double variance); void tableNor(unsigned long seed); -void rxAddInput( struct complex16 *input_sig, - struct complex16 *after_channel_sig, +void rxAddInput( const c16_t *input_sig, + c16_t *after_channel_sig, int rxAnt, channel_desc_t *channelDesc, int nbSamples, diff --git a/targets/ARCH/rfsimulator/simulator.c b/targets/ARCH/rfsimulator/simulator.c index 75f77fd706..5eb0dd463a 100644 --- a/targets/ARCH/rfsimulator/simulator.c +++ b/targets/ARCH/rfsimulator/simulator.c @@ -100,7 +100,7 @@ static telnetshell_vardef_t rfsimu_vardef[] = { }; pthread_mutex_t Sockmutex; -typedef struct complex16 sample_t; // 2*16 bits complex number +typedef c16_t sample_t; // 2*16 bits complex number typedef struct buffer_s { int conn_sock; @@ -117,7 +117,7 @@ typedef struct buffer_s { typedef struct { int listen_sock, epollfd; - openair0_timestamp nextTimestamp; + openair0_timestamp nextRxTstamp; openair0_timestamp lastWroteTS; uint64_t typeStamp; char *ip; @@ -196,7 +196,7 @@ static void removeCirBuf(rfsimulator_state_t *bridge, int sock) { free(bridge->buf[sock].circularBuf); // Fixme: no free_channel_desc_scm(bridge->buf[sock].channel_model) implemented // a lot of mem leaks - free(bridge->buf[sock].channel_model); + //free(bridge->buf[sock].channel_model); memset(&bridge->buf[sock], 0, sizeof(buffer_t)); bridge->buf[sock].conn_sock=-1; } @@ -429,7 +429,7 @@ static int rfsimulator_write_internal(rfsimulator_state_t *t, openair0_timestamp if (!alreadyLocked) pthread_mutex_lock(&Sockmutex); - LOG_D(HW,"sending %d samples at time: %ld\n", nsamps, timestamp); + LOG_D(HW,"sending %d samples at time: %ld, nbAnt %d\n", nsamps, timestamp, nbAnt); for (int i=0; ibuf[i]; @@ -495,7 +495,7 @@ static bool flushInput(rfsimulator_state_t *t, int timeout, int nsamps_for_initi setblocking(conn_sock, notBlocking); allocCirBuf(t, conn_sock); LOG_I(HW,"A client connected, sending the current time\n"); - struct complex16 v= {0}; + c16_t v= {0}; void *samplesVoid[t->tx_num_channels]; for ( int i=0; i < t->tx_num_channels; i++) @@ -549,14 +549,14 @@ static bool flushInput(rfsimulator_state_t *t, int timeout, int nsamps_for_initi (t->typeStamp == ENB_MAGICDL && b->th.magic==UE_MAGICDL), "Socket Error in protocol"); b->headerMode=false; - if ( t->nextTimestamp == 0 ) { // First block in UE, resync with the eNB current TS - t->nextTimestamp=b->th.timestamp> nsamps_for_initial ? + if ( t->nextRxTstamp == 0 ) { // First block in UE, resync with the eNB current TS + t->nextRxTstamp=b->th.timestamp> nsamps_for_initial ? b->th.timestamp - nsamps_for_initial : 0; b->lastReceivedTS=b->th.timestamp> nsamps_for_initial ? b->th.timestamp : nsamps_for_initial; - LOG_W(HW,"UE got first timestamp: starting at %lu\n", t->nextTimestamp); + LOG_W(HW,"UE got first timestamp: starting at %lu\n", t->nextRxTstamp); b->trashingPacket=true; } else if ( b->lastReceivedTS < b->th.timestamp) { int nbAnt= b->th.nbAnt; @@ -623,7 +623,7 @@ static int rfsimulator_read(openair0_device *device, openair0_timestamp *ptimest } rfsimulator_state_t *t = device->priv; - LOG_D(HW, "Enter rfsimulator_read, expect %d samples, will release at TS: %ld\n", nsamps, t->nextTimestamp+nsamps); + LOG_D(HW, "Enter rfsimulator_read, expect %d samples, will release at TS: %ld, nbAnt %d\n", nsamps, t->nextRxTstamp+nsamps, nbAnt); // deliver data from received data // check if a UE is connected int first_sock; @@ -634,54 +634,22 @@ static int rfsimulator_read(openair0_device *device, openair0_timestamp *ptimest if ( first_sock == FD_SETSIZE ) { // no connected device (we are eNB, no UE is connected) - if ( t->nextTimestamp == 0) + if ( t->nextRxTstamp == 0) LOG_W(HW,"No connected device, generating void samples...\n"); if (!flushInput(t, 10, nsamps)) { for (int x=0; x < nbAnt; x++) memset(samplesVoid[x],0,sampleToByte(nsamps,1)); - t->nextTimestamp+=nsamps; + t->nextRxTstamp+=nsamps; - if ( ((t->nextTimestamp/nsamps)%100) == 0) - LOG_D(HW,"No UE, Generated void samples for Rx: %ld\n", t->nextTimestamp); + if ( ((t->nextRxTstamp/nsamps)%100) == 0) + LOG_D(HW,"No UE, Generated void samples for Rx: %ld\n", t->nextRxTstamp); - *ptimestamp = t->nextTimestamp-nsamps; + *ptimestamp = t->nextRxTstamp-nsamps; return nsamps; } } else { - pthread_mutex_lock(&Sockmutex); - - if ( t->nextTimestamp > 0 && t->lastWroteTS < t->nextTimestamp) { - pthread_mutex_unlock(&Sockmutex); - usleep(10000); - pthread_mutex_lock(&Sockmutex); - - if ( t->lastWroteTS < t->nextTimestamp ) { - // Assuming Tx is not done fully in another thread - // We can never write is the past from the received time - // So, the node perform receive but will never write these symbols - // let's tell this to the opposite node - // We send timestamp for nb samples required - // assuming this should have been done earlier if a Tx would exist - pthread_mutex_unlock(&Sockmutex); - struct complex16 v= {0}; - void *dummyS[t->tx_num_channels]; - - for ( int i=0; i < t->tx_num_channels; i++) - dummyS[i]=(void *)&v; - - LOG_I(HW, "No samples Tx occured, so we send 1 sample to notify it: Tx:%lu, Rx:%lu\n", - t->lastWroteTS, t->nextTimestamp); - rfsimulator_write_internal(t, t->nextTimestamp, - dummyS, 1, - t->tx_num_channels, 1, true); - } else { - pthread_mutex_unlock(&Sockmutex); - LOG_W(HW, "trx_write came from another thread\n"); - } - } else - pthread_mutex_unlock(&Sockmutex); bool have_to_wait; @@ -692,7 +660,7 @@ static int rfsimulator_read(openair0_device *device, openair0_timestamp *ptimest buffer_t *b=&t->buf[sock]; if ( b->circularBuf ) - if ( t->nextTimestamp+nsamps > b->lastReceivedTS ) { + if ( t->nextRxTstamp+nsamps > b->lastReceivedTS ) { have_to_wait=true; break; } @@ -701,7 +669,7 @@ static int rfsimulator_read(openair0_device *device, openair0_timestamp *ptimest if (have_to_wait) /*printf("Waiting on socket, current last ts: %ld, expected at least : %ld\n", ptr->lastReceivedTS, - t->nextTimestamp+nsamps); + t->nextRxTstamp+nsamps); */ flushInput(t, 3, nsamps); } while (have_to_wait); @@ -727,19 +695,20 @@ static int rfsimulator_read(openair0_device *device, openair0_timestamp *ptimest t->poll_telnetcmdq(t->telnetcmd_qid,t); for (int a=0; achannel_model != NULL ) // apply a channel model - rxAddInput( ptr->circularBuf, (struct complex16 *) samplesVoid[a], - a, - ptr->channel_model, - nsamps, - t->nextTimestamp, - CirSize - ); + if ( ptr->channel_model != NULL ) { // apply a channel model + rxAddInput(ptr->circularBuf, (c16_t *) samplesVoid[a], + a, + ptr->channel_model, + nsamps, + t->nextRxTstamp, + CirSize); + } else { // no channel modeling - double H_awgn_mimo[4][4] ={{1.0, 0.5, 0.25, 0.125},//rx 0 - {0.5, 1.0, 0.5, 0.25}, //rx 1 - {0.25, 0.5, 1.0, 0.5}, //rx 2 - {0.125, 0.25, 0.5, 1.0}};//rx 3 + + double H_awgn_mimo[4][4] ={{1.0, 0.2, 0.1, 0.05}, //rx 0 + {0.2, 1.0, 0.2, 0.1}, //rx 1 + {0.1, 0.2, 1.0, 0.2}, //rx 2 + {0.05, 0.1, 0.2, 1.0}};//rx 3 sample_t *out=(sample_t *)samplesVoid[a]; int nbAnt_tx = ptr->th.nbAnt;//number of Tx antennas @@ -747,8 +716,8 @@ static int rfsimulator_read(openair0_device *device, openair0_timestamp *ptimest //LOG_I(HW, "nbAnt_tx %d\n",nbAnt_tx); for (int i=0; i < nsamps; i++) {//loop over nsamps for (int a_tx=0; a_txcircularBuf[((t->nextTimestamp+i)*nbAnt_tx+a_tx)%CirSize].r*H_awgn_mimo[a][a_tx]); - out[i].i += (short)(ptr->circularBuf[((t->nextTimestamp+i)*nbAnt_tx+a_tx)%CirSize].i*H_awgn_mimo[a][a_tx]); + out[i].r += (short)(ptr->circularBuf[((t->nextRxTstamp+i)*nbAnt_tx+a_tx)%CirSize].r*H_awgn_mimo[a][a_tx]); + out[i].i += (short)(ptr->circularBuf[((t->nextRxTstamp+i)*nbAnt_tx+a_tx)%CirSize].i*H_awgn_mimo[a][a_tx]); } // end for a_tx } // end for i (number of samps) } // end of no channel modeling @@ -756,11 +725,11 @@ static int rfsimulator_read(openair0_device *device, openair0_timestamp *ptimest } } - *ptimestamp = t->nextTimestamp; // return the time of the first sample - t->nextTimestamp+=nsamps; + *ptimestamp = t->nextRxTstamp; // return the time of the first sample + t->nextRxTstamp+=nsamps; LOG_D(HW,"Rx to upper layer: %d from %ld to %ld, energy in first antenna %d\n", nsamps, - *ptimestamp, t->nextTimestamp, + *ptimestamp, t->nextRxTstamp, signal_energy(samplesVoid[0], nsamps)); return nsamps; } diff --git a/targets/ARCH/tcp_bridge/README b/targets/ARCH/tcp_bridge/README deleted file mode 100644 index 9bd1a16e59..0000000000 --- a/targets/ARCH/tcp_bridge/README +++ /dev/null @@ -1,4 +0,0 @@ -This is sort of a "TCP driver" to ease debugging. This is mostly internal -to EURECOM. You probably don't want to use it. - -Same license as the rest. diff --git a/targets/ARCH/tcp_bridge/README.tcp_bridge_oai b/targets/ARCH/tcp_bridge/README.tcp_bridge_oai deleted file mode 100644 index 05a520f6ae..0000000000 --- a/targets/ARCH/tcp_bridge/README.tcp_bridge_oai +++ /dev/null @@ -1,42 +0,0 @@ -The driver tcp_bridge_oai.c is to be used with the basic simulator. - -To build the basic simulator: - cd [openair top directory] - . oaienv - cd cmake_targets - ./build_oai -I -w USRP - ./build_oai --basic-simulator - cd ../common/utils/T/tracer - make - -To use it, you need to run the eNB and the UE. - -The eNB requires the T tracer. -Open two terminals. -In one terminal, run: - cd [openair top directory] - cd common/utils/T/tracer - ./enb -d ../T_messages.txt -In the other terminal, run: - cd [openair top directory] - cd cmake_targets/basic_simulator/enb - export ENODEB=1 - sudo -E ./lte-softmodem -O [configuration file] --T_stdout 0 -[configuration file] is just a regular configuration file. -The eNB needs an EPC. - -To run the UE, open a terminal and run: - cd [openair top directory] - cd cmake_targets/basic_simulator/ue - sudo ./lte-uesoftmodem -C 2680000000 -r 25 --ue-rxgain 140 -Adapt the value of -r, it has to match the value N_RB_DL in the configuration -file of the eNB. (Same for -C which should match the value downlink_frequency -in the configuration file.) - -The UE configuration (security keys) is generated from the file -openair3/NAS/TOOLS/ue_eurecom_test_sfr.conf. You need to configure -your EPC to know about the UE. If you change the file -openair3/NAS/TOOLS/ue_eurecom_test_sfr.conf then you need to -regenerate the configuration files using the program targets/bin/conf2uedata. -You run it as: - $OPENAIR_DIR/targets/bin/conf2uedata -c $OPENAIR_DIR/openair3/NAS/TOOLS/ue_eurecom_test_sfr.conf -o $OPENAIR_DIR/cmake_targets/basic_simulator/ue diff --git a/targets/ARCH/tcp_bridge/tcp_bridge.c b/targets/ARCH/tcp_bridge/tcp_bridge.c deleted file mode 100644 index f8c12dcb7a..0000000000 --- a/targets/ARCH/tcp_bridge/tcp_bridge.c +++ /dev/null @@ -1,292 +0,0 @@ -#include -#include -#include -#include -#include -#include -#include - -int fullread(int fd, void *_buf, int count) -{ - char *buf = _buf; - int ret = 0; - int l; - while (count) { - l = read(fd, buf, count); - if (l <= 0) return -1; - count -= l; - buf += l; - ret += l; - } - return ret; -} - -int fullwrite(int fd, void *_buf, int count) -{ - char *buf = _buf; - int ret = 0; - int l; - while (count) { - l = write(fd, buf, count); - if (l <= 0) return -1; - count -= l; - buf += l; - ret += l; - } - return ret; -} - -#include "common_lib.h" - -typedef struct { - int32_t data[30720]; /* max 20MHz */ - unsigned long timestamp; - int size; -} input_buffer; - -#define BSIZE 16 - -typedef struct { - int sock; - int samples_per_subframe; - input_buffer b[BSIZE]; - int bstart; - int blen; - unsigned long read_timestamp; -} tcp_bridge_state_t; - - -/****************************************************************************/ -/* buffer management */ -/* (could be simpler, we are synchronous) */ -/* maybe we should lock */ -/****************************************************************************/ - -void put_buffer(tcp_bridge_state_t *t, void *data, int size, unsigned long timestamp) -{ - int nextpos; - if (t->blen == BSIZE) { printf("tcp_bridge: buffer full\n"); exit(1); } - if (size > 30720*4) abort(); - if (t->blen) { - int lastpos = (t->bstart+t->blen-1) % BSIZE; - if (timestamp != t->b[lastpos].timestamp + t->samples_per_subframe) - { printf("tcp_bridge: discontinuity\n"); exit(1); } - } - nextpos = (t->bstart+t->blen) % BSIZE; - t->b[nextpos].timestamp = timestamp; - t->b[nextpos].size = size; - memcpy(t->b[nextpos].data, data, size); - t->blen++; -} - -void get_buffer(tcp_bridge_state_t *t, void *data, int size, unsigned long timestamp) -{ - int pos; - if (t->blen == 0) { printf("tcp_bridge: buffer empty\n"); exit(1); } - if (size >30720*4) abort(); - pos = t->bstart; - if (size != t->b[pos].size) { printf("tcp_bridge: bad size\n"); exit(1); } - memcpy(data, t->b[pos].data, size); - t->bstart = (t->bstart + 1) % BSIZE; - t->blen--; -} - -/****************************************************************************/ -/* end of buffer management */ -/****************************************************************************/ - - -/****************************************************************************/ -/* network management (read/write) */ -/****************************************************************************/ - -void read_data_from_network(int sock, input_buffer *b) -{ - if (fullread(sock, &b->timestamp, sizeof(b->timestamp)) != sizeof(b->timestamp)) goto err; - if (fullread(sock, &b->size, sizeof(b->size)) != sizeof(b->size)) goto err; - if (fullread(sock, b->data, b->size) != b->size) goto err; - return; - -err: - printf("tcp_bridge: read_data_from_network fails\n"); - exit(1); -} - -void write_data_to_network(int sock, input_buffer *b) -{ - if (fullwrite(sock, &b->timestamp, sizeof(b->timestamp)) != sizeof(b->timestamp)) goto err; - if (fullwrite(sock, &b->size, sizeof(b->size)) != sizeof(b->size)) goto err; - if (fullwrite(sock, b->data, b->size) != b->size) goto err; - return; - -err: - printf("tcp_bridge: write_data_to_network fails\n"); - exit(1); -} - -/****************************************************************************/ -/* end of network management */ -/****************************************************************************/ - - -int tcp_bridge_start(openair0_device *device) -{ - int i; - int port = 4042; - tcp_bridge_state_t *tcp_bridge = device->priv; - - int sock = socket(AF_INET, SOCK_STREAM, 0); - if (sock == -1) { perror("tcp_bridge: socket"); exit(1); } - - int enable = 1; - if (setsockopt(sock, SOL_SOCKET, SO_REUSEADDR, &enable, sizeof(int))) - { perror("tcp_bridge: SO_REUSEADDR"); exit(1); } - - struct sockaddr_in addr = { - sin_family: AF_INET, - sin_port: htons(port), - sin_addr: { s_addr: INADDR_ANY } - }; - - if (bind(sock, (struct sockaddr *)&addr, sizeof(addr))) - { perror("tcp_bridge: bind"); exit(1); } - - if (listen(sock, 5)) - { perror("tcp_bridge: listen"); exit(1); } - - printf("tcp_bridge: wait for connection on port %d\n", port); - - socklen_t len = sizeof(addr); - int sock2 = accept(sock, (struct sockaddr *)&addr, &len); - if (sock2 == -1) - { perror("tcp_bridge: accept"); exit(1); } - - close(sock); - - tcp_bridge->sock = sock2; - - /* the other end has to send 10 subframes at startup */ - for (i = 0; i < 10; i++) - read_data_from_network(sock2, &tcp_bridge->b[i]); - tcp_bridge->bstart = 0; - tcp_bridge->blen = 10; - - printf("tcp_bridge: connection established\n"); - - return 0; -} - -int tcp_bridge_request(openair0_device *device, void *msg, ssize_t msg_len) { abort(); return 0; } -int tcp_bridge_reply(openair0_device *device, void *msg, ssize_t msg_len) { abort(); return 0; } -int tcp_bridge_get_stats(openair0_device* device) { return 0; } -int tcp_bridge_reset_stats(openair0_device* device) { return 0; } -void tcp_bridge_end(openair0_device *device) {} -int tcp_bridge_stop(openair0_device *device) { return 0; } -int tcp_bridge_set_freq(openair0_device* device, openair0_config_t *openair0_cfg,int exmimo_dump_config) { return 0; } -int tcp_bridge_set_gains(openair0_device* device, openair0_config_t *openair0_cfg) { return 0; } - -int tcp_bridge_write(openair0_device *device, openair0_timestamp timestamp, void **buff, int nsamps, int cc, int flags) -{ - tcp_bridge_state_t *t = device->priv; - input_buffer out; - int i; -//printf("write ts %ld nsamps %d\n", timestamp, nsamps); - - if (nsamps > 30720) abort(); - - /* read buffer timestamped with 'timestamp' if not already here */ - for (i = 0; i < t->blen; i++) { - input_buffer *b = &t->b[(t->bstart + i) % BSIZE]; - if (b->timestamp == timestamp) break; - } - if (i == t->blen) { - int nextpos = (t->bstart + t->blen) % BSIZE; - if (t->blen == BSIZE) abort(); - read_data_from_network(t->sock, &t->b[nextpos]); - t->blen++; - if (t->b[nextpos].timestamp != timestamp) abort(); - } - - memcpy(out.data, buff[0], nsamps * 4); - out.timestamp = timestamp; - out.size = nsamps * 4; - write_data_to_network(t->sock, &out); - - return nsamps; -} - -int tcp_bridge_read(openair0_device *device, openair0_timestamp *timestamp, void **buff, int nsamps, int cc) -{ - tcp_bridge_state_t *t = device->priv; - input_buffer *b; - - if (cc != 1) abort(); - if (t->blen == 0) abort(); - - b = &t->b[t->bstart]; - - if (b->timestamp != t->read_timestamp) abort(); - if (b->size != nsamps * 4) abort(); - - *timestamp = b->timestamp; - memcpy(buff[0], b->data, b->size); - - t->read_timestamp += nsamps; - t->bstart = (t->bstart + 1) % BSIZE; - t->blen--; - -static unsigned long ts = 0; -//printf("read ts %ld nsamps %d\n", ts, nsamps); -*timestamp = ts; -ts += nsamps; - - return nsamps; -} - -int tcp_bridge_write_init(openair0_device *device) -{ - return 0; -} - -__attribute__((__visibility__("default"))) -int device_init(openair0_device* device, openair0_config_t *openair0_cfg) -{ - tcp_bridge_state_t *tcp_bridge = (tcp_bridge_state_t*)malloc(sizeof(tcp_bridge_state_t)); - memset(tcp_bridge, 0, sizeof(tcp_bridge_state_t)); - - /* only 25 or 50 PRBs handled for the moment */ - if (openair0_cfg[0].sample_rate != 61440000 && - openair0_cfg[0].sample_rate != 30720000 && - openair0_cfg[0].sample_rate != 15360000 && - openair0_cfg[0].sample_rate != 7680000) { - printf("tcp_bridge: ERROR: only sample rate 61.44, 30.72, 15.36, and 7.68 Msps supported\n"); - exit(1); - } - - device->trx_start_func = tcp_bridge_start; - device->trx_get_stats_func = tcp_bridge_get_stats; - device->trx_reset_stats_func = tcp_bridge_reset_stats; - device->trx_end_func = tcp_bridge_end; - device->trx_stop_func = tcp_bridge_stop; - device->trx_set_freq_func = tcp_bridge_set_freq; - device->trx_set_gains_func = tcp_bridge_set_gains; - device->trx_write_func = tcp_bridge_write; - device->trx_read_func = tcp_bridge_read; - device->trx_write_init = tcp_bridge_write_init; - - device->priv = tcp_bridge; - - switch ((int)openair0_cfg[0].sample_rate) { - case 61440000: tcp_bridge->samples_per_subframe = 61440; break; - case 30720000: tcp_bridge->samples_per_subframe = 30720; break; - case 15360000: tcp_bridge->samples_per_subframe = 15360; break; - case 7680000: tcp_bridge->samples_per_subframe = 7680; break; - } - - /* let's pretend to be a b2x0 */ - device->type = USRP_B200_DEV; - - device->openair0_cfg=&openair0_cfg[0]; - - return 0; -} diff --git a/targets/ARCH/tcp_bridge/tcp_bridge_oai.c b/targets/ARCH/tcp_bridge/tcp_bridge_oai.c deleted file mode 100644 index c3d5355876..0000000000 --- a/targets/ARCH/tcp_bridge/tcp_bridge_oai.c +++ /dev/null @@ -1,443 +0,0 @@ -#include -#include -#include -#include -#include -#include -#include -#include -#include - -const int port = 4043; -#define helpTxt "\ -\x1b[31m\ -tcp_bridge: error: you have to run one UE and one eNB\n\ -For this, export TCPBRIDGE=enb (eNB case) or \n\ - TCPBRIDGE= (UE case)\n\ -\x1b[m" - -int fullread(int fd, void *_buf, int count) { - char *buf = _buf; - int ret = 0; - int l; - - while (count) { - l = read(fd, buf, count); - - if (l <= 0) return -1; - - count -= l; - buf += l; - ret += l; - } - - return ret; -} - -int fullwrite(int fd, void *_buf, int count) { - char *buf = _buf; - int ret = 0; - int l; - - while (count) { - l = write(fd, buf, count); - - if (l <= 0) return -1; - - count -= l; - buf += l; - ret += l; - } - - return ret; -} - -#include "common_lib.h" - -typedef struct { - int sock; - int samples_per_subframe; - uint64_t timestamp; - uint64_t next_tx_timestamp; - int is_enb; - char *ip; -} tcp_bridge_state_t; - -void verify_connection(int fd, int is_enb) { - char c = is_enb; - - if (fullwrite(fd, &c, 1) != 1) exit(1); - - if (fullread(fd, &c, 1) != 1) exit(1); - - if (c == is_enb) { - printf(helpTxt); - exit(1); - } -} - - -int start_enb(tcp_bridge_state_t *tcp_bridge) { - struct sockaddr_in addr = { -sin_family: - AF_INET, -sin_port: - htons(port), -sin_addr: - { s_addr: INADDR_ANY } - }; - - if (bind(tcp_bridge->sock, (struct sockaddr *)&addr, sizeof(addr))) { - perror("tcp_bridge: bind"); - exit(1); - } - - if (listen(tcp_bridge->sock, 5)) { - perror("tcp_bridge: listen"); - exit(1); - } - - printf("tcp_bridge: wait for connection on port %d\n", port); - socklen_t len = sizeof(addr); - int sockServ = accept(tcp_bridge->sock, (struct sockaddr *)&addr, &len); - - if ( sockServ == -1) { - perror("tcp_bridge: accept"); - exit(1); - } - - verify_connection(sockServ, tcp_bridge->is_enb); - printf("tcp_bridge: connection established\n"); - close(tcp_bridge->sock); - tcp_bridge->sock=sockServ; - return 0; -} - -int start_ue(tcp_bridge_state_t *tcp_bridge) { -struct sockaddr_in addr = {sin_family: - AF_INET, -sin_port: - htons(port), -sin_addr: - { s_addr: INADDR_ANY } - }; - addr.sin_addr.s_addr = inet_addr(tcp_bridge->ip); - - while(1) { - printf("tcp_bridge: trying to connect to %s:%d\n", tcp_bridge->ip, port); - - if (connect(tcp_bridge->sock, (struct sockaddr *)&addr, sizeof(addr)) == 0) { - verify_connection(tcp_bridge->sock, tcp_bridge->is_enb); - printf("tcp_bridge: connection established\n"); - return 0; - } - - perror("tcp_bridge"); - sleep(1); - } - - return 0; -} - -int tcp_bridge_start(openair0_device *device) { - tcp_bridge_state_t *tcp_bridge = device->priv; - tcp_bridge->sock = socket(AF_INET, SOCK_STREAM, 0); - - if (tcp_bridge->sock == -1) { - perror("tcp_bridge: socket"); - exit(1); - } - - int enable = 1; - - if (setsockopt(tcp_bridge->sock, SOL_SOCKET, SO_REUSEADDR, &enable, sizeof(int))) { - perror("tcp_bridge: SO_REUSEADDR"); - exit(1); - } - - if ( tcp_bridge->is_enb ) - return start_enb(tcp_bridge); - else - return start_ue(tcp_bridge); -} - -int tcp_bridge_request(openair0_device *device, void *msg, ssize_t msg_len) { - abort(); - return 0; -} -int tcp_bridge_reply(openair0_device *device, void *msg, ssize_t msg_len) { - abort(); - return 0; -} -int tcp_bridge_get_stats(openair0_device *device) { - return 0; -} -int tcp_bridge_reset_stats(openair0_device *device) { - return 0; -} -void tcp_bridge_end(openair0_device *device) {} -int tcp_bridge_stop(openair0_device *device) { - return 0; -} -int tcp_bridge_set_freq(openair0_device *device, openair0_config_t *openair0_cfg,int exmimo_dump_config) { - return 0; -} -int tcp_bridge_set_gains(openair0_device *device, openair0_config_t *openair0_cfg) { - return 0; -} - -int tcp_bridge_write(openair0_device *device, openair0_timestamp timestamp, void **buff, int nsamps, int cc, int flags) { - if (cc != 1) { - printf("tcp_bridge: only 1 antenna supported\n"); - exit(1); - } - - tcp_bridge_state_t *t = device->priv; - - /* deal with discontinuities in output (think: eNB in TDD mode) */ - if (t->next_tx_timestamp && timestamp != t->next_tx_timestamp) { - uint32_t b[4096]; - uint64_t to_send = timestamp - t->next_tx_timestamp; - memset(b, 0, 4096 * sizeof(uint32_t)); - - while (to_send) { - int len = to_send > 4096 ? 4096 : to_send; - int n = fullwrite(t->sock, b, len * 4); - - if (n != len * 4) { - printf("tcp_bridge: write error ret %d error %s\n", n, strerror(errno)); - abort(); - } - - to_send -= len; - } - } - - int n = fullwrite(t->sock, buff[0], nsamps * 4); - - if (n != nsamps * 4) { - printf("tcp_bridge: write error ret %d (wanted %d) error %s\n", n, nsamps*4, strerror(errno)); - abort(); - } - - t->next_tx_timestamp = timestamp + nsamps; - return nsamps; -} - -int tcp_bridge_read(openair0_device *device, openair0_timestamp *timestamp, void **buff, int nsamps, int cc) { - if (cc != 1) { - printf("tcp_bridge: only 1 antenna supported\n"); - exit(1); - } - - tcp_bridge_state_t *t = device->priv; - int n = fullread(t->sock, buff[0], nsamps * 4); - - if (n != nsamps * 4) { - printf("tcp_bridge: read error ret %d nsamps*4 %d error %s\n", n, nsamps * 4, strerror(errno)); - abort(); - } - - *timestamp = t->timestamp; - t->timestamp += nsamps; - return nsamps; -} - -int tcp_bridge_read_ue(openair0_device *device, openair0_timestamp *timestamp, void **buff, int nsamps, int cc) { - if (cc != 1) { - printf("tcp_bridge: only 1 antenna supported\n"); - exit(1); - } - - tcp_bridge_state_t *t = device->priv; - int n; - - /* In synch mode, UE does not write, but we need to - send something to the eNodeB. - We know that UE is in synch mode when it reads - 10 subframes at a time. - */ - if (nsamps == t->samples_per_subframe * 10) { - uint32_t b[nsamps]; - memset(b, 0, nsamps * 4); - n = fullwrite(t->sock, b, nsamps * 4); - - if (n != nsamps * 4) { - printf("tcp_bridge: write error ret %d error %s\n", n, strerror(errno)); - abort(); - } - } - - return tcp_bridge_read(device, timestamp, buff, nsamps, cc); -} - -/* To startup proper communcation between eNB and UE, - we need to understand that: - - eNodeB starts reading subframe 0 - - then eNodeB starts sending subframe 4 - and then repeats read/write for each subframe. - The UE: - - reads 10 subframes at a time until it is synchronized - - then reads subframe n and writes subframe n+2 - We also want to enforce that the subframe 0 is read - at the beginning of the UE RX buffer, not in the middle - of it. - So it means: - - for the eNodeB: let it run as in normal mode (as with a B210) - - for the UE, on its very first read: - - we want this read to get data from subframe 0 - but the first write of eNodeB is subframe 4 - so we first need to read and ignore 6 subframes - - the UE will start its TX only at the subframe 2 - corresponding to the subframe 0 it just read, - so we need to write 12 subframes before anything - (the function tcp_bridge_read_ue takes care to - insert dummy TX data during the synch phase) - - Here is a drawing of the beginning of things to make - this logic clearer. - - We see that eNB starts RX at subframe 0, starts TX at subfram 4, - and that UE starts RX at subframe 10 and TX at subframe 12. - - We understand that the UE has to transmit 12 empty - subframes for the eNodeB to start its processing. - - And because the eNodeB starts its TX at subframe 4 and we - want the UE to start its RX at subframe 10, we need to - read and ignore 6 subframes in the UE. - - ------------------------------------------------------------------------- - eNB RX: | *0* | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 ... - ------------------------------------------------------------------------- - - ------------------------------------------------------------------------- - eNB TX: | 0 | 1 | 2 | 3 | *4* | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 ... - ------------------------------------------------------------------------- - - ------------------------------------------------------------------------- - UE RX: | 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | *10* | 11 | 12 | 13 | 14 ... - ------------------------------------------------------------------------- - - ------------------------------------------------------------------------- - UE TX: | 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | *12* | 13 | 14 ... - ------------------------------------------------------------------------- - - As a final note, we do TX before RX to ensure that the eNB will - get some data and send us something so there is no deadlock - at the beginning of things. Hopefully the kernel buffers for - the sockets are big enough so that the first (big) TX can - return to user mode before the buffers are full. If this - is wrong in some environment, we will need to work by smaller - units of data at a time. -*/ -int tcp_bridge_ue_first_read(openair0_device *device, openair0_timestamp *timestamp, void **buff, int nsamps, int cc) { - if (cc != 1) { - printf("tcp_bridge: only 1 antenna supported\n"); - exit(1); - } - - tcp_bridge_state_t *t = device->priv; - uint32_t b[t->samples_per_subframe * 12]; - memset(b, 0, t->samples_per_subframe * 12 * 4); - int n = fullwrite(t->sock, b, t->samples_per_subframe * 12 * 4); - - if (n != t->samples_per_subframe * 12 * 4) { - printf("tcp_bridge: write error ret %d error %s\n", n, strerror(errno)); - abort(); - } - - n = fullread(t->sock, b, t->samples_per_subframe * 6 * 4); - - if (n != t->samples_per_subframe * 6 * 4) { - printf("tcp_bridge: read error ret %d error %s\n", n, strerror(errno)); - abort(); - } - - /* Due to some unknown bug in the eNB (or UE, or both), the first frames - * are not correctly generated (or handled), which leads to a bad behavior - * of the simulator in some cases (seen with 100 RBs: the UE reads a bad - * MIB and switches to 25 RBs, which results in a deadlock in this driver). - * Let's skip 10 frames to avoid this issue. - */ - for (int i = 0; i < 10 * 10; i++) { - memset(b, 0, t->samples_per_subframe * 4); - n = fullwrite(t->sock, b, t->samples_per_subframe * 4); - - if (n != t->samples_per_subframe * 4) { - printf("tcp_bridge: write error ret %d error %s\n", n, strerror(errno)); - abort(); - } - - n = fullread(t->sock, b, t->samples_per_subframe * 4); - - if (n != t->samples_per_subframe * 4) { - printf("tcp_bridge: read error ret %d error %s\n", n, strerror(errno)); - abort(); - } - } - - device->trx_read_func = tcp_bridge_read_ue; - return tcp_bridge_read_ue(device, timestamp, buff, nsamps, cc); -} - -__attribute__((__visibility__("default"))) -int device_init(openair0_device *device, openair0_config_t *openair0_cfg) { - tcp_bridge_state_t *tcp_bridge = (tcp_bridge_state_t *)calloc(sizeof(tcp_bridge_state_t),1); - - if ((tcp_bridge->ip=getenv("TCPBRIDGE")) == NULL ) { - /* for compatibility, we test the ENB environment variable */ - if ((tcp_bridge->ip=getenv("ENODEB")) != NULL ) { - tcp_bridge->ip=strdup("enb"); - } else { - tcp_bridge->ip=strdup("127.0.0.1"); - } - } - - tcp_bridge->is_enb = strncasecmp(tcp_bridge->ip,"enb",3) == 0; - printf("tcp_bridge: running as %s\n", tcp_bridge->is_enb ? "eNB" : "UE"); - - if (openair0_cfg[0].sample_rate != 61440000 && - openair0_cfg[0].sample_rate != 30720000 && - openair0_cfg[0].sample_rate != 15360000 && - openair0_cfg[0].sample_rate != 7680000) { - printf("tcp_bridge: ERROR: only sample rate 61.44, 30.72, 15.36, and 7.68 Msps supported\n"); - exit(1); - } - - device->trx_start_func = tcp_bridge_start; - device->trx_get_stats_func = tcp_bridge_get_stats; - device->trx_reset_stats_func = tcp_bridge_reset_stats; - device->trx_end_func = tcp_bridge_end; - device->trx_stop_func = tcp_bridge_stop; - device->trx_set_freq_func = tcp_bridge_set_freq; - device->trx_set_gains_func = tcp_bridge_set_gains; - device->trx_write_func = tcp_bridge_write; - - if (tcp_bridge->is_enb) { - device->trx_read_func = tcp_bridge_read; - } else { - device->trx_read_func = tcp_bridge_ue_first_read; - } - - device->priv = tcp_bridge; - - switch ((int)openair0_cfg[0].sample_rate) { - case 30720000: - tcp_bridge->samples_per_subframe = 30720; - break; - - case 15360000: - tcp_bridge->samples_per_subframe = 15360; - break; - - case 7680000: - tcp_bridge->samples_per_subframe = 7680; - break; - } - - /* let's pretend to be a b2x0 */ - device->type = USRP_B200_DEV; - device->openair0_cfg=&openair0_cfg[0]; - return 0; -} diff --git a/targets/PROJECTS/GENERIC-LTE-EPC/CONF/benetel-5g.conf b/targets/PROJECTS/GENERIC-LTE-EPC/CONF/benetel-5g.conf index f13f20efba..d14267dcd8 100644 --- a/targets/PROJECTS/GENERIC-LTE-EPC/CONF/benetel-5g.conf +++ b/targets/PROJECTS/GENERIC-LTE-EPC/CONF/benetel-5g.conf @@ -23,8 +23,6 @@ gNBs = ////////// Physical parameters: ssb_SubcarrierOffset = 31; //0; - pdsch_AntennaPorts = 1; - pusch_AntennaPorts = 1; servingCellConfigCommon = ( { diff --git a/targets/PROJECTS/GENERIC-LTE-EPC/CONF/gnb.band257.tm1.32PRB.usrpn300.conf b/targets/PROJECTS/GENERIC-LTE-EPC/CONF/gnb.band257.tm1.32PRB.usrpn300.conf index 483aac6deb..52e4eec30e 100644 --- a/targets/PROJECTS/GENERIC-LTE-EPC/CONF/gnb.band257.tm1.32PRB.usrpn300.conf +++ b/targets/PROJECTS/GENERIC-LTE-EPC/CONF/gnb.band257.tm1.32PRB.usrpn300.conf @@ -22,8 +22,6 @@ gNBs = ////////// Physical parameters: ssb_SubcarrierOffset = 0; - pdsch_AntennaPorts = 1; - pusch_AntennaPorts = 1; servingCellConfigCommon = ( { diff --git a/targets/PROJECTS/GENERIC-LTE-EPC/CONF/gnb.band257.tm1.32PRB.usrpx300.conf b/targets/PROJECTS/GENERIC-LTE-EPC/CONF/gnb.band257.tm1.32PRB.usrpx300.conf index 9a91640a08..ab435c9686 100644 --- a/targets/PROJECTS/GENERIC-LTE-EPC/CONF/gnb.band257.tm1.32PRB.usrpx300.conf +++ b/targets/PROJECTS/GENERIC-LTE-EPC/CONF/gnb.band257.tm1.32PRB.usrpx300.conf @@ -22,8 +22,6 @@ gNBs = ////////// Physical parameters: ssb_SubcarrierOffset = 0; - pdsch_AntennaPorts = 1; - pusch_AntennaPorts = 1; servingCellConfigCommon = ( { diff --git a/targets/PROJECTS/GENERIC-LTE-EPC/CONF/gnb.band257.tm1.66PRB.usrpn300.conf b/targets/PROJECTS/GENERIC-LTE-EPC/CONF/gnb.band257.tm1.66PRB.usrpn300.conf index 05c81b5c51..a04e0e6123 100644 --- a/targets/PROJECTS/GENERIC-LTE-EPC/CONF/gnb.band257.tm1.66PRB.usrpn300.conf +++ b/targets/PROJECTS/GENERIC-LTE-EPC/CONF/gnb.band257.tm1.66PRB.usrpn300.conf @@ -22,9 +22,7 @@ gNBs = ////////// Physical parameters: ssb_SubcarrierOffset = 0; - pdsch_AntennaPorts = 1; - pusch_AntennaPorts = 1; - + servingCellConfigCommon = ( { #spCellConfigCommon diff --git a/targets/PROJECTS/GENERIC-LTE-EPC/CONF/gnb.band261.tm1.32PRB.usrpn300.conf b/targets/PROJECTS/GENERIC-LTE-EPC/CONF/gnb.band261.tm1.32PRB.usrpn300.conf index fbae1136b0..426f9e782b 100644 --- a/targets/PROJECTS/GENERIC-LTE-EPC/CONF/gnb.band261.tm1.32PRB.usrpn300.conf +++ b/targets/PROJECTS/GENERIC-LTE-EPC/CONF/gnb.band261.tm1.32PRB.usrpn300.conf @@ -22,8 +22,6 @@ gNBs = ////////// Physical parameters: ssb_SubcarrierOffset = 0; - pdsch_AntennaPorts = 1; - pusch_AntennaPorts = 1; servingCellConfigCommon = ( { diff --git a/targets/PROJECTS/GENERIC-LTE-EPC/CONF/gnb.band66.tm1.106PRB.usrpn300.conf b/targets/PROJECTS/GENERIC-LTE-EPC/CONF/gnb.band66.tm1.106PRB.usrpn300.conf index e5685d00a4..216728577a 100644 --- a/targets/PROJECTS/GENERIC-LTE-EPC/CONF/gnb.band66.tm1.106PRB.usrpn300.conf +++ b/targets/PROJECTS/GENERIC-LTE-EPC/CONF/gnb.band66.tm1.106PRB.usrpn300.conf @@ -22,8 +22,6 @@ gNBs = ////////// Physical parameters: ssb_SubcarrierOffset = 0; - pdsch_AntennaPorts = 1; - pusch_AntennaPorts = 1; servingCellConfigCommon = ( { diff --git a/targets/PROJECTS/GENERIC-LTE-EPC/CONF/gnb.band66.tm1.106PRB.usrpx300.conf b/targets/PROJECTS/GENERIC-LTE-EPC/CONF/gnb.band66.tm1.106PRB.usrpx300.conf index b0126589cd..59d466656c 100644 --- a/targets/PROJECTS/GENERIC-LTE-EPC/CONF/gnb.band66.tm1.106PRB.usrpx300.conf +++ b/targets/PROJECTS/GENERIC-LTE-EPC/CONF/gnb.band66.tm1.106PRB.usrpx300.conf @@ -22,8 +22,6 @@ gNBs = ////////// Physical parameters: ssb_SubcarrierOffset = 0; - pdsch_AntennaPorts = 1; - pusch_AntennaPorts = 1; servingCellConfigCommon = ( { diff --git a/targets/PROJECTS/GENERIC-LTE-EPC/CONF/gnb.band66.tm1.25PRB.usrpn300.conf b/targets/PROJECTS/GENERIC-LTE-EPC/CONF/gnb.band66.tm1.25PRB.usrpn300.conf new file mode 100644 index 0000000000..6af1356088 --- /dev/null +++ b/targets/PROJECTS/GENERIC-LTE-EPC/CONF/gnb.band66.tm1.25PRB.usrpn300.conf @@ -0,0 +1,266 @@ +Active_gNBs = ( "gNB-Eurecom-5GNRBox"); +# Asn1_verbosity, choice in: none, info, annoying +Asn1_verbosity = "none"; + +gNBs = +( + { + ////////// Identification parameters: + gNB_ID = 0xe00; + + cell_type = "CELL_MACRO_GNB"; + + gNB_name = "gNB-Eurecom-5GNRBox"; + + // Tracking area code, 0x0000 and 0xfffe are reserved values + tracking_area_code = 1; + + plmn_list = ({mcc = 208; mnc = 93; mnc_length = 2;}); + + tr_s_preference = "local_mac"; + + ////////// Physical parameters: + + ssb_SubcarrierOffset = 0; + pdsch_AntennaPorts = 1; + pusch_AntennaPorts = 1; + min_rxtxtime = 6; + + servingCellConfigCommon = ( + { + #spCellConfigCommon + + physCellId = 0; + +# downlinkConfigCommon + #frequencyInfoDL + # this is 2150 MHz + 12 PRBs@15kHz SCS (same as initial BWP), points to Subcarrier 0 of RB#10 of SSB block + absoluteFrequencySSB = 430432; + dl_frequencyBand = 66; + # this is 2150 MHz + dl_absoluteFrequencyPointA = 430000; + #scs-SpecificCarrierList + dl_offstToCarrier = 0; +# subcarrierSpacing +# 0=kHz15, 1=kHz30, 2=kHz60, 3=kHz120 + dl_subcarrierSpacing = 0; + dl_carrierBandwidth = 25; + #initialDownlinkBWP + #genericParameters + # this is RBstart=0,L=25 (275*(L-1))+RBstart + initialDLBWPlocationAndBandwidth = 6600; +# subcarrierSpacing +# 0=kHz15, 1=kHz30, 2=kHz60, 3=kHz120 + initialDLBWPsubcarrierSpacing = 0; + #pdcch-ConfigCommon + initialDLBWPcontrolResourceSetZero = 0; + initialDLBWPsearchSpaceZero = 0; + + #uplinkConfigCommon + #frequencyInfoUL + ul_frequencyBand = 66; + ul_absoluteFrequencyPointA = 350000; + #scs-SpecificCarrierList + ul_offstToCarrier = 0; +# subcarrierSpacing +# 0=kHz15, 1=kHz30, 2=kHz60, 3=kHz120 + ul_subcarrierSpacing = 0; + ul_carrierBandwidth = 25; + pMax = 20; + #initialUplinkBWP + #genericParameters + initialULBWPlocationAndBandwidth = 6600; +# subcarrierSpacing +# 0=kHz15, 1=kHz30, 2=kHz60, 3=kHz120 + initialULBWPsubcarrierSpacing = 0; + #rach-ConfigCommon + #rach-ConfigGeneric + prach_ConfigurationIndex = 98; +#prach_msg1_FDM +#0 = one, 1=two, 2=four, 3=eight + prach_msg1_FDM = 0; + prach_msg1_FrequencyStart = 0; + zeroCorrelationZoneConfig = 13; + preambleReceivedTargetPower = -118; +#preamblTransMax (0...10) = (3,4,5,6,7,8,10,20,50,100,200) + preambleTransMax = 6; +#powerRampingStep +# 0=dB0,1=dB2,2=dB4,3=dB6 + powerRampingStep = 1; +#ra_ReponseWindow +#1,2,4,8,10,20,40,80 + ra_ResponseWindow = 4; +#ssb_perRACH_OccasionAndCB_PreamblesPerSSB_PR +#1=oneeighth,2=onefourth,3=half,4=one,5=two,6=four,7=eight,8=sixteen + ssb_perRACH_OccasionAndCB_PreamblesPerSSB_PR = 4; +#oneHalf (0..15) 4,8,12,16,...60,64 + ssb_perRACH_OccasionAndCB_PreamblesPerSSB = 15; +#ra_ContentionResolutionTimer +#(0..7) 8,16,24,32,40,48,56,64 + ra_ContentionResolutionTimer = 7; + rsrp_ThresholdSSB = 19; +#prach-RootSequenceIndex_PR +#1 = 839, 2 = 139 + prach_RootSequenceIndex_PR = 2; + prach_RootSequenceIndex = 1; + # SCS for msg1, can only be 15 for 30 kHz < 6 GHz, takes precendence over the one derived from prach-ConfigIndex + msg1_SubcarrierSpacing = 0; +# restrictedSetConfig +# 0=unrestricted, 1=restricted type A, 2=restricted type B + restrictedSetConfig = 0; + + msg3_DeltaPreamble = 1; + p0_NominalWithGrant =-90; + +# pucch-ConfigCommon setup : +# pucchGroupHopping +# 0 = neither, 1= group hopping, 2=sequence hopping + pucchGroupHopping = 0; + hoppingId = 40; + p0_nominal = -90; +# ssb_PositionsInBurs_BitmapPR +# 1=short, 2=medium, 3=long + ssb_PositionsInBurst_PR = 2; + ssb_PositionsInBurst_Bitmap = 0x1; + +# 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 = 0; + + + #tdd-UL-DL-ConfigurationCommon +# subcarrierSpacing +# 0=kHz15, 1=kHz30, 2=kHz60, 3=kHz120 + referenceSubcarrierSpacing = 0; + # 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; + }; + + + ////////// MME parameters: + mme_ip_address = ( { ipv4 = "192.168.12.26"; + ipv6 = "192:168:30::17"; + active = "yes"; + preference = "ipv4"; + } + ); + + NETWORK_INTERFACES : + { + + GNB_INTERFACE_NAME_FOR_S1_MME = "eth0"; + GNB_IPV4_ADDRESS_FOR_S1_MME = "192.168.12.111/24"; + GNB_INTERFACE_NAME_FOR_S1U = "eth0"; + GNB_IPV4_ADDRESS_FOR_S1U = "192.168.12.111/24"; + GNB_PORT_FOR_S1U = 2152; # Spec 2152 + }; + } +); + +MACRLCs = ( + { + num_cc = 1; + tr_s_preference = "local_L1"; + tr_n_preference = "local_RRC"; + } +); + +L1s = ( + { + num_cc = 1; + tr_n_preference = "local_mac"; + thread_pool_size = 8; + 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 = [7]; + max_pdschReferenceSignalPower = -27; + max_rxgain = 50; + eNB_instances = [0]; + ## beamforming 1x2 matrix: 1 layer x 2 antennas + bf_weights = [0x00007fff, 0x0000]; + ## beamforming 1x4 matrix: 1 layer x 4 antennas + #bf_weights = [0x00007fff, 0x0000,0x0000, 0x0000]; + ## beamforming 2x2 matrix: + #bf_weights = [0x00007fff, 0x00000000, 0x00000000, 0x00007fff]; + ## beamforming 4x4 matrix: + #bf_weights = [0x00007fff, 0x0000, 0x0000, 0x0000, 0x00000000, 0x00007fff, 0x0000, 0x0000, 0x0000, 0x0000, 0x00007fff, 0x0000, 0x0000, 0x0000, 0x0000, 0x00007fff]; + sdr_addrs = "addr=192.168.10.2,mgmt_addr=192.168.10.2,second_addr=192.168.20.2"; + clock_src = "external"; + # if_freq = 3700000000L; + # if_offset = 1000000; + } +); + +THREAD_STRUCT = ( + { + #three config for level of parallelism "PARALLEL_SINGLE_THREAD", "PARALLEL_RU_L1_SPLIT", or "PARALLEL_RU_L1_TRX_SPLIT" + parallel_config = "PARALLEL_RU_L1_TRX_SPLIT"; + #two option for worker "WORKER_DISABLE" or "WORKER_ENABLE" + worker_config = "WORKER_DISABLE"; + } +); + +security = { + # preferred ciphering algorithms + # the first one of the list that an UE supports in chosen + # valid values: nea0, nea1, nea2, nea3 + ciphering_algorithms = ( "nea0" ); + + # preferred integrity algorithms + # the first one of the list that an UE supports in chosen + # valid values: nia0, nia1, nia2, nia3 + integrity_algorithms = ( "nia2", "nia0" ); + + # setting 'drb_ciphering' to "no" disables ciphering for DRBs, no matter + # what 'ciphering_algorithms' configures; same thing for 'drb_integrity' + drb_ciphering = "yes"; + drb_integrity = "no"; +}; + + log_config : + { + global_log_level ="info"; + hw_log_level ="info"; + phy_log_level ="info"; + mac_log_level ="info"; + rlc_log_level ="info"; + pdcp_log_level ="info"; + rrc_log_level ="info"; + }; + diff --git a/targets/PROJECTS/GENERIC-LTE-EPC/CONF/gnb.band78.106PRB.30kHz,usrpb2x0.conf b/targets/PROJECTS/GENERIC-LTE-EPC/CONF/gnb.band78.106PRB.30kHz,usrpb2x0.conf index 683cdaeb2c..2ae4df07d9 100644 --- a/targets/PROJECTS/GENERIC-LTE-EPC/CONF/gnb.band78.106PRB.30kHz,usrpb2x0.conf +++ b/targets/PROJECTS/GENERIC-LTE-EPC/CONF/gnb.band78.106PRB.30kHz,usrpb2x0.conf @@ -22,8 +22,6 @@ gNBs = ////////// Physical parameters: ssb_SubcarrierOffset = 31; - pdsch_AntennaPorts = 1; - pusch_AntennaPorts = 1; servingCellConfigCommon = ( { diff --git a/targets/PROJECTS/GENERIC-LTE-EPC/CONF/gnb.band78.106PRB.slave.conf b/targets/PROJECTS/GENERIC-LTE-EPC/CONF/gnb.band78.106PRB.slave.conf index 2d85f446d7..21267870bd 100644 --- a/targets/PROJECTS/GENERIC-LTE-EPC/CONF/gnb.band78.106PRB.slave.conf +++ b/targets/PROJECTS/GENERIC-LTE-EPC/CONF/gnb.band78.106PRB.slave.conf @@ -22,9 +22,7 @@ gNBs = ////////// Physical parameters: ssb_SubcarrierOffset = 0; - pdsch_AntennaPorts = 1; - pusch_AntennaPorts = 1; - + servingCellConfigCommon = ( { #spCellConfigCommon diff --git a/targets/PROJECTS/GENERIC-LTE-EPC/CONF/gnb.band78.slave.conf b/targets/PROJECTS/GENERIC-LTE-EPC/CONF/gnb.band78.slave.conf index e1c9e9e167..a0fd0bda9f 100644 --- a/targets/PROJECTS/GENERIC-LTE-EPC/CONF/gnb.band78.slave.conf +++ b/targets/PROJECTS/GENERIC-LTE-EPC/CONF/gnb.band78.slave.conf @@ -22,8 +22,6 @@ gNBs = ////////// Physical parameters: ssb_SubcarrierOffset = 0; - pdsch_AntennaPorts = 1; - pusch_AntennaPorts = 1; servingCellConfigCommon = ( { diff --git a/targets/PROJECTS/GENERIC-LTE-EPC/CONF/gnb.band78.tm1.106PRB.PTRS.usrpx300.conf b/targets/PROJECTS/GENERIC-LTE-EPC/CONF/gnb.band78.tm1.106PRB.PTRS.usrpx300.conf index 367ced1c8a..5c8f90d9b5 100644 --- a/targets/PROJECTS/GENERIC-LTE-EPC/CONF/gnb.band78.tm1.106PRB.PTRS.usrpx300.conf +++ b/targets/PROJECTS/GENERIC-LTE-EPC/CONF/gnb.band78.tm1.106PRB.PTRS.usrpx300.conf @@ -22,8 +22,6 @@ gNBs = ////////// Physical parameters: ssb_SubcarrierOffset = 0; - pdsch_AntennaPorts = 1; - pusch_AntennaPorts = 1; servingCellConfigCommon = ( { diff --git a/targets/PROJECTS/GENERIC-LTE-EPC/CONF/gnb.band78.tm1.106PRB.usrpb210.conf b/targets/PROJECTS/GENERIC-LTE-EPC/CONF/gnb.band78.tm1.106PRB.usrpb210.conf index e7d671e6a4..7bf3626870 100644 --- a/targets/PROJECTS/GENERIC-LTE-EPC/CONF/gnb.band78.tm1.106PRB.usrpb210.conf +++ b/targets/PROJECTS/GENERIC-LTE-EPC/CONF/gnb.band78.tm1.106PRB.usrpb210.conf @@ -22,9 +22,7 @@ gNBs = ////////// Physical parameters: ssb_SubcarrierOffset = 0; - pdsch_AntennaPorts = 1; - pusch_AntennaPorts = 1; - + servingCellConfigCommon = ( { #spCellConfigCommon diff --git a/targets/PROJECTS/GENERIC-LTE-EPC/CONF/gnb.band78.tm1.106PRB.usrpn300.conf b/targets/PROJECTS/GENERIC-LTE-EPC/CONF/gnb.band78.tm1.106PRB.usrpn300.conf index c9363da7f8..909c54b858 100644 --- a/targets/PROJECTS/GENERIC-LTE-EPC/CONF/gnb.band78.tm1.106PRB.usrpn300.conf +++ b/targets/PROJECTS/GENERIC-LTE-EPC/CONF/gnb.band78.tm1.106PRB.usrpn300.conf @@ -22,8 +22,6 @@ gNBs = ////////// Physical parameters: ssb_SubcarrierOffset = 0; - pdsch_AntennaPorts = 1; - pusch_AntennaPorts = 1; servingCellConfigCommon = ( { @@ -184,11 +182,11 @@ gNBs = ); MACRLCs = ( - { - num_cc = 1; - tr_s_preference = "local_L1"; - tr_n_preference = "local_RRC"; - } + { + num_cc = 1; + tr_s_preference = "local_L1"; + tr_n_preference = "local_RRC"; + } ); L1s = ( @@ -196,6 +194,7 @@ L1s = ( num_cc = 1; tr_n_preference = "local_mac"; thread_pool_size = 8; + max_ldpc_iterations = 5; ofdm_offset_divisor = 8; #set this to UINT_MAX for offset 0 } ); @@ -203,7 +202,7 @@ L1s = ( RUs = ( { local_rf = "yes" - nb_tx = 1 + nb_tx = 4 nb_rx = 1 att_tx = 0 att_rx = 0; @@ -217,8 +216,10 @@ RUs = ( #bf_weights = [0x00007fff, 0x0000,0x0000, 0x0000]; ## beamforming 2x2 matrix: #bf_weights = [0x00007fff, 0x00000000, 0x00000000, 0x00007fff]; - ## beamforming 4x4 matrix: - #bf_weights = [0x00007fff, 0x0000, 0x0000, 0x0000, 0x00000000, 0x00007fff, 0x0000, 0x0000, 0x0000, 0x0000, 0x00007fff, 0x0000, 0x0000, 0x0000, 0x0000, 0x00007fff]; + ## beamforming 2x4 matrix: + #bf_weights = [0x00007fff, 0x0000, 0x0000, 0x0000, 0x0000, 0x00007fff, 0x0000, 0x0000]; + #beamforming 4x4 matrix: + bf_weights = [0x00007fff, 0x0000, 0x0000, 0x0000, 0x0000, 0x00007fff, 0x0000, 0x0000, 0x0000, 0x0000, 0x00007fff, 0x0000, 0x0000, 0x0000, 0x0000, 0x00007fff]; sdr_addrs = "addr=192.168.10.2,mgmt_addr=192.168.10.2,second_addr=192.168.20.2"; clock_src = "external"; } diff --git a/targets/PROJECTS/GENERIC-LTE-EPC/CONF/gnb.band78.tm1.106PRB.usrpx300.conf b/targets/PROJECTS/GENERIC-LTE-EPC/CONF/gnb.band78.tm1.106PRB.usrpx300.conf index 0e5ee33950..d0f394be16 100644 --- a/targets/PROJECTS/GENERIC-LTE-EPC/CONF/gnb.band78.tm1.106PRB.usrpx300.conf +++ b/targets/PROJECTS/GENERIC-LTE-EPC/CONF/gnb.band78.tm1.106PRB.usrpx300.conf @@ -22,8 +22,6 @@ gNBs = ////////// Physical parameters: ssb_SubcarrierOffset = 0; - pdsch_AntennaPorts = 1; - pusch_AntennaPorts = 1; servingCellConfigCommon = ( { diff --git a/targets/PROJECTS/GENERIC-LTE-EPC/CONF/gnb.band78.tm1.217PRB.usrpn300.conf b/targets/PROJECTS/GENERIC-LTE-EPC/CONF/gnb.band78.tm1.217PRB.usrpn300.conf index 019a0f0a36..0438e61337 100644 --- a/targets/PROJECTS/GENERIC-LTE-EPC/CONF/gnb.band78.tm1.217PRB.usrpn300.conf +++ b/targets/PROJECTS/GENERIC-LTE-EPC/CONF/gnb.band78.tm1.217PRB.usrpn300.conf @@ -22,8 +22,6 @@ gNBs = ////////// Physical parameters: ssb_SubcarrierOffset = 0; - pdsch_AntennaPorts = 1; - pusch_AntennaPorts = 1; servingCellConfigCommon = ( { diff --git a/targets/PROJECTS/GENERIC-LTE-EPC/CONF/gnb.band78.tm1.217PRB.usrpx300.conf b/targets/PROJECTS/GENERIC-LTE-EPC/CONF/gnb.band78.tm1.217PRB.usrpx300.conf index 35e742900a..66c2151eb8 100644 --- a/targets/PROJECTS/GENERIC-LTE-EPC/CONF/gnb.band78.tm1.217PRB.usrpx300.conf +++ b/targets/PROJECTS/GENERIC-LTE-EPC/CONF/gnb.band78.tm1.217PRB.usrpx300.conf @@ -22,9 +22,7 @@ gNBs = ////////// Physical parameters: ssb_SubcarrierOffset = 0; - pdsch_AntennaPorts = 1; - pusch_AntennaPorts = 1; - + servingCellConfigCommon = ( { #spCellConfigCommon diff --git a/targets/PROJECTS/GENERIC-LTE-EPC/CONF/gnb.band78.tm1.24PRB.usrpb210.conf b/targets/PROJECTS/GENERIC-LTE-EPC/CONF/gnb.band78.tm1.24PRB.usrpb210.conf index 37cde2feb1..c6ea066fc4 100644 --- a/targets/PROJECTS/GENERIC-LTE-EPC/CONF/gnb.band78.tm1.24PRB.usrpb210.conf +++ b/targets/PROJECTS/GENERIC-LTE-EPC/CONF/gnb.band78.tm1.24PRB.usrpb210.conf @@ -22,9 +22,7 @@ gNBs = ////////// Physical parameters: ssb_SubcarrierOffset = 0; - pdsch_AntennaPorts = 1; - pusch_AntennaPorts = 1; - + servingCellConfigCommon = ( { #spCellConfigCommon diff --git a/targets/PROJECTS/GENERIC-LTE-EPC/CONF/gnb.band78.tm1.24PRB.usrpn300.conf b/targets/PROJECTS/GENERIC-LTE-EPC/CONF/gnb.band78.tm1.24PRB.usrpn300.conf index f392240401..fcfe58a3c0 100644 --- a/targets/PROJECTS/GENERIC-LTE-EPC/CONF/gnb.band78.tm1.24PRB.usrpn300.conf +++ b/targets/PROJECTS/GENERIC-LTE-EPC/CONF/gnb.band78.tm1.24PRB.usrpn300.conf @@ -22,9 +22,7 @@ gNBs = ////////// Physical parameters: ssb_SubcarrierOffset = 0; - pdsch_AntennaPorts = 1; - pusch_AntennaPorts = 1; - + servingCellConfigCommon = ( { #spCellConfigCommon diff --git a/targets/PROJECTS/GENERIC-LTE-EPC/CONF/gnb.band78.tm1.24PRB.usrpx300.conf b/targets/PROJECTS/GENERIC-LTE-EPC/CONF/gnb.band78.tm1.24PRB.usrpx300.conf index 59af2a9187..2ad9757cb1 100644 --- a/targets/PROJECTS/GENERIC-LTE-EPC/CONF/gnb.band78.tm1.24PRB.usrpx300.conf +++ b/targets/PROJECTS/GENERIC-LTE-EPC/CONF/gnb.band78.tm1.24PRB.usrpx300.conf @@ -22,8 +22,6 @@ gNBs = ////////// Physical parameters: ssb_SubcarrierOffset = 0; - pdsch_AntennaPorts = 1; - pusch_AntennaPorts = 1; servingCellConfigCommon = ( { diff --git a/targets/PROJECTS/GENERIC-LTE-EPC/CONF/gnb.band78.tm1.273PRB.usrpn300.conf b/targets/PROJECTS/GENERIC-LTE-EPC/CONF/gnb.band78.tm1.273PRB.usrpn300.conf index 9358c3370f..44074f3fd9 100644 --- a/targets/PROJECTS/GENERIC-LTE-EPC/CONF/gnb.band78.tm1.273PRB.usrpn300.conf +++ b/targets/PROJECTS/GENERIC-LTE-EPC/CONF/gnb.band78.tm1.273PRB.usrpn300.conf @@ -22,8 +22,6 @@ gNBs = ////////// Physical parameters: ssb_SubcarrierOffset = 0; - pdsch_AntennaPorts = 1; - pusch_AntennaPorts = 1; servingCellConfigCommon = ( { diff --git a/targets/PROJECTS/GENERIC-LTE-EPC/CONF/rcc.band78.tm1.106PRB.nfapi.conf b/targets/PROJECTS/GENERIC-LTE-EPC/CONF/rcc.band78.tm1.106PRB.nfapi.conf index 004ad4db78..7ce150506f 100644 --- a/targets/PROJECTS/GENERIC-LTE-EPC/CONF/rcc.band78.tm1.106PRB.nfapi.conf +++ b/targets/PROJECTS/GENERIC-LTE-EPC/CONF/rcc.band78.tm1.106PRB.nfapi.conf @@ -22,8 +22,6 @@ gNBs = ////////// Physical parameters: ssb_SubcarrierOffset = 0; - pdsch_AntennaPorts = 1; - pusch_AntennaPorts = 1; servingCellConfigCommon = ( { diff --git a/targets/PROJECTS/GENERIC-LTE-EPC/CONF/testing_gnb.conf b/targets/PROJECTS/GENERIC-LTE-EPC/CONF/testing_gnb.conf index 4ec53064f1..306e652eaa 100644 --- a/targets/PROJECTS/GENERIC-LTE-EPC/CONF/testing_gnb.conf +++ b/targets/PROJECTS/GENERIC-LTE-EPC/CONF/testing_gnb.conf @@ -22,8 +22,6 @@ gNBs = ////////// Physical parameters: ssb_SubcarrierOffset = 31; //0; - pdsch_AntennaPorts = 1; - pusch_AntennaPorts = 1; servingCellConfigCommon = ( { diff --git a/targets/PROJECTS/GENERIC-LTE-EPC/CONF/testing_gnb_24PRB.conf b/targets/PROJECTS/GENERIC-LTE-EPC/CONF/testing_gnb_24PRB.conf index 7c0fa96adb..d08c0f14a0 100644 --- a/targets/PROJECTS/GENERIC-LTE-EPC/CONF/testing_gnb_24PRB.conf +++ b/targets/PROJECTS/GENERIC-LTE-EPC/CONF/testing_gnb_24PRB.conf @@ -22,8 +22,6 @@ gNBs = ////////// Physical parameters: ssb_SubcarrierOffset = 31; //0; - pdsch_AntennaPorts = 1; - pusch_AntennaPorts = 1; servingCellConfigCommon = ( { diff --git a/targets/PROJECTS/GENERIC-LTE-EPC/CONF/testing_gnb_n310.conf b/targets/PROJECTS/GENERIC-LTE-EPC/CONF/testing_gnb_n310.conf index 57aa459d49..e3204db8fa 100644 --- a/targets/PROJECTS/GENERIC-LTE-EPC/CONF/testing_gnb_n310.conf +++ b/targets/PROJECTS/GENERIC-LTE-EPC/CONF/testing_gnb_n310.conf @@ -22,8 +22,6 @@ gNBs = ////////// Physical parameters: ssb_SubcarrierOffset = 31; //0; - pdsch_AntennaPorts = 1; - pusch_AntennaPorts = 1; servingCellConfigCommon = ( { diff --git a/targets/PROJECTS/GENERIC-LTE-EPC/CONF/testing_gnb_nsa_n310.conf b/targets/PROJECTS/GENERIC-LTE-EPC/CONF/testing_gnb_nsa_n310.conf index 89dca2a75c..030dc10226 100644 --- a/targets/PROJECTS/GENERIC-LTE-EPC/CONF/testing_gnb_nsa_n310.conf +++ b/targets/PROJECTS/GENERIC-LTE-EPC/CONF/testing_gnb_nsa_n310.conf @@ -22,8 +22,6 @@ gNBs = ////////// Physical parameters: ssb_SubcarrierOffset = 31; //0; - pdsch_AntennaPorts = 1; - pusch_AntennaPorts = 1; pusch_TargetSNRx10 = 200; pucch_TargetSNRx10 = 200; diff --git a/targets/PROJECTS/GENERIC-NR-5GC/CONF/cu_gnb.conf b/targets/PROJECTS/GENERIC-NR-5GC/CONF/cu_gnb.conf index 43c2ab20ad..6aacd98c7f 100644 --- a/targets/PROJECTS/GENERIC-NR-5GC/CONF/cu_gnb.conf +++ b/targets/PROJECTS/GENERIC-NR-5GC/CONF/cu_gnb.conf @@ -13,7 +13,6 @@ gNBs = gNB_name = "gNB-Eurecom-CU"; - // Tracking area code, 0x0000 and 0xfffe are reserved values // Tracking area code, 0x0000 and 0xfffe are reserved values tracking_area_code = 1; plmn_list = ({ @@ -27,14 +26,14 @@ gNBs = }, { sst = 1; - sd = 0x1; #112233; // 0 false, else true + sd = 0x112233; // 0 false, else true } ); }); - nr_cellid = 12345678L + nr_cellid = 12345678L; tr_s_preference = "f1"; @@ -43,9 +42,145 @@ gNBs = remote_s_address = "127.0.0.3"; local_s_portc = 501; local_s_portd = 2152; - remote_s_portc = 501; + remote_s_portc = 500; remote_s_portd = 2152; + ssb_SubcarrierOffset = 0; + min_rxtxtime = 6; + pdcch_ConfigSIB1 = ( + { + controlResourceSetZero = 12; + searchSpaceZero = 0; + } + ); + + servingCellConfigCommon = ( + { + #spCellConfigCommon + + physCellId = 0; + +# downlinkConfigCommon + #frequencyInfoDL + # this is 3600 MHz + 43 PRBs@30kHz SCS (same as initial BWP) + absoluteFrequencySSB = 641280; + dl_frequencyBand = 78; + # this is 3600 MHz + dl_absoluteFrequencyPointA = 640008; + #scs-SpecificCarrierList + dl_offstToCarrier = 0; +# subcarrierSpacing +# 0=kHz15, 1=kHz30, 2=kHz60, 3=kHz120 + dl_subcarrierSpacing = 1; + dl_carrierBandwidth = 106; + #initialDownlinkBWP + #genericParameters + # this is RBstart=27,L=48 (275*(L-1))+RBstart + initialDLBWPlocationAndBandwidth = 28875; # 6366 12925 12956 28875 12952 +# subcarrierSpacing +# 0=kHz15, 1=kHz30, 2=kHz60, 3=kHz120 + initialDLBWPsubcarrierSpacing = 1; + #pdcch-ConfigCommon + initialDLBWPcontrolResourceSetZero = 11; + initialDLBWPsearchSpaceZero = 0; + + #uplinkConfigCommon + #frequencyInfoUL + ul_frequencyBand = 78; + #scs-SpecificCarrierList + ul_offstToCarrier = 0; +# subcarrierSpacing +# 0=kHz15, 1=kHz30, 2=kHz60, 3=kHz120 + ul_subcarrierSpacing = 1; + ul_carrierBandwidth = 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_PositionsInBurs_BitmapPR +# 1=short, 2=medium, 3=long + ssb_PositionsInBurst_PR = 2; + ssb_PositionsInBurst_Bitmap = 1; + +# ssb_periodicityServingCell +# 0 = ms5, 1=ms10, 2=ms20, 3=ms40, 4=ms80, 5=ms160, 6=spare2, 7=spare1 + ssb_periodicityServingCell = 2; + +# dmrs_TypeA_position +# 0 = pos2, 1 = pos3 + dmrs_TypeA_Position = 0; + +# subcarrierSpacing +# 0=kHz15, 1=kHz30, 2=kHz60, 3=kHz120 + subcarrierSpacing = 1; + + + #tdd-UL-DL-ConfigurationCommon +# subcarrierSpacing +# 0=kHz15, 1=kHz30, 2=kHz60, 3=kHz120 + referenceSubcarrierSpacing = 1; + # pattern1 + # dl_UL_TransmissionPeriodicity + # 0=ms0p5, 1=ms0p625, 2=ms1, 3=ms1p25, 4=ms2, 5=ms2p5, 6=ms5, 7=ms10 + dl_UL_TransmissionPeriodicity = 6; + nrofDownlinkSlots = 7; + nrofDownlinkSymbols = 6; + nrofUplinkSlots = 2; + nrofUplinkSymbols = 4; + + ssPBCH_BlockPower = -25; + } + + ); # ------- SCTP definitions SCTP : { @@ -56,7 +191,7 @@ gNBs = ////////// AMF parameters: - amf_ip_address = ( { ipv4 = "192.168.69.131"; + amf_ip_address = ( { ipv4 = "192.168.69.131"; ipv6 = "192:168:30::17"; active = "yes"; preference = "ipv4"; @@ -66,15 +201,31 @@ gNBs = NETWORK_INTERFACES : { - GNB_INTERFACE_NAME_FOR_NG_AMF = "bond0"; - GNB_IPV4_ADDRESS_FOR_NG_AMF = "192.168.18.207/24"; - GNB_INTERFACE_NAME_FOR_NGU = "bond0"; - GNB_IPV4_ADDRESS_FOR_NGU = "192.168.18.207/24"; + GNB_INTERFACE_NAME_FOR_NG_AMF = "eth0"; + GNB_IPV4_ADDRESS_FOR_NG_AMF = "192.168.18.207"; + GNB_INTERFACE_NAME_FOR_NGU = "eth0"; + GNB_IPV4_ADDRESS_FOR_NGU = "192.168.18.207"; GNB_PORT_FOR_S1U = 2152; # Spec 2152 }; } ); +security = { + # preferred ciphering algorithms + # the first one of the list that an UE supports in chosen + # valid values: nea0, nea1, nea2, nea3 + ciphering_algorithms = ( "nea0" ); + + # preferred integrity algorithms + # the first one of the list that an UE supports in chosen + # valid values: nia0, nia1, nia2, nia3 + integrity_algorithms = ( "nia2", "nia0" ); + + # setting 'drb_ciphering' to "no" disables ciphering for DRBs, no matter + # what 'ciphering_algorithms' configures; same thing for 'drb_integrity' + drb_ciphering = "yes"; + drb_integrity = "no"; +}; log_config : { global_log_level ="info"; diff --git a/targets/PROJECTS/GENERIC-NR-5GC/CONF/du_gnb.conf b/targets/PROJECTS/GENERIC-NR-5GC/CONF/du_gnb.conf index 0b6d7cd7c8..f95bdf91ae 100644 --- a/targets/PROJECTS/GENERIC-NR-5GC/CONF/du_gnb.conf +++ b/targets/PROJECTS/GENERIC-NR-5GC/CONF/du_gnb.conf @@ -12,7 +12,6 @@ gNBs = gNB_name = "gNB-Eurecom-DU"; - // Tracking area code, 0x0000 and 0xfffe are reserved values // Tracking area code, 0x0000 and 0xfffe are reserved values tracking_area_code = 1; plmn_list = ({ @@ -26,24 +25,19 @@ gNBs = }, { sst = 1; - sd = 0x1; #112233; // 0 false, else true + sd = 0x112233; // 0 false, else true } ); }); - nr_cellid = 12345678L - -# tr_s_preference = "local_mac" + nr_cellid = 12345678L; ////////// Physical parameters: ssb_SubcarrierOffset = 0; - pdsch_AntennaPorts = 1; - pusch_AntennaPorts = 1; - sib1_tda = 0; - + min_rxtxtime = 6; pdcch_ConfigSIB1 = ( { @@ -74,15 +68,14 @@ gNBs = #initialDownlinkBWP #genericParameters # this is RBstart=27,L=48 (275*(L-1))+RBstart - initialDLBWPlocationAndBandwidth = 12952; + initialDLBWPlocationAndBandwidth = 28875; # 6366 12925 12956 28875 12952 # subcarrierSpacing # 0=kHz15, 1=kHz30, 2=kHz60, 3=kHz120 initialDLBWPsubcarrierSpacing = 1; #pdcch-ConfigCommon - initialDLBWPcontrolResourceSetZero = 11; + initialDLBWPcontrolResourceSetZero = 11; initialDLBWPsearchSpaceZero = 0; - #uplinkConfigCommon #frequencyInfoUL ul_frequencyBand = 78; @@ -95,7 +88,7 @@ gNBs = pMax = 20; #initialUplinkBWP #genericParameters - initialULBWPlocationAndBandwidth = 12952; + initialULBWPlocationAndBandwidth = 28875; # subcarrierSpacing # 0=kHz15, 1=kHz30, 2=kHz60, 3=kHz120 initialULBWPsubcarrierSpacing = 1; @@ -107,7 +100,7 @@ gNBs = prach_msg1_FDM = 0; prach_msg1_FrequencyStart = 0; zeroCorrelationZoneConfig = 13; - preambleReceivedTargetPower = -118; + preambleReceivedTargetPower = -96; #preamblTransMax (0...10) = (3,4,5,6,7,8,10,20,50,100,200) preambleTransMax = 6; #powerRampingStep @@ -118,9 +111,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 = 3; + ssb_perRACH_OccasionAndCB_PreamblesPerSSB_PR = 4; #oneHalf (0..15) 4,8,12,16,...60,64 - ssb_perRACH_OccasionAndCB_PreamblesPerSSB = 15; + ssb_perRACH_OccasionAndCB_PreamblesPerSSB = 14; #ra_ContentionResolutionTimer #(0..7) 8,16,24,32,40,48,56,64 ra_ContentionResolutionTimer = 7; @@ -136,7 +129,6 @@ gNBs = # 0=unrestricted, 1=restricted type A, 2=restricted type B restrictedSetConfig = 0, - msg3_DeltaPreamble = 1; p0_NominalWithGrant =-90; @@ -177,7 +169,7 @@ gNBs = nrofUplinkSlots = 2; nrofUplinkSymbols = 4; - ssPBCH_BlockPower = 10; + ssPBCH_BlockPower = -25; } ); @@ -201,9 +193,9 @@ MACRLCs = ( local_n_if_name = "lo"; local_n_address = "127.0.0.3"; remote_n_address = "127.0.0.4"; - local_n_portc = 601; + local_n_portc = 500; local_n_portd = 2152; - remote_n_portc = 600; + remote_n_portc = 501; remote_n_portd = 2152; } @@ -214,6 +206,9 @@ L1s = ( num_cc = 1; tr_n_preference = "local_mac"; thread_pool_size = 8; + prach_dtx_threshold = 120; + pucch0_dtx_threshold = 150; + ofdm_offset_divisor = 8; #set this to UINT_MAX for offset 0 } ); @@ -224,21 +219,13 @@ RUs = ( nb_rx = 1 att_tx = 0 att_rx = 0; - bands = [7]; + bands = [78]; max_pdschReferenceSignalPower = -27; - max_rxgain = 75; + max_rxgain = 114; eNB_instances = [0]; - ##beamforming 1x2 matrix: 1 layer x 2 antennas - bf_weights = [0x00007fff, 0x0000]; - ##beamforming 1x4 matrix: 1 layer x 4 antennas - #bf_weights = [0x00007fff, 0x0000,0x0000, 0x0000]; - ## beamforming 2x2 matrix: - # bf_weights = [0x00007fff, 0x00000000, 0x00000000, 0x00007fff]; - ## beamforming 4x4 matrix: - #bf_weights = [0x00007fff, 0x0000, 0x0000, 0x0000, 0x00000000, 0x00007fff, 0x0000, 0x0000, 0x0000, 0x0000, 0x00007fff, 0x0000, 0x0000, 0x0000, 0x0000, 0x00007fff]; - - sdr_addrs = "addr=192.168.10.2,mgmt_addr=192.168.10.2,second_addr=192.168.20.2"; - clock_src = "external"; + #beamforming 1x4 matrix: + bf_weights = [0x00007fff, 0x0000, 0x0000, 0x0000]; + clock_src = "internal"; } ); @@ -250,6 +237,13 @@ THREAD_STRUCT = ( worker_config = "WORKER_ENABLE"; } ); +rfsimulator: { +serveraddr = "server"; + serverport = "4043"; + options = (); #("saviq"); or/and "chanmod" + modelname = "AWGN"; + IQfile = "/tmp/rfsimulator.iqs" +} log_config : { @@ -257,7 +251,7 @@ THREAD_STRUCT = ( hw_log_level ="info"; phy_log_level ="info"; mac_log_level ="info"; - rlc_log_level ="debug"; + rlc_log_level ="info"; pdcp_log_level ="info"; rrc_log_level ="info"; f1ap_log_level ="debug"; diff --git a/targets/PROJECTS/GENERIC-NR-5GC/CONF/gnb.band78.tm1.106PRB.usrpn300.gtp-itti.conf b/targets/PROJECTS/GENERIC-NR-5GC/CONF/gnb.band78.tm1.106PRB.usrpn300.gtp-itti.conf index b0e02ff2bc..f91683897f 100644 --- a/targets/PROJECTS/GENERIC-NR-5GC/CONF/gnb.band78.tm1.106PRB.usrpn300.gtp-itti.conf +++ b/targets/PROJECTS/GENERIC-NR-5GC/CONF/gnb.band78.tm1.106PRB.usrpn300.gtp-itti.conf @@ -37,9 +37,7 @@ gNBs = ////////// Physical parameters: ssb_SubcarrierOffset = 0; - pdsch_AntennaPorts = 1; - pusch_AntennaPorts = 1; - sib1_tda = 0; + servingCellConfigCommon = ( { #spCellConfigCommon diff --git a/targets/PROJECTS/GENERIC-NR-5GC/CONF/gnb.sa.band41.fr1.106PRB.usrpb210.conf b/targets/PROJECTS/GENERIC-NR-5GC/CONF/gnb.sa.band41.fr1.106PRB.usrpb210.conf index 9bf20b54ab..cd84e699c7 100644 --- a/targets/PROJECTS/GENERIC-NR-5GC/CONF/gnb.sa.band41.fr1.106PRB.usrpb210.conf +++ b/targets/PROJECTS/GENERIC-NR-5GC/CONF/gnb.sa.band41.fr1.106PRB.usrpb210.conf @@ -19,10 +19,6 @@ gNBs = { sst = 1; sd = 0x1; // 0 false, else true - }, - { - sst = 1; - sd = 0x112233; // 0 false, else true } ); @@ -33,10 +29,8 @@ gNBs = ////////// Physical parameters: ssb_SubcarrierOffset = 0; - pdsch_AntennaPorts = 1; - pusch_AntennaPorts = 1; - min_rxtxtime = 6; - sib1_tda = 0; + min_rxtxtime = 2; + do_CSIRS = 1; do_SRS = 1; pdcch_ConfigSIB1 = ( @@ -174,6 +168,64 @@ gNBs = ); +# Dedicated Serving Cell Configuration +servingCellConfigDedicated = ({ + # BWP-Downlink + # BWP 1 Configuration + dl_bwp-Id_1 = 1; + dl_bwp1_locationAndBandwidth = 28875; // RBstart=0, L=106 (40 MHz BW) + # subcarrierSpacing + # 0=kHz15, 1=kHz30, 2=kHz60, 3=kHz120 + dl_bwp1_subcarrierSpacing = 1; + + # BWP 2 Configuration + dl_bwp-Id_2 = 2; + dl_bwp2_locationAndBandwidth = 13750; // RBstart=0, L=51 (20 MHz BW) + # subcarrierSpacing + # 0=kHz15, 1=kHz30, 2=kHz60, 3=kHz120 + dl_bwp2_subcarrierSpacing = 1; + + # BWP 3 Configuration + dl_bwp-Id_3 = 3; + dl_bwp3_locationAndBandwidth = 6325; // RBstart=0, L=24 (10 MHz BW) + # subcarrierSpacing + # 0=kHz15, 1=kHz30, 2=kHz60, 3=kHz120 + dl_bwp3_subcarrierSpacing = 1; + + firstActiveDownlinkBWP-Id = 1; #BWP-Id + defaultDownlinkBWP-Id = 1; #BWP-Id + + # bwp-InactivityTimer ENUMERATED {ms2, ms3, ms4, ms5, ms6, ms8, ms10, ms20, ms30, + # ms40,ms50, ms60, ms80,ms100, ms200,ms300, ms500, + # ms750, ms1280, ms1920, ms2560, spare10, spare9, spare8, + # spare7, spare6, spare5, spare4, spare3, spare2, spare1 } + + # UplinkConfig + # BWP-Uplink + # BWP 1 Configuration + ul_bwp-Id_1 = 1; + ul_bwp1_locationAndBandwidth = 28875; // RBstart=0, L=106 (40 MHz BW) + # subcarrierSpacing + # 0=kHz15, 1=kHz30, 2=kHz60, 3=kHz120 + ul_bwp1_subcarrierSpacing = 1; + + # BWP 2 Configuration + ul_bwp-Id_2 = 2; + ul_bwp2_locationAndBandwidth = 13750; // RBstart=0, L=51 (20 MHz BW) + # subcarrierSpacing + # 0=kHz15, 1=kHz30, 2=kHz60, 3=kHz120 + ul_bwp2_subcarrierSpacing = 1; + + # BWP 3 Configuration + ul_bwp-Id_3 = 3; + ul_bwp3_locationAndBandwidth = 6325; // RBstart=0, L=24 (10 MHz BW) + # subcarrierSpacing + # 0=kHz15, 1=kHz30, 2=kHz60, 3=kHz120 + ul_bwp3_subcarrierSpacing = 1; + + firstActiveUplinkBWP-Id = 1; #BWP-Id + } +); # ------- SCTP definitions SCTP : @@ -221,7 +273,7 @@ L1s = ( num_cc = 1; tr_n_preference = "local_mac"; prach_dtx_threshold = 120; - pucch0_dtx_threshold = 150; + pucch0_dtx_threshold = 100; ofdm_offset_divisor = 8; #set this to UINT_MAX for offset 0 } ); @@ -231,12 +283,11 @@ RUs = ( local_rf = "yes" nb_tx = 1 nb_rx = 1 - att_tx = 0 - att_rx = 0; + att_tx = 6; + att_rx = 6; bands = [41]; max_pdschReferenceSignalPower = -27; max_rxgain = 114; - sf_extension = 0; eNB_instances = [0]; #beamforming 1x4 matrix: bf_weights = [0x00007fff, 0x0000, 0x0000, 0x0000]; diff --git a/targets/PROJECTS/GENERIC-NR-5GC/CONF/gnb.sa.band66.fr1.106PRB.usrpn300.conf b/targets/PROJECTS/GENERIC-NR-5GC/CONF/gnb.sa.band66.fr1.106PRB.usrpn300.conf index cab801525b..ff64fe718a 100644 --- a/targets/PROJECTS/GENERIC-NR-5GC/CONF/gnb.sa.band66.fr1.106PRB.usrpn300.conf +++ b/targets/PROJECTS/GENERIC-NR-5GC/CONF/gnb.sa.band66.fr1.106PRB.usrpn300.conf @@ -36,7 +36,6 @@ gNBs = pdsch_AntennaPorts = 1; pusch_AntennaPorts = 1; min_rxtxtime = 6; - sib1_tda = 0; pdcch_ConfigSIB1 = ( { diff --git a/targets/PROJECTS/GENERIC-NR-5GC/CONF/gnb.sa.band78.fr1.106PRB.2x2.usrpn300.conf b/targets/PROJECTS/GENERIC-NR-5GC/CONF/gnb.sa.band78.fr1.106PRB.2x2.usrpn300.conf index 9452f00eed..ef34e68934 100644 --- a/targets/PROJECTS/GENERIC-NR-5GC/CONF/gnb.sa.band78.fr1.106PRB.2x2.usrpn300.conf +++ b/targets/PROJECTS/GENERIC-NR-5GC/CONF/gnb.sa.band78.fr1.106PRB.2x2.usrpn300.conf @@ -19,10 +19,6 @@ gNBs = { sst = 1; sd = 0x1; // 0 false, else true - }, - { - sst = 1; - sd = 0x112233; // 0 false, else true } ); @@ -33,15 +29,15 @@ gNBs = ////////// Physical parameters: ssb_SubcarrierOffset = 0; - pdsch_AntennaPorts = 1; + pdsch_AntennaPorts_N1 = 2; pusch_AntennaPorts = 2; - sib1_tda = 0; + do_CSIRS = 1; do_SRS = 1; ul_prbblacklist = "51,52,53,54" pdcch_ConfigSIB1 = ( { - controlResourceSetZero = 11; + controlResourceSetZero = 12; searchSpaceZero = 0; } ); @@ -73,7 +69,7 @@ gNBs = # 0=kHz15, 1=kHz30, 2=kHz60, 3=kHz120 initialDLBWPsubcarrierSpacing = 1; #pdcch-ConfigCommon - initialDLBWPcontrolResourceSetZero = 11; + initialDLBWPcontrolResourceSetZero = 12; initialDLBWPsearchSpaceZero = 0; #uplinkConfigCommon @@ -100,7 +96,7 @@ gNBs = prach_msg1_FDM = 0; prach_msg1_FrequencyStart = 0; zeroCorrelationZoneConfig = 12; - preambleReceivedTargetPower = -104; + preambleReceivedTargetPower = -96; #preamblTransMax (0...10) = (3,4,5,6,7,8,10,20,50,100,200) preambleTransMax = 6; #powerRampingStep @@ -174,6 +170,64 @@ gNBs = ); +# Dedicated Serving Cell Configuration +servingCellConfigDedicated = ({ + # BWP-Downlink + # BWP 1 Configuration + dl_bwp-Id_1 = 1; + dl_bwp1_locationAndBandwidth = 28875; // RBstart=0, L=106 (40 MHz BW) + # subcarrierSpacing + # 0=kHz15, 1=kHz30, 2=kHz60, 3=kHz120 + dl_bwp1_subcarrierSpacing = 1; + + # BWP 2 Configuration + dl_bwp-Id_2 = 2; + dl_bwp2_locationAndBandwidth = 13750; // RBstart=0, L=51 (20 MHz BW) + # subcarrierSpacing + # 0=kHz15, 1=kHz30, 2=kHz60, 3=kHz120 + dl_bwp2_subcarrierSpacing = 1; + + # BWP 3 Configuration + dl_bwp-Id_3 = 3; + dl_bwp3_locationAndBandwidth = 6325; // RBstart=0, L=24 (10 MHz BW) + # subcarrierSpacing + # 0=kHz15, 1=kHz30, 2=kHz60, 3=kHz120 + dl_bwp3_subcarrierSpacing = 1; + + firstActiveDownlinkBWP-Id = 1; #BWP-Id + defaultDownlinkBWP-Id = 1; #BWP-Id + + # bwp-InactivityTimer ENUMERATED {ms2, ms3, ms4, ms5, ms6, ms8, ms10, ms20, ms30, + # ms40,ms50, ms60, ms80,ms100, ms200,ms300, ms500, + # ms750, ms1280, ms1920, ms2560, spare10, spare9, spare8, + # spare7, spare6, spare5, spare4, spare3, spare2, spare1 } + + # UplinkConfig + # BWP-Uplink + # BWP 1 Configuration + ul_bwp-Id_1 = 1; + ul_bwp1_locationAndBandwidth = 28875; // RBstart=0, L=106 (40 MHz BW) + # subcarrierSpacing + # 0=kHz15, 1=kHz30, 2=kHz60, 3=kHz120 + ul_bwp1_subcarrierSpacing = 1; + + # BWP 2 Configuration + ul_bwp-Id_2 = 2; + ul_bwp2_locationAndBandwidth = 13750; // RBstart=0, L=51 (20 MHz BW) + # subcarrierSpacing + # 0=kHz15, 1=kHz30, 2=kHz60, 3=kHz120 + ul_bwp2_subcarrierSpacing = 1; + + # BWP 3 Configuration + ul_bwp-Id_3 = 3; + ul_bwp3_locationAndBandwidth = 6325; // RBstart=0, L=24 (10 MHz BW) + # subcarrierSpacing + # 0=kHz15, 1=kHz30, 2=kHz60, 3=kHz120 + ul_bwp3_subcarrierSpacing = 1; + + firstActiveUplinkBWP-Id = 1; #BWP-Id + } +); # ------- SCTP definitions SCTP : @@ -235,7 +289,6 @@ RUs = ( bands = [78]; max_pdschReferenceSignalPower = -27; max_rxgain = 75; - sf_extension = 0; eNB_instances = [0]; ##beamforming 1x2 matrix: 1 layer x 2 antennas bf_weights = [0x00007fff, 0x0000]; diff --git a/targets/PROJECTS/GENERIC-NR-5GC/CONF/gnb.sa.band78.fr1.106PRB.usrpb210.4layer.conf b/targets/PROJECTS/GENERIC-NR-5GC/CONF/gnb.sa.band78.fr1.106PRB.usrpb210.4layer.conf new file mode 100644 index 0000000000..74f2f9c11c --- /dev/null +++ b/targets/PROJECTS/GENERIC-NR-5GC/CONF/gnb.sa.band78.fr1.106PRB.usrpb210.4layer.conf @@ -0,0 +1,320 @@ +Active_gNBs = ( "gNB-Eurecom-5GNRBox"); +# Asn1_verbosity, choice in: none, info, annoying +Asn1_verbosity = "none"; + +gNBs = +( + { + ////////// Identification parameters: + gNB_ID = 0xe00; + gNB_name = "gNB-Eurecom-5GNRBox"; + + // Tracking area code, 0x0000 and 0xfffe are reserved values + tracking_area_code = 1; + plmn_list = ({ + mcc = 208; + mnc = 99; + mnc_length = 2; + snssaiList = ( + { + sst = 1; + sd = 0x1; // 0 false, else true + }, + { + sst = 1; + sd = 0x112233; // 0 false, else true + } + ); + + }); + + nr_cellid = 12345678L; + + ////////// Physical parameters: + + ssb_SubcarrierOffset = 0; + pdsch_AntennaPorts = 4; + pusch_AntennaPorts = 4; + sib1_tda = 0; + + pdcch_ConfigSIB1 = ( + { + controlResourceSetZero = 12; + searchSpaceZero = 0; + } + ); + + servingCellConfigCommon = ( + { + #spCellConfigCommon + + physCellId = 0; + +# downlinkConfigCommon + #frequencyInfoDL + # this is 3600 MHz + 43 PRBs@30kHz SCS (same as initial BWP) + absoluteFrequencySSB = 641280; + dl_frequencyBand = 78; + # this is 3600 MHz + dl_absoluteFrequencyPointA = 640008; + #scs-SpecificCarrierList + dl_offstToCarrier = 0; +# subcarrierSpacing +# 0=kHz15, 1=kHz30, 2=kHz60, 3=kHz120 + dl_subcarrierSpacing = 1; + dl_carrierBandwidth = 106; + #initialDownlinkBWP + #genericParameters + # this is RBstart=27,L=48 (275*(L-1))+RBstart + initialDLBWPlocationAndBandwidth = 28875; # 6366 12925 12956 28875 12952 +# subcarrierSpacing +# 0=kHz15, 1=kHz30, 2=kHz60, 3=kHz120 + initialDLBWPsubcarrierSpacing = 1; + #pdcch-ConfigCommon + initialDLBWPcontrolResourceSetZero = 12; + initialDLBWPsearchSpaceZero = 0; + #pdsch-ConfigCommon + #pdschTimeDomainAllocationList (up to 16 entries) + initialDLBWPk0_0 = 0; #for DL slot + initialDLBWPmappingType_0 = 0; #0=typeA,1=typeB + initialDLBWPstartSymbolAndLength_0 = 40; #this is SS=1,L=13 + + initialDLBWPk0_1 = 0; #for mixed slot + initialDLBWPmappingType_1 = 0; + initialDLBWPstartSymbolAndLength_1 = 57; #this is SS=1,L=5 + + #uplinkConfigCommon + #frequencyInfoUL + ul_frequencyBand = 78; + #scs-SpecificCarrierList + ul_offstToCarrier = 0; +# subcarrierSpacing +# 0=kHz15, 1=kHz30, 2=kHz60, 3=kHz120 + ul_subcarrierSpacing = 1; + ul_carrierBandwidth = 106; + pMax = 20; + #initialUplinkBWP + #genericParameters + initialULBWPlocationAndBandwidth = 28875; +# subcarrierSpacing +# 0=kHz15, 1=kHz30, 2=kHz60, 3=kHz120 + initialULBWPsubcarrierSpacing = 1; + #rach-ConfigCommon + #rach-ConfigGeneric + prach_ConfigurationIndex = 98; +#prach_msg1_FDM +#0 = one, 1=two, 2=four, 3=eight + prach_msg1_FDM = 0; + prach_msg1_FrequencyStart = 0; + zeroCorrelationZoneConfig = 13; + preambleReceivedTargetPower = -96; +#preamblTransMax (0...10) = (3,4,5,6,7,8,10,20,50,100,200) + preambleTransMax = 6; +#powerRampingStep +# 0=dB0,1=dB2,2=dB4,3=dB6 + powerRampingStep = 1; +#ra_ReponseWindow +#1,2,4,8,10,20,40,80 + ra_ResponseWindow = 4; +#ssb_perRACH_OccasionAndCB_PreamblesPerSSB_PR +#1=oneeighth,2=onefourth,3=half,4=one,5=two,6=four,7=eight,8=sixteen + ssb_perRACH_OccasionAndCB_PreamblesPerSSB_PR = 4; +#oneHalf (0..15) 4,8,12,16,...60,64 + ssb_perRACH_OccasionAndCB_PreamblesPerSSB = 14; +#ra_ContentionResolutionTimer +#(0..7) 8,16,24,32,40,48,56,64 + ra_ContentionResolutionTimer = 7; + rsrp_ThresholdSSB = 19; +#prach-RootSequenceIndex_PR +#1 = 839, 2 = 139 + prach_RootSequenceIndex_PR = 2; + prach_RootSequenceIndex = 1; + # SCS for msg1, can only be 15 for 30 kHz < 6 GHz, takes precendence over the one derived from prach-ConfigIndex + # + msg1_SubcarrierSpacing = 1, +# restrictedSetConfig +# 0=unrestricted, 1=restricted type A, 2=restricted type B + restrictedSetConfig = 0, + + # pusch-ConfigCommon (up to 16 elements) + initialULBWPk2_0 = 6; # used for UL slot + initialULBWPmappingType_0 = 1 + initialULBWPstartSymbolAndLength_0 = 41; # this is SS=0 L=13 + + initialULBWPk2_1 = 6; # used for mixed slot + initialULBWPmappingType_1 = 1; + initialULBWPstartSymbolAndLength_1 = 52; # this is SS=10 L=4 + + initialULBWPk2_2 = 7; # used for Msg.3 during RA + initialULBWPmappingType_2 = 1; + initialULBWPstartSymbolAndLength_2 = 52; # this is SS=10 L=4 + + msg3_DeltaPreamble = 1; + p0_NominalWithGrant =-90; + +# pucch-ConfigCommon setup : +# pucchGroupHopping +# 0 = neither, 1= group hopping, 2=sequence hopping + pucchGroupHopping = 0; + hoppingId = 40; + p0_nominal = -90; +# ssb_PositionsInBurs_BitmapPR +# 1=short, 2=medium, 3=long + ssb_PositionsInBurst_PR = 2; + ssb_PositionsInBurst_Bitmap = 1; + +# ssb_periodicityServingCell +# 0 = ms5, 1=ms10, 2=ms20, 3=ms40, 4=ms80, 5=ms160, 6=spare2, 7=spare1 + ssb_periodicityServingCell = 2; + +# dmrs_TypeA_position +# 0 = pos2, 1 = pos3 + dmrs_TypeA_Position = 0; + +# subcarrierSpacing +# 0=kHz15, 1=kHz30, 2=kHz60, 3=kHz120 + subcarrierSpacing = 1; + + + #tdd-UL-DL-ConfigurationCommon +# subcarrierSpacing +# 0=kHz15, 1=kHz30, 2=kHz60, 3=kHz120 + referenceSubcarrierSpacing = 1; + # pattern1 + # dl_UL_TransmissionPeriodicity + # 0=ms0p5, 1=ms0p625, 2=ms1, 3=ms1p25, 4=ms2, 5=ms2p5, 6=ms5, 7=ms10 + dl_UL_TransmissionPeriodicity = 6; + nrofDownlinkSlots = 7; + nrofDownlinkSymbols = 6; + nrofUplinkSlots = 2; + nrofUplinkSymbols = 4; + + ssPBCH_BlockPower = -25; + } + + ); + + + # ------- SCTP definitions + SCTP : + { + # Number of streams to use in input/output + SCTP_INSTREAMS = 2; + SCTP_OUTSTREAMS = 2; + }; + + + ////////// MME parameters: + amf_ip_address = ( { ipv4 = "192.168.70.132"; + ipv6 = "192:168:30::17"; + active = "yes"; + preference = "ipv4"; + } + ); + + + NETWORK_INTERFACES : + { + GNB_INTERFACE_NAME_FOR_NG_AMF = "demo-oai"; + GNB_IPV4_ADDRESS_FOR_NG_AMF = "192.168.70.129/24"; + GNB_INTERFACE_NAME_FOR_NGU = "demo-oai"; + GNB_IPV4_ADDRESS_FOR_NGU = "192.168.70.129/24"; + GNB_PORT_FOR_S1U = 2152; # Spec 2152 + }; + + } +); + +MACRLCs = ( + { + num_cc = 1; + tr_s_preference = "local_L1"; + tr_n_preference = "local_RRC"; + pusch_TargetSNRx10 = 150; + pucch_TargetSNRx10 = 200; + } +); + +L1s = ( + { + num_cc = 1; + tr_n_preference = "local_mac"; + pusch_proc_threads = 8; + prach_dtx_threshold = 120; + pucch0_dtx_threshold = 150; + ofdm_offset_divisor = 8; #set this to UINT_MAX for offset 0 + } +); + +RUs = ( + { + local_rf = "yes" + nb_tx = 4 + nb_rx = 4 + att_tx = 0 + att_rx = 0; + bands = [78]; + max_pdschReferenceSignalPower = -27; + max_rxgain = 114; + eNB_instances = [0]; + #beamforming 1x4 matrix: + bf_weights = [0x00007fff, 0x0000, 0x0000, 0x0000, 0x00000000, 0x00007fff, 0x0000, 0x0000, 0x0000, 0x0000, 0x00007fff, 0x0000, 0x0000, 0x0000, 0x0000, 0x00007fff]; + clock_src = "internal"; + } +); + +THREAD_STRUCT = ( + { + #three config for level of parallelism "PARALLEL_SINGLE_THREAD", "PARALLEL_RU_L1_SPLIT", or "PARALLEL_RU_L1_TRX_SPLIT" + parallel_config = "PARALLEL_SINGLE_THREAD"; + #two option for worker "WORKER_DISABLE" or "WORKER_ENABLE" + worker_config = "WORKER_ENABLE"; + } +); + +rfsimulator : +{ + serveraddr = "server"; + serverport = "4043"; + options = (); #("saviq"); or/and "chanmod" + modelname = "AWGN"; + IQfile = "/tmp/rfsimulator.iqs"; +}; + +security = { + # preferred ciphering algorithms + # the first one of the list that an UE supports in chosen + # valid values: nea0, nea1, nea2, nea3 + ciphering_algorithms = ( "nea0" ); + + # preferred integrity algorithms + # the first one of the list that an UE supports in chosen + # valid values: nia0, nia1, nia2, nia3 + integrity_algorithms = ( "nia2", "nia0" ); + + # setting 'drb_ciphering' to "no" disables ciphering for DRBs, no matter + # what 'ciphering_algorithms' configures; same thing for 'drb_integrity' + drb_ciphering = "yes"; + drb_integrity = "no"; +}; + + log_config : + { + global_log_level ="info"; + global_log_verbosity ="medium"; + hw_log_level ="info"; + hw_log_verbosity ="medium"; + phy_log_level ="info"; + phy_log_verbosity ="medium"; + mac_log_level ="info"; + mac_log_verbosity ="high"; + rlc_log_level ="info"; + rlc_log_verbosity ="medium"; + pdcp_log_level ="info"; + pdcp_log_verbosity ="medium"; + rrc_log_level ="info"; + rrc_log_verbosity ="medium"; + ngap_log_level ="info"; + ngap_log_verbosity ="medium"; + }; + diff --git a/targets/PROJECTS/GENERIC-NR-5GC/CONF/gnb.sa.band78.fr1.106PRB.usrpb210.conf b/targets/PROJECTS/GENERIC-NR-5GC/CONF/gnb.sa.band78.fr1.106PRB.usrpb210.conf index 09cf892b91..eceb7c1755 100644 --- a/targets/PROJECTS/GENERIC-NR-5GC/CONF/gnb.sa.band78.fr1.106PRB.usrpb210.conf +++ b/targets/PROJECTS/GENERIC-NR-5GC/CONF/gnb.sa.band78.fr1.106PRB.usrpb210.conf @@ -19,10 +19,6 @@ gNBs = { sst = 1; sd = 0x1; // 0 false, else true - }, - { - sst = 1; - sd = 0x112233; // 0 false, else true } ); @@ -33,10 +29,9 @@ gNBs = ////////// Physical parameters: ssb_SubcarrierOffset = 0; - pdsch_AntennaPorts = 1; - pusch_AntennaPorts = 1; - min_rxtxtime = 6; - sib1_tda = 0; + min_rxtxtime = 2; + do_CSIRS = 1; + do_SRS = 1; pdcch_ConfigSIB1 = ( { @@ -173,6 +168,64 @@ gNBs = ); +# Dedicated Serving Cell Configuration +servingCellConfigDedicated = ({ + # BWP-Downlink + # BWP 1 Configuration + dl_bwp-Id_1 = 1; + dl_bwp1_locationAndBandwidth = 28875; // RBstart=0, L=106 (40 MHz BW) + # subcarrierSpacing + # 0=kHz15, 1=kHz30, 2=kHz60, 3=kHz120 + dl_bwp1_subcarrierSpacing = 1; + + # BWP 2 Configuration + dl_bwp-Id_2 = 2; + dl_bwp2_locationAndBandwidth = 13750; // RBstart=0, L=51 (20 MHz BW) + # subcarrierSpacing + # 0=kHz15, 1=kHz30, 2=kHz60, 3=kHz120 + dl_bwp2_subcarrierSpacing = 1; + + # BWP 3 Configuration + dl_bwp-Id_3 = 3; + dl_bwp3_locationAndBandwidth = 6325; // RBstart=0, L=24 (10 MHz BW) + # subcarrierSpacing + # 0=kHz15, 1=kHz30, 2=kHz60, 3=kHz120 + dl_bwp3_subcarrierSpacing = 1; + + firstActiveDownlinkBWP-Id = 1; #BWP-Id + defaultDownlinkBWP-Id = 1; #BWP-Id + + # bwp-InactivityTimer ENUMERATED {ms2, ms3, ms4, ms5, ms6, ms8, ms10, ms20, ms30, + # ms40,ms50, ms60, ms80,ms100, ms200,ms300, ms500, + # ms750, ms1280, ms1920, ms2560, spare10, spare9, spare8, + # spare7, spare6, spare5, spare4, spare3, spare2, spare1 } + + # UplinkConfig + # BWP-Uplink + # BWP 1 Configuration + ul_bwp-Id_1 = 1; + ul_bwp1_locationAndBandwidth = 28875; // RBstart=0, L=106 (40 MHz BW) + # subcarrierSpacing + # 0=kHz15, 1=kHz30, 2=kHz60, 3=kHz120 + ul_bwp1_subcarrierSpacing = 1; + + # BWP 2 Configuration + ul_bwp-Id_2 = 2; + ul_bwp2_locationAndBandwidth = 13750; // RBstart=0, L=51 (20 MHz BW) + # subcarrierSpacing + # 0=kHz15, 1=kHz30, 2=kHz60, 3=kHz120 + ul_bwp2_subcarrierSpacing = 1; + + # BWP 3 Configuration + ul_bwp-Id_3 = 3; + ul_bwp3_locationAndBandwidth = 6325; // RBstart=0, L=24 (10 MHz BW) + # subcarrierSpacing + # 0=kHz15, 1=kHz30, 2=kHz60, 3=kHz120 + ul_bwp3_subcarrierSpacing = 1; + + firstActiveUplinkBWP-Id = 1; #BWP-Id + } +); # ------- SCTP definitions SCTP : @@ -220,7 +273,7 @@ L1s = ( num_cc = 1; tr_n_preference = "local_mac"; prach_dtx_threshold = 120; - pucch0_dtx_threshold = 150; + pucch0_dtx_threshold = 100; ofdm_offset_divisor = 8; #set this to UINT_MAX for offset 0 } ); @@ -230,12 +283,11 @@ RUs = ( local_rf = "yes" nb_tx = 1 nb_rx = 1 - att_tx = 0 - att_rx = 0; + att_tx = 6; + att_rx = 6; bands = [78]; max_pdschReferenceSignalPower = -27; max_rxgain = 114; - sf_extension = 0; eNB_instances = [0]; #beamforming 1x4 matrix: bf_weights = [0x00007fff, 0x0000, 0x0000, 0x0000]; diff --git a/targets/PROJECTS/GENERIC-NR-5GC/CONF/gnb.sa.band78.fr1.106PRB.usrpb210.sabox.conf b/targets/PROJECTS/GENERIC-NR-5GC/CONF/gnb.sa.band78.fr1.106PRB.usrpb210.sabox.conf index 280461d2ab..8ca0c08876 100644 --- a/targets/PROJECTS/GENERIC-NR-5GC/CONF/gnb.sa.band78.fr1.106PRB.usrpb210.sabox.conf +++ b/targets/PROJECTS/GENERIC-NR-5GC/CONF/gnb.sa.band78.fr1.106PRB.usrpb210.sabox.conf @@ -31,8 +31,6 @@ gNBs = ////////// Physical parameters: ssb_SubcarrierOffset = 0; - pdsch_AntennaPorts = 1; - pusch_AntennaPorts = 1; pdcch_ConfigSIB1 = ( { diff --git a/targets/PROJECTS/GENERIC-NR-5GC/CONF/gnb.sa.band78.fr1.162PRB.2x2.usrpn300.conf b/targets/PROJECTS/GENERIC-NR-5GC/CONF/gnb.sa.band78.fr1.162PRB.2x2.usrpn300.conf index fac54a298b..e3ecf87ca0 100644 --- a/targets/PROJECTS/GENERIC-NR-5GC/CONF/gnb.sa.band78.fr1.162PRB.2x2.usrpn300.conf +++ b/targets/PROJECTS/GENERIC-NR-5GC/CONF/gnb.sa.band78.fr1.162PRB.2x2.usrpn300.conf @@ -19,28 +19,23 @@ gNBs = { sst = 1; sd = 0x1; // 0 false, else true - }, - { - sst = 1; - sd = 0x112233; // 0 false, else true } ); - }); nr_cellid = 12345678L; ////////// Physical parameters: - ssb_SubcarrierOffset = 0; - pdsch_AntennaPorts = 1; - pusch_AntennaPorts = 2; -# do_CSIRS = 1; - min_rxtxtime_pdsch = 2; - ul_prbblacklist = "79,80,81,82" + ssb_SubcarrierOffset = 0; + pdsch_AntennaPorts_XP = 1; + pusch_AntennaPorts = 2; + do_CSIRS = 0; + ul_prbblacklist = "79,80,81,82" + pdcch_ConfigSIB1 = ( { - controlResourceSetZero = 11; + controlResourceSetZero = 12; searchSpaceZero = 10; } ); @@ -66,27 +61,14 @@ gNBs = #initialDownlinkBWP #genericParameters # this is RBstart=0,L=162 (275*(275-L+1))+(274-RBstart)) - initialDLBWPlocationAndBandwidth = 31899; + initialDLBWPlocationAndBandwidth = 31624; # # subcarrierSpacing # 0=kHz15, 1=kHz30, 2=kHz60, 3=kHz120 initialDLBWPsubcarrierSpacing = 1; #pdcch-ConfigCommon - initialDLBWPcontrolResourceSetZero = 11; + initialDLBWPcontrolResourceSetZero = 12; initialDLBWPsearchSpaceZero = 10; - #pdsch-ConfigCommon - #pdschTimeDomainAllocationList (up to 16 entries) - initialDLBWPk0_0 = 0; - #initialULBWPmappingType - #0=typeA,1=typeB - initialDLBWPmappingType_0 = 0; - #this is SS=1,L=13 - initialDLBWPstartSymbolAndLength_0 = 40; - - initialDLBWPk0_1 = 0; - initialDLBWPmappingType_1 = 0; - #this is SS=1,L=5 - initialDLBWPstartSymbolAndLength_1 = 57; #uplinkConfigCommon #frequencyInfoUL @@ -100,7 +82,7 @@ gNBs = pMax = 20; #initialUplinkBWP #genericParameters - initialULBWPlocationAndBandwidth = 31899; + initialULBWPlocationAndBandwidth = 31624; # subcarrierSpacing # 0=kHz15, 1=kHz30, 2=kHz60, 3=kHz120 initialULBWPsubcarrierSpacing = 1; @@ -112,7 +94,7 @@ gNBs = prach_msg1_FDM = 0; prach_msg1_FrequencyStart = 0; zeroCorrelationZoneConfig = 12; - preambleReceivedTargetPower = -104; + preambleReceivedTargetPower = -96; #preamblTransMax (0...10) = (3,4,5,6,7,8,10,20,50,100,200) preambleTransMax = 6; #powerRampingStep @@ -141,22 +123,6 @@ gNBs = # 0=unrestricted, 1=restricted type A, 2=restricted type B restrictedSetConfig = 0, - # pusch-ConfigCommon (up to 16 elements) - initialULBWPk2_0 = 2; - initialULBWPmappingType_0 = 1 - # this is SS=2 L=13 - initialULBWPstartSymbolAndLength_0 = 41; - - initialULBWPk2_1 = 2; - initialULBWPmappingType_1 = 1; - # this is SS=0 L=4 - initialULBWPstartSymbolAndLength_1 = 52; - - initialULBWPk2_2 = 7; - initialULBWPmappingType_2 = 1; - # this is SS=10 L=4 - initialULBWPstartSymbolAndLength_2 = 52; - msg3_DeltaPreamble = 1; p0_NominalWithGrant =-90; @@ -238,7 +204,7 @@ MACRLCs = ( num_cc = 1; tr_s_preference = "local_L1"; tr_n_preference = "local_RRC"; - pusch_TargetSNRx10 = 200; + pusch_TargetSNRx10 = 150; pucch_TargetSNRx10 = 200; ulsch_max_frame_inactivity = 0; } @@ -249,21 +215,20 @@ L1s = ( num_cc = 1; tr_n_preference = "local_mac"; prach_dtx_threshold = 120; - pucch0_dtx_threshold = 120; + pucch0_dtx_threshold = 80; } ); RUs = ( { local_rf = "yes" - nb_tx = 2 - nb_rx = 2 - att_tx = 0 + nb_tx = 2; + nb_rx = 2; + att_tx = 0; att_rx = 0; bands = [78]; max_pdschReferenceSignalPower = -27; max_rxgain = 75; - sf_extension = 0; eNB_instances = [0]; ##beamforming 1x2 matrix: 1 layer x 2 antennas bf_weights = [0x00007fff, 0x0000]; diff --git a/targets/PROJECTS/GENERIC-NR-5GC/CONF/gnb.sa.band78.fr1.217PRB.2x2.usrpn300.conf b/targets/PROJECTS/GENERIC-NR-5GC/CONF/gnb.sa.band78.fr1.217PRB.2x2.usrpn300.conf new file mode 100644 index 0000000000..763396998d --- /dev/null +++ b/targets/PROJECTS/GENERIC-NR-5GC/CONF/gnb.sa.band78.fr1.217PRB.2x2.usrpn300.conf @@ -0,0 +1,321 @@ +Active_gNBs = ( "gNB-OAI"); +# Asn1_verbosity, choice in: none, info, annoying +Asn1_verbosity = "none"; + +gNBs = +( + { + ////////// Identification parameters: + gNB_ID = 0xe00; + gNB_name = "gNB-OAI"; + + // Tracking area code, 0x0000 and 0xfffe are reserved values + tracking_area_code = 1; + plmn_list = ({ + mcc = 208; + mnc = 99; + mnc_length = 2; + snssaiList = ( + { + sst = 1; + sd = 0x1; // 0 false, else true + } + ); + }); + + nr_cellid = 12345678L; + + ////////// Physical parameters: + + ssb_SubcarrierOffset = 0; + pdsch_AntennaPorts_XP = 1; + pusch_AntennaPorts = 2; + do_CSIRS = 0; + ul_prbblacklist = "107,108,109,110" + + pdcch_ConfigSIB1 = ( + { + controlResourceSetZero = 12; + searchSpaceZero = 10; + } + ); + + servingCellConfigCommon = ( + { + #spCellConfigCommon + + physCellId = 0; + +# downlinkConfigCommon + #frequencyInfoDL + # this is 3300.24 + 106*12*30e3 = 3338.40 MHz (5G NR GSCN: 7734) + absoluteFrequencySSB = 622560; + dl_frequencyBand = 78; + # this is 3300.24 MHz + dl_absoluteFrequencyPointA = 620016; + #scs-SpecificCarrierList + dl_offstToCarrier = 0; +# subcarrierSpacing +# 0=kHz15, 1=kHz30, 2=kHz60, 3=kHz120 + dl_subcarrierSpacing = 1; + dl_carrierBandwidth = 217; + #initialDownlinkBWP + #genericParameters + # 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; + #pdcch-ConfigCommon + initialDLBWPcontrolResourceSetZero = 12; + initialDLBWPsearchSpaceZero = 10; + + #uplinkConfigCommon + #frequencyInfoUL + ul_frequencyBand = 78; + #scs-SpecificCarrierList + ul_offstToCarrier = 0; +# subcarrierSpacing +# 0=kHz15, 1=kHz30, 2=kHz60, 3=kHz120 + ul_subcarrierSpacing = 1; + ul_carrierBandwidth = 217; + pMax = 20; + #initialUplinkBWP + #genericParameters + initialULBWPlocationAndBandwidth = 31624; +# subcarrierSpacing +# 0=kHz15, 1=kHz30, 2=kHz60, 3=kHz120 + initialULBWPsubcarrierSpacing = 1; + #rach-ConfigCommon + #rach-ConfigGeneric + prach_ConfigurationIndex = 98; +#prach_msg1_FDM +#0 = one, 1=two, 2=four, 3=eight + prach_msg1_FDM = 0; + prach_msg1_FrequencyStart = 0; + zeroCorrelationZoneConfig = 12; + preambleReceivedTargetPower = -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 = 3; +#oneHalf (0..15) 4,8,12,16,...60,64 + ssb_perRACH_OccasionAndCB_PreamblesPerSSB = 15; +#ra_ContentionResolutionTimer +#(0..7) 8,16,24,32,40,48,56,64 + ra_ContentionResolutionTimer = 7; + rsrp_ThresholdSSB = 19; +#prach-RootSequenceIndex_PR +#1 = 839, 2 = 139 + prach_RootSequenceIndex_PR = 2; + prach_RootSequenceIndex = 1; + # SCS for msg1, can only be 15 for 30 kHz < 6 GHz, takes precendence over the one derived from prach-ConfigIndex + # + msg1_SubcarrierSpacing = 1, +# restrictedSetConfig +# 0=unrestricted, 1=restricted type A, 2=restricted type B + restrictedSetConfig = 0, + + msg3_DeltaPreamble = 1; + p0_NominalWithGrant =-90; + +# pucch-ConfigCommon setup : +# pucchGroupHopping +# 0 = neither, 1= group hopping, 2=sequence hopping + pucchGroupHopping = 0; + hoppingId = 40; + p0_nominal = -70; +# ssb_PositionsInBurs_BitmapPR +# 1=short, 2=medium, 3=long + ssb_PositionsInBurst_PR = 2; + ssb_PositionsInBurst_Bitmap = 1; + +# ssb_periodicityServingCell +# 0 = ms5, 1=ms10, 2=ms20, 3=ms40, 4=ms80, 5=ms160, 6=spare2, 7=spare1 + ssb_periodicityServingCell = 2; + +# dmrs_TypeA_position +# 0 = pos2, 1 = pos3 + dmrs_TypeA_Position = 0; + +# subcarrierSpacing +# 0=kHz15, 1=kHz30, 2=kHz60, 3=kHz120 + subcarrierSpacing = 1; + + + #tdd-UL-DL-ConfigurationCommon +# subcarrierSpacing +# 0=kHz15, 1=kHz30, 2=kHz60, 3=kHz120 + referenceSubcarrierSpacing = 1; + # pattern1 + # dl_UL_TransmissionPeriodicity + # 0=ms0p5, 1=ms0p625, 2=ms1, 3=ms1p25, 4=ms2, 5=ms2p5, 6=ms5, 7=ms10 + dl_UL_TransmissionPeriodicity = 6; + nrofDownlinkSlots = 7; + nrofDownlinkSymbols = 6; + nrofUplinkSlots = 2; + nrofUplinkSymbols = 4; + + ssPBCH_BlockPower = -25; + } + + ); + + +# Dedicated Serving Cell Configuration +servingCellConfigDedicated = ({ + # BWP-Downlink + # BWP 1 Configuration + dl_bwp-Id_1 = 1; + dl_bwp1_locationAndBandwidth = 16499; // RBstart=0, L=217 (80 MHz BW) + # subcarrierSpacing + # 0=kHz15, 1=kHz30, 2=kHz60, 3=kHz120 + dl_bwp1_subcarrierSpacing = 1; + + firstActiveDownlinkBWP-Id = 1; #BWP-Id + defaultDownlinkBWP-Id = 1; #BWP-Id + + # bwp-InactivityTimer ENUMERATED {ms2, ms3, ms4, ms5, ms6, ms8, ms10, ms20, ms30, + # ms40,ms50, ms60, ms80,ms100, ms200,ms300, ms500, + # ms750, ms1280, ms1920, ms2560, spare10, spare9, spare8, + # spare7, spare6, spare5, spare4, spare3, spare2, spare1 } + + # UplinkConfig + # BWP-Uplink + # BWP 1 Configuration + ul_bwp-Id_1 = 1; + ul_bwp1_locationAndBandwidth = 16499; // RBstart=0, L=217 (80 MHz BW) + # subcarrierSpacing + # 0=kHz15, 1=kHz30, 2=kHz60, 3=kHz120 + ul_bwp1_subcarrierSpacing = 1; + + firstActiveUplinkBWP-Id = 1; #BWP-Id + } +); + + + + # ------- SCTP definitions + SCTP : + { + # Number of streams to use in input/output + SCTP_INSTREAMS = 2; + SCTP_OUTSTREAMS = 2; + }; + + + ////////// AMF parameters: + amf_ip_address = ( { ipv4 = "192.168.70.132"; + ipv6 = "192:168:30::17"; + active = "yes"; + preference = "ipv4"; + } + ); + + + NETWORK_INTERFACES : + { + GNB_INTERFACE_NAME_FOR_NG_AMF = "demo-oai"; + GNB_IPV4_ADDRESS_FOR_NG_AMF = "192.168.70.129/24"; + GNB_INTERFACE_NAME_FOR_NGU = "demo-oai"; + GNB_IPV4_ADDRESS_FOR_NGU = "192.168.70.129/24"; + GNB_PORT_FOR_S1U = 2152; # Spec 2152 + }; + + } +); + +MACRLCs = ( +{ + num_cc = 1; + tr_s_preference = "local_L1"; + tr_n_preference = "local_RRC"; + pusch_TargetSNRx10 = 150; + pucch_TargetSNRx10 = 200; + pusch_FailureThres = 1000; + ulsch_max_frame_inactivity = 0; +} +); + +L1s = ( +{ + num_cc = 1; + tr_n_preference = "local_mac"; + prach_dtx_threshold = 120; + pucch0_dtx_threshold = 80; +} +); + +RUs = ( +{ + local_rf = "yes" + nb_tx = 2; + nb_rx = 2; + att_tx = 0; + att_rx = 0; + bands = [78]; + max_pdschReferenceSignalPower = -27; + max_rxgain = 75; + eNB_instances = [0]; + ##beamforming 1x2 matrix: 1 layer x 2 antennas + bf_weights = [0x00007fff, 0x0000]; + #clock_src = "internal"; + sdr_addrs = "mgmt_addr=192.168.10.2,addr=192.168.10.2,clock_source=internal,time_source=internal" +} +); + +THREAD_STRUCT = ( +{ + #three config for level of parallelism "PARALLEL_SINGLE_THREAD", "PARALLEL_RU_L1_SPLIT", or "PARALLEL_RU_L1_TRX_SPLIT" + parallel_config = "PARALLEL_SINGLE_THREAD"; + #two option for worker "WORKER_DISABLE" or "WORKER_ENABLE" + worker_config = "WORKER_ENABLE"; +} +); + +rfsimulator : +{ + serveraddr = "server"; + serverport = "4043"; + options = (); #("saviq"); or/and "chanmod" + modelname = "AWGN"; + IQfile = "/tmp/rfsimulator.iqs"; +}; + +security = { + # preferred ciphering algorithms + # the first one of the list that an UE supports in chosen + # valid values: nea0, nea1, nea2, nea3 + ciphering_algorithms = ( "nea0" ); + + # preferred integrity algorithms + # the first one of the list that an UE supports in chosen + # valid values: nia0, nia1, nia2, nia3 + integrity_algorithms = ( "nia2", "nia0" ); + + # setting 'drb_ciphering' to "no" disables ciphering for DRBs, no matter + # what 'ciphering_algorithms' configures; same thing for 'drb_integrity' + drb_ciphering = "yes"; + drb_integrity = "no"; +}; + +log_config : +{ + global_log_level ="info"; + 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"; +}; \ No newline at end of file diff --git a/targets/PROJECTS/GENERIC-NR-5GC/CONF/gnb.sa.band78.fr1.273PRB.2x2.usrpn300.conf b/targets/PROJECTS/GENERIC-NR-5GC/CONF/gnb.sa.band78.fr1.273PRB.2x2.usrpn300.conf new file mode 100644 index 0000000000..3d93f2cfab --- /dev/null +++ b/targets/PROJECTS/GENERIC-NR-5GC/CONF/gnb.sa.band78.fr1.273PRB.2x2.usrpn300.conf @@ -0,0 +1,321 @@ +Active_gNBs = ( "gNB-OAI"); +# Asn1_verbosity, choice in: none, info, annoying +Asn1_verbosity = "none"; + +gNBs = +( + { + ////////// Identification parameters: + gNB_ID = 0xe00; + gNB_name = "gNB-OAI"; + + // Tracking area code, 0x0000 and 0xfffe are reserved values + tracking_area_code = 1; + plmn_list = ({ + mcc = 208; + mnc = 99; + mnc_length = 2; + snssaiList = ( + { + sst = 1; + sd = 0x1; // 0 false, else true + } + ); + }); + + nr_cellid = 12345678L; + + ////////// Physical parameters: + + ssb_SubcarrierOffset = 0; + pdsch_AntennaPorts_XP = 1; + pusch_AntennaPorts = 2; + do_CSIRS = 0; + ul_prbblacklist = "135,136,137,138" + + pdcch_ConfigSIB1 = ( + { + controlResourceSetZero = 12; + searchSpaceZero = 10; + } + ); + + servingCellConfigCommon = ( + { + #spCellConfigCommon + + physCellId = 0; + +# downlinkConfigCommon + #frequencyInfoDL + # this is 3300.24 + 134*12*30e3 = 3348.48 MHz (5G NR GSCN: 7741) + absoluteFrequencySSB = 623232; + dl_frequencyBand = 78; + # this is 3300.24 MHz + dl_absoluteFrequencyPointA = 620016; + #scs-SpecificCarrierList + dl_offstToCarrier = 0; +# subcarrierSpacing +# 0=kHz15, 1=kHz30, 2=kHz60, 3=kHz120 + dl_subcarrierSpacing = 1; + dl_carrierBandwidth = 273; + #initialDownlinkBWP + #genericParameters + # 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; + #pdcch-ConfigCommon + initialDLBWPcontrolResourceSetZero = 12; + initialDLBWPsearchSpaceZero = 10; + + #uplinkConfigCommon + #frequencyInfoUL + ul_frequencyBand = 78; + #scs-SpecificCarrierList + ul_offstToCarrier = 0; +# subcarrierSpacing +# 0=kHz15, 1=kHz30, 2=kHz60, 3=kHz120 + ul_subcarrierSpacing = 1; + ul_carrierBandwidth = 273; + pMax = 20; + #initialUplinkBWP + #genericParameters + initialULBWPlocationAndBandwidth = 31624; +# subcarrierSpacing +# 0=kHz15, 1=kHz30, 2=kHz60, 3=kHz120 + initialULBWPsubcarrierSpacing = 1; + #rach-ConfigCommon + #rach-ConfigGeneric + prach_ConfigurationIndex = 98; +#prach_msg1_FDM +#0 = one, 1=two, 2=four, 3=eight + prach_msg1_FDM = 0; + prach_msg1_FrequencyStart = 0; + zeroCorrelationZoneConfig = 12; + preambleReceivedTargetPower = -90; +#preamblTransMax (0...10) = (3,4,5,6,7,8,10,20,50,100,200) + preambleTransMax = 6; +#powerRampingStep +# 0=dB0,1=dB2,2=dB4,3=dB6 + powerRampingStep = 1; +#ra_ReponseWindow +#1,2,4,8,10,20,40,80 + ra_ResponseWindow = 4; +#ssb_perRACH_OccasionAndCB_PreamblesPerSSB_PR +#1=oneeighth,2=onefourth,3=half,4=one,5=two,6=four,7=eight,8=sixteen + ssb_perRACH_OccasionAndCB_PreamblesPerSSB_PR = 3; +#oneHalf (0..15) 4,8,12,16,...60,64 + ssb_perRACH_OccasionAndCB_PreamblesPerSSB = 15; +#ra_ContentionResolutionTimer +#(0..7) 8,16,24,32,40,48,56,64 + ra_ContentionResolutionTimer = 7; + rsrp_ThresholdSSB = 19; +#prach-RootSequenceIndex_PR +#1 = 839, 2 = 139 + prach_RootSequenceIndex_PR = 2; + prach_RootSequenceIndex = 1; + # SCS for msg1, can only be 15 for 30 kHz < 6 GHz, takes precendence over the one derived from prach-ConfigIndex + # + msg1_SubcarrierSpacing = 1, +# restrictedSetConfig +# 0=unrestricted, 1=restricted type A, 2=restricted type B + restrictedSetConfig = 0, + + msg3_DeltaPreamble = 1; + p0_NominalWithGrant =-90; + +# pucch-ConfigCommon setup : +# pucchGroupHopping +# 0 = neither, 1= group hopping, 2=sequence hopping + pucchGroupHopping = 0; + hoppingId = 40; + p0_nominal = -70; +# ssb_PositionsInBurs_BitmapPR +# 1=short, 2=medium, 3=long + ssb_PositionsInBurst_PR = 2; + ssb_PositionsInBurst_Bitmap = 1; + +# ssb_periodicityServingCell +# 0 = ms5, 1=ms10, 2=ms20, 3=ms40, 4=ms80, 5=ms160, 6=spare2, 7=spare1 + ssb_periodicityServingCell = 2; + +# dmrs_TypeA_position +# 0 = pos2, 1 = pos3 + dmrs_TypeA_Position = 0; + +# subcarrierSpacing +# 0=kHz15, 1=kHz30, 2=kHz60, 3=kHz120 + subcarrierSpacing = 1; + + + #tdd-UL-DL-ConfigurationCommon +# subcarrierSpacing +# 0=kHz15, 1=kHz30, 2=kHz60, 3=kHz120 + referenceSubcarrierSpacing = 1; + # pattern1 + # dl_UL_TransmissionPeriodicity + # 0=ms0p5, 1=ms0p625, 2=ms1, 3=ms1p25, 4=ms2, 5=ms2p5, 6=ms5, 7=ms10 + dl_UL_TransmissionPeriodicity = 6; + nrofDownlinkSlots = 7; + nrofDownlinkSymbols = 6; + nrofUplinkSlots = 2; + nrofUplinkSymbols = 4; + + ssPBCH_BlockPower = -25; + } + + ); + + +# Dedicated Serving Cell Configuration +servingCellConfigDedicated = ({ + # BWP-Downlink + # BWP 1 Configuration + dl_bwp-Id_1 = 1; + dl_bwp1_locationAndBandwidth = 1099; // RBstart=0, L=273 (100 MHz BW) + # subcarrierSpacing + # 0=kHz15, 1=kHz30, 2=kHz60, 3=kHz120 + dl_bwp1_subcarrierSpacing = 1; + + firstActiveDownlinkBWP-Id = 1; #BWP-Id + defaultDownlinkBWP-Id = 1; #BWP-Id + + # bwp-InactivityTimer ENUMERATED {ms2, ms3, ms4, ms5, ms6, ms8, ms10, ms20, ms30, + # ms40,ms50, ms60, ms80,ms100, ms200,ms300, ms500, + # ms750, ms1280, ms1920, ms2560, spare10, spare9, spare8, + # spare7, spare6, spare5, spare4, spare3, spare2, spare1 } + + # UplinkConfig + # BWP-Uplink + # BWP 1 Configuration + ul_bwp-Id_1 = 1; + ul_bwp1_locationAndBandwidth = 1099; // RBstart=0, L=273 (100 MHz BW) + # subcarrierSpacing + # 0=kHz15, 1=kHz30, 2=kHz60, 3=kHz120 + ul_bwp1_subcarrierSpacing = 1; + + firstActiveUplinkBWP-Id = 1; #BWP-Id + } +); + + + + # ------- SCTP definitions + SCTP : + { + # Number of streams to use in input/output + SCTP_INSTREAMS = 2; + SCTP_OUTSTREAMS = 2; + }; + + + ////////// AMF parameters: + amf_ip_address = ( { ipv4 = "192.168.70.132"; + ipv6 = "192:168:30::17"; + active = "yes"; + preference = "ipv4"; + } + ); + + + NETWORK_INTERFACES : + { + GNB_INTERFACE_NAME_FOR_NG_AMF = "demo-oai"; + GNB_IPV4_ADDRESS_FOR_NG_AMF = "192.168.70.129/24"; + GNB_INTERFACE_NAME_FOR_NGU = "demo-oai"; + GNB_IPV4_ADDRESS_FOR_NGU = "192.168.70.129/24"; + GNB_PORT_FOR_S1U = 2152; # Spec 2152 + }; + + } +); + +MACRLCs = ( +{ + num_cc = 1; + tr_s_preference = "local_L1"; + tr_n_preference = "local_RRC"; + pusch_TargetSNRx10 = 150; + pucch_TargetSNRx10 = 200; + pusch_FailureThres = 1000; + ulsch_max_frame_inactivity = 0; +} +); + +L1s = ( +{ + num_cc = 1; + tr_n_preference = "local_mac"; + prach_dtx_threshold = 120; + pucch0_dtx_threshold = 80; +} +); + +RUs = ( +{ + local_rf = "yes" + nb_tx = 2; + nb_rx = 2; + att_tx = 0; + att_rx = 0; + bands = [78]; + max_pdschReferenceSignalPower = -27; + max_rxgain = 75; + eNB_instances = [0]; + ##beamforming 1x2 matrix: 1 layer x 2 antennas + bf_weights = [0x00007fff, 0x0000]; + #clock_src = "internal"; + sdr_addrs = "mgmt_addr=192.168.10.2,addr=192.168.10.2,clock_source=internal,time_source=internal" +} +); + +THREAD_STRUCT = ( +{ + #three config for level of parallelism "PARALLEL_SINGLE_THREAD", "PARALLEL_RU_L1_SPLIT", or "PARALLEL_RU_L1_TRX_SPLIT" + parallel_config = "PARALLEL_SINGLE_THREAD"; + #two option for worker "WORKER_DISABLE" or "WORKER_ENABLE" + worker_config = "WORKER_ENABLE"; +} +); + +rfsimulator : +{ + serveraddr = "server"; + serverport = "4043"; + options = (); #("saviq"); or/and "chanmod" + modelname = "AWGN"; + IQfile = "/tmp/rfsimulator.iqs"; +}; + +security = { + # preferred ciphering algorithms + # the first one of the list that an UE supports in chosen + # valid values: nea0, nea1, nea2, nea3 + ciphering_algorithms = ( "nea0" ); + + # preferred integrity algorithms + # the first one of the list that an UE supports in chosen + # valid values: nia0, nia1, nia2, nia3 + integrity_algorithms = ( "nia2", "nia0" ); + + # setting 'drb_ciphering' to "no" disables ciphering for DRBs, no matter + # what 'ciphering_algorithms' configures; same thing for 'drb_integrity' + drb_ciphering = "yes"; + drb_integrity = "no"; +}; + +log_config : +{ + global_log_level ="info"; + 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"; +}; \ No newline at end of file diff --git a/targets/RT/USER/lte-enb.c b/targets/RT/USER/lte-enb.c index 0b6b0b3a75..a3048995a5 100644 --- a/targets/RT/USER/lte-enb.c +++ b/targets/RT/USER/lte-enb.c @@ -112,8 +112,6 @@ extern int transmission_mode; extern int oaisim_flag; -//uint16_t sf_ahead=4; -extern uint16_t sf_ahead; #include "executables/thread-common.h" //extern PARALLEL_CONF_t get_thread_parallel_conf(void); //extern WORKER_CONF_t get_thread_worker_conf(void); @@ -466,11 +464,11 @@ void eNB_top(PHY_VARS_eNB *eNB, if (!oai_exit) { T(T_ENB_MASTER_TICK, T_INT(0), T_INT(ru_proc->frame_rx), T_INT(ru_proc->tti_rx)); - L1_proc->timestamp_tx = ru_proc->timestamp_rx + (sf_ahead*fp->samples_per_tti); + L1_proc->timestamp_tx = ru_proc->timestamp_rx + (ru->sf_ahead*fp->samples_per_tti); L1_proc->frame_rx = ru_proc->frame_rx; L1_proc->subframe_rx = ru_proc->tti_rx; - L1_proc->frame_tx = (L1_proc->subframe_rx > (9-sf_ahead)) ? (L1_proc->frame_rx+1)&1023 : L1_proc->frame_rx; - L1_proc->subframe_tx = (L1_proc->subframe_rx + sf_ahead)%10; + L1_proc->frame_tx = (L1_proc->subframe_rx > (9-ru->sf_ahead)) ? (L1_proc->frame_rx+1)&1023 : L1_proc->frame_rx; + L1_proc->subframe_tx = (L1_proc->subframe_rx + ru->sf_ahead)%10; if (rxtx(eNB,L1_proc,string) < 0) LOG_E(PHY,"eNB %d CC_id %d failed during execution\n",eNB->Mod_id,eNB->CC_id); @@ -614,11 +612,11 @@ int wakeup_rxtx(PHY_VARS_eNB *eNB, // The last (TS_rx mod samples_per_frame) was n*samples_per_tti, // we want to generate subframe (n+sf_ahead), so TS_tx = TX_rx+sf_ahead*samples_per_tti, // and proc->subframe_tx = proc->subframe_rx+sf_ahead - L1_proc->timestamp_tx = ru_proc->timestamp_rx + (sf_ahead*fp->samples_per_tti); + L1_proc->timestamp_tx = ru_proc->timestamp_rx + (ru->sf_ahead*fp->samples_per_tti); L1_proc->frame_rx = ru_proc->frame_rx; L1_proc->subframe_rx = ru_proc->tti_rx; - L1_proc->frame_tx = (L1_proc->subframe_rx > (9-sf_ahead)) ? (L1_proc->frame_rx+1)&1023 : L1_proc->frame_rx; - L1_proc->subframe_tx = (L1_proc->subframe_rx + sf_ahead)%10; + L1_proc->frame_tx = (L1_proc->subframe_rx > (9-ru->sf_ahead)) ? (L1_proc->frame_rx+1)&1023 : L1_proc->frame_rx; + L1_proc->subframe_tx = (L1_proc->subframe_rx + ru->sf_ahead)%10; LOG_D(PHY,"wakeup_rxtx: L1_proc->subframe_rx %d, L1_proc->subframe_tx %d, RU %d\n",L1_proc->subframe_rx,L1_proc->subframe_tx,ru->idx); VCD_SIGNAL_DUMPER_DUMP_VARIABLE_BY_NAME(VCD_SIGNAL_DUMPER_VARIABLES_FRAME_NUMBER_WAKEUP_RXTX_RX_RU+ru->idx, L1_proc->frame_rx); VCD_SIGNAL_DUMPER_DUMP_VARIABLE_BY_NAME(VCD_SIGNAL_DUMPER_VARIABLES_SUBFRAME_NUMBER_WAKEUP_RXTX_RX_RU+ru->idx, L1_proc->subframe_rx); @@ -1137,7 +1135,7 @@ void init_transport(PHY_VARS_eNB *eNB) { } for (int i=0;iulsch[i] = new_eNB_ulsch(MAX_TURBO_ITERATIONS,fp->N_RB_UL, 0); if (!eNB->ulsch[i]) { diff --git a/targets/RT/USER/lte-ru.c b/targets/RT/USER/lte-ru.c index 7e897c7deb..836709b473 100644 --- a/targets/RT/USER/lte-ru.c +++ b/targets/RT/USER/lte-ru.c @@ -107,7 +107,6 @@ const char ru_states[6][9] = {"RU_IDLE","RU_CONFIG","RU_READY","RU_RUN","RU_ERRO extern const char NB_functions[7][20]; extern const char NB_timing[2][20]; -extern uint16_t sf_ahead; extern const char ru_if_types[MAX_RU_IF_TYPES][20]; @@ -252,8 +251,8 @@ void fh_if4p5_south_in(RU_t *ru, // proc->timestamp_tx = proc->timestamp_rx + (4*fp->samples_per_tti); if (get_thread_parallel_conf() == PARALLEL_SINGLE_THREAD) { - proc->tti_tx = (sf+sf_ahead)%10; - proc->frame_tx = (sf>(9-sf_ahead)) ? (f+1)&1023 : f; + proc->tti_tx = (sf+ru->sf_ahead)%10; + proc->frame_tx = (sf>(9-ru->sf_ahead)) ? (f+1)&1023 : f; } LOG_D(PHY,"Setting proc for (%d,%d)\n",sf,f); @@ -652,13 +651,13 @@ void rx_rf(RU_t *ru, if (get_thread_parallel_conf() == PARALLEL_SINGLE_THREAD && ru->fh_north_asynch_in == NULL) { #ifdef PHY_TX_THREAD - proc->timestamp_phy_tx = proc->timestamp_rx+((sf_ahead-1)*fp->samples_per_tti); - proc->subframe_phy_tx = (proc->tti_rx+(sf_ahead-1))%10; - proc->frame_phy_tx = (proc->tti_rx>(9-(sf_ahead-1))) ? (proc->frame_rx+1)&1023 : proc->frame_rx; + proc->timestamp_phy_tx = proc->timestamp_rx+((ru->sf_ahead-1)*fp->samples_per_tti); + proc->subframe_phy_tx = (proc->tti_rx+(ru->sf_ahead-1))%10; + proc->frame_phy_tx = (proc->tti_rx>(9-(ru->sf_ahead-1))) ? (proc->frame_rx+1)&1023 : proc->frame_rx; #else - proc->timestamp_tx = proc->timestamp_rx+(sf_ahead*fp->samples_per_tti); - proc->tti_tx = (proc->tti_rx+sf_ahead)%10; - proc->frame_tx = (proc->tti_rx>(9-sf_ahead)) ? (proc->frame_rx+1)&1023 : proc->frame_rx; + proc->timestamp_tx = proc->timestamp_rx+(ru->sf_ahead*fp->samples_per_tti); + proc->tti_tx = (proc->tti_rx+ru->sf_ahead)%10; + proc->frame_tx = (proc->tti_rx>(9-ru->sf_ahead)) ? (proc->frame_rx+1)&1023 : proc->frame_rx; #endif //proc->timestamp_tx = proc->timestamp_rx+(sf_ahead*fp->samples_per_tti); //proc->subframe_tx = (proc->tti_rx+sf_ahead)%10; @@ -733,7 +732,7 @@ void tx_rf(RU_t *ru, int sf_extension = 0; if ((SF_type == SF_DL) || - (SF_type == SF_S)) { + (SF_type == SF_S) ) { int siglen=fp->samples_per_tti,flags=1; if (SF_type == SF_S) { @@ -831,6 +830,23 @@ void tx_rf(RU_t *ru, late_control=STATE_BURST_TERMINATE; LOG_E(PHY,"TX : Timeout (sent %d/%d) state =%d\n",txs, siglen,late_control); } + } else if (IS_SOFTMODEM_RFSIM ) { + // in case of rfsim, we always enable tx because we need to feed rx of the opposite side + // we write 1 single I/Q sample to trigger Rx (rfsim will fill gaps with 0 I/Q) + void *dummy_tx[ru->frame_parms->nb_antennas_tx]; + int16_t dummy_tx_data[ru->frame_parms->nb_antennas_tx][2]; // 2 because the function we call use pairs of int16_t implicitly as complex numbers + memset(dummy_tx_data,0,sizeof(dummy_tx_data)); + for (int i=0; iframe_parms->nb_antennas_tx; i++) + dummy_tx[i]= dummy_tx_data[i]; + + AssertFatal( 1 == + ru->rfdevice.trx_write_func(&ru->rfdevice, + timestamp+ru->ts_offset-ru->openair0_cfg.tx_sample_advance-sf_extension, + dummy_tx, + 1, + ru->frame_parms->nb_antennas_tx, + 4),""); + } } @@ -1355,11 +1371,12 @@ void fill_rf_config(RU_t *ru, cfg->tx_gain[i] = (double)ru->att_tx; cfg->rx_gain[i] = ru->max_rxgain-(double)ru->att_rx; cfg->configFilename = rf_config_file; - LOG_I(PHY,"channel %d, Setting tx_gain offset %f, rx_gain offset %f, tx_freq %f, rx_freq %f\n", + LOG_I(PHY,"channel %d, Setting tx_gain offset %.0f, rx_gain offset %.0f, tx_freq %.0f, rx_freq %.0f, tune_offset %.0f Hz\n", i, cfg->tx_gain[i], cfg->rx_gain[i], cfg->tx_freq[i], - cfg->rx_freq[i]); + cfg->rx_freq[i], + cfg->tune_offset); } } @@ -1387,12 +1404,6 @@ int setup_RU_buffers(RU_t *ru) { else if (frame_parms->N_RB_DL == 50) ru->N_TA_offset = 624/2; else if (frame_parms->N_RB_DL == 25) ru->N_TA_offset = 624/4; - if(IS_SOFTMODEM_BASICSIM) - /* this is required for the basic simulator in TDD mode - * TODO: find a proper cleaner solution - */ - ru->N_TA_offset = 0; - if (frame_parms->N_RB_DL == 100) /* no scaling to do */; else if (frame_parms->N_RB_DL == 50) { ru->sf_extension /= 2; @@ -2962,6 +2973,8 @@ RU_t **RCconfig_RU(int nb_RU,int nb_L1_inst,PHY_VARS_eNB ***eNB,uint64_t *ru_mas ru[j]->openair0_cfg.time_source = unset; } + ru[j]->openair0_cfg.tune_offset = get_softmodem_params()->tune_offset; + LOG_I(PHY,"RU %d is_slave=%s\n",j,*(RUParamList.paramarray[j][RU_IS_SLAVE_IDX].strptr)); if (strcmp(*(RUParamList.paramarray[j][RU_IS_SLAVE_IDX].strptr), "yes") == 0) ru[j]->is_slave=1; @@ -3070,6 +3083,7 @@ RU_t **RCconfig_RU(int nb_RU,int nb_L1_inst,PHY_VARS_eNB ***eNB,uint64_t *ru_mas ru[j]->nb_rx = *(RUParamList.paramarray[j][RU_NB_RX_IDX].uptr); ru[j]->att_tx = *(RUParamList.paramarray[j][RU_ATT_TX_IDX].uptr); ru[j]->att_rx = *(RUParamList.paramarray[j][RU_ATT_RX_IDX].uptr); + ru[j]->sf_ahead = *(RUParamList.paramarray[j][RU_SF_AHEAD].uptr); *ru_mask= (*ru_mask)|(1<frame_parms), frame_parms, sizeof(LTE_DL_FRAME_PARMS)); } @@ -204,8 +202,7 @@ void init_thread(int sched_runtime, int sched_deadline, int sched_fifo, cpu_set_t *cpuset, - char *name) -{ + char *name) { #ifdef DEADLINE_SCHEDULER if (sched_runtime!=0) { @@ -266,8 +263,7 @@ void init_UE(int nb_inst, runmode_t mode, int rxgain, int txpowermax, - LTE_DL_FRAME_PARMS *fp0) -{ + LTE_DL_FRAME_PARMS *fp0) { PHY_VARS_UE *UE; int inst; int ret; @@ -283,9 +279,7 @@ void init_UE(int nb_inst, if (PHY_vars_UE_g[inst]==NULL) PHY_vars_UE_g[inst] = (PHY_VARS_UE **)calloc(1+MAX_NUM_CCs,sizeof(PHY_VARS_UE *)); LOG_I(PHY,"Allocating UE context %d\n",inst); - PHY_vars_UE_g[inst][0] = init_ue_vars(fp0,inst,0); - // turn off timing control loop in UE PHY_vars_UE_g[inst][0]->no_timing_correction = timing_correction; UE = PHY_vars_UE_g[inst][0]; @@ -360,15 +354,8 @@ void init_UE(int nb_inst, } } else UE->N_TA_offset = 0; - if( IS_SOFTMODEM_BASICSIM) - /* this is required for the basic simulator in TDD mode - * TODO: find a proper cleaner solution - */ - UE->N_TA_offset = 0; - LOG_I(PHY,"Intializing UE Threads for instance %d (%p,%p)...\n",inst,PHY_vars_UE_g[inst],PHY_vars_UE_g[inst][0]); init_UE_threads(inst); - ret = openair0_device_load(&(UE->rfdevice), &openair0_cfg[0]); if (ret !=0) { @@ -391,8 +378,7 @@ void init_UE(int nb_inst, void init_UE_stub_single_thread(int nb_inst, int eMBMS_active, int uecap_xer_in, - char *emul_iface) -{ + char *emul_iface) { int inst; LOG_I(PHY,"UE : Calling Layer 2 for initialization, nb_inst: %d \n", nb_inst); l2_init_ue(eMBMS_active,(uecap_xer_in==1)?uecap_xer:NULL, @@ -417,24 +403,23 @@ void init_UE_stub_single_thread(int nb_inst, } } -void init_UE_standalone_thread(int ue_idx) -{ +void init_UE_standalone_thread(int ue_idx) { int standalone_tx_port = 3211 + ue_idx * 2; int standalone_rx_port = 3212 + ue_idx * 2; ue_init_standalone_socket(standalone_tx_port, standalone_rx_port); - pthread_t thread; + if (pthread_create(&thread, NULL, ue_standalone_pnf_task, NULL) != 0) { LOG_E(MAC, "pthread_create failed for calling ue_standalone_pnf_task"); } + pthread_setname_np(thread, "oai:ue-stand"); } void init_UE_stub(int nb_inst, int eMBMS_active, int uecap_xer_in, - char *emul_iface) -{ + char *emul_iface) { int inst; LOG_I(PHY,"UE : Calling Layer 2 for initialization\n"); l2_init_ue(eMBMS_active,(uecap_xer_in==1)?uecap_xer:NULL, @@ -468,8 +453,7 @@ void init_UE_stub(int nb_inst, * \returns a pointer to an int. The storage is not on the heap and must not be freed. */ -static void *UE_thread_synch(void *arg) -{ +static void *UE_thread_synch(void *arg) { static int UE_thread_synch_retval; int i ; PHY_VARS_UE *UE = (PHY_VARS_UE *) arg; @@ -484,6 +468,7 @@ static void *UE_thread_synch(void *arg) printf("UE_thread_sync in with PHY_vars_UE %p\n",arg); cpu_set_t cpuset; CPU_ZERO(&cpuset); + if ( threads.sync != -1 ) CPU_SET(threads.sync, &cpuset); @@ -763,8 +748,7 @@ static void *UE_thread_synch(void *arg) * \param arg is a pointer to a \ref PHY_VARS_UE structure. * \returns a pointer to an int. The storage is not on the heap and must not be freed. */ -const char *get_connectionloss_errstr(int errcode) -{ +const char *get_connectionloss_errstr(int errcode) { switch (errcode) { case CONNECTION_LOST: return "RRC Connection lost, returning to PRACH"; @@ -779,8 +763,7 @@ const char *get_connectionloss_errstr(int errcode) return "UNKNOWN RETURN CODE"; } -static void *UE_thread_rxn_txnp4(void *arg) -{ +static void *UE_thread_rxn_txnp4(void *arg) { static __thread int UE_thread_rxtx_retval; struct rx_tx_thread_data *rtd = arg; UE_rxtx_proc_t *proc = rtd->proc; @@ -873,17 +856,15 @@ static void *UE_thread_rxn_txnp4(void *arg) if ((subframe_select( &UE->frame_parms, proc->subframe_tx) == SF_UL) || (UE->frame_parms.frame_type == FDD) ) - if (UE->mode != loop_through_memory) - phy_procedures_UE_TX(UE,proc,0,0,UE->mode); + phy_procedures_UE_TX(UE,proc,0,0,UE->mode); if ((subframe_select( &UE->frame_parms, proc->subframe_tx) == SF_S) && (UE->frame_parms.frame_type == TDD)) - if (UE->mode != loop_through_memory) - phy_procedures_UE_S_TX(UE,0,0); + phy_procedures_UE_S_TX(UE,0,0); proc->instance_cnt_rxtx--; - if ( IS_SOFTMODEM_BASICSIM || IS_SOFTMODEM_RFSIM ) { + if (IS_SOFTMODEM_RFSIM) { if (pthread_cond_signal(&proc->cond_rxtx) != 0) abort(); } @@ -901,8 +882,7 @@ static void *UE_thread_rxn_txnp4(void *arg) unsigned int emulator_absSF; void ue_stub_rx_handler(unsigned int num_bytes, - char *rx_buffer) -{ + char *rx_buffer) { PHY_VARS_UE *UE; UE = PHY_vars_UE_g[0][0]; UE_tport_t *pdu = (UE_tport_t *)rx_buffer; @@ -957,14 +937,14 @@ void ue_stub_rx_handler(unsigned int num_bytes, } } -uint64_t clock_usec(void) -{ - struct timespec t; - if (clock_gettime(CLOCK_MONOTONIC, &t) == -1) - { - abort(); - } - return (uint64_t)t.tv_sec * 1000000 + (t.tv_nsec / 1000); +uint64_t clock_usec(void) { + struct timespec t; + + if (clock_gettime(CLOCK_MONOTONIC, &t) == -1) { + abort(); + } + + return (uint64_t)t.tv_sec * 1000000 + (t.tv_nsec / 1000); } /*! * \brief This is the UE thread for RX subframe n and TX subframe n+4. @@ -974,23 +954,21 @@ uint64_t clock_usec(void) * \returns a pointer to an int. The storage is not on the heap and must not be freed. */ -static void *UE_phy_stub_standalone_pnf_task(void *arg) -{ +static void *UE_phy_stub_standalone_pnf_task(void *arg) { #if 1 { struct sched_param sparam = { .sched_priority = 79, }; - if (pthread_setschedparam(pthread_self(), SCHED_RR, &sparam) != 0) - { + + if (pthread_setschedparam(pthread_self(), SCHED_RR, &sparam) != 0) { LOG_E(PHY,"pthread_setschedparam: %s\n", strerror(errno)); } } #else thread_top_init("UE_phy_stub_thread_rxn_txnp4", 1, 870000L, 1000000L, 1000000L); #endif - // for multipule UE's L2-emulator //module_id_t Mod_id = 0; //int init_ra_UE = -1; // This counter is used to initiate the RA of each UE in different SFrames @@ -1010,9 +988,7 @@ static void *UE_phy_stub_standalone_pnf_task(void *arg) PHY_VARS_UE *UE = NULL; int ret; proc = &PHY_vars_UE_g[0][0]->proc.proc_rxtx[0]; - UE = rtd->UE; - UL_INFO = (UL_IND_t *)calloc(1, sizeof(UL_IND_t)); UL_INFO->rx_ind.rx_indication_body.rx_pdu_list = calloc(NFAPI_RX_IND_MAX_PDU, sizeof(nfapi_rx_indication_pdu_t)); UL_INFO->rx_ind.rx_indication_body.number_of_pdus = 0; @@ -1025,19 +1001,15 @@ static void *UE_phy_stub_standalone_pnf_task(void *arg) UL_INFO->cqi_ind.cqi_indication_body.cqi_pdu_list = calloc(NFAPI_CQI_IND_MAX_PDU, sizeof(nfapi_cqi_indication_pdu_t)); UL_INFO->cqi_ind.cqi_indication_body.cqi_raw_pdu_list = calloc(NFAPI_CQI_IND_MAX_PDU, sizeof(nfapi_cqi_indication_raw_pdu_t)); UL_INFO->cqi_ind.cqi_indication_body.number_of_cqis = 0; - proc->subframe_rx = proc->sub_frame_start; proc->subframe_tx = -1; proc->frame_rx = -1; proc->frame_tx = -1; // Initializations for nfapi-L2-emulator mode sync_var = 0; - //PANOS: CAREFUL HERE! wait_sync("UE_phy_stub_standalone_pnf_task"); - int last_sfn_sf = -1; - LOG_I(MAC, "Clearing Queues\n"); reset_queue(&dl_config_req_tx_req_queue); reset_queue(&ul_config_req_queue); @@ -1045,72 +1017,77 @@ static void *UE_phy_stub_standalone_pnf_task(void *arg) while (!oai_exit) { bool sent_any = false; + if (sem_wait(&sfn_semaphore) != 0) { LOG_E(MAC, "sem_wait() error\n"); abort(); } int sfn_sf = current_sfn_sf; - if (sfn_sf == last_sfn_sf) - { + + if (sfn_sf == last_sfn_sf) { LOG_W(MAC, "repeated sfn_sf = %d.%d\n", sfn_sf >> 4, sfn_sf & 15); continue; } - last_sfn_sf = sfn_sf; + last_sfn_sf = sfn_sf; nfapi_dl_config_req_tx_req_t *dl_config_req_tx_req = get_queue(&dl_config_req_tx_req_queue); nfapi_ul_config_request_t *ul_config_req = get_queue(&ul_config_req_queue); nfapi_hi_dci0_request_t *hi_dci0_req = get_queue(&hi_dci0_req_queue); - LOG_I(MAC, "received from proxy frame %d subframe %d\n", NFAPI_SFNSF2SFN(sfn_sf), NFAPI_SFNSF2SF(sfn_sf)); if (ul_config_req != NULL) { uint8_t ul_num_pdus = ul_config_req->ul_config_request_body.number_of_pdus; + if (ul_num_pdus > 0) { char *ul_str = nfapi_ul_config_req_to_string(ul_config_req); LOG_I(MAC, "ul_config_req: %s\n", ul_str); free(ul_str); } } + if (hi_dci0_req != NULL) { LOG_D(MAC, "hi_dci0_req pdus: %u Frame: %d Subframe: %d\n", - hi_dci0_req->hi_dci0_request_body.number_of_dci, - NFAPI_SFNSF2SFN(hi_dci0_req->sfn_sf), NFAPI_SFNSF2SF(hi_dci0_req->sfn_sf)); + hi_dci0_req->hi_dci0_request_body.number_of_dci, + NFAPI_SFNSF2SFN(hi_dci0_req->sfn_sf), NFAPI_SFNSF2SF(hi_dci0_req->sfn_sf)); } if (dl_config_req_tx_req != NULL) { - nfapi_tx_req_pdu_list_t *tx_req_pdu_list = dl_config_req_tx_req->tx_req_pdu_list; nfapi_dl_config_request_t *dl_config_req = dl_config_req_tx_req->dl_config_req; - uint16_t dl_num_pdus = dl_config_req->dl_config_request_body.number_pdu; LOG_I(MAC, "(OAI UE) Received dl_config_req from proxy at Frame: %d, Subframe: %d," " with number of PDUs: %u\n", NFAPI_SFNSF2SFN(dl_config_req->sfn_sf), NFAPI_SFNSF2SF(dl_config_req->sfn_sf), dl_num_pdus); + if (dl_num_pdus > 0) { char *dl_str = nfapi_dl_config_req_to_string(dl_config_req); LOG_I(MAC, "dl_config_req: %s\n", dl_str); free(dl_str); } - LOG_D(MAC, "tx_req pdus: %d\n", tx_req_pdu_list->num_pdus); + LOG_D(MAC, "tx_req pdus: %d\n", tx_req_pdu_list->num_pdus); // Handling dl_config_req and tx_req: nfapi_dl_config_request_body_t *dl_config_req_body = &dl_config_req->dl_config_request_body; + for (int i = 0; i < dl_config_req_body->number_pdu; ++i) { nfapi_dl_config_request_pdu_t *pdu = &dl_config_req_body->dl_config_pdu_list[i]; + if (pdu->pdu_type == NFAPI_DL_CONFIG_DCI_DL_PDU_TYPE) { i += 1; AssertFatal(i < dl_config_req->dl_config_request_body.number_pdu, "Need PDU following DCI at index %d, but not found\n", i); nfapi_dl_config_request_pdu_t *dlsch = &dl_config_req_body->dl_config_pdu_list[i]; + if (dlsch->pdu_type != NFAPI_DL_CONFIG_DLSCH_PDU_TYPE) { LOG_E(MAC, "expected DLSCH PDU at index %d\n", i); continue; } + dl_config_req_UE_MAC_dci(NFAPI_SFNSF2SFN(dl_config_req->sfn_sf), NFAPI_SFNSF2SF(dl_config_req->sfn_sf), pdu, @@ -1131,8 +1108,10 @@ static void *UE_phy_stub_standalone_pnf_task(void *arg) } } } + if (hi_dci0_req) { nfapi_hi_dci0_request_body_t *hi_dci0_body = &hi_dci0_req->hi_dci0_request_body; + for (int i = 0; i < hi_dci0_body->number_of_dci + hi_dci0_body->number_of_hi; i++) { nfapi_hi_dci0_request_pdu_t *pdu = &hi_dci0_body->hi_dci0_pdu_list[i]; hi_dci0_req_UE_MAC(NFAPI_SFNSF2SFN(hi_dci0_req->sfn_sf), @@ -1145,13 +1124,13 @@ static void *UE_phy_stub_standalone_pnf_task(void *arg) for (ue_index = 0; ue_index < ue_num; ue_index++) { ue_Mod_id = ue_thread_id + NB_THREAD_INST * ue_index; // Always 0 in standalone pnf mode UE = PHY_vars_UE_g[ue_Mod_id][0]; - #if UE_TIMING_TRACE start_meas(&UE->generic_stat); #endif int rx_frame = NFAPI_SFNSF2SF(sfn_sf) < 4 ? (NFAPI_SFNSF2SFN(sfn_sf) + 1023) % 1024 : NFAPI_SFNSF2SFN(sfn_sf); // subtracting 4 from subframe_tx int rx_subframe = NFAPI_SFNSF2SF(sfn_sf) < 4 ? NFAPI_SFNSF2SF(sfn_sf) + 6 : NFAPI_SFNSF2SF(sfn_sf) - 4; LOG_D(MAC, "rx_frame %d rx_subframe %d\n", rx_frame, rx_subframe); + if (UE->mac_enabled == 1) { ret = ue_scheduler(ue_Mod_id, rx_frame, @@ -1174,67 +1153,60 @@ static void *UE_phy_stub_standalone_pnf_task(void *arg) // Prepare the future Tx data if ((subframe_select(&UE->frame_parms, NFAPI_SFNSF2SF(sfn_sf)) == SF_UL) || - (UE->frame_parms.frame_type == FDD)) - { - if (UE->mode != loop_through_memory) - { - // We make the start of RA between consecutive UEs differ by 20 frames - //if ((UE_mac_inst[Mod_id].UE_mode[0] == PRACH && Mod_id == 0) || (UE_mac_inst[Mod_id].UE_mode[0] == PRACH && Mod_id>0 && rx_frame >= UE_mac_inst[Mod_id-1].ra_frame + 20) ) { - if (UE_mac_inst[ue_Mod_id].UE_mode[0] == RA_RESPONSE && - is_prach_subframe(&UE->frame_parms, NFAPI_SFNSF2SFN(sfn_sf), NFAPI_SFNSF2SF(sfn_sf))) - { - UE_mac_inst[ue_Mod_id].UE_mode[0] = PRACH; - } - LOG_D(MAC, "UE_mode: %d\n", UE_mac_inst[ue_Mod_id].UE_mode[0]); - if (UE_mac_inst[ue_Mod_id].UE_mode[0] == PRACH) - { //&& ue_Mod_id == next_Mod_id) { - next_ra_frame++; - if (next_ra_frame > 500) - { - // check if we have PRACH opportunity - if (is_prach_subframe(&UE->frame_parms, NFAPI_SFNSF2SFN(sfn_sf), NFAPI_SFNSF2SF(sfn_sf)) && UE_mac_inst[ue_Mod_id].SI_Decoded == 1) - { - // The one working strangely... - //if (is_prach_subframe(&UE->frame_parms,NFAPI_SFNSF2SFN(sfn_sf), NFAPI_SFNSF2SF(sfn_sf) && Mod_id == (module_id_t) init_ra_UE) ) { - PRACH_RESOURCES_t *prach_resources = ue_get_rach(ue_Mod_id, 0, NFAPI_SFNSF2SFN(sfn_sf), 0, NFAPI_SFNSF2SF(sfn_sf)); - if (prach_resources != NULL) - { - LOG_I(MAC, "preamble_received_tar_power: %d\n", - prach_resources->ra_PREAMBLE_RECEIVED_TARGET_POWER); - UE_mac_inst[ue_Mod_id].ra_frame = NFAPI_SFNSF2SFN(sfn_sf); - LOG_D(MAC, "UE_phy_stub_thread_rxn_txnp4 before RACH, Mod_id: %d frame %d subframe %d\n", ue_Mod_id, NFAPI_SFNSF2SFN(sfn_sf), NFAPI_SFNSF2SF(sfn_sf)); - fill_rach_indication_UE_MAC(ue_Mod_id, NFAPI_SFNSF2SFN(sfn_sf), NFAPI_SFNSF2SF(sfn_sf), UL_INFO, prach_resources->ra_PreambleIndex, prach_resources->ra_RNTI); - sent_any = true; - Msg1_transmitted(ue_Mod_id, 0, NFAPI_SFNSF2SFN(sfn_sf), 0); - UE_mac_inst[ue_Mod_id].UE_mode[0] = RA_RESPONSE; - next_Mod_id = ue_Mod_id + 1; - //next_ra_frame = (rx_frame + 20)%1000; - next_ra_frame = 0; - } - //ue_prach_procedures(ue,proc,eNB_id,abstraction_flag,mode); - } - } - } // mode is PRACH - - // Substitute call to phy_procedures Tx with call to phy_stub functions in order to trigger - // UE Tx procedures directly at the MAC layer, based on the received ul_config requests from the vnf (eNB). - // Generate UL_indications which correspond to UL traffic. - if (ul_config_req != NULL) - { //&& UE_mac_inst[Mod_id].ul_config_req->ul_config_request_body.ul_config_pdu_list != NULL){ - ul_config_req_UE_MAC(ul_config_req, NFAPI_SFNSF2SFN(sfn_sf), NFAPI_SFNSF2SF(sfn_sf), ue_Mod_id); - } + (UE->frame_parms.frame_type == FDD)) { + // We make the start of RA between consecutive UEs differ by 20 frames + //if ((UE_mac_inst[Mod_id].UE_mode[0] == PRACH && Mod_id == 0) || (UE_mac_inst[Mod_id].UE_mode[0] == PRACH && Mod_id>0 && rx_frame >= UE_mac_inst[Mod_id-1].ra_frame + 20) ) { + if (UE_mac_inst[ue_Mod_id].UE_mode[0] == RA_RESPONSE && + is_prach_subframe(&UE->frame_parms, NFAPI_SFNSF2SFN(sfn_sf), NFAPI_SFNSF2SF(sfn_sf))) { + UE_mac_inst[ue_Mod_id].UE_mode[0] = PRACH; } - phy_procedures_UE_SL_RX(UE, proc); - } - else - { + LOG_D(MAC, "UE_mode: %d\n", UE_mac_inst[ue_Mod_id].UE_mode[0]); + + if (UE_mac_inst[ue_Mod_id].UE_mode[0] == PRACH) { + //&& ue_Mod_id == next_Mod_id) { + next_ra_frame++; + + if (next_ra_frame > 500) { + // check if we have PRACH opportunity + if (is_prach_subframe(&UE->frame_parms, NFAPI_SFNSF2SFN(sfn_sf), NFAPI_SFNSF2SF(sfn_sf)) && UE_mac_inst[ue_Mod_id].SI_Decoded == 1) { + // The one working strangely... + //if (is_prach_subframe(&UE->frame_parms,NFAPI_SFNSF2SFN(sfn_sf), NFAPI_SFNSF2SF(sfn_sf) && Mod_id == (module_id_t) init_ra_UE) ) { + PRACH_RESOURCES_t *prach_resources = ue_get_rach(ue_Mod_id, 0, NFAPI_SFNSF2SFN(sfn_sf), 0, NFAPI_SFNSF2SF(sfn_sf)); + + if (prach_resources != NULL) { + LOG_I(MAC, "preamble_received_tar_power: %d\n", + prach_resources->ra_PREAMBLE_RECEIVED_TARGET_POWER); + UE_mac_inst[ue_Mod_id].ra_frame = NFAPI_SFNSF2SFN(sfn_sf); + LOG_D(MAC, "UE_phy_stub_thread_rxn_txnp4 before RACH, Mod_id: %d frame %d subframe %d\n", ue_Mod_id, NFAPI_SFNSF2SFN(sfn_sf), NFAPI_SFNSF2SF(sfn_sf)); + fill_rach_indication_UE_MAC(ue_Mod_id, NFAPI_SFNSF2SFN(sfn_sf), NFAPI_SFNSF2SF(sfn_sf), UL_INFO, prach_resources->ra_PreambleIndex, prach_resources->ra_RNTI); + sent_any = true; + Msg1_transmitted(ue_Mod_id, 0, NFAPI_SFNSF2SFN(sfn_sf), 0); + UE_mac_inst[ue_Mod_id].UE_mode[0] = RA_RESPONSE; + next_Mod_id = ue_Mod_id + 1; + //next_ra_frame = (rx_frame + 20)%1000; + next_ra_frame = 0; + } + + //ue_prach_procedures(ue,proc,eNB_id,abstraction_flag,mode); + } + } + } // mode is PRACH + + // Substitute call to phy_procedures Tx with call to phy_stub functions in order to trigger + // UE Tx procedures directly at the MAC layer, based on the received ul_config requests from the vnf (eNB). + // Generate UL_indications which correspond to UL traffic. + if (ul_config_req != NULL) { + //&& UE_mac_inst[Mod_id].ul_config_req->ul_config_request_body.ul_config_pdu_list != NULL){ + ul_config_req_UE_MAC(ul_config_req, NFAPI_SFNSF2SFN(sfn_sf), NFAPI_SFNSF2SF(sfn_sf), ue_Mod_id); + } + } else { LOG_I(MAC, "Skipping subframe select statement proxy SFN.SF: %d.%d\n", - NFAPI_SFNSF2SFN(sfn_sf), NFAPI_SFNSF2SF(sfn_sf)); - if (ul_config_req != NULL) - { + NFAPI_SFNSF2SFN(sfn_sf), NFAPI_SFNSF2SF(sfn_sf)); + + if (ul_config_req != NULL) { LOG_I(MAC, "Skipping subframe select statement ul_config_req SFN.SF: %d.%d\n", - NFAPI_SFNSF2SFN(ul_config_req->sfn_sf), NFAPI_SFNSF2SF(ul_config_req->sfn_sf)); + NFAPI_SFNSF2SFN(ul_config_req->sfn_sf), NFAPI_SFNSF2SF(ul_config_req->sfn_sf)); } } } //for (Mod_id=0; Mod_idrx_ind.rx_indication_body.number_of_pdus > 0) { - //LOG_D(PHY,"UL_info->rx_ind.number_of_pdus:%d RX_IND:SFN/SF:%d\n", UL_info->rx_ind.rx_indication_body.number_of_pdus, NFAPI_SFNSF2DEC(UL_info->rx_ind.sfn_sf)); //LOG_I(MAC, "ul_config_req_UE_MAC 2.3, SFN/SF of PNF counter:%d.%d, number_of_pdus: %d \n", timer_frame, timer_subframe, UL_INFO->rx_ind.rx_indication_body.number_of_pdus); send_standalone_msg(UL_INFO, UL_INFO->rx_ind.header.message_id); sent_any = true; - //LOG_I(MAC, "ul_config_req_UE_MAC 2.31 \n"); UL_INFO->rx_ind.rx_indication_body.number_of_pdus = 0; } @@ -1267,16 +1237,16 @@ static void *UE_phy_stub_standalone_pnf_task(void *arg) if (UL_INFO->harq_ind.harq_indication_body.number_of_harqs > 0) { //LOG_D(MAC, "ul_config_req_UE_MAC 2.4, SFN/SF of PNF counter:%d.%d, number_of_harqs: %d \n", timer_frame, timer_subframe, UL_INFO->harq_ind.harq_indication_body.number_of_harqs); - send_standalone_msg(UL_INFO, UL_INFO->harq_ind.header.message_id); - sent_any = true; + send_standalone_msg(UL_INFO, UL_INFO->harq_ind.header.message_id); + sent_any = true; //LOG_I(MAC, "ul_config_req_UE_MAC 2.41 \n"); UL_INFO->harq_ind.harq_indication_body.number_of_harqs = 0; } if (UL_INFO->sr_ind.sr_indication_body.number_of_srs > 0) { //LOG_I(MAC, "ul_config_req_UE_MAC 2.5, SFN/SF of PNF counter:%d.%d, number_of_srs: %d \n", timer_frame, timer_subframe, UL_INFO->sr_ind.sr_indication_body.number_of_srs); - send_standalone_msg(UL_INFO, UL_INFO->sr_ind.header.message_id); - sent_any = true; + send_standalone_msg(UL_INFO, UL_INFO->sr_ind.header.message_id); + sent_any = true; //LOG_I(MAC, "ul_config_req_UE_MAC 2.51 \n"); UL_INFO->sr_ind.sr_indication_body.number_of_srs = 0; } @@ -1292,12 +1262,11 @@ static void *UE_phy_stub_standalone_pnf_task(void *arg) free(dl_config_req_tx_req->dl_config_req->dl_config_request_body.dl_config_pdu_list); dl_config_req_tx_req->dl_config_req->dl_config_request_body.dl_config_pdu_list = NULL; } + nfapi_free_tx_req_pdu_list(dl_config_req_tx_req->tx_req_pdu_list); dl_config_req_tx_req->tx_req_pdu_list = NULL; - free(dl_config_req_tx_req->dl_config_req); dl_config_req_tx_req->dl_config_req = NULL; - free(dl_config_req_tx_req); dl_config_req_tx_req = NULL; } @@ -1321,9 +1290,9 @@ static void *UE_phy_stub_standalone_pnf_task(void *arg) free(hi_dci0_req); hi_dci0_req = NULL; } - if (!sent_any) - { - send_standalone_dummy(); + + if (!sent_any) { + send_standalone_dummy(); } } @@ -1342,7 +1311,6 @@ static void *UE_phy_stub_standalone_pnf_task(void *arg) UL_INFO->rx_ind.rx_indication_body.rx_pdu_list = NULL; free(UL_INFO); UL_INFO = NULL; - // thread finished free(arg); return NULL; @@ -1356,8 +1324,7 @@ static void *UE_phy_stub_standalone_pnf_task(void *arg) * \returns a pointer to an int. The storage is not on the heap and must not be freed. */ -static void *UE_phy_stub_single_thread_rxn_txnp4(void *arg) -{ +static void *UE_phy_stub_single_thread_rxn_txnp4(void *arg) { #if 0 // TODO: doesn't currently compile, obviated by multi-ue proxy thread_top_init("UE_phy_stub_thread_rxn_txnp4",1,870000L,1000000L,1000000L); // for multipule UE's L2-emulator @@ -1383,7 +1350,6 @@ static void *UE_phy_stub_single_thread_rxn_txnp4(void *arg) proc = &PHY_vars_UE_g[0][0]->proc.proc_rxtx[0]; phy_stub_ticking->num_single_thread[ue_thread_id] = -1; UE = rtd->UE; - UL_INFO = (UL_IND_t *)malloc(sizeof(UL_IND_t)); UL_INFO->rx_ind.rx_indication_body.rx_pdu_list = calloc(NB_UE_INST, sizeof(nfapi_rx_indication_pdu_t)); UL_INFO->rx_ind.rx_indication_body.number_of_pdus = 0; @@ -1495,19 +1461,23 @@ static void *UE_phy_stub_single_thread_rxn_txnp4(void *arg) } if (dl_config_req && tx_req_pdu_list) { - nfapi_dl_config_request_body_t* dl_config_req_body = &dl_config_req->dl_config_request_body; + nfapi_dl_config_request_body_t *dl_config_req_body = &dl_config_req->dl_config_request_body; + for (int i = 0; i < dl_config_req_body->number_pdu; ++i) { - nfapi_dl_config_request_pdu_t* pdu = &dl_config_req_body->dl_config_pdu_list[i]; + nfapi_dl_config_request_pdu_t *pdu = &dl_config_req_body->dl_config_pdu_list[i]; + if (pdu->pdu_type == NFAPI_DL_CONFIG_DCI_DL_PDU_TYPE) { i += 1; AssertFatal(i < dl_config_req->dl_config_request_body.number_pdu, "Need PDU following DCI at index %d, but not found\n", i); nfapi_dl_config_request_pdu_t *dlsch = &dl_config_req_body->dl_config_pdu_list[i]; + if (dlsch->pdu_type != NFAPI_DL_CONFIG_DLSCH_PDU_TYPE) { LOG_E(MAC, "expected DLSCH PDU at index %d\n", i); continue; } + dl_config_req_UE_MAC_dci(NFAPI_SFNSF2SFN(dl_config_req->sfn_sf), NFAPI_SFNSF2SF(dl_config_req->sfn_sf), pdu, @@ -1529,8 +1499,9 @@ static void *UE_phy_stub_single_thread_rxn_txnp4(void *arg) if (hi_dci0_req) { nfapi_hi_dci0_request_body_t *hi_dci0_body = &hi_dci0_req->hi_dci0_request_body; + for (int i = 0; i < hi_dci0_body->number_of_dci + hi_dci0_body->number_of_hi; i++) { - nfapi_hi_dci0_request_pdu_t* pdu = &hi_dci0_body->hi_dci0_pdu_list[i]; + nfapi_hi_dci0_request_pdu_t *pdu = &hi_dci0_body->hi_dci0_pdu_list[i]; hi_dci0_req_UE_MAC(NFAPI_SFNSF2SFN(hi_dci0_req->sfn_sf), NFAPI_SFNSF2SF(hi_dci0_req->sfn_sf), pdu, @@ -1598,44 +1569,41 @@ static void *UE_phy_stub_single_thread_rxn_txnp4(void *arg) if ((subframe_select( &UE->frame_parms, proc->subframe_tx) == SF_UL) || (UE->frame_parms.frame_type == FDD) ) - if (UE->mode != loop_through_memory) { - // We make the start of RA between consecutive UEs differ by 20 frames - //if ((UE_mac_inst[Mod_id].UE_mode[0] == PRACH && Mod_id == 0) || (UE_mac_inst[Mod_id].UE_mode[0] == PRACH && Mod_id>0 && proc->frame_rx >= UE_mac_inst[Mod_id-1].ra_frame + 20) ) { - if (UE_mac_inst[ue_Mod_id].UE_mode[0] == PRACH && ue_Mod_id == next_Mod_id) { - next_ra_frame++; - if(next_ra_frame > 500) { - // check if we have PRACH opportunity - if (is_prach_subframe(&UE->frame_parms,proc->frame_tx, proc->subframe_tx) && UE_mac_inst[ue_Mod_id].SI_Decoded == 1) { - // The one working strangely... - //if (is_prach_subframe(&UE->frame_parms,proc->frame_tx, proc->subframe_tx && Mod_id == (module_id_t) init_ra_UE) ) { - PRACH_RESOURCES_t *prach_resources = ue_get_rach(ue_Mod_id, 0, proc->frame_tx, 0, proc->subframe_tx); + // We make the start of RA between consecutive UEs differ by 20 frames + //if ((UE_mac_inst[Mod_id].UE_mode[0] == PRACH && Mod_id == 0) || (UE_mac_inst[Mod_id].UE_mode[0] == PRACH && Mod_id>0 && proc->frame_rx >= UE_mac_inst[Mod_id-1].ra_frame + 20) ) { + if (UE_mac_inst[ue_Mod_id].UE_mode[0] == PRACH && ue_Mod_id == next_Mod_id) { + next_ra_frame++; - if(prach_resources!=NULL ) { - UE_mac_inst[ue_Mod_id].ra_frame = proc->frame_rx; - LOG_D(MAC, "UE_phy_stub_thread_rxn_txnp4 before RACH, Mod_id: %d frame %d subframe %d\n", ue_Mod_id,proc->frame_tx, proc->subframe_tx); - fill_rach_indication_UE_MAC(ue_Mod_id, proc->frame_tx,proc->subframe_tx, UL_INFO, prach_resources->ra_PreambleIndex, prach_resources->ra_RNTI); - Msg1_transmitted(ue_Mod_id, 0, proc->frame_tx, 0); - UE_mac_inst[ue_Mod_id].UE_mode[0] = RA_RESPONSE; - next_Mod_id = ue_Mod_id + 1; - //next_ra_frame = (proc->frame_rx + 20)%1000; - next_ra_frame = 0; - } + if(next_ra_frame > 500) { + // check if we have PRACH opportunity + if (is_prach_subframe(&UE->frame_parms,proc->frame_tx, proc->subframe_tx) && UE_mac_inst[ue_Mod_id].SI_Decoded == 1) { + // The one working strangely... + //if (is_prach_subframe(&UE->frame_parms,proc->frame_tx, proc->subframe_tx && Mod_id == (module_id_t) init_ra_UE) ) { + PRACH_RESOURCES_t *prach_resources = ue_get_rach(ue_Mod_id, 0, proc->frame_tx, 0, proc->subframe_tx); - //ue_prach_procedures(ue,proc,eNB_id,abstraction_flag,mode); + if(prach_resources!=NULL ) { + UE_mac_inst[ue_Mod_id].ra_frame = proc->frame_rx; + LOG_D(MAC, "UE_phy_stub_thread_rxn_txnp4 before RACH, Mod_id: %d frame %d subframe %d\n", ue_Mod_id,proc->frame_tx, proc->subframe_tx); + fill_rach_indication_UE_MAC(ue_Mod_id, proc->frame_tx,proc->subframe_tx, UL_INFO, prach_resources->ra_PreambleIndex, prach_resources->ra_RNTI); + Msg1_transmitted(ue_Mod_id, 0, proc->frame_tx, 0); + UE_mac_inst[ue_Mod_id].UE_mode[0] = RA_RESPONSE; + next_Mod_id = ue_Mod_id + 1; + //next_ra_frame = (proc->frame_rx + 20)%1000; + next_ra_frame = 0; } + + //ue_prach_procedures(ue,proc,eNB_id,abstraction_flag,mode); } - } // mode is PRACH - - // Substitute call to phy_procedures Tx with call to phy_stub functions in order to trigger - // UE Tx procedures directly at the MAC layer, based on the received ul_config requests from the vnf (eNB). - // Generate UL_indications which correspond to UL traffic. - if(ul_config_req!=NULL) { //&& UE_mac_inst[Mod_id].ul_config_req->ul_config_request_body.ul_config_pdu_list != NULL){ - ul_config_req_UE_MAC(ul_config_req, timer_frame, timer_subframe, ue_Mod_id); } - } + } // mode is PRACH - phy_procedures_UE_SL_RX(UE,proc); + // Substitute call to phy_procedures Tx with call to phy_stub functions in order to trigger + // UE Tx procedures directly at the MAC layer, based on the received ul_config requests from the vnf (eNB). + // Generate UL_indications which correspond to UL traffic. + if(ul_config_req!=NULL) { //&& UE_mac_inst[Mod_id].ul_config_req->ul_config_request_body.ul_config_pdu_list != NULL){ + ul_config_req_UE_MAC(ul_config_req, timer_frame, timer_subframe, ue_Mod_id); + } } //for (Mod_id=0; Mod_idnum_single_thread[ue_thread_id] = -1; @@ -1715,6 +1683,7 @@ static void *UE_phy_stub_single_thread_rxn_txnp4(void *arg) tx_req_pdu_list[i].segments[j].segment_data = NULL; } } + tx_req_num_elems = 0; free(tx_req_pdu_list); tx_req_pdu_list = NULL; @@ -1758,7 +1727,6 @@ static void *UE_phy_stub_single_thread_rxn_txnp4(void *arg) free(UL_INFO); UL_INFO = NULL; #endif // disabled UE_phy_stub_single_thread_rxn_txnp4 - // thread finished free(arg); return NULL; @@ -1773,9 +1741,8 @@ static void *UE_phy_stub_single_thread_rxn_txnp4(void *arg) * \returns a pointer to an int. The storage is not on the heap and must not be freed. */ -static void *UE_phy_stub_thread_rxn_txnp4(void *arg) -{ - #if 0 +static void *UE_phy_stub_thread_rxn_txnp4(void *arg) { +#if 0 thread_top_init("UE_phy_stub_thread_rxn_txnp4",1,870000L,1000000L,1000000L); module_id_t Mod_id = 0; static __thread int UE_thread_rxtx_retval; @@ -1886,45 +1853,42 @@ static void *UE_phy_stub_thread_rxn_txnp4(void *arg) if ((subframe_select( &UE->frame_parms, proc->subframe_tx) == SF_UL) || (UE->frame_parms.frame_type == FDD) ) - if (UE->mode != loop_through_memory) { - if ((UE_mac_inst[Mod_id].UE_mode[0] == PRACH) ) { - // check if we have PRACH opportunity - if (is_prach_subframe(&UE->frame_parms,proc->frame_tx, proc->subframe_tx)) { - PRACH_RESOURCES_t *prach_resources = ue_get_rach(Mod_id, 0, proc->frame_tx, 0, proc->subframe_tx); + if ((UE_mac_inst[Mod_id].UE_mode[0] == PRACH) ) { + // check if we have PRACH opportunity + if (is_prach_subframe(&UE->frame_parms,proc->frame_tx, proc->subframe_tx)) { + PRACH_RESOURCES_t *prach_resources = ue_get_rach(Mod_id, 0, proc->frame_tx, 0, proc->subframe_tx); - if(prach_resources!=NULL) { - fill_rach_indication_UE_MAC(Mod_id, proc->frame_tx,proc->subframe_tx, UL_INFO, prach_resources->ra_PreambleIndex, prach_resources->ra_RNTI); - Msg1_transmitted(Mod_id, 0, proc->frame_tx, 0); - UE_mac_inst[Mod_id].UE_mode[0] = RA_RESPONSE; - } - - //ue_prach_procedures(ue,proc,eNB_id,abstraction_flag,mode); - } - } // mode is PRACH - - // Substitute call to phy_procedures Tx with call to phy_stub functions in order to trigger - // UE Tx procedures directly at the MAC layer, based on the received ul_config requests from the vnf (eNB). - // Generate UL_indications which correspond to UL traffic. - if(ul_config_req!= NULL && ul_config_req->ul_config_request_body.ul_config_pdu_list != NULL) { - //LOG_I(MAC, "UE_phy_stub_thread_rxn_txnp4 ul_config_req is not NULL \n"); - ul_config_req_UE_MAC(ul_config_req, timer_frame, timer_subframe, Mod_id); - - if(ul_config_req->ul_config_request_body.ul_config_pdu_list != NULL) { - free(ul_config_req->ul_config_request_body.ul_config_pdu_list); - ul_config_req->ul_config_request_body.ul_config_pdu_list = NULL; + if(prach_resources!=NULL) { + fill_rach_indication_UE_MAC(Mod_id, proc->frame_tx,proc->subframe_tx, UL_INFO, prach_resources->ra_PreambleIndex, prach_resources->ra_RNTI); + Msg1_transmitted(Mod_id, 0, proc->frame_tx, 0); + UE_mac_inst[Mod_id].UE_mode[0] = RA_RESPONSE; } - free(ul_config_req); - ul_config_req = NULL; - } else if(ul_config_req!=NULL) { - free(ul_config_req); - ul_config_req = NULL; + //ue_prach_procedures(ue,proc,eNB_id,abstraction_flag,mode); } + } // mode is PRACH + + // Substitute call to phy_procedures Tx with call to phy_stub functions in order to trigger + // UE Tx procedures directly at the MAC layer, based on the received ul_config requests from the vnf (eNB). + // Generate UL_indications which correspond to UL traffic. + if(ul_config_req!= NULL && ul_config_req->ul_config_request_body.ul_config_pdu_list != NULL) { + //LOG_I(MAC, "UE_phy_stub_thread_rxn_txnp4 ul_config_req is not NULL \n"); + ul_config_req_UE_MAC(ul_config_req, timer_frame, timer_subframe, Mod_id); + + if(ul_config_req->ul_config_request_body.ul_config_pdu_list != NULL) { + free(ul_config_req->ul_config_request_body.ul_config_pdu_list); + ul_config_req->ul_config_request_body.ul_config_pdu_list = NULL; } - phy_procedures_UE_SL_RX(UE,proc); + free(ul_config_req); + ul_config_req = NULL; + } else if(ul_config_req!=NULL) { + free(ul_config_req); + ul_config_req = NULL; + } } - #endif // disabled + +#endif // disabled // thread finished free(arg); return NULL; //return &UE_thread_rxtx_retval; @@ -1944,22 +1908,21 @@ void write_dummy(PHY_VARS_UE *UE, openair0_timestamp timestamp) { // we have to write to tell explicitly to the eNB, else it will wait for us forever // we write the next subframe (always write in future of what we received) // - struct complex16 v= {0}; + c16_t v= {0}; void *samplesVoid[UE->frame_parms.nb_antennas_tx]; - + for ( int i=0; i < UE->frame_parms.nb_antennas_tx; i++) samplesVoid[i]=(void *)&v; - + AssertFatal( 1 == UE->rfdevice.trx_write_func(&UE->rfdevice, - timestamp+2*UE->frame_parms.samples_per_tti, - samplesVoid, - 1, - UE->frame_parms.nb_antennas_tx, - 1),""); + timestamp+2*UE->frame_parms.samples_per_tti, + samplesVoid, + 1, + UE->frame_parms.nb_antennas_tx, + 1),""); } -void *UE_thread(void *arg) -{ +void *UE_thread(void *arg) { PHY_VARS_UE *UE = (PHY_VARS_UE *) arg; // int tx_enabled = 0; int dummy_rx[UE->frame_parms.nb_antennas_rx][UE->frame_parms.samples_per_tti] __attribute__((aligned(32))); @@ -1972,10 +1935,11 @@ void *UE_thread(void *arg) int ret; cpu_set_t cpuset; CPU_ZERO(&cpuset); + if ( threads.main != -1 ) CPU_SET(threads.main, &cpuset); - init_thread(100000, 500000, FIFO_PRIORITY, &cpuset, "UHD Threads"); + init_thread(100000, 500000, FIFO_PRIORITY, &cpuset, "UHD Threads"); /* while (sync_var<0) pthread_cond_wait(&sync_cond, &sync_mutex); @@ -1998,46 +1962,49 @@ void *UE_thread(void *arg) log_scheduler(__func__); while (!oai_exit) { - if (IS_SOFTMODEM_BASICSIM) - while (!(UE->proc.instance_cnt_synch < 0)) { - printf("ue sync not ready\n"); - usleep(500*1000); - } - AssertFatal ( 0== pthread_mutex_lock(&UE->proc.mutex_synch), ""); int instance_cnt_synch = UE->proc.instance_cnt_synch; int is_synchronized = UE->is_synchronized; AssertFatal ( 0== pthread_mutex_unlock(&UE->proc.mutex_synch), ""); - + if (is_synchronized == 0) { if (instance_cnt_synch < 0) { // we can invoke the synch + + // we shift in time flow because the UE doesn't detect sync when frame alignment is not easy + for (int i=0; iframe_parms.nb_antennas_rx; i++) + rxp[i] = (void *)&dummy_rx[i][0]; + + UE->rfdevice.trx_read_func(&UE->rfdevice, + ×tamp, + rxp, + UE->frame_parms.samples_per_tti/2, + UE->frame_parms.nb_antennas_rx); + // grab 10 ms of signal and wakeup synch thread - if (UE->mode != loop_through_memory) { - if (IS_SOFTMODEM_RFSIM ) { - for(int sf=0; sf<10; sf++) { - for (int i=0; iframe_parms.nb_antennas_rx; i++) - rxp[i] = (void *)&UE->common_vars.rxdata[i][UE->frame_parms.samples_per_tti*sf]; - - AssertFatal(UE->frame_parms.samples_per_tti == UE->rfdevice.trx_read_func(&UE->rfdevice, - ×tamp, - rxp, - UE->frame_parms.samples_per_tti, - UE->frame_parms.nb_antennas_rx), ""); - write_dummy(UE, timestamp); - } - } else { - for (int i=0; iframe_parms.nb_antennas_rx; i++) - rxp[i] = (void *)&UE->common_vars.rxdata[i][0]; - - AssertFatal( UE->frame_parms.samples_per_tti*10 == - UE->rfdevice.trx_read_func(&UE->rfdevice, - ×tamp, - rxp, - UE->frame_parms.samples_per_tti*10, - UE->frame_parms.nb_antennas_rx), ""); - } - } + if (IS_SOFTMODEM_RFSIM ) { + for(int sf=0; sf<10; sf++) { + for (int i=0; iframe_parms.nb_antennas_rx; i++) + rxp[i] = (void *)&UE->common_vars.rxdata[i][UE->frame_parms.samples_per_tti*sf]; + + AssertFatal(UE->frame_parms.samples_per_tti == UE->rfdevice.trx_read_func(&UE->rfdevice, + ×tamp, + rxp, + UE->frame_parms.samples_per_tti, + UE->frame_parms.nb_antennas_rx), ""); + write_dummy(UE, timestamp); + } + } else { + for (int i=0; iframe_parms.nb_antennas_rx; i++) + rxp[i] = (void *)&UE->common_vars.rxdata[i][0]; + + AssertFatal( UE->frame_parms.samples_per_tti*10 == + UE->rfdevice.trx_read_func(&UE->rfdevice, + ×tamp, + rxp, + UE->frame_parms.samples_per_tti*10, + UE->frame_parms.nb_antennas_rx), ""); + } AssertFatal ( 0== pthread_mutex_lock(&UE->proc.mutex_synch), ""); instance_cnt_synch = ++UE->proc.instance_cnt_synch; @@ -2051,69 +2018,62 @@ void *UE_thread(void *arg) AssertFatal ( 0== pthread_mutex_unlock(&UE->proc.mutex_synch), ""); } else { -#if OAISIM - (void)dummy_rx; /* avoid gcc warnings */ - usleep(500); -#else // grab 10 ms of signal into dummy buffer - if (UE->mode != loop_through_memory) { - for (int i=0; iframe_parms.nb_antennas_rx; i++) - rxp[i] = (void *)&dummy_rx[i][0]; + for (int i=0; iframe_parms.nb_antennas_rx; i++) + rxp[i] = (void *)&dummy_rx[i][0]; - for (int sf=0; sf<10; sf++) { - // printf("Reading dummy sf %d\n",sf); - UE->rfdevice.trx_read_func(&UE->rfdevice, - ×tamp, - rxp, - UE->frame_parms.samples_per_tti, - UE->frame_parms.nb_antennas_rx); - if (IS_SOFTMODEM_RFSIM ) - write_dummy(UE, timestamp); - } - } -#endif + for (int sf=0; sf<10; sf++) { + // printf("Reading dummy sf %d\n",sf); + UE->rfdevice.trx_read_func(&UE->rfdevice, + ×tamp, + rxp, + UE->frame_parms.samples_per_tti, + UE->frame_parms.nb_antennas_rx); + + if (IS_SOFTMODEM_RFSIM ) + write_dummy(UE, timestamp); + } } } // UE->is_synchronized==0 else { if (start_rx_stream==0) { start_rx_stream=1; - if (UE->mode != loop_through_memory) { - if (UE->no_timing_correction==0) { - LOG_I(PHY,"Resynchronizing RX by %d samples (mode = %d)\n",UE->rx_offset,UE->mode); - while ( UE->rx_offset ) { - size_t s=min(UE->rx_offset,UE->frame_parms.samples_per_tti); - AssertFatal(s == UE->rfdevice.trx_read_func(&UE->rfdevice, - ×tamp, - (void **)UE->common_vars.rxdata, - s, - UE->frame_parms.nb_antennas_rx),""); - if (IS_SOFTMODEM_RFSIM ) - write_dummy(UE, timestamp); - UE->rx_offset-=s; - } + if (UE->no_timing_correction==0) { + LOG_I(PHY,"Resynchronizing RX by %d samples (mode = %d)\n",UE->rx_offset,UE->mode); + + while ( UE->rx_offset ) { + size_t s=min(UE->rx_offset,UE->frame_parms.samples_per_tti); + AssertFatal(s == UE->rfdevice.trx_read_func(&UE->rfdevice, + ×tamp, + (void **)UE->common_vars.rxdata, + s, + UE->frame_parms.nb_antennas_rx),""); + + if (IS_SOFTMODEM_RFSIM ) + write_dummy(UE, timestamp); + + UE->rx_offset-=s; } + } - UE->rx_offset=0; - UE->time_sync_cell=0; + UE->rx_offset=0; + UE->time_sync_cell=0; - //UE->proc.proc_rxtx[0].frame_rx++; - //UE->proc.proc_rxtx[1].frame_rx++; - for (th_id=0; th_id < RX_NB_TH; th_id++) { - UE->proc.proc_rxtx[th_id].frame_rx++; - } + //UE->proc.proc_rxtx[0].frame_rx++; + //UE->proc.proc_rxtx[1].frame_rx++; + for (th_id=0; th_id < RX_NB_TH; th_id++) { + UE->proc.proc_rxtx[th_id].frame_rx++; + } - // read in first symbol - AssertFatal (UE->frame_parms.ofdm_symbol_size+UE->frame_parms.nb_prefix_samples0 == - UE->rfdevice.trx_read_func(&UE->rfdevice, - ×tamp, - (void **)UE->common_vars.rxdata, - UE->frame_parms.ofdm_symbol_size+UE->frame_parms.nb_prefix_samples0, - UE->frame_parms.nb_antennas_rx),""); - slot_fep(UE,0, 0, 0, 0, 0); - } //UE->mode != loop_through_memory - else - rt_sleep_ns(1000*1000); + // read in first symbol + AssertFatal (UE->frame_parms.ofdm_symbol_size+UE->frame_parms.nb_prefix_samples0 == + UE->rfdevice.trx_read_func(&UE->rfdevice, + ×tamp, + (void **)UE->common_vars.rxdata, + UE->frame_parms.ofdm_symbol_size+UE->frame_parms.nb_prefix_samples0, + UE->frame_parms.nb_antennas_rx),""); + slot_fep(UE,0, 0, 0, 0, 0); } else { sub_frame++; sub_frame%=10; @@ -2121,7 +2081,7 @@ void *UE_thread(void *arg) // update thread index for received subframe UE->current_thread_id[sub_frame] = thread_idx; - if (IS_SOFTMODEM_BASICSIM || IS_SOFTMODEM_RFSIM ) { + if (IS_SOFTMODEM_RFSIM ) { int t; for (t = 0; t < 2; t++) { @@ -2132,7 +2092,8 @@ void *UE_thread(void *arg) pthread_mutex_unlock(&proc->mutex_rxtx); } - usleep(300); + + usleep(300); } LOG_D(PHY,"Process Subframe %d thread Idx %d \n", sub_frame, UE->current_thread_id[sub_frame]); @@ -2141,130 +2102,129 @@ void *UE_thread(void *arg) if(thread_idx>=RX_NB_TH) thread_idx = 0; - if (UE->mode != loop_through_memory) { - for (i=0; iframe_parms.nb_antennas_rx; i++) - rxp[i] = (void *)&UE->common_vars.rxdata[i][UE->frame_parms.ofdm_symbol_size+ - UE->frame_parms.nb_prefix_samples0+ - sub_frame*UE->frame_parms.samples_per_tti]; + for (i=0; iframe_parms.nb_antennas_rx; i++) + rxp[i] = (void *)&UE->common_vars.rxdata[i][UE->frame_parms.ofdm_symbol_size+ + UE->frame_parms.nb_prefix_samples0+ + sub_frame*UE->frame_parms.samples_per_tti]; - for (i=0; iframe_parms.nb_antennas_tx; i++) - txp[i] = (void *)&UE->common_vars.txdata[i][((sub_frame+2)%10)*UE->frame_parms.samples_per_tti]; + for (i=0; iframe_parms.nb_antennas_tx; i++) + txp[i] = (void *)&UE->common_vars.txdata[i][((sub_frame+2)%10)*UE->frame_parms.samples_per_tti]; - int readBlockSize, writeBlockSize; + int readBlockSize, writeBlockSize; - if (sub_frame<9) { - readBlockSize=UE->frame_parms.samples_per_tti; - writeBlockSize=UE->frame_parms.samples_per_tti; - } else { - // set TO compensation to zero - UE->rx_offset_diff = 0; - - // compute TO compensation that should be applied for this frame - - if (UE->no_timing_correction == 0) { - if ( UE->rx_offset < 5*UE->frame_parms.samples_per_tti && - UE->rx_offset > 0 ) - UE->rx_offset_diff = -1 ; - - if ( UE->rx_offset > 5*UE->frame_parms.samples_per_tti && - UE->rx_offset < 10*UE->frame_parms.samples_per_tti ) - UE->rx_offset_diff = 1; - } - - LOG_D(PHY,"AbsSubframe %d.%d SET rx_off_diff to %d rx_offset %d \n",proc->frame_rx,sub_frame,UE->rx_offset_diff,UE->rx_offset); - readBlockSize=UE->frame_parms.samples_per_tti - - UE->frame_parms.ofdm_symbol_size - - UE->frame_parms.nb_prefix_samples0 - - UE->rx_offset_diff; - writeBlockSize=UE->frame_parms.samples_per_tti - - UE->rx_offset_diff; - } - - AssertFatal(readBlockSize == - UE->rfdevice.trx_read_func(&UE->rfdevice, - ×tamp, - rxp, - readBlockSize, - UE->frame_parms.nb_antennas_rx),""); - AssertFatal( writeBlockSize == - UE->rfdevice.trx_write_func(&UE->rfdevice, - timestamp+ - (2*UE->frame_parms.samples_per_tti) - - UE->frame_parms.ofdm_symbol_size-UE->frame_parms.nb_prefix_samples0 - - openair0_cfg[0].tx_sample_advance, - txp, - writeBlockSize, - UE->frame_parms.nb_antennas_tx, - 1),""); - - if( sub_frame==9) { - // read in first symbol of next frame and adjust for timing drift - int first_symbols=writeBlockSize-readBlockSize; - - if ( first_symbols > 0 ) - AssertFatal(first_symbols == - UE->rfdevice.trx_read_func(&UE->rfdevice, - ×tamp1, - (void **)UE->common_vars.rxdata, - first_symbols, - UE->frame_parms.nb_antennas_rx),""); - - if ( first_symbols <0 ) - LOG_E(PHY,"can't compensate: diff =%d\n", first_symbols); - } - - /* no timeout in IS_SOFTMODEM_BASICSIM or IS_SOFTMODEM_RFSIM mode */ - if (IS_SOFTMODEM_BASICSIM || IS_SOFTMODEM_RFSIM) { - ret = pthread_mutex_lock(&proc->mutex_rxtx); - } else { - struct timespec tv; - if (clock_gettime(CLOCK_REALTIME, &tv) != 0) { - perror("clock_gettime"); - exit(1); - } - tv.tv_nsec += 10*1000; - if (tv.tv_nsec >= 1000 * 1000 * 1000) { - tv.tv_sec++; - tv.tv_nsec -= 1000 * 1000 * 1000; - } - ret = pthread_mutex_timedlock(&proc->mutex_rxtx, &tv); - } - - // operate on thread sf mod 2 - if (ret != 0) { - if (ret == ETIMEDOUT) { - LOG_E(PHY,"Missed real time\n"); - continue; - } else { - LOG_E(PHY,"System error %s (%d)\n",strerror(errno),errno); - abort(); - } - } - - // usleep(3000); - if(sub_frame == 0) { - //UE->proc.proc_rxtx[0].frame_rx++; - //UE->proc.proc_rxtx[1].frame_rx++; - for (th_id=0; th_id < RX_NB_TH; th_id++) { - UE->proc.proc_rxtx[th_id].frame_rx++; - } - } - - proc->subframe_rx=sub_frame; - proc->subframe_tx=(sub_frame+4)%10; - proc->frame_tx = proc->frame_rx + (proc->subframe_rx>5?1:0); - proc->timestamp_tx = timestamp+ - (4*UE->frame_parms.samples_per_tti)- - UE->frame_parms.ofdm_symbol_size-UE->frame_parms.nb_prefix_samples0; - proc->instance_cnt_rxtx++; - LOG_D( PHY, "[SCHED][UE %d] UE RX instance_cnt_rxtx %d subframe %d !!\n", UE->Mod_id, proc->instance_cnt_rxtx,proc->subframe_rx); - T(T_UE_MASTER_TICK, T_INT(0), T_INT(proc->frame_rx%1024), T_INT(proc->subframe_rx)); - AssertFatal (pthread_cond_signal(&proc->cond_rxtx) ==0,""); - AssertFatal(pthread_mutex_unlock(&proc->mutex_rxtx) ==0,""); + if (sub_frame<9) { + readBlockSize=UE->frame_parms.samples_per_tti; + writeBlockSize=UE->frame_parms.samples_per_tti; } else { - printf("Processing subframe %d",proc->subframe_rx); - getchar(); + // set TO compensation to zero + UE->rx_offset_diff = 0; + + // compute TO compensation that should be applied for this frame + + if (UE->no_timing_correction == 0) { + if ( UE->rx_offset < 5*UE->frame_parms.samples_per_tti && + UE->rx_offset > 0 ) + UE->rx_offset_diff = -1 ; + + if ( UE->rx_offset > 5*UE->frame_parms.samples_per_tti && + UE->rx_offset < 10*UE->frame_parms.samples_per_tti ) + UE->rx_offset_diff = 1; + } + + LOG_D(PHY,"AbsSubframe %d.%d SET rx_off_diff to %d rx_offset %d \n",proc->frame_rx,sub_frame,UE->rx_offset_diff,UE->rx_offset); + readBlockSize=UE->frame_parms.samples_per_tti - + UE->frame_parms.ofdm_symbol_size - + UE->frame_parms.nb_prefix_samples0 - + UE->rx_offset_diff; + writeBlockSize=UE->frame_parms.samples_per_tti - + UE->rx_offset_diff; } + + AssertFatal(readBlockSize == + UE->rfdevice.trx_read_func(&UE->rfdevice, + ×tamp, + rxp, + readBlockSize, + UE->frame_parms.nb_antennas_rx),""); + AssertFatal( writeBlockSize == + UE->rfdevice.trx_write_func(&UE->rfdevice, + timestamp+ + (2*UE->frame_parms.samples_per_tti) - + UE->frame_parms.ofdm_symbol_size-UE->frame_parms.nb_prefix_samples0 - + openair0_cfg[0].tx_sample_advance, + txp, + writeBlockSize, + UE->frame_parms.nb_antennas_tx, + 1),""); + + if( sub_frame==9) { + // read in first symbol of next frame and adjust for timing drift + int first_symbols=writeBlockSize-readBlockSize; + + if ( first_symbols > 0 ) + AssertFatal(first_symbols == + UE->rfdevice.trx_read_func(&UE->rfdevice, + ×tamp1, + (void **)UE->common_vars.rxdata, + first_symbols, + UE->frame_parms.nb_antennas_rx),""); + + if ( first_symbols <0 ) + LOG_E(PHY,"can't compensate: diff =%d\n", first_symbols); + } + + /* no timeout in IS_SOFTMODEM_RFSIM mode */ + if (IS_SOFTMODEM_RFSIM) { + ret = pthread_mutex_lock(&proc->mutex_rxtx); + } else { + struct timespec tv; + + if (clock_gettime(CLOCK_REALTIME, &tv) != 0) { + perror("clock_gettime"); + exit(1); + } + + tv.tv_nsec += 10*1000; + + if (tv.tv_nsec >= 1000 * 1000 * 1000) { + tv.tv_sec++; + tv.tv_nsec -= 1000 * 1000 * 1000; + } + + ret = pthread_mutex_timedlock(&proc->mutex_rxtx, &tv); + } + + // operate on thread sf mod 2 + if (ret != 0) { + if (ret == ETIMEDOUT) { + LOG_E(PHY,"Missed real time\n"); + continue; + } else { + LOG_E(PHY,"System error %s (%d)\n",strerror(errno),errno); + abort(); + } + } + + // usleep(3000); + if(sub_frame == 0) { + //UE->proc.proc_rxtx[0].frame_rx++; + //UE->proc.proc_rxtx[1].frame_rx++; + for (th_id=0; th_id < RX_NB_TH; th_id++) { + UE->proc.proc_rxtx[th_id].frame_rx++; + } + } + + proc->subframe_rx=sub_frame; + proc->subframe_tx=(sub_frame+4)%10; + proc->frame_tx = proc->frame_rx + (proc->subframe_rx>5?1:0); + proc->timestamp_tx = timestamp+ + (4*UE->frame_parms.samples_per_tti)- + UE->frame_parms.ofdm_symbol_size-UE->frame_parms.nb_prefix_samples0; + proc->instance_cnt_rxtx++; + LOG_D( PHY, "[SCHED][UE %d] UE RX instance_cnt_rxtx %d subframe %d !!\n", UE->Mod_id, proc->instance_cnt_rxtx,proc->subframe_rx); + T(T_UE_MASTER_TICK, T_INT(0), T_INT(proc->frame_rx%1024), T_INT(proc->subframe_rx)); + AssertFatal (pthread_cond_signal(&proc->cond_rxtx) ==0,""); + AssertFatal(pthread_mutex_unlock(&proc->mutex_rxtx) ==0,""); } // start_rx_stream==1 } // UE->is_synchronized==1 } // while !oai_exit @@ -2285,8 +2245,7 @@ void *UE_thread(void *arg) * - UE_thread_dlsch_proc_slot1 * and the locking between them. */ -void init_UE_threads(int inst) -{ +void init_UE_threads(int inst) { struct rx_tx_thread_data *rtd; PHY_VARS_UE *UE; AssertFatal(PHY_vars_UE_g!=NULL,"PHY_vars_UE_g is NULL\n"); @@ -2341,8 +2300,7 @@ void init_UE_threads(int inst) * - UE_thread_dlsch_proc_slot1 * and the locking between them. */ -void init_UE_single_thread_stub(int nb_inst) -{ +void init_UE_single_thread_stub(int nb_inst) { struct rx_tx_thread_data *rtd; PHY_VARS_UE *UE; @@ -2370,8 +2328,8 @@ void init_UE_single_thread_stub(int nb_inst) // In phy_stub_UE mode due to less heavy processing operations we don't need two threads //int nb_threads=RX_NB_TH; int nb_threads=1; + void *(*task_func)(void *); - void* (*task_func)(void*); if (NFAPI_MODE == NFAPI_MODE_STANDALONE_PNF) { task_func = UE_phy_stub_standalone_pnf_task; } else { @@ -2415,8 +2373,7 @@ void init_UE_single_thread_stub(int nb_inst) * - UE_thread_dlsch_proc_slot1 * and the locking between them. */ -void init_UE_threads_stub(int inst) -{ +void init_UE_threads_stub(int inst) { struct rx_tx_thread_data *rtd; PHY_VARS_UE *UE; AssertFatal(PHY_vars_UE_g!=NULL,"PHY_vars_UE_g is NULL\n"); @@ -2453,8 +2410,7 @@ void init_UE_threads_stub(int inst) } -void fill_ue_band_info(void) -{ +void fill_ue_band_info(void) { LTE_UE_EUTRA_Capability_t *UE_EUTRA_Capability = UE_rrc_inst[0].UECap->UE_EUTRA_Capability; int i,j; bands_to_scan.nbands = UE_EUTRA_Capability->rf_Parameters.supportedBandListEUTRA.list.count; @@ -2479,8 +2435,7 @@ void fill_ue_band_info(void) } int setup_ue_buffers(PHY_VARS_UE **phy_vars_ue, - openair0_config_t *openair0_cfg) -{ + openair0_config_t *openair0_cfg) { int i, CC_id; LTE_DL_FRAME_PARMS *frame_parms; @@ -2488,23 +2443,18 @@ int setup_ue_buffers(PHY_VARS_UE **phy_vars_ue, AssertFatal( phy_vars_ue[CC_id] !=0, ""); frame_parms = &(phy_vars_ue[CC_id]->frame_parms); // replace RX signal buffers with mmaped HW versions - rxdata = (int32_t **)malloc16( frame_parms->nb_antennas_rx*sizeof(int32_t *) ); - txdata = (int32_t **)malloc16( frame_parms->nb_antennas_tx*sizeof(int32_t *) ); - for (i=0; inb_antennas_rx; i++) { LOG_I(PHY, "Mapping UE CC_id %d, rx_ant %d, freq %lu on card %d, chain %d\n", CC_id, i, downlink_frequency[CC_id][i], phy_vars_ue[CC_id]->rf_map.card, (phy_vars_ue[CC_id]->rf_map.chain)+i ); free( phy_vars_ue[CC_id]->common_vars.rxdata[i] ); - rxdata[i] = (int32_t *)malloc16_clear( 307200*sizeof(int32_t) ); - phy_vars_ue[CC_id]->common_vars.rxdata[i] = rxdata[i]; // what about the "-N_TA_offset" ? // N_TA offset for TDD + phy_vars_ue[CC_id]->common_vars.rxdata[i] = malloc16_clear( 307200*sizeof(int32_t) ); // what about the "-N_TA_offset" ? // N_TA offset for TDD } for (i=0; inb_antennas_tx; i++) { LOG_I(PHY, "Mapping UE CC_id %d, tx_ant %d, freq %lu on card %d, chain %d\n", CC_id, i, downlink_frequency[CC_id][i], phy_vars_ue[CC_id]->rf_map.card, (phy_vars_ue[CC_id]->rf_map.chain)+i ); free( phy_vars_ue[CC_id]->common_vars.txdata[i] ); - txdata[i] = (int32_t *)malloc16_clear( 307200*sizeof(int32_t) ); - phy_vars_ue[CC_id]->common_vars.txdata[i] = txdata[i]; + phy_vars_ue[CC_id]->common_vars.txdata[i] = malloc16_clear( 307200*sizeof(int32_t) ); } // rxdata[x] points now to the same memory region as phy_vars_ue[CC_id]->common_vars.rxdata[x] @@ -2522,8 +2472,7 @@ int setup_ue_buffers(PHY_VARS_UE **phy_vars_ue, // playing the role of nfapi-pnf. //02/02/2018 -static void *timer_thread( void *param ) -{ +static void *timer_thread( void *param ) { thread_top_init("timer_thread",1,870000L,1000000L,1000000L); timer_subframe =9; timer_frame =1023; @@ -2649,8 +2598,7 @@ static void *timer_thread( void *param ) } -int init_timer_thread(void) -{ +int init_timer_thread(void) { //PHY_VARS_UE *UE=PHY_vars_UE_g[0]; PHY_VARS_UE *UE=PHY_vars_UE_g[0][0]; phy_stub_ticking = (SF_ticking *)malloc(sizeof(SF_ticking)); @@ -2672,8 +2620,7 @@ int init_timer_thread(void) */ int8_t find_dlsch(uint16_t rnti, PHY_VARS_eNB *eNB, - find_type_t type) -{ + find_type_t type) { printf("you cannot read this\n"); abort(); } diff --git a/targets/RT/USER/lte-uesoftmodem.c b/targets/RT/USER/lte-uesoftmodem.c index 2b39bd3f0f..678b6e0401 100644 --- a/targets/RT/USER/lte-uesoftmodem.c +++ b/targets/RT/USER/lte-uesoftmodem.c @@ -276,7 +276,6 @@ uint16_t node_number; static void get_options(void) { int CC_id=0; int tddflag=0; - char *loopfile=NULL; int dumpframe=0; int timingadv=0; uint8_t nfapi_mode = NFAPI_MONOLITHIC; @@ -293,14 +292,6 @@ static void get_options(void) { config_process_cmdline( cmdline_ueparams,sizeof(cmdline_ueparams)/sizeof(paramdef_t),NULL); nfapi_setmode(nfapi_mode); - - if (loopfile != NULL) { - printf("Input file for hardware emulation: %s",loopfile); - mode=loop_through_memory; - input_fd = fopen(loopfile,"r"); - AssertFatal(input_fd != NULL,"Please provide a valid input file\n"); - } - get_softmodem_params()->hw_timing_advance = timingadv; if ( (cmdline_uemodeparams[CMDLINE_CALIBUERX_IDX].paramflags & PARAMFLAG_PARAMSET) != 0) mode = rx_calib_ue; @@ -455,6 +446,7 @@ void init_openair0(LTE_DL_FRAME_PARMS *frame_parms,int rxgain) { openair0_cfg[card].num_rb_dl=frame_parms->N_RB_DL; openair0_cfg[card].clock_source = get_softmodem_params()->clock_source; openair0_cfg[card].time_source = get_softmodem_params()->timing_source; + openair0_cfg[card].tune_offset = get_softmodem_params()->tune_offset; openair0_cfg[card].tx_num_channels=min(2,frame_parms->nb_antennas_tx); openair0_cfg[card].rx_num_channels=min(2,frame_parms->nb_antennas_rx); @@ -473,11 +465,12 @@ void init_openair0(LTE_DL_FRAME_PARMS *frame_parms,int rxgain) { openair0_cfg[card].tx_gain[i] = tx_gain[0][i]; openair0_cfg[card].rx_gain[i] = rxgain - rx_gain_off; openair0_cfg[card].configFilename = get_softmodem_params()->rf_config_file; - printf("Card %d, channel %d, Setting tx_gain %f, rx_gain %f, tx_freq %f, rx_freq %f\n", + printf("Card %d, channel %d, Setting tx_gain %.0f, rx_gain %.0f, tx_freq %.0f, rx_freq %.0f, tune_offset %.0f\n", card,i, openair0_cfg[card].tx_gain[i], openair0_cfg[card].rx_gain[i], openair0_cfg[card].tx_freq[i], - openair0_cfg[card].rx_freq[i]); + openair0_cfg[card].rx_freq[i], + openair0_cfg[card].tune_offset); } if (usrp_args) openair0_cfg[card].sdr_addrs = usrp_args; @@ -519,7 +512,7 @@ int restart_L1L2(module_id_t enb_id) { static void init_pdcp(int ue_id) { uint32_t pdcp_initmask = (!IS_SOFTMODEM_NOS1) ? LINK_ENB_PDCP_TO_GTPV1U_BIT : (LINK_ENB_PDCP_TO_GTPV1U_BIT | PDCP_USE_NETLINK_BIT | LINK_ENB_PDCP_TO_IP_DRIVER_BIT); - if (IS_SOFTMODEM_BASICSIM || IS_SOFTMODEM_RFSIM || (nfapi_getmode()==NFAPI_UE_STUB_PNF)) { + if (IS_SOFTMODEM_RFSIM || (nfapi_getmode()==NFAPI_UE_STUB_PNF)) { pdcp_initmask = pdcp_initmask | UE_NAS_USE_TUN_BIT; }